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.
119 lines
4.6 KiB
C
119 lines
4.6 KiB
C
/*
|
|
* AltiVec optimizations for libjpeg-turbo
|
|
*
|
|
* Copyright (C) 2015, D. R. Commander. All Rights Reserved.
|
|
*
|
|
* This software is provided 'as-is', without any express or implied
|
|
* warranty. In no event will the authors be held liable for any damages
|
|
* arising from the use of this software.
|
|
*
|
|
* Permission is granted to anyone to use this software for any purpose,
|
|
* including commercial applications, and to alter it and redistribute it
|
|
* freely, subject to the following restrictions:
|
|
*
|
|
* 1. The origin of this software must not be misrepresented; you must not
|
|
* claim that you wrote the original software. If you use this software
|
|
* in a product, an acknowledgment in the product documentation would be
|
|
* appreciated but is not required.
|
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
* misrepresented as being the original software.
|
|
* 3. This notice may not be removed or altered from any source distribution.
|
|
*/
|
|
|
|
/* MERGED YCC --> RGB CONVERSION AND UPSAMPLING */
|
|
|
|
#include "jsimd_altivec.h"
|
|
|
|
|
|
#define F_0_344 22554 /* FIX(0.34414) */
|
|
#define F_0_714 46802 /* FIX(0.71414) */
|
|
#define F_1_402 91881 /* FIX(1.40200) */
|
|
#define F_1_772 116130 /* FIX(1.77200) */
|
|
#define F_0_402 (F_1_402 - 65536) /* FIX(1.40200) - FIX(1) */
|
|
#define F_0_285 (65536 - F_0_714) /* FIX(1) - FIX(0.71414) */
|
|
#define F_0_228 (131072 - F_1_772) /* FIX(2) - FIX(1.77200) */
|
|
|
|
#define SCALEBITS 16
|
|
#define ONE_HALF (1 << (SCALEBITS - 1))
|
|
|
|
#define RGB_INDEX0 \
|
|
{ 0, 1, 8, 2, 3, 10, 4, 5, 12, 6, 7, 14, 16, 17, 24, 18 }
|
|
#define RGB_INDEX1 \
|
|
{ 3, 10, 4, 5, 12, 6, 7, 14, 16, 17, 24, 18, 19, 26, 20, 21 }
|
|
#define RGB_INDEX2 \
|
|
{ 12, 6, 7, 14, 16, 17, 24, 18, 19, 26, 20, 21, 28, 22, 23, 30 }
|
|
#include "jdmrgext-altivec.c"
|
|
#undef RGB_PIXELSIZE
|
|
|
|
#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
|
|
#define jsimd_h2v1_merged_upsample_altivec jsimd_h2v1_extrgb_merged_upsample_altivec
|
|
#define jsimd_h2v2_merged_upsample_altivec jsimd_h2v2_extrgb_merged_upsample_altivec
|
|
#include "jdmrgext-altivec.c"
|
|
#undef RGB_PIXELSIZE
|
|
#undef RGB_INDEX0
|
|
#undef RGB_INDEX1
|
|
#undef RGB_INDEX2
|
|
#undef jsimd_h2v1_merged_upsample_altivec
|
|
#undef jsimd_h2v2_merged_upsample_altivec
|
|
|
|
#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
|
|
#define RGB_INDEX \
|
|
{ 0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15 }
|
|
#define jsimd_h2v1_merged_upsample_altivec jsimd_h2v1_extrgbx_merged_upsample_altivec
|
|
#define jsimd_h2v2_merged_upsample_altivec jsimd_h2v2_extrgbx_merged_upsample_altivec
|
|
#include "jdmrgext-altivec.c"
|
|
#undef RGB_PIXELSIZE
|
|
#undef RGB_INDEX
|
|
#undef jsimd_h2v1_merged_upsample_altivec
|
|
#undef jsimd_h2v2_merged_upsample_altivec
|
|
|
|
#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
|
|
#define RGB_INDEX0 \
|
|
{ 8, 1, 0, 10, 3, 2, 12, 5, 4, 14, 7, 6, 24, 17, 16, 26 }
|
|
#define RGB_INDEX1 \
|
|
{ 3, 2, 12, 5, 4, 14, 7, 6, 24, 17, 16, 26, 19, 18, 28, 21 }
|
|
#define RGB_INDEX2 \
|
|
{ 4, 14, 7, 6, 24, 17, 16, 26, 19, 18, 28, 21, 20, 30, 23, 22 }
|
|
#define jsimd_h2v1_merged_upsample_altivec jsimd_h2v1_extbgr_merged_upsample_altivec
|
|
#define jsimd_h2v2_merged_upsample_altivec jsimd_h2v2_extbgr_merged_upsample_altivec
|
|
#include "jdmrgext-altivec.c"
|
|
#undef RGB_PIXELSIZE
|
|
#undef RGB_INDEX0
|
|
#undef RGB_INDEX1
|
|
#undef RGB_INDEX2
|
|
#undef jsimd_h2v1_merged_upsample_altivec
|
|
#undef jsimd_h2v2_merged_upsample_altivec
|
|
|
|
#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
|
|
#define RGB_INDEX \
|
|
{ 8, 1, 0, 9, 10, 3, 2, 11, 12, 5, 4, 13, 14, 7, 6, 15 }
|
|
#define jsimd_h2v1_merged_upsample_altivec jsimd_h2v1_extbgrx_merged_upsample_altivec
|
|
#define jsimd_h2v2_merged_upsample_altivec jsimd_h2v2_extbgrx_merged_upsample_altivec
|
|
#include "jdmrgext-altivec.c"
|
|
#undef RGB_PIXELSIZE
|
|
#undef RGB_INDEX
|
|
#undef jsimd_h2v1_merged_upsample_altivec
|
|
#undef jsimd_h2v2_merged_upsample_altivec
|
|
|
|
#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
|
|
#define RGB_INDEX \
|
|
{ 9, 8, 1, 0, 11, 10, 3, 2, 13, 12, 5, 4, 15, 14, 7, 6 }
|
|
#define jsimd_h2v1_merged_upsample_altivec jsimd_h2v1_extxbgr_merged_upsample_altivec
|
|
#define jsimd_h2v2_merged_upsample_altivec jsimd_h2v2_extxbgr_merged_upsample_altivec
|
|
#include "jdmrgext-altivec.c"
|
|
#undef RGB_PIXELSIZE
|
|
#undef RGB_INDEX
|
|
#undef jsimd_h2v1_merged_upsample_altivec
|
|
#undef jsimd_h2v2_merged_upsample_altivec
|
|
|
|
#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
|
|
#define RGB_INDEX \
|
|
{ 9, 0, 1, 8, 11, 2, 3, 10, 13, 4, 5, 12, 15, 6, 7, 14 }
|
|
#define jsimd_h2v1_merged_upsample_altivec jsimd_h2v1_extxrgb_merged_upsample_altivec
|
|
#define jsimd_h2v2_merged_upsample_altivec jsimd_h2v2_extxrgb_merged_upsample_altivec
|
|
#include "jdmrgext-altivec.c"
|
|
#undef RGB_PIXELSIZE
|
|
#undef RGB_INDEX
|
|
#undef jsimd_h2v1_merged_upsample_altivec
|
|
#undef jsimd_h2v2_merged_upsample_altivec
|