ffmpeg.git
6 months agoavformat/movenc: Check pal_size before use
Michael Niedermayer [Sat, 29 May 2021 07:22:27 +0000 (09:22 +0200)]
avformat/movenc: Check pal_size before use

Fixes: assertion failure
Fixes: out of array read
Fixes: Ticket8190
Fixes: CVE-2020-22015

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavcodec/lpc: Avoid floating point division by 0
Michael Niedermayer [Fri, 28 May 2021 18:31:19 +0000 (20:31 +0200)]
avcodec/lpc: Avoid floating point division by 0

Fixes: Ticket7996
Fixes: CVE-2020-20445

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavcodec/aacpsy: Avoid floating point division by 0 of norm_fac
Michael Niedermayer [Fri, 28 May 2021 18:18:25 +0000 (20:18 +0200)]
avcodec/aacpsy: Avoid floating point division by 0 of norm_fac

Fixes: Ticket7995
Fixes: CVE-2020-20446

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavcodec/aacenc: Avoid 0 lambda
Michael Niedermayer [Fri, 28 May 2021 19:37:26 +0000 (21:37 +0200)]
avcodec/aacenc: Avoid 0 lambda

Fixes: Ticket8003
Fixes: CVE-2020-20453

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavfilter/vf_subtitles: allow using embedded fonts
Oneric [Sun, 2 May 2021 21:02:02 +0000 (23:02 +0200)]
avfilter/vf_subtitles: allow using embedded fonts

ASS subtitles can have encoded fonts embedded into the subtitle file
itself. Allow libass to load those, to render subs as intended.

6 months agolibavcodec/mips: Fix specification of instruction name
Jin Bo [Fri, 28 May 2021 02:04:39 +0000 (10:04 +0800)]
libavcodec/mips: Fix specification of instruction name

1.'xor,or,and' to 'pxor,por,pand'. In the case of operating FPR,
  gcc supports both of them, clang only supports the second type.
2.'dsrl,srl' to 'ssrld,ssrlw'. In the case of operating FPR, gcc
  supports both of them, clang only supports the second type.

Signed-off-by: Jin Bo <jinbo@loongson.cn>
Reviewed-by: yinshiyou-hf@loongson.cn
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agolavfi/dnn_backend_openvino.c: Correct Pointer Type while Freeing
Shubhanshu Saxena [Thu, 27 May 2021 18:05:55 +0000 (23:35 +0530)]
lavfi/dnn_backend_openvino.c: Correct Pointer Type while Freeing

This commit corrects the type of pointer of elements from the
inference queue in ff_dnn_free_model_ov.

Signed-off-by: Shubhanshu Saxena <shubhanshu.e01@gmail.com>
6 months agoavfilter/yadif: Fix time base for large denominators
Tom Boshoven [Tue, 25 May 2021 15:57:08 +0000 (11:57 -0400)]
avfilter/yadif: Fix time base for large denominators

This fixes an issue where the yadif filter could cause the timebase denominator to overflow.

Signed-off-by: Tom Boshoven <tom@jwplayer.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavcodec/exr: More strictly check dc_count
Michael Niedermayer [Tue, 25 May 2021 17:29:18 +0000 (19:29 +0200)]
avcodec/exr: More strictly check dc_count

Fixes: out of array access
Fixes: exr/deneme

Found-by: Burak Çarıkçı <burakcarikci@crypttech.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavcodec/exr: x/ymax cannot be INT_MAX
Michael Niedermayer [Tue, 20 Apr 2021 18:24:21 +0000 (20:24 +0200)]
avcodec/exr: x/ymax cannot be INT_MAX

The code uses x/ymax + 1 so the maximum is INT_MAX-1

Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 33158/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5545462457303040

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavcodec/error_resilience: cleanup mpeg2 handling
Michael Niedermayer [Mon, 24 May 2021 18:29:10 +0000 (20:29 +0200)]
avcodec/error_resilience: cleanup mpeg2 handling

After this, the loop for the mpeg2 case is only executed when needed

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavformat/avio: Check av_opt_copy() for failure
Michael Niedermayer [Thu, 20 May 2021 19:16:52 +0000 (21:16 +0200)]
avformat/avio: Check av_opt_copy() for failure

