From 14dd917d87e75ac1c7284373020ec3982082011b Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Mon, 15 Sep 2008 21:49:19 +0200 Subject: [PATCH] Removed unused or redondant fields from subpicture. I removed: i_x/i_y: redondant with region i_x/i_y. Now a subpicture always represent the whole video. i_flags: unused anywhere in the core. I may have broken a few video filters (osdmenu mainly). I will fix it if you report the problem and the way to reproduce it. --- include/vlc_vout.h | 7 +- modules/codec/cc.c | 4 +- modules/codec/csri.c | 2 - modules/codec/cvdsub.c | 7 +- modules/codec/dvbsub.c | 75 ++++++++++--------- modules/codec/libass.c | 2 - modules/codec/spudec/parse.c | 14 ++-- modules/codec/subtitles/subsass.c | 10 +-- modules/codec/subtitles/subsdec.c | 8 +- modules/codec/svcdsub.c | 5 +- modules/codec/telx.c | 6 +- modules/codec/zvbi.c | 3 - .../dynamicoverlay/dynamicoverlay.c | 3 - modules/video_filter/logo.c | 4 +- modules/video_filter/marq.c | 4 +- modules/video_filter/mosaic.c | 1 - modules/video_filter/osdmenu.c | 23 +++--- modules/video_filter/remoteosd.c | 2 - modules/video_filter/rss.c | 5 +- src/control/mediacontrol_audio_video.c | 42 +---------- src/osd/osd_text.c | 20 ++--- src/video_output/video_text.c | 23 +++--- src/video_output/vout_subpictures.c | 37 +++------ 23 files changed, 123 insertions(+), 184 deletions(-) diff --git a/include/vlc_vout.h b/include/vlc_vout.h index ef53fc86f6..16de5390d3 100644 --- a/include/vlc_vout.h +++ b/include/vlc_vout.h @@ -353,14 +353,11 @@ struct subpicture_t * changed by the video output thread, or simply ignored depending of the * subtitle type. */ /**@{*/ - int i_x; /**< offset from alignment position */ - int i_y; /**< offset from alignment position */ - int i_alpha; /**< transparency */ int i_original_picture_width; /**< original width of the movie */ int i_original_picture_height;/**< original height of the movie */ - bool b_absolute; /**< position is absolute */ - int i_flags; /**< position flags */ bool b_subtitle; /**< the picture is a movie subtitle */ + bool b_absolute; /**< position is absolute */ + int i_alpha; /**< transparency */ /**@}*/ /** Pointer to function that renders this subtitle in a picture */ diff --git a/modules/codec/cc.c b/modules/codec/cc.c index dc0c9f78af..f575f669f6 100644 --- a/modules/codec/cc.c +++ b/modules/codec/cc.c @@ -357,8 +357,8 @@ static subpicture_t *Subtitle( decoder_t *p_dec, char *psz_subtitle, char *psz_h /* Decode and format the subpicture unit */ /* Normal text subs, easy markup */ p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM;// | SUBPICTURE_ALIGN_LEFT;// | p_sys->i_align; - p_spu->i_x = 0; //p_sys->i_align ? 20 : 0; - p_spu->i_y = 10; + p_spu->p_region->i_x = 0; //p_sys->i_align ? 20 : 0; + p_spu->p_region->i_y = 10; p_spu->p_region->psz_text = psz_subtitle; p_spu->p_region->psz_html = psz_html; diff --git a/modules/codec/csri.c b/modules/codec/csri.c index 2730fe88fd..3086d6d45e 100644 --- a/modules/codec/csri.c +++ b/modules/codec/csri.c @@ -204,8 +204,6 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) memcpy( p_spu->p_sys->p_subs_data, p_block->p_buffer, p_block->i_buffer ); - p_spu->i_x = 0; - p_spu->i_y = 0; p_spu->i_start = p_block->i_pts; p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->b_ephemer = false; diff --git a/modules/codec/cvdsub.c b/modules/codec/cvdsub.c index 419ff204c1..90cdc33475 100644 --- a/modules/codec/cvdsub.c +++ b/modules/codec/cvdsub.c @@ -504,9 +504,6 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data ) p_spu = p_dec->pf_spu_buffer_new( p_dec ); if( !p_spu ) return NULL; - p_spu->i_x = p_sys->i_x_start; - p_spu->i_x = p_spu->i_x * 3 / 4; /* FIXME: use aspect ratio for x? */ - p_spu->i_y = p_sys->i_y_start; p_spu->i_start = p_data->i_pts; p_spu->i_stop = p_data->i_pts + p_sys->i_duration; p_spu->b_ephemer = true; @@ -526,7 +523,9 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data ) } p_spu->p_region = p_region; - p_region->i_x = p_region->i_y = 0; + p_region->i_x = p_sys->i_x_start; + p_region->i_x = p_region->i_x * 3 / 4; /* FIXME: use aspect ratio for x? */ + p_region->i_y = p_sys->i_y_start; /* Build palette */ fmt.p_palette->i_entries = 4; diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c index dc83d551df..30db44ea70 100644 --- a/modules/codec/dvbsub.c +++ b/modules/codec/dvbsub.c @@ -1446,10 +1446,42 @@ static subpicture_t *render( decoder_t *p_dec ) subpicture_t *p_spu; subpicture_region_t **pp_spu_region; int i, j, i_timeout = 0; + int i_base_x; + int i_base_y; /* Allocate the subpicture internal data. */ p_spu = p_dec->pf_spu_buffer_new( p_dec ); - if( !p_spu ) return NULL; + if( !p_spu ) + return NULL; + + p_spu->b_absolute = p_sys->b_absolute; + /* Set the pf_render callback */ + p_spu->i_start = (mtime_t) p_sys->i_pts; + //p_spu->i_stop = (mtime_t) 0; + p_spu->b_ephemer = true; + //p_spu->b_fade = true; + //p_spu->i_stop = p_spu->i_start + (mtime_t) (i_timeout * 1000000); + + /* Correct positioning of SPU */ + i_base_x = p_sys->i_spu_x; + i_base_y = p_sys->i_spu_y; + p_spu->i_original_picture_width = 720; + p_spu->i_original_picture_height = 576; + + if( p_sys->p_display ) + { + p_spu->i_original_picture_width = p_sys->p_display->i_width; + p_spu->i_original_picture_height = p_sys->p_display->i_height; + + if( p_sys->p_display->b_windowed ) + { + /* TODO: check that this actually works */ + p_spu->i_original_picture_width = p_sys->p_display->i_max_x - p_sys->p_display->i_x; + p_spu->i_original_picture_height = p_sys->p_display->i_max_y - p_sys->p_display->i_y; + i_base_x += p_sys->p_display->i_x; + i_base_y += p_sys->p_display->i_y; + } + } pp_spu_region = &p_spu->p_region; @@ -1519,8 +1551,8 @@ static subpicture_t *render( decoder_t *p_dec ) msg_Err( p_dec, "cannot allocate SPU region" ); continue; } - p_spu_region->i_x = p_regiondef->i_x; - p_spu_region->i_y = p_regiondef->i_y; + p_spu_region->i_x = i_base_x + p_regiondef->i_x; + p_spu_region->i_y = i_base_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; @@ -1574,43 +1606,14 @@ 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_x = i_base_x + p_regiondef->i_x + p_object_def->i_x; + p_spu_region->i_y = i_base_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; } } - /* Set the pf_render callback */ - p_spu->i_start = (mtime_t) p_sys->i_pts; - //p_spu->i_stop = (mtime_t) 0; - p_spu->b_ephemer = true; - //p_spu->b_fade = true; - //p_spu->i_stop = p_spu->i_start + (mtime_t) (i_timeout * 1000000); - - /* Correct positioning of SPU */ - p_spu->b_absolute = p_sys->b_absolute; - p_spu->i_x = p_sys->i_spu_x; - p_spu->i_y = p_sys->i_spu_y; - p_spu->i_original_picture_width = 720; - p_spu->i_original_picture_height = 576; - - if( p_sys->p_display ) - { - p_spu->i_original_picture_width = p_sys->p_display->i_width; - p_spu->i_original_picture_height = p_sys->p_display->i_height; - - if( p_sys->p_display->b_windowed ) - { - /* TODO: check that this actually works */ - p_spu->i_original_picture_width = p_sys->p_display->i_max_x - p_sys->p_display->i_x; - p_spu->i_original_picture_height = p_sys->p_display->i_max_y - p_sys->p_display->i_y; - p_spu->i_x += p_sys->p_display->i_x; - p_spu->i_y += p_sys->p_display->i_y; - } - } - return p_spu; } @@ -2092,8 +2095,8 @@ static void encode_page_composition( encoder_t *p_enc, bs_t *s, } else { - bs_write( s, 16, p_subpic->i_x + p_region->i_x ); - bs_write( s, 16, p_subpic->i_y + p_region->i_y ); + bs_write( s, 16, p_region->i_x ); + bs_write( s, 16, p_region->i_y ); } } } diff --git a/modules/codec/libass.c b/modules/codec/libass.c index c36845182d..5ae9c38860 100644 --- a/modules/codec/libass.c +++ b/modules/codec/libass.c @@ -272,8 +272,6 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) memcpy( p_spu->p_sys->p_subs_data, p_block->p_buffer, p_block->i_buffer ); - p_spu->i_x = 0; - p_spu->i_y = 0; p_spu->i_start = p_block->i_pts; p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->b_ephemer = true; diff --git a/modules/codec/spudec/parse.c b/modules/codec/spudec/parse.c index e8d91c9630..3e0efff3a8 100644 --- a/modules/codec/spudec/parse.c +++ b/modules/codec/spudec/parse.c @@ -44,6 +44,8 @@ typedef struct { int i_width; int i_height; + int i_x; + int i_y; } spu_properties_t; static int ParseControlSeq( decoder_t *, subpicture_t *, subpicture_data_t *, @@ -277,15 +279,15 @@ static int ParseControlSeq( decoder_t *p_dec, subpicture_t *p_spu, return VLC_EGENERIC; } - p_spu->i_x = (p_sys->buffer[i_index+1]<<4)| + p_spu_properties->i_x = (p_sys->buffer[i_index+1]<<4)| ((p_sys->buffer[i_index+2]>>4)&0x0f); p_spu_properties->i_width = (((p_sys->buffer[i_index+2]&0x0f)<<8)| - p_sys->buffer[i_index+3]) - p_spu->i_x + 1; + p_sys->buffer[i_index+3]) - p_spu_properties->i_x + 1; - p_spu->i_y = (p_sys->buffer[i_index+4]<<4)| + p_spu_properties->i_y = (p_sys->buffer[i_index+4]<<4)| ((p_sys->buffer[i_index+5]>>4)&0x0f); p_spu_properties->i_height = (((p_sys->buffer[i_index+5]&0x0f)<<8)| - p_sys->buffer[i_index+6]) - p_spu->i_y + 1; + p_sys->buffer[i_index+6]) - p_spu_properties->i_y + 1; /* Auto crop fullscreen subtitles */ if( p_spu_properties->i_height > 250 ) @@ -672,8 +674,8 @@ static void Render( decoder_t *p_dec, subpicture_t *p_spu, return; } - p_spu->p_region->i_x = 0; - p_spu->p_region->i_y = p_spu_data->i_y_top_offset; + p_spu->p_region->i_x = p_spu_properties->i_x; + p_spu->p_region->i_y = p_spu_properties->i_y + p_spu_data->i_y_top_offset; p_p = p_spu->p_region->picture.p->p_pixels; i_pitch = p_spu->p_region->picture.p->i_pitch; diff --git a/modules/codec/subtitles/subsass.c b/modules/codec/subtitles/subsass.c index 37250026c3..1706c9c78c 100644 --- a/modules/codec/subtitles/subsass.c +++ b/modules/codec/subtitles/subsass.c @@ -127,8 +127,8 @@ void ParseSSAString( decoder_t *p_dec, if( p_style == NULL ) { 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; + p_spu->p_region->i_x = p_sys->i_align ? 20 : 0; + p_spu->p_region->i_y = 10; } else { @@ -137,13 +137,13 @@ void ParseSSAString( decoder_t *p_dec, 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; + p_spu->p_region->i_x = (i_margin_l) ? i_margin_l : p_style->i_margin_h; } else if( p_style->i_align & SUBPICTURE_ALIGN_RIGHT ) { - p_spu->i_x = (i_margin_r) ? i_margin_r : p_style->i_margin_h; + p_spu->p_region->i_x = (i_margin_r) ? i_margin_r : p_style->i_margin_h; } - p_spu->i_y = (i_margin_v) ? i_margin_v : p_style->i_margin_v; + p_spu->p_region->i_y = (i_margin_v) ? i_margin_v : p_style->i_margin_v; } } diff --git a/modules/codec/subtitles/subsdec.c b/modules/codec/subtitles/subsdec.c index 2417e67421..b8f5743e35 100644 --- a/modules/codec/subtitles/subsdec.c +++ b/modules/codec/subtitles/subsdec.c @@ -427,8 +427,8 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block ) { /* Normal text subs, easy markup */ 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; + p_spu->p_region->i_x = p_sys->i_align ? 20 : 0; + p_spu->p_region->i_y = 10; /* Remove formatting from string */ @@ -616,8 +616,8 @@ static char *CreateHtmlSubtitle( int *pi_align, char *psz_subtitle ) /* Check for forced alignment */ if( !strncmp( psz_subtitle, "{\\an", 4 ) && psz_subtitle[4] >= '1' && psz_subtitle[4] <= '9' && psz_subtitle[5] == '}' ) { - static const pi_vertical[3] = { SUBPICTURE_ALIGN_BOTTOM, 0, SUBPICTURE_ALIGN_TOP }; - static const pi_horizontal[3] = { SUBPICTURE_ALIGN_LEFT, 0, SUBPICTURE_ALIGN_RIGHT }; + static const int pi_vertical[3] = { SUBPICTURE_ALIGN_BOTTOM, 0, SUBPICTURE_ALIGN_TOP }; + static const int pi_horizontal[3] = { SUBPICTURE_ALIGN_LEFT, 0, SUBPICTURE_ALIGN_RIGHT }; const int i_id = psz_subtitle[4] - '1'; *pi_align = pi_vertical[i_id/3] | pi_horizontal[i_id%3]; diff --git a/modules/codec/svcdsub.c b/modules/codec/svcdsub.c index f0d174f5d3..2c54c17029 100644 --- a/modules/codec/svcdsub.c +++ b/modules/codec/svcdsub.c @@ -473,8 +473,6 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data ) p_spu = p_dec->pf_spu_buffer_new( p_dec ); if( !p_spu ) return NULL; - p_spu->i_x = p_sys->i_x_start; - p_spu->i_y = p_sys->i_y_start; p_spu->i_start = p_data->i_pts; p_spu->i_stop = p_data->i_pts + p_sys->i_duration; p_spu->b_ephemer = true; @@ -506,7 +504,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data ) p_region->fmt.i_aspect = VOUT_ASPECT_FACTOR; p_spu->p_region = p_region; - p_region->i_x = p_region->i_y = 0; + p_region->i_x = p_sys->i_x_start; + p_region->i_y = p_sys->i_y_start; /* Build palette */ fmt.p_palette->i_entries = 4; diff --git a/modules/codec/telx.c b/modules/codec/telx.c index 0be2a04a03..6da895d0d2 100644 --- a/modules/codec/telx.c +++ b/modules/codec/telx.c @@ -717,10 +717,10 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block ) /* Normal text subs, easy markup */ 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; - + p_spu->p_region->i_x = p_sys->i_align ? 20 : 0; + p_spu->p_region->i_y = 10; p_spu->p_region->psz_text = strdup(psz_text); + p_spu->i_start = p_block->i_pts; p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->b_ephemer = (p_block->i_length == 0); diff --git a/modules/codec/zvbi.c b/modules/codec/zvbi.c index c5c0e7b911..88fe5bd269 100644 --- a/modules/codec/zvbi.c +++ b/modules/codec/zvbi.c @@ -495,9 +495,6 @@ static subpicture_t *Subpicture( decoder_t *p_dec, video_format_t *p_fmt, p_spu->p_region->i_y = 0; p_spu->p_region->i_align = i_align; - /* Normal text subs, easy markup */ - p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM; - p_spu->i_start = i_pts; p_spu->i_stop = 0; p_spu->b_ephemer = true; diff --git a/modules/video_filter/dynamicoverlay/dynamicoverlay.c b/modules/video_filter/dynamicoverlay/dynamicoverlay.c index 02e9a56cd3..77bcd5d794 100644 --- a/modules/video_filter/dynamicoverlay/dynamicoverlay.c +++ b/modules/video_filter/dynamicoverlay/dynamicoverlay.c @@ -337,9 +337,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) return NULL; } - p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP; - p_spu->i_x = 0; - p_spu->i_y = 0; p_spu->b_absolute = true; p_spu->i_start = date; p_spu->i_stop = 0; diff --git a/modules/video_filter/logo.c b/modules/video_filter/logo.c index 004096ac3a..4c7321da3f 100644 --- a/modules/video_filter/logo.c +++ b/modules/video_filter/logo.c @@ -888,8 +888,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) p_spu->b_absolute = false; } - p_spu->i_x = p_sys->posx; - p_spu->i_y = p_sys->posy; + p_region->i_x = p_sys->posx; + p_region->i_y = p_sys->posy; p_spu->p_region = p_region; diff --git a/modules/video_filter/marq.c b/modules/video_filter/marq.c index e454ca907c..030442b65d 100644 --- a/modules/video_filter/marq.c +++ b/modules/video_filter/marq.c @@ -317,8 +317,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) p_spu->b_absolute = false; } - p_spu->i_x = p_sys->i_xoff; - p_spu->i_y = p_sys->i_yoff; + p_spu->p_region->i_x = p_sys->i_xoff; + p_spu->p_region->i_y = p_sys->i_yoff; p_spu->p_region->p_style = p_sys->p_style; diff --git a/modules/video_filter/mosaic.c b/modules/video_filter/mosaic.c index 8c6ac46f68..b581dbd53e 100644 --- a/modules/video_filter/mosaic.c +++ b/modules/video_filter/mosaic.c @@ -458,7 +458,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) p_spu->i_stop = 0; p_spu->b_ephemer = true; p_spu->i_alpha = p_sys->i_alpha; - p_spu->i_flags = p_sys->i_align; p_spu->b_absolute = false; vlc_mutex_lock( &p_sys->lock ); diff --git a/modules/video_filter/osdmenu.c b/modules/video_filter/osdmenu.c index 3393d660b3..d8f68f7a3e 100644 --- a/modules/video_filter/osdmenu.c +++ b/modules/video_filter/osdmenu.c @@ -451,6 +451,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) filter_sys_t *p_sys = p_filter->p_sys; subpicture_t *p_spu = NULL; subpicture_region_t *p_region = NULL; + int i_x, i_y; if( !p_sys->b_update || (p_sys->i_update <= 0) ) return NULL; @@ -472,7 +473,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) p_spu->b_absolute = true; else p_spu->b_absolute = p_sys->b_absolute; - p_spu->i_flags = p_sys->i_position; /* Determine the duration of the subpicture */ if( p_sys->i_end_date > 0 ) @@ -505,8 +505,11 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) NULL ); /* proper positioning of OSD menu image */ - p_spu->i_x = p_filter->p_sys->p_menu->p_state->i_x; - p_spu->i_y = p_filter->p_sys->p_menu->p_state->i_y; + p_region->i_x = p_filter->p_sys->p_menu->p_state->i_x; + p_region->i_y = p_filter->p_sys->p_menu->p_state->i_y; + /* FIXME is it needed ? + p_region->i_align = p_sys->i_position; + */ p_spu->p_region = p_region; p_spu->i_alpha = 0xFF; /* Picture is completely non transparent. */ return p_spu; @@ -535,14 +538,16 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) /* proper positioning of OSD menu image */ if( p_filter->p_sys->p_menu->i_style == OSD_MENU_STYLE_CONCAT ) { - p_spu->i_x = p_filter->p_sys->p_menu->p_button->i_x; - p_spu->i_y = p_filter->p_sys->p_menu->p_button->i_y; + i_x = p_filter->p_sys->p_menu->p_button->i_x; + i_y = p_filter->p_sys->p_menu->p_button->i_y; } else { - p_spu->i_x = p_filter->p_sys->p_menu->p_state->i_x; - p_spu->i_y = p_filter->p_sys->p_menu->p_state->i_y; + i_x = p_filter->p_sys->p_menu->p_state->i_x; + i_y = p_filter->p_sys->p_menu->p_state->i_y; } + p_region->i_x = i_x; + p_region->i_y = i_y; if( p_filter->p_sys->p_menu->i_style == OSD_MENU_STYLE_CONCAT ) { @@ -582,8 +587,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) } else { - p_new->i_x = p_region_tail->fmt.i_visible_width; - p_new->i_y = p_button->i_y; + p_new->i_x = i_x+p_region_tail->fmt.i_visible_width; + p_new->i_y = i_y+p_button->i_y; p_region_tail->p_next = p_new; p_region_tail = p_new; } diff --git a/modules/video_filter/remoteosd.c b/modules/video_filter/remoteosd.c index 1bd84ca14e..04ef5d2fe3 100644 --- a/modules/video_filter/remoteosd.c +++ b/modules/video_filter/remoteosd.c @@ -1182,8 +1182,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) p_spu->b_absolute = false; - p_spu->i_x = 0; - p_spu->i_y = 0; p_spu->i_original_picture_width = 0; /*Let vout core do the horizontal scaling */ p_spu->i_original_picture_height = fmt.i_height; diff --git a/modules/video_filter/rss.c b/modules/video_filter/rss.c index f4d9e21589..29a42debce 100644 --- a/modules/video_filter/rss.c +++ b/modules/video_filter/rss.c @@ -530,9 +530,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) p_spu->b_absolute = false; } - p_spu->i_x = p_sys->i_xoff; - p_spu->i_y = p_sys->i_yoff; - p_spu->p_region->p_style = p_sys->p_style; if( p_feed->p_pic ) @@ -558,6 +555,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) } else { + p_region->i_x = p_sys->i_xoff; + p_region->i_y = p_sys->i_yoff; vout_CopyPicture( p_filter, &p_region->picture, p_pic ); p_spu->p_region->p_next = p_region; } diff --git a/src/control/mediacontrol_audio_video.c b/src/control/mediacontrol_audio_video.c index e0a6f7c55d..cf6f0268c9 100644 --- a/src/control/mediacontrol_audio_video.c +++ b/src/control/mediacontrol_audio_video.c @@ -127,44 +127,10 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel, int i_flags, int i_hmargin, int i_vmargin, mtime_t i_start, mtime_t i_stop ) { - subpicture_t *p_spu; - video_format_t fmt; - - if( !psz_string ) return VLC_EGENERIC; - - p_spu = spu_CreateSubpicture( p_vout->p_spu ); - if( !p_spu ) return VLC_EGENERIC; - - /* Create a new subpicture region */ - memset( &fmt, 0, sizeof(video_format_t) ); - fmt.i_chroma = VLC_FOURCC('T','E','X','T'); - fmt.i_aspect = 0; - fmt.i_width = fmt.i_height = 0; - fmt.i_x_offset = fmt.i_y_offset = 0; - p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_vout), &fmt ); - if( !p_spu->p_region ) - { - msg_Err( p_vout, "cannot allocate SPU region" ); - spu_DestroySubpicture( p_vout->p_spu, p_spu ); - return VLC_EGENERIC; - } - - p_spu->p_region->psz_text = strdup( psz_string ); - p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK; - p_spu->p_region->p_style = p_style; - p_spu->i_start = i_start; - p_spu->i_stop = i_stop; - p_spu->b_ephemer = false; - p_spu->b_absolute = false; - - p_spu->i_x = i_hmargin; - p_spu->i_y = i_vmargin; - p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK; - p_spu->i_channel = i_channel; - - spu_DisplaySubpicture( p_vout->p_spu, p_spu ); - - return VLC_SUCCESS; + return osd_ShowTextAbsolute( p_vout->p_spu, i_channel, + psz_string, p_style, + i_flags, i_hmargin, i_vmargin, + i_start, i_stop ); } diff --git a/src/osd/osd_text.c b/src/osd/osd_text.c index fc878fc37b..ea2c969ac4 100644 --- a/src/osd/osd_text.c +++ b/src/osd/osd_text.c @@ -79,7 +79,14 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel, if( !psz_string ) return VLC_EGENERIC; p_spu = spu_CreateSubpicture( p_spu_channel ); - if( !p_spu ) return VLC_EGENERIC; + if( !p_spu ) + return VLC_EGENERIC; + + p_spu->i_channel = i_channel; + p_spu->i_start = i_start; + p_spu->i_stop = i_stop; + p_spu->b_ephemer = true; + p_spu->b_absolute = false; /* Create a new subpicture region */ memset( &fmt, 0, sizeof(video_format_t) ); @@ -97,15 +104,8 @@ 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 = true; - p_spu->b_absolute = false; - - p_spu->i_x = i_hmargin; - p_spu->i_y = i_vmargin; - p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK; - p_spu->i_channel = i_channel; + p_spu->p_region->i_x = i_hmargin; + p_spu->p_region->i_y = i_vmargin; spu_DisplaySubpicture( p_spu_channel, p_spu ); diff --git a/src/video_output/video_text.c b/src/video_output/video_text.c index 2083438707..a0499bb0e6 100644 --- a/src/video_output/video_text.c +++ b/src/video_output/video_text.c @@ -81,7 +81,16 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel, if( !psz_string ) return VLC_EGENERIC; p_spu = spu_CreateSubpicture( p_vout->p_spu ); - if( !p_spu ) return VLC_EGENERIC; + if( !p_spu ) + return VLC_EGENERIC; + + p_spu->i_channel = i_channel; + p_spu->i_start = i_start; + p_spu->i_stop = i_stop; + p_spu->b_ephemer = true; + p_spu->b_absolute = false; + p_spu->b_fade = true; + /* Create a new subpicture region */ memset( &fmt, 0, sizeof(video_format_t) ); @@ -99,16 +108,8 @@ 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 = true; - p_spu->b_absolute = false; - p_spu->b_fade = true; - - p_spu->i_x = i_hmargin; - p_spu->i_y = i_vmargin; - p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK; - p_spu->i_channel = i_channel; + p_spu->p_region->i_x = i_hmargin; + p_spu->p_region->i_y = i_vmargin; 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 5d102c21ad..2894b276e5 100644 --- a/src/video_output/vout_subpictures.c +++ b/src/video_output/vout_subpictures.c @@ -660,20 +660,10 @@ static void SpuRegionPlace( int *pi_x, int *pi_y, const video_format_t *p_fmt, const subpicture_t *p_subpic, const subpicture_region_t *p_region, - int i_subpic_x, - int i_inv_scale_x, int i_inv_scale_y, - int i_scale_width, int i_scale_height ) + int i_inv_scale_x, int i_inv_scale_y ) { - /* FIXME i_delta_x/y and i_x/y in absolute mode does not use the same - * it seems weird unless I missed something - * At this point we have: - * i_subpic_x == p_subpic->i_x * i_scale_width / SCALE_UNIT - * p_region->i_x/i_y have already been scaled by i_scale_width/i_scale_height. - * */ - int i_delta_x = ( i_subpic_x + p_region->i_x ) * - i_inv_scale_x / SCALE_UNIT; - int i_delta_y = ( p_subpic->i_y + p_region->i_y ) * - i_inv_scale_y / SCALE_UNIT; + int i_delta_x = p_region->i_x * i_inv_scale_x / SCALE_UNIT; + int i_delta_y = p_region->i_y * i_inv_scale_y / SCALE_UNIT; int i_x, i_y; if( p_region->i_align & SUBPICTURE_ALIGN_TOP ) @@ -704,10 +694,8 @@ static void SpuRegionPlace( int *pi_x, int *pi_y, if( p_subpic->b_absolute ) { - i_x = (p_region->i_x + i_subpic_x * i_scale_width / SCALE_UNIT) * - i_inv_scale_x / SCALE_UNIT; - i_y = (p_region->i_y + p_subpic->i_y * i_scale_height / SCALE_UNIT) * - i_inv_scale_y / SCALE_UNIT; + i_x = i_delta_x; + i_y = i_delta_y; } *pi_x = __MAX( i_x, 0 ); @@ -718,7 +706,6 @@ static void SpuRenderRegion( spu_t *p_spu, picture_t *p_pic_dst, subpicture_t *p_subpic, subpicture_region_t *p_region, const int i_scale_width_orig, const int i_scale_height_orig, - const int pi_subpic_x[SCALE_SIZE], const int pi_scale_width[SCALE_SIZE], const int pi_scale_height[SCALE_SIZE], const video_format_t *p_fmt ) @@ -869,9 +856,8 @@ static void SpuRenderRegion( spu_t *p_spu, /* */ SpuRegionPlace( &i_x_offset, &i_y_offset, - p_fmt, p_subpic, p_region, pi_subpic_x[i_scale_idx], - i_inv_scale_x, i_inv_scale_y, - pi_scale_width[i_scale_idx], pi_scale_height[i_scale_idx] ); + p_fmt, p_subpic, p_region, + i_inv_scale_x, i_inv_scale_y ); if( p_spu->i_margin != 0 && !b_force_crop ) { @@ -1059,7 +1045,6 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, subpicture_region_t *p_region; int pi_scale_width[ SCALE_SIZE ]; int pi_scale_height[ SCALE_SIZE ]; - int pi_subpic_x[ SCALE_SIZE ]; int k; if( !p_subpic->p_region ) @@ -1171,19 +1156,15 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, } /* Take care of the aspect ratio */ - for( k = 0; k < SCALE_SIZE ; k++ ) - pi_subpic_x[k] = p_subpic->i_x; - if( ( p_region->fmt.i_sar_num * p_fmt->i_sar_den ) != ( p_region->fmt.i_sar_den * p_fmt->i_sar_num ) ) { + /* FIXME FIXME what about region->i_x/i_y ? */ for( k = 0; k < SCALE_SIZE; k++ ) { pi_scale_width[k] = pi_scale_width[k] * (int64_t)p_region->fmt.i_sar_num * p_fmt->i_sar_den / p_region->fmt.i_sar_den / p_fmt->i_sar_num; - - pi_subpic_x[k] = p_subpic->i_x * pi_scale_width[ k ] / SCALE_UNIT; } } @@ -1191,7 +1172,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, for( ; p_region != NULL; p_region = p_region->p_next ) SpuRenderRegion( p_spu, p_pic_dst, p_subpic, p_region, i_scale_width_orig, i_scale_height_orig, - pi_subpic_x, pi_scale_width, pi_scale_height, + pi_scale_width, pi_scale_height, p_fmt ); } -- 2.39.2