]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_subpictures.c
* modules/access/dvdnav.c, src/video_output/vout_subpictures.c: Use the proper palett...
[vlc] / src / video_output / vout_subpictures.c
index b7bad00daf3943b0d77ebe37c6040b185ee461f7..12ef0f0e9cd34ade1b3758cba8d1722cdf4169e1 100644 (file)
@@ -111,8 +111,7 @@ int spu_Init( spu_t *p_spu )
     psz_filter = psz_filter_orig = val.psz_string;
     while( psz_filter && *psz_filter )
     {
-        char *psz_parser = strchr( psz_filter, ',' );
-        if( !psz_parser ) psz_parser = strchr( psz_filter, ':' );
+        char *psz_parser = strchr( psz_filter, ':' );
 
         if( psz_parser ) *psz_parser++ = 0;
 
@@ -473,9 +472,6 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
                             subpicture_t *p_subpic,
                             int i_scale_width_orig, int i_scale_height_orig )
 {
-
-    int i_subpic_x;
-  
     /* Get lock */
     vlc_mutex_lock( &p_spu->subpicture_lock );
 
@@ -484,6 +480,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
     {
         subpicture_region_t *p_region = p_subpic->p_region;
         int i_scale_width, i_scale_height;
+        int i_subpic_x = p_subpic->i_x;
 
         /* Load the blending module */
         if( !p_spu->p_blend && p_region )
@@ -512,7 +509,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
             p_spu->p_text->fmt_out.video.i_height =
                 p_spu->p_text->fmt_out.video.i_visible_height =
                     p_fmt->i_height;
-                
+
             p_spu->p_text->pf_sub_buffer_new = spu_new_buffer;
             p_spu->p_text->pf_sub_buffer_del = spu_del_buffer;
             p_spu->p_text->p_module =
@@ -528,11 +525,6 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
                     p_fmt->i_height;
         }
 
-        if ( p_region && p_subpic->p_region->fmt.i_aspect == 0 )
-          /* Set subtitle to be the same aspect ratio as the background
-             source video. */
-            p_subpic->p_region->fmt.i_aspect = p_pic_src->format.i_aspect;
-
         i_scale_width = i_scale_width_orig;
         i_scale_height = i_scale_height_orig;
 
@@ -545,25 +537,31 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
                              p_subpic->i_original_picture_height;
         }
 
-        /* Take care of the aspect ratio */
-        if( p_region && p_subpic->p_region->fmt.i_aspect !=
-                        p_pic_src->format.i_aspect)
+        /* Set default subpicture aspect ratio */
+        if( p_region && p_region->fmt.i_aspect &&
+            (!p_region->fmt.i_sar_num || !p_region->fmt.i_sar_den) )
         {
-            i_scale_width = (p_subpic->p_region->fmt.i_aspect*1000) /
-            p_pic_src->format.i_aspect;
-            i_subpic_x = p_subpic->i_x * i_scale_width / 1000;
-        } else
-          i_subpic_x = p_subpic->i_x;
-
+            p_region->fmt.i_sar_den = p_region->fmt.i_aspect;
+            p_region->fmt.i_sar_num = VOUT_ASPECT_FACTOR;
+        }
+        if( p_region &&
+            (!p_region->fmt.i_sar_num || !p_region->fmt.i_sar_den) )
+        {
+            p_region->fmt.i_sar_den = p_fmt->i_sar_den;
+            p_region->fmt.i_sar_num = p_fmt->i_sar_num;
+        }
 
+        /* Take care of the aspect ratio */
         if( p_region && p_region->fmt.i_sar_num * p_fmt->i_sar_den !=
             p_region->fmt.i_sar_den * p_fmt->i_sar_num )
         {
             i_scale_width = i_scale_width *
                 (int64_t)p_region->fmt.i_sar_num * p_fmt->i_sar_den /
                 p_region->fmt.i_sar_den / p_fmt->i_sar_num;
+            i_subpic_x = p_subpic->i_x * i_scale_width / 1000;
         }
 
