[vlc-commits] [Git][videolan/vlc][master] vout_subpicture: fix "fit inside" SPU computation
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Feb 4 10:53:39 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
0df6fa14 by Steve Lhomme at 2025-02-04T10:10:14+00:00
vout_subpicture: fix "fit inside" SPU computation
The restrained size is in source unscaled coordinates
when apply_scale is not set.
We need to unscale the output dimensions to check if it fits inside in that case.
Fixes positioning of SPU's when the window is smaller than the source.
Plus rename SpuAreaFitInside() to SpuAreaMoveInside() as it's not fitting, ie
stretching anything, just moving the subpicture (and probably shouldn't for
absolute placement anyway).
- - - - -
1 changed file:
- src/video_output/vout_subpictures.c
Changes:
=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -582,8 +582,8 @@ static void SpuAreaFixOverlap(spu_area_t *dst,
}
-static void SpuAreaFitInside(spu_area_t *area, const unsigned boundary_width,
- const unsigned boundary_height)
+static void SpuAreaMoveInside(spu_area_t *area, const unsigned boundary_width,
+ const unsigned boundary_height)
{
spu_area_t a = spu_area_scaled(*area);
bool modified = false;
@@ -962,6 +962,7 @@ static struct subpicture_region_rendered *SpuRenderRegion(spu_t *spu,
subpicture_region_t *region,
const spu_scale_t scale_size, bool apply_scale,
const vlc_fourcc_t *chroma_list,
+ const unsigned output_x, const unsigned output_y,
const unsigned output_width, const unsigned output_height,
const spu_area_t *subtitle_area, size_t subtitle_area_count,
vlc_tick_t render_date)
@@ -1046,7 +1047,9 @@ static struct subpicture_region_rendered *SpuRenderRegion(spu_t *spu,
if (subpic->b_subtitle)
restrained.y -= y_margin;
- SpuAreaFitInside(&restrained, output_width, output_height);
+ SpuAreaMoveInside(&restrained,
+ apply_scale ? (output_x + output_width ) : spu_invscale_w(output_x + output_width, scale_size),
+ apply_scale ? (output_y + output_height) : spu_invscale_h(output_y + output_height, scale_size));
/* Fix the position for the current scale_size */
x_offset = spu_scale_w(restrained.x, restrained.scale);
@@ -1415,10 +1418,15 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
const bool subpic_in_video = IsSubpicInVideo(subpic, spu_in_full_window);
unsigned output_width, output_height;
+ unsigned output_x, output_y;
if (subpic_in_video) {
+ output_x = video_position->x;
+ output_y = video_position->y;
output_width = video_position->width;
output_height = video_position->height;
} else {
+ output_x = fmt_dst->i_x_offset;
+ output_y = fmt_dst->i_y_offset;
output_width = fmt_dst->i_visible_width;
output_height = fmt_dst->i_visible_height;
}
@@ -1492,7 +1500,8 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
output_last_ptr = SpuRenderRegion(spu, &area,
&forced_subpic, entry->channel_order,
region, scale, !external_scale,
- chroma_list, output_width, output_height,
+ chroma_list,
+ output_x, output_y, output_width, output_height,
subtitle_area, subtitle_area_count,
subpic->b_subtitle ? render_subtitle_date : system_now);
if (unlikely(output_last_ptr == NULL))
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/0df6fa14d550ce5a130a87c297513f53be5b55d8
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/0df6fa14d550ce5a130a87c297513f53be5b55d8
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list