1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-02 03:06:28 +02:00
Commit Graph

106530 Commits

Author SHA1 Message Date
Paul B Mahol
55d414829c avfilter/af_ladspa: fix pts compensation if number of samples per frame is lower than latency 2022-04-07 09:39:55 +02:00
Paul B Mahol
4fbf3c828b avfilter/af_ladspa: compensate output pts if latency compensation is on 2022-04-06 16:59:45 +02:00
Wenbin Chen
fb88809063 libavcodec/qsvenc: Add more pixel format support to qsvenc
Qsv encoder only support input P010 and nv12 format directly from system
memory. For other format, we need to upload frame to device memory and
input qsv format to encoder. Now add other system memory format support
to qsv encoder.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
2022-04-06 17:12:26 +08:00
Wenbin Chen
e0ae810da3 libavcodec/qsvdec: Add more pixel format support to qsvdec
Qsv decoder only supports directly output nv12 and p010 to system
memory. For other format, we need to download frame from qsv format
to system memory. Now add other supported format to qsvdec.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
2022-04-06 17:12:26 +08:00
Wenbin Chen
0a0847dbac libavcodec/qsvdec: using suggested num to set init_pool_size
The init_pool_size is set to be 64 and it is too many.
Use IOSurfQuery to get NumFrameSuggest which is the suggested
number of frame that needed to be allocated when initializing the decoder.
Considering that the hevc_qsv encoder uses the  most frame buffer,
async is 4 (default) and max_b_frames is 8 (default) and decoder
may followed by VPP, use NumFrameSuggest + 16 to set init_pool_size.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Guangxin Xu <guangxin.xu@intel.com>
2022-04-06 17:12:26 +08:00
Wenbin Chen
4a633eb36f libavcodec/qsvdec: remove redundant decodeHeader()
Since ffmpeg-qsv uses return value to reinit decoder, it doesn't need to
decode header each time. Move qsv_decode_header's position so that
it will be called only if codec needed to be reinitialized.
Rearrange the code of flushing decoder and re-init decoder operation.
Remove the buffer_count and use the got_frame to decide whether the
decoder is drain.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Guangxin Xu <guangxin.xu@intel.com>
2022-04-06 17:12:26 +08:00
Wenbin Chen
40f38659d7 libavcodec/qsvdec: reinit decoder according to decode() return value
FFmpeg-qsv decoder reinit codec when width and height change, but there
are not only resolution change need to reinit codec. I change it to use
return value from DecodeFrameAsync() to decide whether decoder need to
be reinitialized.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Guangxin Xu <guangxin.xu@intel.com>
2022-04-06 17:12:26 +08:00
He, Fan F
ad21f26492 libavcodec/qsvenc: enable LowDelayBRC and MaxFrameSizeI/MaxFrameSizeP for more accurate bitrate control
Feature introduction of LowDelayBRC, MaxFrameSizeI and MaxFrameSizeP could be found here:
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md

Signed-off-by: Dmitry Ermilov <dmitry.ermilov@intel.com>
Signed-off-by: Fan F He <fan.f.he@intel.com>
2022-04-06 17:12:26 +08:00
Ingo Brückl
02111be0c1 libavutil/hwcontext_vaapi: Re-enable support for libva v1
Commit e050959103 implemented passing in
modifiers by using the PRIME_2 memory type, which only exists in v2 of
the library.

To still support v1 of the library, conditionally compile using
VA_CHECK_VERSION() for both the new code and the old code before
the commit.

Note PRIME_2 memory was introduced from VA-API 1.1, so use
VA_CHECK_VERSION(1, 1, 0) instead of VA_CHECK_VERSION(2, 0, 0) (Haihao)

Signed-off-by: Ingo Brückl <ib@wupperonline.de>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-04-06 17:12:26 +08:00
Stefano Sabatini
67c1078046 doc/fate: add note about showing test names and running a tests subset 2022-04-06 09:22:31 +02:00
Danil Chapovalov
706f12992d avcodec/libvpxenc: enable dynamic max quantizer reconfiguration
Signed-off-by: James Zern <jzern@google.com>
2022-04-05 17:38:52 -07:00
James Almer
c9ecbc08a1 tests: use a filtergraph script for fate-mov-channel-description
Should fix running the test on certain shells

Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-05 21:25:26 -03:00
Andreas Rheinhardt
24fd3ff5a2 avcodec/vp9_raw_reorder_bsf: Merge close and flush
Also mark the function as av_cold while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 22:19:50 +02:00
Andreas Rheinhardt
ebec607941 avcodec/vp9_raw_reorder_bsf: Fix leak of cached packet
In case the BSF has not been drained before flushing/closing,
the context's next_frame might be set; yet it is not freed
in flush or close. The former only zeroes it (which automatically
causes a leak in case it was set). So do this when closing
and flushing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 22:19:50 +02:00
Andreas Rheinhardt
a68a6322b7 avformat/mpegenc: Fix ever growing FIFO and infinite loop on error
Since the switch to the new FIFO API in commit
ea511196a6, the FIFO is always
grown by the amount of data intended to be written into it
even in case the FIFO has enough free space. Fix this by
only growing the FIFO if needed and then only by the amount that is
actually needed.

