]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavdevice/lavfi: Don't set pkt->size to the value it already has
Andreas Rheinhardt [Sun, 30 Aug 2020 05:32:48 +0000 (07:32 +0200)]
avdevice/lavfi: Don't set pkt->size to the value it already has

av_new_packet() already sets the size. And if the packet is not
allocated by av_new_packet() (which seems to be impossible atm), both
pkt->size as well as size are 0, so setting it again is unnecessary in
this scenario, too.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavdevice/lavfi: Don't reimplement av_frame_get_side_data()
Andreas Rheinhardt [Sun, 30 Aug 2020 03:49:46 +0000 (05:49 +0200)]
avdevice/lavfi: Don't reimplement av_frame_get_side_data()

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavdevice/lavfi: Use av_packet_move_ref() for packet ownership transfer
Andreas Rheinhardt [Sun, 30 Aug 2020 03:45:47 +0000 (05:45 +0200)]
avdevice/lavfi: Use av_packet_move_ref() for packet ownership transfer

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/bitstream: Remove outdated comment
Andreas Rheinhardt [Sat, 29 Aug 2020 16:23:02 +0000 (18:23 +0200)]
avcodec/bitstream: Remove outdated comment

The comment referred to the INIT_VLC_USE_STATIC flag which has been
removed in 2009 in 595324e143b57a52e2329eb47b84395c70f93087; the
function it referred to was removed even earlier in commit
83422c1940d963d395a64bee0cbb9c637192ce8c in 2008.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodoc/decoders: Document default value of ac3's drc_scale option
Aman Verma [Sun, 30 Aug 2020 18:05:53 +0000 (14:05 -0400)]
doc/decoders: Document default value of ac3's drc_scale option

Signed-off-by: Aman Verma <amanraoverma@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibavformat/dashenc: Reduce confusion in par error message
Chris Miceli [Mon, 31 Aug 2020 04:16:39 +0000 (14:16 +1000)]
libavformat/dashenc: Reduce confusion in par error message

In ticket #8754 there is discourse surrounding the error
message which is printed upon a mismatched aspect ratio in
derived encodings. This should make it clearer to the user
as to the issues which they are experiencing.

Reviewed-by: "Jeyapal, Karthick" <kjeyapal@akamai.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agohwcontext_vaapi: Don't require a render node when deriving from DRM
Mark Thompson [Fri, 28 Aug 2020 22:15:41 +0000 (23:15 +0100)]
hwcontext_vaapi: Don't require a render node when deriving from DRM

The V4L2 driver does not actually have an associated DRM device at all, so
users work around the requirement by giving libva an unrelated display-only
device instead (which is fine, because it doesn't actually do anything with
that device).  This was broken by bc9b6358fb7315c0173de322472641766f6289da
forcing a render node, because the display-only device did not have an
associated render node to use.  Fix that by just passing through the
original non-render DRM fd if we can't find a render node.

Reported-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Tested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
3 years agoavcodec/sheervideo: use cached bitstream reader except for x32
Paul B Mahol [Mon, 31 Aug 2020 18:09:28 +0000 (20:09 +0200)]
avcodec/sheervideo: use cached bitstream reader except for x32

3 years agoavfilter/f_graphmonitor: also show link EOF status in blue
Paul B Mahol [Mon, 31 Aug 2020 16:06:54 +0000 (18:06 +0200)]
avfilter/f_graphmonitor: also show link EOF status in blue

3 years agoavcodec/magicyuv: change bits used by 12bit tables
Paul B Mahol [Mon, 31 Aug 2020 17:53:30 +0000 (19:53 +0200)]
avcodec/magicyuv: change bits used by 12bit tables

Higher number slows decoder.

3 years agoavcodec/magicyuv: use cached bitstream reader except for x32
Paul B Mahol [Mon, 31 Aug 2020 14:23:23 +0000 (16:23 +0200)]
avcodec/magicyuv: use cached bitstream reader except for x32

3 years agoavcodec/magicyuv: invert symbols when building vlc
Paul B Mahol [Mon, 31 Aug 2020 14:19:55 +0000 (16:19 +0200)]
avcodec/magicyuv: invert symbols when building vlc

Instead at every decoded symbol.

3 years agoavfilter/vsrc_gradients: add speed option
Paul B Mahol [Mon, 31 Aug 2020 09:04:38 +0000 (11:04 +0200)]
avfilter/vsrc_gradients: add speed option

3 years agoavfilter/vsrc_gradients: do not use (l)lrint variants for double
Paul B Mahol [Mon, 31 Aug 2020 08:55:59 +0000 (10:55 +0200)]
avfilter/vsrc_gradients: do not use (l)lrint variants for double

3 years agoavfilter/vsrc_gradients: add duration option
Paul B Mahol [Mon, 31 Aug 2020 08:46:42 +0000 (10:46 +0200)]
avfilter/vsrc_gradients: add duration option

3 years agodnn/tensorflow: add log error message
Ting Fu [Thu, 27 Aug 2020 04:17:22 +0000 (12:17 +0800)]
dnn/tensorflow: add log error message

Signed-off-by: Ting Fu <ting.fu@intel.com>
3 years agodnn/openvino: add log error message
Ting Fu [Thu, 27 Aug 2020 04:17:21 +0000 (12:17 +0800)]
dnn/openvino: add log error message

Signed-off-by: Ting Fu <ting.fu@intel.com>
3 years agoavfilter/src_movie: Avoid intermediate buffer for writing string
Andreas Rheinhardt [Sat, 22 Aug 2020 02:08:15 +0000 (04:08 +0200)]
avfilter/src_movie: Avoid intermediate buffer for writing string

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/roqvideodec: Remove set-but-unused frame stats
Andreas Rheinhardt [Sun, 30 Aug 2020 12:20:18 +0000 (14:20 +0200)]
avcodec/roqvideodec: Remove set-but-unused frame stats

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/roqvideodec: Move transient GetByteContext to the stack
Andreas Rheinhardt [Sun, 30 Aug 2020 12:06:11 +0000 (14:06 +0200)]
avcodec/roqvideodec: Move transient GetByteContext to the stack

This avoids keeping potentially dangling pointers in the context,
beautifies the code (by replacing "&ri->gb" by gb for every access to
the GetByteContext) and also highlights the GetByteContext's short-lived
nature better.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cdxl: also mark decoded frame as keyframe
Paul B Mahol [Sun, 30 Aug 2020 22:07:18 +0000 (00:07 +0200)]
avcodec/cdxl: also mark decoded frame as keyframe

3 years agoavcodec/qpeg: reduce unnecessary size of tables
Paul B Mahol [Sun, 30 Aug 2020 21:49:11 +0000 (23:49 +0200)]
avcodec/qpeg: reduce unnecessary size of tables

3 years agolibavcodec/jpeg2000: fix tag tree reset
Gautam Ramakrishnan [Thu, 27 Aug 2020 18:45:36 +0000 (00:15 +0530)]
libavcodec/jpeg2000: fix tag tree reset

The implementation of the tag tree did not
set the correct reset value for the encoder.
This lead to inefficent tag tree being encoded.
This patch fixes the implementation of the
ff_tag_tree_zero() function.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibavcodec/j2kenc: Support for multiple layers
Gautam Ramakrishnan [Thu, 27 Aug 2020 18:45:35 +0000 (00:15 +0530)]
libavcodec/j2kenc: Support for multiple layers

This patch allows setting a compression ratio and to
set multiple layers. The user has to input a compression
ratio for each layer.
The per layer compression ration can be set as follows:
-layer_rates "r1,r2,...rn"
for to create 'n' layers.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibavcodec/j2kenc: Fix tag tree coding
Gautam Ramakrishnan [Thu, 27 Aug 2020 18:45:34 +0000 (00:15 +0530)]
libavcodec/j2kenc: Fix tag tree coding

The implementation of tag tree encoding was incorrect.
However, this error was not visible as the current j2k
encoder encodes only 1 layer.
This patch fixes tag tree coding for JPEG2000 such tag
tree coding would work for multi layer encoding.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibavcodec/jpeg2000: Make tag tree functions non static
Gautam Ramakrishnan [Thu, 27 Aug 2020 18:45:33 +0000 (00:15 +0530)]
libavcodec/jpeg2000: Make tag tree functions non static

This patch makes the tag_tree_zero() and tag_tree_size()
functions non static and callable from other files.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/cfhd: Check transform type
Michael Niedermayer [Thu, 27 Aug 2020 22:17:41 +0000 (00:17 +0200)]
avcodec/cfhd: Check transform type

Fixes: out of array access
Fixes: 24823/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4855119863349248
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 agoavcodec/aacdec_template: Initialize `layout_map` on declaration
Xiaohan Wang [Fri, 28 Aug 2020 19:51:19 +0000 (12:51 -0700)]
avcodec/aacdec_template: Initialize `layout_map` on declaration

