Commit Graph

45972 Commits

Author SHA1 Message Date
Limin Wang
edd305ed54 avcodec/libopenh264enc: set iEntropyCodingModeFlag by coder option
For high/main profile, user can choose to use cavlc by specify "-coder cavlc",
for default, it'll will use cabac, if it's baseline, we'll use cavlc by specs anyway.

ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -coder cavlc -frames:v 1 -bsf trace_headers -f null -
before the patch:
entropy_coding_mode_flag                                    0 = 1

after the patch:
entropy_coding_mode_flag                                    0 = 0

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-01-14 22:00:19 +08:00
Limin Wang
f74e90c2a0 avcodec/libopenh264enc: make the profile configuablable correctly
due to the limitations set in d3a7bdd4ac,
you weren't able to use main profile with OpenH264 1.8, or high profile
with older versions

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-01-14 22:00:19 +08:00
Limin Wang
008cc90d1a avcodec/libopenh264enc: support for colorspace and range information
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-01-14 22:00:19 +08:00
Andreas Rheinhardt
46309f262c avcodec/vp3: Don't output bogus warning
It is perfectly fine to have from one to seven bits left
at the end of parsing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 21:00:26 +01:00
Andreas Rheinhardt
c936c319bd avcodec/mpegpicture: Decrease size of encoding_error array
The current size is AV_NUM_DATA_POINTERS (i.e. eight).
This number is chosen in order to minimize the amount of allocations
for AVFrame.extended_(data|buf) for audio; it is meaningless
for video for which four is sufficient. So decrease this array
in order to minimize what is copied in ff_mpeg_ref_picture()
and at the places that copy a whole MpegEncContext.

Also do the same for snowenc.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:31:02 +01:00
Andreas Rheinhardt
fbeb8eab44 avcodec/mpeg4videodec: Avoid multiple consecutive av_log()
These messages belong together, yet they can be torn apart
if some other call to av_log() happens between them.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:30:21 +01:00
Andreas Rheinhardt
b263415ab7 avcodec/mpegvideo: Don't set unrestricted_mv for decoders
It is write-only for them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:29:44 +01:00
Andreas Rheinhardt
3988016fa3 avcodec/h264pred: Reindentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:28:56 +01:00
Andreas Rheinhardt
c32f6b7f8a avcodec/h264pred: Remove dead > 8 pixels checks for 8bit codecs
RV40, SVQ3 and VP7/VP8 are eight-bit only, so it makes no sense
to check for them in the codepath initializing > eight bit contexts.
Move the codec-specific code to a switch located after the eight-bit
init code where this is easily possible; and add checks to the macro
to enable the compiler to remove the remaining checks when initializing
bitdepths > 8 at compile-time.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:27:52 +01:00
Andreas Rheinhardt
0a6e000d75 avcodec/h264pred: Don't compile > 8 bit versions of VP7/8 functions
VP7 and VP8 are eight bit only.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:26:39 +01:00
Andreas Rheinhardt
d0bf242d02 avcodec/h264_slice: Inline H264 codec id
This code is only reached by the H.264 decoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:26:26 +01:00
Andreas Rheinhardt
67cccd442f avcodec/svq3: Remove dead topright_samples_available variable, code
Topright samples are always available.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:26:13 +01:00
Andreas Rheinhardt
42d30c9019 avcodec/mpegvideo, svq3: Remove unused next_p_frame_damaged
Always zero since 4d2858deac.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:25:10 +01:00
Andreas Rheinhardt
75a3268bee avcodec/h264_slice, mpeg4videodec: Don't use %s to write single char
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:24:47 +01:00
Andreas Rheinhardt
c21433c953 avcodec/mpeg4video: Split off data in a header of its own
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-13 08:15:28 +01:00
Ming Qian
35a9307beb avcodec/v4l2_context: remove reinit variable
Cleanup after commit 3fc72c9fc1.
Fixes coverity ticket #1497095.

Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
2022-01-11 23:02:37 -05:00
Chen,Wenbin
e6b990e25d libavcodec/qsvdec.c: using queue count to unref frame
MSDK vc1 and av1 sometimes output frame into the same suface, but
ffmpeg-qsv assume the surface will be used only once, so it will
unref the frame when it receives the output surface. Now change
it to unref frame according to queue count.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-01-12 10:02:24 +08:00
James Almer
4b053b8db1 avcodec/av1dec: honor the requested skip_frame level
This supports dropping non-intra, non-key, or all frames.

Tested-by: nevcairiel
Signed-off-by: James Almer <jamrial@gmail.com>
2022-01-11 09:51:58 -03:00
James Almer
6c4074e423 avcodec/libdav1d: explicitly set Dav1dSettings.apply_grain
Don't depend on its default value being 1, as that could change anytime.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-01-10 12:20:48 -03:00
Anton Khirnov
55ccbfd790 lavc/flac_parser: use a custom FIFO implementation
FLAC parser currently uses AVFifoBuffer in a highly non-trivial manner,
modifying its "internals" (the whole struct is currently public, but no
other code touches its contents directly). E.g. it does not use any
av_fifo functions for reading the FIFO contents, but implements its own.

