(API Change) libobs: Add bicubic/lanczos scaling
This adds bicubic and lanczos scaling capability to libobs to improve scaling quality and sharpness when the output resolution has to be scaled relative to the base resolution. Bilinear is also available, although bilinear has rather poor quality and causes scaling to appear blurry. If the output resolution is close to the base resolution, then bilinear is used instead as an optimization, as there's no need to use these shaders if scaling is not in use. The Bicubic and Lanczos effects are also exposed via exported function to allow the ability to use those shaders in plugin modules if desired. The API change adds a variable 'scale_type' to the obs_video_info structure that allows the user interface to choose what type of scaling filter should be used.
This commit is contained in:
14
libobs/obs.c
14
libobs/obs.c
@@ -244,6 +244,16 @@ static int obs_init_graphics(struct obs_video_info *ovi)
|
||||
NULL);
|
||||
bfree(filename);
|
||||
|
||||
filename = find_libobs_data_file("bicubic_scale.effect");
|
||||
video->bicubic_effect = gs_effect_create_from_file(filename,
|
||||
NULL);
|
||||
bfree(filename);
|
||||
|
||||
filename = find_libobs_data_file("lanczos_scale.effect");
|
||||
video->lanczos_effect = gs_effect_create_from_file(filename,
|
||||
NULL);
|
||||
bfree(filename);
|
||||
|
||||
if (!video->default_effect)
|
||||
success = false;
|
||||
if (gs_get_device_type() == GS_DEVICE_OPENGL) {
|
||||
@@ -293,6 +303,7 @@ static int obs_init_video(struct obs_video_info *ovi)
|
||||
video->output_width = ovi->output_width;
|
||||
video->output_height = ovi->output_height;
|
||||
video->gpu_conversion = ovi->gpu_conversion;
|
||||
video->scale_type = ovi->scale_type;
|
||||
|
||||
set_video_matrix(video, ovi);
|
||||
|
||||
@@ -399,6 +410,8 @@ static void obs_free_graphics(void)
|
||||
gs_effect_destroy(video->default_rect_effect);
|
||||
gs_effect_destroy(video->solid_effect);
|
||||
gs_effect_destroy(video->conversion_effect);
|
||||
gs_effect_destroy(video->bicubic_effect);
|
||||
gs_effect_destroy(video->lanczos_effect);
|
||||
video->default_effect = NULL;
|
||||
|
||||
gs_leave_context();
|
||||
@@ -756,6 +769,7 @@ bool obs_get_video_info(struct obs_video_info *ovi)
|
||||
ovi->base_width = video->base_width;
|
||||
ovi->base_height = video->base_height;
|
||||
ovi->gpu_conversion= video->gpu_conversion;
|
||||
ovi->scale_type = video->scale_type;
|
||||
ovi->colorspace = info->colorspace;
|
||||
ovi->range = info->range;
|
||||
ovi->output_width = info->width;
|
||||
|
Reference in New Issue
Block a user