]> git.sesse.net Git - vlc/commitdiff
Patch by Bernie Purcell :
authorLaurent Aimar <fenrir@videolan.org>
Mon, 18 Jun 2007 21:08:03 +0000 (21:08 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Mon, 18 Jun 2007 21:08:03 +0000 (21:08 +0000)
"This is part of a former submission stripped out for easier
 assimilation. It modifies vout_subpictures to use the existing alignment
 field on each region, rather than the alignment on the subpicture plane
 itself. Modifications are made to everywhere that depended on the former
 behaviour, to make it use the new alignment location instead."

12 files changed:
include/vlc_vout.h
modules/codec/dvbsub.c
modules/codec/subsdec.c
modules/codec/telx.c
modules/video_filter/logo.c
modules/video_filter/marq.c
modules/video_filter/mosaic.c
modules/video_filter/rss.c
src/control/mediacontrol_audio_video.c
src/osd/osd_text.c
src/video_output/video_text.c
src/video_output/vout_subpictures.c

index 7c5c842ee1d890adc59582e901059e290687f9c7..6ac217e653bb624c95c1ca1776376ccfb8b8c272 100644 (file)
@@ -306,6 +306,8 @@ struct subpicture_t
 #define SUBPICTURE_ALIGN_RIGHT 0x2
 #define SUBPICTURE_ALIGN_TOP 0x4
 #define SUBPICTURE_ALIGN_BOTTOM 0x8
+#define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
+                                SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
 
 /*****************************************************************************
  * Prototypes
index 43f370433092c9f583b85e3124c06a713e84b196..ecc726a526a60a01803043d1934b44104f919b31 100644 (file)
@@ -1492,6 +1492,7 @@ static subpicture_t *render( decoder_t *p_dec )
         }
         p_spu_region->i_x = p_regiondef->i_x;
         p_spu_region->i_y = p_regiondef->i_y;
+        p_spu_region->i_align = p_sys->i_spu_position;
         *pp_spu_region = p_spu_region;
         pp_spu_region = &p_spu_region->p_next;
 
@@ -1546,6 +1547,7 @@ static subpicture_t *render( decoder_t *p_dec )
             p_spu_region->psz_text = strdup( p_object_def->psz_text );
             p_spu_region->i_x = p_regiondef->i_x + p_object_def->i_x;
             p_spu_region->i_y = p_regiondef->i_y + p_object_def->i_y;
+            p_spu_region->i_align = p_sys->i_spu_position;
             *pp_spu_region = p_spu_region;
             pp_spu_region = &p_spu_region->p_next;
         }
index e4d66b309b4da2f6a841093c2b7a0a4731e3c5e4..b8c368cb3565e6effe5bac4b76cc2a31c5cda67e 100644 (file)
@@ -448,7 +448,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
         p_dec->fmt_in.i_codec != VLC_FOURCC('u','s','f',' ') )
     {
         /* Normal text subs, easy markup */
-        p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
+        p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
         p_spu->i_x = p_sys->i_align ? 20 : 0;
         p_spu->i_y = 10;
 
@@ -574,7 +574,7 @@ static void ParseUSFString( decoder_t *p_dec, char *psz_subtitle, subpicture_t *
 
     if( p_style == NULL )
     {
-        p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
+        p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
         p_spu->i_x = p_sys->i_align ? 20 : 0;
         p_spu->i_y = 10;
     }
@@ -582,7 +582,7 @@ static void ParseUSFString( decoder_t *p_dec, char *psz_subtitle, subpicture_t *
     {
         msg_Dbg( p_dec, "style is: %s", p_style->psz_stylename);
         p_spu->p_region->p_style = &p_style->font_style;
-        p_spu->i_flags = p_style->i_align;
+        p_spu->p_region->i_align = p_style->i_align;
     }
 }
 
@@ -678,7 +678,7 @@ static void ParseSSAString( decoder_t *p_dec, char *psz_subtitle, subpicture_t *
     p_spu->p_region->psz_text = psz_new_subtitle;
     if( p_style == NULL )
     {
-        p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
+        p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
         p_spu->i_x = p_sys->i_align ? 20 : 0;
         p_spu->i_y = 10;
     }
@@ -686,7 +686,7 @@ static void ParseSSAString( decoder_t *p_dec, char *psz_subtitle, subpicture_t *
     {
         msg_Dbg( p_dec, "style is: %s", p_style->psz_stylename);
         p_spu->p_region->p_style = &p_style->font_style;
-        p_spu->i_flags = p_style->i_align;
+        p_spu->p_region->i_align = p_style->i_align;
         if( p_style->i_align & SUBPICTURE_ALIGN_LEFT )
         {
             p_spu->i_x = (i_margin_l) ? i_margin_l : p_style->i_margin_h;
@@ -1147,7 +1147,7 @@ static void ParseSSAHeader( decoder_t *p_dec )
                     //p_style->font_style.f_angle = f_angle;
 
                     p_style->i_align = 0;
-                    if( i_align == 0x1 || i_align == 0x4 || i_align == 0x1 ) p_style->i_align |= SUBPICTURE_ALIGN_LEFT;
+                    if( i_align == 0x1 || i_align == 0x4 || i_align == 0x7 ) p_style->i_align |= SUBPICTURE_ALIGN_LEFT;
                     if( i_align == 0x3 || i_align == 0x6 || i_align == 0x9 ) p_style->i_align |= SUBPICTURE_ALIGN_RIGHT;
                     if( i_align == 0x7 || i_align == 0x8 || i_align == 0x9 ) p_style->i_align |= SUBPICTURE_ALIGN_TOP;
                     if( i_align == 0x1 || i_align == 0x2 || i_align == 0x3 ) p_style->i_align |= SUBPICTURE_ALIGN_BOTTOM;
index 0fdde18bc7a628bffa8d7d1cde21d6fbf66a824c..123cd52b779f4baca76fc967baef78601f2f5189 100644 (file)
@@ -711,7 +711,7 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
     }
 
     /* Normal text subs, easy markup */
-    p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
+    p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
     p_spu->i_x = p_sys->i_align ? 20 : 0;
     p_spu->i_y = 10;
 
index 5cd42ba9fec22ac083d0d6bc23a6bb81d8c26d34..4dc19ecdee85b1e8e90029ef2105245484fa6dd3 100644 (file)
@@ -882,14 +882,14 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     /*  where to locate the logo: */
     if( p_sys->posx < 0 || p_sys->posy < 0 )
     {   /* set to one of the 9 relative locations */
-        p_spu->i_flags = p_sys->pos;
+        p_spu->p_region->i_align = p_sys->pos;
         p_spu->i_x = 0;
         p_spu->i_y = 0;
         p_spu->b_absolute = VLC_FALSE;
     }
     else
     {   /*  set to an absolute xy, referenced to upper left corner */
-        p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
+        p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
         p_spu->i_x = p_sys->posx;
         p_spu->i_y = p_sys->posy;
         p_spu->b_absolute = VLC_TRUE;
index ed956557bcf486925f67bb2bc81db467e694c69d..5134b4b57d24768b5c83a793756a88ebc3c09475 100644 (file)
@@ -296,14 +296,14 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     /*  where to locate the string: */
     if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )
     {   /* set to one of the 9 relative locations */
-        p_spu->i_flags = p_sys->i_pos;
+        p_spu->p_region->i_align = p_sys->i_pos;
         p_spu->i_x = 0;
         p_spu->i_y = 0;
         p_spu->b_absolute = VLC_FALSE;
     }
     else
     {   /*  set to an absolute xy, referenced to upper left corner */
-        p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
+        p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
         p_spu->i_x = p_sys->i_xoff;
         p_spu->i_y = p_sys->i_yoff;
         p_spu->b_absolute = VLC_TRUE;
index 72bc5ee5ff0266d10fa3fbaa9580a528dc9e9d12..babe36f278b31f8add5cdb8e5b5e61e734c7382e 100644 (file)
@@ -710,6 +710,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
                     + ( i_row * p_sys->i_borderh ) / p_sys->i_rows
                     + ( row_inner_height - fmt_out.i_height ) / 2;
         }
+        p_region->i_align = p_sys->i_align;
 
         if( p_region_prev == NULL )
         {
index 8fb784f69fbf61d3066cade6cf4c077244d4d971..ca12e524cebc4007daa01bd7124c0ad3baefd437 100644 (file)
@@ -482,14 +482,14 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     /*  where to locate the string: */
     if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )
     {   /* set to one of the 9 relative locations */
-        p_spu->i_flags = p_sys->i_pos;
+        p_spu->p_region->i_align = p_sys->i_pos;
         p_spu->i_x = 0;
         p_spu->i_y = 0;
         p_spu->b_absolute = VLC_FALSE;
     }
     else
     {   /*  set to an absolute xy, referenced to upper left corner */
-        p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
+        p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
         p_spu->i_x = p_sys->i_xoff;
         p_spu->i_y = p_sys->i_yoff;
         p_spu->b_absolute = VLC_TRUE;
index 584f5049efe9bb234ae4af07971ff50f1b2d64fa..a92cc497fe27221a5c2bd846c800b2860067bec9 100644 (file)
@@ -146,6 +146,7 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel,
     }
 
     p_spu->p_region->psz_text = strdup( psz_string );
+    p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK;
     p_spu->i_start = i_start;
     p_spu->i_stop = i_stop;
     p_spu->b_ephemer = VLC_FALSE;
@@ -153,7 +154,7 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel,
 
     p_spu->i_x = i_hmargin;
     p_spu->i_y = i_vmargin;
-    p_spu->i_flags = i_flags;
+    p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK;
     p_spu->i_channel = i_channel;
 
     spu_DisplaySubpicture( p_vout->p_spu, p_spu );
index 1e9490b83c19aae64549978885b2d7d15e8d8611..507d48ac70ff7d04f0e172f67672e11fac25816c 100644 (file)
@@ -92,6 +92,7 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
     }
 
     p_spu->p_region->psz_text = strdup( psz_string );
+    p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK;
     p_spu->i_start = i_start;
     p_spu->i_stop = i_stop;
     p_spu->b_ephemer = VLC_TRUE;
@@ -99,7 +100,7 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
 
     p_spu->i_x = i_hmargin;
     p_spu->i_y = i_vmargin;
-    p_spu->i_flags = i_flags;
+    p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK;
     p_spu->i_channel = i_channel;
 
     spu_DisplaySubpicture( p_spu_channel, p_spu );
index c5f2e7cf5c322d39936f8fd164e708e8d8502f4e..ea9642554f52d0a2fe80844445a5e65461096a80 100644 (file)
@@ -93,6 +93,7 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
     }
 
     p_spu->p_region->psz_text = strdup( psz_string );
+    p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK;
     p_spu->i_start = i_start;
     p_spu->i_stop = i_stop;
     p_spu->b_ephemer = VLC_TRUE;
@@ -101,7 +102,7 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
 
     p_spu->i_x = i_hmargin;
     p_spu->i_y = i_vmargin;
-    p_spu->i_flags = i_flags;
+    p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK;
     p_spu->i_channel = i_channel;
 
     spu_DisplaySubpicture( p_vout->p_spu, p_spu );
index 3be8471213ab86487172ba0f33bd89019f439e08..98d719d6932ba3534042dbaaf4b0330a2425f57e 100644 (file)
@@ -661,8 +661,6 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
             {
                 if( p_spu->p_text && p_spu->p_text->p_module )
                 {
-                    p_region->i_align = p_subpic->i_flags;
-
                     if( p_spu->p_text->pf_render_html && p_region->psz_html )
                     {
                         p_spu->p_text->pf_render_html( p_spu->p_text,
@@ -728,6 +726,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
                 p_region->p_cache->fmt = p_spu->p_scale->fmt_out.video;
                 p_region->p_cache->i_x = p_region->i_x * i_scale_width / 1000;
                 p_region->p_cache->i_y = p_region->i_y * i_scale_height / 1000;
+                p_region->p_cache->i_align = p_region->i_align;
 
                 p_pic = p_spu->p_scale->pf_video_filter(
                                  p_spu->p_scale, &p_region->p_cache->picture );
@@ -745,22 +744,22 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
                 p_region = p_region->p_cache;
             }
 
-            if( p_subpic->i_flags & SUBPICTURE_ALIGN_BOTTOM )
+            if( p_region->i_align & SUBPICTURE_ALIGN_BOTTOM )
             {
                 i_y_offset = p_fmt->i_height - p_region->fmt.i_height -
-                    p_subpic->i_y;
+                    p_subpic->i_y - p_region->i_y;
             }
-            else if ( !(p_subpic->i_flags & SUBPICTURE_ALIGN_TOP) )
+            else if ( !(p_region->i_align & SUBPICTURE_ALIGN_TOP) )
             {
                 i_y_offset = p_fmt->i_height / 2 - p_region->fmt.i_height / 2;
             }
 
-            if( p_subpic->i_flags & SUBPICTURE_ALIGN_RIGHT )
+            if( p_region->i_align & SUBPICTURE_ALIGN_RIGHT )
             {
                 i_x_offset = p_fmt->i_width - p_region->fmt.i_width -
-                    i_subpic_x;
+                    i_subpic_x - p_region->i_x;
             }
-            else if ( !(p_subpic->i_flags & SUBPICTURE_ALIGN_LEFT) )
+            else if ( !(p_region->i_align & SUBPICTURE_ALIGN_LEFT) )
             {
                 i_x_offset = p_fmt->i_width / 2 - p_region->fmt.i_width / 2;
             }