Commit Graph

116525 Commits

Author SHA1 Message Date
Michael Niedermayer
a2e5bcedb2 avformat/rdt: Check pkt_len
Fixes: CID1473553 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
60f46abaa5 avformat/mpeg: Check len in mpegps_probe()
Fixes: CID1473590 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
3071ac48f1 avformat/mov: Check requested_sample before using it
I am not sure the case described by coverity is possible
but its more robust checking the argument first

Fixes: CID1598441 Improper use of negative value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
d76c6b4301 avformat/mxfenc: resurrects the error print
Fixes: CID1524681 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
bb8a7d0c45 avdevice/dshow: Check ICaptureGraphBuilder2_SetFiltergraph() for failure
Fixes: CID1591939 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
72ab51368c avcodec/mfenc: check IMFSample_ConvertToContiguousBuffer() for failure
Fixes: CID1591911 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
f5fe36aac2 avcodec/vc1_loopfilter: Factor duplicate code in vc1_b_h_intfi_loop_filter()
Fixes: CID1435168

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
b8440779c8 avcodec/vvc/ctu: Remove dead ret check
Fixes: CID1560040 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
1dc7ce14fa avcodec/vvc/dec: Remove constant eos_at_start
Fixes: CID1560041 'Constant' variable guards dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
b103a4bdeb avformat/img2dec: assert no pipe on ts_from_file
Help coverity with CID1500302 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
697a7fb0da avcodec/cbs_jpeg: Try to move the read entity to one side in a test
The checked entity should be alone on one side of the check, this avoids
complex considerations of overflows.
This fixes a issue of bad style in our code and a coverity issue.

Fixes: CID1439654 Untrusted pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
17161e6ce7 fftools/ffplay: Check vulkan_params
Fixes: CID1550133 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
70fe32ad94 fftools/ffmpeg_sched: Remove dead assignments in sch_dec_send()
Fixes: CID1592383 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:29 +02:00
Michael Niedermayer
833c1cb303 fftools/ffmpeg_mux_init: Cleanup on error return in set_dispositions()
Fixes: CID1539099 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Michael Niedermayer
e2c45bf673 fftools/ffmpeg_mux: Remove unneeded initialization
Not sure this change makes sense, the code is more robust with ret set

Fixes: CID1559178 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Michael Niedermayer
0b90b642c9 fftools/ffmpeg_enc: Initialize Decoder
Fixes: CID1591439 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Michael Niedermayer
769f09ec2f fftools/ffmpeg_enc: Initialize fd
Fixes: CID1520677 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Michael Niedermayer
f60d425d9d fftools/ffmpeg_enc: simplify opaque_ref check
Found-while-revieweing: CID1520670 Dereference after null check

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Michael Niedermayer
a51314c48a avformat/mov: Check edit list for overflow
Fixes: 67492/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5778297231310848
Fixes: signed integer overflow: 2314885530818453536 + 7782220156096217088 cannot be represented in type 'long'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Mars Zuo
186a3c0b5c swresample/swresample: Rectify invalid function in the documentation
The function av_opt_set_channel_layout has been removed since
version 7.0, and the replacement is av_opt_set_chlayout.
The documentation needs to be updated accordingly.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Michael Niedermayer
6dc34f60cf fftools/ffmpeg: Check read() for failure
Fixes: CID1591932 Ignoring number of bytes read

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Michael Niedermayer
0749dbf837 avcodec/vvc/dec: Check ff_init_cabac_decoder() for failure
Fixes: signed integer overflow: 1107820800 + 1107820800 cannot be represented in type 'int'
Fixes: left shift of 1091059712 by 6 places cannot be represented in type 'int'
Fixes: 69910/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-5162839971528704

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nuo Mi <nuomi2021@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Tong Wu
1b58570366 avcodec/hw_base_encode: avoid getting FFHWBaseEncodeContext from avctx
This patch is to make FFHWBaseEncodeContext a standalone component
and avoid getting FFHWBaseEncodeContext from avctx->priv_data.
This patch also removes some unnecessary AVCodecContext arguments.

For receive_packet call, a small wrapper is introduced.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Tong Wu
47488b3d24 avcodec: add D3D12VA hardware HEVC encoder
This implementation is based on D3D12 Video Encoding Spec:
https://microsoft.github.io/DirectX-Specs/d3d/D3D12VideoEncoding.html

