Commit Graph

43170 Commits

Author SHA1 Message Date
Zachariah Brown
b18fd2b95b avcodec/nvenc: use framerate if available
The h264_nvenc and hevc_nvenc encoders aren't respecting the framerate in the codec context.
Instead it was using the timebase which in our use-case was 1/1000 so the encoder was behaving
as if we wanted 1000fps. This resulted in poor encoding results due to an extremely low bitrate.

Both the amf and qsv encoders already contain similar logic to first check the framerate before
falling back to the timebase.

Signed-off-by: Zachariah Brown <zachariah@renewedvision.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2020-05-15 00:44:31 +02:00
James Almer
b7d89963f0 avcodec/option_table: mark venc_params as a video decoder flag opt type
It's not meant for audio or subtitles, or for encoders of any kind.

Reviewed-by: mypopy@gmail.com <mypopy@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-14 18:43:29 -03:00
Limin Wang
b1cc6b9496 avcodec/mv30: fix warning: suggest braces around initialization of subobject [-Wmissing-braces]
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-14 09:15:25 +08:00
Martin Storsjö
353aecbb28 pixblockdsp, avdct: Add get_pixels_unaligned
Use this in vf_spp.c, where the get_pixels operation is done on
unaligned source addresses.

Hook up the x86 (mmx and sse) versions of get_pixels to this
function pointer, as those implementations seem to support unaligned
use.

This fixes fate-filter-spp on armv7.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-13 13:20:08 +03:00
Michael Niedermayer
b12b05374f avcodec/adpcm: Fix integer overflow in ADPCM THP
The reference (thp.txt) uses floats so wrap around would seem incorrect.

Fixes: signed integer overflow: 1073741824 + 1073741824 cannot be represented in type 'int'
Fixes: 20658/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_THP_fuzzer-5646302555930624

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-13 09:03:45 +02:00
Linjie Fu
e4d37abcc1 lavc/libopenh264enc: Add coder option to replace cabac
Set DEPRECATED flag to option cabac, replace with coder. The
priority logic is:
1. s->coder; then
2. avctx->coder_type; then
3. s->cabac.

Change the default option to -1 and allow the default cabac to be
determined by profile.

Add FF_API_OPENH264_CABAC macro for cabac to remove this option after
LIBAVCODEC_VERSION_MAJOR = 59.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-13 09:55:54 +08:00
Linjie Fu
e3e2702d40 lavc/libopenh264enc: Allow specifying the profile through AVCodecContext
And determine the profile with following priority:
1. s->profile; then
2. avctx->profile; then
3. s->cabac; then
4. a default profile.

This seems more natural in case user somehow sets both avctx->profile and
s->profile.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-13 09:55:47 +08:00
Linjie Fu
d3a7bdd4ac lavc/libopenh264enc: Rewrite profile handling
Support the profiles "constrained_baseline" and "high" for libopenh264
version >= 1.8, support "constrained_baseline" and "main" for earlier
version.

If option not supported with current version, convert to constrained
baseline with a warning for users.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-13 09:55:29 +08:00
Michael Niedermayer
f0c0471075 avcodec/ralf: Check num_blocks before use
Fixes: out of array access
Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5739471895265280

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-12 21:39:13 +02:00
Michael Niedermayer
a035fd88ae avcodec/iff: Test video_size being non zero
Fixes: Out of array access
Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5658548592967680
Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5723561177382912

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-12 21:39:13 +02:00
Michael Niedermayer
4d701e9222 avcodec/cdtoons: Check sprite_offset is within the packet
Fixes: out of array read
Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CDTOONS_fuzzer-5754518731227136

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>
2020-05-12 21:39:13 +02:00
Michael Niedermayer
19738b1bc2 libavcodec/decode: Mark decode_simple_internal() as inline
This was suggested in
https://github.com/google/oss-fuzz/issues/3787
to reduce the grouping errors by oss-fuzz

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-12 21:39:13 +02:00
Anton Khirnov
ffae62d96c vp9dec: support exporting QP tables through the AVVideoEncParams API 2020-05-12 09:37:47 +02:00
Anton Khirnov
c90f57c673 vp9dec: factorise freeing per-tile allocated data 2020-05-12 09:37:47 +02:00
Anton Khirnov
c584409643 lavc: add a flag for exporting AVVideoEncParams from decoders 2020-05-12 09:37:47 +02:00
Michael Niedermayer
876cfa67f3 avcodec/utvideodec: Fix integer overflow in decode_plane()
Fixes: signed integer overflow: 2147483594 + 142 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_fuzzer-5658568101724160

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-12 01:00:28 +02:00
Michael Niedermayer
8627885172 avcodec/ttadsp: Fix several integer overflows in tta_filter_process_c()
Fixes: signed integer overflow: 1931744255 + 252497024 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5763348114440192

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-12 01:00:28 +02:00
Michael Niedermayer
0c4330847c avcodec/ralf: Fix integer overflow in decode_block()
Fixes: signed integer overflow: 289082077 - -2003141111 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5196077752123392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-12 01:00:28 +02:00
Michael Niedermayer
1ac106bf56 avcodec/nuv: widen buf_size type
Fixes: signed integer overflow: 65312 * 65312 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NUV_fuzzer-5740176118906880

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-12 01:00:28 +02:00
Michael Niedermayer
7a92147f87 avcodec/iff: Fix several integer overflows
Fixes: negation of -2147483648 cannot be represented in type 'int32_t' (aka 'int'); cast to an unsigned type to negate this value to itself
Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int32_t' (aka 'int')
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5764066459254784

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-11 00:45:09 +02:00
Michael Niedermayer
82d4c7b95e avcodec/g729postfilter: Clip gain before scaling with AGC_FAC1
The fixed point integer reference specifies the multiplication used
to have 16bit input and clips so we need to clip the input
The floating point implementation does not seem to do that.

Fixes: signed integer overflow: 6317568 * 410 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G729_fuzzer-5700189272932352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-11 00:45:09 +02:00
Michael Niedermayer
22e51e95ac avcodec/alac: Fix integer overflow with 24/20bps samples
Fixes: signed integer overflow: 1020048 * 4096 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5753877751660544

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-11 00:45:09 +02:00
Michael Niedermayer
8ee264e684 avcodec/adpcm: Clip predictor for IMA_APM
Fixes: signed integer overflow: -2147483647 - 61436 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_APM_fuzzer-5092176004644864

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-11 00:45:09 +02:00
Michael Niedermayer
5727b1f13f avcodec/dstdec: Check sample rate
Fixes: out of array access
Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-5735812071424000

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>
2020-05-10 09:55:57 +02:00
James Almer
6dd5da3f8b avcodec/decode: remove unused AVCodecInternal compat_decode field
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-09 21:02:20 -03:00
Andriy Gelman
c76b2bf0b4 avcodec/v4l2_context: Finish draining if V4L2_BUF_FLAG_LAST is set
V4L2 api can indicate that flushing of the capture buffers is completed
by setting the V4L2_BUF_FLAG_LAST flag.
Use guards because the flag was only defined in Linux v4.2.

Reference:
linux/Documentation/media/uapi/v4l/dev-decoder.rst

    "The client must continue to handle both queues independently,
     similarly to normal decode operation. This includes:
     ...
     - queuing and dequeuing CAPTURE buffers, until a buffer marked with
       the V4L2_BUF_FLAG_LAST flag is dequeued"

Reviewed-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-05-09 19:35:05 -04:00
Andriy Gelman
e3b49aaa4e avcodec/v4l2_context: Drop empty packet while draining
v4l2_m2m devices may send an empty packet/frame while draining
to indicate that all capture buffers have been flushed.

Currently, the empty packet/frame is not handled correctly:
When encoding, the empty packet is forwarded to the muxer, usually
creating warnings.
When decoding, a reference to the memory is created anyway. Since in
the past this memory contained a decoded frame, it results in an extra
frame being decoded.

This commit discards the empty packet/frame.

References:
linux/Documentation/media/uapi/v4l/dev-decoder.rst:

    "The last buffer may be empty (with :c:type:`v4l2_buffer` bytesused = 0)
     and in that case it must be ignored by the client, as it does not
     contain a decoded frame."

linux/Documentation/media/uapi/media/v4l/vidioc-encoder-cmd.rst:

    "...This buffer may be empty, indicated by the
     driver setting the ``bytesused`` field to 0."

Reviewed-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-05-09 19:34:41 -04:00
Michael Niedermayer
785f194cd4 avcodec/aacdec_template: Pass AVCodecContext seperatly to set_default_channel_config()
Regression since 4d9b9c5e46
Fixes: Null pointer dereference
Fixes: 21642/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-5670101358739456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-10 01:09:13 +02:00
Michael Niedermayer
79e5c2ee2b avcodec/pngdec: Check length in fdAT
Fixes: 21089/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APNG_fuzzer-5135981419429888
Fixes: out of array read

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-10 01:09:13 +02:00
Michael Niedermayer
5501bb28dd avcodec/g2meet: Check tile_width in epic_jb_decode_tile()
Fixes: out of array access
Fixes: 21469/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-5199357982015488

Alternatively the arrays can be made bigger or the index can be clipped.
In case a real file with such huge tiles exist we ask the user to upload it.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-10 01:09:13 +02:00
Michael Niedermayer
81fe316ad9 avcodec/hapdec: Check tex_size more strictly and before using it
Fixes: OOM
Fixes: 20774/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5678608951803904
Fixes: 20956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5713643025203200

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-10 01:09:13 +02:00
Limin Wang
de7b690300 avcodec/mpegvideo: return more specific error codes for init_duplicate_context()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-09 09:33:49 +08:00
Limin Wang
18e2c0e732 avcodec/mpegvideo: return more specific error codes for ff_mpv_common_init()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-09 09:33:49 +08:00
Limin Wang
0032ca45ff avcodec/mpeg12enc: return more specific error codes for encode_init()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-09 09:33:49 +08:00
Limin Wang
14285e4ca2 avcodec/mpegvideo_enc: return more specific error codes for ff_mpv_encode_init()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-09 09:33:49 +08:00
Andreas Rheinhardt
6db97188d8 avcodec/(null|opus_metadata)_bsf: Use ff_bsf_get_packet_ref() directly
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-08 20:55:49 +02:00
Andreas Rheinhardt
47cd3c88c5 avcodec/bsf: Restrict ff_bsf_get_packet_ref() return values to <= 0
Up until now the documentation of ff_bsf_get_packet_ref() allowed return
values >= 0 in case of success, whereas av_bsf_receive_packet() only
allows 0 on success. Given that for some bitstream filters the return
value of ff_bsf_get_packet_ref() is forwarded to the caller of
av_bsf_receive_packet() without any filtering, there would be a problem
if ff_bsf_get_packet_ref() actually returned values > 0. But it
currently doesn't and there is no reason why it should ever do so.
Therefore this commit aligns the return values of these functions by
restricting ff_bsf_get_packet_ref() to always returns 0 on success.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-08 20:54:15 +02:00
Limin Wang
6825f7c0ba avcodec/mpegvideo_enc: reindent code
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-08 21:09:28 +08:00
Limin Wang
607b85f07e avcodec/zmbv: remove the unnecessary type conversion
Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-08 09:11:56 +08:00
Limin Wang
1b3d5090c5 avcodec/tiff: remove the unnecessary type conversion
Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-08 09:11:56 +08:00
Limin Wang
4cea39ad9b avcodec/pngdec: remove the unnecessary type conversion
Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-08 09:11:56 +08:00
Limin Wang
9d442102b9 avcodec/lcldec: remove the unnecessary type conversion
Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-08 09:11:56 +08:00
Limin Wang
8b07751123 avcodec/libx264: return error if unknown picture type encountered
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-08 06:42:25 +08:00
Limin Wang
f5e33514e7 avcodec/libx264: return immediately if encode_nals return 0
x264_encoder_encode can return 0 with nnal 0. As a result, encode_nals will
return 0. In this condition, it's better to return 0 immediately to avoid
the following unneeded pict_type and flags setting.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-08 06:42:25 +08:00
Limin Wang
d8e98d9348 avcodec/libx265: Fix Uninitialized scalar variable
return error if unknown picture type encountered

Fixes CID 1457234
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-08 06:42:25 +08:00
Marton Balint
2035620b7c avcodec/pcm_rechunk_bsf: add bitstream filter to rechunk pcm audio
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-07 23:12:24 +02:00
Limin Wang
a8d7393804 avcodec/profiles: remove duplicate FF_PROFILE_RESERVED entry
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-07 21:10:34 +08:00
Lynne
bdd57e2a37
lavc/bsf: add an Opus metadata bitstream filter
The only adjustable field is the gain. Some ripping/transcoding programs
have started to use it.
2020-05-05 22:25:33 +01:00
Michael Niedermayer
30f5d67510 avcodec/wavpack: Check rate_x and sample rate for overflow
Fixes: shift exponent 32 is too large for 32-bit type 'int'
Fixes: 21647/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVPACK_fuzzer-5686168323883008

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: David Bryant <david@wavpack.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-05 20:07:19 +02:00
James Almer
f90a48b72e avcodec/avpacket: add missing entry for prft to av_packet_side_data_name()
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-05 11:54:58 -03:00
Linjie Fu
9473268cfb lavc/vp9: fix reference frame dimensions check for SINGLE_REFERENCE mode
With the description in frame size with refs semantics (SPEC 7.2.5),
it is a requirement of bitstream conformance that for at least one
reference frame has the valid dimensions.

Modify the check to make sure the decoder works well in SINGLE_REFERENCE
mode that not all reference frames have valid dimensions.

Check and error out if invalid reference frame is used in inter_recon.

One of the failure case is a 480x272 inter frame (SINGLE_REFERENCE mode)
with following reference pool:

0.  960x544    LAST    valid
1. 1920x1088 GOLDEN  invalid, but not used in single reference mode
2. 1920x1088 ALTREF  invalid, but not used in single reference mode
3~7  ...     Unused

Identical logic in libvpx:
<https://github.com/webmproject/libvpx/blob/master/vp9/decoder/vp9_decodeframe.c#L736>

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2020-05-05 08:22:28 -04:00
Andriy Gelman
486ed509bc avcodec/v4l2_m2m_enc: Support changing qmin/qmax
Hard coded parameters for qmin and qmax are currently used to initialize
v4l2_m2m device. This commit uses values from avctx->{qmin,qmax} if they
are set.

Reviewed-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-05-05 00:49:42 -04:00
Limin Wang
79e3c4dd74 avcodec/utils: simplify, remove duplicate code
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-05 08:20:45 +08:00
Limin Wang
e468106269 avcodec/v4l2_m2m_enc: reindent code
Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-05 08:20:45 +08:00
Limin Wang
6d720b1aef avcodec/prores_metadata_bsf: Use AVCOL_TRC_NB - 1 for the valid max range
Report by Marton after commit.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-05 08:20:45 +08:00
Linjie Fu
2b32068916 lavc/vaapi_encode: add FF_CODEC_CAP_INIT_CLEANUP caps for encoders
ff_vaapi_encode_close() is not enough to free the resources like cbs
if initialization failure happens after codec->configure (except for
vp8/vp9).

We need to call avctx->codec->close() to deallocate, otherwise memory
leak happens.

Add FF_CODEC_CAP_INIT_CLEANUP for vaapi encoders and deallocate the
resources at free_and_end inside avcodec_open2().

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-04 12:33:30 -03:00
James Almer
3d51d3b42d avcodec/cbs_h265: add missing support for reserved_payload_extension_data SEI bits
Fixes ticket #8622

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-03 19:53:01 -03:00
James Almer
3a41bac4e2 avcodec/cbs_h265: move the payload_extension_present check into its own function
Will be reused in the following patch.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-03 19:53:01 -03:00
James Almer
bdfc1d3cd3 avcodec/cbs_h265: rename H265RawPSExtensionData to H265RawExtensionData
So that NAL types other than Parameter Set ones may use it.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-03 19:53:00 -03:00
Limin Wang
aa6d32ae43 Revert "avcodec/proresenc_anatoliy: support for more color matrix for proresenc"
This reverts commit e0eed1fd52.
2020-05-04 05:22:51 +08:00
Derek Buitenhuis
422f1e32ea avcodec/librav1e: Require a bitrate to be set when using 2-pass mode
Not requiring this leads to unexpected result, since Rav1e's current
two pass API has no way to fail in such a case.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-05-03 17:04:07 +01:00
James Almer
1a9684c08a avcodec/h265_metadata: filter parameter sets in packet side data
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-03 11:40:39 -03:00
James Almer
502dacdc50 avcodec/h264_metadata: filter parameter sets in packet side data
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-03 11:39:00 -03:00
James Almer
3921eed398 avcodec/av1_metadata: filter parameter sets in packet side data
Extradata included in packet side data is meant to replace the codec context
extradata. So when muxing for example to MP4 without this change and if
extradata is present in a packet side data, the result will be that the
parameter sets present in keyframes will be filtered, but the parameter sets
ultimately included in the av1C box will not.

