[Kst] extragear/graphics/kst/src/datasources/scuba2

Andrew Walker arwalker at sumusltd.com
Mon Mar 12 23:10:16 CET 2007


SVN commit 641947 by arwalker:

correction for latest version of scuba data source

 M  +20 -15    scuba.cpp  


--- trunk/extragear/graphics/kst/src/datasources/scuba2/scuba.cpp #641946:641947
@@ -378,7 +378,7 @@
             while (read != -1) {
               checksum = 0;
 
-              for (i=0; i<42; i++) {
+              for (i=0; i<_numRows+1; i++) {
                 read = readFullLine(file, s);
 
                 if (read == -1) {
@@ -533,9 +533,9 @@
                             if (!error) {
                               lvalue /= 0x4000;
                             } else {
-                              lvalue -= 0x4000 * ( lvalue / 0x4000 );
-                              if (lvalue > 0x2000) {
-                                lvalue = 0x4000 - lvalue;
+                              lvalue &= 0x3FFF;
+                              if (lvalue & 0x2000) {
+                                lvalue -= 0x4000;
                               }
                             }
                             break;
@@ -543,9 +543,9 @@
                             if (!error) {
                               lvalue /= 0x100;
                             } else {
-                              lvalue -= 0x100 * ( lvalue / 0x100 );
-                              if (lvalue > 0x80) {
-                                lvalue = 0x100 - lvalue;
+                              lvalue &= 0xFF;
+                              if (lvalue & 0x80) {
+                                lvalue -= 0x100;
                               }
                             }
                             break;
@@ -628,6 +628,11 @@
     if (fieldIndex != -1) {
       int iSamplesPerFrame = samplesPerFrame(field);
 
+      //
+      // allow for the existence of the INDEX field...
+      //
+      fieldIndex--;
+
       QIODevice::Offset bufread = _frameIndex[(s + n)/iSamplesPerFrame] - _frameIndex[s/iSamplesPerFrame];
 
       if (bufread > 0) {
@@ -706,22 +711,22 @@
                         case DataRaw:
                           break;
                         case Data18_14:
-                          if (valueIndex % 2 == 0) {
+                          if ( ( fieldIndex - numHousekeepingFields ) % 2 == 0) {
                             lvalue /= 0x4000;
                           } else {
-                            lvalue -= 0x4000 * ( lvalue / 0x4000 );
-                            if (lvalue > 0x2000) {
-                              lvalue = 0x4000 - lvalue;
+                            lvalue &= 0x3FFF;
+                            if (lvalue & 0x2000) {
+                              lvalue -= 0x4000;
                             }
                           }
                           break;
                         case Data24_8:
-                          if (valueIndex % 2 == 0) {
+                          if ( ( fieldIndex - numHousekeepingFields ) % 2 == 0) {
                             lvalue /= 0x100;
                           } else {
-                            lvalue -= 0x100 * ( lvalue / 0x100 );
-                            if (lvalue > 0x80) {
-                              lvalue = 0x100 - lvalue;
+                            lvalue &= 0xFF;
+                            if (lvalue & 0x80) {
+                              lvalue -= 0x100;
                             }
                           }
                           break;


More information about the Kst mailing list