Compare commits

...

304 Commits

Author SHA1 Message Date
nyanmisaka ce3c09c101 avutil/hwcontext_cuda: fix yuv420p V/U plane overlap in cuda_get_buffer()
Odd-height yuv420p result in incorrect calculations of the U-plane
address offset. The last row of the V-plane overlapped with and was
overwritten by the first row of the U-plane, leading to chroma artifacts.

```
ffmpeg -init_hw_device cuda=cu -filter_hw_device cu -f lavfi -i \
testsrc=s=1920x1081,format=yuv420p -vf hwupload -c:v hevc_nvenc \
-vframes 1 -y <OUTPUT>
```

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
(cherry picked from commit 3f6bf150cb)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 17:41:14 +02:00
Niklas Haas 584952257a avfilter/vf_scale_cuda: fix inverted downscaling check
Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit 6baf561303)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:57:01 +02:00
Niklas Haas 1f463e44dc avfilter/vf_scale_cuda: allocate inter buffer with correct subsampling
Since the input and output format can differ (e.g. 444 -> 420), we need to
reference the correct subsampling for the partially applied filter.

Keep track of this in the CUDATex itself.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit 01972b4f85)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:56:38 +02:00
Niklas Haas 578c2dbf1d avfilter/vf_scale_cuda: allocate intermediate buffer directly
Instead of going via an AVFrame at all. This will allow us to fix the
intermediate chroma plane size for split downscaling.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit 420a9e90b8)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:56:12 +02:00
Niklas Haas 1166148417 avfilter/vf_scale_cuda: use persistent intermediate CUDATex
Instead of re-creating this object every frame.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit e79e9f06ba)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:55:48 +02:00
Niklas Haas b7d139be74 avfilter/vf_scale_cuda: defer buffer allocation to setup_filters()
At this point, s->hwctx and CudaFunctions * are available.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit 4289a29bb0)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:55:10 +02:00
Niklas Haas c69542aa9b avfilter/vf_scale_cuda: introduce CUDATex and mapping helper
I want to disentangle the internal logic from AVFrame, because some
intermediate states (e.g. for partially subsampled chroma with simultaneous
scaling) may not directly map to a valid AVPixelFormat.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit fef976b197)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:54:37 +02:00
Niklas Haas 45179413ee avfilter/vf_scale_cuda: add fail: label (cosmetic)
Make the next commit a bit easier to review.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit 61750318db)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:54:12 +02:00
Niklas Haas eac505e3e8 avfilter/vf_scale_cuda: eliminate redundant context push/pop
This is already done by cudascale_filter_frame().

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit 0c3f04a97c)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:53:50 +02:00
Diego de Souza 90b5fc8479 avfilter/cuda: support P012/P212 and MSB 4:4:4 in scale/transpose/thumbnail
NVDEC and CUVID now output AV_PIX_FMT_P012 (12-bit 4:2:0), AV_PIX_FMT_P212
(12-bit 4:2:2) and AV_PIX_FMT_YUV444P10MSB / AV_PIX_FMT_YUV444P12MSB
(10/12-bit 4:4:4) for high-bit-depth content, but these CUDA filters
rejected the formats in their supported-format lists, breaking pipelines
such as "-hwaccel cuda ... -vf scale_cuda" on 12-bit input.

These formats use 16-bit sample storage, and the filters select their CUDA
kernel by byte-storage size and plane layout, not by the number of valid
bits, so they can reuse the existing 16-bit kernels:

- scale_cuda: P012/P212 -> "semiplanar16", YUV444P10MSB/YUV444P12MSB ->
  "planar16".
- transpose_cuda: the ushort/ushort2 kernels are chosen from the pixel
  descriptor (byte size + channel count); just allow the new formats.
- thumbnail_cuda: P012 reuses the P010/P016 path and the MSB 4:4:4 formats
  reuse the YUV444P16 path; P012 is added to the 4:2:0 chroma-histogram
  scaling as well. (thumbnail has no 4:2:2 path, so P212 is not added.)

The CUDA deinterlacers (bwdif_cuda, yadif_cuda) already accept any format
with <= 2 bytes per sample and <= 2 channels, so they need no change. The
8-bit-only filters (overlay_cuda, pad_cuda, bilateral_cuda, chromakey_cuda,
colorspace_cuda) do not support high bit depths and are left untouched.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
(cherry-picked from commit df94900c98)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:53:21 +02:00
Niklas Haas 93aeb8edd3 avfilter/vf_scale_cuda: re-indent after previous change
Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit 9420146e6d)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:52:38 +02:00
Niklas Haas c9fc3f79d0 avfilter/vf_scale_cuda: add use_filters option
This may be faster or slower than the existing specialized kernels,
so I opted not to prefer it by default. I also deliberately didn't expose
additional filter function capabilites yet.

The main motivating reason here is to get correct anti-aliasing behavior
when downscaling, which is currently completely broken.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit 5d0748243f)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:52:14 +02:00
Niklas Haas f99a022cbf avfilter/vf_scale_cuda: add generic 1D filter kernel
This can be useful for any sort of separable filtering with arbitrary
weights.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit 469281fa50)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:51:52 +02:00
Niklas Haas d215ba76a0 avfilter/vf_scale_cuda: generalize kernel signature to accept weights
Ignored for now by the existing fixed function kernels.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit d98cc462f6)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:51:32 +02:00
Niklas Haas 6d00e599fd avfilter/scale_filters: add internal copy of libswscale/filters.c
Useful for GPU-based filters, which may also need to compute filter weights.
Since we cannot cross-link to internal functions, we need to recompile this
helper inside libavfilter.c.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit b400791442)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:51:11 +02:00
Niklas Haas 53a987a274 swscale/filters: add ability to set a virtual output size
Odd-size luma planes are not exact multiples of the chroma plane; but the
sample grid is still matched as though it were. We need to account for this
when translating a luma sample to the corresponding chroma sample coordinates.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit fa1ca69a8b)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:50:44 +02:00
Niklas Haas f866705d4d swscale/filters: add option for adding an input pixel offset
This is needed for chroma subsampling, which requires a different filter
offset for chroma subsamples (according to the frame's chroma location).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry-picked from commit 8215e9bbea)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 15:49:48 +02:00
Niklas Haas 792cde9879 swscale/filters: write new filter LUT generation code
This is a complete rewrite of the math in swscale/utils.c initFilter(), using
floating point math and with a bit more polished UI and internals. I have
also included a substantial number of improvements, including a method to
numerically compute the true filter support size from the parameters, and a
more robust logic for the edge conditions. The upshot of these changes is
that the filter weight computation is now much simpler and faster, and with
fewer edge cases.

I copy/pasted the actual underlying kernel functions from libplacebo, so this
math is already quite battle-tested. I made some adjustments to the defaults
to align with the existing defaults in libswscale, for backwards compatibility.

Note that this commit introduces a lot more filter kernels than what we
actually expose; but they are cheap to carry around, don't take up binary
space, and will probably save some poor soul from incorrectly reimplementing
them in the future. Plus, I have plans to expand the list of functions down
the line, so it makes sense to just define them all, even if we don't
necessarily use them yet.

Backported-from: 475b11b2e0

Since this depended on changes to the public swscale API, I have instead
added the necessary enums/defines to filters.h itself for now.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-29 15:31:21 +02:00
Niklas Haas dba917bab5 fftools/ffmpeg_demux: only throttle readrate on the slowest stream
If streams are badly interleaved, then the readrate logic can end up
accumulating an ever-growing lag. Rather than looping over each stream
and sleeping for each stream individually based on the local DTS and lag
logic, pull the sleep out of the loop and only sleep once based on the
furthest-behind stream (i.e. the stream contributing the lowest sleep
duration).

To reproduce:

$ ./ffmpeg -re -i fallbeatcaptiontest.mp4 -c copy -f null -t 10 -

Before this commit, this would run at ~0.7x and accumulate an infinitely
growing lag in one stream. After this commit, both streams run at ~1x as
expected, after an initial burst period due to the bad (1s granularity)
interleaving.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit de6bcf5c05)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 12:34:07 +02:00
Niklas Haas 9193beee0d fftools/ffmpeg_demux: remove unused variable
This is a dead assignment except on a single branch, so just define it
locally.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit e7be06c8bd)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 12:34:07 +02:00
Niklas Haas eb98bef9d2 fftools/ffmpeg_demux: skip finished/unstarted streams in readrate_sleep()
This shouldn't affect the actual behavior, as the initialization of ds->dts
(implicitly zero'd) and the previous calculation of stream_ts_offset
guarantees that the `if (pts <= stream_ts_offset) continue;` branch fires.

Mainly a minor clarification of the code for the upcoming refactor.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 5c877416a5)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 12:34:07 +02:00
Michael Niedermayer 38b88335f9 Bump for 8.1.2
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 04:33:35 +02:00
Michael Niedermayer 241723a2ac Changelog: update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 04:09:47 +02:00
Michael Niedermayer b8ae2fb714 swscale/x86/rgb_2_rgb: fix uyvytoyuv422 overwrite on odd width
uyvytoyuv422 converts packed UYVY, whose macroblocks are pixel pairs, and
the SIMD code only handled even widths. On an odd width the trailing half
macroblock made the kernel write past the end of the Y/U/V destinations:
the AVX512ICL masked tail dropped the odd pixel and the fall-through
re-entered the SIMD loop, writing a full mmsize*2 chunk past the planes
(127 bytes of Y, 63 of U and 63 of V); the sse2/avx/avx2 scalar tail
wrote one byte past the Y plane.

Process only whole pairs and emit the trailing odd column from a small
per-row epilogue that matches uyvytoyuv422_c (ydst[w-1] = src[2w-1],
udst[cw-1] = src[2w-2], vdst[cw-1] = src[2w]).

All four SIMD variants are now bit-exact with the C reference for even and
odd widths and no longer overwrite the destination. Verified on AVX512ICL
hardware (Ryzen 9 9950X) with checkasm.

Found-by: Claude (Anthropic). Human-verified and reported by Omkhar Arasaratnam <omkhar@linkedin.com>.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 21782b7b31)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 04:08:30 +02:00
Michael Niedermayer 86590257a5 swscale/aarch64: fix uyvy/yuyv to yuv420p/yuv422p on odd width
interleaved_yuv_to_planar, shared by uyvytoyuv422, uyvytoyuv420,
yuyvtoyuv422 and yuyvtoyuv420, only handled even widths. The packed
UYVY/YUYV macroblocks are pixel pairs and the trailing half macroblock of
an odd width was mishandled:

- the slow path (width <= 31) decrements its pixel counter by two from an
  odd value, so it never reaches zero and the loop runs far past the line,
  overwriting the destination (observed as a crash in checkasm);
- the fast path (width >= 32) shifts the tail pointers back by width-32 and
  reprocesses an overlapping, misaligned tuple, producing wrong samples and
  dropping the last chroma column.

Process only whole pixel pairs and emit the trailing odd column from a
per-line epilogue that matches the C reference: for yuv422 one Y, U and V
sample; for yuv420 the Y of both lines of the pair with the chroma averaged
across them, and luma only for the final line when the height is odd. The
empty even part (width 0 or 1) is guarded so the slow path no longer enters
its run-past loop.

All four variants are now bit-exact with the C reference for even and odd
widths. Verified with checkasm under qemu-aarch64.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a554d0aa8a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 04:08:30 +02:00
Bogdan Lisman f7bbcb91b7 avcodec/snowenc: fix SIGFPE in get_dc() when a block lies outside the plane
get_dc() divides the accumulated, OBMC-weighted DC by aa, the sum of the
squared OBMC weights taken over the in-plane pixels.  When an OBMC block
falls entirely outside the plane - e.g. a tiny chroma plane after mcdeint
splits a frame into fields - no pixel contributes, aa stays 0 and the
ROUNDED_DIV() divides by zero (SIGFPE).  ab is 0 in exactly the same case,
so the result degenerates to 0; return it directly.

Reproducible with the GPL mcdeint filter in slow/extra_slow mode, e.g.

    ffmpeg -f lavfi -i testsrc=s=128x2 -vf mcdeint=mode=slow -f null -

Add a self-contained lavfi-based FATE regression test for the slow mode,
which previously crashed and is therefore not covered by the existing
sample-based fast/medium tests.

Fixes trac ticket #7779.

Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
(cherry picked from commit a62d996927)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 04:08:30 +02:00
Michael Niedermayer 8c2e27e7bc avcodec/snowenc: fix out-of-bounds OBMC read in get_dc() for narrow planes
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 30c6667dad)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 04:08:30 +02:00
Aditya Banavi 4d786a8648 avformat/tls_gnutls:fix crash when connecting to peer
When ffmpeg whip client takes up dtls_active role when using gnutls,
it tries to connect to the server over udp and intermittently crashes.
This is because s->host is NULL, and ffmpeg is in ice controlling mode.
The gnutls api - gnutls_server_name_set() crashes if the hostname is NULL.

This commit assigns valid value to s->host in such scenarios.

Signed-off-by: Aditya Banavi <adityabanavi@gmail.com>
(cherry picked from commit 28b92b9b2e)

The upstream fix calls ff_tls_parse_host(), which was introduced after this
branch point by commit df3511db5bdf; its host-parsing is inlined here rather
than backporting that refactor.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 17:52:37 +00:00
Michael Niedermayer d82bcad879 Changelog: update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 19:51:36 +02:00
Michael Niedermayer ad3e1ef726 libavcodec/jpeg2000htdec: remove trailing whitespace
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 19:49:27 +02:00
Romain Beauxis 68c4d7ec8c libavdevice/alsa.c: fix NULL pointer dereference
(cherry picked from commit 82d7e375f1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 06:10:02 +02:00
Leo Izen 3c0b18a3a6 avcodec/libjxlenc: check orientation tag metadata before reading
We need to check that entry->count is nonzero and that entry->type is
AV_TIFF_SHORT before reading from the buffer, in case a maliciously
constructed IFD uses a zero-count or an unusual type (e.g. IFD) for it.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
(cherry picked from commit 05b5add006)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 06:05:42 +02:00
Franciszek Kalinowski cb112ece1c avformat/icecast: reject CR/LF in metadata header values
Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.

(cherry picked from commit 99e1ecca36)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 06:01:29 +02:00
Andreas Rheinhardt 269201a990 avfilter/avf_showspectrum: Fix allocation check
If s->stop is set, the return value would be overwritten
before being checked. This bug was introduced in the switch
to AV_TX in 014ace8f98.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 0992c19c30)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 05:59:45 +02:00
bird 5c56b48dbe avformat/sctp: add size check in sctp_read() matching sctp_write()
Commit 5b98cea4 added a size < 2 guard to sctp_write() to prevent
out-of-bounds access when max_streams is enabled, but the identical
pattern in sctp_read() was not addressed.

When max_streams is non-zero, sctp_read() passes (buf + 2, size - 2)
to ff_sctp_recvmsg(). If size < 2, size - 2 wraps to a large value
on the implicit cast to size_t in the callee.

Add the same guard.

Signed-off-by: bird <6666242+bird@users.noreply.github.com>
(cherry picked from commit 5c3602abaa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 05:52:32 +02:00
Osamu Watanabe b94b712611 avcodec/jpeg2000: Fix undefined behavior on ROI shift-up
(cherry picked from commit 8490363634)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 05:49:18 +02:00
Lynne e33bbfbee6 aacdec_usac_mps212: reject reserved freq_res value
(cherry picked from commit 7c79c79a50)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 05:45:35 +02:00
Gil Portnoy f9d7f434c0 avcodec/aac/aacdec_usac_mps212: Off-by-one bounds check in ff_aac_ec_data_deci()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

No testcase, the check seems redundant

(cherry picked from commit 8b9851b005)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-16 05:41:47 +02:00
Michael Niedermayer 29616f5919 Update for 8.1.2 2026-06-15 23:59:22 +02:00
Bogdan Lisman 223764a43e avcodec/snowenc: fix out-of-bounds memcpy in get_block_rd() for narrow planes
For an edge block, get_block_rd() copies the full-OBMC-weight central
region directly from cur[] into the reconstruction.  It moved one
boundary to block_w/block_h but overwrote the in-plane clip (x0/x1/y0/y1
computed earlier from the plane size) instead of intersecting with it.
When a plane is narrower than block_w - e.g. a tiny field/chroma plane
produced by the mcdeint filter - the right-edge case left x0 = block_w
while x1 stayed clipped to w - sx < block_w, so x1 - x0 became negative
and was passed to memcpy() as a huge size_t, crashing with SIGSEGV.

Intersect the moved boundaries with the existing clip so the copy region
stays inside the plane and the memcpy length can never be negative.

Reproducible with the GPL mcdeint filter in slow/extra_slow mode, e.g.

    ffmpeg -f lavfi -i testsrc=s=5x32 -vf mcdeint=mode=slow -f null -

This is a separate crash from the get_dc() SIGFPE (ticket #7779) reached
through the same iterative_me() path.  Add a lavfi-based FATE regression
test.

Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
(cherry picked from commit 1168447626)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:25 +02:00
Bogdan Lisman 213b6561ba avutil/eval: apply unary sign to print, squish, gauss and lerp
The leading sign of a (sub)expression is stored as +-1 in each node's
value field (parse_factor) and every other function multiplies its
result by it. print, squish, gauss and lerp ignored it, so e.g.
-print(1) evaluated to 1 instead of -1 and -gauss(0) to 0.398942
instead of -0.398942, while -1*print(1) was correct.

Fixes: ticket #9833
Reported-by: Player701
Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
(cherry picked from commit 3d1d546f70)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:24 +02:00
Michael Niedermayer b9dc787d28 avcodec/cbs_av1_syntax_template: reset seen_frame_header on sequence
headers

With this change CBS and the decoder appear to be in sync.

Fixes: division by 0

Fixes: 501794431/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-4792576644546560
Fixes: 501898692/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-4772278394224640
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 fd290e2fcd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:24 +02:00
Michael Niedermayer b6fcd2919d avfilter/convolution: compute user matrix products in unsigned
Fixes: integer overflow

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 44d082edc8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:24 +02:00
Michael Niedermayer 55db63567d avformat/mpegts: use av_fast_realloc() for prg
Fixes: Timeout
Fixes: 514855073/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTS_fuzzer-5074757044469760
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 f7e6a8ade5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:24 +02:00
jiale yao af681f61b7 avfilter/avf_showcwt: fix DIRECTION_DU EOF fill clearing the wrong rows
Fixes: out of array read

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0d0eadd8ed)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:24 +02:00
Michael Niedermayer 68a3f37058 avfilter/avf_showcwt: fix DIRECTION_RL EOF fill clearing the wrong columns
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5f13df1b51)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:23 +02:00
Michael Niedermayer 8db78165b3 avfilter/avf_showcwt: avoid undefined float to int conversion of nb_consumed_samples
Reproduced with:
ffmpeg -f lavfi -i "sine=frequency=440" -filter_complex \
 "[0:a]showcwt=size=32x32:deviation=0[v]" -map "[v]" -f null -

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b276ac07e8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:23 +02:00
Michael Niedermayer 5541caa9d6 avfilter/avf_showcwt: fix out of array read in compute_kernel
Reproduced with a small output (e.g. size=2x2) under ASan.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d133b4a231)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:23 +02:00
Michael Niedermayer 48cdd6b6aa avfilter/v360: compute remap table offsets in 64bit
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a55a8c9a68)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:23 +02:00
Michael Niedermayer 3c51be6c26 avfilter/v360: reject out-of-range dimensions
Fixes: integer overflow

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fd6b3fa423)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:23 +02:00
Michael Niedermayer 0e43e30cda swresample/x86/resample: write only int16 in the int16 resampler
The resample asm code as it is currently handles 1 sample at a time

