Changeset 228

Show
Ignore:
Timestamp:
04/23/06 23:58:47 (3 years ago)
Author:
goodea
Message:

perfect

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/hal/lpc2106-cmucam3/cc3.c

    r214 r228  
    277277    _cc3_seek_left (); 
    278278 
    279     if (cc3_g_current_frame.coi == CC3_ALL) { 
     279    switch (cc3_g_current_frame.coi) { 
     280    case CC3_ALL: 
     281      _cc3_second_green_valid = false; 
    280282      for (j = 0; j < width; j++) { 
    281283        uint8_t *p = ((uint8_t *) mem) + 
     
    283285        _cc3_pixbuf_read_pixel (p, p - 3, off0, off1, off2); 
    284286 
    285         // advance by x_step, but don't go over the edge 
    286         if (cc3_g_current_frame.x_step == 1) { 
    287           x++; 
    288         } else if (cc3_g_current_frame.x_step + x  
    289                    >= cc3_g_current_frame.x1) { 
    290           //printf("outside the window\n"); 
    291           _cc3_pixbuf_skip_pixels ((cc3_g_current_frame.raw_width - x - 1) / 2); 
    292           // and we're done with this row 
     287        // advance by x_step 
     288        x += cc3_g_current_frame.x_step; 
     289        _cc3_pixbuf_skip_pixels ((cc3_g_current_frame.x_step - 1) / 2); 
     290      } 
     291 
     292      break; 
     293 
     294    case CC3_RED: 
     295      for (j = 0; j < width; j++) { 
     296        uint8_t *p = ((uint8_t *) mem) + (r * width + j); 
     297 
     298        if ((j & 0x1) == 0 || cc3_g_current_frame.x_step > 1) { 
     299          // read 
     300          _cc3_pixbuf_skip_subpixel (); 
     301          *p = _cc3_pixbuf_read_subpixel (); 
     302          _cc3_pixbuf_skip_subpixel (); 
     303          _cc3_pixbuf_skip_subpixel (); 
    293304        } else { 
    294           //printf("inside the window\n"); 
    295           _cc3_pixbuf_skip_pixels ((cc3_g_current_frame.x_step - 1) / 2); 
    296           x += cc3_g_current_frame.x_step; 
     305          *p = *(p - 1); 
    297306        } 
     307 
     308        x += cc3_g_current_frame.x_step; 
     309        _cc3_pixbuf_skip_pixels ((cc3_g_current_frame.x_step - 1) / 2); 
    298310      } 
     311      break; 
     312 
     313    case CC3_GREEN: 
     314      for (j = 0; j < width; j++) { 
     315        uint8_t *p = ((uint8_t *) mem) + (r * width + j); 
     316 
     317        if ((j & 0x1) == 0 || cc3_g_current_frame.x_step > 1) { 
     318          // read 
     319          *p = _cc3_pixbuf_read_subpixel (); 
     320          _cc3_pixbuf_skip_subpixel (); 
     321          _cc3_second_green = _cc3_pixbuf_read_subpixel (); 
     322          _cc3_pixbuf_skip_subpixel (); 
     323        } else { 
     324          *p = _cc3_second_green; 
     325        } 
     326 
     327        x += cc3_g_current_frame.x_step; 
     328        _cc3_pixbuf_skip_pixels ((cc3_g_current_frame.x_step - 1) / 2); 
     329      } 
     330      break; 
     331 
     332    case CC3_BLUE: 
     333      for (j = 0; j < width; j++) { 
     334        uint8_t *p = ((uint8_t *) mem) + (r * width + j); 
     335 
     336        if ((j & 0x1) == 0 || cc3_g_current_frame.x_step > 1) { 
     337          // read 
     338          _cc3_pixbuf_skip_subpixel (); 
     339          _cc3_pixbuf_skip_subpixel (); 
     340          _cc3_pixbuf_skip_subpixel (); 
     341          *p = _cc3_pixbuf_read_subpixel (); 
     342        } else { 
     343          *p = *(p - 1); 
     344        } 
     345 
     346        x += cc3_g_current_frame.x_step; 
     347        _cc3_pixbuf_skip_pixels ((cc3_g_current_frame.x_step - 1) / 2); 
     348      } 
     349      break; 
    299350    } 
    300     else { 
    301       // we are just reading 1 channel 
    302       // FIXME 
    303     } 
    304  
    305  
    306     // advance by y_step, but don't go over the edge 
    307     if (cc3_g_current_frame.y_step == 1) { 
    308       cc3_g_current_frame.y_loc++; 
    309     } else if (cc3_g_current_frame.y_step + cc3_g_current_frame.y_loc 
    310                >= cc3_g_current_frame.y1) { 
    311       // we're done 
    312       cc3_g_current_frame.y_loc += cc3_g_current_frame.y_step; 
    313     } else { 
    314       _cc3_pixbuf_skip_pixels ((cc3_g_current_frame.y_step - 1)  
    315                                * cc3_g_current_frame.raw_width / 2); 
    316       cc3_g_current_frame.y_loc += cc3_g_current_frame.y_step; 
    317     } 
     351    _cc3_pixbuf_skip_pixels ((cc3_g_current_frame.raw_width - x) / 2); 
     352 
     353 
     354    // advance by y_step 
     355    _cc3_pixbuf_skip_pixels ((cc3_g_current_frame.y_step - 1) * cc3_g_current_frame.raw_width / 2); 
     356    cc3_g_current_frame.y_loc += cc3_g_current_frame.y_step; 
    318357  } 
    319358  return rows; 
     
    356395  if (x0 < 0) { 
    357396    x0 = 0; 
     397  } 
     398  if ((x0 & 0x1) == 1) { 
     399    x0++;          // x0 must be even! 
    358400  } 
    359401  if (y0 < 0) { 
     
    415457  } 
    416458 
    417   // only allow even subsampling (or 1) 
     459  // only allow even subsampling (or 1) for x 
    418460  if (x_step != 1 && x_step % 2 != 0) { 
    419461    x_step++; 
    420462    result = 0; 
    421463  } 
    422   if (y_step != 1 && y_step % 2 != 0) { 
    423     y_step++; 
    424     result = 0; 
    425   } 
    426  
    427464 
    428465  cc3_g_current_frame.x_step = x_step;