RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
rawspeed::ByteStream Class Referencefinal

#include "io/ByteStream.h"

Inheritance diagram for rawspeed::ByteStream:
[legend]
Collaboration diagram for rawspeed::ByteStream:
[legend]

Public Types

using size_type = uint32_t

Public Member Functions

 ByteStream ()=default
 ByteStream (DataBuffer buffer)
ByteStream getSubStream (size_type offset, size_type size_) const
ByteStream getSubStream (size_type offset) const
size_type check (size_type bytes) const
size_type check (size_type nmemb, size_type size_) const
size_type getPosition () const
void setPosition (size_type newPos)
size_type RAWSPEED_READONLY getRemainSize () const
const uint8_t * peekData (size_type count) const
const uint8_t * getData (size_type count)
Buffer peekBuffer (size_type size_) const
Buffer getBuffer (size_type size_)
Buffer peekRemainingBuffer () const
ByteStream peekStream (size_type size_) const
ByteStream peekStream (size_type nmemb, size_type size_) const
ByteStream getStream (size_type size_)
ByteStream getStream (size_type nmemb, size_type size_)
void skipBytes (size_type nbytes)
void skipBytes (size_type nmemb, size_type size_)
bool hasPatternAt (std::string_view pattern, size_type relPos) const
bool hasPrefix (std::string_view prefix) const
bool skipPrefix (std::string_view prefix)
template<typename T>
T peek (size_type i=0) const
template<typename T>
T get ()
template<typename T, int N>
std::array< T, N > getArray ()
template<typename T>
std::vector< TgetVector (int nElt)
uint8_t peekByte (size_type i=0) const
uint8_t getByte ()
uint16_t peekU16 () const
uint32_t peekU32 (size_type i=0) const
uint16_t getU16 ()
int32_t getI32 ()
uint32_t getU32 ()
float getFloat ()
std::string_view peekString () const
std::string_view getString ()
template<typename T>
T get (size_type offset, size_type index=0) const
template<typename T>
T get (bool inNativeByteOrder, size_type offset, size_type index=0) const
Endianness getByteOrder () const
Endianness setByteOrder (Endianness endianness_)
Array1DRef< const uint8_t > getAsArray1DRef () const
 operator Array1DRef< const uint8_t > () const
Buffer getSubView (size_type offset, size_type size_) const
Buffer getSubView (size_type offset) const
uint8_t operator[] (size_type offset) const
const uint8_t * begin () const
const uint8_t * end () const
size_type RAWSPEED_READONLY getSize () const
bool isValid (size_type offset, size_type count=1) const

Protected Attributes

const uint8_t * data = nullptr

Private Attributes

size_type pos
Endianness endianness = Endianness::little
size_type size = 0

Detailed Description

Definition at line 43 of file ByteStream.h.

Member Typedef Documentation

◆ size_type

Definition at line 49 of file Buffer.h.

Constructor & Destructor Documentation

◆ ByteStream() [1/2]

rawspeed::ByteStream::ByteStream ( )
default

Referenced by getStream(), getStream(), getSubStream(), getSubStream(), peekStream(), and peekStream().

Here is the caller graph for this function:

◆ ByteStream() [2/2]

rawspeed::ByteStream::ByteStream ( DataBuffer buffer)
inlineexplicit

Definition at line 50 of file ByteStream.h.

References rawspeed::DataBuffer::DataBuffer().

Here is the call graph for this function:

Member Function Documentation

◆ begin()

const uint8_t * rawspeed::Buffer::begin ( ) const
inlinenodiscardinherited

◆ check() [1/2]

size_type rawspeed::ByteStream::check ( size_type bytes) const
inlinenodiscard

Definition at line 63 of file ByteStream.h.

References assert(), rawspeed::Buffer::begin(), rawspeed::Buffer::getSize(), rawspeed::Buffer::getSubView(), rawspeed::Buffer::isValid(), pos, rawspeed::ASan::RegionIsPoisoned(), and ThrowIOE.

Referenced by rawspeed::DngOpcodes::DeltaRowOrCol< S >::DeltaRowOrCol(), rawspeed::DngOpcodes::PolynomialMap::PolynomialMap(), rawspeed::SamsungV2Decompressor::SamsungV2Decompressor(), check(), CreateCFA(), getPosition(), getRemainSize(), LLVMFuzzerTestOneInput(), rawspeed::ArwDecoder::ParseA100WB(), rawspeed::MrwDecoder::parseHeader(), setPosition(), skipBytes(), and skipBytes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check() [2/2]

