int ff_h264_decode_sei(H264Context *h)

{

    while (get_bits_left(&h->gb) > 16) {

        int size = 0;

        int type = 0;

        int ret  = 0;

        int last = 0;



        while (get_bits_left(&h->gb) >= 8 &&

               (last = get_bits(&h->gb, 8)) == 255) {

            type += 255;

        }

        type += last;



        last = 0;

        while (get_bits_left(&h->gb) >= 8 &&

               (last = get_bits(&h->gb, 8)) == 255) {

            size += 255;

        }

        size += last;



        if (size > get_bits_left(&h->gb) / 8) {

            av_log(h->avctx, AV_LOG_ERROR, "SEI type %d truncated at %d\n",

                   type, get_bits_left(&h->gb));

            return AVERROR_INVALIDDATA;

        }



        switch (type) {

        case SEI_TYPE_PIC_TIMING: // Picture timing SEI

            ret = decode_picture_timing(h);

            if (ret < 0)

                return ret;

            break;

        case SEI_TYPE_USER_DATA_UNREGISTERED:

            ret = decode_unregistered_user_data(h, size);

            if (ret < 0)

                return ret;

            break;

        case SEI_TYPE_RECOVERY_POINT:

            ret = decode_recovery_point(h);

            if (ret < 0)

                return ret;

            break;

        case SEI_TYPE_BUFFERING_PERIOD:

            ret = decode_buffering_period(h);

            if (ret < 0)

                return ret;

            break;

        case SEI_TYPE_FRAME_PACKING:

            ret = decode_frame_packing_arrangement(h);

            if (ret < 0)

                return ret;

            break;

        case SEI_TYPE_DISPLAY_ORIENTATION:

            ret = decode_display_orientation(h);

            if (ret < 0)

                return ret;

            break;

        default:

            av_log(h->avctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);

            skip_bits(&h->gb, 8 * size);

        }



        // FIXME check bits here

        align_get_bits(&h->gb);

    }



    return 0;

}

int ff_h264_decode_sei(H264Context *h)

{

    while (get_bits_left(&h->gb) > 16) {

        int size = 0;

        int type = 0;

        int ret  = 0;

        int last = 0;



        while (get_bits_left(&h->gb) >= 8 &&

               (last = get_bits(&h->gb, 8)) == 255) {

            type += 255;

        }

        type += last;



        last = 0;

        while (get_bits_left(&h->gb) >= 8 &&

               (last = get_bits(&h->gb, 8)) == 255) {

            size += 255;

        }

        size += last;



        if (size > get_bits_left(&h->gb) / 8) {

            av_log(h->avctx, AV_LOG_ERROR, "SEI type %d truncated at %d\n",

                   type, get_bits_left(&h->gb));

            return AVERROR_INVALIDDATA;

        }



        switch (type) {

        case SEI_TYPE_PIC_TIMING: 

            ret = decode_picture_timing(h);

            if (ret < 0)

                return ret;

            break;

        case SEI_TYPE_USER_DATA_UNREGISTERED:

            ret = decode_unregistered_user_data(h, size);

            if (ret < 0)

                return ret;

            break;

        case SEI_TYPE_RECOVERY_POINT:

            ret = decode_recovery_point(h);

            if (ret < 0)

                return ret;

            break;

        case SEI_TYPE_BUFFERING_PERIOD:

            ret = decode_buffering_period(h);

            if (ret < 0)

                return ret;

            break;

        case SEI_TYPE_FRAME_PACKING:

            ret = decode_frame_packing_arrangement(h);

            if (ret < 0)

                return ret;

            break;

        case SEI_TYPE_DISPLAY_ORIENTATION:

            ret = decode_display_orientation(h);

            if (ret < 0)

                return ret;

            break;

        default:

            av_log(h->avctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);

            skip_bits(&h->gb, 8 * size);

        }



        

        align_get_bits(&h->gb);

    }



    return 0;

}

int FUNC_0(H264Context *VAR_0)