Fixes: CID1477416 Unchecked return value

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavformat/moflex: Remove unneeded format variable
Michael Niedermayer [Thu, 20 May 2021 16:25:47 +0000 (18:25 +0200)]
avformat/moflex: Remove unneeded format variable

Fixes: CID1477423 Uninitialized scalar variable

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavutil/mem: check for max_alloc_size in av_fast_malloc()
James Almer [Sun, 23 May 2021 14:29:04 +0000 (11:29 -0300)]
avutil/mem: check for max_alloc_size in av_fast_malloc()

This puts av_fast_malloc*() in line with av_fast_realloc().

Signed-off-by: James Almer <jamrial@gmail.com>
6 months agoavutil/mem: make ff_fast_malloc() internal to mem.c
James Almer [Sun, 23 May 2021 14:24:17 +0000 (11:24 -0300)]
avutil/mem: make ff_fast_malloc() internal to mem.c

Signed-off-by: James Almer <jamrial@gmail.com>
6 months agoavcodec/utils: don't use ff_fast_mallocz() in av_fast_padded_malloc()
James Almer [Sun, 23 May 2021 14:18:18 +0000 (11:18 -0300)]
avcodec/utils: don't use ff_fast_mallocz() in av_fast_padded_malloc()

It will be removed in the next commit.

Signed-off-by: James Almer <jamrial@gmail.com>
6 months agolibavfilter: vf_drawtext filter support draw text with detection bounding boxes in...
Ting Fu [Fri, 14 May 2021 08:47:02 +0000 (16:47 +0800)]
libavfilter: vf_drawtext filter support draw text with detection bounding boxes in side_data

This feature can be used with dnn detection by setting vf_drawtext's option
text_source=side_data_detection_bboxes, for example:
./ffmpeg -i face.jpeg -vf dnn_detect=dnn_backend=openvino:model=face-detection-adas-0001.xml:\
input=data:output=detection_out:labels=face-detection-adas-0001.label,drawbox=box_source=
side_data_detection_bboxes,drawtext=text_source=side_data_detection_bboxes:fontcolor=green:\
fontsize=40, -y face_detect.jpeg
Please note, the default fontsize of vf_drawtext is 12, which may be too
small to be seen clearly.

Signed-off-by: Ting Fu <ting.fu@intel.com>
6 months agolibavfilter: vf_drawbox filter support draw box with detection bounding boxes in...
Ting Fu [Fri, 14 May 2021 08:47:01 +0000 (16:47 +0800)]
libavfilter: vf_drawbox filter support draw box with detection bounding boxes in side_data

This feature can be used with dnn detection by setting vf_drawbox's
option box_source=side_data_detection_bboxes, for example:
./ffmpeg -i face.jpeg -vf dnn_detect=dnn_backend=openvino:model=face-detection-adas-0001.xml:\
input=data:output=detection_out:labels=face-detection-adas-0001.label,\
drawbox=box_source=side_data_detection_bboxes -y face_detect.jpeg

Signed-off-by: Ting Fu <ting.fu@intel.com>
6 months agolavfi/drawbox: refine code
Ting Fu [Fri, 14 May 2021 08:47:00 +0000 (16:47 +0800)]
lavfi/drawbox: refine code

Extract common code of filter_frame() and drawgrid_filter_frame() to draw_region().

Signed-off-by: Ting Fu <ting.fu@intel.com>
6 months agolavfi/dnn: refine code to separate processing and detection in backends
Guo, Yejun [Mon, 17 May 2021 02:31:16 +0000 (10:31 +0800)]
lavfi/dnn: refine code to separate processing and detection in backends

6 months agolavfi/dnn_filter_common.h: make filter option 'options' as deprecated
Guo, Yejun [Mon, 17 May 2021 08:28:44 +0000 (16:28 +0800)]
lavfi/dnn_filter_common.h: make filter option 'options' as deprecated

we'd use 'backend_configs' to avoid confusion.

6 months agoavutil/mem: make max_alloc_size an atomic type
James Almer [Sat, 22 May 2021 21:03:10 +0000 (18:03 -0300)]
avutil/mem: make max_alloc_size an atomic type

