summaryrefslogtreecommitdiffstats
path: root/demux
Commit message (Collapse)AuthorAgeFilesLines
* demux_mkv: allow negative timestampswm42016-01-271-18/+20
| | | | | | | FFmpeg can generate such files. It's unclear whether they're allowed by Matroska. mkvinfo shows packet timestamps in both forms (one of them must be a bug), and at last libavformat's demuxer treats timestamps as signed.
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-1910-88/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This covers source files which were added in mplayer2 and mpv times only, and where all code is covered by LGPL relicensing agreements. There are probably more files to which this applies, but I'm being conservative here. A file named ao_sdl.c exists in MPlayer too, but the mpv one is a complete rewrite, and was added some time after the original ao_sdl.c was removed. The same applies to vo_sdl.c, for which the SDL2 API is radically different in addition (MPlayer supports SDL 1.2 only). common.c contains only code written by me. But common.h is a strange case: although it originally was named mp_common.h and exists in MPlayer too, by now it contains only definitions written by uau and me. The exceptions are the CONTROL_ defines - thus not changing the license of common.h yet. codec_tags.c contained once large tables generated from MPlayer's codecs.conf, but all of these tables were removed. From demux_playlist.c I'm removing a code fragment from someone who was not asked; this probably could be done later (see commit 15dccc37). misc.c is a bit complicated to reason about (it was split off mplayer.c and thus contains random functions out of this file), but actually all functions have been added post-MPlayer. Except get_relative_time(), which was written by uau, but looks similar to 3 different versions of something similar in each of the Unix/win32/OSX timer source files. I'm not sure what that means in regards to copyright, so I've just moved it into another still-GPL source file for now. screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but they're all gone.
* demux: remove a minor difference between threaded/unthreaded modeswm42016-01-191-2/+2
| | | | This difference was unnecessary.
* demux: fix leaking closed captions packets with unselected sub streamwm42016-01-191-6/+6
| | | | | Calling demux_add_packet() unconditonally frees the packet if the stream is not selected.
* vd_lavc: feed A53_CC side data packets into the demuxer for eia_608 decodingAman Gupta2016-01-182-0/+26
|
* demux: disable stream cache if no tracks are selectedwm42016-01-181-0/+8
| | | | | | | | | Slightly helps with timeline stuff, like EDL. There is no need to keep network (or even just disk I/O) busy for all segments at the same time, because 1. the data won't be needed any time soon, and 2. will probably be discarded anyway if the stream is seeked when segment is resumed. Partially fixes #2692.
* demux: remove unused functionwm42016-01-182-15/+0
|
* demux: fix interleaved subtitle reading in unthreaded modewm42016-01-181-16/+17
| | | | | | Meh. Why are there even two code paths. This adds an additional check; the big function is only moved.
* demux: unify codepaths for threaded/unthreaded track switchingwm42016-01-181-10/+8
| | | | Well, not that the unthreaded case is important, or even works properly.
* demux: remove unused flagwm42016-01-181-1/+0
|
* sub: fix memory leakswm42016-01-181-0/+2
| | | | | | | | | demux_lavf.c leaked the complete subtitle data if it was put through iconv. lavc_conv.c leaked AVCodecContext.subtitle_header (set by libavcodec), which is fixed by using avcodec_free_context(). It also leaked the subtitle that was decoded last.
* demux_lavf: update metadata with information from AV_PROGRAM on switch.Oliver Freyermuth2016-01-141-0/+6
| | | | | | Need to trigger demux_changed() manually since metadata of tracks and streams is not changed, but demuxer-metadata is still changed on program switch.
* demux_lavf: fix charset conversion with UTF-16 subtitleswm42016-01-121-5/+6
| | | | | | | | | | | | | | | | | | | | UTF-16 subtitles are special in that they are usually read by libavformat directly, even though they are not in UTF-8. This is explicitly handled convert_charset() and skips conversion to UTF-8. There was a bug due to not resetting the file position: if conversion happens, the actual stream is replaced with a memory stream containing the converted data, but if conversion is skipped, the original stream with the wrong file position is kept. Fix by always opening a memory stream. (We _could_ seek back, but there is a slight possibility of additional failure due to unseekable streams.) Also, don't enter conversion if the subtitle is detected as UTF-8 either. Fixes #2700.
* demux: merge sh_video/sh_audio/sh_subwm42016-01-1211-179/+165
| | | | | | | | | | This is mainly a refactor. I'm hoping it will make some things easier in the future due to cleanly separating codec metadata and stream metadata. Also, declare that the "codec" field can not be NULL anymore. demux.c will set it to "" if it's NULL when added. This gets rid of a corner case everything had to handle, but which rarely happened.
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-118-8/+8
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* player: eliminate demux_get_next_pts()wm42016-01-112-17/+0
| | | | | | | | | | | | | | | | This slightly changes behavior when seeking with external audio/subtitle tracks if transport streams and mpeg files are played, as well as behavior when seeking with such external tracks. get_main_demux_pts() is evil because it always blocks on the demuxer (if there isn't already a packet queued). Thus it could lock up the player, which is a shame because all other possible causes have been removed. The reduced "precision" when seeking in the ts/mpeg cases (where SEEK_FACTOR is used, resulting in byte seeks instead of timestamp seeks) might lead to issues. We should probably drop this heuristic. (It was introduced because there is no other way to seek in files with PTS resets with libavformat, but its value is still questionable.)
* demux_lavf: re-enable codepage autodetection for .assfwr2016-01-041-2/+1
| | | | | | | | There are a lot of incorrectly encoded subtitles with .ass extension and non-ass subtitles (srt, ssa) with such extension, so we need to try codepage detection even for .ass. Signed-off-by: wm4 <wm4@nowhere>
* demux_mkv: skip EBML void elementsKagami Hiiragi2015-12-291-1/+1
| | | | | | | EBML_ID_VOID might occur at any level, see: https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown This change prevents "Corrupt file detected" errors on completely valid files.
* sub: change how subtitles are readwm42015-12-291-6/+28
| | | | | | | | Slightly change how it is decided when a new packet should be read. Switch to demux_read_packet_async(), and let the player "wait properly" until required subtitle packets arrive, instead of blocking everything. Move distinguishing the cases of passive and active reading into the demuxer, where it belongs.
* sub: do charset conversion in demux_lavf.cwm42015-12-282-14/+19
| | | | | | | | | | | | | Just so I can remove a few lines from dec_sub.c. This is slightly inelegant, as the whole subtitle file has to be read into memory, converted at once in memory, and then provided to libavformat in an awkward way by creating a memory stream instead of using demuxer->stream. It also won't be possible to force the charset on subtitles in binary container formats - but this wasn't exposed before, and we just hope this won't be ever needed. (One motivation was fixing broken files with non-UTF8 muxed.) It also won't be possible to change the charset on the fly, but this was not exposed either.
* demux_lavf: prepare for using wrapper stream instancewm42015-12-281-14/+20
| | | | Preparation for the next commit.
* demux_mkv: adjust subtitle preroll defaultswm42015-12-271-3/+13
| | | | | | | | | | | | | | | | | Always preroll by default if the cue (index) information indicates overlapping subtitles. Increase the amount of maximum data it will skip to get such subtitles to 10 seconds. Since the index information can reliably tell whether reading earlier is needed, the maximum should be rarely actually used, thus we can set it high. On the other hand, the "old" prerolling mechanism always has to skip the maximum amount of data; thus the method using the index gets its own option to control the maximum amount of data to skip. (As more and more files With newer mkvtoolnix versions are muxed, and with this new and hopefully sane default established, these options can probably be removed in the future.)
* sub: cache subtitle state per track instead of per demuxer streamwm42015-12-261-1/+0
| | | | | | | | | | | | Since commit 6d9cb893, subtitle state doesn't survive timeline switches (ordered chapters etc.). So there is no point in caching the state per sh_stream anymore (which would be required to deal with multiple segments). Move the cache to struct track. (Whether it's worth caching the subtitle state just for the situation when subtitle tracks get reselected is questionable. But for now, it's nice to have the subtitles immediately show up when reselecting a subtitle.)
* demux_mf: fix previous commitwm42015-12-231-5/+7
| | | | It was total crap.
* demux: remove weird tripple-buffering for the sh_stream listwm42015-12-239-130/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The demuxer infrastructure was originally single-threaded. To make it suitable for multithreading (specifically, demuxing and decoding on separate threads), some sort of tripple-buffering was introduced. There are separate "struct demuxer" allocations. The demuxer thread sets the state on d_thread. If anything changes, the state is copied to d_buffer (the copy is protected by a lock), and the decoder thread is notified. Then the decoder thread copies the state from d_buffer to d_user (again while holding a lock). This avoids the need for locking in the demuxer/decoder code itself (only demux.c needs an internal, "invisible" lock.) Remove the streams/num_streams fields from this tripple-buffering schema. Move them to the internal struct, and protect them with the internal lock. Use accessors for read access outside of demux.c. Other than replacing all field accesses with accessors, this separates allocating and adding sh_streams. This is needed to avoid race conditions. Before this change, this was awkwardly handled by first initializing the sh_stream, and then sending a stream change event. Now the stream is allocated, then initialized, and then declared as immutable and added (at which point it becomes visible to the decoder thread immediately). This change is useful for PR #2626. And eventually, we should probably get entirely of the tripple buffering, and this makes a nice first step.
* demux_lavf: rename to handle_new_stream to clarify intentAman Gupta2015-12-221-2/+2
|
* demux_lavf: make trace output for mp_seek easier to digestAman Gupta2015-12-211-1/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* demux_disc: fix aspect ratio retrieval (again)wm42015-12-201-3/+3
| | | | | | Commit 127da161 was not properly tested either - it did nothing, and just made it use the video bitstream aspect ratio determined by libavformat (which isn't always the correct one).
* demux_disc: fix aspect ratiowm42015-12-201-2/+6
| | | | | Broken by commit 0a0bb905. STREAM_CTRL_GET_ASPECT_RATIO returns a display aspect ratio, not a pixel aspect ratio.
* video: switch from using display aspect to sample aspectwm42015-12-194-12/+16
| | | | | | | | | | | | | | | | MPlayer traditionally always used the display aspect ratio, e.g. 16:9, while FFmpeg uses the sample (aka pixel) aspect ratio. Both have a bunch of advantages and disadvantages. Actually, it seems using sample aspect ratio is generally nicer. The main reason for the change is making mpv closer to how FFmpeg works in order to make life easier. It's also nice that everything uses integer fractions instead of floats now (except --video-aspect option/property). Note that there is at least 1 user-visible change: vf_dsize now does not set the display size, only the display aspect ratio. This is because the image_params d_w/d_h fields did not just set the display aspect, but also the size (except in encoding mode).
* demux: check embedded cuesheet refers to only one fileKevin Mitchell2015-12-173-4/+25
| | | | | | If someone was "clever" enough to embed a cuesheet referencing multiple files, mpv would create a bunch of nonsense chapter markers.
* demux_cue: remove cue tracks which have a null filename.Kevin Mitchell2015-12-171-2/+12
| | | | | | | | | | This can happen if the file references a track, but does not specify an INDEX 01 for it. This would cause mpv to just segfault due to dereferencing the null pointer as a string. A file causing this was observed in the wild by ExactAudioCopy v0.99pb4 for a disk that contained a data track at the end.
* demux_lavf: minor cleanupswm42015-12-171-13/+5
|
* sub: detect charset in demuxerwm42015-12-172-9/+27
| | | | | | | | | | | | Slightly simpler, and removes the need to pre-read all subtitle packets. This still does the subtitle charset conversion on the packet level (instead converting when parsing the file), so in theory this still could provide a way to change the charset at runtime. But maybe even this should be removed, as FFmpeg is somewhat likely to get its own charset detection and conversion mechanism in the future. (Would have to keep the subtitle file in memory to allow changing the charset on the fly, I guess.)
* sub: remove sd_movtext.cwm42015-12-151-4/+12
| | | | | libavcodec's movtext-to-ass converter does the same and has more features. On Libav, this commit disables mp4 subtitle display.
* demux: remove old subtitle parserwm42015-12-102-840/+0
| | | | | | | | | All of these are supported by FFmpeg now. It was disabled by default too (with FFmpeg). If compiled against Libav, mpv will lose the ability to read some subtitle formats (but the most important ones, srt and ass, still should work).
* csputils: rename "yuv2rgb" functionswm42015-12-091-1/+1
| | | | | | They're not necessarily restricted to YUV aka YCbCr. vo_direct3d.c and demux_disc.c (DVD specific code) changes untested.
* csputils: remove obscure int_bits matrix scalingwm42015-12-091-4/+3
| | | | | | | This has no reason to be there. Put the functionality into another function instead. While we're at it, also adjust for possible accuracy issues with high bit depth YUV (matters for rendering subtitles into screenshots only).
* demux: fix seeking in .tswm42015-11-231-1/+1
| | | | | .ts files (and some other raw streams) are the only files that enable the SEEK_FACTOR code path, which was broken since commit 70df1608.
* demux_mkv: fix incremental indexing with single-keyframe fileswm42015-11-171-2/+1
| | | | | | | | | | | | This is another regression of the recently added start time probing. If a seek is executed after opening the file (but before reading any packets), the first block is discarded instead of indexed. If there are no other keyframes in the file, seeking will fail completely. Fix it by seeking to the cluster start if there aren't any index entries yet. This will read the skipped packet again. Fixes #2498.
* player: handle rebasing start time differentlywm42015-11-162-1/+21
| | | | | | | | | | | | | | | | Most of this is explained in the DOCS additions. This gives us slightly more sanity, because there is less interaction between the various parts. The goal is getting rid of the video_offset entirely. The simplification extends to the user API. In particular, we don't need to fix missing parts in the API, such as the lack for a seek command that seeks relatively to the start time. All these things are now transparent. (If someone really wants to know the real timestamps/start time, new properties would have to be added.)
* demux_libass: remove this demuxerwm42015-11-112-115/+0
| | | | | | | | | This loaded external .ass files via libass. libavformat's .ass reader is now good enough, so use that instead. Apparently libavformat still doesn't support fonts embedded into text .ass files, but support for this has been accidentally broken in mpv for a while anyway. (And only 1 person complained.)
* demux_lavf: mark ASS tracks as always UTF-8wm42015-11-111-0/+4
| | | | | Stops mpv from trying to run a subtitle charset detector on .ass files loaded by libavformat.
* libarchive: remove redundant log prefixKevin Mitchell2015-11-091-1/+1
| | | | "libarchive:" is already added by the logging system
* demux_mkv: remove --demuxer-mkv-fix-timestampswm42015-11-071-17/+1
| | | | | | | | While it seemed like a pretty good idea at first, it's just a dead end and works only in the simplest cases. While it may or may not help slightly with audio sync mode, the display-sync mode already compensates this in a better way. The main issue is that timestamps at this layer are not in order, so it can look at single timestamps only.
* demux_mkv: dump mixing/writing app fields in verbose logwm42015-11-061-0/+4
|
* Replace deprecated av_free_packet() callswm42015-10-281-4/+4
| | | | | | av_free_packet() got finally deprecated. Use av_packet_unref() instead, which has almost the same semantics, has existed for a while, and is available in all FFmpeg and Libav versions we support.
* demux_mkv: fix cluster skip with duration probingwm42015-10-271-6/+7
| | | | The start time probing essentially broke it.
* demux_mkv: fix duration probing for files with non-0 start timewm42015-10-261-1/+1
| | | | | When using --demuxer-mkv-probe-video-duration=full and the file did not start at timestamp 0, the reported duration was still wrong.
* command: do not return 0 for bitrates if unknownwm42015-10-231-2/+3
| | | | | | | | This makes the bitrate properties unavailable, instead of returning 0 when: 1. No track is selected, or 2. Not enough packets have been read to have a bitrate estimate yet
* demux: cosmetics: remove indirectionwm42015-10-221-4/+2
| | | | Let's not waste precious lines.
* demux_lavf: always copy codec headerswm42015-10-191-1/+8
| | | | | | If this is not done, libavformat could change the headers while demuxing, all while the decoder thread reads these fields during initialization.
* demux: remove demux_add_packet() return valuewm42015-10-173-7/+7
|
* demux_mkv: probe start timewm42015-10-161-10/+43
| | | | | | | | | | | | | | | | | MKV files can very well start with timestamps other than 0. While mpv has support for such files in general, and demux_lavf enables this feature, demux_mkv didn't export a start time. Implement this by simply reading the first cluster timestamp. This in turn is done by reading 1 block. While we don't need the block for this prupose at all, it's the easiest way to get the cluster timestamp read correctly without code duplication. In theory this could be wrong, and a packet could start at a much later time, but in practice this won't happen. This commit also adds an option to disable this feature. It's not documented because nobody should use it. (But I happen to have a need for this.)
* demux_mkv: do not return subtitle packets that end before seek targetwm42015-10-121-2/+6
| | | | | | This affects the subtitle preroll mode during seeking. It could matter somewhat with insane files with ten-thousands of subtitle events, which now seem to pop up, and will avoid packet queue overflow.
* demux_subreader: participate in probing only on Libavwm42015-10-081-0/+4
| | | | | | FFmpeg supports all formats the old subreader code does, and is better at it. On the other hand, subreader.c's probing is bad and can lead to false positives easily.
* demux: don't attempt to open a demuxer after abort signal was givenwm42015-10-061-0/+3
| | | | | demux_open() kept trying to fallback to other demuxers when opening was cancelled. This was not really a problem, but it was stupid.
* cue: read more metadatawm42015-10-014-26/+42
| | | | | | | | | | | Make handling of metadata slightly more generic, and add reading of the "PERFORMER" fields. There are some more fields, but for now let's leave it at this. TRACK-specific PERFORMER fields have to be read from the per-chapter metadata (somewhat obscure). Fixes #2328.
* Take care of libavcodec convergence_duration deprecationwm42015-09-291-0/+2
| | | | | | This AVPacket field was a hack against the fact that the duration field was merely an int (too small for things like subtitle durations). Newer libavcodec drops this field and makes duration 64 bit.
* ebml: warn if an EBML has unknown lengthwm42015-09-031-0/+4
| | | | | | | | | | | | | While unknown lengths are supported in some important cases like segments and clusters, they are not for small and complex metadata elements like the track list. Such elements are simply rejected. This case was caught by the size sanity check below, but the message is misleading and wrong. (There are likely no files in the wild which require support for this. The sample file I've seen was muxed by libavformat, but in a case where it aborted when writing the header. Clearly a broken file.)
*