From patchwork Thu Jun 27 05:37:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marth64 X-Patchwork-Id: 50189 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:bc92:0:b0:482:c625:d099 with SMTP id p18csp247375vqy; Wed, 26 Jun 2024 22:38:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXEe0hbq/TcJ6i5HTg9fOt81T+4/rvfu3Im3Je3WaCXo8ens0AngefjBBNHPXIRglhdCehyrjZ/JZBIvBU1Zz5taR8DM9HC5mraqQ== X-Google-Smtp-Source: AGHT+IEEh4MxwxR2S7KRnCHCdyRTKGIthIahlviD6y/NBD135HKEJg11mEoK7QJhYrDtjF60NBBM X-Received: by 2002:aa7:c583:0:b0:57d:5c96:72aa with SMTP id 4fb4d7f45d1cf-57d5c9672f0mr7532850a12.0.1719466713477; Wed, 26 Jun 2024 22:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719466713; cv=none; d=google.com; s=arc-20160816; b=RdqUGnEhxKZnqVFAAui1yxKppVwW5szB+2+Ks975ontf3lcDP6Cm2rO2GdZo0xKYX2 OCvgyrVLOMY4q/Xi85YiIKx6T3g14WQO6UdAHftwL11iuztul3dIHYQFl0prGEAC6kp9 youYhcadd0Y8X0wS9NKI4nNS2T61FQ6+eFon3cbCSsjUUtqden/Kvx3lt7GW0CZz8Gcc xVmnSOXHGZAzV5cmpeuoxlZ66vU4CAC05gJJ28cRTlAPqFHrd2wFNy8vHcWEYbskpWTm AVzvuBttDYYwpxchrCXSn31VoNY+Xq/XX5IRjWXWDlQ+w+RnhQSPiHlgBSi9156EyIBq gqSA== 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=9ebIX3JQtntf3jrMR3eLRFSEPJ+jDcYdsjPMEtVfRaU=; fh=PlWMzmI9LD2qGS7ipLrQl8z0iaQTLQLHzoGuXcBzpCg=; b=K6+IcTH5E7T1IY3HihSflSqWVdMBI59NowtJie2vHhf85Za7tbSZYtWNnJb/tsLCyf Nf1eO8xBrRcEfogUhilqk6z1WWWfS0bufPPFHkAz4ACkV2VsaBLiK/P18AglpdDpWbtC oJw7LcogfrXLBKdG2nJ4MDkjE0AeCum0mvjRGtnPcUxRK2DJSZeaidhiZwboDKB8mhOD Vj7OxmMiby1+0ySP1+RhCrydiwYJrpPoPKZygaI4COO9zfQ16vZGYOBZ9I/d1IugYYLX PGsOLkuantvxWM+y6mMB/6BC8UoTb2jR0dIRORcTK+e26mgTWGdBJJMxQjxneYOVFmbX +b6w==; 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=gq93pfFY; 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-584d287836dsi330619a12.301.2024.06.26.22.38.32; Wed, 26 Jun 2024 22:38:33 -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=gq93pfFY; 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 4868E68CD00; Thu, 27 Jun 2024 08:38:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f227.google.com (mail-pg1-f227.google.com [209.85.215.227]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6066F68CD00 for ; Thu, 27 Jun 2024 08:38:23 +0300 (EEST) Received: by mail-pg1-f227.google.com with SMTP id 41be03b00d2f7-7180308e90bso3946187a12.1 for ; Wed, 26 Jun 2024 22:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proxyid.net; s=google; t=1719466701; x=1720071501; 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=CTRfg4nBPcaI144iH7TgqZcCOApHZBhf2W0LNCK/J5I=; b=gq93pfFY/dGBZs+RWMovsvXQWtKRhyXzF8T9chDT0FqMJuATt4NnKjqqqBXfxr66gX 7P+F0jeFxr3c6HMt3eQquyYgl+By0KPC3nbWdouGCfZ17w+s/N5dkLPIZJQ5e9fCQklZ U83tLyax+Y6iugrq1/mlEFipjcUIE3X3gl4cuvRl1uKKAL0B2SfFloqrL9TISSfaIvEj 4Wmy1p6XuoGZYPEVo00OuNWELQ1Z1DyZ/CuPEk+HL/d0ya6JKVUwaukvKWoLIK7kPcfb W6iZYccD7GdOMkMIPtFp/Ox90vN+oW+aQ/hZJ0msAsUUuNwq/KRvU5/ax3hSXOAXi49Q l6Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719466701; x=1720071501; 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=CTRfg4nBPcaI144iH7TgqZcCOApHZBhf2W0LNCK/J5I=; b=ZGfAHvaw8wo/cEV27xPOhSjsKHlen0dENMsYKcZuhnf2oyVa9gdq4MEi/Gz2xMZDO5 c5Kf/LGqxu+7bjJBWk/HgHytvc158jA1+jZYFaJbqOM0C2i6vPaCsIUpGutK1Fu6XN+b u047pMoyEmM2l9ZXHp/0wz8LoggKIBofwu4PI3mp1GWN/Sx/iwDppj8Q1YOvPGit1Ki1 sO63Hh4HNI7etbg5W166mt0nyD24yuPKZmcD+H9FyJhIp5ocL9ldCsOxw6XUInrMpTS2 GjAGdlzvnCU57nXUozmiF7EAsviiJsYY9hpvAin4JEvjm9aUqiVZcWMRKQqv/id5VLpw v12A== X-Gm-Message-State: AOJu0Yy0q5BP9kM2KraW7l0VbMGfI6TjIfaixPsRFBxLXvB/nZTP/ht6 5SYJ5grL0k2bSAKULyvGS0WLW7jo7ZvEETpBNSJ3OOdIFhFbOic13cPvQ8mJxjgWXnGG95b8TuU RC63oNlBkSMZmG5KDaWVoJmZwQYYZ4Yk/F2WIRxlk X-Received: by 2002:a05:6a20:bf08:b0:1bd:22fe:fca2 with SMTP id adf61e73a8af0-1bd22fefd92mr6032206637.18.1719466701358; Wed, 26 Jun 2024 22:38:21 -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-1faac993c04sm191805ad.97.2024.06.26.22.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 22:38:21 -0700 (PDT) X-Relaying-Domain: proxyid.net From: Marth64 To: ffmpeg-devel@ffmpeg.org Date: Thu, 27 Jun 2024 00:37:46 -0500 Message-Id: <20240627053746.189095-1-marth64@proxyid.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Simplify 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: aC39VYGJ71T4 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 when we attempt to lock on to the PGC navigation event stream, but this is a wrong assumption because we have already entered the PGC. This causes false positives 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 MPEG-PS block reading event handling, in turn also fixing the trim function for these weirdly authored discs. Signed-off-by: Marth64 --- libavformat/dvdvideodec.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c index e7132725b7..b0fb5f0de2 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; } @@ -785,8 +778,13 @@ static int dvdvideo_play_next_ps_block(AVFormatContext *s, DVDVideoPlaybackState return nav_len; case DVDNAV_BLOCK_OK: if (!state->in_ps) { - if (state->in_pgc) - i = 0; /* necessary in case we are skipping junk cells at the beginning */ + continue; + } + + if (c->opt_trim && !dvdvideo_is_cell_promising(s, state->pgc, state->celln)) { + av_log(s, AV_LOG_DEBUG, "skipping packet in padding cell #%d\n", state->celln); + + i = 0; continue; }