Commit 3f98a0ff authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Text codecs: move to text_segment list

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 6b45f45e
......@@ -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;
......
......@@ -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 */
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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 );
......
......@@ -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;
}
......
......@@ -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 ) )
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment