audio_format: remove the packed S24 format

For simplicity, the MPD core should not have to deal with packing.  It
is rarely used, and those plugins that need it should use the
pcm_export library instead.
This commit is contained in:
Max Kellermann 2012-03-21 19:37:33 +01:00
parent 208a96b211
commit b99ecb4dc9
14 changed files with 4 additions and 155 deletions

View File

@ -63,9 +63,6 @@ sample_format_to_string(enum sample_format format)
case SAMPLE_FORMAT_S16:
return "16";
case SAMPLE_FORMAT_S24:
return "24_3";
case SAMPLE_FORMAT_S24_P32:
return "24";

View File

@ -31,11 +31,6 @@ enum sample_format {
SAMPLE_FORMAT_S8,
SAMPLE_FORMAT_S16,
/**
* Signed 24 bit integer samples, without padding.
*/
SAMPLE_FORMAT_S24,
/**
* Signed 24 bit integer samples, packed in 32 bit integers
* (the most significant byte is filled with the sign bit).
@ -175,7 +170,6 @@ audio_valid_sample_format(enum sample_format format)
switch (format) {
case SAMPLE_FORMAT_S8:
case SAMPLE_FORMAT_S16:
case SAMPLE_FORMAT_S24:
case SAMPLE_FORMAT_S24_P32:
case SAMPLE_FORMAT_S32:
case SAMPLE_FORMAT_FLOAT:
@ -248,9 +242,6 @@ sample_format_size(enum sample_format format)
case SAMPLE_FORMAT_S16:
return 2;
case SAMPLE_FORMAT_S24:
return 3;
case SAMPLE_FORMAT_S24_P32:
case SAMPLE_FORMAT_S32:
case SAMPLE_FORMAT_FLOAT:

View File

@ -116,11 +116,11 @@ parse_sample_format(const char *src, bool mask,
break;
case 24:
if (memcmp(endptr, "_3", 2) == 0) {
sample_format = SAMPLE_FORMAT_S24;
if (memcmp(endptr, "_3", 2) == 0)
/* for backwards compatibility */
endptr += 2;
} else
sample_format = SAMPLE_FORMAT_S24_P32;
sample_format = SAMPLE_FORMAT_S24_P32;
break;
case 32:

View File

@ -101,7 +101,6 @@ flac_convert(void *dest,
position, end);
break;
case SAMPLE_FORMAT_S24:
case SAMPLE_FORMAT_FLOAT:
case SAMPLE_FORMAT_DSD:
case SAMPLE_FORMAT_DSD_OVER_USB:

View File

