From patchwork Sun Aug 23 02:02:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 21827 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 946C9447CDD for ; Sun, 23 Aug 2020 05:25:28 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7B87568B591; Sun, 23 Aug 2020 05:25:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5064D68AD2F for ; Sun, 23 Aug 2020 05:25:21 +0300 (EEST) Received: by mail-qk1-f195.google.com with SMTP id j187so4652410qke.11 for ; Sat, 22 Aug 2020 19:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=4ToxXiXavDWGe4OsbijdKhAELCWYG0u0yJCwXRCcmyo=; b=hcOfpzgwN0phujtVIi9B6DQq2rx2+2z61VoPSRFlXwFjf61ubfQYtiiTCOXHVrbtlO uubGWIBeN157xMVkOQb+cFT12BxSvYndCvO0JnDYi1UuS0RxGrdPvzy+ce/ITOcYJFEj 5AtMcpI06zkFVC2ukpCIC/4KhsBCvaiswDbkla2JAIBtiuKk7NMRH5sBPqw18t3Tn5aM oDO+qmPXyDYideNhaMLrVxKzmkXwolC6+R0IAOeSmf/6Wqo5elgRyuMjo38ajFTCzwJI /T25Vla7V2DsUrinlqwky03w4OSywMsZqDn8/IWvY3kTP5+ibXJQqlzcelAiDrqiQsQp CjIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=4ToxXiXavDWGe4OsbijdKhAELCWYG0u0yJCwXRCcmyo=; b=Ba5sNig93pCCCTKiU1qUY8QtHPPsFz5/AaV65nFrFuP1iVRE+etETd6w1MjtmlknG7 jnqWfHw5pOOrfhgpJaAWPoNjqFtH49crjsHxnv2AoZMRphRdBYbpmseTSDkMSFczlQxy XzY7X2K98QXVKo80vr4nnhpzcXYg8mNuLw9ErV+D1vSEa8ROMN7LN+pHcQ2oVIWR0Uzv 6AAZXt0dFsmbeoHKQUGpKeoNad5rYsICia2qWsvwd4UMHnKkiXdSlEHpm9z/Q2MMDrHL ywfaaPnnRqelbXA3F8EMVBDz/qA+liq0+PY0CnfgGO4CrpyQbpMIfTslHzFc9vOl6NGw kHkQ== X-Gm-Message-State: AOAM5315w9y8hLj4Q+nRhs/bxTZLKdUDSCWiJncPy7OGyHFnuDo2omQd pwrT64gkAFwn/MQo5dl4Lp04rtwB3WHNbw== X-Google-Smtp-Source: ABdhPJyh+o6Lh+SUia5GS5BNbgKW5zV1LrWvg3KX0gYUgcM3qXO5VmZgP35Ru+ZpV1KBEM2BF3vtXg== X-Received: by 2002:ac8:51d7:: with SMTP id d23mr21274qtn.382.1598148152136; Sat, 22 Aug 2020 19:02:32 -0700 (PDT) Received: from localhost.localdomain ([181.23.70.159]) by smtp.gmail.com with ESMTPSA id 20sm7702506qtp.53.2020.08.22.19.02.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2020 19:02:31 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 22 Aug 2020 23:02:16 -0300 Message-Id: <20200823020218.12659-1-jamrial@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/cbs_av1: add derived frame size to AV1RawFrameHeader X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Same logic as tile_cols and tile_rows, this saves CBS users having to recalculate these values, and makes them available for all frames within a Temporal Unit. Signed-off-by: James Almer --- Not a fan of adding more derived values to "raw" structs, but much like the tile ones, these will be useful. libavcodec/cbs_av1.h | 8 +++++++ libavcodec/cbs_av1_syntax_template.c | 32 ++++++++++++++-------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h index f5fed220a5..4482498eb3 100644 --- a/libavcodec/cbs_av1.h +++ b/libavcodec/cbs_av1.h @@ -161,6 +161,14 @@ typedef struct AV1RawFrameHeader { uint8_t render_width_minus_1; uint8_t render_height_minus_1; + // These are derived values, but it's very unhelpful to have to + // recalculate them all the time so we store them here. + uint32_t upscaled_width; + uint32_t frame_width; + uint32_t frame_height; + uint32_t render_width; + uint32_t render_height; + uint8_t found_ref[AV1_REFS_PER_FRAME]; uint8_t refresh_frame_flags; diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index a315e8868a..27d04375fc 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -468,9 +468,9 @@ static int FUNC(superres_params)(CodedBitstreamContext *ctx, RWContext *rw, denom = AV1_SUPERRES_NUM; } - priv->upscaled_width = priv->frame_width; - priv->frame_width = (priv->upscaled_width * AV1_SUPERRES_NUM + - denom / 2) / denom; + priv->upscaled_width = current->upscaled_width = priv->frame_width; + priv->frame_width = current->frame_width = (priv->upscaled_width * AV1_SUPERRES_NUM + + denom / 2) / denom; return 0; } @@ -486,11 +486,11 @@ static int FUNC(frame_size)(CodedBitstreamContext *ctx, RWContext *rw, fb(seq->frame_width_bits_minus_1 + 1, frame_width_minus_1); fb(seq->frame_height_bits_minus_1 + 1, frame_height_minus_1); - priv->frame_width = current->frame_width_minus_1 + 1; - priv->frame_height = current->frame_height_minus_1 + 1; + priv->frame_width = current->frame_width = current->frame_width_minus_1 + 1; + priv->frame_height = current->frame_height = current->frame_height_minus_1 + 1; } else { - priv->frame_width = seq->max_frame_width_minus_1 + 1; - priv->frame_height = seq->max_frame_height_minus_1 + 1; + priv->frame_width = current->frame_width = seq->max_frame_width_minus_1 + 1; + priv->frame_height = current->frame_height = seq->max_frame_height_minus_1 + 1; } CHECK(FUNC(superres_params)(ctx, rw, current)); @@ -510,11 +510,11 @@ static int FUNC(render_size)(CodedBitstreamContext *ctx, RWContext *rw, fb(16, render_width_minus_1); fb(16, render_height_minus_1); - priv->render_width = current->render_width_minus_1 + 1; - priv->render_height = current->render_height_minus_1 + 1; + priv->render_width = current->render_width = current->render_width_minus_1 + 1; + priv->render_height = current->render_height = current->render_height_minus_1 + 1; } else { - priv->render_width = priv->upscaled_width; - priv->render_height = priv->frame_height; + priv->render_width = current->render_width = current->upscaled_width; + priv->render_height = current->render_height = current->frame_height; } return 0; @@ -540,11 +540,11 @@ static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext *rw, return AVERROR_INVALIDDATA; } - priv->upscaled_width = ref->upscaled_width; - priv->frame_width = ref->frame_width; - priv->frame_height = ref->frame_height; - priv->render_width = ref->render_width; - priv->render_height = ref->render_height; + priv->upscaled_width = current->upscaled_width = ref->upscaled_width; + priv->frame_width = current->frame_width = ref->frame_width; + priv->frame_height = current->frame_height = ref->frame_height; + priv->render_width = current->render_width = ref->render_width; + priv->render_height = current->render_height = ref->render_height; break; } }