Mercurial > mplayer.hg
annotate libmpcodecs/vf_halfpack.c @ 8256:cde8aaad8198
This file gets created during the wine/svq3 build process.
author | diego |
---|---|
date | Sat, 23 Nov 2002 11:45:44 +0000 |
parents | a894e99c1e51 |
children | 7538bf7e728d |
rev | line source |
---|---|
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
1 #include <stdio.h> |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
2 #include <stdlib.h> |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
3 #include <string.h> |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
4 #include <inttypes.h> |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
5 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
6 #include "../config.h" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
7 #include "../mp_msg.h" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
8 #include "../cpudetect.h" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
9 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
10 #include "img_format.h" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
11 #include "mp_image.h" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
12 #include "vf.h" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
13 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
14 #include "../libvo/fastmemcpy.h" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
15 #include "../postproc/rgb2rgb.h" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
16 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
17 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
18 #ifdef HAVE_MMX |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
19 static void halfpack_MMX(unsigned char *dst, unsigned char *src[3], |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
20 unsigned int dststride, unsigned int srcstride[3], |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
21 int w, int h) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
22 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
23 int j; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
24 unsigned char *y1, *y2, *u, *v; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
25 unsigned int dstinc, yinc, uinc, vinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
26 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
27 y1 = src[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
28 y2 = src[0] + srcstride[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
29 u = src[1]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
30 v = src[2]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
31 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
32 dstinc = dststride - 2*w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
33 yinc = 2*srcstride[0] - w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
34 uinc = srcstride[1] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
35 vinc = srcstride[2] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
36 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
37 for (h/=2; h; h--) { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
38 asm ( |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
39 "pxor %%mm0, %%mm0 \n\t" |
7167 | 40 ".balign 16 \n\t" |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
41 "1: \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
42 "movq (%0), %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
43 "movq (%0), %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
44 "movq (%1), %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
45 "movq (%1), %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
46 "punpcklbw %%mm0, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
47 "punpckhbw %%mm0, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
48 "punpcklbw %%mm0, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
49 "punpckhbw %%mm0, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
50 "paddw %%mm3, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
51 "paddw %%mm4, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
52 "psrlw $1, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
53 "psrlw $1, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
54 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
55 "movq (%2), %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
56 "movq (%3), %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
57 "punpcklbw %%mm0, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
58 "punpcklbw %%mm0, %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
59 "movq %%mm3, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
60 "movq %%mm5, %%mm6 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
61 "punpcklwd %%mm0, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
62 "punpckhwd %%mm0, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
63 "punpcklwd %%mm0, %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
64 "punpckhwd %%mm0, %%mm6 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
65 "pslld $8, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
66 "pslld $8, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
67 "pslld $24, %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
68 "pslld $24, %%mm6 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
69 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
70 "por %%mm3, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
71 "por %%mm4, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
72 "por %%mm5, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
73 "por %%mm6, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
74 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
75 "addl $8, %0 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
76 "addl $8, %1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
77 "addl $4, %2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
78 "addl $4, %3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
79 "movq %%mm1, (%8) \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
80 "movq %%mm2, 8(%8) \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
81 "addl $16, %8 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
82 "decl %9 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
83 "jnz 1b \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
84 : "=r" (y1), "=r" (y2), "=r" (u), "=r" (v) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
85 : "0" (y1), "1" (y2), "2" (u), "3" (v), "r" (dst), "r" (w/8) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
86 : "memory" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
87 ); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
88 for (j = (w&7)/2; j; j--) { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
89 *dst++ = (*y1++ + *y2++)/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
90 *dst++ = *u++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
91 *dst++ = (*y1++ + *y2++)/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
92 *dst++ = *v++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
93 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
94 y1 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
95 y2 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
96 u += uinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
97 v += vinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
98 dst += dstinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
99 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
100 asm volatile ( "emms \n\t" ::: "memory" ); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
101 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
102 #endif |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
103 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
104 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
105 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
106 static void halfpack_C(unsigned char *dst, unsigned char *src[3], |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
107 unsigned int dststride, unsigned int srcstride[3], |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
108 int w, int h) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
109 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
110 int i, j; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
111 unsigned char *y1, *y2, *u, *v; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
112 unsigned int dstinc, yinc, uinc, vinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
113 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
114 y1 = src[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
115 y2 = src[0] + srcstride[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
116 u = src[1]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
117 v = src[2]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
118 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
119 dstinc = dststride - 2*w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
120 yinc = 2*srcstride[0] - w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
121 uinc = srcstride[1] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
122 vinc = srcstride[2] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
123 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
124 for (i = h/2; i; i--) { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
125 for (j = w/2; j; j--) { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
126 *dst++ = (*y1++ + *y2++)>>1; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
127 *dst++ = *u++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
128 *dst++ = (*y1++ + *y2++)>>1; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
129 *dst++ = *v++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
130 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
131 y1 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
132 y2 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
133 u += uinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
134 v += vinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
135 dst += dstinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
136 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
137 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
138 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
139 static void (*halfpack)(unsigned char *dst, unsigned char *src[3], |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
140 unsigned int dststride, unsigned int srcstride[3], int w, int h); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
141 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
142 |
7368 | 143 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi) |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
144 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
145 mp_image_t *dmpi; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
146 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
147 // hope we'll get DR buffer: |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
148 dmpi=vf_get_image(vf->next, IMGFMT_YUY2, |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
149 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
150 mpi->w, mpi->h/2); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
151 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
152 halfpack(dmpi->planes[0], mpi->planes, |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
153 dmpi->stride[0], mpi->stride, |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
154 mpi->w, mpi->h); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
155 |
7368 | 156 return vf_next_put_image(vf,dmpi); |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
157 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
158 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
159 static int config(struct vf_instance_s* vf, |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
160 int width, int height, int d_width, int d_height, |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
161 unsigned int flags, unsigned int outfmt) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
162 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
163 /* FIXME - also support UYVY output? */ |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
164 return vf_next_config(vf, width, height/2, d_width, d_height, flags, IMGFMT_YUY2); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
165 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
166 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
167 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
168 static int query_format(struct vf_instance_s* vf, unsigned int fmt) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
169 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
170 /* FIXME - really any YUV 4:2:0 input format should work */ |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
171 switch (fmt) { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
172 case IMGFMT_YV12: |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
173 case IMGFMT_IYUV: |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
174 case IMGFMT_I420: |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
175 return vf_next_query_format(vf,IMGFMT_YUY2); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
176 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
177 return 0; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
178 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
179 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
180 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
181 static int open(vf_instance_t *vf, char* args) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
182 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
183 vf->config=config; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
184 vf->query_format=query_format; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
185 vf->put_image=put_image; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
186 halfpack = halfpack_C; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
187 #ifdef HAVE_MMX |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
188 if(gCpuCaps.hasMMX) halfpack = halfpack_MMX; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
189 #endif |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
190 return 1; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
191 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
192 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
193 vf_info_t vf_info_halfpack = { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
194 "yuv planar 4:2:0 -> packed 4:2:2, half height", |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
195 "halfpack", |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
196 "Richard Felker", |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
197 "", |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
198 open |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
199 }; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
200 |