From patchwork Sun Aug 23 19:23:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 21853 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 EAFEF44AB55 for ; Sun, 23 Aug 2020 22:24:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D2C396898C1; Sun, 23 Aug 2020 22:24:29 +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 F1143687F97 for ; Sun, 23 Aug 2020 22:24:22 +0300 (EEST) Received: by mail-qv1-f68.google.com with SMTP id r19so2843172qvw.11 for ; Sun, 23 Aug 2020 12:24:22 -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=HBxJ08ST/v4xNDxuA74kGm0PJwfM9q3M58PwTR/EH1w=; b=oXpk7nMqcmzpC6RHSkGbwnoM3ZDl4LpDiN6Ve2F5Ng3WDx8qoj0d+BYOs1N2asXHdv UKgYRomRSZx3EIWpXKLw6Yty6v3wRSiSeH92qh/byPulIkV1jK+SlHQUH94AJcCXRzBc 8ob6Ekto/pWV6DIGShJqxeP6AQZjUe7EGQREfwTqI8coSKygJXc7pIq1J7d8oH7ERf01 /v9ENDRfqshE/RR6TCrMvLPCmm9YaRoBOxZk3+tNS507b51410vV1BDJ10O2o4oGi0lT 1+j9vpd9gzf9J6GIv5Y604hCSCShC6UeTSloznojxi/va5lTMczaHHD5ToVCYeYB2/SA NPBA== 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=HBxJ08ST/v4xNDxuA74kGm0PJwfM9q3M58PwTR/EH1w=; b=LCw8L9QW/881+Rv0rPiDpKdk1JE7ODCu6AMBWB7tCWdKMga2iZ+dFQ8Vj2Gi5Dy6hl kzVl1+D197SxYudearsSavySG1bz6hoWBZqutUh69/iUisOsZTHQlLB/s56cVyMEVg0o 2nfIQq8uFAcwjpUdOLWU/i77CWjfdg1uOMyQAXdQY2MeUbqRf4GENfU3Hqnp1hCGrRhW MnhhaujhuHmIz1QXAFI51hUqj0Qsohph+hUA22Ye6SkqB0mvFtCEOduIMCsDHTiOBBUh lOahs+h296hQ4LrK3xtb2CKrShQF5rbLrCs+71rm42f6kv6hx62wcutPZj+oznvsz7ky G/lQ== X-Gm-Message-State: AOAM531+D5ArYZ47OR8ONyop9d1LyFXYwWW2UgH3ZJuKzwZRxUK9c32/ 7m0D5eZWms9Wv2oAysKS0lOA6U33FAg= X-Google-Smtp-Source: ABdhPJxiz6I5A+ljhvv5gxDLTp4VFmL0gancZiIL02zMOZXBgp/oaat0LhfpdAknGLZ8FETHDBPyFg== X-Received: by 2002:a0c:fa85:: with SMTP id o5mr2061935qvn.91.1598210660250; Sun, 23 Aug 2020 12:24:20 -0700 (PDT) Received: from localhost.localdomain ([181.23.70.159]) by smtp.gmail.com with ESMTPSA id y9sm7890838qka.0.2020.08.23.12.24.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 12:24:19 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 23 Aug 2020 16:23:55 -0300 Message-Id: <20200823192358.12087-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: infer frame sizes when not coded in the bitstream 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 makes them available for all frames within a Temporal Unit. Signed-off-by: James Almer --- libavcodec/cbs_av1_syntax_template.c | 43 +++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 3a832c3ca0..dedd549572 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -492,14 +492,14 @@ static int FUNC(frame_size)(CodedBitstreamContext *ctx, RWContext *rw, if (current->frame_size_override_flag) { 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; } else { - priv->frame_width = seq->max_frame_width_minus_1 + 1; - priv->frame_height = seq->max_frame_height_minus_1 + 1; + infer(frame_width_minus_1, seq->max_frame_width_minus_1); + infer(frame_height_minus_1, seq->max_frame_height_minus_1); } + priv->frame_width = current->frame_width_minus_1 + 1; + priv->frame_height = current->frame_height_minus_1 + 1; + CHECK(FUNC(superres_params)(ctx, rw, current)); return 0; @@ -516,14 +516,14 @@ static int FUNC(render_size)(CodedBitstreamContext *ctx, RWContext *rw, if (current->render_and_frame_size_different) { 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; } else { - priv->render_width = priv->upscaled_width; - priv->render_height = priv->frame_height; + infer(render_width_minus_1, current->frame_width_minus_1); + infer(render_height_minus_1, current->frame_height_minus_1); } + priv->render_width = current->render_width_minus_1 + 1; + priv->render_height = current->render_height_minus_1 + 1; + return 0; } @@ -547,6 +547,11 @@ static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext *rw, return AVERROR_INVALIDDATA; } + infer(frame_width_minus_1, ref->upscaled_width - 1); + infer(frame_height_minus_1, ref->frame_height - 1); + infer(render_width_minus_1, ref->render_width - 1); + infer(render_height_minus_1, ref->render_height - 1); + priv->upscaled_width = ref->upscaled_width; priv->frame_width = ref->frame_width; priv->frame_height = ref->frame_height; @@ -1273,6 +1278,13 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, fb(3, frame_to_show_map_idx); frame = &priv->ref[current->frame_to_show_map_idx]; + if (!frame->valid) { + av_log(ctx->log_ctx, AV_LOG_ERROR, "Missing reference frame needed for " + "show_existing_frame (frame_to_show_map_idx = %d).\n", + current->frame_to_show_map_idx); + return AVERROR_INVALIDDATA; + } + if (seq->decoder_model_info_present_flag && !seq->timing_info.equal_picture_interval) { fb(seq->decoder_model_info.frame_presentation_time_length_minus_1 + 1, @@ -1287,6 +1299,17 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, else infer(refresh_frame_flags, 0); + 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); + 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; } From patchwork Sun Aug 23 19:23:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 21854 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 2967844AB55 for ; Sun, 23 Aug 2020 22:24:32 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0DDFD6899D2; Sun, 23 Aug 2020 22:24:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4488B6899D2 for ; Sun, 23 Aug 2020 22:24:25 +0300 (EEST) Received: by mail-qt1-f195.google.com with SMTP id s16so4810871qtn.7 for ; Sun, 23 Aug 2020 12:24:25 -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=6D4n2j5rz/5O/C/zWscPVYiAyLzGgYA1ELquES57ijo=; b=dMIQzqB1ZanOxP1CkCYh+HbhvHKv5/Jot1C0HI3Ga28b1yDByoHnuDpxcdFN9TcNNh xz+f5qDpIgE9MQKkXz9uhAidFS9uepmZMRGPnP0EfaGR2MuIgsXbi5aG7r5jQSipKleP geaiJoL34G8Tb8RWZj5jXup/Eq0zuVNLvW0aB3VT2rFBMtHy5XEhvnLK4h1Lw/h5HeLw 2udVWVDYqAiaBMtKUPLDIoMDarww0u7kyZCKZLx2G531/qbA6mEycXuqJ9B5SgIw50V7 L87USx2xx5YpE8xMkLii6/6QVYU37ivtCCvIMe4dRL8/MM4KVGIli+fE58dg7G2yZ618 NL1Q== 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=6D4n2j5rz/5O/C/zWscPVYiAyLzGgYA1ELquES57ijo=; b=AiRscAFzcKJSlNnEbiPYLQGvpp7NSCC0DoOcdhqEVfx+61TpEDGNHk3oghHhglYuLM S0AC83MP4Qv9odbhFGa2+cRZ6EtKn0UQXmLVCPylF6oKbIU6WqhritdflJv2W8TtJWFl X3YPIwfBKpcciTE38SkBVgkbs+7jc6F8xvUHwzxXAkbZeMKEeGrIVhYTQt9rqUJuxgBU Eu70HK7txj3WCF4SFirXqA/lIZvRY/otiUEL1t4x8kmHy7s37NeueS8Z8tIOpERAVb6o olsn4ws2AKRDFmkh+q6qaSoPVBKs1MCsmrFfz4YODpGRoyKeKO4O5gsrc4HhQ99ESWUf +BSA== X-Gm-Message-State: AOAM532Km0VDTRmq15gSSzB8ETnSejvNtGBOdsMJ2RnQuUXfWIOl/QBs k5zQm7dzJfNAqCiTNaZzhAxF4Qy345s= X-Google-Smtp-Source: ABdhPJxE2ghXGLWU2ZlxOSqKHOh+Tjk/RKgPmrq/nQKdoYT/RdrbVx3IzGPhjuRU1ZabkKzbGyxQvA== X-Received: by 2002:ac8:4e91:: with SMTP id 17mr2060227qtp.284.1598210662536; Sun, 23 Aug 2020 12:24:22 -0700 (PDT) Received: from localhost.localdomain ([181.23.70.159]) by smtp.gmail.com with ESMTPSA id y9sm7890838qka.0.2020.08.23.12.24.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 12:24:21 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 23 Aug 2020 16:23:56 -0300 Message-Id: <20200823192358.12087-2-jamrial@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200823192358.12087-1-jamrial@gmail.com> References: <20200823192358.12087-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_av1: infer frame_type when parsing a show_existing_frame frame 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" Signed-off-by: James Almer --- libavcodec/cbs_av1_syntax_template.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index dedd549572..28d9ab9817 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1299,6 +1299,7 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, 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 Sun Aug 23 19:23:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 21855 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 0CF0644AB55 for ; Sun, 23 Aug 2020 22:24:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F260A6897CD; Sun, 23 Aug 2020 22:24:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 93B21689ABF for ; Sun, 23 Aug 2020 22:24:25 +0300 (EEST) Received: by mail-qk1-f181.google.com with SMTP id z3so1404635qkz.7 for ; Sun, 23 Aug 2020 12:24:25 -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=nfJ9MHDISBTHbjlm3mZ2ciSUTbeNZk8RK4RGjAOwoqg=; b=snMnA2q8oywylCN+ugojw1uj3pCPPb4m3qmJOWU0n/h/eWETojrcI6CJAPUiPh7iiI mn5r5vaKWGUcCvI8SUqpysZIcS+Y3TRq5bUJbAhhO8Rdd5zlkpQEuvRzbKYrVze6DHLF dXJx8gZ+5XbxJpEF2SGUGXfGNn6NaJCxDn1ixOMpYZGPs696tAJyr1E0eBwL4quFAcH/ 6a41UNPwugl4WU8+ZXtPAf4XE9EsQkjcgJP7qZCPIaRP6UBP10o4ZXF6djfHUZwXHWls giXsJBnoHtKAXSgkDnw2tsMvyd2p0nnkeV0ied+yGxumUDCIBCTvVTen1qnhT3CkefRd vxnQ== 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=nfJ9MHDISBTHbjlm3mZ2ciSUTbeNZk8RK4RGjAOwoqg=; b=bH4nmGGBmdiVURVZcNkdCG5G8cucvF+ahzBpVM8FFww5Nk2oTgQFgkm4Nu6eNjUY+E Xn26ybz9T5G+pxZ+iJiL5iEHGgrwUa2qutnVWmfrQiI4NcPDr8dbvamVfnqZQiBCd2sg Va+wHIg2HXDJpGorXu1sbmysweSLIy3A4IwDQSMMZuLGjsIp5zAKqEH7DdfTvWckH4wo mSUbRFvN3zmfG9c35fOb2KDuFt1xYaTlRG4AKfd6yzf/Es1kXd4BzI7GffOWSMjZSf/M 9kDDLbwo9MamgwDE5VUCO2gg0JZtPA7fFVCZL9/tnGgOSPunnJHWJn0Efim+0GoI0wAw S5yw== X-Gm-Message-State: AOAM532csk9G5T7IrTHen7yEsk+4fH4IYu6Cjpp/JKfr64QzpftPX7qc NTBlwCzZCPbOSvGRyRdQot/u5cB5ovM= X-Google-Smtp-Source: ABdhPJzKjSG1r48C7aiO6Ny7KN3MRJOjvryKFTkgb6ajwQZTwF2bQ7hRrQXbNW5pCO3rDTu8LiZMlg== X-Received: by 2002:a37:9a88:: with SMTP id c130mr2046956qke.298.1598210663984; Sun, 23 Aug 2020 12:24:23 -0700 (PDT) Received: from localhost.localdomain ([181.23.70.159]) by smtp.gmail.com with ESMTPSA id y9sm7890838qka.0.2020.08.23.12.24.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 12:24:23 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 23 Aug 2020 16:23:57 -0300 Message-Id: <20200823192358.12087-3-jamrial@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200823192358.12087-1-jamrial@gmail.com> References: <20200823192358.12087-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/av1_parser: read frame properties directly from 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" Simplifies code Signed-off-by: James Almer --- libavcodec/av1_parser.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c index cd426a2b0f..1b9868d364 100644 --- a/libavcodec/av1_parser.c +++ b/libavcodec/av1_parser.c @@ -99,7 +99,6 @@ static int av1_parser_parse(AVCodecParserContext *ctx, CodedBitstreamUnit *unit = &td->units[i]; AV1RawOBU *obu = unit->content; AV1RawFrameHeader *frame; - int frame_type; if (unit->type == AV1_OBU_FRAME) frame = &obu->obu.frame.header; @@ -111,30 +110,15 @@ static int av1_parser_parse(AVCodecParserContext *ctx, if (obu->header.spatial_id > 0) continue; - if (frame->show_existing_frame) { - AV1ReferenceFrameState *ref = &av1->ref[frame->frame_to_show_map_idx]; - - if (!ref->valid) { - av_log(avctx, AV_LOG_ERROR, "Invalid reference frame\n"); - goto end; - } - - ctx->width = ref->frame_width; - ctx->height = ref->frame_height; - frame_type = ref->frame_type; - - ctx->key_frame = 0; - } else if (!frame->show_frame) { + if (!frame->show_frame) continue; - } else { - ctx->width = av1->frame_width; - ctx->height = av1->frame_height; - frame_type = frame->frame_type; - ctx->key_frame = frame_type == AV1_FRAME_KEY; - } + ctx->width = frame->frame_width_minus_1 + 1; + ctx->height = frame->frame_height_minus_1 + 1; + + ctx->key_frame = frame->frame_type == AV1_FRAME_KEY && !frame->show_existing_frame; - switch (frame_type) { + switch (frame->frame_type) { case AV1_FRAME_KEY: case AV1_FRAME_INTRA_ONLY: ctx->pict_type = AV_PICTURE_TYPE_I;