diff options
Diffstat (limited to 'libavcodec/alac.c')
-rw-r--r-- | libavcodec/alac.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 07b03c126f..c5a8b5d8c6 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -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(AVCodecContext *avctx, /* 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(AVCodecContext *avctx, 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(AVCodecContext * avctx) { 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; } |