else { video_body->getRaw (i, buffer, &len); fwrite (buffer, len, 1, file);
else {   if(i==frameStart) { video_body->getRaw (i, buffer, &len); if(buffer[0]==0 && buffer[1]==0 && buffer[2]==1 && buffer[3]==0xb3) { Mrequant_frame(buffer,  len,outbuffer, &lenout); encoding->feedFrame(lenout); if(!muxer) fwrite (outbuffer, lenout, 1, file); else { muxer->writeVideoPacket(lenout,outbuffer); PACK_AUDIO; } } else { uint32_t seq; video_body->getRawStart (frameStart, buffer, &seq); video_body->getRaw (i, buffer+seq, &len);  Mrequant_frame(buffer,  len+seq,outbuffer, &lenout); encoding->feedFrame(lenout); if(!muxer) fwrite (outbuffer, lenout, 1, file); else { muxer->writeVideoPacket(lenout,outbuffer); PACK_AUDIO; } } } else PACK_FRAME(i);
void A_requantize2( float percent, uint32_t quality, char *out_name )	{	FILE 		*file=NULL;	char 		*requant;	char 		cmd[1024];	uint32_t 	len,flags;	DIA_working	*work;		if(!prefs->get(REQUANT_PATH, &requant))	{		GUI_Alert("Use misc->prefs to tell where m2vrequant is\n");		return;	}		uint64_t size=0;	uint32_t fsize=0;	uint8_t *buffer = new uint8_t[avifileinfo->width * avifileinfo->height * 2]; 	// Seq header must be taken this time 	video_body->getRawStart ( 0,(uint8_t*)buffer, &len);	size=len;	for(uint32_t i=frameStart;i<frameEnd;i++)	{		fsize=0;		video_body->getFrameSize(i,&fsize);		size+=fsize;	}			printf("Total size %llu bytes\n",size);	// Format is downquantize method [0-3] and size of stream	sprintf(cmd,"%s %f %lu %llu > %s",requant,percent,quality,size,out_name);	printf("Cmd : %s\n",cmd);	// send header	// recheck the file is there	file=fopen(requant,"rb");	if(!file)			{			GUI_Alert("Cannot locate M2Vrequant\nUse misc->preference");			return;		}	fclose(file);	file=popen(cmd,"w");	if(!file)		{	// probably too late if it fails			GUI_Alert("Cannot locate M2Vrequant\nUse misc->preference");			return;		}	printf("Sending seq header\n");	fwrite(buffer,1,len,file);	work=new DIA_working("Requantizing mpeg stream");		//  	and then body	//	We re-order to have DTS order	//	for(uint32_t i=frameStart;i<frameEnd;i++)	{	      		//printf("Frame %lu/%lu\n",i,avifileinfo->nb_frames);		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);	  		fwrite (buffer, len, 1, file);	  		// and the B frames	  		for (uint32_t j = i; j < found; j++)	    		{	      			video_body->getRaw (j, buffer, &len);	      			fwrite (buffer, len, 1, file);	    		}	  		i = found;		// Will be plussed by for		}      		else			// P or I frame		{	  		video_body->getRaw (i, buffer, &len);	  		fwrite (buffer, len, 1, file);	  				}	}_abt:	delete work;	delete [] buffer;	pclose(file);	GUI_Alert("Done!");}