]> Creatis software - gdcm.git/blob - src/gdcmjpeg/jcscale.c
ENH: Ok serioulsy nobody was updating this file - removed
[gdcm.git] / src / gdcmjpeg / jcscale.c
1 /*
2  * jcscale.c
3  *
4  * Copyright (C) 1998, 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 sample downscaling by 2^Pt for lossless JPEG.
9  */
10
11 #define JPEG_INTERNALS
12 #include "jinclude.h"
13 #include "jpeglib.h"
14 #include "jlossls.h"    /* Private declarations for lossless codec */
15
16
17 #ifdef C_LOSSLESS_SUPPORTED
18
19 METHODDEF(void)
20 simple_downscale(j_compress_ptr cinfo,
21      JSAMPROW input_buf, JSAMPROW output_buf, JDIMENSION width)
22 {
23   /* j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec; */
24   unsigned int xindex;
25   SHIFT_TEMPS
26
27   for (xindex = 0; xindex < width; xindex++)
28     output_buf[xindex] = (JSAMPLE) RIGHT_SHIFT(GETJSAMPLE(input_buf[xindex]),
29                  cinfo->Al);
30 }
31
32
33 METHODDEF(void)
34 noscale(j_compress_ptr cinfo,
35   JSAMPROW input_buf, JSAMPROW output_buf, JDIMENSION width)
36 {
37   (void)cinfo;
38   MEMCOPY(output_buf, input_buf, width * SIZEOF(JSAMPLE));
39   return;
40 }
41
42
43 METHODDEF(void)
44 scaler_start_pass (j_compress_ptr cinfo)
45 {
46   j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
47
48   /* Set scaler function based on Pt */
49   if (cinfo->Al)
50     losslsc->scaler_scale = simple_downscale;
51   else
52     losslsc->scaler_scale = noscale;
53 }
54
55
56 GLOBAL(void)
57 jinit_c_scaler (j_compress_ptr cinfo)
58 {
59   j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
60
61   losslsc->scaler_start_pass = scaler_start_pass;
62 }
63
64 #endif /* C_LOSSLESS_SUPPORTED */