Path: blob/master/thirdparty/libjpeg-turbo/src/jdcoefct.h
9904 views
/*1* jdcoefct.h2*3* This file was part of the Independent JPEG Group's software:4* Copyright (C) 1994-1997, Thomas G. Lane.5* libjpeg-turbo Modifications:6* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB7* Copyright (C) 2020, Google, Inc.8* Copyright (C) 2022, D. R. Commander.9* For conditions of distribution and use, see the accompanying README.ijg10* file.11*/1213#define JPEG_INTERNALS14#include "jpeglib.h"151617#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)1819/* Block smoothing is only applicable for progressive JPEG, so: */20#ifndef D_PROGRESSIVE_SUPPORTED21#undef BLOCK_SMOOTHING_SUPPORTED22#endif232425/* Private buffer controller object */2627typedef struct {28struct jpeg_d_coef_controller pub; /* public fields */2930/* These variables keep track of the current location of the input side. */31/* cinfo->input_iMCU_row is also used for this. */32JDIMENSION MCU_ctr; /* counts MCUs processed in current row */33int MCU_vert_offset; /* counts MCU rows within iMCU row */34int MCU_rows_per_iMCU_row; /* number of such rows needed */3536/* The output side's location is represented by cinfo->output_iMCU_row. */3738/* In single-pass modes, it's sufficient to buffer just one MCU.39* We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,40* and let the entropy decoder write into that workspace each time.41* In multi-pass modes, this array points to the current MCU's blocks42* within the virtual arrays; it is used only by the input side.43*/44JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU];4546/* Temporary workspace for one MCU */47JCOEF *workspace;4849#ifdef D_MULTISCAN_FILES_SUPPORTED50/* In multi-pass modes, we need a virtual block array for each component. */51jvirt_barray_ptr whole_image[MAX_COMPONENTS];52#endif5354#ifdef BLOCK_SMOOTHING_SUPPORTED55/* When doing block smoothing, we latch coefficient Al values here */56int *coef_bits_latch;57#define SAVED_COEFS 10 /* we save coef_bits[0..9] */58#endif59} my_coef_controller;6061typedef my_coef_controller *my_coef_ptr;626364LOCAL(void)65start_iMCU_row(j_decompress_ptr cinfo)66/* Reset within-iMCU-row counters for a new row (input side) */67{68my_coef_ptr coef = (my_coef_ptr)cinfo->coef;6970/* In an interleaved scan, an MCU row is the same as an iMCU row.71* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.72* But at the bottom of the image, process only what's left.73*/74if (cinfo->comps_in_scan > 1) {75coef->MCU_rows_per_iMCU_row = 1;76} else {77if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows - 1))78coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;79else80coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;81}8283coef->MCU_ctr = 0;84coef->MCU_vert_offset = 0;85}8687#endif /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */888990