]> git.sesse.net Git - vlc/blobdiff - plugins/dummy/vout_dummy.c
* ./BUGS: added a list of known bugs. Please add your findings!
[vlc] / plugins / dummy / vout_dummy.c
index 2cf5b4c7257a30f188735d96fef005e7b685b0f3..1eaf76836512149fbae081bc32525adb7b56f310 100644 (file)
@@ -2,7 +2,7 @@
  * vout_dummy.c: Dummy video output display method for testing purposes
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: vout_dummy.c,v 1.12 2001/12/16 16:18:36 sam Exp $
+ * $Id: vout_dummy.c,v 1.15 2002/01/04 14:01:34 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#define MODULE_NAME dummy
-#include "modules_inner.h"
-
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "defs.h"
-
 #include <errno.h>                                                 /* ENOMEM */
 #include <stdlib.h>                                                /* free() */
 #include <string.h>                                            /* strerror() */
 
-#include "common.h"
-#include "intf_msg.h"
-#include "threads.h"
-#include "mtime.h"
-#include "tests.h"
+#include <videolan/vlc.h>
 
 #include "video.h"
 #include "video_output.h"
 
-#include "modules.h"
-#include "modules_export.h"
-
 #define DUMMY_WIDTH 16
 #define DUMMY_HEIGHT 16
 #define DUMMY_MAX_DIRECTBUFFERS 5
@@ -70,6 +58,7 @@ static int  vout_Init      ( struct vout_thread_s * );
 static void vout_End       ( struct vout_thread_s * );
 static void vout_Destroy   ( struct vout_thread_s * );
 static int  vout_Manage    ( struct vout_thread_s * );
+static void vout_Render    ( struct vout_thread_s *, struct picture_s * );
 static void vout_Display   ( struct vout_thread_s *, struct picture_s * );
 
 static int  DummyNewPicture( struct vout_thread_s *, struct picture_s * );
@@ -86,6 +75,7 @@ void _M( vout_getfunctions )( function_list_t * p_function_list )
     p_function_list->functions.vout.pf_end        = vout_End;
     p_function_list->functions.vout.pf_destroy    = vout_Destroy;
     p_function_list->functions.vout.pf_manage     = vout_Manage;
+    p_function_list->functions.vout.pf_render     = vout_Render;
     p_function_list->functions.vout.pf_display    = vout_Display;
     p_function_list->functions.vout.pf_setpalette = NULL;
 }
@@ -95,11 +85,6 @@ void _M( vout_getfunctions )( function_list_t * p_function_list )
  *****************************************************************************/
 static int vout_Probe( probedata_t *p_data )
 {
-    if( TestMethod( VOUT_METHOD_VAR, "dummy" ) )
-    {
-        return( 999 );
-    }
-
     return( 1 );
 }
 
@@ -134,7 +119,9 @@ static int vout_Init( vout_thread_t *p_vout )
     /* Initialize the output structure */
     switch( p_vout->render.i_chroma )
     {
-        case YUV_420_PICTURE:
+        case FOURCC_I420:
+        case FOURCC_IYUV:
+        case FOURCC_YV12:
             p_vout->output.i_chroma = p_vout->render.i_chroma;
             p_vout->output.i_width  = p_vout->render.i_width;
             p_vout->output.i_height = p_vout->render.i_height;
@@ -142,7 +129,7 @@ static int vout_Init( vout_thread_t *p_vout )
             break;
 
         default:
-            p_vout->output.i_chroma = RGB_16BPP_PICTURE;
+            p_vout->output.i_chroma = FOURCC_RV16;
             p_vout->output.i_width  = p_vout->render.i_width;
             p_vout->output.i_height = p_vout->render.i_height;
             p_vout->output.i_aspect = p_vout->render.i_aspect;
@@ -165,18 +152,13 @@ static int vout_Init( vout_thread_t *p_vout )
         }
 
         /* Allocate the picture */
-        if( DummyNewPicture( p_vout, p_pic ) )
+        if( p_pic == NULL || DummyNewPicture( p_vout, p_pic ) )
         {
             break;
         }
 
-        p_pic->i_status        = DESTROYED_PICTURE;
-        p_pic->i_type          = DIRECT_PICTURE;
-
-        p_pic->i_left_margin   =
-        p_pic->i_right_margin  =
-        p_pic->i_top_margin    =
-        p_pic->i_bottom_margin = 0;
+        p_pic->i_status = DESTROYED_PICTURE;
+        p_pic->i_type   = DIRECT_PICTURE;
 
         PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
 
@@ -197,7 +179,7 @@ static void vout_End( vout_thread_t *p_vout )
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
         i_index--;
-        free( PP_OUTPUTPICTURE[ i_index ]->planes[ 0 ].p_data );
+        free( PP_OUTPUTPICTURE[ i_index ]->p_data );
     }
 }
 
@@ -222,18 +204,22 @@ static int vout_Manage( vout_thread_t *p_vout )
     return( 0 );
 }
 
+/*****************************************************************************
+ * vout_Render: render previously calculated output
+ *****************************************************************************/
+static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
+{
+    /* No need to do anything, the fake direct buffers stay as they are */
+}
+
 /*****************************************************************************
  * vout_Display: displays previously rendered output
- *****************************************************************************
- * This function send the currently rendered image to dummy image, waits until
- * it is displayed and switch the two rendering buffers, preparing next frame.
  *****************************************************************************/
 static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
 {
     /* No need to do anything, the fake direct buffers stay as they are */
 }
 
-
 /*****************************************************************************
  * DummyNewPicture: allocate a picture
  *****************************************************************************
@@ -241,8 +227,6 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
  *****************************************************************************/
 static int DummyNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
 {
-    int i_luma_bytes, i_chroma_bytes;
-
     int i_width  = p_vout->output.i_width;
     int i_height = p_vout->output.i_height;
 
@@ -250,31 +234,33 @@ static int DummyNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
     {
     /* We know this chroma, allocate a buffer which will be used
      * directly by the decoder */
-    case YUV_420_PICTURE:
-
-        /* Precalculate some values */
-        p_pic->i_size         = i_width * i_height;
-        p_pic->i_chroma_width = i_width / 2;
-        p_pic->i_chroma_size  = i_width * ( i_height / 2 );
+    case FOURCC_I420:
+    case FOURCC_IYUV:
+    case FOURCC_YV12:
 
         /* Allocate the memory buffer */
-        i_luma_bytes = p_pic->i_size * sizeof(pixel_data_t);
-        i_chroma_bytes = p_pic->i_chroma_size * sizeof(pixel_data_t);
+        p_pic->p_data = memalign( 16, i_width * i_height * 3 / 2 );
 
         /* Y buffer */
-        p_pic->planes[ Y_PLANE ].p_data = malloc( i_luma_bytes + 2 * i_chroma_bytes );
-        p_pic->planes[ Y_PLANE ].i_bytes = i_luma_bytes;
-        p_pic->planes[ Y_PLANE ].i_line_bytes = i_width * sizeof(pixel_data_t);
+        p_pic->Y_PIXELS = p_pic->p_data;
+        p_pic->p[Y_PLANE].i_lines = i_height;
+        p_pic->p[Y_PLANE].i_pitch = i_width;
+        p_pic->p[Y_PLANE].i_pixel_bytes = 1;
+        p_pic->p[Y_PLANE].b_margin = 0;
 
         /* U buffer */
-        p_pic->planes[ U_PLANE ].p_data = p_pic->planes[ Y_PLANE ].p_data + i_height * i_width;
-        p_pic->planes[ U_PLANE ].i_bytes = i_chroma_bytes / 2;
-        p_pic->planes[ U_PLANE ].i_line_bytes = p_pic->i_chroma_width * sizeof(pixel_data_t);
+        p_pic->U_PIXELS = p_pic->Y_PIXELS + i_height * i_width;
+        p_pic->p[U_PLANE].i_lines = i_height / 2;
+        p_pic->p[U_PLANE].i_pitch = i_width / 2;
+        p_pic->p[U_PLANE].i_pixel_bytes = 1;
+        p_pic->p[U_PLANE].b_margin = 0;
 
         /* V buffer */
-        p_pic->planes[ V_PLANE ].p_data = p_pic->planes[ U_PLANE ].p_data + i_height * p_pic->i_chroma_width;
-        p_pic->planes[ V_PLANE ].i_bytes = i_chroma_bytes / 2;
-        p_pic->planes[ V_PLANE ].i_line_bytes = p_pic->i_chroma_width * sizeof(pixel_data_t);
+        p_pic->V_PIXELS = p_pic->U_PIXELS + i_height * i_width / 4;
+        p_pic->p[V_PLANE].i_lines = i_height / 2;
+        p_pic->p[V_PLANE].i_pitch = i_width / 2;
+        p_pic->p[V_PLANE].i_pixel_bytes = 1;
+        p_pic->p[V_PLANE].b_margin = 0;
 
         /* We allocated 3 planes */
         p_pic->i_planes = 3;
@@ -284,20 +270,31 @@ static int DummyNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
 
     /* Unknown chroma, allocate an RGB buffer, the video output's job
      * will be to do the chroma->RGB conversion */
-    default:
-
-        /* Precalculate some values */
-        i_luma_bytes = sizeof(u16) * i_width * i_height;
+    case FOURCC_RV16:
 
         /* Allocate the memory buffer */
-        p_pic->planes[ RGB_PLANE ].p_data = malloc( i_luma_bytes );
-        p_pic->planes[ RGB_PLANE ].i_bytes = i_luma_bytes;
+        p_pic->p_data = memalign( 16, i_width * i_height * 2 );
+
+        /* Fill important structures */
+        p_pic->p->p_pixels = p_pic->p_data;
+        p_pic->p->i_lines = i_height;
+        p_pic->p->i_pitch = i_width;
+        p_pic->p->i_pixel_bytes = 2;
+        p_pic->p->b_margin = 0;
+        p_pic->p->i_red_mask   = 0xf800;
+        p_pic->p->i_green_mask = 0x07e0;
+        p_pic->p->i_blue_mask  = 0x001f;
 
         /* We allocated 1 plane */
         p_pic->i_planes = 1;
 
         return( 0 );
         break;
+
+    default:
+        p_pic->i_planes = 0;
+        return( 0 );
+        break;
     }
 }