Reimplement the needed parts of the AVFifoBuffer API in the FLAC parser,
making it completely self-contained. This will allow us to make
AVFifoBuffer private.
2022-01-10 15:59:52 +01:00
Timo Rothenpieler
0b13c34a65 avcodec/nvenc: zero-initialize NV_ENC_REGISTER_RESOURCE struct 2022-01-10 15:41:50 +01:00
Linjie Fu
c39b6e1425 lavc/qsvenc: add return check for ff_qsv_map_pixfmt
Return an error directly if pixfmt is not supported for encoding, otherwise
it may be hidden until query/check in MSDK.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-01-10 14:54:36 +08:00
Ming Qian
3fc72c9fc1 avcodec/v4l2_context: send start decode command after dynamic resolution change event
Fixes decoding of sample https://streams.videolan.org/ffmpeg/incoming/720p60.mp4
on RPi4 after kernel driver commit:
staging: bcm2835-codec: Format changed should trigger drain

Reference:
linux/Documentation/userspace-api/media/v4l/dev-decoder.rst
    "A source change triggers an implicit decoder drain, similar to the
     explicit Drain sequence. The decoder is stopped after it completes.
     The decoding process must be resumed with either a pair of calls to
     VIDIOC_STREAMOFF and VIDIOC_STREAMON on the CAPTURE queue, or a call to
     VIDIOC_DECODER_CMD with the V4L2_DEC_CMD_START command."

Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
2022-01-09 11:14:37 -05:00
Ming Qian
df701ed0b5 avcodec/v4l2_context: don't reinit output queue on dynamic resolution change event
Reference:
linux/Documentation/userspace-api/media/v4l/dev-decoder.rst
    "During the resolution change sequence, the OUTPUT queue must remain
     streaming. Calling VIDIOC_STREAMOFF() on the OUTPUT queue would
     abort the sequence and initiate a seek.

     In principle, the OUTPUT queue operates separately from the CAPTURE
     queue and this remains true for the duration of the entire
     resolution change sequence as well."

Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
2022-01-09 11:14:37 -05:00
Andreas Rheinhardt
ebf1d0f4bb avcodec/avcodec: Remove outdated comment
avcodec_open2() is supposed to be thread-safe (those codecs
whose init functions are not thread-safe are guarded
by a global lock).

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09 09:46:30 +01:00
Andreas Rheinhardt
a88a141c17 avcodec: Remove unnecessary h263.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09 09:46:21 +01:00
Andreas Rheinhardt
e60debb93e avcodec/bitstream: Don't pretend VLCs to be initialized concurrently
Since the MPEG-4 parser no longer initializes some MPEG-4 VLCs,
no VLC is initialized concurrently by multiple threads
(initializing static VLCs is guarded by locks and nonstatic VLCs
never posed an issue in this regard). So remove the code
in bitstream.c that only exists because of this possibility.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09 09:39:09 +01:00
Andreas Rheinhardt
938251c878 avcodec/rl: Don't pretend ff_rl_init() initializes a RLTable twice
It can't any longer, because all users of ff_rl_init() are now
behind ff_thread_once() or the global codec lock. Therefore
the check for whether the RLTable is already initialized can be removed;
as can the stack buffers that existed to make sure that nothing is ever
set to a value different from its final value.
Similarly, it is not necessary to check whether the VLCs associated
with the RLTable are already initialized (they aren't).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09 09:38:43 +01:00
Andreas Rheinhardt
832ead2ec4 avcodec/mpeg4videodec: Fix data race when initializing VLCs
Both the MPEG-4 parser as well as the decoder initialized
several VLCs. There is a "static int done = 0;" in order to
guard against initializing these multiple times, but this does
not work when several threads try to initialize these VLCs
concurrently, which can happen when initializing several parsers
at the same time (they don't use the global lock that is used
for codecs without the FF_CODEC_CAP_INIT_THREADSAFE cap; actually,
they don't use any lock at all).

Since ff_mpeg4_decode_picture_header() now aborts early when called
from the parser, it no longer needs to have these VLCs initialized
at all. This commit therefore does exactly this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09 09:32:53 +01:00
Andreas Rheinhardt
f0194e860e avcodec/mpeg4video: Skip unneeded element when parsing picture header
Namely, skip some elements that are only useful for a decoder
when calling ff_mpeg4_decode_picture_header() from the MPEG-4 parser.

In particular, this ensures that the VLCs need no longer be
initialized by the parser.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09 09:30:36 +01:00
Andreas Rheinhardt
6739bb5a0e avcodec/h263: Move functions only used once to their caller
In this case it means moving ff_h263_pred_dc() resp. ff_h263_pred_acdc()
to ituh263enc.c resp. ituh263dec.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09 09:28:37 +01:00
Andreas Rheinhardt
de29d482f9 avcodec/mpegvideo: Avoid macro/av_calloc for ordinary allocations
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09 09:27:58 +01:00
Andreas Rheinhardt
4fc4cf4931 avcodec/mpegvideo: Don't unnecessarily allocate buffers
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09 09:26:57 +01:00
Andreas Rheinhardt
750c765ca4 avcodec/mpeg12dec: Don't set write-only variable
MpegEncContext.picture_number is write-only for MPEG-1/2 decoding.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-09 09:25:13 +01:00
Andreas Rheinhardt
ffb000fff8 avcodec/jpeglsdec: Avoid get_bits_long() where possible
It is possible here, because the values of ff_log2_run used
here are actually in the range 0..15 given that run_index is
in the range 0..31.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-08 18:17:40 +01:00
Martin Storsjö
24b93022fe aarch64: Disable ff_hevc_sao_band_filter_8x8_8_neon out of precaution
While this function on its own passes all of fate-hevc, there's
indications that the function might need to handle widths that
aren't a multiple of 8 (noted in commit
f63f9be37c, which later was
reverted).

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-01-07 22:33:27 +02:00
Martin Storsjö
16fba44b4d Revert "lavc/aarch64: add hevc sao edge 16x16"
This reverts commit a9214a2ca3, as
it breaks fate-hevc.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-01-07 22:33:23 +02:00
Martin Storsjö
df48b1d06f Revert "lavc/aarch64: add hevc sao edge 8x8"
This reverts commit c97ffc1a77, as
it breaks fate-hevc.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-01-07 22:33:19 +02:00
Martin Storsjö
cafed377eb Revert "lavc/aarch64: add hevc sao band 8x8 tiling"
This reverts commit f63f9be37c, as
it breaks fate-hevc.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-01-07 22:33:14 +02:00
Michael Niedermayer
0c9c9bbd01 avcodec/apedec: Fix integer overflows in predictor_update_3930()
Fixes: signed integer overflow: 1074134419 - -1075212485 cannot be represented in type 'int'
Fixes: 43273/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-4706880883130368

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-01-07 16:57:10 +01:00
Andreas Rheinhardt
72a822b975 avformat/takdec: Don't initialize get_bits context to read one value
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-07 11:55:57 +01:00
Fei Wang
7787cca180 lavc/av1dec: use frame split bsf
Split packed data in case of its contains multiple show frame in some
non-standard bitstream. This can benefit decoder which can decode
continuously instead of interrupt with unexpected error.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-01-07 14:05:58 +08:00
James Almer
3e17e0e5ef avcodec/libdav1d: honor the requested strict_std_compliance level on supported builds
Signed-off-by: James Almer <jamrial@gmail.com>
2022-01-06 22:57:46 -03:00
Andreas Rheinhardt
2b541b8c1d avcodec/golomb: Factor writing golomb codes out
Most users only want to either read or write golomb codes, not both.
By splitting these headers one avoids having unnecesssary
(get|put)_hits.h inclusions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-06 08:28:02 +01:00
Andreas Rheinhardt
df4cb384fb avcodec/Makefile: Add missing entry for ADPCM_IMA_AMV_ENCODER
Forgotten in 555f5c1fc5.

Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-06 08:12:28 +01:00
Andreas Rheinhardt
a2372f904c avcodec/Makefile: Only compile nvenc.o if needed
This fixes compilation errors in case nvenc is enabled
(e.g. autodected) with both nvenc-based encoders disabled
because nvenc uses ff_alloc_a53_sei(), yet only the nvenc-based
encoders require atsc_a53.
(This error does not manifest itself in case of static linking
(nothing pulls in nvenc.o), but it exists with shared builds.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2022-01-05 19:33:14 +01:00
Andreas Rheinhardt
aa8bb05d29 avcodec/Makefile: Add missing HEVC decoder->h274.o dependency
Forgotten in 3cc3f5de2a.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-05 14:41:39 +01:00
Andreas Rheinhardt
07fd34aca7 avcodec/Makefile: Add missing mpegaudiodata.o dependency to MPEGAUDIO
mpegaudiodec_template.c uses stuff from mpegaudiodata directly,
yet this dependency was only indirectly fulfilled via mpegaudio-headers
before 33e6d57f01. Since this commit,
the latter only needs (and therefore provides) mpegaudiotabs,
leading to compilation failures.
This commit adds this missing direct dependency directly.
(Sorry for not having checked indirect dependencies.)

Found-by: Zane van Iperen <zane@zanevaniperen.com>
Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-05 05:11:33 +01:00
Haihao Xiang
8d4c0c8823 lavc/qsvdec: needn't free the string for AV_OPT_TYPE_STRING AVOption
The string for AV_OPT_TYPE_STRING AVOption gets freed by av_opt_free()
when closing the AVCodecContext

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-01-05 11:05:06 +08:00
Haihao Xiang
0d82613b7d lavc/qsvenc: set base address for V plane
The SDK checks Data.V when using system memory for VP9 encoding. This
fixed the error below:

$ ffmpeg -qsv_device /dev/dri/renderD129 -f lavfi -i yuvtestsrc -c:v
vp9_qsv -f null -

[vp9_qsv @ 0x55b8387cbe90] Error during encoding: NULL pointer (-2)
Video encoding failed

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-01-05 11:05:06 +08:00