Re: [x265] [PATCH] Disable fall-back on traditional scenecut algorithm with --hist-scenecut

2021-07-30 Thread Pooja Venkatesan
-tests.txt
index 971c854df..26d43b28a 100644
--- a/source/test/regression-tests.txt
+++ b/source/test/regression-tests.txt
@@ -160,6 +160,7 @@ Traffic_4096x2048_30p.y4m, --preset medium --frame-dup
--dup-threshold 60 --hrd
 Kimono1_1920x1080_24_400.yuv,--preset superfast --qp 28 --zones 0,139,q=32
 sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut
--hist-threshold 0.02 --frame-dup --dup-threshold 60 --hrd --bitrate 1
--vbv-bufsize 15000 --vbv-maxrate 12000
 sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut
--hist-threshold 0.02
+sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut
--hist-threshold 0.02 --no-traditional-scenecut
 sintel_trailer_2k_1920x1080_24.yuv, --preset ultrafast --hist-scenecut
--hist-threshold 0.02
 crowd_run_1920x1080_50.yuv, --preset faster --ctu 32 --rskip 2
--rskip-edge-threshold 5
 crowd_run_1920x1080_50.yuv, --preset fast --ctu 64 --rskip 2
--rskip-edge-threshold 5 --aq-mode 4
diff --git a/source/x265.h b/source/x265.h
index 324f3163f..3f3133536 100644
--- a/source/x265.h
+++ b/source/x265.h
@@ -1963,6 +1963,10 @@ typedef struct x265_param
 /* Flag indicating whether the encoder should emit an End of Sequence
  * NAL at the end of every Coded Video Sequence. Default false */
 int  bEnableEndOfSequence;
