[FFmpeg-devel] skip multiple id3v2 headers

Michael Niedermayer michaelni
Sat Sep 11 02:34:10 CEST 2010


On Thu, Sep 09, 2010 at 08:02:40AM -0700, David Byron wrote:
> > if you want to see a patch applied that skips half of the
> > metadata such thing must be justified and shown to be
> > neccessary compared to parsing all metadata which is also
> > simpler in code.  and no i dont care what is closer to
> > current buggy behavior.
> 
> Fair enough.  Here are patches to read all the metadata.
> 
> The third patch changes the behavior of ff_id3v2_parse so it gets all the
> way to the end of the second id3v2 tag in the
> two_id3v2_with_fake_mpeg_small.mp3 file I sent earlier.  Without this patch
> it doesn't read enough and av_read_frame delivers part of the second id3v2
> tag as audio.
> 
> -DB

>  Changelog           |    1 +
>  libavformat/id3v2.c |   11 +++++++++--
>  2 files changed, 10 insertions(+), 2 deletions(-)
> d78547b4fbe8c3d92d6af3e46f28f23fdff68c10  0001-read-all-id3v2-tags-at-the-beginning-of-mp3-files.patch
> From 7665effa4b03fe97742563ac6b2b6a7d3b4d466d Mon Sep 17 00:00:00 2001
> From: David Byron <dbyron at UbuntuVM.(none)>
> Date: Thu, 9 Sep 2010 06:43:56 -0700
> Subject: [PATCH] read all id3v2 tags at the beginning of mp3 files

ok


[...]
[...]

>  id3v2.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 8eee73e2f8cbac93c36f2e55a104432a1a42073d  0003-make-sure-to-get-to-the-end-of-an-id3v2-tag-even-if.patch
> From f957ce24a04198c0e01b348bb84070a2bf0ee5bd Mon Sep 17 00:00:00 2001
> From: David Byron <dbyron at UbuntuVM.(none)>
> Date: Thu, 9 Sep 2010 07:53:42 -0700
> Subject: [PATCH] make sure to get to the end of an id3v2 tag, even if something in the tag is bogus
> 
> ---
>  libavformat/id3v2.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index 877e37d..d259159 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -171,6 +171,11 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
>      ByteIOContext pb;
>      unsigned char *buffer = NULL;
>      int buffer_size = 0;
> +    int64_t end_of_tag;
> +
> +    /* Figure out where the end of the tag is and make sure
> +       we get there even if we find something bogus */
> +    end_of_tag = len + url_ftell(s->pb);
>  
>      switch (version) {
>      case 2:
> @@ -219,7 +224,11 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
>          len -= taghdrlen + tlen;
>  
>          if (len < 0)
> +        {
> +            av_log(s, AV_LOG_INFO, "\"%s\": bogus tag length: %d\n",
> +                   s->filename, tlen);
>              break;
> +        }
>  
>          next = url_ftell(s->pb) + tlen;
>  

not K&R


> @@ -257,6 +266,9 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
>      if (version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */
>          url_fskip(s->pb, 10);
>  
> +    if (url_ftell(s->pb) != end_of_tag)
> +        url_fseek(s->pb, end_of_tag, SEEK_SET);

useless if

but above all, why this patch?
what does this fix?

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

No great genius has ever existed without some touch of madness. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100911/933c156d/attachment.pgp>



More information about the ffmpeg-devel mailing list