Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. int match(int *x, int *y, int posx, int posy, uint8 *prev, uint8 *curr, int width)
  2. /* Try to find the best match of the 16x16 block located at (idx, idy) of */
  3. /* the current image in the search window of the previous image. The search */
  4. /* window is defined as a 32x32 area in the previous image at the location */
  5. /* centered around the block position (idx, idy). */
  6. /* The motion vector of both x and y components range from -16 to 15 pixels. */
  7. {
  8. //int timer = get_usec_time();
  9. int min_sad, sad, mvx, mvy, down;
  10.  
  11. /* Set the matching error to the largest integer value */
  12. min_sad = INT_MAX;
  13.  
  14. int start = 0;
  15. for (int i=2; i<=BSIZE*2; i+=2){
  16. mvx = start;
  17. mvy = start;
  18. sad = compute_sad(prev, curr, width, posx+start, posy+start, posx, posy, min_sad);
  19. if (sad)
  20. {
  21. min_sad = sad;
  22. *x = mvx, *y = mvy;
  23.  
  24. }
  25. compute_sad_compare_out++;
  26. for(int j=i-1; j>0; j--){
  27. mvy --;
  28. sad = compute_sad(prev, curr, width, posx+mvx, posy+mvy, posx, posy, min_sad);
  29. if (sad)
  30. {
  31. min_sad = sad;
  32. *x = mvx, *y = mvy;
  33. }
  34. compute_sad_compare_out++;
  35. }
  36. for(int j=i-1; j>0; j--){
  37. mvx --;
  38. sad = compute_sad(prev, curr, width, posx+mvx, posy+mvy, posx, posy, min_sad);
  39. if (sad)
  40. {
  41. min_sad = sad;
  42. *x = mvx, *y = mvy;
  43. compute_sad_compare_out++;
  44. }
  45. }
  46. for(int j=i-1; j>0; j--){
  47. mvy ++;
  48. sad = compute_sad(prev, curr, width, posx+mvx, posy+mvy, posx, posy, min_sad);
  49. if (sad)
  50. {
  51. min_sad = sad;
  52. *x = mvx, *y = mvy;
  53. }
  54. compute_sad_compare_out++;
  55. }
  56. for(int j=i-2; j>0; j--){
  57. mvx ++;
  58. sad = compute_sad(prev, curr, width, posx+mvx, posy+mvy, posx, posy, min_sad);
  59. if (sad)
  60. {
  61. min_sad = sad;
  62. *x = mvx, *y = mvy;
  63. }
  64. compute_sad_compare_out++;
  65. }
  66. start ++;
  67. }
  68.  
  69.  
  70. //time_match += (get_usec_time()-timer);
  71. return min_sad;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement