From patchwork Thu Jun 27 03:05:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marth64 X-Patchwork-Id: 50188 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:bc92:0:b0:482:c625:d099 with SMTP id p18csp204051vqy; Wed, 26 Jun 2024 20:07:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVRAnsbUq378pzxdzVDVf7rvRmga2Lm4gPpBv1s3td/NdDRPqz1w/uJhc3zksTgq5H7mxKIJrctvyjgtMduBYWvndEOLAZJ+e6GWw== X-Google-Smtp-Source: AGHT+IHILZyn6005PlOhtOFeFwT/QxedOfv9ygIbcPQGMb8ic8cErmauoh6nP/8t3dhQ3AtDEDeO X-Received: by 2002:a2e:7008:0:b0:2ed:5a07:535b with SMTP id 38308e7fff4ca-2ed5a0753b4mr21435151fa.51.1719457643584; Wed, 26 Jun 2024 20:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719457643; cv=none; d=google.com; s=arc-20160816; b=m4LW3H4VanZKBMulb7V8LNd3bFHPcYgNJpJpGyYDf/0OjVRPm6bWCkgqpVbwZ2+edX ij8eMz0mkCOT4WFzaX32Jg1YxG0/vOhFcjZdoY2WlkLYh1oarscmAsr+pyXJWSW+adng J3bSHUZP8GXcGPTIjKIeiab429vQ/7xlxX+VvTfVY5Mj/cOBE5gXfuaG2EV2kIAmSEI/ so2/ny4mnubkDi5SwKKfBPEuauIdKijrGLXdEeYdGv9sLfVvOKMM3XoBRyfzzpgoZq1Z uhCm4KHg4yRADxV1t2IIxNJTbCeMXftDuxyboQ3F9BRE4oaKBAgScgvGmC24Bi3qpHHD xJcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=MxBPVvSvv1G/QrFWDogRtaOTP8tkulHrE32FWzINOpM=; fh=PlWMzmI9LD2qGS7ipLrQl8z0iaQTLQLHzoGuXcBzpCg=; b=o5Xd13hHrXJdFJ04Sq4SGk8IJZkAdiDI0+yqd7QJPAnG4H2EXJMkdsCyme7JrMcUfq ghMfRdEax3phAP2ccnDLBWwsh52eA8a+/CA3o64EuxBzbbNWLmuRWJT8ONiYrxlwhive fjH/KZUgNhZixXth4Aywij+SajxG3N16BD3Ya5s3viW1z2HVRtfAmMHsPZMTmlHrZUeI SbEhdzuspWVyN8q1vbQtPmgWH6WADYCL55dd10Y4JU7ka266m7OwT6aEvF9LdZflksMX 4a4Hl8BxfGk7yB4Cb5wyLHY/OubmaBaSExgtE+sw+LbHzzywLwkQx0gj4YVI5qYhpuzR J5LQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@proxyid.net header.s=google header.b=E2jsMtvL; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2ee4a4d2bc4si1084001fa.656.2024.06.26.20.07.23; Wed, 26 Jun 2024 20:07:23 -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=@proxyid.net header.s=google header.b=E2jsMtvL; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B5F7368CB61; Thu, 27 Jun 2024 06:07:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f228.google.com (mail-pl1-f228.google.com [209.85.214.228]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 43F4268CB61 for ; Thu, 27 Jun 2024 06:07:11 +0300 (EEST) Received: by mail-pl1-f228.google.com with SMTP id d9443c01a7336-1fa75f53f42so16090565ad.0 for ; Wed, 26 Jun 2024 20:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proxyid.net; s=google; t=1719457629; x=1720062429; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YbYfrOGiUc7qE9rsVmZgRwnKbg3g7F3bjDpqy2ffI3o=; b=E2jsMtvLkOCSAoBeuJFoAk1bIXTY6JqqmC5wJaG8NqYr48xDhpOncz32Z5FsSuPB2j octwlkwByPgTU4Y9BKewNSyK2iQJMjQuWZlXYVRMEAUTMsCvcoF2NZsC4v/t4kkaadtv ptBjfiWmg4p/9mY3TnIS4Fyi81ETk6/BZHnONtvCrZ6BD+RLV2PdZjElJ2/gOyP1bfRf CzPAT0LXuv1TDwrE61HjrMIe45w7H5lkgW2Rqy1Ze6PJFGclm9YDfQW08juG8Vz7V6Nu YKjN/UVybZIsshtUqVas3EL2LbBk2Iz2C/93DZfmnIUver1OfaJ2y1nQ4y7b3W79xAbO zo0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719457629; x=1720062429; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YbYfrOGiUc7qE9rsVmZgRwnKbg3g7F3bjDpqy2ffI3o=; b=HFSuINlu61Y0PWBvZQoemN2LR7g+2EqITQ6LcN3um4kEL5+uluqH1jIBqbh7bLoiyI Ope3NiaeLrXARag/+qFeF8EQiuVW2QYE/rwPBRhQukxmYTPah6KngYpjuf3js2TlO+xi PkXP/J6FXQ7wraAYBq/d59YNOC+yByhuODrkRC4t0mpHpg0pFXQPlfksZW6LlAj8xjhk Z9SxQ1w+63hCMETr2WrzmKAp031161cD8ou/uhLNMBBzrU6tBnHuEy1N/tEr3iD6LJdC ZVZIIt54yP91Z4I1WH9x5Ot88PpGXYzmb6hPxpG01cJLri7nkM5Nzf6Qp6WMs7QGHQsM tmwg== X-Gm-Message-State: AOJu0YyG7/K/jKBops4btdRXMV8b9GpPqvPzdd1b2eEOgHyTbiDVRgKD xQjcc5XICFxr23Zexf5LKI5KnIVZAueVn7xyFzgqwht7WbhXLqt8KYaphJFriK54pkxVyqd6MT1 yevJFVR/ceubhqDulRu1C3RW6ac7eiKsh7aO1hSMH X-Received: by 2002:a17:902:e807:b0:1fa:2ae7:cc37 with SMTP id d9443c01a7336-1fa2ae7d4damr136131135ad.63.1719457629276; Wed, 26 Jun 2024 20:07:09 -0700 (PDT) Received: from wsx-cc1-001.. (c-76-136-218-80.hsd1.il.comcast.net. [76.136.218.80]) by smtp-relay.gmail.com with ESMTPS id d9443c01a7336-1faac9a5b31sm117305ad.119.2024.06.26.20.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 20:07:09 -0700 (PDT) X-Relaying-Domain: proxyid.net From: Marth64 To: ffmpeg-devel@ffmpeg.org Date: Wed, 26 Jun 2024 22:05:46 -0500 Message-Id: <20240627030546.143368-1-marth64@proxyid.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range 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 Cc: Marth64 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: g7bTlN8u3XFz Chapters and duration are calculated together in dvdvideo demuxer. Previous chapter calculation logic treated extraction of 1 chapter using chapter_start and chapter_end switches incorrectly, returning the duration of the entire title instead of just the segment. Fix the logic so that it calculates and returns the duration of the chapter segment instead. Additionally, validate that chapter_end exceeds chapter_start (except in the special case of 0). Signed-off-by: Marth64 --- libavformat/dvdvideodec.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c index 8326595e1b..e7132725b7 100644 --- a/libavformat/dvdvideodec.c +++ b/libavformat/dvdvideodec.c @@ -865,8 +865,7 @@ static int dvdvideo_chapters_setup_simple(AVFormatContext *s) int chapter_end = c->opt_chapter_end > 0 ? c->opt_chapter_end : c->play_state.pgc_nb_pg_est - 1; /* dvdnav_describe_title_chapters() describes PGs rather than PTTs, so validate our range */ - if (chapter_start == chapter_end || - c->play_state.pgc_nb_pg_est == 1 || + if (c->play_state.pgc_nb_pg_est == 1 || chapter_start > c->play_state.pgc_nb_pg_est || chapter_end > c->play_state.pgc_nb_pg_est) { @@ -878,8 +877,11 @@ static int dvdvideo_chapters_setup_simple(AVFormatContext *s) for (int i = chapter_start - 1; i < chapter_end; i++) { uint64_t time_effective = c->play_state.pgc_pg_times_est[i] - c->play_state.nav_pts; - if (!avpriv_new_chapter(s, i, DVDVIDEO_TIME_BASE_Q, time_prev, time_effective, NULL)) + if (chapter_start != chapter_end && + !avpriv_new_chapter(s, i, DVDVIDEO_TIME_BASE_Q, time_prev, time_effective, NULL)) { + return AVERROR(ENOMEM); + } time_prev = time_effective; total_duration = time_effective; @@ -1548,6 +1550,13 @@ static int dvdvideo_read_header(AVFormatContext *s) return 0; } + if (c->opt_chapter_end != 0 && c->opt_chapter_start > c->opt_chapter_end) { + av_log(s, AV_LOG_ERROR, "Chapter (PTT) range [%d, %d] is invalid\n", + c->opt_chapter_start, c->opt_chapter_end); + + return AVERROR(EINVAL); + } + if (c->opt_title == 0) { av_log(s, AV_LOG_INFO, "Defaulting to title #1. " "This is not always the main feature, validation suggested.\n");