DGen/SDL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
scale2x.c File Reference
#include "scale2x.h"
#include <assert.h>

Functions

static void scale2x_8_def_whole (scale2x_uint8 *restrict dst0, scale2x_uint8 *restrict dst1, const scale2x_uint8 *restrict src0, const scale2x_uint8 *restrict src1, const scale2x_uint8 *restrict src2, unsigned count)
 Define the macro USE_SCALE_RANDOMWRITE to enable an optimized version which writes memory in random order.
static void scale2x_8_def_border (scale2x_uint8 *restrict dst, const scale2x_uint8 *restrict src0, const scale2x_uint8 *restrict src1, const scale2x_uint8 *restrict src2, unsigned count)
static void scale2x_8_def_center (scale2x_uint8 *restrict dst, const scale2x_uint8 *restrict src0, const scale2x_uint8 *restrict src1, const scale2x_uint8 *restrict src2, unsigned count)
static void scale2x_16_def_whole (scale2x_uint16 *restrict dst0, scale2x_uint16 *restrict dst1, const scale2x_uint16 *restrict src0, const scale2x_uint16 *restrict src1, const scale2x_uint16 *restrict src2, unsigned count)
static void scale2x_16_def_border (scale2x_uint16 *restrict dst, const scale2x_uint16 *restrict src0, const scale2x_uint16 *restrict src1, const scale2x_uint16 *restrict src2, unsigned count)
static void scale2x_16_def_center (scale2x_uint16 *restrict dst, const scale2x_uint16 *restrict src0, const scale2x_uint16 *restrict src1, const scale2x_uint16 *restrict src2, unsigned count)
static void scale2x_32_def_whole (scale2x_uint32 *restrict dst0, scale2x_uint32 *restrict dst1, const scale2x_uint32 *restrict src0, const scale2x_uint32 *restrict src1, const scale2x_uint32 *restrict src2, unsigned count)
static void scale2x_32_def_border (scale2x_uint32 *restrict dst, const scale2x_uint32 *restrict src0, const scale2x_uint32 *restrict src1, const scale2x_uint32 *restrict src2, unsigned count)
static void scale2x_32_def_center (scale2x_uint32 *restrict dst, const scale2x_uint32 *restrict src0, const scale2x_uint32 *restrict src1, const scale2x_uint32 *restrict src2, unsigned count)
void scale2x_8_def (scale2x_uint8 *dst0, scale2x_uint8 *dst1, const scale2x_uint8 *src0, const scale2x_uint8 *src1, const scale2x_uint8 *src2, unsigned count)
 Scale by a factor of 2 a row of pixels of 8 bits.
void scale2x_16_def (scale2x_uint16 *dst0, scale2x_uint16 *dst1, const scale2x_uint16 *src0, const scale2x_uint16 *src1, const scale2x_uint16 *src2, unsigned count)
 Scale by a factor of 2 a row of pixels of 16 bits.
void scale2x_32_def (scale2x_uint32 *dst0, scale2x_uint32 *dst1, const scale2x_uint32 *src0, const scale2x_uint32 *src1, const scale2x_uint32 *src2, unsigned count)
 Scale by a factor of 2 a row of pixels of 32 bits.
void scale2x3_8_def (scale2x_uint8 *dst0, scale2x_uint8 *dst1, scale2x_uint8 *dst2, const scale2x_uint8 *src0, const scale2x_uint8 *src1, const scale2x_uint8 *src2, unsigned count)
 Scale by a factor of 2x3 a row of pixels of 8 bits.
void scale2x3_16_def (scale2x_uint16 *dst0, scale2x_uint16 *dst1, scale2x_uint16 *dst2, const scale2x_uint16 *src0, const scale2x_uint16 *src1, const scale2x_uint16 *src2, unsigned count)
 Scale by a factor of 2x3 a row of pixels of 16 bits.
void scale2x3_32_def (scale2x_uint32 *dst0, scale2x_uint32 *dst1, scale2x_uint32 *dst2, const scale2x_uint32 *src0, const scale2x_uint32 *src1, const scale2x_uint32 *src2, unsigned count)
 Scale by a factor of 2x3 a row of pixels of 32 bits.
