static int svq1_decode_frame_header(GetBitContext *bitbuf, MpegEncContext *s)

{

    int frame_size_code;



    skip_bits(bitbuf, 8); /* temporal_reference */



    /* frame type */

    s->pict_type = get_bits(bitbuf, 2) + 1;

    if (s->pict_type == 4)

        return AVERROR_INVALIDDATA;



    if (s->pict_type == AV_PICTURE_TYPE_I) {

        /* unknown fields */

        if (s->f_code == 0x50 || s->f_code == 0x60) {

            int csum = get_bits(bitbuf, 16);



            csum = ff_svq1_packet_checksum(bitbuf->buffer,

                                           bitbuf->size_in_bits >> 3,

                                           csum);



            av_dlog(s->avctx, "%s checksum (%02x) for packet data\n",

                    (csum == 0) ? "correct" : "incorrect", csum);

        }



        if ((s->f_code ^ 0x10) >= 0x50) {

            uint8_t msg[256];



            svq1_parse_string(bitbuf, msg);



            av_log(s->avctx, AV_LOG_ERROR,

                   "embedded message: \"%s\"\n", (char *)msg);

        }



        skip_bits(bitbuf, 2);

        skip_bits(bitbuf, 2);

        skip_bits1(bitbuf);



        /* load frame size */

        frame_size_code = get_bits(bitbuf, 3);



        if (frame_size_code == 7) {

            /* load width, height (12 bits each) */

            s->width  = get_bits(bitbuf, 12);

            s->height = get_bits(bitbuf, 12);



            if (!s->width || !s->height)

                return AVERROR_INVALIDDATA;

        } else {

            /* get width, height from table */

            s->width  = ff_svq1_frame_size_table[frame_size_code].width;

            s->height = ff_svq1_frame_size_table[frame_size_code].height;

        }

    }



    /* unknown fields */

    if (get_bits1(bitbuf) == 1) {

        skip_bits1(bitbuf);    /* use packet checksum if (1) */

        skip_bits1(bitbuf);    /* component checksums after image data if (1) */



        if (get_bits(bitbuf, 2) != 0)

            return AVERROR_INVALIDDATA;

    }



    if (get_bits1(bitbuf) == 1) {

        skip_bits1(bitbuf);

        skip_bits(bitbuf, 4);

        skip_bits1(bitbuf);

        skip_bits(bitbuf, 2);



        while (get_bits1(bitbuf) == 1)

            skip_bits(bitbuf, 8);

    }



    return 0;

}

static int svq1_decode_frame_header(GetBitContext *bitbuf, MpegEncContext *s)

{

    int frame_size_code;



    skip_bits(bitbuf, 8); 



    

    s->pict_type = get_bits(bitbuf, 2) + 1;

    if (s->pict_type == 4)

        return AVERROR_INVALIDDATA;



    if (s->pict_type == AV_PICTURE_TYPE_I) {

        

        if (s->f_code == 0x50 || s->f_code == 0x60) {

            int csum = get_bits(bitbuf, 16);



            csum = ff_svq1_packet_checksum(bitbuf->buffer,

                                           bitbuf->size_in_bits >> 3,

                                           csum);



            av_dlog(s->avctx, "%s checksum (%02x) for packet data\n",

                    (csum == 0) ? "correct" : "incorrect", csum);

        }



        if ((s->f_code ^ 0x10) >= 0x50) {

            uint8_t msg[256];



            svq1_parse_string(bitbuf, msg);



            av_log(s->avctx, AV_LOG_ERROR,

                   "embedded message: \"%s\"\n", (char *)msg);

        }



        skip_bits(bitbuf, 2);

        skip_bits(bitbuf, 2);

        skip_bits1(bitbuf);



        

        frame_size_code = get_bits(bitbuf, 3);



        if (frame_size_code == 7) {

            

            s->width  = get_bits(bitbuf, 12);

            s->height = get_bits(bitbuf, 12);



            if (!s->width || !s->height)

                return AVERROR_INVALIDDATA;

        } else {

            

            s->width  = ff_svq1_frame_size_table[frame_size_code].width;

            s->height = ff_svq1_frame_size_table[frame_size_code].height;

        }

    }



    

    if (get_bits1(bitbuf) == 1) {

        skip_bits1(bitbuf);    

        skip_bits1(bitbuf);    



        if (get_bits(bitbuf, 2) != 0)

            return AVERROR_INVALIDDATA;

    }



    if (get_bits1(bitbuf) == 1) {

        skip_bits1(bitbuf);

        skip_bits(bitbuf, 4);

        skip_bits1(bitbuf);

        skip_bits(bitbuf, 2);



        while (get_bits1(bitbuf) == 1)

            skip_bits(bitbuf, 8);

    }



    return 0;

}

static int FUNC_0(GetBitContext *VAR_0, MpegEncContext *VAR_1)

{

    int VAR_2;



    skip_bits(VAR_0, 8); 



    

    VAR_1->pict_type = get_bits(VAR_0, 2) + 1;

    if (VAR_1->pict_type == 4)

        return AVERROR_INVALIDDATA;



    if (VAR_1->pict_type == AV_PICTURE_TYPE_I) {

        

        if (VAR_1->f_code == 0x50 || VAR_1->f_code == 0x60) {

            int VAR_3 = get_bits(VAR_0, 16);



            VAR_3 = ff_svq1_packet_checksum(VAR_0->buffer,

                                           VAR_0->size_in_bits >> 3,

                                           VAR_3);



            av_dlog(VAR_1->avctx, "%VAR_1 checksum (%02x) for packet data\n",

                    (VAR_3 == 0) ? "correct" : "incorrect", VAR_3);

        }



        if ((VAR_1->f_code ^ 0x10) >= 0x50) {

            uint8_t msg[256];



            svq1_parse_string(VAR_0, msg);



            av_log(VAR_1->avctx, AV_LOG_ERROR,

                   "embedded message: \"%VAR_1\"\n", (char *)msg);

        }



        skip_bits(VAR_0, 2);

        skip_bits(VAR_0, 2);

        skip_bits1(VAR_0);



        

        VAR_2 = get_bits(VAR_0, 3);



        if (VAR_2 == 7) {

            

            VAR_1->width  = get_bits(VAR_0, 12);

            VAR_1->height = get_bits(VAR_0, 12);



            if (!VAR_1->width || !VAR_1->height)

                return AVERROR_INVALIDDATA;

        } else {

            

            VAR_1->width  = ff_svq1_frame_size_table[VAR_2].width;

            VAR_1->height = ff_svq1_frame_size_table[VAR_2].height;

        }

    }



    

    if (get_bits1(VAR_0) == 1) {

        skip_bits1(VAR_0);    

        skip_bits1(VAR_0);    



        if (get_bits(VAR_0, 2) != 0)

            return AVERROR_INVALIDDATA;

    }



    if (get_bits1(VAR_0) == 1) {

        skip_bits1(VAR_0);

        skip_bits(VAR_0, 4);

        skip_bits1(VAR_0);

        skip_bits(VAR_0, 2);



        while (get_bits1(VAR_0) == 1)

            skip_bits(VAR_0, 8);

    }



    return 0;

}

static int FUNC_0(GetBitContext *VAR_0, MpegEncContext *VAR_1)
{ int VAR_2; skip_bits(VAR_0, 8); VAR_1->pict_type = get_bits(VAR_0, 2) + 1; if (VAR_1->pict_type == 4)
return AVERROR_INVALIDDATA; if (VAR_1->pict_type == AV_PICTURE_TYPE_I) { if (VAR_1->f_code == 0x50 || VAR_1->f_code == 0x60) { int VAR_3 = get_bits(VAR_0, 16); VAR_3 = ff_svq1_packet_checksum(VAR_0->buffer,
VAR_0->size_in_bits >> 3,
VAR_3); av_dlog(VAR_1->avctx, "%VAR_1 checksum (%02x) for packet data\n",
(VAR_3 == 0) ? "correct" : "incorrect", VAR_3); } if ((VAR_1->f_code ^ 0x10) >= 0x50) { uint8_t msg[256]; svq1_parse_string(VAR_0, msg); av_log(VAR_1->avctx, AV_LOG_ERROR,
"embedded message: \"%VAR_1\"\n", (char *)msg); } skip_bits(VAR_0, 2); skip_bits(VAR_0, 2); skip_bits1(VAR_0); VAR_2 = get_bits(VAR_0, 3); if (VAR_2 == 7) { VAR_1->width  = get_bits(VAR_0, 12); VAR_1->height = get_bits(VAR_0, 12); if (!VAR_1->width || !VAR_1->height)
return AVERROR_INVALIDDATA; } else { VAR_1->width  = ff_svq1_frame_size_table[VAR_2].width; VAR_1->height = ff_svq1_frame_size_table[VAR_2].height; } } if (get_bits1(VAR_0) == 1) { skip_bits1(VAR_0); skip_bits1(VAR_0); if (get_bits(VAR_0, 2) != 0)
return AVERROR_INVALIDDATA; } if (get_bits1(VAR_0) == 1) { skip_bits1(VAR_0); skip_bits(VAR_0, 4); skip_bits1(VAR_0); skip_bits(VAR_0, 2); while (get_bits1(VAR_0) == 1)
skip_bits(VAR_0, 8); } return 0; }