Commit 6cda74c1 authored by Andrew D'Addesio's avatar Andrew D'Addesio Committed by Justin Ruggles

alac: simplify channel interleaving

Signed-off-by: 's avatarJustin Ruggles <justin.ruggles@gmail.com>
parent 5138ff14
...@@ -266,28 +266,6 @@ static void append_extra_bits(int32_t *buffer[MAX_CHANNELS], ...@@ -266,28 +266,6 @@ static void append_extra_bits(int32_t *buffer[MAX_CHANNELS],
buffer[ch][i] = (buffer[ch][i] << extra_bits) | extra_bits_buffer[ch][i]; buffer[ch][i] = (buffer[ch][i] << extra_bits) | extra_bits_buffer[ch][i];
} }
static void interleave_stereo_16(int32_t *buffer[MAX_CHANNELS],
int16_t *buffer_out, int numsamples)
{
int i;
for (i = 0; i < numsamples; i++) {
*buffer_out++ = buffer[0][i];
*buffer_out++ = buffer[1][i];
}
}
static void interleave_stereo_24(int32_t *buffer[MAX_CHANNELS],
int32_t *buffer_out, int numsamples)
{
int i;
for (i = 0; i < numsamples; i++) {
*buffer_out++ = buffer[0][i] << 8;
*buffer_out++ = buffer[1][i] << 8;
}
}
static int alac_decode_frame(AVCodecContext *avctx, void *data, static int alac_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt) int *got_frame_ptr, AVPacket *avpkt)
{ {
...@@ -430,28 +408,21 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data, ...@@ -430,28 +408,21 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
} }
switch(alac->sample_size) { switch(alac->sample_size) {
case 16: case 16: {
if (channels == 2) {
interleave_stereo_16(alac->output_samples_buffer,
(int16_t *)alac->frame.data[0],
alac->nb_samples);
} else {
int16_t *outbuffer = (int16_t *)alac->frame.data[0]; int16_t *outbuffer = (int16_t *)alac->frame.data[0];
for (i = 0; i < alac->nb_samples; i++) { for (i = 0; i < alac->nb_samples; i++) {
outbuffer[i] = alac->output_samples_buffer[0][i]; *outbuffer++ = alac->output_samples_buffer[0][i];
} if (channels == 2)
} *outbuffer++ = alac->output_samples_buffer[1][i];
}}
break; break;
case 24: case 24: {
if (channels == 2) {
interleave_stereo_24(alac->output_samples_buffer,
(int32_t *)alac->frame.data[0],
alac->nb_samples);
} else {
int32_t *outbuffer = (int32_t *)alac->frame.data[0]; int32_t *outbuffer = (int32_t *)alac->frame.data[0];
for (i = 0; i < alac->nb_samples; i++) for (i = 0; i < alac->nb_samples; i++) {
outbuffer[i] = alac->output_samples_buffer[0][i] << 8; *outbuffer++ = alac->output_samples_buffer[0][i] << 8;
} if (channels == 2)
*outbuffer++ = alac->output_samples_buffer[1][i] << 8;
}}
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment