Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Dec 1995 10:05:38 PST
From:      Ron Frederick <frederic@parc.xerox.com>
To:        Luigi Rizzo <luigi@labinfo.iet.unipi.it>
Cc:        multimedia@star-gate.com, hackers@freebsd.org
Subject:   Re: nv and cuseeme mode 
Message-ID:  <95Dec10.100553pst.16136@ecco.parc.xerox.com>
In-Reply-To: Your message of "Sun, 10 Dec 95 09:40:04 PST." <199512101740.SAA02970@labinfo.iet.unipi.it> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <199512101740.SAA02970@labinfo.iet.unipi.it> you write:
> I reported a few days ago problems in using the CU_SeeMe encoding
> in nv 3.3.beta. Further investigation shows that there are endiannes
> problems in some of the encoding/decoding routines.  I have
> instrumented the encoding and decoding routines, found out that:
> 
> * if a geometry mismatch is found, the encoding routine is not invoked;
>   in order to enable the PAL mode to work, I had to change slightly
>   the tests at the beginning of CUSeeMe_Encode_Reconfig()
> 
As far as I have been told, CUSeeMe is only capable of coping with sizes
160x120 and 320x240. This isn't something I have control over in nv. The only
way to make it work with PAL inputs, or other inputs that do not match one of
its supported sizes, is to actually take the incoming image and crop or
rescale it to one of the supported sizes before it is encoded.

No patch or workaround to this problem is available at this time.

> * the incoming packet type in CUSeeMe_Decode is seen as 256 instead of
>   1. Swapping the bytes makes the rest of the code be called, but
>   evidently there are other parts of the code where endiannes is
>   important.
> 
This is a known bug. There's also another endian bug in the decode routine
which causes it to display a distorted image, with alternating pixels swapped.
Patches for both of these are below:

*** cuseeme_decode.c.orig	Mon Mar 21 17:41:04 1994
--- cuseeme_decode.c	Wed Apr  5 23:33:28 1995
***************
*** 23,33 ****
--- 23,37 ----
   */
  
  #include <sys/types.h>
+ #include <netinet/in.h>
  #include "sized_types.h"
  #include "vid_image.h"
  #include "vid_code.h"
  #include "cuseeme.h"
  
+ /* Mildly gross but moderately portable test for littleendian machines */
+ #define LITTLEENDIAN (ntohl(0x12345678) != 0x12345678)
+ 
  static int16 intraRowBytes[16] =
    { -1,
      -1, 0, 1,
***************
*** 144,150 ****
      0x11111000, 0x11111001, 0x11111010, 0x11111011,
      0x11111100, 0x11111101, 0x11111110, 0x11111111 };
  
! static uint16 cvt4bitTo8bit[256] =
   { 0xffff, 0xffee, 0xffdd, 0xffcc, 0xffbb, 0xffaa, 0xff99, 0xff88,
     0xff77, 0xff66, 0xff55, 0xff44, 0xff33, 0xff22, 0xff11, 0xff00,
     0xeeff, 0xeeee, 0xeedd, 0xeecc, 0xeebb, 0xeeaa, 0xee99, 0xee88,
--- 148,154 ----
      0x11111000, 0x11111001, 0x11111010, 0x11111011,
      0x11111100, 0x11111101, 0x11111110, 0x11111111 };
  
! static uint16 pixpairMSB[256] =
   { 0xffff, 0xffee, 0xffdd, 0xffcc, 0xffbb, 0xffaa, 0xff99, 0xff88,
     0xff77, 0xff66, 0xff55, 0xff44, 0xff33, 0xff22, 0xff11, 0xff00,
     0xeeff, 0xeeee, 0xeedd, 0xeecc, 0xeebb, 0xeeaa, 0xee99, 0xee88,
***************
*** 178,203 ****
     0x00ff, 0x00ee, 0x00dd, 0x00cc, 0x00bb, 0x00aa, 0x0099, 0x0088,
     0x0077, 0x0066, 0x0055, 0x0044, 0x0033, 0x0022, 0x0011, 0x0000 };
  
  static uint8 *CUSeeMe_DecodeRow(uint16 *ip, uint8 *data, int code,
  				uint32 *rowdatap)
  {
      int intra;
      uint32 pix, rowdata;
  
      rowdata = *rowdatap;
      if (code == 0) {
  	pix = data[0];
  	rowdata = pix << 24;
! 	ip[0] = cvt4bitTo8bit[pix];
  	pix = data[1];
  	rowdata += pix << 16;
! 	ip[1] = cvt4bitTo8bit[pix];
  	pix = data[2];
  	rowdata += pix << 8;
! 	ip[2] = cvt4bitTo8bit[pix];
  	pix = data[3];
  	rowdata += pix;
! 	ip[3] = cvt4bitTo8bit[pix];
  	data += 4;
      } else {
  	rowdata -= interRowDiff[code];
--- 182,244 ----
     0x00ff, 0x00ee, 0x00dd, 0x00cc, 0x00bb, 0x00aa, 0x0099, 0x0088,
     0x0077, 0x0066, 0x0055, 0x0044, 0x0033, 0x0022, 0x0011, 0x0000 };
  
+ static uint16 pixpairLSB[256] =
+  { 0xffff, 0xeeff, 0xddff, 0xccff, 0xbbff, 0xaaff, 0x99ff, 0x88ff,
+    0x77ff, 0x66ff, 0x55ff, 0x44ff, 0x33ff, 0x22ff, 0x11ff, 0x00ff,
+    0xffee, 0xeeee, 0xddee, 0xccee, 0xbbee, 0xaaee, 0x99ee, 0x88ee,
+    0x77ee, 0x66ee, 0x55ee, 0x44ee, 0x33ee, 0x22ee, 0x11ee, 0x00ee,
+    0xffdd, 0xeedd, 0xdddd, 0xccdd, 0xbbdd, 0xaadd, 0x99dd, 0x88dd,
+    0x77dd, 0x66dd, 0x55dd, 0x44dd, 0x33dd, 0x22dd, 0x11dd, 0x00dd,
+    0xffcc, 0xeecc, 0xddcc, 0xcccc, 0xbbcc, 0xaacc, 0x99cc, 0x88cc,
+    0x77cc, 0x66cc, 0x55cc, 0x44cc, 0x33cc, 0x22cc, 0x11cc, 0x00cc,
+    0xffbb, 0xeebb, 0xddbb, 0xccbb, 0xbbbb, 0xaabb, 0x99bb, 0x88bb,
+    0x77bb, 0x66bb, 0x55bb, 0x44bb, 0x33bb, 0x22bb, 0x11bb, 0x00bb,
+    0xffaa, 0xeeaa, 0xddaa, 0xccaa, 0xbbaa, 0xaaaa, 0x99aa, 0x88aa,
+    0x77aa, 0x66aa, 0x55aa, 0x44aa, 0x33aa, 0x22aa, 0x11aa, 0x00aa,
+    0xff99, 0xee99, 0xdd99, 0xcc99, 0xbb99, 0xaa99, 0x9999, 0x8899,
+    0x7799, 0x6699, 0x5599, 0x4499, 0x3399, 0x2299, 0x1199, 0x0099,
+    0xff88, 0xee88, 0xdd88, 0xcc88, 0xbb88, 0xaa88, 0x9988, 0x8888,
+    0x7788, 0x6688, 0x5588, 0x4488, 0x3388, 0x2288, 0x1188, 0x0088,
+    0xff77, 0xee77, 0xdd77, 0xcc77, 0xbb77, 0xaa77, 0x9977, 0x8877,
+    0x7777, 0x6677, 0x5577, 0x4477, 0x3377, 0x2277, 0x1177, 0x0077,
+    0xff66, 0xee66, 0xdd66, 0xcc66, 0xbb66, 0xaa66, 0x9966, 0x8866,
+    0x7766, 0x6666, 0x5566, 0x4466, 0x3366, 0x2266, 0x1166, 0x0066,
+    0xff55, 0xee55, 0xdd55, 0xcc55, 0xbb55, 0xaa55, 0x9955, 0x8855,
+    0x7755, 0x6655, 0x5555, 0x4455, 0x3355, 0x2255, 0x1155, 0x0055,
+    0xff44, 0xee44, 0xdd44, 0xcc44, 0xbb44, 0xaa44, 0x9944, 0x8844,
+    0x7744, 0x6644, 0x5544, 0x4444, 0x3344, 0x2244, 0x1144, 0x0044,
+    0xff33, 0xee33, 0xdd33, 0xcc33, 0xbb33, 0xaa33, 0x9933, 0x8833,
+    0x7733, 0x6633, 0x5533, 0x4433, 0x3333, 0x2233, 0x1133, 0x0033,
+    0xff22, 0xee22, 0xdd22, 0xcc22, 0xbb22, 0xaa22, 0x9922, 0x8822,
+    0x7722, 0x6622, 0x5522, 0x4422, 0x3322, 0x2222, 0x1122, 0x0022,
+    0xff11, 0xee11, 0xdd11, 0xcc11, 0xbb11, 0xaa11, 0x9911, 0x8811,
+    0x7711, 0x6611, 0x5511, 0x4411, 0x3311, 0x2211, 0x1111, 0x0011,
+    0xff00, 0xee00, 0xdd00, 0xcc00, 0xbb00, 0xaa00, 0x9900, 0x8800,
+    0x7700, 0x6600, 0x5500, 0x4400, 0x3300, 0x2200, 0x1100, 0x0000 };
+ 
  static uint8 *CUSeeMe_DecodeRow(uint16 *ip, uint8 *data, int code,
  				uint32 *rowdatap)
  {
      int intra;
      uint32 pix, rowdata;
+     uint16 *pixpair;
  
+     pixpair = LITTLEENDIAN? pixpairLSB : pixpairMSB;
+ 
      rowdata = *rowdatap;
      if (code == 0) {
  	pix = data[0];
  	rowdata = pix << 24;
! 	ip[0] = pixpair[pix];
  	pix = data[1];
  	rowdata += pix << 16;
! 	ip[1] = pixpair[pix];
  	pix = data[2];
  	rowdata += pix << 8;
! 	ip[2] = pixpair[pix];
  	pix = data[3];
  	rowdata += pix;
! 	ip[3] = pixpair[pix];
  	data += 4;
      } else {
  	rowdata -= interRowDiff[code];
***************
*** 209,218 ****
  	    rowdata += longDiff[data[0]];
  	    data++;
  	}
! 	ip[0] = cvt4bitTo8bit[rowdata >> 24];
! 	ip[1] = cvt4bitTo8bit[(rowdata >> 16) & 0xff];
! 	ip[2] = cvt4bitTo8bit[(rowdata >> 8) & 0xff];
! 	ip[3] = cvt4bitTo8bit[rowdata & 0xff];
      }
  
      *rowdatap = rowdata;
--- 250,259 ----
  	    rowdata += longDiff[data[0]];
  	    data++;
  	}
