Update of /cvsroot/playerstage/code/player/server/drivers/camera/compress
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10946/server/drivers/camera/compress

Modified Files:
        .cvsignore cameracompress.cc camerauncompress.cc 
Log Message:
applied Toby's patch to replace fixed-size arrays

Index: .cvsignore
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/camera/compress/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** .cvsignore  17 Sep 2007 02:18:55 -0000      1.2
--- .cvsignore  1 Nov 2007 22:16:18 -0000       1.3
***************
*** 6,7 ****
--- 6,8 ----
  *.lo
  *.a
+ *.loT

Index: cameracompress.cc
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/camera/compress/cameracompress.cc,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** cameracompress.cc   18 Oct 2007 22:33:27 -0000      1.17
--- cameracompress.cc   1 Nov 2007 22:16:18 -0000       1.18
***************
*** 114,118 ****
        
      // scratch for converted data camera data
!     char converted[PLAYER_CAMERA_IMAGE_SIZE];
  
      // Output (compressed) camera data
--- 114,118 ----
        
      // scratch for converted data camera data
!     char *converted;
  
      // Output (compressed) camera data
***************
*** 239,246 ****
  void CameraCompress::ProcessImage(player_camera_data_t & rawdata)
  {
-   size_t size;
    char filename[256];
    char * ptr, * ptr1;
    int i, l;
  
    if ((rawdata.width <= 0) || (rawdata.height <= 0))
--- 239,247 ----
  void CameraCompress::ProcessImage(player_camera_data_t & rawdata)
  {
    char filename[256];
    char * ptr, * ptr1;
    int i, l;
+   char * buffer = NULL;
+   
  
    if ((rawdata.width <= 0) || (rawdata.height <= 0))
***************
*** 269,273 ****
      case 32:
        l = (rawdata.width) * (rawdata.height);
!       ptr = this->converted; 
        ptr1 = (char *)(rawdata.image);
        for (i = 0; i < l; i++)
--- 270,274 ----
      case 32:
        l = (rawdata.width) * (rawdata.height);
!       ptr = buffer = new char[(rawdata.width) * (rawdata.height)*3];
        ptr1 = (char *)(rawdata.image);
        for (i = 0; i < l; i++)
***************
*** 278,282 ****
          ptr += 3; ptr1 += 4;
        }
!       ptr = this->converted;
        break;
      default:
--- 279,283 ----
          ptr += 3; ptr1 += 4;
        }
!       ptr = buffer;
        break;
      default:
***************
*** 284,292 ****
        return;
      }
      this->data.image_count = jpeg_compress( (char*)this->data.image, 
                                              ptr,
                                              rawdata.width, 
                                              rawdata.height,
!                                             PLAYER_CAMERA_IMAGE_SIZE, 
                                              (int)(this->quality*100));
      this->data.width = (rawdata.width);
--- 285,294 ----
        return;
      }
+     this->data.image = new unsigned char [rawdata.width*rawdata.width*3];
      this->data.image_count = jpeg_compress( (char*)this->data.image, 
                                              ptr,
                                              rawdata.width, 
                                              rawdata.height,
!                                             rawdata.width*rawdata.width*3, 
                                              (int)(this->quality*100));
      this->data.width = (rawdata.width);
***************
*** 306,309 ****
--- 308,313 ----
      this->data.image_count = (rawdata.image_count);
    }
+   delete [] buffer;
+   
    if (this->save)
    {
***************
*** 314,320 ****
    }
  
-   size = sizeof(this->data) - sizeof(this->data.image) + 
this->data.image_count;
    
!   Publish(device_addr, PLAYER_MSGTYPE_DATA, PLAYER_CAMERA_DATA_STATE, (void*) 
&this->data, size, &this->camera_time);
    this->valid = !0;
  }
--- 318,325 ----
    }
  
    
!   Publish(device_addr, PLAYER_MSGTYPE_DATA, PLAYER_CAMERA_DATA_STATE, (void*) 
&this->data, 0, &this->camera_time);
!   delete [] this->data.image;
!   this->data.image = NULL;
    this->valid = !0;
  }

Index: camerauncompress.cc
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/camera/compress/camerauncompress.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** camerauncompress.cc 17 Sep 2007 02:18:55 -0000      1.5
--- camerauncompress.cc 1 Nov 2007 22:16:18 -0000       1.6
***************
*** 117,121 ****
        
      // Acquired camera data
!     char converted[PLAYER_CAMERA_IMAGE_SIZE];
  
      // Output (uncompressed) camera data
--- 117,121 ----
        
      // Acquired camera data
!     char *converted;
  
      // Output (uncompressed) camera data
***************
*** 239,250 ****
  void CameraUncompress::ProcessImage(player_camera_data_t & compdata)
  {
- //  size_t size;
    char filename[256];
- 
-   jpeg_decompress( (unsigned char*)this->data.image, 
-                     PLAYER_CAMERA_IMAGE_SIZE,
-                     compdata.image,
-                     compdata.image_count);
- 
    this->data.width = (compdata.width);
    this->data.height = (compdata.height);
--- 239,243 ----
***************
*** 253,256 ****
--- 246,256 ----
    this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
    this->data.compression = PLAYER_CAMERA_COMPRESS_RAW;
+   this->data.image = new unsigned char [this->data.image_count];
+ 
+   jpeg_decompress( (unsigned char*)this->data.image,
+     this->data.image_count,
+     compdata.image,
+     compdata.image_count);
+ 
  
    if (this->save)
***************
*** 262,266 ****
    }
  
!   Publish(device_addr, PLAYER_MSGTYPE_DATA, PLAYER_CAMERA_DATA_STATE, (void*) 
&this->data, sizeof(this->data), &this->camera_time);
! 
  }
--- 262,267 ----
    }
  
!   Publish(device_addr, PLAYER_MSGTYPE_DATA, PLAYER_CAMERA_DATA_STATE, (void*) 
&this->data, 0, &this->camera_time);
!   delete [] this->data.image;
!   this->data.image = NULL;
  }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to