IMG_mad_8x8


Detailed Description


Functions

void IMG_mad_8x8 (const unsigned char *ref_data, const unsigned char *src_data, int pitch, int sx, int sy, unsigned int *match)


Function Documentation

void IMG_mad_8x8 ( const unsigned char *  ref_data,
const unsigned char *  src_data,
int  pitch,
int  sx,
int  sy,
unsigned int *  match 
)

Description:
This routine locates the position in a reference image which most closely matches an 8x8 block from a source image, using the Minimum Absolute Difference metric. Searches over a range that is 'sx' pixels wide and 'sy' pixels tall within a reference image that is 'pitch' pixels wide.
The search is performed in top-to-bottom, left-to-right order, with the earliest match taking precedence in the case of ties.
The match location as well as the Minimum Absolute Difference metric for the match are returned in the 'match' array. The first element contains the packed horizontal and vertical coordinates of the match, with the X coordinate in the upper halfword and the Y coordinate in the lower halfword. The second element contains the MAD value for this match location.
The reference image is an image of width 'pitch'. The mad_8x8 routine searches a (sx,sy) window within the image.
The source image is an 8x8 block of pixels which contain the image block that is being searched for.
The match[] array is where the best match location and MAD value for the best match are stored. The best match position and its absolute difference are returned in match, packed as follows:
                      31             16 15             0                   
                      +----------------+----------------+                  
          match[0]:  |    X offset    |    Y offset    |                  
                      +----------------+----------------+                  
                                                                          
                      31                               0                   
                      +---------------------------------+                  
          match[1]:  |   Minimum Absolute Difference    |                  
                      +---------------------------------+                  
   
Parameters:
ref_data Reference image to search
src_data Source 8x8 image block
pitch Width of reference image
sx Horizontal size of search area
sy Vertical size of search area (must be a multiple of 2)
match Result: match[0] is packed x, y match[1] is MAD value
Assumptions:
  • Src_data and match must be 16-bit aligned
  • The routine is written for Little Endian configuration
  • Two MADS are performed together and hence it is assumed that the vertical dimension is a multiple of 2
Implementation Notes:
The inner loops that perform the 8x8 mads are completely unrolled and the outer two loops are collpaesd together. In addition all source image data is pre-loaded into registers.
The data required for any one row is brought in using non-aligned loads. SUBABS4 and DOTPU4 are used together to do the MAD computation.
To save instructions and fit within an 8 cycle loop, the precise location of a given match is not stored. Rather, the loop iteration that it was encountered on is stored. A short divide loop after the search loop converts this value into X and Y coordinates for the location.
  • This code is compatible with C66x processors (though not optimized)
  • No bank conflicts occur for this kernel
  • No alignment is required for ref_data
  • This code suppresses interrupts for the entire duration of the call
  • This kernel is Little Endian only
Benchmarks:
See IMGLIB_Test_Report.html for cycle and memory information.


Copyright 2012, Texas Instruments Incorporated