Пример #1
0
void FSKDemodulation::generateDemodulation(
    const std::vector<int> &BitesVector) {
  multiBuffer1 = allocateBuffer(this->ttime, this->samplingFrequency);
  multiBuffer2 = allocateBuffer(this->ttime, this->samplingFrequency);
  demodulatedSignal = allocateBuffer(this->ttime, this->samplingFrequency);
  binarySignal = allocateBuffer(this->ttime, this->samplingFrequency);

  int bit = 0, tempBit = 0, i = 0, ii = 0, highFrequency = 0, lowFrequency = 0;
  this->sumHighFrequency = 0;
  this->sumLowFrequency = 0;

  for (auto x : BitesVector) {
    std::cout << i << ". bit's value: " << x << std::endl;
    for (int j = 0; j < 100; j++) {
      bit = (i * 100) + j;
      multiBuffer2[bit] =
          modulatedSignal[bit] * this->amplitude *
          sin((6 * M_PI * (this->signalFrequency / 2) * bit) / 100);
      multiBuffer1[bit] =
          modulatedSignal[bit] * this->amplitude *
          sin((2 * M_PI * (this->signalFrequency / 2) * bit) / 100);

      this->sumHighFrequency += multiBuffer2[bit];
      this->sumLowFrequency += multiBuffer1[bit];

      demodulatedSignal[bit] = this->sumHighFrequency - this->sumLowFrequency;
    }

    this->sumHighFrequency = 0;
    this->sumLowFrequency = 0;
    ++i;
  }

  i = 0;
  for (int k = 0; k < BitesVector.size(); ++k) {
    for (int j = 0; j < 100; j++) {
      bit = (i * 100) + j;
      if (demodulatedSignal[bit] > 0) {
        ++highFrequency;
      } else {
        ++lowFrequency;
      }
    }
    for (int j = 0; j < 100; j++) {
      tempBit = (ii * 100) + j;
      if (highFrequency > lowFrequency) {
        binarySignal[tempBit] = 1;
      } else {
        binarySignal[tempBit] = 0;
      }
    }
    highFrequency = 0;
    lowFrequency = 0;
    ++i;
    ++ii;
  }
  binarySignal[tempBit - 1] = 1.2f;
}
    void GLES2HardwarePixelBuffer::blitFromMemory(const PixelBox &src, const Image::Box &dstBox)
    {
        if (!mBuffer.contains(dstBox))
        {
            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
                        "Destination box out of range",
                        "GLES2HardwarePixelBuffer::blitFromMemory");
        }

        PixelBox scaled;

        if (src.getWidth() != dstBox.getWidth() ||
            src.getHeight() != dstBox.getHeight() ||
            src.getDepth() != dstBox.getDepth())
        {
            // Scale to destination size.
            // This also does pixel format conversion if needed
            allocateBuffer();
            scaled = mBuffer.getSubVolume(dstBox);
            Image::scale(src, scaled, Image::FILTER_BILINEAR);
        }
#if OGRE_PLATFORM != OGRE_PLATFORM_APPLE_IOS
        else if ((src.format != mFormat) ||                 
                 ((GLES2PixelUtil::getGLOriginFormat(src.format) == 0) && (src.format != PF_R8G8B8)))
#else
        else if (GLES2PixelUtil::getGLOriginFormat(src.format) == 0)
#endif
        {
            // Extents match, but format is not accepted as valid source format for GL
            // do conversion in temporary buffer
            allocateBuffer();
            scaled = mBuffer.getSubVolume(dstBox);
            PixelUtil::bulkPixelConversion(src, scaled);
        }
        else
        {
            allocateBuffer();
            // No scaling or conversion needed
            scaled = src;
            if (src.format == PF_R8G8B8)
            {
                scaled.format = PF_B8G8R8;
                PixelUtil::bulkPixelConversion(src, scaled);
            }
#if OGRE_PLATFORM == OGRE_PLATFORM_NACL
            if (src.format == PF_A8R8G8B8)
            {
                scaled.format = PF_A8B8G8R8;
                PixelUtil::bulkPixelConversion(src, scaled);
            }
#endif
        }

        upload(scaled, dstBox);
        freeBuffer();
    }
