summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-07-07 17:50:36 +0200
committerwm4 <wm4@nowhere>2017-07-07 17:56:22 +0200
commit03596ac551c67cf66c962b1533feec49de18626d (patch)
treecfb850e97e0d90d00a71be24a39bba57c65df08f
parent300097536d1de5beea286e8c8b492370333462b0 (diff)
downloadmpv-03596ac551c67cf66c962b1533feec49de18626d.tar.bz2
mpv-03596ac551c67cf66c962b1533feec49de18626d.tar.xz
audio: drop AF_FORMAT_S24
This is the last sample format that was only in mpv and not in FFmpeg (except the spdif special formats). It was a huge pain, even if the removed code in af_lavrresample is pretty small after all. Note that this drops S24 from the ao_coreaudio AOs too. I'm not sure about the impact, but I expect it doesn't matter. af_fmt_change_bytes() was unused as well, so remove that too.
-rw-r--r--audio/filter/af_lavrresample.c28
-rw-r--r--audio/format.c16
-rw-r--r--audio/format.h2
3 files changed, 2 insertions, 44 deletions
diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c
index 47c374b227..ce991fa4fe 100644
--- a/audio/filter/af_lavrresample.c
+++ b/audio/filter/af_lavrresample.c
@@ -152,17 +152,6 @@ static int rate_from_speed(int rate, double speed)
return lrint(rate * speed);
}
-// Return the format libavresample should convert to, given the final output
-// format mp_format. In some cases (S24) we perform an extra conversion step,
-// and signal here what exactly libavresample should output. It will be the
-// input to the final conversion to mp_format.
-static int check_output_conversion(int mp_format)
-{
- if (mp_format == AF_FORMAT_S24)
- return AV_SAMPLE_FMT_S32;
- return af_to_avformat(mp_format);
-}
-
static struct mp_chmap fudge_pairs[][2] = {
{MP_CHMAP2(BL, BR), MP_CHMAP2(SL, SR)},
{MP_CHMAP2(SL, SR), MP_CHMAP2(BL, BR)},
@@ -223,7 +212,7 @@ static int configure_lavrr(struct af_instance *af, struct mp_audio *in,
goto error;
enum AVSampleFormat in_samplefmt = af_to_avformat(in->format);
- enum AVSampleFormat out_samplefmt = check_output_conversion(out->format);
+ enum AVSampleFormat out_samplefmt = af_to_avformat(out->format);
enum AVSampleFormat out_samplefmtp = av_get_planar_sample_fmt(out_samplefmt);
if (in_samplefmt == AV_SAMPLE_FMT_NONE ||
@@ -305,7 +294,6 @@ static int configure_lavrr(struct af_instance *af, struct mp_audio *in,
mp_audio_set_format(&s->avrctx_fmt, af_from_avformat(out_samplefmtp));
s->pre_out_fmt = *out;
- mp_audio_set_format(&s->pre_out_fmt, af_from_avformat(out_samplefmt));
// If there are NA channels, the final output will have more channels than
// the avrctx output. Also, avrctx will output planar (out_samplefmtp was
@@ -380,7 +368,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
if (af_to_avformat(in->format) == AV_SAMPLE_FMT_NONE)
mp_audio_set_format(in, AF_FORMAT_FLOAT);
- if (check_output_conversion(out->format) == AV_SAMPLE_FMT_NONE)
+ if (af_to_avformat(out->format) == AV_SAMPLE_FMT_NONE)
mp_audio_set_format(out, in->format);
int r = ((in->format == orig_in.format) &&
@@ -426,18 +414,6 @@ static void uninit(struct af_instance *af)
static void extra_output_conversion(struct af_instance *af, struct mp_audio *mpa)
{
- if (mpa->format == AF_FORMAT_S32 && af->data->format == AF_FORMAT_S24) {
- size_t len = mp_audio_psize(mpa) / mpa->bps;
- for (int s = 0; s < len; s++) {
- uint32_t val = *((uint32_t *)mpa->planes[0] + s);
- uint8_t *ptr = (uint8_t *)mpa->planes[0] + s * 3;
- ptr[0] = val >> SHIFT24(0);
- ptr[1] = val >> SHIFT24(1);
- ptr[2] = val >> SHIFT24(2);
- }
- mp_audio_set_format(mpa, AF_FORMAT_S24);
- }
-
for (int p = 0; p < mpa->num_planes; p++) {
void *ptr = mpa->planes[p];
int total = mpa->samples * mpa->spf;
diff --git a/audio/format.c b/audio/format.c
index efbb605d98..9a0ebbee42 100644
--- a/audio/format.c
+++ b/audio/format.c
@@ -28,7 +28,6 @@ int af_fmt_to_bytes(int format)
switch (af_fmt_from_planar(format)) {
case AF_FORMAT_U8: return 1;
case AF_FORMAT_S16: return 2;
- case AF_FORMAT_S24: return 3;
case AF_FORMAT_S32: return 4;
case AF_FORMAT_FLOAT: return 4;
case AF_FORMAT_DOUBLE: return 8;
@@ -38,20 +37,6 @@ int af_fmt_to_bytes(int format)
return 0;
}
-int af_fmt_change_bytes(int format, int bytes)
-{
- if (!af_fmt_is_valid(format) || !bytes)
- return 0;
- for (int fmt = 1; fmt < AF_FORMAT_COUNT; fmt++) {
- if (af_fmt_to_bytes(fmt) == bytes &&
- af_fmt_is_float(fmt) == af_fmt_is_float(format) &&
- af_fmt_is_planar(fmt) == af_fmt_is_planar(format) &&
- (fmt == format || (!af_fmt_is_spdif(fmt) && !af_fmt_is_spdif(format))))
- return fmt;
- }
- return 0;
-}
-
// All formats are considered signed, except explicitly unsigned int formats.
bool af_fmt_is_unsigned(int format)
{
@@ -130,7 +115,6 @@ const char *af_fmt_to_str(int format)
switch (format) {
case AF_FORMAT_U8: return "u8";
case AF_FORMAT_S16: return "s16";
- case AF_FORMAT_S24: return "s24";
case AF_FORMAT_S32: return "s32";
case AF_FORMAT_FLOAT: return "float";
case AF_FORMAT_DOUBLE: return "double";
diff --git a/audio/format.h b/audio/format.h
index ace19da5e5..6d6485ff68 100644
--- a/audio/format.h
+++ b/audio/format.h
@@ -26,7 +26,6 @@ enum af_format {
AF_FORMAT_U8,
AF_FORMAT_S16,
- AF_FORMAT_S24,
AF_FORMAT_S32,
AF_FORMAT_FLOAT,
AF_FORMAT_DOUBLE,
@@ -53,7 +52,6 @@ enum af_format {
const char *af_fmt_to_str(int format);
int af_fmt_to_bytes(int format);
-int af_fmt_change_bytes(int format, int bytes);
bool af_fmt_is_valid(int format);
bool af_fmt_is_unsigned(int format);