ffmpeg.git
2 months agolibavfilter/x86/vf_gblur: correct the order of loop step
Wu Jianhua [Thu, 16 Sep 2021 07:34:08 +0000 (15:34 +0800)]
libavfilter/x86/vf_gblur: correct the order of loop step

The problem was caused by if the width of the processed block
minus 1 is a multiple of the aligned number the instruction
jle .bscale_scalar would skip the Optimized Loop Step, which
will lead to an incorrect sampling when specifying steps more
than 1. Move the Optimized Loop Step after .bscale_scalar to
ensure the loop step is enabled.

Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
2 months agolibavfilter/x86/vf_gblur: fixed the fate-test failed on MacOS
Wu Jianhua [Thu, 16 Sep 2021 07:34:07 +0000 (15:34 +0800)]
libavfilter/x86/vf_gblur: fixed the fate-test failed on MacOS

Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
2 months agoavfilter/vf_zscale: fix output color_range discrepancy
Pavel Koshevoy [Fri, 17 Sep 2021 02:09:13 +0000 (20:09 -0600)]
avfilter/vf_zscale: fix output color_range discrepancy

This filter chain was supposed to convert from narrow range
to full range yuv444p, but didn't:

buffer=width=1280:height=720:pix_fmt=yuv444p:frame_rate=25/1:\
time_base=1/25:sar=1/1,zscale=min=709:rin=limited:pin=709:\
tin=709:t=linear,format=gbrpf32le,zscale=tin=linear:p=709:m=709:\
r=full:t=709,format=pix_fmts=yuv444p,buffersink

2 months agoavcodec/mpeg12dec: Do not put mpeg_f_code into an invalid state on error return
Michael Niedermayer [Tue, 31 Aug 2021 18:15:09 +0000 (20:15 +0200)]
avcodec/mpeg12dec: Do not put mpeg_f_code into an invalid state on error return

Fixes: invalid shift
Fixes: 37018/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG2VIDEO_fuzzer-5290280902328320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/mpegvideo_enc: Limit bitrate tolerance to the representable
Michael Niedermayer [Sun, 30 May 2021 16:38:23 +0000 (18:38 +0200)]
avcodec/mpegvideo_enc: Limit bitrate tolerance to the representable

Fixes: error: 1.66789e+11 is outside the range of representable values of type 'int'
Fixes: Ticket8201

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/wmaprodec: Check that the EOF frame was allocated before decoding into it
Michael Niedermayer [Thu, 16 Sep 2021 22:21:25 +0000 (00:21 +0200)]
avcodec/wmaprodec: Check that the EOF frame was allocated before decoding into it

Fixes: NULL pointer dereference
Fixes: 38125/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA1_fuzzer-5151909422432256

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavutil/buffer: constify some function parameters
James Almer [Fri, 17 Sep 2021 03:06:45 +0000 (00:06 -0300)]
avutil/buffer: constify some function parameters

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavfilter/vf_coreimage: Simplify query_formats
Andreas Rheinhardt [Sun, 15 Aug 2021 05:43:21 +0000 (07:43 +0200)]
avfilter/vf_coreimage: Simplify query_formats

Using ff_set_common_formats_from_list() avoids using different functions
depending upon how many inputs the filter has.

Reviewed-by: Thilo Borgmann <thilo.borgmann@mail.de>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavfilter/avfilter: Actually error out on init error
Andreas Rheinhardt [Wed, 15 Sep 2021 03:13:11 +0000 (05:13 +0200)]
avfilter/avfilter: Actually error out on init error

Currently an error from init could be overwritten by successfully
setting the enable expression.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agolibavdevice/avfoundation.m: fix potential unreleased lock issue
Chengfeng Ye [Thu, 26 Aug 2021 14:40:46 +0000 (07:40 -0700)]
libavdevice/avfoundation.m: fix potential unreleased lock issue

The problem here is that the lock ctx->frame_lock will become
an unreleased lock if the program returns at patched lines.

