mp_msg: print messages to stdout, statusline to stderr
[mplayer.git] / libmpcodecs / vf_harddup.c
blobb2b1bd64830334147628ec5d290d099d482c456a
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
23 #include "config.h"
24 #include "mp_msg.h"
26 #include "img_format.h"
27 #include "mp_image.h"
28 #include "vf.h"
30 struct vf_priv_s {
31 mp_image_t *last_mpi;
34 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
36 mp_image_t *dmpi;
38 vf->priv->last_mpi = mpi;
40 dmpi = vf_get_image(vf->next, mpi->imgfmt,
41 MP_IMGTYPE_EXPORT, 0, mpi->width, mpi->height);
43 dmpi->planes[0] = mpi->planes[0];
44 dmpi->stride[0] = mpi->stride[0];
45 if (dmpi->flags&MP_IMGFLAG_PLANAR) {
46 dmpi->planes[1] = mpi->planes[1];
47 dmpi->stride[1] = mpi->stride[1];
48 dmpi->planes[2] = mpi->planes[2];
49 dmpi->stride[2] = mpi->stride[2];
52 return vf_next_put_image(vf, dmpi, pts);
55 static int control(struct vf_instance *vf, int request, void* data)
57 switch (request) {
58 case VFCTRL_DUPLICATE_FRAME:
59 if (!vf->priv->last_mpi) break;
60 // This is a huge hack. We assume nothing
61 // has been called earlier in the filter chain
62 // since the last put_image. This is reasonable
63 // because we're handling a duplicate frame!
64 if (put_image(vf, vf->priv->last_mpi, MP_NOPTS_VALUE))
65 return CONTROL_TRUE;
66 break;
68 return vf_next_control(vf, request, data);
71 static void uninit(struct vf_instance *vf)
73 free(vf->priv);
76 static int vf_open(vf_instance_t *vf, char *args)
78 vf->put_image = put_image;
79 vf->control = control;
80 vf->uninit = uninit;
81 vf->priv = calloc(1, sizeof(struct vf_priv_s));
82 return 1;
85 const vf_info_t vf_info_harddup = {
86 "resubmit duplicate frames for encoding",
87 "harddup",
88 "Rich Felker",
89 "",
90 vf_open,
91 NULL