annotate libmpcodecs/vf_halfpack.c @ 34624:5d6367c875c2

Don't unnecessarily destroy audio_driver_list. Only change the list when there is a device or driver in the GUI configuration file.
author ib
date Mon, 13 Feb 2012 14:10:43 +0000
parents 53073a44a899
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30368
diff changeset
18
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
19 #include <stdio.h>
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
20 #include <stdlib.h>
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
21 #include <string.h>
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
22 #include <inttypes.h>
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
23
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14794
diff changeset
24 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14794
diff changeset
25 #include "mp_msg.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14794
diff changeset
26 #include "cpudetect.h"
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
27
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
28 #include "img_format.h"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
29 #include "mp_image.h"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
30 #include "vf.h"
30368
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
31 #include "vf_scale.h"
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
32
30368
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
33 #include "libswscale/swscale.h"
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
34 #include "fmt-conversion.h"
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
35
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
36 struct vf_priv_s {
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
37 int field;
30368
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
38 struct SwsContext *ctx;
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
39 };
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
40
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27754
diff changeset
41 #if HAVE_MMX
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
42 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
43 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
44 int w, int h)
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
45 {
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
46 int j;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
47 unsigned char *y1, *y2, *u, *v;
14794
a9f383892015 100l to me: bugfix for negative stride
rfelker
parents: 13720
diff changeset
48 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
49
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
50 y1 = src[0];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
51 y2 = src[0] + srcstride[0];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
52 u = src[1];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
53 v = src[2];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
54
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
55 dstinc = dststride - 2*w;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
56 yinc = 2*srcstride[0] - w;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
57 uinc = srcstride[1] - w/2;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
58 vinc = srcstride[2] - w/2;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
59
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
60 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
61 __asm__ (
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
62 "pxor %%mm0, %%mm0 \n\t"
19372
6334c14b38eb Replace asmalign.h hack by ASMALIGN cpp macros from config.h.
diego
parents: 18861
diff changeset
63 ASMALIGN(4)
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
64 "1: \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
65 "movq (%0), %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
66 "movq (%0), %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
67 "movq (%1), %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
68 "movq (%1), %%mm4 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
69 "punpcklbw %%mm0, %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
70 "punpckhbw %%mm0, %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
71 "punpcklbw %%mm0, %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
72 "punpckhbw %%mm0, %%mm4 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
73 "paddw %%mm3, %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
74 "paddw %%mm4, %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
75 "psrlw $1, %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
76 "psrlw $1, %%mm2 \n\t"
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28290
diff changeset
77
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
78 "movq (%2), %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
79 "movq (%3), %%mm5 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
80 "punpcklbw %%mm0, %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
81 "punpcklbw %%mm0, %%mm5 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
82 "movq %%mm3, %%mm4 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
83 "movq %%mm5, %%mm6 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
84 "punpcklwd %%mm0, %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
85 "punpckhwd %%mm0, %%mm4 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
86 "punpcklwd %%mm0, %%mm5 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
87 "punpckhwd %%mm0, %%mm6 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
88 "pslld $8, %%mm3 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
89 "pslld $8, %%mm4 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
90 "pslld $24, %%mm5 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
91 "pslld $24, %%mm6 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
92
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
93 "por %%mm3, %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
94 "por %%mm4, %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
95 "por %%mm5, %%mm1 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
96 "por %%mm6, %%mm2 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
97
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 9593
diff changeset
98 "add $8, %0 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 9593
diff changeset
99 "add $8, %1 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 9593
diff changeset
100 "add $4, %2 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 9593
diff changeset
101 "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
102 "movq %%mm1, (%8) \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
103 "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
104 "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
105 "decl %9 \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
106 "jnz 1b \n\t"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
107 : "=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
108 : "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
109 : "memory"
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
110 );
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
111 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
112 *dst++ = (*y1++ + *y2++)/2;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
113 *dst++ = *u++;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
114 *dst++ = (*y1++ + *y2++)/2;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
115 *dst++ = *v++;
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 += yinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
118 y2 += yinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
119 u += uinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
120 v += vinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
121 dst += dstinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
122 }
27754
08d18fe9da52 Change all occurrences of asm and __asm to __asm__, same as was done for FFmpeg.
diego
parents: 25221
diff changeset
123 __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
124 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
125 #endif
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
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
128
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
129 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
130 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
131 int w, int h)
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 int i, j;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
134 unsigned char *y1, *y2, *u, *v;
14794
a9f383892015 100l to me: bugfix for negative stride
rfelker
parents: 13720
diff changeset
135 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
136
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
137 y1 = src[0];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
138 y2 = src[0] + srcstride[0];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
139 u = src[1];
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
140 v = src[2];
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 dstinc = dststride - 2*w;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
143 yinc = 2*srcstride[0] - w;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
144 uinc = srcstride[1] - w/2;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
145 vinc = srcstride[2] - w/2;
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 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
148 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
149 *dst++ = (*y1++ + *y2++)>>1;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
150 *dst++ = *u++;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
151 *dst++ = (*y1++ + *y2++)>>1;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
152 *dst++ = *v++;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
153 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
154 y1 += yinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
155 y2 += yinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
156 u += uinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
157 v += vinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
158 dst += dstinc;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
159 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
160 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
161
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
162 static void (*halfpack)(unsigned char *dst, unsigned char *src[3],
14794
a9f383892015 100l to me: bugfix for negative stride
rfelker
parents: 13720
diff changeset
163 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
164
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
165
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
166 static int put_image(struct vf_instance *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
167 {
30368
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
168 const uint8_t *src[MP_MAX_PLANES] = {
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
169 mpi->planes[0] + mpi->stride[0]*vf->priv->field,
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
170 mpi->planes[1], mpi->planes[2], NULL};
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
171 int src_stride[MP_MAX_PLANES] = {mpi->stride[0]*2, mpi->stride[1], mpi->stride[2], 0};
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
172 mp_image_t *dmpi;
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 // 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
175 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
176 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
177 mpi->w, mpi->h/2);
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
178
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
179 switch(vf->priv->field) {
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
180 case 0:
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
181 case 1:
30368
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
182 sws_scale(vf->priv->ctx, src, src_stride,
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
183 0, mpi->h/2, dmpi->planes, dmpi->stride);
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
184 break;
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
185 default:
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
186 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
187 mpi->stride, mpi->w, mpi->h);
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
188 }
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
189
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
190 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
191 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
192
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
193 static int config(struct vf_instance *vf,
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
194 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
195 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
196 {
30368
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
197 if (vf->priv->field < 2) {
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
198 sws_freeContext(vf->priv->ctx);
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
199 // get unscaled 422p -> yuy2 conversion
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
200 vf->priv->ctx =
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
201 sws_getContext(width, height / 2, PIX_FMT_YUV422P,
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
202 width, height / 2, PIX_FMT_YUYV422,
33415
53073a44a899 Fix build after removal of SWS_CPU_CAPS_* from libswscale in FFmpeg.
iive
parents: 30642
diff changeset
203 SWS_POINT | SWS_PRINT_INFO,
30368
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
204 NULL, NULL, NULL);
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
205 }
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
206 /* FIXME - also support UYVY output? */
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
207 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
208 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
209
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
210
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
211 static int query_format(struct vf_instance *vf, unsigned int fmt)
7155
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 /* 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
214 switch (fmt) {
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
215 case IMGFMT_YV12:
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
216 case IMGFMT_IYUV:
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
217 case IMGFMT_I420:
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
218 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
219 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
220 return 0;
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
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
223 static void uninit(struct vf_instance *vf)
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
224 {
30368
9f69fbf5cae6 Switch -vf halfpack to use only public API of libswscale.
reimar
parents: 29263
diff changeset
225 sws_freeContext(vf->priv->ctx);
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
226 free(vf->priv);
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
227 }
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
228
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30633
diff changeset
229 static int vf_open(vf_instance_t *vf, char *args)
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
230 {
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
231 vf->config=config;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
232 vf->query_format=query_format;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
233 vf->put_image=put_image;
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
234 vf->uninit=uninit;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28290
diff changeset
235
8870
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
236 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
237 vf->priv->field = 2;
7538bf7e728d halfpack now takes an optional argument, field, which tells it to keep
rfelker
parents: 7368
diff changeset
238 if (args) sscanf(args, "%d", &vf->priv->field);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28290
diff changeset
239
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
240 halfpack = halfpack_C;
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27754
diff changeset
241 #if HAVE_MMX
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
242 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
243 #endif
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
244 return 1;
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
245 }
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
246
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 23373
diff changeset
247 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
248 "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
249 "halfpack",
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
250 "Richard Felker",
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
251 "",
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30633
diff changeset
252 vf_open,
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8870
diff changeset
253 NULL
7155
66019eb62edc "halfpack" (yuv planar 4:2:0 -> packed 4:2:2, half height) video filter
rfelker
parents:
diff changeset
254 };