Signed-off-by: James Almer <jamrial@gmail.com>
6 months agoavcodec/libxavs2: Allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libxavs2: Allow user-supplied buffers

Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/sbcenc: Avoid copying packet data, allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/sbcenc: Avoid copying packet data, allow user-supplied buffers

When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/pngenc: Avoid copying APNG data, allow user-supplied buffer
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/pngenc: Avoid copying APNG data, allow user-supplied buffer

The APNG encoder already uses internal buffers, so that the packet size
is already known before allocating the packet; therefore one can avoid
another (implicit) intermediate buffer by switching to
ff_get_encode_buffer(), thereby also supporting user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/pngenc: Remove always-true check
Andreas Rheinhardt [Tue, 11 May 2021 08:54:49 +0000 (10:54 +0200)]
avcodec/pngenc: Remove always-true check

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/flacenc: Avoid copying packet data, allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/flacenc: Avoid copying packet data, allow user-supplied buffers

The FLAC encoder calculates the size in advance, so one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/pamenc: Avoid copying packet data, allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/pamenc: Avoid copying packet data, allow user-supplied buffers

When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/pnmenc: Avoid intermediate buffer, allow user-supplied buffers
Andreas Rheinhardt [Tue, 11 May 2021 03:30:15 +0000 (05:30 +0200)]
avcodec/pnmenc: Avoid intermediate buffer, allow user-supplied buffers

For all p*m encoders a very sharp upper bound for the size of the
output packets is available before the packet is allocated. This can
be used to avoid an intermediate buffer when encoding by using
ff_get_encode_buffer() instead of ff_alloc_packet2() (without min_size);
this also adds support for user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libxavs: Improve returned error codes
Andreas Rheinhardt [Tue, 11 May 2021 03:16:24 +0000 (05:16 +0200)]
avcodec/libxavs: Improve returned error codes

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libxavs: Avoid overallocating, copying packet data
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libxavs: Avoid overallocating, copying packet data

When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data; also, there is no reason
to add AV_INPUT_BUFFER_MIN_SIZE to the packet size any more, as the
actually needed packet size can be easily calculated: It is three bytes
more than the raw nal size per NALU.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libx265: Allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libx265: Allow user-supplied buffers

Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libx264: Avoid copying data, allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libx264: Avoid copying data, allow user-supplied buffers

Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libwebpenc_animencoder: Allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libwebpenc_animencoder: Allow user-supplied buffers

Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libwebpenc: Allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libwebpenc: Allow user-supplied buffers

Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libvpxenc: Avoid one level of indentation
Andreas Rheinhardt [Tue, 27 Apr 2021 22:06:36 +0000 (00:06 +0200)]
avcodec/libvpxenc: Avoid one level of indentation

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libvpxenc: Avoid copying data, allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libvpxenc: Avoid copying data, allow user-supplied buffers

Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libvorbisenc: Avoid copying data, allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libvorbisenc: Avoid copying data, allow user-supplied buffers

Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libtheoraenc: Avoid copying data, allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libtheoraenc: Avoid copying data, allow user-supplied buffers

Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libshine: Avoid copying data, allow user-supplied buffer
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libshine: Avoid copying data, allow user-supplied buffer

The libshine encoder already uses an internal buffer, so that the
packet size is already known before allocating the packet; therefore
one can avoid another (implicit) intermediate buffer by switching
to ff_get_encode_buffer(), thereby also supporting user-supplied
buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libopenh264enc: Allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libopenh264enc: Allow user-supplied buffers

Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libmp3lame: Avoid copying data, allow user-supplied buffer
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libmp3lame: Avoid copying data, allow user-supplied buffer

The libmp3lame encoder already uses an internal buffer, so that the
packet size is already known before allocating the packet; therefore
one can avoid another (implicit) intermediate buffer by switching
to ff_get_encode_buffer(), thereby also supporting user-supplied
buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libkvazaar: Allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libkvazaar: Allow user-supplied buffers

Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libgsmenc: Avoid copying packet data, allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libgsmenc: Avoid copying packet data, allow user-supplied buffers

