1/*
2 * jdmainct.h
3 *
4 * This file was part of the Independent JPEG Group's software:
5 * Copyright (C) 1994-1996, Thomas G. Lane.
6 * For conditions of distribution and use, see the accompanying README.ijg
7 * file.
8 */
9
10#define JPEG_INTERNALS
11#include "jpeglib.h"
12#include "jpegcomp.h"
13
14
15/* Private buffer controller object */
16
17typedef struct {
18 struct jpeg_d_main_controller pub; /* public fields */
19
20 /* Pointer to allocated workspace (M or M+2 row groups). */
21 JSAMPARRAY buffer[MAX_COMPONENTS];
22
23 boolean buffer_full; /* Have we gotten an iMCU row from decoder? */
24 JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */
25
26 /* Remaining fields are only used in the context case. */
27
28 /* These are the master pointers to the funny-order pointer lists. */
29 JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */
30
31 int whichptr; /* indicates which pointer set is now in use */
32 int context_state; /* process_data state machine status */
33 JDIMENSION rowgroups_avail; /* row groups available to postprocessor */
34 JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */
35} my_main_controller;
36
37typedef my_main_controller *my_main_ptr;
38
39
40/* context_state values: */
41#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */
42#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */
43#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */
44
45
46LOCAL(void)
47set_wraparound_pointers(j_decompress_ptr cinfo)
48/* Set up the "wraparound" pointers at top and bottom of the pointer lists.
49 * This changes the pointer list state from top-of-image to the normal state.
50 */
51{
52 my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
53 int ci, i, rgroup;
54 int M = cinfo->_min_DCT_scaled_size;
55 jpeg_component_info *compptr;
56 JSAMPARRAY xbuf0, xbuf1;
57
58 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
59 ci++, compptr++) {
60 rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
61 cinfo->_min_DCT_scaled_size; /* height of a row group of component */
62 xbuf0 = main_ptr->xbuffer[0][ci];
63 xbuf1 = main_ptr->xbuffer[1][ci];
64 for (i = 0; i < rgroup; i++) {
65 xbuf0[i - rgroup] = xbuf0[rgroup * (M + 1) + i];
66 xbuf1[i - rgroup] = xbuf1[rgroup * (M + 1) + i];
67 xbuf0[rgroup * (M + 2) + i] = xbuf0[i];
68 xbuf1[rgroup * (M + 2) + i] = xbuf1[i];
69 }
70 }
71}
72