summaryrefslogtreecommitdiffstats
path: root/libmpdemux/demux_lavf.c
Commit message (Collapse)AuthorAgeFilesLines
* Rename directories, move files (step 1 of 2) (does not compile)wm42012-11-121-1092/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tis drops the silly lib prefixes, and attempts to organize the tree in a more logical way. Make the top-level directory less cluttered as well. Renames the following directories: libaf -> audio/filter libao2 -> audio/out libvo -> video/out libmpdemux -> demux Split libmpcodecs: vf* -> video/filter vd*, dec_video.* -> video/decode mp_image*, img_format*, ... -> video/ ad*, dec_audio.* -> audio/decode libaf/format.* is moved to audio/ - this is similar to how mp_image.* is located in video/. Move most top-level .c/.h files to core. (talloc.c/.h is left on top- level, because it's external.) Park some of the more annoying files in compat/. Some of these are relicts from the time mplayer used ffmpeg internals. sub/ is not split, because it's too much of a mess (subtitle code is mixed with OSD display and rendering). Maybe the organization of core is not ideal: it mixes playback core (like mplayer.c) and utility helpers (like bstr.c/h). Should the need arise, the playback core will be moved somewhere else, while core contains all helper and common code.
* make compile with recent libavStefano Pigozzi2012-11-031-0/+1
|
* demux_lavf, ad_ffmpeg: don't change AVCodecContext.block_alignwm42012-10-301-1/+1
| | | | | | | | | | | If block_align was 0, demux_lavf changed it to 1. This breaks at least decoding of IMA ADPCM in LVF. Pass it through without changing instead. (nBlockAlign as set in demux_lavf is put back into lavc's block_align in ad_ffmpeg.) This reverts 296f360f82e5. This commit gives no explanation why it does things the way it does. But since nothing in mpv uses nBlockAlign anymore except ad_ffmpeg, this is probably safe.
* demux_lavf: add a hack to work around other hackswm42012-10-301-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | mplayer (and all forks) use a single FourCC field to map codecs. This is what sh_video->format and sh_audio->format is used for. Basically it's a key into the codecs.conf table to find out what decoder to use. (There's only one video codec and one major audio codec left - both libavcodec. But we still have to deal with mapping coming from non-libavformat demuxers.) It seems this causes some video codecs to fail, such as WV1F in AVI [1]. demux_lavf generally throws away the codec_tag from libavformat if the codec is MPEG-in-AVI. There are probably other cases like this. Add a hack to enforce passing the correct codec tag when only ffmpeg demuxers and decoders involved. Note: the sample [1] needs to be flipped. With --demuxer=avi, this is done correctly, because unlike demux_lavf, the demuxer uses the FourCC directly for the sh_video->format tag, and finds the correct codecs.conf entry (which contains the flip flag). We could just add a "whitelist" of codec tags which can be passed through to sh_video->format, but I don't want to do that just for such an obscure format as the sample at hand. Note 2: when demux_lavf is used, the AVCodecContext could be passed directly to vd_ffmpeg/ad_ffmpeg. The code to convert to/from the internal mplayer stream headers is probably still needed, as there are non-ffmpeg demuxers and audio decoders. [1] http://samples.mplayerhq.hu/V-codecs/WV1F/AVI/title2.avi
* demux_lavf: support SRT subtitlesreimar2012-10-301-2/+2
| | | | | | | | | | | Support subrip format subtitles. Patch by Philip Langdale [philipl overt org]. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35118 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: libmpdemux/demux_lavf.c
* demux_lavf: do not special case ID_TEXT subs on program switchingreimar2012-10-301-1/+1
| | | | | | | | | | | | | | When switching programs select subtitle stream regardless of whether the format is text, ASS, bitmap or whatever. There probably was some good reason for the condition but it got lost in time and special-casing CODEC_ID_TEXT over other test-based subtitles doesn't seem to make much sense. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35117 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: libmpdemux/demux_lavf.c
* stream_ffmpeg: handle rtsp:// URLs by default, add lavf://Uoti Urpala2012-10-281-5/+8
| | | | | | | | | | | Make stream_ffmpeg handle rtsp:// URLs by default, without requiring ffmpeg://rtsp://. Previously (after removal of other rtsp implementations) rtsp:// fell back to using HTTP, which was unlikely to work. Also add lavf:// as an alternative to ffmpeg:// to force the stream implementation. Since libavformat can come from Libav rather than FFmpeg, using the ffmpeg name in the prefix is misleading.
* demuxer: do not set sub_utf8 optionwm42012-09-181-2/+0
| | | | | | | | demux_lavf and demux_mkv, which both support demuxing subtitles, set the global variable sub_utf8. This variable is connected with the -utf8 option, and should not be reset by code. Since demuxer subtitles are not influenced by this option (anymore?), this is unnecessary. Remove the code setting this variable from the demuxers.
* core: fix DVD subtitle selectionwm42012-09-181-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add all subtitle tracks as reported by libdvdread at playback start. Display language for subtitle and audio tracks. This commit restores these features to the state when demux_mpg was default for DVD playback, and makes them work with demux_lavf and the recent changes to subtitle selection in the frontend. demux_mpg, which was the default demuxer for DVD playback, reordered the subtitle streams according to the "logical" subtitle track number, which conforms to the track layout reported by libdvdread, and is what stream_dvd expects for the STREAM_CTRL_GET_LANG call. demux_lavf, on the other hand, adds the streams in the order it encounters them in the MPEG stream. It seems this order is essentially random, and can't be mapped easily to what stream_dvd expects. Solve this by making demux_lavf hand out the MPEG stream IDs (using the demuxer_id field). The MPEG IDs are mapped by mplayer.c by special casing DVD playback (map_id_from/to_demuxer() functions). This mapping is essentially the same what demux_mpg did. Making demux_lavf reorder the streams is out of the question, because its stream handling is already messy enough. (Note that demux_lavf doesn't export stream IDs for other formats, because most time libavformat demuxers do not set AVStream.id, and we don't know which demuxers do. But we know that MPEG is safe.) Another major complication is that subtitle tracks are added lazily, as soon as the demuxer encounters the first subtitle packet for a given subtitle stream. Add the streams in advance. If a yet non-existent stream is selected, demux_lavf must be made to auto-select that subtitle stream as soon as it is added. Otherwise, the first subtitle packet would be lost. This is done by DEMUXER_CTRL_PRESELECT_SUBTITLE. demux_mpg didn't need this: the frontend code could just set ds->id to the desired stream number. But demux_lavf's stream IDs don't map directly to the stream number as used by libdvdread, which is why this hack is needed.
* core: manage tracks in the frontendwm42012-09-181-3/+0
| | | | | | | | | | | | | | | Introduce a general track struct for every audio/video/subtitle track known to the frontend. External files (subtitles) are now represented as tracks too. This mainly serves to clean up the subtitle selection code: now every subtitle is simply a track, instead of using a messy numbering that goes by subtitle type (as it was stored in the global_sub_pos field). The mplayer fontend will list external subtitle files as additional tracks. The timeline code now tries to match the exact demuxer IDs of all tracks. This may cause problems when Matroska files with different track numberings are used with EDL timelines. Change demux_lavf not to set demuxer IDs, since most time they are not set.
* demux_lavf: assume audio codec_tag 0 means unsetUoti Urpala2012-08-161-0/+2
| | | | | | | | | | | Libavformat does not distinguish between "no codec_tag given" and "codec_tag given, value is 0". 0 can be a valid value. Change demux_lavf to assume that 0 always means unset for audio. This prevents incorrect selection of the PCM decoder, which includes "format 0x0" in its codecs.conf entry. The video case accepts 0 iff codec_id is RAWVIDEO, but there's no obvious similar check possible for audio. Thus this could possibly cause issues if a file really uses 0 to mean uncompressed audio.
* demuxer: introduce a general stream structwm42012-08-031-8/+8
| | | | | | | | | | | | | | | | There are different C types for each stream type: sh_video for video, sh_audio for audio, sh_sub for sub. There is no type that handles all stream types in a generic way. Instead, there's a macro SH_COMMON, that is used to define common fields for all 3 stream structs. Accessing the common fields is hard if you want to be independent from the stream type. Introduce an actual generic stream struct (struct sh_stream), which is supposed to unify all 3 stream types one day. Once all fields defined by SH_COMMON have been moved into sh_stream, the transition is complete. Move some fields into sh_stream, and rewrite osd_show_tracks to use them.
* mplayer: let frontend print stream info, instead of demuxerswm42012-07-301-6/+13
| | | | | | | | | | | | | | | | | | When playing a file, users (i.e. me) expect mplayer to print a list of video/audio/subtitle streams. Currently, this is done in each demuxer separately. This also means the output is formatted differently depending which demuxer is active. Add code to print an uniformly formatted streams list in the player front end. Extend the streams headers to export additional information about the streams. Change the lavf and mkv demuxers to follow this new scheme, and raise the log level for the "old" printing functions. The intention is to make every demuxer behave like this eventually. The stream list output attempts to provide codec information. It's a bit hacky and doesn't always provide useful output, and I'm not sure how to do it better.
* bstr: rename bstr() function to bstr0(), and typedef bstr to struct bstrwm42012-07-281-3/+3
| | | | | Replace all uses of bstr() with bstr0(). Also remove the ridiculous C++ workaround.
* demux_lavf: use lavf for RealMedia (.rm) files by defaultUoti Urpala2012-07-261-2/+0
| | | | | | | | | | | | | | RealMedia was listed as a format for which the internal demuxer (demux_real) was preferred over lavf. The original reason for this (lavf failing to give any timing information for some video frames) has been fixed in libavformat since. Make demux_lavf the preferred demuxer for RealMedia. The libavformat demuxer does still have issues. COOK audio initially misbehaves after a seek (inconsistent timestamps, audio remaining from the before-seek position). However, the internal demuxer seemed to be _consistently_ out of sync with a test file. I haven't done thorough testing, but the internal demuxer does not seem less buggy.
* demux, vd_ffmpeg: fix demux keyframe flag, set AV_PKT_FLAG_KEYUoti Urpala2012-07-251-1/+1
| | | | | | | | | | | | | | | | | | There was some confusion about the "flags" field in demuxer packets. Demuxers set it to either 1 or 0x10 to indicate a keyframe (and the field was not used to indicate anything else). This didn't cause visible problems because nothing read the value. Replace the "flags" field with a boolean "keyframe" field. Set AV_PKT_FLAG_KEY based on this field in packets fed to libavcodec video decoders (looks like PNG and ZeroCodec are the only ones which depend on values from demuxer; previously this was hardcoded to true for PNG). Make demux_mf set the keyframe field in every packet. This matters for PNG files now that the demuxer flag is forwarded to libavcodec. Fix logic setting the field in demux_mkv. It had probably not been updated when adding SimpleBlock support. This probably makes no difference for any current practical use.
* video, audio: use lavc decoders without codecs.conf entriesUoti Urpala2012-07-241-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for using libavcodec decoders that do not have entries in codecs.conf. This is currently only used with demux_lavf, and the codec selection is based on codec_id returned by libavformat. Also modify codec-related terminal output somewhat to make it use information from libavcodec and avoid excessively long default output. The new any-lavc-codec support is implemented with codecs.conf entries that invoke vd_ffmpeg/ad_ffmpeg without directly specifying any libavcodec codec name. In this mode, the decoders now instead select the libavcodec codec based on codec_id previously set by demux_lavf (if any). These new "generic" codecs.conf entries specify "status buggy", so that they're tried after any specific entries with higher-priority status. Add new directive "anyinput" to codecs.conf syntax. This means the entry will always match regardless of fourcc. This is used for the above new codecs.conf entries (so the driver always gets to decide whether to accept the input, and will fail init() if it can't find a suitable codec in libavcodec). Remove parsing support for the obsolete codecs.conf directive "cpuflags". This directive has not had any effect and has not been used in default codecs.conf since many years ago. Shorten codec-related terminal output. When using libavcodec decoders, show the libavcodec long_name field rather than codecs.conf "info" field as the name of the codec. Stop showing the codecs.conf entry name and "vfm/afm" name by default, as these are rarely needed; they're now in verbose output only. Show "VIDEO:" line at VO initialization rather than at demuxer open. This didn't really belong in demuxer code; the new location may show more accurate values (known after decoder has been opened) and works right if video track is changed after initial demuxer open. The vd.c changes (primarily done for terminal output changes) remove round-to-even behavior from code setting dimensions based on aspect ratio. I hope nothing depended on this; at least the even values were not consistently guaranteed anyway, as the rounding code did not run if the video file did not specify a nonzero aspect value.
* demux_lavf: try harder to make up a frame rateUoti Urpala2012-04-141-2/+16
| | | | | | | | | | | | Frame rate information is mostly irrelevant for playback, but it's needed at least to convert frame numbers used in some subtitle formats (like MicroDVD) into timestamps. Libavformat stopped making up a frame rate if no "reliable" information is available (commit 7929e22bd "lavf: don't guess r_frame_rate from either stream or codec timebase", 1.5 months ago). This caused a regression with AVI files and MicroDVD subtitles. Add a heuristic similar to what libavformat used to have, to make up FPS values which should work at least for the AVI+MicroDVD use case.
* cosmetics: misc minor cleanupsUoti Urpala2012-03-251-1/+1
| | | | | The deleted ZRM* things were only relevant to vo_zr, which was deleted earlier.
* demux_lavf: update growing file size info for AVSEEK_SIZEUoti Urpala2012-02-261-2/+5
| | | | | | | | demux_lavf was returning a static size value when libavformat queried file size with AVSEEK_SIZE. Add code to query the stream for possibly changed value first. This at least improves seeking with growing MPEG files; before seeks would never go beyond the part of the file that existed when the stream was first opened.
* demux_lavf: use Libav RIFF tag lists directlyUoti Urpala2012-02-011-6/+3
| | | | | | Change demux_lavf to use CodecID -> RIFF tag mappings that are now available through the public Libav API. Previously it used a copy in ffmpeg_files/taglists.c. That can now be deleted.
* Update Libav API usesUoti Urpala2012-02-011-17/+14
| | | | | | | | | | | | | | | | | | | Change various code to use the latest Libav API. The libavcodec error_recognition setting has been removed and replaced with different semantics. I removed the "--lavdopts=er=<value>" option accordingly, as I don't think it's widely enough used to be worth attempting to emulate the old option semantics using the new API. A new option with the new semantics can be added later if needed. Libav dropped APIs that were necessary with all Libav versions until quite recently (like setting avctx->age), and it would thus not be possible to keep compatibility with previous Libav versions without adding workarounds. The new APIs also had some bugs/limitations in the recent Libav release 0.8, and it would not work fully (at least some avcodec options would not be set correctly). Because of those issues, this commit makes no attempt to maintain compatibility with anything but the latest Libav git head. Hopefully the required fixes and improvements will be included in a following Libav point release.
* Libav API updates (remove most deprecated-in-0.7 uses)Uoti Urpala2011-12-221-23/+19
| | | | | | | | Update various code using Libav libraries to remove use of API features that were deprecated at Libav release 0.7. I think this removes them all with the exception of URLContext functions still used in stream_ffmpeg.c (at least other uses that generated deprecation warnings with libraries from 0.7 are removed).
* configure, build: require at least Libav 0.7Uoti Urpala2011-12-221-22/+0
| | | | | | | | | | | | | | | | Require versions of the Libav libraries corresponding to Libav release 0.7. These are: libavutil 51.7.0 libavcodec 53.5.0 libavformat 53.2.0 libswscale 2.0.0 libpostproc 52.0.0 Also disable the fallback to simple header check if these libraries could not be found with pkg-config; now compiling without pkg-config support for these always requires explicitly setting --enable-libav and any needed compiler/linker flags. The simple check would have let compilation proceed even if a version mismatch was detected.
* demux_lavf: set rawvideo codec_tag based on pix_fmtUoti Urpala2011-10-181-0/+2
| | | | | | | | | | | | Libav stopped automatically filling missing codec_tag field for raw codecs based on pix_fmt in libav commit bb416bd68c ("lavf: do not set codec_tag for rawvideo"). This broke demux_lavf for raw video in formats like YUV4MPEG, as the video format was not exported from demux_lavf in any form (the information only existed in the pix_fmt field of the struct AVCodecContext from libavformat, and that is not exported). Add an explicit call to avcodec_pix_fmt_to_codec_tag() to set the codec tag again so that selecting the correct raw decoder based on the tag works.
* demux_lavf: Adding av_dup_packet() missing from recent 6e8d420a41Uoti Urpala2011-08-211-0/+5
| | | | | | | | | Commit 6e8d420a41 ("demux: avoid a copy of demux packets with lavf, reduce padding") was missing an av_dup_packet() line. As a result at least formats that use parsing on the lavf side could fail (with parsing the packet may contain pointers to temporary fields that will be overwritten/freed when reading further packets, and av_dup_packet() is required to allocate permanent storage).
* demux: avoid a copy of demux packets with lavf, reduce paddingUoti Urpala2011-08-191-23/+20
| | | | | | | | | | | | | When demux_lavf read a new packet it used to copy the data from libavformat's struct AVPacket to struct demux_packet and then free the lavf packet. Change it to instead keep the AVPacket allocated and point demux_packet fields to the buffer in that. Also change MP_INPUT_BUFFER_PADDING_SIZE to 8 which matches FF_INPUT_BUFFER_PADDING SIZE; demux_lavf packets won't have more padding now anyway (it was increased from 8 earlier when FF_INPUT_BUFFER_PADDING_SIZE was increased in libavcodec, but that change was reverted).
* demux_lavf: don't interpret MPEG codec tags as generic tagsUoti Urpala2011-08-101-3/+8
| | | | | | | | Don't interpret native MPEG codec tags using our generic format-agnostic codec tag tables. MPEG may use tag 3 for MP3, whereas the generic tables map 3 to uncompressed PCM. Make the code ignore the codec_tag field for the "mpeg" and "mpegts" libavformat demuxers and rely on the codec_id value provided by lavf only.
* bstr: rename BSTR() -> bstr()Uoti Urpala2011-07-271-3/+3
| | | | | | Rename the BSTR() function to bstr(). The former caused a conflict with some Windows OS name, and it's no longer a macro so uppercase naming is less appropriate.
* cleanup: do libav* initialization on startupUoti Urpala2011-07-181-2/+0
| | | | | | | Do the global initialization of libavcodec and libavformat (avcodec_register_all(), av_register_all()) immediately on program startup and remove the initialization calls from various individual modules that use libavcodec/libavformat functionality.
* cleanup: silence most of the clang warningsClément Bœsch2011-07-091-1/+1
|
* Merge branch 'mplayer1_changes'Uoti Urpala2011-07-061-7/+9
|\
| * demux_lavf: Do not set AVIOContext for AVFMT_NOFILE formatsreimar2011-07-061-5/+7
| | | | | | | | | | | | | | | | Setting AVIOContext for AVFMT_NOFILE formats now triggers a warning from libavformat (and triggered an error for a while), so add a check to avoid setting AVIOContext when not necessary. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33695 b3059339-0415-0410-9bf9-f77b7e298cf2
| * demux_lavf: fix code printing subtitle typereimar2011-07-061-2/+2
| | | | | | | | | | | | | | Fix printing of subtitle type, the wrong index was used to look up the type. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33664 b3059339-0415-0410-9bf9-f77b7e298cf2
* | demux_lavf: add missing #include <libavutil/mathematics.h>Uoti Urpala2011-07-061-0/+1
|/ | | | Not included by avutil.h any more in recent Libav versions.
* OSD: when switching sub/audio tracks show title of new trackUoti Urpala2011-07-031-3/+9
| | | | | | If the played file has per-track titles for audio and subtitles show those on the OSD when switching tracks. This changes the OSD message from 'Audio: (2) eng' to 'Audio: (2) eng ("Director's commentary")'.
* cosmetics: reformat demux_lavf.c, m_option.[ch] and m_property.cUoti Urpala2011-07-031-480/+513
|
* demux: use talloc for sh_* structs and "lang" fieldUoti Urpala2011-07-031-2/+2
|
* Update libav API usesUoti Urpala2011-04-201-11/+14
| | | | | | | | | | | Update various code to use newer alternatives instead of deprecated functions/fields that are being dropped at libav API bump. An exception is avcodec_thread_init() which is being dropped even though it's still _necessary_ with fairly recent libav versions, so there's no good alternative which would work with both those recent versions and latest libavcodec. I think there are grounds to consider the drop premature and revert it for now; if that doesn't happen I'll add a version-test #if check around it later.
* demux_lavf: disable support for byte-based seekingUoti Urpala2011-04-081-0/+4
| | | | | | | | | | | | libavformat returns nonsense per-stream bitrate values for some MPEG files (0 or many times higher than the overall bitrate of the file), which triggered the heuristic to enable byte-based seeking in demux_lavf and then made the byte-based seeks wildly inaccurate. Disable the support for byte-based seeks. This will avoid problems with files that have consistent timestamps, but on the other hand will completely break seeking in MPEG files that have timestamp resets. I'll probably add at least an option to manually enable byte-based seeking later.
* demux_mkv, demux_lavf: don't select initial audio trackUoti Urpala2011-04-021-8/+2
| | | | | | | | | | | | | Remove code that tries to select audio track during demuxer initialization from demux_mkv and demux_lavf. Just leave audio disabled at that point; the higher-level select_audio() function will call the demuxer to switch track later anyway. Removing this unneeded code also fixes use of these demuxers as the main demuxer with -audiofile. Before the automatic track selection would have enabled an audio track (if the file had any); as the main demuxer was not used for audio the unused packets from this enabled track would accumulate until they reached queue size limits.
* demux_lavf: fix initial "-vid"-based video selectionUoti Urpala2011-03-311-1/+2
| | | | | | In 59058b54a73809866476b243d8bee82174fb4de8 (from svn r31129) Aurelien changed demux_lavf -vid indexing, but failed to change the initial video stream selection based on -vid to match. Fix.
* demux_lavf: fix stream switch returned index for no sound/videoUoti Urpala2011-03-311-12/+8
| | | | | | | | If the argument given to demux_lavf audio/video switch code is not one of -2, -1, or valid audio/video ID the code will treat it the same as -2 (switch to no sound / no video). However the returned index was not set to -2 in this case. Fix. Also change the returned index from -1 to -2 when staying at no sound / video.
* Merge branch 'sub'Uoti Urpala2011-01-261-5/+5
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |