* include/video_output.h, ALL: changed api for vout_Request()/vout_Create() to be...
authorGildas Bazin <gbazin@videolan.org>
Sat, 5 Mar 2005 16:49:15 +0000 (16:49 +0000)
committerGildas Bazin <gbazin@videolan.org>
Sat, 5 Mar 2005 16:49:15 +0000 (16:49 +0000)
18 files changed:
include/video_output.h
modules/codec/ffmpeg/video.c
modules/video_filter/adjust.c
modules/video_filter/clone.c
modules/video_filter/crop.c
modules/video_filter/deinterlace.c
modules/video_filter/distort.c
modules/video_filter/invert.c
modules/video_filter/logo.c
modules/video_filter/motionblur.c
modules/video_filter/motiondetect.c
modules/video_filter/transform.c
modules/video_filter/wall.c
modules/visualization/goom.c
modules/visualization/visual/visual.c
src/input/decoder.c
src/video_output/video_output.c
src/video_output/vout_pictures.c

index 0ddccd9..0eeacd6 100644 (file)
@@ -121,6 +121,10 @@ struct vout_thread_t
     picture_heap_t      output;                          /**< direct buffers */
     vlc_bool_t          b_direct;            /**< rendered are like direct ? */
     vout_chroma_t       chroma;                      /**< translation tables */
+
+    video_format_t      fmt_render;      /* render format (from the decoder) */
+    video_format_t      fmt_in;            /* input (modified render) format */
+    video_format_t      fmt_out;     /* output format (for the video output) */
     /**@}*/
 
     /* Picture heap */
@@ -194,10 +198,10 @@ struct vout_thread_t
 /*****************************************************************************
  * Prototypes
  *****************************************************************************/
-#define vout_Request(a,b,c,d,e,f) __vout_Request(VLC_OBJECT(a),b,c,d,e,f)
-VLC_EXPORT( vout_thread_t *, __vout_Request,      ( vlc_object_t *, vout_thread_t *, unsigned int, unsigned int, uint32_t, unsigned int ) );
-#define vout_Create(a,b,c,d,e) __vout_Create(VLC_OBJECT(a),b,c,d,e)
-VLC_EXPORT( vout_thread_t *, __vout_Create,       ( vlc_object_t *, unsigned int, unsigned int, uint32_t, unsigned int ) );
+#define vout_Request(a,b,c) __vout_Request(VLC_OBJECT(a),b,c)
+VLC_EXPORT( vout_thread_t *, __vout_Request,    ( vlc_object_t *, vout_thread_t *, video_format_t * ) );
+#define vout_Create(a,b) __vout_Create(VLC_OBJECT(a),b)
+VLC_EXPORT( vout_thread_t *, __vout_Create,       ( vlc_object_t *, video_format_t * ) );
 VLC_EXPORT( void,            vout_Destroy,        ( vout_thread_t * ) );
 VLC_EXPORT( int, vout_VarCallback, ( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ) );
 
index 146d61a..7813b7a 100644 (file)
@@ -169,6 +169,8 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,
         p_dec->fmt_out.video.i_aspect =
             VOUT_ASPECT_FACTOR * ( av_q2d(p_context->sample_aspect_ratio) *
                 p_context->width / p_context->height );
+       p_dec->fmt_out.video.i_sar_num = p_context->sample_aspect_ratio.num;
+       p_dec->fmt_out.video.i_sar_den = p_context->sample_aspect_ratio.den;
 #else
         p_dec->fmt_out.video.i_aspect =
             VOUT_ASPECT_FACTOR * p_context->aspect_ratio;
