Use proper length specifiers in mp_msg calls, fixes the warnings:
[mplayer/greg.git] / libmpcodecs / vf_softpulldown.c
blob30bb405eb59a67df3e50ebea911e44c69d6df0c9
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 #include "config.h"
6 #include "mp_msg.h"
8 #include "img_format.h"
9 #include "mp_image.h"
10 #include "vf.h"
12 #include "libvo/fastmemcpy.h"
14 struct vf_priv_s {
15 int state;
16 long long in;
17 long long out;
20 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
22 mp_image_t *dmpi;
23 int ret = 0;
24 int flags = mpi->fields;
25 int state = vf->priv->state;
27 dmpi = vf_get_image(vf->next, mpi->imgfmt,
28 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
29 MP_IMGFLAG_PRESERVE, mpi->width, mpi->height);
31 vf->priv->in++;
33 if ((state == 0 &&
34 !(flags & MP_IMGFIELD_TOP_FIRST)) ||
35 (state == 1 &&
36 flags & MP_IMGFIELD_TOP_FIRST)) {
37 mp_msg(MSGT_VFILTER, MSGL_WARN,
38 "softpulldown: Unexpected field flags: state=%d top_field_first=%d repeat_first_field=%d\n",
39 state,
40 (flags & MP_IMGFIELD_TOP_FIRST) != 0,
41 (flags & MP_IMGFIELD_REPEAT_FIRST) != 0);
42 state ^= 1;
45 if (state == 0) {
46 ret = vf_next_put_image(vf, mpi, MP_NOPTS_VALUE);
47 vf->priv->out++;
48 if (flags & MP_IMGFIELD_REPEAT_FIRST) {
49 my_memcpy_pic(dmpi->planes[0],
50 mpi->planes[0], mpi->w, mpi->h/2,
51 dmpi->stride[0]*2, mpi->stride[0]*2);
52 if (mpi->flags & MP_IMGFLAG_PLANAR) {
53 my_memcpy_pic(dmpi->planes[1],
54 mpi->planes[1],
55 mpi->chroma_width,
56 mpi->chroma_height/2,
57 dmpi->stride[1]*2,
58 mpi->stride[1]*2);
59 my_memcpy_pic(dmpi->planes[2],
60 mpi->planes[2],
61 mpi->chroma_width,
62 mpi->chroma_height/2,
63 dmpi->stride[2]*2,
64 mpi->stride[2]*2);
66 state=1;
68 } else {
69 my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
70 mpi->planes[0]+mpi->stride[0], mpi->w, mpi->h/2,
71 dmpi->stride[0]*2, mpi->stride[0]*2);
72 if (mpi->flags & MP_IMGFLAG_PLANAR) {
73 my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
74 mpi->planes[1]+mpi->stride[1],
75 mpi->chroma_width, mpi->chroma_height/2,
76 dmpi->stride[1]*2, mpi->stride[1]*2);
77 my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
78 mpi->planes[2]+mpi->stride[2],
79 mpi->chroma_width, mpi->chroma_height/2,
80 dmpi->stride[2]*2, mpi->stride[2]*2);
82 ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
83 vf->priv->out++;
84 if (flags & MP_IMGFIELD_REPEAT_FIRST) {
85 ret |= vf_next_put_image(vf, mpi, MP_NOPTS_VALUE);
86 vf->priv->out++;
87 state=0;
88 } else {
89 my_memcpy_pic(dmpi->planes[0],
90 mpi->planes[0], mpi->w, mpi->h/2,
91 dmpi->stride[0]*2, mpi->stride[0]*2);
92 if (mpi->flags & MP_IMGFLAG_PLANAR) {
93 my_memcpy_pic(dmpi->planes[1],
94 mpi->planes[1],
95 mpi->chroma_width,
96 mpi->chroma_height/2,
97 dmpi->stride[1]*2,
98 mpi->stride[1]*2);
99 my_memcpy_pic(dmpi->planes[2],
100 mpi->planes[2],
101 mpi->chroma_width,
102 mpi->chroma_height/2,
103 dmpi->stride[2]*2,
104 mpi->stride[2]*2);
109 vf->priv->state = state;
111 return ret;
114 static int config(struct vf_instance_s* vf,
115 int width, int height, int d_width, int d_height,
116 unsigned int flags, unsigned int outfmt)
118 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
121 static void uninit(struct vf_instance_s* vf)
123 mp_msg(MSGT_VFILTER, MSGL_INFO, "softpulldown: %lld frames in, %lld frames out\n", vf->priv->in, vf->priv->out);
124 free(vf->priv);
127 static int open(vf_instance_t *vf, char* args)
129 struct vf_priv_s *p;
130 vf->config = config;
131 vf->put_image = put_image;
132 vf->uninit = uninit;
133 vf->default_reqs = VFCAP_ACCEPT_STRIDE;
134 vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
135 vf->priv->state = 0;
136 return 1;
139 const vf_info_t vf_info_softpulldown = {
140 "mpeg2 soft 3:2 pulldown",
141 "softpulldown",
142 "Tobias Diedrich <ranma+mplayer@tdiedrich.de>",
144 open,
145 NULL