From patchwork Tue Aug 27 15:05:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51173 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c944:0:b0:48e:c0f8:d0de with SMTP id k4csp364933vqt; Tue, 27 Aug 2024 09:20:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUFI6fK5GHKol0LAHBBY0ntx0WrptyWqrECm5ZgDmbggOF8v+SmPLR4wfNB5n0A6XDqnfFDJse0yfuU6AFE4I6r@gmail.com X-Google-Smtp-Source: AGHT+IFcM0XSdsGf26JONqBejPGRJ9RBdCQhL6EbDyO//qOSqZF64HlbbQt1j7tfOL/Tar3UmddD X-Received: by 2002:a2e:bea3:0:b0:2ef:1c03:73e6 with SMTP id 38308e7fff4ca-2f4f493f3b0mr58021461fa.5.1724775612896; Tue, 27 Aug 2024 09:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724775612; cv=none; d=google.com; s=arc-20240605; b=Q0ZAZSAfsWVXo/mAXIKgBvuZ22rF3613jh4PJ1mRdyVQ5vtiLU2gh9Q1AcRdaQ3Z4Y rx+kz4hzLn7grZ4jQXR2Af1Rbtsr7kItUS1lX02qRQb19mftlZ2uy8tp4nSV33/3rlu5 xMP3H2VlGMwSlmswIWIjytUKYCQ+73kMC4tutMQ6pufmKstVb495PL9Lmoy1ijQKDguK tygWR5EkdftedU8HWWDm6uego0lLuW4fxVuxKyVvq1Eksfh2+SUylGyjzxtQ7HQA9m1e VYvMxIuvNCdJMadABpDqDCi8u+HptfdPhALx+jVz1di3tRCU1QDh6Zv40rDyLlr7lE3W Q3EA== 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=OFam9zHoPHGNkt9R2sLapava0poRBM13Y/q+8rY//CA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=lToJ4sAMrESqGM1Hz4//y9Wmag23osrh2fj0cKPdyMgQY00ChJ2nq5Af203cNyyNQg R7pnPuW4Kphw5wVzyu42GTPTGmczSBQAt46+UWRkS6XLX3ZsLSenr3ibuQCR6Rvgi8S3 FYRFmKoew2ipyaAugw1PkfCd8V/2CT9YAArs0uUBGjKJOKoagxBigwlqYlgaTkX0tIhG tl3YchQ+kREpxMYeHGh7WZBJiYwTcC/4cKZ8Eocuwh56e6TEoD4Xod0VAWRLmOflT9ex ebNqJvlV/bZZj69wGK1k6stZPP3cc+PthfejjUHoRum0k64u15Mewur0cyoJprTMlyob 1MXg==; 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=YTbGKSEd; 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 38308e7fff4ca-2f4047aa97asi38276321fa.73.2024.08.27.09.20.12; Tue, 27 Aug 2024 09:20:12 -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=YTbGKSEd; 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 B460C68DEA4; Tue, 27 Aug 2024 18:43:44 +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 16BFF68DDDA for ; Tue, 27 Aug 2024 18:42:58 +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=YTbGKSEd; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 840284E0F 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 a2mH0P1R8WEV for ; Tue, 27 Aug 2024 17:42:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1724773369; bh=Eiit31zVo0Zcq7XeNdSbq261dAnFbvTGnla3n2hu37U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YTbGKSEdD9DWg/YYQdAQrzfbr1aNS7Dmy3TfZQB0Nv4q0YjWuP73vUCxNC+8FDzUW MHGu29lEoI7YSdzhEpc/su22XKPMZ85XsFwROlrHvb8AQvxJZjTIdbLpeJOQgCO3xX 7a6kLev7epcQiWwjX0yi3NsdOzzjGwinQf5IeVJuXOz5Z3Wd/tdgvky/BQ68J1NYRa hUjRb2gcFvoqJxXXbs18otfuijv5Nl92ldRq6PJQJc1V/hXaVMAm8vrCnWaeLDBROH exFgO7V6WqMWtMztoTFDJ75XslOKPj5bIDZi+fup0dRnIthHNWwr+ERunUp/yFylSX X3OEQeeHAP/Mg== 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 363AE4E12 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 990323A2E5E for ; Tue, 27 Aug 2024 17:42:42 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Aug 2024 17:05:00 +0200 Message-ID: <20240827154041.13846-22-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 20/42] lavc/hevcdec: move HEVCContext.{horizontal, vertical}_bs 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: Vk527Do0qZa7 --- libavcodec/hevc/filter.c | 24 ++++++++++++------------ libavcodec/hevc/hevcdec.c | 14 +++++++------- libavcodec/hevc/hevcdec.h | 5 +++-- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/libavcodec/hevc/filter.c b/libavcodec/hevc/filter.c index ad655a2b36..db82f2319f 100644 --- a/libavcodec/hevc/filter.c +++ b/libavcodec/hevc/filter.c @@ -549,8 +549,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext * for (y = y0; y < y_end; y += 8) { // vertical filtering luma for (x = x0 ? x0 : 8; x < x_end; x += 8) { - const int bs0 = s->vertical_bs[(x + y * l->bs_width) >> 2]; - const int bs1 = s->vertical_bs[(x + (y + 4) * l->bs_width) >> 2]; + const int bs0 = l->vertical_bs[(x + y * l->bs_width) >> 2]; + const int bs1 = l->vertical_bs[(x + (y + 4) * l->bs_width) >> 2]; if (bs0 || bs1) { const int qp = (get_qPy(sps, l->qp_y_tab, x - 1, y) + get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; @@ -578,8 +578,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext * // horizontal filtering luma for (x = x0 ? x0 - 8 : 0; x < x_end2; x += 8) { - const int bs0 = s->horizontal_bs[( x + y * l->bs_width) >> 2]; - const int bs1 = s->horizontal_bs[((x + 4) + y * l->bs_width) >> 2]; + const int bs0 = l->horizontal_bs[( x + y * l->bs_width) >> 2]; + const int bs1 = l->horizontal_bs[((x + 4) + y * l->bs_width) >> 2]; if (bs0 || bs1) { const int qp = (get_qPy(sps, l->qp_y_tab, x, y - 1) + get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; @@ -613,8 +613,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext * // vertical filtering chroma for (y = y0; y < y_end; y += (8 * v)) { for (x = x0 ? x0 : 8 * h; x < x_end; x += (8 * h)) { - const int bs0 = s->vertical_bs[(x + y * l->bs_width) >> 2]; - const int bs1 = s->vertical_bs[(x + (y + (4 * v)) * l->bs_width) >> 2]; + const int bs0 = l->vertical_bs[(x + y * l->bs_width) >> 2]; + const int bs1 = l->vertical_bs[(x + (y + (4 * v)) * l->bs_width) >> 2]; if ((bs0 == 2) || (bs1 == 2)) { const int qp0 = (get_qPy(sps, l->qp_y_tab, x - 1, y) + @@ -647,8 +647,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext * if (x_end != sps->width) x_end2 = x_end - 8 * h; for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) { - const int bs0 = s->horizontal_bs[( x + y * l->bs_width) >> 2]; - const int bs1 = s->horizontal_bs[((x + 4 * h) + y * l->bs_width) >> 2]; + const int bs0 = l->horizontal_bs[( x + y * l->bs_width) >> 2]; + const int bs1 = l->horizontal_bs[((x + 4 * h) + y * l->bs_width) >> 2]; if ((bs0 == 2) || (bs1 == 2)) { const int qp0 = bs0 == 2 ? (get_qPy(sps, l->qp_y_tab, x, y - 1) + get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1 : 0; @@ -788,7 +788,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer bs = 1; else bs = boundary_strength(s, curr, top, rpl_top); - s->horizontal_bs[((x0 + i) + y0 * l->bs_width) >> 2] = bs; + l->horizontal_bs[((x0 + i) + y0 * l->bs_width) >> 2] = bs; } } @@ -826,7 +826,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer bs = 1; else bs = boundary_strength(s, curr, left, rpl_left); - s->vertical_bs[(x0 + (y0 + i) * l->bs_width) >> 2] = bs; + l->vertical_bs[(x0 + (y0 + i) * l->bs_width) >> 2] = bs; } } @@ -844,7 +844,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; bs = boundary_strength(s, curr, top, rpl); - s->horizontal_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs; + l->horizontal_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs; } } @@ -859,7 +859,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; bs = boundary_strength(s, curr, left, rpl); - s->vertical_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs; + l->vertical_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs; } } } diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index fd5da54fb1..2e31928e99 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -82,8 +82,8 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l) av_freep(&l->tab_slice_address); av_freep(&l->filter_slice_edges); - av_freep(&s->horizontal_bs); - av_freep(&s->vertical_bs); + av_freep(&l->horizontal_bs); + av_freep(&l->vertical_bs); ff_refstruct_pool_uninit(&s->tab_mvf_pool); ff_refstruct_pool_uninit(&s->rpl_tab_pool); @@ -127,9 +127,9 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s if (!l->qp_y_tab || !l->filter_slice_edges || !l->tab_slice_address) goto fail; - s->horizontal_bs = av_calloc(l->bs_width, l->bs_height); - s->vertical_bs = av_calloc(l->bs_width, l->bs_height); - if (!s->horizontal_bs || !s->vertical_bs) + l->horizontal_bs = av_calloc(l->bs_width, l->bs_height); + l->vertical_bs = av_calloc(l->bs_width, l->bs_height); + if (!l->horizontal_bs || !l->vertical_bs) goto fail; s->tab_mvf_pool = ff_refstruct_pool_alloc(min_pu_size * sizeof(MvField), 0); @@ -2956,8 +2956,8 @@ static int hevc_frame_start(HEVCContext *s, HEVCLayerContext *l) new_sequence = 1; } - memset(s->horizontal_bs, 0, l->bs_width * l->bs_height); - memset(s->vertical_bs, 0, l->bs_width * l->bs_height); + memset(l->horizontal_bs, 0, l->bs_width * l->bs_height); + memset(l->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(l->tab_slice_address, -1, pic_size_in_ctb * sizeof(*l->tab_slice_address)); diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h index 6eb63c1b6c..426b7968b0 100644 --- a/libavcodec/hevc/hevcdec.h +++ b/libavcodec/hevc/hevcdec.h @@ -462,6 +462,9 @@ typedef struct HEVCLayerContext { int32_t *tab_slice_address; int8_t *qp_y_tab; + + uint8_t *horizontal_bs; + uint8_t *vertical_bs; } HEVCLayerContext; typedef struct HEVCContext { @@ -513,8 +516,6 @@ typedef struct HEVCContext { VideoDSPContext vdsp; BswapDSPContext bdsp; H274FilmGrainDatabase h274db; - uint8_t *horizontal_bs; - uint8_t *vertical_bs; /** used on BE to byteswap the lines for checksumming */ uint8_t *checksum_buf;