Without this change, it'll cause use-of-uninitialized-variable error.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mpegvideo_enc: Replace some s->avctx by avctx
Michael Niedermayer [Tue, 25 Aug 2020 19:31:57 +0000 (21:31 +0200)]
avcodec/mpegvideo_enc: Replace some s->avctx by avctx

Fixes issue reported by: Xu Guangxin <guangxin.xu@intel.com>
Original report:
Steps to reproduce:
1. ./configure --enable-debug=3 --disable-libx264 && make install
2. ffmpeg -i input.mp4 -profile:v baseline output.mp4 -y

you will see a crash like this:
[mpeg4 @ 0x5555575854c0] [Eval @ 0x7fffffffbf80] Undefined constant or missing '(' in 'baseline'
[mpeg4 @ 0x5555575854c0] Unable to parse option value "baseline"
[mpeg4 @ 0x5555575854c0] Error setting option profile to value baseline.
Thread 1 "ffmpeg" received signal SIGSEGV, Segmentation fault.

root cause:
If the codec has FF_CODEC_CAP_INIT_CLEANUP flag, and avcodec_open2 got an error before avctx->codec->init,
the ff_mpv_encode_end will face a null s->avctx.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoadtsenc: Add ability to write MPEG2 ID
Marvin Scholz [Sat, 29 Aug 2020 11:57:13 +0000 (13:57 +0200)]
adtsenc: Add ability to write MPEG2 ID

Reviewed-by: Kieran Kunhya <kierank@obe.tv>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/cfhd: Replace a few literal numbers by named constants
Michael Niedermayer [Sat, 29 Aug 2020 19:45:54 +0000 (21:45 +0200)]
avcodec/cfhd: Replace a few literal numbers by named constants

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavfilter/vf_xfade: fix excessive number of queued frames
Paul B Mahol [Sun, 30 Aug 2020 09:07:51 +0000 (11:07 +0200)]
avfilter/vf_xfade: fix excessive number of queued frames

Also do not abort in some cases too early when transition is over.

Fixes #8823.

3 years agoavcodec/truemotion1: Cleanup generically after init failure
Andreas Rheinhardt [Sat, 29 Aug 2020 07:39:40 +0000 (09:39 +0200)]
avcodec/truemotion1: 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/y41penc: Remove empty close function
Andreas Rheinhardt [Sat, 29 Aug 2020 15:59:17 +0000 (17:59 +0200)]
avcodec/y41penc: Remove empty close function

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/yuv4enc: Remove empty functions
Andreas Rheinhardt [Sat, 29 Aug 2020 15:55:15 +0000 (17:55 +0200)]
avcodec/yuv4enc: Remove empty functions

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/wnv1: Move temporary variables from context to stack
Andreas Rheinhardt [Sat, 29 Aug 2020 15:14:18 +0000 (17:14 +0200)]
avcodec/wnv1: Move temporary variables from context to stack

Here it even leads to the complete removal of the context.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/wnv1: Use LE bitstream reader, avoid copying packet, fix memleak
Andreas Rheinhardt [Sat, 29 Aug 2020 14:12:05 +0000 (16:12 +0200)]
avcodec/wnv1: Use LE bitstream reader, avoid copying packet, fix memleak

The Winnov WNV1 format is designed for a little-endian bitstream reader;
yet our decoder reversed every byte bitwise (in a buffer only
allocated for this purpose) to use a big-endian bitstream reader. This
commit stops this.

Two things needed to be done to achieve this: The codes in the table used
to initialize a VLC reader needed to be reversed bitwise (when
initializing a VLC in LE mode, it is expected that the first bit to be
read is in the least significant bit; with BE codes the first bit to be
read is the most significant bit of the code) and the following
expression needed to be adapted:

ff_reverse[get_bits(&w->gb, 8 - w->shift)]

But this is easy: When only the bits read are reversed, they coincide
with what a little-endian bitstream reader reads that reads the
original, not-reversed data. But ff_reverse always reverses the full
eight bits and this also performs a shift by (8 - (8 - w->shift)) on top
of reversing the bits read. So the above line needs to be changed to

get_bits(&w->gb, 8 - w->shift) << w->shift

and this also shows why the variable shift is named the way it is.

