Mercurial > mplayer.hg
annotate libmpcodecs/vf_decimate.c @ 34514:e421fb9bb0b9
Fix compilation with --disable-networking.
Patch by Andrew Wason, rectalogic rectalogic com
author | cehoyos |
---|---|
date | Thu, 26 Jan 2012 23:16:43 +0000 |
parents | 064be070d8c8 |
children | 35fe96aedad5 |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
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:
29263
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:
29263
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:
29263
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
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:
29263
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:
29263
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:
29263
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
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:
29263
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:
29263
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:
29263
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
18 |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
19 #include <stdio.h> |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
20 #include <stdlib.h> |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
21 #include <string.h> |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
22 |
17012 | 23 #include "config.h" |
24 #include "mp_msg.h" | |
25 #include "cpudetect.h" | |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
26 |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
27 #include "img_format.h" |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
28 #include "mp_image.h" |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
29 #include "vf.h" |
34198 | 30 #include "libavutil/x86_cpu.h" |
17012 | 31 #include "libvo/fastmemcpy.h" |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
32 |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
33 |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
34 struct vf_priv_s { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
35 int hi, lo; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
36 float frac; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
37 int max, last, cnt; |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
38 }; |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
39 |
28907
ccbde3575f0a
Check for HAVE_EBX_AVAILABLE before enabling MMX code that needs the EBX
reimar
parents:
28905
diff
changeset
|
40 #if HAVE_MMX && HAVE_EBX_AVAILABLE |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
41 static int diff_MMX(unsigned char *old, unsigned char *new, int os, int ns) |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
42 { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
43 volatile short out[4]; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
44 __asm__ ( |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
45 "movl $8, %%ecx \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
46 "pxor %%mm4, %%mm4 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
47 "pxor %%mm7, %%mm7 \n\t" |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28907
diff
changeset
|
48 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
49 ASMALIGN(4) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
50 "1: \n\t" |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28907
diff
changeset
|
51 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
52 "movq (%%"REG_S"), %%mm0 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
53 "movq (%%"REG_S"), %%mm2 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
54 "add %%"REG_a", %%"REG_S" \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
55 "movq (%%"REG_D"), %%mm1 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
56 "add %%"REG_b", %%"REG_D" \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
57 "psubusb %%mm1, %%mm2 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
58 "psubusb %%mm0, %%mm1 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
59 "movq %%mm2, %%mm0 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
60 "movq %%mm1, %%mm3 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
61 "punpcklbw %%mm7, %%mm0 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
62 "punpcklbw %%mm7, %%mm1 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
63 "punpckhbw %%mm7, %%mm2 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
64 "punpckhbw %%mm7, %%mm3 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
65 "paddw %%mm0, %%mm4 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
66 "paddw %%mm1, %%mm4 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
67 "paddw %%mm2, %%mm4 \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
68 "paddw %%mm3, %%mm4 \n\t" |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28907
diff
changeset
|
69 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
70 "decl %%ecx \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
71 "jnz 1b \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
72 "movq %%mm4, (%%"REG_d") \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
73 "emms \n\t" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
74 : |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
75 : "S" (old), "D" (new), "a" ((long)os), "b" ((long)ns), "d" (out) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
76 : "%ecx", "memory" |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
77 ); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
78 return out[0]+out[1]+out[2]+out[3]; |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
79 } |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
80 #endif |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
81 |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
82 static int diff_C(unsigned char *old, unsigned char *new, int os, int ns) |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
83 { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
84 int x, y, d=0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
85 for (y = 8; y; y--) { |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
86 for (x = 8; x; x--) { |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
87 d += abs(new[x] - old[x]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
88 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
89 new += ns; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
90 old += os; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
91 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
92 return d; |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
93 } |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
94 |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
95 static int (*diff)(unsigned char *, unsigned char *, int, int); |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
96 |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
97 static int diff_to_drop_plane(int hi, int lo, float frac, unsigned char *old, unsigned char *new, int w, int h, int os, int ns) |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
98 { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
99 int x, y; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
100 int d, c=0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
101 int t = (w/16)*(h/16)*frac; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
102 for (y = 0; y < h-7; y += 4) { |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
103 for (x = 8; x < w-7; x += 4) { |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
104 d = diff(old+x+y*os, new+x+y*ns, os, ns); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
105 if (d > hi) return 0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
106 if (d > lo) { |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
107 c++; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
108 if (c > t) return 0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
109 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
110 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
111 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
112 return 1; |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
113 } |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
114 |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
115 static int diff_to_drop(int hi, int lo, float frac, mp_image_t *old, mp_image_t *new) |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
116 { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
117 if (new->flags & MP_IMGFLAG_PLANAR) { |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
118 return diff_to_drop_plane(hi,lo,frac, old->planes[0], new->planes[0], |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
119 new->w, new->h, old->stride[0], new->stride[0]) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
120 && diff_to_drop_plane(hi,lo,frac, old->planes[1], new->planes[1], |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
121 new->chroma_width, new->chroma_height, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
122 old->stride[1], new->stride[1]) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
123 && diff_to_drop_plane(hi,lo,frac, old->planes[2], new->planes[2], |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
124 new->chroma_width, new->chroma_height, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
125 old->stride[2], new->stride[2]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
126 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
127 return diff_to_drop_plane(hi,lo,frac, old->planes[0], new->planes[0], |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
128 new->w*(new->bpp/8), new->h, old->stride[0], new->stride[0]); |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
129 } |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
130 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
131 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
132 { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
133 mp_image_t *dmpi; |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
134 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
135 dmpi = vf_get_image(vf->next, mpi->imgfmt, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
136 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE | |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
137 MP_IMGFLAG_PRESERVE | MP_IMGFLAG_READABLE, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
138 mpi->width, mpi->height); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
139 dmpi->qscale = mpi->qscale; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
140 dmpi->qstride = mpi->qstride; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
141 dmpi->qscale_type = mpi->qscale_type; |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
142 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
143 if (diff_to_drop(vf->priv->hi, vf->priv->lo, vf->priv->frac, dmpi, mpi)) { |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
144 if (vf->priv->max == 0) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
145 return 0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
146 else if ((vf->priv->max > 0) && (vf->priv->cnt++ < vf->priv->max)) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
147 return 0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
148 else if ((vf->priv->max < 0) && (vf->priv->last+1 >= -vf->priv->max)) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
149 return vf->priv->last=0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
150 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
151 vf->priv->last++; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
152 vf->priv->cnt=0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28907
diff
changeset
|
153 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
154 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
155 dmpi->stride[0], mpi->stride[0]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
156 if (mpi->flags & MP_IMGFLAG_PLANAR) { |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
157 memcpy_pic(dmpi->planes[1], mpi->planes[1], |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
158 mpi->chroma_width, mpi->chroma_height, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
159 dmpi->stride[1], mpi->stride[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
160 memcpy_pic(dmpi->planes[2], mpi->planes[2], |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
161 mpi->chroma_width, mpi->chroma_height, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
162 dmpi->stride[2], mpi->stride[2]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
163 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
164 return vf_next_put_image(vf, dmpi, pts); |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
165 } |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
166 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
167 static void uninit(struct vf_instance *vf) |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
168 { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
169 free(vf->priv); |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
170 } |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
171 |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30633
diff
changeset
|
172 static int vf_open(vf_instance_t *vf, char *args) |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
173 { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
174 struct vf_priv_s *p; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
175 vf->put_image = put_image; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
176 vf->uninit = uninit; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
177 vf->default_reqs = VFCAP_ACCEPT_STRIDE; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
178 vf->priv = p = calloc(1, sizeof(struct vf_priv_s)); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
179 p->max = 0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
180 p->hi = 64*12; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
181 p->lo = 64*5; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
182 p->frac = 0.33; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
183 if (args) sscanf(args, "%d:%d:%d:%f", &p->max, &p->hi, &p->lo, &p->frac); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
184 diff = diff_C; |
28907
ccbde3575f0a
Check for HAVE_EBX_AVAILABLE before enabling MMX code that needs the EBX
reimar
parents:
28905
diff
changeset
|
185 #if HAVE_MMX && HAVE_EBX_AVAILABLE |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
186 if(gCpuCaps.hasMMX) diff = diff_MMX; |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
187 #endif |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
30642
diff
changeset
|
188 return 1; |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
189 } |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
190 |
25221 | 191 const vf_info_t vf_info_decimate = { |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
192 "near-duplicate frame remover", |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
193 "decimate", |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
194 "Rich Felker", |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
195 "", |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30633
diff
changeset
|
196 vf_open, |
10150
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
197 NULL |
b34ede44dada
new filter for dropping (near-)duplicate frames. can be used to fix
rfelker
parents:
diff
changeset
|
198 }; |