From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 713A54BFBF for ; Thu, 1 May 2025 14:45:09 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BCF4A68B7AD; Thu, 1 May 2025 17:43:57 +0300 (EEST) Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D237868B709 for ; Thu, 1 May 2025 17:43:49 +0300 (EEST) Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-b1a1930a922so738851a12.3 for ; Thu, 01 May 2025 07:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746110628; x=1746715428; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lCmqWEkrWZ+1FEvoQu9iDv6Ioa6wyBhbNKzhzjD591E=; b=B/4DqdbzSXa97OBvmx4agYOMacjHZwxdy9yAmVz7f9UYHB9WXgb/B8HliFigzgww0R XnD0VGUVAgBb/twgVFu8ficW7QPAZVJNb5nq2LUXqENXQf5MHzuQTG/sTgiZ0GfGwzGY dT7gTsJwDgYq4RYOhmGcPx3bpvSPYH77FbVqQB8k9Atva7ewhkeiuuQBwcDx37AwHqB8 OhfgtSrZP9kyfgkReZiG6fHBfNcwMBcnnhDK+y+KT7aU9KZD6N6kK+/Wegltste2C9C9 VvwhHzZLQVRM4XDE1D6WS26uSq4tn/gAMyffmB+deWWXSBC/xmEkkqW5bx5WKdvakHT7 4W/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746110628; x=1746715428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lCmqWEkrWZ+1FEvoQu9iDv6Ioa6wyBhbNKzhzjD591E=; b=rcQIhe5VHYo6IbAzkHuph3TgZbEBkecHVw8Kean/W+uIdgfGKEVniSkPEzB5wrKPle Pg2xdNK1tjjSVIsU+0kE6rqbhHwCNBCnrKEUjMd5j3rU4hnZastoQqq7KxhylHUQ1IJV dUyUNJZIhsv1I5xAOpxbaRBuD2cc92Rc55KUQtPBqYzIzsueshXLOC3+p2l0OrbcjTUR SCmzIIRTs0SfYiRCm/kex78vEaPCzJWB5wTqq/O8eBDjmmI9A9IwyITSbd2Xs9ejlKMS BPst1XHAVL11Nw/ZaJ2UxhyAdP24/3CkDw6L12Spc9ZBXQFibDSoq1TuYMmayjXUkU13 lqbg== X-Gm-Message-State: AOJu0YyRckSuMa5Kv9G0M4ByAFfA6/AK/wIpzh2db/j0AampgpDJ8euc 4/oNnw3N4yCdCcMcbo3OaswcWgdpF66y97JrqdvDJQaTWwod7BigrlmKCg== X-Gm-Gg: ASbGncuSwFBi6jo6Eart1apnbDfV47/wZsC1SKRwMnMBz/JR+tIQKIea0Ug8c8ClzrY V9k8WUaEMM40yAQsi+O5RmSYzvMdvn4gfgM50UvjsVt719Cs/QmRhw1qcrYplUyoDeVUekjGwc0 w4Nrbd+FmB8LrvJWxKPWYG0mBMZKVXItSmx0LEYM9kVQBqv5OhZIqQ58XNAUoUXIrODGvdRG0NF KaAu1mzw813yF8bEHnFDck82zlI+6bImlzH1LJaCIB9di38nVPQpNI/mUkLJOtR40JbNVZTD6nh epCjGpsjRqu63Kj1eZliwSGrF8qN8izyU2q7q2WE/S02WdImnhPdZybV3rWB9w== X-Google-Smtp-Source: AGHT+IGIh96ezgH0TJIGfHIWrsNO7m0oM8oUKQ/YPjPYd2Bqn75SE4w7HRW7gYHOpIqQv1Gv8zeRiQ== X-Received: by 2002:a05:6a21:1786:b0:1f3:388b:3b4b with SMTP id adf61e73a8af0-20a87c546b4mr10378835637.15.1746110627906; Thu, 01 May 2025 07:43:47 -0700 (PDT) Received: from localhost.localdomain ([124.79.129.75]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b1f9d4b68e8sm807271a12.27.2025.05.01.07.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 May 2025 07:43:47 -0700 (PDT) From: toqsxw@gmail.com X-Google-Original-From: toqsxw@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 1 May 2025 22:43:04 +0800 Message-ID: <20250501144324.958-6-toqsxw@outlook.com> X-Mailer: git-send-email 2.44.0.windows.1 In-Reply-To: <20250501144324.958-1-toqsxw@outlook.com> References: <20250501144324.958-1-toqsxw@outlook.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 06/23] avcodec/vvc: refact out ep_init and ep_init_wpp X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Wu Jianhua Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Wu Jianhua Signed-off-by: Wu Jianhua --- 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".