summaryrefslogtreecommitdiffstats
path: root/audio/decode/ad_lavc.c
Commit message (Collapse)AuthorAgeFilesLines
* audio: fix playback of Musepack SV8 fileswm42013-09-011-2/+4
| | | | | | | | | | | | | | This is basically a libavcodec API oddity: it can happen that avcodec_decode_audio4() returns 0 (meaning 0 bytes were consumed). It requires you to feed the complete packet again to decode the full packet, and to successfully decode the following packets. We ignored this case with the argument that there's the danger of an endless decode loop (because nothing of that packet is apparently decoded, so it would retry forever), but change it in order to decode mpc8 files correctly. Also add some comments to explain the mess.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-5/+5
| | | | Followup commit. Fixes all the files references.
* audio/decode: remove macro crapwm42013-07-221-3/+14
| | | | | Declare decoders directly, instead of using the LIBAD_EXTERN macro. This is simpler (no weird magic) and more extensible.
* demux_mkv: never force output sample ratewm42013-07-161-12/+5
| | | | | | | | | | | | | | Matroska has an output sample rate (OutputSamplingFrequency), which in theory should be forced instead of whatever the decoder outputs. But it appears no software (other than mplayer2 and mpv until now) actually respects this. Even worse, there were broken files around, which played correctly with (in theory) broken software, but not mplayer2/mpv. Hacks were added to our code to play these files correctly, but they didn't catch all cases. Simplify this by doing what everyone else does, and always use the decoder's sample rate instead. In particular, we try to handle all sample rate issues like libavformat's Matroska demuxer does.
* ad_lavc: re-unsimplify, fix libavcodec API usagewm42013-07-111-2/+19
| | | | | | | | | | | | | | | | | | | | | | It turns out that some code that was removed earlier was still needed. avcodec_decode_audio4() can decode packets "partially". In that case, you have to "slice" the packet and call the decode function again. Codecs which need this are obscure and in low numbers. One sample that needs it is here: rsync://fate-suite.ffmpeg.org/fate-suite/lossless-audio/luckynight-partial.shn (This one decodes in rather small increments.) The new code is much simpler than what has been removed earlier, though. The fact that we own the packet returned by the demuxer helps a lot. Not sure what should happen if avcodec_decode_audio4() returns 0. Currently, we throw away the packet in this case. We don't want to be stuck in an endless loop (could happen if the decoder produces no output either).
* demux: remove facility for partial packet readswm42013-07-111-2/+5
| | | | | | | | | | | | | | | | | | 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.
* ad_lavc: simplifywm42013-07-101-30/+5
| | | | | | | | | We don't need to deal with partial packet reads, manually using an audio parser, or having to call the libavcodec decoder multiple times per packet. Actually, I'm not sure about the last point. ffplay still does this, but the ffmpeg demuxing.c example doesn't.
* demux: remove audio parserwm42013-07-081-8/+3
| | | | | | | | | | | 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.
* core: add common function to initialize AVPacketwm42013-06-031-5/+2
| | | | | | | | | | Audio and video had their own (very similar) functions to initialize an AVPacket (ffmpeg's packet struct) from a demux_packet (mplayer's packet struct). Add a common function for these. Also use this function for sd_lavc_conv. This is actually a functional change, as some libavfilter subtitle demuxers add weird out-of-band stuff as side-data.
* Merge branch 'audio_changes'wm42013-05-121-32/+53
|\ | | | | | | | | Conflicts: audio/out/ao_lavc.c
| * ad_lavc: force channel layout pass-through with demux_rawaudiowm42013-05-121-2/+11
| | | | | | | | | | | | | | | | Using demux_rawaudio and the --rawaudio-channels option is useful for testing channel map stuff. The libavcodec PCM decoder normalizes the channel map to ffmpeg order, though. Prevent this by forcing the original channel map when using the mp-pcm pseudo decoder entry (used by demux_rawaudio and stream/tv.c only).
| * core: use channel map on demuxer level toowm42013-05-121-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This helps passing the channel layout correctly from decoder to audio filter chain. (Because that part "reuses" the demuxer level codec parameters, which is very disgusting.) Note that ffmpeg stuff already passed the channel layout via mp_copy_lav_codec_headers(). So other than easier dealing with the demuxer/decoder parameters mess, there's no real advantage to doing this. Make the --channels option accept a channel map. Since simple numbers map to standard layouts with the given number of channels, this is downwards compatible. Likewise for demux_rawaudio.
| * reorder_ch: remove old channel reorder functionswm42013-05-121-7/+0
| | | | | | | | | | | | | | This is done in af_lavrresample now, and as part of format negotiation. Also remove the remaining reorder_channel calls. They were redundant and did nothing.
| * options: add option to prevent decoder audio downmixingwm42013-04-131-3/+24
| | | | | | | | Also rename --a52drc to --ad-lavc-ac3drc, and add --ad-lavc-o.
| * ad_lavc: use fmt-conversion to map sample formatsStefano Pigozzi2013-04-131-18/+6
| |
* | audio/decode: remove vararg from ad_control()wm42013-04-121-1/+1
|/ | | | | This was unused and dumb. Ancient MPlayer used varargs instead of void* arguments for control() functions, and this was the last leftover.
* Prefix CODEC_ID_ with AV_wm42013-03-131-1/+1
| | | | | | | | | The old names have been deprecated a while ago, but were needed for supporting older ffmpeg/libav versions. The deprecated identifiers have been removed from recent Libav and FFmpeg git. This change breaks compatibility with Libav 0.8.x and equivalent FFmpeg releases.
* demux_lavf, ad_lavc, vd_lavc: pass codec header data directlywm42013-02-101-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Instead of putting codec header data into WAVEFORMATEX and BITMAPINFOHEADER, pass it directly via AVCodecContext. To do this, we add mp_copy_lav_codec_headers(), which copies the codec header data from one AVCodecContext to another (originally, the plan was to use avcodec_copy_context() for this, but it looks like this would turn decoder initialization into an even worse mess). Get rid of the silly CodecID <-> codec_tag mapping. This was originally needed for codecs.conf: codec tags were used to identify codecs, but libavformat didn't always return useful codec tags (different file formats can have different, overlapping tag numbers). Since we don't go through WAVEFORMATEX etc. and pass all header data directly via AVCodecContext, we can be absolutely sure that the codec tag mapping is not needed anymore. Note that this also destroys the "standard" MPlayer method of exporting codec header data. WAVEFORMATEX and BITMAPINFOHEADER made sure that other non-libavcodec decoders could be initialized. However, all these decoders have been removed, so this is just cruft full of old hacks that are not needed anymore. There's still ad_spdif and ad_mpg123, bu neither of these need codec header data. Should we ever add non-libavcodec decoders, better data structures without the past hacks could be added to export the headers.
* demux_lavf, ad_lavc, vd_lavc: refactor, cleanupwm42013-02-101-24/+18
| | | | | | | | | Rearrange some code to make it easier readable. Remove some dead code, and stop printing AVI headers in demux_lavf. (These are not actual AVI headers, just for internal use.) There should be no functional changes, other than reducing output in verbose mode.
* core: redo how codecs are mapped, remove codecs.confwm42013-02-101-44/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use codec names instead of FourCCs to identify codecs. Rewrite how codecs are selected and initialized. Now each decoder exports a list of decoders (and the codec it supports) via add_decoders(). The order matters, and the first decoder for a given decoder is preferred over the other decoders. E.g. all ad_mpg123 decoders are preferred over ad_lavc, because it comes first in the mpcodecs_ad_drivers array. Likewise, decoders within ad_lavc that are enumerated first by libavcodec (using av_codec_next()) are preferred. (This is actually critical to select h264 software decoding by default instead of vdpau. libavcodec and ffmpeg/avconv use the same method to select decoders by default, so we hope this is sane.) The codec names follow libavcodec's codec names as defined by AVCodecDescriptor.name (see libavcodec/codec_desc.c). Some decoders have names different from the canonical codec name. The AVCodecDescriptor API is relatively new, so we need a compatibility layer for older libavcodec versions for codec names that are referenced internally, and which are different from the decoder name. (Add a configure check for that, because checking versions is getting way too messy.) demux/codec_tags.c is generated from the former codecs.conf (minus "special" decoders like vdpau, and excluding the mappings that are the same as the mappings libavformat's exported RIFF tables). It contains all the mappings from FourCCs to codec name. This is needed for demux_mkv, demux_mpg, demux_avi and demux_asf. demux_lavf will set the codec as determined by libavformat, while the other demuxers have to do this on their own, using the mp_set_audio/video_codec_from_tag() functions. Note that the sh_audio/video->format members don't uniquely identify the codec anymore, and sh->codec takes over this role. Replace the --ac/--vc/--afm/--vfm with new --vd/--ad options, which provide cover the functionality of the removed switched. Note: there's no CODECS_FLAG_FLIP flag anymore. This means some obscure container/video combinations (e.g. the sample Film_200_zygo_pro.mov) are played flipped. ffplay/avplay doesn't handle this properly either, so we don't care and blame ffmeg/libav instead.
* audio: make de-planarization fasterwm42012-12-281-13/+4
| | | | | | Uses the same trick as the planarization code to turn per-sample memcpy calls into mov instructions. Makes decoding a ~25min 48000Hz 2ch floatle audio file faster from 3.8s to 2.7s.
* audio/decode: remove ad_pcm and use ad_lavc for PCMwm42012-12-111-4/+95
| | | | | | | | | | | | | | | Since libavcodec doesn't have a "generic" PCM decoder, we have to go out of out way to make it look like ad_lavc provides one: make it provide a pseudo "pcm" decoder, which maps some format tags manually to the individual libavcodec PCM decoders. Format tags which uniquely map to one libavcodec could be mapped via codecs.conf. Since defining these in tag_map[] is much shorter (one line vs. a full codec entry in codecs.conf), and since we need tag_map[] anyway, we don't use codecs.conf for these. ad_pcm is evil because it still does partial packet reads (with demux_read_data()), and it's redundant to libavcodec anyway.
* Fix potential bugs and issues, general cleanupsreimar2012-11-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of these are reimar fixing issues found by Coverity static analyzer, and possibly some more cleanup commits independent from this. Since these commits are rather noisy, squash them all together. Try to make code a bit clearer. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35294 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: audio/out/ao_alsa.c Check the correct variable for NULL. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35323 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove pointless unreachable code (the loop condition already checks the 0xff case). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35325 b3059339-0415-0410-9bf9-f77b7e298cf2 Fix typo that might have caused reading beyond the string end. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35326 b3059339-0415-0410-9bf9-f77b7e298cf2 Do not needlessly use "long" types. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35331 b3059339-0415-0410-9bf9-f77b7e298cf2 Use AV_RB32 to avoid sign extension issues and validate offset before using it. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35332 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove nonsense casts. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35343 b3059339-0415-0410-9bf9-f77b7e298cf2 Fix crash in case sh_audio allocation failed. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35348 b3059339-0415-0410-9bf9-f77b7e298cf2 Fix potential NULL dereference. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35351 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: libmpcodecs/ad_ffmpeg.c Note: Slightly modified. Fix malloc failure check to check the correct variable. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35353 b3059339-0415-0410-9bf9-f77b7e298cf2 Avoid code duplication and pointless casts. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35363 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: stream/tv.c Error out if an invalid channel list name was specified instead of continuing and reading outside array bounds all over the place. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35364 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: stream/tv.c Make array "static const". git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35365 b3059339-0415-0410-9bf9-f77b7e298cf2 Properly free resources even when encountering many parse errors. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35367 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: parser-cfg.c Avoid leaks in error handling. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35380 b3059339-0415-0410-9bf9-f77b7e298cf2 Do not do sign comparisons on "char" type which can be both signed or unsigned. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35381 b3059339-0415-0410-9bf9-f77b7e298cf2 Free cookies file data after parsing it. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35382 b3059339-0415-0410-9bf9-f77b7e298cf2 http_set_field only makes a copy of the string, so we still need to free it. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35383 b3059339-0415-0410-9bf9-f77b7e298cf2 check4proxies does not modify input URL, so mark it const. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35390 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove proxy "support" from stream_rtp and stream_upd, trying to use a http proxy for UDP connections makes no sense. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35394 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: stream/stream_rtp.c stream/stream_udp.c Add url_new_with_proxy function to reduce code duplication and memleaks. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35395 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: stream/pnm.c stream/stream_live555.c stream/stream_nemesi.c stream/stream_rtsp.c Fix off-by-one errors in file descriptor validity checks. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35402 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove pointless cast. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35403 b3059339-0415-0410-9bf9-f77b7e298cf2 Abort when opening the file failed instead of calling "write" with an invalid descriptor. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35404 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove pointless local variable. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35411 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: stream/http.c
* Add missing compat/libav.h includeswm42012-11-121-0/+1
| | | | For avcodec_free_frame().
* Rename directories, move files (step 2 of 2)wm42012-11-121-4/+4
| | | | | | | | | | | | Finish renaming directories and moving files. Adjust all include statements to make the previous commit compile. The two commits are separate, because git is bad at tracking renames and content changes at the same time. Also take this as an opportunity to remove the separation between "common" and "mplayer" sources in the Makefile. ("common" used to be shared between mplayer and mencoder.)
* Rename directories, move files (step 1 of 2) (does not compile)wm42012-11-121-0/+413
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.