Esempio n. 1
0
int lima::GetDefMaxNbBuffers(const FrameDim& frame_dim)
{
	int frame_size = frame_dim.getMemSize();
	if (frame_size <= 0)
		throw LIMA_HW_EXC(InvalidValue, "Invalid FrameDim");

	int tot_buffers;
	GetSystemMem(frame_size, tot_buffers);
	return int(tot_buffers);
}
Esempio n. 2
0
int lima::GetDefMaxNbBuffers(const FrameDim& frame_dim, double sys_mem_factor)
{
    int frame_size = frame_dim.getMemSize();
    if (frame_size <= 0)
        throw LIMA_HW_EXC(InvalidValue, "Invalid FrameDim");

    if (sys_mem_factor == 0)
        sys_mem_factor = 0.8;

    int tot_buffers;
    GetSystemMem(frame_size, tot_buffers);
    return int(tot_buffers * sys_mem_factor);
}
Esempio n. 3
0
void StdBufferCbMgr::allocBuffers(int nb_buffers, int nb_concat_frames, 
				  const FrameDim& frame_dim)
{
	DEB_MEMBER_FUNCT();
	DEB_PARAM() << DEB_VAR3(nb_buffers, nb_concat_frames, frame_dim);

	int frame_size = frame_dim.getMemSize();
	if (frame_size <= 0) {
		THROW_HW_ERROR(InvalidValue) << "Invalid " 
					     << DEB_VAR1(frame_dim);
	} else if (nb_concat_frames < 1) {
		THROW_HW_ERROR(InvalidValue) << "Invalid " 
					     << DEB_VAR1(nb_concat_frames);
	}

	int curr_nb_buffers;
	getNbBuffers(curr_nb_buffers);
	if ((nb_buffers == curr_nb_buffers) && (frame_dim == m_frame_dim) && 
	    (nb_concat_frames == m_nb_concat_frames)) {
		DEB_TRACE() << "Nothing to do";
		return;
	}

	releaseBuffers();

	try {
		FrameDim buffer_frame_dim;
		getBufferFrameDim(frame_dim, nb_concat_frames, 
				  buffer_frame_dim);

		DEB_TRACE() << "Allocating buffers";
		m_alloc_mgr->allocBuffers(nb_buffers, buffer_frame_dim);
		m_frame_dim = frame_dim;
		m_nb_concat_frames = nb_concat_frames;

		DEB_TRACE() << "Allocating frame info list";
		int nb_frames = nb_buffers * nb_concat_frames;
		m_info_list.reserve(nb_frames);
		for (int i = 0; i < nb_frames; ++i)
			m_info_list.push_back(HwFrameInfoType());
	} catch (...) {
		releaseBuffers();
		throw;
	}
}
void BufferCtrlObj::prepareAcq()
{
  DEB_MEMBER_FUNCT();
  FrameDim dim;
  getFrameDim(dim);
  m_frame[0].ImageBufferSize = m_frame[1].ImageBufferSize = dim.getMemSize();
  
  m_acq_frame_nb = -1;
  int buffer_nb,concat_frame_nb;
  m_buffer_cb_mgr.acqFrameNb2BufferNb(0,buffer_nb,concat_frame_nb);
  tPvFrame& frame0 = m_frame[0];
  frame0.ImageBuffer = (char*) m_buffer_cb_mgr.getBufferPtr(buffer_nb,
							    concat_frame_nb);

  m_buffer_cb_mgr.acqFrameNb2BufferNb(1,buffer_nb,concat_frame_nb);
  tPvFrame& frame1 = m_frame[1];
  frame1.ImageBuffer = (char*) m_buffer_cb_mgr.getBufferPtr(buffer_nb,
							    concat_frame_nb);
}
Esempio n. 5
0
void SoftBufferAllocMgr::allocBuffers(int nb_buffers,
				      const FrameDim& frame_dim)
{
	DEB_MEMBER_FUNCT();
	DEB_PARAM() << DEB_VAR2(nb_buffers, frame_dim);

	int frame_size = frame_dim.getMemSize();
	if (frame_size <= 0) 
		THROW_HW_ERROR(InvalidValue) << "Invalid " 
					     << DEB_VAR1(frame_dim);
       
	int max_buffers = getMaxNbBuffers(frame_dim);
	if ((nb_buffers < 1) || (nb_buffers > max_buffers)) 
		THROW_HW_ERROR(InvalidValue) << "Invalid " 
					     << DEB_VAR1(nb_buffers);

	int curr_nb_buffers;
	getNbBuffers(curr_nb_buffers);
	if ((frame_dim == m_frame_dim) && (nb_buffers == curr_nb_buffers)) {
		DEB_TRACE() << "Nothing to do";
		return;
	}

	releaseBuffers();

	try {
		m_buffer_list.reserve(nb_buffers);
		for (int i = 0; i < nb_buffers; ++i) {
			MemBuffer *buffer = new MemBuffer(frame_size);
			m_buffer_list.push_back(buffer);
		}
	} catch (...) {
		DEB_ERROR() << "Error alloc. buffer #" << m_buffer_list.size();
		releaseBuffers();
		throw;
	}

	m_frame_dim = frame_dim;
}
Esempio n. 6
0
void lima::ClearBuffer(void *ptr, int nb_concat_frames, 
		       const FrameDim& frame_dim)
{
	memset(ptr, 0, nb_concat_frames * frame_dim.getMemSize());
}