1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00
Commit Graph

102664 Commits

Author SHA1 Message Date
Andreas Rheinhardt
cbf6047c83 avcodec/frame_thread_encoder: Remove redundant memcpy
In case the underlying AVCodec has no private class, the private data
of both the main as well as each worker AVCodecContext is just zeroed
(the codec's init function has not been called on any of them and
without a private class there is no way to legitimately set anything
before the aforementioned init function).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:50 +02:00
Andreas Rheinhardt
3f6e715336 avcodec/frame_thread_encoder: Avoid dictionaries
avcodec_open2() allows to provide options via an AVDictionary;
but it is also allowed to set options by simply setting the value
of the AVCodecContext or via the AVOptions API if the codec has
a private class. Any options provided via an AVDictionary have already
been applied before ff_frame_thread_init(), so in order to copy
all the options from the main AVCodecContext and its private context,
it is enough to av_opt_copy() these options.

The current code does this, but it does more: It also copies the
user-provided AVDictionary and uses it for the initialization of
each of the worker-AVCodecContexts. This is completely unnecessary,
because said options have already been copied from the main context.

Furthermore, these options were also examined to decide if frame
threading should be used for huffman encoding in case this would incur
nondeterminism. This is wrong, because options not set via
an AVDictionary are ignored. Instead inspect the values stored in the
contexts directly. (In order to maintain the current behaviour, the
default value of the "non_deterministic" option has been changed to false,
because the absence of an entry with said key in the AVDictionary
had the consequence of disallowing nondeterminism.)

Finally, the AVDictionary has been removed from the signature of
ff_frame_thread_encoder_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:50 +02:00
Andreas Rheinhardt
56e9e0273a avcodec/encode: Always use intermediate buffer in ff_alloc_packet2()
Up until now, ff_alloc_packet2() has a min_size parameter:
It is supposed to be a lower bound on the final size of the packet
to allocate. If it is not too far from the upper bound (namely,
if it is at least half the upper bound), then ff_alloc_packet2()
already allocates the final, already refcounted packet; if it is
not, then the packet is not refcounted and its data only points to
a buffer owned by the AVCodecContext (in this case, the packet will
be made refcounted in encode_simple_internal() in libavcodec/encode.c).
The goal of this was to avoid data copies and intermediate buffers
if one has a precise lower bound.

Yet those encoders for which precise lower bounds exist have recently
been switched to ff_get_encode_buffer() (which automatically allocates
final buffers), leaving only two encoders to actually set the min_size
to something else than zero (namely aliaspixenc and hapenc). Both of
these encoders use a very low lower bound that is not helpful in any
nontrivial case.

This commit therefore removes the min_size parameter as well as the
codepath in ff_alloc_packet2() for the allocation of final buffers.
Furthermore, the function has been renamed to ff_alloc_packet() and
moved to encode.h alongside ff_get_encode_buffer().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:50 +02:00
Andreas Rheinhardt
4e5d2a819c avcodec/internal: Remove outdated documentation of ff_alloc_packet2()
Its documentation described the way user-supplied buffers worked
before 93016f5d1d.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:49 +02:00
Andreas Rheinhardt
7a57c5ab91 avcodec/omx: Zero packet padding
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:49 +02:00
Andreas Rheinhardt
964c826f55 avcodec/omx: Reindentation
Also combine two if blocks that check for the same condition
and don't check had_partial if we already have a complete packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:49 +02:00
Andreas Rheinhardt
eeedc8817a avcodec/omx: Remove remnants of old preallocated buffers
There are no preallocated buffer packets any more; this feature only
worked with the old encode API and only until said API was turned into
a wrapper for the new API in 93016f5d1d.
So remove its remnants.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:49 +02:00
Andreas Rheinhardt
835d8b7401 avcodec/dvenc: 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; this also makes it easy
to allow user-supplied buffers. Only one thing needed to be changed:
The earlier code relied on the buffer having been initially zeroed
by av_fast_padded_malloc(), so one now needs to zero the packet at
first.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:49 +02:00
Steven Liu
282b9f4cba avfilter/overlay_cuda: add hsub and vsub compute x and y positions
fix problem when set x to odd number in nv12 by cuda

test step:
1. ffmpeg -f lavfi testsrc2=s=176x144 -pix_fmt nv12 -t 1 output_overlay.yuv
2. ffmpeg -f lavfi testsrc2=s=352x288 -pix_fmt nv12 -t 1 output_main.yuv
before this patch:
overlay_cuda=x=0:y=0 will right,
overlay_cuda=x=3:y=0 will wrong,

both will right after patch.

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-06-07 17:02:36 +02:00
Timo Rothenpieler
8bcce5673a avcodec/nvenc: add option to disable all extra SEI data
With these triggering a lot of crashes recently, an option to globally
disable all of them is added as a tool to work around those crashes in
case the SEI data is not needed by the user.

