static int parse_video_var(AVFormatContext *avctx, AVStream *st, const char *name, int size)

{

    AVIOContext *pb = avctx->pb;

    if (!strcmp(name, "__DIR_COUNT")) {

        st->nb_frames = st->duration = var_read_int(pb, size);

    } else if (!strcmp(name, "COMPRESSION")) {

        char * str = var_read_string(pb, size);

        if (!strcmp(str, "1")) {

            st->codec->codec_id = AV_CODEC_ID_MVC1;

        } else if (!strcmp(str, "2")) {

            st->codec->pix_fmt  = AV_PIX_FMT_ABGR;

            st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;

        } else if (!strcmp(str, "3")) {

            st->codec->codec_id = AV_CODEC_ID_SGIRLE;

        } else if (!strcmp(str, "10")) {

            st->codec->codec_id = AV_CODEC_ID_MJPEG;

        } else if (!strcmp(str, "MVC2")) {

            st->codec->codec_id = AV_CODEC_ID_MVC2;

        } else {

            av_log_ask_for_sample(avctx, "unknown video compression %s\n", str);

        }

        av_free(str);

    } else if (!strcmp(name, "FPS")) {

        st->time_base = av_inv_q(var_read_float(pb, size));

    } else if (!strcmp(name, "HEIGHT")) {

        st->codec->height = var_read_int(pb, size);

    } else if (!strcmp(name, "PIXEL_ASPECT")) {

        st->sample_aspect_ratio = var_read_float(pb, size);

        av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den,

                  st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, INT_MAX);

    } else if (!strcmp(name, "WIDTH")) {

        st->codec->width = var_read_int(pb, size);

    } else if (!strcmp(name, "ORIENTATION")) {

        if (var_read_int(pb, size) == 1101) {

            st->codec->extradata       = av_strdup("BottomUp");

            st->codec->extradata_size  = 9;

        }

    } else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) {

        var_read_metadata(avctx, name, size);

    } else if (!strcmp(name, "INTERLACING") || !strcmp(name, "PACKING")) {

        avio_skip(pb, size); // ignore

    } else

        return -1;

    return 0;

}

static int parse_video_var(AVFormatContext *avctx, AVStream *st, const char *name, int size)

{

    AVIOContext *pb = avctx->pb;

    if (!strcmp(name, "__DIR_COUNT")) {

        st->nb_frames = st->duration = var_read_int(pb, size);

    } else if (!strcmp(name, "COMPRESSION")) {

        char * str = var_read_string(pb, size);

        if (!strcmp(str, "1")) {

            st->codec->codec_id = AV_CODEC_ID_MVC1;

        } else if (!strcmp(str, "2")) {

            st->codec->pix_fmt  = AV_PIX_FMT_ABGR;

            st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;

        } else if (!strcmp(str, "3")) {

            st->codec->codec_id = AV_CODEC_ID_SGIRLE;

        } else if (!strcmp(str, "10")) {

            st->codec->codec_id = AV_CODEC_ID_MJPEG;

        } else if (!strcmp(str, "MVC2")) {

            st->codec->codec_id = AV_CODEC_ID_MVC2;

        } else {

            av_log_ask_for_sample(avctx, "unknown video compression %s\n", str);

        }

        av_free(str);

    } else if (!strcmp(name, "FPS")) {

        st->time_base = av_inv_q(var_read_float(pb, size));

    } else if (!strcmp(name, "HEIGHT")) {

        st->codec->height = var_read_int(pb, size);

    } else if (!strcmp(name, "PIXEL_ASPECT")) {

        st->sample_aspect_ratio = var_read_float(pb, size);

        av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den,

                  st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, INT_MAX);

    } else if (!strcmp(name, "WIDTH")) {

        st->codec->width = var_read_int(pb, size);

    } else if (!strcmp(name, "ORIENTATION")) {

        if (var_read_int(pb, size) == 1101) {

            st->codec->extradata       = av_strdup("BottomUp");

            st->codec->extradata_size  = 9;

        }

    } else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) {

        var_read_metadata(avctx, name, size);

    } else if (!strcmp(name, "INTERLACING") || !strcmp(name, "PACKING")) {

        avio_skip(pb, size); 

    } else

        return -1;

    return 0;

}

        st->time_base = av_inv_q(var_read_float(pb, size));
static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, const char *VAR_2, int VAR_3)

{

    AVIOContext *pb = VAR_0->pb;

    if (!strcmp(VAR_2, "__DIR_COUNT")) {

        VAR_1->nb_frames = VAR_1->duration = var_read_int(pb, VAR_3);

    } else if (!strcmp(VAR_2, "COMPRESSION")) {

        char * VAR_4 = var_read_string(pb, VAR_3);

        if (!strcmp(VAR_4, "1")) {

            VAR_1->codec->codec_id = AV_CODEC_ID_MVC1;

        } else if (!strcmp(VAR_4, "2")) {

            VAR_1->codec->pix_fmt  = AV_PIX_FMT_ABGR;

            VAR_1->codec->codec_id = AV_CODEC_ID_RAWVIDEO;

        } else if (!strcmp(VAR_4, "3")) {

            VAR_1->codec->codec_id = AV_CODEC_ID_SGIRLE;

        } else if (!strcmp(VAR_4, "10")) {

            VAR_1->codec->codec_id = AV_CODEC_ID_MJPEG;

        } else if (!strcmp(VAR_4, "MVC2")) {

            VAR_1->codec->codec_id = AV_CODEC_ID_MVC2;

        } else {

            av_log_ask_for_sample(VAR_0, "unknown video compression %s\n", VAR_4);

        }

        av_free(VAR_4);

    } else if (!strcmp(VAR_2, "FPS")) {

        VAR_1->time_base = av_inv_q(var_read_float(pb, VAR_3));

    } else if (!strcmp(VAR_2, "HEIGHT")) {

        VAR_1->codec->height = var_read_int(pb, VAR_3);

    } else if (!strcmp(VAR_2, "PIXEL_ASPECT")) {

        VAR_1->sample_aspect_ratio = var_read_float(pb, VAR_3);

        av_reduce(&VAR_1->sample_aspect_ratio.num, &VAR_1->sample_aspect_ratio.den,

                  VAR_1->sample_aspect_ratio.num, VAR_1->sample_aspect_ratio.den, INT_MAX);

    } else if (!strcmp(VAR_2, "WIDTH")) {

        VAR_1->codec->width = var_read_int(pb, VAR_3);

    } else if (!strcmp(VAR_2, "ORIENTATION")) {

        if (var_read_int(pb, VAR_3) == 1101) {

            VAR_1->codec->extradata       = av_strdup("BottomUp");

            VAR_1->codec->extradata_size  = 9;

        }

    } else if (!strcmp(VAR_2, "Q_SPATIAL") || !strcmp(VAR_2, "Q_TEMPORAL")) {

        var_read_metadata(VAR_0, VAR_2, VAR_3);

    } else if (!strcmp(VAR_2, "INTERLACING") || !strcmp(VAR_2, "PACKING")) {

        avio_skip(pb, VAR_3); 

    } else

        return -1;

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, const char *VAR_2, int VAR_3)
{ AVIOContext *pb = VAR_0->pb; if (!strcmp(VAR_2, "__DIR_COUNT")) { VAR_1->nb_frames = VAR_1->duration = var_read_int(pb, VAR_3); } else if (!strcmp(VAR_2, "COMPRESSION")) { char * VAR_4 = var_read_string(pb, VAR_3); if (!strcmp(VAR_4, "1")) { VAR_1->codec->codec_id = AV_CODEC_ID_MVC1; } else if (!strcmp(VAR_4, "2")) { VAR_1->codec->pix_fmt  = AV_PIX_FMT_ABGR; VAR_1->codec->codec_id = AV_CODEC_ID_RAWVIDEO; } else if (!strcmp(VAR_4, "3")) { VAR_1->codec->codec_id = AV_CODEC_ID_SGIRLE; } else if (!strcmp(VAR_4, "10")) { VAR_1->codec->codec_id = AV_CODEC_ID_MJPEG; } else if (!strcmp(VAR_4, "MVC2")) { VAR_1->codec->codec_id = AV_CODEC_ID_MVC2; } else { av_log_ask_for_sample(VAR_0, "unknown video compression %s\n", VAR_4); } av_free(VAR_4); } else if (!strcmp(VAR_2, "FPS")) { VAR_1->time_base = av_inv_q(var_read_float(pb, VAR_3)); } else if (!strcmp(VAR_2, "HEIGHT")) { VAR_1->codec->height = var_read_int(pb, VAR_3); } else if (!strcmp(VAR_2, "PIXEL_ASPECT")) { VAR_1->sample_aspect_ratio = var_read_float(pb, VAR_3); av_reduce(&VAR_1->sample_aspect_ratio.num, &VAR_1->sample_aspect_ratio.den,
VAR_1->sample_aspect_ratio.num, VAR_1->sample_aspect_ratio.den, INT_MAX); } else if (!strcmp(VAR_2, "WIDTH")) { VAR_1->codec->width = var_read_int(pb, VAR_3); } else if (!strcmp(VAR_2, "ORIENTATION")) { if (var_read_int(pb, VAR_3) == 1101) { VAR_1->codec->extradata       = av_strdup("BottomUp"); VAR_1->codec->extradata_size  = 9; } } else if (!strcmp(VAR_2, "Q_SPATIAL") || !strcmp(VAR_2, "Q_TEMPORAL")) { var_read_metadata(VAR_0, VAR_2, VAR_3); } else if (!strcmp(VAR_2, "INTERLACING") || !strcmp(VAR_2, "PACKING")) { avio_skip(pb, VAR_3); } else return -1; return 0; }