With rare exceptions ...
- Always separate line continuation characters by one space from
preceding code.
- Always use two-space indentation. Never use tabs.
- Always use K&R-style conditional blocks.
- Always surround operators with spaces, except in raw assembly code.
- Always put a space after, but not before, a comma.
- Never put a space between type casts and variables/function calls.
- Never put a space between the function name and the argument list in
function declarations and prototypes.
- Always surround braces ('{' and '}') with spaces.
- Always surround statements (if, for, else, catch, while, do, switch)
with spaces.
- Always attach pointer symbols ('*' and '**') to the variable or
function name.
- Always precede pointer symbols ('*' and '**') by a space in type
casts.
- Use the MIN() macro from jpegint.h within the libjpeg and TurboJPEG
API libraries (using min() from tjutil.h is still necessary for
TJBench.)
- Where it makes sense (particularly in the TurboJPEG code), put a blank
line after variable declaration blocks.
- Always separate statements in one-liners by two spaces.
The purpose of this was to ease maintenance on my part and also to make
it easier for contributors to figure out how to format patch
submissions. This was admittedly confusing (even to me sometimes) when
we had 3 or 4 different style conventions in the same source tree. The
new convention is more consistent with the formatting of other OSS code
bases.
This commit corrects deviations from the chosen formatting style in the
libjpeg API code and reformats the TurboJPEG API code such that it
conforms to the same standard.
NOTES:
- Although it is no longer necessary for the function name in function
declarations to begin in Column 1 (this was historically necessary
because of the ansi2knr utility, which allowed libjpeg to be built
with non-ANSI compilers), we retain that formatting for the libjpeg
code because it improves readability when using libjpeg's function
attribute macros (GLOBAL(), etc.)
- This reformatting project was accomplished with the help of AStyle and
Uncrustify, although neither was completely up to the task, and thus
a great deal of manual tweaking was required. Note to developers of
code formatting utilities: the libjpeg-turbo code base is an
excellent test bed, because AFAICT, it breaks every single one of the
utilities that are currently available.
- The legacy (MMX, SSE, 3DNow!) assembly code for i386 has been
formatted to match the SSE2 code (refer to
ff5685d5344273df321eb63a005eaae19d2496e3.) I hadn't intended to
bother with this, but the Loongson MMI implementation demonstrated
that there is still academic value to the MMX implementation, as an
algorithmic model for other 64-bit vector implementations. Thus, it
is desirable to improve its readability in the same manner as that of
the SSE2 implementation.
72 lines
2.4 KiB
C
72 lines
2.4 KiB
C
/*
|
|
* jdmainct.h
|
|
*
|
|
* This file was part of the Independent JPEG Group's software:
|
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
|
* For conditions of distribution and use, see the accompanying README.ijg
|
|
* file.
|
|
*/
|
|
|
|
#define JPEG_INTERNALS
|
|
#include "jpeglib.h"
|
|
#include "jpegcomp.h"
|
|
|
|
|
|
/* Private buffer controller object */
|
|
|
|
typedef struct {
|
|
struct jpeg_d_main_controller pub; /* public fields */
|
|
|
|
/* Pointer to allocated workspace (M or M+2 row groups). */
|
|
JSAMPARRAY buffer[MAX_COMPONENTS];
|
|
|
|
boolean buffer_full; /* Have we gotten an iMCU row from decoder? */
|
|
JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */
|
|
|
|
/* Remaining fields are only used in the context case. */
|
|
|
|
/* These are the master pointers to the funny-order pointer lists. */
|
|
JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */
|
|
|
|
int whichptr; /* indicates which pointer set is now in use */
|
|
int context_state; /* process_data state machine status */
|
|
JDIMENSION rowgroups_avail; /* row groups available to postprocessor */
|
|
JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */
|
|
} my_main_controller;
|
|
|
|
typedef my_main_controller *my_main_ptr;
|
|
|
|
|
|
/* context_state values: */
|
|
#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */
|
|
#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */
|
|
#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */
|
|
|
|
|
|
LOCAL(void)
|
|
set_wraparound_pointers(j_decompress_ptr cinfo)
|
|
/* Set up the "wraparound" pointers at top and bottom of the pointer lists.
|
|
* This changes the pointer list state from top-of-image to the normal state.
|
|
*/
|
|
{
|
|
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
|
int ci, i, rgroup;
|
|
int M = cinfo->_min_DCT_scaled_size;
|
|
jpeg_component_info *compptr;
|
|
JSAMPARRAY xbuf0, xbuf1;
|
|
|
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
|
ci++, compptr++) {
|
|
rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
|
|
cinfo->_min_DCT_scaled_size; /* height of a row group of component */
|
|
xbuf0 = main_ptr->xbuffer[0][ci];
|
|
xbuf1 = main_ptr->xbuffer[1][ci];
|
|
for (i = 0; i < rgroup; i++) {
|
|
xbuf0[i - rgroup] = xbuf0[rgroup * (M + 1) + i];
|
|
xbuf1[i - rgroup] = xbuf1[rgroup * (M + 1) + i];
|
|
xbuf0[rgroup * (M + 2) + i] = xbuf0[i];
|
|
xbuf1[rgroup * (M + 2) + i] = xbuf1[i];
|
|
}
|
|
}
|
|
}
|