From b0c29a45dc3c42eb0c32eb78a850b3c3f581459c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 1 Jun 2024 20:05:36 +0200 Subject: [PATCH] lavc/hevc/cabac: do not infer WPP use based on HEVCContext.threads_number Pass this information explicitly instead. --- libavcodec/hevc/cabac.c | 7 ++++--- libavcodec/hevc/hevcdec.c | 4 ++-- libavcodec/hevc/hevcdec.h | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libavcodec/hevc/cabac.c b/libavcodec/hevc/cabac.c index 8708efc248..39ca7c0135 100644 --- a/libavcodec/hevc/cabac.c +++ b/libavcodec/hevc/cabac.c @@ -452,7 +452,8 @@ static void cabac_init_state(HEVCLocalContext *lc, const HEVCContext *s) } int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps, - int ctb_addr_ts, const uint8_t *data, size_t size) + int ctb_addr_ts, const uint8_t *data, size_t size, + int is_wpp) { const HEVCContext *const s = lc->parent; const HEVCSPS *const sps = pps->sps; @@ -479,7 +480,7 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps, if (pps->tiles_enabled_flag && pps->tile_id[ctb_addr_ts] != pps->tile_id[ctb_addr_ts - 1]) { int ret; - if (s->threads_number == 1) + if (!is_wpp) ret = cabac_reinit(lc); else { ret = ff_init_cabac_decoder(&lc->cc, data, size); @@ -492,7 +493,7 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps, if (ctb_addr_ts % sps->ctb_width == 0) { int ret; get_cabac_terminate(&lc->cc); - if (s->threads_number == 1) + if (!is_wpp) ret = cabac_reinit(lc); else { ret = ff_init_cabac_decoder(&lc->cc, data, size); diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index a57fa4e539..e3773a6147 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -2599,7 +2599,7 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) y_ctb = (ctb_addr_rs / ((sps->width + ctb_size - 1) >> sps->log2_ctb_size)) << sps->log2_ctb_size; hls_decode_neighbour(lc, pps, sps, x_ctb, y_ctb, ctb_addr_ts); - ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, slice_data, slice_size); + ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, slice_data, slice_size, 0); if (ret < 0) { s->tab_slice_address[ctb_addr_rs] = -1; return ret; @@ -2669,7 +2669,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, return 0; } - ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, data, data_size); + ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, data, data_size, 1); if (ret < 0) goto error; hls_sao_param(lc, pps, sps, diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h index 04eacca76d..22367602aa 100644 --- a/libavcodec/hevc/hevcdec.h +++ b/libavcodec/hevc/hevcdec.h @@ -579,7 +579,8 @@ int ff_hevc_slice_rpl(HEVCContext *s); void ff_hevc_save_states(HEVCLocalContext *lc, const HEVCPPS *pps, int ctb_addr_ts); int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps, - int ctb_addr_ts, const uint8_t *data, size_t size); + int ctb_addr_ts, const uint8_t *data, size_t size, + int is_wpp); int ff_hevc_sao_merge_flag_decode(HEVCLocalContext *lc); int ff_hevc_sao_type_idx_decode(HEVCLocalContext *lc); int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc);