annotate libmpcodecs/vf_format.c @ 17874:1973600f8f3e

Small fix with object list (-vf) help. Tell the user when an object have no option description instead of falling back to the "normal" help, like with -vf pp=help. Don't display a useless error message when querying the help of an object option (as in -vf scale=presize=help).
author albeu
date Wed, 15 Mar 2006 17:16:13 +0000
parents 6ff3379a0862
children bcd805923554
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
1 #include <stdio.h>
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
2 #include <stdlib.h>
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
3 #include <string.h>
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
4 #include <inttypes.h>
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
5
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 12999
diff changeset
6 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 12999
diff changeset
7 #include "mp_msg.h"
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
8
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
9 #include "img_format.h"
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
10 #include "mp_image.h"
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
11 #include "vf.h"
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
12
9601
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
13 #include "m_option.h"
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
14 #include "m_struct.h"
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
15
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
16 static struct vf_priv_s {
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
17 unsigned int fmt;
9601
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
18 } vf_priv_dflt = {
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
19 IMGFMT_YUY2
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
20 };
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
21
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
22 //===========================================================================//
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
23
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
24 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
25 if(fmt==vf->priv->fmt)
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
26 return vf_next_query_format(vf,fmt);
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
27 return 0;
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
28 }
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
29
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
30 static int open(vf_instance_t *vf, char* args){
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
31 vf->query_format=query_format;
6001
0263a3eabcd7 reset default caps
arpi
parents: 5607
diff changeset
32 vf->default_caps=0;
9601
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
33 if(!vf->priv) {
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
34 vf->priv=malloc(sizeof(struct vf_priv_s));
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
35 vf->priv->fmt=IMGFMT_YUY2;
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
36 }
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
37 if(args){
6872
e75137e656d3 added new formats: 444p,422p, 411p
arpi
parents: 6836
diff changeset
38 if(!strcasecmp(args,"444p")) vf->priv->fmt=IMGFMT_444P; else
e75137e656d3 added new formats: 444p,422p, 411p
arpi
parents: 6836
diff changeset
39 if(!strcasecmp(args,"422p")) vf->priv->fmt=IMGFMT_422P; else
e75137e656d3 added new formats: 444p,422p, 411p
arpi
parents: 6836
diff changeset
40 if(!strcasecmp(args,"411p")) vf->priv->fmt=IMGFMT_411P; else
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
41 if(!strcasecmp(args,"yuy2")) vf->priv->fmt=IMGFMT_YUY2; else
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
42 if(!strcasecmp(args,"yv12")) vf->priv->fmt=IMGFMT_YV12; else
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
43 if(!strcasecmp(args,"i420")) vf->priv->fmt=IMGFMT_I420; else
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 6001
diff changeset
44 if(!strcasecmp(args,"yvu9")) vf->priv->fmt=IMGFMT_YVU9; else
0a7be46617d8 yvu9 and if09 support
alex
parents: 6001
diff changeset
45 if(!strcasecmp(args,"if09")) vf->priv->fmt=IMGFMT_IF09; else
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
46 if(!strcasecmp(args,"iyuv")) vf->priv->fmt=IMGFMT_IYUV; else
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
47 if(!strcasecmp(args,"uyvy")) vf->priv->fmt=IMGFMT_UYVY; else
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
48 if(!strcasecmp(args,"bgr24")) vf->priv->fmt=IMGFMT_BGR24; else
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
49 if(!strcasecmp(args,"bgr32")) vf->priv->fmt=IMGFMT_BGR32; else
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
50 if(!strcasecmp(args,"bgr16")) vf->priv->fmt=IMGFMT_BGR16; else
5565
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5539
diff changeset
51 if(!strcasecmp(args,"bgr15")) vf->priv->fmt=IMGFMT_BGR15; else
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 6001
diff changeset
52 if(!strcasecmp(args,"bgr8")) vf->priv->fmt=IMGFMT_BGR8; else
6836
0e6860ff93e3 added missing formats :)
rfelker
parents: 6708
diff changeset
53 if(!strcasecmp(args,"bgr4")) vf->priv->fmt=IMGFMT_BGR4; else
9171
898e5270a46e fixing rgb4 & bgr4 (2 pixels per byte)
michael
parents: 6872
diff changeset
54 if(!strcasecmp(args,"bg4b")) vf->priv->fmt=IMGFMT_BG4B; else
6836
0e6860ff93e3 added missing formats :)
rfelker
parents: 6708
diff changeset
55 if(!strcasecmp(args,"bgr1")) vf->priv->fmt=IMGFMT_BGR1; else
6708
8058078f1248 support for external pp by divx4. some fixes/cosmetics?
alex
parents: 6525
diff changeset
56 if(!strcasecmp(args,"rgb24")) vf->priv->fmt=IMGFMT_RGB24; else
8058078f1248 support for external pp by divx4. some fixes/cosmetics?
alex
parents: 6525
diff changeset
57 if(!strcasecmp(args,"rgb32")) vf->priv->fmt=IMGFMT_RGB32; else
8058078f1248 support for external pp by divx4. some fixes/cosmetics?
alex
parents: 6525
diff changeset
58 if(!strcasecmp(args,"rgb16")) vf->priv->fmt=IMGFMT_RGB16; else
8058078f1248 support for external pp by divx4. some fixes/cosmetics?
alex
parents: 6525
diff changeset
59 if(!strcasecmp(args,"rgb15")) vf->priv->fmt=IMGFMT_RGB15; else
8058078f1248 support for external pp by divx4. some fixes/cosmetics?
alex
parents: 6525
diff changeset
60 if(!strcasecmp(args,"rgb8")) vf->priv->fmt=IMGFMT_RGB8; else
6836
0e6860ff93e3 added missing formats :)
rfelker
parents: 6708
diff changeset
61 if(!strcasecmp(args,"rgb4")) vf->priv->fmt=IMGFMT_RGB4; else
9171
898e5270a46e fixing rgb4 & bgr4 (2 pixels per byte)
michael
parents: 6872
diff changeset
62 if(!strcasecmp(args,"rg4b")) vf->priv->fmt=IMGFMT_RG4B; else
6836
0e6860ff93e3 added missing formats :)
rfelker
parents: 6708
diff changeset
63 if(!strcasecmp(args,"rgb1")) vf->priv->fmt=IMGFMT_RGB1; else
12999
bc8cda64ad7f RGBA variants
michael
parents: 9601
diff changeset
64 if(!strcasecmp(args,"rgba")) vf->priv->fmt=IMGFMT_RGBA; else
bc8cda64ad7f RGBA variants
michael
parents: 9601
diff changeset
65 if(!strcasecmp(args,"argb")) vf->priv->fmt=IMGFMT_ARGB; else
bc8cda64ad7f RGBA variants
michael
parents: 9601
diff changeset
66 if(!strcasecmp(args,"bgra")) vf->priv->fmt=IMGFMT_BGRA; else
bc8cda64ad7f RGBA variants
michael
parents: 9601
diff changeset
67 if(!strcasecmp(args,"abgr")) vf->priv->fmt=IMGFMT_ABGR; else
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
68 { printf("Unknown format name: '%s'\n",args);return 0;}
9601
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
69 }
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
70
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
71
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
72 return 1;
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
73 }
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
74
9601
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
75 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
76 static m_option_t vf_opts_fields[] = {
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
77 {"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL},
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
78 { NULL, NULL, 0, 0, 0, 0, NULL }
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
79 };
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
80
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
81 static m_struct_t vf_opts = {
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
82 "format",
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
83 sizeof(struct vf_priv_s),
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
84 &vf_priv_dflt,
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
85 vf_opts_fields
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
86 };
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
87
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
88 vf_info_t vf_info_format = {
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
89 "force output format",
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
90 "format",
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
91 "A'rpi",
5565
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5539
diff changeset
92 "FIXME! get_image()/put_image()",
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9171
diff changeset
93 open,
9601
0e265e2f3ac9 New options stuff
albeu
parents: 9593
diff changeset
94 &vf_opts
5539
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
95 };
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
96
eefc339440bc 2 new simple filters: yuy2 and format
arpi
parents:
diff changeset
97 //===========================================================================//