! 	ip[0] = pixpair[rowdata >> 24];
! 	ip[1] = pixpair[(rowdata >> 16) & 0xff];
! 	ip[2] = pixpair[(rowdata >> 8) & 0xff];
! 	ip[3] = pixpair[rowdata & 0xff];
      }
  
      *rowdatap = rowdata;
*** cuseeme_encode.c.orig	Wed Jun  1 15:52:29 1994
--- cuseeme_encode.c	Wed Apr  5 23:27:24 1995
***************
*** 338,346 ****
      height = h;
  
      if ((w == CUSEEME_FULLWIDTH) && (h == CUSEEME_FULLHEIGHT)) {
! 	cuseeme_type = CUSEEME_FULLSIZE;
      } else if ((w == CUSEEME_HALFWIDTH) && (h == CUSEEME_HALFHEIGHT)) {
! 	cuseeme_type = CUSEEME_HALFSIZE;
      } else {
  	cuseeme_type = 0;
  	return;
--- 338,346 ----
      height = h;
  
      if ((w == CUSEEME_FULLWIDTH) && (h == CUSEEME_FULLHEIGHT)) {
! 	cuseeme_type = htons(CUSEEME_FULLSIZE);
      } else if ((w == CUSEEME_HALFWIDTH) && (h == CUSEEME_HALFHEIGHT)) {
! 	cuseeme_type = htons(CUSEEME_HALFSIZE);
      } else {
  	cuseeme_type = 0;
  	return;
--
Ron Frederick
frederick@parc.xerox.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?95Dec10.100553pst.16136>