1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-02-09 14:14:39 +02:00

50869 Commits

Author SHA1 Message Date
Rémi Denis-Courmont
d8fb44c0aa lavc/mpegvideoencdsp: R-V V add_8x8basis
T-Head C908:
add_8x8basis_c:      440.6
add_8x8basis_rvv_i32: 70.3

SpacemiT X60:
add_8x8basis_c:      436.3
add_8x8basis_rvv_i32: 40.5
2024-08-19 22:41:13 +03:00
Rémi Denis-Courmont
1907dd7f23 lavc/mpegvideoencdsp: R-V V try_8x8basis
T-Head C908:
try_8x8basis_c:       922.5
try_8x8basis_rvv_i32: 135.3

SpacemiT X60:
try_8x8basis_c:       926.1
try_8x8basis_rvv_i32: 103.1
2024-08-19 22:41:13 +03:00
Rémi Denis-Courmont
0fd37c00d7 lavc/mpegvideoencdsp: R-V V pix_norm1
T-Head C908:
pix_norm1_c:       480.2
pix_norm1_rvv_i64: 146.9

SpacemiT X60:
pix_norm1_c:       478.2
pix_norm1_rvv_i64:  92.7
2024-08-19 22:41:13 +03:00
Rémi Denis-Courmont
63d016aea5 lavc/mpegvideoencdsp: R-V V pix_sum
T-Head C908:
pix_sum_c:      332.2
pix_sum_rvv_i64: 91.2

SpacemiT X60:
pix_sum_c:      321.2
pix_sum_rvv_i64: 60.9
2024-08-19 22:41:13 +03:00
Anton Khirnov
631a725670 lavc/hevcdec: call ff_thread_finish_setup() even if hwaccel is in use
Serializing frame threading for non-threadsafe hwaccels is handled at the
generic level, the decoder does not need to care about it.
2024-08-19 21:37:22 +02:00
Anton Khirnov
4b9adb35b6 lavc/hevcdec: simplify output logic
Current code is written around the "simple" decode API's limitation that
a single input packet (AU/coded frame) triggers the output of at most
one output frame. However the spec contains two cases where a coded
frame may cause multiple frames to be output (cf. C.5.2.2.2):
* start of a new sequence
* overflowing sps_max_dec_pic_buffering

The decoder currently contains rather convoluted logic to handle these
cases:
* decode/output/per-frame sequence counters,
* HEVC_FRAME_FLAG_BUMPING
* ff_hevc_bump_frame()
* special clauses in ff_hevc_output_frame()

However, with the receive_frame() API none of that is necessary, as we
can just output multiple frames at once. Previously added ContainerFifo
allows that to be done in a straightforward and efficient manner.
2024-08-19 21:37:22 +02:00
Anton Khirnov
79afc45c03 lavc/hevcdec: use a ContainerFifo to hold frames scheduled for output
Instead of a single AVFrame.

Will be useful in future commits, where we will want to produce multiple
output frames for a single coded frame.
2024-08-19 21:37:22 +02:00
Anton Khirnov
4bda7f288c lavc/videotoolbox: drop HEVC cropping from start_frame rather than end_frame
HEVCContext.output_frame will be removed in following commits.

Reported-By: Max Bykov
2024-08-19 21:37:22 +02:00
Anton Khirnov
6174818252 lavc: add private container FIFO API
It provides a FIFO for "container" objects like AVFrame/AVPacket and
features an integrated FFRefStructPool-based pool to avoid allocating an
freeing them repeatedly.
2024-08-19 21:37:22 +02:00
Anton Khirnov
2fdecbb239 lavc/hevcdec: switch to receive_frame()
Required by following commits, where we will want to output multiple
frames per packet.
2024-08-19 21:37:22 +02:00
sunyuechi
4e7b5ac48f lavc/vp9dsp: R-V V mc bilin hv
C908   X60
vp9_avg_bilin_4hv_8bpp_c                           :   10.7    9.5
vp9_avg_bilin_4hv_8bpp_rvv_i32                     :    4.0    3.5
vp9_avg_bilin_8hv_8bpp_c                           :   38.5   34.2
vp9_avg_bilin_8hv_8bpp_rvv_i32                     :    7.2    6.5
vp9_avg_bilin_16hv_8bpp_c                          :  147.2  130.5
vp9_avg_bilin_16hv_8bpp_rvv_i32                    :   14.5   12.7
vp9_avg_bilin_32hv_8bpp_c                          :  574.2  509.7
vp9_avg_bilin_32hv_8bpp_rvv_i32                    :   42.5   38.0
vp9_avg_bilin_64hv_8bpp_c                          : 2321.2 2017.7
vp9_avg_bilin_64hv_8bpp_rvv_i32                    :  163.5  131.0
vp9_put_bilin_4hv_8bpp_c                           :   10.0    8.7
vp9_put_bilin_4hv_8bpp_rvv_i32                     :    3.5    3.0
vp9_put_bilin_8hv_8bpp_c                           :   35.2   31.2
vp9_put_bilin_8hv_8bpp_rvv_i32                     :    6.5    5.7
vp9_put_bilin_16hv_8bpp_c                          :  134.0  119.0
vp9_put_bilin_16hv_8bpp_rvv_i32                    :   12.7   11.5
vp9_put_bilin_32hv_8bpp_c                          :  538.5  464.2
vp9_put_bilin_32hv_8bpp_rvv_i32                    :   39.7   35.2
vp9_put_bilin_64hv_8bpp_c                          : 2111.7 1833.2
vp9_put_bilin_64hv_8bpp_rvv_i32                    :  138.5  122.5

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
2024-08-19 22:29:20 +03:00
sunyuechi
9edd2e723b lavc/vp9dsp: R-V V mc bilin h v
C908   X60
vp9_avg_bilin_4h_8bpp_c                            :    5.5    4.7
vp9_avg_bilin_4h_8bpp_rvv_i32                      :    1.7    1.5
vp9_avg_bilin_4v_8bpp_c                            :    5.5    4.7
vp9_avg_bilin_4v_8bpp_rvv_i32                      :    1.5    1.2
vp9_avg_bilin_8h_8bpp_c                            :   20.0   17.7
vp9_avg_bilin_8h_8bpp_rvv_i32                      :    3.0    2.7
vp9_avg_bilin_8v_8bpp_c                            :   20.7   18.7
vp9_avg_bilin_8v_8bpp_rvv_i32                      :    3.0    2.7
vp9_avg_bilin_16h_8bpp_c                           :   78.2   69.7
vp9_avg_bilin_16h_8bpp_rvv_i32                     :    7.0    6.2
vp9_avg_bilin_16v_8bpp_c                           :   98.5   73.2
vp9_avg_bilin_16v_8bpp_rvv_i32                     :    7.0    6.0
vp9_avg_bilin_32h_8bpp_c                           :  325.5  275.5
vp9_avg_bilin_32h_8bpp_rvv_i32                     :   23.0   20.5
vp9_avg_bilin_32v_8bpp_c                           :  342.2  290.0
vp9_avg_bilin_32v_8bpp_rvv_i32                     :   21.7   19.5
vp9_avg_bilin_64h_8bpp_c                           : 1263.7 1095.7
vp9_avg_bilin_64h_8bpp_rvv_i32                     :   91.2   81.2
vp9_avg_bilin_64v_8bpp_c                           : 1331.7 1155.2
vp9_avg_bilin_64v_8bpp_rvv_i32                     :   91.2   81.0
vp9_put_bilin_4h_8bpp_c                            :    4.5    4.0
vp9_put_bilin_4h_8bpp_rvv_i32                      :    1.0    1.0
vp9_put_bilin_4v_8bpp_c                            :    4.7    4.2
vp9_put_bilin_4v_8bpp_rvv_i32                      :    1.0    1.0
vp9_put_bilin_8h_8bpp_c                            :   16.7   15.0
vp9_put_bilin_8h_8bpp_rvv_i32                      :    2.2    2.0
vp9_put_bilin_8v_8bpp_c                            :   17.5   15.7
vp9_put_bilin_8v_8bpp_rvv_i32                      :    2.2    2.0
vp9_put_bilin_16h_8bpp_c                           :   65.2   58.0
vp9_put_bilin_16h_8bpp_rvv_i32                     :    6.0    5.5
vp9_put_bilin_16v_8bpp_c                           :   69.2   61.7
vp9_put_bilin_16v_8bpp_rvv_i32                     :    5.7    5.2
vp9_put_bilin_32h_8bpp_c                           :  273.2  229.0
vp9_put_bilin_32h_8bpp_rvv_i32                     :   19.7   17.7
vp9_put_bilin_32v_8bpp_c                           :  290.5  243.7
vp9_put_bilin_32v_8bpp_rvv_i32                     :   18.7   16.7
vp9_put_bilin_64h_8bpp_c                           : 1040.5  910.5
vp9_put_bilin_64h_8bpp_rvv_i32                     :   82.5   73.0
vp9_put_bilin_64v_8bpp_c                           : 1108.5  971.0
vp9_put_bilin_64v_8bpp_rvv_i32                     :   82.2   73.2

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
2024-08-19 22:29:20 +03:00
Michael Niedermayer
67947f2a1c
avcodec/hevc/ps: use unsigned shift
Fixes: left shift of 1 by 31 places cannot be represented in type 'int'
Fixes: 70726/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6149928703819776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-18 23:05:39 +02:00
Michael Niedermayer
043875941f
avcodec/cbs_h265_syntax_template:
Fixes: Assertion width > 0 && width <= 32 failed
Fixes: 71012/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6073354744823808

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-18 23:05:28 +02:00
Michael Niedermayer
8657eb9c3f
avcodec/avcodec: Warn about data returned from get_buffer*()
Text based on suggestion by: epirat07@gmail.com
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-18 23:04:28 +02:00
Ramiro Polla
5c1c0325cd avcodec/aarch64/me_cmp: add dotprod implementations of sse16 and vsse_intra16
checkasm --bench for Raspberry Pi 5 Model B Rev 1.0:
sse_0_c: 241.5
sse_0_neon: 37.2
sse_0_dotprod: 22.2
vsse_4_c: 148.7
vsse_4_neon: 31.0
vsse_4_dotprod: 15.7
2024-08-17 15:31:48 +02:00
sfan5
c779766b5c avcodec/mediacodecdec: call MediaCodec.stop on close
Usually the MediaCodec context will be released immediately, or it needs to stay
alive due to existing hardware buffers.

