[x265] [X265][PATCH] Fix: warnings in Windows

Niranjan Bala niranjan at multicorewareinc.com
Wed Dec 23 16:25:23 UTC 2020


>From df3fe9fdbe3e362f0ef5f1fb823e50c996460c78 Mon Sep 17 00:00:00 2001
From: Niranjan <niranjan at multicorewareinc.com>
Date: Mon, 21 Dec 2020 23:40:42 +0530
Subject: [PATCH] Fix: warnings in Windows

---
 source/common/param.cpp            | 15 ++++++++++++++-
 source/encoder/encoder.cpp         |  4 ++--
 source/encoder/ratecontrol.cpp     | 14 ++++++--------
 source/test/rate-control-tests.txt |  1 +
 source/x265.h                      |  6 ++++++
 source/x265cli.cpp                 |  2 +-
 6 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/source/common/param.cpp b/source/common/param.cpp
index 7a9be18c3..5c0409e93 100755
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -179,6 +179,8 @@ void x265_param_default(x265_param* param)
     param->bEnableHRDConcatFlag = 0;
     param->bEnableFades = 0;
     param->bEnableSceneCutAwareQp = 0;
+    param->forwardWindow = 0;
+    param->backwardWindow = 0;
     param->fwdScenecutWindow = 500;
     param->fwdRefQpDelta = 5;
     param->fwdNonRefQpDelta = param->fwdRefQpDelta + (SLICE_TYPE_DELTA *
param->fwdRefQpDelta);
@@ -1347,7 +1349,14 @@ int x265_param_parse(x265_param* p, const char*
name, const char* value)
             p->selectiveSAO = atoi(value);
         }
         OPT("fades") p->bEnableFades = atobool(value);
-        OPT("scenecut-aware-qp") p->bEnableSceneCutAwareQp = atoi(value);
+        OPT("scenecut-aware-qp")
+        {
+            p->bEnableSceneCutAwareQp = atoi(value);
+            if (p->bEnableSceneCutAwareQp & FORWARD)
+                p->forwardWindow = 1;
+            if (p->bEnableSceneCutAwareQp & BACKWARD)
+                p->backwardWindow = 1;
+        }
         OPT("masking-strength")
         {
             int window1;
@@ -1831,6 +1840,8 @@ int x265_check_params(x265_param* param)
         }
         else
         {
+            CHECK(param->bEnableSceneCutAwareQp < 0 ||
param->bEnableSceneCutAwareQp >3,
+            "Invalid scenecut window direction. Value must be between 0
and 3(inclusive)");
             CHECK(param->fwdScenecutWindow < 0 || param->fwdScenecutWindow
> 1000,
             "Invalid forward scenecut Window duration. Value must be
between 0 and 1000(inclusive)");
             CHECK(param->fwdRefQpDelta < 0 || param->fwdRefQpDelta > 10,
@@ -2659,6 +2670,8 @@ void x265_copy_params(x265_param* dst, x265_param*
src)
     dst->bEnableSvtHevc = src->bEnableSvtHevc;
     dst->bEnableFades = src->bEnableFades;
     dst->bEnableSceneCutAwareQp = src->bEnableSceneCutAwareQp;
+    dst->forwardWindow = src->forwardWindow;
+    dst->backwardWindow = src->backwardWindow;
     dst->fwdScenecutWindow = src->fwdScenecutWindow;
     dst->fwdRefQpDelta = src->fwdRefQpDelta;
     dst->fwdNonRefQpDelta = src->fwdNonRefQpDelta;
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index 18c3b6788..49951c725 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -1810,7 +1810,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
                 inFrame->m_lowres.m_bIsHardScenecut = isHardSC;
         }

-        if ((m_param->bEnableSceneCutAwareQp == BI_DIRECTIONAL ||
m_param->bEnableSceneCutAwareQp == BACKWARD) && m_param->rc.bStatRead)
+        if (m_param->backwardWindow && m_param->rc.bStatRead)
         {
             RateControlEntry * rcEntry = NULL;
             rcEntry = &(m_rateControl->m_rce2Pass[inFrame->m_poc]);
@@ -2242,7 +2242,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
             frameEnc = m_lookahead->getDecidedPicture();
         if (frameEnc && !pass && (!m_param->chunkEnd || (m_encodedFrameNum
< m_param->chunkEnd)))
         {
-            if ((m_param->bEnableSceneCutAwareQp == BI_DIRECTIONAL ||
m_param->bEnableSceneCutAwareQp == FORWARD) && m_param->rc.bStatRead)
+            if (m_param->forwardWindow && m_param->rc.bStatRead)
             {
                 RateControlEntry * rcEntry;
                 rcEntry = &(m_rateControl->m_rce2Pass[frameEnc->m_poc]);
diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp
index 1299f6527..3153dcc31 100644
--- a/source/encoder/ratecontrol.cpp
+++ b/source/encoder/ratecontrol.cpp
@@ -1860,9 +1860,9 @@ double RateControl::rateEstimateQscale(Frame*
curFrame, RateControlEntry *rce)
         {
             double lqmin = m_lmin[m_sliceType];
             double lqmax = m_lmax[m_sliceType];
-            if (m_param->bEnableSceneCutAwareQp == FORWARD ||
m_param->bEnableSceneCutAwareQp == BI_DIRECTIONAL)
+            if (m_param->forwardWindow)
                 qScale = forwardMasking(curFrame, qScale);
-            if (m_param->bEnableSceneCutAwareQp == BACKWARD ||
m_param->bEnableSceneCutAwareQp == BI_DIRECTIONAL)
+            if (m_param->backwardWindow)
                 qScale = backwardMasking(curFrame, qScale);
             qScale = x265_clip3(lqmin, lqmax, qScale);
             q = x265_qScale2qp(qScale);
@@ -1987,9 +1987,9 @@ double RateControl::rateEstimateQscale(Frame*
curFrame, RateControlEntry *rce)
                 double qmin = m_lmin[m_sliceType];
                 double qmax = m_lmax[m_sliceType];

-                if (m_param->bEnableSceneCutAwareQp == FORWARD ||
m_param->bEnableSceneCutAwareQp == BI_DIRECTIONAL)
+                if (m_param->forwardWindow)
                     q = forwardMasking(curFrame, q);
-                if (m_param->bEnableSceneCutAwareQp == BACKWARD ||
m_param->bEnableSceneCutAwareQp == BI_DIRECTIONAL)
+                if (m_param->backwardWindow)
                     q = backwardMasking(curFrame, q);

                 q = x265_clip3(qmin, qmax, q);
@@ -2156,9 +2156,9 @@ double RateControl::rateEstimateQscale(Frame*
curFrame, RateControlEntry *rce)
                 double qmin = m_lmin[m_sliceType];
                 double qmax = m_lmax[m_sliceType];

-                if (m_param->bEnableSceneCutAwareQp == FORWARD ||
m_param->bEnableSceneCutAwareQp == BI_DIRECTIONAL)
+                if (m_param->forwardWindow)
                     q = forwardMasking(curFrame, q);
-                if (m_param->bEnableSceneCutAwareQp == BACKWARD ||
m_param->bEnableSceneCutAwareQp == BI_DIRECTIONAL)
+                if (m_param->backwardWindow)
                     q = backwardMasking(curFrame, q);

                 q = x265_clip3(qmin, qmax, q);
@@ -3192,8 +3192,6 @@ double RateControl::forwardMasking(Frame* curFrame,
double q)
     int lastIFrame = m_top->m_rateControl->m_lastScenecutAwareIFrame;
     double fwdRefQpDelta = double(m_param->fwdRefQpDelta);
     double fwdNonRefQpDelta = double(m_param->fwdNonRefQpDelta);
-    double bwdRefQpDelta = double(m_param->bwdRefQpDelta);
-    double bwdNonRefQpDelta = double(m_param->bwdNonRefQpDelta);
     double sliceTypeDelta = SLICE_TYPE_DELTA * fwdRefQpDelta;
     double window2Delta = WINDOW2_DELTA * fwdRefQpDelta;
     double window3Delta = WINDOW3_DELTA * fwdRefQpDelta;
diff --git a/source/test/rate-control-tests.txt
b/source/test/rate-control-tests.txt
index 6c8f10cb6..e3dd2507d 100644
--- a/source/test/rate-control-tests.txt
+++ b/source/test/rate-control-tests.txt
@@ -46,6 +46,7 @@ sita_1920x1080_30.yuv, --preset ultrafast --crf 20
--no-cutree --keyint 50 --min
 sita_1920x1080_30.yuv, --preset medium --crf 20 --no-cutree --keyint 50
--min-keyint 50 --no-open-gop --pass 1 --vbv-bufsize 7000 --vbv-maxrate
5000 --repeat-headers --multi-pass-opt-rps:: --preset medium --crf 20
--no-cutree --keyint 50 --min-keyint 50 --no-open-gop --pass 2
--vbv-bufsize 7000 --vbv-maxrate 5000 --repeat-headers --multi-pass-opt-rps
 sintel_trailer_2k_1920x1080_24.yuv,--preset medium --bitrate 6000
--no-cutree --aq-mode 0 --pass 1::--preset medium --bitrate 6000
--no-cutree --aq-mode 0 --pass 2 --scenecut-aware-qp 1
 sintel_trailer_2k_1920x1080_24.yuv,--preset medium --bitrate 6000
--no-cutree --aq-mode 0 --hist-scenecut --pass 1::--preset medium --bitrate
6000 --no-cutree --aq-mode 0 --hist-scenecut --pass 2 --scenecut-aware-qp 3
--masking-strength 300,-1,7,100,2,3
+sintel_trailer_2k_1920x1080_24.yuv,--preset medium --bitrate 6000
--no-cutree --aq-mode 0 --pass 1::--preset medium --bitrate 6000
--no-cutree --aq-mode 0 --pass 2 --scenecut-aware-qp 2 --masking-strength
100,-1,-1

 # multi-pass rate control and analysis
 ducks_take_off_1080p50.y4m,--bitrate 6000 --pass 1
 --multi-pass-opt-analysis  --hash 1 --ssim --psnr:: --bitrate 6000 --pass
2  --multi-pass-opt-analysis  --hash 1 --ssim --psnr
diff --git a/source/x265.h b/source/x265.h
index b064f67c2..62bc7706f 100644
--- a/source/x265.h
+++ b/source/x265.h
@@ -1948,6 +1948,12 @@ typedef struct x265_param

     /* The offset by which QP is incremented for non-referenced
inter-frames before a scenecut when bEnableSceneCutAwareQp is 2 or 3. */
     double    bwdNonRefQpDelta;
+
+    /* It is set when bEnableSceneCutAwareQp is 1 or 3 */
+    int       forwardWindow;
+
+    /* It is set when bEnableSceneCutAwareQp is 2 or 3 */
+    int       backwardWindow;
 } x265_param;

 /* x265_param_alloc:
diff --git a/source/x265cli.cpp b/source/x265cli.cpp
index 0c0d27ff5..8ad5a18cb 100755
--- a/source/x265cli.cpp
+++ b/source/x265cli.cpp
@@ -181,7 +181,7 @@ namespace X265_NS {
         H1("                                 1 - Forward masking\n");
         H1("                                 2 - Backward masking\n");
         H1("                                 3 - Bidirectional masking\n");
-        H1("   --masking-strength <string>   Comma separated values which
specifies the duration and offset for the QP increment for inter-frames");
+        H1("   --masking-strength <string>   Comma separated values which
specifies the duration and offset for the QP increment for inter-frames\n");
         H0("   --radl <integer>              Number of RADL pictures
allowed in front of IDR. Default %d\n", param->radl);
         H0("   --intra-refresh               Use Periodic Intra Refresh
instead of IDR frames\n");
         H0("   --rc-lookahead <integer>      Number of frames for
frame-type lookahead (determines encoder latency) Default %d\n",
param->lookaheadDepth);
-- 
2.18.0.windows.1


-- 

Thanks & Regards
*Niranjan Kumar B*
Video Codec Engineer
Media & AI Analytics
+91 958 511 1449
<https://multicorewareinc.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20201223/66257b28/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 10145 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20201223/66257b28/attachment-0001.obj>


More information about the x265-devel mailing list