+
+/* Flag to turn on/off traditional scenecut detection in histogram
based scenecut detection.
+ * When false, only spatial properties are used for scenecut
detection. Default true */
+int  bEnableTradScdInHscd;
 } x265_param;

 /* x265_param_alloc:
diff --git a/source/x265cli.h b/source/x265cli.h
index 46a2b68ae..8fcf37b8a 100644
--- a/source/x265cli.h
+++ b/source/x265cli.h
@@ -144,6 +144,8 @@ static const struct option long_options[] =
 { "hist-scenecut",no_argument, NULL, 0},
 { "no-hist-scenecut", no_argument, NULL, 0},
 { "hist-threshold", required_argument, NULL, 0},
+{ "traditional-scenecut", no_argument, NULL, 0},
+{ "no-traditional-scenecut", no_argument, NULL, 0},
 { "fades",no_argument, NULL, 0 },
 { "no-fades", no_argument, NULL, 0 },
 { "scenecut-aware-qp", required_argument, NULL, 0 },
-- 
2.24.0.windows.2


On Fri, Jul 30, 2021 at 3:24 PM Pooja Venkatesan 
wrote:

>
>
> On Fri, Jul 30, 2021 at 2:18 PM Aruna Matheswaran <
> ar...@multicorewareinc.com> wrote:
>
>>
>>
>> On Thu, Jun 24, 2021 at 2:18 PM Pooja Venkatesan <
>> po...@multicorewareinc.com> wrote:
>>
>>> From f6c1b86d99ab3a0dd57204f930e526a07e28fed7 Mon Sep 17 00:00:00 2001
>>> From: Praveen Karadugattu 
>>> Date: Sun, 20 Jun 2021 21:20:50 +0530
>>> Subject: [PATCH] Disable fall-back on traditional scenecut algorithm with
>>>  --hist-scenecut
>>>
>>> ---
>>>  doc/reST/cli.rst |  9 +++--
>>>  source/CMakeLists.txt|  2 +-
>>>  source/common/param.cpp  |  8 +++-
>>>  source/encoder/encoder.cpp   | 17 -
>>>  source/encoder/slicetype.cpp | 15 ++-
>>>  source/test/regression-tests.txt |  1 +
>>>  source/x265.h|  4 
>>>  source/x265cli.h |  1 +
>>>  8 files changed, 43 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
>>> index 4154221af..280b734b3 100755
>>> --- a/doc/reST/cli.rst
>>> +++ b/doc/reST/cli.rst
>>> @@ -1470,7 +1470,8 @@ Slice decision options
>>>  .. option:: --hist-scenecut, --no-hist-scenecut
>>>
>>>   Indicates that scenecuts need to be detected using luma edge and
>>> chroma histograms.
>>> - :option:`--hist-scenecut` enables scenecut detection using the
>>> histograms and disables the default scene cut algorithm.
>>> + :option:`--hist-scenecut` enables scenecut detection using the
>>> histograms.
>>> + It also uses the intra and inter cost info to arrive at a scenecut
>>> decision from the default scenecut method.
>>>   :option:`--no-hist-scenecut` disables histogram based scenecut
>>> algorithm.
>>>
>>>  .. option:: --hist-threshold <0.0..1.0>
>>> @@ -1480,7 +1481,11 @@ Slice decision options
>>>   greater than 0.2 against the previous frame as scenecut.
>>>   Increasing the threshold reduces the number of scenecuts detected.
>>>   Default 0.03.
>>> -
>>> +
>>> +.. option:: --disable-traditional-scenecut
>>> +
>>> + Indicates that the usage of traditional scenecut detection using intra
>>> and inter cost should be disabled when :o

Re: [x265] [PATCH] Disable fall-back on traditional scenecut algorithm with --hist-scenecut

2021-07-30 Thread Pooja Venkatesan
On Fri, Jul 30, 2021 at 2:18 PM Aruna Matheswaran <
ar...@multicorewareinc.com> wrote:

>
>
> On Thu, Jun 24, 2021 at 2:18 PM Pooja Venkatesan <
> po...@multicorewareinc.com> wrote:
>
>> From f6c1b86d99ab3a0dd57204f930e526a07e28fed7 Mon Sep 17 00:00:00 2001
>> From: Praveen Karadugattu 
>> Date: Sun, 20 Jun 2021 21:20:50 +0530
>> Subject: [PATCH] Disable fall-back on traditional scenecut algorithm with
>>  --hist-scenecut
>>
>> ---
>>  doc/reST/cli.rst |  9 +++--
>>  source/CMakeLists.txt|  2 +-
>>  source/common/param.cpp  |  8 +++-
>>  source/encoder/encoder.cpp   | 17 -
>>  source/encoder/slicetype.cpp | 15 ++-
>>  source/test/regression-tests.txt |  1 +
>>  source/x265.h|  4 
>>  source/x265cli.h |  1 +
>>  8 files changed, 43 insertions(+), 14 deletions(-)
>>
>> diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
>> index 4154221af..280b734b3 100755
>> --- a/doc/reST/cli.rst
>> +++ b/doc/reST/cli.rst
>> @@ -1470,7 +1470,8 @@ Slice decision options
>>  .. option:: --hist-scenecut, --no-hist-scenecut
>>
>>   Indicates that scenecuts need to be detected using luma edge and chroma
>> histograms.
>> - :option:`--hist-scenecut` enables scenecut detection using the
>> histograms and disables the default scene cut algorithm.
>> + :option:`--hist-scenecut` enables scenecut detection using the
>> histograms.
>> + It also uses the intra and inter cost info to arrive at a scenecut
>> decision from the default scenecut method.
>>   :option:`--no-hist-scenecut` disables histogram based scenecut
>> algorithm.
>>
>>  .. option:: --hist-threshold <0.0..1.0>
>> @@ -1480,7 +1481,11 @@ Slice decision options
>>   greater than 0.2 against the previous frame as scenecut.
>>   Increasing the threshold reduces the number of scenecuts detected.
>>   Default 0.03.
>> -
>> +
>> +.. option:: --disable-traditional-scenecut
>> +
>> + Indicates that the usage of traditional scenecut detection using intra
>> and inter cost should be disabled when :option:`--hist-scenecut` is used.
>> +
>>  .. option:: --radl 
>>
>>   Number of RADL pictures allowed infront of IDR. Requires closed gop
>> interval.
>> diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
>> index b4e57b592..f4a9cb793 100755
>> --- a/source/CMakeLists.txt
>> +++ b/source/CMakeLists.txt
>> @@ -29,7 +29,7 @@ option(NATIVE_BUILD "Target the build CPU" OFF)
>>  option(STATIC_LINK_CRT "Statically link C runtime for release builds"
>> OFF)
>>  mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
>>  # X265_BUILD must be incremented each time the public API is changed
>> -set(X265_BUILD 200)
>> +set(X265_BUILD 201)
>>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>> "${PROJECT_BINARY_DIR}/x265.def")
>>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
>> diff --git a/source/common/param.cpp b/source/common/param.cpp
>> index 8a27aaef3..3b84415c3 100755
>> --- a/source/common/param.cpp
>> +++ b/source/common/param.cpp
>> @@ -172,6 +172,7 @@ void x265_param_default(x265_param* param)
>>  param->scenecutThreshold = 40; /* Magic number pulled in from x264 */
>>  param->edgeTransitionThreshold = 0.03;
>>  param->bHistBasedSceneCut = 0;
>> +param->bDisableTradScdInHscd = 0;
>>  param->lookaheadSlices = 8;
>>  param->lookaheadThreads = 0;
>>  param->scenecutBias = 5.0;
>> @@ -598,6 +599,7 @@ int x265_param_default_preset(x265_param* param,
>> const char* preset, const char*
>>  param->lookaheadDepth = 0;
>>  param->scenecutThreshold = 0;
>>  param->bHistBasedSceneCut = 0;
>> +param->bDisableTradScdInHscd = 0;
>>  param->rc.cuTree = 0;
>>  param->frameNumThreads = 1;
>>  }
>> @@ -953,6 +955,7 @@ int x265_param_parse(x265_param* p, const char* name,
>> const char* value)
>> bError = false;
>> p->scenecutThreshold = atoi(value);
>> p->bHistBasedSceneCut = 0;
>> +   p->bDisableTradScdInHscd = 0;
>> }
>>  }
>>  OPT("temporal-layers") p->bEnableTemporalSubLayers = atobool(value);
>> @@ -1234,6 +1237,7 @@ int x265_param_parse(x265_param* p, const char

[x265] [PATCH] Disable fall-back on traditional scenecut algorithm with --hist-scenecut

2021-06-24 Thread Pooja Venkatesan
sion-tests.txt
index 971c854df..828157cab 100644
--- a/source/test/regression-tests.txt
+++ b/source/test/regression-tests.txt
@@ -160,6 +160,7 @@ Traffic_4096x2048_30p.y4m, --preset medium --frame-dup
--dup-threshold 60 --hrd
 Kimono1_1920x1080_24_400.yuv,--preset superfast --qp 28 --zones 0,139,q=32
 sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut
--hist-threshold 0.02 --frame-dup --dup-threshold 60 --hrd --bitrate 1
--vbv-bufsize 15000 --vbv-maxrate 12000
 sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut
--hist-threshold 0.02
+sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut
--hist-threshold 0.02 --disable-traditional-scenecut
 sintel_trailer_2k_1920x1080_24.yuv, --preset ultrafast --hist-scenecut
--hist-threshold 0.02
 crowd_run_1920x1080_50.yuv, --preset faster --ctu 32 --rskip 2
--rskip-edge-threshold 5
 crowd_run_1920x1080_50.yuv, --preset fast --ctu 64 --rskip 2
--rskip-edge-threshold 5 --aq-mode 4
diff --git a/source/x265.h b/source/x265.h
index 324f3163f..3a65fdda6 100644
--- a/source/x265.h
+++ b/source/x265.h
@@ -1963,6 +1963,10 @@ typedef struct x265_param
 /* Flag indicating whether the encoder should emit an End of Sequence
  * NAL at the end of every Coded Video Sequence. Default false */
 int  bEnableEndOfSequence;
+
+/* Flag to turn off traditional scenecut detection in histogram based
scenecut detection so that
+ * only spatial properties are used for scenecut detection. Default
false */
+int  bDisableTradScdInHscd;
 } x265_param;

 /* x265_param_alloc:
diff --git a/source/x265cli.h b/source/x265cli.h
index 46a2b68ae..86136fbfb 100644
--- a/source/x265cli.h
+++ b/source/x265cli.h
@@ -144,6 +144,7 @@ static const struct option long_options[] =
 { "hist-scenecut",no_argument, NULL, 0},
 { "no-hist-scenecut", no_argument, NULL, 0},
 { "hist-threshold", required_argument, NULL, 0},
+{ "disable-traditional-scenecut", no_argument, NULL, 0},
 { "fades",no_argument, NULL, 0 },
 { "no-fades", no_argument, NULL, 0 },
 { "scenecut-aware-qp", required_argument, NULL, 0 },
-- 
2.24.0.windows.2

Regards,
*Pooja Venkatesan*,
Video Codec Engineer,
Media & AI analytics BU


disable-trad-scenecutHSCD.diff
Description: Binary data
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH: Release_3.3 branch] hme: Perform check for search range only if hme is enabled.

2020-08-25 Thread Pooja Venkatesan
Hi,
The patch is to be applied on the Release_3.3 branch

>From acea099ac4e3834716cc7a474d9035553eac3a72 Mon Sep 17 00:00:00 2001
From: Pooja Venkatesan 
Date: Tue, 25 Aug 2020 14:23:23 +0530
Subject: [PATCH] hme: Perform check for search range only if hme is enabled.

---
 source/common/param.cpp | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/source/common/param.cpp b/source/common/param.cpp
index d2cab5b3d..7bac55316 100644
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -1761,9 +1761,12 @@ int x265_check_params(x265_param* param)
 "Invalid scenecut Window duration. Value must be between 0 and
1000(inclusive)");
 CHECK(param->maxQpDelta < 0 || param->maxQpDelta > 10,
 "Invalid maxQpDelta value. Value must be between 0 and 10
(inclusive)");
-for(int level = 0; level < 3; level++)
-CHECK(param->hmeRange[level] < 0 || param->hmeRange[level] >=
32768,
-"Search Range for HME levels must be between 0 and 32768");
+if (param->bEnableHME)
+{
+for (int level = 0; level < 3; level++)
+CHECK(param->hmeRange[level] < 0 || param->hmeRange[level] >=
32768,
+"Search Range for HME levels must be between 0 and 32768");
+}
 #if !X86_64
 CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 ||
param->sourceHeight > 480),
 "SEA motion search does not support resolutions greater than 480p
in 32 bit build");
-- 
2.24.0.windows.2

Regards,
*Pooja Venkatesan*,
Video Codec Engineer,
Media & AI analytics BU


hme_check.diff
Description: Binary data
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH] Fix cost estimation error for hist-based scenecut

2020-07-15 Thread Pooja Venkatesan
>From 613e174411f9d52677444f142f6f6dc0fe2e7885 Mon Sep 17 00:00:00 2001
From: Pooja Venkatesan 
Date: Thu, 9 Jul 2020 18:04:29 +0530
Subject: [PATCH] Fix cost estimation error for hist-based scenecut

---
 source/encoder/slicetype.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source/encoder/slicetype.cpp b/source/encoder/slicetype.cpp
index 5292473b1..81d2adbe6 100644
--- a/source/encoder/slicetype.cpp
+++ b/source/encoder/slicetype.cpp
@@ -2244,7 +2244,7 @@ bool Lookahead::scenecut(Lowres **frames, int p0, int
p1, bool bRealScenecut, in
  * and not considered a scenecut. */
 for (int cp1 = p1; cp1 <= maxp1; cp1++)
 {
-if (!m_param->bHistBasedSceneCut && !scenecutInternal(frames,
p0, cp1, false))
+if (!scenecutInternal(frames, p0, cp1, false) &&
!m_param->bHistBasedSceneCut)
 {
 /* Any frame in between p0 and cur_p1 cannot be a real
scenecut. */
 for (int i = cp1; i > p0; i--)
-- 
2.24.0.windows.2

Regards,
*Pooja Venkatesan*,
Video Codec Engineer,
Media & AI analytics BU


fix_hist_patch.diff
Description: Binary data
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


Re: [x265] [PATCH 2 of 2] Add support for RADL pictures at IDR scenecuts.

2020-06-29 Thread Pooja Venkatesan
>From 095b73ef10eaf0600f0078cbae433ecc0942cb46 Mon Sep 17 00:00:00 2001
From: Pooja Venkatesan 
Date: Mon, 29 Jun 2020 17:13:34 +0530
Subject: [PATCH] Add support for RADL pictures at IDR scenecuts

---
 doc/reST/cli.rst |  5 -
 source/common/lowres.cpp |  1 +
 source/common/lowres.h   |  1 +
 source/encoder/encoder.cpp   | 14 ++
 source/encoder/encoder.h |  2 +-
 source/encoder/slicetype.cpp | 12 +++-
 6 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
index 23b74c3d8..3b8a6e2e6 100644
--- a/doc/reST/cli.rst
+++ b/doc/reST/cli.rst
@@ -1475,7 +1475,10 @@ Slice decision options

 .. option:: --radl 

- Number of RADL pictures allowed infront of IDR. Requires fixed keyframe
interval.
+ Number of RADL pictures allowed infront of IDR. Requires closed gop
interval.
+ If enabled for fixed keyframe interval, inserts RADL at every IDR.
+ If enabled for closed gop interval, in case of :option:`--hist-scenecut`
inserts RADL at every hard scenecut
+ whereas for the :option:`--scenecut`, inserts RADL at every scenecut.
  Recommended value is 2-3. Default 0 (disabled).

  **Range of values: Between 0 and `--bframes`
diff --git a/source/common/lowres.cpp b/source/common/lowres.cpp
index db1c2d159..578981d64 100644
--- a/source/common/lowres.cpp
+++ b/source/common/lowres.cpp
@@ -269,6 +269,7 @@ void Lowres::init(PicYuv *origPic, int poc)
 interPCostPercDiff = 0.0;
 intraCostPercDiff = 0.0;
 m_bIsMaxThres = false;
+m_bIsHardScenecut = false;

 if (qpAqOffset && invQscaleFactor)
 memset(costEstAq, -1, sizeof(costEstAq));
diff --git a/source/common/lowres.h b/source/common/lowres.h
index 200b1f032..2a7497258 100644
--- a/source/common/lowres.h
+++ b/source/common/lowres.h
@@ -238,6 +238,7 @@ struct Lowres : public ReferencePlanes
 bool   m_bIsMaxThres;
 double interPCostPercDiff;
 double intraCostPercDiff;
+bool   m_bIsHardScenecut;

 bool create(x265_param* param, PicYuv *origPic, uint32_t qgSize);
 void destroy();
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index 0c6fd80bf..6101eeacd 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -1528,7 +1528,7 @@ double Encoder::normalizeRange(int32_t value, int32_t
minValue, int32_t maxValue
 return (double)(value - minValue) * (rangeEnd - rangeStart) /
(maxValue - minValue) + rangeStart;
 }

-void Encoder::findSceneCuts(x265_picture *pic, bool& bDup, double
maxUVSad, double edgeSad, bool& isMaxThres)
+void Encoder::findSceneCuts(x265_picture *pic, bool& bDup, double
maxUVSad, double edgeSad, bool& isMaxThres, bool& isHardSC)
 {
 double minEdgeT = m_edgeHistThreshold * MIN_EDGE_FACTOR;
 double minChromaT = minEdgeT * SCENECUT_CHROMA_FACTOR;
@@ -1556,12 +1556,15 @@ void Encoder::findSceneCuts(x265_picture *pic,
bool& bDup, double maxUVSad, doub
 {
 pic->frameData.bScenecut = true;
 isMaxThres = true;
+isHardSC = true;
 }
 else if (edgeSad > m_scaledEdgeThreshold || maxUVSad >=
m_scaledChromaThreshold
  || (edgeSad > m_edgeHistThreshold && maxUVSad >=
m_chromaHistThreshold))
 {
 pic->frameData.bScenecut = true;
 bDup = false;
+if (edgeSad > m_scaledEdgeThreshold || maxUVSad >=
m_scaledChromaThreshold)
+isHardSC = true;
 }
 }
 }
@@ -1595,6 +1598,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
 bool bdropFrame = false;
 bool dropflag = false;
 bool isMaxThres = false;
+bool isHardSC = false;

 if (m_exportedPic)
 {
@@ -1621,7 +1625,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
 {
 double maxUVSad = 0.0, edgeSad = 0.0;
 computeHistogramSAD(, , pic_in->poc);
-findSceneCuts(pic, bdropFrame, maxUVSad, edgeSad,
isMaxThres);
+findSceneCuts(pic, bdropFrame, maxUVSad, edgeSad,
isMaxThres, isHardSC);
 }
 }

@@ -1801,6 +1805,8 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
 {
 inFrame->m_lowres.bScenecut = (inputPic->frameData.bScenecut
== 1) ? true : false;
 inFrame->m_lowres.m_bIsMaxThres = isMaxThres;
+if (m_param->radl && m_param->keyframeMax !=
m_param->keyframeMin)
+inFrame->m_lowres.m_bIsHardScenecut = isHardSC;
 }
 if (m_param->bHistBasedSceneCut && m_param->analysisSave)
 {
@@ -4218,10 +4224,10 @@ void Encoder::configure(x265_param *p)
 p->unitSizeDepth = p->maxLog2CUSize - LOG2_UNIT_SIZE;
 p->num4x4Partitions = (1U << (p->unitSizeDepth << 1));

-if (p->radl && (p->keyframeMax != p->

Re: [x265] [PATCH 1 of 2] Improvements to hist-based scenecut algorithm.

2020-06-29 Thread Pooja Venkatesan
>From 671506e40fbbb0aed825013e434c7c39cec2bb93 Mon Sep 17 00:00:00 2001
From: Pooja Venkatesan 
Date: Thu, 25 Jun 2020 20:42:50 +0530
Subject: [PATCH] Improvements to hist-based scenecut algorithm.

This patch does the following:
1. Strengthens scenecut detection using threshold intervals, spatial and
temporal properties.
2. Change default value of hist-threshold to 0.03
---
 doc/reST/cli.rst |  7 +--
 source/common/lowres.cpp |  3 ++
 source/common/lowres.h   |  5 ++
 source/common/param.cpp  |  2 +-
 source/encoder/encoder.cpp   | 25 --
 source/encoder/encoder.h |  5 +-
 source/encoder/slicetype.cpp | 89 +++-
 source/encoder/slicetype.h   |  1 +
 source/x265.h|  2 +-
 9 files changed, 107 insertions(+), 32 deletions(-)

diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
index b9d795ace..23b74c3d8 100644
--- a/doc/reST/cli.rst
+++ b/doc/reST/cli.rst
@@ -1468,9 +1468,10 @@ Slice decision options
 .. option:: --hist-threshold <0.0..1.0>

  This value represents the threshold for normalized SAD of edge histograms
used in scenecut detection.
- This requires :option:`--hist-scenecut` to be enabled. For example, a
value of 0.2 indicates that a frame with normalized SAD value
- greater than 0.2 against the previous frame as scenecut.
- Default 0.01.
+ This requires :option:`--hist-scenecut` to be enabled. For example, a
value of 0.2 indicates that a frame with normalized SAD value
+ greater than 0.2 against the previous frame as scenecut.
+ Increasing the threshold reduces the number of scenecuts detected.
+ Default 0.03.

 .. option:: --radl 

diff --git a/source/common/lowres.cpp b/source/common/lowres.cpp
index e8dd991bc..db1c2d159 100644
--- a/source/common/lowres.cpp
+++ b/source/common/lowres.cpp
@@ -266,6 +266,9 @@ void Lowres::init(PicYuv *origPic, int poc)
 indB = 0;
 memset(costEst, -1, sizeof(costEst));
 memset(weightedCostDelta, 0, sizeof(weightedCostDelta));
+interPCostPercDiff = 0.0;
+intraCostPercDiff = 0.0;
+m_bIsMaxThres = false;

 if (qpAqOffset && invQscaleFactor)
 memset(costEstAq, -1, sizeof(costEstAq));
diff --git a/source/common/lowres.h b/source/common/lowres.h
index 5c50fad67..200b1f032 100644
--- a/source/common/lowres.h
+++ b/source/common/lowres.h
@@ -234,6 +234,11 @@ struct Lowres : public ReferencePlanes
 uint16_t* propagateCost;
 doubleweightedCostDelta[X265_BFRAME_MAX + 2];
 ReferencePlanes weightedRef[X265_BFRAME_MAX + 2];
+/* For hist-based scenecut */
+bool   m_bIsMaxThres;
+double interPCostPercDiff;
+double intraCostPercDiff;
+
 bool create(x265_param* param, PicYuv *origPic, uint32_t qgSize);
 void destroy();
 void init(PicYuv *origPic, int poc);
diff --git a/source/common/param.cpp b/source/common/param.cpp
index 925f0c460..8c0498efc 100644
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -168,7 +168,7 @@ void x265_param_default(x265_param* param)
 param->bFrameAdaptive = X265_B_ADAPT_TRELLIS;
 param->bBPyramid = 1;
 param->scenecutThreshold = 40; /* Magic number pulled in from x264 */
-param->edgeTransitionThreshold = 0.01;
+param->edgeTransitionThreshold = 0.03;
 param->bHistBasedSceneCut = 0;
 param->lookaheadSlices = 8;
 param->lookaheadThreads = 0;
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index f6bc5408d..0c6fd80bf 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -1528,8 +1528,12 @@ double Encoder::normalizeRange(int32_t value,
int32_t minValue, int32_t maxValue
 return (double)(value - minValue) * (rangeEnd - rangeStart) /
(maxValue - minValue) + rangeStart;
 }

-void Encoder::findSceneCuts(x265_picture *pic, bool& bDup, double
maxUVSad, double edgeSad)
+void Encoder::findSceneCuts(x265_picture *pic, bool& bDup, double
maxUVSad, double edgeSad, bool& isMaxThres)
 {
+double minEdgeT = m_edgeHistThreshold * MIN_EDGE_FACTOR;
+double minChromaT = minEdgeT * SCENECUT_CHROMA_FACTOR;
+double maxEdgeT = m_edgeHistThreshold * MAX_EDGE_FACTOR;
+double maxChromaT = maxEdgeT * SCENECUT_CHROMA_FACTOR;
 pic->frameData.bScenecut = false;

 if (pic->poc == 0)
@@ -1544,11 +1548,20 @@ void Encoder::findSceneCuts(x265_picture *pic,
bool& bDup, double maxUVSad, doub
 {
 bDup = true;
 }
-else if (edgeSad > m_scaledEdgeThreshold || maxUVSad >=
m_scaledChromaThreshold || (edgeSad > m_edgeHistThreshold && maxUVSad >=
m_chromaHistThreshold))
+else if (edgeSad < minEdgeT && maxUVSad < minChromaT)
+{
+pic->frameData.bScenecut = false;
+}
+else if (edgeSad > maxEdgeT && maxUVSad > maxChromaT)
+{
+pic->frameData.bScenecut = true;
+isMaxThres = true;
+}
+else if (edgeS

Re: [x265] [PATCH 1 of 2] Improvements to hist-based scenecut algorithm.

2020-06-29 Thread Pooja Venkatesan
Hi,

I am working on the review comments on this patch series. Will be sending
the updated patches soon. Stay tuned!

Regards,
*Pooja Venkatesan*,
Video Codec Engineer,
Media & AI analytics BU



On Thu, Jun 25, 2020 at 9:00 PM Pooja Venkatesan 
wrote:

> From 2777c2e3389eaf556f3420bc0717171bbcf97e52 Mon Sep 17 00:00:00 2001
> From: Pooja Venkatesan 
> Date: Thu, 25 Jun 2020 20:42:50 +0530
> Subject: [PATCH] Improvements to hist-based scenecut algorithm.
>
> This patch does the following:
> 1. Add min and max threshold intervals to detect scenecuts.
> 2. For those within the range,
> Compare colour and edge histogram along with inter and intra satdcosts
> to detect scenecuts.
> 3. Handle scene transitions.
> 4. Change default value of hist-threshold to 0.03
> ---
>  doc/reST/cli.rst |  7 +--
>  source/common/lowres.cpp |  2 +
>  source/common/lowres.h   |  5 ++
>  source/common/param.cpp  |  2 +-
>  source/encoder/encoder.cpp   | 25 --
>  source/encoder/encoder.h |  2 +-
>  source/encoder/slicetype.cpp | 88 +++-
>  source/x265.h|  2 +-
>  8 files changed, 101 insertions(+), 32 deletions(-)
>
> diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
> index b9d795ace..23b74c3d8 100644
> --- a/doc/reST/cli.rst
> +++ b/doc/reST/cli.rst
> @@ -1468,9 +1468,10 @@ Slice decision options
>  .. option:: --hist-threshold <0.0..1.0>
>
>   This value represents the threshold for normalized SAD of edge
> histograms used in scenecut detection.
> - This requires :option:`--hist-scenecut` to be enabled. For example, a
> value of 0.2 indicates that a frame with normalized SAD value
> - greater than 0.2 against the previous frame as scenecut.
> - Default 0.01.
> + This requires :option:`--hist-scenecut` to be enabled. For example, a
> value of 0.2 indicates that a frame with normalized SAD value
> + greater than 0.2 against the previous frame as scenecut.
> + Increasing the threshold reduces the number of scenecuts detected.
> + Default 0.03.
>
>  .. option:: --radl 
>
> diff --git a/source/common/lowres.cpp b/source/common/lowres.cpp
> index e8dd991bc..8e19ac17c 100644
> --- a/source/common/lowres.cpp
> +++ b/source/common/lowres.cpp
> @@ -266,6 +266,8 @@ void Lowres::init(PicYuv *origPic, int poc)
>  indB = 0;
>  memset(costEst, -1, sizeof(costEst));
>  memset(weightedCostDelta, 0, sizeof(weightedCostDelta));
> +interPCostPercDiff = 0.0;
> +intraCostPercDiff = 0.0;
>
>  if (qpAqOffset && invQscaleFactor)
>  memset(costEstAq, -1, sizeof(costEstAq));
> diff --git a/source/common/lowres.h b/source/common/lowres.h
> index 5c50fad67..200b1f032 100644
> --- a/source/common/lowres.h
> +++ b/source/common/lowres.h
> @@ -234,6 +234,11 @@ struct Lowres : public ReferencePlanes
>  uint16_t* propagateCost;
>  doubleweightedCostDelta[X265_BFRAME_MAX + 2];
>  ReferencePlanes weightedRef[X265_BFRAME_MAX + 2];
> +/* For hist-based scenecut */
> +bool   m_bIsMaxThres;
> +double interPCostPercDiff;
> +double intraCostPercDiff;
> +
>  bool create(x265_param* param, PicYuv *origPic, uint32_t qgSize);
>  void destroy();
>  void init(PicYuv *origPic, int poc);
> diff --git a/source/common/param.cpp b/source/common/param.cpp
> index 925f0c460..8c0498efc 100644
> --- a/source/common/param.cpp
> +++ b/source/common/param.cpp
> @@ -168,7 +168,7 @@ void x265_param_default(x265_param* param)
>  param->bFrameAdaptive = X265_B_ADAPT_TRELLIS;
>  param->bBPyramid = 1;
>  param->scenecutThreshold = 40; /* Magic number pulled in from x264 */
> -param->edgeTransitionThreshold = 0.01;
> +param->edgeTransitionThreshold = 0.03;
>  param->bHistBasedSceneCut = 0;
>  param->lookaheadSlices = 8;
>  param->lookaheadThreads = 0;
> diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
> index f6bc5408d..bec7ff5c0 100644
> --- a/source/encoder/encoder.cpp
> +++ b/source/encoder/encoder.cpp
> @@ -1528,8 +1528,12 @@ double Encoder::normalizeRange(int32_t value,
> int32_t minValue, int32_t maxValue
>  return (double)(value - minValue) * (rangeEnd - rangeStart) /
> (maxValue - minValue) + rangeStart;
>  }
>
> -void Encoder::findSceneCuts(x265_picture *pic, bool& bDup, double
> maxUVSad, double edgeSad)
> +void Encoder::findSceneCuts(x265_picture *pic, bool& isMax, bool& bDup,
> double maxUVSad, double edgeSad)
>  {
> +double minEdgeT = m_edgeHistThreshold * 0.5;
> +double minChromaT = minEdgeT * 10.0;
> +double maxEdgeT = m_edgeHistThreshold * 1.5;
> +double maxChromaT = maxEdg

[x265] [PATCH 1 of 2] Improvements to hist-based scenecut algorithm.

2020-06-25 Thread Pooja Venkatesan
>From 2777c2e3389eaf556f3420bc0717171bbcf97e52 Mon Sep 17 00:00:00 2001
From: Pooja Venkatesan 
Date: Thu, 25 Jun 2020 20:42:50 +0530
Subject: [PATCH] Improvements to hist-based scenecut algorithm.

This patch does the following:
1. Add min and max threshold intervals to detect scenecuts.
2. For those within the range,
Compare colour and edge histogram along with inter and intra satdcosts
to detect scenecuts.
3. Handle scene transitions.
4. Change default value of hist-threshold to 0.03
---
 doc/reST/cli.rst |  7 +--
 source/common/lowres.cpp |  2 +
 source/common/lowres.h   |  5 ++
 source/common/param.cpp  |  2 +-
 source/encoder/encoder.cpp   | 25 --
 source/encoder/encoder.h |  2 +-
 source/encoder/slicetype.cpp | 88 +++-
 source/x265.h|  2 +-
 8 files changed, 101 insertions(+), 32 deletions(-)

diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
index b9d795ace..23b74c3d8 100644
--- a/doc/reST/cli.rst
+++ b/doc/reST/cli.rst
@@ -1468,9 +1468,10 @@ Slice decision options
 .. option:: --hist-threshold <0.0..1.0>

  This value represents the threshold for normalized SAD of edge histograms
used in scenecut detection.
- This requires :option:`--hist-scenecut` to be enabled. For example, a
value of 0.2 indicates that a frame with normalized SAD value
- greater than 0.2 against the previous frame as scenecut.
- Default 0.01.
+ This requires :option:`--hist-scenecut` to be enabled. For example, a
value of 0.2 indicates that a frame with normalized SAD value
+ greater than 0.2 against the previous frame as scenecut.
+ Increasing the threshold reduces the number of scenecuts detected.
+ Default 0.03.

 .. option:: --radl 

diff --git a/source/common/lowres.cpp b/source/common/lowres.cpp
index e8dd991bc..8e19ac17c 100644
--- a/source/common/lowres.cpp
+++ b/source/common/lowres.cpp
@@ -266,6 +266,8 @@ void Lowres::init(PicYuv *origPic, int poc)
 indB = 0;
 memset(costEst, -1, sizeof(costEst));
 memset(weightedCostDelta, 0, sizeof(weightedCostDelta));
+interPCostPercDiff = 0.0;
+intraCostPercDiff = 0.0;

 if (qpAqOffset && invQscaleFactor)
 memset(costEstAq, -1, sizeof(costEstAq));
diff --git a/source/common/lowres.h b/source/common/lowres.h
index 5c50fad67..200b1f032 100644
--- a/source/common/lowres.h
+++ b/source/common/lowres.h
@@ -234,6 +234,11 @@ struct Lowres : public ReferencePlanes
 uint16_t* propagateCost;
 doubleweightedCostDelta[X265_BFRAME_MAX + 2];
 ReferencePlanes weightedRef[X265_BFRAME_MAX + 2];
+/* For hist-based scenecut */
+bool   m_bIsMaxThres;
+double interPCostPercDiff;
+double intraCostPercDiff;
+
 bool create(x265_param* param, PicYuv *origPic, uint32_t qgSize);
 void destroy();
 void init(PicYuv *origPic, int poc);
diff --git a/source/common/param.cpp b/source/common/param.cpp
index 925f0c460..8c0498efc 100644
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -168,7 +168,7 @@ void x265_param_default(x265_param* param)
 param->bFrameAdaptive = X265_B_ADAPT_TRELLIS;
 param->bBPyramid = 1;
 param->scenecutThreshold = 40; /* Magic number pulled in from x264 */
-param->edgeTransitionThreshold = 0.01;
+param->edgeTransitionThreshold = 0.03;
 param->bHistBasedSceneCut = 0;
 param->lookaheadSlices = 8;
 param->lookaheadThreads = 0;
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index f6bc5408d..bec7ff5c0 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -1528,8 +1528,12 @@ double Encoder::normalizeRange(int32_t value,
int32_t minValue, int32_t maxValue
 return (double)(value - minValue) * (rangeEnd - rangeStart) /
(maxValue - minValue) + rangeStart;
 }

-void Encoder::findSceneCuts(x265_picture *pic, bool& bDup, double
maxUVSad, double edgeSad)
+void Encoder::findSceneCuts(x265_picture *pic, bool& isMax, bool& bDup,
double maxUVSad, double edgeSad)
 {
+double minEdgeT = m_edgeHistThreshold * 0.5;
+double minChromaT = minEdgeT * 10.0;
+double maxEdgeT = m_edgeHistThreshold * 1.5;
+double maxChromaT = maxEdgeT * 10.0;
 pic->frameData.bScenecut = false;

 if (pic->poc == 0)
@@ -1544,11 +1548,20 @@ void Encoder::findSceneCuts(x265_picture *pic,
bool& bDup, double maxUVSad, doub
 {
 bDup = true;
 }
-else if (edgeSad > m_scaledEdgeThreshold || maxUVSad >=
m_scaledChromaThreshold || (edgeSad > m_edgeHistThreshold && maxUVSad >=
m_chromaHistThreshold))
+else if (edgeSad < minEdgeT && maxUVSad < minChromaT)
+{
+pic->frameData.bScenecut = false;
+}
+else if (edgeSad > maxEdgeT && maxUVSad > maxChromaT)
+{
+pic->frameData.bScenecut = true;
+isMax = true;
+}
+else if (edgeSad > m_sc

[x265] [PATCH 2 of 2] Add support for RADL pictures at IDR scenecuts.

2020-06-25 Thread Pooja Venkatesan
>From 9d8c8657374b1154cab1a75ac6e23d04be58015c Mon Sep 17 00:00:00 2001
From: Pooja Venkatesan 
Date: Thu, 25 Jun 2020 20:48:22 +0530
Subject: [PATCH] Add support for RADL pictures at IDR scenecuts.

---
 source/common/lowres.h   |  1 +
 source/encoder/encoder.cpp   | 21 +
 source/encoder/encoder.h |  2 +-
 source/encoder/slicetype.cpp | 13 -
 4 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/source/common/lowres.h b/source/common/lowres.h
index 200b1f032..a0ec05b25 100644
--- a/source/common/lowres.h
+++ b/source/common/lowres.h
@@ -238,6 +238,7 @@ struct Lowres : public ReferencePlanes
 bool   m_bIsMaxThres;
 double interPCostPercDiff;
 double intraCostPercDiff;
+bool m_bIsHardScenecut;

 bool create(x265_param* param, PicYuv *origPic, uint32_t qgSize);
 void destroy();
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index bec7ff5c0..c9bcf2664 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -1528,11 +1528,11 @@ double Encoder::normalizeRange(int32_t value,
int32_t minValue, int32_t maxValue
 return (double)(value - minValue) * (rangeEnd - rangeStart) /
(maxValue - minValue) + rangeStart;
 }

-void Encoder::findSceneCuts(x265_picture *pic, bool& isMax, bool& bDup,
double maxUVSad, double edgeSad)
+void Encoder::findSceneCuts(x265_picture *pic, bool& isMax, bool&
isHardSC, bool& bDup, double maxUVSad, double edgeSad)
 {
-double minEdgeT = m_edgeHistThreshold * 0.5;
-double minChromaT = minEdgeT * 10.0;
-double maxEdgeT = m_edgeHistThreshold * 1.5;
+double minEdgeT = m_edgeHistThreshold * 0.5;
+double minChromaT = minEdgeT * 10.0;
+double maxEdgeT = m_edgeHistThreshold * 1.5;
 double maxChromaT = maxEdgeT * 10.0;
 pic->frameData.bScenecut = false;

@@ -1555,11 +1555,14 @@ void Encoder::findSceneCuts(x265_picture *pic,
bool& isMax, bool& bDup, double m
 else if (edgeSad > maxEdgeT && maxUVSad > maxChromaT)
 {
 pic->frameData.bScenecut = true;
+isHardSC = true;
 isMax = true;
 }
 else if (edgeSad > m_scaledEdgeThreshold || maxUVSad >=
m_scaledChromaThreshold
  || (edgeSad > m_edgeHistThreshold && maxUVSad >=
m_chromaHistThreshold))
 {
+if (edgeSad > m_scaledEdgeThreshold || maxUVSad >=
m_scaledChromaThreshold)
+isHardSC = true;
 pic->frameData.bScenecut = true;
 bDup = false;
 }
@@ -1594,7 +1597,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
 bool dontRead = false;
 bool bdropFrame = false;
 bool dropflag = false;
-bool isMaxThreshold = false;
+bool isMaxThreshold = false, isHardSC = false;

 if (m_exportedPic)
 {
@@ -1621,7 +1624,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
 {
 double maxUVSad = 0.0, edgeSad = 0.0;
 computeHistogramSAD(, , pic_in->poc);
-findSceneCuts(pic, isMaxThreshold, bdropFrame, maxUVSad,
edgeSad);
+findSceneCuts(pic, isMaxThreshold, isHardSC, bdropFrame,
maxUVSad, edgeSad);
 }
 }

@@ -1801,6 +1804,8 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture* pic_out)
 {
 inFrame->m_lowres.bScenecut = (inputPic->frameData.bScenecut
== 1) ? true : false;
 inFrame->m_lowres.m_bIsMaxThres = isMaxThreshold;
+if (m_param->radl && m_param->keyframeMax !=
m_param->keyframeMin)
+inFrame->m_lowres.m_bIsHardScenecut = isHardSC;
 }
 if (m_param->bHistBasedSceneCut && m_param->analysisSave)
 {
@@ -4218,10 +4223,10 @@ void Encoder::configure(x265_param *p)
 p->unitSizeDepth = p->maxLog2CUSize - LOG2_UNIT_SIZE;
 p->num4x4Partitions = (1U << (p->unitSizeDepth << 1));

-if (p->radl && (p->keyframeMax != p->keyframeMin))
+if (p->radl && p->bOpenGOP)
 {
 p->radl = 0;
-x265_log(p, X265_LOG_WARNING, "Radl requires fixed gop-length
(keyint == min-keyint). Disabling radl.\n");
+x265_log(p, X265_LOG_WARNING, "Radl requires closed gop structure.
Disabling radl.\n");
 }

 if ((p->chunkStart || p->chunkEnd) && p->bOpenGOP &&
m_param->bResetZoneConfig)
diff --git a/source/encoder/encoder.h b/source/encoder/encoder.h
index 1d4fe2476..4fbd234c2 100644
--- a/source/encoder/encoder.h
+++ b/source/encoder/encoder.h
@@ -373,7 +373,7 @@ public:
 bool computeHistograms(x265_picture *pic);
 void computeHistogramSAD(double *maxUVNormalizedSAD, double
*edgeNormalizedSAD, int curPoc);
 double normalizeRange(int32_t value, int32_t minValue, int32_t
max

[x265] [PATCH] scaler: Update copyrights details

2020-03-31 Thread Pooja Venkatesan
# HG changeset patch
# User Pooja Venkatesan 
# Date 1585660434 -19800
#  Tue Mar 31 18:43:54 2020 +0530
# Node ID 5031d38328aab3f39f29a4e50ed4cff9ec925f30
# Parent  7ebf4b9369b3037370a73be24f5f1bd93cce7822
scaler: Update copyrights details

diff -r 7ebf4b9369b3 -r 5031d38328aa source/common/scaler.cpp
--- a/source/common/scaler.cpp Wed Feb 26 14:40:35 2020 +0530
+++ b/source/common/scaler.cpp Tue Mar 31 18:43:54 2020 +0530
@@ -1,3 +1,26 @@
+/*
+* Copyright (C) 2013-2020 MulticoreWare, Inc
+*
+* Authors: Pooja Venkatesan 
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111,
USA.
+*
+* This program is also available under a commercial proprietary license.
+* For more information, contact us at license @ x265.com.
+*/
+
 #include "scaler.h"

 #if _MSC_VER
diff -r 7ebf4b9369b3 -r 5031d38328aa source/common/scaler.h
--- a/source/common/scaler.h Wed Feb 26 14:40:35 2020 +0530
+++ b/source/common/scaler.h Tue Mar 31 18:43:54 2020 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2020 MulticoreWare, Inc
+ * Copyright (C) 2013-2020 MulticoreWare, Inc
  *
  * Authors: Pooja Venkatesan 
  *


x265.patch
Description: Binary data
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


Re: [x265] [PATCH] Add option hme-range to modify search range for HME levels L0, L1 and L2

2019-12-02 Thread Pooja Venkatesan
Hi Aruna,
I have incorporated the changes suggested by you. Thanks and PFA the
modified patch.

# HG changeset patch
# User Pooja Venkatesan 
# Date 1568196486 -19800
#  Wed Sep 11 15:38:06 2019 +0530
# Node ID 7685a9d072a229f41813f7d61a53c82d019911ec
# Parent  f8a38d6ef1ebbaf928fae6c34c17dd4c65fda485
Add option hme-range to modify search range for HME levels L0, L1 and L2.

diff -r f8a38d6ef1eb -r 7685a9d072a2 doc/reST/cli.rst
--- a/doc/reST/cli.rst Thu Nov 28 18:37:53 2019 +0530
+++ b/doc/reST/cli.rst Wed Sep 11 15:38:06 2019 +0530
@@ -1290,6 +1290,12 @@
which will apply to all levels. Default is hex,umh,umh for
levels 0,1,2 respectively.

+.. option:: --hme-range ,,
+
+ Search range for HME level 0, 1 and 2.
+ The Search Range for each HME level must be between 0 and
32768(excluding).
+ Default search range is 16,32,48 for level 0,1,2 respectively.
+
 Spatial/intra options
 =

diff -r f8a38d6ef1eb -r 7685a9d072a2 source/CMakeLists.txt
--- a/source/CMakeLists.txt Thu Nov 28 18:37:53 2019 +0530
+++ b/source/CMakeLists.txt Wed Sep 11 15:38:06 2019 +0530
@@ -29,7 +29,7 @@
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 183)
+set(X265_BUILD 184)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
"${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r f8a38d6ef1eb -r 7685a9d072a2 source/common/param.cpp
--- a/source/common/param.cpp Thu Nov 28 18:37:53 2019 +0530
+++ b/source/common/param.cpp Wed Sep 11 15:38:06 2019 +0530
@@ -210,6 +210,9 @@
 param->bEnableHME = 0;
 param->hmeSearchMethod[0] = X265_HEX_SEARCH;
 param->hmeSearchMethod[1] = param->hmeSearchMethod[2] =
X265_UMH_SEARCH;
+param->hmeRange[0] = 16;
+param->hmeRange[1] = 32;
+param->hmeRange[2] = 48;
 param->bSourceReferenceEstimation = 0;
 param->limitTU = 0;
 param->dynamicRd = 0;
@@ -1344,6 +1347,11 @@
 }
 p->bEnableHME = true;
 }
+OPT("hme-range")
+{
+sscanf(value, "%d,%d,%d", >hmeRange[0], >hmeRange[1],
>hmeRange[2]);
+p->bEnableHME = true;
+}
 else
 return X265_PARAM_BAD_NAME;
 }
@@ -1734,6 +1742,9 @@
 "Invalid scenecut Window duration. Value must be between 0 and
1000(inclusive)");
 CHECK(param->maxQpDelta < 0 || param->maxQpDelta > 10,
 "Invalid maxQpDelta value. Value must be between 0 and 10
(inclusive)");
+for(int level = 0; level < 3; level++)
+CHECK(param->hmeRange[level] < 0 || param->hmeRange[level] >=
32768,
+"Search Range for HME levels must be between 0 and 32768");
 #if !X86_64
 CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 ||
param->sourceHeight > 480),
 "SEA motion search does not support resolutions greater than 480p
in 32 bit build");
@@ -2019,7 +2030,10 @@
 s += sprintf(s, " dup-threshold=%d", p->dupThreshold);
 BOOL(p->bEnableHME, "hme");
 if (p->bEnableHME)
+{
 s += sprintf(s, " Level 0,1,2=%d,%d,%d", p->hmeSearchMethod[0],
p->hmeSearchMethod[1], p->hmeSearchMethod[2]);
+s += sprintf(s, " merange L0,L1,L2=%d,%d,%d", p->hmeRange[0],
p->hmeRange[1], p->hmeRange[2]);
+}
 BOOL(p->bEnableWeightedPred, "weightp");
 BOOL(p->bEnableWeightedBiPred, "weightb");
 BOOL(p->bSourceReferenceEstimation, "analyze-src-pics");
@@ -2320,7 +2334,10 @@
 if (src->bEnableHME)
 {
 for (int level = 0; level < 3; level++)
+{
 dst->hmeSearchMethod[level] = src->hmeSearchMethod[level];
+dst->hmeRange[level] = src->hmeRange[level];
+}
 }
 dst->bEnableWeightedBiPred = src->bEnableWeightedBiPred;
 dst->bEnableWeightedPred = src->bEnableWeightedPred;
diff -r f8a38d6ef1eb -r 7685a9d072a2 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Thu Nov 28 18:37:53 2019 +0530
+++ b/source/encoder/encoder.cpp Wed Sep 11 15:38:06 2019 +0530
@@ -4079,10 +4079,14 @@
 x265_log(p, X265_LOG_WARNING, "Source height < 540p is too low
for HME. Disabling HME.\n");
 p->bEnableHME = 0;
 }
-if (m_param->bEnableHME && m_param->searchMethod !=
m_param->hmeSearchMethod[2])
-{
+}
+
+if (m_param->bEnableHME)
+{
+if (m_param->searchMethod != m_param->hmeSearchMethod[2])
 m_param->searchMethod = m_param->hmeSearchMethod[2];

[x265] [PATCH] Add option hme-range to modify search range for HME levels L0, L1 and L2

2019-11-29 Thread Pooja Venkatesan
# HG changeset patch
# User Pooja Venkatesan 
# Date 1568196486 -19800
#  Wed Sep 11 15:38:06 2019 +0530
# Node ID c31884e780444d00ee7a25ccbb32a9b9fd52f47a
# Parent  4a29e0c5bfaf30aaed2c5224bcba1f464d68de83
Add option hme-range to modify search range for HME levels L0, L1 and L2.

diff -r 4a29e0c5bfaf -r c31884e78044 doc/reST/cli.rst
--- a/doc/reST/cli.rst Fri Nov 08 15:30:50 2019 +0530
+++ b/doc/reST/cli.rst Wed Sep 11 15:38:06 2019 +0530
@@ -1290,6 +1290,11 @@
which will apply to all levels. Default is hex,umh,umh for
levels 0,1,2 respectively.

+.. option:: --hme-range ,,
+
+ Search range for HME level 0, 1 and 2.
+ Default search range is 16,32,48 for level 0,1,2 respectively.
+
 Spatial/intra options
 =

diff -r 4a29e0c5bfaf -r c31884e78044 source/CMakeLists.txt
--- a/source/CMakeLists.txt Fri Nov 08 15:30:50 2019 +0530
+++ b/source/CMakeLists.txt Wed Sep 11 15:38:06 2019 +0530
@@ -29,7 +29,7 @@
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 183)
+set(X265_BUILD 184)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
"${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 4a29e0c5bfaf -r c31884e78044 source/common/param.cpp
--- a/source/common/param.cpp Fri Nov 08 15:30:50 2019 +0530
+++ b/source/common/param.cpp Wed Sep 11 15:38:06 2019 +0530
@@ -210,6 +210,9 @@
 param->bEnableHME = 0;
 param->hmeSearchMethod[0] = X265_HEX_SEARCH;
 param->hmeSearchMethod[1] = param->hmeSearchMethod[2] =
X265_UMH_SEARCH;
+param->hmeRange[0] = 16;
+param->hmeRange[1] = 32;
+param->hmeRange[2] = 48;
 param->bSourceReferenceEstimation = 0;
 param->limitTU = 0;
 param->dynamicRd = 0;
@@ -1344,6 +1347,11 @@
 }
 p->bEnableHME = true;
 }
+OPT("hme-range")
+{
+sscanf(value, "%d,%d,%d", >hmeRange[0], >hmeRange[1],
>hmeRange[2]);
+p->bEnableHME = true;
+}
 else
 return X265_PARAM_BAD_NAME;
 }
@@ -1734,6 +1742,9 @@
 "Invalid scenecut Window duration. Value must be between 0 and
1000(inclusive)");
 CHECK(param->maxQpDelta < 0 || param->maxQpDelta > 10,
 "Invalid maxQpDelta value. Value must be between 0 and 10
(inclusive)");
+for(int level=0; level < 3; level++)
+CHECK(param->hmeRange[level] < 0 || param->hmeRange[level] >=
32768,
+"Search Range for HME levels must be between 0 and 32768");
 #if !X86_64
 CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 ||
param->sourceHeight > 480),
 "SEA motion search does not support resolutions greater than 480p
in 32 bit build");
@@ -2018,8 +2029,10 @@
 if(p->bEnableFrameDuplication)
 s += sprintf(s, " dup-threshold=%d", p->dupThreshold);
 BOOL(p->bEnableHME, "hme");
-if (p->bEnableHME)
+if (p->bEnableHME){
 s += sprintf(s, " Level 0,1,2=%d,%d,%d", p->hmeSearchMethod[0],
p->hmeSearchMethod[1], p->hmeSearchMethod[2]);
+s += sprintf(s, " merange L0,L1,L2=%d,%d,%d", p->hmeRange[0],
p->hmeRange[1], p->hmeRange[2]);
+}
 BOOL(p->bEnableWeightedPred, "weightp");
 BOOL(p->bEnableWeightedBiPred, "weightb");
 BOOL(p->bSourceReferenceEstimation, "analyze-src-pics");
@@ -2320,7 +2333,10 @@
 if (src->bEnableHME)
 {
 for (int level = 0; level < 3; level++)
+{
 dst->hmeSearchMethod[level] = src->hmeSearchMethod[level];
+dst->hmeRange[level] = src->hmeRange[level];
+}
 }
 dst->bEnableWeightedBiPred = src->bEnableWeightedBiPred;
 dst->bEnableWeightedPred = src->bEnableWeightedPred;
diff -r 4a29e0c5bfaf -r c31884e78044 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Fri Nov 08 15:30:50 2019 +0530
+++ b/source/encoder/encoder.cpp Wed Sep 11 15:38:06 2019 +0530
@@ -4077,11 +4077,12 @@
 x265_log(p, X265_LOG_WARNING, "Source height < 540p is too low
for HME. Disabling HME.\n");
 p->bEnableHME = 0;
 }
-if (m_param->bEnableHME && m_param->searchMethod !=
m_param->hmeSearchMethod[2])
-{
-m_param->searchMethod = m_param->hmeSearchMethod[2];
-}
-}
+}
+
+if (m_param->bEnableHME && m_param->searchMethod !=
m_param->hmeSearchMethod[2])
+m_param->searchMethod = m_param->hmeSearchMethod[2];
+if (m_param->

Re: [x265] [PATCH 2 of 2] Implement slice-level SAO filter

2019-09-11 Thread Pooja Venkatesan
Please ignore this patch. I have sent an updated version which can be found
in the link -
https://mailman.videolan.org/pipermail/x265-devel/2019-September/012662.html


On Tue, Sep 10, 2019 at 11:08 AM  wrote:

> # HG changeset patch
> # User Soundariya Ranin Venkatesh 
> # Date 1567501320 -19800
> #  Tue Sep 03 14:32:00 2019 +0530
> # Node ID b1799841d3307237a741eb7d097cba2efd76f1eb
> # Parent  f6d9a0145c4fcd7ac0a2a776a4f99fc431f8fd4a
> Implement slice-level SAO filter.
>
> diff -r f6d9a0145c4f -r b1799841d330 source/encoder/frameencoder.cpp
> --- a/source/encoder/frameencoder.cpp   Tue Sep 03 14:25:44 2019 +0530
> +++ b/source/encoder/frameencoder.cpp   Tue Sep 03 14:32:00 2019 +0530
> @@ -634,14 +634,22 @@
>  if (!m_param->bEnableWavefront)
>  m_backupStreams = new Bitstream[numSubstreams];
>  m_substreamSizes = X265_MALLOC(uint32_t, numSubstreams);
> -if (!m_param->enableSAO)
> +if (!slice->m_bUseSao)
> +{
>  for (uint32_t i = 0; i < numSubstreams; i++)
>  m_rows[i].rowGoOnCoder.setBitstream(_outStreams[i]);
> +}
>  }
>  else
>  {
>  for (uint32_t i = 0; i < numSubstreams; i++)
> +{
>  m_outStreams[i].resetBits();
> +if (!slice->m_bUseSao)
> +m_rows[i].rowGoOnCoder.setBitstream(_outStreams[i]);
> +else
> +m_rows[i].rowGoOnCoder.setBitstream(NULL);
> +}
>  }
>
>  m_rce.encodeOrder = m_frame->m_encodeOrder;
> @@ -981,7 +989,7 @@
>  m_entropyCoder.setBitstream(_bs);
>
>  // finish encode of each CTU row, only required when SAO is enabled
> -if (m_param->enableSAO)
> +if (slice->m_bUseSao)
>  encodeSlice(0);
>
>  m_entropyCoder.setBitstream(_bs);
> @@ -1221,7 +1229,7 @@
>  const uint32_t lastCUAddr = (slice->m_endCUAddr +
> m_param->num4x4Partitions - 1) / m_param->num4x4Partitions;
>  const uint32_t numSubstreams = m_param->bEnableWavefront ?
> slice->m_sps->numCuInHeight : 1;
>
> -SAOParam* saoParam = slice->m_sps->bUseSAO ?
> m_frame->m_encData->m_saoParam : NULL;
> +SAOParam* saoParam = slice->m_sps->bUseSAO && slice->m_bUseSao ?
> m_frame->m_encData->m_saoParam : NULL;
>  for (uint32_t cuAddr = sliceAddr; cuAddr < lastCUAddr; cuAddr++)
>  {
>  uint32_t col = cuAddr % widthInLCUs;
> @@ -1515,11 +1523,11 @@
>  curRow.bufferedEntropy.loadContexts(rowCoder);
>
>  /* SAO parameter estimation using non-deblocked pixels for CTU
> bottom and right boundary areas */
> -if (m_param->enableSAO && m_param->bSaoNonDeblocked)
> +if (slice->m_bUseSao && m_param->bSaoNonDeblocked)
>
>  m_frameFilter.m_parallelFilter[row].m_sao.calcSaoStatsCu_BeforeDblk(m_frame,
> col, row);
>
>  /* Deblock with idle threading */
> -if (m_param->bEnableLoopFilter | m_param->enableSAO)
> +if (m_param->bEnableLoopFilter | slice->m_bUseSao)
>  {
>  // NOTE: in VBV mode, we may reencode anytime, so we can't do
> Deblock stage-Horizon and SAO
>  if (!bIsVbv)
> @@ -1833,12 +1841,12 @@
>
>  /* flush row bitstream (if WPP and no SAO) or flush frame if no WPP
> and no SAO */
>  /* end_of_sub_stream_one_bit / end_of_slice_segment_flag */
> -if (!m_param->enableSAO && (m_param->bEnableWavefront ||
> bLastRowInSlice))
> -rowCoder.finishSlice();
> +   if (!slice->m_bUseSao && (m_param->bEnableWavefront ||
> bLastRowInSlice))
> +   rowCoder.finishSlice();
>
>
>  /* Processing left Deblock block with current threading */
> -if ((m_param->bEnableLoopFilter | m_param->enableSAO) & (rowInSlice
> >= 2))
> +if ((m_param->bEnableLoopFilter | slice->m_bUseSao) & (rowInSlice >=
> 2))
>  {
>  /* Check conditional to start previous row process with current
> threading */
>  if (m_frameFilter.m_parallelFilter[row - 2].m_lastDeblocked.get()
> == (int)numCols)
> diff -r f6d9a0145c4f -r b1799841d330 source/encoder/frameencoder.h
> --- a/source/encoder/frameencoder.h Tue Sep 03 14:25:44 2019 +0530
> +++ b/source/encoder/frameencoder.h Tue Sep 03 14:32:00 2019 +0530
> @@ -150,6 +150,7 @@
>  uint32_t m_filterRowDelay;
>  uint32_t m_filterRowDelayCus;
>  uint32_t m_refLagRows;
> +bool m_bUseSao;
>
>  CTURow*  m_rows;
>  uint16_t m_sliceAddrBits;
>
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


Re: [x265] [PATCH 1 of 2] Add option to enable slicetype based SAO filter

2019-09-11 Thread Pooja Venkatesan
Please ignore this patch. I have sent an updated version which can be found
in the link -
https://mailman.videolan.org/pipermail/x265-devel/2019-September/012661.html

On Tue, Sep 10, 2019 at 11:08 AM  wrote:

> # HG changeset patch
> # User Pooja Venkatesan 
> # Date 1567500944 -19800
> #  Tue Sep 03 14:25:44 2019 +0530
> # Node ID f6d9a0145c4fcd7ac0a2a776a4f99fc431f8fd4a
> # Parent  a092e82e6acfe7afe6a9a381e9ef52323e4e2467
> Add option to enable slicetype based SAO filter.
>
> diff -r a092e82e6acf -r f6d9a0145c4f doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Thu Aug 01 22:55:21 2019 +0200
> +++ b/doc/reST/cli.rst  Tue Sep 03 14:25:44 2019 +0530
> @@ -1979,9 +1979,22 @@
> If deblocking is disabled, or the offsets are non-zero, these
> changes from the default configuration are signaled in the PPS.
>
> -.. option:: --sao, --no-sao
> -
> -   Toggle Sample Adaptive Offset loop filter, default enabled
> +.. option:: --sao <0..4>
> +
> +   Toggle Sample Adaptive Offset loop filter at slice level. Default
> 4.
> +   +--+---+
> +   | Level|  Description  |
> +   +==+===+
> +   |  0   | Disable SAO for all slices|
> +   +--+---+
> +   |  1   | Enable SAO only for I-slices  |
> +   +--+---+
> +   |  2   | Enable SAO for I-slices & P-slices|
> +   +--+---+
> +   |  3   | Enable SAO for all reference slices   |
> +   +--+---+
> +   |  4   | Enable SAO for all slices |
> +   +--+---+
>
>  .. option:: --sao-non-deblock, --no-sao-non-deblock
>
> diff -r a092e82e6acf -r f6d9a0145c4f source/common/param.cpp
> --- a/source/common/param.cpp   Thu Aug 01 22:55:21 2019 +0200
> +++ b/source/common/param.cpp   Tue Sep 03 14:25:44 2019 +0530
> @@ -212,7 +212,7 @@
>  param->bEnableLoopFilter = 1;
>
>  /* SAO Loop Filter */
> -param->bEnableSAO = 1;
> +param->enableSAO = 4;
>  param->bSaoNonDeblocked = 0;
>  param->bLimitSAO = 0;
>
> @@ -374,7 +374,7 @@
>  param->bFrameAdaptive = 0;
>  param->subpelRefine = 0;
>  param->searchMethod = X265_DIA_SEARCH;
> -param->bEnableSAO = 0;
> +param->enableSAO = 0;
>  param->bEnableSignHiding = 0;
>  param->bEnableWeightedPred = 0;
>  param->rdLevel = 2;
> @@ -403,7 +403,7 @@
>  param->rc.aqMode = X265_AQ_NONE;
>  param->rc.hevcAq = 0;
>  param->rc.qgSize = 32;
> -param->bEnableSAO = 0;
> +param->enableSAO = 0;
>  param->bEnableFastIntra = 1;
>  }
>  else if (!strcmp(preset, "veryfast"))
> @@ -550,7 +550,7 @@
>   !strcmp(tune, "fast-decode"))
>  {
>  param->bEnableLoopFilter = 0;
> -param->bEnableSAO = 0;
> +param->enableSAO = 0;
>  param->bEnableWeightedPred = 0;
>  param->bEnableWeightedBiPred = 0;
>  param->bIntraInBFrames = 0;
> @@ -577,7 +577,7 @@
>  param->bEnableRecursionSkip = 0;
>  param->psyRd = 4.0;
>  param->psyRdoq = 10.0;
> -param->bEnableSAO = 0;
> +param->enableSAO = 0;
>  param->rc.bEnableConstVbv = 1;
>  }
>  else if (!strcmp(tune, "animation"))
> @@ -1001,7 +1001,7 @@
>  else
>  p->bEnableLoopFilter = atobool(value);
>  }
> -OPT("sao") p->bEnableSAO = atobool(value);
> +OPT("sao") p->enableSAO = atoi(value);
>  OPT("sao-non-deblock") p->bSaoNonDeblocked = atobool(value);
>  OPT("ssim") p->bEnableSsim = atobool(value);
>  OPT("psnr") p->bEnablePsnr = atobool(value);
> @@ -1861,7 +1861,7 @@
>  TOOLOPT(param->bEnableLoopFilter, "deblock");
>  }
>  TOOLOPT(param->bSaoNonDeblocked, "sao-non-deblock");
> -TOOLOPT(!param->bSaoNonDeblocked && param->bEnableSAO, "sao");
> +TOOLOPT(!param->bSaoNonDeblocked && param->enableSAO, "sao");
> 

Re: [x265] [PATCH] motion: Modify "--refine-mv" option

2019-09-04 Thread Pooja Venkatesan
Sure.

On Wed, Sep 4, 2019 at 12:52 PM Aruna Matheswaran <
ar...@multicorewareinc.com> wrote:

> The patch is not applying on default. Could you please rebase it on the
> latest default tip and resend the patch?
>
> On Fri, Aug 23, 2019 at 12:40 PM  wrote:
>
>> # HG changeset patch
>> # User Pooja Venkatesan
>> # Date 1566540185 -19800
>> #  Fri Aug 23 11:33:05 2019 +0530
>> # Node ID ff2a24a84069327711f08d8ea026bf7383013f21
>> # Parent  de920e0a31831f52599f3937c3ee6945e88ed851
>> motion: Modify "--refine-mv" option
>>
>> Add MV refinement level 1,2 and 3.
>> Based on the MV refinement level, number of search increases.
>>
>> diff -r de920e0a3183 -r ff2a24a84069 doc/reST/cli.rst
>> --- a/doc/reST/cli.rst  Tue Jul 23 17:03:51 2019 +0530
>> +++ b/doc/reST/cli.rst  Fri Aug 23 11:33:05 2019 +0530
>> @@ -997,11 +997,14 @@
>> the encoder settings. It is recommended to use
>> :option:`--refine-intra` 4 with dynamic
>> refinement. Default disabled.
>>
>> -.. option:: --refine-mv
>> -
>> +.. option:: --refine-mv <0..3>
>> +
>> Enables refinement of motion vector for scaled video. Evaluates
>> the best
>> -   motion vector by searching the surrounding eight integer and
>> subpel pixel
>> -   positions.
>> +   motion vector based on the level selected. Default 0 - disabled.
>> +
>> +   Level 1 - Search around scaled MV.
>> +   Level 2 - Level 1 + Search around best AMVP cand.
>> +   Level 3 - Level 2 + Search around the other AMVP cand.
>>
>>  Options which affect the transform unit quad-tree, sometimes referred to
>>  as the residual quad-tree (RQT).
>> diff -r de920e0a3183 -r ff2a24a84069 source/common/param.cpp
>> --- a/source/common/param.cpp   Tue Jul 23 17:03:51 2019 +0530
>> +++ b/source/common/param.cpp   Fri Aug 23 11:33:05 2019 +0530
>> @@ -1209,7 +1209,7 @@
>>  OPT("scale-factor") p->scaleFactor = atoi(value);
>>  OPT("refine-intra")p->intraRefine = atoi(value);
>>  OPT("refine-inter")p->interRefine = atoi(value);
>> -OPT("refine-mv")p->mvRefine = atobool(value);
>> +OPT("refine-mv")p->mvRefine = atoi(value);
>>  OPT("force-flush")p->forceFlush = atoi(value);
>>  OPT("splitrd-skip") p->bEnableSplitRdSkip = atobool(value);
>>  OPT("lowpass-dct") p->bLowPassDct = atobool(value);
>> @@ -1650,6 +1650,8 @@
>>"Strict-cbr cannot be applied without specifying target
>> bitrate or vbv bufsize");
>>  CHECK((param->analysisSave || param->analysisLoad) &&
>> (param->analysisReuseLevel < 1 || param->analysisReuseLevel > 10),
>>  "Invalid analysis refine level. Value must be between 1 and 10
>> (inclusive)");
>> +CHECK(param->analysisLoad && (param->mvRefine < 0 || param->mvRefine
>> > 3),
>> +"Invalid mv refinement level. Value must be between 0 and 3
>> (inclusive)");
>>  CHECK(param->scaleFactor > 2, "Invalid scale-factor. Supports factor
>> <= 2");
>>  CHECK(param->rc.qpMax < QP_MIN || param->rc.qpMax > QP_MAX_MAX,
>>  "qpmax exceeds supported range (0 to 69)");
>> diff -r de920e0a3183 -r ff2a24a84069 source/encoder/analysis.cpp
>> --- a/source/encoder/analysis.cpp   Tue Jul 23 17:03:51 2019 +0530
>> +++ b/source/encoder/analysis.cpp   Fri Aug 23 11:33:05 2019 +0530
>> @@ -2488,14 +2488,18 @@
>>  MV mvp;
>>
>>  int numMvc =
>> mode.cu.getPMV(mode.interNeighbours, list, ref, mode.amvpCand[list][ref],
>> mvc);
>> -if (m_param->interRefine != 1)
>> -mvp =
>> mode.amvpCand[list][ref][mode.cu.m_mvpIdx[list][pu.puAbsPartIdx]];
>> -else
>> -mvp = interDataCTU->mv[list][cuIdx +
>> part].word;
>> +mvp =
>> mode.amvpCand[list][ref][mode.cu.m_mvpIdx[list][pu.puAbsPartIdx]];
>>  if (m_param->mvRefine ||
>> m_param->interRefine == 1)
>>  {
>> -MV outmv;
>> -searchMV(mode, pu, list, ref, outmv,
>> mvp, numMvc, mvc);
>> +MV 

Re: [x265] Segfault with hme-search=star

2019-07-25 Thread Pooja Venkatesan
Hi,

Thanks for pointing out.
Can you please verify whether the patch found in the link below resolves
your issue.
Link -
https://mailman.videolan.org/pipermail/x265-devel/2019-July/012601.html

Thanks.
Pooja

On Thu, Jul 25, 2019 at 10:21 PM Grozdan  wrote:

> Hi,
>
> On Linux, I'm getting a segfault when hme-search is set to star or
> star is used for L0. Using hme-search=umh,star,star works with no
> issues. All other combinations do so too
>
> Users on the doom9 forum have also posted about this segfault
> ___
> x265-devel mailing list
> x265-devel@videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH] motion: Enable star search for HME Level-0

2019-07-25 Thread Pooja Venkatesan
# HG changeset patch
# User Pooja Venkatesan 
# Date 1564118589 -19800
#  Fri Jul 26 10:53:09 2019 +0530
# Node ID 661effca62e3904bf3577ac4b60670e2f17f643e
# Parent  21db162c8622677c41a4fc77a14a59eb7326b46a
motion: Enable star search for HME Level-0

diff -r 21db162c8622 -r 661effca62e3 source/encoder/motion.cpp
--- a/source/encoder/motion.cpp Fri Jul 12 16:22:24 2019 +0530
+++ b/source/encoder/motion.cpp Fri Jul 26 10:53:09 2019 +0530
@@ -367,12 +367,13 @@
int &bPointNr,
int &bDistance,
int  earlyExitIters,
-   int  merange)
+   int  merange,
+   int  hme)
 {
 ALIGN_VAR_16(int, costs[16]);
 pixel* fenc = fencPUYuv.m_buf[0];
-pixel* fref = ref->fpelPlane[0] + blockOffset;
-intptr_t stride = ref->lumaStride;
+pixel* fref = (hme? ref->fpelLowerResPlane[0] : ref->fpelPlane[0]) + 
blockOffset;
+intptr_t stride = hme? ref->lumaStride / 2 : ref->lumaStride;
 
 MV omv = bmv;
 int saved = bcost;
@@ -1134,7 +1135,7 @@
 int bDistance = 0;
 
 const int EarlyExitIters = 3;
-StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bPointNr, bDistance, 
EarlyExitIters, merange);
+StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bPointNr, bDistance, 
EarlyExitIters, merange, hme);
 if (bDistance == 1)
 {
 // if best distance was only 1, check two missing points.  If no 
new point is found, stop
@@ -1207,7 +1208,7 @@
 bDistance = 0;
 bPointNr = 0;
 const int MaxIters = 32;
-StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bPointNr, 
bDistance, MaxIters, merange);
+StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bPointNr, 
bDistance, MaxIters, merange, hme);
 
 if (bDistance == 1)
 {
diff -r 21db162c8622 -r 661effca62e3 source/encoder/motion.h
--- a/source/encoder/motion.h   Fri Jul 12 16:22:24 2019 +0530
+++ b/source/encoder/motion.h   Fri Jul 26 10:53:09 2019 +0530
@@ -109,7 +109,8 @@
   int &bPointNr,
   int &bDistance,
   int  earlyExitIters,
-  int  merange);
+  int  merange,
+  int  hme);
 };
 }
 
# HG changeset patch
# User Pooja Venkatesan 
# Date 1564118589 -19800
#  Fri Jul 26 10:53:09 2019 +0530
# Node ID 661effca62e3904bf3577ac4b60670e2f17f643e
# Parent  21db162c8622677c41a4fc77a14a59eb7326b46a
motion: Enable star search for HME Level-0

diff -r 21db162c8622 -r 661effca62e3 source/encoder/motion.cpp
--- a/source/encoder/motion.cpp	Fri Jul 12 16:22:24 2019 +0530
+++ b/source/encoder/motion.cpp	Fri Jul 26 10:53:09 2019 +0530
@@ -367,12 +367,13 @@
int &bPointNr,
int &bDistance,
int  earlyExitIters,
-   int  merange)
+   int  merange,
+   int  hme)
 {
 ALIGN_VAR_16(int, costs[16]);
 pixel* fenc = fencPUYuv.m_buf[0];
-pixel* fref = ref->fpelPlane[0] + blockOffset;
-intptr_t stride = ref->lumaStride;
+pixel* fref = (hme? ref->fpelLowerResPlane[0] : ref->fpelPlane[0]) + blockOffset;
+intptr_t stride = hme? ref->lumaStride / 2 : ref->lumaStride;
 
 MV omv = bmv;
 int saved = bcost;
@@ -1134,7 +1135,7 @@
 int bDistance = 0;
 
 const int EarlyExitIters = 3;
-StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bPointNr, bDistance, EarlyExitIters, merange);
+StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bPointNr, bDistance, EarlyExitIters, merange, hme);
 if (bDistance == 1)
 {
 // if best distance was only 1, check two missing points.  If no new point is found, stop
@@ -1207,7 +1208,7 @@
 bDistance = 0;
 bPointNr = 0;
 const int MaxIters = 32;
-StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bPointNr, bDistance, MaxIters, merange);
+StarPatternSearch(ref, mvmin, mvmax, bmv, bcost, bPointNr, bDistance, MaxIters, merange, hme);
 
 if (bDistance == 1)
 {
diff -r 21db162c8622 -r 661effca62e3 source/encoder/motion.h
--- a/source/encoder/motion.h	Fri Jul 12 16:22:24 2019 +0530
+++ b/source/encoder/motion.h	Fri Jul 26 10:53:09 2019 +0530
@@ -109,7 +109,8 @@

Re: [x265] [PATCH] Select the best among the tradition MVP and the Scaled MV as MVP

2019-06-11 Thread Pooja Venkatesan
Please ignore this patch. Will be sharing an improved version soon.

Thanks.
Pooja.

On Thu, May 30, 2019 at 2:42 PM  wrote:

> # HG changeset patch
> # User Pooja Venkatesan 
> # Date 1559024172 -19800
> #  Tue May 28 11:46:12 2019 +0530
> # Node ID 4d5ea449955a12f4704f7eef8ee9da30d674819b
> # Parent  a46ded2c14116af1cafacdc1fb98be43259dc7d6
> Select the best among the tradition MVP and the Scaled MV as MVP
> from analysis-save encode in load mode for refine-inter levels.
>
> diff -r a46ded2c1411 -r 4d5ea449955a source/encoder/analysis.cpp
> --- a/source/encoder/analysis.cpp   Tue May 28 14:01:54 2019 +0800
> +++ b/source/encoder/analysis.cpp   Tue May 28 11:46:12 2019 +0530
> @@ -2488,10 +2488,14 @@
>  MV mvp;
>
>  int numMvc =
> mode.cu.getPMV(mode.interNeighbours, list, ref, mode.amvpCand[list][ref],
> mvc);
> -if (m_param->interRefine != 1)
> -mvp =
> mode.amvpCand[list][ref][mode.cu.m_mvpIdx[list][pu.puAbsPartIdx]];
> -else
> -mvp = interDataCTU->mv[list][cuIdx +
> part].word;
> +mvp =
> mode.amvpCand[list][ref][mode.cu.m_mvpIdx[list][pu.puAbsPartIdx]];
> +if(m_param->interRefine == 1)
> +{
> +
> mode.amvpCand[list][ref][!(mode.cu.m_mvpIdx[list][pu.puAbsPartIdx])] =
> interDataCTU->mv[list][cuIdx + part].word;
> +int mvpIdx = selectMVP(mode.cu, pu,
> mode.amvpCand[list][ref], list, ref);
> +if (mvpIdx !=
> mode.cu.m_mvpIdx[list][pu.puAbsPartIdx])
> +mvp = interDataCTU->mv[list][cuIdx +
> part].word;
> +}
>  if (m_param->mvRefine || m_param->interRefine
> == 1)
>  {
>  MV outmv;
> diff -r a46ded2c1411 -r 4d5ea449955a source/encoder/search.cpp
> --- a/source/encoder/search.cpp Tue May 28 14:01:54 2019 +0800
> +++ b/source/encoder/search.cpp Tue May 28 11:46:12 2019 +0530
> @@ -2196,7 +2196,7 @@
>  bestME[1].cost = MAX_UINT;
>
>  getBlkBits((PartSize)cu.m_partSize[0], slice->isInterP(), puIdx,
> lastMode, m_listSelBits);
> -bool bDoUnidir = true;
> +bool bDoUnidir = true, bDoPme =
> m_param->bDistributeMotionEstimation;
>
>  cu.getNeighbourMV(puIdx, pu.puAbsPartIdx,
> interMode.interNeighbours);
>  /* Uni-directional prediction */
> @@ -2225,8 +2225,18 @@
>  MV mvmin, mvmax, outmv, mvp;
>  if (useAsMVP)
>  {
> -mvp = interDataCTU->mv[list][cuIdx + puIdx].word;
> -mvpIdx = interDataCTU->mvpIdx[list][cuIdx + puIdx];
> +interMode.amvpCand[list][ref][!mvpIdx] =
> interDataCTU->mv[list][cuIdx + puIdx].word;
> +int mvpIdx0 = selectMVP(interMode.cu, pu,
> interMode.amvpCand[list][ref], list, ref);
> +if (mvpIdx != mvpIdx0)
> +{
> +mvp = interDataCTU->mv[list][cuIdx + puIdx].word;
> +mvpIdx = interDataCTU->mvpIdx[list][cuIdx +
> puIdx];
> +}
> +else
> +{
> +useAsMVP = false;
> +break;
> +}
>  }
>  else
>  mvp = amvp[mvpIdx];
> @@ -2277,10 +2287,10 @@
>  bestME[list].mvCost  = mvCost;
>  bestME[list].ref = ref;
>  }
> -bDoUnidir = false;
> -}
> +bDoUnidir = bDoPme = false;
> +}
>  }
> -else if (m_param->bDistributeMotionEstimation)
> +if (bDoPme)
>  {
>  PME pme(*this, interMode, cuGeom, pu, puIdx);
>  pme.m_jobTotal = 0;
>
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


Re: [x265] [PATCH] aq: Disable hevc-aq based on checks

2019-01-07 Thread Pooja Venkatesan
On Tue, Jan 8, 2019 at 10:59 AM Pradeep Ramachandran <
prad...@multicorewareinc.com> wrote:

>
>
> On Tue, Jan 8, 2019 at 9:34 AM  wrote:
>
>> # HG changeset patch
>> # User Pooja Venkatesan 
>> # Date 1546170546 -19800
>> #  Sun Dec 30 17:19:06 2018 +0530
>> # Node ID 9c28a4122495d57b8ebd36ba37813b2cbfd60d28
>> # Parent  8aebc58efe5cbd5bf04b32120184b082a940eb9b
>> aq: Disable hevc-aq based on checks
>>
>> diff -r 8aebc58efe5c -r 9c28a4122495 source/common/param.cpp
>> --- a/source/common/param.cpp   Wed Jan 02 14:15:53 2019 +0530
>> +++ b/source/common/param.cpp   Sun Dec 30 17:19:06 2018 +0530
>> @@ -353,6 +353,7 @@
>>  param->limitReferences = 0;
>>  param->rc.aqStrength = 0.0;
>>  param->rc.aqMode = X265_AQ_NONE;
>> +param->rc.hevcAq = 0;
>>  param->rc.qgSize = 32;
>>  param->bEnableFastIntra = 1;
>>  }
>> @@ -370,6 +371,7 @@
>>  param->limitReferences = 0;
>>  param->rc.aqStrength = 0.0;
>>  param->rc.aqMode = X265_AQ_NONE;
>> +param->rc.hevcAq = 0;
>>  param->rc.qgSize = 32;
>>  param->bEnableSAO = 0;
>>  param->bEnableFastIntra = 1;
>> diff -r 8aebc58efe5c -r 9c28a4122495 source/encoder/encoder.cpp
>> --- a/source/encoder/encoder.cppWed Jan 02 14:15:53 2019 +0530
>> +++ b/source/encoder/encoder.cppSun Dec 30 17:19:06 2018 +0530
>> @@ -2677,6 +2677,7 @@
>>  {
>>  p->rc.qp = zone->rc.qp;
>>  p->rc.aqMode = X265_AQ_NONE;
>> +p->rc.hevcAq = 0;
>>  }
>>  p->radl = zone->radl;
>>
>> @@ -2811,6 +2812,7 @@
>>  if (p->rc.rateControlMode == X265_RC_CQP)
>>  {
>>  p->rc.aqMode = X265_AQ_NONE;
>> +p->rc.hevcAq = 0;
>>  p->rc.bitrate = 0;
>>  p->rc.cuTree = 0;
>>  p->rc.aqStrength = 0;
>> @@ -2835,14 +2837,16 @@
>>  }
>>
>>  if (p->rc.aqStrength == 0 && p->rc.cuTree == 0)
>> +{
>>  p->rc.aqMode = X265_AQ_NONE;
>> +p->rc.hevcAq = 0;
>> +}
>>
>>  if (p->rc.aqMode == X265_AQ_NONE && p->rc.cuTree == 0)
>>  p->rc.aqStrength = 0;
>>
>>  if (p->rc.hevcAq && p->rc.aqMode)
>>  {
>> -p->rc.aqMode = X265_AQ_NONE;
>>
>
> Isn't this disabling required? What happens when we enable hevc-aq +
> aq-mode now?
>
No. The hierarchy for AQ modes works as aq-mode 0, hevc-aq, aq-mode 1 and
then aq-mode 2. When we enable hevc-aq and aq-mode (2 by default) it works
taking hevc-aq only. We can just leave the warning and should not disable
aq-mode.

>
>
>>  x265_log(p, X265_LOG_WARNING, "hevc-aq enabled, disabling other
>> aq-modes\n");
>>  }
>>
>> ___
>> x265-devel mailing list
>> x265-devel@videolan.org
>> https://mailman.videolan.org/listinfo/x265-devel
>>
> ___
> x265-devel mailing list
> x265-devel@videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


Re: [x265] [PATCH] new aq implementation

2018-12-30 Thread Pooja Venkatesan
Hevc-aq works for both cases when cuTree is enabled/disabled. So, its up to
the user to disable cutree with --no-cutree if needed.

Thanks.
Pooja.

On Mon, Dec 31, 2018 at 5:55 AM Mateusz  wrote:

> W dniu 28.12.2018 o 06:30, po...@multicorewareinc.com pisze:
> > diff -r 129416ec0479 -r 3cd0b5ed0b91 source/encoder/encoder.cpp
> > --- a/source/encoder/encoder.cpp  Fri Dec 28 09:03:26 2018 +0530
> > +++ b/source/encoder/encoder.cpp  Thu Dec 27 14:43:54 2018 +0530
> > @@ -2839,6 +2839,12 @@
> >  if (p->rc.aqMode == X265_AQ_NONE && p->rc.cuTree == 0)
> >  p->rc.aqStrength = 0;
> >
> > +if (p->rc.hevcAq && p->rc.aqMode)
> > +{
> > +p->rc.aqMode = X265_AQ_NONE;
> > +x265_log(p, X265_LOG_WARNING, "hevc-aq enabled, disabling other
> aq-modes\n");
> > +}
>
> If hevc-aq doesn't use cuTree, maybe it is better to make sure that
> p->rc.cuTree is 0 and simplify condition checking later
> [...] = (m_param->rc.cuTree && !m_param->rc.hevcAq) ? [...]
> There are places that the part '&& !m_param->rc.hevcAq' is missing.
>
> Regards,
> Mateusz
>
> ___
> x265-devel mailing list
> x265-devel@videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH] new aq implementation

2018-12-28 Thread Pooja Venkatesan
Hi,
I am only attaching the patch as the Message body becomes too
big(247208 bytes exceeds limit of 200 KB).


x265-stable.patch
Description: Binary data
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH 5 of 5] zone: Add support for RADL pictures

