Skip to content

Commit

Permalink
Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Martchus committed Feb 5, 2018
1 parent 6068bb0 commit b55d956
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
30 changes: 14 additions & 16 deletions matroska/matroskacontainer.cpp
Expand Up @@ -93,7 +93,7 @@ void MatroskaContainer::validateIndex()
static const string context("validating Matroska file index (cues)");
bool cuesElementsFound = false;
if(m_firstElement) {
unordered_set<int> ids;
unordered_set<EbmlElement::identifierType> ids;
bool cueTimeFound = false, cueTrackPositionsFound = false;
unique_ptr<EbmlElement> clusterElement;
uint64 pos, prevClusterSize = 0, currentOffset = 0;
Expand Down Expand Up @@ -785,10 +785,10 @@ struct SegmentData
clusterEndOffset(0),
startOffset(0),
newPadding(0),
sizeDenotationLength(0),
totalDataSize(0),
totalSize(0),
newDataOffset(0)
newDataOffset(0),
sizeDenotationLength(0)
{}

/// \brief whether CRC-32 checksum is present
Expand All @@ -811,14 +811,14 @@ struct SegmentData
uint64 startOffset;
/// \brief padding (in the new file)
uint64 newPadding;
/// \brief header size (in the new file)
byte sizeDenotationLength;
/// \brief total size of the segment data (in the new file, excluding header)
uint64 totalDataSize;
/// \brief total size of the segment data (in the new file, including header)
uint64 totalSize;
/// \brief data offset of the segment in the new file
uint64 newDataOffset;
/// \brief header size (in the new file)
byte sizeDenotationLength;
};

void MatroskaContainer::internalMakeFile()
Expand Down Expand Up @@ -1036,16 +1036,14 @@ void MatroskaContainer::internalMakeFile()
SegmentData &segment = segmentData[segmentIndex];

