From patchwork Tue Aug 27 15:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51158 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c944:0:b0:48e:c0f8:d0de with SMTP id k4csp341304vqt; Tue, 27 Aug 2024 08:43:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWRxFrs/5kgF7ovet6oQ3pNY/WS6v1TBJoZ10w/cKPWasQkUBSjgK4+yJMBSS2yYyui42wbgyLiH0hSky82Twxg@gmail.com X-Google-Smtp-Source: AGHT+IEJxDDXwjjrXRxyMDBxSU1brG/1jX+NhrdfcaNHrppdaCdyUiJqRZgcXWAxgY5ID5cgSK8H X-Received: by 2002:a17:907:9724:b0:a7a:9f0f:ab1b with SMTP id a640c23a62f3a-a86a54bb7e9mr492756466b.7.1724773428651; Tue, 27 Aug 2024 08:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724773428; cv=none; d=google.com; s=arc-20240605; b=W6L9K6j7i/U1i1cRxJcJmcgG0/vCEUX1+jvFoetQ7Ii3nW+MUlhSXcQBAxT3XFk9ET +akFOES3YXv6xzejb8GyLzwsc+inYKqD3sJHTUBj3a/rvtF7o2C+7Xmm4NdEA+amw81c iLVoCjE38J17sSfMNLkK6x/7z6mLo+dNffrcL/frHu1uif5I17F/nPaEZYMcT7tr8mAn lWn77BTs88a+AyaIBtTmMr7AFIQwMmOgaMy5ps8G6ZrSWR2rNiSu/9xaz3e/TmRSe9rl CPutXVnf//fkHiXVO/es8bdH9x5yCASJ+EuDMfkEPmXHaYRMi2fqqvA2Cd5M8XLphGYL SF8Q== 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=093uodGTuNCjszxRdb59SWxBfglENRVHeqc63YLNE4w=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=XKBiJXseuLupjOuQ4+l2PEB0DMEW+Rz72I4+D15eNBCPRVUmeqLJo3ycqZBsNNxzqV jY0JNzZUcDbaknU8aSLfQVuEDIIKb/caI0L3nTJkXBF7WHegcA8VgiKybOz+yryla55R 9LlUh/aKzaDGPOkTQbYOTU5GGTWIY+88irKVOHmb6hfnpO+reyXbvgdtHAH4ms6UI1/1 fgvRqG46abT08D5FsQ6sdsbd85P5wDGyGs2v1TUBlkUMHcgV18+kP/ZVLfkE5ljWo+IC zTtDh++mt65vwHgTZQMomDajjuKghlUBqODygApZAqa4BKZdnLCGGNP9KHVUEQ45ffcV 3sRQ==; 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=JRm7iqat; 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 a640c23a62f3a-a86e58ab076si155460766b.695.2024.08.27.08.43.47; Tue, 27 Aug 2024 08:43:48 -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=JRm7iqat; 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 019FB68DDD8; Tue, 27 Aug 2024 18:43:03 +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 2A9A168DD8C 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=JRm7iqat; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 79F184DFE 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 q2RsjLSkO0qL 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=4Vm/OwJBV84a82Wd5RJauJ5PCcAdX/caDWkuMJIHB/o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JRm7iqatxnDIc182ZSLnYStCDt650ZxgpFPcek0XXwaJNGUhnQZCxWMxZs8VrK7hF Bm8/whf/fOP40Z1JJ8BtJGgTPSGozSavGK9T5zAsUTHKUn9qzDHKKIGWqHCHPZF1PB /oLg3VN72eMBMaY5Cbv7kw9uswoy76r6NKYkNxjuFSO85/u9fdhfvkcz0VtycnEuLZ pLTbu3w8vrCRBKomZ0BQtf+O//Pl9HxVjvAQgVYcLorWR0YLS+sDH8Fdz0y/uNU6Cd EvGQmJnyTsDGVguwp5ONY38jEE/2wP8NMjCqtB51xzeqPSIXoy/EbEBlATU4DvWeVW cOcMIZoMMp9aw== 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 4609A4E13 for ; Tue, 27 Aug 2024 17:42:48 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5E6DF3A2D03 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:55 +0200 Message-ID: <20240827154041.13846-17-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 15/42] lavc/hevcdec: move HEVCContext.tab_ipm 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: 1kolRUWsm4DM --- libavcodec/hevc/hevcdec.c | 32 ++++++++++++++++++-------------- libavcodec/hevc/hevcdec.h | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index 1887a44e3e..0a3b5ba4c4 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -74,7 +74,7 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l) av_freep(&l->skip_flag); av_freep(&l->tab_ct_depth); - av_freep(&s->tab_ipm); + av_freep(&l->tab_ipm); av_freep(&l->cbf_luma); av_freep(&s->is_pcm); @@ -114,9 +114,9 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s goto fail; l->cbf_luma = av_malloc_array(sps->min_tb_width, sps->min_tb_height); - s->tab_ipm = av_mallocz(min_pu_size); + l->tab_ipm = av_mallocz(min_pu_size); s->is_pcm = av_malloc_array(sps->min_pu_width + 1, sps->min_pu_height + 1); - if (!s->tab_ipm || !l->cbf_luma || !s->is_pcm) + if (!l->tab_ipm || !l->cbf_luma || !s->is_pcm) goto fail; s->filter_slice_edges = av_mallocz(ctb_count); @@ -2010,7 +2010,8 @@ static void hls_prediction_unit(HEVCLocalContext *lc, /** * 8.4.1 */ -static int luma_intra_pred_mode(HEVCLocalContext *lc, const HEVCSPS *sps, +static int luma_intra_pred_mode(HEVCLocalContext *lc, const HEVCLayerContext *l, + const HEVCSPS *sps, int x0, int y0, int pu_size, int prev_intra_luma_pred_flag) { @@ -2023,9 +2024,9 @@ static int luma_intra_pred_mode(HEVCLocalContext *lc, const HEVCSPS *sps, int y0b = av_zero_extend(y0, sps->log2_ctb_size); int cand_up = (lc->ctb_up_flag || y0b) ? - s->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] : INTRA_DC; + l->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] : INTRA_DC; int cand_left = (lc->ctb_left_flag || x0b) ? - s->tab_ipm[y_pu * min_pu_width + x_pu - 1] : INTRA_DC; + l->tab_ipm[y_pu * min_pu_width + x_pu - 1] : INTRA_DC; int y_ctb = (y0 >> (sps->log2_ctb_size)) << (sps->log2_ctb_size); @@ -2080,7 +2081,7 @@ static int luma_intra_pred_mode(HEVCLocalContext *lc, const HEVCSPS *sps, if (!size_in_pus) size_in_pus = 1; for (i = 0; i < size_in_pus; i++) { - memset(&s->tab_ipm[(y_pu + i) * min_pu_width + x_pu], + memset(&l->tab_ipm[(y_pu + i) * min_pu_width + x_pu], intra_pred_mode, size_in_pus); for (j = 0; j < size_in_pus; j++) { @@ -2109,7 +2110,8 @@ static const uint8_t tab_mode_idx[] = { 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31}; -static void intra_prediction_unit(HEVCLocalContext *lc, const HEVCSPS *sps, +static void intra_prediction_unit(HEVCLocalContext *lc, + const HEVCLayerContext *l, const HEVCSPS *sps, int x0, int y0, int log2_cb_size) { @@ -2133,7 +2135,8 @@ static void intra_prediction_unit(HEVCLocalContext *lc, const HEVCSPS *sps, lc->pu.rem_intra_luma_pred_mode = ff_hevc_rem_intra_luma_pred_mode_decode(lc); lc->pu.intra_pred_mode[2 * i + j] = - luma_intra_pred_mode(lc, sps, x0 + pb_size * j, y0 + pb_size * i, pb_size, + luma_intra_pred_mode(lc, l, sps, + x0 + pb_size * j, y0 + pb_size * i, pb_size, prev_intra_luma_pred_flag[2 * i + j]); } } @@ -2178,6 +2181,7 @@ static void intra_prediction_unit(HEVCLocalContext *lc, const HEVCSPS *sps, } static void intra_prediction_unit_default_value(HEVCLocalContext *lc, + const HEVCLayerContext *l, const HEVCSPS *sps, int x0, int y0, int log2_cb_size) @@ -2194,7 +2198,7 @@ static void intra_prediction_unit_default_value(HEVCLocalContext *lc, if (size_in_pus == 0) size_in_pus = 1; for (j = 0; j < size_in_pus; j++) - memset(&s->tab_ipm[(y_pu + j) * min_pu_width + x_pu], INTRA_DC, size_in_pus); + memset(&l->tab_ipm[(y_pu + j) * min_pu_width + x_pu], INTRA_DC, size_in_pus); if (lc->cu.pred_mode == MODE_INTRA) for (j = 0; j < size_in_pus; j++) for (k = 0; k < size_in_pus; k++) @@ -2256,7 +2260,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, if (SAMPLE_CTB(l->skip_flag, x_cb, y_cb)) { hls_prediction_unit(lc, l, pps, sps, x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); - intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size); + intra_prediction_unit_default_value(lc, l, sps, x0, y0, log2_cb_size); if (!s->sh.disable_deblocking_filter_flag) ff_hevc_deblocking_boundary_strengths(lc, l, pps, x0, y0, log2_cb_size); @@ -2279,7 +2283,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, pcm_flag = ff_hevc_pcm_flag_decode(lc); } if (pcm_flag) { - intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size); + intra_prediction_unit_default_value(lc, l, sps, x0, y0, log2_cb_size); ret = hls_pcm_sample(lc, l, pps, x0, y0, log2_cb_size); if (sps->pcm_loop_filter_disabled) set_deblocking_bypass(s, sps, x0, y0, log2_cb_size); @@ -2287,10 +2291,10 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, if (ret < 0) return ret; } else { - intra_prediction_unit(lc, sps, x0, y0, log2_cb_size); + intra_prediction_unit(lc, l, sps, x0, y0, log2_cb_size); } } else { - intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size); + intra_prediction_unit_default_value(lc, l, sps, x0, y0, log2_cb_size); switch (lc->cu.part_mode) { case PART_2Nx2N: hls_prediction_unit(lc, l, pps, sps, diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h index ccea7a46e1..5f686772c8 100644 --- a/libavcodec/hevc/hevcdec.h +++ b/libavcodec/hevc/hevcdec.h @@ -453,6 +453,7 @@ typedef struct HEVCLayerContext { // PU uint8_t *cbf_luma; // cbf_luma of colocated TU + uint8_t *tab_ipm; } HEVCLayerContext; typedef struct HEVCContext { @@ -511,7 +512,6 @@ typedef struct HEVCContext { int32_t *tab_slice_address; // PU - uint8_t *tab_ipm; uint8_t *is_pcm;