summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-12 21:47:55 +0200
committerwm4 <wm4@nowhere>2013-05-12 21:47:55 +0200
commite6e5a7b221ef2fcdd5a1982d6fdcb627100447d2 (patch)
tree08b54ef9bb771434fc7fbe9185793503d3ba314c
parent6a83ef1552de4a1a71da49e45647ce1a4ce64e53 (diff)
parent48f94311516dc1426644b3e68b2a48c22727e1e7 (diff)
downloadmpv-e6e5a7b221ef2fcdd5a1982d6fdcb627100447d2.tar.bz2
mpv-e6e5a7b221ef2fcdd5a1982d6fdcb627100447d2.tar.xz
Merge branch 'audio_changes'
Conflicts: audio/out/ao_lavc.c
-rw-r--r--DOCS/man/en/af.rst58
-rw-r--r--DOCS/man/en/changes.rst1
-rw-r--r--DOCS/man/en/options.rst87
-rw-r--r--Makefile5
-rw-r--r--TOOLS/uncrustify.cfg7
-rw-r--r--audio/audio.c76
-rw-r--r--audio/audio.h46
-rw-r--r--audio/chmap.c486
-rw-r--r--audio/chmap.h132
-rw-r--r--audio/chmap_sel.c210
-rw-r--r--audio/chmap_sel.h43
-rw-r--r--audio/decode/ad.h6
-rw-r--r--audio/decode/ad_lavc.c85
-rw-r--r--audio/decode/ad_mpg123.c2
-rw-r--r--audio/decode/ad_spdif.c17
-rw-r--r--audio/decode/dec_audio.c72
-rw-r--r--audio/decode/dec_audio.h4
-rw-r--r--audio/filter/af.c1078
-rw-r--r--audio/filter/af.h63
-rw-r--r--audio/filter/af_bs2b.c8
-rw-r--r--audio/filter/af_center.c5
-rw-r--r--audio/filter/af_channels.c47
-rw-r--r--audio/filter/af_delay.c5
-rw-r--r--audio/filter/af_drc.c13
-rw-r--r--audio/filter/af_dummy.c4
-rw-r--r--audio/filter/af_equalizer.c30
-rw-r--r--audio/filter/af_export.c6
-rw-r--r--audio/filter/af_extrastereo.c17
-rw-r--r--audio/filter/af_force.c146
-rw-r--r--audio/filter/af_format.c32
-rw-r--r--audio/filter/af_hrtf.c11
-rw-r--r--audio/filter/af_karaoke.c6
-rw-r--r--audio/filter/af_ladspa.c38
-rw-r--r--audio/filter/af_lavcac3enc.c29
-rw-r--r--audio/filter/af_lavrresample.c171
-rw-r--r--audio/filter/af_pan.c24
-rw-r--r--audio/filter/af_scaletempo.c14
-rw-r--r--audio/filter/af_sinesuppress.c19
-rw-r--r--audio/filter/af_sub.c5
-rw-r--r--audio/filter/af_surround.c12
-rw-r--r--audio/filter/af_sweep.c8
-rw-r--r--audio/filter/af_tools.c4
-rw-r--r--audio/filter/af_volume.c33
-rw-r--r--audio/filter/control.h127
-rw-r--r--audio/fmt-conversion.c65
-rw-r--r--audio/fmt-conversion.h25
-rw-r--r--audio/format.c18
-rw-r--r--audio/format.h9
-rw-r--r--audio/mixer.c2
-rw-r--r--audio/out/ao.c12
-rw-r--r--audio/out/ao.h14
-rw-r--r--audio/out/ao_alsa.c1345
-rw-r--r--audio/out/ao_coreaudio.c19
-rw-r--r--audio/out/ao_dsound.c91
-rw-r--r--audio/out/ao_jack.c23
-rw-r--r--audio/out/ao_lavc.c85
-rw-r--r--audio/out/ao_null.c11
-rw-r--r--audio/out/ao_openal.c82
-rw-r--r--audio/out/ao_oss.c36
-rw-r--r--audio/out/ao_pcm.c38
-rw-r--r--audio/out/ao_portaudio.c11
-rw-r--r--audio/out/ao_pulse.c106
-rw-r--r--audio/out/ao_rsound.c13
-rw-r--r--audio/out/ao_sdl.c18
-rw-r--r--audio/out/audio_out_internal.h3
-rw-r--r--audio/reorder_ch.c1373
-rw-r--r--audio/reorder_ch.h108
-rw-r--r--core/cfg-mplayer.h13
-rw-r--r--core/command.c16
-rw-r--r--core/defaultopts.c8
-rw-r--r--core/m_option.c42
-rw-r--r--core/m_option.h6
-rw-r--r--core/mplayer.c24
-rw-r--r--core/options.h9
-rw-r--r--demux/demux_lavf.c4
-rw-r--r--demux/demux_mkv.c6
-rw-r--r--demux/demux_rawaudio.c13
-rw-r--r--demux/stheader.h5
-rw-r--r--stream/tv.c10
79 files changed, 3341 insertions, 3614 deletions
diff --git a/DOCS/man/en/af.rst b/DOCS/man/en/af.rst
index 2eaeabed0c..08e7853990 100644
--- a/DOCS/man/en/af.rst
+++ b/DOCS/man/en/af.rst
@@ -30,15 +30,15 @@ filter list.
Available filters are:
lavrresample[=option1:option2:...]
- Changes the sample rate of the audio stream to an integer <srate> in Hz.
- Can be used if you have a fixed frequency sound card or if you are stuck
- with an old sound card that is only capable of max 44.1kHz.
+ This filter uses libavresample (or libswresample, depending on the build)
+ to change sample rate, sample format, or channel layout of the audio stream.
+ This filter is automatically enabled if the audio output doesn't support
+ the audio configuration of the file being played.
- This filter is automatically enabled if necessary. It only supports the
- 16-bit integer native-endian format.
+ It supports only the following sample formats: u8, s16ne, s32ne, floatne.
srate=<srate>
- the output sample rate (defaut: 44100)
+ the output sample rate
length=<length>
length of the filter with respect to the lower sampling rate (default:
16)
@@ -50,6 +50,11 @@ lavrresample[=option1:option2:...]
linear
if set then filters will be linearly interpolated between polyphase
entries (default: no)
+ no-detach
+ don't detach if input and output audio format/rate/channels are the
+ same. You should add this option if you specify additional parameters,
+ as automatically inserted lavrresample instances will use the
+ default settings.
lavcac3enc[=tospdif[:bitrate[:minchn]]]
Encode multi-channel audio to AC-3 at runtime using libavcodec. Supports
@@ -205,6 +210,34 @@ channels=nch[:nr:from1:to1:from2:to2:from3:to3:...]
Would change the number of channels to 6 and set up 4 routes that copy
channel 0 to channels 0 to 3. Channel 4 and 5 will contain silence.
+force=in-format:in-srate:in-channels:out-format:out-srate:out-channels
+ Force a specific audio format/configuration without actually changing the
+ audio data. Keep in mind that the filter system might auto-insert actual
+ conversion filters before or after this filter if needed.
+
+ All parameters are optional. The ``in-`` variants restrict what the filter
+ accepts as input. The ``out-`` variants change the audio format, without
+ actually doing a conversion. The data will be 'reinterpreted' by the
+ filters or audio outputs following this filter.
+
+ <in-format>
+ Force conversion to this format. See ``format`` filter for valid audio
+ format values.
+
+ <in-srate>
+ Force conversion to a specific sample rate. The rate is an integer,
+ 48000 for example.
+
+ <in-channels>
+ Force mixing to a specific channel layout. See ``--channels`` option
+ for possible values.
+
+ <out-format>
+
+ <out-srate>
+
+ <out-channels>
+
format[=format]
Convert between different sample formats. Automatically enabled when
needed by the sound card or another filter. See also ``--format``.
@@ -219,7 +252,7 @@ format[=format]
rule that are also valid format specifiers: u8, s8, floatle, floatbe,
floatne, mpeg2, and ac3.
-volume[=v[:sc]]
+volume[=v[:sc[:fast]]]
Implements software volume control. Use this filter with caution since it
can reduce the signal to noise ratio of the sound. In most cases it is
best to set the level for the PCM sound to max, leave this filter out and
@@ -233,8 +266,7 @@ volume[=v[:sc]]
This filter has a second feature: It measures the overall maximum sound
level and prints out that level when mpv exits. This feature currently
- only works with floating-point data, use e.g. ``--af-adv=force=5``, or use
- ``--af=stats``.
+ only works with floating-point data.
*NOTE*: This filter is not reentrant and can therefore only be enabled
once for every audio stream.
@@ -250,6 +282,9 @@ volume[=v[:sc]]
*WARNING*: This feature creates distortion and should be considered a
last resort.
+ <fast>
+ Force S16 sample format if set to 1. Lower quality, but might be faster
+ in some situations.
*EXAMPLE*:
@@ -286,6 +321,11 @@ pan=n[:L00:L01:L02:...L10:L11:L12:...Ln0:Ln1:Ln2:...]
channels 0 and 1 into output channel 2 (which could be sent to a
subwoofer for example).
+ *NOTE*: if you just want to force remixing to a certain output channel
+ layout, it's easier to use the ``force`` filter. For example,
+ ``mpv '--af=force=channels=5.1' '--channels=5.1'`` would always force
+ remixing audio to 5.1 and output it like this.
+
sub[=fc:ch]
Adds a subwoofer channel to the audio stream. The audio data used for
creating the subwoofer channel is an average of the sound in channel 0 and
diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst
index 1e5bb74a2c..20f6be553a 100644
--- a/DOCS/man/en/changes.rst
+++ b/DOCS/man/en/changes.rst
@@ -124,6 +124,7 @@ Command line switches
-afm hwac3 --ad=spdif:ac3,spdif:dts
-x W, -y H --geometry=WxH + --no-keepaspect
-xy W --autofit=W
+ -a52drc level --ad-lavc-ac3drc=level
=================================== ===================================
*NOTE*: ``-opt val`` becomes ``--opt=val``.
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index d49acaf03c..cd1b4ab90a 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1,11 +1,3 @@
---a52drc=<level>
- Select the Dynamic Range Compression level for AC-3 audio streams. <level>
- is a float value ranging from 0 to 1, where 0 means no compression and 1
- (which is the default) means full compression (make loud passages more
- silent and vice versa). Values up to 2 are also accepted, but are purely
- experimental. This option only shows an effect if the AC-3 stream contains
- the required range compression information.
-
--abs=<value>
(``--ao=oss`` only) (OBSOLETE)
Override audio driver/card buffer size detection.
@@ -37,6 +29,25 @@
``--ad=help``
List all available decoders.
+--ad-lavc-ac3drc=<level>
+ Select the Dynamic Range Compression level for AC-3 audio streams. <level>
+ is a float value ranging from 0 to 1, where 0 means no compression and 1
+ (which is the default) means full compression (make loud passages more
+ silent and vice versa). Values up to 2 are also accepted, but are purely
+ experimental. This option only shows an effect if the AC-3 stream contains
+ the required range compression information.
+
+--ad-lavc-downmix=<yes|no>
+ Whether to request audio channel downmixing from the decoder (default: yes).
+ Some decoders, like AC-3, AAC and DTS, can remix audio on decoding. The
+ requested number of output channels is set with the ``--channels`` option.
+ Useful for playing surround audio on a stereo system.
+
+--ad-lavc-o=<key>=<value>[,<key>=<value>[,...]]
+ Pass AVOptions to libavcodec decoder. Note, a patch to make the o=
+ unneeded and pass all unknown options through the AVOption system is
+ welcome. A full list of AVOptions can be found in the FFmpeg manual.
+
--af=<filter1[=parameter1:parameter2:...],filter2,...>
Specify a list of audio filters to apply to the audio stream. See
`audio_filters` for details and descriptions of the available filters.
@@ -44,40 +55,6 @@
``--af-clr`` exist to modify a previously specified list, but you
shouldn't need these for typical use.
---af-adv=<force=(0-7):list=(filters)>
- See also ``--af``.
- Specify advanced audio filter options:
-
- force=<0-7>
- Forces the insertion of audio filters to one of the following:
-
- 0
- Use completely automatic filter insertion (currently identical to
- 1).
- 1
- Optimize for accuracy (default).
- 2
- Optimize for speed. *Warning*: Some features in the audio filters
- may silently fail, and the sound quality may drop.
- 3
- Use no automatic insertion of filters and no optimization.
- *Warning*: It may be possible to crash mpv using this setting.
- 4
- Use automatic insertion of filters according to 0 above, but use
- floating point processing when possible.
- 5
- Use automatic insertion of filters according to 1 above, but use
- floating point processing when possible.
- 6
- Use automatic insertion of filters according to 2 above, but use
- floating point processing when possible.
- 7
- Use no automatic insertion of filters according to 3 above, and
- use floating point processing when possible.
-
- list=<filters>
- Same as ``--af``.
-
--aid=<ID|auto|no>
Select audio channel. ``auto`` selects the default, ``no`` disables audio.
See also ``--alang``.
@@ -381,25 +358,24 @@
--cdrom-device=<path>
Specify the CD-ROM device (default: ``/dev/cdrom``).
---channels=<number>
+--channels=<number|layout>
Request the number of playback channels (default: 2). mpv asks the
decoder to decode the audio into as many channels as specified. Then it is
up to the decoder to fulfill the requirement. This is usually only
- important when playing videos with AC-3 audio (like DVDs). In that case
- liba52 does the decoding by default and correctly downmixes the audio into
- the requested number of channels. To directly control the number of output
- channels independently of how many channels are decoded, use the channels
- filter (``--af=channels``).
+ important when playing videos with AC-3, AAC or DTS audio. In that case
+ libavcodec downmixes the audio into the requested number of channels if
+ possible.
*NOTE*: This option is honored by codecs (AC-3 only), filters (surround)
and audio output drivers (OSS at least).
- Available options are:
+ The ``--channels`` option either takes a channel number or an explicit
+ channel layout. Channel numbers refer to default layouts, e.g. 2 channels
+ refer to stereo, 6 refers to 5.1.
- :2: stereo
- :4: surround
- :6: full 5.1
- :8: full 7.1
+ See ``--channels=help`` output for defined default layouts. This also
+ lists speaker names, which can be used to express arbitrary channel
+ layouts (e.g. ``fl-fr-lfe`` is 2.1).
--chapter=<start[-end]>
Specify which chapter to start playing at. Optionally specify which
@@ -1985,9 +1961,8 @@
--srate=<Hz>
Select the output sample rate to be used (of course sound cards have
limits on this). If the sample frequency selected is different from that
- of the current media, the resample or lavcresample audio filter will be
- inserted into the audio filter layer to compensate for the difference. The
- type of resampling can be controlled by the ``--af-adv`` option.
+ of the current media, the lavrresample audio filter will be
+ inserted into the audio filter layer to compensate for the difference.
--start=<relative time>
Seek to given time position.
diff --git a/Makefile b/Makefile
index 314bbb4fb7..76040a38f1 100644
--- a/Makefile
+++ b/Makefile
@@ -124,6 +124,10 @@ ifeq ($(HAVE_AVUTIL_REFCOUNTING),no)
endif
SOURCES = talloc.c \
+ audio/audio.c \
+ audio/chmap.c \
+ audio/chmap_sel.c \
+ audio/fmt-conversion.c \
audio/format.c \
audio/mixer.c \
audio/reorder_ch.c \
@@ -138,6 +142,7 @@ SOURCES = talloc.c \
audio/filter/af_dummy.c \
audio/filter/af_equalizer.c \
audio/filter/af_extrastereo.c \
+ audio/filter/af_force.c \
audio/filter/af_format.c \
audio/filter/af_hrtf.c \
audio/filter/af_karaoke.c \
diff --git a/TOOLS/uncrustify.cfg b/TOOLS/uncrustify.cfg
index b5133be203..837d9a1770 100644
--- a/TOOLS/uncrustify.cfg
+++ b/TOOLS/uncrustify.cfg
@@ -1,3 +1,10 @@
+# Usage:
+# uncrustify -l C -c TOOLS/uncrustify.cfg --no-backup --replace file.c
+#
+# Keep in mind that this uncrustify configuration still produces some
+# bad/broken formatting.
+#
+
code_width=80
indent_align_string=false
indent_braces=false
diff --git a/audio/audio.c b/audio/audio.c
new file mode 100644
index 0000000000..c9d5c9231c
--- /dev/null
+++ b/audio/audio.c
@@ -0,0 +1,76 @@
+/*
+ * This file is part of mpv.
+ *
+ * mpv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * mpv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with mpv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <assert.h>
+
+#include "core/mp_talloc.h"
+#include "audio.h"
+
+void mp_audio_set_format(struct mp_audio *mpa, int format)
+{
+ mpa->format = format;
+ mpa->bps = af_fmt2bits(format) / 8;
+}
+
+void mp_audio_set_num_channels(struct mp_audio *mpa, int num_channels)
+{
+ struct mp_chmap map;
+ mp_chmap_from_channels(&map, num_channels);
+ mp_audio_set_channels(mpa, &map);
+}
+
+// Use old MPlayer/ALSA channel layout.
+void mp_audio_set_channels_old(struct mp_audio *mpa, int num_channels)
+{
+ struct mp_chmap map;
+ mp_chmap_from_channels_alsa(&map, num_channels);
+ mp_audio_set_channels(mpa, &map);
+}
+
+void mp_audio_set_channels(struct mp_audio *mpa, const struct mp_chmap *chmap)
+{
+ assert(mp_chmap_is_empty(chmap) || mp_chmap_is_valid(chmap));
+ mpa->channels = *chmap;
+ mpa->nch = mpa->channels.num;
+}
+
+void mp_audio_copy_config(struct mp_audio *dst, const struct mp_audio *src)
+{
+ mp_audio_set_format(dst, src->format);
+ mp_audio_set_channels(dst, &src->channels);
+ dst->rate = src->rate;
+}
+
+bool mp_audio_config_equals(const struct mp_audio *a, const struct mp_audio *b)
+{
+ return a->format == b->format && a->rate == b->rate &&
+ mp_chmap_equals(&a->channels, &b->channels);
+}
+
+char *mp_audio_fmt_to_str(int srate, const struct mp_chmap *chmap, int format)
+{
+ char *chstr = mp_chmap_to_str(chmap);
+ char *res = talloc_asprintf(NULL, "%dHz %s %dch %s", srate, chstr,
+ chmap->num, af_fmt2str_short(format));
+ talloc_free(chstr);
+ return res;
+}
+
+char *mp_audio_config_to_str(struct mp_audio *mpa)
+{
+ return mp_audio_fmt_to_str(mpa->rate, &mpa->channels, mpa->format);
+}
diff --git a/audio/audio.h b/audio/audio.h
new file mode 100644
index 0000000000..de35e697c8
--- /dev/null
+++ b/audio/audio.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of mpv.
+ *
+ * mpv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * mpv is distributed in the hope