2018-12-19 Thread Pooja Venkatesan
# HG changeset patch
# User Pooja Venkatesan 
# Date 1544770885 -19800
#  Fri Dec 14 12:31:25 2018 +0530
# Node ID d5d79e22bfddda8c103da2182a68137757340425
# Parent  1a62483c0b7549ef677ce2f343e9c7f1fcd45c44
zone: Add support for RADL pictures

diff -r 1a62483c0b75 -r d5d79e22bfdd source/common/param.cpp
--- a/source/common/param.cpp Fri Dec 14 12:28:56 2018 +0530
+++ b/source/common/param.cpp Fri Dec 14 12:31:25 2018 +0530
@@ -624,6 +624,7 @@
 OPT("amp") p->bEnableAMP = atobool(value);
 OPT("max-merge") p->maxNumMergeCand = (uint32_t)atoi(value);
 OPT("rd") p->rdLevel = atoi(value);
+OPT("radl") p->radl = atoi(value);
 OPT2("rdoq", "rdoq-level")
 {
 int bval = atobool(value);
diff -r 1a62483c0b75 -r d5d79e22bfdd source/encoder/dpb.h
--- a/source/encoder/dpb.h Fri Dec 14 12:28:56 2018 +0530
+++ b/source/encoder/dpb.h Fri Dec 14 12:31:25 2018 +0530
@@ -52,6 +52,14 @@
 m_lastIDR = 0;
 m_pocCRA = 0;
 m_bhasLeadingPicture = param->radl;
+for (int i = 0; i < param->rc.zonefileCount; i++)
+{
+if (param->rc.zones[i].zoneParam->radl)
+{
+m_bhasLeadingPicture = param->rc.zones[i].zoneParam->radl;
+break;
+}
+}
 m_bRefreshPending = false;
 m_frameDataFreeList = NULL;
 m_bOpenGOP = param->bOpenGOP;
diff -r 1a62483c0b75 -r d5d79e22bfdd source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Fri Dec 14 12:28:56 2018 +0530
+++ b/source/encoder/encoder.cpp Fri Dec 14 12:31:25 2018 +0530
@@ -2652,6 +2652,7 @@
 p->rc.qp = zone->rc.qp;
 p->rc.aqMode = X265_AQ_NONE;
 }
