Commit Graph

43181 Commits

Author SHA1 Message Date
Limin Wang
b01d12bcc0 avcodec/h264dec: Add FF_CODEC_CAP_INIT_CLEANUP
then ff_h264_free_tables() and h264_decode_end() can be removed
in h264_decode_init() if it's failed.

The FF_CODEC_CAP_INIT_CLEANUP flag is need for single thread, For multithread,
it'll be cleanup still by AV_CODEC_CAP_FRAME_THREADS flag if have.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-27 21:59:51 +08:00
Limin Wang
467d9e27e0 avcodec: Add FF_CODEC_CAP_INIT_CLEANUP
then ff_mpv_encode_end() will be unnecessary in ff_mpv_encode_init()
if it's failed.

The FF_CODEC_CAP_INIT_CLEANUP flag is need for single thread, For multithread,
it'll be cleanup still by AV_CODEC_CAP_FRAME_THREADS flag if have.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-27 21:59:51 +08:00
Limin Wang
6124cbdcfa avcodec/adpcmenc: Add FF_CODEC_CAP_INIT_CLEANUP
then we can remove adpcm_encode_close() in adpcm_encode_init() if have failed.
so the goto error lable will be unnecessary and can be removed later.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-27 21:59:51 +08:00
Anton Khirnov
b5aee6086b avcodec.h: move avcodec_get_{type,name} to codec_id.h 2020-05-27 10:22:17 +02:00
Anton Khirnov
ba6cada92e avcodec.h: split AVCodec API into its own header 2020-05-27 10:22:17 +02:00
Linjie Fu
7ae340111e lavc/vaapi_hevc: add missing max_8bit_constraint_flag
This is accidentally missed while rebasing.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-27 15:34:16 +08:00
Xu Guangxin
8b5ffaea64 lavc/hevc_refs: Fix the logic of find_ref_idx()
Currently find_ref_idx() would trigger 2 scans in DPB to find the
requested POC:
1. Firstly, ignore MSB of ref->poc and search for the requested POC;
2. Secondly, compare the entire ref->poc with requested POC;

For long term reference, we are able to only check LSB if MSB is not
presented(e.g. delta_poc_msb_present_flag == 0). However, for short
term reference, we should never ignore poc's MSB and it should be
kind of bit-exact. (Details in 8.3.2)

Otherwise this leads to decoding failures like:
[hevc @ 0x5638f4328600] Error constructing the frame RPS.
[hevc @ 0x5638f4328600] Error parsing NAL unit #2.
[hevc @ 0x5638f4338a80] Could not find ref with POC 21
Error while decoding stream #0:0: Invalid data found when processing input

Search the requested POC based on whether MSB is used, and avoid
the 2-times scan for DPB buffer. This benefits both native HEVC
decoder and integrated HW decoders.

Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-27 14:47:55 +08:00
Xu Guangxin
939a4db227 lavc/hevc: Add poc_msb_present filed in LongTermRPS
delta_poc_msb_present_flag is needed in find_ref_idx() to
indicate whether MSB of POC should be taken into account.

Details in 8.3.2.

Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-27 14:39:36 +08:00
Martin Storsjö
6c33a230e4 mfenc: Avoid including codecapi.h, fix building in UWP mode with clang
Including codecapi.h and uuids.h in UWP mode doesn't define all defines
properly, ending up with constructs that MSVC silently tolerates, but
that clang errors out on, like this:
    DEFINE_GUIDEX(CODECAPI_AVEncCommonFormatConstraint);

