[vlc-commits] x264: do colorspace/transfer/primaries mapping

Ilkka Ollakka git at videolan.org
Sun Apr 17 10:57:03 CEST 2016


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sat Apr 16 16:24:13 2016 +0300| [b79c56d8d9da472031fee18c4d1faf18e76b1ed9] | committer: Ilkka Ollakka

x264: do colorspace/transfer/primaries mapping

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

 modules/codec/x264.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/modules/codec/x264.c b/modules/codec/x264.c
index 48c58b5..321cfdc 100644
--- a/modules/codec/x264.c
+++ b/modules/codec/x264.c
@@ -842,6 +842,7 @@ static int  Open ( vlc_object_t *p_this )
         return VLC_ENOMEM;
 
     fullrange = var_GetBool( p_enc, SOUT_CFG_PREFIX "fullrange" );
+    fullrange |= p_enc->fmt_in.video.b_color_range_full;
     p_enc->fmt_in.i_codec = fullrange ? VLC_CODEC_J420 : VLC_CODEC_I420;
     p_sys->i_colorspace = X264_CSP_I420;
 #if X264_BUILD >= 118
@@ -922,6 +923,53 @@ static int  Open ( vlc_object_t *p_this )
     p_sys->param.i_height = p_enc->fmt_in.video.i_visible_height;
     p_sys->param.vui.b_fullrange = fullrange;
 
+    switch( p_enc->fmt_in.video.space )
+    {
+        case COLOR_SPACE_BT601:
+            p_sys->param.vui.i_colmatrix = 5; /* bt470bg*/
+            break;
+        case COLOR_SPACE_BT709:
+            p_sys->param.vui.i_colmatrix = 1; /* bt709*/
+            break;
+        case COLOR_SPACE_BT2020:
+            p_sys->param.vui.i_colmatrix = 10; /* bt2020c*/
+            break;
+        default:
+            break;
+    }
+
+    switch( p_enc->fmt_in.video.transfer )
+    {
+        case TRANSFER_FUNC_LINEAR:
+            p_sys->param.vui.i_transfer = 7; /* linear*/
+            break;
+        case TRANSFER_FUNC_SRGB:
+        case TRANSFER_FUNC_BT709:
+            p_sys->param.vui.i_transfer = 1; /* bt709*/
+            break;
+        default:
+            break;
+    }
+
+    switch( p_enc->fmt_in.video.primaries )
+    {
+        case COLOR_PRIMARIES_BT601_625:
+            p_sys->param.vui.i_colorprim = 5; /* BT470BG */
+            break;
+        case COLOR_PRIMARIES_BT601_525:
+            p_sys->param.vui.i_colorprim = 6; /* SMPTE170M */
+            break;
+        case COLOR_PRIMARIES_BT709:
+            p_sys->param.vui.i_colorprim = 1; /* BT.709 */
+            break;
+        case COLOR_PRIMARIES_BT2020:
+            p_sys->param.vui.i_colorprim = 9; /* BT.2020 */
+            break;
+        default:
+            break;
+    }
+
+
     if( fabs(var_GetFloat( p_enc, SOUT_CFG_PREFIX "qcomp" ) - 0.60) > 0.005 )
        p_sys->param.rc.f_qcompress = var_GetFloat( p_enc, SOUT_CFG_PREFIX "qcomp" );
 



More information about the vlc-commits mailing list