|
<html><head><title>dlib C++ Library - jcmaster.c</title></head><body bgcolor='white'><pre> |
|
<font color='#009900'>/*
|
|
* jcmaster.c
|
|
*
|
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
|
* Modified 2003-2011 by Guido Vollbeding.
|
|
* This file is part of the Independent JPEG Group's software.
|
|
* For conditions of distribution and use, see the accompanying README file.
|
|
*
|
|
* This file contains master control logic for the JPEG compressor.
|
|
* These routines are concerned with parameter validation, initial setup,
|
|
* and inter-pass control (determining the number of passes and the work
|
|
* to be done in each pass).
|
|
*/</font>
|
|
|
|
<font color='#0000FF'>#define</font> JPEG_INTERNALS
|
|
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='jinclude.h.html'>jinclude.h</a>"
|
|
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='jpeglib.h.html'>jpeglib.h</a>"
|
|
|
|
|
|
<font color='#009900'>/* Private state */</font>
|
|
|
|
<font color='#0000FF'>typedef</font> <font color='#0000FF'>enum</font> <b>{</b>
|
|
main_pass, <font color='#009900'>/* input data, also do first output step */</font>
|
|
huff_opt_pass, <font color='#009900'>/* Huffman code optimization pass */</font>
|
|
output_pass <font color='#009900'>/* data output pass */</font>
|
|
<b>}</b> c_pass_type;
|
|
|
|
<font color='#0000FF'>typedef</font> <font color='#0000FF'>struct</font> <b>{</b>
|
|
<font color='#0000FF'>struct</font> jpeg_comp_master pub; <font color='#009900'>/* public fields */</font>
|
|
|
|
c_pass_type pass_type; <font color='#009900'>/* the type of the current pass */</font>
|
|
|
|
<font color='#0000FF'><u>int</u></font> pass_number; <font color='#009900'>/* # of passes completed */</font>
|
|
<font color='#0000FF'><u>int</u></font> total_passes; <font color='#009900'>/* total # of passes needed */</font>
|
|
|
|
<font color='#0000FF'><u>int</u></font> scan_number; <font color='#009900'>/* current index in scan_info[] */</font>
|
|
<b>}</b> my_comp_master;
|
|
|
|
<font color='#0000FF'>typedef</font> my_comp_master <font color='#5555FF'>*</font> my_master_ptr;
|
|
|
|
|
|
<font color='#009900'>/*
|
|
* Support routines that do various essential calculations.
|
|
*/</font>
|
|
|
|
<font color='#009900'>/*
|
|
* Compute JPEG image dimensions and related values.
|
|
* NOTE: this is exported for possible use by application.
|
|
* Hence it mustn't do anything that can't be done twice.
|
|
*/</font>
|
|
|
|
<b><a name='GLOBAL'></a>GLOBAL</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='jpeg_calc_jpeg_dimensions'></a>jpeg_calc_jpeg_dimensions</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo<font face='Lucida Console'>)</font>
|
|
<font color='#009900'>/* Do computations that are needed before master selection phase */</font>
|
|
<b>{</b>
|
|
<font color='#0000FF'>#ifdef</font> DCT_SCALING_SUPPORTED
|
|
|
|
<font color='#009900'>/* Sanity check on input image dimensions to prevent overflow in
|
|
* following calculation.
|
|
* We do check jpeg_width and jpeg_height in initial_setup below,
|
|
* but image_width and image_height can come from arbitrary data,
|
|
* and we need some space for multiplication by block_size.
|
|
*/</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>></font><font color='#5555FF'>></font> <font color='#979000'>24</font><font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>></font><font color='#5555FF'>></font> <font color='#979000'>24</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_IMAGE_TOO_BIG, <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font> JPEG_MAX_DIMENSION<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* Compute actual JPEG image dimensions and DCT scaling choices. */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/1 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>2</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/2 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>2</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>2</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>2</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>2</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>3</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/3 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>3</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>3</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>3</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>3</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>4</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/4 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>4</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>4</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>4</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>4</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>5</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/5 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>5</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>5</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>5</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>5</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>6</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/6 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>6</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>6</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>6</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>6</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>7</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/7 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>7</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>7</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>7</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>7</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>8</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/8 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>8</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>8</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>8</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>8</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>9</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/9 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>9</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>9</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>9</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>9</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>10</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/10 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>10</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>10</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>10</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>10</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>11</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/11 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>11</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>11</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>11</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>11</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>12</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/12 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>12</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>12</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>12</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>12</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>13</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/13 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>13</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>13</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>13</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>13</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>14</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/14 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>14</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>14</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>14</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>14</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_num <font color='#5555FF'>*</font> <font color='#979000'>15</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scale_denom <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/15 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>15</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>15</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>15</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>15</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
|
|
<font color='#009900'>/* Provide block_size/16 scaling */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>16</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, <font color='#979000'>16</font>L<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>16</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> <font color='#979000'>16</font>;
|
|
<b>}</b>
|
|
|
|
<font color='#0000FF'>#else</font> <font color='#009900'>/* !DCT_SCALING_SUPPORTED */</font>
|
|
|
|
<font color='#009900'>/* Hardwire it to "no scaling" */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_height;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>=</font> DCTSIZE;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>=</font> DCTSIZE;
|
|
|
|
<font color='#0000FF'>#endif</font> <font color='#009900'>/* DCT_SCALING_SUPPORTED */</font>
|
|
<b>}</b>
|
|
|
|
|
|
<b><a name='LOCAL'></a>LOCAL</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='jpeg_calc_trans_dimensions'></a>jpeg_calc_trans_dimensions</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo<font face='Lucida Console'>)</font>
|
|
<b>{</b>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>!</font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT2</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_DCTSIZE,
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size, cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size<font face='Lucida Console'>)</font>;
|
|
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size;
|
|
<b>}</b>
|
|
|
|
|
|
<b><a name='LOCAL'></a>LOCAL</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='initial_setup'></a>initial_setup</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo, boolean transcode_only<font face='Lucida Console'>)</font>
|
|
<font color='#009900'>/* Do computations that are needed before master selection phase */</font>
|
|
<b>{</b>
|
|
<font color='#0000FF'><u>int</u></font> ci, ssize;
|
|
jpeg_component_info <font color='#5555FF'>*</font>compptr;
|
|
<font color='#0000FF'><u>long</u></font> samplesperrow;
|
|
JDIMENSION jd_samplesperrow;
|
|
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>transcode_only<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jpeg_calc_trans_dimensions</font><font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>else</font>
|
|
<font color='#BB00BB'>jpeg_calc_jpeg_dimensions</font><font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* Sanity check on block_size */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size <font color='#5555FF'><</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size <font color='#5555FF'>></font> <font color='#979000'>16</font><font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT2</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_DCTSIZE, cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size, cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* Derive natural_order from block_size */</font>
|
|
<font color='#0000FF'>switch</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>case</font> <font color='#979000'>2</font>: cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>natural_order <font color='#5555FF'>=</font> jpeg_natural_order2; <font color='#0000FF'>break</font>;
|
|
<font color='#0000FF'>case</font> <font color='#979000'>3</font>: cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>natural_order <font color='#5555FF'>=</font> jpeg_natural_order3; <font color='#0000FF'>break</font>;
|
|
<font color='#0000FF'>case</font> <font color='#979000'>4</font>: cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>natural_order <font color='#5555FF'>=</font> jpeg_natural_order4; <font color='#0000FF'>break</font>;
|
|
<font color='#0000FF'>case</font> <font color='#979000'>5</font>: cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>natural_order <font color='#5555FF'>=</font> jpeg_natural_order5; <font color='#0000FF'>break</font>;
|
|
<font color='#0000FF'>case</font> <font color='#979000'>6</font>: cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>natural_order <font color='#5555FF'>=</font> jpeg_natural_order6; <font color='#0000FF'>break</font>;
|
|
<font color='#0000FF'>case</font> <font color='#979000'>7</font>: cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>natural_order <font color='#5555FF'>=</font> jpeg_natural_order7; <font color='#0000FF'>break</font>;
|
|
<font color='#0000FF'>default</font>: cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>natural_order <font color='#5555FF'>=</font> jpeg_natural_order; <font color='#0000FF'>break</font>;
|
|
<b>}</b>
|
|
|
|
<font color='#009900'>/* Derive lim_Se from block_size */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>lim_Se <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size <font color='#5555FF'><</font> DCTSIZE ?
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size <font color='#5555FF'>-</font> <font color='#979000'>1</font> : DCTSIZE2<font color='#5555FF'>-</font><font color='#979000'>1</font>;
|
|
|
|
<font color='#009900'>/* Sanity check on image dimensions */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'><</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'><</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components <font color='#5555FF'><</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>input_components <font color='#5555FF'><</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT</font><font face='Lucida Console'>(</font>cinfo, JERR_EMPTY_IMAGE<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* Make sure image isn't bigger than I can handle */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>></font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> JPEG_MAX_DIMENSION <font color='#5555FF'>|</font><font color='#5555FF'>|</font>
|
|
<font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>></font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> JPEG_MAX_DIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_IMAGE_TOO_BIG, <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font> JPEG_MAX_DIMENSION<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* Width of an input scanline must be representable as JDIMENSION. */</font>
|
|
samplesperrow <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>image_width <font color='#5555FF'>*</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>input_components;
|
|
jd_samplesperrow <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font> samplesperrow;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> jd_samplesperrow <font color='#5555FF'>!</font><font color='#5555FF'>=</font> samplesperrow<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT</font><font face='Lucida Console'>(</font>cinfo, JERR_WIDTH_OVERFLOW<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* For now, precision must match compiled-in value... */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>data_precision <font color='#5555FF'>!</font><font color='#5555FF'>=</font> BITS_IN_JSAMPLE<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_PRECISION, cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>data_precision<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* Check that number of components won't exceed internal array sizes */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components <font color='#5555FF'>></font> MAX_COMPONENTS<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT2</font><font face='Lucida Console'>(</font>cinfo, JERR_COMPONENT_COUNT, cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components,
|
|
MAX_COMPONENTS<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* Compute maximum sampling factors; check factor validity */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_h_samp_factor <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_v_samp_factor <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>, compptr <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comp_info; ci <font color='#5555FF'><</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components;
|
|
ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font>, compptr<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>h_samp_factor<font color='#5555FF'><</font><font color='#5555FF'>=</font><font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>h_samp_factor<font color='#5555FF'>></font>MAX_SAMP_FACTOR <font color='#5555FF'>|</font><font color='#5555FF'>|</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>v_samp_factor<font color='#5555FF'><</font><font color='#5555FF'>=</font><font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>v_samp_factor<font color='#5555FF'>></font>MAX_SAMP_FACTOR<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_SAMPLING<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_h_samp_factor <font color='#5555FF'>=</font> <font color='#BB00BB'>MAX</font><font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_h_samp_factor,
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>h_samp_factor<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_v_samp_factor <font color='#5555FF'>=</font> <font color='#BB00BB'>MAX</font><font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_v_samp_factor,
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>v_samp_factor<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
|
|
<font color='#009900'>/* Compute dimensions of components */</font>
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>, compptr <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comp_info; ci <font color='#5555FF'><</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components;
|
|
ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font>, compptr<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Fill in the correct component_index value; don't rely on application */</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>component_index <font color='#5555FF'>=</font> ci;
|
|
<font color='#009900'>/* In selecting the actual DCT scaling for each component, we try to
|
|
* scale down the chroma components via DCT scaling rather than downsampling.
|
|
* This saves time if the downsampler gets to use 1:1 scaling.
|
|
* Note this code adapts subsampling ratios which are powers of 2.
|
|
*/</font>
|
|
ssize <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
<font color='#0000FF'>#ifdef</font> DCT_SCALING_SUPPORTED
|
|
<font color='#0000FF'>while</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>*</font> ssize <font color='#5555FF'><</font><font color='#5555FF'>=</font>
|
|
<font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>do_fancy_downsampling ? DCTSIZE : DCTSIZE <font color='#5555FF'>/</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font>
|
|
<font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_h_samp_factor <font color='#5555FF'>%</font> <font face='Lucida Console'>(</font>compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>h_samp_factor <font color='#5555FF'>*</font> ssize <font color='#5555FF'>*</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
ssize <font color='#5555FF'>=</font> ssize <font color='#5555FF'>*</font> <font color='#979000'>2</font>;
|
|
<b>}</b>
|
|
<font color='#0000FF'>#endif</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_h_scaled_size <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_h_scaled_size <font color='#5555FF'>*</font> ssize;
|
|
ssize <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
<font color='#0000FF'>#ifdef</font> DCT_SCALING_SUPPORTED
|
|
<font color='#0000FF'>while</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>*</font> ssize <font color='#5555FF'><</font><font color='#5555FF'>=</font>
|
|
<font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>do_fancy_downsampling ? DCTSIZE : DCTSIZE <font color='#5555FF'>/</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font>
|
|
<font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_v_samp_factor <font color='#5555FF'>%</font> <font face='Lucida Console'>(</font>compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>v_samp_factor <font color='#5555FF'>*</font> ssize <font color='#5555FF'>*</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
ssize <font color='#5555FF'>=</font> ssize <font color='#5555FF'>*</font> <font color='#979000'>2</font>;
|
|
<b>}</b>
|
|
<font color='#0000FF'>#endif</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_v_scaled_size <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>min_DCT_v_scaled_size <font color='#5555FF'>*</font> ssize;
|
|
|
|
<font color='#009900'>/* We don't support DCT ratios larger than 2. */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_h_scaled_size <font color='#5555FF'>></font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_v_scaled_size <font color='#5555FF'>*</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_h_scaled_size <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_v_scaled_size <font color='#5555FF'>*</font> <font color='#979000'>2</font>;
|
|
<font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_v_scaled_size <font color='#5555FF'>></font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_h_scaled_size <font color='#5555FF'>*</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_v_scaled_size <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_h_scaled_size <font color='#5555FF'>*</font> <font color='#979000'>2</font>;
|
|
|
|
<font color='#009900'>/* Size in DCT blocks */</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>width_in_blocks <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>*</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>h_samp_factor,
|
|
<font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_h_samp_factor <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>height_in_blocks <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>*</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>v_samp_factor,
|
|
<font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_v_samp_factor <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
|
|
<font color='#009900'>/* Size in samples */</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>downsampled_width <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width <font color='#5555FF'>*</font>
|
|
<font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>h_samp_factor <font color='#5555FF'>*</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_h_scaled_size<font face='Lucida Console'>)</font>,
|
|
<font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_h_samp_factor <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>downsampled_height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height <font color='#5555FF'>*</font>
|
|
<font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>v_samp_factor <font color='#5555FF'>*</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_v_scaled_size<font face='Lucida Console'>)</font>,
|
|
<font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_v_samp_factor <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
|
|
<font color='#009900'>/* Mark component needed (this flag isn't actually used for compression) */</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>component_needed <font color='#5555FF'>=</font> TRUE;
|
|
<b>}</b>
|
|
|
|
<font color='#009900'>/* Compute number of fully interleaved MCU rows (number of times that
|
|
* main controller will call coefficient controller).
|
|
*/</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>total_iMCU_rows <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height,
|
|
<font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_v_samp_factor <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
|
|
|
|
<font color='#0000FF'>#ifdef</font> C_MULTISCAN_FILES_SUPPORTED
|
|
|
|
<b><a name='LOCAL'></a>LOCAL</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='validate_script'></a>validate_script</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo<font face='Lucida Console'>)</font>
|
|
<font color='#009900'>/* Verify that the scan script in cinfo->scan_info[] is valid; also
|
|
* determine whether it uses progressive JPEG, and set cinfo->progressive_mode.
|
|
*/</font>
|
|
<b>{</b>
|
|
<font color='#0000FF'>const</font> jpeg_scan_info <font color='#5555FF'>*</font> scanptr;
|
|
<font color='#0000FF'><u>int</u></font> scanno, ncomps, ci, coefi, thisi;
|
|
<font color='#0000FF'><u>int</u></font> Ss, Se, Ah, Al;
|
|
boolean component_sent[MAX_COMPONENTS];
|
|
<font color='#0000FF'>#ifdef</font> C_PROGRESSIVE_SUPPORTED
|
|
<font color='#0000FF'><u>int</u></font> <font color='#5555FF'>*</font> last_bitpos_ptr;
|
|
<font color='#0000FF'><u>int</u></font> last_bitpos[MAX_COMPONENTS][DCTSIZE2];
|
|
<font color='#009900'>/* -1 until that coefficient has been seen; then last Al for it */</font>
|
|
<font color='#0000FF'>#endif</font>
|
|
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_scans <font color='#5555FF'><</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_SCAN_SCRIPT, <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1;
|
|
* for progressive JPEG, no scan can have this.
|
|
*/</font>
|
|
scanptr <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scan_info;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ss <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>Se <font color='#5555FF'>!</font><font color='#5555FF'>=</font> DCTSIZE2<font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>#ifdef</font> C_PROGRESSIVE_SUPPORTED
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>progressive_mode <font color='#5555FF'>=</font> TRUE;
|
|
last_bitpos_ptr <font color='#5555FF'>=</font> <font color='#5555FF'>&</font> last_bitpos[<font color='#979000'>0</font>][<font color='#979000'>0</font>];
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>; ci <font color='#5555FF'><</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components; ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font>
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>coefi <font color='#5555FF'>=</font> <font color='#979000'>0</font>; coefi <font color='#5555FF'><</font> DCTSIZE2; coefi<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font>
|
|
<font color='#5555FF'>*</font>last_bitpos_ptr<font color='#5555FF'>+</font><font color='#5555FF'>+</font> <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>1</font>;
|
|
<font color='#0000FF'>#else</font>
|
|
<font color='#BB00BB'>ERREXIT</font><font face='Lucida Console'>(</font>cinfo, JERR_NOT_COMPILED<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>#endif</font>
|
|
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>progressive_mode <font color='#5555FF'>=</font> FALSE;
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>; ci <font color='#5555FF'><</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components; ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font>
|
|
component_sent[ci] <font color='#5555FF'>=</font> FALSE;
|
|
<b>}</b>
|
|
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>scanno <font color='#5555FF'>=</font> <font color='#979000'>1</font>; scanno <font color='#5555FF'><</font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_scans; scanptr<font color='#5555FF'>+</font><font color='#5555FF'>+</font>, scanno<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Validate component indexes */</font>
|
|
ncomps <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>comps_in_scan;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>ncomps <font color='#5555FF'><</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> ncomps <font color='#5555FF'>></font> MAX_COMPS_IN_SCAN<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT2</font><font face='Lucida Console'>(</font>cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>; ci <font color='#5555FF'><</font> ncomps; ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
thisi <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>component_index[ci];
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>thisi <font color='#5555FF'><</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> thisi <font color='#5555FF'>></font><font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_SCAN_SCRIPT, scanno<font face='Lucida Console'>)</font>;
|
|
<font color='#009900'>/* Components must appear in SOF order within each scan */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>></font> <font color='#979000'>0</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font> thisi <font color='#5555FF'><</font><font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>component_index[ci<font color='#5555FF'>-</font><font color='#979000'>1</font>]<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_SCAN_SCRIPT, scanno<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
<font color='#009900'>/* Validate progression parameters */</font>
|
|
Ss <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ss;
|
|
Se <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>Se;
|
|
Ah <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ah;
|
|
Al <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>Al;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>progressive_mode<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>#ifdef</font> C_PROGRESSIVE_SUPPORTED
|
|
<font color='#009900'>/* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that
|
|
* seems wrong: the upper bound ought to depend on data precision.
|
|
* Perhaps they really meant 0..N+1 for N-bit precision.
|
|
* Here we allow 0..10 for 8-bit data; Al larger than 10 results in
|
|
* out-of-range reconstructed DC values during the first DC scan,
|
|
* which might cause problems for some decoders.
|
|
*/</font>
|
|
<font color='#0000FF'>#if</font> BITS_IN_JSAMPLE <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>8</font>
|
|
<font color='#0000FF'>#define</font> MAX_AH_AL <font color='#979000'>10</font>
|
|
<font color='#0000FF'>#else</font>
|
|
<font color='#0000FF'>#define</font> MAX_AH_AL <font color='#979000'>13</font>
|
|
<font color='#0000FF'>#endif</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Ss <font color='#5555FF'><</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> Ss <font color='#5555FF'>></font><font color='#5555FF'>=</font> DCTSIZE2 <font color='#5555FF'>|</font><font color='#5555FF'>|</font> Se <font color='#5555FF'><</font> Ss <font color='#5555FF'>|</font><font color='#5555FF'>|</font> Se <font color='#5555FF'>></font><font color='#5555FF'>=</font> DCTSIZE2 <font color='#5555FF'>|</font><font color='#5555FF'>|</font>
|
|
Ah <font color='#5555FF'><</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> Ah <font color='#5555FF'>></font> MAX_AH_AL <font color='#5555FF'>|</font><font color='#5555FF'>|</font> Al <font color='#5555FF'><</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> Al <font color='#5555FF'>></font> MAX_AH_AL<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_PROG_SCRIPT, scanno<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Ss <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Se <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> <font color='#009900'>/* DC and AC together not OK */</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_PROG_SCRIPT, scanno<font face='Lucida Console'>)</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>ncomps <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font> <font color='#009900'>/* AC scans must be for only one component */</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_PROG_SCRIPT, scanno<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>; ci <font color='#5555FF'><</font> ncomps; ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
last_bitpos_ptr <font color='#5555FF'>=</font> <font color='#5555FF'>&</font> last_bitpos[scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>component_index[ci]][<font color='#979000'>0</font>];
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Ss <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font> last_bitpos_ptr[<font color='#979000'>0</font>] <font color='#5555FF'><</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> <font color='#009900'>/* AC without prior DC scan */</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_PROG_SCRIPT, scanno<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>coefi <font color='#5555FF'>=</font> Ss; coefi <font color='#5555FF'><</font><font color='#5555FF'>=</font> Se; coefi<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>last_bitpos_ptr[coefi] <font color='#5555FF'><</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* first scan of this coefficient */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Ah <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_PROG_SCRIPT, scanno<font face='Lucida Console'>)</font>;
|
|
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
|
|
<font color='#009900'>/* not first scan */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Ah <font color='#5555FF'>!</font><font color='#5555FF'>=</font> last_bitpos_ptr[coefi] <font color='#5555FF'>|</font><font color='#5555FF'>|</font> Al <font color='#5555FF'>!</font><font color='#5555FF'>=</font> Ah<font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_PROG_SCRIPT, scanno<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
last_bitpos_ptr[coefi] <font color='#5555FF'>=</font> Al;
|
|
<b>}</b>
|
|
<b>}</b>
|
|
<font color='#0000FF'>#endif</font>
|
|
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
|
|
<font color='#009900'>/* For sequential JPEG, all progression parameters must be these: */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>Ss <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> Se <font color='#5555FF'>!</font><font color='#5555FF'>=</font> DCTSIZE2<font color='#5555FF'>-</font><font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> Ah <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> Al <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_PROG_SCRIPT, scanno<font face='Lucida Console'>)</font>;
|
|
<font color='#009900'>/* Make sure components are not sent twice */</font>
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>; ci <font color='#5555FF'><</font> ncomps; ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
thisi <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>component_index[ci];
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>component_sent[thisi]<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT1</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_SCAN_SCRIPT, scanno<font face='Lucida Console'>)</font>;
|
|
component_sent[thisi] <font color='#5555FF'>=</font> TRUE;
|
|
<b>}</b>
|
|
<b>}</b>
|
|
<b>}</b>
|
|
|
|
<font color='#009900'>/* Now verify that everything got sent. */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>progressive_mode<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>#ifdef</font> C_PROGRESSIVE_SUPPORTED
|
|
<font color='#009900'>/* For progressive mode, we only check that at least some DC data
|
|
* got sent for each component; the spec does not require that all bits
|
|
* of all coefficients be transmitted. Would it be wiser to enforce
|
|
* transmission of all coefficient bits??
|
|
*/</font>
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>; ci <font color='#5555FF'><</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components; ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>last_bitpos[ci][<font color='#979000'>0</font>] <font color='#5555FF'><</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT</font><font face='Lucida Console'>(</font>cinfo, JERR_MISSING_DATA<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
<font color='#0000FF'>#endif</font>
|
|
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>; ci <font color='#5555FF'><</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components; ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font> component_sent[ci]<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT</font><font face='Lucida Console'>(</font>cinfo, JERR_MISSING_DATA<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
<b>}</b>
|
|
<b>}</b>
|
|
|
|
|
|
<b><a name='LOCAL'></a>LOCAL</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='reduce_script'></a>reduce_script</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo<font face='Lucida Console'>)</font>
|
|
<font color='#009900'>/* Adapt scan script for use with reduced block size;
|
|
* assume that script has been validated before.
|
|
*/</font>
|
|
<b>{</b>
|
|
jpeg_scan_info <font color='#5555FF'>*</font> scanptr;
|
|
<font color='#0000FF'><u>int</u></font> idxout, idxin;
|
|
|
|
<font color='#009900'>/* Circumvent const declaration for this function */</font>
|
|
scanptr <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>jpeg_scan_info <font color='#5555FF'>*</font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scan_info;
|
|
idxout <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
|
|
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>idxin <font color='#5555FF'>=</font> <font color='#979000'>0</font>; idxin <font color='#5555FF'><</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_scans; idxin<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* After skipping, idxout becomes smaller than idxin */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>idxin <font color='#5555FF'>!</font><font color='#5555FF'>=</font> idxout<font face='Lucida Console'>)</font>
|
|
<font color='#009900'>/* Copy rest of data;
|
|
* note we stay in given chunk of allocated memory.
|
|
*/</font>
|
|
scanptr[idxout] <font color='#5555FF'>=</font> scanptr[idxin];
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>scanptr[idxout].Ss <font color='#5555FF'>></font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>lim_Se<font face='Lucida Console'>)</font>
|
|
<font color='#009900'>/* Entire scan out of range - skip this entry */</font>
|
|
<font color='#0000FF'>continue</font>;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>scanptr[idxout].Se <font color='#5555FF'>></font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>lim_Se<font face='Lucida Console'>)</font>
|
|
<font color='#009900'>/* Limit scan to end of block */</font>
|
|
scanptr[idxout].Se <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>lim_Se;
|
|
idxout<font color='#5555FF'>+</font><font color='#5555FF'>+</font>;
|
|
<b>}</b>
|
|
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_scans <font color='#5555FF'>=</font> idxout;
|
|
<b>}</b>
|
|
|
|
<font color='#0000FF'>#endif</font> <font color='#009900'>/* C_MULTISCAN_FILES_SUPPORTED */</font>
|
|
|
|
|
|
<b><a name='LOCAL'></a>LOCAL</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='select_scan_parameters'></a>select_scan_parameters</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo<font face='Lucida Console'>)</font>
|
|
<font color='#009900'>/* Set up the scan parameters for the current scan */</font>
|
|
<b>{</b>
|
|
<font color='#0000FF'><u>int</u></font> ci;
|
|
|
|
<font color='#0000FF'>#ifdef</font> C_MULTISCAN_FILES_SUPPORTED
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scan_info <font color='#5555FF'>!</font><font color='#5555FF'>=</font> NULL<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* Prepare for current scan --- the script is already validated */</font>
|
|
my_master_ptr master <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>my_master_ptr<font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>master;
|
|
<font color='#0000FF'>const</font> jpeg_scan_info <font color='#5555FF'>*</font> scanptr <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scan_info <font color='#5555FF'>+</font> master<font color='#5555FF'>-</font><font color='#5555FF'>></font>scan_number;
|
|
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comps_in_scan <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>comps_in_scan;
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>; ci <font color='#5555FF'><</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>comps_in_scan; ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>cur_comp_info[ci] <font color='#5555FF'>=</font>
|
|
<font color='#5555FF'>&</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comp_info[scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>component_index[ci]];
|
|
<b>}</b>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>progressive_mode<font face='Lucida Console'>)</font> <b>{</b>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ss <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ss;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>Se <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>Se;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ah <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ah;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>Al <font color='#5555FF'>=</font> scanptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>Al;
|
|
<font color='#0000FF'>return</font>;
|
|
<b>}</b>
|
|
<b>}</b>
|
|
<font color='#0000FF'>else</font>
|
|
<font color='#0000FF'>#endif</font>
|
|
<b>{</b>
|
|
<font color='#009900'>/* Prepare for single sequential-JPEG scan containing all components */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components <font color='#5555FF'>></font> MAX_COMPS_IN_SCAN<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT2</font><font face='Lucida Console'>(</font>cinfo, JERR_COMPONENT_COUNT, cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components,
|
|
MAX_COMPS_IN_SCAN<font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comps_in_scan <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components;
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>; ci <font color='#5555FF'><</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_components; ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>cur_comp_info[ci] <font color='#5555FF'>=</font> <font color='#5555FF'>&</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comp_info[ci];
|
|
<b>}</b>
|
|
<b>}</b>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ss <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>Se <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size <font color='#5555FF'>-</font> <font color='#979000'>1</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ah <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>Al <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
|
|
<b>}</b>
|
|
|
|
|
|
<b><a name='LOCAL'></a>LOCAL</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='per_scan_setup'></a>per_scan_setup</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo<font face='Lucida Console'>)</font>
|
|
<font color='#009900'>/* Do computations that are needed before processing a JPEG scan */</font>
|
|
<font color='#009900'>/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */</font>
|
|
<b>{</b>
|
|
<font color='#0000FF'><u>int</u></font> ci, mcublks, tmp;
|
|
jpeg_component_info <font color='#5555FF'>*</font>compptr;
|
|
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comps_in_scan <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
|
|
<font color='#009900'>/* Noninterleaved (single-component) scan */</font>
|
|
compptr <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>cur_comp_info[<font color='#979000'>0</font>];
|
|
|
|
<font color='#009900'>/* Overall image size in MCUs */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCUs_per_row <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>width_in_blocks;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_rows_in_scan <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>height_in_blocks;
|
|
|
|
<font color='#009900'>/* For noninterleaved scan, always one block per MCU */</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_width <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_height <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_blocks <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_sample_width <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_h_scaled_size;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>last_col_width <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
<font color='#009900'>/* For noninterleaved scans, it is convenient to define last_row_height
|
|
* as the number of block rows present in the last iMCU row.
|
|
*/</font>
|
|
tmp <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>height_in_blocks <font color='#5555FF'>%</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>v_samp_factor<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>tmp <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> tmp <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>v_samp_factor;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>last_row_height <font color='#5555FF'>=</font> tmp;
|
|
|
|
<font color='#009900'>/* Prepare array describing MCU composition */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>blocks_in_MCU <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_membership[<font color='#979000'>0</font>] <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
|
|
|
|
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
|
|
|
|
<font color='#009900'>/* Interleaved (multi-component) scan */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comps_in_scan <font color='#5555FF'><</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comps_in_scan <font color='#5555FF'>></font> MAX_COMPS_IN_SCAN<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT2</font><font face='Lucida Console'>(</font>cinfo, JERR_COMPONENT_COUNT, cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comps_in_scan,
|
|
MAX_COMPS_IN_SCAN<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* Overall image size in MCUs */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCUs_per_row <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_width,
|
|
<font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_h_samp_factor <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_rows_in_scan <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>JDIMENSION<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>jdiv_round_up</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>jpeg_height,
|
|
<font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>max_v_samp_factor <font color='#5555FF'>*</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
|
|
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>blocks_in_MCU <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
|
|
|
|
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font>ci <font color='#5555FF'>=</font> <font color='#979000'>0</font>; ci <font color='#5555FF'><</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>comps_in_scan; ci<font color='#5555FF'>+</font><font color='#5555FF'>+</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
compptr <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>cur_comp_info[ci];
|
|
<font color='#009900'>/* Sampling factors give # of blocks of component in each MCU */</font>
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_width <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>h_samp_factor;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_height <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>v_samp_factor;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_blocks <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_width <font color='#5555FF'>*</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_height;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_sample_width <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_width <font color='#5555FF'>*</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>DCT_h_scaled_size;
|
|
<font color='#009900'>/* Figure number of non-dummy blocks in last MCU column & row */</font>
|
|
tmp <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>width_in_blocks <font color='#5555FF'>%</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_width<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>tmp <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> tmp <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_width;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>last_col_width <font color='#5555FF'>=</font> tmp;
|
|
tmp <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>height_in_blocks <font color='#5555FF'>%</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_height<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>tmp <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> tmp <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_height;
|
|
compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>last_row_height <font color='#5555FF'>=</font> tmp;
|
|
<font color='#009900'>/* Prepare array describing MCU composition */</font>
|
|
mcublks <font color='#5555FF'>=</font> compptr<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_blocks;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>blocks_in_MCU <font color='#5555FF'>+</font> mcublks <font color='#5555FF'>></font> C_MAX_BLOCKS_IN_MCU<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>ERREXIT</font><font face='Lucida Console'>(</font>cinfo, JERR_BAD_MCU_SIZE<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>while</font> <font face='Lucida Console'>(</font>mcublks<font color='#5555FF'>-</font><font color='#5555FF'>-</font> <font color='#5555FF'>></font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCU_membership[cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>blocks_in_MCU<font color='#5555FF'>+</font><font color='#5555FF'>+</font>] <font color='#5555FF'>=</font> ci;
|
|
<b>}</b>
|
|
<b>}</b>
|
|
|
|
<b>}</b>
|
|
|
|
<font color='#009900'>/* Convert restart specified in rows to actual MCU count. */</font>
|
|
<font color='#009900'>/* Note that count must fit in 16 bits, so we provide limiting. */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>restart_in_rows <font color='#5555FF'>></font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'><u>long</u></font> nominal <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>restart_in_rows <font color='#5555FF'>*</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>MCUs_per_row;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>restart_interval <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font> <font color='#BB00BB'>MIN</font><font face='Lucida Console'>(</font>nominal, <font color='#979000'>65535</font>L<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
<b>}</b>
|
|
|
|
|
|
<font color='#009900'>/*
|
|
* Per-pass setup.
|
|
* This is called at the beginning of each pass. We determine which modules
|
|
* will be active during this pass and give them appropriate start_pass calls.
|
|
* We also set is_last_pass to indicate whether any more passes will be
|
|
* required.
|
|
*/</font>
|
|
|
|
<b><a name='METHODDEF'></a>METHODDEF</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='prepare_for_pass'></a>prepare_for_pass</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo<font face='Lucida Console'>)</font>
|
|
<b>{</b>
|
|
my_master_ptr master <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>my_master_ptr<font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>master;
|
|
|
|
<font color='#0000FF'>switch</font> <font face='Lucida Console'>(</font>master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_type<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>case</font> main_pass:
|
|
<font color='#009900'>/* Initial pass: will collect input data, and do either Huffman
|
|
* optimization or data output for the first scan.
|
|
*/</font>
|
|
<font color='#BB00BB'>select_scan_parameters</font><font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font color='#BB00BB'>per_scan_setup</font><font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>raw_data_in<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>cconvert<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>downsample<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>prep<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo, JBUF_PASS_THRU<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>fdct<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>entropy<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo, cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>optimize_coding<font face='Lucida Console'>)</font>;
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>coef<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo,
|
|
<font face='Lucida Console'>(</font>master<font color='#5555FF'>-</font><font color='#5555FF'>></font>total_passes <font color='#5555FF'>></font> <font color='#979000'>1</font> ?
|
|
JBUF_SAVE_AND_PASS : JBUF_PASS_THRU<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>main<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo, JBUF_PASS_THRU<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>optimize_coding<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* No immediate data output; postpone writing frame/scan headers */</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pub.call_pass_startup <font color='#5555FF'>=</font> FALSE;
|
|
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
|
|
<font color='#009900'>/* Will write frame/scan headers at first jpeg_write_scanlines call */</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pub.call_pass_startup <font color='#5555FF'>=</font> TRUE;
|
|
<b>}</b>
|
|
<font color='#0000FF'>break</font>;
|
|
<font color='#0000FF'>#ifdef</font> ENTROPY_OPT_SUPPORTED
|
|
<font color='#0000FF'>case</font> huff_opt_pass:
|
|
<font color='#009900'>/* Do Huffman optimization for a scan after the first one. */</font>
|
|
<font color='#BB00BB'>select_scan_parameters</font><font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font color='#BB00BB'>per_scan_setup</font><font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ss <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>Ah <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font> <b>{</b>
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>entropy<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo, TRUE<font face='Lucida Console'>)</font>;
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>coef<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo, JBUF_CRANK_DEST<font face='Lucida Console'>)</font>;
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pub.call_pass_startup <font color='#5555FF'>=</font> FALSE;
|
|
<font color='#0000FF'>break</font>;
|
|
<b>}</b>
|
|
<font color='#009900'>/* Special case: Huffman DC refinement scans need no Huffman table
|
|
* and therefore we can skip the optimization pass for them.
|
|
*/</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_type <font color='#5555FF'>=</font> output_pass;
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_number<font color='#5555FF'>+</font><font color='#5555FF'>+</font>;
|
|
<font color='#009900'>/*FALLTHROUGH*/</font>
|
|
<font color='#0000FF'>#endif</font>
|
|
<font color='#0000FF'>case</font> output_pass:
|
|
<font color='#009900'>/* Do a data-output pass. */</font>
|
|
<font color='#009900'>/* We need not repeat per-scan setup if prior optimization pass did it. */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>optimize_coding<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#BB00BB'>select_scan_parameters</font><font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font color='#BB00BB'>per_scan_setup</font><font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>entropy<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo, FALSE<font face='Lucida Console'>)</font>;
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>coef<font color='#5555FF'>-</font><font color='#5555FF'>></font>start_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo, JBUF_CRANK_DEST<font face='Lucida Console'>)</font>;
|
|
<font color='#009900'>/* We emit frame/scan headers now */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>master<font color='#5555FF'>-</font><font color='#5555FF'>></font>scan_number <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>marker<font color='#5555FF'>-</font><font color='#5555FF'>></font>write_frame_header<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>marker<font color='#5555FF'>-</font><font color='#5555FF'>></font>write_scan_header<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pub.call_pass_startup <font color='#5555FF'>=</font> FALSE;
|
|
<font color='#0000FF'>break</font>;
|
|
<font color='#0000FF'>default</font>:
|
|
<font color='#BB00BB'>ERREXIT</font><font face='Lucida Console'>(</font>cinfo, JERR_NOT_COMPILED<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pub.is_last_pass <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_number <font color='#5555FF'>=</font><font color='#5555FF'>=</font> master<font color='#5555FF'>-</font><font color='#5555FF'>></font>total_passes<font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* Set up progress monitor's pass info if present */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>progress <font color='#5555FF'>!</font><font color='#5555FF'>=</font> NULL<font face='Lucida Console'>)</font> <b>{</b>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>progress<font color='#5555FF'>-</font><font color='#5555FF'>></font>completed_passes <font color='#5555FF'>=</font> master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_number;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>progress<font color='#5555FF'>-</font><font color='#5555FF'>></font>total_passes <font color='#5555FF'>=</font> master<font color='#5555FF'>-</font><font color='#5555FF'>></font>total_passes;
|
|
<b>}</b>
|
|
<b>}</b>
|
|
|
|
|
|
<font color='#009900'>/*
|
|
* Special start-of-pass hook.
|
|
* This is called by jpeg_write_scanlines if call_pass_startup is TRUE.
|
|
* In single-pass processing, we need this hook because we don't want to
|
|
* write frame/scan headers during jpeg_start_compress; we want to let the
|
|
* application write COM markers etc. between jpeg_start_compress and the
|
|
* jpeg_write_scanlines loop.
|
|
* In multi-pass processing, this routine is not used.
|
|
*/</font>
|
|
|
|
<b><a name='METHODDEF'></a>METHODDEF</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='pass_startup'></a>pass_startup</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo<font face='Lucida Console'>)</font>
|
|
<b>{</b>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>master<font color='#5555FF'>-</font><font color='#5555FF'>></font>call_pass_startup <font color='#5555FF'>=</font> FALSE; <font color='#009900'>/* reset flag so call only once */</font>
|
|
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>marker<font color='#5555FF'>-</font><font color='#5555FF'>></font>write_frame_header<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>marker<font color='#5555FF'>-</font><font color='#5555FF'>></font>write_scan_header<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<b>}</b>
|
|
|
|
|
|
<font color='#009900'>/*
|
|
* Finish up at end of pass.
|
|
*/</font>
|
|
|
|
<b><a name='METHODDEF'></a>METHODDEF</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='finish_pass_master'></a>finish_pass_master</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo<font face='Lucida Console'>)</font>
|
|
<b>{</b>
|
|
my_master_ptr master <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>my_master_ptr<font face='Lucida Console'>)</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>master;
|
|
|
|
<font color='#009900'>/* The entropy coder always needs an end-of-pass call,
|
|
* either to analyze statistics or to flush its output buffer.
|
|
*/</font>
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>entropy<font color='#5555FF'>-</font><font color='#5555FF'>></font>finish_pass<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#009900'>/* Update state for next pass */</font>
|
|
<font color='#0000FF'>switch</font> <font face='Lucida Console'>(</font>master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_type<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>case</font> main_pass:
|
|
<font color='#009900'>/* next pass is either output of scan 0 (after optimization)
|
|
* or output of scan 1 (if no optimization).
|
|
*/</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_type <font color='#5555FF'>=</font> output_pass;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#5555FF'>!</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>optimize_coding<font face='Lucida Console'>)</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>scan_number<font color='#5555FF'>+</font><font color='#5555FF'>+</font>;
|
|
<font color='#0000FF'>break</font>;
|
|
<font color='#0000FF'>case</font> huff_opt_pass:
|
|
<font color='#009900'>/* next pass is always output of current scan */</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_type <font color='#5555FF'>=</font> output_pass;
|
|
<font color='#0000FF'>break</font>;
|
|
<font color='#0000FF'>case</font> output_pass:
|
|
<font color='#009900'>/* next pass is either optimization or output of next scan */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>optimize_coding<font face='Lucida Console'>)</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_type <font color='#5555FF'>=</font> huff_opt_pass;
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>scan_number<font color='#5555FF'>+</font><font color='#5555FF'>+</font>;
|
|
<font color='#0000FF'>break</font>;
|
|
<b>}</b>
|
|
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_number<font color='#5555FF'>+</font><font color='#5555FF'>+</font>;
|
|
<b>}</b>
|
|
|
|
|
|
<font color='#009900'>/*
|
|
* Initialize master compression control.
|
|
*/</font>
|
|
|
|
<b><a name='GLOBAL'></a>GLOBAL</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>void</u></font><font face='Lucida Console'>)</font>
|
|
<b><a name='jinit_c_master_control'></a>jinit_c_master_control</b> <font face='Lucida Console'>(</font>j_compress_ptr cinfo, boolean transcode_only<font face='Lucida Console'>)</font>
|
|
<b>{</b>
|
|
my_master_ptr master;
|
|
|
|
master <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>my_master_ptr<font face='Lucida Console'>)</font>
|
|
<font face='Lucida Console'>(</font><font color='#5555FF'>*</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>mem<font color='#5555FF'>-</font><font color='#5555FF'>></font>alloc_small<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>j_common_ptr<font face='Lucida Console'>)</font> cinfo, JPOOL_IMAGE,
|
|
<font color='#BB00BB'>SIZEOF</font><font face='Lucida Console'>(</font>my_comp_master<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>master <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'>struct</font> jpeg_comp_master <font color='#5555FF'>*</font><font face='Lucida Console'>)</font> master;
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pub.prepare_for_pass <font color='#5555FF'>=</font> prepare_for_pass;
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pub.pass_startup <font color='#5555FF'>=</font> pass_startup;
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pub.finish_pass <font color='#5555FF'>=</font> finish_pass_master;
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pub.is_last_pass <font color='#5555FF'>=</font> FALSE;
|
|
|
|
<font color='#009900'>/* Validate parameters, determine derived values */</font>
|
|
<font color='#BB00BB'>initial_setup</font><font face='Lucida Console'>(</font>cinfo, transcode_only<font face='Lucida Console'>)</font>;
|
|
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>scan_info <font color='#5555FF'>!</font><font color='#5555FF'>=</font> NULL<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#0000FF'>#ifdef</font> C_MULTISCAN_FILES_SUPPORTED
|
|
<font color='#BB00BB'>validate_script</font><font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size <font color='#5555FF'><</font> DCTSIZE<font face='Lucida Console'>)</font>
|
|
<font color='#BB00BB'>reduce_script</font><font face='Lucida Console'>(</font>cinfo<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>#else</font>
|
|
<font color='#BB00BB'>ERREXIT</font><font face='Lucida Console'>(</font>cinfo, JERR_NOT_COMPILED<font face='Lucida Console'>)</font>;
|
|
<font color='#0000FF'>#endif</font>
|
|
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>progressive_mode <font color='#5555FF'>=</font> FALSE;
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_scans <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
|
|
<b>}</b>
|
|
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>progressive_mode <font color='#5555FF'>|</font><font color='#5555FF'>|</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>block_size <font color='#5555FF'><</font> DCTSIZE<font face='Lucida Console'>)</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font>
|
|
<font color='#5555FF'>!</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>arith_code<font face='Lucida Console'>)</font> <font color='#009900'>/* TEMPORARY HACK ??? */</font>
|
|
<font color='#009900'>/* assume default tables no good for progressive or downscale mode */</font>
|
|
cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>optimize_coding <font color='#5555FF'>=</font> TRUE;
|
|
|
|
<font color='#009900'>/* Initialize my private state */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>transcode_only<font face='Lucida Console'>)</font> <b>{</b>
|
|
<font color='#009900'>/* no main pass in transcoding */</font>
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>optimize_coding<font face='Lucida Console'>)</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_type <font color='#5555FF'>=</font> huff_opt_pass;
|
|
<font color='#0000FF'>else</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_type <font color='#5555FF'>=</font> output_pass;
|
|
<b>}</b> <font color='#0000FF'>else</font> <b>{</b>
|
|
<font color='#009900'>/* for normal compression, first pass is always this type: */</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_type <font color='#5555FF'>=</font> main_pass;
|
|
<b>}</b>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>scan_number <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>pass_number <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
|
|
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>optimize_coding<font face='Lucida Console'>)</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>total_passes <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_scans <font color='#5555FF'>*</font> <font color='#979000'>2</font>;
|
|
<font color='#0000FF'>else</font>
|
|
master<font color='#5555FF'>-</font><font color='#5555FF'>></font>total_passes <font color='#5555FF'>=</font> cinfo<font color='#5555FF'>-</font><font color='#5555FF'>></font>num_scans;
|
|
<b>}</b>
|
|
|
|
</pre></body></html> |