[vlc-devel] commit: Factorize and correctly set rgb shifts. (Laurent Aimar )

git version control git at videolan.org
Wed Aug 20 23:10:23 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Aug 20 23:09:19 2008 +0200| [35a248f1ac6304b1a9931eaee786f36b224a92f9] | committer: Laurent Aimar 

Factorize and correctly set rgb shifts.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=35a248f1ac6304b1a9931eaee786f36b224a92f9
---

 src/video_output/video_output.c |   66 ++++++++++++++++++++++----------------
 1 files changed, 38 insertions(+), 28 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 54fd9e8..880067a 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -72,6 +72,9 @@ static void     AspectRatio       ( int, int *, int * );
 static int      BinaryLog         ( uint32_t );
 static void     MaskToShift       ( int *, int *, uint32_t );
 
+static void VideoFormatImportRgb( video_format_t *, picture_heap_t * );
+static void PictureHeapFixRgb( picture_heap_t * );
+
 static void     vout_Destructor   ( vlc_object_t * p_this );
 
 /* Object variables callbacks */
@@ -601,20 +604,13 @@ static int InitThread( vout_thread_t *p_vout )
              i_aspect_x, i_aspect_y,
              p_vout->fmt_out.i_sar_num, p_vout->fmt_out.i_sar_den );
 
+    /* FIXME removed the need of both fmt_* and heap infos */
     /* Calculate shifts from system-updated masks */
-    MaskToShift( &p_vout->render.i_lrshift, &p_vout->output.i_rrshift,
-                 p_vout->render.i_rmask );
-    MaskToShift( &p_vout->render.i_lgshift, &p_vout->output.i_rgshift,
-                 p_vout->render.i_gmask );
-    MaskToShift( &p_vout->render.i_lbshift, &p_vout->output.i_rbshift,
-                 p_vout->render.i_bmask );
-
-    MaskToShift( &p_vout->output.i_lrshift, &p_vout->output.i_rrshift,
-                 p_vout->output.i_rmask );
-    MaskToShift( &p_vout->output.i_lgshift, &p_vout->output.i_rgshift,
-                 p_vout->output.i_gmask );
-    MaskToShift( &p_vout->output.i_lbshift, &p_vout->output.i_rbshift,
-                 p_vout->output.i_bmask );
+    PictureHeapFixRgb( &p_vout->render );
+    VideoFormatImportRgb( &p_vout->fmt_render, &p_vout->render );
+
+    PictureHeapFixRgb( &p_vout->output );
+    VideoFormatImportRgb( &p_vout->fmt_out, &p_vout->output );
 
     /* Check whether we managed to create direct buffers similar to
      * the render buffers, ie same size and chroma */
@@ -1203,19 +1199,6 @@ static picture_t *ChromaGetPicture( filter_t *p_filter )
     return p_pic;
 }
 
-static void ChromaCopyRgbInfo( es_format_t *p_fmt, picture_heap_t *p_heap )
-{
-    p_fmt->video.i_rmask = p_heap->i_rmask;
-    p_fmt->video.i_gmask = p_heap->i_gmask;
-    p_fmt->video.i_bmask = p_heap->i_bmask;
-    p_fmt->video.i_rrshift = p_heap->i_rrshift;
-    p_fmt->video.i_lrshift = p_heap->i_lrshift;
-    p_fmt->video.i_rgshift = p_heap->i_rgshift;
-    p_fmt->video.i_lgshift = p_heap->i_lgshift;
-    p_fmt->video.i_rbshift = p_heap->i_rbshift;
-    p_fmt->video.i_lbshift = p_heap->i_lbshift;
-}
-
 static int ChromaCreate( vout_thread_t *p_vout )
 {
     static const char typename[] = "chroma";
@@ -1231,8 +1214,8 @@ static int ChromaCreate( vout_thread_t *p_vout )
     /* TODO: Set the fmt_in and fmt_out stuff here */
     p_chroma->fmt_in.video = p_vout->fmt_render;
     p_chroma->fmt_out.video = p_vout->fmt_out;
-    ChromaCopyRgbInfo( &p_chroma->fmt_in, &p_vout->render );
-    ChromaCopyRgbInfo( &p_chroma->fmt_out, &p_vout->output );
+    VideoFormatImportRgb( &p_chroma->fmt_in.video, &p_vout->render );
+    VideoFormatImportRgb( &p_chroma->fmt_out.video, &p_vout->output );
 
     p_chroma->p_module = module_Need( p_chroma, "video filter2", NULL, 0 );
 
@@ -1381,6 +1364,33 @@ static void MaskToShift( int *pi_left, int *pi_right, uint32_t i_mask )
     *pi_right = (8 - i_high + i_low);
 }
 
+/**
+ * This function copies all RGB informations from a picture_heap_t into
+ * a video_format_t
+ */
+static void VideoFormatImportRgb( video_format_t *p_fmt, picture_heap_t *p_heap )
+{
+    p_fmt->i_rmask = p_heap->i_rmask;
+    p_fmt->i_gmask = p_heap->i_gmask;
+    p_fmt->i_bmask = p_heap->i_bmask;
+    p_fmt->i_rrshift = p_heap->i_rrshift;
+    p_fmt->i_lrshift = p_heap->i_lrshift;
+    p_fmt->i_rgshift = p_heap->i_rgshift;
+    p_fmt->i_lgshift = p_heap->i_lgshift;
+    p_fmt->i_rbshift = p_heap->i_rbshift;
+    p_fmt->i_lbshift = p_heap->i_lbshift;
+}
+
+/**
+ * This function computes rgb shifts from masks
+ */
+static void PictureHeapFixRgb( picture_heap_t *p_heap )
+{
+    MaskToShift( &p_heap->i_lrshift, &p_heap->i_rrshift, p_heap->i_rmask );
+    MaskToShift( &p_heap->i_lgshift, &p_heap->i_rgshift, p_heap->i_gmask );
+    MaskToShift( &p_heap->i_lbshift, &p_heap->i_rbshift, p_heap->i_bmask );
+}
+
 /*****************************************************************************
  * Helper thread for object variables callbacks.
  * Only used to avoid deadlocks when using the video embedded mode.




More information about the vlc-devel mailing list