This is especially important for AV1 as both currently supported encoders don't
export the Sequence Header in the codec context extradata, but as packet side
data instead.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-03 11:38:03 -03:00
Limin Wang
e0eed1fd52 avcodec/proresenc_anatoliy: support for more color matrix for proresenc
Please tested with below command:
./ffmpeg -i ../fate-suite/mpeg2/t.mpg  -c:v prores_aw -color_primaries bt2020 -colorspace bt2020_ncl -color_trc smpte2084 -an output.mov

mediainfo outout.mov
...
Color primaries                          : BT.2020
Transfer characteristics                 : PQ
Matrix coefficients                      : BT.2020 non-constant

./ffmpeg -i ../fate-suite/mpeg2/t.mpg  -c:v prores_aw -color_primaries bt2020 -colorspace bt2020_ncl -color_trc arib-std-b67 -an output.mov
mediainfo outout.mov
...
Color primaries                          : BT.2020
Transfer characteristics                 : HLG
Matrix coefficients                      : BT.2020 non-constant

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-03 05:28:33 +08:00
Limin Wang
d8bc4d23e3 avcodec/prores_metadata_bsf: add arib-std-b67 format support
It's based on the following specs:
RDD 45:2017 - SMPTE Registered Disclosure Doc - Interoperable Master Format - Application ProRes

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-03 05:28:33 +08:00
Limin Wang
2d17f43fe1 avcodec/prores_metadata_bsf: add smpte2084 format support
It's based on the following specs:
RDD 36:2015 - SMPTE Registered Disclosure Doc - Apple ProRes Bitstream Syntax and Decoding Process

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-03 05:28:33 +08:00
Limin Wang
f88a7aa49a avcodec/nvenc_hevc: add spatial-aq and temporal-aq option to consistent with nvenc_h264
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-03 05:28:33 +08:00
Limin Wang
4897ebb6ea avcodec/nvenc_h264: add spatial_aq and temporal_aq option to consistent with nvenc_hevc
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-03 05:28:33 +08:00
Marton Balint
425e08d571 avcodec/bsf: support shorthand options for av_bsf_list_parse_str
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-02 19:14:08 +02:00
Marton Balint
c96904f525 avcodec/decode: use a single list bsf for codec decode bsfs
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-02 19:14:08 +02:00
Michael Niedermayer
e16e3e63f0 avcodec/vp9dsp_template: Fix integer overflows in idct32_1d()
Fixes: signed integer overflow: -193177 * 11585 cannot be represented in type 'int'
Fixes: 20557/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP9_fuzzer-5704852816789504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-02 17:31:04 +02:00
Michael Niedermayer
49ae034b42 avcodec/alacdsp: Fix invalid shift in append_extra_bits()
Fixes: left shift of negative value -1
Fixes: 21390/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-6242539519868928

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-02 17:30:02 +02:00
Michael Niedermayer
62e4003780 libavcodec/wmalosslessdec: prevent sum of positive numbers from becoming negative
Fixes: left shift of negative value -8321365
Fixes: 20506/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-4798062906310656

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-02 17:29:23 +02:00
Michael Niedermayer
2d465a401d avcodec/dstdec: Fix integer overflow in read_table()
Fixes: signed integer overflow: -16 * 134217879 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-5639509530378240

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-02 17:28:06 +02:00
Carl Eugen Hoyos
0d81edcbba lavc/opus: Reset alloc_trim when doing decoder bit-allocation.
Fixes ticket #8649.
Reported-by: irc user Xogium
2020-05-02 10:51:55 +02:00
Timo Rothenpieler
9ce7de9038 avcodec/nvenc: refactor dts calculation logic
The old approach used some highly complex delta computation math and
output-delaying.
I do not remember what the initial reasoning behind that was, but given
that we can just offset the dts by the amount of bframes, it seems wholy
unnecessary.

This leaves open an issue with VFR content, for which some more complex
logic might be needed.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2020-05-02 01:33:49 +02:00
Piotr Oleszczyk
b9746fcbee ac3enc: fix AC3 downmix metadata issue
Due to a typo, it was impossible to write 0.595 / -4.5 dB
of ltrt_cmixlev, ltrt_surmixlev, loro_cmixlev, loro_surmixlev.
Without any error 0.841 / -1.5 dB was written to file.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-01 23:30:35 +02:00
Derek Buitenhuis
3c740f2d9f avcodec/librav1e: Use the framerate when available for ratecontrol
Rav1e currently uses the time base given to it only for ratecontrol... where
the inverse is taken and used as a framerate. So, do what we do in other wrappers
and use the framerate if we can.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-05-01 20:00:42 +01:00
Timo Rothenpieler
aaadf0dce8 avcodec/nvenc: offset dts to account for b-frame reordering
Fixes ticket #7303

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2020-05-01 20:52:36 +02:00
Limin Wang
1726eefec6 avcodec/mpeg12enc: Use FF_PROFILE_MPEG2_xxx macros
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-01 22:57:29 +08:00
James Almer
38d1815cc6 avcodec/cbs_h265: fix writing extension_data bits
We only care about the right most bit.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-30 16:28:01 -03:00
Andriy Gelman
2a9d623561 avcodec/v4l2_context: Log warning when all capture buffers are in userspace
v4l2_m2m uses device memory mapped buffers to store dequeued
frames/packets (reference counted by AVBufferRef). When the reference
count drops to zero, the buffer ownership is returned back to the
device, so that they can re-filled with frames/packets.

There are some cases when all the capture buffers are in userspace
(i.e. due to internal buffering in ffmpeg). On the s5p-mfc this causes
an infinite wait when polling to dequeue the buffers, which can be
prevented by increasing the total number of buffers. This commit adds a
warning when all the capture buffers are dequeued.

Reviewed-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-04-30 11:00:15 -04:00
Andreas Rheinhardt
8f51a89d66 avcodec/avpacket: Don't write into non-writable buffer
The data of an AVPacket may be a part of the data of an AVBufferRef;
Therefore av_grow_packet() doesn't reallocate if the available space in
the actual buffer is sufficient for the enlargement. But given that it
also zeroes the padding it also needs to make sure that the buffer is
actually writable; this commit implements this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-30 09:02:27 +02:00
Ming Qian
7afd34050c avcodec/v4l2_buffers: don't prevent enqueue capture buffer to driver
Enqueue/dequeue of the capture buffers should continue while draining.

Reference: linux/Documentation/media/uapi/v4l/dev-decoder.rst

    "The client must continue to handle both queues independently,
     similarly to normal decode operation. This includes:
     ...
     - queuing and dequeuing CAPTURE buffers, until a buffer marked with
       the V4L2_BUF_FLAG_LAST flag is dequeued"

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-04-29 21:55:35 -04:00
Michael Niedermayer
e444e5bb1a avcodec/tiff: assert that raw tiff dng blit does not write over the end of a line
Found-by: 黄宁 <tsukimurarin@163.com>
Reviewed-by: Nick Renieris <velocityra@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-29 23:42:37 +02:00
Michael Niedermayer
61e6eddc57 avcodec/tiff: Check for planar DNG images
The DNG code hardcodes plane 0 at some places, so its better to disallow cases
that have more planes.

Fixes: eg_crash
Found-by: 黄宁 <tsukimurarin@163.com>
Reviewed-by: Nick Renieris <velocityra@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-29 23:42:37 +02:00
Michael Niedermayer
f1ab6962ca avcodec/tiff: Replace width overriding for bayer by assert
This is less confusing

