[vlc-devel] [PATCH] aom: encoder: sync profiles with spec and make bit depth configurable

Tristan Matthews tmatth at videolan.org
Sat Apr 7 16:37:03 CEST 2018


---
 modules/codec/aom.c | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/modules/codec/aom.c b/modules/codec/aom.c
index 11252f8ddd..6e69f56f13 100644
--- a/modules/codec/aom.c
+++ b/modules/codec/aom.c
@@ -71,6 +71,8 @@ vlc_module_begin ()
         set_callbacks(OpenEncoder, CloseEncoder)
         add_integer( SOUT_CFG_PREFIX "profile", 0, "Profile", NULL, true )
             change_integer_range( 0, 3 )
+        add_integer( SOUT_CFG_PREFIX "bitdepth", 8, "Bit Depth", NULL, true )
+            change_integer_range( 8, 13 )
 #endif
 vlc_module_end ()
 
@@ -363,26 +365,38 @@ static int OpenEncoder(vlc_object_t *p_this)
 
     int enc_flags;
     int i_profile = var_InheritInteger( p_enc, SOUT_CFG_PREFIX "profile" );
+    int i_bit_depth = var_InheritInteger( p_enc, SOUT_CFG_PREFIX "bitdepth" );
+
+    /* TODO: implement higher profiles, bit depths and other pixformats. */
     switch( i_profile )
     {
         case 0:
-            p_enc->fmt_in.i_codec = VLC_CODEC_I420;
-            enc_flags = 0;
-            /* Profile 0: 8-bit 4:2:0 only. */
+            /* Main Profile: 8 and 10-bit 4:2:0. */
             enccfg.g_profile = 0;
-            enccfg.g_bit_depth = 8;
-            break;
-
-        case 2:
-            p_enc->fmt_in.i_codec = VLC_CODEC_I420_10L;
-            enc_flags = AOM_CODEC_USE_HIGHBITDEPTH;
-            /* Profile 2: 10-bit and 12-bit color only, with 4:2:0 sampling. */
-            enccfg.g_profile = 2;
-            enccfg.g_bit_depth = 10;
+            switch( i_bit_depth )
+            {
+                case 10:
+                    p_enc->fmt_in.i_codec = VLC_CODEC_I420_10L;
+                    enc_flags = AOM_CODEC_USE_HIGHBITDEPTH;
+                    break;
+                case 8:
+                    p_enc->fmt_in.i_codec = VLC_CODEC_I420;
+                    enc_flags = 0;
+                    break;
+                default:
+                    msg_Err( p_enc, "%d bit is unsupported for profile %d", i_bit_depth, i_profile );
+                    free( p_sys );
+                    return VLC_EGENERIC;
+            }
+            enccfg.g_bit_depth = i_bit_depth;
             break;
 
         case 1:
-        case 3:
+            /* High Profile: 8 and 10-bit 4:4:4 */
+            /* fallthrough */
+        case 2:
+            /* Professional Profile: 8, 10 and 12-bit for 4:2:2, otherwise 12-bit. */
+            /* fallthrough */
         default:
             msg_Err( p_enc, "Unsupported profile %d", i_profile );
             free( p_sys );
-- 
2.14.1



More information about the vlc-devel mailing list