iOS/buildlibs/armv7/allegro-4.4.2/addons/jpgalleg/src/decode.c
/* read_sof0_chunk:
 *  Reads a SOF0 (Start Of Frame 0) chunk from the input stream.
 */
Reads a SOF0 (Start Of Frame 0) chunk from the input stream.
Reads a SOF0 ( Start Of Frame 0 ) chunk from the input stream .
static int
read_sof0_chunk(void)
{
	int i, data;
	_jpeg_open_chunk();
	if ((data = _jpeg_getc()) != 8) {
		TRACE("Unsupported data precision (%d)", data);
		jpgalleg_error = JPG_ERROR_UNSUPPORTED_DATA_PRECISION;
		return -1;
	}
	jpeg_h = _jpeg_getw();
	jpeg_w = _jpeg_getw();
	jpeg_components = _jpeg_getc();
	if ((jpeg_components != 1) && (jpeg_components != 3)) {
		TRACE("Unsupported number of components (%d)", jpeg_components);
		jpgalleg_error = JPG_ERROR_UNSUPPORTED_COLOR_SPACE;
		return -1;
	}
	for (i = 0; i < jpeg_components; i++) {
		switch (_jpeg_getc()) {
			case 1:
				data = _jpeg_getc();
				h_sampling = data >> 4;
				v_sampling = data & 0xf;
				sampling = h_sampling * v_sampling;
				if ((sampling != 1) && (sampling != 2) && (sampling != 4)) {
					TRACE("Bad sampling byte (%d)", sampling);
					jpgalleg_error = JPG_ERROR_BAD_IMAGE;
					return -1;
				}
				data = _jpeg_getc();
				if (data > 3) {
					TRACE("Bad quantization table number (%d)", data);
					jpgalleg_error = JPG_ERROR_BAD_IMAGE;
					return -1;
				}
				luminance_quantization_table = &quantization_table[data * 64];
				break;
			case 2:
			case 3:
				_jpeg_getc();
				data = _jpeg_getc();
				if (data > 3) {
					TRACE("Bad quantization table number (%d)", data);
					jpgalleg_error = JPG_ERROR_BAD_IMAGE;
					return -1;
				}
				chrominance_quantization_table = &quantization_table[data * 64];
				break;
		}
	}
	_jpeg_close_chunk();
	return 0;
}
static int read_sof0_chunk ( void ) { int i , data ; _jpeg_open_chunk ( ) ; if ( ( data = _jpeg_getc ( ) ) != 8 ) { TRACE ( " " , data ) ; jpgalleg_error = JPG_ERROR_UNSUPPORTED_DATA_PRECISION ; return -1 ; } jpeg_h = _jpeg_getw ( ) ; jpeg_w = _jpeg_getw ( ) ; jpeg_components = _jpeg_getc ( ) ; if ( ( jpeg_components != 1 ) && ( jpeg_components != 3 ) ) { TRACE ( " " , jpeg_components ) ; jpgalleg_error = JPG_ERROR_UNSUPPORTED_COLOR_SPACE ; return -1 ; } for ( i = 0 ; i < jpeg_components ; i ++ ) { switch ( _jpeg_getc ( ) ) { case 1 : data = _jpeg_getc ( ) ; h_sampling = data >> 4 ; v_sampling = data & 0xf ; sampling = h_sampling * v_sampling ; if ( ( sampling != 1 ) && ( sampling != 2 ) && ( sampling != 4 ) ) { TRACE ( " " , sampling ) ; jpgalleg_error = JPG_ERROR_BAD_IMAGE ; return -1 ; } data = _jpeg_getc ( ) ; if ( data > 3 ) { TRACE ( " " , data ) ; jpgalleg_error = JPG_ERROR_BAD_IMAGE ; return -1 ; } luminance_quantization_table = & quantization_table [ data * 64 ] ; break ; case 2 : case 3 : _jpeg_getc ( ) ; data = _jpeg_getc ( ) ; if ( data > 3 ) { TRACE ( " " , data ) ; jpgalleg_error = JPG_ERROR_BAD_IMAGE ; return -1 ; } chrominance_quantization_table = & quantization_table [ data * 64 ] ; break ; } } _jpeg_close_chunk ( ) ; return 0 ; }
read_sof0_chunk:
  Reads a SOF0 (Start Of Frame 0) chunk from the input stream.
read_sof0_chunk : Reads a SOF0 ( Start Of Frame 0 ) chunk from the input stream .