Changeset 1203
- Timestamp:
- 06/10/11 08:42:50 (2 years ago)
- File:
-
- 1 edited
-
trunk/core/edgeoverlay.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/edgeoverlay.c
r1024 r1203 25 25 static unsigned char* smbuf = NULL; 26 26 27 static int slice = 0; // the current slice of the frame we are calculating/drawing28 static int slice_height; // the height of a single slice29 30 static int viewport_ size; // whole viewport size in bytes??31 static int viewport_ width; // screenwidth * 3, width in bytes of one viewport line ??32 static int viewport_ height;27 static int slice = 0; // the current slice of the frame we are calculating/drawing 28 static int slice_height; // the height of a single slice 29 30 static int viewport_byte_width; // width in bytes of one viewport line ?? 31 static int viewport_height; // height of visible / used area of viewport 32 static int viewport_width; // width of visible / used area of viewport (in 3 byte units) 33 33 static int viewport_xoffset; // used when image size != viewport size (e.g. wide screen image on 4:3 LCD) 34 34 static int viewport_yoffset; // used when image size != viewport size (e.g. wide screen image on 4:3 LCD) 35 #if CAM_USES_ASPECT_CORRECTION36 static int viewportw; //nandoide , width of viewport (not necessarily equal to width of screen)37 #endif38 35 39 36 static void get_viewport_size() … … 42 39 // here too to calculate the buffer we need... 43 40 44 #if CAM_USES_ASPECT_CORRECTION//nandoide sept-2009 get the viewport dimensions, not the screen dimensions, on sx200is they aren't the same. 41 #if defined(CAM_USES_ASPECT_CORRECTION) 42 //nandoide sept-2009 get the viewport dimensions, not the screen dimensions, on sx200is they aren't the same. 45 43 viewport_height = vid_get_viewport_height()-EDGE_HMARGIN*2; //don't trace bottom lines 46 viewport w= vid_get_viewport_width();47 viewport_ width = vid_get_viewport_buffer_width() * 3;44 viewport_width = vid_get_viewport_width(); 45 viewport_byte_width = vid_get_viewport_buffer_width() * 3; 48 46 #else 49 47 viewport_height = screen_height;//vid_get_viewport_height(); 50 viewport_width = screen_width * 3; 48 viewport_width = screen_width; 49 viewport_byte_width = screen_width * 3; 51 50 #endif 52 51 … … 54 53 viewport_yoffset = vid_get_viewport_yoffset(); 55 54 56 viewport_size = viewport_height * viewport_width;57 55 slice_height = viewport_height / EDGE_SLICES; 58 59 56 } 60 57 … … 63 60 if(edgebuf == NULL) 64 61 { 65 edgebuf = bv_create(viewport_ size, 1);62 edgebuf = bv_create(viewport_height * viewport_width, 1); 66 63 if (edgebuf != NULL) 67 64 memset(edgebuf->ptr, 0, edgebuf->ptrLen); … … 69 66 if (conf.edge_overlay_filter && (smbuf == NULL)) 70 67 { 71 smbuf = (unsigned char*)malloc(viewport_ width*3);68 smbuf = (unsigned char*)malloc(viewport_byte_width*3); 72 69 if (smbuf != NULL) 73 memset(smbuf, 0, viewport_ width*3);70 memset(smbuf, 0, viewport_byte_width*3); 74 71 else 75 72 { … … 88 85 } 89 86 90 bv_free(edgebuf); 91 edgebuf = NULL; 87 if (edgebuf != NULL) 88 { 89 draw_restore(); // Refresh display to restore Canon OSD 90 bv_free(edgebuf); 91 edgebuf = NULL; 92 } 93 92 94 fsm_state = EDGE_LIVE; 93 95 slice = 0; … … 206 208 } 207 209 208 static void average_filter_row(const unsigned char* ptrh1, // previous row 209 const unsigned char* ptrh2, // current row 210 const unsigned char* ptrh3, // next row 211 unsigned char* smptr ) // write results here 212 { 213 int x; 214 #if CAM_USES_ASPECT_CORRECTION 215 const int x_max = (viewportw + viewport_xoffset - 2) * 3; 216 #else 217 const int x_max = (screen_width + viewport_xoffset - 2) * 3; 218 #endif 219 220 for (x=viewport_xoffset*3+6; x<x_max; x+=6) 210 static void average_filter_row(const unsigned char* ptrh1, // previous row 211 unsigned char* smptr, // write results here 212 int x, int x_max) 213 { 214 const unsigned char* ptrh2 = ptrh1 + viewport_byte_width; // current row 215 const unsigned char* ptrh3 = ptrh2 + viewport_byte_width; // next row 216 217 for (; x<x_max; x+=6) 221 218 { 222 219 *(smptr + x + 1) = (*(ptrh1 + x - 1) + … … 268 265 *(ptrh3 + x + 7)) / 9u; 269 266 } 267 268 // copy 2nd last column to last column to prevent vertical stripe artifact. 269 smptr[x+1] = smptr[x-5]; 270 smptr[x+3] = smptr[x-3]; 271 smptr[x+4] = smptr[x-2]; 272 smptr[x+5] = smptr[x-1]; 270 273 } 271 274 … … 287 290 const int y_max = viewport_yoffset + EDGE_HMARGIN+(slice+1)*slice_height; 288 291 const int x_min = viewport_xoffset*3 + 6; 289 #if CAM_USES_ASPECT_CORRECTION 290 const int x_max = (viewportw + viewport_xoffset - 2) * 3; 291 #else 292 const int x_max = (screen_width + viewport_xoffset - 2) * 3; 293 #endif 294 295 const int vp_width = viewport_width; 292 const int x_max = (viewport_width + viewport_xoffset - 2) * 3; 296 293 297 294 xoffset = 0; … … 322 319 shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL); 323 320 324 ptrh1 = img + (y_min+y-1) * vp_width; 325 ptrh2 = img + (y_min+y ) * vp_width; 326 ptrh3 = img + (y_min+y+1) * vp_width; 327 smptr = smbuf + (y+1) * vp_width; 328 329 average_filter_row(ptrh1, ptrh2, ptrh3, smptr); 321 ptrh1 = img + (y_min+y-1) * viewport_byte_width; 322 smptr = smbuf + (y+1) * viewport_byte_width; 323 324 average_filter_row(ptrh1, smptr, x_min, x_max); 330 325 } 331 326 } … … 344 339 345 340 // Shift 346 memcpy(smbuf+vp_width*0, smbuf+vp_width*1, vp_width); 347 memcpy(smbuf+vp_width*1, smbuf+vp_width*2, vp_width); 341 memcpy(smbuf, smbuf+viewport_byte_width, viewport_byte_width*2); 348 342 349 343 // Filter new line 350 ptrh1 = img + y * vp_width; 351 ptrh2 = img + (y+1) * vp_width; 352 ptrh3 = img + (y+2) * vp_width; 353 smptr = smbuf + 2 * vp_width; 354 average_filter_row(ptrh1, ptrh2, ptrh3, smptr); 355 356 ptrh1 = smbuf + 0 * vp_width; 357 ptrh2 = smbuf + 1 * vp_width; 358 ptrh3 = smbuf + 2 * vp_width; 344 ptrh1 = img + y * viewport_byte_width; 345 smptr = smbuf + 2 * viewport_byte_width; 346 average_filter_row(ptrh1, smptr, x_min, x_max); 347 348 ptrh1 = smbuf; 359 349 } 360 350 else 361 351 { 362 ptrh1 = img + (y-1) * v p_width;363 ptrh2 = img + y * vp_width;364 ptrh3 = img + (y+1) * vp_width;365 }352 ptrh1 = img + (y-1) * viewport_byte_width; 353 } 354 ptrh2 = ptrh1 + viewport_byte_width; 355 ptrh3 = ptrh2 + viewport_byte_width; 366 356 367 357 // Now we do sobel on the current line … … 394 384 if (conv1 + conv2 > conf.edge_overlay_thresh) 395 385 { 396 bv_set(edgebuf, (y-viewport_yoffset-EDGE_HMARGIN)*v p_width + xdiv3, 1);386 bv_set(edgebuf, (y-viewport_yoffset-EDGE_HMARGIN)*viewport_width + xdiv3, 1); 397 387 } 398 388 … … 424 414 if (conv1 + conv2 > conf.edge_overlay_thresh) 425 415 { 426 bv_set(edgebuf, (y-viewport_yoffset-EDGE_HMARGIN)*v p_width + xdiv3+1, 1);416 bv_set(edgebuf, (y-viewport_yoffset-EDGE_HMARGIN)*viewport_width + xdiv3+1, 1); 427 417 } 428 418 } // for x … … 452 442 // shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL); 453 443 // 454 //#if CAM_USES_ASPECT_CORRECTION 455 // for (x=12; x<(viewportw - 4); ++x) 456 //#else 457 // for (x=12; x<(screen_width - 4); ++x) 458 //#endif 444 // for (x=12; x<(viewport_width - 4); ++x) 459 445 // { 460 446 // int bEdge = bv_get(edgebuf, y*viewport_width + x); … … 509 495 const int y_max = viewport_yoffset+EDGE_HMARGIN+viewport_height; 510 496 const int x_min = viewport_xoffset+2; 511 #if CAM_USES_ASPECT_CORRECTION 512 const int x_max = (viewportw + viewport_xoffset - 2); 513 #else 514 const int x_max = (screen_width + viewport_xoffset - 2); 515 #endif 497 const int x_max = (viewport_width + viewport_xoffset - 2); 516 498 517 499 if( !is_buffer_ready() ) return 0; … … 595 577 { 596 578 const int y_max = viewport_height; 597 #if CAM_USES_ASPECT_CORRECTION 598 const int x_max = (viewportw - 2); 599 #else 600 const int x_max = (screen_width - 2); 601 #endif 579 const int x_max = (viewport_width - 2); 602 580 603 581 switch(conf.edge_overlay_pano)
Note: See TracChangeset
for help on using the changeset viewer.