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

Modified Files:
        camera1394.cc 
Log Message:
applied patches 
[ 1892298 ] camera1394: pass messages without copy
[ 1891487 ] allow message publication without copy


Index: camera1394.cc
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/camera/1394/camera1394.cc,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** camera1394.cc       30 Jan 2008 07:00:52 -0000      1.39
--- camera1394.cc       15 Feb 2008 08:16:48 -0000      1.40
***************
*** 356,363 ****
  
    // Capture timestamp
!   private: struct timeval frameTime;
    
    // Data to send to server
!   private: player_camera_data_t data;
  
    // Bayer Colour Conversion
--- 356,363 ----
  
    // Capture timestamp
!   private: double frameTime;
    
    // Data to send to server
!   private: player_camera_data_t *data;
  
    // Bayer Colour Conversion
***************
*** 687,691 ****
        break;
    }
-   this->data.compression = PLAYER_CAMERA_COMPRESS_RAW;
    
    return;
--- 687,690 ----
***************
*** 743,747 ****
  int Camera1394::Setup()
  {
!   memset(&(this->data), 0, sizeof(this->data));
  
  #if LIBDC1394_VERSION == 0200
--- 742,746 ----
  int Camera1394::Setup()
  {
!   this->data = 0;
  
  #if LIBDC1394_VERSION == 0200
***************
*** 1112,1118 ****
      this->GrabFrame();
  
-     // Write data to server
-     this->RefreshData();
- 
      // this should go or be replaced
      // Save frames; must be done after writedata (which will byteswap)
--- 1111,1114 ----
***************
*** 1123,1126 ****
--- 1119,1126 ----
        this->SaveFrame(filename);
      }
+ 
+     // Write data to server
+     this->RefreshData();
+ 
      /*
        gettimeofday(&now,NULL);
***************
*** 1197,1204 ****
--- 1197,1206 ----
    }
  
+   this->data = (player_camera_data_t *)malloc(sizeof(*this->data));
    unsigned int frame_width;
    unsigned int frame_height;
    uint8_t * capture_buffer;
  #if LIBDC1394_VERSION == 0200
+   frameTime = frame->timestamp/1.e-6;
    frame_width = frame->size[0];
    frame_height = frame->size[1];
***************
*** 1213,1232 ****
      frameSize = frame_width * frame_height;
    
-   
-   //delete [] this->data.image;
-   //this->data.image = NULL;
-   unsigned int old_image_count = this->data.image_count;
    switch (this->mode)
    {
    case MODE_320x240_YUV422:
    case MODE_640x480_YUV422:
!     this->data.bpp = 24;
!     this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
!     this->data.image_count = this->frameSize;
!     if(old_image_count < this->data.image_count)
!         this->data.image = new uint8_t [this->data.image_count];
!     this->data.width = frame_width;
!     this->data.height = frame_height;
!     uyvy2rgb(capture_buffer, this->data.image, (frame_width) * 
(frame_height));
      break;
    case MODE_1024x768_YUV422:
--- 1215,1229 ----
      frameSize = frame_width * frame_height;
    
    switch (this->mode)
    {
    case MODE_320x240_YUV422:
    case MODE_640x480_YUV422:
!     this->data->bpp = 24;
!     this->data->format = PLAYER_CAMERA_FORMAT_RGB888;
!     this->data->image_count = this->frameSize;
!     this->data->image = (uint8_t*) malloc(this->data->image_count);
!     this->data->width = frame_width;
!     this->data->height = frame_height;
!     uyvy2rgb(capture_buffer, this->data->image, (frame_width) * 
(frame_height));
      break;
    case MODE_1024x768_YUV422:
***************
*** 1234,1251 ****
      if (resized == NULL)
        resized = new uint8_t [1280 * 960 * 3];
!     this->data.bpp = 24;
!     this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
!     this->data.image_count = this->frameSize;
!     if(old_image_count < this->data.image_count)
!         this->data.image = new uint8_t [this->data.image_count];
!     this->data.width = frame_width / 2;
!     this->data.height = frame_height / 2;
!     assert(this->data.image_count <= sizeof(this->data.image));
      uyvy2rgb(capture_buffer, this->resized, (frame_width) * (frame_height));
      ptr1 = this->resized;
!     ptr2 = this->data.image;
!     for (f = 0; f < (this->data.height); f++)
      {
!       for (c = 0; c < (this->data.width); c++)
        {
        ptr2[0] = ptr1[0];
--- 1231,1247 ----
      if (resized == NULL)
        resized = new uint8_t [1280 * 960 * 3];
!     this->data->bpp = 24;
!     this->data->format = PLAYER_CAMERA_FORMAT_RGB888;
!     this->data->image_count = this->frameSize;
!     this->data->image = (uint8_t *) malloc(this->data->image_count);
!     this->data->width = frame_width / 2;
!     this->data->height = frame_height / 2;
!     assert(this->data->image_count <= sizeof(this->data->image));
      uyvy2rgb(capture_buffer, this->resized, (frame_width) * (frame_height));
      ptr1 = this->resized;
!     ptr2 = this->data->image;
!     for (f = 0; f < (this->data->height); f++)
      {
!       for (c = 0; c < (this->data->width); c++)
        {
        ptr2[0] = ptr1[0];
***************
*** 1261,1278 ****
      if (resized == NULL)
        resized = new uint8_t [1280 * 960 * 3];
!     this->data.bpp = 24;
!     this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
!     this->data.image_count = this->frameSize;
!     if(old_image_count < this->data.image_count)
!         this->data.image = new uint8_t [this->data.image_count];
!     this->data.width = 600;
!     this->data.height = 450;
      uyvy2rgb(capture_buffer, this->resized, (frame_width) * (frame_height));
      ptr1 = this->resized;
!     ptr2 = this->data.image;
      i = 3; j = 3;
!     for (f = 0; f < (this->data.height); f++)
      {
!       for (c = 0; c < (this->data.width); c++)
        {
        ptr2[0] = ptr1[0];
--- 1257,1273 ----
      if (resized == NULL)
        resized = new uint8_t [1280 * 960 * 3];
!     this->data->bpp = 24;
!     this->data->format = PLAYER_CAMERA_FORMAT_RGB888;
!     this->data->image_count = this->frameSize;
!     this->data->image = (uint8_t *) malloc(this->data->image_count);
!     this->data->width = 600;
!     this->data->height = 450;
      uyvy2rgb(capture_buffer, this->resized, (frame_width) * (frame_height));
      ptr1 = this->resized;
!     ptr2 = this->data->image;
      i = 3; j = 3;
!     for (f = 0; f < (this->data->height); f++)
      {
!       for (c = 0; c < (this->data->width); c++)
        {
        ptr2[0] = ptr1[0];
***************
*** 1289,1300 ****
      break;  
    case MODE_640x480_RGB:
!     this->data.bpp = 24;
!     this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
!     this->data.image_count = this->frameSize;
!     if(old_image_count < this->data.image_count)
!         this->data.image = new uint8_t [this->data.image_count];
!     this->data.width = frame_width;
!     this->data.height = frame_height;
!     memcpy(this->data.image, capture_buffer, this->data.image_count);
      break;
    case MODE_640x480_MONO:
--- 1284,1294 ----
      break;  
    case MODE_640x480_RGB:
!     this->data->bpp = 24;
!     this->data->format = PLAYER_CAMERA_FORMAT_RGB888;
!     this->data->image_count = this->frameSize;
!     this->data->image = (uint8_t *)malloc(this->data->image_count);
!     this->data->width = frame_width;
!     this->data->height = frame_height;
!     memcpy(this->data->image, capture_buffer, this->data->image_count);
      break;
    case MODE_640x480_MONO:
***************
*** 1305,1337 ****
      if (!DoBayerConversion)
      {
!       this->data.bpp = 8;
!       this->data.format = PLAYER_CAMERA_FORMAT_MONO8;
!       this->data.image_count = this->frameSize;
!       if(old_image_count < this->data.image_count)
!           this->data.image = new uint8_t [this->data.image_count];
!       this->data.width = frame_width;
!       this->data.height = frame_height;
!       memcpy(this->data.image, capture_buffer, this->data.image_count);
      } 
      else
      {
!       this->data.bpp = 24;
!       this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
!       dst = this->data.image;
        switch (this->BayerMethod)
        {
        case BAYER_DECODING_DOWNSAMPLE:
          // quarter of the image but 3 bytes per pixel
!       this->data.image_count = this->frameSize/4*3;
!         if(old_image_count < this->data.image_count)
!             this->data.image = new uint8_t [this->data.image_count];
!       BayerDownsample(capture_buffer, this->data.image,
                                        frame_width/2, frame_height/2,
                                        (bayer_pattern_t)this->BayerPattern);
        break;
        case BAYER_DECODING_NEAREST:
!         this->data.image_count = this->frameSize * 3;
!         if(old_image_count < this->data.image_count)
!             this->data.image = new uint8_t [this->data.image_count];
          BayerNearestNeighbor(capture_buffer, dst,
                                        frame_width, frame_height,
--- 1299,1328 ----
      if (!DoBayerConversion)
      {
!       this->data->bpp = 8;
!       this->data->format = PLAYER_CAMERA_FORMAT_MONO8;
!       this->data->image_count = this->frameSize;
!       this->data->image = (uint8_t*) malloc(this->data->image_count);
!       this->data->width = frame_width;
!       this->data->height = frame_height;
!       memcpy(this->data->image, capture_buffer, this->data->image_count);
      } 
      else
      {
!       this->data->bpp = 24;
!       this->data->format = PLAYER_CAMERA_FORMAT_RGB888;
!       dst = this->data->image;
        switch (this->BayerMethod)
        {
        case BAYER_DECODING_DOWNSAMPLE:
          // quarter of the image but 3 bytes per pixel
!       this->data->image_count = this->frameSize/4*3;
!     this->data->image = (uint8_t *) malloc(this->data->image_count);
!       BayerDownsample(capture_buffer, this->data->image,
                                        frame_width/2, frame_height/2,
                                        (bayer_pattern_t)this->BayerPattern);
        break;
        case BAYER_DECODING_NEAREST:
!         this->data->image_count = this->frameSize * 3;
!         this->data->image = (uint8_t *) malloc(this->data->image_count);
          BayerNearestNeighbor(capture_buffer, dst,
                                        frame_width, frame_height,
***************
*** 1339,1345 ****
        break;
        case BAYER_DECODING_EDGE_SENSE:
!         this->data.image_count = this->frameSize * 3;
!         if(old_image_count < this->data.image_count)
!             this->data.image = new uint8_t [this->data.image_count];
          
        BayerEdgeSense(capture_buffer, dst,
--- 1330,1335 ----
        break;
        case BAYER_DECODING_EDGE_SENSE:
!         this->data->image_count = this->frameSize * 3;
!         this->data->image = (uint8_t *) malloc(this->data->image_count);
          
        BayerEdgeSense(capture_buffer, dst,
***************
*** 1353,1363 ****
        if (this->BayerMethod != BAYER_DECODING_DOWNSAMPLE)
        {
!         this->data.width = frame_width;
!         this->data.height = frame_height;
        } 
        else
        {    //image is half the size of grabbed frame
!         this->data.width = frame_width/2;
!         this->data.height = frame_height/2;
        }
      }
--- 1343,1353 ----
        if (this->BayerMethod != BAYER_DECODING_DOWNSAMPLE)
        {
!         this->data->width = frame_width;
!         this->data->height = frame_height;
        } 
        else
        {    //image is half the size of grabbed frame
!         this->data->width = frame_width/2;
!         this->data->height = frame_height/2;
        }
      }
***************
*** 1373,1376 ****
--- 1363,1367 ----
  #endif
  
+   this->data->compression = PLAYER_CAMERA_COMPRESS_RAW;
    return 0;
  }
***************
*** 1382,1387 ****
    Publish(this->device_addr, 
            PLAYER_MSGTYPE_DATA, PLAYER_CAMERA_DATA_STATE,
!           reinterpret_cast<void*>(&this->data));  
!   
    return;
  }
--- 1373,1382 ----
    Publish(this->device_addr, 
            PLAYER_MSGTYPE_DATA, PLAYER_CAMERA_DATA_STATE,
!           reinterpret_cast<void*>(this->data),
! #if LIBDC1394_VERSION == 0200
!           0, &this->frameTime, false);  
! #else
!           0, 0, false);
! #endif  
    return;
  }
***************
*** 1400,1412 ****
    }
  
!   switch (this->data.format)
    {
      case PLAYER_CAMERA_FORMAT_MONO8:
!       fprintf(fp,"P5\n%u %u\n255\n", this->data.width, this->data.height);
!       fwrite((unsigned char*)this->data.image, 1, this->data.image_count, fp);
        break;
      case PLAYER_CAMERA_FORMAT_RGB888:
!       fprintf(fp,"P6\n%u %u\n255\n", this->data.width, this->data.height);
!       fwrite((unsigned char*)this->data.image, 1, this->data.image_count, fp);
        break;
      default:
--- 1395,1407 ----
    }
  
!   switch (this->data->format)
    {
      case PLAYER_CAMERA_FORMAT_MONO8:
!       fprintf(fp,"P5\n%u %u\n255\n", this->data->width, this->data->height);
!       fwrite((unsigned char*)this->data->image, 1, this->data->image_count, 
fp);
        break;
      case PLAYER_CAMERA_FORMAT_RGB888:
!       fprintf(fp,"P6\n%u %u\n255\n", this->data->width, this->data->height);
!       fwrite((unsigned char*)this->data->image, 1, this->data->image_count, 
fp);
        break;
      default:


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to