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

David Conrad lessen42
Mon Jul 13 04:27:14 CEST 2009


On Jul 11, 2009, at 4:52 AM, ogg.k.ogg.k at googlemail.com wrote:

> On 7/11/09, Diego Biurrun <diego at biurrun.de> wrote:
>
> [feedback]
>
> Updated patch attached with comments taken into account.
>
> Thanks

> From c959a1e925baa76f3b82edde2e12eb1ac125d87a Mon Sep 17 00:00:00 2001
> From: ogg.k.ogg.k <ogg.k.ogg.k at googlemail.com>
> Date: Wed, 3 Jun 2009 22:39:51 +0100
> Subject: [PATCH] first pass kate decoding support
>
> ---
>  libavformat/Makefile       |    1 +
>  libavformat/oggdec.c       |   31 +++++-
>  libavformat/oggdec.h       |    3 +
>  libavformat/oggparsekate.c |  248 ++++++++++++++++++++++++++++++++++ 
> ++++++++++
>  4 files changed, 277 insertions(+), 6 deletions(-)
>  create mode 100644 libavformat/oggparsekate.c

>

> [...]

>
> @@ -450,7 +457,7 @@ ogg_get_length (AVFormatContext * s)
>      size = url_fsize(s->pb);
>      if(size < 0)
>          return 0;
> -    end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: 0;
> +    end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: size;
>
>      ogg_save (s);
>      url_fseek (s->pb, end, SEEK_SET);

This breaks finding the duration of ogg files smaller than  
MAX_PAGE_SIZE, why is it needed?

> @@ -498,25 +505,37 @@ ogg_read_packet (AVFormatContext * s, AVPacket  
> * pkt)
>      struct ogg_stream *os;
>      int idx = -1;
>      int pstart, psize;
> +    int64_t duration;
>
>      //Get an ogg packet
>      do{
> -        if (ogg_packet (s, &idx, &pstart, &psize) < 0)
> +        if (ogg_packet (s, &idx, &pstart, &psize, &duration) < 0)
>              return AVERROR(EIO);
>      }while (idx < 0 || !s->streams[idx]);
>
>      ogg = s->priv_data;
>      os = ogg->streams + idx;
>
> +    if (psize == 0)
> +        return 0;
> +

Kate can have size 0 packets?

>      //Alloc a pkt
>      if (av_new_packet (pkt, psize) < 0)
>          return AVERROR(EIO);
>      pkt->stream_index = idx;
>      memcpy (pkt->data, os->buf + pstart, psize);
> -    if (os->lastgp != -1LL){
> +
> +    /* ffmpeg assumes timing by end of buffer, as vorbis, newer  
> theora, etc - kate is not */
> +    if (os->codec == &ff_kate_codec) {
> +        pkt->pts = ogg_gptopts (s, idx, os->granule);
> +    }
> +    else if (os->lastgp != -1LL){
>          pkt->pts = ogg_gptopts (s, idx, os->lastgp);
>          os->lastgp = -1;
>      }

This ought to be a field in struct ogg_codec so it can be used for  
dirac and ogm as well; I'll fix this shortly.

> +    // we ignore any non text data packet for now (repeats, etc)
> +    if (packtype != 0) {
> +        av_log(NULL, AV_LOG_DEBUG, "Packet type %02x ignored\n",  
> packtype);
> +        os->psize = 0;
> +        return 0;
> +    }

If Kate allows for formatting above raw UTF-8, I think that the idea  
of ffmpeg's subtitle system is to pass the raw data, and have a  
decoder convert it to plain utf-8 or ass, with the renderer being a  
third separate thing. But I'm not sure since I don't think that's  
really implemented.



More information about the ffmpeg-devel mailing list