summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* chmap: fix oddity due to ambiguous 6.1 ffmpeg channel layoutwm42013-05-131-2/+3
| | | | | | | | FFmpeg (as well as Libav) have two layouts called "6.1": AV_CH_LAYOUT_6POINT1 and AV_CH_LAYOUT_6POINT1_BACK. We call them "6.1" and "6.1(back)". Change the default layout for 7 channels as well to return the same layout as av_get_default_channel_layout(). (Looks a bit questionable, but for now it's better to follow FFmpeg.)
* audio: fix ALSA 4 channel surround outputwm42013-05-132-2/+4
| | | | | | | | | It turns out that ALSA's 4 channel layout is different from mpv's and ffmpeg's 4.0 layout. Thus trying to do 4 channel output led to incorrect remixing via lib{av,sw}resample. Fix the default layouts for the internal filter chain as well, although I'm not sure if it matters at all.
* af_lavrresample: fix inverted conditionwm42013-05-131-1/+1
| | | | | This was added with the previous commit. It likely broke some obscure special-cases, which (hopefully) do not happen with normal playback.
* audio: fix compilation with older libavresample versionswm42013-05-133-1/+68
| | | | | | | | | | | | | | The libavresample version of the current Libav stable release lacks the avresample_set_channel_mapping() function. (FFmpeg's libswresample seems to be fine, because they added swr_set_channel_mapping() first.) Add a cheap/slow workaround to do channel reordering on our own. We don't use the recently removed MPlayer code (see commit 586b75a), because that is not generic enough. The functionality should be the same as with full-featured libavresample, and any differences are bugs. It's probably slower, though.
* ao_coreaudio: fix switched parameterswm42013-05-121-1/+1
|
* Merge branch 'audio_changes'wm42013-05-1262-3498/+3143
|\ | | | | | | | | Conflicts: audio/out/ao_lavc.c
| * af: improve filter chain setup retry limitwm42013-05-121-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | af_reinit() is responsible for inserting automatic conversion filters for channel remixing, format conversion, and resampling. We don't require that a single filter can do all these (even though af_lavrresample does nearly all of this, sometimes af_format has to be used instead for format conversions). This makes setting up the chain more complicated, and a way is needed to prevent endless appending of conversion filters if a conversion is not possible. Until now, this used a stupidly simple yet robust static retry limit to detect failure. This is perfectly fine, and the limit (20) was good enough to handle about ~5 filters. But with more filters, and if each filter requires 3 additional conversion filters, this would fail. So raise the limit to 4 retries per filter. This is still stupidly simple and robust, but won't arbitrarily fail if the filter count is too large.
| * audio: add double sample formatwm42013-05-123-14/+12
| | | | | | | | | | | | To make this easier, get rid of the direct mapping of the AF_FORMAT_BITS_MASK bit field to number of bytes. This way we can throw away the unused AF_FORMAT_48BIT and don't have to add ..._56BIT.
| * ao_alsa: set fallback if format unknownwm42013-05-121-4/+6
| | | | | | | | | | | | The snd_pcm_hw_params_test_format() call actually crashes in alsa-lib if called with SND_PCM_FORMAT_UNKNOWN, so the already existing fallback code won't work in this case.
| * audio/out: channel map selectionwm42013-05-1214-68/+114
| | | | | | | | | | | | | | | | | | Make all AOs use what has been introduced in the previous commit. Note that even AOs which can handle all possible layouts (like ao_null) use the new functions. This might be important if in the future ao_select_champ() possibly honors global user options about downmixing and so on.
| * audio: add channel map selection functionwm42013-05-127-20/+297
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The point is selecting a minimal fallback. The AOs will call this through the AO API, so it will be possible to add options affecting the general channel layout selection. It provides the following mechanism to AOs: - forcing the correct channel order - downmixing to stereo if no layout is available - allow 5.1 <-> 5.1(side) fallback - handling "unknown" channel layouts This is quite weak and lots of code/complexity for little gain. All AOs already made sure the channel order was correct, and the fallback is of little value, and could perhaps be done in the frontend instead, like stereo downmixing with --channels=2 is handled. But I'm not really sure how this stuff should _really_ work, and the new code will hopefully provides enough flexibility to make radical changes to channel layout negotiation easier.
| * ao_pulse: move format setup codewm42013-05-121-27/+27
| |
| * af_lavrresample: avoid channel reordering with unknown layoutswm42013-05-121-8/+24
| | | | | | | | | | | | | | If one of the input or output is an unknown layout, but the other is known, it can still happen that channels are remixed randomly. Avoid this by forcing default layouts in this case. (Doesn't work if the channel counts are different.)
| * ao_openal: use channel map instead of ALSA fixed layoutwm42013-05-121-10/+31
| | | | | | | | | | | | | | | | | | Now mpv's channel map is used to map each channel to a speaker. This allows in theory for playback of any layout for which ao_openal actually has a speaker defined. Also add the back-center (BC) speaker, which allows playback of 6.0 audio. Enabling more layouts by adding other speakers would be possible, but I'm not sure about the speaker positions.
| * audio/filters: add af_forcewm42013-05-124-0/+155
| | | | | | | | | | Its main purpose is for testing in case channel layout stuff breaks, in particular in connection with old audio filters.
| * ao: remove ao_driver.is_new fieldwm42013-05-129-9/+0
| | | | | | | | Is unused, is completely pointless.
| * ao_alsa: remove global variableswm42013-05-121-110/+116
| |
| * ao_alsa: switch to new AO APIwm42013-05-121-39/+54
| |
| * af_ladspa: code cleanupeng2013-05-121-15/+17
| | | | | | | | | | | | Cleanup based on results from cppcheck-1.59 Reduce the scope of several variables Fix memory leak
| * audio: print channel map additionally to channel count on terminalwm42013-05-124-19/+31
| |
| * ao_alsa: map to exact channel layoutwm42013-05-121-38/+48
| | | | | | | | | | | | | | This allows supporting 5 channel audio (which can be eother 5.0 or 4.1). Fallback doesn't work yet. It will do nonsense if the channel layout doesn't match perfectly, even though it's similar.
| * ao_alsa: move format lookup into separate functionwm42013-05-121-58/+36
| |
| * ao_alsa: more reformatwm42013-05-121-118/+113
| |
| * af: print filter chain info on errorwm42013-05-121-15/+16
| | | | | | | | | | The filter chain was only visible with -v. Always print it if the filter chain could not be configured.
| * ao_alsa: cosmetics, macro-fy error reportingwm42013-05-121-321/+181
| | | | | | | | | | | | | | | | Add a CHECK_ALSA_ERROR macro to report ALSA errors. This is similar to what vo_vdpau does. This removes lots of boiler plate, it almost gives me the feeling the ao_alsa initialization code is now readable. This change is squashed with the reformatting, because both changes are just as noisy and useless.
| * ao_alsa: uncrustifywm42013-05-121-623/+717
| |
| * 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).
| * ao_coreaudio: switch to WAVEEXT channel orderwm42013-05-121-2/+1
| | | | | | | | | | This used ALSA order, which was not correct. Most likely this has been wrong since forever.
| * ao_pulse: try to set correct channel layoutwm42013-05-121-2/+54
| | | | | | | | | | | | | | | | | | | | | | | | Like most other AOs, ao_pulse set the channel count only, always using a default layout. Try to set the exact layout. For this, we need a big lookup table to map waveex/lavc/mpv speaker position to PulseAudio's, since PA_CHANNEL_POSITION_ is apparently not compatible to waveext, and I haven't seen any API functions that would help mapping them. Completely untested. (Let's leave that to someone else...)
| * 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-124-1497/+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: let libavresample do channel reorderingwm42013-05-121-3/+49
| |
| * af_lavrresample: context is always allocated herewm42013-05-121-2/+1
| |
| * audio/out: switch to channel mapwm42013-05-1219-235/+158
| | | | | | | | | | | | 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.
| * af_pan: set unknown channel layout for outputwm42013-05-121-2/+11
| |
| * af: use mp_chmap for mp_audio, include channel map in format negotiationwm42013-05-1212-57/+64
| | | | | | | | | | Now af_lavrresample pretends to reorder the channels, although it doesn't yet, and nothing sets non-standard layouts either.
| * audio: add some setters for mp_audio, and require filters to use themwm42013-05-1228-178/+166
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * audio: add channel map APIwm42013-05-123-3/+613
| | | | | | | | | | | | | | Unused, will be used in the following commits. Let chmap.h define the number of maximum channels, because that is most convenient.
| * audio/filter: remove unused AF_CONTROLswm42013-05-127-213/+1
| | | | | | | | Was unused, has never been used.
| * 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: fix negotiation endless loopwm42013-04-131-3/+2
| | | | | | | | | | | | | | Yeah... ok. Can be reproduced by having AF_CONTROL_CHANNELS not really set the correct channel map.
| * af: streamline format negotiationwm42013-04-133-167/+210
| | | | | | | | | | | | | | | | | | | | | | | | | | 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).
| * af_lavrresample: add no-detach suboptionwm42013-04-131-1/+6
| | | | | | | | | | Normally, af_lavrresample detaches itself immediately if the input and output audio parameters are the same. no-detach prevents this.
| * options: remove --af-advwm42013-04-133-23/+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.
| * af: remove accuracy optionwm42013-04-131-15/+4
| | | | | | | | | | | | | | | | All this option did was deciding whether the resample filter was to be insert at the beginning or end of the filter chain. Always do what the option set for accuracy did. I doubt it makes much of a difference. libavresample does most things in just one go anyway, so it won't matter.
| * af: remove force optionwm42013-04-131-64/+49
| | | | | | | | | | | | Dangerous and misleading. If it turns out that this is actually needed to make certain setups work right, it should be added back in a better way (in a way it doesn't cause random crashes).
| * audio: remove float processing optionwm42013-04-135-30/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * audio: switch to libavcodec channel order, use libavresample for mixingwm42013-04-135-44/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switch the internal channel order to libavcodec's. If the channel number mismatches at some point, use libavresample for up- or downmixing. Remove the old af_pan automatic downmixing. The libavcodec channel order should be equivalent to WAVEFORMATEX order, at least nowadays. reorder_ch.h assumes that WAVEFORMATEX and libavcodec might be different, but all defined channels have the same mappings. Remove the downmixing with af_pan as well as the channel conversion with af_channels from af.c, and prefer af_lavrresample for this. The automatic downmixing behavior should be the same as before (if the --channels option is set to 2, which is the default, the audio output is forced to 2 channels, and libavresample does all downmixing). Note that mpv still can't do channel layouts. It will pick the default channel layout according to the channel count. This will be fixed later by passing down the channel layout as well. af_hrtf depends on the order of the input channels, so reorder to ALSA (for which this code was written). This is better than changing the filter code, which is more risky. ao_pulse can accept waveext order directly, so set that as channel mapping.
| * ao_alsa: reorder channels from internal to alsa orderwm42013-04-131-0/+6
| | | | | | | | | | Currently, internal and alsa order are exactly the same, so this will do absolutely nothing.
| * af: simplificationwm42013-04-131-35/+20
| | | | | | | | | | | | | | | | | | If format negotiation fails, and additional filters are inserted to fix this, don't try to reinitialize the filter immediately. Instead, correct the audio format, and let the caller retry. Add a retry counter to af_reinit() to ensure that misbehaving filters can't put the format negotiation into an endless loop.
| * af: factor channel filter insertionwm42013-04-131-30/+45
| | | | | | | | Do this just like it has been done for the format filter.
| * af: use af_lavrresample for format conversions, if possiblewm42013-04-134-45/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | Refactor to remove the duplicated format filter insertion code. Allow other format converting filters to be inserted on format mismatches. af_info.test_conversion checks whether conversion between two formats would work with the given filter; do this to avoid having to insert multiple conversion filters at once and such things. (Although this isn't ideal: what if we want to avoid af_format for some conversions? What if we want to split af_format in endian-swapping filters etc.?) Prefer af_lavrresample for conversions that it supports natively, otherwise let af_format handle the full conversion.
| * af: remove automatically inserted filters on full reinitwm42013-04-132-31/+44