Mercurial > mplayer.hg
annotate libmpcodecs/vf_halfpack.c @ 29136:cfdba9b5abba
Sync with latest FFmpeg changes.
author | diego |
---|---|
date | Mon, 13 Apr 2009 08:55:20 +0000 |
parents | 25337a2147e7 |
children | 0f1b5b68af32 |
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 |
17012 | 6 #include "config.h" |
7 #include "mp_msg.h" | |
8 #include "cpudetect.h" | |
7155
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 |
18861 | 14 #include "libswscale/rgb2rgb.h" |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
15 |
8870
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
16 struct vf_priv_s { |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
17 int field; |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
18 }; |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
19 |
28290 | 20 #if HAVE_MMX |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
21 static void halfpack_MMX(unsigned char *dst, unsigned char *src[3], |
14794 | 22 int dststride, int srcstride[3], |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
23 int w, int h) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
24 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
25 int j; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
26 unsigned char *y1, *y2, *u, *v; |
14794 | 27 int dstinc, yinc, uinc, vinc; |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
28 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
29 y1 = src[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
30 y2 = src[0] + srcstride[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
31 u = src[1]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
32 v = src[2]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
33 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
34 dstinc = dststride - 2*w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
35 yinc = 2*srcstride[0] - w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
36 uinc = srcstride[1] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
37 vinc = srcstride[2] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
38 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
39 for (h/=2; h; h--) { |
27754
08d18fe9da52
Change all occurrences of asm and __asm to __asm__, same as was done for FFmpeg.
diego
parents:
25221
diff
changeset
|
40 __asm__ ( |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
41 "pxor %%mm0, %%mm0 \n\t" |
19372
6334c14b38eb
Replace asmalign.h hack by ASMALIGN cpp macros from config.h.
diego
parents:
18861
diff
changeset
|
42 ASMALIGN(4) |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
43 "1: \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
44 "movq (%0), %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
45 "movq (%0), %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
46 "movq (%1), %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
47 "movq (%1), %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
48 "punpcklbw %%mm0, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
49 "punpckhbw %%mm0, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
50 "punpcklbw %%mm0, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
51 "punpckhbw %%mm0, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
52 "paddw %%mm3, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
53 "paddw %%mm4, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
54 "psrlw $1, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
55 "psrlw $1, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
56 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
57 "movq (%2), %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
58 "movq (%3), %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
59 "punpcklbw %%mm0, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
60 "punpcklbw %%mm0, %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
61 "movq %%mm3, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
62 "movq %%mm5, %%mm6 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
63 "punpcklwd %%mm0, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
64 "punpckhwd %%mm0, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
65 "punpcklwd %%mm0, %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
66 "punpckhwd %%mm0, %%mm6 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
67 "pslld $8, %%mm3 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
68 "pslld $8, %%mm4 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
69 "pslld $24, %%mm5 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
70 "pslld $24, %%mm6 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
71 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
72 "por %%mm3, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
73 "por %%mm4, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
74 "por %%mm5, %%mm1 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
75 "por %%mm6, %%mm2 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
76 |
13720
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
9593
diff
changeset
|
77 "add $8, %0 \n\t" |
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
9593
diff
changeset
|
78 "add $8, %1 \n\t" |
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
9593
diff
changeset
|
79 "add $4, %2 \n\t" |
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
9593
diff
changeset
|
80 "add $4, %3 \n\t" |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
81 "movq %%mm1, (%8) \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
82 "movq %%mm2, 8(%8) \n\t" |
13720
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
9593
diff
changeset
|
83 "add $16, %8 \n\t" |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
84 "decl %9 \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
85 "jnz 1b \n\t" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
86 : "=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
|
87 : "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
|
88 : "memory" |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
89 ); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
90 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
|
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++ = *u++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
93 *dst++ = (*y1++ + *y2++)/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
94 *dst++ = *v++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
95 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
96 y1 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
97 y2 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
98 u += uinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
99 v += vinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
100 dst += dstinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
101 } |
27754
08d18fe9da52
Change all occurrences of asm and __asm to __asm__, same as was done for FFmpeg.
diego
parents:
25221
diff
changeset
|
102 __asm__ volatile ( "emms \n\t" ::: "memory" ); |
7155
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 #endif |
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 |
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 static void halfpack_C(unsigned char *dst, unsigned char *src[3], |
14794 | 109 int dststride, int srcstride[3], |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
110 int w, int h) |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
111 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
112 int i, j; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
113 unsigned char *y1, *y2, *u, *v; |
14794 | 114 int dstinc, yinc, uinc, vinc; |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
115 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
116 y1 = src[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
117 y2 = src[0] + srcstride[0]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
118 u = src[1]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
119 v = src[2]; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
120 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
121 dstinc = dststride - 2*w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
122 yinc = 2*srcstride[0] - w; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
123 uinc = srcstride[1] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
124 vinc = srcstride[2] - w/2; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
125 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
126 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
|
127 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
|
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++ = *u++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
130 *dst++ = (*y1++ + *y2++)>>1; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
131 *dst++ = *v++; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
132 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
133 y1 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
134 y2 += yinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
135 u += uinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
136 v += vinc; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
137 dst += dstinc; |
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 } |
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 static void (*halfpack)(unsigned char *dst, unsigned char *src[3], |
14794 | 142 int dststride, int srcstride[3], int w, int h); |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
143 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
144 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
145 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) |
7155
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 mp_image_t *dmpi; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
148 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
149 // 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
|
150 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
|
151 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
|
152 mpi->w, mpi->h/2); |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
153 |
8870
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
154 switch(vf->priv->field) { |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
155 case 0: |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
156 case 1: |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
157 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
|
158 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
|
159 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
|
160 break; |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
161 default: |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
162 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
|
163 mpi->stride, mpi->w, mpi->h); |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
164 } |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
165 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
166 return vf_next_put_image(vf,dmpi, pts); |
7155
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 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
169 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
|
170 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
|
171 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
|
172 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
173 /* FIXME - also support UYVY output? */ |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
174 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
|
175 } |
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 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
|
179 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
180 /* 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
|
181 switch (fmt) { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
182 case IMGFMT_YV12: |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
183 case IMGFMT_IYUV: |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
184 case IMGFMT_I420: |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
185 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
|
186 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
187 return 0; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
188 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
189 |
8870
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
190 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
|
191 { |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
192 free(vf->priv); |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
193 } |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
194 |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
195 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
|
196 { |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
197 vf->config=config; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
198 vf->query_format=query_format; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
199 vf->put_image=put_image; |
8870
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
200 vf->uninit=uninit; |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
201 |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
202 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
|
203 vf->priv->field = 2; |
7538bf7e728d
halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents:
7368
diff
changeset
|
204 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
|
205 |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
206 halfpack = halfpack_C; |
28290 | 207 #if HAVE_MMX |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
208 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
|
209 #endif |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
210 return 1; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
211 } |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
212 |
25221 | 213 const vf_info_t vf_info_halfpack = { |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
214 "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
|
215 "halfpack", |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
216 "Richard Felker", |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
217 "", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8870
diff
changeset
|
218 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8870
diff
changeset
|
219 NULL |
7155
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
220 }; |
66019eb62edc
"halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff
changeset
|
221 |