[FFmpeg-devel] [PATCH 1/2] avformat: read id3v2 comment tags
Michael Niedermayer
michael at niedermayer.cc
Sat Jul 23 14:03:34 EEST 2016
On Fri, Jul 22, 2016 at 05:59:09PM -0700, kode54 at gmail.com wrote:
> From: Chris Moeller <kode54 at gmail.com>
>
> ---
> libavformat/id3v2.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index 46b9394..c38c610 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -400,6 +400,47 @@ error:
> }
>
> /**
> + * Parse a comment tag.
> + */
> +static void read_comm(AVFormatContext *s, AVIOContext *pb, int taglen,
> + AVDictionary **metadata)
> +{
> + const char *key = "comment";
> + uint8_t *dst;
> + int encoding, dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_VAL;
> + int language;
> +
> + if (taglen < 4)
> + return;
> +
> + encoding = avio_r8(pb);
> + taglen--;
> +
> + language = avio_rl24(pb);
> + taglen -= 3;
> +
> + if (decode_str(s, pb, encoding, &dst, &taglen) < 0) {
> + av_log(s, AV_LOG_ERROR, "Error reading comment frame, skipped\n");
> + return;
> + }
> +
> + if (dst && dst[0]) {
> + key = (const char *) dst;
> + dict_flags |= AV_DICT_DONT_STRDUP_KEY;
> + }
> +
> + if (decode_str(s, pb, encoding, &dst, &taglen) < 0) {
> + av_log(s, AV_LOG_ERROR, "Error reading comment frame, skipped\n");
> + if (dict_flags & AV_DICT_DONT_STRDUP_KEY)
> + av_freep((void*)&key);
> + return;
> + }
> +
> + if (dst)
> + av_dict_set(metadata, key, (const char *) dst, dict_flags);
> +}
> +
> +/**
> * Parse GEOB tag into a ID3v2ExtraMetaGEOB struct.
> */
> static void read_geobtag(AVFormatContext *s, AVIOContext *pb, int taglen,
> @@ -905,6 +946,9 @@ static void id3v2_parse(AVIOContext *pb, AVDictionary **metadata,
>
> av_log(s, AV_LOG_WARNING, "Skipping %s ID3v2 frame %s.\n", type, tag);
> avio_skip(pb, tlen);
> + /* check for comment frame */
> + } else if (!memcmp(tag, "COMM", 4)) {
> + read_comm(s, pbx, tlen, metadata);
pbx can be uninitialized here
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Democracy is the form of government in which you can choose your dictator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160723/524c4b7d/attachment.sig>
More information about the ffmpeg-devel
mailing list