[FFmpeg-devel] [PATCH 30/39] lavc/hevcdec: move constructing slice RPL to decode_slice_data()
Anton Khirnov
anton at khirnov.net
Fri Jun 7 16:01:26 EEST 2024
---
libavcodec/hevc/hevcdec.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index c148244361..804cceac3e 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -665,11 +665,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
if (!sh->dependent_slice_segment_flag) {
sh->slice_addr = sh->slice_segment_addr;
- s->slice_idx++;
}
} else {
sh->slice_segment_addr = sh->slice_addr = 0;
- s->slice_idx = 0;
s->slice_initialized = 0;
}
@@ -2801,6 +2799,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext *gb)
{
const HEVCPPS *pps = s->pps;
+ int ret;
if (s->sh.dependent_slice_segment_flag) {
int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
@@ -2811,6 +2810,15 @@ static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext
}
}
+ if (!s->sh.dependent_slice_segment_flag && s->sh.slice_type != HEVC_SLICE_I) {
+ ret = ff_hevc_slice_rpl(s);
+ if (ret < 0) {
+ av_log(s->avctx, AV_LOG_WARNING,
+ "Error constructing the reference lists for the current slice.\n");
+ return ret;
+ }
+ }
+
if (s->avctx->hwaccel)
return FF_HW_CALL(s->avctx, decode_slice, nal->raw_data, nal->raw_size);
@@ -2828,6 +2836,8 @@ static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext
s->local_ctx[0].tu.cu_qp_offset_cb = 0;
s->local_ctx[0].tu.cu_qp_offset_cr = 0;
+ s->slice_idx += !s->sh.dependent_slice_segment_flag;
+
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)
@@ -2938,6 +2948,7 @@ static int hevc_frame_start(HEVCContext *s)
memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address));
s->is_decoded = 0;
+ s->slice_idx = 0;
s->first_nal_type = s->nal_unit_type;
s->poc = s->sh.poc;
@@ -3151,16 +3162,6 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
return AVERROR_INVALIDDATA;
}
- if (!s->sh.dependent_slice_segment_flag &&
- s->sh.slice_type != HEVC_SLICE_I) {
- ret = ff_hevc_slice_rpl(s);
- if (ret < 0) {
- av_log(s->avctx, AV_LOG_WARNING,
- "Error constructing the reference lists for the current slice.\n");
- goto fail;
- }
- }
-
ctb_addr_ts = decode_slice_data(s, nal, &gb);
if (ctb_addr_ts >= s->cur_frame->ctb_count) {
ret = hevc_frame_end(s);
--
2.43.0
More information about the ffmpeg-devel
mailing list