[FFmpeg-devel] [PATCH 2/2] add ASS encoder and decoder

Michael Niedermayer michaelni
Tue Nov 9 19:25:52 CET 2010


On Mon, Nov 08, 2010 at 12:54:25AM +0100, Aurelien Jacobs wrote:
> On Sun, Oct 24, 2010 at 07:13:01PM +0200, Michael Niedermayer wrote:
> > On Sat, Oct 16, 2010 at 05:31:27PM +0200, Aurelien Jacobs wrote:
> > > ---
> > >  libavcodec/Makefile    |    2 +
> > >  libavcodec/allcodecs.c |    1 +
> > >  libavcodec/ass.c       |   37 +++++++++++++++++++++++++
> > >  libavcodec/ass.h       |   30 ++++++++++++++++++++
> > >  libavcodec/assdec.c    |   50 +++++++++++++++++++++++++++++++++
> > >  libavcodec/assenc.c    |   71 ++++++++++++++++++++++++++++++++++++++++++++++++
> > >  6 files changed, 191 insertions(+), 0 deletions(-)
> > >  create mode 100644 libavcodec/ass.c
> > >  create mode 100644 libavcodec/ass.h
> > >  create mode 100644 libavcodec/assdec.c
> > >  create mode 100644 libavcodec/assenc.c
> > > 
> > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > > index 385ae02..d4afc0b 100644
> > > --- a/libavcodec/Makefile
> > > +++ b/libavcodec/Makefile
> > > @@ -66,6 +66,8 @@ OBJS-$(CONFIG_AMV_DECODER)             += sp5xdec.o mjpegdec.o mjpeg.o
> > >  OBJS-$(CONFIG_ANM_DECODER)             += anm.o
> > >  OBJS-$(CONFIG_ANSI_DECODER)            += ansi.o cga_data.o
> > >  OBJS-$(CONFIG_APE_DECODER)             += apedec.o
> > > +OBJS-$(CONFIG_ASS_DECODER)             += assdec.o
> > > +OBJS-$(CONFIG_ASS_ENCODER)             += assenc.o
> > >  OBJS-$(CONFIG_ASV1_DECODER)            += asv1.o mpeg12data.o
> > >  OBJS-$(CONFIG_ASV1_ENCODER)            += asv1.o mpeg12data.o
> > >  OBJS-$(CONFIG_ASV2_DECODER)            += asv1.o mpeg12data.o
> > > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> > > index 89614ab..b42935c 100644
> > > --- a/libavcodec/allcodecs.c
> > > +++ b/libavcodec/allcodecs.c
> > > @@ -341,6 +341,7 @@ void avcodec_register_all(void)
> > >      REGISTER_ENCDEC  (ADPCM_YAMAHA, adpcm_yamaha);
> > >  
> > >      /* subtitles */
> > > +    REGISTER_ENCDEC  (ASS, ass);
> > >      REGISTER_ENCDEC  (DVBSUB, dvbsub);
> > >      REGISTER_ENCDEC  (DVDSUB, dvdsub);
> > >      REGISTER_DECODER (PGSSUB, pgssub);
> > > diff --git a/libavcodec/ass.c b/libavcodec/ass.c
> > > new file mode 100644
> > > index 0000000..36650c1
> > > --- /dev/null
> > > +++ b/libavcodec/ass.c
> > > @@ -0,0 +1,37 @@
> > > +/*
> > > + * SSA/ASS common funtions
> > > + * Copyright (c) 2010  Aurelien Jacobs <aurel at gnuage.org>
> > > + *
> > > + * This file is part of FFmpeg.
> > > + *
> > > + * FFmpeg is free software; you can redistribute it and/or
> > > + * modify it under the terms of the GNU Lesser General Public
> > > + * License as published by the Free Software Foundation; either
> > > + * version 2.1 of the License, or (at your option) any later version.
> > > + *
> > > + * FFmpeg is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > > + * Lesser General Public License for more details.
> > > + *
> > > + * You should have received a copy of the GNU Lesser General Public
> > > + * License along with FFmpeg; if not, write to the Free Software
> > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> > > + */
> > > +
> > > +#include "avcodec.h"
> > > +#include "ass.h"
> > > +
> > > +int ff_ass_subtitle(AVSubtitle *sub, int *data_size, const char *dialog,
> > > +                    int duration)
> > > +{
> > > +    memset(sub, 0, sizeof(*sub));
> > > +    sub->end_display_time = 10 * duration;
> > > +    sub->rects     = av_mallocz(sizeof(*sub->rects));
> > > +    sub->rects[0]  = av_mallocz(sizeof(AVSubtitleRect));
> > > +    sub->num_rects = 1;
> > > +    sub->rects[0]->type = SUBTITLE_ASS;
> > > +    sub->rects[0]->ass  = av_strdup(dialog);
> > > +    *data_size = 1;
> > > +    return 0;
> > > +}
> > > diff --git a/libavcodec/ass.h b/libavcodec/ass.h
> > > new file mode 100644
> > > index 0000000..00ad504
> > > --- /dev/null
> > > +++ b/libavcodec/ass.h
> > > @@ -0,0 +1,30 @@
> > > +/*
> > > + * SSA/ASS common funtions
> > > + * Copyright (c) 2010  Aurelien Jacobs <aurel at gnuage.org>
> > > + *
> > > + * This file is part of FFmpeg.
> > > + *
> > > + * FFmpeg is free software; you can redistribute it and/or
> > > + * modify it under the terms of the GNU Lesser General Public
> > > + * License as published by the Free Software Foundation; either
> > > + * version 2.1 of the License, or (at your option) any later version.
> > > + *
> > > + * FFmpeg is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > > + * Lesser General Public License for more details.
> > > + *
> > > + * You should have received a copy of the GNU Lesser General Public
> > > + * License along with FFmpeg; if not, write to the Free Software
> > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> > > + */
> > > +
> > > +#ifndef AVCODEC_ASS_H
> > > +#define AVCODEC_ASS_H
> > > +
> > > +#include "avcodec.h"
> > > +
> > 
> > > +int ff_ass_subtitle(AVSubtitle *sub, int *data_size, const char *dialog,
> > > +                    int duration);
> > 
> > global functions should be documented, always IMHO
> 
> OK.
> 
> I took this opportunity to make this shared function more versatile and
> more useful for other decoders (which I'm currently working on).
> 
> Aurel
>  Makefile    |    2 +
>  allcodecs.c |    1 
>  ass.c       |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  ass.h       |   53 ++++++++++++++++++++++++++++++++++++++++++++++
>  assdec.c    |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  assenc.c    |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 255 insertions(+)
> 5e1fe4c1b65d3b526bda4518936839fb7f02a422  ass_enc_dec.diff
> commit 56aade3d85939478b6ef05dd249936292041fddc
> Author: Aurelien Jacobs <aurel at gnuage.org>
> Date:   Mon Aug 30 15:00:57 2010 +0200
> 
>     add ASS encoder and decoder
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 385ae02..d4afc0b 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -66,6 +66,8 @@ OBJS-$(CONFIG_AMV_DECODER)             += sp5xdec.o mjpegdec.o mjpeg.o
>  OBJS-$(CONFIG_ANM_DECODER)             += anm.o
>  OBJS-$(CONFIG_ANSI_DECODER)            += ansi.o cga_data.o
>  OBJS-$(CONFIG_APE_DECODER)             += apedec.o
> +OBJS-$(CONFIG_ASS_DECODER)             += assdec.o
> +OBJS-$(CONFIG_ASS_ENCODER)             += assenc.o
>  OBJS-$(CONFIG_ASV1_DECODER)            += asv1.o mpeg12data.o
>  OBJS-$(CONFIG_ASV1_ENCODER)            += asv1.o mpeg12data.o
>  OBJS-$(CONFIG_ASV2_DECODER)            += asv1.o mpeg12data.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 89614ab..b42935c 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -341,6 +341,7 @@ void avcodec_register_all(void)
>      REGISTER_ENCDEC  (ADPCM_YAMAHA, adpcm_yamaha);
>  
>      /* subtitles */
> +    REGISTER_ENCDEC  (ASS, ass);
>      REGISTER_ENCDEC  (DVBSUB, dvbsub);
>      REGISTER_ENCDEC  (DVDSUB, dvdsub);
>      REGISTER_DECODER (PGSSUB, pgssub);
> diff --git a/libavcodec/ass.c b/libavcodec/ass.c
> new file mode 100644
> index 0000000..d771cb9
> --- /dev/null
> +++ b/libavcodec/ass.c
> @@ -0,0 +1,68 @@
> +/*
> + * SSA/ASS common funtions
> + * Copyright (c) 2010  Aurelien Jacobs <aurel at gnuage.org>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include "avcodec.h"
> +#include "ass.h"
> +

> +void ff_ass_init(AVSubtitle *sub)
> +{
> +    memset(sub, 0, sizeof(*sub));
> +}

why not call memset() directly ?

except that lgtm

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

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101109/a61736b6/attachment.pgp>



More information about the ffmpeg-devel mailing list