Just avoid including codecapi.h completely and hardcode the last few
enum values we use from there. We already use local versions of most
enums from there, due to older mingw-w64 headers being incomplete.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-27 00:19:32 +03:00
Martin Storsjö
869f655e2e mfenc: Remove an unused include
This might have been used originally for the decoder parts of
the MediaFoundation wrapper, which aren't merged yet.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-27 00:19:32 +03:00
Lynne
2502e13b07
opusenc: add apply_phase_inv option
By popular request.
Does the same as in libopusenc.
2020-05-26 10:52:12 +01:00
Lynne
b8d9bc2e87
pngdec: add ability to check chunk CRC
By default now, if AV_EF_CRCCHECK or AV_EF_IGNORE_ERR are enabled the decoder
will skip the chunk and carry on with the next one. This should make the
decoder able to decode more corrupt files because the functions which decode
individual chunks will very likely error out if fed invalid data and stop the
decoding of the entire image.
2020-05-26 10:23:13 +01:00
Lynne
e69f407b52
mpegaudiodec_template: add ability to check CRC
A lot of files have CRC included.
The CRC only covers 34 bytes at most from the frame but it should still be
enough for some amount of error detection.
2020-05-26 10:23:11 +01:00
Lynne
1cc8eecd38
apedec: add ability to check CRC
The CRC flag is only signalled once every few minutes but CRC is still
always present so the patch uses the file version instead.
CRC on 24-bit files wants non-padded samples so skip such files.
Some corrupt samples may have been output before the final check
depending on the -max_samples setting.
2020-05-26 10:23:06 +01:00
Matthieu Bouron
6268034b5d avcodec/mediacodec_wrapper: use MediaFormat to probe frame color characteristics 2020-05-25 18:07:45 +02:00
James Almer
cde7818d9f avcodec/frame_thread_encoder: remove usage of avcodec_encode_video2()
Call the encoder's internal AVCodec.encode2() function instead.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-25 12:46:22 -03:00
Anton Khirnov
064b875e89 h264dec: support exporting QP tables through the AVVideoEncParams API 2020-05-25 11:59:42 +02:00
James Almer
c7c8f141eb avcodec: move avcodec_flush_buffers from decode.c to utils.c
It's not a decoding exclusive function anymore.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-24 12:05:40 -03:00
Andreas Rheinhardt
26b4509690 libavcodec/libvpxenc: Don't free user-provided AVPacket
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 20:25:11 +02:00
Andreas Rheinhardt
7e6941e185 libavcodec/libmp3lame: Don't free user-provided AVPacket
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 20:25:08 +02:00
Andreas Rheinhardt
b803993b6d avcodec/libopusenc: Don't free user-provided AVPacket
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 20:24:37 +02:00
Martin Storsjö
2a1fd3c84e mfenc: Fix building with clang in MSVC mode
Just including icodecapi.h + codecapi.h apparently misses some bits,
that MSVC doesn't complain about, but Clang does. Thus add a missing
header to the custom hacky include path (required for keeping
ICodecAPI visible when building in UWP mode, as it is intended to).

The issue in Windows SDK headers about ICodecAPI availability in
UWP/app mode has been reported upstream at
https://developercommunity.visualstudio.com/content/problem/1037125/icodecapi-not-visible-when-compiling-in-uwp-mode.html,
and later also filed in Feedback Hub (which can't be linked to
externally).

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-23 21:17:55 +03:00
Andreas Rheinhardt
6fb79c1af5 avcodec/xiph: Return better error codes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 07:07:36 +02:00
Oneric
e6dcb6a0db avcodec/ass: explicitly set ScaledBorderAndShadow
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-23 00:26:38 +02:00
Marton Balint
82f9eb6f6c avcodec: move mpeg4 profiles to profiles.h
Also bump micro version after the recent option changes.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-22 22:23:18 +02:00
Marton Balint
ebb770d3ab avcodec: move msbc profile to encoder
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-22 22:23:18 +02:00
Marton Balint
d55f1cc58b avcodec/options_table: remove dts profiles
Our encoder (dcaenc) does not use any of these.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-22 22:22:46 +02:00
Marton Balint
aee036cdd0 avcodec: move aacenc profiles to profiles.h
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-22 22:16:53 +02:00
Marton Balint
337fe4bcc2 avcodec/options_table: make AVCodecContext->profile search for child constants
This change makes it possible for child encoders to define custom profile
option names which can be used for setting the AVCodecContext->profile.

Also rename unit name to something rather unique, so it won't be used elsewhere.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-22 22:16:53 +02:00
Martin Storsjö
c116c127f9 mfenc: Fall back to avctx->time_base if avctx->framerate isn't set
The framerate field is the one users are supposed to set, but not
all users might be setting it, so it might be good to fall back
time_base in that case.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-22 21:49:48 +03:00
Martin Storsjö
fea5f5bc64 mfenc: Fix setting has_b_frames for max_b_frames == 1
This was a mistake in my own additions in
050b72ab5e.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-22 21:49:37 +03:00
Martin Storsjö
1f7c8d319b cbs_h265: Fix use of an uninitialized variable
This fixes test failures in fate-cbs-hevc-* in certain configurations
since c53f9f4364.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-22 21:01:29 +03:00
James Almer
1e8ed181e3 avcodec/bsf: mention that av_bsf_send_packet() returning EAGAIN is not an error
EAGAIN is returned when input is provided but can't be consumed. The filtering
process is unaffected in this case, and the function will be able to consume
new input after retrieving filtered packets with av_bsf_receive_packet().

Remove the line about empty packets never failing added in
41b05b849f while at it. Even if it's currently
the case, it unnecessarily constrains the API and could be changed in the future
in case it needs to be extended.
The user should always check for errors and never expect a call to never fail.

Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-22 11:16:40 -03:00
Anton Khirnov
bdd6aa25c1 avcodec.h: split bitstream filters API into its own header 2020-05-22 14:38:57 +02:00
Anton Khirnov
bf80725352 lavc: rename bsf.h to bsf_internal.h
This will allow adding a public header named bsf.h
2020-05-22 14:38:57 +02:00
Anton Khirnov
9d443c3e68 avcodec.h: split AVCodecParameters API into its own header 2020-05-22 14:38:57 +02:00
Anton Khirnov
f30a41a608 Stop hardcoding align=32 in av_frame_get_buffer() calls.
Use 0, which selects the alignment automatically.
2020-05-22 14:38:57 +02:00
James Almer
13b1bbff0b avcodec: deprecate Lossless and Intra Only encoder capabilites
Both are codec properties and not encoder capabilities. The relevant
AVCodecDescriptor.props flags exist for this purpose.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-21 12:32:15 -03:00
James Almer
d3bedba97f avcodec/decode: remove ff_decode_bsfs_uninit()
It's been a wrapper for a simple av_bsf_free() call since c96904f525.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-21 12:32:15 -03:00
Michael Niedermayer
70faa9f618 avcodec/tiff: Check for Tiled and Stripped TIFFs
TIFF 6 spec: "Do not use both strip-oriented and tile-oriented fields in the same TIFF file."

Fixes: null pointer use, crash
Fixes: crash-762680f9d1b27f9b9085e12887ad44893fb2b020

Found-by: Shiziru <lunasl@protonmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-21 13:08:23 +02:00
Michael Niedermayer
49459aca47 avcodec/pnmdec: Use unsigned for maxval rescaling
Fixes: signed integer overflow: 65535 * 55335 cannot be represented in type 'int'
Fixes: 21955/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGMYUV_fuzzer-5669206981083136

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-21 09:31:08 +02:00
Michael Niedermayer
1d633e6a0a avcodec/ivi: Clear got_p_frame before decoding a new frame using it
Fixes: assertion failure
Fixes: 21666/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INDEO4_fuzzer-5706468994318336

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-21 09:31:08 +02:00
Michael Niedermayer
2570a8777e avcodec/dsddec: Check channels
Fixes: division by zero
Fixes: 21677/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DSD_MSBF_fuzzer-5712547983654912
Fixes: 21751/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DSD_LSBF_fuzzer-5197097180856320

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-21 09:31:08 +02:00
Michael Niedermayer
620236e4d2 avcodec/xvididct: Fix integer overflow in idct_row()
Fixes: signed integer overflow: -1238335488 + -1003634688 cannot be represented in type 'int'
Fixes: 21649/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-5112005765890048

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-21 09:31:08 +02:00
Michael Niedermayer
e9a4c4fe99 avcodec/wmalosslessdec: Fix integer overflows in revert_inter_ch_decorr()
Fixes: signed integer overflow: -717241856 + -1434459904 cannot be represented in type 'int'
Fixes: 21405/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-5677143666458624

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-21 09:31:08 +02:00
Michael Niedermayer
a3dc67c984 avcodec/cbs_jpeg: Fix infinite loop in cbs_jpeg_split_fragment()
Fixes: Timeout
Fixes: 21104/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5129580475318272

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-21 09:31:08 +02:00
Michael Niedermayer
a629cec58e avcodec/bitpacked: Add codec_tags list
This should improve coverage

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-21 09:31:08 +02:00
Michael Niedermayer
435fa373d1 avcodec/cbs_h265_syntax_template: Limit num_long_term_pics more strictly
The limit is based on hevcdec.c
Fixes: 20854/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-5160442882424832
Fixes: out of array access

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-21 09:31:08 +02:00
Mark Thompson
c53f9f4364 cbs_h265: Ensure that a predicted RPS doesn't contain too many pictures
If the RPS we are predicting from has maximum size then at least one of
the pictures in it must be discarded before adding the current one.