link: https://trac.ffmpeg.org/ticket/9386\#ticket
Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
2 months agolibavdevice/avfoundation.m: fix protential unreleased lock issue
Chengfeng Ye [Thu, 26 Aug 2021 14:40:24 +0000 (07:40 -0700)]
libavdevice/avfoundation.m: fix protential unreleased lock issue

The problem here is that the lock ctx->frame_lock will
become an unreleased lock if the program returns at
line 697, line 735 and line744.

link: https://trac.ffmpeg.org/ticket/9385\#ticket
Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
2 months agoavcodec/elbg: Remove avoidable buffer
Andreas Rheinhardt [Thu, 16 Sep 2021 23:35:48 +0000 (01:35 +0200)]
avcodec/elbg: Remove avoidable buffer

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/utils: Use st for AVStream variable in avpriv_set_pts_info
Andreas Rheinhardt [Thu, 9 Sep 2021 15:08:49 +0000 (17:08 +0200)]
avformat/utils: Use st for AVStream variable in avpriv_set_pts_info

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/demux: Don't free inexistent ID3v2 metadata
Andreas Rheinhardt [Wed, 8 Sep 2021 20:35:43 +0000 (22:35 +0200)]
avformat/demux: Don't free inexistent ID3v2 metadata

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/utils: Move demuxing code out into a new file
Andreas Rheinhardt [Fri, 27 Aug 2021 07:24:10 +0000 (09:24 +0200)]
avformat/utils: Move demuxing code out into a new file

libavformat/utils.c has over 4800 lines and is supposed to contain
"various utility functions for use within FFmpeg". In reality it
contains all that and the whole demuxing core of libavformat.
This is especially bad, because said file includes the FFMPEG_VERSION
(the git commit sha) so that it is rebuilt whenever the commit HEAD
points to changes. Therefore this commit makes it smaller by moving
the demuxing code out to a new file, demux.c (in analogy to mux.c
for the muxing code).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/utils: Move seeking code out into a new file
Andreas Rheinhardt [Thu, 26 Aug 2021 21:41:01 +0000 (23:41 +0200)]
avformat/utils: Move seeking code out into a new file

libavformat/utils.c has over 5500 lines and is supposed to contain
"various utility functions for use within FFmpeg". In reality it
contains all that and the whole demuxing+seeking core of libavformat.
This is especially bad, because said file includes the FFMPEG_VERSION
(the git commit sha) so that it is rebuilt whenever the commit HEAD
points to changes. Therefore this commit starts making it smaller
by factoring the seeking code out.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/utils: Reindentation
Andreas Rheinhardt [Thu, 26 Aug 2021 14:41:50 +0000 (16:41 +0200)]
avformat/utils: Reindentation

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat: Avoid allocation for AVStreamInternal
Andreas Rheinhardt [Tue, 24 Aug 2021 17:41:16 +0000 (19:41 +0200)]
avformat: Avoid allocation for AVStreamInternal

Do this by allocating AVStream together with the data that is
currently in AVStreamInternal; or rather: Put AVStream at the
beginning of a new structure called FFStream (which encompasses
more than just the internal fields and is a proper context in its own
right, hence the name) and remove AVStreamInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/mux, utils: Use dedicated pointer for AVStreamInternal
Andreas Rheinhardt [Tue, 24 Aug 2021 17:07:51 +0000 (19:07 +0200)]
avformat/mux, utils: Use dedicated pointer for AVStreamInternal

This gets rid of ugly "->internal" and is in preparation for removing
AVStreamInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat: Avoid allocation for AVFormatInternal
Andreas Rheinhardt [Tue, 24 Aug 2021 12:58:07 +0000 (14:58 +0200)]
avformat: Avoid allocation for AVFormatInternal

Do this by allocating AVFormatContext together with the data that is
currently in AVFormatInternal; or rather: Put AVFormatContext at the
beginning of a new structure called FFFormatContext (which encompasses
more than just the internal fields and is a proper context in its own
right, hence the name) and remove AVFormatInternal altogether.

The biggest simplifications occured in avformat_alloc_context(), where
one can now simply call avformat_free_context() in case of errors.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/mux, mxfenc, utils: Use dedicated pointer for AVFormatInternal
Andreas Rheinhardt [Tue, 24 Aug 2021 11:37:28 +0000 (13:37 +0200)]
avformat/mux, mxfenc, utils: Use dedicated pointer for AVFormatInternal

This gets rid of ugly "->internal" and is in preparation for removing
AVFormatInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/asfenc, mux, utils: Use smaller scope for variables
Andreas Rheinhardt [Tue, 24 Aug 2021 15:47:04 +0000 (17:47 +0200)]
avformat/asfenc, mux, utils: Use smaller scope for variables

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/mp3dec: Simplify checking for no-metadata
Andreas Rheinhardt [Thu, 9 Sep 2021 10:54:30 +0000 (12:54 +0200)]
avformat/mp3dec: Simplify checking for no-metadata

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/mp3dec: Avoid calling avio_tell() multiple times
Andreas Rheinhardt [Thu, 9 Sep 2021 10:50:42 +0000 (12:50 +0200)]
avformat/mp3dec: Avoid calling avio_tell() multiple times

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agodoc/decoders: mention that some libdav1d options are deprecated
James Almer [Thu, 16 Sep 2021 23:43:26 +0000 (20:43 -0300)]
doc/decoders: mention that some libdav1d options are deprecated

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavformat/mvdec: Don't signal success on parse_audio_var() error
James Almer [Thu, 16 Sep 2021 19:34:03 +0000 (16:34 -0300)]
avformat/mvdec: Don't signal success on parse_audio_var() error

Propagate the error it returned instead.

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavcodec/apedec: Fix integer overflow in intermediate
Michael Niedermayer [Wed, 15 Sep 2021 20:00:47 +0000 (22:00 +0200)]
avcodec/apedec: Fix integer overflow in intermediate

Fixes: signed integer overflow: 559334865 * 4 cannot be represented in type 'int'
Fixes: 37929/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-6751932295806976

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/mvdec: Do not set invalid sample rate
Michael Niedermayer [Wed, 15 Sep 2021 20:00:46 +0000 (22:00 +0200)]
avformat/mvdec: Do not set invalid sample rate

Fixes: signed integer overflow: -682581959642593728 * 16 cannot be represented in type 'long'
Fixes: 37883/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5311691517198336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/sbgdec: Check for t0 overflow in expand_tseq()
Michael Niedermayer [Wed, 15 Sep 2021 20:00:44 +0000 (22:00 +0200)]
avformat/sbgdec: Check for t0 overflow in expand_tseq()

Fixes: signed integer overflow: 4611686025627387904 + 4611686025627387904 cannot be represented in type 'long'
Fixes: 35489/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-4862678601433088

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/mjpegdec: export display matrix frame side data when available
James Almer [Wed, 8 Sep 2021 18:34:27 +0000 (15:34 -0300)]
avcodec/mjpegdec: export display matrix frame side data when available

Finishes fixing ticket #6945.

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoffmpeg: take into account image flipping in the display matrix
James Almer [Wed, 8 Sep 2021 18:34:26 +0000 (15:34 -0300)]
ffmpeg: take into account image flipping in the display matrix

This covers only standard rotations.
Fixes part of ticket #6945.

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoffmpeg: use display matrix frame side data for autorotation
James Almer [Wed, 8 Sep 2021 18:34:25 +0000 (15:34 -0300)]
ffmpeg: use display matrix frame side data for autorotation

And give it priority over stream side data when present.
Fixes part of ticket #6945.

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agocmdutils: round rotation value to nearest integer
James Almer [Wed, 8 Sep 2021 18:34:24 +0000 (15:34 -0300)]
cmdutils: round rotation value to nearest integer

As recommended by the doxy for av_display_rotation_get().

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agotools/dvd2concat: generate VOBSUB extradata
Nicolas George [Tue, 31 Aug 2021 17:37:09 +0000 (19:37 +0200)]
tools/dvd2concat: generate VOBSUB extradata