Finally, this also fixes a hypothetical memleak: For gigantic packets,
initializing a GetBitContext can fail and in this case, the buffer
containing the reversed data would leak.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/roqvideoenc: Cleanup generically after init failure
Andreas Rheinhardt [Sat, 29 Aug 2020 07:05:17 +0000 (09:05 +0200)]
avcodec/roqvideoenc: 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/roqvideodec: Cleanup generically after init failure
Andreas Rheinhardt [Sat, 29 Aug 2020 07:04:42 +0000 (09:04 +0200)]
avcodec/roqvideodec: 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/mss3: Cleanup generically after init failure
Andreas Rheinhardt [Sat, 29 Aug 2020 06:51:55 +0000 (08:51 +0200)]
avcodec/mss3: 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/mss3: Remove unnecessary free of unallocated frame
Andreas Rheinhardt [Sat, 29 Aug 2020 06:49:45 +0000 (08:49 +0200)]
avcodec/mss3: Remove unnecessary free of unallocated frame

The frame will only be allocated a few lines below.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/interplayvideo: Cleanup generically after init failure
Andreas Rheinhardt [Sat, 29 Aug 2020 06:43:42 +0000 (08:43 +0200)]
avcodec/interplayvideo: 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/eacmv: Cleanup generically after init failure
Andreas Rheinhardt [Sat, 29 Aug 2020 06:26:03 +0000 (08:26 +0200)]
avcodec/eacmv: 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/cinepakenc: Cleanup generically after init failure
Andreas Rheinhardt [Sat, 29 Aug 2020 06:37:17 +0000 (08:37 +0200)]
avcodec/cinepakenc: Cleanup generically after init failure

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/truemotion2: Avoid duplicating array, fix memleak
Andreas Rheinhardt [Sat, 29 Aug 2020 07:40:39 +0000 (09:40 +0200)]
avcodec/truemotion2: Avoid duplicating array, fix memleak

TrueMotion 2.0 uses Huffmann trees. To parse them, the decoder allocates
arrays for the codes, their lengths and their value; afterwards a VLC
table is initialized using these values. If everything up to this point
succeeds, a new buffer of the same size as the already allocated arrays
for the values is allocated and upon success the values are copied into
the new array; all the old arrays are then freed. Yet if allocating the
new array fails, the old arrays get freed, but the VLC table doesn't.

This leak is fixed by not allocating a new array at all; instead the old
array is simply reused, ensuring that nothing can fail after the
creation of the VLC table.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolibavformat/mxfenc: color_range should be inclusive
Harry Mallon [Thu, 20 Aug 2020 13:58:53 +0000 (14:58 +0100)]
libavformat/mxfenc: color_range should be inclusive

MXF CDCI color range was being set to (1<<sc->component_depth) - 1
for full range but it should be (1<<sc->component_depth) as 0 is
a valid value.

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
3 years agoavformat/mxfdec: Read video range from CDCIEssenceDescriptor
Harry Mallon [Thu, 20 Aug 2020 13:58:52 +0000 (14:58 +0100)]
avformat/mxfdec: Read video range from CDCIEssenceDescriptor

* Capture black_ref, white_ref and color_range and recognise
  full and narrow range.

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
3 years agox86/cfhddsp: zero extend int arguments
James Almer [Fri, 28 Aug 2020 22:40:09 +0000 (19:40 -0300)]
x86/cfhddsp: zero extend int arguments

if taken from stack, they may have garbage in the upper bits otherwise.
Also, there are only 8 arguments, so don't attempt to load 11.

Fixes SIGSEV crashes in some targets.

Reviewed-by: durandal_1707
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/mov: See if mfra makes up the difference for an incomplete sidx.
Dale Curtis [Thu, 13 Aug 2020 22:02:02 +0000 (15:02 -0700)]
avformat/mov: See if mfra makes up the difference for an incomplete sidx.

A few popular sites have started generating MP4 files which have a
sidx plus an mfra. The sidx accounts for all size except the mfra,
so the old code did not mark the fragment index as complete.

Instead we can just check if there's an mfra and if its size makes
up the difference we can mark the index as complete.

Bug: https://crbug.com/1107130
Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
3 years agoavcodec/flacdec: use designated initializers for AVClass
Paul B Mahol [Thu, 27 Aug 2020 23:15:56 +0000 (01:15 +0200)]
avcodec/flacdec: use designated initializers for AVClass

3 years agoavcodec/cfhd: Remove unused-but-set variable
Andreas Rheinhardt [Fri, 21 Aug 2020 09:44:16 +0000 (11:44 +0200)]
avcodec/cfhd: Remove unused-but-set variable

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_arnndn: use memcpy for copying in compute_rnn()
Paul B Mahol [Thu, 27 Aug 2020 18:32:52 +0000 (20:32 +0200)]
avfilter/af_arnndn: use memcpy for copying in compute_rnn()

