[FFmpeg-devel] [PATCH 2/4] id3v2: merge TYER/TDAT/TIME to date tag
Michael Niedermayer
michaelni
Sun Oct 17 10:37:20 CEST 2010
On Fri, Oct 15, 2010 at 09:20:59PM +0200, Anton Khirnov wrote:
> ---
> libavformat/id3v2.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 files changed, 37 insertions(+), 0 deletions(-)
>
> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index fbcb8f8..d66509f 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -162,6 +162,42 @@ static void read_ttag(AVFormatContext *s, ByteIOContext *pb, int taglen, const c
> av_metadata_set2(&s->metadata, key, val, 0);
> }
>
> +static int is_number(const char *p)
> +{
> + while (*p)
> + if (!isdigit(*p++))
> + return 0;
> + return 1;
> +}
> +
> +static void merge_date(AVMetadata **m)
> +{
> + AVMetadataTag *t;
> + char date[17] = {0}; // YYYY-MM-DD hh:mm
> +
> + if (!(t = av_metadata_get(*m, "TYER", NULL, AV_METADATA_MATCH_CASE)) ||
> + strlen(t->value) != 4 || !is_number(t->value))
> + return;
> + snprintf(date, sizeof(date), "%04d", atoi(t->value));
> + av_metadata_set2(m, "TYER", NULL, 0);
> +
> + if (!(t = av_metadata_get(*m, "TDAT", NULL, AV_METADATA_MATCH_CASE)) ||
> + strlen(t->value) != 4 || !is_number(t->value))
> + goto finish;
> + snprintf(date + 4, sizeof(date) - 4, "-%.2s-%.2s", t->value + 2, t->value);
> + av_metadata_set2(m, "TDAT", NULL, 0);
> +
> + if (!(t = av_metadata_get(*m, "TIME", NULL, AV_METADATA_MATCH_CASE)) ||
> + strlen(t->value) != 4 || !is_number(t->value))
> + goto finish;
> + snprintf(date + 10, sizeof(date) - 10, " %.2s:%.2s", t->value, t->value + 2);
> + av_metadata_set2(m, "TIME", NULL, 0);
why 3 snprintf instead of 1?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101017/67e443f1/attachment.pgp>
More information about the ffmpeg-devel
mailing list