Compare commits

...

128 Commits

Author SHA1 Message Date
Michael Niedermayer 239f2c733d Bump micro for 8.1.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-04 00:07:35 +02:00
James Almer 6266867e7b avcodec/av1dec: check that primary_ref_frame is within range
Fixes CVE-2026-30997

Fixes: Out-of-Bounds Access
Found-by: Xinghang Lv
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1a2c16fe51)
2026-05-03 15:58:37 -03:00
Michael Niedermayer 2c28491579 Preparing 8.1.1 release
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:42:27 +02:00
Michael Niedermayer 140d581786 avcodec/aac/aacdec_usac_mps212: fix attach_lsb() OOB after huff_decode
Fixes: VS-FF-2026-0001/poc.wav

Reported-by: Vuln Seeker Cyber Security Team
(cherry picked from commit 2e32276872)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:25:01 +02:00
Michael Niedermayer e2c6836694 avcodec/dfpwmdec: Check nb_samples
Fixes: integer overflow

Found-by: Dhiraj Mishra <mishra.dhiraj95@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 118bddf0ce)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:25:01 +02:00
Michael Niedermayer d2597ecda6 avcodec/alsdec: do not set nbits invalidly
note that the spec actually disallows the 0 case too but we are
a little lenient here so the full 24bit twos-complement range can be handled

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7ae36ceba9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:25:00 +02:00
Michael Niedermayer 0a69adf4ee swscale/swscale_unscaled: adjust last line copy
Fixes: out of array access
Fixes: DFVULN-694

*Reporter: Zhenpeng (Leo) Lin at depthfirst*

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 43a0715e30)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:25:00 +02:00
Michael Niedermayer 1d24758bd1 swscale/swscale: Check srcSliceY and srcSliceH
Obviously noone should pass negative values, they make no sense, but better to
explicitly check

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7d0837a742)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:25:00 +02:00
Michael Niedermayer 0a752b7913 avformat/avidec: check LIST size in avi_load_index()
This avoids an unsigned integer underflow and passing that large value to ff_read_riff_info()

(cherry picked from commit 2678bce860)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:25:00 +02:00
depthfirst-dev[bot] 847b2afc9c avformat/avidec: validate INFO list size before parsing
Reject INFO list chunks that are too small to contain the expected
4-byte list type field before calling ff_read_riff_info().

The parser subtracts 4 from the list size when handing the remaining
payload to ff_read_riff_info(). If the chunk is smaller than 4 bytes,
that underflows the expected structure and should be treated as invalid
input.

Fixes: DFVULN-607

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

(cherry picked from commit f1c3f1cae1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:25:00 +02:00
Michael Niedermayer bad324bd68 avformat/matroskadec: Check audio.sub_packet_h * audio.frame_size
Fixes: out of array access
Fixes: poc_matroska.mkv

This issue requires manually increasing the malloc limit
(-max_alloc 4294967296)

Found-by: Guanni Qu <qguanni@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f47ca0a5e6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:59 +02:00
Michael Niedermayer eaf5015aa8 libavformat/xwma: fix overflow in seek position
Fixes: signed integer overflow

Found-by: Marius Momeu <marius.momeu@berkeley.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2d4ec46345)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:59 +02:00
Michael Niedermayer e483eb921d avformat/pcm: Use 64bit for byte_rate
Fixes: integer overflow

Found-by: Marius Momeu <marius.momeu@berkeley.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9d9250e5da)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:59 +02:00
Michael Niedermayer 76dddbc961 avcodec/adpcm: signed integer overflow in ADPCM_N64
Fixes: signed integer overflow

Found-by: Marius Momeu <marius.momeu@berkeley.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b45a6d3f76)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:59 +02:00
Michael Niedermayer af2a176fd2 avcodec/hevc/ps: validate rep_format dimensions in multi-layer SPS
When an SPS uses the multi-layer extension (nuh_layer_id > 0 with
sps_max_sub_layers_minus1 == 7), width and height are taken from the
VPS rep_format without the av_image_check_size() validation that the
direct path performs.  HEVC F.7.4.3.1.1 requires rep_format pic
dimensions to satisfy the constraints in 7.4.3.2.1, including
"pic_width_in_luma_samples shall not be equal to 0".

Run the same av_image_check_size() check in the multi-layer-extension
path so the SPS is rejected before it reaches setup_pps().

Fixes: VS-FF-2026-0003/poc.flv
Fixes: out of array access

Found-by: Vuln Seeker Cyber Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0f5705959d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:59 +02:00
Marius Momeu 698000f5bd avfilter/vf_kerndeint: Check for minimum height
Fixes: out of array access

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e32b2c8886)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:59 +02:00
Marius Momeu f6dd450a26 avcodec/ralf: Add the missing return statement after the error log
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ff3223b5d6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:58 +02:00
Michael Niedermayer 31855e032c avfilter/vf_codecview: Clamp block to the visible frame region
Fixes: write into the padding area of the frame

Found-by: Marius Momeu <marius.momeu@berkeley.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c568f40597)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:58 +02:00
Michael Niedermayer 77f2c227c2 avcodec/zmbv: reject XOR data that overruns the decompression buffer
Add a per-block bounds check at the start of each XOR block so the
read is rejected before src crosses decomp_len, and propagate the
error from decode_frame().

Fixes: out of array read

Found-by: Seung Min Shin
(cherry picked from commit 2a991a3475)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:58 +02:00
Michael Niedermayer 102c590a5f avcodec/rasc: fix heap use-after-free in decode_move()
Use a separate scratch buffer (s->mv_scratch) for the type-0 pixel
copy so s->delta and mc are not disturbed for the lifetime of
decode_move().  The new buffer is freed in decode_close().

Found-by: Seung Min Shin
Patch based on suggsted fix by Seung Min Shin

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2f60af465a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:58 +02:00
depthfirst-dev[bot] ad62419fb8 avformat/rtpdec_mpeg4: reject zero-length AU header sections
Reject AU header sections with a signaled length of zero in
rtp_parse_mp4_au().

