dslinux/user/pixil/packages/dvdview/dvdview/oldlibgfx/libvideogfx/graphics/motvec .cvsignore Makefile.am blkcmp.hh full.cc full.hh mv.cc mv.hh

amadeus dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:25:54 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/pixil/packages/dvdview/dvdview/oldlibgfx/libvideogfx/graphics/motvec
In directory antilope:/tmp/cvs-serv11916/packages/dvdview/dvdview/oldlibgfx/libvideogfx/graphics/motvec

Added Files:
	.cvsignore Makefile.am blkcmp.hh full.cc full.hh mv.cc mv.hh 
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it

--- NEW FILE: mv.hh ---
/*********************************************************************
  mv.hh

  purpose:

  notes:

  to do:

  author(s):
   - Dirk Farin, farin at ti.uni-mannheim.de
     University Mannheim, Dept. Circuitry and Simulation
     B 6,26 EG, room 0.10 / D-68131 Mannheim / Germany

  modifications:
   25/May/99 - Dirk Farin
     - first implementation
 *********************************************************************/

#ifndef LIBVIDEOGFX_GRAPHICS_MOTVEC_MV_HH
#define LIBVIDEOGFX_GRAPHICS_MOTVEC_MV_HH

#include "libvideogfx/graphics/basic/bitmap.hh"


struct FullSearchData
{
  Bitmap<int> error;
};

struct MotVec
{
  int h,v;
};

#endif

--- NEW FILE: .cvsignore ---
Makefile
Makefile.in
*.lo
_libs
.libs
.deps
libvideogfx-graphics-motvec.la

--- NEW FILE: full.cc ---
/*
 *  full.cc
 */

#include <iostream.h>

#include "full.hh"


inline int Abs(int a)
{
  if (a<0) return -a; else return a;
}

void CalcFullSearch(const Bitmap<Pixel>& img1,const Bitmap<Pixel>& img2,
		    Bitmap<FullSearchData>* searchdata,
		    Bitmap<MotVec>* motiondata,
		    int hblksize,int vblksize,int hrange,int vrange)
{
  assert(img1.AskWidth()  == img2.AskWidth());
  assert(img1.AskHeight() == img2.AskHeight());

  int width  = img1.AskWidth();
  int height = img1.AskHeight();

  int hsize = (img1.AskWidth() +hblksize-1)/hblksize;
  int vsize = (img1.AskHeight()+vblksize-1)/vblksize;

  FullSearchData*const* fsdptr = NULL;
  MotVec*const* mvptr = NULL;
  if (searchdata) { searchdata->Create(hsize,vsize); fsdptr = searchdata->AskFrame(); }
  if (motiondata) { motiondata->Create(hsize,vsize); mvptr = motiondata->AskFrame(); }

  const Pixel*const* i1 = img1.AskFrame_const();
  const Pixel*const* i2 = img2.AskFrame_const();

  for (int y=0;y<vsize;y++)
    { cout << '.'; cout.flush();
    for (int x=0;x<hsize;x++)
      {
	int*const* fsderr = NULL;
	if (fsdptr)
	  {
	    FullSearchData& fsd = fsdptr[y][x];
	    fsd.error.Create(2*hrange+1,2*vrange+1);
	    fsderr = fsd.error.AskFrame();
	  }

	int x0 = x*hblksize;
	int y0 = y*vblksize;

	int besterror = 0x7FFFFFFF;
	int besth=0,bestv=0;

	for (int dy=-vrange;dy<=vrange;dy++)
	  for (int dx=-hrange;dx<=hrange;dx++)
	    {
	      int error;

	      if (x0+dx < 0 || y0+dy < 0 ||
		  x0+hblksize+dx > width ||
		  y0+vblksize+dy > height)
		{
		  error = 0x7FFFFFFF;
		}
	      else
		{
		  error = 0;
		  for (int yy=0;yy<vblksize;yy++)
		    for (int xx=0;xx<hblksize;xx++)
		      error += Abs(i1[y0+yy][x0+xx] - i2[y0+yy+dy][x0+xx+dx]);
		}

	      if ((error<besterror) ||
		  (error==besterror && Abs(dy)+Abs(dx) < Abs(besth)+Abs(bestv)))
		{
		  besterror = error;
		  besth = dx;
		  bestv = dy;
		}

	      if (fsderr) fsderr[dy+vrange][dx+hrange] = error;
	    }

	if (mvptr)
	  {
	    mvptr[y][x].h = besth;
	    mvptr[y][x].v = bestv;
	  }
      }
    }
}

--- NEW FILE: Makefile.am ---
## Makefile.am for libvideogfx/libvideogfx/graphics/motvec

noinst_LTLIBRARIES = libvideogfx-graphics-motvec.la

libvideogfx_graphics_motvec_la_SOURCES = \
	blkcmp.hh	\
	full.cc		\
	full.hh		\
	mv.cc		\
	mv.hh

INCLUDES = \
	-I$(top_srcdir)

.PHONY: files

files:
	@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
	  echo $$p; \
	done

--- NEW FILE: full.hh ---
/*********************************************************************
  full.hh

  purpose:

  notes:

  to do:

  author(s):
   - Dirk Farin, farin at ti.uni-mannheim.de
     University Mannheim, Dept. Circuitry and Simulation
     B 6,26 EG, room 0.10 / D-68131 Mannheim / Germany

  modifications:
   25/May/99 - Dirk Farin
     - first implementation
 *********************************************************************/

#ifndef LIBVIDEOGFX_GRAPHICS_MOTVEC_FULL_HH
#define LIBVIDEOGFX_GRAPHICS_MOTVEC_FULL_HH

#include "libvideogfx/graphics/basic/bitmap.hh"
#include "libvideogfx/graphics/motvec/mv.hh"


void CalcFullSearch(const Bitmap<Pixel>& img1,const Bitmap<Pixel>& img2,
		    Bitmap<FullSearchData>* searchdata,
		    Bitmap<MotVec>* motiondata,
		    int hblksize,int vblksize,int hrange,int vrange);

#endif

--- NEW FILE: mv.cc ---
/*
 *  mv.cc
 */

#include "mv.hh"


template class Bitmap<int>;
template class Bitmap<MotVec>;
template class Bitmap<FullSearchData>;


#include "libvideogfx/graphics/basic/bitmap.cc"

--- NEW FILE: blkcmp.hh ---
/*********************************************************************
  blkcmp.hh

  purpose:
    Block-compare code including KNI (MMX2) instruction set optimized
    version.

  notes:
    !!! Don't forget to call EMMS() before using any floating-point
    arithmetic when using the MMX-version !!!

  to do:

  author(s):
   - Dirk Farin, farin at ti.uni-mannheim.de
     University Mannheim, Dept. Circuitry and Simulation
     B 6,26 EG, room 0.10 / D-68131 Mannheim / Germany

  modifications:
   11/Jul/2000 - Dirk Farin
     - first implementation
 *********************************************************************/

#ifndef LIBVIDEOGFX_GRAPHICS_MOTVEC_BLKCMP_KNI_HH
#define LIBVIDEOGFX_GRAPHICS_MOTVEC_BLKCMP_KNI_HH

#include "libvideogfx/graphics/basic/bitmap.hh"


#if ENABLE_MMX
inline int ComputeSAD_w16(const Pixel*const* blkrows_1,int h0_1,
			  const Pixel*const* blkrows_2,int h0_2,
			  int blk_height,
			  int max_error_threshold)
{
  volatile uint32 error;

  __asm__
    (
     "pxor %mm0,%mm0\n\t"
     );

  for (int dv=0; dv<blk_height; dv++) {
    const Pixel*const p1 = &blkrows_1[dv][h0_1];
    const Pixel*const p2 = &blkrows_2[dv][h0_2];

    __asm__ __volatile__ 
      (
       "movq   (%0),%%mm1\n\t"
       "psadbw (%1),%%mm1\n\t"
       "paddw  %%mm1,%%mm0\n\t"
	 
       "movq   8(%0),%%mm2\n\t"
       "psadbw 8(%1),%%mm2\n\t"
       "paddw  %%mm2,%%mm0\n\t"

       "movd   %%mm0,(%2)\n\t"

       : : "r" (p1), "r" (p2), "r" (&error)
       );

    if (error>max_error_threshold)
      return error+1;
  }

  return error;
}

inline void EMMS()
{
  __asm__
    (
     "emms\n\t"
     );
}
#else
inline int ComputeSAD_w16(const Pixel*const* blkrows_1,int h0_1,
			  const Pixel*const* blkrows_2,int h0_2,
			  int blk_height,
			  int max_error_threshold)
{
  uint32 error=0;

  for (int dv=0; dv<blk_height; dv++) {
    const Pixel* p1 = &blkrows_1[dv][h0_1];
    const Pixel* p2 = &blkrows_2[dv][h0_2];

    for (int dh=0; dh<16; dh+=4) {
      int diff1 = abs(p1[0]-p2[0]);
      int diff2 = abs(p1[1]-p2[1]);
      int diff3 = abs(p1[2]-p2[2]);
      int diff4 = abs(p1[3]-p2[3]);
      diff1 += diff2;
      diff3 += diff4;
      diff1 += diff3;
      error += diff1;
      p1 += 4;
      p2 += 4;
    }

    if (error>max_error_threshold)
      return error+1;
  }

  return error;
}

inline void EMMS() { }
#endif

#endif




More information about the dslinux-commit mailing list