00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #include <string.h>
00022
00023 #include "config.h"
00024 #include "mp_msg.h"
00025
00026 #include "img_format.h"
00027 #include "mp_image.h"
00028 #include "vf.h"
00029
00030 struct vf_priv_s {
00031 int skipflag;
00032 };
00033
00034 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
00035 {
00036 mp_image_t *dmpi;
00037
00038 if (vf->priv->skipflag)
00039 return vf->priv->skipflag = 0;
00040
00041 dmpi = vf_get_image(vf->next, mpi->imgfmt,
00042 MP_IMGTYPE_EXPORT, 0, mpi->width, mpi->height);
00043 vf_clone_mpi_attributes(dmpi, mpi);
00044
00045 dmpi->planes[0] = mpi->planes[0];
00046 dmpi->stride[0] = mpi->stride[0];
00047 if (dmpi->flags&MP_IMGFLAG_PLANAR) {
00048 dmpi->planes[1] = mpi->planes[1];
00049 dmpi->stride[1] = mpi->stride[1];
00050 dmpi->planes[2] = mpi->planes[2];
00051 dmpi->stride[2] = mpi->stride[2];
00052 }
00053
00054 return vf_next_put_image(vf, dmpi, pts);
00055 }
00056
00057 static int control(struct vf_instance *vf, int request, void* data)
00058 {
00059 switch (request) {
00060 case VFCTRL_SKIP_NEXT_FRAME:
00061 vf->priv->skipflag = 1;
00062 return CONTROL_TRUE;
00063 }
00064 return vf_next_control(vf, request, data);
00065 }
00066
00067 #if 0
00068 static int query_format(struct vf_instance *vf, unsigned int fmt)
00069 {
00070
00071 switch (fmt) {
00072 case IMGFMT_YV12:
00073 case IMGFMT_IYUV:
00074 case IMGFMT_I420:
00075 return vf_next_query_format(vf, fmt);
00076 }
00077 return 0;
00078 }
00079 #endif
00080
00081 static void uninit(struct vf_instance *vf)
00082 {
00083 free(vf->priv);
00084 }
00085
00086 static int vf_open(vf_instance_t *vf, char *args)
00087 {
00088 vf->put_image = put_image;
00089 vf->control = control;
00090 vf->uninit = uninit;
00091 vf->priv = calloc(1, sizeof(struct vf_priv_s));
00092 return 1;
00093 }
00094
00095 const vf_info_t vf_info_softskip = {
00096 "soft (post-filter) frame skipping for encoding",
00097 "softskip",
00098 "Rich Felker",
00099 "",
00100 vf_open,
00101 NULL
00102 };