From patchwork Tue Apr 6 23:22:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lode Willems X-Patchwork-Id: 26790 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C0F8F44A958 for ; Wed, 7 Apr 2021 02:22:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9E0A2680777; Wed, 7 Apr 2021 02:22:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9366F6802C2 for ; Wed, 7 Apr 2021 02:22:35 +0300 (EEST) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4FFNpy6VPDzQjyC; Wed, 7 Apr 2021 01:22:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id E-c9aGbpMLM7; Wed, 7 Apr 2021 01:22:31 +0200 (CEST) Date: Wed, 7 Apr 2021 01:22:30 +0200 (CEST) From: Lode Willems To: "ffmpeg-devel@ffmpeg.org" Message-ID: <1118083116.39618.1617751350909@office.mailbox.org> MIME-Version: 1.0 X-Priority: 3 Importance: Normal X-MBO-SPAM-Probability: X-Rspamd-Score: -4.87 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9F4CD17E8 X-Rspamd-UID: e9a65e Subject: [FFmpeg-devel] [PATCH] libavformat/id3v2: Read full null seperated list for text info frames X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" All id3v2.4 text information frames are null separated lists: https://id3.org/id3v2.4.0-frames This change reads all values into the metadata dictionary without changing the outputs of ffmpeg or ffprobe Relevant ticket: https://trac.ffmpeg.org/ticket/6949 Signed-off-by: Lode Willems --- libavformat/id3v2.c | 5 ++++- libavformat/metadata.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 863709abbf..9ef56a52c2 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -320,7 +320,7 @@ 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; + int encoding, dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_VAL | AV_DICT_MULTIKEY; unsigned genre; if (taglen < 1) @@ -329,6 +329,8 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, encoding = avio_r8(pb); taglen--; /* account for encoding type byte */ + /* Read all null-terminated values */ + while (taglen > 0) { if (decode_str(s, pb, encoding, &dst, &taglen) < 0) { av_log(s, AV_LOG_ERROR, "Error reading frame %s, skipped\n", key); return; @@ -353,6 +355,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, if (dst) av_dict_set(metadata, key, dst, dict_flags); + } } static void read_uslt(AVFormatContext *s, AVIOContext *pb, int taglen, diff --git a/libavformat/metadata.c b/libavformat/metadata.c index b9b6de7972..68382e7937 100644 --- a/libavformat/metadata.c +++ b/libavformat/metadata.c @@ -50,7 +50,7 @@ void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv, key = dc->native; break; } - av_dict_set(&dst, key, mtag->value, 0); + av_dict_set(&dst, key, mtag->value, AV_DICT_DONT_OVERWRITE); } av_dict_free(pm); *pm = dst;