Exemple #1
0
void
setq(int q)
{
	int qt[64];
	jpeg_luma_qt(q, qt);
	for (int i = 0; i < 64; ++i)
		jfifhdr[i + JFIF_OFF_LUMA_QUANT] = qt[i];
	jpeg_chroma_qt(q, qt);
	for (i = 0; i < 64; ++i)
		jfifhdr[i + JFIF_OFF_CHROMA_QUANT] = qt[i];
}
void XILOutputAssistor::setq(int q)
{
        int	qt[8][8];
	XilJpegQTable	xq;

	inq_ = q;
	sentfirstheader=0;

	jpeg_luma_qt(q, (int*)qt);
	xq.table = 0;
	xq.value = qt;
	(void)xil_cis_set_attribute(cis_, "QUANTIZATION_TABLE", (void*)&xq);
	jpeg_chroma_qt(q, (int*)qt);
	xq.table = 1;
	xq.value = qt;
	(void)xil_cis_set_attribute(cis_, "QUANTIZATION_TABLE", (void*)&xq);
}
void XILWindowAssistor::reset(int type,int q, int w, int h)
{
        int		qt[64];
	unsigned int		i,j;

	//fprintf(stderr,"XILWindowAssistor::"__FUNCTION__"\n");
	Module::size(w, h);

	inq_ = q;
	sentfirstheader=0;
	lastjpegtype_ = type;
	switch (type) {
	case 1: /* 420 */
		decimation_ = 420;
		break;
	default:
		decimation_ = 422;
		break;
	}
	for (i=0;i<sizeof(jfif_header1_);i++) {
		if (jfif_header1[i]!=0xff)
			continue;
		i++;if (i==sizeof(jfif_header1)) break;
		switch (jfif_header1[i]) {
		case M_DQT:
			//well the size is correct. we have defined the table
			i+=3;
			switch (jfif_header1[i]) {
			case 0:/* LUMA */
				i++;
				jpeg_luma_qt(q,qt);
				for (j=0;j<64;j++)
					jfif_header1[i+j]=qt[mapkoord2jfifentry[j]];
				break;
			case 1:/* CHROMA */
				i++;
				jpeg_chroma_qt(q,qt);
				for (j=0;j<64;j++)
					jfif_header1[i+j]=qt[mapkoord2jfifentry[j]];
				break;
			}
			break;
		case M_SOF0:
			i+=3;
			i++;	/* sample precision */
			jfif_header1[i++] = h>>8;
			jfif_header1[i++] = h&0xff;
			jfif_header1[i++] = w>>8;
			jfif_header1[i++] = w&0xff;
			i++; 	/* components (3) */
				i++;	/* comp id 0 */
				if (decimation_ == 420)
					jfif_header1[i++] = 0x22;/* 0x22 for 2 hor/2 vert */
				else
					jfif_header1[i++] = 0x21;/* 0x21 for 2 hor/1 vert */
				i++;	/* quant dest */

				i++;	/* comp id 1 */
				i++;	/* hor/ver quant 1:1 */
				i++;	/* quant dest */

				i++;	/* comp id 2 */
				i++;	/* hor/ver quant 1:1 */
				i++;	/* quant dest */
			break;
		default:
			//fprintf(stderr,"blocktype %02x\n",jfif_header1[i]);
			break;
		}
	}
	for (i=0;i<sizeof(jfif_header2);i++) {
		if (jfif_header2[i]!=0xff)
			continue;
		i++;if (i==sizeof(jfif_header2)) break;
		switch (jfif_header2[i]) {
		case M_SOF0:
			i+=3;
			i++;	/* sample precision */
			jfif_header2[i++] = h>>8;
			jfif_header2[i++] = h&0xff;
			jfif_header2[i++] = w>>8;
			jfif_header2[i++] = w&0xff;
			i++; 	/* components (3) */
				i++;	/* comp id 0 */
				if (decimation_ == 420)
					jfif_header2[i++] = 0x22;/* 0x22 for 2 hor/2 vert */
				else
					jfif_header2[i++] = 0x21;/* 0x21 for 2 hor/1 vert */
				i++;	/* quant dest */

				i++;	/* comp id 1 */
				i++;	/* hor/ver quant 1:1 */
				i++;	/* quant dest */

				i++;	/* comp id 2 */
				i++;	/* hor/ver quant 1:1 */
				i++;	/* quant dest */
			break;
		default:
			break;
		}
	}
	/*
	 * Make sure all outstanding putimage's finish.
	 * Syncing with the first window, syncs the server,
	 * and hence all of them.
	 */
	window_->sync();
}