~ubuntu-branches/ubuntu/trusty/liblivemedia/trusty

« back to all changes in this revision

Viewing changes to liveMedia/MatroskaFileParser.cpp

  • Committer: Package Import Robot
  • Author(s): Benjamin Drung
  • Date: 2013-10-30 10:30:48 UTC
  • mfrom: (27.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20131030103048-ggp9ojaizodox2y6
Tags: 2013.10.25-1
* Team upload.
* New upstream release.
* Link shared libraries with g++ instead of gcc to fix build failure.
* Refresh patches.
* Update shared library versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
251
251
        if (parseEBMLVal_unsigned(size, timecodeScale) && timecodeScale > 0) {
252
252
          fOurFile.fTimecodeScale = timecodeScale;
253
253
#ifdef DEBUG
254
 
          fprintf(stderr, "\tTimecode Scale %u ns (=> Segment Duration == %f seconds)\n", fOurFile.timecodeScale(), fOurFile.fileDuration());
 
254
          fprintf(stderr, "\tTimecode Scale %u ns (=> Segment Duration == %f seconds)\n",
 
255
                  fOurFile.timecodeScale(), fOurFile.segmentDuration()*(fOurFile.fTimecodeScale/1000000000.0f));
255
256
#endif
256
257
        }
257
258
        break;
259
260
      case MATROSKA_ID_DURATION: { // 'Segment Duration' header: get this value
260
261
        if (parseEBMLVal_float(size, fOurFile.fSegmentDuration)) {
261
262
#ifdef DEBUG
262
 
          fprintf(stderr, "\tSegment Duration %f (== %f seconds)\n", fOurFile.segmentDuration(), fOurFile.fileDuration());
 
263
          fprintf(stderr, "\tSegment Duration %f (== %f seconds)\n",
 
264
                  fOurFile.segmentDuration(), fOurFile.segmentDuration()*(fOurFile.fTimecodeScale/1000000000.0f));
263
265
#endif
264
266
        }
265
267
        break;
481
483
        }
482
484
        break;
483
485
      }
 
486
      case MATROSKA_ID_DISPLAY_UNIT: {
 
487
        unsigned displayUnit;
 
488
        if (parseEBMLVal_unsigned(size, displayUnit)) {
 
489
#ifdef DEBUG
 
490
          fprintf(stderr, "\tDisplay Unit %d\n", displayUnit);
 
491
#endif
 
492
        }
 
493
        break;
 
494
      }
484
495
      case MATROSKA_ID_AUDIO: { // 'Audio settings' header: enter this
485
496
        break;
486
497
      }
515
526
        }
516
527
        break;
517
528
      }
 
529
      case MATROSKA_ID_BIT_DEPTH: {
 
530
        unsigned bitDepth;
 
531
        if (parseEBMLVal_unsigned(size, bitDepth)) {
 
532
#ifdef DEBUG
 
533
          fprintf(stderr, "\tBit Depth %d\n", bitDepth);
 
534
#endif
 
535
        }
 
536
        break;
 
537
      }
518
538
      case MATROSKA_ID_CONTENT_ENCODINGS:
519
539
      case MATROSKA_ID_CONTENT_ENCODING: { // 'Content Encodings' or 'Content Encoding' header: enter this
520
540
        break;
1130
1150
}
1131
1151
 
1132
1152
Boolean MatroskaFileParser::parseEBMLVal_float(EBMLDataSize& size, float& result) {
1133
 
  unsigned resultAsUnsigned;
1134
 
  if (!parseEBMLVal_unsigned(size, resultAsUnsigned)) return False;
1135
 
 
1136
 
  if (sizeof result != sizeof resultAsUnsigned) return False;
1137
 
  memcpy(&result, &resultAsUnsigned, sizeof result);
1138
 
  return True;
 
1153
  if (size.val() == 4) {
 
1154
    // Normal case.  Read the value as if it were a 4-byte integer, then copy it to the 'float' result:
 
1155
    unsigned resultAsUnsigned;
 
1156
    if (!parseEBMLVal_unsigned(size, resultAsUnsigned)) return False;
 
1157
 
 
1158
    if (sizeof result != sizeof resultAsUnsigned) return False;
 
1159
    memcpy(&result, &resultAsUnsigned, sizeof result);
 
1160
    return True;
 
1161
  } else if (size.val() == 8) {
 
1162
    // Read the value as if it were an 8-byte integer, then copy it to a 'double', the convert that to the 'float' result:
 
1163
    u_int64_t resultAsUnsigned64;
 
1164
    if (!parseEBMLVal_unsigned64(size, resultAsUnsigned64)) return False;
 
1165
 
 
1166
    double resultDouble;
 
1167
    if (sizeof resultDouble != sizeof resultAsUnsigned64) return False;
 
1168
    memcpy(&resultDouble, &resultAsUnsigned64, sizeof resultDouble);
 
1169
 
 
1170
    result = (float)resultDouble;
 
1171
    return True;
 
1172
  } else {
 
1173
    // Unworkable size
 
1174
    return False;
 
1175
  }
1139
1176
}
1140
1177
 
1141
1178
Boolean MatroskaFileParser::parseEBMLVal_string(EBMLDataSize& size, char*& result) {