[vlc-commits] codec: cc/substext: handle relative offset, don't use cc/row coords
Francois Cartegnie
git at videolan.org
Thu Sep 28 19:30:13 CEST 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Sep 28 17:57:05 2017 +0200| [f1c456ae9c9cbe262d18e22142bce101e47ec3f2] | committer: Francois Cartegnie
codec: cc/substext: handle relative offset, don't use cc/row coords
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f1c456ae9c9cbe262d18e22142bce101e47ec3f2
---
modules/codec/cc.c | 10 ++++++++--
modules/codec/substext.h | 36 ++++++++++++++++++++----------------
2 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index 2ed58cc27a..56d9343a31 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -102,6 +102,10 @@ typedef enum
#define EIA608_SCREEN_ROWS 15
#define EIA608_SCREEN_COLUMNS 32
+#define EIA608_MARGIN 0.10
+#define EIA608_VISIBLE (1.0 - EIA608_MARGIN * 2)
+#define FONT_TO_LINE_HEIGHT_RATIO 1.06
+
struct eia608_screen // A CC buffer
{
uint8_t characters[EIA608_SCREEN_ROWS][EIA608_SCREEN_COLUMNS+1];
@@ -452,7 +456,7 @@ static subpicture_t *Subtitle( decoder_t *p_dec, eia608_t *h, mtime_t i_pts )
p_spu_sys->p_default_style->i_features |= STYLE_HAS_BACKGROUND_ALPHA;
p_spu_sys->p_default_style->i_style_flags |= STYLE_BACKGROUND;
}
- p_spu_sys->margin_ratio = 0.10;
+ p_spu_sys->margin_ratio = EIA608_MARGIN;
p_spu_sys->p_default_style->i_font_color = rgi_eia608_colors[EIA608_COLOR_DEFAULT];
/* FCC defined "safe area" for EIA-608 captions is 80% of the height of the display */
p_spu_sys->p_default_style->f_font_relsize = EIA608_VISIBLE * 100 / EIA608_SCREEN_ROWS /
@@ -1159,7 +1163,9 @@ static void Eia608FillUpdaterRegions( subpicture_updater_sys_t *p_updater, eia60
if( p_region->p_segments == NULL ) /* First segment in the [new] region */
{
- p_region->origin.y = i; /* set start line number */
+ p_region->origin.y = (float) i /* start line number */
+ / (EIA608_SCREEN_ROWS * FONT_TO_LINE_HEIGHT_RATIO);
+ p_region->flags |= UPDT_REGION_ORIGIN_Y_IS_PERCENTILE;
}
else /* Insert line break between region lines */
{
diff --git a/modules/codec/substext.h b/modules/codec/substext.h
index 6fd519e0b8..076f42b701 100644
--- a/modules/codec/substext.h
+++ b/modules/codec/substext.h
@@ -37,18 +37,12 @@ enum subpicture_updater_sys_region_flags_e
UPDT_REGION_FIX_DONE = 1 << 31,
};
-#define EIA608_MARGIN 0.10
-#define EIA608_VISIBLE 0.80
-#define EIA608_ROWS 15
-
-#define FONT_TO_LINE_HEIGHT_RATIO 1.06
-
struct subpicture_updater_sys_region_t
{
struct
{
- int x;
- int y;
+ float x;
+ float y;
} origin, extent;
/* store above percentile meanings as modifier flags */
int flags; /* subpicture_updater_sys_region_flags_e */
@@ -184,22 +178,32 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
: fmt_dst->i_visible_width );
const int margin_v = margin_ratio * fmt_dst->i_visible_height;
+ /* subpic invisible margins sizes */
+ const int outerright_h = fmt_dst->i_width - (fmt_dst->i_visible_width + fmt_dst->i_x_offset);
+ const int outerbottom_v = fmt_dst->i_height - (fmt_dst->i_visible_height + fmt_dst->i_y_offset);
+ /* regions usable */
+ const int inner_w = fmt_dst->i_visible_width - margin_h * 2;
+ const int inner_h = fmt_dst->i_visible_height - margin_v * 2;
+
if (r->i_align & SUBPICTURE_ALIGN_LEFT)
r->i_x = margin_h + fmt_dst->i_x_offset;
else if (r->i_align & SUBPICTURE_ALIGN_RIGHT)
- r->i_x = margin_h + fmt_dst->i_width - (fmt_dst->i_visible_width + fmt_dst->i_x_offset);
+ r->i_x = margin_h + outerright_h;
if (r->i_align & SUBPICTURE_ALIGN_TOP )
r->i_y = margin_v + fmt_dst->i_y_offset;
else if (r->i_align & SUBPICTURE_ALIGN_BOTTOM )
- r->i_y = margin_v + fmt_dst->i_height - (fmt_dst->i_visible_height + fmt_dst->i_y_offset);
+ r->i_y = margin_v + outerbottom_v;
- if( r->b_gridmode )
- {
- r->i_y += p_updtregion->origin.y * /* row number */
- (EIA608_VISIBLE / EIA608_ROWS) *
- (fmt_dst->i_visible_height - r->i_y) * FONT_TO_LINE_HEIGHT_RATIO;
- }
+ if( p_updtregion->flags & UPDT_REGION_ORIGIN_X_IS_PERCENTILE )
+ r->i_x += p_updtregion->origin.x * inner_w;
+ else
+ r->i_x += p_updtregion->origin.x;
+
+ if( p_updtregion->flags & UPDT_REGION_ORIGIN_Y_IS_PERCENTILE )
+ r->i_y += p_updtregion->origin.y * inner_h;
+ else
+ r->i_y += p_updtregion->origin.y;
} else {
/* FIXME it doesn't adapt on crop settings changes */
More information about the vlc-commits
mailing list