static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,

                             AVPacket *avpkt) {

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    AVSContext *h = avctx->priv_data;

    MpegEncContext *s = &h->s;

    int input_size;

    const uint8_t *buf_end;

    const uint8_t *buf_ptr;

    AVFrame *picture = data;

    uint32_t stc = -1;



    s->avctx = avctx;



    if (buf_size == 0) {

        if (!s->low_delay && h->DPB[0].f.data[0]) {

            *data_size = sizeof(AVPicture);

            *picture = *(AVFrame *) &h->DPB[0];

        }

        return 0;

    }



    buf_ptr = buf;

    buf_end = buf + buf_size;

    for(;;) {

        buf_ptr = ff_find_start_code(buf_ptr,buf_end, &stc);

        if(stc & 0xFFFFFE00)

            return FFMAX(0, buf_ptr - buf - s->parse_context.last_index);

        input_size = (buf_end - buf_ptr)*8;

        switch(stc) {

        case CAVS_START_CODE:

            init_get_bits(&s->gb, buf_ptr, input_size);

            decode_seq_header(h);

            break;

        case PIC_I_START_CODE:

            if(!h->got_keyframe) {

                if(h->DPB[0].f.data[0])

                    avctx->release_buffer(avctx, (AVFrame *)&h->DPB[0]);

                if(h->DPB[1].f.data[0])

                    avctx->release_buffer(avctx, (AVFrame *)&h->DPB[1]);

                h->got_keyframe = 1;

            }

        case PIC_PB_START_CODE:

            *data_size = 0;

            if(!h->got_keyframe)

                break;

            init_get_bits(&s->gb, buf_ptr, input_size);

            h->stc = stc;

            if(decode_pic(h))

                break;

            *data_size = sizeof(AVPicture);

            if(h->pic_type != AV_PICTURE_TYPE_B) {

                if(h->DPB[1].f.data[0]) {

                    *picture = *(AVFrame *) &h->DPB[1];

                } else {

                    *data_size = 0;

                }

            } else

                *picture = *(AVFrame *) &h->picture;

            break;

        case EXT_START_CODE:

            //mpeg_decode_extension(avctx,buf_ptr, input_size);

            break;

        case USER_START_CODE:

            //mpeg_decode_user_data(avctx,buf_ptr, input_size);

            break;

        default:

            if (stc <= SLICE_MAX_START_CODE) {

                init_get_bits(&s->gb, buf_ptr, input_size);

                decode_slice_header(h, &s->gb);

            }

            break;

        }

    }

}

static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,

                             AVPacket *avpkt) {

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    AVSContext *h = avctx->priv_data;

    MpegEncContext *s = &h->s;

    int input_size;

    const uint8_t *buf_end;

    const uint8_t *buf_ptr;

    AVFrame *picture = data;

    uint32_t stc = -1;



    s->avctx = avctx;



    if (buf_size == 0) {

        if (!s->low_delay && h->DPB[0].f.data[0]) {

            *data_size = sizeof(AVPicture);

            *picture = *(AVFrame *) &h->DPB[0];

        }

        return 0;

    }



    buf_ptr = buf;

    buf_end = buf + buf_size;

    for(;;) {

        buf_ptr = ff_find_start_code(buf_ptr,buf_end, &stc);

        if(stc & 0xFFFFFE00)

            return FFMAX(0, buf_ptr - buf - s->parse_context.last_index);

        input_size = (buf_end - buf_ptr)*8;

        switch(stc) {

        case CAVS_START_CODE:

            init_get_bits(&s->gb, buf_ptr, input_size);

            decode_seq_header(h);

            break;

        case PIC_I_START_CODE:

            if(!h->got_keyframe) {

                if(h->DPB[0].f.data[0])

                    avctx->release_buffer(avctx, (AVFrame *)&h->DPB[0]);

                if(h->DPB[1].f.data[0])

                    avctx->release_buffer(avctx, (AVFrame *)&h->DPB[1]);

                h->got_keyframe = 1;

            }

        case PIC_PB_START_CODE:

            *data_size = 0;

            if(!h->got_keyframe)

                break;

            init_get_bits(&s->gb, buf_ptr, input_size);

            h->stc = stc;

            if(decode_pic(h))

                break;

            *data_size = sizeof(AVPicture);

            if(h->pic_type != AV_PICTURE_TYPE_B) {

                if(h->DPB[1].f.data[0]) {

                    *picture = *(AVFrame *) &h->DPB[1];

                } else {

                    *data_size = 0;

                }

            } else

                *picture = *(AVFrame *) &h->picture;

            break;

        case EXT_START_CODE:

            

            break;

        case USER_START_CODE:

            

            break;

        default:

            if (stc <= SLICE_MAX_START_CODE) {

                init_get_bits(&s->gb, buf_ptr, input_size);

                decode_slice_header(h, &s->gb);

            }

            break;

        }

    }

}

        if(stc & 0xFFFFFE00)
