[FFmpeg-devel] [PATCHv5 2/3] vorbis: append data from tags together
Michael Niedermayer
michaelni at gmx.at
Fri Jan 17 22:46:09 CET 2014
On Sun, Jan 12, 2014 at 10:19:27PM -0500, Ben Boeckel wrote:
> Currently, if there are multiple 'performer' tags, the last one is the
> only one which appears. Instead, join them with a semicolon.
>
> Signed-off-by: Ben Boeckel <mathstuf at gmail.com>
> ---
> libavformat/oggparsevorbis.c | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
> index 36ad738..79d7ec0 100644
> --- a/libavformat/oggparsevorbis.c
> +++ b/libavformat/oggparsevorbis.c
> @@ -52,7 +52,6 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
> avpriv_new_chapter(as, cnum, (AVRational) { 1, 1000 },
> ms + 1000 * (s + 60 * (m + 60 * h)),
> AV_NOPTS_VALUE, NULL);
> - av_free(val);
> } else if (!strcmp(key + keylen - 4, "NAME")) {
> for (i = 0; i < as->nb_chapters; i++)
> if (as->chapters[i]->id == cnum) {
> @@ -62,7 +61,7 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
> if (!chapter)
> return 0;
>
> - av_dict_set(&chapter->metadata, "title", val, AV_DICT_DONT_STRDUP_VAL);
> + av_dict_set(&chapter->metadata, "title", val, 0);
> } else
> return 0;
>
> @@ -113,22 +112,24 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
> v++;
>
> if (tl && vl) {
> - char *tt, *ct;
> + char *tt, *ct, *vt;
>
> tt = av_malloc(tl + 1);
> - ct = av_malloc(vl + 1);
> + ct = av_malloc(vl + 2);
> if (!tt || !ct) {
> av_freep(&tt);
> av_freep(&ct);
> return AVERROR(ENOMEM);
> }
> + ct[0] = ';';
> + vt = ct + 1;
>
> for (j = 0; j < tl; j++)
> tt[j] = av_toupper(t[j]);
> tt[tl] = 0;
>
> - memcpy(ct, v, vl);
> - ct[vl] = 0;
> + memcpy(vt, v, vl);
> + vt[vl] = 0;
>
> /* The format in which the pictures are stored is the FLAC format.
> * Xiph says: "The binary FLAC picture structure is base64 encoded
> @@ -146,7 +147,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
> av_freep(&ct);
> continue;
> }
> - if ((ret = av_base64_decode(pict, ct, vl)) > 0)
> + if ((ret = av_base64_decode(pict, vt, vl)) > 0)
> ret = ff_flac_parse_picture(as, pict, ret);
> av_freep(&tt);
> av_freep(&ct);
> @@ -155,10 +156,17 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
> av_log(as, AV_LOG_WARNING, "Failed to parse cover art block.\n");
> continue;
> }
> - } else if (!ogm_chapter(as, tt, ct))
> - av_dict_set(m, tt, ct,
> + } else if (!ogm_chapter(as, tt, vt)) {
> + int extra_flags = 0;
> + if (m && av_dict_get(*m, tt, NULL, 0)) {
> + extra_flags = AV_DICT_APPEND;
> + --vt;
> + }
the check for m != null shouldnt be needed, also extra_flags shouldnt
be needed, AV_DICT_APPEND should have no effect if theres no previous
matching entry
also av_dict_set(m, tt, ";", AV_DICT_APPEND);
should be simpler than all the changes to ct/vt
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140117/b0774e16/attachment.asc>
More information about the ffmpeg-devel
mailing list