Also re-enables s12m for hevc_nvenc, since the issue is not specifically
with that, but it affects all SEI data.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-06-06 22:01:56 +02:00
Timo Rothenpieler
c67f354be8 configure: detect nvcc without sm_30 support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-06-06 21:31:00 +02:00
Limin Wang
43295ae6a9 swscale/swscale_unscaled: don't use the optimized bgr24toYV12 unscaled conversion when width%2
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-06-06 12:34:05 +08:00
Michael Niedermayer
29b244ffc1 avformat/rpl: Use 64bit in bitrate computation and check it
Fixes: signed integer overflow: 777777776 * 4 cannot be represented in type 'int'
Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_RPL_fuzzer-6726188921913344

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-05 16:59:37 +02:00
Valerii Zapodovnikov
ff0d70c8a9 avfilter/vf_hqdn3d: fix left shift of negative numbers
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-05 16:59:37 +02:00
Guo Yejun
3ac7d99428 lavfi/dnn/dnn_io_proc.c: fix CID 1484955
CID 1484955:  Memory - corruptions  (ARRAY_VS_SINGLETON)
2021-06-05 17:15:29 +08:00
James Almer
ab4f299e23 fftools/ffmpeg: remove usage of internal timestamp AVStream fields
They should not be accessed outside of libavformat.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-06-04 22:36:39 -03:00
Timo Rothenpieler
57de80673c avcodec/nvenc: extract sei data prep into own function 2021-06-04 18:40:17 +02:00
Brad Hards
cee9f9628f avcodec/nvenc: write out user data unregistered SEI
Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-06-04 18:24:49 +02:00
Brad Hards
63948a6170 avcodec/nvenc: use persistent sei data buffer
Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-06-04 18:24:49 +02:00
Jin Bo
2fac1e370c 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>
2021-06-03 13:44:00 +02:00
Jin Bo
fd5fd48659 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>
2021-06-03 13:44:00 +02:00
Michael Niedermayer
864d1ef2fc 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>
2021-06-02 22:35:36 +02:00
Michael Niedermayer
06d23c6f3f 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>
2021-06-02 22:35:36 +02:00
Michael Niedermayer
996797f8ed avcodec/mpegvideo_enc: Reset stuffing bits if they are not supported
Fixes: Assertion failure
Fixes: Ticket8202

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-02 17:35:54 +02:00
Michael Niedermayer
c297f7e57a 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>
2021-06-02 17:30:24 +02:00
Michael Niedermayer
36dead4bc2 avcodec/aacpsy: Check bandwidth
Fixes: Ticket8011

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-02 17:30:24 +02:00
Michael Niedermayer
c520b98691 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>
2021-06-02 17:30:24 +02:00
Michael Niedermayer
4b89cf7aa4 avcodec/aacenc: Use FLT_EPSILON for lambda minimum 2021-06-02 17:30:24 +02:00
Valerii Zapodovnikov
6b1268f8c3 pixfmt: fixed wrong fix of comment
This mostly reverts 785bfb1d7b.
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>
2021-06-02 17:30:24 +02:00
Gyan Doshi
071930de72 avformat/mov: add option to use tfdt for fragment timestamps. 2021-06-02 10:46:04 +05:30
Joel Linn
127c40c9ca avcodec/movenc: fix spelling in warning message
hldr -> hdlr
2021-06-01 23:49:35 +05:30
Przemysław Sobala
575e52272d 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
2021-06-01 11:58:26 +05:30
James Almer
baf5cc5b7a avutil/mem: use GCC builtins to check for overflow in av_size_mult()
Signed-off-by: James Almer <jamrial@gmail.com>
2021-05-31 09:02:06 -03:00
Gyan Doshi
51f1194eda avformat/hls: relay format options to segment demuxer
Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
2021-05-30 09:21:19 +05:30
Timo Rothenpieler
8d0fea81c7 avcodec/nvenc: disable s12m timestamps by default
Leads to weird crashes with valid looking input data for otherwise
unknown reasons.
2021-05-29 22:59:57 +02:00
Philip Langdale
8f8a7e491d 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>
2021-05-29 13:21:18 -07:00
Philip Langdale
7885ab3036 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>
2021-05-29 13:21:18 -07:00
Michael Niedermayer
7971f62120 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>
2021-05-29 20:14:24 +02:00
Michael Niedermayer
82ad1b7675 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>
2021-05-29 20:14:24 +02:00
Michael Niedermayer
4c1afa2925 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>
2021-05-29 20:14:24 +02:00
Michael Niedermayer
38d18fb578 avcodec/lpc: Avoid floating point division by 0
Fixes: Ticket7996
Fixes: CVE-2020-20445

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-29 20:14:24 +02:00
Michael Niedermayer
223b5e8ac9 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>
2021-05-29 20:14:24 +02:00
Michael Niedermayer
a7a7f32c8a avcodec/aacenc: Avoid 0 lambda
Fixes: Ticket8003
Fixes: CVE-2020-20453

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-29 20:14:24 +02:00
Oneric
3300625c6f 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.
2021-05-29 11:32:23 +05:30
Jin Bo
ebedd26eef 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>
2021-05-28 17:31:21 +02:00
Shubhanshu Saxena
e41255cddb 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>
2021-05-28 08:40:07 +08:00
Tom Boshoven
8205f32663 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>
2021-05-27 17:43:40 +02:00
Michael Niedermayer
26d3c81bc5 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>
2021-05-27 17:43:40 +02:00
Michael Niedermayer
48342aa075 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>
2021-05-27 17:43:40 +02:00
Michael Niedermayer
b752d195cc 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>
2021-05-27 17:41:36 +02:00