From patchwork Mon Aug 24 17:08:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 21881 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 091E244B34A for ; Mon, 24 Aug 2020 20:09:20 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D97FD689ED4; Mon, 24 Aug 2020 20:09:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 261BE68974F for ; Mon, 24 Aug 2020 20:09:13 +0300 (EEST) Received: by mail-qv1-f68.google.com with SMTP id x7so4063187qvi.5 for ; Mon, 24 Aug 2020 10:09:13 -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=F9UdWfSQezQUFjUfV9CfuXmy4kjPiz0x823n1XYyBqQ=; b=jV4T6DVYAC5OPCp6F9T1Rfq9SWtahkVC+1qD27LwGcEOp6cI0GtJi7DNInuKoX76xe 8Y0t8Xh7lX4gAGsIfvj78rA/gSHaUGczqEvHXFxLTlm2MIyYpLbOgg8QB+doF0PC/6Pu mtFhfFon7zdM3PX8kO7P1+AZUR0XPoazbbc/Fh8Q6+iIjwabzYUHkagiHPkgQzbAnoCM NBEKPOvhYOVKxXbZrdUEKc0Ftz9sAAG38yiUSB6Ri67qmymsTf+nCnh6TsXExGTe9EnT 06AGa7O8HKaoFTOjxfKU9n4c8P4nMKvT7GCpxa9JNgjC6LIzf3shfwTfPrsO1VwvFyeP L/og== 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=F9UdWfSQezQUFjUfV9CfuXmy4kjPiz0x823n1XYyBqQ=; b=q0TB4wAnM5dHQ06l0bvhvVqjomognDOINBwi6uiMU/lXJicAyDaj5haniFDrI8sYYl hsZSVi8KlI3YrNCSkQv8a6IXf06KUQM0+/9f7DiV0Q3UCuaxCSfH8X7gp3eHe4DWZCVe ZFwKByDh0lwzjZrIhYpKIpv9JuU80pioSqJnCuQ3s9ym0rRErX1FuthMAIBIc1RS92rN BoETkEU4uD+QZamNeF4Ne2bs8ASzOIR1lDprY+ZQuVrQBxp3A4JHQ3kjcan5HcGBNjsx tGHw2m3zdyGZfZTvvfR8/9kpunsSQGqGDzQIyimeVMXyAN305gHj4Xa4IwZnZBgcnHdn H4wQ== X-Gm-Message-State: AOAM533s+XGSc7L5YU/DE/2BYkoTqCbscNFPRlGr0sG89Zmxv8Gzhq+3 ioF5TQPy53cQa4k3X2Ws2LECVlnzT1o= X-Google-Smtp-Source: ABdhPJxfnI4jy1eCCMUdpv0pLs5bpXN12lQ0fn/eQbZgekXR+mHInAshJztrun2/ODYnY4dTNiKSyg== X-Received: by 2002:ad4:55ca:: with SMTP id bt10mr5851097qvb.200.1598288947148; Mon, 24 Aug 2020 10:09:07 -0700 (PDT) Received: from localhost.localdomain ([181.23.70.159]) by smtp.gmail.com with ESMTPSA id b187sm9626911qkd.107.2020.08.24.10.09.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 10:09:06 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Aug 2020 14:08:48 -0300 Message-Id: <20200824170851.4289-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 OrderHint to CodedBitstreamAV1Context 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" This follows the spec and will come in handy in a following commit. Signed-off-by: James Almer --- libavcodec/cbs_av1.h | 1 + libavcodec/cbs_av1_syntax_template.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h index 704a231209..913a6e5dea 100644 --- a/libavcodec/cbs_av1.h +++ b/libavcodec/cbs_av1.h @@ -429,6 +429,7 @@ typedef struct CodedBitstreamAV1Context { int operating_point_idc; int bit_depth; + int order_hint; int frame_width; int frame_height; int upscaled_width; diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 28d9ab9817..6a0a105904 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -373,7 +373,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw, for (i = 0; i < AV1_NUM_REF_FRAMES; i++) shifted_order_hints[i] = cur_frame_hint + cbs_av1_get_relative_dist(seq, priv->ref[i].order_hint, - current->order_hint); + priv->order_hint); latest_order_hint = shifted_order_hints[current->last_frame_idx]; earliest_order_hint = shifted_order_hints[current->golden_frame_idx]; @@ -1005,7 +1005,7 @@ static int FUNC(skip_mode_params)(CodedBitstreamContext *ctx, RWContext *rw, for (i = 0; i < AV1_REFS_PER_FRAME; i++) { ref_hint = priv->ref[current->ref_frame_idx[i]].order_hint; dist = cbs_av1_get_relative_dist(seq, ref_hint, - current->order_hint); + priv->order_hint); if (dist < 0) { if (forward_idx < 0 || cbs_av1_get_relative_dist(seq, ref_hint, @@ -1397,6 +1397,7 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, fb(order_hint_bits, order_hint); else infer(order_hint, 0); + priv->order_hint = current->order_hint; if (frame_is_intra || current->error_resilient_mode) infer(primary_ref_frame, AV1_PRIMARY_REF_NONE); @@ -1586,14 +1587,14 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, .subsampling_x = seq->color_config.subsampling_x, .subsampling_y = seq->color_config.subsampling_y, .bit_depth = priv->bit_depth, - .order_hint = current->order_hint, + .order_hint = priv->order_hint, }; } } av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame %d: size %dx%d " "upscaled %d render %dx%d subsample %dx%d " - "bitdepth %d tiles %dx%d.\n", current->order_hint, + "bitdepth %d tiles %dx%d.\n", priv->order_hint, priv->frame_width, priv->frame_height, priv->upscaled_width, priv->render_width, priv->render_height, seq->color_config.subsampling_x + 1, From patchwork Mon Aug 24 17:08:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 21882 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 D603744B34A for ; Mon, 24 Aug 2020 20:09:21 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C4A7A68A345; Mon, 24 Aug 2020 20:09:21 +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 A20E66897CD for ; Mon, 24 Aug 2020 20:09:14 +0300 (EEST) Received: by mail-qk1-f195.google.com with SMTP id n129so8071198qkd.6 for ; Mon, 24 Aug 2020 10:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=foXjFLI1NaaTxcpTNVD+DDFZXDOIGovmUNSR3D7Rojg=; b=DEtGx26/y9AMW5RPCM69PcKate9gFI45PbWSTPXVpmmDxey0OGFdBApAYiIK8fvk0u usgDvKE+ltIpaNvXX25tvHmxW1n8lc3GbigQFnt1J7tUjg4/bXYF3nnEmMPI5MqxDChI m7rl4m0D2Q8axDEedsDEwtnW1pYQXKQuv1g18r/HPnGliUnIsqjrqokF0QgsRED63FZV gDNDUsTRKTdEdtF6vzbmLa0iV1XxI/T6vE04G8lstADZveMmoJx2qTWdnhrcyzXvFxyb yi+oJK60XWxy9hBr71YnYI7/zaw+GBTf8Rqdy7fQV952+N/wR/DJ0mLJSghjjAaSTGFh fDqQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=foXjFLI1NaaTxcpTNVD+DDFZXDOIGovmUNSR3D7Rojg=; b=N86DaV2LWALaBuXh4maqTINM4VYpkkpfgOPUhbzycW6pNmd7txlWE/YXaRUsfOD0EN OS6fiw5UtGxj4ewJDNBR6PJfjptqSmQG/XB7mTIsFiVY7Cr+J+TEXMDhBs2U52BxciPj mrTjSByIztoWkOA8vFUyX1rYLTQvcGKPP/7RhZb1WDfp/ufPOmomcz8b3TfQdWoGk9Tz UgCiAYaVXQNZa2rD2S0Cju8kCMy4SIgRS6dWC2urNNJ8nCh2QwNc7asRMYHUGAkxRIc6 QdiO81P1Jy76nSOnev9P4UUrtjxihILTvGnvUD9QXTDiw/6wK7FLmBmNan3O0wrWbrcq w34w== X-Gm-Message-State: AOAM533aD6blK6GVQNyUSpvelNdsAEPKRuSBA83w8RQvpbo/D8THg27g ljNKVMUR/m4NhgkMxTsWdrkDSCMIc8o= X-Google-Smtp-Source: ABdhPJwrpwy0/OvfElrx9NtJIVwCBHXu0v9TeRSGWZ00NJ0yLepmlslJVuLCa9VKsj0VRzeluuJ15Q== X-Received: by 2002:a37:5c84:: with SMTP id q126mr5401180qkb.462.1598288948826; Mon, 24 Aug 2020 10:09:08 -0700 (PDT) Received: from localhost.localdomain ([181.23.70.159]) by smtp.gmail.com with ESMTPSA id b187sm9626911qkd.107.2020.08.24.10.09.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 10:09:08 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Aug 2020 14:08:49 -0300 Message-Id: <20200824170851.4289-2-jamrial@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200824170851.4289-1-jamrial@gmail.com> References: <20200824170851.4289-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_av1: infer frame_type in show_existing_frame frames earlier 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" This follows the spec and will come in handy in the next commit. Signed-off-by: James Almer --- libavcodec/cbs_av1_syntax_template.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 6a0a105904..258779c591 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1294,12 +1294,12 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, if (seq->frame_id_numbers_present_flag) fb(id_len, display_frame_id); - if (frame->frame_type == AV1_FRAME_KEY) + infer(frame_type, frame->frame_type); + if (current->frame_type == AV1_FRAME_KEY) infer(refresh_frame_flags, all_frames); else infer(refresh_frame_flags, 0); - infer(frame_type, frame->frame_type); infer(frame_width_minus_1, frame->upscaled_width - 1); infer(frame_height_minus_1, frame->frame_height - 1); infer(render_width_minus_1, frame->render_width - 1); From patchwork Mon Aug 24 17:08:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 21883 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 B97F544B34A for ; Mon, 24 Aug 2020 20:09:22 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A785368A48B; Mon, 24 Aug 2020 20:09:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 371586880A2 for ; Mon, 24 Aug 2020 20:09:16 +0300 (EEST) Received: by mail-qt1-f193.google.com with SMTP id s16so6704179qtn.7 for ; Mon, 24 Aug 2020 10:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FSYmnIr/9TPzmDGihX2PVSPjKcQ9HUlvVkyzE4aFo9I=; b=pz/kon67SmC+CX2XXT9e7XKi3+B07tCs4rlkPIc5jAOrNPd2z3Hcy+JFKGrrSwBgNa pHidaJaEcxD8gBUv5pvm5bEfa7DwUwMiFsY9NzDrZqLeFd7F+mrMZ5YMDK+yAr6pQs09 W3/8eiPhuJ1BkSVVURuT53tgbJ0+7ij7a0CCXI9MmhCqcB52bSVe8FWvu38R4841LbQA MY9sG9BmVsc3RDyKpXa4Nlqqzpys+8ggyg3sQAan2hC8T5roPgB28+dywEr2Kh2kQN6l TAeJ6ishH70ohRKZ6CLxYyBcZdjxTzPsbKbpSkLI1H2gDV9Qh/+Y4EdSA35O3dnOLQEo i9ig== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=FSYmnIr/9TPzmDGihX2PVSPjKcQ9HUlvVkyzE4aFo9I=; b=NbwQmtG15lKk7U14mawQCCRr4DBWT97dYh/qJvhxi8KUBVU1tV2tKX4mLhfxYr8oEh tZxA8pAZVnq2nrtX3yi1SozjS6vEt7cSk2ef3u24nPM9zgI/uKERV2K98Alfv2c5nb/9 uSbPZB/UFm1DqfuWZrbpt1WCLnEKIU6s4H5eyic2pBO0S4UfglW26pIo4nQPV4Oez9+i h2JEUTdmWziZIDRw2TKa7LBehXZTMyulXwuBqR0Sio9KSeXGVcXOyFqZ7onujOI7PqgD IIoujyQ0AYv98XeMCyQqUMZJuaEcy300eS9rhoWN/lAiYtWyQhOFQcEgph6l/TuL9vpL uMHA== X-Gm-Message-State: AOAM533BzxzET7ekL/93Pp20aFo5iXimoZi129eKvHruexkGCrm6NrbP UdYQW9w4v6teyQvRwqA5ryaoEKEg/88= X-Google-Smtp-Source: ABdhPJwqJYm0S4jpCe/q53JDIeErfRZASAnyqJWr2SkU4ttuwJnU78h9lVeeH2p9sBedk7LN9D4s3Q== X-Received: by 2002:ac8:60c5:: with SMTP id i5mr5811577qtm.268.1598288950349; Mon, 24 Aug 2020 10:09:10 -0700 (PDT) Received: from localhost.localdomain ([181.23.70.159]) by smtp.gmail.com with ESMTPSA id b187sm9626911qkd.107.2020.08.24.10.09.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 10:09:09 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Aug 2020 14:08:50 -0300 Message-Id: <20200824170851.4289-3-jamrial@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200824170851.4289-1-jamrial@gmail.com> References: <20200824170851.4289-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/cbs_av1: fix handling reference frames on show_existing_frame frames 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" Implement Section 7.21 "Reference frame loading process" and Section 7.20 "Reference frame update process" for show_existing_frame frames, as required by the definition in Section 7.4 "Decode frame wrapup process". Signed-off-by: James Almer --- libavcodec/cbs_av1_syntax_template.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 258779c591..f5ed189be4 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1295,9 +1295,19 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, fb(id_len, display_frame_id); infer(frame_type, frame->frame_type); - if (current->frame_type == AV1_FRAME_KEY) + if (current->frame_type == AV1_FRAME_KEY) { infer(refresh_frame_flags, all_frames); - else + + // Section 7.21 + infer(current_frame_id, frame->frame_id); + priv->upscaled_width = frame->upscaled_width; + priv->frame_width = frame->frame_width; + priv->frame_height = frame->frame_height; + priv->render_width = frame->render_width; + priv->render_height = frame->render_height; + priv->bit_depth = frame->bit_depth; + priv->order_hint = frame->order_hint; + } else infer(refresh_frame_flags, 0); infer(frame_width_minus_1, frame->upscaled_width - 1); @@ -1305,13 +1315,8 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, infer(render_width_minus_1, frame->render_width - 1); infer(render_height_minus_1, frame->render_height - 1); - priv->upscaled_width = frame->upscaled_width; - priv->frame_width = frame->frame_width; - priv->frame_height = frame->frame_height; - priv->render_width = frame->render_width; - priv->render_height = frame->render_height; - - return 0; + // Section 7.20 + goto update_refs; } fb(2, frame_type); @@ -1573,6 +1578,7 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, CHECK(FUNC(film_grain_params)(ctx, rw, current)); +update_refs: for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { if (current->refresh_frame_flags & (1 << i)) { priv->ref[i] = (AV1ReferenceFrameState) { @@ -1592,6 +1598,10 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, } } + // Don't print debug log a second time + if (current->show_existing_frame) + return 0; + av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame %d: size %dx%d " "upscaled %d render %dx%d subsample %dx%d " "bitdepth %d tiles %dx%d.\n", priv->order_hint,