size_type rawspeed::ByteStream::check ( size_type nmemb,
size_type size_ ) const
inlinenodiscard

Definition at line 72 of file ByteStream.h.

References check(), and ThrowIOE.

Here is the call graph for this function:

◆ end()

const uint8_t * rawspeed::Buffer::end ( ) const
inlinenodiscardinherited

Definition at line 102 of file Buffer.h.

References Array1DRef< T >::end(), and getAsArray1DRef().

Referenced by rawspeed::TiffEntry::getString(), rawspeed::operator<(), rawspeed::PanasonicV4Decompressor::ProxyStream::parseBlock(), rawspeed::PanasonicV5Decompressor::ProxyStream::parseBlock(), rawspeed::ByteStream::peekString(), and rawspeed::HuffmanCode< CodeTag >::setNCodesPerLength().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get() [1/3]

template<typename T>
T rawspeed::Buffer::get ( bool inNativeByteOrder,
size_type offset,
size_type index = 0 ) const
inlinenodiscardinherited

Definition at line 107 of file Buffer.h.

References Buffer(), rawspeed::buf, rawspeed::getByteSwapped(), getSubView(), and rawspeed::T().

Referenced by rawspeed::DataBuffer::get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get() [2/3]

template<typename T>
T rawspeed::ByteStream::get ( )
inline

Definition at line 159 of file ByteStream.h.

References peek(), pos, and rawspeed::T().

Referenced by rawspeed::DngOpcodes::DeltaRowOrCol< S >::DeltaRowOrCol(), rawspeed::DngOpcodes::PolynomialMap::PolynomialMap(), getByte(), getCodeSymbols(), getCodeValues(), getFloat(), getI32(), rawspeed::anonymous_namespace{Rw2Decoder.cpp}::getPanasonicTiffVector(), getU16(), getU32(), and LLVMFuzzerTestOneInput().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get() [3/3]

template<typename T>
T rawspeed::DataBuffer::get ( size_type offset,
size_type index = 0 ) const
inlinenodiscardinherited

Definition at line 147 of file Buffer.h.

References assert(), rawspeed::big, endianness, rawspeed::Buffer::get(), rawspeed::getHostEndianness(), rawspeed::little, rawspeed::T(), and rawspeed::unknown.

Referenced by rawspeed::IiqDecoder::isAppropriateDecoder(), and rawspeed::ByteStream::peek().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getArray()

template<typename T, int N>
std::array< T, N > rawspeed::ByteStream::getArray ( )
inline

Definition at line 165 of file ByteStream.h.

References getStream(), invariant, and rawspeed::T().

Referenced by rawspeed::LLVMFuzzerTestOneInput().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAsArray1DRef()

◆ getBuffer()

Buffer rawspeed::ByteStream::getBuffer ( size_type size_)
inline

Definition at line 103 of file ByteStream.h.

References peekBuffer(), and pos.

Referenced by createHuffmanCode(), rawspeed::anonymous_namespace{PanasonicV8Decompressor.cpp}::getTrailingStrips(), LLVMFuzzerTestOneInput(), rawspeed::AbstractLJpegDecoder::parseDHT(), rawspeed::MrwDecoder::parseHeader(), and rawspeed::NefDecoder::parseWhiteBalance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getByte()

◆ getByteOrder()

Endianness rawspeed::DataBuffer::getByteOrder ( ) const
inlinenodiscardinherited

Definition at line 154 of file Buffer.h.

References endianness.

Referenced by rawspeed::RafDecoder::decodeRawInternal(), rawspeed::ByteStream::getSubStream(), rawspeed::ByteStream::getSubStream(), and rawspeed::ArwDecoder::GetWB().

Here is the caller graph for this function:

◆ getData()

const uint8_t * rawspeed::ByteStream::getData ( size_type count)
inline

Definition at line 95 of file ByteStream.h.

References peekData(), and pos.

Referenced by rawspeed::ArwDecoder::GetWB().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFloat()

float rawspeed::ByteStream::getFloat ( )
inline

Definition at line 197 of file ByteStream.h.

References get().

Referenced by rawspeed::IiqDecoder::decodeRawInternal(), and LLVMFuzzerTestOneInput().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getI32()

int32_t rawspeed::ByteStream::getI32 ( )
inline

Definition at line 195 of file ByteStream.h.

