Replace if-else constructs for type -> fourcc mapping by a table in demux_mf

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25061 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2007-11-17 17:27:30 +00:00
parent 647585034a
commit d0326807a7
1 changed files with 24 additions and 13 deletions

View File

@ -62,9 +62,24 @@ static int demux_mf_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds){
return 1; return 1;
} }
static const struct {
const char *type;
uint32_t *format;
} type2format[] = {
{ "bmp", mmioFOURCC('b', 'm', 'p', ' ') },
{ "jpeg", mmioFOURCC('I', 'J', 'P', 'G') },
{ "jpg", mmioFOURCC('I', 'J', 'P', 'G') },
{ "png", mmioFOURCC('M', 'P', 'N', 'G') },
{ "tga", mmioFOURCC('M', 'T', 'G', 'A') },
{ "tif", mmioFOURCC('t', 'i', 'f', 'f') },
{ "sgi", mmioFOURCC('S', 'G', 'I', '1') },
{ NULL, 0 }
};
static demuxer_t* demux_open_mf(demuxer_t* demuxer){ static demuxer_t* demux_open_mf(demuxer_t* demuxer){
sh_video_t *sh_video = NULL; sh_video_t *sh_video = NULL;
mf_t *mf = NULL; mf_t *mf = NULL;
int i;
if(!demuxer->stream->url) return NULL; if(!demuxer->stream->url) return NULL;
if(strncmp(demuxer->stream->url, "mf://", 5)) return NULL; if(strncmp(demuxer->stream->url, "mf://", 5)) return NULL;
@ -99,19 +114,15 @@ static demuxer_t* demux_open_mf(demuxer_t* demuxer){
// video_read_properties() will choke // video_read_properties() will choke
sh_video->ds = demuxer->video; sh_video->ds = demuxer->video;
if ( !strcasecmp( mf_type,"jpg" ) || for (i = 0; type2format[i].type; i++)
!(strcasecmp(mf_type, "jpeg"))) sh_video->format = mmioFOURCC('I', 'J', 'P', 'G'); if (strcasecmp(mf_type, type2format[i].type) == 0)
else break;
if ( !strcasecmp( mf_type,"png" )) sh_video->format = mmioFOURCC('M', 'P', 'N', 'G' ); if (!type2format[i].type) {
else mp_msg(MSGT_DEMUX, MSGL_INFO, "[demux_mf] unknown input file type.\n" );
if ( !strcasecmp( mf_type,"tif" )) sh_video->format = mmioFOURCC('t', 'i', 'f', 'f' ); free(mf);
else return NULL;
if ( !strcasecmp( mf_type,"tga" )) sh_video->format = mmioFOURCC('M', 'T', 'G', 'A' ); }
else sh_video->format = type2format[i].format;
if ( !strcasecmp( mf_type,"bmp" )) sh_video->format = mmioFOURCC('b', 'm', 'p', ' ' );
else
if (!strcasecmp( mf_type,"sgi" )) sh_video->format = mmioFOURCC('S', 'G', 'I', '1');
else { mp_msg(MSGT_DEMUX, MSGL_INFO, "[demux_mf] unknown input file type.\n" ); free( mf ); return NULL; }
sh_video->disp_w = mf_w; sh_video->disp_w = mf_w;
sh_video->disp_h = mf_h; sh_video->disp_h = mf_h;