1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-09-04 23:38:20 +02:00
Commit Graph

45632 Commits

Author SHA1 Message Date
James Almer
ab25874e32 avcodec/h264_slice: signal the presence of Film Grain in the decoder context
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 10:00:20 -03:00
James Almer
9b05263ac1 avcodec/av1: signal the presence of Film Grain in the decoder context
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 10:00:20 -03:00
James Almer
651fed3860 avcodec/libdav1d: signal the presence of Film Grain in the decoder context
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 10:00:20 -03:00
James Almer
590a7e02f0 avcodec: add a Film Grain codec property flag
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 10:00:06 -03:00
James Almer
6dd7149f4c avcodec/pthread_frame: also keep AVCodecContext.properties in sync between threads
Some frame threaded decoders set it, but this information never reached the
caller in frame threading scenarios.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 09:58:52 -03:00
Niklas Haas
66845cffc3 avcodec/h264dec: apply H.274 film grain
Because we need access to ref frames without film grain applied, we have
to add an extra AVFrame to H264Picture to avoid messing with the
original. This requires some amount of overhead to make the reference
moves work out, but it allows us to benefit from frame multithreading
for film grain application "for free".

Unfortunately, this approach requires twice as much RAM to be constantly
allocated for ref frames, due to the need for an extra buffer per
H264Picture. In theory, we could get away with freeing up this memory as
soon as it's no longer needed (since ref frames do not need film grain
buffers any longer), but trying to call ff_thread_release_buffer() from
output_frame() conflicts with possible later accesses to that same frame
and I'm not sure how to synchronize that well.

Tested on all three cases of (no fg), (fg present but exported) and (fg
present and not exported), with and without threading.

Co-authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 09:58:52 -03:00
Niklas Haas
6bc29a6b57 avcodec/h274: add film grain synthesis routine
This could arguably also be a vf, but I decided to put it here since
decoders are technically required to apply film grain during the output
step, and I would rather want to avoid requiring users insert the
correct film grain synthesis filter on their own.

The code, while in C, is written in a way that unrolls/vectorizes fairly
well under -O3, and is reasonably cache friendly. On my CPU, a single
thread pushes about 400 FPS at 1080p.

Apart from hand-written assembly, one possible avenue of improvement
would be to change the access order to compute the grain row-by-row
rather than in 8x8 blocks. This requires some redundant PRNG calls, but
would make the algorithm more cache-oblivious.

The implementation has been written to the wording of SMPTE RDD 5-2006
as faithfully as I can manage. However, apart from passing a visual
inspection, no guarantee of correctness can be made due to the lack of
any publicly available reference implementation against which to
compare it.

Signed-off-by: Niklas Haas <git@haasn.dev>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 09:58:52 -03:00
Niklas Haas
cf37c3fb6c avcodec/h264_slice: compute and export film grain seed
From SMPTE RDD 5-2006, the grain seed is to be computed from the
following definition of `pic_offset`:

> When decoding H.264 | MPEG-4 AVC bitstreams, pic_offset is defined as
> follows:
>   - pic_offset = PicOrderCnt(CurrPic) + (PicOrderCnt_offset << 5)
> where:
>   - PicOrderCnt(CurrPic) is the picture order count of the current frame,
>     which shall be derived from [the video stream].
>
>   - PicOrderCnt_offset is set to idr_pic_id on IDR frames. idr_pic_id
>     shall be read from the slice header of [the video stream]. On non-IDR I
>     frames, PicOrderCnt_offset is set to 0. A frame shall be classified as I
>     frame when all its slices are I slices, which may be optionally
>     designated by setting primary_pic_type to 0 in the access delimiter NAL
>     unit. Otherwise, PicOrderCnt_offset it not changed. PicOrderCnt_offset is
>     updated in decoding order.

Co-authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 09:58:52 -03:00
James Zern
cb23c1e553 avcodec/libaomenc: use ctx->usage to get default cfg
this prevents some mismatches in config values for realtime and all
intra modes, avoiding failures like:

[libaom-av1 @ ...] Failed to initialize encoder: Invalid parameter
[libaom-av1 @ ...]   Additional information: g_lag_in_frames out of
range [..0]

Signed-off-by: James Zern <jzern@google.com>
2021-08-23 15:33:51 -07:00
Andreas Rheinhardt
5a3385d49a avcodec/av1_frame_merge_bsf: Passthrough pos in case of no timestamps
This is needed by the AV1-Annex B and AV1-OBU demuxers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-23 07:04:55 +02:00
Michael Niedermayer
5e00eab611 avcodec/webp: Check available space in loop in decode_entropy_coded_image()
Fixes: Timeout
Fixes: 35401/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WEBP_fuzzer-5714401821851648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-22 18:08:00 +02:00
Michael Niedermayer
65892516d5 avcodec/h264dec: use picture parameters in ff_print_debug_info2()
Fixes: out of array read
Fixes: 36341/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-6737583085322240

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-22 18:08:00 +02:00
Michael Niedermayer
c59b5e3d1e avcodec/vc1dec: ff_print_debug_info() does not support WMV3 field_mode
Fixes: out of array read
Fixes: 36331/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3_fuzzer-5140494328922112.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-22 18:08:00 +02:00
Mikhail Nitenko
d3e56b56ae lavc/aarch64: add pred functions for 10-bit
Benchmarks:                        A53     A72
pred8x8_dc_10_c:                   64.2    49.5
pred8x8_dc_10_neon:                62.0    53.7
pred8x8_dc_128_10_c:               26.0    14.0
pred8x8_dc_128_10_neon:            30.7    17.5
pred8x8_horizontal_10_c:           60.0    27.7
pred8x8_horizontal_10_neon:        38.0    34.0
pred8x8_left_dc_10_c:              42.5    27.5
pred8x8_left_dc_10_neon:           51.0    41.2
pred8x8_mad_cow_dc_0l0_10_c:       55.7    37.2
pred8x8_mad_cow_dc_0l0_10_neon:    50.2    35.2
pred8x8_mad_cow_dc_0lt_10_c:       89.2    67.0
pred8x8_mad_cow_dc_0lt_10_neon:    52.2    46.7
pred8x8_mad_cow_dc_l0t_10_c:       74.7    51.0
pred8x8_mad_cow_dc_l0t_10_neon:    50.5    45.2
pred8x8_mad_cow_dc_l00_10_c:       58.0    38.0
pred8x8_mad_cow_dc_l00_10_neon:    42.5    37.5
pred8x8_plane_10_c:               354.0   288.7
pred8x8_plane_10_neon:            141.0   101.2
pred8x8_top_dc_10_c:               44.5    30.5
pred8x8_top_dc_10_neon:            40.0    31.0
pred8x8_vertical_10_c:             27.5    14.5
pred8x8_vertical_10_neon:          21.0    17.5
pred16x16_plane_10_c:            1242.0  1070.5
pred16x16_plane_10_neon:          324.0   196.7

Signed-off-by: Mikhail Nitenko <mnitenko@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2021-08-21 00:06:26 +03:00
Mikhail Nitenko
43ca887bc2 lavc/aarch64: h264, add chroma loop filters for 10bit
Benchmarks:                                             A53     A72
h264_h_loop_filter_chroma422_10bpp_c:                  282.7   114.2
h264_h_loop_filter_chroma422_10bpp_neon:               109.5    78.5
h264_h_loop_filter_chroma_10bpp_c:                     165.0    81.5
h264_h_loop_filter_chroma_10bpp_neon:                  120.0    76.7
h264_h_loop_filter_chroma_intra422_10bpp_c:            323.7   124.2
h264_h_loop_filter_chroma_intra422_10bpp_neon:         155.0   102.7
h264_h_loop_filter_chroma_intra_10bpp_c:               121.0    49.5
h264_h_loop_filter_chroma_intra_10bpp_neon:             79.7    53.7
h264_h_loop_filter_chroma_mbaff422_10bpp_c:            188.5    75.0
h264_h_loop_filter_chroma_mbaff422_10bpp_neon:         120.0    75.5
h264_h_loop_filter_chroma_mbaff_intra422_10bpp_c:      116.7    46.0
h264_h_loop_filter_chroma_mbaff_intra422_10bpp_neon:    79.7    53.7
h264_h_loop_filter_chroma_mbaff_intra_10bpp_c:          63.0    27.2
h264_h_loop_filter_chroma_mbaff_intra_10bpp_neon:       48.5    34.0
h264_v_loop_filter_chroma_10bpp_c:                     258.7   135.5
h264_v_loop_filter_chroma_10bpp_neon:                   71.2    51.0
h264_v_loop_filter_chroma_intra_10bpp_c:               158.0    70.7
h264_v_loop_filter_chroma_intra_10bpp_neon:             48.7    31.5

