Ejemplo n.º 1
0
/*
 * Decode a 1x2 mcu
 *  .---.
 *  | 1 |
 *  |---|
 *  | 2 |
 *  `---'
 */
static void decode_MCU_1x2_1plane(struct jdec_private *priv)
{
  // Y
  process_Huffman_data_unit(priv, cY);
  IDCT(&priv->component_infos[cY], priv->Y, 8);
  process_Huffman_data_unit(priv, cY);
  IDCT(&priv->component_infos[cY], priv->Y+64, 8);

  // Cb
  process_Huffman_data_unit(priv, cCb);

  // Cr
  process_Huffman_data_unit(priv, cCr);
}
Ejemplo n.º 2
0
/*
 * Decode all the 3 components for 1x1 
 */
static void decode_MCU_1x1_3planes(struct jdec_private *priv)
{
  // Y
  process_Huffman_data_unit(priv, cY);
  IDCT(&priv->component_infos[cY], priv->Y, 8);
  
  // Cb
  process_Huffman_data_unit(priv, cCb);
  IDCT(&priv->component_infos[cCb], priv->Cb, 8);

  // Cr
  process_Huffman_data_unit(priv, cCr);
  IDCT(&priv->component_infos[cCr], priv->Cr, 8);
}
Ejemplo n.º 3
0
Archivo: compute.c Proyecto: claf/MJPEG
int idct_process (Channel * c[2]) {
#ifdef DEADLOCK
  printf("Thread compute 0x%.8x has been created\n", (unsigned int)pthread_self());
#endif

	uint8_t * Idct_YCbCr;
	int32_t * block_YCbCr;
	uint32_t flit_size = 0;

	channelRead (c[0], (uint8_t *) & flit_size, sizeof (uint32_t));
	VPRINTF("Flit size = %lu\r\n", flit_size);

	Idct_YCbCr = (uint8_t *) malloc (flit_size * 64 * sizeof (uint8_t));
	if (Idct_YCbCr == NULL) printf ("%s,%d: malloc failed\n", __FILE__, __LINE__);

	block_YCbCr = (int32_t *) malloc (flit_size * 64 * sizeof (int32_t));
	if (block_YCbCr == NULL) printf ("%s,%d: malloc failed\n", __FILE__, __LINE__);

	while (1) {
		channelRead (c[0], (unsigned char *) block_YCbCr, flit_size * 64 * sizeof (int32_t));

		for (uint32_t i = 0; i < flit_size; i++) IDCT(& block_YCbCr[i * 64], & Idct_YCbCr[i * 64]);

		channelWrite (c[1], (unsigned char *) Idct_YCbCr, flit_size * 64 * sizeof (uint8_t));
	}

	return 0;
}
Ejemplo n.º 4
0
int main() {
  freopen("Lena.raw", "rb", stdin);
  int r, c;
  for (r = 0; r < N; r++)
    for (c = 0; c < N; c++)
      scanf("%c", &pic[r][c]);
  init();
  DCT();
  quantization();
  IDCT();
  MSE();
  return 0;
}
Ejemplo n.º 5
0
/* Decode un bloc frequentiel dans le fichier et renvoie un bloc pixmap */
void get_pixmap_block(uint8_t *pixmap_block, FILE *f, scan_desc_t *scan, 
		      uint8_t index, image_t *im, uint16_t RI, 
		      uint8_t QT[2][_BSIZE]) 
{
        /* decompression d'une MCU frequentielle zigzag quant. */
	printbody2("   │   ├─  Unpack block...\n");
	int32_t bck_freq_qzz[_BSIZE];
	unpack_block_sync(f,scan,RI,index,bck_freq_qzz);
	
        /* dequantification et dezigzag */
	printbody2("   │   ├─  IQZZ block...\n");
	int32_t bck_freq[_BSIZE];
	iqzz_block(bck_freq_qzz, bck_freq, QT[im->comp[index].iq]);
	
        /* conversion du domaine frequentiel vers bitmap */
	printbody2("   │   └─  IDCT block...\n");
	IDCT(bck_freq,pixmap_block);
}
Ejemplo n.º 6
0
bool CBaseDecoder::PerformSynthesis(float *InputFreq, float *ToHere, int Channel, int step)
{
	if(Channel)
		ToHere ++;

	/* We have 18 time-vectors of 32 subband magnitudes each. For every
	   vector of 32 magnitudes, the subband synthesis generates 32
	   PCM samples, so the result of 18 of these is 18*32=576 samples.
	 */

	/* advance the buffer position */
	Vpointer[Channel] = (Vpointer[Channel] - 64) & 0x3ff;

	IDCT(InputFreq, &V[ Channel ][ Vpointer[Channel] ]);

	/* 32*16=512 mac's */

	Window(Channel, ToHere, step);

	return(true);
}
/* Perform IDCT on Y channel of the image converted to DCT

*/
void MyImage::IDCTBasedCompDecomp()
{
	//memory allocated for  elements of each column.
	floatsYIDCTBlock = new float *[Height];

	for( int i = 0 ; i < Height ; i++ )
	{
		floatsYIDCTBlock[i] = new float[Width];
	}
	
	if(PRINTIDCT == 1)
	{
		remove("IDCT.txt");
	}

	//Perform Discrete Cosine Transform
	// Converts image from spatial or pixel domain into frequency domain
	for(int row = 0; row < Height; row += 8)
	{
		for(int col = 0; col < Width; col += 8)
		{
			IDCT(row, col);

			if(PRINTIDCT == 1)
			{
				PrintIDCT(row, col);
			}
		}
	}
	
	// Convert format from 
	//From 2D Array [YYYY..Y	[UUUU..U	[VVVV..V
	//			   YYYY..]	 UUUU..U]	 VVVV..V]
	//To Linear array [YYYY...Y][UUUU...U][VVVV...V]
	LinearArrayForm();
}
Ejemplo n.º 8
0
mlib_status
__mlib_VideoIDCT8x8_S16_S16_B12(
	mlib_s16 *block,
	const mlib_s16 *coeffs)
{
	mlib_d64 *dPtr = (mlib_d64 *)coeffs;
	mlib_d64 *outPtr = (mlib_d64 *)block;
	mlib_d64 dx0, dx1, dx2, dx3, dx4, dx6, dx7, dx8;
	mlib_d64 p00, p10, p20, p30, p40, p50, p60, p70,
		p01, p11, p21, p31, p41, p51, p61, p71;
	mlib_d64 t0, t1;
	mlib_d64 d0, d1, d2, d3, d4, d5, d6, d7;

	mlib_f32 COS_1_16;
	mlib_f32 COS_2_16;
	mlib_f32 COS_6_16;
	mlib_f32 COS_7_16;
	mlib_f32 COS_4_16;
	mlib_f32 C_1_4;

/* First pass */

	vis_write_bmask(0x018923ab, 0x0);

	LOAD_DATA_AA1 COS_1_16 = ((mlib_f32 *)mlib_cTable)[0];
	COS_2_16 = ((mlib_f32 *)mlib_cTable)[1];
	COS_6_16 = ((mlib_f32 *)mlib_cTable)[2];
	COS_7_16 = ((mlib_f32 *)mlib_cTable)[3];
	COS_4_16 = ((mlib_f32 *)mlib_cTable)[4];
	C_1_4 = ((mlib_f32 *)mlib_cTable)[5];

	TRANSPOSE_VIS2(p00, p10, p20, p30, d0, d1, d2, d3)
		TRANSPOSE_VIS2(p01, p11, p21, p31, d4, d5, d6, d7)
		LOAD_DATA_AA2 IDCT(d0, d1, d2, d3, d4, d5, d6, d7)
		TRANSPOSE_VIS2(p40, p50, p60, p70, d0, d1, d2, d3)
		p00 = vis_fpadd16(dx7, dx1);
	p10 = vis_fpadd16(dx3, dx2);
	p20 = vis_fpadd16(dx0, dx4);
	p30 = vis_fpadd16(dx8, dx6);
	p01 = vis_fpsub16(dx8, dx6);
	p11 = vis_fpsub16(dx0, dx4);
	p21 = vis_fpsub16(dx3, dx2);
	p31 = vis_fpsub16(dx7, dx1);

	TRANSPOSE_VIS2(p41, p51, p61, p71, d4, d5, d6, d7)
		IDCT(d0, d1, d2, d3, d4, d5, d6, d7)
		TRANSPOSE_VIS2(p00, p10, p20, p30, d0, d1, d2, d3)
		p40 = vis_fpadd16(dx7, dx1);
	p50 = vis_fpadd16(dx3, dx2);
	p60 = vis_fpadd16(dx0, dx4);
	p70 = vis_fpadd16(dx8, dx6);
	p41 = vis_fpsub16(dx8, dx6);
	p51 = vis_fpsub16(dx0, dx4);
	p61 = vis_fpsub16(dx3, dx2);
	p71 = vis_fpsub16(dx7, dx1);

/* Second pass */

	TRANSPOSE_VIS2(p40, p50, p60, p70, d4, d5, d6, d7)
		IDCT(d0, d1, d2, d3, d4, d5, d6, d7)
		TRANSPOSE_VIS2(p01, p11, p21, p31, d0, d1, d2, d3)
		outPtr[0] = vis_fmul8x16(C_1_4, vis_fpadd16(dx7, dx1));
	outPtr[2] = vis_fmul8x16(C_1_4, vis_fpadd16(dx3, dx2));
	outPtr[4] = vis_fmul8x16(C_1_4, vis_fpadd16(dx0, dx4));
	outPtr[6] = vis_fmul8x16(C_1_4, vis_fpadd16(dx8, dx6));
	outPtr[8] = vis_fmul8x16(C_1_4, vis_fpsub16(dx8, dx6));
	outPtr[10] = vis_fmul8x16(C_1_4, vis_fpsub16(dx0, dx4));
	outPtr[12] = vis_fmul8x16(C_1_4, vis_fpsub16(dx3, dx2));
	outPtr[14] = vis_fmul8x16(C_1_4, vis_fpsub16(dx7, dx1));

	TRANSPOSE_VIS2(p41, p51, p61, p71, d4, d5, d6, d7)
		IDCT(d0, d1, d2, d3, d4, d5, d6, d7)
		outPtr[1] = vis_fmul8x16(C_1_4, vis_fpadd16(dx7, dx1));
	outPtr[3] = vis_fmul8x16(C_1_4, vis_fpadd16(dx3, dx2));
	outPtr[5] = vis_fmul8x16(C_1_4, vis_fpadd16(dx0, dx4));
	outPtr[7] = vis_fmul8x16(C_1_4, vis_fpadd16(dx8, dx6));
	outPtr[9] = vis_fmul8x16(C_1_4, vis_fpsub16(dx8, dx6));
	outPtr[11] = vis_fmul8x16(C_1_4, vis_fpsub16(dx0, dx4));
	outPtr[13] = vis_fmul8x16(C_1_4, vis_fpsub16(dx3, dx2));
	outPtr[15] = vis_fmul8x16(C_1_4, vis_fpsub16(dx7, dx1));

	return (MLIB_SUCCESS);
}
Ejemplo n.º 9
0
void PitchMod::Modification()
{
	int i,j;
	float in1,in2;
	pml=0;
	float inc;
	TRACE("\n PMS -l = %d",PMS_l);
	Signal = new float [PMS_l];
	Modifx = new short int [PMS_l*2];
	for(i=0;i<PMS_l;i++)
		Signal[i] = float(PMSignal[i]);
	//AfxMessageBox("Fine");
	PitchMark();
	Find = new int [PMS_l];

	//storing the pitch marked indices in Find array
	for(i=0,j=0;i<PMS_l;i++)
	{
		if(PMark[i] == 1)
		{
			Find[j]=i;
			//TRACE("Find = %d\n",Find[j]);
			j++; // stores the no. of pitch marks
		}
	}
	count=j-1; // total no of pitch marks
	// Pitch modification
	in1=float(1.0);
	int f,fin,cnt,cc,k=0;
	float pe,*ccc;
	ccc = new float [count];
	if(Type == 1)//question
	{
		if(Mod_Count == 1)
		{
			in1=float(1.0);//in question,pitch should raise
			in2=float(1.1);//so from 1.0 to 1.1
		}
		else if(Mod_Count == 2)
		{
			in1 = float(1.0);
			in2 = float(1.1);
		}
	}
	else if(Type == 2)//exclamation
	{
		if(Mod_Count == 1)
		{
			in1 = float(1.0);//in exclmtn,pitch should raise
			in2 = float(1.1);//so from 1.0 to 1.1
		}
		else if(Mod_Count == 2)
		{
			in1=float(1.0);
			in2=float(1.1);
		}
	}
	else if(Type == 3)//comma
	{
		in1=float(1.0);//in comma,pitch should drop
		in2=float(0.95);//so from 1.0 to .95
	}
	else if(Type == 4)//dot
	{
		in1=float(1.0);//in dot,pitch should drop
		in2 = float(0.9);//so from 1.0 to .9
	}

	inc=float(in2-in1)/count;
	//inc=float((log(in2)-log(in1))/float(count));
	
	//TRACE("inc = %f",inc);
	/*for(i=0;i<count;i++)
	{
		ccc[i]=float(exp(log(in1)+i*inc));
	//	TRACE(" ccc = %f",ccc[i]);
	}*/
	
	
	f=0; fin=1; cnt=0; cc=1;j=0;
	len_modifx=0;
	while(j<count)//count contains total no. of pitch marks
	{
		k=0;
		//TRACE("\n Pass 1 i=%d,Find = %d",i,Find[j+1]);
		for(i=Find[j];i<=Find[j+1];i++) //read 1 frame data,from 1 pitchmark to another
		{
			frame[k]=Signal[i];
			k++;
		}	
		j=j+1; 
		frame_l=k-1; //no. of points in the frame
		int a_l,b_l,x_l;
		float *g;
		g = new float;
		g[0]=1.0;
		LPC();
		b_l=11;
		a_l=1;
		x_l=frame_l;
		Filter(LpcCoeff,g,frame,b_l,a_l,x_l);
		Excitation = new float [frame_l];
		Excitation=y;
		FDCT();
		pe=float(1.0/(in1+cnt*inc));
		//pe=float(1.0/ccc[cnt]);
		len=int(ceil(pe*frame_l));
		//TRACE("len = %d frame_l = %d\t",len,frame_l);
		IDCT();
		b_l=1;
		a_l=11;
		x_l=len;
		Filter(g,LpcCoeff,IDctCoeff,b_l,a_l,x_l);

		for(i=0;i<len;i++)
		{

            Modifx[pml]=(sqrt(1.0*frame_l/len) * y[i]);
			len_modifx++;
			pml=pml+1;
		}
		// Normalisation 
		short int max=0;
		for(i=0;i<len;i++)
		{
			//Modifx[i]=abs(Modifx[i]);
			if(abs(Modifx[i]) > max)
				max=abs(Modifx[i]);
		}
		//TRACE(" \nmax = %d",max);
		for(i=0;i<len;i++)
			Modifx[i]=short int(Modifx[i]*1.0/max);
		cc=cc+1;   
		cnt=cnt+1;
		delete [] DctCoeff;
		delete [] IDctCoeff;
		delete [] Excitation;
		delete [] y;
		delete [] g;
		pml--;
		//TRACE(" j= %d count = %d",j,count);
	}//endof loop for all pitch marks
	pml--;
	delete [] ccc;
	TRACE("\nOut of PM");
}//Modification()