[FFmpeg-devel] [PATCH] avcodec: add C xvid IDCT support

Michael Niedermayer michaelni at gmx.at
Mon Aug 11 13:09:14 CEST 2014


On Mon, Aug 11, 2014 at 12:36:56AM -0300, James Almer wrote:
> On 11/08/14 12:18 AM, Michael Niedermayer wrote:
> > From: Pascal Massimino <pascal.massimino at gmail.com>
> > 
> > Thanks to Pascal Massimino and Michael Militzer for permission to use under LGPL
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavcodec/Makefile      |    2 +-
> >  libavcodec/xvid_c_idct.c |  335 ++++++++++++++++++++++++++++++++++++++++++++++
> >  libavcodec/xvididct.c    |   60 +++++++++
> >  libavcodec/xvididct.h    |    2 +
> >  4 files changed, 398 insertions(+), 1 deletion(-)
> >  create mode 100644 libavcodec/xvid_c_idct.c
> > 
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index 6873439..55b7b02 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -325,7 +325,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_DECODER)      += mpeg12dec.o mpeg12.o mpeg12data.o
> >  OBJS-$(CONFIG_MPEG1VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o
> >  OBJS-$(CONFIG_MPEG2VIDEO_DECODER)      += mpeg12dec.o mpeg12.o mpeg12data.o
> >  OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o
> > -OBJS-$(CONFIG_MPEG4_DECODER)           += xvididct.o
> > +OBJS-$(CONFIG_MPEG4_DECODER)           += xvididct.o xvid_c_idct.o
> >  OBJS-$(CONFIG_MPL2_DECODER)            += mpl2dec.o ass.o
> >  OBJS-$(CONFIG_MSMPEG4V1_DECODER)       += msmpeg4dec.o msmpeg4.o msmpeg4data.o
> >  OBJS-$(CONFIG_MSMPEG4V2_DECODER)       += msmpeg4dec.o msmpeg4.o msmpeg4data.o
> > diff --git a/libavcodec/xvid_c_idct.c b/libavcodec/xvid_c_idct.c
> > new file mode 100644
> > index 0000000..b15fb8e
> > --- /dev/null
> > +++ b/libavcodec/xvid_c_idct.c
> > @@ -0,0 +1,335 @@
> > +/*****************************************************************************
> > + *
> > + *  XVID MPEG-4 VIDEO CODEC
> > + *  - Inverse DCT  -
> > + *
> > + *  Copyright (C) 2006-2011 Xvid Solutions GmbH
> > + *
> > + * 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
> > + *
> > + * $Id$
> > + *
> > + ****************************************************************************/
> > +
> > +/*
> > + *  Authors: Skal
> > + *
> > + *  Walken IDCT
> > + *  Alternative idct implementations for decoding compatibility
> > + *
> > + *  NOTE: this "C" version is not the original one,
> > + *  but is modified to yield the same error profile
> > + *  than the MMX version.
> > + *
> > + ************************************************************************/
> 
> Is a separate file really necessary? The above copyright could be copied to xvididct.c just fine.
> It's all lgpl code.

a seperate file is not neccessary but may make future syncing with
xvid easier


> 
> [...]
> 
> > diff --git a/libavcodec/xvididct.c b/libavcodec/xvididct.c
> > index 8645af4..9b07518 100644
> > --- a/libavcodec/xvididct.c
> > +++ b/libavcodec/xvididct.c
> > @@ -22,6 +22,59 @@
> >  #include "idctdsp.h"
> >  #include "xvididct.h"
> >  
> > +static void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,
> > +                                 int line_size)
> > +{
> > +    int i;
> > +
> > +    /* read the pixels */
> > +    for (i = 0; i < 8; i++) {
> > +        pixels[0] = av_clip_uint8(block[0]);
> > +        pixels[1] = av_clip_uint8(block[1]);
> > +        pixels[2] = av_clip_uint8(block[2]);
> > +        pixels[3] = av_clip_uint8(block[3]);
> > +        pixels[4] = av_clip_uint8(block[4]);
> > +        pixels[5] = av_clip_uint8(block[5]);
> > +        pixels[6] = av_clip_uint8(block[6]);
> > +        pixels[7] = av_clip_uint8(block[7]);
> > +
> > +        pixels += line_size;
> > +        block  += 8;
> > +    }
> > +}
> > +
> > +static void add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,
> > +                                 int line_size)
> > +{
> > +    int i;
> > +
> > +    /* read the pixels */
> > +    for (i = 0; i < 8; i++) {
> > +        pixels[0] = av_clip_uint8(pixels[0] + block[0]);
> > +        pixels[1] = av_clip_uint8(pixels[1] + block[1]);
> > +        pixels[2] = av_clip_uint8(pixels[2] + block[2]);
> > +        pixels[3] = av_clip_uint8(pixels[3] + block[3]);
> > +        pixels[4] = av_clip_uint8(pixels[4] + block[4]);
> > +        pixels[5] = av_clip_uint8(pixels[5] + block[5]);
> > +        pixels[6] = av_clip_uint8(pixels[6] + block[6]);
> > +        pixels[7] = av_clip_uint8(pixels[7] + block[7]);
> > +        pixels   += line_size;
> > +        block    += 8;
> > +    }
> > +}
> 
> Why the code duplication? These two functions are exact copies of the ones in idctdsp.
> You could share the latter and use them here instead.

fixed

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

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140811/b3564b10/attachment.asc>


More information about the ffmpeg-devel mailing list