Path: blob/master/thirdparty/libjpeg-turbo/src/jdmainct.h
9904 views
/*1* jdmainct.h2*3* This file was part of the Independent JPEG Group's software:4* Copyright (C) 1994-1996, Thomas G. Lane.5* libjpeg-turbo Modifications:6* Copyright (C) 2022, D. R. Commander.7* For conditions of distribution and use, see the accompanying README.ijg8* file.9*/1011#define JPEG_INTERNALS12#include "jpeglib.h"13#include "jpegapicomp.h"14#include "jsamplecomp.h"151617#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)1819/* Private buffer controller object */2021typedef struct {22struct jpeg_d_main_controller pub; /* public fields */2324/* Pointer to allocated workspace (M or M+2 row groups). */25_JSAMPARRAY buffer[MAX_COMPONENTS];2627boolean buffer_full; /* Have we gotten an iMCU row from decoder? */28JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */2930/* Remaining fields are only used in the context case. */3132/* These are the master pointers to the funny-order pointer lists. */33_JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */3435int whichptr; /* indicates which pointer set is now in use */36int context_state; /* process_data state machine status */37JDIMENSION rowgroups_avail; /* row groups available to postprocessor */38JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */39} my_main_controller;4041typedef my_main_controller *my_main_ptr;424344/* context_state values: */45#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */46#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */47#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */484950LOCAL(void)51set_wraparound_pointers(j_decompress_ptr cinfo)52/* Set up the "wraparound" pointers at top and bottom of the pointer lists.53* This changes the pointer list state from top-of-image to the normal state.54*/55{56my_main_ptr main_ptr = (my_main_ptr)cinfo->main;57int ci, i, rgroup;58int M = cinfo->_min_DCT_scaled_size;59jpeg_component_info *compptr;60_JSAMPARRAY xbuf0, xbuf1;6162for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;63ci++, compptr++) {64rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /65cinfo->_min_DCT_scaled_size; /* height of a row group of component */66xbuf0 = main_ptr->xbuffer[0][ci];67xbuf1 = main_ptr->xbuffer[1][ci];68for (i = 0; i < rgroup; i++) {69xbuf0[i - rgroup] = xbuf0[rgroup * (M + 1) + i];70xbuf1[i - rgroup] = xbuf1[rgroup * (M + 1) + i];71xbuf0[rgroup * (M + 2) + i] = xbuf0[i];72xbuf1[rgroup * (M + 2) + i] = xbuf1[i];73}74}75}7677#endif /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */787980