Commit f24cc1b2 authored by Justin Ruggles's avatar Justin Ruggles

alacenc: use s16p sample format as input

parent 358078d9
...@@ -78,17 +78,15 @@ typedef struct AlacEncodeContext { ...@@ -78,17 +78,15 @@ typedef struct AlacEncodeContext {
} AlacEncodeContext; } AlacEncodeContext;
static void init_sample_buffers(AlacEncodeContext *s, static void init_sample_buffers(AlacEncodeContext *s, int16_t **input_samples)
const int16_t *input_samples)
{ {
int ch, i; int ch, i;
for (ch = 0; ch < s->avctx->channels; ch++) { for (ch = 0; ch < s->avctx->channels; ch++) {
const int16_t *sptr = input_samples + ch; int32_t *bptr = s->sample_buf[ch];
for (i = 0; i < s->frame_size; i++) { const int16_t *sptr = input_samples[ch];
s->sample_buf[ch][i] = *sptr; for (i = 0; i < s->frame_size; i++)
sptr += s->avctx->channels; bptr[i] = sptr[i];
}
} }
} }
...@@ -347,8 +345,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) ...@@ -347,8 +345,7 @@ static void alac_entropy_coder(AlacEncodeContext *s)
} }
} }
static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, int16_t **samples)
const int16_t *samples)
{ {
int i, j; int i, j;
int prediction_type = 0; int prediction_type = 0;
...@@ -358,8 +355,10 @@ static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, ...@@ -358,8 +355,10 @@ static int write_frame(AlacEncodeContext *s, AVPacket *avpkt,
if (s->verbatim) { if (s->verbatim) {
write_frame_header(s); write_frame_header(s);
for (i = 0; i < s->frame_size * s->avctx->channels; i++) /* samples are channel-interleaved in verbatim mode */
put_sbits(pb, 16, *samples++); for (i = 0; i < s->frame_size; i++)
for (j = 0; j < s->avctx->channels; j++)
put_sbits(pb, 16, samples[j][i]);
} else { } else {
init_sample_buffers(s, samples); init_sample_buffers(s, samples);
write_frame_header(s); write_frame_header(s);
...@@ -537,7 +536,7 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -537,7 +536,7 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
{ {
AlacEncodeContext *s = avctx->priv_data; AlacEncodeContext *s = avctx->priv_data;
int out_bytes, max_frame_size, ret; int out_bytes, max_frame_size, ret;
const int16_t *samples = (const int16_t *)frame->data[0]; int16_t **samples = (int16_t **)frame->extended_data;
s->frame_size = frame->nb_samples; s->frame_size = frame->nb_samples;
...@@ -577,7 +576,7 @@ AVCodec ff_alac_encoder = { ...@@ -577,7 +576,7 @@ AVCodec ff_alac_encoder = {
.encode2 = alac_encode_frame, .encode2 = alac_encode_frame,
.close = alac_encode_close, .close = alac_encode_close,
.capabilities = CODEC_CAP_SMALL_LAST_FRAME, .capabilities = CODEC_CAP_SMALL_LAST_FRAME,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16P,
AV_SAMPLE_FMT_NONE }, AV_SAMPLE_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
}; };
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