<div dir="ltr">From 58f011df8ce0c5ac2a333d1ee25f0843caf2ee07 Mon Sep 17 00:00:00 2001<br>From: AnusuyaKumarasamy <<a href="mailto:anusuya.kumarasamy@multicorewareinc.com">anusuya.kumarasamy@multicorewareinc.com</a>><br>Date: Fri, 5 Jul 2024 16:11:02 +0530<br>Subject: [PATCH] Add support for Alpha channel CLI<br><br>---<br> doc/reST/cli.rst        | 11 +++++++++++<br> source/CMakeLists.txt   |  2 +-<br> source/common/param.cpp | 16 ++++++++++++++++<br> source/x265.h           |  4 ++++<br> source/x265cli.cpp      |  1 +<br> source/x265cli.h        |  1 +<br> 6 files changed, 34 insertions(+), 1 deletion(-)<br><br>diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst<br>index c57491b63..4d5ac1a15 100755<br>--- a/doc/reST/cli.rst<br>+++ b/doc/reST/cli.rst<br>@@ -2882,4 +2882,15 @@ See section :ref:`svthevc <SvtHevc>` for more details.<br> <br>     **CLI_ONLY**<br> <br>+Alpha Encode Options<br>+===================<br>+<br>+.. option:: --alpha<br>+<br>+      Enable alpha layer encoding support in x265.This option can be enabled<br>+       only when ENABLE_ALPHA is set during the make of x265.When enabled<br>+   --alpha always expects an input file in YUVA420 format.<br>+<br>+**CLI_ONLY**<br>+<br> .. vim: noet<br>diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt<br>index bed98bb37..9a215cbbf 100755<br>--- a/source/CMakeLists.txt<br>+++ b/source/CMakeLists.txt<br>@@ -31,7 +31,7 @@ option(NATIVE_BUILD "Target the build CPU" OFF)<br> option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br> # X265_BUILD must be incremented each time the public API is changed<br>-set(X265_BUILD 209)<br>+set(X265_BUILD 210)<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in">x265.def.in</a>"<br>                "${PROJECT_BINARY_DIR}/x265.def")<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in">x265_config.h.in</a>"<br>diff --git a/source/common/param.cpp b/source/common/param.cpp<br>index 5b2922587..e05e79eaf 100755<br>--- a/source/common/param.cpp<br>+++ b/source/common/param.cpp<br>@@ -392,6 +392,10 @@ void x265_param_default(x265_param* param)<br>     param->bEnableTemporalFilter = 0;<br>     param->temporalFilterStrength = 0.95;<br> <br>+    /*Alpha Channel Encoding*/<br>+    param->bEnableAlpha = 0;<br>+    param->numScalableLayers = 1;<br>+<br> #ifdef SVT_HEVC<br>     param->svtHevcParam = svtParam;<br>     svt_param_default(param);<br>@@ -1444,6 +1448,14 @@ int x265_param_parse(x265_param* p, const char* name, const char* value)<br>         OPT("film-grain") p->filmGrain = (char* )value;<br>         OPT("mcstf") p->bEnableTemporalFilter = atobool(value);<br>         OPT("sbrc") p->bEnableSBRC = atobool(value);<br>+        OPT("alpha")<br>+        {<br>+            if (atobool(value))<br>+            {<br>+                p->bEnableAlpha = 1;<br>+                p->numScalableLayers = 2;<br>+            }<br>+        }<br>         else<br>             return X265_PARAM_BAD_NAME;<br>     }<br>@@ -2079,6 +2091,7 @@ void x265_print_params(x265_param* param)<br>     TOOLOPT(param->rc.bStatWrite, "stats-write");<br>     TOOLOPT(param->rc.bStatRead,  "stats-read");<br>     TOOLOPT(param->bSingleSeiNal, "single-sei");<br>+    TOOLOPT(param->numScalableLayers > 1, "alpha");<br> #if ENABLE_HDR10_PLUS<br>     TOOLOPT(param->toneMapFile != NULL, "dhdr10-info");<br> #endif<br>@@ -2343,6 +2356,7 @@ char *x265_param2string(x265_param* p, int padx, int pady)<br>     if (p->filmGrain)<br>         s += sprintf(s, " film-grain=%s", p->filmGrain); // Film grain characteristics model filename<br>     BOOL(p->bEnableTemporalFilter, "mcstf");<br>+    BOOL(p->bEnableAlpha, "alpha");<br>     BOOL(p->bEnableSBRC, "sbrc");<br> #undef BOOL<br>     return buf;<br>@@ -2864,6 +2878,8 @@ void x265_copy_params(x265_param* dst, x265_param* src)<br>     dst->confWinRightOffset = src->confWinRightOffset;<br>     dst->confWinBottomOffset = src->confWinBottomOffset;<br>     dst->bliveVBV2pass = src->bliveVBV2pass;<br>+    dst->bEnableAlpha = src->bEnableAlpha;<br>+    dst->numScalableLayers = src->numScalableLayers;<br> <br>     if (src->videoSignalTypePreset) dst->videoSignalTypePreset = strdup(src->videoSignalTypePreset);<br>     else dst->videoSignalTypePreset = NULL;<br>diff --git a/source/x265.h b/source/x265.h<br>index c48b8648a..b6e410435 100644<br>--- a/source/x265.h<br>+++ b/source/x265.h<br>@@ -2269,6 +2269,10 @@ typedef struct x265_param<br>     /*SBRC*/<br>     int      bEnableSBRC;<br>     int mcstfFrameRange;<br>+<br>+    /*Alpha channel encoding*/<br>+    int      bEnableAlpha;<br>+    int      numScalableLayers;<br> } x265_param;<br> <br> /* x265_param_alloc:<br>diff --git a/source/x265cli.cpp b/source/x265cli.cpp<br>index 861595a5a..2f8a150d4 100755<br>--- a/source/x265cli.cpp<br>+++ b/source/x265cli.cpp<br>@@ -374,6 +374,7 @@ namespace X265_NS {<br>         H0("   --[no-]frame-dup              Enable Frame duplication. Default %s\n", OPT(param->bEnableFrameDuplication));<br>         H0("   --dup-threshold <integer>     PSNR threshold for Frame duplication. Default %d\n", param->dupThreshold);<br>         H0("   --[no-]mcstf                  Enable GOP based temporal filter. Default %d\n", param->bEnableTemporalFilter);<br>+        H0("   --alpha                       Enable alpha channel support. Default %d\n", param->bEnableAlpha);<br> #ifdef SVT_HEVC<br>         H0("   --[no]svt                     Enable SVT HEVC encoder %s\n", OPT(param->bEnableSvtHevc));<br>         H0("   --[no-]svt-hme                Enable Hierarchial motion estimation(HME) in SVT HEVC encoder \n");<br>diff --git a/source/x265cli.h b/source/x265cli.h<br>index b5fe327a6..b4e91a137 100644<br>--- a/source/x265cli.h<br>+++ b/source/x265cli.h<br>@@ -358,6 +358,7 @@ static const struct option long_options[] =<br>     { "dup-threshold", required_argument, NULL, 0 },<br>     { "mcstf",                 no_argument, NULL, 0 },<br>     { "no-mcstf",              no_argument, NULL, 0 },<br>+    { "alpha",                 no_argument, NULL, 0 },<br> #ifdef SVT_HEVC<br>     { "svt",     no_argument, NULL, 0 },<br>     { "no-svt",  no_argument, NULL, 0 },<br>-- <br>2.36.0.windows.1<br><br></div>