[x264-devel] Add support for RGB formats in bit-depth conversion filter

Anton Mitrofanov git at videolan.org
Tue May 22 23:56:14 CEST 2012


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Fri May  4 17:18:12 2012 +0400| [ecfbf9d8025e39783bc4262dc1972ca742d8a993] | committer: Jason Garrett-Glaser

Add support for RGB formats in bit-depth conversion filter

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=ecfbf9d8025e39783bc4262dc1972ca742d8a993
---

 filters/video/depth.c |   31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/filters/video/depth.c b/filters/video/depth.c
index e01aaae..9465f17 100644
--- a/filters/video/depth.c
+++ b/filters/video/depth.c
@@ -50,13 +50,19 @@ static int depth_filter_csp_is_supported( int csp )
            csp_mask == X264_CSP_YV16 ||
            csp_mask == X264_CSP_YV24 ||
            csp_mask == X264_CSP_NV12 ||
-           csp_mask == X264_CSP_NV16;
+           csp_mask == X264_CSP_NV16 ||
+           csp_mask == X264_CSP_BGR ||
+           csp_mask == X264_CSP_RGB ||
+           csp_mask == X264_CSP_BGRA;
 }
 
 static int csp_num_interleaved( int csp, int plane )
 {
     int csp_mask = csp & X264_CSP_MASK;
-    return ( (csp_mask == X264_CSP_NV12 || csp_mask == X264_CSP_NV16) && plane == 1 ) ? 2 : 1;
+    return (csp_mask == X264_CSP_NV12 || csp_mask == X264_CSP_NV16) && plane == 1 ? 2 :
+           csp_mask == X264_CSP_BGR || csp_mask == X264_CSP_RGB ? 3 :
+           csp_mask == X264_CSP_BGRA ? 4 :
+           1;
 }
 
 /* The dithering algorithm is based on Sierra-2-4A error diffusion. It has been
@@ -86,6 +92,8 @@ static void dither_plane_##pitch( pixel *dst, int dst_stride, uint16_t *src, int
 
 DITHER_PLANE( 1 )
 DITHER_PLANE( 2 )
+DITHER_PLANE( 3 )
+DITHER_PLANE( 4 )
 
 static void dither_image( cli_image_t *out, cli_image_t *img, int16_t *error_buf )
 {
@@ -100,15 +108,28 @@ static void dither_image( cli_image_t *out, cli_image_t *img, int16_t *error_buf
         dither_plane_##pitch( ((pixel*)out->plane[i])+off, out->stride[i]/sizeof(pixel), \
                 ((uint16_t*)img->plane[i])+off, img->stride[i]/2, width, height, error_buf )
 
-        if( num_interleaved == 1 )
+        if( num_interleaved == 4 )
         {
-            CALL_DITHER_PLANE( 1, 0 );
+            CALL_DITHER_PLANE( 4, 0 );
+            CALL_DITHER_PLANE( 4, 1 );
+            CALL_DITHER_PLANE( 4, 2 );
+            CALL_DITHER_PLANE( 4, 3 ); //we probably can skip this one
         }
-        else
+        else if( num_interleaved == 3 )
+        {
+            CALL_DITHER_PLANE( 3, 0 );
+            CALL_DITHER_PLANE( 3, 1 );
+            CALL_DITHER_PLANE( 3, 2 );
+        }
+        else if( num_interleaved == 2 )
         {
             CALL_DITHER_PLANE( 2, 0 );
             CALL_DITHER_PLANE( 2, 1 );
         }
+        else //if( num_interleaved == 1 )
+        {
+            CALL_DITHER_PLANE( 1, 0 );
+        }
     }
 }
 



More information about the x264-devel mailing list