Пример #3
0
daeString daeStringTable::allocString(daeString string)
{
	if ( string == NULL ) return _empty;
	size_t stringSize = strlen(string) + 1;
	size_t sizeLeft = _stringBufferSize - _stringBufferIndex;
	daeString buf;
	if (sizeLeft < stringSize)
	{
		if (stringSize > _stringBufferSize)
			_stringBufferSize = ((stringSize / _stringBufferSize) + 1) * _stringBufferSize ;
		buf = allocateBuffer();
	}
	else
	{
		buf = _stringBuffersList.get((daeInt)_stringBuffersList.getCount()-1);
	}
	daeChar *str = (char*)buf + _stringBufferIndex;
	memcpy(str,string,stringSize);
	_stringBufferIndex += stringSize;

	int align = sizeof(void*);
	_stringBufferIndex = (_stringBufferIndex+(align-1)) & (~(align-1));

	return str;
}
Пример #4
0
void ReadBuffer::appendBuffer(const unsigned char *message, unsigned int length)
{
  if (start_ + length_ + length > size_)
  {
    unsigned int newSize = length_ + length + initialReadSize_;

    #ifdef TEST
    *logofs << "ReadBuffer: WARNING! Resizing buffer "
            << "for FD#" << transport_ -> fd()
            << " from " << size_ << " to " << newSize
            << " bytes.\n" << logofs_flush;
    #endif

    unsigned char *newBuffer = allocateBuffer(newSize);

    memcpy(newBuffer, buffer_ + start_, length_);

    delete [] buffer_;

    buffer_ = newBuffer;
    size_   = newSize;

    start_ = 0;
  }

  memcpy(buffer_ + start_ + length_, message, length);

  length_ += length;

  transport_ -> pendingReset();

  owner_ = 1;
}
    PixelBox GL3PlusHardwarePixelBuffer::lockImpl( const Image::Box &lockBox, LockOptions options )
    {
        //Allocate memory for the entire image, as the buffer
        //maynot be freed and be reused in subsequent calls.
        allocateBuffer( PixelUtil::getMemorySize( mWidth, mHeight, mDepth, mFormat ) );

        mBuffer = PixelBox( lockBox.getWidth(), lockBox.getHeight(),
                            lockBox.getDepth(), mFormat, mBuffer.data );
        mCurrentLock = mBuffer;
        mCurrentLock.left    = lockBox.left;
        mCurrentLock.right  += lockBox.left;
        mCurrentLock.top     = lockBox.top;
        mCurrentLock.bottom += lockBox.top;

        if(options != HardwareBuffer::HBL_DISCARD)
        {
            // Download the old contents of the texture
            download( mCurrentLock );
        }
        mCurrentLockOptions = options;
        mLockedBox = lockBox;
        mCurrentLock = mBuffer;

        return mBuffer;
    }
Пример #6
0
void ArrayBase::load(std::istream &inStream) {
  std::string tag;
  size_t count;

  NTA_CHECK(inStream.get() == '[')
      << "Binary load of Array, expected starting '['.";
  inStream >> count;
  inStream >> tag;
  type_ = BasicType::parse(tag);
  if (count > 0 && type_ == NTA_BasicType_SDR) {
    SDR *sdr = new SDR();
    sdr->load(inStream);
    std::shared_ptr<char> sp((char *)(sdr));
    buffer_ = sp;
    count_ = sdr->size;
    capacity_ = sdr->size;
  } else {
    allocateBuffer(count);
    inStream.ignore(1);
    inStream.read(buffer_.get(), capacity_);
  }
  NTA_CHECK(inStream.get() == ']')
      << "Binary load of Array, expected ending ']'.";
  inStream.ignore(1); // skip over the endl
}
/** @brief Contruct a new string from an existing numeric value
 
 @param const long value: The numeric value to create the string from
 @param const int base: The base of the number system used to convert the value (2|8|10|16)
 */
