[vlc-commits] [Git][videolan/vlc][master] subpictures: scale with the least cropping
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Oct 19 15:29:52 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
372e62c0 by Steve Lhomme at 2023-10-19T14:39:21+00:00
subpictures: scale with the least cropping
Right now we keep the height and crop the width. But we should avoid
cropping as much as possible.
- - - - -
1 changed file:
- src/video_output/vout_subpictures.c
Changes:
=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -1227,15 +1227,26 @@ static subpicture_t *SpuRenderSubpictures(spu_t *spu,
i_sar_num, i_sar_den, 65536);
}
- /* Compute scaling from original size to destination size
- * FIXME The current scaling ensure that the heights match, the width being
- * cropped.
- */
- spu_scale_t scale = spu_scale_createq((uint64_t)fmt_dst->i_visible_height * fmt_dst->i_sar_den * region_fmt.i_sar_num,
+ /* Compute scaling from original size to destination size */
+ // ensures that the heights match, the width being cropped.
+ spu_scale_t scale_h = spu_scale_createq((uint64_t)fmt_dst->i_visible_height * fmt_dst->i_sar_den * region_fmt.i_sar_num,
(uint64_t)subpic->i_original_picture_height * fmt_dst->i_sar_num * region_fmt.i_sar_den,
fmt_dst->i_visible_height,
subpic->i_original_picture_height);
+ // ensures that the widths match, the height being cropped.
+ spu_scale_t scale_w = spu_scale_createq((uint64_t)fmt_dst->i_visible_width * fmt_dst->i_sar_den * region_fmt.i_sar_num,
+ (uint64_t)subpic->i_original_picture_width * fmt_dst->i_sar_num * region_fmt.i_sar_den,
+ fmt_dst->i_visible_width,
+ subpic->i_original_picture_width);
+
+ // take the scale that will crop the least
+ spu_scale_t scale;
+ if (scale_h.h * scale_h.w > scale_w.h * scale_w.w)
+ scale = scale_w;
+ else
+ scale = scale_h;
+
/* Check scale validity */
assert(scale.w != 0 && scale.h != 0);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/372e62c00c50884629ef3c63c1d3b9ed490c9b02
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/372e62c00c50884629ef3c63c1d3b9ed490c9b02
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