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

Modified Files:
        cameracompress.cc 
Log Message:
applied patches 1825568 and 1826743 fixing some issues with recent updates.

Index: cameracompress.cc
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/camera/compress/cameracompress.cc,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** cameracompress.cc   1 Nov 2007 22:16:18 -0000       1.18
--- cameracompress.cc   8 Nov 2007 04:23:26 -0000       1.19
***************
*** 77,80 ****
--- 77,81 ----
  #include <stdlib.h>
  #include <unistd.h>
+ #include <stddef.h>
  #include <stdlib.h>       // for atoi(3)
  #include <netinet/in.h>   // for htons(3)
***************
*** 112,122 ****
      double camera_time;
      bool camera_subscribed;
-       
-     // scratch for converted data camera data
-     char *converted;
  
      // Output (compressed) camera data
      private: player_camera_data_t data;
-     private: int valid;
  
      // Image quality for JPEG compression
--- 113,119 ----
***************
*** 142,145 ****
--- 139,143 ----
    : Driver(cf, section, true, PLAYER_MSGQUEUE_DEFAULT_MAXLEN, 
PLAYER_CAMERA_CODE)
  {
+   this->data.image = NULL;
    this->frameno = 0;
  
***************
*** 156,160 ****
    this->save = cf->ReadInt(section,"save",0);
    this->quality = cf->ReadFloat(section, "image_quality", 0.8);
-   this->valid = 0;
  
    return;
--- 154,157 ----
***************
*** 163,167 ****
  int CameraCompress::Setup()
  {
!   // Subscribe to the laser.
    if(Device::MatchDeviceAddress(this->camera_id, this->device_addr))
    {
--- 160,164 ----
  int CameraCompress::Setup()
  {
!   // Subscribe to the camera.
    if(Device::MatchDeviceAddress(this->camera_id, this->device_addr))
    {
***************
*** 192,195 ****
--- 189,198 ----
    
    camera->Unsubscribe(InQueue);
+   
+   if (this->data.image)
+   {
+     delete []this->data.image;
+     this->data.image = NULL;
+   }
  
    return 0;
***************
*** 208,218 ****
      assert(hdr->size >= sizeof(player_camera_data_t));
      player_camera_data_t * recv = reinterpret_cast<player_camera_data_t * > 
(data);
-     /* now we can deal with already compressed camera images
-     if (recv->compression != PLAYER_CAMERA_COMPRESS_RAW)
-     {
-       PLAYER_WARN("compressing already compressed camera images (not good)");
-       return -1;
-     }
-     */
      ProcessImage(*recv);
      return 0;
--- 211,214 ----
***************
*** 240,251 ****
  {
    char filename[256];
!   char * ptr, * ptr1;
    int i, l;
!   char * buffer = NULL;
    
  
    if ((rawdata.width <= 0) || (rawdata.height <= 0))
    {
!     if (!(this->valid)) return;
    } else if (rawdata.compression == PLAYER_CAMERA_COMPRESS_RAW)
    {
--- 236,247 ----
  {
    char filename[256];
!   unsigned char * ptr, * ptr1;
    int i, l;
!   unsigned char * buffer = NULL;
    
  
    if ((rawdata.width <= 0) || (rawdata.height <= 0))
    {
!     if (!(this->data.image)) return;
    } else if (rawdata.compression == PLAYER_CAMERA_COMPRESS_RAW)
    {
***************
*** 254,259 ****
      case 8:
        l = (rawdata.width) * (rawdata.height);
!       ptr = this->converted; 
!       ptr1 = (char *)(rawdata.image);
        for (i = 0; i < l; i++)
        {
--- 250,256 ----
      case 8:
        l = (rawdata.width) * (rawdata.height);
!       ptr = buffer = new unsigned char[(rawdata.width) * (rawdata.height) * 
3];
!       assert(buffer);
!       ptr1 = (unsigned char *)(rawdata.image);
        for (i = 0; i < l; i++)
        {
***************
*** 263,275 ****
          ptr += 3; ptr1++;
        }
!       ptr = this->converted;
        break;
      case 24:
!       ptr = (char *)(rawdata.image);
        break;
      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++)
        {
--- 260,273 ----
          ptr += 3; ptr1++;
        }
!       ptr = buffer;
        break;
      case 24:
!       ptr = (unsigned char *)(rawdata.image);
        break;
      case 32:
        l = (rawdata.width) * (rawdata.height);
!       ptr = buffer = new unsigned char[(rawdata.width) * (rawdata.height) * 
3];
!       assert(buffer);
!       ptr1 = (unsigned char *)(rawdata.image);
        for (i = 0; i < l; i++)
        {
***************
*** 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);
--- 283,294 ----
        return;
      }
!     if (this->data.image) delete []this->data.image;
!     this->data.image = new unsigned char[(rawdata.width) * (rawdata.height) * 
3];
!     assert(this->data.image);
!     this->data.image_count = jpeg_compress( (char *)(this->data.image),
!                                             (char *)ptr,
!                                             rawdata.width,
                                              rawdata.height,
!                                             (rawdata.width) * 
(rawdata.height) * 3,
                                              (int)(this->quality*100));
      this->data.width = (rawdata.width);
***************
*** 308,312 ****
      this->data.image_count = (rawdata.image_count);
    }
!   delete [] buffer;
    
    if (this->save)
--- 308,313 ----
      this->data.image_count = (rawdata.image_count);
    }
!   if (buffer) delete []buffer;
!   buffer = NULL;
    
    if (this->save)
***************
*** 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;
  }
--- 319,323 ----
    }
  
    Publish(device_addr, PLAYER_MSGTYPE_DATA, PLAYER_CAMERA_DATA_STATE, (void*) 
&this->data, 0, &this->camera_time);
!   // don't delete anything here! this->data.image is required and is deleted 
somewhere else
  }


-------------------------------------------------------------------------
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