String::String(const long value, const int base)
{
  char buf[33];
  sup_itoa(value, buf, base);
  allocateBuffer(m_length = strlen(buf));
  if (m_buffer != NULL)
    strcpy(m_buffer, buf);
}
/** @brief Contruct a new string from an existing C string
    
    @param const char* cstr: Pointer to existing C string to copy
 */
String::String(const char* cstr)
{
  if (cstr == NULL)
    cstr = "";
  allocateBuffer(m_length = strlen(cstr));
  if (m_buffer != NULL)
    strcpy(m_buffer, cstr);
}
Пример #9
0
int LCALIFLayer::allocateBuffers() {
   const size_t numNeurons = getNumNeuronsAllBatches();
   //Allocate data to keep track of trace
   int status = PV_SUCCESS;
   if (status==PV_SUCCESS) status = allocateBuffer(&integratedSpikeCount, numNeurons, "integratedSpikeCount");
   if (status==PV_SUCCESS) status = allocateBuffer(&Vadpt, numNeurons, "Vadpt");
   if (status==PV_SUCCESS) status = allocateBuffer(&Vattained, numNeurons, "Vattained");
   if (status==PV_SUCCESS) status = allocateBuffer(&Vmeminf, numNeurons, "Vmeminf");
   if (status==PV_SUCCESS) status = allocateBuffer(&G_Norm, numNeurons, "G_Norm");
   if (status==PV_SUCCESS) status = allocateBuffer(&GSynExcEffective, numNeurons, "GSynExcEffective");
   if (status==PV_SUCCESS) status = allocateBuffer(&GSynInhEffective, numNeurons, "GSynInhEffective");
   if (status==PV_SUCCESS) status = allocateBuffer(&excitatoryNoise, numNeurons, "excitatoryNoise");
   if (status==PV_SUCCESS) status = allocateBuffer(&inhibitoryNoise, numNeurons, "inhibitoryNoise");
   if (status==PV_SUCCESS) status = allocateBuffer(&inhibNoiseB, numNeurons, "inhibNoiseB");
   if (status!=PV_SUCCESS) exit(EXIT_FAILURE);
   return LIFGap::allocateBuffers();
}
Пример #10
0
AmBufferedAudio::AmBufferedAudio(size_t output_buffer_size, 
				 size_t low_buffer_thresh, size_t full_buffer_thresh) 
  : output_buffer_size(output_buffer_size), 
    low_buffer_thresh(low_buffer_thresh), full_buffer_thresh(full_buffer_thresh),
    r(0), w(0), eof(false), err_code(0)
{
  allocateBuffer();
}
Пример #11
0
void SoundEmitter::play(const std::string &filename,
                        int volume,
                        int pitch)
{
	float _volume = clamp<int>(volume, 0, 100) / 100.0f;
	float _pitch  = clamp<int>(pitch, 50, 150) / 100.0f;

	SoundBuffer *buffer = allocateBuffer(filename);

	if (!buffer)
		return;

	/* Try to find first free source */
	size_t i;
	for (i = 0; i < srcCount; ++i)
		if (AL::Source::getState(alSrcs[srcPrio[i]]) != AL_PLAYING)
			break;

	/* If we didn't find any, try to find the lowest priority source
	 * with the same buffer to overtake */
	if (i == srcCount)
		for (size_t j = 0; j < srcCount; ++j)
			if (atchBufs[srcPrio[j]] == buffer)
				i = j;

	/* If we didn't find any, overtake the one with lowest priority */
	if (i == srcCount)
		i = 0;

	size_t srcIndex = srcPrio[i];

	/* Only detach/reattach if it's actually a different buffer */
	bool switchBuffer = (atchBufs[srcIndex] != buffer);

	/* Push the used source to the back of the priority list */
	arrayPushBack(srcPrio, srcCount, i);

	AL::Source::ID src = alSrcs[srcIndex];
	AL::Source::stop(src);

	if (switchBuffer)
		AL::Source::detachBuffer(src);

	SoundBuffer *old = atchBufs[srcIndex];

	if (old)
		SoundBuffer::deref(old);

	atchBufs[srcIndex] = SoundBuffer::ref(buffer);

	if (switchBuffer)
		AL::Source::attachBuffer(src, buffer->alBuffer);

	AL::Source::setVolume(src, _volume * GLOBAL_VOLUME);
	AL::Source::setPitch(src, _pitch);

	AL::Source::play(src);
}
/** @brief Contruct a new string from an existing character
 
 @param const unsigned char value: Character value to use for string data
 */
