changeset 12597:a62d540af8b8 Release_3.1

Fix x265 SVT integration This patch does the following. - Fix error for newly added param variables and other default variables - Remove EbTime.h file as its no longer present in include directory of SVT - Set SVT-HEVC lib version required to 1.4.1 - Modify doc page
author snehaa@multicorewareinc.com
date Wed, 11 Dec 2019 16:11:24 +0530
parents 2db562627201
children 37fffabeb841
files doc/reST/cli.rst doc/reST/svthevc.rst source/CMakeLists.txt source/cmake/Findsvthevc.cmake source/common/param.cpp source/encoder/svt.h
diffstat 6 files changed, 94 insertions(+-), 102 deletions(-) [+]
line wrap: on
line diff
--- a/doc/reST/cli.rst	Mon Dec 23 14:40:32 2019 +0530
+++ b/doc/reST/cli.rst	Wed Dec 11 16:11:24 2019 +0530
@@ -2451,12 +2451,12 @@ See section :ref:`svthevc <SvtHevc>` for
 
 .. option:: --svt-preset-tuner <integer>
 
-    SVT-HEVC exposes 13 presets. Presets [3-12] of SVT-HEVC is mapped to x265's
-    presets [placebo-ultrafast]. Ultrafast is mapped to preset(12) of SVT-HEVC,
-    superfast to preset(11), placebo to preset(3) and so on. svt-preset-tuner works
-    only on top of placebo preset and maps to presets (0-2) of SVT-HEVC.
-
-    Values: [0-2]
+    SVT-HEVC exposes 12 presets. Presets [2-11] of SVT-HEVC is mapped to x265's
+    presets [placebo-ultrafast]. Ultrafast is mapped to preset(11) of SVT-HEVC,
+    superfast to preset(10), placebo to preset(2) and so on. svt-preset-tuner works
+    only on top of placebo preset and maps to presets (0-1) of SVT-HEVC.
+
+    Values: [0-1]
 
     **CLI_ONLY**
 
--- a/doc/reST/svthevc.rst	Mon Dec 23 14:40:32 2019 +0530
+++ b/doc/reST/svthevc.rst	Wed Dec 11 16:11:24 2019 +0530
@@ -12,6 +12,10 @@ API should be used for all param assignm
 wont't be mapped to SVT-HEVC. This document describes the steps needed to compile x265 
 with SVT-HEVC and CLI options mapping between x265 and SVT-HEVC.
 
+Supported Version
+=================
+Version - 1.4.1
+
 Build Steps
 ===========
 This section describes the build steps to be followed to link SVT-HEVC with x265.
