1 /**************************************************************************
3 * Copyright 2010 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
26 **************************************************************************/
31 * YUV and RGB subsampled formats conversion.
33 * @author Jose Fonseca <jfonseca@vmware.com>
37 #include "util/u_debug.h"
38 #include "util/u_format_yuv.h"
42 util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
43 const uint8_t *src_row
, unsigned src_stride
,
44 unsigned width
, unsigned height
)
48 for (y
= 0; y
< height
; y
+= 1) {
50 const uint32_t *src
= (const uint32_t *)src_row
;
54 for (x
= 0; x
+ 1 < width
; x
+= 2) {
57 #ifdef PIPE_ARCH_BIG_ENDIAN
58 value
= util_bswap32(value
);
61 r
= ubyte_to_float((value
>> 0) & 0xff);
62 g0
= ubyte_to_float((value
>> 8) & 0xff);
63 b
= ubyte_to_float((value
>> 16) & 0xff);
64 g1
= ubyte_to_float((value
>> 24) & 0xff);
69 dst
[3] = 1.0f
; /* a */
75 dst
[3] = 1.0f
; /* a */
82 #ifdef PIPE_ARCH_BIG_ENDIAN
83 value
= util_bswap32(value
);
86 r
= ubyte_to_float((value
>> 0) & 0xff);
87 g0
= ubyte_to_float((value
>> 8) & 0xff);
88 b
= ubyte_to_float((value
>> 16) & 0xff);
89 g1
= ubyte_to_float((value
>> 24) & 0xff);
94 dst
[3] = 1.0f
; /* a */
97 src_row
+= src_stride
/sizeof(*src_row
);
98 dst_row
+= dst_stride
/sizeof(*dst_row
);
104 util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
105 const uint8_t *src_row
, unsigned src_stride
,
106 unsigned width
, unsigned height
)
110 for (y
= 0; y
< height
; y
+= 1) {
111 uint8_t *dst
= dst_row
;
112 const uint32_t *src
= (const uint32_t *)src_row
;
114 uint8_t r
, g0
, g1
, b
;
116 for (x
= 0; x
+ 1 < width
; x
+= 2) {
119 #ifdef PIPE_ARCH_BIG_ENDIAN
120 value
= util_bswap32(value
);
123 r
= (value
>> 0) & 0xff;
124 g0
= (value
>> 8) & 0xff;
125 b
= (value
>> 16) & 0xff;
126 g1
= (value
>> 24) & 0xff;
131 dst
[3] = 0xff; /* a */
137 dst
[3] = 0xff; /* a */
144 #ifdef PIPE_ARCH_BIG_ENDIAN
145 value
= util_bswap32(value
);
148 r
= (value
>> 0) & 0xff;
149 g0
= (value
>> 8) & 0xff;
150 b
= (value
>> 16) & 0xff;
151 g1
= (value
>> 24) & 0xff;
156 dst
[3] = 0xff; /* a */
159 src_row
+= src_stride
/sizeof(*src_row
);
160 dst_row
+= dst_stride
/sizeof(*dst_row
);
166 util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
167 const float *src_row
, unsigned src_stride
,
168 unsigned width
, unsigned height
)
172 for (y
= 0; y
< height
; y
+= 1) {
173 const float *src
= src_row
;
174 uint32_t *dst
= (uint32_t *)dst_row
;
178 for (x
= 0; x
+ 1 < width
; x
+= 2) {
179 r
= 0.5f
*(src
[0] + src
[4]);
182 b
= 0.5f
*(src
[2] + src
[6]);
184 value
= float_to_ubyte(r
);
185 value
|= float_to_ubyte(g0
) << 8;
186 value
|= float_to_ubyte(b
) << 16;
187 value
|= float_to_ubyte(g1
) << 24;
189 #ifdef PIPE_ARCH_BIG_ENDIAN
190 value
= util_bswap32(value
);
204 value
= float_to_ubyte(r
);
205 value
|= float_to_ubyte(g0
) << 8;
206 value
|= float_to_ubyte(b
) << 16;
207 value
|= float_to_ubyte(g1
) << 24;
209 #ifdef PIPE_ARCH_BIG_ENDIAN
210 value
= util_bswap32(value
);
216 dst_row
+= dst_stride
/sizeof(*dst_row
);
217 src_row
+= src_stride
/sizeof(*src_row
);
223 util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
224 const uint8_t *src_row
, unsigned src_stride
,
225 unsigned width
, unsigned height
)
229 for (y
= 0; y
< height
; y
+= 1) {
230 const uint8_t *src
= src_row
;
231 uint32_t *dst
= (uint32_t *)dst_row
;
232 uint32_t r
, g0
, g1
, b
;
235 for (x
= 0; x
+ 1 < width
; x
+= 2) {
236 r
= (src
[0] + src
[4] + 1) >> 1;
239 b
= (src
[2] + src
[6] + 1) >> 1;
246 #ifdef PIPE_ARCH_BIG_ENDIAN
247 value
= util_bswap32(value
);
266 #ifdef PIPE_ARCH_BIG_ENDIAN
267 value
= util_bswap32(value
);
273 dst_row
+= dst_stride
/sizeof(*dst_row
);
274 src_row
+= src_stride
/sizeof(*src_row
);
280 util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst
, const uint8_t *src
,
281 unsigned i
, unsigned j
)
286 dst
[0] = ubyte_to_float(src
[0]); /* r */
287 dst
[1] = ubyte_to_float(src
[1 + 2*i
]); /* g */
288 dst
[2] = ubyte_to_float(src
[2]); /* b */
289 dst
[3] = 1.0f
; /* a */
294 util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
295 const uint8_t *src_row
, unsigned src_stride
,
296 unsigned width
, unsigned height
)
300 for (y
= 0; y
< height
; y
+= 1) {
301 float *dst
= dst_row
;
302 const uint32_t *src
= (const uint32_t *)src_row
;
306 for (x
= 0; x
+ 1 < width
; x
+= 2) {
309 #ifdef PIPE_ARCH_BIG_ENDIAN
310 value
= util_bswap32(value
);
313 g0
= ubyte_to_float((value
>> 0) & 0xff);
314 r
= ubyte_to_float((value
>> 8) & 0xff);
315 g1
= ubyte_to_float((value
>> 16) & 0xff);
316 b
= ubyte_to_float((value
>> 24) & 0xff);
321 dst
[3] = 1.0f
; /* a */
327 dst
[3] = 1.0f
; /* a */
334 #ifdef PIPE_ARCH_BIG_ENDIAN
335 value
= util_bswap32(value
);
338 g0
= ubyte_to_float((value
>> 0) & 0xff);
339 r
= ubyte_to_float((value
>> 8) & 0xff);
340 g1
= ubyte_to_float((value
>> 16) & 0xff);
341 b
= ubyte_to_float((value
>> 24) & 0xff);
346 dst
[3] = 1.0f
; /* a */
349 src_row
+= src_stride
/sizeof(*src_row
);
350 dst_row
+= dst_stride
/sizeof(*dst_row
);
356 util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
357 const uint8_t *src_row
, unsigned src_stride
,
358 unsigned width
, unsigned height
)
362 for (y
= 0; y
< height
; y
+= 1) {
363 uint8_t *dst
= dst_row
;
364 const uint32_t *src
= (const uint32_t *)src_row
;
366 uint8_t r
, g0
, g1
, b
;
368 for (x
= 0; x
+ 1 < width
; x
+= 2) {
371 #ifdef PIPE_ARCH_BIG_ENDIAN
372 value
= util_bswap32(value
);
375 g0
= (value
>> 0) & 0xff;
376 r
= (value
>> 8) & 0xff;
377 g1
= (value
>> 16) & 0xff;
378 b
= (value
>> 24) & 0xff;
383 dst
[3] = 0xff; /* a */
389 dst
[3] = 0xff; /* a */
396 #ifdef PIPE_ARCH_BIG_ENDIAN
397 value
= util_bswap32(value
);
400 g0
= (value
>> 0) & 0xff;
401 r
= (value
>> 8) & 0xff;
402 g1
= (value
>> 16) & 0xff;
403 b
= (value
>> 24) & 0xff;
408 dst
[3] = 0xff; /* a */
411 src_row
+= src_stride
/sizeof(*src_row
);
412 dst_row
+= dst_stride
/sizeof(*dst_row
);
418 util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
419 const float *src_row
, unsigned src_stride
,
420 unsigned width
, unsigned height
)
424 for (y
= 0; y
< height
; y
+= 1) {
425 const float *src
= src_row
;
426 uint32_t *dst
= (uint32_t *)dst_row
;
430 for (x
= 0; x
+ 1 < width
; x
+= 2) {
431 r
= 0.5f
*(src
[0] + src
[4]);
434 b
= 0.5f
*(src
[2] + src
[6]);
436 value
= float_to_ubyte(g0
);
437 value
|= float_to_ubyte(r
) << 8;
438 value
|= float_to_ubyte(g1
) << 16;
439 value
|= float_to_ubyte(b
) << 24;
441 #ifdef PIPE_ARCH_BIG_ENDIAN
442 value
= util_bswap32(value
);
456 value
= float_to_ubyte(g0
);
457 value
|= float_to_ubyte(r
) << 8;
458 value
|= float_to_ubyte(g1
) << 16;
459 value
|= float_to_ubyte(b
) << 24;
461 #ifdef PIPE_ARCH_BIG_ENDIAN
462 value
= util_bswap32(value
);
468 dst_row
+= dst_stride
/sizeof(*dst_row
);
469 src_row
+= src_stride
/sizeof(*src_row
);
475 util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
476 const uint8_t *src_row
, unsigned src_stride
,
477 unsigned width
, unsigned height
)
481 for (y
= 0; y
< height
; y
+= 1) {
482 const uint8_t *src
= src_row
;
483 uint32_t *dst
= (uint32_t *)dst_row
;
484 uint32_t r
, g0
, g1
, b
;
487 for (x
= 0; x
+ 1 < width
; x
+= 2) {
488 r
= (src
[0] + src
[4] + 1) >> 1;
491 b
= (src
[2] + src
[6] + 1) >> 1;
498 #ifdef PIPE_ARCH_BIG_ENDIAN
499 value
= util_bswap32(value
);
518 #ifdef PIPE_ARCH_BIG_ENDIAN
519 value
= util_bswap32(value
);
525 dst_row
+= dst_stride
/sizeof(*dst_row
);
526 src_row
+= src_stride
/sizeof(*src_row
);
532 util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst
, const uint8_t *src
,
533 unsigned i
, unsigned j
)
538 dst
[0] = ubyte_to_float(src
[1]); /* r */
539 dst
[1] = ubyte_to_float(src
[0 + 2*i
]); /* g */
540 dst
[2] = ubyte_to_float(src
[3]); /* b */
541 dst
[3] = 1.0f
; /* a */
546 util_format_uyvy_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
547 const uint8_t *src_row
, unsigned src_stride
,
548 unsigned width
, unsigned height
)
552 for (y
= 0; y
< height
; y
+= 1) {
553 float *dst
= dst_row
;
554 const uint32_t *src
= (const uint32_t *)src_row
;
556 uint8_t y0
, y1
, u
, v
;
558 for (x
= 0; x
+ 1 < width
; x
+= 2) {
561 #ifdef PIPE_ARCH_BIG_ENDIAN
562 value
= util_bswap32(value
);
565 u
= (value
>> 0) & 0xff;
566 y0
= (value
>> 8) & 0xff;
567 v
= (value
>> 16) & 0xff;
568 y1
= (value
>> 24) & 0xff;
570 util_format_yuv_to_rgb_float(y0
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
571 dst
[3] = 1.0f
; /* a */
574 util_format_yuv_to_rgb_float(y1
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
575 dst
[3] = 1.0f
; /* a */
582 #ifdef PIPE_ARCH_BIG_ENDIAN
583 value
= util_bswap32(value
);
586 u
= (value
>> 0) & 0xff;
587 y0
= (value
>> 8) & 0xff;
588 v
= (value
>> 16) & 0xff;
589 y1
= (value
>> 24) & 0xff;
591 util_format_yuv_to_rgb_float(y0
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
592 dst
[3] = 1.0f
; /* a */
595 src_row
+= src_stride
/sizeof(*src_row
);
596 dst_row
+= dst_stride
/sizeof(*dst_row
);
602 util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
603 const uint8_t *src_row
, unsigned src_stride
,
604 unsigned width
, unsigned height
)
608 for (y
= 0; y
< height
; y
+= 1) {
609 uint8_t *dst
= dst_row
;
610 const uint32_t *src
= (const uint32_t *)src_row
;
612 uint8_t y0
, y1
, u
, v
;
614 for (x
= 0; x
+ 1 < width
; x
+= 2) {
617 #ifdef PIPE_ARCH_BIG_ENDIAN
618 value
= util_bswap32(value
);
621 u
= (value
>> 0) & 0xff;
622 y0
= (value
>> 8) & 0xff;
623 v
= (value
>> 16) & 0xff;
624 y1
= (value
>> 24) & 0xff;
626 util_format_yuv_to_rgb_8unorm(y0
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
627 dst
[3] = 0xff; /* a */
630 util_format_yuv_to_rgb_8unorm(y1
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
631 dst
[3] = 0xff; /* a */
638 #ifdef PIPE_ARCH_BIG_ENDIAN
639 value
= util_bswap32(value
);
642 u
= (value
>> 0) & 0xff;
643 y0
= (value
>> 8) & 0xff;
644 v
= (value
>> 16) & 0xff;
645 y1
= (value
>> 24) & 0xff;
647 util_format_yuv_to_rgb_8unorm(y0
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
648 dst
[3] = 0xff; /* a */
651 src_row
+= src_stride
/sizeof(*src_row
);
652 dst_row
+= dst_stride
/sizeof(*dst_row
);
658 util_format_uyvy_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
659 const float *src_row
, unsigned src_stride
,
660 unsigned width
, unsigned height
)
664 for (y
= 0; y
< height
; y
+= 1) {
665 const float *src
= src_row
;
666 uint32_t *dst
= (uint32_t *)dst_row
;
667 uint8_t y0
, y1
, u
, v
;
670 for (x
= 0; x
+ 1 < width
; x
+= 2) {
671 uint8_t y0
, y1
, u0
, u1
, v0
, v1
, u
, v
;
673 util_format_rgb_float_to_yuv(src
[0], src
[1], src
[2],
675 util_format_rgb_float_to_yuv(src
[4], src
[5], src
[6],
678 u
= (u0
+ u1
+ 1) >> 1;
679 v
= (v0
+ v1
+ 1) >> 1;
686 #ifdef PIPE_ARCH_BIG_ENDIAN
687 value
= util_bswap32(value
);
696 util_format_rgb_float_to_yuv(src
[0], src
[1], src
[2],
705 #ifdef PIPE_ARCH_BIG_ENDIAN
706 value
= util_bswap32(value
);
712 dst_row
+= dst_stride
/sizeof(*dst_row
);
713 src_row
+= src_stride
/sizeof(*src_row
);
719 util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
720 const uint8_t *src_row
, unsigned src_stride
,
721 unsigned width
, unsigned height
)
725 for (y
= 0; y
< height
; y
+= 1) {
726 const uint8_t *src
= src_row
;
727 uint32_t *dst
= (uint32_t *)dst_row
;
728 uint8_t y0
, y1
, u
, v
;
731 for (x
= 0; x
+ 1 < width
; x
+= 2) {
732 uint8_t y0
, y1
, u0
, u1
, v0
, v1
, u
, v
;
734 util_format_rgb_8unorm_to_yuv(src
[0], src
[1], src
[2],
736 util_format_rgb_8unorm_to_yuv(src
[4], src
[5], src
[6],
739 u
= (u0
+ u1
+ 1) >> 1;
740 v
= (v0
+ v1
+ 1) >> 1;
747 #ifdef PIPE_ARCH_BIG_ENDIAN
748 value
= util_bswap32(value
);
757 util_format_rgb_8unorm_to_yuv(src
[0], src
[1], src
[2],
766 #ifdef PIPE_ARCH_BIG_ENDIAN
767 value
= util_bswap32(value
);
773 dst_row
+= dst_stride
/sizeof(*dst_row
);
774 src_row
+= src_stride
/sizeof(*src_row
);
780 util_format_uyvy_fetch_rgba_float(float *dst
, const uint8_t *src
,
781 unsigned i
, unsigned j
)
792 util_format_yuv_to_rgb_float(y
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
799 util_format_yuyv_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
800 const uint8_t *src_row
, unsigned src_stride
,
801 unsigned width
, unsigned height
)
805 for (y
= 0; y
< height
; y
+= 1) {
806 float *dst
= dst_row
;
807 const uint32_t *src
= (const uint32_t *)src_row
;
809 uint8_t y0
, y1
, u
, v
;
811 for (x
= 0; x
+ 1 < width
; x
+= 2) {
814 #ifdef PIPE_ARCH_BIG_ENDIAN
815 value
= util_bswap32(value
);
818 y0
= (value
>> 0) & 0xff;
819 u
= (value
>> 8) & 0xff;
820 y1
= (value
>> 16) & 0xff;
821 v
= (value
>> 24) & 0xff;
823 util_format_yuv_to_rgb_float(y0
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
824 dst
[3] = 1.0f
; /* a */
827 util_format_yuv_to_rgb_float(y1
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
828 dst
[3] = 1.0f
; /* a */
835 #ifdef PIPE_ARCH_BIG_ENDIAN
836 value
= util_bswap32(value
);
839 y0
= (value
>> 0) & 0xff;
840 u
= (value
>> 8) & 0xff;
841 y1
= (value
>> 16) & 0xff;
842 v
= (value
>> 24) & 0xff;
844 util_format_yuv_to_rgb_float(y0
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
845 dst
[3] = 1.0f
; /* a */
848 src_row
+= src_stride
/sizeof(*src_row
);
849 dst_row
+= dst_stride
/sizeof(*dst_row
);
855 util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
856 const uint8_t *src_row
, unsigned src_stride
,
857 unsigned width
, unsigned height
)
861 for (y
= 0; y
< height
; y
+= 1) {
862 uint8_t *dst
= dst_row
;
863 const uint32_t *src
= (const uint32_t *)src_row
;
865 uint8_t y0
, y1
, u
, v
;
867 for (x
= 0; x
+ 1 < width
; x
+= 2) {
870 #ifdef PIPE_ARCH_BIG_ENDIAN
871 value
= util_bswap32(value
);
874 y0
= (value
>> 0) & 0xff;
875 u
= (value
>> 8) & 0xff;
876 y1
= (value
>> 16) & 0xff;
877 v
= (value
>> 24) & 0xff;
879 util_format_yuv_to_rgb_8unorm(y0
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
880 dst
[3] = 0xff; /* a */
883 util_format_yuv_to_rgb_8unorm(y1
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
884 dst
[3] = 0xff; /* a */
891 #ifdef PIPE_ARCH_BIG_ENDIAN
892 value
= util_bswap32(value
);
895 y0
= (value
>> 0) & 0xff;
896 u
= (value
>> 8) & 0xff;
897 y1
= (value
>> 16) & 0xff;
898 v
= (value
>> 24) & 0xff;
900 util_format_yuv_to_rgb_8unorm(y0
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
901 dst
[3] = 0xff; /* a */
904 src_row
+= src_stride
/sizeof(*src_row
);
905 dst_row
+= dst_stride
/sizeof(*dst_row
);
911 util_format_yuyv_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
912 const float *src_row
, unsigned src_stride
,
913 unsigned width
, unsigned height
)
917 for (y
= 0; y
< height
; y
+= 1) {
918 const float *src
= src_row
;
919 uint32_t *dst
= (uint32_t *)dst_row
;
920 uint8_t y0
, y1
, u
, v
;
923 for (x
= 0; x
+ 1 < width
; x
+= 2) {
924 uint8_t y0
, y1
, u0
, u1
, v0
, v1
, u
, v
;
926 util_format_rgb_float_to_yuv(src
[0], src
[1], src
[2],
928 util_format_rgb_float_to_yuv(src
[4], src
[5], src
[6],
931 u
= (u0
+ u1
+ 1) >> 1;
932 v
= (v0
+ v1
+ 1) >> 1;
939 #ifdef PIPE_ARCH_BIG_ENDIAN
940 value
= util_bswap32(value
);
949 util_format_rgb_float_to_yuv(src
[0], src
[1], src
[2],
958 #ifdef PIPE_ARCH_BIG_ENDIAN
959 value
= util_bswap32(value
);
965 dst_row
+= dst_stride
/sizeof(*dst_row
);
966 src_row
+= src_stride
/sizeof(*src_row
);
972 util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
973 const uint8_t *src_row
, unsigned src_stride
,
974 unsigned width
, unsigned height
)
978 for (y
= 0; y
< height
; y
+= 1) {
979 const uint8_t *src
= src_row
;
980 uint32_t *dst
= (uint32_t *)dst_row
;
981 uint8_t y0
, y1
, u
, v
;
984 for (x
= 0; x
+ 1 < width
; x
+= 2) {
985 uint8_t y0
, y1
, u0
, u1
, v0
, v1
, u
, v
;
987 util_format_rgb_8unorm_to_yuv(src
[0], src
[1], src
[2],
989 util_format_rgb_8unorm_to_yuv(src
[4], src
[5], src
[6],
992 u
= (u0
+ u1
+ 1) >> 1;
993 v
= (v0
+ v1
+ 1) >> 1;
1000 #ifdef PIPE_ARCH_BIG_ENDIAN
1001 value
= util_bswap32(value
);
1010 util_format_rgb_8unorm_to_yuv(src
[0], src
[1], src
[2],
1019 #ifdef PIPE_ARCH_BIG_ENDIAN
1020 value
= util_bswap32(value
);
1026 dst_row
+= dst_stride
/sizeof(*dst_row
);
1027 src_row
+= src_stride
/sizeof(*src_row
);
1033 util_format_yuyv_fetch_rgba_float(float *dst
, const uint8_t *src
,
1034 unsigned i
, unsigned j
)
1045 util_format_yuv_to_rgb_float(y
, u
, v
, &dst
[0], &dst
[1], &dst
[2]);
1050 /* XXX: Stubbed for now */
1052 util_format_yv12_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1053 const uint8_t *src_row
, unsigned src_stride
,
1054 unsigned width
, unsigned height
) {}
1056 util_format_yv12_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1057 const uint8_t *src_row
, unsigned src_stride
,
1058 unsigned width
, unsigned height
) {}
1060 util_format_yv12_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
1061 const uint8_t *src_row
, unsigned src_stride
,
1062 unsigned width
, unsigned height
) {}
1064 util_format_yv12_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
1065 const float *src_row
, unsigned src_stride
,
1066 unsigned width
, unsigned height
) {}
1068 util_format_yv12_fetch_rgba_float(float *dst
, const uint8_t *src
,
1069 unsigned i
, unsigned j
) {}
1071 util_format_yv16_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1072 const uint8_t *src_row
, unsigned src_stride
,
1073 unsigned width
, unsigned height
) {}
1075 util_format_yv16_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1076 const uint8_t *src_row
, unsigned src_stride
,
1077 unsigned width
, unsigned height
) {}
1079 util_format_yv16_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
1080 const uint8_t *src_row
, unsigned src_stride
,
1081 unsigned width
, unsigned height
) {}
1083 util_format_yv16_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
1084 const float *src_row
, unsigned src_stride
,
1085 unsigned width
, unsigned height
) {}
1087 util_format_yv16_fetch_rgba_float(float *dst
, const uint8_t *src
,
1088 unsigned i
, unsigned j
) {}
1090 util_format_iyuv_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1091 const uint8_t *src_row
, unsigned src_stride
,
1092 unsigned width
, unsigned height
) {}
1094 util_format_iyuv_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1095 const uint8_t *src_row
, unsigned src_stride
,
1096 unsigned width
, unsigned height
) {}
1098 util_format_iyuv_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
1099 const uint8_t *src_row
, unsigned src_stride
,
1100 unsigned width
, unsigned height
) {}
1102 util_format_iyuv_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
1103 const float *src_row
, unsigned src_stride
,
1104 unsigned width
, unsigned height
) {}
1106 util_format_iyuv_fetch_rgba_float(float *dst
, const uint8_t *src
,
1107 unsigned i
, unsigned j
) {}
1109 util_format_nv12_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1110 const uint8_t *src_row
, unsigned src_stride
,
1111 unsigned width
, unsigned height
) {}
1113 util_format_nv12_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1114 const uint8_t *src_row
, unsigned src_stride
,
1115 unsigned width
, unsigned height
) {}
1117 util_format_nv12_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
1118 const uint8_t *src_row
, unsigned src_stride
,
1119 unsigned width
, unsigned height
) {}
1121 util_format_nv12_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
1122 const float *src_row
, unsigned src_stride
,
1123 unsigned width
, unsigned height
) {}
1125 util_format_nv12_fetch_rgba_float(float *dst
, const uint8_t *src
,
1126 unsigned i
, unsigned j
) {}
1128 util_format_nv21_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1129 const uint8_t *src_row
, unsigned src_stride
,
1130 unsigned width
, unsigned height
) {}
1132 util_format_nv21_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1133 const uint8_t *src_row
, unsigned src_stride
,
1134 unsigned width
, unsigned height
) {}
1136 util_format_nv21_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
1137 const uint8_t *src_row
, unsigned src_stride
,
1138 unsigned width
, unsigned height
) {}
1140 util_format_nv21_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
1141 const float *src_row
, unsigned src_stride
,
1142 unsigned width
, unsigned height
) {}
1144 util_format_nv21_fetch_rgba_float(float *dst
, const uint8_t *src
,
1145 unsigned i
, unsigned j
) {}
1148 util_format_r8g8_r8b8_unorm_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
1149 const uint8_t *src_row
, unsigned src_stride
,
1150 unsigned width
, unsigned height
) {}
1153 util_format_r8g8_r8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1154 const uint8_t *src_row
, unsigned src_stride
,
1155 unsigned width
, unsigned height
) {}
1158 util_format_r8g8_r8b8_unorm_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
1159 const float *src_row
, unsigned src_stride
,
1160 unsigned width
, unsigned height
) {}
1163 util_format_r8g8_r8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1164 const uint8_t *src_row
, unsigned src_stride
,
1165 unsigned width
, unsigned height
) {}
1168 util_format_r8g8_r8b8_unorm_fetch_rgba_float(float *dst
, const uint8_t *src
,
1169 unsigned i
, unsigned j
) {}
1172 util_format_g8r8_b8r8_unorm_unpack_rgba_float(float *dst_row
, unsigned dst_stride
,
1173 const uint8_t *src_row
, unsigned src_stride
,
1174 unsigned width
, unsigned height
) {}
1177 util_format_g8r8_b8r8_unorm_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1178 const uint8_t *src_row
, unsigned src_stride
,
1179 unsigned width
, unsigned height
) {}
1182 util_format_g8r8_b8r8_unorm_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
,
1183 const float *src_row
, unsigned src_stride
,
1184 unsigned width
, unsigned height
) {}
1187 util_format_g8r8_b8r8_unorm_pack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
,
1188 const uint8_t *src_row
, unsigned src_stride
,
1189 unsigned width
, unsigned height
) {}
1192 util_format_g8r8_b8r8_unorm_fetch_rgba_float(float *dst
, const uint8_t *src
,
1193 unsigned i
, unsigned j
) {}