String::String(const unsigned char value)
{
  m_length = 1;
  allocateBuffer(1);
  if (m_buffer != NULL) {
    m_buffer[0] = value;
    m_buffer[1] = 0;
  }
}
Пример #13
0
 void
 Allocator::acquireMemory(void)
 {
   quota_ = quotaInitial_;
   for (BufferCount i = 0; i < nInitial_; ++i)
   {
     reuseList_.push_back(allocateBuffer(true));
   }
 }
Пример #14
0
static DWIOBUFF *findWrBuffer(  // FIND A BUFFER FOR WRITING
    void )
{
    DWIOBUFF *ctl;              // - buffer control

    ctl = allocateBuffer();
    ctl->disk_addr = IoSuppTempNextBlock( DWBLOCK_FACTOR );
    ctl->writing = true;
    ctl->written = false;
    return ctl;
}
Пример #15
0
void DsdSampleReader::clearBuffer() 
{
	if (!isBufferAllocated) {
		allocateBuffer();
		return;
	}
	
	dsf2flac_uint8 c = getIdleSample();
	for (dsf2flac_uint32 i = 0; i<getNumChannels(); i++)
		for (dsf2flac_uint32 j=0; j<getBufferLength(); j++)
			circularBuffers[i].push_front(c);
}
 PixelBox GL3PlusHardwarePixelBuffer::lockImpl(const Image::Box &lockBox,  LockOptions options)
 {
     allocateBuffer();
     if(options != HardwareBuffer::HBL_DISCARD)
     {
         // Download the old contents of the texture
         download(mBuffer);
     }
     mCurrentLockOptions = options;
     mLockedBox = lockBox;
     return mBuffer.getSubVolume(lockBox);
 }
OMX_ERRORTYPE SHM_PcmOut::instantiateBindingComponent(void) {
    OMX_ERRORTYPE error;
    OMX_U32 priority = getPortPriorityLevel();

    MEMORY_TRACE_ENTER("SHM_PcmOut::instantiateBindingComponent");

    if(priority == 0){
        OstTraceFiltInst1(TRACE_ALWAYS, "AFM_PROXY: SHM_PcmOut:: instantiateBindingComponent: SHM_PcmOut instantiated with priority %d",priority +1);
        error = ENS::instantiateNMFComponent(
            getNMFDomainHandle(), "bindings.shmpcm.shmout", 
            "SHM_PcmOut", &mNmfHandle, priority+1);
    }
    else{
        OstTraceFiltInst1(TRACE_ALWAYS, "AFM_PROXY: SHM_PcmOut:: instantiateBindingComponent: SHM_PcmOut instantiated with priority %d",priority);
        error = ENS::instantiateNMFComponent(
            getNMFDomainHandle(), "bindings.shmpcm.shmout", 
            "SHM_PcmOut", &mNmfHandle, priority);
    }
    if (error != OMX_ErrorNone) return error;

	error = ENS::bindComponent(
           mNmfHandle, "osttrace", mOstTrace, "osttrace");
    if (error != OMX_ErrorNone) return error;

    OstTraceFiltInst1(TRACE_ALWAYS, "AFM_PROXY: SHM_PcmOut:: instantiateBindingComponent: synchronisation instantiated with priority %d",priority);
    error = ENS::instantiateNMFComponent(
            getNMFDomainHandle(), "misc.synchronisation", "synchronisation", 
            &mNmfSyncLib, priority);
    if (error != OMX_ErrorNone) return error;
    
    error = ENS::bindComponent(
            mNmfHandle, "synchronisation", mNmfSyncLib, "synchronisation");
    if (error != OMX_ErrorNone) return error;

    error = ENS::bindComponentFromHostEx(mNmfHandle, "configure", &mIconfigure, 1);
    if (error != OMX_ErrorNone) return error;

    error = ENS::bindComponent(
            mNmfHandle, "outputport", mNmfSharedBuffer, "emptythisbuffer");
    if (error != OMX_ErrorNone) return error;

    error = ENS::bindComponent(
            mNmfSharedBuffer, "mpc", mNmfHandle, "fillthisbuffer");
    if (error != OMX_ErrorNone) return error;

    error = allocateBuffer();
    if (error != OMX_ErrorNone) return error;

    MEMORY_TRACE_LEAVE("SHM_PcmOut::instantiateBindingComponent");

    return OMX_ErrorNone;
}
Пример #18
0
int OffscreenNativeWindow::setBufferCount(int count)
{
	TRACE("%s: count=%i", __PRETTY_FUNCTION__, count);

	if (m_buffers.size() < count) {
		for (int n = 0; n < m_buffers.size() - count; n++) {
			OffscreenNativeWindowBuffer *buffer = allocateBuffer();
			m_buffers.push_back(buffer);
		}
	}

	return NO_ERROR;
}
Пример #19
0
 char*
 Allocator::allocate(bool failureIsFatal)
 {
   // Return NULL if Allocator memory has been released
   if (!memAllocated_ && (reuseList_.size() == 0))
   {
     return NULL;
   }
   else
   {
    return allocateBuffer(failureIsFatal);
   }
 }
    void GL3PlusHardwarePixelBuffer::blitFromMemory(const PixelBox &src, const Image::Box &dstBox)
    {
        if (!mBuffer.contains(dstBox))
        {
            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
                        "Destination box out of range",
                        "GL3PlusHardwarePixelBuffer::blitFromMemory");
        }

        PixelBox scaled;

        if (src.getWidth() != dstBox.getWidth() ||
            src.getHeight() != dstBox.getHeight() ||
            src.getDepth() != dstBox.getDepth())
        {
            // Scale to destination size.
            // This also does pixel format conversion if needed.
            allocateBuffer( mSizeInBytes );
            scaled = mBuffer.getSubVolume(dstBox);
            Image::scale(src, scaled, Image::FILTER_BILINEAR);
        }
        else if (GL3PlusPixelUtil::getGLOriginFormat(src.format) == 0)
        {
            // Extents match, but format is not accepted as valid
            // source format for GL. Do conversion in temporary buffer.
            allocateBuffer( mSizeInBytes );
            scaled = mBuffer.getSubVolume(dstBox);
            PixelUtil::bulkPixelConversion(src, scaled);
        }
        else
        {
            allocateBuffer( mSizeInBytes );
            // No scaling or conversion needed.
            scaled = src;
        }

        upload(scaled, dstBox);
        freeBuffer();
    }
