diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-08-23 14:23:08 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-08-23 14:33:33 +0200 |
commit | 104f42e69485557a7d603047e1d29c44bbd12562 (patch) | |
tree | f70179c1693b6fe212ac4090f49ea1ed843f92d4 /libavcodec/alacenc.c | |
parent | c2271fa7f9a88afb374300c7320b57b870969926 (diff) | |
parent | 7b44061f4be1075eefbc2eec649f38dd0dbfcc82 (diff) | |
download | ffmpeg-104f42e69485557a7d603047e1d29c44bbd12562.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
doc/APIchanges: add an entry for codec descriptors.
vorbisenc: set AVCodecContext.bit_rate to 0
vorbisenc: fix quality parameter
FATE: add ALAC encoding tests
lpc: fix alignment of windowed samples for odd maximum LPC order
alacenc: use s16p sample format as input
alacenc: remove unneeded sample_fmt check
alacenc: fix max_frame_size calculation for the final frame
adpcm_swf: Use correct sample offsets when using trellis.
rtmp: support strict rtmp servers
mjpegdec: support AVRn interlaced
x86: remove FASTDIV inline asm
Conflicts:
doc/APIchanges
libavcodec/mjpegdec.c
libavcodec/vorbisenc.c
libavutil/x86/intmath.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/alacenc.c')
-rw-r--r-- | libavcodec/alacenc.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 8b2b513cd7..79b6ba8dd8 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -78,17 +78,15 @@ typedef struct AlacEncodeContext { } AlacEncodeContext; -static void init_sample_buffers(AlacEncodeContext *s, - const int16_t *input_samples) +static void init_sample_buffers(AlacEncodeContext *s, int16_t **input_samples) { int ch, i; for (ch = 0; ch < s->avctx->channels; ch++) { - const int16_t *sptr = input_samples + ch; - for (i = 0; i < s->frame_size; i++) { - s->sample_buf[ch][i] = *sptr; - sptr += s->avctx->channels; - } + int32_t *bptr = s->sample_buf[ch]; + const int16_t *sptr = input_samples[ch]; + for (i = 0; i < s->frame_size; i++) + bptr[i] = sptr[i]; } } @@ -347,8 +345,7 @@ static void alac_entropy_coder(AlacEncodeContext *s) } } -static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, - const int16_t *samples) +static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, int16_t **samples) { int i, j; int prediction_type = 0; @@ -358,8 +355,10 @@ static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, if (s->verbatim) { write_frame_header(s); - for (i = 0; i < s->frame_size * s->avctx->channels; i++) - put_sbits(pb, 16, *samples++); + /* samples are channel-interleaved in verbatim mode */ + for (i = 0; i < s->frame_size; i++) + for (j = 0; j < s->avctx->channels; j++) + put_sbits(pb, 16, samples[j][i]); } else { init_sample_buffers(s, samples); write_frame_header(s); @@ -426,11 +425,6 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) avctx->frame_size = s->frame_size = DEFAULT_FRAME_SIZE; - if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) { - av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n"); - return -1; - } - /* TODO: Correctly implement multi-channel ALAC. It is similar to multi-channel AAC, in that it has a series of single-channel (SCE), channel-pair (CPE), and LFE elements. */ @@ -542,11 +536,11 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, { AlacEncodeContext *s = avctx->priv_data; 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; - if (avctx->frame_size < DEFAULT_FRAME_SIZE) + if (frame->nb_samples < DEFAULT_FRAME_SIZE) max_frame_size = get_max_frame_size(s->frame_size, avctx->channels, DEFAULT_SAMPLE_SIZE); else @@ -580,7 +574,7 @@ AVCodec ff_alac_encoder = { .encode2 = alac_encode_frame, .close = alac_encode_close, .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 }, .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), }; |