From: toqsxw@gmail.com To: ffmpeg-devel@ffmpeg.org Cc: Wu Jianhua <toqsxw@outlook.com> Subject: [FFmpeg-devel] [PATCH v1 06/23] avcodec/vvc: refact out ep_init and ep_init_wpp Date: Wed, 14 May 2025 21:40:13 +0800 Message-ID: <20250514134031.1584-6-toqsxw@outlook.com> (raw) In-Reply-To: <20250514134031.1584-1-toqsxw@outlook.com> From: Wu Jianhua <toqsxw@outlook.com> Signed-off-by: Wu Jianhua <toqsxw@outlook.com> --- libavcodec/vvc/dec.c | 48 ++++++++++++++++++++++++++--------------- libavcodec/vvc/thread.c | 12 +++++++---- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c index f860e116ab..09b0053703 100644 --- a/libavcodec/vvc/dec.c +++ b/libavcodec/vvc/dec.c @@ -506,23 +506,18 @@ static int slices_realloc(VVCFrameContext *fc) return 0; } -static int ep_init_cabac_decoder(SliceContext *sc, const int index, - const H2645NAL *nal, GetBitContext *gb, const CodedBitstreamUnit *unit) +static int get_ep_size(const H266RawSliceHeader *rsh, GetBitContext *gb, const H2645NAL *nal, const int header_size, const int ep_index) { - const H266RawSlice *slice = unit->content_ref; - const H266RawSliceHeader *rsh = sc->sh.r; - EntryPoint *ep = sc->eps + index; int size; - int ret; - if (index < rsh->num_entry_points) { + if (ep_index < rsh->num_entry_points) { int skipped = 0; int64_t start = (gb->index >> 3); - int64_t end = start + rsh->sh_entry_point_offset_minus1[index] + 1; - while (skipped < nal->skipped_bytes && nal->skipped_bytes_pos[skipped] <= start + slice->header_size) { + int64_t end = start + rsh->sh_entry_point_offset_minus1[ep_index] + 1; + while (skipped < nal->skipped_bytes && nal->skipped_bytes_pos[skipped] <= start + header_size) { skipped++; } - while (skipped < nal->skipped_bytes && nal->skipped_bytes_pos[skipped] <= end + slice->header_size) { + while (skipped < nal->skipped_bytes && nal->skipped_bytes_pos[skipped] <= end + header_size) { end--; skipped++; } @@ -531,6 +526,13 @@ static int ep_init_cabac_decoder(SliceContext *sc, const int index, } else { size = get_bits_left(gb) / 8; } + return size; +} + +static int ep_init_cabac_decoder(EntryPoint *ep, GetBitContext *gb, const int size) +{ + int ret; + av_assert0(gb->buffer + get_bits_count(gb) / 8 + size <= gb->buffer_end); ret = ff_init_cabac_decoder (&ep->cc, gb->buffer + get_bits_count(gb) / 8, size); if (ret < 0) @@ -539,6 +541,19 @@ static int ep_init_cabac_decoder(SliceContext *sc, const int index, return 0; } +static int ep_init(EntryPoint *ep, const int ctu_addr, const int ctu_end, GetBitContext *gb, const int size) +{ + const int ret = ep_init_cabac_decoder(ep, gb, size); + + if (ret < 0) + return ret; + + ep->ctu_start = ctu_addr; + ep->ctu_end = ctu_end; + + return 0; +} + static int slice_init_entry_points(SliceContext *sc, VVCFrameContext *fc, const H2645NAL *nal, const CodedBitstreamUnit *unit) { @@ -562,20 +577,19 @@ static int slice_init_entry_points(SliceContext *sc, return ret; for (int i = 0; i < sc->nb_eps; i++) { - EntryPoint *ep = sc->eps + i; + const int size = get_ep_size(sc->sh.r, &gb, nal, slice->header_size, i); + const int ctu_end = (i + 1 == sc->nb_eps ? sh->num_ctus_in_curr_slice : sh->entry_point_start_ctu[i]); + EntryPoint *ep = sc->eps + i; - ep->ctu_start = ctu_addr; - ep->ctu_end = (i + 1 == sc->nb_eps ? sh->num_ctus_in_curr_slice : sh->entry_point_start_ctu[i]); + ret = ep_init(ep, ctu_addr, ctu_end, &gb, size); + if (ret < 0) + return ret; for (int j = ep->ctu_start; j < ep->ctu_end; j++) { const int rs = sc->sh.ctb_addr_in_curr_slice[j]; fc->tab.slice_idx[rs] = sc->slice_idx; } - ret = ep_init_cabac_decoder(sc, i, nal, &gb, unit); - if (ret < 0) - return ret; - if (i + 1 < sc->nb_eps) ctu_addr = sh->entry_point_start_ctu[i]; } diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c index 6194416e14..e1d64bd3d2 100644 --- a/libavcodec/vvc/thread.c +++ b/libavcodec/vvc/thread.c @@ -283,6 +283,12 @@ static void add_progress_listener(VVCFrame *ref, ProgressListener *l, ff_vvc_add_progress_listener(ref, (VVCProgressListener*)l); } +static void ep_init_wpp(EntryPoint *next, const EntryPoint *ep, const VVCSPS *sps) +{ + memcpy(next->cabac_state, ep->cabac_state, sizeof(next->cabac_state)); + ff_vvc_ep_init_stat_coeff(next, sps->bit_depth, sps->r->sps_persistent_rice_adaptation_enabled_flag); +} + static void schedule_next_parse(VVCContext *s, VVCFrameContext *fc, const SliceContext *sc, const VVCTask *t) { VVCFrameThread *ft = fc->ft; @@ -292,10 +298,8 @@ static void schedule_next_parse(VVCContext *s, VVCFrameContext *fc, const SliceC if (sps->r->sps_entropy_coding_sync_enabled_flag) { if (t->rx == fc->ps.pps->ctb_to_col_bd[t->rx]) { EntryPoint *next = ep + 1; - if (next < sc->eps + sc->nb_eps && !is_first_row(fc, t->rx, t->ry + 1)) { - memcpy(next->cabac_state, ep->cabac_state, sizeof(next->cabac_state)); - ff_vvc_ep_init_stat_coeff(next, sps->bit_depth, sps->r->sps_persistent_rice_adaptation_enabled_flag); - } + if (next < sc->eps + sc->nb_eps && !is_first_row(fc, t->rx, t->ry + 1)) + ep_init_wpp(next, ep, sps); } if (t->ry + 1 < ft->ctu_height && !is_first_row(fc, t->rx, t->ry + 1)) frame_thread_add_score(s, ft, t->rx, t->ry + 1, VVC_TASK_STAGE_PARSE); -- 2.44.0.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-05-14 13:42 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-05-14 13:40 [FFmpeg-devel] [PATCH v1 01/23] avcodec/vvc/cabac: add 9.3.3.5 k-th order Exp - Golomb binarization process toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 02/23] avcodec/vvc/cabac: add 9.3.3.7 Fixed-length " toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 03/23] avcodec/vvc/cabac: add palette support toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 04/23] avcodec/vvc: add VVC_MAX_NUM_PALETTE_PREDICTOR_SIZE toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 05/23] avcodec/vvc/ctu: refact out ff_vvc_channel_range toqsxw 2025-05-14 13:40 ` toqsxw [this message] 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 07/23] avcodec/vvc: refact, save pf and ciip_flag in ff_vvc_set_intra_mvf toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 08/23] avcodec/vvc/ctu: refact out intra_data toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 09/23] avcodec/vvc/intra: add ff_vvc_palette_derive_scale toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 10/23] avcodec/vvc/ctu: add palette support toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 11/23] avcodec/vvc/filter: skip deblocking filter for palette toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 12/23] avcodec/vvc/intra: add palette coding decoder toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 13/23] avcodec/vvc/cabac: add ff_vvc_cu_act_enabled_flag toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 14/23] avcodec/vvc/ctu: read act_enabled_flag for adaptive color transform toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 15/23] avcodec/vvc/ctu: fix derive_chroma_intra_pred_mode toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 16/23] avcodec/vvc/dsp: update the interface of pred_residual_joint for joint cbcr residual functionality toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 17/23] avcodec/vvc/dsp: add adaptive_color_transform toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 18/23] avcodec/vvc/intra: fix scaling process for transform coefficients toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 19/23] avcodec/vvc/intra: refact, predict jcbcr to tb->coeffs toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 20/23] avcodec/vvc/intra: make lmcs_scale_chroma inplace toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 21/23] avcodec/vvc/intra: refact out lmcs_scale_chroma and add_residual toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 22/23] avcodec/vvc: add adaptive color transform support toqsxw 2025-05-14 13:40 ` [FFmpeg-devel] [PATCH v1 23/23] Changelog: VVC supports all content of SCC toqsxw 2025-05-14 13:46 ` [FFmpeg-devel] 回复: [PATCH v1 01/23] avcodec/vvc/cabac: add 9.3.3.5 k-th order Exp - Golomb binarization process Wu Jianhua 2025-05-17 5:39 ` [FFmpeg-devel] " Nuo Mi -- strict thread matches above, loose matches on Subject: below -- 2025-05-01 14:42 toqsxw 2025-05-01 14:43 ` [FFmpeg-devel] [PATCH v1 06/23] avcodec/vvc: refact out ep_init and ep_init_wpp toqsxw
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250514134031.1584-6-toqsxw@outlook.com \ --to=toqsxw@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=toqsxw@outlook.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git