[vlc-commits] codec: webvtt: rename/nz prefix time vars
Francois Cartegnie
git at videolan.org
Wed Mar 24 14:02:37 UTC 2021
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Mar 24 13:55:02 2021 +0100| [aee5e3884c20cc03ed0adf29de32232c6949e77d] | committer: Francois Cartegnie
codec: webvtt: rename/nz prefix time vars
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aee5e3884c20cc03ed0adf29de32232c6949e77d
---
modules/codec/webvtt/subsvtt.c | 140 ++++++++++++++++++++---------------------
1 file changed, 70 insertions(+), 70 deletions(-)
diff --git a/modules/codec/webvtt/subsvtt.c b/modules/codec/webvtt/subsvtt.c
index f20f734f7b..c61c0ee13f 100644
--- a/modules/codec/webvtt/subsvtt.c
+++ b/modules/codec/webvtt/subsvtt.c
@@ -122,8 +122,8 @@ struct webvtt_dom_cue_t
{
WEBVTT_NODE_BASE_MEMBERS
char *psz_id;
- vlc_tick_t i_start;
- vlc_tick_t i_stop;
+ vlc_tick_t i_nzstart;
+ vlc_tick_t i_nzstop;
webvtt_cue_settings_t settings;
unsigned i_lines;
text_style_t *p_cssstyle;
@@ -139,7 +139,7 @@ typedef struct
typedef struct
{
WEBVTT_NODE_BASE_MEMBERS
- vlc_tick_t i_start;
+ vlc_tick_t i_nzstart;
char *psz_tag;
char *psz_attrs;
text_style_t *p_cssstyle;
@@ -508,7 +508,7 @@ static webvtt_dom_tag_t * webvtt_dom_tag_New( webvtt_dom_node_t *p_parent )
webvtt_dom_tag_t *p_node = calloc( 1, sizeof(*p_node) );
if( p_node )
{
- p_node->i_start = -1;
+ p_node->i_nzstart = -1;
p_node->type = NODE_TAG;
p_node->p_parent = p_parent;
}
@@ -558,9 +558,9 @@ static vlc_tick_t webvtt_domnode_GetPlaybackTime( const webvtt_dom_node_t *p_nod
{
if( p_node->type == NODE_TAG )
{
- vlc_tick_t i_start = ((const webvtt_dom_tag_t *) p_node)->i_start;
- if( i_start > -1 && !b_end )
- return i_start;
+ vlc_tick_t i_nzstart = ((const webvtt_dom_tag_t *) p_node)->i_nzstart;
+ if( i_nzstart > -1 && !b_end )
+ return i_nzstart;
}
else if( p_node->type == NODE_CUE )
{
@@ -568,8 +568,8 @@ static vlc_tick_t webvtt_domnode_GetPlaybackTime( const webvtt_dom_node_t *p_nod
}
}
if( p_node )
- return b_end ? ((const webvtt_dom_cue_t *) p_node)->i_stop:
- ((const webvtt_dom_cue_t *) p_node)->i_start;
+ return b_end ? ((const webvtt_dom_cue_t *) p_node)->i_nzstop:
+ ((const webvtt_dom_cue_t *) p_node)->i_nzstart;
return VLC_TICK_INVALID;
}
@@ -620,12 +620,12 @@ static bool webvtt_domnode_Match_Tag( const webvtt_dom_node_t *p_node, const cha
}
static bool webvtt_domnode_Match_PseudoClass( const webvtt_dom_node_t *p_node, const char *psz,
- vlc_tick_t i_playbacktime )
+ vlc_tick_t i_nzplaybacktime )
{
if( !strcmp(psz, "past") || !strcmp(psz, "future") )
{
- vlc_tick_t i_start = webvtt_domnode_GetPlaybackTime( p_node, false );
- return ( *psz == 'p' ) ? i_start < i_playbacktime : i_start > i_playbacktime;
+ vlc_tick_t i_nzstart = webvtt_domnode_GetPlaybackTime( p_node, false );
+ return ( *psz == 'p' ) ? i_nzstart < i_nzplaybacktime : i_nzstart > i_nzplaybacktime;
}
return false;
}
@@ -717,7 +717,7 @@ static bool webvtt_domnode_Match_Attribute( const webvtt_dom_node_t *p_node,
}
static bool webvtt_domnode_MatchType( const webvtt_dom_node_t *p_node,
- const vlc_css_selector_t *p_sel, vlc_tick_t i_playbacktime )
+ const vlc_css_selector_t *p_sel, vlc_tick_t i_nzplaybacktime )
{
switch( p_sel->type )
{
@@ -725,7 +725,7 @@ static bool webvtt_domnode_MatchType( const webvtt_dom_node_t *p_node,
return webvtt_domnode_Match_Tag( p_node, p_sel->psz_name );
case SELECTOR_PSEUDOCLASS:
return webvtt_domnode_Match_PseudoClass( p_node, p_sel->psz_name,
- i_playbacktime );
+ i_nzplaybacktime );
case SELECTOR_PSEUDOELEMENT:
return webvtt_domnode_Match_PseudoElement( p_node, p_sel->psz_name );
case SPECIFIER_ID:
@@ -786,24 +786,24 @@ static void webvtt_domnode_setCSSStyle( webvtt_dom_node_t *p_node, text_style_t
#ifdef HAVE_CSS
static void webvtt_domnode_SelectNodesInTree( const webvtt_dom_node_t *p_tree,
const vlc_css_selector_t *p_sel, int i_max_depth,
- vlc_tick_t i_playbacktime, vlc_array_t *p_results );
+ vlc_tick_t i_nzplaybacktime, vlc_array_t *p_results );
static void webvtt_domnode_SelectChildNodesInTree( const webvtt_dom_node_t *p_tree,
const vlc_css_selector_t *p_sel, int i_max_depth,
- vlc_tick_t i_playbacktime, vlc_array_t *p_results )
+ vlc_tick_t i_nzplaybacktime, vlc_array_t *p_results )
{
const webvtt_dom_node_t *p_child = webvtt_domnode_getFirstChild( p_tree );
if( i_max_depth > 0 )
{
for( ; p_child; p_child = p_child->p_next )
webvtt_domnode_SelectNodesInTree( p_child, p_sel, i_max_depth - 1,
- i_playbacktime, p_results );
+ i_nzplaybacktime, p_results );
}
}
static void webvtt_domnode_SelectNodesBySpeficier( const webvtt_dom_node_t *p_node,
const vlc_css_selector_t *p_spec,
- vlc_tick_t i_playbacktime, vlc_array_t *p_results )
+ vlc_tick_t i_nzplaybacktime, vlc_array_t *p_results )
{
if( p_spec == NULL )
return;
@@ -812,37 +812,37 @@ static void webvtt_domnode_SelectNodesBySpeficier( const webvtt_dom_node_t *p_no
{
case RELATION_DESCENDENT:
webvtt_domnode_SelectChildNodesInTree( p_node, p_spec, WEBVTT_MAX_DEPTH,
- i_playbacktime, p_results );
+ i_nzplaybacktime, p_results );
break;
case RELATION_DIRECTADJACENT:
for( const webvtt_dom_node_t *p_adj = p_node->p_next; p_adj; p_adj = p_adj->p_next )
webvtt_domnode_SelectChildNodesInTree( p_adj, p_spec, 1,
- i_playbacktime, p_results );
+ i_nzplaybacktime, p_results );
break;
case RELATION_INDIRECTADJACENT:
for( const webvtt_dom_node_t *p_adj = webvtt_domnode_getFirstChild( p_node->p_parent );
p_adj && p_adj != p_node; p_adj = p_adj->p_next )
webvtt_domnode_SelectChildNodesInTree( p_adj, p_spec, 1,
- i_playbacktime, p_results );
+ i_nzplaybacktime, p_results );
break;
case RELATION_CHILD:
webvtt_domnode_SelectChildNodesInTree( p_node, p_spec, 1,
- i_playbacktime, p_results );
+ i_nzplaybacktime, p_results );
break;
case RELATION_SELF:
webvtt_domnode_SelectNodesInTree( p_node, p_spec, WEBVTT_MAX_DEPTH,
- i_playbacktime, p_results );
+ i_nzplaybacktime, p_results );
}
}
static void webvtt_domnode_SelectNodesInTree( const webvtt_dom_node_t *p_node,
const vlc_css_selector_t *p_sel, int i_max_depth,
- vlc_tick_t i_playbacktime, vlc_array_t *p_results )
+ vlc_tick_t i_nzplaybacktime, vlc_array_t *p_results )
{
if( p_node == NULL )
return;
- if( webvtt_domnode_MatchType( p_node, p_sel, i_playbacktime ) )
+ if( webvtt_domnode_MatchType( p_node, p_sel, i_nzplaybacktime ) )
{
if( p_sel->specifiers.p_first == NULL )
{
@@ -850,16 +850,16 @@ static void webvtt_domnode_SelectNodesInTree( const webvtt_dom_node_t *p_node,
(void) vlc_array_append( p_results, (void *) p_node );
}
else webvtt_domnode_SelectNodesBySpeficier( p_node, p_sel->specifiers.p_first,
- i_playbacktime, p_results );
+ i_nzplaybacktime, p_results );
}
/* lookup other subnodes */
webvtt_domnode_SelectChildNodesInTree( p_node, p_sel, i_max_depth - 1,
- i_playbacktime, p_results );
+ i_nzplaybacktime, p_results );
}
static void webvtt_domnode_SelectRuleNodes( const webvtt_dom_node_t *p_root, const vlc_css_rule_t *p_rule,
- vlc_tick_t i_playbacktime, vlc_array_t *p_results )
+ vlc_tick_t i_nzplaybacktime, vlc_array_t *p_results )
{
if(!p_root || p_root->type != NODE_TAG)
return;
@@ -871,7 +871,7 @@ static void webvtt_domnode_SelectRuleNodes( const webvtt_dom_node_t *p_root, con
for( const webvtt_dom_node_t *p_node = p_cues; p_node; p_node = p_node->p_next )
{
webvtt_domnode_SelectNodesInTree( p_node, p_sel, WEBVTT_MAX_DEPTH,
- i_playbacktime, &tempresults );
+ i_nzplaybacktime, &tempresults );
}
for( size_t i=0; i<vlc_array_count(&tempresults); i++ )
(void) vlc_array_append( p_results, vlc_array_item_at_index( &tempresults, i ) );
@@ -928,15 +928,15 @@ static const char *SplitTag( const char *psz_tag, size_t *pi_tag, const char **p
/*****************************************************************************
*
*****************************************************************************/
-static webvtt_dom_cue_t * webvtt_dom_cue_New( vlc_tick_t i_start, vlc_tick_t i_end )
+static webvtt_dom_cue_t * webvtt_dom_cue_New( vlc_tick_t i_nzstart, vlc_tick_t i_nzend )
{
webvtt_dom_cue_t *p_cue = calloc( 1, sizeof(*p_cue) );
if( p_cue )
{
p_cue->type = NODE_CUE;
p_cue->psz_id = NULL;
- p_cue->i_start = i_start;
- p_cue->i_stop = i_end;
+ p_cue->i_nzstart = i_nzstart;
+ p_cue->i_nzstop = i_nzend;
p_cue->p_child = NULL;
p_cue->i_lines = 0;
p_cue->p_cssstyle = NULL;
@@ -1077,7 +1077,7 @@ static void webvtt_region_ClearCues( webvtt_region_t *p_region )
p_region->p_child = NULL;
}
-static void ClearCuesByTime( webvtt_dom_node_t **pp_next, vlc_tick_t i_time )
+static void ClearCuesByTime( webvtt_dom_node_t **pp_next, vlc_tick_t i_nztime )
{
while( *pp_next )
{
@@ -1087,7 +1087,7 @@ static void ClearCuesByTime( webvtt_dom_node_t **pp_next, vlc_tick_t i_time )
if( p_node->type == NODE_CUE )
{
webvtt_dom_cue_t *p_cue = (webvtt_dom_cue_t *)p_node;
- if( p_cue->i_stop <= i_time )
+ if( p_cue->i_nzstop <= i_nztime )
{
*pp_next = p_node->p_next;
p_node->p_next = NULL;
@@ -1098,7 +1098,7 @@ static void ClearCuesByTime( webvtt_dom_node_t **pp_next, vlc_tick_t i_time )
else if( p_node->type == NODE_REGION )
{
webvtt_region_t *p_region = (webvtt_region_t *) p_node;
- ClearCuesByTime( &p_region->p_child, i_time );
+ ClearCuesByTime( &p_region->p_child, i_nztime );
}
pp_next = &p_node->p_next;
}
@@ -1243,7 +1243,7 @@ static webvtt_dom_node_t * CreateDomNodes( const char *psz_text, unsigned *pi_li
p_node->psz_attrs = strndup( psz_attrs, psz_taglast - psz_attrs );
/* <hh:mm::ss:fff> time tags */
if( p_node->psz_attrs && isdigit(p_node->psz_attrs[0]) )
- (void) webvtt_scan_time( p_node->psz_attrs, &p_node->i_start );
+ (void) webvtt_scan_time( p_node->psz_attrs, &p_node->i_nzstart );
*pp_append = (webvtt_dom_node_t *) p_node;
p_parent = (webvtt_dom_node_t *) p_node;
pp_append = &p_node->p_child;
@@ -1330,11 +1330,11 @@ static text_style_t * ComputeStyle( decoder_t *p_dec, const webvtt_dom_node_t *p
{
const webvtt_dom_tag_t *p_tagnode = (const webvtt_dom_tag_t *)p_node;
- if( p_tagnode->i_start > -1 )
+ if( p_tagnode->i_nzstart > -1 )
{
/* Ignore other timed stylings */
if( i_tagtime == -1 )
- i_tagtime = p_tagnode->i_start;
+ i_tagtime = p_tagnode->i_nzstart;
else
continue;
}
@@ -1599,20 +1599,20 @@ static void ChainCueSegments( const webvtt_dom_cue_t *p_cue, text_segment_t *p_n
}
}
-static text_segment_t * ConvertCuesToSegments( decoder_t *p_dec, vlc_tick_t i_start, vlc_tick_t i_stop,
+static text_segment_t * ConvertCuesToSegments( decoder_t *p_dec, vlc_tick_t i_nzstart, vlc_tick_t i_nzstop,
struct render_variables_s *p_vars,
const webvtt_dom_cue_t *p_cue )
{
text_segment_t *p_segments = NULL;
text_segment_t **pp_append = &p_segments;
- VLC_UNUSED(i_stop);
+ VLC_UNUSED(i_nzstop);
for( ; p_cue; p_cue = (const webvtt_dom_cue_t *) p_cue->p_next )
{
if( p_cue->type != NODE_CUE )
continue;
- if( p_cue->i_start > i_start || p_cue->i_stop <= i_start )
+ if( p_cue->i_nzstart > i_nzstart || p_cue->i_nzstop <= i_nzstart )
continue;
text_segment_t *p_new = ConvertCueToSegments( p_dec, p_vars, p_cue );
@@ -1622,7 +1622,7 @@ static text_segment_t * ConvertCuesToSegments( decoder_t *p_dec, vlc_tick_t i_st
}
static void GetTimedTags( const webvtt_dom_node_t *p_node,
- vlc_tick_t i_start, vlc_tick_t i_stop, vlc_array_t *p_times )
+ vlc_tick_t i_nzstart, vlc_tick_t i_nzstop, vlc_array_t *p_times )
{
for( ; p_node; p_node = p_node->p_next )
{
@@ -1631,14 +1631,14 @@ static void GetTimedTags( const webvtt_dom_node_t *p_node,
case NODE_TAG:
{
const webvtt_dom_tag_t *p_tag = (const webvtt_dom_tag_t *) p_node;
- if( p_tag->i_start > -1 && p_tag->i_start >= i_start && p_tag->i_start < i_stop )
+ if( p_tag->i_nzstart > -1 && p_tag->i_nzstart >= i_nzstart && p_tag->i_nzstart < i_nzstop )
(void) vlc_array_append( p_times, (void *) p_tag );
- GetTimedTags( p_tag->p_child, i_start, i_stop, p_times );
+ GetTimedTags( p_tag->p_child, i_nzstart, i_nzstop, p_times );
} break;
case NODE_REGION:
case NODE_CUE:
GetTimedTags( webvtt_domnode_getFirstChild( p_node ),
- i_start, i_stop, p_times );
+ i_nzstart, i_nzstop, p_times );
break;
default:
break;
@@ -1682,7 +1682,7 @@ static void ClearCSSStyles( webvtt_dom_node_t *p_node )
#ifdef HAVE_CSS
static void ApplyCSSRules( decoder_t *p_dec, const vlc_css_rule_t *p_rule,
- vlc_tick_t i_playbacktime )
+ vlc_tick_t i_nzplaybacktime )
{
decoder_sys_t *p_sys = p_dec->p_sys;
@@ -1692,7 +1692,7 @@ static void ApplyCSSRules( decoder_t *p_dec, const vlc_css_rule_t *p_rule,
vlc_array_init( &results );
webvtt_domnode_SelectRuleNodes( (webvtt_dom_node_t *) p_sys->p_root,
- p_rule, i_playbacktime, &results );
+ p_rule, i_nzplaybacktime, &results );
for( const vlc_css_declaration_t *p_decl = p_rule->p_declarations;
p_decl; p_decl = p_decl->p_next )
@@ -1721,14 +1721,14 @@ static void ApplyCSSRules( decoder_t *p_dec, const vlc_css_rule_t *p_rule,
}
#endif
-static void RenderRegions( decoder_t *p_dec, vlc_tick_t i_start, vlc_tick_t i_stop )
+static void RenderRegions( decoder_t *p_dec, vlc_tick_t i_nzstart, vlc_tick_t i_nzstop )
{
subpicture_t *p_spu = NULL;
substext_updater_region_t *p_updtregion = NULL;
decoder_sys_t *p_sys = p_dec->p_sys;
#ifdef HAVE_CSS
- ApplyCSSRules( p_dec, p_sys->p_css_rules, i_start );
+ ApplyCSSRules( p_dec, p_sys->p_css_rules, i_nzstart );
#endif
const webvtt_dom_cue_t *p_rlcue = NULL;
@@ -1749,7 +1749,7 @@ static void RenderRegions( decoder_t *p_dec, vlc_tick_t i_start, vlc_tick_t i_st
/* !Variables */
text_segment_t *p_segments =
- ConvertCuesToSegments( p_dec, i_start, i_stop, &v,
+ ConvertCuesToSegments( p_dec, i_nzstart, i_nzstop, &v,
(const webvtt_dom_cue_t *)p_vttregion->p_child );
if( !p_segments )
continue;
@@ -1796,7 +1796,7 @@ static void RenderRegions( decoder_t *p_dec, vlc_tick_t i_start, vlc_tick_t i_st
if( p_cue->type != NODE_CUE )
continue;
- if( p_cue->i_start > i_start || p_cue->i_stop <= i_start )
+ if( p_cue->i_nzstart > i_nzstart || p_cue->i_nzstop <= i_nzstart )
continue;
text_segment_t *p_segments = ConvertCueToSegments( p_dec, &v, p_cue );
@@ -1834,8 +1834,8 @@ static void RenderRegions( decoder_t *p_dec, vlc_tick_t i_start, vlc_tick_t i_st
if( p_spu )
{
- p_spu->i_start = i_start;
- p_spu->i_stop = i_stop;
+ p_spu->i_start = i_nzstart;
+ p_spu->i_stop = i_nzstop;
p_spu->b_ephemer = true; /* !important */
p_spu->b_absolute = false; /* can't be absolute as snap to lines can overlap ! */
@@ -1850,39 +1850,39 @@ static int timedtagsArrayCmp( const void *a, const void *b )
{
const webvtt_dom_tag_t *ta = *((const webvtt_dom_tag_t **) a);
const webvtt_dom_tag_t *tb = *((const webvtt_dom_tag_t **) b);
- const int64_t result = ta->i_start - tb->i_start;
+ const int64_t result = ta->i_nzstart - tb->i_nzstart;
return result == 0 ? 0 : result > 0 ? 1 : -1;
}
-static void Render( decoder_t *p_dec, vlc_tick_t i_start, vlc_tick_t i_stop )
+static void Render( decoder_t *p_dec, vlc_tick_t i_nzstart, vlc_tick_t i_nzstop )
{
decoder_sys_t *p_sys = p_dec->p_sys;
vlc_array_t timedtags;
vlc_array_init( &timedtags );
- GetTimedTags( p_sys->p_root->p_child, i_start, i_stop, &timedtags );
+ GetTimedTags( p_sys->p_root->p_child, i_nzstart, i_nzstop, &timedtags );
if( timedtags.i_count )
qsort( timedtags.pp_elems, timedtags.i_count, sizeof(*timedtags.pp_elems), timedtagsArrayCmp );
- vlc_tick_t i_substart = i_start;
+ vlc_tick_t i_subnzstart = i_nzstart;
for( size_t i=0; i<timedtags.i_count; i++ )
{
const webvtt_dom_tag_t *p_tag =
(const webvtt_dom_tag_t *) vlc_array_item_at_index( &timedtags, i );
- if( p_tag->i_start != i_substart ) /* might be duplicates */
+ if( p_tag->i_nzstart != i_subnzstart ) /* might be duplicates */
{
if( i > 0 )
ClearCSSStyles( (webvtt_dom_node_t *)p_sys->p_root );
- RenderRegions( p_dec, i_substart, p_tag->i_start );
- i_substart = p_tag->i_start;
+ RenderRegions( p_dec, i_subnzstart, p_tag->i_nzstart );
+ i_subnzstart = p_tag->i_nzstart;
}
}
- if( i_substart != i_stop )
+ if( i_subnzstart != i_nzstop )
{
- if( i_substart != i_start )
+ if( i_subnzstart != i_nzstart )
ClearCSSStyles( (webvtt_dom_node_t *)p_sys->p_root );
- RenderRegions( p_dec, i_substart, i_stop );
+ RenderRegions( p_dec, i_subnzstart, i_nzstop );
}
vlc_array_clear( &timedtags );
@@ -1890,7 +1890,7 @@ static void Render( decoder_t *p_dec, vlc_tick_t i_start, vlc_tick_t i_stop )
static int ProcessISOBMFF( decoder_t *p_dec,
const uint8_t *p_buffer, size_t i_buffer,
- vlc_tick_t i_start, vlc_tick_t i_stop )
+ vlc_tick_t i_nzstart, vlc_tick_t i_nzstop )
{
decoder_sys_t *p_sys = p_dec->p_sys;
mp4_box_iterator_t it;
@@ -1899,7 +1899,7 @@ static int ProcessISOBMFF( decoder_t *p_dec,
{
if( it.i_type == ATOM_vttc || it.i_type == ATOM_vttx )
{
- webvtt_dom_cue_t *p_cue = webvtt_dom_cue_New( i_start, i_stop );
+ webvtt_dom_cue_t *p_cue = webvtt_dom_cue_New( i_nzstart, i_nzstop );
if( !p_cue )
continue;
@@ -2078,18 +2078,18 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
decoder_sys_t *p_sys = p_dec->p_sys;
- vlc_tick_t i_start = p_block->i_pts - VLC_TICK_0;
- vlc_tick_t i_stop = i_start + p_block->i_length;
+ vlc_tick_t i_nzstart = p_block->i_pts - VLC_TICK_0;
+ vlc_tick_t i_nzstop = i_nzstart + p_block->i_length;
if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
Flush( p_dec );
else
- ClearCuesByTime( &p_sys->p_root->p_child, i_start );
+ ClearCuesByTime( &p_sys->p_root->p_child, i_nzstart );
ProcessISOBMFF( p_dec, p_block->p_buffer, p_block->i_buffer,
- i_start, i_stop );
+ i_nzstart, i_nzstop );
- Render( p_dec, i_start, i_stop );
+ Render( p_dec, i_nzstart, i_nzstop );
block_Release( p_block );
return VLCDEC_SUCCESS;
More information about the vlc-commits
mailing list