Also revert 588114cea4, which added
now-redundant checks for the special case of a too-large RPS with all
pictures being in the same direction from the current one.
2020-05-20 22:07:01 +01:00
Mark Reid
af5922a79a avcodec/exr: output float pixels in float pixel format
changes since v1
- default behavior, no longer hidden behind decoder parameter
- updated tests to reflect change

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-20 15:47:22 +02:00
James Almer
74dfc88b63 avcodec/libx265: add support for reordered_opaque
Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-19 19:12:17 -03:00
wm4
050b72ab5e avcodec: Add MediaFoundation encoder wrapper
This contains encoder wrappers for H264, HEVC, AAC, AC3 and MP3.

This is based on top of an original patch by wm4
<nfxjfg@googlemail.com>. The original patch supported both encoding
and decoding, but this patch only includes encoding.

The patch contains further changes by Paweł Wegner
<pawel.wegner95@gmail.com> (primarily for splitting out the encoding
parts of the original patch) and further cleanup, build compatibility
fixes and tweaks for use with Qualcomm encoders by Martin Storsjö.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-19 21:34:04 +03:00
Paul B Mahol
cdd06db56f avcodec: add NotchLC decoder 2020-05-19 20:09:25 +02:00
James Almer
6275a7ec73 avcodec/frame_thread_encoder: check for frame threading codec cap instead of intra only
It's the correct dedicated capability reported by supported encoders.
Otherwise, the frame thread path will be used for unsupported encoders
like r210 for no gain.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-18 12:39:34 -03:00
James Almer
49220869a8 avcodec/libdav1d: export frame sample aspect ratio
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-18 12:28:03 -03:00
Linjie Fu
8999a2f21d lavc/qsvenc: add encode support for HEVC 4:2:2 8-bit and 10-bit
Enables HEVC Range Extension encoding support (Linux) for 4:2:2 8/10 bit
on ICL+ (gen11 +) platform.

Restricted to linux only for now.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-18 13:33:29 +08:00
Linjie Fu
9723d7d523 lavc/qsvdec: add decode support for HEVC 4:2:2 8-bit and 10-bit
Enables HEVC Range Extension decoding support (Linux) for 4:2:2 8/10 bit
on ICL+ (gen11 +) platform.

Restricted to linux only for now.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-18 13:32:50 +08:00
Michael Niedermayer
f603d10b1e avcodec/binkaudio: Fix 2Ghz sample_rate
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 19950/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINKAUDIO_DCT_fuzzer-5765514337189888

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Suggested-by: Paul
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-17 00:43:45 +02:00
Michael Niedermayer
ea29f07b2f avcodec/jpeg2000dec: Free packed_headers
Fixes: memleak
Fixes: 21784/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-565256551058636

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Gautam Ramakrishnan <gautamramk@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-17 00:36:20 +02:00
Martin Storsjö
7168adedbc libavcodec: aarch64: Add a NEON implementation of pixblockdsp
Cortex A53    A72    A73
get_pixels_c:                140.7   87.7   72.5
get_pixels_neon:              46.0   20.0   19.5
get_pixels_unaligned_c:      140.7   87.7   73.0
get_pixels_unaligned_neon:    49.2   20.2   26.2
diff_pixels_c:               209.7  133.7  138.7
diff_pixels_neon:             54.2   31.7   23.5
diff_pixels_unaligned_c:     209.7  134.2  139.0
diff_pixels_unaligned_neon:   68.0   27.7   41.7

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-15 23:37:55 +03:00
Martin Storsjö
b252178321 libavcodec: arm: Add a NEON implementation of pixblockdsp
Cortex A7     A8     A9    A53   A72
get_pixels_c:                144.7  146.0  143.0  137.7   69.0
get_pixels_armv6:            112.0  106.7   90.2   95.0   72.5
get_pixels_neon:              69.0   29.7   68.7   40.2   19.0
get_pixels_unaligned_c:      144.7  146.2  143.0  137.7   69.0
get_pixels_unaligned_neon:    77.0   36.5   72.5   48.5   19.0
diff_pixels_c:               376.7  319.7  265.5  307.7  148.0
diff_pixels_armv6:           179.0  159.5  205.5  139.0  142.0
diff_pixels_neon:             69.0   40.2   77.5   53.2   26.0
diff_pixels_unaligned_c:     376.7  319.7  265.5  307.7  148.0
diff_pixels_unaligned_neon:   85.0   54.5   93.5   66.7   26.0

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-15 23:37:43 +03:00
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