1 #include "pipe/p_compiler.h"
2 #include "util/u_debug.h"
3 #include "util/u_math.h"
4 #include "u_format_etc.h"
6 /* define etc1_parse_block and etc. */
7 #define UINT8_TYPE uint8_t
9 #include "../../../mesa/main/texcompress_etc_tmp.h"
14 util_format_etc1_rgb8_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
16 const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
17 struct etc1_block block;
20 for (y = 0; y < height; y += bh) {
21 const uint8_t *src = src_row;
23 for (x = 0; x < width; x+= bw) {
24 etc1_parse_block(&block, src);
26 for (j = 0; j < bh; j++) {
27 uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
28 for (i = 0; i < bw; i++) {
29 etc1_fetch_texel(&block, i, j, dst);
38 src_row += src_stride;
43 util_format_etc1_rgb8_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
49 util_format_etc1_rgb8_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
51 const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
52 struct etc1_block block;
55 for (y = 0; y < height; y += bh) {
56 const uint8_t *src = src_row;
58 for (x = 0; x < width; x+= bw) {
59 etc1_parse_block(&block, src);
61 for (j = 0; j < bh; j++) {
62 float *dst = dst_row + (y + j) * dst_stride / sizeof(*dst_row) + x * comps;
65 for (i = 0; i < bw; i++) {
66 etc1_fetch_texel(&block, i, j, tmp);
67 dst[0] = ubyte_to_float(tmp[0]);
68 dst[1] = ubyte_to_float(tmp[1]);
69 dst[2] = ubyte_to_float(tmp[2]);
78 src_row += src_stride;
83 util_format_etc1_rgb8_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
89 util_format_etc1_rgb8_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
91 const unsigned bw = 4, bh = 4;
92 struct etc1_block block;
95 assert(i < bw && j < bh);
97 etc1_parse_block(&block, src);
98 etc1_fetch_texel(&block, i, j, tmp);
100 dst[0] = ubyte_to_float(tmp[0]);
101 dst[1] = ubyte_to_float(tmp[1]);
102 dst[2] = ubyte_to_float(tmp[2]);