Reviewed-by: Nick Renieris <velocityra@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-29 23:42:36 +02:00
Michael Niedermayer
071e223129 avcodec/tiff: Some checks on bpp for DNG
dng spec 1.5.0.0
"BitsPerSample
Supported values are from 8 to 32 bits/sample. The depth must be the same for each sample if
SamplesPerPixel is not equal to 1."

Fixes: eg_crash
Found-by: 黄宁 <tsukimurarin@163.com>
Reviewed-by: Nick Renieris <velocityra@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-29 23:42:35 +02:00
Michael Niedermayer
aeb4e43584 avcodec/txd: Check for input size against the header size.
Fixes: Timeout (21sec -> 80ms)
Fixes: 20673/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TXD_fuzzer-5177453863763968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-29 23:33:33 +02:00
Michael Niedermayer
55e344ee5a avcodec/svq1dec: Check that there is data left after the header
Fixes: Timeout (21sec -> 255ms)
Fixes: 20709/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ1_fuzzer-5085075089915904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-29 23:31:02 +02:00
Linjie Fu
59a9204b8a lavc/libopenh264enc: set slice_mode option to deprecated
"slice mode" option seems to be unnecessary since it could be
determined by -slices/max_nal_size.

default:        SM_FIXEDSLCNUM_SLICE mode with cpu-number slices.
-slices N:      SM_FIXEDSLCNUM_SLICE mode with N slices.
-max_nal_size:  SM_SIZELIMITED_SLICE mode with limited size slices.

Add FF_API_OPENH264_SLICE_MODE macro to remove this option after
LIBAVCODEC_VERSION_MAJOR = 59.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-29 20:58:17 +03:00
Linjie Fu
9310361252 lavc/libopenh264enc: prompt slice number changing inside libopenh264
Libopenh264enc would set the slice according to the number of cpu cores
if uiSliceNum equals to 0 (auto) in SM_FIXEDSLCNUM_SLICE mode.

Prompt a warning for user to catch this.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-29 20:58:17 +03:00
Linjie Fu
75fc3f97b0 lavc/libopenh264enc: add bit rate control select support
RC_BITRATE_MODE:
    set BITS_EXCEEDED to iCurrentBitsLevel and allows QP adjust
    in RcCalculatePictureQp().

RC_BUFFERBASED_MODE:
    use buffer status to adjust the video quality.

RC_TIMESTAMP_MODE:
    bit rate control based on timestamp, introduced in release 1.4.

Default to use RC_QUALITY_MODE.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-29 20:58:17 +03:00
Linjie Fu
e5f097eca7 lavc/libopenh264enc: add default gop size and bit rate
It would be 200kbps bitrate with gop size = 12 by default
which generated too many IDR frames in rather low bit rate.
The quality would be poor.

Set these default values to -1 to check whether it's specified
by user explicitly.

Use 2Mbps bitrate as nvenc sugguested, and leave gop size
untouched in libopenh264.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-29 20:58:17 +03:00
Linjie Fu
433ece8c8b lavc/libopenh264enc: Add qmin/qmax support
Clip iMinQp/iMaxQp to (1, 51) for user specified qp range.

If not set, leave iMinQp/iMaxQp untouched and use the values (0, 51)
initialized in FillDefault(), and the QP range would be adjusted to the
defaults inside libopenh264 library according to the iUsageType, (12, 42)
for iUsageType == CAMERA_VIDEO_REAL_TIME which is default.

<https://github.com/cisco/openh264/blob/master/codec/encoder/core/src/encoder_ext.cpp#L375>

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-29 20:58:17 +03:00
Josh Brewster
79f001675a libavcodec/libx264: fix reference frame computation based on level
The current implementation allows passing levels to libavcodec as
integers (such as "31" instead of "3.1").

However, in this case, the maximum reference frame value per level was
ignored because libavcodec converted the string to 310 instead of 31.

Since libx264 has correctly parsed the level to int
(x4->params.i_level_idc), we should rely on this value instead of
attempting to parse the level string on our own.

Signed-off-by: Josh Brewster <josh.brewster@protonmail.com>
Signed-off-by: Josh de Kock <josh@itanimul.li>
2020-04-29 12:01:14 +01:00
Andriy Gelman
1cc3851b60 avcodec/v4l2_m2m_enc: Enable frame level rate control by default
Without this setting, bitrate and qmin/qmax options have no
effect on the s5p-mfc hardware encoder.

Reviewed-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-04-28 12:39:39 -04:00
Andriy Gelman
9b5001a494 avcodec/v4l2_m2m_enc: Reduce log verbosity for some params
Currently the user gets unhelpful warnings when some default parameters
are not supported by the device. The verbosity of these log messages has
been changed to AV_LOG_DEBUG.

Reviewed-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-04-28 12:39:19 -04:00
Mark Thompson
1dff97b7bc avcodec/nvenc: add hardware config metadata
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2020-04-27 23:06:06 +02:00
Mark Thompson
344e6c3ff1 lavc/vaapi_encode: Add hardware config metadata
These encoders all accept VAAPI surfaces in a hardware frames context.
2020-04-26 18:38:25 +01:00
Mark Thompson
5a1ff44907 lavc/qsvenc: Add hardware config metadata
All of these encoders can accept libmfx surfaces directly in a hardware
frames context, or they can accept software frames if a suitable device
is supplied to use.
2020-04-26 18:38:25 +01:00
Mark Thompson
858eba0ca4 lavc: Extend hardware config metadata to encoders 2020-04-26 18:38:25 +01:00
Mark Thompson
2594f6a362 lavc: Rename hwaccel.h to hwconfig.h
This already applied to decoders as well as hwaccels, and adding encoder
support was going to make the name even more inaccurate.
2020-04-26 18:38:25 +01:00
Michael Niedermayer
588114cea4 avcodec/cbs_h265_syntax_template: Check num_negative/positive_pics when inter_ref_pic_set_prediction_flag is set
Fixes: out of array access
Fixes: 20446/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-5707770718584832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-26 18:25:53 +02:00
Michael Niedermayer
0a9ccc2514 avcodec/intrax8: Check for end of bitstream in ff_intrax8_decode_picture()
Fixes: Timeout (105sec -> 1sec)
Fixes: 20479/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5769846937878528

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-26 18:23:16 +02:00
Michael Niedermayer
cca0436efc avcodec/dirac_vlc: Fix integer overflow in ff_dirac_golomb_read_32/16bit()
Fixes: left shift of 1073741824 by 1 places cannot be represented in type 'int32_t' (aka 'int')
Fixes: 21245/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5683334274613248

Change to int16_t suggested by Lynne

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-25 22:32:16 +02:00
Limin Wang
56b9130fff avcodec/bsf: simplify the code
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-25 20:39:25 +02:00
Peter Ross
1217b06a9b avcodec/vp9: prevent null pointer use on init_frames() failure
Signed-off-by: Peter Ross <pross@xvid.org>
Reviewed-by: James Almer <jamrial@gmail.com>
2020-04-25 12:11:11 +10:00
Zane van Iperen
3e22e738c0 avcodec: add support for Cunning Developments' ADPCM
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-24 19:43:04 +02:00
Andreas Rheinhardt
a501947a84 avcodec/mjpeg2jpeg_bsf: Remove unnecessary header
libavutil/mem.h is unneeded since 33d18982fa,
the commit that introduced the new packet-based bsf API, because with
this switch the allocations were no longer performed directly, but by
av_new_packet().

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-24 05:00:15 +02:00
Andreas Rheinhardt
88a37f0f5b avcodec/noise_bsf: Remove unnecessary headers
With 33d18982fa, the commit introducing
the new packet-based bsf API, a new buffer was no longer allocated
directly, but via av_new_packet(), so that libavutil/mem.h was no longer
needed.

