annotate libvo/yuv2rgb_mmx.c @ 1159:b7574af79fea

- added bug report section
author acki2
date Mon, 18 Jun 2001 16:51:13 +0000
parents 961f53221ffc
children 7ce37211e454
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 * yuv2rgb_mmx.c, Software YUV to RGB coverter with Intel MMX "technology"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 * Copyright (C) 2000, Silicon Integrated System Corp.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 * All Rights Reserved.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 * Author: Olie Lho <ollie@sis.com.tw>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 * This file is part of mpeg2dec, a free MPEG-2 video decoder
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 * mpeg2dec is free software; you can redistribute it and/or modify
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 * the Free Software Foundation; either version 2, or (at your option)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 * any later version.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 * mpeg2dec is distributed in the hope that it will be useful,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 * GNU General Public License for more details.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 * along with GNU Make; see the file COPYING. If not, write to
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
31 #include "../config.h"
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
32
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 #include "mmx.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 //#include "libmpeg2/mpeg2.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 //#include "libmpeg2/mpeg2_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 #include <inttypes.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 #include "yuv2rgb.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 /* hope these constant values are cache line aligned */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 uint64_t mmx_80w = 0x0080008000800080;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 uint64_t mmx_10w = 0x1010101010101010;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 uint64_t mmx_00ffw = 0x00ff00ff00ff00ff;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 uint64_t mmx_Y_coeff = 0x253f253f253f253f;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 /* hope these constant values are cache line aligned */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 uint64_t mmx_U_green = 0xf37df37df37df37d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 uint64_t mmx_U_blue = 0x4093409340934093;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 uint64_t mmx_V_red = 0x3312331233123312;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 uint64_t mmx_V_green = 0xe5fce5fce5fce5fc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 /* hope these constant values are cache line aligned */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 uint64_t mmx_redmask = 0xf8f8f8f8f8f8f8f8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 uint64_t mmx_grnmask = 0xfcfcfcfcfcfcfcfc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 uint64_t mmx_grnshift = 0x03;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 uint64_t mmx_blueshift = 0x03;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57
688
1a016347010a movntq causes SIGILL on k6-3. Lets it be for K7, P3 cpus only
nickols_k
parents: 1
diff changeset
58 #ifdef HAVE_MMX2
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
59 /* use this for K7 and p3 only */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
60 #define MOVNTQ "movntq"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 #else
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
62 /* for MMX-only processors */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
63 #define MOVNTQ "movq"
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
64 #endif
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
65
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
66 #if !defined( HAVE_MMX2) && defined( HAVE_3DNOW)
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
67 /* for K6 2/2+/3 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
68 #define EMMS "femms;"
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
69 #else
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
70 #define EMMS "emms;"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 static void yuv420_rgb16_mmx (uint8_t * image, uint8_t * py,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 uint8_t * pu, uint8_t * pv,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 int h_size, int v_size,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 int rgb_stride, int y_stride, int uv_stride)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 int even = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 int x = 0, y = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 /* load data for first scan line */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
82 __asm__ __volatile__ (
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
83 "movd (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
84 "movd (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
86 "pxor %%mm4, %%mm4;" /* zero mm4 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
87 "movq (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
89 //"movl $0, (%3);" /* cache preload for image */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 : : "r" (py), "r" (pu), "r" (pv), "r" (image));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 do {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 do {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 pixels in each iteration */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
96 __asm__ __volatile__ (".align 8;"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 /* Do the multiply part of the conversion for even and odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 register usage:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 mm6 -> Y even, mm7 -> Y odd */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 /* convert the chroma part */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
103 "punpcklbw %%mm4, %%mm0;" /* scatter 4 Cb 00 u3 00 u2 00 u1 00 u0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
104 "punpcklbw %%mm4, %%mm1;" /* scatter 4 Cr 00 v3 00 v2 00 v1 00 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
106 "psubsw mmx_80w, %%mm0;" /* Cb -= 128 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
107 "psubsw mmx_80w, %%mm1;" /* Cr -= 128 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
109 "psllw $3, %%mm0;" /* Promote precision */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
110 "psllw $3, %%mm1;" /* Promote precision */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
112 "movq %%mm0, %%mm2;" /* Copy 4 Cb 00 u3 00 u2 00 u1 00 u0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
113 "movq %%mm1, %%mm3;" /* Copy 4 Cr 00 v3 00 v2 00 v1 00 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
115 "pmulhw mmx_U_green, %%mm2;" /* Mul Cb with green coeff -> Cb green */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
116 "pmulhw mmx_V_green, %%mm3;" /* Mul Cr with green coeff -> Cr green */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
118 "pmulhw mmx_U_blue, %%mm0;" /* Mul Cb -> Cblue 00 b3 00 b2 00 b1 00 b0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
119 "pmulhw mmx_V_red, %%mm1;" /* Mul Cr -> Cred 00 r3 00 r2 00 r1 00 r0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
121 "paddsw %%mm3, %%mm2;" /* Cb green + Cr green -> Cgreen */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 /* convert the luma part */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
124 "psubusb mmx_10w, %%mm6;" /* Y -= 16 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
126 "movq %%mm6, %%mm7;" /* Copy 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
127 "pand mmx_00ffw, %%mm6;" /* get Y even 00 Y6 00 Y4 00 Y2 00 Y0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
129 "psrlw $8, %%mm7;" /* get Y odd 00 Y7 00 Y5 00 Y3 00 Y1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
131 "psllw $3, %%mm6;" /* Promote precision */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
132 "psllw $3, %%mm7;" /* Promote precision */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
134 "pmulhw mmx_Y_coeff, %%mm6;" /* Mul 4 Y even 00 y6 00 y4 00 y2 00 y0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
135 "pmulhw mmx_Y_coeff, %%mm7;" /* Mul 4 Y odd 00 y7 00 y5 00 y3 00 y1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 /* Do the addition part of the conversion for even and odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 register usage:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 mm6 -> Y even, mm7 -> Y odd */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
142 "movq %%mm0, %%mm3;" /* Copy Cblue */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
143 "movq %%mm1, %%mm4;" /* Copy Cred */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
144 "movq %%mm2, %%mm5;" /* Copy Cgreen */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
146 "paddsw %%mm6, %%mm0;" /* Y even + Cblue 00 B6 00 B4 00 B2 00 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
147 "paddsw %%mm7, %%mm3;" /* Y odd + Cblue 00 B7 00 B5 00 B3 00 B1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
149 "paddsw %%mm6, %%mm1;" /* Y even + Cred 00 R6 00 R4 00 R2 00 R0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
150 "paddsw %%mm7, %%mm4;" /* Y odd + Cred 00 R7 00 R5 00 R3 00 R1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
152 "paddsw %%mm6, %%mm2;" /* Y even + Cgreen 00 G6 00 G4 00 G2 00 G0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
153 "paddsw %%mm7, %%mm5;" /* Y odd + Cgreen 00 G7 00 G5 00 G3 00 G1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 /* Limit RGB even to 0..255 */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
156 "packuswb %%mm0, %%mm0;" /* B6 B4 B2 B0 B6 B4 B2 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
157 "packuswb %%mm1, %%mm1;" /* R6 R4 R2 R0 R6 R4 R2 R0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
158 "packuswb %%mm2, %%mm2;" /* G6 G4 G2 G0 G6 G4 G2 G0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 /* Limit RGB odd to 0..255 */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
161 "packuswb %%mm3, %%mm3;" /* B7 B5 B3 B1 B7 B5 B3 B1 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
162 "packuswb %%mm4, %%mm4;" /* R7 R5 R3 R1 R7 R5 R3 R1 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
163 "packuswb %%mm5, %%mm5;" /* G7 G5 G3 G1 G7 G5 G3 G1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 /* Interleave RGB even and odd */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
166 "punpcklbw %%mm3, %%mm0;" /* B7 B6 B5 B4 B3 B2 B1 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
167 "punpcklbw %%mm4, %%mm1;" /* R7 R6 R5 R4 R3 R2 R1 R0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
168 "punpcklbw %%mm5, %%mm2;" /* G7 G6 G5 G4 G3 G2 G1 G0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 /* mask unneeded bits off */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
171 "pand mmx_redmask, %%mm0;" /* b7b6b5b4 b3_0_0_0 b7b6b5b4 b3_0_0_0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
172 "pand mmx_grnmask, %%mm2;" /* g7g6g5g4 g3g2_0_0 g7g6g5g4 g3g2_0_0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
173 "pand mmx_redmask, %%mm1;" /* r7r6r5r4 r3_0_0_0 r7r6r5r4 r3_0_0_0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
175 "psrlw mmx_blueshift,%%mm0;" /* 0_0_0_b7 b6b5b4b3 0_0_0_b7 b6b5b4b3 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
176 "pxor %%mm4, %%mm4;" /* zero mm4 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
178 "movq %%mm0, %%mm5;" /* Copy B7-B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
179 "movq %%mm2, %%mm7;" /* Copy G7-G0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 /* convert rgb24 plane to rgb16 pack for pixel 0-3 */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
182 "punpcklbw %%mm4, %%mm2;" /* 0_0_0_0 0_0_0_0 g7g6g5g4 g3g2_0_0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
183 "punpcklbw %%mm1, %%mm0;" /* r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
185 "psllw mmx_blueshift,%%mm2;" /* 0_0_0_0 0_g7g6g5 g4g3g2_0 0_0_0_0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
186 "por %%mm2, %%mm0;" /* r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
188 "movq 8 (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
189 MOVNTQ " %%mm0, (%3);" /* store pixel 0-3 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 /* convert rgb24 plane to rgb16 pack for pixel 0-3 */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
192 "punpckhbw %%mm4, %%mm7;" /* 0_0_0_0 0_0_0_0 g7g6g5g4 g3g2_0_0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
193 "punpckhbw %%mm1, %%mm5;" /* r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
195 "psllw mmx_blueshift,%%mm7;" /* 0_0_0_0 0_g7g6g5 g4g3g2_0 0_0_0_0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
196 "movd 4 (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
198 "por %%mm7, %%mm5;" /* r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
199 "movd 4 (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
201 MOVNTQ " %%mm5, 8 (%3);" /* store pixel 4-7 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 : : "r" (py), "r" (pu), "r" (pv), "r" (image));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 py += 8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 pu += 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 pv += 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 image += 16;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 x += 8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 } while (x < h_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 if (even) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 pu -= h_size/2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 pv -= h_size/2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 pu += (uv_stride - h_size/2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 pv += (uv_stride - h_size/2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 py += (y_stride - h_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 image += (rgb_stride - 2*h_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 /* load data for start of next scan line */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
223 __asm__ __volatile__ (
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
224 "movd (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 00 u3 u2 u1 u0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
225 "movd (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 00 v2 v1 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
227 //"movl $0, (%3);" /* cache preload for image */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
228 "movq (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 : : "r" (py), "r" (pu), "r" (pv), "r" (image));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 x = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 y += 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 even = (!even);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 } while (y < v_size) ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
237 __asm__ __volatile__ (EMMS);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 static void yuv420_argb32_mmx (uint8_t * image, uint8_t * py,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 uint8_t * pu, uint8_t * pv,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 int h_size, int v_size,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 int rgb_stride, int y_stride, int uv_stride)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 int even = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 int x = 0, y = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
248 __asm__ __volatile__ (
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
249 ".align 8;"
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
250 "movd (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
251 //"movl $0, (%3);" /* cache preload for image */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
253 "movd (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
254 "pxor %%mm4, %%mm4;" /* zero mm4 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
256 "movq (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 : : "r" (py), "r" (pu), "r" (pv), "r" (image));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 do {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 do {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 pixels in each iteration */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
263 __asm__ __volatile__ (
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
264 ".align 8;"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 /* Do the multiply part of the conversion for even and odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 register usage:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 mm6 -> Y even, mm7 -> Y odd */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 /* convert the chroma part */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
272 "punpcklbw %%mm4, %%mm0;" /* scatter 4 Cb 00 u3 00 u2 00 u1 00 u0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
273 "punpcklbw %%mm4, %%mm1;" /* scatter 4 Cr 00 v3 00 v2 00 v1 00 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
275 "psubsw mmx_80w, %%mm0;" /* Cb -= 128 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
276 "psubsw mmx_80w, %%mm1;" /* Cr -= 128 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
278 "psllw $3, %%mm0;" /* Promote precision */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
279 "psllw $3, %%mm1;" /* Promote precision */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
281 "movq %%mm0, %%mm2;" /* Copy 4 Cb 00 u3 00 u2 00 u1 00 u0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
282 "movq %%mm1, %%mm3;" /* Copy 4 Cr 00 v3 00 v2 00 v1 00 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
284 "pmulhw mmx_U_green, %%mm2;" /* Mul Cb with green coeff -> Cb green */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
285 "pmulhw mmx_V_green, %%mm3;" /* Mul Cr with green coeff -> Cr green */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
287 "pmulhw mmx_U_blue, %%mm0;" /* Mul Cb -> Cblue 00 b3 00 b2 00 b1 00 b0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
288 "pmulhw mmx_V_red, %%mm1;" /* Mul Cr -> Cred 00 r3 00 r2 00 r1 00 r0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
290 "paddsw %%mm3, %%mm2;" /* Cb green + Cr green -> Cgreen */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 /* convert the luma part */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
293 "psubusb mmx_10w, %%mm6;" /* Y -= 16 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
295 "movq %%mm6, %%mm7;" /* Copy 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
296 "pand mmx_00ffw, %%mm6;" /* get Y even 00 Y6 00 Y4 00 Y2 00 Y0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
298 "psrlw $8, %%mm7;" /* get Y odd 00 Y7 00 Y5 00 Y3 00 Y1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
300 "psllw $3, %%mm6;" /* Promote precision */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
301 "psllw $3, %%mm7;" /* Promote precision */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
303 "pmulhw mmx_Y_coeff, %%mm6;" /* Mul 4 Y even 00 y6 00 y4 00 y2 00 y0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
304 "pmulhw mmx_Y_coeff, %%mm7;" /* Mul 4 Y odd 00 y7 00 y5 00 y3 00 y1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306 /* Do the addition part of the conversion for even and odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
307 register usage:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 mm6 -> Y even, mm7 -> Y odd */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
311
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
312 "movq %%mm0, %%mm3;" /* Copy Cblue */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
313 "movq %%mm1, %%mm4;" /* Copy Cred */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
314 "movq %%mm2, %%mm5;" /* Copy Cgreen */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
316 "paddsw %%mm6, %%mm0;" /* Y even + Cblue 00 B6 00 B4 00 B2 00 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
317 "paddsw %%mm7, %%mm3;" /* Y odd + Cblue 00 B7 00 B5 00 B3 00 B1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
319 "paddsw %%mm6, %%mm1;" /* Y even + Cred 00 R6 00 R4 00 R2 00 R0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
320 "paddsw %%mm7, %%mm4;" /* Y odd + Cred 00 R7 00 R5 00 R3 00 R1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
322 "paddsw %%mm6, %%mm2;" /* Y even + Cgreen 00 G6 00 G4 00 G2 00 G0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
323 "paddsw %%mm7, %%mm5;" /* Y odd + Cgreen 00 G7 00 G5 00 G3 00 G1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325 /* Limit RGB even to 0..255 */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
326 "packuswb %%mm0, %%mm0;" /* B6 B4 B2 B0 B6 B4 B2 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
327 "packuswb %%mm1, %%mm1;" /* R6 R4 R2 R0 R6 R4 R2 R0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
328 "packuswb %%mm2, %%mm2;" /* G6 G4 G2 G0 G6 G4 G2 G0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330 /* Limit RGB odd to 0..255 */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
331 "packuswb %%mm3, %%mm3;" /* B7 B5 B3 B1 B7 B5 B3 B1 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
332 "packuswb %%mm4, %%mm4;" /* R7 R5 R3 R1 R7 R5 R3 R1 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
333 "packuswb %%mm5, %%mm5;" /* G7 G5 G3 G1 G7 G5 G3 G1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 /* Interleave RGB even and odd */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
336 "punpcklbw %%mm3, %%mm0;" /* B7 B6 B5 B4 B3 B2 B1 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
337 "punpcklbw %%mm4, %%mm1;" /* R7 R6 R5 R4 R3 R2 R1 R0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
338 "punpcklbw %%mm5, %%mm2;" /* G7 G6 G5 G4 G3 G2 G1 G0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 /* convert RGB plane to RGB packed format,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342 mm4 -> GB, mm5 -> AR pixel 4-7,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 mm6 -> GB, mm7 -> AR pixel 0-3 */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
344 "pxor %%mm3, %%mm3;" /* zero mm3 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
346 "movq %%mm0, %%mm6;" /* B7 B6 B5 B4 B3 B2 B1 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
347 "movq %%mm1, %%mm7;" /* R7 R6 R5 R4 R3 R2 R1 R0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
349 "movq %%mm0, %%mm4;" /* B7 B6 B5 B4 B3 B2 B1 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
350 "movq %%mm1, %%mm5;" /* R7 R6 R5 R4 R3 R2 R1 R0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
352 "punpcklbw %%mm2, %%mm6;" /* G3 B3 G2 B2 G1 B1 G0 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
353 "punpcklbw %%mm3, %%mm7;" /* 00 R3 00 R2 00 R1 00 R0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
355 "punpcklwd %%mm7, %%mm6;" /* 00 R1 B1 G1 00 R0 B0 G0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
356 MOVNTQ " %%mm6, (%3);" /* Store ARGB1 ARGB0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
358 "movq %%mm0, %%mm6;" /* B7 B6 B5 B4 B3 B2 B1 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
359 "punpcklbw %%mm2, %%mm6;" /* G3 B3 G2 B2 G1 B1 G0 B0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
361 "punpckhwd %%mm7, %%mm6;" /* 00 R3 G3 B3 00 R2 B3 G2 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
362 MOVNTQ " %%mm6, 8 (%3);" /* Store ARGB3 ARGB2 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
364 "punpckhbw %%mm2, %%mm4;" /* G7 B7 G6 B6 G5 B5 G4 B4 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
365 "punpckhbw %%mm3, %%mm5;" /* 00 R7 00 R6 00 R5 00 R4 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
367 "punpcklwd %%mm5, %%mm4;" /* 00 R5 B5 G5 00 R4 B4 G4 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
368 MOVNTQ " %%mm4, 16 (%3);" /* Store ARGB5 ARGB4 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
369
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
370 "movq %%mm0, %%mm4;" /* B7 B6 B5 B4 B3 B2 B1 B0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
371 "punpckhbw %%mm2, %%mm4;" /* G7 B7 G6 B6 G5 B5 G4 B4 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
373 "punpckhwd %%mm5, %%mm4;" /* 00 R7 G7 B7 00 R6 B6 G6 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
374 MOVNTQ " %%mm4, 24 (%3);" /* Store ARGB7 ARGB6 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
376 "movd 4 (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
377 "movd 4 (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
378
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
379 "pxor %%mm4, %%mm4;" /* zero mm4 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
380 "movq 8 (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382 : : "r" (py), "r" (pu), "r" (pv), "r" (image));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 py += 8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 pu += 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 pv += 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 image += 32;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 x += 8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389 } while (x < h_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 if (even) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 pu -= h_size/2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 pv -= h_size/2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395 pu += (uv_stride - h_size/2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396 pv += (uv_stride - h_size/2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 py += (y_stride - h_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 image += (rgb_stride - 4*h_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402 /* load data for start of next scan line */
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
403 __asm__ __volatile__
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 (
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
405 ".align 8;"
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
406 "movd (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
407 "movd (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
409 //"movl $0, (%3);" /* cache preload for image */
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
410 "movq (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 : : "r" (py), "r" (pu), "r" (pv), "r" (image)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415 x = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 y += 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 even = (!even);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 } while ( y < v_size) ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
420 __asm__ __volatile__ (EMMS);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 yuv2rgb_fun yuv2rgb_init_mmx (int bpp, int mode)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425 // if (bpp == 15 || bpp == 16) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 if (bpp == 16 && mode == MODE_RGB) return yuv420_rgb16_mmx;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 if (bpp == 32 && mode == MODE_RGB) return yuv420_argb32_mmx;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 return NULL; // Fallback to C.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430