From patchwork Sat Jul 1 23:39:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42364 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1e:b0:12b:9ae3:586d with SMTP id c30csp3457051pzh; Sat, 1 Jul 2023 16:40:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Qdfw2FbMaQTDRcBWnFNxspXdp7nGajirtqR1Y+CvTlncWEk5Ql5j4KR7oASMxVYYVTvEe X-Received: by 2002:a17:907:8689:b0:982:7434:ea84 with SMTP id qa9-20020a170907868900b009827434ea84mr7888611ejc.10.1688254824622; Sat, 01 Jul 2023 16:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688254824; cv=none; d=google.com; s=arc-20160816; b=n2Bg9P8qcCpT7kyb0CKt+SpD+hwzkIRokUJV55s0o1XDD44g8g3iamT7BipmlGCH/Q LUzSAoEqT26zOTsf2d4GifCqHscXhixOHg6Yglia5/1FpuOuBZixkY3B5LaXY3nehlwJ p6uoY3l+cYjEko5Rcj3d1c8yaf/DFHw47efuABBIpaUvi5uu2s7WEuhVFUVtSLdZ7y/k 5Rl01CZzSfPpB/IyD4rcjdBUyBKQyZZ2v93FNtsTVFd0vFRZ/R3KztQ2CkhBef14i9OJ nzHFWeeme2NMuEn7O74y3dU2kgZZLAC71OamNKj0J59dfOD4xqAIzRFhz3pccoGkQCgG FpDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=xY+RCK9GZ0nh5Ecagl5tqXx/8WZSfLxBtuRkhGLmDLY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=z8F325/2gAsiuQJdK1CE17KjtMlaoCPMlsYg9l5+tR+HyJoc9Ylp5CweUN4u8R58gL TolsMjQdBv3/uPxGgWx0tUZyCAI5JVC1V8JTr+q5MIP4s0aWKUYa/F1QIFjAdrqnACy/ ECB1h5q0Oa3SOrjSoLJdeg6ERhm7dDejSusSTvjSsr83dQUksbd2fn/EOwSFLexxi32F ZP75gpUnvf+Jg7SFY+ZKfjp+Ok6K9tKZ3Eu/ISGy3DGloKpidvwKuV7NEibQaIlSqkct VxhW4TxE59BTSEcviWdk34OJVWw30lsoe5+yI9bEq7hyLuIkDdM6d0MT7sRUp7GzqRPX 4BjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b="gIm/38pB"; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id jj24-20020a170907985800b00992e3285fc3si743887ejc.545.2023.07.01.16.40.24; Sat, 01 Jul 2023 16:40:24 -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=@gmail.com header.s=20221208 header.b="gIm/38pB"; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 803F368C1EC; Sun, 2 Jul 2023 02:40:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ECB4868C096 for ; Sun, 2 Jul 2023 02:40:13 +0300 (EEST) Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-1b38121a011so533492fac.2 for ; Sat, 01 Jul 2023 16:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688254812; x=1690846812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SX6qsjC83qn/syM43YwWoGLs5lle6WP+4maW5Y9KGTA=; b=gIm/38pBCumBaF2wEHCnVFY3Td9Yt7Z/4+mACo4xLOJwyKsSuZrH3GO08DTsqLzci2 Yvx+hILtpbjgu7RKU5c6pF28WJIoFJBsDmaIvlwnkyjDUeP8/GUW5RgjGVz/+3Hmmrv3 LyjZrRU7ww57g3xDVwQUPljwsExen3paXHTF5wgtjLbUKTft8YLBXx2nGjaALqNUqdv0 W7pPlKCbr5aXIzlO9/NlwsyUGYDyRgL9SwgY3W/xtIM/46fZ7A5B5T7NmWRAHclZUMpV 838f8hePg84YP2NEI0hruGNCcbuA2yWJF8tRDFbXgAdvj4Xl+XYUZtON1tnQAzha7ZDn uoSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688254812; x=1690846812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SX6qsjC83qn/syM43YwWoGLs5lle6WP+4maW5Y9KGTA=; b=MTRMtMqvm8jLX6eDBnkiQrnhrC2I6ImIkzikwvkx20czxFcScwj8gHkaFGjJWOBLMg KFzn4m9Dvkt5KV8QlUJHMuncbGmmu5j/vR1U7vH2xme98s9aR4c8xep0DAjgNlYZzp/k QX0oc/hhSXtS0ayK/519XhaHdLjANQH1UqWqIMS9QxW6xQpHLDFHcBFatCvSgaEdYIFG Pspi281Wwekd5KkqmD3UurXCib9WHRNTCz82l5VJm6ukA+tyf7Holk71IaAEYgxHiIk2 Q27qfhFzlkLe9UiUqlOXyxC6Bbc5P7lzE6w+JbRIFWOtvtWWEf8V1w3q+O/aLJr5oLY3 VS1A== X-Gm-Message-State: ABy/qLbZIKYm2rD4NNaKjb/Cu8kUw/xRtZctFdbRO5K2ct+/NgdJVcAY 54NBjvEcZ1+8y7d9F9MUnMt3H6tGcNg= X-Received: by 2002:a05:6870:63a7:b0:1b3:977b:8201 with SMTP id t39-20020a05687063a700b001b3977b8201mr243228oap.7.1688254812183; Sat, 01 Jul 2023 16:40:12 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id ld17-20020a0568702b1100b001a66847f5e4sm10539085oab.19.2023.07.01.16.40.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 16:40:11 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 1 Jul 2023 20:39:08 -0300 Message-ID: <20230701233908.1637-1-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230701013651.30004-2-jamrial@gmail.com> References: <20230701013651.30004-2-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avcodec/cbs_h266: store RowHeightVal and ColWidthVal in the context 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: C36ipoqJyqfF Stop overwriting values from the bitstream arrays pps_tile_column_width_minus1 and pps_tile_row_height_minus1. Signed-off-by: James Almer --- libavcodec/cbs_h266.h | 2 ++ libavcodec/cbs_h266_syntax_template.c | 37 ++++++++++++++------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/libavcodec/cbs_h266.h b/libavcodec/cbs_h266.h index 9e823919af..dc7406f084 100644 --- a/libavcodec/cbs_h266.h +++ b/libavcodec/cbs_h266.h @@ -553,6 +553,8 @@ typedef struct H266RawPPS { uint16_t slice_height_in_ctus[VVC_MAX_SLICES]; uint16_t num_slices_in_subpic[VVC_MAX_SLICES]; uint16_t sub_pic_id_val[VVC_MAX_SLICES]; + uint16_t col_width_val[VVC_MAX_TILE_COLUMNS]; + uint16_t row_height_val[VVC_MAX_TILE_ROWS]; } H266RawPPS; typedef struct H266RawAUD { diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c index f1cd45f815..f8d0fc8f1b 100644 --- a/libavcodec/cbs_h266_syntax_template.c +++ b/libavcodec/cbs_h266_syntax_template.c @@ -1748,10 +1748,10 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, "Tile column width(%d) exceeds picture width\n",i); return AVERROR_INVALIDDATA; } + current->col_width_val[i] = current->pps_tile_column_width_minus1[i] + 1; remaining_size -= (current->pps_tile_column_width_minus1[i] + 1); } - unified_size = (i == 0 ? pic_width_in_ctbs_y : - (current->pps_tile_column_width_minus1[i - 1] + 1)); + unified_size = current->pps_tile_column_width_minus1[i - 1] + 1; while (remaining_size > 0) { if (current->num_tile_columns > VVC_MAX_TILE_COLUMNS) { av_log(ctx->log_ctx, AV_LOG_ERROR, @@ -1760,7 +1760,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, return AVERROR_INVALIDDATA; } unified_size = FFMIN(remaining_size, unified_size); - current->pps_tile_column_width_minus1[i] = unified_size - 1; + current->col_width_val[i] = unified_size; remaining_size -= unified_size; i++; } @@ -1779,14 +1779,14 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, "Tile row height(%d) exceeds picture height\n",i); return AVERROR_INVALIDDATA; } + current->row_height_val[i] = current->pps_tile_row_height_minus1[i] + 1; remaining_size -= (current->pps_tile_row_height_minus1[i] + 1); } - unified_size = (i == 0 ? pic_height_in_ctbs_y : - (current->pps_tile_row_height_minus1[i - 1] + 1)); + unified_size = current->pps_tile_row_height_minus1[i - 1] + 1; while (remaining_size > 0) { unified_size = FFMIN(remaining_size, unified_size); - current->pps_tile_row_height_minus1[i] = unified_size - 1; + current->row_height_val[i] = unified_size; remaining_size -= unified_size; i++; } @@ -1852,20 +1852,20 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, ctu_x = ctu_y = 0; for (j = 0; j < tile_x; j++) { - ctu_x += current->pps_tile_column_width_minus1[j] + 1; + ctu_x += current->col_width_val[j]; } for (j = 0; j < tile_y; j++) { - ctu_y += current->pps_tile_row_height_minus1[j] + 1; + ctu_y += current->row_height_val[j]; } if (current->pps_slice_width_in_tiles_minus1[i] == 0 && current->pps_slice_height_in_tiles_minus1[i] == 0 && - current->pps_tile_row_height_minus1[tile_y] > 0) { + current->row_height_val[tile_y] > 1) { int num_slices_in_tile, uniform_slice_height, remaining_height_in_ctbs_y; remaining_height_in_ctbs_y = - current->pps_tile_row_height_minus1[tile_y] + 1; + current->row_height_val[tile_y]; ues(pps_num_exp_slices_in_tile[i], - 0, current->pps_tile_row_height_minus1[tile_y], 1, i); + 0, current->row_height_val[tile_y] - 1, 1, i); if (current->pps_num_exp_slices_in_tile[i] == 0) { num_slices_in_tile = 1; slice_top_left_ctu_x[i] = ctu_x; @@ -1875,7 +1875,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, for (j = 0; j < current->pps_num_exp_slices_in_tile[i]; j++) { ues(pps_exp_slice_height_in_ctus_minus1[i][j], 0, - current->pps_tile_row_height_minus1[tile_y], 2, + current->row_height_val[tile_y] - 1, 2, i, j); slice_height_in_ctus = current-> @@ -1890,7 +1890,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, remaining_height_in_ctbs_y -= slice_height_in_ctus; } uniform_slice_height = 1 + - (j == 0 ? current->pps_tile_row_height_minus1[tile_y] : + (j == 0 ? current->row_height_val[tile_y] - 1: current->pps_exp_slice_height_in_ctus_minus1[i][j-1]); while (remaining_height_in_ctbs_y > uniform_slice_height) { current->slice_height_in_ctus[i + j] = @@ -1919,7 +1919,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, j <= current->pps_slice_height_in_tiles_minus1[i]; j++) { height += - current->pps_tile_row_height_minus1[tile_y + j] + 1; + current->row_height_val[tile_y + j]; } current->slice_height_in_ctus[i] = height; @@ -1956,10 +1956,10 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, ctu_x = 0, ctu_y = 0; for (j = 0; j < tile_x; j++) { - ctu_x += current->pps_tile_column_width_minus1[j] + 1; + ctu_x += current->col_width_val[j]; } for (j = 0; j < tile_y; j++) { - ctu_y += current->pps_tile_row_height_minus1[j] + 1; + ctu_y += current->row_height_val[j]; } slice_top_left_ctu_x[i] = ctu_x; slice_top_left_ctu_y[i] = ctu_y; @@ -1972,7 +1972,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, for (j = 0; j <= current->pps_slice_height_in_tiles_minus1[i]; j++) { height += - current->pps_tile_row_height_minus1[tile_y + j] + 1; + current->row_height_val[tile_y + j]; } current->slice_height_in_ctus[i] = height; @@ -2015,6 +2015,7 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw, infer(pps_tile_column_width_minus1[0], pic_width_in_ctbs_y - 1); infer(pps_num_exp_tile_rows_minus1, 0); infer(pps_tile_row_height_minus1[0], pic_height_in_ctbs_y - 1); + infer(row_height_val[0], pic_height_in_ctbs_y); infer(num_tile_columns, 1); infer(num_tile_rows, 1); infer(num_tiles_in_pic, 1); @@ -3037,7 +3038,7 @@ static int FUNC(slice_header) (CodedBitstreamContext *ctx, RWContext *rw, current->sh_slice_address + current->sh_num_tiles_in_slice_minus1; tile_idx++) { tile_y = tile_idx / pps->num_tile_rows; - height = pps->pps_tile_row_height_minus1[tile_y] + 1; + height = pps->row_height_val[tile_y]; num_entry_points += (entropy_sync ? height : 1); } }