From patchwork Tue Aug 27 15:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51162 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c944:0:b0:48e:c0f8:d0de with SMTP id k4csp350390vqt; Tue, 27 Aug 2024 09:00:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVJsRxAu/LmYs6qqUfPVfnkgjZ+WdTDjv+5gPYL1+XEQglMDIEPy2HAsgHBL8VtemU4YSCdn0VuLrMYDlt9STNG@gmail.com X-Google-Smtp-Source: AGHT+IGzE5IXm0iFOWilQ+sDpu6p5wnSgqohe7cq3Dv3z5+G3yYnWq1h5IEOOG6TfUS8pm10n2Xe X-Received: by 2002:a05:6512:1596:b0:52c:deb9:904b with SMTP id 2adb3069b0e04-5343887e17bmr12383709e87.38.1724774409290; Tue, 27 Aug 2024 09:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724774409; cv=none; d=google.com; s=arc-20240605; b=KhlH/Az7qaJcvIyZs4Bhyv5ClfDh0GblLLFpjngkL1ae9PMmfot0dWdpSsFdMtKOQM dfa7NjVoixU9TtOYxdRebpvAYMVS3xOWYILBFf8p8mTsZhwpF8/j1v3REzQdAMA624hV SOU/ynjWPbLdxqZ71imXRON3Cp6rm5Q97+wP2IpgGi5WhSOFvn1nuEjc2BVrXwLloF2I BiCD77MzUsznA45BNG+vSUMhATSRXkUgZaFqYJGTto0EtcTnlmeuWdZVO66+zCHVdo7p KHdvuQY7Ppiii6RpnJ/1sTpx7D61t5hOfvRYiUEqrzHlUPezhls7OdnDbxHnDIivPjGk Xllw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=ogWz+eLDMmSXh275M5Lb01V5y0KqBgV9tS2Xm5lNs40=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=UMWSvw+28zbSlhyBmb3ArXpEqPDMKDVZNEPT0NbksX+Xo167eOoAwnkw7PQaOySajQ OCEQrSZeKD7xs1DToGHeksfnrXP6+sbcpjPW+17KrOJKxY36Kqcrvfj3Pck+DBRFXTp4 S6BFDHMpj3GZf9M/qeZtpmcEEB3LTvTbWm8hNT6VDc3lnAVHGCwgkX2MY3FB0y548HNU HU6rBKWSUMNMXvu6y0d24akk9xcCY0u/GbsDIR2JgGupflv4l+UilxxjYOQoIIpxEt/e sve1mD2l1+uqeMv/+2Ly6F9nzizGXGyr3tlHgq/RscUBPX/75ZB/nNs8f2T3XDp1pR/6 oP2Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=pd5PszK1; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-5334ea85207si4320825e87.369.2024.08.27.09.00.08; Tue, 27 Aug 2024 09:00:09 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=pd5PszK1; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2600068DEA0; Tue, 27 Aug 2024 18:43:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0C2068DDD7 for ; Tue, 27 Aug 2024 18:42:57 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=pd5PszK1; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 047834E05 for ; Tue, 27 Aug 2024 17:42:54 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Od_M8iWFQ3ze for ; Tue, 27 Aug 2024 17:42:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1724773369; bh=CxxvQKKsuccs0CxZ1ZvdeF2Sm8t2WP47yqOU4eorvrw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pd5PszK1FutyzcgmbIe4XLNVvGuQPM9yOqNfg90m/TnidPGESGJTtlSa0M0iSyRdz hD6zQu/+A7RWKAMC0fluZCaCww8jPB8RHHtSuNkFL5egETDJYKHnXwy2AvGJ05svI5 TZaU9jFWhs4dZdBoZEPHb4Vnnw9ZPb70wb2Q2bdTHsVAqsJ6LjFkOmbYayFZfJEIT3 HFjbQ34U8Ae0P0m1XIz3aG7odxRC1IHk8BqZwqUjMnn6EHrt13i/i/THMCgof3C1n5 tKgFxz7IC0Ml4nZmjg3TmswpLSjxhaL0lWyWZFLixLS6cuCO3Q7TkMDXBXishyrVM5 uy9uH/kU0OQPw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 1B5DB4E0F for ; Tue, 27 Aug 2024 17:42:49 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 81A073A2DE0 for ; Tue, 27 Aug 2024 17:42:42 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Aug 2024 17:04:58 +0200 Message-ID: <20240827154041.13846-20-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240827154041.13846-2-anton@khirnov.net> References: <20240827154041.13846-2-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/42] lavc/hevcdec: move HEVCContext.tab_slice_address to HEVCLayerContext 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: k7yx/1/L524C --- libavcodec/hevc/filter.c | 16 ++++++++-------- libavcodec/hevc/hevcdec.c | 34 ++++++++++++++++++---------------- libavcodec/hevc/hevcdec.h | 4 ++-- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/libavcodec/hevc/filter.c b/libavcodec/hevc/filter.c index 12a57eb223..14afb147b9 100644 --- a/libavcodec/hevc/filter.c +++ b/libavcodec/hevc/filter.c @@ -298,31 +298,31 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCLayerContext *l, if (restore) { if (!edges[0]) { left_tile_edge = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs-1]]; - vert_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb)) || left_tile_edge; + vert_edge[0] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb - 1, y_ctb)) || left_tile_edge; } if (!edges[2]) { right_tile_edge = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs+1]]; - vert_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb)) || right_tile_edge; + vert_edge[1] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb + 1, y_ctb)) || right_tile_edge; } if (!edges[1]) { up_tile_edge = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs - sps->ctb_width]]; - horiz_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb - 1)) || up_tile_edge; + horiz_edge[0] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb, y_ctb - 1)) || up_tile_edge; } if (!edges[3]) { bottom_tile_edge = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs + sps->ctb_width]]; - horiz_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb + 1)) || bottom_tile_edge; + horiz_edge[1] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb, y_ctb + 1)) || bottom_tile_edge; } if (!edges[0] && !edges[1]) { - diag_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb - 1)) || left_tile_edge || up_tile_edge; + diag_edge[0] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb - 1, y_ctb - 1)) || left_tile_edge || up_tile_edge; } if (!edges[1] && !edges[2]) { - diag_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb - 1)) || right_tile_edge || up_tile_edge; + diag_edge[1] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb + 1, y_ctb - 1)) || right_tile_edge || up_tile_edge; } if (!edges[2] && !edges[3]) { - diag_edge[2] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb + 1)) || right_tile_edge || bottom_tile_edge; + diag_edge[2] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb + 1, y_ctb + 1)) || right_tile_edge || bottom_tile_edge; } if (!edges[0] && !edges[3]) { - diag_edge[3] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb + 1)) || left_tile_edge || bottom_tile_edge; + diag_edge[3] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb - 1, y_ctb + 1)) || left_tile_edge || bottom_tile_edge; } } diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index 4174743eb6..3561a3a3ad 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -79,7 +79,7 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l) av_freep(&l->is_pcm); av_freep(&s->qp_y_tab); - av_freep(&s->tab_slice_address); + av_freep(&l->tab_slice_address); av_freep(&l->filter_slice_edges); av_freep(&s->horizontal_bs); @@ -120,11 +120,11 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s goto fail; l->filter_slice_edges = av_mallocz(ctb_count); - s->tab_slice_address = av_malloc_array(pic_size_in_ctb, - sizeof(*s->tab_slice_address)); + l->tab_slice_address = av_malloc_array(pic_size_in_ctb, + sizeof(*l->tab_slice_address)); s->qp_y_tab = av_malloc_array(pic_size_in_ctb, sizeof(*s->qp_y_tab)); - if (!s->qp_y_tab || !l->filter_slice_edges || !s->tab_slice_address) + if (!s->qp_y_tab || !l->filter_slice_edges || !l->tab_slice_address) goto fail; s->horizontal_bs = av_calloc(l->bs_width, l->bs_height); @@ -2486,6 +2486,7 @@ static int hls_coding_quadtree(HEVCLocalContext *lc, } static void hls_decode_neighbour(HEVCLocalContext *lc, + const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x_ctb, int y_ctb, int ctb_addr_ts) { @@ -2494,7 +2495,7 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts]; int ctb_addr_in_slice = ctb_addr_rs - s->sh.slice_addr; - s->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr; + l->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr; if (pps->entropy_coding_sync_enabled_flag) { if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0) @@ -2516,11 +2517,11 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, if (pps->tiles_enabled_flag) { if (x_ctb > 0 && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]]) lc->boundary_flags |= BOUNDARY_LEFT_TILE; - if (x_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - 1]) + if (x_ctb > 0 && l->tab_slice_address[ctb_addr_rs] != l->tab_slice_address[ctb_addr_rs - 1]) lc->boundary_flags |= BOUNDARY_LEFT_SLICE; if (y_ctb > 0 && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs - sps->ctb_width]]) lc->boundary_flags |= BOUNDARY_UPPER_TILE; - if (y_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - sps->ctb_width]) + if (y_ctb > 0 && l->tab_slice_address[ctb_addr_rs] != l->tab_slice_address[ctb_addr_rs - sps->ctb_width]) lc->boundary_flags |= BOUNDARY_UPPER_SLICE; } else { if (ctb_addr_in_slice <= 0) @@ -2555,11 +2556,11 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) x_ctb = (ctb_addr_rs % ((sps->width + ctb_size - 1) >> sps->log2_ctb_size)) << sps->log2_ctb_size; 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); + hls_decode_neighbour(lc, l, pps, sps, x_ctb, y_ctb, ctb_addr_ts); 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; + l->tab_slice_address[ctb_addr_rs] = -1; return ret; } @@ -2572,7 +2573,7 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) more_data = hls_coding_quadtree(lc, l, pps, sps, x_ctb, y_ctb, sps->log2_ctb_size, 0); if (more_data < 0) { - s->tab_slice_address[ctb_addr_rs] = -1; + l->tab_slice_address[ctb_addr_rs] = -1; return more_data; } @@ -2616,7 +2617,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctx, void *hevc_lclist, int x_ctb = (ctb_addr_rs % sps->ctb_width) << sps->log2_ctb_size; int y_ctb = (ctb_addr_rs / sps->ctb_width) << sps->log2_ctb_size; - hls_decode_neighbour(lc, pps, sps, x_ctb, y_ctb, ctb_addr_ts); + hls_decode_neighbour(lc, l, pps, sps, x_ctb, y_ctb, ctb_addr_ts); ff_thread_await_progress2(s->avctx, ctb_row, thread, SHIFT_CTB_WPP); @@ -2669,7 +2670,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctx, void *hevc_lclist, return 0; error: - s->tab_slice_address[ctb_addr_rs] = -1; + l->tab_slice_address[ctb_addr_rs] = -1; /* Casting const away here is safe, because it is an atomic operation. */ atomic_store((atomic_int*)&s->wpp_err, 1); ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP); @@ -2778,7 +2779,8 @@ 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) +static int decode_slice_data(HEVCContext *s, const HEVCLayerContext *l, + const H2645NAL *nal, GetBitContext *gb) { const HEVCPPS *pps = s->pps; int ret; @@ -2809,7 +2811,7 @@ static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext 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) { + if (l->tab_slice_address[prev_rs] != s->sh.slice_addr) { av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n"); return AVERROR_INVALIDDATA; } @@ -2957,7 +2959,7 @@ static int hevc_frame_start(HEVCContext *s, HEVCLayerContext *l) memset(s->vertical_bs, 0, l->bs_width * l->bs_height); memset(l->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height); memset(l->is_pcm, 0, (sps->min_pu_width + 1) * (sps->min_pu_height + 1)); - memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address)); + memset(l->tab_slice_address, -1, pic_size_in_ctb * sizeof(*l->tab_slice_address)); if (IS_IDR(s)) ff_hevc_clear_refs(l); @@ -3221,7 +3223,7 @@ static int decode_slice(HEVCContext *s, HEVCLayerContext *l, return AVERROR_INVALIDDATA; } - ret = decode_slice_data(s, nal, gb); + ret = decode_slice_data(s, l, nal, gb); if (ret < 0) return ret; diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h index afaf4c1954..b69b039655 100644 --- a/libavcodec/hevc/hevcdec.h +++ b/libavcodec/hevc/hevcdec.h @@ -458,6 +458,8 @@ typedef struct HEVCLayerContext { // CTB-level flags affecting loop filter operation uint8_t *filter_slice_edges; + + int32_t *tab_slice_address; } HEVCLayerContext; typedef struct HEVCContext { @@ -513,8 +515,6 @@ typedef struct HEVCContext { uint8_t *horizontal_bs; uint8_t *vertical_bs; - int32_t *tab_slice_address; - /** used on BE to byteswap the lines for checksumming */ uint8_t *checksum_buf; int checksum_buf_size;