示例#1
0
void InitH263Decoder()
{
 
    // Open log file
	dlog=fopen("decoder.log","w");
	
	if(dlog==NULL)
	{
	trace=0;
	quiet=1;
	verbose=0;
	}

     framerate=0;  // not used...
     outtype=0;    // YUV 
	 temp_ref = 0;
     prev_temp_ref= -1; 


     ld = &base; 
     
     initbits();    // Setup source buffer pointers
	 InitConvertTable();
     
 	 
	// For debugging....	 
	// trace=1;		// trace output
	// quiet=0;       // don't keep quiet print mesgs
	 
}
示例#2
0
int InitH263Decoder()
{
	
/*	if(dlog==NULL)
	{
	trace=0;
	quiet=1;
	verbose=0;
	__android_log_print(ANDROID_LOG_ERROR, "InitH263Decoder()","Unable to open log file: %s", strerror(errno) );
	return -1;
	}*/

   framerate=0;  // not used...
   outtype=0;    // YUV 
	temp_ref = 0;
   prev_temp_ref= -1; 

   ld = &base; 
     
	initbits();    // Setup source buffer pointers
	InitConvertTable();

	myLog.WriteLog((char*)"InitH263Decoder()",(char*)"Init OK");
	return 0;
 	 
	// For debugging....	 
	// trace=1;		// trace output
	// quiet=0;       // don't keep quiet print mesgs
	 
}
示例#3
0
static int decore_init(int hor_size, int ver_size, unsigned long color_depth)
{
	// init global stuff
	ld = &base;
	coeff_pred = &ac_dc;
	
	initbits ();
	
	// read first vol and vop
	mp4_hdr.width = hor_size;
	mp4_hdr.height = ver_size;
	
	mp4_hdr.quant_precision = 5;
	mp4_hdr.bits_per_pixel = 8;
	
	mp4_hdr.quant_type = 0;
	
	mp4_hdr.time_increment_resolution = 15;
	mp4_hdr.complexity_estimation_disable = 1;
	
	mp4_hdr.picnum = 0;
	mp4_hdr.mb_xsize = mp4_hdr.width / 16;
	mp4_hdr.mb_ysize = mp4_hdr.height / 16;
	mp4_hdr.mba_size = mp4_hdr.mb_xsize * mp4_hdr.mb_ysize;

	// set picture dimension global vars
	{
		horizontal_size = mp4_hdr.width;
		vertical_size = mp4_hdr.height;

		mb_width = horizontal_size / 16;
		mb_height = vertical_size / 16;

		coded_picture_width = horizontal_size + 64;
		coded_picture_height = vertical_size + 64;
		chrom_width = coded_picture_width >> 1;
		chrom_height = coded_picture_height >> 1;
	}

	// init decoder
	initdecoder();

	switch (color_depth)
		{
		case 32:
			convert_yuv = yuv2rgb_32;
			break;
		case 16:
			convert_yuv = yuv2rgb_16;
			break;
		default:
			convert_yuv = yuv2rgb_24;
			break;
		}

	return 1;
}
示例#4
0
static int decore_frame(unsigned char *stream, int length, unsigned char *bmp, int render_flag)
{
	decore_stream = stream;
	decore_length = length;

	initbits ();

	getvophdr(); // read vop header
	get_mp4picture(bmp, render_flag); // decode vop

	mp4_hdr.picnum++;

	return 1;
}
示例#5
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)
		{
			myLog.WriteLog((char*)"DecompressFrame",(char*)"decompression failed...");
			return  0;
		}
		*outdata = yp;
/*
        if(yp!=NULL && up!=NULL && vp!=NULL){
			FILE *fpyuv;
			if (framenum==1)
				fpyuv=fopen("/sdcard/video2.yuv","wb");
			else
				fpyuv=fopen("/sdcard/video2.yuv","ab");
			if (fpyuv!=NULL){
				char sMsgLog[128];
				int iUVSize = (horizontal_size/2) * (vertical_size/2);
				fwrite(yp,1,horizontal_size * vertical_size+(iUVSize*2), fpyuv);
				fclose(fpyuv);
			}
		}*/
		return 1;
	


   		// convert YUV to RGB
		// *******  TODO *********
		// check if outdata is enough to store rgb data
		//
		int totalsize=horizontal_size * vertical_size *4;
		if(outsize< totalsize || outdata==NULL)
		{
			myLog.WriteLog((char*)"DecompressFrame",(char*)"Output buffer is not sufficient");
			return 0;			
		}
		
//		ConvertYUVtoRGB32(yp,up,vp,outdata,horizontal_size,vertical_size);
		/*FILE *fpyuv;
		char sFileName[128];
		sprintf(sFileName, "/sdcard/video_%d.rgba", framenum);		
		fpyuv=fopen(sFileName,"wb");
		
		if (fpyuv!=NULL){
			fwrite(outdata,1,horizontal_size * vertical_size*4, fpyuv);
			fclose(fpyuv);
		}*/
		
		//myLog.WriteLog((char*)"DecompressFrame()",(char*)"Decode SUCCESSFUL :-)");
 
return 1;
示例#6
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;
}
示例#7
0
void mpeg2enc(UINT16 h_size,UINT16 v_size,UINT8* y_addr,UINT8* c_addr,UINT8* f_y_addr,UINT8* f_c_addr,UINT8* out_stream_buf,UINT32* out_stream_size)
{
	UINT32 dest_size = *out_stream_size;
	if(dest_size == 0) dest_size = 32768;
	
	#if (CAPTURE_MODE==FRAME_CAPTURE)
	prog_frame = 0;
	g_mquant = 18;
	#else //(CAPTURE_MODE==FIELD_CAPTURE)
	prog_frame = 1;
	g_mquant = 10;
	#endif

	do{

		g_bs_ptr = out_stream_buf;
		g_bs_len = 0;

		initparam();

		/* round picture dimensions to nearest multiple of 16 or 32 */
		mb_width = (h_size+15)/16;
	#if (CAPTURE_MODE==FRAME_CAPTURE)
		mb_height = prog_seq ? (v_size+15)/16 : 2*((v_size+31)/32);
	#else//(CAPTURE_MODE==FIELD_CAPTURE)
		mb_height = prog_seq ? (v_size/2+15)/16 : 2*((v_size/2+31)/32);
	#endif
		mb_height2 = fieldpic ? mb_height>>1 : mb_height; /* for field pictures */
		luma_width = 16*mb_width;
		luma_height = 16*mb_height;

		chrom_width = luma_width>>1;
		chrom_height = luma_height>>1;

		width2 = fieldpic ? luma_width<<1 : luma_width;
		chrom_width2 = fieldpic ? chrom_width<<1 : chrom_width;

		block_count = 6;//420

			
		neworg[0] = f_c_addr;
		neworg[1] = neworg[0]+luma_width*luma_height;
		neworg[2] = neworg[1]+chrom_width*chrom_height;	


		format_transform(y_addr,c_addr,neworg[0],neworg[1],neworg[2],luma_width,luma_height);

		initquantmat();
		initbits();

		putseq();
		//soc_printf("mquant:%d,bs_len:%d\n",g_mquant,g_bs_len);

		if(g_mquant == 62 && g_bs_len>dest_size) 
		{
			soc_printf("ERROR: compressed size exceed buffer size!\n");
			break;				
		} 

		if(g_bs_len*10/dest_size < 12)
			g_mquant +=2;
		else if(g_bs_len*10/dest_size < 15)
			g_mquant +=4;
		else if(g_bs_len*10/dest_size < 18)
			g_mquant +=6;
		else if(g_bs_len*10/dest_size < 21)
			g_mquant +=8;
		else			
			g_mquant +=10;
		
		if(g_mquant > 62) 
			g_mquant = 62;
		
	}while(g_bs_len > dest_size);
	
	*out_stream_size = g_bs_len;
	
	return ;
}