Commit Graph

115606 Commits

Author SHA1 Message Date
Lynne
91fd6ca000
lavc: bump minor and add APIchanges entry for new USAC profile 2024-06-08 00:22:36 +02:00
Lynne
1c066867df
aac: define a new profile for USAC
This allows users to determine whether a stream is USAC or not.
2024-06-08 00:22:35 +02:00
Lynne
ee419804da
mpeg4audio: explicitly define each AOT
This makes it far easier to figure out which AOT belongs to which
profile.
Also, explicitly highlight the holes.
2024-06-08 00:22:35 +02:00
Lynne
8a2fe8a5b9
mpeg4audio: rename AOT_USAC_NOSBR to AOT_USAC
The issue is that AOT 45 isn't defined anywhere, and looking at the git
blame, it seems to have sprung up through a reordering of the enum,
and adding a hole.

The spec does not define an explicit AOT for SBR and no SBR, and only
uses AOT 42 (previously AOT_USAC_NOSBR), so just rename AOT_USAC to
it and replace its use everywhere.
2024-06-08 00:22:31 +02:00
Michael Niedermayer
840f2bc18e
fftools/ffmpeg_mux_init: Free pts on error
Fixes: CID1538863 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:26 +02:00
Michael Niedermayer
d9b9fc4be2
fftools/cmdutils: Add protective () to FLAGS
issue found while reviewing CID1452612 Free of array-typed value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:26 +02:00
Michael Niedermayer
5b82852519
avformat/sdp: Check before appending ","
Found by reviewing code related to CID1500301 String not null terminated

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:25 +02:00
Kacper Michajłow
a3d3a58026
avformat/rpl: reject invalid sample rate
Fixes overflow check for bit_rate multiplication few lines below.

Found by OSS-Fuzz.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:25 +02:00
Michael Niedermayer
dce69ba89e
avcodec/libx264: Check init_get_bits8() return code
Fixes: CID1594529 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:25 +02:00
Michael Niedermayer
8a64a003b5
avcodec/ilbcdec: Remove dead code
Yes the same dead code is in "iLBC Speech Coder ANSI-C Source Code"

Fixes: CID1509370 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:24 +02:00
Michael Niedermayer
9b76e49061
avcodec/vp8: Check cond init
Fixes: CID1598563 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:24 +02:00
Michael Niedermayer
4ac7405aaf
avcodec/vp8: Check mutex init
Fixes: CID1598556 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:24 +02:00
Gerion Entrup
300df41c30
libavfilter/signature_lookup: fix jaccard distance
Actually, the jaccard distance is defined as D = 1 - intersect / union.
Additionally, the distance value is compared against a constant that
must be between 0 and 1, which is not the case here. Both facts together
has led to the fact, that the function always returned a matching course
signature. To leave the constant intact and to avoid floating point
computation, this commit multiplies with 1 << 16 making the constant
effectively 9000 / (1<<16) =~ 0.14.

Reported-by: Sachin Tilloo <sachin.tilloo@gmail.com>
Reviewed-by: Sachin Tilloo <sachin.tilloo@gmail.com>
Tested-by: Sachin Tilloo <sachin.tilloo@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:23 +02:00
Rémi Denis-Courmont
3152c684cb lavc/vc1dsp: R-V V vc1_inv_trans_4x4
T-Head C908 (cycles):
vc1dsp.vc1_inv_trans_4x4_c: 310.7
vc1dsp.vc1_inv_trans_4x4_rvv_i32: 120.0

