summaryrefslogtreecommitdiff
path: root/libavcodec
Commit message (Collapse)AuthorAge
* avcodec/vc1dec: return value check for init_get_bitsmaryam ebrahimzadeh2021-08-26
| | | | | | As the second argument for init_get_bits(avctx and buf) can be crafted, a return value check for this function call is necessary, so replace init_get_bits with init_get_bits8 and add return value check.
* avcodec/wmadec: handle run_level_decode errorStéphane Cerveau2021-08-26
| | | | | | | | | Consider data as invalid if ff_wma_run_level_decode gets out with an error. It avoids an unpleasant sound distorsion. See http://trac.ffmpeg.org/ticket/9358
* avcodec/wma: Return specific error codeOlivier Crête2021-08-26
| | | | | | | This way, the calling function can just forward it instead of making it up. Signed-off-by: Olivier Crête <olivier.crete@collabora.com>
* avcodec/vp6: return value check for init_get_bitsmaryam ebrahimzadeh2021-08-26
| | | | | | | | As the second argument for init_get_bits(buf) can be crafted, a return value check for this function call is necessary. Also replace init_get_bits with init_get_bits8. Signed-off-by: Peter Ross <pross@xvid.org>
* avcodec/bsf: Avoid allocation for AVBSFInternalAndreas Rheinhardt2021-08-25
| | | | | | | | | | Do this by allocating AVBSFContext together with the data that is currently in AVBSFInternal; or rather: Put AVBSFContext at the beginning of a new structure called FFBSFContext (which encompasses more than just the internal fields and is a proper context in its own right, hence the name) and remove the AVBSFInternal altogether. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec: Reorder elements to make AVCodec smallerAndreas Rheinhardt2021-08-25
| | | | | | Reordering max_lowres is an ABI break. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/h264_slice: don't allocate film grain buffers when using hwaccelJames Almer2021-08-25
| | | | | | Fixes regression since 66845cffc3bbb17f91294d15cd6f57f3df3bce97 Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/dnxhddec: ignore second flag for encoded fieldPaul B Mahol2021-08-25
| | | | | | And instead use previous field flag. Fixes decoding files produced by non-compliant encoders.
* arm: hevc_qpel: Fix the assembly to work with non-multiple of 8 widthsMartin Storsjö2021-08-25
| | | | | | | | | | | | | | | | | | | | This unbreaks the fate-checkasm-hevc_pel test on arm targets. The assembly assumed that the width passed to the DSP functions is a multiple of 8, while the checkasm test used other widths too. This wasn't noticed before, because the hevc_pel checkasm tests (that were added in 9c513edb7999a35ddcc6e3a8d984a96c8fb492a3 in January) weren't run as part of fate until in b492cacffd36ad4cb251ba1f13ac398318ee639a in August. As this hasn't been an issue in practice with actual full decoding tests, it seems like the actual decoder doesn't call these functions with such widths. Therefore, we could alternatively fix the test to only test things that the real decoder does, and this modification could be reverted. Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/jpeg2000_parser: Fix skipping of JP2 info markers by correctly ↵Shaun Simpson2021-08-25
| | | | | | reading marker size Signed-off-by: Shaun Simpson <shauns2029@gmail.com>
* avcodec/jpeg2000_parser: Fix parsing of tile-part headerShaun Simpson2021-08-25
| | | | | | And frames where the end of frame marker is at the end of the buffer. Signed-off-by: Shaun Simpson <shauns2029@gmail.com>
* avcodec/h264dec: fix possible out-of-bounds array accessNiklas Haas2021-08-25
| | | | | | | | | | | | | | If slice_type is > 9, the access to ff_h264_golomb_to_pict_type is out-of-bounds. Fix this by simply setting the slice_type to 0 in this case. This is completely inconsequential because the value is only being used to being used as an offset in the calculation of the film grain seed value, a corruption of which is practically invisible. Fixes coverity ticket #1490802 Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h264_slice: signal the presence of Film Grain in the decoder contextJames Almer2021-08-24
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1: signal the presence of Film Grain in the decoder contextJames Almer2021-08-24
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libdav1d: signal the presence of Film Grain in the decoder contextJames Almer2021-08-24
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: add a Film Grain codec property flagJames Almer2021-08-24
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/pthread_frame: also keep AVCodecContext.properties in sync between ↵James Almer2021-08-24
| | | | | | | | | threads Some frame threaded decoders set it, but this information never reached the caller in frame threading scenarios. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h264dec: apply H.274 film grainNiklas Haas2021-08-24
| | | | | | | | | | | | | | | | | | | | | | | Because we need access to ref frames without film grain applied, we have to add an extra AVFrame to H264Picture to avoid messing with the original. This requires some amount of overhead to make the reference moves work out, but it allows us to benefit from frame multithreading for film grain application "for free". Unfortunately, this approach requires twice as much RAM to be constantly allocated for ref frames, due to the need for an extra buffer per H264Picture. In theory, we could get away with freeing up this memory as soon as it's no longer needed (since ref frames do not need film grain buffers any longer), but trying to call ff_thread_release_buffer() from output_frame() conflicts with possible later accesses to that same frame and I'm not sure how to synchronize that well. Tested on all three cases of (no fg), (fg present but exported) and (fg present and not exported), with and without threading. 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/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>