index a3382b1..509cd4c 100644 (file)
@@ -150,6 +150,7 @@ static int Init( vout_thread_t *p_vout )
 {
     int i_index;
     picture_t *p_pic;
+    video_format_t fmt = {0};
 
     I_OUTPUTPICTURES = 0;
 
@@ -159,12 +160,18 @@ static int Init( vout_thread_t *p_vout )
     p_vout->output.i_height = p_vout->render.i_height;
     p_vout->output.i_aspect = p_vout->render.i_aspect;
 
+    fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->render.i_chroma;
+    fmt.i_aspect = p_vout->render.i_aspect;
+    fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     /* Try to open the real video output */
     msg_Dbg( p_vout, "spawning the real video output" );
 
-    p_vout->p_sys->p_vout = vout_Create( p_vout,
-                     p_vout->render.i_width, p_vout->render.i_height,
-                     p_vout->render.i_chroma, p_vout->render.i_aspect );
+    p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
 
     /* Everything failed */
     if( p_vout->p_sys->p_vout == NULL )
index f274512..ceb5b15 100644 (file)
@@ -205,6 +205,7 @@ static int Init( vout_thread_t *p_vout )
     int   i_index, i_vout;
     picture_t *p_pic;
     char *psz_default_vout;
+    video_format_t fmt = {0};
 
     I_OUTPUTPICTURES = 0;
 
@@ -214,6 +215,14 @@ static int Init( vout_thread_t *p_vout )
     p_vout->output.i_height = p_vout->render.i_height;
     p_vout->output.i_aspect = p_vout->render.i_aspect;
 
+    fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->render.i_chroma;
+    fmt.i_aspect = p_vout->render.i_aspect;
+    fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     /* Try to open the real video output */
     msg_Dbg( p_vout, "spawning the real video outputs" );
 
@@ -227,9 +236,7 @@ static int Init( vout_thread_t *p_vout )
                            "default", 8 ) ) )
         {
             p_vout->p_sys->pp_vout[i_vout] =
-                vout_Create( p_vout, p_vout->render.i_width,
-                             p_vout->render.i_height, p_vout->render.i_chroma, 
-                             p_vout->render.i_aspect );
+                vout_Create( p_vout, &fmt );
         }
         else
         {
@@ -237,9 +244,7 @@ static int Init( vout_thread_t *p_vout )
             config_PutPsz( p_vout, "vout",
                            p_vout->p_sys->ppsz_vout_list[i_vout] );
             p_vout->p_sys->pp_vout[i_vout] =
-                vout_Create( p_vout, p_vout->render.i_width,
-                             p_vout->render.i_height, p_vout->render.i_chroma, 
-                             p_vout->render.i_aspect );
+                vout_Create( p_vout, &fmt );
 
             /* Reset the default value */
             config_PutPsz( p_vout, "vout", psz_default_vout );
index 5e34196..191a037 100644 (file)
@@ -134,6 +134,7 @@ static int Init( vout_thread_t *p_vout )
     int   i_index;
     char *psz_var;
     picture_t *p_pic;
+    video_format_t fmt = {0};
 
     I_OUTPUTPICTURES = 0;
 
@@ -247,10 +248,16 @@ static int Init( vout_thread_t *p_vout )
                             * p_vout->output.i_height / p_vout->p_sys->i_height
                             * p_vout->p_sys->i_width / p_vout->output.i_width;
 
+    fmt.i_width = fmt.i_visible_width = p_vout->p_sys->i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->p_sys->i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->render.i_chroma;
+    fmt.i_aspect = p_vout->p_sys->i_aspect;
+    fmt.i_sar_num = p_vout->p_sys->i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     /* Try to open the real video output */
-    p_vout->p_sys->p_vout = vout_Create( p_vout,
-                    p_vout->p_sys->i_width, p_vout->p_sys->i_height,
-                    p_vout->render.i_chroma, p_vout->p_sys->i_aspect );
+    p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
     if( p_vout->p_sys->p_vout == NULL )
     {
         msg_Err( p_vout, "failed to create vout" );
@@ -310,6 +317,8 @@ static void Destroy( vlc_object_t *p_this )
  *****************************************************************************/
 static int Manage( vout_thread_t *p_vout )
 {
+    video_format_t fmt = {0};
+
     if( !p_vout->p_sys->b_changed )
     {
         return VLC_SUCCESS;
@@ -317,9 +326,15 @@ static int Manage( vout_thread_t *p_vout )
 
     vout_Destroy( p_vout->p_sys->p_vout );
 
-    p_vout->p_sys->p_vout = vout_Create( p_vout,
-                    p_vout->p_sys->i_width, p_vout->p_sys->i_height,
-                    p_vout->render.i_chroma, p_vout->p_sys->i_aspect );
+    fmt.i_width = fmt.i_visible_width = p_vout->p_sys->i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->p_sys->i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->render.i_chroma;
+    fmt.i_aspect = p_vout->p_sys->i_aspect;
+    fmt.i_sar_num = p_vout->p_sys->i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
+    p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
     if( p_vout->p_sys->p_vout == NULL )
     {
         msg_Err( p_vout, "failed to create vout" );
index b959f6c..3a4a440 100644 (file)
@@ -320,9 +320,18 @@ static int Init( vout_thread_t *p_vout )
 static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout )
 {
     vout_thread_t *p_real_vout = NULL;
+    video_format_t fmt = {0};
 
     msg_Dbg( p_vout, "spawning the real video output" );
 
+    fmt.i_width = fmt.i_visible_width = p_vout->output.i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->output.i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->output.i_chroma;
+    fmt.i_aspect = p_vout->output.i_aspect;
+    fmt.i_sar_num = p_vout->output.i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     switch( p_vout->render.i_chroma )
     {
     case VLC_FOURCC('I','4','2','0'):
@@ -332,28 +341,21 @@ static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout )
         {
         case DEINTERLACE_MEAN:
         case DEINTERLACE_DISCARD:
-            p_real_vout =
-                vout_Create( p_vout,
-                       p_vout->output.i_width, p_vout->output.i_height / 2,
-                       p_vout->output.i_chroma, p_vout->output.i_aspect );
+            fmt.i_height = fmt.i_visible_height = p_vout->output.i_height / 2;
+            p_real_vout = vout_Create( p_vout, &fmt );
             break;
 
         case DEINTERLACE_BOB:
         case DEINTERLACE_BLEND:
         case DEINTERLACE_LINEAR:
-            p_real_vout =
-                vout_Create( p_vout,
-                       p_vout->output.i_width, p_vout->output.i_height,
-                       p_vout->output.i_chroma, p_vout->output.i_aspect );
+            p_real_vout = vout_Create( p_vout, &fmt );
             break;
         }
         break;
 
     case VLC_FOURCC('I','4','2','2'):
-        p_real_vout =
-            vout_Create( p_vout,
-                       p_vout->output.i_width, p_vout->output.i_height,
-                       VLC_FOURCC('I','4','2','0'), p_vout->output.i_aspect );
+        fmt.i_chroma = VLC_FOURCC('I','4','2','0');
+        p_real_vout = vout_Create( p_vout, &fmt );
         break;
 
     default:
index bf560e8..f79bcd1 100644 (file)
@@ -165,6 +165,7 @@ static int Init( vout_thread_t *p_vout )
 {
     int i_index;
     picture_t *p_pic;
+    video_format_t fmt = {0};
 
     I_OUTPUTPICTURES = 0;
 
@@ -174,12 +175,18 @@ static int Init( vout_thread_t *p_vout )
     p_vout->output.i_height = p_vout->render.i_height;
     p_vout->output.i_aspect = p_vout->render.i_aspect;
 
+    fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->render.i_chroma;
+    fmt.i_aspect = p_vout->render.i_aspect;
+    fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     /* Try to open the real video output */
     msg_Dbg( p_vout, "spawning the real video output" );
 
-    p_vout->p_sys->p_vout = vout_Create( p_vout,
-                           p_vout->render.i_width, p_vout->render.i_height,
-                           p_vout->render.i_chroma, p_vout->render.i_aspect );
+    p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
 
     /* Everything failed */
     if( p_vout->p_sys->p_vout == NULL )
index 8fcbe6c..3cb78c5 100644 (file)
@@ -111,6 +111,7 @@ static int Init( vout_thread_t *p_vout )
 {
     int i_index;
     picture_t *p_pic;
+    video_format_t fmt = {0};
 
     I_OUTPUTPICTURES = 0;
 
@@ -120,12 +121,18 @@ static int Init( vout_thread_t *p_vout )
     p_vout->output.i_height = p_vout->render.i_height;
     p_vout->output.i_aspect = p_vout->render.i_aspect;
 
+    fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->render.i_chroma;
+    fmt.i_aspect = p_vout->render.i_aspect;
+    fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     /* Try to open the real video output */
     msg_Dbg( p_vout, "spawning the real video output" );
 
-    p_vout->p_sys->p_vout = vout_Create( p_vout,
-                           p_vout->render.i_width, p_vout->render.i_height,
-                           p_vout->render.i_chroma, p_vout->render.i_aspect );
+    p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
 
     /* Everything failed */
     if( p_vout->p_sys->p_vout == NULL )
index 9bd00ed..7325801 100644 (file)
@@ -211,6 +211,7 @@ static int Init( vout_thread_t *p_vout )
     vout_sys_t *p_sys = p_vout->p_sys;
     picture_t *p_pic;
     int i_index;
+    video_format_t fmt = {0};
 
     I_OUTPUTPICTURES = 0;
 
@@ -220,6 +221,14 @@ static int Init( vout_thread_t *p_vout )
     p_vout->output.i_height = p_vout->render.i_height;
     p_vout->output.i_aspect = p_vout->render.i_aspect;
 
+    fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->render.i_chroma;
+    fmt.i_aspect = p_vout->render.i_aspect;
+    fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     /* Load the video blending filter */
     p_sys->p_blend = vlc_object_create( p_vout, sizeof(filter_t) );
     vlc_object_attach( p_sys->p_blend, p_vout );
@@ -280,9 +289,7 @@ static int Init( vout_thread_t *p_vout )
     /* Try to open the real video output */
     msg_Dbg( p_vout, "spawning the real video output" );
 
-    p_sys->p_vout =
-        vout_Create( p_vout, p_vout->render.i_width, p_vout->render.i_height,
-                     p_vout->render.i_chroma, p_vout->render.i_aspect );
+    p_sys->p_vout = vout_Create( p_vout, &fmt );
 
     /* Everything failed */
     if( p_sys->p_vout == NULL )
index 015ba58..406f9e5 100644 (file)
@@ -129,6 +129,7 @@ static int Init( vout_thread_t *p_vout )
 {
     int i_index;
     picture_t *p_pic;
+    video_format_t fmt = {0};
 
     I_OUTPUTPICTURES = 0;
 
@@ -153,14 +154,20 @@ static int Init( vout_thread_t *p_vout )
 
     msg_Dbg( p_vout, "spawning the real video output" );
 
+    fmt.i_width = fmt.i_visible_width = p_vout->output.i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->output.i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->output.i_chroma;
+    fmt.i_aspect = p_vout->output.i_aspect;
+    fmt.i_sar_num = p_vout->output.i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     switch( p_vout->render.i_chroma )
     {
     case VLC_FOURCC('I','4','2','0'):
     case VLC_FOURCC('I','Y','U','V'):
     case VLC_FOURCC('Y','V','1','2'):
-        p_vout->p_sys->p_vout = vout_Create( p_vout,
-                           p_vout->output.i_width, p_vout->output.i_height,
-                           p_vout->output.i_chroma, p_vout->output.i_aspect );
+        p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
         break;
     default:
         break;
index 4daeb43..34bd4cf 100644 (file)
@@ -211,6 +211,7 @@ static int Init( vout_thread_t *p_vout )
 {
     int i_index;
     picture_t *p_pic;
+    video_format_t fmt = {0};
 
     I_OUTPUTPICTURES = 0;
 
@@ -220,12 +221,18 @@ static int Init( vout_thread_t *p_vout )
     p_vout->output.i_height = p_vout->render.i_height;
     p_vout->output.i_aspect = p_vout->render.i_aspect;
 
+    fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->render.i_chroma;
+    fmt.i_aspect = p_vout->render.i_aspect;
+    fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     /* Try to open the real video output */
     msg_Dbg( p_vout, "spawning the real video output" );
 
-    p_vout->p_sys->p_vout = vout_Create( p_vout,
-                           p_vout->render.i_width, p_vout->render.i_height,
-                           p_vout->render.i_chroma, p_vout->render.i_aspect );
+    p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
 
     /* Everything failed */
     if( p_vout->p_sys->p_vout == NULL )
index be4ede3..954b96b 100644 (file)
@@ -180,6 +180,7 @@ static int Init( vout_thread_t *p_vout )
 {
     int i_index;
     picture_t *p_pic;
+    video_format_t fmt = {0};
 
     I_OUTPUTPICTURES = 0;
 
@@ -189,23 +190,31 @@ static int Init( vout_thread_t *p_vout )
     p_vout->output.i_height = p_vout->render.i_height;
     p_vout->output.i_aspect = p_vout->render.i_aspect;
 
+    fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->render.i_chroma;
+    fmt.i_aspect = p_vout->render.i_aspect;
+    fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     /* Try to open the real video output */
     msg_Dbg( p_vout, "spawning the real video output" );
 
     if( p_vout->p_sys->b_rotation )
     {
-        p_vout->p_sys->p_vout = vout_Create( p_vout,
-                           p_vout->render.i_height, p_vout->render.i_width,
-                           p_vout->render.i_chroma,
-                           (uint64_t)VOUT_ASPECT_FACTOR
-                            * (uint64_t)VOUT_ASPECT_FACTOR
-                            / (uint64_t)p_vout->render.i_aspect );
+        fmt.i_width = fmt.i_visible_width = p_vout->render.i_height;
+        fmt.i_height = fmt.i_visible_height = p_vout->render.i_width;
+        fmt.i_aspect = VOUT_ASPECT_FACTOR *
+            (uint64_t)VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
+        fmt.i_sar_num = VOUT_ASPECT_FACTOR;
+        fmt.i_sar_den = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
+
+        p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
     }
     else
     {
-        p_vout->p_sys->p_vout = vout_Create( p_vout,
-                           p_vout->render.i_width, p_vout->render.i_height,
-                           p_vout->render.i_chroma, p_vout->render.i_aspect );
+        p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
     }
 
     /* Everything failed */
index 8ebc34c..3d0c309 100644 (file)
@@ -229,6 +229,7 @@ static int Init( vout_thread_t *p_vout )
     int i_index, i_row, i_col, i_width, i_height, i_left, i_top;
     unsigned int i_target_width,i_target_height;
     picture_t *p_pic;
+    video_format_t fmt = {0};
     int i_aspect = 4*VOUT_ASPECT_FACTOR/3;
     int i_align = 0;
     unsigned int i_hstart, i_hend, i_vstart, i_vend;
@@ -269,6 +270,14 @@ static int Init( vout_thread_t *p_vout )
     p_vout->output.i_aspect = p_vout->render.i_aspect;
     var_Create( p_vout, "align", VLC_VAR_INTEGER );
 
+    fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
+    fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_chroma = p_vout->render.i_chroma;
+    fmt.i_aspect = p_vout->render.i_aspect;
+    fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+
     w1 = p_vout->output.i_width / p_vout->p_sys->i_col;
     w1 &= ~1;
     h1 = w1 * VOUT_ASPECT_FACTOR / i_aspect&~1;
@@ -394,12 +403,14 @@ static int Init( vout_thread_t *p_vout )
             var_SetInteger( p_vout, "video-x", i_left + i_xpos - i_width);
             var_SetInteger( p_vout, "video-y", i_top + i_ypos );
 
+            fmt.i_width = fmt.i_visible_width = i_width;
+            fmt.i_height = fmt.i_visible_height = i_height;
+            fmt.i_aspect = i_aspect * i_target_height / i_height *
+                i_width / i_target_width;
+
             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout =
-                vout_Create( p_vout, i_width, i_height,
-                             p_vout->render.i_chroma,
-                             i_aspect * i_target_height / i_height *
-                             i_width / i_target_width );
-            if( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout == NULL )
+                vout_Create( p_vout, &fmt );
+            if( !p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout )
             {
                 msg_Err( p_vout, "failed to get %ix%i vout threads",
                                  p_vout->p_sys->i_col, p_vout->p_sys->i_row );
index f9d9e0a..1ec0f33 100644 (file)
@@ -131,6 +131,7 @@ static int Open( vlc_object_t *p_this )
     aout_filter_sys_t *p_sys;
     goom_thread_t     *p_thread;
     vlc_value_t       width, height;
+    video_format_t    fmt = {0};
 
     if ( p_filter->input.i_format != VLC_FOURCC('f','l','3','2' )
          || p_filter->output.i_format != VLC_FOURCC('f','l','3','2') )
@@ -160,10 +161,13 @@ static int Open( vlc_object_t *p_this )
     var_Create( p_thread, "goom-height", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
     var_Get( p_thread, "goom-height", &height );
 
-    p_thread->p_vout =
-        vout_Request( p_filter, NULL, width.i_int, height.i_int,
-                      VLC_FOURCC('R','V','3','2'),
-                      VOUT_ASPECT_FACTOR * width.i_int/height.i_int );
+    fmt.i_width = fmt.i_visible_width = width.i_int;
+    fmt.i_height = fmt.i_visible_height = height.i_int;
+    fmt.i_chroma = VLC_FOURCC('R','V','3','2');
+    fmt.i_aspect = VOUT_ASPECT_FACTOR * width.i_int/height.i_int;
+    fmt.i_sar_num = fmt.i_sar_den = 1;
+
+    p_thread->p_vout = vout_Request( p_filter, NULL, &fmt );
     if( p_thread->p_vout == NULL )
     {
         msg_Err( p_filter, "no suitable vout module" );
@@ -386,7 +390,7 @@ static void Close( vlc_object_t *p_this )
     vlc_thread_join( p_sys->p_thread );
 
     /* Free data */
-    vout_Request( p_filter, p_sys->p_thread->p_vout, 0, 0, 0, 0 );
+    vout_Request( p_filter, p_sys->p_thread->p_vout, 0 );
     vlc_mutex_destroy( &p_sys->p_thread->lock );
     vlc_cond_destroy( &p_sys->p_thread->wait );
     vlc_object_detach( p_sys->p_thread );
index 5d10f61..1c0c022 100644 (file)
@@ -132,6 +132,7 @@ static int Open( vlc_object_t *p_this )
     vlc_value_t        val;
 
     char *psz_effects, *psz_parser;
+    video_format_t fmt = {0};
 
     if( ( p_filter->input.i_format != VLC_FOURCC('f','l','3','2') &&
           p_filter->input.i_format != VLC_FOURCC('f','i','3','2') ) )
@@ -246,12 +247,13 @@ static int Open( vlc_object_t *p_this )
     }
 
     /* Open the video output */
-    p_sys->p_vout =
-         vout_Request( p_filter, NULL,
-                       p_sys->i_width, p_sys->i_height,
-                       VLC_FOURCC('I','4','2','0'),
-                       VOUT_ASPECT_FACTOR * p_sys->i_width/p_sys->i_height );
+    fmt.i_width = fmt.i_visible_width = p_sys->i_width;
+    fmt.i_height = fmt.i_visible_height = p_sys->i_height;
+    fmt.i_chroma = VLC_FOURCC('I','4','2','0');
+    fmt.i_aspect = VOUT_ASPECT_FACTOR * p_sys->i_width/p_sys->i_height;
+    fmt.i_sar_num = fmt.i_sar_den = 1;
 
+    p_sys->p_vout = vout_Request( p_filter, NULL, &fmt );
     if( p_sys->p_vout == NULL )
     {
         msg_Err( p_filter, "no suitable vout module" );
@@ -329,7 +331,7 @@ static void Close( vlc_object_t *p_this )
 
     if( p_filter->p_sys->p_vout )
     {
-        vout_Request( p_filter, p_filter->p_sys->p_vout, 0, 0, 0, 0 );
+        vout_Request( p_filter, p_filter->p_sys->p_vout, 0 );
     }
 
     /* Free the list */
index 3eee429..40ef2bb 100644 (file)
@@ -779,7 +779,7 @@ static void DeleteDecoder( decoder_t * p_dec )
 #undef p_pic
 
         /* We are about to die. Reattach video output to p_vlc. */
-        vout_Request( p_dec, p_dec->p_owner->p_vout, 0, 0, 0, 0 );
+        vout_Request( p_dec, p_dec->p_owner->p_vout, 0 );
     }
 
     if( p_dec->p_owner->p_sout_input )
@@ -885,15 +885,35 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
             return NULL;
         }
 
+        if( !p_dec->fmt_out.video.i_sar_num ||
+            !p_dec->fmt_out.video.i_sar_den )
+        {
+            p_dec->fmt_out.video.i_sar_num =
+              p_dec->fmt_out.video.i_aspect * p_dec->fmt_out.video.i_height;
+
+            p_dec->fmt_out.video.i_sar_den = VOUT_ASPECT_FACTOR *
+              p_dec->fmt_out.video.i_width;
+        }
+
+        vlc_reduce( &p_dec->fmt_out.video.i_sar_num,
+                    &p_dec->fmt_out.video.i_sar_den,
+                   p_dec->fmt_out.video.i_sar_num,
+                   p_dec->fmt_out.video.i_sar_den, 0 );
+
+       if( !p_dec->fmt_out.video.i_visible_width ||
+           !p_dec->fmt_out.video.i_visible_height )
+       {
+           p_dec->fmt_out.video.i_visible_width =
+               p_dec->fmt_out.video.i_width;
+           p_dec->fmt_out.video.i_visible_height =
+               p_dec->fmt_out.video.i_height;
+       }
+
         p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec;
         p_sys->video = p_dec->fmt_out.video;
 
         p_sys->p_vout = vout_Request( p_dec, p_sys->p_vout,
-                                      p_sys->video.i_width,
-                                      p_sys->video.i_height,
-                                      p_sys->video.i_chroma,
-                                      p_sys->video.i_aspect );
-
+                                      &p_dec->fmt_out.video );
         if( p_sys->p_vout == NULL )
         {
             msg_Err( p_dec, "failed to create video output" );
index ed1e29d..343475d 100644 (file)
@@ -9,6 +9,7 @@
  * $Id$
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
+ *          Gildas Bazin <gbazin@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -74,11 +75,10 @@ int vout_Snapshot( vout_thread_t *, picture_t * );
  * This function looks for a video output thread matching the current
  * properties. If not found, it spawns a new one.
  *****************************************************************************/
-vout_thread_t * __vout_Request ( vlc_object_t *p_this, vout_thread_t *p_vout,
-                                 unsigned int i_width, unsigned int i_height,
-                                 vlc_fourcc_t i_chroma, unsigned int i_aspect )
+vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
+                               video_format_t *p_fmt )
 {
-    if( !i_width || !i_height || !i_chroma )
+    if( !p_fmt )
     {
         /* Reattach video output to input before bailing out */
         if( p_vout )
@@ -168,10 +168,10 @@ vout_thread_t * __vout_Request ( vlc_object_t *p_this, vout_thread_t *p_vout,
             if( psz_filter_chain ) free( psz_filter_chain );
         }
 
-        if( ( p_vout->render.i_width != i_width ) ||
-            ( p_vout->render.i_height != i_height ) ||
-            ( p_vout->render.i_chroma != i_chroma ) ||
-            ( p_vout->render.i_aspect != i_aspect
+        if( ( p_vout->fmt_render.i_width != p_fmt->i_width ) ||
+            ( p_vout->fmt_render.i_height != p_fmt->i_height ) ||
+            ( p_vout->fmt_render.i_chroma != p_fmt->i_chroma ) ||
+            ( p_vout->fmt_render.i_aspect != p_fmt->i_aspect
                     && !p_vout->b_override_aspect ) ||
             p_vout->b_filter_change )
         {
@@ -195,7 +195,7 @@ vout_thread_t * __vout_Request ( vlc_object_t *p_this, vout_thread_t *p_vout,
     {
         msg_Dbg( p_this, "no usable vout present, spawning one" );
 
-        p_vout = vout_Create( p_this, i_width, i_height, i_chroma, i_aspect );
+        p_vout = vout_Create( p_this, p_fmt );
     }
 
     return p_vout;
@@ -207,9 +207,7 @@ vout_thread_t * __vout_Request ( vlc_object_t *p_this, vout_thread_t *p_vout,
  * This function creates a new video output thread, and returns a pointer
  * to its description. On error, it returns NULL.
  *****************************************************************************/
-vout_thread_t * __vout_Create( vlc_object_t *p_parent,
-                               unsigned int i_width, unsigned int i_height,
-                               vlc_fourcc_t i_chroma, unsigned int i_aspect )
+vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
 {
     vout_thread_t  * p_vout;                            /* thread descriptor */
     input_thread_t * p_input_thread;
@@ -217,6 +215,11 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
     char           * psz_plugin;
     vlc_value_t      val, text;
 
+    unsigned int i_width = p_fmt->i_width;
+    unsigned int i_height = p_fmt->i_height;
+    vlc_fourcc_t i_chroma = p_fmt->i_chroma;
+    unsigned int i_aspect = p_fmt->i_aspect;
+
     /* Allocate descriptor */
     p_vout = vlc_object_create( p_parent, VLC_OBJECT_VOUT );
     if( p_vout == NULL )
@@ -241,6 +244,8 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
 
     /* Initialize the rendering heap */
     I_RENDERPICTURES = 0;
+    p_vout->fmt_render        = *p_fmt;   /* FIXME palette */
+    p_vout->fmt_in            = *p_fmt;   /* FIXME palette */
     p_vout->render.i_width    = i_width;
     p_vout->render.i_height   = i_height;
     p_vout->render.i_chroma   = i_chroma;
@@ -558,19 +563,59 @@ static int InitThread( vout_thread_t *p_vout )
 
     msg_Dbg( p_vout, "got %i direct buffer(s)", I_OUTPUTPICTURES );
 
-    AspectRatio( p_vout->render.i_aspect, &i_aspect_x, &i_aspect_y );
-    msg_Dbg( p_vout,
-             "picture in %ix%i, chroma 0x%.8x (%4.4s), aspect ratio %i:%i",
-             p_vout->render.i_width, p_vout->render.i_height,
-             p_vout->render.i_chroma, (char*)&p_vout->render.i_chroma,
-             i_aspect_x, i_aspect_y );
+    AspectRatio( p_vout->fmt_render.i_aspect, &i_aspect_x, &i_aspect_y );
+
+    msg_Dbg( p_vout, "picture in %ix%i (%i,%i,%ix%i), "
+             "chroma %4.4s, ar %i:%i, sar %i:%i",
+             p_vout->fmt_render.i_width, p_vout->fmt_render.i_height,
+             p_vout->fmt_render.i_x_offset, p_vout->fmt_render.i_y_offset,
+             p_vout->fmt_render.i_visible_width,
+             p_vout->fmt_render.i_visible_height,
+             (char*)&p_vout->fmt_render.i_chroma,
+             i_aspect_x, i_aspect_y,
+             p_vout->fmt_render.i_sar_num, p_vout->fmt_render.i_sar_den );
+
+    AspectRatio( p_vout->fmt_in.i_aspect, &i_aspect_x, &i_aspect_y );
+
+    msg_Dbg( p_vout, "picture user %ix%i (%i,%i,%ix%i), "
+             "chroma %4.4s, ar %i:%i, sar %i:%i",
+             p_vout->fmt_in.i_width, p_vout->fmt_in.i_height,
+             p_vout->fmt_in.i_x_offset, p_vout->fmt_in.i_y_offset,
+             p_vout->fmt_in.i_visible_width,
+             p_vout->fmt_in.i_visible_height,
+             (char*)&p_vout->fmt_in.i_chroma,
+             i_aspect_x, i_aspect_y,
+             p_vout->fmt_in.i_sar_num, p_vout->fmt_in.i_sar_den );
+
+    if( !p_vout->fmt_out.i_width || !p_vout->fmt_out.i_height )
+    {
+        p_vout->fmt_out.i_width = p_vout->fmt_out.i_visible_width =
+            p_vout->output.i_width;
+        p_vout->fmt_out.i_height = p_vout->fmt_out.i_visible_height =
+            p_vout->output.i_height;
+        p_vout->fmt_out.i_x_offset =  p_vout->fmt_out.i_y_offset = 0;
+
+        p_vout->fmt_out.i_aspect = p_vout->output.i_aspect;
+        p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
+    }
+    if( !p_vout->fmt_out.i_sar_num || !p_vout->fmt_out.i_sar_num )
+    {
+        p_vout->fmt_out.i_sar_num = p_vout->fmt_out.i_aspect *
+            p_vout->fmt_out.i_height;
+        p_vout->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR *
+            p_vout->fmt_out.i_width;
+    }
+
+    vlc_reduce( &p_vout->fmt_out.i_sar_num, &p_vout->fmt_out.i_sar_den,
+                p_vout->fmt_out.i_sar_num, p_vout->fmt_out.i_sar_den, 0 );
+
+    AspectRatio( p_vout->fmt_out.i_aspect, &i_aspect_x, &i_aspect_y );
 
-    AspectRatio( p_vout->output.i_aspect, &i_aspect_x, &i_aspect_y );
-    msg_Dbg( p_vout,
-             "picture out %ix%i, chroma 0x%.8x (%4.4s), aspect ratio %i:%i",
+    msg_Dbg( p_vout, "picture out %ix%i, chroma %4.4s, ar %i:%i, sar %i:%i",
              p_vout->output.i_width, p_vout->output.i_height,
-             p_vout->output.i_chroma, (char*)&p_vout->output.i_chroma,
-             i_aspect_x, i_aspect_y );
+             (char*)&p_vout->output.i_chroma,
+             i_aspect_x, i_aspect_y,
+             p_vout->fmt_out.i_sar_num, p_vout->fmt_out.i_sar_den );
 
     /* Calculate shifts from system-updated masks */
     MaskToShift( &p_vout->output.i_lrshift, &p_vout->output.i_rrshift,
index a7ff57f..b3be49e 100644 (file)
@@ -286,24 +286,18 @@ void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
 picture_t * vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
                                                        subpicture_t *p_subpic )
 {
-    video_format_t fmt;
     int i_scale_width, i_scale_height;
 
     if( p_pic == NULL )
     {
         /* XXX: subtitles */
-
         return NULL;
     }
 
-    fmt.i_aspect = p_vout->output.i_aspect;
-    fmt.i_chroma = p_vout->output.i_chroma;
-    fmt.i_width = p_vout->output.i_width;
-    fmt.i_height = p_vout->output.i_height;
-    fmt.i_sar_num = p_vout->output.i_aspect * fmt.i_height / fmt.i_width;
-    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
-    i_scale_width = p_vout->output.i_width * 1000 / p_vout->render.i_width;
-    i_scale_height = p_vout->output.i_height * 1000 / p_vout->render.i_height;
+    i_scale_width = p_vout->fmt_out.i_visible_width * 1000 /
+        p_vout->fmt_in.i_visible_width;
+    i_scale_height = p_vout->fmt_out.i_visible_height * 1000 /
+        p_vout->fmt_in.i_visible_height;
 
     if( p_pic->i_type == DIRECT_PICTURE )
     {
@@ -320,7 +314,7 @@ picture_t * vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
                  * subtitles. */
                 vout_CopyPicture( p_vout, PP_OUTPUTPICTURE[0], p_pic );
 
-                spu_RenderSubpictures( p_vout->p_spu, &fmt,
+                spu_RenderSubpictures( p_vout->p_spu, &p_vout->fmt_out,
                                        PP_OUTPUTPICTURE[0], p_pic, p_subpic,
                                        i_scale_width, i_scale_height );
 
@@ -336,8 +330,8 @@ picture_t * vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
         /* Picture is in a direct buffer but isn't used by the
          * decoder. We can safely render subtitles on it and
          * display it. */
-        spu_RenderSubpictures( p_vout->p_spu, &fmt, p_pic, p_pic, p_subpic,
-                               i_scale_width, i_scale_height );
+        spu_RenderSubpictures( p_vout->p_spu, &p_vout->fmt_out, p_pic, p_pic,
+                               p_subpic, i_scale_width, i_scale_height );
 
         return p_pic;
     }
@@ -355,8 +349,9 @@ picture_t * vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
                 return NULL;
 
         vout_CopyPicture( p_vout, PP_OUTPUTPICTURE[0], p_pic );
-        spu_RenderSubpictures( p_vout->p_spu, &fmt, PP_OUTPUTPICTURE[0],
-                               p_pic, p_subpic, i_scale_width, i_scale_height);
+        spu_RenderSubpictures( p_vout->p_spu, &p_vout->fmt_out,
+                               PP_OUTPUTPICTURE[0], p_pic,
+                               p_subpic, i_scale_width, i_scale_height );
 
         if( PP_OUTPUTPICTURE[0]->pf_unlock )
             PP_OUTPUTPICTURE[0]->pf_unlock( p_vout, PP_OUTPUTPICTURE[0] );
@@ -378,10 +373,10 @@ picture_t * vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
         if( p_tmp_pic->i_status == FREE_PICTURE )
         {
             vout_AllocatePicture( VLC_OBJECT(p_vout),
-                                  p_tmp_pic, p_vout->output.i_chroma,
-                                  p_vout->output.i_width,
-                                  p_vout->output.i_height,
-                                  p_vout->output.i_aspect );
+                                  p_tmp_pic, p_vout->fmt_out.i_chroma,
+                                  p_vout->fmt_out.i_width,
+                                  p_vout->fmt_out.i_height,
+                                  p_vout->fmt_out.i_aspect );
             p_tmp_pic->i_type = MEMORY_PICTURE;
             p_tmp_pic->i_status = RESERVED_PICTURE;
         }
@@ -390,7 +385,7 @@ picture_t * vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
         p_vout->chroma.pf_convert( p_vout, p_pic, p_tmp_pic );
 
         /* Render subpictures on the first direct buffer */
-        spu_RenderSubpictures( p_vout->p_spu, &fmt, p_tmp_pic,
+        spu_RenderSubpictures( p_vout->p_spu, &p_vout->fmt_out, p_tmp_pic,
                                p_tmp_pic, p_subpic,
                                i_scale_width, i_scale_height );
 
@@ -410,9 +405,9 @@ picture_t * vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
         p_vout->chroma.pf_convert( p_vout, p_pic, &p_vout->p_picture[0] );
 
         /* Render subpictures on the first direct buffer */
-        spu_RenderSubpictures( p_vout->p_spu, &fmt, &p_vout->p_picture[0],
-                               &p_vout->p_picture[0], p_subpic,
-                               i_scale_width, i_scale_height );
+        spu_RenderSubpictures( p_vout->p_spu, &p_vout->fmt_out,
+                               &p_vout->p_picture[0], &p_vout->p_picture[0],
+                               p_subpic, i_scale_width, i_scale_height );
     }
 
     if( p_vout->p_picture[0].pf_unlock )
@@ -435,7 +430,6 @@ void vout_PlacePicture( vout_thread_t *p_vout,
     if( (i_width <= 0) || (i_height <=0) )
     {
         *pi_width = *pi_height = *pi_x = *pi_y = 0;
-
         return;
     }