{

    while (get_bits_left(&VAR_0->gb) > 16) {

        int VAR_1 = 0;

        int VAR_2 = 0;

        int VAR_3  = 0;

        int VAR_4 = 0;



        while (get_bits_left(&VAR_0->gb) >= 8 &&

               (VAR_4 = get_bits(&VAR_0->gb, 8)) == 255) {

            VAR_2 += 255;

        }

        VAR_2 += VAR_4;



        VAR_4 = 0;

        while (get_bits_left(&VAR_0->gb) >= 8 &&

               (VAR_4 = get_bits(&VAR_0->gb, 8)) == 255) {

            VAR_1 += 255;

        }

        VAR_1 += VAR_4;



        if (VAR_1 > get_bits_left(&VAR_0->gb) / 8) {

            av_log(VAR_0->avctx, AV_LOG_ERROR, "SEI VAR_2 %d truncated at %d\n",

                   VAR_2, get_bits_left(&VAR_0->gb));

            return AVERROR_INVALIDDATA;

        }



        switch (VAR_2) {

        case SEI_TYPE_PIC_TIMING: 

            VAR_3 = decode_picture_timing(VAR_0);

            if (VAR_3 < 0)

                return VAR_3;

            break;

        case SEI_TYPE_USER_DATA_UNREGISTERED:

            VAR_3 = decode_unregistered_user_data(VAR_0, VAR_1);

            if (VAR_3 < 0)

                return VAR_3;

            break;

        case SEI_TYPE_RECOVERY_POINT:

            VAR_3 = decode_recovery_point(VAR_0);

            if (VAR_3 < 0)

                return VAR_3;

            break;

        case SEI_TYPE_BUFFERING_PERIOD:

            VAR_3 = decode_buffering_period(VAR_0);

            if (VAR_3 < 0)

                return VAR_3;

            break;

        case SEI_TYPE_FRAME_PACKING:

            VAR_3 = decode_frame_packing_arrangement(VAR_0);

            if (VAR_3 < 0)

                return VAR_3;

            break;

        case SEI_TYPE_DISPLAY_ORIENTATION:

            VAR_3 = decode_display_orientation(VAR_0);

            if (VAR_3 < 0)

                return VAR_3;

            break;

        default:

            av_log(VAR_0->avctx, AV_LOG_DEBUG, "unknown SEI VAR_2 %d\n", VAR_2);

            skip_bits(&VAR_0->gb, 8 * VAR_1);

        }



        

        align_get_bits(&VAR_0->gb);

    }



    return 0;

}

int FUNC_0(H264Context *VAR_0)
{ while (get_bits_left(&VAR_0->gb) > 16) { int VAR_1 = 0; int VAR_2 = 0; int VAR_3  = 0; int VAR_4 = 0; while (get_bits_left(&VAR_0->gb) >= 8 &&
(VAR_4 = get_bits(&VAR_0->gb, 8)) == 255) { VAR_2 += 255; } VAR_2 += VAR_4; VAR_4 = 0; while (get_bits_left(&VAR_0->gb) >= 8 &&
(VAR_4 = get_bits(&VAR_0->gb, 8)) == 255) { VAR_1 += 255; } VAR_1 += VAR_4; if (VAR_1 > get_bits_left(&VAR_0->gb) / 8) { av_log(VAR_0->avctx, AV_LOG_ERROR, "SEI VAR_2 %d truncated at %d\n",
VAR_2, get_bits_left(&VAR_0->gb)); return AVERROR_INVALIDDATA; } switch (VAR_2) { case SEI_TYPE_PIC_TIMING:
VAR_3 = decode_picture_timing(VAR_0); if (VAR_3 < 0)
return VAR_3; break; case SEI_TYPE_USER_DATA_UNREGISTERED:
VAR_3 = decode_unregistered_user_data(VAR_0, VAR_1); if (VAR_3 < 0)
return VAR_3; break; case SEI_TYPE_RECOVERY_POINT:
VAR_3 = decode_recovery_point(VAR_0); if (VAR_3 < 0)
return VAR_3; break; case SEI_TYPE_BUFFERING_PERIOD:
VAR_3 = decode_buffering_period(VAR_0); if (VAR_3 < 0)
return VAR_3; break; case SEI_TYPE_FRAME_PACKING:
VAR_3 = decode_frame_packing_arrangement(VAR_0); if (VAR_3 < 0)
return VAR_3; break; case SEI_TYPE_DISPLAY_ORIENTATION:
VAR_3 = decode_display_orientation(VAR_0); if (VAR_3 < 0)
return VAR_3; break; default:
av_log(VAR_0->avctx, AV_LOG_DEBUG, "unknown SEI VAR_2 %d\n", VAR_2); skip_bits(&VAR_0->gb, 8 * VAR_1); } align_get_bits(&VAR_0->gb); } return 0; }