The extradata contains the frame size of the subtitles images
and the palette.

2 months agolavf/concatdec: add stream_extradata directive
Nicolas George [Tue, 31 Aug 2021 17:36:35 +0000 (19:36 +0200)]
lavf/concatdec: add stream_extradata directive

2 months agotools/dvd2concat: add support for chapters
Nicolas George [Tue, 31 Aug 2021 13:58:02 +0000 (15:58 +0200)]
tools/dvd2concat: add support for chapters

2 months agolavf/concat: add support for chapters
Nicolas George [Tue, 31 Aug 2021 13:57:48 +0000 (15:57 +0200)]
lavf/concat: add support for chapters

2 months agotools/dvd2concat: specify stream_codec for subtitles
Nicolas George [Tue, 31 Aug 2021 12:31:16 +0000 (14:31 +0200)]
tools/dvd2concat: specify stream_codec for subtitles

Avoid requiring a huge probe size and analyze duration.

2 months agolavf/concatdec: add stream_codec directive
Nicolas George [Tue, 31 Aug 2021 12:30:28 +0000 (14:30 +0200)]
lavf/concatdec: add stream_codec directive

2 months agotests/concat-demuxer: add stream_meta test
Nicolas George [Tue, 31 Aug 2021 12:19:18 +0000 (14:19 +0200)]
tests/concat-demuxer: add stream_meta test

2 months agotools/dvd2concat: include language metadata
Nicolas George [Tue, 31 Aug 2021 12:10:07 +0000 (14:10 +0200)]
tools/dvd2concat: include language metadata

2 months agolavf/concatdec: support stream metadata
Nicolas George [Tue, 31 Aug 2021 12:09:57 +0000 (14:09 +0200)]
lavf/concatdec: support stream metadata

2 months agolavf/concat: deprecate file_packet_metadata
Nicolas George [Tue, 31 Aug 2021 11:48:31 +0000 (13:48 +0200)]
lavf/concat: deprecate file_packet_metadata

2 months agolavf/concat: add file_packet_meta directive
Nicolas George [Tue, 31 Aug 2021 17:56:24 +0000 (19:56 +0200)]
lavf/concat: add file_packet_meta directive

Same as file_packet_metadata without the double parsing.

2 months agolavf/concat: refactor parsing
Nicolas George [Tue, 31 Aug 2021 11:30:01 +0000 (13:30 +0200)]
lavf/concat: refactor parsing

2 months agoavcodec/elbg: Increase some fields to 64bit
Michael Niedermayer [Sun, 6 Jun 2021 20:42:08 +0000 (22:42 +0200)]
avcodec/elbg: Increase some fields to 64bit

Fixes: Ticket8312
Fixes: Ticket8321

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/rmdec: Use 64bit for intermediate for DEINT_ID_INT4
Michael Niedermayer [Thu, 15 Apr 2021 20:44:19 +0000 (22:44 +0200)]
avformat/rmdec: Use 64bit for intermediate for DEINT_ID_INT4

Fixes: runtime error: signed integer overflow: 65312 * 65535 cannot be represented in type 'int'
Fixes: 32832/clusterfuzz-testcase-minimized-ffmpeg_dem_RM_fuzzer-4817710040088576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/sbgdec: Check opt_duration and start for overflow
Michael Niedermayer [Thu, 24 Jun 2021 16:57:51 +0000 (18:57 +0200)]
avformat/sbgdec: Check opt_duration and start for overflow

Fixes: signed integer overflow: 2788626175500000000 + 7118941284000000000 cannot be represented in type 'long'
Fixes: 35215/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6123272247836672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agolibavfilter/vf_vpp_qsv: fix uninitialized variable problem
Wenbin Chen [Wed, 15 Sep 2021 05:15:18 +0000 (13:15 +0800)]
libavfilter/vf_vpp_qsv: fix uninitialized variable problem

This two variables may be used below with uninitialized value.
Now fix them.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com>
Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavfilter/frei0r: use win32dlfcn wrapper
Timo Rothenpieler [Sun, 5 Sep 2021 14:34:37 +0000 (16:34 +0200)]
avfilter/frei0r: use win32dlfcn wrapper

2 months agoconfigure: account for openssl3 license change
Timo Rothenpieler [Tue, 7 Sep 2021 17:35:31 +0000 (19:35 +0200)]
configure: account for openssl3 license change

2 months agoavcodec/dxva2_av1: fix superres_denom parameter
Tong Wu [Wed, 8 Sep 2021 05:19:50 +0000 (13:19 +0800)]
avcodec/dxva2_av1: fix superres_denom parameter

Defined in spec 5.9.8. When superres is enabled, SuperresDenom equals
"coded_denom + SUPERRES_DENOM_MIN" instead of coded_denom.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com>
2 months agofftools/ffprobe: Don't access AVProgram.(start|end)_time
Andreas Rheinhardt [Thu, 9 Sep 2021 15:49:43 +0000 (17:49 +0200)]
fftools/ffprobe: Don't access AVProgram.(start|end)_time

These are internal fields.

Reviewed-by: Tobias Rapp <t.rapp@noa-archive.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavcodec/h264_picture: wait for the second slice to apply film grain on interlaced...
James Almer [Tue, 14 Sep 2021 12:47:32 +0000 (09:47 -0300)]
avcodec/h264_picture: wait for the second slice to apply film grain on interlaced content

Fixes: Assertion failure
Fixes: clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-6581961297100800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavcodec/exr: Fix undefined integer multiplication
Michael Niedermayer [Mon, 13 Sep 2021 22:14:56 +0000 (00:14 +0200)]
avcodec/exr: Fix undefined integer multiplication

Fixes: signed integer overflow: 7020950083487072256 * 2 cannot be represented in type 'long long'
Fixes: 37523/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5133634955771904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/mov: Check for duplicate clli
Michael Niedermayer [Mon, 13 Sep 2021 21:04:13 +0000 (23:04 +0200)]
avformat/mov: Check for duplicate clli

Fixes: memleak
Fixes: 35261/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4869656287510528

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agotools/target_dec_fuzzer: Adjust threshold for WMV3
Michael Niedermayer [Mon, 13 Sep 2021 22:26:12 +0000 (00:26 +0200)]
tools/target_dec_fuzzer: Adjust threshold for WMV3

Fixes: Timeout clearing images
Fixes: 37726/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3_fuzzer-4604669570187264

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/jpeg2000_parser: Check state!=0
Michael Niedermayer [Mon, 13 Sep 2021 21:53:23 +0000 (23:53 +0200)]
avcodec/jpeg2000_parser: Check state!=0

Fixes: out of array read
Fixes: 37664/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5893420460146688

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/utils: Ignore negative duration in codec_info_duration computation
Michael Niedermayer [Sat, 3 Jul 2021 21:02:16 +0000 (23:02 +0200)]
avformat/utils: Ignore negative duration in codec_info_duration computation

Fixes: signed integer overflow: -5994697211974418462 + -3255307777713450286 cannot be represented in type 'long'
Fixes: 35332/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-5868035117285376

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/bsf: Unref the packet when flushing
Andreas Rheinhardt [Mon, 6 Sep 2021 20:31:38 +0000 (22:31 +0200)]
avcodec/bsf: Unref the packet when flushing

The documentation does not require the packet to be blank in this case
(i.e. it can now contain opaque_ref), but it does contain that the
contents will be reset upon success.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavcodec/bsf: Use null-bsf for passthrough when available
Andreas Rheinhardt [Mon, 6 Sep 2021 17:39:19 +0000 (19:39 +0200)]
avcodec/bsf: Use null-bsf for passthrough when available

