IMG_mad_16x16


Detailed Description


Functions

void IMG_mad_16x16 (const unsigned char *restrict refImg, const unsigned char *restrict srcImg, int pitch, int h, int v, unsigned *restrict match)


Function Documentation

void IMG_mad_16x16 ( const unsigned char *restrict  refImg,
const unsigned char *restrict  srcImg,
int  pitch,
int  h,
int  v,
unsigned *restrict  match 
)

Description:
This routine returns the location of the minimum absolute difference between a 16x16 search block and some block in a (h + 16) x (v + 16) search area. h and v are the sizes of the search space for the top left coordinate of the search block. refImg points to the top left pixel of the search area.
  
            (0,0)          (h,0)      (h+16,0)                             
              ;--------------+--------;                                    
              ;    search    |        ;                                    
              ;    space     |        ;                                    
              ;              |        ;        search area                 
              ;--------------+        ;        within reference image      
            (0,v)          (h,v)      ;                                    
              ;                       ;                                    
              ;-----------------------;                                    
            (0, v+16)                 (v+16,h+16)                          
   
The location is returned relative to the above coordinate system as x and y packed in two 16-bit quantities in a 32-bit word:
                  31             16 15             0                      
                  +----------------+----------------+                     
        match[0]:  |       x        |       y        |                     
                  +----------------+----------------+                     
                                                                          
                  31                               0                      
                  +---------------------------------+                     
        match[1]:  |   SAD value at location x, y    |                     
                  +---------------------------------+                     
   

Parameters:
refImg Reference image
srcImg 16x16 block image to look for
pitch Width of reference image
h Horizontal size of search area
v 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:
  • srcImg and refImg do not alias in memory
  • 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 two outer loops are merged, the two inner loops are merged. The inner loop process 2 lines of 2 search locations in parallel. The search is performed in top-to-bottom, left-to-right order, with the earliest match taking precedence in the case of ties. Further use is made of C64x specific instructions such as SUBABS4 and DOTPU4. The SUBABS4 takes the absolute difference on four 8 bit quantities packed into a 32 bit word. The DOTPU4 performs four 8 bit wide multiplies and adds the results together.
  • This code is fully interruptible and fully reentrant
  • This code is compatible with C66x processors (though not optimized)
Benchmarks:
See IMGLIB_Test_Report.html for cycle and memory information.


Copyright 2012, Texas Instruments Incorporated