source: trunk/src/3rdparty/libjpeg/jdsample.c@ 116

Last change on this file since 116 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 16.0 KB
Line 
1/*
2 * jdsample.c
3 *
4 * Copyright (C) 1991-1996, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file.
7 *
8 * This file contains upsampling routines.
9 *
10 * Upsampling input data is counted in "row groups". A row group
11 * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)
12 * sample rows of each component. Upsampling will normally produce
13 * max_v_samp_factor pixel rows from each row group (but this could vary
14 * if the upsampler is applying a scale factor of its own).
15 *
16 * An excellent reference for image resampling is
17 * Digital Image Warping, George Wolberg, 1990.
18 * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7.
19 */
20
21#define JPEG_INTERNALS
22#include "jinclude.h"
23#include "jpeglib.h"
24
25
26/* Pointer to routine to upsample a single component */
27typedef JMETHOD(void, upsample1_ptr,
28 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
29 JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
30
31/* Private subobject */
32
33typedef struct {
34 struct jpeg_upsampler pub; /* public fields */
35
36 /* Color conversion buffer. When using separate upsampling and color
37 * conversion steps, this buffer holds one upsampled row group until it
38 * has been color converted and output.
39 * Note: we do not allocate any storage for component(s) which are full-size,
40 * ie do not need rescaling. The corresponding entry of color_buf[] is
41 * simply set to point to the input data array, thereby avoiding copying.
42 */
43 JSAMPARRAY color_buf[MAX_COMPONENTS];
44
45 /* Per-component upsampling method pointers */
46 upsample1_ptr methods[MAX_COMPONENTS];
47
48 int next_row_out; /* counts rows emitted from color_buf */
49 JDIMENSION rows_to_go; /* counts rows remaining in image */
50
51 /* Height of an input row group for each component. */
52 int rowgroup_height[MAX_COMPONENTS];
53
54 /* These arrays save pixel expansion factors so that int_expand need not
55 * recompute them each time. They are unused for other upsampling methods.
56 */
57 UINT8 h_expand[MAX_COMPONENTS];
58 UINT8 v_expand[MAX_COMPONENTS];
59} my_upsampler;
60
61typedef my_upsampler * my_upsample_ptr;
62
63
64/*
65 * Initialize for an upsampling pass.