When an empty list bsf is used for passthrough, there is a check
for every packet in bsf_list_filter() before ff_bsf_get_packet_ref()
is called. Directly using the null bsf avoids that.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agotools/target_bsf_fuzzer: Make it const-correct
Andreas Rheinhardt [Mon, 6 Sep 2021 17:38:09 +0000 (19:38 +0200)]
tools/target_bsf_fuzzer: Make it const-correct

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoconfigure: Remove null_bsf dependency
Andreas Rheinhardt [Mon, 6 Sep 2021 15:04:31 +0000 (17:04 +0200)]
configure: Remove null_bsf dependency

Unneeded since c96904f525afcaba756a5ce8511a3ee1aa9fd2d7
(a bsf-list with zero bsfs is used since that commit).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavformat/jacosubdec: Check for min in t overflow in get_shift()
Michael Niedermayer [Thu, 3 Jun 2021 20:26:41 +0000 (22:26 +0200)]
avformat/jacosubdec: Check for min in t overflow in get_shift()

Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 34651/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-5157941012463616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/mxfdec: check channel number in mxf_get_d10_aes3_packet()
Michael Niedermayer [Sun, 5 Sep 2021 19:24:15 +0000 (21:24 +0200)]
avformat/mxfdec: check channel number in mxf_get_d10_aes3_packet()

Fixes: Out of array access
Fixes: 37030/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5387719147651072

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavfilter/internal: Add AVFILTER_DEFINE_CLASS_EXT
Andreas Rheinhardt [Fri, 10 Sep 2021 18:20:08 +0000 (20:20 +0200)]
avfilter/internal: Add AVFILTER_DEFINE_CLASS_EXT

This macro will allow to share options between AVClasses without
having to redefine the option name (as is currently done) and will
also allow to share the AVClasses itself (which is possible now
that AVClass.child_class_next is gone).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavfilter/vf_maskedminmax: Simplify init
Andreas Rheinhardt [Fri, 10 Sep 2021 17:44:26 +0000 (19:44 +0200)]
avfilter/vf_maskedminmax: Simplify init

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavfilter/avfilter: Remove unused count
Andreas Rheinhardt [Fri, 10 Sep 2021 23:32:05 +0000 (01:32 +0200)]
avfilter/avfilter: Remove unused count

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavfilter/af_speechnorm: improve EOF timestamp precision
Paul B Mahol [Sun, 12 Sep 2021 21:44:03 +0000 (23:44 +0200)]
avfilter/af_speechnorm: improve EOF timestamp precision

2 months agoavfilter/af_dynaudnorm: improve EOF timestamp precision
Paul B Mahol [Sun, 12 Sep 2021 21:41:49 +0000 (23:41 +0200)]
avfilter/af_dynaudnorm: improve EOF timestamp precision

2 months agoavcodec/wmadec: fix WMA gapless playback
bnnm [Fri, 5 Oct 2018 17:39:26 +0000 (19:39 +0200)]
avcodec/wmadec: fix WMA gapless playback

Fixes trac issue #7473.

Removes encoder delay (skip samples) and writes remaining frame samples after EOF to get correct sample count.

Output is now accurate vs players that use Microsoft's codecs (Windows Media Format Runtime).

Tested vs encode>decode WMAv2 with MS's codecs and most sample rate/bit rate/channel/mode combinations in ASF/XWMA.
WMAv1 appears to use the same delay, from FFmpeg samples.

Signed-off-by: bnnm <bananaman255@gmail.com>
2 months agoavformat/dv: always set audio packet duration
Paul B Mahol [Mon, 6 Sep 2021 17:48:54 +0000 (19:48 +0200)]
avformat/dv: always set audio packet duration

If audio packet is present in DV stream it have duration of 1 in DV timebase units.

2 months agoffmpeg_hw: make hardware selection for filters more user friendly
Haihao Xiang [Tue, 29 Jun 2021 01:45:38 +0000 (09:45 +0800)]
ffmpeg_hw: make hardware selection for filters more user friendly

When a device is derived from a source device, there are at least 2
devices, and usually the derived device is the expected device, so let's
pick the last device if user doesn't specify the filter device with
filter_hw_device option