+p->radl = zone->radl;

 memcpy(zone, p, sizeof(x265_param));
 }
diff -r 1a62483c0b75 -r d5d79e22bfdd source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp Fri Dec 14 12:28:56 2018 +0530
+++ b/source/encoder/slicetype.cpp Fri Dec 14 12:31:25 2018 +0530
@@ -1117,7 +1117,9 @@
 }
 for (int i = 0; i < m_param->rc.zonefileCount; i++)
 {
-if (m_param->rc.zones[i].startFrame == frm.frameNum)
+int curZoneStart = m_param->rc.zones[i].startFrame;
+curZoneStart += curZoneStart ?
m_param->rc.zones[i].zoneParam->radl : 0;
+if (curZoneStart == frm.frameNum)
 frm.sliceType = X265_TYPE_IDR;
 }
 if ((frm.sliceType == X265_TYPE_I && frm.frameNum -
m_lastKeyframe >= m_param->keyframeMin) || (frm.frameNum ==
(m_param->chunkStart - 1)) || (frm.frameNum == m_param->chunkEnd))
@@ -1135,7 +1137,20 @@
 /* Closed GOP */
 m_lastKeyframe = frm.frameNum;
 frm.bKeyframe = true;
-if (bframes > 0 && !m_param->radl)
+int zoneRadl = 0;
+for (int i = 0; i < m_param->rc.zonefileCount; i++)
+{
+int zoneStart = m_param->rc.zones[i].startFrame;
+zoneStart += zoneStart ?
m_param->rc.zones[i].zoneParam->radl : 0;
+if (zoneStart == frm.frameNum)
+{
+zoneRadl = m_param->rc.zones[i].zoneParam->radl;
+m_param->radl = 0;
+m_param->rc.zones->zoneParam->radl = i <
m_param->rc.zonefileCount - 1? m_param->rc.zones[i + 1].zoneParam->radl : 0;
+break;
+}
+}
+if (bframes > 0 && !m_param->radl && !zoneRadl)
 {
 list[bframes - 1]->m_lowres.sliceType = X265_TYPE_P;
 bframes--;
@@ -1423,6 +1438,14 @@
 }
 frames[framecnt + 1] = NULL;

