aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/dvdvideodec.c
Commit message (Collapse)AuthorAgeFilesLines
* avformat/dvdvideodec: fix seeking on multi-angle discsMarth642025-06-151-0/+36
| | | | | | | | | | | | | | | | | | | | | When seeking on multi-angle titles, libdvdnav does not lock on to the correct sectors initially as it seeks to find the right NAV packet. This manifests itself as two bugs: (1) When seeking on the first angle in a multi-angle segment, frames from another angle will appear (for example in intro or credits scenes). This issue is present in VLC also. (2) When seeking during a segment on angle n+1, the demuxer cannot deduce the right position from dvdnav and does not allow seeking within the segment (due to it maintaining a strict state). Correct the issue by switching to angle 1 before doing the seek operation, and skipping 3 VOBUs (NAV packet led segments) ahead where dvdnav will have positioned itself correctly. Reported-by: Kacper Michajlow <kasper93@gmail.com> Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: remove unused has_cc fieldMarth642025-06-151-2/+0
| | | | Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: check return code of ff_dvdclut_yuv_to_rgb()Marth642024-12-011-1/+4
| | | | Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: fix missing last chapter marker due to off-by-oneMarth642024-12-011-1/+1
| | | | | | | When using fast chapter marker calculation (default), the last marker is inadverdently ignored due to an off-by-one. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: don't allow seeking beyond dvdnav reported durationMarth642024-11-161-1/+1
| | | | | | | There is no reason to accept timestamp values beyond what dvdnav reported as the duration of the title. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: discard duplicate or partial AC3 samplesMarth642024-11-161-1/+35
| | | | | | | | | | | | | | | Some DVD muxers signal segments to start with duplicate audio samples when starting extraction from a chapter marker or terminate seamless PGs on partial audio samples (causing corrupt AC3 frames). Clean up after these muxers by tracking frames with duplicate PTS and eliminating partial AC3 frames. This results in smoother chapter extraction and overall seeking experience, with linear PTS and AC3 delay within 32ms (1 frame) away from the video. The issue was not apparent until the flushing pattern was replaced with a full subdemux reset, as the flushing dropped the frames prematurely, along side others, as such they were never present to begin with.
* avformat/dvdvideodec: drop packets with unset PTS or DTSMarth642024-11-161-17/+12
| | | | | | | | | The packets effectively serve no purpose and we are already dropping packets with PTS less than 0. This also creates for a smoother seeking experience after the subdemuxer reset fix. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: remove unnecessary need_parsing argumentMarth642024-11-161-13/+9
| | | | | | The value is always AVSTREAM_PARSE_HEADERS. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: open subdemuxer after initializing IFO headersMarth642024-11-161-10/+8
| | | | | | | It is wasteful to open the subdemuxer if an error occurs while initializing streams or reading IFO headers. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: remove auto value for menu_lu optionMarth642024-11-161-8/+1
| | | | | | | | The "auto" mode serves no functional purpose except for logging a message and setting the value to 1. The documentation clearly explains what the option is for. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: default menu_vts option to 1 and clarify descriptionMarth642024-11-161-1/+1
| | | | | | | Menu 0 is the VIDEO_TS root menu, which does not appear to be used commonly for menu segments. Instead, default to the menu of VTS 1. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: check the length of a NAV packet when reading titlesMarth642024-11-161-0/+7
| | | | | | | | Some discs present titles with bogus NAV packets. We apply this check for menus and for title MPEG blocks, but we should also apply it for NAV packets during title demuxing. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: reset the subdemuxer on discontinuity instead of flushingMarth642024-11-161-64/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DVDs naturally consist of segmented MPEG-PS blobs within a VOB (i.e. VOBs are not linear). NAV packs set the segment boundaries. When switching between segments, discontinuities occur and thus the subdemuxer needs to be reset. The current approach to manage this is by invoking ff_read_frame_flush() on the subdemuxer context, via a callback function which is invoked during the menu or dvdnav block functions. The same subdemuxer context is used throughout the demux, with a stretched PTS wrap bits value (64) + disabled overflow correction, and then flushed on each segment. Eventually, a play_end context variable is set to declare EOF. However, this approach causes frame drops. The block read flushes the demuxer before the frame read is complete, causing frames to drop on discontinuity. The play_end signal likewise ends playback before the frame read is complete, causing frames to drop at end of the title. To compound the issue, the PTS wrap bits value of 64 is wrong; the VOBU limit is actually 32 and the overflow correction should work. Instead, EOF the MPEG-PS subdemuxer organically when each VOB segment ends, and re-open it if needed with the offset after the full frame read is complete. In doing so, correct the PTS wrap behavior to 32 bits and remove the play_end/segment_started signals and callback pattern. Note that the timestamps as reported by the NAV packets are known as "PTMs", so the fields storing the time prior to adjustment are renamed accordingly. This makes it more clear when we are offsetting the NAV packet reported timestamps versus what we present as a demuxer. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: simplify dvdvideo_read_packet()Marth642024-11-161-23/+21
| | | | | | | | | The function has a few branches where it discards frames via FFERROR_REDO; consolidate is via a goto block to simplify the function and improve readability. Logging still maintains all the relevant details for the reason of the discard. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: enable chapter calculation for menusMarth642024-11-161-18/+35
| | | | | | | Menus are generally segmented by cell, so use them as the marker delimiters. Requires preindex option to be enabled. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: standardize the NAV packet event signalMarth642024-11-161-14/+17
| | | | | | | | | This consolidates the FFERROR_REDO handling of NAV packets to dvdvideo_subdemux_read_data(), is a pre-requisite to calculating chapter markers for menus, and a pre-requisite to fixing the frame desync issue when the subdemuxer is flushed. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: move memcpy below missed NAV packet warningMarth642024-11-161-2/+2
| | | | | | | | Readability improvement; the warning can be bundled beneath the preceding validations rather than awkwardly between the memcpy and return. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: remove "auto" value for -pg option, default to 1Marth642024-11-161-22/+9
| | | | | | | | | | | | | | The default "auto" mode is effectively useless; the reasonable default use case is to use the first PG (segment) of the selected PGC for both menus and standard titles. Just default the value to 1, since the option is irrelevant unless -pgc is also set. Note that this should not break users using this advanced option. The "auto" mode errored and asked for a PG number regardless for non-menus, and for menus the mode simply defaulted to 1. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: measure duration of the current menu VOBU in stateMarth642024-11-161-0/+1
| | | | | | | This will be a pre-requisite to calculating chapter markers for menus. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: fix menu PGC number off-by-one in stateMarth642024-11-161-1/+1
| | | | Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: remove unused headersMarth642024-11-161-2/+0
| | | | Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: implement seekingMarth642024-09-151-5/+72
| | | | | | | | | Player applications can now enjoy seeking while playing back a title. Accuracy is at the mercy of what libdvdnav exposes, which is currently dvdnav_time_search(). Signed-off-by: Marth64 <marth64@proxyid.net> Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avformat/dvdvideodec: Fix incorrect padding cell trim logicMarth642024-07-131-9/+9
| | | | | | | | | | | | | | | | | | | 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 <marth64@proxyid.net>
* avformat/dvdvideodec: Remove redundant ret initializationsMarth642024-07-131-6/+6
| | | | | | | | Remove initializing ret = 0, in areas where ret is only used to hold an error value, immediately returned, and the function would otherwise return a literal 0. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: Don't add chapter markers for empty/dummy PTTsMarth642024-07-131-5/+11
| | | | | | | | | | Some discs (usually same ones with padding cells), also have empty padding PTTs / chapters to accompany them. This results, for example, in an extra chapter marker that starts and ends at 0 (no duration). Don't add these empty chapter markers. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: Remove unused cell count variableMarth642024-07-071-2/+0
| | | | | Signed-off-by: Marth64 <marth64@proxyid.net> Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter ↵Marth642024-07-011-3/+12
| | | | | | | | | | | | | | | range 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 <marth64@proxyid.net>
* avformat/dvdvideodec: Do not EOF on WAIT eventsMarth642024-07-011-9/+8
| | | | | | | | | A DVDNAV_WAIT event by itself should not warrant an EOF when navigating the program stream. Some discs have WAIT events in the middle of a title, causing playback to end prematurely prior to this fix. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: add explicit inttypes.h includeMarth642024-03-261-0/+2
| | | | | | | | | | Since log statements printing int64 were made portable in 4464b7eeb194e98ac115f18d2b6be67361407c8a, let us include inttypes.h explicitly (as it is unclear where PRId64 and such are coming from now). Reported-by: Leo Izen <leo.izen@gmail.com> Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/internal: Move FF_FMT_INIT_CLEANUP to demux.hAndreas Rheinhardt2024-03-261-1/+1
| | | | | | | | | and rename it to FF_INFMT_INIT_CLEANUP. This flag is demuxer-only, so this is the more appropriate place for it. This does not preclude adding internal flags common to both demuxer and muxer in the future. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dvdvideodec: use int64_t for menu blocks_read and make format ↵Marth642024-03-151-7/+8
| | | | | | | expressions portable Signed-off-by: Marth64 <marth64@proxyid.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dvdvideodec: add menu demuxing supportMarth642024-03-121-11/+303
| | | | Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: add CLUT utilities and subtitle color supportMarth642024-03-121-0/+14
| | | | Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: assign mono channel layout explicitlyMarth642024-03-101-1/+3
| | | | Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/avformat: Add FFInputFormat, hide internals of AVInputFormatAndreas Rheinhardt2024-03-071-7/+8
| | | | | | | | | | | | | | | | | | | | | This commit does for AVInputFormat what commit 59c9dc82f450638a3068deeb1db5c56f6d155752 did for AVOutputFormat: It adds a new type FFInputFormat, moves all the internals of AVInputFormat to it and adds a now reduced AVInputFormat as first member. This does not affect/improve extensibility of both public or private fields for demuxers (it is still a mess due to lavd). This is possible since 50f34172e0cca2cabc5836308ec66dbf93f5f2a3 (which removed the last usage of an internal field of AVInputFormat in fftools). (Hint: tools/probetest.c accesses the internals of FFInputFormat as well, but given that it is a testing tool this is not considered a problem.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dvdvideodec: fix -pgc and -pg optionsMarth642024-03-041-10/+13
| | | | | | | | | | Rebased on top of recently merged fixes (should apply correctly now). In merged DVD patch, -pgc and -pg options were broken. While these are rather advanced options, they are the only means to get content for some strangely authored discs. Signed-off-by: Marth64 <marth64@proxyid.net>
* avformat/dvdvideodec: Reorder allocations to simplify freeingAndreas Rheinhardt2024-03-031-8/+4
| | | | | Reviewed-by: Marth64 <marth64@proxyid.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dvdvideodec: Only free allocated buffersAndreas Rheinhardt2024-03-031-1/+0
| | | | | Reviewed-by: Marth64 <marth64@proxyid.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dvdvideodec: Don't store AVInputFormat*Andreas Rheinhardt2024-03-031-6/+2
| | | | | | | | | | | The inner AVInputFormat* of the inner mpegps-demuxer is only used once (in avformat_open_input()), so don't even store it. In fact, just use ff_mpegps_demuxer directly, as this demuxer has a configure dependency on it. Reviewed-by: Marth64 <marth64@proxyid.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dvdvideodec: Explicitly return 0 on successAndreas Rheinhardt2024-03-031-9/+6
| | | | | | | Don't "return ret" even when ret is zero on success. Reviewed-by: Marth64 <marth64@proxyid.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* libavformat/dvdvideo: add DVD-Video demuxer, powered by libdvdread and libdvdnavMarth642024-03-021-0/+1411
Signed-off-by: Marth64 <marth64@proxyid.net> Signed-off-by: Anton Khirnov <anton@khirnov.net>