3 years agoavfilter/af_arnndn: use scalarproduct_float() in dct function
Paul B Mahol [Thu, 27 Aug 2020 16:49:02 +0000 (18:49 +0200)]
avfilter/af_arnndn: use scalarproduct_float() in dct function

3 years agoavfilter/af_compensationdelay: always initialize w_ptr with 0
Paul B Mahol [Thu, 27 Aug 2020 16:06:15 +0000 (18:06 +0200)]
avfilter/af_compensationdelay: always initialize w_ptr with 0

It will be changed later anyway, and in case inlink have 0 channels
(should never happen) it will not pick some random value.

3 years agoavfilter/vf_xfade: do not use alpha for average rgb color
Paul B Mahol [Thu, 27 Aug 2020 12:42:44 +0000 (14:42 +0200)]
avfilter/vf_xfade: do not use alpha for average rgb color

3 years agoavfilter/vf_xfade: add corner wipe transforms
Paul B Mahol [Thu, 27 Aug 2020 11:49:14 +0000 (13:49 +0200)]
avfilter/vf_xfade: add corner wipe transforms

3 years agoRevert "avfilter/yadif: simplify the code for better readability"
Limin Wang [Wed, 26 Aug 2020 23:30:30 +0000 (07:30 +0800)]
Revert "avfilter/yadif: simplify the code for better readability"

This reverts commit 2a9b934675b9e2d3850b46f8a618c19b03f02551.

3 years agoavfilter/af_headphone: Fix leak of channel layouts list on error
Andreas Rheinhardt [Mon, 24 Aug 2020 20:21:51 +0000 (22:21 +0200)]
avfilter/af_headphone: Fix leak of channel layouts list on error

In case the multichannel HRIR mode was enabled, an error could happen
between allocating a channel layouts list and attaching it to its target
destination. If an error happened, the list would leak. This is fixed by
attaching the list to its target directly after its allocation.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Fix segfault upon allocation failure
Andreas Rheinhardt [Mon, 24 Aug 2020 03:26:57 +0000 (05:26 +0200)]
avfilter/af_headphone: Fix segfault upon allocation failure

The headphone filter uses a variable number of inpads and allocates them
in its init function; if all goes well, the number of inpads coincides
with a number stored in the filter's private context. Yet if allocating a
subsequent inpad fails, the uninit function nevertheless uses the number
stored in the private context to determine the number of inpads to free
and not the AVFilterContext's nb_inputs. This will lead to an access
beyond the end of the allocated AVFilterContext.input_pads array and
an invalid free.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_signature: Avoid cast from function pointer to void*
Andreas Rheinhardt [Mon, 24 Aug 2020 22:55:56 +0000 (00:55 +0200)]
avfilter/vf_signature: Avoid cast from function pointer to void*

The signature filter uses qsort, but its compare function doesn't have
the signature required of such a function; therefore it casts the
function pointer to void. Yet this is wrong:
C90 only guarantees that one can convert a pointer to any incomplete
type or object type to void* and back with the result comparing equal
to the original which makes pointers to void generic pointers to
incomplete or object type. Yet C90 lacks a generic function pointer
type.
C99 additionally guarantees that a pointer to a function of one type may
be converted to a pointer to a function of another type with the result
and the original comparing equal when converting back.
This makes any function pointer type a generic function pointer type.
Yet even this does not make pointers to void generic function pointers.

Both GCC and Clang emit warnings for this when in pedantic mode.

This commit fixes this by modifying the compare function to comply with
the expected signature.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_signature: Fix leak of string upon error
Andreas Rheinhardt [Mon, 24 Aug 2020 22:20:35 +0000 (00:20 +0200)]
avfilter/vf_signature: Fix leak of string upon error

If an error happens between allocating a string intended to be used as
an inpad's name and attaching it to its input pad, the string leaks.
Fix this by inserting the inpad directly after allocating its string.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_signature: Fix leak of inpads' names
Andreas Rheinhardt [Mon, 24 Aug 2020 22:20:01 +0000 (00:20 +0200)]
avfilter/vf_signature: Fix leak of inpads' names

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_afir: Avoid allocating AVFilterPad names
Andreas Rheinhardt [Sat, 22 Aug 2020 03:20:01 +0000 (05:20 +0200)]
avfilter/af_afir: Avoid allocating AVFilterPad names

If the names are always the same, they need not be duplicated; doing so
saves allocations, checks for the allocations as well as frees.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_aiir: Fix segfault and leak upon allocation failure
Andreas Rheinhardt [Sat, 22 Aug 2020 02:47:14 +0000 (04:47 +0200)]
avfilter/af_aiir: Fix segfault and leak upon allocation failure

