summaryrefslogtreecommitdiffstats
path: root/audio/decode
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-065-13/+13
| | | | Followup commit. Fixes all the files references.
* audio/filter: use new option APIwm42013-07-222-14/+5
| | | | | | | | | | | | | Make the VF/VO/AO option parser available to audio filters. No audio filter uses this yet, but it's still a quite intrusive change. In particular, the commands for manipulating filters at runtime completely change. We delete the old code, and use the same infrastructure as for video filters. (This forces complete reinitialization of the filter chain, which hopefully isn't a problem for any use cases. The old code forced reinitialization too, but it could potentially allow a filter to cache things; e.g. consider loaded ladspa plugins and such.)
* audio/decode: remove macro crapwm42013-07-227-115/+61
| | | | | 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).
* mplayer: fix incorrect audio sync after format changeswm42013-07-111-8/+2
| | | | | | | | | | | This is not directly related to the handling of format changes itself, but playing audio normally after the change. This was broken: the output byte rate was not recalculated, so audio-video sync was simply broken. Fix this by calculating the byte rate on the fly, instead of storing it in sh_audio. Format changes are relatively common (switches between stereo and 5.1 in TV recordings), so this fixes a somewhat critical bug.
* ad_spdif: better PTS syncwm42013-07-111-1/+3
| | | | | | | | | | | pts_bytes can't just be changed at the end. It must be offset to the pts value, which is reset with each packet read from the demuxer. Make sure the pts_byte field is always reset after receiving a new PTS, i.e. increment it after actually writing to the output buffer. Flush the AVFormatContext's write buffer, because otherwise the audio PTS will jump around too much: the calculation doesn't use the exact output buffer size if there's still data in the avio buffer.
* demux: remove facility for partial packet readswm42013-07-115-73/+23
| | | | | | | | | | | | | | | | | | 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.
* audio: remove decoder input bufferwm42013-07-102-12/+0
| | | | This was unused.
* demux: remove audio parserwm42013-07-082-26/+5
| | | | | | | | | | | 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-0/+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.
* options: remove --stereowm42013-06-132-14/+1
| | | | | | | Whatever this was supposed to be originally, it doesn't have much value anymore. It just forced ad_mpg123 to upmix mono to stereo by default (the audio chain can do that). As an option, it was mostly useless and misleading, so get rid of it.
* core: make options.c compile standalonewm42013-06-081-0/+2
| | | | | This also removes the split between "mplayer" and "common" opts (common opts used to be shared between mencoder and mplayer).
* 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-126-88/+98
|\ | | | | | | | | Conflicts: audio/out/ao_lavc.c
| * audio: print channel map additionally to channel count on terminalwm42013-05-121-4/+5
| |
| * 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-124-21/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * audio/out: switch to channel mapwm42013-05-122-4/+7
| | | | | | | | | | | | This actually breaks audio for 5/6/8 channels. There's no reordering done yet. The actual reordering will be done inside of af_lavrresample and has to be made part of the format negotiation.
| * audio: add some setters for mp_audio, and require filters to use themwm42013-05-121-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mp_audio has some redundant fields. Setters like mp_audio_set_format() initialize these properly. Also move the mp_audio struct to a the file audio.c. We can remove a mysterious line of code from af.c: in.format |= af_bits2fmt(in.bps * 8); I'm not sure if this was ever actually needed, or if it was some kind of "make it work" quick-fix that works against the way things were supposed to work. All filters etc. now set the format correctly, so if there ever was a need for this code, it's definitely gone.
| * options: add option to prevent decoder audio downmixingwm42013-04-131-3/+24
| | | | | | | | Also rename --a52drc to --ad-lavc-ac3drc, and add --ad-lavc-o.
| * af: streamline format negotiationwm42013-04-131-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Add dummy input and output filters to remove special cases in the format negotiation code (af_fix_format_conversion() etc.). The output of the filter chain is now negotiated in exactly the same way as normal filters. Negotiate setting the sample rate in the same way as other audio parameters. As a side effect, the resampler is inserted at the start of the filter chain instead of the end, but that shouldn't matter much, especially since conversion and channel mixing are conflated into the same filter (due to libavresample's API).
| * options: remove --af-advwm42013-04-131-1/+1
| | | | | | | | | | | | | | Anything this option did has been removed in the preceding 3 commits. Note that even though these options sounded like a good idea (like setting accuracy vs. speed tradeoffs), they were not really properly implemented.
| * audio: remove float processing optionwm42013-04-132-16/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The only thing this option did was changing the behavior of af_volume. The option decided what sample format af_volume would use, but only if the sample format was not already float. If the option was set, it would default to float, otherwise to S16. Remove use of the option and all associated code, and make af_volume always use float (unless a af_volume specific sub-option is set). Silence maximum value tracking. This message is printed when the filter is destroyed, and it's slightly annoying. Was enabled due to enabling float by default.
| * ad_lavc: use fmt-conversion to map sample formatsStefano Pigozzi2013-04-131-18/+6
| |
* | audio/decode: remove vararg from ad_control()wm42013-04-125-5/+5
|/ | | | | 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-132-15/+15
| | | | | | | | | 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.
* Add a --dtshd optionWessel Dankers2013-03-041-13/+22
| | | | | | | | | | The spdif decoder was hardcoded to assume that the spdif output is capable of accepting high (>1.5Mbps) bitrates. While this is true for modern HDMI spdif interfaces, the original coax/toslink system cannot deal with this and will fail to work. This patch adds an option --dtshd which can be enabled if you use a DTS-capable receiver behind a HDMI link.
* 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-108-243/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* dec_audio: uncrustifywm42013-02-092-193/+203
|
* 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_dvdpcm and use ad_lavc for DVD PCMwm42012-12-112-164/+0
| | | | | | | | | | ad_dvdpcm reads MPEG specific headers directly (passed through codecdata by demux_mpg), so you couldn't use ffmpeg's "pcm_dvd" with demux_mpg. Change demux_mpg to set the correct audio parameters directly. The code for this is taken from ad_dvdpcm. ad_dvdpcm is evil because it still does partial packet reads (with demux_read_data()), and it's redundant to libavcodec anyway.
* audio/decode: remove ad_pcm and use ad_lavc for PCMwm42012-12-113-226/+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.
* audio: make AC3 pass-through with ad_spdif workreimar2012-12-031-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not fall back to 0 for samplerate when parser is not initialized. Might fix some issues with using -ac spdifenc with audio in MKV or MP4. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35517 b3059339-0415-0410-9bf9-f77b7e298cf2 Replace outdated list of unsupported formats by list of supported formats. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35534 b3059339-0415-0410-9bf9-f77b7e298cf2 Do not call af_fmt2str on the same data over and over. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35535 b3059339-0415-0410-9bf9-f77b7e298cf2 ad_spdif: use the more specific AF_FORMAT_AC3_LE when we handle AC3. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35536 b3059339-0415-0410-9bf9-f77b7e298cf2 Make AF_FORMAT_IS_IEC61937 include AF_FORMAT_IS_AC3. Our AC3 "sample format" is also iec61937. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35537 b3059339-0415-0410-9bf9-f77b7e298cf2 af_format: support endianness conversion also for iec61937 formats in general, not just AC3. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35538 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: audio/filter/af_format.c af_format: Fix check_format, non-special formats are of course supported. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35545 b3059339-0415-0410-9bf9-f77b7e298cf2 Note: see mplayer bug #2110
* audio: improve decoder open failure handlingUoti Urpala2012-12-031-0/+2
| | | | | | | | | | | | | | | | Reinitialize sh_audio->samplesize and sample_format before falling back to another audio decoder (some decoders rely on default values). Remove code setting these fields from demux_mkv and demux_lavf (no decoder should depend on demuxer-set values for these fields). Conflicts: audio/decode/ad_lavc.c Merged from mplayer2 commit 6b9567. The changes to ad_lavc.c are not merged, as they are very specific to the mplayer2 libavresample hack; we deplanarize manually, so we can't get unsupported sample formats yet (except on raw audio with "pcm_f64le", as we don't support AV_SAMPLE_FMT_DBL in the audio chain).
* core: fix crash when video filter returns inf as PTSwm42012-11-201-1/+1
| | | | | | | | | | | | | | | | | | | When a video filter returned inf as PTS, the player crashed. One reason for this was that decode_audio() was called with a negative minlen parameter, which at some point caused it to call a memory allocation function with a ridiculous value, triggering an out of memory code path in talloc.c. (talloc.c has been modified to abort() on out of memory situations.) Fix this by sanity checking minlen in decode_audio(). (The check against outbuf->len always succeeded, because it's an unsigned comparison.) Make an existing sanity check in mplayer.c more robust: check for NaN too, which happens if the video PTS is inf. This happened with "-vf pullup,softpulldown" (but is not triggered when the following commit is applied).
* Fix potential bugs and issues, general cleanupsreimar2012-11-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |