static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) {

    NUTContext * priv = avf->priv_data;

    AVIOContext * bc = avf->pb;

    nut_demuxer_opts_tt dopts = {

        .input = {

            .priv = bc,

            .seek = av_seek,

            .read = av_read,

            .eof = NULL,

            .file_pos = 0,

        },

        .alloc = { av_malloc, av_realloc, av_free },

        .read_index = 1,

        .cache_syncpoints = 1,

    };

    nut_context_tt * nut = priv->nut = nut_demuxer_init(&dopts);

    nut_stream_header_tt * s;

    int ret, i;



    if ((ret = nut_read_headers(nut, &s, NULL))) {

        av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(ret));


        return -1;




    priv->s = s;



    for (i = 0; s[i].type != -1 && i < 2; i++) {

        AVStream * st = avformat_new_stream(avf, NULL);

        int j;



        for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[i].fourcc[j]<<(j*8);



        st->codec->has_b_frames = s[i].decode_delay;



        st->codec->extradata_size = s[i].codec_specific_len;

        if (st->codec->extradata_size) {

            st->codec->extradata = av_mallocz(st->codec->extradata_size);





            memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size);




        avpriv_set_pts_info(avf->streams[i], 60, s[i].time_base.num, s[i].time_base.den);

        st->start_time = 0;

        st->duration = s[i].max_pts;



        st->codec->codec_id = ff_codec_get_id(nut_tags, st->codec->codec_tag);



        switch(s[i].type) {

        case NUT_AUDIO_CLASS:

            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;

            if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, st->codec->codec_tag);



            st->codec->channels = s[i].channel_count;

            st->codec->sample_rate = s[i].samplerate_num / s[i].samplerate_denom;

            break;

        case NUT_VIDEO_CLASS:

            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;

            if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);



            st->codec->width = s[i].width;

            st->codec->height = s[i].height;

            st->sample_aspect_ratio.num = s[i].sample_width;

            st->sample_aspect_ratio.den = s[i].sample_height;

            break;


        if (st->codec->codec_id == CODEC_ID_NONE) av_log(avf, AV_LOG_ERROR, "Unknown codec?!\n");




    return 0;

static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) {

    NUTContext * priv = avf->priv_data;

    AVIOContext * bc = avf->pb;

    nut_demuxer_opts_tt dopts = {

        .input = {

            .priv = bc,

            .seek = av_seek,

            .read = av_read,

            .eof = NULL,

            .file_pos = 0,

        },

        .alloc = { av_malloc, av_realloc, av_free },

        .read_index = 1,

        .cache_syncpoints = 1,

    };

    nut_context_tt * nut = priv->nut = nut_demuxer_init(&dopts);

    nut_stream_header_tt * s;

    int ret, i;



    if ((ret = nut_read_headers(nut, &s, NULL))) {

        av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(ret));


        return -1;




    priv->s = s;



    for (i = 0; s[i].type != -1 && i < 2; i++) {

        AVStream * st = avformat_new_stream(avf, NULL);

        int j;



        for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[i].fourcc[j]<<(j*8);



        st->codec->has_b_frames = s[i].decode_delay;



        st->codec->extradata_size = s[i].codec_specific_len;

        if (st->codec->extradata_size) {

            st->codec->extradata = av_mallocz(st->codec->extradata_size);





            memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size);




        avpriv_set_pts_info(avf->streams[i], 60, s[i].time_base.num, s[i].time_base.den);

        st->start_time = 0;

        st->duration = s[i].max_pts;



        st->codec->codec_id = ff_codec_get_id(nut_tags, st->codec->codec_tag);



        switch(s[i].type) {

        case NUT_AUDIO_CLASS:

            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;

            if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, st->codec->codec_tag);



            st->codec->channels = s[i].channel_count;

            st->codec->sample_rate = s[i].samplerate_num / s[i].samplerate_denom;

            break;

        case NUT_VIDEO_CLASS:

            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;

            if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);



            st->codec->width = s[i].width;

            st->codec->height = s[i].height;

            st->sample_aspect_ratio.num = s[i].sample_width;

            st->sample_aspect_ratio.den = s[i].sample_height;

            break;


        if (st->codec->codec_id == CODEC_ID_NONE) av_log(avf, AV_LOG_ERROR, "Unknown codec?!\n");




    return 0;

static int FUNC_0(AVFormatContext * VAR_0, AVFormatParameters * VAR_1) {

    NUTContext * priv = VAR_0->priv_data;

    AVIOContext * bc = VAR_0->pb;

    nut_demuxer_opts_tt dopts = {

        .input = {

            .priv = bc,

            .seek = av_seek,

            .read = av_read,

            .eof = NULL,

            .file_pos = 0,

        },

        .alloc = { av_malloc, av_realloc, av_free },

        .read_index = 1,

        .cache_syncpoints = 1,

    };

    nut_context_tt * nut = priv->nut = nut_demuxer_init(&dopts);

    nut_stream_header_tt * s;

    int VAR_2, VAR_3;



    if ((VAR_2 = nut_read_headers(nut, &s, NULL))) {

        av_log(VAR_0, AV_LOG_ERROR, " NUT error: %s\n", nut_error(VAR_2));


        return -1;




    priv->s = s;



    for (VAR_3 = 0; s[VAR_3].type != -1 && VAR_3 < 2; VAR_3++) {

        AVStream * st = avformat_new_stream(VAR_0, NULL);

        int j;



        for (j = 0; j < s[VAR_3].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[VAR_3].fourcc[j]<<(j*8);



        st->codec->has_b_frames = s[VAR_3].decode_delay;



        st->codec->extradata_size = s[VAR_3].codec_specific_len;

        if (st->codec->extradata_size) {

            st->codec->extradata = av_mallocz(st->codec->extradata_size);





            memcpy(st->codec->extradata, s[VAR_3].codec_specific, st->codec->extradata_size);




        avpriv_set_pts_info(VAR_0->streams[VAR_3], 60, s[VAR_3].time_base.num, s[VAR_3].time_base.den);

        st->start_time = 0;

        st->duration = s[VAR_3].max_pts;



        st->codec->codec_id = ff_codec_get_id(nut_tags, st->codec->codec_tag);



        switch(s[VAR_3].type) {

        case NUT_AUDIO_CLASS:

            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;

            if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, st->codec->codec_tag);



            st->codec->channels = s[VAR_3].channel_count;

            st->codec->sample_rate = s[VAR_3].samplerate_num / s[VAR_3].samplerate_denom;

            break;

        case NUT_VIDEO_CLASS:

            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;

            if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);



            st->codec->width = s[VAR_3].width;

            st->codec->height = s[VAR_3].height;

            st->sample_aspect_ratio.num = s[VAR_3].sample_width;

            st->sample_aspect_ratio.den = s[VAR_3].sample_height;

            break;


        if (st->codec->codec_id == CODEC_ID_NONE) av_log(VAR_0, AV_LOG_ERROR, "Unknown codec?!\n");




    return 0;

static int FUNC_0(AVFormatContext * VAR_0, AVFormatParameters * VAR_1) { NUTContext * priv = VAR_0->priv_data; AVIOContext * bc = VAR_0->pb; nut_demuxer_opts_tt dopts = { .input = { .priv = bc,
.seek = av_seek,
.read = av_read,
.eof = NULL,
.file_pos = 0,
}, .alloc = { av_malloc, av_realloc, av_free }, .read_index = 1,
.cache_syncpoints = 1,
}; nut_context_tt * nut = priv->nut = nut_demuxer_init(&dopts); nut_stream_header_tt * s; int VAR_2, VAR_3; if ((VAR_2 = nut_read_headers(nut, &s, NULL))) { av_log(VAR_0, AV_LOG_ERROR, " NUT error: %s\n", nut_error(VAR_2)); return -1; priv->s = s; for (VAR_3 = 0; s[VAR_3].type != -1 && VAR_3 < 2; VAR_3++) { AVStream * st = avformat_new_stream(VAR_0, NULL); int j; for (j = 0; j < s[VAR_3].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[VAR_3].fourcc[j]<<(j*8); st->codec->has_b_frames = s[VAR_3].decode_delay; st->codec->extradata_size = s[VAR_3].codec_specific_len; if (st->codec->extradata_size) { st->codec->extradata = av_mallocz(st->codec->extradata_size); memcpy(st->codec->extradata, s[VAR_3].codec_specific, st->codec->extradata_size); avpriv_set_pts_info(VAR_0->streams[VAR_3], 60, s[VAR_3].time_base.num, s[VAR_3].time_base.den); st->start_time = 0; st->duration = s[VAR_3].max_pts; st->codec->codec_id = ff_codec_get_id(nut_tags, st->codec->codec_tag); switch(s[VAR_3].type) { case NUT_AUDIO_CLASS:
st->codec->codec_type = AVMEDIA_TYPE_AUDIO; if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, st->codec->codec_tag); st->codec->channels = s[VAR_3].channel_count; st->codec->sample_rate = s[VAR_3].samplerate_num / s[VAR_3].samplerate_denom; break; case NUT_VIDEO_CLASS:
st->codec->codec_type = AVMEDIA_TYPE_VIDEO; if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag); st->codec->width = s[VAR_3].width; st->codec->height = s[VAR_3].height; st->sample_aspect_ratio.num = s[VAR_3].sample_width; st->sample_aspect_ratio.den = s[VAR_3].sample_height; break; if (st->codec->codec_id == CODEC_ID_NONE) av_log(VAR_0, AV_LOG_ERROR, "Unknown codec?!\n"); return 0;