MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / decodeBlock

Method decodeBlock

src/quicktimevideo.cpp:581–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

579} // QuickTimeVideo::readMetadata
580
581void QuickTimeVideo::decodeBlock(size_t recursion_depth, std::string const& entered_from) {
582 enforce(recursion_depth < max_recursion_depth_, Exiv2::ErrorCode::kerCorruptedMetadata);
583
584 const long bufMinSize = 4;
585 DataBuf buf(bufMinSize + 1);
586 uint64_t size = 0;
587 buf.data()[4] = '\0';
588
589 io_->read(buf.data(), 4);
590 if (io_->eof()) {
591 continueTraversing_ = false;
592 return;
593 }
594
595 size = buf.read_uint32(0, bigEndian);
596
597 io_->readOrThrow(buf.data(), 4);
598
599 // we have read 2x 4 bytes
600 size_t hdrsize = 8;
601
602 if (size == 1) {
603 // The box size is encoded as a uint64_t, so we need to read another 8 bytes.
604 DataBuf data(8);
605 hdrsize += 8;
606 io_->readOrThrow(data.data(), data.size());
607 size = data.read_uint64(0, bigEndian);
608 } else if (size == 0 && entered_from == "meta") {
609 size = buf.read_uint32(0, bigEndian);
610 io_->readOrThrow(buf.data(), 4, Exiv2::ErrorCode::kerCorruptedMetadata);
611 }
612
613 enforce(size >= hdrsize, Exiv2::ErrorCode::kerCorruptedMetadata);
614 enforce(size - hdrsize <= io_->size() - io_->tell(), Exiv2::ErrorCode::kerCorruptedMetadata);
615 enforce(size - hdrsize <= std::numeric_limits<size_t>::max(), Exiv2::ErrorCode::kerCorruptedMetadata);
616
617 // std::cerr<<"Tag=>"<<buf.data()<<" size=>"<<size-hdrsize << std::endl;
618 const auto newsize = static_cast<size_t>(size - hdrsize);
619 if (newsize > buf.size()) {
620 buf.resize(newsize);
621 }
622 tagDecoder(buf, newsize, recursion_depth + 1);
623} // QuickTimeVideo::decodeBlock
624
625static std::string readString(BasicIo& io, size_t size) {
626 enforce(size <= io.size() - io.tell(), Exiv2::ErrorCode::kerCorruptedMetadata);

Callers

nothing calls this directly

Calls 10

enforceFunction · 0.85
dataMethod · 0.80
eofMethod · 0.80
read_uint32Method · 0.80
readOrThrowMethod · 0.80
read_uint64Method · 0.80
tellMethod · 0.80
resizeMethod · 0.80
readMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected