annotate libmpcodecs/vf_telecine.c @ 22654:e69efc71da7b

Merge CFLAGS and INCLUDES where appropriate.
author diego
date Sat, 17 Mar 2007 01:18:03 +0000
parents 20aca9baf5d8
children a124f3abc1ec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9468
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
1 #include <stdio.h>
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
2 #include <stdlib.h>
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
3 #include <string.h>
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
4
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9593
diff changeset
5 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9593
diff changeset
6 #include "mp_msg.h"
9468
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
7
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
8 #include "img_format.h"
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
9 #include "mp_image.h"
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
10 #include "vf.h"
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
11
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9593
diff changeset
12 #include "libvo/fastmemcpy.h"
9468
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
13
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
14 struct vf_priv_s {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
15 int frame;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
16 };
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
17
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
18 static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
19 {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
20 int i;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
21 void *retval=dst;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
22
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
23 for(i=0; i<height; i++)
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
24 {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
25 memcpy(dst, src, bytesPerLine);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
26 src+= srcStride;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
27 dst+= dstStride;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
28 }
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
29
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
30 return retval;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
31 }
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
32
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
33 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
9468
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
34 {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
35 mp_image_t *dmpi;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
36 int ret;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
37
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
38 vf->priv->frame = (vf->priv->frame+1)%4;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
39
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
40 dmpi = vf_get_image(vf->next, mpi->imgfmt,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
41 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
42 MP_IMGFLAG_PRESERVE, mpi->width, mpi->height);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
43
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
44 ret = 0;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
45 // 0/0 1/1 2/2 2/3 3/0
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
46 switch (vf->priv->frame) {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
47 case 0:
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
48 my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
49 mpi->planes[0]+mpi->stride[0], mpi->w, mpi->h/2,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
50 dmpi->stride[0]*2, mpi->stride[0]*2);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
51 if (mpi->flags & MP_IMGFLAG_PLANAR) {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
52 my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
53 mpi->planes[1]+mpi->stride[1],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
54 mpi->chroma_width, mpi->chroma_height/2,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
55 dmpi->stride[1]*2, mpi->stride[1]*2);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
56 my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
57 mpi->planes[2]+mpi->stride[2],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
58 mpi->chroma_width, mpi->chroma_height/2,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
59 dmpi->stride[2]*2, mpi->stride[2]*2);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
60 }
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
61 ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
9468
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
62 case 1:
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
63 case 2:
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
64 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
65 dmpi->stride[0], mpi->stride[0]);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
66 if (mpi->flags & MP_IMGFLAG_PLANAR) {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
67 memcpy_pic(dmpi->planes[1], mpi->planes[1],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
68 mpi->chroma_width, mpi->chroma_height,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
69 dmpi->stride[1], mpi->stride[1]);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
70 memcpy_pic(dmpi->planes[2], mpi->planes[2],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
71 mpi->chroma_width, mpi->chroma_height,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
72 dmpi->stride[2], mpi->stride[2]);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
73 }
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
74 return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE) || ret;
9468
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
75 case 3:
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
76 my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
77 mpi->planes[0]+mpi->stride[0], mpi->w, mpi->h/2,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
78 dmpi->stride[0]*2, mpi->stride[0]*2);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
79 if (mpi->flags & MP_IMGFLAG_PLANAR) {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
80 my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
81 mpi->planes[1]+mpi->stride[1],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
82 mpi->chroma_width, mpi->chroma_height/2,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
83 dmpi->stride[1]*2, mpi->stride[1]*2);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
84 my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
85 mpi->planes[2]+mpi->stride[2],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
86 mpi->chroma_width, mpi->chroma_height/2,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
87 dmpi->stride[2]*2, mpi->stride[2]*2);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
88 }
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
89 ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
9468
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
90 my_memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h/2,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
91 dmpi->stride[0]*2, mpi->stride[0]*2);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
92 if (mpi->flags & MP_IMGFLAG_PLANAR) {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
93 my_memcpy_pic(dmpi->planes[1], mpi->planes[1],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
94 mpi->chroma_width, mpi->chroma_height/2,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
95 dmpi->stride[1]*2, mpi->stride[1]*2);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
96 my_memcpy_pic(dmpi->planes[2], mpi->planes[2],
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
97 mpi->chroma_width, mpi->chroma_height/2,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
98 dmpi->stride[2]*2, mpi->stride[2]*2);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
99 }
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
100 return ret;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
101 }
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
102 return 0;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
103 }
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
104
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
105 static int query_format(struct vf_instance_s* vf, unsigned int fmt)
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
106 {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
107 /* FIXME - figure out which other formats work */
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
108 switch (fmt) {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
109 case IMGFMT_YV12:
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
110 case IMGFMT_IYUV:
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
111 case IMGFMT_I420:
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
112 return vf_next_query_format(vf, fmt);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
113 }
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
114 return 0;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
115 }
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
116
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
117 static int config(struct vf_instance_s* vf,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
118 int width, int height, int d_width, int d_height,
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
119 unsigned int flags, unsigned int outfmt)
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
120 {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
121 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
122 }
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
123
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
124 static void uninit(struct vf_instance_s* vf)
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
125 {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
126 free(vf->priv);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
127 }
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
128
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
129 static int open(vf_instance_t *vf, char* args)
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
130 {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
131 //vf->config = config;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
132 vf->put_image = put_image;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
133 //vf->query_format = query_format;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
134 vf->uninit = uninit;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
135 vf->default_reqs = VFCAP_ACCEPT_STRIDE;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
136 vf->priv = calloc(1, sizeof(struct vf_priv_s));
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
137 vf->priv->frame = 1;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
138 if (args) sscanf(args, "%d", &vf->priv->frame);
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
139 vf->priv->frame--;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
140 return 1;
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
141 }
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
142
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
143 vf_info_t vf_info_telecine = {
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
144 "telecine filter",
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
145 "telecine",
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
146 "Rich Felker",
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
147 "",
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9468
diff changeset
148 open,
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9468
diff changeset
149 NULL
9468
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
150 };
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
151
356963ad4784 filter for applying 3:2 telecine to 23.976 fps progressive material.
rfelker
parents:
diff changeset
152