MCPcopy Create free account
hub / github.com/IENT/YUView / seek

Method seek

YUViewLib/src/filesource/FileSourceAnnexBFile.cpp:237–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237bool FileSourceAnnexBFile::seek(int64_t pos)
238{
239 if (!isFileOpened)
240 return false;
241
242 DEBUG_ANNEXBFILE("FileSourceAnnexBFile::seek to " << pos);
243 // Seek the file and update the buffer
244 srcFile.seek(pos);
245 this->fileBufferSize = srcFile.read(this->fileBuffer.data(), BUFFERSIZE);
246 if (this->fileBufferSize == 0)
247 // The file is empty of there was an error reading from the file.
248 return false;
249 this->bufferStartPosInFile = pos;
250 this->posInBuffer = 0;
251
252 if (pos == 0)
253 this->seekToFirstNAL();
254 else
255 {
256 // Check if we are at a start code position (001 or 0001)
257 if (this->fileBuffer.at(0) == (char)0 && this->fileBuffer.at(1) == (char)0 && this->fileBuffer.at(2) == (char)0 && this->fileBuffer.at(3) == (char)1)
258 return true;
259 if (this->fileBuffer.at(0) == (char)0 && this->fileBuffer.at(1) == (char)0 && this->fileBuffer.at(2) == (char)1)
260 return true;
261
262 DEBUG_ANNEXBFILE("FileSourceAnnexBFile::seek could not find start code at seek position");
263 return false;
264 }
265
266 return true;
267}

Callers 1

getFrameDataMethod · 0.95

Calls 3

seekToFirstNALMethod · 0.95
dataMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected