mirror of
https://github.com/libjpeg-turbo/libjpeg-turbo.git
synced 2026-01-18 21:41:20 +01:00
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.
79 lines
1.9 KiB
C
79 lines
1.9 KiB
C
/*
|
|
* jclossy.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 the control logic for the lossy JPEG compressor.
|
|
*/
|
|
|
|
#define JPEG_INTERNALS
|
|
#include "jinclude.h"
|
|
#include "jpeglib.h"
|
|
#include "jlossy.h"
|
|
|
|
|
|
/*
|
|
* Initialize for a processing pass.
|
|
*/
|
|
|
|
METHODDEF(void)
|
|
start_pass (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
|
{
|
|
j_lossy_c_ptr lossyc = (j_lossy_c_ptr) cinfo->codec;
|
|
|
|
(*lossyc->fdct_start_pass) (cinfo);
|
|
(*lossyc->coef_start_pass) (cinfo, pass_mode);
|
|
}
|
|
|
|
|
|
/*
|
|
* Initialize the lossy compression codec.
|
|
* This is called only once, during master selection.
|
|
*/
|
|
|
|
GLOBAL(void)
|
|
jinit_lossy_c_codec (j_compress_ptr cinfo)
|
|
{
|
|
j_lossy_c_ptr lossyc;
|
|
|
|
/* Create subobject in permanent pool */
|
|
lossyc = (j_lossy_c_ptr)
|
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
|
SIZEOF(jpeg_lossy_c_codec));
|
|
cinfo->codec = (struct jpeg_c_codec *) lossyc;
|
|
|
|
/* Initialize sub-modules */
|
|
|
|
/* Forward DCT */
|
|
jinit_forward_dct(cinfo);
|
|
/* Entropy encoding: either Huffman or arithmetic coding. */
|
|
if (cinfo->arith_code) {
|
|
ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
|
|
} else {
|
|
if (cinfo->process == JPROC_PROGRESSIVE) {
|
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
|
jinit_phuff_encoder(cinfo);
|
|
#else
|
|
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
|
#endif
|
|
} else
|
|
jinit_shuff_encoder(cinfo);
|
|
}
|
|
|
|
/* Need a full-image coefficient buffer in any multi-pass mode. */
|
|
jinit_c_coef_controller(cinfo,
|
|
(boolean) (cinfo->num_scans > 1 ||
|
|
cinfo->optimize_coding));
|
|
|
|
/* Initialize method pointers.
|
|
*
|
|
* Note: entropy_start_pass and entropy_finish_pass are assigned in
|
|
* jcshuff.c or jcphuff.c and compress_data is assigned in jccoefct.c.
|
|
*/
|
|
lossyc->pub.start_pass = start_pass;
|
|
}
|