Advertisement
Guest User

test case of a gcc issue

a guest
Nov 12th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <stdint.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5.  
  6.  
  7. void f(const uint32_t* image_bgra, int H, int W,
  8.         float* out,
  9.         int margin)
  10. {
  11.  
  12.     const int mu = margin;
  13.     const int md = margin;
  14.     const int mr = margin;
  15.     const int ml = margin;
  16.     //const int ml = 3;
  17.  
  18.     printf("params: H=%d W=%d, ml%d mr%d mu%d md%d\n", H, W, ml, mr, mu, md);
  19.  
  20.     for(int y=0; y<H; y++) {
  21.         for(int x=0; x<W; x++) {
  22.             const int idx = x + W*y;
  23.  
  24.             if ((y < mu)  || (y >= H - md) ||
  25.                     (x < ml)  || (x >= W - mr)) {
  26.  
  27.                 out[idx + H*W*0] = 0.0f;
  28.                 out[idx + H*W*1] = 0.0f;
  29.                 out[idx + H*W*2] = 0.0f;
  30.                 out[idx + H*W*3] = 0.0f;
  31.  
  32.             } else {
  33.                 out[idx + H*W*0] = 1.0;
  34.                 out[idx + H*W*1] = 2.0;
  35.                 out[idx + H*W*2] = 3.0;
  36.                 out[idx + H*W*3] = 4.0;
  37.  
  38.             }
  39.             if (x==0) {
  40.                 printf("out(x = %d ,y = %d, idx = %d , H = %d, W = %d) = %.f.\n",x,y,idx,H,W,out[idx + H*W*0]);
  41.             }
  42.  
  43.         }
  44.     }
  45.  
  46.     for (int y = 0; y < H; y++) {
  47.         if (out[W*y] > 0.0f) {
  48.             printf ("This shouldn't be seen: Line %d, value = %f\n", y, out[W*y]);
  49.         }
  50.     }
  51.  
  52.     return;
  53. }
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. int main ()
  61. {
  62.     const int H = 42;
  63.     const int W = 32;
  64.     const int D = 4;
  65.  
  66.  
  67.  
  68.     float* out2 = (float*) malloc(H * W * D * sizeof(float));
  69.  
  70.  
  71.     f(NULL, H, W,
  72.             out2,
  73.             3);
  74.  
  75.  
  76.     return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement