stb_image: Add more of the SSE2 skeleton.
This commit is contained in:
parent
c6a3235995
commit
fb2c841bb8
35
stb_image.h
35
stb_image.h
@ -191,6 +191,19 @@
|
|||||||
//
|
//
|
||||||
// The three functions you must define are "read" (reads some bytes of data),
|
// The three functions you must define are "read" (reads some bytes of data),
|
||||||
// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end).
|
// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end).
|
||||||
|
//
|
||||||
|
// ===========================================================================
|
||||||
|
//
|
||||||
|
// SIMD support
|
||||||
|
//
|
||||||
|
// The JPEG decoder will automatically use SIMD kernels where supported,
|
||||||
|
// replacing the STBI_SIMD-do-it-yourself interface from previous versions.
|
||||||
|
// The code will automatically detect if the required SIMD instructions are
|
||||||
|
// available, and fall back to the generic C version where they're not.
|
||||||
|
//
|
||||||
|
// The supplied kernels are designed to produce results that are bit-identical
|
||||||
|
// to the C versions. Nevertheless, if you want to disable this functionality,
|
||||||
|
// define STBI_NO_SIMD.
|
||||||
|
|
||||||
|
|
||||||
#ifndef STBI_NO_STDIO
|
#ifndef STBI_NO_STDIO
|
||||||
@ -404,6 +417,21 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];
|
|||||||
#define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y))))
|
#define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y))))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(STBI_NO_SIMD) && (defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86))
|
||||||
|
#define STBI_SSE2
|
||||||
|
#include <emmintrin.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name
|
||||||
|
#else // assume GCC-style if not VC++
|
||||||
|
#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STBI_SIMD_ALIGN
|
||||||
|
#define STBI_SIMD_ALIGN(type, name) type name
|
||||||
|
#endif
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// stbi__context struct and start_xxx functions
|
// stbi__context struct and start_xxx functions
|
||||||
@ -1445,10 +1473,7 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z)
|
|||||||
stbi__jpeg_reset(z);
|
stbi__jpeg_reset(z);
|
||||||
if (z->scan_n == 1) {
|
if (z->scan_n == 1) {
|
||||||
int i,j;
|
int i,j;
|
||||||
#ifdef STBI_SIMD
|
STBI_SIMD_ALIGN(short, data[64]);
|
||||||
__declspec(align(16))
|
|
||||||
#endif
|
|
||||||
short data[64];
|
|
||||||
int n = z->order[0];
|
int n = z->order[0];
|
||||||
// non-interleaved data, we just need to process one block at a time,
|
// non-interleaved data, we just need to process one block at a time,
|
||||||
// in trivial scanline order
|
// in trivial scanline order
|
||||||
@ -1473,7 +1498,7 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z)
|
|||||||
}
|
}
|
||||||
} else { // interleaved!
|
} else { // interleaved!
|
||||||
int i,j,k,x,y;
|
int i,j,k,x,y;
|
||||||
short data[64];
|
STBI_SIMD_ALIGN(short, data[64]);
|
||||||
for (j=0; j < z->img_mcu_y; ++j) {
|
for (j=0; j < z->img_mcu_y; ++j) {
|
||||||
for (i=0; i < z->img_mcu_x; ++i) {
|
for (i=0; i < z->img_mcu_x; ++i) {
|
||||||
// scan an interleaved mcu... process scan_n components in order
|
// scan an interleaved mcu... process scan_n components in order
|
||||||
|
Loading…
Reference in New Issue
Block a user