Changeset 2890:7b1a574adb24 in roaraudio


Ignore:
Timestamp:
10/10/09 02:31:25 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

function to parse codec parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/config.c

    r2888 r2890  
    6868} 
    6969 
     70#define _P_FP(v)   ((int)(atof((v))*256.0)) 
     71#define _P_INT(v)  (atoi((v))) 
     72#define _P_BOOL(v) (*(v) == 'y' || *(v) == 'j' || *(v) == 't' || *(v) == '1' ? 1 : 0) 
     73 
     74static int roar_libroar_config_parse_codec(struct roar_libroar_config * config, char * txt) { 
     75 struct roar_libroar_config_codec * codec_cfg; 
     76 int codec; 
     77 char * codec_str, * option_str, * value_str; 
     78 
     79 if ( config == NULL || txt == NULL ) 
     80  return -1; 
     81 
     82 codec_str = txt; 
     83 
     84 option_str = strtok(txt, ":"); 
     85 
     86 if ( option_str == NULL ) 
     87  return -1; 
     88 
     89 *option_str = 0; 
     90  option_str++; 
     91 
     92 value_str = strtok(option_str, ":"); 
     93 
     94 if ( value_str == NULL ) 
     95  return -1; 
     96 
     97 *value_str = 0; 
     98  value_str++; 
     99 
     100 if ( (codec = roar_str2codec(codec_str)) == -1 ) { 
     101  ROAR_WARN("roar_libroar_config_parse_codec(*): Unknown codec: %s", codec_str); 
     102  return -1; 
     103 } 
     104 
     105 if ( (codec_cfg = roar_libroar_config_codec_get(codec, 1)) == NULL ) 
     106  return -1; 
     107 
     108 if ( !strcmp(option_str, "q") || !strcmp(option_str, "quality") ) { 
     109  codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_Q; 
     110  codec_cfg->q = _P_FP(value_str); 
     111 } else if ( !strcmp(option_str, "complexity") ) { 
     112  codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_COMPLEXITY; 
     113  codec_cfg->complexity = _P_FP(value_str); 
     114 } else if ( !strcmp(option_str, "dtx") ) { 
     115  codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_DTX; 
     116  codec_cfg->dtx = _P_BOOL(value_str); 
     117 } else if ( !strcmp(option_str, "cc-max") ) { 
     118  codec_cfg->para_set |= ROAR_LIBROAR_CONFIG_PSET_MAX_CC; 
     119  codec_cfg->max_cc = _P_INT(value_str); 
     120 } else { 
     121  ROAR_WARN("roar_libroar_config_parse_codec(*): Unkown codec option: %s", option_str); 
     122 } 
     123 
     124 return -1; 
     125} 
     126 
    70127int    roar_libroar_config_parse(char * txt, char * delm) { 
    71128 struct roar_libroar_config * config = roar_libroar_get_config_ptr(); 
     
    131188   } else { 
    132189    ROAR_WARN("roar_libroar_config_parse(*): Unknown warning option: %s", v); 
     190   } 
     191  } else if ( !strcmp(k, "codec") ) { 
     192   if ( roar_libroar_config_parse_codec(config, v) == -1 ) { 
     193    ROAR_WARN("roar_libroar_config_parse(*): Error parsing codec config option"); 
    133194   } 
    134195  } else { 
Note: See TracChangeset for help on using the changeset viewer.