The AU-headers-length field specifies the length in bits of the AU header
section that immediately follows. A zero-length section is not useful input
for this parser and can lead to invalid downstream state, so reject it
up front together with oversized values.

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: OOB read
(cherry picked from commit 8010aa2193)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:58 +02:00
Niels Provos 874f26fe96 avcodec/hevc/refs: Check multiplication in alloc_frame()
Fixes: integer overflow on 32bit
(cherry picked from commit fd5023053a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:57 +02:00
depthfirst-dev[bot] dc3742fd7f fftools/ffmpeg_opt: validate stream index in negative map handling
Negative -map processing iterates previously parsed stream map entries
and dereferences input_files[m->file_index]->ctx->streams[m->stream_index]
without validating that stream_index is in range.

A malformed earlier map can leave m->stream_index negative, which causes
an out-of-bounds read when a later negative map walks existing entries.
Check that stream_index is non-negative and below nb_streams before
calling stream_specifier_match().

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: DFVULN-695
(cherry picked from commit 25a98586cc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:57 +02:00
Flavio Milan cdd6df0104 avformat/rtmpproto: prevent integer overflow accumulating FLV buffer size
Fixes: out of array access
(cherry picked from commit a45a91b23b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:57 +02:00
depthfirst-dev[bot] 2d646e5584 avformat/rtmpproto: validate compressed SWF header length
Reject truncated compressed SWF input before attempting to read the
8-byte header in rtmp_calc_swfhash().

Compressed SWF data identified by the "CWS" signature must be at least
8 bytes long to contain the fixed header. Bail out early when the input
is shorter to avoid operating on malformed data.

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: DFVULN-612
(cherry picked from commit 52b78cd3fe)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:57 +02:00
depthfirst-dev[bot] 62a87e5516 avformat/rtsp: Fix out-of-bounds read in SDP parser when control_url is empty
Guard against empty string before reading the last byte in control_url.
When parsing relative a=control: paths, if no base control URL was set,
the code would access control_url[strlen(control_url)-1] which on an
empty string causes a size_t underflow and out-of-bounds read.

Now compute the length first and check for len == 0 before array access.

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: DFVULN-611
(cherry picked from commit 1a00ea51cb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:57 +02:00
depthfirst-dev[bot] 19fc59fde6 avformat/rtpdec_latm: avoid integer overflow in LATM length parsing
latm_parse_packet() accumulated attacker-controlled AU length bytes in
a signed int and later checked data->pos + cur_len against data->len.
That addition could overflow, allowing malformed packets to bypass the
bounds check and drive memcpy() far past the end of the LATM buffer.

Reject length-byte accumulation that would exceed the remaining packet
size, and compare cur_len against the remaining buffer space using
subtraction so the bounds check cannot overflow.

Fixes: DFVULN-610

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

(cherry picked from commit 664d44a825)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:57 +02:00
Michael Niedermayer 0ba002f92d avcodec/h264: recompute per-slice direct mode state for every slice
Regression since: 7f05c5cea0
Fixes: poc10
Fixes: null pointer dereference

Reported-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1772386392)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:56 +02:00
Michael Niedermayer 8462c37595 avcodec/h264_refs: Clear stale pointers from ref_list
Testcase: poc10.bin

Reported-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1886c3269d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:56 +02:00
Michael Niedermayer 6c2e9930b2 avcodec/pdvdec: Check input space before buffer allocation
this rejects packets whose claimed decompressed frame would require a deflate ratio beyond the format's theoretical 1032:1 limit

Fixes: Timeout
Fixes: 474457186/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PDV_fuzzer-5366108782919680

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b801f1fe6d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:56 +02:00
Kacper Michajłow 5bb3c22021 avformat/concat: guard total_size overflow
Fixes: 466797413/clusterfuzz-testcase-minimized-fuzzer_options_parser-6015183727427584
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
(cherry picked from commit 702b0784b7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:56 +02:00
Michael Niedermayer d26ce3ec60 avformat/iamf_parse.c: Fix potential integer overflow in opus_decoder_config()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 016a241102)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:56 +02:00
Michael Niedermayer d1b0069077 avcodec/wmaenc: Fix missing padding in extradata
Reported-by: Kenan Alghythee <kalghy2@uic.edu>
(cherry picked from commit 23227a444d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:55 +02:00
Michael Niedermayer 7d612d27ae avformat: Fix various extradata padding issues
Reported-by: Kenan Alghythee <kalghy2@uic.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8439e02037)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:55 +02:00
Michael Niedermayer 031fae5c41 avcodec/tdsc: remove double stride adjustment
Fixes: out of array access

Found-by: Seung Min Shin
Patch based on suggested fix by Seung Min Shin
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 242ff799c7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:55 +02:00
depthfirst-dev[bot] f9a9fae557 avformat/cafdec: fix negative index use in read_seek
av_index_search_timestamp() returns a negative value when a seek target
cannot be resolved from the stream index. Bail out before using that
result as an index into sti->index_entries to avoid out-of-bounds reads.

Fixes: Buffer underflow

Fixes: DFVULN-608

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

(cherry picked from commit 5408059eb7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:55 +02:00
Michael Niedermayer 3e57f240cc avcodec/notchlc: Check 255 loops
Fixes: integer overflow

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 05817dc7dd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:55 +02:00
Michael Niedermayer b5489087f3 avformat/rtpdec_jpeg: check qtable_len
Fixes: out of array access
Fixes: 605/pc.py

Based-on patch by depthfirst

*Reporter: Zhenpeng (Leo) Lin at depthfirst*

(cherry picked from commit 91d29be49a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:55 +02:00
ASTRA 66d96bd65e avformat/vividas: use-of-uninitialized-value in keybuffer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 26732641fb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:54 +02:00
Michael Niedermayer cdfa960ddf avcodec/tdsc: Check jpeg size
Fixes: out of array read
Fixes: tdsc_tile_dim_mismatch.avi

Found-by: Ante Silovic <asilovic155@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bb69a090a7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:54 +02:00
Michael Niedermayer ee35cdda74 avcodec/tdsc: Better input size check
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bf4eb194cf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:54 +02:00
Michael Niedermayer e9fc881384 avcodec/tdsc: Check tile_size
Fixes: out of array read
Fixes: tdsc_war_groom_far4096.avi

Found by: Ante Silovic <asilovic155@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e9e6fb8798)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:54 +02:00
Michael Niedermayer df197112c2 avcodec/decode: Better documentation for ff_set_dimensions()
Clarify what is checked and that it avoids explicit generic overflow checks

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9572ab7f45)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:54 +02:00
Dale Curtis 76fd415fce avformat/mov: Limit maximum box size for mov_read_lhvc()
Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
(cherry picked from commit a7d42bfba8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:53 +02:00
depthfirst-dev[bot] dd2a960971 avformat/mov: reject dimg references with zero entries
Reject dimg entries with a zero reference count in mov_read_iref_dimg().
This is the earliest point where the parser learns how many input images
a derived HEIF item references, so it is the right place to enforce the
invariant.

If entries == 0 is accepted here, the value is stored in HEIFGrid.nb_tiles,
later propagated by read_image_iovl() into AVStreamGroupTileGrid.nb_tiles,
and finally consumed in istg_parse_tile_grid(), which assumes at least one
tile and reads tg->offsets[tg->nb_tiles - 1]. With zero tiles, that
assumption breaks and leads to the out-of-bounds access seen in ASan.

Fixing the problem at the parser boundary is preferable to adding a later
workaround because it prevents creation of an invalid derived-image state
and stops that malformed state from reaching downstream consumers.

This is also consistent with the HEIF specification. Both iovl and grid
derived images are formed from one or more input images, and for grid the
dimg reference count must equal rows * columns; since rows and columns are
encoded as *_minus_one + 1, that count cannot be zero. A zero dimg entry
count is therefore invalid input and should be rejected when parsed.

(cherry picked from commit 68ea660d83)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:53 +02:00
Michael Niedermayer 9e5a493d71 avformat/mov: check extradata in mov_read_dops()
We do want to limit an attackers ability to change once parsed structures.
So once extradata (or another array) is finished and possibly has been used we do not
want to allow an attacker to change it.

This reduces the attack surface

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7c67748537)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:53 +02:00
Ted Meyer 797504295b avformat/mov: Check read size for opus extradata
in mov_read_dops, `size` bytes is allocated for
`st->codecpar->extradata`, but ff_alloc_extradata doesn't memset, so the
contents of that buffer are just old heap data. If `avio_read` reads
fewer bytes than were requested, uninitialized data can still be left in
the extradata buffer, which is operated on by AV_WL16A and AV_WL32A.

I think the best solution here is to just check the read size and ensure
it's filling the extradata buffer in it's entirety, or erroring out if
there isn't enough data left.

(cherry picked from commit 53cd2c9f2a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:53 +02:00
depthfirst-dev[bot] a3abd79fde avformat/rtspdec: reject non-positive ANNOUNCE Content-Length
rtsp_read_announce() treated any non-zero Content-Length as valid,
including negative values parsed via strtol(). This could send invalid
sizes into allocation, body reads and trailing NUL writes.

Accept only strictly positive SDP body lengths and reject invalid
Content-Length values with AVERROR_INVALIDDATA.

Found-by: Seung Min Shin (was reported to us on 10th April)
CC: 신승민 <guncraft2000@naver.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit eec78bdac1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:53 +02:00
ASTRA 01d380bdb2 avformat/wavdec: Fix use-of-uninitialized-value in find_guid()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 163ba704b7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:52 +02:00
Marvin Scholz 9cbd7e2589 lavfi: vf_drawtext: check memory allocation
Switch to av_calloc and check the allocation.

Fix #22867

(cherry picked from commit 69072fe8d8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:52 +02:00
Michael Niedermayer 9601014f1e avcodec/svq1dec: Check input space for minimum
We reject inputs that are significantly smaller than the smallest frame.
This check raises the minimum input needed before time consuming computations are performed
it thus improves the computation per input byte and reduces the potential DoS impact

Fixes: Timeout
Fixes: 472769364/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ1_DEC_fuzzer-5519737145851904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d538a71ad5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:52 +02:00
Paul Adenot 5fe5d2a13b avcodec/vp9: Rollback dimensions when format is rejected
Fixes: BMO#2029296

Found-by: Mozilla Security Team, Paul Adenot for the write variant
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6c114bd6fa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:52 +02:00
Michael Niedermayer 44fe8891c8 avformat/rtpdec_qdm2: Check block_size
Fixes: out of array access
no testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 29a0973855)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:52 +02:00
Zhao Zhili 5a1dc812b1 avfilter/vf_ssim360: fix integer overflow in tape_length allocation
tape_length * 8 overflows 32-bit int for large input widths. Then
av_malloc_array() allocates a tiny buffer while the subsequent
loop writes tape_length*8 BilinearMap entries, causing
heap-buffer-overflow.

Validate the value in float before converting to int and left
shifting, to avoid both float-to-int and signed left shift
overflow UB. Also split av_malloc_array() arguments to avoid
the multiplication overflow.

Fixes: #21511

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
(cherry picked from commit b62ae766c1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:52 +02:00
Michael Niedermayer fa1ac7bd8a avcodec/escape130: Initialize old_y_avg
Fixes: use of uninitialized memory

Found-by: Carl Sampson <carl.sampson@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d0761626cf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:51 +02:00
Michael Niedermayer ea84befff6 avutil/samplefmt: Dont claim that av_get_sample_fmt_string checks sample_fmt
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b11729f154)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:51 +02:00
Hankang Li d5d2f063ff swscale: fix signed integer overflow in color conversion arithmetic
Fixes: #22331

Signed-off-by: Hankang Li <hankang201222@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e33b3962e5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:51 +02:00
Sankalpa Sarkar 08a31e67af avformat: check avio_read() return values in dss/dtshd/mlv
Multiple demuxers call avio_read() without checking its return
value. When input is truncated, destination buffers remain
uninitialized but are still used for offset calculations, memcmp,
and metadata handling. This results in undefined behavior
(detectable with Valgrind/MSan).

Fix this by checking the return value of avio_read() in:
- dss.c: dss_read_seek() — check before using header buffer
- dtshddec.c: FILEINFO chunk — check before using value buffer
- mlvdec.c: check_file_header() — check before memcmp on version

Fixes: #21520
(cherry picked from commit 65eed0732c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:51 +02:00
Ruikai Peng 8c7ec4b4b5 avformat/whip: check RTP history packet size before RTX retransmission
handle_rtx_packet() constructs an RTX packet by shifting the payload
of a history entry to insert the original sequence number. It uses
memmove with length (ori_size - 12), but never checks that ori_size
is at least 12 bytes (the minimum RTP header size).

Zero-initialized history slots have seq == 0 and size == 0.
rtp_history_find() only compares sequence numbers, so an RTCP NACK
requesting seq 0 early in a session matches such a slot. The
subtraction then wraps to a huge value when converted to size_t,
causing a stack buffer overflow in memmove().

Add a little size check to reject history entries smaller than and
valid RTP header before any arithmetic on their size.

Found-by: Pwno
(cherry picked from commit 7466d8a850)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:51 +02:00
Michael Niedermayer 0b0a2d236d avcodec/aac/aacdec_usac: Implement missing bits of otts_bands_phase and residual_bands computation
Fixes: out of array access
Fixes: matejsmycka/poc.mp4

Introducing commit: `baad75cafa6bac298b72c177f657a2eb8e31cff1` — "aacdec_usac: add support for parsing Mpsp212 (MPEG surround)", 2025-11-17.

Found-by: Matěj Smyčka <matejsmycka@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ddcb9dd3b5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:50 +02:00
Priyanshu Thapliyal 71818d86ae avcodec/alsdec: preserve full float value in zero-truncated samples
Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
(cherry picked from commit d1bcaab230)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:50 +02:00
Priyanshu Thapliyal e927c11cfc avcodec/alsdec: propagate read_diff_float_data() errors in read_frame_data()
The return value of read_diff_float_data() was previously ignored,
allowing decode to continue silently with partially transformed samples
on malformed floating ALS input. Check and propagate the error.

All failure paths in read_diff_float_data() already return
AVERROR_INVALIDDATA, so the caller fix is sufficient without
any normalization inside the function.

Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
(cherry picked from commit febc82690d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:50 +02:00
Priyanshu Thapliyal f5e4bf6dbd avcodec/alsdec: fix mantissa unpacking in compressed Part A path
Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
(cherry picked from commit ae6f233988)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:50 +02:00
Zhao Zhili c47b33c61c avfilter/vf_drawtext: fix newline rendered as .notdef glyph
GET_UTF8 advances the pointer past the newline byte before the
newline check, so shape_text_hb receives text that includes the
newline character. Since HarfBuzz does not treat U+000A as
default-ignorable, it gets shaped into a .notdef glyph.

Fixes #21565

Reported-by: scriptituk <info@scriptit.uk>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
(cherry picked from commit fd9f1e9c52)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:50 +02:00
Priyanshu Thapliyal f7103aa69e avcodec/pngdec: fix dead overflow check in decode_text_to_exif()
The expression (exif_len & ~SIZE_MAX) is always 0 for size_t,
making the overflow guard permanently dead code.

Reported-by: Guanni Qu <qguanni@gmail.com>
Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
(cherry picked from commit e7b4ddc9d6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:50 +02:00
Kacper Michajłow b81bc90e0c avcodec/vp9: fix cbs fragment leak on error
Fixes: c0bf1382a7
Fixes: 490257166/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP9_fuzzer-6185031050788864
Fixes: 490131106/clusterfuzz-testcase-minimized-fuzzer_loadfile-5438205762797568
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
(cherry picked from commit e17d84ac8a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:49 +02:00
marcos ashton c3fa0d869b libavfilter/vf_v360: fix operator precedence in stereo loop condition
The loop condition in the DEFINE_REMAP macro:

  stereo < 1 + s->out_stereo > STEREO_2D

is parsed by C as:

  (stereo < (1 + s->out_stereo)) > STEREO_2D

Since STEREO_2D is 0 and relational operators return 0 or 1, the
outer comparison against 0 is a no-op for STEREO_2D and STEREO_SBS.
But for STEREO_TB (value 2) the loop runs 3 iterations instead of 2,
producing an out-of-bounds stereo pass.

Add parentheses so the comparison is evaluated first:

  stereo < 1 + (s->out_stereo > STEREO_2D)

This gives 1 iteration for 2D and 2 for any stereo format (SBS or TB),
matching the actual number of stereo views.

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
(cherry picked from commit 9559a6036d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:49 +02:00
Priyanshu Thapliyal ff129c8f04 avcodec/alsdec: fix abs(INT_MIN) UB in read_diff_float_data()
Replace abs() with FFABSU() to avoid undefined behavior when
raw_samples[c][i] == INT_MIN. Per libavutil/common.h, FFABS()
has the same INT_MIN UB as abs(); FFABSU() is the correct
helper as it casts to unsigned before negation.

Reported-by: Guanni Qu <qguanni@gmail.com>
Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
(cherry picked from commit 1853c80e20)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:49 +02:00
Weidong Wang 097668f94c avformat/rsd: reject short ADPCM_THP extradata reads
Use ffio_read_size() to enforce exact-length reads of the per-channel
ADPCM_THP coefficient tables. Previously the return value of
avio_read() was unchecked, silently accepting truncated extradata.

(cherry picked from commit 06d19d000d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:49 +02:00
Ted Meyer 355269a9f0 avformat/mov: Handle integer overflow in MOV parser
A chromium UBSAN fuzzer caught this instance.

(cherry picked from commit fc7cab6be3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:49 +02:00
Michael Niedermayer 059489977b avcodec/dvdsub_parser: Fix buf_size check
Fixes: signed integer overflow
Fixes: out of array access
Fixes: dvdsub_int_overflow_mixed_ps.mpg

Found-by: Quang Luong of Calif.io in collaboration with OpenAI Codex
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1bde76da89)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:48 +02:00
marcos ashton 93b8ad91bf avfilter/af_pan: fix sscanf() return value checks in parse_channel_name
sscanf() returns EOF (-1) on input failure, which is non-zero and
passes a bare truthy check. When this happens, the %n directive is
never processed, so len stays uninitialized. Using that value to
advance the arg pointer causes an out-of-bounds read and crash.

Check for >= 1 instead, matching the fix applied to the other
sscanf() call in init() by commit b5b6391d64.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22451
Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
(cherry picked from commit a43ea8bff7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:48 +02:00
marcos ashton ff47e29b10 avutil/bswap: fix implicit conversion warning in av_bswap64
Explicitly cast uint64_t arguments to uint32_t before passing them
to av_bswap32(). The truncation is intentional (extracting low and
high halves), but clang on macOS 26 warns about it.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22453
Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
(cherry picked from commit dfa53aae5f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:48 +02:00
James Almer 3127b0db72 avcodec/h2645_sei: don't use provider_code uninitialized
Regression since 8172be423e.
Fixes Coverity issue CID 1689618.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit e22a1ed712)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:24:48 +02:00
AdityaTeltia 75d37c499d avformat/hls_sample_encryption: add missing padding for audio setup buffer
Fixes ticket #22890.

The ff_hls_senc_parse_audio_setup_info function passes setup_data to
parsers like avpriv_ac3_parse_header and init_get_bits8 which require
the buffer to be padded with AV_INPUT_BUFFER_PADDING_SIZE bytes at the end.

(cherry picked from commit 71d5fa8d4d)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-04-28 11:41:32 +02:00
Jun Zhao 7f5c90f77e lavc/videotoolbox_vp9: fix vpcC flags offset
Write the 24-bit vpcC flags field at the current cursor position after
the version byte. The previous code wrote to p+1 instead of p, leaving
one byte uninitialized between version and flags and shifting all
subsequent fields (profile, level, bitdepth, etc.) by one byte.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
(cherry picked from commit 19c4bcae68a16ea893b0558d720dd4a2ecd58f0f)
2026-04-15 23:13:24 +08:00
Jun Zhao 0fa756d03d lavc/videotoolboxenc: return SEI parse errors
Return the actual find_sei_end() error when SEI appending fails instead of
reusing the previous status code. This preserves the real parse failure for
callers instead of reporting malformed SEI handling as success.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
(cherry picked from commit f7c04283367269c7aef2505a1839fb3ea9362330)
2026-04-15 23:13:24 +08:00
Stéphane Cerveau 735c84b57f vulkan: fix encode feedback query handling
Check that the driver supports both BUFFER_OFFSET and BYTES_WRITTEN
encode feedback flags before creating the query pool, failing with
EINVAL if either is missing.

Set these flags explicitly instead of masking off HAS_OVERRIDES with a
bitwise NOT, which could pass unrecognized bits from newer drivers to
vkCreateQueryPool causing validation errors and
crashes.

(cherry picked from commit 3f9e04b489)
2026-04-14 23:32:41 +02:00
James Almer a3475e2554 avcodec/cbs_lcevc: fix writing process blocks with size 6
6 is an undefined value for payload_size_type. For those, 7 is used to signal
a custom_byte_size synxtax element.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 35a1e43a6a)
2026-03-24 18:06:22 -03:00
James Almer bd7f101bda avformat/mov: don't try to create an LCEVC group if there's a single track
In this scenario, as it's the case with DASH segments, the lcevc track will be
alone but potentially have a sbas tref entry referencing itself, which will
make avformat_stream_group_add_stream() fail.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit e1158301f0)
2026-03-23 10:51:59 -03:00
Martin Storsjö 3ec48e4bc6 aarch64: Add Armv9.3-A GCS (Guarded Control Stack) support
Signal that our assembly is compliant with the GCS feature, if
the GCS feature is enabled in the compiler (available since Clang
18 and GCC 15) - this is enabled by -mbranch-protection=standard
with a new enough compiler.

GCS doesn't require any specific modifications to the assembly
code, but requires that all functions return to the expected call
address (checked through a shadow stack).

(cherry picked from commit 846746be4b)
2026-03-20 13:12:08 +02:00
Martin Storsjö 2bb6264105 aarch64: hevcdsp: Make returns match the call site
For cases when returning early without updating any pixels, we
previously returned to return address in the caller's scope,
bypassing one function entirely. While this may seem like a neat
optimization, it makes the return stack predictor mispredict
the returns - which potentially can cost more performance than
it gains.

Secondly, if the armv9.3 feature GCS (Guarded Control Stack) is
enabled, then returns _must_ match the expected value; this feature
is being enabled across linux distributions, and by fixing the
hevc assembly, we can enable the security feature on ffmpeg as well.

(cherry picked from commit 1f7ed8a78d)
2026-03-20 13:12:04 +02:00
James Almer 9abdfda6f2 avcodec/lcevcdec: don't try to derive final dimensions from SAR
Not only do some sources not provide an aspect ratio, as is the case of
MPEG-TS, but also some enhanced streams have no change in dimensions, and this
heuristic would generate bugus values.
Instead, we need to parse the LCEVC bitstream for a Global Config process block
in order to get the actual dimensions. This add a little overhead, but it can't
be avoided.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 49d75d81f6)
2026-03-18 13:35:56 -03:00
James Almer 395dc6fa27 avcodec/lcevc_parser: move the resolution type table to a header
Will be useful in the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit c5aa31d252)
2026-03-18 13:35:56 -03:00
James Almer a2e15f15b0 avcodec/cbs_lcevc: don't look for process blocks if the unit was not decomposed
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit ce7375fc17)
2026-03-18 13:35:56 -03:00
Marvin Scholz 9047fa1b08 avutil: attributes: fix AV_HAS_STD_ATTRIBUTE checks
Attributes with the language-supported [[attr]] style are only supported
since C++11 and C23 respectively, so this needs to be accounted for in
these checks.

This solves a huge amount of warning spam of:
  warning: [[]] attributes are a C23 extension [-Wc23-extensions]
when using --enable-extra-warnings.

(cherry picked from commit cce545a74b)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-03-16 18:46:24 +01:00
Michael Niedermayer e1a84cd003 doc/Doxyfile: set version to 8.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-16 17:24:34 +01:00
Michael Niedermayer 5c923e26ab avformat/wsddec: Use ffio_read_size() in get_metadata()
Fixes: use of uninitialized memory
Fixes: 492587173/clusterfuzz-testcase-minimized-ffmpeg_dem_WSD_fuzzer-6596163492184064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4b83833087)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-16 17:23:47 +01:00
Nicholas Carlini c471fce2bf avformat/mpegts: fix descriptor accounting across multiple IOD descriptors
pmt_cb() passes mp4_descr + mp4_descr_count as the output base but
MAX_MP4_DESCR_COUNT (16) as the capacity, not the remaining capacity.
init_MP4DescrParseContext() resets d->descr_count to 0 on every call,
so the bounds check at parse_MP4ESDescrTag compares a fresh 0 against
16 regardless of the shifted base.

A PMT with two IOD descriptors of 16 ESDescrs each will crash. The first
fills the buffer mp4_descr[0..15], and then the second writes
mp4_descr[16..31] -- 1152 bytes past the end of the stack.

This change passes the remaining capacity instead of always passing 16.
The writeback in mp4_read_iods is incremented so the caller's running
count is preserved.

Fixes: stack-buffer-overflow

Found-by: Nicholas Carlini <nicholas@carlini.com>
(cherry picked from commit 3e8bec7871)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-16 17:23:47 +01:00
Weidong Wang 5f3122760f avcodec/xxan: zero-initialize y_buffer
Fixes ticket #22420.

When the first decoded frame is type 1, xan_decode_frame_type1() reads y_buffer as prior-frame state before any data has been written to it.
Since y_buffer is allocated with av_malloc(), this may propagate uninitialized heap data into the decoded luma output.

Allocate y_buffer with av_mallocz() instead.

(cherry picked from commit 236dbc9f82)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-16 17:23:47 +01:00
Anton Khirnov 43a4771cd0 opus/dec_celt: avoid emph_coeff becoming a subnormal
This happens for silence frames, which on many CPUs massively slows down
processing the decoded output.

Cf. https://github.com/Genymobile/scrcpy/issues/6715

(cherry picked from commit 5b112b17c0)
2026-03-16 11:53:14 +01:00
Michael Niedermayer 8a8881d226 RELEASE: prepare for 8.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-16 03:42:03 +01:00
Michael Niedermayer 7dad4d2cb5 Changelog, remove "version <next>" 2026-03-16 03:42:03 +01:00
Michael Niedermayer a5a1653a9e RELEASE_NOTES: Based on the version from 8.0
Name suggested by 2 people on ML, all other suggestions had only 1 supporter

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-16 03:42:03 +01:00
James Almer 0a8bf5fcaa avcodec/bsf/extract_extradata: don't use a NULL pointer to initialize an empty PutByteContext
Fixes UB in the form or adding a 0 offset to a NULL pointer, and substracting a
NULL pointer from another.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-15 19:44:21 -03:00
James Almer 29e0d0ef13 avcodec/h2645_sei: fix parsing payloads for UK country_code
The correct syntax after country_code is:

t35_uk_country_code_second_octet      b(8)
t35_uk_manufacturer_code_first_octet  b(8)
t35_uk_manufacturer_code_second_octet b(8)

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 8172be423e)
2026-03-15 17:46:51 -03:00
James Almer 93c915a572 avcodec/h2645_sei: reindent after the previous change
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 3af824a540)
2026-03-15 17:46:51 -03:00
James Almer fcbbd8b394 avcodec/h2645_sei: refactor decode_registered_user_data()
Switch statements are cleaner and will be useful for an upcoming change.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 64edbb37f1)
2026-03-15 17:46:51 -03:00
Zhao Zhili 7df9a56f0d avformat/rtmpproto: fix listen_timeout conversion for special negative values
rtmpproto converts listen_timeout to milliseconds by multiplying it
by 1000 before passing it to TCP. However, negative values are special
sentinels (e.g., -1 for infinite wait) and should not be multiplied.

This worked prior to commit 49c6e6cc44 because there was no range
validation. Since that commit, ff_parse_opts_from_query_string
validates option values against their declared ranges, causing these
multiplied negative values to fail.

Fixes ticket #22469.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
(cherry picked from commit f189657ec6)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-03-15 03:15:37 +00:00
Michael Niedermayer 6f890cb104 avcodec/exr: Check input space before reverse_lut()
Fixes: use of uninitialized memory
Fixes: 490707906/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-6310933506097152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 70286d59f1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:58 +01:00
Nicholas Carlini 42692d0f57 avformat/mpegts: remove JPEG-XS early return on invalid header_size
new_pes_packet() moves a buffer with pkt->buf = pes->buffer before
JPEG-XS validation. If header_size > pkt->size, an early return leaves
pes->buffer as a stale alias of pkt->buf with refcount 1. Later,
mpegts_read_packet() calls av_packet_unref(), freeing the buffer
through pkt->buf. The flush loop then re-enters new_pes_packet() and
dereferences the dangling pes->buffer; a second path hits it via
av_buffer_unref() in handle_packets() after a seek.

Drop the early return. The packet is delivered with AV_PKT_FLAG_CORRUPT
set, matching the PES-size-mismatch case above, and the function falls
through to the normal cleanup path. The else guards the header trim so
pkt->data/pkt->size stay valid for the memset.

Fixes: use after free
Fixes regression since 16f89d342e.

Found-by: Nicholas Carlini <nicholas@carlini.com>
(cherry picked from commit 55bf0e6cd5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:58 +01:00
Michael Niedermayer 259ee609ac avcodec/aac/aacdec_usac_mps212: Introduce a temporary array for ff_aac_ec_data_dec()
This also reverts: c2364e9222

Fixes: out of array access (testcase exists but did not replicate for me)

Founbd-by: Gil Portnoy <dddhkts1@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 770bc1c23a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:58 +01:00
Michael Niedermayer b6a617c8bf avcodec/cbs_h266_syntax_template: Check tile_y
Fixes: invalid state leading to out of array access
Fixes: 490615782/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-4711353817563136

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 12303cd922)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:58 +01:00
Nicholas Carlini a5696b44a6 avcodec/h264_slice: reject slice_num >= 0xFFFF
An H.264 picture with 65536 slices makes slice_num collide with the
slice_table sentinel. slice_table is uint16_t, initialized via
memset(..., -1, ...) so spare entries (one per row, mb_stride =
mb_width + 1) stay 0xFFFF. slice_num is an uncapped ++h->current_slice.
At slice 65535 the collision makes slice_table[spare] == slice_num
pass, defeating the deblock_topleft check in xchg_mb_border and the
top_type zeroing in fill_decode_caches.

With both guards bypassed at mb_x = 0, top_borders[top_idx][-1]
underflows 96 bytes and XCHG writes at -88 below the allocation
(plus -72 and -56 for chroma in the non-444 path).

Fixes: heap-buffer-overflow

Found-by: Nicholas Carlini <nicholas@carlini.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 39e1969303)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:57 +01:00
Jun Zhao 5bc4a9898c lavfi/bwdif: fix heap-buffer-overflow with small height videos
Reproduce:
  ffmpeg -i /tmp/bwdif_test_input_160x4_gray16.jpg -vf "bwdif" -f null -

filter_intra accesses rows 3 lines away via cur[mrefs3] and cur[prefs3].
For small height videos (h <= 4), this causes heap-buffer-overflow.

Add boundary check for filter_intra when YADIF_FIELD_END is set.
The boundary condition (y < 3) or (y + 3 >= td->h) precisely matches
filter_intra's 3-line context requirement.

Test file: 160x4 gray16 JPEG
https://code.ffmpeg.org/attachments/db2ace24-bc00-4af6-a53a-5df6b0d51b15

fix #21570

Reviewed-by: Thomas Mundt <tmundt75@gmail.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
(cherry picked from commit 795bccdaf5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:57 +01:00
Michael Niedermayer b6faea362a avcodec/wmv2dec: More Checks about reading skip bits
Fixes: out of array read with --disable-safe-bitstream-reader
Fixes: poc_wmv2.avi

Note, this requires the safe bitstream reader to be turned off by the user and the user disregarding the security warning

Change suggested by: Guanni Qu <qguanni@gmail.com>
Found-by: Guanni Qu <qguanni@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f73849887c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:57 +01:00
Gil Portnoy ca6e0ee7aa avcodec/cbs_h266_syntax_template: Fix w/h typo
Fixes: out of array access
Fixes: vvc_poc_subpic_wh_bug.h266

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 26dd9f9b56)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:57 +01:00
Oliver Chang f851191ce6 aacdec_usac: skip FD-specific decoding for LPD channels
`spectrum_decode` currently executes Frequency Domain (FD) decoding steps
for all channels, regardless of their `core_mode`. When a channel is in
Linear Prediction Domain (LPD) mode (`core_mode == 1`), FD-specific
parameters such as scalefactor offsets (`sfo`) and individual channel
stream (`ics`) information are not parsed.

This causes a global-buffer-overflow in `dequant_scalefactors`. Because
`spectrum_scale` is called on LPD channels, it uses stale or
uninitialized `sfo` values to index `ff_aac_pow2sf_tab`. In the reported
crash, a stale `sfo` value of 240 resulted in an index of 440
(240 + POW_SF2_ZERO), exceeding the table's size of 428.

Fix this by ensuring `spectrum_scale` and `imdct_and_windowing` are only
called for channels where `core_mode == 0` (FD).

Co-authored-by: CodeMender <codemender-patching@google.com>
Fixes: https://issues.oss-fuzz.com/486160985
(cherry picked from commit d519ab8993)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:57 +01:00
Michael Niedermayer 60f3904718 avformat/dhav: Fix handling or slightly larger files
Fixes: integer overflow
Fixes: 490241718/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-4902512932225024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c5d5fb2309)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:57 +01:00
Michael Niedermayer 56217dccd6 avutil/timecode: Check for integer overflow in av_timecode_init_from_components()
Fixes: integer overflow
Fixes: testcase that calls av_timecode_init_from_components() with hh set explicitly to INT_MAX

