comparison libmpcodecs/vf_format.c @ 31265:59f9bf345c0f

Extend -vf format to allow substituting the format for a compatible one (e.g. chaning rgb24 to bgr24).
author reimar
date Sat, 05 Jun 2010 17:55:20 +0000
parents f19d56a023db
children
comparison
equal deleted inserted replaced
31264:f19d56a023db 31265:59f9bf345c0f
32 #include "m_option.h" 32 #include "m_option.h"
33 #include "m_struct.h" 33 #include "m_struct.h"
34 34
35 static struct vf_priv_s { 35 static struct vf_priv_s {
36 unsigned int fmt; 36 unsigned int fmt;
37 unsigned int outfmt;
37 } const vf_priv_dflt = { 38 } const vf_priv_dflt = {
38 IMGFMT_YUY2 39 IMGFMT_YUY2,
40 0
39 }; 41 };
40 42
41 //===========================================================================// 43 //===========================================================================//
42 44
43 static int query_format(struct vf_instance *vf, unsigned int fmt){ 45 static int query_format(struct vf_instance *vf, unsigned int fmt){
44 if(fmt==vf->priv->fmt) 46 if(fmt==vf->priv->fmt) {
47 if (vf->priv->outfmt)
48 fmt = vf->priv->outfmt;
45 return vf_next_query_format(vf,fmt); 49 return vf_next_query_format(vf,fmt);
50 }
46 return 0; 51 return 0;
52 }
53
54 static int config(struct vf_instance *vf, int width, int height,
55 int d_width, int d_height,
56 unsigned flags, unsigned outfmt){
57 return vf_next_config(vf, width, height, d_width, d_height, flags, vf->priv->outfmt);
47 } 58 }
48 59
49 static int vf_open(vf_instance_t *vf, char *args){ 60 static int vf_open(vf_instance_t *vf, char *args){
50 vf->query_format=query_format; 61 vf->query_format=query_format;
51 vf->draw_slice=vf_next_draw_slice; 62 vf->draw_slice=vf_next_draw_slice;
52 vf->default_caps=0; 63 vf->default_caps=0;
64 if (vf->priv->outfmt)
65 vf->config=config;
53 return 1; 66 return 1;
54 } 67 }
55 68
56 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) 69 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
57 static const m_option_t vf_opts_fields[] = { 70 static const m_option_t vf_opts_fields[] = {
58 {"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL}, 71 {"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL},
72 {"outfmt", ST_OFF(outfmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL},
59 { NULL, NULL, 0, 0, 0, 0, NULL } 73 { NULL, NULL, 0, 0, 0, 0, NULL }
60 }; 74 };
61 75
62 static const m_struct_t vf_opts = { 76 static const m_struct_t vf_opts = {
63 "format", 77 "format",