annotate postproc/yuv2rgb_template.c @ 3024:7a5021d0a2de

Small two pass mencoder helper script in perl.
author atmos4
date Tue, 20 Nov 2001 13:02:56 +0000
parents 2cbecedb2616
children 86910f54c391
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
1
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
2 /*
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
3 * yuv2rgb_mmx.c, Software YUV to RGB coverter with Intel MMX "technology"
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
4 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
5 * Copyright (C) 2000, Silicon Integrated System Corp.
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
6 * All Rights Reserved.
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
7 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
8 * Author: Olie Lho <ollie@sis.com.tw>
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
9 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
10 * This file is part of mpeg2dec, a free MPEG-2 video decoder
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
11 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
12 * mpeg2dec is free software; you can redistribute it and/or modify
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
14 * the Free Software Foundation; either version 2, or (at your option)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
15 * any later version.
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
16 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
17 * mpeg2dec is distributed in the hope that it will be useful,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
20 * GNU General Public License for more details.
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
21 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
23 * along with GNU Make; see the file COPYING. If not, write to
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
24 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
25 *
2749
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
26 * 15,24 bpp and dithering from Michael Niedermayer (michaelni@gmx.at)
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
27 */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
28
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
29 #include <stdio.h>
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
30 #include <stdlib.h>
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
31
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
32 #include "../config.h"
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
33
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
34 //#include "libmpeg2/mpeg2.h"
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
35 //#include "libmpeg2/mpeg2_internal.h"
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
36 #include <inttypes.h>
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
37
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
38 #include "rgb2rgb.h"
2736
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
39 #include "../mmx_defs.h"
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
40
2749
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
41 #define DITHER1XBPP
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
42
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
43 /* hope these constant values are cache line aligned */
2737
d0f34e15aa5f vars are aligned by 8 now (even faster, yes they where not aligned correctly)
michael
parents: 2736
diff changeset
44 uint64_t __attribute__((aligned(8))) mmx_80w = 0x0080008000800080;
d0f34e15aa5f vars are aligned by 8 now (even faster, yes they where not aligned correctly)
michael
parents: 2736
diff changeset
45 uint64_t __attribute__((aligned(8))) mmx_10w = 0x1010101010101010;
d0f34e15aa5f vars are aligned by 8 now (even faster, yes they where not aligned correctly)
michael
parents: 2736
diff changeset
46 uint64_t __attribute__((aligned(8))) mmx_00ffw = 0x00ff00ff00ff00ff;
d0f34e15aa5f vars are aligned by 8 now (even faster, yes they where not aligned correctly)
michael
parents: 2736
diff changeset
47 uint64_t __attribute__((aligned(8))) mmx_Y_coeff = 0x253f253f253f253f;
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
48
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
49 /* hope these constant values are cache line aligned */
2737
d0f34e15aa5f vars are aligned by 8 now (even faster, yes they where not aligned correctly)
michael
parents: 2736
diff changeset
50 uint64_t __attribute__((aligned(8))) mmx_U_green = 0xf37df37df37df37d;
d0f34e15aa5f vars are aligned by 8 now (even faster, yes they where not aligned correctly)
michael
parents: 2736
diff changeset
51 uint64_t __attribute__((aligned(8))) mmx_U_blue = 0x4093409340934093;
d0f34e15aa5f vars are aligned by 8 now (even faster, yes they where not aligned correctly)
michael
parents: 2736
diff changeset
52 uint64_t __attribute__((aligned(8))) mmx_V_red = 0x3312331233123312;
d0f34e15aa5f vars are aligned by 8 now (even faster, yes they where not aligned correctly)
michael
parents: 2736
diff changeset
53 uint64_t __attribute__((aligned(8))) mmx_V_green = 0xe5fce5fce5fce5fc;
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
54
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
55 /* hope these constant values are cache line aligned */
2737
d0f34e15aa5f vars are aligned by 8 now (even faster, yes they where not aligned correctly)
michael
parents: 2736
diff changeset
56 uint64_t __attribute__((aligned(8))) mmx_redmask = 0xf8f8f8f8f8f8f8f8;
d0f34e15aa5f vars are aligned by 8 now (even faster, yes they where not aligned correctly)
michael
parents: 2736
diff changeset
57 uint64_t __attribute__((aligned(8))) mmx_grnmask = 0xfcfcfcfcfcfcfcfc;
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
58
2739
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
59 uint64_t __attribute__((aligned(8))) M24A= 0x00FF0000FF0000FFLL;
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
60 uint64_t __attribute__((aligned(8))) M24B= 0xFF0000FF0000FF00LL;
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
61 uint64_t __attribute__((aligned(8))) M24C= 0x0000FF0000FF0000LL;
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
62
2749
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
63 // the volatile is required because gcc otherwise optimizes some writes away not knowing that these
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
64 // are read in the asm block
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
65 volatile uint64_t __attribute__((aligned(8))) b5Dither;
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
66 volatile uint64_t __attribute__((aligned(8))) g5Dither;
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
67 volatile uint64_t __attribute__((aligned(8))) g6Dither;
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
68 volatile uint64_t __attribute__((aligned(8))) r5Dither;
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
69
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
70 uint64_t __attribute__((aligned(8))) dither4[2]={
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
71 0x0103010301030103LL,
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
72 0x0200020002000200LL,};
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
73
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
74 uint64_t __attribute__((aligned(8))) dither8[2]={
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
75 0x0602060206020602LL,
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
76 0x0004000400040004LL,};
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
77
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
78
2739
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
79
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
80 #define YUV2RGB \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
81 /* Do the multiply part of the conversion for even and odd pixels,
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
82 register usage:
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
83 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
84 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels,
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
85 mm6 -> Y even, mm7 -> Y odd */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
86 /* convert the chroma part */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
87 "punpcklbw %%mm4, %%mm0;" /* scatter 4 Cb 00 u3 00 u2 00 u1 00 u0 */ \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
88 "punpcklbw %%mm4, %%mm1;" /* scatter 4 Cr 00 v3 00 v2 00 v1 00 v0 */ \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
89 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
90 "psubsw mmx_80w, %%mm0;" /* Cb -= 128 */ \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
91 "psubsw mmx_80w, %%mm1;" /* Cr -= 128 */ \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
92 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
93 "psllw $3, %%mm0;" /* Promote precision */ \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
94 "psllw $3, %%mm1;" /* Promote precision */ \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
95 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
96 "movq %%mm0, %%mm2;" /* Copy 4 Cb 00 u3 00 u2 00 u1 00 u0 */ \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
97 "movq %%mm1, %%mm3;" /* Copy 4 Cr 00 v3 00 v2 00 v1 00 v0 */ \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
98 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
99 "pmulhw mmx_U_green, %%mm2;" /* Mul Cb with green coeff -> Cb green */ \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
100 "pmulhw mmx_V_green, %%mm3;" /* Mul Cr with green coeff -> Cr green */ \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
101 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
102 "pmulhw mmx_U_blue, %%mm0;" /* Mul Cb -> Cblue 00 b3 00 b2 00 b1 00 b0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
103 "pmulhw mmx_V_red, %%mm1;" /* Mul Cr -> Cred 00 r3 00 r2 00 r1 00 r0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
104 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
105 "paddsw %%mm3, %%mm2;" /* Cb green + Cr green -> Cgreen */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
106 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
107 /* convert the luma part */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
108 "psubusb mmx_10w, %%mm6;" /* Y -= 16 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
109 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
110 "movq %%mm6, %%mm7;" /* Copy 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
111 "pand mmx_00ffw, %%mm6;" /* get Y even 00 Y6 00 Y4 00 Y2 00 Y0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
112 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
113 "psrlw $8, %%mm7;" /* get Y odd 00 Y7 00 Y5 00 Y3 00 Y1 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
114 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
115 "psllw $3, %%mm6;" /* Promote precision */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
116 "psllw $3, %%mm7;" /* Promote precision */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
117 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
118 "pmulhw mmx_Y_coeff, %%mm6;" /* Mul 4 Y even 00 y6 00 y4 00 y2 00 y0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
119 "pmulhw mmx_Y_coeff, %%mm7;" /* Mul 4 Y odd 00 y7 00 y5 00 y3 00 y1 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
120 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
121 /* Do the addition part of the conversion for even and odd pixels,
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
122 register usage:
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
123 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
124 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels,
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
125 mm6 -> Y even, mm7 -> Y odd */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
126 "movq %%mm0, %%mm3;" /* Copy Cblue */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
127 "movq %%mm1, %%mm4;" /* Copy Cred */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
128 "movq %%mm2, %%mm5;" /* Copy Cgreen */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
129 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
130 "paddsw %%mm6, %%mm0;" /* Y even + Cblue 00 B6 00 B4 00 B2 00 B0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
131 "paddsw %%mm7, %%mm3;" /* Y odd + Cblue 00 B7 00 B5 00 B3 00 B1 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
132 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
133 "paddsw %%mm6, %%mm1;" /* Y even + Cred 00 R6 00 R4 00 R2 00 R0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
134 "paddsw %%mm7, %%mm4;" /* Y odd + Cred 00 R7 00 R5 00 R3 00 R1 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
135 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
136 "paddsw %%mm6, %%mm2;" /* Y even + Cgreen 00 G6 00 G4 00 G2 00 G0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
137 "paddsw %%mm7, %%mm5;" /* Y odd + Cgreen 00 G7 00 G5 00 G3 00 G1 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
138 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
139 /* Limit RGB even to 0..255 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
140 "packuswb %%mm0, %%mm0;" /* B6 B4 B2 B0 B6 B4 B2 B0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
141 "packuswb %%mm1, %%mm1;" /* R6 R4 R2 R0 R6 R4 R2 R0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
142 "packuswb %%mm2, %%mm2;" /* G6 G4 G2 G0 G6 G4 G2 G0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
143 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
144 /* Limit RGB odd to 0..255 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
145 "packuswb %%mm3, %%mm3;" /* B7 B5 B3 B1 B7 B5 B3 B1 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
146 "packuswb %%mm4, %%mm4;" /* R7 R5 R3 R1 R7 R5 R3 R1 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
147 "packuswb %%mm5, %%mm5;" /* G7 G5 G3 G1 G7 G5 G3 G1 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
148 \
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
149 /* Interleave RGB even and odd */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
150 "punpcklbw %%mm3, %%mm0;" /* B7 B6 B5 B4 B3 B2 B1 B0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
151 "punpcklbw %%mm4, %%mm1;" /* R7 R6 R5 R4 R3 R2 R1 R0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
152 "punpcklbw %%mm5, %%mm2;" /* G7 G6 G5 G4 G3 G2 G1 G0 */\
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
153
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
154
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
155 static void yuv420_rgb16_mmx (uint8_t * image, uint8_t * py,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
156 uint8_t * pu, uint8_t * pv,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
157 int h_size, int v_size,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
158 int rgb_stride, int y_stride, int uv_stride)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
159 {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
160 int even = 1;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
161 int x, y;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
162
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
163 __asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
164
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
165 for (y = v_size; --y >= 0; ) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
166 uint8_t *_image = image;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
167 uint8_t *_py = py;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
168 uint8_t *_pu = pu;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
169 uint8_t *_pv = pv;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
170
2749
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
171 b5Dither= dither8[y&1];
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
172 g6Dither= dither4[y&1];
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
173 g5Dither= dither8[y&1];
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
174 r5Dither= dither8[(y+1)&1];
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
175
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
176 /* load data for start of next scan line */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
177 __asm__ __volatile__ (
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
178 "movd (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
179 "movd (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
180 "movq (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
181
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
182 : : "r" (_py), "r" (_pu), "r" (_pv));
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
183
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
184 for (x = h_size >> 3; --x >= 0; ) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
185 /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
186 pixels in each iteration */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
187
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
188 __asm__ __volatile__ (
2736
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
189 /* no speed diference on my p3@500 with prefetch,
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
190 * if it is faster for anyone with -benchmark then tell me
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
191 PREFETCH" 64(%0) \n\t"
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
192 PREFETCH" 64(%1) \n\t"
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
193 PREFETCH" 64(%2) \n\t"
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
194 */
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
195 YUV2RGB
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
196
2749
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
197 #ifdef DITHER1XBPP
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
198 "paddusb b5Dither, %%mm0;"
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
199 "paddusb g6Dither, %%mm2;"
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
200 "paddusb r5Dither, %%mm1;"
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
201 #endif
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
202 /* mask unneeded bits off */
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
203 "pand mmx_redmask, %%mm0;" /* b7b6b5b4 b3_0_0_0 b7b6b5b4 b3_0_0_0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
204 "pand mmx_grnmask, %%mm2;" /* g7g6g5g4 g3g2_0_0 g7g6g5g4 g3g2_0_0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
205 "pand mmx_redmask, %%mm1;" /* r7r6r5r4 r3_0_0_0 r7r6r5r4 r3_0_0_0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
206
2736
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
207 "psrlw $3,%%mm0;" /* 0_0_0_b7 b6b5b4b3 0_0_0_b7 b6b5b4b3 */
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
208 "pxor %%mm4, %%mm4;" /* zero mm4 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
209
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
210 "movq %%mm0, %%mm5;" /* Copy B7-B0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
211 "movq %%mm2, %%mm7;" /* Copy G7-G0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
212
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
213 /* convert rgb24 plane to rgb16 pack for pixel 0-3 */
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
214 "punpcklbw %%mm4, %%mm2;" /* 0_0_0_0 0_0_0_0 g7g6g5g4 g3g2_0_0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
215 "punpcklbw %%mm1, %%mm0;" /* r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
216
2736
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
217 "psllw $3, %%mm2;" /* 0_0_0_0 0_g7g6g5 g4g3g2_0 0_0_0_0 */
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
218 "por %%mm2, %%mm0;" /* r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
219
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
220 "movq 8 (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
221 MOVNTQ " %%mm0, (%3);" /* store pixel 0-3 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
222
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
223 /* convert rgb24 plane to rgb16 pack for pixel 0-3 */
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
224 "punpckhbw %%mm4, %%mm7;" /* 0_0_0_0 0_0_0_0 g7g6g5g4 g3g2_0_0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
225 "punpckhbw %%mm1, %%mm5;" /* r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
226
2736
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
227 "psllw $3, %%mm7;" /* 0_0_0_0 0_g7g6g5 g4g3g2_0 0_0_0_0 */
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
228 "movd 4 (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
229
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
230 "por %%mm7, %%mm5;" /* r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
231 "movd 4 (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
232
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
233 MOVNTQ " %%mm5, 8 (%3);" /* store pixel 4-7 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
234 : : "r" (_py), "r" (_pu), "r" (_pv), "r" (_image));
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
235
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
236 _py += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
237 _pu += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
238 _pv += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
239 _image += 16;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
240 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
241
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
242 if (!even) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
243 pu += uv_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
244 pv += uv_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
245 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
246
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
247 py += y_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
248 image += rgb_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
249
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
250 even = (!even);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
251 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
252
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
253 __asm__ __volatile__ (EMMS);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
254 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
255
2735
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
256 static void yuv420_rgb15_mmx (uint8_t * image, uint8_t * py,
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
257 uint8_t * pu, uint8_t * pv,
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
258 int h_size, int v_size,
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
259 int rgb_stride, int y_stride, int uv_stride)
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
260 {
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
261 int even = 1;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
262 int x, y;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
263
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
264 __asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
265
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
266 for (y = v_size; --y >= 0; ) {
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
267 uint8_t *_image = image;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
268 uint8_t *_py = py;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
269 uint8_t *_pu = pu;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
270 uint8_t *_pv = pv;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
271
2749
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
272 b5Dither= dither8[y&1];
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
273 g6Dither= dither4[y&1];
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
274 g5Dither= dither8[y&1];
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
275 r5Dither= dither8[(y+1)&1];
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
276
2735
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
277 /* load data for start of next scan line */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
278 __asm__ __volatile__ (
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
279 "movd (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
280 "movd (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
281 "movq (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
282
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
283 : : "r" (_py), "r" (_pu), "r" (_pv));
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
284
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
285 for (x = h_size >> 3; --x >= 0; ) {
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
286 /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
287 pixels in each iteration */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
288
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
289 __asm__ __volatile__ (
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
290 YUV2RGB
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
291
2749
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
292 #ifdef DITHER1XBPP
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
293 "paddusb b5Dither, %%mm0 \n\t"
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
294 "paddusb g5Dither, %%mm2 \n\t"
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
295 "paddusb r5Dither, %%mm1 \n\t"
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
296 #endif
2cbecedb2616 15/16 bpp dithering
michael
parents: 2739
diff changeset
297
2735
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
298 /* mask unneeded bits off */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
299 "pand mmx_redmask, %%mm0;" /* b7b6b5b4 b3_0_0_0 b7b6b5b4 b3_0_0_0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
300 "pand mmx_redmask, %%mm2;" /* g7g6g5g4 g3_0_0_0 g7g6g5g4 g3_0_0_0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
301 "pand mmx_redmask, %%mm1;" /* r7r6r5r4 r3_0_0_0 r7r6r5r4 r3_0_0_0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
302
2736
aeef41a19f4b 16bpp is 10% faster
michael
parents: 2735
diff changeset
303 "psrlw $3,%%mm0;" /* 0_0_0_b7 b6b5b4b3 0_0_0_b7 b6b5b4b3 */
2735
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
304 "psrlw $1,%%mm1;" /* 0_r7r6r5 r4r3_0_0 0_r7r6r5 r4r3_0_0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
305 "pxor %%mm4, %%mm4;" /* zero mm4 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
306
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
307 "movq %%mm0, %%mm5;" /* Copy B7-B0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
308 "movq %%mm2, %%mm7;" /* Copy G7-G0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
309
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
310 /* convert rgb24 plane to rgb16 pack for pixel 0-3 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
311 "punpcklbw %%mm4, %%mm2;" /* 0_0_0_0 0_0_0_0 g7g6g5g4 g3_0_0_0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
312 "punpcklbw %%mm1, %%mm0;" /* r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
313
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
314 "psllw $2, %%mm2;" /* 0_0_0_0 0_0_g7g6 g5g4g3_0 0_0_0_0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
315 "por %%mm2, %%mm0;" /* 0_r7r6r5 r4r3g7g6 g5g4g3b7 b6b5b4b3 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
316
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
317 "movq 8 (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
318 MOVNTQ " %%mm0, (%3);" /* store pixel 0-3 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
319
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
320 /* convert rgb24 plane to rgb16 pack for pixel 0-3 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
321 "punpckhbw %%mm4, %%mm7;" /* 0_0_0_0 0_0_0_0 0_g7g6g5 g4g3_0_0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
322 "punpckhbw %%mm1, %%mm5;" /* r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
323
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
324 "psllw $2, %%mm7;" /* 0_0_0_0 0_0_g7g6 g5g4g3_0 0_0_0_0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
325 "movd 4 (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
326
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
327 "por %%mm7, %%mm5;" /* 0_r7r6r5 r4r3g7g6 g5g4g3b7 b6b5b4b3 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
328 "movd 4 (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
329
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
330 MOVNTQ " %%mm5, 8 (%3);" /* store pixel 4-7 */
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
331 : : "r" (_py), "r" (_pu), "r" (_pv), "r" (_image));
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
332
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
333 _py += 8;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
334 _pu += 4;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
335 _pv += 4;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
336 _image += 16;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
337 }
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
338
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
339 if (!even) {
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
340 pu += uv_stride;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
341 pv += uv_stride;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
342 }
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
343
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
344 py += y_stride;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
345 image += rgb_stride;
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
346
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
347 even = (!even);
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
348 }
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
349
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
350 __asm__ __volatile__ (EMMS);
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
351 }
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
352
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
353 static void yuv420_rgb24_mmx (uint8_t * image, uint8_t * py,
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
354 uint8_t * pu, uint8_t * pv,
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
355 int h_size, int v_size,
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
356 int rgb_stride, int y_stride, int uv_stride)
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
357 {
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
358 int even = 1;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
359 int x, y;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
360
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
361 __asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
362
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
363 for (y = v_size; --y >= 0; ) {
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
364 uint8_t *_image = image;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
365 uint8_t *_py = py;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
366 uint8_t *_pu = pu;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
367 uint8_t *_pv = pv;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
368
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
369 /* load data for start of next scan line */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
370 __asm__ __volatile__ (
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
371 "movd (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
372 "movd (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
373 "movq (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
374
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
375 : : "r" (_py), "r" (_pu), "r" (_pv));
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
376
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
377 for (x = h_size >> 3; --x >= 0; ) {
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
378 /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
379 pixels in each iteration */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
380
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
381 __asm__ __volatile__ (
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
382 YUV2RGB
2739
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
383 /* mm0=B, %%mm2=G, %%mm1=R */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
384 #ifdef HAVE_MMX2
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
385 "movq M24A, %%mm4 \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
386 "movq M24C, %%mm7 \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
387 "pshufw $0x50, %%mm0, %%mm5 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
388 "pshufw $0x50, %%mm2, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
389 "pshufw $0x00, %%mm1, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
390
2739
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
391 "pand %%mm4, %%mm5 \n\t" /* B2 B1 B0 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
392 "pand %%mm4, %%mm3 \n\t" /* G2 G1 G0 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
393 "pand %%mm7, %%mm6 \n\t" /* R1 R0 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
394
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
395 "psllq $8, %%mm3 \n\t" /* G2 G1 G0 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
396 "por %%mm5, %%mm6 \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
397 "por %%mm3, %%mm6 \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
398 MOVNTQ" %%mm6, (%3) \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
399
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
400 "psrlq $8, %%mm2 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
401 "pshufw $0xA5, %%mm0, %%mm5 \n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
402 "pshufw $0x55, %%mm2, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
403 "pshufw $0xA5, %%mm1, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
404
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
405 "pand M24B, %%mm5 \n\t" /* B5 B4 B3 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
406 "pand %%mm7, %%mm3 \n\t" /* G4 G3 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
407 "pand %%mm4, %%mm6 \n\t" /* R4 R3 R2 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
408
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
409 "por %%mm5, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
410 "por %%mm3, %%mm6 \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
411 MOVNTQ" %%mm6, 8(%3) \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
412
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
413 "pshufw $0xFF, %%mm0, %%mm5 \n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
414 "pshufw $0xFA, %%mm2, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
415 "pshufw $0xFA, %%mm1, %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
416 "movd 4 (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
417
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
418 "pand %%mm7, %%mm5 \n\t" /* B7 B6 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
419 "pand %%mm4, %%mm3 \n\t" /* G7 G6 G5 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
420 "pand M24B, %%mm6 \n\t" /* R7 R6 R5 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
421 "movd 4 (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
422 \
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
423 "por %%mm5, %%mm3 \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
424 "por %%mm3, %%mm6 \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
425 MOVNTQ" %%mm6, 16(%3) \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
426 "movq 8 (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
427 "pxor %%mm4, %%mm4 \n\t"
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
428
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
429 #else
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
430
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
431 "pxor %%mm4, %%mm4 \n\t"
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
432 "movq %%mm0, %%mm5 \n\t" /* B */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
433 "movq %%mm1, %%mm6 \n\t" /* R */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
434 "punpcklbw %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
435 "punpcklbw %%mm4, %%mm1 \n\t" /* 0R0R0R0R 0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
436 "punpckhbw %%mm2, %%mm5 \n\t" /* GBGBGBGB 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
437 "punpckhbw %%mm4, %%mm6 \n\t" /* 0R0R0R0R 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
438 "movq %%mm0, %%mm7 \n\t" /* GBGBGBGB 0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
439 "movq %%mm5, %%mm3 \n\t" /* GBGBGBGB 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
440 "punpcklwd %%mm1, %%mm7 \n\t" /* 0RGB0RGB 0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
441 "punpckhwd %%mm1, %%mm0 \n\t" /* 0RGB0RGB 1 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
442 "punpcklwd %%mm6, %%mm5 \n\t" /* 0RGB0RGB 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
443 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
444
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
445 "movq %%mm7, %%mm2 \n\t" /* 0RGB0RGB 0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
446 "movq %%mm0, %%mm6 \n\t" /* 0RGB0RGB 1 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
447 "movq %%mm5, %%mm1 \n\t" /* 0RGB0RGB 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
448 "movq %%mm3, %%mm4 \n\t" /* 0RGB0RGB 3 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
449
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
450 "psllq $40, %%mm7 \n\t" /* RGB00000 0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
451 "psllq $40, %%mm0 \n\t" /* RGB00000 1 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
452 "psllq $40, %%mm5 \n\t" /* RGB00000 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
453 "psllq $40, %%mm3 \n\t" /* RGB00000 3 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
454
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
455 "punpckhdq %%mm2, %%mm7 \n\t" /* 0RGBRGB0 0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
456 "punpckhdq %%mm6, %%mm0 \n\t" /* 0RGBRGB0 1 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
457 "punpckhdq %%mm1, %%mm5 \n\t" /* 0RGBRGB0 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
458 "punpckhdq %%mm4, %%mm3 \n\t" /* 0RGBRGB0 3 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
459
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
460 "psrlq $8, %%mm7 \n\t" /* 00RGBRGB 0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
461 "movq %%mm0, %%mm6 \n\t" /* 0RGBRGB0 1 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
462 "psllq $40, %%mm0 \n\t" /* GB000000 1 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
463 "por %%mm0, %%mm7 \n\t" /* GBRGBRGB 0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
464 MOVNTQ" %%mm7, (%3) \n\t"
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
465
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
466 "movd 4 (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
467
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
468 "psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
469 "movq %%mm5, %%mm1 \n\t" /* 0RGBRGB0 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
470 "psllq $24, %%mm5 \n\t" /* BRGB0000 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
471 "por %%mm5, %%mm6 \n\t" /* BRGBRGBR 1 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
472 MOVNTQ" %%mm6, 8(%3) \n\t"
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
473
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
474 "movq 8 (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
475
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
476 "psrlq $40, %%mm1 \n\t" /* 000000RG 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
477 "psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
478 "por %%mm3, %%mm1 \n\t" /* RGBRGBRG 2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
479 MOVNTQ" %%mm1, 16(%3) \n\t"
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
480
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
481 "movd 4 (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
482 "pxor %%mm4, %%mm4 \n\t"
2739
f365024806c0 mmx2 bgr24 stuff from swscale (slightly faster)
michael
parents: 2737
diff changeset
483 #endif
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
484
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
485 : : "r" (_py), "r" (_pu), "r" (_pv), "r" (_image));
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
486
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
487 _py += 8;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
488 _pu += 4;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
489 _pv += 4;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
490 _image += 24;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
491 }
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
492
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
493 if (!even) {
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
494 pu += uv_stride;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
495 pv += uv_stride;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
496 }
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
497
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
498 py += y_stride;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
499 image += rgb_stride;
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
500
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
501 even = (!even);
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
502 }
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
503
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
504 __asm__ __volatile__ (EMMS);
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
505 }
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
506
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
507
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
508 static void yuv420_argb32_mmx (uint8_t * image, uint8_t * py,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
509 uint8_t * pu, uint8_t * pv,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
510 int h_size, int v_size,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
511 int rgb_stride, int y_stride, int uv_stride)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
512 {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
513 int even = 1;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
514 int x, y;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
515
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
516 __asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
517
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
518 for (y = v_size; --y >= 0; ) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
519 uint8_t *_image = image;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
520 uint8_t *_py = py;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
521 uint8_t *_pu = pu;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
522 uint8_t *_pv = pv;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
523
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
524 /* load data for start of next scan line */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
525 __asm__ __volatile__
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
526 (
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
527 "movd (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
528 "movd (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
529 "movq (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
530 : : "r" (_py), "r" (_pu), "r" (_pv)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
531 );
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
532
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
533 for (x = h_size >> 3; --x >= 0; ) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
534 /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
535 pixels in each iteration */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
536 __asm__ __volatile__ (
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
537 YUV2RGB
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
538 /* convert RGB plane to RGB packed format,
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
539 mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
540 mm4 -> GB, mm5 -> AR pixel 4-7,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
541 mm6 -> GB, mm7 -> AR pixel 0-3 */
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
542 "pxor %%mm3, %%mm3;" /* zero mm3 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
543
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
544 "movq %%mm0, %%mm6;" /* B7 B6 B5 B4 B3 B2 B1 B0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
545 "movq %%mm1, %%mm7;" /* R7 R6 R5 R4 R3 R2 R1 R0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
546
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
547 "movq %%mm0, %%mm4;" /* B7 B6 B5 B4 B3 B2 B1 B0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
548 "movq %%mm1, %%mm5;" /* R7 R6 R5 R4 R3 R2 R1 R0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
549
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
550 "punpcklbw %%mm2, %%mm6;" /* G3 B3 G2 B2 G1 B1 G0 B0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
551 "punpcklbw %%mm3, %%mm7;" /* 00 R3 00 R2 00 R1 00 R0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
552
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
553 "punpcklwd %%mm7, %%mm6;" /* 00 R1 B1 G1 00 R0 B0 G0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
554 MOVNTQ " %%mm6, (%3);" /* Store ARGB1 ARGB0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
555
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
556 "movq %%mm0, %%mm6;" /* B7 B6 B5 B4 B3 B2 B1 B0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
557 "punpcklbw %%mm2, %%mm6;" /* G3 B3 G2 B2 G1 B1 G0 B0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
558
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
559 "punpckhwd %%mm7, %%mm6;" /* 00 R3 G3 B3 00 R2 B3 G2 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
560 MOVNTQ " %%mm6, 8 (%3);" /* Store ARGB3 ARGB2 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
561
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
562 "punpckhbw %%mm2, %%mm4;" /* G7 B7 G6 B6 G5 B5 G4 B4 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
563 "punpckhbw %%mm3, %%mm5;" /* 00 R7 00 R6 00 R5 00 R4 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
564
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
565 "punpcklwd %%mm5, %%mm4;" /* 00 R5 B5 G5 00 R4 B4 G4 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
566 MOVNTQ " %%mm4, 16 (%3);" /* Store ARGB5 ARGB4 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
567
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
568 "movq %%mm0, %%mm4;" /* B7 B6 B5 B4 B3 B2 B1 B0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
569 "punpckhbw %%mm2, %%mm4;" /* G7 B7 G6 B6 G5 B5 G4 B4 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
570
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
571 "punpckhwd %%mm5, %%mm4;" /* 00 R7 G7 B7 00 R6 B6 G6 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
572 MOVNTQ " %%mm4, 24 (%3);" /* Store ARGB7 ARGB6 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
573
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
574 "movd 4 (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
575 "movd 4 (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
576
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
577 "pxor %%mm4, %%mm4;" /* zero mm4 */
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
578 "movq 8 (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
579
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
580 : : "r" (_py), "r" (_pu), "r" (_pv), "r" (_image));
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
581
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
582 _py += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
583 _pu += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
584 _pv += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
585 _image += 32;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
586 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
587
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
588 if (!even) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
589 pu += uv_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
590 pv += uv_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
591 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
592
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
593 py += y_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
594 image += rgb_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
595
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
596 even = (!even);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
597 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
598
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
599 __asm__ __volatile__ (EMMS);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
600 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
601
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
602 yuv2rgb_fun yuv2rgb_init_mmx (int bpp, int mode)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
603 {
2735
0f4c3ae92857 15 bpp support
michael
parents: 2734
diff changeset
604 if (bpp == 15 && mode == MODE_RGB) return yuv420_rgb15_mmx;
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
605 if (bpp == 16 && mode == MODE_RGB) return yuv420_rgb16_mmx;
2734
4ce165aa0135 common code moved to a #define
michael
parents: 2732
diff changeset
606 if (bpp == 24 && mode == MODE_RGB) return yuv420_rgb24_mmx;
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
607 if (bpp == 32 && mode == MODE_RGB) return yuv420_argb32_mmx;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
608 return NULL; // Fallback to C.
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
609 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
610