annotate libvo/yuv2rgb_mmx.c @ 2539:4ec3d2f594f8

No longer required
author nick
date Mon, 29 Oct 2001 18:44:20 +0000
parents 7ce37211e454
children ae2026ac39d4
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;
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
79 int x, y;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
80
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
81 __asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
83 for (y = v_size; --y >= 0; ) {
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
84 uint8_t *_image = image;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
85 uint8_t *_py = py;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
86 uint8_t *_pu = pu;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
87 uint8_t *_pv = pv;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
89 /* load data for start of next scan line */
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
90 __asm__ __volatile__ (
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
91 "movd (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
92 "movd (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
93 "movq (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
95 : : "r" (_py), "r" (_pu), "r" (_pv));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
97 for (x = h_size >> 3; --x >= 0; ) {
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 pixels in each iteration */
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
100
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
101 __asm__ __volatile__ (
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 /* Do the multiply part of the conversion for even and odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 register usage:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 mm6 -> Y even, mm7 -> Y odd */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 /* 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
108 "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
109 "punpcklbw %%mm4, %%mm1;" /* scatter 4 Cr 00 v3 00 v2 00 v1 00 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
111 "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
112 "psubsw mmx_80w, %%mm1;" /* Cr -= 128 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
114 "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
115 "psllw $3, %%mm1;" /* Promote precision */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
117 "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
118 "movq %%mm1, %%mm3;" /* Copy 4 Cr 00 v3 00 v2 00 v1 00 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
120 "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
121 "pmulhw mmx_V_green, %%mm3;" /* Mul Cr with green coeff -> Cr green */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
123 "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
124 "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
125
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
126 "paddsw %%mm3, %%mm2;" /* Cb green + Cr green -> Cgreen */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 /* 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
129 "psubusb mmx_10w, %%mm6;" /* Y -= 16 */
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 "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
132 "pand mmx_00ffw, %%mm6;" /* get Y even 00 Y6 00 Y4 00 Y2 00 Y0 */
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 "psrlw $8, %%mm7;" /* get Y odd 00 Y7 00 Y5 00 Y3 00 Y1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
136 "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
137 "psllw $3, %%mm7;" /* Promote precision */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
139 "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
140 "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
141
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 /* Do the addition part of the conversion for even and odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 register usage:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 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
147 "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
148 "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
149 "movq %%mm2, %%mm5;" /* Copy Cgreen */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
151 "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
152 "paddsw %%mm7, %%mm3;" /* Y odd + Cblue 00 B7 00 B5 00 B3 00 B1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
154 "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
155 "paddsw %%mm7, %%mm4;" /* Y odd + Cred 00 R7 00 R5 00 R3 00 R1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
157 "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
158 "paddsw %%mm7, %%mm5;" /* Y odd + Cgreen 00 G7 00 G5 00 G3 00 G1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 /* 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
161 "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
162 "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
163 "packuswb %%mm2, %%mm2;" /* G6 G4 G2 G0 G6 G4 G2 G0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 /* 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
166 "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
167 "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
168 "packuswb %%mm5, %%mm5;" /* G7 G5 G3 G1 G7 G5 G3 G1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 /* 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
171 "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
172 "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
173 "punpcklbw %%mm5, %%mm2;" /* G7 G6 G5 G4 G3 G2 G1 G0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 /* 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
176 "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
177 "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
178 "pand mmx_redmask, %%mm1;" /* r7r6r5r4 r3_0_0_0 r7r6r5r4 r3_0_0_0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
180 "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
181 "pxor %%mm4, %%mm4;" /* zero mm4 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
183 "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
184 "movq %%mm2, %%mm7;" /* Copy G7-G0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 /* 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
187 "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
188 "punpcklbw %%mm1, %%mm0;" /* r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
190 "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
191 "por %%mm2, %%mm0;" /* r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
193 "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
194 MOVNTQ " %%mm0, (%3);" /* store pixel 0-3 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 /* 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
197 "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
198 "punpckhbw %%mm1, %%mm5;" /* r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
200 "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
201 "movd 4 (%1), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
203 "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
204 "movd 4 (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
206 MOVNTQ " %%mm5, 8 (%3);" /* store pixel 4-7 */
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
207 : : "r" (_py), "r" (_pu), "r" (_pv), "r" (_image));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
209 _py += 8;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
210 _pu += 4;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
211 _pv += 4;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
212 _image += 16;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
215 if (!even) {
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
216 pu += uv_stride;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
217 pv += uv_stride;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
218 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
220 py += y_stride;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
221 image += rgb_stride;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 even = (!even);
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
224 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
226 __asm__ __volatile__ (EMMS);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 static void yuv420_argb32_mmx (uint8_t * image, uint8_t * py,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 uint8_t * pu, uint8_t * pv,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 int h_size, int v_size,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 int rgb_stride, int y_stride, int uv_stride)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 int even = 1;
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
235 int x, y;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
236
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
237 __asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
239 for (y = v_size; --y >= 0; ) {
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
240 uint8_t *_image = image;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
241 uint8_t *_py = py;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
242 uint8_t *_pu = pu;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
243 uint8_t *_pv = pv;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
244
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
245 /* load data for start of next scan line */
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
246 __asm__ __volatile__
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
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 "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
249 "movd (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
250 "movq (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
251 : : "r" (_py), "r" (_pu), "r" (_pv)
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
252 );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
254 for (x = h_size >> 3; --x >= 0; ) {
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 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
257 __asm__ __volatile__ (
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 /* Do the multiply part of the conversion for even and odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 register usage:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 mm6 -> Y even, mm7 -> Y odd */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 /* 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
265 "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
266 "punpcklbw %%mm4, %%mm1;" /* scatter 4 Cr 00 v3 00 v2 00 v1 00 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
268 "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
269 "psubsw mmx_80w, %%mm1;" /* Cr -= 128 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
271 "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
272 "psllw $3, %%mm1;" /* Promote precision */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
274 "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
275 "movq %%mm1, %%mm3;" /* Copy 4 Cr 00 v3 00 v2 00 v1 00 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
277 "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
278 "pmulhw mmx_V_green, %%mm3;" /* Mul Cr with green coeff -> Cr green */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
280 "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
281 "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
282
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
283 "paddsw %%mm3, %%mm2;" /* Cb green + Cr green -> Cgreen */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 /* 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
286 "psubusb mmx_10w, %%mm6;" /* Y -= 16 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
288 "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
289 "pand mmx_00ffw, %%mm6;" /* get Y even 00 Y6 00 Y4 00 Y2 00 Y0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
291 "psrlw $8, %%mm7;" /* get Y odd 00 Y7 00 Y5 00 Y3 00 Y1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
293 "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
294 "psllw $3, %%mm7;" /* Promote precision */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
296 "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
297 "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
298
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 /* Do the addition part of the conversion for even and odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 register usage:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 mm0 -> Cblue, mm1 -> Cred, mm2 -> Cgreen even pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 mm3 -> Cblue, mm4 -> Cred, mm5 -> Cgreen odd pixels,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303 mm6 -> Y even, mm7 -> Y odd */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
305 "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
306 "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
307 "movq %%mm2, %%mm5;" /* Copy Cgreen */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
309 "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
310 "paddsw %%mm7, %%mm3;" /* Y odd + Cblue 00 B7 00 B5 00 B3 00 B1 */
1
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 "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
313 "paddsw %%mm7, %%mm4;" /* Y odd + Cred 00 R7 00 R5 00 R3 00 R1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
315 "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
316 "paddsw %%mm7, %%mm5;" /* Y odd + Cgreen 00 G7 00 G5 00 G3 00 G1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318 /* 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
319 "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
320 "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
321 "packuswb %%mm2, %%mm2;" /* G6 G4 G2 G0 G6 G4 G2 G0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 /* 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
324 "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
325 "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
326 "packuswb %%mm5, %%mm5;" /* G7 G5 G3 G1 G7 G5 G3 G1 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 /* 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
329 "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
330 "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
331 "punpcklbw %%mm5, %%mm2;" /* G7 G6 G5 G4 G3 G2 G1 G0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 /* convert RGB plane to RGB packed format,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334 mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 mm4 -> GB, mm5 -> AR pixel 4-7,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336 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
337 "pxor %%mm3, %%mm3;" /* zero mm3 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
339 "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
340 "movq %%mm1, %%mm7;" /* R7 R6 R5 R4 R3 R2 R1 R0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
342 "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
343 "movq %%mm1, %%mm5;" /* R7 R6 R5 R4 R3 R2 R1 R0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
345 "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
346 "punpcklbw %%mm3, %%mm7;" /* 00 R3 00 R2 00 R1 00 R0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
347
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
348 "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
349 MOVNTQ " %%mm6, (%3);" /* Store ARGB1 ARGB0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
351 "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
352 "punpcklbw %%mm2, %%mm6;" /* G3 B3 G2 B2 G1 B1 G0 B0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
354 "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
355 MOVNTQ " %%mm6, 8 (%3);" /* Store ARGB3 ARGB2 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
357 "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
358 "punpckhbw %%mm3, %%mm5;" /* 00 R7 00 R6 00 R5 00 R4 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
360 "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
361 MOVNTQ " %%mm4, 16 (%3);" /* Store ARGB5 ARGB4 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
363 "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
364 "punpckhbw %%mm2, %%mm4;" /* G7 B7 G6 B6 G5 B5 G4 B4 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
366 "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
367 MOVNTQ " %%mm4, 24 (%3);" /* Store ARGB7 ARGB6 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
368
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
369 "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
370 "movd 4 (%2), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
372 "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
373 "movq 8 (%0), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
375 : : "r" (_py), "r" (_pu), "r" (_pv), "r" (_image));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
377 _py += 8;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
378 _pu += 4;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
379 _pv += 4;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
380 _image += 32;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
383 if (!even) {
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
384 pu += uv_stride;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
385 pv += uv_stride;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
386 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
388 py += y_stride;
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
389 image += rgb_stride;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 even = (!even);
1306
7ce37211e454 yuv2rgb_mmx crashes with ffdivx codec, when we play back avi files that have
jkeil
parents: 1101
diff changeset
392 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393
1101
961f53221ffc Code cleanup and fix missing config.h and use femms on K6 2/2+/3.
atmosfear
parents: 1098
diff changeset
394 __asm__ __volatile__ (EMMS);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 yuv2rgb_fun yuv2rgb_init_mmx (int bpp, int mode)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 // if (bpp == 15 || bpp == 16) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 if (bpp == 16 && mode == MODE_RGB) return yuv420_rgb16_mmx;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401 if (bpp == 32 && mode == MODE_RGB) return yuv420_argb32_mmx;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402 return NULL; // Fallback to C.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404