diff mbox series

[FFmpeg-devel,02/14] avformat/mp3dec: Avoid calling avio_tell() multiple times

Message ID PR3PR03MB666542871696A05DAA3253758FD59@PR3PR03MB6665.eurprd03.prod.outlook.com
State Accepted
Commit 6d1e792980cd3d1bfed7840e80764fa403df17ab
Headers show
Series [FFmpeg-devel,01/14] Revert "avfilter/af_silenceremove: fix processing of periods > 1" | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/configureppc warning Failed to apply patch

Commit Message

Andreas Rheinhardt Sept. 9, 2021, 3:57 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/mp3dec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Andreas Rheinhardt Sept. 14, 2021, 1:17 p.m. UTC | #1
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavformat/mp3dec.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
> index 195d89814e..9205abebc4 100644
> --- a/libavformat/mp3dec.c
> +++ b/libavformat/mp3dec.c
> @@ -171,7 +171,8 @@ static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st,
>      MP3DecContext *mp3 = s->priv_data;
>      static const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
>      uint64_t fsize = avio_size(s->pb);
> -    fsize = fsize >= avio_tell(s->pb) ? fsize - avio_tell(s->pb) : 0;
> +    int64_t pos = avio_tell(s->pb);
> +    fsize = fsize >= pos ? fsize - pos : 0;
>  
>      /* Check for Xing / Info tag */
>      avio_skip(s->pb, xing_offtbl[c->lsf == 1][c->nb_channels == 1]);
> @@ -430,9 +431,10 @@ static int mp3_read_header(AVFormatContext *s)
>              return ret;
>      }
>  
> +    off = avio_tell(s->pb);
>      // the seek index is relative to the end of the xing vbr headers
>      for (i = 0; i < st->internal->nb_index_entries; i++)
> -        st->internal->index_entries[i].pos += avio_tell(s->pb);
> +        st->internal->index_entries[i].pos += off;
>  
>      /* the parameters will be extracted from the compressed bitstream */
>      return 0;
> 
Will apply the libavformat patches of this patchset tomorrow unless
there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 195d89814e..9205abebc4 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -171,7 +171,8 @@  static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st,
     MP3DecContext *mp3 = s->priv_data;
     static const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
     uint64_t fsize = avio_size(s->pb);
-    fsize = fsize >= avio_tell(s->pb) ? fsize - avio_tell(s->pb) : 0;
+    int64_t pos = avio_tell(s->pb);
+    fsize = fsize >= pos ? fsize - pos : 0;
 
     /* Check for Xing / Info tag */
     avio_skip(s->pb, xing_offtbl[c->lsf == 1][c->nb_channels == 1]);
@@ -430,9 +431,10 @@  static int mp3_read_header(AVFormatContext *s)
             return ret;
     }
 
+    off = avio_tell(s->pb);
     // the seek index is relative to the end of the xing vbr headers
     for (i = 0; i < st->internal->nb_index_entries; i++)
-        st->internal->index_entries[i].pos += avio_tell(s->pb);
+        st->internal->index_entries[i].pos += off;
 
     /* the parameters will be extracted from the compressed bitstream */
     return 0;