Moreover since commit dc99ee6b08
av_packet_make_writable() is employed which copies the data in case it
is unavoidable so that string.h is no longer used (it was used for
memcpy()).

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-24 05:00:15 +02:00
Andreas Rheinhardt
60f9ecdccd avcodec/dump_extradata_bsf: Remove unnecessary header
Since 33d18982fa (the commit that
introduced the new bsf API) allocating an enlarged buffer in case
extradata needs to be added to a packet is done via av_new_packet(),
so that libavutil/mem.h is no longer needed.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-24 05:00:15 +02:00
Andreas Rheinhardt
6063b39e4d avcodec/dca_core_bsf: Remove unnecessary header
This bsf never needed libavutil/mem.h.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-24 05:00:15 +02:00
Andreas Rheinhardt
9f8dc586a0 avcodec/chomp_bsf: Remove unnecessary header
This bsf never needed internal.h.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-24 05:00:15 +02:00
Andreas Rheinhardt
cc489e43de avcodec/vp9_raw_reorder_bsf: Remove unnecessary header
This bsf doesn't have any options, so including libavutil/opt.h is
unnecessary.

Reviewed-by: Peter Ross <pross@xvid.org>
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-24 05:00:02 +02:00
Andreas Rheinhardt
6b0c94780d libavcodec/avpacket: Don't simply forward return value of av_dict_set()
The documentation of av_dict_set() states that values >= 0 indicate
success, whereas av_packet_unpack_dictionary() implies that return
values > 0 are impossible. So only forward the return value of
av_dict_set() in av_packet_unpack_dictionary() on error.

(Btw: av_dict_set() does currently not return values > 0.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-23 19:42:03 +02:00
Michael Niedermayer
ae2537f53e avcodec/hevc_mp4toannexb_bsf: Check nalu_size
Fixes: Timeout (29sec -> 5ms)
Fixes: 20237/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_MP4TOANNEXB_fuzzer-5165615044362240

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-23 19:30:07 +02:00
Gautam Ramakrishnan
e58766ba12 libavcodec/jpeg2000dec.c: ROI marker support
This patch adds support for decoding images
with a Region of Interest. Allows decoding
samples such as p0_03.j2k. This patch should
fix ticket #4681.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-23 19:30:07 +02:00
Jun Zhao
7fd70ad9e9 lavc/version: bump minor version for DOVI sidedata
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-04-23 08:06:30 +08:00
Jun Zhao
0e1db79e37 lavc: add a new sidedata type for DOVI
add a new sidedata type for DOVI.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-04-23 08:05:06 +08:00
Vitaly Buka
f163d30de2 mpeg4videoenc: Don't crash with -fsanitize=bounds
Also the patch makes this code consistent with mpeg4videodec.c

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-22 23:21:10 +02:00
Gautam Ramakrishnan
6bd4a26168 libavcodec/jpeg2000dec.c: Support for CRG marker
This patch adds support to skip the CRG marker.
The CRG marker, is an informational marker.
Allows samples such as p0_03.j2k to be decoded.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-22 22:57:38 +02:00
Michael Niedermayer
b4a33387cb avcodec/iff: Check length before memcpy() in decode_deep_rle32()
Fixes: out of array read
Fixes: 20796/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5111364702175232.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-22 22:57:38 +02:00
Michael Niedermayer
bc41a29a5a avcodec/iff: Fix invalid pointer intermediates in decode_deep_rle32()
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-22 22:57:38 +02:00
Michael Niedermayer
4c7bcaa385 avcodec/pngdec: Pass ret from decode_iccp_chunk()
Found while reviewing a patch fixing a similar issue

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-20 20:38:41 +02:00
Zane van Iperen
0bce55ac89 avcodec/adpcm: update get_nb_samples() doc
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-20 20:03:00 +02:00
Zane van Iperen
7150123aab avcodec/adpcm_ima_{apc, ssi, oki}: replace while() with for()
Per discussion at https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/260854.html

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-20 20:03:00 +02:00
James Almer
795ff53f18 avcodec/qpeg: mark the init function as thread-safe and init cleanup capable
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:46:37 -03:00
James Almer
18bb1d40c1 avcodec/qpeg: export missing frame properties
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:46:37 -03:00
James Almer
1b13023860 avcodec/qpeg: remove an unnecessary intermediary AVFrame
Decoding can be handled directly in the output frame.

Also ensure flushing cleans the reference frame in all cases.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:46:37 -03:00
Andreas Rheinhardt
ee593bff98 avcodec/bsf: Use macro for "packet is empty"
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 18:25:02 +02:00
Josh de Kock
bd2e7b74e1 lavc: stop using deprecated av_codec_next()
Signed-off-by: Josh de Kock <josh@itanimul.li>
2020-04-20 15:08:20 +00:00
qoroliang
cacdac819f lavc/hevcdec: fix the HEVC decoder crash when memory over-read
Fix an occasional crash for hevc decoder in ARM 32 platform, the
root cause is the memory over read(read cross the memory boundary)
in SAO NENO functions ff_hevc_sao_band_filter_neon_8 and
ff_hevc_sao_edge_filter_neon_8.

After this fix, the crash disapper in the massive Android phone
test.

Signed-off-by: qoroliang <qoroliang@tencent.com>
2020-04-20 10:28:04 +08:00
Andreas Rheinhardt
4bbf2a240f avcodec/truehd_core_bsf: Remove unused AVClass pointer
The context structure of the truehd_core bsf had a pointer to a const
AVClass as its first member; yet this bsf does not have any AVClass
associated with it, so that this pointer is always NULL. So remove it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-19 19:20:03 +02:00
Michael Niedermayer
13171ad2e3 avcodec/rv40dsp: Fix integer overflows in rv40_weight_func_*()
Fixes: signed integer overflow: 40550400 * 128 cannot be represented in type 'int'
Fixes: 20331/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV40_fuzzer-5676685725007872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-19 17:08:08 +02:00
Peter Ross
55d830f69a avcodec/pngdec: set return value on av_stereo3d_create_side_data() failure
Signed-off-by: Peter Ross <pross@xvid.org>
Reviewed-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2020-04-18 10:16:55 +10:00
Marton Balint
7d89445473 avcodec/bsf: use simplified algorithm for bsf_list chained filtering
Based on the one in ffmpeg.c and it is not using an extra flush_idx variable.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-17 21:26:55 +02:00
Peter Ross
1b59f3f844 avcodec/mv30: use aandcttables 2020-04-17 19:34:02 +10:00
Peter Ross
06dab51e68 avcodec/mv30: remove unused table elements 2020-04-17 19:34:02 +10:00
Peter Ross
3e5f0cf271 avcodec/vp3: fix indentation 2020-04-17 19:33:43 +10:00
James Almer
fccd6c2be0 avcodec: add a WebP parser
Based on code from the BMP parser.

Addresses ticket #8574

Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-16 15:05:07 -03:00
Michael Niedermayer
8e30502abe avcodec/ac3dec_fixed: Fix several invalid left shifts in scale_coefs()
Fixes: left shift of negative value -14336
Fixes: 20298/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AC3_FIXED_fuzzer-5675484201615360

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-16 00:56:49 +02:00
Michael Niedermayer
55f9683cf6 avcodec/flac_parser: Do not lose header count in find_headers_search()
Fixes: Timeout
Fixes: out of array access
Fixes: 20274/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-5649631988154368
Fixes: 19275/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-5757535722405888

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-16 00:56:49 +02:00
Michael Niedermayer
abb5762e98 avcodec/audiodsp: Fix integer overflow in scalarproduct_int16_c()
Fixes: signed integer overflow: 2145417478 + 76702564 cannot be represented in type 'int'
Fixes: 20313/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RA_144_fuzzer-5734487724130304

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-16 00:56:49 +02:00
Philip Langdale
22b25b3ea5 avcodec: Add explicit capability flag for encoder flushing
Previously, there was no way to flush an encoder such that after
draining, the encoder could be used again. We generally suggested
that clients teardown and replace the encoder instance in these
situations. However, for at least some hardware encoders, the cost of
this tear down/replace cycle is very high, which can get in the way of
some use-cases - for example: segmented encoding with nvenc.

To help address that use case, we added support for calling
avcodec_flush_buffers() to nvenc and things worked in practice,
although it was not clearly documented as to whether this should work
or not. There was only one previous example of an encoder implementing
the flush callback (audiotoolboxenc) and it's unclear if that was
intentional or not. However, it was clear that calling
avocdec_flush_buffers() on any other encoder would leave the encoder in
an undefined state, and that's not great.

As part of cleaning this up, this change introduces a formal capability
flag for encoders that support flushing and ensures a flush call is a
no-op for any other encoder. This allows client code to check if it is
meaningful to call flush on an encoder before actually doing it.

I have not attempted to separate the steps taken inside
avcodec_flush_buffers() because it's not doing anything that's wrong
for an encoder. But I did add a sanity check to reject attempts to
flush a frame threaded encoder because I couldn't wrap my head around
whether that code path was actually safe or not. As this combination
doesn't exist today, we'll deal with it if it ever comes up.
2020-04-15 14:54:42 -07:00
Carl Eugen Hoyos
d727fea4da lavc/jpeg2000dec: Cosmetics, re-indent after last commit. 2020-04-15 20:03:33 +02:00
Carl Eugen Hoyos
cbe3f1b1fb lavc/jpeg2000dec: Allow to force a compatible pix_fmt.
This copies the behaviour of the libopenjpeg decoder.
Fixes ticket #5919.
2020-04-15 20:00:51 +02:00
Michael Niedermayer
18f5256c0d avcodec/cbs_jpeg_syntax_template: Check array index in huffman_table()
Fixes: index 224 out of bounds for type 'uint8_t [224]'
Fixes: 21534/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-6291612167831552

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-15 18:48:23 +02:00
Michael Niedermayer
d31862c2b1 avcodec/cbs_jpeg_syntax_template: Check table index before use in dht()
Fixes: out of array access
Fixes: 21515/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5766121576988672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-15 18:48:23 +02:00
Matthieu Bouron
5216edbc54 avcodec/mediacodec_wrapper: fix {input,output}_buffers global reference leak
Fixes ticket #8607.

Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
2020-04-15 09:43:16 +02:00
Ming Qian
8ac8e905e9 avcodec/v4l2_m2m: handle v4l2 end of stream event
When flushing the capture buffers, the driver may send a V4L2_EVENT_EOS
to notify that draining is completed. Currently, v4l2_m2m does not
subscribe to this event, which can cause some devices (i.e. imx8qm) to
hang at the end of encoding/decoding. Support for handling the event is
added in this commit.

Some devices may not signal V4L2_EVENT_EOS. This is logged as a warning
message during initialization and not treated as a fatal error.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-04-14 23:42:05 -04:00
Linjie Fu
798ab1d03e lavc/vaapi_decode: fix the build failure when hevc_vaapi is disabled
Verified with ./configure --enable-vaapi --disable-hwaccel=hevc_vaapi

Failure reported in:
http://fate.ffmpeg.org/report.cgi?time=20200401135031&slot=x86_64-archlinux-gcc-random

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-04-13 14:14:52 +01:00
Andreas Rheinhardt
14dd0a9057 avcodec/cbs: Avoid leaving the ... out in calls to variadic macros
According to C99, there has to be at least one argument for every ...
in a variadic function-like macro. In practice most (all?) compilers also
allow to leave it completely out, but it is nevertheless required: In a
variadic macro "there shall be more arguments in the invocation than there
are parameters in the macro definition (excluding the ...)." (C99,
6.10.3.4).

