summaryrefslogtreecommitdiffstats
path: root/libmpdemux/demux_mkv.c
Commit message (Collapse)AuthorAgeFilesLines
* demux_mkv: improve seeking with generated indexUoti Urpala2010-01-011-46/+69
| | | | | | | | | | | | | | | | | | | When using generated index (-idx / -forceidx) the Matroska seeking code first guessed a file position using bitrate-based heuristics, then located the cluster nearest to that file position. Change it to store cluster timestamps in addition to file positions and seek to the cluster with the closest timestamp. This makes seeking with -idx a lot more accurate. This change also fixes a crash when trying to seek with generated index before playing any data from the beginning of the file (could be triggered by -idx together with ordered chapters or -ss for example). I removed the code handling MATROSKA_ID_CUES in the middle of parsing clusters. Such cue entries were not consistently handled if encountered during playback instead of index creation and the seek code was also buggy when they were encountered and parsed; i didn't consider it worth the effort to fix it.
* demux_mkv: remove useless codeUoti Urpala2009-12-311-16/+2
| | | | | Remove leftover code that no longer did anything useful after earlier changes.
* demux_mkv: respect -forceidxUoti Urpala2009-12-311-1/+1
| | | | | Don't use the index included in the file if the -forceidx option was specified.
* demux_mkv.c, ebml.c: Reformat to K&R styleUoti Urpala2009-12-291-2232/+2037
|
* Support for multiple editions in MatroskaDaniel Dawson2009-12-041-27/+65
| | | | | | | | Add code to intelligently choose an appropriate Matroska edition when there are several. Will choose, in descending order of preference: the edition chosen by the user through the option "-edition <edition id>" if it exists, the first edition with EditionFlagDefault set to 1 if there is one, or the first edition.
* demux_mkv: Detect and warn about virtual timeline nestingDaniel Dawson2009-12-041-0/+16
| | | | | | | | | Detect use of ChapterSegmentEditionUID element in a Matroska chapter definition, indicating inclusion of an external virtual timeline, which is not yet supported. Leave the chapter is the chapter list but set segment_uid to zero. This way timeline parsing will skip the chapter and avoid nonsensical output but will still print information about missing content.
* demux_mkv.c: Make time arithmetic more precise in one more caseUoti Urpala2009-12-021-1/+1
| | | | | Use rounding instead of truncation in another case of double division used with integer variables.
* demux_mkv: Stop moving FLAC extradata into stream packetsUoti Urpala2009-10-171-8/+6
| | | | | | | | | | | | | | | | | | | | | | | The Matroska demuxer didn't place FLAC codec extradata in the normal extradata field but instead constructed a fake data packet and inserted that at the start of the demuxer stream. Current FFmpeg FLAC decoder can read the data from the proper extradata field too, so use that mechanism instead. This fixes a problem with files that use ordered chapters to load external segments from other files that have FLAC audio. In that case there can be a seek before the audio decoder is first initialized, and the seek will flush all stream packets so the decoder would never see the inserted extra packet. That particular issue could be fixed by initializing the decoder before any seeks instead (and there could still be other similar problem cases where doing that would be more robust), but this change is still generally right. I think the previous code would also cause problems in case there are multiple audio streams; there's only a single demuxer stream used for data packets, meaning that a packet inserted for the sake of a secondary audio stream could be read by the codec of the default stream (possibly not FLAC at all) and the packet would not be available when switching to the secondary audio stream later.
* Merge svn changes up to r29752Uoti Urpala2009-10-061-26/+6
|\ | | | | | | | | | | | | | | | | As part of merging subtitle-in-terminal changes make update_subtitles() only clear existing subtitles if called with the reset argument, and not try to set new ones. Later calls should set the needed new subtitles, and this change avoids some problems with trying to set subtitles when mp_property_sub() in command.c gets called from initialization code before full initialization.
| * Avoid void * arithmetic.reimar2009-09-301-1/+1
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29740 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Simplify aac_get_sample_rate_indexreimar2009-09-301-24/+4
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29739 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Check for grow_array allocation failure.reimar2009-09-301-0/+8
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29738 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Avoid a possible crash if num_cluster_pos is 0.reimar2009-09-301-1/+1
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29737 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Check for integer overflow in grow_array.reimar2009-09-301-1/+4
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29736 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Rearrange code of grow_array to make it easier to extend.reimar2009-09-301-2/+3
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29735 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Avoid a memleak if realloc fails in grow_array.reimar2009-09-301-0/+3
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29734 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Change grow_array argument from void ** to void *, this avoids a aliasingreimar2009-09-301-4/+5
| | | | | | | | | | | | | | | | violation (thus making gcc 4.4.x compile the code correctly) and allows to get rid of some casts at the expense of making the code less clear. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29733 b3059339-0415-0410-9bf9-f77b7e298cf2
* | demux_mkv: Fix memory leaks in attachment readingUoti Urpala2009-09-181-2/+10
| | | | | | | | | | | | | | | | When the attachment-reading code was changed to use demuxer_add_attachment it should have been changed to free its internally-allocated objects too, since demuxer_add_attachment creates copies of everything and leaves ownership of original objects to caller.
* | Merge svn changes up to r29532Uoti Urpala2009-08-181-1/+4
|\|
| * Fix incompatible pointer types warning, also seems to fix mis-compilation ↵reimar2009-08-171-2/+2
| | | | | | | | | | | | with gcc-4.4.1 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29532 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Add Dolby TrueHD support for mkv demuxer.cehoyos2009-08-131-1/+4
| | | | | | | | | | | | | | Patch by Jason Tackaberry, tack urandom ca git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29513 b3059339-0415-0410-9bf9-f77b7e298cf2
| * whitespace cosmetics: Remove all trailing whitespace.diego2009-05-131-17/+17
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29305 b3059339-0415-0410-9bf9-f77b7e298cf2
* | Remove internal libass treeUoti Urpala2009-07-261-2/+1
| | | | | | | | | | Remove the libass/ directory and use the newest standalone version of the library instead.
* | Replace libavutil internal header #includes with MPlayer copiesUoti Urpala2009-07-261-1/+1
| | | | | | | | | | | | Change #include lines for libavutil/intreadwrite.h, libavutil/bswap.h and libavutil/x86_cpu.h to use the MPlayer file under ffmpeg_files/ instead.
* | demux_mkv.c: Make some time arithmetic more preciseUoti Urpala2009-07-101-20/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some calculations in the demuxer that are in principle integer arithmetic use float divisions instead of 64-bit integer ones (as in (int64_t)(x / 1000000.0) ). When compiled with -ffast-math gcc replaces the division with multiplication by inverse. The calculation of the inverse can introduce rounding error even for divisions that would have been exact, and any rounding error down from an exact integer result in the division makes the result after cast one smaller. This caused some inaccuracy in seeking due to timecodes in the index not quite matching those calculated for actual packets. Add 0.5 to such expressions before casting to round instead of truncating, which should be enough to avoid the problem. Also replace some non-performance-critical use of float types by doubles.
* | demux_mkv: Round more seeks to "backwards" keyframesUoti Urpala2009-07-091-1/+1
| | | | | | | | | | | | | | | | Allow more fuzziness in treating timestamps as inaccurate attempts to seek "exactly" to a keyframe. A seek forward can now actually go to a keyframe 5 ms back from the timecode, and correspondingly for seeks backwards. Before only 1 ms was allowed. This helps with some files that have inaccurate chapter boundaries.
* | demux_mkv: Make seeks more precise in some casesUoti Urpala2009-07-091-2/+2
| | | | | | | | | | | | | | When seeking backward, after seeking to the file position specified by an index entry skip packets until the timecode of that index entry. The existence of the entry should guarantee a keyframe there before the seek target time.
* | Remove trailing whitespace from most filesUoti Urpala2009-07-071-13/+13
| |
* | Merge svn changes up to r29304Uoti Urpala2009-07-071-4/+19
|\|
| * Add standard license header to all files in libmpdemux.diego2009-05-081-4/+19
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29280 b3059339-0415-0410-9bf9-f77b7e298cf2
* | Translation system changes part 2: replace macros by stringsAmar Takhar2009-07-071-17/+17
| | | | | | | | | | Replace all MSGTR_ macros in the source by the corresponding English string.
* | Translation system changes part 1: wrap translated stringsAmar Takhar2009-07-071-16/+16
| | | | | | | | | | Replace mp_msg() calls which have a translated string as the format argument with mp_tmsg and add _() around all other translated strings.
* | Support chapter seeking with ordered chaptersUoti Urpala2009-04-021-0/+1
| |
* | demux_mkv: Remove first_tc and stop_timecodeUoti Urpala2009-04-021-33/+3
| | | | | | | | | | | | | | | | | | | | | | The first_tc code was used to force timestamps in the file to start from 0. There should be no need to do this, and it would likely break ordered chapter support for any files it affected (since the chapter timecodes would refer to the original times, not the modified ones). stop_timecode was used to implement end of playback at a specified chapter. There is now common code which implements that and demuxer-specific implementations are not needed.
* | demux_mkv: Adjust seeks a bit to catch inexact keyframe matchesUoti Urpala2009-04-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow a seek to "time X or before" to match a keyframe at X plus 1 ms, and correspondingly for seeks to "X or later". This allows seeks to a known keyframe to succeed even if the time is not quite perfectly exact. The main motivation for this improvement was chapter seeking. Some time ago things worked in practice because chapter times were slightly below the exact target and demux_mkv seeked forward of the specified position by default. Some commits ago demux_mkv started seeking backward by default, which is generally a more desirable behavior, but worked worse for the chapter times which happened to be slightly behind a keyframe rather than ahead. After this commit chapter seeks go to the desired keyframe again.
* | Add improved relative seek modeUoti Urpala2009-03-241-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the new mode is active relative seeks are converted to absolute ones (current video pts + relative seek amount) and forward/backward flag before being sent to the demuxer. This mode is used if the demuxer has set the accurate_seek field in the demuxer struct and there is a video stream. At the moment the mkv and lavf demuxers enable the flag. This change is useful for later Matroska ordered chapter support (and for more general timelime editing), but also fixes problems in existing functionality. The main problem with the old mode, where relative seeks are passed directly to the demuxer, is that the user wants to seek relative to the currently displayed position but the demuxer does not know what that position is. There can be an arbitrary amount of buffering between the demuxer read position and what is displayed on the screen. In some situations this makes small seeks fail to move backward at all (especially visible at high playback speed, when audio needs to be demuxed and decoded further ahead to fill the output buffers after resampling). Some container formats that can be used with the lavf demuxer do not always have reliable timestamps that could be used for unambiguous absolute seeking. However I made the demuxer always enable the new mode because it already converted all seeks to absolute ones before sending them to libavformat, so cases without reliable absolute seeks were failing already and this should only improve the working cases.
* | demux_mkv: Parse ordered chapter informationUoti Urpala2009-03-221-2/+73
| | | | | | | | | | | | Parse the ordered chapter structure if present and place the information in the public demuxer structure. Nothing uses the information yet.
* | demux_mkv: Some cleanup, fix duration printed at verbose levelUoti Urpala2009-03-211-154/+134
| | | | | | | | | | | | | | | | | | | | | | Clean up demux_mkv_read_info() and demux_mkv_read_chapters() somewhat. (Why do the names of static functions have a stupid prefix like that? Didn't remove it now however). Demux_mkv_read_info() now delays printing duration information until the end of the function where we hopefully have the correct timescale for converting it to seconds. The code to calculate the duration had been fixed for that earlier but the message had not.
* | Merge svn changes up to r28537Uoti Urpala2009-02-121-89/+11
|\|
| * change internal real video packetizing format to the more straight forward oneaurel2009-02-091-86/+8
| | | | | | | | | | | | | | | | see [MPlayer-dev-eng] [PATCH] cleanup/uniformize real video packetizing patch blessed by Roberto git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28503 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Convert CONFIG_ZLIB into a 0/1 option.diego2009-02-071-3/+3
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28475 b3059339-0415-0410-9bf9-f77b7e298cf2
* | Merge svn changes up to r28461Uoti Urpala2009-02-041-7/+7
|\|
| * Adapt to lzo changes in libavutilreimar2009-02-021-7/+7
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28448 b3059339-0415-0410-9bf9-f77b7e298cf2
* | Merge svn changes up to r27841Uoti Urpala2008-10-281-208/+0
|\| | | | | | | | | Conflicts: mplayer.c
| * Factorize vobsub idx/extradata handling.aurel2008-10-271-208/+0
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27841 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Revert bad changes to SSA/ASS subtitle packet formatuau2008-09-081-38/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following commits are reverted partially or completely: "a valid ASS line contains 9 ',' before actual text" "demux_mkv: output correctly formated ASS packets" "libass: add a new ass_process_data() to process demuxed subtitle packets" These commits converted the internal representation of SSA/ASS subtitle packets from the format used by Matroska to a custom format where each packet has contents exactly matching one line in complete SSA script files. AFAIK no files natively use such a format for muxed subtitles. The stated reason for this change was to use a format that could in principle be muxed into a maximal number of containers. SSA subtitles do not have an implicit duration so both start time and duration or end time need to be specified explicitly; the new format moved timing information inside the codec packet data so it could be muxed without modification into containers that can represent only start time at the container level. However such a change is wrong from the viewpoint of program architecture. Timing information belongs to the demuxer level, but these commits moved not only the duration but also the authoritative value of the start time to inside the codec data. Additionally the new format lost the value of the Matroska ReadOrder field which is used by MPlayer. This commit changes the internal packet format back to that used by Matroska and makes the internal Matroska demuxer output that format again. Libavformat still outputs the "new" format; it could be converted back to the Matroska format in demux_lavf.c, but I'm not adding that code at least yet. The current lavf code has similar problems as the reverted code in MPlayer, and it also currently fails to provide any way to access the value of the ReadOrder field. I hope that the lavf side will be improved; if it isn't conversion can be added later. For now I'll make MPlayer default to the internal Matroska demuxer instead of the lavf one in a separate commit. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27550 b3059339-0415-0410-9bf9-f77b7e298cf2
| * demux_mkv: output correctly formated ASS packetsaurel2008-09-051-1/+38
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27529 b3059339-0415-0410-9bf9-f77b7e298cf2
* | Merge svn changes up to r27374Uoti Urpala2008-07-301-6/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: cfg-common-opts.h cfg-mplayer.h command.c configure libmpcodecs/dec_video.c libmpcodecs/vd.c libmpcodecs/vf_vo.c libmpdemux/demuxer.h libmpdemux/stheader.h mp_core.h mplayer.c stream/stream_radio.c
| * Start unifying names of internal preprocessor directives.diego2008-07-301-6/+6
| | | | | | | | | | | | | | | | Replace all USE_ prefixes by CONFIG_ prefixes to indicate options which are configurable. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27373 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Remove unused function, fixes the warning:diego2008-05-151