[vlc-commits] [Git][videolan/vlc][master] 8 commits: codec/ttml: remove VLC_UNUSED of used variable
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Oct 26 12:34:54 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
1acaa895 by Steve Lhomme at 2023-10-26T12:10:15+00:00
codec/ttml: remove VLC_UNUSED of used variable
- - - - -
fbd19c1c by Steve Lhomme at 2023-10-26T12:10:15+00:00
subsusf: check the plain text allocation succeeds
Otherwise we should not create a region with bogus text. The code is similar to
the other CreateTextRegion() call logic.
- - - - -
455cca65 by Steve Lhomme at 2023-10-26T12:10:15+00:00
subsusf: set the text in the region in one call
- - - - -
e184b46a by Steve Lhomme at 2023-10-26T12:10:15+00:00
subsusf: simplify indentation
- - - - -
8db1796b by Steve Lhomme at 2023-10-26T12:10:15+00:00
vout_subpictures: no need to include vlc_vout.h
- - - - -
dc3c2495 by Steve Lhomme at 2023-10-26T12:10:15+00:00
vout_subpictures: remove dead code
picture can't be NULL and it's set in region->p_private->p_picture. So
region->p_private->p_picture can't be NULL.
- - - - -
784850f5 by Steve Lhomme at 2023-10-26T12:10:15+00:00
subpicture: initialize missing fields during region copy
- - - - -
ba147775 by Steve Lhomme at 2023-10-26T12:10:15+00:00
subsdelay: check the empty subtitle by region
- - - - -
5 changed files:
- modules/codec/subsusf.c
- modules/codec/ttml/imageupdater.h
- modules/spu/subsdelay.c
- src/misc/subpicture.c
- src/video_output/vout_subpictures.c
Changes:
=====================================
modules/codec/subsusf.c
=====================================
@@ -412,6 +412,7 @@ static void SetupPositions( subpicture_region_t *p_region, char *psz_subtitle )
static subpicture_region_t *CreateTextRegion( decoder_t *p_dec,
char *psz_subtitle,
+ char *psz_plaintext,
int i_sys_align )
{
decoder_sys_t *p_sys = p_dec->p_sys;
@@ -419,57 +420,59 @@ static subpicture_region_t *CreateTextRegion( decoder_t *p_dec,
/* Create a new subpicture region */
p_text_region = subpicture_region_NewText();
- if( p_text_region != NULL )
- {
- ssa_style_t *p_ssa_style = NULL;
+ if( p_text_region == NULL )
+ return NULL;
+
+ ssa_style_t *p_ssa_style = NULL;
- p_ssa_style = ParseStyle( p_sys, psz_subtitle );
- if( !p_ssa_style )
+ p_ssa_style = ParseStyle( p_sys, psz_subtitle );
+ if( !p_ssa_style )
+ {
+ for( int i = 0; i < p_sys->i_ssa_styles; i++ )
{
- for( int i = 0; i < p_sys->i_ssa_styles; i++ )
- {
- if( !strcasecmp( p_sys->pp_ssa_styles[i]->psz_stylename, "Default" ) )
- p_ssa_style = p_sys->pp_ssa_styles[i];
- }
+ if( !strcasecmp( p_sys->pp_ssa_styles[i]->psz_stylename, "Default" ) )
+ p_ssa_style = p_sys->pp_ssa_styles[i];
}
+ }
- /* Set default or user align/margin.
- * Style overridden if no user value. */
- p_text_region->i_x = i_sys_align > 0 ? 20 : 0;
- p_text_region->i_y = 10;
- p_text_region->i_align = SUBPICTURE_ALIGN_BOTTOM |
- ((i_sys_align > 0) ? i_sys_align : 0);
+ /* Set default or user align/margin.
+ * Style overridden if no user value. */
+ p_text_region->i_x = i_sys_align > 0 ? 20 : 0;
+ p_text_region->i_y = 10;
+ p_text_region->i_align = SUBPICTURE_ALIGN_BOTTOM |
+ ((i_sys_align > 0) ? i_sys_align : 0);
- if( p_ssa_style )
- {
- msg_Dbg( p_dec, "style is: %s", p_ssa_style->psz_stylename );
+ if( p_ssa_style )
+ {
+ msg_Dbg( p_dec, "style is: %s", p_ssa_style->psz_stylename );
- /* TODO: Setup % based offsets properly, without adversely affecting
- * everything else in vlc. Will address with separate patch,
- * to prevent this one being any more complicated.
+ /* TODO: Setup % based offsets properly, without adversely affecting
+ * everything else in vlc. Will address with separate patch,
+ * to prevent this one being any more complicated.
- * p_ssa_style->i_margin_percent_h;
- * p_ssa_style->i_margin_percent_v;
- */
- if( i_sys_align == -1 )
- {
- p_text_region->i_align = p_ssa_style->i_align;
- p_text_region->i_x = p_ssa_style->i_margin_h;
- p_text_region->i_y = p_ssa_style->i_margin_v;
- }
- p_text_region->p_text = text_segment_NewInheritStyle( p_ssa_style->p_style );
- }
- else
+ * p_ssa_style->i_margin_percent_h;
+ * p_ssa_style->i_margin_percent_v;
+ */
+ if( i_sys_align == -1 )
{
- p_text_region->p_text = text_segment_New( NULL );
+ p_text_region->i_align = p_ssa_style->i_align;
+ p_text_region->i_x = p_ssa_style->i_margin_h;
+ p_text_region->i_y = p_ssa_style->i_margin_v;
}
- /* Look for position arguments which may override the style-based
- * defaults.
- */
- SetupPositions( p_text_region, psz_subtitle );
-
- p_text_region->p_next = NULL;
+ p_text_region->p_text = text_segment_NewInheritStyle( p_ssa_style->p_style );
+ }
+ else
+ {
+ p_text_region->p_text = text_segment_New( NULL );
}
+
+ p_text_region->p_text->psz_text = psz_plaintext;
+
+ /* Look for position arguments which may override the style-based
+ * defaults.
+ */
+ SetupPositions( p_text_region, psz_subtitle );
+
return p_text_region;
}
@@ -825,27 +828,25 @@ static subpicture_region_t *ParseUSFString( decoder_t *p_dec,
{
subpicture_region_t *p_text_region;
- char *psz_flat = NULL;
char *psz_knodes = strndup( &psz_subtitle[9], psz_end - &psz_subtitle[9] );
if( psz_knodes )
{
/* remove timing <k> tags */
- psz_flat = CreatePlainText( psz_knodes );
+ char *psz_flat = CreatePlainText( psz_knodes );
free( psz_knodes );
if( psz_flat )
{
p_text_region = CreateTextRegion( p_dec,
+ psz_flat,
psz_flat,
p_sys->i_align );
if( p_text_region )
{
- free( p_text_region->p_text->psz_text );
- p_text_region->p_text->psz_text = psz_flat;
if( !p_region_first )
{
p_region_first = p_region_upto = p_text_region;
}
- else if( p_text_region )
+ else
{
p_region_upto->p_next = p_text_region;
p_region_upto = p_region_upto->p_next;
@@ -918,24 +919,26 @@ static subpicture_region_t *ParseUSFString( decoder_t *p_dec,
psz_end = psz_subtitle + strlen( psz_subtitle );
- p_text_region = CreateTextRegion( p_dec,
- psz_subtitle,
- p_sys->i_align );
-
- if( p_text_region )
- {
- free( p_text_region->p_text->psz_text );
- p_text_region->p_text->psz_text = CreatePlainText( psz_subtitle );
- }
-
- if( !p_region_first )
+ char *psz_flat = CreatePlainText( psz_subtitle );
+ if( psz_flat )
{
- p_region_first = p_region_upto = p_text_region;
- }
- else if( p_text_region )
- {
- p_region_upto->p_next = p_text_region;
- p_region_upto = p_region_upto->p_next;
+ p_text_region = CreateTextRegion( p_dec,
+ psz_subtitle,
+ psz_flat,
+ p_sys->i_align );
+ if( p_text_region )
+ {
+ if( !p_region_first )
+ {
+ p_region_first = p_region_upto = p_text_region;
+ }
+ else
+ {
+ p_region_upto->p_next = p_text_region;
+ p_region_upto = p_region_upto->p_next;
+ }
+ }
+ else free( psz_flat );
}
}
if( psz_end )
=====================================
modules/codec/ttml/imageupdater.h
=====================================
@@ -90,7 +90,7 @@ static void TTML_ImageSpuUpdate(subpicture_t *p_spu,
const video_format_t *p_fmt_dst,
vlc_tick_t i_ts)
{
- VLC_UNUSED(p_fmt_src); VLC_UNUSED(p_fmt_dst);
+ VLC_UNUSED(p_fmt_src);
VLC_UNUSED(i_ts);
ttml_image_updater_sys_t *p_sys = p_spu->updater.p_sys;
subpicture_region_t **pp_last_region = &p_spu->p_region;
=====================================
modules/spu/subsdelay.c
=====================================
@@ -208,7 +208,7 @@ static int SubsdelayCalculateAlpha( filter_t *p_filter, int i_overlapping, int i
static int SubsdelayGetTextRank( char *psz_text );
-static bool SubsdelayIsTextEmpty( const text_segment_t* p_segment );
+static bool SubsdelayIsTextEmpty( const subpicture_region_t * );
/*****************************************************************************
* Subpicture functions
@@ -1044,8 +1044,7 @@ static void SubpicLocalUpdate( subpicture_t* p_subpic, vlc_tick_t i_ts )
if( p_entry->b_check_empty && p_subpic->p_region )
{
- //FIXME: What if there is more than one segment?
- if( SubsdelayIsTextEmpty( p_subpic->p_region->p_text ) )
+ if( SubsdelayIsTextEmpty( p_subpic->p_region ) )
{
/* remove empty subtitle */
@@ -1108,7 +1107,7 @@ static void SubpicLocalUpdate( subpicture_t* p_subpic, vlc_tick_t i_ts )
*****************************************************************************/
static bool SubpicIsEmpty( subpicture_t* p_subpic )
{
- return ( p_subpic->p_region && ( SubsdelayIsTextEmpty( p_subpic->p_region->p_text ) ) );
+ return p_subpic->p_region != NULL && SubsdelayIsTextEmpty( p_subpic->p_region );
}
/*****************************************************************************
@@ -1327,8 +1326,11 @@ static int SubsdelayGetTextRank( char *psz_text )
/*****************************************************************************
* SubsdelayIsTextEmpty: Check if the text contains spaces only
*****************************************************************************/
-static bool SubsdelayIsTextEmpty( const text_segment_t *p_segment )
+static bool SubsdelayIsTextEmpty( const subpicture_region_t *p_region )
{
+ if ( p_region->fmt.i_chroma != VLC_CODEC_TEXT )
+ return true;
+ const text_segment_t *p_segment = p_region->p_text;
while ( p_segment )
{
if ( p_segment->psz_text && strlen( p_segment->psz_text ) > 0 )
=====================================
src/misc/subpicture.c
=====================================
@@ -363,8 +363,17 @@ subpicture_region_t* subpicture_region_Copy( subpicture_region_t *p_region_src )
p_region_dst->i_align = p_region_src->i_align;
p_region_dst->i_alpha = p_region_src->i_alpha;
+ p_region_dst->i_text_align = p_region_src->i_text_align;
+ p_region_dst->b_noregionbg = p_region_src->b_noregionbg;
+ p_region_dst->b_gridmode = p_region_src->b_gridmode;
+ p_region_dst->b_balanced_text = p_region_src->b_balanced_text;
+ p_region_dst->i_max_width = p_region_src->i_max_width;
+ p_region_dst->i_max_height = p_region_src->i_max_height;
p_region_dst->p_text = text_segment_Copy( p_region_src->p_text );
+ p_region_dst->zoom_h = p_region_src->zoom_h;
+ p_region_dst->zoom_v = p_region_src->zoom_v;
+
picture_CopyPixels(p_region_dst->p_picture, p_region_src->p_picture);
return p_region_dst;
}
=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -34,7 +34,6 @@
#include <vlc_common.h>
#include <vlc_modules.h>
-#include <vlc_vout.h>
#include <vlc_filter.h>
#include <vlc_spu.h>
#include <vlc_vector.h>
@@ -1046,10 +1045,6 @@ static subpicture_region_t *SpuRenderRegion(spu_t *spu,
region->p_private = subpicture_region_private_New(&picture->format);
if (region->p_private) {
region->p_private->p_picture = picture;
- if (!region->p_private->p_picture) {
- subpicture_region_private_Delete(region->p_private);
- region->p_private = NULL;
- }
} else {
picture_Release(picture);
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6a8aeb5397f4ce08b9842b1d3f3d5d3156f4b54f...ba147775f8858049d3a5c66fc5ec702ab7ebdbdb
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6a8aeb5397f4ce08b9842b1d3f3d5d3156f4b54f...ba147775f8858049d3a5c66fc5ec702ab7ebdbdb
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