Skip to content

Commit

Permalink
CONF_TYPE_AFMT similar to CONF_TYPE_IMGFMT
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14247 b3059339-0415-0410-9bf9-f77b7e298cf2
  • Loading branch information
alex committed Dec 27, 2004
1 parent 507121f commit cd9e475
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
89 changes: 89 additions & 0 deletions m_option.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,95 @@ m_option_type_t m_option_type_imgfmt = {
NULL
};

#include "libaf/af_format.h"

/* FIXME: snyc with af_format.h */
static struct {
char* name;
unsigned int fmt;
} mp_afmt_list[] = {
// SPECIAL
{"mulaw", AF_FORMAT_MU_LAW},
{"alaw", AF_FORMAT_A_LAW},
{"mpeg2", AF_FORMAT_MPEG2},
{"ac3", AF_FORMAT_AC3},
{"imaadpcm", AF_FORMAT_IMA_ADPCM},
// ORIDNARY
{"u8", AF_FORMAT_U8},
{"s8", AF_FORMAT_S8},
{"u16le", AF_FORMAT_U16_LE},
{"u16be", AF_FORMAT_U16_BE},
{"u16ne", AF_FORMAT_U16_NE},
{"s16le", AF_FORMAT_S16_LE},
{"s16be", AF_FORMAT_S16_BE},
{"s16ne", AF_FORMAT_S16_NE},
{"u24le", AF_FORMAT_U24_LE},
{"u24be", AF_FORMAT_U24_BE},
{"u24ne", AF_FORMAT_U24_NE},
{"s24le", AF_FORMAT_S24_LE},
{"s24be", AF_FORMAT_S24_BE},
{"s24ne", AF_FORMAT_S24_NE},
{"u32le", AF_FORMAT_U32_LE},
{"u32be", AF_FORMAT_U32_BE},
{"u32ne", AF_FORMAT_U32_NE},
{"s32le", AF_FORMAT_S32_LE},
{"s32be", AF_FORMAT_S32_BE},
{"s32ne", AF_FORMAT_S32_NE},
{"floatle", AF_FORMAT_FLOAT_LE},
{"floatbe", AF_FORMAT_FLOAT_BE},
{"floatne", AF_FORMAT_FLOAT_NE},
{ NULL, 0 }
};

static int parse_afmt(m_option_t* opt,char *name, char *param, void* dst, int src) {
uint32_t fmt = 0;
int i;

if (param == NULL || strlen(param) == 0)
return M_OPT_MISSING_PARAM;

if(!strcmp(param,"help")) {
mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Available formats:");
for(i = 0 ; mp_afmt_list[i].name ; i++)
mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s",mp_afmt_list[i].name);
mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n");
return M_OPT_EXIT;
}

if (sscanf(param, "0x%x", &fmt) != 1)
{
for(i = 0 ; mp_afmt_list[i].name ; i++) {
if(!strcasecmp(param,mp_afmt_list[i].name)) {
fmt=mp_afmt_list[i].fmt;
break;
}
}
if(!mp_afmt_list[i].name) {
mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: unknown format name: '%s'\n",name,param);
return M_OPT_INVALID;
}
}

if(dst)
*((uint32_t*)dst) = fmt;

return 1;
}

m_option_type_t m_option_type_afmt = {
"Audio format",
"Please report any missing formats.",
sizeof(uint32_t),
0,
parse_afmt,
NULL,
copy_opt,
copy_opt,
NULL,
NULL
};


//// Objects (i.e. filters, etc) settings

#include "m_struct.h"
Expand Down
2 changes: 2 additions & 0 deletions m_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern m_option_type_t m_option_type_print;
extern m_option_type_t m_option_type_print_indirect;
extern m_option_type_t m_option_type_subconfig;
extern m_option_type_t m_option_type_imgfmt;
extern m_option_type_t m_option_type_afmt;

// Func based types
extern m_option_type_t m_option_type_func_full;
Expand Down Expand Up @@ -90,6 +91,7 @@ extern m_obj_params_t m_span_params_def;
#define CONF_TYPE_STRING_LIST (&m_option_type_string_list)
#define CONF_TYPE_POSITION (&m_option_type_position)
#define CONF_TYPE_IMGFMT (&m_option_type_imgfmt)
#define CONF_TYPE_AFMT (&m_option_type_afmt)
#define CONF_TYPE_SPAN (&m_option_type_span)
#define CONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list)
#define CONF_TYPE_OBJ_PRESETS (&m_option_type_obj_presets)
Expand Down

0 comments on commit cd9e475

Please sign in to comment.