[MPlayer-dev-eng] [PATCH] improving MP3 detection

D Richard Felker III dalias at aerifal.cx
Thu Sep 9 15:52:15 CEST 2004


On Thu, Sep 09, 2004 at 08:26:11AM +0200, Dominik 'Rathann' Mierzejewski wrote:
> On Wednesday, 08 September 2004 at 21:52, Reimar Döffinger wrote:
> > Hi,
> > the following patch improves MP3 detection. It is a bit more
> > complicated, because it avoids seeking backwards as much as possible.
> > Even with linear streams only as many frames as neccessary for reliable
> > detection will be skipped.
> > Please comment.
> > 
> > Greetings,
> > Reimar Döffinger
> 
> > Index: libmpdemux/demux_audio.c
> > ===================================================================
> > RCS file: /cvsroot/mplayer/main/libmpdemux/demux_audio.c,v
> > retrieving revision 1.26
> > diff -u -r1.26 demux_audio.c
> > --- libmpdemux/demux_audio.c	12 Aug 2004 12:36:08 -0000	1.26
> > +++ libmpdemux/demux_audio.c	5 Sep 2004 12:04:44 -0000
> > @@ -27,17 +27,74 @@
> >    float last_pts;
> >  } da_priv_t;
> > 
> > +typedef struct mp3_hdr {
> > +  int frame_pos;
> > +  int next_frame_pos;
> > +  int mp3_chans;
> > +  int mp3_freq;
> > +  int cons_hdrs;
> > +  struct mp3_hdr *next;
> > +} mp3_hdr_t;
> 
> When it comes to defining file formats, I believe we should use
> platform-independent inttypes, like int32_t. I know int is 32bit
> on both ia32 and amd64, but I think we still should, as a good
> practice. Besides, isn't mp3 header structure defined elsewhere?
> 
> R.

umm, do you think this struct is read raw from mp3 files?!??! no, it
contains data that's decoded from the mp3 header. there's absolutely
no sense in using fixed-size types for any data unless one of the
following conditions is met:

1) you're reading the struct directly from a file.
2) the type is for a sample buffer of some sort where you need a
particular size.
3) the volume of data is so huge that using a larger type than
necessary would seriously impact memory usage or cache coherency.

anyway, int is basically stuck at 32 bits forever. why? if int is
bigger than 32 bits, there's at least one size that you _cannot_ get.
think about it a sec...

rich




More information about the MPlayer-dev-eng mailing list