[FFmpeg-cvslog] r25572 - trunk/libavcodec/alac.c
darkshikari
subversion
Tue Oct 26 09:20:51 CEST 2010
Author: darkshikari
Date: Tue Oct 26 09:20:51 2010
New Revision: 25572
Log:
Clean up ALACdec
Do decode init in the init function instead of at the first frame.
Fix some possible crash cases.
Modified:
trunk/libavcodec/alac.c
Modified: trunk/libavcodec/alac.c
==============================================================================
--- trunk/libavcodec/alac.c Tue Oct 26 03:59:14 2010 (r25571)
+++ trunk/libavcodec/alac.c Tue Oct 26 09:20:51 2010 (r25572)
@@ -65,9 +65,6 @@ typedef struct {
AVCodecContext *avctx;
GetBitContext gb;
- /* init to 0; first frame decode should initialize from extradata and
- * set this to 1 */
- int context_initialized;
int numchannels;
int bytespersample;
@@ -471,21 +468,7 @@ static int alac_decode_frame(AVCodecCont
/* short-circuit null buffers */
if (!inbuffer || !input_buffer_size)
- return input_buffer_size;
-
- /* initialize from the extradata */
- if (!alac->context_initialized) {
- if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
- av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
- ALAC_EXTRADATA_SIZE);
- return input_buffer_size;
- }
- if (alac_set_info(alac)) {
- av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
- return input_buffer_size;
- }
- alac->context_initialized = 1;
- }
+ return -1;
init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
@@ -493,7 +476,7 @@ static int alac_decode_frame(AVCodecCont
if (channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "channels > %d not supported\n",
MAX_CHANNELS);
- return input_buffer_size;
+ return -1;
}
/* 2^result = something to do with output waiting.
@@ -678,10 +661,19 @@ static av_cold int alac_decode_init(AVCo
{
ALACContext *alac = avctx->priv_data;
alac->avctx = avctx;
- alac->context_initialized = 0;
-
alac->numchannels = alac->avctx->channels;
+ /* initialize from the extradata */
+ if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
+ av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
+ ALAC_EXTRADATA_SIZE);
+ return -1;
+ }
+ if (alac_set_info(alac)) {
+ av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
+ return -1;
+ }
+
return 0;
}
More information about the ffmpeg-cvslog
mailing list