After applying this patch, the command below can work:

$> ffmpeg -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device
qsv=hw@va -f lavfi -i yuvtestsrc  -vf
format=nv12,hwupload=extra_hw_frames=64 -c:v h264_qsv -y out.h264

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavfilter/vf_extractplanes: fix regression
Paul B Mahol [Sun, 12 Sep 2021 15:03:38 +0000 (17:03 +0200)]
avfilter/vf_extractplanes: fix regression

Report & solution provided by Andreas Rheinhardt.

2 months agoavcodec/h274: trim unnecessarily large array
Niklas Haas [Sun, 5 Sep 2021 11:02:57 +0000 (13:02 +0200)]
avcodec/h274: trim unnecessarily large array

We only ever read to idx+3, so 256 values are overkill.

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavcodec/h274: don't read from uninitialized array members
Niklas Haas [Sun, 12 Sep 2021 13:14:31 +0000 (15:14 +0200)]
avcodec/h274: don't read from uninitialized array members

This bug flew under the radar because, in practice, these values are
0-initialized for the first invocation. But for subsequent invocations
(with different h/v values), reading from the uninitialized parts of
`out` is undefined behavior.

Avoid this by simply adjusting the iteration range of the following
loops. Has the added benefit of being a minor speedup.

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavfilter/vf_xfade: check default switch case
Paul B Mahol [Sun, 12 Sep 2021 13:04:31 +0000 (15:04 +0200)]
avfilter/vf_xfade: check default switch case

2 months agoavfilter/vf_xfade: add zoomin transition
Paul B Mahol [Sun, 12 Sep 2021 12:56:56 +0000 (14:56 +0200)]
avfilter/vf_xfade: add zoomin transition

2 months agoavfilter/vf_extractplanes: stop marking alphaextract filter as dynamic outputs
Paul B Mahol [Sun, 12 Sep 2021 11:48:00 +0000 (13:48 +0200)]
avfilter/vf_extractplanes: stop marking alphaextract filter as dynamic outputs

2 months agoavfilter/af_afftfilt: reindent after last commit
Paul B Mahol [Sun, 12 Sep 2021 11:25:22 +0000 (13:25 +0200)]
avfilter/af_afftfilt: reindent after last commit

2 months agoavfilter/af_afftfilt: add timeline support
Paul B Mahol [Sun, 12 Sep 2021 11:24:49 +0000 (13:24 +0200)]
avfilter/af_afftfilt: add timeline support

2 months agoavfilter/af_asoftclip: rewrite oversampling
Paul B Mahol [Sat, 11 Sep 2021 22:31:13 +0000 (00:31 +0200)]
avfilter/af_asoftclip: rewrite oversampling

Fixes most aliasing issues.

2 months agoavfilter/vf_fieldmatch: initialize dst pointer to silence warning
Paul B Mahol [Sat, 11 Sep 2021 20:13:21 +0000 (22:13 +0200)]
avfilter/vf_fieldmatch: initialize dst pointer to silence warning

2 months agoavfilter/f_segment: silence compiler warning
Paul B Mahol [Sat, 11 Sep 2021 20:11:46 +0000 (22:11 +0200)]
avfilter/f_segment: silence compiler warning

2 months agoavfilter/f_loop: initialize ret to silence compiler warning
Paul B Mahol [Sat, 11 Sep 2021 20:08:32 +0000 (22:08 +0200)]
avfilter/f_loop: initialize ret to silence compiler warning

2 months agoavfilter/af_arnndn: initialize ret to silence compiler warning
Paul B Mahol [Sat, 11 Sep 2021 20:02:42 +0000 (22:02 +0200)]
avfilter/af_arnndn: initialize ret to silence compiler warning

2 months agoavfilter/af_afftdn: move i initialization to silence warning
Paul B Mahol [Sat, 11 Sep 2021 19:59:24 +0000 (21:59 +0200)]
avfilter/af_afftdn: move i initialization to silence warning

