iOS/buildlibs/armv7/allegro-4.4.2/addons/jpgalleg/src/decode.c
/* read_dqt_chunk:
 *  Reads a DQT (Define Quantization Table) chunk from the input stream.
 */
Reads a DQT (Define Quantization Table) chunk from the input stream.
Reads a DQT ( Define Quantization Table ) chunk from the input stream .
static int
read_dqt_chunk(void)
{
	int i, data;
	short *table, temp[64];
	float value;
	_jpeg_open_chunk();
	do {
  		data = _jpeg_getc();
		if ((data & 0xf) > 3) {
			TRACE("Bad quantization table number (%d)", data);
			jpgalleg_error = JPG_ERROR_BAD_IMAGE;
			return -1;
		}
		if (data & 0xf0) {
			TRACE("Unsupported quantization table data precision");
			jpgalleg_error = JPG_ERROR_UNSUPPORTED_DATA_PRECISION;
			return -1;
		}
		table = &quantization_table[(data & 0xf) * 64];
		for (i = 0; i < 64; i++)
			temp[i] = _jpeg_getc();
		zigzag_reorder(temp, table);
		for (i = 0; i < 64; i++) {
			value = (float)table[i] * AAN_FACTOR(i) * 16384.0;
			table[i] = ((int)value + (1 << 11)) >> 12;
		}
	} while (!_jpeg_eoc());
	_jpeg_close_chunk();
	return 0;
}
static int read_dqt_chunk ( void ) { int i , data ; short * table , temp [ 64 ] ; float value ; _jpeg_open_chunk ( ) ; do { data = _jpeg_getc ( ) ; if ( ( data & 0xf ) > 3 ) { TRACE ( " " , data ) ; jpgalleg_error = JPG_ERROR_BAD_IMAGE ; return -1 ; } if ( data & 0xf0 ) { TRACE ( " " ) ; jpgalleg_error = JPG_ERROR_UNSUPPORTED_DATA_PRECISION ; return -1 ; } table = & quantization_table [ ( data & 0xf ) * 64 ] ; for ( i = 0 ; i < 64 ; i ++ ) temp [ i ] = _jpeg_getc ( ) ; zigzag_reorder ( temp , table ) ; for ( i = 0 ; i < 64 ; i ++ ) { value = ( float ) table [ i ] * AAN_FACTOR ( i ) * 16384.0 ; table [ i ] = ( ( int ) value + ( 1 << 11 ) ) >> 12 ; } } while ( ! _jpeg_eoc ( ) ) ; _jpeg_close_chunk ( ) ; return 0 ; }
read_dqt_chunk:
  Reads a DQT (Define Quantization Table) chunk from the input stream.
read_dqt_chunk : Reads a DQT ( Define Quantization Table ) chunk from the input stream .