Signed-off-by: Mikhail Nitenko <mnitenko@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2021-08-21 00:06:26 +03:00
Mikhail Nitenko
756d2e087a lavc/aarch64: move transpose_4x8H to neon.S
transpose_4x8H was declared in vp9lpf_16bpp_neon, however this macro is
not unique to vp9 and could be used elsewhere.

Signed-off-by: Mikhail Nitenko <mnitenko@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2021-08-21 00:06:26 +03:00
Andreas Rheinhardt
c83a7dd25f avcodec/h264_parser: Fix undefined left shift
Use an uint32_t for the NAL unit size of an AVC H.264 NAL unit instead
of an int as a left shift of a signed value is undefined behaviour
if the result doesn't fit into the target type.

Also make the log message never output negative lengths.

Fixes: left shift of 16711968 by 8 places cannot be represented in type 'int'
Fixes: 36601/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-6581933285965824

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-20 12:19:12 +02:00
Christopher Degawa
8990c5869e get_cabac_inline_x86: Don't inline if 32-bit clang on windows
Fixes https://trac.ffmpeg.org/ticket/8903

relevant https://github.com/msys2/MINGW-packages/discussions/9258

Signed-off-by: Christopher Degawa <ccom@randomderp.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2021-08-19 22:29:23 +03:00
Jan Ekström
dbe40478e2 avcodec/libx265: improve full range flag setting logic
Unlike libx264, libx265 does not have a separate "unspecified"/"auto"
default for color range, so we do always have to specify it.
Thus, we are required to handle the RGB case on the libavcodec
side to enable the correct value to be written out in in case
of RGB content with unspecified color range being received.

In other words:
1. If the user has set color range specifically, follow that.
2. If the user has not set color range specifically, set full
   range by default in case of RGB and YUVJ pixel formats.
2021-08-18 12:09:37 +03:00
Jan Ekström
7ca71b79f2 avcodec/libx264: leave full range flag unchanged if unknown
By default the x264 full range flag is set to -1. By not setting
it to something else, we can let libx264 handle the RGB case.
Additionally, change the preference order to user-specified range
first, and then any fall-back logic left for the YUVJ pix_fmts.

Fixes the capture part of #9374
2021-08-18 12:09:37 +03:00
Paul B Mahol
ed47a4a842 avcodec: add SMC encoder 2021-08-18 08:55:56 +02:00
Michael Niedermayer
7bba0dd638 avcodec/frame_thread_encoder: Free AVCodecContext structure on error during init
Fixes: MemLeak
Fixes: 8281
Fixes: PoC_option158.jpg
Fixes: CVE-2020-22037

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-17 10:34:10 +02:00
Andreas Rheinhardt
1cc64146e3 avcodec/options_table: Treat (request_)channel_layout as channel layout
Also adapt some FATE tests to already cover this.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-15 23:19:35 +02:00
Niklas Haas
33756c539b avcodec/h264_sei: fix H.274 film grain parsing
The current code reads the wrong number of bits for `fg_model_id`, which
causes all of the values downstream of this to contain corrupt values.

Fixes: corrupt SEI values
Fixes: 4ff73add5d

Signed-off-by: Niklas Haas <git@haasn.dev>
2021-08-15 13:15:21 -03:00
James Almer
acd079843b avcodec/trace_headers_bsf: also parse extradata in packet side data
Certain mov/mp4 files have parameter sets out of band, and when required for a
sample it may be propagated within the relevant packet's side data.
This fixes parsing said files if the SPS and/or PPS in the side data is
different than the one in extradata.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-14 23:06:38 -03:00
James Almer
46e4562b3a avcodec/cbs_bsf: use ff_cbs_read_packet_side_data() to parse extradata in packet side data
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-14 23:06:38 -03:00
James Almer
e680c5c344 avcodec/cbs: add a helper to read extradata within packet side data
Using ff_cbs_read() on the raw buffer will not parse it as extradata,
resulting in parsing errors for example when handling ISOBMFF avcC.
This helper works around that.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-14 23:06:38 -03:00
Paul B Mahol
f852490f72 avcodec/smc: use shorter way to access GetByteContext 2021-08-14 10:20:38 +02:00
Paul B Mahol
b6156dd665 avcodec/smc: use unchecked reader for call after checking remaining size 2021-08-14 10:20:38 +02:00
Paul B Mahol
96491430c2 avcodec/smc: use uint8_t type instead of longer variant 2021-08-13 19:18:24 +02:00
Paul B Mahol
b78fccd080 avcodec/smc: report error codes instead of silently ignoring them 2021-08-13 19:18:24 +02:00
Paul B Mahol
cf7240d1a7 avcodec/smc: 0xF0 opcode operates like 0xE0 opcode 2021-08-13 19:18:24 +02:00
Anselm Busse
55d9d67679 Fix for bug #9231: B-frames parameter is ignored in videotoolboxenc
This commit fixes the bug as report in
https://trac.ffmpeg.org/ticket/9231 by removing the line that
overwrites the user settings for max_b_frames.

Signed-off-by: Anselm Busse <anselm.busse@outlook.com>
Signed-off-by: Rick Kern <kernrj@gmail.com>
2021-08-13 08:57:27 -04:00
Haihao Xiang
115f5e8035 lavc/qsvenc: allows the SDK runtime to choose LowPower/non-LowPower modes
The SDK supports LowPower and non-LowPower modes, but some features are
available only under one of the two modes. Currently non-LowPower mode
is always chosen in FFmpeg if the mode is not set to LowPower
explicitly. User will experience some SDK errors if a LowPower related
feature is specified but the mode is not set to LowPower. With this
patch, the mode is set to unknown by default in FFmpeg, the SDK is able
to choose a workable mode for the specified features.

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-12 22:25:11 -03:00
Haihao Xiang
ecee3b07cd qsvdec: add support for HW_DEVICE_CTX method
This allows user set hw_device_ctx instead of hw_frames_ctx for QSV
decoders, hence we may remove the ad-hoc libmfx setup code from FFmpeg.

"-hwaccel_output_format format" is applied to QSV decoders after
removing the ad-hoc libmfx code. In order to keep compatibility with old
commandlines, the default format is set to AV_PIX_FMT_QSV, but this
behavior will be removed in the future. Please set "-hwaccel_output_format qsv"
explicitly if AV_PIX_FMT_QSV is expected.

The normal device stuff works for QSV decoders now, user may use
"-init_hw_device args" to initialise device and "-hwaccel_device
devicename" to select a device for QSV decoders.

"-qsv_device device" which was added for workarounding device selection
in the ad-hoc libmfx code still works

For example:

$> ffmpeg -init_hw_device qsv=qsv:hw_any,child_device=/dev/dri/card0
-hwaccel qsv -c:v h264_qsv -i input.h264  -f null -

/dev/dri/renderD128 is actually open for h264_qsv decoder in the above
command without this patch. After applying this patch, /dev/dri/card0
is used.

$> ffmpeg -init_hw_device vaapi=va:/dev/dri/card0 -init_hw_device
qsv=hw@va -hwaccel_device hw -hwaccel qsv -c:v h264_qsv -i input.h264
-f null -

