[FFmpeg-devel] [PATCH 2/4] id3v2: merge TYER/TDAT/TIME to date tag
Anton Khirnov
anton
Tue Nov 2 22:16:31 CET 2010
On Mon, Nov 01, 2010 at 07:54:00AM +0100, Reimar D?ffinger wrote:
> On Sun, Oct 31, 2010 at 10:38:11PM +0100, Anton Khirnov wrote:
> > On Sun, Oct 31, 2010 at 06:39:58PM +0100, Reimar D?ffinger wrote:
> > > > + for (i = 0; i < sizeof(keys); i++) {
> > > > + AVMetadataTag *t = av_metadata_get(*m, keys[i], NULL, AV_METADATA_MATCH_CASE);
> > > > + if (!t || strlen(t->value) != 4 || !is_number(t->value))
> > > > + break;
> > > > + tags[i] = t;
> > > > + }
> > > > +
> > > > + if (tags[2]) len = sizeof("YYYY-MM-DD HH:MM");
> > > > + else if (tags[1]) len = sizeof("YYYY-MM-DD");
> > > > + else if (tags[0]) len = sizeof("YYYY");
> > > > + else return;
> > > > +
> > > > + if (!(date = av_malloc(len)))
> > > > + return;
> > > > + snprintf(date, len, "%.4s-%.2s-%.2s %.2s:%.2s",
> > > > + tags[0] ? tags[0]->value : "", // year
> > > > + tags[1] ? tags[1]->value + 2 : "", // month
> > > > + tags[1] ? tags[1]->value : "", // day
> > > > + tags[2] ? tags[2]->value : "", // hour
> > > > + tags[2] ? tags[2]->value + 2 : ""); // minute
> > >
> > > I suspect this could profit hugely from some restructuring, but at the very
> > > least I'd suggest adding some variables and doing
> > > year = tags[0] ? tags[0]->value : "";
> > > ....
> > >
> > i fail to see what that would accomplish other than making it longer
>
> Making it a lot easier to understand what it does?
> In particular, get rid of the comments that are likely to be wrong
> after the next code change anyway?
> It might also be possible to combine them with the if (tags[...])
> checks that are already there anyway.
ok, done
--
Anton Khirnov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-id3v2-merge-TYER-TDAT-TIME-to-date-tag.patch
Type: text/x-diff
Size: 2497 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101102/b0ea3a36/attachment.patch>
-------------- 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/20101102/b0ea3a36/attachment.pgp>
More information about the ffmpeg-devel
mailing list