11 #include "img_format.h"
22 //===========================================================================//
23 static int config(struct vf_instance
* vf
,
24 int width
, int height
, int d_width
, int d_height
,
25 unsigned int flags
, unsigned int outfmt
){
26 return vf_next_config(vf
,width
,height
,d_width
,d_height
,flags
,outfmt
);
29 static int put_image(struct vf_instance
* vf
, mp_image_t
*mpi
, double pts
){
31 struct vf_priv_s
*priv
= (struct vf_priv_s
*) vf
->priv
;
33 // hope we'll get DR buffer:
34 if(mpi
->flags
&MP_IMGFLAG_DIRECT
){
35 dmpi
=(mp_image_t
*)mpi
->priv
;
37 dmpi
=vf_get_image(vf
->next
, mpi
->imgfmt
, MP_IMGTYPE_EXPORT
, 0, mpi
->w
, mpi
->h
);
39 dmpi
->planes
[0]=mpi
->planes
[0];
40 dmpi
->planes
[1]=mpi
->planes
[1];
41 dmpi
->planes
[2]=mpi
->planes
[2];
42 dmpi
->stride
[0]=mpi
->stride
[0];
43 dmpi
->stride
[1]=mpi
->stride
[1];
44 dmpi
->stride
[2]=mpi
->stride
[2];
45 dmpi
->width
=mpi
->width
;
46 dmpi
->height
=mpi
->height
;
48 if (pts
== MP_NOPTS_VALUE
) {
49 if (!priv
->noptswarn
) {
51 mp_msg(MSGT_VFILTER
, MSGL_WARN
, MSGTR_MPCODECS_TCDumpNoPTS
);
54 if (!priv
->tcv2file
&& priv
->tcv2filename
) {
55 priv
->tcv2file
= fopen(priv
->tcv2filename
,"w");
56 if (!priv
->tcv2file
) {
57 mp_msg(MSGT_VFILTER
, MSGL_WARN
, MSGTR_MPCODECS_TCDumpOpenFail
,
59 free(priv
->tcv2filename
);
60 priv
->tcv2filename
= NULL
;
62 fprintf(priv
->tcv2file
, "# timecode format v2\n");
65 fprintf(priv
->tcv2file
, "%.2f\n", pts
*1000);
68 return vf_next_put_image(vf
,dmpi
, pts
);
71 static void uninit(struct vf_instance
*vf
) {
72 struct vf_priv_s
*priv
= (struct vf_priv_s
*) vf
->priv
;
74 fclose(priv
->tcv2file
);
75 if (priv
->tcv2filename
)
76 free (priv
->tcv2filename
);
80 //===========================================================================//
82 static int open(vf_instance_t
*vf
, char* args
){
84 vf
->put_image
=put_image
;
86 vf
->priv
=malloc(sizeof(struct vf_priv_s
));
87 vf
->priv
->tcv2filename
= strdup(args
? args
: "timecodesv2.txt");
88 vf
->priv
->tcv2file
= NULL
;
89 vf
->priv
->noptswarn
= 0;
93 vf_info_t vf_info_tcdump
= {
94 "dump frame timecodes to file",