device hw of type qsv is not usable in the above command without this
patch. After applying this patch, this command works as expected.

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-11 13:45:36 -03:00
Soft Works
4b3906bd7e libavcodec/qsvence: Use QSV encoder defaults as ffmpeg defaults
Signed-off-by: softworkz <softworkz@hotmail.com>
2021-08-11 09:54:20 -03:00
James Almer
90bf83d6f1 avcodec/h264_slice: use ff_h264_replace_picture when syncing thread contexts
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-10 15:11:46 -03:00
James Almer
a2a5a579bc avcodec/h264_picture: add ff_h264_replace_picture()
Will remove unnecessary allocations when both src and dst picture contain
references to the same buffers.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-10 15:11:42 -03:00
James Almer
ab448a7f9b avcodec/h264_picture: split copying H264Picture some fields into a separate function
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-10 15:11:42 -03:00
James Almer
ce4a31cd1f avcodec/h264_slice: clear old slice POC values on parsing failure
If a slice header fails to parse, and the next one uses different Sequence and
Picture parameter sets, certain values may not be read if they are not coded,
resulting in the previous slice values being used.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-10 15:11:41 -03:00
Michael Niedermayer
f803635c4f avcodec/faxcompr: Check for end of input in cmode == 1 in decode_group3_2d_line()
Fixes: Infinite loop
Fixes: 35591/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4503764022198272

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-10 18:05:13 +02:00
Michael Niedermayer
643b2d49bf avcodec/vc1dec: Disable error concealment for *IMAGE
The existing error concealment makes no sense for the image formats, they
use transformed source images which is different from keyframe + MC+difference
for which the error concealment is designed.
Of course feel free to re-enable this if you have a case where it works and
improves vissual results

Fixes: Timeout
Fixes: 36234/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-6300306743885824

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-10 18:05:13 +02:00
Michael Niedermayer
8f2856a1da avcodec/sbrdsp_fixed: Fix negation overflow in sbr_neg_odd_64_c()
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 35593/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5182217725804544

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-10 18:05:13 +02:00
Michael Niedermayer
c2f5e9ff3c avcodec/argo: Check for even dimensions
Fixes: reading over the end
Fixes: 36346/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARGO_fuzzer-5366943107383296

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-10 18:05:13 +02:00
Timo Rothenpieler
00b579890d avcodec/nvenc: always set qp cr/cb offsets 2021-08-09 15:16:58 +02:00
Martin Storsjö
c60b76d0c8 aarch64: h264dsp: Fix indentation of some functions to match the rest
Signed-off-by: Martin Storsjö <martin@martin.st>
2021-08-08 23:18:43 +03:00
Martin Storsjö
e86ec831b0 aarch64: h264dsp: Remove unnecessary sign extensions
These became unnecessary when the stride arguments were changed from
int to ptrdiff_t in bc26fe8927
(0576ef466d) and
d5d699ab6e
(aa844dc46f).

Signed-off-by: Martin Storsjö <martin@martin.st>
2021-08-08 23:18:43 +03:00
Marton Balint
a2690dccca avcodec/mpeg12dec: report error when picture type is unknown and err_detect is EXPLODE
Also split error message to error and warning.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-08-08 21:22:51 +02:00
Andreas Rheinhardt
c0d7d5f595 avcodec/qsv: Remove unused ff_qsv_level_to_mfx()
Unused since 00d0a4aa9e.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-08 18:40:46 +02:00
Andreas Rheinhardt
afc95a10ac avcodec/h264dsp, h264idct: Fix lengths of array parameters
Fixes many -Warray-parameter warnings from GCC 11.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-08 17:44:57 +02:00
Andreas Rheinhardt
ab97d163b6 avcodec/aacps: Fix length of array in function definition
hybrid2_re() has a parameter declared as "const INTFLOAT filter[8]",
although the actual argument for said parameter only has seven elements;
the code itself only uses seven elements, so change the parameter.

Fixes a -Wstringop-overread warning with GCC 11.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-08 17:44:57 +02:00
Timo Rothenpieler
ac0408522a avcodec/nvenc: make aware of SDK 11.1 driver requirements 2021-08-08 02:00:38 +02:00
Ricardo Monteiro
e56f6e59b6 avcodec/nvenc: add chroma qp offset support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-08-08 01:56:32 +02:00
Andreas Rheinhardt
5ad436fcb9 avcodec/ass_split: Rename ff_ass_split_dialog2->ff_ass_split_dialog
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-08 00:13:57 +02:00
Andreas Rheinhardt
7f1edcb4ef avcodec/ass_split: Remove unused ff_ass_split_dialogue()
Unused since 1f63665ca5.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-07 23:45:32 +02:00
Andreas Rheinhardt
127da193d4 avcodec/acelp_vectors: Add missing brackets
Before 3793caa5e2 the code was
"if (...) do { ... } while (...);". After said commit this became
"if (...) av_assert0(...); do { ... } while (...);", i.e. the loop
is always executed. This commit changes the logic to what it was before
said commit. Notice that the condition is always true in FATE, so no
changes are necessary there.

This fixes a -Wmisleading-indentation warning from GCC 11.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-07 21:51:42 +02:00
James Almer
e01d306c64 avcodec/utils: don't return negative values in av_get_audio_frame_duration()
In some extrme cases, like with adpcm_ms samples with an extremely high channel
count, get_audio_frame_duration() may return a negative frame duration value.
Don't propagate it, and instead return 0, signaling that a duration could not
be determined.

Fixes ticket #9312

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-06 21:22:49 -03:00
Michael Niedermayer
9bc32d7c4b avcodec/exr: Check ac_count
Fixes: signed integer overflow: -9223372036854775808 * 2 cannot be represented in type 'long long'
Fixes: 36244/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-6090656186499072

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-06 21:04:43 +02:00
James Almer
82be9f2777 avcodec/hevc_sei: parse and export Film Grain Characteristics SEI messages
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-06 09:56:44 -03:00
James Almer
794e15fd54 cbs_h265: add support for Film Grain Characteristics SEI message
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-06 09:56:44 -03:00
James Almer
6b594ba5d1 avcodec/mfenc: remove usage of avctx->pkt_timebase
The field is documented to be for decoding only.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-06 09:38:35 -03:00
Andreas Rheinhardt
2146b65553 avutil/internal: Move MAKE_ACCESSORS to its only user
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-05 20:05:54 +02:00
Andreas Rheinhardt
549502868d Move ff_tlog() from lavc/internal.h to lavu/internal.h
It is also used by libavfilter and it is only natural to define it
alongside ff_dlog().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-05 20:02:35 +02:00
Andreas Rheinhardt
b75dc8bd70 avcodec/huffman: Use logcontext instead of AVCodecContext
Said AVCodecContext is only used for logging; it furthermore avoids
an avcodec.h inclusion.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-05 19:58:10 +02:00
Andreas Rheinhardt
a449fb35ca avcodec/fft-internal: Make it a standalone header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-05 19:56:40 +02:00
Andreas Rheinhardt
211619ad7f avcodec: Remove the FFT_FIXED_32 define
Since the removal of the 16-bit FFT said define is unnecessary as
FFT_FIXED_32 is always !FFT_FLOAT. But one wouldn't believe it when
looking at the code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-05 19:46:33 +02:00
Andreas Rheinhardt
763c501432 avcodec/fft-internal: Remove unused macros
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-05 19:02:16 +02:00
Andreas Rheinhardt
7bad2a61d8 avcodec/mips/constants: Include intfloat.h in constants.h
Don't rely on the user including it (mostly indirectly).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-05 19:00:53 +02:00
Haihao Xiang
65fdc0e589 lavc/qsvenc: pass the color properties to the SDK
Otherwise the color properties won't be encoded into the bitstream
header

Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com>
Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-04 10:06:26 -03:00
Haihao Xiang
c8cfe67694 lavc/qsvdec: update color properties in codec context
User may get color properties from the SDK via VIDEO_SIGNAL_INFO extbuf

Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com>
Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-04 10:04:53 -03:00
maryam ebr
7150f95756 avcodec/dnxhddec: check and propagate function return value
Similar to CVE-2013-0868, here return value check for 'init_vlc' is needed.
crafted DNxHD data can cause unspecified impact.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-03 10:39:37 -03:00
Lynne
c8b1f2bcc4
packet: initialize time_base field to (0, 1) instead of (0, 0)
Forget rational or irrational numbers, division by zero is undefined.
2021-08-02 14:45:47 +02:00
Lynne
a1a0fddfd0
avpacket: ABI bump additions
This commit adds a long-requested by API users opaque fields for
AVPacket, as well as a time_base field.
2021-08-02 14:30:52 +02:00
Brad Hards
1f58503013 libavcodec/libx265: add user data unregistered SEI encoding
MISB ST 0604 and ST 2101 require user data unregistered SEI messages
(precision timestamps and sensor identifiers) to be included. That
currently isn't supported for libx265. This patch adds support
for user data unregistered SEI messages in accordance with
ISO/IEC 23008-2:2020 Section D.2.7

The design is based on nvenc, with support finished up at
57de80673c

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2021-08-01 12:07:54 +01:00
Michael Niedermayer
75a099fc73 avcodec/aaccoder: Add minimal bias in search_for_ms()
Fixes: floating point division by 0
Fixes: Ticket8218

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-07-31 22:04:07 +02:00
Gyan Doshi
b9176dbfb7 avcodec/noise_bsf: restore dropamount for backwards compatibility 2021-07-30 17:14:43 +05:30
Gyan Doshi
23da5caf09 avcodec/noise_bsf: add expr support 2021-07-29 22:05:11 +05:30
Jiaxun Yang
2323d3a923 avcodec/mips: cabac.h provide fallback for wsbh instruction
wsbh is only avilable for MIPS R2+.
Provide a fallback for older processors.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-07-28 23:31:48 +02:00
Jiaxun Yang
1042039ccd avcodec/mips: Use MMI marcos to replace Loongson3 instructions
Loongson3's extention instructions (prefixed with gs) are widely used
in our MMI codebase. However, these instructions are not avilable on
Loongson-2E/F while MMI code should work on these processors.

Previously we introduced mmiutils marcos to provide backward compactbility
but newly commited code didn't follow that. In this patch I revised the
codebase and converted all these instructions into MMI marcos to get
Loongson2 supproted again.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-07-28 23:31:48 +02:00
Thierry Foucu
fc300613be libavcodec/mpeg12dec.c: Switch to init_get_bits8 and checks return value
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-07-28 19:15:26 +02:00
Haihao Xiang
f2feb31b78 qsvenc: Value '0' is not a valid value for parameter GopOptFlag
The accepted values for GopOptFlag are MFX_GOP_CLOSED (1) and
MFX_GOP_STRICT (2).

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: Zhong Li <zhongli_dev@126.com>
2021-07-27 23:48:53 +08:00
James Almer
f7958d0883 avcodec/h264_sei: honor the Film Grain Characteristics cancel flag
Film Grain persistence is cancelled when it's true.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-07-25 23:54:10 -03:00
James Almer
4ff73add5d avcodec/h264_sei: parse and export Film Grain Characteristics SEI messages
Signed-off-by: James Almer <jamrial@gmail.com>
2021-07-23 11:06:45 -03:00
James Almer
41d1dba4d2 cbs_h264: add support for Film Grain Characteristics SEI messages
Signed-off-by: James Almer <jamrial@gmail.com>
2021-07-23 11:05:04 -03:00
Andreas Rheinhardt
5be809fed9 avcodec/tableprint_vlc: Fix building with hardcoded tables
This has been broken in 25c8507818,
because the hacks for headers that are incompatible with building
for the host in libavcodec/tableprint_vlc.h have not been adjusted.

Moving AV_INPUT_BUFFER_PADDING_SIZE to defs.h which is valid for
both the target as well as the host allowed to remove some of the hacks.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-23 14:43:52 +02:00
Andreas Rheinhardt
25c8507818 Remove/replace some unnecessary avcodec.h inclusions
Also remove other unnecessary headers and include headers directly while
at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:29:46 +02:00
Andreas Rheinhardt
e3023e9015 avcodec/g729postfilter.h: Include acelp_pitch_delay.h
Needed for PITCH_DELAY_MAX.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:46 +02:00
Andreas Rheinhardt
e0b4fe0efa avcodec: Remove some unnecessary mpegvideo.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:46 +02:00
Andreas Rheinhardt
2934a4b9a5 Remove unnecessary avassert.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:30 +02:00
Andreas Rheinhardt
4608f7cc6a Remove unnecessary mem.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 14:47:57 +02:00
Andreas Rheinhardt
e7bd47e657 Remove obsolete version.h inclusions
These have mostly been added because of FF_API_*; yet when these were
removed, removing the header has been forgotten.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 14:34:31 +02:00
Andreas Rheinhardt
2c05ee092b avutil/internal, swresample/audioconvert: Remove cpu.h inclusions
These inclusions are not necessary, as cpu.h is already included
wherever it is needed (via direct inclusion or via the arch-specific
headers).
Also remove other unnecessary cpu.h inclusions from ordinary
non-headers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 14:33:45 +02:00
Andreas Rheinhardt
f6f85d9582 avcodec/lossless_videodsp: Improve included headers
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 13:00:11 +02:00
Andreas Rheinhardt
69f120ead7 avcodec/avcodec: Don't include cpu.h
It is not used here at all; instead, add it where it is used without
including it or any of the arch-specific CPU headers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 12:59:07 +02:00
Andreas Rheinhardt
cea34b9172 avcodec/avcodec: Don't include hwcontext.h
It is no longer used directly; but it is still indirectly included via
codec.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 12:49:37 +02:00
Andreas Rheinhardt
912f125c42 avcodec/avcodec: Don't include errno.h
This inclusion has been added before libavutil/error.h was split off
from avcodec.h (in 60c144f700).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 12:48:22 +02:00
Andreas Rheinhardt
1be3d8a0cb avcodec/avcodec: Stop including channel_layout.h in avcodec.h
Also include channel_layout.h directly wherever used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 11:14:31 +02:00
Andreas Rheinhardt
57b5ec6ba7 avcodec/avcodec: Stop including bsf.h in avcodec.h
Also include bsf.h directly wherever it is used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 11:14:16 +02:00
Andreas Rheinhardt
73b847e136 avcodec/adpcm_data: Move tables only used by adpcm.c to it
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 08:31:23 +02:00
Andreas Rheinhardt
ac5bd4e41a avcodec/adpcm_data: Fix type mismatch for ff_adpcm_afc_coeffs
According to the header it is an array of int16_t, yet it is declared as
uint16_t. Fix this by using int16_t troughout and convert the definition
to use values in the range of int16_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 08:31:23 +02:00
Andreas Rheinhardt
0a67ca63e4 avcodec/adpcm: Don't include disabled AVCodecs
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 08:31:23 +02:00
Andreas Rheinhardt
0f168344f1 avcodec/adpcm: Disable dead code
This change ensures that the linker can drop adpcm_data.o if no decoder
that actually uses anything from there is enabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 08:30:18 +02:00
Andreas Rheinhardt
6914aa7fb4 avcodec/adpcm: Fix indentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 08:12:20 +02:00
Andreas Rheinhardt
421de73a10 avcodec/adpcm: Use smaller scope for some variables
This is to avoid unused variables warnings after the code for
the disabled encoders has been #if'ed away which will happen in
a subsequent commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 08:06:10 +02:00
Andreas Rheinhardt
c8a8691c97 avcodec/adpcmenc: Don't include disabled AVCodecs
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 08:00:39 +02:00
Andreas Rheinhardt
62e3d01cc7 avcodec/adpcmenc: Deduplicate AVClasses
The child_class_next API relied on different (de)muxers to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 07:50:05 +02:00
Andreas Rheinhardt
63f736f476 avcodec/adpcmenc: #if disabled code away, fix build without ADPCM_ARGO
The adpcm_argo encoder does not use the data from adpcm_data.c directly;
instead it shares a function with the adpcm_argo decoder that is in
adpcm.c. When all the ADPCM decoders and the adpcm_argo encoder are
disabled, adpcm.c is not compiled; yet the code in adpcmenc.c calling
said function from adpcm.c is still present, leading to link errors.

Fix this by disabling the code belonging to disabled codecs in
adpcmenc.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 07:35:31 +02:00
Andreas Rheinhardt
10f8f06a56 avcodec/adpcmenc: Use smaller scope for some variables
This is to avoid unused variables warnings if the code for disabled
encoders is #if'ed away which will happen in a subsequent commit.
In case of buf it also avoids shadowing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 07:32:09 +02:00
Zane van Iperen
f687f8e0d3
avcodec/argo: use bits_per_coded_sample instead of bits_per_raw_sample
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-07-19 14:14:35 +10:00
Andreas Rheinhardt
1c2d8ff92b avcodec/dsd_tablegen: Merge header into dsd.c
Since b492fbcc6e, the DSD tables are
always initialized at runtime, so merge the dsd_tablegen.h header
into dsd.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-19 00:21:42 +02:00
Andreas Rheinhardt
f9136d6026 Avoid calling functions repeatedly via FFMIN
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-18 22:06:20 +02:00
Andreas Rheinhardt
e1836b191b avcodec/libavcodec.v: Tighten export whitelist
Currently every symbol (with external linkage) that starts with "av" is
exported. Yet libaom-av1 has lots of functions that are not meant to be
exported and start with "av1_" (I counted 1236); and libvpx has
average_split_mvs. These functions are exported if one links these
libraries statically into a shared libavcodec.so.

Solve this by tightening the whitelist to "av_", "avcodec_", "avpriv_"
and (as a special-case) "avsubtitle_free".

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-18 21:50:52 +02:00
Michael Niedermayer
adae546f24 avcodec/exr: Check uncompressed_size against max_pixels
Fixes: Timeout
Fixes: 35286/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-6557139802914816
Fixes: 31253/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-4901782326214656

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-07-17 10:48:27 +02:00
James Almer
1349de10b2 avcodec/libdav1d: parse sequence headers in extradata if available
This allows the decoder context to be initialized with all stream parameters
before a packet is parsed.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-07-14 13:11:51 -03:00
Jan Ekström
f32f56468c {configure,avcodec/libx264}: remove separate x264_csp_bgr check
We already require X264_BUILD >= 118, which includes an unconditional
definition of X264_CSP_BGR in itself, thus making this check
effectively always true.
2021-07-12 12:07:10 +03:00
Guangyu Sun
24b3178efd libavcodec/vorbisenc: Add missing initial_padding
Vorbis has priming samples at the beginning. If the initial_padding is not
set in the encoder, the total sample count will be one frame fewer than it
should be. The result is that we get a truncated version of encoding.

initial_padding should be set to the frame_size used in
vorbis_encode_frame().

Signed-off-by: Guangyu Sun <gsun@roblox.com>
2021-07-12 09:54:52 +02:00
Gyan Doshi
1aa9dcd091 avcodec/qsvenc: clip global_quality for ICQ modes.
Allowed range is 1 to 51.

Ref: https://software.intel.com/content/www/us/en/develop/articles/advanced-bitrate-control-methods-in-intel-media-sdk.html
2021-07-12 09:33:22 +05:30
James Almer
7ee17ec7e4 avcodec/libdav1d: don't repeatedly parse the same sequence header
Look at the event flag that signals a new sequence header was found
in the bitstream on supported libdav1d versions for this purpose.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-07-09 11:07:29 -03:00
James Almer
48eaf8ba1c avcodec/libdav1d: use ff_decode_frame_props() to fill frame properties
The main benefit comes from propagating container level metadata like hdr,
which is more commonly used than the relevant Metadata OBUs.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-07-09 11:07:29 -03:00
Michael Niedermayer
eaec4df63f avcodec/aacdec_template: Avoid some invalid values to be set by decode_audio_specific_config_gb()
Fixes: NULL pointer dereference
Fixes: decode_spectrum_and_dequant.mp4

Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-07-09 14:57:49 +02:00
Andreas Rheinhardt
f067795c74 avcodec/textdec: Deduplicate AVClasses
The child_class_next API relied on different AVCodecs to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 20:10:17 +02:00
Andreas Rheinhardt
d46de6d4bc avcodec/proresenc_anatoliy: Deduplicate pix_fmts arrays
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 20:10:17 +02:00
Andreas Rheinhardt
a45058ddf9 avcodec/proresenc_anatoliy: Deduplicate AVClasses
The child_class_next API relied on different AVCodecs to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 20:10:17 +02:00
Andreas Rheinhardt
f41a9b331e avcodec/pngenc: Deduplicate AVClasses
The child_class_next API relied on different AVCodecs to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 20:10:17 +02:00
Andreas Rheinhardt
34ff543672 avcodec/mpegvideo_enc: Deduplicate ff_mpv_generic_options-based AVClasses
The child_class_next API relied on different AVCodecs to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 20:10:17 +02:00
Andreas Rheinhardt
19d8077e31 avcodec/libwebpenc: Deduplicate options, AVClass, pix_fmts
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 20:10:17 +02:00
Andreas Rheinhardt
425d272507 avcodec/libcodec2: Remove AVClass for decoder
The decoder has no options.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 20:10:17 +02:00
Andreas Rheinhardt
01f4f6c297 avcodec/g726: Deduplicate AVClasses
The child_class_next API relied on different AVCodecs to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 20:10:17 +02:00
Andreas Rheinhardt
bc368575a9 avcodec/ac3enc: Deduplicate AVClasses
The child_class_next API relied on different AVCodecs to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 20:10:01 +02:00
Andreas Rheinhardt
9a1a82d21c avcodec/ac3dec_float: Deduplicate AVClasses
The child_class_next API relied on different AVCodecs to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 19:30:36 +02:00
Andreas Rheinhardt
34a7e61768 avcodec/Makefile: Fix standalone build of adpcm_argo encoder
Said encoder uses a function in adpcm.c and while it does not use
anything from adpcm_data.c, other parts of both adpcm.c and adpcmenc.c
need it, so adpcm_data.c needs to be enabled anyway.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 16:03:18 +02:00
Andriy Gelman
78f21f4ec1 avcodec/mjpegdec: Try to continue decoding on zero quant matrix value
A zero value in the quantization matrix is invalid but in practice will
just set the transform coefficient to zero after inverse quantization.
Try to continue decoding if the AV_EF_EXPLODE flag is not set.

Fixes ticket #9287.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2021-07-05 13:00:50 -04:00
James Almer
041267b558 avcodec/setts_bsf: add a NOPTS constant
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-07-04 11:18:43 -03:00
James Almer
b0b3fce3c3 avcodec/setts_bsf: actually store the current packet's timestamps to be usable by the next
Before this change, the PREV_OUTPTS and PREV_OUTDTS constants always evaluated
to AV_NOPTS_VALUE.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-07-04 11:16:01 -03:00
Gyan Doshi
301d275301 avcodec/bsf: switch to av_get_token to parse bsf list string
The recently added setts bsf makes use of the eval API whose
expressions can contain commas. The existing parsing in
av_bsf_list_parse_str() uses av_strtok to naively split
the string at commas, thus preventing the use of setts filter
with expressions containing commas.

av_get_token can work with escaped commas, allowing full use of setts.
2021-07-04 09:54:33 +05:30
Michael Niedermayer
70874e024a avcodec/lpc: check for zero err in normalization in compute_lpc_coefs()
Fixes: floating point division by 0
Fixes: Ticket8213

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-07-03 18:03:35 +02:00
Michael Niedermayer
6a6a765fa4 avcodec/j2kenc: Check for av_strtok() failure
Fixes: CID1466601 Dereference null return value

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-07-03 18:03:35 +02:00
Haihao Xiang
9583e66ea0 qsvenc_hevc: allow user set more coding options
The SDK supports NalHrdConformance, RecoveryPointSEI and AUDelimiter for
hevc encoder, so we may allow user to set these coding options like as
what we did for h264_qsv encoder.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: Zhong Li <zhongli_dev@126.com>
2021-07-02 23:38:36 +08:00
Michael Niedermayer
cea05864e6 avcodec/cpia: Fix missing src_size update
Fixes: out of array read
Fixes: 35210/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CPIA_fuzzer-5669199688105984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-29 19:36:36 +02:00
Michael Niedermayer
18b0dd0738 avcodec/exr: Better size checks
Fixes: signed integer overflow: 3530839700044513368 + 8386093932303352321 cannot be represented in type 'long long'
Fixes: 35182/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5398383270428672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-29 19:36:36 +02:00
Michael Niedermayer
11fac9613e avcodec/clearvideo: Check tile_size to be not too large
Fixes: left shift of 1 by 31 places cannot be represented in type 'int'
Fixes: 35023/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-6740166587842560

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-29 19:36:36 +02:00
Michael Niedermayer
00ae9b77ef avcodec/utils: Use 64bit for intermediate in AV_CODEC_ID_ADPCM_THP* duration calculation
Fixes: signed integer overflow: 486539264 * 14 cannot be represented in type 'int'
Fixes: 35281/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-6068262742917120

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-29 19:36:36 +02:00
Derek Buitenhuis
d70dde2712 avcodec/h264_metadata_bsf: Allow zeroing constraint_set4_flag and constraint_set5_flag
These bits are reserved in earlier versions of the H.264 spec, and
some poor hardware decoders require they are zero. Thus, it is useful
to be able to zero these on streams that may have them set. The result
is still a valid H.264 bitstream.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2021-06-29 15:31:06 +01:00
Anton Khirnov
296dc876ec lavc: fix and extend AVCodecContext.get_format doxy
Remove some incorrect (or at least misleading) statements, such as the
formats being ordered by quality, or the first format being the native
one. Neither of those are true for hardware acceleration, which is the
main use of this callback.
2021-06-26 19:33:42 +02:00
Limin Wang
81bad080cd avcodec/libx264: Separate headers not supported in AVC-Intra mode
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-06-25 09:27:52 +08:00
Limin Wang
93da0869e6 avcodec/libx264: Add support for Sony XAVC Class 300 and 480
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-06-25 09:27:52 +08:00
Mohammad Izadi
aca923b365 avcodec: Pass HDR10+ metadata to packet side data in VP9 encoder
HDR10+ metadata is stored in the bit stream for HEVC. The story is
different for VP9 and cannot store the metadata in the bit stream.
HDR10+ should be passed to packet side data an stored in the container
(mkv) for VP9.

