From f770ee038f641b0637669756b7aad08b8636148b Mon Sep 17 00:00:00 2001 From: Mike Melanson Date: Sun, 6 Mar 2005 07:00:24 +0000 Subject: [PATCH] decoder works fine now, when fed properly-sized chunks by the demuxer; cleaned up some cruft for this commit Originally committed as revision 4010 to svn://svn.ffmpeg.org/ffmpeg/trunk --- Changelog | 1 + doc/ffmpeg-doc.texi | 2 ++ libavcodec/alac.c | 60 +++++++++++---------------------------------- 3 files changed, 17 insertions(+), 46 deletions(-) diff --git a/Changelog b/Changelog index cf233b3c5d..b21df354ed 100644 --- a/Changelog +++ b/Changelog @@ -11,6 +11,7 @@ version - Nullsoft Video (NSV) file demuxer - Shorten audio decoder - LOCO video decoder +- Apple Lossless Audio Codec (ALAC) decoder version 0.4.9-pre1: diff --git a/doc/ffmpeg-doc.texi b/doc/ffmpeg-doc.texi index af49c2ca3e..24806211a6 100644 --- a/doc/ffmpeg-doc.texi +++ b/doc/ffmpeg-doc.texi @@ -837,6 +837,8 @@ solutions. @item Apple MACE 6 @tab @tab X @item FLAC lossless audio @tab @tab X @item Shorten lossless audio @tab @tab X +@item Apple lossless audio @tab @tab X +@tab QuickTime fourcc 'alac' @item FFmpeg Sonic @tab X @tab X @tab Experimental lossy/lossless codec @end multitable diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 8231fb1f67..c0c7fdf3bf 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -132,7 +132,7 @@ static uint32_t readbits_16(alac_file *alac, int bits) int new_accumulator; if (alac->input_buffer_index + 2 >= alac->input_buffer_size) { - av_log(NULL, AV_LOG_INFO, "alac: input buffer went out of bounds (%d >= %d)\n", + av_log(NULL, AV_LOG_ERROR, "alac: input buffer went out of bounds (%d >= %d)\n", alac->input_buffer_index + 2, alac->input_buffer_size); // exit (0); } @@ -184,9 +184,9 @@ static int readbit(alac_file *alac) int new_accumulator; if (alac->input_buffer_index >= alac->input_buffer_size) { - av_log(NULL, AV_LOG_INFO, "alac: input buffer went out of bounds (%d >= %d)\n", + av_log(NULL, AV_LOG_ERROR, "alac: input buffer went out of bounds (%d >= %d)\n", alac->input_buffer_index + 2, alac->input_buffer_size); -// exit (0); + exit (0); } result = alac->input_buffer[alac->input_buffer_index]; @@ -508,14 +508,6 @@ void deinterlace_16(int32_t *buffer_a, int32_t *buffer_b, left = (midright - ((difference * interlacing_leftweight) >> interlacing_shift)) + difference; - /* output is always little endian */ -/* - if (host_bigendian) { - be2me_16(left); - be2me_16(right); - } -*/ - buffer_out[i*numchannels] = left; buffer_out[i*numchannels + 1] = right; } @@ -530,27 +522,25 @@ void deinterlace_16(int32_t *buffer_a, int32_t *buffer_b, left = buffer_a[i]; right = buffer_b[i]; - /* output is always little endian */ -/* - if (host_bigendian) { - be2me_16(left); - be2me_16(right); - } -*/ - buffer_out[i*numchannels] = left; buffer_out[i*numchannels + 1] = right; } } -int decode_frame(ALACContext *s, alac_file *alac, - unsigned char *inbuffer, - int input_buffer_size, - void *outbuffer, int *outputsize) +static int alac_decode_frame(AVCodecContext *avctx, + void *outbuffer, int *outputsize, + uint8_t *inbuffer, int input_buffer_size) { + ALACContext *s = avctx->priv_data; + alac_file *alac = s->alac; + int channels; int32_t outputsamples; + /* short-circuit null buffers */ + if (!inbuffer || !input_buffer_size) + return input_buffer_size; + /* initialize from the extradata */ if (!s->context_initialized) { if (s->avctx->extradata_size != ALAC_EXTRADATA_SIZE) { @@ -906,15 +896,7 @@ int decode_frame(ALACContext *s, alac_file *alac, } } -av_log(NULL, AV_LOG_INFO, "buf size = %d, consumed %d\n", - input_buffer_size, alac->input_buffer_index); - - /* avoid infinite loop: if decoder consumed 0 bytes; report all bytes - * consumed */ -// if (alac->input_buffer_index) -// return alac->input_buffer_index; -// else - return input_buffer_size; + return input_buffer_size; } static int alac_decode_init(AVCodecContext * avctx) @@ -932,20 +914,6 @@ static int alac_decode_init(AVCodecContext * avctx) return 0; } -static int alac_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - ALACContext *s = avctx->priv_data; - int bytes_consumed = buf_size; - - if (buf) - bytes_consumed = decode_frame(s, s->alac, buf, buf_size, - data, data_size); - - return bytes_consumed; -} - static int alac_decode_close(AVCodecContext *avctx) { ALACContext *s = avctx->priv_data;