References get().

Referenced by CreateCFA(), and LLVMFuzzerTestOneInput().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPosition()

size_type rawspeed::ByteStream::getPosition ( ) const
inlinenodiscard

Definition at line 78 of file ByteStream.h.

References check(), rawspeed::Buffer::getSize(), invariant, and pos.

Referenced by rawspeed::DngOpcodes::DngOpcodes(), rawspeed::DngOpcodes::FixBadPixelsList::FixBadPixelsList(), rawspeed::TiffEntry::TiffEntry(), anonymous_namespace{Dual.cpp}::checkFlavour(), rawspeed::CiffEntry::Create(), rawspeed::IiqDecoder::decodeRawInternal(), rawspeed::ArwDecoder::ParseA100WB(), rawspeed::FiffParser::parseData(), rawspeed::MrwDecoder::parseHeader(), rawspeed::TiffIFD::parseIFDEntry(), and rawspeed::TiffIFD::parseMakerNote().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRemainSize()

◆ getSize()

◆ getStream() [1/2]

ByteStream rawspeed::ByteStream::getStream ( size_type nmemb,
size_type size_ )
inline

Definition at line 124 of file ByteStream.h.

References ByteStream(), getStream(), and ThrowIOE.

Here is the call graph for this function:

◆ getStream() [2/2]

◆ getString()

std::string_view rawspeed::ByteStream::getString ( )
inlinenodiscard

Definition at line 210 of file ByteStream.h.

References rawspeed::implicit_cast(), peekString(), and skipBytes().

Here is the call graph for this function:

◆ getSubStream() [1/2]

ByteStream rawspeed::ByteStream::getSubStream ( size_type offset) const
inlinenodiscard

Definition at line 59 of file ByteStream.h.

References ByteStream(), rawspeed::DataBuffer::DataBuffer(), rawspeed::DataBuffer::getByteOrder(), and rawspeed::Buffer::getSubView().

Here is the call graph for this function:

◆ getSubStream() [2/2]

ByteStream rawspeed::ByteStream::getSubStream ( size_type offset,
size_type size_ ) const
inlinenodiscard

Definition at line 54 of file ByteStream.h.

References ByteStream(), rawspeed::DataBuffer::DataBuffer(), rawspeed::DataBuffer::getByteOrder(), and rawspeed::Buffer::getSubView().

Referenced by rawspeed::SamsungV2Decompressor::SamsungV2Decompressor(), rawspeed::TiffEntry::TiffEntry(), rawspeed::IiqDecoder::CorrectPhaseOneC(), rawspeed::CiffEntry::Create(), rawspeed::IiqDecoder::decodeRawInternal(), rawspeed::RafDecoder::decodeRawInternal(), LLVMFuzzerTestOneInput(), rawspeed::ArwDecoder::ParseA100WB(), rawspeed::CiffParser::parseData(), rawspeed::FiffParser::parseData(), rawspeed::MrwDecoder::parseHeader(), rawspeed::TiffIFD::parseMakerNote(), and peekStream().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSubView() [1/2]

Buffer rawspeed::Buffer::getSubView ( size_type offset) const
inlinenodiscardinherited

Definition at line 85 of file Buffer.h.

References Buffer(), getSize(), getSubView(), isValid(), and ThrowIOE.

Here is the call graph for this function:

◆ getSubView() [2/2]

Buffer rawspeed::Buffer::getSubView ( size_type offset,
size_type size_ ) const
inlinenodiscardinherited

◆ getU16()

◆ getU32()

uint32_t rawspeed::ByteStream::getU32 ( )
inline

Definition at line 196 of file ByteStream.h.

References get().

Referenced by rawspeed::CiffIFD::CiffIFD(), rawspeed::DngOpcodes::DeltaRowOrCol< S >::DeltaRowOrCol(), rawspeed::DngOpcodes::DngOpcodes(), rawspeed::DngOpcodes::FixBadPixelsConstant::FixBadPixelsConstant(), rawspeed::DngOpcodes::FixBadPixelsList::FixBadPixelsList(), rawspeed::DngOpcodes::PixelOpcode::PixelOpcode(), rawspeed::DngOpcodes::PolynomialMap::PolynomialMap(), rawspeed::DngOpcodes::ROIOpcode::ROIOpcode(), rawspeed::DngOpcodes::TableMap::TableMap(), rawspeed::TiffEntry::TiffEntry(), rawspeed::TiffIFD::TiffIFD(), rawspeed::SamsungV0Decompressor::computeStripes(), rawspeed::IiqDecoder::CorrectPhaseOneC(), rawspeed::IiqDecoder::CorrectQuadrantMultipliersCombined(), rawspeed::CiffEntry::Create(), CreateCFA(), createPrefixCode(), CreateRawImage(), rawspeed::IiqDecoder::decodeRawInternal(), rawspeed::anonymous_namespace{PanasonicV8Decompressor.cpp}::getTrailingStrips(), LLVMFuzzerTestOneInput(), rawspeed::anonymous_namespace{BitVacuumerRoundtrip.cpp}::LLVMFuzzerTestOneInput(), rawspeed::LLVMFuzzerTestOneInput(), rawspeed::TiffParser::parse(), rawspeed::ArwDecoder::ParseA100WB(), rawspeed::CiffParser::parseData(), rawspeed::FiffParser::parseData(), rawspeed::MrwDecoder::parseHeader(), and rawspeed::NefDecoder::parseWhiteBalance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVector()

template<typename T>
std::vector< T > rawspeed::ByteStream::getVector ( int nElt)
inline

Definition at line 173 of file ByteStream.h.

References getStream(), invariant, and rawspeed::T().

Referenced by rawspeed::LLVMFuzzerTestOneInput().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasPatternAt()

bool rawspeed::ByteStream::hasPatternAt ( std::string_view pattern,
size_type relPos ) const
inlinenodiscard

Definition at line 135 of file ByteStream.h.

References assert(), rawspeed::Buffer::getSubView(), rawspeed::implicit_cast(), rawspeed::Buffer::isValid(), and pos.

Referenced by rawspeed::getTiffByteOrder(), hasPrefix(), rawspeed::TiffIFD::parseMakerNote(), and rawspeed::NefDecoder::parseWhiteBalance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasPrefix()

bool rawspeed::ByteStream::hasPrefix ( std::string_view prefix) const
inlinenodiscard

Definition at line 145 of file ByteStream.h.

References hasPatternAt().

Referenced by rawspeed::TiffIFD::parseMakerNote(), and skipPrefix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValid()

bool rawspeed::Buffer::isValid ( size_type offset,
size_type count = 1 ) const
inlinenodiscardinherited

Definition at line 117 of file Buffer.h.

References getSize().

Referenced by rawspeed::ByteStream::check(), getSubView(), getSubView(), and rawspeed::ByteStream::hasPatternAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator Array1DRef< const uint8_t >()

rawspeed::Buffer::operator Array1DRef< const uint8_t > ( ) const
inlineexplicitinherited

Definition at line 74 of file Buffer.h.

References getAsArray1DRef().

Here is the call graph for this function:

◆ operator[]()

uint8_t rawspeed::Buffer::operator[] ( size_type offset) const
inlineinherited

Definition at line 94 of file Buffer.h.

References getAsArray1DRef().

Here is the call graph for this function:

◆ peek()

template<typename T>
T rawspeed::ByteStream::peek ( size_type i = 0) const
inlinenodiscard

Definition at line 156 of file ByteStream.h.

References rawspeed::DataBuffer::get(), pos, and rawspeed::T().

Referenced by get(), peekByte(), peekU16(), and peekU32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peekBuffer()

Buffer rawspeed::ByteStream::peekBuffer ( size_type size_) const
inlinenodiscard

Definition at line 100 of file ByteStream.h.

References rawspeed::Buffer::getSubView(), and pos.

Referenced by getBuffer(), and peekString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peekByte()

uint8_t rawspeed::ByteStream::peekByte ( size_type i = 0) const
inlinenodiscard

Definition at line 183 of file ByteStream.h.

References peek().

Referenced by rawspeed::peekMarker().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peekData()

const uint8_t * rawspeed::ByteStream::peekData ( size_type count) const
inlinenodiscard

Definition at line 92 of file ByteStream.h.

References rawspeed::Buffer::begin(), rawspeed::Buffer::getSubView(), and pos.

Referenced by rawspeed::MosDecoder::decodeMetaDataInternal(), rawspeed::NefDecoder::DecodeNikonSNef(), and getData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peekRemainingBuffer()

Buffer rawspeed::ByteStream::peekRemainingBuffer ( ) const
inlinenodiscard

◆ peekStream() [1/2]

