]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavcodec/dxtory: Fix negative shift in dxtory_decode_v1_410()
Michael Niedermayer [Fri, 25 Sep 2020 15:15:29 +0000 (17:15 +0200)]
avcodec/dxtory: Fix negative shift in dxtory_decode_v1_410()

Fixes: left shift of negative value -256
Fixes: 25460/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXTORY_fuzzer-5073252341514240
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>
3 years agoavcodec/dxtory: Fix get_raw_size() for YUV
Michael Niedermayer [Fri, 25 Sep 2020 15:07:24 +0000 (17:07 +0200)]
avcodec/dxtory: Fix get_raw_size() for YUV

Fixes: out of array read
Fixes: 25455/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXTORY_fuzzer-6327985731534848
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>
3 years agolavc/qsvdec: Add QSV AV1 decoder
Haihao Xiang [Wed, 16 Sep 2020 07:07:54 +0000 (15:07 +0800)]
lavc/qsvdec: Add QSV AV1 decoder

AV1 decoder is supported on Tiger Lake+ platforms since libmfx 1.34

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: Zhong Li <zhongli_dev@126.com>
3 years agoavcodec/mpeg12dec: remove inter block calls in IPU decoder
Paul B Mahol [Fri, 25 Sep 2020 21:32:34 +0000 (23:32 +0200)]
avcodec/mpeg12dec: remove inter block calls in IPU decoder

This is intra only codec.

3 years agoavcodec/mpeg12dec: add support for MPEG1 blocks in IPU codec
Paul B Mahol [Fri, 25 Sep 2020 20:05:03 +0000 (22:05 +0200)]
avcodec/mpeg12dec: add support for MPEG1 blocks in IPU codec

3 years agoavcodec/mobiclip: Move quantizer check into setup_qtables()
Michael Niedermayer [Thu, 24 Sep 2020 09:03:43 +0000 (11:03 +0200)]
avcodec/mobiclip: Move quantizer check into setup_qtables()

Fixes: shift exponent -2 is negative
Fixes: 25683/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOBICLIP_fuzzer-6434808492982272
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>
3 years agoavformat/http: fix memleak
Zhao Zhili [Sun, 23 Aug 2020 16:58:09 +0000 (00:58 +0800)]
avformat/http: fix memleak

Reviewed-by: "mypopy@gmail.com" <mypopy@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/sonic: Check channels before deallocating
Michael Niedermayer [Thu, 24 Sep 2020 20:20:39 +0000 (22:20 +0200)]
avcodec/sonic: Check channels before deallocating

Fixes: heap-buffer-overflow
Fixes: 25744/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5172961169113088
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat: add IPU demuxer
Paul B Mahol [Mon, 14 Sep 2020 10:02:50 +0000 (12:02 +0200)]
avformat: add IPU demuxer

3 years agoavcodec: add IPU Video decoder and parser
Paul B Mahol [Mon, 14 Sep 2020 09:35:26 +0000 (11:35 +0200)]
avcodec: add IPU Video decoder and parser

3 years agoavcodec/cfhd: check that lowpass_height is >= 3 when used in vertical filter
Paul B Mahol [Sat, 19 Sep 2020 23:31:07 +0000 (01:31 +0200)]
avcodec/cfhd: check that lowpass_height is >= 3 when used in vertical filter

Also check for out of buffer access.
Also return early when encountering fatal error.

3 years agoavformat/flvdec: RtmpSampleAccess no longer breaks stream detection
Peter van der Spek [Wed, 19 Aug 2020 07:06:54 +0000 (09:06 +0200)]
avformat/flvdec: RtmpSampleAccess no longer breaks stream detection

Since release 4.2, FFmpeg fails to detect the correct streams in an RTMP
stream that contains a |RtmpSampleAccess AMF object prior to the
onMetaData AMF object. In the debug log it would show "[flv] Unknown
type |RtmpSampleAccess".

This functionality broke in commit d7638d8dfc3c4ffd0dc18a64937a5a07ed67b354
as unknown metadata packets now result in an opaque data stream, and the
|RtmpSampleAccess packet was an "unknown" metadata packet type.

With this change the RTMP streams are correctly detected when there
is a |RtmpSampleAccess object prior to the onMetaData object.

Signed-off-by: Peter van der Spek <p.vanderspek@bluebillywig.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibavcodec/vp8dec: fix the multi-thread HWAccel decode error
Shaofei Wang [Tue, 11 Jun 2019 06:52:29 +0000 (02:52 -0400)]
libavcodec/vp8dec: fix the multi-thread HWAccel decode error

Fix the issue: https://github.com/intel/media-driver/issues/317

