mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
300097536d
commit
03596ac551
|
@ -152,17 +152,6 @@ static int rate_from_speed(int rate, double speed)
|
||||||
return lrint(rate * 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] = {
|
static struct mp_chmap fudge_pairs[][2] = {
|
||||||
{MP_CHMAP2(BL, BR), MP_CHMAP2(SL, SR)},
|
{MP_CHMAP2(BL, BR), MP_CHMAP2(SL, SR)},
|
||||||
{MP_CHMAP2(SL, SR), MP_CHMAP2(BL, BR)},
|
{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;
|
goto error;
|
||||||
|
|
||||||
enum AVSampleFormat in_samplefmt = af_to_avformat(in->format);
|
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);
|
enum AVSampleFormat out_samplefmtp = av_get_planar_sample_fmt(out_samplefmt);
|
||||||
|
|
||||||
if (in_samplefmt == AV_SAMPLE_FMT_NONE ||
|
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));
|
mp_audio_set_format(&s->avrctx_fmt, af_from_avformat(out_samplefmtp));
|
||||||
|
|
||||||
s->pre_out_fmt = *out;
|
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
|
// If there are NA channels, the final output will have more channels than
|
||||||
// the avrctx output. Also, avrctx will output planar (out_samplefmtp was
|
// 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)
|
if (af_to_avformat(in->format) == AV_SAMPLE_FMT_NONE)
|
||||||
mp_audio_set_format(in, AF_FORMAT_FLOAT);
|
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);
|
mp_audio_set_format(out, in->format);
|
||||||
|
|
||||||
int r = ((in->format == orig_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)
|
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++) {
|
for (int p = 0; p < mpa->num_planes; p++) {
|
||||||
void *ptr = mpa->planes[p];
|
void *ptr = mpa->planes[p];
|
||||||
int total = mpa->samples * mpa->spf;
|
int total = mpa->samples * mpa->spf;
|
||||||
|
|
|
@ -28,7 +28,6 @@ int af_fmt_to_bytes(int format)
|
||||||
switch (af_fmt_from_planar(format)) {
|
switch (af_fmt_from_planar(format)) {
|
||||||
case AF_FORMAT_U8: return 1;
|
case AF_FORMAT_U8: return 1;
|
||||||
case AF_FORMAT_S16: return 2;
|
case AF_FORMAT_S16: return 2;
|
||||||
case AF_FORMAT_S24: return 3;
|
|
||||||
case AF_FORMAT_S32: return 4;
|
case AF_FORMAT_S32: return 4;
|
||||||
case AF_FORMAT_FLOAT: return 4;
|
case AF_FORMAT_FLOAT: return 4;
|
||||||
case AF_FORMAT_DOUBLE: return 8;
|
case AF_FORMAT_DOUBLE: return 8;
|
||||||
|
@ -38,20 +37,6 @@ int af_fmt_to_bytes(int format)
|
||||||
return 0;
|
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.
|
// All formats are considered signed, except explicitly unsigned int formats.
|
||||||
bool af_fmt_is_unsigned(int format)
|
bool af_fmt_is_unsigned(int format)
|
||||||
{
|
{
|
||||||
|
@ -130,7 +115,6 @@ const char *af_fmt_to_str(int format)
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case AF_FORMAT_U8: return "u8";
|
case AF_FORMAT_U8: return "u8";
|
||||||
case AF_FORMAT_S16: return "s16";
|
case AF_FORMAT_S16: return "s16";
|
||||||
case AF_FORMAT_S24: return "s24";
|
|
||||||
case AF_FORMAT_S32: return "s32";
|
case AF_FORMAT_S32: return "s32";
|
||||||
case AF_FORMAT_FLOAT: return "float";
|
case AF_FORMAT_FLOAT: return "float";
|
||||||
case AF_FORMAT_DOUBLE: return "double";
|
case AF_FORMAT_DOUBLE: return "double";
|
||||||
|
|
|
@ -26,7 +26,6 @@ enum af_format {
|
||||||
|
|
||||||
AF_FORMAT_U8,
|
AF_FORMAT_U8,
|
||||||
AF_FORMAT_S16,
|
AF_FORMAT_S16,
|
||||||
AF_FORMAT_S24,
|
|
||||||
AF_FORMAT_S32,
|
AF_FORMAT_S32,
|
||||||
AF_FORMAT_FLOAT,
|
AF_FORMAT_FLOAT,
|
||||||
AF_FORMAT_DOUBLE,
|
AF_FORMAT_DOUBLE,
|
||||||
|
@ -53,7 +52,6 @@ enum af_format {
|
||||||
const char *af_fmt_to_str(int format);
|
const char *af_fmt_to_str(int format);
|
||||||
|
|
||||||
int af_fmt_to_bytes(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_valid(int format);
|
||||||
bool af_fmt_is_unsigned(int format);
|
bool af_fmt_is_unsigned(int format);
|
||||||
|
|
Loading…
Reference in New Issue