This CL is taking HDR10+ from AVFrame side data in libvpxenc and is
passing it to the AVPacket side data.

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Zern <jzern@google.com>
2021-06-24 10:29:17 -07:00
James Almer
ec8e95296e avcodec/crystalhd: signal that the decoder sets all output frame properties
Signed-off-by: James Almer <jamrial@gmail.com>
2021-06-21 15:26:44 -03:00
James Almer
6b4805686c avcodec/cuviddec: signal that the decoder sets all output frame properties
Fixes memleaks described in ticket #9082.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-06-21 15:21:51 -03:00
James Almer
854a9d8c6e avcodec/cuviddec: remove unused AVCodec.decode() callback
The AVCodec.receive_frame() callback takes precedence.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-06-21 15:05:20 -03:00
James Almer
b4c2ff3e41 avcodec/decode: reindent after the previous commit
Signed-off-by: James Almer <jamrial@gmail.com>
2021-06-21 15:05:11 -03:00
James Almer
7b9610ebd8 avcodec/decode: add an internal codec flag to signal a decoder sets all output frame properties
Decoders like cuviddec ignore and overwrite all the properties set by the generic
code as derived from AVCodecInternal.last_pkt_props. This flag ensures libavcodec
will not store and potentially queue input packets that ultimately will not be used.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-06-21 15:03:52 -03:00
James Almer
a4fb03563a avcodec/decode: fetch packets from the pkt_props FIFO on every frame returned
Fixes memleaks on decoders that don't call ff_decode_frame_props(), like
libdav1d.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-06-21 14:59:54 -03:00
Michael Niedermayer
d866787dac avcodec/hevc_sei: Use get_bits_long() for time_offset_value
Fixes: assertion failure
Fixes: crash_1

Found-by: Thuan Pham <tpham.unimelb@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-20 17:43:47 +02:00
Haihao Xiang
971b4ac733 lavc/qsvdec: fix pts
The time base used for compressed bitstream and video frame in the SDK
is { 1, 90000 }. [1][2]

This can avoid the error message below from the muxer.

$> ffmpeg -hwaccel qsv -c:v hevc_qsv -i input.h265 -f null -
...
[null @ 0x561c24f6f2f0] Application provided invalid, non monotonically
increasing dts to muxer in stream 0: 2 >= 2

[1]https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxbitstream
[2]https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxframedata

Signed-off-by: Zhong Li <zhongli_dev@126.com>
2021-06-20 23:04:35 +08:00
Pavel Koshevoy
b51c2c48c1 avcodec/ccaption_dec: Make real-time latency configurable
Un-hardcode the 200ms minimum latency between emitting subtitle events
so that those that wish to receive a subtitle event for every screen
change could do so.

The problem with delaying realtime output by any amount is that it is
unknown when the next byte pair that would trigger output will happen.
It may be within 200ms, or it may be several seconds later -- that's
not realtime at all.
2021-06-18 19:20:03 -06:00
Michael Niedermayer
216eb60b85 avcodec/iff: Only write palette to plane 1 if its PAL8
Fixes: null pointer passed as argument 1, which is declared to never be null
Fixes: 33791/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5107575256383488.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-18 18:58:25 +02:00
Matthieu Patou
fcb80aa289 lavc/libvpxenc: Show encoder config as a warning in case of failed initialization
Suggested-By: ffmpeg@fb.com
2021-06-14 20:25:56 +02:00
Matthieu Patou
268f134e51 lavc/libaomenc: Show encoder config as a warning in case of failed initialization
Suggested-By: ffmpeg@fb.com
2021-06-14 20:25:52 +02:00
Thilo Borgmann
115aa7cea3 lavc/videotoolboxenc.c: Fix preprocessor macro for OSX 10.10.5 and probably older versions 2021-06-14 16:20:47 +02:00
Michael Niedermayer
ff56c139e0 avcodec/faxcompr: Check available bits in decode_uncompressed()
Fixes: Timeout
Fixes: 34950/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5686764151898112
Fixes: 34966/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4587409334468608

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-12 14:22:42 +02:00
Michael Niedermayer
7d8421e3d5 avcodec/faxcompr: Check if bits are available before reading in cmode == 9 || cmode == 10
Fixes: Timeout
Fixes: 34950/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5686764151898112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-12 14:22:42 +02:00
Michael Niedermayer
3447979d08 avcodec/utils: do "calc from frame_bytes, channels, and block_align" in 64bit
Fixes: signed integer overflow: 104962766 * 32 cannot be represented in type 'int'
Fixes: 33614/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-6252129036664832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-12 14:22:42 +02:00
Michael Niedermayer
dbbcfbcc4e avcodec/ttadata: Add sentinel at the end of ff_tta_shift_1
Fixes: out of array access
Fixes: 34933/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5629322560929792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-12 14:22:42 +02:00
stuhlo
a501d55905 avcodec/cuviddec: correctly set key_frame with interlaced content
Fixes #9283