void scale2x4_8_def (scale2x_uint8 *dst0, scale2x_uint8 *dst1, scale2x_uint8 *dst2, scale2x_uint8 *dst3, const scale2x_uint8 *src0, const scale2x_uint8 *src1, const scale2x_uint8 *src2, unsigned count)
 Scale by a factor of 2x4 a row of pixels of 8 bits.
void scale2x4_16_def (scale2x_uint16 *dst0, scale2x_uint16 *dst1, scale2x_uint16 *dst2, scale2x_uint16 *dst3, const scale2x_uint16 *src0, const scale2x_uint16 *src1, const scale2x_uint16 *src2, unsigned count)
 Scale by a factor of 2x4 a row of pixels of 16 bits.
void scale2x4_32_def (scale2x_uint32 *dst0, scale2x_uint32 *dst1, scale2x_uint32 *dst2, scale2x_uint32 *dst3, const scale2x_uint32 *src0, const scale2x_uint32 *src1, const scale2x_uint32 *src2, unsigned count)
 Scale by a factor of 2x4 a row of pixels of 32 bits.

Function Documentation

void scale2x3_16_def ( scale2x_uint16 dst0,
scale2x_uint16 dst1,
scale2x_uint16 dst2,
const scale2x_uint16 src0,
const scale2x_uint16 src1,
const scale2x_uint16 src2,
unsigned  count 
)

Scale by a factor of 2x3 a row of pixels of 16 bits.

Note:
Like scale2x_16_def();
void scale2x3_32_def ( scale2x_uint32 dst0,
scale2x_uint32 dst1,
scale2x_uint32 dst2,
const scale2x_uint32 src0,
const scale2x_uint32 src1,
const scale2x_uint32 src2,
unsigned  count 
)

Scale by a factor of 2x3 a row of pixels of 32 bits.

Note:
Like scale2x_32_def();
void scale2x3_8_def ( scale2x_uint8 dst0,
scale2x_uint8 dst1,
scale2x_uint8 dst2,
const scale2x_uint8 src0,
const scale2x_uint8 src1,
const scale2x_uint8 src2,
unsigned  count 
)

Scale by a factor of 2x3 a row of pixels of 8 bits.

Note:
Like scale2x_8_def();
void scale2x4_16_def ( scale2x_uint16 dst0,
scale2x_uint16 dst1,
scale2x_uint16 dst2,
scale2x_uint16 dst3,
const scale2x_uint16 src0,
const scale2x_uint16 src1,
const scale2x_uint16 src2,
unsigned  count 
)

Scale by a factor of 2x4 a row of pixels of 16 bits.

Note:
Like scale2x_16_def();
void scale2x4_32_def ( scale2x_uint32 dst0,
scale2x_uint32 dst1,
scale2x_uint32 dst2,
scale2x_uint32 dst3,
const scale2x_uint32 src0,
const scale2x_uint32 src1,
const scale2x_uint32 src2,
unsigned  count 
)

Scale by a factor of 2x4 a row of pixels of 32 bits.

Note:
Like scale2x_32_def();
void scale2x4_8_def ( scale2x_uint8 dst0,
scale2x_uint8 dst1,
scale2x_uint8 dst2,
scale2x_uint8 dst3,
const scale2x_uint8 src0,
const scale2x_uint8 src1,
const scale2x_uint8 src2,
unsigned  count 
)

Scale by a factor of 2x4 a row of pixels of 8 bits.

Note:
Like scale2x_8_def();
void scale2x_16_def ( scale2x_uint16 dst0,
scale2x_uint16 dst1,
const scale2x_uint16 src0,
const scale2x_uint16 src1,
const scale2x_uint16 src2,
unsigned  count 
)

Scale by a factor of 2 a row of pixels of 16 bits.

This function operates like scale2x_8_def() but for 16 bits pixels.

Parameters:
src0Pointer at the first pixel of the previous row.
src1Pointer at the first pixel of the current row.
src2Pointer at the first pixel of the next row.
countLength in pixels of the src0, src1 and src2 rows. It must be at least 2.
dst0First destination row, double length in pixels.
dst1Second destination row, double length in pixels.
static void scale2x_16_def_border ( scale2x_uint16 *restrict  dst,
const scale2x_uint16 *restrict  src0,
const scale2x_uint16 *restrict  src1,
const scale2x_uint16 *restrict  src2,
unsigned  count 
)
inlinestatic
static void scale2x_16_def_center ( scale2x_uint16 *restrict  dst,
const scale2x_uint16 *restrict  src0,
const scale2x_uint16 *restrict  src1,
const scale2x_uint16 *restrict  src2,
unsigned  count 
)
inlinestatic
static void scale2x_16_def_whole ( scale2x_uint16 *restrict  dst0,
scale2x_uint16 *restrict  dst1,
const scale2x_uint16 *restrict  src0,
const scale2x_uint16 *restrict  src1,
const scale2x_uint16 *restrict  src2,
unsigned  count 
)
inlinestatic
void scale2x_32_def ( scale2x_uint32 dst0,
scale2x_uint32 dst1,
const scale2x_uint32 src0,
const scale2x_uint32 src1,
const scale2x_uint32 src2,
unsigned  count 
)

Scale by a factor of 2 a row of pixels of 32 bits.

This function operates like scale2x_8_def() but for 32 bits pixels.

Parameters:
src0Pointer at the first pixel of the previous row.
src1Pointer at the first pixel of the current row.
src2Pointer at the first pixel of the next row.
countLength in pixels of the src0, src1 and src2 rows. It must be at least 2.
dst0First destination row, double length in pixels.
dst1Second destination row, double length in pixels.
static void scale2x_32_def_border ( scale2x_uint32 *restrict  dst,
const scale2x_uint32 *restrict  src0,
const scale2x_uint32 *restrict  src1,
const scale2x_uint32 *restrict  src2,
unsigned  count 
)
inlinestatic
static void scale2x_32_def_center ( scale2x_uint32 *restrict  dst,
const scale2x_uint32 *restrict  src0,
const scale2x_uint32 *restrict  src1,
const scale2x_uint32 *restrict  src2,
unsigned  count 
)
inlinestatic
static void scale2x_32_def_whole ( scale2x_uint32 *restrict  dst0,
scale2x_uint32 *restrict  dst1,
const scale2x_uint32 *restrict  src0,
const scale2x_uint32 *restrict  src1,
const scale2x_uint32 *restrict  src2,
unsigned  count 
)
inlinestatic
void scale2x_8_def ( scale2x_uint8 dst0,
scale2x_uint8 dst1,
const scale2x_uint8 src0,
const scale2x_uint8 src1,
const scale2x_uint8 src2,
unsigned  count 
)

Scale by a factor of 2 a row of pixels of 8 bits.

The function is implemented in C. The pixels over the left and right borders are assumed of the same color of the pixels on the border. Note that the implementation is optimized to write data sequentially to maximize the bandwidth on video memory.

Parameters:
src0Pointer at the first pixel of the previous row.
src1Pointer at the first pixel of the current row.
src2Pointer at the first pixel of the next row.
countLength in pixels of the src0, src1 and src2 rows. It must be at least 2.
dst0First destination row, double length in pixels.
dst1Second destination row, double length in pixels.
static void scale2x_8_def_border ( scale2x_uint8 *restrict  dst,
const scale2x_uint8 *restrict  src0,
const scale2x_uint8 *restrict  src1,
const scale2x_uint8 *restrict  src2,
unsigned  count 
)
inlinestatic
static void scale2x_8_def_center ( scale2x_uint8 *restrict  dst,
const scale2x_uint8 *restrict  src0,
const scale2x_uint8 *restrict  src1,
const scale2x_uint8 *restrict  src2,
unsigned  count 
)
inlinestatic
static void scale2x_8_def_whole ( scale2x_uint8 *restrict  dst0,
scale2x_uint8 *restrict  dst1,
const scale2x_uint8 *restrict  src0,
const scale2x_uint8 *restrict  src1,
const scale2x_uint8 *restrict  src2,
unsigned  count 
)
inlinestatic

Define the macro USE_SCALE_RANDOMWRITE to enable an optimized version which writes memory in random order.

This version is a little faster if you write in system memory. But it's a lot slower if you write in video memory. So, enable it only if you are sure to never write directly in video memory.