[FFmpeg-devel] [PATCH] Decoding of raw UTF-8 text from Ogg streams
Michael Niedermayer
michaelni
Mon Aug 17 23:00:47 CEST 2009
On Sun, Aug 16, 2009 at 04:02:25PM +0100, ogg.k.ogg.k at googlemail.com wrote:
> > So I can't see how what you said would make any sense at all
>
> After thinking some more about the code and your comment, I now
> see why it all falls down into place without needing the extra check.
> Patch attached again :)
[...]
> +static void find_timing(const AVPacket *avpkt, const AVRational *time_base,
> + uint32_t *start, uint32_t *end)
> +{
> + unsigned int hour0, min0, sec0, hsec0;
> + unsigned int hour1, min1, sec1, hsec1;
> + uint32_t start_ms, end_ms, pts_ms;
> + char *copy;
> +
> + *start = 0;
> + *end = 0;
> +
> + copy = av_malloc(avpkt->size+1);
> + if (!copy)
> + return;
this silent error handling seems bad to me
> + memcpy(copy, avpkt->data, avpkt->size);
> + copy[avpkt->size] = 0;
> +
> + if (sscanf(copy, "%*[^,],%u:%u:%u%*c%u,%u:%u:%u%*c%u",
> + &hour0, &min0, &sec0, &hsec0, &hour1, &min1, &sec1, &hsec1) != 8) {
> + goto end;
> + }
> +
> +#define CHK(val, mx) if ((val) >= (mx)) goto end;
> + CHK(hour0, ((unsigned int)INT_MAX)+1);
> + CHK(hour1, ((unsigned int)INT_MAX)+1);
> + CHK(min0, 60);
> + CHK(min1, 60);
> + CHK(sec0, 60);
> + CHK(sec1, 60);
> + CHK(hsec0, 100);
> + CHK(hsec1, 100);
> +#undef CHK
> +
> + /* 1197 hours or so */
> + start_ms = hour0 * 60*60*1000 + min0 * 60*1000 + sec0 * 1000 + hsec0 * 10;
> + end_ms = hour1 * 60*60*1000 + min1 * 60*1000 + sec1 * 1000 + hsec1 * 10;
> + pts_ms = 1000 * avpkt->pts * time_base->num / time_base->den;
> +
> + if (start_ms < pts_ms || end_ms < start_ms)
> + goto end;
> +
> + /* assumes the packet pts is set to the start data from the string */
> + *start = 0;
if start is always 0 it doesnt need to be passed into the function to begin with
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090817/7133ef57/attachment.pgp>
More information about the ffmpeg-devel
mailing list