+for (int i = 0; i < m_param->rc.zonefileCount; i++)
+{
+int curZoneStart = m_param->rc.zones[i].startFrame, nextZoneStart
= 0;
+curZoneStart += curZoneStart ?
m_param->rc.zones[i].zoneParam->radl : 0;
+nextZoneStart += (i + 1 < m_param->rc.zonefileCount) ?
m_param->rc.zones[i + 1].startFrame + m_param->rc.zones[i +
1].zoneParam->radl : m_param->totalFrames;
+if (curZoneStart <= frames[0]->frameNum && nextZoneStart >
frames[0]->frameNum)
+m_param->keyframeMax = nextZoneStart - curZoneStart;
+}
 int keylimit = m_param->keyframeMax;
 if (frames[0]->frameNum < m_param->chunkEnd)
 {
@@ -1632,14 +1655,16 @@
 frames[numFrames]->sliceType = X265_TYPE_P;
 }

-bool bForceRADL = m_param->radl && !m_param->bOpenGOP;
+int zoneRadl = m_param->rc.zonefileCount ?
m_param->rc.zones->zoneParam->radl : 0;
+

[x265] [PATCH 4 of 5] zone: reconfigure rate control parameters

2018-12-19 Thread Pooja Venkatesan
# HG changeset patch
# User Pooja Venkatesan 
# Date 1544770736 -19800
#  Fri Dec 14 12:28:56 2018 +0530
# Node ID 1a62483c0b7549ef677ce2f343e9c7f1fcd45c44
# Parent  587431d49124b5e990883a919ec9eaf8b3708c34
zone: reconfigure rate control parameters

diff -r 587431d49124 -r 1a62483c0b75 source/common/param.cpp
--- a/source/common/param.cpp Fri Dec 14 12:26:15 2018 +0530
+++ b/source/common/param.cpp Fri Dec 14 12:28:56 2018 +0530
@@ -637,6 +637,21 @@
 }
 OPT("b-intra") p->bIntraInBFrames = atobool(value);
 OPT("scaling-list") p->scalingLists = strdup(value);
+OPT("crf")
+{
+p->rc.rfConstant = atof(value);
+p->rc.rateControlMode = X265_RC_CRF;
+}
+OPT("qp")
+{
+p->rc.qp = atoi(value);
+p->rc.rateControlMode = X265_RC_CQP;
+}
+OPT("bitrate")
+{
+p->rc.bitrate = atoi(value);
+p->rc.rateControlMode = X265_RC_ABR;
+}
 OPT("aq-mode") p->rc.aqMode = atoi(value);
 OPT("aq-strength") p->rc.aqStrength = atof(value);
 OPT("nr-intra") p->noiseReductionIntra = atoi(value);
diff -r 587431d49124 -r 1a62483c0b75 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Fri Dec 14 12:26:15 2018 +0530
+++ b/source/encoder/encoder.cpp Fri Dec 14 12:28:56 2018 +0530
@@ -2643,6 +2643,16 @@
 p->bEnableTransformSkip = zone->bEnableTransformSkip;
 p->bEnableAMP = zone->bEnableAMP;

