34 #define RGBA(r, g, b, a) ((r) | ((g) << 8) | ((b) << 16) | ((a) << 24))
45 tmp = (color0 >> 11) * 255 + 16;
46 r0 = (
uint8_t) ((tmp / 32 + tmp) / 32);
47 tmp = ((color0 & 0x07E0) >> 5) * 255 + 32;
48 g0 = (
uint8_t) ((tmp / 64 + tmp) / 64);
49 tmp = (color0 & 0x001F) * 255 + 16;
50 b0 = (
uint8_t) ((tmp / 32 + tmp) / 32);
52 tmp = (color1 >> 11) * 255 + 16;
53 r1 = (
uint8_t) ((tmp / 32 + tmp) / 32);
54 tmp = ((color1 & 0x07E0) >> 5) * 255 + 32;
55 g1 = (
uint8_t) ((tmp / 64 + tmp) / 64);
56 tmp = (color1 & 0x001F) * 255 + 16;
57 b1 = (
uint8_t) ((tmp / 32 + tmp) / 32);
59 if (dxtn || color0 > color1) {
60 colors[0] =
RGBA(r0, g0, b0, a);
61 colors[1] =
RGBA(r1, g1, b1, a);
62 colors[2] =
RGBA((2 * r0 + r1) / 3,
66 colors[3] =
RGBA((2 * r1 + r0) / 3,
71 colors[0] =
RGBA(r0, g0, b0, a);
72 colors[1] =
RGBA(r1, g1, b1, a);
73 colors[2] =
RGBA((r0 + r1) / 2,
77 colors[3] =
RGBA(0, 0, 0, alpha);
86 uint16_t color0 =
AV_RL16(block + 0);
87 uint16_t color1 =
AV_RL16(block + 2);
88 uint32_t code =
AV_RL32(block + 4);
92 for (y = 0; y < 4; y++) {
93 for (x = 0; x < 4; x++) {
94 uint32_t
pixel = colors[code & 3];
140 uint16_t color0 =
AV_RL16(block + 8);
141 uint16_t color1 =
AV_RL16(block + 10);
142 uint32_t code =
AV_RL32(block + 12);
146 for (y = 0; y < 4; y++) {
147 const uint16_t alpha_code =
AV_RL16(block + 2 * y);
150 alpha_values[0] = ((alpha_code >> 0) & 0x0F) * 17;
151 alpha_values[1] = ((alpha_code >> 4) & 0x0F) * 17;
152 alpha_values[2] = ((alpha_code >> 8) & 0x0F) * 17;
153 alpha_values[3] = ((alpha_code >> 12) & 0x0F) * 17;
155 for (x = 0; x < 4; x++) {
157 uint32_t
pixel = colors[code & 3] | (alpha << 24);
174 src[0] = (
uint8_t) r * a / 255;
175 src[1] = (
uint8_t) g * a / 255;
176 src[2] = (
uint8_t) b * a / 255;
196 for (y = 0; y < 4; y++)
197 for (x = 0; x < 4; x++)
237 for (block = 0; block < 2; block++) {
241 for (i = 0; i < 8; i++)
242 dst[i] = (tmp >> (i * 3)) & 0x7;
255 uint16_t color0 =
AV_RL16(block + 8);
256 uint16_t color1 =
AV_RL16(block + 10);
257 uint32_t code =
AV_RL32(block + 12);
265 for (y = 0; y < 4; y++) {
266 for (x = 0; x < 4; x++) {
267 int alpha_code = alpha_indices[x + y * 4];
271 if (alpha_code == 0) {
273 }
else if (alpha_code == 1) {
276 if (alpha0 > alpha1) {
277 alpha = (
uint8_t) (((8 - alpha_code) * alpha0 +
278 (alpha_code - 1) * alpha1) / 7);
280 if (alpha_code == 6) {
282 }
else if (alpha_code == 7) {
285 alpha = (
uint8_t) (((6 - alpha_code) * alpha0 +
286 (alpha_code - 1) * alpha1) / 5);
290 pixel = colors[code & 3] | (alpha << 24);
315 for (y = 0; y < 4; y++)
316 for (x = 0; x < 4; x++)
351 int s = scaled ? (b >> 3) + 1 : 1;
353 int co = (r - 128) / s;
354 int cg = (g - 128) / s;
356 src[0] = av_clip_uint8(y + co - cg);
357 src[1] = av_clip_uint8(y + cg);
358 src[2] = av_clip_uint8(y - co - cg);
359 src[3] = scaled ? 255 :
b;
379 for (y = 0; y < 4; y++)
380 for (x = 0; x < 4; x++)
403 for (y = 0; y < 4; y++)
404 for (x = 0; x < 4; x++)
412 const int *color_tab)
423 for (y = 0; y < 4; y++) {
424 for (x = 0; x < 4; x++) {
425 int i = indices[x + y * 4];
427 int c = color_tab[i];
429 AV_WL32(dst + x * 4 + y * stride, pixel);
443 r0 = ((int8_t) block[0]) + 128;
444 r1 = ((int8_t) block[1]) + 128;
455 color_table[2] = (6 * r0 + 1 * r1) / 7;
456 color_table[3] = (5 * r0 + 2 * r1) / 7;
457 color_table[4] = (4 * r0 + 3 * r1) / 7;
458 color_table[5] = (3 * r0 + 4 * r1) / 7;
459 color_table[6] = (2 * r0 + 5 * r1) / 7;
460 color_table[7] = (1 * r0 + 6 * r1) / 7;
463 color_table[2] = (4 * r0 + 1 * r1) / 5;
464 color_table[3] = (3 * r0 + 2 * r1) / 5;
465 color_table[4] = (2 * r0 + 3 * r1) / 5;
466 color_table[5] = (1 * r0 + 4 * r1) / 5;
468 color_table[7] = 255;
519 for (y = 0; y < 4; y++) {
520 for (x = 0; x < 4; x++) {
522 int r = c0[x * 4 + y * 16];
523 int g = c1[x * 4 + y * 16];
526 int d = (255 * 255 - r * r - g *
g) / 2;
585 for (y = 0; y < 4; y++) {
586 for (x = 0; x < 4; x++) {
static double rint(double x)
int(* dxt1_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Texture block (4x4) module.
static void rgtc2_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block, int sign)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
static void dxt3_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Macro definitions for various function/variable attributes.
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 av_always_inline void ycocg2rgba(uint8_t *src, int scaled)
Convert a YCoCg buffer to RGBA.
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'.
int(* dxt5y_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
int(* dxt1a_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
static double alpha(void *priv, double x, double y)
int(* dxt4_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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 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 ...
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_RL24
int(* dxt5_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
static void dxt1_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block, uint8_t alpha)
av_cold void ff_texturedsp_init(TextureDSPContext *c)
int(* rgtc1s_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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 av_always_inline void premult2straight(uint8_t *src)
Convert a premultiplied alpha pixel to a straigth alpha pixel.
static av_always_inline void extract_color(uint32_t colors[4], uint16_t color0, uint16_t color1, int dxtn, int alpha)
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 void dxt5_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
static const ColorEntry color_table[]
int(* dxn3dc_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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...
int(* rgtc2u_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
int(* dxt3_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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 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'.
GLint GLenum GLboolean GLsizei stride
common internal and external API header
static void rgtc1_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block, int sign)
static void rgtc_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block, const int *color_tab)
int(* rgtc2s_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
#define FFSWAP(type, a, b)
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 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 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'...
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
int(* dxt5ys_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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.
int(* dxt2_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
int(* rgtc1u_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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'.