示例#1
0
void Server::netupdate_IN(float deltaTime)
{
	//Handle all new incomming messages
	while (true)
	{
		Packet* rec = connection.receive();
		if (rec == 0) // no more messages to handle
			break;

		//extract net index
		Uint8 index_short;
		*rec >> index_short;
		NET_INDEX index = NET_INDEX(index_short);

		switch (index)
		{
		case PING:					in_ping(rec); break;
		case PING_ACK:				in_ping_ACK(rec); break;
		case NEW_CONNECTION:		in_new_connection(rec); break;
		case NEW_CONNECTION_ACK:	in_new_connection_ACK(rec); break;
		case EVENT:					in_event(rec); break;
		case EVENT_ACK:				in_event_ACK(rec); break;
		case FRAME:					in_frame(rec); break;
		default:
			//package error?
			break;
		}

		delete rec;
	}
}
示例#2
0
	std::shared_ptr<AVFrame> convert_video(core::read_frame& frame, AVCodecContext* c)
	{
		if(!sws_) 
		{
			sws_.reset(sws_getContext(format_desc_.width, format_desc_.height, PIX_FMT_BGRA, c->width, c->height, c->pix_fmt, SWS_BICUBIC, nullptr, nullptr, nullptr), sws_freeContext);
			if (sws_ == nullptr) 
				BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Cannot initialize the conversion context"));
		}

		std::shared_ptr<AVFrame> in_frame(avcodec_alloc_frame(), av_free);
		auto in_picture = reinterpret_cast<AVPicture*>(in_frame.get());

		if (key_only_)
		{
			key_picture_buf_.resize(frame.image_data().size());
			in_picture->linesize[0] = format_desc_.width * 4;
			in_picture->data[0] = key_picture_buf_.data();

			fast_memshfl(in_picture->data[0], frame.image_data().begin(), frame.image_data().size(), 0x0F0F0F0F, 0x0B0B0B0B, 0x07070707, 0x03030303);
		}
		else
		{
			avpicture_fill(in_picture, const_cast<uint8_t*>(frame.image_data().begin()), PIX_FMT_BGRA, format_desc_.width, format_desc_.height);
		}

		std::shared_ptr<AVFrame> out_frame(avcodec_alloc_frame(), av_free);
		picture_buf_.resize(avpicture_get_size(c->pix_fmt, c->width, c->height));
		avpicture_fill(reinterpret_cast<AVPicture*>(out_frame.get()), picture_buf_.data(), c->pix_fmt, c->width, c->height);

		sws_scale(sws_.get(), in_frame->data, in_frame->linesize, 0, format_desc_.height, out_frame->data, out_frame->linesize);

		return out_frame;
	}
示例#3
0
frame_t frame(tmp_label_t name, list_t formals)
{
    frame_t p = checked_malloc(sizeof(*p));
    list_t formal = formals, q = NULL;
    int i = 0;

    p->name = name;
    p->locals = NULL;
    p->local_count = 0;
    for (; formal; formal = formal->next, i++)
    {
        fr_access_t access;
        if (formal->b || i >= K)
            access = in_frame(i * FR_WORD_SIZE);
        else
            access = in_reg(temp());
        if (q)
        {
            q->next = list(access, NULL);
            q = q->next;
        }
        else
            p->formals = q = list(access, NULL);
    }
    return p;
}
示例#4
0
fr_access_t fr_alloc_local(frame_t fr, bool escape)
{
    fr_access_t access;

    if (escape)
    {
        fr->local_count++;
        /* -2 for the the return address and frame pointer. */
        access = in_frame(FR_WORD_SIZE * (-2 - fr->local_count));
    }
    else
        access = in_reg(temp());
    if (fr->locals)
    {
        list_t p = fr->locals;
        while (p->next)
            p = p->next;
        p->next = list(access, NULL);
    }
    else
        fr->locals = list(access, NULL);
    return access;
}