+if (m_param->rc.rateControlMode == X265_RC_ABR)
+p->rc.bitrate = zone->rc.bitrate;
+if (m_param->rc.rateControlMode == X265_RC_CRF)
+p->rc.rfConstant = zone->rc.rfConstant;
+if (m_param->rc.rateControlMode == X265_RC_CQP)
+{
+p->rc.qp = zone->rc.qp;
+p->rc.aqMode = X265_AQ_NONE;
+}
+
 memcpy(zone, p, sizeof(x265_param));
 }

diff -r 587431d49124 -r 1a62483c0b75 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp Fri Dec 14 12:26:15 2018 +0530
+++ b/source/encoder/ratecontrol.cpp Fri Dec 14 12:28:56 2018 +0530
@@ -741,6 +741,20 @@
 if (m_param->rc.rfConstantMin)
 m_rateFactorMaxDecrement = m_param->rc.rfConstant -
m_param->rc.rfConstantMin;
 }
+if (m_param->rc.rateControlMode == X265_RC_CQP)
+{
+m_qp = m_param->rc.qp;
+if (m_qp && !m_param->bLossless)
+{
+m_qpConstant[P_SLICE] = m_qp;
+m_qpConstant[I_SLICE] = x265_clip3(QP_MIN, QP_MAX_MAX,
(int)(m_qp - m_ipOffset + 0.5));
+m_qpConstant[B_SLICE] = x265_clip3(QP_MIN, QP_MAX_MAX,
(int)(m_qp + m_pbOffset + 0.5));
+}
+else
+{
+m_qpConstant[P_SLICE] = m_qpConstant[I_SLICE] =
m_qpConstant[B_SLICE] = m_qp;
+}
+}
 m_bitrate = m_param->rc.bitrate * 1000;
 }

