[FFmpeg-devel] [PATCH] id3v2: read TXXX frames
Daniel Verkamp
daniel
Mon Sep 28 11:38:44 CEST 2009
On Mon, Sep 28, 2009 at 4:01 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Sat, Sep 26, 2009 at 02:48:16PM +0200, Anton Khirnov wrote:
>> i've replaced this patch with a better one, which now reads all text
>> information frames and exports them with correct tag names.
> [...]
>> @@ -134,19 +135,26 @@ static void read_ttag(AVFormatContext *s, int taglen, const char *key)
>> ? ? ? ? ?av_log(s, AV_LOG_WARNING, "Unknown encoding in tag %s\n.", key);
>> ? ? ?}
>>
>> - ? ?if (!strcmp(key, "genre")
>> + ? ?if (!(strcmp(key, "TCON") && strcmp(key, "TCO"))
>> ? ? ? ? ?&& (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d", &genre) == 1)
>> ? ? ? ? ?&& genre <= ID3v1_GENRE_MAX)
>> - ? ? ? ?av_strlcpy(dst, ff_id3v1_genre_str[genre], sizeof(dst));
>> + ? ? ? ?val = ff_id3v1_genre_str[genre];
>> + ? ?else if (!strcmp(key, "TXXX")) { /*dst now contains two 0-terminated strings*/
>> + ? ? ? ?dst[dstlen] = 0;
>> + ? ? ? ?key = dst;
>> + ? ? ? ?val = dst + FFMIN(dstlen - 1, strlen(dst)) + 1;
>
> FFMIN(dstlen, strlen(dst) + 1);
>
Surely the FFMIN is not necessary at all here due to dst[dstlen] = 0
just previously... if the string is shorter than dstlen - 1, then the
strlen() result will be used, and the only other possible case is
strlen(dst) == dstlen - 1, so just
val = dst + strlen(dst) + 1
should be enough.
-- Daniel Verkamp
More information about the ffmpeg-devel
mailing list