summaryrefslogtreecommitdiffstats
path: root/demux
Commit message (Collapse)AuthorAgeFilesLines
* demux_lavf: set PTS of first packet for formats with no timestampswm42014-11-251-0/+9
| | | | Makes time display work for some raw audio formats (*.shn).
* demux_mkv: fix scary sign extension issueswm42014-11-211-8/+8
| | | | | | | 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 accesseswm42014-11-211-1/+7
| | | | | | | Could index static arrays from arbitrary input data without checking for bounds. Found by Coverity.
* demux_mkv: fix uninitialized variablewm42014-11-211-1/+1
| | | | Found by Coverity.
* demux_mkv: haali hack: add last frame duration to video length toowm42014-11-201-2/+3
| | | | | 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 Haaliwm42014-11-181-0/+65
| | | | This was requested on IRC.
* demux_mkv: check file type without actually reading datawm42014-11-161-0/+7
| | | | | | | | 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_cue: use stream_peek()wm42014-11-161-6/+2
| | | | | | This could cause probing failures with unseekable streams. (Although I'm not perfectly sure why; seeking back should work in this particular case.)
* demux_mkv: adjust subtitle preroll again (2)wm42014-11-151-3/+12
| | | | | | | | | | | | | | 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: update cache state when pausedwm42014-11-121-1/+11
| | | | | | | | | | | | | This was removed in commit 480f82fa. This caused the cache display not to update while paused, because the update_cache() function is never called in the thread (now I remember why the extra call was "needed"). The old implementation intentionally run update_cache() only before waiting on a mutex, with no further checks for the condition variable. In theory, this is strictly not sane, but since it was just for the retrieval of the very fuzzy cache status, it was ok. Now we want to call update_cache() outside of the mutex though - which means that in order to avoid missed wakeups, a proper condition has to be used.
* demux_mkv: adjust subtitle preroll againwm42014-11-111-14/+17
| | | | | | | | | | | | | | | 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 undefined shiftswm42014-11-081-4/+4
| | | | | | | Found by clang sanitizer. Casting unsigned integers to signed integers with same size has implementation defined behavior (it's even allowed to crash), but it seems reasonable to expect that reasonable implementations do a complement of 2 "conversion".
* demux_mkv: fix indentationwm42014-11-051-3/+3
| | | | Meh.
* demux_mkv: for subtitle preroll, consider all clusterswm42014-11-051-5/+3
| | | | | | | | | 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 indexwm42014-11-051-0/+16
| | | | | | | | | 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 elementswm42014-11-051-11/+27
| | | | | | | | 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 packetswm42014-11-051-4/+2
| | | | | | | | | | | | 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: report 0s readahead time as fallback in some situationswm42014-11-051-1/+5
| | | | | | | | | | If no packets are queued, the readahead time is obviously 0. If the end time is smaller than the start time, the problem is probably that audio and video start at slightly different times - report 0 in this case too. Do this because seeing "???" as readahead time is a bit annoying.
* demux: unbreak build with Libavwm42014-11-031-0/+4
| | | | ....
* demux: don't account known range for streams that are EOFwm42014-11-031-2/+4
| | | | | | | | | This influences the demuxer readahead display. If a stream has reached EOF, we want to ignore it for the purpose of this calculation. Note that if a stream contains no packets, it still should cause the value 0s to be displayed (unless it's EOF), because that's just the actual situation.
* demux: fix PTS comparisonwm42014-11-031-2/+4
| | | | | | | | This was relying on the fact that timestamps will always be numerically larger than MP_NOPTS_VALUE, but the trick didn't actually work for MP_PTS_MIN. Be a bit more sincere, and don't rely on this anymore. This fixes the comparison, and avoids the readahead amount displaying as "???" in some situations (since one of the values was NOPTS).
* demux: don't consider stream EOF an underrunwm42014-11-031-1/+1
| | | | | | | | | | | | In this case, we didn't find any new packets for this stream, even though we've read ahead as much as possible. (If reading ahead in this case, the "Too many packets in the demuxer packet queues" error is normally printed.) If we do consider this an underrun, handle_pause_on_low_cache() will pause and show the "buffering" state, which is not useful. Could also happen on very bad interleaving.
* demux_mkv: remove minor code duplicationwm42014-11-031-12/+6
|
* demux_mkv: implement audio skipping/trimmingwm42014-11-033-2/+41
| | | | | | | | | | | | | 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_chapterwm42014-11-025-15/+23
| | | | | | | | | 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_lavf, stream_lavf: drop local buffers on time-seekswm42014-10-301-2/+5
| | | | | There was chance that some data was left in various local buffers after time-seeks. Probably doesn't actually matter.
* demux_lavf: mark as seekable if protocol supports seeking by timewm42014-10-301-0/+2
| | | | | | | | | | | | Basically, this will mark the demuxer as seekable with rtmp* and mmsh protocols. These protocols have network-level time seeking, and whether you can seek on the byte level does not matter. Until now, seeking was typically only enabled because of the cache, and a (nonsensical) warning was shown accordingly. It still could happen that the server doesn't actually support thse requests (or simply rejects them), so this is somewhat imperfect.
* demux_playlist: redirect ASF streaming to mmsh://wm42014-10-301-14/+30
| | | | | | | | | | | | I'm not sure if this could be done in libavformat instead. Probably not, because libavformat doesn't seem to have any mechanism for trying one protocol and reverting (or redirecting) to another one if needed. This commit is sort of a hack too, because it redirects the URL by pretending the http:// link is a playlist containing the mmsh:// link. The list of mime types is borrowed from MPlayer (which has completely different code to handle this).
* demux: fix demux_seek signaturewm42014-10-292-2/+2
| | | | Probably doesn't matter much.
* demux: move some seek flag sanitation to generic codewm42014-10-292-10/+15
| | | | No reason why only demux_mkv.c should do this.
* demux_mkv: implement percentage seeking with no indexwm42014-10-291-22/+24
| | | | It was implemented only for the case the index exists (pretty useless).
* demux_mkv: export packet file positionwm42014-10-291-0/+1
| | | | | This gives us approximate fallback playback percentage position if the duration is unknown.
* demux: seek to position 0 when loading, instead of restoring itwm42014-10-281-7/+7
| | | | | | | | | | This was originally done for DVD/BD/DVB, where the start position could be something different from 0, and seeking back to 0 would mess it up completely. Since we're not quite sure that these streams are unseekable, we can simplify this somewhat, and also make sure we also start at 0 for normal files. Helps a little bit with the following edition reloading commit.
* demux: don't access stream while lock is heldwm42014-10-241-22/+30
| | | | | | | | | | Although this is fine when the stream cache is active (which caches these and returns the result immediately), it seems cleaner not to rely on this detail. Remove the update_cache() call from demux_thread(), because it's sort of in the way. I forgot why it exists, and there's probably no good reason for it to exist anyway.
* demux: cache STREAM_CTRL_GET_BASE_FILENAMEwm42014-10-241-0/+18
| | | | | | | | It's needed for some obscure feature in combination with .rar reading. However, it's unconditionally used by the subtitle loader code, so take care of not blocking the main thread unnecessarily. (Untested.)
* player: add stream selection by ffmpeg indexwm42014-10-213-0/+4
| | | | | | | | | Apparently using the stream index is the best way to refer to the same streams across multiple FFmpeg-using programs, even if the stream index itself is rarely meaningful in any way. For Matroska, there are some possible problems, depending how FFmpeg actually adds streams. Normally they seem to match though.
* Set thread name for debuggingwm42014-10-191-0/+2
| | | | | | | | | | Especially with other components (libavcodec, OSX stuff), the thread list can get quite populated. Setting the thread name helps when debugging. Since this is not portable, we check the OS variants in waf configure. old-configure just gets a special-case for glibc, since doing a full check here would probably be a waste of effort.
* demux: print a warning if stream is not seekablewm42014-10-171-2/+3
|
* demux_lavf: set stream network options if applicablewm42014-10-141-2/+3
| | | | | | | | | | | Normally, we pass libavformat demuxers a wrapped mpv stream. But in some cases, such as HLS and RTSP, we let libavformat open the stream itself. In these cases, set typical network properties like useragent according to the mpv options. (We still don't set it for the cases where libavformat opens other streams on its own, e.g. when opening the companion .sub file for .idx files - not sure if we maybe should always set these options.)
* demux_lavf: let libavformat open HLS streams directlywm42014-10-141-1/+2
| | | | | | | | Fixes opening some streams. This means the HLS playlist will be opened twice, but that's not much of a problem, considering it's pretty small, and HLS will make many other http accesses anyway.
* demux_mkv: fix undefined behaviorwm42014-10-131-1/+1
| | | | | | | With some files, the extradata variable can remain uninitialized, but will be used for memory access. CC: @mpv-player/stable (with high priority)
* demux: fix a commentwm42014-10-121-2/+1
| | | | Don't refer to fields that were removed.
* Add some missing "const"swm42014-10-101-2/+2
| | | | | | | The one in msg.c was mistakenly removed with commit e99a37f6. I didn't actually test the change in ao_sndio.c (but obviously "ap" shouldn't be static).
* demux_lavf: blacklist jpeg fileswm42014-10-061-0/+1
| | | | | | | We handle them under demux_mf.c for stupid reasons; mostly so that an image is shown for a second instead of just flashing it. CC: @mpv-player/stable
* demux_disc: bluray: fix stream language (2)wm42014-09-301-0/+1
| | | | | | | | | Commit 50e131b43ed happened to make it work for DVD (because the higher bits of the ID are masked in the DVD case), but failed for Bluray. This probably fixes it, although I don't have a sample to multiple streams to confirm it really does it right. CC: @mpv-player/stable
* demux_disc: export BD/DVD audio languagewm42014-09-291-0/+1
| | | | This was "forgotten".
* demux_lavf: bluray: don't skip stream data when flushingwm42014-09-291-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This code meant to flush demuxer internal buffers by doing a byte seek to the current position. In theory this shouldn't drop any stream data. However, if the stream positions mismatch, then avio_seek() (called by av_seek_frame()) stops being a no-op, and might for example read some data to skip to the seek target. (This can happen if the distance is less than SHORT_SEEK_THRESHOLD.) The positions get out of sync because we drop data at one point (which is what we _want_ to do). Strictly speaking, the AVIOContext flushing is done incorrectly, becuase pb->pos points to the start of the buffer, not the current position. So we have to increment pb->pos by the buffered amount. Since there are other weird reasons why the positions might go out of sync (such as stream_dvd.c dropping buffers itself), and they don't necessarily need to be in sync in the first place unless AVIOContext has nothing buffered internally, just use the sledgehammer approach and correct the position manually. Also run av_seek_frame() after this. Currently, it shouldn't read anything, but who knows how that might change with future libavformat development. This whole change didn't have any observable effect for me, but I'm hoping it fixes a reported problem.
* demux_disc: bluray: potentially fix some aspects of seekingwm42014-09-292-1/+7
| | | | | | | | | | | | | When flushing the AVIOContext, make sure it can't seek back to discarded data. buf_ptr is just the current read position, while buf_end - buffer is the actual buffer size. Since mpegts.c is littered with seek calls, it might be that the ability to seek could read Mark the stream (which the demuxer uses) as not seekable. The cache can enable seeking again (this behavior is sometimes useful for other things). I think this should have had no bad influence in theory, since seeking BD/DVD first does the "real" seek, then flushes libavformat and reads new packets.
* demux_mkv: don't use default_duration for parsed packetswm42014-09-261-4/+6
| | | | | | | | | 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.
* Remove mpbswap.hwm42014-09-251-1/+0
| | | | | | This was once central, but now it's almost unused. Only vf_divtc still uses it for extremely weird and incomprehensible reasons. The use in stream.c is trivial. Replace these, and remove mpbswap.h.
* stream_cdda, demux_raw: always use s16lewm42014-09-251-1/+1
| | | | | | | | | | | | | stream_cdda's output format is linked to demux_raw's default audio format, and at least we don't care enough to provide a separate mechanism to let stream_cdda explicitly set the format, so they must match. Judging from the existing code, it looks like CDDA always outputs little endian. stream_cdda.c changed this back to native endian (what demux_raw expects). Just make them both little endian. This requires less code, and also having a raw demuxer's behavior depend on the endianness of the machine isn't very sane anyway.
* demux_mkv: get rid of MS structswm42014-09-253-119/+39
| | | | | | | 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 APIwm42014-09-254-79/+83
| | | | | Same as with the previous commit. A bit more involved due to how the code is written.
* video: remove BITMAPINFOHEADER from internal demuxer APIwm42014-09-252-11/+11
| | | | | | | | | | 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.
* audio: confine demux_mkv audio PCM hackwm42014-09-241-6/+28
| | | | | | | | Let codec_tags.c do the messy mapping. In theory we could simplify further by makign demux_mkv.c directly use codec names instead of the MPlayer-inherited "internal FourCC" business, but I'd rather not touch this - it would just break things.
* audio: decouple demux and audio decoder/filter sample formatswm42014-09-245-51/+62
| | | | | | | | | | | | | | | | | | | | For a while, we used this to transfer PCM from demuxer to the filter chain. We had a special "codec" that mapped what MPlayer used to do (MPlayer passes the AF sample format over an extra field to ad_pcm, which specially interprets it). Do this by providing a mp_set_pcm_codec() function, which describes a sample format in a generic way, and sets the appropriate demuxer header fields so that libavcodec interprets it correctly. We use the fact that libavcodec has separate PCM decoders for each format. These are systematically named, so we can easily map them. This has the advantage that we can change the audio filter chain as we like, without losing features from the "rawaudio" demuxer. In fact, this commit also gets rid of the audio filter chain formats completely. Instead have an explicit list of PCM formats. (We could even just have the user pass libavcodec PCM decoder names directly, but that would be annoying in other ways.)
* audio: cleanup spdif format definitionswm42014-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, there was AF_FORMAT_AC3 (the original spdif format, used for AC3 and DTS core), and AF_FORMAT_IEC61937 (used for AC3, DTS and DTS-HD), which was handled as some sort of superset for AF_FORMAT_AC3. There also was AF_FORMAT_MPEG2, which used IEC61937-framing, but still was handled as something "separate". Technically, all of them are pretty similar, but may use different bitrates. Since digital passthrough pretends to be PCM (just with special headers that wrap digital packets), this is easily detectable by the higher samplerate or higher number of channels, so I don't know why you'd need a separate "class" of sample formats (AF_FORMAT_AC3 vs. AF_FORMAT_IEC61937) to distinguish them. Actually, this whole thing is just a mess. Simplify this by handling all these formats the same way. AF_FORMAT_IS_IEC61937() now returns 1 for all spdif formats (even MP3). All AOs just accept all spdif formats now - whether that works or not is not really clear (seems inconsistent due to earlier attempts to make DTS-HD work). But on the other hand, enabling spdif requires manual user interaction, so it doesn't matter much if initialization fails in slightly less graceful ways if it can't work at all. At a later point, we will support passthrough with ao_pulse. It seems the PulseAudio API wants to know the codec type (or maybe not - feeding it DTS while telling it it's AC3 works), add separate formats for each codecs. While this