When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libcodec2: Avoid copying packet data, allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libcodec2: Avoid copying packet data, allow user-supplied buffers

When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/libaomenc: Avoid copying data, allow user-supplied buffers
Andreas Rheinhardt [Sat, 24 Apr 2021 23:43:26 +0000 (01:43 +0200)]
avcodec/libaomenc: Avoid copying data, allow user-supplied buffers

Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/audiotoolboxenc: Remove AV_CODEC_CAP_DR1
Andreas Rheinhardt [Sat, 15 May 2021 11:02:25 +0000 (13:02 +0200)]
avcodec/audiotoolboxenc: Remove AV_CODEC_CAP_DR1

It has been added in 2016 when this flag made no sense for encoders at
all; now that it makes sense, audiotoolboxenc doesn't support it,
despite claiming to do so.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavfilter/vf_guided: Don't needlessly copy properties, fix potential NPD
Andreas Rheinhardt [Fri, 14 May 2021 09:22:31 +0000 (11:22 +0200)]
avfilter/vf_guided: Don't needlessly copy properties, fix potential NPD

ref_frame is owned by the framesync structure and should therefore not
be modified; furthermore, these properties that are copied don't seem to
be used at all, so copying is unnecessary. Finally copying when the
destination frame is NULL gives a guaranteed segfault.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavfilter/vf_guided: Fix leak of frames
Andreas Rheinhardt [Fri, 14 May 2021 08:37:00 +0000 (10:37 +0200)]
avfilter/vf_guided: Fix leak of frames

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavfilter/vf_guided: Don't free frame we don't own
Andreas Rheinhardt [Fri, 14 May 2021 08:34:41 +0000 (10:34 +0200)]
avfilter/vf_guided: Don't free frame we don't own

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agodoc/encoders: update default coder for aac
Gyan Doshi [Sun, 23 May 2021 08:00:44 +0000 (13:30 +0530)]
doc/encoders: update default coder for aac

Changed in 660d1d8e3b.

6 months agoavio: do not export avpriv_io_{move,delete}
Anton Khirnov [Fri, 10 Jan 2020 11:18:29 +0000 (12:18 +0100)]
avio: do not export avpriv_io_{move,delete}

They are private and not used by anything outside of lavf. There is no
reason for them to be exported.

6 months agoaarch64: hevc_idct: Fix overflows in idct_dc
Martin Storsjö [Mon, 17 May 2021 09:48:03 +0000 (12:48 +0300)]
aarch64: hevc_idct: Fix overflows in idct_dc

This is marginally slower, but correct for all input values.
The previous implementation failed with certain input seeds, e.g.
"checkasm --test=hevc_idct 98".

Signed-off-by: Martin Storsjö <martin@martin.st>
6 months agofate-aac: use the fast coder for tests
Lynne [Fri, 21 May 2021 17:28:50 +0000 (19:28 +0200)]
fate-aac: use the fast coder for tests

The twoloop coder is highly loaded with (pseudo-)perceptual metrics,
and the aim of the tests is to piece-wise test each function of the
encoder, for which the 'fast' coder is perfect, since it only decides
on which scalefactors to use, rather than enable or disable encoder
features.

6 months agoaacenc: make the twoloop coder the default
Lynne [Fri, 21 May 2021 15:39:36 +0000 (17:39 +0200)]
aacenc: make the twoloop coder the default

This used to be the default, but was reverted as it was slower than
the 'fast' coder by around 25%.
Since our encoder is still not very good, change back to the twoloop
coder by default. It has much better rate control management as well,
making it closer to CBR, and it sounds much better.

6 months agoavformat/mpegtsenc: add NIT support
Ubaldo Porcheddu [Tue, 18 May 2021 11:56:00 +0000 (13:56 +0200)]
avformat/mpegtsenc: add NIT support

With some minor changes by Marton Balint:
 - removed trailing whitespace
 - fixed network_descriptors_length
 - fixed reserved_future_use flag in the start of the section
 - removed unused program variable
 - emit first NIT after PAT
 - some other cosmetics