2 months agoavfilter/af_apsyclip: fix mixed declarations and code
Paul B Mahol [Sat, 11 Sep 2021 19:45:08 +0000 (21:45 +0200)]
avfilter/af_apsyclip: fix mixed declarations and code

2 months agoavfilter: add audio psychoacoustic clipper
Paul B Mahol [Sun, 18 Jul 2021 08:20:33 +0000 (10:20 +0200)]
avfilter: add audio psychoacoustic clipper

2 months agoavfilter/af_astats: add entropy stat
Paul B Mahol [Sat, 11 Sep 2021 08:45:09 +0000 (10:45 +0200)]
avfilter/af_astats: add entropy stat

2 months agoavfilter/vf_convolution: add scharr operator
Paul B Mahol [Fri, 10 Sep 2021 15:52:23 +0000 (17:52 +0200)]
avfilter/vf_convolution: add scharr operator

2 months agofate: fix silenceremove test
Paul B Mahol [Thu, 9 Sep 2021 19:09:57 +0000 (21:09 +0200)]
fate: fix silenceremove test

2 months agoavfilter/af_silenceremove: fix regression in output frame pts
Paul B Mahol [Thu, 9 Sep 2021 18:20:13 +0000 (20:20 +0200)]
avfilter/af_silenceremove: fix regression in output frame pts

2 months agoavcodec/qsv_enc: do not reuse enc_ctrl from previous frames
Xu Guangxin [Wed, 6 Jan 2021 03:12:34 +0000 (11:12 +0800)]
avcodec/qsv_enc: do not reuse enc_ctrl from previous frames

fixes #8857

If we do not clear the enc_ctrl, we will reuse previous frames' data like FrameType.

Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavcodec/mlpenc: Fix mixed declarations and code warning
Andreas Rheinhardt [Wed, 8 Sep 2021 22:00:51 +0000 (00:00 +0200)]
avcodec/mlpenc: Fix mixed declarations and code warning

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2 months agoavcodec/siren: decode_vector: remove unused parameter
Peter Ross [Sat, 4 Sep 2021 10:27:09 +0000 (20:27 +1000)]
avcodec/siren: decode_vector: remove unused parameter

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Peter Ross <pross@xvid.org>
2 months agoavcodec/siren: replace magic numbers with macro value
Peter Ross [Sat, 4 Sep 2021 10:24:39 +0000 (20:24 +1000)]
avcodec/siren: replace magic numbers with macro value

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Peter Ross <pross@xvid.org>
3 months agoavcodec/libvpxenc: Apply codec options to alpha codec context
Adam Chelminski [Fri, 3 Sep 2021 08:32:06 +0000 (10:32 +0200)]
avcodec/libvpxenc: Apply codec options to alpha codec context

When encoding yuva420 (alpha) frames, the vpx encoder uses a second
vpx_codec_ctx to encode the alpha stream. However, codec options were
only being applied to the primary encoder. This patch updates
codecctl_int and codecctl_intp to also apply codec options to the alpha
codec context when encoding frames with alpha.

This is necessary to take advantage of libvpx speed optimizations
such as 'row-mt' and 'cpu-used' when encoding videos with alpha.
Without this patch, the speed optimizations are only applied to the
primary stream encoding, and the overall encoding is just as slow
as it would be without the options specified.

Signed-off-by: Adam Chelminski <chelminski.adam@gmail.com>
Signed-off-by: James Zern <jzern@google.com>
3 months agoavformat/rtpdec: Make ff_rtp_handler_iterate() static
Andreas Rheinhardt [Mon, 6 Sep 2021 12:03:22 +0000 (14:03 +0200)]
avformat/rtpdec: Make ff_rtp_handler_iterate() static

Possible since 61974537610d82bd35b6e3ac91ccd270c6bdc711.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 months agoavformat/rawdec: Make ff_raw_data_read_header() static
Andreas Rheinhardt [Mon, 6 Sep 2021 11:59:26 +0000 (13:59 +0200)]
avformat/rawdec: Make ff_raw_data_read_header() static

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>