// parse original "Cues"-element (if present)
if(!segment.cuesElement) {
if((segment.cuesElement = level0Element->childById(MatroskaIds::Cues))) {
try {
segment.cuesUpdater.parse(segment.cuesElement);
} catch(const Failure &) {
addNotifications(segment.cuesUpdater);
throw;
}
if(!segment.cuesElement && (segment.cuesElement = level0Element->childById(MatroskaIds::Cues))) {
try {
segment.cuesUpdater.parse(segment.cuesElement);
} catch(const Failure &) {
addNotifications(segment.cuesUpdater);
throw;
}
addNotifications(segment.cuesUpdater);
}

// get first "Cluster"-element
Expand Down Expand Up @@ -1724,7 +1722,7 @@ void MatroskaContainer::internalMakeFile()
if(level2Element->dataSize() < sizeLength) {
// can't update position -> void position elements ("Position"-elements seem a bit useless anyways)
outputStream.seekp(level2Element->startOffset());
outputStream.put(EbmlIds::Void);
outputStream.put(static_cast<char>(EbmlIds::Void));
} else {
// update position
outputStream.seekp(level2Element->dataOffset());
Expand Down Expand Up @@ -1795,7 +1793,7 @@ void MatroskaContainer::internalMakeFile()
updateStatus("Reparsing output file ...");
if(rewriteRequired) {
// report new size
fileInfo().reportSizeChanged(outputStream.tellp());
fileInfo().reportSizeChanged(static_cast<uint64>(outputStream.tellp()));

// "save as path" is now the regular path
if(!fileInfo().saveFilePath().empty()) {
Expand All @@ -1814,7 +1812,7 @@ void MatroskaContainer::internalMakeFile()
// -> close stream before truncating
outputStream.close();
// -> truncate file
if(truncate(fileInfo().path().c_str(), newSize) == 0) {
if(truncate(fileInfo().path().c_str(), static_cast<iostream::off_type>(newSize)) == 0) {
fileInfo().reportSizeChanged(newSize);
} else {
addNotification(NotificationType::Critical, "Unable to truncate the file.", context);
Expand Down
16 changes: 8 additions & 8 deletions mp4/mp4container.cpp
Expand Up @@ -77,7 +77,7 @@ void Mp4Container::internalParseHeader()
m_firstElement->parse();
Mp4Atom *ftypAtom = m_firstElement->siblingById(Mp4AtomIds::FileType, true);
if(ftypAtom) {
stream().seekg(ftypAtom->dataOffset());
stream().seekg(static_cast<iostream::off_type>(ftypAtom->dataOffset()));
m_doctype = reader().readString(4);
m_version = reader().readUInt32BE();
} else {
Expand Down Expand Up @@ -124,7 +124,7 @@ void Mp4Container::internalParseTracks()
// get mvhd atom which holds overall track information
if(Mp4Atom *mvhdAtom = moovAtom->childById(Mp4AtomIds::MovieHeader)) {
if(mvhdAtom->dataSize() > 0) {
stream().seekg(mvhdAtom->dataOffset());
stream().seekg(static_cast<iostream::off_type>(mvhdAtom->dataOffset()));
byte version = reader().readByte();
if((version == 1 && mvhdAtom->dataSize() >= 32) || (mvhdAtom->dataSize() >= 20)) {
stream().seekg(3, ios_base::cur); // skip flags
Expand Down Expand Up @@ -157,7 +157,7 @@ void Mp4Container::internalParseTracks()
if(Mp4Atom *mehdAtom = moovAtom->subelementByPath({Mp4AtomIds::MovieExtends, Mp4AtomIds::MovieExtendsHeader})) {
m_fragmented = true;
if(mehdAtom->dataSize() > 0) {
stream().seekg(mehdAtom->dataOffset());
stream().seekg(static_cast<iostream::off_type>(mehdAtom->dataOffset()));
unsigned int durationSize = reader().readByte() == 1u ? 8u : 4u; // duration size depends on atom version
if(mehdAtom->dataSize() >= 4 + durationSize) {
stream().seekg(3, ios_base::cur); // skip flags
Expand Down Expand Up @@ -772,7 +772,7 @@ void Mp4Container::internalMakeFile()
outputWriter.writeUInt32BE(Mp4AtomIds::Free);
break;
default:
outputStream.seekp(level0Atom->totalSize(), ios_base::cur);
outputStream.seekp(static_cast<iostream::off_type>(level0Atom->totalSize()), ios_base::cur);
}
if(level0Atom == lastAtomToBeWritten) {
break;
Expand All @@ -786,7 +786,7 @@ void Mp4Container::internalMakeFile()
updateStatus("Reparsing output file ...");
if(rewriteRequired) {
// report new size
fileInfo().reportSizeChanged(outputStream.tellp());
fileInfo().reportSizeChanged(static_cast<iostream::off_type>(outputStream.tellp()));
// "save as path" is now the regular path
if(!fileInfo().saveFilePath().empty()) {
fileInfo().reportPathChanged(fileInfo().saveFilePath());
Expand All @@ -803,7 +803,7 @@ void Mp4Container::internalMakeFile()
// -> close stream before truncating
outputStream.close();
// -> truncate file
if(truncate(fileInfo().path().c_str(), newSize) == 0) {
if(truncate(fileInfo().path().c_str(), static_cast<iostream::off_type>(newSize)) == 0) {
fileInfo().reportSizeChanged(newSize);
} else {
addNotification(NotificationType::Critical, "Unable to truncate the file.", context);
Expand Down Expand Up @@ -901,7 +901,7 @@ void Mp4Container::updateOffsets(const std::vector<int64> &oldMdatOffsets, const
tfhdAtom->parse();
++tfhdAtomCount;
if(tfhdAtom->dataSize() >= 8) {
stream().seekg(tfhdAtom->dataOffset() + 1);
stream().seekg(static_cast<iostream::off_type>(tfhdAtom->dataOffset()) + 1);
uint32 flags = reader().readUInt24BE();
if(flags & 1) {
if(tfhdAtom->dataSize() >= 16) {
Expand All @@ -911,7 +911,7 @@ void Mp4Container::updateOffsets(const std::vector<int64> &oldMdatOffsets, const
iOld != end; ++iOld, ++iNew) {
if(off >= static_cast<uint64>(*iOld)) {
off += (*iNew - *iOld);
stream().seekp(tfhdAtom->dataOffset() + 8);
stream().seekp(static_cast<iostream::off_type>(tfhdAtom->dataOffset()) + 8);
writer().writeUInt64BE(off);
break;
}
Expand Down

0 comments on commit b55d956

Please sign in to comment.