The aiir filter adds output pads in its init function. Each of these
output pads had a name which was allocated and to be freed in the uninit
function. Given that the aiir filter has between one and two outputs,
one output pad's name was freed unconditionally and a second was freed
conditionally.

Yet if adding output pads fails, there are no output pads at all and
trying to free a nonexistent pad's name will lead to a segfault.

Furthermore, if the name could be successfully allocated, yet adding the
new pad fails, the name would leak.

This commit fixes this by not allocating the pads' names at all any
more: They are constant anyway. This allows to remove the code to free
them and hence fixes the aforementioned bugs.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/avf_aphasemeter: Don't allocate outpad names
Andreas Rheinhardt [Sat, 22 Aug 2020 02:33:58 +0000 (04:33 +0200)]
avfilter/avf_aphasemeter: Don't allocate outpad names

These names are always the same, so not using duplicates saves
allocations, checks for the allocations as well as frees.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_bm3d: Don't allocate inpad names
Andreas Rheinhardt [Sat, 22 Aug 2020 02:17:11 +0000 (04:17 +0200)]
avfilter/vf_bm3d: Don't allocate inpad names

These names are always the same, so not using duplicates saves
allocations, checks for the allocations as well as frees.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/f_ebur128: Don't allocate outpad names
Andreas Rheinhardt [Sat, 22 Aug 2020 02:13:28 +0000 (04:13 +0200)]
avfilter/f_ebur128: Don't allocate outpad names

These names are mostly the same, so not using duplicates saves
allocations, checks for the allocations as well as frees.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_decimate: Don't allocate inpad names
Andreas Rheinhardt [Sat, 22 Aug 2020 02:03:21 +0000 (04:03 +0200)]
avfilter/vf_decimate: Don't allocate inpad names

These names are always the same, so not using duplicates saves
allocations, checks for the allocations as well as frees.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_fieldmatch: Don't allocate inpad names
Andreas Rheinhardt [Sat, 22 Aug 2020 01:57:55 +0000 (03:57 +0200)]
avfilter/vf_fieldmatch: Don't allocate inpad names

These names are always the same, so not using duplicates saves
allocations, checks for the allocations as well as frees.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_premultiply: Fix leak of names of inpads
Andreas Rheinhardt [Sat, 22 Aug 2020 01:51:46 +0000 (03:51 +0200)]
avfilter/vf_premultiply: Fix leak of names of inpads

These names leak because freeing them in the uninit function has been
forgotten. Instead of adding the freeing code, this commit stops
allocating these names. They are constants anyway.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_anequalizer: Don't allocate outpad names
Andreas Rheinhardt [Sat, 22 Aug 2020 01:29:25 +0000 (03:29 +0200)]
avfilter/af_anequalizer: Don't allocate outpad names

These names are always the same, so not using duplicates saves
allocations, checks for the allocations as well as frees.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_anequalizer: Fix memleak when inserting pad fails
Andreas Rheinhardt [Sat, 22 Aug 2020 01:23:51 +0000 (03:23 +0200)]
avfilter/af_anequalizer: Fix memleak when inserting pad fails

It has been forgotten to free the name of the second outpad if attaching
the first one to the AVFilterContext fails. Fixing this is easy: Only
prepare the second outpad after (and if) the first outpad has been
successfully attached to the AVFilterContext.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/x86/cfhddsp: try to fix build on x32
Paul B Mahol [Wed, 26 Aug 2020 21:38:10 +0000 (23:38 +0200)]
avcodec/x86/cfhddsp: try to fix build on x32

3 years agoavfilter/vf_xfade: add fadegrays transition
Paul B Mahol [Wed, 26 Aug 2020 21:23:33 +0000 (23:23 +0200)]
avfilter/vf_xfade: add fadegrays transition

3 years agoavcodec/cfhd: add x86 SIMD
Paul B Mahol [Sun, 9 Aug 2020 15:47:34 +0000 (17:47 +0200)]
avcodec/cfhd: add x86 SIMD

Overall speed changes for 1920x1080, yuv422p10le, 60fps from: 0.19x to 0.343x

3 years agoavcodec/tiff: Check jpeg context against jpeg frame parameters
Michael Niedermayer [Wed, 19 Aug 2020 23:05:35 +0000 (01:05 +0200)]
avcodec/tiff: Check jpeg context against jpeg frame parameters

Fixes: out of array access
Fixes: 24825/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6326925027704832
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 agoavcodec/tiff: Restrict tag order based on specification
Michael Niedermayer [Wed, 19 Aug 2020 23:05:35 +0000 (01:05 +0200)]
avcodec/tiff: Restrict tag order based on specification

