Exemplo n.º 1
0
static inline void output_video_data(struct obs_core_video *video,
		struct video_data *input_frame, int count)
{
	const struct video_output_info *info;
	struct video_frame output_frame;
	bool locked;

	info = video_output_get_info(video->video);

	locked = video_output_lock_frame(video->video, &output_frame, count,
			input_frame->timestamp);
	if (locked) {
		if (video->gpu_conversion) {
			set_gpu_converted_data(video, &output_frame,
					input_frame, info);

		} else if (format_is_yuv(info->format)) {
			convert_frame(&output_frame, input_frame, info);
		} else {
			copy_rgbx_frame(&output_frame, input_frame, info);
		}

		video_output_unlock_frame(video->video);
	}
}
Exemplo n.º 2
0
static void obs_source_draw_async_texture(struct obs_source *source)
{
	effect_t    effect        = gs_geteffect();
	bool        yuv           = format_is_yuv(source->async_format);
	bool        limited_range = yuv && !source->async_full_range;
	const char  *type         = yuv ? "DrawMatrix" : "Draw";
	bool        def_draw      = (!effect);
	technique_t tech;

	if (def_draw) {
		effect = obs_get_default_effect();
		tech = effect_gettechnique(effect, type);
		technique_begin(tech);
		technique_beginpass(tech, 0);
	}

	obs_source_draw_texture(source, effect,
			yuv ? source->async_color_matrix : NULL,
			limited_range ? source->async_color_range_min : NULL,
			limited_range ? source->async_color_range_max : NULL);

	if (def_draw) {
		technique_endpass(tech);
		technique_end(tech);
	}
}
void deinterlace_render(obs_source_t *s)
{
	gs_effect_t *effect = s->deinterlace_effect;

	uint64_t frame2_ts;
	gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image");
	gs_eparam_t *prev = gs_effect_get_param_by_name(effect,
			"previous_image");
	gs_eparam_t *field = gs_effect_get_param_by_name(effect, "field_order");
	gs_eparam_t *frame2 = gs_effect_get_param_by_name(effect, "frame2");
	gs_eparam_t *dimensions = gs_effect_get_param_by_name(effect,
			"dimensions");
	struct vec2 size = {(float)s->async_width, (float)s->async_height};
	bool yuv = format_is_yuv(s->async_format);
	bool limited_range = yuv && !s->async_full_range;
	const char *tech = yuv ? "DrawMatrix" : "Draw";

	gs_texture_t *cur_tex = s->async_texrender ?
		gs_texrender_get_texture(s->async_texrender) :
		s->async_texture;
	gs_texture_t *prev_tex = s->async_prev_texrender ?
		gs_texrender_get_texture(s->async_prev_texrender) :
		s->async_prev_texture;

	if (!cur_tex || !prev_tex || !s->async_width || !s->async_height)
		return;

	gs_effect_set_texture(image, cur_tex);
	gs_effect_set_texture(prev, prev_tex);
	gs_effect_set_int(field, s->deinterlace_top_first);
	gs_effect_set_vec2(dimensions, &size);

	if (yuv) {
		gs_eparam_t *color_matrix = gs_effect_get_param_by_name(
				effect, "color_matrix");
		gs_effect_set_val(color_matrix, s->async_color_matrix,
				sizeof(float) * 16);
	}
	if (limited_range) {
		const size_t size = sizeof(float) * 3;
		gs_eparam_t *color_range_min = gs_effect_get_param_by_name(
				effect, "color_range_min");
		gs_eparam_t *color_range_max = gs_effect_get_param_by_name(
				effect, "color_range_max");
		gs_effect_set_val(color_range_min, s->async_color_range_min,
				size);
		gs_effect_set_val(color_range_max, s->async_color_range_max,
				size);
	}

	frame2_ts = s->deinterlace_frame_ts + s->deinterlace_offset +
		s->deinterlace_half_duration - TWOX_TOLERANCE;

	gs_effect_set_bool(frame2, obs->video.video_time >= frame2_ts);

	while (gs_effect_loop(effect, tech))
		gs_draw_sprite(NULL, s->async_flip ? GS_FLIP_V : 0,
				s->async_width, s->async_height);
}
Exemplo n.º 4
0
void dx_copy_pixels(GF_VideoSurface *dst_s, const GF_VideoSurface *src_s, const GF_Window *src_wnd)
{
	/*handle YUV input*/
	if (get_yuv_base(src_s->pixel_format)==GF_PIXEL_YV12) {
		if (format_is_yuv(dst_s->pixel_format)) {
			/*generic YV planar to YUV (planar or not) */
			write_yv12_to_yuv(dst_s, src_s->video_buffer, src_s->pitch_y, src_s->pixel_format, src_s->width, src_s->height, src_wnd, src_s->u_ptr, src_s->v_ptr);
			return;
		}
	} else if (get_yuv_base(src_s->pixel_format)==GF_PIXEL_YV12_10) {
		if (format_is_yuv(dst_s->pixel_format)) {
			/*generic YV planar to YUV (planar or not) */
			gf_color_write_yv12_10_to_yuv(dst_s, src_s->video_buffer, src_s->u_ptr, src_s->v_ptr, src_s->pitch_y, src_s->width, src_s->height, src_wnd);
			return;
		}
	} else if (format_is_yuv(src_s->pixel_format)) {
		if (format_is_yuv(dst_s->pixel_format)) {
			write_yvyu_to_yuv(dst_s, src_s->video_buffer, src_s->pitch_y, src_s->pixel_format, src_s->width, src_s->height, src_wnd);
			return;
		}
	} else {
		switch (dst_s->pixel_format) {
		case GF_PIXEL_RGB_555:
			rgb_to_555(dst_s, src_s->video_buffer, src_s->pitch_y, src_s->width, src_s->height, src_s->pixel_format, src_wnd);
			return;
		case GF_PIXEL_RGB_565:
			rgb_to_565(dst_s, src_s->video_buffer, src_s->pitch_y, src_s->width, src_s->height, src_s->pixel_format, src_wnd);
			return;
		case GF_PIXEL_RGB_24:
		case GF_PIXEL_RGBS:
		case GF_PIXEL_BGR_24:
			rgb_to_24(dst_s, src_s->video_buffer, src_s->pitch_y, src_s->width, src_s->height, src_s->pixel_format, src_wnd);
			return;
		case GF_PIXEL_RGB_32:
		case GF_PIXEL_RGBD:
		case GF_PIXEL_RGBDS:
		case GF_PIXEL_BGR_32:
			rgb_to_32(dst_s, src_s->video_buffer, src_s->pitch_y, src_s->width, src_s->height, src_s->pixel_format, src_wnd);
			return;
		}
	}

	gf_stretch_bits(dst_s, (GF_VideoSurface*) src_s, NULL, (GF_Window *)src_wnd, 0xFF, 0, NULL, NULL);
}
Exemplo n.º 5
0
static inline void output_video_data(struct obs_core_video *video,
		struct video_data *frame, int cur_texture)
{
	const struct video_output_info *info;
	info = video_output_getinfo(video->video);

