commit 6077246dc4a0b079fd50f05483a28210e04f6dbd32b6aa66d741b09908983937 Author: Jan Engelhardt Date: Sat Jul 27 03:24:07 2024 +0000 Add ffmpeg-6-CVE-2024-32228-shim-f50382cb.patch, ffmpeg-6-CVE-2024-32228-shim-5d7f234e.patch, ffmpeg-6-CVE-2024-32228-shim-1535d338.patch, ffmpeg-6-CVE-2024-32228.patch, ffmpeg-6-CVE-2024-32230.patch, to fix CVE issues. OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/ffmpeg-6?expand=0&rev=37 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/0001-avcodec-tests-rename-the-bundled-Mesa-AV1-vulkan-vid.patch b/0001-avcodec-tests-rename-the-bundled-Mesa-AV1-vulkan-vid.patch new file mode 100644 index 0000000..7a7eff4 --- /dev/null +++ b/0001-avcodec-tests-rename-the-bundled-Mesa-AV1-vulkan-vid.patch @@ -0,0 +1,992 @@ +From e06ce6d2b45edac4a2df04f304e18d4727417d24 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= +Date: Wed, 14 Feb 2024 22:40:54 +0200 +Subject: [PATCH] {avcodec,tests}: rename the bundled Mesa AV1 vulkan video + headers + +This together with adjusting the inclusion define allows for the +build to not fail with latest Vulkan-Headers that contain the +stabilized Vulkan AV1 decoding definitions. + +Compilation fails currently as the AV1 header is getting included +via hwcontext_vulkan.h -> -> vulkan_core.h, which +finally includes vk_video/vulkan_video_codec_av1std.h and the decode +header, leading to the bundled header to never defining anything +due to the inclusion define being the same. + +This fix is imperfect, as it leads to additional re-definition +warnings for things such as +VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION. , but it is +not clear how to otherwise have the bundled version trump the +actually standardized one for a short-term compilation fix. +--- + libavcodec/Makefile | 4 +- + libavcodec/vulkan_video.h | 4 +- + libavcodec/vulkan_video_codec_av1std.h | 403 ------------------ + libavcodec/vulkan_video_codec_av1std_decode.h | 36 -- + .../vulkan_video_codec_av1std_decode_mesa.h | 36 ++ + libavcodec/vulkan_video_codec_av1std_mesa.h | 403 ++++++++++++++++++ + tests/ref/fate/source | 4 +- + 7 files changed, 445 insertions(+), 445 deletions(-) + delete mode 100644 libavcodec/vulkan_video_codec_av1std.h + delete mode 100644 libavcodec/vulkan_video_codec_av1std_decode.h + create mode 100644 libavcodec/vulkan_video_codec_av1std_decode_mesa.h + create mode 100644 libavcodec/vulkan_video_codec_av1std_mesa.h + +diff --git a/libavcodec/Makefile b/libavcodec/Makefile +index 470d7cb9b1..09ae5270b3 100644 +--- a/libavcodec/Makefile ++++ b/libavcodec/Makefile +@@ -1262,7 +1262,7 @@ SKIPHEADERS += %_tablegen.h \ + aacenc_quantization.h \ + aacenc_quantization_misc.h \ + bitstream_template.h \ +- vulkan_video_codec_av1std.h \ ++ vulkan_video_codec_av1std_mesa.h \ + $(ARCH)/vpx_arith.h \ + + SKIPHEADERS-$(CONFIG_AMF) += amfenc.h +@@ -1285,7 +1285,7 @@ SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h + SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_decode.h vaapi_hevc.h vaapi_encode.h + SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h + SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h +-SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h vulkan_decode.h vulkan_video_codec_av1std_decode.h ++SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h vulkan_decode.h vulkan_video_codec_av1std_decode_mesa.h + SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h v4l2_m2m.h + SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h + +diff --git a/libavcodec/vulkan_video.h b/libavcodec/vulkan_video.h +index b28e3fe0bd..51f44dd543 100644 +--- a/libavcodec/vulkan_video.h ++++ b/libavcodec/vulkan_video.h +@@ -23,8 +23,8 @@ + #include "vulkan.h" + + #include +-#include "vulkan_video_codec_av1std.h" +-#include "vulkan_video_codec_av1std_decode.h" ++#include "vulkan_video_codec_av1std_mesa.h" ++#include "vulkan_video_codec_av1std_decode_mesa.h" + + #define CODEC_VER_MAJ(ver) (ver >> 22) + #define CODEC_VER_MIN(ver) ((ver >> 12) & ((1 << 10) - 1)) +diff --git a/libavcodec/vulkan_video_codec_av1std.h b/libavcodec/vulkan_video_codec_av1std.h +deleted file mode 100644 +index c46236c457..0000000000 +--- a/libavcodec/vulkan_video_codec_av1std.h ++++ /dev/null +@@ -1,403 +0,0 @@ +-/* Copyright 2023 Lynne +- * Copyright 2023 Dave Airlie +- * +- * Licensed under the Apache License, Version 2.0 (the "License"); +- * you may not use this file except in compliance with the License. +- * You may obtain a copy of the License at +- * +- * http://www.apache.org/licenses/LICENSE-2.0 +- * +- * Unless required by applicable law or agreed to in writing, software +- * distributed under the License is distributed on an "AS IS" BASIS, +- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +- * See the License for the specific language governing permissions and +- * limitations under the License. +- */ +- +-#ifndef VULKAN_VIDEO_CODEC_AV1STD_H_ +-#define VULKAN_VIDEO_CODEC_AV1STD_H_ 1 +- +-/* +-** This header is NOT YET generated from the Khronos Vulkan XML API Registry. +-** +-*/ +- +-#ifdef __cplusplus +-extern "C" { +-#endif +-#define vulkan_video_codec_av1std 1 +- +-#define VK_MAKE_VIDEO_STD_VERSION(major, minor, patch) \ +- ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) +-#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_0_1_0 VK_MAKE_VIDEO_STD_VERSION(0, 1, 0) +-#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_0_1_0 +-#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_av1_decode" +- +-typedef enum StdVideoAV1MESAProfile { +- STD_VIDEO_AV1_MESA_PROFILE_MAIN = 0, +- STD_VIDEO_AV1_MESA_PROFILE_HIGH = 1, +- STD_VIDEO_AV1_MESA_PROFILE_PROFESSIONAL = 2, +-} StdVideoAV1MESAProfile; +- +-typedef enum StdVideoAV1MESALevel { +- STD_VIDEO_AV1_MESA_LEVEL_2_0 = 0, +- STD_VIDEO_AV1_MESA_LEVEL_2_1 = 1, +- STD_VIDEO_AV1_MESA_LEVEL_2_2 = 2, +- STD_VIDEO_AV1_MESA_LEVEL_2_3 = 3, +- STD_VIDEO_AV1_MESA_LEVEL_3_0 = 4, +- STD_VIDEO_AV1_MESA_LEVEL_3_1 = 5, +- STD_VIDEO_AV1_MESA_LEVEL_3_2 = 6, +- STD_VIDEO_AV1_MESA_LEVEL_3_3 = 7, +- STD_VIDEO_AV1_MESA_LEVEL_4_0 = 8, +- STD_VIDEO_AV1_MESA_LEVEL_4_1 = 9, +- STD_VIDEO_AV1_MESA_LEVEL_4_2 = 10, +- STD_VIDEO_AV1_MESA_LEVEL_4_3 = 11, +- STD_VIDEO_AV1_MESA_LEVEL_5_0 = 12, +- STD_VIDEO_AV1_MESA_LEVEL_5_1 = 13, +- STD_VIDEO_AV1_MESA_LEVEL_5_2 = 14, +- STD_VIDEO_AV1_MESA_LEVEL_5_3 = 15, +- STD_VIDEO_AV1_MESA_LEVEL_6_0 = 16, +- STD_VIDEO_AV1_MESA_LEVEL_6_1 = 17, +- STD_VIDEO_AV1_MESA_LEVEL_6_2 = 18, +- STD_VIDEO_AV1_MESA_LEVEL_6_3 = 19, +- STD_VIDEO_AV1_MESA_LEVEL_7_0 = 20, +- STD_VIDEO_AV1_MESA_LEVEL_7_1 = 21, +- STD_VIDEO_AV1_MESA_LEVEL_7_2 = 22, +- STD_VIDEO_AV1_MESA_LEVEL_7_3 = 23, +- STD_VIDEO_AV1_MESA_LEVEL_MAX = 31, +-} StdVideoAV1MESALevel; +- +-typedef struct StdVideoAV1MESAFilmGrainFlags { +- uint8_t apply_grain; +- uint8_t chroma_scaling_from_luma; +- uint8_t overlap_flag; +- uint8_t clip_to_restricted_range; +-} StdVideoAV1MESAFilmGrainFlags; +- +-typedef struct StdVideoAV1MESAFilmGrainParameters { +- StdVideoAV1MESAFilmGrainFlags flags; +- uint32_t grain_scaling_minus_8; +- uint32_t ar_coeff_lag; +- uint32_t ar_coeff_shift_minus_6; +- uint32_t grain_scale_shift; +- +- uint16_t grain_seed; +- uint8_t num_y_points; +- uint8_t point_y_value[14]; +- uint8_t point_y_scaling[14]; +- +- uint8_t num_cb_points; +- uint8_t point_cb_value[10]; +- uint8_t point_cb_scaling[10]; +- +- uint8_t num_cr_points; +- uint8_t point_cr_value[10]; +- uint8_t point_cr_scaling[10]; +- +- int8_t ar_coeffs_y_plus_128[24]; +- int8_t ar_coeffs_cb_plus_128[25]; +- int8_t ar_coeffs_cr_plus_128[25]; +- uint8_t cb_mult; +- uint8_t cb_luma_mult; +- uint16_t cb_offset; +- uint8_t cr_mult; +- uint8_t cr_luma_mult; +- uint16_t cr_offset; +-} StdVideoAV1MESAFilmGrainParameters; +- +-typedef struct StdVideoAV1MESAGlobalMotionFlags { +- uint8_t gm_invalid; +-} StdVideoAV1MESAGlobalMotionFlags; +- +-typedef struct StdVideoAV1MESAGlobalMotion { +- StdVideoAV1MESAGlobalMotionFlags flags; +- uint8_t gm_type; +- uint32_t gm_params[6]; +-} StdVideoAV1MESAGlobalMotion; +- +-typedef struct StdVideoAV1MESALoopRestoration { +- uint8_t lr_type[3]; +- uint8_t lr_unit_shift; +- uint8_t lr_uv_shift; +-} StdVideoAV1MESALoopRestoration; +- +-typedef struct StdVideoAV1MESATileInfoFlags { +- uint8_t uniform_tile_spacing_flag; +-} StdVideoAV1MESATileInfoFlags; +- +-typedef struct StdVideoAV1MESATileInfo { +- StdVideoAV1MESATileInfoFlags flags; +- uint8_t tile_cols; +- uint8_t tile_rows; +- uint8_t tile_start_col_sb[64]; +- uint8_t tile_start_row_sb[64]; +- uint8_t width_in_sbs_minus_1[64]; +- uint8_t height_in_sbs_minus_1[64]; +- uint16_t context_update_tile_id; +- uint8_t tile_size_bytes_minus1; +-} StdVideoAV1MESATileInfo; +- +-typedef struct StdVideoAV1MESAQuantizationFlags { +- uint8_t using_qmatrix; +-} StdVideoAV1MESAQuantizationFlags; +- +-typedef struct StdVideoAV1MESAQuantization { +- StdVideoAV1MESAQuantizationFlags flags; +- uint8_t base_q_idx; +- int8_t delta_q_y_dc; +- uint8_t diff_uv_delta; +- int8_t delta_q_u_dc; +- int8_t delta_q_u_ac; +- int8_t delta_q_v_dc; +- int8_t delta_q_v_ac; +- uint8_t qm_y; +- uint8_t qm_u; +- uint8_t qm_v; +-} StdVideoAV1MESAQuantization; +- +-typedef struct StdVideoAV1MESACDEF { +- uint8_t damping_minus_3; +- uint8_t bits; +- uint8_t y_pri_strength[8]; +- uint8_t y_sec_strength[8]; +- uint8_t uv_pri_strength[8]; +- uint8_t uv_sec_strength[8]; +-} StdVideoAV1MESACDEF; +- +-typedef struct StdVideoAV1MESADeltaQFlags { +- uint8_t delta_lf_present; +- uint8_t delta_lf_multi; +-} StdVideoAV1MESADeltaQFlags; +- +-typedef struct StdVideoAV1MESADeltaQ { +- StdVideoAV1MESADeltaQFlags flags; +- uint8_t delta_q_res; +- uint8_t delta_lf_res; +-} StdVideoAV1MESADeltaQ; +- +-typedef struct StdVideoAV1MESASegmentationFlags { +- uint8_t enabled; +- uint8_t update_map; +- uint8_t temporal_update; +- uint8_t update_data; +-} StdVideoAV1MESASegmentationFlags; +- +-typedef struct StdVideoAV1MESASegmentation { +- StdVideoAV1MESASegmentationFlags flags; +- uint8_t feature_enabled_bits[8]; +- int16_t feature_data[8][8]; +-} StdVideoAV1MESASegmentation; +- +-typedef struct StdVideoAV1MESALoopFilterFlags { +- uint8_t delta_enabled; +- uint8_t delta_update; +-} StdVideoAV1MESALoopFilterFlags; +- +-typedef struct StdVideoAV1MESALoopFilter { +- StdVideoAV1MESALoopFilterFlags flags; +- uint8_t level[4]; +- uint8_t sharpness; +- int8_t ref_deltas[8]; +- int8_t mode_deltas[2]; +-} StdVideoAV1MESALoopFilter; +- +-typedef struct StdVideoAV1MESAFrameHeaderFlags { +- uint8_t error_resilient_mode; +- uint8_t disable_cdf_update; +- uint8_t use_superres; +- uint8_t render_and_frame_size_different; +- uint8_t allow_screen_content_tools; +- uint8_t is_filter_switchable; +- uint8_t force_integer_mv; +- uint8_t frame_size_override_flag; +- uint8_t buffer_removal_time_present_flag; +- uint8_t allow_intrabc; +- uint8_t frame_refs_short_signaling; +- uint8_t allow_high_precision_mv; +- uint8_t is_motion_mode_switchable; +- uint8_t use_ref_frame_mvs; +- uint8_t disable_frame_end_update_cdf; +- uint8_t allow_warped_motion; +- uint8_t reduced_tx_set; +- uint8_t reference_select; +- uint8_t skip_mode_present; +- uint8_t delta_q_present; +- uint8_t UsesLr; +-} StdVideoAV1MESAFrameHeaderFlags; +- +-typedef struct StdVideoAV1MESAFrameHeader { +- StdVideoAV1MESAFrameHeaderFlags flags; +- +- uint32_t frame_presentation_time; +- uint32_t display_frame_id; +- uint32_t current_frame_id; +- uint8_t frame_to_show_map_idx; +- uint8_t frame_type; +- uint8_t order_hint; +- uint8_t primary_ref_frame; +- uint16_t frame_width_minus_1; +- uint16_t frame_height_minus_1; +- uint16_t render_width_minus_1; +- uint16_t render_height_minus_1; +- uint8_t coded_denom; +- +- uint8_t refresh_frame_flags; +- uint8_t ref_order_hint[8]; +- int8_t ref_frame_idx[7]; +- uint32_t delta_frame_id_minus1[7]; +- +- uint8_t interpolation_filter; +- uint8_t tx_mode; +- +- StdVideoAV1MESATileInfo tiling; +- StdVideoAV1MESAQuantization quantization; +- StdVideoAV1MESASegmentation segmentation; +- StdVideoAV1MESADeltaQ delta_q; +- StdVideoAV1MESALoopFilter loop_filter; +- StdVideoAV1MESACDEF cdef; +- StdVideoAV1MESALoopRestoration lr; +- StdVideoAV1MESAGlobalMotion global_motion[8]; // One per ref frame +- StdVideoAV1MESAFilmGrainParameters film_grain; +-} StdVideoAV1MESAFrameHeader; +- +-typedef struct StdVideoAV1MESAScreenCoding { +- uint8_t seq_force_screen_content_tools; +-} StdVideoAV1MESAScreenCoding; +- +-typedef struct StdVideoAV1MESATimingInfoFlags { +- uint8_t equal_picture_interval; +-} StdVideoAV1MESATimingInfoFlags; +- +-typedef struct StdVideoAV1MESATimingInfo { +- StdVideoAV1MESATimingInfoFlags flags; +- uint32_t num_units_in_display_tick; +- uint32_t time_scale; +- uint32_t num_ticks_per_picture_minus_1; +-} StdVideoAV1MESATimingInfo; +- +-typedef struct StdVideoAV1MESAColorConfigFlags { +- uint8_t mono_chrome; +- uint8_t color_range; +- uint8_t separate_uv_delta_q; +-} StdVideoAV1MESAColorConfigFlags; +- +-typedef struct StdVideoAV1MESAColorConfig { +- StdVideoAV1MESAColorConfigFlags flags; +- uint8_t bit_depth; +- uint8_t subsampling_x; +- uint8_t subsampling_y; +-} StdVideoAV1MESAColorConfig; +- +-typedef struct StdVideoAV1MESASequenceHeaderFlags { +- uint8_t still_picture; +- uint8_t reduced_still_picture_header; +- uint8_t use_128x128_superblock; +- uint8_t enable_filter_intra; +- uint8_t enable_intra_edge_filter; +- uint8_t enable_interintra_compound; +- uint8_t enable_masked_compound; +- uint8_t enable_warped_motion; +- uint8_t enable_dual_filter; +- uint8_t enable_order_hint; +- uint8_t enable_jnt_comp; +- uint8_t enable_ref_frame_mvs; +- uint8_t frame_id_numbers_present_flag; +- uint8_t enable_superres; +- uint8_t enable_cdef; +- uint8_t enable_restoration; +- uint8_t film_grain_params_present; +- uint8_t timing_info_present_flag; +- uint8_t initial_display_delay_present_flag; +-} StdVideoAV1MESASequenceHeaderFlags; +- +-typedef struct StdVideoAV1MESASequenceHeader { +- StdVideoAV1MESASequenceHeaderFlags flags; +- +- StdVideoAV1MESAProfile seq_profile; +- uint8_t frame_width_bits_minus_1; +- uint8_t frame_height_bits_minus_1; +- uint16_t max_frame_width_minus_1; +- uint16_t max_frame_height_minus_1; +- uint8_t delta_frame_id_length_minus_2; +- uint8_t additional_frame_id_length_minus_1; +- uint8_t order_hint_bits_minus_1; +- uint8_t seq_choose_integer_mv; +- uint8_t seq_force_integer_mv; +- +- StdVideoAV1MESATimingInfo timing_info; +- StdVideoAV1MESAColorConfig color_config; +-} StdVideoAV1MESASequenceHeader; +- +-typedef struct StdVideoAV1MESATile { +- uint16_t tg_start; +- uint16_t tg_end; +- uint16_t row; +- uint16_t column; +- uint32_t size; +- uint32_t offset; +-} StdVideoAV1MESATile; +- +-typedef struct StdVideoAV1MESATileList { +- StdVideoAV1MESATile *tile_list; +- uint32_t nb_tiles; +-} StdVideoAV1MESATileList; +- +-typedef struct VkVideoDecodeAV1PictureInfoMESA { +- VkStructureType sType; +- const void *pNext; +- StdVideoAV1MESAFrameHeader *frame_header; +- StdVideoAV1MESATileList *tile_list; +- uint8_t skip_mode_frame_idx[2]; +-} VkVideoDecodeAV1PictureInfoMESA; +- +-typedef struct VkVideoDecodeAV1DpbSlotInfoMESA { +- VkStructureType sType; +- const void *pNext; +- uint8_t frameIdx; +- uint8_t ref_order_hint[7]; +- uint8_t disable_frame_end_update_cdf; +-} VkVideoDecodeAV1DpbSlotInfoMESA; +- +-typedef struct VkVideoDecodeAV1SessionParametersAddInfoMESA { +- VkStructureType sType; +- const void *pNext; +- StdVideoAV1MESASequenceHeader *sequence_header; +-} VkVideoDecodeAV1SessionParametersAddInfoMESA; +- +-typedef struct VkVideoDecodeAV1SessionParametersCreateInfoMESA { +- VkStructureType sType; +- const void *pNext; +- const VkVideoDecodeAV1SessionParametersAddInfoMESA *pParametersAddInfo; +-} VkVideoDecodeAV1SessionParametersCreateInfoMESA; +- +-typedef struct VkVideoDecodeAV1ProfileInfoMESA { +- VkStructureType sType; +- const void *pNext; +- StdVideoAV1MESAProfile stdProfileIdc; +-} VkVideoDecodeAV1ProfileInfoMESA; +- +-typedef enum VkVideoDecodeAV1CapabilityFlagBitsMESA { +- VK_VIDEO_DECODE_AV1_CAPABILITY_EXTERNAL_FILM_GRAIN_MESA = 0x00000001, +- VK_VIDEO_DECODE_AV1_CAPABILITY_FLAG_BITS_MAX_ENUM_MESA = 0x7FFFFFFF +-} VkVideoDecodeAV1CapabilityFlagBitsMESA; +-typedef VkFlags VkVideoDecodeAV1CapabilityFlagsMESA; +- +-typedef struct VkVideoDecodeAV1CapabilitiesMESA { +- VkStructureType sType; +- const void *pNext; +- VkVideoDecodeAV1CapabilityFlagsMESA flags; +- StdVideoAV1MESALevel maxLevelIdc; +-} VkVideoDecodeAV1CapabilitiesMESA; +- +-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_MESA 1000509000 +-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_MESA 1000509001 +-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_ADD_INFO_MESA 1000509002 +-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_DPB_SLOT_INFO_MESA 1000509003 +-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_MESA 1000509004 +-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_MESA 1000509005 +- +-#ifdef __cplusplus +-} +-#endif +- +-#endif +diff --git a/libavcodec/vulkan_video_codec_av1std_decode.h b/libavcodec/vulkan_video_codec_av1std_decode.h +deleted file mode 100644 +index a697c00593..0000000000 +--- a/libavcodec/vulkan_video_codec_av1std_decode.h ++++ /dev/null +@@ -1,36 +0,0 @@ +-/* Copyright 2023 Lynne +- * Copyright 2023 Dave Airlie +- * +- * Licensed under the Apache License, Version 2.0 (the "License"); +- * you may not use this file except in compliance with the License. +- * You may obtain a copy of the License at +- * +- * http://www.apache.org/licenses/LICENSE-2.0 +- * +- * Unless required by applicable law or agreed to in writing, software +- * distributed under the License is distributed on an "AS IS" BASIS, +- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +- * See the License for the specific language governing permissions and +- * limitations under the License. +- */ +- +-#ifndef VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_ +-#define VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_ 1 +- +-/* +-** This header is NOT YET generated from the Khronos Vulkan XML API Registry. +-** +-*/ +- +-#ifdef __cplusplus +-extern "C" { +-#endif +-#define vulkan_video_codec_av1std_decode 1 +- +- +- +-#ifdef __cplusplus +-} +-#endif +- +-#endif +diff --git a/libavcodec/vulkan_video_codec_av1std_decode_mesa.h b/libavcodec/vulkan_video_codec_av1std_decode_mesa.h +new file mode 100644 +index 0000000000..e2f37b4e6e +--- /dev/null ++++ b/libavcodec/vulkan_video_codec_av1std_decode_mesa.h +@@ -0,0 +1,36 @@ ++/* Copyright 2023 Lynne ++ * Copyright 2023 Dave Airlie ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#ifndef VULKAN_VIDEO_CODEC_AV1STD_DECODE_MESA_H_ ++#define VULKAN_VIDEO_CODEC_AV1STD_DECODE_MESA_H_ 1 ++ ++/* ++** This header is NOT YET generated from the Khronos Vulkan XML API Registry. ++** ++*/ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++#define vulkan_video_codec_av1std_decode 1 ++ ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff --git a/libavcodec/vulkan_video_codec_av1std_mesa.h b/libavcodec/vulkan_video_codec_av1std_mesa.h +new file mode 100644 +index 0000000000..c91589eee2 +--- /dev/null ++++ b/libavcodec/vulkan_video_codec_av1std_mesa.h +@@ -0,0 +1,403 @@ ++/* Copyright 2023 Lynne ++ * Copyright 2023 Dave Airlie ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#ifndef VULKAN_VIDEO_CODEC_AV1STD_MESA_H_ ++#define VULKAN_VIDEO_CODEC_AV1STD_MESA_H_ 1 ++ ++/* ++** This header is NOT YET generated from the Khronos Vulkan XML API Registry. ++** ++*/ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++#define vulkan_video_codec_av1std 1 ++ ++#define VK_MAKE_VIDEO_STD_VERSION(major, minor, patch) \ ++ ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) ++#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_0_1_0 VK_MAKE_VIDEO_STD_VERSION(0, 1, 0) ++#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_0_1_0 ++#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_av1_decode" ++ ++typedef enum StdVideoAV1MESAProfile { ++ STD_VIDEO_AV1_MESA_PROFILE_MAIN = 0, ++ STD_VIDEO_AV1_MESA_PROFILE_HIGH = 1, ++ STD_VIDEO_AV1_MESA_PROFILE_PROFESSIONAL = 2, ++} StdVideoAV1MESAProfile; ++ ++typedef enum StdVideoAV1MESALevel { ++ STD_VIDEO_AV1_MESA_LEVEL_2_0 = 0, ++ STD_VIDEO_AV1_MESA_LEVEL_2_1 = 1, ++ STD_VIDEO_AV1_MESA_LEVEL_2_2 = 2, ++ STD_VIDEO_AV1_MESA_LEVEL_2_3 = 3, ++ STD_VIDEO_AV1_MESA_LEVEL_3_0 = 4, ++ STD_VIDEO_AV1_MESA_LEVEL_3_1 = 5, ++ STD_VIDEO_AV1_MESA_LEVEL_3_2 = 6, ++ STD_VIDEO_AV1_MESA_LEVEL_3_3 = 7, ++ STD_VIDEO_AV1_MESA_LEVEL_4_0 = 8, ++ STD_VIDEO_AV1_MESA_LEVEL_4_1 = 9, ++ STD_VIDEO_AV1_MESA_LEVEL_4_2 = 10, ++ STD_VIDEO_AV1_MESA_LEVEL_4_3 = 11, ++ STD_VIDEO_AV1_MESA_LEVEL_5_0 = 12, ++ STD_VIDEO_AV1_MESA_LEVEL_5_1 = 13, ++ STD_VIDEO_AV1_MESA_LEVEL_5_2 = 14, ++ STD_VIDEO_AV1_MESA_LEVEL_5_3 = 15, ++ STD_VIDEO_AV1_MESA_LEVEL_6_0 = 16, ++ STD_VIDEO_AV1_MESA_LEVEL_6_1 = 17, ++ STD_VIDEO_AV1_MESA_LEVEL_6_2 = 18, ++ STD_VIDEO_AV1_MESA_LEVEL_6_3 = 19, ++ STD_VIDEO_AV1_MESA_LEVEL_7_0 = 20, ++ STD_VIDEO_AV1_MESA_LEVEL_7_1 = 21, ++ STD_VIDEO_AV1_MESA_LEVEL_7_2 = 22, ++ STD_VIDEO_AV1_MESA_LEVEL_7_3 = 23, ++ STD_VIDEO_AV1_MESA_LEVEL_MAX = 31, ++} StdVideoAV1MESALevel; ++ ++typedef struct StdVideoAV1MESAFilmGrainFlags { ++ uint8_t apply_grain; ++ uint8_t chroma_scaling_from_luma; ++ uint8_t overlap_flag; ++ uint8_t clip_to_restricted_range; ++} StdVideoAV1MESAFilmGrainFlags; ++ ++typedef struct StdVideoAV1MESAFilmGrainParameters { ++ StdVideoAV1MESAFilmGrainFlags flags; ++ uint32_t grain_scaling_minus_8; ++ uint32_t ar_coeff_lag; ++ uint32_t ar_coeff_shift_minus_6; ++ uint32_t grain_scale_shift; ++ ++ uint16_t grain_seed; ++ uint8_t num_y_points; ++ uint8_t point_y_value[14]; ++ uint8_t point_y_scaling[14]; ++ ++ uint8_t num_cb_points; ++ uint8_t point_cb_value[10]; ++ uint8_t point_cb_scaling[10]; ++ ++ uint8_t num_cr_points; ++ uint8_t point_cr_value[10]; ++ uint8_t point_cr_scaling[10]; ++ ++ int8_t ar_coeffs_y_plus_128[24]; ++ int8_t ar_coeffs_cb_plus_128[25]; ++ int8_t ar_coeffs_cr_plus_128[25]; ++ uint8_t cb_mult; ++ uint8_t cb_luma_mult; ++ uint16_t cb_offset; ++ uint8_t cr_mult; ++ uint8_t cr_luma_mult; ++ uint16_t cr_offset; ++} StdVideoAV1MESAFilmGrainParameters; ++ ++typedef struct StdVideoAV1MESAGlobalMotionFlags { ++ uint8_t gm_invalid; ++} StdVideoAV1MESAGlobalMotionFlags; ++ ++typedef struct StdVideoAV1MESAGlobalMotion { ++ StdVideoAV1MESAGlobalMotionFlags flags; ++ uint8_t gm_type; ++ uint32_t gm_params[6]; ++} StdVideoAV1MESAGlobalMotion; ++ ++typedef struct StdVideoAV1MESALoopRestoration { ++ uint8_t lr_type[3]; ++ uint8_t lr_unit_shift; ++ uint8_t lr_uv_shift; ++} StdVideoAV1MESALoopRestoration; ++ ++typedef struct StdVideoAV1MESATileInfoFlags { ++ uint8_t uniform_tile_spacing_flag; ++} StdVideoAV1MESATileInfoFlags; ++ ++typedef struct StdVideoAV1MESATileInfo { ++ StdVideoAV1MESATileInfoFlags flags; ++ uint8_t tile_cols; ++ uint8_t tile_rows; ++ uint8_t tile_start_col_sb[64]; ++ uint8_t tile_start_row_sb[64]; ++ uint8_t width_in_sbs_minus_1[64]; ++ uint8_t height_in_sbs_minus_1[64]; ++ uint16_t context_update_tile_id; ++ uint8_t tile_size_bytes_minus1; ++} StdVideoAV1MESATileInfo; ++ ++typedef struct StdVideoAV1MESAQuantizationFlags { ++ uint8_t using_qmatrix; ++} StdVideoAV1MESAQuantizationFlags; ++ ++typedef struct StdVideoAV1MESAQuantization { ++ StdVideoAV1MESAQuantizationFlags flags; ++ uint8_t base_q_idx; ++ int8_t delta_q_y_dc; ++ uint8_t diff_uv_delta; ++ int8_t delta_q_u_dc; ++ int8_t delta_q_u_ac; ++ int8_t delta_q_v_dc; ++ int8_t delta_q_v_ac; ++ uint8_t qm_y; ++ uint8_t qm_u; ++ uint8_t qm_v; ++} StdVideoAV1MESAQuantization; ++ ++typedef struct StdVideoAV1MESACDEF { ++ uint8_t damping_minus_3; ++ uint8_t bits; ++ uint8_t y_pri_strength[8]; ++ uint8_t y_sec_strength[8]; ++ uint8_t uv_pri_strength[8]; ++ uint8_t uv_sec_strength[8]; ++} StdVideoAV1MESACDEF; ++ ++typedef struct StdVideoAV1MESADeltaQFlags { ++ uint8_t delta_lf_present; ++ uint8_t delta_lf_multi; ++} StdVideoAV1MESADeltaQFlags; ++ ++typedef struct StdVideoAV1MESADeltaQ { ++ StdVideoAV1MESADeltaQFlags flags; ++ uint8_t delta_q_res; ++ uint8_t delta_lf_res; ++} StdVideoAV1MESADeltaQ; ++ ++typedef struct StdVideoAV1MESASegmentationFlags { ++ uint8_t enabled; ++ uint8_t update_map; ++ uint8_t temporal_update; ++ uint8_t update_data; ++} StdVideoAV1MESASegmentationFlags; ++ ++typedef struct StdVideoAV1MESASegmentation { ++ StdVideoAV1MESASegmentationFlags flags; ++ uint8_t feature_enabled_bits[8]; ++ int16_t feature_data[8][8]; ++} StdVideoAV1MESASegmentation; ++ ++typedef struct StdVideoAV1MESALoopFilterFlags { ++ uint8_t delta_enabled; ++ uint8_t delta_update; ++} StdVideoAV1MESALoopFilterFlags; ++ ++typedef struct StdVideoAV1MESALoopFilter { ++ StdVideoAV1MESALoopFilterFlags flags; ++ uint8_t level[4]; ++ uint8_t sharpness; ++ int8_t ref_deltas[8]; ++ int8_t mode_deltas[2]; ++} StdVideoAV1MESALoopFilter; ++ ++typedef struct StdVideoAV1MESAFrameHeaderFlags { ++ uint8_t error_resilient_mode; ++ uint8_t disable_cdf_update; ++ uint8_t use_superres; ++ uint8_t render_and_frame_size_different; ++ uint8_t allow_screen_content_tools; ++ uint8_t is_filter_switchable; ++ uint8_t force_integer_mv; ++ uint8_t frame_size_override_flag; ++ uint8_t buffer_removal_time_present_flag; ++ uint8_t allow_intrabc; ++ uint8_t frame_refs_short_signaling; ++ uint8_t allow_high_precision_mv; ++ uint8_t is_motion_mode_switchable; ++ uint8_t use_ref_frame_mvs; ++ uint8_t disable_frame_end_update_cdf; ++ uint8_t allow_warped_motion; ++ uint8_t reduced_tx_set; ++ uint8_t reference_select; ++ uint8_t skip_mode_present; ++ uint8_t delta_q_present; ++ uint8_t UsesLr; ++} StdVideoAV1MESAFrameHeaderFlags; ++ ++typedef struct StdVideoAV1MESAFrameHeader { ++ StdVideoAV1MESAFrameHeaderFlags flags; ++ ++ uint32_t frame_presentation_time; ++ uint32_t display_frame_id; ++ uint32_t current_frame_id; ++ uint8_t frame_to_show_map_idx; ++ uint8_t frame_type; ++ uint8_t order_hint; ++ uint8_t primary_ref_frame; ++ uint16_t frame_width_minus_1; ++ uint16_t frame_height_minus_1; ++ uint16_t render_width_minus_1; ++ uint16_t render_height_minus_1; ++ uint8_t coded_denom; ++ ++ uint8_t refresh_frame_flags; ++ uint8_t ref_order_hint[8]; ++ int8_t ref_frame_idx[7]; ++ uint32_t delta_frame_id_minus1[7]; ++ ++ uint8_t interpolation_filter; ++ uint8_t tx_mode; ++ ++ StdVideoAV1MESATileInfo tiling; ++ StdVideoAV1MESAQuantization quantization; ++ StdVideoAV1MESASegmentation segmentation; ++ StdVideoAV1MESADeltaQ delta_q; ++ StdVideoAV1MESALoopFilter loop_filter; ++ StdVideoAV1MESACDEF cdef; ++ StdVideoAV1MESALoopRestoration lr; ++ StdVideoAV1MESAGlobalMotion global_motion[8]; // One per ref frame ++ StdVideoAV1MESAFilmGrainParameters film_grain; ++} StdVideoAV1MESAFrameHeader; ++ ++typedef struct StdVideoAV1MESAScreenCoding { ++ uint8_t seq_force_screen_content_tools; ++} StdVideoAV1MESAScreenCoding; ++ ++typedef struct StdVideoAV1MESATimingInfoFlags { ++ uint8_t equal_picture_interval; ++} StdVideoAV1MESATimingInfoFlags; ++ ++typedef struct StdVideoAV1MESATimingInfo { ++ StdVideoAV1MESATimingInfoFlags flags; ++ uint32_t num_units_in_display_tick; ++ uint32_t time_scale; ++ uint32_t num_ticks_per_picture_minus_1; ++} StdVideoAV1MESATimingInfo; ++ ++typedef struct StdVideoAV1MESAColorConfigFlags { ++ uint8_t mono_chrome; ++ uint8_t color_range; ++ uint8_t separate_uv_delta_q; ++} StdVideoAV1MESAColorConfigFlags; ++ ++typedef struct StdVideoAV1MESAColorConfig { ++ StdVideoAV1MESAColorConfigFlags flags; ++ uint8_t bit_depth; ++ uint8_t subsampling_x; ++ uint8_t subsampling_y; ++} StdVideoAV1MESAColorConfig; ++ ++typedef struct StdVideoAV1MESASequenceHeaderFlags { ++ uint8_t still_picture; ++ uint8_t reduced_still_picture_header; ++ uint8_t use_128x128_superblock; ++ uint8_t enable_filter_intra; ++ uint8_t enable_intra_edge_filter; ++ uint8_t enable_interintra_compound; ++ uint8_t enable_masked_compound; ++ uint8_t enable_warped_motion; ++ uint8_t enable_dual_filter; ++ uint8_t enable_order_hint; ++ uint8_t enable_jnt_comp; ++ uint8_t enable_ref_frame_mvs; ++ uint8_t frame_id_numbers_present_flag; ++ uint8_t enable_superres; ++ uint8_t enable_cdef; ++ uint8_t enable_restoration; ++ uint8_t film_grain_params_present; ++ uint8_t timing_info_present_flag; ++ uint8_t initial_display_delay_present_flag; ++} StdVideoAV1MESASequenceHeaderFlags; ++ ++typedef struct StdVideoAV1MESASequenceHeader { ++ StdVideoAV1MESASequenceHeaderFlags flags; ++ ++ StdVideoAV1MESAProfile seq_profile; ++ uint8_t frame_width_bits_minus_1; ++ uint8_t frame_height_bits_minus_1; ++ uint16_t max_frame_width_minus_1; ++ uint16_t max_frame_height_minus_1; ++ uint8_t delta_frame_id_length_minus_2; ++ uint8_t additional_frame_id_length_minus_1; ++ uint8_t order_hint_bits_minus_1; ++ uint8_t seq_choose_integer_mv; ++ uint8_t seq_force_integer_mv; ++ ++ StdVideoAV1MESATimingInfo timing_info; ++ StdVideoAV1MESAColorConfig color_config; ++} StdVideoAV1MESASequenceHeader; ++ ++typedef struct StdVideoAV1MESATile { ++ uint16_t tg_start; ++ uint16_t tg_end; ++ uint16_t row; ++ uint16_t column; ++ uint32_t size; ++ uint32_t offset; ++} StdVideoAV1MESATile; ++ ++typedef struct StdVideoAV1MESATileList { ++ StdVideoAV1MESATile *tile_list; ++ uint32_t nb_tiles; ++} StdVideoAV1MESATileList; ++ ++typedef struct VkVideoDecodeAV1PictureInfoMESA { ++ VkStructureType sType; ++ const void *pNext; ++ StdVideoAV1MESAFrameHeader *frame_header; ++ StdVideoAV1MESATileList *tile_list; ++ uint8_t skip_mode_frame_idx[2]; ++} VkVideoDecodeAV1PictureInfoMESA; ++ ++typedef struct VkVideoDecodeAV1DpbSlotInfoMESA { ++ VkStructureType sType; ++ const void *pNext; ++ uint8_t frameIdx; ++ uint8_t ref_order_hint[7]; ++ uint8_t disable_frame_end_update_cdf; ++} VkVideoDecodeAV1DpbSlotInfoMESA; ++ ++typedef struct VkVideoDecodeAV1SessionParametersAddInfoMESA { ++ VkStructureType sType; ++ const void *pNext; ++ StdVideoAV1MESASequenceHeader *sequence_header; ++} VkVideoDecodeAV1SessionParametersAddInfoMESA; ++ ++typedef struct VkVideoDecodeAV1SessionParametersCreateInfoMESA { ++ VkStructureType sType; ++ const void *pNext; ++ const VkVideoDecodeAV1SessionParametersAddInfoMESA *pParametersAddInfo; ++} VkVideoDecodeAV1SessionParametersCreateInfoMESA; ++ ++typedef struct VkVideoDecodeAV1ProfileInfoMESA { ++ VkStructureType sType; ++ const void *pNext; ++ StdVideoAV1MESAProfile stdProfileIdc; ++} VkVideoDecodeAV1ProfileInfoMESA; ++ ++typedef enum VkVideoDecodeAV1CapabilityFlagBitsMESA { ++ VK_VIDEO_DECODE_AV1_CAPABILITY_EXTERNAL_FILM_GRAIN_MESA = 0x00000001, ++ VK_VIDEO_DECODE_AV1_CAPABILITY_FLAG_BITS_MAX_ENUM_MESA = 0x7FFFFFFF ++} VkVideoDecodeAV1CapabilityFlagBitsMESA; ++typedef VkFlags VkVideoDecodeAV1CapabilityFlagsMESA; ++ ++typedef struct VkVideoDecodeAV1CapabilitiesMESA { ++ VkStructureType sType; ++ const void *pNext; ++ VkVideoDecodeAV1CapabilityFlagsMESA flags; ++ StdVideoAV1MESALevel maxLevelIdc; ++} VkVideoDecodeAV1CapabilitiesMESA; ++ ++#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_MESA 1000509000 ++#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_MESA 1000509001 ++#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_ADD_INFO_MESA 1000509002 ++#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_DPB_SLOT_INFO_MESA 1000509003 ++#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_MESA 1000509004 ++#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_MESA 1000509005 ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff --git a/tests/ref/fate/source b/tests/ref/fate/source +index c575789dd5..8bb58b61f1 100644 +--- a/tests/ref/fate/source ++++ b/tests/ref/fate/source +@@ -23,8 +23,8 @@ compat/djgpp/math.h + compat/float/float.h + compat/float/limits.h + libavcodec/bitstream_template.h +-libavcodec/vulkan_video_codec_av1std.h +-libavcodec/vulkan_video_codec_av1std_decode.h ++libavcodec/vulkan_video_codec_av1std_decode_mesa.h ++libavcodec/vulkan_video_codec_av1std_mesa.h + tools/decode_simple.h + Use of av_clip() where av_clip_uintp2() could be used: + Use of av_clip() where av_clip_intp2() could be used: +-- +2.44.0 + diff --git a/0001-avfilter-af_dialoguenhance-do-output-scaling-once.patch b/0001-avfilter-af_dialoguenhance-do-output-scaling-once.patch new file mode 100644 index 0000000..bfd6f74 --- /dev/null +++ b/0001-avfilter-af_dialoguenhance-do-output-scaling-once.patch @@ -0,0 +1,44 @@ +From f1f973313b6edc460339c2dfa4675dd3ad72fe98 Mon Sep 17 00:00:00 2001 +From: Paul B Mahol +Date: Mon, 27 Nov 2023 11:52:37 +0100 +Subject: [PATCH] avfilter/af_dialoguenhance: do output scaling once +References: https://bugzilla.opensuse.org/1222730 +References: CVE-2023-49528 + +--- + libavfilter/af_dialoguenhance.c | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +diff --git a/libavfilter/af_dialoguenhance.c b/libavfilter/af_dialoguenhance.c +index 5c8614c185..2674313f5c 100644 +--- a/libavfilter/af_dialoguenhance.c ++++ b/libavfilter/af_dialoguenhance.c +@@ -108,7 +108,7 @@ static int config_input(AVFilterLink *inlink) + + generate_window_func(s->window, s->fft_size, WFUNC_SINE, &overlap); + +- iscale = 1.f / s->fft_size; ++ iscale = 1.f / (s->fft_size * 1.5f); + + ret = av_tx_init(&s->tx_ctx[0], &s->tx_fn, AV_TX_FLOAT_RDFT, 0, s->fft_size, &scale, 0); + if (ret < 0) +@@ -296,13 +296,10 @@ static int de_stereo(AVFilterContext *ctx, AVFrame *out) + memcpy(left_osamples, left_in, overlap * sizeof(float)); + memcpy(right_osamples, right_in, overlap * sizeof(float)); + +- // 4 times overlap with squared hanning window results in 1.5 time increase in amplitude +- if (!ctx->is_disabled) { +- for (int i = 0; i < overlap; i++) +- center_osamples[i] = left_out[i] / 1.5f; +- } else { ++ if (ctx->is_disabled) + memset(center_osamples, 0, overlap * sizeof(float)); +- } ++ else ++ memcpy(center_osamples, left_out, overlap * sizeof(float)); + + return 0; + } +-- +2.44.0 + diff --git a/0001-avfilter-af_dialoguenhance-fix-overreads.patch b/0001-avfilter-af_dialoguenhance-fix-overreads.patch new file mode 100644 index 0000000..591bfad --- /dev/null +++ b/0001-avfilter-af_dialoguenhance-fix-overreads.patch @@ -0,0 +1,56 @@ +From 2d9ed64859c9887d0504cd71dbd5b2c15e14251a Mon Sep 17 00:00:00 2001 +From: Paul B Mahol +Date: Sat, 25 Nov 2023 12:54:28 +0100 +Subject: [PATCH] avfilter/af_dialoguenhance: fix overreads +References: https://bugzilla.opensuse.org/1222730 +References: CVE-2023-49528 + +--- + libavfilter/af_dialoguenhance.c | 17 +++++++++-------- + 1 file changed, 9 insertions(+), 8 deletions(-) + +diff --git a/libavfilter/af_dialoguenhance.c b/libavfilter/af_dialoguenhance.c +index 1762ea7cde..29c8ab10a7 100644 +--- a/libavfilter/af_dialoguenhance.c ++++ b/libavfilter/af_dialoguenhance.c +@@ -96,12 +96,12 @@ static int config_input(AVFilterLink *inlink) + if (!s->window) + return AVERROR(ENOMEM); + +- s->in_frame = ff_get_audio_buffer(inlink, s->fft_size * 4); +- s->center_frame = ff_get_audio_buffer(inlink, s->fft_size * 4); +- s->out_dist_frame = ff_get_audio_buffer(inlink, s->fft_size * 4); +- s->windowed_frame = ff_get_audio_buffer(inlink, s->fft_size * 4); +- s->windowed_out = ff_get_audio_buffer(inlink, s->fft_size * 4); +- s->windowed_prev = ff_get_audio_buffer(inlink, s->fft_size * 4); ++ s->in_frame = ff_get_audio_buffer(inlink, (s->fft_size + 2) * 2); ++ s->center_frame = ff_get_audio_buffer(inlink, (s->fft_size + 2) * 2); ++ s->out_dist_frame = ff_get_audio_buffer(inlink, (s->fft_size + 2) * 2); ++ s->windowed_frame = ff_get_audio_buffer(inlink, (s->fft_size + 2) * 2); ++ s->windowed_out = ff_get_audio_buffer(inlink, (s->fft_size + 2) * 2); ++ s->windowed_prev = ff_get_audio_buffer(inlink, (s->fft_size + 2) * 2); + if (!s->in_frame || !s->windowed_out || !s->windowed_prev || + !s->out_dist_frame || !s->windowed_frame || !s->center_frame) + return AVERROR(ENOMEM); +@@ -250,6 +250,7 @@ static int de_stereo(AVFilterContext *ctx, AVFrame *out) + float *right_osamples = (float *)out->extended_data[1]; + float *center_osamples = (float *)out->extended_data[2]; + const int offset = s->fft_size - s->overlap; ++ const int nb_samples = FFMIN(s->overlap, s->in->nb_samples); + float vad; + + // shift in/out buffers +@@ -258,8 +259,8 @@ static int de_stereo(AVFilterContext *ctx, AVFrame *out) + memmove(left_out, &left_out[s->overlap], offset * sizeof(float)); + memmove(right_out, &right_out[s->overlap], offset * sizeof(float)); + +- memcpy(&left_in[offset], left_samples, s->overlap * sizeof(float)); +- memcpy(&right_in[offset], right_samples, s->overlap * sizeof(float)); ++ memcpy(&left_in[offset], left_samples, nb_samples * sizeof(float)); ++ memcpy(&right_in[offset], right_samples, nb_samples * sizeof(float)); + memset(&left_out[offset], 0, s->overlap * sizeof(float)); + memset(&right_out[offset], 0, s->overlap * sizeof(float)); + +-- +2.44.0 + diff --git a/0001-avfilter-af_dialoguenhance-simplify-channels-copy.patch b/0001-avfilter-af_dialoguenhance-simplify-channels-copy.patch new file mode 100644 index 0000000..3f7bebf --- /dev/null +++ b/0001-avfilter-af_dialoguenhance-simplify-channels-copy.patch @@ -0,0 +1,71 @@ +From 4671fb7dfb8e72b228e04f3b81da7f2003c62240 Mon Sep 17 00:00:00 2001 +From: Paul B Mahol +Date: Mon, 27 Nov 2023 00:38:56 +0100 +Subject: [PATCH] avfilter/af_dialoguenhance: simplify channels copy +References: https://bugzilla.opensuse.org/1222730 +References: CVE-2023-49528 + +--- + libavfilter/af_dialoguenhance.c | 32 +++++++++++++++++--------------- + 1 file changed, 17 insertions(+), 15 deletions(-) + +diff --git a/libavfilter/af_dialoguenhance.c b/libavfilter/af_dialoguenhance.c +index 29c8ab10a7..5c8614c185 100644 +--- a/libavfilter/af_dialoguenhance.c ++++ b/libavfilter/af_dialoguenhance.c +@@ -249,20 +249,21 @@ static int de_stereo(AVFilterContext *ctx, AVFrame *out) + float *left_osamples = (float *)out->extended_data[0]; + float *right_osamples = (float *)out->extended_data[1]; + float *center_osamples = (float *)out->extended_data[2]; +- const int offset = s->fft_size - s->overlap; +- const int nb_samples = FFMIN(s->overlap, s->in->nb_samples); ++ const int overlap = s->overlap; ++ const int offset = s->fft_size - overlap; ++ const int nb_samples = FFMIN(overlap, s->in->nb_samples); + float vad; + + // shift in/out buffers +- memmove(left_in, &left_in[s->overlap], offset * sizeof(float)); +- memmove(right_in, &right_in[s->overlap], offset * sizeof(float)); +- memmove(left_out, &left_out[s->overlap], offset * sizeof(float)); +- memmove(right_out, &right_out[s->overlap], offset * sizeof(float)); ++ memmove(left_in, &left_in[overlap], offset * sizeof(float)); ++ memmove(right_in, &right_in[overlap], offset * sizeof(float)); ++ memmove(left_out, &left_out[overlap], offset * sizeof(float)); ++ memmove(right_out, &right_out[overlap], offset * sizeof(float)); + + memcpy(&left_in[offset], left_samples, nb_samples * sizeof(float)); + memcpy(&right_in[offset], right_samples, nb_samples * sizeof(float)); +- memset(&left_out[offset], 0, s->overlap * sizeof(float)); +- memset(&right_out[offset], 0, s->overlap * sizeof(float)); ++ memset(&left_out[offset], 0, overlap * sizeof(float)); ++ memset(&right_out[offset], 0, overlap * sizeof(float)); + + apply_window(s, left_in, windowed_left, 0); + apply_window(s, right_in, windowed_right, 0); +@@ -292,14 +293,15 @@ static int de_stereo(AVFilterContext *ctx, AVFrame *out) + + apply_window(s, windowed_oleft, left_out, 1); + +- for (int i = 0; i < s->overlap; i++) { +- // 4 times overlap with squared hanning window results in 1.5 time increase in amplitude +- if (!ctx->is_disabled) ++ memcpy(left_osamples, left_in, overlap * sizeof(float)); ++ memcpy(right_osamples, right_in, overlap * sizeof(float)); ++ ++ // 4 times overlap with squared hanning window results in 1.5 time increase in amplitude ++ if (!ctx->is_disabled) { ++ for (int i = 0; i < overlap; i++) + center_osamples[i] = left_out[i] / 1.5f; +- else +- center_osamples[i] = 0.f; +- left_osamples[i] = left_in[i]; +- right_osamples[i] = right_in[i]; ++ } else { ++ memset(center_osamples, 0, overlap * sizeof(float)); + } + + return 0; +-- +2.44.0 + diff --git a/0001-avfilter-asrc_afirsrc-fix-by-one-smaller-allocation-.patch b/0001-avfilter-asrc_afirsrc-fix-by-one-smaller-allocation-.patch new file mode 100644 index 0000000..474b5e3 --- /dev/null +++ b/0001-avfilter-asrc_afirsrc-fix-by-one-smaller-allocation-.patch @@ -0,0 +1,28 @@ +From 4adb93dff05dd947878c67784d98c9a4e13b57a7 Mon Sep 17 00:00:00 2001 +From: Paul B Mahol +Date: Thu, 23 Nov 2023 14:58:35 +0100 +Subject: [PATCH] avfilter/asrc_afirsrc: fix by one smaller allocation of + buffer +References: https://bugzilla.opensuse.org/1223215 +References: CVE-2023-49501 + +--- + libavfilter/asrc_afirsrc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libavfilter/asrc_afirsrc.c b/libavfilter/asrc_afirsrc.c +index e2359c159f..ea04c35759 100644 +--- a/libavfilter/asrc_afirsrc.c ++++ b/libavfilter/asrc_afirsrc.c +@@ -480,7 +480,7 @@ static av_cold int config_eq_output(AVFilterLink *outlink) + if (ret < 0) + return ret; + +- s->magnitude = av_calloc(s->nb_magnitude, sizeof(*s->magnitude)); ++ s->magnitude = av_calloc(s->nb_magnitude + 1, sizeof(*s->magnitude)); + if (!s->magnitude) + return AVERROR(ENOMEM); + memcpy(s->magnitude, eq_presets[s->preset].gains, sizeof(*s->magnitude) * s->nb_magnitude); +-- +2.44.0 + diff --git a/0001-avfilter-bwdif-account-for-chroma-sub-sampling-in-mi.patch b/0001-avfilter-bwdif-account-for-chroma-sub-sampling-in-mi.patch new file mode 100644 index 0000000..44941a7 --- /dev/null +++ b/0001-avfilter-bwdif-account-for-chroma-sub-sampling-in-mi.patch @@ -0,0 +1,104 @@ +From 737ede405b11a37fdd61d19cf25df296a0cb0b75 Mon Sep 17 00:00:00 2001 +From: Cosmin Stejerean +Date: Wed, 6 Dec 2023 18:39:32 +0800 +Subject: [PATCH] avfilter/bwdif: account for chroma sub-sampling in min size + calculation +References: https://bugzilla.opensuse.org/1223235 +References: CVE-2023-49502 + +The current logic for detecting frames that are too small for the +algorithm does not account for chroma sub-sampling, and so a sample +where the luma plane is large enough, but the chroma planes are not +will not be rejected. In that event, a heap overflow will occur. + +This change adjusts the logic to consider the chroma planes and makes +the change to all three bwdif implementations. + +Fixes #10688 + +Signed-off-by: Cosmin Stejerean +Reviewed-by: Thomas Mundt +Signed-off-by: Philip Langdale +--- + libavfilter/vf_bwdif.c | 9 +++++---- + libavfilter/vf_bwdif_cuda.c | 11 ++++++----- + libavfilter/vf_bwdif_vulkan.c | 11 +++++------ + 3 files changed, 16 insertions(+), 15 deletions(-) + +diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c +index 137cd5ef13..353cd0b61a 100644 +--- a/libavfilter/vf_bwdif.c ++++ b/libavfilter/vf_bwdif.c +@@ -191,13 +191,14 @@ static int config_props(AVFilterLink *link) + return ret; + } + +- if (link->w < 3 || link->h < 4) { +- av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or 4 lines is not supported\n"); ++ yadif->csp = av_pix_fmt_desc_get(link->format); ++ yadif->filter = filter; ++ ++ if (AV_CEIL_RSHIFT(link->w, yadif->csp->log2_chroma_w) < 3 || AV_CEIL_RSHIFT(link->h, yadif->csp->log2_chroma_h) < 4) { ++ av_log(ctx, AV_LOG_ERROR, "Video with planes less than 3 columns or 4 lines is not supported\n"); + return AVERROR(EINVAL); + } + +- yadif->csp = av_pix_fmt_desc_get(link->format); +- yadif->filter = filter; + ff_bwdif_init_filter_line(&s->dsp, yadif->csp->comp[0].depth); + + return 0; +diff --git a/libavfilter/vf_bwdif_cuda.c b/libavfilter/vf_bwdif_cuda.c +index a5ecfbadb6..418f15f989 100644 +--- a/libavfilter/vf_bwdif_cuda.c ++++ b/libavfilter/vf_bwdif_cuda.c +@@ -296,15 +296,16 @@ static int config_output(AVFilterLink *link) + link->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate, + (AVRational){2, 1}); + +- if (link->w < 3 || link->h < 3) { +- av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or lines is not supported\n"); +- ret = AVERROR(EINVAL); +- goto exit; +- } + + y->csp = av_pix_fmt_desc_get(output_frames->sw_format); + y->filter = filter; + ++ if (AV_CEIL_RSHIFT(link->w, y->csp->log2_chroma_w) < 3 || AV_CEIL_RSHIFT(link->h, y->csp->log2_chroma_h) < 3) { ++ av_log(ctx, AV_LOG_ERROR, "Video with planes less than 3 columns or lines is not supported\n"); ++ ret = AVERROR(EINVAL); ++ goto exit; ++ } ++ + ret = CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx)); + if (ret < 0) + goto exit; +diff --git a/libavfilter/vf_bwdif_vulkan.c b/libavfilter/vf_bwdif_vulkan.c +index 690a89c4ba..c51df9aa26 100644 +--- a/libavfilter/vf_bwdif_vulkan.c ++++ b/libavfilter/vf_bwdif_vulkan.c +@@ -362,15 +362,14 @@ static int bwdif_vulkan_config_output(AVFilterLink *outlink) + outlink->frame_rate = av_mul_q(avctx->inputs[0]->frame_rate, + (AVRational){2, 1}); + +- if (outlink->w < 4 || outlink->h < 4) { +- av_log(avctx, AV_LOG_ERROR, "Video of less than 4 columns or lines is not " +- "supported\n"); +- return AVERROR(EINVAL); +- } +- + y->csp = av_pix_fmt_desc_get(vkctx->frames->sw_format); + y->filter = bwdif_vulkan_filter_frame; + ++ if (AV_CEIL_RSHIFT(outlink->w, y->csp->log2_chroma_w) < 4 || AV_CEIL_RSHIFT(outlink->h, y->csp->log2_chroma_h) < 4) { ++ av_log(avctx, AV_LOG_ERROR, "Video with planes less than 4 columns or lines is not supported\n"); ++ return AVERROR(EINVAL); ++ } ++ + return init_filter(avctx); + } + +-- +2.44.0 + diff --git a/0001-avfilter-vf_codecview-fix-heap-buffer-overflow.patch b/0001-avfilter-vf_codecview-fix-heap-buffer-overflow.patch new file mode 100644 index 0000000..00b9203 --- /dev/null +++ b/0001-avfilter-vf_codecview-fix-heap-buffer-overflow.patch @@ -0,0 +1,31 @@ +From 99debe5f823f45a482e1dc08de35879aa9c74bd2 Mon Sep 17 00:00:00 2001 +From: Zhao Zhili +Date: Fri, 29 Dec 2023 05:56:43 +0800 +Subject: [PATCH] avfilter/vf_codecview: fix heap buffer overflow +References: https://bugzilla.opensuse.org/1223085 +References: CVE-2024-31582 + +And improve the performance by a little bit. + +Signed-off-by: Zhao Zhili +--- + libavfilter/vf_codecview.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/libavfilter/vf_codecview.c b/libavfilter/vf_codecview.c +index 55d9c8c04f..f65ccbda70 100644 +--- a/libavfilter/vf_codecview.c ++++ b/libavfilter/vf_codecview.c +@@ -216,9 +216,6 @@ static void draw_block_rectangle(uint8_t *buf, int sx, int sy, int w, int h, ptr + buf[sx + w - 1] = color; + buf += stride; + } +- +- for (int x = sx; x < sx + w; x++) +- buf[x] = color; + } + + static int filter_frame(AVFilterLink *inlink, AVFrame *frame) +-- +2.44.0 + diff --git a/0001-avutil-hwcontext-Don-t-assume-frames_uninit-is-reent.patch b/0001-avutil-hwcontext-Don-t-assume-frames_uninit-is-reent.patch new file mode 100644 index 0000000..6501dad --- /dev/null +++ b/0001-avutil-hwcontext-Don-t-assume-frames_uninit-is-reent.patch @@ -0,0 +1,46 @@ +From 3bb00c0a420c3ce83c6fafee30270d69622ccad7 Mon Sep 17 00:00:00 2001 +From: Zhao Zhili +Date: Tue, 20 Feb 2024 20:08:55 +0800 +Subject: [PATCH] avutil/hwcontext: Don't assume frames_uninit is reentrant +References: https://bugzilla.opensuse.org/1223070 +References: CVE-2024-31578 + +Fix heap use after free when vulkan_frames_init failed. + +Signed-off-by: Zhao Zhili +--- + libavutil/hwcontext.c | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c +index 1d2c2d7920..aa1329bf2b 100644 +--- a/libavutil/hwcontext.c ++++ b/libavutil/hwcontext.c +@@ -359,7 +359,7 @@ int av_hwframe_ctx_init(AVBufferRef *ref) + if (ctx->internal->hw_type->frames_init) { + ret = ctx->internal->hw_type->frames_init(ctx); + if (ret < 0) +- goto fail; ++ return ret; + } + + if (ctx->internal->pool_internal && !ctx->pool) +@@ -369,14 +369,10 @@ int av_hwframe_ctx_init(AVBufferRef *ref) + if (ctx->initial_pool_size > 0) { + ret = hwframe_pool_prealloc(ref); + if (ret < 0) +- goto fail; ++ return ret; + } + + return 0; +-fail: +- if (ctx->internal->hw_type->frames_uninit) +- ctx->internal->hw_type->frames_uninit(ctx); +- return ret; + } + + int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ref, +-- +2.44.0 + diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..3636f9c --- /dev/null +++ b/_multibuild @@ -0,0 +1,3 @@ + + ffmpeg-6-mini + diff --git a/baselibs.conf b/baselibs.conf new file mode 100644 index 0000000..e659c42 --- /dev/null +++ b/baselibs.conf @@ -0,0 +1,8 @@ +libavcodec60 +libavdevice60 +libavfilter9 +libavformat60 +libavutil58 +libpostproc57 +libswresample4 +libswscale7 diff --git a/enable_decoders b/enable_decoders new file mode 100644 index 0000000..38f6f03 --- /dev/null +++ b/enable_decoders @@ -0,0 +1,480 @@ +## module name # reason for enablement in ffmpeg (usually there is another package that already got legal review) +aac +aasc +ac3 +acelp_kelvin +adpcm_4xm +adpcm_adx +adpcm_afc +adpcm_agm +adpcm_aica +adpcm_argo +adpcm_ct +adpcm_dtk +adpcm_ea +adpcm_ea_maxis_xa +adpcm_ea_r1 +adpcm_ea_r2 +adpcm_ea_r3 +adpcm_ea_xas +adpcm_g722 +adpcm_g726 +adpcm_g726le +adpcm_ima_acorn +adpcm_ima_alp +adpcm_ima_amv +adpcm_ima_apc +adpcm_ima_apm +adpcm_ima_cunning +adpcm_ima_dat4 +adpcm_ima_dk3 +adpcm_ima_dk4 +adpcm_ima_ea_eacs +adpcm_ima_ea_sead +adpcm_ima_iss +adpcm_ima_moflex +adpcm_ima_mtf +adpcm_ima_oki +adpcm_ima_qt +adpcm_ima_rad +adpcm_ima_smjpeg +adpcm_ima_ssi +adpcm_ima_wav +adpcm_ima_ws +adpcm_ms +adpcm_mtaf +adpcm_psx +adpcm_sbpro_2 +adpcm_sbpro_3 +adpcm_sbpro_4 +adpcm_swf +adpcm_thp +adpcm_thp_le +adpcm_vima +adpcm_xa +adpcm_xmd +adpcm_yamaha +adpcm_zork +alac +alias_pix +amrnb # opencore-amr +amrwb # opencore-amr +amv +anm +ansi # trivial +anull +apac +ape +apng # animated png +arbc +argo +ass # trivial +asv1 +asv2 +atrac1 +atrac3 +atrac3al +atrac3p +atrac3pal +aura +aura2 +av1 # libaom +av1_nvdec # passthrough +av1_qsv # passthrough +av1_vaapi # passthrough +ayuv # trivial +bethsoftvid # trivial +bfi # trivial +bink +binkaudio_dct +binkaudio_rdft +bintext +bitpacked # trivial +bmp # trivial +bmv_audio +bmv_video +bonk +brender_pix +c93 +cbd2_dpcm +ccaption +cdgraphics +cdtoons +cdxl +cinepak +clearvideo +cljr +cook +cpia +cscd +cyuv +dca +dds +derf_dpcm +dfa +dfpwm +dirac # dirac +dnxhd +dolby_e +dpx +dsd_lsbf +dsd_msbf +dsicinaudio +dsicinvideo +dss_sp +dvaudio +dvbsub +dvdsub +dvvideo +dxa +dxtory +eacmv +eamad +eatgq +eatgv +eatqi +eightbps +eightsvx_exp +eightsvx_fib +escape124 +escape130 +evrc +exr # openEXR +ffv1 # ffmpeg +ffvhuff # ffmpeg +ffwavesynth # pseudo +fits +flac # libFLAC +flashsv +flashsv2 +flic +flv +fmvc +fourxm +ftr # fdk-aac +g723_1 +g729 +gdv +gem +gif # libpng +gremlin_dpcm +gsm # libgsm +gsm_ms +h261 +h263 +h263_v4l2m2m # passthrough +h263i +h263p +hap +hca +hcom +hdr +hnm4_video +hq_hqa +hqx +huffyuv # trivial+zlib +hymt # huffyuv-mt +iac +idcin +idf +iff_ilbm +ilbc # ilbc +imc +indeo2 +indeo3 +indeo4 +indeo5 +interplay_acm +interplay_dpcm +interplay_video +ipu +jacosub +jpeg2000 # openjpeg2 +jpegls +jv +kgv1 +kmvc +lagarith +libaom # libaom +libaom_av1 # libaom +libcodec2 # codec2 +libdav1d # av1 +libgsm # libgsm +libgsm_ms # libgsm +libjxl # libjxl +libopencore_amrnb # opencore-amr +libopencore_amrwb # opencore-amr +libopenh264 # passthrough/dlopen +libopenjpeg # openjpeg +libopus # opus +libschroedinger # schroedinger +libspeex # speex +libvorbis # libvorbis +libvpx_vp8 # libvpx +libvpx_vp9 # libvpx +libzvbi_teletext # zvbi +loco +lscr +m101 +mace3 +mace6 +mdec +media100 +metasound +microdvd +mimic +misc4 +mjpeg # mjpegtools +mjpeg_qsv # passthrough +mjpegb +mlp +mmvideo +motionpixels +mp1 # twolame/lame +mp1float # twolame/lame +mp2 # twolame +mp2float # twolame +mp3 # lame +mp3adu +mp3adufloat +mp3float # lame +mp3on4 +mp3on4float +mpc7 +mpc8 +mpeg1_cuvid # passthrough +mpeg1_v4l2m2m # passthrough +mpeg1video +mpeg2_cuvid # passthrough +mpeg2_qsv # passthrough +mpeg2_v4l2m2m # passthrough +mpeg2_vaapi # passthrough +mpeg2video +mpeg4 +mpeg4_cuvid # passthrough +mpeg4_v4l2m2m # passthrough +mpegvideo +mpl2 +msa1 +mscc +msmpeg4 +msmpeg4v1 +msmpeg4v2 +msmpeg4v3 +msnsiren +msp2 +msrle +mss1 +msvideo1 +mszh +mts2 +mv30 +mvc1 +mvc2 +mvdv +mvha +mwsc +mxpeg +nellymoser +nuv +on2avc +opus # opus +paf_audio +paf_video +pam # trivial +pbm # trivial +pcm_alaw # trivial +pcm_bluray +pcm_dvd +pcm_f16le # trivial +pcm_f24le # trivial +pcm_f32be # trivial +pcm_f32be # trivial +pcm_f32le # trivial +pcm_f64be # trivial +pcm_f64le # trivial +pcm_lxf # trivial +pcm_mulaw # trivial +pcm_s16be # trivial +pcm_s16be_planar # trivial +pcm_s16le # trivial +pcm_s16le_planar # trivial +pcm_s24be # trivial +pcm_s24daud # trivial +pcm_s24le # trivial +pcm_s24le_planar # trivial +pcm_s32be # trivial +pcm_s32le # trivial +pcm_s32le_planar # trivial +pcm_s64be # trivial +pcm_s64le # trivial +pcm_s8 # trivial +pcm_s8_planar # trivial +pcm_sga # trivial +pcm_u16be # trivial +pcm_u16le # trivial +pcm_u24be # trivial +pcm_u24le # trivial +pcm_u32be # trivial +pcm_u32le # trivial +pcm_u8 # trivial +pcm_vidc # trivial +pcx +pfm # trivial +pgm # trivial +pgmyuv # trivial +pgssub # mkvtoolnix +pgx +phm # trivial +photocd +pictor +pjs +png # libpng +ppm # trivial +prosumer +psd +ptx +qcelp +qdm2 +qdmc +qdraw +qoi +qpeg +qtrle +r10k +r210 +ra_144 +ra_288 +rasc +rawvideo # trivial +realtext +rka +rl2 +roq +roq_dpcm +rpza +rscc +rv10 +rv20 +s302m +sami +sanm +sbc +screenpresso +sdx2_dpcm +sgi # trivial +sgirle # trivial +shorten +simbiosis_imx +sipr +siren +smackaud +smacker +smc +smvjpeg +snow +sol_dpcm +sonic +sp5x +speedhq +speex # speex +srgc +srt # trivial +ssa # trivial +stl +subrip +subviewer +subviewer1 +sunrast # trivial +svq1 +svq3 +tak +targa # trivial +targa_y216 +tdsc +text # trivial +theora # libtheora +thp +tiertexseqvideo +tiff # libtiff +tmv +truehd +truemotion1 +truemotion2 +truemotion2rt +truespeech +tscc +tscc2 +tta +twinvq +txd +ulti +utvideo +v210 # trivial +v210x # trivial +v308 # trivial +v408 # trivial +v410 # trivial +vb +vble +vcr1 +vmdaudio +vmdvideo +vmnc +vnull # trivial +vorbis # libvorbis +vp3 # libav +vp4 # libav +vp5 # libav +vp5 # libav +vp6 # libav +vp6 # libav +vp6a # libav +vp6a # libav +vp6f # libav +vp6f # libav +vp7 # libav +vp8 # libvpx +vp8_qsv # passthrough +vp8_v4l2m2m # passthrough +vp9 # libvpx +vp9_qsv # passthrough +vp9_v4l2m2m # passthrough +vplayer +vqa +vqc +wady_dpcm +wavarc +wavpack # wavpack +wbmp +wcmv +webp # libwebp +webvtt # trivial +wmav1 +wmav2 +wmavoice +wmv1 +wmv2 +wnv1 +wrapped_avframe # passthrough +ws_snd1 +xan_dpcm +xan_wc3 +xan_wc4 +xbin +xbm # trivial +xface +xl +xpm +xsub +xwd # xwd +y41p # trivial +y41p # trivial +ylc +yop +yuv4 # trivial +yuv4 # trivial +zero12v +zerocodec +zlib # zlib +zmbv # dosbox diff --git a/enable_encoders b/enable_encoders new file mode 100644 index 0000000..f35ba53 --- /dev/null +++ b/enable_encoders @@ -0,0 +1,195 @@ +## module name # reason for enablement in ffmpeg (usually there is another package that already got legal review) +a64multi +a64multi5 +aac +ac3 +adpcm_adx +adpcm_argo +adpcm_g722 +adpcm_g726 +adpcm_g726le +adpcm_ima_alp +adpcm_ima_amv +adpcm_ima_apm +adpcm_ima_qt +adpcm_ima_ssi +adpcm_ima_wav +adpcm_ima_ws +adpcm_ms +adpcm_swf +adpcm_yamaha +alac +alias_pix +amv +anull +apng # libpng +ass # trivial +asv1 +asv2 +av1_nvenc +av1_vaapi +ayuv # trival +bitpacked # trivial +bmp # trivial +cinepak +cljr +dca +dfpwm +dnxhd +dpx +dvdsub +dvvideo +exr +ffv1 +ffvhuff # trivial+zlib +flac # libFLAC +flashsv +flashsv2 +flv +g723_1 +gif # libpng +h261 +h263 +h263_v4l2m2m # passthrough +h263p +hdr +huffyuv # trivial+zlib +ilbc # ilbc +jpeg2000 +jpegls +libaom # libaom +libaom_av1 # libaom +libcodec2 # codec2 +libgsm # libgsm +libgsm_ms # libgsm +libjxl # libjxl +libmp3lame # lame +libopencore_amrnb # opencore-amr +libopenh264 # passthrough/dlopen +libopenjpeg # openjpeg +libopus # opus +librav1e # rav1e +libschroedinger # schroedinger +libspeex # speex +libsvtav1 # SVT-AV1 +libtheora # libtheora +libtwolame # twolame +libvo_amrwbenc # vo-amrwbenc +libvorbis # libvorbis +libvpx_vp8 # libvpx +libvpx_vp9 # libvpx +libwebp # libwebp +libwebp_anim # libwebp +libxvid # xvidcore +mjpeg # mjpegtools +mjpeg_qsv # passthrough +mjpeg_vaapi # passthrough +mlp +mp2 # twolame +mp2fixed # twolame +mpeg1video +mpeg2_qsv +mpeg2_vaapi +mpeg2video +mpeg4 +mpeg4_v4l2m2m # passthrough +msmpeg4v1 +msmpeg4v2 +msmpeg4v3 +msnsiren +msvideo1 +nellymoser +opus # opus +pam +pbm # trivial +pcm_alaw # trivial +pcm_f32be # trivial +pcm_f32le # trivial +pcm_f64be # trivial +pcm_f64le # trivial +pcm_mulaw # trivial +pcm_s16be # trivial +pcm_s16be_planar # trivial +pcm_s16le # trivial +pcm_s16le_planar # trivial +pcm_s24be # trivial +pcm_s24le # trivial +pcm_s24le_planar # trivial +pcm_s32be # trivial +pcm_s32le # trivial +pcm_s32le_planar # trivial +pcm_s8 # trivial +pcm_s8_planar # trivial +pcm_u16be # trivial +pcm_u16le # trivial +pcm_u24be # trivial +pcm_u24le # trivial +pcm_u32be # trivial +pcm_u32le # trivial +pcm_u8 # trivial +pcx +pgm # trivial +pgmyuv # trivial +phm # trivial +png # libpng +ppm # trivial +qoi +qtrle +r10k # trivial +r210 # trivial +ra_144 +rawvideo # trivial +roq +roq_dpcm +rpza +rv10 +rv20 +s302m +sbc +sgi # trivial +siren +smc +snow +sonic +sonic_ls +speedhq +srt # trivial +ssa # trivial +subrip # trivial +sunrast # trivial +svq1 +targa # trivial +text # trivial +tiff # libtiff +truehd +tta +ttml +utvideo +v210 # trivial +v308 # trivial +v408 # trivial +v410 # trivial +vc2 # dirac +vnull # trivial +vorbis # libvorbis +vp8_qsv # passthrough +vp8_v4l2m2m # passthrough +vp8_vaapi # passthrough +vp9_qsv # passthrough +vp9_vaapi # passthough +wavpack +wbmp +webvtt # trivial +wmav1 +wmav2 +wmv1 +wmv2 +wrapped_avframe # passthrough +xbm # trivial +xface +xsub +xwd # xwd +y41p # trivial +yuv4 # trivial +zlib # zlib +zmbv # dosbox diff --git a/ffmpeg-4.2-dlopen-fdk_aac.patch b/ffmpeg-4.2-dlopen-fdk_aac.patch new file mode 100644 index 0000000..fbbabb5 --- /dev/null +++ b/ffmpeg-4.2-dlopen-fdk_aac.patch @@ -0,0 +1,195 @@ +From: Ismail Dönmez +Date: 2019-06-11 11:21:23 + +This is ffmpeg-4.1-dlopen-faac-mp3lame-opencore-x264-x265-xvid.patch +from OpenMandriva to optionally enable runtime enabling of +fdkaac/lame/x264/x265. + +--- + configure | 3 ++ + libavcodec/dlopen.h | 12 ++++++++++ + libavcodec/libfdk-aacdec.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ + libavcodec/libfdk-aacenc.c | 47 +++++++++++++++++++++++++++++++++++++++ + 4 files changed, 115 insertions(+) + +Index: ffmpeg-6.1.1/configure +=================================================================== +--- ffmpeg-6.1.1.orig/configure ++++ ffmpeg-6.1.1/configure +@@ -228,6 +228,7 @@ External library support: + --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394 + and libraw1394 [no] + --enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no] ++ --enable-libfdk-aac-dlopen enable AAC de/encoding via dlopen()'ed libfdk-aac [no] + --enable-libflite enable flite (voice synthesis) support via libflite [no] + --enable-libfontconfig enable libfontconfig, useful for drawtext filter [no] + --enable-libfreetype enable libfreetype, needed for drawtext filter [no] +@@ -1812,6 +1813,7 @@ EXTERNAL_LIBRARY_GPL_LIST=" + EXTERNAL_LIBRARY_NONFREE_LIST=" + decklink + libfdk_aac ++ libfdk_aac_dlopen + libtls + " + +@@ -6697,6 +6699,7 @@ enabled libdrm && require_pkg + enabled libfdk_aac && { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen || + { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac && + warn "using libfdk without pkg-config"; } } ++enabled libfdk_aac_dlopen && enable libfdk_aac && add_cppflags "-I/usr/include/fdk-aac" + flite_extralibs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite" + enabled libflite && require libflite "flite/flite.h" flite_init $flite_extralibs + enabled fontconfig && enable libfontconfig +Index: ffmpeg-6.1.1/libavcodec/dlopen.h +=================================================================== +--- /dev/null ++++ ffmpeg-6.1.1/libavcodec/dlopen.h +@@ -0,0 +1,12 @@ ++#ifndef LOCALINC_DLOPEN_H ++#define LOCALINC_DLOPEN_H ++#include ++#define num2str(x) str(x) ++#define str(x) #x ++ ++#define dl_sym(func, args, lib) \ ++ dl_##func = args dlsym(lib, #func); \ ++ if ((err = dlerror())) \ ++ goto error; ++ ++#endif +Index: ffmpeg-6.1.1/libavcodec/libfdk-aacdec.c +=================================================================== +--- ffmpeg-6.1.1.orig/libavcodec/libfdk-aacdec.c ++++ ffmpeg-6.1.1/libavcodec/libfdk-aacdec.c +@@ -38,6 +38,54 @@ + #define AAC_PCM_MAX_OUTPUT_CHANNELS AAC_PCM_OUTPUT_CHANNELS + #endif + ++#ifdef CONFIG_LIBFDK_AAC_DLOPEN ++#include "dlopen.h" ++AAC_DECODER_ERROR (*dl_aacDecoder_AncDataInit)(HANDLE_AACDECODER, UCHAR*, int); ++HANDLE_AACDECODER (*dl_aacDecoder_Open)(TRANSPORT_TYPE, UINT); ++AAC_DECODER_ERROR (*dl_aacDecoder_Fill)(HANDLE_AACDECODER, UCHAR**, const UINT*, UINT*); ++AAC_DECODER_ERROR (*dl_aacDecoder_ConfigRaw)(HANDLE_AACDECODER, UCHAR **, const UINT*); ++AAC_DECODER_ERROR (*dl_aacDecoder_SetParam)(const HANDLE_AACDECODER, const AACDEC_PARAM, const INT); ++AAC_DECODER_ERROR (*dl_aacDecoder_DecodeFrame)(HANDLE_AACDECODER, INT_PCM*, const INT, const UINT); ++CStreamInfo* (*dl_aacDecoder_GetStreamInfo)(HANDLE_AACDECODER); ++void (*dl_aacDecoder_Close)(HANDLE_AACDECODER); ++#define aacDecoder_AncDataInit dl_aacDecoder_AncDataInit ++#define aacDecoder_Open dl_aacDecoder_Open ++#define aacDecoder_Fill dl_aacDecoder_Fill ++#define aacDecoder_ConfigRaw dl_aacDecoder_ConfigRaw ++#define aacDecoder_SetParam dl_aacDecoder_SetParam ++#define aacDecoder_DecodeFrame dl_aacDecoder_DecodeFrame ++#define aacDecoder_GetStreamInfo dl_aacDecoder_GetStreamInfo ++#define aacDecoder_Close dl_aacDecoder_Close ++#define FDKAAC_LIB "libfdk-aac.so.2" ++static int loadLibFdkAac(AVCodecContext *avctx); ++static int loadLibFdkAac(AVCodecContext *avctx) { ++ void *libfdkaac = NULL; ++ const char *err = NULL; ++ ++ libfdkaac = dlopen(FDKAAC_LIB, RTLD_LAZY); ++ if(err = dlerror()) { ++ av_log(avctx, AV_LOG_FATAL, "%s\n%s is missing, libfdk-aac support will be disabled\n", err, FDKAAC_LIB); ++ if(libfdkaac) ++ dlclose(libfdkaac); ++ return 1; ++ } ++ dl_sym(aacDecoder_AncDataInit, (AAC_DECODER_ERROR (*)(HANDLE_AACDECODER, UCHAR*, int)), libfdkaac); ++ dl_sym(aacDecoder_Open, (HANDLE_AACDECODER (*)(TRANSPORT_TYPE, UINT)), libfdkaac); ++ dl_sym(aacDecoder_Fill, (AAC_DECODER_ERROR (*)(HANDLE_AACDECODER, UCHAR**, const UINT*, UINT*)), libfdkaac); ++ dl_sym(aacDecoder_ConfigRaw, (AAC_DECODER_ERROR (*)(HANDLE_AACDECODER, UCHAR**, const UINT*)), libfdkaac); ++ dl_sym(aacDecoder_SetParam, (AAC_DECODER_ERROR (*)(const HANDLE_AACDECODER, const AACDEC_PARAM, const INT)), libfdkaac); ++ dl_sym(aacDecoder_DecodeFrame, (AAC_DECODER_ERROR (*)(HANDLE_AACDECODER, INT_PCM*, const INT, const UINT)), libfdkaac); ++ dl_sym(aacDecoder_GetStreamInfo, (CStreamInfo* (*)(HANDLE_AACDECODER)), libfdkaac); ++ dl_sym(aacDecoder_Close, (void (*)(HANDLE_AACDECODER)), libfdkaac); ++ return 0; ++error: ++ av_log(avctx, AV_LOG_FATAL, "libfdk-aac: Missing symbols in %s: %s\n" ++ "libfdk-aac support disabled\n", FDKAAC_LIB, err); ++ dlclose(libfdkaac); ++ return 1; ++} ++#endif ++ + enum ConcealMethod { + CONCEAL_METHOD_SPECTRAL_MUTING = 0, + CONCEAL_METHOD_NOISE_SUBSTITUTION = 1, +@@ -244,6 +292,11 @@ static av_cold int fdk_aac_decode_init(A + FDKAACDecContext *s = avctx->priv_data; + AAC_DECODER_ERROR err; + ++#ifdef CONFIG_LIBFDK_AAC_DLOPEN ++ if (loadLibFdkAac(avctx)) ++ return -1; ++#endif ++ + s->handle = aacDecoder_Open(avctx->extradata_size ? TT_MP4_RAW : TT_MP4_ADTS, 1); + if (!s->handle) { + av_log(avctx, AV_LOG_ERROR, "Error opening decoder\n"); +Index: ffmpeg-6.1.1/libavcodec/libfdk-aacenc.c +=================================================================== +--- ffmpeg-6.1.1.orig/libavcodec/libfdk-aacenc.c ++++ ffmpeg-6.1.1/libavcodec/libfdk-aacenc.c +@@ -37,6 +37,48 @@ + #define FDKENC_VER_AT_LEAST(vl0, vl1) 0 + #endif + ++#ifdef CONFIG_LIBFDK_AAC_DLOPEN ++#include "dlopen.h" ++#include ++AACENC_ERROR (*dl_aacEncOpen)(HANDLE_AACENCODER*, const UINT, const UINT); ++AACENC_ERROR (*dl_aacEncoder_SetParam)(const HANDLE_AACENCODER, const AACENC_PARAM, const UINT); ++AACENC_ERROR (*dl_aacEncEncode)(const HANDLE_AACENCODER, const AACENC_BufDesc*, const AACENC_BufDesc*, const AACENC_InArgs*, AACENC_OutArgs*); ++AACENC_ERROR (*dl_aacEncInfo)(const HANDLE_AACENCODER, AACENC_InfoStruct*); ++AACENC_ERROR (*dl_aacEncClose)(HANDLE_AACENCODER*); ++ ++#define aacEncOpen dl_aacEncOpen ++#define aacEncoder_SetParam dl_aacEncoder_SetParam ++#define aacEncEncode dl_aacEncEncode ++#define aacEncInfo dl_aacEncInfo ++#define aacEncClose dl_aacEncClose ++#define FDKAAC_LIB "libfdk-aac.so.2" ++ ++static int loadLibFdkAac(AVCodecContext *avctx); ++static int loadLibFdkAac(AVCodecContext *avctx) { ++ void *libfdkaac = NULL; ++ const char *err = NULL; ++ ++ libfdkaac = dlopen(FDKAAC_LIB, RTLD_LAZY); ++ if(err = dlerror()) { ++ av_log(avctx, AV_LOG_FATAL, "%s\n%s is missing, libfdk-aac support will be disabled\n", err, FDKAAC_LIB); ++ if(libfdkaac) ++ dlclose(libfdkaac); ++ return 1; ++ } ++ dl_sym(aacEncOpen, (AACENC_ERROR (*)(HANDLE_AACENCODER*, const UINT, const UINT)), libfdkaac); ++ dl_sym(aacEncoder_SetParam, (AACENC_ERROR (*)(const HANDLE_AACENCODER, const AACENC_PARAM, const UINT)), libfdkaac); ++ dl_sym(aacEncEncode, (AACENC_ERROR (*)(const HANDLE_AACENCODER, const AACENC_BufDesc*, const AACENC_BufDesc*, const AACENC_InArgs*, AACENC_OutArgs*)), libfdkaac); ++ dl_sym(aacEncInfo, (AACENC_ERROR (*)(const HANDLE_AACENCODER, AACENC_InfoStruct*)), libfdkaac); ++ dl_sym(aacEncClose, (AACENC_ERROR (*)(HANDLE_AACENCODER*)), libfdkaac); ++ return 0; ++error: ++ av_log(avctx, AV_LOG_FATAL, "libfdk-aac: Missing symbols in %s: %s\n" ++ "libfdk-aac support disabled\n", FDKAAC_LIB, err); ++ dlclose(libfdkaac); ++ return 1; ++} ++#endif ++ + typedef struct AACContext { + const AVClass *class; + HANDLE_AACENCODER handle; +@@ -182,6 +224,11 @@ static av_cold int aac_encode_init(AVCod + int aot = AV_PROFILE_AAC_LOW + 1; + int sce = 0, cpe = 0; + ++#ifdef CONFIG_LIBFDK_AAC_DLOPEN ++ if (loadLibFdkAac(avctx)) ++ return -1; ++#endif ++ + if ((err = aacEncOpen(&s->handle, 0, avctx->ch_layout.nb_channels)) != AACENC_OK) { + av_log(avctx, AV_LOG_ERROR, "Unable to open the encoder: %s\n", + aac_get_error(err)); diff --git a/ffmpeg-6-CVE-2023-50007.patch b/ffmpeg-6-CVE-2023-50007.patch new file mode 100644 index 0000000..f90ee9f --- /dev/null +++ b/ffmpeg-6-CVE-2023-50007.patch @@ -0,0 +1,68 @@ +From b1942734c7cbcdc9034034373abcc9ecb9644c47 Mon Sep 17 00:00:00 2001 +From: Paul B Mahol +Date: Mon, 27 Nov 2023 11:45:34 +0100 +Subject: [PATCH] avfilter/af_afwtdn: fix crash with EOF handling +References: https://bugzilla.opensuse.org/1223253 +References: CVE-2023-50007 + +diff -Nura ffmpeg-6.1.1/libavfilter/af_afwtdn.c ffmpeg-6.1.1_new/libavfilter/af_afwtdn.c +--- ffmpeg-6.1.1/libavfilter/af_afwtdn.c 2023-11-11 08:25:17.000000000 +0800 ++++ ffmpeg-6.1.1_new/libavfilter/af_afwtdn.c 2024-04-25 14:15:23.737350315 +0800 +@@ -408,6 +408,7 @@ + + uint64_t sn; + int64_t eof_pts; ++ int eof; + + int wavelet_type; + int channels; +@@ -1069,7 +1070,7 @@ + s->drop_samples = 0; + } else { + if (s->padd_samples < 0 && eof) { +- out->nb_samples += s->padd_samples; ++ out->nb_samples = FFMAX(0, out->nb_samples + s->padd_samples); + s->padd_samples = 0; + } + if (!eof) +@@ -1208,23 +1209,26 @@ + + FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); + +- ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in); +- if (ret < 0) +- return ret; +- if (ret > 0) +- return filter_frame(inlink, in); ++ if (!s->eof) { ++ ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in); ++ if (ret < 0) ++ return ret; ++ if (ret > 0) ++ return filter_frame(inlink, in); ++ } + + if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { +- if (status == AVERROR_EOF) { +- while (s->padd_samples != 0) { +- ret = filter_frame(inlink, NULL); +- if (ret < 0) +- return ret; +- } +- ff_outlink_set_status(outlink, status, pts); +- return ret; +- } ++ if (status == AVERROR_EOF) ++ s->eof = 1; + } ++ ++ if (s->eof && s->padd_samples != 0) { ++ return filter_frame(inlink, NULL); ++ } else if (s->eof) { ++ ff_outlink_set_status(outlink, AVERROR_EOF, s->eof_pts); ++ return 0; ++ } ++ + FF_FILTER_FORWARD_WANTED(outlink, inlink); + + return FFERROR_NOT_READY; diff --git a/ffmpeg-6-CVE-2023-50008.patch b/ffmpeg-6-CVE-2023-50008.patch new file mode 100644 index 0000000..b23fcd7 --- /dev/null +++ b/ffmpeg-6-CVE-2023-50008.patch @@ -0,0 +1,19 @@ +From 5f87a68cf70dafeab2fb89b42e41a4c29053b89b Mon Sep 17 00:00:00 2001 +From: Paul B Mahol +Date: Mon Nov 27 12:08:20 2023 +0100 +Subject: avfilter/vf_colorcorrect: fix memory leaks +References: https://bugzilla.opensuse.org/1223254 +References: CVE-2023-50008 + +diff -Nura ffmpeg-6.1.1/libavfilter/vf_colorcorrect.c ffmpeg-6.1.1_new/libavfilter/vf_colorcorrect.c +--- ffmpeg-6.1.1/libavfilter/vf_colorcorrect.c 2023-11-11 08:25:17.000000000 +0800 ++++ ffmpeg-6.1.1_new/libavfilter/vf_colorcorrect.c 2024-04-25 14:35:29.717468737 +0800 +@@ -497,6 +497,8 @@ + ColorCorrectContext *s = ctx->priv; + + av_freep(&s->analyzeret); ++ av_freep(&s->uhistogram); ++ av_freep(&s->vhistogram); + } + + static const AVFilterPad colorcorrect_inputs[] = { diff --git a/ffmpeg-6-CVE-2024-32228-shim-1535d338.patch b/ffmpeg-6-CVE-2024-32228-shim-1535d338.patch new file mode 100644 index 0000000..95e3aac --- /dev/null +++ b/ffmpeg-6-CVE-2024-32228-shim-1535d338.patch @@ -0,0 +1,970 @@ +From 1535d338186f5e40383270b4a85fb1d4e213d3db Mon Sep 17 00:00:00 2001 +Author: Niklas Haas +Date: Wed, 4 Oct 2023 13:43:51 +0200 +Subject: [PATCH] avcodec/aom_film_grain: add AOM film grain synthesis +References: CVE-2024-32228 +References: bsc#1227277 +Upstream: Backport from upstream + +Implementation copied wholesale from dav1d, sans SIMD, under permissive +license. This implementation was extensively verified to be bit-exact, +so it serves as a much better starting point than trying to re-engineer +this from scratch for no reason. (I also authored the original +implementation in dav1d, so any "clean room" implementation would end up +looking much the same, anyway) + +The notable changes I had to make while adapting this from the dav1d +code-base to the FFmpeg codebase include: + +- reordering variable declarations to avoid triggering warnings +- replacing several inline helpers by avutil equivalents +- changing code that accesses frame metadata +- replacing raw plane copying logic by av_image_copy_plane + +Apart from this, the implementation is basically unmodified. + +diff --git a/libavcodec/aom_film_grain.c b/libavcodec/aom_film_grain.c +new file mode 100644 +index 0000000000..ffcd71b584 +--- /dev/null ++++ b/libavcodec/aom_film_grain.c +@@ -0,0 +1,310 @@ ++/* ++ * AOM film grain synthesis ++ * Copyright (c) 2023 Niklas Haas ++ * ++ * This file is part of FFmpeg. ++ * ++ * FFmpeg is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * FFmpeg is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with FFmpeg; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++/** ++ * @file ++ * AOM film grain synthesis. ++ * @author Niklas Haas ++ */ ++ ++#include "libavutil/avassert.h" ++#include "libavutil/imgutils.h" ++ ++#include "aom_film_grain.h" ++ ++// Common/shared helpers (not dependent on BIT_DEPTH) ++static inline int get_random_number(const int bits, unsigned *const state) { ++ const int r = *state; ++ unsigned bit = ((r >> 0) ^ (r >> 1) ^ (r >> 3) ^ (r >> 12)) & 1; ++ *state = (r >> 1) | (bit << 15); ++ ++ return (*state >> (16 - bits)) & ((1 << bits) - 1); ++} ++ ++static inline int round2(const int x, const uint64_t shift) { ++ return (x + ((1 << shift) >> 1)) >> shift; ++} ++ ++enum { ++ GRAIN_WIDTH = 82, ++ GRAIN_HEIGHT = 73, ++ SUB_GRAIN_WIDTH = 44, ++ SUB_GRAIN_HEIGHT = 38, ++ FG_BLOCK_SIZE = 32, ++}; ++ ++static const int16_t gaussian_sequence[2048]; ++ ++#define BIT_DEPTH 16 ++#include "aom_film_grain_template.c" ++#undef BIT_DEPTH ++ ++#define BIT_DEPTH 8 ++#include "aom_film_grain_template.c" ++#undef BIT_DEPTH ++ ++ ++int ff_aom_apply_film_grain(AVFrame *out, const AVFrame *in, ++ const AVFilmGrainParams *params) ++{ ++ const AVFilmGrainAOMParams *const data = ¶ms->codec.aom; ++ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(out->format); ++ const int subx = desc->log2_chroma_w, suby = desc->log2_chroma_h; ++ const int pxstep = desc->comp[0].step; ++ ++ av_assert0(out->format == in->format); ++ av_assert0(params->type == AV_FILM_GRAIN_PARAMS_AV1); ++ ++ // Copy over the non-modified planes ++ if (!params->codec.aom.num_y_points) { ++ av_image_copy_plane(out->data[0], out->linesize[0], ++ in->data[0], in->linesize[0], ++ out->width * pxstep, out->height); ++ } ++ for (int uv = 0; uv < 2; uv++) { ++ if (!data->num_uv_points[uv]) { ++ av_image_copy_plane(out->data[1+uv], out->linesize[1+uv], ++ in->data[1+uv], in->linesize[1+uv], ++ AV_CEIL_RSHIFT(out->width, subx) * pxstep, ++ AV_CEIL_RSHIFT(out->height, suby)); ++ } ++ } ++ ++ switch (in->format) { ++ case AV_PIX_FMT_GRAY8: ++ case AV_PIX_FMT_YUV420P: ++ case AV_PIX_FMT_YUV422P: ++ case AV_PIX_FMT_YUV444P: ++ case AV_PIX_FMT_YUVJ420P: ++ case AV_PIX_FMT_YUVJ422P: ++ case AV_PIX_FMT_YUVJ444P: ++ return apply_film_grain_8(out, in, params); ++ case AV_PIX_FMT_GRAY9: ++ case AV_PIX_FMT_YUV420P9: ++ case AV_PIX_FMT_YUV422P9: ++ case AV_PIX_FMT_YUV444P9: ++ return apply_film_grain_16(out, in, params, 9); ++ case AV_PIX_FMT_GRAY10: ++ case AV_PIX_FMT_YUV420P10: ++ case AV_PIX_FMT_YUV422P10: ++ case AV_PIX_FMT_YUV444P10: ++ return apply_film_grain_16(out, in, params, 10); ++ case AV_PIX_FMT_GRAY12: ++ case AV_PIX_FMT_YUV420P12: ++ case AV_PIX_FMT_YUV422P12: ++ case AV_PIX_FMT_YUV444P12: ++ return apply_film_grain_16(out, in, params, 12); ++ } ++ ++ /* The AV1 spec only defines film grain synthesis for these formats */ ++ return AVERROR_INVALIDDATA; ++} ++ ++// Taken from the AV1 spec. Range is [-2048, 2047], mean is 0 and stddev is 512 ++static const int16_t gaussian_sequence[2048] = { ++ 56, 568, -180, 172, 124, -84, 172, -64, -900, 24, 820, ++ 224, 1248, 996, 272, -8, -916, -388, -732, -104, -188, 800, ++ 112, -652, -320, -376, 140, -252, 492, -168, 44, -788, 588, ++ -584, 500, -228, 12, 680, 272, -476, 972, -100, 652, 368, ++ 432, -196, -720, -192, 1000, -332, 652, -136, -552, -604, -4, ++ 192, -220, -136, 1000, -52, 372, -96, -624, 124, -24, 396, ++ 540, -12, -104, 640, 464, 244, -208, -84, 368, -528, -740, ++ 248, -968, -848, 608, 376, -60, -292, -40, -156, 252, -292, ++ 248, 224, -280, 400, -244, 244, -60, 76, -80, 212, 532, ++ 340, 128, -36, 824, -352, -60, -264, -96, -612, 416, -704, ++ 220, -204, 640, -160, 1220, -408, 900, 336, 20, -336, -96, ++ -792, 304, 48, -28, -1232, -1172, -448, 104, -292, -520, 244, ++ 60, -948, 0, -708, 268, 108, 356, -548, 488, -344, -136, ++ 488, -196, -224, 656, -236, -1128, 60, 4, 140, 276, -676, ++ -376, 168, -108, 464, 8, 564, 64, 240, 308, -300, -400, ++ -456, -136, 56, 120, -408, -116, 436, 504, -232, 328, 844, ++ -164, -84, 784, -168, 232, -224, 348, -376, 128, 568, 96, ++ -1244, -288, 276, 848, 832, -360, 656, 464, -384, -332, -356, ++ 728, -388, 160, -192, 468, 296, 224, 140, -776, -100, 280, ++ 4, 196, 44, -36, -648, 932, 16, 1428, 28, 528, 808, ++ 772, 20, 268, 88, -332, -284, 124, -384, -448, 208, -228, ++ -1044, -328, 660, 380, -148, -300, 588, 240, 540, 28, 136, ++ -88, -436, 256, 296, -1000, 1400, 0, -48, 1056, -136, 264, ++ -528, -1108, 632, -484, -592, -344, 796, 124, -668, -768, 388, ++ 1296, -232, -188, -200, -288, -4, 308, 100, -168, 256, -500, ++ 204, -508, 648, -136, 372, -272, -120, -1004, -552, -548, -384, ++ 548, -296, 428, -108, -8, -912, -324, -224, -88, -112, -220, ++ -100, 996, -796, 548, 360, -216, 180, 428, -200, -212, 148, ++ 96, 148, 284, 216, -412, -320, 120, -300, -384, -604, -572, ++ -332, -8, -180, -176, 696, 116, -88, 628, 76, 44, -516, ++ 240, -208, -40, 100, -592, 344, -308, -452, -228, 20, 916, ++ -1752, -136, -340, -804, 140, 40, 512, 340, 248, 184, -492, ++ 896, -156, 932, -628, 328, -688, -448, -616, -752, -100, 560, ++ -1020, 180, -800, -64, 76, 576, 1068, 396, 660, 552, -108, ++ -28, 320, -628, 312, -92, -92, -472, 268, 16, 560, 516, ++ -672, -52, 492, -100, 260, 384, 284, 292, 304, -148, 88, ++ -152, 1012, 1064, -228, 164, -376, -684, 592, -392, 156, 196, ++ -524, -64, -884, 160, -176, 636, 648, 404, -396, -436, 864, ++ 424, -728, 988, -604, 904, -592, 296, -224, 536, -176, -920, ++ 436, -48, 1176, -884, 416, -776, -824, -884, 524, -548, -564, ++ -68, -164, -96, 692, 364, -692, -1012, -68, 260, -480, 876, ++ -1116, 452, -332, -352, 892, -1088, 1220, -676, 12, -292, 244, ++ 496, 372, -32, 280, 200, 112, -440, -96, 24, -644, -184, ++ 56, -432, 224, -980, 272, -260, 144, -436, 420, 356, 364, ++ -528, 76, 172, -744, -368, 404, -752, -416, 684, -688, 72, ++ 540, 416, 92, 444, 480, -72, -1416, 164, -1172, -68, 24, ++ 424, 264, 1040, 128, -912, -524, -356, 64, 876, -12, 4, ++ -88, 532, 272, -524, 320, 276, -508, 940, 24, -400, -120, ++ 756, 60, 236, -412, 100, 376, -484, 400, -100, -740, -108, ++ -260, 328, -268, 224, -200, -416, 184, -604, -564, -20, 296, ++ 60, 892, -888, 60, 164, 68, -760, 216, -296, 904, -336, ++ -28, 404, -356, -568, -208, -1480, -512, 296, 328, -360, -164, ++ -1560, -776, 1156, -428, 164, -504, -112, 120, -216, -148, -264, ++ 308, 32, 64, -72, 72, 116, 176, -64, -272, 460, -536, ++ -784, -280, 348, 108, -752, -132, 524, -540, -776, 116, -296, ++ -1196, -288, -560, 1040, -472, 116, -848, -1116, 116, 636, 696, ++ 284, -176, 1016, 204, -864, -648, -248, 356, 972, -584, -204, ++ 264, 880, 528, -24, -184, 116, 448, -144, 828, 524, 212, ++ -212, 52, 12, 200, 268, -488, -404, -880, 824, -672, -40, ++ 908, -248, 500, 716, -576, 492, -576, 16, 720, -108, 384, ++ 124, 344, 280, 576, -500, 252, 104, -308, 196, -188, -8, ++ 1268, 296, 1032, -1196, 436, 316, 372, -432, -200, -660, 704, ++ -224, 596, -132, 268, 32, -452, 884, 104, -1008, 424, -1348, ++ -280, 4, -1168, 368, 476, 696, 300, -8, 24, 180, -592, ++ -196, 388, 304, 500, 724, -160, 244, -84, 272, -256, -420, ++ 320, 208, -144, -156, 156, 364, 452, 28, 540, 316, 220, ++ -644, -248, 464, 72, 360, 32, -388, 496, -680, -48, 208, ++ -116, -408, 60, -604, -392, 548, -840, 784, -460, 656, -544, ++ -388, -264, 908, -800, -628, -612, -568, 572, -220, 164, 288, ++ -16, -308, 308, -112, -636, -760, 280, -668, 432, 364, 240, ++ -196, 604, 340, 384, 196, 592, -44, -500, 432, -580, -132, ++ 636, -76, 392, 4, -412, 540, 508, 328, -356, -36, 16, ++ -220, -64, -248, -60, 24, -192, 368, 1040, 92, -24, -1044, ++ -32, 40, 104, 148, 192, -136, -520, 56, -816, -224, 732, ++ 392, 356, 212, -80, -424, -1008, -324, 588, -1496, 576, 460, ++ -816, -848, 56, -580, -92, -1372, -112, -496, 200, 364, 52, ++ -140, 48, -48, -60, 84, 72, 40, 132, -356, -268, -104, ++ -284, -404, 732, -520, 164, -304, -540, 120, 328, -76, -460, ++ 756, 388, 588, 236, -436, -72, -176, -404, -316, -148, 716, ++ -604, 404, -72, -88, -888, -68, 944, 88, -220, -344, 960, ++ 472, 460, -232, 704, 120, 832, -228, 692, -508, 132, -476, ++ 844, -748, -364, -44, 1116, -1104, -1056, 76, 428, 552, -692, ++ 60, 356, 96, -384, -188, -612, -576, 736, 508, 892, 352, ++ -1132, 504, -24, -352, 324, 332, -600, -312, 292, 508, -144, ++ -8, 484, 48, 284, -260, -240, 256, -100, -292, -204, -44, ++ 472, -204, 908, -188, -1000, -256, 92, 1164, -392, 564, 356, ++ 652, -28, -884, 256, 484, -192, 760, -176, 376, -524, -452, ++ -436, 860, -736, 212, 124, 504, -476, 468, 76, -472, 552, ++ -692, -944, -620, 740, -240, 400, 132, 20, 192, -196, 264, ++ -668, -1012, -60, 296, -316, -828, 76, -156, 284, -768, -448, ++ -832, 148, 248, 652, 616, 1236, 288, -328, -400, -124, 588, ++ 220, 520, -696, 1032, 768, -740, -92, -272, 296, 448, -464, ++ 412, -200, 392, 440, -200, 264, -152, -260, 320, 1032, 216, ++ 320, -8, -64, 156, -1016, 1084, 1172, 536, 484, -432, 132, ++ 372, -52, -256, 84, 116, -352, 48, 116, 304, -384, 412, ++ 924, -300, 528, 628, 180, 648, 44, -980, -220, 1320, 48, ++ 332, 748, 524, -268, -720, 540, -276, 564, -344, -208, -196, ++ 436, 896, 88, -392, 132, 80, -964, -288, 568, 56, -48, ++ -456, 888, 8, 552, -156, -292, 948, 288, 128, -716, -292, ++ 1192, -152, 876, 352, -600, -260, -812, -468, -28, -120, -32, ++ -44, 1284, 496, 192, 464, 312, -76, -516, -380, -456, -1012, ++ -48, 308, -156, 36, 492, -156, -808, 188, 1652, 68, -120, ++ -116, 316, 160, -140, 352, 808, -416, 592, 316, -480, 56, ++ 528, -204, -568, 372, -232, 752, -344, 744, -4, 324, -416, ++ -600, 768, 268, -248, -88, -132, -420, -432, 80, -288, 404, ++ -316, -1216, -588, 520, -108, 92, -320, 368, -480, -216, -92, ++ 1688, -300, 180, 1020, -176, 820, -68, -228, -260, 436, -904, ++ 20, 40, -508, 440, -736, 312, 332, 204, 760, -372, 728, ++ 96, -20, -632, -520, -560, 336, 1076, -64, -532, 776, 584, ++ 192, 396, -728, -520, 276, -188, 80, -52, -612, -252, -48, ++ 648, 212, -688, 228, -52, -260, 428, -412, -272, -404, 180, ++ 816, -796, 48, 152, 484, -88, -216, 988, 696, 188, -528, ++ 648, -116, -180, 316, 476, 12, -564, 96, 476, -252, -364, ++ -376, -392, 556, -256, -576, 260, -352, 120, -16, -136, -260, ++ -492, 72, 556, 660, 580, 616, 772, 436, 424, -32, -324, ++ -1268, 416, -324, -80, 920, 160, 228, 724, 32, -516, 64, ++ 384, 68, -128, 136, 240, 248, -204, -68, 252, -932, -120, ++ -480, -628, -84, 192, 852, -404, -288, -132, 204, 100, 168, ++ -68, -196, -868, 460, 1080, 380, -80, 244, 0, 484, -888, ++ 64, 184, 352, 600, 460, 164, 604, -196, 320, -64, 588, ++ -184, 228, 12, 372, 48, -848, -344, 224, 208, -200, 484, ++ 128, -20, 272, -468, -840, 384, 256, -720, -520, -464, -580, ++ 112, -120, 644, -356, -208, -608, -528, 704, 560, -424, 392, ++ 828, 40, 84, 200, -152, 0, -144, 584, 280, -120, 80, ++ -556, -972, -196, -472, 724, 80, 168, -32, 88, 160, -688, ++ 0, 160, 356, 372, -776, 740, -128, 676, -248, -480, 4, ++ -364, 96, 544, 232, -1032, 956, 236, 356, 20, -40, 300, ++ 24, -676, -596, 132, 1120, -104, 532, -1096, 568, 648, 444, ++ 508, 380, 188, -376, -604, 1488, 424, 24, 756, -220, -192, ++ 716, 120, 920, 688, 168, 44, -460, 568, 284, 1144, 1160, ++ 600, 424, 888, 656, -356, -320, 220, 316, -176, -724, -188, ++ -816, -628, -348, -228, -380, 1012, -452, -660, 736, 928, 404, ++ -696, -72, -268, -892, 128, 184, -344, -780, 360, 336, 400, ++ 344, 428, 548, -112, 136, -228, -216, -820, -516, 340, 92, ++ -136, 116, -300, 376, -244, 100, -316, -520, -284, -12, 824, ++ 164, -548, -180, -128, 116, -924, -828, 268, -368, -580, 620, ++ 192, 160, 0, -1676, 1068, 424, -56, -360, 468, -156, 720, ++ 288, -528, 556, -364, 548, -148, 504, 316, 152, -648, -620, ++ -684, -24, -376, -384, -108, -920, -1032, 768, 180, -264, -508, ++ -1268, -260, -60, 300, -240, 988, 724, -376, -576, -212, -736, ++ 556, 192, 1092, -620, -880, 376, -56, -4, -216, -32, 836, ++ 268, 396, 1332, 864, -600, 100, 56, -412, -92, 356, 180, ++ 884, -468, -436, 292, -388, -804, -704, -840, 368, -348, 140, ++ -724, 1536, 940, 372, 112, -372, 436, -480, 1136, 296, -32, ++ -228, 132, -48, -220, 868, -1016, -60, -1044, -464, 328, 916, ++ 244, 12, -736, -296, 360, 468, -376, -108, -92, 788, 368, ++ -56, 544, 400, -672, -420, 728, 16, 320, 44, -284, -380, ++ -796, 488, 132, 204, -596, -372, 88, -152, -908, -636, -572, ++ -624, -116, -692, -200, -56, 276, -88, 484, -324, 948, 864, ++ 1000, -456, -184, -276, 292, -296, 156, 676, 320, 160, 908, ++ -84, -1236, -288, -116, 260, -372, -644, 732, -756, -96, 84, ++ 344, -520, 348, -688, 240, -84, 216, -1044, -136, -676, -396, ++ -1500, 960, -40, 176, 168, 1516, 420, -504, -344, -364, -360, ++ 1216, -940, -380, -212, 252, -660, -708, 484, -444, -152, 928, ++ -120, 1112, 476, -260, 560, -148, -344, 108, -196, 228, -288, ++ 504, 560, -328, -88, 288, -1008, 460, -228, 468, -836, -196, ++ 76, 388, 232, 412, -1168, -716, -644, 756, -172, -356, -504, ++ 116, 432, 528, 48, 476, -168, -608, 448, 160, -532, -272, ++ 28, -676, -12, 828, 980, 456, 520, 104, -104, 256, -344, ++ -4, -28, -368, -52, -524, -572, -556, -200, 768, 1124, -208, ++ -512, 176, 232, 248, -148, -888, 604, -600, -304, 804, -156, ++ -212, 488, -192, -804, -256, 368, -360, -916, -328, 228, -240, ++ -448, -472, 856, -556, -364, 572, -12, -156, -368, -340, 432, ++ 252, -752, -152, 288, 268, -580, -848, -592, 108, -76, 244, ++ 312, -716, 592, -80, 436, 360, 4, -248, 160, 516, 584, ++ 732, 44, -468, -280, -292, -156, -588, 28, 308, 912, 24, ++ 124, 156, 180, -252, 944, -924, -772, -520, -428, -624, 300, ++ -212, -1144, 32, -724, 800, -1128, -212, -1288, -848, 180, -416, ++ 440, 192, -576, -792, -76, -1080, 80, -532, -352, -132, 380, ++ -820, 148, 1112, 128, 164, 456, 700, -924, 144, -668, -384, ++ 648, -832, 508, 552, -52, -100, -656, 208, -568, 748, -88, ++ 680, 232, 300, 192, -408, -1012, -152, -252, -268, 272, -876, ++ -664, -648, -332, -136, 16, 12, 1152, -28, 332, -536, 320, ++ -672, -460, -316, 532, -260, 228, -40, 1052, -816, 180, 88, ++ -496, -556, -672, -368, 428, 92, 356, 404, -408, 252, 196, ++ -176, -556, 792, 268, 32, 372, 40, 96, -332, 328, 120, ++ 372, -900, -40, 472, -264, -592, 952, 128, 656, 112, 664, ++ -232, 420, 4, -344, -464, 556, 244, -416, -32, 252, 0, ++ -412, 188, -696, 508, -476, 324, -1096, 656, -312, 560, 264, ++ -136, 304, 160, -64, -580, 248, 336, -720, 560, -348, -288, ++ -276, -196, -500, 852, -544, -236, -1128, -992, -776, 116, 56, ++ 52, 860, 884, 212, -12, 168, 1020, 512, -552, 924, -148, ++ 716, 188, 164, -340, -520, -184, 880, -152, -680, -208, -1156, ++ -300, -528, -472, 364, 100, -744, -1056, -32, 540, 280, 144, ++ -676, -32, -232, -280, -224, 96, 568, -76, 172, 148, 148, ++ 104, 32, -296, -32, 788, -80, 32, -16, 280, 288, 944, ++ 428, -484 ++}; +diff --git a/libavcodec/aom_film_grain.h b/libavcodec/aom_film_grain.h +new file mode 100644 +index 0000000000..5d772bd7d1 +--- /dev/null ++++ b/libavcodec/aom_film_grain.h +@@ -0,0 +1,38 @@ ++/* ++ * AOM film grain synthesis ++ * Copyright (c) 2021 Niklas Haas ++ * ++ * This file is part of FFmpeg. ++ * ++ * FFmpeg is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * FFmpeg is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with FFmpeg; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++/** ++ * @file ++ * AOM film grain synthesis. ++ * @author Niklas Haas ++ */ ++ ++#ifndef AVCODEC_AOM_FILM_GRAIN_H ++#define AVCODEC_AOM_FILM_GRAIN_H ++ ++#include "libavutil/film_grain_params.h" ++ ++// Synthesizes film grain on top of `in` and stores the result to `out`. `out` ++// must already have been allocated and set to the same size and format as `in`. ++int ff_aom_apply_film_grain(AVFrame *out, const AVFrame *in, ++ const AVFilmGrainParams *params); ++ ++#endif /* AVCODEC_AOM_FILM_GRAIN_H */ +diff --git a/libavcodec/aom_film_grain_template.c b/libavcodec/aom_film_grain_template.c +new file mode 100644 +index 0000000000..5f9f29f1fa +--- /dev/null ++++ b/libavcodec/aom_film_grain_template.c +@@ -0,0 +1,577 @@ ++/* ++ * AOM film grain synthesis ++ * Copyright (c) 2023 Niklas Haas ++ * ++ * This file is part of FFmpeg. ++ * ++ * FFmpeg is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * FFmpeg is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with FFmpeg; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++/* ++ * Copyright © 2018, Niklas Haas ++ * Copyright © 2018, VideoLAN and dav1d authors ++ * Copyright © 2018, Two Orioles, LLC ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright notice, this ++ * list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright notice, ++ * this list of conditions and the following disclaimer in the documentation ++ * and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ++ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ++ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ++ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include "bit_depth_template.c" ++ ++#undef entry ++#undef bitdepth ++#undef bitdepth_max ++#undef HBD_DECL ++#undef HBD_CALL ++#undef SCALING_SIZE ++ ++#if BIT_DEPTH > 8 ++# define entry int16_t ++# define bitdepth_max ((1 << bitdepth) - 1) ++# define HBD_DECL , const int bitdepth ++# define HBD_CALL , bitdepth ++# define SCALING_SIZE 4096 ++#else ++# define entry int8_t ++# define bitdepth 8 ++# define bitdepth_max UINT8_MAX ++# define HBD_DECL ++# define HBD_CALL ++# define SCALING_SIZE 256 ++#endif ++ ++static void FUNC(generate_grain_y_c)(entry buf[][GRAIN_WIDTH], ++ const AVFilmGrainParams *const params ++ HBD_DECL) ++{ ++ const AVFilmGrainAOMParams *const data = ¶ms->codec.aom; ++ const int bitdepth_min_8 = bitdepth - 8; ++ unsigned seed = params->seed; ++ const int shift = 4 - bitdepth_min_8 + data->grain_scale_shift; ++ const int grain_ctr = 128 << bitdepth_min_8; ++ const int grain_min = -grain_ctr, grain_max = grain_ctr - 1; ++ ++ const int ar_pad = 3; ++ const int ar_lag = data->ar_coeff_lag; ++ ++ for (int y = 0; y < GRAIN_HEIGHT; y++) { ++ for (int x = 0; x < GRAIN_WIDTH; x++) { ++ const int value = get_random_number(11, &seed); ++ buf[y][x] = round2(gaussian_sequence[ value ], shift); ++ } ++ } ++ ++ for (int y = ar_pad; y < GRAIN_HEIGHT; y++) { ++ for (int x = ar_pad; x < GRAIN_WIDTH - ar_pad; x++) { ++ const int8_t *coeff = data->ar_coeffs_y; ++ int sum = 0, grain; ++ for (int dy = -ar_lag; dy <= 0; dy++) { ++ for (int dx = -ar_lag; dx <= ar_lag; dx++) { ++ if (!dx && !dy) ++ break; ++ sum += *(coeff++) * buf[y + dy][x + dx]; ++ } ++ } ++ ++ grain = buf[y][x] + round2(sum, data->ar_coeff_shift); ++ buf[y][x] = av_clip(grain, grain_min, grain_max); ++ } ++ } ++} ++ ++static void ++FUNC(generate_grain_uv_c)(entry buf[][GRAIN_WIDTH], ++ const entry buf_y[][GRAIN_WIDTH], ++ const AVFilmGrainParams *const params, const intptr_t uv, ++ const int subx, const int suby HBD_DECL) ++{ ++ const AVFilmGrainAOMParams *const data = ¶ms->codec.aom; ++ const int bitdepth_min_8 = bitdepth - 8; ++ unsigned seed = params->seed ^ (uv ? 0x49d8 : 0xb524); ++ const int shift = 4 - bitdepth_min_8 + data->grain_scale_shift; ++ const int grain_ctr = 128 << bitdepth_min_8; ++ const int grain_min = -grain_ctr, grain_max = grain_ctr - 1; ++ ++ const int chromaW = subx ? SUB_GRAIN_WIDTH : GRAIN_WIDTH; ++ const int chromaH = suby ? SUB_GRAIN_HEIGHT : GRAIN_HEIGHT; ++ ++ const int ar_pad = 3; ++ const int ar_lag = data->ar_coeff_lag; ++ ++ for (int y = 0; y < chromaH; y++) { ++ for (int x = 0; x < chromaW; x++) { ++ const int value = get_random_number(11, &seed); ++ buf[y][x] = round2(gaussian_sequence[ value ], shift); ++ } ++ } ++ ++ for (int y = ar_pad; y < chromaH; y++) { ++ for (int x = ar_pad; x < chromaW - ar_pad; x++) { ++ const int8_t *coeff = data->ar_coeffs_uv[uv]; ++ int sum = 0, grain; ++ for (int dy = -ar_lag; dy <= 0; dy++) { ++ for (int dx = -ar_lag; dx <= ar_lag; dx++) { ++ // For the final (current) pixel, we need to add in the ++ // contribution from the luma grain texture ++ if (!dx && !dy) { ++ const int lumaX = ((x - ar_pad) << subx) + ar_pad; ++ const int lumaY = ((y - ar_pad) << suby) + ar_pad; ++ int luma = 0; ++ if (!data->num_y_points) ++ break; ++ for (int i = 0; i <= suby; i++) { ++ for (int j = 0; j <= subx; j++) { ++ luma += buf_y[lumaY + i][lumaX + j]; ++ } ++ } ++ luma = round2(luma, subx + suby); ++ sum += luma * (*coeff); ++ break; ++ } ++ ++ sum += *(coeff++) * buf[y + dy][x + dx]; ++ } ++ } ++ ++ grain = buf[y][x] + round2(sum, data->ar_coeff_shift); ++ buf[y][x] = av_clip(grain, grain_min, grain_max); ++ } ++ } ++} ++ ++// samples from the correct block of a grain LUT, while taking into account the ++// offsets provided by the offsets cache ++static inline entry FUNC(sample_lut)(const entry grain_lut[][GRAIN_WIDTH], ++ const int offsets[2][2], ++ const int subx, const int suby, ++ const int bx, const int by, ++ const int x, const int y) ++{ ++ const int randval = offsets[bx][by]; ++ const int offx = 3 + (2 >> subx) * (3 + (randval >> 4)); ++ const int offy = 3 + (2 >> suby) * (3 + (randval & 0xF)); ++ return grain_lut[offy + y + (FG_BLOCK_SIZE >> suby) * by] ++ [offx + x + (FG_BLOCK_SIZE >> subx) * bx]; ++} ++ ++static void FUNC(fgy_32x32xn_c)(pixel *const dst_row, const pixel *const src_row, ++ const ptrdiff_t stride, ++ const AVFilmGrainParams *const params, const size_t pw, ++ const uint8_t scaling[SCALING_SIZE], ++ const entry grain_lut[][GRAIN_WIDTH], ++ const int bh, const int row_num HBD_DECL) ++{ ++ const AVFilmGrainAOMParams *const data = ¶ms->codec.aom; ++ const int rows = 1 + (data->overlap_flag && row_num > 0); ++ const int bitdepth_min_8 = bitdepth - 8; ++ const int grain_ctr = 128 << bitdepth_min_8; ++ const int grain_min = -grain_ctr, grain_max = grain_ctr - 1; ++ unsigned seed[2]; ++ int offsets[2 /* col offset */][2 /* row offset */]; ++ ++ int min_value, max_value; ++ if (data->limit_output_range) { ++ min_value = 16 << bitdepth_min_8; ++ max_value = 235 << bitdepth_min_8; ++ } else { ++ min_value = 0; ++ max_value = bitdepth_max; ++ } ++ ++ // seed[0] contains the current row, seed[1] contains the previous ++ for (int i = 0; i < rows; i++) { ++ seed[i] = params->seed; ++ seed[i] ^= (((row_num - i) * 37 + 178) & 0xFF) << 8; ++ seed[i] ^= (((row_num - i) * 173 + 105) & 0xFF); ++ } ++ ++ av_assert1(stride % (FG_BLOCK_SIZE * sizeof(pixel)) == 0); ++ ++ // process this row in FG_BLOCK_SIZE^2 blocks ++ for (unsigned bx = 0; bx < pw; bx += FG_BLOCK_SIZE) { ++ const int bw = FFMIN(FG_BLOCK_SIZE, (int) pw - bx); ++ const pixel *src; ++ pixel *dst; ++ int noise; ++ ++ // x/y block offsets to compensate for overlapped regions ++ const int ystart = data->overlap_flag && row_num ? FFMIN(2, bh) : 0; ++ const int xstart = data->overlap_flag && bx ? FFMIN(2, bw) : 0; ++ ++ static const int w[2][2] = { { 27, 17 }, { 17, 27 } }; ++ ++ if (data->overlap_flag && bx) { ++ // shift previous offsets left ++ for (int i = 0; i < rows; i++) ++ offsets[1][i] = offsets[0][i]; ++ } ++ ++ // update current offsets ++ for (int i = 0; i < rows; i++) ++ offsets[0][i] = get_random_number(8, &seed[i]); ++ ++#define add_noise_y(x, y, grain) \ ++ src = (const pixel*)((const char*)src_row + (y) * stride) + (x) + bx; \ ++ dst = (pixel*)((char*)dst_row + (y) * stride) + (x) + bx; \ ++ noise = round2(scaling[ *src ] * (grain), data->scaling_shift); \ ++ *dst = av_clip(*src + noise, min_value, max_value); ++ ++ for (int y = ystart; y < bh; y++) { ++ // Non-overlapped image region (straightforward) ++ for (int x = xstart; x < bw; x++) { ++ int grain = FUNC(sample_lut)(grain_lut, offsets, 0, 0, 0, 0, x, y); ++ add_noise_y(x, y, grain); ++ } ++ ++ // Special case for overlapped column ++ for (int x = 0; x < xstart; x++) { ++ int grain = FUNC(sample_lut)(grain_lut, offsets, 0, 0, 0, 0, x, y); ++ int old = FUNC(sample_lut)(grain_lut, offsets, 0, 0, 1, 0, x, y); ++ grain = round2(old * w[x][0] + grain * w[x][1], 5); ++ grain = av_clip(grain, grain_min, grain_max); ++ add_noise_y(x, y, grain); ++ } ++ } ++ ++ for (int y = 0; y < ystart; y++) { ++ // Special case for overlapped row (sans corner) ++ for (int x = xstart; x < bw; x++) { ++ int grain = FUNC(sample_lut)(grain_lut, offsets, 0, 0, 0, 0, x, y); ++ int old = FUNC(sample_lut)(grain_lut, offsets, 0, 0, 0, 1, x, y); ++ grain = round2(old * w[y][0] + grain * w[y][1], 5); ++ grain = av_clip(grain, grain_min, grain_max); ++ add_noise_y(x, y, grain); ++ } ++ ++ // Special case for doubly-overlapped corner ++ for (int x = 0; x < xstart; x++) { ++ int grain = FUNC(sample_lut)(grain_lut, offsets, 0, 0, 0, 0, x, y); ++ int top = FUNC(sample_lut)(grain_lut, offsets, 0, 0, 0, 1, x, y); ++ int old = FUNC(sample_lut)(grain_lut, offsets, 0, 0, 1, 1, x, y); ++ ++ // Blend the top pixel with the top left block ++ top = round2(old * w[x][0] + top * w[x][1], 5); ++ top = av_clip(top, grain_min, grain_max); ++ ++ // Blend the current pixel with the left block ++ old = FUNC(sample_lut)(grain_lut, offsets, 0, 0, 1, 0, x, y); ++ grain = round2(old * w[x][0] + grain * w[x][1], 5); ++ grain = av_clip(grain, grain_min, grain_max); ++ ++ // Mix the row rows together and apply grain ++ grain = round2(top * w[y][0] + grain * w[y][1], 5); ++ grain = av_clip(grain, grain_min, grain_max); ++ add_noise_y(x, y, grain); ++ } ++ } ++ } ++} ++ ++static void ++FUNC(fguv_32x32xn_c)(pixel *const dst_row, const pixel *const src_row, ++ const ptrdiff_t stride, const AVFilmGrainParams *const params, ++ const size_t pw, const uint8_t scaling[SCALING_SIZE], ++ const entry grain_lut[][GRAIN_WIDTH], const int bh, ++ const int row_num, const pixel *const luma_row, ++ const ptrdiff_t luma_stride, const int uv, const int is_id, ++ const int sx, const int sy HBD_DECL) ++{ ++ const AVFilmGrainAOMParams *const data = ¶ms->codec.aom; ++ const int rows = 1 + (data->overlap_flag && row_num > 0); ++ const int bitdepth_min_8 = bitdepth - 8; ++ const int grain_ctr = 128 << bitdepth_min_8; ++ const int grain_min = -grain_ctr, grain_max = grain_ctr - 1; ++ unsigned seed[2]; ++ int offsets[2 /* col offset */][2 /* row offset */]; ++ ++ int min_value, max_value; ++ if (data->limit_output_range) { ++ min_value = 16 << bitdepth_min_8; ++ max_value = (is_id ? 235 : 240) << bitdepth_min_8; ++ } else { ++ min_value = 0; ++ max_value = bitdepth_max; ++ } ++ ++ // seed[0] contains the current row, seed[1] contains the previous ++ for (int i = 0; i < rows; i++) { ++ seed[i] = params->seed; ++ seed[i] ^= (((row_num - i) * 37 + 178) & 0xFF) << 8; ++ seed[i] ^= (((row_num - i) * 173 + 105) & 0xFF); ++ } ++ ++ av_assert1(stride % (FG_BLOCK_SIZE * sizeof(pixel)) == 0); ++ ++ // process this row in FG_BLOCK_SIZE^2 blocks (subsampled) ++ for (unsigned bx = 0; bx < pw; bx += FG_BLOCK_SIZE >> sx) { ++ const int bw = FFMIN(FG_BLOCK_SIZE >> sx, (int)(pw - bx)); ++ int val, lx, ly, noise; ++ const pixel *src, *luma; ++ pixel *dst, avg; ++ ++ // x/y block offsets to compensate for overlapped regions ++ const int ystart = data->overlap_flag && row_num ? FFMIN(2 >> sy, bh) : 0; ++ const int xstart = data->overlap_flag && bx ? FFMIN(2 >> sx, bw) : 0; ++ ++ static const int w[2 /* sub */][2 /* off */][2] = { ++ { { 27, 17 }, { 17, 27 } }, ++ { { 23, 22 } }, ++ }; ++ ++ if (data->overlap_flag && bx) { ++ // shift previous offsets left ++ for (int i = 0; i < rows; i++) ++ offsets[1][i] = offsets[0][i]; ++ } ++ ++ // update current offsets ++ for (int i = 0; i < rows; i++) ++ offsets[0][i] = get_random_number(8, &seed[i]); ++ ++#define add_noise_uv(x, y, grain) \ ++ lx = (bx + x) << sx; \ ++ ly = y << sy; \ ++ luma = (const pixel*)((const char*)luma_row + ly * luma_stride) + lx;\ ++ avg = luma[0]; \ ++ if (sx) \ ++ avg = (avg + luma[1] + 1) >> 1; \ ++ src = (const pixel*)((const char *)src_row + (y) * stride) + bx + (x);\ ++ dst = (pixel *) ((char *) dst_row + (y) * stride) + bx + (x); \ ++ val = avg; \ ++ if (!data->chroma_scaling_from_luma) { \ ++ const int combined = avg * data->uv_mult_luma[uv] + \ ++ *src * data->uv_mult[uv]; \ ++ val = av_clip( (combined >> 6) + \ ++ (data->uv_offset[uv] * (1 << bitdepth_min_8)), \ ++ 0, bitdepth_max ); \ ++ } \ ++ noise = round2(scaling[ val ] * (grain), data->scaling_shift); \ ++ *dst = av_clip(*src + noise, min_value, max_value); ++ ++ for (int y = ystart; y < bh; y++) { ++ // Non-overlapped image region (straightforward) ++ for (int x = xstart; x < bw; x++) { ++ int grain = FUNC(sample_lut)(grain_lut, offsets, sx, sy, 0, 0, x, y); ++ add_noise_uv(x, y, grain); ++ } ++ ++ // Special case for overlapped column ++ for (int x = 0; x < xstart; x++) { ++ int grain = FUNC(sample_lut)(grain_lut, offsets, sx, sy, 0, 0, x, y); ++ int old = FUNC(sample_lut)(grain_lut, offsets, sx, sy, 1, 0, x, y); ++ grain = round2(old * w[sx][x][0] + grain * w[sx][x][1], 5); ++ grain = av_clip(grain, grain_min, grain_max); ++ add_noise_uv(x, y, grain); ++ } ++ } ++ ++ for (int y = 0; y < ystart; y++) { ++ // Special case for overlapped row (sans corner) ++ for (int x = xstart; x < bw; x++) { ++ int grain = FUNC(sample_lut)(grain_lut, offsets, sx, sy, 0, 0, x, y); ++ int old = FUNC(sample_lut)(grain_lut, offsets, sx, sy, 0, 1, x, y); ++ grain = round2(old * w[sy][y][0] + grain * w[sy][y][1], 5); ++ grain = av_clip(grain, grain_min, grain_max); ++ add_noise_uv(x, y, grain); ++ } ++ ++ // Special case for doubly-overlapped corner ++ for (int x = 0; x < xstart; x++) { ++ int top = FUNC(sample_lut)(grain_lut, offsets, sx, sy, 0, 1, x, y); ++ int old = FUNC(sample_lut)(grain_lut, offsets, sx, sy, 1, 1, x, y); ++ int grain = FUNC(sample_lut)(grain_lut, offsets, sx, sy, 0, 0, x, y); ++ ++ // Blend the top pixel with the top left block ++ top = round2(old * w[sx][x][0] + top * w[sx][x][1], 5); ++ top = av_clip(top, grain_min, grain_max); ++ ++ // Blend the current pixel with the left block ++ old = FUNC(sample_lut)(grain_lut, offsets, sx, sy, 1, 0, x, y); ++ grain = round2(old * w[sx][x][0] + grain * w[sx][x][1], 5); ++ grain = av_clip(grain, grain_min, grain_max); ++ ++ // Mix the row rows together and apply to image ++ grain = round2(top * w[sy][y][0] + grain * w[sy][y][1], 5); ++ grain = av_clip(grain, grain_min, grain_max); ++ add_noise_uv(x, y, grain); ++ } ++ } ++ } ++} ++ ++static void FUNC(generate_scaling)(const uint8_t points[][2], const int num, ++ uint8_t scaling[SCALING_SIZE] HBD_DECL) ++{ ++ const int shift_x = bitdepth - 8; ++ const int scaling_size = 1 << bitdepth; ++ const int max_value = points[num - 1][0] << shift_x; ++ av_assert0(scaling_size <= SCALING_SIZE); ++ ++ if (num == 0) { ++ memset(scaling, 0, scaling_size); ++ return; ++ } ++ ++ // Fill up the preceding entries with the initial value ++ memset(scaling, points[0][1], points[0][0] << shift_x); ++ ++ // Linearly interpolate the values in the middle ++ for (int i = 0; i < num - 1; i++) { ++ const int bx = points[i][0]; ++ const int by = points[i][1]; ++ const int ex = points[i+1][0]; ++ const int ey = points[i+1][1]; ++ const int dx = ex - bx; ++ const int dy = ey - by; ++ const int delta = dy * ((0x10000 + (dx >> 1)) / dx); ++ av_assert1(dx > 0); ++ for (int x = 0, d = 0x8000; x < dx; x++) { ++ scaling[(bx + x) << shift_x] = by + (d >> 16); ++ d += delta; ++ } ++ } ++ ++ // Fill up the remaining entries with the final value ++ memset(&scaling[max_value], points[num - 1][1], scaling_size - max_value); ++ ++#if BIT_DEPTH != 8 ++ for (int i = 0; i < num - 1; i++) { ++ const int pad = 1 << shift_x, rnd = pad >> 1; ++ const int bx = points[i][0] << shift_x; ++ const int ex = points[i+1][0] << shift_x; ++ const int dx = ex - bx; ++ for (int x = 0; x < dx; x += pad) { ++ const int range = scaling[bx + x + pad] - scaling[bx + x]; ++ for (int n = 1, r = rnd; n < pad; n++) { ++ r += range; ++ scaling[bx + x + n] = scaling[bx + x] + (r >> shift_x); ++ } ++ } ++ } ++#endif ++} ++ ++static av_always_inline void ++FUNC(apply_grain_row)(AVFrame *out, const AVFrame *in, ++ const int ss_x, const int ss_y, ++ const uint8_t scaling[3][SCALING_SIZE], ++ const entry grain_lut[3][GRAIN_HEIGHT+1][GRAIN_WIDTH], ++ const AVFilmGrainParams *params, ++ const int row HBD_DECL) ++{ ++ // Synthesize grain for the affected planes ++ const AVFilmGrainAOMParams *const data = ¶ms->codec.aom; ++ const int cpw = (out->width + ss_x) >> ss_x; ++ const int is_id = out->colorspace == AVCOL_SPC_RGB; ++ const int bh = (FFMIN(out->height - row * FG_BLOCK_SIZE, FG_BLOCK_SIZE) + ss_y) >> ss_y; ++ const ptrdiff_t uv_off = row * FG_BLOCK_SIZE * out->linesize[1] >> ss_y; ++ pixel *const luma_src = (pixel *) ++ ((char *) in->data[0] + row * FG_BLOCK_SIZE * in->linesize[0]); ++ ++ if (data->num_y_points) { ++ const int bh = FFMIN(out->height - row * FG_BLOCK_SIZE, FG_BLOCK_SIZE); ++ const ptrdiff_t off = row * FG_BLOCK_SIZE * out->linesize[0]; ++ FUNC(fgy_32x32xn_c)((pixel *) ((char *) out->data[0] + off), luma_src, ++ out->linesize[0], params, out->width, scaling[0], ++ grain_lut[0], bh, row HBD_CALL); ++ } ++ ++ if (!data->num_uv_points[0] && !data->num_uv_points[1] && ++ !data->chroma_scaling_from_luma) ++ { ++ return; ++ } ++ ++ // extend padding pixels ++ if (out->width & ss_x) { ++ pixel *ptr = luma_src; ++ for (int y = 0; y < bh; y++) { ++ ptr[out->width] = ptr[out->width - 1]; ++ ptr = (pixel *) ((char *) ptr + (in->linesize[0] << ss_y)); ++ } ++ } ++ ++ if (data->chroma_scaling_from_luma) { ++ for (int pl = 0; pl < 2; pl++) ++ FUNC(fguv_32x32xn_c)((pixel *) ((char *) out->data[1 + pl] + uv_off), ++ (const pixel *) ((const char *) in->data[1 + pl] + uv_off), ++ in->linesize[1], params, cpw, scaling[0], ++ grain_lut[1 + pl], bh, row, luma_src, ++ in->linesize[0], pl, is_id, ss_x, ss_y HBD_CALL); ++ } else { ++ for (int pl = 0; pl < 2; pl++) { ++ if (data->num_uv_points[pl]) { ++ FUNC(fguv_32x32xn_c)((pixel *) ((char *) out->data[1 + pl] + uv_off), ++ (const pixel *) ((const char *) in->data[1 + pl] + uv_off), ++ in->linesize[1], params, cpw, scaling[1 + pl], ++ grain_lut[1 + pl], bh, row, luma_src, ++ in->linesize[0], pl, is_id, ss_x, ss_y HBD_CALL); ++ } ++ } ++ } ++} ++ ++static int FUNC(apply_film_grain)(AVFrame *out_frame, const AVFrame *in_frame, ++ const AVFilmGrainParams *params HBD_DECL) ++{ ++ entry grain_lut[3][GRAIN_HEIGHT + 1][GRAIN_WIDTH]; ++ uint8_t scaling[3][SCALING_SIZE]; ++ ++ const AVFilmGrainAOMParams *const data = ¶ms->codec.aom; ++ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(out_frame->format); ++ const int rows = AV_CEIL_RSHIFT(out_frame->height, 5); /* log2(FG_BLOCK_SIZE) */ ++ const int subx = desc->log2_chroma_w, suby = desc->log2_chroma_h; ++ ++ // Generate grain LUTs as needed ++ FUNC(generate_grain_y_c)(grain_lut[0], params HBD_CALL); ++ if (data->num_uv_points[0] || data->chroma_scaling_from_luma) ++ FUNC(generate_grain_uv_c)(grain_lut[1], grain_lut[0], params, 0, subx, suby HBD_CALL); ++ if (data->num_uv_points[1] || data->chroma_scaling_from_luma) ++ FUNC(generate_grain_uv_c)(grain_lut[2], grain_lut[0], params, 1, subx, suby HBD_CALL); ++ ++ // Generate scaling LUTs as needed ++ if (data->num_y_points || data->chroma_scaling_from_luma) ++ FUNC(generate_scaling)(data->y_points, data->num_y_points, scaling[0] HBD_CALL); ++ if (data->num_uv_points[0]) ++ FUNC(generate_scaling)(data->uv_points[0], data->num_uv_points[0], scaling[1] HBD_CALL); ++ if (data->num_uv_points[1]) ++ FUNC(generate_scaling)(data->uv_points[1], data->num_uv_points[1], scaling[2] HBD_CALL); ++ ++ for (int row = 0; row < rows; row++) { ++ FUNC(apply_grain_row)(out_frame, in_frame, subx, suby, scaling, grain_lut, ++ params, row HBD_CALL); ++ } ++ ++ return 0; ++} +-- +2.41.0 diff --git a/ffmpeg-6-CVE-2024-32228-shim-5d7f234e.patch b/ffmpeg-6-CVE-2024-32228-shim-5d7f234e.patch new file mode 100644 index 0000000..4185e9e --- /dev/null +++ b/ffmpeg-6-CVE-2024-32228-shim-5d7f234e.patch @@ -0,0 +1,101 @@ +From 5d7f234e7ec45ccc385dca8c5fbe3b887af1c2c6 Mon Sep 17 00:00:00 2001 +Author: Niklas Haas +Date: Wed, 4 Oct 2023 14:05:24 +0200 +Subject: [PATCH] avcodec/hevcdec: apply AOM film grain synthesis +References: CVE-2024-32228 +References: bsc#1227277 +Upstream: Backport from upstream + +Following the usual logic for H.274 film grain. + +diff --git a/libavcodec/Makefile b/libavcodec/Makefile +index 824845276a..7ef2e03ca6 10064 +--- a/libavcodec/Makefile ++++ b/libavcodec/Makefile +@@ -432,7 +432,7 @@ OBJS-$(CONFIG_HDR_ENCODER) += hdrenc.o + OBJS-$(CONFIG_HEVC_DECODER) += hevcdec.o hevc_mvs.o \ + hevc_cabac.o hevc_refs.o hevcpred.o \ + hevcdsp.o hevc_filter.o hevc_data.o \ +- h274.o ++ h274.o aom_film_grain.o + OBJS-$(CONFIG_HEVC_AMF_ENCODER) += amfenc_hevc.o + OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuviddec.o + OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o +diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c +index 76aa6b4588..575836e340 100644 +--- a/libavcodec/hevcdec.c ++++ b/libavcodec/hevcdec.c +@@ -35,6 +35,7 @@ + #include "libavutil/pixdesc.h" + #include "libavutil/timecode.h" + ++#include "aom_film_grain.h" + #include "bswapdsp.h" + #include "cabac_functions.h" + #include "codec_internal.h" +@@ -388,7 +389,8 @@ static int export_stream_params_from_sei(HEVCContext *s) + avctx->color_trc = s->sei.common.alternative_transfer.preferred_transfer_characteristics; + } + +- if (s->sei.common.film_grain_characteristics.present) ++ if (s->sei.common.film_grain_characteristics.present || ++ s->sei.common.aom_film_grain.enable) + avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; + + return 0; +@@ -2885,11 +2887,13 @@ static int hevc_frame_start(HEVCContext *s) + else + s->ref->frame->flags &= ~AV_FRAME_FLAG_KEY; + +- s->ref->needs_fg = s->sei.common.film_grain_characteristics.present && ++ s->ref->needs_fg = (s->sei.common.film_grain_characteristics.present || ++ s->sei.common.aom_film_grain.enable) && + !(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && + !s->avctx->hwaccel; + + if (s->ref->needs_fg && ++ s->sei.common.film_grain_characteristics.present && + !ff_h274_film_grain_params_supported(s->sei.common.film_grain_characteristics.model_id, + s->ref->frame->format)) { + av_log_once(s->avctx, AV_LOG_WARNING, AV_LOG_DEBUG, &s->film_grain_warning_shown, +@@ -2934,14 +2938,24 @@ fail: + static int hevc_frame_end(HEVCContext *s) + { + HEVCFrame *out = s->ref; +- const AVFrameSideData *sd; ++ const AVFilmGrainParams *fgp; + av_unused int ret; + + if (out->needs_fg) { +- sd = av_frame_get_side_data(out->frame, AV_FRAME_DATA_FILM_GRAIN_PARAMS); +- av_assert0(out->frame_grain->buf[0] && sd); +- ret = ff_h274_apply_film_grain(out->frame_grain, out->frame, &s->h274db, +- (AVFilmGrainParams *) sd->data); ++ av_assert0(out->frame_grain->buf[0]); ++ fgp = av_film_grain_params_select(out->frame); ++ switch (fgp->type) { ++ case AV_FILM_GRAIN_PARAMS_NONE: ++ av_assert0(0); ++ return AVERROR_BUG; ++ case AV_FILM_GRAIN_PARAMS_H274: ++ ret = ff_h274_apply_film_grain(out->frame_grain, out->frame, ++ &s->h274db, fgp); ++ break; ++ case AV_FILM_GRAIN_PARAMS_AV1: ++ ret = ff_aom_apply_film_grain(out->frame_grain, out->frame, fgp); ++ break; ++ } + av_assert1(ret >= 0); + } + +@@ -3596,6 +3610,7 @@ static int hevc_update_thread_context(AVCodecContext *dst, + s->sei.common.alternative_transfer = s0->sei.common.alternative_transfer; + s->sei.common.mastering_display = s0->sei.common.mastering_display; + s->sei.common.content_light = s0->sei.common.content_light; ++ s->sei.common.aom_film_grain = s0->sei.common.aom_film_grain; + + ret = export_stream_params_from_sei(s); + if (ret < 0) +-- +2.41.0 + diff --git a/ffmpeg-6-CVE-2024-32228-shim-f50382cb.patch b/ffmpeg-6-CVE-2024-32228-shim-f50382cb.patch new file mode 100644 index 0000000..0bbf0f4 --- /dev/null +++ b/ffmpeg-6-CVE-2024-32228-shim-f50382cb.patch @@ -0,0 +1,319 @@ +From f50382cba60d106440f1ad83396ff7bed586a5ac Mon Sep 17 00:00:00 2001 +Author: Niklas Haas +Date: Mon, 26 Feb 2024 14:12:53 +0100 +Subject: [PATCH] avcodec/aom_film_grain: implement AFGS1 parsing +References: CVE-2024-32228 +References: bsc#1227277 +Upstream: Backport from upstream + +Based on the AOMedia Film Grain Synthesis 1 (AFGS1) spec: + https://aomediacodec.github.io/afgs1-spec/ + +The parsing has been changed substantially relative to the AV1 film +grain OBU. In particular: + +1. There is the possibility of maintaining multiple independent film + grain parameter sets, and decoders/players are recommended to pick + the one most appropriate for the intended display resolution. This + could also be used to e.g. switch between different grain profiles + without having to re-signal the appropriate coefficients. + +2. Supporting this, it's possible to *predict* the grain coefficients + from previously signalled parameter sets, transmitting only the + residual. + +3. When not predicting, the parameter sets are now stored as a series of + increments, rather than being directly transmitted. + +4. There are several new AFGS1-exclusive fields. + +I placed this parser in its own file, rather than h2645_sei.c, since +nothing in the generic AFGS1 film grain payload is specific to T.35, and +to compartmentalize the code base. + +diff --git a/libavcodec/aom_film_grain.c b/libavcodec/aom_film_grain.c +index ffcd71b584..e302567ba5 100644 +--- a/libavcodec/aom_film_grain.c ++++ b/libavcodec/aom_film_grain.c +@@ -29,6 +29,7 @@ + #include "libavutil/imgutils.h" + + #include "aom_film_grain.h" ++#include "get_bits.h" + + // Common/shared helpers (not dependent on BIT_DEPTH) + static inline int get_random_number(const int bits, unsigned *const state) { +@@ -118,6 +119,243 @@ int ff_aom_apply_film_grain(AVFrame *out, const AVFrame *in, + return AVERROR_INVALIDDATA; + } + ++int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s, ++ const uint8_t *payload, int payload_size) ++{ ++ GetBitContext gbc, *gb = &gbc; ++ AVFilmGrainAOMParams *aom; ++ AVFilmGrainParams *fgp, *ref = NULL; ++ int ret, num_sets, n, i, uv, num_y_coeffs, update_grain, luma_only; ++ ++ ret = init_get_bits8(gb, payload, payload_size); ++ if (ret < 0) ++ return ret; ++ ++ s->enable = get_bits1(gb); ++ if (!s->enable) ++ return 0; ++ ++ skip_bits(gb, 4); // reserved ++ num_sets = get_bits(gb, 3) + 1; ++ for (n = 0; n < num_sets; n++) { ++ int payload_4byte, payload_size, set_idx, apply_units_log2, vsc_flag; ++ int predict_scaling, predict_y_scaling, predict_uv_scaling[2]; ++ int payload_bits, start_position; ++ ++ start_position = get_bits_count(gb); ++ payload_4byte = get_bits1(gb); ++ payload_size = get_bits(gb, payload_4byte ? 2 : 8); ++ set_idx = get_bits(gb, 3); ++ fgp = &s->sets[set_idx]; ++ aom = &fgp->codec.aom; ++ ++ fgp->type = get_bits1(gb) ? AV_FILM_GRAIN_PARAMS_AV1 : AV_FILM_GRAIN_PARAMS_NONE; ++ if (!fgp->type) ++ continue; ++ ++ fgp->seed = get_bits(gb, 16); ++ update_grain = get_bits1(gb); ++ if (!update_grain) ++ continue; ++ ++ apply_units_log2 = get_bits(gb, 4); ++ fgp->width = get_bits(gb, 12) << apply_units_log2; ++ fgp->height = get_bits(gb, 12) << apply_units_log2; ++ luma_only = get_bits1(gb); ++ if (luma_only) { ++ fgp->subsampling_x = fgp->subsampling_y = 0; ++ } else { ++ fgp->subsampling_x = get_bits1(gb); ++ fgp->subsampling_y = get_bits1(gb); ++ } ++ ++ fgp->bit_depth_luma = fgp->bit_depth_chroma = 0; ++ fgp->color_primaries = AVCOL_PRI_UNSPECIFIED; ++ fgp->color_trc = AVCOL_TRC_UNSPECIFIED; ++ fgp->color_space = AVCOL_SPC_UNSPECIFIED; ++ fgp->color_range = AVCOL_RANGE_UNSPECIFIED; ++ ++ vsc_flag = get_bits1(gb); // video_signal_characteristics_flag ++ if (vsc_flag) { ++ int cicp_flag; ++ fgp->bit_depth_luma = get_bits(gb, 3) + 8; ++ if (!luma_only) ++ fgp->bit_depth_chroma = fgp->bit_depth_luma; ++ cicp_flag = get_bits1(gb); ++ if (cicp_flag) { ++ fgp->color_primaries = get_bits(gb, 8); ++ fgp->color_trc = get_bits(gb, 8); ++ fgp->color_space = get_bits(gb, 8); ++ fgp->color_range = get_bits1(gb) ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; ++ if (fgp->color_primaries > AVCOL_PRI_NB || ++ fgp->color_primaries == AVCOL_PRI_RESERVED || ++ fgp->color_primaries == AVCOL_PRI_RESERVED0 || ++ fgp->color_trc > AVCOL_TRC_NB || ++ fgp->color_trc == AVCOL_TRC_RESERVED || ++ fgp->color_trc == AVCOL_TRC_RESERVED0 || ++ fgp->color_space > AVCOL_SPC_NB || ++ fgp->color_space == AVCOL_SPC_RESERVED) ++ goto error; ++ } ++ } ++ ++ predict_scaling = get_bits1(gb); ++ if (predict_scaling && (!ref || ref == fgp)) ++ goto error; // prediction must be from valid, different set ++ ++ predict_y_scaling = predict_scaling ? get_bits1(gb) : 0; ++ if (predict_y_scaling) { ++ int y_scale, y_offset, bits_res; ++ y_scale = get_bits(gb, 9) - 256; ++ y_offset = get_bits(gb, 9) - 256; ++ bits_res = get_bits(gb, 3); ++ if (bits_res) { ++ int res[14], pred, granularity; ++ aom->num_y_points = ref->codec.aom.num_y_points; ++ for (i = 0; i < aom->num_y_points; i++) ++ res[i] = get_bits(gb, bits_res); ++ granularity = get_bits(gb, 3); ++ for (i = 0; i < aom->num_y_points; i++) { ++ pred = ref->codec.aom.y_points[i][1]; ++ pred = ((pred * y_scale + 8) >> 4) + y_offset; ++ pred += (res[i] - (1 << (bits_res - 1))) * granularity; ++ aom->y_points[i][0] = ref->codec.aom.y_points[i][0]; ++ aom->y_points[i][1] = av_clip_uint8(pred); ++ } ++ } ++ } else { ++ aom->num_y_points = get_bits(gb, 4); ++ if (aom->num_y_points > 14) { ++ goto error; ++ } else if (aom->num_y_points) { ++ int bits_inc, bits_scaling; ++ int y_value = 0; ++ bits_inc = get_bits(gb, 3) + 1; ++ bits_scaling = get_bits(gb, 2) + 5; ++ for (i = 0; i < aom->num_y_points; i++) { ++ y_value += get_bits(gb, bits_inc); ++ if (y_value > UINT8_MAX) ++ goto error; ++ aom->y_points[i][0] = y_value; ++ aom->y_points[i][1] = get_bits(gb, bits_scaling); ++ } ++ } ++ } ++ ++ if (luma_only) { ++ aom->chroma_scaling_from_luma = 0; ++ aom->num_uv_points[0] = aom->num_uv_points[1] = 0; ++ } else { ++ aom->chroma_scaling_from_luma = get_bits1(gb); ++ if (aom->chroma_scaling_from_luma) { ++ aom->num_uv_points[0] = aom->num_uv_points[1] = 0; ++ } else { ++ for (uv = 0; uv < 2; uv++) { ++ predict_uv_scaling[uv] = predict_scaling ? get_bits1(gb) : 0; ++ if (predict_uv_scaling[uv]) { ++ int uv_scale, uv_offset, bits_res; ++ uv_scale = get_bits(gb, 9) - 256; ++ uv_offset = get_bits(gb, 9) - 256; ++ bits_res = get_bits(gb, 3); ++ aom->uv_mult[uv] = ref->codec.aom.uv_mult[uv]; ++ aom->uv_mult_luma[uv] = ref->codec.aom.uv_mult_luma[uv]; ++ aom->uv_offset[uv] = ref->codec.aom.uv_offset[uv]; ++ if (bits_res) { ++ int res[10], pred, granularity; ++ aom->num_uv_points[uv] = ref->codec.aom.num_uv_points[uv]; ++ for (i = 0; i < aom->num_uv_points[uv]; i++) ++ res[i] = get_bits(gb, bits_res); ++ granularity = get_bits(gb, 3); ++ for (i = 0; i < aom->num_uv_points[uv]; i++) { ++ pred = ref->codec.aom.uv_points[uv][i][1]; ++ pred = ((pred * uv_scale + 8) >> 4) + uv_offset; ++ pred += (res[i] - (1 << (bits_res - 1))) * granularity; ++ aom->uv_points[uv][i][0] = ref->codec.aom.uv_points[uv][i][0]; ++ aom->uv_points[uv][i][1] = av_clip_uint8(pred); ++ } ++ } ++ } else { ++ int bits_inc, bits_scaling, uv_offset; ++ int uv_value = 0; ++ aom->num_uv_points[uv] = get_bits(gb, 4); ++ if (aom->num_uv_points[uv] > 10) ++ goto error; ++ bits_inc = get_bits(gb, 3) + 1; ++ bits_scaling = get_bits(gb, 2) + 5; ++ uv_offset = get_bits(gb, 8); ++ for (i = 0; i < aom->num_uv_points[uv]; i++) { ++ uv_value += get_bits(gb, bits_inc); ++ if (uv_value > UINT8_MAX) ++ goto error; ++ aom->uv_points[uv][i][0] = uv_value; ++ aom->uv_points[uv][i][1] = get_bits(gb, bits_scaling) + uv_offset; ++ } ++ } ++ } ++ } ++ } ++ ++ aom->scaling_shift = get_bits(gb, 2) + 8; ++ aom->ar_coeff_lag = get_bits(gb, 2); ++ num_y_coeffs = 2 * aom->ar_coeff_lag * (aom->ar_coeff_lag + 1); ++ if (aom->num_y_points) { ++ int ar_bits = get_bits(gb, 2) + 5; ++ for (i = 0; i < num_y_coeffs; i++) ++ aom->ar_coeffs_y[i] = get_bits(gb, ar_bits) - (1 << (ar_bits - 1)); ++ } ++ for (uv = 0; uv < 2; uv++) { ++ if (aom->chroma_scaling_from_luma || aom->num_uv_points[uv]) { ++ int ar_bits = get_bits(gb, 2) + 5; ++ for (i = 0; i < num_y_coeffs + !!aom->num_y_points; i++) ++ aom->ar_coeffs_uv[uv][i] = get_bits(gb, ar_bits) - (1 << (ar_bits - 1)); ++ } ++ } ++ aom->ar_coeff_shift = get_bits(gb, 2) + 6; ++ aom->grain_scale_shift = get_bits(gb, 2); ++ for (uv = 0; uv < 2; uv++) { ++ if (aom->num_uv_points[uv] && !predict_uv_scaling[uv]) { ++ aom->uv_mult[uv] = get_bits(gb, 8) - 128; ++ aom->uv_mult_luma[uv] = get_bits(gb, 8) - 128; ++ aom->uv_offset[uv] = get_bits(gb, 9) - 256; ++ } ++ } ++ aom->overlap_flag = get_bits1(gb); ++ aom->limit_output_range = get_bits1(gb); ++ ++ // use first set as reference only if it was fully transmitted ++ if (n == 0) ++ ref = fgp; ++ ++ payload_bits = get_bits_count(gb) - start_position; ++ if (payload_bits > payload_size * 8) ++ goto error; ++ skip_bits(gb, payload_size * 8 - payload_bits); ++ } ++ return 0; ++ ++error: ++ memset(s, 0, sizeof(*s)); ++ return AVERROR_INVALIDDATA; ++} ++ ++int ff_aom_attach_film_grain_sets(const AVFilmGrainAFGS1Params *s, AVFrame *frame) ++{ ++ AVFilmGrainParams *fgp; ++ if (!s->enable) ++ return 0; ++ ++ for (int i = 0; i < FF_ARRAY_ELEMS(s->sets); i++) { ++ if (s->sets[i].type != AV_FILM_GRAIN_PARAMS_AV1) ++ continue; ++ fgp = av_film_grain_params_create_side_data(frame); ++ if (!fgp) ++ return AVERROR(ENOMEM); ++ memcpy(fgp, &s->sets[i], sizeof(*fgp)); ++ } ++ ++ return 0; ++} ++ + // Taken from the AV1 spec. Range is [-2048, 2047], mean is 0 and stddev is 512 + static const int16_t gaussian_sequence[2048] = { + 56, 568, -180, 172, 124, -84, 172, -64, -900, 24, 820, +diff --git a/libavcodec/aom_film_grain.h b/libavcodec/aom_film_grain.h +index 5d772bd7d1..1f8c78f657 100644 +--- a/libavcodec/aom_film_grain.h ++++ b/libavcodec/aom_film_grain.h +@@ -30,9 +30,22 @@ + + #include "libavutil/film_grain_params.h" + ++typedef struct AVFilmGrainAFGS1Params { ++ int enable; ++ AVFilmGrainParams sets[8]; ++} AVFilmGrainAFGS1Params; ++ + // Synthesizes film grain on top of `in` and stores the result to `out`. `out` + // must already have been allocated and set to the same size and format as `in`. + int ff_aom_apply_film_grain(AVFrame *out, const AVFrame *in, + const AVFilmGrainParams *params); + ++// Parse AFGS1 parameter sets from an ITU-T T.35 payload. Returns 0 on success, ++// or a negative error code. ++int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s, ++ const uint8_t *payload, int payload_size); ++ ++// Attach all valid film grain param sets to `frame`. ++int ff_aom_attach_film_grain_sets(const AVFilmGrainAFGS1Params *s, AVFrame *frame); ++ + #endif /* AVCODEC_AOM_FILM_GRAIN_H */ +-- +2.41.0 + diff --git a/ffmpeg-6-CVE-2024-32228.patch b/ffmpeg-6-CVE-2024-32228.patch new file mode 100644 index 0000000..e293a2a --- /dev/null +++ b/ffmpeg-6-CVE-2024-32228.patch @@ -0,0 +1,58 @@ +From 459648761f5412acdc3317d5bac982ceaa257584 Mon Sep 17 00:00:00 2001 +Author: Niklas Haas +Date: Sat Apr 6 13:11:09 2024 +0200 +Subject: avcodec/hevcdec: fix segfault on invalid film grain metadata +References: CVE-2024-32228 +References: bsc#1227277 +Upstream: Backport from upstream + +Invalid input files may contain film grain metadata which survives +ff_h274_film_grain_params_supported() but does not pass +av_film_grain_params_select(), leading to a SIGSEGV on hevc_frame_end(). + +Fix this by duplicating the av_film_grain_params_select() check at frame +init time. + +An alternative solution here would be to defer the incompatibility check +to hevc_frame_end(), but this has the downside of allocating a film +grain buffer even when we already know we can't apply film grain. + +Fixes: https://trac.ffmpeg.org/ticket/10951 + +diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c +index 727b02f0f4..d3b668af00 100644 +--- a/libavcodec/hevcdec.c ++++ b/libavcodec/hevcdec.c +@@ -2893,10 +2893,15 @@ static int hevc_frame_start(HEVCContext *s) + !(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && + !s->avctx->hwaccel; + ++ ret = set_side_data(s); ++ if (ret < 0) ++ goto fail; ++ + if (s->ref->needs_fg && +- s->sei.common.film_grain_characteristics.present && +- !ff_h274_film_grain_params_supported(s->sei.common.film_grain_characteristics.model_id, +- s->ref->frame->format)) { ++ ( s->sei.common.film_grain_characteristics.present && ++ !ff_h274_film_grain_params_supported(s->sei.common.film_grain_characteristics.model_id, ++ s->ref->frame->format)) ++ || !av_film_grain_params_select(s->ref->frame)) { + av_log_once(s->avctx, AV_LOG_WARNING, AV_LOG_DEBUG, &s->film_grain_warning_shown, + "Unsupported film grain parameters. Ignoring film grain.\n"); + s->ref->needs_fg = 0; +@@ -2910,10 +2915,6 @@ static int hevc_frame_start(HEVCContext *s) + goto fail; + } + +- ret = set_side_data(s); +- if (ret < 0) +- goto fail; +- + s->frame->pict_type = 3 - s->sh.slice_type; + + if (!IS_IRAP(s)) +-- +2.41.0 + diff --git a/ffmpeg-6-CVE-2024-32230.patch b/ffmpeg-6-CVE-2024-32230.patch new file mode 100644 index 0000000..58712b4 --- /dev/null +++ b/ffmpeg-6-CVE-2024-32230.patch @@ -0,0 +1,25 @@ +From 96449cfeaeb95fcfd7a2b8d9ccf7719e97471ed1 +Author: Michael Niedermayer +Date: Mon Apr 8 18:38:42 2024 +0200 +Subject: avcodec/mpegvideo_enc: Fix 1 line and one column images +References: CVE-2024-32230 +References: bsc#1227296 +Upstream: Backport from upstream + +Fixes: Ticket10952 +Fixes: poc21ffmpeg +Signed-off-by: Michael Niedermayer + +--- ffmpeg-6.1.1/libavcodec/mpegvideo_enc.c 2023-12-31 08:07:26.000000000 +0800 ++++ ffmpeg-6.1.1_new/libavcodec/mpegvideo_enc.c 2024-07-05 18:08:49.827035281 +0800 +@@ -1198,8 +1198,8 @@ + int dst_stride = i ? s->uvlinesize : s->linesize; + int h_shift = i ? s->chroma_x_shift : 0; + int v_shift = i ? s->chroma_y_shift : 0; +- int w = s->width >> h_shift; +- int h = s->height >> v_shift; ++ int w = AV_CEIL_RSHIFT(s->width , h_shift); ++ int h = AV_CEIL_RSHIFT(s->height, v_shift); + const uint8_t *src = pic_arg->data[i]; + uint8_t *dst = pic->f->data[i]; + int vpad = 16; diff --git a/ffmpeg-6-rpmlintrc b/ffmpeg-6-rpmlintrc new file mode 100644 index 0000000..4e8a166 --- /dev/null +++ b/ffmpeg-6-rpmlintrc @@ -0,0 +1 @@ +addFilter("shlib-fixed-dependency") diff --git a/ffmpeg-6.1.1.tar.xz b/ffmpeg-6.1.1.tar.xz new file mode 100644 index 0000000..ef6608f --- /dev/null +++ b/ffmpeg-6.1.1.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8684f4b00f94b85461884c3719382f1261f0d9eb3d59640a1f4ac0873616f968 +size 10458600 diff --git a/ffmpeg-6.1.1.tar.xz.asc b/ffmpeg-6.1.1.tar.xz.asc new file mode 100644 index 0000000..d44fa30 --- /dev/null +++ b/ffmpeg-6.1.1.tar.xz.asc @@ -0,0 +1,11 @@ +-----BEGIN PGP SIGNATURE----- + +iQFMBAABCAA2FiEE/PmG6hXm4pOlZE8QtDIvBNZ2WNgFAmWQvW4YHGZmbXBlZy1k +ZXZlbEBmZm1wZWcub3JnAAoJELQyLwTWdljYWJgH+wVyt5Var56jG1YL+2cr9XCQ +E1pfyKEX4j23y4MtRhk/Oks1apqHZ3MtP+u/K+Z2nwqdUh8kMdczWBRqcSl/qxdr +Ak2uFVwIIg4eF03XplWjIbOdMJACaWTz2vOyX9GjwTe6rckcGHBZXd41IzYnJHLh +3pvxMp4TBxmiAjfrvzzMBFqgmD+WlmrYDqTsw1B1eq2OSNNjQzfd7VEy0+B/eQ13 +T0kIC2vh/N1OcJloYW5I1Cb8zUmLRFztoVL5JXR41jFYgPxjpjG1hjS/bEB47qXb +7Kte43eesFaGWKBFYp8lU5IoIxuB9utXjPunZV8WVgVpslhptPLwe4EgBKeU1to= +=BdLd +-----END PGP SIGNATURE----- diff --git a/ffmpeg-6.changes b/ffmpeg-6.changes new file mode 100644 index 0000000..e0712f6 --- /dev/null +++ b/ffmpeg-6.changes @@ -0,0 +1,200 @@ +------------------------------------------------------------------- +Tue Jul 2 12:26:28 UTC 2024 - Cliff Zhao + +- Add ffmpeg-6-CVE-2024-32230.patch: + Backporting 96449cfe from upstream, Fix 1 line and one column images. + (CVE-2024-32230 bsc#1227296) + +------------------------------------------------------------------- +Tue Jul 2 11:57:01 UTC 2024 - Cliff Zhao + +- Add ffmpeg-6-CVE-2024-32228.patch: + Backporting 45964876 from upstream, Fix segfault on invalid film + grain metadata. + (CVE-2024-32228, bsc#1227277) + +-------------------------------------------------------------------* +Tue Jul 2 11:56:01 UTC 2024 - Cliff Zhao + +- Add ffmpeg-6-CVE-2024-32228-shim-5d7f234e.patch: + Backporting 5d7f234e from upstream, document that there can be multiple + complex filtergraphs to prepare dependence code for CVE-2024-32228. + (CVE-2024-32228, bsc#1227277) + +-------------------------------------------------------------------* +Tue Jul 2 11:55:01 UTC 2024 - Cliff Zhao + +- Add ffmpeg-6-CVE-2024-32228-shim-f50382cb.patch: + Backporting f50382cb from upstream, implement AFGS1 parsing. + to prepare dependence code for CVE-2024-32228. + (CVE-2024-32228, bsc#1227277) + +-------------------------------------------------------------------* +Tue Jul 2 11:54:01 UTC 2024 - Cliff Zhao + +- Add ffmpeg-6-CVE-2024-32228-shim-1535d338.patch: + Backporting 1535d338 from upstream, add AOM film grain synthesis, + to prepare dependence code for CVE-2024-32228. + (CVE-2024-32228, bsc#1227277) + +------------------------------------------------------------------- +Tue Jul 2 11:28:10 UTC 2024 - Cliff Zhao + +- Rename CVE patches as SUSE CVE standard:(package name)-%(CVE number) + ffmpeg-CVE-2023-50007.patch + ffmpeg-CVE-2023-50008.patch + +------------------------------------------------------------------- +Thu Apr 23 14:05:28 UTC 2024 - Cliff Zhao + +- Add ffmpeg-CVE-2023-50008.patch: + Backporting 5f87a68c from upstream, Fix memory leaks. + (CVE-2023-50008 bsc#1223254) + +------------------------------------------------------------------- +Thu Apr 23 12:22:53 UTC 2024 - Cliff Zhao + +- Add ffmpeg-CVE-2023-50007.patch: + Backporting b1942734 from upstream, Fix crash with EOF handling. + (CVE-2023-50007 bsc#1223253) + +------------------------------------------------------------------- +Mon Apr 22 12:41:55 UTC 2024 - Jan Engelhardt + +- Address boo#1223215/CVE-2023-49501: add patch + 0001-avfilter-asrc_afirsrc-fix-by-one-smaller-allocation-.patch +- Address boo#1223235/CVE-2023-49502: add patch + 0001-avfilter-bwdif-account-for-chroma-sub-sampling-in-mi.patch +- Address boo#1222730/CVE-2023-49528: add patches + 0001-avfilter-af_dialoguenhance-fix-overreads.patch, + 0001-avfilter-af_dialoguenhance-simplify-channels-copy.patch, + 0001-avfilter-af_dialoguenhance-do-output-scaling-once.patch +- Address boo#1223070/CVE-2024-31578: add patch + 0001-avutil-hwcontext-Don-t-assume-frames_uninit-is-reent.patch +- Address boo#1223085/CVE-2024-31582: add patch + 0001-avfilter-vf_codecview-fix-heap-buffer-overflow.patch + +------------------------------------------------------------------- +Fri Mar 22 09:25:28 UTC 2024 - Jan Engelhardt + +- Add 0001-avcodec-tests-rename-the-bundled-Mesa-AV1-vulkan-vid.patch + +------------------------------------------------------------------- +Thu Mar 14 18:58:31 UTC 2024 - Jan Engelhardt + +- Let the ffmpeg-6 main program be combinable with ffmpeg-6-mini-libs + +------------------------------------------------------------------- +Mon Jan 15 11:11:08 UTC 2024 - Enrico Belleri + +- Update to version 6.1.1: + * libaribcaption decoder + * Playdate video decoder and demuxer + * Extend VAAPI support for libva-win32 on Windows + * afireqsrc audio source filter + * arls filter + * ffmpeg CLI new option: -readrate_initial_burst + * zoneplate video source filter + * command support in the setpts and asetpts filters + * Vulkan decode hwaccel, supporting H264, HEVC and AV1 + * color_vulkan filter + * bwdif_vulkan filter + * nlmeans_vulkan filter + * RivaTuner video decoder + * xfade_vulkan filter + * vMix video decoder + * Essential Video Coding parser, muxer and demuxer + * Essential Video Coding frame merge bsf + * bwdif_cuda filter + * Microsoft RLE video encoder + * Raw AC-4 muxer and demuxer + * Raw VVC bitstream parser, muxer and demuxer + * Bitstream filter for editing metadata in VVC streams + * Bitstream filter for converting VVC from MP4 to Annex B + * scale_vt filter for videotoolbox + * transpose_vt filter for videotoolbox + * support for the P_SKIP hinting to speed up libx264 encoding + * Support HEVC,VP9,AV1 codec in enhanced flv format + * apsnr and asisdr audio filters + * OSQ demuxer and decoder + * Support HEVC,VP9,AV1 codec fourcclist in enhanced rtmp protocol + * CRI USM demuxer + * ffmpeg CLI '-top' option deprecated in favor of the setfield filter + * VAAPI AV1 encoder + * ffprobe XML output schema changed to account for multiple variable-fields elements within the same parent element + * ffprobe -output_format option added as an alias of -of +- Remove patch6 0001-avfilter-vf_libplacebo-remove-deprecated-field.diff +- Prefer libvpl to libmfx: the latter is deprecated +- Delete ffmpeg-6-private-devel package as it is only needed to build libav-tools + +------------------------------------------------------------------- +Wed Nov 22 15:23:54 UTC 2023 - Bjørn Lie + +- Enable more decoders and encoders explicitly: + * amrwb via bcond_without for TW only (and in + enable_decoder/encoder) + * opencore via bcond_without for TW only (and in + enable_decoder/encoder) + * xvid via bcond_without for TW only (and in + enable_decoder/encoder) + * h.263 via enable_decoder/encoder and no longer explicitly + disabling in call to configure + * MPEG4 Visual via enable_decoder/encoder and no longer + explicitly disabling in call to configure + * MPEG2 Hardware decoders via enable_decoder/encoder + * And many many more via enable_decoder/encoder. + +------------------------------------------------------------------- +Fri Nov 10 10:09:46 UTC 2023 - Bjørn Lie + +- Update to version 6.0.1: + * Updates and bugfixes to avcodecs, avformat and avfilters + mainly. +- Drop patch fixed upstream: + * 0001-avcodec-x86-mathops-clip-constants-used-with-shift-i.patch + +------------------------------------------------------------------- +Wed Oct 4 07:59:01 UTC 2023 - Manfred Hollstein + +- Add 0001-avcodec-x86-mathops-clip-constants-used-with-shift-i.patch + to resolve a build failure on 15.4/15.5. + +------------------------------------------------------------------- +Mon Jul 31 09:05:39 UTC 2023 - llyyr + +- Bump required libplacebo version to v6.292.0 or newer for TW +- Temporarily demote deprecation errors to deprecation warnings + for vf_libplacebo +- Add upstream patches to fix build with libplacebo v6: + * 0001-avfilter-vf_libplacebo-remove-deprecated-field.diff + +------------------------------------------------------------------- +Mon Apr 10 09:08:08 UTC 2023 - Jan Engelhardt + +- Reset fixed leftover value for BUILD_ORIG + +------------------------------------------------------------------- +Thu Mar 16 17:56:04 UTC 2023 - Jan Engelhardt + +- Conflict with otherproviders(ffmpeg-tools). + +------------------------------------------------------------------- +Thu Mar 9 09:02:01 UTC 2023 - Enrico Belleri + +- enable libplacebo filter +- clean old BuildRequires conditions +- add libjxl to enable_encoders + +------------------------------------------------------------------- +Tue Feb 28 13:23:08 UTC 2023 - Jan Engelhardt + +- Branch from ffmpeg-5.spec +- Remove ffmpeg-4.4-CVE-2020-22046.patch (inapplicable), + no-vk-video-decoding.patch (obsolete), + ffmpeg-CVE-2022-3964.patch (appears merged) +- Update to release 6.0 + * FFmpeg now runs every muxer in a separate thread and requires + threading to be enabled for compilation + * VA-API encoding and decoding support for 10/12-bit 422, + 10/12-bit 444 VP9 support + * RISC-V optimizations diff --git a/ffmpeg-6.keyring b/ffmpeg-6.keyring new file mode 100644 index 0000000..35375c8 --- /dev/null +++ b/ffmpeg-6.keyring @@ -0,0 +1,30 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQENBE22rV0BCAC3DzRmA2XlhrqYv9HKoEvNHHf+PzosmCTHmYhWHDqvBxPkSvCl +ipkbvJ4pBnVvcX6mW5QyKhspHm5j1X5ibe9Bt9/chS/obnIobmvF8shSUgjQ0qRW +9c1aWOjvT26SxYQ1y9TmYCFwixeydGFHYKjAim+evGUccni5KMlfPoT3VTPtim78 +ufkr3E9Nco/Mobn/8APO0NmLEGWAM6ln/8J/c9h6a1QKnQyBqWfT0YnAaebafFaZ +YwOtRdDG54VbJ4xwcHbCj5cKhTABk/QtBzDvnW4bG+uSpqdHbFZEY2JpURDuj/T3 +NudKQGzn0bYNpY1XY2l0pqs/btKHnBW0fVMjABEBAAG0NEZGbXBlZyByZWxlYXNl +IHNpZ25pbmcga2V5IDxmZm1wZWctZGV2ZWxAZmZtcGVnLm9yZz6JATgEEwECACIF +Ak22rV0CGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJELQyLwTWdljYKxUH +/1fqzl7SKie2g4t4PJbqUbkLuMsC+CP6gp0dcVZOHkuUYAoD3PM3iVxpLBVyKIXI +g7wMSTAtlIcYnzhWIpnoCBes6/O2Mrq6xHgGeTp6CDcm3LmmSYR1f5KdD8KUaA+l +c/M/1fEnwrSs/UGDk6R6iUmbqwxPsbozlOvmUHOLbDZBnKrk9XfAJdUhAuFACrSA +T+KF1jniz0OfNGd23SaHWRCphoRW9pXDc5FfkdaueBUvBvGv19ZNcDhcxT3/u6z2 +DaUFC0rLWqk8obo951jVvi/zOhB94Pw6u1SLvcTq3V1q5URWJtgSbpih9VRqxUbQ +NbXduKGzbHz6Vwpkupz4JRe5AQ0ETbatXQEIANjYrygJi/fn1nlSg5Mz0l9KHDm4 +yfWtaOrXUjJcyiGe4G0XXJLGh45qxJ0DOKzi9id+9W4jby+kKuzG9O6Vn0iDeODO +aOGnz4ua7Vu6d0AbYfNXZPWge/GCodo/ZD/qri1tPkLmRtT/sniahwy6LruPNHfF +SRoNIjwbcD/IL+EbY1pL1/IFSzEAA1ZZamgmHgB7o9pwDIkK6HuvHMR/Y5MsoMfV +fWV3ZGtA6v9z51CvnHsHPsADRSnUp7aYtR412SiAO4XodMLTA92L3LxgYhI4ma7D +XZ8jgKg4JkKO+DXmoU63HtRdq/HZjeXJKk1JGJF3zCvP3DyIzZ8LWIjN8t0AEQEA +AYkBHwQYAQIACQUCTbatXQIbDAAKCRC0Mi8E1nZY2LS8B/0bMoUAl4X9D0WQbL4l +U0czCIOKOsvbHpIxivjCnOQxU23+PV5WZdoCCpSuAHGv+2OHzhNrij++P9BNTJeQ +skxdS9FH4MZwy1IRSPrxegSxbCUpBI1rd0Zf7qb9BNPrHPTueWFV1uExOSB2Apsv +WrKo2D8mR0uZAPYfYl2ToFVoa5PR7/+ii9WiJr/flF6qm7hoLpI5Bm4VcZh2GPsJ +9Vo/8x/qOGwtdWHqBykYloKsrwD4U69rjn+d9feLoPBRgoVroXWQttt0sUnyoudz ++x8ETJgPoNK3kQoDagApj4qAt83Ayac3HzNIuEJ7LdvfINIOprujnJ9vH4n04XLg +I4EZ +=Rjbw +-----END PGP PUBLIC KEY BLOCK----- diff --git a/ffmpeg-6.spec b/ffmpeg-6.spec new file mode 100644 index 0000000..924c75e --- /dev/null +++ b/ffmpeg-6.spec @@ -0,0 +1,953 @@ +# +# spec file for package ffmpeg-6 +# +# Copyright (c) 2024 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%define flavor @BUILD_FLAVOR@%nil +# +# preamble is present twice, watch out +# +%if "%flavor" != "ffmpeg-6-mini" + +# Create proper conflicts to make sure we require all from one version +# p: Conflict string, eg if you need them all for requires instead +# Default value Conflicts: +# c: copmare string ie "<" or ">=", must be defined +# v: version string ie. "< 42.3.4" or ">= 15.0.2.1", must be defined +%define devel_conflicts(p:c:v:) \ +%define preamble_string %{-p:%{-p*}}%{!-p:Conflicts:} \ +%define comparator %{-c:%{-c*}}%{!-c:%{error:Comparator not defined}} \ +%define conflicts_version %{-v:%{-v*}}%{!-v:%{error:Version not defined}} \ +\ +%preamble_string libavcodec-devel %comparator %conflicts_version \ +%preamble_string libavdevice-devel %comparator %conflicts_version \ +%preamble_string libavfilter-devel %comparator %conflicts_version \ +%preamble_string libavformat-devel %comparator %conflicts_version \ +%preamble_string libavutil-devel %comparator %conflicts_version \ +%preamble_string libpostproc-devel %comparator %conflicts_version \ +%preamble_string libswresample-devel %comparator %conflicts_version \ +%preamble_string libswscale-devel %comparator %conflicts_version \ +%nil + +%if 0%{?BUILD_ORIG} +%bcond_without amf_sdk +%bcond_without cuda_sdk +%else +# If software H264 is disabled, the hw driver must be as well: +# HW drivers can fail to initialize, namely when the hardware is absent. +# Browsers choose video formats on sites like youtube based on `ffmpeg +# -codecs` rather than the success/failure status of libav* initialization. +# This becomes a problem when a format only has a HW driver; +# the browser thinks it can do H264 but never succeeds. +%bcond_with amf_sdk +%bcond_with cuda_sdk +%endif + +%bcond_with amrwb +%bcond_with fdk_aac_dlopen +%bcond_with opencore +%bcond_with smbclient +%bcond_with x264 +%bcond_with x265 +%bcond_with xvid + +%if 0%{?suse_version} > 1500 +%bcond_without mysofa +%bcond_without vidstab +%bcond_without codec2 +%bcond_without rubberband +%bcond_without vulkan +%bcond_without amrwb +%bcond_without opencore +%bcond_without xvid +%else +%bcond_with mysofa +%bcond_with vidstab +%bcond_with codec2 +%bcond_with rubberband +%bcond_with vulkan +%endif + +%define _name ffmpeg +%define _major_version 6 +%define _major_expected 7 + +Name: ffmpeg-6 +Version: 6.1.1 +Release: 0 +Summary: Set of libraries for working with various multimedia formats +License: GPL-3.0-or-later +Group: Productivity/Multimedia/Video/Editors and Convertors +URL: https://ffmpeg.org/ + +#Freshcode-URL: http://freshcode.club/projects/ffmpeg +#Git-Clone: git://source.ffmpeg.org/ffmpeg +Source: https://www.ffmpeg.org/releases/%_name-%version.tar.xz +Source2: https://www.ffmpeg.org/releases/%_name-%version.tar.xz.asc +Source3: ffmpeg-6-rpmlintrc +Source4: enable_decoders +Source5: enable_encoders +Source6: ffmpeg-dlopen-headers.tar.xz +Source92: ffmpeg_get_dlopen_headers.sh +Source98: http://ffmpeg.org/ffmpeg-devel.asc#/ffmpeg-6.keyring +Source99: baselibs.conf + +Patch1: ffmpeg-arm6l.diff +Patch2: ffmpeg-new-coder-errors.diff +Patch3: ffmpeg-codec-choice.diff +Patch4: ffmpeg-4.2-dlopen-fdk_aac.patch +Patch5: work-around-abi-break.patch +Patch6: 0001-avcodec-tests-rename-the-bundled-Mesa-AV1-vulkan-vid.patch +Patch7: 0001-avfilter-asrc_afirsrc-fix-by-one-smaller-allocation-.patch +Patch8: 0001-avfilter-bwdif-account-for-chroma-sub-sampling-in-mi.patch +Patch9: 0001-avfilter-af_dialoguenhance-fix-overreads.patch +Patch10: 0001-avfilter-af_dialoguenhance-simplify-channels-copy.patch +Patch11: 0001-avfilter-af_dialoguenhance-do-output-scaling-once.patch +Patch12: 0001-avutil-hwcontext-Don-t-assume-frames_uninit-is-reent.patch +Patch13: 0001-avfilter-vf_codecview-fix-heap-buffer-overflow.patch +Patch90: ffmpeg-chromium.patch +Patch91: ffmpeg-dlopen-openh264.patch +Patch92: ffmpeg-6-CVE-2023-50007.patch +Patch93: ffmpeg-6-CVE-2023-50008.patch +Patch94: ffmpeg-6-CVE-2024-32228-shim-1535d338.patch +Patch95: ffmpeg-6-CVE-2024-32228-shim-f50382cb.patch +Patch96: ffmpeg-6-CVE-2024-32228-shim-5d7f234e.patch +Patch97: ffmpeg-6-CVE-2024-32228.patch +Patch98: ffmpeg-6-CVE-2024-32230.patch +BuildRequires: ladspa-devel +BuildRequires: libgsm-devel +BuildRequires: libmp3lame-devel >= 3.98.3 +BuildRequires: nasm +BuildRequires: pkgconfig +BuildRequires: pkgconfig(alsa) +BuildRequires: pkgconfig(aom) >= 1.0.0 +BuildRequires: pkgconfig(dav1d) >= 0.5.0 +BuildRequires: pkgconfig(ffnvcodec) >= 8.1.24.15 +BuildRequires: pkgconfig(fontconfig) >= 2.4.2 +BuildRequires: pkgconfig(freetype2) +BuildRequires: pkgconfig(fribidi) >= 0.19.0 +BuildRequires: pkgconfig(gnutls) +BuildRequires: pkgconfig(jack) +BuildRequires: pkgconfig(libass) >= 0.11.0 +BuildRequires: pkgconfig(libbluray) +BuildRequires: pkgconfig(libbs2b) +BuildRequires: pkgconfig(libcdio) +BuildRequires: pkgconfig(libcdio_paranoia) +BuildRequires: pkgconfig(libdc1394-2) +BuildRequires: pkgconfig(libdrm) +BuildRequires: pkgconfig(libgme) +BuildRequires: pkgconfig(libopenjp2) >= 2.1.0 +BuildRequires: pkgconfig(libopenmpt) >= 0.2.6557 +BuildRequires: pkgconfig(libpng) +BuildRequires: pkgconfig(libpulse) +BuildRequires: pkgconfig(libraw1394) +BuildRequires: pkgconfig(libssh) >= 0.6.0 +BuildRequires: pkgconfig(libva) >= 0.35.0 +BuildRequires: pkgconfig(libva-drm) +BuildRequires: pkgconfig(libva-x11) +BuildRequires: pkgconfig(libvmaf) >= 2.0.0 +BuildRequires: pkgconfig(libwebp) >= 0.4 +BuildRequires: pkgconfig(libwebpmux) >= 0.4.0 +BuildRequires: pkgconfig(libxml-2.0) +BuildRequires: pkgconfig(libzmq) >= 4.2.1 +BuildRequires: pkgconfig(lilv-0) +BuildRequires: pkgconfig(ogg) +BuildRequires: pkgconfig(opus) +BuildRequires: pkgconfig(sdl2) >= 2.0.1 +BuildRequires: pkgconfig(soxr) +BuildRequires: pkgconfig(speex) +BuildRequires: pkgconfig(srt) >= 1.3.0 +BuildRequires: pkgconfig(theora) >= 1.1 +BuildRequires: pkgconfig(twolame) >= 0.3.10 +BuildRequires: pkgconfig(vdpau) +BuildRequires: pkgconfig(vorbis) +BuildRequires: pkgconfig(vpx) >= 1.4.0 +BuildRequires: pkgconfig(x11) +BuildRequires: pkgconfig(xcb) +BuildRequires: pkgconfig(xcb-shape) +BuildRequires: pkgconfig(xcb-shm) +BuildRequires: pkgconfig(xcb-xfixes) +BuildRequires: pkgconfig(xext) +BuildRequires: pkgconfig(zimg) >= 2.7.0 +BuildRequires: pkgconfig(zlib) +BuildRequires: pkgconfig(zvbi-0.2) >= 0.2.28 + +%if %{with amf_sdk} +BuildRequires: AMF-devel +%endif +%if %{with mysofa} +BuildRequires: libmysofa-devel +%endif +%if %{with codec2} +BuildRequires: pkgconfig(codec2) +%endif +%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150700 +BuildRequires: pkgconfig(libjxl) >= 0.7.0 +BuildRequires: pkgconfig(libjxl_threads) >= 0.7.0 +BuildRequires: pkgconfig(librist) >= 0.2.7 +%endif +%if 0%{?suse_version} > 1500 || 0%{?sle_version} >= 150400 +BuildRequires: pkgconfig(rav1e) >= 0.5.0 +%endif +%if %{with rubberband} +BuildRequires: pkgconfig(rubberband) >= 1.8.1 +%endif +%if %{with smbclient} +BuildRequires: pkgconfig(smbclient) +%endif +%if %{with vidstab} +BuildRequires: pkgconfig(vidstab) >= 0.98 +%endif +%if %{with fdk_aac_dlopen} +BuildRequires: pkgconfig(fdk-aac) +%endif +%if %{with xvid} +BuildRequires: libxvidcore-devel +%endif +%if %{with opencore} +BuildRequires: pkgconfig(opencore-amrnb) +%endif +%if %{with amrwb} +BuildRequires: pkgconfig(vo-amrwbenc) +%endif +%if %{with x264} +BuildRequires: pkgconfig(x264) +%endif +%if %{with x265} +BuildRequires: pkgconfig(x265) +%endif + +%ifarch x86_64 %x86_64 aarch64 +%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150500 +BuildRequires: pkgconfig(SvtAv1Enc) >= 0.9.0 +%endif +%endif + +%if %{with vulkan} +%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150600 +BuildRequires: pkgconfig(libplacebo) >= 6.292.0 +%else +BuildRequires: (pkgconfig(libplacebo) >= 4.192.0 with pkgconfig (libplacebo) < 6.292.0) +%endif +BuildRequires: pkgconfig(shaderc) >= 2019.1 +BuildRequires: pkgconfig(vulkan) >= 1.3.255 +%endif + +%if 0%{?suse_version} < 1550 && 0%{?sle_version} >= 150200 && 0%{?sle_version} < 150600 +%ifarch x86_64 %x86_64 +BuildRequires: pkgconfig(libmfx) +%endif +%else +%ifarch x86_64 %x86_64 +BuildRequires: pkgconfig(vpl) >= 2.6 +%endif +%endif + +Provides: ffmpeg-tools = %version +Conflicts: ffmpeg-tools +Provides: ffmpeg = %version +Obsoletes: ffmpeg < %version +Requires: (libavcodec60 = %version-%release or ffmpeg-6-mini-libs = %version-%release) +Requires: (libavdevice60 = %version-%release or ffmpeg-6-mini-libs = %version-%release) +Requires: (libavfilter9 = %version-%release or ffmpeg-6-mini-libs = %version-%release) +Requires: (libavformat60 = %version-%release or ffmpeg-6-mini-libs = %version-%release) +Requires: (libavutil58 = %version-%release or ffmpeg-6-mini-libs = %version-%release) +Requires: (libpostproc57 = %version-%release or ffmpeg-6-mini-libs = %version-%release) +Requires: (libswresample4 = %version-%release or ffmpeg-6-mini-libs = %version-%release) +Requires: (libswscale7 = %version-%release or ffmpeg-6-mini-libs = %version-%release) + +%description +FFmpeg is a multimedia framework, able to decode, encode, +transcode, mux, demux, stream, filter and play several formats +that humans and machines have created. +%if !0%{?BUILD_ORIG} + +This build of ffmpeg is limited in the number of codecs supported. +%endif + +%package -n libavcodec60 +Summary: FFmpeg codec library +Group: System/Libraries +Requires: libavutil58 = %version-%release +Requires: libswresample4 = %version-%release +%if 0%{?BUILD_ORIG} +Provides: libavcodec-full = %version-%release +# This can be (and is) required by packages like vlc-codecs - +# do follow the shlib name to not get random lib providers +Provides: libavcodec60(unrestricted) +%endif +# For mozillas +Provides: libavcodec = %version-%release + +%description -n libavcodec60 +The libavcodec library provides a generic encoding/decoding framework +and contains multiple decoders and encoders for audio, video and +subtitle streams, and several bitstream filters. +%if !0%{?BUILD_ORIG} + +This build of ffmpeg is limited in the number of codecs supported. +%endif + +%package libavcodec-devel +Summary: Development files for FFmpeg's codec library +Group: Development/Libraries/C and C++ +Provides: libavcodec-devel = %version-%release +Obsoletes: libavcodec-devel < %version-%release +Requires: %name-libavutil-devel = %version-%release +Requires: libavcodec60 = %version-%release +%devel_conflicts -c < -v %_major_version +%devel_conflicts -c >= -v %_major_expected + +%description libavcodec-devel +The libavcodec library provides a generic encoding/decoding framework +and contains multiple decoders and encoders for audio, video and +subtitle streams, and several bitstream filters. + +This subpackage contains the headers for FFmpeg libavcodec. + +%package -n libavdevice60 +Summary: FFmpeg device library +Group: System/Libraries +Requires: libavcodec60 = %version-%release +Requires: libavfilter9 = %version-%release +Requires: libavformat60 = %version-%release +Requires: libavutil58 = %version-%release + +%description -n libavdevice60 +The libavdevice library provides a generic framework for grabbing from +and rendering to many common multimedia input/output devices, and +supports several input and output devices, including Video4Linux2, VfW, +DShow, and ALSA. + +%package libavdevice-devel +Summary: Development files for FFmpeg's device library +Group: Development/Libraries/C and C++ +Provides: ffmpeg-devel = %version-%release +Conflicts: ffmpeg-devel +Provides: libavdevice-devel = %version-%release +Obsoletes: libavdevice-devel < %version-%release +Requires: %name-libavcodec-devel = %version-%release +Requires: %name-libavfilter-devel = %version-%release +Requires: %name-libavformat-devel = %version-%release +Requires: %name-libavutil-devel = %version-%release +Requires: %name-libpostproc-devel = %version-%release +Requires: %name-libswresample-devel = %version-%release +Requires: %name-libswscale-devel = %version-%release +Requires: libavdevice60 = %version-%release +%devel_conflicts -c < -v %_major_version +%devel_conflicts -c >= -v %_major_expected + +%description libavdevice-devel +The libavdevice library provides a generic framework for grabbing from +and rendering to many common multimedia input/output devices, and +supports several input and output devices, including Video4Linux2, VfW, +DShow, and ALSA. + +This subpackage contains the headers for FFmpeg libavcodec. + +%package -n libavfilter9 +Summary: FFmpeg audio and video filtering library +Group: System/Libraries +Requires: libavcodec60 = %version-%release +Requires: libavformat60 = %version-%release +Requires: libavutil58 = %version-%release +Requires: libpostproc57 = %version-%release +Requires: libswresample4 = %version-%release +Requires: libswscale7 = %version-%release + +%description -n libavfilter9 +The libavfilter library provides a generic audio/video filtering +framework containing several filters, sources and sinks. + +%package libavfilter-devel +Summary: Development files for FFmpeg's audio/video filter library +Group: Development/Libraries/C and C++ +Provides: libavfilter-devel = %version-%release +Obsoletes: libavfilter-devel < %version-%release +Requires: %name-libavcodec-devel = %version-%release +Requires: %name-libavformat-devel = %version-%release +Requires: %name-libavutil-devel = %version-%release +Requires: %name-libpostproc-devel = %version-%release +Requires: %name-libswresample-devel = %version-%release +Requires: %name-libswscale-devel = %version-%release +Requires: libavfilter9 = %version-%release +%devel_conflicts -c < -v %_major_version +%devel_conflicts -c >= -v %_major_expected + +%description libavfilter-devel +The libavfilter library provides a generic audio/video filtering +framework containing several filters, sources and sinks. + +This subpackage contains the headers for FFmpeg libavfilter. + +%package -n libavformat60 +Summary: FFmpeg's stream format library +Group: System/Libraries +Requires: libavcodec60 = %version-%release +Requires: libavutil58 = %version-%release + +%description -n libavformat60 +The libavformat library provides a generic framework for multiplexing +and demultiplexing (muxing and demuxing) audio, video and subtitle +streams. It encompasses multiple muxers and demuxers for multimedia +container formats. +%if !0%{?BUILD_ORIG} + +This build of ffmpeg is limited in the number of codecs supported. +%endif + +%package libavformat-devel +Summary: Development files for FFmpeg's stream format library +Group: Development/Libraries/C and C++ +Provides: libavformat-devel = %version-%release +Obsoletes: libavformat-devel < %version-%release +Requires: %name-libavcodec-devel = %version-%release +Requires: %name-libavutil-devel = %version-%release +Requires: %name-libswresample-devel = %version-%release +Requires: libavformat60 = %version-%release +%devel_conflicts -c < -v %_major_version +%devel_conflicts -c >= -v %_major_expected + +%description libavformat-devel +The libavformat library provides a generic framework for multiplexing +and demultiplexing (muxing and demuxing) audio, video and subtitle +streams. It encompasses multiple muxers and demuxers for multimedia +container formats. + +This subpackage contains the headers for FFmpeg libavformat. + +%package -n libavutil58 +Summary: FFmpeg's utility library +Group: System/Libraries + +%description -n libavutil58 +The libavutil library is a utility library to aid portable multimedia +programming. It contains safe portable string functions, random +number generators, data structures, additional mathematics functions, +cryptography and multimedia related functionality (like enumerations +for pixel and sample formats). + +%package libavutil-devel +Summary: Development files for FFmpeg's utility library +Group: Development/Libraries/C and C++ +Provides: libavutil-devel = %version-%release +Obsoletes: libavutil-devel < %version-%release +Requires: libavutil58 = %version-%release +%devel_conflicts -c < -v %_major_version +%devel_conflicts -c >= -v %_major_expected + +%description libavutil-devel +The libavutil library is a utility library to aid portable multimedia +programming. It contains safe portable string functions, random +number generators, data structures, additional mathematics functions, +cryptography and multimedia related functionality (like enumerations +for pixel and sample formats). + +This subpackage contains the headers for FFmpeg libavutil. + +%package -n libpostproc57 +Summary: FFmpeg post-processing library +Group: System/Libraries +Requires: libavutil58 = %version-%release + +%description -n libpostproc57 +A library with video postprocessing filters, such as deblocking and +deringing filters, noise reduction, automatic contrast and brightness +correction, linear/cubic interpolating deinterlacing. + +%package libpostproc-devel +Summary: Development files for the FFmpeg post-processing library +Group: Development/Libraries/C and C++ +Provides: libpostproc-devel = %version-%release +Obsoletes: libpostproc-devel < %version-%release +Requires: %name-libavutil-devel = %version-%release +Requires: libpostproc57 = %version-%release +%devel_conflicts -c < -v %_major_version +%devel_conflicts -c >= -v %_major_expected + +%description libpostproc-devel +A library with video postprocessing filters, such as deblocking and +deringing filters, noise reduction, automatic contrast and brightness +correction, linear/cubic interpolating deinterlacing. + +This subpackage contains the headers for FFmpeg libpostproc. + +%package -n libswresample4 +Summary: FFmpeg software resampling library +Group: System/Libraries +Requires: libavutil58 = %version-%release + +%description -n libswresample4 +The libswresample library performs audio conversion between different +sample rates, channel layout and channel formats. + +%package libswresample-devel +Summary: Development files for the FFmpeg software resampling library +Group: Development/Libraries/C and C++ +Provides: libswresample-devel = %version-%release +Obsoletes: libswresample-devel < %version-%release +Requires: %name-libavutil-devel = %version-%release +Requires: libswresample4 = %version-%release +%devel_conflicts -c < -v %_major_version +%devel_conflicts -c >= -v %_major_expected + +%description libswresample-devel +The libswresample library performs audio conversion between different +sample rates, channel layout and channel formats. + +This subpackage contains the headers for FFmpeg libswresample. + +%package -n libswscale7 +Summary: FFmpeg image scaling and colorspace/pixel conversion library +Group: System/Libraries +Requires: libavutil58 = %version-%release + +%description -n libswscale7 +The libswscale library performs image scaling and colorspace and +pixel format conversion operations. + +%package libswscale-devel +Summary: Development files for FFmpeg's image scaling and colorspace library +Group: Development/Libraries/C and C++ +Conflicts: libswscale-devel +Provides: libswscale-devel = %version-%release +Requires: %name-libavutil-devel = %version-%release +Requires: libswscale7 = %version-%release +%devel_conflicts -c < -v %_major_version +%devel_conflicts -c >= -v %_major_expected + +%description libswscale-devel +The libswscale library performs image scaling and colorspace and +pixel format conversion operations. + +This subpackage contains the headers for FFmpeg libswscale. + +%prep +%autosetup -p1 -a6 -n %_name-%version + +%build +%ifarch %ix86 %arm +%define _lto_cflags %nil +%endif +%if "%_lto_cflags" != "" +%global _lto_cflags %_lto_cflags -ffat-lto-objects +%endif +CFLAGS="%optflags" \ +%if 0%{?suse_version} > 1500 +%ifarch %ix86 +%else +LDFLAGS="%_lto_cflags" \ +%endif +%endif +./configure \ + --prefix="%_prefix" \ + --libdir="%_libdir" \ + --shlibdir="%_libdir" \ + --incdir="%_includedir/ffmpeg" \ + --extra-cflags="%optflags" \ + --optflags="%optflags" \ + --disable-htmlpages \ + --enable-pic \ + --disable-stripping \ + --enable-shared \ + --disable-static \ + --enable-gpl \ + --enable-version3 \ +%if %{with smbclient} + --enable-libsmbclient \ +%endif + --disable-openssl \ + --enable-gnutls \ + --enable-ladspa \ +%if %{with vulkan} + --enable-libshaderc \ + --enable-vulkan \ + --enable-libplacebo \ +%endif +%if %{with amf} + --enable-amf \ +%endif +%if !%{with cuda_sdk} + --disable-cuda-sdk \ +%endif + --enable-libaom \ + --enable-libass \ + --enable-libbluray \ + --enable-libbs2b \ + --enable-libcdio \ +%if %{with codec2} + --enable-libcodec2 \ +%endif + --enable-libdav1d \ + --enable-libdc1394 \ + --enable-libdrm \ + --enable-libfontconfig \ + --enable-libfreetype \ + --enable-libfribidi \ + --enable-libgsm \ + --enable-libjack \ +%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150700 + --enable-libjxl \ + --enable-librist \ +%endif + --enable-libmp3lame \ +%if %{with mysofa} + --enable-libmysofa \ +%endif + --enable-libopenjpeg \ + --enable-libopenmpt \ + --enable-libopenh264-dlopen \ + --enable-libopus \ + --enable-libpulse \ +%if 0%{?suse_version} > 1500 || 0%{?sle_version} >= 150400 + --enable-librav1e \ +%endif +%if %{with rubberband} + --enable-librubberband \ +%endif +%ifarch x86_64 %x86_64 aarch64 +%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150500 + --enable-libsvtav1 \ +%endif +%endif + --enable-libsoxr \ + --enable-libspeex \ + --enable-libssh \ + --enable-libsrt \ + --enable-libtheora \ + --enable-libtwolame \ +%if %{with vidstab} + --enable-libvidstab \ +%endif + --enable-libvmaf \ + --enable-libvorbis \ + --enable-libvpx \ + --enable-libwebp \ + --enable-libxml2 \ + --enable-libzimg \ + --enable-libzmq \ + --enable-libzvbi \ +%if 0%{?suse_version} > 1500 +%ifarch %ix86 +%else + --enable-lto \ +%endif +%endif + --enable-lv2 \ +%if 0%{?suse_version} < 1550 && 0%{?sle_version} >= 150200 && 0%{?sle_version} < 150600 +%ifarch x86_64 %x86_64 + --enable-libmfx \ +%endif +%else +%ifarch x86_64 %x86_64 + --enable-libvpl \ +%endif +%endif + --enable-vaapi \ + --enable-vdpau \ + --enable-version3 \ +%if %{with fdk_aac_dlopen} + --enable-libfdk-aac-dlopen \ + --enable-nonfree \ +%endif +%if %{with opencore} + --enable-libopencore-amrnb \ + --enable-libopencore-amrwb \ +%endif +%if %{with amrwb} + --enable-libvo-amrwbenc \ +%endif +%if %{with x264} + --enable-libx264 \ +%endif +%if %{with x265} + --enable-libx265 \ +%endif +%if %{with xvid} + --enable-libxvid \ +%endif +%if !0%{?BUILD_ORIG} + --enable-muxers \ + --enable-demuxers \ + --disable-encoders \ + --disable-decoders \ + --disable-decoder=h264,hevc,vc1 \ + --enable-encoder="$(perl -pe 's{^(\w*).*}{$1,}gs' <%_sourcedir/enable_encoders)" \ + --enable-decoder="$(perl -pe 's{^(\w*).*}{$1,}gs' <%_sourcedir/enable_decoders)" \ + +for i in H264 HEVC VC1; do + grep -q "#define CONFIG_${i}_DECODER 0" config_components.h +done +%endif + +cat config.h +%make_build + +%global extratools aviocat cws2fws ffescape ffeval ffhash fourcc2pixfmt graph2dot ismindex pktdumper probetest qt-faststart seek_print sidxindex trasher + +for i in %extratools; do + %make_build "tools/$i" +done + +%install +b="%buildroot" +%make_install install-man +rm -Rf "$b/%_datadir/ffmpeg/examples" +for i in %extratools; do + cp -a "tools/$i" "$b/%_bindir/" +done + +%post -n libavcodec60 -p /sbin/ldconfig +%postun -n libavcodec60 -p /sbin/ldconfig +%post -n libavdevice60 -p /sbin/ldconfig +%postun -n libavdevice60 -p /sbin/ldconfig +%post -n libavfilter9 -p /sbin/ldconfig +%postun -n libavfilter9 -p /sbin/ldconfig +%post -n libavformat60 -p /sbin/ldconfig +%postun -n libavformat60 -p /sbin/ldconfig +%post -n libavutil58 -p /sbin/ldconfig +%postun -n libavutil58 -p /sbin/ldconfig +%post -n libpostproc57 -p /sbin/ldconfig +%postun -n libpostproc57 -p /sbin/ldconfig +%post -n libswresample4 -p /sbin/ldconfig +%postun -n libswresample4 -p /sbin/ldconfig +%post -n libswscale7 -p /sbin/ldconfig +%postun -n libswscale7 -p /sbin/ldconfig + +%files +%doc Changelog CREDITS README.md +%_bindir/* +%_mandir/man1/ff*.1* +%_datadir/ffmpeg/ + +%files -n libavcodec60 +%license COPYING.GPLv2 LICENSE.md +%_libdir/libavcodec.so.* + +%files -n libavdevice60 +%license COPYING.GPLv2 LICENSE.md +%_libdir/libavdevice.so.* + +%files -n libavfilter9 +%license COPYING.GPLv2 LICENSE.md +%_libdir/libavfilter.so.* + +%files -n libavformat60 +%license COPYING.GPLv2 LICENSE.md +%_libdir/libavformat.so.* + +%files -n libavutil58 +%license COPYING.GPLv2 LICENSE.md +%_libdir/libavutil.so.* + +%files -n libpostproc57 +%license COPYING.GPLv2 LICENSE.md +%_libdir/libpostproc.so.* + +%files -n libswresample4 +%license COPYING.GPLv2 LICENSE.md +%_libdir/libswresample.so.* + +%files -n libswscale7 +%license COPYING.GPLv2 LICENSE.md +%_libdir/libswscale.so.* + +%files libavcodec-devel +%dir %_includedir/ffmpeg/ +%_includedir/ffmpeg/libavcodec/ +%_libdir/libavcodec.so +%_libdir/pkgconfig/libavcodec.pc +%_mandir/man3/libavcodec.3* + +%files libavdevice-devel +%dir %_includedir/ffmpeg/ +%_includedir/ffmpeg/libavdevice/ +%_libdir/libavdevice.so +%_libdir/pkgconfig/libavdevice.pc +%_mandir/man3/libavdevice.3* + +%files libavfilter-devel +%dir %_includedir/ffmpeg/ +%_includedir/ffmpeg/libavfilter/ +%_libdir/libavfilter.so +%_libdir/pkgconfig/libavfilter.pc +%_mandir/man3/libavfilter.3* + +%files libavformat-devel +%dir %_includedir/ffmpeg/ +%_includedir/ffmpeg/libavformat/ +%_libdir/libavformat.so +%_libdir/pkgconfig/libavformat.pc +%_mandir/man3/libavformat.3* + +%files libavutil-devel +%dir %_includedir/ffmpeg/ +%_includedir/ffmpeg/libavutil/ +%_libdir/libavutil.so +%_libdir/pkgconfig/libavutil.pc +%_mandir/man3/libavutil.3* + +%files libpostproc-devel +%dir %_includedir/ffmpeg/ +%_includedir/ffmpeg/libpostproc/ +%_libdir/libpostproc.so +%_libdir/pkgconfig/libpostproc.pc + +%files libswresample-devel +%dir %_includedir/ffmpeg/ +%_includedir/ffmpeg/libswresample/ +%_libdir/libswresample.so +%_libdir/pkgconfig/libswresample.pc +%_mandir/man3/libswresample.3* + +%files libswscale-devel +%dir %_includedir/ffmpeg/ +%_includedir/ffmpeg/libswscale/ +%_libdir/libswscale.so +%_libdir/pkgconfig/libswscale.pc +%_mandir/man3/libswscale.3* + +%else +%define _name ffmpeg +Name: ffmpeg-6-mini +Version: 6.1.1 +Release: 0 +Summary: Set of libraries for working with various multimedia formats +License: GPL-3.0-or-later +URL: https://ffmpeg.org/ +#Git-Clone: git://source.ffmpeg.org/ffmpeg +Source: https://www.ffmpeg.org/releases/%_name-%version.tar.xz +Source2: https://www.ffmpeg.org/releases/%_name-%version.tar.xz.asc +Source3: ffmpeg-6-rpmlintrc +Source98: http://ffmpeg.org/ffmpeg-devel.asc#/ffmpeg-6.keyring +Patch1: ffmpeg-arm6l.diff +Patch3: ffmpeg-codec-choice.diff +Patch4: ffmpeg-4.2-dlopen-fdk_aac.patch +Patch5: work-around-abi-break.patch +Patch6: 0001-avcodec-tests-rename-the-bundled-Mesa-AV1-vulkan-vid.patch +Patch7: 0001-avfilter-asrc_afirsrc-fix-by-one-smaller-allocation-.patch +Patch8: 0001-avfilter-bwdif-account-for-chroma-sub-sampling-in-mi.patch +Patch9: 0001-avfilter-af_dialoguenhance-fix-overreads.patch +Patch10: 0001-avfilter-af_dialoguenhance-simplify-channels-copy.patch +Patch11: 0001-avfilter-af_dialoguenhance-do-output-scaling-once.patch +Patch12: 0001-avutil-hwcontext-Don-t-assume-frames_uninit-is-reent.patch +Patch13: 0001-avfilter-vf_codecview-fix-heap-buffer-overflow.patch +Patch90: ffmpeg-chromium.patch +Patch91: ffmpeg-dlopen-openh264.patch +Patch92: ffmpeg-CVE-2023-50007.patch +Patch93: ffmpeg-CVE-2023-50008.patch +BuildRequires: c_compiler +Requires: this-is-only-for-build-envs + +%description +FFmpeg is a multimedia framework. +This package merely builds the API for the sake of other packages. + +%package libs +# Even with mini, we want ff5 libs to be coinstallable to ff4-devel(!), +# hence mini-libs and mini-devel are still separated. +Summary: Feature-reduced build of FFmpeg, a multimedia framework +Conflicts: libavcodec60 +Conflicts: libavdevice60 +Conflicts: libavfilter9 +Conflicts: libavformat60 +Conflicts: libavutil58 +Conflicts: libpostproc57 +Conflicts: libswresample4 +Conflicts: libswscale7 +Requires: this-is-only-for-build-envs + +%description libs +FFmpeg is a multimedia framework. +This package contains a cut-down version for building other packages. + +%package devel +Summary: Header files for feature-reduced FFmpeg build +Provides: libavcodec-devel = %version-%release +Conflicts: libavcodec-devel +Provides: libavdevice-devel = %version-%release +Conflicts: libavdevice-devel +Provides: libavfilter-devel = %version-%release +Conflicts: libavfilter-devel +Provides: libavformat-devel = %version-%release +Conflicts: libavformat-devel +Provides: libavutil-devel = %version-%release +Conflicts: libavutil-devel +Provides: libpostproc-devel = %version-%release +Conflicts: libpostproc-devel +Provides: libswresample-devel = %version-%release +Conflicts: libswresample-devel +Provides: libswscale-devel = %version-%release +Conflicts: libswscale-devel +Requires: %name-libs = %version-%release +Requires: this-is-only-for-build-envs + +%description devel +FFmpeg is a multimedia framework. +This package contains the headers accompanying %name. + +%prep +%autosetup -p1 -n %_name-%version + +%build +%define _lto_cflags %nil +CFLAGS="%optflags" \ +./configure \ + --prefix="%_prefix" \ + --libdir="%_libdir" \ + --shlibdir="%_libdir" \ + --incdir="%_includedir/ffmpeg" \ + --extra-cflags="%optflags" \ + --optflags="%optflags" \ + --disable-htmlpages --disable-stripping --disable-x86asm \ + --disable-static --enable-shared --enable-pic \ + --enable-gpl --enable-version3 \ + --disable-muxers --disable-demuxers \ + --disable-encoders --disable-decoders \ + --disable-programs --disable-doc +for i in H264 HEVC VC1; do + grep -q "#define CONFIG_${i}_DECODER 0" config_components.h +done +cat config.h +%make_build + +%install +b="%buildroot" +%make_install +rm -Rf "$b/%_datadir/ffmpeg/examples" + +%post libs -p /sbin/ldconfig +%postun libs -p /sbin/ldconfig + +%files libs +%_libdir/libavcodec.so.* +%_libdir/libavdevice.so.* +%_libdir/libavfilter.so.* +%_libdir/libavformat.so.* +%_libdir/libavutil.so.* +%_libdir/libpostproc.so.* +%_libdir/libswresample.so.* +%_libdir/libswscale.so.* + +%files devel +%license COPYING.GPLv2 LICENSE.md +%_libdir/*.so +%_libdir/pkgconfig/*.pc +%_includedir/ffmpeg/ + +%endif + +%changelog diff --git a/ffmpeg-CVE-2023-50007.patch b/ffmpeg-CVE-2023-50007.patch new file mode 100644 index 0000000..f90ee9f --- /dev/null +++ b/ffmpeg-CVE-2023-50007.patch @@ -0,0 +1,68 @@ +From b1942734c7cbcdc9034034373abcc9ecb9644c47 Mon Sep 17 00:00:00 2001 +From: Paul B Mahol +Date: Mon, 27 Nov 2023 11:45:34 +0100 +Subject: [PATCH] avfilter/af_afwtdn: fix crash with EOF handling +References: https://bugzilla.opensuse.org/1223253 +References: CVE-2023-50007 + +diff -Nura ffmpeg-6.1.1/libavfilter/af_afwtdn.c ffmpeg-6.1.1_new/libavfilter/af_afwtdn.c +--- ffmpeg-6.1.1/libavfilter/af_afwtdn.c 2023-11-11 08:25:17.000000000 +0800 ++++ ffmpeg-6.1.1_new/libavfilter/af_afwtdn.c 2024-04-25 14:15:23.737350315 +0800 +@@ -408,6 +408,7 @@ + + uint64_t sn; + int64_t eof_pts; ++ int eof; + + int wavelet_type; + int channels; +@@ -1069,7 +1070,7 @@ + s->drop_samples = 0; + } else { + if (s->padd_samples < 0 && eof) { +- out->nb_samples += s->padd_samples; ++ out->nb_samples = FFMAX(0, out->nb_samples + s->padd_samples); + s->padd_samples = 0; + } + if (!eof) +@@ -1208,23 +1209,26 @@ + + FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); + +- ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in); +- if (ret < 0) +- return ret; +- if (ret > 0) +- return filter_frame(inlink, in); ++ if (!s->eof) { ++ ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in); ++ if (ret < 0) ++ return ret; ++ if (ret > 0) ++ return filter_frame(inlink, in); ++ } + + if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { +- if (status == AVERROR_EOF) { +- while (s->padd_samples != 0) { +- ret = filter_frame(inlink, NULL); +- if (ret < 0) +- return ret; +- } +- ff_outlink_set_status(outlink, status, pts); +- return ret; +- } ++ if (status == AVERROR_EOF) ++ s->eof = 1; + } ++ ++ if (s->eof && s->padd_samples != 0) { ++ return filter_frame(inlink, NULL); ++ } else if (s->eof) { ++ ff_outlink_set_status(outlink, AVERROR_EOF, s->eof_pts); ++ return 0; ++ } ++ + FF_FILTER_FORWARD_WANTED(outlink, inlink); + + return FFERROR_NOT_READY; diff --git a/ffmpeg-CVE-2023-50008.patch b/ffmpeg-CVE-2023-50008.patch new file mode 100644 index 0000000..b23fcd7 --- /dev/null +++ b/ffmpeg-CVE-2023-50008.patch @@ -0,0 +1,19 @@ +From 5f87a68cf70dafeab2fb89b42e41a4c29053b89b Mon Sep 17 00:00:00 2001 +From: Paul B Mahol +Date: Mon Nov 27 12:08:20 2023 +0100 +Subject: avfilter/vf_colorcorrect: fix memory leaks +References: https://bugzilla.opensuse.org/1223254 +References: CVE-2023-50008 + +diff -Nura ffmpeg-6.1.1/libavfilter/vf_colorcorrect.c ffmpeg-6.1.1_new/libavfilter/vf_colorcorrect.c +--- ffmpeg-6.1.1/libavfilter/vf_colorcorrect.c 2023-11-11 08:25:17.000000000 +0800 ++++ ffmpeg-6.1.1_new/libavfilter/vf_colorcorrect.c 2024-04-25 14:35:29.717468737 +0800 +@@ -497,6 +497,8 @@ + ColorCorrectContext *s = ctx->priv; + + av_freep(&s->analyzeret); ++ av_freep(&s->uhistogram); ++ av_freep(&s->vhistogram); + } + + static const AVFilterPad colorcorrect_inputs[] = { diff --git a/ffmpeg-arm6l.diff b/ffmpeg-arm6l.diff new file mode 100644 index 0000000..ef90b3d --- /dev/null +++ b/ffmpeg-arm6l.diff @@ -0,0 +1,17 @@ +--- + libavutil/arm/timer.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: ffmpeg-4.4.1/libavutil/arm/timer.h +=================================================================== +--- ffmpeg-4.4.1.orig/libavutil/arm/timer.h ++++ ffmpeg-4.4.1/libavutil/arm/timer.h +@@ -30,7 +30,7 @@ + + #define AV_READ_TIME mach_absolute_time + +-#elif HAVE_INLINE_ASM && defined(__ARM_ARCH_7A__) ++#elif HAVE_INLINE_ASM && defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_6ZK__) + + #define AV_READ_TIME read_time + diff --git a/ffmpeg-chromium.patch b/ffmpeg-chromium.patch new file mode 100644 index 0000000..db1104b --- /dev/null +++ b/ffmpeg-chromium.patch @@ -0,0 +1,46 @@ +commit 95aab0fd83619408995720ce53d7a74790580220 +author liberato@chromium.org Thu Jul 08 02:01:22 2021 +committer liberato@chromium.org Thu Jul 08 02:01:22 2021 +tree ac725b5e2c548c8142aa7096d8184d87d3876a49 +parent e073b7a22e4993e0a7cab80a42a21524e5349f95 + +Add av_stream_get_first_dts for Chromium + +--- + libavformat/avformat.h | 4 ++++ + libavformat/utils.c | 7 +++++++ + 2 files changed, 11 insertions(+) + +Index: ffmpeg-6.1.1/libavformat/avformat.h +=================================================================== +--- ffmpeg-6.1.1.orig/libavformat/avformat.h ++++ ffmpeg-6.1.1/libavformat/avformat.h +@@ -1030,6 +1030,10 @@ attribute_deprecated + int64_t av_stream_get_end_pts(const AVStream *st); + #endif + ++// Chromium: We use the internal field first_dts vvv ++int64_t av_stream_get_first_dts(const AVStream *st); ++// Chromium: We use the internal field first_dts ^^^ ++ + #define AV_PROGRAM_RUNNING 1 + + /** +Index: ffmpeg-6.1.1/libavformat/utils.c +=================================================================== +--- ffmpeg-6.1.1.orig/libavformat/utils.c ++++ ffmpeg-6.1.1/libavformat/utils.c +@@ -56,6 +56,13 @@ int ff_unlock_avformat(void) + return ff_mutex_unlock(&avformat_mutex) ? -1 : 0; + } + ++// Chromium: We use the internal field first_dts vvv ++int64_t av_stream_get_first_dts(const AVStream *st) ++{ ++ return cffstream(st)->first_dts; ++} ++// Chromium: We use the internal field first_dts ^^^ ++ + /* an arbitrarily chosen "sane" max packet size -- 50M */ + #define SANE_CHUNK_SIZE (50000000) + diff --git a/ffmpeg-codec-choice.diff b/ffmpeg-codec-choice.diff new file mode 100644 index 0000000..01ab372 --- /dev/null +++ b/ffmpeg-codec-choice.diff @@ -0,0 +1,57 @@ +From: Jan Engelhardt + +Edit the default codec selection such that + + ffmpeg -i youtube.blah.webm foobar.mkv + +without any further arguments can produce a result even on a +reduced codec selection list. + +--- + libavformat/matroskaenc.c | 20 ++++++++++++++------ + 1 file changed, 14 insertions(+), 6 deletions(-) + +Index: ffmpeg-6.1.1/libavformat/matroskaenc.c +=================================================================== +--- ffmpeg-6.1.1.orig/libavformat/matroskaenc.c ++++ ffmpeg-6.1.1/libavformat/matroskaenc.c +@@ -3538,16 +3538,25 @@ static int mkv_query_codec(enum AVCodecI + return 0; + } + ++#define PREFAUDIO \ ++ CONFIG_LIBOPUS_ENCODER ? AV_CODEC_ID_OPUS : \ ++ CONFIG_AAC_ENCODER ? AV_CODEC_ID_AAC : \ ++ CONFIG_VORBIS_ENCODER ? AV_CODEC_ID_VORBIS : \ ++ AV_CODEC_ID_AC3 ++ + const FFOutputFormat ff_matroska_muxer = { + .p.name = "matroska", + .p.long_name = NULL_IF_CONFIG_SMALL("Matroska"), + .p.mime_type = "video/x-matroska", + .p.extensions = "mkv", + .priv_data_size = sizeof(MatroskaMuxContext), +- .p.audio_codec = CONFIG_LIBVORBIS_ENCODER ? +- AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3, +- .p.video_codec = CONFIG_LIBX264_ENCODER ? +- AV_CODEC_ID_H264 : AV_CODEC_ID_MPEG4, ++ .p.audio_codec = PREFAUDIO, ++ .p.video_codec = ++ CONFIG_LIBVPX_VP9_ENCODER ? AV_CODEC_ID_VP9 : \ ++ CONFIG_LIBX264_ENCODER ? AV_CODEC_ID_H264 : \ ++ CONFIG_LIBVPX_VP8_ENCODER ? AV_CODEC_ID_VP8 : \ ++ CONFIG_MPEG4_ENCODER ? AV_CODEC_ID_MPEG4 : \ ++ AV_CODEC_ID_THEORA, + .init = mkv_init, + .deinit = mkv_deinit, + .write_header = mkv_write_header, +@@ -3615,8 +3624,7 @@ const FFOutputFormat ff_matroska_audio_m + .p.mime_type = "audio/x-matroska", + .p.extensions = "mka", + .priv_data_size = sizeof(MatroskaMuxContext), +- .p.audio_codec = CONFIG_LIBVORBIS_ENCODER ? +- AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3, ++ .p.audio_codec = PREFAUDIO, + .p.video_codec = AV_CODEC_ID_NONE, + .init = mkv_init, + .deinit = mkv_deinit, diff --git a/ffmpeg-dlopen-headers.tar.xz b/ffmpeg-dlopen-headers.tar.xz new file mode 100644 index 0000000..c72db64 --- /dev/null +++ b/ffmpeg-dlopen-headers.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0cc860a1940704082c81502fe9245aaefeeee9a1674797ccd74a123ab054cf77 +size 15532 diff --git a/ffmpeg-dlopen-openh264.patch b/ffmpeg-dlopen-openh264.patch new file mode 100644 index 0000000..357dceb --- /dev/null +++ b/ffmpeg-dlopen-openh264.patch @@ -0,0 +1,378 @@ +From 4739b0c97b3378bdaf737171777fe9a71a53eff1 Mon Sep 17 00:00:00 2001 +From: Neal Gompa +Date: Wed, 12 Oct 2022 09:41:27 -0400 +Subject: [PATCH] avcodec/openh264: Add the ability to dlopen() OpenH264 + +We can't directly depend on OpenH264, but we can weakly link to it +and gracefully expose the capability. + +Co-authored-by: Andreas Schneider +Co-authored-by: Neal Gompa + +Signed-off-by: Andreas Schneider +Signed-off-by: Neal Gompa +--- + configure | 3 + + libavcodec/Makefile | 1 + + libavcodec/libopenh264.c | 18 +++- + libavcodec/libopenh264_dlopen.c | 147 ++++++++++++++++++++++++++++++++ + libavcodec/libopenh264_dlopen.h | 58 +++++++++++++ + libavcodec/libopenh264dec.c | 10 +++ + libavcodec/libopenh264enc.c | 10 +++ + 7 files changed, 245 insertions(+), 2 deletions(-) + create mode 100644 libavcodec/libopenh264_dlopen.c + create mode 100644 libavcodec/libopenh264_dlopen.h + +Index: ffmpeg-6.1.1/configure +=================================================================== +--- ffmpeg-6.1.1.orig/configure ++++ ffmpeg-6.1.1/configure +@@ -250,6 +250,7 @@ External library support: + --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no] + --enable-libopencv enable video filtering via libopencv [no] + --enable-libopenh264 enable H.264 encoding via OpenH264 [no] ++ --enable-libopenh264-dlopen enable H.264 encoding via dlopen()'ed OpenH264 [no] + --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no] + --enable-libopenmpt enable decoding tracked files via libopenmpt [no] + --enable-libopenvino enable OpenVINO as a DNN module backend +@@ -1873,6 +1874,7 @@ EXTERNAL_LIBRARY_LIST=" + libmysofa + libopencv + libopenh264 ++ libopenh264_dlopen + libopenjpeg + libopenmpt + libopenvino +@@ -6770,6 +6772,7 @@ enabled libopencv && { check_hea + require libopencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } || + require_pkg_config libopencv opencv opencv/cxcore.h cvCreateImageHeader; } + enabled libopenh264 && require_pkg_config libopenh264 openh264 wels/codec_api.h WelsGetCodecVersion ++enabled libopenh264_dlopen && enable libopenh264 && add_cppflags "-I$(dirname `readlink -f $0`)/ffdlopenhdrs/include -DCONFIG_LIBOPENH264_DLOPEN=1" + enabled libopenjpeg && { check_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version || + { require_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } } + enabled libopenmpt && require_pkg_config libopenmpt "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -lstdc++ && append libopenmpt_extralibs "-lstdc++" +Index: ffmpeg-6.1.1/libavcodec/Makefile +=================================================================== +--- ffmpeg-6.1.1.orig/libavcodec/Makefile ++++ ffmpeg-6.1.1/libavcodec/Makefile +@@ -1115,6 +1115,7 @@ OBJS-$(CONFIG_LIBMP3LAME_ENCODER) + OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o + OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER) += libopencore-amr.o + OBJS-$(CONFIG_LIBOPENCORE_AMRWB_DECODER) += libopencore-amr.o ++OBJS-$(CONFIG_LIBOPENH264_DLOPEN) += libopenh264_dlopen.o + OBJS-$(CONFIG_LIBOPENH264_DECODER) += libopenh264dec.o libopenh264.o + OBJS-$(CONFIG_LIBOPENH264_ENCODER) += libopenh264enc.o libopenh264.o + OBJS-$(CONFIG_LIBOPENJPEG_ENCODER) += libopenjpegenc.o +Index: ffmpeg-6.1.1/libavcodec/libopenh264.c +=================================================================== +--- ffmpeg-6.1.1.orig/libavcodec/libopenh264.c ++++ ffmpeg-6.1.1/libavcodec/libopenh264.c +@@ -20,8 +20,13 @@ + */ + + #include ++ ++#ifdef CONFIG_LIBOPENH264_DLOPEN ++#include "libopenh264_dlopen.h" ++#else + #include + #include ++#endif + + #include "libavutil/error.h" + #include "libavutil/log.h" +@@ -52,8 +57,17 @@ int ff_libopenh264_check_version(void *l + // Mingw GCC < 4.7 on x86_32 uses an incorrect/buggy ABI for the WelsGetCodecVersion + // function (for functions returning larger structs), thus skip the check in those + // configurations. +-#if !defined(_WIN32) || !defined(__GNUC__) || !ARCH_X86_32 || AV_GCC_VERSION_AT_LEAST(4, 7) +- OpenH264Version libver = WelsGetCodecVersion(); ++ // Also, for dlopened OpenH264, we should not do the version check. It's too punitive. ++#if !defined(_WIN32) || !defined(__GNUC__) || !ARCH_X86_32 || AV_GCC_VERSION_AT_LEAST(4, 7) || !defined(CONFIG_LIBOPENH264_DLOPEN) ++ OpenH264Version libver; ++ ++#ifdef CONFIG_LIBOPENH264_DLOPEN ++ if (loadLibOpenH264(logctx)) { ++ return AVERROR_EXTERNAL; ++ } ++#endif ++ ++ libver = WelsGetCodecVersion(); + if (memcmp(&libver, &g_stCodecVersion, sizeof(libver))) { + av_log(logctx, AV_LOG_ERROR, "Incorrect library version loaded\n"); + return AVERROR(EINVAL); +Index: ffmpeg-6.1.1/libavcodec/libopenh264_dlopen.c +=================================================================== +--- /dev/null ++++ ffmpeg-6.1.1/libavcodec/libopenh264_dlopen.c +@@ -0,0 +1,147 @@ ++/* ++ * OpenH264 dlopen code ++ * ++ * Copyright (C) 2022 Andreas Schneider ++ * ++ * This file is part of FFmpeg. ++ * ++ * FFmpeg is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * FFmpeg is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with FFmpeg; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#include ++ ++#include "libopenh264_dlopen.h" ++ ++/* ++ * The symbol binding makes sure we do not run into strict aliasing issues which ++ * can lead into segfaults. ++ */ ++typedef int (*__oh264_WelsCreateSVCEncoder)(ISVCEncoder **); ++typedef void (*__oh264_WelsDestroySVCEncoder)(ISVCEncoder *); ++typedef int (*__oh264_WelsGetDecoderCapability)(SDecoderCapability *); ++typedef long (*__oh264_WelsCreateDecoder)(ISVCDecoder **); ++typedef void (*__oh264_WelsDestroyDecoder)(ISVCDecoder *); ++typedef OpenH264Version (*__oh264_WelsGetCodecVersion)(void); ++typedef void (*__oh264_WelsGetCodecVersionEx)(OpenH264Version *); ++ ++#define OH264_SYMBOL_ENTRY(i) \ ++ union { \ ++ __oh264_##i f; \ ++ void *obj; \ ++ } _oh264_##i ++ ++struct oh264_symbols { ++ OH264_SYMBOL_ENTRY(WelsCreateSVCEncoder); ++ OH264_SYMBOL_ENTRY(WelsDestroySVCEncoder); ++ OH264_SYMBOL_ENTRY(WelsGetDecoderCapability); ++ OH264_SYMBOL_ENTRY(WelsCreateDecoder); ++ OH264_SYMBOL_ENTRY(WelsDestroyDecoder); ++ OH264_SYMBOL_ENTRY(WelsGetCodecVersion); ++ OH264_SYMBOL_ENTRY(WelsGetCodecVersionEx); ++}; ++ ++/* Symbols are bound by loadLibOpenH264() */ ++static struct oh264_symbols openh264_symbols; ++ ++int oh264_WelsCreateSVCEncoder(ISVCEncoder **ppEncoder) { ++ return openh264_symbols._oh264_WelsCreateSVCEncoder.f(ppEncoder); ++} ++ ++void oh264_WelsDestroySVCEncoder(ISVCEncoder *pEncoder) { ++ return openh264_symbols._oh264_WelsDestroySVCEncoder.f(pEncoder); ++} ++ ++int oh264_WelsGetDecoderCapability(SDecoderCapability *pDecCapability) { ++ return openh264_symbols._oh264_WelsGetDecoderCapability.f(pDecCapability); ++} ++ ++long oh264_WelsCreateDecoder(ISVCDecoder **ppDecoder) { ++ return openh264_symbols._oh264_WelsCreateDecoder.f(ppDecoder); ++} ++ ++void oh264_WelsDestroyDecoder(ISVCDecoder *pDecoder) { ++ return openh264_symbols._oh264_WelsDestroyDecoder.f(pDecoder); ++} ++ ++OpenH264Version oh264_WelsGetCodecVersion(void) { ++ return openh264_symbols._oh264_WelsGetCodecVersion.f(); ++} ++ ++void oh264_WelsGetCodecVersionEx(OpenH264Version *pVersion) { ++ openh264_symbols._oh264_WelsGetCodecVersionEx.f(pVersion); ++} ++ ++static void *_oh264_bind_symbol(AVCodecContext *avctx, ++ void *handle, ++ const char *sym_name) { ++ void *sym = NULL; ++ ++ sym = dlsym(handle, sym_name); ++ if (sym == NULL) { ++ const char *err = dlerror(); ++ av_log(avctx, ++ AV_LOG_WARNING, ++ "%s: Failed to bind %s\n", ++ err, ++ sym_name); ++ return NULL; ++ } ++ ++ return sym; ++} ++ ++#define oh264_bind_symbol(avctx, handle, sym_name) \ ++ if (openh264_symbols._oh264_##sym_name.obj == NULL) { \ ++ openh264_symbols._oh264_##sym_name.obj = _oh264_bind_symbol(avctx, handle, #sym_name); \ ++ if (openh264_symbols._oh264_##sym_name.obj == NULL) { \ ++ return 1; \ ++ } \ ++ } ++ ++int loadLibOpenH264(AVCodecContext *avctx) { ++ static bool initialized = false; ++ void *libopenh264 = NULL; ++ const char *err = NULL; ++ ++ if (initialized) { ++ return 0; ++ } ++ ++#define OPENH264_LIB "libopenh264.so.7" ++ libopenh264 = dlopen(OPENH264_LIB, RTLD_LAZY); ++ err = dlerror(); ++ if (err != NULL) { ++ av_log(avctx, AV_LOG_WARNING, ++ "%s: %s is missing, openh264 support will be disabled\n", err, ++ OPENH264_LIB); ++ ++ if (libopenh264 != NULL) { ++ dlclose(libopenh264); ++ } ++ return 1; ++ } ++ ++ oh264_bind_symbol(avctx, libopenh264, WelsCreateSVCEncoder); ++ oh264_bind_symbol(avctx, libopenh264, WelsDestroySVCEncoder); ++ oh264_bind_symbol(avctx, libopenh264, WelsGetDecoderCapability); ++ oh264_bind_symbol(avctx, libopenh264, WelsCreateDecoder); ++ oh264_bind_symbol(avctx, libopenh264, WelsDestroyDecoder); ++ oh264_bind_symbol(avctx, libopenh264, WelsGetCodecVersion); ++ oh264_bind_symbol(avctx, libopenh264, WelsGetCodecVersionEx); ++ ++ initialized = true; ++ ++ return 0; ++} +Index: ffmpeg-6.1.1/libavcodec/libopenh264_dlopen.h +=================================================================== +--- /dev/null ++++ ffmpeg-6.1.1/libavcodec/libopenh264_dlopen.h +@@ -0,0 +1,58 @@ ++/* ++ * OpenH264 dlopen code ++ * ++ * Copyright (C) 2022 Andreas Schneider ++ * ++ * This file is part of FFmpeg. ++ * ++ * FFmpeg is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * FFmpeg is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with FFmpeg; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#ifndef HAVE_LIBOPENH264_DLOPEN_H ++#define HAVE_LIBOPENH264_DLOPEN_H ++ ++#ifdef CONFIG_LIBOPENH264_DLOPEN ++ ++#include ++#include ++ ++#include "avcodec.h" ++ ++int oh264_WelsCreateSVCEncoder(ISVCEncoder **ppEncoder); ++#define WelsCreateSVCEncoder oh264_WelsCreateSVCEncoder ++ ++void oh264_WelsDestroySVCEncoder(ISVCEncoder *pEncoder); ++#define WelsDestroySVCEncoder oh264_WelsDestroySVCEncoder ++ ++int oh264_WelsGetDecoderCapability(SDecoderCapability *pDecCapability); ++#define WelsGetDecoderCapability oh264_WelsGetDecoderCapability ++ ++long oh264_WelsCreateDecoder(ISVCDecoder **ppDecoder); ++#define WelsCreateDecoder oh264_WelsCreateDecoder ++ ++void oh264_WelsDestroyDecoder(ISVCDecoder *pDecoder); ++#define WelsDestroyDecoder oh264_WelsDestroyDecoder ++ ++OpenH264Version oh264_WelsGetCodecVersion(void); ++#define WelsGetCodecVersion oh264_WelsGetCodecVersion ++ ++void oh264_WelsGetCodecVersionEx(OpenH264Version *pVersion); ++#define WelsGetCodecVersionEx oh264_WelsGetCodecVersionEx ++ ++int loadLibOpenH264(AVCodecContext *avctx); ++ ++#endif /* CONFIG_LIBOPENH264_DLOPEN */ ++ ++#endif /* HAVE_LIBOPENH264_DLOPEN_H */ +Index: ffmpeg-6.1.1/libavcodec/libopenh264dec.c +=================================================================== +--- ffmpeg-6.1.1.orig/libavcodec/libopenh264dec.c ++++ ffmpeg-6.1.1/libavcodec/libopenh264dec.c +@@ -19,8 +19,12 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + ++#ifdef CONFIG_LIBOPENH264_DLOPEN ++#include "libopenh264_dlopen.h" ++#else + #include + #include ++#endif + + #include "libavutil/common.h" + #include "libavutil/fifo.h" +@@ -56,6 +60,12 @@ static av_cold int svc_decode_init(AVCod + int log_level; + WelsTraceCallback callback_function; + ++#ifdef CONFIG_LIBOPENH264_DLOPEN ++ if (loadLibOpenH264(avctx)) { ++ return AVERROR_DECODER_NOT_FOUND; ++ } ++#endif ++ + if ((err = ff_libopenh264_check_version(avctx)) < 0) + return AVERROR_DECODER_NOT_FOUND; + +Index: ffmpeg-6.1.1/libavcodec/libopenh264enc.c +=================================================================== +--- ffmpeg-6.1.1.orig/libavcodec/libopenh264enc.c ++++ ffmpeg-6.1.1/libavcodec/libopenh264enc.c +@@ -19,8 +19,12 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + ++#ifdef CONFIG_LIBOPENH264_DLOPEN ++#include "libopenh264_dlopen.h" ++#else + #include + #include ++#endif + + #include "libavutil/attributes.h" + #include "libavutil/common.h" +@@ -115,6 +119,12 @@ static av_cold int svc_encode_init(AVCod + WelsTraceCallback callback_function; + AVCPBProperties *props; + ++#ifdef CONFIG_LIBOPENH264_DLOPEN ++ if (loadLibOpenH264(avctx)) { ++ return AVERROR_ENCODER_NOT_FOUND; ++ } ++#endif ++ + if ((err = ff_libopenh264_check_version(avctx)) < 0) + return AVERROR_ENCODER_NOT_FOUND; + diff --git a/ffmpeg-new-coder-errors.diff b/ffmpeg-new-coder-errors.diff new file mode 100644 index 0000000..5c8d884 --- /dev/null +++ b/ffmpeg-new-coder-errors.diff @@ -0,0 +1,23 @@ +From: Jan Engelhardt +Date: 2016-04-10 23:23:53.138440254 +0200 + +Improve the error messages a bit to say what's really going on +(in light of openSUSE's reduced build). + +--- + fftools/ffmpeg_dec.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: ffmpeg-6.1.1/fftools/ffmpeg_dec.c +=================================================================== +--- ffmpeg-6.1.1.orig/fftools/ffmpeg_dec.c ++++ ffmpeg-6.1.1/fftools/ffmpeg_dec.c +@@ -1075,7 +1075,7 @@ int dec_open(InputStream *ist) + + if (!codec) { + av_log(ist, AV_LOG_ERROR, +- "Decoding requested, but no decoder found for: %s\n", ++ "Decoding was requested, but this build of ffmpeg does not include a \"%s\" decoder\n", + avcodec_get_name(ist->dec_ctx->codec_id)); + return AVERROR(EINVAL); + } diff --git a/ffmpeg_get_dlopen_headers.sh b/ffmpeg_get_dlopen_headers.sh new file mode 100644 index 0000000..6e0f419 --- /dev/null +++ b/ffmpeg_get_dlopen_headers.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Script to grab headers from existing packages to support dlopen() codec libraries +# Requires: bash, coreutils, curl, bsdtar, dnf, dnf-plugins-core, tar, xz +# Author: Neal Gompa +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +echo "Setting up..." +# Get local directory +LOCALDIR=$(realpath $(dirname $0)) + +# Create working area +TMPDIR=$(mktemp -d /tmp/mmheadersXXXXXX) +mkdir -pv $TMPDIR + +echo "Fetching headers..." +# Get OpenH264 headers +OPENH264_DEVEL=$(dnf -q download --url 'pkgconfig(openh264)') +curl -L $OPENH264_DEVEL | bsdtar -xvf - --include "./usr/include/*" -C $TMPDIR + +echo "Generating tarball..." +# Prep tarball tree +mv -v ${TMPDIR}/usr ${TMPDIR}/ffdlopenhdrs +# Generate tarball +tar --transform "s|^${TMPDIR#?}/||" -cJvf ${LOCALDIR}/ffmpeg-dlopen-headers.tar.xz ${TMPDIR}/ffdlopenhdrs +# Clean up +echo "Cleaning up..." +rm -rfv ${TMPDIR} + +echo "Tarball created: ${LOCALDIR}/ffmpeg-dlopen-headers.tar.xz" diff --git a/work-around-abi-break.patch b/work-around-abi-break.patch new file mode 100644 index 0000000..edb250a --- /dev/null +++ b/work-around-abi-break.patch @@ -0,0 +1,52 @@ +From: Jan Engelhardt +Date: 2020-07-04 23:56:54.411950316 +0200 +References: http://ffmpeg.org/pipermail/ffmpeg-devel/2020-July/265694.html + +User frispete wrote on 2020-6-26 22:13+0000 at +https://build.opensuse.org/package/show/multimedia:libs/ffmpeg-4#comment-1257440 +: """Unfortunately, this version is binary incompatible to 4.2.3 in some +aspects. [...]""" + +Further discussion on the mailing list explored this topic, and +revealed that ELF symbol versioning is lacklusterly implemented in +ffmpeg, which can cause inadvertent mixing of library versions on +openSUSE, and precompiled Linux distributions in general. + +Upstream says "we only add new functions" - which is ok in its own +right. verdefs, if you have them, *must*not* change under any +circumstances, but that is what they broke: the set of symbols +included in the "LIBAVFORMAT_59" verdef changed between 5.0 and 5.1. + +$ abidiff abidiff /usr/lib64/libavformat.so.59.16.100 usr/lib64/libavformat.so.59.27.100 +Functions changes summary: 0 Removed, 0 Changed, 0 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable +Function symbols changes summary: 0 Removed, 1 Added function symbol not referenced by debug info +Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info + +1 Added function symbol not referenced by debug info: + + [A] avio_vprintf@@LIBAVFORMAT_59 + +] + +Henceforth, we're changing the .v files such that the symbol set in +any one verdef we will ever emit is never modified in future +releases. + +--- + ffbuild/library.mak | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: ffmpeg-5.1/ffbuild/library.mak +=================================================================== +--- ffmpeg-5.1.orig/ffbuild/library.mak ++++ ffmpeg-5.1/ffbuild/library.mak +@@ -59,7 +59,7 @@ $(SUBDIR)lib$(FULLNAME).pc: $(SUBDIR)ver + $$(M) $$(SRC_PATH)/ffbuild/pkgconfig_generate.sh $(NAME) "$(DESC)" + + $(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS) +- $$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@ ++ $$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR).$(lib$(NAME)_VERSION_MINOR)_SUSE/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@ + + $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR) + $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)