Signed-off-by: Ubaldo Porcheddu <ubaldo@eja.it>
Signed-off-by: Marton Balint <cus@passwd.hu>
6 months agoavformat/flvdec: use milisecond precision for parsing timestamps
Marton Balint [Wed, 12 May 2021 18:26:54 +0000 (20:26 +0200)]
avformat/flvdec: use milisecond precision for parsing timestamps

Also use helper function to set the timestamp. Maybe we could also use
nanosecond precision, but there were some float rounding concerns.

Signed-off-by: Marton Balint <cus@passwd.hu>
6 months agoavcodec/vaapi_av1: pass full buffer size for each tile
Fei Wang [Wed, 19 May 2021 02:23:32 +0000 (10:23 +0800)]
avcodec/vaapi_av1: pass full buffer size for each tile

Previously, only the size of a given tile was passed, making the
offset and size marked in VASliceParameterBufferAV1 invalid with
multiple tiles.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
6 months agolibavformat/hlsenc: fix typos in comments
Valerii Zapodovnikov [Wed, 19 May 2021 15:33:40 +0000 (18:33 +0300)]
libavformat/hlsenc: fix typos in comments

6 months agoavfilter/avfiltergraph: Remove NULL checks after dereferences
Michael Niedermayer [Tue, 18 May 2021 20:03:11 +0000 (22:03 +0200)]
avfilter/avfiltergraph: Remove NULL checks after dereferences

Fixes: CID1398579 Dereference before null check
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agodoc/filters: note order of inputs for libvmaf
Gyan Doshi [Wed, 19 May 2021 09:20:00 +0000 (14:50 +0530)]
doc/filters: note order of inputs for libvmaf

6 months agoavcodec/videotoolboxenc: #define TARGET_CPU_ARM64 to 0 if not provided by the SDK
Zane van Iperen [Sat, 15 May 2021 09:33:52 +0000 (19:33 +1000)]
avcodec/videotoolboxenc: #define TARGET_CPU_ARM64 to 0 if not provided by the SDK

Fixes build failure on older SDKs without it.

Fixes #9242

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
6 months agoavformat/fifo: check for flushed packets and timeshift
Michael Niedermayer [Sun, 16 May 2021 19:18:09 +0000 (21:18 +0200)]
avformat/fifo: check for flushed packets and timeshift

Fixes: CID1464151 Dereference after null check

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavformat/framecrcenc: print basic side data information again
James Almer [Tue, 11 May 2021 20:07:41 +0000 (17:07 -0300)]
avformat/framecrcenc: print basic side data information again

This partially reverts c6ae560a18d67b9ddaa25a0338b7fb55e3312e57.

Signed-off-by: James Almer <jamrial@gmail.com>
6 months agolavfi/vf_dnn_processing.c: fix CID 1460603
Guo, Yejun [Tue, 11 May 2021 06:05:18 +0000 (14:05 +0800)]
lavfi/vf_dnn_processing.c: fix CID 1460603

CID 1460603 (#1 of 1): Improper use of negative value (NEGATIVE_RETURNS)

6 months agolavfi/dnn/dnn_io_proc.c: fix Improper use of negative value (NEGATIVE_RETURNS)
Guo, Yejun [Tue, 11 May 2021 05:46:49 +0000 (13:46 +0800)]
lavfi/dnn/dnn_io_proc.c: fix Improper use of negative value (NEGATIVE_RETURNS)

fix coverity CID 1473511 and 1473566

6 months agolavfi/dnn/dnn_io_proc.c: Fix Out-of-bounds access (ARRAY_VS_SINGLETON)
Guo, Yejun [Tue, 11 May 2021 04:31:02 +0000 (12:31 +0800)]
lavfi/dnn/dnn_io_proc.c: Fix Out-of-bounds access (ARRAY_VS_SINGLETON)

fix coverity CID 14735711473577 and 1482089

6 months agolavfi/dnn_backend_native_layer_mathunary.h: Documentation
Shubhanshu Saxena [Fri, 14 May 2021 07:11:08 +0000 (12:41 +0530)]
lavfi/dnn_backend_native_layer_mathunary.h: Documentation

Add documentation for Unary Math Layer

Signed-off-by: Shubhanshu Saxena <shubhanshu.e01@gmail.com>
6 months agolavfi/dnn_backend_native_layer_depth2space.h: Documentation
Shubhanshu Saxena [Fri, 14 May 2021 07:11:06 +0000 (12:41 +0530)]
lavfi/dnn_backend_native_layer_depth2space.h: Documentation

Add documentation for Depth to Space Layer

Signed-off-by: Shubhanshu Saxena <shubhanshu.e01@gmail.com>
6 months agolavfi/dnn_backend_native_layer_dense.h: Documentation
Shubhanshu Saxena [Fri, 14 May 2021 07:11:04 +0000 (12:41 +0530)]
lavfi/dnn_backend_native_layer_dense.h: Documentation

Add documentation for Dense Layer

Signed-off-by: Shubhanshu Saxena <shubhanshu.e01@gmail.com>
6 months agolavfi/dnn_backend_native_layer_conv2d.h: Documentation
Shubhanshu Saxena [Fri, 14 May 2021 07:11:02 +0000 (12:41 +0530)]
lavfi/dnn_backend_native_layer_conv2d.h: Documentation

Add documentation for 2D Convolution Layer

Signed-off-by: Shubhanshu Saxena <shubhanshu.e01@gmail.com>
6 months agoavfilter/metadata: add intuitive labels for metadata values
Gyan Doshi [Fri, 14 May 2021 10:20:30 +0000 (15:50 +0530)]
avfilter/metadata: add intuitive labels for metadata values

6 months agoavcodec/exrenc: Allow user-supplied buffers
Andreas Rheinhardt [Tue, 27 Apr 2021 14:58:16 +0000 (16:58 +0200)]
avcodec/exrenc: Allow user-supplied buffers

Trivial for an encoder that has a good estimate of the size of
the output packet in advance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/vc2enc: Allow user-supplied buffers
Andreas Rheinhardt [Tue, 27 Apr 2021 14:58:16 +0000 (16:58 +0200)]
avcodec/vc2enc: Allow user-supplied buffers

Trivial for an encoder that has a very good estimate of the size
of the output packet in advance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/jpeglsenc: Remove unnecessary header
Andreas Rheinhardt [Thu, 29 Apr 2021 18:34:00 +0000 (20:34 +0200)]
avcodec/jpeglsenc: Remove unnecessary header

Unnecessary since 130d89d786d29148deb846de48b16e11a894e8a7.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/jpeglsenc: Remove redundant implicit checks
Andreas Rheinhardt [Thu, 29 Apr 2021 13:31:46 +0000 (15:31 +0200)]
avcodec/jpeglsenc: Remove redundant implicit checks

Now that the proper buffer size is calculated (and checked) before
allocating the buffer, it is known that the buffer always suffices.
So use the unchecked PutBit-API; and also use an unchecked bitstream
reader as we check ourselves.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/jpeglsenc: Avoid intermediate buffer, allow user-supplied buffers
Andreas Rheinhardt [Thu, 29 Apr 2021 15:44:22 +0000 (17:44 +0200)]
avcodec/jpeglsenc: Avoid intermediate buffer, allow user-supplied buffers

Up until now, the JPEG-LS encoder allocated a worst-case-sized packet
at the beginning of each encode2 call; then it wrote the packet header
into its destination buffer and encoded the actual packet data;
said data is written into another worst-case-sized buffer, because it
needs to be escaped before being written into the packet buffer.
Finally, because the packet buffer is worst-case-sized, the generic
code copies the actually used part into a fresh buffer.

This commit changes this: Allocating the packet and writing the header
into it is deferred until the actual data has been encoded and its size
is known. This gives a good upper bound for the needed size of the packet
buffer (the upper bound might be 1/15 too large) and so one can avoid the
implicit intermediate buffer and support user-supplied buffers by using
ff_get_encode_buffer().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/jpeglsenc: Allocate buffer with fixed size only once
Andreas Rheinhardt [Thu, 29 Apr 2021 15:27:00 +0000 (17:27 +0200)]
avcodec/jpeglsenc: Allocate buffer with fixed size only once

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavcodec/jpeglsenc: Check for invalid dimensions
Andreas Rheinhardt [Thu, 29 Apr 2021 11:38:16 +0000 (13:38 +0200)]
avcodec/jpeglsenc: Check for invalid dimensions

The dimensions are written on two bytes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoRevert "avformat/hlsenc: compute video_keyframe_size after write keyframe"
Steven Liu [Sat, 1 May 2021 07:07:53 +0000 (15:07 +0800)]
Revert "avformat/hlsenc: compute video_keyframe_size after write keyframe"

This reverts commit b5ca8f2c66954614d81579082025f580efc0cffc.

This commit will make new problem about tickets: 9193,9205
It flush data into file with init file context together,
and it can get keyframe size, maybe need more method to get keyframe
size.

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
6 months agoavcodec/libx264: Fix redundant setting of caps_internal
Andreas Rheinhardt [Fri, 14 May 2021 10:59:07 +0000 (12:59 +0200)]
avcodec/libx264: Fix redundant setting of caps_internal

Exists since 8a129077cc37202a00dd666bd5365c3f61ea2e80.
Fixes a -Winitializer-overrides warning when building with Clang.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agodoc/filters: Unhedge note for sub option in guided filter
Gyan Doshi [Fri, 14 May 2021 10:09:47 +0000 (15:39 +0530)]
doc/filters: Unhedge note for sub option in guided filter

6 months agoavfilter/guided: reindent after 93ddb9b617
Gyan Doshi [Fri, 14 May 2021 10:07:45 +0000 (15:37 +0530)]
avfilter/guided: reindent after 93ddb9b617

6 months agoavfilter/guided: simplify subsampling assignment.
Gyan Doshi [Fri, 14 May 2021 03:39:49 +0000 (09:09 +0530)]
avfilter/guided: simplify subsampling assignment.

Reduce option ranges to effective values.

Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
6 months agofate: add a more extensive test for APNG_DISPOSE_OP_BACKGROUND
Anton Khirnov [Sat, 8 May 2021 11:07:56 +0000 (13:07 +0200)]
fate: add a more extensive test for APNG_DISPOSE_OP_BACKGROUND

Uses the sample from #9184.

6 months agolavc/pngdec: fix updating reference frames for APNG_DISPOSE_OP_BACKGROUND
Anton Khirnov [Sat, 8 May 2021 11:02:33 +0000 (13:02 +0200)]
lavc/pngdec: fix updating reference frames for APNG_DISPOSE_OP_BACKGROUND

They should be treated the same as APNG_DISPOSE_OP_NONE.

Broken in 5663301560.

Fixes #9184.

6 months agolavfi/dnn_backend_native_layer_avgpool.h: Documentation
Shubhanshu Saxena [Thu, 13 May 2021 07:04:19 +0000 (12:34 +0530)]
lavfi/dnn_backend_native_layer_avgpool.h: Documentation

Add documentation for Average Pool Layer

Signed-off-by: Shubhanshu Saxena <shubhanshu.e01@gmail.com>
6 months agoavcodec: remove leftover references to AVCodecContext.refcounted_frames
James Almer [Wed, 12 May 2021 13:25:43 +0000 (10:25 -0300)]
avcodec: remove leftover references to AVCodecContext.refcounted_frames

Signed-off-by: James Almer <jamrial@gmail.com>
6 months agoavcodec/allcodecs: Don't include libx264 twice in the list of codecs
Andreas Rheinhardt [Tue, 11 May 2021 01:14:30 +0000 (03:14 +0200)]
avcodec/allcodecs: Don't include libx264 twice in the list of codecs

Since a247ac640df3da573cd661065bf53f37863e2b46, allcodecs.c contained
two lines that matched the regex used by find_filters_extern in
configure; as a result, libx264 appeared twice the list of codecs
(if enabled).

Fix this by using only one matching line by adding a preprocessor define
for the part that differed in the two old lines: The const qualifier.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoavformat/utils: Fix NPD when allocating AVStreamInternal fails
Andreas Rheinhardt [Thu, 13 May 2021 20:06:02 +0000 (22:06 +0200)]
avformat/utils: Fix NPD when allocating AVStreamInternal fails

Regression since b9c5fdf6027010d15ee90a43aa023e45a5189097;
fixes Coverity ID #1484786.

Also remove the check for st->internal->parser as av_parser_close(NULL)
is a no-op.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
6 months agoffmpeg: return no chosen output if an uninitialized stream is unavailable
Jan Ekström [Thu, 6 May 2021 20:31:44 +0000 (23:31 +0300)]
ffmpeg: return no chosen output if an uninitialized stream is unavailable

Otherwise the rate emulation logic in `transcode_step` never gets
hit, and the unavailability flag never gets reset, leading to an
eternal loop with some rate emulation use cases.

This change was missed during the rework of ffmpeg.c, in which
encoder initialization was moved further down the time line in
commit 67be1ce0c6de330b1c10d1d121819d8a74a7b1f5 . Previously,
as the encoder initialization had happened earlier, this state was
not possible (flow getting as far as hitting the rate emulation logic,
yet not having the encoder initialized yet).

Fixes #9160

6 months agodoc/filters: correct name for guided filter
Gyan Doshi [Thu, 13 May 2021 13:35:12 +0000 (19:05 +0530)]
doc/filters: correct name for guided filter

Note input requirements and reword option sub description.

6 months agoRevert "avcodec/adpcm: Set vqa_version before use in init"
Michael Niedermayer [Thu, 13 May 2021 12:17:46 +0000 (14:17 +0200)]
Revert "avcodec/adpcm: Set vqa_version before use in init"

Redundant with ff946633a30e15415974c3f0ec7751c04eb91701.

Found-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This reverts commit 7a403da0cb8e5fe308fe307b7ed219110f7021e0.

6 months agoGSoC: Support fast guided filter.
Xuewei Meng [Mon, 10 May 2021 13:42:31 +0000 (21:42 +0800)]
GSoC: Support fast guided filter.

Two modes are supported in guided filter, basic mode and fast mode.
Basic mode is the initial pushed guided filter without optimization.
Fast mode is implemented based on the basic one by sub-sampling method.
The sub-sampling ratio which can be defined by users controls the
algorithm complexity. The larger the sub-sampling ratio, the lower
the algorithm complexity.

Signed-off-by: Xuewei Meng <xwmeng96@gmail.com>
Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
6 months agofix broken links to msdn documentation
Peter Ross [Tue, 20 Apr 2021 06:38:45 +0000 (16:38 +1000)]
fix broken links to msdn documentation

Signed-off-by: Peter Ross <pross@xvid.org>
6 months agoavcodec/clearvideo: Check for 0 tile_shift
Michael Niedermayer [Mon, 19 Apr 2021 14:46:08 +0000 (16:46 +0200)]
avcodec/clearvideo: Check for 0 tile_shift

Fixes: shift exponent -1 is negative
Fixes: 33401/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-5908683596890112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agotools/target_dec_fuzzer: Adjust threshold for TAK
Michael Niedermayer [Mon, 19 Apr 2021 14:42:25 +0000 (16:42 +0200)]
tools/target_dec_fuzzer: Adjust threshold for TAK

Fixes: Timeout
Fixes: 33346/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-4715352157192192

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavcodec/adpcm: Set vqa_version before use in init
Michael Niedermayer [Mon, 19 Apr 2021 14:20:55 +0000 (16:20 +0200)]
avcodec/adpcm: Set vqa_version before use in init

Fixes: null pointer dereference
Fixes: 33172/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_WS_fuzzer-5200164273913856

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavcodec/vc1: Check remaining bits in ff_vc1_parse_frame_header()
Michael Niedermayer [Mon, 19 Apr 2021 13:50:43 +0000 (15:50 +0200)]
avcodec/vc1: Check remaining bits in ff_vc1_parse_frame_header()

Fixes: Timeout
Fixes: 33156/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3_fuzzer-6259655027326976

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavformat/mov: Ignore duplicate CoLL
Michael Niedermayer [Mon, 19 Apr 2021 11:37:26 +0000 (13:37 +0200)]
avformat/mov: Ignore duplicate CoLL

Fixes: memleak
Fixes: 32146/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5377612845285376

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>