We could use 1 `vlseg4e64.v` instead of 4 `vle16.v`, but that seems to
be about 7% slower.
2024-06-07 17:53:05 +03:00
Rémi Denis-Courmont
6ffa639c8a lavc/vc1dsp: R-V V vc1_inv_trans_4x8
T-Head C908 (cycles):
vc1dsp.vc1_inv_trans_4x8_c: 653.2
vc1dsp.vc1_inv_trans_4x8_rvv_i32: 234.0
2024-06-07 17:53:05 +03:00
Rémi Denis-Courmont
a169f3bca5 lavc/vc1dsp: R-V V vc1_inv_trans_8x4
T-Head C908 (cycles):
vc1dsp.vc1_inv_trans_8x4_c:       626.2
vc1dsp.vc1_inv_trans_8x4_rvv_i32: 215.2
2024-06-07 17:53:05 +03:00
Rémi Denis-Courmont
04397a29de lavc/vc1dsp: R-V V vc1_inv_trans_8x8
T-Head C908 (cycles):
vc1dsp.vc1_inv_trans_8x8_c:       871.7
vc1dsp.vc1_inv_trans_8x8_rvv_i32: 286.7
2024-06-07 17:53:05 +03:00
Rémi Denis-Courmont
8d117024fe checkasm: disable unaligned access emulation
The OS may silently fix (emulate) unaligned hardware access exceptions.
This is extremely slow and code should be fixed not to rely on unaligned
access on affected hardware. Accordingly this requests that the OS
disable emulation and instead throw Bus error, which will be caught by
checkasm's signal handler.

This has no effects if the hardware supports unaligned access in
hardware, since no exceptions are generated. prctl() will fail safe in
that case.
2024-06-07 17:53:05 +03:00
Rémi Denis-Courmont
c3dbbb316e lavc/flacdsp: fix sign extension in R-V V wasted33
We need to use either VWCVT.X.X.V or VSEXT.VF2. The later is preferable
to avoid changing VTYPE.
2024-06-07 17:53:05 +03:00
Ramiro Polla
5939f7228a libswscale/x86/yuv_2_rgb: fix some comments 2024-06-07 15:24:06 +02:00
Zhao Zhili
7d46ab9e12 avcodec/mediacodecenc: workaround the alignment requirement for H.265
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-06-07 13:14:46 +08:00
Zhao Zhili
2a68b2d643 avcodec/mediacodecenc: workaround the alignment requirement only for H.264
There is no bsf for other codecs to modify crop info except H.265.
For H.265, the assumption that FFALIGN(width, 16)xFFALIGN(height, 16)
is the video resolution can be wrong, since the encoder can use CTU
larger than 16x16. In that case, use FFALIGN(width, 16) - width
as crop_right is incorrect. So disable the workaround for H.265 now.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-06-07 13:14:46 +08:00
Zhao Zhili
680b3cee1f avcodec/h265_metadata: Add options to set width/height after crop
It's a common usecase to request a video size after crop. Before
this patch, user must know the video size before crop, then set
crop_right/crop_bottom accordingly. Since HEVC can have different
CTU size, it's not easy to get/deduce the video size before crop.
With the new width/height options, there is no such requirement.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-06-07 13:14:46 +08:00
Gyan Doshi
d55f5cba7b avfilter/trim: flag trim filter as metadata only
Similar to select filter for video - it can only pass through or drop frames
2024-06-06 15:09:45 +05:30
Zhao Zhili
47ba87551c checkasm/sw_rgb: test rgb24/bgr24 to yuv
The line width 8 is supposed to test corner case, while the
performance doesn't matter. Width 1080 is also a case of
unaligned to 16.

Width 1920 meant for benchmark (together with --runs options).

Signed-off-by: James Almer <jamrial@gmail.com>
2024-06-05 15:22:49 -03:00
Ramiro Polla
2d24a80e5e avcodec/mpegvideo_enc: give magic number a name 2024-06-05 19:39:36 +02:00
Ramiro Polla
01b1f4c9a5 libavcodec/libxvid: code cleanup (replace magic numbers) 2024-06-05 19:39:35 +02:00
Rémi Denis-Courmont
0415bb74c8 lavc/vp8dsp: remove no longer used macros 2024-06-04 17:42:07 +03:00
Rémi Denis-Courmont
121fb846b9 lavc/vp7dsp: add R-V V vp7_idct_dc_add4uv
This is almost the same story as vp7_idct_add4y. We just have to use
strided loads of 2 64-bit elements to account for the different data
layout in memory.

T-Head C908:
vp7_idct_dc_add4uv_c:       7.5
vp7_idct_dc_add4uv_rvv_i64: 2.0
vp8_idct_dc_add4uv_c:       6.2
vp8_idct_dc_add4uv_rvv_i32: 2.2 (before)
vp8_idct_dc_add4uv_rvv_i64: 2.0

SpacemiT X60:
vp7_idct_dc_add4uv_c:       6.7
vp7_idct_dc_add4uv_rvv_i64: 2.2
vp8_idct_dc_add4uv_c:       5.7
vp8_idct_dc_add4uv_rvv_i32: 2.5 (before)
vp8_idct_dc_add4uv_rvv_i64: 2.0
2024-06-04 17:42:07 +03:00
Rémi Denis-Courmont
225de53c9d lavc/vp8dsp: rework R-V V idct_dc_add4y
DCT-related FFmpeg functions often add an unsigned 8-bit sample to a
signed 16-bit coefficient, then clip the result back to an unsigned
8-bit value. RISC-V has no signed 16-bit to unsigned 8-bit clip, so
instead our most common sequence is:
    VWADDU.WV
    set SEW to 16 bits
    VMAX.VV zero     # clip negative values to 0
    set SEW to 8 bits
    VNCLIPU.WI       # clip values over 255 to 255 and narrow

Here we use a different sequence which does not require toggling the
vector type. This assumes that the wide addend vector is biased by
-128:
    VWADDU.WV
    VNCLIP.WI    # clip values to signed 8-bit and narrow
    VXOR.VX 0x80 # flip sign bit (convert signed to unsigned)

Also the VMAX is effectively replaced by a VXOR of half-width. In this
function, this comes for free as we anyway add a constant to the wide
vector in the prologue.

On C908, this has no observable effects. On X60, this improves
microbenchmarks by about 20%.
2024-06-04 17:42:07 +03:00
Rémi Denis-Courmont
4e120fbbbd lavc/vp8dsp: add R-V V vp7_idct_dc_add4y
As with idct_dc_add, most of the code is shared with, and replaces, the
previous VP8 function. To improve performance, we break down the 16x4
matrix into 4 rows, rather than 4 squares. Thus strided loads and
stores are avoided, and the 4 DC calculations are vectored.
Unfortunately this requires a vector gather to splat the DC values, but
overall this is still a win for performance:

T-Head C908:
vp7_idct_dc_add4y_c:       7.2
vp7_idct_dc_add4y_rvv_i32: 2.2
vp8_idct_dc_add4y_c:       6.2
vp8_idct_dc_add4y_rvv_i32: 2.2 (before)
vp8_idct_dc_add4y_rvv_i32: 1.7

SpacemiT X60:
vp7_idct_dc_add4y_c:       6.2
vp7_idct_dc_add4y_rvv_i32: 2.0
vp8_idct_dc_add4y_c:       5.5
vp8_idct_dc_add4y_rvv_i32: 2.5 (before)
vp8_idct_dc_add4y_rvv_i32: 1.7

I also tried to provision the DC values using indexed loads. It ends up
slower overall, especially for VP7, as we then have to compute 16 DC's
instead of just 4.
2024-06-04 17:40:41 +03:00
Rémi Denis-Courmont
30797e4ff6 lavc/vp8dsp: add R-V V vp7_idct_dc_add
This just computes the direct coefficient and hands over to code shared
with VP8. Accordingly the bulk of changes are just rewriting the VP8
code to share.