Пример #21
0
void ASKDemodulation::generateDemodulation(
    const std::vector<int> &BitesVector) {
  multiBuffer = allocateBuffer(this->ttime, this->samplingFrequency);
  demodulatedSignal = allocateBuffer(this->ttime, this->samplingFrequency);
  binarySignal = allocateBuffer(this->ttime, this->samplingFrequency);

  int bit = 0;
  int i = 0;
  this->sum = 0;

  for (auto x : BitesVector) {
    std::cout << i << ". bit's value: " << x << std::endl;
    for (int j = 0; j < 100; j++) {
      bit = (i * 100) + j;
      multiBuffer[bit] =
          modulatedSignal[bit] * this->amplitude *
          sin((2 * M_PI * (this->signalFrequency / 2) * bit) / 100);
      this->sum += multiBuffer[bit];
      demodulatedSignal[bit] = this->sum;
    }
    this->sum = 0;
    ++i;
  }

  i = 0;
  for (int k = 0; k < BitesVector.size(); ++k) {
    for (int j = 0; j < 100; j++) {
      bit = (i * 100) + j;
      if (demodulatedSignal[bit] > 0) {
        binarySignal[bit] = 1.0f;
      } else {
        binarySignal[bit] = 0.0f;
      }
    }
    ++i;
  }
  binarySignal[bit - 1] = 1.2f;
}
Пример #22
0
void SinusDrawing::generateSinusSignal(float SignalFrequency, float Amplitude,
                                       float StartPoint) {
  buffer = nullptr;
  buffer = allocateBuffer(ttime, samplingFrequency);
  amplitude = Amplitude;
  startPoint = StartPoint;
  signalFrequency = SignalFrequency;

  for (int i = 0; i < samplingFrequency * ttime; i++) {
    buffer[i] =
        amplitude *
        sin(2 * M_PI * signalFrequency * (i / samplingFrequency) + startPoint);
  }
}
Пример #23
0
int IncrementLayer::allocateDataStructures() {
   int status = ANNLayer::allocateDataStructures();

   if (status == PV_SUCCESS) status = allocateBuffer(&Vprev, getNumNeurons(), "V at previous time");
   if (status == PV_SUCCESS) {
      assert(GSyn && GSyn[0] && GSyn[1]);
      for( int k=0; k<getNumNeurons(); k++ ) {
         assert(GSyn[0][k]==0 && GSyn[1][k]==0);
      }
   }
   if (status != PV_SUCCESS) exit(EXIT_FAILURE);

   return status;
}
Пример #24
0
    PixelBox GLES2HardwarePixelBuffer::lockImpl(const Image::Box lockBox,  LockOptions options)
    {
        allocateBuffer();
        if (options != HardwareBuffer::HBL_DISCARD
//#ifndef GL_NV_read_buffer
            && (mUsage & HardwareBuffer::HBU_WRITE_ONLY) == 0)
        {
            // Download the old contents of the texture
            download(mBuffer);
        }
        mCurrentLockOptions = options;
        mLockedBox = lockBox;
        return mBuffer.getSubVolume(lockBox);
    }
Пример #25
0
	PixelData GLPixelBuffer::lockImpl(PixelVolume lockBox, GpuLockOptions options)
	{
		allocateBuffer();

		if(options != GBL_WRITE_ONLY_DISCARD) 
		{
			// Download the old contents of the texture
			download(mBuffer);
		}

		mCurrentLockOptions = options;
		mLockedBox = lockBox;
		return mBuffer.getSubVolume(lockBox);
	}
