uint32_t seq; video_body->getRawStart (frameStart, buffer, &seq); video_body->getRaw (i, buffer+seq, &len); muxer->writeVideoPacket (len+seq,buffer); PACK_AUDIO(0)
video_body->getRaw (i, buffer, &len); if(buffer[0]==0 && buffer[1]==0 && buffer[2]==1 && buffer[3]==0xb3) { muxer->writeVideoPacket (len,buffer); PACK_AUDIO(0) } else { uint32_t seq; video_body->getRawStart (frameStart, buffer, &seq); video_body->getRaw (i, buffer+seq, &len); muxer->writeVideoPacket (len+seq,buffer); PACK_AUDIO(0) }
void mpeg_passthrough(  char *name ){  uint32_t len, flags;  AVDMGenericAudioStream *audio=NULL;  uint32_t audiolen;  uint8_t *buffer = new uint8_t[avifileinfo->width * avifileinfo->height * 3];    DIA_working *work;  double pcm=0;    double total_wanted=0;  double total_got=0;    MpegMuxer *muxer=NULL;    	printf("Saving as mpg PS to file %s\n",name);    	// First we check it is mpeg  	if(!fourCC::check(avifileinfo->fcc,(uint8_t *)"MPEG"))  	{  		GUI_Alert("This is not a mpeg.\nSwitch to process mode.");		return ;  	}  	if(!currentaudiostream)  	{  		GUI_Alert("There is no audio track.");		return ;  	}    	audio=mpt_getAudioStream(&pcm);	if(!audio)	{		GUI_Alert("Audio track is not suitable!\n");		return;	}			if(!pcm)	{		GUI_Alert("Audio track is not suitable(2)!\n");		return;	}	  	muxer=new MpegMuxer();	if(!muxer->open(name,MUX_MPEG_VRATE,avifileinfo->fps1000,audio->getInfo(),pcm))	{		delete muxer;		muxer=NULL;		printf("Muxer init failed\n");		return ;			}	// In copy mode it is better to recompute the gop timestamp	muxer->forceRestamp();  ///____________________________  work=new DIA_working("Saving MpegPS stream");  // preamble  /*  video_body->getRawStart (frameStart, buffer, &len);  muxer->writeVideoPacket (len,buffer);*/  for (uint32_t i = frameStart; i < frameEnd; i++)    {                  work->update (i - frameStart, frameEnd - frameStart);      if(!work->isAlive()) goto _abt;      assert (video_body->getFlags (i, &flags));      if (flags & AVI_B_FRAME)	// oops	{	  // se search for the next i /p	  uint32_t found = 0;	for (uint32_t j = i + 1; j < frameEnd; j++)	{		assert (video_body->getFlags (j, &flags));		if (!(flags & AVI_B_FRAME))		{			found = j;			break;		}	}	if (!found)	    goto _abt;	  // Write the found frame	video_body->getRaw (found, buffer, &len);	muxer->writeVideoPacket (len,buffer);		PACK_AUDIO(0)	  	  // and the B frames	for (uint32_t j = i; j < found; j++)	    {		video_body->getRaw (j, buffer, &len);		muxer->writeVideoPacket (len,buffer);		PACK_AUDIO(0)    	    }	  i = found;		// Will be plussed by for	}      else			// P or I frame	{		if(i==frameStart) // Pack sequ_start with the frame		{			uint32_t seq;			video_body->getRawStart (frameStart, buffer, &seq);  			  		video_body->getRaw (i, buffer+seq, &len);			muxer->writeVideoPacket (len+seq,buffer);			PACK_AUDIO(0)		}		else		{			video_body->getRaw (i, buffer, &len);			muxer->writeVideoPacket (len,buffer);					PACK_AUDIO(0)		}	}    }_abt:  delete work;  muxer->close();  delete muxer;  delete buffer;  deleteAudioFilter();}