From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0603D4B48D for ; Mon, 8 Jul 2024 00:47:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 25DE168DC18; Mon, 8 Jul 2024 03:47:03 +0300 (EEST) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1D8CE68DBA3 for ; Mon, 8 Jul 2024 03:46:57 +0300 (EEST) Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-75e15a48d6aso1676210a12.0 for ; Sun, 07 Jul 2024 17:46:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720399614; x=1721004414; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=cx5J45Yk8dZ2xk+wpgrJ46fz6OriF+KJ1bwLdScVC1E=; b=NFRSW/eWb25m8AGV9Z9W0D3LP/W8Q8KlRhl3j4mjYxi4ELzxuXhDyyj/aUYQnkA1eG YI7Y0GKDLndwQd8TwpSpcLKG3db+JQOq7xEPphD7d5REENnK8kjfPxrUgC5VM7PTqyTO 9FogXoI59XS6OO3cebCNVg1EjstAuLQ1odjdtumtDhGBf8A3As/j4Q/Bl2vGprv7coLO iHUKzzGfyMvVqOdOPwbs5VLT03reKjNLt8KfjYCI3KkV6GkrKpq1gStwhW15rsmmBbt+ L5uhpjrTlZhV5dTKuIhEsYCiO8jCN8qoCQdwztoa+jLOjMjwXlHyIZIh3jNMZ037EH8E fjjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720399614; x=1721004414; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cx5J45Yk8dZ2xk+wpgrJ46fz6OriF+KJ1bwLdScVC1E=; b=kAeX5AUQ7v5zNYsjDiCNbkHxnaggsItl8M8yiV1Zjjh/aa0Wonu1bEMRg253aJvyYp guJYT+Uj2yAlibQ64QfKylTbMDiZFHRG1BUsjC4+9Gh92ynPKPjuuls43pn7sRbQhMUB tKmFPsd1F4Cw67mEjKUsjFqDwV0sIjvJsyPiJVnhymxoCeP76Tedj8h+J0NScexX9r2/ P1oieQrCcNV4OYQOL65FIneDK4EqEmkUfNXCY39b9wqVorgQKY8kSAHYoIMSf0mlpMu8 qnE5cuPlYTp/D4RR8VwzyZ8UYOOBL2GJzEpsx7G8kXtNjr0pdeHeK9KXRqWeK/7we2/Q EHxg== X-Gm-Message-State: AOJu0YwzwA/GPCOj1aag/XDGEr2vSRxBPjtunGubrsVHkqY/F6n6P6tU LroeS+GIqBGMmWSq67H50L/jDDokR1PLNVv5HFbbXMAR/mUPWigRcMHdUw== X-Google-Smtp-Source: AGHT+IFk5cEOjfKJOZBz6UohrQMWs4Lz5fyqf1AESQ0MUmP7lIiDFai39Z82T0GtVJrXFbs0Rv0klw== X-Received: by 2002:a05:6a20:7345:b0:1c0:f26e:2293 with SMTP id adf61e73a8af0-1c0f26e24e4mr1008918637.41.1720399613766; Sun, 07 Jul 2024 17:46:53 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fb2bbb0947sm70953865ad.16.2024.07.07.17.46.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jul 2024 17:46:53 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Jul 2024 21:46:40 -0300 Message-ID: <20240708004640.2808-1-jamrial@gmail.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/cbs_h265: fix range of sps_max_sub_layers_minus1 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: The VPS referenced by the SPS must always be present as the max value for sps_max_sub_layers_minus1 is vps_max_sub_layers_minus1. This replaces a buggy custom range check for the aforementioned field. Also, add the missing conformance check for sps_temporal_id_nesting_flag while at it. Signed-off-by: James Almer --- libavcodec/cbs_h265_syntax_template.c | 37 +++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 86ca00a0c9..c6db439b3b 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -788,25 +788,28 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, ub(4, sps_video_parameter_set_id); h265->active_vps = vps = h265->vps[current->sps_video_parameter_set_id]; + if (!vps) { + av_log(ctx->log_ctx, AV_LOG_ERROR, "VPS id %d not available.\n", + current->sps_video_parameter_set_id); + return AVERROR_INVALIDDATA; + } - u(3, sps_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS - 1); + u(3, sps_max_sub_layers_minus1, 0, vps->vps_max_sub_layers_minus1); flag(sps_temporal_id_nesting_flag); - if (vps) { - if (vps->vps_max_sub_layers_minus1 > current->sps_max_sub_layers_minus1) { - av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: " - "sps_max_sub_layers_minus1 (%d) must be less than or equal to " - "vps_max_sub_layers_minus1 (%d).\n", - vps->vps_max_sub_layers_minus1, - current->sps_max_sub_layers_minus1); - return AVERROR_INVALIDDATA; - } - if (vps->vps_temporal_id_nesting_flag && - !current->sps_temporal_id_nesting_flag) { - av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: " - "sps_temporal_id_nesting_flag must be 1 if " - "vps_temporal_id_nesting_flag is 1.\n"); - return AVERROR_INVALIDDATA; - } + + if (vps->vps_temporal_id_nesting_flag && + !current->sps_temporal_id_nesting_flag) { + av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: " + "sps_temporal_id_nesting_flag must be 1 if " + "vps_temporal_id_nesting_flag is 1.\n"); + return AVERROR_INVALIDDATA; + } + if (current->sps_max_sub_layers_minus1 == 0 && + current->sps_temporal_id_nesting_flag != 1) { + av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: " + "sps_temporal_id_nesting_flag must be 1 if " + "sps_max_sub_layers_minus1 is 0.\n"); + return AVERROR_INVALIDDATA; } CHECK(FUNC(profile_tier_level)(ctx, rw, ¤t->profile_tier_level, -- 2.45.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".