the root cause is update_dimensions will be called multple times
when decoder thread number is not only 1, but update_dimensions
call get_pixel_format in each decode thread will trigger the
hwaccel_uninit/hwaccel_init more than once. But only one hwaccel
should be shared with all decode threads.
in current context,
there are 3 situations in the update_dimensions():
1. First time calling. No matter single thread or multithread,
   get_pixel_format() should be called after dimensions were
   set;
2. Dimention changed at the runtime. Dimention need to be
   updated when macroblocks_base is already allocated,
   get_pixel_format() should be called to recreate new frames
   according to updated dimension;
3. Multithread first time calling. After decoder init, the
   other threads will call update_dimensions() at first time
   to allocate macroblocks_base and set dimensions.
   But get_pixel_format() is shouldn't be called due to low
   level frames and context are already created.

In this fix, we only call update_dimensions as need.

Signed-off-by: Wang, Shaofei <shaofei.wang@intel.com>
Reviewed-by: Jun, Zhao <jun.zhao@intel.com>
Reviewed-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
3 years agoavutil/pixfmt: improve definition of AVColorRange
Jan Ekström [Fri, 18 Sep 2020 20:50:54 +0000 (23:50 +0300)]
avutil/pixfmt: improve definition of AVColorRange

As it was brought up that the current documentation leaves things
as specific to YCbCr only, ICtCp and RGB are now mentioned.
Additionally, the specifications on which these definitions of
narrow and full range are defined are mentioned.

This way, the documentation of AVColorRange should now match how
most people seem to read interpret it at this point, and thus
flagging RGB AVFrames as full range is valid not only according to
common sense, but also the enum definition.

3 years agoavformat/swfdec: Reorder allocations/initializations
Andreas Rheinhardt [Sun, 20 Sep 2020 10:28:03 +0000 (12:28 +0200)]
avformat/swfdec: Reorder allocations/initializations

The earlier code would first attempt to allocate two buffers, then
attempt to allocate an AVIOContext, using one of the new buffers I/O
buffer, then check the allocations. On success, a z_stream that is used
in the AVIOContext's read_packet callback is initialized afterwards.

There are two problems with this: In case the allocation of the I/O
buffer fails avio_alloc_context() will be given a NULL read buffer
with a size > 0. This works right now, but it is fragile. The second
problem is that the z_stream used in the read_packet callback is not
functional when avio_alloc_context() is allocated (it might be that
avio_alloc_context() might already fill the buffer in the future). This
commit fixes both of these problems by reordering the operations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/swfdec: Fix memleaks on error
Andreas Rheinhardt [Sun, 20 Sep 2020 10:07:19 +0000 (12:07 +0200)]
avformat/swfdec: Fix memleaks on error

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/h264_slice: sync User Data Unregistered SEI buffers across threads
James Almer [Thu, 17 Sep 2020 16:36:15 +0000 (13:36 -0300)]
avcodec/h264_slice: sync User Data Unregistered SEI buffers across threads

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/hevcdec: sync User Data Unregistered SEI buffers across threads
James Almer [Thu, 17 Sep 2020 13:34:08 +0000 (10:34 -0300)]
avcodec/hevcdec: sync User Data Unregistered SEI buffers across threads

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/hevcdec: sync SEI derived AVCodecContext fields across threads
James Almer [Thu, 17 Sep 2020 00:17:45 +0000 (21:17 -0300)]
avcodec/hevcdec: sync SEI derived AVCodecContext fields across threads

Fixes ticket #8610.

Found-by: Pavel Koshevoy <pkoshevoy@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/argo_asf: implement seeking
Zane van Iperen [Mon, 21 Sep 2020 09:36:03 +0000 (19:36 +1000)]
avformat/argo_asf: implement seeking

Causes some error as the ADPCM predictors aren't known, but
the difference is negligible and not audible.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/magicyuv: add support for recently added new format
Paul B Mahol [Tue, 22 Sep 2020 16:31:14 +0000 (18:31 +0200)]
avcodec/magicyuv: add support for recently added new format

3 years agoavformat/movenc: simplify ISML manifest bit rate logic
Jan Ekström [Sun, 20 Sep 2020 16:55:14 +0000 (19:55 +0300)]
avformat/movenc: simplify ISML manifest bit rate logic

The newly calculated average bit rate value is pretty much what is
being done here.

3 years agoavformat/movenc: use more fall-back values for average bit rate fields
Jan Ekström [Sun, 20 Sep 2020 15:14:48 +0000 (18:14 +0300)]
avformat/movenc: use more fall-back values for average bit rate fields

If the average bit rate cannot be calculated, such as in the case
of streamed fragmented mp4, utilize various available parameters
in priority order.

