[vlc-devel] commit: Added support for palettized RGB (RGBP) (Laurent Aimar )

git version control git at videolan.org
Sun Sep 7 15:03:48 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Sep  6 13:03:50 2008 +0200| [27f77b04b0c204629e5cac253f164a1816a718f1] | committer: Laurent Aimar 

Added support for palettized RGB (RGBP)

SwScaler uses a really ugly hack to transmit the palette.

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

 modules/video_filter/swscale.c   |   20 +++++++++++++++++---
 src/video_output/vout_pictures.c |   12 ++++++++++++
 src/video_output/vout_pictures.h |    4 ++++
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/modules/video_filter/swscale.c b/modules/video_filter/swscale.c
index bbe07fe..3cc5236 100644
--- a/modules/video_filter/swscale.c
+++ b/modules/video_filter/swscale.c
@@ -43,6 +43,8 @@
 /* Gruikkkkkkkkkk!!!!! */
 #include "../codec/avcodec/chroma.h"
 
+#define AVPALETTE_SIZE (256 * sizeof(uint32_t))
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -490,13 +492,25 @@ static void CopyPad( picture_t *p_dst, const picture_t *p_src )
     }
 }
 
-static void Convert( struct SwsContext *ctx,
+static void Convert( filter_t *p_filter, struct SwsContext *ctx,
                      picture_t *p_dst, picture_t *p_src, int i_height, int i_plane_start, int i_plane_count )
 {
+    uint8_t palette[AVPALETTE_SIZE];
+
     uint8_t *src[3]; int src_stride[3];
     uint8_t *dst[3]; int dst_stride[3];
 
     GetPixels( src, src_stride, p_src, i_plane_start, i_plane_count );
+    if( p_filter->fmt_in.video.i_chroma == VLC_FOURCC( 'R', 'G', 'B', 'P' ) )
+    {
+        memset( palette, 0, sizeof(palette) );
+        if( p_filter->fmt_in.video.p_palette )
+            memcpy( palette, p_filter->fmt_in.video.p_palette->palette,
+                    __MIN( sizeof(video_palette_t), AVPALETTE_SIZE ) );
+        src[1] = palette;
+        src_stride[1] = 4;
+    }
+
     GetPixels( dst, dst_stride, p_dst, i_plane_start, i_plane_count );
 
 #if LIBSWSCALE_VERSION_INT  >= ((0<<16)+(5<<8)+0)
@@ -549,7 +563,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
     if( p_sys->b_copy )
         picture_CopyPixels( p_dst, p_src );
     else
-        Convert( p_sys->ctx, p_dst, p_src, p_fmti->i_height, 0, 3 );
+        Convert( p_filter, p_sys->ctx, p_dst, p_src, p_fmti->i_height, 0, 3 );
     if( p_sys->ctxA )
     {
         /* We extract the A plane to rescale it, and then we reinject it. */
@@ -558,7 +572,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         else
             plane_CopyPixels( p_sys->p_src_a->p, p_src->p+A_PLANE );
 
-        Convert( p_sys->ctxA, p_sys->p_dst_a, p_sys->p_src_a, p_fmti->i_height, 0, 1 );
+        Convert( p_filter, p_sys->ctxA, p_sys->p_dst_a, p_sys->p_src_a, p_fmti->i_height, 0, 1 );
         if( p_fmto->i_chroma == VLC_FOURCC( 'R', 'G', 'B', 'A' ) )
             InjectA( p_dst, p_sys->p_dst_a, p_fmto->i_width * p_sys->i_extend_factor, p_fmto->i_height );
         else
diff --git a/src/video_output/vout_pictures.c b/src/video_output/vout_pictures.c
index f08f193..d0e124e 100644
--- a/src/video_output/vout_pictures.c
+++ b/src/video_output/vout_pictures.c
@@ -645,6 +645,7 @@ void vout_InitFormat( video_frame_format_t *p_format, vlc_fourcc_t i_chroma,
         case FOURCC_GREY:
         case FOURCC_Y800:
         case FOURCC_Y8:
+        case FOURCC_RGBP:
             p_format->i_bits_per_pixel = 8;
             break;
 
@@ -897,6 +898,7 @@ int __vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,
         case FOURCC_GREY:
         case FOURCC_Y800:
         case FOURCC_Y8:
+        case FOURCC_RGBP:
             p_pic->p->i_lines = i_height_aligned;
             p_pic->p->i_visible_lines = i_height;
             p_pic->p->i_pitch = i_width_aligned;
@@ -987,6 +989,16 @@ int vout_ChromaCmp( vlc_fourcc_t i_chroma, vlc_fourcc_t i_amorhc )
                     return 0;
             }
 
+        case FOURCC_RGBP:
+            switch( i_amorhc )
+            {
+                case FOURCC_RGBP:
+                    return 1;
+
+                default:
+                    return 0;
+            }
+
         default:
             return 0;
     }
diff --git a/src/video_output/vout_pictures.h b/src/video_output/vout_pictures.h
index 456f310..8cfc892 100644
--- a/src/video_output/vout_pictures.h
+++ b/src/video_output/vout_pictures.h
@@ -104,6 +104,10 @@
 /* Palettized YUV with palette element Y:U:V:A */
 #define FOURCC_YUVP         VLC_FOURCC('Y','U','V','P')
 
+/* Palettized RGB with palette element R:G:B */
+#define FOURCC_RGBP         VLC_FOURCC('R','G','B','P')
+
+
 /* Planar 8-bit grayscale */
 #define FOURCC_GREY         VLC_FOURCC('G','R','E','Y')
 #define FOURCC_Y800         VLC_FOURCC('Y','8','0','0')




More information about the vlc-devel mailing list