35#define RGBA(r, g, b, a) (((uint8_t)(r) << 0) | \
36 ((uint8_t)(g) << 8) | \
37 ((uint8_t)(b) << 16) | \
38 ((unsigned)(uint8_t)(a) << 24))
46 uint8_t r0, g0,
b0, r1, g1,
b1;
47 uint8_t
a = dxtn ? 0 : 255;
49 tmp = (color0 >> 11) * 255 + 16;
50 r0 = (uint8_t) ((
tmp / 32 +
tmp) / 32);
51 tmp = ((color0 & 0x07E0) >> 5) * 255 + 32;
52 g0 = (uint8_t) ((
tmp / 64 +
tmp) / 64);
53 tmp = (color0 & 0x001F) * 255 + 16;
54 b0 = (uint8_t) ((
tmp / 32 +
tmp) / 32);
56 tmp = (color1 >> 11) * 255 + 16;
57 r1 = (uint8_t) ((
tmp / 32 +
tmp) / 32);
58 tmp = ((color1 & 0x07E0) >> 5) * 255 + 32;
59 g1 = (uint8_t) ((
tmp / 64 +
tmp) / 64);
60 tmp = (color1 & 0x001F) * 255 + 16;
61 b1 = (uint8_t) ((
tmp / 32 +
tmp) / 32);
63 if (dxtn || color0 > color1) {
64 colors[0] =
RGBA(r0, g0,
b0,
a);
65 colors[1] =
RGBA(r1, g1,
b1,
a);
66 colors[2] =
RGBA((2 * r0 + r1) / 3,
70 colors[3] =
RGBA((2 * r1 + r0) / 3,
75 colors[0] =
RGBA(r0, g0,
b0,
a);
76 colors[1] =
RGBA(r1, g1,
b1,
a);
77 colors[2] =
RGBA((r0 + r1) / 2,
96 for (y = 0; y < 4; y++) {
97 for (x = 0; x < 4; x++) {
140 const uint8_t *
block)
150 for (y = 0; y < 4; y++) {
152 uint8_t alpha_values[4];
154 alpha_values[0] = ((alpha_code >> 0) & 0x0F) * 17;
155 alpha_values[1] = ((alpha_code >> 4) & 0x0F) * 17;
156 alpha_values[2] = ((alpha_code >> 8) & 0x0F) * 17;
157 alpha_values[3] = ((alpha_code >> 12) & 0x0F) * 17;
159 for (x = 0; x < 4; x++) {
160 uint8_t
alpha = alpha_values[x];
203 for (y = 0; y < 4; y++)
204 for (x = 0; x < 4; x++)
248 for (
i = 0;
i < 8;
i++)
257 const uint8_t *
block)
261 uint8_t alpha_indices[16];
265 uint8_t alpha0 = *(
block);
266 uint8_t alpha1 = *(
block + 1);
272 for (y = 0; y < 4; y++) {
273 for (x = 0; x < 4; x++) {
274 int alpha_code = alpha_indices[x + y * 4];
278 if (alpha_code == 0) {
280 }
else if (alpha_code == 1) {
283 if (alpha0 > alpha1) {
284 alpha = (uint8_t) (((8 - alpha_code) * alpha0 +
285 (alpha_code - 1) * alpha1) / 7);
287 if (alpha_code == 6) {
289 }
else if (alpha_code == 7) {
292 alpha = (uint8_t) (((6 - alpha_code) * alpha0 +
293 (alpha_code - 1) * alpha1) / 5);
322 for (y = 0; y < 4; y++)
323 for (x = 0; x < 4; x++)
358 int s = scaled ? (
b >> 3) + 1 : 1;
360 int co = (
r - 128) /
s;
361 int cg = (
g - 128) /
s;
366 src[3] = scaled ? 255 :
b;
386 for (y = 0; y < 4; y++)
387 for (x = 0; x < 4; x++)
410 for (y = 0; y < 4; y++)
411 for (x = 0; x < 4; x++)
418 const uint8_t *
block,
419 const int *color_tab,
int mono,
int offset,
int pix_size)
430 for (y = 0; y < 4; y++) {
431 for (x = 0; x < 4; x++) {
432 int i = indices[x + y * 4];
434 int c = color_tab[
i];
448 const uint8_t *
block,
int sign,
int mono,
int offset,
int pix_size)
456 r0 = ((int8_t)
block[0]) + 128;
457 r1 = ((int8_t)
block[1]) + 128;
552 const uint8_t *
block,
int sign)
555 uint8_t c0[4 * 4 * 4];
556 uint8_t
c1[4 * 4 * 4];
564 for (y = 0; y < 4; y++) {
565 for (x = 0; x < 4; x++) {
567 int r = c0[x * 4 + y * 16];
568 int g =
c1[x * 4 + y * 16];
571 int d = (255 * 255 -
r *
r -
g *
g) / 2;
630 for (y = 0; y < 4; y++) {
631 for (x = 0; x < 4; x++) {
633 FFSWAP(uint8_t, p[0], p[1]);
659#define TEXTUREDSP_FUNC_NAME ff_texturedsp_exec_decompress_threads
660#define TEXTUREDSP_TEX_FUNC(a, b, c) tex_funct(a, b, c)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define i(width, name, range_min, range_max)
common internal and external API header
static __device__ float sqrtf(float a)
static const int16_t alpha[]
Macro definitions for various function/variable attributes.
Replacements for frequently missing libm functions.
#define FFSWAP(type, a, b)
static int rgtc1u_gray_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a RGTC1 texture with unsigned components to Gray 8.
av_cold void ff_texturedsp_init(TextureDSPContext *c)
static void dxt5_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
static int dxt4_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a DXT4 texture and store the resulting RGBA pixels in 'dst'.
static void decompress_indices(uint8_t *dst, const uint8_t *src)
Decompress a BC 16x3 index block stored as h g f e d c b a p o n m l k j i.
static int rgtc2u_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a RGRC2 texture with unsigned components and store the resulting RGBA pixels ...
static int dxt5_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a DXT5 texture and store the resulting RGBA pixels in 'dst'.
static void rgtc_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block, const int *color_tab, int mono, int offset, int pix_size)
static av_always_inline void ycocg2rgba(uint8_t *src, int scaled)
Convert a YCoCg buffer to RGBA.
static av_always_inline void premult2straight(uint8_t *src)
Convert a premultiplied alpha pixel to a straight alpha pixel.
static int dxn3dc_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a 3Dc texture with unsigned components and store the resulting RGBA pixels in...
static int rgtc1u_alpha_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a RGTC1 texture with unsigned components and overwrite the alpha component in...
static void dxt1_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block, uint8_t alpha)
static int dxt1a_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a DXT1 with 1-bit alpha texture and store the resulting RGBA pixels in 'dst'.
static int dxt1_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a DXT1 texture and store the resulting RGBA pixels in 'dst'.
static int rgtc1s_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a RGRC1 texture with signed components and store the resulting RGBA pixels in...
static void dxt3_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
static void rgtc2_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block, int sign)
static void rgtc1_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block, int sign, int mono, int offset, int pix_size)
static int dxt5ys_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a DXT5 texture with scaled YCoCg and store the resulting RGBA pixels in 'dst'...
static int dxt5y_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a DXT5 texture with classic YCoCg and store the resulting RGBA pixels in 'dst...
static int dxt2_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a DXT2 texture and store the resulting RGBA pixels in 'dst'.
static av_always_inline void extract_color(uint32_t colors[4], uint16_t color0, uint16_t color1, int dxtn, int alpha)
static int rgtc1u_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a RGRC1 texture with unsigned components and store the resulting RGBA pixels ...
static int dxt3_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a DXT3 texture and store the resulting RGBA pixels in 'dst'.
static int rgtc2s_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Decompress one block of a RGRC2 texture with signed components and store the resulting RGBA pixels in...
Texture block (4x4) module.
static double b1(void *priv, double x, double y)
static double b0(void *priv, double x, double y)
static const ColorEntry color_table[]