annotate postproc/swscale_template.c @ 2503:d21d8d5f2e23

yuv2rgb bugfix
author michael
date Sun, 28 Oct 2001 03:03:49 +0000
parents a6c5a537f30a
children 6f3fa9bc3b27
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
2 // Software scaling and colorspace conversion routines for MPlayer
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
3
2269
95c48204bcd9 (C) fixed
arpi
parents: 2267
diff changeset
4 // Orginal C implementation by A'rpi/ESP-team <arpi@thot.banki.hu>
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
5 // current version mostly by Michael Niedermayer (michaelni@gmx.at)
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
6 // the parts written by michael are under GNU GPL
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
7
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
8 #include <inttypes.h>
2476
a6c5a537f30a a few warning fixes (missing #include's)
pl
parents: 2469
diff changeset
9 #include <string.h>
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
10 #include "../config.h"
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
11 #include "swscale.h"
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
12
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
13 //#undef HAVE_MMX2
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
14 //#undef HAVE_MMX
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
15 //#undef ARCH_X86
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
16 #define DITHER1XBPP
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
17 int fullUVIpol=0;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
18 //disables the unscaled height version
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
19 int allwaysIpol=0;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
20
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
21 #define RET 0xC3 //near return opcode
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
22 /*
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
23 NOTES
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
24
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
25 known BUGS with known cause (no bugreports please!, but patches are welcome :) )
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
26 horizontal MMX2 scaler reads 1-7 samples too much (might cause a sig11)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
27
2326
7d3542955132 BGR24 bugfix
michael
parents: 2316
diff changeset
28 Supported output formats BGR15 BGR16 BGR24 BGR32
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
29 BGR15 & BGR16 MMX verions support dithering
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
30 Special versions: fast Y 1:1 scaling (no interpolation in y direction)
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
31
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
32 TODO
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
33 more intelligent missalignment avoidance for the horizontal scaler
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
34 */
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
35
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
36 #define ABS(a) ((a) > 0 ? (a) : (-(a)))
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
37 #define MIN(a,b) ((a) > (b) ? (b) : (a))
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
38 #define MAX(a,b) ((a) < (b) ? (b) : (a))
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
39
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
40 #ifdef HAVE_MMX2
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
41 #define PAVGB(a,b) "pavgb " #a ", " #b " \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
42 #elif defined (HAVE_3DNOW)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
43 #define PAVGB(a,b) "pavgusb " #a ", " #b " \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
44 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
45
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
46 #ifdef HAVE_MMX2
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
47 #define MOVNTQ(a,b) "movntq " #a ", " #b " \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
48 #else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
49 #define MOVNTQ(a,b) "movq " #a ", " #b " \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
50 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
51
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
52
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
53 #ifdef HAVE_MMX
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
54 static uint64_t __attribute__((aligned(8))) yCoeff= 0x2568256825682568LL;
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
55 static uint64_t __attribute__((aligned(8))) vrCoeff= 0x3343334333433343LL;
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
56 static uint64_t __attribute__((aligned(8))) ubCoeff= 0x40cf40cf40cf40cfLL;
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
57 static uint64_t __attribute__((aligned(8))) vgCoeff= 0xE5E2E5E2E5E2E5E2LL;
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
58 static uint64_t __attribute__((aligned(8))) ugCoeff= 0xF36EF36EF36EF36ELL;
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
59 static uint64_t __attribute__((aligned(8))) w400= 0x0400040004000400LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
60 static uint64_t __attribute__((aligned(8))) w80= 0x0080008000800080LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
61 static uint64_t __attribute__((aligned(8))) w10= 0x0010001000100010LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
62 static uint64_t __attribute__((aligned(8))) bm00001111=0x00000000FFFFFFFFLL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
63 static uint64_t __attribute__((aligned(8))) bm00000111=0x0000000000FFFFFFLL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
64 static uint64_t __attribute__((aligned(8))) bm11111000=0xFFFFFFFFFF000000LL;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
65
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
66 static uint64_t __attribute__((aligned(8))) b16Dither= 0x0004000400040004LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
67 static uint64_t __attribute__((aligned(8))) b16Dither1=0x0004000400040004LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
68 static uint64_t __attribute__((aligned(8))) b16Dither2=0x0602060206020602LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
69 static uint64_t __attribute__((aligned(8))) g16Dither= 0x0002000200020002LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
70 static uint64_t __attribute__((aligned(8))) g16Dither1=0x0002000200020002LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
71 static uint64_t __attribute__((aligned(8))) g16Dither2=0x0301030103010301LL;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
72
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
73 static uint64_t __attribute__((aligned(8))) b16Mask= 0x001F001F001F001FLL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
74 static uint64_t __attribute__((aligned(8))) g16Mask= 0x07E007E007E007E0LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
75 static uint64_t __attribute__((aligned(8))) r16Mask= 0xF800F800F800F800LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
76 static uint64_t __attribute__((aligned(8))) b15Mask= 0x001F001F001F001FLL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
77 static uint64_t __attribute__((aligned(8))) g15Mask= 0x03E003E003E003E0LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
78 static uint64_t __attribute__((aligned(8))) r15Mask= 0x7C007C007C007C00LL;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
79
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
80 static uint64_t __attribute__((aligned(8))) temp0;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
81 static uint64_t __attribute__((aligned(8))) asm_yalpha1;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
82 static uint64_t __attribute__((aligned(8))) asm_uvalpha1;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
83 #endif
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
84
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
85 // temporary storage for 4 yuv lines:
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
86 // 16bit for now (mmx likes it more compact)
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
87 #ifdef HAVE_MMX
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
88 static uint16_t __attribute__((aligned(8))) pix_buf_y[4][2048];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
89 static uint16_t __attribute__((aligned(8))) pix_buf_uv[2][2048*2];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
90 #else
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
91 static uint16_t pix_buf_y[4][2048];
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
92 static uint16_t pix_buf_uv[2][2048*2];
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
93 #endif
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
94
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
95 // clipping helper table for C implementations:
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
96 static unsigned char clip_table[768];
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
97
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
98 // yuv->rgb conversion tables:
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
99 static int yuvtab_2568[256];
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
100 static int yuvtab_3343[256];
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
101 static int yuvtab_0c92[256];
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
102 static int yuvtab_1a1e[256];
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
103 static int yuvtab_40cf[256];
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
104
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
105
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
106 static uint8_t funnyYCode[10000];
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
107 static uint8_t funnyUVCode[10000];
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
108
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
109 static int canMMX2BeUsed=0;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
110
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
111 #define FULL_YSCALEYUV2RGB \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
112 "pxor %%mm7, %%mm7 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
113 "movd %6, %%mm6 \n\t" /*yalpha1*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
114 "punpcklwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
115 "punpcklwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
116 "movd %7, %%mm5 \n\t" /*uvalpha1*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
117 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
118 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
119 "xorl %%eax, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
120 "1: \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
121 "movq (%0, %%eax, 2), %%mm0 \n\t" /*buf0[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
122 "movq (%1, %%eax, 2), %%mm1 \n\t" /*buf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
123 "movq (%2, %%eax,2), %%mm2 \n\t" /* uvbuf0[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
124 "movq (%3, %%eax,2), %%mm3 \n\t" /* uvbuf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
125 "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
126 "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
127 "pmulhw %%mm6, %%mm0 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
128 "pmulhw %%mm5, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
129 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
130 "movq 4096(%2, %%eax,2), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
131 "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
132 "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
133 "movq 4096(%3, %%eax,2), %%mm0 \n\t" /* uvbuf1[eax+2048]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
134 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
135 "psubw %%mm0, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
136 "psubw w80, %%mm1 \n\t" /* 8(Y-16)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
137 "psubw w400, %%mm3 \n\t" /* 8(U-128)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
138 "pmulhw yCoeff, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
139 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
140 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
141 "pmulhw %%mm5, %%mm4 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
142 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
143 "pmulhw ubCoeff, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
144 "psraw $4, %%mm0 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
145 "pmulhw ugCoeff, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
146 "paddw %%mm4, %%mm0 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
147 "psubw w400, %%mm0 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
148 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
149 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
150 "movq %%mm0, %%mm4 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
151 "pmulhw vrCoeff, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
152 "pmulhw vgCoeff, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
153 "paddw %%mm1, %%mm3 \n\t" /* B*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
154 "paddw %%mm1, %%mm0 \n\t" /* R*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
155 "packuswb %%mm3, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
156 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
157 "packuswb %%mm0, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
158 "paddw %%mm4, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
159 "paddw %%mm2, %%mm1 \n\t" /* G*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
160 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
161 "packuswb %%mm1, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
162
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
163 #define YSCALEYUV2RGB \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
164 "movd %6, %%mm6 \n\t" /*yalpha1*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
165 "punpcklwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
166 "punpcklwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
167 "movq %%mm6, asm_yalpha1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
168 "movd %7, %%mm5 \n\t" /*uvalpha1*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
169 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
170 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
171 "movq %%mm5, asm_uvalpha1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
172 "xorl %%eax, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
173 "1: \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
174 "movq (%2, %%eax), %%mm2 \n\t" /* uvbuf0[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
175 "movq (%3, %%eax), %%mm3 \n\t" /* uvbuf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
176 "movq 4096(%2, %%eax), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
177 "movq 4096(%3, %%eax), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
178 "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
179 "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
180 "movq asm_uvalpha1, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
181 "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
182 "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
183 "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
184 "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
185 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
186 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
187 "psubw w400, %%mm3 \n\t" /* (U-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
188 "psubw w400, %%mm4 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
189 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
190 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
191 "pmulhw ugCoeff, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
192 "pmulhw vgCoeff, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
193 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
194 "movq (%0, %%eax, 2), %%mm0 \n\t" /*buf0[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
195 "movq (%1, %%eax, 2), %%mm1 \n\t" /*buf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
196 "movq 8(%0, %%eax, 2), %%mm6 \n\t" /*buf0[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
197 "movq 8(%1, %%eax, 2), %%mm7 \n\t" /*buf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
198 "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
199 "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
200 "pmulhw asm_yalpha1, %%mm0 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
201 "pmulhw asm_yalpha1, %%mm6 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
202 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
203 "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
204 "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
205 "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
206 "pmulhw ubCoeff, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
207 "pmulhw vrCoeff, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
208 "psubw w80, %%mm1 \n\t" /* 8(Y-16)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
209 "psubw w80, %%mm7 \n\t" /* 8(Y-16)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
210 "pmulhw yCoeff, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
211 "pmulhw yCoeff, %%mm7 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
212 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
213 "paddw %%mm3, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
214 "movq %%mm2, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
215 "movq %%mm5, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
216 "movq %%mm4, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
217 "punpcklwd %%mm2, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
218 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
219 "punpcklwd %%mm4, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
220 "paddw %%mm1, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
221 "paddw %%mm1, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
222 "paddw %%mm1, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
223 "punpckhwd %%mm0, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
224 "punpckhwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
225 "punpckhwd %%mm3, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
226 "paddw %%mm7, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
227 "paddw %%mm7, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
228 "paddw %%mm7, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
229 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
230 "packuswb %%mm0, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
231 "packuswb %%mm6, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
232 "packuswb %%mm3, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
233 "pxor %%mm7, %%mm7 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
234
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
235 #define YSCALEYUV2RGB1 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
236 "xorl %%eax, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
237 "1: \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
238 "movq (%2, %%eax), %%mm3 \n\t" /* uvbuf0[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
239 "movq 4096(%2, %%eax), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
240 "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
241 "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
242 "psubw w400, %%mm3 \n\t" /* (U-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
243 "psubw w400, %%mm4 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
244 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
245 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
246 "pmulhw ugCoeff, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
247 "pmulhw vgCoeff, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
248 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
249 "movq (%1, %%eax, 2), %%mm1 \n\t" /*buf0[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
250 "movq 8(%1, %%eax, 2), %%mm7 \n\t" /*buf0[eax]*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
251 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
252 "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
253 "pmulhw ubCoeff, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
254 "pmulhw vrCoeff, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
255 "psubw w80, %%mm1 \n\t" /* 8(Y-16)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
256 "psubw w80, %%mm7 \n\t" /* 8(Y-16)*/\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
257 "pmulhw yCoeff, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
258 "pmulhw yCoeff, %%mm7 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
259 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
260 "paddw %%mm3, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
261 "movq %%mm2, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
262 "movq %%mm5, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
263 "movq %%mm4, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
264 "punpcklwd %%mm2, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
265 "punpcklwd %%mm5, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
266 "punpcklwd %%mm4, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
267 "paddw %%mm1, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
268 "paddw %%mm1, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
269 "paddw %%mm1, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
270 "punpckhwd %%mm0, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
271 "punpckhwd %%mm6, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
272 "punpckhwd %%mm3, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
273 "paddw %%mm7, %%mm0 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
274 "paddw %%mm7, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
275 "paddw %%mm7, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
276 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
277 "packuswb %%mm0, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
278 "packuswb %%mm6, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
279 "packuswb %%mm3, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
280 "pxor %%mm7, %%mm7 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
281
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
282 #define WRITEBGR32 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
283 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
284 "movq %%mm2, %%mm1 \n\t" /* B */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
285 "movq %%mm5, %%mm6 \n\t" /* R */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
286 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
287 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
288 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
289 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
290 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
291 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
292 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
293 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
294 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
295 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
296 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
297 MOVNTQ(%%mm0, (%4, %%eax, 4))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
298 MOVNTQ(%%mm2, 8(%4, %%eax, 4))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
299 MOVNTQ(%%mm1, 16(%4, %%eax, 4))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
300 MOVNTQ(%%mm3, 24(%4, %%eax, 4))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
301 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
302 "addl $8, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
303 "cmpl %5, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
304 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
305
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
306 #define WRITEBGR16 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
307 "movq %%mm2, %%mm1 \n\t" /* B */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
308 "movq %%mm4, %%mm3 \n\t" /* G */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
309 "movq %%mm5, %%mm6 \n\t" /* R */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
310 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
311 "punpcklbw %%mm7, %%mm3 \n\t" /* 0G0G0G0G */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
312 "punpcklbw %%mm7, %%mm2 \n\t" /* 0B0B0B0B */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
313 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
314 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
315 "psrlw $3, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
316 "psllw $3, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
317 "psllw $8, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
318 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
319 "pand g16Mask, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
320 "pand r16Mask, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
321 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
322 "por %%mm3, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
323 "por %%mm5, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
324 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
325 "punpckhbw %%mm7, %%mm4 \n\t" /* 0G0G0G0G */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
326 "punpckhbw %%mm7, %%mm1 \n\t" /* 0B0B0B0B */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
327 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
328 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
329 "psrlw $3, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
330 "psllw $3, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
331 "psllw $8, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
332 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
333 "pand g16Mask, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
334 "pand r16Mask, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
335 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
336 "por %%mm4, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
337 "por %%mm6, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
338 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
339 MOVNTQ(%%mm2, (%4, %%eax, 2))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
340 MOVNTQ(%%mm1, 8(%4, %%eax, 2))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
341 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
342 "addl $8, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
343 "cmpl %5, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
344 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
345
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
346 #define WRITEBGR15 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
347 "movq %%mm2, %%mm1 \n\t" /* B */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
348 "movq %%mm4, %%mm3 \n\t" /* G */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
349 "movq %%mm5, %%mm6 \n\t" /* R */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
350 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
351 "punpcklbw %%mm7, %%mm3 \n\t" /* 0G0G0G0G */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
352 "punpcklbw %%mm7, %%mm2 \n\t" /* 0B0B0B0B */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
353 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
354 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
355 "psrlw $3, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
356 "psllw $2, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
357 "psllw $7, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
358 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
359 "pand g15Mask, %%mm3 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
360 "pand r15Mask, %%mm5 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
361 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
362 "por %%mm3, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
363 "por %%mm5, %%mm2 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
364 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
365 "punpckhbw %%mm7, %%mm4 \n\t" /* 0G0G0G0G */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
366 "punpckhbw %%mm7, %%mm1 \n\t" /* 0B0B0B0B */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
367 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
368 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
369 "psrlw $3, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
370 "psllw $2, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
371 "psllw $7, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
372 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
373 "pand g15Mask, %%mm4 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
374 "pand r15Mask, %%mm6 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
375 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
376 "por %%mm4, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
377 "por %%mm6, %%mm1 \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
378 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
379 MOVNTQ(%%mm2, (%4, %%eax, 2))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
380 MOVNTQ(%%mm1, 8(%4, %%eax, 2))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
381 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
382 "addl $8, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
383 "cmpl %5, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
384 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
385 // FIXME find a faster way to shuffle it to BGR24
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
386 #define WRITEBGR24 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
387 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
388 "movq %%mm2, %%mm1 \n\t" /* B */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
389 "movq %%mm5, %%mm6 \n\t" /* R */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
390 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
391 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
392 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
393 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
394 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
395 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\
2326
7d3542955132 BGR24 bugfix
michael
parents: 2316
diff changeset
396 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\
7d3542955132 BGR24 bugfix
michael
parents: 2316
diff changeset
397 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\
7d3542955132 BGR24 bugfix
michael
parents: 2316
diff changeset
398 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\
7d3542955132 BGR24 bugfix
michael
parents: 2316
diff changeset
399 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
400 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
401 "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
402 "psrlq $8, %%mm0 \n\t" /* 00RGB0RG 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
403 "pand bm00000111, %%mm4 \n\t" /* 00000RGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
404 "pand bm11111000, %%mm0 \n\t" /* 00RGB000 0.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
405 "por %%mm4, %%mm0 \n\t" /* 00RGBRGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
406 "movq %%mm2, %%mm4 \n\t" /* 0RGB0RGB 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
407 "psllq $48, %%mm2 \n\t" /* GB000000 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
408 "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
409 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
410 "movq %%mm4, %%mm2 \n\t" /* 0RGB0RGB 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
411 "psrld $16, %%mm4 \n\t" /* 000R000R 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
412 "psrlq $24, %%mm2 \n\t" /* 0000RGB0 1.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
413 "por %%mm4, %%mm2 \n\t" /* 000RRGBR 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
414 "pand bm00001111, %%mm2 \n\t" /* 0000RGBR 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
415 "movq %%mm1, %%mm4 \n\t" /* 0RGB0RGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
416 "psrlq $8, %%mm1 \n\t" /* 00RGB0RG 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
417 "pand bm00000111, %%mm4 \n\t" /* 00000RGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
418 "pand bm11111000, %%mm1 \n\t" /* 00RGB000 2.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
419 "por %%mm4, %%mm1 \n\t" /* 00RGBRGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
420 "movq %%mm1, %%mm4 \n\t" /* 00RGBRGB 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
421 "psllq $32, %%mm1 \n\t" /* BRGB0000 2 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
422 "por %%mm1, %%mm2 \n\t" /* BRGBRGBR 1 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
423 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
424 "psrlq $32, %%mm4 \n\t" /* 000000RG 2.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
425 "movq %%mm3, %%mm5 \n\t" /* 0RGB0RGB 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
426 "psrlq $8, %%mm3 \n\t" /* 00RGB0RG 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
427 "pand bm00000111, %%mm5 \n\t" /* 00000RGB 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
428 "pand bm11111000, %%mm3 \n\t" /* 00RGB000 3.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
429 "por %%mm5, %%mm3 \n\t" /* 00RGBRGB 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
430 "psllq $16, %%mm3 \n\t" /* RGBRGB00 3 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
431 "por %%mm4, %%mm3 \n\t" /* RGBRGBRG 2.5 */\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
432 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
433 "leal (%%eax, %%eax, 2), %%ebx \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
434 MOVNTQ(%%mm0, (%4, %%ebx))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
435 MOVNTQ(%%mm2, 8(%4, %%ebx))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
436 MOVNTQ(%%mm3, 16(%4, %%ebx))\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
437 \
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
438 "addl $8, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
439 "cmpl %5, %%eax \n\t"\
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
440 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
441
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
442
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
443 /**
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
444 * vertical scale YV12 to RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
445 */
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
446 static inline void yuv2rgbX(uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
447 uint8_t *dest, int dstw, int yalpha, int uvalpha, int dstbpp)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
448 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
449 int yalpha1=yalpha^4095;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
450 int uvalpha1=uvalpha^4095;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
451 int i;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
452
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
453 if(fullUVIpol)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
454 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
455
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
456 #ifdef HAVE_MMX
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
457 if(dstbpp == 32)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
458 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
459 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
460
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
461
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
462 FULL_YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
463 "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
464 "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
465
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
466 "movq %%mm3, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
467 "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
468 "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
469
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
470 MOVNTQ(%%mm3, (%4, %%eax, 4))
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
471 MOVNTQ(%%mm1, 8(%4, %%eax, 4))
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
472
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
473 "addl $4, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
474 "cmpl %5, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
475 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
476
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
477
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
478 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
479 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
480 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
481 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
482 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
483 else if(dstbpp==24)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
484 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
485 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
486
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
487 FULL_YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
488
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
489 // lsb ... msb
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
490 "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
491 "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
492
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
493 "movq %%mm3, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
494 "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
495 "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
496
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
497 "movq %%mm3, %%mm2 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
498 "psrlq $8, %%mm3 \n\t" // GR0BGR00
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
499 "pand bm00000111, %%mm2 \n\t" // BGR00000
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
500 "pand bm11111000, %%mm3 \n\t" // 000BGR00
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
501 "por %%mm2, %%mm3 \n\t" // BGRBGR00
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
502 "movq %%mm1, %%mm2 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
503 "psllq $48, %%mm1 \n\t" // 000000BG
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
504 "por %%mm1, %%mm3 \n\t" // BGRBGRBG
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
505
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
506 "movq %%mm2, %%mm1 \n\t" // BGR0BGR0
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
507 "psrld $16, %%mm2 \n\t" // R000R000
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
508 "psrlq $24, %%mm1 \n\t" // 0BGR0000
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
509 "por %%mm2, %%mm1 \n\t" // RBGRR000
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
510
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
511 "movl %4, %%ebx \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
512 "addl %%eax, %%ebx \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
513
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
514 #ifdef HAVE_MMX2
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
515 //FIXME Alignment
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
516 "movntq %%mm3, (%%ebx, %%eax, 2)\n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
517 "movntq %%mm1, 8(%%ebx, %%eax, 2)\n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
518 #else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
519 "movd %%mm3, (%%ebx, %%eax, 2) \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
520 "psrlq $32, %%mm3 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
521 "movd %%mm3, 4(%%ebx, %%eax, 2) \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
522 "movd %%mm1, 8(%%ebx, %%eax, 2) \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
523 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
524 "addl $4, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
525 "cmpl %5, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
526 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
527
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
528 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
529 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
530 : "%eax", "%ebx"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
531 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
532 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
533 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
534 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
535 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
536
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
537 FULL_YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
538 #ifdef DITHER1XBPP
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
539 "paddusb b16Dither, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
540 "paddusb b16Dither, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
541 "paddusb b16Dither, %%mm3 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
542 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
543 "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
544 "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
545 "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
546
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
547 "psrlw $3, %%mm3 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
548 "psllw $2, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
549 "psllw $7, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
550 "pand g15Mask, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
551 "pand r15Mask, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
552
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
553 "por %%mm3, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
554 "por %%mm1, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
555
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
556 MOVNTQ(%%mm0, (%4, %%eax, 2))
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
557
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
558 "addl $4, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
559 "cmpl %5, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
560 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
561
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
562 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
563 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
564 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
565 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
566 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
567 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
568 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
569 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
570
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
571 FULL_YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
572 #ifdef DITHER1XBPP
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
573 "paddusb g16Dither, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
574 "paddusb b16Dither, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
575 "paddusb b16Dither, %%mm3 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
576 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
577 "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
578 "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
579 "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
580
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
581 "psrlw $3, %%mm3 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
582 "psllw $3, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
583 "psllw $8, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
584 "pand g16Mask, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
585 "pand r16Mask, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
586
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
587 "por %%mm3, %%mm1 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
588 "por %%mm1, %%mm0 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
589
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
590 MOVNTQ(%%mm0, (%4, %%eax, 2))
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
591
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
592 "addl $4, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
593 "cmpl %5, %%eax \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
594 " jb 1b \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
595
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
596 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
597 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
598 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
599 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
600 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
601 #else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
602 if(dstbpp==32 || dstbpp==24)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
603 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
604 for(i=0;i<dstw;i++){
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
605 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
606 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
607 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
608 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
609 dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
610 dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
611 dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
612 dest+=dstbpp>>3;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
613 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
614 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
615 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
616 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
617 for(i=0;i<dstw;i++){
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
618 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
619 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
620 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
621 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
622
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
623 ((uint16_t*)dest)[0] =
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
624 (clip_table[(Y + yuvtab_40cf[U]) >>13]>>3) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
625 ((clip_table[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13]<<3)&0x07E0) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
626 ((clip_table[(Y + yuvtab_3343[V]) >>13]<<8)&0xF800);
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
627 dest+=2;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
628 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
629 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
630 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
631 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
632 for(i=0;i<dstw;i++){
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
633 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
634 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
635 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
636 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
637
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
638 ((uint16_t*)dest)[0] =
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
639 (clip_table[(Y + yuvtab_40cf[U]) >>13]>>3) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
640 ((clip_table[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13]<<2)&0x03E0) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
641 ((clip_table[(Y + yuvtab_3343[V]) >>13]<<7)&0x7C00);
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
642 dest+=2;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
643 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
644 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
645 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
646 }//FULL_UV_IPOL
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
647 else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
648 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
649 #ifdef HAVE_MMX
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
650 if(dstbpp == 32)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
651 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
652 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
653 YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
654 WRITEBGR32
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
655
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
656 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
657 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
658 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
659 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
660 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
661 else if(dstbpp==24)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
662 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
663 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
664 YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
665 WRITEBGR24
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
666
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
667 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
668 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
669 : "%eax", "%ebx"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
670 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
671 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
672 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
673 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
674 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
675 YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
676 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
677 #ifdef DITHER1XBPP
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
678 "paddusb b16Dither, %%mm2 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
679 "paddusb b16Dither, %%mm4 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
680 "paddusb b16Dither, %%mm5 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
681 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
682
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
683 WRITEBGR15
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
684
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
685 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
686 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
687 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
688 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
689 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
690 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
691 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
692 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
693 YSCALEYUV2RGB
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
694 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
695 #ifdef DITHER1XBPP
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
696 "paddusb g16Dither, %%mm2 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
697 "paddusb b16Dither, %%mm4 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
698 "paddusb b16Dither, %%mm5 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
699 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
700
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
701 WRITEBGR16
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
702
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
703 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
704 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
705 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
706 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
707 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
708 #else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
709 //FIXME unroll C loop and dont recalculate UV
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
710 if(dstbpp==32 || dstbpp==24)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
711 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
712 for(i=0;i<dstw;i++){
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
713 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
714 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
715 int U=((uvbuf0[i/2]*uvalpha1+uvbuf1[i/2]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
716 int V=((uvbuf0[i/2+2048]*uvalpha1+uvbuf1[i/2+2048]*uvalpha)>>19);
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
717 dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
718 dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
719 dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
720 dest+=dstbpp>>3;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
721 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
722 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
723 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
724 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
725 for(i=0;i<dstw;i++){
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
726 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
727 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
728 int U=((uvbuf0[i/2]*uvalpha1+uvbuf1[i/2]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
729 int V=((uvbuf0[i/2+2048]*uvalpha1+uvbuf1[i/2+2048]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
730
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
731 ((uint16_t*)dest)[0] =
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
732 (clip_table[(Y + yuvtab_40cf[U]) >>13]>>3) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
733 ((clip_table[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13]<<3)&0x07E0) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
734 ((clip_table[(Y + yuvtab_3343[V]) >>13]<<8)&0xF800);
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
735 dest+=2;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
736 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
737 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
738 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
739 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
740 for(i=0;i<dstw;i++){
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
741 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
742 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
743 int U=((uvbuf0[i/2]*uvalpha1+uvbuf1[i/2]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
744 int V=((uvbuf0[i/2+2048]*uvalpha1+uvbuf1[i/2+2048]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
745
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
746 ((uint16_t*)dest)[0] =
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
747 (clip_table[(Y + yuvtab_40cf[U]) >>13]>>3) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
748 ((clip_table[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13]<<2)&0x03E0) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
749 ((clip_table[(Y + yuvtab_3343[V]) >>13]<<7)&0x7C00);
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
750 dest+=2;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
751 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
752 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
753 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
754 } //!FULL_UV_IPOL
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
755 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
756
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
757 /**
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
758 * YV12 to RGB without scaling or interpolating
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
759 */
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
760 static inline void yuv2rgb1(uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
761 uint8_t *dest, int dstw, int yalpha, int uvalpha, int dstbpp)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
762 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
763 int yalpha1=yalpha^4095;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
764 int uvalpha1=uvalpha^4095;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
765 int i;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
766 if(fullUVIpol || allwaysIpol)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
767 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
768 yuv2rgbX(buf0, buf1, uvbuf0, uvbuf1, dest, dstw, yalpha, uvalpha, dstbpp);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
769 return;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
770 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
771 #ifdef HAVE_MMX
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
772 if(dstbpp == 32)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
773 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
774 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
775 YSCALEYUV2RGB1
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
776 WRITEBGR32
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
777 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
778 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
779 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
780 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
781 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
782 else if(dstbpp==24)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
783 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
784 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
785 YSCALEYUV2RGB1
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
786 WRITEBGR24
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
787 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
788 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
789 : "%eax", "%ebx"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
790 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
791 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
792 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
793 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
794 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
795 YSCALEYUV2RGB1
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
796 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
797 #ifdef DITHER1XBPP
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
798 "paddusb b16Dither, %%mm2 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
799 "paddusb b16Dither, %%mm4 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
800 "paddusb b16Dither, %%mm5 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
801 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
802 WRITEBGR15
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
803 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
804 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
805 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
806 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
807 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
808 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
809 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
810 asm volatile(
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
811 YSCALEYUV2RGB1
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
812 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
813 #ifdef DITHER1XBPP
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
814 "paddusb g16Dither, %%mm2 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
815 "paddusb b16Dither, %%mm4 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
816 "paddusb b16Dither, %%mm5 \n\t"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
817 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
818
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
819 WRITEBGR16
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
820 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstw),
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
821 "m" (yalpha1), "m" (uvalpha1)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
822 : "%eax"
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
823 );
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
824 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
825 #else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
826 //FIXME unroll C loop and dont recalculate UV
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
827 if(dstbpp==32 || dstbpp==24)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
828 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
829 for(i=0;i<dstw;i++){
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
830 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
831 int Y=yuvtab_2568[buf0[i]>>7];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
832 int U=((uvbuf0[i/2]*uvalpha1+uvbuf1[i/2]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
833 int V=((uvbuf0[i/2+2048]*uvalpha1+uvbuf1[i/2+2048]*uvalpha)>>19);
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
834 dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)];
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
835 dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)];
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
836 dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)];
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
837 dest+=dstbpp>>3;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
838 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
839 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
840 else if(dstbpp==16)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
841 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
842 for(i=0;i<dstw;i++){
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
843 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
844 int Y=yuvtab_2568[buf0[i]>>7];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
845 int U=((uvbuf0[i/2]*uvalpha1+uvbuf1[i/2]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
846 int V=((uvbuf0[i/2+2048]*uvalpha1+uvbuf1[i/2+2048]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
847
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
848 ((uint16_t*)dest)[0] =
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
849 (clip_table[(Y + yuvtab_40cf[U]) >>13]>>3) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
850 ((clip_table[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13]<<3)&0x07E0) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
851 ((clip_table[(Y + yuvtab_3343[V]) >>13]<<8)&0xF800);
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
852 dest+=2;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
853 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
854 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
855 else if(dstbpp==15)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
856 {
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
857 for(i=0;i<dstw;i++){
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
858 // vertical linear interpolation && yuv2rgb in a single step:
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
859 int Y=yuvtab_2568[buf0[i]>>7];
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
860 int U=((uvbuf0[i/2]*uvalpha1+uvbuf1[i/2]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
861 int V=((uvbuf0[i/2+2048]*uvalpha1+uvbuf1[i/2+2048]*uvalpha)>>19);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
862
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
863 ((uint16_t*)dest)[0] =
2503
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
864 (clip_table[(Y + yuvtab_40cf[U]) >>13]>>3) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
865 ((clip_table[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13]<<2)&0x03E0) |
d21d8d5f2e23 yuv2rgb bugfix
michael
parents: 2476
diff changeset
866 ((clip_table[(Y + yuvtab_3343[V]) >>13]<<7)&0x7C00);
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
867 dest+=2;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
868 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
869 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
870 #endif
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
871 }
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
872
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
873
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
874 static inline void hyscale(uint16_t *dst, int dstWidth, uint8_t *src, int srcWidth, int xInc)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
875 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
876 int i;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
877 unsigned int xpos=0;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
878 // *** horizontal scale Y line to temp buffer
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
879 #ifdef ARCH_X86
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
880
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
881 #ifdef HAVE_MMX2
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
882 if(canMMX2BeUsed)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
883 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
884 asm volatile(
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
885 "pxor %%mm7, %%mm7 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
886 "pxor %%mm2, %%mm2 \n\t" // 2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
887 "movd %5, %%mm6 \n\t" // xInc&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
888 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
889 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
890 "movq %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
891 "psllq $16, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
892 "paddw %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
893 "psllq $16, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
894 "paddw %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
895 "psllq $16, %%mm2 \n\t" //0,t,2t,3t t=xInc&0xFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
896 "movq %%mm2, temp0 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
897 "movd %4, %%mm6 \n\t" //(xInc*4)&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
898 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
899 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
900 "xorl %%eax, %%eax \n\t" // i
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
901 "movl %0, %%esi \n\t" // src
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
902 "movl %1, %%edi \n\t" // buf1
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
903 "movl %3, %%edx \n\t" // (xInc*4)>>16
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
904 "xorl %%ecx, %%ecx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
905 "xorl %%ebx, %%ebx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
906 "movw %4, %%bx \n\t" // (xInc*4)&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
907 #ifdef HAVE_MMX2
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
908 #define FUNNY_Y_CODE \
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
909 "prefetchnta 1024(%%esi) \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
910 "prefetchnta 1056(%%esi) \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
911 "prefetchnta 1088(%%esi) \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
912 "call funnyYCode \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
913 "movq temp0, %%mm2 \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
914 "xorl %%ecx, %%ecx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
915 #else
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
916 #define FUNNY_Y_CODE \
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
917 "call funnyYCode \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
918 "movq temp0, %%mm2 \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
919 "xorl %%ecx, %%ecx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
920 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
921 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
922 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
923 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
924 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
925 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
926 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
927 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
928 FUNNY_Y_CODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
929
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
930 :: "m" (src), "m" (dst), "m" (dstWidth), "m" ((xInc*4)>>16),
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
931 "m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
932 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
933 );
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
934 for(i=dstWidth-1; (i*xInc)>>16 >=srcWidth-1; i--) dst[i] = src[srcWidth-1]*128;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
935 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
936 else
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
937 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
938 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
939 //NO MMX just normal asm ...
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
940 asm volatile(
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
941 "xorl %%eax, %%eax \n\t" // i
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
942 "xorl %%ebx, %%ebx \n\t" // xx
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
943 "xorl %%ecx, %%ecx \n\t" // 2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
944 "1: \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
945 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
946 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
947 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
948 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
949 "shll $16, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
950 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
951 "movl %1, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
952 "shrl $9, %%esi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
953 "movw %%si, (%%edi, %%eax, 2) \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
954 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
955 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
956
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
957 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
958 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
959 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
960 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
961 "shll $16, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
962 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
963 "movl %1, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
964 "shrl $9, %%esi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
965 "movw %%si, 2(%%edi, %%eax, 2) \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
966 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
967 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
968
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
969
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
970 "addl $2, %%eax \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
971 "cmpl %2, %%eax \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
972 " jb 1b \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
973
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
974
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
975 :: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
976 : "%eax", "%ebx", "%ecx", "%edi", "%esi"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
977 );
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
978 #ifdef HAVE_MMX2
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
979 } //if MMX2 cant be used
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
980 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
981 #else
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
982 for(i=0;i<dstWidth;i++){
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
983 register unsigned int xx=xpos>>16;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
984 register unsigned int xalpha=(xpos&0xFFFF)>>9;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
985 dst[i]=(src[xx]*(xalpha^127)+src[xx+1]*xalpha);
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
986 xpos+=xInc;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
987 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
988 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
989 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
990
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
991 inline static void hcscale(uint16_t *dst, int dstWidth,
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
992 uint8_t *src1, uint8_t *src2, int srcWidth, int xInc)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
993 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
994 int xpos=0;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
995 int i;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
996 #ifdef ARCH_X86
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
997 #ifdef HAVE_MMX2
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
998 if(canMMX2BeUsed)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
999 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1000 asm volatile(
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1001 "pxor %%mm7, %%mm7 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1002 "pxor %%mm2, %%mm2 \n\t" // 2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1003 "movd %5, %%mm6 \n\t" // xInc&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1004 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1005 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1006 "movq %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1007 "psllq $16, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1008 "paddw %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1009 "psllq $16, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1010 "paddw %%mm6, %%mm2 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1011 "psllq $16, %%mm2 \n\t" //0,t,2t,3t t=xInc&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1012 "movq %%mm2, temp0 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1013 "movd %4, %%mm6 \n\t" //(xInc*4)&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1014 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1015 "punpcklwd %%mm6, %%mm6 \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1016 "xorl %%eax, %%eax \n\t" // i
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1017 "movl %0, %%esi \n\t" // src
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1018 "movl %1, %%edi \n\t" // buf1
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1019 "movl %3, %%edx \n\t" // (xInc*4)>>16
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1020 "xorl %%ecx, %%ecx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1021 "xorl %%ebx, %%ebx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1022 "movw %4, %%bx \n\t" // (xInc*4)&0xFFFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1023
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1024 #ifdef HAVE_MMX2
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1025 #define FUNNYUVCODE \
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1026 "prefetchnta 1024(%%esi) \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1027 "prefetchnta 1056(%%esi) \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1028 "prefetchnta 1088(%%esi) \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1029 "call funnyUVCode \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1030 "movq temp0, %%mm2 \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1031 "xorl %%ecx, %%ecx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1032 #else
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1033 #define FUNNYUVCODE \
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1034 "call funnyUVCode \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1035 "movq temp0, %%mm2 \n\t"\
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1036 "xorl %%ecx, %%ecx \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1037 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1038
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1039 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1040 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1041 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1042 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1043
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1044 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1045 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1046 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1047 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1048
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1049
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1050 "xorl %%eax, %%eax \n\t" // i
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1051 "movl %6, %%esi \n\t" // src
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1052 "movl %1, %%edi \n\t" // buf1
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1053 "addl $4096, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1054
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1055 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1056 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1057 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1058 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1059
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1060 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1061 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1062 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1063 FUNNYUVCODE
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1064
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1065 :: "m" (src1), "m" (dst), "m" (dstWidth), "m" ((xInc*4)>>16),
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1066 "m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF), "m" (src2)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1067 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1068 );
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1069 for(i=dstWidth-1; (i*xInc)>>16 >=srcWidth/2-1; i--)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1070 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1071 dst[i] = src1[srcWidth/2-1]*128;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1072 dst[i+2048] = src2[srcWidth/2-1]*128;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1073 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1074 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1075 else
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1076 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1077 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1078 asm volatile(
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1079 "xorl %%eax, %%eax \n\t" // i
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1080 "xorl %%ebx, %%ebx \n\t" // xx
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1081 "xorl %%ecx, %%ecx \n\t" // 2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1082 "1: \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1083 "movl %0, %%esi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1084 "movzbl (%%esi, %%ebx), %%edi \n\t" //src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1085 "movzbl 1(%%esi, %%ebx), %%esi \n\t" //src[xx+1]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1086 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1087 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1088 "shll $16, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1089 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1090 "movl %1, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1091 "shrl $9, %%esi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1092 "movw %%si, (%%edi, %%eax, 2) \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1093
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1094 "movzbl (%5, %%ebx), %%edi \n\t" //src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1095 "movzbl 1(%5, %%ebx), %%esi \n\t" //src[xx+1]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1096 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1097 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1098 "shll $16, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1099 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1100 "movl %1, %%edi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1101 "shrl $9, %%esi \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1102 "movw %%si, 4096(%%edi, %%eax, 2)\n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1103
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1104 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1105 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1106 "addl $1, %%eax \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1107 "cmpl %2, %%eax \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1108 " jb 1b \n\t"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1109
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1110 :: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF),
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1111 "r" (src2)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1112 : "%eax", "%ebx", "%ecx", "%edi", "%esi"
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1113 );
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1114 #ifdef HAVE_MMX2
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1115 } //if MMX2 cant be used
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1116 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1117 #else
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1118 for(i=0;i<dstWidth;i++){
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1119 register unsigned int xx=xpos>>16;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1120 register unsigned int xalpha=(xpos&0xFFFF)>>9;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1121 dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1122 dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1123 xpos+=xInc;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1124 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1125 #endif
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1126 }
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1127
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1128
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1129 // *** bilinear scaling and yuv->rgb conversion of yv12 slices:
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1130 // *** Note: it's called multiple times while decoding a frame, first time y==0
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1131 // *** Designed to upscale, but may work for downscale too.
2274
9ee34c6950e0 xinc scaled by 16 instead of 8
arpi
parents: 2271
diff changeset
1132 // s_xinc = (src_width << 16) / dst_width
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1133 // s_yinc = (src_height << 16) / dst_height
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1134 void SwScale_YV12slice_brg24(unsigned char* srcptr[],int stride[], int y, int h,
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1135 unsigned char* dstptr, int dststride, int dstw, int dstbpp,
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1136 unsigned int s_xinc,unsigned int s_yinc){
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1137
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1138 // scaling factors:
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1139 //static int s_yinc=(vo_dga_src_height<<16)/vo_dga_vp_height;
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1140 //static int s_xinc=(vo_dga_src_width<<8)/vo_dga_vp_width;
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1141
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1142 unsigned int s_xinc2;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1143
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1144 static int s_srcypos; // points to the dst Pixels center in the source (0 is the center of pixel 0,0 in src)
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1145 static int s_ypos;
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1146
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1147 // last horzontally interpolated lines, used to avoid unnecessary calculations
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1148 static int s_last_ypos;
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1149 static int s_last_y1pos;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1150
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1151 static int static_dstw;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1152
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1153 #ifdef HAVE_MMX2
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1154 // used to detect a horizontal size change
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1155 static int old_dstw= -1;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1156 static int old_s_xinc= -1;
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1157 #endif
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1158
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1159 int srcWidth= (dstw*s_xinc + 0x8000)>>16;
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1160 int dstUVw= fullUVIpol ? dstw : dstw/2;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1161
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1162
2270
56ca174d8169 vertical lines bugfix
michael
parents: 2269
diff changeset
1163 #ifdef HAVE_MMX2
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1164 canMMX2BeUsed= (s_xinc <= 0x10000 && (dstw&31)==0 && (srcWidth&15)==0) ? 1 : 0;
2270
56ca174d8169 vertical lines bugfix
michael
parents: 2269
diff changeset
1165 #endif
56ca174d8169 vertical lines bugfix
michael
parents: 2269
diff changeset
1166
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1167 // match pixel 0 of the src to pixel 0 of dst and match pixel n-2 of src to pixel n-2 of dst
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1168 // n-2 is the last chrominance sample available
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1169 // FIXME this is not perfect, but noone shuld notice the difference, the more correct variant
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1170 // would be like the vertical one, but that would require some special code for the
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1171 // first and last pixel
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1172 if(canMMX2BeUsed) s_xinc+= 20;
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1173 else s_xinc = ((srcWidth-2)<<16)/(dstw-2) - 20;
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1174
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1175 if(fullUVIpol) s_xinc2= s_xinc>>1;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1176 else s_xinc2= s_xinc;
2271
a8d57bbc4413 horizontal lines bugfix
michael
parents: 2270
diff changeset
1177 // force calculation of the horizontal interpolation of the first line
a8d57bbc4413 horizontal lines bugfix
michael
parents: 2270
diff changeset
1178
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1179 if(y==0){
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1180 s_last_ypos=-99;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1181 s_last_y1pos=-99;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1182 s_srcypos= s_yinc/2 - 0x8000;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1183 s_ypos=0;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1184 #ifdef HAVE_MMX2
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1185 // cant downscale !!!
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1186 if((old_s_xinc != s_xinc || old_dstw!=dstw) && canMMX2BeUsed)
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1187 {
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1188 uint8_t *fragment;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1189 int imm8OfPShufW1;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1190 int imm8OfPShufW2;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1191 int fragmentLength;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1192
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1193 int xpos, xx, xalpha, i;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1194
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1195 old_s_xinc= s_xinc;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1196 old_dstw= dstw;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1197
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1198 static_dstw= dstw;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1199
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1200 // create an optimized horizontal scaling routine
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1201
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1202 //code fragment
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1203
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1204 asm volatile(
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1205 "jmp 9f \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1206 // Begin
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1207 "0: \n\t"
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1208 "movq (%%esi), %%mm0 \n\t" //FIXME Alignment
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1209 "movq %%mm0, %%mm1 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1210 "psrlq $8, %%mm0 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1211 "punpcklbw %%mm7, %%mm1 \n\t"
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1212 "movq %%mm2, %%mm3 \n\t"
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1213 "punpcklbw %%mm7, %%mm0 \n\t"
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1214 "addw %%bx, %%cx \n\t" //2*xalpha += (4*s_xinc)&0xFFFF
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1215 "pshufw $0xFF, %%mm1, %%mm1 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1216 "1: \n\t"
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1217 "adcl %%edx, %%esi \n\t" //xx+= (4*s_xinc)>>16 + carry
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1218 "pshufw $0xFF, %%mm0, %%mm0 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1219 "2: \n\t"
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1220 "psrlw $9, %%mm3 \n\t"
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1221 "psubw %%mm1, %%mm0 \n\t"
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1222 "pmullw %%mm3, %%mm0 \n\t"
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1223 "paddw %%mm6, %%mm2 \n\t" // 2*alpha += xpos&0xFFFF
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1224 "psllw $7, %%mm1 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1225 "paddw %%mm1, %%mm0 \n\t"
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1226
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1227 "movq %%mm0, (%%edi, %%eax) \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1228
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1229 "addl $8, %%eax \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1230 // End
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1231 "9: \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1232 // "int $3\n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1233 "leal 0b, %0 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1234 "leal 1b, %1 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1235 "leal 2b, %2 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1236 "decl %1 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1237 "decl %2 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1238 "subl %0, %1 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1239 "subl %0, %2 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1240 "leal 9b, %3 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1241 "subl %0, %3 \n\t"
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1242 :"=r" (fragment), "=r" (imm8OfPShufW1), "=r" (imm8OfPShufW2),
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1243 "=r" (fragmentLength)
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1244 );
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1245
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1246 xpos= 0; //s_xinc/2 - 0x8000; // difference between pixel centers
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1247
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1248 /* choose xinc so that all 8 parts fit exactly
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1249 Note: we cannot use just 1 part because it would not fit in the code cache */
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1250 // s_xinc2_diff= -((((s_xinc2*(dstw/8))&0xFFFF))/(dstw/8))-10;
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1251 // s_xinc_diff= -((((s_xinc*(dstw/8))&0xFFFF))/(dstw/8));
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1252 #ifdef ALT_ERROR
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1253 // s_xinc2_diff+= ((0x10000/(dstw/8)));
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1254 #endif
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1255 // s_xinc_diff= s_xinc2_diff*2;
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1256
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1257 // s_xinc2+= s_xinc2_diff;
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1258 // s_xinc+= s_xinc_diff;
2270
56ca174d8169 vertical lines bugfix
michael
parents: 2269
diff changeset
1259
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1260 // old_s_xinc= s_xinc;
2270
56ca174d8169 vertical lines bugfix
michael
parents: 2269
diff changeset
1261
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1262 for(i=0; i<dstw/8; i++)
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1263 {
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1264 int xx=xpos>>16;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1265
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1266 if((i&3) == 0)
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1267 {
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1268 int a=0;
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1269 int b=((xpos+s_xinc)>>16) - xx;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1270 int c=((xpos+s_xinc*2)>>16) - xx;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1271 int d=((xpos+s_xinc*3)>>16) - xx;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1272
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1273 memcpy(funnyYCode + fragmentLength*i/4, fragment, fragmentLength);
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1274
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1275 funnyYCode[fragmentLength*i/4 + imm8OfPShufW1]=
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1276 funnyYCode[fragmentLength*i/4 + imm8OfPShufW2]=
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1277 a | (b<<2) | (c<<4) | (d<<6);
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1278
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1279 // if we dont need to read 8 bytes than dont :), reduces the chance of
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1280 // crossing a cache line
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1281 if(d<3) funnyYCode[fragmentLength*i/4 + 1]= 0x6E;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1282
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1283 funnyYCode[fragmentLength*(i+4)/4]= RET;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1284 }
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1285 xpos+=s_xinc;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1286 }
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1287
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1288 xpos= 0; //s_xinc2/2 - 0x10000; // difference between centers of chrom samples
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1289 for(i=0; i<dstUVw/8; i++)
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1290 {
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1291 int xx=xpos>>16;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1292
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1293 if((i&3) == 0)
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1294 {
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1295 int a=0;
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1296 int b=((xpos+s_xinc2)>>16) - xx;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1297 int c=((xpos+s_xinc2*2)>>16) - xx;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1298 int d=((xpos+s_xinc2*3)>>16) - xx;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1299
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1300 memcpy(funnyUVCode + fragmentLength*i/4, fragment, fragmentLength);
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1301
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1302 funnyUVCode[fragmentLength*i/4 + imm8OfPShufW1]=
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1303 funnyUVCode[fragmentLength*i/4 + imm8OfPShufW2]=
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1304 a | (b<<2) | (c<<4) | (d<<6);
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1305
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1306 // if we dont need to read 8 bytes than dont :), reduces the chance of
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1307 // crossing a cache line
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1308 if(d<3) funnyUVCode[fragmentLength*i/4 + 1]= 0x6E;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1309
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1310 funnyUVCode[fragmentLength*(i+4)/4]= RET;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1311 }
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1312 xpos+=s_xinc2;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1313 }
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1314 // funnyCode[0]= RET;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1315 }
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1316
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1317 #endif // HAVE_MMX2
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1318 } // reset counters
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1319
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1320 while(1){
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1321 unsigned char *dest=dstptr+dststride*s_ypos;
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1322 int y0=(s_srcypos + 0xFFFF)>>16; // first luminance source line number below the dst line
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1323 // points to the dst Pixels center in the source (0 is the center of pixel 0,0 in src)
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1324 int srcuvpos= s_srcypos + s_yinc/2 - 0x8000;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1325 int y1=(srcuvpos + 0x1FFFF)>>17; // first chrominance source line number below the dst line
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1326 int yalpha=((s_srcypos-1)&0xFFFF)>>4;
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1327 int uvalpha=((srcuvpos-1)&0x1FFFF)>>5;
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1328 uint16_t *buf0=pix_buf_y[y0&1]; // top line of the interpolated slice
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1329 uint16_t *buf1=pix_buf_y[((y0+1)&1)]; // bottom line of the interpolated slice
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1330 uint16_t *uvbuf0=pix_buf_uv[y1&1]; // top line of the interpolated slice
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1331 uint16_t *uvbuf1=pix_buf_uv[(y1+1)&1]; // bottom line of the interpolated slice
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1332 int i;
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1333
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1334 if(y0>=y+h) break; // FIXME wrong, skips last lines, but they are dupliactes anyway
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1335
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1336 // if this is after the last line than use only the last src line
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1337 /* if(y0>=y+h)
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1338 {
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1339 buf1= buf0;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1340 s_last_ypos=y0;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1341 }
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1342 if(y1>=(y+h)/2)
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1343 {
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1344 uvbuf1= uvbuf0;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1345 s_last_y1pos=y1;
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1346 }
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1347 */
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1348
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1349 s_ypos++; s_srcypos+=s_yinc;
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1350
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1351 //only interpolate the src line horizontally if we didnt do it allready
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1352 if(s_last_ypos!=y0)
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1353 {
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1354 unsigned char *src;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1355 // skip if first line has been horiz scaled alleady
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1356 if(s_last_ypos != y0-1)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1357 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1358 // check if first line is before any available src lines
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1359 if(y0-1 < y) src=srcptr[0]+(0 )*stride[0];
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1360 else src=srcptr[0]+(y0-y-1)*stride[0];
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1361
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1362 hyscale(buf0, dstw, src, srcWidth, s_xinc);
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1363 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1364 // check if second line is after any available src lines
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1365 if(y0-y >= h) src=srcptr[0]+(h-1)*stride[0];
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1366 else src=srcptr[0]+(y0-y)*stride[0];
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1367
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1368 // the min() is required to avoid reuseing lines which where not available
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1369 s_last_ypos= MIN(y0, y+h-1);
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1370 hyscale(buf1, dstw, src, srcWidth, s_xinc);
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1371 }
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1372 // printf("%d %d %d %d\n", y, y1, s_last_y1pos, h);
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1373 // *** horizontal scale U and V lines to temp buffer
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1374 if(s_last_y1pos!=y1)
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1375 {
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1376 uint8_t *src1, *src2;
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1377 // skip if first line has been horiz scaled alleady
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1378 if(s_last_y1pos != y1-1)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1379 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1380 // check if first line is before any available src lines
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1381 if(y1-y/2-1 < 0)
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1382 {
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1383 src1= srcptr[1]+(0)*stride[1];
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1384 src2= srcptr[2]+(0)*stride[2];
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1385 }else{
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1386 src1= srcptr[1]+(y1-y/2-1)*stride[1];
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1387 src2= srcptr[2]+(y1-y/2-1)*stride[2];
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1388 }
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1389 hcscale(uvbuf0, dstUVw, src1, src2, srcWidth, s_xinc2);
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1390 }
2264
7851375ea156 increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents: 2237
diff changeset
1391
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1392 // check if second line is after any available src lines
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1393 if(y1 - y/2 >= h/2)
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1394 {
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1395 src1= srcptr[1]+(h/2-1)*stride[1];
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1396 src2= srcptr[2]+(h/2-1)*stride[2];
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1397 }else{
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1398 src1= srcptr[1]+(y1-y/2)*stride[1];
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1399 src2= srcptr[2]+(y1-y/2)*stride[2];
2279
9b9c3363abbe horizontal scaling bugs fixed, should be mostly bugfree now
michael
parents: 2274
diff changeset
1400 }
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1401 hcscale(uvbuf1, dstUVw, src1, src2, srcWidth, s_xinc2);
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1402
2469
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1403 // the min() is required to avoid reuseing lines which where not available
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1404 s_last_y1pos= MIN(y1, y/2+h/2-1);
03abc2743ed6 downscale
michael
parents: 2326
diff changeset
1405 }
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1406
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1407
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1408 if(ABS(s_yinc - 0x10000) < 10)
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1409 yuv2rgb1(buf0, buf1, uvbuf0, uvbuf1, dest, dstw, yalpha, uvalpha, dstbpp);
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1410 else
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1411 yuv2rgbX(buf0, buf1, uvbuf0, uvbuf1, dest, dstw, yalpha, uvalpha, dstbpp);
2237
00a46cd41edd 24bpp support (untested)
michael
parents: 2236
diff changeset
1412
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1413 #ifdef HAVE_MMX
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1414 b16Dither= b16Dither1;
2232
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1415 b16Dither1= b16Dither2;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1416 b16Dither2= b16Dither;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1417
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1418 g16Dither= g16Dither1;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1419 g16Dither1= g16Dither2;
65996b3467d7 MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents: 2230
diff changeset
1420 g16Dither2= g16Dither;
2316
bcb229557e9b fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents: 2297
diff changeset
1421 #endif
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1422 }
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1423
2236
32027d53eacb added (f)emms
arpi
parents: 2235
diff changeset
1424 #ifdef HAVE_3DNOW
32027d53eacb added (f)emms
arpi
parents: 2235
diff changeset
1425 asm volatile("femms");
32027d53eacb added (f)emms
arpi
parents: 2235
diff changeset
1426 #elif defined (HAVE_MMX)
32027d53eacb added (f)emms
arpi
parents: 2235
diff changeset
1427 asm volatile("emms");
32027d53eacb added (f)emms
arpi
parents: 2235
diff changeset
1428 #endif
2216
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1429 }
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1430
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1431
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1432 void SwScale_Init(){
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1433 // generating tables:
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1434 int i;
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1435 for(i=0;i<256;i++){
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1436 clip_table[i]=0;
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1437 clip_table[i+256]=i;
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1438 clip_table[i+512]=255;
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1439 yuvtab_2568[i]=(0x2568*(i-16))+(256<<13);
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1440 yuvtab_3343[i]=0x3343*(i-128);
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1441 yuvtab_0c92[i]=-0x0c92*(i-128);
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1442 yuvtab_1a1e[i]=-0x1a1e*(i-128);
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1443 yuvtab_40cf[i]=0x40cf*(i-128);
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1444 }
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1445
9da2a0515184 software yv12->rgb scaler - separated from fsdga
arpi
parents:
diff changeset
1446 }