<div dir="ltr">From 01d3a62b3cb36e23d6ff4ddaa624ba343ef5239b Mon Sep 17 00:00:00 2001<br>From: Karam Singh <<a href="mailto:karam.singh@multicorewareinc.com">karam.singh@multicorewareinc.com</a>><br>Date: Fri, 10 Feb 2023 18:27:59 +0530<br>Subject: [PATCH] fix x265 zonefile feature<br><br>Signed-off-by: maheshpittala <<a href="mailto:mahesh@multicorewareinc.com">mahesh@multicorewareinc.com</a>><br>---<br> source/abrEncApp.cpp   | 20 ++++++++++----------<br> source/encoder/api.cpp |  1 -<br> source/x265cli.cpp     |  1 +<br> 3 files changed, 11 insertions(+), 11 deletions(-)<br><br>diff --git a/source/abrEncApp.cpp b/source/abrEncApp.cpp<br>index 9ad4e0abd..94644a1c0 100644<br>--- a/source/abrEncApp.cpp<br>+++ b/source/abrEncApp.cpp<br>@@ -186,6 +186,16 @@ namespace X265_NS {<br>             }<br>         }<br> <br>+        if (m_cliopt.zoneFile)<br>+        {<br>+            if (!m_cliopt.parseZoneFile())<br>+            {<br>+                x265_log(NULL, X265_LOG_ERROR, "Unable to parse zonefile in %s\n");<br>+                fclose(m_cliopt.zoneFile);<br>+                m_cliopt.zoneFile = NULL;<br>+            }<br>+        }<br>+<br>         /* note: we could try to acquire a different libx265 API here based on<br>         * the profile found during option parsing, but it must be done before<br>         * opening an encoder */<br>@@ -515,16 +525,6 @@ ret:<br>                 reconPlay = new ReconPlay(m_cliopt.reconPlayCmd, *m_param);<br>             char* profileName = m_cliopt.encName ? m_cliopt.encName : (char *)"x265";<br> <br>-            if (m_cliopt.zoneFile)<br>-            {<br>-                if (!m_cliopt.parseZoneFile())<br>-                {<br>-                    x265_log(NULL, X265_LOG_ERROR, "Unable to parse zonefile in %s\n", profileName);<br>-                    fclose(m_cliopt.zoneFile);<br>-                    m_cliopt.zoneFile = NULL;<br>-                }<br>-            }<br>-<br>             if (signal(SIGINT, sigint_handler) == SIG_ERR)<br>                 x265_log(m_param, X265_LOG_ERROR, "Unable to register CTRL+C handler: %s in %s\n",<br>                     strerror(errno), profileName);<br>diff --git a/source/encoder/api.cpp b/source/encoder/api.cpp<br>index 9b53e62ae..15b898a3c 100644<br>--- a/source/encoder/api.cpp<br>+++ b/source/encoder/api.cpp<br>@@ -208,7 +208,6 @@ x265_encoder *x265_encoder_open(x265_param *p)<br>     memcpy(zoneParam, param, sizeof(x265_param));<br>     for (int i = 0; i < param->rc.zonefileCount; i++)<br>     {<br>-        param->rc.zones[i].startFrame = -1;<br>         encoder->configureZone(zoneParam, param->rc.zones[i].zoneParam);<br>     }<br> <br>diff --git a/source/x265cli.cpp b/source/x265cli.cpp<br>index 4d10076c0..1d22b7944 100755<br>--- a/source/x265cli.cpp<br>+++ b/source/x265cli.cpp<br>@@ -1010,6 +1010,7 @@ namespace X265_NS {<br>         param->rc.zones = X265_MALLOC(x265_zone, param->rc.zonefileCount);<br>         for (int i = 0; i < param->rc.zonefileCount; i++)<br>         {<br>+            param->rc.zones[i].startFrame = -1;<br>             while (fgets(line, sizeof(line), zoneFile))<br>             {<br>                 if (*line == '#' || (strcmp(line, "\r\n") == 0))<br>-- <br>2.23.0.windows.1<br><br></div>