if(audio_id==AUDIO_ID_MP2) ps->audio_encoded_fs=(int)ceil(( MP2_FRAME_SIZE*a_bit_rate)/(8*sample_rate)); else ps->audio_encoded_fs=(int)ceil((AC3_FRAME_SIZE *a_bit_rate)/(8*sample_rate));  #if 0 ap.size_pf = (int)( (ap.samples_pf * ap.br) / (8.0 * ap.sr) + 0.5); fprintf(stderr, "\naudio stream type (%s) detected \n", (ap.id==AUDIO_ID_MP2)? "MP2":"AC3"); fprintf(stderr, "- sample rate (%d Hz)\n- bitrate (%d bps)\n- frame size (%d bytes)\n", ap.sr, ap.br, ap.size_pf); #endif
PackStream *mux_open(char *fn,                      int v_bit_rate, double frame_rate,                      int a_bit_rate, int sample_rate, uint8_t audio_id){  static PackStream _ps = {VOB_PACK_LEN, 40.0, V_PTS_DFLT, A_PTS_DFLT, NULL};    uint32_t muxrate = v_bit_rate + a_bit_rate + 2000;     PackStream   *ps = &_ps;    if (!v_bit_rate) muxrate = 10080000; // fixed defined for DVD    if (!strcmp(fn,"-"))  {    ps->fp = fdopen(1, "wb");    ps->is_stdout = 1;  }  else  {    ps->fp = fopen(fn, "w+b");    ps->is_stdout = 0;  }        if ( ps->fp )  {    ps->pack_start    = ps->stream_buf;    ps->buf_level     = 0;    ps->pack_cnt      = 0;        ps->frame_no      = 0;    ps->gop_cnt       = 0;    ps->pict_duration = 1000.0 / frame_rate;    ps->mux_rate = (muxrate + (8*50)-1) /(8*50);    ps->pts      = -1.0;    ps->scr      =  0.0;           ps->video_id    = VIDEO_ID;    ps->video_bound = 1;    ps->video_max_buf_size = 46 * 1024;     ps->video_pts   = 0;         ps->audio_id    = audio_id;    ps->audio_bound = 1;    ps->audio_delay = 0; //(audio_id == 0x80)? 200:0;    ps->audio_max_buf_size = 4 * 1024;    ps->audio_pts   = 0;       put_init_bp(&ps->bit_pack, ps->stream_buf); // equal to pack_start now        return ps;     }   return NULL; }