From patchwork Sat Jul 13 14:58:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 50521 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2298:b0:482:c625:d099 with SMTP id fp24csp1405832vqb; Sat, 13 Jul 2024 07:59:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUc9XOpA8jdgZQQYImsxdSL9hJ50rA1eTi+wuvB9qaHIQTddiVQyIABiZiZE/QN5Ke6pxDIVL2rMsSnPmWYJ5qDgnGApvcnN9gMpQ== X-Google-Smtp-Source: AGHT+IElrV+jAI9FIfuFKKPP9dRR0kqPgExl/UCS/oaGPP71gcK4Tt1cJXtIza+cY0C2ZxgcRLB5 X-Received: by 2002:a05:6402:26c7:b0:59a:aa54:4e23 with SMTP id 4fb4d7f45d1cf-59aaa54586cmr2381474a12.3.1720882754451; Sat, 13 Jul 2024 07:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720882754; cv=none; d=google.com; s=arc-20160816; b=v1wqnEIJKBlFNhxbW9HCnvq09bFBI8zZchw8WEE7I/L8XUR5YK2FRCaz1b27PxVJ5a fiMVZ+dnhT+yW8Kuf1BNpa7JiD8QLC4nvc90tbcreMSunfig1xuNrdJXFDP7QKTaXpjM u0LA9d6k9EULTQpgCKQK/89tc+iFrBw4jJ8ICpxwun8Xe3j4SepraU5Uq3LkJgYsCZce lL2QZUGdOXEATkLcNUnpIxwg5yxF20M797q9n2mUfsMMuj8yArSpxhfZuPxaENvsIDqc pzrhz5LSAhT8S/rWhtjIkrIpDeoKZCUftvbUdel6md56LKlg6pHbEDL5eVBs7I2r9p7y oGvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=Ok8Zuv1hwOHZSW3oHKigMu74gxSJMwlGXXF1L2iTJi4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=PlNyQR3zSsmB9nz/OW0Z3xIW9hV+OlLMuapmpsYKEAcmUToNN6yPSVIWh/2kkDgLuH DFX/bdUdZOCiKRa0ZJLUMw8lojWn1o0SuXAUvSjUcmEMsVz23msKeD6QRu4KK7sJHGNH qVBbiLJ2R8Y1ZMJcUkeVP2t3F+sPVWsXvj8EptwBmaMIhswFGlmP54JAhnns7EQ21Hb7 dqAobu/pN63nBnaCUr9f2bCo3132lnp56KgJCTQpTLbvnuQ3JjZQtxo8ASwqPHjQTQQn oi1mE+EltEGU57mxJJ0BwKrHss0ELN2NG/lRYyiiOW3eyPxAwFzOV2mFwnocbQSp7QTh kTxA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=cuLTcPDt; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-59b26f662c1si641474a12.383.2024.07.13.07.59.13; Sat, 13 Jul 2024 07:59:14 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=cuLTcPDt; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 92A3068D82A; Sat, 13 Jul 2024 17:59:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C67868D82A for ; Sat, 13 Jul 2024 17:59:04 +0300 (EEST) Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1fbc0a1494dso19596995ad.3 for ; Sat, 13 Jul 2024 07:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720882741; x=1721487541; 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=cuLTcPDtcBHLFCBoGuKvxGHM3oxJj7ZjyJzRRS+4kEKtNNf+x9eKiGJNygDXnKGuG4 QgLlUvd4g9LcqdOHpwq8YPkMt44l9Efn60fGDgcayAnLJQmIuXx4l6QswZATnBICI2bD /4utsrPF0KzL8WeTuJTsqhj/Us26aVwfnzQV8XXr/WGgTFagUcBnh/z8b5cCAQ5Ga57Y kDR1m9H+xiHTSaxnaetufSJ+by4TRhV+2n77s7gxaiHsWwsWWwv4gIQDKaEt6aMqSaPH 4+atfbZ/hSBqVw3Ti3FQALLDn/49kKTWECHL747bVaJQ1vMY/kdt8c11sIukf0Xbm90Z qOHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720882741; x=1721487541; 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=UQxWeoUq9fDyV27RL/FCg77dHSq2ndxQo74n4DEaYdEFgZpgGsEZ8sjIrIPiFcV8YT q2uCAx7hlPccVtHeQX6nZOjFQWDhvw11ZNuywMYeV73lqVfgzeRrnJxkVvm+d7VfWMuX FLDpgmlI/r7CzuYYauCsKGwpoMzfF8BbecROtQLTP1n13kIgd/mxUcZQ3y3r6LSUc0Ra 8jTMWNVMuhsBhZLvFNOttW61NclUal8Z51fdkkfKoFntTikPMCcs4p5EJgYiDKn4AInb ImwqQEv0I0uY/jjMQYvkb88loM80+OYnA2XVu87ITyrUymsz77UjjNHdIxhpRcvRP/zP Q7aQ== X-Gm-Message-State: AOJu0Ywul123J2X+akkZjFs3agruin4w30fczPw8OWXAMnpbW91eh76M U5xsDTmfo04JqCEnXINYjpBIeqF0NRSMni2YEppH0Jr6sDOZK04UKePteA== X-Received: by 2002:a17:903:11c3:b0:1fb:82f5:6641 with SMTP id d9443c01a7336-1fbb6d0b69emr113184185ad.23.1720882741321; Sat, 13 Jul 2024 07:59:01 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fc0eea3cfbsm9800275ad.115.2024.07.13.07.59.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jul 2024 07:59:00 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 13 Jul 2024 11:58:43 -0300 Message-ID: <20240713145846.1331-1-jamrial@gmail.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: f6t9yA6dWLVb 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,