static void get_overlay_format(const gavl_video_format_t * src, gavl_video_format_t * dst, const gavl_rectangle_i_t * src_rect) { gavl_video_format_copy(dst, src); dst->image_width = src_rect->w + src_rect->x; dst->image_height = src_rect->h + src_rect->y; gavl_video_format_set_frame_size(dst, 0, 0); }
gavl_video_sink_t * bg_ov_add_overlay_stream(bg_ov_t * ov, gavl_video_format_t * format) { ovl_stream_t * str; ov->ovl_str = realloc(ov->ovl_str, (ov->num_ovl_str+1)* sizeof(*ov->ovl_str)); str = ov->ovl_str + ov->num_ovl_str; memset(str, 0, sizeof(*str)); ov->num_ovl_str++; if(!format->image_width || !format->image_height) { format->image_width = ov->format.image_width; format->image_height = ov->format.image_height; format->pixel_width = ov->format.pixel_width; format->pixel_height = ov->format.pixel_height; gavl_video_format_set_frame_size(format, 0, 0); } if(ov->plugin->add_overlay_stream) { /* Try hardware overlay */ LOCK(ov); str->sink_int = ov->plugin->add_overlay_stream(ov->priv, format); UNLOCK(ov); if(str->sink_int) { bg_log(BG_LOG_INFO, LOG_DOMAIN, "Using hardeware overlay for stream %d", ov->num_ovl_str-1); return str->sink_int; } } /* Software overlay */ ov->flags |= FLAG_EMULATE_OVL; bg_log(BG_LOG_INFO, LOG_DOMAIN, "Using software overlay for stream %d", ov->num_ovl_str - 1); str->ctx = gavl_overlay_blend_context_create(); gavl_overlay_blend_context_init(str->ctx, &ov->format, format); str->sink_ext = gavl_video_sink_create(NULL, put_overlay, str, format); gavl_video_format_copy(&str->format, format); return str->sink_ext; }