aboutsummaryrefslogtreecommitdiffhomepage
path: root/demux/demux_mkv.c
Commit message (Collapse)AuthorAge
* demux_mkv: reduce log noiseGravatar wm42014-12-29
| | | | | | | This message can happen a lot for mkv files which index clusters in the seekhead (which is also broken non-sense, but that's a different story). Also remove a duplicate define from matroska.h.
* demux_mkv: use attachment filename as coverart titleGravatar wm42014-12-23
|
* demux_mkv: support embedded coverartGravatar wm42014-12-22
| | | | | | | | | | | The code could as well be in demux.c, but it's better to avoid accidental clashes with demux_lavf.c. FFmpeg provides no way yet to map a mime type to a codec, so do it manually. (It _can_ map a mime type to an "input format", but not a codec.) Fixes #1374.
* demux_mkv: support svq3Gravatar wm42014-12-08
| | | | | | | | | | The most awesome codec, not. The actual code for svq3 is actually just the part that checks for MKV_V_QUICKTIME (no other QT-muxed codecs are supported). The rest is minor refactoring, that actually improves the code in general. This is just enough to support the 2 svq3-in-mkv sample files I have.
* demux_mkv: reject 0 TimecodeScaleGravatar wm42014-12-06
| | | | | | | Also reject anything over INT_MAX; no particular reason for this upper bound. Fixes #1317.
* demux_mkv: remove ancient codec mapping leftoversGravatar wm42014-11-28
| | | | | | | | | | | | | | | | | | | All of this is basically due to how MPlayer's codecs.conf worked. It had a demuxer-interface based an AVI, using FourCCs and data structures found in AVI. FourCCs were used to map streams to decoders. For codecs not supported by AVI, "MPlayer internal" FourCCs were made up. codec_tags.c is there to bridge demuxers written against the old API to the mpv one. By now, only demux_mkv.c needs this (because demux_mkv is the only serious demuxer left - preferably, we should use libavformat for mkv too, but I can't see this happening any time soon, because libavformat _still_ doesn't support segment linking). But the codec tables are full of weird stuff automatically extracted from the old codecs.conf tables. Most of it isn't needed for mkv. Remove all custom tags, readd those used by demux_mkv.c internally (see vinfo and mkv_audio_tag tables). The rest is handled by the tables provided by libavformat, which includes AVI and QT tags.
* demux_mkv: simplify extradata handlingGravatar wm42014-11-27
| | | | | | | | | It was more complicated than necessary. The behavior changes slightly. Now it might pass through extradata when it didn't before (hopefully harmless), and doesn't fail with an error if extradata is not available, even though it's needed (harmless, will fail either way).
* demux_mkv: cosmeticsGravatar wm42014-11-27
|
* demux_mkv: fix a possible out of bounds accessGravatar wm42014-11-27
| | | | | | | | | | | | | The if branch has a weak check to test whether the codec_id is the short ID, and handles the long IDs in the else branch. The long IDs are all longer than 12 bytes long, so hardcoding the string offset to get the trailing part of the name makes sense. But the if condition checks for another thing, which could get the else branch run even if the codec_id is short. Fix the bogus control flow and check if the codec_id is long enough. One of these checks could be considered redundant, but include them both for defensive coding.
* demux_mkv: fix scary sign extension issuesGravatar wm42014-11-21
| | | | | | | Expressions involving uint16_t are promoted to int, which then can overflow if the uint16_t values are large enough. Found by Coverity.
* demux_mkv: fix possible real-audio out of bounds accessesGravatar wm42014-11-21
| | | | | | | Could index static arrays from arbitrary input data without checking for bounds. Found by Coverity.
* demux_mkv: fix uninitialized variableGravatar wm42014-11-21
| | | | Found by Coverity.
* demux_mkv: haali hack: add last frame duration to video length tooGravatar wm42014-11-20
| | | | | From what I can see, only the blockduration of the packet needs to be added, never the "default duration".
* demux_mkv: add an option for compatibility with HaaliGravatar wm42014-11-18
| | | | This was requested on IRC.
* demux_mkv: check file type without actually reading dataGravatar wm42014-11-16
| | | | | | | | Do a minimal check on data read with stream_peek(). This could help with probing from unseekable streams in some situations. (We could check the entire EBML and Matroska headers, but probably not worth the trouble. We could also seek back to the start, which demux.c doesn't do, but which would work usually - also not worth the trouble.)
* demux_mkv: adjust subtitle preroll again (2)Gravatar wm42014-11-15
| | | | | | | | | | | | | | Make the changes started in commit c827ae5f more eloborate, and provide an option to control the amount of data read before the seek-target. To achieve this, rewrite the loop that finds the lowest still acceptable target cluster. It is now searched by time instead of file position. The behavior (both with and without preroll option) may be different from before this change, although it shouldn't be worse. The change demux_mkv_read_cues() fixes a bug: when seeking after playing normally, the code would erroneously assume that durations are set. This doesn't happen if the first operation after loading was a seek instead of playback.
* demux_mkv: adjust subtitle preroll againGravatar wm42014-11-11
| | | | | | | | | | | | | | | Revert commit 24e52f66; even though the old beheavior doesn't make sense (as the commit message assured), it turns out that this works better: typically, it means preroll will start from the previous video key frame (the video CUE index will contain clusters with video key frames only), which often coincides with subtitle changes. Thus the old behavior is actually better. Change the code that uses CueDuration elements. Instead of merely checking whether preroll should be done, find the first cluster that needs to be read to get all subtitle packets. (The intention is to compensate for the enlarged preroll cluster-range due to reverting commit 24e52f66.)
* demux_mkv: fix indentationGravatar wm42014-11-05
| | | | Meh.
* demux_mkv: for subtitle preroll, consider all clustersGravatar wm42014-11-05
| | | | | | | | | This considered only index entries that were for the same track ID as the track used for seeking. This doesn't make much sense for preroll; it'll just possibly skip clusters, and select an earlier cluster. One possible negative side-effect is that the preroll might be too tight now, and miss subtitle packets more often.
* demux_mkv: apply subtitle preroll only if needed, based on cue indexGravatar wm42014-11-05
| | | | | | | | | The demuxer has a hack to seek to the cluster before the target cluster in order to "catch" subtitle lines that start before the seek target, but overlap with the video after the seek target. Avoid this hack if the cue index indicates that there are no overlapping subtitle packets that can be caught by seeking to the previous cluster.
* demux_mkv: read CueRelativePosition/CueDuration elementsGravatar wm42014-11-05
| | | | | | | | Nothing is done with them yet. This is preparation for the following commit. CueRelativePosition isn't even saved anywhere, because I don't intend to use it. (Too messy for no gain.)
* demux_mkv: index all packetsGravatar wm42014-11-05
| | | | | | | | | | | | Instead of indexing only 1 packet per cluster (which is enough for working seeking), add every packet to the index. Since on seek, we go through every single index entry, this probably makes seeking slower. On the other hand, this code is used for files without index only (e.g. incomplete files), so it probably doesn't matter much. Preparation for the following commits.
* demux_mkv: remove minor code duplicationGravatar wm42014-11-03
|
* demux_mkv: implement audio skipping/trimmingGravatar wm42014-11-03
| | | | | | | | | | | | | This mechanism was introduced for Opus, and allows correct skipping of "preroll" data, as well as discarding trailing audio if the file's length isn't a multiple of the audio frame size. Not sure how to handle seeking. I don't understand the purpose of the SeekPreRoll element. This was tested with correctness_trimming_nobeeps.opus, remuxed to mka with mkvmerge v7.2.0. It seems to be correct, although the reported file duration is incorrect (maybe a mkvmerge issue).
* player: always use demux_chapterGravatar wm42014-11-02
| | | | | | | | | Instead of defining a separate data structure in the core. For some odd reason, demux_chapter exported the chapter time in nano-seconds. Change that to the usual timestamps (rename the field to make any code relying on this to fail compilation), and also remove the unused chapter end time.
* demux: move some seek flag sanitation to generic codeGravatar wm42014-10-29
| | | | No reason why only demux_mkv.c should do this.
* demux_mkv: implement percentage seeking with no indexGravatar wm42014-10-29
| | | | It was implemented only for the case the index exists (pretty useless).
* demux_mkv: export packet file positionGravatar wm42014-10-29
| | | | | This gives us approximate fallback playback percentage position if the duration is unknown.
* demux_mkv: fix undefined behaviorGravatar wm42014-10-13
| | | | | | | With some files, the extradata variable can remain uninitialized, but will be used for memory access. CC: @mpv-player/stable (with high priority)
* demux_mkv: don't use default_duration for parsed packetsGravatar wm42014-09-26
| | | | | | | | | Makes it behave slightly better for VP9. This is also the behavior libavformat has. Also while we're at it, don't set duration except for the first packet. Normally we don't use the duration except for subtitles (which are never parsed or "laced"), so this should make no observable difference.
* demux_mkv: get rid of MS structsGravatar wm42014-09-25
| | | | | | | See previous commits. This finally replaces directly reading the file data into a struct with reading them manually. In theory this is more portable (no alignment issues and other things). For the most part, it's nice seeing this gone.
* audio: remove WAVEFORMATEX from internal demuxer APIGravatar wm42014-09-25
| | | | | Same as with the previous commit. A bit more involved due to how the code is written.
* video: remove BITMAPINFOHEADER from internal demuxer APIGravatar wm42014-09-25
| | | | | | | | | | MPlayer traditionally did this because it made sense: the most important formats (avi, asf/wmv) used Microsoft formats, and many important decoders (win32 binary codecs) also did. But the world has changed, and I've always wanted to get rid of this thing from the codebase. demux_mkv.c internally still uses it, because, guess what, Matroska has a VfW muxing mode, which uses these data structures natively.
* demux: gracefully handle packet allocation failuresGravatar wm42014-09-16
| | | | Now the packet allocation functions can fail.
* demux_mkv: allow up to 256 MB of extradata to make broken files workGravatar wm42014-09-04
| | | | | | | | What the flying fuck? Unfortunately, these are already in the wild. CC: @mpv-player/stable
* video: initial Matroska 3D supportGravatar wm42014-08-30
| | | | | | | | | | | | | | | | | | | | | This inserts an automatic conversion filter if a Matroska file is marked as 3D (StereoMode element). The basic idea is similar to video rotation and colorspace handling: the 3D mode is added as a property to the video params. Depending on this property, a video filter can be inserted. As of this commit, extending mp_image_params is actually completely unnecessary - but the idea is that it will make it easier to integrate with VOs supporting stereo 3D mogrification. Although vo_opengl does support some stereo rendering, it didn't support the mode my sample file used, so I'll leave that part for later. Not that most mappings from Matroska mode to vf_stereo3d mode are probably wrong, and some are missing. Assuming that Matroska modes, and vf_stereo3d in modes, and out modes are all the same might be an oversimplification - we'll see. See issue #1045.
* demux_mkv: eliminate redundant branchGravatar shdown2014-08-30
| | | | | | In the else branch pict_type is always 3, so pict_type != 3 is always false. (Note that I have no idea of what it was supposed to do and it is just an equivalent of the old behaviour.)
* Move compat/ and bstr/ directory contents somewhere elseGravatar wm42014-08-29
| | | | | | | | | bstr.c doesn't really deserve its own directory, and compat had just a few files, most of which may as well be in osdep. There isn't really any justification for these extra directories, so get rid of them. The compat/libav.h was empty - just delete it. We changed our approach to API compatibility, and will likely not need it anymore.
* demux: fix timestamp type for seek callsGravatar wm42014-07-21
| | | | | mpv/mplayer2/MPlayer use double for timestamps, but the demuxer API used float.
* demux: minor simplificationGravatar wm42014-07-06
| | | | Oops, should have been part of commit 37085788.
* demux: minor simplification to internal APIGravatar wm42014-07-05
| | | | Also some other unrelated minor changes.
* demux_mkv: cosmeticsGravatar wm42014-07-05
|
* demux_mkv: minor improvement to overflow checkGravatar wm42014-07-02
| | | | CC: @mpv-player/stable
* Audit and replace all ctype.h usesGravatar wm42014-07-01
| | | | | | | | | | | | | | | | Something like "char *s = ...; isdigit(s[0]);" triggers undefined behavior, because char can be signed, and thus s[0] can be a negative value. The is*() functions require unsigned char _or_ EOF. EOF is a special value outside of unsigned char range, thus the argument to the is*() functions can't be a char. This undefined behavior can actually trigger crashes if the implementation of these functions e.g. uses lookup tables, which are then indexed with out-of-range values. Replace all <ctype.h> uses with our own custom mp_is*() functions added with misc/ctype.h. As a bonus, these functions are locale-independent. (Although currently, we _require_ C locale for other reasons.)
* demux_mkv: cosmeticsGravatar wm42014-06-29
|
* demux_mkv: add some overflow checks etc.Gravatar wm42014-06-29
| | | | | | | | | | | Some of these might be security relevant. The RealAudio code was especially bad. I'm not sure if all RealAudio stuff still plays correctly; I didn't have that many samples for testing. Some checks might be unnecessary or overcomplicated compared to the (obfuscated) nature of the code. CC: @mpv-player/stable
* demux_mkv: add S_DVBSUBGravatar wm42014-06-17
| | | | Probably works; untested.
* options: turn --idx, --forceidx into --indexGravatar wm42014-06-13
| | | | | | | | | | | | Also clarify the semantics. It seems --idx didn't do anything. Possibly it used to change how the now removed legacy demuxers like demux_avi used to behave. Or maybe it was accidental. --forceidx basically becomes --index=force. It's possible that new index modes will be added in the future, so I'm keeping it extensible, instead of e.g. creating --force-index.
* Add more constGravatar wm42014-06-11
| | | | | | | While I'm not very fond of "const", it's important for declarations (it decides whether a symbol is emitted in a read-only or read/write section). Fix all these cases, so we have writeable global data only when we really need.
* stream: don't use end_posGravatar wm42014-05-24
| | | | | | | | | | | | | | | | | | | Stop using it in most places, and prefer STREAM_CTRL_GET_SIZE. The advantage is that always the correct size will be used. There can be no doubt anymore whether the end_pos value is outdated (as it happens often with files that are being downloaded). Some streams still use end_pos. They don't change size, and it's easier to emulate STREAM_CTRL_GET_SIZE using end_pos, instead of adding a STREAM_CTRL_GET_SIZE implementation to these streams. Make sure int64_t is always used for STREAM_CTRL_GET_SIZE (it was uint64_t before). Remove the seek flags mess, and replace them with a seekable flag. Every stream must set it consistently now, and an assertion in stream.c checks this. Don't distinguish between streams that can only be forward or backwards seeked, since we have no such stream types.