1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

87 Commits

Author SHA1 Message Date
James Almer
d250cc02e2 avcodec/hevc/refs: ensure LCEVC SEI payloads are exported as frame side data before get_buffer() calls
Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 10:05:34 -03:00
Zhao Zhili
11443cc9b1 avcodec/hevc: ff_hevc_(qpel/epel)_filters are signed type 2024-09-14 16:36:34 +08:00
Anton Khirnov
536bb98888 lavc/hevcdec: set per-CTB filter parameters for WPP
Fixes #10887
2024-09-13 12:10:11 +02:00
Anton Khirnov
21ef80f3d9 lavc/hevcdec: remove a duplicate variable
In hls_decode_entry_wpp(), self_id is always identical to thread.
2024-09-13 12:10:11 +02:00
Anton Khirnov
b53800691c lavc/hevcdec: set output frame pkt_dts
pkt_dts needs to be set manually when using the receive_frame() callback, so
it was unset after 2fdecbb239.

Fixes PTS guessing for certain files with broken timestamps. Cf.
https://github.com/mpv-player/mpv/issues/14806

Reported-by: llyyr <llyyr.public@gmail.com>
2024-09-13 11:56:53 +02:00
Anton Khirnov
eec1a7a6bb lavc/hevc: check framerate num/den to be strictly positive
Rather than just != 0. These values are read as uint32 and can become
negative when cast to int.
2024-09-06 14:09:03 +02:00
Anton Khirnov
fc8df81cb1 lavc/hevcdec: move active SPS from HEVCParamSets to HEVCLayerContext
Currently active SPS is a per-layer property.
2024-09-06 13:59:29 +02:00
Anton Khirnov
9bccc634af lavc/hevcdec: make a HEVCFrame hold a reference to its PPS
ff_hevc_get_ref_list() needs the PPS of a previously decoded frame,
which may be different from the currently active one.
2024-09-06 13:59:29 +02:00
Anton Khirnov
672713761b lavc/hevcdec: move HEVCContext.sao_pixel_buffer_[vh] to HEVCLayerContext
Handle them together with other sps-dependent arrays.

Note that current code only allocates these arrays when hwaccel is not
set, but this is wrong as the relevant code runs BEFORE get_format() is
called and hence before we know whether hwaccel is in use.
2024-09-06 13:59:29 +02:00
Anton Khirnov
6fcf0045cf lavc/hevcdec: move HEVCContext.{tab_mvf,rpl_tab}_pool to HEVCLayerContext
pic_arrays_{init,free}() no longer access HEVCContext
2024-09-06 13:59:29 +02:00
Anton Khirnov
4f87ff7666 lavc/hevcdec: move HEVCContext.{horizontal,vertical}_bs to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
e8baf2fb97 lavc/hevcdec: move HEVCContext.qp_y_tab to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
d5188adba8 lavc/hevcdec: move HEVCContext.tab_slice_address to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
eeb369d24f lavc/hevcdec: move HEVCContext.filter_slice_edges to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
463a85c5a1 lavc/hevcdec: move HEVCContext.is_pcm to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
0704559932 lavc/hevcdec: move HEVCContext.tab_ipm to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
59de042cf6 lavc/hevcdec: move HEVCContext.cbf_luma to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
cf7add8d70 lavc/hevcdec: move HEVCContext.tab_ct_depth to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
1ca4c2a96d lavc/hevcdec: move HEVCContext.skip_flag to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
ed2d25e7f0 lavc/hevcdec: move HEVCContext.deblock to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
3d4294e344 lavc/hevcdec: move HEVCContext.sao to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
747609e967 lavc/hevcdec: move HEVCContext.bs_{width,height} to HEVCLayerContext 2024-09-06 13:59:29 +02:00
Anton Khirnov
c7f0753a6b lavc/hevcdec: move active VPS from HEVCParamSets to HEVCContext
Active VPS is a property of the decoding process, not of the list of
parameter sets.

Check that the VPS can only change in a base layer - while this can
never happen currently (as no other layers can exist in the decoder), it
will become useful when multilayer decoding is supported.
2024-09-06 13:59:29 +02:00
Anton Khirnov
4c0d669b20 lavc/hevcdec: add a per-layer context
Start by moving the DPB to it.

Only one context exists for now, so decoder behaviour should not change
with this commit, but that will change in the future.
2024-09-06 13:59:29 +02:00
Anton Khirnov
c35a51f4bb lavc: add HEVC Multiview Main profile 2024-09-06 13:59:28 +02:00
Hendrik Leppkes
d4cfbf329c
hevc/sei: return INVALIDDATA when a referenced SPS is not available
The code previously returned ENOMEM, despite this not being an
allocation problem, but rather a bitstream problem referring to data not
currently available.

Fixes playback of such streams, as it allows further processing of NAL
units after skipping the broken SEI NAL.
2024-09-04 18:34:47 +02:00
James Almer
a754ee0844 avcodec/h2645_parse: replace three bool arguments in ff_h2645_packet_split with a single flags one
Signed-off-by: James Almer <jamrial@gmail.com>
2024-08-19 20:23:20 -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
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
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
James Almer
afb06aef7e avcodec/decode: remove unused argument from ff_frame_new_side_data_from_buf()
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-29 14:00:48 -03:00
Michael Niedermayer
d52fabaec0
avcodec/hevc/hevcdec: avoid signed shifts with lt_idx_sps
Fixes: left shift of 1 by 31 places cannot be represented in type 'int'
Fixes: 70122/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5172200613675008

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-23 23:21:14 +02:00
Michael Niedermayer
5d9544cfb0
avcodec/hevc/hevcdec: Do not allow slices to depend on failed slices
An alternative would be to leave the context unchanged on failure of hls_slice_header()

Fixes: out of array access
Fixes: NULL pointer dereference
Fixes: 69584/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5931086299856896
Fixes: 69724/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5104066422702080
Fixes: 70422/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5908731129298944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-23 23:21:13 +02:00
Fei Wang
71f802cdc9 lavc/hevcdec: Update slice index before hwaccel decode slice
Otherwise, slice index will never update for hwaccel decode, and slice
RPL will be always overlap into first one which use slice index to construct.

Fixes hwaccel decoding after 47d34ba7fb

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2024-07-12 16:27:34 +08:00
Fei Wang
e741cf665d lavc/hevcdec: Put slice address checking after hwaccel decode slice
Slice address tab only been updated in software decode slice data.

Fixes hwaccel decoding after d725c737fe.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2024-07-12 16:27:34 +08:00
Anton Khirnov
e939f02ce6 lavc/hevcdec: improve check for PPS changing between slices
Compare actual PPS objects rather than just PPS ID, as the former might
change while the latter stays the same.

Reported-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-02 09:55:39 +02:00
Anton Khirnov
5861576f39 lavc/hevcdec: move export_stream_params() from set_sps() to hevc_frame_start()
The only other caller of set_sps() --- hevc_update_thread_context() ---
does not need to call export_stream_params(), since it only updates
AVCodecContext fields that have already been updated by generic code.
2024-07-02 09:55:39 +02:00
Anton Khirnov
99b0c3dc7c lavc/hevcdec: do not pass a pixel format to set_sps()
It is merely copied to AVCodecContext.pix_fmt, which serves no useful
purpose. set_sps() is called from two places:
* when a new SPS becomes active - then the pixel format is
  overridden immediately after the set_sps() call by the result from
  ff_get_format();
* when a new SPS is propagated across frame threads - then the
  AVCodecContext value is already set to the same value by the generic
  code.
2024-07-02 09:55:39 +02:00
Anton Khirnov
5295650655 lavc/hevcdec: do not call export_stream_params_from_sei() in update_thread_context()
It is redundant, since it only sets AVCodecContext fields that are
already copied by the generic code.
2024-07-02 09:55:39 +02:00
Anton Khirnov
fd69700e51 lavc/hevcdec: call export_stream_params_from_sei() before ff_get_buffer()
So that correct values of color_trc are set on the allocated frame.
2024-07-02 09:55:39 +02:00
James Almer
1b9af306da avcodec: use the renamed av_zero_extend
Signed-off-by: James Almer <jamrial@gmail.com>
2024-06-13 20:36:09 -03:00
Anton Khirnov
0060a368b1 lavc/hevcdec: always call hevc_frame_end() after successfully decoding an AU
Currently it is only done if the final CTB address is at the end of the
frame, however that address is not known with hwaccel decoding. As we
only support exactly one AU per packet, and not partial/multiple AUs, we
can just as well call hevc_frame_end() unconditionally.

Fixes hwaccel decoding after d725c737fe.

Reported-by: llyyr <llyyr.public@gmail.com>
2024-06-13 11:44:05 +02:00
Anton Khirnov
08ea7d6b8e lavc/hevcdec: constify source frame in hevc_ref_frame() 2024-06-11 17:39:35 +02:00
Anton Khirnov
ccd391d6a3 lavc/hevcdec: do not unref current frame on frame_end() failure
It's a race with frame threading.
2024-06-11 17:39:35 +02:00
Anton Khirnov
d725c737fe lavc/hevcdec: move some frame-end code to hevc_frame_end()
Specifically, calling hwaccel end_frame, verifying frame checksum,
and printing the frame-was-decoded message.
2024-06-11 17:39:35 +02:00
Anton Khirnov
edb6a471c4 lavc/hevcdec: factor decoding a slice NALU out of decode_nal_unit() 2024-06-11 17:39:35 +02:00
Anton Khirnov
90e75c4ec9 lavc/hevcdec: drop a redundant multiple-frame-per-packet check 2024-06-11 17:39:35 +02:00
Anton Khirnov
3cd6492fb5 lavc/hevcdec: move the check for multiple frames in a packet
Do not do it in hls_slice_header(), which is the wrong place for it.
Avoids special magic return value of 1 in that function. The comment
mentioning potential corrupted state is no longer relevant, as
hls_slice_header() modifies no state beyond SliceHeader, which will only
get used for a valid frame.
2024-06-11 17:39:35 +02:00