[FFmpeg-devel] [PATCH] Coremake support

Diego Biurrun diego
Wed May 16 11:58:08 CEST 2007


On Mon, May 14, 2007 at 05:38:44PM -0400, Ronald S. Bultje wrote:
> 
> first, sorry for the threading, if you know of a way to fix that in  
> digest mode, please let me know...

Not use digest mode?  Try gmane if the volume of ffmpeg-devel drowns
you.

> On May 14, 2007, Diego Biurrun wrote:
> >On Mon, May 14, 2007 at 01:47:52PM -0400, Ronald S. Bultje wrote:
> >>IMHO it's just a lot easier to let it all be done automatically by
> >>using auto* than doing it all manually. A quick wc - l/-c shows that
> >>my Makefile.ams + configure.ac are currently +/- 2250 lines or 48000
> >>bytes - how much is ffmpeg's configure + Makefile?
> >
> >Where are they?
> 
> Google for autotools.patch, or attached. (And forgive me if the Mac  
> mailer breaks attachments also, I'm expecting that it will.)

It sets the wrong mime type, but this is not hard to work around..

This patch mixes various unrelated changes, some of which are suitable
for upstream.

> --- ffmpeg.orig/libavcodec/alpha/dsputil_alpha.c	2007-03-22 01:00:39.000000000 -0400
> +++ ffmpeg/libavcodec/alpha/dsputil_alpha.c	2007-03-22 01:20:53.000000000 -0400
> @@ -20,7 +20,7 @@
>  
>  #include "asm.h"
> -#include "../dsputil.h"
> +#include "dsputil.h"

These are acceptable for us, I've committed them.  Rejoice, this will
cut the size of this patch in half.

> --- ffmpeg.orig/libavcodec/dct-test.c	2007-03-22 01:00:46.000000000 -0400
> +++ ffmpeg/libavcodec/dct-test.c	2007-03-22 01:20:53.000000000 -0400
> @@ -39,6 +39,7 @@
>  #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
>  #endif
>  
> +#undef fprintf
>  #undef printf
>  
>  void *fast_memcpy(void *a, const void *b, size_t c){return memcpy(a,b,c);};
> @@ -46,13 +47,17 @@
>  /* reference fdct/idct */
>  extern void fdct(DCTELEM *block);
>  extern void idct(DCTELEM *block);
> +#if defined(HAVE_MMX) && defined(CONFIG_GPL)
>  extern void ff_idct_xvid_mmx(DCTELEM *block);
>  extern void ff_idct_xvid_mmx2(DCTELEM *block);
> +#endif
>  extern void init_fdct();
>  
>  extern void j_rev_dct(DCTELEM *data);
> +#ifdef HAVE_MMX
>  extern void ff_mmx_idct(DCTELEM *data);
>  extern void ff_mmxext_idct(DCTELEM *data);
> +#endif
>  
>  extern void odivx_idct_c (short *block);
>  
> @@ -83,6 +88,7 @@
>  
>  static short idct_mmx_perm[64];
>  
> +#ifdef HAVE_MMX
>  static short idct_simple_mmx_perm[64]={
>          0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
>          0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
> @@ -93,6 +99,7 @@
>          0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
>          0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
>  };
> +#endif
>  
>  void idct_mmx_init(void)
>  {
> @@ -162,14 +169,19 @@
>          for(i=0; i<64; i++)
>              block_org[i]= block1[i];
>  
> +#ifdef HAVE_MMX
>          if (fdct_func == ff_mmx_idct ||
>              fdct_func == j_rev_dct || fdct_func == ff_mmxext_idct) {
> +#else
> +	if (fdct_func == j_rev_dct) {
> +#endif
>              for(i=0;i<64;i++)
>                  block[idct_mmx_perm[i]] = block1[i];
> +#ifdef HAVE_MMX
>          } else if(fdct_func == ff_simple_idct_mmx ) {
>              for(i=0;i<64;i++)
>                  block[idct_simple_mmx_perm[i]] = block1[i];
> -
> +#endif
>          } else {
>              for(i=0; i<64; i++)
>                  block[i]= block1[i];
> @@ -184,7 +196,9 @@
>  #endif
>  
>          fdct_func(block);
> +#ifdef HAVE_MMX
>          emms(); /* for ff_mmx_idct */
> +#endif
>  
>          if (fdct_func == fdct_ifast
>  #ifndef FAAN_POSTSCALE
> @@ -261,13 +275,19 @@
>      }break;
>      }
>  
> +#ifdef HAVE_MMX
>      if (fdct_func == ff_mmx_idct ||
>          fdct_func == j_rev_dct || fdct_func == ff_mmxext_idct) {
> +#else
> +    if (fdct_func == j_rev_dct) {
> +#endif
>          for(i=0;i<64;i++)
>              block[idct_mmx_perm[i]] = block1[i];
> +#ifdef HAVE_MMX
>      } else if(fdct_func == ff_simple_idct_mmx ) {
>          for(i=0;i<64;i++)
>              block[idct_simple_mmx_perm[i]] = block1[i];
> +#endif
>      } else {
>          for(i=0; i<64; i++)
>              block[i]= block1[i];
> @@ -286,7 +306,9 @@
>          it1 += NB_ITS_SPEED;
>          ti1 = gettime() - ti;
>      } while (ti1 < 1000000);
> +#ifdef HAVE_MMX
>      emms();
> +#endif
>  
>      printf("%s %s: %0.1f kdct/s\n",
>             is_idct ? "IDCT" : "DCT",
> @@ -446,7 +468,9 @@
>          it1 += NB_ITS_SPEED;
>          ti1 = gettime() - ti;
>      } while (ti1 < 1000000);
> +#ifdef HAVE_MMX
>      emms();
> +#endif
>  
>      printf("%s %s: %0.1f kdct/s\n",
>             1 ? "IDCT248" : "DCT248",
> @@ -508,18 +532,26 @@
>              dct_error("REF-DBL", 0, fdct, fdct, test); /* only to verify code ! */
>              dct_error("IJG-AAN-INT", 0, fdct_ifast, fdct, test);
>              dct_error("IJG-LLM-INT", 0, ff_jpeg_fdct_islow, fdct, test);
> +#ifdef HAVE_MMX
>              dct_error("MMX", 0, ff_fdct_mmx, fdct, test);
>              dct_error("MMX2", 0, ff_fdct_mmx2, fdct, test);
> +#endif
>              dct_error("FAAN", 0, ff_faandct, fdct, test);
>          } else {
>              dct_error("REF-DBL", 1, idct, idct, test);
>              dct_error("INT", 1, j_rev_dct, idct, test);
> +#ifdef HAVE_MMX
>              dct_error("LIBMPEG2-MMX", 1, ff_mmx_idct, idct, test);
>              dct_error("LIBMPEG2-MMXEXT", 1, ff_mmxext_idct, idct, test);
> +#endif
>              dct_error("SIMPLE-C", 1, simple_idct, idct, test);
> +#ifdef HAVE_MMX
>              dct_error("SIMPLE-MMX", 1, ff_simple_idct_mmx, idct, test);
> +#ifdef CONFIG_GPL
>              dct_error("XVID-MMX", 1, ff_idct_xvid_mmx, idct, test);
>              dct_error("XVID-MMX2", 1, ff_idct_xvid_mmx2, idct, test);
> +#endif
> +#endif
>              //        dct_error("ODIVX-C", 1, odivx_idct_c, idct);
>              //printf(" test against odivx idct\n");
>              //        dct_error("REF", 1, idct, odivx_idct_c);

Probably OK, you should submit this to us.

> --- ffmpeg.orig/libavcodec/fft-test.c	2007-03-22 01:00:48.000000000 -0400
> +++ ffmpeg/libavcodec/fft-test.c	2007-03-22 01:20:53.000000000 -0400
> @@ -28,6 +28,9 @@
>  #include <unistd.h>
>  #include <sys/time.h>
>  
> +#undef fprintf
> +#undef printf
> +
>  int mm_flags;

dito

> --- ffmpeg.orig/libavcodec/i386/cputest.c	2007-03-22 01:00:40.000000000 -0400
> +++ ffmpeg/libavcodec/i386/cputest.c	2007-03-22 01:20:53.000000000 -0400
> @@ -21,7 +21,7 @@
>   */
>  
>  #include <stdlib.h>
> -#include "../dsputil.h"
> +#include "dsputil.h"
>  
>  #undef printf
>  
> @@ -120,6 +120,7 @@
>  }
>  
>  #ifdef __TEST__
> +#undef printf
>  int main ( void )
>  {

dito

> --- ffmpeg.orig/libavcodec/imgresample.c	2007-03-22 01:00:47.000000000 -0400
> +++ ffmpeg/libavcodec/imgresample.c	2007-03-22 01:20:53.000000000 -0400
> @@ -28,8 +28,10 @@
>  #include "swscale.h"
>  #include "dsputil.h"
>  
> -#ifdef USE_FASTMEMCPY
> -#include "libvo/fastmemcpy.h"
> +#ifdef TEST
> +#undef printf
> +#undef fprintf
> +#define av_log(p,l,...) fprintf(stderr,__VA_ARGS__)
>  #endif

Removing the #include is pointless, the rest is probably OK.

> --- ffmpeg.orig/libavcodec/motion_test.c	2007-03-22 01:00:50.000000000 -0400
> +++ ffmpeg/libavcodec/motion_test.c	2007-03-22 01:20:53.000000000 -0400
> @@ -31,24 +31,27 @@
>  
>  #include "dsputil.h"
>  
> +#ifdef HAVE_MMX
>  #include "i386/mmx.h"
> +#endif
>  
>  #undef printf
> +#undef fprintf
>  
> -int pix_abs16x16_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_c(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_x2_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_x2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_x2_c(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_y2_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_y2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_y2_c(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_xy2_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_xy2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
> -int pix_abs16x16_xy2_c(uint8_t *blk1, uint8_t *blk2, int lx);
> +int pix_abs16x16_mmx(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_mmx1(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_c(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_x2_mmx(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_x2_mmx1(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_x2_c(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_y2_mmx(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_y2_mmx1(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_y2_c(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_xy2_mmx(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_xy2_mmx1(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
> +int pix_abs16x16_xy2_c(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
>  
> -typedef int motion_func(uint8_t *blk1, uint8_t *blk2, int lx);
> +typedef int motion_func(void *v, uint8_t *blk1, uint8_t *blk2, int lx, int h);
>  
>  #define WIDTH 64
>  #define HEIGHT 64
> @@ -103,15 +106,17 @@
>          for(y=0;y<HEIGHT-17;y++) {
>              for(x=0;x<WIDTH-17;x++) {
>                  ptr = img2 + y * WIDTH + x;
> -                d1 = test_func(img1, ptr, WIDTH);
> -                d2 = ref_func(img1, ptr, WIDTH);
> +                d1 = test_func(NULL, img1, ptr, WIDTH, 1);
> +                d2 = ref_func(NULL, img1, ptr, WIDTH, 1);
>                  if (d1 != d2) {
>                      printf("error: mmx=%d c=%d\n", d1, d2);
>                  }
>              }
>          }
>      }
> +#ifdef HAVE_MMX
>      emms();
> +#endif
>  
>      /* speed test */
>      ti = gettime();
> @@ -120,11 +125,13 @@
>          for(y=0;y<HEIGHT-17;y++) {
>              for(x=0;x<WIDTH-17;x++) {
>                  ptr = img2 + y * WIDTH + x;
> -                d1 += test_func(img1, ptr, WIDTH);
> +                d1 += test_func(NULL, img1, ptr, WIDTH, 1);
>              }
>          }
>      }
> +#ifdef HAVE_MMX
>      emms();
> +#endif
>      dummy = d1; /* avoid optimisation */
>      ti = gettime() - ti;
>  
> @@ -136,13 +143,17 @@
>  
>  int main(int argc, char **argv)
>  {
> -    int c;
> +    int n;
> +#ifdef HAVE_MMX
> +    AVCodecContext *ctx;
> +    DSPContext c, mmx;
> +#endif
>  
>      for(;;) {
> -        c = getopt(argc, argv, "h");
> -        if (c == -1)
> +        n = getopt(argc, argv, "h");
> +        if (n == -1)
>              break;
> -        switch(c) {
> +        switch(n) {
>          case 'h':
>              help();
>              break;
> @@ -151,9 +162,25 @@
>  
>      printf("ffmpeg motion test\n");
>  
> -    test_motion("mmx", pix_abs16x16_mmx, pix_abs16x16_c);
> -    test_motion("mmx_x2", pix_abs16x16_x2_mmx, pix_abs16x16_x2_c);
> -    test_motion("mmx_y2", pix_abs16x16_y2_mmx, pix_abs16x16_y2_c);
> -    test_motion("mmx_xy2", pix_abs16x16_xy2_mmx, pix_abs16x16_xy2_c);
> +#ifdef HAVE_MMX
> +    ctx = avcodec_alloc_context();
> +    mm_flags = 0;
> +    dsputil_init(&c, ctx);
> +    mm_flags = MM_MMX;
> +    dsputil_init(&mmx, ctx);
> +
> +    test_motion("mmx/16",     mmx.pix_abs[0][0], c.pix_abs[0][0]);
> +    test_motion("mmx_x2/16",  mmx.pix_abs[0][1], c.pix_abs[0][1]);
> +    test_motion("mmx_y2/16",  mmx.pix_abs[0][2], c.pix_abs[0][2]);
> +    test_motion("mmx_xy2/16", mmx.pix_abs[0][3], c.pix_abs[0][3]);
> +
> +    test_motion("mmx/8",      mmx.pix_abs[1][0], c.pix_abs[1][0]);
> +    test_motion("mmx_x2/8",   mmx.pix_abs[1][1], c.pix_abs[1][1]);
> +    test_motion("mmx_y2/8",   mmx.pix_abs[1][2], c.pix_abs[1][2]);
> +    test_motion("mmx_xy2/8",  mmx.pix_abs[1][3], c.pix_abs[1][3]);
> +
> +    av_free(ctx);
> +#endif
> +
>      return 0;
>  }

Might be OK.

> --- ffmpeg.orig/libavformat/grab.c	2007-03-22 01:00:54.000000000 -0400
> +++ ffmpeg/libavformat/grab.c	2007-03-22 01:20:53.000000000 -0400
> @@ -431,7 +431,7 @@
>  }
>  
>  #ifdef HAVE_MMX
> -#include "libavcodec/i386/mmx.h"
> +#include "i386/mmx.h"
>  
> @@ -582,7 +582,7 @@
>  
>  #else
> -#include "libavcodec/dsputil.h"
> +#include "dsputil.h"

Committed.

> --- ffmpeg.orig/tests/dsptest.c	2007-03-22 01:00:52.000000000 -0400
> +++ ffmpeg/tests/dsptest.c	2007-03-22 01:20:53.000000000 -0400
> @@ -22,16 +22,16 @@
>  #include "mpegvideo.h"
>  #include "mpeg12data.h"
>  #include "mpeg4data.h"
> -#include "../libavcodec/i386/cputest.c"
> -#include "../libavcodec/i386/dsputil_mmx.c"
> +#include "i386/cputest.c"
> +#include "i386/dsputil_mmx.c"
>  
> -#include "../libavcodec/i386/fdct_mmx.c"
> -#include "../libavcodec/i386/idct_mmx.c"
> -#include "../libavcodec/i386/motion_est_mmx.c"
> -#include "../libavcodec/i386/simple_idct_mmx.c"
> -#include "../libavcodec/dsputil.c"
> -#include "../libavcodec/simple_idct.c"
> -#include "../libavcodec/jfdctfst.c"
> +#include "i386/fdct_mmx.c"
> +#include "i386/idct_mmx.c"
> +#include "i386/motion_est_mmx.c"
> +#include "i386/simple_idct_mmx.c"
> +#include "dsputil.c"
> +#include "simple_idct.c"
> +#include "jfdctfst.c"

This is OK, I'll commit it in a moment.

> @@ -73,13 +73,13 @@
>      int mm_flags;
>  } pix_func[] = {
>  
> -    PIX_FUNC_MMX(put_pixels),
> +    PIX_FUNC_MMX(put_pixels8),
>      //PIX_FUNC_MMX(get_pixels),
>      //PIX_FUNC_MMX(put_pixels_clamped),
>  #if 1
> -    PIX_FUNC(put_pixels_x2),
> -    PIX_FUNC(put_pixels_y2),
> -    PIX_FUNC_MMX(put_pixels_xy2),
> +    PIX_FUNC(put_pixels8_x2),
> +    PIX_FUNC(put_pixels8_y2),
> +    PIX_FUNC_MMX(put_pixels8_xy2),

Not sure about this part.

> --- ffmpeg.orig/libavcodec/i386/h264dsp_mmx.c	2007-03-22 01:00:40.000000000 -0400
> +++ ffmpeg/libavcodec/i386/h264dsp_mmx.c	2007-03-22 01:20:53.000000000 -0400
> @@ -386,7 +386,7 @@
>  
> -static inline void h264_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0)
> +static void h264_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0)

?

> --- ffmpeg.orig/libavcodec/i386/snowdsp_mmx.c	2007-03-22 01:00:40.000000000 -0400
> +++ ffmpeg/libavcodec/i386/snowdsp_mmx.c	2007-03-22 01:20:53.000000000 -0400
> @@ -459,7 +459,6 @@
>          b2[i] += (W_BM*(b1[i] + b3[i])+4*b2[i]+W_BO)>>W_BS;
>          b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
>      }
> -
>           asm volatile (
>          "jmp 2f                                      \n\t"
>          "1:                                          \n\t"
> @@ -566,7 +565,6 @@
>          b2[i] += (W_BM*(b1[i] + b3[i])+4*b2[i]+W_BO)>>W_BS;
>          b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
>      }
> -
>      asm volatile(
>          "jmp 2f                                      \n\t"
>          "1:                                          \n\t"

What for?

> Index: ffmpeg/AUTHORS
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ ffmpeg/AUTHORS	2007-03-22 01:20:53.000000000 -0400
> Index: ffmpeg/ChangeLog
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ ffmpeg/ChangeLog	2007-03-22 01:21:56.000000000 -0400

Why the heck do you duplicate these files?

> Index: ffmpeg/libavcodec/liba52/Makefile.am
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ ffmpeg/libavcodec/liba52/Makefile.am	2007-03-22 01:20:53.000000000 -0400

This hasn't been updated in a while ...

> Index: ffmpeg/libavcodec/.cvsignore
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ ffmpeg/libavcodec/.cvsignore	2007-03-22 01:20:53.000000000 -0400

Still using CVS?

> Index: ffmpeg/libavcodec/allcodecs.c
> ===================================================================
> --- ffmpeg.orig/libavcodec/allcodecs.c	2007-03-22 01:00:46.000000000 -0400
> +++ ffmpeg/libavcodec/allcodecs.c	2007-03-22 01:20:53.000000000 -0400
> @@ -96,7 +96,9 @@
>      REGISTER_ENCDEC (MJPEG, mjpeg);
>      REGISTER_DECODER(MJPEGB, mjpegb);
>      REGISTER_DECODER(MMVIDEO, mmvideo);
> +#ifdef HAVE_XVMC
>      REGISTER_DECODER(MPEG_XVMC, mpeg_xvmc);
> +#endif

We were glad to get rid of these.  It seems our configure does have a
feature or two more than yours after all ...

> Index: ffmpeg/libswscale/cs_test.c
> ===================================================================
> --- ffmpeg.orig/libswscale/cs_test.c	2007-03-22 01:00:59.000000000 -0400
> +++ ffmpeg/libswscale/cs_test.c	2007-03-22 09:03:57.000000000 -0400
> @@ -23,7 +23,9 @@
>  #include <unistd.h>
>  #include <stdlib.h>
>  #include <inttypes.h>
> +#ifdef HAVE_MALLOC_H
>  #include <malloc.h>
> +#endif
>  
>  #include "swscale.h"
>  #include "rgb2rgb.h"
> @@ -34,6 +36,7 @@
>  
>  #ifdef __APPLE_CC__
>  #define memalign(x,y) malloc(y)
> +#undef malloc
>  #endif

likely acceptable

Diego




More information about the ffmpeg-devel mailing list