iOS/buildlibs/armv7/allegro-4.4.2/addons/jpgalleg/src/encode.c
/* write_quantization_table:
 *  Computes a quantization table given a quality value and writes it to the
 *  output stream.
 */
Computes a quantization table given a quality value and writes it to the
output stream.
Computes a quantization table given a quality value and writes it to the output stream .
static void
write_quantization_table(int *quant_table, const unsigned char *data, int quality)
{
	short temp[64], temp_table[64];
	double value, factor = QUALITY_FACTOR(quality);
	int i;
	for (i = 0; i < 64; i++) {
		if (quality == 100)
			value = (double)data[i] / 15.0;
		else
			value = (double)data[i] / factor;
		temp[i] = MID(1, (int)floor(value), 255);
	}
	zigzag_reorder(temp, temp_table);
	for (i = 0; i < 64; i++) {
		_jpeg_chunk_putc(temp_table[i]);
		quant_table[i] = (1 << 16) / (int)temp_table[i];
	}
}
static void write_quantization_table ( int * quant_table , const unsigned char * data , int quality ) { short temp [ 64 ] , temp_table [ 64 ] ; double value , factor = QUALITY_FACTOR ( quality ) ; int i ; for ( i = 0 ; i < 64 ; i ++ ) { if ( quality == 100 ) value = ( double ) data [ i ] / 15.0 ; else value = ( double ) data [ i ] / factor ; temp [ i ] = MID ( 1 , ( int ) floor ( value ) , 255 ) ; } zigzag_reorder ( temp , temp_table ) ; for ( i = 0 ; i < 64 ; i ++ ) { _jpeg_chunk_putc ( temp_table [ i ] ) ; quant_table [ i ] = ( 1 << 16 ) / ( int ) temp_table [ i ] ; } }
write_quantization_table:
  Computes a quantization table given a quality value and writes it to the
  output stream.
write_quantization_table : Computes a quantization table given a quality value and writes it to the output stream .