[x265] [PATCH] Fix x265 SVT integration

Snehaa Giridharan snehaa at multicorewareinc.com
Tue Dec 31 05:53:37 CET 2019


# HG changeset patch
# User snehaa at multicorewareinc.com
# Date 1576060884 -19800
#      Wed Dec 11 16:11:24 2019 +0530
# Node ID fad5b16ba443e113ce8c14840431eba50a14f332
# Parent  a4e060a4483913e28df2ce8b8549f3ba8b63ac5a
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

diff -r a4e060a44839 -r fad5b16ba443 doc/reST/cli.rst
--- a/doc/reST/cli.rst Wed Sep 11 15:38:06 2019 +0530
+++ b/doc/reST/cli.rst Wed Dec 11 16:11:24 2019 +0530
@@ -2541,12 +2541,12 @@

 .. 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**

diff -r a4e060a44839 -r fad5b16ba443 doc/reST/svthevc.rst
--- a/doc/reST/svthevc.rst Wed Sep 11 15:38:06 2019 +0530
+++ b/doc/reST/svthevc.rst Wed Dec 11 16:11:24 2019 +0530
@@ -12,6 +12,10 @@
 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 @@
 +-------------------------------------------+------------------------------+------------------------------+
 | :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 @@
 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                           |
+| Ultrafast                              | 11                           |
 +----------------------------------------+------------------------------+
-| Superfast                              | 11                           |
+| Superfast                              | 10                           |
 +----------------------------------------+------------------------------+
-| Veryfast                               | 10                           |
+| Veryfast                               | 9                            |
 +----------------------------------------+------------------------------+
-| Faster                                 | 9                            |
+| Faster                                 | 8                            |
 +----------------------------------------+------------------------------+
-| Fast                                   | 8                            |
+| Fast                                   | 7                            |
 +----------------------------------------+------------------------------+
-| Medium                                 | 7                            |
+| Medium                                 | 6                            |
 +----------------------------------------+------------------------------+
-| Slow                                   | 6                            |
+| Slow                                   | 5                            |
 +----------------------------------------+------------------------------+
-| Slower                                 | 5                            |
+| Slower                                 | 4                            |
 +----------------------------------------+------------------------------+
-| Veryslow                               | 4                            |
+| Veryslow                               | 3                            |
 +----------------------------------------+------------------------------+
-| Placebo                                | 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.
diff -r a4e060a44839 -r fad5b16ba443 source/CMakeLists.txt
--- a/source/CMakeLists.txt Wed Sep 11 15:38:06 2019 +0530
+++ b/source/CMakeLists.txt Wed Dec 11 16:11:24 2019 +0530
@@ -573,7 +573,6 @@
 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()

diff -r a4e060a44839 -r fad5b16ba443 source/cmake/Findsvthevc.cmake
--- a/source/cmake/Findsvthevc.cmake Wed Sep 11 15:38:06 2019 +0530
+++ b/source/cmake/Findsvthevc.cmake Wed Dec 11 16:11:24 2019 +0530
@@ -15,34 +15,37 @@
 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)
+    if(EXISTS "${SVT_HEVC_INCLUDE_DIR}/EbApiVersion.h")
+        file(READ "${SVT_HEVC_INCLUDE_DIR}/EbApiVersion.h" version)

-string(REGEX MATCH "SVT_VERSION_MAJOR       ([0-9]*)" _ ${version})
-set(SVT_VERSION_MAJOR ${CMAKE_MATCH_1})
+        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})
+        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})
+        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
"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()
-
+        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
diff -r a4e060a44839 -r fad5b16ba443 source/common/param.cpp
--- a/source/common/param.cpp Wed Sep 11 15:38:06 2019 +0530
+++ b/source/common/param.cpp Wed Dec 11 16:11:24 2019 +0530
@@ -2553,8 +2553,8 @@
     svtHevcParam->latencyMode = 0;

     //Preset & Tune
-    svtHevcParam->encMode = 9;
-    svtHevcParam->tune = 0;
+    svtHevcParam->encMode = 7;
+    svtHevcParam->tune = 1;

     // Interlaced Video
     svtHevcParam->interlacedVideo = 0;
@@ -2594,10 +2594,10 @@
     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;
@@ -2607,7 +2607,7 @@
     svtHevcParam->unregisteredUserDataSeiFlag = 0;
     svtHevcParam->recoveryPointSeiFlag = 0;
     svtHevcParam->enableTemporalId = 1;
-    svtHevcParam->profile = 2;
+    svtHevcParam->profile = 1;
     svtHevcParam->tier = 0;
     svtHevcParam->level = 0;

@@ -2638,6 +2638,13 @@
     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)
@@ -2646,27 +2653,21 @@

     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;
+        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;
     }
     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;
-        else  return -1;
+        svtHevcParam->tune = 1;
     }
     return 0;
 }
@@ -2820,11 +2821,10 @@
     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);
@@ -2850,6 +2850,16 @@
         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);

diff -r a4e060a44839 -r fad5b16ba443 source/encoder/svt.h
--- a/source/encoder/svt.h Wed Sep 11 15:38:06 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 {

@@ -49,4 +48,4 @@

 #endif // ifdef SVT_HEVC

-#endif // ifndef SVT_H
\ No newline at end of file
+#endif // ifndef SVT_H


Thanks and Regards,
*Snehaa.G*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20191231/d9c5fb06/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Fix_x265_SVT_integration.patch
Type: application/x-patch
Size: 17930 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20191231/d9c5fb06/attachment-0001.bin>


More information about the x265-devel mailing list