[MPlayer-cvslog] r25061 - trunk/libmpdemux/demux_mf.c

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Nov 18 11:11:46 CET 2007


Hello,
On Sun, Nov 18, 2007 at 03:10:43AM -0500, Rich Felker wrote:
> On Sat, Nov 17, 2007 at 06:27:31PM +0100, reimar wrote:
> > Author: reimar
> > Date: Sat Nov 17 18:27:30 2007
> > New Revision: 25061
> > 
> > Log:
> > Replace if-else constructs for type -> fourcc mapping by a table in demux_mf
> > 
> > 
> > Modified:
> >    trunk/libmpdemux/demux_mf.c
> > 
> > Modified: trunk/libmpdemux/demux_mf.c
> > ==============================================================================
> > --- trunk/libmpdemux/demux_mf.c	(original)
> > +++ trunk/libmpdemux/demux_mf.c	Sat Nov 17 18:27:30 2007
> > @@ -62,9 +62,24 @@ static int demux_mf_fill_buffer(demuxer_
> >    return 1;
> >  }
> >  
> > +static const struct {
> > +  const char *type;
> > +  uint32_t *format;
> > +} type2format[] = {
> > +  { "bmp",  mmioFOURCC('b', 'm', 'p', ' ') },
> 
> Why is this uint32_t * and not uint32_t ? Am I missing something??

Arg! A really stupid typo. Should have looked closer at the warnings.

> Also, const char type[5]; would probably be saner than const char
> *type.. If nothing else it will be smaller on 64bit and no worse on
> 32bit.

It saves 19 bytes on 64 bit at the expense of not working right with
long extensions or type names (no idea if we'll actually ever need it
though).
Feel free to apply e.g. attached patch if you think it is really better.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_mf.c
===================================================================
--- libmpdemux/demux_mf.c	(revision 25090)
+++ libmpdemux/demux_mf.c	(working copy)
@@ -59,7 +59,7 @@
 }
 
 static const struct {
-  const char *type;
+  const char type[5];
   uint32_t format;
 } type2format[] = {
   { "bmp",  mmioFOURCC('b', 'm', 'p', ' ') },
@@ -69,7 +69,7 @@
   { "tga",  mmioFOURCC('M', 'T', 'G', 'A') },
   { "tif",  mmioFOURCC('t', 'i', 'f', 'f') },
   { "sgi",  mmioFOURCC('S', 'G', 'I', '1') },
-  { NULL,   0 }
+  { "",   0 }
 };
 
 static demuxer_t* demux_open_mf(demuxer_t* demuxer){
@@ -110,10 +110,10 @@
   // video_read_properties() will choke
   sh_video->ds = demuxer->video;
   
-  for (i = 0; type2format[i].type; i++)
+  for (i = 0; type2format[i].type[0]; i++)
     if (strcasecmp(mf_type, type2format[i].type) == 0)
       break;
-  if (!type2format[i].type) {
+  if (!type2format[i].type[0]) {
     mp_msg(MSGT_DEMUX, MSGL_INFO, "[demux_mf] unknown input file type.\n" );
     free(mf);
     return NULL;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-cvslog/attachments/20071118/ccb15b9b/attachment.pgp>


More information about the MPlayer-cvslog mailing list