@@ -109,7 +113,15 @@ SVT-HEVC encoder options (Name as shown 
 +-------------------------------------------+------------------------------+------------------------------+
 | :option:`--nalu-file`                     | NaluFile                     | Any String                   |
 +-------------------------------------------+------------------------------+------------------------------+
-| :option:`--tune` zerolatency              | LatencyMode                  |                              |
+| :option:`--hrd`                           | hrdFlag                      | [0, 1]                       |
++-------------------------------------------+------------------------------+------------------------------+
+| :option:`--vbv-maxrate`                   | vbvMaxrate                   | Any Positive Integer         |
++-------------------------------------------+------------------------------+------------------------------+
+| :option:`--vbv-bufsize`                   | vbvBufsize                   | Any Positive Integer         |
++-------------------------------------------+------------------------------+------------------------------+
+| :option:`--vbv-init`                      | VbvBufInit                   | [0 - 100]                    |
++-------------------------------------------+------------------------------+------------------------------+
+| :option:`--frame-threads`                 | ThreadCount                  | Any Number                   |
 +-------------------------------------------+------------------------------+------------------------------+
 | :option:`--svt-search-width`              | SearchAreaWidth              | [1 - 256]                    |
 +-------------------------------------------+------------------------------+------------------------------+
@@ -139,64 +151,37 @@ section in the above table. Options star
 fecilitate access to the features of SVT-HEVC which couldn't be mapped to the existing x265 CLI's. 
 So these options will have effect only if SVT-HEVC is enabled and would be ignored with default x265 encode.
 
-Preset & Tune Options Mapping
+Preset Option Mapping
 =============================
-x265 has 10 presets from ultrafast to placebo whereas SVT-HEVC has 13 presets. Use :option:`--svt-preset-tuner` 
-with Placebo preset to access the additional 3 presets of SVT-HEVC. Note that :option:`--svt-preset-tuner` should be 
+x265 has 10 presets from ultrafast to placebo whereas SVT-HEVC has 12 presets. Use :option:`--svt-preset-tuner` 
+with Placebo preset to access the additional 2 presets of SVT-HEVC. Note that :option:`--svt-preset-tuner` should be 
 used only if SVT-HEVC is enabled and only with Placebo preset, would be ignored otherwise. 
 Below table shows the actual mapping of presets,
 
 +----------------------------------------+------------------------------+
 | x265 Preset                            | SVT-HEVC Preset              |
 +========================================+==============================+
-| Ultrafast                              | 12                           |
-+----------------------------------------+------------------------------+
-| Superfast                              | 11                           |
-+----------------------------------------+------------------------------+
-| Veryfast                               | 10                           |
-+----------------------------------------+------------------------------+
-| Faster                                 | 9                            |
+| Ultrafast                              | 11                           |
 +----------------------------------------+------------------------------+
-| Fast                                   | 8                            |
-+----------------------------------------+------------------------------+
-| Medium                                 | 7                            |
+| Superfast                              | 10                           |
 +----------------------------------------+------------------------------+
-| Slow                                   | 6                            |
+| Veryfast                               | 9                            |
 +----------------------------------------+------------------------------+
-| Slower                                 | 5                            |
+| Faster                                 | 8                            |
 +----------------------------------------+------------------------------+
-| Veryslow                               | 4                            |
+| Fast                                   | 7                            |
 +----------------------------------------+------------------------------+
-| Placebo                                | 3                            |
+| Medium                                 | 6                            |
++----------------------------------------+------------------------------+
+| Slow                                   | 5                            |
++----------------------------------------+------------------------------+
+| Slower                                 | 4                            |
++----------------------------------------+------------------------------+
+| Veryslow                               | 3                            |
++----------------------------------------+------------------------------+
+| Placebo                                | 2                            |
 +----------------------------------------+------------------------------+
 | Placebo :option:`--svt-preset-tuner` 0 | 0                            |
 +----------------------------------------+------------------------------+
 | Placebo :option:`--svt-preset-tuner` 1 | 1                            |
 +----------------------------------------+------------------------------+
-| Placebo :option:`--svt-preset-tuner` 2 | 2                            |
-+----------------------------------------+------------------------------+
-
-x265 has 5 tune modes (psnr, ssim, grain, zero-latency, animation) whereas SVT-HEVC
-has only 3 tune modes (0 - visual quality, 1 - PSNR / SSIM and 2 - VMAF). Below 
-table shows the mapping of tune modes,
-
-+-----------------------+---------------------------+
-| x265 Tune Modes       | SVT-HEVC Tune Modes       |
-+=======================+===========================+
-| vmaf                  | 2                         |
-+-----------------------+---------------------------+
-| psnr                  | 1                         |
-+-----------------------+---------------------------+
-| ssim                  | 1                         |
-+-----------------------+---------------------------+
-| grain                 | 0                         |
-+-----------------------+---------------------------+
-| fastdecode            | 0                         |
-+-----------------------+---------------------------+
-| zerolatency           | 0                         |
-+-----------------------+---------------------------+
-| animation             | 0                         |
-+-----------------------+---------------------------+
-
-Note that : 1.option:`--tune` animation is also mapped to "LatencyMode" of SVT-HEVC.
-            2.option: '--tune' vmaf is not supported in x265, its under development.
--- a/source/CMakeLists.txt	Mon Dec 23 14:40:32 2019 +0530
+++ b/source/CMakeLists.txt	Wed Dec 11 16:11:24 2019 +0530
@@ -573,7 +573,6 @@ endif()
 if(SVTHEVC_FOUND)
     install(FILES "${SVT_HEVC_INCLUDE_DIR}/EbApi.h" DESTINATION include)
     install(FILES "${SVT_HEVC_INCLUDE_DIR}/EbErrorCodes.h" DESTINATION include)
-    install(FILES "${SVT_HEVC_INCLUDE_DIR}/EbTime.h" DESTINATION include)
     install(FILES "${SVT_HEVC_LIBRARY}" DESTINATION ${BIN_INSTALL_DIR})
 endif()
 
--- a/source/cmake/Findsvthevc.cmake	Mon Dec 23 14:40:32 2019 +0530
+++ b/source/cmake/Findsvthevc.cmake	Wed Dec 11 16:11:24 2019 +0530
@@ -15,34 +15,37 @@ else()
 SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
 endif()
 
-set(SVT_VERSION_MAJOR_REQUIRED 1)
-set(SVT_VERSION_MINOR_REQUIRED 3)
-set(SVT_VERSION_PATCHLEVEL_REQUIRED 0)
+set(SVT_VERSION_MAJOR_REQUIRED       1)
+set(SVT_VERSION_MINOR_REQUIRED       4)
+set(SVT_VERSION_PATCHLEVEL_REQUIRED  1)
 
 find_path(SVT_HEVC_INCLUDE_DIR
-    NAMES EbApi.h EbErrorCodes.h EbTime.h
+    NAMES EbApiVersion.h EbErrorCodes.h
     HINTS $ENV{SVT_HEVC_INCLUDE_DIR}
     PATHS ENV
     DOC "SVT-HEVC include directory")
 
 if(SVT_HEVC_INCLUDE_DIR)
-file(READ "${SVT_HEVC_INCLUDE_DIR}/EbApi.h" version)
-
-string(REGEX MATCH "SVT_VERSION_MAJOR       ([0-9]*)" _ ${version})
-set(SVT_VERSION_MAJOR ${CMAKE_MATCH_1})
-
-string(REGEX MATCH "SVT_VERSION_MINOR       ([0-9]*)" _ ${version})
-set(SVT_VERSION_MINOR ${CMAKE_MATCH_1})
+    if(EXISTS "${SVT_HEVC_INCLUDE_DIR}/EbApiVersion.h")
+        file(READ "${SVT_HEVC_INCLUDE_DIR}/EbApiVersion.h" version)
 
-string(REGEX MATCH "SVT_VERSION_PATCHLEVEL  ([0-9]*)" _ ${version})
-set(SVT_VERSION_PATCHLEVEL ${CMAKE_MATCH_1})
+        string(REGEX MATCH "SVT_VERSION_MAJOR       \\(([0-9]*)\\)" _ ${version})
+        set(SVT_VERSION_MAJOR ${CMAKE_MATCH_1})
 
-if(NOT ${SVT_VERSION_MAJOR} EQUAL "1" OR NOT ${SVT_VERSION_MINOR} EQUAL "3" OR NOT ${SVT_VERSION_PATCHLEVEL} EQUAL "0")
-    message (SEND_ERROR "-- Found SVT-HEVC Lib Version: ${SVT_VERSION_MAJOR}.${SVT_VERSION_MINOR}.${SVT_VERSION_PATCHLEVEL} which doesn't match the required version: ${SVT_VERSION_MAJOR_REQUIRED}.${SVT_VERSION_MINOR_REQUIRED}.${SVT_VERSION_PATCHLEVEL_REQUIRED}; Aborting configure  ")
-else()
-    message(STATUS "-- Found SVT-HEVC Lib Version: ${SVT_VERSION_MAJOR}.${SVT_VERSION_MINOR}.${SVT_VERSION_PATCHLEVEL}")
-endif()
+        string(REGEX MATCH "SVT_VERSION_MINOR       \\(([0-9]*)\\)" _ ${version})
+        set(SVT_VERSION_MINOR ${CMAKE_MATCH_1})
 
+        string(REGEX MATCH "SVT_VERSION_PATCHLEVEL  \\(([0-9]*)\\)" _ ${version})
+        set(SVT_VERSION_PATCHLEVEL ${CMAKE_MATCH_1})
+
+        if(NOT ${SVT_VERSION_MAJOR} EQUAL "1" OR NOT ${SVT_VERSION_MINOR} EQUAL "4" OR NOT ${SVT_VERSION_PATCHLEVEL} EQUAL "1")
+            message (SEND_ERROR "-- Found SVT-HEVC Lib Version: ${SVT_VERSION_MAJOR}.${SVT_VERSION_MINOR}.${SVT_VERSION_PATCHLEVEL} which doesn't match the required version: ${SVT_VERSION_MAJOR_REQUIRED}.${SVT_VERSION_MINOR_REQUIRED}.${SVT_VERSION_PATCHLEVEL_REQUIRED}; Aborting configure  ")
+        else()
+            message(STATUS "-- Found SVT-HEVC Lib Version: ${SVT_VERSION_MAJOR}.${SVT_VERSION_MINOR}.${SVT_VERSION_PATCHLEVEL}")
+        endif()
+    else()
+        message (SEND_ERROR "-- Required version of SVT-HEVC Lib: ${SVT_VERSION_MAJOR_REQUIRED}.${SVT_VERSION_MINOR_REQUIRED}.${SVT_VERSION_PATCHLEVEL_REQUIRED}; Aborting configure  ")
+    endif()
 endif()
 
 find_library(SVT_HEVC_LIBRARY
--- a/source/common/param.cpp	Mon Dec 23 14:40:32 2019 +0530
+++ b/source/common/param.cpp	Wed Dec 11 16:11:24 2019 +0530
@@ -594,7 +594,7 @@ int x265_param_default_preset(x265_param
     }
 
 #ifdef SVT_HEVC
-    if (svt_set_preset_tune(param, preset, tune))
+    if (svt_set_preset(param, preset))
         return -1;
 #endif
 
@@ -2422,8 +2422,8 @@ void svt_param_default(x265_param* param
     svtHevcParam->latencyMode = 0;
 
     //Preset & Tune
-    svtHevcParam->encMode = 9;
-    svtHevcParam->tune = 0;
+    svtHevcParam->encMode = 7;
+    svtHevcParam->tune = 1;
 
     // Interlaced Video 
     svtHevcParam->interlacedVideo = 0;
@@ -2463,10 +2463,10 @@ void svt_param_default(x265_param* param
     svtHevcParam->targetBitRate = 7000000;
     svtHevcParam->maxQpAllowed = 48;
     svtHevcParam->minQpAllowed = 10;
-    svtHevcParam->bitRateReduction = 1;
+    svtHevcParam->bitRateReduction = 0;
 
     // Thresholds
-    svtHevcParam->improveSharpness = 1;
+    svtHevcParam->improveSharpness = 0;
     svtHevcParam->videoUsabilityInfo = 0;
     svtHevcParam->highDynamicRangeInput = 0;
     svtHevcParam->accessUnitDelimiter = 0;
@@ -2476,7 +2476,7 @@ void svt_param_default(x265_param* param
     svtHevcParam->unregisteredUserDataSeiFlag = 0;
     svtHevcParam->recoveryPointSeiFlag = 0;
     svtHevcParam->enableTemporalId = 1;
-    svtHevcParam->profile = 2;
+    svtHevcParam->profile = 1;
     svtHevcParam->tier = 0;
     svtHevcParam->level = 0;
 
@@ -2507,34 +2507,31 @@ void svt_param_default(x265_param* param
     svtHevcParam->tileRowCount = 1;
     svtHevcParam->tileSliceMode = 0;
     svtHevcParam->unrestrictedMotionVector = 1;
+    svtHevcParam->threadCount = 0;
+
+    // vbv
+    svtHevcParam->hrdFlag = 0;
+    svtHevcParam->vbvMaxrate = 0;
+    svtHevcParam->vbvBufsize = 0;
+    svtHevcParam->vbvBufInit = 90;
 }
 
-int svt_set_preset_tune(x265_param* param, const char* preset, const char* tune)
+int svt_set_preset(x265_param* param, const char* preset)
 {
     EB_H265_ENC_CONFIGURATION* svtHevcParam = (EB_H265_ENC_CONFIGURATION*)param->svtHevcParam;
     
     if (preset)
     {
-        if (!strcmp(preset, "ultrafast")) svtHevcParam->encMode = 12;
-        else if (!strcmp(preset, "superfast")) svtHevcParam->encMode = 11;
-        else if (!strcmp(preset, "veryfast")) svtHevcParam->encMode = 10;
-        else if (!strcmp(preset, "faster")) svtHevcParam->encMode = 9;
-        else if (!strcmp(preset, "fast")) svtHevcParam->encMode = 8;
-        else if (!strcmp(preset, "medium")) svtHevcParam->encMode = 7;
-        else if (!strcmp(preset, "slow")) svtHevcParam->encMode = 6;
-        else if (!strcmp(preset, "slower")) svtHevcParam->encMode = 5;
-        else if (!strcmp(preset, "veryslow")) svtHevcParam->encMode = 4;
-        else if (!strcmp(preset, "placebo")) svtHevcParam->encMode = 3;
-        else  return -1;
-    }
-    if (tune)
-    {
-        if (!strcmp(tune, "psnr")) svtHevcParam->tune = 1;
-        else if (!strcmp(tune, "ssim")) svtHevcParam->tune = 1;
-        else if (!strcmp(tune, "grain")) svtHevcParam->tune = 0;
-        else if (!strcmp(tune, "animation")) svtHevcParam->tune = 0;
-        else if (!strcmp(tune, "vmaf")) svtHevcParam->tune = 2;
-        else if (!strcmp(tune, "zero-latency") || !strcmp(tune, "zerolatency")) svtHevcParam->latencyMode = 1;
+        if (!strcmp(preset, "ultrafast")) svtHevcParam->encMode = 11;
+        else if (!strcmp(preset, "superfast")) svtHevcParam->encMode = 10;
+        else if (!strcmp(preset, "veryfast")) svtHevcParam->encMode = 9;
+        else if (!strcmp(preset, "faster")) svtHevcParam->encMode = 8;
+        else if (!strcmp(preset, "fast")) svtHevcParam->encMode = 7;
+        else if (!strcmp(preset, "medium")) svtHevcParam->encMode = 6;
+        else if (!strcmp(preset, "slow")) svtHevcParam->encMode = 5;
+        else if (!strcmp(preset, "slower")) svtHevcParam->encMode =4;
+        else if (!strcmp(preset, "veryslow")) svtHevcParam->encMode = 3;
+        else if (!strcmp(preset, "placebo")) svtHevcParam->encMode = 2;
         else  return -1;
     }
     return 0;
@@ -2689,11 +2686,10 @@ int svt_param_parse(x265_param* param, c
     OPT("svt-speed-control") svtHevcParam->speedControlFlag = x265_atobool(value, bError);
     OPT("svt-preset-tuner")
     {
-        if (svtHevcParam->encMode == 3)
+        if (svtHevcParam->encMode == 2)
         {
             if (!strcmp(value, "0")) svtHevcParam->encMode = 0;
             else if (!strcmp(value, "1")) svtHevcParam->encMode = 1;
-            else if (!strcmp(value, "2")) svtHevcParam->encMode = 2;
             else
             {
                 x265_log(param, X265_LOG_ERROR, " Unsupported value=%s for svt-preset-tuner \n", value);
@@ -2719,6 +2715,16 @@ int svt_param_parse(x265_param* param, c
         else
             bError = true;
     }
+    OPT("hrd")
+        svtHevcParam->hrdFlag = (uint32_t)x265_atobool(value, bError);
+    OPT("vbv-maxrate")
+        svtHevcParam->vbvMaxrate = (uint32_t)x265_atoi(value, bError);
+    OPT("vbv-bufsize")
+        svtHevcParam->vbvBufsize = (uint32_t)x265_atoi(value, bError);
+    OPT("vbv-init")
+        svtHevcParam->vbvBufInit = (uint64_t)x265_atof(value, bError);
+    OPT("frame-threads")
+        svtHevcParam->threadCount = (uint32_t)x265_atoi(value, bError);
     else
         x265_log(param, X265_LOG_INFO, "SVT doesn't support %s param; Disabling it \n", name);
 
--- a/source/encoder/svt.h	Mon Dec 23 14:40:32 2019 +0530
+++ b/source/encoder/svt.h	Wed Dec 11 16:11:24 2019 +0530
@@ -29,7 +29,6 @@
 
 #include "EbApi.h"
 #include "EbErrorCodes.h"
-#include "EbTime.h"
 
 namespace X265_NS {
 
@@ -41,7 +40,7 @@ namespace X265_NS {
 #define EB_OUTPUTSTREAMBUFFERSIZE_MACRO(ResolutionSize)    ((ResolutionSize) < (INPUT_SIZE_1080i_TH) ? 0x1E8480 : (ResolutionSize) < (INPUT_SIZE_1080p_TH) ? 0x2DC6C0 : (ResolutionSize) < (INPUT_SIZE_4K_TH) ? 0x2DC6C0 : 0x2DC6C0)
 
 void svt_param_default(x265_param* param);
-int svt_set_preset_tune(x265_param* param, const char* preset, const char* tune);
+int svt_set_preset(x265_param* param, const char* preset);
 int svt_param_parse(x265_param* param, const char* name, const char* value);
 void svt_initialise_app_context(x265_encoder *enc);
 int svt_initialise_input_buffer(x265_encoder *enc);
@@ -49,4 +48,4 @@ int svt_initialise_input_buffer(x265_enc
 
 #endif // ifdef SVT_HEVC
 
-#endif // ifndef SVT_H
\ No newline at end of file
+#endif // ifndef SVT_H