]> git.sesse.net Git - vlc/blobdiff - src/video_output/video_output.c
. les sous-titres sont centr�s
[vlc] / src / video_output / video_output.c
index d2e165ee9c183cf27074ce9a69ccfe1a16467baa..b2b9c6add7599e218fe5fe584b89a211fe73d44c 100644 (file)
@@ -42,6 +42,7 @@
 #include "video.h"
 #include "video_output.h"
 #include "video_text.h"
+#include "video_spu.h"
 #include "video_yuv.h"
 
 #include "intf_msg.h"
@@ -204,7 +205,11 @@ vout_thread_t * vout_CreateThread   ( char *psz_display, int i_root_window,
 
     /* Load fonts - fonts must be initialized after the system method since
      * they may be dependant on screen depth and other thread properties */
-    p_vout->p_default_font      = vout_LoadFont( VOUT_DEFAULT_FONT );
+    p_vout->p_default_font      = vout_LoadFont( DATA_PATH "/" VOUT_DEFAULT_FONT );
+    if( p_vout->p_default_font == NULL )
+    {
+        p_vout->p_default_font  = vout_LoadFont( "share/" VOUT_DEFAULT_FONT );
+    }
     if( p_vout->p_default_font == NULL )
     {
         p_vout->p_sys_destroy( p_vout );
@@ -212,7 +217,11 @@ vout_thread_t * vout_CreateThread   ( char *psz_display, int i_root_window,
         free( p_vout );
         return( NULL );
     }
-    p_vout->p_large_font        = vout_LoadFont( VOUT_LARGE_FONT );
+    p_vout->p_large_font        = vout_LoadFont( DATA_PATH "/" VOUT_LARGE_FONT );
+    if( p_vout->p_large_font == NULL )
+    {
+        p_vout->p_large_font    = vout_LoadFont( "share/" VOUT_LARGE_FONT );
+    }
     if( p_vout->p_large_font == NULL )
     {
         vout_UnloadFont( p_vout->p_default_font );
@@ -352,9 +361,10 @@ subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
             if( (p_vout->p_subpicture[i_subpic].i_type  == i_type)   &&
                 (p_vout->p_subpicture[i_subpic].i_size  >= i_size) )
             {
-                /* Memory size do match or is smaller : memory will not be reallocated,
-                 * and function can end immediately - this is the best possible case,
-                 * since no memory allocation needs to be done */
+                /* Memory size do match or is smaller : memory will not be
+                 * reallocated, and function can end immediately - this is
+                 * the best possible case, since no memory allocation needs
+                 * to be done */
                 p_vout->p_subpicture[i_subpic].i_status = RESERVED_SUBPICTURE;
 #ifdef DEBUG_VIDEO
                 intf_DbgMsg("subpicture %p (in destroyed subpicture slot)\n",
@@ -381,8 +391,8 @@ subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
     /* If no free subpicture is available, use a destroyed subpicture */
     if( (p_free_subpic == NULL) && (p_destroyed_subpic != NULL ) )
     {
-        /* No free subpicture or matching destroyed subpicture has been found, but
-         * a destroyed subpicture is still avalaible */
+        /* No free subpicture or matching destroyed subpicture has been
+         * found, but a destroyed subpicture is still avalaible */
         free( p_destroyed_subpic->p_data );
         p_free_subpic = p_destroyed_subpic;
     }
@@ -398,6 +408,9 @@ subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
         case TEXT_SUBPICTURE:                             /* text subpicture */
             p_free_subpic->p_data = malloc( i_size + 1 );
             break;
+        case DVD_SUBPICTURE:                          /* DVD subpicture unit */
+            p_free_subpic->p_data = malloc( i_size );
+            break;
 #ifdef DEBUG
         default:
             intf_DbgMsg("error: unknown subpicture type %d\n", i_type );
@@ -407,7 +420,7 @@ subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
         }
 
         if( p_free_subpic->p_data != NULL )
-        {                    /* Copy subpicture informations, set some default values */
+        {           /* Copy subpicture informations, set some default values */
             p_free_subpic->i_type                      = i_type;
             p_free_subpic->i_status                    = RESERVED_SUBPICTURE;
             p_free_subpic->i_size                      = i_size;
@@ -996,9 +1009,10 @@ last_display_date = display_date;
 #endif
                 if( display_date > current_date + VOUT_DISPLAY_DELAY )
             {
-                /* A picture is ready to be rendered, but its rendering date is
-                 * far from the current one so the thread will perform an empty loop
-                 * as if no picture were found. The picture state is unchanged */
+                /* A picture is ready to be rendered, but its rendering date
+                 * is far from the current one so the thread will perform an
+                 * empty loop as if no picture were found. The picture state
+                 * is unchanged */
                 p_pic =         NULL;
                 display_date =  0;
             }
@@ -1010,11 +1024,20 @@ last_display_date = display_date;
             }
         }
         /*
-         * Find the subpicture to display - this operation does not need lock, since
-         * only READY_SUBPICTURES are handled. If no picture has been selected,
-         * display_date will depend on the subpicture
+         * Find the subpictures to display - this operation does not need
+         * lock, since only READY_SUBPICTURE are handled. If no picture
+         * has been selected, display_date will depend on the subpicture
          */
-        /* XXX?? */
+        /* FIXME: we should find *all* subpictures to display, and
+         * check their displaying date as well */
+        for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
+        {
+            if( p_vout->p_subpicture[i_index].i_status == READY_SUBPICTURE )
+            {
+                p_subpic = &p_vout->p_subpicture[i_index];
+                break;
+            }
+        }
 
         /*
          * Perform rendering, sleep and display rendered picture
@@ -1064,12 +1087,13 @@ last_display_date = display_date;
                 }
 
                 /* Remove subpicture from heap */
-                vlc_mutex_lock( &p_vout->subpicture_lock );
+                /*vlc_mutex_lock( &p_vout->subpicture_lock );
                 p_subpic->i_status = DESTROYED_SUBPICTURE;
-                vlc_mutex_unlock( &p_vout->subpicture_lock );
+                vlc_mutex_unlock( &p_vout->subpicture_lock );*/
             }
 
         }
+#if 0
         else if( p_subpic )                              /* subpicture alone */
         {
             b_display = p_vout->b_active;
@@ -1093,10 +1117,11 @@ last_display_date = display_date;
             }
 
             /* Remove subpicture from heap */
-            vlc_mutex_lock( &p_vout->subpicture_lock );
+            /*vlc_mutex_lock( &p_vout->subpicture_lock );
             p_subpic->i_status = DESTROYED_SUBPICTURE;
-            vlc_mutex_unlock( &p_vout->subpicture_lock );
+            vlc_mutex_unlock( &p_vout->subpicture_lock );*/
         }
+#endif
         else if( p_vout->b_active )        /* idle or interface screen alone */
         {
             if( p_vout->b_interface && 0 /* && XXX?? intf_change */ )
@@ -1206,7 +1231,7 @@ static void ErrorThread( vout_thread_t *p_vout )
 /*****************************************************************************
  * EndThread: thread destruction
  *****************************************************************************
- * This function is called when the thread ends after a sucessfull
+ * This function is called when the thread ends after a sucessful
  * initialization. It frees all ressources allocated by InitThread.
  *****************************************************************************/
 static void EndThread( vout_thread_t *p_vout )
@@ -1805,6 +1830,12 @@ static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
 
     switch( p_subpic->i_type )
     {
+    case DVD_SUBPICTURE:                              /* DVD subpicture unit */
+        vout_RenderSPU( p_subpic->p_data, p_subpic->type.spu.i_offset,
+                        p_subpic->type.spu.i_x1, p_subpic->type.spu.i_y1,
+                        p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
+                        p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line );
+        break;
     case TEXT_SUBPICTURE:                                /* single line text */
         /* Select default font if not specified */
         p_font = p_subpic->type.text.p_font;
@@ -1813,7 +1844,8 @@ static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
             p_font = p_vout->p_default_font;
         }
 
-        /* Computes text size (width and height fields are ignored) and print it */
+        /* Compute text size (width and height fields are ignored)
+         * and print it */
         vout_TextSize( p_font, p_subpic->type.text.i_style, p_subpic->p_data, &i_width, &i_height );
         if( !Align( p_vout, &p_subpic->i_x, &p_subpic->i_y, i_width, i_height,
                     p_subpic->i_horizontal_align, p_subpic->i_vertical_align ) )