Mercurial > mplayer.hg
annotate libmpcodecs/vf_dint.c @ 29087:290420c32921
Remove unnecessary malloc.h #includes and related #ifdeffery.
author | diego |
---|---|
date | Thu, 02 Apr 2009 09:20:48 +0000 |
parents | 00fff9a3b735 |
children | bbb6ebec87a0 |
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" | |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
8 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
9 #include "mp_image.h" |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
10 #include "img_format.h" |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
11 #include "vf.h" |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
12 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
13 struct vf_priv_s { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
14 float sense; // first parameter |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
15 float level; // second parameter |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
16 unsigned int imgfmt; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
17 char diff; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
18 uint32_t max; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
19 // int dfr; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
20 // int rdfr; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
21 int was_dint; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
22 mp_image_t *pmpi; // previous mpi |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
23 }; |
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 #define MAXROWSIZE 1200 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
26 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
27 static int config (struct vf_instance_s* vf, |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
28 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
|
29 unsigned int flags, unsigned int outfmt) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
30 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
31 int rowsize; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
32 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
33 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
|
34 0, width, height); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
35 if (!(vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
36 outfmt != IMGFMT_RGB32 && outfmt != IMGFMT_BGR32 && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
37 outfmt != IMGFMT_RGB24 && outfmt != IMGFMT_BGR24 && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
38 outfmt != IMGFMT_RGB16 && outfmt != IMGFMT_BGR16) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
39 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
40 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
|
41 return 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
42 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
43 vf->priv->imgfmt = outfmt; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
44 // recalculate internal values |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
45 rowsize = vf->priv->pmpi->width; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
46 if (rowsize > MAXROWSIZE) rowsize = MAXROWSIZE; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
47 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
|
48 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
|
49 vf->priv->diff = vf->priv->sense * 256; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
50 else |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
51 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
|
52 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
|
53 if (!(vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) && |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
54 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
|
55 vf->priv->diff = 31; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
56 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
|
57 vf->priv->pmpi->width, vf->priv->pmpi->height, |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
58 (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
|
59 // vf->priv->rdfr = vf->priv->dfr = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
60 vf->priv->was_dint = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
61 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
|
62 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
63 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
64 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
|
65 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
66 char rrow0[MAXROWSIZE]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
67 char rrow1[MAXROWSIZE]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
68 char rrow2[MAXROWSIZE]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
69 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
|
70 int rowsize = mpi->width; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
71 uint32_t nok = 0, max = vf->priv->max; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
72 int diff = vf->priv->diff; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
73 int i, j; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
74 register int n1, n2; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
75 unsigned char *cur0, *prv0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
76 register unsigned char *cur, *prv; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
77 |
16125 | 78 if (rowsize > MAXROWSIZE) rowsize = MAXROWSIZE; |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
79 // check if nothing to do |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
80 if (mpi->imgfmt == vf->priv->imgfmt) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
81 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
82 cur0 = mpi->planes[0] + mpi->stride[0]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
83 prv0 = mpi->planes[0]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
84 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
|
85 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
86 cur = cur0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
87 prv = prv0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
88 // analyse row (row0) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
89 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
|
90 for (i = 0; i < rowsize; i++) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
91 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
92 if (cur[0] - prv[0] > diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
93 row0[i] = 1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
94 else if (cur[0] - prv[0] < -diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
95 row0[i] = -1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
96 else |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
97 row0[i] = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
98 cur++; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
99 prv++; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
100 // 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
|
101 // 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
|
102 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
|
103 (++nok) > max) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
104 break; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
105 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
106 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
|
107 for (i = 0; i < rowsize; i++) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
108 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
109 n1 = cur[0] + (cur[1]<<8); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
110 n2 = prv[0] + (prv[1]<<8); |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
111 if ((n1&0x1f) - (n2&0x1f) > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
112 ((n1>>5)&0x3f) - ((n2>>5)&0x3f) > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
113 ((n1>>11)&0x1f) - ((n2>>11)&0x1f) > diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
114 row0[i] = 1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
115 else if ((n1&0x1f) - (n2&0x1f) < -diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
116 ((n1>>5)&0x3f) - ((n2>>5)&0x3f) < -diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
117 ((n1>>11)&0x1f) - ((n2>>11)&0x1f) < -diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
118 row0[i] = -1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
119 else |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
120 row0[i] = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
121 cur += 2; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
122 prv += 2; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
123 // 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
|
124 // 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
|
125 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
|
126 (++nok) > max) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
127 break; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
128 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
129 else // RGB/BGR 24/32 |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
130 for (i = 0; i < rowsize; i++) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
131 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
132 if (cur[0] - prv[0] > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
133 cur[1] - prv[1] > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
134 cur[2] - prv[2] > diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
135 row0[i] = 1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
136 else if (prv[0] - cur[0] > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
137 prv[1] - cur[1] > diff || |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
138 prv[2] - cur[2] > diff) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
139 row0[i] = -1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
140 else |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
141 row0[i] = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
142 cur += mpi->bpp/8; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
143 prv += mpi->bpp/8; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
144 // 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
|
145 // 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
|
146 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
|
147 (++nok) > max) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
148 break; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
149 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
150 cur0 += mpi->stride[0]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
151 prv0 += mpi->stride[0]; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
152 // rotate rows |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
153 cur = row2; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
154 row2 = row1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
155 row1 = row0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
156 row0 = cur; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
157 } |
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 // 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
|
160 if (nok > max) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
161 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
162 // vf->priv->dfr++; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
163 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
|
164 { |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
165 vf->priv->was_dint++; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
166 // vf->priv->rdfr++; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
167 // 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
|
168 return 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
169 } |
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 vf->priv->was_dint = 0; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
172 // 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
|
173 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
|
174 } |
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 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
|
177 vf->config = config; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
178 vf->put_image = put_image; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
179 // vf->default_reqs=VFCAP_ACCEPT_STRIDE; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
180 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
|
181 vf->priv->sense = 0.1; |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
182 vf->priv->level = 0.15; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
183 vf->priv->pmpi = NULL; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
184 if (args) |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
185 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
|
186 return 1; |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
187 } |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
188 |
25221 | 189 const vf_info_t vf_info_dint = { |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
190 "drop interlaced frames", |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
191 "dint", |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
192 "A.G.", |
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
193 "", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7631
diff
changeset
|
194 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7631
diff
changeset
|
195 NULL |
7369
b34b005ab4f8
drop-deinterlace (dint) filter by Andriy N. Gritsenko <andrej@lucky.net>
arpi
parents:
diff
changeset
|
196 }; |