@@ -1231,6 +1245,17 @@
 rce->keptAsRef = IS_REFERENCED(curFrame);
 m_predType = getPredictorType(curFrame->m_lowres.sliceType,
m_sliceType);
 rce->poc = m_curSlice->m_poc;
+
+/* change ratecontrol stats for next zone if specified */
+for (int i = 0; i < m_param->rc.zonefileCount; i++)
+{
+if (m_param->rc.zones[i].startFrame == curFrame->m_encodeOrder)
+{
+m_param = m_param->rc.zones[i].zoneParam;
+reconfigureRC();
+init(*m_curSlice->m_sps);
+}
+}
 if (m_param->rc.bStatRead)
 {
 X265_CHECK(rce->poc >= 0 && rce->poc < m_numEntries, "bad encode
ordinal\n");


x265-clean-4 (1).patch
Description: Binary data
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH 3 of 5] zone: Resend parameter set

2018-12-19 Thread Pooja Venkatesan
# HG changeset patch
# User Pooja Venkatesan 
# Date 1544770575 -19800
#  Fri Dec 14 12:26:15 2018 +0530
# Node ID 587431d49124b5e990883a919ec9eaf8b3708c34
# Parent  1d196adca6aad0d10c2a01429541971556534015
zone: Resend parameter set

diff -r 1d196adca6aa -r 587431d49124 source/encoder/api.cpp
--- a/source/encoder/api.cpp Fri Dec 14 12:17:29 2018 +0530
+++ b/source/encoder/api.cpp Fri Dec 14 12:26:15 2018 +0530
@@ -259,6 +259,9 @@
 }
 encoder->printReconfigureParams();
 }
+/* Zones support modifying num of Refs. Requires determining level at
each zone start*/
+if (encoder->m_param->rc.zonefileCount)
+determineLevel(*encoder->m_latestParam, encoder->m_vps);
 return ret;
 }

diff -r 1d196adca6aa -r 587431d49124 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Fri Dec 14 12:17:29 2018 +0530
+++ b/source/encoder/encoder.cpp Fri Dec 14 12:26:15 2018 +0530
@@ -1663,6 +1663,11 @@
 encParam->dynamicRd = param->dynamicRd;
 encParam->bEnableTransformSkip = param->bEnableTransformSkip;
 encParam->bEnableAMP = param->bEnableAMP;
+
+/* Resignal changes in params in Parameter Sets */
+m_sps.maxAMPDepth = (m_sps.bUseAMP = param->bEnableAMP &&
param->bEnableAMP) ? param->maxCUDepth : 0;
+m_pps.bTransformSkipEnabled = param->bEnableTransformSkip ? 1 : 0;
+
 }
 encParam->forceFlush = param->forceFlush;
 /* To add: Loop Filter/deblocking controls, transform skip, signhide
require PPS to be resent */
@@ -3275,6 +3280,12 @@
 p->bOpenGOP = 0;
 x265_log(p, X265_LOG_WARNING, "Zone encoding requires closed gop
structure. Enabling closed GOP.\n");
 }
+
+if (m_param->rc.zonefileCount && !p->bRepeatHeaders)
+{
+p->bRepeatHeaders = 1;
+x265_log(p, X265_LOG_WARNING, "Turning on repeat - headers for
zone encoding\n");
+}
 }

 void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc,
const x265_picture* picIn, int paramBytes)


x265-clean-3 (1).patch
Description: Binary data
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH] Fix issue #441 build error in VMAF lib

2018-11-08 Thread Pooja Venkatesan
# HG changeset patch
# User Pooja Venkatesan 
# Date 1541396041 -19800
#  Mon Nov 05 11:04:01 2018 +0530
# Branch stable
# Node ID daf2785a189391ce6964f673858dc8234c641807
# Parent  471726d3a0462739ff8e3518eb1a1e8a01de4e8d
Fix issue #441 build error in VMAF lib

diff -r 471726d3a046 -r daf2785a1893 source/encoder/api.cpp
--- a/source/encoder/api.cpp Wed Oct 31 16:35:48 2018 +0530
+++ b/source/encoder/api.cpp Mon Nov 05 11:04:01 2018 +0530
@@ -1501,7 +1501,7 @@
 else
 x265_log(NULL, X265_LOG_ERROR, "Invalid format\n");

-compute_vmaf(, vcd->format, data->width, data->height,
read_frame, data, vcd->model_path, vcd->log_path, vcd->log_fmt,
vcd->disable_clip, vcd->disable_avx, vcd->enable_transform,
vcd->phone_model, vcd->psnr, vcd->ssim, vcd->ms_ssim, vcd->pool);
+compute_vmaf(, vcd->format, data->width, data->height,
read_frame, data, vcd->model_path, vcd->log_path, vcd->log_fmt,
vcd->disable_clip, vcd->disable_avx, vcd->enable_transform,
vcd->phone_model, vcd->psnr, vcd->ssim, vcd->ms_ssim, vcd->pool,
vcd->thread, vcd->subsample, vcd->enable_conf_interval);

 return score;
 }
@@ -1603,7 +1603,7 @@
 read_frame = read_frame_8bit;
 else
 read_frame = read_frame_10bit;
-compute_vmaf(, vcd->format, vmafframedata->width,
vmafframedata->height, read_frame, vmafframedata, vcd->model_path,
vcd->log_path, vcd->log_fmt, vcd->disable_clip, vcd->disable_avx,
vcd->enable_transform, vcd->phone_model, vcd->psnr, vcd->ssim,
vcd->ms_ssim, vcd->pool);
+compute_vmaf(, vcd->format, vmafframedata->width,
vmafframedata->height, read_frame, vmafframedata, vcd->model_path,
vcd->log_path, vcd->log_fmt, vcd->disable_clip, vcd->disable_avx,
vcd->enable_transform, vcd->phone_model, vcd->psnr, vcd->ssim,
vcd->ms_ssim, vcd->pool, vcd->thread, vcd->subsample,
vcd->enable_conf_interval);

 return score;
 }
diff -r 471726d3a046 -r daf2785a1893 source/x265.h
--- a/source/x265.h Wed Oct 31 16:35:48 2018 +0530
+++ b/source/x265.h Mon Nov 05 11:04:01 2018 +0530
@@ -688,9 +688,12 @@
 int ssim;
 int ms_ssim;
 char *pool;
+int thread;
+int subsample;
+int enable_conf_interval;
 }x265_vmaf_commondata;

-static const x265_vmaf_commondata vcd[] = { { NULL, (char
*)"/usr/local/share/model/vmaf_v0.6.1.pkl", NULL, NULL, 0, 0, 0, 0, 0, 0,
0, NULL } };
+static const x265_vmaf_commondata vcd[] = { { NULL, (char
*)"/usr/local/share/model/vmaf_v0.6.1.pkl", NULL, NULL, 0, 0, 0, 0, 0, 0,
0, NULL, 0, 1, 0 } };

 /* x265 input parameters
  *


issue441.patch
Description: Binary data
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel