[vlc-commits] [Git][videolan/vlc][master] 5 commits: vout_subpictures: only use the y_margin for subtitle subpictures
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue May 7 05:57:41 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
7192c196 by Steve Lhomme at 2024-05-07T05:33:15+00:00
vout_subpictures: only use the y_margin for subtitle subpictures
It's unused otherwise, but we keep it initialized.
- - - - -
1d0e7df8 by Steve Lhomme at 2024-05-07T05:33:15+00:00
vout_subpictures: move non-text related code out of spu_PrerenderText()
- - - - -
453e5347 by Steve Lhomme at 2024-05-07T05:33:15+00:00
vout_subpictures: use shallow copies for video formats for prerendering
The formats won't be modified as they are passed as const.
No need to copy the palette and Clean afterwards.
- - - - -
0400168e by Steve Lhomme at 2024-05-07T05:33:15+00:00
video_widgets: use unsigned int for positioning
Plus unlikely check.
- - - - -
289427f5 by Steve Lhomme at 2024-05-07T05:33:15+00:00
display: document what each internal format is
- - - - -
3 changed files:
- src/video_output/display.c
- src/video_output/video_widgets.c
- src/video_output/vout_subpictures.c
Changes:
=====================================
src/video_output/display.c
=====================================
@@ -249,8 +249,8 @@ typedef struct {
struct vout_crop crop;
/* */
- video_format_t source;
- video_format_t display_fmt;
+ video_format_t source; // format coming from the decoder
+ video_format_t display_fmt; // format required on the input of the display module
vlc_video_context *src_vctx;
vout_display_place_t src_place;
=====================================
src/video_output/video_widgets.c
=====================================
@@ -116,7 +116,7 @@ static void DrawTriangle(subpicture_region_t *r, int fill, uint8_t color,
*/
static subpicture_region_t *OSDRegion(int x, int y, int width, int height)
{
- if( width == 0 || height == 0 )
+ if( unlikely( width == 0 || height == 0 ) )
return NULL;
video_palette_t palette;
@@ -205,20 +205,21 @@ static subpicture_region_t *OSDSlider(int type, int position,
*/
static subpicture_region_t *OSDIcon(int type, const video_format_t *fmt)
{
- const float size_ratio = 0.05f;
- const float margin_ratio = 0.07f;
+ const unsigned int size_ratio = 20;
+ const unsigned int margin_ratio = 14;
- const int size = __MAX(fmt->i_visible_width, fmt->i_visible_height);
- const int width = size * size_ratio;
- const int height = size * size_ratio;
- const int x = fmt->i_x_offset + fmt->i_visible_width - margin_ratio * size - width;
- const int y = fmt->i_y_offset + margin_ratio * size;
-
- if( width < 1 || height < 1 )
+ const unsigned int size = __MAX(fmt->i_visible_width, fmt->i_visible_height);
+ if( size < size_ratio )
return NULL;
+ const unsigned int width = size / size_ratio;
+ const unsigned int height = width;
+ const unsigned int margin = size / margin_ratio;
+ const int x = fmt->i_x_offset + fmt->i_visible_width - margin - width;
+ const int y = fmt->i_y_offset + margin;
+
subpicture_region_t *r = OSDRegion(__MAX(x, 0),
- __MIN(y, (int)fmt->i_visible_height - height),
+ __MIN(y, (int)fmt->i_visible_height - (int)height),
width, height);
if (!r)
return NULL;
@@ -241,7 +242,7 @@ static subpicture_region_t *OSDIcon(int type, const video_format_t *fmt)
DrawRect(r, STYLE_FILLED, COL_WHITE, delta, mid / 2, width - delta, height - 1 - mid / 2);
DrawTriangle(r, STYLE_FILLED, COL_WHITE, width - delta, 0, delta, y2);
if (type == OSD_MUTE_ICON) {
- for(int y1 = 0; y1 <= height -1; y1++)
+ for(unsigned y1 = 0; y1 < height; y1++)
DrawRect(r, STYLE_FILLED, COL_FILL, y1, y1, __MIN(y1 + delta, width - 1), y1);
}
}
=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -1008,7 +1008,7 @@ static struct subpicture_region_rendered *SpuRenderRegion(spu_t *spu,
* still exist. */
y_offset -= secondary_margin;
}
- else
+ else if (subpic->b_subtitle)
{
/* Use an absolute margin for secondary subpictures that have
* already been placed but have been moved by the user */
@@ -1722,14 +1722,8 @@ static void spu_PrerenderSync(spu_private_t *sys, const subpicture_t *p_subpic)
}
static void spu_PrerenderText(spu_t *spu, subpicture_t *p_subpic,
- const video_format_t *fmtsrc, const video_format_t *fmtdst,
const vlc_fourcc_t *chroma_list)
{
- spu_UpdateOriginalSize(spu, p_subpic, fmtsrc);
-
- subpicture_Update(p_subpic, fmtsrc, fmtdst,
- p_subpic->b_subtitle ? p_subpic->i_start : vlc_tick_now());
-
const unsigned i_original_picture_width = p_subpic->i_original_picture_width;
const unsigned i_original_picture_height = p_subpic->i_original_picture_height;
@@ -1785,8 +1779,8 @@ static void * spu_PrerenderThread(void *priv)
}
vlc_vector_remove(&sys->prerender.vector, i_idx);
memcpy(chroma_list, sys->prerender.chroma_list, SPU_CHROMALIST_COUNT);
- video_format_Copy(&fmtdst, &sys->prerender.fmtdst);
- video_format_Copy(&fmtsrc, &sys->prerender.fmtsrc);
+ fmtdst = sys->prerender.fmtdst;
+ fmtsrc = sys->prerender.fmtsrc;
if (IsSubpicInVideo(sys->prerender.p_processed, sys->prerender.spu_in_full_window))
{
@@ -1797,11 +1791,14 @@ static void * spu_PrerenderThread(void *priv)
vlc_mutex_unlock(&sys->prerender.lock);
- spu_PrerenderText(spu, sys->prerender.p_processed,
- &fmtsrc, &fmtdst, chroma_list);
+ subpicture_t *p_subpic = sys->prerender.p_processed;
+
+ spu_UpdateOriginalSize(spu, p_subpic, &fmtsrc);
+
+ subpicture_Update(p_subpic, &fmtsrc, &fmtdst,
+ p_subpic->b_subtitle ? p_subpic->i_start : vlc_tick_now());
- video_format_Clean(&fmtdst);
- video_format_Clean(&fmtsrc);
+ spu_PrerenderText(spu, p_subpic, chroma_list);
vlc_mutex_lock(&sys->prerender.lock);
sys->prerender.p_processed = NULL;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ff02f0a9502a996c9d62baf453fb8ff030d94d67...289427f5c45eb4e6f2ef0eb4e69466e441e4e002
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ff02f0a9502a996c9d62baf453fb8ff030d94d67...289427f5c45eb4e6f2ef0eb4e69466e441e4e002
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