annotate m_struct.c @ 27148:858c01b81117

r26502: Document rgbtest arguments r26057: Fix copy&paste typo in rgbtest documentation r26198: Grayscale encoding/decoding with FFmpeg is no longer enabled, remove references r26221: Try to fix the description of what mbcmp influences, please fix if I misunderstood the code. r26231: better syntax for A key r26232: added missing escapes r26260: Experimental support for -framedrop with -correct-pts. r26271: Mention that '-frames 0' is useful with -identify, closes bug #1046. r26273: add "ipod" to the list of formats handled by lavf r26297: compacted new libavformat's 'ipod' description r26402: Enable runtime control for colorful and/or module name output r26427: Restore grayscale decoding support with FFmpeg. r26449: 10L, forgot to commit the documentation for the -noconfig options. r26460: restore options alphabetical order r26650: Update documentation for the gl2 driver to make clear gl is usually preferred. r26674: add h264 to list of supported codecs r26732: Mark new options Michael committed as undocumented. r26739: Oops, remove stray .TP. r26749: -psprobe can be used in mpeg-pes streams, too r26762: Add a new suboption to -vo xv and -vo xvmc that allows selection r26763: Remove '(pass 1/2)' from some lavcopts. These options really worked on r26795: Add support for AppleIR Remote as an input under Linux systems. r26798: Document the -noar command-line option in en/fr manpages. r26806: Document x264's AQ options r26853: Update gl vo section with the new force-pbo suboption. r26909: Add a slave command to stop stream playback. r26979: small spelling/wording fixes r26986: Document VIDIXIVTVALPHA environment variable. r26997: Fix codec-specific options syntax declaration to be less confusing and wrong. r27057: Ability for specifying TV standard individually for each TV channel. r27132: Fix/restore the description of the rectangle video filter. previously applied: r27169: add missing escapes and full stops for scaletempo filter r27179: remove two trailing whitespaces
author kraymer
date Mon, 30 Jun 2008 19:35:45 +0000
parents cc170348a763
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18258
96568be4bfdc Doxygen attack!
albeu
parents: 10718
diff changeset
1
96568be4bfdc Doxygen attack!
albeu
parents: 10718
diff changeset
2 /// \file
96568be4bfdc Doxygen attack!
albeu
parents: 10718
diff changeset
3 /// \ingroup OptionsStruct
96568be4bfdc Doxygen attack!
albeu
parents: 10718
diff changeset
4
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
5 #include "config.h"
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
6
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
7 #include <stdlib.h>
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
8 #include <string.h>
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
9
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
10 #include "m_option.h"
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
11 #include "m_struct.h"
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
12 #include "mp_msg.h"
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
13
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23873
diff changeset
14 const m_option_t*
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23873
diff changeset
15 m_struct_get_field(const m_struct_t* st,const char* f) {
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
16 int i;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
17
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
18 for(i = 0 ; st->fields[i].name ; i++) {
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
19 if(strcasecmp(st->fields[i].name,f) == 0)
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
20 return &st->fields[i];
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
21 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
22 return NULL;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
23 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
24
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
25 void*
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23873
diff changeset
26 m_struct_alloc(const m_struct_t* st) {
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
27 int i;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
28 void* r;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
29
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
30 if(!st->defaults) {
10718
alex
parents: 10594
diff changeset
31 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Struct %s needs defaults\n",st->name);
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
32 return NULL;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
33 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
34 // Check the struct fields
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
35 for(i = 0 ; st->fields[i].name ; i++) {
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
36 if(st->fields[i].type->flags & M_OPT_TYPE_INDIRECT) {
23873
49a433e2e78f cosmetics: misc typo fixes
diego
parents: 19104
diff changeset
37 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Struct %s->%s: Option types with the indirect flag are forbidden.\n",st->name,st->fields[i].name);
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
38 return NULL;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
39 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
40 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
41
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
42 r = calloc(1,st->size);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
43 memcpy(r,st->defaults,st->size);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
44
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
45 for(i = 0 ; st->fields[i].name ; i++) {
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
46 if(st->fields[i].type->flags & M_OPT_TYPE_DYNAMIC)
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
47 memset(M_ST_MB_P(r,st->fields[i].p),0,st->fields[i].type->size);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
48 m_option_copy(&st->fields[i],M_ST_MB_P(r,st->fields[i].p),M_ST_MB_P(st->defaults,st->fields[i].p));
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
49 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
50 return r;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
51 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
52
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
53 int
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23873
diff changeset
54 m_struct_set(const m_struct_t* st, void* obj, char* field, char* param) {
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23873
diff changeset
55 const m_option_t* f = m_struct_get_field(st,field);
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
56
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
57 if(!f) {
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
58 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Struct %s doesn't have any %s field\n",
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
59 st->name,field);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
60 return 0;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
61 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
62
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
63 if(f->type->parse(f,field,param,M_ST_MB_P(obj,f->p),M_CONFIG_FILE) < 0) {
9790
864cdb2debb0 Typo fix
albeu
parents: 8169
diff changeset
64 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Struct %s, field %s parsing error: %s\n",
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
65 st->name,field,param);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
66 return 0;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
67 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
68
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
69 return 1;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
70 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
71
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
72 void
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23873
diff changeset
73 m_struct_reset(const m_struct_t* st, void* obj, const char* field) {
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23873
diff changeset
74 const m_option_t* f;
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
75
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
76 if(!field) { // Reset all options
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
77 int i;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
78 for(i = 0 ; st->fields[i].name ; i++)
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
79 m_option_copy(&st->fields[i],M_ST_MB_P(obj,st->fields[i].p),M_ST_MB_P(st->defaults,st->fields[i].p));
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
80 return;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
81 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
82
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
83 // Only one
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
84 f = m_struct_get_field(st,field);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
85 if(!f) {
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
86 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Struct %s doesn't have any %s field\n",
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
87 st->name,field);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
88 return;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
89 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
90 m_option_copy(f,M_ST_MB_P(obj,f->p),M_ST_MB_P(st->defaults,f->p));
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
91 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
92
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
93 /// Free an allocated struct
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
94 void
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23873
diff changeset
95 m_struct_free(const m_struct_t* st, void* obj) {
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
96 int i;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
97
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
98 for(i = 0 ; st->fields[i].name ; i++)
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
99 m_option_free(&st->fields[i],M_ST_MB_P(obj,st->fields[i].p));
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
100 free(obj);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
101 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
102
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
103 void*
24966
cc170348a763 correct const usage in the option handling code so that tables can be
rfelker
parents: 23873
diff changeset
104 m_struct_copy(const m_struct_t* st, void* obj) {
8169
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
105 void* r = malloc(st->size);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
106 int i;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
107
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
108 memcpy(r,obj,st->size);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
109 for(i = 0 ; st->fields[i].name ; i++) {
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
110 if(st->fields[i].type->flags & M_OPT_TYPE_DYNAMIC)
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
111 memset(M_ST_MB_P(r,st->fields[i].p),0,st->fields[i].type->size);
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
112 m_option_copy(&st->fields[i],M_ST_MB_P(r,st->fields[i].p),M_ST_MB_P(obj,st->fields[i].p));
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
113 }
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
114
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
115 return r;
7c9253521f9c A struct setter. It allow you to setup struct from some user
albeu
parents:
diff changeset
116 }