Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int match(int *x, int *y, int posx, int posy, uint8 *prev, uint8 *curr, int width)
- /* Try to find the best match of the 16x16 block located at (idx, idy) of */
- /* the current image in the search window of the previous image. The search */
- /* window is defined as a 32x32 area in the previous image at the location */
- /* centered around the block position (idx, idy). */
- /* The motion vector of both x and y components range from -16 to 15 pixels. */
- {
- //int timer = get_usec_time();
- int min_sad, sad, mvx, mvy, down;
- /* Set the matching error to the largest integer value */
- min_sad = INT_MAX;
- int start = 0;
- for (int i=2; i<=BSIZE*2; i+=2){
- mvx = start;
- mvy = start;
- sad = compute_sad(prev, curr, width, posx+start, posy+start, posx, posy, min_sad);
- if (sad)
- {
- min_sad = sad;
- *x = mvx, *y = mvy;
- }
- compute_sad_compare_out++;
- for(int j=i-1; j>0; j--){
- mvy --;
- sad = compute_sad(prev, curr, width, posx+mvx, posy+mvy, posx, posy, min_sad);
- if (sad)
- {
- min_sad = sad;
- *x = mvx, *y = mvy;
- }
- compute_sad_compare_out++;
- }
- for(int j=i-1; j>0; j--){
- mvx --;
- sad = compute_sad(prev, curr, width, posx+mvx, posy+mvy, posx, posy, min_sad);
- if (sad)
- {
- min_sad = sad;
- *x = mvx, *y = mvy;
- compute_sad_compare_out++;
- }
- }
- for(int j=i-1; j>0; j--){
- mvy ++;
- sad = compute_sad(prev, curr, width, posx+mvx, posy+mvy, posx, posy, min_sad);
- if (sad)
- {
- min_sad = sad;
- *x = mvx, *y = mvy;
- }
- compute_sad_compare_out++;
- }
- for(int j=i-2; j>0; j--){
- mvx ++;
- sad = compute_sad(prev, curr, width, posx+mvx, posy+mvy, posx, posy, min_sad);
- if (sad)
- {
- min_sad = sad;
- *x = mvx, *y = mvy;
- }
- compute_sad_compare_out++;
- }
- start ++;
- }
- //time_match += (get_usec_time()-timer);
- return min_sad;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement