예제 #1
0
파일: Filing.hpp 프로젝트: allogn/TOUCH
	inline 	std::string BufferedFileReader::readString()
	{
		if (m_bEOF) throw EndOfStreamException("");

		std::string::size_type len;
		m_file.read(reinterpret_cast<char*>(&len), sizeof(std::string::size_type));
		if (! m_file.good())
		{
			m_bEOF = true;
			throw EndOfStreamException("");
		}

		std::string::value_type* buf = new std::string::value_type[len];
		m_file.read(reinterpret_cast<char*>(buf), len * sizeof(std::string::value_type));
		if (! m_file.good())
		{
			delete[] buf;
			m_bEOF = true;
			throw EndOfStreamException("");
		}

		std::string ret(buf, len);
		delete[] buf;

		return ret;
	}
예제 #2
0
파일: Filing.hpp 프로젝트: allogn/TOUCH
	inline void BufferedFileReader::readBytes(uint32_t u32Len, byte** pData)
	{
		if (m_bEOF) throw EndOfStreamException("");

		*pData = new byte[u32Len];
		m_file.read(reinterpret_cast<char*>(*pData), u32Len);
		if (! m_file.good())
		{
			delete[] *pData;
			m_bEOF = true;
			throw EndOfStreamException("");
		}
	}
예제 #3
0
파일: Filing.hpp 프로젝트: allogn/TOUCH
	inline bool BufferedFileReader::readBoolean()
	{
		if (m_bEOF) throw EndOfStreamException("");

		bool ret;
		m_file.read(reinterpret_cast<char*>(&ret), sizeof(bool));
		if (! m_file.good())
		{
			m_bEOF = true;
			throw EndOfStreamException("");
		}
		return ret;
	}
예제 #4
0
파일: Filing.hpp 프로젝트: allogn/TOUCH
	inline float BufferedFileReader::readFloat()
	{
		if (m_bEOF) throw EndOfStreamException("");

		float ret;
		m_file.read(reinterpret_cast<char*>(&ret), sizeof(float));
		if (! m_file.good())
		{
                    m_bEOF = true;
			throw EndOfStreamException("");
		}
		return ret;
	}
예제 #5
0
파일: Filing.hpp 프로젝트: allogn/TOUCH
	inline uint64_t BufferedFileReader::readUInt64()
	{
		if (m_bEOF) throw EndOfStreamException("");

		uint64_t ret;
		m_file.read(reinterpret_cast<char*>(&ret), sizeof(uint64_t));
		if (! m_file.good())
		{
			m_bEOF = true;
			throw EndOfStreamException("");
		}
		return ret;
	}
예제 #6
0
void IWORKMemoryStream::read(const RVNGInputStreamPtr_t &input, const unsigned length)
{
  if (0 == length)
    return;
  if (!bool(input))
    throw EndOfStreamException();

  unsigned long readBytes = 0;
  const unsigned char *const data = input->read(length, readBytes);
  if (length != readBytes)
    throw EndOfStreamException();

  m_length = (long) length;
  assign(data, length);
}
예제 #7
0
파일: Filing.hpp 프로젝트: allogn/TOUCH
	inline double BufferedFileReader::readDouble()
	{
		if (m_bEOF) throw EndOfStreamException("");
                if (! m_file.good ())
                {
                    m_bEOF = true;
                    throw EndOfStreamException ("");
                }

		double ret;
		m_file.read(reinterpret_cast<char*>(&ret), sizeof(double));
		if (! m_file.good())
		{
			m_bEOF = true;
			throw EndOfStreamException("");
		}
		return ret;
	}
 void syncPts() throw(EndOfStreamException)
 {
     if (!hasPacket())
         throw EndOfStreamException();
     sampleBufferSize = 0;
     if (packet.pts != AV_NOPTS_VALUE)
         sampleBufferStart = uint64_t(floor(ptsToTime(packet.pts) * pCodecCtx->sample_rate));
     
     if (sampleBufferStart > streamSize)
         streamSize = sampleBufferStart;
 }
uint8_t readU8(const RVNGInputStreamPtr &input, bool /* bigEndian */)
{
  checkStream(input);

  unsigned long numBytesRead;
  uint8_t const *p = input->read(sizeof(uint8_t), numBytesRead);

  if (p && numBytesRead == sizeof(uint8_t))
    return *(uint8_t const *)(p);
  throw EndOfStreamException();
}
const unsigned char *readNBytes(const RVNGInputStreamPtr &input, const unsigned long numBytes)
{
  checkStream(input);

  unsigned long readBytes = 0;
  const unsigned char *const s = input->read(numBytes, readBytes);

  if (numBytes != readBytes)
    throw EndOfStreamException();

  return s;
}
uint64_t readU64(const RVNGInputStreamPtr &input, bool bigEndian)
{
  checkStream(input);

  unsigned long numBytesRead;
  uint8_t const *p = input->read(sizeof(uint64_t), numBytesRead);

  if (p && numBytesRead == sizeof(uint64_t))
  {
    if (bigEndian)
      return (uint64_t)p[7]|((uint64_t)p[6]<<8)|((uint64_t)p[5]<<16)|((uint64_t)p[4]<<24)|((uint64_t)p[3]<<32)|((uint64_t)p[2]<<40)|((uint64_t)p[1]<<48)|((uint64_t)p[0]<<56);
    return (uint64_t)p[0]|((uint64_t)p[1]<<8)|((uint64_t)p[2]<<16)|((uint64_t)p[3]<<24)|((uint64_t)p[4]<<32)|((uint64_t)p[5]<<40)|((uint64_t)p[6]<<48)|((uint64_t)p[7]<<56);
  }
  throw EndOfStreamException();
}
uint16_t readU16(const RVNGInputStreamPtr &input, bool bigEndian)
{
  checkStream(input);

  unsigned long numBytesRead;
  uint8_t const *p = input->read(sizeof(uint16_t), numBytesRead);

  if (p && numBytesRead == sizeof(uint16_t))
  {
    if (bigEndian)
      return static_cast<uint16_t>((uint16_t)p[1]|((uint16_t)p[0]<<8));
    return static_cast<uint16_t>((uint16_t)p[0]|((uint16_t)p[1]<<8));
  }
  throw EndOfStreamException();
}
            void readPacket() throw(EndOfStreamException)
            {
                // Read the next packet, skipping all packets that aren't for this stream
                #if (LIBAVCODEC_VERSION_MAJOR >= 53)
                packet.size = packetBufferSize;
                packet.data = packetBuffer;
                #endif
                do {
                    // Free old packet
                    if (packet.data != NULL)
                        av_free_packet( &packet );
                    
                    // Read new packet
                    if(av_read_frame(pFormatCtx, &packet) < 0)
                        throw EndOfStreamException();
                } while(packet.stream_index != streamIndex);
        
                packetBufferSize = packet.size;
                packetBuffer = packet.data;

                if (packet.pts != AV_NOPTS_VALUE)
                    sampleBufferStart = uint64_t(floor(ptsToTime(packet.pts) * pCodecCtx->sample_rate));
            }