From: Soft Works <softworkz@hotmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 3/3] lavf/id3v2dec: support multiple values and TIPL frames
Date: Thu, 25 Aug 2022 00:16:16 +0000
Message-ID: <DM8P223MB0365C5BC1C28AEE0E4984A03BA729@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20220824235200.22312-3-rcombs@rcombs.me>
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> rcombs
> Sent: Thursday, August 25, 2022 1:52 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 3/3] lavf/id3v2dec: support multiple
> values and TIPL frames
>
> Fixes https://trac.ffmpeg.org/ticket/6949
>
> Ordinary text frames in ID3v2 are allowed to have multiple
> (null-separated) values. This technically isn't allowed in TXXX,
> but it's used in practice by Picard, and supporting it is harmless.
>
> TIPL/IPL (Involved People List) and TMCL (Musician Credits List) work
> similarly to TXXX, but alternate key-value-key-value.
> ---
> libavformat/id3v2.c | 49 ++++++++++++++++++++++++++-----------------
> --
> 1 file changed, 28 insertions(+), 21 deletions(-)
>
> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index 191a305ffb..335a1436b2 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -321,8 +321,12 @@ static void read_ttag(AVFormatContext *s,
> AVIOContext *pb, int taglen,
> AVDictionary **metadata, const char *key)
> {
> uint8_t *dst;
> - int encoding, dict_flags = AV_DICT_DONT_OVERWRITE |
> AV_DICT_DONT_STRDUP_VAL;
> + uint8_t *dst_key = NULL;
> + int encoding, dict_flags = AV_DICT_MULTIKEY |
> AV_DICT_DONT_STRDUP_VAL | AV_DICT_DEDUP;
> unsigned genre;
> + int count = 0;
> + int is_tipl = !(strcmp(key, "TIPL") && strcmp(key, "TMCL") &&
> + strcmp(key, "IPL"));
>
> if (taglen < 1)
> return;
> @@ -330,30 +334,33 @@ static void read_ttag(AVFormatContext *s,
> AVIOContext *pb, int taglen,
> encoding = avio_r8(pb);
> taglen--; /* account for encoding type byte */
>
> - if (decode_str(s, pb, encoding, &dst, &taglen) < 0) {
> - av_log(s, AV_LOG_ERROR, "Error reading frame %s, skipped\n",
> key);
> - return;
> - }
> -
> - if (!(strcmp(key, "TCON") && strcmp(key, "TCO"))
> &&
> - (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d",
> &genre) == 1) &&
> - genre <= ID3v1_GENRE_MAX) {
> - av_freep(&dst);
> - dst = av_strdup(ff_id3v1_genre_str[genre]);
> - } else if (!(strcmp(key, "TXXX") && strcmp(key, "TXX"))) {
> - /* dst now contains the key, need to get value */
> - key = dst;
> + while (taglen > 1) {
int n = 0;
> if (decode_str(s, pb, encoding, &dst, &taglen) < 0) {
> av_log(s, AV_LOG_ERROR, "Error reading frame %s,
> skipped\n", key);
> - av_freep(&key);
> return;
> }
> - dict_flags |= AV_DICT_DONT_STRDUP_KEY;
> - } else if (!*dst)
> - av_freep(&dst);
>
> - if (dst)
> - av_dict_set(metadata, key, dst, dict_flags);
> + count++;
> +
> + if (!(strcmp(key, "TCON") && strcmp(key, "TCO"))
> &&
> + (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d",
> &genre) == 1) &&
(sscanf(dst, "(%d)", &genre) == 1 || (sscanf(dst, "%d%n", &genre, &n) == 1 && n == strlen(dst))) &&
avoids parsing genre strings starting with numbers (like '2step')
as genre id.
Thanks for resubmitting,
softworkz
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-08-25 0:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 23:51 [FFmpeg-devel] [PATCH 1/3] lavu/dict: add AV_DICT_DEDUP rcombs
2022-08-24 23:51 ` [FFmpeg-devel] [PATCH 2/3] lavf/metadata: support duplicate keys in ff_metadata_conv rcombs
2022-08-24 23:52 ` [FFmpeg-devel] [PATCH 3/3] lavf/id3v2dec: support multiple values and TIPL frames rcombs
2022-08-25 0:16 ` Soft Works [this message]
2022-08-25 0:23 ` Ridley Combs
2022-08-25 0:27 [FFmpeg-devel] [PATCH 1/3] lavu/dict: add AV_DICT_DEDUP rcombs
2022-08-25 0:27 ` [FFmpeg-devel] [PATCH 3/3] lavf/id3v2dec: support multiple values and TIPL frames rcombs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM8P223MB0365C5BC1C28AEE0E4984A03BA729@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM \
--to=softworkz@hotmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git