From patchwork Thu Jun 20 17:45:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 13649 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 68579449D65 for ; Thu, 20 Jun 2019 20:45:47 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3E0F968A937; Thu, 20 Jun 2019 20:45:47 +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 EA986689E37 for ; Thu, 20 Jun 2019 20:45:39 +0300 (EEST) Received: by mail-qt1-f195.google.com with SMTP id h21so3998207qtn.13 for ; Thu, 20 Jun 2019 10:45:39 -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=ixhDW52blFfYrl6VYzYy/RQypCjHF2tOfyWEGynN7FU=; b=inv2gkcqtEtaYzREHn0SSQmTEZAx+G2v8Sg9PJHNXbM1o/rwyN0EowDbISgiVW2Itf FXLH0R2tSZlQ7w+6MqorMpSr4SkoN8tkTQwSgzDvLqmnnSc6Nil/Ed2fBRO5nQQBx0hn 04WKmc552UjlP4Nv9ZUHw3nWeHyQ9H/4lnyJ7dS6cyfzszkACBpZo1eFlHpxDRovTXLE 6eeXOip3S2rO6GL6jbMDUWmiA9H20VHNajJMux74UhRaZM+/+EemX+s7AwjNtam58Uhw Dx8eUaZMkVhEkSsT71tp5iqW4qibjg6A7pmd3xYa4BKViHpGwzBQK6qi2JfWJJ3joy7A MEMw== 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=ixhDW52blFfYrl6VYzYy/RQypCjHF2tOfyWEGynN7FU=; b=enciIb1IDcFPLBnVcJDVvWhvz+jjN9D4YEyLGajCgsaCn7qct4rS4SpMn4zTDm1DCf zUUP0VdE/abqbYnEqr/QUSW02a7yjCTH732i89YgEh0qiun2pTL0y0jO7DfFrOAm/neR bs8J8NEAC7f8IYXTaenfWbsDK9/8fKBO3ECUQ8998yrX6hbC0JEPvpuIB7/ZRQJTEN2e nCOJHQqecTSeY6UBYz7Y7YFzI2z/jNSpEfA4aw4ljixGgb5W3Ta94bk0Sz1XrrVxz6Wy sFPJvSZZ71HdokDJh8d0iDNx0F2TgTj0vDJuJlpl2ZSwb2wjCDkuVIajPwaSXPMnhbfv Eivw== X-Gm-Message-State: APjAAAXwSqKL7l3zWyLHB2frLA0pmDpKPI0MtHQr4lA9E6sRzzxmwMFA gOEhs2JKB8Z5GfyuSIZrf6+hijzn X-Google-Smtp-Source: APXvYqxX567c6o3E+E/3LfAqJdtFGsY+ax84LOO6mGKj7SeBRtU/ylj7CpKip7jUyDhGKx7stkUjLA== X-Received: by 2002:aed:3e36:: with SMTP id l51mr112366263qtf.269.1561052738137; Thu, 20 Jun 2019 10:45:38 -0700 (PDT) Received: from localhost.localdomain ([181.23.83.211]) by smtp.gmail.com with ESMTPSA id u7sm334386qtc.25.2019.06.20.10.45.37 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 10:45:37 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 20 Jun 2019 14:45:24 -0300 Message-Id: <20190620174525.6515-1-jamrial@gmail.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h265: fix valid range of num_tile_{columns, rows}_minus1 in H265RawPPS 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" The spec states they can't be higher than the respective dimensions of the stream in CTBs. Signed-off-by: James Almer --- I don't think it's wise further limiting the range to the maximum currently defined for level 6.2 using those two HEVC_ defines, since a stream could in theory go beyond them (New levels defined in the future?), but the alternative is making the column_width_minus1 and row_height_minus1 arrays much bigger, or dinamically allocated. libavcodec/cbs_h265_syntax_template.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index f279d283d9..d2a20ddb35 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -1045,8 +1045,17 @@ static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext *rw, flag(entropy_coding_sync_enabled_flag); if (current->tiles_enabled_flag) { - ue(num_tile_columns_minus1, 0, HEVC_MAX_TILE_COLUMNS); - ue(num_tile_rows_minus1, 0, HEVC_MAX_TILE_ROWS); + unsigned int min_cb_log2_size_y = sps->log2_min_luma_coding_block_size_minus3 + 3; + unsigned int ctb_log2_size_y = + min_cb_log2_size_y + sps->log2_diff_max_min_luma_coding_block_size; + unsigned int ctb_size_y = 1 << ctb_log2_size_y; + unsigned int pic_width_in_ctbs_y = + (sps->pic_width_in_luma_samples + ctb_size_y - 1) / ctb_size_y; + unsigned int pic_height_in_ctbs_y = + (sps->pic_height_in_luma_samples + ctb_size_y - 1) / ctb_size_y; + + ue(num_tile_columns_minus1, 0, FFMIN(pic_width_in_ctbs_y - 1, HEVC_MAX_TILE_COLUMNS - 1)); + ue(num_tile_rows_minus1, 0, FFMIN(pic_height_in_ctbs_y - 1, HEVC_MAX_TILE_ROWS - 1)); flag(uniform_spacing_flag); if (!current->uniform_spacing_flag) { for (i = 0; i < current->num_tile_columns_minus1; i++)