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 mp_image_t *last_mpi;
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 vf->priv->last_mpi = mpi;
00039
00040 dmpi = vf_get_image(vf->next, mpi->imgfmt,
00041 MP_IMGTYPE_EXPORT, 0, mpi->width, mpi->height);
00042
00043 dmpi->planes[0] = mpi->planes[0];
00044 dmpi->stride[0] = mpi->stride[0];
00045 if (dmpi->flags&MP_IMGFLAG_PLANAR) {
00046 dmpi->planes[1] = mpi->planes[1];
00047 dmpi->stride[1] = mpi->stride[1];
00048 dmpi->planes[2] = mpi->planes[2];
00049 dmpi->stride[2] = mpi->stride[2];
00050 }
00051
00052 return vf_next_put_image(vf, dmpi, pts);
00053 }
00054
00055 static int control(struct vf_instance *vf, int request, void* data)
00056 {
00057 switch (request) {
00058 case VFCTRL_DUPLICATE_FRAME:
00059 if (!vf->priv->last_mpi) break;
00060
00061
00062
00063
00064 if (put_image(vf, vf->priv->last_mpi, MP_NOPTS_VALUE))
00065 return CONTROL_TRUE;
00066 break;
00067 }
00068 return vf_next_control(vf, request, data);
00069 }
00070
00071 static void uninit(struct vf_instance *vf)
00072 {
00073 free(vf->priv);
00074 }
00075
00076 static int vf_open(vf_instance_t *vf, char *args)
00077 {
00078 vf->put_image = put_image;
00079 vf->control = control;
00080 vf->uninit = uninit;
00081 vf->priv = calloc(1, sizeof(struct vf_priv_s));
00082 return 1;
00083 }
00084
00085 const vf_info_t vf_info_harddup = {
00086 "resubmit duplicate frames for encoding",
00087 "harddup",
00088 "Rich Felker",
00089 "",
00090 vf_open,
00091 NULL
00092 };