aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-06-02 09:12:06 +0200
committerAnton Khirnov <anton@khirnov.net>2024-06-11 17:39:35 +0200
commitefc827bf6fdcb046e215547e8c3edfee9b22d5db (patch)
treea0dc3a7e3fbc5c09509d27428c79c7a102154657
parent7cce612a26c3bd750b4a64db6e31ce370b067993 (diff)
downloadffmpeg-efc827bf6fdcb046e215547e8c3edfee9b22d5db.tar.gz
lavc/hevcdec: move slice decoding dispatch to its own function
Also move there a sanity check from hls_decode_entry() that should also be performed when WPP is active (note that the check is not moved to hls_slice_header() because it requires the HEVCContext.tab_slice_address to be set up).
-rw-r--r--libavcodec/hevc/hevcdec.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 9c1d879953..bbcaa350c7 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2578,14 +2578,6 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
int ret;
- if (s->sh.dependent_slice_segment_flag) {
- int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
- if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
- av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
- return AVERROR_INVALIDDATA;
- }
- }
-
while (more_data && ctb_addr_ts < sps->ctb_size) {
int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts];
@@ -2813,6 +2805,27 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
return res;
}
+static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext *gb)
+{
+ const HEVCPPS *pps = s->pps;
+
+ if (s->sh.dependent_slice_segment_flag) {
+ int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
+ int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
+ if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
+ av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
+ return AVERROR_INVALIDDATA;
+ }
+ }
+
+ if (s->avctx->active_thread_type == FF_THREAD_SLICE &&
+ s->sh.num_entry_point_offsets > 0 &&
+ pps->num_tile_rows == 1 && pps->num_tile_columns == 1)
+ return hls_slice_data_wpp(s, nal);
+
+ return hls_decode_entry(s, gb);
+}
+
static int set_side_data(HEVCContext *s)
{
AVFrame *out = s->cur_frame->f;
@@ -3152,12 +3165,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
goto fail;
}
- if (s->avctx->active_thread_type == FF_THREAD_SLICE &&
- s->sh.num_entry_point_offsets > 0 &&
- s->pps->num_tile_rows == 1 && s->pps->num_tile_columns == 1)
- ctb_addr_ts = hls_slice_data_wpp(s, nal);
- else
- ctb_addr_ts = hls_decode_entry(s, &gb);
+ ctb_addr_ts = decode_slice_data(s, nal, &gb);
if (ctb_addr_ts >= s->cur_frame->ctb_count) {
ret = hevc_frame_end(s);
if (ret < 0)