"The entries in an IFD must be sorted in ascending order by Tag. Note that this is
 not the order in which the fields are described in this document."

This way various dimensions, sample and bit sizes cannot be changed at
arbitrary times which reduces the potential for bugs.
The tag reading code also on various places assumes that numerically previous
tags have already been parsed, so this needs to be enforced one way or another.

If this commit causes problems with real world files which are not easy to fix
then some other form of checks are needed to ensure the various dependencies
in the tag reading are not violated.

Fixes: out of array access
Fixes: 24825/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6326925027704832
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 agoavcodec/tiff: Avoid abort with DNG RAW TIFF with YA8
Michael Niedermayer [Wed, 19 Aug 2020 22:59:35 +0000 (00:59 +0200)]
avcodec/tiff: Avoid abort with DNG RAW TIFF with YA8

Fixes: Assertion failure
Fixes: 24707/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5179910197608448
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 agoavcodec/tiff: Check the linearization table size
Michael Niedermayer [Wed, 19 Aug 2020 21:21:21 +0000 (23:21 +0200)]
avcodec/tiff: Check the linearization table size

Fixes: out of array access
Fixes: 24604/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4843529818603520
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 agoavcodec/libdav1d: Call ff_set_sar in addition to setting the frame SAR
Derek Buitenhuis [Tue, 25 Aug 2020 13:49:02 +0000 (14:49 +0100)]
avcodec/libdav1d: Call ff_set_sar in addition to setting the frame SAR

Similar to what we do in libaomdec.c.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
3 years agoavfilter/yadif: simplify the code for better readability
Limin Wang [Tue, 11 Aug 2020 16:21:54 +0000 (00:21 +0800)]
avfilter/yadif: simplify the code for better readability

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavformat/mpegtsenc: reindent the code
Limin Wang [Sun, 23 Aug 2020 15:32:31 +0000 (23:32 +0800)]
avformat/mpegtsenc: reindent the code

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavformat/mpegtsenc: add registration descriptor for AC-3 and EAC3
Limin Wang [Sun, 23 Aug 2020 15:02:31 +0000 (23:02 +0800)]
avformat/mpegtsenc: add registration descriptor for AC-3 and EAC3

Some DVB and ATSC captures are using the official MPEG2 registration
descriptor in addition to using the correct stream type and the
AC-3_audio_stream_descriptor/AC3_descriptor. So let's add it even if it is not
strictly needed for DVB/ATSC.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavfilter/af_amerge: Fix segfault upon allocation failure
Andreas Rheinhardt [Mon, 24 Aug 2020 03:46:08 +0000 (05:46 +0200)]
avfilter/af_amerge: Fix segfault upon allocation failure

The amerge filter uses a variable number of inpads and allocates them
in its init function; if all goes well, the number of inpads coincides
with a number stored in the filter's private context. Yet if allocating a
subsequent inpad fails, the uninit function nevertheless uses the number
stored in the private context to determine the number of inpads to free
and not the AVFilterContext's nb_inputs. This will lead to an access
beyond the end of the allocated AVFilterContext.input_pads array and
an invalid free.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/avfilter: Fix indentation
Andreas Rheinhardt [Fri, 21 Aug 2020 23:54:26 +0000 (01:54 +0200)]
avfilter/avfilter: Fix indentation

Forgotten after fdd93eabfb2644f541f7aac9943abce26776ea73.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cbs_av1: fix setting FrameWidth in frame_size_with_refs()
James Almer [Sun, 23 Aug 2020 23:45:12 +0000 (20:45 -0300)]
avcodec/cbs_av1: fix setting FrameWidth in frame_size_with_refs()

Section 5.9.7 of the spec states

    UpscaledWidth = RefUpscaledWidth[ ref_frame_idx[ i ] ]
    FrameWidth    = UpscaledWidth
    FrameHeight   = RefFrameHeight[ ref_frame_idx[ i ] ]
    RenderWidth   = RefRenderWidth[ ref_frame_idx[ i ] ]
    RenderHeight  = RefRenderHeight[ ref_frame_idx[ i ] ]

Meaning FrameWidth must not be set to RefFrameWidth[ ref_frame_idx[ i ] ]
like we're currently doing.

Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/av1_parser: fix parsing show_existing_frame headers
James Almer [Tue, 25 Aug 2020 18:01:43 +0000 (15:01 -0300)]
avcodec/av1_parser: fix parsing show_existing_frame headers

