PageRenderTime 71ms CodeModel.GetById 28ms app.highlight 5ms RepoModel.GetById 21ms app.codeStats 0ms

/libjpeg/jcscale.c

https://code.google.com/p/xee/
C | 62 lines | 38 code | 14 blank | 10 comment | 2 complexity | a774b925aa1c7d29f97d617615345f51 MD5 | raw file
 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
19METHODDEF(void)
20simple_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  int xindex;
25
26  for (xindex = 0; xindex < width; xindex++)
27    output_buf[xindex] = (JSAMPLE) RIGHT_SHIFT(GETJSAMPLE(input_buf[xindex]),
28					       cinfo->Al);
29}
30
31
32METHODDEF(void)
33noscale(j_compress_ptr cinfo,
34	JSAMPROW input_buf, JSAMPROW output_buf, JDIMENSION width)
35{
36  MEMCOPY(output_buf, input_buf, width * SIZEOF(JSAMPLE));
37  return;
38}
39
40
41METHODDEF(void)
42scaler_start_pass (j_compress_ptr cinfo)
43{
44  j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
45
46  /* Set scaler function based on Pt */
47  if (cinfo->Al)
48    losslsc->scaler_scale = simple_downscale;
49  else
50    losslsc->scaler_scale = noscale;
51}
52
53
54GLOBAL(void)
55jinit_c_scaler (j_compress_ptr cinfo)
56{
57  j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
58
59  losslsc->scaler_start_pass = scaler_start_pass;
60}
61
62#endif /* C_LOSSLESS_SUPPORTED */