However we can free resources early in the case of
hw_buffer_count == 0 && refcount > 1, which can be reproduced by keeping frames
referenced after flushing and closing. mpv currently behaves like this.

Signed-off-by: sfan5 <sfan5@live.de>
Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
2024-08-17 09:03:05 +02:00
Niklas Haas
7b723ebd5a avcodec/dovi_rpudec: error out on strange RPU formats
Better safe than sorry.
2024-08-16 11:48:02 +02:00
Niklas Haas
3e1b70383e avcodec/dovi_rpuenc: slightly improve profile autodetection
In the absence of an RPU header, we can consult the colorspace tags to
make a more informed guess about whether we're looking at profile 5 or
profile 8.
2024-08-16 11:48:02 +02:00
Niklas Haas
ecea6ed3c9 avcodec/dovi_rpuenc: implement DM metadata compression
This implements limited metadata compression. To be a bit more lenient,
we try and re-order the static extension blocks when testing for an
exact match.

For sanity, and to avoid producing bitstreams we couldn't ourselves
decode, we don't accept partial matches - if some extension blocks
change while others remain static, compression is disabled for the
entire frame.

This shouldn't be an issue in practice because static extension blocks
are stated to remain constant throughout the entire sequence.
2024-08-16 11:48:02 +02:00
Niklas Haas
9824d1539e avcodec/dovi_rpudec: sanitize DM data before decoding
Some DM types do not fill the whole struct, so just clear it entirely
before going filling the decoded values.
2024-08-16 11:48:02 +02:00
Niklas Haas
45f5f4d3da avcodec/dovi_rpudec: implement limited DM decompression
This implements the limited DM metadata compression scheme described in
chapter 9 of the dolby vision bitstream specification.

The spec is a bit unclear about how to handle the presence of static
metadata inside compressed frames; in that it doesn't explicitly forbid
an encoder from repeating redundant metadata. In theory, we would need
to detect this case and then strip the corresponding duplicate metadata
from the existing set of static metadata. However, this is difficult to
implement - esspecially for the case of metadata blocks which may be
internally repeated (e.g. level 10).

That said, the spec states outright that static metadata should be
constant throughout the entire sequence, so a sane bitstream should not
have any static metadata values changing from one frame to the next (at
least up to a keyframe boundary), and therefore they should never be
present in compressed frames. As a consequence, it makes sense to treat
this as an error state regardless. (Ignoring them by default, or
erroring if either AV_EF_EXPLODE or AV_EF_AGGRESSIVE are set)

I was not able to find such samples in the wild (outside of artificially
produced test cases for this exact scenario), so I don't think we need
to worry about it until somebody produces one.
2024-08-16 11:48:02 +02:00
Niklas Haas
1c4d4cc368 avcodec/dovi_rpudec: don't unnecessarily allocate DOVIExt 2024-08-16 11:48:02 +02:00
Niklas Haas
a1f96ae157 avcodec/dovi_rpu: separate static ext blocks
Static and dynamic extension blocks are handled differently by metadata
compression, so we need to separate the extension block array into two.
2024-08-16 11:48:02 +02:00
Niklas Haas
f5d6eb4017 avcodec/dovi_rpu: move ext blocks into dedicated struct
Slightly re-organize the logic around extension blocks in order to allow
expanding the state tracking in a following commit.
2024-08-16 11:48:02 +02:00
Niklas Haas
b3d33f11fa avcodec/bsf/dovi_rpu: add new bitstream filter
This can be used to strip dovi metadata, or enable/disable dovi
metadata compression. Possibly more use cases in the future.
2024-08-16 11:48:02 +02:00
Niklas Haas
07712a0cab avcodec/dovi_rpuenc: add configuration for compression
In particular, validate that the chosen compression level is compatible
with the chosen profile.
2024-08-16 11:48:02 +02:00
Niklas Haas
1917270d32 avcodec/dovi_rpuenc: add ff_dovi_configure_ext()
More flexible version of ff_dovi_configure() which does not require an
AVCodecContext. Usable, for example, inside a bitstream filter.
2024-08-16 11:48:02 +02:00
Niklas Haas
765f29c61e avcodec/dovi_rpu: add ff_dovi_get_metadata()
Provides direct access to the AVDOVIMetadata without having to attach it
to a frame.
2024-08-16 11:48:02 +02:00
Niklas Haas
ae3a78593d avcodec/dovi_rpuenc: add a flag to enable compression
Keyframes must reset the metadata compression state, so we need to
also signal this at rpu generation time.

Default to uncompressed, because encoders cannot generally know if
a given frame will be a keyframe before they finish encoding, but also
cannot retroactively attach the RPU. (Within the confines of current
APIs)
2024-08-16 11:48:02 +02:00
Niklas Haas
b3bc8f8e1e avcodec/dovi_rpuenc: make encapsulation optional
And move the choice of desired container to `flags`. This is needed to
handle differing API requirements (e.g. libx265 requires the NAL RBSP,
but CBS BSF requires the unescaped bytes).
2024-08-16 11:48:02 +02:00
Niklas Haas
1e6fdb89bd avcodec/dovi_rpuenc: add flags to ff_dovi_rpu_generate()
Will be used to control compression, encapsulation etc.
2024-08-16 11:48:02 +02:00
Niklas Haas
c62b364dcb avcodec/dovi_rpuenc: respect dv_md_compression
Limited mode can only ever maintain a single VDR RPU reference, and
furthermore requires vdr_rpu_id == 0. So in practice, it will only ever
use VDR RPU slot 0. All remaining slots get flushed in this case, to
avoid leaking partial state.
2024-08-16 11:48:02 +02:00
Niklas Haas
fd00a56653 avcodec/dovi_rpuenc: eliminate unnecessary loop
This struct itself contains vdr_rpu_id, so we can never match it except
in the case of i == vdr_rpu_id. So just directly use this ID.
2024-08-16 11:48:02 +02:00
Niklas Haas
bf92441d6a avcodec/dovi_rpuenc: also copy ext blocks to dovi ctx
As the comment implies, DOVIContext.ext_blocks should also reflect the
current state after ff_dovi_rpu_generate().

