From 23cc599d06abb5c84913c7399dd08c6b283fc49e Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Mon, 18 Jun 2007 21:08:03 +0000 Subject: [PATCH] Patch by Bernie Purcell : "This is part of a former submission stripped out for easier assimilation. It modifies vout_subpictures to use the existing alignment field on each region, rather than the alignment on the subpicture plane itself. Modifications are made to everywhere that depended on the former behaviour, to make it use the new alignment location instead." --- include/vlc_vout.h | 2 ++ modules/codec/dvbsub.c | 2 ++ modules/codec/subsdec.c | 12 ++++++------ modules/codec/telx.c | 2 +- modules/video_filter/logo.c | 4 ++-- modules/video_filter/marq.c | 4 ++-- modules/video_filter/mosaic.c | 1 + modules/video_filter/rss.c | 4 ++-- src/control/mediacontrol_audio_video.c | 3 ++- src/osd/osd_text.c | 3 ++- src/video_output/video_text.c | 3 ++- src/video_output/vout_subpictures.c | 15 +++++++-------- 12 files changed, 31 insertions(+), 24 deletions(-) diff --git a/include/vlc_vout.h b/include/vlc_vout.h index 7c5c842ee1..6ac217e653 100644 --- a/include/vlc_vout.h +++ b/include/vlc_vout.h @@ -306,6 +306,8 @@ struct subpicture_t #define SUBPICTURE_ALIGN_RIGHT 0x2 #define SUBPICTURE_ALIGN_TOP 0x4 #define SUBPICTURE_ALIGN_BOTTOM 0x8 +#define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \ + SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM ) /***************************************************************************** * Prototypes diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c index 43f3704330..ecc726a526 100644 --- a/modules/codec/dvbsub.c +++ b/modules/codec/dvbsub.c @@ -1492,6 +1492,7 @@ static subpicture_t *render( decoder_t *p_dec ) } p_spu_region->i_x = p_regiondef->i_x; p_spu_region->i_y = p_regiondef->i_y; + p_spu_region->i_align = p_sys->i_spu_position; *pp_spu_region = p_spu_region; pp_spu_region = &p_spu_region->p_next; @@ -1546,6 +1547,7 @@ static subpicture_t *render( decoder_t *p_dec ) p_spu_region->psz_text = strdup( p_object_def->psz_text ); p_spu_region->i_x = p_regiondef->i_x + p_object_def->i_x; p_spu_region->i_y = p_regiondef->i_y + p_object_def->i_y; + p_spu_region->i_align = p_sys->i_spu_position; *pp_spu_region = p_spu_region; pp_spu_region = &p_spu_region->p_next; } diff --git a/modules/codec/subsdec.c b/modules/codec/subsdec.c index e4d66b309b..b8c368cb35 100644 --- a/modules/codec/subsdec.c +++ b/modules/codec/subsdec.c @@ -448,7 +448,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block ) p_dec->fmt_in.i_codec != VLC_FOURCC('u','s','f',' ') ) { /* Normal text subs, easy markup */ - p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; + p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; p_spu->i_x = p_sys->i_align ? 20 : 0; p_spu->i_y = 10; @@ -574,7 +574,7 @@ static void ParseUSFString( decoder_t *p_dec, char *psz_subtitle, subpicture_t * if( p_style == NULL ) { - p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; + p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; p_spu->i_x = p_sys->i_align ? 20 : 0; p_spu->i_y = 10; } @@ -582,7 +582,7 @@ static void ParseUSFString( decoder_t *p_dec, char *psz_subtitle, subpicture_t * { msg_Dbg( p_dec, "style is: %s", p_style->psz_stylename); p_spu->p_region->p_style = &p_style->font_style; - p_spu->i_flags = p_style->i_align; + p_spu->p_region->i_align = p_style->i_align; } } @@ -678,7 +678,7 @@ static void ParseSSAString( decoder_t *p_dec, char *psz_subtitle, subpicture_t * p_spu->p_region->psz_text = psz_new_subtitle; if( p_style == NULL ) { - p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; + p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; p_spu->i_x = p_sys->i_align ? 20 : 0; p_spu->i_y = 10; } @@ -686,7 +686,7 @@ static void ParseSSAString( decoder_t *p_dec, char *psz_subtitle, subpicture_t * { msg_Dbg( p_dec, "style is: %s", p_style->psz_stylename); p_spu->p_region->p_style = &p_style->font_style; - p_spu->i_flags = p_style->i_align; + p_spu->p_region->i_align = p_style->i_align; if( p_style->i_align & SUBPICTURE_ALIGN_LEFT ) { p_spu->i_x = (i_margin_l) ? i_margin_l : p_style->i_margin_h; @@ -1147,7 +1147,7 @@ static void ParseSSAHeader( decoder_t *p_dec ) //p_style->font_style.f_angle = f_angle; p_style->i_align = 0; - if( i_align == 0x1 || i_align == 0x4 || i_align == 0x1 ) p_style->i_align |= SUBPICTURE_ALIGN_LEFT; + if( i_align == 0x1 || i_align == 0x4 || i_align == 0x7 ) p_style->i_align |= SUBPICTURE_ALIGN_LEFT; if( i_align == 0x3 || i_align == 0x6 || i_align == 0x9 ) p_style->i_align |= SUBPICTURE_ALIGN_RIGHT; if( i_align == 0x7 || i_align == 0x8 || i_align == 0x9 ) p_style->i_align |= SUBPICTURE_ALIGN_TOP; if( i_align == 0x1 || i_align == 0x2 || i_align == 0x3 ) p_style->i_align |= SUBPICTURE_ALIGN_BOTTOM; diff --git a/modules/codec/telx.c b/modules/codec/telx.c index 0fdde18bc7..123cd52b77 100644 --- a/modules/codec/telx.c +++ b/modules/codec/telx.c @@ -711,7 +711,7 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block ) } /* Normal text subs, easy markup */ - p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; + p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; p_spu->i_x = p_sys->i_align ? 20 : 0; p_spu->i_y = 10; diff --git a/modules/video_filter/logo.c b/modules/video_filter/logo.c index 5cd42ba9fe..4dc19ecdee 100644 --- a/modules/video_filter/logo.c +++ b/modules/video_filter/logo.c @@ -882,14 +882,14 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) /* where to locate the logo: */ if( p_sys->posx < 0 || p_sys->posy < 0 ) { /* set to one of the 9 relative locations */ - p_spu->i_flags = p_sys->pos; + p_spu->p_region->i_align = p_sys->pos; p_spu->i_x = 0; p_spu->i_y = 0; p_spu->b_absolute = VLC_FALSE; } else { /* set to an absolute xy, referenced to upper left corner */ - p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP; + p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP; p_spu->i_x = p_sys->posx; p_spu->i_y = p_sys->posy; p_spu->b_absolute = VLC_TRUE; diff --git a/modules/video_filter/marq.c b/modules/video_filter/marq.c index ed956557bc..5134b4b57d 100644 --- a/modules/video_filter/marq.c +++ b/modules/video_filter/marq.c @@ -296,14 +296,14 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) /* where to locate the string: */ if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 ) { /* set to one of the 9 relative locations */ - p_spu->i_flags = p_sys->i_pos; + p_spu->p_region->i_align = p_sys->i_pos; p_spu->i_x = 0; p_spu->i_y = 0; p_spu->b_absolute = VLC_FALSE; } else { /* set to an absolute xy, referenced to upper left corner */ - p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP; + p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP; p_spu->i_x = p_sys->i_xoff; p_spu->i_y = p_sys->i_yoff; p_spu->b_absolute = VLC_TRUE; diff --git a/modules/video_filter/mosaic.c b/modules/video_filter/mosaic.c index 72bc5ee5ff..babe36f278 100644 --- a/modules/video_filter/mosaic.c +++ b/modules/video_filter/mosaic.c @@ -710,6 +710,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) + ( i_row * p_sys->i_borderh ) / p_sys->i_rows + ( row_inner_height - fmt_out.i_height ) / 2; } + p_region->i_align = p_sys->i_align; if( p_region_prev == NULL ) { diff --git a/modules/video_filter/rss.c b/modules/video_filter/rss.c index 8fb784f69f..ca12e524ce 100644 --- a/modules/video_filter/rss.c +++ b/modules/video_filter/rss.c @@ -482,14 +482,14 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) /* where to locate the string: */ if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 ) { /* set to one of the 9 relative locations */ - p_spu->i_flags = p_sys->i_pos; + p_spu->p_region->i_align = p_sys->i_pos; p_spu->i_x = 0; p_spu->i_y = 0; p_spu->b_absolute = VLC_FALSE; } else { /* set to an absolute xy, referenced to upper left corner */ - p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP; + p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP; p_spu->i_x = p_sys->i_xoff; p_spu->i_y = p_sys->i_yoff; p_spu->b_absolute = VLC_TRUE; diff --git a/src/control/mediacontrol_audio_video.c b/src/control/mediacontrol_audio_video.c index 584f5049ef..a92cc497fe 100644 --- a/src/control/mediacontrol_audio_video.c +++ b/src/control/mediacontrol_audio_video.c @@ -146,6 +146,7 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel, } p_spu->p_region->psz_text = strdup( psz_string ); + p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK; p_spu->i_start = i_start; p_spu->i_stop = i_stop; p_spu->b_ephemer = VLC_FALSE; @@ -153,7 +154,7 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel, p_spu->i_x = i_hmargin; p_spu->i_y = i_vmargin; - p_spu->i_flags = i_flags; + p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK; p_spu->i_channel = i_channel; spu_DisplaySubpicture( p_vout->p_spu, p_spu ); diff --git a/src/osd/osd_text.c b/src/osd/osd_text.c index 1e9490b83c..507d48ac70 100644 --- a/src/osd/osd_text.c +++ b/src/osd/osd_text.c @@ -92,6 +92,7 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel, } p_spu->p_region->psz_text = strdup( psz_string ); + p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK; p_spu->i_start = i_start; p_spu->i_stop = i_stop; p_spu->b_ephemer = VLC_TRUE; @@ -99,7 +100,7 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel, p_spu->i_x = i_hmargin; p_spu->i_y = i_vmargin; - p_spu->i_flags = i_flags; + p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK; p_spu->i_channel = i_channel; spu_DisplaySubpicture( p_spu_channel, p_spu ); diff --git a/src/video_output/video_text.c b/src/video_output/video_text.c index c5f2e7cf5c..ea9642554f 100644 --- a/src/video_output/video_text.c +++ b/src/video_output/video_text.c @@ -93,6 +93,7 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel, } p_spu->p_region->psz_text = strdup( psz_string ); + p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK; p_spu->i_start = i_start; p_spu->i_stop = i_stop; p_spu->b_ephemer = VLC_TRUE; @@ -101,7 +102,7 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel, p_spu->i_x = i_hmargin; p_spu->i_y = i_vmargin; - p_spu->i_flags = i_flags; + p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK; p_spu->i_channel = i_channel; spu_DisplaySubpicture( p_vout->p_spu, p_spu ); diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c index 3be8471213..98d719d693 100644 --- a/src/video_output/vout_subpictures.c +++ b/src/video_output/vout_subpictures.c @@ -661,8 +661,6 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, { if( p_spu->p_text && p_spu->p_text->p_module ) { - p_region->i_align = p_subpic->i_flags; - if( p_spu->p_text->pf_render_html && p_region->psz_html ) { p_spu->p_text->pf_render_html( p_spu->p_text, @@ -728,6 +726,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, p_region->p_cache->fmt = p_spu->p_scale->fmt_out.video; p_region->p_cache->i_x = p_region->i_x * i_scale_width / 1000; p_region->p_cache->i_y = p_region->i_y * i_scale_height / 1000; + p_region->p_cache->i_align = p_region->i_align; p_pic = p_spu->p_scale->pf_video_filter( p_spu->p_scale, &p_region->p_cache->picture ); @@ -745,22 +744,22 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, p_region = p_region->p_cache; } - if( p_subpic->i_flags & SUBPICTURE_ALIGN_BOTTOM ) + if( p_region->i_align & SUBPICTURE_ALIGN_BOTTOM ) { i_y_offset = p_fmt->i_height - p_region->fmt.i_height - - p_subpic->i_y; + p_subpic->i_y - p_region->i_y; } - else if ( !(p_subpic->i_flags & SUBPICTURE_ALIGN_TOP) ) + else if ( !(p_region->i_align & SUBPICTURE_ALIGN_TOP) ) { i_y_offset = p_fmt->i_height / 2 - p_region->fmt.i_height / 2; } - if( p_subpic->i_flags & SUBPICTURE_ALIGN_RIGHT ) + if( p_region->i_align & SUBPICTURE_ALIGN_RIGHT ) { i_x_offset = p_fmt->i_width - p_region->fmt.i_width - - i_subpic_x; + i_subpic_x - p_region->i_x; } - else if ( !(p_subpic->i_flags & SUBPICTURE_ALIGN_LEFT) ) + else if ( !(p_region->i_align & SUBPICTURE_ALIGN_LEFT) ) { i_x_offset = p_fmt->i_width / 2 - p_region->fmt.i_width / 2; } -- 2.39.2