From patchwork Thu Jun 27 06:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marth64 X-Patchwork-Id: 50190 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:bc92:0:b0:482:c625:d099 with SMTP id p18csp258211vqy; Wed, 26 Jun 2024 23:12:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUy+gz7w+ksJuXE3QHixKYCWZ6+2O59eyNGVIaZ0Phaj4WI+UjIyv+wHE6abDAej46Xft2uF3adcrE/uLcf0bG2bT8ey6uoqq4Zvw== X-Google-Smtp-Source: AGHT+IHjI8D439/ga+kw+nXCKVTTfWBiu8aYKbHnGmSczQwNjAWUTmlpX6/KTQTWc04d2E71X0qp X-Received: by 2002:a50:a693:0:b0:57c:68fd:2bc9 with SMTP id 4fb4d7f45d1cf-57d49c976d1mr9401197a12.3.1719468769697; Wed, 26 Jun 2024 23:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719468769; cv=none; d=google.com; s=arc-20160816; b=ET3YVuH6nk8x4YQKZICPVUtj1SQYMeGevqb9Gz1CjH7Ctvsgohrc8PWgU7PGySIJx7 OAOQkmkxwckfXMBpV+lkUY5iE6G61D+pIdP5iNdpy02B33JJgA2NiZIZoPStyFMzhnns B45NJIzQ1qJ1eI0f/H8qmSEvTaGVrGh+bsiQHJuvuD8HYgahLavaxY3fzQy0ZZXBg/CD 10BrWcMRUMgWQpX03hRht471/a7JL//E/stCQMAfMv26cOFUvRU56EXbRAiJBrd/hIZP GLXMP9UCnR0SKqe4bsZMhaLDCx23dYcsIdJdaF+hUNwIik+rlk4Vde7qp/XuvLmJPo12 TOPw== 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=ctC/Dvj5oUQDANTppYtsUplYStzf+QD923xiC5VdJWM=; fh=PlWMzmI9LD2qGS7ipLrQl8z0iaQTLQLHzoGuXcBzpCg=; b=ZoPtsUSoKQ1FAKhAgMjw3XgmeMS7iFTUqDKGTJSVfVL+oTc8C2Vzg+raWmcPG9VEXl flTiFCtclbDhd+Go/3dLExceU25PbCCe2KAxIti9KoC3PpAQvEXS+OiGmfDSQNiD87W2 TaAl33PKK3/Ew5m44qx0r/ORtTfA2x+jaodsoqYmd4yoAkMs4rXnK4Ui7mLHY4JYj+mE N1u1CZ0jk5IqAgabvC0JeQBrXrIqKhaRZnu8lsHuR8x+LjhoHC0k4FCRPZXdYxW091Yi o6hEFHFVNdUErPuTqDDA2YBW5bV3Chet2eRofb/M738hhwdxktU43LjL2VrgxFpHTDfE wluw==; 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=ecRErvYs; 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-584d0ba5efesi367499a12.83.2024.06.26.23.12.49; Wed, 26 Jun 2024 23:12:49 -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=ecRErvYs; 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 7E02F68D630; Thu, 27 Jun 2024 09:06:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f99.google.com (mail-qv1-f99.google.com [209.85.219.99]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3AC5068D2F5 for ; Thu, 27 Jun 2024 09:06:19 +0300 (EEST) Received: by mail-qv1-f99.google.com with SMTP id 6a1803df08f44-6b4febddfd3so34828836d6.1 for ; Wed, 26 Jun 2024 23:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proxyid.net; s=google; t=1719468378; x=1720073178; 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=wYOp6HZSiSMUHPA4B7gK0ayhgrfD9vgXshhCKN49CtM=; b=ecRErvYsjixgINOX9kGjbewfOXhgOAw2dCwHmZyWrFKMVz/29laJmvqOdGal72itkh CvdBNYa/CVcPnom/lh8lLAvF7ivmokEEWT3nJw4DP8mr9bIuz2TtLK351630OrBgEqGI ouK5xBNKNg9evnmNxkJflnLxyTfoAyDlUkG9/e17hRCoAkZdc79Y4t+8So4cX/MxoLLT rl6hn4tyevkFtv/YSkEc4Xh8XLCL+HHI8Alc2OMXfCf33Wsw1eyl382hTk389M6ymfim O9QZl3F8N9vn1NZMZTWhwwBt6dmnIERZitrUslM7pjccvbVWCC7btcoUiwMfqgRdJKLd CxRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719468378; x=1720073178; 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=wYOp6HZSiSMUHPA4B7gK0ayhgrfD9vgXshhCKN49CtM=; b=LRE21VZ2QXGLIDmX+s2PSdaIzDpyuIrH8KX6sDvaw/IAcj3SvjdWNCnnWEJDVrf6vu nGiQhynpWH5mqvgujGYB6IKWy6IW43io1YJDTA0mWJ0F1HjLu4CCGERkZ7kNtFrUQC9C cvLsv2IyYZfisMwi8eIdBGXlipiHOUsUkMDu7k2EpHzjSvP3YOAWdBChTFvpRlGZ3SoP N2cXjFczcJnoigUx4HVRimoMrtUGNNU58rWSu1XxBdcGFKlLcYSFEejYurgIOVes21wg p8xa2j9dN0fTEblA1KFqhzCrHRX7agZv16XeMtrA4Chp2V8/P3UV6xp8jNbD0P4IBPVB HJJQ== X-Gm-Message-State: AOJu0YxWER0Zaiw14+sTZzwnYnmnX1x1PbBGe5LxNaM5jJIvDrcoQ0hN luK3z5oKGjPOUbN8wDv/cMLbCyTarLxJydYs1FV91np1wa82cvgcHqeO6ncnI0ZE7IoJ+J1JWEP +ez4XosKaK44i9o7tDSGva1CRTSREEAKZUGHr3VX+ X-Received: by 2002:a05:6214:94f:b0:6b5:83bb:11b7 with SMTP id 6a1803df08f44-6b583bb16d4mr30177956d6.6.1719468377855; Wed, 26 Jun 2024 23:06:17 -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 6a1803df08f44-6b59252e0desm280896d6.26.2024.06.26.23.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 23:06:17 -0700 (PDT) X-Relaying-Domain: proxyid.net From: Marth64 To: ffmpeg-devel@ffmpeg.org Date: Thu, 27 Jun 2024 01:06:04 -0500 Message-Id: <20240627060604.191897-1-marth64@proxyid.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] 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: /TQwmoAiyyaN 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 | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c index e7132725b7..f1c960b56b 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; } @@ -784,9 +777,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 */ + if (!state->in_ps) + continue; + + if (c->opt_trim && !dvdvideo_is_cell_promising(s, state->pgc, state->celln)) { + av_log(s, AV_LOG_DEBUG, "skipping block in trimmed cell #%d\n", state->celln); + + i = 0; continue; }