[vlc-commits] Text codecs: move to text_segment list
Jean-Baptiste Kempf
git at videolan.org
Tue Jul 28 16:01:57 CEST 2015
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun May 3 15:47:40 2015 +0200| [3f98a0ffb25b70373bf97e8bf5398ce87eccab83] | committer: Jean-Baptiste Kempf
Text codecs: move to text_segment list
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3f98a0ffb25b70373bf97e8bf5398ce87eccab83
---
modules/codec/arib/substext.h | 3 ++-
modules/codec/dvbsub.c | 8 ++++----
modules/codec/kate.c | 4 ++--
modules/codec/stl.c | 4 ++--
modules/codec/substext.h | 2 +-
modules/codec/subsusf.c | 4 ++--
modules/codec/t140.c | 7 ++++---
modules/codec/telx.c | 2 +-
8 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/modules/codec/arib/substext.h b/modules/codec/arib/substext.h
index ef1c6cc..e787b7b 100644
--- a/modules/codec/arib/substext.h
+++ b/modules/codec/arib/substext.h
@@ -97,7 +97,8 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
return;
}
- r->psz_text = p_region->psz_text ? strdup(p_region->psz_text) : NULL;
+ if( p_region->psz_text )
+ r->p_text = text_segment_New( p_region->psz_text );
r->psz_html = p_region->psz_html ? strdup(p_region->psz_html) : NULL;
r->i_align = SUBPICTURE_ALIGN_LEFT | SUBPICTURE_ALIGN_TOP;
diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c
index 879bc8d..cf2ebfa 100644
--- a/modules/codec/dvbsub.c
+++ b/modules/codec/dvbsub.c
@@ -1644,7 +1644,7 @@ static subpicture_t *render( decoder_t *p_dec )
fmt.i_x_offset = fmt.i_y_offset = 0;
p_spu_region = subpicture_region_New( &fmt );
- p_spu_region->psz_text = strdup( p_object_def->psz_text );
+ p_spu_region->p_text = text_segment_New( p_object_def->psz_text );
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;
@@ -2303,14 +2303,14 @@ static void encode_object( encoder_t *p_enc, bs_t *s, subpicture_t *p_subpic )
{
int i_size, i;
- if( !p_region->psz_text ) continue;
+ if( !p_region->p_text ) continue;
- i_size = __MIN( strlen( p_region->psz_text ), 256 );
+ i_size = __MIN( strlen( p_region->p_text->psz_text ), 256 );
bs_write( s, 8, i_size ); /* number of characters in string */
for( i = 0; i < i_size; i++ )
{
- bs_write( s, 16, p_region->psz_text[i] );
+ bs_write( s, 16, p_region->p_text->psz_text[i] );
}
/* Update segment length */
diff --git a/modules/codec/kate.c b/modules/codec/kate.c
index 3c64856..8a9aad2 100644
--- a/modules/codec/kate.c
+++ b/modules/codec/kate.c
@@ -702,7 +702,7 @@ static void SetupText( decoder_t *p_dec, subpicture_t *p_spu, const kate_event *
switch( ev->text_markup_type )
{
case kate_markup_none:
- p_spu->p_region->psz_text = strdup( ev->text ); /* no leak, this actually gets killed by the core */
+ p_spu->p_region->p_text = text_segment_New( ev->text ); /* no leak, this actually gets killed by the core */
break;
case kate_markup_simple:
if( p_sys->b_formatted )
@@ -722,7 +722,7 @@ static void SetupText( decoder_t *p_dec, subpicture_t *p_spu, const kate_event *
char *copy = strdup( ev->text );
size_t len0 = strlen( copy ) + 1;
kate_text_remove_markup( ev->text_encoding, copy, &len0 );
- p_spu->p_region->psz_text = copy;
+ p_spu->p_region->p_text = text_segment_New( copy );
}
break;
}
diff --git a/modules/codec/stl.c b/modules/codec/stl.c
index b65fc16..e2f8a20 100644
--- a/modules/codec/stl.c
+++ b/modules/codec/stl.c
@@ -143,9 +143,9 @@ static subpicture_t *Decode(decoder_t *dec, block_t **block)
video_format_Clean(&fmt);
if (sub->p_region) {
- sub->p_region->psz_text = ParseText(payload,
+ sub->p_region->p_text = text_segment_New( ParseText(payload,
payload_size,
- cct_nums[dec->p_sys->cct - CCT_BEGIN].str);
+ cct_nums[dec->p_sys->cct - CCT_BEGIN].str) );
sub->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM;
}
diff --git a/modules/codec/substext.h b/modules/codec/substext.h
index 0cfce23..ba4b96c 100644
--- a/modules/codec/substext.h
+++ b/modules/codec/substext.h
@@ -206,7 +206,7 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
if (!r)
return;
- r->psz_text = sys->text ? strdup(sys->text) : NULL;
+ r->p_text = sys->text ? text_segment_New( sys->text ): NULL;
if ( sys->p_htmlsegments )
r->psz_html = SegmentsToHtml( sys->p_htmlsegments,
(float) fmt_dst->i_height / fmt_src->i_height );
diff --git a/modules/codec/subsusf.c b/modules/codec/subsusf.c
index 426fc5b..113b2d9 100644
--- a/modules/codec/subsusf.c
+++ b/modules/codec/subsusf.c
@@ -843,7 +843,7 @@ static subpicture_region_t *ParseUSFString( decoder_t *p_dec,
if( p_text_region )
{
- p_text_region->psz_text = CreatePlainText( p_text_region->psz_html );
+ p_text_region->p_text = text_segment_New( CreatePlainText( p_text_region->psz_html ) );
if( ! var_CreateGetBool( p_dec, "subsdec-formatted" ) )
{
@@ -941,7 +941,7 @@ static subpicture_region_t *ParseUSFString( decoder_t *p_dec,
SetupPositions( p_image_region, psz_subtitle );
p_image_region->p_next = NULL;
- p_image_region->psz_text = NULL;
+ p_image_region->p_text = NULL;
p_image_region->psz_html = NULL;
}
diff --git a/modules/codec/t140.c b/modules/codec/t140.c
index feba0fe..39cf09b 100644
--- a/modules/codec/t140.c
+++ b/modules/codec/t140.c
@@ -94,13 +94,14 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_spu )
p_region = p_spu->p_region;
if( ( p_region == NULL )
|| ( p_region->fmt.i_chroma != VLC_CODEC_TEXT )
- || ( p_region->psz_text == NULL ) )
+ || ( p_region->p_text == NULL )
+ || ( p_region->p_text->psz_text == NULL) )
return NULL;
/* This should already be UTF-8 encoded, so not much effort... */
- len = strlen( p_region->psz_text );
+ len = strlen( p_region->p_text->psz_text );
p_block = block_Alloc( len );
- memcpy( p_block->p_buffer, p_region->psz_text, len );
+ memcpy( p_block->p_buffer, p_region->p_text->psz_text, len );
p_block->i_pts = p_block->i_dts = p_spu->i_start;
if( !p_spu->b_ephemer && ( p_spu->i_stop > p_spu->i_start ) )
diff --git a/modules/codec/telx.c b/modules/codec/telx.c
index dfc5dcb..4f8842a 100644
--- a/modules/codec/telx.c
+++ b/modules/codec/telx.c
@@ -707,7 +707,7 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
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->p_region->p_text = text_segment_New(psz_text);
p_spu->i_start = p_block->i_pts;
p_spu->i_stop = p_block->i_pts + p_block->i_length;
More information about the vlc-commits
mailing list