251
251
if (parseEBMLVal_unsigned(size, timecodeScale) && timecodeScale > 0) {
252
252
fOurFile.fTimecodeScale = timecodeScale;
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));
259
260
case MATROSKA_ID_DURATION: { // 'Segment Duration' header: get this value
260
261
if (parseEBMLVal_float(size, fOurFile.fSegmentDuration)) {
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));
486
case MATROSKA_ID_DISPLAY_UNIT: {
487
unsigned displayUnit;
488
if (parseEBMLVal_unsigned(size, displayUnit)) {
490
fprintf(stderr, "\tDisplay Unit %d\n", displayUnit);
484
495
case MATROSKA_ID_AUDIO: { // 'Audio settings' header: enter this
529
case MATROSKA_ID_BIT_DEPTH: {
531
if (parseEBMLVal_unsigned(size, bitDepth)) {
533
fprintf(stderr, "\tBit Depth %d\n", bitDepth);
518
538
case MATROSKA_ID_CONTENT_ENCODINGS:
519
539
case MATROSKA_ID_CONTENT_ENCODING: { // 'Content Encodings' or 'Content Encoding' header: enter this
1132
1152
Boolean MatroskaFileParser::parseEBMLVal_float(EBMLDataSize& size, float& result) {
1133
unsigned resultAsUnsigned;
1134
if (!parseEBMLVal_unsigned(size, resultAsUnsigned)) return False;
1136
if (sizeof result != sizeof resultAsUnsigned) return False;
1137
memcpy(&result, &resultAsUnsigned, sizeof result);
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;
1158
if (sizeof result != sizeof resultAsUnsigned) return False;
1159
memcpy(&result, &resultAsUnsigned, sizeof result);
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;
1166
double resultDouble;
1167
if (sizeof resultDouble != sizeof resultAsUnsigned64) return False;
1168
memcpy(&resultDouble, &resultAsUnsigned64, sizeof resultDouble);
1170
result = (float)resultDouble;
1141
1178
Boolean MatroskaFileParser::parseEBMLVal_string(EBMLDataSize& size, char*& result) {