[vlc-commits] codec: ttml: fix absolute position inside root region

Francois Cartegnie git at videolan.org
Wed Dec 20 15:19:07 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Dec 20 14:54:25 2017 +0100| [99da9428939be8bf1128991f0e74198632fc0c5e] | committer: Francois Cartegnie

codec: ttml: fix absolute position inside root region

and default to bottom (not really matching spec)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=99da9428939be8bf1128991f0e74198632fc0c5e
---

 modules/codec/substext.h      |  4 ++--
 modules/codec/ttml/substtml.c | 26 +++++++++++++++++---------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/modules/codec/substext.h b/modules/codec/substext.h
index a0aab57440..2ece70a909 100644
--- a/modules/codec/substext.h
+++ b/modules/codec/substext.h
@@ -75,8 +75,8 @@ static inline void SubpictureUpdaterSysRegionClean(subpicture_updater_sys_region
 static inline void SubpictureUpdaterSysRegionInit(subpicture_updater_sys_region_t *p_updtregion)
 {
     memset(p_updtregion, 0, sizeof(*p_updtregion));
-    p_updtregion->align = SUBPICTURE_ALIGN_TOP;
-    p_updtregion->inner_align = SUBPICTURE_ALIGN_LEFT;
+    p_updtregion->align = SUBPICTURE_ALIGN_BOTTOM;
+    p_updtregion->inner_align = 0;
 }
 
 static inline subpicture_updater_sys_region_t *SubpictureUpdaterSysRegionNew( )
diff --git a/modules/codec/ttml/substtml.c b/modules/codec/ttml/substtml.c
index 118dc76134..24f85fda24 100644
--- a/modules/codec/ttml/substtml.c
+++ b/modules/codec/ttml/substtml.c
@@ -180,7 +180,7 @@ static void ttml_style_Merge( const ttml_style_t *p_src, ttml_style_t *p_dst )
     }
 }
 
-static ttml_region_t *ttml_region_New( )
+static ttml_region_t *ttml_region_New( bool b_root )
 {
     ttml_region_t *p_ttml_region = calloc( 1, sizeof( ttml_region_t ) );
     if( unlikely( !p_ttml_region ) )
@@ -190,7 +190,17 @@ static ttml_region_t *ttml_region_New( )
     p_ttml_region->pp_last_segment = &p_ttml_region->updt.p_segments;
     /* Align to top by default. !Warn: center align is obtained with NO flags */
     p_ttml_region->updt.align = SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_LEFT;
-    p_ttml_region->updt.inner_align = SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_LEFT;
+    if( b_root )
+    {
+        p_ttml_region->updt.inner_align = SUBPICTURE_ALIGN_BOTTOM;
+        p_ttml_region->updt.extent.x = 1.0;
+        p_ttml_region->updt.extent.y = 1.0;
+        p_ttml_region->updt.flags = UPDT_REGION_EXTENT_X_IS_RATIO|UPDT_REGION_EXTENT_Y_IS_RATIO;
+    }
+    else
+    {
+        p_ttml_region->updt.inner_align = SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_LEFT;
+    }
 
     return p_ttml_region;
 }
@@ -732,7 +742,7 @@ static ttml_region_t *GetTTMLRegion( ttml_context_t *p_ctx, const char *psz_regi
             vlc_dictionary_init( &merged, 0 );
             /* Get all attributes, including region > style */
             DictMergeWithRegionID( p_ctx, psz_region_id, &merged );
-            if( (p_region = ttml_region_New()) )
+            if( (p_region = ttml_region_New( false )) )
             {
                 /* Fill from its own attributes */
                 for( int i = 0; i < merged.i_size; ++i )
@@ -749,7 +759,7 @@ static ttml_region_t *GetTTMLRegion( ttml_context_t *p_ctx, const char *psz_regi
 
             vlc_dictionary_insert( &p_ctx->regions, psz_region_id, p_region );
         }
-        else if( (p_region = ttml_region_New()) ) /* create default */
+        else if( (p_region = ttml_region_New( true )) ) /* create default */
         {
             vlc_dictionary_insert( &p_ctx->regions, "", p_region );
         }
@@ -1057,12 +1067,10 @@ static int ParseBlock( decoder_t *p_dec, const block_t *p_block )
                     SubpictureUpdaterSysRegionAdd( &p_spu_sys->region, p_updtregion );
                 }
 
-                /* broken legacy align var (can't handle center...) */
+                /* broken legacy align var (can't handle center...). Will change only regions content. */
                 if( p_dec->p_sys->i_align & SUBPICTURE_ALIGN_MASK )
-                {
-                    p_spu_sys->region.align = p_dec->p_sys->i_align & (SUBPICTURE_ALIGN_BOTTOM|SUBPICTURE_ALIGN_TOP);
-                    p_spu_sys->region.inner_align = p_dec->p_sys->i_align & (SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT);
-                }
+                    p_spu_sys->region.inner_align = p_dec->p_sys->i_align;
+
                 p_spu_sys->margin_ratio = 0.0;
 
                 /* copy and take ownership of pointeds */



More information about the vlc-commits mailing list