The asm code should be redesigned and handle more than 1 sample at a
time. That is the whole purpose of SIMD. There is also multiple samples
available that need identical handling like from several channels or
similar handling from other points in time.

Such redesign would make the resampler faster and would change the
requirements of padding and maybe memory layout. So it seems simpler
to just avoid overwriting in the asm as it is today than to have
the allocation handle specific overallocation for asm code that
ideally should be redesigned

Fixes writing 16bits over the end of the array

This is an alternative fix for https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23053

Found-by: Ivan Grigorev <ivangrigoriev@meta.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4171581953)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:23 +02:00
jiale yao faa81d0b18 avformat/rtpenc_amr: Check input size
Fixes: heap buffer overflow

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 71478d1165)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:22 +02:00
Scott Boudreaux 733cce258b swscale/ppc: fix ASAN stack-buffer-overflow in yuv2planeX
Fix two buffer overreads in the PowerPC yuv2planeX SIMD paths
that cause daily FATE checkasm-sw_scale ASAN failures on both
ppc64 (G5, altivec) and ppc64le (POWER9, VSX):

1. VSX LOAD_FILTER: vec_vsx_ld(joffset, filter) reads 16 bytes
   at the given byte offset.  When joffset >= filterSize*2 - 14
   (e.g. joffset=30 for filterSize=16), this reads up to 14 bytes
   past the 32-byte filter array.  Fix by replacing the vector
   load with vec_splats(f[j]) which only reads the single int16_t
   element needed (the result is splatted to all lanes anyway).

2. GET_LS look-ahead overread: yuv2planeX_8_16 calls
   yuv2planeX_8 twice per filter tap.  Each call's GET_LS macro
   speculatively loads the next 16-byte vector for pipelining.
   On the second call, this look-ahead reads 16 bytes past the
   last valid source element.  Fix by tightening the SIMD loop
   bound from (dstW - 15) to (dstW - 23), ensuring the farthest
   speculative load stays within src[j][0..dstW-1].  The scalar
   fallback handles the remaining 16-23 trailing pixels.

The ASAN reports from FATE:
  ppc64 (altivec): stack-buffer-overflow in yuv2planeX_8_16_altivec
                   at swscale_ppc_template.c:56
  ppc64le (VSX):   unknown-crash in yuv2planeX_8_16_vsx
                   at swscale_ppc_template.c:52

Signed-off-by: Scott Boudreaux <scott@elyanlabs.com>
(cherry picked from commit d4673a97ac)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:22 +02:00
Scott Boudreaux 9825a8af1d swscale/ppc: fix LOAD_FILTER overread in VSX path
Part of the yuv2planeX ASAN fix - replace vec_vsx_ld with vec_splats
to avoid reading past the filter array.

Signed-off-by: Scott Boudreaux <scott@elyanlabs.com>
(cherry picked from commit dddc703cc1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:22 +02:00
Michael Niedermayer 874de02d87 avcodec/sanm: reject codec37 frames taller than the allocated buffer
No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ab5043f055)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:22 +02:00
Michael Niedermayer 79b1d1e1aa avcodec/sanm: reject codec47 frames taller than the allocated buffer
Fixes: 513469519/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5024854725427200
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 b2695bcbb3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:22 +02:00
Michael Niedermayer ae9dd27979 avfilter: use ff_slice_pos() for per-slice boundary computation
This is a behavior preserving change for all non-overflowing cases.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f7368f97b9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:21 +02:00
Michael Niedermayer 2cf7bb6089 avfilter: add ff_slice_pos() helper for slice boundaries
Slice based filter workers compute their per-thread row/sample/channel
boundaries as total * jobnr / nb_jobs. The total * jobnr product is
evaluated in int and overflows signed int for large dimensions and many
slice threads, before the division by nb_jobs brings it back in range.

(cherry picked from commit 218b4771a3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:57:21 +02:00
James Almer 1034b144ff avformat/iamf_writer: reject muxing PCM streams
Supporting PCM streams requires API changes present in newer releases that
can't be backported, so don't create invalid files.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-14 10:06:31 -03:00
Michael Niedermayer 7aecd49777 avfilter/estdif: avoid signed overflow in slice boundary calculation
deinterlace_slice() computed per-thread row boundaries with int
multiplication height * (jobnr + 1). With a tall frame and many filter
threads the product overflows signed int before the division by nb_jobs.

Use int64_t for the intermediate product before converting back to int
row indices.

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 200e0cba67)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:08 +02:00
Michael Niedermayer 352f6dfbe1 swscale: support sliced input with cascaded scaling contexts
Previously scale_cascaded() assumed the whole source frame arrived in a
single sws_scale() call, and the dispatcher only routed full-frame calls
to it. A partial input slice fell through to ff_swscale() on the parent
dispatcher context, whose scaler state (c->desc) is never initialized in
cascade mode, causing a NULL dereference / crash.

Top-down sliced output is bit-exact with full-frame scaling; bottom-up
matches swscale's pre-existing (non-cascade) slice behaviour for
subsampled intermediate formats.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 10f2abc41f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:08 +02:00
Michael Niedermayer 2dfc8f3919 avformat/rtspdec: bound Content-Length in the ANNOUNCE handler to SDP_MAX_SIZE
Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.

(cherry picked from commit 6049b4d7bc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:07 +02:00
James Almer 84087839af avcodec/cbs_h266_syntax_template: reject subpic info with res_change_in_clvs
Found-by: Anthony Hurtado
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0cf9169c85)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:07 +02:00
Michael Niedermayer 4b32214900 avcodec/misc4: Check nb channels
Found-by: Forgejo Fairy
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7b717fe50d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:07 +02:00
Michael Niedermayer 52af067ac2 avcodec/rv10, rv34: check init_get_bits8() before RealVideo bit access
Found-by: Samarth Kumbla <samarthk@cantina.security>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0c662529f6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:07 +02:00
haoyuLiu 8280545165 avformat/http: reject request-line tokens not terminated by whitespace
Fixes out of array access

Found-by: Cloud-LHY (@Clouditera-lhy) / VulnForge Security Research Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dd9083cb89)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:07 +02:00
Michael Niedermayer 31a192f5dd avformat/mov: reject out of range ispe dimensions, avoid overflow summing HEIF tile dimensions
ispe width/height are read as uint32 but stored in int HEIFItem fields;
values above INT_MAX became negative, and read_image_grid() summing such
widths into coded_width overflowed int:
libavformat/mov.c:10404:33: runtime error: signed integer overflow: -2147483647 + -2147483647 cannot be represented in type 'int'

Also accumulate the grid tile dimensions and running offsets in 64bit
and validate the totals, as up to 256 tile columns of individually
valid widths can still overflow int.

Found-by: 51511
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2cc7b87bdb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:06 +02:00
David Korczynski a4152636b8 avcodec/agm: validate actual src_y against prev plane in decode_inter_plane
Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4527854281)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:06 +02:00
David Korczynski a0e7ee5468 avformat/dhav: Fix second integer overflow in get_duration()
Fixes: ada-2-poc.dhav

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects, and I am from Ada Logics helping validate the found issues and report to maintainers.
(cherry picked from commit 50e65074f5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:06 +02:00
Zhen Yan ee25d8ec07 fftools/ffmpeg_dec: deep-copy subtitle_header to fix use-after-free
Found-by: Zhen Yan
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fa391e90fb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:06 +02:00
Michael Niedermayer e3ce59ba68 avcodec/hevc/ps: Check window parameters
Fixes: signed integer overflow: -1094995529 * 2 cannot be represented in type 'int'
Fixes: 484567435/clusterfuzz-testcase-minimized-ffmpeg_dem_HXVS_fuzzer-5628836988649472

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 82f097c825)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:06 +02:00
Michael Niedermayer bcee8b9f0b avcodec/hevc/ps: Factor window reading out
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8c868a1fd2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:05 +02:00
David Korczynski e3d0fca1bb avcodec/truespeech: reject iterations count whose * 240 product overflows 32-bit
Found-by: Anthropic agents; validated and reported by Ada Logics.
Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d30dead35e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:05 +02:00
Robert Nagy 101bb4c249 libavcodec/options_table: gamma22 and gamma28 aliases
(cherry picked from commit 06e11c87c6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:05 +02:00
David Korczynski 797cbc7413 avcodec/on2avc: reject subframe count whose * SUBFRAME_SIZE product overflows 32-bit
Found-by: Anthropic agents; validated and reported by Ada Logics.
Signed-off-by: David Korczynski <david@adalogics.com>
(cherry picked from commit 331b3e9dea)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:05 +02:00
haoyuLiu 3a9a2f13de avfilter/zmq: initialize send_buf before shared cleanup on parse failure
Found-by: VulnForge Security Research Team
Reported-by: Cloud-LHY <haoyuliu@clouditera.com>
(cherry picked from commit 6028720d70)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:05 +02:00
Michael Niedermayer 849ed5f176 avcodec/adpcm: fix signed integer overflow in get_nb_samples()
Fixes: signed integer overflow: 314572800 * 8 cannot be represented in type 'int'

Tighten the guard to INT_MAX/14, which covers the largest expansion
factor used in the function currently.

Found-by: Jiale Yao <19888972804@163.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 04e2341056)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:05 +02:00
Michael Niedermayer e15ede87a3 avformat/matroskadec: avoid signed overflow in DASH cue time differences
Fixes: 493466409/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6150181551931392
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 0a8d961388)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:04 +02:00
David Korczynski 417061746d avcodec/fastaudio: reject subframes count whose * 256 product overflows 32-bit
fastaudio_decode() computes
    subframes = pkt->size / (40 * channels);
    frame->nb_samples = subframes * 256;
both as 32-bit signed multiplications. When pkt->size is large enough
to make subframes >= 2^24, the second multiplication overflows the
signed int range and frame->nb_samples wraps to a small value.
ff_get_buffer() then sizes the audio plane for that wrapped sample
count, while the decoder loop at line 152 still iterates the full
(unwrapped) subframes count, performing a 1024-byte memcpy per
subframe per channel. The 27th iteration (or first iteration with
nb_samples=0) writes one byte past the per-plane allocation,
yielding the ASan heap-buffer-overflow WRITE at libavcodec/fastaudio
.c:171 reported as ANT-2026-03891.

Reject the subframes value whose *256 product would overflow before
performing the multiplication. The bound INT_MAX / 256 (= 8388607)
keeps the existing two's-complement semantics of every reachable
input and rejects only the configurations that would have wrapped.

Reproducer: a crafted AVI declaring one mono audio chunk of
671_088_680 bytes (sparse) with the decoder forced via
'ffmpeg -c:a fastaudio -i evil.avi'.

Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1e9984772b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:04 +02:00
Michael Niedermayer 31be6491d2 avcodec/vc2enc_dwt: avoid signed overflow in the 9/7 DWT lifting
Fixes: 490488944/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC2_fuzzer-5310290362433536
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 5f91556215)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:04 +02:00
Michael Niedermayer cb55da3768 avcodec/vc2enc_dwt: avoid signed overflow in the 5/3 and Haar DWT
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7c7ca349bc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:04 +02:00
Michael Niedermayer d4175fe20d avformat/dashdec: Fail with any inner stream count being 0
Fixes: ada-3-poc.mpd

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects, and I am from Ada Logics helping validate the found issues and report to maintainers.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b99c6fc8c3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:04 +02:00
Michael Niedermayer d5ac401940 avcodec/mjpegdec: require progress in AVRn interlaced field loop
Fixes: Timeout
Fixes: 500554625/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MEDIA100_fuzzer-5094103347167232
Fixes: 511253447/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-5780722463080448
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 b355200263)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:03 +02:00
Michael Niedermayer 08597a382e avcodec/mwsc: do not dereference a missing reference frame
Fixes: 493841393/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MWSC_fuzzer-5079884677578752
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 ba825ce85f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:03 +02:00
Michael Niedermayer b77508937f avcodec/misc4: reject invalid sample rate
Fixes: AVERROR_BUG

Fixes: 493055111/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MISC4_fuzzer-5752676962074624
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 32eb07bb83)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:03 +02:00
Michael Niedermayer 9006342109 swscale/output: avoid signed overflow in yuv2rgba64_1 alpha
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0ab097fb34)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:03 +02:00
Michael Niedermayer 28c0fda2cd swscale/output: avoid signed overflow in yuv2rgba64_full_1 alpha
Fixes: 493055112/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5823995319746560
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 ad84fc9b7d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:03 +02:00
Michael Niedermayer 6a25c9adfc tools/target_dem_fuzzer: do not exit on io_buffer allocation failure
Failure to allocate a randomly sized buffer should not count as a anomaly in the fuzzer
there is nothing to fix in that case

Fixes: 490112574/clusterfuzz-testcase-minimized-ffmpeg_dem_TMV_fuzzer-6600485921685504
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 2cce6ad030)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:03 +02:00
Michael Niedermayer 46a66b2ccc avformat/gxfenc: Check timecode and propagate error
Fixes: ./ffmpeg   -f lavfi -i testsrc=duration=0.1:size=720x480:rate=30   -c:v mpeg2video -frames:v 1   -metadata timecode="999999999:00:00:00"   -f gxf output.gxf

Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0ea090e09f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:02 +02:00
Michael Niedermayer 5da47b2752 swscale/rgb2rgb_template: use unsigned for <<24
Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dbe78ffdb8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:02 +02:00
Michael Niedermayer e61c9faabd avformat/iamf_parse: bound substream count by remaining OBU size
also check for nb_substreams == 0

Fixes: 472641765/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6390897173659648
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 fe2dabbbf4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:02 +02:00
Michael Niedermayer a6740266e0 avformat/matroskadec: bound TRACKENTRY parsing by max_streams
After the fix the reproducer finishes in 43 ms instead of OOM-ing at the
2 GB limit. Legitimate .mkv/.webm fate samples still parse cleanly.

Fixes: 471604245/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6662979358883840
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 c7e0bac050)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:02 +02:00
Anthony Hurtado b7f3a666ca avcodec/diracdec: fix heap buffer overflow in edge_emu_buffer
Fixes: poc_dirac_v2_*
(cherry picked from commit 495b402f27)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:02 +02:00
Michael Niedermayer 363435f591 avformat/rtmppkt: Check recursion depth
Based on flvdec.c

Fixes: out of array access

Found-by: Xueqing
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 92804c9e25)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:01 +02:00
Michael Niedermayer ea01723885 avcodec/tdsc: propagate max_pixels to the JPEG tile decoder
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 47f3996bdd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:01 +02:00
Michael Niedermayer 36beb07e57 avcodec/imm5: propagate max_pixels to the H264/HEVC sub-decoders
Fixes: 501794495/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IMM5_fuzzer-5192457796255744
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 c1d3e8c46f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:01 +02:00
Michael Niedermayer e569af76bc avcodec/cri: propagate max_pixels to the JPEG tile decoder
Fixes: 489941776/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-4845035614175232
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 cdba2d76dc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:01 +02:00
Michael Niedermayer 5ff3913787 avcodec/jpeglsdec: only apply color transform to decoded rows
Fixes: Timeout
Fixes: 503996733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_DEC_fuzzer-4948713016721408
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 3669a742dd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:01 +02:00
David Korczynski cbc62ea2c8 avcodec/adpcm: require block_align to be a multiple of channels in ADPCM_PSXC init
The ADPCM_PSXC block loop in adpcm_decode_frame() (libavcodec/adpcm.c:
2770) iterates 'block < avpkt->size / block_align' times and, for
each block, consumes
    channels * (1 + (block_align - 1) / channels)
input bytes via the *unchecked* bytestream2_get_byteu() reader. The
loop divides avpkt->size by block_align, so the loop bound is sound
only when the per-block consumption equals block_align — i.e. when
block_align is an exact multiple of channels. For any other
combination (e.g. block_align=9 with channels=8), each block consumes
more than block_align bytes; iterating avpkt->size/block_align
blocks then walks the input bytestream past avpkt->data +
avpkt->size, producing the heap-buffer-overflow READ at
libavcodec/bytestream.h:99 reported as ANT-2026-04052.

adpcm_decode_init() previously only enforced 'channels > 0' and
'block_align > 0' for PSXC. Tighten the init check to additionally
require 'block_align % channels == 0', which is the precise
invariant the decode loop depends on.

Reproducer: a crafted WAV header declaring channels=8, block_align=9
with the decoder forced via 'ffmpeg -c:a adpcm_psxc -i evil.wav'.

Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
(cherry picked from commit 6d8f7882ae)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:01 +02:00
jiale yao 9906b38d1d avfilter/avf_showcwt: fix out-of-bounds read in du scroll
Fixes: out of array access
Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e8031e5b9a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:00 +02:00
Michael Niedermayer 41e1b6d817 avfilter/f_ebur128: avoid signed-int wrap when sizing per-channel cache
Fixes: integer overflow
Fixes: out of array access

Found-by: Claude (Anthropic), reported by Omkhar Arasaratnam <omkhar@linkedin.com>.
(cherry picked from commit 537e87e3c2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:00 +02:00
Omkhar Arasaratnam 89d9ad0345 avformat/mov: cap HEIF ICC profile copies via c*max_streams to bound CPU and memory
Found-by: Claude (Anthropic). Human-verified and reported by
Omkhar Arasaratnam <omkhar@linkedin.com>.
Signed-off-by: Omkhar Arasaratnam <omkhar@linkedin.com>
(cherry picked from commit 711cdae64f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:00 +02:00
Michael Niedermayer a153f5f2fa avcodec/aac/aacdec_usac: reject explicit usacSamplingFrequency of 0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 263374ac7d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:00 +02:00
Michael Niedermayer a8a7a2afa1 avcodec/aac/aacdec_usac: avoid signed overflow in decode_tsd
decode_tsd() computes the binomial coefficient c = C(k, p) incrementally.
this commit makes it less overflow prone

Fixes: 515703905/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_DEC_fuzzer-4890954254581760
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 69c9f1158c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:41:00 +02:00
Michael Niedermayer 2b81143984 avcodec/aac/aacdec: reject decoded frame without a valid sample rate
Later code will turn this into AVERROR_BUG

When returning sample_rate == 0 samples is considered a bug, we have no
nice choice but to error out cleanly

Fixes: assertion failure
Fixes: ffmpeg_AV_CODEC_ID_AAC_DEC_fuzzer crash-0a86d46fef2442b222ee34403c21f7f582ffccb0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e711e60827)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:59 +02:00
Michael Niedermayer 36abe87a0b avformat/iff: check av_get_packet() result in ANIM branch
Fixes: 494958338/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-6265824670449664
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 43f712d917)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:59 +02:00
James Almer b3a15b4ee1 avcodec/cbs_h266_syntax_template: Fix pps_exp_slice_height_in_ctus_minus1 range
Found-by: Claude (Anthropic). Human-verified and reported by Omkhar Arasaratnam <omkhar@linkedin.com>.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bf608f16fd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:59 +02:00
Michael Niedermayer 2834b438ec avfilter/vf_scale: split rational multiply
Fixes: integer overflow in SAR
Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 97ea5da419)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:59 +02:00
Michael Niedermayer 532063e7ff avcodec/bsf/dts2pts: fix binary tree invariant violation on selective dec_poc
Modifying the keys of a sorted structure, be that a tree or other
can lead to changes in the ordering and undefined behavior.
It can also lead to collisions with existing keys.