This fixes setting of 'key_frame' flag in AVFrame when input h264 packets represents individual fields of interlaced video.
In this case, pairs of two consecutive fields represents a single decoded picture and have identical 'CurrPicIdx', however, only
the first field is entirely intra-coded and has the flag 'intra_pic_flag' set and the second field was resetting the flag before
it was even read in the function 'cuvid_output_frame'.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-06-11 16:50:53 +02:00
Anton Khirnov
c28823ff97 lavc/get_bits: avoid avcodec.h dependency
Include only defs.h, needed for AV_INPUT_BUFFER_PADDING_SIZE.
2021-06-10 16:51:44 +02:00
Anton Khirnov
58a39e3436 lavc/hevc_sei: include buffer.h explicitly
Do not rely on including it indirectly through get_bits.h->avcodec.h
2021-06-10 16:51:44 +02:00
Anton Khirnov
43002487cb lavc/mlp_parse: add required includes explicitly 2021-06-10 16:51:44 +02:00
Anton Khirnov
93822dacb9 lavc/dolby_e_parser: #include avcodec.h explicitly
This file uses definitions from it, but relies on an indirect include
through get_bits.h
2021-06-10 16:51:44 +02:00
Anton Khirnov
9dbdabe0e0 lavc/cbs_internal: clean up headers
Include all required headers explicitly, avoid avcodec.h dependency.
2021-06-10 16:51:44 +02:00
Anton Khirnov
e91901adf6 lavc/cbs: avoid avcodec.h dependency
Include only the headers that are actually needed.
2021-06-10 16:51:44 +02:00
Anton Khirnov
f3f404edd2 lavc/cbs_bsf.h: explicitly #include all required headers 2021-06-10 16:51:44 +02:00
Anton Khirnov
7c9763070d lavc: move av_get_profile_name() from avcodec.h to codec.h 2021-06-10 16:51:44 +02:00
Anton Khirnov
bb3648e676 lavc: move av_get_audio_frame_duration2() from avcodec.h to codec_par.h 2021-06-10 16:51:44 +02:00
Anton Khirnov
881db34f6a lavc: move av_get_pcm_codec() from avcodec.h to codec_id.h 2021-06-10 16:51:44 +02:00
Anton Khirnov
2628dff366 lavc: move avcodec_profile_name() from avcodec.h to codec_id.h 2021-06-10 16:51:44 +02:00
Anton Khirnov
000f35125f lavc: move av_get_[exact_]bits_per_sample() to codec_id.h 2021-06-10 16:51:44 +02:00
Anton Khirnov
ff0a96046d lavc: move small misc definitions into a separate header
This will allow to avoid #including the entire avcodec.h in some places.
2021-06-10 16:51:44 +02:00
Michael Niedermayer
ca9025f374 avcodec/dpx: fix off by 1 in bits_per_color check
Fixes: CID1476303 Bad bit shift operation
Fixes: 34871/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DPX_fuzzer-6331163028357120

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-08 18:00:05 +02:00
Michael Niedermayer
f7862e8268 avcodec/vc2enc: Check for non negative slice bounds
Fixes: invalid shifts
Fixes: Ticket 8221

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-08 18:00:05 +02:00
Andreas Rheinhardt
7af1a3cebe avcodec/avcodec: Don't free options on failure in avcodec_open2()
Instead return the dictionary in the state it is at the time the error
occurred. This is more in line with the description of this parameter
and allows to notify the user of unrecognized options if an error
happens lateron (which might very well be due to e.g. misspelled
options).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:50 +02:00
Andreas Rheinhardt
73f9d5b673 avcodec/avcodec: Avoid redundant copies of options in avcodec_open2
It is no longer necessary now that ff_frame_thread_encoder_init()
no longer receives an options dictionary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:50 +02:00
Andreas Rheinhardt
cbf6047c83 avcodec/frame_thread_encoder: Remove redundant memcpy
In case the underlying AVCodec has no private class, the private data
of both the main as well as each worker AVCodecContext is just zeroed
(the codec's init function has not been called on any of them and
without a private class there is no way to legitimately set anything
before the aforementioned init function).

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:49 +02:00
Andreas Rheinhardt
835d8b7401 avcodec/dvenc: Avoid copying packet data, allow user-supplied buffers
When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data; this also makes it easy
to allow user-supplied buffers. Only one thing needed to be changed:
The earlier code relied on the buffer having been initially zeroed
by av_fast_padded_malloc(), so one now needs to zero the packet at
first.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:49 +02:00
Timo Rothenpieler
8bcce5673a avcodec/nvenc: add option to disable all extra SEI data
With these triggering a lot of crashes recently, an option to globally
disable all of them is added as a tool to work around those crashes in
case the SEI data is not needed by the user.

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

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-06-06 22:01:56 +02:00
Timo Rothenpieler
57de80673c avcodec/nvenc: extract sei data prep into own function 2021-06-04 18:40:17 +02:00
Brad Hards
cee9f9628f avcodec/nvenc: write out user data unregistered SEI
Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-06-04 18:24:49 +02:00
Brad Hards
63948a6170 avcodec/nvenc: use persistent sei data buffer
Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-06-04 18:24:49 +02:00
Jin Bo
2fac1e370c libavcodec/mips: Fix fate errors reported by clang
The data width of gsldrc1/gsldlc1 should be 8 bytes wide.

Signed-off-by: Jin Bo <jinbo@loongson.cn>
Reviewed-by: yinshiyou-hf@loongson.cn
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-03 13:44:00 +02:00
Jin Bo
fd5fd48659 libavcodec/mips: Fix build errors reported by clang
Clang is more strict on the type of asm operands, float or double
type variable should use constraint 'f', integer variable should
use constraint 'r'.

Signed-off-by: Jin Bo <jinbo@loongson.cn>
Reviewed-by: yinshiyou-hf@loongson.cn
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-03 13:44:00 +02:00
Michael Niedermayer
864d1ef2fc avcodec/jpeglsdec: force pal8 only once
Fixes: Infinite loop
Fixes: 33958/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-6590264069193728
Fixes: 33981/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-5343224173559808
Fixes: 33986/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-6598815122587648
Fixes: 34001/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-6171098111672320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-02 22:35:36 +02:00
Michael Niedermayer
06d23c6f3f avcodec/mjpegdec: Fix order of condition for pal8
Fixes: out of array access
Fixes: 33960/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-5052852809629696
Fixes: 34163/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-6123678099177472

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-02 22:35:36 +02:00
Michael Niedermayer
996797f8ed avcodec/mpegvideo_enc: Reset stuffing bits if they are not supported
Fixes: Assertion failure
Fixes: Ticket8202

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-02 17:35:54 +02:00
Michael Niedermayer
c297f7e57a avcodec/svq1enc: Do not print debug RD value before it has been computed
Avoids floating point division by 0

Fixes: Ticket8191

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-02 17:30:24 +02:00
Michael Niedermayer
36dead4bc2 avcodec/aacpsy: Check bandwidth
Fixes: Ticket8011

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-02 17:30:24 +02:00
Michael Niedermayer
c520b98691 avcodec/aacenc: Do not divide by lambda_count if it is 0
Avoids Floating point division by 0

Fixes: Ticket8011

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-02 17:30:24 +02:00
Michael Niedermayer
4b89cf7aa4 avcodec/aacenc: Use FLT_EPSILON for lambda minimum 2021-06-02 17:30:24 +02:00
Timo Rothenpieler
8d0fea81c7 avcodec/nvenc: disable s12m timestamps by default
Leads to weird crashes with valid looking input data for otherwise
unknown reasons.
2021-05-29 22:59:57 +02:00
Michael Niedermayer
38d18fb578 avcodec/lpc: Avoid floating point division by 0
Fixes: Ticket7996
Fixes: CVE-2020-20445

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-29 20:14:24 +02:00
Michael Niedermayer
223b5e8ac9 avcodec/aacpsy: Avoid floating point division by 0 of norm_fac
Fixes: Ticket7995
Fixes: CVE-2020-20446

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

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-29 20:14:24 +02:00
Jin Bo
ebedd26eef libavcodec/mips: Fix specification of instruction name
1.'xor,or,and' to 'pxor,por,pand'. In the case of operating FPR,
  gcc supports both of them, clang only supports the second type.
2.'dsrl,srl' to 'ssrld,ssrlw'. In the case of operating FPR, gcc
  supports both of them, clang only supports the second type.

Signed-off-by: Jin Bo <jinbo@loongson.cn>
Reviewed-by: yinshiyou-hf@loongson.cn
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-28 17:31:21 +02:00
Michael Niedermayer
26d3c81bc5 avcodec/exr: More strictly check dc_count
Fixes: out of array access
Fixes: exr/deneme

Found-by: Burak Çarıkçı <burakcarikci@crypttech.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-27 17:43:40 +02:00
Michael Niedermayer
48342aa075 avcodec/exr: x/ymax cannot be INT_MAX
The code uses x/ymax + 1 so the maximum is INT_MAX-1

Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 33158/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5545462457303040

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-27 17:43:40 +02:00
Michael Niedermayer
b752d195cc avcodec/error_resilience: cleanup mpeg2 handling
After this, the loop for the mpeg2 case is only executed when needed

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-27 17:41:36 +02:00
James Almer
e44cb7363f avcodec/utils: don't use ff_fast_mallocz() in av_fast_padded_malloc()
It will be removed in the next commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-05-27 10:28:32 -03:00
Andreas Rheinhardt
3abdf0efac avcodec/libxavs2: Allow user-supplied buffers
Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 15:17:13 +02:00
Andreas Rheinhardt
7a3613696d avcodec/sbcenc: Avoid copying packet data, allow user-supplied buffers
When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 15:16:31 +02:00
Andreas Rheinhardt
250d8661ab avcodec/pngenc: Avoid copying APNG data, allow user-supplied buffer
The APNG encoder already uses internal buffers, so that the packet size
is already known before allocating the packet; therefore one can avoid
another (implicit) intermediate buffer by switching to
ff_get_encode_buffer(), thereby also supporting user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 15:15:57 +02:00
Andreas Rheinhardt
aaefb84b04 avcodec/pngenc: Remove always-true check
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 15:14:44 +02:00
Andreas Rheinhardt
5abb5c0415 avcodec/flacenc: Avoid copying packet data, allow user-supplied buffers
The FLAC encoder calculates the size in advance, so one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 15:12:57 +02:00
Andreas Rheinhardt
314c086a85 avcodec/pamenc: Avoid copying packet data, allow user-supplied buffers
When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 15:10:41 +02:00
Andreas Rheinhardt
981c4caed3 avcodec/pnmenc: Avoid intermediate buffer, allow user-supplied buffers
For all p*m encoders a very sharp upper bound for the size of the
output packets is available before the packet is allocated. This can
be used to avoid an intermediate buffer when encoding by using
ff_get_encode_buffer() instead of ff_alloc_packet2() (without min_size);
this also adds support for user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 15:08:30 +02:00
Andreas Rheinhardt
ea2ec1dfae avcodec/libxavs: Improve returned error codes
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 15:07:49 +02:00
Andreas Rheinhardt
4085cfc944 avcodec/libxavs: Avoid overallocating, copying packet data
When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data; also, there is no reason
to add AV_INPUT_BUFFER_MIN_SIZE to the packet size any more, as the
actually needed packet size can be easily calculated: It is three bytes
more than the raw nal size per NALU.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 15:03:37 +02:00
Andreas Rheinhardt
a4b3343278 avcodec/libx265: Allow user-supplied buffers
Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:59:15 +02:00
Andreas Rheinhardt
9c4f2bc3bf avcodec/libx264: Avoid copying data, allow user-supplied buffers
Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:57:43 +02:00
Andreas Rheinhardt
cfff94b7f8 avcodec/libwebpenc_animencoder: Allow user-supplied buffers
Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:56:35 +02:00
Andreas Rheinhardt
ad26efbf52 avcodec/libwebpenc: Allow user-supplied buffers
Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:54:18 +02:00
Andreas Rheinhardt
e099a29f5a avcodec/libvpxenc: Avoid one level of indentation
Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:52:34 +02:00
Andreas Rheinhardt
3280c6f938 avcodec/libvpxenc: Avoid copying data, allow user-supplied buffers
Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:50:46 +02:00
Andreas Rheinhardt
d8e66ec1d7 avcodec/libvorbisenc: Avoid copying data, allow user-supplied buffers
Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:49:45 +02:00
Andreas Rheinhardt
6ba55e9652 avcodec/libtheoraenc: Avoid copying data, allow user-supplied buffers
Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:47:49 +02:00
Andreas Rheinhardt
6564ab0e01 avcodec/libshine: Avoid copying data, allow user-supplied buffer
The libshine encoder already uses an internal buffer, so that the
packet size is already known before allocating the packet; therefore
one can avoid another (implicit) intermediate buffer by switching
to ff_get_encode_buffer(), thereby also supporting user-supplied
buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:44:13 +02:00
Andreas Rheinhardt
0812a60fee avcodec/libopenh264enc: Allow user-supplied buffers
Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:43:32 +02:00
Andreas Rheinhardt
c59398970b avcodec/libmp3lame: Avoid copying data, allow user-supplied buffer
The libmp3lame encoder already uses an internal buffer, so that the
packet size is already known before allocating the packet; therefore
one can avoid another (implicit) intermediate buffer by switching
to ff_get_encode_buffer(), thereby also supporting user-supplied
buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:42:54 +02:00
Andreas Rheinhardt
95c8a859d9 avcodec/libkvazaar: Allow user-supplied buffers
Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:42:22 +02:00
Andreas Rheinhardt
91567c28fc avcodec/libgsmenc: Avoid copying packet data, allow user-supplied buffers
When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:42:02 +02:00
Andreas Rheinhardt
398822a70e avcodec/libcodec2: Avoid copying packet data, allow user-supplied buffers
When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:41:28 +02:00
Andreas Rheinhardt
044daa7c45 avcodec/libaomenc: Avoid copying data, allow user-supplied buffers
Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:39:51 +02:00
Andreas Rheinhardt
c685249ff8 avcodec/audiotoolboxenc: Remove AV_CODEC_CAP_DR1
It has been added in 2016 when this flag made no sense for encoders at
all; now that it makes sense, audiotoolboxenc doesn't support it,
despite claiming to do so.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:38:15 +02:00
Martin Storsjö
f27e3ccf06 aarch64: hevc_idct: Fix overflows in idct_dc
This is marginally slower, but correct for all input values.
The previous implementation failed with certain input seeds, e.g.
"checkasm --test=hevc_idct 98".

Signed-off-by: Martin Storsjö <martin@martin.st>
2021-05-22 00:08:03 +03:00
Lynne
660d1d8e3b
aacenc: make the twoloop coder the default
This used to be the default, but was reverted as it was slower than
the 'fast' coder by around 25%.
Since our encoder is still not very good, change back to the twoloop
coder by default. It has much better rate control management as well,
making it closer to CBR, and it sounds much better.
2021-05-21 17:43:13 +02:00
Fei Wang
9b131e8500 avcodec/vaapi_av1: pass full buffer size for each tile
Previously, only the size of a given tile was passed, making the
offset and size marked in VASliceParameterBufferAV1 invalid with
multiple tiles.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2021-05-20 17:09:48 +03:00
Zane van Iperen
f9eb440e78
avcodec/videotoolboxenc: #define TARGET_CPU_ARM64 to 0 if not provided by the SDK
Fixes build failure on older SDKs without it.

Fixes #9242

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-05-19 10:37:51 +10:00
Andreas Rheinhardt
bc40cd6214 avcodec/exrenc: Allow user-supplied buffers
Trivial for an encoder that has a good estimate of the size of
the output packet in advance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-15 13:00:12 +02:00
Andreas Rheinhardt
ed8a7c25cd avcodec/vc2enc: Allow user-supplied buffers
Trivial for an encoder that has a very good estimate of the size
of the output packet in advance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-15 12:14:41 +02:00
Andreas Rheinhardt
911806ec75 avcodec/jpeglsenc: Remove unnecessary header
Unnecessary since 130d89d786.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-15 12:07:36 +02:00
Andreas Rheinhardt
83cb9be1d2 avcodec/jpeglsenc: Remove redundant implicit checks
Now that the proper buffer size is calculated (and checked) before
allocating the buffer, it is known that the buffer always suffices.
So use the unchecked PutBit-API; and also use an unchecked bitstream
reader as we check ourselves.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-15 12:06:32 +02:00
Andreas Rheinhardt
f249c32eff avcodec/jpeglsenc: Avoid intermediate buffer, allow user-supplied buffers
Up until now, the JPEG-LS encoder allocated a worst-case-sized packet
at the beginning of each encode2 call; then it wrote the packet header
into its destination buffer and encoded the actual packet data;
said data is written into another worst-case-sized buffer, because it
needs to be escaped before being written into the packet buffer.
Finally, because the packet buffer is worst-case-sized, the generic
code copies the actually used part into a fresh buffer.

This commit changes this: Allocating the packet and writing the header
into it is deferred until the actual data has been encoded and its size
is known. This gives a good upper bound for the needed size of the packet
buffer (the upper bound might be 1/15 too large) and so one can avoid the
implicit intermediate buffer and support user-supplied buffers by using
ff_get_encode_buffer().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-15 11:56:35 +02:00
Andreas Rheinhardt
634a187b9b avcodec/jpeglsenc: Allocate buffer with fixed size only once
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-15 11:45:23 +02:00
Andreas Rheinhardt
79402e2c36 avcodec/jpeglsenc: Check for invalid dimensions
The dimensions are written on two bytes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-15 11:32:15 +02:00
Andreas Rheinhardt
c9a79532e5 avcodec/libx264: Fix redundant setting of caps_internal
Exists since 8a129077cc.
Fixes a -Winitializer-overrides warning when building with Clang.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-14 13:58:02 +02:00
Anton Khirnov
aa726eaed9 lavc/pngdec: fix updating reference frames for APNG_DISPOSE_OP_BACKGROUND
They should be treated the same as APNG_DISPOSE_OP_NONE.

Broken in 5663301560.

Fixes #9184.
2021-05-14 11:15:13 +02:00