1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 09:02:38 +00:00

audio: drop "_NE"/"ne" suffix from audio formats

You get the native format by not appending any suffix to the format.

This change includes user-facing names, e.g. for the --format option.
This commit is contained in:
wm4 2013-11-15 21:25:05 +01:00
parent 2289a479b1
commit 514c454770
29 changed files with 63 additions and 75 deletions

View File

@ -35,7 +35,7 @@ Available filters are:
This filter is automatically enabled if the audio output does not support
the audio configuration of the file being played.
It supports only the following sample formats: u8, s16ne, s32ne, floatne.
It supports only the following sample formats: u8, s16, s32, float.
``filter-size=<length>``
Length of the filter with respect to the lower sampling rate. (default:
@ -223,11 +223,11 @@ Available filters are:
Force conversion to this format. Use ``--af=format=format=help`` to get
a list of valid formats. The general form is 'sbe', where 's' denotes
the sign (either 's' for signed or 'u' for unsigned), 'b' denotes the
number of bits per sample (16, 24 or 32) and 'e' denotes the
endianness ('le' means little-endian, 'be' big-endian and 'ne' the
number of bits per sample (16, 24 or 32) and 'e' denotes the endian
('le' means little-endian, 'be' big-endian and leaving it away the
endianness of the computer mpv is running on). Valid values (amongst
others) are: 's16le', 'u32be' and 'u24ne'. Exceptions to this rule that
are also valid format specifiers: u8, s8, floatle, floatbe, floatne,
others) are: 's16le', 'u32be' and 'u24'. Exceptions to this rule that
are also valid format specifiers: u8, s8, floatle, floatbe, float,
mpeg2, and ac3.
``<srate>``
@ -553,7 +553,7 @@ Available filters are:
``mpv --af=scaletempo=stride=30:overlap=.50:search=10 media.ogg``
Would tweak the quality and performace parameters.
``mpv --af=format=floatne,scaletempo media.ogg``
``mpv --af=format=float,scaletempo media.ogg``
Would make scaletempo use float code. Maybe faster on some
platforms.

View File

@ -149,13 +149,13 @@ static int set_format(sh_audio_t *sh)
sh->sample_format = AF_FORMAT_S8;
break;
case MPG123_ENC_SIGNED_16:
sh->sample_format = AF_FORMAT_S16_NE;
sh->sample_format = AF_FORMAT_S16;
break;
case MPG123_ENC_SIGNED_32:
sh->sample_format = AF_FORMAT_S32_NE;
sh->sample_format = AF_FORMAT_S32;
break;
case MPG123_ENC_FLOAT_32:
sh->sample_format = AF_FORMAT_FLOAT_NE;
sh->sample_format = AF_FORMAT_FLOAT;
break;
default:
/* This means we got a funny custom build of libmpg123 that only supports an unknown format. */

View File

@ -135,7 +135,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
break;
default:
af->play = play_f;
mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
break;
}

View File

@ -50,7 +50,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
af->data->rate = ((struct mp_audio*)arg)->rate;
mp_audio_set_channels_old(af->data, MPMAX(s->ch+1,((struct mp_audio*)arg)->nch));
mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
return af_test_output(af,(struct mp_audio*)arg);
}

View File

@ -23,10 +23,10 @@
static bool test_conversion(int src_format, int dst_format)
{
return (src_format == AF_FORMAT_U24_NE && dst_format == AF_FORMAT_U32_NE) ||
(src_format == AF_FORMAT_S24_NE && dst_format == AF_FORMAT_S32_NE) ||
(src_format == AF_FORMAT_U32_NE && dst_format == AF_FORMAT_U24_NE) ||
(src_format == AF_FORMAT_S32_NE && dst_format == AF_FORMAT_S24_NE);
return (src_format == AF_FORMAT_U24 && dst_format == AF_FORMAT_U32) ||
(src_format == AF_FORMAT_S24 && dst_format == AF_FORMAT_S32) ||
(src_format == AF_FORMAT_U32 && dst_format == AF_FORMAT_U24) ||
(src_format == AF_FORMAT_S32 && dst_format == AF_FORMAT_S24);
}
static int control(struct af_instance *af, int cmd, void *arg)

View File

@ -91,8 +91,8 @@ static int control(struct af_instance* af, int cmd, void* arg)
mp_audio_force_interleaved_format((struct mp_audio*)arg);
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
if(((struct mp_audio*)arg)->format != (AF_FORMAT_S16_NE)){
mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
if(((struct mp_audio*)arg)->format != (AF_FORMAT_S16)){
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
}
return af_test_output(af,(struct mp_audio*)arg);
case AF_CONTROL_COMMAND_LINE:{
@ -296,14 +296,14 @@ static struct mp_audio* play(struct af_instance* af, struct mp_audio* data)
{
af_drc_t *s = af->setup;
if(af->data->format == (AF_FORMAT_S16_NE))
if(af->data->format == (AF_FORMAT_S16))
{
if (s->method)
method2_int16(s, data);
else
method1_int16(s, data);
}
else if(af->data->format == (AF_FORMAT_FLOAT_NE))
else if(af->data->format == (AF_FORMAT_FLOAT))
{
if (s->method)
method2_float(s, data);

View File

@ -98,7 +98,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
if(!arg) return AF_ERROR;
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
// Calculate number of active filters
s->K=KM;

View File

@ -88,7 +88,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Accept only int16_t as input format (which sucks)
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
mp_audio_set_format(af->data, AF_FORMAT_S16_NE);
mp_audio_set_format(af->data, AF_FORMAT_S16);
// If buffer length isn't set, set it to the default value
if(s->sz == 0)

View File

@ -51,12 +51,12 @@ static int control(struct af_instance* af, int cmd, void* arg)
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
mp_audio_force_interleaved_format(af->data);
mp_audio_set_num_channels(af->data, 2);
if (af->data->format == AF_FORMAT_FLOAT_NE)
if (af->data->format == AF_FORMAT_FLOAT)
{
af->play = play_float;
}// else
{
mp_audio_set_format(af->data, AF_FORMAT_S16_NE);
mp_audio_set_format(af->data, AF_FORMAT_S16);
af->play = play_s16;
}

View File

@ -311,7 +311,7 @@ static int control(struct af_instance *af, int cmd, void* arg)
}
else if (af->data->nch < 5)
mp_audio_set_channels_old(af->data, 5);
mp_audio_set_format(af->data, AF_FORMAT_S16_NE);
mp_audio_set_format(af->data, AF_FORMAT_S16);
test_output_res = af_test_output(af, (struct mp_audio*)arg);
// after testing input set the real output format
mp_audio_set_num_channels(af->data, 2);

View File

@ -35,7 +35,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
switch(cmd){
case AF_CONTROL_REINIT:
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
return af_test_output(af,(struct mp_audio*)arg);
}
return AF_UNKNOWN;

View File

@ -495,7 +495,7 @@ static int control(struct af_instance *af, int cmd, void *arg) {
/* accept FLOAT, let af_format do conversion */
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
return af_test_output(af, (struct mp_audio*)arg);
case AF_CONTROL_COMMAND_LINE: {

View File

@ -175,7 +175,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
struct mp_audio *out = af->data;
if (af_to_avformat(in->format) == AV_SAMPLE_FMT_NONE)
mp_audio_set_format(in, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(in, AF_FORMAT_FLOAT);
if (!mp_chmap_is_lavc(&in->channels))
mp_chmap_reorder_to_lavc(&in->channels); // will always work

View File

@ -245,7 +245,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
mp_audio_set_channels(out, &in->channels);
if (af_to_avformat(in->format) == AV_SAMPLE_FMT_NONE)
mp_audio_set_format(in, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(in, AF_FORMAT_FLOAT);
if (af_to_avformat(out->format) == AV_SAMPLE_FMT_NONE)
mp_audio_set_format(out, in->format);

View File

@ -55,7 +55,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
if(!arg) return AF_ERROR;
af->data->rate = ((struct mp_audio*)arg)->rate;
mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
set_channels(af->data, s->nch ? s->nch: ((struct mp_audio*)arg)->nch);
if((af->data->format != ((struct mp_audio*)arg)->format) ||

View File

@ -290,10 +290,10 @@ static int control(struct af_instance *af, int cmd, void *arg)
return af_test_output(af, data);
}
if (data->format == AF_FORMAT_S16_NE) {
if (data->format == AF_FORMAT_S16) {
use_int = 1;
} else {
mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
}
int bps = af->data->bps;

View File

@ -57,15 +57,15 @@ static int control(struct af_instance* af, int cmd, void* arg)
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
mp_audio_set_num_channels(af->data, 1);
#if 0
if (((struct mp_audio*)arg)->format == AF_FORMAT_FLOAT_NE)
if (((struct mp_audio*)arg)->format == AF_FORMAT_FLOAT)
{
af->data->format = AF_FORMAT_FLOAT_NE;
af->data->format = AF_FORMAT_FLOAT;
af->data->bps = 4;
af->play = play_float;
}// else
#endif
{
mp_audio_set_format(af->data, AF_FORMAT_S16_NE);
mp_audio_set_format(af->data, AF_FORMAT_S16);
af->play = play_s16;
}

View File

@ -72,7 +72,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
af->data->rate = ((struct mp_audio*)arg)->rate;
mp_audio_set_channels_old(af->data, MPMAX(s->ch+1,((struct mp_audio*)arg)->nch));
mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
// Design low-pass filter
s->k = 1.0;

View File

@ -98,7 +98,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
return AF_DETACH;
}
mp_audio_set_format(in, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(in, AF_FORMAT_FLOAT);
mp_audio_copy_config(af->data, in);
mp_audio_set_channels_old(af->data, in->nch * 2);

View File

@ -42,7 +42,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
switch(cmd){
case AF_CONTROL_REINIT:
mp_audio_copy_config(af->data, data);
mp_audio_set_format(af->data, AF_FORMAT_S16_NE);
mp_audio_set_format(af->data, AF_FORMAT_S16);
return af_test_output(af, data);
case AF_CONTROL_COMMAND_LINE:

View File

@ -47,10 +47,10 @@ static int control(struct af_instance *af, int cmd, void *arg)
mp_audio_copy_config(af->data, in);
mp_audio_force_interleaved_format(af->data);
if (s->fast && af_fmt_from_planar(in->format) != AF_FORMAT_FLOAT_NE) {
mp_audio_set_format(af->data, AF_FORMAT_S16_NE);
if (s->fast && af_fmt_from_planar(in->format) != AF_FORMAT_FLOAT) {
mp_audio_set_format(af->data, AF_FORMAT_S16);
} else {
mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
}
if (af_fmt_is_planar(in->format))
mp_audio_set_format(af->data, af_fmt_to_planar(af->data->format));
@ -70,7 +70,7 @@ static void filter_plane(struct af_instance *af, void *ptr, int num_samples)
{
struct priv *s = af->priv;
if (af_fmt_from_planar(af->data->format) == AF_FORMAT_S16_NE) {
if (af_fmt_from_planar(af->data->format) == AF_FORMAT_S16) {
int16_t *a = ptr;
int vol = 256.0 * s->level;
if (vol != 256) {
@ -79,7 +79,7 @@ static void filter_plane(struct af_instance *af, void *ptr, int num_samples)
a[i] = MPCLAMP(x, SHRT_MIN, SHRT_MAX);
}
}
} else if (af_fmt_from_planar(af->data->format) == AF_FORMAT_FLOAT_NE) {
} else if (af_fmt_from_planar(af->data->format) == AF_FORMAT_FLOAT) {
float *a = ptr;
float vol = s->level;
if (vol != 1.0) {

View File

@ -27,10 +27,10 @@ static const struct {
int fmt;
} audio_conversion_map[] = {
{AV_SAMPLE_FMT_U8, AF_FORMAT_U8},
{AV_SAMPLE_FMT_S16, AF_FORMAT_S16_NE},
{AV_SAMPLE_FMT_S32, AF_FORMAT_S32_NE},
{AV_SAMPLE_FMT_FLT, AF_FORMAT_FLOAT_NE},
{AV_SAMPLE_FMT_DBL, AF_FORMAT_DOUBLE_NE},
{AV_SAMPLE_FMT_S16, AF_FORMAT_S16},
{AV_SAMPLE_FMT_S32, AF_FORMAT_S32},
{AV_SAMPLE_FMT_FLT, AF_FORMAT_FLOAT},
{AV_SAMPLE_FMT_DBL, AF_FORMAT_DOUBLE},
{AV_SAMPLE_FMT_U8P, AF_FORMAT_U8P},
{AV_SAMPLE_FMT_S16P, AF_FORMAT_S16P},

View File

@ -109,7 +109,6 @@ bool af_fmt_is_planar(int format)
#define FMT_ENDIAN(string, id) \
{string, id}, \
{string "ne", id}, \
{string "le", MP_CONCAT(id, _LE)}, \
{string "be", MP_CONCAT(id, _BE)}, \

View File

@ -130,17 +130,6 @@ enum af_format {
AF_FORMAT_IEC61937 = AF_SELECT_LE_BE(AF_FORMAT_IEC61937_LE, AF_FORMAT_IEC61937_BE),
};
#define AF_FORMAT_U16_NE AF_FORMAT_U16
#define AF_FORMAT_S16_NE AF_FORMAT_S16
#define AF_FORMAT_U24_NE AF_FORMAT_U24
#define AF_FORMAT_S24_NE AF_FORMAT_S24
#define AF_FORMAT_U32_NE AF_FORMAT_U32
#define AF_FORMAT_S32_NE AF_FORMAT_S32
#define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT
#define AF_FORMAT_DOUBLE_NE AF_FORMAT_DOUBLE
#define AF_FORMAT_AC3_NE AF_FORMAT_AC3
#define AF_FORMAT_IEC61937_NE AF_FORMAT_IEC61937
#define AF_FORMAT_IS_AC3(fmt) \
(((fmt) & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_S_AC3)

View File

@ -387,7 +387,7 @@ static int init(struct ao *ao)
ao->channels.num);
} else {
device = select_chmap(ao);
if (strcmp(device, "default") != 0 && ao->format == AF_FORMAT_FLOAT_NE)
if (strcmp(device, "default") != 0 && ao->format == AF_FORMAT_FLOAT)
{
// hack - use the converter plugin (why the heck?)
device = talloc_asprintf(ao, "plug:%s", device);
@ -435,7 +435,7 @@ static int init(struct ao *ao)
p->alsa_fmt = find_alsa_format(ao->format);
if (p->alsa_fmt == SND_PCM_FORMAT_UNKNOWN) {
p->alsa_fmt = SND_PCM_FORMAT_S16;
ao->format = AF_FORMAT_S16_NE;
ao->format = AF_FORMAT_S16;
}
err = snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt);

View File

@ -392,7 +392,7 @@ static int init(struct ao *ao)
int rate = ao->samplerate;
if (AF_FORMAT_IS_AC3(format))
format = AF_FORMAT_AC3_NE;
format = AF_FORMAT_AC3;
else {
struct mp_chmap_sel sel = {0};
mp_chmap_sel_add_waveext(&sel);
@ -400,7 +400,7 @@ static int init(struct ao *ao)
return -1;
}
switch (format) {
case AF_FORMAT_AC3_NE:
case AF_FORMAT_AC3:
case AF_FORMAT_S24_LE:
case AF_FORMAT_S16_LE:
case AF_FORMAT_U8:

View File

@ -89,14 +89,14 @@ static int format_table[][2] = {
{AFMT_S32_BE, AF_FORMAT_S32_BE},
#endif
#ifdef AFMT_FLOAT
{AFMT_FLOAT, AF_FORMAT_FLOAT_NE},
{AFMT_FLOAT, AF_FORMAT_FLOAT},
#endif
// SPECIALS
#ifdef AFMT_MPEG
{AFMT_MPEG, AF_FORMAT_MPEG2},
#endif
#ifdef AFMT_AC3
{AFMT_AC3, AF_FORMAT_AC3_NE},
{AFMT_AC3, AF_FORMAT_AC3},
#endif
{-1, -1}
};
@ -269,7 +269,7 @@ static int init(struct ao *ao)
ac3_retry:
if (AF_FORMAT_IS_AC3(ao->format))
ao->format = AF_FORMAT_AC3_NE;
ao->format = AF_FORMAT_AC3;
oss_format = format2oss(ao->format);
if (oss_format == -1) {
MP_VERBOSE(ao, "Unknown/not supported internal format: %s\n",
@ -279,15 +279,15 @@ ac3_retry:
#else
oss_format = AFMT_S16_LE;
#endif
ao->format = AF_FORMAT_S16_NE;
ao->format = AF_FORMAT_S16;
}
if (ioctl(p->audio_fd, SNDCTL_DSP_SETFMT, &oss_format) < 0 ||
oss_format != format2oss(ao->format))
{
MP_WARN(ao, "Can't set audio device %s to %s output, trying %s...\n",
p->dsp, af_fmt_to_str(ao->format),
af_fmt_to_str(AF_FORMAT_S16_NE));
ao->format = AF_FORMAT_S16_NE;
af_fmt_to_str(AF_FORMAT_S16));
ao->format = AF_FORMAT_S16;
goto ac3_retry;
}

View File

@ -56,12 +56,12 @@ struct format_map {
static const struct format_map format_maps[] = {
// first entry is the default format
{AF_FORMAT_S16_NE, paInt16},
{AF_FORMAT_S24_NE, paInt24},
{AF_FORMAT_S32_NE, paInt32},
{AF_FORMAT_S8, paInt8},
{AF_FORMAT_U8, paUInt8},
{AF_FORMAT_FLOAT_NE, paFloat32},
{AF_FORMAT_S16, paInt16},
{AF_FORMAT_S24, paInt24},
{AF_FORMAT_S32, paInt32},
{AF_FORMAT_S8, paInt8},
{AF_FORMAT_U8, paUInt8},
{AF_FORMAT_FLOAT, paFloat32},
{AF_FORMAT_UNKNOWN, 0}
};

View File

@ -41,7 +41,7 @@ struct priv {
static struct mp_chmap channels = MP_CHMAP_INIT_STEREO;
static int samplerate = 44100;
static int aformat = AF_FORMAT_S16_NE;
static int aformat = AF_FORMAT_S16;
const m_option_t demux_rawaudio_opts[] = {
{ "channels", &channels, &m_option_type_chmap, CONF_MIN, 1 },