Fluff for now, but will be needed once we start implementing metadata
compression for extension blocks as well.
2024-08-16 11:48:02 +02:00
Niklas Haas
a93801b626 avcodec/dovi_rpudec: implement validation for compression
Add some error checking. I've limited it to AV_EF_CAREFUL and
AV_EF_COMPLIANT for now, because we can technically decode such RPUs
just fine.
2024-08-16 11:48:02 +02:00
Fei Wang
be7ab63552 lavc/qsvdec: Add vvc_mp4toannexb bsf for QSV VVC decoder
Fix error:
$ ffmpeg -hwaccel qsv -i input.mp4 -f null -
..
[vvc_qsv @ 0000026890D966C0] Error decoding stream header: unknown error (-1)
[vvc_qsv @ 0000026890D966C0] Error decoding header

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2024-08-16 14:15:04 +08:00
Lynne
18d964fc2c
vulkan: enable encoding of images if video_maintenance1 is enabled
Vulkan encoding was designed in a very... consolidated way.
You had to know the exact codec and profile that the image was going to
eventually be encoded as at... image creation time. Unfortunately, as good
as our code is, glimpsing into the exact future isn't what its capable of.

video_maintenance1 removed that requirement, which only then made encoding
images practically possible.
2024-08-16 01:22:16 +02:00
Lynne
869f4aec48
vulkan_decode: use the correct queue family for decoding ops
In 680d969a305c0927480573a1b455024088b51aeb, the new API was
used to find a queue family for dispatch, but the found queue
family was not used for decoding, just for dispatching.
2024-08-16 01:22:08 +02:00
Wu Jianhua
ca5c9e810a avcodec/vvc/dsp: prefix TxType and TxSize with VVC
See https://patchwork.ffmpeg.org/project/ffmpeg/patch/TYSPR06MB64337C4A9ADF5312E6648543AA62A@TYSPR06MB6433.apcprd06.prod.outlook.com/#81892

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2024-08-15 20:52:14 +08:00
Wu Jianhua
ae1a9cfd52 avcodec/vvc_parser: move avctx->has_b_frames initialization to dec
From Jun Zhao <mypopydev@gmail.com>:
> Should we relocate this to the decoder? Other codecs typically set this
> parameter in the decoder.

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2024-08-15 20:50:24 +08:00
Nuo Mi
80af195804 avcodec/vvcdec: move frame tab memset from the main thread to worker threads
memset tables in the main thread can become a bottleneck for the decoder.
For example, if it takes 1% of the processing time for one core, the maximum achievable FPS will be 100.
Move the memeset to worker threads will fix the issue.
2024-08-15 20:33:57 +08:00
Nuo Mi
daf6fcd816 avcodec/vvcdec: do not zero frame qp table
For luma, qp can only change at the CU level, so the qp tab size is related to the CU.
For chroma, considering the joint CbCr, the QP tab size is related to the TU.
2024-08-15 20:33:57 +08:00
Nuo Mi
ca2caeb21d avcodec/vvcdec: do not zero frame msf mmi table 2024-08-15 20:33:57 +08:00
Nuo Mi
0c7106f618 avcodec/vvcdec: do not zero frame cpm table 2024-08-15 20:33:57 +08:00
Nuo Mi
3e497249eb avcodec/vvcdec: check_available, use && instead of &= for shortcut evaluation 2024-08-15 20:33:57 +08:00
Nuo Mi
4f882c453e avcodec/vvcdec: do not zero frame mvf table 2024-08-15 20:33:57 +08:00
Nuo Mi
93b0d5f9ce avcodec/vvcdec: refact out is_available from is_a0_available 2024-08-15 20:33:57 +08:00
Nuo Mi
e8ac761293 avcodec/vvcdec: split ctu table to zero init and no zero init parts
cus need to init to zero, other parts are not
2024-08-15 20:19:45 +08:00
Nuo Mi
4f60961498 avcodec/vvcdec: remove unnecessary perframe initializations
deblock, sao, alf
skip, imtf, ipm, cqt_depth, cb_pos_x, cb_pos_y, cb_height, cp_mv,
tb_pos_x0, tb_pos_y0, tb_width, tb_height
2024-08-15 20:19:45 +08:00