[FFmpeg-devel] [PATCH 09/11] libzvbi-teletextdec: output ass subtitles instead of plain text

Clément Bœsch u at pkh.me
Sat Nov 9 00:19:17 CET 2013


On Thu, Oct 31, 2013 at 09:28:55PM +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
>  libavcodec/libzvbi-teletextdec.c | 50 +++++++++++++++++++++++++++++++++-------
>  1 file changed, 42 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/libzvbi-teletextdec.c b/libavcodec/libzvbi-teletextdec.c
> index 6180192..4678d5f 100644
> --- a/libavcodec/libzvbi-teletextdec.c
> +++ b/libavcodec/libzvbi-teletextdec.c
> @@ -19,6 +19,7 @@
>   */
>  
>  #include "avcodec.h"
> +#include "libavcodec/ass.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/bprint.h"
>  #include "libavutil/intreadwrite.h"
> @@ -49,7 +50,7 @@ typedef struct TeletextContext
>      char           *pgno;
>      int             x_offset;
>      int             y_offset;
> -    int             format_id; /* 0 = bitmap, 1 = text */
> +    int             format_id; /* 0 = bitmap, 1 = text/ass */
>      int             chop_top;
>      int             sub_duration; /* in msec */
>      int             transparent_bg;
> @@ -88,10 +89,41 @@ subtitle_rect_free(AVSubtitleRect **sub_rect)
>  {
>      av_freep(&(*sub_rect)->pict.data[0]);
>      av_freep(&(*sub_rect)->pict.data[1]);
> -    av_freep(&(*sub_rect)->text);
> +    av_freep(&(*sub_rect)->ass);
>      av_freep(sub_rect);
>  }
>  
> +static int
> +create_ass_text(TeletextContext *ctx, const char *text, char **ass)

style nit: static int create_ass_text(...)

(same line)

(yes i know this is done for consistency with rest of the code but that's
not common style)

> +{
> +    int ret;
> +    AVBPrint buf, buf2;
> +    const int ts_start    = av_rescale_q(ctx->pts,          AV_TIME_BASE_Q,        (AVRational){1, 100});
> +    const int ts_duration = av_rescale_q(ctx->sub_duration, (AVRational){1, 1000}, (AVRational){1, 100});
> +

> +    av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
> +    ff_ass_bprint_text_event(&buf, text, strlen(text), "", 0);
> +
> +    if (!av_bprint_is_complete(&buf)) {
> +        av_bprint_finalize(&buf, NULL);
> +        return AVERROR(ENOMEM);
> +    }

Sorry but what is this buf indirection for?

> +
> +    av_bprint_init(&buf2, 0, AV_BPRINT_SIZE_UNLIMITED);
> +    ff_ass_bprint_dialog(&buf2, buf.str, ts_start, ts_duration, 0);
> +    av_bprint_finalize(&buf, NULL);
> +
> +    if (!av_bprint_is_complete(&buf2)) {
> +        av_bprint_finalize(&buf2, NULL);
> +        return AVERROR(ENOMEM);
> +    }
> +
> +    if ((ret = av_bprint_finalize(&buf2, ass)) < 0)
> +        return ret;
> +
> +    return 0;
> +}
> +
[...]

Should be OK otherwise

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131109/056cae53/attachment.asc>


More information about the ffmpeg-devel mailing list