diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index bc1ed60bf0..b6dd5f2d3f 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -1266,10 +1266,11 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, av_log(h->avctx, AV_LOG_WARNING, "no frame decoded\n"); return FFMAX(0, buf_ptr - buf); } - input_size = (buf_end - buf_ptr) * 8; + input_size = buf_end - buf_ptr; + if ((ret = init_get_bits8(&h->gb, buf_ptr, input_size)) < 0) + return ret; switch (stc) { case CAVS_START_CODE: - init_get_bits(&h->gb, buf_ptr, input_size); decode_seq_header(h); break; case PIC_I_START_CODE: @@ -1288,7 +1289,6 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, *got_frame = 0; if (!h->got_keyframe) break; - init_get_bits(&h->gb, buf_ptr, input_size); h->stc = stc; if (decode_pic(h)) break; @@ -1312,7 +1312,6 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, break; default: if (stc <= SLICE_MAX_START_CODE) { - init_get_bits(&h->gb, buf_ptr, input_size); decode_slice_header(h, &h->gb); } break;