/* * jctrans.c * * This file was part of the Independent JPEG Group's software: * Copyright (C) 1995-1998, Thomas G. Lane. * Modified 2000-2009 by Guido Vollbeding. * libjpeg-turbo Modifications: * Copyright (C) 2020, 2022, D. R. Commander. * For conditions of distribution and use, see the accompanying README.ijg * file. * * This file contains library routines for transcoding compression, * that is, writing raw DCT coefficient arrays to an output JPEG file. * The routines in jcapimin.c will also be needed by a transcoder. */ #define JPEG_INTERNALS #include "jinclude.h" #include "jpeglib.h" #include "jpegcomp.h" /* Forward declarations */ LOCAL(void) transencode_master_selection(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays); LOCAL(void) transencode_coef_controller(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays); /* * Compression initialization for writing raw-coefficient data. * Before calling this, all parameters and a data destination must be set up. * Call jpeg_finish_compress() to actually write the data. * * The number of passed virtual arrays must match cinfo->num_components. * Note that the virtual arrays need not be filled or even realized at * the time write_coefficients is called; indeed, if the virtual arrays * were requested from this compression object's memory manager, they * typically will be realized during this routine and filled afterwards. */ GLOBAL(void) jpeg_write_coefficients(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays) { … } /* * Initialize the compression object with default parameters, * then copy from the source object all parameters needed for lossless * transcoding. Parameters that can be varied without loss (such as * scan script and Huffman optimization) are left in their default states. */ GLOBAL(void) jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo) { … } /* * Master selection of compression modules for transcoding. * This substitutes for jcinit.c's initialization of the full compressor. */ LOCAL(void) transencode_master_selection(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays) { … } /* * The rest of this file is a special implementation of the coefficient * buffer controller. This is similar to jccoefct.c, but it handles only * output from presupplied virtual arrays. Furthermore, we generate any * dummy padding blocks on-the-fly rather than expecting them to be present * in the arrays. */ /* Private buffer controller object */ my_coef_controller; my_coef_ptr; LOCAL(void) start_iMCU_row(j_compress_ptr cinfo) /* Reset within-iMCU-row counters for a new row */ { … } /* * Initialize for a processing pass. */ METHODDEF(void) start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode) { … } /* * Process some data. * We process the equivalent of one fully interleaved MCU row ("iMCU" row) * per call, ie, v_samp_factor block rows for each component in the scan. * The data is obtained from the virtual arrays and fed to the entropy coder. * Returns TRUE if the iMCU row is completed, FALSE if suspended. * * NB: input_buf is ignored; it is likely to be a NULL pointer. */ METHODDEF(boolean) compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf) { … } /* * Initialize coefficient buffer controller. * * Each passed coefficient array must be the right size for that * coefficient: width_in_blocks wide and height_in_blocks high, * with unitheight at least v_samp_factor. */ LOCAL(void) transencode_coef_controller(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays) { … }