Nothing to write home about:
vp7_idct_dc_add_c:       1.7
vp7_idct_dc_add_rvv_i32: 1.2
2024-06-04 17:40:36 +03:00
Frank Plowman
d866f49791 lavc/vvc: Reallocate pixel buffers if pixel shift changes
Allocations in the following lines depend on the pixel shift, and so
these buffers must be reallocated if the pixel shift changes.  Patch
fixes segmentation faults in fuzzed bitstreams.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2024-06-04 20:13:47 +08:00
Anton Khirnov
9576a00527 lavc/hevcdec: drop unused HEVCContext.width/height 2024-06-04 11:46:27 +02:00
Anton Khirnov
a13b892080 lavc/hevcdec: deduplicate calling hwaccel decode_params() 2024-06-04 11:46:27 +02:00
Anton Khirnov
e4601cc339 lavc/hevc*: move to hevc/ subdir 2024-06-04 11:46:27 +02:00
Anton Khirnov
ba56a300a9 lavc/hevcdec: drop HEVCContext.frame
It is merely a redundant pointer to cur_frame->f
2024-06-04 11:46:27 +02:00
Anton Khirnov
db84c1c6ef lavc/hevcdec: rename HEVCFrame.frame to just f
This is shorter, loses no information, and is consistent with other
similar structs.
2024-06-04 11:46:23 +02:00
Anton Khirnov
9226514ced lavc/hevcdec: rename HEVCContext.ref to cur_frame
Since it stores a pointer to the current frame.
2024-06-04 11:44:37 +02:00
Anton Khirnov
7ad9400952 lavc/hevcdec: drop HEVCContext.HEVClc
It is merely a pointer to local_ctx[0], which we can just as well use
directly.
2024-06-04 11:36:51 +02:00
Anton Khirnov
67ca18dd56 lavc/hevcdec: drop HEVCLocalContext.gb
In all HEVCLocalContext instances except the first one, the bitreader is
never used for actually reading bits, but merely for passing the buffer
to ff_init_cabac_decoder(), which is better done directly.

The instance that actually is used for bitreading gets moved to stack in
decode_nal_unit(), which makes its lifetime clearer.
2024-06-04 11:36:51 +02:00
Anton Khirnov
ac69e6caf6 lavc/hevcdec: include first row in SliceHeader.offset/size
Will be useful in the following commit.
2024-06-04 11:36:51 +02:00
Anton Khirnov
79c0310aca lavc/hevcdec: drop a useless condition
hls_slice_data_wpp() is only called when num_entry_point_offsets>0
2024-06-04 11:36:51 +02:00
Anton Khirnov
74159cbfc3 lavc/hevcdec: move handling of byte alignment at the end of slice header
Do it in hls_slice_header() rather than cabac_init_decoder() - the
former is a more logical place as according the spec the byte alignment
is a part of the slice header, not slice data. Avoids a second instance
of alignment handling in vaapi_hevc.

Also, check that alignment_bit_equal_to_one is, in fact, equal to one.
2024-06-04 11:36:51 +02:00
James Almer
a14440867c x86/float_dsp: add SSE2 and AVX versions of scalarproduct_double
Signed-off-by: James Almer <jamrial@gmail.com>
2024-06-03 22:14:55 -03:00
Lynne
7413b81e50
aacdec_usac: fix typo in debug message 2024-06-04 03:08:46 +02:00
Lynne
f4371029f8
aacdec_usac: fix off by one error check on channel numbers 2024-06-04 03:08:45 +02:00
Lynne
0d93e04bc6
aacdec_usac: error out on receiving too many channels for the current layout
Verify that we have a correct number of channels.
2024-06-04 03:08:45 +02:00
Lynne
39826eacff
aacdec_usac: error out on too many elements
USAC supports up to 64 audio channels, but puts no limit on the total
number of extensions that may be present. Which may mean that there's
a single audio channel, with 65 thousand extension elements.

We assume that 64 elements is the maximum for now. So check the value.
2024-06-04 03:08:44 +02:00
Lynne
b70fdbde9c
aacdec_usac: prevent get_bits(0) in get_escaped_value
Some calls to get_escaped_value() specify 0 bits as the third value.
This would result in get_bits(0), which is not a correct usage of the
get_bits API.
2024-06-04 03:08:39 +02:00