static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)

{

    NUTContext *nut = s->priv_data;

    ByteIOContext *bc = &s->pb;

    int64_t pos;

    int inited_stream_count;



    nut->avf= s;

    

    /* main header */

    pos=0;

    for(;;){

        pos= find_startcode(bc, MAIN_STARTCODE, pos)+1;

        if (pos<0){

            av_log(s, AV_LOG_ERROR, "no main startcode found\n");

            return -1;

        }

        if(decode_main_header(nut) >= 0)

            break;

    }

    

    

    s->bit_rate = 0;



    nut->stream = av_malloc(sizeof(StreamContext)*nut->stream_count);



    /* stream headers */

    pos=0;

    for(inited_stream_count=0; inited_stream_count < nut->stream_count;){

        pos= find_startcode(bc, STREAM_STARTCODE, pos)+1;

        if (pos<0){

            av_log(s, AV_LOG_ERROR, "not all stream headers found\n");

            return -1;

        }

        if(decode_stream_header(nut) >= 0)

            inited_stream_count++;

    }



    /* info headers */

    pos=0;

    for(;;){

        uint64_t startcode= find_any_startcode(bc, pos);

        pos= url_ftell(bc);



        if(startcode==0){

            av_log(s, AV_LOG_ERROR, "EOF before video frames\n");

            return -1;

        }else if(startcode == KEYFRAME_STARTCODE){

            nut->next_startcode= startcode;

            break;

        }else if(startcode != INFO_STARTCODE){

            continue;

        }



        decode_info_header(nut);

    }



    return 0;

}

static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)

{

    NUTContext *nut = s->priv_data;

    ByteIOContext *bc = &s->pb;

    int64_t pos;

    int inited_stream_count;



    nut->avf= s;

    

    

    pos=0;

    for(;;){

        pos= find_startcode(bc, MAIN_STARTCODE, pos)+1;

        if (pos<0){

            av_log(s, AV_LOG_ERROR, "no main startcode found\n");

            return -1;

        }

        if(decode_main_header(nut) >= 0)

            break;

    }

    

    

    s->bit_rate = 0;



    nut->stream = av_malloc(sizeof(StreamContext)*nut->stream_count);



    

    pos=0;

    for(inited_stream_count=0; inited_stream_count < nut->stream_count;){

        pos= find_startcode(bc, STREAM_STARTCODE, pos)+1;

        if (pos<0){

            av_log(s, AV_LOG_ERROR, "not all stream headers found\n");

            return -1;

        }

        if(decode_stream_header(nut) >= 0)

            inited_stream_count++;

    }



    

    pos=0;

    for(;;){

        uint64_t startcode= find_any_startcode(bc, pos);

        pos= url_ftell(bc);



        if(startcode==0){

            av_log(s, AV_LOG_ERROR, "EOF before video frames\n");

            return -1;

        }else if(startcode == KEYFRAME_STARTCODE){

            nut->next_startcode= startcode;

            break;

        }else if(startcode != INFO_STARTCODE){

            continue;

        }



        decode_info_header(nut);

    }



    return 0;

}

        if (pos<0){
static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)

{

    NUTContext *nut = VAR_0->priv_data;

    ByteIOContext *bc = &VAR_0->pb;

    int64_t pos;

    int VAR_2;



    nut->avf= VAR_0;

    

    

    pos=0;

    for(;;){

        pos= find_startcode(bc, MAIN_STARTCODE, pos)+1;

        if (pos<0){

            av_log(VAR_0, AV_LOG_ERROR, "no main startcode found\n");

            return -1;

        }

        if(decode_main_header(nut) >= 0)

            break;

    }

    

    

    VAR_0->bit_rate = 0;



    nut->stream = av_malloc(sizeof(StreamContext)*nut->stream_count);



    

    pos=0;

    for(VAR_2=0; VAR_2 < nut->stream_count;){

        pos= find_startcode(bc, STREAM_STARTCODE, pos)+1;

        if (pos<0){

            av_log(VAR_0, AV_LOG_ERROR, "not all stream headers found\n");

            return -1;

        }

        if(decode_stream_header(nut) >= 0)

            VAR_2++;

    }



    

    pos=0;

    for(;;){

        uint64_t startcode= find_any_startcode(bc, pos);

        pos= url_ftell(bc);



        if(startcode==0){

            av_log(VAR_0, AV_LOG_ERROR, "EOF before video frames\n");

            return -1;

        }else if(startcode == KEYFRAME_STARTCODE){

            nut->next_startcode= startcode;

            break;

        }else if(startcode != INFO_STARTCODE){

            continue;

        }



        decode_info_header(nut);

    }



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)
{ NUTContext *nut = VAR_0->priv_data; ByteIOContext *bc = &VAR_0->pb; int64_t pos; int VAR_2; nut->avf= VAR_0; pos=0; for(;;){ pos= find_startcode(bc, MAIN_STARTCODE, pos)+1; if (pos<0){ av_log(VAR_0, AV_LOG_ERROR, "no main startcode found\n"); return -1; } if(decode_main_header(nut) >= 0)
break; } VAR_0->bit_rate = 0; nut->stream = av_malloc(sizeof(StreamContext)*nut->stream_count); pos=0; for(VAR_2=0; VAR_2 < nut->stream_count;){ pos= find_startcode(bc, STREAM_STARTCODE, pos)+1; if (pos<0){ av_log(VAR_0, AV_LOG_ERROR, "not all stream headers found\n"); return -1; } if(decode_stream_header(nut) >= 0)
VAR_2++; } pos=0; for(;;){ uint64_t startcode= find_any_startcode(bc, pos); pos= url_ftell(bc); if(startcode==0){ av_log(VAR_0, AV_LOG_ERROR, "EOF before video frames\n"); return -1; }else if(startcode == KEYFRAME_STARTCODE){ nut->next_startcode= startcode; break; }else if(startcode != INFO_STARTCODE){ continue; } decode_info_header(nut); } return 0; }