コード例 #1
0
ファイル: obs-source.c プロジェクト: BraginWoW/obs-studio
static bool upload_frame(texture_t tex, const struct source_frame *frame)
{
    void *ptr;
    uint32_t row_bytes;
    enum convert_type type = get_convert_type(frame->format);

    if (type == CONVERT_NONE) {
        texture_setimage(tex, frame->data, frame->row_bytes, false);
        return true;
    }

    if (!texture_map(tex, &ptr, &row_bytes))
        return false;

    if (type == CONVERT_420)
        decompress_420(frame->data, frame->width, frame->height,
                       frame->row_bytes, 0, frame->height, ptr);

    else if (type == CONVERT_NV12)
        decompress_nv12(frame->data, frame->width, frame->height,
                        frame->row_bytes, 0, frame->height, ptr);

    else if (type == CONVERT_422_Y)
        decompress_422(frame->data, frame->width, frame->height,
                       frame->row_bytes, 0, frame->height, ptr, true);

    else if (type == CONVERT_422_U)
        decompress_422(frame->data, frame->width, frame->height,
                       frame->row_bytes, 0, frame->height, ptr, false);

    texture_unmap(tex);
    return true;
}
コード例 #2
0
ファイル: dc-capture.c プロジェクト: GamingAtheist/obs-studio
static inline void dc_capture_release_dc(struct dc_capture *capture)
{
	if (capture->compatibility) {
		texture_setimage(capture->textures[capture->cur_tex],
				capture->bits, capture->width*4, false);
	} else {
		texture_release_dc(capture->textures[capture->cur_tex]);
	}
}
コード例 #3
0
ファイル: obs-source.c プロジェクト: Christicles/obs-studio
static bool update_async_texture(struct obs_source *source,
		const struct source_frame *frame)
{
	texture_t         tex       = source->async_texture;
	texrender_t       texrender = source->async_convert_texrender;
	enum convert_type type      = get_convert_type(frame->format);
	void              *ptr;
	uint32_t          linesize;

	source->async_format     = frame->format;
	source->async_flip       = frame->flip;
	source->async_full_range = frame->full_range;
	memcpy(source->async_color_matrix, frame->color_matrix,
			sizeof(frame->color_matrix));
	memcpy(source->async_color_range_min, frame->color_range_min,
			sizeof frame->color_range_min);
	memcpy(source->async_color_range_max, frame->color_range_max,
			sizeof frame->color_range_max);

	if (source->async_gpu_conversion && texrender)
		return update_async_texrender(source, frame);

	if (type == CONVERT_NONE) {
		texture_setimage(tex, frame->data[0], frame->linesize[0],
				false);
		return true;
	}

	if (!texture_map(tex, &ptr, &linesize))
		return false;

	if (type == CONVERT_420)
		decompress_420((const uint8_t* const*)frame->data,
				frame->linesize,
				0, frame->height, ptr, linesize);

	else if (type == CONVERT_NV12)
		decompress_nv12((const uint8_t* const*)frame->data,
				frame->linesize,
				0, frame->height, ptr, linesize);

	else if (type == CONVERT_422_Y)
		decompress_422(frame->data[0], frame->linesize[0],
				0, frame->height, ptr, linesize, true);

	else if (type == CONVERT_422_U)
		decompress_422(frame->data[0], frame->linesize[0],
				0, frame->height, ptr, linesize, false);

	texture_unmap(tex);
	return true;
}
コード例 #4
0
ファイル: obs-source.c プロジェクト: Christicles/obs-studio
static void upload_raw_frame(texture_t tex, const struct source_frame *frame)
{
	switch (get_convert_type(frame->format)) {
		case CONVERT_422_U:
		case CONVERT_422_Y:
			texture_setimage(tex, frame->data[0],
					frame->linesize[0], false);
			break;

		case CONVERT_NV12:
		case CONVERT_420:
			assert(false && "Conversion not yet implemented");
			break;

		case CONVERT_NONE:
			assert(false && "No conversion requested");
			break;
	}
}
コード例 #5
0
ファイル: xcursor.c プロジェクト: FromHeartToSun/obs-studio
/*
 * Create the cursor texture, either by updating if the new cursor has the same
 * size or by creating a new texture if the size is different
 */
static void xcursor_create(xcursor_t *data, XFixesCursorImage *xc) {
	uint32_t *pixels = xcursor_pixels(xc);

	if (data->tex
	&& data->last_height == xc->width
	&& data->last_width == xc->height) {
		texture_setimage(data->tex, (void **) pixels,
			xc->width * sizeof(uint32_t), False);
	} else {
		if (data->tex)
			texture_destroy(data->tex);

		data->tex = gs_create_texture(xc->width, xc->height,
			GS_BGRA, 1, (const void **) &pixels, GS_DYNAMIC);
	}

	bfree(pixels);

	data->last_serial = xc->cursor_serial;
	data->last_width = xc->width;
	data->last_height = xc->height;
}