[vlc-commits] yuvp: Merge RGBA and ARGB code

Hugo Beauzée-Luyssen git at videolan.org
Fri Feb 3 12:51:52 CET 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Feb  3 12:48:59 2017 +0100| [2326b733f5f5909caabefa48fd602fe887d8f1ea] | committer: Hugo Beauzée-Luyssen

yuvp: Merge RGBA and ARGB code

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

 modules/video_chroma/yuvp.c | 53 +++++++++++----------------------------------
 1 file changed, 13 insertions(+), 40 deletions(-)

diff --git a/modules/video_chroma/yuvp.c b/modules/video_chroma/yuvp.c
index cecb13d..af66d6a 100644
--- a/modules/video_chroma/yuvp.c
+++ b/modules/video_chroma/yuvp.c
@@ -141,56 +141,29 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
             }
         }
     }
-    else if( p_filter->fmt_out.video.i_chroma == VLC_CODEC_RGBA )
-    {
-        video_palette_t rgbp;
-
-        /* Create a RGBA palette */
-        rgbp.i_entries = p_yuvp->i_entries;
-        for( int i = 0; i < p_yuvp->i_entries; i++ )
-        {
-            Yuv2Rgb( &rgbp.palette[i][0], &rgbp.palette[i][1], &rgbp.palette[i][2],
-                     p_yuvp->palette[i][0], p_yuvp->palette[i][1], p_yuvp->palette[i][2] );
-            rgbp.palette[i][3] = p_yuvp->palette[i][3];
-        }
-
-        for( unsigned int y = 0; y < p_filter->fmt_in.video.i_height; y++ )
-        {
-            const uint8_t *p_line = &p_pic->p->p_pixels[y*p_pic->p->i_pitch];
-            uint8_t *p_rgba = &p_out->p->p_pixels[y*p_out->p->i_pitch];
-
-            for( unsigned int x = 0; x < p_filter->fmt_in.video.i_width; x++ )
-            {
-                const int v = p_line[x];
-
-                if( v >= rgbp.i_entries )  /* maybe assert ? */
-                    continue;
-
-                p_rgba[4*x+0] = rgbp.palette[v][0];
-                p_rgba[4*x+1] = rgbp.palette[v][1];
-                p_rgba[4*x+2] = rgbp.palette[v][2];
-                p_rgba[4*x+3] = rgbp.palette[v][3];
-            }
-        }
-    }
     else
     {
         video_palette_t rgbp;
 
-        assert( p_filter->fmt_out.video.i_chroma == VLC_CODEC_ARGB );
+        assert( p_filter->fmt_out.video.i_chroma == VLC_CODEC_ARGB ||
+                p_filter->fmt_out.video.i_chroma == VLC_CODEC_RGBA );
         /* Create a RGBA palette */
         rgbp.i_entries = p_yuvp->i_entries;
+        const uint8_t r = p_filter->fmt_out.video.i_chroma == VLC_CODEC_ARGB ? 1 : 0;
+        const uint8_t g = p_filter->fmt_out.video.i_chroma == VLC_CODEC_ARGB ? 2 : 1;
+        const uint8_t b = p_filter->fmt_out.video.i_chroma == VLC_CODEC_ARGB ? 3 : 2;
+        const uint8_t a = p_filter->fmt_out.video.i_chroma == VLC_CODEC_ARGB ? 0 : 3;
         for( int i = 0; i < p_yuvp->i_entries; i++ )
         {
-            Yuv2Rgb( &rgbp.palette[i][1], &rgbp.palette[i][2], &rgbp.palette[i][3],
+            Yuv2Rgb( &rgbp.palette[i][r], &rgbp.palette[i][g], &rgbp.palette[i][b],
                      p_yuvp->palette[i][0], p_yuvp->palette[i][1], p_yuvp->palette[i][2] );
-            rgbp.palette[i][0] = p_yuvp->palette[i][3];
+            rgbp.palette[i][a] = p_yuvp->palette[i][3];
         }
 
         for( unsigned int y = 0; y < p_filter->fmt_in.video.i_height; y++ )
         {
             const uint8_t *p_line = &p_pic->p->p_pixels[y*p_pic->p->i_pitch];
-            uint8_t *p_rgba = &p_out->p->p_pixels[y*p_out->p->i_pitch];
+            uint8_t *p_pixels = &p_out->p->p_pixels[y*p_out->p->i_pitch];
 
             for( unsigned int x = 0; x < p_filter->fmt_in.video.i_width; x++ )
             {
@@ -199,10 +172,10 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
                 if( v >= rgbp.i_entries )  /* maybe assert ? */
                     continue;
 
-                p_rgba[4*x+0] = rgbp.palette[v][0];
-                p_rgba[4*x+1] = rgbp.palette[v][1];
-                p_rgba[4*x+2] = rgbp.palette[v][2];
-                p_rgba[4*x+3] = rgbp.palette[v][3];
+                p_pixels[4*x+0] = rgbp.palette[v][0];
+                p_pixels[4*x+1] = rgbp.palette[v][1];
+                p_pixels[4*x+2] = rgbp.palette[v][2];
+                p_pixels[4*x+3] = rgbp.palette[v][3];
             }
         }
 



More information about the vlc-commits mailing list