Make AVI demuxer more resilient against broken or incomplete files.
[mplayer/glamo.git] / libmpcodecs / vf_softskip.c
blob89727906ce7aa876d64bf0879b49f6d1cff5b9d3
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 struct vf_priv_s {
13 int skipflag;
16 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
18 mp_image_t *dmpi;
20 if (vf->priv->skipflag)
21 return vf->priv->skipflag = 0;
23 dmpi = vf_get_image(vf->next, mpi->imgfmt,
24 MP_IMGTYPE_EXPORT, 0, mpi->width, mpi->height);
25 vf_clone_mpi_attributes(dmpi, mpi);
27 dmpi->planes[0] = mpi->planes[0];
28 dmpi->stride[0] = mpi->stride[0];
29 if (dmpi->flags&MP_IMGFLAG_PLANAR) {
30 dmpi->planes[1] = mpi->planes[1];
31 dmpi->stride[1] = mpi->stride[1];
32 dmpi->planes[2] = mpi->planes[2];
33 dmpi->stride[2] = mpi->stride[2];
36 return vf_next_put_image(vf, dmpi, pts);
39 static int control(struct vf_instance_s* vf, int request, void* data)
41 switch (request) {
42 case VFCTRL_SKIP_NEXT_FRAME:
43 vf->priv->skipflag = 1;
44 return CONTROL_TRUE;
46 return vf_next_control(vf, request, data);
49 #if 0
50 static int query_format(struct vf_instance_s* vf, unsigned int fmt)
52 /* FIXME - figure out which other formats work */
53 switch (fmt) {
54 case IMGFMT_YV12:
55 case IMGFMT_IYUV:
56 case IMGFMT_I420:
57 return vf_next_query_format(vf, fmt);
59 return 0;
61 #endif
63 static void uninit(struct vf_instance_s* vf)
65 free(vf->priv);
68 static int open(vf_instance_t *vf, char* args)
70 vf->put_image = put_image;
71 vf->control = control;
72 vf->uninit = uninit;
73 vf->priv = calloc(1, sizeof(struct vf_priv_s));
74 return 1;
77 const vf_info_t vf_info_softskip = {
78 "soft (post-filter) frame skipping for encoding",
79 "softskip",
80 "Rich Felker",
81 "",
82 open,
83 NULL