summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2015-04-02 22:01:51 -0700
committerKevin Mitchell <kevmitch@gmail.com>2015-04-03 15:40:01 -0700
commit46b9df9f9e1eec5cdaa03ab842b34cf1f2ad9ece (patch)
treeeae7a659723e84dc6382cc4a011aa1809342c97c
parent07671ac57b41710201e9a0f22b8a8d0febad1c37 (diff)
downloadmpv-46b9df9f9e1eec5cdaa03ab842b34cf1f2ad9ece.tar.bz2
mpv-46b9df9f9e1eec5cdaa03ab842b34cf1f2ad9ece.tar.xz
audio: make all format query shortcuts macros
af_fmt_is_float and af_fmt_is_planar were previously inconsistent with AF_FORAMT_IS_SPECIAL/AF_FORMAT_IS_IEC61937
-rw-r--r--audio/audio.c4
-rw-r--r--audio/filter/af_lavrresample.c2
-rw-r--r--audio/filter/af_volume.c2
-rw-r--r--audio/format.c13
-rw-r--r--audio/format.h5
-rw-r--r--audio/out/ao.c2
-rw-r--r--audio/out/ao_alsa.c6
-rw-r--r--audio/out/ao_lavc.c4
-rwxr-xr-xaudio/out/ao_wasapi_utils.c2
9 files changed, 15 insertions, 25 deletions
diff --git a/audio/audio.c b/audio/audio.c
index e5df25a6ad..ea0b6203e2 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -35,7 +35,7 @@ static void update_redundant_info(struct mp_audio *mpa)
mp_chmap_is_valid(&mpa->channels));
mpa->nch = mpa->channels.num;
mpa->bps = af_fmt2bps(mpa->format);
- if (af_fmt_is_planar(mpa->format)) {
+ if (AF_FORMAT_IS_PLANAR(mpa->format)) {
mpa->spf = 1;
mpa->num_planes = mpa->nch;
mpa->sstride = mpa->bps;
@@ -101,7 +101,7 @@ char *mp_audio_config_to_str_buf(char *buf, size_t buf_sz, struct mp_audio *mpa)
void mp_audio_force_interleaved_format(struct mp_audio *mpa)
{
- if (af_fmt_is_planar(mpa->format))
+ if (AF_FORMAT_IS_PLANAR(mpa->format))
mp_audio_set_format(mpa, af_fmt_from_planar(mpa->format));
}
diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c
index 7ccfc5c593..9e4a8adaaa 100644
--- a/audio/filter/af_lavrresample.c
+++ b/audio/filter/af_lavrresample.c
@@ -404,7 +404,7 @@ static int filter(struct af_instance *af, struct mp_audio *in)
}
if (needs_reorder(s->reorder_out, out->nch)) {
- if (af_fmt_is_planar(out->format)) {
+ if (AF_FORMAT_IS_PLANAR(out->format)) {
reorder_planes(out, s->reorder_out);
} else if (out->samples) {
struct mp_audio *new = mp_audio_pool_get(s->reorder_buffer, out,
diff --git a/audio/filter/af_volume.c b/audio/filter/af_volume.c
index 0a3264e409..89a18e9d39 100644
--- a/audio/filter/af_volume.c
+++ b/audio/filter/af_volume.c
@@ -59,7 +59,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
} else {
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
}
- if (af_fmt_is_planar(in->format))
+ if (AF_FORMAT_IS_PLANAR(in->format))
mp_audio_set_format(af->data, af_fmt_to_planar(af->data->format));
s->rgain = 1.0;
if ((s->rgain_track || s->rgain_album) && af->replaygain_data) {
diff --git a/audio/format.c b/audio/format.c
index 7f9cb1477e..a25682e7e2 100644
--- a/audio/format.c
+++ b/audio/format.c
@@ -45,11 +45,6 @@ int af_fmt2bits(int format)
return af_fmt2bps(format) * 8;
}
-bool af_fmt_is_float(int format)
-{
- return !!(format & AF_FORMAT_F);
-}
-
static int bits_to_mask(int bits)
{
switch (bits) {
@@ -105,12 +100,6 @@ int af_fmt_from_planar(int format)
return format;
}
-// false for interleaved and AF_FORMAT_UNKNOWN
-bool af_fmt_is_planar(int format)
-{
- return !!(format & AF_FORMAT_PLANAR);
-}
-
const struct af_fmt_entry af_fmtstr_table[] = {
{"u8", AF_FORMAT_U8},
{"s8", AF_FORMAT_S8},
@@ -161,7 +150,7 @@ const char *af_fmt_to_str(int format)
int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate)
{
- assert(!af_fmt_is_planar(format));
+ assert(!AF_FORMAT_IS_PLANAR(format));
int bps = af_fmt2bps(format);
int framelen = channels * bps;
int bytes = seconds * bps * samplerate;
diff --git a/audio/format.h b/audio/format.h
index 910b952fd2..5d41b2e3f1 100644
--- a/audio/format.h
+++ b/audio/format.h
@@ -96,6 +96,9 @@ enum af_format {
#define AF_FORMAT_IS_IEC61937(f) (((f) & AF_FORMAT_TYPE_MASK) == AF_FORMAT_S)
#define AF_FORMAT_IS_SPECIAL(f) AF_FORMAT_IS_IEC61937(f)
+#define AF_FORMAT_IS_FLOAT(f) (!!((f) & AF_FORMAT_F))
+// false for interleaved and AF_FORMAT_UNKNOWN
+#define AF_FORMAT_IS_PLANAR(f) (!!((f) & AF_FORMAT_PLANAR))
struct af_fmt_entry {
const char *name;
@@ -109,12 +112,10 @@ const char *af_fmt_to_str(int format);
int af_fmt2bps(int format);
int af_fmt2bits(int format);
-bool af_fmt_is_float(int format);
int af_fmt_change_bits(int format, int bits);
int af_fmt_to_planar(int format);
int af_fmt_from_planar(int format);
-bool af_fmt_is_planar(int format);
// Amount of bytes that contain audio of the given duration, aligned to frames.
int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate);
diff --git a/audio/out/ao.c b/audio/out/ao.c
index 8a66b1171c..4953c14c71 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -199,7 +199,7 @@ static struct ao *ao_init(bool probing, struct mpv_global *global,
ao->sstride = af_fmt2bps(ao->format);
ao->num_planes = 1;
- if (af_fmt_is_planar(ao->format)) {
+ if (AF_FORMAT_IS_PLANAR(ao->format)) {
ao->num_planes = ao->channels.num;
} else {
ao->sstride *= ao->channels.num;
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 1ee662ac77..f84a781e8a 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -467,11 +467,11 @@ static int init_device(struct ao *ao)
err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt);
CHECK_ALSA_ERROR("Unable to set format");
- snd_pcm_access_t access = af_fmt_is_planar(ao->format)
+ snd_pcm_access_t access = AF_FORMAT_IS_PLANAR(ao->format)
? SND_PCM_ACCESS_RW_NONINTERLEAVED
: SND_PCM_ACCESS_RW_INTERLEAVED;
err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access);
- if (err < 0 && af_fmt_is_planar(ao->format)) {
+ if (err < 0 && AF_FORMAT_IS_PLANAR(ao->format)) {
ao->format = af_fmt_from_planar(ao->format);
access = SND_PCM_ACCESS_RW_INTERLEAVED;
err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access);
@@ -817,7 +817,7 @@ static int play(struct ao *ao, void **data, int samples, int flags)
return 0;
do {
- if (af_fmt_is_planar(ao->format)) {
+ if (AF_FORMAT_IS_PLANAR(ao->format)) {
res = snd_pcm_writen(p->alsa, data, samples);
} else {
res = snd_pcm_writei(p->alsa, data[0], samples);
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c
index 2405b2213a..f61401a49e 100644
--- a/audio/out/ao_lavc.c
+++ b/audio/out/ao_lavc.c
@@ -242,7 +242,7 @@ static int encode(struct ao *ao, double apts, void **data)
frame->format = af_to_avformat(ao->format);
frame->nb_samples = ac->aframesize;
- size_t num_planes = af_fmt_is_planar(ao->format) ? ao->channels.num : 1;
+ size_t num_planes = AF_FORMAT_IS_PLANAR(ao->format) ? ao->channels.num : 1;
assert(num_planes <= AV_NUM_DATA_POINTERS);
for (int n = 0; n < num_planes; n++)
frame->extended_data[n] = data[n];
@@ -351,7 +351,7 @@ static int play(struct ao *ao, void **data, int samples, int flags)
double pts = ectx->last_audio_in_pts;
pts += ectx->samples_since_last_pts / (double)ao->samplerate;
- size_t num_planes = af_fmt_is_planar(ao->format) ? ao->channels.num : 1;
+ size_t num_planes = AF_FORMAT_IS_PLANAR(ao->format) ? ao->channels.num : 1;
void *tempdata = NULL;
void *padded[MP_NUM_CHANNELS];
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c
index c5c4cd0a9a..afeb7d1dc0 100755
--- a/audio/out/ao_wasapi_utils.c
+++ b/audio/out/ao_wasapi_utils.c
@@ -91,7 +91,7 @@ static const GUID *format_to_subtype(int format)
return wasapi_fmt_table[i].subtype;
}
return &KSDATAFORMAT_SPECIFIER_NONE;
- } else if (af_fmt_is_float(format)) {
+ } else if (AF_FORMAT_IS_FLOAT(format)) {
return &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
}
return &KSDATAFORMAT_SUBTYPE_PCM;