pred_count= 2 + codec->has_b_frames;
pred_count= 2 + codec->has_b_frames + (codec->codec_id == CODEC_ID_VORBIS);
static void build_frame_code(AVFormatContext *s){    NUTContext *nut = s->priv_data;    int key_frame, frame_type, full_pts, index, pred, stream_id;    int start=0;    int end= 255;    int keyframe_0_esc= s->nb_streams > 2;    if(keyframe_0_esc){        /* keyframe = 0 escapes, 3 codes */        for(frame_type=0; frame_type<2; frame_type++){            for(full_pts=frame_type; full_pts<2; full_pts++){                FrameCode *ft= &nut->frame_code[start];                ft->flags= FLAG_FRAME_TYPE*frame_type + FLAG_FULL_PTS*full_pts;                ft->flags|= FLAG_DATA_SIZE | FLAG_PTS;                 ft->stream_id_plus1= 0;                ft->size_mul=1;                start++;            }        }    }    for(stream_id= 0; stream_id<s->nb_streams; stream_id++){        int start2= start + (end-start)*stream_id / s->nb_streams;        int end2  = start + (end-start)*(stream_id+1) / s->nb_streams;        AVCodecContext *codec = &s->streams[stream_id]->codec;        int is_audio= codec->codec_type == CODEC_TYPE_AUDIO;        int intra_only= /*codec->intra_only || */is_audio;        int pred_count;        for(key_frame=0; key_frame<2; key_frame++){            if(intra_only && keyframe_0_esc && key_frame==0)                continue;                        for(frame_type=0; frame_type<2; frame_type++){                for(full_pts=frame_type; full_pts<2; full_pts++){                    FrameCode *ft= &nut->frame_code[start2];                    ft->flags= FLAG_FRAME_TYPE*frame_type + FLAG_FULL_PTS*full_pts + FLAG_KEY_FRAME*key_frame;                    ft->flags|= FLAG_DATA_SIZE | FLAG_PTS;                    ft->stream_id_plus1= stream_id + 1;                    ft->size_mul=1;                    start2++;                }            }        }        key_frame= intra_only;#if 1        if(is_audio){            int frame_bytes= codec->frame_size*(int64_t)codec->bit_rate / (8*codec->sample_rate);            for(pred=0; pred<MAX_SIZE_LRU; pred++){                for(frame_type=0; frame_type<1; frame_type++){                    FrameCode *ft= &nut->frame_code[start2];                    ft->flags= FLAG_KEY_FRAME*key_frame + (FLAG_FULL_PTS+FLAG_PTS+FLAG_FRAME_TYPE)*frame_type;                    ft->stream_id_plus1= stream_id + 1;                    ft->size_mul=1;                    ft->size_lsb=1 + pred;                    start2++;                }                nut->stream[stream_id].initial_size_predictor[pred]= frame_bytes + pred;            }        }else{            FrameCode *ft= &nut->frame_code[start2];            ft->flags= FLAG_KEY_FRAME | FLAG_DATA_SIZE;            ft->stream_id_plus1= stream_id + 1;            ft->size_mul=1;            start2++;        }#endif        pred_count= 2 + codec->has_b_frames;        for(pred=0; pred<pred_count; pred++){            int start3= start2 + (end2-start2)*pred / pred_count;            int end3  = start2 + (end2-start2)*(pred+1) / pred_count;            for(index=start3; index<end3; index++){                FrameCode *ft= &nut->frame_code[index];                ft->flags= FLAG_KEY_FRAME*key_frame + pred*4;                ft->flags|= FLAG_DATA_SIZE;                ft->stream_id_plus1= stream_id + 1;//FIXME use single byte size and pred from last                ft->size_mul= end3-start3;                ft->size_lsb= index - start3;            }            nut->stream[stream_id].initial_pts_predictor[pred]= pred+1;        }    }    memmove(&nut->frame_code['N'+1], &nut->frame_code['N'], sizeof(FrameCode)*(255-'N'));    nut->frame_code['N'].flags= 1;}