[FFmpeg-devel] [PATCH 3/4] srtenc: Add timing-less "subrip" encoder.

Clément Bœsch ubitux at gmail.com
Mon Aug 13 07:47:18 CEST 2012


On Sun, Aug 12, 2012 at 02:26:28PM -0700, Philip Langdale wrote:
> Unsurprisingly, if a timing-less subrip decoder is desireable, an
> encoder is as well. With this in place, we can move on to remove
> the use of the old encoder/decoder with embedded timing and move
> all timing handling the (de)muxer where they belong.
> 
> Signed-off-by: Philip Langdale <philipl at overt.org>
> ---
>  libavcodec/allcodecs.c |    2 +-
>  libavcodec/srtenc.c    |   39 ++++++++++++++++++++++++++++-----------
>  libavcodec/version.h   |    2 +-
>  3 files changed, 30 insertions(+), 13 deletions(-)
> 

Don't you need an update of the Makefile using CONFIG_SUBRIP_ENCODER as
well?

> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index f7ae449..9814773 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -415,7 +415,7 @@ void avcodec_register_all(void)
>      REGISTER_DECODER (REALTEXT, realtext);
>      REGISTER_DECODER (SAMI, sami);
>      REGISTER_ENCDEC  (SRT, srt);
> -    REGISTER_DECODER (SUBRIP, subrip);
> +    REGISTER_ENCDEC  (SUBRIP, subrip);
>      REGISTER_DECODER (SUBVIEWER, subviewer);
>      REGISTER_ENCDEC  (XSUB, xsub);
>  
> diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c
> index 9e152c7..dfc4e6c 100644
> --- a/libavcodec/srtenc.c
> +++ b/libavcodec/srtenc.c
> @@ -252,16 +252,18 @@ static int srt_encode_frame(AVCodecContext *avctx,
>  
>          dialog = ff_ass_split_dialog(s->ass_ctx, sub->rects[i]->ass, 0, &num);
>          for (; dialog && num--; dialog++) {
> -            int sh, sm, ss, sc = 10 * dialog->start;
> -            int eh, em, es, ec = 10 * dialog->end;
> -            sh = sc/3600000;  sc -= 3600000*sh;
> -            sm = sc/  60000;  sc -=   60000*sm;
> -            ss = sc/   1000;  sc -=    1000*ss;
> -            eh = ec/3600000;  ec -= 3600000*eh;
> -            em = ec/  60000;  ec -=   60000*em;
> -            es = ec/   1000;  ec -=    1000*es;
> -            srt_print(s,"%d\r\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n",
> -                      ++s->count, sh, sm, ss, sc, eh, em, es, ec);
> +            if (avctx->codec->id == CODEC_ID_SRT) {
> +                int sh, sm, ss, sc = 10 * dialog->start;
> +                int eh, em, es, ec = 10 * dialog->end;
> +                sh = sc/3600000;  sc -= 3600000*sh;
> +                sm = sc/  60000;  sc -=   60000*sm;
> +                ss = sc/   1000;  sc -=    1000*ss;
> +                eh = ec/3600000;  ec -= 3600000*eh;
> +                em = ec/  60000;  ec -=   60000*em;
> +                es = ec/   1000;  ec -=    1000*es;
> +                srt_print(s,"%d\r\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n",
> +                          ++s->count, sh, sm, ss, sc, eh, em, es, ec);
> +            }

I assume this block is just re-indented without any modification in it.

[...]

Rest should be OK.

Note: ideally, a FATE test would be welcome at the end of the patchset.

-- 
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/20120813/256009bb/attachment.asc>


More information about the ffmpeg-devel mailing list