[FFmpeg-devel] [PATCH 3/5] mp3dec: parse initial silence padding information from lame tag

Michael Niedermayer michaelni at gmx.at
Thu Jul 12 20:40:08 CEST 2012


On Thu, Jul 05, 2012 at 05:58:58PM +0200, Nicolas George wrote:
> Le septidi 17 messidor, an CCXX, Michael Niedermayer a écrit :
> > And pass the information on to the lavf core.
> > 
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavformat/mp3dec.c |   28 ++++++++++++++++++++++++++++
> >  1 file changed, 28 insertions(+)
> > 
> > diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
> > index 61405f7..bc62694 100644
> > --- a/libavformat/mp3dec.c
> > +++ b/libavformat/mp3dec.c
> > @@ -31,6 +31,8 @@
> >  
> >  typedef struct {
> >      int64_t filesize;
> > +    int start_pad;
> > +    int end_pad;
> 
> They look to be used only locally (and, for end_pad, only in debug output).
> Do you have a reason to put them in the context?

start_pad is used in the seeking code. end_pad is unused but will be
used once end padding/truncation is implemented
we could remove the variable now and just add it later, if you prefer
this feel free to remove it, but to me it seemed easier to add it
with the other


> 
> >  } MP3Context;
> >  
> >  /* mp3 read */
> > @@ -82,6 +84,7 @@ static int mp3_read_probe(AVProbeData *p)
> >   */
> >  static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
> >  {
> > +    MP3Context *mp3 = s->priv_data;
> >      uint32_t v, spf;
> >      unsigned frames = 0; /* Total number of frames in file */
> >      unsigned size = 0; /* Total number of bytes in the stream */
> > @@ -107,6 +110,20 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
> >              frames = avio_rb32(s->pb);
> >          if(v & 0x2)
> >              size = avio_rb32(s->pb);
> > +        if(v & 4)
> > +            avio_skip(s->pb, 100);
> > +        if(v & 8)
> > +            avio_skip(s->pb, 4);
> > +
> > +        v = avio_rb32(s->pb);
> > +        if(v == MKBETAG('L', 'A', 'M', 'E')) {
> > +            avio_skip(s->pb, 21-4);
> > +            v= avio_rb24(s->pb);
> > +            mp3->start_pad = v>>12;
> > +            mp3->  end_pad = v&4095;
> > +            st->skip_samples = mp3->start_pad + 528 + 1;
> > +            av_log(s, AV_LOG_DEBUG, "pad %d %d\n", mp3->start_pad, mp3->  end_pad);
> > +        }
> >      }
> >  
> >      /* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */
> > @@ -206,6 +223,16 @@ static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
> >      return ret;
> >  }
> >  
> > +static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
> > +{
> > +    MP3Context *mp3 = s->priv_data;
> > +    AVStream *st = s->streams[stream_index];
> > +
> > +    st->skip_samples = (mp3->start_pad + 528 + 1) * (timestamp <= 0);
> 
> st->skip_samples = timestamp <= 0 ? mp3->start_pad + 528 + 1 : 0
> 
> would look more readable to my eyes.

agree and changed

patch applied

thanks

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120712/cbe0cf0d/attachment.asc>


More information about the ffmpeg-devel mailing list