Files
mozjpeg/jcscale.c
DRC ec6e451d05 Lossless JPEG support: Add copyright attributions
Referring to
https://github.com/libjpeg-turbo/libjpeg-turbo/issues/402#issuecomment-768348440
and
https://github.com/libjpeg-turbo/libjpeg-turbo/issues/402#issuecomment-770221584

Ken Murchison clarified that it was his intent to release the lossless
JPEG patch under the IJG License and that adding his name to the
copyright headers would be sufficient to acknowledge that any
derivatives are based on his work.
2022-10-21 16:53:53 -05:00

65 lines
1.5 KiB
C

/*
* jcscale.c
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1998, Thomas G. Lane.
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains sample downscaling by 2^Pt for lossless JPEG.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jlossls.h" /* Private declarations for lossless codec */
#ifdef C_LOSSLESS_SUPPORTED
METHODDEF(void)
simple_downscale(j_compress_ptr cinfo,
JSAMPROW input_buf, JSAMPROW output_buf, JDIMENSION width)
{
j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
int xindex;
for (xindex = 0; xindex < width; xindex++)
output_buf[xindex] = (JSAMPLE) RIGHT_SHIFT(GETJSAMPLE(input_buf[xindex]),
cinfo->Al);
}
METHODDEF(void)
noscale(j_compress_ptr cinfo,
JSAMPROW input_buf, JSAMPROW output_buf, JDIMENSION width)
{
MEMCOPY(output_buf, input_buf, width * SIZEOF(JSAMPLE));
return;
}
METHODDEF(void)
scaler_start_pass (j_compress_ptr cinfo)
{
j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
/* Set scaler function based on Pt */
if (cinfo->Al)
losslsc->scaler_scale = simple_downscale;
else
losslsc->scaler_scale = noscale;
}
GLOBAL(void)
jinit_c_scaler (j_compress_ptr cinfo)
{
j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
losslsc->scaler_start_pass = scaler_start_pass;
}
#endif /* C_LOSSLESS_SUPPORTED */