Mercurial > mplayer.hg
comparison libmpcodecs/vf_harddup.c @ 12334:eeddcef4fb08
"hard" frame duplication for mencoder. this finally makes it possible
to generate valid mpeg output from avi's that have duplicate frames in
them, or when using inverse telecine filters. to use it, put the
"harddup" filter at the end of your filter chain.
author | rfelker |
---|---|
date | Wed, 28 Apr 2004 04:02:46 +0000 |
parents | |
children | e0b92e840609 |
comparison
equal
deleted
inserted
replaced
12333:80036bf4a9f5 | 12334:eeddcef4fb08 |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 | |
5 #include "../config.h" | |
6 #include "../mp_msg.h" | |
7 | |
8 #include "img_format.h" | |
9 #include "mp_image.h" | |
10 #include "vf.h" | |
11 | |
12 #include "../libvo/fastmemcpy.h" | |
13 | |
14 struct vf_priv_s { | |
15 mp_image_t *last_mpi; | |
16 }; | |
17 | |
18 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi) | |
19 { | |
20 mp_image_t *dmpi; | |
21 int ret; | |
22 | |
23 vf->priv->last_mpi = mpi; | |
24 | |
25 dmpi = vf_get_image(vf->next, mpi->imgfmt, | |
26 MP_IMGTYPE_EXPORT, 0, mpi->width, mpi->height); | |
27 | |
28 dmpi->planes[0] = mpi->planes[0]; | |
29 dmpi->stride[0] = mpi->stride[0]; | |
30 if (dmpi->flags&MP_IMGFLAG_PLANAR) { | |
31 dmpi->planes[1] = mpi->planes[1]; | |
32 dmpi->stride[1] = mpi->stride[1]; | |
33 dmpi->planes[2] = mpi->planes[2]; | |
34 dmpi->stride[2] = mpi->stride[2]; | |
35 } | |
36 | |
37 return vf_next_put_image(vf, dmpi); | |
38 } | |
39 | |
40 static int control(struct vf_instance_s* vf, int request, void* data) | |
41 { | |
42 switch (request) { | |
43 case VFCTRL_DUPLICATE_FRAME: | |
44 if (!vf->priv->last_mpi) break; | |
45 // This is a huge hack. We assume nothing | |
46 // has been called earlier in the filter chain | |
47 // since the last put_image. This is reasonable | |
48 // because we're handling a duplicate frame! | |
49 puts("hard dup!"); | |
50 if (put_image(vf, vf->priv->last_mpi)) | |
51 return CONTROL_TRUE; | |
52 break; | |
53 } | |
54 return vf_next_control(vf, request, data); | |
55 } | |
56 | |
57 static int query_format(struct vf_instance_s* vf, unsigned int fmt) | |
58 { | |
59 /* FIXME - figure out which other formats work */ | |
60 switch (fmt) { | |
61 case IMGFMT_YV12: | |
62 case IMGFMT_IYUV: | |
63 case IMGFMT_I420: | |
64 return vf_next_query_format(vf, fmt); | |
65 } | |
66 return 0; | |
67 } | |
68 | |
69 static void uninit(struct vf_instance_s* vf) | |
70 { | |
71 free(vf->priv); | |
72 } | |
73 | |
74 static int open(vf_instance_t *vf, char* args) | |
75 { | |
76 vf->put_image = put_image; | |
77 vf->control = control; | |
78 vf->uninit = uninit; | |
79 vf->priv = calloc(1, sizeof(struct vf_priv_s)); | |
80 return 1; | |
81 } | |
82 | |
83 vf_info_t vf_info_harddup = { | |
84 "resubmit duplicate frames for encoding", | |
85 "harddup", | |
86 "Rich Felker", | |
87 "", | |
88 open, | |
89 NULL | |
90 }; | |
91 | |
92 |