summaryrefslogtreecommitdiff
path: root/libavcodec
Commit message (Collapse)AuthorAge
* avcodec/h274: add film grain synthesis routineNiklas Haas2021-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | This could arguably also be a vf, but I decided to put it here since decoders are technically required to apply film grain during the output step, and I would rather want to avoid requiring users insert the correct film grain synthesis filter on their own. The code, while in C, is written in a way that unrolls/vectorizes fairly well under -O3, and is reasonably cache friendly. On my CPU, a single thread pushes about 400 FPS at 1080p. Apart from hand-written assembly, one possible avenue of improvement would be to change the access order to compute the grain row-by-row rather than in 8x8 blocks. This requires some redundant PRNG calls, but would make the algorithm more cache-oblivious. The implementation has been written to the wording of SMPTE RDD 5-2006 as faithfully as I can manage. However, apart from passing a visual inspection, no guarantee of correctness can be made due to the lack of any publicly available reference implementation against which to compare it. Signed-off-by: Niklas Haas <git@haasn.dev> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h264_slice: compute and export film grain seedNiklas Haas2021-08-24
| | | | | | | | | | | | | | | | | | | | | | | | From SMPTE RDD 5-2006, the grain seed is to be computed from the following definition of `pic_offset`: > When decoding H.264 | MPEG-4 AVC bitstreams, pic_offset is defined as > follows: > - pic_offset = PicOrderCnt(CurrPic) + (PicOrderCnt_offset << 5) > where: > - PicOrderCnt(CurrPic) is the picture order count of the current frame, > which shall be derived from [the video stream]. > > - PicOrderCnt_offset is set to idr_pic_id on IDR frames. idr_pic_id > shall be read from the slice header of [the video stream]. On non-IDR I > frames, PicOrderCnt_offset is set to 0. A frame shall be classified as I > frame when all its slices are I slices, which may be optionally > designated by setting primary_pic_type to 0 in the access delimiter NAL > unit. Otherwise, PicOrderCnt_offset it not changed. PicOrderCnt_offset is > updated in decoding order. Co-authored-by: James Almer <jamrial@gmail.com> Signed-off-by: Niklas Haas <git@haasn.dev> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libaomenc: use ctx->usage to get default cfgJames Zern2021-08-23
| | | | | | | | | | | this prevents some mismatches in config values for realtime and all intra modes, avoiding failures like: [libaom-av1 @ ...] Failed to initialize encoder: Invalid parameter [libaom-av1 @ ...] Additional information: g_lag_in_frames out of range [..0] Signed-off-by: James Zern <jzern@google.com>
* avcodec/av1_frame_merge_bsf: Passthrough pos in case of no timestampsAndreas Rheinhardt2021-08-23
| | | | | | | This is needed by the AV1-Annex B and AV1-OBU demuxers. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/webp: Check available space in loop in decode_entropy_coded_image()Michael Niedermayer2021-08-22
| | | | | | | | Fixes: Timeout Fixes: 35401/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WEBP_fuzzer-5714401821851648 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/h264dec: use picture parameters in ff_print_debug_info2()Michael Niedermayer2021-08-22
| | | | | | | | Fixes: out of array read Fixes: 36341/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-6737583085322240 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1dec: ff_print_debug_info() does not support WMV3 field_modeMichael Niedermayer2021-08-22
| | | | | | | | Fixes: out of array read Fixes: 36331/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3_fuzzer-5140494328922112.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc/aarch64: add pred functions for 10-bitMikhail Nitenko2021-08-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Benchmarks: A53 A72 pred8x8_dc_10_c: 64.2 49.5 pred8x8_dc_10_neon: 62.0 53.7 pred8x8_dc_128_10_c: 26.0 14.0 pred8x8_dc_128_10_neon: 30.7 17.5 pred8x8_horizontal_10_c: 60.0 27.7 pred8x8_horizontal_10_neon: 38.0 34.0 pred8x8_left_dc_10_c: 42.5 27.5 pred8x8_left_dc_10_neon: 51.0 41.2 pred8x8_mad_cow_dc_0l0_10_c: 55.7 37.2 pred8x8_mad_cow_dc_0l0_10_neon: 50.2 35.2 pred8x8_mad_cow_dc_0lt_10_c: 89.2 67.0 pred8x8_mad_cow_dc_0lt_10_neon: 52.2 46.7 pred8x8_mad_cow_dc_l0t_10_c: 74.7 51.0 pred8x8_mad_cow_dc_l0t_10_neon: 50.5 45.2 pred8x8_mad_cow_dc_l00_10_c: 58.0 38.0 pred8x8_mad_cow_dc_l00_10_neon: 42.5 37.5 pred8x8_plane_10_c: 354.0 288.7 pred8x8_plane_10_neon: 141.0 101.2 pred8x8_top_dc_10_c: 44.5 30.5 pred8x8_top_dc_10_neon: 40.0 31.0 pred8x8_vertical_10_c: 27.5 14.5 pred8x8_vertical_10_neon: 21.0 17.5 pred16x16_plane_10_c: 1242.0 1070.5 pred16x16_plane_10_neon: 324.0 196.7 Signed-off-by: Mikhail Nitenko <mnitenko@gmail.com> Signed-off-by: Martin Storsjö <martin@martin.st>
* lavc/aarch64: h264, add chroma loop filters for 10bitMikhail Nitenko2021-08-21
| | | | | | | | | | | | | | | | | | | | | | | | | Benchmarks: A53 A72 h264_h_loop_filter_chroma422_10bpp_c: 282.7 114.2 h264_h_loop_filter_chroma422_10bpp_neon: 109.5 78.5 h264_h_loop_filter_chroma_10bpp_c: 165.0 81.5 h264_h_loop_filter_chroma_10bpp_neon: 120.0 76.7 h264_h_loop_filter_chroma_intra422_10bpp_c: 323.7 124.2 h264_h_loop_filter_chroma_intra422_10bpp_neon: 155.0 102.7 h264_h_loop_filter_chroma_intra_10bpp_c: 121.0 49.5 h264_h_loop_filter_chroma_intra_10bpp_neon: 79.7 53.7 h264_h_loop_filter_chroma_mbaff422_10bpp_c: 188.5 75.0 h264_h_loop_filter_chroma_mbaff422_10bpp_neon: 120.0 75.5 h264_h_loop_filter_chroma_mbaff_intra422_10bpp_c: 116.7 46.0 h264_h_loop_filter_chroma_mbaff_intra422_10bpp_neon: 79.7 53.7 h264_h_loop_filter_chroma_mbaff_intra_10bpp_c: 63.0 27.2 h264_h_loop_filter_chroma_mbaff_intra_10bpp_neon: 48.5 34.0 h264_v_loop_filter_chroma_10bpp_c: 258.7 135.5 h264_v_loop_filter_chroma_10bpp_neon: 71.2 51.0 h264_v_loop_filter_chroma_intra_10bpp_c: 158.0 70.7 h264_v_loop_filter_chroma_intra_10bpp_neon: 48.7 31.5 Signed-off-by: Mikhail Nitenko <mnitenko@gmail.com> Signed-off-by: Martin Storsjö <martin@martin.st>
* lavc/aarch64: move transpose_4x8H to neon.SMikhail Nitenko2021-08-21
| | | | | | | | transpose_4x8H was declared in vp9lpf_16bpp_neon, however this macro is not unique to vp9 and could be used elsewhere. Signed-off-by: Mikhail Nitenko <mnitenko@gmail.com> Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/h264_parser: Fix undefined left shiftAndreas Rheinhardt2021-08-20
| | | | | | | | | | | | | | Use an uint32_t for the NAL unit size of an AVC H.264 NAL unit instead of an int as a left shift of a signed value is undefined behaviour if the result doesn't fit into the target type. Also make the log message never output negative lengths. Fixes: left shift of 16711968 by 8 places cannot be represented in type 'int' Fixes: 36601/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-6581933285965824 Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* get_cabac_inline_x86: Don't inline if 32-bit clang on windowsChristopher Degawa2021-08-19
| | | | | | | | | Fixes https://trac.ffmpeg.org/ticket/8903 relevant https://github.com/msys2/MINGW-packages/discussions/9258 Signed-off-by: Christopher Degawa <ccom@randomderp.com> Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/libx265: improve full range flag setting logicJan Ekström2021-08-18
| | | | | | | | | | | | | Unlike libx264, libx265 does not have a separate "unspecified"/"auto" default for color range, so we do always have to specify it. Thus, we are required to handle the RGB case on the libavcodec side to enable the correct value to be written out in in case of RGB content with unspecified color range being received. In other words: 1. If the user has set color range specifically, follow that. 2. If the user has not set color range specifically, set full range by default in case of RGB and YUVJ pixel formats.
* avcodec/libx264: leave full range flag unchanged if unknownJan Ekström2021-08-18
| | | | | | | | | By default the x264 full range flag is set to -1. By not setting it to something else, we can let libx264 handle the RGB case. Additionally, change the preference order to user-specified range first, and then any fall-back logic left for the YUVJ pix_fmts. Fixes the capture part of #9374
* avcodec: add SMC encoderPaul B Mahol2021-08-18
|
* avcodec/frame_thread_encoder: Free AVCodecContext structure on error during initMichael Niedermayer2021-08-17
| | | | | | | | | | Fixes: MemLeak Fixes: 8281 Fixes: PoC_option158.jpg Fixes: CVE-2020-22037 Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/options_table: Treat (request_)channel_layout as channel layoutAndreas Rheinhardt2021-08-15
| | | | | | | Also adapt some FATE tests to already cover this. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/h264_sei: fix H.274 film grain parsingNiklas Haas2021-08-15
| | | | | | | | | | The current code reads the wrong number of bits for `fg_model_id`, which causes all of the values downstream of this to contain corrupt values. Fixes: corrupt SEI values Fixes: 4ff73add5dbe6c319d693355be44df2e17a0b8bf Signed-off-by: Niklas Haas <git@haasn.dev>
* avcodec/trace_headers_bsf: also parse extradata in packet side dataJames Almer2021-08-14
| | | | | | | | | Certain mov/mp4 files have parameter sets out of band, and when required for a sample it may be propagated within the relevant packet's side data. This fixes parsing said files if the SPS and/or PPS in the side data is different than the one in extradata. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_bsf: use ff_cbs_read_packet_side_data() to parse extradata in ↵James Almer2021-08-14
| | | | | | packet side data Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs: add a helper to read extradata within packet side dataJames Almer2021-08-14
| | | | | | | | Using ff_cbs_read() on the raw buffer will not parse it as extradata, resulting in parsing errors for example when handling ISOBMFF avcC. This helper works around that. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/smc: use shorter way to access GetByteContextPaul B Mahol2021-08-14
|
* avcodec/smc: use unchecked reader for call after checking remaining sizePaul B Mahol2021-08-14
|
* avcodec/smc: use uint8_t type instead of longer variantPaul B Mahol2021-08-13
|
* avcodec/smc: report error codes instead of silently ignoring themPaul B Mahol2021-08-13
|
* avcodec/smc: 0xF0 opcode operates like 0xE0 opcodePaul B Mahol2021-08-13
|
* Fix for bug #9231: B-frames parameter is ignored in videotoolboxencAnselm Busse2021-08-13
| | | | | | | | | This commit fixes the bug as report in https://trac.ffmpeg.org/ticket/9231 by removing the line that overwrites the user settings for max_b_frames. Signed-off-by: Anselm Busse <anselm.busse@outlook.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/qsvenc: allows the SDK runtime to choose LowPower/non-LowPower modesHaihao Xiang2021-08-12
| | | | | | | | | | | | | The SDK supports LowPower and non-LowPower modes, but some features are available only under one of the two modes. Currently non-LowPower mode is always chosen in FFmpeg if the mode is not set to LowPower explicitly. User will experience some SDK errors if a LowPower related feature is specified but the mode is not set to LowPower. With this patch, the mode is set to unknown by default in FFmpeg, the SDK is able to choose a workable mode for the specified features. Reviewed-by: Soft Works <softworkz@hotmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* qsvdec: add support for HW_DEVICE_CTX methodHaihao Xiang2021-08-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows user set hw_device_ctx instead of hw_frames_ctx for QSV decoders, hence we may remove the ad-hoc libmfx setup code from FFmpeg. "-hwaccel_output_format format" is applied to QSV decoders after removing the ad-hoc libmfx code. In order to keep compatibility with old commandlines, the default format is set to AV_PIX_FMT_QSV, but this behavior will be removed in the future. Please set "-hwaccel_output_format qsv" explicitly if AV_PIX_FMT_QSV is expected. The normal device stuff works for QSV decoders now, user may use "-init_hw_device args" to initialise device and "-hwaccel_device devicename" to select a device for QSV decoders. "-qsv_device device" which was added for workarounding device selection in the ad-hoc libmfx code still works For example: $> ffmpeg -init_hw_device qsv=qsv:hw_any,child_device=/dev/dri/card0 -hwaccel qsv -c:v h264_qsv -i input.h264 -f null - /dev/dri/renderD128 is actually open for h264_qsv decoder in the above command without this patch. After applying this patch, /dev/dri/card0 is used. $> ffmpeg -init_hw_device vaapi=va:/dev/dri/card0 -init_hw_device qsv=hw@va -hwaccel_device hw -hwaccel qsv -c:v h264_qsv -i input.h264 -f null - device hw of type qsv is not usable in the above command without this patch. After applying this patch, this command works as expected. Reviewed-by: Soft Works <softworkz@hotmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* libavcodec/qsvence: Use QSV encoder defaults as ffmpeg defaultsSoft Works2021-08-11
| | | | Signed-off-by: softworkz <softworkz@hotmail.com>
* avcodec/h264_slice: use ff_h264_replace_picture when syncing thread contextsJames Almer2021-08-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h264_picture: add ff_h264_replace_picture()James Almer2021-08-10
| | | | | | | Will remove unnecessary allocations when both src and dst picture contain references to the same buffers. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h264_picture: split copying H264Picture some fields into a separate ↵James Almer2021-08-10
| | | | | | function Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h264_slice: clear old slice POC values on parsing failureJames Almer2021-08-10
| | | | | | | | If a slice header fails to parse, and the next one uses different Sequence and Picture parameter sets, certain values may not be read if they are not coded, resulting in the previous slice values being used. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/faxcompr: Check for end of input in cmode == 1 in ↵Michael Niedermayer2021-08-10
| | | | | | | | | | decode_group3_2d_line() Fixes: Infinite loop Fixes: 35591/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4503764022198272 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc1dec: Disable error concealment for *IMAGEMichael Niedermayer2021-08-10
| | | | | | | | | | | | | | The existing error concealment makes no sense for the image formats, they use transformed source images which is different from keyframe + MC+difference for which the error concealment is designed. Of course feel free to re-enable this if you have a case where it works and improves vissual results Fixes: Timeout Fixes: 36234/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-6300306743885824 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/sbrdsp_fixed: Fix negation overflow in sbr_neg_odd_64_c()Michael Niedermayer2021-08-10
| | | | | | | | Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself Fixes: 35593/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5182217725804544 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/argo: Check for even dimensionsMichael Niedermayer2021-08-10
| | | | | | | | Fixes: reading over the end Fixes: 36346/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARGO_fuzzer-5366943107383296 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/nvenc: always set qp cr/cb offsetsTimo Rothenpieler2021-08-09
|
* aarch64: h264dsp: Fix indentation of some functions to match the restMartin Storsjö2021-08-08
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* aarch64: h264dsp: Remove unnecessary sign extensionsMartin Storsjö2021-08-08
| | | | | | | | | | These became unnecessary when the stride arguments were changed from int to ptrdiff_t in bc26fe89275c267d169b468356c82ee59874407d (0576ef466d8a631326d1d0a5ec2e4c4c81d25353) and d5d699ab6e6f8a8290748d107416fd5c19757a1b (aa844dc46f93182a63ec0b53267d19e7342c79b9). Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/mpeg12dec: report error when picture type is unknown and err_detect ↵Marton Balint2021-08-08
| | | | | | | | is EXPLODE Also split error message to error and warning. Signed-off-by: Marton Balint <cus@passwd.hu>
* avcodec/qsv: Remove unused ff_qsv_level_to_mfx()Andreas Rheinhardt2021-08-08
| | | | | | Unused since 00d0a4aa9eda8553113e51556123c46648a5f31b. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/h264dsp, h264idct: Fix lengths of array parametersAndreas Rheinhardt2021-08-08
| | | | | | Fixes many -Warray-parameter warnings from GCC 11. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacps: Fix length of array in function definitionAndreas Rheinhardt2021-08-08
| | | | | | | | | | hybrid2_re() has a parameter declared as "const INTFLOAT filter[8]", although the actual argument for said parameter only has seven elements; the code itself only uses seven elements, so change the parameter. Fixes a -Wstringop-overread warning with GCC 11. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/nvenc: make aware of SDK 11.1 driver requirementsTimo Rothenpieler2021-08-08
|
* avcodec/nvenc: add chroma qp offset supportRicardo Monteiro2021-08-08
| | | | Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
* avcodec/ass_split: Rename ff_ass_split_dialog2->ff_ass_split_dialogAndreas Rheinhardt2021-08-08
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ass_split: Remove unused ff_ass_split_dialogue()Andreas Rheinhardt2021-08-07
| | | | | | | Unused since 1f63665ca567fbc49fa80166d468a822c2999efa. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/acelp_vectors: Add missing bracketsAndreas Rheinhardt2021-08-07
| | | | | | | | | | | | | | Before 3793caa5e2d1d16ed45771574b2ffc932497cfcf the code was "if (...) do { ... } while (...);". After said commit this became "if (...) av_assert0(...); do { ... } while (...);", i.e. the loop is always executed. This commit changes the logic to what it was before said commit. Notice that the condition is always true in FATE, so no changes are necessary there. This fixes a -Wmisleading-indentation warning from GCC 11. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>