static int FUNC_0(AVCodecContext * VAR_0,void *VAR_1, int *VAR_2,

                             AVPacket *VAR_3) {

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    int VAR_5 = VAR_3->size;

    AVSContext *h = VAR_0->priv_data;

    MpegEncContext *s = &h->s;

    int VAR_6;

    const uint8_t *VAR_7;

    const uint8_t *VAR_8;

    AVFrame *picture = VAR_1;

    uint32_t stc = -1;



    s->VAR_0 = VAR_0;



    if (VAR_5 == 0) {

        if (!s->low_delay && h->DPB[0].f.VAR_1[0]) {

            *VAR_2 = sizeof(AVPicture);

            *picture = *(AVFrame *) &h->DPB[0];

        }

        return 0;

    }



    VAR_8 = VAR_4;

    VAR_7 = VAR_4 + VAR_5;

    for(;;) {

        VAR_8 = ff_find_start_code(VAR_8,VAR_7, &stc);

        if(stc & 0xFFFFFE00)

            return FFMAX(0, VAR_8 - VAR_4 - s->parse_context.last_index);

        VAR_6 = (VAR_7 - VAR_8)*8;

        switch(stc) {

        case CAVS_START_CODE:

            init_get_bits(&s->gb, VAR_8, VAR_6);

            decode_seq_header(h);

            break;

        case PIC_I_START_CODE:

            if(!h->got_keyframe) {

                if(h->DPB[0].f.VAR_1[0])

                    VAR_0->release_buffer(VAR_0, (AVFrame *)&h->DPB[0]);

                if(h->DPB[1].f.VAR_1[0])

                    VAR_0->release_buffer(VAR_0, (AVFrame *)&h->DPB[1]);

                h->got_keyframe = 1;

            }

        case PIC_PB_START_CODE:

            *VAR_2 = 0;

            if(!h->got_keyframe)

                break;

            init_get_bits(&s->gb, VAR_8, VAR_6);

            h->stc = stc;

            if(decode_pic(h))

                break;

            *VAR_2 = sizeof(AVPicture);

            if(h->pic_type != AV_PICTURE_TYPE_B) {

                if(h->DPB[1].f.VAR_1[0]) {

                    *picture = *(AVFrame *) &h->DPB[1];

                } else {

                    *VAR_2 = 0;

                }

            } else

                *picture = *(AVFrame *) &h->picture;

            break;

        case EXT_START_CODE:

            

            break;

        case USER_START_CODE:

            

            break;

        default:

            if (stc <= SLICE_MAX_START_CODE) {

                init_get_bits(&s->gb, VAR_8, VAR_6);

                decode_slice_header(h, &s->gb);

            }

            break;

        }

    }

}

static int FUNC_0(AVCodecContext * VAR_0,void *VAR_1, int *VAR_2,
AVPacket *VAR_3) { const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; AVSContext *h = VAR_0->priv_data; MpegEncContext *s = &h->s; int VAR_6; const uint8_t *VAR_7; const uint8_t *VAR_8; AVFrame *picture = VAR_1; uint32_t stc = -1; s->VAR_0 = VAR_0; if (VAR_5 == 0) { if (!s->low_delay && h->DPB[0].f.VAR_1[0]) { *VAR_2 = sizeof(AVPicture); *picture = *(AVFrame *) &h->DPB[0]; } return 0; } VAR_8 = VAR_4; VAR_7 = VAR_4 + VAR_5; for(;;) { VAR_8 = ff_find_start_code(VAR_8,VAR_7, &stc); if(stc & 0xFFFFFE00)
return FFMAX(0, VAR_8 - VAR_4 - s->parse_context.last_index); VAR_6 = (VAR_7 - VAR_8)*8; switch(stc) { case CAVS_START_CODE:
init_get_bits(&s->gb, VAR_8, VAR_6); decode_seq_header(h); break; case PIC_I_START_CODE:
if(!h->got_keyframe) { if(h->DPB[0].f.VAR_1[0])
VAR_0->release_buffer(VAR_0, (AVFrame *)&h->DPB[0]); if(h->DPB[1].f.VAR_1[0])
VAR_0->release_buffer(VAR_0, (AVFrame *)&h->DPB[1]); h->got_keyframe = 1; } case PIC_PB_START_CODE:
*VAR_2 = 0; if(!h->got_keyframe)
break; init_get_bits(&s->gb, VAR_8, VAR_6); h->stc = stc; if(decode_pic(h))
break; *VAR_2 = sizeof(AVPicture); if(h->pic_type != AV_PICTURE_TYPE_B) { if(h->DPB[1].f.VAR_1[0]) { *picture = *(AVFrame *) &h->DPB[1]; } else { *VAR_2 = 0; } } else *picture = *(AVFrame *) &h->picture; break; case EXT_START_CODE:
break; case USER_START_CODE:
break; default:
if (stc <= SLICE_MAX_START_CODE) { init_get_bits(&s->gb, VAR_8, VAR_6); decode_slice_header(h, &s->gb); } break; } } }