[FFmpeg-devel] [PATCH] Decoding of raw UTF-8 text from Ogg streams

Diego Biurrun diego
Tue Jul 28 22:03:01 CEST 2009


On Tue, Jul 28, 2009 at 07:03:16PM +0100, ogg.k.ogg.k at googlemail.com wrote:
> 
> Thanks, very useful pointer!
> Attached is a patch to do just that, along with an updated patch for
> the ASS/SSA decoder which parses the text to extract timings.
> 
> --- /dev/null
> +++ b/libavcodec/ssadec.c
> @@ -0,0 +1,120 @@
> +
> +    if(sscanf(avpkt->data, "%*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d",

if (

> +#define CHK(val,mx) if ((val) < 0 || (val) >= (mx)) return;
> +    CHK(hour0,(uint32_t)-1);
> +    CHK(hour1,(uint32_t)-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)
> +        return;
> +
> +    *start = start_ms - pts_ms;
> +    *end = end_ms - pts_ms;

Much of this could be aligned for better readability.

Diego



More information about the ffmpeg-devel mailing list