All these cases need to be handled unless there is a bug elsewhere
that would prevent them.

Fixes: out of array access
Fixes: 504281984/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-6032368162111488

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 054dffd133)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:59 +02:00
Michael Niedermayer b0570f35cf avfilter/vf_drawtext: Avoid double free in glyph_enu_border_free()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 073c44b8bc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:58 +02:00
Michael Niedermayer 5a409e87b7 avfilter/vf_drawtext: plug error-path leaks in measure_text/draw_text
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 47c503c6a9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:58 +02:00
Michael Niedermayer 734b17cb98 avfilter/vf_drawtext: shape_text_hb() free allocated things on error
Fixes: memleak
Found-by: Fairy

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 77554d85d7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:58 +02:00
Michael Niedermayer 2fd0577bc9 avfilter/vf_drawtext: avoid double-free of aliased FT_Glyph in glyph_enu_free
For glyphs whose source is already in bitmap form (color emoji fonts such
as NotoColorEmoji.ttf), FT_Glyph_To_Bitmap(..., destroy=0) returns the
input pointer unchanged. The result is that glyph->bglyph[idx] aliases
glyph->glyph (and analogously border_bglyph[t] may alias border_glyph).
glyph_enu_free then called FT_Done_Glyph on both, double-freeing the
underlying object.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9efca1d946)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:58 +02:00
Michael Niedermayer 23b50185c6 avfilter/vf_drawtext: don't double-free glyph that has been cached in tree
Reproducer:
  ffmpeg -f lavfi -i color=s=640x120:d=1 \
      -vf "drawtext=fontfile=/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf:\
text='FFmpeg':fontsize=109:fontcolor=white:x=20:y=35" \
      -frames:v 1 out.png

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c51789b052)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:58 +02:00
Michael Niedermayer f80ccca187 avfilter/vf_drawtext: always check pixel_mode == FT_PIXEL_MODE_MONO
The code as written can add such glyphs in the cache so we need to check
glyphs from the cache too.
This should be the most robust and simple solution

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c8c4e2d2a5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:58 +02:00
David Korczynski 0bbf29dee3 avcodec/cook: bound subpacket channel sum against channel count
Fixes: out of array read
Fixes: evil.rm

Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1152139b48)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:57 +02:00
Michael Niedermayer af81aaae76 avcodec/apv_decode: avoid using apv_cbc
Fixes: out of array access
Fixes: evil.apv

Found-by: Claude (Anthropic). Human-verified and reported by Omkhar Arasaratnam <omkhar@linkedin.com>. on 05-20
Found-by: Anthropic agents; validated and reported by Ada Logics. on 05-26
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7a2424eb43)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:57 +02:00
Michael Niedermayer 61218852d1 avformat/mxfdec: Remove unneeded check
size is 16bit only

Found-by: Tomas Härdin
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit aaac0989e6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:57 +02:00
Michael Niedermayer 0cda9f02e7 avformat/ftp: Check string used for RNTO
Found-by: Forgejo Fairy
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4d24cb1c39)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:57 +02:00
Michael Niedermayer bdcec7edb8 avformat/ftp: Check for Telnet IAC characters and other non printable ASCII chars
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 090838497c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:57 +02:00
Franciszek Kalinowski 643048daef avformat/ftp: reject CR/LF in the URL path to prevent FTP command injection
ftp_connect() interpolates the URL path into SIZE/RETR/STOR/CWD/DELE/RMD/RNFR
commands without checking for CR/LF, although it already rejects CR/LF in the
user and password fields. Reject CR/LF in s->path the same way.

Reported and reviewed by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Śmigielski.