+        /* Load the scaling module */
         if( !p_spu->p_scale && (i_scale_width != 1000 ||
             i_scale_height != 1000) )
         {
@@ -583,18 +581,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
                 module_Need( p_spu->p_scale, "video filter2", 0, 0 );
         }
 
-        if( p_subpic->pf_render )
-        {
-            /* HACK to remove when the ogt subpic decoder is gone */
-            if( p_spu->p_parent &&
-                p_spu->p_parent->i_object_type == VLC_OBJECT_VOUT )
-            {
-                vout_thread_t *p_vout = (vout_thread_t *)p_spu->p_parent;
-                p_subpic->pf_render( p_vout, p_pic_dst, p_subpic );
-            }
-        }
-        else while( p_region && p_spu->p_blend &&
-                    p_spu->p_blend->pf_video_blend )
+        while( p_region && p_spu->p_blend && p_spu->p_blend->pf_video_blend )
         {
             int i_fade_alpha = 255;
             int i_x_offset = p_region->i_x + i_subpic_x;
@@ -612,13 +599,11 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
             }
 
             /* Force palette if requested */
-            if( p_spu->b_force_alpha && VLC_FOURCC('Y','U','V','P') ==
+            if( p_spu->b_force_palette && VLC_FOURCC('Y','U','V','P') ==
                 p_region->fmt.i_chroma )
             {
-                p_region->fmt.p_palette->palette[0][3] = p_spu->pi_alpha[0];
-                p_region->fmt.p_palette->palette[1][3] = p_spu->pi_alpha[1];
-                p_region->fmt.p_palette->palette[2][3] = p_spu->pi_alpha[2];
-                p_region->fmt.p_palette->palette[3][3] = p_spu->pi_alpha[3];
+                memcpy( p_region->fmt.p_palette->palette,
+                        p_spu->palette, 16 );
             }
 
             /* Scale SPU if necessary */
@@ -977,7 +962,7 @@ static void UpdateSPU( spu_t *p_spu, vlc_object_t *p_object )
 {
     vlc_value_t val;
 
-    p_spu->b_force_alpha = VLC_FALSE;
+    p_spu->b_force_palette = VLC_FALSE;
     p_spu->b_force_crop = VLC_FALSE;
 
     if( var_Get( p_object, "highlight", &val ) || !val.b_bool ) return;
@@ -992,32 +977,16 @@ static void UpdateSPU( spu_t *p_spu, vlc_object_t *p_object )
     var_Get( p_object, "y-end", &val );
     p_spu->i_crop_height = val.i_int - p_spu->i_crop_y;
 
-#if 0
-    if( var_Get( p_object, "color", &val ) == VLC_SUCCESS )
+    if( var_Get( p_object, "menu-palette", &val ) == VLC_SUCCESS )
     {
-        int i;
-        for( i = 0; i < 4; i++ )
-        {
-            p_spu->pi_color[i] = ((uint8_t *)val.p_address)[i];
-        }
-    }
-#endif
-
-    if( var_Get( p_object, "menu-contrast", &val ) == VLC_SUCCESS )
-    {
-        int i;
-        for( i = 0; i < 4; i++ )
-        {
-            p_spu->pi_alpha[i] = ((uint8_t *)val.p_address)[i];
-            p_spu->pi_alpha[i] = p_spu->pi_alpha[i] == 0xf ?
-                0xff : p_spu->pi_alpha[i] << 4;
-        }
-        p_spu->b_force_alpha = VLC_TRUE;
+        memcpy( p_spu->palette, val.p_address, 16 );
+        p_spu->b_force_palette = VLC_TRUE;
     }
 
-    msg_Dbg( p_object, "crop: %i,%i,%i,%i, alpha: %i",
+    msg_Dbg( p_object, "crop: %i,%i,%i,%i, palette forced: %i",
              p_spu->i_crop_x, p_spu->i_crop_y,
-             p_spu->i_crop_width, p_spu->i_crop_height, p_spu->b_force_alpha );
+             p_spu->i_crop_width, p_spu->i_crop_height,
+             p_spu->b_force_palette );
 }
 
 /*****************************************************************************