[FFmpeg-devel] [PATCH] ADTS AAC with ID3v2

Benoit Fouet benoit.fouet
Fri Jan 23 10:11:47 CET 2009


On 01/22/2009 06:42 PM, David DeHaven wrote:
>
> [...]
>
> <parrot mode> FLAC! FLAC! </parrot mode>
> This works on all the id3v2 infested flac files I have.
>

> Index: raw.c
> ===================================================================
> --- raw.c    (revision 16719)
> +++ raw.c    (working copy)
> @@ -282,6 +282,8 @@
>  static int audio_read_header(AVFormatContext *s,
>                               AVFormatParameters *ap)
>  {
> +    uint8_t buf[ID3v2_HEADER_SIZE];
> +    int ret;

these ones could be moved where they're used

>      AVStream *st = av_new_stream(s, 0);
>      if (!st)
>          return AVERROR(ENOMEM);
> @@ -289,6 +291,20 @@
>      st->codec->codec_id = s->iformat->value;
>      st->need_parsing = AVSTREAM_PARSE_FULL;
>      /* the parameters will be extracted from the compressed bitstream */
> +   
> +    if(st->codec->codec_id == CODEC_ID_FLAC) {
> +        /* skip ID3v2 header if found */
> +        ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
> +        if (ret != ID3v2_HEADER_SIZE)
> +            return -1;

isn't it possible that ret is not ID3v2_HEADER_SIZE long and the file
still is a valid flac file ?

> +        if (ff_id3v2_match(buf)) {
> +            /* FIXME: parse ID3v2 info instead of skipping */
> +            int len = ff_id3v2_tag_len(buf);
> +            url_fseek(s->pb, len-ID3v2_HEADER_SIZE, SEEK_CUR);
> +        } else {
> +            url_fseek(s->pb, 0, SEEK_SET);
> +        }
> +    }
>      return 0;
>  }
> 
> @@ -573,8 +589,13 @@
>  #if CONFIG_FLAC_DEMUXER
>  static int flac_probe(AVProbeData *p)
>  {
> -    if(memcmp(p->buf, "fLaC", 4)) return 0;
> -    else                          return AVPROBE_SCORE_MAX / 2;
> +    uint8_t *bptr = p->buf;
> +
> +    if(ff_id3v2_match(bptr))
> +        bptr += ff_id3v2_tag_len(bptr);
> +
> +    if(memcmp(bptr, "fLaC", 4)) return 0;
> +    else                        return AVPROBE_SCORE_MAX / 2;

this mixes cosmetics and functionnal changes.

>  }
>  #endif
> 

Ben





More information about the ffmpeg-devel mailing list