Mercurial > mplayer.hg
annotate libmpcodecs/vf_dint.c @ 21969:ae6aa1d099ff
r21959: Apply ancient double-click patch that nobody cares to comment on.
author | voroshil |
---|---|
date | Sun, 21 Jan 2007 20:08:06 +0000 |
parents | 20aca9baf5d8 |
children | f8d4f8eff72b |
rev | line source |
---|---|
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
1 #include <stdio.h> |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
2 #include <stdlib.h> |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
3 #include <string.h> |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
4 #include <inttypes.h> |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
5 |
17012 | 6 #include "config.h" |
7 #include "mp_msg.h" | |
8 #include "libvo/fastmemcpy.h" | |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
9 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
10 #include "mp_image.h" |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
11 #include "img_format.h" |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
12 #include "vf.h" |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
13 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
14 struct vf_priv_s { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
15 float sense; // first parameter |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
16 float level; // second parameter |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
17 unsigned int imgfmt; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
18 char diff; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
19 uint32_t max; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
20 // int dfr; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
21 // int rdfr; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
22 int was_dint; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
23 mp_image_t *pmpi; // previous mpi |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
24 }; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
25 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
26 #define MAXROWSIZE 1200 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
27 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
28 static int config (struct vf_instance_s* vf, |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
29 int width, int height, int d_width, int d_height, |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
30 unsigned int flags, unsigned int outfmt) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
31 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
32 int rowsize; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
33 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
34 vf->priv->pmpi = vf_get_image (vf->next, outfmt, MP_IMGTYPE_TEMP, |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
35 0, width, height); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
36 if (!(vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
37 outfmt != IMGFMT_RGB32 && outfmt != IMGFMT_BGR32 && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
38 outfmt != IMGFMT_RGB24 && outfmt != IMGFMT_BGR24 && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
39 outfmt != IMGFMT_RGB16 && outfmt != IMGFMT_BGR16) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
40 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
41 mp_msg (MSGT_VFILTER, MSGL_WARN, "Drop-interlaced filter doesn't support this outfmt :(\n"); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
42 return 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
43 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
44 vf->priv->imgfmt = outfmt; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
45 // recalculate internal values |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
46 rowsize = vf->priv->pmpi->width; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
47 if (rowsize > MAXROWSIZE) rowsize = MAXROWSIZE; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
48 vf->priv->max = vf->priv->level * vf->priv->pmpi->height * rowsize / 2; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
49 if (vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) // planar YUV |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
50 vf->priv->diff = vf->priv->sense * 256; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
51 else |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
52 vf->priv->diff = vf->priv->sense * (1 << (vf->priv->pmpi->bpp/3)); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
53 if (vf->priv->diff < 0) vf->priv->diff = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
54 if (!(vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
55 vf->priv->pmpi->bpp < 24 && vf->priv->diff > 31) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
56 vf->priv->diff = 31; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
57 mp_msg (MSGT_VFILTER, MSGL_INFO, "Drop-interlaced: %dx%d diff %d / level %u\n", |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
58 vf->priv->pmpi->width, vf->priv->pmpi->height, |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
59 (int)vf->priv->diff, (unsigned int)vf->priv->max); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
60 // vf->priv->rdfr = vf->priv->dfr = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
61 vf->priv->was_dint = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
62 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
63 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
64 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
65 static int put_image (struct vf_instance_s* vf, mp_image_t *mpi, double pts) |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
66 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
67 char rrow0[MAXROWSIZE]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
68 char rrow1[MAXROWSIZE]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
69 char rrow2[MAXROWSIZE]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
70 char *row0 = rrow0, *row1 = rrow1, *row2 = rrow2/*, *row3 = rrow3*/; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
71 int rowsize = mpi->width; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
72 uint32_t nok = 0, max = vf->priv->max; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
73 int diff = vf->priv->diff; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
74 int i, j; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
75 register int n1, n2; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
76 unsigned char *cur0, *prv0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
77 register unsigned char *cur, *prv; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
78 |
16125 | 79 if (rowsize > MAXROWSIZE) rowsize = MAXROWSIZE; |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
80 // check if nothing to do |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
81 if (mpi->imgfmt == vf->priv->imgfmt) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
82 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
83 cur0 = mpi->planes[0] + mpi->stride[0]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
84 prv0 = mpi->planes[0]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
85 for (j = 1; j < mpi->height && nok <= max; j++) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
86 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
87 cur = cur0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
88 prv = prv0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
89 // analyse row (row0) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
90 if (mpi->flags & MP_IMGFLAG_PLANAR) // planar YUV - check luminance |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
91 for (i = 0; i < rowsize; i++) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
92 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
93 if (cur[0] - prv[0] > diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
94 row0[i] = 1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
95 else if (cur[0] - prv[0] < -diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
96 row0[i] = -1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
97 else |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
98 row0[i] = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
99 cur++; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
100 prv++; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
101 // check if row0 is 1 but row1 is 0, and row2 is 1 or row2 is 0 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
102 // but row3 is 1 so it's interlaced ptr (nok++) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
103 if (j > 2 && row0[i] > 0 && (row1[i] < 0 || (!row1[i] && row2[i] < 0)) && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
104 (++nok) > max) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
105 break; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
106 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
107 else if (mpi->bpp < 24) // RGB/BGR 16 - check all colors |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
108 for (i = 0; i < rowsize; i++) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
109 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
110 n1 = cur[0] + (cur[1]<<8); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
111 n2 = prv[0] + (prv[1]<<8); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
112 if ((n1&0x1f) - (n2&0x1f) > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
113 ((n1>>5)&0x3f) - ((n2>>5)&0x3f) > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
114 ((n1>>11)&0x1f) - ((n2>>11)&0x1f) > diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
115 row0[i] = 1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
116 else if ((n1&0x1f) - (n2&0x1f) < -diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
117 ((n1>>5)&0x3f) - ((n2>>5)&0x3f) < -diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
118 ((n1>>11)&0x1f) - ((n2>>11)&0x1f) < -diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
119 row0[i] = -1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
120 else |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
121 row0[i] = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
122 cur += 2; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
123 prv += 2; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
124 // check if row0 is 1 but row1 is 0, and row2 is 1 or row2 is 0 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
125 // but row3 is 1 so it's interlaced ptr (nok++) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
126 if (j > 2 && row0[i] > 0 && (row1[i] < 0 || (!row1[i] && row2[i] < 0)) && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
127 (++nok) > max) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
128 break; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
129 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
130 else // RGB/BGR 24/32 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
131 for (i = 0; i < rowsize; i++) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
132 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
133 if (cur[0] - prv[0] > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
134 cur[1] - prv[1] > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
135 cur[2] - prv[2] > diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
136 row0[i] = 1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
137 else if (prv[0] - cur[0] > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
138 prv[1] - cur[1] > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
139 prv[2] - cur[2] > diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
140 row0[i] = -1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
141 else |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
142 row0[i] = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
143 cur += mpi->bpp/8; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
144 prv += mpi->bpp/8; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
145 // check if row0 is 1 but row1 is 0, and row2 is 1 or row2 is 0 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
146 // but row3 is 1 so it's interlaced ptr (nok++) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
147 if (j > 2 && row0[i] > 0 && (row1[i] < 0 || (!row1[i] && row2[i] < 0)) && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
148 (++nok) > max) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
149 break; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
150 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
151 cur0 += mpi->stride[0]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
152 prv0 += mpi->stride[0]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
153 // rotate rows |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
154 cur = row2; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
155 row2 = row1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
156 row1 = row0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
157 row0 = cur; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
158 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
159 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
160 // check if number of interlaced is above of max |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
161 if (nok > max) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
162 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
163 // vf->priv->dfr++; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
164 if (vf->priv->was_dint < 1) // can skip at most one frame! |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
165 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
166 vf->priv->was_dint++; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
167 // vf->priv->rdfr++; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
168 // mp_msg (MSGT_VFILTER, MSGL_INFO, "DI:%d/%d ", vf->priv->rdfr, vf->priv->dfr); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
169 return 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
170 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
171 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
172 vf->priv->was_dint = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
173 // mp_msg (MSGT_VFILTER, MSGL_INFO, "DI:%d/%d ", vf->priv->rdfr, vf->priv->dfr); |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
174 return vf_next_put_image (vf, mpi, pts); |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
175 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
176 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
177 static int open (vf_instance_t *vf, char* args){ |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
178 vf->config = config; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
179 vf->put_image = put_image; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
180 // vf->default_reqs=VFCAP_ACCEPT_STRIDE; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
181 vf->priv = malloc (sizeof(struct vf_priv_s)); |
7631
04a6df4fb976
I found that default isn't optimal so it's changed a bit. :)
arpi
parents:
7369
diff
changeset
|
182 vf->priv->sense = 0.1; |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
183 vf->priv->level = 0.15; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
184 vf->priv->pmpi = NULL; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
185 if (args) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
186 sscanf (args, "%f:%f", &vf->priv->sense, &vf->priv->level); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
187 return 1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
188 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
189 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
190 vf_info_t vf_info_dint = { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
191 "drop interlaced frames", |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
192 "dint", |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
193 "A.G.", |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
194 "", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7631
diff
changeset
|
195 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7631
diff
changeset
|
196 NULL |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
197 }; |