if(!memcmp(pkt_buf, gop_start_code, 4))
if(ps->forceRestamp)
int mux_write_packet(PackStream *ps,                      uint8_t pkt_id, uint8_t *pkt_buf, int pkt_len) {    static uint8_t seq_start_code [] = {0x00, 0x00, 0x01, MX_SEQ_CODE};    static uint8_t gop_start_code [] = {0x00, 0x00, 0x01, MX_GOP_CODE};        int payload_size;          ps->pkt_id  = pkt_id;    // 0xC0=MP2-Audio, 0x80=AC3 Audio, 0xE0=Video     ps->pkt_buf = pkt_buf;    ps->pkt_len = pkt_len;     ps->pts     = -1.0;    //-- different handling for video and audio data --     //-------------------------------------------------    if (pkt_id == VIDEO_ID)     {            if (pkt_len >= 4)      {      	        if ( !memcmp(pkt_buf, seq_start_code, 4) || !memcmp(pkt_buf, gop_start_code, 4) )        {		if(!memcmp(pkt_buf, gop_start_code, 4))		{			// MEANX			if(ps->forceRestamp)				mean_update_gop(ps,pkt_buf+4);			// /Meanx		}        	  //-- every 2nd. sequence/GOP insert a VOBU packet --          if (ps->gop_cnt==0)          {            mux_put_vobu_pack(ps);            ps->gop_cnt = 1;          }          else            ps->gop_cnt--;                  //-- every sequence/GOP packet will by PTS timestamped --          ps->pts = ps->frame_no * ps->pict_duration + ps->v_pts_ofs; // with videoffset        }      }      if(pkt_len>50) // Do not take isolated pack start      	ps->framecount++; //MEANX    }    else if (pkt_len)    {      double pts_step;                ps->audio_blocks = pkt_len/(double)ps->audio_encoded_fs;            //fprintf(stderr, "*** (%1.4f/%d len=%d) ***\n",       //        ps->audio_blocks, ps->audio_encoded_fs, pkt_len);      if (ps->audio_id == AUDIO_ID_MP2)         pts_step = ps->audio_blocks * 24;      else        pts_step = ps->audio_blocks * 32;      //-- every packet containing 1st. correspondend audio data --       //-- of the last frame (fields) will be PTS timestamped.   --      ps->pts = ps->audio_pts + ps->a_pts_ofs + ps->audio_delay;      ps->audio_pts += pts_step;           }    else    {      ps->audio_pts += ps->pict_duration;    }        while (ps->pkt_len > 0)    {      //-- flush stream data as packets (with padding last --      //-- packet to full packet size, if necessarily.)    --      payload_size = mux_put_av_pack(ps);            ps->pkt_buf += payload_size;      ps->pkt_len -= payload_size;      //-- in assumption, that audio data will be fit  into --      //-- at max 2 packs and ALL sync words will occur in  --      //-- 1st. pack the 2nd. pack can be timestamped with  --      //-- the same value prepared for next function call.  --      if (ps->pkt_id == AUDIO_ID_MP2)        ps->pts = ps->audio_pts + ps->a_pts_ofs + ps->audio_delay;      else        ps->pts = -1.0;      }      //-- after audio data -> update all pack SCRs and write unit --     if (ps->pkt_id < VIDEO_ID) return mux_flush_packs(ps);        //printf("A-V :%d\n",ps->audio_pts-ps->pts);    return 0;}