diff options
author | Matt Turner <mattst88@gmail.com> | 2015-02-20 19:46:21 -0800 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2015-02-23 10:41:22 -0800 |
commit | 14ded5ee61b2dfc23878c4a6f38021b15bd0a2fc (patch) | |
tree | c18fe35996ccfe416e558683075479876537830d /src/gallium/auxiliary/util/u_format_yuv.c | |
parent | 3492e88090d2d0c0bfbc934963b8772b45fc8880 (diff) | |
download | external_mesa3d-14ded5ee61b2dfc23878c4a6f38021b15bd0a2fc.zip external_mesa3d-14ded5ee61b2dfc23878c4a6f38021b15bd0a2fc.tar.gz external_mesa3d-14ded5ee61b2dfc23878c4a6f38021b15bd0a2fc.tar.bz2 |
gallium: Use util_cpu_to_le{16,32} in many more places.
... and util_le{16,32}_to_cpu. I think I've used the right ones for
describing the actual operation performed (even though they're both just
"byte-swap this if I'm on big-endian").
The Linux Kernel has typedefs __le32/__be32 and friends that static
analysis tools can use to check that byte-orderings are correct. It
might be interesting to apply that here as well.
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/util/u_format_yuv.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_format_yuv.c | 192 |
1 files changed, 32 insertions, 160 deletions
diff --git a/src/gallium/auxiliary/util/u_format_yuv.c b/src/gallium/auxiliary/util/u_format_yuv.c index 891d99c..16ed8af 100644 --- a/src/gallium/auxiliary/util/u_format_yuv.c +++ b/src/gallium/auxiliary/util/u_format_yuv.c @@ -52,11 +52,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid float r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); r = ubyte_to_float((value >> 0) & 0xff); g0 = ubyte_to_float((value >> 8) & 0xff); @@ -77,11 +73,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); r = ubyte_to_float((value >> 0) & 0xff); g0 = ubyte_to_float((value >> 8) & 0xff); @@ -114,11 +106,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st uint8_t r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); r = (value >> 0) & 0xff; g0 = (value >> 8) & 0xff; @@ -139,11 +127,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); r = (value >> 0) & 0xff; g0 = (value >> 8) & 0xff; @@ -186,11 +170,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(b) << 16; value |= float_to_ubyte(g1) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -206,11 +186,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(b) << 16; value |= float_to_ubyte(g1) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -243,11 +219,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= b << 16; value |= g1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -263,11 +235,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= b << 16; value |= g1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -304,11 +272,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid float r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); g0 = ubyte_to_float((value >> 0) & 0xff); r = ubyte_to_float((value >> 8) & 0xff); @@ -329,11 +293,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); g0 = ubyte_to_float((value >> 0) & 0xff); r = ubyte_to_float((value >> 8) & 0xff); @@ -366,11 +326,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st uint8_t r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); g0 = (value >> 0) & 0xff; r = (value >> 8) & 0xff; @@ -391,11 +347,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); g0 = (value >> 0) & 0xff; r = (value >> 8) & 0xff; @@ -438,11 +390,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(g1) << 16; value |= float_to_ubyte(b) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -458,11 +406,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(g1) << 16; value |= float_to_ubyte(b) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -495,11 +439,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= g1 << 16; value |= b << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -515,11 +455,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= g1 << 16; value |= b << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -556,11 +492,7 @@ util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -577,11 +509,7 @@ util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -612,11 +540,7 @@ util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -633,11 +557,7 @@ util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -683,11 +603,7 @@ util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -702,11 +618,7 @@ util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -744,11 +656,7 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -763,11 +671,7 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -809,11 +713,7 @@ util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -830,11 +730,7 @@ util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -865,11 +761,7 @@ util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -886,11 +778,7 @@ util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -936,11 +824,7 @@ util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -955,11 +839,7 @@ util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -997,11 +877,7 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -1016,11 +892,7 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); |