Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #include <stdio.h>
00066 #include <stdlib.h>
00067 #include <string.h>
00068
00069 #include "config.h"
00070 #include "mp_msg.h"
00071 #include "help_mp.h"
00072 #include "cpudetect.h"
00073
00074 #include "img_format.h"
00075 #include "mp_image.h"
00076 #include "vf.h"
00077
00078
00079
00080
00081
00082 struct vf_priv_s {
00083
00084 int frame_cur;
00085
00086 int frame_step;
00087
00088 int dump_iframe;
00089 };
00090
00091
00092 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
00093 {
00094 mp_image_t *dmpi;
00095 struct vf_priv_s *priv;
00096 int skip;
00097
00098 priv = vf->priv;
00099
00100
00101
00102
00103 if (priv->dump_iframe) {
00104 if (mpi->pict_type == 1) {
00105 mp_msg(MSGT_VFILTER, MSGL_INFO, "I!\n");
00106 }
00107 }
00108
00109
00110 if (priv->dump_iframe == 2) {
00111
00112 skip = mpi->pict_type == 1 ? 0 : 1;
00113 }
00114 else {
00115
00116 skip = 0;
00117 if ((priv->frame_step != 0) && ((priv->frame_cur % priv->frame_step) != 0)) {
00118 skip = 1;
00119 }
00120 }
00121
00122 ++priv->frame_cur;
00123
00124 if (skip == 0) {
00125
00126 dmpi=vf_get_image(vf->next, mpi->imgfmt,
00127 MP_IMGTYPE_EXPORT, 0,
00128 mpi->w, mpi->h);
00129
00130 dmpi->planes[0] = mpi->planes[0];
00131 dmpi->planes[1] = mpi->planes[1];
00132 dmpi->planes[2] = mpi->planes[2];
00133
00134 dmpi->stride[0] = mpi->stride[0];
00135 dmpi->stride[1] = mpi->stride[1];
00136 dmpi->stride[2] = mpi->stride[2];
00137
00138 dmpi->width = mpi->width;
00139 dmpi->height = mpi->height;
00140
00141
00142 return vf_next_put_image(vf, dmpi, pts);
00143 }
00144
00145
00146 return 0;
00147 }
00148
00149 static void uninit(struct vf_instance *vf)
00150 {
00151
00152 free(vf->priv);
00153 }
00154
00155
00156 static int vf_open(vf_instance_t *vf, char *args)
00157 {
00158 struct vf_priv_s *p;
00159
00160 vf->put_image = put_image;
00161 vf->uninit = uninit;
00162 vf->default_reqs = VFCAP_ACCEPT_STRIDE;
00163 vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
00164 if (p == NULL) {
00165 return 0;
00166 }
00167
00168 if (args != NULL) {
00169 #ifdef DUMP_FORMAT_DATA
00170 if (*args == 'd') {
00171 p->dump_iframe = 3;
00172 }
00173 else
00174 #endif
00175 if (*args == 'I') {
00176
00177 p->dump_iframe = 2;
00178 }
00179 else {
00180 if (*args == 'i') {
00181
00182 p->dump_iframe = 1;
00183 ++args;
00184 }
00185
00186 if (*args != '\0') {
00187 p->frame_step = atoi(args);
00188 if (p->frame_step <= 0) {
00189 mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_ErrorParsingArgument);
00190 return 0;
00191 }
00192 }
00193 }
00194 }
00195 return 1;
00196 }
00197
00198 const vf_info_t vf_info_framestep = {
00199 "Dump one every n / key frames",
00200 "framestep",
00201 "Daniele Forghieri",
00202 "",
00203 vf_open,
00204 NULL
00205 };