]> git.sesse.net Git - ffmpeg/blob - libavfilter/libmpcodecs/vf_softskip.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavfilter / libmpcodecs / vf_softskip.c
1 /*
2  * This file is part of MPlayer.
3  *
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.
8  *
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.
13  *
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.
17  */
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22
23 #include "config.h"
24 #include "mp_msg.h"
25
26 #include "img_format.h"
27 #include "mp_image.h"
28 #include "vf.h"
29
30 struct vf_priv_s {
31     int skipflag;
32 };
33
34 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
35 {
36     mp_image_t *dmpi;
37
38     if (vf->priv->skipflag)
39         return vf->priv->skipflag = 0;
40
41     dmpi = vf_get_image(vf->next, mpi->imgfmt,
42         MP_IMGTYPE_EXPORT, 0, mpi->width, mpi->height);
43     vf_clone_mpi_attributes(dmpi, mpi);
44
45     dmpi->planes[0] = mpi->planes[0];
46     dmpi->stride[0] = mpi->stride[0];
47     if (dmpi->flags&MP_IMGFLAG_PLANAR) {
48         dmpi->planes[1] = mpi->planes[1];
49         dmpi->stride[1] = mpi->stride[1];
50         dmpi->planes[2] = mpi->planes[2];
51         dmpi->stride[2] = mpi->stride[2];
52     }
53
54     return vf_next_put_image(vf, dmpi, pts);
55 }
56
57 static int control(struct vf_instance *vf, int request, void* data)
58 {
59     switch (request) {
60     case VFCTRL_SKIP_NEXT_FRAME:
61         vf->priv->skipflag = 1;
62         return CONTROL_TRUE;
63     }
64     return vf_next_control(vf, request, data);
65 }
66
67 #if 0
68 static int query_format(struct vf_instance *vf, unsigned int fmt)
69 {
70     /* FIXME - figure out which other formats work */
71     switch (fmt) {
72     case IMGFMT_YV12:
73     case IMGFMT_IYUV:
74     case IMGFMT_I420:
75         return vf_next_query_format(vf, fmt);
76     }
77     return 0;
78 }
79 #endif
80
81 static void uninit(struct vf_instance *vf)
82 {
83     free(vf->priv);
84 }
85
86 static int vf_open(vf_instance_t *vf, char *args)
87 {
88     vf->put_image = put_image;
89     vf->control = control;
90     vf->uninit = uninit;
91     vf->priv = calloc(1, sizeof(struct vf_priv_s));
92     return 1;
93 }
94
95 const vf_info_t vf_info_softskip = {
96     "soft (post-filter) frame skipping for encoding",
97     "softskip",
98     "Rich Felker",
99     "",
100     vf_open,
101     NULL
102 };