assert (video_body->getFlags (i, &flags));
ADM_assert (video_body->getFlags (i, &flags));
void A_requantize2( float percent, uint32_t quality, char *out_name )	{	FILE 		*file=NULL;	uint32_t 	len,flags,lenout;	DIA_encoding	*encoding=NULL;	AVDMGenericAudioStream *audio=NULL;	double 		audioInc=0;	double		audioWanted=0,audioGot=0;	uint32_t	audioLen;	MpegMuxer	*muxer=NULL;	uint32_t	fps1000=0;			uint64_t size=0;	uint32_t fsize=0;	uint8_t *buffer 	= new uint8_t[avifileinfo->width * avifileinfo->height * 2];	uint8_t *outbuffer 	= new uint8_t[avifileinfo->width * avifileinfo->height * 2];	uint8_t *audioBuffer 	= new uint8_t[56000*10]; //  10 sec of audio at max bitrate 	Mrequant_init (percent,1);		 		// get audio if any	audio=mpt_getAudioStream(&audioInc);	if(audio)	{		fps1000=avifileinfo->fps1000;		muxer=new MpegMuxer;		if(!muxer->open(out_name,MUX_MPEG_VRATE,fps1000,audio->getInfo(),(float)audioInc))		{			GUI_Alert("Muxer init failed\n");			goto _abt;		}		// The requantizer will not alter the gop timestamp		// they (may) need to be resynced		muxer->forceRestamp();			}	else	{		file=fopen(out_name,"wb");		if(!file)		{			GUI_Alert("Problem writing file");			goto _abt;		}				}						encoding=new DIA_encoding(avifileinfo->fps1000);	encoding->setPhasis("Requantizing.");	encoding->setFrame(0,frameEnd-frameStart);			for(uint32_t i=frameStart;i<frameEnd;i++)	{		encoding->setFrame(i-frameStart,frameEnd-frameStart);		      		if(!encoding->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	  		PACK_FRAME(found);	  		// and the B frames	  		for (uint32_t j = i; j < found; j++)	    		{	      			PACK_FRAME(j);			}	  		i = found;		// Will be plussed by for		}      		else	// P or I frame		{	// First frame is special as we want the stream to begin by a SEQ_HEADER			// In case it is aleady the case do nothing			// If not, we fetch the seq header from the extraData, hoping it is there			if(i==frameStart)			{				video_body->getRaw (i, buffer, &len);								if(buffer[0]==0 && buffer[1]==0 && buffer[2]==1 && buffer[3]==0xb3) // Seq start				{						printf("1st frame contains the seq header\n");					Mrequant_frame(buffer,  len,outbuffer, &lenout); 						encoding->feedFrame(lenout);						if(!muxer) 	  					fwrite (outbuffer, lenout, 1, file); 					else					{						muxer->writeVideoPacket(lenout,outbuffer); 						aprintf("in:%03lu out:%03lu\n",len>>10,lenout>>10); \						PACK_AUDIO; 					}				}				else // need to add seq start				{					uint32_t seq;					video_body->getRawStart (frameStart, buffer, &seq);						printf("Adding seq header (%lu)\n",seq);						  				video_body->getRaw (i, buffer+seq, &len);					printf("Stat : %x %x %x %x\n",buffer[seq],buffer[seq+1],buffer[seq+2],								buffer[seq+3]);					Mrequant_frame(buffer,  len+seq,outbuffer, &lenout);					encoding->feedFrame(lenout);	 	  				if(!muxer) 	  					fwrite (outbuffer, lenout, 1, file); 					else					{						muxer->writeVideoPacket(lenout,outbuffer); 						PACK_AUDIO; 						aprintf("in:%03lu out:%03lu\n",len>>10,lenout>>10); \					}				}			}			else	  			PACK_FRAME(i);			}	}_abt:	if(encoding) delete encoding;	if(buffer) delete [] buffer;	if(outbuffer) delete [] outbuffer;	if(audioBuffer) delete [] audioBuffer;	if(file) fclose(file);	if(muxer) {	muxer->close();			delete muxer;			muxer=NULL;		   }	Mrequant_end();	deleteAudioFilter();	GUI_Alert("Done!");}