@ -122,11 +122,6 @@ wave_encoder_open(struct encoder *_encoder,
encoder->bits = 16;
break;
case SAMPLE_FORMAT_S24:
audio_format->format = SAMPLE_FORMAT_S24_P32;
encoder->bits = 24;
break;
case SAMPLE_FORMAT_S24_P32:
encoder->bits = 24;
break;

View File

@ -211,7 +211,6 @@ get_bitformat(enum sample_format sample_format)
case SAMPLE_FORMAT_UNDEFINED:
case SAMPLE_FORMAT_DSD:
case SAMPLE_FORMAT_DSD_OVER_USB:
case SAMPLE_FORMAT_S24:
return SND_PCM_FORMAT_UNKNOWN;
case SAMPLE_FORMAT_S8:

View File

@ -434,7 +434,6 @@ sample_format_to_oss(enum sample_format format)
case SAMPLE_FORMAT_FLOAT:
case SAMPLE_FORMAT_DSD:
case SAMPLE_FORMAT_DSD_OVER_USB:
case SAMPLE_FORMAT_S24:
return AFMT_QUERY;
case SAMPLE_FORMAT_S8:

View File

@ -167,10 +167,6 @@ roar_use_audio_format(struct roar_audio_info *info,
info->bits = 16;
break;
case SAMPLE_FORMAT_S24:
info->bits = 24;
break;
case SAMPLE_FORMAT_S24_P32:
info->bits = 32;
audio_format->format = SAMPLE_FORMAT_S32;

View File

@ -161,7 +161,6 @@ winmm_output_open(struct audio_output *ao, struct audio_format *audio_format,
case SAMPLE_FORMAT_S16:
break;
case SAMPLE_FORMAT_S24:
case SAMPLE_FORMAT_S24_P32:
case SAMPLE_FORMAT_S32:
case SAMPLE_FORMAT_UNDEFINED:

View File

@ -42,7 +42,6 @@ void pcm_convert_init(struct pcm_convert_state *state)
pcm_dither_24_init(&state->dither);
pcm_buffer_init(&state->format_buffer);
pcm_buffer_init(&state->pack_buffer);
pcm_buffer_init(&state->channels_buffer);
}
@ -52,7 +51,6 @@ void pcm_convert_deinit(struct pcm_convert_state *state)
pcm_resample_deinit(&state->resample);
pcm_buffer_deinit(&state->format_buffer);
pcm_buffer_deinit(&state->pack_buffer);
pcm_buffer_deinit(&state->channels_buffer);
}
@ -75,7 +73,6 @@ pcm_convert_channels(struct pcm_buffer *buffer, enum sample_format format,
switch (format) {
case SAMPLE_FORMAT_UNDEFINED:
case SAMPLE_FORMAT_S8:
case SAMPLE_FORMAT_S24:
case SAMPLE_FORMAT_FLOAT:
case SAMPLE_FORMAT_DSD:
case SAMPLE_FORMAT_DSD_OVER_USB:
@ -215,45 +212,6 @@ pcm_convert_24(struct pcm_convert_state *state,
return buf;
}
/**
* Convert to 24 bit packed samples (aka S24_3LE / S24_3BE).
*/
static const void *
pcm_convert_24_packed(struct pcm_convert_state *state,
const struct audio_format *src_format,
const void *src_buffer, size_t src_size,
const struct audio_format *dest_format,
size_t *dest_size_r,
GError **error_r)
{
assert(dest_format->format == SAMPLE_FORMAT_S24);
/* use the normal 24 bit conversion first */
struct audio_format audio_format;
audio_format_init(&audio_format, dest_format->sample_rate,
SAMPLE_FORMAT_S24_P32, dest_format->channels);
const int32_t *buffer;
size_t buffer_size;
buffer = pcm_convert_24(state, src_format, src_buffer, src_size,
&audio_format, &buffer_size, error_r);
if (buffer == NULL)
return NULL;
/* now convert to packed 24 bit */
unsigned num_samples = buffer_size / 4;
size_t dest_size = num_samples * 3;
uint8_t *dest = pcm_buffer_get(&state->pack_buffer, dest_size);
pcm_pack_24(dest, buffer, buffer + num_samples);
*dest_size_r = dest_size;
return dest;
}
static const int32_t *
pcm_convert_32(struct pcm_convert_state *state,
const struct audio_format *src_format,
@ -395,12 +353,6 @@ pcm_convert(struct pcm_convert_state *state,
dest_format, dest_size_r,
error_r);
case SAMPLE_FORMAT_S24:
return pcm_convert_24_packed(state,
src_format, src, src_size,
dest_format, dest_size_r,
error_r);
case SAMPLE_FORMAT_S24_P32:
return pcm_convert_24(state,
src_format, src, src_size,

View File

@ -42,9 +42,6 @@ struct pcm_convert_state {
/** the buffer for converting the sample format */
struct pcm_buffer format_buffer;
/** the buffer for converting to/from packed samples */
struct pcm_buffer pack_buffer;
/** the buffer for converting the channel count */
struct pcm_buffer channels_buffer;
};

View File

@ -69,33 +69,6 @@ pcm_allocate_8_to_16(struct pcm_buffer *buffer,
return dest;
}
static int32_t *
pcm_allocate_24_to_24p32(struct pcm_buffer *buffer, const uint8_t *src,
size_t src_size, size_t *dest_size_r)
{
int32_t *dest;
*dest_size_r = src_size / 3 * sizeof(*dest);
dest = pcm_buffer_get(buffer, *dest_size_r);
pcm_unpack_24(dest, src, pcm_end_pointer(src, src_size));
return dest;
}
static int16_t *
pcm_allocate_24_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither,
const uint8_t *src, size_t src_size, size_t *dest_size_r)
{
/* convert to S24_P32 first */
size_t tmp_size;
int32_t *tmp = pcm_allocate_24_to_24p32(buffer, src, src_size,
&tmp_size);
/* convert to 16 bit in-place */
int16_t *dest = (int16_t *)tmp;
*dest_size_r = tmp_size / sizeof(*tmp) * sizeof(*dest);
pcm_convert_24_to_16(dither, dest, tmp, pcm_end_pointer(tmp, tmp_size));
return dest;
}
static int16_t *
pcm_allocate_24p32_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither,
const int32_t *src, size_t src_size,
@ -159,10 +132,6 @@ pcm_convert_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither,
*dest_size_r = src_size;
return src;
case SAMPLE_FORMAT_S24:
return pcm_allocate_24_to_16(buffer, dither,
src, src_size, dest_size_r);
case SAMPLE_FORMAT_S24_P32:
return pcm_allocate_24p32_to_16(buffer, dither, src, src_size,
dest_size_r);
@ -279,10 +248,6 @@ pcm_convert_to_24(struct pcm_buffer *buffer,
return pcm_allocate_16_to_24(buffer,
src, src_size, dest_size_r);
case SAMPLE_FORMAT_S24:
return pcm_allocate_24_to_24p32(buffer, src, src_size,
dest_size_r);
case SAMPLE_FORMAT_S24_P32:
*dest_size_r = src_size;
return src;
@ -345,20 +310,6 @@ pcm_allocate_16_to_32(struct pcm_buffer *buffer,
return dest;
}
static int32_t *
pcm_allocate_24_to_32(struct pcm_buffer *buffer,
const uint8_t *src,
size_t src_size, size_t *dest_size_r)
{
/* convert to S24_P32 first */
int32_t *dest = pcm_allocate_24_to_24p32(buffer, src, src_size,
dest_size_r);
/* convert to 32 bit in-place */
pcm_convert_24_to_32(dest, dest, pcm_end_pointer(dest, *dest_size_r));
return dest;
}
static int32_t *
pcm_allocate_24p32_to_32(struct pcm_buffer *buffer,
const int32_t *src, size_t src_size,
@ -405,10 +356,6 @@ pcm_convert_to_32(struct pcm_buffer *buffer,
return pcm_allocate_16_to_32(buffer, src, src_size,
dest_size_r);
case SAMPLE_FORMAT_S24:
return pcm_allocate_24_to_32(buffer, src, src_size,
dest_size_r);
case SAMPLE_FORMAT_S24_P32:
return pcm_allocate_24p32_to_32(buffer, src, src_size,
dest_size_r);
@ -486,21 +433,6 @@ pcm_allocate_16_to_float(struct pcm_buffer *buffer,
return dest;
}
static float *
pcm_allocate_24_to_float(struct pcm_buffer *buffer,
const uint8_t *src,
size_t src_size, size_t *dest_size_r)
{
/* convert to S24_P32 first */
int32_t *tmp = pcm_allocate_24_to_24p32(buffer, src, src_size,
dest_size_r);
/* convert to float in-place */
float *dest = (float *)tmp;
pcm_convert_24_to_float(dest, tmp, pcm_end_pointer(tmp, *dest_size_r));
return dest;
}
static float *
pcm_allocate_24p32_to_float(struct pcm_buffer *buffer,
const int32_t *src, size_t src_size,
@ -542,10 +474,6 @@ pcm_convert_to_float(struct pcm_buffer *buffer,
return pcm_allocate_16_to_float(buffer,
src, src_size, dest_size_r);
case SAMPLE_FORMAT_S24:
return pcm_allocate_24_to_float(buffer,
src, src_size, dest_size_r);
case SAMPLE_FORMAT_S24_P32:
return pcm_allocate_24p32_to_float(buffer,
src, src_size, dest_size_r);

View File

@ -119,7 +119,6 @@ pcm_add_vol(void *buffer1, const void *buffer2, size_t size,
{
switch (format) {
case SAMPLE_FORMAT_UNDEFINED:
case SAMPLE_FORMAT_S24:
case SAMPLE_FORMAT_DSD:
case SAMPLE_FORMAT_DSD_OVER_USB:
/* not implemented */
@ -230,7 +229,6 @@ pcm_add(void *buffer1, const void *buffer2, size_t size,
{
switch (format) {
case SAMPLE_FORMAT_UNDEFINED:
case SAMPLE_FORMAT_S24:
case SAMPLE_FORMAT_DSD:
case SAMPLE_FORMAT_DSD_OVER_USB:
/* not implemented */

View File

@ -158,7 +158,6 @@ pcm_volume(void *buffer, size_t length,
const void *end = pcm_end_pointer(buffer, length);
switch (format) {
case SAMPLE_FORMAT_UNDEFINED:
case SAMPLE_FORMAT_S24:
case SAMPLE_FORMAT_DSD:
case SAMPLE_FORMAT_DSD_OVER_USB:
/* not implemented */