[FFmpeg-devel] [PATCH 1/2] aea: make demuxer probing actually work and set title info

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Fri Feb 26 07:57:04 EET 2021


Lynne:
> Someone forgot to add `i` to the loop. 
> Also, the format has a 16-char title that we don't currently
> check.
> 
> Bytestream info from:
> https://github.com/dcherednik/atracdenc/blob/master/src/aea.cpp
> 
> Patch attached
> 
> @@ -61,12 +61,19 @@ static int aea_read_probe(const AVProbeData *p)
>  
>  static int aea_read_header(AVFormatContext *s)
>  {
> +    char title[17] = { 0 };
>      AVStream *st = avformat_new_stream(s, NULL);
>      if (!st)
>          return AVERROR(ENOMEM);
>  
> +    avio_skip(s->pb, 4);
> +
> +    avio_read(s->pb, title, 16);
> +    if (strlen(title) && strlen(title) < 16)
> +        av_dict_set(&s->metadata, "title", title, 0);
> +

You are not checking that you actually read 16 bytes. Maybe use
ffio_read_len for that. If you do, you can modify the check to
if (title[0] && !title[15])
and you also don't need the extra byte in title and can also avoid
initializing it.

>  
> @@ -90,11 +97,8 @@ static int aea_read_header(AVFormatContext *s)
>  static int aea_read_packet(AVFormatContext *s, AVPacket *pkt)
>  {
>      int ret = av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
> -
> -    pkt->stream_index = 0;
> -    if (ret <= 0)
> -        return AVERROR(EIO);
> -
> +    if (ret >= 0)
> +        pkt->stream_index = 0;

The check is unnecessary.

>      return ret;
>  }
>  
> -- 




More information about the ffmpeg-devel mailing list