int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,

                                   dirac_source_params *source)

{

    unsigned version_major;

    unsigned video_format, picture_coding_mode;



    version_major  = svq3_get_ue_golomb(gb);

    svq3_get_ue_golomb(gb); /* version_minor */

    avctx->profile = svq3_get_ue_golomb(gb);

    avctx->level   = svq3_get_ue_golomb(gb);

    video_format   = svq3_get_ue_golomb(gb);



    if (version_major < 2)

        av_log(avctx, AV_LOG_WARNING, "Stream is old and may not work\n");

    else if (version_major > 2)

        av_log(avctx, AV_LOG_WARNING, "Stream may have unhandled features\n");



    if (video_format > 20)

        return -1;



    // Fill in defaults for the source parameters.

    *source = dirac_source_parameters_defaults[video_format];



    // Override the defaults.

    if (parse_source_parameters(avctx, gb, source))

        return -1;



    if (av_image_check_size(source->width, source->height, 0, avctx))

        return -1;



    avcodec_set_dimensions(avctx, source->width, source->height);



    // currently only used to signal field coding

    picture_coding_mode = svq3_get_ue_golomb(gb);

    if (picture_coding_mode != 0) {

        av_log(avctx, AV_LOG_ERROR, "Unsupported picture coding mode %d",

               picture_coding_mode);

        return -1;

    }

    return 0;

}

int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,

                                   dirac_source_params *source)

{

    unsigned version_major;

    unsigned video_format, picture_coding_mode;



    version_major  = svq3_get_ue_golomb(gb);

    svq3_get_ue_golomb(gb); 

    avctx->profile = svq3_get_ue_golomb(gb);

    avctx->level   = svq3_get_ue_golomb(gb);

    video_format   = svq3_get_ue_golomb(gb);



    if (version_major < 2)

        av_log(avctx, AV_LOG_WARNING, "Stream is old and may not work\n");

    else if (version_major > 2)

        av_log(avctx, AV_LOG_WARNING, "Stream may have unhandled features\n");



    if (video_format > 20)

        return -1;



    

    *source = dirac_source_parameters_defaults[video_format];



    

    if (parse_source_parameters(avctx, gb, source))

        return -1;



    if (av_image_check_size(source->width, source->height, 0, avctx))

        return -1;



    avcodec_set_dimensions(avctx, source->width, source->height);



    

    picture_coding_mode = svq3_get_ue_golomb(gb);

    if (picture_coding_mode != 0) {

        av_log(avctx, AV_LOG_ERROR, "Unsupported picture coding mode %d",

               picture_coding_mode);

        return -1;

    }

    return 0;

}

int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1,

                                   dirac_source_params *VAR_2)

{

    unsigned VAR_3;

    unsigned VAR_4, VAR_5;



    VAR_3  = svq3_get_ue_golomb(VAR_1);

    svq3_get_ue_golomb(VAR_1); 

    VAR_0->profile = svq3_get_ue_golomb(VAR_1);

    VAR_0->level   = svq3_get_ue_golomb(VAR_1);

    VAR_4   = svq3_get_ue_golomb(VAR_1);



    if (VAR_3 < 2)

        av_log(VAR_0, AV_LOG_WARNING, "Stream is old and may not work\n");

    else if (VAR_3 > 2)

        av_log(VAR_0, AV_LOG_WARNING, "Stream may have unhandled features\n");



    if (VAR_4 > 20)

        return -1;



    

    *VAR_2 = dirac_source_parameters_defaults[VAR_4];



    

    if (parse_source_parameters(VAR_0, VAR_1, VAR_2))

        return -1;



    if (av_image_check_size(VAR_2->width, VAR_2->height, 0, VAR_0))

        return -1;



    avcodec_set_dimensions(VAR_0, VAR_2->width, VAR_2->height);



    

    VAR_5 = svq3_get_ue_golomb(VAR_1);

    if (VAR_5 != 0) {

        av_log(VAR_0, AV_LOG_ERROR, "Unsupported picture coding mode %d",

               VAR_5);

        return -1;

    }

    return 0;

}

int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1,
dirac_source_params *VAR_2)
{ unsigned VAR_3; unsigned VAR_4, VAR_5; VAR_3  = svq3_get_ue_golomb(VAR_1); svq3_get_ue_golomb(VAR_1); VAR_0->profile = svq3_get_ue_golomb(VAR_1); VAR_0->level   = svq3_get_ue_golomb(VAR_1); VAR_4   = svq3_get_ue_golomb(VAR_1); if (VAR_3 < 2)
av_log(VAR_0, AV_LOG_WARNING, "Stream is old and may not work\n"); else if (VAR_3 > 2)
av_log(VAR_0, AV_LOG_WARNING, "Stream may have unhandled features\n"); if (VAR_4 > 20)
return -1; *VAR_2 = dirac_source_parameters_defaults[VAR_4]; if (parse_source_parameters(VAR_0, VAR_1, VAR_2))
return -1; if (av_image_check_size(VAR_2->width, VAR_2->height, 0, VAR_0))
return -1; avcodec_set_dimensions(VAR_0, VAR_2->width, VAR_2->height); VAR_5 = svq3_get_ue_golomb(VAR_1); if (VAR_5 != 0) { av_log(VAR_0, AV_LOG_ERROR, "Unsupported picture coding mode %d",
VAR_5); return -1; } return 0; }