Mercurial > mplayer.hg
annotate libmpcodecs/vf_halfpack.c @ 10788:c11c87536da4
some updates
author | alex |
---|---|
date | Mon, 01 Sep 2003 19:11:44 +0000 |
parents | e9a2af584986 |
children | 821f464b4d90 |
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 |
8870
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
17 struct vf_priv_s { |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
18 int field; |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
19 }; |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
20 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
21 #ifdef HAVE_MMX |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
22 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
|
23 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
|
24 int w, int h) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
25 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
26 int j; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
27 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
|
28 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
|
29 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
30 y1 = src[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
31 y2 = src[0] + srcstride[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
32 u = src[1]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
33 v = src[2]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
34 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
35 dstinc = dststride - 2*w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
36 yinc = 2*srcstride[0] - w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
37 uinc = srcstride[1] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
38 vinc = srcstride[2] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
39 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
40 for (h/=2; h; h--) { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
41 asm ( |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
42 "pxor %%mm0, %%mm0 \n\t" |
7167 | 43 ".balign 16 \n\t" |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
44 "1: \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
45 "movq (%0), %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
46 "movq (%0), %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
47 "movq (%1), %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
48 "movq (%1), %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
49 "punpcklbw %%mm0, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
50 "punpckhbw %%mm0, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
51 "punpcklbw %%mm0, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
52 "punpckhbw %%mm0, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
53 "paddw %%mm3, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
54 "paddw %%mm4, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
55 "psrlw $1, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
56 "psrlw $1, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
57 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
58 "movq (%2), %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
59 "movq (%3), %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
60 "punpcklbw %%mm0, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
61 "punpcklbw %%mm0, %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
62 "movq %%mm3, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
63 "movq %%mm5, %%mm6 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
64 "punpcklwd %%mm0, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
65 "punpckhwd %%mm0, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
66 "punpcklwd %%mm0, %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
67 "punpckhwd %%mm0, %%mm6 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
68 "pslld $8, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
69 "pslld $8, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
70 "pslld $24, %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
71 "pslld $24, %%mm6 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
72 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
73 "por %%mm3, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
74 "por %%mm4, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
75 "por %%mm5, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
76 "por %%mm6, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
77 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
78 "addl $8, %0 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
79 "addl $8, %1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
80 "addl $4, %2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
81 "addl $4, %3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
82 "movq %%mm1, (%8) \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
83 "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
|
84 "addl $16, %8 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
85 "decl %9 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
86 "jnz 1b \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
87 : "=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
|
88 : "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
|
89 : "memory" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
90 ); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
91 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
|
92 *dst++ = (*y1++ + *y2++)/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
93 *dst++ = *u++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
94 *dst++ = (*y1++ + *y2++)/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
95 *dst++ = *v++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
96 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
97 y1 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
98 y2 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
99 u += uinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
100 v += vinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
101 dst += dstinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
102 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
103 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
|
104 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
105 #endif |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
106 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
107 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
108 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
109 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
|
110 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
|
111 int w, int h) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
112 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
113 int i, j; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
114 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
|
115 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
|
116 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
117 y1 = src[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
118 y2 = src[0] + srcstride[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
119 u = src[1]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
120 v = src[2]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
121 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
122 dstinc = dststride - 2*w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
123 yinc = 2*srcstride[0] - w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
124 uinc = srcstride[1] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
125 vinc = srcstride[2] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
126 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
127 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
|
128 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
|
129 *dst++ = (*y1++ + *y2++)>>1; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
130 *dst++ = *u++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
131 *dst++ = (*y1++ + *y2++)>>1; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
132 *dst++ = *v++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
133 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
134 y1 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
135 y2 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
136 u += uinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
137 v += vinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
138 dst += dstinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
139 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
140 } |
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 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
|
143 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
|
144 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
145 |
7368 | 146 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
|
147 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
148 mp_image_t *dmpi; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
149 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
150 // 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
|
151 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
|
152 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
|
153 mpi->w, mpi->h/2); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
154 |
8870
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
155 switch(vf->priv->field) { |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
156 case 0: |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
157 case 1: |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
158 yuv422ptoyuy2(mpi->planes[0] + mpi->stride[0]*vf->priv->field, |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
159 mpi->planes[1], mpi->planes[2], dmpi->planes[0], |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
160 mpi->w, mpi->h/2, mpi->stride[0]*2, mpi->stride[1], dmpi->stride[0]); |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
161 break; |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
162 default: |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
163 halfpack(dmpi->planes[0], mpi->planes, dmpi->stride[0], |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
164 mpi->stride, mpi->w, mpi->h); |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
165 } |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
166 |
7368 | 167 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
|
168 } |
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 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
|
171 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
|
172 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
|
173 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
174 /* FIXME - also support UYVY output? */ |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
175 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
|
176 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
177 |
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 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
|
180 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
181 /* 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
|
182 switch (fmt) { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
183 case IMGFMT_YV12: |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
184 case IMGFMT_IYUV: |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
185 case IMGFMT_I420: |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
186 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
|
187 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
188 return 0; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
189 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
190 |
8870
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
191 static void uninit(struct vf_instance_s* vf) |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
192 { |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
193 free(vf->priv); |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
194 } |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
195 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
196 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
|
197 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
198 vf->config=config; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
199 vf->query_format=query_format; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
200 vf->put_image=put_image; |
8870
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
201 vf->uninit=uninit; |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
202 |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
203 vf->priv = calloc(1, sizeof (struct vf_priv_s)); |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
204 vf->priv->field = 2; |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
205 if (args) sscanf(args, "%d", &vf->priv->field); |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
206 |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
207 halfpack = halfpack_C; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
208 #ifdef HAVE_MMX |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
209 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
|
210 #endif |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
211 return 1; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
212 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
213 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
214 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
|
215 "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
|
216 "halfpack", |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
217 "Richard Felker", |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
218 "", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8870
diff
changeset
|
219 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8870
diff
changeset
|
220 NULL |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
221 }; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
222 |