[FFmpeg-devel] [PATCH] avformat/mp3dec: Adjust returned timestamp in the CBR seeking case

Michael Niedermayer michaelni at gmx.at
Tue Apr 21 01:30:42 CEST 2015


On Mon, Apr 20, 2015 at 09:47:33PM +0200, wm4 wrote:
> On Mon, 20 Apr 2015 21:25:44 +0200
> Michael Niedermayer <michaelni at gmx.at> wrote:
> 
> > With this the returned timestamp should match the packet instead of
> > the requested timestamp, which may lay between  packets
> > 
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavformat/mp3dec.c             |    6 ++++++
> >  tests/ref/fate/gapless-mp3-notoc |    2 +-
> >  2 files changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
> > index 06bc1d0..89990ec 100644
> > --- a/libavformat/mp3dec.c
> > +++ b/libavformat/mp3dec.c
> > @@ -489,6 +489,12 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
> >      ret = avio_seek(s->pb, best_pos, SEEK_SET);
> >      if (ret < 0)
> >          return ret;
> > +
> > +    if (mp3->is_cbr && ie == &ie1) {
> > +        int frame_duration = av_rescale(st->duration, 1, mp3->frames);
> 
> Why use av_rescale here? Shouldn't a normal division work fine?

i was thinking that if duration is slightly wrong then av_rescale
would be more robust as its rounding to nearest


> 
> > +        ie1.timestamp = frame_duration * (av_rescale(best_pos - s->internal->data_offset, mp3->frames, mp3->header_filesize));
> 
> Redundant (  ) ?

yes, ill remove it

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150421/1aec22dd/attachment.asc>


More information about the ffmpeg-devel mailing list