[FFmpeg-devel] [PATCH] Handle ID3v1 tag while decoding mp[123] frames

Michael Niedermayer michaelni
Fri Jan 7 03:41:18 CET 2011


On Fri, Jan 07, 2011 at 02:40:14AM +0100, Cl?ment B?sch wrote:
> Hi,
> 
> I have a lot of mp3 with id3v1 tag at the end of the file; here is a
> random one:
> http://ccmixter.org/content/Ghost_k/Ghost_k_-_Stop_(blue_mix).mp3
> 
> While reading this last frame, the header is not recognized as a mpeg
> one so the frame read basically fails. If I'm not wrong, it also tries
> byte per byte to find a new mpeg header (since id3v1 header is 128 bytes
> it should be around 124 times).
> 
> So I attached a patch to just ignore this frame. I'm not sure this is the
> correct place to do so (maybe there is some stream end offset mark to
> explicit the end of the file before the tag?), and I'm also not sure about
> the way I made av_read_frame ignoring this packet. Do I also need to
> update the data_size (function argument) value?
> 
> Regards,
> 
> -- 
> Cl?ment B.

>  mpegaudiodec.c |    9 +++++++++
>  1 file changed, 9 insertions(+)
> a91239b090f15a3761ab97fe3ff121d4e991cd0c  0001-Handle-ID3v1-tag-while-decoding-mp-123-frames.patch
> From 6b291325a850f098568afcac915aeed11a2cc219 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
> Date: Fri, 7 Jan 2011 02:27:25 +0100
> Subject: [PATCH] Handle ID3v1 tag while decoding mp[123] frames
> 
> ---
>  libavcodec/mpegaudiodec.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
> index 769be89..fe84214 100644
> --- a/libavcodec/mpegaudiodec.c
> +++ b/libavcodec/mpegaudiodec.c
> @@ -27,6 +27,7 @@
>  #include "avcodec.h"
>  #include "get_bits.h"
>  #include "dsputil.h"
> +#include "libavformat/id3v1.h"
>  
>  /*
>   * TODO:
> @@ -2043,6 +2044,14 @@ static int decode_frame(AVCodecContext * avctx,
>  
>      header = AV_RB32(buf);
>      if(ff_mpa_check_header(header) < 0){
> +
> +        if (buf_size == ID3v1_TAG_SIZE
> +            && buf[0] == 'T' && buf[1] == 'A' && buf[2] == 'G') {

> +            avpkt->data += ID3v1_TAG_SIZE;
> +            avpkt->size = 0;

These 2 look wrong, decoders are not supposed to change them


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

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- 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/20110107/c80fd47c/attachment.pgp>



More information about the ffmpeg-devel mailing list