annotate libmpcodecs/vf_tinterlace.c @ 35400:074069bb765a

Don't increment a pointer which might be null.
author ib
date Wed, 28 Nov 2012 11:57:52 +0000
parents 1a50a0bcd444
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
1 /*
26727
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
2 * Copyright (C) 2003 Michael Zucchi <notzed@ximian.com>
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
3 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
4 * This file is part of MPlayer.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
5 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
7 * it under the terms of the GNU General Public License as published by
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
9 * (at your option) any later version.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
10 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
14 * GNU General Public License for more details.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
15 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
16 * You should have received a copy of the GNU General Public License along
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
19 */
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
20
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
21 #include <stdio.h>
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
22 #include <stdlib.h>
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
23 #include <string.h>
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
24
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16137
diff changeset
25 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16137
diff changeset
26 #include "mp_msg.h"
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
27
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
28 #include "img_format.h"
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
29 #include "mp_image.h"
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
30 #include "vf.h"
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
31
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16137
diff changeset
32 #include "libvo/fastmemcpy.h"
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
33
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
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 mode;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
36 int frame;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
37 mp_image_t *dmpi;
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
38 };
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
39
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
40 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
41 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
42 int ret = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
43 mp_image_t *dmpi;
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
44
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
45 switch (vf->priv->mode) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
46 case 0:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
47 dmpi = vf->priv->dmpi;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
48 if (dmpi == NULL) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
49 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
50 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
51 MP_IMGFLAG_PRESERVE,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
52 mpi->width, mpi->height*2);
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
53
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
54 vf->priv->dmpi = dmpi;
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
55
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
56 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
57 dmpi->stride[0]*2, mpi->stride[0]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
58 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
59 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
60 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
61 dmpi->stride[1]*2, mpi->stride[1]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
62 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
63 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
64 dmpi->stride[2]*2, mpi->stride[2]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
65 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
66 } else {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
67 vf->priv->dmpi = NULL;
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
68
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
69 memcpy_pic(dmpi->planes[0]+dmpi->stride[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
70 dmpi->stride[0]*2, mpi->stride[0]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
71 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
72 memcpy_pic(dmpi->planes[1]+dmpi->stride[1], mpi->planes[1],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
73 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
74 dmpi->stride[1]*2, mpi->stride[1]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
75 memcpy_pic(dmpi->planes[2]+dmpi->stride[2], mpi->planes[2],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
76 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
77 dmpi->stride[2]*2, mpi->stride[2]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
78 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
79 ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
80 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
81 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
82 case 1:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
83 if (vf->priv->frame & 1)
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
84 ret = vf_next_put_image(vf, mpi, MP_NOPTS_VALUE);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
85 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
86 case 2:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
87 if ((vf->priv->frame & 1) == 0)
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
88 ret = vf_next_put_image(vf, mpi, MP_NOPTS_VALUE);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
89 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
90 case 3:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
91 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
92 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
93 mpi->width, mpi->height*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
94 /* fixme, just clear alternate lines */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
95 vf_mpi_clear(dmpi, 0, 0, dmpi->w, dmpi->h);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
96 if ((vf->priv->frame & 1) == 0) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
97 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
98 dmpi->stride[0]*2, mpi->stride[0]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
99 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
100 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
101 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
102 dmpi->stride[1]*2, mpi->stride[1]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
103 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
104 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
105 dmpi->stride[2]*2, mpi->stride[2]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
106 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
107 } else {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
108 memcpy_pic(dmpi->planes[0]+dmpi->stride[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
109 dmpi->stride[0]*2, mpi->stride[0]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
110 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
111 memcpy_pic(dmpi->planes[1]+dmpi->stride[1], mpi->planes[1],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
112 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
113 dmpi->stride[1]*2, mpi->stride[1]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
114 memcpy_pic(dmpi->planes[2]+dmpi->stride[2], mpi->planes[2],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
115 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
116 dmpi->stride[2]*2, mpi->stride[2]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
117 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
118 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
119 ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
120 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
121 case 4:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
122 // Interleave even lines (only) from Frame 'i' with odd
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
123 // lines (only) from Frame 'i+1', halving the Frame
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
124 // rate and preserving image height.
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
125
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
126 dmpi = vf->priv->dmpi;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26727
diff changeset
127
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
128 // @@ Need help: Should I set dmpi->fields to indicate
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
129 // that the (new) frame will be interlaced!? E.g. ...
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
130 // dmpi->fields |= MP_IMGFIELD_INTERLACED;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
131 // dmpi->fields |= MP_IMGFIELD_TOP_FIRST;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
132 // etc.
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26727
diff changeset
133
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
134 if (dmpi == NULL) {
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,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
138 mpi->width, mpi->height);
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
139
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
140 vf->priv->dmpi = dmpi;
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
141
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
142 my_memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
143 dmpi->stride[0]*2, mpi->stride[0]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
144 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
145 my_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
146 mpi->chroma_width, mpi->chroma_height/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
147 dmpi->stride[1]*2, mpi->stride[1]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
148 my_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
149 mpi->chroma_width, mpi->chroma_height/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
150 dmpi->stride[2]*2, mpi->stride[2]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
151 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
152 } else {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
153 vf->priv->dmpi = NULL;
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
154
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
155 my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
156 mpi->planes[0]+mpi->stride[0],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
157 mpi->w, mpi->h/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
158 dmpi->stride[0]*2, mpi->stride[0]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
159 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
160 my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
161 mpi->planes[1]+mpi->stride[1],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
162 mpi->chroma_width, mpi->chroma_height/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
163 dmpi->stride[1]*2, mpi->stride[1]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
164 my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
165 mpi->planes[2]+mpi->stride[2],
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
166 mpi->chroma_width, mpi->chroma_height/2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
167 dmpi->stride[2]*2, mpi->stride[2]*2);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
168 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
169 ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
170 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
171 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
172 }
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
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 vf->priv->frame++;
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
175
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
176 return ret;
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
177 }
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
178
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
179 static int query_format(struct vf_instance *vf, unsigned int fmt)
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
180 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
181 /* FIXME - figure out which other formats work */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
182 switch (fmt) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
183 case IMGFMT_YV12:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
184 case IMGFMT_IYUV:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
185 case IMGFMT_I420:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
186 return vf_next_query_format(vf, fmt);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
187 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
188 return 0;
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
189 }
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
190
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
191 static int config(struct vf_instance *vf,
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
192 int width, int height, int d_width, int d_height,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
193 unsigned int flags, unsigned int outfmt)
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
194 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
195 switch (vf->priv->mode) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
196 case 0:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
197 case 3:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
198 return vf_next_config(vf,width,height*2,d_width,d_height*2,flags,outfmt);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
199 case 1: /* odd frames */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
200 case 2: /* even frames */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
201 case 4: /* alternate frame (height-preserving) interlacing */
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
202 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
203 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
204 return 0;
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
205 }
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
206
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
207 static void uninit(struct vf_instance *vf)
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
208 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
209 free(vf->priv);
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
210 }
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
211
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 29263
diff changeset
212 static int vf_open(vf_instance_t *vf, char *args)
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
213 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
214 struct vf_priv_s *p;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
215 vf->config = config;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
216 vf->put_image = put_image;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
217 vf->query_format = query_format;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
218 vf->uninit = uninit;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
219 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
220 vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
35181
1a50a0bcd444 Use local variable since we already have it.
reimar
parents: 32702
diff changeset
221 p->mode = 0;
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
222 if (args)
35181
1a50a0bcd444 Use local variable since we already have it.
reimar
parents: 32702
diff changeset
223 sscanf(args, "%d", &p->mode);
1a50a0bcd444 Use local variable since we already have it.
reimar
parents: 32702
diff changeset
224 p->frame = 0;
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
225 return 1;
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
226 }
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
227
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 23666
diff changeset
228 const vf_info_t vf_info_tinterlace = {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
229 "temporal field interlacing",
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
230 "tinterlace",
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
231 "Michael Zucchi",
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
232 "",
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
233 vf_open,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
234 NULL
10571
07cfe1e1a2c9 'tinterlace' filter (partial inverse of tfields) by Not Zed <notzed@ximian.com> (with minor fixes for current cvs by me)
alex
parents:
diff changeset
235 };