Esempio n. 1
0
static void Process(unsigned char* p, int width, int height, char * outfilename)
{
    unsigned char *rgb_buf = malloc(width * height * 3);

    ConvertYUV2RGB(p, rgb_buf, width, height);

    jpegWrite(rgb_buf, width, height, outfilename);

    free(rgb_buf);
}
Esempio n. 2
0
int DecompressFrame(unsigned char *cdata,int size,unsigned char *outdata,int outsize)
{
static int first=1,framenum=0;
		
		//Initialize output pointers...
		yp=NULL;
		up=NULL;
		vp=NULL;

		// Copy to other buffer can be done...
		// So that source buffer will be free
		 
		cindex=0;       // index into the cframe....
		csize=size;     // size of compressed frame 
		cframe=cdata;   // pointer to compressed frme
		//memcpy(cframe,cdata,size);


		// Reset the pointers...
		initbits();

		// Get the frame header
		getheader();

	
		// If first time...then call initdecoder....
		// This has to be done after calling getheader()
		// because getheader() setup some variables using the information
		// from header...

		if (first) 
		{
		   initdecoder();
		   first = 0;
		}

    

		// Decompress the frame and get the picture frame in YUV format
		getpicture(&framenum);
    
		framenum++;

		if(yp==NULL || up==NULL || vp==NULL)
		{
			if(trace)
			fputs("decompression failed...",dlog);
		
			return  0;
		}


   		// convert YUV to RGB
		// *******  TODO *********
		// check if outdata is enough to store rgb data
		//
		int totalsize=horizontal_size * vertical_size *3;
		if(outsize< totalsize || outdata==NULL)
		{
			if(dlog)
			fputs("Output buffer is not sufficient",dlog);
		return 0;			
		}

		ConvertYUV2RGB(yp,up,vp,outdata,horizontal_size,vertical_size);
 
return 1;
}