[vlc-commits] video_output: allow the display to scale the SPU
Steve Lhomme
git at videolan.org
Mon Nov 26 08:56:36 CET 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Nov 22 14:25:58 2018 +0100| [ba2d739a19a2ed4c1e4d1fc2b3772ceee28250ce] | committer: Steve Lhomme
video_output: allow the display to scale the SPU
Don't do it for text based subpictures so they are rendered at the proper
resolution.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ba2d739a19a2ed4c1e4d1fc2b3772ceee28250ce
---
include/vlc_spu.h | 5 ++++-
include/vlc_vout_display.h | 1 +
modules/stream_out/transcode/video.c | 2 +-
src/video_output/video_output.c | 3 ++-
src/video_output/vout_subpictures.c | 30 ++++++++++++++++++++++++++----
5 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/include/vlc_spu.h b/include/vlc_spu.h
index 127d586ac0..7eb3cafc2d 100644
--- a/include/vlc_spu.h
+++ b/include/vlc_spu.h
@@ -73,7 +73,10 @@ VLC_API void spu_PutSubpicture( spu_t *, subpicture_t * );
*
* The returned value if non NULL must be released by subpicture_Delete().
*/
-VLC_API subpicture_t * spu_Render( spu_t *, const vlc_fourcc_t *p_chroma_list, const video_format_t *p_fmt_dst, const video_format_t *p_fmt_src, vlc_tick_t render_subtitle_date, vlc_tick_t render_osd_date, bool ignore_osd );
+VLC_API subpicture_t * spu_Render( spu_t *, const vlc_fourcc_t *p_chroma_list,
+ const video_format_t *p_fmt_dst, const video_format_t *p_fmt_src,
+ vlc_tick_t render_subtitle_date, vlc_tick_t render_osd_date,
+ bool ignore_osd, bool external_scale );
/**
* It registers a new SPU channel.
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 09f257790c..c6d1972ffb 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -112,6 +112,7 @@ typedef struct {
bool is_slow; /* The picture memory has slow read/write */
bool has_double_click; /* Is double-click generated */
bool has_pictures_invalid; /* Will VOUT_DISPLAY_EVENT_PICTURES_INVALID be used */
+ bool can_scale_spu; /* Handles subpictures with a non default zoom factor */
const vlc_fourcc_t *subpicture_chromas; /* List of supported chromas for subpicture rendering. */
} vout_display_info_t;
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index a209482123..bdb4f8fe32 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -406,7 +406,7 @@ static picture_t * RenderSubpictures( sout_stream_t *p_stream, sout_stream_id_sy
subpicture_t *p_subpic = spu_Render( id->p_spu, NULL, &fmt,
&outfmt,
- p_pic->date, p_pic->date, false );
+ p_pic->date, p_pic->date, false, false );
/* Overlay subpicture */
if( p_subpic )
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index cc95c4d874..0925eb5de1 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1115,7 +1115,8 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced)
subpicture_chromas, &fmt_spu_rot,
&vd->source,
render_subtitle_date, render_osd_date,
- do_snapshot);
+ do_snapshot,
+ vd->info.can_scale_spu);
/*
* Perform rendering
*
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index 6df7669943..74cefe604d 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -1010,7 +1010,8 @@ static subpicture_t *SpuRenderSubpictures(spu_t *spu,
const video_format_t *fmt_dst,
const video_format_t *fmt_src,
vlc_tick_t render_subtitle_date,
- vlc_tick_t render_osd_date)
+ vlc_tick_t render_osd_date,
+ bool external_scale)
{
spu_private_t *sys = spu->p;
@@ -1114,14 +1115,33 @@ static subpicture_t *SpuRenderSubpictures(spu_t *spu,
if (scale.w <= 0 || scale.h <= 0)
continue;
+ const bool do_external_scale = external_scale && region->fmt.i_chroma != VLC_CODEC_TEXT;
+ spu_scale_t virtual_scale = external_scale ? (spu_scale_t){ SCALE_UNIT, SCALE_UNIT } : scale;
+
/* */
SpuRenderRegion(spu, output_last_ptr, &area,
- subpic, region, scale,
+ subpic, region, virtual_scale,
chroma_list, fmt_dst,
subtitle_area, subtitle_area_count,
subpic->b_subtitle ? render_subtitle_date : render_osd_date);
if (*output_last_ptr)
+ {
+ if (do_external_scale)
+ {
+ if (scale.h != SCALE_UNIT)
+ {
+ (*output_last_ptr)->zoom_h.num = scale.h;
+ (*output_last_ptr)->zoom_h.den = SCALE_UNIT;
+ }
+ if (scale.w != SCALE_UNIT)
+ {
+ (*output_last_ptr)->zoom_v.num = scale.w;
+ (*output_last_ptr)->zoom_v.den = SCALE_UNIT;
+ }
+ }
+
output_last_ptr = &(*output_last_ptr)->p_next;
+ }
if (subpic->b_subtitle) {
area = spu_area_unscaled(area, scale);
@@ -1512,7 +1532,8 @@ subpicture_t *spu_Render(spu_t *spu,
const video_format_t *fmt_src,
vlc_tick_t render_subtitle_date,
vlc_tick_t render_osd_date,
- bool ignore_osd)
+ bool ignore_osd,
+ bool external_scale)
{
spu_private_t *sys = spu->p;
@@ -1596,7 +1617,8 @@ subpicture_t *spu_Render(spu_t *spu,
fmt_dst,
fmt_src,
render_subtitle_date,
- render_osd_date);
+ render_osd_date,
+ external_scale);
vlc_mutex_unlock(&sys->lock);
return render;
More information about the vlc-commits
mailing list