From patchwork Tue Jul 2 06:41:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marth64 X-Patchwork-Id: 50278 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp2232955vqv; Mon, 1 Jul 2024 23:41:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV+qtbTFCsSjsTnXq+OFen8Sc1fCGAq+t8jDhm8zNDnEEWJZTen85IVvcY+rxFGWjmF5F73wpJ8xRJr3MAkd4QbTVqv/9kuM5B5qg== X-Google-Smtp-Source: AGHT+IGQZAnsY3ZPMRNBnD1NwkQxojUpnR4j6bBS3QQWbyn/HStDsdnqPHh5rdJNQiPvKpuTbz91 X-Received: by 2002:a05:6402:2711:b0:57a:2eff:8ae with SMTP id 4fb4d7f45d1cf-5879f0cbed1mr5421589a12.1.1719902514301; Mon, 01 Jul 2024 23:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719902514; cv=none; d=google.com; s=arc-20160816; b=eV2K8qSnRyD8jvb8P81a5+xAsgshZNgA1CKFCS4JaLV9ltaqBJUad5UXxhSJLQzATv M8349sLLwXOwQJseR2yZU6DACTR8G2IoTJvLA2o+MjxMxKqwbCKkxLvjFipmaKYSHeJp G5jY/wMEExyp0Pg5Gra8MNcLHosIwwM+n9YSJYFclZ4IMRgZRyQ8yhVtszV23h6yqoQu KHg3tzHg/eLahCnR6R+NnvkpDC++MBwReGG5X3s4QtT+O7BeMcLzRJt+VrD/UTHKFGYN IYX6B/KkMU0l1tVbYLdWG4SKOwTgLAsh6E9jRI+TD8GD0KFHenew/gxXJgc4MiMElXor dV8A== 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=G5o1tKYzI8U1EQA70mwadzTbBgRY4TY+eg9wWiyvT3c=; fh=PlWMzmI9LD2qGS7ipLrQl8z0iaQTLQLHzoGuXcBzpCg=; b=Y8zSytGulZs8N75n1kdYizaAZOk1iwPIod7Pyu6id2wAeiUaXCGzZybxG5rRUAaa0M N5uuCO1jVh2MuXfyLhPvhteoGxsVjqxWcKi19yomk/KDu+i1JuRxihjCEXbiC7GKRlR/ /HQnTcDJoQfF2KlBzcSzAx4Pz2kXRTer0QQpR305fYSuMlZkb3DSvn/oWkxiZsmHEHI6 KgVaZeL3cS0gjkR/IR8G9eobYcg7VAzMnj+WoaRj5WSNrulf6atueiA5TafxAHOJXYxx NS+p1WePmmn6DC75Wtaww7TBNSvIX8VtRVu3N7flBeUDUPiP90ScW64F3EjUvAyYJ4bv ZZsA==; 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=hQNj3hJ4; 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 4fb4d7f45d1cf-58b30ab3423si607396a12.118.2024.07.01.23.41.53; Mon, 01 Jul 2024 23:41:54 -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=hQNj3hJ4; 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 1E29168D8C8; Tue, 2 Jul 2024 09:41:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f225.google.com (mail-il1-f225.google.com [209.85.166.225]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B3F868CB9F for ; Tue, 2 Jul 2024 09:41:36 +0300 (EEST) Received: by mail-il1-f225.google.com with SMTP id e9e14a558f8ab-376208fbe7bso17053025ab.3 for ; Mon, 01 Jul 2024 23:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proxyid.net; s=google; t=1719902495; x=1720507295; 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=V3iHAesxPqU81aPN0gk+zQsiv3HmoL3VVCVpI1M7PbI=; b=hQNj3hJ4ca9YjHQ16oiIDcNfk3rvowYaTlS1+hy6zbcBlvuqBBniU6Yzv8yEJchQ+6 7kZGQnqSeHNBmQPSGgQT7nVmP8Za9hV5XmjHX+mIMiT9/0iuMEXZ9vEvqBH2VaqiapM0 SrGWiCZoH5Rjj+f5KHBWs3wbquJJrjWGF2GUZt/YaUw1BTToMs1KjcifqRuvtC8nP7xl X+WLGH7tM8nA5tKSoOB2jIMrTgOseIV2NCUkM8Lsw0nEOZbDHNhuOvFmvBOD2fsreCO+ IodVg7BCdAiP9zdItlyvkyZnVVK94Un5Acc5G687oN5/GdyHBHLLAmBrwo0lCDx11TJx g7yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719902495; x=1720507295; 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=V3iHAesxPqU81aPN0gk+zQsiv3HmoL3VVCVpI1M7PbI=; b=oCSK7zouMUidpe7qiOMs4+1u+HHi+9GKJTmqDylPe7cjimKD/DnBDJu8oPDs1q+KdS kkIAFWy4aStJQ/M7DbvLF9YXj1G4G+nP26I0t9ghLqGNHoi4wDiv0jr5WhzXzkCHEsYy nL3ghiXOiQxoCejQvtRwn5+9eRwdcB4MQcSDg+J75WYTErhzKpF2SJW1T1uyuWJD2vtr nyrreBhM1FxzzSksUJyeEOA62w+H1Rv3Al1q9Qo70JslSCysogGbdSYnZOQT6EFTKvED D44WeZCMe9TY68r8sgOgg7FYR/PlM1uQH5oMpAUjfy9QNMhbrSF3yM1kLcMG2JhavFpl S4ZQ== X-Gm-Message-State: AOJu0YyTDtv5t41KLZmX5j15YbWnfBfK/r0+PVXM/ujs6qXgTdbXbWcR IECF6Y0awH4DI4aymt2jFaNUxYKY8b3LVf7LW4IO97MI5EZSGIRNw8eVt6WWgH8yscD7F2oqWb0 rbFe1KNiXlIx6qPvWi0MO9wbCzNm9ur8JjZvCFqFW X-Received: by 2002:a05:6e02:1a22:b0:374:abf8:4f65 with SMTP id e9e14a558f8ab-37cd3873a6cmr90281435ab.32.1719902495050; Mon, 01 Jul 2024 23:41:35 -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 e9e14a558f8ab-37ad22cab75sm4059395ab.2.2024.07.01.23.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 23:41:35 -0700 (PDT) X-Relaying-Domain: proxyid.net From: Marth64 To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Jul 2024 01:41:31 -0500 Message-Id: <20240702064131.1310942-1-marth64@proxyid.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4] avformat/dvdvideodec: Fix incorrect padding cell trim logic 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: S1TLHEjVCCsW When -trim option is used (by default), padding cells at the beginning of the title are supposed to be ignored. The current implementation does the ignoring after we have locked on to the PGC navigation event stream, but does not set the PGC/PG state properly. This causes false positives and errors on some discs due to a search for a program stream cell that never succeeds. User would have to know to disable the -trim option to work around the issue. Simplify the logic and move it to the NAV packet event handling, in turn implementing the behaviour correctly and fixing the trim function for impacted discs. Signed-off-by: Marth64 --- libavformat/dvdvideodec.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c index e7132725b7..c694e8d00f 100644 --- a/libavformat/dvdvideodec.c +++ b/libavformat/dvdvideodec.c @@ -624,7 +624,6 @@ static int dvdvideo_play_next_ps_block(AVFormatContext *s, DVDVideoPlaybackState dvdnav_vts_change_event_t *e_vts; dvdnav_cell_change_event_t *e_cell; int cur_title, cur_pgcn, cur_pgn, cur_angle, cur_title_unused, cur_ptt, cur_nb_angles; - int is_cell_promising = 0; pci_t *e_pci; dsi_t *e_dsi; @@ -706,23 +705,17 @@ static int dvdvideo_play_next_ps_block(AVFormatContext *s, DVDVideoPlaybackState continue; e_cell = (dvdnav_cell_change_event_t *) nav_buf; - is_cell_promising = !c->opt_trim || dvdvideo_is_cell_promising(s, state->pgc, e_cell->cellN); - av_log(s, AV_LOG_DEBUG, "new cell: prev=%d new=%d promising=%d\n", - state->celln, e_cell->cellN, is_cell_promising); + av_log(s, AV_LOG_DEBUG, "new cell: prev=%d new=%d\n", state->celln, e_cell->cellN); if (!state->in_ps && !state->in_pgc) { if (cur_title == c->opt_title && (c->opt_pgc || cur_ptt == c->opt_chapter_start) && cur_pgcn == state->pgcn && - cur_pgn == state->entry_pgn && - is_cell_promising) { + cur_pgn == state->entry_pgn) { state->in_pgc = 1; } - - if (c->opt_trim && !is_cell_promising) - av_log(s, AV_LOG_INFO, "Skipping padding cell #%d\n", e_cell->cellN); } else if (state->celln >= e_cell->cellN || state->pgn > cur_pgn) { return AVERROR_EOF; } @@ -766,6 +759,13 @@ static int dvdvideo_play_next_ps_block(AVFormatContext *s, DVDVideoPlaybackState e_pci->pci_gi.nv_pck_lbn, state->vobu_duration, state->nav_pts); if (!state->in_ps) { + if (c->opt_trim && !dvdvideo_is_cell_promising(s, state->pgc, state->celln)) { + av_log(s, AV_LOG_INFO, "Skipping padding cell #%d\n", state->celln); + + i = 0; + continue; + } + av_log(s, AV_LOG_DEBUG, "navigation: locked to program stream\n"); state->in_ps = 1;