CBS (not the framework itself, but the macros used in the
cbs_*_syntax_template.c files) relies on the compiler allowing to leave
a variadic macro argument out. This leads to warnings when compiling in
-pedantic mode, e.g. "warning: must specify at least one argument for
'...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]"
from Clang.

Most of these warnings can be easily avoided: The syntax_templates
mostly contain helper macros that expand to more complex variadic macros
and these helper macros often omit an argument for the .... Modifying
them to always expand to complex macros with an empty argument for the
... at the end fixes most of these warnings: The number of warnings went
down from 400 to 0 for cbs_av1, from 1114 to 32 for cbs_h2645, from 38 to
0 for cbs_jpeg, from 166 to 0 for cbs_mpeg2 and from 110 to 8 for cbs_vp9.

These eight remaining warnings for cbs_vp9 have been fixed by switching
to another macro in cbs_vp9_syntax_template: The fixed values for the
sync bytes as well as the trailing bits for byte-alignment are now read
via the fixed() macro (this also adds a check to ensure that trailing
bits are indeed zero as they have to be).

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-12 23:23:49 +02:00
Rosen Penev
4fa4ab97f9 avcodec/mips: fix get_cabac_inline_mips function name
On other platforms, the functions are named get_cabac_inline_xxx but not
this one. There's also a define.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-12 16:36:47 +02:00
James Zern
0ece80559a avcodec/libaomenc,cosmetics: fix a typo
tradeof -> trade-off

Signed-off-by: James Zern <jzern@google.com>
2020-04-11 15:22:35 -07:00
Wang Cao
bd3389e9f4 avcodec/libaomenc.c: Add a libaom command-line option 'tune'
Signed-off-by: Wang Cao <wangcao@google.com>
Signed-off-by: James Zern <jzern@google.com>
2020-04-11 15:12:34 -07:00
Michael Niedermayer
20ade59d96 avcodec/dpcm: clip exponent into supported range in XAN DPCM
Fixes: shift exponent 32 is too large for 32-bit type 'int'
Fixes: 21200/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XAN_DPCM_fuzzer-5754704894361600

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-11 18:15:58 +02:00
Gautam Ramakrishnan
995d937827 libavcodec/jpeg2000: fix precinct coordinate calculation
The calculation of precinct boundaries has been
fixed. The precinct boundaries were calculated
as an offset to the band boundary, but must
instead be calculated as an offset from the
reslevel. This patch fixes #4669 and #4679.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-11 18:15:58 +02:00
Gautam Ramakrishnan
e8344f21e1 libavcodec/jpeg2000dec.c: fix error in cod marker
This patch fixes an error where the COC marker
overrides all data of the SPcod field of the
COD marker. It must override only one bit of
SPcod field. This now allows p0_08.j2k to be
decoded correctly (mentioned in #4679).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-11 18:15:58 +02:00
Andreas Rheinhardt
12a5e0409d avcodec/ac3_tab: Zero-terminate ff_ac3_sample_rate_tab
This is required to use it as an AVCodec.supported_samplerates array.
Adding the sentinel has been forgotten in 4679a474.
Without it e.g. the FATE-test ffmpeg-filter_complex_audio fails with ASAN.

Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-11 17:13:36 +02:00
Zane van Iperen
67c4405fac avcodec/adpcm: remove unused shift parameter from adpcm_ima_qt_expand_nibble()
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-04-11 17:01:18 +02:00
Carl Eugen Hoyos
5325423437 lavc/amrwbdec: Add a comment about the missing muting technique. 2020-04-11 14:23:51 +02:00
Carl Eugen Hoyos
e426f71c96 lavc/amrwbdec: Output silence for frames marked as corrupt.
Fixes ticket #7113.
2020-04-11 14:10:45 +02:00
Carl Eugen Hoyos
8f01fa378f lavc/amrwbdec: Remove a dead comparison.
Modes > MODE_SID are already filtered out at this point.
Simplifies the following change.
2020-04-11 14:08:49 +02:00
Rosen Penev
875ba23333 avcodec/aacdec: fix compilation under soft float MIPS
Place HAVE_MIPSFPU further up so that functions that use floating point
ASM are defined away. Otherwise compilation failures result when soft
float in enabled on the toolchain.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-11 14:00:32 +02:00
John Stebbins
fa736a994c lavc/xsubenc: return meaningfull error codes
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 15:58:04 -07:00
John Stebbins
5fcf620eee lavc/webvttenc: return more meaningful error codes
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 15:58:04 -07:00
John Stebbins
9ac715a367 lavc/srtenc: return more meaninful error codes
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 15:58:04 -07:00
John Stebbins
1d544e410e lavc/movtextenc: return more meaningful error codes
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 15:58:04 -07:00
John Stebbins
9a0817baa4 lavc/assenc: return more meaningful error code
When the buffer is too small, return AVERROR_BUFFER_TOO_SMALL

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 15:58:04 -07:00
John Stebbins
75a8458863 lavc/dvbsub: return meaningful error codes
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 15:58:04 -07:00
John Stebbins
eda8d48fea lavc/dvbsub: fix potential encode buffer overflow
encode buffer size was ignored

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 15:58:04 -07:00
Philip Langdale
7b0c22768e Changelog: Add entry for expanded styling support in movtext 2020-04-10 09:32:13 -07:00
John Stebbins
ad3f6212ac lavc/movtextenc: handle changes to hilight alpha
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
eeef870851 lavc/movtextenc: add option to scale fontsize with height
If the video dimensions are different than the ASS play_res then the
font sizes need to be adjusted to get the same apparent render size.

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
1f8278ee24 lavc/movtextenc: add font name handling
Initializes the mov text sample description from the ASS header and
creates an mov font table from the fonts available in the ASS Styles.

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
dbdbcbf384 lavc/movtextenc: simplify initialization of new style record
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
bb8fd04665 lavc/movtextenc: handle cancel overrides callback
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
848792be60 lavc/movtextenc: add font size tag handling
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
2e79843e37 lavc/movtextenc: add alpha tag handling
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
b847bd9582 lavc/movtextenc: add color tag handling
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
37ab5e2e7b lavc/movtextenc: init style record from ASS dialog style
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
a129cc9e29 lavc/movtextenc: fix unclosed style records
The last record at the end of each dialog was never closed

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
1bf0df4c4f lavc/movtextenc: simplify style record updates
Makes style update code easier to extend for style types not yet handled

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
15b81f5e6b lavc/movtextenc: keep values in native byte order till written
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
32cf264d8f lavc/movtextenc: use correct color component order
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
a52eef68d4 lavc/ass_split: fix parsing utf8 scripts
The [Script Info] section was skipped if starts with UTF8 BOM

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
b8d4a66b29 lavc/movtextdec: allow setting subtitle frame dimensions
Font sizes are relative to the subtitle frame dimensions. If the
expected frame dimensions are not known, the font sizes will most
likely be incorrect.

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
f406dc9ceb lavc/movtextdec: restore active style color after hilite
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
032ad7a0bb lavc/movtextdec: add color and alpha style tags
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
91447ae3ba lavc/movtextdec: add alpha default to ass header colors
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
c0d3fea600 lavc/movtextdec: make sure default font name is set
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
e5b99df096 lavc/movtextdec: only write fontsize, fontID tags if not default
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
d3c012ff42 lavc/movtextdec: handle changes to default style flags
Style flags were only being turned on.  If the default was on and style
record turned off, style flag remained on.

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
5f39f63a65 lavc/movtextdec: fix bold, italic, underline flags
They should be 0 or 1 so that 0 or -1 is written to the ass header

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
2949f17e99 lavc/movtextdec: simplify style record walk
It's not necessary to walk the style record list twice per subtitle
character.  style records are in order and do not overlap.

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
47e88adc0d lavc/movtextdec: fix ass header colors
A conversion from rgb to bgr is necessary

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
Anton Khirnov
c3a2615bb8 lavc: install codec_desc.h
Forgotten in 672946c7fe
2020-04-10 18:18:51 +02:00
Anton Khirnov
fc12d6c258 h264dec: do not set picture_structure on init
This has been cargo culted from mpegvideo and serves no useful purpose.
It will be initialize correctly in h264_field_start()
2020-04-10 15:53:31 +02:00
Anton Khirnov
4fb05c0d5d h264dec: rename flush_dpb()
The name is misleading, this function does a lot more than just flushing
the DPB.
2020-04-10 15:53:27 +02:00
Anton Khirnov
5e316096fa h264_ps: make the PPS hold a reference to its SPS
It represents the relationship between them more naturally and will be
useful in the following commits.

Allows significantly more frames in fate-h264-attachment-631 to be
decoded.
2020-04-10 15:52:41 +02:00
Anton Khirnov
ec7f33a38e h264_sei: parse the picture timing SEIs correctly
Those SEIs refer to the currently active SPS. However, since the SEI
NALUs precede the coded picture data in the bitstream, the active SPS is
in general not known when we are decoding the SEI.

Therefore, store the content of the picture timing SEIs and actually
parse it when the active SPS is known.
2020-04-10 15:52:22 +02:00
Anton Khirnov
1e9615c5d4 h264_sei: use a separate reader for the individual SEI messages
This tells the parsing functions the payload size and prevents them from
overreading.
2020-04-10 15:50:26 +02:00
Anton Khirnov
d41faffb53 h264dec: do not abort if decoding extradata fails
Such errors are not necessarily fatal and decoding might still be
possible, e.g. it happens for MVC streams where we do not handle the
subset SPS thus failing to parse its corresponding PPS.
2020-04-10 15:49:27 +02:00
Anton Khirnov
9d6785d426 lavc: do not implicitly share the frame pool between threads
Currently the frame pool used by the default get_buffer2()
implementation is a single struct, allocated when opening the decoder.
A pointer to it is simply copied to each frame thread and we assume that
no thread attempts to modify it at an unexpected time. This is rather
fragile and potentially dangerous.

With this commit, the frame pool is made refcounted, with the reference
being propagated across threads along with other context variables. The
frame pool is now also immutable - when the stream parameters change we
drop the old reference and create a new one.
2020-04-10 15:47:30 +02:00
Anton Khirnov
2944537430 pthread_frame: do not copy a range of AVCodecContext fields at once
This is extremely fragile against reordering and hides what is actually
being copied. Copy all the fields manually instead.
2020-04-10 15:46:09 +02:00
Anton Khirnov
b630a270f5 pthread_frame: do not embed full AVFrame structs into per-thread contexts
Use the AVFrame API to properly allocate and free frames for delayed
release.
2020-04-10 15:45:16 +02:00
Anton Khirnov
e40107c1ad pthread_frame: do not share priv_data between multiple codec contexts
Specifically, between the user-facing one and the first frame thread
one.

This is fragile and dangerous, allocate separate private data for each
per-thread context.
2020-04-10 15:44:15 +02:00
Anton Khirnov
1f4cf92cfb pthread_frame: merge the functionality for normal decoder init and init_thread_copy
The current design, where
- proper init is called for the first per-thread context
- first thread's private data is copied into private data for all the
  other threads
- a "fixup" function is called for all the other threads to e.g.
  allocate dynamically allocated data
is very fragile and hard to follow, so it is abandoned. Instead, the
same init function is used to init each per-thread context. Where
necessary, AVCodecInternal.is_copy can be used to differentiate between
the first thread and the other ones (e.g. for decoding the extradata
just once).
2020-04-10 15:24:54 +02:00
Anton Khirnov
665e5b0fba lavc: replace AVCodecInternal.allocate_progress with an internal cap
This is a constant codec property, so a capability flag is more appropriate.
2020-04-10 14:16:39 +02:00
Anton Khirnov
7385ffbd31 mpeg4videodec: do not copy a range of fields at once
This is extremely fragile against reordering and hides what is actually
being copied. Copy all the fields manually instead.
2020-04-10 14:16:22 +02:00
Anton Khirnov
672946c7fe avcodec.h: split AVCodecDescriptor API into its own header 2020-04-10 14:15:14 +02:00
Anton Khirnov
c6978418b8 avcodec.h: split codec IDs into their own header 2020-04-10 13:57:21 +02:00
Anton Khirnov
9875fd24ce avcodec.h: split AVPacket API into its own header 2020-04-10 13:54:03 +02:00
Anton Khirnov
f1e3e9e204 wavpack: fully support stream parameter changes
Fix invalid memory access on DSD streams with changing channel count.
2020-04-10 13:52:15 +02:00
Anton Khirnov
a1133db30e decode: make sure ff_get_buffer() cleans the frame on failure
Merge ff_get_buffer() and get_buffer_internal() to simplify the code.
2020-04-10 13:52:06 +02:00
Anton Khirnov
e923a35988 pthread_frame: make sure ff_thread_release_buffer always cleans the frame 2020-04-10 13:51:23 +02:00
Linjie Fu
917d28d5ff lavc/libopenh264enc: fix the if-else coding style
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2020-04-10 13:50:47 +02:00
Paul B Mahol
932493f9c2 avcodec/zerocodec: use init cleanup internal cap 2020-04-10 12:22:09 +02:00
Paul B Mahol
05e04e821d avcodec/zerocodec: implement flushing 2020-04-10 12:22:09 +02:00
Paul B Mahol
481ebb1c8b avcodec: add MV30 decoder 2020-04-10 12:22:09 +02:00
Andreas Rheinhardt
7104c4dd88 avcodec/jpeg2000dec: Fix mixed declaration and code
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-09 18:19:04 +02:00
Gautam Ramakrishnan
e531891f3d libavcodec/jpeg2000dec.c: Add support for PPT marker
This patch adds functional changes to support the
PPT marker. This patch fixes bug ticket #4610.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-09 13:43:15 +02:00
Andriy Gelman
cd04bb4afe avcodec/v4l2_context: Use av_freep()
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-04-08 21:41:52 -04:00
Michael Niedermayer
3935c891e9 avcodec/flacdsp_template: Fix invalid shifts in decorrelate
Fixes: left shift of negative value -2
Fixes: 20303/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-5096829297623040

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-07 18:29:20 +02:00
Michael Niedermayer
7ccb576191 avcodec/xvididct: Fix integer overflow in MULT()
Fixes: signed integer overflow: 23170 * 95058 cannot be represented in type 'int'
Fixes: 20295/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-5800212870463488

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-07 18:24:14 +02:00
Michael Niedermayer
187161d62f avcodec/ffwavesynth: Correct undefined overflow of PINK_UNIT
Fixes: signed integer overflow: 9223372036854775775 + 128 cannot be represented in type 'long'
Fixes: 20054/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5686385113825280

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-07 18:21:28 +02:00
Peter Ross
31c4fe177d avcodec/vp3: propagate error codes
throughout vp3_decode_frame the error code was being captured (ret) but never returned.

Signed-off-by: Peter Ross <pross@xvid.org>
Reviewed-by: Anton Khirnov <anton@khirnov.net>
2020-04-07 20:59:15 +10:00
Michael Niedermayer
741565a1e6 avcodec/cbs_h264_syntax_template: fix off by 1 error with slice_group_change_cycle
Fixes: assertion failure
Fixes: 20390/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_REDUNDANT_PPS_fuzzer-5683400772157440

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-05 23:18:55 +02:00
Carl Eugen Hoyos
559c2e96e3 lavc/amrwbdec: Use av_samples_set_silence().
Suggested-by: James Almer
2020-04-05 17:24:57 +02:00
Carl Eugen Hoyos
bef3c14dd1 lavc/amrwbdec: Do not ignore NO_DATA frames.
Fixes the actual output duration of the sample in ticket #7113.
2020-04-05 01:55:34 +02:00
Carl Eugen Hoyos
4d9b9c5e46 lavc/aacdec_template: Only warn once about unusual 7.1 encoding. 2020-04-04 23:56:51 +02:00
Carl Eugen Hoyos
c59233d503 lavc/sbc: Remove bool usage. 2020-04-04 23:26:15 +02:00
Carl Eugen Hoyos
d46a91b7f3 lavc/qsvenc: Fix format specifiers for two variables of type int. 2020-04-04 23:18:08 +02:00
Carl Eugen Hoyos
4679a474f0 lavc: Use supported_samplerates for Dolby Digital encoders.
Fixes ticket #8518.
2020-04-04 23:12:27 +02:00
Gautam Ramakrishnan
88f95253e1 libavcodec/jpeg2000dec.c: Fix indentation
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-04 18:04:21 +02:00
Gautam Ramakrishnan
e116cb45c2 libavcodec/jpeg2000dec.c: Handle non EOC streams
This patch allows decoding of j2k streams which do
not have an EOC marker.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-04 18:04:21 +02:00
Andriy Gelman
b343eca8d5 avcodec/v4l2_m2m_dec: Init reserved bytes to zero before ioctl call
struct v4l2_selection contains reserved bytes which should be set to
zero before the ioctl call.

Fixes valgrind error:
Syscall param ioctl(VKI_V4L2_S_SELECTION) points to uninitialised byte(s)

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-03-31 23:41:37 -04:00
Ming Qian
edee0d0104 avcodec/v4l2_m2m: fix setting frame period
Currently the driver's frame period is incorrectly set to the frame
rate. This is fixed in the commit.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-03-31 17:24:42 -04:00
Michael Niedermayer
67de1865b1 avcodec/hcadec: Check scale_factors
Fixes: out of array read
Fixes: 21286/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HCA_fuzzer-5683183715876864

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>
2020-03-31 20:12:15 +02:00
Timo Rothenpieler
767f53533a nvdec: attach real hw_frames to post-processed frames 2020-03-28 17:58:54 +01:00
Andreas Rheinhardt
3362330741 ffplay, avcodec, avformat: Don't initialize before av_packet_ref()
It already initializes the packet.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-03-28 04:17:20 +01:00
Andreas Rheinhardt
c52ec0367d avcodec/avcodec, avpacket: Return blank packet on av_packet_ref() failure
Up until now, it was completely unspecified what the content of the
destination packet dst was on error. Depending upon where the error
happened calling av_packet_unref() on dst might be dangerous.

This commit changes this by making sure that dst is blank on error, so
unreferencing it again is safe (and still pointless). This behaviour is
documented.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-03-28 03:59:15 +01:00
Andreas Rheinhardt
e621f2b6cd avcodec/avpacket: Always treat dst in av_packet_ref as uninitialized
av_packet_ref() mostly treated the destination packet dst as uninitialized,
i.e. the destination fields were simply overwritten. But if the source
packet was not reference-counted, dst->buf was treated as if it pointed
to an already allocated buffer (if != NULL) to be reallocated to the
desired size.

The documentation did not explicitly state whether the dst will be treated
as uninitialized, but it stated that if the source packet is not refcounted,
a new buffer in dst will be allocated. This and the fact that the side-data
as well as the codepath taken in case src is refcounted always treated the
packet as uninitialized means that dst should always be treated as
uninitialized for the sake of consistency. And this behaviour has been
explicitly documented.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-03-28 03:54:48 +01:00
Gautam Ramakrishnan
26a36801c0 avcodec/jpeg2000dec: error check when processing tlm marker
Validate the value of ST field in the TLM marker of JPEG2000.
Throw an error when ST takes value of 0b11.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-03-27 21:36:06 +01:00
Anton Khirnov
ad9052c4f8 h264_ps: pass AVCodecContext as void* where possible
Makes sure it is only used for logging and nothing else.
2020-03-27 13:43:40 +01:00
Linjie Fu
8b8492452d lavc/x86/hevc_add_res: Fix coeff overflow in ADD_RES_SSE_16_32_8
Fix overflow for coeff -32768 in function ADD_RES_SSE_16_32_8 with no
performance drop.(SSE2/AVX/AVX2)

./checkasm --test=hevc_add_res --bench

Mainline:
  - hevc_add_res.add_residual [OK]
    hevc_add_res_32x32_8_sse2: 127.5
    hevc_add_res_32x32_8_avx: 127.0
    hevc_add_res_32x32_8_avx2: 86.5

Add overflow test case:
  - hevc_add_res.add_residual [FAILED]

After:
  - hevc_add_res.add_residual [OK]
    hevc_add_res_32x32_8_sse2: 126.8
    hevc_add_res_32x32_8_avx: 128.3
    hevc_add_res_32x32_8_avx2: 86.8

Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2020-03-27 10:57:40 +01:00
Linjie Fu
e9abef437f lavc/x86/hevc_add_res: Fix overflow in ADD_RES_SSE_8_8
Fix overflow for coeff -32768 in function ADD_RES_SSE_8_8 with
no performance drop.

./checkasm --test=hevc_add_res --bench

Mainline:
  - hevc_add_res.add_residual [OK]
    hevc_add_res_8x8_8_sse2: 15.5

Add overflow test case:
  - hevc_add_res.add_residual [FAILED]

After:
  - hevc_add_res.add_residual [OK]
    hevc_add_res_8x8_8_sse2: 15.5

Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2020-03-27 10:57:40 +01:00
Linjie Fu
0da14ed09e lavc/x86/hevc_add_res: Fix overflow in ADD_RES_MMX_4_8
Fix overflow for coeff -32768 in function ADD_RES_MMX_4_8 with no
performance drop.

./checkasm --test=hevc_add_res --bench

Mainline:
  - hevc_add_res.add_residual [OK]
    hevc_add_res_4x4_8_mmxext: 15.5

Add overflow test case:
  - hevc_add_res.add_residual [FAILED]

After:
  - hevc_add_res.add_residual [OK]
    hevc_add_res_4x4_8_mmxext: 15.0

Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2020-03-27 10:57:40 +01:00