Пример #1
0
void FrameOrganizer::notifySubscribers(FrameWriter* writer, VideoFrame*
                                       frame)
{
    assertFinalized();
    ASSERT(writer);
    ASSERT(frame);

    LogDebug2("Notifiying subscribers");

    // take temporary ownership of frame and add custom delete function to
    // decrease counter as well as free frame
    auto deleter = std::bind(&FrameOrganizer::deleteVideoFrame, this,
                             std::placeholders::_1, writer);

    shared_ptr<const VideoFrame> frame_shared(frame, deleter);

    for (auto& subscription : m_subscriptions)
    {
        if (subscription.second == writer)
        {
            subscription.first->processFrameWrapper(writer->getWriterId(),
                                                    frame_shared);
        }
    }
}
Пример #2
0
Eventgen::Eventgen(const vector<ObjectGroup> grouped_event_boxes, const SDL_Rect& viewport, const SDL_Rect& player, std::shared_ptr<LoadedMap>& map)
    : m_grouped_event_boxes(grouped_event_boxes)
    , mViewport(viewport)
    , mPlayerBoundingBox(player)
    , mMap(map)
{
    LogDebug2("Constructed eventgen");
}
Пример #3
0
int GaussianBlur::initWriter()
{
    LogDebug2("Init writer called for gaussian blur");
    m_weight_matrix_x = new WeightMatrix(m_blurfactor, m_dist_x, m_dist_y,
            false);
    m_weight_matrix_y = new WeightMatrix(m_blurfactor, m_dist_x, m_dist_y,
            true);
    return 0;
}
Пример #4
0
    static axis2_status_t AXIS2_CALL CallbackOnFault(axis2_callback_t* pCallback, const axutil_env_t* pEnv,
                                                     int nFaultCode)
    {
      if (!pCallback)
      {
        LogError() << "pCallback is NULL";
        return AXIS2_FAILURE;
      }

      PICallback tpCallback(reinterpret_cast<ICallback<const DataObject&>*>(axis2_callback_get_data(pCallback)));
      axis2_callback_set_data(pCallback, NULL);  // avoid axis2/c to destroy C++ data

      if (!tpCallback.get())
      {
        LogError() << "pointer to ICallback is NULL";
        return AXIS2_FAILURE;
      }

      axiom_node_t* pAxiomResponseNode = NULL;
      {
        axiom_soap_envelope_t* pSoapEnvelope = axis2_callback_get_envelope(pCallback, pEnv);
        if (pSoapEnvelope)
        {
          pAxiomResponseNode = axiom_soap_envelope_get_base_node(pSoapEnvelope, pEnv);
#ifdef _DEBUG
      LogDebug2() << "Received Response: \n" << staff::ColorTextBlue
          << DataObject(pAxiomResponseNode).ToString() << staff::ColorDefault;
#endif
        }
      }

      try
      {
        if (!pAxiomResponseNode)
        {
          CreateFault(*tpCallback, AXIS2_ERROR_GET_MESSAGE(pEnv->error), ToString(nFaultCode));
        }
        else
        {
          tpCallback->OnFault(pAxiomResponseNode);
        }
      }
      STAFF_CATCH_ALL_DESCR("Error while processing response")

      return AXIS2_SUCCESS;
    }
Пример #5
0
int GaussianBlur::processFrame(const string &writer_id, shared_ptr<const
        VideoFrame> frame)
{
    LogDebug2("Applying gaussian blur on frame " << frame->getId());
    FrameMatrix matrix(frame);

    //TODO/FIXME DC: Currently ignoring edges
    VideoFrame *blurred_frame = new VideoFrame(frame->getId(),
            frame->getWidth() - (m_dist_x * 2), frame->getHeight() - (m_dist_y * 2));

    uint counter = 0;

    //Implementation note: pass as result reference to avoid a ton of
    //mallocs
    Matrix<uint> matrix_x(m_weight_matrix_x->getX(), m_weight_matrix_y->getY());
    Matrix<uint> matrix_y(m_weight_matrix_x->getX(), m_weight_matrix_y->getY());

    //TODO/FIXME DC: Currently ignoring edges
    for(uint y = m_dist_y; y < matrix.getY() - m_dist_y; y++)
    {
        for(uint x = m_dist_x; x < matrix.getX() - m_dist_x; x++)
        {
            //do some fancy math to not get out of bounds and set the
            //middle as origin
            uint x_start    = x - m_dist_x;
            uint y_start    = y - m_dist_y;
            uint x_end      = x + m_dist_x;
            uint y_end      = y + m_dist_y;

            matrix.multiplyFrameMatrixPart(x_start, x_end, y_start, y_end,
                    *m_weight_matrix_x, matrix_x);
            matrix.multiplyFrameMatrixPart(x_start, x_end, y_start, y_end,
                    *m_weight_matrix_y, matrix_y);

            Matrix<uint> matrix_added = matrix_x + matrix_y;
            uint8_t value = matrix_added.getTotal()/2;

            blurred_frame->getLumaData()[counter] = value;
            counter = counter + 1;
        }
    }

    addFrame(blurred_frame);
    return 0;
}
Пример #6
0
	ssize_t Scheduler::SchedulerImpl::run(void* data)
	{
		UNUSED(data);

		LogTraceObj();
		while (true) {
			auto activateClock = get_activate_time();
//			LogTraceObj(L"activateClock: %I64d", activateClock);
			auto activateTimeout = (activateClock == TIMEOUT_INFINITE) ? TIMEOUT_INFINITE : activateClock - simstd::min(activateClock, sync::now());
//			LogTraceObj(L"activateTimeout: %I64d", activateTimeout);

			Message msg;
			auto reason = messg_queue->get(msg, activateTimeout);
			if (reason == WaitResult_t::SUCCESS) {
				if (msg->check(message::Dt::MASK, message::Dt::SCHEDULER)) {
					if (msg->check(message::Et::MASK, message::Et::STOP)) {
						break;
					}
					if (msg->check(message::Et::MASK, message::Et::UPDATE)) {
						LogDebug2("update message received");
						fire_tasks();
					}
				} else {
					notify(msg);
				}
			} else if (reason == WaitResult_t::TIMEOUT) {
				fire_tasks();
			} else {
				break;
			}
		}

		LogInfo("finishing thread");
		::TerminateThread(::GetCurrentThread(), 0);
		return 0;
	}
Пример #7
0
int GaussianBlur::initReader()
{
    LogDebug2("Initialized Gaussian blur");
    return 0;
}
Пример #8
0
Eventgen::~Eventgen()
{
    LogDebug2("Destroyed eventgen");
}