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

Michael Niedermayer michaelni
Mon Aug 10 21:50:38 CEST 2009


On Tue, Aug 04, 2009 at 06:54:26PM +0100, ogg.k.ogg.k at googlemail.com wrote:
> > please set start=0
> 
> Attached.

[...]
> +static void find_timing(const AVPacket *avpkt, const AVRational *time_base,
> +                        uint32_t *start, uint32_t *end)
> +{
> +    int hour0, min0, sec0, hsec0;
> +    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;

indention depth should be x*4


> +    memcpy(copy, avpkt->data, avpkt->size);
> +    copy[avpkt->size] = 0;
> +
> +    if (sscanf(copy, "%*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d",
> +        &hour0, &min0, &sec0, &hsec0, &hour1, &min1, &sec1, &hsec1) != 8) {
> +        goto end;
> +    }
> +
> +#define CHK(val, mx) if ((val) < 0 || (val) >= (mx)) goto end;

if the values are unsigned, >= is enough


[...]
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 43147a5..c13ad90 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -655,6 +655,31 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
>      return ret;
>  }
>  
> +int avcodec_free_subtitle(AVCodecContext *avctx, AVSubtitle *sub)
> +{
> +    unsigned int n;
> +
> +    if (!sub || !sub->num_rects)
> +        return 0;
> +
> +    for (n = 0; n < sub->num_rects; n++) {
> +        AVSubtitleRect *r = sub->rects[n];
> +        AVPicture *pic;
> +        if (r) {
> +            unsigned int d;
> +
> +            av_freep(&r->text);
> +            av_freep(&r->ass);
> +            pic = &r->pict;
> +            for (d = 0; d < FF_ARRAY_ELEMS(pic->data); d++) {
> +                av_freep(&pic->data[n]);
> +            }
> +        }
> +    }
> +
> +    return 0;
> +}
> +
>  int avcodec_close(AVCodecContext *avctx)
>  {

that should be a seperate patch

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
            conveniently.
New school: Use the highest level language in which the latest supercomputer
            can solve the problem without the user falling asleep waiting.
-------------- 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/20090810/696cf5a7/attachment.pgp>



More information about the ffmpeg-devel mailing list