Regression since c8716b5029

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cbs_av1: use a more appropiate AV1ReferenceFrameState pointer variable name
James Almer [Tue, 25 Aug 2020 17:53:42 +0000 (14:53 -0300)]
avcodec/cbs_av1: use a more appropiate AV1ReferenceFrameState pointer variable name

frame is more commonly used for AV1RawFrameHeader and AV1RawFrame.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cbs_av1: fix handling reference frames on show_existing_frame frames
James Almer [Mon, 24 Aug 2020 16:04:23 +0000 (13:04 -0300)]
avcodec/cbs_av1: fix handling reference frames on show_existing_frame frames

Implement Section 7.21 "Reference frame loading process" and Section 7.20
"Reference frame update process" for show_existing_frame frames, as required by
the definition in Section 7.4 "Decode frame wrapup process".

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cbs_av1: infer frame_type in show_existing_frame frames earlier
James Almer [Mon, 24 Aug 2020 15:21:51 +0000 (12:21 -0300)]
avcodec/cbs_av1: infer frame_type in show_existing_frame frames earlier

This follows the spec and will come in handy in the next commit.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cbs_av1: add OrderHint to CodedBitstreamAV1Context
James Almer [Mon, 24 Aug 2020 15:37:23 +0000 (12:37 -0300)]
avcodec/cbs_av1: add OrderHint to CodedBitstreamAV1Context

This follows the spec and will come in handy in a following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agolavf/rtpdec_jpeg: Fix JFIF version.
Carl Eugen Hoyos [Thu, 21 May 2020 20:03:08 +0000 (22:03 +0200)]
lavf/rtpdec_jpeg: Fix JFIF version.

See also b1931321

3 years agodoc/examples: Always open files as "binary", not "text".
Carl Eugen Hoyos [Wed, 24 Jun 2020 22:01:36 +0000 (00:01 +0200)]
doc/examples: Always open files as "binary", not "text".

Fixes ticket #8638.

3 years agodnn/native: add log error message
Ting Fu [Tue, 25 Aug 2020 03:47:50 +0000 (11:47 +0800)]
dnn/native: add log error message

Signed-off-by: Ting Fu <ting.fu@intel.com>
3 years agodnn/native: unify error return to DNN_ERROR
Ting Fu [Tue, 25 Aug 2020 03:47:49 +0000 (11:47 +0800)]
dnn/native: unify error return to DNN_ERROR

Unify all error return as DNN_ERROR, in order to cease model executing
when return error in ff_dnn_execute_model_native layer_func.pf_exec

Signed-off-by: Ting Fu <ting.fu@intel.com>
3 years agodnn: move output name from DNNModel.set_input_output to DNNModule.execute_model
Guo, Yejun [Thu, 13 Aug 2020 08:19:48 +0000 (16:19 +0800)]
dnn: move output name from DNNModel.set_input_output to DNNModule.execute_model

currently, output is set both at DNNModel.set_input_output and
DNNModule.execute_model, it makes sense that the output name is
provided at model inference time so all the output info is set
at a single place.

and so DNNModel.set_input_output is renamed to DNNModel.set_input

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agolavfi/hflip: Support Bayer pixel formats.
Carl Eugen Hoyos [Sun, 26 Jul 2020 19:58:31 +0000 (21:58 +0200)]
lavfi/hflip: Support Bayer pixel formats.

Fixes part of ticket #8819.

3 years agolavf/mxfdec: Limit score for files with run-in.
Carl Eugen Hoyos [Mon, 24 Aug 2020 19:37:00 +0000 (21:37 +0200)]
lavf/mxfdec: Limit score for files with run-in.

Only return AVPROBE_SCORE_MAX if the header partition pack key
is at the start of the file.
Fixes ticket #8846.

Reviewed-by: Tomas Härdin
3 years agoavcodec/aacdec_template: add more checks to make sure only 22.2 gets to 22.2
Jan Ekström [Tue, 18 Aug 2020 17:49:00 +0000 (20:49 +0300)]
avcodec/aacdec_template: add more checks to make sure only 22.2 gets to 22.2

Validates the set channel layout as well as verifies that the received
layout to the function matches the reference layout, so that it matches
the implemented re-ordering logic.

Fixes #8845

3 years agoavcodec/aacdec_template: keep tabs on layout in sniff_channel_order
Jan Ekström [Tue, 18 Aug 2020 17:25:03 +0000 (20:25 +0300)]
avcodec/aacdec_template: keep tabs on layout in sniff_channel_order

This way the layout set at various points can be checked instead
of only having the layout at the end.