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 113F84B082 for ; Thu, 27 Jun 2024 03:07:21 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EEBC068D702; Thu, 27 Jun 2024 06:07:17 +0300 (EEST) 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-Google-Smtp-Source: AGHT+IEHA+FLSQ34QnXh5BIR0cHeF3PpzUfs3RaqL1voX8eW3Am2X6yxstgtbndeunECKTmWwuRLKD/4E2MA 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 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: 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"); -- 2.34.1 _______________________________________________ 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".