[FFmpeg-devel] Trans.: a64multienc.c and drawutils.c optimisations

yann.lepetitcorps at free.fr yann.lepetitcorps at free.fr
Wed Dec 28 04:35:04 CET 2011


Selon yann.lepetitcorps at free.fr:

> I have begin the factorization on the dpcm_ima_qt_expand_nibble() func into
> libavcodec/adpcm.c
>
> This add a very little array
>
>     int adpcm_nibble_diff_step_tab[8] = { 0, 4, 2, 6, 1, 3, 5, 7 };
>
> and factorize the 4 "nibbled diffs"  on the adpcm_ima_qt_expand_nibble() func
>
>     diff = step >> 3;
>     if (nibble & 4) diff += step;
>     if (nibble & 2) diff += step >> 1;
>     if (nibble & 1) diff += step >> 2;
>
> into one indexation into this array, one addition and one multiply
>
>     diff =  (adpcm_nibble_diff_step_tab[nibble &0x7]+8) * step;
>
> No tested, the +8 add can certainly to be trivialy added to each entry on the
> adpcm_nibble_diff_step_tab[] array  ...  but the idea is here :)
>
>
> @+
> Yannoo
>
> Selon yann.lepetitcorps at free.fr:
>
> > I think that needed modifications are in this attachment
> >
> > How can I automaticaly replace tabs with the good group of spaces with git
> > (or
> > gedit) ?
> >
> > I think to make tomorrow some modifications into the libavcodec/admpc.c
> file
> > at
> > the adpcm_ima_qt_expand_nibble() func
> > (the 3x diff successives test/additions can certainly to be factorised via
> a
> > multiplication of step with an entry on a table indexed by nibble)
> >
> >
> > @+
> > Yannoo
> >
> > Selon Michael Niedermayer <michaelni at gmx.at>:
> >
> > > On Tue, Dec 27, 2011 at 09:39:19PM +0100, yann.lepetitcorps at free.fr
> wrote:
> > > > The same thing but with a very little optimization that economize one
> > > > multiplication into the memcpy on the memset_sized() func in
> drawutils.C
> > > >
> > > > @+
> > > > Yannoo
> > > >
> > > > Selon yann.lepetitcorps at free.fr:
> > > >
> > > > > I have download the FFMPEG git into my linux box, make modifications,
> > > > > compiled
> > > > > the new version and generated the diff file in attachment.
> > > > >
> > > > >
> > > > >
> > > > > @+
> > > > > Yannoo
> > > > >
> > > > >
> > > > > Selon yann.lepetitcorps at free.fr:
> > > > >
> > > > > > No problem :)
> > > > > >
> > > > > > => I download the current git head on my linux box and work only
> with
> > > it
> > > > > >    (instead the 0.9 version that I have previously used on my Apple
> > > box)
> > > > > >
> > > > > > @+
> > > > > > Yannoo
> > > > > >
> > > > > > Selon Carl Eugen Hoyos <cehoyos at ag.or.at>:
> > > > > >
> > > > > > >  <yann.lepetitcorps <at> free.fr> writes:
> > > > > > >
> > > > > > > > I have begin to analyse FFMPEG 0.9 sources and think to has
> found
> > > somes
> > > > > > > areas
> > > > > > >
> > > > > > > Please do not work on a release, only develop with current git
> > head!
> > > > > > >
> > > > > > > > that can to be a little optimised such as in a64multienc.c or
> > > > > drawutils.c
> > > > > > >
> > > > > > > If you feel unable to use git send-email (which is the preferred
> > way
> > > of
> > > > > > > sending
> > > > > > > patches), please at least do "git diff >patchfile.diff" and send
> > the
> > > > > result
> > > > > > > as
> > > > > > > an attachment.
> > > > > > >
> > > > > > > Carl Eugen
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > ffmpeg-devel mailing list
> > > > > > > ffmpeg-devel at ffmpeg.org
> > > > > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > > > > >
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > ffmpeg-devel mailing list
> > > > > > ffmpeg-devel at ffmpeg.org
> > > > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > > >  libavcodec/a64multienc.c |    5 ++-
> > > >  libavfilter/drawutils.c  |   61
> > > ++++++++++++++++++++++++++++++++++++++++++++++-
> > > >  libavfilter/drawutils.h  |    6 ++++
> > > >  3 files changed, 69 insertions(+), 3 deletions(-)
> > > > fb09107371ee746b3b3a4ae5a576ad70fc6e71ec  ylp_27dec2011_21h19.diff
> > > > diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
> > > > index 5a665d0..b0e7b14 100644
> > > > --- a/libavcodec/a64multienc.c
> > > > +++ b/libavcodec/a64multienc.c
> > > > @@ -49,15 +49,16 @@ static void to_meta_with_crop(AVCodecContext
> *avctx,
> > > AVFrame *p, int *dest)
> > > >      int height = FFMIN(avctx->height, C64YRES);
> > > >      int width  = FFMIN(avctx->width , C64XRES);
> > > >      uint8_t *src = p->data[0];
> > > > +    uint8_t *src2;
> > > >
> > > >      for (blocky = 0; blocky < C64YRES; blocky += 8) {
> > > >          for (blockx = 0; blockx < C64XRES; blockx += 8) {
> > > >              for (y = blocky; y < blocky + 8 && y < C64YRES; y++) {
> > > > +                src2 = src + y * p->linesize[0];
> > > >                  for (x = blockx; x < blockx + 8 && x < C64XRES; x +=
> 2)
> > {
> > > >                      if(x < width && y < height) {
> > > >                          /* build average over 2 pixels */
> > > > -                        luma = (src[(x + 0 + y * p->linesize[0])] +
> > > > -                                src[(x + 1 + y * p->linesize[0])]) /
> 2;
> > > > +                        luma  = ((int)(src2[x]) + (int)(src2[x+1])) /
> 2;
> > >
> > > the casts are unneeded
> > >
> > >
> > >
> > > >                          /* write blocks as linear data now so they are
> > > suitable for elbg */
> > > >                          dest[0] = luma;
> > > >                      }
> > > > diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c
> > > > index bf308a1..055cfd0 100644
> > > > --- a/libavfilter/drawutils.c
> > > > +++ b/libavfilter/drawutils.c
> > > > @@ -38,6 +38,46 @@ int ff_fill_rgba_map(uint8_t *rgba_map, enum
> > PixelFormat
> > > pix_fmt)
> > > >      return 0;
> > > >  }
> > > >
> > > > +void memset8(char *dst, char *val, int num)
> > > > +{
> > > > +        memset(dst, *val, num);
> > > > +}
> > >
> > > should be static or needs a ff_ prefix to avoid namespace conflicts
> > > with other libs
> > > also if it has a ff_ prefix / is intended to be used from outside
> > > char val seems easier to use than char *val
> > >
> > >
> > > > +
> > > > +void memset16(short int *dst, short int *val, int num)
> > > > +{
> > > > +        int i;
> > > > +        short int  set16 = *val;
> > >
> > > should be int16_t, as short is not guranteed to be 16bit
> > >
> > >
> > > > +
> > > > +        for(i=0;i<num;i++)
> > > > +                *dst++ = set16;
> > > > +}
> > > > +
> > > > +void memset32(int *dst, int *val, int num)
> > > > +{
> > > > +        int i;
> > > > +        int set32 = *val;
> > >
> > > int32_t
> > >
> > >
> > > > +
> > > > +        for(i=0;i<num;i++)
> > > > +                *dst++ = set32;
> > > > +}
> > > > +
> > > > +
> > > > +void memset24(char *dst, char *src, int num)
> > > > +{
> > > > +        int i;
> > > > +
> > > > +        for (i = 0; i < num; i++)
> > > > +            memcpy(dst + i * 3, src, 3);
> > > > +}
> > > > +
> > > > +void memset_sized(char *dst, char *src, int num, int stepsize)
> > > > +{
> > > > +        int i;
> > > > +
> > > > +        for (i = 0; i < num; i++, dst += stepsize)
> > > > +            memcpy(dst, src, stepsize);
> > > > +}
> > > > +
> > > >  int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int
> w,
> > > uint8_t dst_color[4],
> > > >                              enum PixelFormat pix_fmt, uint8_t
> > > rgba_color[4],
> > > >                              int *is_packed_rgba, uint8_t
> > rgba_map_ptr[4])
> > >
> > > > @@ -55,8 +95,27 @@ int ff_fill_line_with_color(uint8_t *line[4], int
> > > pixel_step[4], int w, uint8_t
> > > >              dst_color[rgba_map[i]] = rgba_color[i];
> > > >
> > > >          line[0] = av_malloc(w * pixel_step[0]);
> > > > -        for (i = 0; i < w; i++)
> > > > +        /* for (i = 0; i < w; i++)
> > > >              memcpy(line[0] + i * pixel_step[0], dst_color,
> > pixel_step[0]);
> > > > +	*/
> > >
> > > that can be removed entirely
> > >
> > >
> > > > +	switch(av_get_bits_per_pixel(pix_desc))
> > >
> > > tabs are forbidden in git
> > >
> > >
> > >
> > > thanks
> > >
> > > --
> > > Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> > >
> > > If you think the mosad wants you dead since a long time then you are
> either
> > > wrong or dead since a long time.
> > >
> >
> >
> >
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


I have a make a new diff file that compile the majority of the needed
corrections

PS : is better to add the last post at the beginning (we see instantly the
lastest modification at the opening of the mail) or to add the last post at the
end (the discusion is stored in the natural order) [cf. FIFO vs FILO order] ?

@+
Yannoo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ylp_28dec2011_04h02.diff
Type: text/x-patch
Size: 5093 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111228/caf74dc5/attachment.bin>


More information about the ffmpeg-devel mailing list