本文整理汇总了C++中EBMLDataSize类的典型用法代码示例。如果您正苦于以下问题:C++ EBMLDataSize类的具体用法?C++ EBMLDataSize怎么用?C++ EBMLDataSize使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EBMLDataSize类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fprintf
void MatroskaFileParser::lookForNextBlock() {
#ifdef DEBUG
fprintf(stderr, "looking for Block\n");
#endif
// Read and skip over each Matroska header, until we get to a 'Cluster':
EBMLId id;
EBMLDataSize size;
while (fCurrentParseState == LOOKING_FOR_BLOCK) {
while (!parseEBMLIdAndSize(id, size)) {}
#ifdef DEBUG
fprintf(stderr, "MatroskaFileParser::lookForNextBlock(): Parsed id 0x%s (%s), size: %lld\n", id.hexString(), id.stringName(), size.val());
#endif
switch (id.val()) {
case MATROSKA_ID_SEGMENT: { // 'Segment' header: enter this
break;
}
case MATROSKA_ID_CLUSTER: { // 'Cluster' header: enter this
break;
}
case MATROSKA_ID_TIMECODE: { // 'Timecode' header: get this value
unsigned timecode;
if (parseEBMLVal_unsigned(size, timecode)) {
fClusterTimecode = timecode;
#ifdef DEBUG
fprintf(stderr, "\tCluster timecode: %d (== %f seconds)\n", fClusterTimecode, fClusterTimecode*(fOurFile.fTimecodeScale/1000000000.0));
#endif
}
break;
}
case MATROSKA_ID_BLOCK_GROUP: { // 'Block Group' header: enter this
break;
}
case MATROSKA_ID_SIMPLEBLOCK:
case MATROSKA_ID_BLOCK: { // 'SimpleBlock' or 'Block' header: enter this (and we're done)
fBlockSize = (unsigned)size.val();
fCurrentParseState = PARSING_BLOCK;
break;
}
case MATROSKA_ID_BLOCK_DURATION: { // 'Block Duration' header: get this value (but we currently don't do anything with it)
unsigned blockDuration;
if (parseEBMLVal_unsigned(size, blockDuration)) {
#ifdef DEBUG
fprintf(stderr, "\tblock duration: %d (== %f ms)\n", blockDuration, (float)(blockDuration*fOurFile.fTimecodeScale/1000000.0));
#endif
}
break;
}
default: { // skip over this header
skipHeader(size);
#ifdef DEBUG
fprintf(stderr, "\tskipped %lld bytes\n", size.val());
#endif
break;
}
}
setParseState();
}
}
示例2: parseEBMLVal_unsigned
Boolean MatroskaFileParser::parseEBMLVal_unsigned(EBMLDataSize& size, unsigned& result) {
if (size.val() > 4) return False; // size too large
u_int64_t result64;
if (!parseEBMLVal_unsigned64(size, result64)) return False;
result = (unsigned)result64;
return True;
}
示例3: skipHeader
void MatroskaFileParser::skipHeader(EBMLDataSize const& size) {
unsigned sv = (unsigned)size.val();
// Hack: To avoid tripping into a parser 'internal error' if we try to skip an excessively large distance.
// (Such large distances are likely caused by erroneous data. We might not be able to recover from this, but at least we won't
// generate a parser 'internal error'.)
if (sv > bankSize()-12) sv = bankSize()-12;
skipBytes(sv);
fCurOffsetInFile += sv;
}
示例4:
Boolean MatroskaFileParser::parseEBMLVal_unsigned64(EBMLDataSize& size, u_int64_t& result) {
u_int64_t sv = size.val();
if (sv > 8) return False; // size too large
result = 0; // initially
for (unsigned i = (unsigned)sv; i > 0; --i) {
if (fLimitOffsetInFile > 0 && fCurOffsetInFile > fLimitOffsetInFile) return False; // We've hit our pre-set limit
u_int8_t c = get1Byte();
++fCurOffsetInFile;
result = result*256 + c;
}
return True;
}
示例5: parseEBMLVal_float
Boolean MatroskaFileParser::parseEBMLVal_float(EBMLDataSize& size, float& result) {
switch (size.val()) {
case 4: {
unsigned resultAsUnsigned;
if (!parseEBMLVal_unsigned(size, resultAsUnsigned)) return False;
result = *(float*)&resultAsUnsigned;
return True;
}
case 8: {
u_int64_t resultAsU64;
if (!parseEBMLVal_unsigned64(size, resultAsU64)) return False;
result = (float)*(double*)&resultAsU64;
return True;
}
default: {
return False;
}
}
}
示例6: parseEBMLVal_binary
Boolean MatroskaFileParser::parseEBMLVal_binary(EBMLDataSize& size, u_int8_t*& result) {
unsigned resultLength = (unsigned)size.val();
result = new u_int8_t[resultLength];
if (result == NULL) return False;
u_int8_t* p = result;
unsigned i;
for (i = 0; i < resultLength; ++i) {
if (fLimitOffsetInFile > 0 && fCurOffsetInFile > fLimitOffsetInFile) break; // We've hit our pre-set limit
u_int8_t c = get1Byte();
++fCurOffsetInFile;
*p++ = c;
}
if (i < resultLength) { // an error occurred
delete[] result;
result = NULL;
return False;
}
return True;
}
示例7: parseEBMLVal_string
Boolean MatroskaFileParser::parseEBMLVal_string(EBMLDataSize& size, char*& result) {
unsigned resultLength = (unsigned)size.val();
result = new char[resultLength + 1]; // allow for the trailing '\0'
if (result == NULL) return False;
char* p = result;
unsigned i;
for (i = 0; i < resultLength; ++i) {
if (fLimitOffsetInFile > 0 && fCurOffsetInFile > fLimitOffsetInFile) break; // We've hit our pre-set limit
u_int8_t c = get1Byte();
++fCurOffsetInFile;
*p++ = c;
}
if (i < resultLength) { // an error occurred
delete[] result;
result = NULL;
return False;
}
*p = '\0';
return True;
}
示例8: defined
Boolean MatroskaFileParser::parseCues() {
#if defined(DEBUG) || defined(DEBUG_CUES)
fprintf(stderr, "parsing Cues\n");
#endif
EBMLId id;
EBMLDataSize size;
// Read the next header, which should be MATROSKA_ID_CUES:
if (!parseEBMLIdAndSize(id, size) || id != MATROSKA_ID_CUES) return True; // The header wasn't what we expected, so we're done
fLimitOffsetInFile = fCurOffsetInFile + size.val(); // Make sure we don't read past the end of this header
double currentCueTime = 0.0;
u_int64_t currentClusterOffsetInFile = 0;
while (fCurOffsetInFile < fLimitOffsetInFile) {
while (!parseEBMLIdAndSize(id, size)) {}
#ifdef DEBUG_CUES
if (id == MATROSKA_ID_CUE_POINT) fprintf(stderr, "\n"); // makes debugging output easier to read
fprintf(stderr, "MatroskaFileParser::parseCues(): Parsed id 0x%s (%s), size: %lld\n", id.hexString(), id.stringName(), size.val());
#endif
switch (id.val()) {
case MATROSKA_ID_CUE_POINT: { // 'Cue Point' header: enter this
break;
}
case MATROSKA_ID_CUE_TIME: { // 'Cue Time' header: get this value
unsigned cueTime;
if (parseEBMLVal_unsigned(size, cueTime)) {
currentCueTime = cueTime*(fOurFile.fTimecodeScale/1000000000.0);
#ifdef DEBUG_CUES
fprintf(stderr, "\tCue Time %d (== %f seconds)\n", cueTime, currentCueTime);
#endif
}
break;
}
case MATROSKA_ID_CUE_TRACK_POSITIONS: { // 'Cue Track Positions' header: enter this
break;
}
case MATROSKA_ID_CUE_TRACK: { // 'Cue Track' header: get this value (but only for debugging; we don't do anything with it)
unsigned cueTrack;
if (parseEBMLVal_unsigned(size, cueTrack)) {
#ifdef DEBUG_CUES
fprintf(stderr, "\tCue Track %d\n", cueTrack);
#endif
}
break;
}
case MATROSKA_ID_CUE_CLUSTER_POSITION: { // 'Cue Cluster Position' header: get this value
u_int64_t cueClusterPosition;
if (parseEBMLVal_unsigned64(size, cueClusterPosition)) {
currentClusterOffsetInFile = fOurFile.fSegmentDataOffset + cueClusterPosition;
#ifdef DEBUG_CUES
fprintf(stderr, "\tCue Cluster Position %llu (=> offset within the file: %llu (0x%llx))\n", cueClusterPosition, currentClusterOffsetInFile, currentClusterOffsetInFile);
#endif
// Record this cue point:
fOurFile.addCuePoint(currentCueTime, currentClusterOffsetInFile, 1/*default block number within cluster*/);
}
break;
}
case MATROSKA_ID_CUE_BLOCK_NUMBER: { // 'Cue Block Number' header: get this value
unsigned cueBlockNumber;
if (parseEBMLVal_unsigned(size, cueBlockNumber) && cueBlockNumber != 0) {
#ifdef DEBUG_CUES
fprintf(stderr, "\tCue Block Number %d\n", cueBlockNumber);
#endif
// Record this cue point (overwriting any existing entry for this cue time):
fOurFile.addCuePoint(currentCueTime, currentClusterOffsetInFile, cueBlockNumber);
}
break;
}
default: { // We don't process this header, so just skip over it:
skipHeader(size);
#ifdef DEBUG_CUES
fprintf(stderr, "\tskipped %lld bytes\n", size.val());
#endif
break;
}
}
setParseState();
}
fLimitOffsetInFile = 0; // reset
#if defined(DEBUG) || defined(DEBUG_CUES)
fprintf(stderr, "done parsing Cues\n");
#endif
#ifdef DEBUG_CUES
fprintf(stderr, "Cue Point tree: ");
fOurFile.printCuePoints(stderr);
fprintf(stderr, "\n");
#endif
return True; // we're done parsing Cues
}