ByteStream rawspeed::ByteStream::peekStream ( size_type nmemb,
size_type size_ ) const
inlinenodiscard

Definition at line 114 of file ByteStream.h.

References ByteStream(), peekStream(), and ThrowIOE.

Here is the call graph for this function:

◆ peekStream() [2/2]

ByteStream rawspeed::ByteStream::peekStream ( size_type size_) const
inlinenodiscard

Definition at line 111 of file ByteStream.h.

References ByteStream(), getSubStream(), and pos.

Referenced by rawspeed::PanasonicV4Decompressor::PanasonicV4Decompressor(), rawspeed::PanasonicV5Decompressor::PanasonicV5Decompressor(), rawspeed::PanasonicV6Decompressor::PanasonicV6Decompressor(), rawspeed::PanasonicV7Decompressor::PanasonicV7Decompressor(), rawspeed::SamsungV0Decompressor::SamsungV0Decompressor(), rawspeed::SonyArw2Decompressor::SonyArw2Decompressor(), rawspeed::SonyArw2Decompressor::decompressRow(), getStream(), and peekStream().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peekString()

std::string_view rawspeed::ByteStream::peekString ( ) const
inlinenodiscard

Definition at line 199 of file ByteStream.h.

References rawspeed::Buffer::begin(), rawspeed::Buffer::end(), getRemainSize(), peekBuffer(), and ThrowIOE.

Referenced by rawspeed::MosDecoder::decodeMetaDataInternal(), and getString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peekU16()

uint16_t rawspeed::ByteStream::peekU16 ( ) const
inlinenodiscard

Definition at line 188 of file ByteStream.h.

References peek().

Here is the call graph for this function:

◆ peekU32()

uint32_t rawspeed::ByteStream::peekU32 ( size_type i = 0) const
inlinenodiscard

Definition at line 190 of file ByteStream.h.

References peek().

Here is the call graph for this function:

◆ setByteOrder()

Endianness rawspeed::DataBuffer::setByteOrder ( Endianness endianness_)
inlineinherited

Definition at line 156 of file Buffer.h.

References endianness.

Referenced by rawspeed::DngOpcodes::DngOpcodes(), rawspeed::ArwDecoder::DecodeARW2(), rawspeed::TiffParser::parse(), rawspeed::ArwDecoder::ParseA100WB(), rawspeed::TiffIFD::parseMakerNote(), and rawspeed::NefDecoder::parseWhiteBalance().

Here is the caller graph for this function:

◆ setPosition()

void rawspeed::ByteStream::setPosition ( size_type newPos)
inline

Definition at line 83 of file ByteStream.h.

References check(), and pos.

Referenced by rawspeed::CiffIFD::CiffIFD(), rawspeed::DngOpcodes::DngOpcodes(), rawspeed::DngOpcodes::FixBadPixelsList::FixBadPixelsList(), rawspeed::TiffIFD::TiffIFD(), rawspeed::IiqDecoder::CorrectPhaseOneC(), rawspeed::IiqDecoder::decodeRawInternal(), rawspeed::OrfDecoder::handleSlices(), rawspeed::MrwDecoder::parseHeader(), and rawspeed::TiffIFD::parseIFDEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ skipBytes() [1/2]

◆ skipBytes() [2/2]

void rawspeed::ByteStream::skipBytes ( size_type nmemb,
size_type size_ )
inline

Definition at line 131 of file ByteStream.h.

References check(), and pos.

Here is the call graph for this function:

◆ skipPrefix()

bool rawspeed::ByteStream::skipPrefix ( std::string_view prefix)
inline

Definition at line 149 of file ByteStream.h.

References hasPrefix(), and pos.

Referenced by rawspeed::MosDecoder::decodeMetaDataInternal(), and rawspeed::TiffIFD::parseMakerNote().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ data

const uint8_t* rawspeed::Buffer::data = nullptr
protectedinherited

Definition at line 52 of file Buffer.h.

Referenced by Buffer(), and getAsArray1DRef().

◆ endianness

Endianness rawspeed::DataBuffer::endianness = Endianness::little
privateinherited

Definition at line 136 of file Buffer.h.

Referenced by DataBuffer(), get(), getByteOrder(), and setByteOrder().

◆ pos

◆ size

size_type rawspeed::Buffer::size = 0
privateinherited

Definition at line 55 of file Buffer.h.

Referenced by Buffer(), getAsArray1DRef(), and getSize().


The documentation for this class was generated from the following file: