From patchwork Tue Oct 27 21:25:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 23259 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 7D467443F1E for ; Tue, 27 Oct 2020 23:25:51 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 50CA76891E1; Tue, 27 Oct 2020 23:25:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4C68E688191 for ; Tue, 27 Oct 2020 23:25:45 +0200 (EET) Received: by mail-qt1-f196.google.com with SMTP id z33so2157825qth.8 for ; Tue, 27 Oct 2020 14:25:45 -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=Lj8Jxi/20NquKk7sQj0J/jfFkBXgRrXChM6ekpjJmiI=; b=r9rp9xeE0HasZ22rj3Ui/KzubIl20ctUzsYZXMhnmD0yOrG86bkp4//f+hvISEeBfZ PFB9rOyAMSELMcRhnTiPqXjo71Ky11kdagUiWufiWerigpTbDxgEMhkcu4yJ96AFU9Iz bDe3eHD/49KmicJfqYfbS2hTYcM8qxkMGn/K/uf/knt9pE1G38c/cLFfG52NCu87Qb/M pOaCRw4UPyrMaIlt4pgwTJbKH2I4T3r6ygvO73ZGmWujCPcSu7xfa2Uc8oZGWi4i2WsS gAzeeBIgeBif/8VtLy+/fvcuJmAAl1ThJ3hLMCf9actxIcEwM8CJadYYCZ5JasgBWDIQ Hl7A== 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=Lj8Jxi/20NquKk7sQj0J/jfFkBXgRrXChM6ekpjJmiI=; b=rrLdQ1FMSvqhs+ZU4zBViHzQ20fo533D+u2gfX0NkZCAZo90otGkqtgPLBLlBKojls GINnv8ELBynefl567BDrCA1du8jjq0JqXXe588Vk9exb3ARWEWVwtfbD8o9nIpofEXiG UzEkeOv76dihCJFEiIywulKD335Numiyesp/gqlO09gBi787CCEp7kZbDxNWlqV4OZhA EObyMY7fp+wQanRZN0XHccnNm53ZhLEYHdWnNI5r+1nC9t1V8iwzBf2XNHOT/ou/WgEL 7ZoKQ/W0Xtcun8caXzbFtToWlbrCiIzJ5aG6LM8f3AuU68ENMIiEpbMTUBiuHLVu/8Lq dmEQ== X-Gm-Message-State: AOAM530JNiu6E2xsahLlwtAhoN2Ds1GEz0IBeJFiSp9baicOh5zE2dPl gmGhm6rjvZu9rW8QQiNH4yq3qllfRJQ= X-Google-Smtp-Source: ABdhPJxr+9TgcSZXfmhDjS+VpFhvy/APPMOH2HHUWa7yoEoMp4U1y8axpCqNaLGFvZCA7GNZTogMww== X-Received: by 2002:aed:20a8:: with SMTP id 37mr4163694qtb.201.1603833943665; Tue, 27 Oct 2020 14:25:43 -0700 (PDT) Received: from localhost.localdomain ([181.23.86.134]) by smtp.gmail.com with ESMTPSA id t8sm1774104qtb.97.2020.10.27.14.25.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 14:25:42 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Oct 2020 18:25:06 -0300 Message-Id: <20201027212506.21925-1-jamrial@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <5d24bc45-645c-3ff2-11e1-949cd974df6b@jkqxz.net> References: <5d24bc45-645c-3ff2-11e1-949cd974df6b@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/cbs_av1: add a range check to tg_end 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" Section 6.10.1 of the AV1 spec states: It is a requirement of bitstream conformance that the value of tg_start is equal to the value of TileNum at the point that tile_group_obu is invoked. It is a requirement of bitstream conformance that the value of tg_end is greater than or equal to tg_start. Signed-off-by: James Almer --- Not sure if we should clear priv->tile_num in other places, too. libavcodec/cbs_av1.h | 1 + libavcodec/cbs_av1_syntax_template.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h index a2d78e736f..386774750a 100644 --- a/libavcodec/cbs_av1.h +++ b/libavcodec/cbs_av1.h @@ -446,6 +446,7 @@ typedef struct CodedBitstreamAV1Context { int all_lossless; int tile_cols; int tile_rows; + int tile_num; AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES]; } CodedBitstreamAV1Context; diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 2df5619279..f0be7aab59 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1719,6 +1719,8 @@ static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw, CHECK(FUNC(uncompressed_header)(ctx, rw, current)); + priv->tile_num = 0; + if (current->show_existing_frame) { priv->seen_frame_header = 0; } else { @@ -1784,10 +1786,12 @@ static int FUNC(tile_group_obu)(CodedBitstreamContext *ctx, RWContext *rw, } else { tile_bits = cbs_av1_tile_log2(1, priv->tile_cols) + cbs_av1_tile_log2(1, priv->tile_rows); - fb(tile_bits, tg_start); - fb(tile_bits, tg_end); + fc(tile_bits, tg_start, priv->tile_num, priv->tile_num); + fc(tile_bits, tg_end, current->tg_start, num_tiles - 1); } + priv->tile_num += current->tg_end - current->tg_start + 1; + CHECK(FUNC(byte_alignment)(ctx, rw)); // Reset header for next frame.