Commit 429f944eebba388fe2da591af3243c03b13e5e91

Authored by Josh Klontz
1 parent 827eef9d

.mat column-major order bug fix

Showing 1 changed file with 9 additions and 4 deletions
sdk/plugins/format.cpp
@@ -38,7 +38,7 @@ namespace br @@ -38,7 +38,7 @@ namespace br
38 * \author Josh Klonyz \cite jklontz 38 * \author Josh Klonyz \cite jklontz
39 * First 4 bytes indicate the number of rows. 39 * First 4 bytes indicate the number of rows.
40 * Second 4 bytes indicate the number of columns. 40 * Second 4 bytes indicate the number of columns.
41 - * The rest of the bytes are 32-bit floating data elements. 41 + * The rest of the bytes are 32-bit floating data elements in row-major order.
42 */ 42 */
43 class binFormat : public Format 43 class binFormat : public Format
44 { 44 {
@@ -318,8 +318,11 @@ class matFormat : public Format @@ -318,8 +318,11 @@ class matFormat : public Format
318 } 318 }
319 } 319 }
320 320
321 - if ((rows > 0) && (columns > 0) && (matrixType != 0) && !matrixData.isEmpty())  
322 - t.append(Mat(rows, columns, matrixType, matrixData.data()).clone()); 321 + if ((rows > 0) && (columns > 0) && (matrixType != 0) && !matrixData.isEmpty()) {
  322 + Mat transposed;
  323 + transpose(Mat(rows, columns, matrixType, matrixData.data()), transposed);
  324 + t.append(transposed);
  325 + }
323 } 326 }
324 } 327 }
325 328
@@ -404,9 +407,11 @@ class matFormat : public Format @@ -404,9 +407,11 @@ class matFormat : public Format
404 } 407 }
405 quint32 bytes = m.elemSize() * m.rows * m.cols; 408 quint32 bytes = m.elemSize() * m.rows * m.cols;
406 QByteArray buffer((8 - bytes%8)%8, 0); 409 QByteArray buffer((8 - bytes%8)%8, 0);
  410 + Mat transposed;
  411 + transpose(m, transposed);
407 substream.writeRawData((const char*)&type, 4); 412 substream.writeRawData((const char*)&type, 4);
408 substream.writeRawData((const char*)&bytes, 4); 413 substream.writeRawData((const char*)&bytes, 4);
409 - substream.writeRawData((const char*)m.data, bytes); 414 + substream.writeRawData((const char*)transposed.data, bytes);
410 substream.writeRawData(buffer.data(), buffer.size()); 415 substream.writeRawData(buffer.data(), buffer.size());
411 } 416 }
412 417