annotate libmpcodecs/vf_tinterlace.c @ 29385:f9ae25067fe0

Fix 24bit audio playback. The reordering channels code had reoccurring bug where in switch(samplesize) block the case 3 (3 bytes) doesn't end with break; leading to execution of the next case 4 too. This mangles the already processed data and causes massive memory corruption.
author iive
date Sun, 19 Jul 2009 09:55:29 +0000
parents 0f1b5b68af32
children a7b908875c14
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 {
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
35 int mode;
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
36 int frame;
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
37 mp_image_t *dmpi;
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
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17367
diff changeset
40 static int put_image(struct vf_instance_s* 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 {
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
42 int ret = 0;
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
43 mp_image_t *dmpi;
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
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
45 switch (vf->priv->mode) {
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
46 case 0:
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
47 dmpi = vf->priv->dmpi;
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
48 if (dmpi == NULL) {
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
49 dmpi = vf_get_image(vf->next, mpi->imgfmt,
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
50 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
16137
23b7f5476b61 we do not read from dmpi, so it doesn't have to be readable
reimar
parents: 10571
diff changeset
51 MP_IMGFLAG_PRESERVE,
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
52 mpi->width, mpi->height*2);
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
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
54 vf->priv->dmpi = dmpi;
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
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
56 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->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
57 dmpi->stride[0]*2, mpi->stride[0]);
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
58 if (mpi->flags & MP_IMGFLAG_PLANAR) {
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
59 memcpy_pic(dmpi->planes[1], mpi->planes[1],
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
60 mpi->chroma_width, mpi->chroma_height,
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
61 dmpi->stride[1]*2, mpi->stride[1]);
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
62 memcpy_pic(dmpi->planes[2], mpi->planes[2],
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
63 mpi->chroma_width, mpi->chroma_height,
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
64 dmpi->stride[2]*2, mpi->stride[2]);
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
65 }
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
66 } else {
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
67 vf->priv->dmpi = NULL;
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
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
69 memcpy_pic(dmpi->planes[0]+dmpi->stride[0], mpi->planes[0], mpi->w, mpi->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
70 dmpi->stride[0]*2, mpi->stride[0]);
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
71 if (mpi->flags & MP_IMGFLAG_PLANAR) {
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
72 memcpy_pic(dmpi->planes[1]+dmpi->stride[1], mpi->planes[1],
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
73 mpi->chroma_width, mpi->chroma_height,
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
74 dmpi->stride[1]*2, mpi->stride[1]);
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
75 memcpy_pic(dmpi->planes[2]+dmpi->stride[2], mpi->planes[2],
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
76 mpi->chroma_width, mpi->chroma_height,
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
77 dmpi->stride[2]*2, mpi->stride[2]);
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
78 }
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17367
diff changeset
79 ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
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
80 }
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
81 break;
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
82 case 1:
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
83 if (vf->priv->frame & 1)
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17367
diff changeset
84 ret = vf_next_put_image(vf, mpi, MP_NOPTS_VALUE);
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
85 break;
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
86 case 2:
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
87 if ((vf->priv->frame & 1) == 0)
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17367
diff changeset
88 ret = vf_next_put_image(vf, mpi, MP_NOPTS_VALUE);
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
89 break;
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
90 case 3:
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
91 dmpi = vf_get_image(vf->next, mpi->imgfmt,
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
92 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
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
93 mpi->width, mpi->height*2);
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
94 /* fixme, just clear alternate lines */
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
95 vf_mpi_clear(dmpi, 0, 0, dmpi->w, dmpi->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
96 if ((vf->priv->frame & 1) == 0) {
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
97 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->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
98 dmpi->stride[0]*2, mpi->stride[0]);
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
99 if (mpi->flags & MP_IMGFLAG_PLANAR) {
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
100 memcpy_pic(dmpi->planes[1], mpi->planes[1],
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
101 mpi->chroma_width, mpi->chroma_height,
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
102 dmpi->stride[1]*2, mpi->stride[1]);
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
103 memcpy_pic(dmpi->planes[2], mpi->planes[2],
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
104 mpi->chroma_width, mpi->chroma_height,
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
105 dmpi->stride[2]*2, mpi->stride[2]);
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
106 }
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
107 } else {
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
108 memcpy_pic(dmpi->planes[0]+dmpi->stride[0], mpi->planes[0], mpi->w, mpi->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
109 dmpi->stride[0]*2, mpi->stride[0]);
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
110 if (mpi->flags & MP_IMGFLAG_PLANAR) {
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
111 memcpy_pic(dmpi->planes[1]+dmpi->stride[1], mpi->planes[1],
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
112 mpi->chroma_width, mpi->chroma_height,
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
113 dmpi->stride[1]*2, mpi->stride[1]);
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
114 memcpy_pic(dmpi->planes[2]+dmpi->stride[2], mpi->planes[2],
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
115 mpi->chroma_width, mpi->chroma_height,
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
116 dmpi->stride[2]*2, mpi->stride[2]);
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
117 }
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
118 }
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17367
diff changeset
119 ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
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
120 break;
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
121 case 4:
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
122 // Interleave even lines (only) from Frame 'i' with odd
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
123 // lines (only) from Frame 'i+1', halving the Frame
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
124 // rate and preserving image height.
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
125
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
126 dmpi = vf->priv->dmpi;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26727
diff changeset
127
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
128 // @@ Need help: Should I set dmpi->fields to indicate
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
129 // that the (new) frame will be interlaced!? E.g. ...
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
130 // dmpi->fields |= MP_IMGFIELD_INTERLACED;
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
131 // dmpi->fields |= MP_IMGFIELD_TOP_FIRST;
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
132 // etc.
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26727
diff changeset
133
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
134 if (dmpi == NULL) {
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
135 dmpi = vf_get_image(vf->next, mpi->imgfmt,
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
136 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
137 MP_IMGFLAG_PRESERVE,
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
138 mpi->width, mpi->height);
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
139
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
140 vf->priv->dmpi = dmpi;
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
141
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
142 my_memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h/2,
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
143 dmpi->stride[0]*2, mpi->stride[0]*2);
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
144 if (mpi->flags & MP_IMGFLAG_PLANAR) {
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
145 my_memcpy_pic(dmpi->planes[1], mpi->planes[1],
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
146 mpi->chroma_width, mpi->chroma_height/2,
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
147 dmpi->stride[1]*2, mpi->stride[1]*2);
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
148 my_memcpy_pic(dmpi->planes[2], mpi->planes[2],
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
149 mpi->chroma_width, mpi->chroma_height/2,
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
150 dmpi->stride[2]*2, mpi->stride[2]*2);
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
151 }
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
152 } else {
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
153 vf->priv->dmpi = NULL;
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
154
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26727
diff changeset
155 my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
156 mpi->planes[0]+mpi->stride[0],
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26727
diff changeset
157 mpi->w, mpi->h/2,
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
158 dmpi->stride[0]*2, mpi->stride[0]*2);
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
159 if (mpi->flags & MP_IMGFLAG_PLANAR) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26727
diff changeset
160 my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
161 mpi->planes[1]+mpi->stride[1],
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
162 mpi->chroma_width, mpi->chroma_height/2,
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
163 dmpi->stride[1]*2, mpi->stride[1]*2);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26727
diff changeset
164 my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
165 mpi->planes[2]+mpi->stride[2],
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
166 mpi->chroma_width, mpi->chroma_height/2,
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
167 dmpi->stride[2]*2, mpi->stride[2]*2);
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
168 }
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
169 ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
170 }
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
171 break;
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
172 }
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
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
174 vf->priv->frame++;
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
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
176 return ret;
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
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
179 static int query_format(struct vf_instance_s* vf, unsigned int fmt)
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 {
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
181 /* FIXME - figure out which other formats work */
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
182 switch (fmt) {
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
183 case IMGFMT_YV12:
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
184 case IMGFMT_IYUV:
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
185 case IMGFMT_I420:
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
186 return vf_next_query_format(vf, fmt);
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
187 }
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
188 return 0;
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
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
191 static int config(struct vf_instance_s* vf,
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
192 int width, int height, int d_width, int d_height,
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
193 unsigned int flags, unsigned int outfmt)
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 {
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
195 switch (vf->priv->mode) {
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
196 case 0:
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
197 case 3:
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
198 return vf_next_config(vf,width,height*2,d_width,d_height*2,flags,outfmt);
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
199 case 1: /* odd frames */
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
200 case 2: /* even frames */
18055
d1c6b9abbc73 New mode for tinterlace filter
iive
parents: 17906
diff changeset
201 case 4: /* alternate frame (height-preserving) interlacing */
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
202 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
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
203 }
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
204 return 0;
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
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
207 static void uninit(struct vf_instance_s* vf)
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 {
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
209 free(vf->priv);
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
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
212 static int open(vf_instance_t *vf, char* args)
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 {
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
214 struct vf_priv_s *p;
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
215 vf->config = config;
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
216 vf->put_image = put_image;
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
217 vf->query_format = query_format;
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
218 vf->uninit = uninit;
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
219 vf->default_reqs = VFCAP_ACCEPT_STRIDE;
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
220 vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
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
221 vf->priv->mode = 0;
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
222 if (args)
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
223 sscanf(args, "%d", &vf->priv->mode);
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
224 vf->priv->frame = 0;
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
225 return 1;
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 = {
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
229 "temporal field interlacing",
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
230 "tinterlace",
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
231 "Michael Zucchi",
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
232 "",
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
233 open,
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
234 NULL
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 };