	if (video->gpu_conversion) {
		if (!set_gpu_converted_data(video, frame, cur_texture))
			return;

	} else if (format_is_yuv(info->format)) {
		if (!convert_frame(video, frame, info, cur_texture))
			return;
	}

	video_output_swap_frame(video->video, frame);
}
Exemplo n.º 6
0
static bool obs_init_textures(struct obs_video_info *ovi)
{
	struct obs_core_video *video = &obs->video;
	bool yuv = format_is_yuv(ovi->output_format);
	uint32_t output_height = video->gpu_conversion ?
		video->conversion_height : ovi->output_height;
	size_t i;

	for (i = 0; i < NUM_TEXTURES; i++) {
		video->copy_surfaces[i] = gs_stagesurface_create(
				ovi->output_width, output_height, GS_RGBA);

		if (!video->copy_surfaces[i])
			return false;

		video->render_textures[i] = gs_texture_create(
				ovi->base_width, ovi->base_height,
				GS_RGBA, 1, NULL, GS_RENDER_TARGET);

		if (!video->render_textures[i])
			return false;

		video->output_textures[i] = gs_texture_create(
				ovi->output_width, ovi->output_height,
				GS_RGBA, 1, NULL, GS_RENDER_TARGET);

		if (!video->output_textures[i])
			return false;

		if (yuv)
			obs_source_frame_init(&video->convert_frames[i],
					ovi->output_format,
					ovi->output_width,ovi->output_height);
	}

	return true;
}