1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

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
This commit is contained in:
Mike Melanson 2005-03-06 07:00:24 +00:00
parent 7ff85a81ed
commit f770ee038f
3 changed files with 17 additions and 46 deletions

View File

@ -11,6 +11,7 @@ version <next>
- Nullsoft Video (NSV) file demuxer - Nullsoft Video (NSV) file demuxer
- Shorten audio decoder - Shorten audio decoder
- LOCO video decoder - LOCO video decoder
- Apple Lossless Audio Codec (ALAC) decoder
version 0.4.9-pre1: version 0.4.9-pre1:

View File

@ -837,6 +837,8 @@ solutions.
@item Apple MACE 6 @tab @tab X @item Apple MACE 6 @tab @tab X
@item FLAC lossless audio @tab @tab X @item FLAC lossless audio @tab @tab X
@item Shorten 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 @item FFmpeg Sonic @tab X @tab X
@tab Experimental lossy/lossless codec @tab Experimental lossy/lossless codec
@end multitable @end multitable

View File

@ -132,7 +132,7 @@ static uint32_t readbits_16(alac_file *alac, int bits)
int new_accumulator; int new_accumulator;
if (alac->input_buffer_index + 2 >= alac->input_buffer_size) { 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); alac->input_buffer_index + 2, alac->input_buffer_size);
// exit (0); // exit (0);
} }
@ -184,9 +184,9 @@ static int readbit(alac_file *alac)
int new_accumulator; int new_accumulator;
if (alac->input_buffer_index >= alac->input_buffer_size) { 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); alac->input_buffer_index + 2, alac->input_buffer_size);
// exit (0); exit (0);
} }
result = alac->input_buffer[alac->input_buffer_index]; 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)) left = (midright - ((difference * interlacing_leftweight) >> interlacing_shift))
+ difference; + difference;
/* output is always little endian */
/*
if (host_bigendian) {
be2me_16(left);
be2me_16(right);
}
*/
buffer_out[i*numchannels] = left; buffer_out[i*numchannels] = left;
buffer_out[i*numchannels + 1] = right; 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]; left = buffer_a[i];
right = buffer_b[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] = left;
buffer_out[i*numchannels + 1] = right; buffer_out[i*numchannels + 1] = right;
} }
} }
int decode_frame(ALACContext *s, alac_file *alac, static int alac_decode_frame(AVCodecContext *avctx,
unsigned char *inbuffer, void *outbuffer, int *outputsize,
int input_buffer_size, uint8_t *inbuffer, int input_buffer_size)
void *outbuffer, int *outputsize)
{ {
ALACContext *s = avctx->priv_data;
alac_file *alac = s->alac;
int channels; int channels;
int32_t outputsamples; int32_t outputsamples;
/* short-circuit null buffers */
if (!inbuffer || !input_buffer_size)
return input_buffer_size;
/* initialize from the extradata */ /* initialize from the extradata */
if (!s->context_initialized) { if (!s->context_initialized) {
if (s->avctx->extradata_size != ALAC_EXTRADATA_SIZE) { 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", return input_buffer_size;
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;
} }
static int alac_decode_init(AVCodecContext * avctx) static int alac_decode_init(AVCodecContext * avctx)
@ -932,20 +914,6 @@ static int alac_decode_init(AVCodecContext * avctx)
return 0; 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) static int alac_decode_close(AVCodecContext *avctx)
{ {
ALACContext *s = avctx->priv_data; ALACContext *s = avctx->priv_data;