annotate libmpcodecs/vf_halfpack.c @ 19265:f8d91df64bf1

Clarify licensing situation.
author diego
date Sun, 30 Jul 2006 22:20:50 +0000
parents 8579acff875e
children 6334c14b38eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14794
diff changeset
6 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14794
diff changeset
7 #include "mp_msg.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14794
diff changeset
8 #include "cpudetect.h"
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 17906
diff changeset
9 #include "asmalign.h"
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
10
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
11 #include "img_format.h"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
12 #include "mp_image.h"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
13 #include "vf.h"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
14
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14794
diff changeset
15 #include "libvo/fastmemcpy.h"
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents: 18104
diff changeset
16 #include "libswscale/rgb2rgb.h"
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
17
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
18 struct vf_priv_s {
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
19 int field;
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
20 };
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
21
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
22 #ifdef HAVE_MMX
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
23 static void halfpack_MMX(unsigned char *dst, unsigned char *src[3],
14794
a9f383892015 100l to me: bugfix for negative stride
rfelker
parents: 13720
diff changeset
24 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
25 int w, int h)
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 int j;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
28 unsigned char *y1, *y2, *u, *v;
14794
a9f383892015 100l to me: bugfix for negative stride
rfelker
parents: 13720
diff changeset
29 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
30
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
31 y1 = src[0];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
32 y2 = src[0] + srcstride[0];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
33 u = src[1];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
34 v = src[2];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
35
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
36 dstinc = dststride - 2*w;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
37 yinc = 2*srcstride[0] - w;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
38 uinc = srcstride[1] - w/2;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
39 vinc = srcstride[2] - w/2;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
40
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
41 for (h/=2; h; h--) {
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
42 asm (
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
43 "pxor %%mm0, %%mm0 \n\t"
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 17906
diff changeset
44 ASMALIGN16
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
45 "1: \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
46 "movq (%0), %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
47 "movq (%0), %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
48 "movq (%1), %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
49 "movq (%1), %%mm4 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
50 "punpcklbw %%mm0, %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
51 "punpckhbw %%mm0, %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
52 "punpcklbw %%mm0, %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
53 "punpckhbw %%mm0, %%mm4 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
54 "paddw %%mm3, %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
55 "paddw %%mm4, %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
56 "psrlw $1, %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
57 "psrlw $1, %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
58
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
59 "movq (%2), %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
60 "movq (%3), %%mm5 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
61 "punpcklbw %%mm0, %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
62 "punpcklbw %%mm0, %%mm5 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
63 "movq %%mm3, %%mm4 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
64 "movq %%mm5, %%mm6 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
65 "punpcklwd %%mm0, %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
66 "punpckhwd %%mm0, %%mm4 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
67 "punpcklwd %%mm0, %%mm5 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
68 "punpckhwd %%mm0, %%mm6 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
69 "pslld $8, %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
70 "pslld $8, %%mm4 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
71 "pslld $24, %%mm5 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
72 "pslld $24, %%mm6 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
73
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
74 "por %%mm3, %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
75 "por %%mm4, %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
76 "por %%mm5, %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
77 "por %%mm6, %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
78
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 9593
diff changeset
79 "add $8, %0 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 9593
diff changeset
80 "add $8, %1 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 9593
diff changeset
81 "add $4, %2 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 9593
diff changeset
82 "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
83 "movq %%mm1, (%8) \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
84 "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
85 "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
86 "decl %9 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
87 "jnz 1b \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
88 : "=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
89 : "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
90 : "memory"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
91 );
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
92 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
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++ = *u++;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
95 *dst++ = (*y1++ + *y2++)/2;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
96 *dst++ = *v++;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
97 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
98 y1 += yinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
99 y2 += yinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
100 u += uinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
101 v += vinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
102 dst += dstinc;
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 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
105 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
106 #endif
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
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
110 static void halfpack_C(unsigned char *dst, unsigned char *src[3],
14794
a9f383892015 100l to me: bugfix for negative stride
rfelker
parents: 13720
diff changeset
111 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
112 int w, int h)
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 int i, j;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
115 unsigned char *y1, *y2, *u, *v;
14794
a9f383892015 100l to me: bugfix for negative stride
rfelker
parents: 13720
diff changeset
116 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
117
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
118 y1 = src[0];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
119 y2 = src[0] + srcstride[0];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
120 u = src[1];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
121 v = src[2];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
122
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
123 dstinc = dststride - 2*w;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
124 yinc = 2*srcstride[0] - w;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
125 uinc = srcstride[1] - w/2;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
126 vinc = srcstride[2] - w/2;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
127
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
128 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
129 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
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++ = *u++;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
132 *dst++ = (*y1++ + *y2++)>>1;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
133 *dst++ = *v++;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
134 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
135 y1 += yinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
136 y2 += yinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
137 u += uinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
138 v += vinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
139 dst += dstinc;
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
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
143 static void (*halfpack)(unsigned char *dst, unsigned char *src[3],
14794
a9f383892015 100l to me: bugfix for negative stride
rfelker
parents: 13720
diff changeset
144 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
145
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
146
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
147 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
148 {
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
149 mp_image_t *dmpi;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
150
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
151 // 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
152 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
153 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
154 mpi->w, mpi->h/2);
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
155
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
156 switch(vf->priv->field) {
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
157 case 0:
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
158 case 1:
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
159 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
160 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
161 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
162 break;
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
163 default:
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
164 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
165 mpi->stride, mpi->w, mpi->h);
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
166 }
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
167
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
168 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
169 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
170
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
171 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
172 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
173 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
174 {
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
175 /* FIXME - also support UYVY output? */
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
176 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
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
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
180 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
181 {
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
182 /* 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
183 switch (fmt) {
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
184 case IMGFMT_YV12:
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
185 case IMGFMT_IYUV:
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
186 case IMGFMT_I420:
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
187 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
188 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
189 return 0;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
190 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
191
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
192 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
193 {
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
194 free(vf->priv);
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
195 }
7155
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 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
198 {
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
199 vf->config=config;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
200 vf->query_format=query_format;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
201 vf->put_image=put_image;
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
202 vf->uninit=uninit;
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
203
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
204 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
205 vf->priv->field = 2;
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
206 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
207
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
208 halfpack = halfpack_C;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
209 #ifdef HAVE_MMX
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
210 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
211 #endif
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
212 return 1;
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
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
215 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
216 "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
217 "halfpack",
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
218 "Richard Felker",
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
219 "",
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8870
diff changeset
220 open,
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8870
diff changeset
221 NULL
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
222 };
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
223