本文整理汇总了C++中FileReader::Tell方法的典型用法代码示例。如果您正苦于以下问题:C++ FileReader::Tell方法的具体用法?C++ FileReader::Tell怎么用?C++ FileReader::Tell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader::Tell方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file_seek
sf_count_t SndFileDecoder::file_seek(sf_count_t offset, int whence, void *user_data)
{
FileReader *reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
if(reader->Seek((long)offset, whence) != 0)
return -1;
return reader->Tell();
}
示例2: Init
bool Init(const String& path)
{
File file;
if(!file.OpenRead(path))
return false;
FileReader stream = FileReader(file);
WavHeader riff;
stream << riff;
if(riff != "RIFF")
return false;
char riffType[4];
stream.SerializeObject(riffType);
if(strncmp(riffType, "WAVE", 4) != 0)
return false;
while(stream.Tell() < stream.GetSize())
{
WavHeader chunkHdr;
stream << chunkHdr;
if(chunkHdr == "fmt ")
{
stream << m_format;
//Logf("Sample format: %s", Logger::Info, (m_format.nFormat == 1) ? "PCM" : "Unknown");
//Logf("Channels: %d", Logger::Info, m_format.nChannels);
//Logf("Sample rate: %d", Logger::Info, m_format.nSampleRate);
//Logf("Bps: %d", Logger::Info, m_format.nBitsPerSample);
}
else if(chunkHdr == "data") // data Chunk
{
// validate header
if(m_format.nFormat != 1)
return false;
if(m_format.nChannels > 2 || m_format.nChannels == 0)
return false;
if(m_format.nBitsPerSample != 16)
return false;
// Read data
m_length = chunkHdr.nLength / sizeof(short);
m_pcm.resize(chunkHdr.nLength);
stream.Serialize(m_pcm.data(), chunkHdr.nLength);
}
else
{
stream.Skip(chunkHdr.nLength);
}
}
// Calculate the sample step if the rate is not the same as the output rate
double sampleStep = (double)m_format.nSampleRate / (double)m_audio->GetSampleRate();
m_sampleStepIncrement = (uint64)(sampleStep * (double)fp_sampleStep);
return true;
}
示例3: if
off_t MPG123Decoder::file_lseek(void *handle, off_t offset, int whence)
{
FileReader *reader = reinterpret_cast<MPG123Decoder*>(handle)->Reader;
if(whence == SEEK_CUR)
{
if(offset < 0 && reader->Tell()+offset < 0)
return -1;
}
else if(whence == SEEK_END)
{
if(offset < 0 && reader->GetLength()+offset < 0)
return -1;
}
if(reader->Seek(offset, whence) != 0)
return -1;
return reader->Tell();
}
示例4: if
off_t MPG123Decoder::file_lseek(void *handle, off_t offset, int whence)
{
MPG123Decoder *self = reinterpret_cast<MPG123Decoder*>(handle);
FileReader *reader = self->Reader;
if(whence == SEEK_SET)
offset += self->StartOffset;
else if(whence == SEEK_CUR)
{
if(offset < 0 && reader->Tell()+offset < self->StartOffset)
return -1;
}
else if(whence == SEEK_END)
{
if(offset < 0 && reader->GetLength()+offset < self->StartOffset)
return -1;
}
if(reader->Seek(offset, whence) != 0)
return -1;
return reader->Tell() - self->StartOffset;
}
示例5:
virtual char *Gets(char *strbuf, int len)
{
if (len <= 0 || FilePos >= StartPos + Length) return NULL;
char *p = mReader->Gets(strbuf, len);
if (p != NULL)
{
int old = FilePos;
FilePos = (long)mReader->Tell();
if (FilePos - StartPos > Length)
{
strbuf[Length - old + StartPos] = 0;
}
}
return p;
}
示例6: Seek
virtual long Seek(long offset, int origin)
{
switch (origin)
{
case SEEK_SET:
offset += StartPos;
break;
case SEEK_END:
offset += StartPos + Length;
break;
case SEEK_CUR:
offset += (long)mReader->Tell();
break;
}
if (offset < StartPos || offset > StartPos + Length) return -1; // out of scope
if (mReader->Seek(offset, FileReader::SeekSet) == 0)
{
FilePos = offset;
return 0;
}
return -1;
}
示例7: MAKE_ID
//.........这里部分代码省略.........
lump.Read(&hotx, 4);
lump.Read(&hoty, 4);
ihotx = BigLong((int)hotx);
ihoty = BigLong((int)hoty);
if (ihotx < -32768 || ihotx > 32767)
{
Printf ("X-Offset for PNG texture %s is bad: %d (0x%08x)\n", Wads.GetLumpFullName (lumpnum), ihotx, ihotx);
ihotx = 0;
}
if (ihoty < -32768 || ihoty > 32767)
{
Printf ("Y-Offset for PNG texture %s is bad: %d (0x%08x)\n", Wads.GetLumpFullName (lumpnum), ihoty, ihoty);
ihoty = 0;
}
LeftOffset = ihotx;
TopOffset = ihoty;
}
break;
case MAKE_ID('P','L','T','E'):
PaletteSize = MIN<int> (len / 3, 256);
lump.Read (p.pngpal, PaletteSize * 3);
if (PaletteSize * 3 != (int)len)
{
lump.Seek (len - PaletteSize * 3, SEEK_CUR);
}
for (i = PaletteSize - 1; i >= 0; --i)
{
p.palette[i] = MAKERGB(p.pngpal[i][0], p.pngpal[i][1], p.pngpal[i][2]);
}
break;
case MAKE_ID('t','R','N','S'):
lump.Read (trans, len);
HaveTrans = true;
// Save for colortype 2
NonPaletteTrans[0] = uint16_t(trans[0] * 256 + trans[1]);
NonPaletteTrans[1] = uint16_t(trans[2] * 256 + trans[3]);
NonPaletteTrans[2] = uint16_t(trans[4] * 256 + trans[5]);
break;
case MAKE_ID('a','l','P','h'):
bAlphaTexture = true;
bMasked = true;
break;
}
lump.Seek(4, SEEK_CUR); // Skip CRC
lump.Read(&len, 4);
id = MAKE_ID('I','E','N','D');
lump.Read(&id, 4);
}
StartOfIDAT = lump.Tell() - 8;
switch (colortype)
{
case 4: // Grayscale + Alpha
bMasked = true;
// intentional fall-through
case 0: // Grayscale
if (!bAlphaTexture)
{
if (colortype == 0 && HaveTrans && NonPaletteTrans[0] < 256)
{
bMasked = true;
PaletteSize = 256;
PaletteMap = new uint8_t[256];
memcpy (PaletteMap, GrayMap, 256);
PaletteMap[NonPaletteTrans[0]] = 0;
}
else
{
PaletteMap = GrayMap;
}
}
break;
case 3: // Paletted
PaletteMap = new uint8_t[PaletteSize];
GPalette.MakeRemap (p.palette, PaletteMap, trans, PaletteSize);
for (i = 0; i < PaletteSize; ++i)
{
if (trans[i] == 0)
{
bMasked = true;
PaletteMap[i] = 0;
}
}
break;
case 6: // RGB + Alpha
bMasked = true;
break;
case 2: // RGB
bMasked = HaveTrans;
break;
}
}
示例8: file_tell
sf_count_t SndFileDecoder::file_tell(void *user_data)
{
FileReader *reader = reinterpret_cast<SndFileDecoder*>(user_data)->Reader;
return reader->Tell();
}