Found-by: Youngjae Choi, Mingyoung Ban, Seunghoon Woo
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit eb5d607861)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:56 +01:00
Gil Portnoy 4f72addce1 avcodec/cbs_h266_syntax_template: Fix rows vs columns
Fixes: out of array access
Fixes: vvc_poc_cbs_divergence_max.h266

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 51606de0e9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:56 +01:00
Ted Meyer 1f217b4b7d avformat/mov: do not allocate out-of-range buffers
There's a possibility here with a well-crafted MP4 file containing only
the nested boxes in order: MOOV.TRAK.MDIA.MINF.STBL.SDTP where the
header size uses the 64 bit large size, and the ending stdp box has some
size value >= 0x100000014.

On a 32 bit build of ffmpeg, av_malloc's size parameter drops the high
order bits of `entries`, and and the allocation is now a controlled size
that is significantly smaller than `entries`. The following loop will
then write off the ended of allocated memory with data that follows the
box fourcc.

(cherry picked from commit 86f53f9ffb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:56 +01:00
Karl Mogensen 0ce7bd66a7 avfilter/af_lv2: call lilv_instance_activate before lilv_instance_run
Why: the change is done to comply with lilv expectations of hosts.

Added call lilv_instance_activate in the config_output function to abide by lilv documentation that states it must be called before lilv_instance_run:
"This MUST be called before calling lilv_instance_run()" - documentation source (https://github.com/lv2/lilv/blob/main/include/lilv/lilv.h)

Added call lilv_instance_deactivate in the uninit function to abide by lv2 documentation:
"If a host calls activate(), it MUST call deactivate() at some point in the future" - documentation source (https://gitlab.com/lv2/lv2/-/blob/main/include/lv2/core/lv2.h)

Added instance_activated integer to LV2Context struct to track if instance was activated and only do lilv_instance_deactivate if was activated to abide by lv2 documentation:
"Hosts MUST NOT call deactivate() unless activate() was previously called." - documentation source (https://gitlab.com/lv2/lv2/-/blob/main/include/lv2/core/lv2.h)

Regarding the patcheck warning (possibly constant :instance_activated):
This is a false positive since the struct member is zero-initialized.

Fixes: trac issue #11661 (https://trac.ffmpeg.org/ticket/11661)
Reported-by: Dave Flater
Signed-off-by: Karl Mogensen <karlmogensen0@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fa281d1394)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:56 +01:00
Zhao Zhili 2803bcd5d5 avformat/rtmpproto: fix listen_timeout conversion for special negative values
rtmpproto converts listen_timeout to milliseconds by multiplying it
by 1000 before passing it to TCP. However, negative values are special
sentinels (e.g., -1 for infinite wait) and should not be multiplied.

This worked prior to commit 49c6e6cc44 because there was no range
validation. Since that commit, ff_parse_opts_from_query_string
validates option values against their declared ranges, causing these
multiplied negative values to fail.

Fixes ticket #22469.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
(cherry picked from commit f189657ec6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:56 +01:00
Michael Niedermayer 2cf15d3fc0 avcodec/aom_film_grain: Remove impossible check
fgp is freshly allocated so it cannot be equal to ref

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b4b569f922)
2026-03-15 00:49:55 +01:00
Michael Niedermayer c9cf8cf9c3 avcodec/aom_film_grain: avoid duplicate indexes in ff_aom_parse_film_grain_sets()
Fixes: use after free
Fixes: 478301106/clusterfuzz-testcase-minimized-ffmpeg_dem_HEVC_fuzzer-6155792247226368

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ebb6ac1bc7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:55 +01:00
Michael Niedermayer 21719ece26 avformat/hxvs: Do not allow backward steps in hxvs_probe()
Fixes: infinite loop
Fixes: 487632033/clusterfuzz-testcase-minimized-ffmpeg_dem_IMAGE2_fuzzer-4565877872984064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4ccad70d57)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:55 +01:00
Michael Niedermayer b842218402 swscale/output: fix integer overflows in chroma in yuv2rgba64_X_c_template()
Fixes: signed integer overflow: 130489 * 16525 cannot be represented in type 'int'
Fixes: 488950053/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4627272670969856

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3b98e29da8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:55 +01:00
Michael Niedermayer c88ae59e31 avcodec/lcldec: Fixes uqvq overflow
Fixes: integer overflow
Fixes: 490241717/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZLIB_DEC_fuzzer-4560518961758208

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7241b80422)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:55 +01:00
Olivier Laflamme 711b69c615 fftools/ffprobe: Initialize data_dump_format_id
This was used uninitialized previously

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 10d36e5d3d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:55 +01:00
Michael Niedermayer 511387e49a avformat/aiffdec: Check for partial read
Fixes: read of uninitialized memory
Fixes: 490305404/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6406386140643328

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ba0f8083fd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:54 +01:00
Lynne c9a5f7c6ca hwcontext_vulkan: deprecate AVVulkanDeviceContext.lock/unlock_queue
Without replacement, as VK_KHR_internally_synchronized_queues will be required.

(cherry picked from commit c102e89448)
2026-03-14 18:54:46 +01:00
James Almer 680ac1aa32 avcodec/lcevc_parser: check return value of init_get_bits8()
Fixes coverity issue CID 1684198.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit a9984fec81)
2026-03-13 09:06:53 -03:00
James Almer b013bbf092 avcodec/lcevc_parser: Check that block_size is not negative
Based on 248b481c33

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 125bb2e045)
2026-03-13 09:06:53 -03:00
Michael Niedermayer d8d4a96414 avcodec/bsf/extract_extradata: Replace incorrect size accounting
Fixes: out of array writes
Fixes: 492054712/clusterfuzz-testcase-minimized-ffmpeg_BSF_EXTRACT_EXTRADATA_fuzzer-5705993148497920

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f84c859ec5)
2026-03-12 23:17:53 -03:00
Lynne b1da475805 ffv1enc_vulkan: fix typo
Fixes a segfault when host mapping is unsupported.

(cherry picked from commit 215e22d1f1)
2026-03-10 19:32:38 +01:00
nyanmisaka b6db764c86 fftools/ffmpeg: fix read_key() always return 255 when there was no input
fixup 08d327e

When an uchar is set to -1, it will become 255 when read as an int.
Duplicate variables for two terminal types can also avoid unused variable warnings.

(cherry picked from commit 3f10a054dc)

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-09 17:17:17 +01:00
Michael Niedermayer 0ab823b47a avcodec/bsf/extract_extradata: Check that block_size is not negative
Fixes: out of array access
Fixes: 490576036/clusterfuzz-testcase-minimized-ffmpeg_BSF_EXTRACT_EXTRADATA_fuzzer-4605696279904256

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 248b481c33)
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-08 20:36:52 -03:00
120 changed files with 1013 additions and 366 deletions
+83 -2
View File
@@ -1,8 +1,89 @@
Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
version <next>:
version 8.1.1:
avcodec/aac/aacdec_usac_mps212: fix attach_lsb() OOB after huff_decode
avcodec/dfpwmdec: Check nb_samples
avcodec/alsdec: do not set nbits invalidly
swscale/swscale_unscaled: adjust last line copy
swscale/swscale: Check srcSliceY and srcSliceH
avformat/avidec: check LIST size in avi_load_index()
avformat/avidec: validate INFO list size before parsing
avformat/matroskadec: Check audio.sub_packet_h * audio.frame_size
libavformat/xwma: fix overflow in seek position
avformat/pcm: Use 64bit for byte_rate
avcodec/adpcm: signed integer overflow in ADPCM_N64
avcodec/hevc/ps: validate rep_format dimensions in multi-layer SPS
avfilter/vf_kerndeint: Check for minimum height
avcodec/ralf: Add the missing return statement after the error log
avfilter/vf_codecview: Clamp block to the visible frame region
avcodec/zmbv: reject XOR data that overruns the decompression buffer
avcodec/rasc: fix heap use-after-free in decode_move()
avformat/rtpdec_mpeg4: reject zero-length AU header sections
avcodec/hevc/refs: Check multiplication in alloc_frame()
fftools/ffmpeg_opt: validate stream index in negative map handling
avformat/rtmpproto: prevent integer overflow accumulating FLV buffer size
avformat/rtmpproto: validate compressed SWF header length
avformat/rtsp: Fix out-of-bounds read in SDP parser when control_url is empty
avformat/rtpdec_latm: avoid integer overflow in LATM length parsing
avcodec/h264: recompute per-slice direct mode state for every slice
avcodec/h264_refs: Clear stale pointers from ref_list
avcodec/pdvdec: Check input space before buffer allocation
avformat/concat: guard total_size overflow
avformat/iamf_parse.c: Fix potential integer overflow in opus_decoder_config()
avcodec/wmaenc: Fix missing padding in extradata
avformat: Fix various extradata padding issues
avcodec/tdsc: remove double stride adjustment
avformat/cafdec: fix negative index use in read_seek
avcodec/notchlc: Check 255 loops
avformat/rtpdec_jpeg: check qtable_len
avformat/vividas: use-of-uninitialized-value in keybuffer
avcodec/tdsc: Check jpeg size
avcodec/tdsc: Better input size check
avcodec/tdsc: Check tile_size
avcodec/decode: Better documentation for ff_set_dimensions()
avformat/mov: Limit maximum box size for mov_read_lhvc()
avformat/mov: reject dimg references with zero entries
avformat/mov: check extradata in mov_read_dops()
avformat/mov: Check read size for opus extradata
avformat/rtspdec: reject non-positive ANNOUNCE Content-Length
avformat/wavdec: Fix use-of-uninitialized-value in find_guid()
lavfi: vf_drawtext: check memory allocation
avcodec/svq1dec: Check input space for minimum
avcodec/vp9: Rollback dimensions when format is rejected
avformat/rtpdec_qdm2: Check block_size
avfilter/vf_ssim360: fix integer overflow in tape_length allocation
avcodec/escape130: Initialize old_y_avg
avutil/samplefmt: Dont claim that av_get_sample_fmt_string checks sample_fmt
swscale: fix signed integer overflow in color conversion arithmetic
avformat: check avio_read() return values in dss/dtshd/mlv
avformat/whip: check RTP history packet size before RTX retransmission
avcodec/aac/aacdec_usac: Implement missing bits of otts_bands_phase and residual_bands computation
avcodec/alsdec: preserve full float value in zero-truncated samples
avcodec/alsdec: propagate read_diff_float_data() errors in read_frame_data()
avcodec/alsdec: fix mantissa unpacking in compressed Part A path
avfilter/vf_drawtext: fix newline rendered as .notdef glyph
avcodec/pngdec: fix dead overflow check in decode_text_to_exif()
avcodec/vp9: fix cbs fragment leak on error
libavfilter/vf_v360: fix operator precedence in stereo loop condition
avcodec/alsdec: fix abs(INT_MIN) UB in read_diff_float_data()
avformat/rsd: reject short ADPCM_THP extradata reads
avformat/mov: Handle integer overflow in MOV parser
avcodec/dvdsub_parser: Fix buf_size check
avfilter/af_pan: fix sscanf() return value checks in parse_channel_name
avutil/bswap: fix implicit conversion warning in av_bswap64
avcodec/h2645_sei: don't use provider_code uninitialized
(fforge/pr/22943) avformat/hls_sample_encryption: add missing padding for audio setup buffer
(fforge/pr/22826) lavc/videotoolbox_vp9: fix vpcC flags offset
lavc/videotoolboxenc: return SEI parse errors
vulkan: fix encode feedback query handling
avcodec/cbs_lcevc: fix writing process blocks with size 6
avformat/mov: don't try to create an LCEVC group if there's a single track
(fforge/pr/22563) aarch64: Add Armv9.3-A GCS (Guarded Control Stack) support
aarch64: hevcdsp: Make returns match the call site
(fforge/pr/22545) avcodec/lcevcdec: don't try to derive final dimensions from SAR
avcodec/lcevc_parser: move the resolution type table to a header
avcodec/cbs_lcevc: don't look for process blocks if the unit was not decomposed
version 8.1:
- ffprobe -codec option
+1 -1
View File
@@ -1 +1 @@
8.0.git
8.1.1
+15
View File
@@ -0,0 +1,15 @@
┌──────────────────────────────────────┐
│ RELEASE NOTES for FFmpeg 8.1 "Hoare" │
└──────────────────────────────────────┘
The FFmpeg Project proudly presents FFmpeg 8.1 "Hoare", about 7
months after the release of FFmpeg 8.0.
A complete Changelog is available at the root of the project, and the
complete Git history on https://git.ffmpeg.org/gitweb/ffmpeg.git
We hope you will like this release as much as we enjoyed working on it, and
as usual, if you have any questions about it, or any FFmpeg related topic,
feel free to join us on the #ffmpeg IRC channel (on irc.libera.chat) or ask
on the mailing-lists.
+4
View File
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2025-03-28
API changes, most recent first:
2026-03-14 - xxxxxxxxxx - lavu 60.26.100 - hwcontext_vulkan.h
Deprecate AVVulkanDeviceContext.lock_queue and
AVVulkanDeviceContext.unlock_queue without replacement.
2026-03-07 - c23d56b173a - lavc 62.26.100 - codec_desc.h
Add AV_CODEC_PROP_ENHANCEMENT.
+1 -1
View File
@@ -38,7 +38,7 @@ PROJECT_NAME = FFmpeg
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER =
PROJECT_NUMBER = 8.1.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
+3 -2
View File
@@ -253,7 +253,6 @@ void term_init(void)
/* read a key without blocking */
static int read_key(void)
{
unsigned char ch = -1;
#if HAVE_TERMIOS_H
int n = 1;
struct timeval tv;
@@ -265,6 +264,7 @@ static int read_key(void)
tv.tv_usec = 0;
n = select(1, &rfds, NULL, NULL, &tv);
if (n > 0) {
unsigned char ch;
n = read(0, &ch, 1);
if (n == 1)
return ch;
@@ -289,6 +289,7 @@ static int read_key(void)
}
//Read it
if(nchars != 0) {
unsigned char ch;
if (read(0, &ch, 1) == 1)
return ch;
return 0;
@@ -300,7 +301,7 @@ static int read_key(void)
if(kbhit())
return(getch());
#endif
return ch;
return -1;
}
static int decode_interrupt_cb(void *ctx)
+2
View File
@@ -645,6 +645,8 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
for (i = 0; i < o->nb_stream_maps; i++) {
m = &o->stream_maps[i];
if (file_idx == m->file_index &&
m->stream_index >= 0 &&
m->stream_index < input_files[m->file_index]->nb_streams &&
stream_specifier_match(&ss,
input_files[m->file_index]->ctx,
input_files[m->file_index]->ctx->streams[m->stream_index],
+21
View File
@@ -43,6 +43,7 @@
#include "libavutil/bprint.h"
#include "libavutil/mem.h"
#include "libavutil/internal.h"
#endif
@@ -115,14 +116,22 @@ static void hwctx_lock_queue(void *priv, uint32_t qf, uint32_t qidx)
{
AVHWDeviceContext *avhwctx = priv;
const AVVulkanDeviceContext *hwctx = avhwctx->hwctx;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->lock_queue(avhwctx, qf, qidx);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
static void hwctx_unlock_queue(void *priv, uint32_t qf, uint32_t qidx)
{
AVHWDeviceContext *avhwctx = priv;
const AVVulkanDeviceContext *hwctx = avhwctx->hwctx;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->unlock_queue(avhwctx, qf, qidx);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
static int add_instance_extension(const char **ext, unsigned num_ext,
@@ -283,7 +292,11 @@ static void placebo_lock_queue(struct AVHWDeviceContext *dev_ctx,
{
RendererContext *ctx = dev_ctx->user_opaque;
pl_vulkan vk = ctx->placebo_vulkan;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
vk->lock_queue(vk, queue_family, index);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
static void placebo_unlock_queue(struct AVHWDeviceContext *dev_ctx,
@@ -292,7 +305,11 @@ static void placebo_unlock_queue(struct AVHWDeviceContext *dev_ctx,
{
RendererContext *ctx = dev_ctx->user_opaque;
pl_vulkan vk = ctx->placebo_vulkan;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
vk->unlock_queue(vk, queue_family, index);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
static int get_decode_queue(VkRenderer *renderer, int *index, int *count)
@@ -386,8 +403,12 @@ static int create_vk_by_placebo(VkRenderer *renderer,
device_ctx->user_opaque = ctx;
vk_dev_ctx = device_ctx->hwctx;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
vk_dev_ctx->lock_queue = placebo_lock_queue;
vk_dev_ctx->unlock_queue = placebo_unlock_queue;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
vk_dev_ctx->get_proc_addr = ctx->placebo_instance->get_proc_addr;
+1 -1
View File
@@ -3238,7 +3238,7 @@ int main(int argc, char **argv)
char *buf;
char *f_name = NULL, *f_args = NULL;
int ret, input_ret;
AVTextFormatDataDump data_dump_format_id;
AVTextFormatDataDump data_dump_format_id = AV_TEXTFORMAT_DATADUMP_XXD;
init_dynload();
+1 -1
View File
@@ -1277,7 +1277,7 @@ OBJS-$(CONFIG_IPU_PARSER) += ipu_parser.o
OBJS-$(CONFIG_JPEG2000_PARSER) += jpeg2000_parser.o
OBJS-$(CONFIG_JPEGXL_PARSER) += jpegxl_parser.o jpegxl_parse.o
OBJS-$(CONFIG_JPEGXS_PARSER) += jpegxs_parser.o
OBJS-$(CONFIG_LCEVC_PARSER) += lcevc_parser.o
OBJS-$(CONFIG_LCEVC_PARSER) += lcevc_parser.o lcevctab.o
OBJS-$(CONFIG_MISC4_PARSER) += misc4_parser.o
OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o
OBJS-$(CONFIG_MLP_PARSER) += mlp_parse.o mlp_parser.o mlp.o
+19 -6
View File
@@ -215,6 +215,8 @@ static int decode_usac_element_pair(AACDecContext *ac,
if (e->stereo_config_index) {
e->mps.freq_res = get_bits(gb, 3); /* bsFreqRes */
int numBands = ((int[]){0,28,20,14,10,7,5,4})[e->mps.freq_res]; // ISO/IEC 23003-1:2007, 5.2, Table 39
e->mps.fixed_gain = get_bits(gb, 3); /* bsFixedGainDMX */
e->mps.temp_shape_config = get_bits(gb, 2); /* bsTempShapeConfig */
e->mps.decorr_config = get_bits(gb, 2); /* bsDecorrConfig */
@@ -222,12 +224,21 @@ static int decode_usac_element_pair(AACDecContext *ac,
e->mps.phase_coding = get_bits1(gb); /* bsPhaseCoding */
e->mps.otts_bands_phase_present = get_bits1(gb);
if (e->mps.otts_bands_phase_present) /* bsOttBandsPhasePresent */
e->mps.otts_bands_phase = get_bits(gb, 5); /* bsOttBandsPhase */
int otts_bands_phase = ((int[]){0,10,10,7,5,3,2,2})[e->mps.freq_res]; // Table 109 — Default value of bsOttBandsPhase
if (e->mps.otts_bands_phase_present) { /* bsOttBandsPhasePresent */
otts_bands_phase = get_bits(gb, 5); /* bsOttBandsPhase */
if (otts_bands_phase > numBands)
return AVERROR_INVALIDDATA;
}
e->mps.otts_bands_phase = otts_bands_phase;
e->mps.residual_coding = e->stereo_config_index >= 2; /* bsResidualCoding */
if (e->mps.residual_coding) {
e->mps.residual_bands = get_bits(gb, 5); /* bsResidualBands */
int residual_bands = get_bits(gb, 5); /* bsResidualBands */
if (residual_bands > numBands)
return AVERROR_INVALIDDATA;
e->mps.residual_bands = residual_bands;
e->mps.otts_bands_phase = FFMAX(e->mps.otts_bands_phase,
e->mps.residual_bands);
e->mps.pseudo_lr = get_bits1(gb); /* bsPseudoLr */
@@ -1293,7 +1304,8 @@ static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac,
SingleChannelElement *sce = &cpe->ch[ch];
AACUsacElemData *ue = &sce->ue;
spectrum_scale(ac, sce, ue);
if (!ue->core_mode)
spectrum_scale(ac, sce, ue);
}
if (nb_channels > 1 && us->common_window) {
@@ -1343,8 +1355,9 @@ static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac,
if (sce->tns.present && ((nb_channels == 1) || (us->tns_on_lr)))
ac->dsp.apply_tns(sce->coeffs, &sce->tns, &sce->ics, 1);
ac->oc[1].m4ac.frame_length_short ? ac->dsp.imdct_and_windowing_768(ac, sce) :
ac->dsp.imdct_and_windowing(ac, sce);
if (!sce->ue.core_mode)
ac->oc[1].m4ac.frame_length_short ? ac->dsp.imdct_and_windowing_768(ac, sce) :
ac->dsp.imdct_and_windowing(ac, sce);
}
}
+13 -15
View File
@@ -464,10 +464,10 @@ static int ec_pair_dec(GetBitContext *gb,
}
if (pair) {
p_data[0] = data_pair[0];
p_data[1] = data_pair[1];
p_data[0] = data_diff[0];
p_data[1] = data_diff[1];
} else {
p_data[0] = data_pair[0];
p_data[0] = data_diff[0];
p_data[1] = NULL;
}
@@ -480,7 +480,7 @@ static int ec_pair_dec(GetBitContext *gb,
if (pair && (diff_freq[0] || diff_time_back))
diff_freq[1] = !get_bits1(gb);
int time_pair;
int time_pair = 0;
huff_decode(gb, p_data, data_type, diff_freq,
nb_bands, &time_pair);
@@ -534,11 +534,11 @@ static int ec_pair_dec(GetBitContext *gb,
}
/* Decode LSBs */
attach_lsb(gb, p_data[0], quant_offset, attach_lsb_flag,
nb_bands, p_data[0]);
attach_lsb(gb, data_pair[0], quant_offset, attach_lsb_flag,
nb_bands, data_pair[0]);
if (pair)
attach_lsb(gb, p_data[1], quant_offset, attach_lsb_flag,
nb_bands, p_data[1]);
attach_lsb(gb, data_pair[1], quant_offset, attach_lsb_flag,
nb_bands, data_pair[1]);
memcpy(&set1[start_band], data_pair[0], 2*nb_bands);
if (pair)
@@ -591,9 +591,6 @@ static int get_freq_strides(int16_t *freq_strides, int band_stride,
}
}
for (int i = 0; i <= data_bands; i++)
freq_strides[i] = av_clip_uintp2(freq_strides[i], 2);
return data_bands;
}
@@ -643,7 +640,8 @@ int ff_aac_ec_data_dec(GetBitContext *gb, AACMPSLosslessData *ld,
fine_to_coarse(ld->last_data, data_type, start_band, end_band);
}
int data_bands = get_freq_strides(ld->freq_res,
int16_t freq_stride_map[MPS_MAX_PARAM_BANDS + 1];
int data_bands = get_freq_strides(freq_stride_map,
stride_table[ld->freq_res[set_idx]],
start_band, end_band);
@@ -651,7 +649,7 @@ int ff_aac_ec_data_dec(GetBitContext *gb, AACMPSLosslessData *ld,
return AVERROR(EINVAL);
for (int j = 0; j < data_bands; j++)
ld->last_data[start_band + j] = ld->last_data[ld->freq_res[j]];
ld->last_data[start_band + j] = ld->last_data[freq_stride_map[j]];
int err = ec_pair_dec(gb,
ld->data[set_idx + 0], ld->data[set_idx + 1],
@@ -664,11 +662,11 @@ int ff_aac_ec_data_dec(GetBitContext *gb, AACMPSLosslessData *ld,
if (data_type == MPS_IPD) {
const int mask = ld->coarse_quant[set_idx] ? 0x7 : 0xF;
for (int j = 0; j < data_bands; j++)
for (int k = ld->freq_res[j + 0]; k < ld->freq_res[j + 1]; k++)
for (int k = freq_stride_map[j + 0]; k < freq_stride_map[j + 1]; k++)
ld->last_data[k] = ld->data[set_idx + data_pair][start_band + j] & mask;
} else {
for (int j = 0; j < data_bands; j++)
for (int k = ld->freq_res[j + 0]; k < ld->freq_res[j + 1]; k++)
for (int k = freq_stride_map[j + 0]; k < freq_stride_map[j + 1]; k++)
ld->last_data[k] = ld->data[set_idx + data_pair][start_band + j];
}
+6 -1
View File
@@ -511,8 +511,11 @@ function hevc_loop_filter_luma_body_\bitdepth\()_neon, export=0
sqxtun v6.8b, v6.8h
sqxtun v7.8b, v7.8h
.endif
// Use x15 to signal whether any pixels should be updated or not.
mov x15, #1
ret
3: mov x15, #0
ret
3: ret x6
endfunc
.endm
@@ -562,6 +565,7 @@ function ff_hevc_\dir\()_loop_filter_luma_\bitdepth\()_neon, export=1
.endif
.endif
bl hevc_loop_filter_luma_body_\bitdepth\()_neon
cbz x15, 9f
.if \bitdepth > 8
.ifc \dir, v
transpose_8x8H v0, v1, v2, v3, v4, v5, v6, v7, v16, v17
@@ -587,6 +591,7 @@ function ff_hevc_\dir\()_loop_filter_luma_\bitdepth\()_neon, export=1
st1 {v6.8b}, [x10], x1
st1 {v7.8b}, [x10]
.endif
9:
ret x6
endfunc
.endm
+1 -1
View File
@@ -2704,7 +2704,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
for (int k = i-1; k > -1; k--) {
for (int o = 1; o < order; o++)
delta += sf_codes[(i-1) - k] * coefs[(o*8) + k];
delta += sf_codes[(i-1) - k] * (unsigned)coefs[(o*8) + k];
}
sample = sf_codes[i] * 2048;
+13 -4
View File
@@ -1548,8 +1548,12 @@ static int read_diff_float_data(ALSDecContext *ctx, unsigned int ra_frame) {
return AVERROR_INVALIDDATA;
}
j = 0;
for (i = 0; i < frame_length; ++i) {
ctx->raw_mantissa[c][i] = AV_RB32(larray);
if (ctx->raw_samples[c][i] == 0) {
ctx->raw_mantissa[c][i] = AV_RB32(larray + j);
j += 4;
}
}
}
}
@@ -1560,7 +1564,10 @@ static int read_diff_float_data(ALSDecContext *ctx, unsigned int ra_frame) {
if (ctx->raw_samples[c][i] != 0) {
//The following logic is taken from Table 14.45 and 14.46 from the ISO spec
if (av_cmp_sf_ieee754(acf[c], FLOAT_1)) {
nbits[i] = 23 - av_log2(abs(ctx->raw_samples[c][i]));
int nbit = av_log2(FFABSU(ctx->raw_samples[c][i]));
if (nbit > 23)
return AVERROR_INVALIDDATA;
nbits[i] = 23 - nbit;
} else {
nbits[i] = 23;
}
@@ -1634,7 +1641,7 @@ static int read_diff_float_data(ALSDecContext *ctx, unsigned int ra_frame) {
tmp_32 = (sign << 31) | ((e + EXP_BIAS) << 23) | (mantissa);
ctx->raw_samples[c][i] = tmp_32;
} else {
ctx->raw_samples[c][i] = raw_mantissa[c][i] & 0x007fffffUL;
ctx->raw_samples[c][i] = raw_mantissa[c][i];
}
}
align_get_bits(gb);
@@ -1790,7 +1797,9 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
}
if (sconf->floating) {
read_diff_float_data(ctx, ra_frame);
ret = read_diff_float_data(ctx, ra_frame);
if (ret < 0)
return ret;
}
if (get_bits_left(gb) < 0) {
+3 -2
View File
@@ -152,8 +152,9 @@ int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s,
payload_4byte = get_bits1(gb);
payload_size = get_bits(gb, payload_4byte ? 2 : 8);
set_idx = get_bits(gb, 3);
fgp = av_film_grain_params_alloc(&fgp_size);
if (!fgp)
if (!fgp || s->sets[set_idx])
goto error;
aom = &fgp->codec.aom;
@@ -212,7 +213,7 @@ int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s,
}
predict_scaling = get_bits1(gb);
if (predict_scaling && (!ref || ref == fgp))
if (predict_scaling && !ref)
goto error; // prediction must be from valid, different set
predict_y_scaling = predict_scaling ? get_bits1(gb) : 0;
+4 -3
View File
@@ -99,12 +99,11 @@ static int32_t decode_signed_subexp_with_ref(uint32_t sub_exp, int low,
static void read_global_param(AV1DecContext *s, int type, int ref, int idx)
{
uint8_t primary_frame, prev_frame;
int primary_frame;
uint32_t abs_bits, prec_bits, round, prec_diff, sub, mx;
int32_t r, prev_gm_param;
primary_frame = s->raw_frame_header->primary_ref_frame;
prev_frame = s->raw_frame_header->ref_frame_idx[primary_frame];
abs_bits = AV1_GM_ABS_ALPHA_BITS;
prec_bits = AV1_GM_ALPHA_PREC_BITS;
@@ -114,8 +113,10 @@ static void read_global_param(AV1DecContext *s, int type, int ref, int idx)
*/
if (s->raw_frame_header->primary_ref_frame == AV1_PRIMARY_REF_NONE)
prev_gm_param = s->cur_frame.gm_params[ref][idx];
else
else {
int prev_frame = s->raw_frame_header->ref_frame_idx[primary_frame];
prev_gm_param = s->ref[prev_frame].gm_params[ref][idx];
}
if (idx < 2) {
if (type == AV1_WARP_MODEL_TRANSLATION) {
+16 -29
View File
@@ -30,6 +30,7 @@
#include "h2645_parse.h"
#include "h264.h"
#include "lcevc.h"
#include "lcevc_parse.h"
#include "startcode.h"
#include "vc1_common.h"
#include "vvc.h"
@@ -268,22 +269,6 @@ static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
return 0;
}
static inline uint64_t get_mb(GetBitContext *s) {
int more, i = 0;
uint64_t mb = 0;
do {
int byte = get_bits(s, 8);
unsigned bits = byte & 0x7f;
more = byte & 0x80;
mb = (mb << 7) | bits;
if (++i == 10)
break;
} while (more);
return mb;
}
/**
* Rewrite the NALu stripping the unneeded blocks.
* Given that length fields coded inside the NALu are not aware of any emulation_3bytes
@@ -304,7 +289,8 @@ static int write_lcevc_nalu(AVBSFContext *ctx, PutByteContext *pbc, const H2645N
while (bytestream2_get_bytes_left(&gbc) > 1) {
GetBitContext gb;
int payload_size_type, payload_type, payload_size;
int payload_size_type, payload_type;
uint64_t payload_size;
int block_size, raw_block_size, block_end;
init_get_bits8(&gb, gbc.buffer, bytestream2_get_bytes_left(&gbc));
@@ -317,6 +303,9 @@ static int write_lcevc_nalu(AVBSFContext *ctx, PutByteContext *pbc, const H2645N
if (payload_size_type == 7)
payload_size = get_mb(&gb);
if (payload_size > INT_MAX - (get_bits_count(&gb) >> 3))
return AVERROR_INVALIDDATA;
block_size = raw_block_size = payload_size + (get_bits_count(&gb) >> 3);
if (block_size >= bytestream2_get_bytes_left(&gbc))
return AVERROR_INVALIDDATA;
@@ -380,8 +369,9 @@ static int extract_extradata_lcevc(AVBSFContext *ctx, AVPacket *pkt,
for (i = 0; i < s->h2645_pkt.nb_nals; i++) {
H2645NAL *nal = &s->h2645_pkt.nals[i];
if (val_in_array(extradata_nal_types, nb_extradata_nal_types, nal->type)) {
bytestream2_init_writer(&pb_extradata, NULL, 0);
// dummy pass to find sc, gc or ai
// dummy pass to find sc, gc or ai. A dummy pointer is used to prevent
// UB in PutByteContext. Nothing will be written.
bytestream2_init_writer(&pb_extradata, nal->data, 0);
if (!write_lcevc_nalu(ctx, &pb_extradata, nal, 0))
extradata_size += nal->raw_size + 3;
}
@@ -407,14 +397,10 @@ static int extract_extradata_lcevc(AVBSFContext *ctx, AVPacket *pkt,
return AVERROR(ENOMEM);
}
*data = extradata;
*size = 0;
bytestream2_init_writer(&pb_extradata, extradata, extradata_size);
if (s->remove)
bytestream2_init_writer(&pb_filtered_data, filtered_buf->data, filtered_size);
filtered_size = 0;
for (i = 0; i < s->h2645_pkt.nb_nals; i++) {
H2645NAL *nal = &s->h2645_pkt.nals[i];
if (val_in_array(extradata_nal_types, nb_extradata_nal_types,
@@ -422,33 +408,34 @@ static int extract_extradata_lcevc(AVBSFContext *ctx, AVPacket *pkt,
bytestream2_put_be24(&pb_extradata, 1); //startcode
ret = write_lcevc_nalu(ctx, &pb_extradata, nal, 0);
if (ret < 0) {
av_freep(data);
av_freep(&extradata);
av_buffer_unref(&filtered_buf);
return ret;
}
*size += ret;
if (s->remove) {
bytestream2_put_be24(&pb_filtered_data, 1); //startcode
ret = write_lcevc_nalu(ctx, &pb_filtered_data, nal, 1);
if (ret < 0) {
av_freep(data);
av_freep(&extradata);
av_buffer_unref(&filtered_buf);
return ret;
}
filtered_size += ret;
}
} else if (s->remove) {
bytestream2_put_be24(&pb_filtered_data, 1); //startcode
bytestream2_put_bufferu(&pb_filtered_data, nal->raw_data, nal->raw_size);
filtered_size += nal->raw_size;
}
}
*data = extradata;
*size = bytestream2_tell_p(&pb_extradata);
av_assert0(*size <= extradata_size);
if (s->remove) {
av_assert0(bytestream2_tell_p(&pb_filtered_data) <= filtered_size);
av_buffer_unref(&pkt->buf);
pkt->buf = filtered_buf;
pkt->data = filtered_buf->data;
pkt->size = filtered_size;
pkt->size = bytestream2_tell_p(&pb_filtered_data);
}
}
+4 -2
View File
@@ -1216,7 +1216,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
int num_subpic_cols = tmp_width_val /
(current->sps_subpic_width_minus1[0] + 1);
if (tmp_width_val % (current->sps_subpic_width_minus1[0] + 1) ||
tmp_height_val % (current->sps_subpic_width_minus1[0] + 1) ||
tmp_height_val % (current->sps_subpic_height_minus1[0] + 1) ||
current->sps_num_subpics_minus1 !=
(num_subpic_cols * tmp_height_val /
(current->sps_subpic_height_minus1[0] + 1) - 1))
@@ -1971,6 +1971,8 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw,
current->slice_top_left_tile_idx[i] = tile_idx;
tile_x = tile_idx % current->num_tile_columns;
tile_y = tile_idx / current->num_tile_columns;
if (tile_y >= current->num_tile_rows)
return AVERROR_INVALIDDATA;
if (tile_x != current->num_tile_columns - 1) {
ues(pps_slice_width_in_tiles_minus1[i],
0, current->num_tile_columns - 1 - tile_x, 1, i);
@@ -3506,7 +3508,7 @@ static int FUNC(slice_header) (CodedBitstreamContext *ctx, RWContext *rw,
tile_idx <=
current->sh_slice_address +
current->sh_num_tiles_in_slice_minus1; tile_idx++) {
tile_y = tile_idx / pps->num_tile_rows;
tile_y = tile_idx / pps->num_tile_columns;
height = pps->row_height_val[tile_y];
current->num_entry_points += (entropy_sync ? height : 1);
}
+3
View File
@@ -674,6 +674,9 @@ int ff_cbs_lcevc_find_process_block(CodedBitstreamContext *ctx,
CodedBitstreamUnit *unit = &au->units[i];
LCEVCRawProcessBlockList *list;
if (!unit->content)
continue;
err = cbs_lcevc_get_process_block_list(ctx, unit, &list);
if (err < 0)
continue;
+2
View File
@@ -635,6 +635,8 @@ static int FUNC(process_block_list)(CodedBitstreamContext *ctx, RWContext *rw,
*rw = start_state;
tmp = FFMIN(block->payload_size, 7);
if (tmp == 6)
tmp = 7;
xu(3, payload_size_type, tmp, 0, 7, 0);
xu(5, payload_type, block->payload_type, 0, MAX_UINT_BITS(5), 0);
+33 -11
View File
@@ -98,6 +98,8 @@ typedef struct DecodeContext {
struct {
FFLCEVCContext *ctx;
int frame;
int base_width;
int base_height;
int width;
int height;
} lcevc;
@@ -1661,7 +1663,7 @@ int ff_attach_decode_data(AVFrame *frame)
return 0;
}
static void update_frame_props(AVCodecContext *avctx, AVFrame *frame)
static int update_frame_props(AVCodecContext *avctx, AVFrame *frame)
{
#if CONFIG_LIBLCEVC_DEC
AVCodecInternal *avci = avctx->internal;
@@ -1671,12 +1673,23 @@ static void update_frame_props(AVCodecContext *avctx, AVFrame *frame)
av_frame_get_side_data(frame, AV_FRAME_DATA_LCEVC);
if (dc->lcevc.frame) {
dc->lcevc.width = frame->width;
dc->lcevc.height = frame->height;
frame->width = frame->width * 2 / FFMAX(frame->sample_aspect_ratio.den, 1);
frame->height = frame->height * 2 / FFMAX(frame->sample_aspect_ratio.num, 1);
int ret = ff_lcevc_parse_frame(dc->lcevc.ctx, frame,
&dc->lcevc.width, &dc->lcevc.height, avctx);
if (ret < 0)
return ret;
// force get_buffer2() to allocate the base frame using the same dimensions
// as the final enhanced frame, in order to prevent reinitializing the buffer
// pools unnecessarely
if (dc->lcevc.width && dc->lcevc.height) {
dc->lcevc.base_width = frame->width;
dc->lcevc.base_height = frame->height;
frame->width = dc->lcevc.width;
frame->height = dc->lcevc.height;
}
}
#endif
return 0;
}
static int attach_post_process_data(AVCodecContext *avctx, AVFrame *frame)
@@ -1690,6 +1703,11 @@ static int attach_post_process_data(AVCodecContext *avctx, AVFrame *frame)
FFLCEVCFrame *frame_ctx;
int ret;
if (!dc->lcevc.width || !dc->lcevc.height) {
dc->lcevc.frame = 0;
return 0;
}
frame_ctx = av_mallocz(sizeof(*frame_ctx));
if (!frame_ctx)
return AVERROR(ENOMEM);
@@ -1701,12 +1719,12 @@ static int attach_post_process_data(AVCodecContext *avctx, AVFrame *frame)
}
frame_ctx->lcevc = av_refstruct_ref(dc->lcevc.ctx);
frame_ctx->frame->width = frame->width;
frame_ctx->frame->height = frame->height;
frame_ctx->frame->width = dc->lcevc.width;
frame_ctx->frame->height = dc->lcevc.height;
frame_ctx->frame->format = frame->format;
frame->width = dc->lcevc.width;
frame->height = dc->lcevc.height;
frame->width = dc->lcevc.base_width;
frame->height = dc->lcevc.base_height;
ret = avctx->get_buffer2(avctx, frame_ctx->frame, 0);
if (ret < 0) {
@@ -1771,7 +1789,9 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
}
} else {
avctx->sw_pix_fmt = avctx->pix_fmt;
update_frame_props(avctx, frame);
ret = update_frame_props(avctx, frame);
if (ret < 0)
goto fail;
}
ret = avctx->get_buffer2(avctx, frame, flags);
@@ -2091,7 +2111,7 @@ av_cold int ff_decode_preinit(AVCodecContext *avctx)
if (!(avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) {
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
#if CONFIG_LIBLCEVC_DEC
ret = ff_lcevc_alloc(&dc->lcevc.ctx);
ret = ff_lcevc_alloc(&dc->lcevc.ctx, avctx);
if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
#endif
@@ -2338,6 +2358,8 @@ av_cold void ff_decode_internal_sync(AVCodecContext *dst, const AVCodecContext *
dst_dc->side_data_pref_mask = src_dc->side_data_pref_mask;
#if CONFIG_LIBLCEVC_DEC
av_refstruct_replace(&dst_dc->lcevc.ctx, src_dc->lcevc.ctx);
dst_dc->lcevc.width = src_dc->lcevc.width;
dst_dc->lcevc.height = src_dc->lcevc.height;
#endif
}
+7 -3
View File
@@ -93,9 +93,13 @@ int ff_attach_decode_data(AVFrame *frame);
*/
int ff_copy_palette(void *dst, const AVPacket *src, void *logctx);
/**
* Check that the provided frame dimensions are valid and set them on the codec
* context.
/*
* Validate and set video frame dimensions on AVCodecContext.
*
* Dimensions accepted here satisfy FFmpeg's generic image-size validation
* (see av_image_check_size2()). Decoder code normally should not duplicate
* generic width/height overflow checks before ff_get_buffer(); add local
* checks only for codec-specific derived sizes or complexity bounds.
*/
int ff_set_dimensions(AVCodecContext *s, int width, int height);
+3 -2
View File
@@ -101,15 +101,16 @@ static int dfpwm_dec_frame(struct AVCodecContext *ctx, AVFrame *frame,
{
DFPWMState *state = ctx->priv_data;
int ret;
uint64_t nb_samples = packet->size * 8LL / ctx->ch_layout.nb_channels;
if (packet->size * 8LL % ctx->ch_layout.nb_channels)
return AVERROR_PATCHWELCOME;
frame->nb_samples = packet->size * 8LL / ctx->ch_layout.nb_channels;
if (frame->nb_samples <= 0) {
if (nb_samples > INT_MAX || !nb_samples) {
av_log(ctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
return AVERROR_INVALIDDATA;
}
frame->nb_samples = nb_samples;
if ((ret = ff_get_buffer(ctx, frame, 0)) < 0)
return ret;
+1 -1
View File
@@ -60,7 +60,7 @@ static int dvdsub_parse(AVCodecParserContext *s,
pc->packet = av_malloc(pc->packet_len + AV_INPUT_BUFFER_PADDING_SIZE);
}
if (pc->packet) {
if (pc->packet_index + buf_size <= pc->packet_len) {
if (buf_size <= pc->packet_len - pc->packet_index) {
memcpy(pc->packet + pc->packet_index, buf, buf_size);
pc->packet_index += buf_size;
if (pc->packet_index >= pc->packet_len) {
+1 -1
View File
@@ -125,7 +125,7 @@ static av_cold int escape130_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
s->old_y_avg = av_malloc(avctx->width * avctx->height / 4);
s->old_y_avg = av_mallocz(avctx->width * avctx->height / 4);
s->buf1 = av_malloc(avctx->width * avctx->height * 3 / 2);
s->buf2 = av_malloc(avctx->width * avctx->height * 3 / 2);
if (!s->old_y_avg || !s->buf1 || !s->buf2) {
+3
View File
@@ -637,6 +637,9 @@ static int piz_uncompress(const EXRContext *s, const uint8_t *src, int ssize,
max_non_zero - min_non_zero + 1);
memset(td->bitmap + max_non_zero + 1, 0, BITMAP_SIZE - max_non_zero - 1);
if (bytestream2_get_bytes_left(&gb) < 4)
return AVERROR_INVALIDDATA;
maxval = reverse_lut(td->bitmap, td->lut);
bytestream2_skip(&gb, 4);
+1 -1
View File
@@ -241,7 +241,7 @@ static int vulkan_encode_ffv1_submit_frame(AVCodecContext *avctx,
if (maxsize < fv->max_heap_size) {
out_buf_flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
/* If we can't map host memory, we can't let the GPU copy its buffer. */
if (!fv->s.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY)
if (!(fv->s.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY))
out_buf_flags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
} else {
out_buf_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
+104 -68
View File
@@ -145,7 +145,7 @@ static int decode_registered_user_data_closed_caption(H2645SEIA53Caption *h,
static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb,
enum AVCodecID codec_id, void *logctx)
{
int country_code, provider_code;
int country_code, provider_code = -1;
if (bytestream2_get_bytes_left(gb) < 3)
return AVERROR_INVALIDDATA;
@@ -159,92 +159,128 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb,
}
/* itu_t_t35_payload_byte follows */
provider_code = bytestream2_get_be16u(gb);
if (country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == ITU_T_T35_PROVIDER_CODE_ATSC) {
uint32_t user_identifier;
switch (country_code) {
case ITU_T_T35_COUNTRY_CODE_US:
provider_code = bytestream2_get_be16u(gb);
if (bytestream2_get_bytes_left(gb) < 4)
return AVERROR_INVALIDDATA;
switch (provider_code) {
case ITU_T_T35_PROVIDER_CODE_ATSC: {
uint32_t user_identifier;
user_identifier = bytestream2_get_be32u(gb);
switch (user_identifier) {
case MKBETAG('D', 'T', 'G', '1'): // afd_data
return decode_registered_user_data_afd(&h->afd, gb);
case MKBETAG('G', 'A', '9', '4'): // closed captions
return decode_registered_user_data_closed_caption(&h->a53_caption, gb);
default:
av_log(logctx, AV_LOG_VERBOSE,
"Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
user_identifier);
if (bytestream2_get_bytes_left(gb) < 4)
return AVERROR_INVALIDDATA;
user_identifier = bytestream2_get_be32u(gb);
switch (user_identifier) {
case MKBETAG('D', 'T', 'G', '1'): // afd_data
return decode_registered_user_data_afd(&h->afd, gb);
case MKBETAG('G', 'A', '9', '4'): // closed captions
return decode_registered_user_data_closed_caption(&h->a53_caption, gb);
default:
av_log(logctx, AV_LOG_VERBOSE,
"Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
user_identifier);
break;
}
break;
}
} else if (country_code == ITU_T_T35_COUNTRY_CODE_UK && provider_code == ITU_T_T35_PROVIDER_CODE_VNOVA) {
#if CONFIG_HEVC_SEI
case ITU_T_T35_PROVIDER_CODE_AOM: {
const uint16_t aom_grain_provider_oriented_code = 0x0001;
uint16_t provider_oriented_code;
if (!IS_HEVC(codec_id))
break;
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
provider_oriented_code = bytestream2_get_byteu(gb);
if (provider_oriented_code == aom_grain_provider_oriented_code) {
return ff_aom_parse_film_grain_sets(&h->aom_film_grain,
gb->buffer,
bytestream2_get_bytes_left(gb));
}
break;
}
case ITU_T_T35_PROVIDER_CODE_SAMSUNG: {
// A/341 Amendment - 2094-40
const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
const uint8_t smpte2094_40_application_identifier = 0x04;
uint16_t provider_oriented_code;
uint8_t application_identifier;
if (!IS_HEVC(codec_id))
break;
if (bytestream2_get_bytes_left(gb) < 3)
return AVERROR_INVALIDDATA;
provider_oriented_code = bytestream2_get_be16u(gb);
application_identifier = bytestream2_get_byteu(gb);
if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
application_identifier == smpte2094_40_application_identifier) {
return decode_registered_user_data_dynamic_hdr_plus(&h->dynamic_hdr_plus, gb);
}
break;
}
#endif
default:
break;
}
break;
case ITU_T_T35_COUNTRY_CODE_UK:
bytestream2_skipu(gb, 1); // t35_uk_country_code_second_octet
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
bytestream2_skipu(gb, 1); // user_data_type_code
return decode_registered_user_data_lcevc(&h->lcevc, gb);
}
provider_code = bytestream2_get_be16u(gb);
switch (provider_code) {
case ITU_T_T35_PROVIDER_CODE_VNOVA:
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
return decode_registered_user_data_lcevc(&h->lcevc, gb);
default:
break;
}
break;
#if CONFIG_HEVC_SEI
else if (country_code == ITU_T_T35_COUNTRY_CODE_CN && provider_code == ITU_T_T35_PROVIDER_CODE_HDR_VIVID) {
case ITU_T_T35_COUNTRY_CODE_CN: {
const uint16_t cuva_provider_oriented_code = 0x0005;
uint16_t provider_oriented_code;
if (!IS_HEVC(codec_id))
goto unsupported_provider_code;
provider_code = bytestream2_get_be16u(gb);
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
switch (provider_code) {
case ITU_T_T35_PROVIDER_CODE_HDR_VIVID:
if (!IS_HEVC(codec_id))
break;
provider_oriented_code = bytestream2_get_be16u(gb);
if (provider_oriented_code == cuva_provider_oriented_code) {
return decode_registered_user_data_dynamic_hdr_vivid(&h->dynamic_hdr_vivid, gb);
}
} else if(country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == ITU_T_T35_PROVIDER_CODE_SAMSUNG) {
// A/341 Amendment - 2094-40
const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
const uint8_t smpte2094_40_application_identifier = 0x04;
uint16_t provider_oriented_code;
uint8_t application_identifier;
if (!IS_HEVC(codec_id))
goto unsupported_provider_code;
if (bytestream2_get_bytes_left(gb) < 3)
return AVERROR_INVALIDDATA;
provider_oriented_code = bytestream2_get_be16u(gb);
application_identifier = bytestream2_get_byteu(gb);
if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
application_identifier == smpte2094_40_application_identifier) {
return decode_registered_user_data_dynamic_hdr_plus(&h->dynamic_hdr_plus, gb);
}
} else if (country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == ITU_T_T35_PROVIDER_CODE_AOM) {
const uint16_t aom_grain_provider_oriented_code = 0x0001;
uint16_t provider_oriented_code;
if (!IS_HEVC(codec_id))
goto unsupported_provider_code;
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
provider_oriented_code = bytestream2_get_byteu(gb);
if (provider_oriented_code == aom_grain_provider_oriented_code) {
return ff_aom_parse_film_grain_sets(&h->aom_film_grain,
gb->buffer,
bytestream2_get_bytes_left(gb));
if (bytestream2_get_bytes_left(gb) < 2)
return AVERROR_INVALIDDATA;
provider_oriented_code = bytestream2_get_be16u(gb);
if (provider_oriented_code == cuva_provider_oriented_code) {
return decode_registered_user_data_dynamic_hdr_vivid(&h->dynamic_hdr_vivid, gb);
}
break;
default:
break;
}
break;
}
#endif
else {
unsupported_provider_code:
av_log(logctx, AV_LOG_VERBOSE,
"Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d, provider_code = %d)\n",
country_code, provider_code);
default:
break;
}
av_log(logctx, AV_LOG_VERBOSE,
"Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d, provider_code = %d)\n",
country_code, provider_code);
return 0;
}
+19 -15
View File
@@ -121,26 +121,30 @@ void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *
{
H264Ref *const ref1 = &sl->ref_list[1][0];
H264Picture *const cur = h->cur_pic_ptr;
int list, j, field;
int list, field;
int sidx = (h->picture_structure & 1) ^ 1;
int ref1sidx = (ref1->reference & 1) ^ 1;
for (list = 0; list < sl->list_count; list++) {
cur->ref_count[sidx][list] = sl->ref_count[list];
for (j = 0; j < sl->ref_count[list]; j++)
cur->ref_poc[sidx][list][j] = 4 * sl->ref_list[list][j].parent->frame_num +
(sl->ref_list[list][j].reference & 3);
}
/* Updates to cur_pic are not safe once ff_thread_finish_setup() has been
* called (other threads may already be reading these fields). */
if (!h->setup_finished) {
for (list = 0; list < sl->list_count; list++) {
cur->ref_count[sidx][list] = sl->ref_count[list];
for (int j = 0; j < sl->ref_count[list]; j++)
cur->ref_poc[sidx][list][j] = 4 * sl->ref_list[list][j].parent->frame_num +
(sl->ref_list[list][j].reference & 3);
}
if (h->picture_structure == PICT_FRAME) {
memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0]));
memcpy(cur->ref_poc[1], cur->ref_poc[0], sizeof(cur->ref_poc[0]));
}
if (h->picture_structure == PICT_FRAME) {
memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0]));
memcpy(cur->ref_poc[1], cur->ref_poc[0], sizeof(cur->ref_poc[0]));
}
if (h->current_slice == 0) {
cur->mbaff = FRAME_MBAFF(h);
} else {
av_assert0(cur->mbaff == FRAME_MBAFF(h));
if (h->current_slice == 0) {
cur->mbaff = FRAME_MBAFF(h);
} else {
av_assert0(cur->mbaff == FRAME_MBAFF(h));
}
}
sl->col_fieldoff = 0;
+2 -4
View File
@@ -156,8 +156,7 @@ static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl)
h->long_ref, 16, 1, h->picture_structure);
av_assert0(len <= 32);
if (len < sl->ref_count[list])
memset(&sl->ref_list[list][len], 0, sizeof(H264Ref) * (sl->ref_count[list] - len));
memset(&sl->ref_list[list][len], 0, sizeof(H264Ref) * (32 - len));
lens[list] = len;
}
@@ -178,8 +177,7 @@ static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl)
h-> long_ref, 16, 1, h->picture_structure);
av_assert0(len <= 32);
if (len < sl->ref_count[0])
memset(&sl->ref_list[0][len], 0, sizeof(H264Ref) * (sl->ref_count[0] - len));
memset(&sl->ref_list[0][len], 0, sizeof(H264Ref) * (32 - len));
}
#ifdef TRACE
for (int i = 0; i < sl->ref_count[0]; i++) {
+7 -2
View File
@@ -1949,8 +1949,7 @@ static int h264_slice_init(H264Context *h, H264SliceContext *sl,
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !sl->direct_spatial_mv_pred)
ff_h264_direct_dist_scale_factor(h, sl);
if (!h->setup_finished)
ff_h264_direct_ref_list_init(h, sl);
ff_h264_direct_ref_list_init(h, sl);
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
@@ -1979,6 +1978,12 @@ static int h264_slice_init(H264Context *h, H264SliceContext *sl,
h->ps.pps->chroma_qp_index_offset[1]) +
6 * (h->ps.sps->bit_depth_luma - 8);
// slice_table is uint16_t initialized to 0xFFFF as a sentinel.
if (h->current_slice >= 0xFFFE) {
av_log(h->avctx, AV_LOG_ERROR, "Too many slices (%d)\n", h->current_slice + 1);
return AVERROR_PATCHWELCOME;
}
sl->slice_num = ++h->current_slice;
if (sl->slice_num)
+3
View File
@@ -1280,6 +1280,9 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
sps->bit_depth = rf->bit_depth_luma;
sps->width = rf->pic_width_in_luma_samples;
sps->height = rf->pic_height_in_luma_samples;
if ((ret = av_image_check_size(sps->width,
sps->height, 0, avctx)) < 0)
return ret;
sps->pic_conf_win.left_offset = rf->conf_win_left_offset;
sps->pic_conf_win.right_offset = rf->conf_win_right_offset;
+4 -1
View File
@@ -162,7 +162,10 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l)
if (ret < 0)
goto fail;
frame->rpl = av_refstruct_allocz(s->pkt.nb_nals * sizeof(*frame->rpl));
size_t rpl_bytes;
if (av_size_mult(s->pkt.nb_nals, sizeof(*frame->rpl), &rpl_bytes) < 0)
goto fail;
frame->rpl = av_refstruct_allocz(rpl_bytes);
if (!frame->rpl)
goto fail;
frame->nb_rpl_elems = s->pkt.nb_nals;
+1 -3
View File
@@ -30,10 +30,8 @@
// - CN providers
#define ITU_T_T35_PROVIDER_CODE_HDR_VIVID 0x0004
// - UK providers
// V-Nova should be 0x5000 according to UK Register of Manufacturer Codes
// https://www.cix.co.uk/~bpechey/H221/h221code.htm
// but FFmpeg has been using 0x0050
#define ITU_T_T35_PROVIDER_CODE_VNOVA 0x0050
#define ITU_T_T35_PROVIDER_CODE_VNOVA 0x5000
// - US providers
#define ITU_T_T35_PROVIDER_CODE_ATSC 0x0031
#define ITU_T_T35_PROVIDER_CODE_DOLBY 0x003B
+42
View File
@@ -0,0 +1,42 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_LCEVC_PARSE_H
#define AVCODEC_LCEVC_PARSE_H
#include <stdint.h>
#include "get_bits.h"
static inline uint64_t get_mb(GetBitContext *s) {
int more, i = 0;
uint64_t mb = 0;
do {
int byte = get_bits(s, 8);
unsigned bits = byte & 0x7f;
more = byte & 0x80;
mb = (mb << 7) | bits;
if (++i == 10)
break;
} while (more);
return mb;
}
#endif /* AVCODEC_LCEVC_PARSE_H */
+12 -39
View File
@@ -25,6 +25,8 @@
#include "get_bits.h"
#include "h2645_parse.h"
#include "lcevc.h"
#include "lcevc_parse.h"
#include "lcevctab.h"
#include "parser.h"
#include "parser_internal.h"
@@ -81,41 +83,6 @@ static const enum AVPixelFormat pix_fmts[4][4] = {
AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, },
};
static const struct {
int width;
int height;
} resolution_type_lut[63] = {
{ 0, 0},
{ 360, 200 }, { 400, 240 }, { 480, 320 }, { 640, 360 },
{ 640, 480 }, { 768, 480 }, { 800, 600 }, { 852, 480 },
{ 854, 480 }, { 856, 480 }, { 960, 540 }, { 960, 640 },
{ 1024, 576 }, { 1024, 600 }, { 1024, 768 }, { 1152, 864 },
{ 1280, 720 }, { 1280, 800 }, { 1280, 1024 }, { 1360, 768 },
{ 1366, 768 }, { 1920, 1200 }, { 2048, 1080 }, { 2048, 1152 },
{ 2048, 1536 }, { 2160, 1440 }, { 2560, 1440 }, { 2560, 1600 },
{ 2560, 2048 }, { 3200, 1800 }, { 3200, 2048 }, { 3200, 2400 },
{ 3440, 1440 }, { 3840, 1600 }, { 3840, 2160 }, { 3840, 2400 },
{ 4096, 2160 }, { 4096, 3072 }, { 5120, 2880 }, { 5120, 3200 },
{ 5120, 4096 }, { 6400, 4096 }, { 6400, 4800 }, { 7680, 4320 },
{ 7680, 4800 },
};
static inline uint64_t get_mb(GetBitContext *s) {
int more, i = 0;
uint64_t mb = 0;
do {
int byte = get_bits(s, 8);
unsigned bits = byte & 0x7f;
more = byte & 0x80;
mb = (mb << 7) | bits;
if (++i == 10)
break;
} while (more);
return mb;
}
static int parse_nal_unit(AVCodecParserContext *s, AVCodecContext *avctx,
const H2645NAL *nal)
{
@@ -125,10 +92,13 @@ static int parse_nal_unit(AVCodecParserContext *s, AVCodecContext *avctx,
while (bytestream2_get_bytes_left(&gbc) > 1) {
GetBitContext gb;
int payload_size_type, payload_type, payload_size;
uint64_t payload_size;
int payload_size_type, payload_type;
int block_size;
init_get_bits8(&gb, gbc.buffer, bytestream2_get_bytes_left(&gbc));
int ret = init_get_bits8(&gb, gbc.buffer, bytestream2_get_bytes_left(&gbc));
if (ret < 0)
return ret;
payload_size_type = get_bits(&gb, 3);
payload_type = get_bits(&gb, 5);
@@ -138,6 +108,9 @@ static int parse_nal_unit(AVCodecParserContext *s, AVCodecContext *avctx,
if (payload_size_type == 7)
payload_size = get_mb(&gb);
if (payload_size > INT_MAX - (get_bits_count(&gb) >> 3))
return AVERROR_INVALIDDATA;
block_size = payload_size + (get_bits_count(&gb) >> 3);
if (block_size >= bytestream2_get_bytes_left(&gbc))
return AVERROR_INVALIDDATA;
@@ -161,8 +134,8 @@ static int parse_nal_unit(AVCodecParserContext *s, AVCodecContext *avctx,
s->format = pix_fmts[bit_depth][chroma_format_idc];
if (resolution_type < 63) {
s->width = resolution_type_lut[resolution_type].width;
s->height = resolution_type_lut[resolution_type].height;
s->width = ff_lcevc_resolution_type[resolution_type].width;
s->height = ff_lcevc_resolution_type[resolution_type].height;
} else {
int upsample_type, tile_dimensions_type;
int temporal_step_width_modifier_signalled_flag, level1_filtering_signalled_flag;
+78 -1
View File
@@ -23,8 +23,12 @@
#include "libavutil/mem.h"
#include "libavutil/refstruct.h"
#include "cbs.h"
#include "cbs_lcevc.h"
#include "decode.h"
#include "lcevc_parse.h"
#include "lcevcdec.h"
#include "lcevctab.h"
static LCEVC_ColorFormat map_format(int format)
{
@@ -191,6 +195,15 @@ static int generate_output(void *logctx, FFLCEVCFrame *frame_ctx, AVFrame *out)
out->width = desc.width + out->crop_left + out->crop_right;
out->height = desc.height + out->crop_top + out->crop_bottom;
av_log(logctx, AV_LOG_DEBUG, "out PTS %"PRId64", %dx%d, "
"%zu/%zu/%zu/%zu, "
"SAR %d:%d, "
"hasEnhancement %d, enhanced %d\n",
out->pts, out->width, out->height,
out->crop_top, out->crop_bottom, out->crop_left, out->crop_right,
out->sample_aspect_ratio.num, out->sample_aspect_ratio.den,
info.hasEnhancement, info.enhanced);
res = LCEVC_FreePicture(lcevc->decoder, picture);
if (res != LCEVC_Success)
return AVERROR_EXTERNAL;
@@ -256,6 +269,10 @@ static void lcevc_free(AVRefStructOpaque unused, void *obj)
lcevc_flush_pictures(lcevc);
LCEVC_DestroyDecoder(lcevc->decoder);
}
if (lcevc->frag)
ff_cbs_fragment_free(lcevc->frag);
av_freep(&lcevc->frag);
ff_cbs_close(&lcevc->cbc);
memset(lcevc, 0, sizeof(*lcevc));
}
@@ -313,14 +330,74 @@ int ff_lcevc_process(void *logctx, AVFrame *frame)
return 0;
}
int ff_lcevc_alloc(FFLCEVCContext **plcevc)
int ff_lcevc_parse_frame(FFLCEVCContext *lcevc, const AVFrame *frame,
int *width, int *height, void *logctx)
{
LCEVCRawProcessBlock *block = NULL;
LCEVCRawGlobalConfig *gc = NULL;
AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_LCEVC);
int ret;
ret = ff_cbs_read(lcevc->cbc, lcevc->frag, sd->buf, sd->data, sd->size);
if (ret < 0) {
av_log(logctx, AV_LOG_ERROR, "Failed to parse Access Unit.\n");
goto end;
}
ret = ff_cbs_lcevc_find_process_block(lcevc->cbc, lcevc->frag,
LCEVC_PAYLOAD_TYPE_GLOBAL_CONFIG, &block);
if (ret < 0) {
ret = 0;
goto end;
}
gc = block->payload;
if (gc->resolution_type < 63) {
*width = ff_lcevc_resolution_type[gc->resolution_type].width;
*height = ff_lcevc_resolution_type[gc->resolution_type].height;
} else {
*width = gc->custom_resolution_width;
*height = gc->custom_resolution_height;
}
ret = 0;
end:
ff_cbs_fragment_reset(lcevc->frag);
return ret;
}
static const CodedBitstreamUnitType decompose_unit_types[] = {
LCEVC_IDR_NUT,
};
int ff_lcevc_alloc(FFLCEVCContext **plcevc, void *logctx)
{
FFLCEVCContext *lcevc = NULL;
int ret;
lcevc = av_refstruct_alloc_ext(sizeof(*lcevc), 0, NULL, lcevc_free);
if (!lcevc)
return AVERROR(ENOMEM);
lcevc->frag = av_mallocz(sizeof(*lcevc->frag));
if (!lcevc->frag) {
ret = AVERROR(ENOMEM);
goto fail;
}
ret = ff_cbs_init(&lcevc->cbc, AV_CODEC_ID_LCEVC, logctx);
if (ret < 0)
goto fail;
lcevc->cbc->decompose_unit_types = decompose_unit_types;
lcevc->cbc->nb_decompose_unit_types = FF_ARRAY_ELEMS(decompose_unit_types);
*plcevc = lcevc;
return 0;
fail:
av_refstruct_unref(&lcevc);
return ret;
}
void ff_lcevc_unref(void *opaque)
+8 -1
View File
@@ -28,8 +28,13 @@
typedef uintptr_t LCEVC_DecoderHandle;
#endif
struct CodedBitstreamContext;
struct CodedBitstreamFragment;
typedef struct FFLCEVCContext {
LCEVC_DecoderHandle decoder;
struct CodedBitstreamContext *cbc;
struct CodedBitstreamFragment *frag;
int initialized;
} FFLCEVCContext;
@@ -40,7 +45,9 @@ typedef struct FFLCEVCFrame {
struct AVFrame *frame;
} FFLCEVCFrame;
int ff_lcevc_alloc(FFLCEVCContext **plcevc);
int ff_lcevc_alloc(FFLCEVCContext **plcevc, void *logctx);
int ff_lcevc_process(void *logctx, struct AVFrame *frame);
int ff_lcevc_parse_frame(FFLCEVCContext *lcevc, const struct AVFrame *frame,
int *width, int *height, void *logctx);
void ff_lcevc_unref(void *opaque);
#endif /* AVCODEC_LCEVCDEC_H */
+19
View File
@@ -0,0 +1,19 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "lcevctab.h"
+41
View File
@@ -0,0 +1,41 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_LCEVCTAB_H
#define AVCODEC_LCEVCTAB_H
static const struct {
int width;
int height;
} ff_lcevc_resolution_type[63] = {
{ 0, 0},
{ 360, 200 }, { 400, 240 }, { 480, 320 }, { 640, 360 },
{ 640, 480 }, { 768, 480 }, { 800, 600 }, { 852, 480 },
{ 854, 480 }, { 856, 480 }, { 960, 540 }, { 960, 640 },
{ 1024, 576 }, { 1024, 600 }, { 1024, 768 }, { 1152, 864 },
{ 1280, 720 }, { 1280, 800 }, { 1280, 1024 }, { 1360, 768 },
{ 1366, 768 }, { 1920, 1200 }, { 2048, 1080 }, { 2048, 1152 },
{ 2048, 1536 }, { 2160, 1440 }, { 2560, 1440 }, { 2560, 1600 },
{ 2560, 2048 }, { 3200, 1800 }, { 3200, 2048 }, { 3200, 2400 },
{ 3440, 1440 }, { 3840, 1600 }, { 3840, 2160 }, { 3840, 2400 },
{ 4096, 2160 }, { 4096, 3072 }, { 5120, 2880 }, { 5120, 3200 },
{ 5120, 4096 }, { 6400, 4096 }, { 6400, 4800 }, { 7680, 4320 },
{ 7680, 4800 },
};
#endif /* AVCODEC_LCEVCTAB_H */
+2 -2
View File
@@ -175,7 +175,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
int height = avctx->height; // Real image height
unsigned int mszh_dlen;
unsigned char yq, y1q, uq, vq;
int uqvq, ret;
int ret;
unsigned int mthread_inlen, mthread_outlen;
unsigned int len = buf_size;
int linesize, offset;
@@ -306,7 +306,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
for (row = 0; row < height; row++) {
pixel_ptr = row * width * 3;
yq = encoded[pixel_ptr++];
uqvq = AV_RL16(encoded+pixel_ptr);
unsigned uqvq = AV_RL16(encoded+pixel_ptr);
pixel_ptr += 2;
for (col = 1; col < width; col++) {
encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
+4
View File
@@ -90,6 +90,8 @@ static int lz4_decompress(AVCodecContext *avctx,
unsigned char current;
do {
current = bytestream2_get_byte(gb);
if (current > INT_MAX - num_literals)
return AVERROR_INVALIDDATA;
num_literals += current;
} while (current == 255);
}
@@ -122,6 +124,8 @@ static int lz4_decompress(AVCodecContext *avctx,
do {
current = bytestream2_get_byte(gb);
if (current > INT_MAX - match_length)
return AVERROR_INVALIDDATA;
match_length += current;
} while (current == 255);
}
+2
View File
@@ -463,6 +463,8 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc,
block->emph_coeff,
ff_opus_deemph_weights,
frame_size);
if (!isnormal(block->emph_coeff))
block->emph_coeff = 0.0;
}
if (channels == 1)
+3
View File
@@ -77,6 +77,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
return AVERROR_INVALIDDATA;
}
if (avpkt->size * 1032LL < ((avctx->width + 7) >> 3) * avctx->height) //Asymptotic max compression of deflate
return AVERROR_INVALIDDATA;
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
+1 -1
View File
@@ -558,7 +558,7 @@ static int decode_text_to_exif(PNGDecContext *s, const char *txt_utf8)
}
// first condition checks for overflow in 2 * exif_len
if ((exif_len & ~SIZE_MAX) || end - ptr < 2 * exif_len)
if (exif_len > SIZE_MAX / 2 || end - ptr < 2 * exif_len)
return AVERROR_INVALIDDATA;
if (exif_len < 10)
return AVERROR_INVALIDDATA;
+1
View File
@@ -403,6 +403,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
dst->hwaccel_flags = src->hwaccel_flags;
av_refstruct_replace(&dst->internal->pool, src->internal->pool);
ff_decode_internal_sync(dst, src);
}
if (for_user) {
+1
View File
@@ -157,6 +157,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (ctx->max_frame_size > (1 << 20) || !ctx->max_frame_size) {
av_log(avctx, AV_LOG_ERROR, "invalid frame size %d\n",
ctx->max_frame_size);
return AVERROR_INVALIDDATA;
}
ctx->max_frame_size = FFMAX(ctx->max_frame_size, avctx->sample_rate);
+6 -4
View File
@@ -51,6 +51,8 @@ typedef struct RASCContext {
GetByteContext gb;
uint8_t *delta;
int delta_size;
uint8_t *mv_scratch;
unsigned int mv_scratch_size;
uint8_t *cursor;
int cursor_size;
unsigned cursor_w;
@@ -294,10 +296,8 @@ static int decode_move(AVCodecContext *avctx,
b2 -= s->frame2->linesize[0];
}
} else if (type == 0) {
uint8_t *buffer;
av_fast_padded_malloc(&s->delta, &s->delta_size, w * h * s->bpp);
buffer = s->delta;
av_fast_padded_malloc(&s->mv_scratch, &s->mv_scratch_size, w * h * s->bpp);
uint8_t *buffer = s->mv_scratch;
if (!buffer)
return AVERROR(ENOMEM);
@@ -772,6 +772,8 @@ static av_cold int decode_close(AVCodecContext *avctx)
s->cursor_size = 0;
av_freep(&s->delta);
s->delta_size = 0;
av_freep(&s->mv_scratch);
s->mv_scratch_size = 0;
av_frame_free(&s->frame1);
av_frame_free(&s->frame2);
ff_inflate_end(&s->zstream);
+5
View File
@@ -696,6 +696,11 @@ static int svq1_decode_frame(AVCodecContext *avctx, AVFrame *cur,
avctx->skip_frame >= AVDISCARD_ALL)
return buf_size;
// Reject obviously too-small packets early: require at least one remaining bit per aligned luma macroblock.
// FFALIGN(s->width, 16) * FFALIGN(s->height, 16) / 256 represent the number of Macroblocks
if (get_bits_left(&s->gb) < FFALIGN(s->width, 16) * FFALIGN(s->height, 16) / 256)
return AVERROR_INVALIDDATA;
result = ff_get_buffer(avctx, cur, s->nonref ? 0 : AV_GET_BUFFER_FLAG_REF);
if (result < 0)
return result;
+6 -4
View File
@@ -240,7 +240,6 @@ static int tdsc_load_cursor(AVCodecContext *avctx)
bits <<= 1;
}
}
dst += ctx->cursor_stride - ctx->cursor_w * 4;
}
dst = ctx->cursor;
@@ -272,7 +271,6 @@ static int tdsc_load_cursor(AVCodecContext *avctx)
bits <<= 1;
}
}
dst += ctx->cursor_stride - ctx->cursor_w * 4;
}
break;
case CUR_FMT_BGRA:
@@ -358,7 +356,8 @@ static int tdsc_decode_jpeg_tile(AVCodecContext *avctx, int tile_size,
}
ret = avcodec_receive_frame(ctx->jpeg_avctx, ctx->jpgframe);
if (ret < 0 || ctx->jpgframe->format != AV_PIX_FMT_YUVJ420P) {
if (ret < 0 || ctx->jpgframe->format != AV_PIX_FMT_YUVJ420P ||
w > ctx->jpgframe->width || h > ctx->jpgframe->height) {
av_log(avctx, AV_LOG_ERROR,
"JPEG decoding error (%d).\n", ret);
@@ -402,7 +401,7 @@ static int tdsc_decode_tiles(AVCodecContext *avctx, int number_tiles)
}
tile_size = bytestream2_get_le32(&ctx->gbc);
if (bytestream2_get_bytes_left(&ctx->gbc) < tile_size)
if (bytestream2_get_bytes_left(&ctx->gbc) < tile_size + 24LL)
return AVERROR_INVALIDDATA;
tile_mode = bytestream2_get_le32(&ctx->gbc);
@@ -435,6 +434,9 @@ static int tdsc_decode_tiles(AVCodecContext *avctx, int number_tiles)
if (ret < 0)
return ret;
} else if (tile_mode == MKTAG(' ','W','A','R')) {
if (3LL * w * h > tile_size)
return AVERROR_INVALIDDATA;
/* Just copy the buffer to output */
av_image_copy_plane(ctx->refframe->data[0] + x * 3 +
ctx->refframe->linesize[0] * y,
+1 -1
View File
@@ -30,7 +30,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 28
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
+1 -1
View File
@@ -83,7 +83,7 @@ CFDataRef ff_videotoolbox_vpcc_extradata_create(AVCodecContext *avctx)
p = vt_extradata;
*p++ = 1; /* version */
AV_WB24(p + 1, 0); /* flags */
AV_WB24(p, 0); /* flags */
p += 3;
*p++ = h->h.profile;
+1 -1
View File
@@ -2150,7 +2150,7 @@ static int copy_replace_length_codes(
uint8_t *new_sei;
old_sei_length = find_sei_end(avctx, dst_box, box_len, &new_sei);
if (old_sei_length < 0)
return status;
return old_sei_length;
wrote_bytes = write_sei(sei,
SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35,
+4 -1
View File
@@ -255,8 +255,10 @@ static int update_size(AVCodecContext *avctx, int w, int h)
*fmtp = AV_PIX_FMT_NONE;
ret = ff_get_format(avctx, pix_fmts);
if (ret < 0)
if (ret < 0) {
ff_set_dimensions(avctx, s->w, s->h);
return ret;
}
avctx->pix_fmt = ret;
s->gf_fmt = s->pix_fmt;
@@ -1825,6 +1827,7 @@ finish:
return pkt->size;
fail:
ff_cbs_fragment_reset(&s->current_frag);
ff_progress_frame_report(&s->s.frames[CUR_FRAME].tf, INT_MAX);
return ret;
}
+11 -2
View File
@@ -751,6 +751,8 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext *
VkVideoFormatPropertiesKHR *ret_info;
uint32_t nb_out_fmts = 0;
const uint32_t feedback_flags = VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_BUFFER_OFFSET_BIT_KHR |
VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_BYTES_WRITTEN_BIT_KHR;
VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR quality_info;
@@ -770,6 +772,14 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext *
return AVERROR(EINVAL);
}
if ((ctx->enc_caps.supportedEncodeFeedbackFlags & feedback_flags) !=
feedback_flags) {
av_log (avctx, AV_LOG_ERROR,
"Driver does not support required encode feedback flags "
"(BUFFER_OFFSET and BYTES_WRITTEN).\n");
return AVERROR(ENOTSUP);
}
ctx->base.op = &vulkan_base_encode_ops;
ctx->codec = codec;
@@ -879,8 +889,7 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext *
query_create = (VkQueryPoolVideoEncodeFeedbackCreateInfoKHR) {
.sType = VK_STRUCTURE_TYPE_QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR,
.pNext = &ctx->profile,
.encodeFeedbackFlags = ctx->enc_caps.supportedEncodeFeedbackFlags &
(~VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_HAS_OVERRIDES_BIT_KHR),
.encodeFeedbackFlags = feedback_flags,
};
err = ff_vk_exec_pool_init(s, ctx->qf_enc, &ctx->enc_pool, base_ctx->async_depth,
1, VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR, 0,
+2 -2
View File
@@ -65,14 +65,14 @@ static av_cold int encode_init(AVCodecContext *avctx)
flags1 = 0;
flags2 = 1;
if (avctx->codec->id == AV_CODEC_ID_WMAV1) {
extradata = av_malloc(4);
extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!extradata)
return AVERROR(ENOMEM);
avctx->extradata_size = 4;
AV_WL16(extradata, flags1);
AV_WL16(extradata + 2, flags2);
} else if (avctx->codec->id == AV_CODEC_ID_WMAV2) {
extradata = av_mallocz(10);
extradata = av_mallocz(10 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!extradata)
return AVERROR(ENOMEM);
avctx->extradata_size = 10;
+4
View File
@@ -343,6 +343,8 @@ static int parse_mb_skip(WMV2DecContext *w)
mb_type[mb_y * h->c.mb_stride + mb_x] =
MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
} else {
if (get_bits_left(&h->gb) < h->c.mb_width)
return AVERROR_INVALIDDATA;
for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
mb_type[mb_y * h->c.mb_stride + mb_x] =
(get_bits1(&h->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
@@ -358,6 +360,8 @@ static int parse_mb_skip(WMV2DecContext *w)
mb_type[mb_y * h->c.mb_stride + mb_x] =
MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
} else {
if (get_bits_left(&h->gb) < h->c.mb_height)
return AVERROR_INVALIDDATA;
for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
mb_type[mb_y * h->c.mb_stride + mb_x] =
(get_bits1(&h->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
+1 -1
View File
@@ -68,7 +68,7 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
}
s->buffer_size = avctx->width * avctx->height;
s->y_buffer = av_malloc(s->buffer_size);
s->y_buffer = av_mallocz(s->buffer_size);
if (!s->y_buffer)
return AVERROR(ENOMEM);
s->scratch_buffer = av_malloc(s->buffer_size + 130);
+12 -2
View File
@@ -138,6 +138,8 @@ static int zmbv_decode_xor_8(ZmbvContext *c)
}
if (d) { /* apply XOR'ed difference */
if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2)
return AVERROR_INVALIDDATA;
out = output + x;
for (j = 0; j < bh2; j++) {
for (i = 0; i < bw2; i++)
@@ -212,6 +214,8 @@ static int zmbv_decode_xor_16(ZmbvContext *c)
}
if (d) { /* apply XOR'ed difference */
if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2 * 2)
return AVERROR_INVALIDDATA;
out = output + x;
for (j = 0; j < bh2; j++){
for (i = 0; i < bw2; i++) {
@@ -296,6 +300,8 @@ static int zmbv_decode_xor_24(ZmbvContext *c)
}
if (d) { /* apply XOR'ed difference */
if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2 * 3)
return AVERROR_INVALIDDATA;
out = output + x * 3;
for (j = 0; j < bh2; j++) {
for (i = 0; i < bw2; i++) {
@@ -374,6 +380,8 @@ static int zmbv_decode_xor_32(ZmbvContext *c)
}
if (d) { /* apply XOR'ed difference */
if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2 * 4)
return AVERROR_INVALIDDATA;
out = output + x;
for (j = 0; j < bh2; j++){
for (i = 0; i < bw2; i++) {
@@ -568,8 +576,10 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
frame->pict_type = AV_PICTURE_TYPE_P;
if (c->decomp_len < 2LL * ((c->width + c->bw - 1) / c->bw) * ((c->height + c->bh - 1) / c->bh))
return AVERROR_INVALIDDATA;
if (c->decomp_len)
c->decode_xor(c);
if (c->decomp_len) {
if ((ret = c->decode_xor(c)) < 0)
return ret;
}
}
/* update frames */
+1 -1
View File
@@ -30,7 +30,7 @@
#include "version_major.h"
#define LIBAVDEVICE_VERSION_MINOR 3
#define LIBAVDEVICE_VERSION_MICRO 100
#define LIBAVDEVICE_VERSION_MICRO 101
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
LIBAVDEVICE_VERSION_MINOR, \
+6
View File
@@ -74,6 +74,7 @@ typedef struct LV2Context {
float *controls;
LilvInstance *instance;
int instance_activated;
LilvNode *atom_AtomPort;
LilvNode *atom_Sequence;
@@ -387,6 +388,9 @@ static int config_output(AVFilterLink *outlink)
inlink->min_samples = inlink->max_samples = 4096;
}
lilv_instance_activate(s->instance);
s->instance_activated = 1;
return 0;
}
@@ -562,6 +566,8 @@ static av_cold void uninit(AVFilterContext *ctx)
{
LV2Context *s = ctx->priv;
if (s->instance_activated)
lilv_instance_deactivate(s->instance);
lilv_node_free(s->powerOf2BlockLength);
lilv_node_free(s->fixedBlockLength);
lilv_node_free(s->boundedBlockLength);
+2 -2
View File
@@ -70,7 +70,7 @@ static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
skip_spaces(arg);
/* try to parse a channel name, e.g. "FL" */
if (sscanf(*arg, "%7[A-Z]%n", buf, &len)) {
if (sscanf(*arg, "%7[A-Z]%n", buf, &len) >= 1) {
channel_id = av_channel_from_string(buf);
if (channel_id < 0)
return channel_id;
@@ -81,7 +81,7 @@ static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
return 0;
}
/* try to parse a channel number, e.g. "c2" */
if (sscanf(*arg, "c%d%n", &channel_id, &len) &&
if (sscanf(*arg, "c%d%n", &channel_id, &len) >= 1 &&
channel_id >= 0 && channel_id < MAX_CHANNELS) {
*rchannel = channel_id;
*rnamed = 0;
+1 -1
View File
@@ -32,7 +32,7 @@
#include "version_major.h"
#define LIBAVFILTER_VERSION_MINOR 14
#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_MICRO 101
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
+14 -5
View File
@@ -77,11 +77,20 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
uint8_t *next = &yadif->next->data[td->plane][y * linesize];
uint8_t *dst = &td->frame->data[td->plane][y * td->frame->linesize[td->plane]];
if (yadif->current_field == YADIF_FIELD_END) {
s->dsp.filter_intra(dst, cur, td->w, (y + df) < td->h ? refs : -refs,
y > (df - 1) ? -refs : refs,
(y + 3*df) < td->h ? 3 * refs : -refs,
y > (3*df - 1) ? -3 * refs : refs,
td->parity ^ td->tff, clip_max);
if ((y < 3) || ((y + 3) >= td->h)) {
s->dsp.filter_edge(dst, prev, cur, next, td->w,
(y + df) < td->h ? refs : -refs,
y > (df - 1) ? -refs : refs,
refs << 1, -(refs << 1),
td->parity ^ td->tff, clip_max,
(y < 2) || ((y + 3) > td->h) ? 0 : 1);
} else {
s->dsp.filter_intra(dst, cur, td->w, (y + df) < td->h ? refs : -refs,
y > (df - 1) ? -refs : refs,
(y + 3*df) < td->h ? 3 * refs : -refs,
y > (3*df - 1) ? -3 * refs : refs,
td->parity ^ td->tff, clip_max);
}
} else if ((y < 4) || ((y + 5) > td->h)) {
s->dsp.filter_edge(dst, prev, cur, next, td->w,
(y + df) < td->h ? refs : -refs,
+15 -2
View File
@@ -266,9 +266,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
if (par->nb_blocks) {
for (int block_idx = 0; block_idx < par->nb_blocks; block_idx++) {
AVVideoBlockParams *b = av_video_enc_params_block(par, block_idx);
uint8_t *buf = frame->data[0] + b->src_y * stride;
draw_block_rectangle(buf, b->src_x, b->src_y, b->w, b->h, stride, 100);
int64_t x0 = b->src_x;
int64_t y0 = b->src_y;
int64_t x1 = x0 + b->w;
int64_t y1 = y0 + b->h;
x0 = FFMAX(x0, 0);
y0 = FFMAX(y0, 0);
x1 = FFMIN(x1, frame->width);
y1 = FFMIN(y1, frame->height);
if (x1 <= x0 || y1 <= y0)
continue;
uint8_t *buf = frame->data[0] + y0 * stride;
draw_block_rectangle(buf, x0, y0, x1-x0, y1-y0, stride, 100);
}
}
}
+9 -3
View File
@@ -1435,8 +1435,13 @@ continue_on_failed:
}
s->line_count = line_count;
s->lines = av_mallocz(line_count * sizeof(TextLine));
s->tab_clusters = av_mallocz(s->tab_count * sizeof(uint32_t));
s->lines = av_calloc(line_count, sizeof(TextLine));
s->tab_clusters = av_calloc(s->tab_count, sizeof(uint32_t));
if ((line_count > 0 && !s->lines) ||
(s->tab_count > 0 && !s->tab_clusters)) {
ret = AVERROR(ENOMEM);
goto done;
}
for (i = 0; i < s->tab_count; ++i) {
s->tab_clusters[i] = -1;
}
@@ -1452,13 +1457,14 @@ continue_on_failed:
s->tab_clusters[tab_idx++] = i;
*p = ' ';
}
size_t len = p - start;
GET_UTF8(code, *p ? *p++ : 0, code = 0xfffd; goto continue_on_failed2;);
continue_on_failed2:
if (ff_is_newline(code) || code == 0) {
TextLine *cur_line = &s->lines[line_count];
HarfbuzzData *hb = &cur_line->hb_data;
cur_line->cluster_offset = line_offset;
ret = shape_text_hb(s, hb, start, p - start);
ret = shape_text_hb(s, hb, start, len);
if (ret != 0) {
goto done;
}
+6
View File
@@ -85,6 +85,12 @@ static int config_props(AVFilterLink *inlink)
kerndeint->is_packed_rgb = av_pix_fmt_desc_get(inlink->format)->flags & AV_PIX_FMT_FLAG_RGB;
kerndeint->vsub = desc->log2_chroma_h;
if (AV_CEIL_RSHIFT(inlink->h, kerndeint->vsub) < 4) {
av_log(inlink->dst, AV_LOG_ERROR,
"Input height %d is too small; minimum chroma plane height is 4\n",
inlink->h);
return AVERROR(EINVAL);
}
ret = av_image_alloc(kerndeint->tmp_data, kerndeint->tmp_linesize,
inlink->w, inlink->h, inlink->format, 16);
+8
View File
@@ -667,14 +667,22 @@ static void lock_queue(void *priv, uint32_t qf, uint32_t qidx)
{
AVHWDeviceContext *avhwctx = priv;
const AVVulkanDeviceContext *hwctx = avhwctx->hwctx;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->lock_queue(avhwctx, qf, qidx);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
static void unlock_queue(void *priv, uint32_t qf, uint32_t qidx)
{
AVHWDeviceContext *avhwctx = priv;
const AVVulkanDeviceContext *hwctx = avhwctx->hwctx;
#if FF_API_VULKAN_SYNC_QUEUES
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->unlock_queue(avhwctx, qf, qidx);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
#endif
+9 -3
View File
@@ -1034,10 +1034,16 @@ generate_eye_tape_map(SSIM360Context *s,
float x_range = end_x - start_x;
// Ensure tape length is a multiple of 4, for full SSIM block coverage
int tape_length = s->tape_length[plane] = ((int)ROUNDED_DIV(x_range, 4)) << 2;
float tape_length_f = ROUNDED_DIV(x_range, 4);
int tape_length;
s->ref_tape_map[plane][eye] = av_malloc_array(tape_length * 8, sizeof(BilinearMap));
s->main_tape_map[plane][eye] = av_malloc_array(tape_length * 8, sizeof(BilinearMap));
if (!(tape_length_f > 0.f) || tape_length_f > INT_MAX / 4.0f)
return AVERROR(EINVAL);
tape_length = s->tape_length[plane] = (int)tape_length_f << 2;
s->ref_tape_map[plane][eye] = av_malloc_array(tape_length, 8 * sizeof(BilinearMap));
s->main_tape_map[plane][eye] = av_malloc_array(tape_length, 8 * sizeof(BilinearMap));
if (!s->ref_tape_map[plane][eye] || !s->main_tape_map[plane][eye])
return AVERROR(ENOMEM);
+1 -1
View File
@@ -291,7 +291,7 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo
\
av_assert1(s->nb_planes <= AV_VIDEO_MAX_PLANES); \
\
for (int stereo = 0; stereo < 1 + s->out_stereo > STEREO_2D; stereo++) { \
for (int stereo = 0; stereo < 1 + (s->out_stereo > STEREO_2D); stereo++) { \
for (int plane = 0; plane < s->nb_planes; plane++) { \
const unsigned map = s->map[plane]; \
const int in_linesize = in->linesize[plane]; \
+5 -3
View File
@@ -23,6 +23,7 @@
#include "libavutil/dict.h"
#include "libavutil/mem.h"
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
#include "pcm.h"
@@ -368,9 +369,10 @@ static int aiff_read_header(AVFormatContext *s)
if (len == 11 && size > 11) {
uint8_t chunk[11];
ret = avio_read(pb, chunk, 11);
if (ret > 0)
size -= ret;
ret = ffio_read_size(pb, chunk, 11);
if (ret < 0)
return ret;
size -= ret;
if (!memcmp(chunk, "VADPCMCODES", sizeof(chunk))) {
if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0)
return ret;
+8 -2
View File
@@ -562,9 +562,11 @@ static int avi_read_header(AVFormatContext *s)
avi->movi_end = avi->fsize;
av_log(s, AV_LOG_TRACE, "movi end=%"PRIx64"\n", avi->movi_end);
goto end_of_header;
} else if (tag1 == MKTAG('I', 'N', 'F', 'O'))
} else if (tag1 == MKTAG('I', 'N', 'F', 'O')) {
if (size < 4)
return AVERROR_INVALIDDATA;
ff_read_riff_info(s, size - 4);
else if (tag1 == MKTAG('n', 'c', 'd', 't'))
} else if (tag1 == MKTAG('n', 'c', 'd', 't'))
avi_read_nikon(s, list_end);
break;
@@ -1834,6 +1836,10 @@ static int avi_load_index(AVFormatContext *s)
avi->index_loaded=2;
ret = 0;
}else if (tag == MKTAG('L', 'I', 'S', 'T')) {
if (size < 4) {
av_log(s, AV_LOG_WARNING, "Invalid size (%u) LIST in index\n", size);
break;
}
uint32_t tag1 = avio_rl32(pb);
if (tag1 == MKTAG('I', 'N', 'F', 'O'))
+2
View File
@@ -566,6 +566,8 @@ static int read_seek(AVFormatContext *s, int stream_index,
frame_cnt = caf->frames_per_packet * packet_cnt - st->codecpar->initial_padding;
} else if (sti->nb_index_entries) {
packet_cnt = av_index_search_timestamp(st, timestamp, flags);
if (packet_cnt < 0)
return -1;
frame_cnt = sti->index_entries[packet_cnt].timestamp;
pos = sti->index_entries[packet_cnt].pos;
} else {
+12
View File
@@ -113,6 +113,12 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags)
break;
}
if (total_size > INT64_MAX - size) {
ffurl_close(uc);
err = AVERROR_INVALIDDATA;
break;
}
/* assembling */
nodes[i].uc = uc;
nodes[i].size = size;
@@ -282,6 +288,12 @@ static av_cold int concatf_open(URLContext *h, const char *uri, int flags)
break;
}
if (total_size > INT64_MAX - size) {
ffurl_close(uc);
err = AVERROR_INVALIDDATA;
break;
}
nodes = av_fast_realloc(data->nodes, &nodes_size, sizeof(*nodes) * len);
if (!nodes) {
ffurl_close(uc);
+1 -1
View File
@@ -252,7 +252,7 @@ static int64_t get_duration(AVFormatContext *s)
int64_t size = avio_size(s->pb);
int64_t ret = 0;
if (start_pos + 20 > size)
if (start_pos < 0 || start_pos > size - 20)
return 0;
avio_skip(s->pb, 16);
+4 -1
View File
@@ -26,6 +26,7 @@
#include "avformat.h"
#include "demux.h"
#include "internal.h"
#include "avio_internal.h"
#define DSS_HEAD_OFFSET_AUTHOR 0xc
#define DSS_AUTHOR_SIZE 16
@@ -339,7 +340,9 @@ static int dss_read_seek(AVFormatContext *s, int stream_index,
if (ret < 0)
return ret;
avio_read(s->pb, header, DSS_AUDIO_BLOCK_HEADER_SIZE);
ret = ffio_read_size(s->pb, header, DSS_AUDIO_BLOCK_HEADER_SIZE);
if (ret < 0)
return ret;
ctx->swap = !!(header[0] & 0x80);
offset = 2*header[1] + 2*ctx->swap;
if (offset < DSS_AUDIO_BLOCK_HEADER_SIZE)
+6 -1
View File
@@ -26,6 +26,7 @@
#include "avformat.h"
#include "demux.h"
#include "internal.h"
#include "avio_internal.h"
#define AUPR_HDR 0x415550522D484452
#define AUPRINFO 0x41555052494E464F
@@ -125,7 +126,11 @@ static int dtshd_read_header(AVFormatContext *s)
value = av_malloc(chunk_size);
if (!value)
goto skip;
avio_read(pb, value, chunk_size);
ret = ffio_read_size(pb, value, chunk_size);
if (ret < 0) {
av_free(value);
goto skip;
}
value[chunk_size - 1] = 0;
av_dict_set(&s->metadata, "fileinfo", value,
AV_DICT_DONT_STRDUP_VAL);
+1
View File
@@ -88,6 +88,7 @@ void ff_hls_senc_read_audio_setup_info(HLSAudioSetupInfo *info, const uint8_t *b
return;
memcpy(info->setup_data, buf, info->setup_data_length);
memset(info->setup_data + info->setup_data_length, 0, AV_INPUT_BUFFER_PADDING_SIZE);
}
int ff_hls_senc_parse_audio_setup_info(AVStream *st, HLSAudioSetupInfo *info)
+1 -1
View File
@@ -52,7 +52,7 @@ typedef struct HLSAudioSetupInfo {
uint16_t priming;
uint8_t version;
uint8_t setup_data_length;
uint8_t setup_data[HLS_MAX_AUDIO_SETUP_DATA_LEN];
uint8_t setup_data[HLS_MAX_AUDIO_SETUP_DATA_LEN + AV_INPUT_BUFFER_PADDING_SIZE];
} HLSAudioSetupInfo;
+4
View File
@@ -118,6 +118,10 @@ static int hxvs_probe(const AVProbeData *p)
i += 4;
if (tag == HXVF || tag == HXAF) {
bytes = AV_RL32(&p->buf[i]);
if (12 + bytes > INT_MAX - i)
return 0;
i += 12 + bytes;
flag |= (tag == HXVF) ? 2 : 4;
continue;
+1 -1
View File
@@ -38,7 +38,7 @@ static int opus_decoder_config(IAMFCodecConfig *codec_config,
{
int ret, left = len - avio_tell(pb);
if (left < 11 || codec_config->audio_roll_distance >= 0)
if (left < 11 || codec_config->audio_roll_distance >= 0 || left > INT_MAX - 8)
return AVERROR_INVALIDDATA;
codec_config->extradata = av_malloc(left + 8);
+10 -3
View File
@@ -126,9 +126,14 @@ static int fill_codec_config(IAMFContext *iamf, const AVStreamGroup *stg,
}
populate_audio_roll_distance(codec_config);
if (st->codecpar->extradata_size) {
codec_config->extradata = av_memdup(st->codecpar->extradata, st->codecpar->extradata_size);
if (st->codecpar->extradata_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
return AVERROR_INVALIDDATA;
codec_config->extradata = av_malloc(st->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!codec_config->extradata)
return AVERROR(ENOMEM);
memcpy(codec_config->extradata, st->codecpar->extradata, st->codecpar->extradata_size);
memset(codec_config->extradata + st->codecpar->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
codec_config->extradata_size = st->codecpar->extradata_size;
ret = update_extradata(codec_config);
if (ret < 0)
@@ -1237,15 +1242,17 @@ int ff_iamf_write_audio_frame(const IAMFContext *iamf, AVIOContext *pb,
AV_PKT_DATA_NEW_EXTRADATA,
&new_extradata_size);
if (!new_extradata)
if (!new_extradata || new_extradata_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
return AVERROR_INVALIDDATA;
av_free(codec_config->extradata);
codec_config->extradata = av_memdup(new_extradata, new_extradata_size);
codec_config->extradata = av_malloc(new_extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!codec_config->extradata) {
codec_config->extradata_size = 0;
return AVERROR(ENOMEM);
}
memcpy(codec_config->extradata, new_extradata, new_extradata_size);
memset(codec_config->extradata + new_extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
codec_config->extradata_size = new_extradata_size;
return update_extradata(codec_config);
+4
View File
@@ -2783,6 +2783,10 @@ static int mka_parse_audio_codec(MatroskaTrack *track, AVCodecParameters *par,
par->block_align = track->audio.sub_packet_size;
*extradata_offset = 78;
}
if (par->block_align <= 0 ||
track->audio.sub_packet_h * (unsigned)track->audio.frame_size > INT_MAX ||
track->audio.frame_size * track->audio.sub_packet_h < par->block_align)
return AVERROR_INVALIDDATA;
track->audio.buf = av_malloc_array(track->audio.sub_packet_h,
track->audio.frame_size);
if (!track->audio.buf)
+5 -1
View File
@@ -36,6 +36,7 @@
#include "avformat.h"
#include "demux.h"
#include "internal.h"
#include "avio_internal.h"
#include "riff.h"
#define MLV_VERSION "v2.0"
@@ -74,12 +75,15 @@ static int check_file_header(AVIOContext *pb, uint64_t guid)
{
unsigned int size;
uint8_t version[8];
int ret;
avio_skip(pb, 4);
size = avio_rl32(pb);
if (size < 52)
return AVERROR_INVALIDDATA;
avio_read(pb, version, 8);
ret = ffio_read_size(pb, version, 8);
if (ret < 0)
return ret;
if (memcmp(version, MLV_VERSION, 5) || avio_rl64(pb) != guid)
return AVERROR_INVALIDDATA;
avio_skip(pb, size - 24);
+32 -9
View File
@@ -932,10 +932,9 @@ static int mov_read_iacb(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM);
iamf = &sc->iamf->iamf;
st->codecpar->extradata = av_malloc(descriptors_size);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
st->codecpar->extradata_size = descriptors_size;
ret = ff_alloc_extradata(st->codecpar, descriptors_size);
if (ret < 0)
return ret;
ret = avio_read(pb, st->codecpar->extradata, descriptors_size);
if (ret != descriptors_size)
@@ -3697,6 +3696,9 @@ static int mov_read_sdtp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
av_freep(&sc->sdtp_data);
sc->sdtp_count = 0;
if (entries < 0 || entries > SIZE_MAX)
return AVERROR(ERANGE);
sc->sdtp_data = av_malloc(entries);
if (!sc->sdtp_data)
return AVERROR(ENOMEM);
@@ -4327,7 +4329,12 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
st->index, edit_list_index, edit_list_media_time, edit_list_duration);
edit_list_index++;
edit_list_dts_counter = edit_list_dts_entry_end;
edit_list_dts_entry_end += edit_list_duration;
edit_list_dts_entry_end = av_sat_add64(edit_list_dts_entry_end, edit_list_duration);
if (edit_list_dts_entry_end == INT64_MAX) {
av_log(mov->fc, AV_LOG_ERROR, "Cannot calculate dts entry length with duration %"PRId64"\n",
edit_list_duration);
break;
}
num_discarded_begin = 0;
if (!found_non_empty_edit && edit_list_media_time == -1) {
empty_edits_sum_duration += edit_list_duration;
@@ -8559,7 +8566,7 @@ static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
if ((uint64_t)atom.size > (1<<30) || atom.size < 11)
if ((uint64_t)atom.size > (1<<30) || atom.size < 11 || st->codecpar->extradata)
return AVERROR_INVALIDDATA;
/* Check OpusSpecificBox version. */
@@ -8577,7 +8584,11 @@ static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AV_WL32A(st->codecpar->extradata, MKTAG('O','p','u','s'));
AV_WL32A(st->codecpar->extradata + 4, MKTAG('H','e','a','d'));
AV_WB8(st->codecpar->extradata + 8, 1); /* OpusHead version */
avio_read(pb, st->codecpar->extradata + 9, size - 9);
if ((ret = ffio_read_size(pb, st->codecpar->extradata + 9, size - 9)) < 0) {
av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = 0;
return ret;
}
/* OpusSpecificBox is stored in big-endian, but OpusHead is
little-endian; aside from the preceding magic and version they're
@@ -8665,8 +8676,10 @@ static int mov_read_lhvc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
// TODO: handle lhvC when present before hvcC
return 0;
if (atom.size < 6 || st->codecpar->extradata_size < 23)
if (atom.size < 6 || st->codecpar->extradata_size < 23 ||
atom.size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
return AVERROR_INVALIDDATA;
}
buf = av_malloc(atom.size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!buf)
@@ -9199,6 +9212,13 @@ static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version)
return AVERROR_INVALIDDATA;
}
entries = avio_rb16(pb);
if (!entries) {
av_log(c->fc, AV_LOG_ERROR,
"Derived image item references no input images\n");
return AVERROR_INVALIDDATA;
}
grid = av_realloc_array(c->heif_grid, c->nb_heif_grid + 1U,
sizeof(*c->heif_grid));
if (!grid)
@@ -9206,7 +9226,6 @@ static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version)
c->heif_grid = grid;
grid = &grid[c->nb_heif_grid];
entries = avio_rb16(pb);
grid->tile_id_list = av_malloc_array(entries, sizeof(*grid->tile_id_list));
grid->tile_idx_list = av_calloc(entries, sizeof(*grid->tile_idx_list));
grid->tile_item_list = av_calloc(entries, sizeof(*grid->tile_item_list));
@@ -10790,6 +10809,10 @@ static int mov_parse_lcevc_streams(AVFormatContext *s)
{
int err;
// Don't try to add a group if there's only one track
if (s->nb_streams <= 1)
return 0;
for (int i = 0; i < s->nb_streams; i++) {
AVStreamGroup *stg;
AVStream *st = s->streams[i];
+5 -5
View File
@@ -1041,10 +1041,10 @@ static int new_pes_packet(PESContext *pes, AVPacket *pkt)
"Invalid JPEG-XS header size %"PRIu32" > packet size %d\n",
header_size, pkt->size);
pes->flags |= AV_PKT_FLAG_CORRUPT;
return AVERROR_INVALIDDATA;
} else {
pkt->data += header_size;
pkt->size -= header_size;
}
pkt->data += header_size;
pkt->size -= header_size;
}
memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
@@ -1703,7 +1703,7 @@ static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size,
ret = parse_mp4_descr(&d, avio_tell(&d.pb.pub), size, MP4IODescrTag);
*descr_count = d.descr_count;
*descr_count += d.descr_count;
return ret;
}
@@ -2614,7 +2614,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
get8(&p, p_end); // label
len -= 2;
mp4_read_iods(ts->stream, p, len, mp4_descr + mp4_descr_count,
&mp4_descr_count, MAX_MP4_DESCR_COUNT);
&mp4_descr_count, MAX_MP4_DESCR_COUNT - mp4_descr_count);
} else if (tag == REGISTRATION_DESCRIPTOR && len >= 4) {
prog_reg_desc = bytestream_get_le32(&p);
len -= 4;
+7 -3
View File
@@ -74,7 +74,8 @@ int ff_pcm_read_seek(AVFormatContext *s,
int stream_index, int64_t timestamp, int flags)
{
AVStream *st;
int block_align, byte_rate;
int block_align;
int64_t byte_rate;
int64_t pos, ret;
st = s->streams[0];
@@ -82,9 +83,9 @@ int ff_pcm_read_seek(AVFormatContext *s,
block_align = st->codecpar->block_align ? st->codecpar->block_align :
(av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->ch_layout.nb_channels) >> 3;
byte_rate = st->codecpar->bit_rate ? st->codecpar->bit_rate >> 3 :
block_align * st->codecpar->sample_rate;
block_align * (int64_t)st->codecpar->sample_rate;
if (block_align <= 0 || byte_rate <= 0)
if (block_align <= 0 || byte_rate <= 0 || FFMAX(timestamp, st->time_base.num) > INT64_MAX / byte_rate)
return -1;
if (timestamp < 0) timestamp = 0;
@@ -93,6 +94,9 @@ int ff_pcm_read_seek(AVFormatContext *s,
st->time_base.num,
st->time_base.den * (int64_t)block_align,
(flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
if (pos > (INT64_MAX - FFMAX(ffformatcontext(s)->data_offset, 0)) / block_align)
return -1;
pos *= block_align;
/* recompute exact position */
+4 -3
View File
@@ -22,6 +22,7 @@
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avio.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
@@ -131,9 +132,9 @@ static int rsd_read_header(AVFormatContext *s)
return ret;
for (i = 0; i < par->ch_layout.nb_channels; i++) {
if (avio_feof(pb))
return AVERROR_EOF;
avio_read(s->pb, st->codecpar->extradata + 32 * i, 32);
ret = ffio_read_size(s->pb, st->codecpar->extradata + 32 * i, 32);
if (ret < 0)
return ret;
avio_skip(s->pb, 8);
}
break;
+37 -21
View File
@@ -1209,6 +1209,10 @@ static int rtmp_calc_swfhash(URLContext *s)
if (!memcmp(in_data, "CWS", 3)) {
#if CONFIG_ZLIB
int64_t out_size;
if (in_size < 8) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
/* Decompress the SWF player file using Zlib. */
if (!(out_data = av_malloc(8))) {
ret = AVERROR(ENOMEM);
@@ -2269,9 +2273,14 @@ static int update_offset(RTMPContext *rt, int size)
{
int old_flv_size;
if (size < 0)
return AVERROR(EINVAL);
// generate packet header and put data into buffer for FLV demuxer
if (rt->flv_off < rt->flv_size) {
// There is old unread data in the buffer, thus append at the end
if (rt->flv_size > INT_MAX - size)
return AVERROR(ERANGE);
old_flv_size = rt->flv_size;
rt->flv_size += size;
} else {
@@ -2298,7 +2307,11 @@ static int append_flv_data(RTMPContext *rt, RTMPPacket *pkt, int skip)
rt->has_video = 1;
}
if (size > INT_MAX - 15)
return AVERROR(ERANGE);
old_flv_size = update_offset(rt, size + 15);
if (old_flv_size < 0)
return old_flv_size;
if ((ret = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) {
rt->flv_size = rt->flv_off = 0;
@@ -2428,48 +2441,50 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
static int handle_metadata(RTMPContext *rt, RTMPPacket *pkt)
{
int ret, old_flv_size, type;
const uint8_t *next;
uint8_t *p;
PutByteContext pbc;
GetByteContext gbc;
uint32_t size;
uint32_t ts, cts, pts = 0;
old_flv_size = update_offset(rt, pkt->size);
if (old_flv_size < 0)
return old_flv_size;
if ((ret = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) {
rt->flv_size = rt->flv_off = 0;
return ret;
}
next = pkt->data;
p = rt->flv_data + old_flv_size;
bytestream2_init(&gbc, pkt->data, pkt->size);
bytestream2_init_writer(&pbc, rt->flv_data, rt->flv_size);
bytestream2_skip_p(&pbc, old_flv_size);
/* copy data while rewriting timestamps */
ts = pkt->timestamp;
while (next - pkt->data < pkt->size - RTMP_HEADER) {
type = bytestream_get_byte(&next);
size = bytestream_get_be24(&next);
cts = bytestream_get_be24(&next);
cts |= bytestream_get_byte(&next) << 24;
while (bytestream2_get_bytes_left(&gbc) > RTMP_HEADER) {
type = bytestream2_get_byte(&gbc);
size = bytestream2_get_be24(&gbc);
cts = bytestream2_get_be24(&gbc);
cts |= bytestream2_get_byte(&gbc) << 24;
if (!pts)
pts = cts;
ts += cts - pts;
pts = cts;
if (size + 3 + 4 > pkt->data + pkt->size - next)
if (size + 3 + 4 > bytestream2_get_bytes_left(&gbc))
break;
bytestream_put_byte(&p, type);
bytestream_put_be24(&p, size);
bytestream_put_be24(&p, ts);
bytestream_put_byte(&p, ts >> 24);
memcpy(p, next, size + 3 + 4);
p += size + 3;
bytestream_put_be32(&p, size + RTMP_HEADER);
next += size + 3 + 4;
bytestream2_put_byte(&pbc, type);
bytestream2_put_be24(&pbc, size);
bytestream2_put_be24(&pbc, ts);
bytestream2_put_byte(&pbc, ts >> 24);
bytestream2_copy_buffer(&pbc, &gbc, size + 3);
bytestream2_skip(&gbc, 4);
bytestream2_put_be32(&pbc, size + RTMP_HEADER);
}
if (p != rt->flv_data + rt->flv_size) {
if (bytestream2_tell_p(&pbc) != rt->flv_size) {
av_log(rt, AV_LOG_WARNING, "Incomplete flv packets in "
"RTMP_PT_METADATA packet\n");
rt->flv_size = p - rt->flv_data;
rt->flv_size = bytestream2_tell_p(&pbc);
}
return 0;
@@ -2736,7 +2751,8 @@ static int rtmp_open(URLContext *s, const char *uri, int flags, AVDictionary **o
if (rt->listen)
ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port,
"?listen&listen_timeout=%d&tcp_nodelay=%d",
rt->listen_timeout * 1000, rt->tcp_nodelay);
rt->listen_timeout < 0 ? -1 : rt->listen_timeout * 1000,
rt->tcp_nodelay);
else
ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, "?tcp_nodelay=%d", rt->tcp_nodelay);
}
+6
View File
@@ -276,6 +276,12 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
av_log(ctx, AV_LOG_WARNING, "Only 8-bit precision is supported.\n");
if (qtable_len > 0) {
if (qtable_len != 128) {
av_log(ctx, AV_LOG_ERROR, "Invalid RTP/JPEG packet. Invalid qtable length %d.\n", qtable_len);
if (qtable_len%64 || qtable_len > 4*64)
return AVERROR_INVALIDDATA;
}
if (len < qtable_len) {
av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n");
return AVERROR_INVALIDDATA;
+5 -1
View File
@@ -73,11 +73,15 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data,
cur_len = 0;
while (data->pos < data->len) {
uint8_t val = data->buf[data->pos++];
if (val > data->len - cur_len) {
av_log(ctx, AV_LOG_ERROR, "Malformed LATM packet\n");
return AVERROR_INVALIDDATA;
}
cur_len += val;
if (val != 0xff)
break;
}
if (data->pos + cur_len > data->len) {
if (cur_len > data->len - data->pos) {
av_log(ctx, AV_LOG_ERROR, "Malformed LATM packet\n");
return AVERROR(EIO);
}
+1 -1
View File
@@ -138,7 +138,7 @@ static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf, int len)
length in bits */
au_headers_length = AV_RB16(buf);
if (au_headers_length > RTP_MAX_PACKET_LENGTH)
if (au_headers_length == 0 || au_headers_length > RTP_MAX_PACKET_LENGTH)
return -1;
data->au_headers_length_bytes = (au_headers_length + 7) / 8;
+8 -2
View File
@@ -186,8 +186,9 @@ static int qdm2_parse_subpacket(PayloadContext *qdm, AVStream *st,
*/
static int qdm2_restore_block(PayloadContext *qdm, AVStream *st, AVPacket *pkt)
{
int to_copy, n, res, include_csum;
int to_copy, n, res;
uint8_t *p, *csum_pos = NULL;
int include_csum = qdm->block_type == 2 || qdm->block_type == 4;
/* create packet to hold subpkts into a superblock */
av_assert0(qdm->cache > 0);
@@ -196,6 +197,11 @@ static int qdm2_restore_block(PayloadContext *qdm, AVStream *st, AVPacket *pkt)
break;
av_assert0(n < 0x80);
int min_size = 2 + (qdm->len[n] > 0xff) + 2*include_csum;
if (qdm->block_size < min_size)
return AVERROR_INVALIDDATA;
if ((res = av_new_packet(pkt, qdm->block_size)) < 0)
return res;
memset(pkt->data, 0, pkt->size);
@@ -211,7 +217,7 @@ static int qdm2_restore_block(PayloadContext *qdm, AVStream *st, AVPacket *pkt)
*p++ = qdm->block_type;
*p++ = qdm->len[n];
}
if ((include_csum = (qdm->block_type == 2 || qdm->block_type == 4))) {
if (include_csum) {
csum_pos = p;
p += 2;
}
+2 -1
View File
@@ -612,7 +612,8 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
NULL, NULL, 0, p);
if (proto[0] == '\0') {
/* relative control URL */
if (rtsp_st->control_url[strlen(rtsp_st->control_url)-1]!='/')
size_t len = strlen(rtsp_st->control_url);
if (len == 0 || rtsp_st->control_url[len - 1] != '/')
av_strlcat(rtsp_st->control_url, "/",
sizeof(rtsp_st->control_url));
av_strlcat(rtsp_st->control_url, p,
+4 -4
View File
@@ -191,7 +191,7 @@ static int rtsp_read_announce(AVFormatContext *s)
rtsp_send_reply(s, RTSP_STATUS_SERVICE, NULL, request.seq);
return AVERROR_OPTION_NOT_FOUND;
}
if (request.content_length) {
if (request.content_length > 0) {
sdp = av_malloc(request.content_length + 1);
if (!sdp)
return AVERROR(ENOMEM);
@@ -215,10 +215,10 @@ static int rtsp_read_announce(AVFormatContext *s)
return 0;
}
av_log(s, AV_LOG_ERROR,
"Content-Length header value exceeds sdp allocated buffer (4KB)\n");
"Invalid ANNOUNCE Content-Length %d\n", request.content_length);
rtsp_send_reply(s, RTSP_STATUS_INTERNAL,
"Content-Length exceeds buffer size", request.seq);
return AVERROR(EIO);
"Invalid Content-Length", request.seq);
return AVERROR_INVALIDDATA;
}
static int rtsp_read_options(AVFormatContext *s)
+1 -1
View File
@@ -32,7 +32,7 @@
#include "version_major.h"
#define LIBAVFORMAT_VERSION_MINOR 12
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
+3 -1
View File
@@ -589,7 +589,9 @@ static int viv_read_header(AVFormatContext *s)
block_type = avio_r8(pb);
if (block_type == 22) {
avio_read(pb, keybuffer, 187);
ret = ffio_read_size(pb, keybuffer, 187);
if (ret < 0)
return ret;
b22_key = decode_key(keybuffer);
b22_size = avio_rl32(pb);
}
+2 -1
View File
@@ -694,7 +694,8 @@ static int64_t find_guid(AVIOContext *pb, const uint8_t guid1[16])
int64_t size;
while (!avio_feof(pb)) {
avio_read(pb, guid, 16);
if (avio_read(pb, guid, 16) != 16)
break;
size = avio_rl64(pb);
if (size <= 24 || size > INT64_MAX - 8)
return AVERROR_INVALIDDATA;
+6
View File
@@ -1906,6 +1906,12 @@ static void handle_rtx_packet(AVFormatContext *s, uint16_t seq)
ori_buf = it->buf;
ori_size = it->size;
/* A valid RTP packet must have at least a RTP header. */
if (ori_size < WHIP_RTP_HEADER_SIZE) {
av_log(whip, AV_LOG_WARNING, "RTX history packet too small, size=%d\n", ori_size);
goto end;
}
/* RTX packet format: header + original seq (2 bytes) + payload */
if (ori_size + 2 > sizeof(rtx_buf)) {
av_log(whip, AV_LOG_WARNING, "RTX packet is too large, size=%d\n", ori_size);

Some files were not shown because too many files have changed in this diff Show More