summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
Commit message (Collapse)AuthorAgeFilesLines
* talloc: change talloc destructor signaturewm42013-10-131-4/+2
| | | | | | | | | | | | | Change talloc destructor so that they can never signal failure, and don't return a status code. This makes our talloc copy even more incompatible to upstream talloc, but on the other hand this is preparation for getting rid of talloc entirely. (The talloc replacement in the next commit won't allow the talloc_free equivalent to fail, and the destructor return value would be useless. But I don't want to change any mpv code either; the idea is that the talloc replacement commit can be reverted for some time in order to test whether the talloc replacement introduced a regression.)
* demux: don't print "Clip info:" line if there are no tagswm42013-09-231-1/+1
|
* demux: keep title chapter tag in uppercasewm42013-09-081-1/+1
| | | | | | | This is generally more uniform. Do the same for the file global title in demux_mkv.c, although that is not strictly related to chapters.
* demux: retrieve per-chapter metadatawm42013-09-081-2/+17
| | | | | | | | | | Retrieve per-chapter metadata, but don't do much with it. We just make the metadata of the _current_ chapter available as chapter-metadata property. Returning the full chapter list with metadata would be no problem, except that the property interface isn't really good with structured data, so it's not available for now. Not sure if it's worth it, but it was requested via github issue #201.
* demux: refactor tag handlingwm42013-09-081-36/+50
| | | | | Make the code somewhat reuseable, instead of bound to a single demuxer instance. The plan is to add support for per-chapter tags later.
* stream: add uncompressed rar supportwm42013-08-261-0/+4
| | | | | | | | | | | | | | | | | Apparently, it is popular to store large files in uncompressed rar archives. Extracting files is not practical, and some media players suport playing directly from uncompressed rar (at least VLC and some DirectShow components). Storing or accessing files this way is completely idiotic, but it is a common practice, and the ones subjected to this practice can't do much to change this (at least that's what I assume/hope). Also, it's a feature request, so we say yes. This code is mostly taken from VLC (commit f6e7240 from their git tree). We also copy the way this is done: opening a rar file by itself yields a playlist, which contains URLs to the actual entries in the rar file. Compressed entries are simply skipped.
* core: add a playlist demuxerwm42013-08-261-0/+4
| | | | | | | | | Modeled after the old playlist_parser.c, but actually new code, and it works a bit differently. Demuxers (and sometimes streams) are the component that should be used to open files and to determine the file format. This was already done for subtitles, but playlists still use a separate code path.
* demux: remove unused audio_delay parameter from demux_seek()wm42013-08-221-3/+2
| | | | Used to be needed by demux_avi.
* demux: check whether stream is selected in demux_get_next_pts()wm42013-08-221-1/+1
| | | | | | | | Otherwise, this would just try to demux a good chunk of the file, even though the operation can't succeed anyway. This caused some pretty strange issues, where perfectly valid use cases would print a "Too many packets in the demuxer packet queue..." message.
* demux: move demux_mf before demux_subreaderwm42013-08-121-3/+3
| | | | | demux_subreader is quite aggressive, and sometimes detects random strings in EXIF as subtitle text.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-3/+3
| | | | Followup commit. Fixes all the files references.
* core: make --demuxer not affect external subtitleswm42013-07-221-2/+0
| | | | | | This also affects --audiofile. The previous behavior wasn't really useful. There are even separate switches for that: --audio-demuxer and --sub-demuxer.
* demux: make claiming accurate seek the defaultwm42013-07-121-0/+1
| | | | Enables hr-seek for raw audio/video demuxers.
* demux: remove useless author/comment fieldswm42013-07-121-12/+5
| | | | Same deal as with previous commit.
* demux: rewrite probing and demuxer initializationwm42013-07-121-152/+68
| | | | | | | | | | | | | | Get rid of the strange and messy reliance on DEMUXER_TYPE_ constants. Instead of having two open functions for the demuxer callbacks (which somehow are both optional, but you can also decide to implement both...), just have one function. This function takes a parameter that tells the demuxer how strictly it should check for the file headers. This is a nice simplification and allows more flexibility. Remove the file extension code. This literally did nothing (anymore). Change demux_lavf so that we check our other builtin demuxers first before libavformat tries to guess by file extension.
* core: change open_stream and demux_open signaturewm42013-07-121-24/+16
| | | | | | | | | | | This removes the dependency on DEMUXER_TYPE_* and the file_format parameter from the stream open functions. Remove some of the playlist handling code. It looks like this was needed only for loading linked mov files with demux_mov (which was removed long ago). Delete a minor bit of dead network-related code from stream.c as well.
* demux: change signature of open functions, cleanupswm42013-07-111-13/+8
| | | | Preparation for redoing the open functions.
* demux: allow passing NULL as packet to demuxer_add_packet()wm42013-07-111-1/+1
| | | | demux_subreader relied on this.
* core: completely change handling of attached picture pseudo videowm42013-07-111-28/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, we tried to play along with libavformat and tried to pretend that attached pictures are video streams with a single frame, and that the frame magically appeared at the seek position when seeking. The playback core would then switch to a mode where the video has ended, and the "remaining" audio is played. This didn't work very well: - we needed a hack in demux.c, because we tried to read more packets in order to find the "next" video frame (libavformat doesn't tell us if a stream has ended) - switching the video stream didn't work, because we can't tell libavformat to send the packet again - seeking and resuming after was hacky (for some reason libavformat sets the returned packet's PTS to that of the previously returned audio packet in generic code not related to attached pictures, and this happened to work) - if the user did something stupid and e.g. inserted a deinterlacer by default, a picture was never displayed, only an inactive VO window) - same when using a command that reconfigured the VO (like switching aspect or video filters) - hr-seek didn't work For this reason, handle attached pictures as separate case with a separate video decoding function, which doesn't read packets. Also, do not synchronize audio to video start in this case.
* demux: improve DVD sub auto-selection hackwm42013-07-111-7/+21
| | | | | | | | | | | | | | | | | | | | | | | The code touched by this commit makes sure that DVD subtitle tracks known by libdvdread but not known by demux_lavf can be selected and displayed properly. These subtitle tracks have the first packet some time late in the packet stream, so that libavformat won't immediately recognize them, and will add the track as soon as the first packet is seen during normal demuxing. demux_mpg used to handle this elegantly: you just set the MPEG ID of the stream you wanted. demux_lavf couldn't do this, so it was emulated with a DEMUXER_CTRL. This commit changes it so that new streams are selected by default (if autoselect is enabled), and the playloop simply can take appropriate action before the lower layer throws away the first packet. This also changes the demux_lavf behavior that subtitle packets are always demuxed, even if not needed. (They were immediately thrown away, so there was no advantage to this.) Further, this adds the ability to demux.c to deal with demuxing more than one stream of a kind at once. (Though currently it's not useful.)
* demux: refactorwm42013-07-111-138/+123
|
* core: don't access demux_stream outside of demux.c, make it privatewm42013-07-111-43/+52
| | | | | | | | | | | | | | | | | | | Generally remove all accesses to demux_stream from all the code, except inside of demux.c. Make it completely private to demux.c. This simplifies the code because it removes an extra concept. In demux.c it is reduced to a simple packet queue. There were other uses of demux_stream, but they were removed or are removed with this commit. Remove the extra "ds" argument to demux fill_buffer callback. It was used by demux_avi and the TV pseudo-demuxer only. Remove usage of d_video->last_pts from the no-correct-pts code. This field contains the last PTS retrieved after a packet that is not NOPTS. We can easily get this value manually because we read the packets ourselves. Reuse sh_video->last_pts to store the packet PTS values. It was used only by the correct-pts code before, and like d_video->last_pts, it is reset on seek. The behavior should be exactly the same.
* tv: add hack in preparation of demux_stream removalwm42013-07-111-0/+7
| | | | | | | | | | Currently, all demuxer fill_buffer functions have a demux_stream parameter. We want to remove that, but the TV code still depends on it. Add a hack to remove that dependency. The problem with the TV code is that reading video and audio frames blocks, so in order to avoid a deadlock, you should read either of them only if the decoder actually requests new data.
* demux: remove facility for partial packet readswm42013-07-111-117/+61
| | | | | | | | | | | | | | | | | | Partial packet reads were needed because the video/audio parsers were working on top of them. So it could happen that a parser read a part of a packet, and returned that to the decoder. With libavformat/libavcodec, packets are already parsed, and everything is much simpler. Most of the simplifications in ad_spdif could have been done earlier. Remove some other stuff as well, like the questionable slave mode start time reporting (could be replaced by proper code, but we don't bother). Remove the unused skip_audio_frame() functionality as well (it was used by old demuxers). Some functions become private to demux.c, like demux_fill_buffer(). Introduce new packet read functions, which have simpler semantics. Packets returned from them are owned by the caller, and all packets in the demux.c packet queue are considered unread. Remove special code that dropped subtitle packets with size 0. This used to be needed because it caused special cases in the old code.
* demux: remove ds_read_packet()wm42013-07-101-13/+0
|
* demux: remove some more minor unused thingswm42013-07-101-8/+0
|
* Merge branch 'master' into remove_old_demuxerswm42013-07-081-0/+2
|\ | | | | | | | | | | Conflicts: DOCS/man/en/changes.rst DOCS/man/en/options.rst
| * Fix building with --disable-libasswm42013-07-081-0/+2
| | | | | | | | Obscure corner case, but in theory we support this.
* | demux: simplify demux_open() callswm42013-07-081-18/+9
| | | | | | | | | | | | The demux_open as well as demux_open_withparams calls don't use the stream selection parameters anymore, so remove them everywhere. Completes the previous commit.
* | demux: remove separate arrays for audio/video/sub streams, simplifywm42013-07-081-70/+24
| | | | | | | | | | | | | | | | | | | | | | | | These separate arrays were used by the old demuxers and are not needed anymore. We can simplify track switching as well. One interesting thing is that stream/tv.c (which is a demuxer) won't respect --no-audio anymore. It will probably work as expected, but it will still open an audio device etc. - this is because track selection is now always done with the runtime track switching mechanism. Maybe the TV code could be updated to do proper runtime switching, but I can't test this stuff.
* | demux: merge functionswm42013-07-081-17/+9
| |
* | demux: remove some old stream header functionswm42013-07-081-36/+0
| |
* | demux: remove audio parserwm42013-07-081-70/+0
| | | | | | | | | | | | | | | | | | | | | | The audio parser was needed only by the "old" demuxers, and demux_rawaudio. All other demuxers output already parsed packets. demux_rawaudio is usually for raw audio, so using a parser with it doesn't usually make sense. But you can also force it to read compressed formats with fixed packet sizes, in which case the parser would have been used. This use case is probably broken now, but you will be able to do the same thing with libavformat demuxers.
* | Remove old demuxerswm42013-07-071-138/+2
|/ | | | | | | | | | Delete demux_avi, demux_asf, demux_mpg, demux_ts. libavformat does better than them (except in rare corner cases), and the demuxers have a bad influence on the rest of the code. Often they don't output proper packets, and require additional audio and video parsing. Most work only in --no-correct-pts mode. Remove them to facilitate further cleanups.
* core: update metadata during playback, allow streams to export metadatawm42013-07-021-0/+13
| | | | | | | STREAM_CTRL_GET_METADATA will be used to poll for streamcast metadata. Also add DEMUXER_CTRL_UPDATE_INFO, which could in theory be used by demux_lavf.c. (Unfortunately, libavformat is too crappy to read metadata mid-stream for mp3 or ogg, so we don't implement it.)
* sub: add demux_libass wrapper, drop old hackswm42013-06-251-15/+2
| | | | | | | | | | | | demux_libass.c allows us to make subtitle format detection part of the normal file loading process. libass has no probe function, but trying to load the start of a file (the first 4 KB) is good enough. Hope that libass can even handle random binary input gracefully without printing stupid log messages, and that the libass parser doesn't accept too many non-ASS files as input. This doesn't handle the -subcp option correctly yet. This will be fixed later.
* core: don't set correct-pts mode randomlywm42013-06-251-5/+0
| | | | | | The default correct-pts mode depended on which demuxer was opened last. Often this is the subtitle demuxer. The correct-pts mode should be decided on the demuxer for video instead.
* subreader: turn into actual demuxerwm42013-06-251-0/+2
| | | | | | | | | | | | | | | | subreader.c (before this commit renamed to demux_subreader.c) was special cased to the -sub option. The plan is using the normal demuxer codepath for all subtitle formats (so we can prefer libavformat demuxers for most formats). There are some subtle changes. The probe size is restricted to 32 KB (instead of unlimitted + giving up after 100 lines of input). For formats like MicroDVD, the video FPS isn't used anymore, because it's not available on the subtitle demuxer level. Instead, hardcode it to 23.976 FPS (libavformat seems to do the same). The user can probably still use -sub-fps to fix the timing. Checking the file extension for ".utf"/".utf8"/".utf-8" is simply removed (seems worthless, was in the way, and I've never seen this anywhere).
* demux: add utility functions for preloading demuxerswm42013-06-251-3/+72
| | | | | These will be needed by subtitle demuxers, which read all data on initialization.
* sub: preload external text subtitleswm42013-06-231-1/+37
| | | | | | | | If a subtitle is external, read it completely and add all subtitle events in advance when the subtitle track is selected. This is done for text subtitles only. (Note that subreader.c and subtitles loaded with libass are different and don't have anything to do with this commit.)
* demux: don't require fill_buffer callbackwm42013-06-231-1/+1
|
* Merge branch 'sub_mess'wm42013-06-041-11/+26
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | This branch heavily refactors the subtitle code (both loading and rendering), and adds support for a few new formats through FFmpeg. We don't remove any of the old code yet. There are still some subtleties related to subreader.c to be resolved: code page detection & conversion, timing post-processing, UTF-16 subtitle support, support for the -subfps option. Also, SRT reading and loading ASS via libass should be turned into proper demuxers. (SRT is needed because Libav's is gravely broken, and we want ASS loading via libass to cover full libass format support. Both should be demuxers which are probed _before_ libavformat, so that all subtitles can be loaded through the demuxer infrastructure, and libavformat subtitles don't need to be treated in a special way.)
| * sub: pass subtitle packets directlywm42013-06-031-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Before this, subtitle packets were returned as data ptr/len pairs, and mplayer.c got the rest (pts and duration) directly from the demuxer data structures. Then mplayer.c reassembled the packet data structure again. Pass packets directly instead. The mplayer.c side stays a bit awkward, because the (now by default unused) DVD path keeps getting in the way. In demux.c there's lots of weird stuff (3 functions that read packets, really?), but we want to keep the code equivalent for now to avoid hitting weird issues and corner cases.
| * core: add demux_sub pseudo demuxerwm42013-06-011-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Subtitle files are opened in mplayer.c, not using the demuxer infrastructure in general. Pretend that this is not the case (outside of the loading code) by opening a pseudo demuxer that does nothing. One advantage is that the initialization code is now the same, and there's no confusion about what the difference between track->stream, track->sh_sub and mpctx->sh_sub is supposed to be. This is a bit stupid, and it would be much better if there were proper subtitle demuxers (there are many in recent FFmpeg, but not Libav). So for now this is just a transition to a more proper architecture. Look at demux_sub like an artifical limb: it's ugly, but don't hate it - it helps you to get on with your life.
* | demux: fix "-demuxer mpegps", don't force demuxer in stream_dvdwm42013-06-021-1/+1
|/ | | | | | | | | | Internally, stream_dvd.c returned DEMUXER_TYPE_MPEG_PS, and the same value was hardcoded to enforced usage of demux_lavf in demux.c. But "-demuxer mpegps" basically did the same, so that switch was broken for this format. Undo this and don't request a demuxer in stream_dvd.c. demux_lavf.c is (probably) good enough to probe correctly with DVD. Otherwise, we'd actually have to do something completely different to force the libavformat demuxer.
* core: avoid deselecting and reselecting stream needlesslywm42013-05-291-0/+4
| | | | | | | | | The core deselected all streams on initialization, and then selected the streams it actually wanted. This was no problem for demux_mkv/demux_lavf, but old demuxers (like demux_asf) could lose some packets. The problem is that these demuxers can buffer some data on initialization, which then is flushed on track switching. Fix this by explicitly avoiding deselecting a wanted stream.
* demux_asf: fix after commit 5165e19wm42013-05-291-2/+1
| | | | | This demuxer reallocated packets on its own, instead of using the demux.c functions, which clashed with a recent change.
* demux_lavf: workaround minor ffmpeg memory leakwm42013-05-211-4/+0
| | | | | | | | | | | | The sequence of avcodec_alloc_context3() / avcodec_copy_context() / avcodec_close() / av_free() leaks some memory. So don't copy the context and use it directly. Originally avcodec_copy_context() was used to guarantee that libavformat can't update the fields of the context during demuxing in order to make things a little more robust, but it's not strictly needed, and ffmpeg/ffplay don't do this anyway. Still might make the situation worse should we move demuxing into a separate thread, though.
* demux: workaround for -demuxer mpegts -correct-ptswm42013-05-211-8/+15
| | | | | | | | | | | | | | | | | | | | | | Using -demuxer mpegts -correct-pts triggered the assertion in ds_get_packet2(). This is not surprising, because the correct-pts code was changed to accept _complete_ packets, while all the old demuxers (including the mpegts demuxer) require you to use "partial" packet reads, together with the video_read_frame(). (That function actually parses video frames, so fragments of the original "packets" can be fed to the decoder.) However, it returns out demux_ts packet's are mostly useable. demux_ts still adds an offset (i.e. ds->buffer_pos != 0) to the packets when calling internal parser functions, such as in parse_es.c. While this is unclean design due to mplayer's old video demuxing/decoding path, it can be easily be made work by modifying the packet as returned by ds_get_packet2(). We also have to change the packet freeing code, as demux_packet->buffer doesn't have to point to the start of the memory allocation anymore. MPlayer handles this "correctly" because it doesn't have a function that reads a complete packet.
* demux: restructure chapter seeking codewm42013-05-091-8/+8
| | | | | | Arrange the code such that commenting the first if will allow doing stream chapter seeks instead of time chapter seeks again, if both are possible.
* demux: don't name unknown chapters "unknown"wm42013-05-061-2/+1
| | | | The frontend's fallback for missing chapter names is better.
* stream: report chapter times, use time seeks for DVD chapterswm42013-05-061-0/+17
| | | | | |