static char * getfilename(void) { char *s; int d; unsigned char i; if (!refill(1)) { fprintf(stderr, "%s: Error reading file\n", progname); exit(EXIT_FAILURE); } i = (unsigned char) *bufferpos; bufferpos++; bufferlen--; if (i == 0) return NULL; d = ((i & 0x80) != 0); i = (i & 0x7F) - 1; if (d != 0) { s = getstring(); if (filenames[i] != NULL) free(filenames[i]); if ((filenames[i] = (char *) malloc(strlen(s) + 1)) == NULL) { fprintf(stderr, "%s: Out of memory\n", progname); exit(EXIT_FAILURE); } strcpy(filenames[i], s); } return filenames[i]; }
// ****************************************************** uint32_t dmx_demuxerMSDVR::read(uint8_t *w,uint32_t len) { uint32_t mx; // enough in buffer ? if(_pesBufferIndex+len<=_pesBufferLen) { memcpy(w,_pesBuffer+_pesBufferIndex,len); _pesBufferIndex+=len; consumed+=len; return len; } // flush mx=_pesBufferLen-_pesBufferIndex; if(mx) { memcpy(w,_pesBuffer+_pesBufferIndex,mx); _pesBufferIndex+=mx; consumed+=mx; w+=mx; len-=mx; } if(!refill()) { printf("Refill failed at %d \n",_pesBufferStart); _lastErr=1; return 0; } return mx+read(w,len); }
// ------------------------------------------------------- // next level // ------------------------------------------------------- void Board::nextLevel(int level) { _hover = -1; _killed = 0; _maxBombs = level * 2; refill(); _grid.decrementBombs(); }
int ScanStreamBase::get( void ) //----------------------------- { REQUIRE( !_error, "ScanStreamBase::get with _error ! " ); if( _eof ) { return EOF; } if( _usePrev ) { _usePrev = false; _eof = _prevEOF; return _prevChar; } int ret = _buffer[ _currPos ]; _currPos += 1; if( _currPos > _endPos ) { refill(); } if( ret == '\n' ) { _line += 1; } return ret; }
VorbisStream::VorbisStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) : _inStream(inStream), _disposeAfterUse(dispose), _length(0, 1000), _bufferEnd(_buffer + ARRAYSIZE(_buffer)) { int res = ov_open_callbacks(inStream, &_ovFile, NULL, 0, g_stream_wrap); if (res < 0) { warning("Could not create Vorbis stream (%d)", res); _pos = _bufferEnd; return; } // Read in initial data if (!refill()) return; // Setup some header information _isStereo = ov_info(&_ovFile, -1)->channels >= 2; _rate = ov_info(&_ovFile, -1)->rate; #ifdef USE_TREMOR _length = Timestamp(ov_time_total(&_ovFile, -1), getRate()); #else _length = Timestamp(uint32(ov_time_total(&_ovFile, -1) * 1000.0), getRate()); #endif }
/** \fn peek */ bool ADM_audioStreamBuffered::peek(uint32_t n,uint8_t *d) { if(start+n>=limit) refill(); if(start+n>=limit) return false; memcpy(d,buffer.at(start),n); return true; }
ScanStreamFile::ScanStreamFile( const char * fname ) : ScanStreamBase() , _fileName( fname ) //-------------------------------------------------- { char buffer[ _MAX_PATH ]; _handle = open( fname, O_TEXT | O_RDONLY ); for( int i = 0; i < _searchPaths.count() && _handle < 0 && errno == ENOENT; i += 1 ) { strcpy( buffer, _searchPaths[ i ] ); char c = buffer[ strlen( buffer ) - 1 ]; if( !strchr( PathDelim, c ) ) { strcat( buffer, "/" ); } strcat( buffer, fname ); _handle = open( buffer, O_TEXT | O_RDONLY ); } if( _handle < 0 ) { if( errno != ENOENT ) { errMessage( "ScanStream::Streamfile - [%s]: %s", fname, strerror( errno ) ); } else { _error = true; } } else { _endPos = SECTOR_SIZE; // so refill won't think eof. refill(); } }
int FS_getChar(int dev) { struct FileStream *f; if (opened(dev, 1) == -1) { return -1; } f = g_file[dev]; if (f->inSize == f->inCapacity && refill(dev) == -1) { return -1; } FS_errmsg = (const char *)0; if (f->inSize + 1 == f->inCapacity) { char ch = f->inBuf[f->inSize]; f->inSize = f->inCapacity = 0; return ch; } else { return f->inBuf[f->inSize++]; } }
/** \fn getNextFrame */ bool resampleFps::getNextFrame(uint32_t *fn,ADMImage *image) { if(!prefillDone) // Empty, need 1/ to refill, 2/ to rebase { if(false==refill()) return false; baseTime=frames[1]->Pts; // We start at the first frame if(false==refill()) return false; prefillDone=true; } float offset=configuration.newFpsDen; offset*=1000000LL; offset*=nextFrame; offset=(offset+(configuration.newFpsNum/2-1))/configuration.newFpsNum; uint64_t thisTime=baseTime+(uint64_t)offset; again: uint64_t frame1Dts=frames[0]->Pts; uint64_t frame2Dts=frames[1]->Pts; aprintf("Frame : %d, timeIncrement %d ms, Wanted : %" PRIu64", available %" PRIu64" and %" PRIu64"\n", nextFrame,info.frameIncrement/1000,thisTime,frame1Dts,frame2Dts); if(thisTime>frame1Dts && thisTime>frame2Dts) { if(false==refill()) return false; goto again; } if(thisTime<frame1Dts && thisTime<frame2Dts) { image->duplicate(frames[0]); image->Pts=thisTime; *fn=nextFrame++; return true; } // In between, take closer double diff1=(double)thisTime-double(frame1Dts); double diff2=(double)thisTime-double(frame2Dts); if(diff1<0) diff1=-diff1; if(diff2<0) diff2=-diff2; int index=1; if(diff1<diff2) index=0; image->duplicate(frames[index]); image->Pts=thisTime; *fn=nextFrame++; return true; }
/** \fn needBytes */ bool ADM_audioStreamBuffered::needBytes(uint32_t nbBytes) { while(1) { if((limit-start)>=nbBytes) return true; if(false==refill()) return false; } }
int DialogSocket::peek() { refill(); if (_pNext != _pEnd) return std::char_traits<char>::to_int_type(*_pNext); else return EOF_CHAR; }
int32_t BufferedReader::peek() { if (bufferPosition >= bufferLength) { if (refill() == READER_EOF) { return READER_EOF; } } return buffer[bufferPosition]; }
//! most important function to get one frame data plus frame type, used in getNextBundledAccessUnits() int32 bitstreamObject::getNextFrame(uint8* frameBuffer, uint8& frame_type, bool bHeaderIncluded) { PVMF_AMRPARSER_LOGDEBUG((0, "GetNextFrame In ipos=%d, iBytesRead=%d, iBytesProcessed=%d, iActualSize=%d, iFileSize=%d", iPos, iBytesRead, iBytesProcessed, iActual_size, iFileSize)); if (!frameBuffer) { return bitstreamObject::MISC_ERROR; } int32 ret_value = bitstreamObject::EVERYTHING_OK; // Need to refill? if (iFileSize == 0 || iPos >= iActual_size) { ret_value = refill(); if (ret_value) { return ret_value; } } int32 frame_size = 0; uint8 *pBuffer = &iBuffer[iPos]; if (EAMRIETF_SingleNB == iAmrFormat) // IETF format single channel NB { // Search the next IETF frame header (NOT returning error when the error is corrupt) while ((iBuffer[iPos] & 0x83) != 0) { // Wrong IETF frame header(P+FT(4bits)+Q+PP) if (iPos + 1 >= iActual_size) { ret_value = refill(); if (ret_value) { return ret_value; } } iPos++; iBytesProcessed++; } pBuffer = &iBuffer[iPos]; frame_type = (uint8)((pBuffer[0] >> 3) & 0x0f); frame_size = IetfDecInputBytes[(uint16)frame_type]; } else if (EAMRIETF_SingleWB == iAmrFormat) // IETF format single channel WB
void CanvasLayout::removeObjects(const std::vector<int>& ids) { if (ids.empty()) return; for (auto it = ids.begin(); it != ids.end(); ++it) removeObject(*it); refill(); updateBox(); }
int StompSocket::get() { refill(); //std::cout << "get()==" << *_pNext << "(" << ((int) *_pNext) << ")" << std::endl; if (_pNext != _pEnd) return std::char_traits<char>::to_int_type(*_pNext++); else return EOF_CHAR; }
/// Return the next element in the chunk. inline std::vector<flexible_type>&& sframe_reader_buffer::next() { if (m_buffer_pos == m_buffer.size()) { refill(); m_buffer_pos = 0; } DASSERT_LT(m_buffer_pos, m_buffer.size()); ++m_iter; return std::move(m_buffer[m_buffer_pos++]); }
T&& sarray_reader_buffer<T>::next() { if (m_buffer_pos == m_buffer.size()) { refill(); m_buffer_pos = 0; } DASSERT_LT(m_buffer_pos, m_buffer.size()); ++m_iter; return std::move(m_buffer[m_buffer_pos++]); }
int DialogSocket::receiveRawBytes(void* buffer, int length) { refill(); int n = static_cast<int>(_pEnd - _pNext); if (n > length) n = length; std::memcpy(buffer, _pNext, n); _pNext += n; return n; }
ThumbWidget::ThumbWidget(const SVGInfo &info, bool compare, QWidget *parent) : QWidget(parent) { setupUi(this); #ifdef Q_OS_WIN frame->setFrameShadow(QFrame::Plain); #endif refill(info, compare); }
void RandomArray::allocate() { if(_array == nullptr) { size_t arraySize = 1 << (sizeof(decltype(_sharedIdx)) * 8); _array = new double[arraySize]; refill(); } }
CLUInputStream::CLUInputStream(Common::File *file, int size) : _file(file), _firstTime(true), _bufferEnd(_outbuf + BUFFER_SIZE) { // Determine the end position. _file_pos = _file->pos(); _end_pos = _file_pos + size; // Read in initial data refill(); }
int HTTPSession::peek() { if (_pCurrent == _pEnd) refill(); if (_pCurrent < _pEnd) return *_pCurrent; else return std::char_traits<char>::eof(); }
void SpecialBonusGuided::trigger() { if(nbActivation > 0) { --nbActivation; spaceship->shotGuidedBonus(); if(nbActivation == 0) QTimer::singleShot(timeToWait,this,SLOT(refill())); } }
void KBookmarkMenu::slotAboutToShow() { // Did the bookmarks change since the last time we showed them ? if (m_bDirty) { m_bDirty = false; clear(); refill(); m_parentMenu->adjustSize(); } }
/// Return the next element in the chunk. inline const sframe_rows::row& sframe_reader_buffer::next() { if (m_buffer_pos == m_buffer.num_rows()) { refill(); m_buffer_pos = 0; } DASSERT_LT(m_buffer_pos, m_buffer.num_rows()); ++m_iter; m_current.copy_reference(m_buffer[m_buffer_pos++]); return m_current; }
bool VorbisStream::seek(const Timestamp &where) { // Vorbisfile uses the sample pair number, thus we always use "false" for the isStereo parameter // of the convertTimeToStreamPos helper. int res = ov_pcm_seek(&_ovFile, convertTimeToStreamPos(where, getRate(), false).totalNumberOfFrames()); if (res) { warning("Error seeking in Vorbis stream (%d)", res); _pos = _bufferEnd; return false; } return refill(); }
void skip(size_t len) { while (len) { size_t chunk_size = MIN(len, buffer_used); if (chunk_size) { buffer_ptr = reinterpret_cast<char*>(buffer_ptr) + chunk_size; buffer_used -= chunk_size; len -= chunk_size; } if (! len) break; refill(); } }
//! specially used in ResetPlayback(), re-position the file pointer int32 bitstreamObject::reset(int32 filePos) { iFrame_type = 0; iBytesRead = iInitFilePos + filePos; // set the initial value iBytesProcessed = iBytesRead; if (ipAMRFile) { ipAMRFile->Seek(iInitFilePos + filePos, Oscl_File::SEEKSET); } iPos = bitstreamObject::MAIN_BUFF_SIZE + bitstreamObject::SECOND_BUFF_SIZE; return refill(); }
void CPlayerStatsDlg::OnHdnItemclickStats(NMHDR *pNMHDR, LRESULT *pResult) { LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR); if (phdr->iItem == sortBy) sortUp = !sortUp; else { sortBy = phdr->iItem; sortUp = false; } refill (); *pResult = 0; }
static int fun_A(int *bitfill) { int ret; static int tab[] = { 12, 13, 14, 15, 16, 17, 18, 19, -12, -13, -14, -15, -16, -17, -18, -19, -19 }; ret = tab[nbits(bitfill, 4)]; refill(bitfill); return ret; }