Tests are updated where the esds or btrt or ISML manifest boxes'
output changes.

3 years agoavformat/movenc: implement writing of the btrt box
Jan Ekström [Sun, 20 Sep 2020 12:26:42 +0000 (15:26 +0300)]
avformat/movenc: implement writing of the btrt box

This is utilized by various media ingests to figure out the bit
rate of the content you are pushing towards it, so write it for
video, audio and subtitle tracks in case at least one nonzero value
is available. It is only mentioned for timed metadata sample
descriptions in QTFF, so limit it only to ISOBMFF (MODE_MP4) mode.

Updates the FATE tests which have their results changed due to the
20 extra bytes being written per track.

3 years agoavformat/movenc: utilize bit rate helper function in ISML writing
Jan Ekström [Sun, 20 Sep 2020 12:01:29 +0000 (15:01 +0300)]
avformat/movenc: utilize bit rate helper function in ISML writing

This way we have a single location in movenc which utilizes the
CPB properties.

3 years agoavformat/movenc: split MPEG-4 bit rate value calculation
Jan Ekström [Sun, 20 Sep 2020 11:41:18 +0000 (14:41 +0300)]
avformat/movenc: split MPEG-4 bit rate value calculation

This can now be re-utilized in other places.

3 years agodnn: add a new interface DNNModel.get_output
Guo, Yejun [Fri, 11 Sep 2020 14:15:04 +0000 (22:15 +0800)]
dnn: add a new interface DNNModel.get_output

for some cases (for example, super resolution), the DNN model changes
the frame size which impacts the filter behavior, so the filter needs
to know the out frame size at very beginning.

Currently, the filter reuses DNNModule.execute_model to query the
out frame size, it is not clear from interface perspective, so add
a new explict interface DNNModel.get_output for such query.

3 years agodnn: put DNNModel.set_input and DNNModule.execute_model together
Guo, Yejun [Thu, 10 Sep 2020 14:29:57 +0000 (22:29 +0800)]
dnn: put DNNModel.set_input and DNNModule.execute_model together

suppose we have a detect and classify filter in the future, the
detect filter generates some bounding boxes (BBox) as AVFrame sidedata,
and the classify filter executes DNN model for each BBox. For each
BBox, we need to crop the AVFrame, copy data to DNN model input and do
the model execution. So we have to save the in_frame at DNNModel.set_input
and use it at DNNModule.execute_model, such saving is not feasible
when we support async execute_model.

This patch sets the in_frame as execution_model parameter, and so
all the information are put together within the same function for
each inference. It also makes easy to support BBox async inference.

3 years agodnn: change dnn interface to replace DNNData* with AVFrame*
Guo, Yejun [Fri, 28 Aug 2020 04:51:44 +0000 (12:51 +0800)]
dnn: change dnn interface to replace DNNData* with AVFrame*

Currently, every filter needs to provide code to transfer data from
AVFrame* to model input (DNNData*), and also from model output
(DNNData*) to AVFrame*. Actually, such transfer can be implemented
within DNN module, and so filter can focus on its own business logic.

DNN module also exports the function pointer pre_proc and post_proc
in struct DNNModel, just in case that a filter has its special logic
to transfer data between AVFrame* and DNNData*. The default implementation
within DNN module is used if the filter does not set pre/post_proc.

3 years agodnn: add userdata for load model parameter
Guo, Yejun [Mon, 24 Aug 2020 08:09:59 +0000 (16:09 +0800)]
dnn: add userdata for load model parameter

the userdata will be used for the interaction between AVFrame and DNNData

3 years agoavformat/moflex: Check pop_int() for overflow
Michael Niedermayer [Sun, 20 Sep 2020 19:23:38 +0000 (21:23 +0200)]
avformat/moflex: Check pop_int() for overflow

Fixes: signed integer overflow: 2 * 2132811776 cannot be represented in type 'int'
Fixes: 25722/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6221704077246464
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>
3 years agoavformat/vividas: Check for EOF in first loop in track_header()
Michael Niedermayer [Sun, 20 Sep 2020 19:09:31 +0000 (21:09 +0200)]
avformat/vividas: Check for EOF in first loop in track_header()

Fixes: timeout (243sec -> a few ms)
Fixes: 25716/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5764093666131968
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>
3 years agoavformat/wvdec: Check rate for overflow
Michael Niedermayer [Sun, 20 Sep 2020 18:53:31 +0000 (20:53 +0200)]
avformat/wvdec: Check rate for overflow

Fixes: signed integer overflow: 6000 * -2147483648 cannot be represented in type 'int'
Fixes: 25700/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6578316302352384
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/dashdec: Avoid duplicating string
Andreas Rheinhardt [Mon, 7 Sep 2020 16:46:32 +0000 (18:46 +0200)]
avformat/dashdec: Avoid duplicating string

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Fix memleak on allocation error, avoid allocation
Andreas Rheinhardt [Mon, 7 Sep 2020 16:14:47 +0000 (18:14 +0200)]
avformat/dashdec: Fix memleak on allocation error, avoid allocation

get_content_url() allocates two buffers for temporary strings and when
one of them couldn't be allocated, it simply returns, although one of
the two allocations could have succeeded and would leak in this
scenario. This can be fixed by avoiding one of the temporary buffers.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Cosmetics
Andreas Rheinhardt [Sat, 19 Sep 2020 10:32:27 +0000 (12:32 +0200)]
avformat/dashdec: Cosmetics

1. Perform the necessary reindentations after the last few commits.
2. Adapt switches to the ordinary indentation style.
3. Now that the effective lifetimes of the variables containing
the freshly allocated strings used when parsing the representation
are disjoint, the variables can be replaced by a single variable.
Doing so has the advantage of making it more clear that these are
throwaway variables, hence it has been done.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Remove redundant casts to const
Andreas Rheinhardt [Mon, 7 Sep 2020 17:15:59 +0000 (19:15 +0200)]
avformat/dashdec: Remove redundant casts to const

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Return early for unsupported representations
Andreas Rheinhardt [Sat, 19 Sep 2020 10:08:00 +0000 (12:08 +0200)]
avformat/dashdec: Return early for unsupported representations

This allows to reduce the level of indentation for parsing the supported
representations (audio, video and subtitles). It also allows to avoid
some allocations and frees for unsupported representations.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Remove redundant checks
Andreas Rheinhardt [Sat, 19 Sep 2020 08:27:34 +0000 (10:27 +0200)]
avformat/dashdec: Remove redundant checks

This commit removes two always-true checks as well as a dead default
case of a switch. The check when parsing manifests is always true,
because we now jump to the cleaning code in case the format of the
representation is unknown. The default case of the switch is dead,
because the type of the representation is already checked at the
beginning of parse_manifest_representation(). The check when reading
the header is dead, because we error out if an error happened before.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Fix memleaks on error to add representation to dynarray
Andreas Rheinhardt [Sat, 19 Sep 2020 06:52:41 +0000 (08:52 +0200)]
avformat/dashdec: Fix memleaks on error to add representation to dynarray

Up until now, the DASH demuxer used av_dynarray_add() to add
audio/video/subtitles representations to arrays. Yet av_dynarray_add()
frees the array upon failure, leading to leaks of its elements;
furthermore, the element to be added leaks, too.

This has been fixed by using av_dynarray_add_nofree() instead and by
freeing the elements that could not be added to the list. Furthermore,
errors from this are now checked and returned.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Fix leak of representation languages
Andreas Rheinhardt [Sat, 19 Sep 2020 05:01:30 +0000 (07:01 +0200)]
avformat/dashdec: Fix leak of representation languages

These languages are normally freed after having been added as metadata
to their respective AVStreams. Yet if one never reaches said point, they
leak. This can happen as a result of an error when reading the header or
as a result of refreshing the manifests.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Fix leak of string on error when parsing representation
Andreas Rheinhardt [Sat, 19 Sep 2020 04:32:42 +0000 (06:32 +0200)]
avformat/dashdec: Fix leak of string on error when parsing representation

The DASH demuxer currently extracts several strings at once from an xml
document before processing them one by one; these strings are allocated,
stored in local variables and need to be freed by the demuxer itself.
So if an error happens when processing one of them, all strings need to
be freed before returning. This has simply not been done, leading to
leaks.

A simple fix would be to add the necessary code for freeing; yet there is
a better solution: Avoid having several strings at the same time by
extracting a string, processing it and immediately freeing it. That way
one only has to free at most one string on error.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Fix leak of representation on error
Andreas Rheinhardt [Sat, 19 Sep 2020 02:28:47 +0000 (04:28 +0200)]
avformat/dashdec: Fix leak of representation on error

If parsing a representation fails, it is not added to the list of
representations and is therefore not freed in dash_close(); it therefore
leaked in most error paths in parse_manifest_representation() (some
error paths had (incomplete) code for freeing). This commit fixes
freeing the representation in this case.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Remove unused index of representation
Andreas Rheinhardt [Mon, 7 Sep 2020 18:06:23 +0000 (20:06 +0200)]
avformat/dashdec: Remove unused index of representation

It is always zero. Also remove other unused elements.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Fix memleaks upon read_header failure
Andreas Rheinhardt [Sat, 19 Sep 2020 01:18:30 +0000 (03:18 +0200)]
avformat/dashdec: Fix memleaks upon read_header failure

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Check allocation of AVProgram
Andreas Rheinhardt [Sat, 19 Sep 2020 11:14:12 +0000 (13:14 +0200)]
avformat/dashdec: Check allocation of AVProgram

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec, hls: Update correct pointer to AVDictionary
Andreas Rheinhardt [Mon, 7 Sep 2020 18:49:02 +0000 (20:49 +0200)]
avformat/dashdec, hls: Update correct pointer to AVDictionary

open_url() in the DASH as well in the hls demuxer share a common bug:
They modify an AVDictionary (i.e. set a new entry) given to them as
AVDictionary *, yet if this new entry leads to reallocation and
relocation of the AVDictionary, the caller's pointer will become
dangling, leading to use-after-frees. So pass an AVDictionary **.

(With the current implementation of AVDictionary the above can only
happen if the AVDictionary was empty initially (in which case the
new AVDictionary leaks); furthermore if the I/O is ordinary (i.e. opened
by avio_open2() or ffio_open_whitelist()), the dict is never empty (it
contains an rw_timeout entry from save_avio_options()). So this issue
could only happen if the caller sets a nondefault io_open callback, but
no AVIOContext (the AVFMT_FLAG_CUSTOM_IO flag won't be set in this
case). In case of the HLS demuxer, it was also necessary that setting
the "seekable" entry failed. Yet one should simply not rely on internals
of the AVDict API.)

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Fix leak of AVDictionary on error
Andreas Rheinhardt [Mon, 7 Sep 2020 18:36:25 +0000 (20:36 +0200)]
avformat/dashdec: Fix leak of AVDictionary on error

Just postpone the allocation of the dict until it is really needed
(after the checks that can fail).

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Free subtitle representations on exit
Andreas Rheinhardt [Sat, 19 Sep 2020 00:37:05 +0000 (02:37 +0200)]
avformat/dashdec: Free subtitle representations on exit

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Free strings as soon as they aren't needed anymore
Andreas Rheinhardt [Mon, 7 Sep 2020 17:25:22 +0000 (19:25 +0200)]
avformat/dashdec: Free strings as soon as they aren't needed anymore

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Don't overwrite and leak old initialization fragments
Andreas Rheinhardt [Fri, 18 Sep 2020 23:04:32 +0000 (01:04 +0200)]
avformat/dashdec: Don't overwrite and leak old initialization fragments

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Don't leave representation in inconsistent state on error
Andreas Rheinhardt [Mon, 7 Sep 2020 18:32:51 +0000 (20:32 +0200)]
avformat/dashdec: Don't leave representation in inconsistent state on error

This currently doesn't cause any trouble, because the only caller did
not clean up the representation upon error at all; but fixing this is
a prerequisite for doing so.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Remove dead code
Andreas Rheinhardt [Fri, 18 Sep 2020 21:50:53 +0000 (23:50 +0200)]
avformat/dashdec: Remove dead code

The code in question seems to have been copied from about 70 lines
above; yet the code here is only executed if some of the variables
(namely representation_segmenttemplate_node and fragment_template_node)
are NULL, so it makes no sense to check them for a child element.

Also remove a redundant resetting of a pointer to an AVFormatContext
after avformat_close_input() (which already sets the pointer to NULL).

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dashdec: Avoid double free on error
Andreas Rheinhardt [Mon, 7 Sep 2020 16:41:51 +0000 (18:41 +0200)]
avformat/dashdec: Avoid double free on error

When using one of the AV_DICT_DONT_STRDUP_KEY/VAL flags, av_dict_set()
already frees the key/value on error, so that freeing it again would
lead to a double free.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavdevice/lavfi: av_malloc -> av_malloc_array
Limin Wang [Thu, 17 Sep 2020 14:05:17 +0000 (22:05 +0800)]
avdevice/lavfi: av_malloc -> av_malloc_array

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavdevice/lavfi: unref the frame on failure
Limin Wang [Thu, 17 Sep 2020 13:54:28 +0000 (21:54 +0800)]
avdevice/lavfi: unref the frame on failure

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavdevice/lavfi: fix FIXME and check a/v type by codec_type
Limin Wang [Thu, 17 Sep 2020 13:46:50 +0000 (21:46 +0800)]
avdevice/lavfi: fix FIXME and check a/v type by codec_type

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoMAINTAINERS: remove my public key fingerprint
Lou Logan [Sun, 20 Sep 2020 23:03:45 +0000 (15:03 -0800)]
MAINTAINERS: remove my public key fingerprint

Forgot to remove this last time I edited my info.

Signed-off-by: Lou Logan <lou@lrcd.com>
3 years agoavformat/aaxdec: Fix potential integer overflow
Andreas Rheinhardt [Sun, 20 Sep 2020 15:33:23 +0000 (17:33 +0200)]
avformat/aaxdec: Fix potential integer overflow

The AAX demuxer reads a 32bit number containing the amount of entries
of an array and stores it in an uint32_t. Yet when iterating over this
array, a loop counter of type int is used. This leads to undefined
behaviour if the amount of entries is not in the range of int; to avoid
this, it is generally good to use the same type for the loop counter as
for the variable it is compared to. This is done in one of the two loops
affected by this.

In the other loop, the undefined behaviour can begin even earlier: Here
the loop counter is multiplied by an uint16_t which can overflow as soon
as the loop counter is > 2^15. Using an unsigned type would avoid the
undefined behaviour, but truncation would still be possible, so use an
uint64_t.

Also use an uint32_t for a variable containing an index in said array.

This fixes Coverity issue #1466767.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/swf: Separate mux and demux contexts
Andreas Rheinhardt [Sun, 20 Sep 2020 11:21:28 +0000 (13:21 +0200)]
avformat/swf: Separate mux and demux contexts

There was almost no overlap between them: The only field used by both
was an int named samples_per_frame. Therefore this commit separates
them.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ansi: Check nb_args for overflow
Michael Niedermayer [Sat, 19 Sep 2020 18:48:38 +0000 (20:48 +0200)]
avcodec/ansi: Check nb_args for overflow

Fixes: Integer overflow (no testcase)
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/wc3movie: Cleanup on wc3_read_header() failure
Michael Niedermayer [Sun, 19 Jul 2020 13:20:53 +0000 (15:20 +0200)]
avformat/wc3movie: Cleanup on wc3_read_header() failure

Fixes: memleak
Fixes: 23660/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6007508031504384
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/wc3movie: Move wc3_read_close() up
Michael Niedermayer [Sun, 19 Jul 2020 13:20:14 +0000 (15:20 +0200)]
avformat/wc3movie: Move wc3_read_close() up

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/mov: fix typo in comments
Zhao Zhili [Fri, 18 Sep 2020 14:33:37 +0000 (22:33 +0800)]
avformat/mov: fix typo in comments

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/tedcaptionsdec: Fix leak of AVBPrint upon error
Andreas Rheinhardt [Sun, 20 Sep 2020 14:16:51 +0000 (16:16 +0200)]
avformat/tedcaptionsdec: Fix leak of AVBPrint upon error

The tedcaptions demuxer uses an AVBPrint whose string is not restricted
to its internal buffer; it therefore needs to be cleaned up, yet this is
not done on error, as parse_file() returned simply returned directly.
This is fixed by going to fail first in such cases.
Furthermore, there is also a second way how this string can leak: By
having more than one subtitle per subtitle block, as the new one simply
overwrites the old one in this case as the AVBPrint is initialized each
time upon encountering a subtitle line. The code has been modified to
simply append the new subtitle to the old one, so that the old one can't
leak any more.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/argo_brp: don't pass AVStream into avpriv_request_sample()
Zane van Iperen [Sat, 19 Sep 2020 22:19:03 +0000 (08:19 +1000)]
avformat/argo_brp: don't pass AVStream into avpriv_request_sample()

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_brp: set BVID packet duration
Zane van Iperen [Sat, 19 Sep 2020 12:14:52 +0000 (22:14 +1000)]
avformat/argo_brp: set BVID packet duration

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_brp: handle multiple BASF blocks
Zane van Iperen [Mon, 14 Sep 2020 10:12:53 +0000 (20:12 +1000)]
avformat/argo_brp: handle multiple BASF blocks

Turns out that there are files with multiple (reasonably-sized) BASF
blocks. Some of the files just have particularly large frames (~10s).

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_brp: make sure stream ids match
Zane van Iperen [Sat, 19 Sep 2020 12:10:45 +0000 (22:10 +1000)]
avformat/argo_brp: make sure stream ids match

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_brp: cleanup 'goto fail's
Zane van Iperen [Sat, 19 Sep 2020 12:05:43 +0000 (22:05 +1000)]
avformat/argo_brp: cleanup 'goto fail's

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_brp: remove an allocation
Zane van Iperen [Sat, 19 Sep 2020 12:02:42 +0000 (22:02 +1000)]
avformat/argo_brp: remove an allocation

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_asf: cosmetics
Zane van Iperen [Sun, 20 Sep 2020 07:53:27 +0000 (17:53 +1000)]
avformat/argo_asf: cosmetics

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_asf: fix enforcement of chunk count
Zane van Iperen [Sat, 19 Sep 2020 02:35:42 +0000 (12:35 +1000)]
avformat/argo_asf: fix enforcement of chunk count

Enforcing num_chunks == 1 only makes sense when demuxing from an ASF
file. When embedded in a BRP file, an ASF stream can have multiple chunks.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/swfdec: Avoid unnecessary skip
Andreas Rheinhardt [Sun, 20 Sep 2020 06:46:16 +0000 (08:46 +0200)]
avformat/swfdec: Avoid unnecessary skip

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/swfenc: Fix memleak upon write_header error
Andreas Rheinhardt [Sun, 20 Sep 2020 06:05:58 +0000 (08:05 +0200)]
avformat/swfenc: Fix memleak upon write_header error

The SWF muxer accepts at most one mp3 audio and at most one VP6F, FLV1
or MJPEG stream. Upon encountering an mp3 stream, a fifo is allocated
that leaks if one of the subsequent streams is incompliant with the
restrictions mentioned above or if the framerate or samplerate are
invalid. This is fixed by adding a deinit function to free said fifo.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn_backend_native_layer_conv2d.c: fix bug of loop boundary in single thread mode.
Xu Jun [Sat, 19 Sep 2020 15:24:25 +0000 (23:24 +0800)]
dnn_backend_native_layer_conv2d.c: fix bug of loop boundary in single thread mode.

Before patch, fate test for dnn may fail in some Windows environment
while succeed in my Linux. The bug was caused by a wrong loop boundary.
After patch, fate test succeed in my windows mingw 64-bit.

Signed-off-by: Xu Jun <xujunzz@sjtu.edu.cn>
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agoavformat/rmdec: Fix potential crash on allocation failure
Andreas Rheinhardt [Mon, 20 Jul 2020 20:44:42 +0000 (22:44 +0200)]
avformat/rmdec: Fix potential crash on allocation failure

The RealMedia demuxer uses the priv_data of its streams to store a
structure containing an AVPacket. These packets are unreferenced in the
read_close function, yet said function simply presumed that the
priv_data has been successfully allocated. This implies that it mustn't
be called when an allocation of priv_data fails; but this can happen
since commit 35bbc1955a58ba74552c50d9161084644f00bbd3 if one has a
stream with multiple substreams (also exported as AVStream) and if
allocating the priv_data for one of these substreams fails.

This has been fixed by making sure that read_close can handle the case
in which priv_data has not been successfully allocated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/rmdec: Actually return value < 0 on read_header failure
Andreas Rheinhardt [Mon, 20 Jul 2020 19:14:15 +0000 (21:14 +0200)]
avformat/rmdec: Actually return value < 0 on read_header failure

The RealMedia demuxer's read_header function initially initializes ret,
the variable designated for the return variable to -1. Afterwards, chunks
of the file are parsed in a loop until an error happens or until the actual
frame data is encountered. If the first function whose return
value is put into ret doesn't fail, then ret contains a value >= 0
(actually == 0) and this is what will be returned if an error is
encountered afterwards.

This is a regression since 35bbc1955a58ba74552c50d9161084644f00bbd3.
Before that, ret had never been overwritten with a nonnegative value.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/avidec: Fix memleak when error happens after creating DV stream
Andreas Rheinhardt [Tue, 18 Aug 2020 21:21:31 +0000 (23:21 +0200)]
avformat/avidec: Fix memleak when error happens after creating DV stream

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec*: Cleanup generically on init failure
Andreas Rheinhardt [Tue, 15 Sep 2020 06:33:22 +0000 (08:33 +0200)]
avcodec/mpegaudiodec*: Cleanup generically on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec_float: Avoid indirection with float dsp function
Andreas Rheinhardt [Tue, 15 Sep 2020 06:16:13 +0000 (08:16 +0200)]
avcodec/mpegaudiodec_float: Avoid indirection with float dsp function

Do this by only keeping the only function pointer from the
AVFloatDSPContext that is needed lateron. This also allows to remove the
decoders' close function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec_template: Check return value of subdecoder
Andreas Rheinhardt [Tue, 15 Sep 2020 05:13:46 +0000 (07:13 +0200)]
avcodec/mpegaudiodec_template: Check return value of subdecoder

After all, allocating an AVFloatDSPContext might have failed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ljpegenc: Don't free buffer known to be NULL
Andreas Rheinhardt [Tue, 15 Sep 2020 00:09:42 +0000 (02:09 +0200)]
avcodec/ljpegenc: Don't free buffer known to be NULL

The lossless JPEG encoder allocates one buffer in its init function
and freeing said buffer is the only thing done in its close function.
Despite this the init function called the close function if allocating
said buffer fails, although there is nothing to free in this case.
This commit stops doing this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/j2kenc: Fix leaks on init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 23:29:58 +0000 (01:29 +0200)]
avcodec/j2kenc: Fix leaks on init failure

The JPEG2000 encoder did not clean up after itself on error.
This commit fixes this by modifying the cleanup function to be able to
handle only partially allocated structures and by setting the
FF_CODEC_CAP_INIT_CLEANUP flag.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/indeo3: Cleanup generically after init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 17:58:07 +0000 (19:58 +0200)]
avcodec/indeo3: Cleanup generically after init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/imc: Avoid indirection when calling float dsp function
Andreas Rheinhardt [Mon, 14 Sep 2020 17:43:49 +0000 (19:43 +0200)]
avcodec/imc: Avoid indirection when calling float dsp function

Do this by only keeping the only function pointer from
the AVFloatDSPContext that is needed lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/hq_hqadata: Make local arrays static
Andreas Rheinhardt [Mon, 14 Sep 2020 16:59:56 +0000 (18:59 +0200)]
avcodec/hq_hqadata: Make local arrays static

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/hnm4video: Don't reimplement FFSWAP()
Andreas Rheinhardt [Mon, 14 Sep 2020 16:09:09 +0000 (18:09 +0200)]
avcodec/hnm4video: Don't reimplement FFSWAP()

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/hnm4video: Don't return nonsense error messages
Andreas Rheinhardt [Mon, 14 Sep 2020 15:53:58 +0000 (17:53 +0200)]
avcodec/hnm4video: Don't return nonsense error messages

The HNM 4 video decoder's init function claimed that an allocation
failed if the image dimensions are wrong. This is fixed in this commit:
The dimensions are checked before the allocations are attempted.
The check whether width * height is zero is redundant as
av_image_check_size() already checks for this; it has been removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/hnm4video: Cleanup generically on init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 15:48:20 +0000 (17:48 +0200)]
avcodec/hnm4video: Cleanup generically on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/g722enc: Cleanup generically on init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 15:21:12 +0000 (17:21 +0200)]
avcodec/g722enc: Cleanup generically on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flashsv2enc: Return better error codes
Andreas Rheinhardt [Mon, 14 Sep 2020 15:02:04 +0000 (17:02 +0200)]
avcodec/flashsv2enc: Return better error codes

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flashsv2enc: Cleanup generically after init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 14:57:49 +0000 (16:57 +0200)]
avcodec/flashsv2enc: Cleanup generically after init failure

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flashsv2enc: Check allocations for success before usage
Andreas Rheinhardt [Mon, 14 Sep 2020 14:56:13 +0000 (16:56 +0200)]
avcodec/flashsv2enc: Check allocations for success before usage

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flashsvenc: Remove unused z_stream
Andreas Rheinhardt [Mon, 14 Sep 2020 14:37:58 +0000 (16:37 +0200)]
avcodec/flashsvenc: Remove unused z_stream

This encoder uses the compress2 utility function provided by zlib
instead of using a z_stream.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flashsvenc: Avoid allocation of buffer, fix memleak
Andreas Rheinhardt [Mon, 14 Sep 2020 14:28:32 +0000 (16:28 +0200)]
avcodec/flashsvenc: Avoid allocation of buffer, fix memleak

Up until now, the flashsv encoder tried to allocate two buffers in its
init function; if only one of these allocations succeeds, the other
buffer leaks. Fix this by making one of these buffers part of the
context (its size is a compile-time constant).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_datascope: fix oscilloscope with gray>8 depth
Paul B Mahol [Sat, 19 Sep 2020 14:34:55 +0000 (16:34 +0200)]
avfilter/vf_datascope: fix oscilloscope with gray>8 depth

3 years agoavformat/argo_{asf,brp}: use variable frame sizes when (de)muxing adpcm_argo
Zane van Iperen [Tue, 15 Sep 2020 21:39:51 +0000 (07:39 +1000)]
avformat/argo_{asf,brp}: use variable frame sizes when (de)muxing adpcm_argo

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_{psx,argo}: add missing indent
Zane van Iperen [Wed, 16 Sep 2020 07:09:57 +0000 (17:09 +1000)]
avcodec/adpcm_{psx,argo}: add missing indent

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_argo: support decoding multiple frames
Zane van Iperen [Sat, 12 Sep 2020 12:02:26 +0000 (22:02 +1000)]
avcodec/adpcm_argo: support decoding multiple frames

Increases decode speed significantly.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>