Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / compiler / libjpeg / main / jcscale.c
blobbbf54e8e3075535b86e2eedc3ffaa64ecb2ea974
1 /*
2 $Id$
3 */
5 /*
6 * jcscale.c
8 * Copyright (C) 1998, Thomas G. Lane.
9 * This file is part of the Independent JPEG Group's software.
10 * For conditions of distribution and use, see the accompanying README file.
12 * This file contains sample downscaling by 2^Pt for lossless JPEG.
15 #define JPEG_INTERNALS
16 #include "jinclude.h"
17 #include "jpeglib.h"
18 #include "jlossls.h" /* Private declarations for lossless codec */
21 #ifdef C_LOSSLESS_SUPPORTED
23 METHODDEF(void)
24 simple_downscale(j_compress_ptr cinfo,
25 JSAMPROW input_buf, JSAMPROW output_buf, JDIMENSION width)
27 j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
28 int xindex;
30 for (xindex = 0; xindex < width; xindex++)
31 output_buf[xindex] = (JSAMPLE) RIGHT_SHIFT(GETJSAMPLE(input_buf[xindex]),
32 cinfo->Al);
36 METHODDEF(void)
37 noscale(j_compress_ptr cinfo,
38 JSAMPROW input_buf, JSAMPROW output_buf, JDIMENSION width)
40 MEMCOPY(output_buf, input_buf, width * SIZEOF(JSAMPLE));
41 return;
45 METHODDEF(void)
46 scaler_start_pass (j_compress_ptr cinfo)
48 j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
50 /* Set scaler function based on Pt */
51 if (cinfo->Al)
52 losslsc->scaler_scale = simple_downscale;
53 else
54 losslsc->scaler_scale = noscale;
58 JGLOBAL(void)
59 jinit_c_scaler (j_compress_ptr cinfo)
61 j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
63 losslsc->scaler_start_pass = scaler_start_pass;
66 #endif /* C_LOSSLESS_SUPPORTED */