Пример #26
0
bool DsdSampleReader::setBufferLength(dsf2flac_uint32 b)
{
	if (b<1) {
		errorMsg = "dsdSampleReader::setBufferLength:buffer length must be >0";
		return false;
	}
	bufferLength=b;
	if (!isBufferAllocated)
		allocateBuffer();
	for (dsf2flac_uint32 i = 0; i<getNumChannels(); i++)
		circularBuffers[i].set_capacity(getBufferLength());
	clearBuffer(); // should be called by rewind... but just incase.
	rewind();
	return true;
}
Пример #27
0
int OffscreenNativeWindow::dequeueBuffer(BaseNativeWindowBuffer **buffer, int *fenceFd)
{
	TRACE("%s", __PRETTY_FUNCTION__);

	OffscreenNativeWindowBuffer *selectedBuffer = 0;
	std::list<OffscreenNativeWindowBuffer*>::iterator iter;

	g_mutex_lock(&m_bufferMutex);

	while (1) {
		for (iter = m_buffers.begin(); iter != m_buffers.end(); iter++) {
			OffscreenNativeWindowBuffer *currentBuffer = *iter;
			if (!currentBuffer->busy()) {
				TRACE("%s: Found buffer ready to be used", __PRETTY_FUNCTION__);

				selectedBuffer = currentBuffer;
				break;
			}
		}

		if (selectedBuffer)
			break;

		TRACE("%s: Waiting for buffer to be released", __PRETTY_FUNCTION__);
		g_cond_wait(&m_nextBufferCondition, &m_bufferMutex);
		TRACE("%s: Got notified that we have a new buffer available", __PRETTY_FUNCTION__);
	}

	// check wether buffer already has the right size
	if (selectedBuffer->width != m_width || selectedBuffer->height != m_height) {
		TRACE("%s buffer and window size doesn't match: recreating buffer ...\n", __PRETTY_FUNCTION__);

		m_buffers.remove(selectedBuffer);
		// Let the current buffer be cleared up by it's own
		selectedBuffer->decStrong(0);

		selectedBuffer = allocateBuffer();
		m_buffers.push_back(selectedBuffer);
	}

	selectedBuffer->setBusy(true);

	g_mutex_unlock(&m_bufferMutex);

	*buffer = selectedBuffer;

	return NO_ERROR;
}
Пример #28
0
int PursuitLayer::allocateDataStructures() {
    int status = ANNLayer::allocateDataStructures();

    if (status == PV_SUCCESS) {
        status = allocateBuffer(&wnormsq, getLayerLoc()->nf, "wnormsq");
    }
    if (status==PV_SUCCESS) {
        status = allocateBuffer(&minimumLocations, getNumNeurons(), "minimumLocations");
    }
    if (status==PV_SUCCESS) {
        status = allocateBuffer(&energyDrops, getNumNeurons(), "energyDrops");
    }

    int xy = getLayerLoc()->nx * getLayerLoc()->ny;
    if (status==PV_SUCCESS) {
        status = allocateBuffer(&minFeatures, xy, "minFeatures");
    }
    if (status==PV_SUCCESS) {
        status = allocateBuffer(&energyDropsBestFeature, xy, "energyDropsBestFeature");
    }
    if (status==PV_SUCCESS) {
        status = allocateBuffer(&foundFeatures, xy, "foundFeatures");
        for (int k=0; k<xy; k++) {
            foundFeatures[k]=-1;
        }
    }
    if (status==PV_SUCCESS) {
        status = allocateBuffer(&minLocationsBestFeature, xy, "minLocationsBestFeature");
    }
    if (status==PV_SUCCESS) {
        status = allocateBuffer(&gSynSparse, xy, "gSynSparse");
    }
    if (status==PV_SUCCESS) {
        status = allocateBuffer(&minEnergyFiltered, xy, "minEnergyFiltered");
    }
    if (status != PV_SUCCESS) abort();

    return status;
}
Пример #29
0
// WARNING: do not call this while device is in use! buffer is not locked!
void AmBufferedAudio::setBufferSize(size_t _output_buffer_size, 
				    size_t _low_buffer_thresh,
				    size_t _full_buffer_thresh) {

  DBG("set output buffer size to %zd low thresh %zd, fill thresh %zd\n", 
      _output_buffer_size, _low_buffer_thresh, _full_buffer_thresh);

  bool reset_buffer = output_buffer_size != _output_buffer_size;
  output_buffer_size = _output_buffer_size;
  low_buffer_thresh = _low_buffer_thresh;
  full_buffer_thresh = _full_buffer_thresh;

  if (reset_buffer) {
    releaseBuffer();
    allocateBuffer();
  }
}
Пример #30
0
    bool VertexBuffer::allocate(ID3D11Device* device, void* vertices, UINT stride, UINT numVertices,D3D11_USAGE usage, UINT cpuAccess ,
            bool createSOBuffer)
    {
		m_stride = 0;
		m_vertexCount = 0;

		UINT binding = createSOBuffer ? D3D11_BIND_STREAM_OUTPUT : D3D11_BIND_VERTEX_BUFFER; 
		bool res = allocateBuffer(device, vertices, stride*numVertices, binding, usage, cpuAccess);
		if (res){
			m_vertexCount = numVertices;
			m_stride = stride;
			return true;
		}
		return false;

       
    }