ffmpeg.git
5 months agoavcodec/nvenc: extract sei data prep into own function
Timo Rothenpieler [Fri, 4 Jun 2021 16:40:17 +0000 (18:40 +0200)]
avcodec/nvenc: extract sei data prep into own function

5 months agoavcodec/nvenc: write out user data unregistered SEI
Brad Hards [Fri, 4 Jun 2021 14:06:38 +0000 (16:06 +0200)]
avcodec/nvenc: write out user data unregistered SEI

Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
5 months agoavcodec/nvenc: use persistent sei data buffer
Brad Hards [Tue, 25 May 2021 10:11:57 +0000 (20:11 +1000)]
avcodec/nvenc: use persistent sei data buffer

Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
5 months agolibavcodec/mips: Fix fate errors reported by clang
Jin Bo [Fri, 28 May 2021 02:04:41 +0000 (10:04 +0800)]
libavcodec/mips: Fix fate errors reported by clang

The data width of gsldrc1/gsldlc1 should be 8 bytes wide.

Signed-off-by: Jin Bo <jinbo@loongson.cn>
Reviewed-by: yinshiyou-hf@loongson.cn
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agolibavcodec/mips: Fix build errors reported by clang
Jin Bo [Tue, 1 Jun 2021 06:22:09 +0000 (14:22 +0800)]
libavcodec/mips: Fix build errors reported by clang

Clang is more strict on the type of asm operands, float or double
type variable should use constraint 'f', integer variable should
use constraint 'r'.

Signed-off-by: Jin Bo <jinbo@loongson.cn>
Reviewed-by: yinshiyou-hf@loongson.cn
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/jpeglsdec: force pal8 only once
Michael Niedermayer [Mon, 10 May 2021 19:36:18 +0000 (21:36 +0200)]
avcodec/jpeglsdec: force pal8 only once

Fixes: Infinite loop
Fixes: 33958/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-6590264069193728
Fixes: 33981/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-5343224173559808
Fixes: 33986/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-6598815122587648
Fixes: 34001/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-6171098111672320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/mjpegdec: Fix order of condition for pal8
Michael Niedermayer [Mon, 10 May 2021 19:30:35 +0000 (21:30 +0200)]
avcodec/mjpegdec: Fix order of condition for pal8

Fixes: out of array access
Fixes: 33960/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-5052852809629696
Fixes: 34163/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-6123678099177472

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/mpegvideo_enc: Reset stuffing bits if they are not supported
Michael Niedermayer [Sun, 30 May 2021 16:51:09 +0000 (18:51 +0200)]
avcodec/mpegvideo_enc: Reset stuffing bits if they are not supported

Fixes: Assertion failure
Fixes: Ticket8202

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/svq1enc: Do not print debug RD value before it has been computed
Michael Niedermayer [Sun, 30 May 2021 16:09:37 +0000 (18:09 +0200)]
avcodec/svq1enc: Do not print debug RD value before it has been computed

Avoids floating point division by 0

Fixes: Ticket8191

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/aacpsy: Check bandwidth
Michael Niedermayer [Sat, 29 May 2021 15:50:27 +0000 (17:50 +0200)]
avcodec/aacpsy: Check bandwidth

Fixes: Ticket8011

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/aacenc: Do not divide by lambda_count if it is 0
Michael Niedermayer [Sat, 29 May 2021 15:49:22 +0000 (17:49 +0200)]
avcodec/aacenc: Do not divide by lambda_count if it is 0

Avoids Floating point division by 0

Fixes: Ticket8011

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/aacenc: Use FLT_EPSILON for lambda minimum
Michael Niedermayer [Tue, 1 Jun 2021 08:07:05 +0000 (10:07 +0200)]
avcodec/aacenc: Use FLT_EPSILON for lambda minimum

5 months agopixfmt: fixed wrong fix of comment
Valerii Zapodovnikov [Mon, 31 May 2021 13:00:16 +0000 (16:00 +0300)]
pixfmt: fixed wrong fix of comment

This mostly reverts 785bfb1d7bb8de567c3aac1d9cc369b55ac9fb7b.
But I also added some clarifications so that nobody mixes primaries
with matrix again. SMPTE 240 and 170 primaires are the same, while
matrix coeff. are different, because 240 is derived from 170's new
primaries and white point while 170 uses BT.601 derived from BT.470
System M (yes, with Illuminant C) a.k.a. NTSC 1953. Some nits too.

Reviewed-by: Reto Kromer <lists@reto.ch>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavformat/mov: add option to use tfdt for fragment timestamps.
Gyan Doshi [Sat, 29 May 2021 08:57:34 +0000 (14:27 +0530)]
avformat/mov: add option to use tfdt for fragment timestamps.

5 months agoavcodec/movenc: fix spelling in warning message
Joel Linn [Tue, 1 Jun 2021 18:06:11 +0000 (20:06 +0200)]
avcodec/movenc: fix spelling in warning message

hldr -> hdlr

5 months agolavf/dashenc.c: Fix creating audio-only HLS playlists
Przemysław Sobala [Thu, 20 May 2021 09:50:27 +0000 (11:50 +0200)]
lavf/dashenc.c: Fix creating audio-only HLS playlists

With audio/video HLS playlists, audio chunklists are treated as
alternative renditions for video chunklists. This is wrong for
audio-only HLS playlists.

fixes: 9252

5 months agoavutil/mem: use GCC builtins to check for overflow in av_size_mult()
James Almer [Thu, 27 May 2021 14:58:57 +0000 (11:58 -0300)]
avutil/mem: use GCC builtins to check for overflow in av_size_mult()

Signed-off-by: James Almer <jamrial@gmail.com>
6 months agoavformat/hls: relay format options to segment demuxer
Gyan Doshi [Sat, 29 May 2021 09:57:18 +0000 (15:27 +0530)]
avformat/hls: relay format options to segment demuxer

Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
6 months agoavcodec/nvenc: disable s12m timestamps by default
Timo Rothenpieler [Sat, 29 May 2021 20:53:38 +0000 (22:53 +0200)]
avcodec/nvenc: disable s12m timestamps by default

Leads to weird crashes with valid looking input data for otherwise
unknown reasons.

6 months agoavfilter/yadif_cuda: Fix time base for large denominators
Philip Langdale [Sat, 29 May 2021 20:15:55 +0000 (13:15 -0700)]
avfilter/yadif_cuda: Fix time base for large denominators

This is the same fix applied to regular yadif.

Signed-off-by: Philip Langdale <philipl@overt.org>
6 months agoavfilter/bwdif: Fix time base for large denominators
Philip Langdale [Sat, 29 May 2021 20:19:26 +0000 (13:19 -0700)]
avfilter/bwdif: Fix time base for large denominators

This is the same fix applied to regular yadif.

Signed-off-by: Philip Langdale <philipl@overt.org>
6 months agoavfilter/vf_yadif: Fix handing of tiny images
Michael Niedermayer [Sat, 29 May 2021 09:17:35 +0000 (11:17 +0200)]
avfilter/vf_yadif: Fix handing of tiny images

Fixes: out of array access
Fixes: Ticket8240
Fixes: CVE-2020-22021

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
6 months agoavfilter/vf_vmafmotion: Check dimensions
Michael Niedermayer [Sat, 29 May 2021 07:58:31 +0000 (09:58 +0200)]
avfilter/vf_vmafmotion: Check dimensions

Fixes: out of array access
Fixes: Ticket8241
Fixes: Ticket8246
Fixes: CVE-2020-22019
Fixes: CVE-2020-22033

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
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>