Sample command line for transcoding:
ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4
-c:v hevc_d3d12va output.mp4

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Tong Wu
76db085baf avutil/hwcontext_d3d12va: add Flags for resource creation
Flags field is added to support diffferent resource creation.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Tong Wu
0f93f303c8 avcodec/vaapi_encode: extract a free funtion to base layer
Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Tong Wu
75c88d19ec avcodec/vaapi_encode: extract a get_recon_format function to base layer
Surface size and block size parameters are also moved to base layer.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Tong Wu
b66ce76fb9 avcodec/vaapi_encode: extract set_output_property to base layer
Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Tong Wu
48c753e020 avcodec/vaapi_encode: extract gop configuration and two options to base layer
idr_interval and desired_b_depth are moved to HW_BASE_ENCODE_COMMON_OPTIONS.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Tong Wu
9838dc21ea avcodec/vaapi_encode: extract the init and close function to base layer
Related parameters such as device context, frame context are also moved
to base layer.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Tong Wu
ef42c4010d avcodec/vaapi_encode: move the dpb logic from VAAPI to base layer
Move receive_packet function to base. This requires adding *alloc,
*issue, *output, *free as hardware callbacks. HWBaseEncodePicture is
introduced as the base layer structure. The related parameters in
VAAPIEncodeContext are also extracted to HWBaseEncodeContext. Then DPB
management logic can be fully extracted to base layer as-is.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:28 +02:00
Tong Wu
659d53a39e avcodec/vaapi_encode: move pic->input_surface initialization to encode_alloc
When allocating the VAAPIEncodePicture, pic->input_surface can be
initialized right in the place. This movement simplifies the send_frame
logic and is the preparation for moving vaapi_encode_send_frame to the base layer.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:27 +02:00
Tong Wu
8e430cea68 avcodec/vaapi_encode: add picture type name to base
Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:27 +02:00
Tong Wu
ab06c9d158 avcodec/vaapi_encode: add async_depth to common options
Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:27 +02:00
Tong Wu
4511245d43 avcodec/hw_base_encode: add FF_HW_ prefix for two enums
PICTURE_TYPE_* and FLAG_* are added FF_HW_ prefix after being moved to
base layer.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:27 +02:00
Tong Wu
4a32c0f309 avcodec/vaapi_encode: introduce a base layer for vaapi encode
Since VAAPI and future D3D12VA implementation may share some common parameters,
a base layer encode context is introduced as vaapi context's base.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:27 +02:00
Anton Khirnov
79d884f246 lavc/hevcdec: improve check for PPS changing between slices
Compare actual PPS objects rather than just PPS ID, as the former might
change while the latter stays the same.

Reported-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:27 +02:00
Anton Khirnov
5a326f6f81 lavc/hevcdec: move export_stream_params() from set_sps() to hevc_frame_start()
The only other caller of set_sps() --- hevc_update_thread_context() ---
does not need to call export_stream_params(), since it only updates
AVCodecContext fields that have already been updated by generic code.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:26 +02:00
Anton Khirnov
d016eb0f6a lavc/hevcdec: do not pass a pixel format to set_sps()
It is merely copied to AVCodecContext.pix_fmt, which serves no useful
purpose. set_sps() is called from two places:
* when a new SPS becomes active - then the pixel format is
  overridden immediately after the set_sps() call by the result from
  ff_get_format();
* when a new SPS is propagated across frame threads - then the
  AVCodecContext value is already set to the same value by the generic
  code.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:26 +02:00
Anton Khirnov
9e5b34eb04 lavc/hevcdec: do not call export_stream_params_from_sei() in update_thread_context()
It is redundant, since it only sets AVCodecContext fields that are
already copied by the generic code.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:26 +02:00
Anton Khirnov
f62ac99a8d lavc/hevcdec: call export_stream_params_from_sei() before ff_get_buffer()
So that correct values of color_trc are set on the allocated frame.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:26 +02:00
Jiasheng Jiang
034898d2bd avcodec/mpegvideo_enc: Add check for av_packet_new_side_data()
Add check for av_packet_new_side_data() to avoid null pointer
dereference if allocation fails.

Fixes: bdc1220eeb ("h263enc: Add an option for outputting info about MBs as side data")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@outlook.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-03 08:46:26 +02:00
Paul B Mahol
5126bd0409 remove pointless ;; 2024-07-03 08:46:26 +02:00
Paul B Mahol
dbf20122a9 avfilter/af_volumedetect: rewrite using template 2024-07-02 17:16:29 +02:00
Paul B Mahol
71cb41edf9 avfilter/vsrc_perlin: simplify pixel format setup 2024-07-02 10:11:28 +02:00
Marth64
197c0037ca avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range
Chapters and duration are calculated together in dvdvideo demuxer.
Previous chapter calculation logic treated extraction of 1 chapter
using chapter_start and chapter_end switches incorrectly, returning
the duration of the entire title instead of just the segment.

Fix the logic so that it calculates and returns the duration of the
chapter segment instead. Additionally, validate that chapter_end
exceeds chapter_start (except in the special case of 0).

Signed-off-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-02 10:05:06 +02:00
Marth64
00d55b54f2 avformat/dvdvideodec: Do not EOF on WAIT events
A DVDNAV_WAIT event by itself should not warrant an
EOF when navigating the program stream. Some discs
have WAIT events in the middle of a title, causing
playback to end prematurely prior to this fix.

Signed-off-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-02 10:05:06 +02:00
Stefano Sabatini
217138068c lavfi: add Perlin noise generator
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-02 10:05:06 +02:00
Josh Allmann
fbab7a9694 avcodec/nvenc: fix segfault in intra-only mode
In intra-only mode, frameIntervalP is 0, which means the frame
data array is smaller than the number of surfaces.

Together with using the wrong size on deallocation of the
frame_data_array, this lead to a crash.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2024-07-02 10:05:06 +02:00
Paul B Mahol
4470427bf3 avformat: add MotionCam RAW demuxer 2024-07-02 10:05:06 +02:00