(cherry picked from commit 640f32b1b6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:56 +02:00
Michael Niedermayer 27766a8f74 avcodec/jpeg2000dec: Clear header derived variables
Fixes: NULL pointer dereference

Found-by: Oguzhan Akkaya with AFL++ fuzzing (May 2026)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6631bbc5d4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:56 +02:00
Michael Niedermayer 8b45f41791 avcodec/bsf/smpte436m_to_eia608: properly frees stuff on errors in ff_smpte436m_to_eia608_filter()
Fixes: memleaks
Fixes: 501913473/clusterfuzz-testcase-minimized-ffmpeg_BSF_SMPTE436M_TO_EIA608_fuzzer-5607133705207808

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 0834dbed1c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:56 +02:00
James Almer 96f9a6e28c tests/checkasm/crc: retain offset values between calls
Should fix buffer overflows as reported by clang-asan and use of uninitialized
values as reported by valgrind.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 224659360a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:56 +02:00
James Almer 2812a5b8d7 avformat/avc: Adjust get_ue_golomb() to handle 32 bit
Fixes: assertion failure
Fixes: PR-009/bad_extra_idr_only.avi

Found-by: mosskappa
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 93512bc2fd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:56 +02:00
Omkhar Arasaratnam eb588c4f78 avformat/whip: require remote DTLS fingerprint in SDP answer
WHIP relies on the SDP a=fingerprint to bind the peer identity to
the SRTP keying material (RFC 8842 §§ 5.1, 5.3). parse_answer()
walks the SDP body looking for `a=ice-lite`, `a=ice-ufrag:`,
`a=ice-pwd:`, and `a=candidate:` lines and ignores everything else,
including `a=fingerprint`. WHIP intentionally runs the OpenSSL DTLS
backend with s->verify=0 (DTLS-SRTP uses self-signed certs by
design, so a CA chain check would be meaningless); the peer cert is
accepted regardless of identity. The spec's compensating identity
control — verifying the DTLS peer cert against the SDP a=fingerprint
hash — is missing, so the SRTP keys are derived from a session
whose peer identity was never authenticated. Any on-path attacker,
or a malicious WHIP server URL, can substitute their own DTLS
material and the publisher's RTP stream will be encrypted to them.

The full fix is a two-step process:
  (a) Require a=fingerprint to be present in the SDP answer
      (RFC 8842 § 5.3 MUST).
  (b) After DTLS handshake, compute the peer-cert hash and compare
      against the stored fingerprint (RFC 8842 § 5.1 MUST); tear
      down the session on mismatch.
This patch implements step (a) only; step (b) requires plumbing
the cert hash out of dtls_start() through the openssl TLS context
and is left as a follow-up.

Add a remote_fingerprint field to WHIPContext, extract the
a=fingerprint value from the SDP answer in parse_answer(), and
return AVERROR(EINVAL) when it is absent. This raises the bar from
"no fingerprint required" to "any fingerprint required"; the
follow-up patch will raise it again to "fingerprint MUST hash-match
the DTLS peer cert."

Found-by: Claude (Anthropic). Human-verified and reported by
Omkhar Arasaratnam <omkhar@linkedin.com>.
Signed-off-by: Omkhar Arasaratnam <omkhar@linkedin.com>
(cherry picked from commit 7b46c6a2a3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:56 +02:00
Hassan Hany 2196cd43dc avcodec/x86/vorbisdsp: change cmpleps to cmpltps in inverse coupling
Changed the comparison from cmpleps to strictly less than
(cmpltps) to strictly follow the Vorbis spec

Fixes https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21501

(cherry picked from commit 9288681068)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:55 +02:00
Soham Kute 9318eb0a98 avcodec/liboapvenc: derive and validate APV profile from pixel format
(cherry picked from commit 8885116f4d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:55 +02:00
Michael Niedermayer 1c871a90bf avformat/dashdec: bound manifest reloads and fragment-open retries
Mirror the HLS demuxer's max_reload pattern

Reported as a DoS finding by Xueqing. Verified with the supplied PoC
server: a 30s ffmpeg run that previously generated ~10000 requests
without termination now exits in ~100ms after exactly max_reload
fragment-open failures.

(cherry picked from commit 4945e33e98)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:55 +02:00
Franciszek Kalinowski 64fd93e361 avfilter/af_join: fix wrong loop bound in buffer dedup (use-after-free)
try_push_frame() decides whether an input buffer is already tracked by testing
`j == i` (the channel index) instead of `j == nb_buffers`. Once an earlier
channel shared a buffer, nb_buffers falls behind i and a genuinely new buffer is
never referenced, so it is freed while the output frame still points at it.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.

(cherry picked from commit 461fb22053)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:55 +02:00
Diego de Souza 83853cf1e8 avcodec/nvenc: fix compatibility with Video Codec SDK 13.1
NV_ENC_CLOCK_TIMESTAMP_SET was changed in SDK 13.1: countingType was
replaced by countingTypeLSB and countingTypeMSB.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
(cherry picked from commit 0a7c5e507b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:55 +02:00
Omkhar Arasaratnam 86dd0a3adf avformat/mov: validate APV access unit length before passing to decoder
libavformat/mov.c read the APV AU length field directly from the
sample without sanity-checking against the remaining sample size or
a documented maximum. The patch validates that au_size is bounded by
the remaining sample bytes and that the AU envelope (4 bytes plus
au_size) fits inside the declared sample size.

Validate the access unit length at the demuxer boundary so that the
decoder is not handed an attacker-controllable buffer size. Returns
AVERROR_INVALIDDATA on the bound failure with an explicit log line.

Found-by: Claude (Anthropic). Human-verified and reported by
Omkhar Arasaratnam <omkhar@linkedin.com>.
Signed-off-by: Omkhar Arasaratnam <omkhar@linkedin.com>
(cherry picked from commit 387ad6d102)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:54 +02:00
Franciszek Kalinowski d7ceb10bfe avcodec/h264_slice: guard color_frame() against chroma-width underflow
In the >= 9 bit path, color_frame() does
`av_memcpy_backptr(dst + 2, 2, bytes - 2)`. When the effective chroma width
is 1 pixel (bytes == 1) the count becomes -1 and the underlying fill16()
loop runs roughly 2^32 times, producing a heap overflow. The original count
was also wrong in units (pixels rather than bytes); fix that at the same
time so the 2-pixel case still fills both pixels.

Confirmed via a standalone harness reproducing av_memcpy_backptr's fill16
loop with cnt = -1; reaching the call from a crafted H.264 bitstream
requires Hi10P plus a frame_num gap on a frame whose effective chroma width
is 1 pixel, which is hard to express but is reachable via mid-stream SPS
changes. Compiles cleanly; no regressions seen running existing crafted
H.264 PoCs and trivial transcodes.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.

(cherry picked from commit c79dfd29e6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:54 +02:00
Ori Hollander 9516e6900a avcodec/magicyuv: reject slice_height misaligned with chroma vshift
Fixes: poc_magicyuv.avi
Fixes: out of array access

Found-by: Ori Hollander of the JFrog Vulnerability Research team
(cherry picked from commit 374b726ffa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:54 +02:00
Michael Niedermayer e302bafe79 avcodec/magicyuv: Expand the s->interlaced slice-height sanity check
Fixes: poc_magicyuv.avi
Fixes: out of array access

Found-by: Ori Hollander of the JFrog Vulnerability Research team
(cherry picked from commit 5806e8b9f3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:54 +02:00
Michael Niedermayer a991b3e110 avcodec/magicyuv: Fix 1 line MEDIAN slices
No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c23d4da312)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:54 +02:00
Michael Niedermayer 167c14a418 avformat/mxfdec: zero-init Sony MPEG-4 extradata and add padding
Found-by: Calm (AI security-research agent, for John Bradley / Credex)
(cherry picked from commit 8f1769703c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:54 +02:00
Michael Niedermayer e9b3388dcb avformat/soxdec: Check sample_rate for nan
Found-by: iceray-Li
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d2d79dca9a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:53 +02:00
Balling 07d615e903 tests/tiny_ssim: fixed mistake in ssim_c1 calculation
Reporter uses this code in production.

Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
(cherry picked from commit 8cd7465565)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:53 +02:00
Michael Niedermayer 69ca310fb7 avformat/hls: Check TIME-OFFSET value
Fixes: UB with out of range values
Fixes: poc_overflow.m3u8

Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 59094859a8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:53 +02:00
Michael Niedermayer 61ffafe95b avformat/hls: Check url_offset and size
Fixes: integer overflow

Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c2047918e6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:53 +02:00
amhurtado 621d35023a avcodec/prores_raw: reject invalid tile alignment values
Fixes: out of array access

Regression since d8cb567 ("prores_raw: fix tile alignment
issues").

Found-by: amhurtado <amhurtado@pm.me>
Signed-off-by: amhurtado <amhurtado@pm.me>
(cherry picked from commit d3f59f9b7f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:53 +02:00
Michael Niedermayer 16474a560e avformat/ty: check rec_size
Fixes: ada-4-poc.ty

change is based on the suggested fix

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4492ad7228)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:52 +02:00
Dale Curtis 507d8e8284 avformat/ogg: Fix overflow and stale oggvorbis_private values
- Prevent integer overflow when summing header lengths; add bounds check.
- Re-initialize priv->vp with the new stream's extradata once all chained
  stream headers are collected.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
(cherry picked from commit 6e0e13b0bf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:52 +02:00
Franciszek Kalinowski ccae7f536b avformat/rtpenc_xiph: bail out when the max payload size underflows
Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.

(cherry picked from commit 0857141823)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:52 +02:00
Franciszek Kalinowski 88c482d7b7 avformat/rtpenc_aac: reject packets smaller than the ADTS header
When extradata_size == 0, ff_rtp_send_aac() does `size -= 7` to skip the
ADTS header without checking size >= 7. A short packet makes size negative,
and the value is later passed to memcpy() as size_t, reading past the buffer
end. Bail out instead.

The vulnerable branch is not reached when using the built-in AAC encoder
(which always emits extradata), but an application that feeds raw
ADTS-stripped AAC packets through the libavformat RTP muxer can hit it. The
fix is a one-line lower-bound check and compiles/runs cleanly; see audit
PoC for the static analysis and reachable-by-API write-up.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.

(cherry picked from commit a44cae9025)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:52 +02:00
Michael Niedermayer d14ea0d715 avcodec/jpeg2000dec: compute mask in decode_clnpass() like in decode_sigpass()
Fixes: integer overflow

Found by: Jiale Yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 59367afc3d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:52 +02:00
Michael Niedermayer 182bc42768 avformat/flvdec: Check size at the top of the main loop
Fixes: signed integer overflow
Fixes: ffmpeg_flv_read_packet_libavformat_flvdec.c_1900_26.poc

Found-by: iceray-Li
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cc1459ed85)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:52 +02:00
Michael Niedermayer 96d5d4c75d avformat/vividas: fix misaligned access
Fixes: ffmpeg_xor_block_libavformat_vividas.c_134_15.poc

Found-by: iceray-Li
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 84a48165f0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:51 +02:00
Michael Niedermayer 377fb77be3 avformat/mccdec: dont pass NULL to bytestream2_put_buffer()
Fixes: passing NULL pointer

Found-by: iceray-Li
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2bfc7ce3ec)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:51 +02:00
David Korczynski cba36a17af avcodec/g2meet: The stack is EPIC_PIX_STACK_SIZE
Fixes: out of array access
Fixes: ada-5-poc.avi

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects, and I am from Ada Logics helping validate the found issues and report to maintainers.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 989e621bcd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:51 +02:00
Michael Niedermayer 5e1a71ce13 avcodec/h2645_sei: Initialize side data before deallocation
Fixes: use after free
Fixes: poc_hvcc_modified.mp4

Found by: Jiale Yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f435ce22e1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:51 +02:00
David Korczynski cb2f4b4f5f avfilter/boxblur: Fix off by one errors
Fixes: ada-2-poc.mkv

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects, and I am from Ada Logics helping validate the found issues and report to maintainers.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 444f2cf047)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:51 +02:00
David Korczynski d7e1d91762 avformat/assenc: Add the missing parentheses
Fixes: ada-1-poc.mkv

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects, and I am from Ada Logics helping validate the found issues and report to maintainers.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 08d7646abf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:50 +02:00
Thai Duong f966d1eea6 avcodec/diracdec: Enlarge mctmp to cover the worst-case blheight·ybsep + yblen rows, and break the MC loop when no output rows remain
Fixes: ffmpeg_ANT-2026-02842_dirac-mctmp-heap-overflow

Discovered by Claude (Anthropic). Confirmed and reported by Thai Duong (Calif.io).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bbdce45fda)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:50 +02:00
James Almer 874cd67a3c tools/zmqsend: free the AVBprint buffer after using it
Fixes CVE-2026-30999

Fixes: memleak
Found-by: Xinghang Lv
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 144af8f81a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:50 +02:00
Dale Curtis 022642e3ad [Wave] Fix issues with unaligned metadata chunks.
Fixes corruption issues with the sample in this PR.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
(cherry picked from commit 5bbc00c05d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:50 +02:00
Michael Niedermayer bda47c505f avformat/mpegts: Dont assume fc->priv_data is a MpegTSContext
Fixes: out of array access
Fixes: 508365271/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-6219535958212608

Regression since: b9cb948ec1

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 188461be10)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:50 +02:00
Yong Yu 27561c4e39 fftools/graph: Add missing include "libavutil/mem.h" for fftools/graph/graphprint.c
when HAVE_AV_CONFIG_H is defined, include libavutil/mem.h
is skipped in libavutil/common.h.
Need this header file to build successfully.

(cherry picked from commit 9ab345b2d1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:50 +02:00
Michael Niedermayer ce82410ef8 avcodec/cbs_h266_syntax_template: tighten sh_num_tiles_in_slice_minus1 upper bound
Fixes: out of array access

Found-by: Vishal Panchani
Fix suggested by: Vishal Panchani
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b5c7c7d273)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:49 +02:00
Zhao Zhili bcdca173aa avcodec/hevc: limit missing-ref fill to coded planes
generate_missing_ref walked frame->f->data[] until a NULL slot, which
on alpha-video frames extended to data[3] and read
sps->hshift[3]/vshift[3] out of bounds.

The alpha plane is produced by the alpha layer via
replace_alpha_plane; the base decoder path never reads or writes it.
Bound the fill loop by the SPS coded plane count. This both removes
the out-of-bounds shift access and avoids an unnecessary full-frame
memset of the alpha plane.

Fixes: out of array read
Fixes: 500770604/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6157374833623040

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
(cherry picked from commit 3b939ced79)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:49 +02:00
Dale Curtis 56e8d17d9b avformat/mov: Fix negative index given to can_seek_to_key_sample()
The potentially negative return value of av_index_search_timestamp()
wasn't being handled before passing it to can_seek_to_key_sample().

Found by Wongi Lee (@_qwerty_po) of Theori with Xint Code,
Jungwoo Lee (@physicube).

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
(cherry picked from commit 256d93413f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:49 +02:00
João Neves 56f758b8b4 avcodec/hdrdec: fix pixel count decrement in RLE decompress loop
The w variable counts pixels, not bytes. The non-RLE path correctly
uses w-- (one pixel = 4 bytes), but the RLE path uses w -= 4, causing
the loop to terminate after roughly 1/4 of the expected pixels.

The w -= 4 was introduced in 14e99cb472 which moved the decrement
inside the loop to fix an OOB write (clusterfuzz-5423041009549312).
The move was correct, but the decrement value should have been 1 to
match the non-RLE path.

Signed-off-by: João Neves <joaocns0@protonmail.com>
(cherry picked from commit 2c71a28bf0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 04:40:49 +02:00
Timo Rothenpieler 83e8541aa6 forgejo/workflows: update test workflow for 8.1 release 2026-06-12 15:07:35 +02:00
Martin Storsjö e0e38acd2f aarch64: vp9lpf: Fix GCS violations
The aarch64 VP9 loopfilters actually violate aarch64 GCS
(Guarded Control Stack), even though we marked the code as GCS
compliant in 846746be4b.

This means that builds with GCS enabled, after that commit,
will crash when decoding VP9, on future hardware (or current
QEMU) that supports GCS. This also goes for ffmpeg version 8.1.1
where the GCS enabling was backported.

This matches the fix that was done for hevcdsp in
1f7ed8a78d.

This issue wasn't observed if running checkasm in QEMU - therefore,
I thought all GCS issues had been fixed by
846746be4b. (If I would have
tested the full "make fate" with QEMU, the issue would
have appeared though.)

However with the new checkasm, some of the GCS violations
do appear even in checkasm.

The reason is that the checkasm vp9 test intentionally craft
input pixels that attempt to trigger all the individual
separate cases in each input buffer (in
randomize_loopfilter_buffers). This means that the checkasm
tests actually never test or exercise the early exit cases,
which are the ones that violate GCS.

With the new checkasm, the call to "bench_new" always test
running the code at least once, even if not benchmarking.

As the input buffers weren't reinitialized between the test
and "bench_new", the pixel differences now differ from the
initial setup, so that the code now some times (often) would
end up hitting the early exit cases.

Ideally, the vp9 checkasm test would be repeated to cover all
cases of input buffers that allow early exits, in addition to
covering the case with all different cases in one block.

(cherry picked from commit d05786cf23)
2026-06-10 21:05:42 +03:00
James Almer e4c7fbf6c0 avformat/mov: don't abort on unsupported or invalid chnl boxes
They are optional and just define a channel layout, which may also be defined
by the underlying codec.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 95fe0658d7)
2026-06-01 11:25:05 -03:00
James Almer 9eb9f4799f avformat/mov_chan: keep the layout untouched on chan/chnl box failure
Needed to keep the process going if some issue was found while parsing these boxes.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit fd1c8fa0e6)
2026-06-01 11:24:49 -03:00
Romain Beauxis 58d4114d36 avformat/oggparsevorbis.c: Prevent integer overflow when summing header lengths; add bounds check.
Cherry-picked from 6e0e13b0bf

Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-05-26 16:49:12 -05:00
Franciszek Kalinowski b21e00eda5 avformat/oggparsecelt: bound extra_headers to avoid an effectively infinite loop
celt_header() reads a uint32 `extra_headers` field from the CELT identification
header and stores `1 + extra_headers` into the signed int extra_headers_left.
With extra_headers = 0x7FFFFFFE this becomes INT_MAX and the OGG parser
consumes every subsequent page as a CELT "extra header" without ever reaching
audio data, hanging on any streaming input. A value of 0xFFFFFFFE wraps the
signed addition negative, with the same family of consequences.

Reject any extra_headers count above a small fixed cap (16, well above any
real CELT-over-Ogg stream).

Verified with the audit PoC (a crafted file plus an infinite-page FIFO):
without the patch, ffmpeg consumes pages forever; with the patch it logs
"Too many CELT extra headers (...)" and exits in ~70 ms with
AVERROR_INVALIDDATA.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.

(cherry picked from commit 87439ed619)
2026-05-21 09:36:30 -05:00
Kacper Michajłow 3728de467d avformat/demux: use correct close function for custom io
You may look and think `AVFMT_FLAG_CUSTOM_IO` check is enough, but this
is not what it seems. This flag means that user provided custom
AVIOContext, before creating AVFormatContext and it should not be
closed. However nested sub-demuxers may still open an temporary io, and
those have to be closed and use correct io_close2 function.

You can see 0dcac9c3f0 and
ef01061225 where this flag is cleared for
nested opens to avoid leaking those.

lavf micro version bumped so API users can know if it is safe to use
custom io.

(cherry picked from commit dc74fe70b2)

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 18:08:07 +02:00
Kacper Michajłow da9dd86bdc avformat/hlsenc: use correct close function for custom io
This is open by s->io_open().

(cherry picked from commit 200cbaeb5a)

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 18:07:19 +02:00
Kacper Michajłow 8c31bbbb37 avformat/hlsenc: respect io_open set in AVFormatContext
io_open_default() will call internal impl if needed, don't call it
directly.

(cherry picked from commit 06ef9a74ea)

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 17:30:43 +02:00
Kacper Michajłow 470685bd1d avformat/dashenc: respect io_open set in AVFormatContext
io_open_default() will call internal impl if needed, don't call it
directly.

(cherry picked from commit 4cf687b3b1)

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 17:26:51 +02:00
Kacper Michajłow 6f746f57d8 avformat/dashdec: respect io_open set in AVFormatContext
io_open_default() will call internal impl if needed, don't call it
directly.

(cherry picked from commit fbc4003642)

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-16 17:25:56 +02:00
nyanmisaka fb216b5fac vulkan: fix using encode caps before querying
Fix using enc_caps.supportedEncodeFeedbackFlags before
calling vkGetPhysicalDeviceVideoCapabilitiesKHR().

Otherwise the check will never pass and will fail with ENOTSUP.

Fixes 3f9e04b

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
(cherry picked from commit d01d18ad71)
2026-05-15 04:30:53 +09:00
Marvin Scholz 1068a26663 avformat/rtpdec_av1: fix buffer overflow due to variable confusion
The pktpos denotes the position in the output packet buffer, while
buf_ptr is the position in the input buffer. As this payload is ignored,
nothing is written to the output packet so increasing the pktpos does
not make sense here, instead the buf_ptr has to be increased to advance
the input buffer to the correct position after this OBU.

This incorrect increment here could result in pktpos exceeding the whole
size of the output packet and the later call to memcpy to write to that
buffer would start its write way past the end of the packet buffer.

Fix #22812

Reported-By: fre3dm4n
(cherry picked from commit 18761f9fb5)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-05-12 16:15:10 +02:00
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
360 changed files with 4252 additions and 1584 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ name: Test
on:
push:
branches:
- master
- release/8.1
pull_request:
concurrency:
@@ -68,7 +68,7 @@ jobs:
strategy:
fail-fast: false
matrix:
image: ['ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest']
image: ['ghcr.io/btbn/ffmpeg-builds/win64-gpl-8.1:latest']
target_exec: ['wine']
runs-on: linux-amd64
container: ${{ matrix.image }}
+238 -1
View File
@@ -1,8 +1,245 @@
Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
version <next>:
version 8.1.2:
swscale/x86/rgb_2_rgb: fix uyvytoyuv422 overwrite on odd width
swscale/aarch64: fix uyvy/yuyv to yuv420p/yuv422p on odd width
avcodec/snowenc: fix SIGFPE in get_dc() when a block lies outside the plane
avcodec/snowenc: fix out-of-bounds OBMC read in get_dc() for narrow planes
(fforge/pr/23505) avformat/tls_gnutls:fix crash when connecting to peer
libavcodec/jpeg2000htdec: remove trailing whitespace
libavdevice/alsa.c: fix NULL pointer dereference
avcodec/libjxlenc: check orientation tag metadata before reading
avformat/icecast: reject CR/LF in metadata header values
avfilter/avf_showspectrum: Fix allocation check
avformat/sctp: add size check in sctp_read() matching sctp_write()
avcodec/jpeg2000: Fix undefined behavior on ROI shift-up
aacdec_usac_mps212: reject reserved freq_res value
avcodec/aac/aacdec_usac_mps212: Off-by-one bounds check in ff_aac_ec_data_deci()
Update for 8.1.2
avcodec/snowenc: fix out-of-bounds memcpy in get_block_rd() for narrow planes
avutil/eval: apply unary sign to print, squish, gauss and lerp
avcodec/cbs_av1_syntax_template: reset seen_frame_header on sequence headers
avfilter/convolution: compute user matrix products in unsigned
avformat/mpegts: use av_fast_realloc() for prg
avfilter/avf_showcwt: fix DIRECTION_DU EOF fill clearing the wrong rows
avfilter/avf_showcwt: fix DIRECTION_RL EOF fill clearing the wrong columns
avfilter/avf_showcwt: avoid undefined float to int conversion of nb_consumed_samples
avfilter/avf_showcwt: fix out of array read in compute_kernel
avfilter/v360: compute remap table offsets in 64bit
avfilter/v360: reject out-of-range dimensions
swresample/x86/resample: write only int16 in the int16 resampler
avformat/rtpenc_amr: Check input size
swscale/ppc: fix ASAN stack-buffer-overflow in yuv2planeX
swscale/ppc: fix LOAD_FILTER overread in VSX path
avcodec/sanm: reject codec37 frames taller than the allocated buffer
avcodec/sanm: reject codec47 frames taller than the allocated buffer
avfilter: use ff_slice_pos() for per-slice boundary computation
avfilter: add ff_slice_pos() helper for slice boundaries
(origin/release/8.1, fforge/release/8.1) avformat/iamf_writer: reject muxing PCM streams
avfilter/estdif: avoid signed overflow in slice boundary calculation
swscale: support sliced input with cascaded scaling contexts
avformat/rtspdec: bound Content-Length in the ANNOUNCE handler to SDP_MAX_SIZE
avcodec/cbs_h266_syntax_template: reject subpic info with res_change_in_clvs
avcodec/misc4: Check nb channels
avcodec/rv10, rv34: check init_get_bits8() before RealVideo bit access
avformat/http: reject request-line tokens not terminated by whitespace
avformat/mov: reject out of range ispe dimensions, avoid overflow summing HEIF tile dimensions
avcodec/agm: validate actual src_y against prev plane in decode_inter_plane
avformat/dhav: Fix second integer overflow in get_duration()
fftools/ffmpeg_dec: deep-copy subtitle_header to fix use-after-free
avcodec/hevc/ps: Check window parameters
avcodec/hevc/ps: Factor window reading out
avcodec/truespeech: reject iterations count whose * 240 product overflows 32-bit
libavcodec/options_table: gamma22 and gamma28 aliases
avcodec/on2avc: reject subframe count whose * SUBFRAME_SIZE product overflows 32-bit
avfilter/zmq: initialize send_buf before shared cleanup on parse failure
avcodec/adpcm: fix signed integer overflow in get_nb_samples()
avformat/matroskadec: avoid signed overflow in DASH cue time differences
avcodec/fastaudio: reject subframes count whose * 256 product overflows 32-bit
avcodec/vc2enc_dwt: avoid signed overflow in the 9/7 DWT lifting
avcodec/vc2enc_dwt: avoid signed overflow in the 5/3 and Haar DWT
avformat/dashdec: Fail with any inner stream count being 0
avcodec/mjpegdec: require progress in AVRn interlaced field loop
avcodec/mwsc: do not dereference a missing reference frame
avcodec/misc4: reject invalid sample rate
swscale/output: avoid signed overflow in yuv2rgba64_1 alpha
swscale/output: avoid signed overflow in yuv2rgba64_full_1 alpha
tools/target_dem_fuzzer: do not exit on io_buffer allocation failure
avformat/gxfenc: Check timecode and propagate error
swscale/rgb2rgb_template: use unsigned for <<24
avformat/iamf_parse: bound substream count by remaining OBU size
avformat/matroskadec: bound TRACKENTRY parsing by max_streams
avcodec/diracdec: fix heap buffer overflow in edge_emu_buffer
avformat/rtmppkt: Check recursion depth
avcodec/tdsc: propagate max_pixels to the JPEG tile decoder
avcodec/imm5: propagate max_pixels to the H264/HEVC sub-decoders
avcodec/cri: propagate max_pixels to the JPEG tile decoder
avcodec/jpeglsdec: only apply color transform to decoded rows
avcodec/adpcm: require block_align to be a multiple of channels in ADPCM_PSXC init
avfilter/avf_showcwt: fix out-of-bounds read in du scroll
avfilter/f_ebur128: avoid signed-int wrap when sizing per-channel cache
avformat/mov: cap HEIF ICC profile copies via c*max_streams to bound CPU and memory
avcodec/aac/aacdec_usac: reject explicit usacSamplingFrequency of 0
avcodec/aac/aacdec_usac: avoid signed overflow in decode_tsd
avcodec/aac/aacdec: reject decoded frame without a valid sample rate
avformat/iff: check av_get_packet() result in ANIM branch
avcodec/cbs_h266_syntax_template: Fix pps_exp_slice_height_in_ctus_minus1 range
avfilter/vf_scale: split rational multiply
avcodec/bsf/dts2pts: fix binary tree invariant violation on selective dec_poc
avfilter/vf_drawtext: Avoid double free in glyph_enu_border_free()
avfilter/vf_drawtext: plug error-path leaks in measure_text/draw_text
avfilter/vf_drawtext: shape_text_hb() free allocated things on error
avfilter/vf_drawtext: avoid double-free of aliased FT_Glyph in glyph_enu_free
avfilter/vf_drawtext: don't double-free glyph that has been cached in tree
avfilter/vf_drawtext: always check pixel_mode == FT_PIXEL_MODE_MONO
avcodec/cook: bound subpacket channel sum against channel count
avcodec/apv_decode: avoid using apv_cbc
avformat/mxfdec: Remove unneeded check
avformat/ftp: Check string used for RNTO
avformat/ftp: Check for Telnet IAC characters and other non printable ASCII chars
avformat/ftp: reject CR/LF in the URL path to prevent FTP command injection
avcodec/jpeg2000dec: Clear header derived variables
avcodec/bsf/smpte436m_to_eia608: properly frees stuff on errors in ff_smpte436m_to_eia608_filter()
tests/checkasm/crc: retain offset values between calls
avformat/avc: Adjust get_ue_golomb() to handle 32 bit
avformat/whip: require remote DTLS fingerprint in SDP answer
avcodec/x86/vorbisdsp: change cmpleps to cmpltps in inverse coupling
avcodec/liboapvenc: derive and validate APV profile from pixel format
avformat/dashdec: bound manifest reloads and fragment-open retries
avfilter/af_join: fix wrong loop bound in buffer dedup (use-after-free)
avcodec/nvenc: fix compatibility with Video Codec SDK 13.1
avformat/mov: validate APV access unit length before passing to decoder
avcodec/h264_slice: guard color_frame() against chroma-width underflow
avcodec/magicyuv: reject slice_height misaligned with chroma vshift
avcodec/magicyuv: Expand the s->interlaced slice-height sanity check
avcodec/magicyuv: Fix 1 line MEDIAN slices
avformat/mxfdec: zero-init Sony MPEG-4 extradata and add padding
avformat/soxdec: Check sample_rate for nan
tests/tiny_ssim: fixed mistake in ssim_c1 calculation
avformat/hls: Check TIME-OFFSET value
avformat/hls: Check url_offset and size
avcodec/prores_raw: reject invalid tile alignment values
avformat/ty: check rec_size
avformat/ogg: Fix overflow and stale oggvorbis_private values
avformat/rtpenc_xiph: bail out when the max payload size underflows
avformat/rtpenc_aac: reject packets smaller than the ADTS header
avcodec/jpeg2000dec: compute mask in decode_clnpass() like in decode_sigpass()
avformat/flvdec: Check size at the top of the main loop
avformat/vividas: fix misaligned access
avformat/mccdec: dont pass NULL to bytestream2_put_buffer()
avcodec/g2meet: The stack is EPIC_PIX_STACK_SIZE
avcodec/h2645_sei: Initialize side data before deallocation
avfilter/boxblur: Fix off by one errors
avformat/assenc: Add the missing parentheses
avcodec/diracdec: Enlarge `mctmp` to cover the worst-case `blheight·ybsep + yblen` rows, and break the MC loop when no output rows remain
tools/zmqsend: free the AVBprint buffer after using it
[Wave] Fix issues with unaligned metadata chunks.
avformat/mpegts: Dont assume fc->priv_data is a MpegTSContext
fftools/graph: Add missing include "libavutil/mem.h" for fftools/graph/graphprint.c
avcodec/cbs_h266_syntax_template: tighten sh_num_tiles_in_slice_minus1 upper bound
avcodec/hevc: limit missing-ref fill to coded planes
avformat/mov: Fix negative index given to can_seek_to_key_sample()
avcodec/hdrdec: fix pixel count decrement in RLE decompress loop
(fforge/pr/23464) forgejo/workflows: update test workflow for 8.1 release
(fforge/pr/23445) aarch64: vp9lpf: Fix GCS violations
(fforge/pr/23303) avformat/mov: don't abort on unsupported or invalid chnl boxes
avformat/mov_chan: keep the layout untouched on chan/chnl box failure
(fforge/pr/23240) avformat/oggparsevorbis.c: Prevent integer overflow when summing header lengths; add bounds check.
(fforge/pr/23187) avformat/oggparsecelt: bound extra_headers to avoid an effectively infinite loop
(fforge/pr/23111) avformat/demux: use correct close function for custom io
avformat/hlsenc: use correct close function for custom io
avformat/hlsenc: respect io_open set in AVFormatContext
avformat/dashenc: respect io_open set in AVFormatContext
avformat/dashdec: respect io_open set in AVFormatContext
vulkan: fix using encode caps before querying
avformat/rtpdec_av1: fix buffer overflow due to variable confusion
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.2
+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.2
# 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
+6
View File
@@ -27324,6 +27324,12 @@ frame-consumer that exhausts the limited decoder frame pool.
If set to 1, frames are passed through as-is if they match the desired output
parameters. This is the default behaviour.
@item use_filters
If set to 1, filter with a generic weight LUT instead of using fixed-function
shader kernels. May be faster or slower depending on the hardware. A value
of @code{auto} (the default) enables this automatically when required for
correct anti-aliasing when downscaling.
@item param
Algorithm-Specific parameter.
+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)
+1 -1
View File
@@ -469,7 +469,7 @@ typedef struct Decoder {
enum AVMediaType type;
const uint8_t *subtitle_header;
uint8_t *subtitle_header;
int subtitle_header_size;
// number of frames/samples retrieved from the decoder
+11 -2
View File
@@ -136,6 +136,8 @@ void dec_free(Decoder **pdec)
av_frame_free(&dp->sub_prev[i]);
av_frame_free(&dp->sub_heartbeat);
av_freep(&dp->dec.subtitle_header);
av_freep(&dp->parent_name);
av_freep(&dp->views_requested);
@@ -1621,8 +1623,15 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts,
dp->dec_ctx->extra_hw_frames = extra_frames;
}
dp->dec.subtitle_header = dp->dec_ctx->subtitle_header;
dp->dec.subtitle_header_size = dp->dec_ctx->subtitle_header_size;
if (dp->dec_ctx->subtitle_header) {
/* ASS code assumes this buffer is null terminated so add extra byte. */
dp->dec.subtitle_header = av_mallocz(dp->dec_ctx->subtitle_header_size + 1);
if (!dp->dec.subtitle_header)
return AVERROR(ENOMEM);
memcpy(dp->dec.subtitle_header, dp->dec_ctx->subtitle_header,
dp->dec_ctx->subtitle_header_size);
dp->dec.subtitle_header_size = dp->dec_ctx->subtitle_header_size;
}
if (param_out) {
if (dp->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+49 -36
View File
@@ -96,12 +96,6 @@ typedef struct DemuxStream {
uint64_t nb_packets;
// combined size of all the packets read
uint64_t data_size;
// latest wallclock time at which packet reading resumed after a stall - used for readrate
int64_t resume_wc;
// timestamp of first packet sent after the latest stall - used for readrate
int64_t resume_pts;
// measure of how far behind packet reading is against spceified readrate
int64_t lag;
} DemuxStream;
typedef struct DemuxStreamGroup {
@@ -144,6 +138,13 @@ typedef struct Demuxer {
double readrate_initial_burst;
float readrate_catchup;
// latest wallclock time at which packet reading resumed after a stall - used for readrate
int64_t resume_wc;
// relative timestamp of first packet sent after the latest stall - used for readrate
int64_t resume_progress;
// measure of how far behind packet reading is against spceified readrate
int64_t lag;
Scheduler *sch;
AVPacket *pkt_heartbeat;
@@ -514,43 +515,55 @@ static void readrate_sleep(Demuxer *d)
int64_t initial_burst = AV_TIME_BASE * d->readrate_initial_burst;
int resume_warn = 0;
DemuxStream *slowest = NULL;
int64_t progress = INT64_MAX;
for (int i = 0; i < f->nb_streams; i++) {
InputStream *ist = f->streams[i];
DemuxStream *ds = ds_from_ist(ist);
int64_t stream_ts_offset, pts, now, wc_elapsed, elapsed, lag, max_pts, limit_pts;
int64_t stream_ts_offset, pts, pts_diff;
if (ds->discard || ds->finished || ds->first_dts == AV_NOPTS_VALUE)
continue;
if (ds->discard) continue;
stream_ts_offset = FFMAX(ds->first_dts != AV_NOPTS_VALUE ? ds->first_dts : 0, file_start);
stream_ts_offset = FFMAX(ds->first_dts, file_start);
pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE);
now = av_gettime_relative();
wc_elapsed = now - d->wallclock_start;
if (pts <= stream_ts_offset + initial_burst) continue;
max_pts = stream_ts_offset + initial_burst + (int64_t)(wc_elapsed * d->readrate);
lag = FFMAX(max_pts - pts, 0);
if ( (!ds->lag && lag > 0.3 * AV_TIME_BASE) || ( lag > ds->lag + 0.3 * AV_TIME_BASE) ) {
ds->lag = lag;
ds->resume_wc = now;
ds->resume_pts = pts;
av_log_once(ds, AV_LOG_WARNING, AV_LOG_DEBUG, &resume_warn,
"Resumed reading at pts %0.3f with rate %0.3f after a lag of %0.3fs\n",
(float)pts/AV_TIME_BASE, d->readrate_catchup, (float)lag/AV_TIME_BASE);
pts_diff = pts - stream_ts_offset;
if (pts_diff < progress) {
progress = pts_diff;
slowest = ds;
}
if (ds->lag && !lag)
ds->lag = ds->resume_wc = ds->resume_pts = 0;
if (ds->resume_wc) {
elapsed = now - ds->resume_wc;
limit_pts = ds->resume_pts + (int64_t)(elapsed * d->readrate_catchup);
} else {
elapsed = wc_elapsed;
limit_pts = max_pts;
}
if (pts > limit_pts)
av_usleep(pts - limit_pts);
}
if (!slowest || progress <= initial_burst)
return;
int64_t now = av_gettime_relative();
int64_t wc_elapsed = now - d->wallclock_start;
int64_t max_prog = initial_burst + (int64_t)(wc_elapsed * d->readrate);
int64_t lag = FFMAX(max_prog - progress, 0);
int64_t limit;
if ( (!d->lag && lag > 0.3 * AV_TIME_BASE) || ( lag > d->lag + 0.3 * AV_TIME_BASE) ) {
d->lag = lag;
d->resume_wc = now;
d->resume_progress = progress;
int64_t pts = FFMAX(slowest->first_dts, file_start) + progress;
av_log_once(slowest, AV_LOG_WARNING, AV_LOG_DEBUG, &resume_warn,
"Resumed reading at pts %0.3f with rate %0.3f after a lag of %0.3fs\n",
(float)pts/AV_TIME_BASE, d->readrate_catchup, (float)lag/AV_TIME_BASE);
}
if (d->lag && !lag)
d->lag = d->resume_wc = d->resume_progress = 0;
if (d->resume_wc) {
int64_t elapsed = now - d->resume_wc;
limit = d->resume_progress + (int64_t)(elapsed * d->readrate_catchup);
} else {
limit = max_prog;
}
if (progress > limit)
av_usleep(progress - limit);
}
static int do_send(Demuxer *d, DemuxStream *ds, AVPacket *pkt, unsigned flags,
+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
View File
@@ -33,6 +33,7 @@
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/dict.h"
#include "libavutil/common.h"
+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
+6
View File
@@ -2383,6 +2383,12 @@ static int decode_frame_ga(AVCodecContext *avctx, AACDecContext *ac,
ac->oc[1].status = OC_LOCKED;
}
if (samples && avctx->sample_rate <= 0) {
av_log(avctx, AV_LOG_ERROR,
"Cannot output a frame without a valid sample rate\n");
return AVERROR_INVALIDDATA;
}
if (!ac->frame->data[0] && samples) {
av_log(avctx, AV_LOG_ERROR, "no frame data found\n");
return AVERROR_INVALIDDATA;
+27 -10
View File
@@ -215,6 +215,11 @@ static int decode_usac_element_pair(AACDecContext *ac,
if (e->stereo_config_index) {
e->mps.freq_res = get_bits(gb, 3); /* bsFreqRes */
if (!e->mps.freq_res)
return AVERROR_INVALIDDATA; /* value 0 is reserved */
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 +227,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 */
@@ -363,6 +377,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
freq_idx = get_bits(gb, 5); /* usacSamplingFrequencyIndex */
if (freq_idx == 0x1f) {
samplerate = get_bits(gb, 24); /* usacSamplingFrequency */
if (samplerate == 0)
return AVERROR(EINVAL);
} else {
samplerate = ff_aac_usac_samplerate[freq_idx];
if (samplerate < 0)
@@ -1293,7 +1309,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 +1360,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);
}
}
@@ -1372,11 +1390,10 @@ static void decode_tsd(GetBitContext *gb, int *data,
break;
}
int64_t c = k - p + 1;
for (int h = 2; h <= p; h++) {
c *= k - p + h;
c /= h;
for (int h = 2; h <= p && c <= s; h++) {
c += c*(k-p)/h;
}
if (s >= (int)c) { /* c is long long for up to 32 slots */
if (s >= c) {
s -= c;
data[k] = 1;
p--;
+14 -16
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,15 +640,16 @@ 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);
if (set_idx + data_pair > MPS_MAX_PARAM_SETS)
if (set_idx + data_pair >= MPS_MAX_PARAM_SETS)
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
+36 -26
View File
@@ -56,9 +56,7 @@
mov x11, v4.d[0]
mov x12, v4.d[1]
adds x11, x11, x12
b.ne 1f
ret x10
1:
b.eq 9f
.if \wd >= 8
dup v0.8h, w5
@@ -189,13 +187,7 @@
// If no pixels need flat8in, jump to flat8out
// (or to a writeout of the inner 4 pixels, for wd=8)
.if \wd >= 8
.if \wd == 16
b.eq 6f
.else
b.ne 1f
ret x13
1:
.endif
// flat8in
add \tmp1\().8h, v20.8h, v21.8h
@@ -249,20 +241,16 @@
mov x11, v2.d[0]
mov x12, v2.d[1]
adds x11, x11, x12
b.ne 1f
// If no pixels needed flat8in nor flat8out, jump to a
// writeout of the inner 4 pixels
ret x14
1:
b.eq 7f
mov x11, v7.d[0]
mov x12, v7.d[1]
adds x11, x11, x12
b.ne 1f
// If no pixels need flat8out, jump to a writeout of the inner 6 pixels
ret x15
b.eq 8f
1:
// flat8out
// This writes all outputs into v2-v17 (skipping v6 and v16).
// If this part is skipped, the output is read from v21-v26 (which is the input
@@ -378,35 +366,57 @@
// while we need those for inputs/outputs in wd=16 and use v8-v15
// for temp registers there instead.
function vp9_loop_filter_4
mov x13, #0
loop_filter 4, v16, v17, v18, v19, v28, v29, v30, v31
ret
9:
mov x13, #(1<<9)
ret
endfunc
function vp9_loop_filter_8
mov x13, #0
loop_filter 8, v16, v17, v18, v19, v28, v29, v30, v31
ret
6:
mov x13, #(1<<6)
ret
9:
mov x13, #(1<<9)
ret
endfunc
function vp9_loop_filter_16
mov x13, #0
loop_filter 16, v8, v9, v10, v11, v12, v13, v14, v15
ret
7:
mov x13, #(1<<7)
ret
8:
mov x13, #(1<<8)
ret
9:
mov x13, #(1<<9)
ret
endfunc
.macro loop_filter_4
bl vp9_loop_filter_4
tbnz x13, #9, 9f
.endm
.macro loop_filter_8
// calculate alternative 'return' targets
adr x13, 6f
bl vp9_loop_filter_8
tbnz x13, #6, 6f
tbnz x13, #9, 9f
.endm
.macro loop_filter_16
// calculate alternative 'return' targets
adr x14, 7f
adr x15, 8f
bl vp9_loop_filter_16
tbnz x13, #7, 7f
tbnz x13, #8, 8f
tbnz x13, #9, 9f
.endm
@@ -540,7 +550,7 @@ function vp9_loop_filter_v_4_8_16_neon
st1 {v23.8h}, [x9], x1
st1 {v25.8h}, [x0], x1
sub x0, x0, x1, lsl #1
9:
ret x10
endfunc
@@ -588,7 +598,7 @@ function vp9_loop_filter_h_4_8_16_neon
st1 {v25.d}[1], [x0], x1
sub x0, x0, x1, lsl #3
add x0, x0, #4
9:
ret x10
endfunc
@@ -619,7 +629,7 @@ function vp9_loop_filter_v_8_8_16_neon
st1 {v26.8h}, [x0], x1
sub x0, x0, x1, lsl #1
sub x0, x0, x1
9:
ret x10
6:
sub x9, x0, x1, lsl #1
@@ -670,7 +680,7 @@ function vp9_loop_filter_h_8_8_16_neon
st1 {v27.8h}, [x0], x1
sub x0, x0, x1, lsl #3
add x0, x0, #8
9:
ret x10
6:
// If we didn't need to do the flat8in part, we use the same writeback
@@ -742,7 +752,7 @@ function vp9_loop_filter_v_16_8_16_neon
st1 {v17.8h}, [x0], x1
sub x0, x0, x1, lsl #3
add x0, x0, x1
9:
ret x10
8:
add x9, x9, x1, lsl #2
@@ -820,7 +830,7 @@ function vp9_loop_filter_h_16_8_16_neon
st1 {v9.8h}, [x9], x1
st1 {v31.8h}, [x0], x1
sub x0, x0, x1, lsl #3
9:
ret x10
8:
// The same writeback as in loop_filter_h_8_8
+61 -45
View File
@@ -388,32 +388,28 @@
.endif
.if \wd == 16
6:
// If no pixels needed flat8in nor flat8out, jump to a
// writeout of the inner 4 pixels
orr v2\sz, v6\sz, v7\sz
mov x5, v2.d[0]
.ifc \sz, .16b
mov x6, v2.d[1]
adds x5, x5, x6
b.ne 1f
b.eq 7f
.else
cbnz x5, 1f
cbz x5, 7f
.endif
// If no pixels needed flat8in nor flat8out, jump to a
// writeout of the inner 4 pixels
ret x14
1:
// If no pixels need flat8out, jump to a writeout of the inner 6 pixels
mov x5, v7.d[0]
.ifc \sz, .16b
mov x6, v7.d[1]
adds x5, x5, x6
b.ne 1f
b.eq 8f
.else
cbnz x5, 1f
cbz x5, 8f
.endif
// If no pixels need flat8out, jump to a writeout of the inner 6 pixels
ret x15
1:
// flat8out
// This writes all outputs into v2-v17 (skipping v6 and v16).
// If this part is skipped, the output is read from v21-v26 (which is the input
@@ -529,76 +525,94 @@
// while we need those for inputs/outputs in wd=16 and use v8-v15
// for temp registers there instead.
function vp9_loop_filter_4
mov x13, #0
loop_filter 4, .8b, 0, v16, v17, v18, v19, v28, v29, v30, v31
ret
9:
ret x10
mov x13, #(1<<9)
ret
endfunc
function vp9_loop_filter_4_16b_mix_44
mov x13, #0
loop_filter 4, .16b, 44, v16, v17, v18, v19, v28, v29, v30, v31
ret
9:
ret x10
mov x13, #(1<<9)
ret
endfunc
function vp9_loop_filter_8
mov x13, #0
loop_filter 8, .8b, 0, v16, v17, v18, v19, v28, v29, v30, v31
ret
6:
ret x13
mov x13, #(1<<6)
ret
9:
ret x10
mov x13, #(1<<9)
ret
endfunc
function vp9_loop_filter_8_16b_mix
mov x13, #0
loop_filter 8, .16b, 88, v16, v17, v18, v19, v28, v29, v30, v31
ret
6:
ret x13
mov x13, #(1<<6)
ret
9:
ret x10
mov x13, #(1<<9)
ret
endfunc
function vp9_loop_filter_16
mov x13, #0
loop_filter 16, .8b, 0, v8, v9, v10, v11, v12, v13, v14, v15
ret
7:
mov x13, #(1<<7)
ret
8:
mov x13, #(1<<8)
ret
9:
ldp d10, d11, [sp, #0x10]
ldp d12, d13, [sp, #0x20]
ldp d14, d15, [sp, #0x30]
ldp d8, d9, [sp], #0x40
ret x10
mov x13, #(1<<9)
ret
endfunc
function vp9_loop_filter_16_16b
mov x13, #0
loop_filter 16, .16b, 0, v8, v9, v10, v11, v12, v13, v14, v15
ret
7:
mov x13, #(1<<7)
ret
8:
mov x13, #(1<<8)
ret
9:
ldp d10, d11, [sp, #0x10]
ldp d12, d13, [sp, #0x20]
ldp d14, d15, [sp, #0x30]
ldp d8, d9, [sp], #0x40
ret x10
mov x13, #(1<<9)
ret
endfunc
.macro loop_filter_4
bl vp9_loop_filter_4
tbnz x13, #9, 9f
.endm
.macro loop_filter_4_16b_mix mix
bl vp9_loop_filter_4_16b_mix_\mix
tbnz x13, #9, 9f
.endm
.macro loop_filter_8
// calculate alternative 'return' targets
adr x13, 6f
bl vp9_loop_filter_8
tbnz x13, #6, 6f
tbnz x13, #9, 9f
.endm
.macro loop_filter_8_16b_mix mix
// calculate alternative 'return' targets
adr x13, 6f
.if \mix == 48
mov x11, #0xffffffff00000000
.elseif \mix == 84
@@ -607,20 +621,22 @@ endfunc
mov x11, #0xffffffffffffffff
.endif
bl vp9_loop_filter_8_16b_mix
tbnz x13, #6, 6f
tbnz x13, #9, 9f
.endm
.macro loop_filter_16
// calculate alternative 'return' targets
adr x14, 7f
adr x15, 8f
bl vp9_loop_filter_16
tbnz x13, #7, 7f
tbnz x13, #8, 8f
tbnz x13, #9, 9f
.endm
.macro loop_filter_16_16b
// calculate alternative 'return' targets
adr x14, 7f
adr x15, 8f
bl vp9_loop_filter_16_16b
tbnz x13, #7, 7f
tbnz x13, #8, 8f
tbnz x13, #9, 9f
.endm
@@ -647,7 +663,7 @@ function ff_vp9_loop_filter_v_4_8_neon, export=1
st1 {v24.8b}, [x0], x1
st1 {v23.8b}, [x9], x1
st1 {v25.8b}, [x0], x1
9:
ret x10
endfunc
@@ -671,7 +687,7 @@ function ff_vp9_loop_filter_v_44_16_neon, export=1
st1 {v24.16b}, [x0], x1
st1 {v23.16b}, [x9], x1
st1 {v25.16b}, [x0], x1
9:
ret x10
endfunc
@@ -713,7 +729,7 @@ function ff_vp9_loop_filter_h_4_8_neon, export=1
st1 {v24.s}[1], [x0], x1
st1 {v25.s}[0], [x9], x1
st1 {v25.s}[1], [x0], x1
9:
ret x10
endfunc
@@ -765,7 +781,7 @@ function ff_vp9_loop_filter_h_44_16_neon, export=1
st1 {v24.s}[3], [x0], x1
st1 {v25.s}[1], [x9], x1
st1 {v25.s}[3], [x0], x1
9:
ret x10
endfunc
@@ -792,7 +808,7 @@ function ff_vp9_loop_filter_v_8_8_neon, export=1
st1 {v25.8b}, [x0], x1
st1 {v23.8b}, [x9], x1
st1 {v26.8b}, [x0], x1
9:
ret x10
6:
sub x9, x0, x1, lsl #1
@@ -827,7 +843,7 @@ function ff_vp9_loop_filter_v_\mix\()_16_neon, export=1
st1 {v25.16b}, [x0], x1
st1 {v23.16b}, [x9], x1
st1 {v26.16b}, [x0], x1
9:
ret x10
6:
sub x9, x0, x1, lsl #1
@@ -875,7 +891,7 @@ function ff_vp9_loop_filter_h_8_8_neon, export=1
st1 {v26.8b}, [x0], x1
st1 {v23.8b}, [x9], x1
st1 {v27.8b}, [x0], x1
9:
ret x10
6:
// If we didn't need to do the flat8in part, we use the same writeback
@@ -941,7 +957,7 @@ function ff_vp9_loop_filter_h_\mix\()_16_neon, export=1
st1 {v26.d}[1], [x0], x1
st1 {v27.8b}, [x9], x1
st1 {v27.d}[1], [x0], x1
9:
ret x10
6:
add x9, x9, #2
+4 -3
View File
@@ -294,7 +294,8 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
break;
case AV_CODEC_ID_ADPCM_PSXC:
max_channels = 8;
if (avctx->ch_layout.nb_channels <= 0 || avctx->block_align <= 0)
if (avctx->ch_layout.nb_channels <= 0 || avctx->block_align <= 0 ||
avctx->block_align % avctx->ch_layout.nb_channels)
return AVERROR_INVALIDDATA;
break;
case AV_CODEC_ID_ADPCM_IMA_DAT4:
@@ -1173,7 +1174,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
if(ch <= 0)
return 0;
if (buf_size > INT_MAX / 2)
if (buf_size > INT_MAX / 14)
return 0;
switch (avctx->codec->id) {
@@ -2704,7 +2705,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;
+10 -6
View File
@@ -409,12 +409,14 @@ static int decode_inter_plane(AGMContext *s, GetBitContext *gb, int size,
int map = s->map[x];
if (orig_mv_x >= -32) {
if (y * 8 + mv_y < 0 || y * 8 + mv_y + 8 > h ||
x * 8 + mv_x < 0 || x * 8 + mv_x + 8 > w)
int src_y = (s->blocks_h - 1 - y) * 8 - mv_y;
int src_x = x * 8 + mv_x;
if (src_y < 0 || src_y + 8 > h ||
src_x < 0 || src_x + 8 > w)
return AVERROR_INVALIDDATA;
copy_block8(frame->data[plane] + (s->blocks_h - 1 - y) * 8 * frame->linesize[plane] + x * 8,
prev->data[plane] + ((s->blocks_h - 1 - y) * 8 - mv_y) * prev->linesize[plane] + (x * 8 + mv_x),
prev->data[plane] + src_y * prev->linesize[plane] + src_x,
frame->linesize[plane], prev->linesize[plane], 8);
if (map) {
s->idsp.idct(s->wblocks + x * 64);
@@ -446,12 +448,14 @@ static int decode_inter_plane(AGMContext *s, GetBitContext *gb, int size,
return ret;
if (orig_mv_x >= -32) {
if (y * 8 + mv_y < 0 || y * 8 + mv_y + 8 > h ||
x * 8 + mv_x < 0 || x * 8 + mv_x + 8 > w)
int src_y = (s->blocks_h - 1 - y) * 8 - mv_y;
int src_x = x * 8 + mv_x;
if (src_y < 0 || src_y + 8 > h ||
src_x < 0 || src_x + 8 > w)
return AVERROR_INVALIDDATA;
copy_block8(frame->data[plane] + (s->blocks_h - 1 - y) * 8 * frame->linesize[plane] + x * 8,
prev->data[plane] + ((s->blocks_h - 1 - y) * 8 - mv_y) * prev->linesize[plane] + (x * 8 + mv_x),
prev->data[plane] + src_y * prev->linesize[plane] + src_x,
frame->linesize[plane], prev->linesize[plane], 8);
if (map) {
s->idsp.idct(s->block);
+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;
+5 -6
View File
@@ -208,14 +208,13 @@ static int apv_decode_tile_component(AVCodecContext *avctx, void *data,
{
APVRawFrame *input = data;
APVDecodeContext *apv = avctx->priv_data;
const CodedBitstreamAPVContext *apv_cbc = apv->cbc->priv_data;
const APVDerivedTileInfo *tile_info = &apv->tile_info;
int tile_index = job / apv_cbc->num_comp;
int comp_index = job % apv_cbc->num_comp;
const AVPixFmtDescriptor *pix_fmt_desc =
av_pix_fmt_desc_get(avctx->pix_fmt);
int nb_components = pix_fmt_desc->nb_components;
int tile_index = job / nb_components;
int comp_index = job % nb_components;
int sub_w_shift = comp_index == 0 ? 0 : pix_fmt_desc->log2_chroma_w;
int sub_h_shift = comp_index == 0 ? 0 : pix_fmt_desc->log2_chroma_h;
@@ -266,7 +265,7 @@ static int apv_decode_tile_component(AVCodecContext *avctx, void *data,
int qp = tile->tile_header.tile_qp[comp_index];
int level_scale = apv_level_scale[qp % 6];
bit_depth = apv_cbc->bit_depth;
bit_depth = input->frame_header.frame_info.bit_depth_minus8 + 8;
qp_shift = qp / 6;
for (int y = 0; y < 8; y++) {
+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) {
+34 -6
View File
@@ -412,11 +412,23 @@ static int hevc_init_nb_frame(AVBSFContext *ctx, int poc)
return 0;
}
static int same_gop(void *opaque, void *elem)
typedef struct DTS2PTSCollect {
int gop;
DTS2PTSNode **out;
int count;
int max;
} DTS2PTSCollect;
static int collect_same_gop(void *opaque, void *elem)
{
DTS2PTSCollect *c = opaque;
DTS2PTSNode *node = elem;
int gop = ((int *)opaque)[1];
return FFDIFFSIGN(gop, node->gop);
if (node->gop == c->gop) {
if (c->count < c->max)
c->out[c->count] = node;
c->count++;
}
return 0;
}
static int hevc_queue_frame(AVBSFContext *ctx, AVPacket *pkt, int poc, bool *queued)
@@ -440,10 +452,26 @@ static int hevc_queue_frame(AVBSFContext *ctx, AVPacket *pkt, int poc, bool *que
}
if (poc < s->nb_frame && hevc->gop == s->gop) {
int tmp[] = {s->nb_frame - poc, s->gop};
int dec = s->nb_frame - poc;
DTS2PTSNode *nodes[HEVC_MAX_DPB_SIZE * 2];
DTS2PTSCollect c = { s->gop, nodes, 0, FF_ARRAY_ELEMS(nodes) };
s->nb_frame -= tmp[0];
av_tree_enumerate(s->root, tmp, same_gop, dec_poc);
s->nb_frame -= dec;
av_tree_enumerate(s->root, &c, NULL, collect_same_gop);
av_assert0(c.count <= c.max);
for (int i = 0; i < c.count; i++) {
struct AVTreeNode *tnode = NULL;
DTS2PTSNode *r;
av_tree_insert(&s->root, nodes[i], cmp_insert, &tnode);
nodes[i]->poc -= dec;
r = av_tree_insert(&s->root, nodes[i], cmp_insert, &tnode);
if (r && r != nodes[i]) {
*r = *nodes[i];
av_refstruct_unref(&nodes[i]);
av_free(tnode);
}
}
}
ret = alloc_and_insert_node(ctx, pkt->dts, pkt->duration, s->nb_frame, 1, s->gop);
+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);
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ static int ff_smpte436m_to_eia608_filter(AVBSFContext *ctx, AVPacket *out)
return 0;
}
if (ret != AVERROR_EOF)
return ret;
goto fail;
ret = AVERROR(EAGAIN);
fail:
+3
View File
@@ -186,10 +186,13 @@ static int FUNC(decoder_model_info)(CodedBitstreamContext *ctx, RWContext *rw,
static int FUNC(sequence_header_obu)(CodedBitstreamContext *ctx, RWContext *rw,
AV1RawSequenceHeader *current)
{
CodedBitstreamAV1Context *priv = ctx->priv_data;
int i, err;
HEADER("Sequence Header");
priv->seen_frame_header = 0;
fc(3, seq_profile, AV_PROFILE_AV1_MAIN,
AV_PROFILE_AV1_PROFESSIONAL);
flag(still_picture);
+7 -5
View File
@@ -1133,7 +1133,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
max_width_minus1 = tmp_width_val - 1;
max_height_minus1 = tmp_height_val - 1;
flag(sps_subpic_info_present_flag);
u(1, sps_subpic_info_present_flag, 0, !current->sps_res_change_in_clvs_allowed_flag);
if (current->sps_subpic_info_present_flag) {
ue(sps_num_subpics_minus1, 0, VVC_MAX_SLICES - 1);
if (current->sps_num_subpics_minus1 > 0) {
@@ -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);
@@ -2020,7 +2022,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw,
for (j = 0; j < current->pps_num_exp_slices_in_tile[i];
j++) {
ues(pps_exp_slice_height_in_ctus_minus1[i][j], 0,
remaining_height_in_ctbs_y - 1, 2,
remaining_height_in_ctbs_y - (current->pps_num_exp_slices_in_tile[i] - j), 2,
i, j);
slice_height_in_ctus =
current->
@@ -3143,7 +3145,7 @@ static int FUNC(slice_header) (CodedBitstreamContext *ctx, RWContext *rw,
if (!pps->pps_rect_slice_flag &&
pps->num_tiles_in_pic - current->sh_slice_address > 1)
ue(sh_num_tiles_in_slice_minus1, 0, pps->num_tiles_in_pic - 1);
ue(sh_num_tiles_in_slice_minus1, 0, pps->num_tiles_in_pic - 1 - current->sh_slice_address);
else
infer(sh_num_tiles_in_slice_minus1, 0);
@@ -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);
+5 -2
View File
@@ -1080,6 +1080,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
int s = 0;
unsigned int channel_mask = 0;
int samples_per_frame = 0;
int total_channels = 0;
int ret;
int channels = avctx->ch_layout.nb_channels;
@@ -1237,10 +1238,12 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
q->subpacket[s].gains2.now = q->subpacket[s].gain_3;
q->subpacket[s].gains2.previous = q->subpacket[s].gain_4;
if (q->num_subpackets + q->subpacket[s].num_channels > channels) {
av_log(avctx, AV_LOG_ERROR, "Too many subpackets %d for channels %d\n", q->num_subpackets, channels);
if (total_channels + q->subpacket[s].num_channels > channels) {
av_log(avctx, AV_LOG_ERROR, "Too many subpacket channels %d for channels %d\n",
total_channels + q->subpacket[s].num_channels, channels);
return AVERROR_INVALIDDATA;
}
total_channels += q->subpacket[s].num_channels;
q->num_subpackets++;
s++;
+1
View File
@@ -69,6 +69,7 @@ static av_cold int cri_decode_init(AVCodecContext *avctx)
s->jpeg_avctx->flags = avctx->flags;
s->jpeg_avctx->flags2 = avctx->flags2;
s->jpeg_avctx->idct_algo = avctx->idct_algo;
s->jpeg_avctx->max_pixels = avctx->max_pixels;
ret = avcodec_open2(s->jpeg_avctx, NULL, NULL);
if (ret < 0)
return ret;
+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;
+4 -4
View File
@@ -339,9 +339,9 @@ static int alloc_buffers(DiracContext *s, int stride)
av_freep(&s->mctmp);
av_freep(&s->mcscratch);
s->edge_emu_buffer_base = av_malloc_array(stride, MAX_BLOCKSIZE);
s->edge_emu_buffer_base = av_malloc_array(stride, 4 * MAX_BLOCKSIZE);
s->mctmp = av_malloc_array((stride+MAX_BLOCKSIZE), (h+MAX_BLOCKSIZE) * sizeof(*s->mctmp));
s->mctmp = av_malloc_array((stride+MAX_BLOCKSIZE), (h + 5*MAX_BLOCKSIZE) * sizeof(*s->mctmp));
s->mcscratch = av_malloc_array(stride, MAX_BLOCKSIZE);
if (!s->edge_emu_buffer_base || !s->mctmp || !s->mcscratch)
@@ -1895,7 +1895,7 @@ static int dirac_decode_frame_internal(DiracContext *s)
/* FIXME: small resolutions */
for (i = 0; i < 4; i++)
s->edge_emu_buffer[i] = s->edge_emu_buffer_base + i*FFALIGN(p->width, 16);
s->edge_emu_buffer[i] = s->edge_emu_buffer_base + i*s->buffer_stride*MAX_BLOCKSIZE;
if (!s->zero_res && !s->low_delay)
{
@@ -1944,7 +1944,7 @@ static int dirac_decode_frame_internal(DiracContext *s)
h = p->height - start;
else
h = p->ybsep - (start - dsty);
if (h < 0)
if (h <= 0)
break;
memset(mctmp+2*p->yoffset*p->stride, 0, 2*rowheight);
+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);
+2
View File
@@ -113,6 +113,8 @@ static int fastaudio_decode(AVCodecContext *avctx, AVFrame *frame,
int ret;
subframes = pkt->size / (40 * avctx->ch_layout.nb_channels);
if (subframes <= 0 || subframes > INT_MAX / 256)
return AVERROR_INVALIDDATA;
frame->nb_samples = subframes * 256;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
+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 |
+3 -2
View File
@@ -481,12 +481,13 @@ static void epic_free_pixel_cache(ePICPixHash *hash)
static inline int is_pixel_on_stack(const ePICContext *dc, uint32_t pix)
{
int i;
int n = FFMIN(dc->stack_pos, EPIC_PIX_STACK_SIZE);
for (i = 0; i < dc->stack_pos; i++)
for (i = 0; i < n; i++)
if (dc->stack[i] == pix)
break;
return i != dc->stack_pos;
return i != n;
}
#define TOSIGNED(val) (((val) >> 1) ^ -((val) & 1))
+108 -72
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;
}
@@ -593,15 +629,15 @@ static int h2645_sei_to_side_data(AVCodecContext *avctx, H2645SEI *sei,
return AVERROR(ENOMEM);
}
dst_env->ambient_illuminance = av_make_q(env->ambient_illuminance, 10000);
dst_env->ambient_light_x = av_make_q(env->ambient_light_x, 50000);
dst_env->ambient_light_y = av_make_q(env->ambient_light_y, 50000);
ret = ff_frame_new_side_data_from_buf_ext(avctx, sd, nb_sd,
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, &buf);
if (ret < 0)
return ret;
dst_env->ambient_illuminance = av_make_q(env->ambient_illuminance, 10000);
dst_env->ambient_light_x = av_make_q(env->ambient_light_x, 50000);
dst_env->ambient_light_y = av_make_q(env->ambient_light_y, 50000);
}
if (sei->mastering_display.present) {
+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++) {
+11 -4
View File
@@ -316,8 +316,10 @@ static void color_frame(AVFrame *frame, const int c[4])
int bytes = is_chroma ? AV_CEIL_RSHIFT(frame->width, desc->log2_chroma_w) : frame->width;
int height = is_chroma ? AV_CEIL_RSHIFT(frame->height, desc->log2_chroma_h) : frame->height;
if (desc->comp[0].depth >= 9) {
((uint16_t*)dst)[0] = c[p];
av_memcpy_backptr(dst + 2, 2, bytes - 2);
if (bytes >= 1)
((uint16_t*)dst)[0] = c[p];
if (bytes >= 2)
av_memcpy_backptr(dst + 2, 2, 2 * (bytes - 1));
dst += frame->linesize[p];
for (int y = 1; y < height; y++) {
memcpy(dst, frame->data[p], 2*bytes);
@@ -1949,8 +1951,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 +1980,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)
+1 -1
View File
@@ -72,7 +72,7 @@ static int decompress(uint8_t *scanline, int w, GetByteContext *gb, const uint8_
for (int i = run << rshift; i > 0 && w > 0 && scanline >= start + 4; i--) {
memcpy(scanline, scanline - 4, 4);
scanline += 4;
w -= 4;
w--;
}
rshift += 8;
if (rshift > 16)
+37 -22
View File
@@ -62,6 +62,29 @@ static const uint8_t hevc_sub_height_c[] = {
1, 2, 1, 1
};
static int read_window(HEVCWindow *window, GetBitContext *gb, int chroma_format_idc, int w, int h)
{
int64_t vert_mult = hevc_sub_height_c[chroma_format_idc];
int64_t horiz_mult = hevc_sub_width_c [chroma_format_idc];
int64_t left = get_ue_golomb_long(gb) * horiz_mult;
int64_t right = get_ue_golomb_long(gb) * horiz_mult;
int64_t top = get_ue_golomb_long(gb) * vert_mult;
int64_t bottom = get_ue_golomb_long(gb) * vert_mult;
if (left < 0 || right < 0 || top < 0 || bottom < 0 ||
w <= left + right ||
h <= top + bottom) {
memset(window, 0, sizeof(*window));
return AVERROR_INVALIDDATA;
}
window->left_offset = left;
window->right_offset = right;
window->top_offset = top;
window->bottom_offset = bottom;
return 0;
}
static void remove_sps(HEVCParamSets *s, int id)
{
int i;
@@ -702,12 +725,9 @@ static int decode_vps_ext(GetBitContext *gb, AVCodecContext *avctx, HEVCVPS *vps
}
if (get_bits1(gb) /* conformance_window_vps_flag */) {
int vert_mult = hevc_sub_height_c[vps->rep_format.chroma_format_idc];
int horiz_mult = hevc_sub_width_c[vps->rep_format.chroma_format_idc];
vps->rep_format.conf_win_left_offset = get_ue_golomb(gb) * horiz_mult;
vps->rep_format.conf_win_right_offset = get_ue_golomb(gb) * horiz_mult;
vps->rep_format.conf_win_top_offset = get_ue_golomb(gb) * vert_mult;
vps->rep_format.conf_win_bottom_offset = get_ue_golomb(gb) * vert_mult;
int ret = read_window(&vps->rep_format.conf_win, gb, vps->rep_format.chroma_format_idc, vps->rep_format.pic_width_in_luma_samples, vps->rep_format.pic_height_in_luma_samples);
if (ret < 0)
return ret;
}
vps->max_one_active_ref_layer = get_bits1(gb);
@@ -962,12 +982,7 @@ static void decode_vui(GetBitContext *gb, AVCodecContext *avctx,
vui->default_display_window_flag = get_bits1(gb);
if (vui->default_display_window_flag) {
int vert_mult = hevc_sub_height_c[sps->chroma_format_idc];
int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc];
vui->def_disp_win.left_offset = get_ue_golomb_long(gb) * horiz_mult;
vui->def_disp_win.right_offset = get_ue_golomb_long(gb) * horiz_mult;
vui->def_disp_win.top_offset = get_ue_golomb_long(gb) * vert_mult;
vui->def_disp_win.bottom_offset = get_ue_golomb_long(gb) * vert_mult;
read_window(&vui->def_disp_win, gb, sps->chroma_format_idc, sps->width, sps->height);
if (apply_defdispwin &&
avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) {
@@ -1280,11 +1295,14 @@ 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;
sps->pic_conf_win.top_offset = rf->conf_win_top_offset;
sps->pic_conf_win.bottom_offset = rf->conf_win_bottom_offset;
sps->pic_conf_win.left_offset = rf->conf_win.left_offset;
sps->pic_conf_win.right_offset = rf->conf_win.right_offset;
sps->pic_conf_win.top_offset = rf->conf_win.top_offset;
sps->pic_conf_win.bottom_offset = rf->conf_win.bottom_offset;
} else {
sps->chroma_format_idc = get_ue_golomb_long(gb);
@@ -1307,12 +1325,9 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
sps->conformance_window = get_bits1(gb);
if (sps->conformance_window) {
int vert_mult = hevc_sub_height_c[sps->chroma_format_idc];
int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc];
sps->pic_conf_win.left_offset = get_ue_golomb_long(gb) * horiz_mult;
sps->pic_conf_win.right_offset = get_ue_golomb_long(gb) * horiz_mult;
sps->pic_conf_win.top_offset = get_ue_golomb_long(gb) * vert_mult;
sps->pic_conf_win.bottom_offset = get_ue_golomb_long(gb) * vert_mult;
ret = read_window(&sps->pic_conf_win, gb, sps->chroma_format_idc, sps->width, sps->height);
if (ret < 0)
return ret;
if (avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) {
av_log(avctx, AV_LOG_DEBUG,
+1 -4
View File
@@ -162,10 +162,7 @@ typedef struct RepFormat {
uint8_t separate_colour_plane_flag;
uint8_t bit_depth_luma; ///< bit_depth_vps_luma_minus8 + 8
uint8_t bit_depth_chroma; ///< bit_depth_vps_chroma_minus8 + 8
uint16_t conf_win_left_offset;
uint16_t conf_win_right_offset;
uint16_t conf_win_top_offset;
uint16_t conf_win_bottom_offset;
HEVCWindow conf_win;
} RepFormat;
typedef struct HEVCVPS {
+7 -3
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;
@@ -470,12 +473,13 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, HEVCLayerContext *l, int
return NULL;
if (!s->avctx->hwaccel) {
int nb_planes = l->sps->chroma_format_idc ? 3 : 1;
if (!l->sps->pixel_shift) {
for (i = 0; frame->f->data[i]; i++)
for (i = 0; i < nb_planes; i++)
memset(frame->f->data[i], 1 << (l->sps->bit_depth - 1),
frame->f->linesize[i] * AV_CEIL_RSHIFT(l->sps->height, l->sps->vshift[i]));
} else {
for (i = 0; frame->f->data[i]; i++)
for (i = 0; i < nb_planes; i++)
for (y = 0; y < (l->sps->height >> l->sps->vshift[i]); y++) {
uint8_t *dst = frame->f->data[i] + y * frame->f->linesize[i];
AV_WN16(dst, 1 << (l->sps->bit_depth - 1));
+2
View File
@@ -62,6 +62,7 @@ static av_cold int imm5_init(AVCodecContext *avctx)
ctx->h264_avctx->thread_count = 1;
ctx->h264_avctx->flags = avctx->flags;
ctx->h264_avctx->flags2 = avctx->flags2;
ctx->h264_avctx->max_pixels = avctx->max_pixels;
ret = avcodec_open2(ctx->h264_avctx, NULL, NULL);
if (ret < 0)
return ret;
@@ -73,6 +74,7 @@ static av_cold int imm5_init(AVCodecContext *avctx)
ctx->hevc_avctx->thread_count = 1;
ctx->hevc_avctx->flags = avctx->flags;
ctx->hevc_avctx->flags2 = avctx->flags2;
ctx->hevc_avctx->max_pixels = avctx->max_pixels;
ret = avcodec_open2(ctx->hevc_avctx, NULL, NULL);
if (ret < 0)
return ret;
+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
+7 -1
View File
@@ -1957,7 +1957,7 @@ static void decode_clnpass(const Jpeg2000DecoderContext *s, Jpeg2000T1Context *t
int width, int height, int bpno, int bandno,
int seg_symbols, int vert_causal_ctx_csty_symbol)
{
int mask = 3 << (bpno - 1), y0, x, y, runlen, dec;
int mask = (3u << bpno)>>1, y0, x, y, runlen, dec;
for (y0 = 0; y0 < height; y0 += 4) {
for (x = 0; x < width; x++) {
@@ -2448,8 +2448,14 @@ static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s)
memset(s->qntsty, 0, sizeof(s->qntsty));
memset(s->properties, 0, sizeof(s->properties));
memset(&s->poc , 0, sizeof(s->poc));
memset(s->roi_shift, 0, sizeof(s->roi_shift));
s->numXtiles = s->numYtiles = 0;
s->ncomponents = 0;
s->has_ppm = 0;
s->isHT = 0;
s->precision = 0;
s->colour_space = 0;
s->pal8 = 0;
}
static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
+13 -2
View File
@@ -1334,8 +1334,19 @@ ff_jpeg2000_decode_htj2k(const Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c
sign = val & INT32_MIN;
val &= INT32_MAX;
/* ROI shift, if necessary */
if (roi_shift && (((uint32_t)val & ~mask) == 0))
val <<= roi_shift;
if (roi_shift && (((uint32_t)val & ~mask) == 0)) {
if ((32 - ff_clz(val | 1)) < roi_shift)
// Assuming that the internal precision for codeblock decoding is 32 bits.
val <<= roi_shift;
else {
av_log(s->avctx, AV_LOG_ERROR,
"Pixel precision in ROI is beyond the supported range.\n"
);
ret = AVERROR_PATCHWELCOME;
goto free;
}
}
t1->data[n] = val | sign; /* NOTE: Binary point for reconstruction value is located in 31 - M_b */
}
}
+1 -1
View File
@@ -499,7 +499,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s)
if (s->bits <= 8) {
uint8_t *src = s->picture_ptr->data[0];
for (i = 0; i < s->height; i++) {
for (i = 0; i < decoded_height; i++) {
switch(s->xfrm) {
case 1:
for (x = off; x + 2 < w; x += 3) {
+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];
+2 -1
View File
@@ -434,7 +434,8 @@ static int libjxl_preprocess_stream(AVCodecContext *avctx, const AVFrame *frame,
if (ret >= 0)
ret = av_exif_get_entry(avctx, &ifd, tag, 0, &orient);
if (ret >= 0 && orient) {
if (!have_matrix && orient->value.uint[0] >= 1 && orient->value.uint[0] <= 8) {
if (!have_matrix && orient->type == AV_TIFF_SHORT && orient->count
&& orient->value.uint[0] >= 1 && orient->value.uint[0] <= 8) {
av_exif_orientation_to_matrix(matrix, orient->value.uint[0]);
have_matrix = 1;
}
+134 -18
View File
@@ -59,8 +59,6 @@ typedef struct ApvEncContext {
oapv_frms_t ifrms; // frames for input
int num_frames; // number of frames in an access unit
int preset_id; // preset of apv ( fastest, fast, medium, slow, placebo)
int qp; // quantization parameter (QP) [0,63]
@@ -129,6 +127,121 @@ static inline int get_color_format(enum AVPixelFormat pix_fmt)
return cf;
}
static inline int get_chroma_format_idc(enum AVPixelFormat pix_fmt)
{
int cfi = -1;
switch (pix_fmt) {
case AV_PIX_FMT_GRAY10:
cfi = APV_CHROMA_FORMAT_400;
break;
case AV_PIX_FMT_YUV422P10:
case AV_PIX_FMT_YUV422P12:
cfi = APV_CHROMA_FORMAT_422;
break;
case AV_PIX_FMT_YUV444P10:
case AV_PIX_FMT_YUV444P12:
cfi = APV_CHROMA_FORMAT_444;
break;
case AV_PIX_FMT_YUVA444P10:
case AV_PIX_FMT_YUVA444P12:
cfi = APV_CHROMA_FORMAT_4444;
break;
default:
av_assert0(cfi >= 0);
}
return cfi;
}
static inline int get_min_profile(enum AVPixelFormat pix_fmt)
{
int profile = AV_PROFILE_UNKNOWN;
switch (pix_fmt) {
case AV_PIX_FMT_GRAY10:
profile = AV_PROFILE_APV_400_10;
break;
case AV_PIX_FMT_YUV422P10:
profile = AV_PROFILE_APV_422_10;
break;
case AV_PIX_FMT_YUV422P12:
profile = AV_PROFILE_APV_422_12;
break;
case AV_PIX_FMT_YUV444P10:
profile = AV_PROFILE_APV_444_10;
break;
case AV_PIX_FMT_YUV444P12:
profile = AV_PROFILE_APV_444_12;
break;
case AV_PIX_FMT_YUVA444P10:
profile = AV_PROFILE_APV_4444_10;
break;
case AV_PIX_FMT_YUVA444P12:
profile = AV_PROFILE_APV_4444_12;
break;
default:
av_assert0(profile != AV_PROFILE_UNKNOWN);
}
return profile;
}
static int profile_is_compatible(enum AVPixelFormat pix_fmt, int profile)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
const int chroma_format_idc = get_chroma_format_idc(pix_fmt);
const int bit_depth = desc->comp[0].depth;
av_assert0(desc);
switch (profile) {
case AV_PROFILE_APV_422_10:
return chroma_format_idc == APV_CHROMA_FORMAT_422 && bit_depth == 10;
case AV_PROFILE_APV_422_12:
return chroma_format_idc == APV_CHROMA_FORMAT_422 &&
bit_depth >= 10 && bit_depth <= 12;
case AV_PROFILE_APV_444_10:
return chroma_format_idc >= APV_CHROMA_FORMAT_422 &&
chroma_format_idc <= APV_CHROMA_FORMAT_444 &&
bit_depth == 10;
case AV_PROFILE_APV_444_12:
return chroma_format_idc >= APV_CHROMA_FORMAT_422 &&
chroma_format_idc <= APV_CHROMA_FORMAT_444 &&
bit_depth >= 10 && bit_depth <= 12;
case AV_PROFILE_APV_4444_10:
return chroma_format_idc >= APV_CHROMA_FORMAT_422 &&
chroma_format_idc <= APV_CHROMA_FORMAT_4444 &&
bit_depth == 10;
case AV_PROFILE_APV_4444_12:
return chroma_format_idc >= APV_CHROMA_FORMAT_422 &&
chroma_format_idc <= APV_CHROMA_FORMAT_4444 &&
bit_depth >= 10 && bit_depth <= 12;
case AV_PROFILE_APV_400_10:
return chroma_format_idc == APV_CHROMA_FORMAT_400 && bit_depth == 10;
default:
return 0;
}
}
static int validate_profile(AVCodecContext *avctx, int profile)
{
const int minimum = get_min_profile(avctx->pix_fmt);
const char *profile_name = av_get_profile_name(avctx->codec, profile);
const char *minimum_name = av_get_profile_name(avctx->codec, minimum);
if (!profile_is_compatible(avctx->pix_fmt, profile)) {
av_log(avctx, AV_LOG_ERROR,
"Profile %s (%d) is incompatible with pixel format %s; minimum compatible profile is %s (%d)\n",
profile_name ? profile_name : "unknown", profile,
av_get_pix_fmt_name(avctx->pix_fmt),
minimum_name ? minimum_name : "unknown", minimum);
return AVERROR(EINVAL);
}
return 0;
}
static oapv_imgb_t *apv_imgb_create(AVCodecContext *avctx)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
@@ -180,22 +293,12 @@ fail:
}
/**
* The function returns a pointer to the object of the oapve_cdesc_t type.
* oapve_cdesc_t contains all encoder parameters that should be initialized before the encoder is used.
* Populate the liboapv configuration from AVCodecContext and encoder options.
*
* The field values of the oapve_cdesc_t structure are populated based on:
* - the corresponding field values of the AvCodecConetxt structure,
* - the apv encoder specific option values,
*
* The order of processing input data and populating the apve_cdsc structure
* 1) first, the fields of the AVCodecContext structure corresponding to the provided input options are processed,
* (i.e -pix_fmt yuv422p -s:v 1920x1080 -r 30 -profile:v 0)
* 2) then apve-specific options added as AVOption to the apv AVCodec implementation
* (i.e -preset 0)
*
* Keep in mind that, there are options that can be set in different ways.
* In this case, please follow the above-mentioned order of processing.
* The most recent assignments overwrite the previous values.
* AVCodecContext fields are applied first, followed by liboapv private options
* and finally oapv-params. The APV profile defaults to the minimum profile
* implied by pix_fmt, and later overrides must remain compatible with that
* pixel format.
*
* @param[in] avctx codec context (AVCodecContext)
* @param[out] cdsc contains all APV encoder encoder parameters that should be initialized before the encoder is use
@@ -228,6 +331,13 @@ static int get_conf(AVCodecContext *avctx, oapve_cdesc_t *cdsc)
cdsc->param[FRM_IDX].fps_den = avctx->time_base.num;
}
cdsc->param[FRM_IDX].profile_idc = get_min_profile(avctx->pix_fmt);
if (avctx->profile != AV_PROFILE_UNKNOWN) {
ret = validate_profile(avctx, avctx->profile);
if (ret < 0)
return ret;
cdsc->param[FRM_IDX].profile_idc = avctx->profile;
}
cdsc->param[FRM_IDX].preset = apv->preset_id;
cdsc->param[FRM_IDX].qp = apv->qp;
if (avctx->bit_rate / 1000 > INT_MAX || avctx->rc_max_rate / 1000 > INT_MAX) {
@@ -275,6 +385,12 @@ static int get_conf(AVCodecContext *avctx, oapve_cdesc_t *cdsc)
av_log(avctx, AV_LOG_WARNING, "Error parsing option '%s = %s'.\n", en->key, en->value);
}
ret = validate_profile(avctx, cdsc->param[FRM_IDX].profile_idc);
if (ret < 0)
return ret;
avctx->profile = cdsc->param[FRM_IDX].profile_idc;
return 0;
}
@@ -426,7 +542,7 @@ static av_cold int liboapve_close(AVCodecContext *avctx)
{
ApvEncContext *apv = avctx->priv_data;
for (int i = 0; i < apv->num_frames; i++) {
for (int i = 0; i < apv->ifrms.num_frms; i++) {
if (apv->ifrms.frm[i].imgb != NULL)
apv->ifrms.frm[i].imgb->release(apv->ifrms.frm[i].imgb);
apv->ifrms.frm[i].imgb = NULL;
+13 -5
View File
@@ -225,7 +225,8 @@ static int magy_decode_slice10(AVCodecContext *avctx, void *tdata,
s->llviddsp.add_left_pred_int16(dst, dst, max, width, 0);
dst += stride;
}
lefttop = left = dst[0];
if (1 + interlaced < height)
lefttop = left = dst[0];
for (k = 1 + interlaced; k < height; k++) {
magicyuv_median_pred16(dst, dst - fake_stride, dst, width, &left, &lefttop, max);
lefttop = left = dst[0];
@@ -553,6 +554,13 @@ static int magy_decode_frame(AVCodecContext *avctx, AVFrame *p,
"invalid slice height: %d\n", s->slice_height);
return AVERROR_INVALIDDATA;
}
if (s->vshift[1] && (s->slice_height & ((1 << s->vshift[1]) - 1))) {
av_log(avctx, AV_LOG_ERROR,
"slice_height %d is not aligned to chroma vertical "
"subsampling (must be a multiple of %d)\n",
s->slice_height, 1 << s->vshift[1]);
return AVERROR_INVALIDDATA;
}
bytestream2_skipu(&gb, 4);
@@ -563,11 +571,11 @@ static int magy_decode_frame(AVCodecContext *avctx, AVFrame *p,
return AVERROR_INVALIDDATA;
}
if ((s->slice_height >> s->vshift[1]) <= s->interlaced) {
av_log(avctx, AV_LOG_ERROR, "impossible slice height\n");
return AVERROR_INVALIDDATA;
}
if (s->interlaced) {
if ((s->slice_height >> s->vshift[1]) < 2) {
av_log(avctx, AV_LOG_ERROR, "impossible slice height\n");
return AVERROR_INVALIDDATA;
}
if ((avctx->coded_height % s->slice_height) && ((avctx->coded_height % s->slice_height) >> s->vshift[1]) < 2) {
av_log(avctx, AV_LOG_ERROR, "impossible height\n");
return AVERROR_INVALIDDATA;
+6
View File
@@ -57,6 +57,12 @@ static av_cold int misc4_init(AVCodecContext *avctx)
{
MISC4Context *s = avctx->priv_data;
if (avctx->sample_rate <= 0)
return AVERROR_INVALIDDATA;
if (avctx->ch_layout.nb_channels != 1 && avctx->ch_layout.nb_channels != 2)
return AVERROR_INVALIDDATA;
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
switch (avctx->sample_rate) {
case 8000:
+3
View File
@@ -1453,6 +1453,7 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s)
int linesize[MAX_COMPONENTS];
GetBitContext mb_bitmask_gb = {0}; // initialize to silence gcc warning
int bytes_per_pixel = 1 + (s->bits > 8);
int field_pos = -1;
int ret;
if (s->avctx->codec_id == AV_CODEC_ID_MXPEG) {
@@ -1586,9 +1587,11 @@ next_field:
if (s->interlaced &&
bytestream2_get_bytes_left(&s->gB) > 2 &&
bytestream2_tell(&s->gB) > 2 &&
bytestream2_tell(&s->gB) != field_pos &&
s->gB.buffer[-2] == 0xFF &&
s->gB.buffer[-1] == 0xD1) {
av_log(s->avctx, AV_LOG_DEBUG, "AVRn interlaced picture marker found\n");
field_pos = bytestream2_tell(&s->gB);
s->bottom_field ^= 1;
goto next_field;
+11 -3
View File
@@ -65,6 +65,9 @@ static int rle_uncompress(GetByteContext *gb, PutByteContext *pb, GetByteContext
} else if (run == 255) {
int pos = bytestream2_tell_p(pb);
if (!gbp)
return AVERROR_INVALIDDATA;
bytestream2_seek(gbp, pos, SEEK_SET);
if (pos + width - w < fill)
@@ -128,11 +131,16 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
return ret;
bytestream2_init(&gb, s->decomp_buf, zstream->total_out);
bytestream2_init(&gbp, s->prev_frame->data[0], avctx->height * s->prev_frame->linesize[0]);
if (s->prev_frame->data[0])
bytestream2_init(&gbp, s->prev_frame->data[0], avctx->height * s->prev_frame->linesize[0]);
bytestream2_init_writer(&pb, frame->data[0], avctx->height * frame->linesize[0]);
if (rle_uncompress(&gb, &pb, &gbp, avctx->width, avctx->height, avctx->width * 3,
frame->linesize[0], s->prev_frame->linesize[0]))
ret = rle_uncompress(&gb, &pb, s->prev_frame->data[0] ? &gbp : NULL,
avctx->width, avctx->height, avctx->width * 3,
frame->linesize[0], s->prev_frame->linesize[0]);
if (ret < 0)
return ret;
if (ret)
frame->flags |= AV_FRAME_FLAG_KEY;
else
frame->flags &= ~AV_FRAME_FLAG_KEY;
+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);
}
+8 -1
View File
@@ -263,8 +263,10 @@ static void nvenc_map_preset(NvencContext *ctx)
static void nvenc_print_driver_requirement(AVCodecContext *avctx, int level)
{
#if NVENCAPI_CHECK_VERSION(13, 1)
#if NVENCAPI_CHECK_VERSION(13, 2)
const char *minver = "(unknown)";
#elif NVENCAPI_CHECK_VERSION(13, 1)
const char *minver = "610.00";
#elif NVENCAPI_CHECK_VERSION(13, 0)
const char *minver = "570.0";
#elif NVENCAPI_CHECK_VERSION(12, 2)
@@ -2526,7 +2528,12 @@ static void nvenc_fill_time_code(AVCodecContext *avctx, const AVFrame *frame, NV
unsigned hh, mm, ss, ff, drop;
ff_timecode_set_smpte(&drop, &hh, &mm, &ss, &ff, avctx->framerate, tc[i + 1], 0, 0);
#ifdef NVENC_NEW_COUNTING_TYPE
time_code->clockTimestamp[i].countingTypeLSB = 0;
time_code->clockTimestamp[i].countingTypeMSB = 0;
#else
time_code->clockTimestamp[i].countingType = 0;
#endif
time_code->clockTimestamp[i].discontinuityFlag = 0;
time_code->clockTimestamp[i].cntDroppedFrames = drop;
time_code->clockTimestamp[i].nFrames = ff;
+5
View File
@@ -111,6 +111,11 @@ typedef void ID3D11Device;
#define NVENC_HAVE_MVHEVC
#endif
// SDK 13.1 compile time feature checks
#if NVENCAPI_CHECK_VERSION(13, 1)
#define NVENC_NEW_COUNTING_TYPE
#endif
typedef struct NvencSurface
{
NV_ENC_INPUT_PTR input_surface;
+6
View File
@@ -866,6 +866,12 @@ static int on2avc_decode_frame(AVCodecContext * avctx, AVFrame *frame,
av_log(avctx, AV_LOG_ERROR, "No subframes present\n");
return AVERROR_INVALIDDATA;
}
if (num_frames > INT_MAX / ON2AVC_SUBFRAME_SIZE) {
av_log(avctx, AV_LOG_ERROR,
"Too many subframes (%d); per-frame sample count overflows\n",
num_frames);
return AVERROR_INVALIDDATA;
}
/* get output buffer */
frame->nb_samples = ON2AVC_SUBFRAME_SIZE * num_frames;
+2
View File
@@ -291,7 +291,9 @@ static const AVOption avcodec_options[] = {
{"bt709", "BT.709", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_BT709 }, INT_MIN, INT_MAX, V|E|D, .unit = "color_trc_type"},
{"unknown", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, .unit = "color_trc_type"},
{"gamma22", "BT.470 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_GAMMA22 }, INT_MIN, INT_MAX, V|E|D, .unit = "color_trc_type"},
{"bt470m", "BT.470 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_GAMMA22 }, INT_MIN, INT_MAX, V|E|D, .unit = "color_trc_type"},
{"gamma28", "BT.470 BG", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_GAMMA28 }, INT_MIN, INT_MAX, V|E|D, .unit = "color_trc_type"},
{"bt470bg", "BT.470 BG", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_GAMMA28 }, INT_MIN, INT_MAX, V|E|D, .unit = "color_trc_type"},
{"smpte170m", "SMPTE 170 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_SMPTE170M }, INT_MIN, INT_MAX, V|E|D, .unit = "color_trc_type"},
{"smpte240m", "SMPTE 240 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_SMPTE240M }, INT_MIN, INT_MAX, V|E|D, .unit = "color_trc_type"},
{"linear", "Linear", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_LINEAR }, INT_MIN, INT_MAX, V|E|D, .unit = "color_trc_type"},
+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;
+5
View File
@@ -414,6 +414,11 @@ static int decode_frame(AVCodecContext *avctx,
/* Flags */
int flags = bytestream2_get_be16(&gb_hdr);
int align = (flags >> 1) & 0x7;
if (align > 4) {
av_log(avctx, AV_LOG_ERROR,
"Invalid tile alignment %d (max 4)\n", align);
return AVERROR_INVALIDDATA;
}
/* Quantization matrix */
if (flags & 1)
+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);
+2 -1
View File
@@ -415,8 +415,9 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
H263DecContext *const h = &rv->h;
int mb_count, mb_pos, left, start_mb_x, active_bits_size, ret;
if ((ret = init_get_bits8(&h->gb, buf, FFMAX(buf_size, buf_size2))) < 0)
return ret;
active_bits_size = buf_size * 8;
init_get_bits(&h->gb, buf, FFMAX(buf_size, buf_size2) * 8);
if (h->c.codec_id == AV_CODEC_ID_RV10)
mb_count = rv10_decode_picture_header(h);
else
+8 -3
View File
@@ -1427,7 +1427,9 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
int mb_pos, slice_type;
int res;
init_get_bits(gb, buf, buf_size*8);
res = init_get_bits8(gb, buf, buf_size);
if (res < 0)
return res;
res = r->parse_slice_header(r, gb, &r->si);
if(res < 0){
av_log(s->avctx, AV_LOG_ERROR, "Incorrect or unknown slice header\n");
@@ -1647,7 +1649,8 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict,
av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");
return AVERROR_INVALIDDATA;
}
init_get_bits(&r->gb, buf+offset, (buf_size-offset)*8);
if ((ret = init_get_bits8(&r->gb, buf+offset, buf_size-offset)) < 0)
return ret;
if (r->parse_slice_header(r, &r->gb, &si) < 0 || si.start) {
av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n");
return AVERROR_INVALIDDATA;
@@ -1777,7 +1780,9 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict,
av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");
break;
}
init_get_bits(&r->gb, buf+offset1, (buf_size-offset1)*8);
ret = init_get_bits8(&r->gb, buf+offset1, buf_size-offset1);
if (ret < 0)
return ret;
if (r->parse_slice_header(r, &r->gb, &si) < 0) {
size = offset2 - offset;
}else
+6
View File
@@ -1228,6 +1228,9 @@ static int old_codec37(SANMVideoContext *ctx, GetByteContext *gb, int top, int l
if (width > ctx->aligned_width)
return AVERROR_INVALIDDATA;
if (FFALIGN(height, 4) > ctx->aligned_height)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(gb) < 16)
return AVERROR_INVALIDDATA;
@@ -1551,6 +1554,9 @@ static int old_codec47(SANMVideoContext *ctx, GetByteContext *gb, int top, int l
if (width > ctx->aligned_width)
return AVERROR_INVALIDDATA;
if (FFALIGN(height, 8) > ctx->aligned_height)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(gb) < 26)
return AVERROR_INVALIDDATA;
+15 -9
View File
@@ -705,13 +705,15 @@ static int get_dc(SnowEncContext *enc, int mb_x, int mb_y, int plane_index)
for(y2= FFMAX(y, 0); y2<FFMIN(h, y+block_h); y2++){
for(x2= FFMAX(x, 0); x2<FFMIN(w, x+block_w); x2++){
int index= x2-(block_w*mb_x - block_w/2) + (y2-(block_h*mb_y - block_h/2))*obmc_stride;
int col= x2-(block_w*mb_x - block_w/2);
int row= y2-(block_h*mb_y - block_h/2);
int index= col + row*obmc_stride;
int obmc_v= obmc[index];
int d;
if(y<0) obmc_v += obmc[index + block_h*obmc_stride];
if(x<0) obmc_v += obmc[index + block_w];
if(y+block_h>h) obmc_v += obmc[index - block_h*obmc_stride];
if(x+block_w>w) obmc_v += obmc[index - block_w];
if(y<0) obmc_v += obmc[index + block_h*obmc_stride];
if(x<0) obmc_v += obmc[index + block_w];
if(y+block_h>h && row-block_h >= 0) obmc_v += obmc[index - block_h*obmc_stride];
if(x+block_w>w && col-block_w >= 0) obmc_v += obmc[index - block_w];
//FIXME precalculate this or simplify it somehow else
d = -dst[index] + (1<<(FRAC_BITS-1));
@@ -723,6 +725,9 @@ static int get_dc(SnowEncContext *enc, int mb_x, int mb_y, int plane_index)
}
*b= backup;
if (!aa)
return 0;
return av_clip_uint8( ROUNDED_DIV((int64_t)ab<<LOG2_OBMC_MAX, aa) ); //FIXME we should not need clipping
}
@@ -820,13 +825,14 @@ static int get_block_rd(SnowEncContext *enc, int mb_x, int mb_y,
&& (mb_x == 0 || mb_x == b_stride-1)
&& (mb_y == 0 || mb_y == b_height-1)){
if(mb_x == 0)
x1 = block_w;
x1 = FFMIN(x1, block_w);
else
x0 = block_w;
x0 = FFMAX(x0, block_w);
if(mb_y == 0)
y1 = block_h;
y1 = FFMIN(y1, block_h);
else
y0 = block_h;
y0 = FFMAX(y0, block_h);
x0 = FFMIN(x0, x1);
for(y=y0; y<y1; y++)
memcpy(dst + sx+x0 + (sy+y)*ref_stride, cur + x0 + y*ref_stride, x1-x0);
}
+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;
+7 -4
View File
@@ -127,6 +127,7 @@ static av_cold int tdsc_init(AVCodecContext *avctx)
ctx->jpeg_avctx->flags = avctx->flags;
ctx->jpeg_avctx->flags2 = avctx->flags2;
ctx->jpeg_avctx->idct_algo = avctx->idct_algo;
ctx->jpeg_avctx->max_pixels = avctx->max_pixels;
ret = avcodec_open2(ctx->jpeg_avctx, NULL, NULL);
if (ret < 0)
return ret;
@@ -240,7 +241,6 @@ static int tdsc_load_cursor(AVCodecContext *avctx)
bits <<= 1;
}
}
dst += ctx->cursor_stride - ctx->cursor_w * 4;
}
dst = ctx->cursor;
@@ -272,7 +272,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 +357,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 +402,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 +435,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,
+5
View File
@@ -323,6 +323,11 @@ static int truespeech_decode_frame(AVCodecContext *avctx, AVFrame *frame,
"Too small input buffer (%d bytes), need at least 32 bytes\n", buf_size);
return -1;
}
if (iterations > INT_MAX / 240) {
av_log(avctx, AV_LOG_ERROR,
"Too large input buffer (%d bytes); per-block sample count overflows\n", buf_size);
return AVERROR_INVALIDDATA;
}
/* get output buffer */
frame->nb_samples = iterations * 240;
+33 -33
View File
@@ -56,7 +56,7 @@ static void vc2_subband_dwt_97(VC2TransformContext *t, dwtcoef *data,
ptrdiff_t stride, int width, int height)
{
int x, y;
dwtcoef *datal = data, *synth = t->buffer, *synthl = synth;
uint32_t *datal = (uint32_t *)data, *synth = (uint32_t *)t->buffer, *synthl = synth;
const ptrdiff_t synth_width = width << 1;
const ptrdiff_t synth_height = height << 1;
@@ -75,21 +75,21 @@ static void vc2_subband_dwt_97(VC2TransformContext *t, dwtcoef *data,
synthl = synth;
for (y = 0; y < synth_height; y++) {
/* Lifting stage 2. */
synthl[1] -= (8*synthl[0] + 9*synthl[2] - synthl[4] + 8) >> 4;
synthl[1] -= (dwtcoef)(8*synthl[0] + 9*synthl[2] - synthl[4] + 8) >> 4;
for (x = 1; x < width - 2; x++)
synthl[2*x + 1] -= (9*synthl[2*x] + 9*synthl[2*x + 2] - synthl[2*x + 4] -
synthl[2*x + 1] -= (dwtcoef)(9*synthl[2*x] + 9*synthl[2*x + 2] - synthl[2*x + 4] -
synthl[2 * x - 2] + 8) >> 4;
synthl[synth_width - 1] -= (17*synthl[synth_width - 2] -
synthl[synth_width - 1] -= (dwtcoef)(17*synthl[synth_width - 2] -
synthl[synth_width - 4] + 8) >> 4;
synthl[synth_width - 3] -= (8*synthl[synth_width - 2] +
synthl[synth_width - 3] -= (dwtcoef)(8*synthl[synth_width - 2] +
9*synthl[synth_width - 4] -
synthl[synth_width - 6] + 8) >> 4;
/* Lifting stage 1. */
synthl[0] += (synthl[1] + synthl[1] + 2) >> 2;
synthl[0] += (dwtcoef)(synthl[1] + synthl[1] + 2) >> 2;
for (x = 1; x < width - 1; x++)
synthl[2*x] += (synthl[2*x - 1] + synthl[2*x + 1] + 2) >> 2;
synthl[2*x] += (dwtcoef)(synthl[2*x - 1] + synthl[2*x + 1] + 2) >> 2;
synthl[synth_width - 2] += (synthl[synth_width - 3] +
synthl[synth_width - 2] += (dwtcoef)(synthl[synth_width - 3] +
synthl[synth_width - 1] + 2) >> 2;
synthl += synth_width;
}
@@ -97,13 +97,13 @@ static void vc2_subband_dwt_97(VC2TransformContext *t, dwtcoef *data,
/* Vertical synthesis: Lifting stage 2. */
synthl = synth + synth_width;
for (x = 0; x < synth_width; x++)
synthl[x] -= (8*synthl[x - synth_width] + 9*synthl[x + synth_width] -
synthl[x] -= (dwtcoef)(8*synthl[x - synth_width] + 9*synthl[x + synth_width] -
synthl[x + 3 * synth_width] + 8) >> 4;
synthl = synth + (synth_width << 1);
for (y = 1; y < height - 2; y++) {
for (x = 0; x < synth_width; x++)
synthl[x + synth_width] -= (9*synthl[x] +
synthl[x + synth_width] -= (dwtcoef)(9*synthl[x] +
9*synthl[x + 2 * synth_width] -
synthl[x - 2 * synth_width] -
synthl[x + 4 * synth_width] + 8) >> 4;
@@ -112,36 +112,36 @@ static void vc2_subband_dwt_97(VC2TransformContext *t, dwtcoef *data,
synthl = synth + (synth_height - 1) * synth_width;
for (x = 0; x < synth_width; x++) {
synthl[x] -= (17*synthl[x - synth_width] -
synthl[x] -= (dwtcoef)(17*synthl[x - synth_width] -
synthl[x - 3*synth_width] + 8) >> 4;
synthl[x - 2*synth_width] -= (9*synthl[x - 3*synth_width] +
synthl[x - 2*synth_width] -= (dwtcoef)(9*synthl[x - 3*synth_width] +
8*synthl[x - 1*synth_width] - synthl[x - 5*synth_width] + 8) >> 4;
}
/* Vertical synthesis: Lifting stage 1. */
synthl = synth;
for (x = 0; x < synth_width; x++)
synthl[x] += (synthl[x + synth_width] + synthl[x + synth_width] + 2) >> 2;
synthl[x] += (dwtcoef)(synthl[x + synth_width] + synthl[x + synth_width] + 2) >> 2;
synthl = synth + (synth_width << 1);
for (y = 1; y < height - 1; y++) {
for (x = 0; x < synth_width; x++)
synthl[x] += (synthl[x - synth_width] + synthl[x + synth_width] + 2) >> 2;
synthl[x] += (dwtcoef)(synthl[x - synth_width] + synthl[x + synth_width] + 2) >> 2;
synthl += synth_width << 1;
}
synthl = synth + (synth_height - 2) * synth_width;
for (x = 0; x < synth_width; x++)
synthl[x] += (synthl[x - synth_width] + synthl[x + synth_width] + 2) >> 2;
synthl[x] += (dwtcoef)(synthl[x - synth_width] + synthl[x + synth_width] + 2) >> 2;
deinterleave(data, stride, width, height, synth);
deinterleave(data, stride, width, height, (dwtcoef *)synth);
}
static void vc2_subband_dwt_53(VC2TransformContext *t, dwtcoef *data,
ptrdiff_t stride, int width, int height)
{
int x, y;
dwtcoef *synth = t->buffer, *synthl = synth, *datal = data;
uint32_t *synth = (uint32_t *)t->buffer, *synthl = synth, *datal = (uint32_t *)data;
const ptrdiff_t synth_width = width << 1;
const ptrdiff_t synth_height = height << 1;
@@ -161,16 +161,16 @@ static void vc2_subband_dwt_53(VC2TransformContext *t, dwtcoef *data,
for (y = 0; y < synth_height; y++) {
/* Lifting stage 2. */
for (x = 0; x < width - 1; x++)
synthl[2 * x + 1] -= (synthl[2 * x] + synthl[2 * x + 2] + 1) >> 1;
synthl[2 * x + 1] -= (dwtcoef)(synthl[2 * x] + synthl[2 * x + 2] + 1) >> 1;
synthl[synth_width - 1] -= (2*synthl[synth_width - 2] + 1) >> 1;
synthl[synth_width - 1] -= (dwtcoef)(2*synthl[synth_width - 2] + 1) >> 1;
/* Lifting stage 1. */
synthl[0] += (2*synthl[1] + 2) >> 2;
synthl[0] += (dwtcoef)(2*synthl[1] + 2) >> 2;
for (x = 1; x < width - 1; x++)
synthl[2 * x] += (synthl[2 * x - 1] + synthl[2 * x + 1] + 2) >> 2;
synthl[2 * x] += (dwtcoef)(synthl[2 * x - 1] + synthl[2 * x + 1] + 2) >> 2;
synthl[synth_width - 2] += (synthl[synth_width - 3] + synthl[synth_width - 1] + 2) >> 2;
synthl[synth_width - 2] += (dwtcoef)(synthl[synth_width - 3] + synthl[synth_width - 1] + 2) >> 2;
synthl += synth_width;
}
@@ -178,37 +178,37 @@ static void vc2_subband_dwt_53(VC2TransformContext *t, dwtcoef *data,
/* Vertical synthesis: Lifting stage 2. */
synthl = synth + synth_width;
for (x = 0; x < synth_width; x++)
synthl[x] -= (synthl[x - synth_width] + synthl[x + synth_width] + 1) >> 1;
synthl[x] -= (dwtcoef)(synthl[x - synth_width] + synthl[x + synth_width] + 1) >> 1;
synthl = synth + (synth_width << 1);
for (y = 1; y < height - 1; y++) {
for (x = 0; x < synth_width; x++)
synthl[x + synth_width] -= (synthl[x] + synthl[x + synth_width * 2] + 1) >> 1;
synthl[x + synth_width] -= (dwtcoef)(synthl[x] + synthl[x + synth_width * 2] + 1) >> 1;
synthl += (synth_width << 1);
}
synthl = synth + (synth_height - 1) * synth_width;
for (x = 0; x < synth_width; x++)
synthl[x] -= (2*synthl[x - synth_width] + 1) >> 1;
synthl[x] -= (dwtcoef)(2*synthl[x - synth_width] + 1) >> 1;
/* Vertical synthesis: Lifting stage 1. */
synthl = synth;
for (x = 0; x < synth_width; x++)
synthl[x] += (2*synthl[synth_width + x] + 2) >> 2;
synthl[x] += (dwtcoef)(2*synthl[synth_width + x] + 2) >> 2;
synthl = synth + (synth_width << 1);
for (y = 1; y < height - 1; y++) {
for (x = 0; x < synth_width; x++)
synthl[x] += (synthl[x + synth_width] + synthl[x - synth_width] + 2) >> 2;
synthl[x] += (dwtcoef)(synthl[x + synth_width] + synthl[x - synth_width] + 2) >> 2;
synthl += (synth_width << 1);
}
synthl = synth + (synth_height - 2)*synth_width;
for (x = 0; x < synth_width; x++)
synthl[x] += (synthl[x - synth_width] + synthl[x + synth_width] + 2) >> 2;
synthl[x] += (dwtcoef)(synthl[x - synth_width] + synthl[x + synth_width] + 2) >> 2;
deinterleave(data, stride, width, height, synth);
deinterleave(data, stride, width, height, (dwtcoef *)synth);
}
static av_always_inline void dwt_haar(VC2TransformContext *t, dwtcoef *data,
@@ -216,7 +216,7 @@ static av_always_inline void dwt_haar(VC2TransformContext *t, dwtcoef *data,
const int s)
{
int x, y;
dwtcoef *synth = t->buffer, *synthl = synth, *datal = data;
uint32_t *synth = (uint32_t *)t->buffer, *synthl = synth, *datal = (uint32_t *)data;
const ptrdiff_t synth_width = width << 1;
const ptrdiff_t synth_height = height << 1;
@@ -225,7 +225,7 @@ static av_always_inline void dwt_haar(VC2TransformContext *t, dwtcoef *data,
for (x = 0; x < synth_width; x += 2) {
synthl[y*synth_width + x + 1] = (datal[y*stride + x + 1] - datal[y*stride + x]) * (1 << s);
synthl[y*synth_width + x] = datal[y*stride + x + 0] * (1 << s) +
((synthl[y*synth_width + x + 1] + 1) >> 1);
((dwtcoef)(synthl[y*synth_width + x + 1] + 1) >> 1);
}
}
@@ -235,11 +235,11 @@ static av_always_inline void dwt_haar(VC2TransformContext *t, dwtcoef *data,
synthl[(y + 1)*synth_width + x] = synthl[(y + 1)*synth_width + x] -
synthl[y*synth_width + x];
synthl[y*synth_width + x] = synthl[y*synth_width + x] +
((synthl[(y + 1)*synth_width + x] + 1) >> 1);
((dwtcoef)(synthl[(y + 1)*synth_width + x] + 1) >> 1);
}
}
deinterleave(data, stride, width, height, synth);
deinterleave(data, stride, width, height, (dwtcoef *)synth);
}
static void vc2_subband_dwt_haar(VC2TransformContext *t, dwtcoef *data,
+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 102
#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;
@@ -871,6 +873,14 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext *
return AVERROR_EXTERNAL;
}
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);
}
err = init_rc(avctx, ctx);
if (err < 0)
return err;
@@ -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;

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