The allocation errors that resulted from this uncovered another bug:
The context is left in an inconsistent state in case the FIFO can't
be grown, because the FIFO does not contain as much data as the sizes
contained in the PacketDesc list claim. This led to an infinite loop
in output_packet() (called from mpeg_mux_end()).

Fix this by growing the FIFO before adding a new PacketDesc element,
thereby preventing the context from becoming inconsistent.

Reported-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 21:52:11 +02:00
Andreas Rheinhardt
6ed0d95fa2 avcodec/codec_internal: Constify AVPacket in decode_sub cb
No subtitle decoder ever modifies the AVPacket given to it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 20:02:47 +02:00
Andreas Rheinhardt
4243da4ff4 avcodec/codec_internal: Use union for FFCodec decode/encode callbacks
This is possible, because every given FFCodec has to implement
exactly one of these. Doing so decreases sizeof(FFCodec) and
therefore decreases the size of the binary.
Notice that in case of position-independent code the decrease
is in .data.rel.ro, so that this translates to decreased
memory consumption.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 20:02:37 +02:00
Andreas Rheinhardt
ce7dbd0481 avcodec/codec_internal: Make FFCodec.decode use AVFrame*
This increases type-safety by avoiding conversions from/through void*.
It also avoids the boilerplate "AVFrame *frame = data;" line
for non-subtitle decoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 19:54:09 +02:00
Andreas Rheinhardt
fb59a42ef9 avcodec/codec_internal: Add FFCodec.decode_sub
This increases type-safety by avoiding conversions from/through void*.
It also avoids the boilerplate "AVSubtitle *sub = data;" line
for subtitle decoders. Its only downside is that it increases
sizeof(FFCodec), yet this can be more than offset lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 19:53:27 +02:00
Andreas Rheinhardt
1c3c29d07d avcodec/options: Fix AVClassCategory of decoders with .receive_frame
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 19:46:51 +02:00
Paul B Mahol
21ca221068 avfilter/vsrc_gradients: add spiral type 2022-04-05 17:38:16 +02:00
Paul B Mahol
8e1cedbb61 avfilter/vsrc_gradients: add circular type 2022-04-05 17:38:16 +02:00
James Almer
cc6c5ff201 avcodec/libvpxenc: avoid unnecessary variable shadowing
Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-05 12:19:04 -03:00
Danil Chapovalov
53fd2d2203 avcodec/libvpxenc: return quantizer parameter for an encoded frame 2022-04-05 11:25:43 -03:00
James Almer
0e03807f69 fate: add a test for writing channel descriptions in mov
Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-05 09:19:59 -03:00
James Almer
7ccc910803 avformat/movenc: don't use mono layout when a front center label is expected
On output streams where a multichannel stream needs to be stored as one track
per channel, each track will have a channel layout describing the position of
the channel they contain. For the track with front center, the mov muxer was
using the mov layout "mono" instead of the label for the front center position.

Since our channel layout API considers front center == mono, we need to do some
heuristics. To achieve this, we make sure all audio tracks contain streams with
a single channel, and only one of them is front center. In that case, we write
the front center label instead of signaling mono layout.

Fixes the last part of ticket #2865

Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-05 09:19:59 -03:00
James Almer
feb3b44c1c avformat/mov_chan: move the definition of MovChannelLayoutTag to the header
Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-05 09:19:59 -03:00
James Almer
c2c5f34843 avformat/movenc: write channel descriptions when a known layout or a bitmap can't be used
Fixes part of ticket #2865

Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-05 09:19:59 -03:00
James Almer
b4373bc422 avformat/mov_chan: use a higher log level for a debug message
Trace is too noisy and this line is useful enough to get it printed
at debug level.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-05 09:19:58 -03:00
James Almer
603f2245d4 avformat/mov_chan: add a few missing channel label mappings
Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-05 09:19:58 -03:00
James Almer
90ef712de5 avformat/mov_chan: rename mov_get_channel_label() to better reflect its purpose
This function turns a mov channel label into a lavf native bitmask.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-05 09:19:58 -03:00
Paul B Mahol
854615adf2 avfilter/vf_mergeplanes: deprecate mapping option 2022-04-05 12:03:36 +02:00
Paul B Mahol
385bc756bf avfilter/vf_mergeplanes: add alternative for less user friendly option 2022-04-05 12:03:36 +02:00
Paul B Mahol
f92e4636fe avfilter/vf_mergeplanes: make map code more verbose 2022-04-05 12:03:36 +02:00
Paul B Mahol
e5189b1382 avfilter/vf_zscale: fix regression with src/dst_format initialization 2022-04-05 10:33:14 +02:00
Michael Niedermayer
1291568c98 avcodec/exr: Avoid signed overflow in displayWindow
The inputs are unused except for this computation so wraparound
does not give an attacker any extra values as they are already fully
controlled

Fixes: signed integer overflow: 0 - -2147483648 cannot be represented in type 'int'
Fixes: 45820/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5766159019933696

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-03 23:22:54 +02:00
Michael Niedermayer
7f1279684e avcodec/diracdec: avoid signed integer overflow in global mv
Fixes: signed integer overflow: -128275513086 * -76056576 cannot be represented in type 'long'
Fixes: 45818/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5129799149944832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-03 23:17:16 +02:00
Michael Niedermayer
01d8c887f6 avcodec/takdsp: Fix integer overflow in decorrelate_sf()
Fixes: signed integer overflow: -101 * 71041254 cannot be represented in type 'int'
Fixes: 45938/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-4687974320701440

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-03 23:16:24 +02:00
Michael Niedermayer
b085b400be avcodec/apedec: fix a integer overflow in long_filter_high_3800()
Fixes: signed integer overflow: -2146549696 - 3923884 cannot be represented in type 'int'
Fixes: 45907/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5992380584558592

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-03 23:16:12 +02:00
Thilo Borgmann
bb4e0f6162 lavfi/vf_siti.c: Relicense to LGPL 2.1 2022-04-02 13:14:00 +02:00
James Almer
5021b2ba06 avcodec/dfa: don't check for the bitstream version on every copied line
And use av_image_copy_plane() while at it to simplify things for
version != 0x100.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-02 00:24:44 -03:00
Andreas Rheinhardt
2b2380c098 avfilter: Constify non-const filters
This makes the filters match their declaration in
libavfilter/allfilters.c; the earlier discrepancy was btw UB.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-01 21:29:01 +02:00
Boris Baracaldo
80831e742b lavfilter: Add SITI filter
Calculate Spatial Info (SI) and Temporal Info (TI) scores for a video, as defined
in ITU-T P.910: Subjective video quality assessment methods for multimedia
applications.
2022-04-01 20:27:43 +02:00
Andreas Rheinhardt
451300d0e8 avcodec/mpegvideo_enc: Remove redundant unref+ref
Setting current_picture will already be done in frame_start().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-01 17:03:03 +02:00
Andreas Rheinhardt
37250f7f64 avcodec/mpegvideo: Make new_picture an ordinary AVFrame
It is currently a "Picture", an mpegvideo-specific type
that has a lot of baggage, all of which is unnecessary
for new_picture, because only its embedded AVFrame
is ever used. So just use an ordinary AVFrame.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-01 17:02:54 +02:00
Andreas Rheinhardt
88720f3d81 avcodec/mpegvideo: Remove strict_std_compliance from MpegEncContext
It just duplicates AVCodecContext.strict_std_compliance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-01 16:51:32 +02:00
Andreas Rheinhardt
046736f342 avcodec/speedhqenc: Add SpeedHQEncContext and move slice_start to it
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-01 16:14:10 +02:00
Andreas Rheinhardt
9b3279b201 avcodec/mjpegenc: Fix files with slices > 1, but threads == 1
In the aforementioned case mpegvideo_enc.c calls
ff_mjpeg_encode_stuffing() at the end of every line which
pads the output to byte-alignment and escapes it;
yet it does not write the restart-markers (and also not
the DRI marker when writing the header) and so the output files
are broken.

Fix this by writing these markers depending upon the number of
slices and not the number of threads in use; this also makes
the output of the encoder reproducible given a slice count
and is therefore important if encoder tests that actually use
-threads auto are added in the future.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-01 16:12:14 +02:00
Andreas Rheinhardt
f7d44804a6 avcodec/mjpegenc, speedhqenc: Remove nonsense assert
Our code for writing optimal huffman tables is incompatible
with using multiple slices and hence commit
884506dfe2 that implemented this
also added an assert that slice_context_count is always 1.

Yet this was always wrong: a) The MJPEG-encoder has (and had)
the AV_CODEC_CAP_SLICE_THREADS capability, so asserting that
it always uses one slice context is incorrect.
b) This commit did not add any proper checks that ensured that
optimal huffman tables are never used together with multiple slices.
This only happened with 03eb0515c1.
c) This assert is at the wrong place: ff_mjpeg_encode_init() is
called before the actual slice_context_count is set. This is
the reason why this assert was never triggered.

Therefore this commit removes this assert.
Also remove an assert from the SpeedHQ encoder sharing b) and c).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-01 16:10:33 +02:00
Andreas Rheinhardt
8ca4b515e7 avcodec/mpegvideo_enc: Allow slices only for slice-thread-able codecs
One can use slices without slice-threading. The results for
mpegvideo-encoders are abysmal: AMV, SpeedHQ, H.263, RV10, RV20,
MSMPEG4v2, MSMPEG4v3 and WMV1 produce broken files.
WMV2 meanwhile expects the MpegEncContext given to ff_wmv2_encode_mb()
to be at the beginning of a Wmv2Context (a structure that this encoder
shares with the WMV2 decoder), yet this is only true for the
main context and not for the slice contexts, leading to segfaults.
SpeedHQ additionally triggers an av_assert2, because it is not
byte-aligned at a position where it ought to be byte-aligned.

Given that no codec not supporting slice threading works this commit
disallows using slices unless the encoder supports slice threading.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-01 16:07:22 +02:00