Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-21 Thread Mario *LigH* Rohkrämer

srikanth.kurap...@multicorewareinc.com schrieb am 19.02.2020 um 07:45:

@@ -457,7 +457,9 @@

> ...

+H0("   --rskip Set mode for early exit from recursion. 
Mode 1: exit using rdcost. Mode 2: exit using edge density. Mode 3: exit using edge density 
with forceful skip for small sized CU's."
+   "  Mode 0: disabled. Default 
%s\n", OPT(param->enableRecursionSkip));


Mode is integer (0..3).

Help page reports "Default enabled" where I would expect a number 
instead of a boolean.


--

Fun and success!

Mario *LigH* Rohkrämer
maito:cont...@ligh.de
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-20 Thread Mario *LigH* Rohkrämer

srikanth.kurap...@multicorewareinc.com schrieb am 19.02.2020 um 07:45:

@@ -457,7 +457,9 @@
...
+H0("   --rskip Set mode for early exit from recursion. 
Mode 1: exit using rdcost. Mode 2: exit using edge density. Mode 3: exit using edge density 
with forceful skip for small sized CU's."


Misses a \n at the end of the line.

--

Fun and success!

Mario *LigH* Rohkrämer
maito:cont...@ligh.de
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-19 Thread Aruna Matheswaran
Pushed to default.

On Wed, Feb 19, 2020 at 12:15 PM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1580280547 -19800
> #  Wed Jan 29 12:19:07 2020 +0530
> # Node ID ecf19726600a3218c10eb28dcfded16d2a18c301
> # Parent  c2769ac5fa9d6776317e720d19f5f8b0eab4
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion for quadtree establishment using edge information.
> 2. Adds modes for option "--rskip". Modes 0,1 for current usage and 2,3
> for edge
>  based recursion skip.
> 3. Adds option "rskip-edge-threshold" to decide recursion skip using CU
> edge density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r c2769ac5fa9d -r ecf19726600a doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Mon Feb 17 20:46:53 2020 +0530
> +++ b/doc/reST/cli.rst  Wed Jan 29 12:19:07 2020 +0530
> @@ -842,15 +842,31 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2|3>
> +
> +   This option determines early exit from CU depth recursion in modes
> 1, 2 and 3. When a skip CU is
> +   found, additional heuristics (depending on RD level and rskip
> mode) are used to decide whether
> +   to terminate recursion. The following table summarizes the
> behavior.
> +
> +
>  
> +--+++
> +   | RD Level | Rskip Mode |   Skip Recursion Heuristic
>|
> +
>  
> +==+++
> +   |   0 - 4  |  1 |   Neighbour costs.
>|
> +
>  
> +--+++
> +   |   5 - 6  |  1 |   Comparison with inter2Nx2N.
>   |
> +
>  
> +--+++
> +   |   0 - 6  |  2 |   CU edge denstiy.
>|
> +
>  
> +--+++
> +   |   0 - 6  |  3 |   CU edge denstiy with forceful skip for
> lower levels of CTU.  |
> +
>  
> +--+++
> +
> +   Provides minimal quality degradation at good performance gains for
> non-zero modes.
> +   :option:`--rskip mode 0` means disabled. Default: 1, disabled when
> :option:`--tune grain` is used.
> +
> +.. option:: --rskip-edge-threshold <0..100>
> +
> +   Denotes the minimum expected edge-density percentage within the
> CU, below which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2|3` to be enabled.
>
>  .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r c2769ac5fa9d -r ecf19726600a source/CMakeLists.txt
> --- a/source/CMakeLists.txt Mon Feb 17 20:46:53 2020 +0530
> +++ b/source/CMakeLists.txt Wed Jan 29 12:19:07 2020 +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 188)
> +set(X265_BUILD 189)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r c2769ac5fa9d -r ecf19726600a source/common/common.h
> --- a/source/common/common.hMon Feb 17 20:46:53 2020 +0530
> +++ b/source/common/common.hWed Jan 29 12:19:07 2020 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #else
>  typedef uint8_t  pixel;
> @@ -136,6 +137,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #endif // if HIGH_BIT_DEPTH
>
> @@ -270,6 +272,9 @@
>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>
> +#define RDCOST_BASED_RSKIP 1
> +#define EDGE_BASED_RSKIP 2
> +
>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-18 Thread Srikanth Kurapati
Hi Aruna,

 1. addressed all the cosmetic changes.
 2. Regarding the question for threshold datatype. I have justified this in
the external review itself.
 reiterating the same here.
[Srikanth] The purpose is to make it easily configurable by naive users for
providing the threshold and then normalizing the values to between 0 to 1.
It's difficult for user to think in terms of normalized variance.


On Tue, Feb 18, 2020 at 3:17 PM Aruna Matheswaran <
ar...@multicorewareinc.com> wrote:

>
>
> On Fri, Feb 7, 2020 at 3:37 PM 
> wrote:
>
>> # HG changeset patch
>> # User Srikanth Kurapati
>> # Date 1580280547 -19800
>> #  Wed Jan 29 12:19:07 2020 +0530
>> # Node ID 30d303b38c7bd1733aedd01a3f738fb08ec1488c
>> # Parent  fdbd4e4a2aff93bfc14b10efcd9e681a7ebae311
>> Edge Aware Quad Tree Establishment.
>>
>> This patch does the following:
>> 1. Terminates recursion for quadtree establishment using edge information.
>> 2. Adds modes for option "--rskip". Modes 0,1 for current usage and 2,3
>> for edge
>>  based recursion skip.
>> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
>> density.
>> 4. Re uses edge information when already available in encoder.
>>
>> diff -r fdbd4e4a2aff -r 30d303b38c7b doc/reST/cli.rst
>> --- a/doc/reST/cli.rst  Sat Jan 25 18:08:03 2020 +0530
>> +++ b/doc/reST/cli.rst  Wed Jan 29 12:19:07 2020 +0530
>> @@ -842,15 +842,31 @@
>> Measure 2Nx2N merge candidates first; if no residual is found,
>> additional modes at that depth are not analysed. Default disabled
>>
>> -.. option:: --rskip, --no-rskip
>> -
>> -   This option determines early exit from CU depth recursion. When a
>> skip CU is
>> -   found, additional heuristics (depending on rd-level) are used to
>> decide whether
>> -   to terminate recursion. In rdlevels 5 and 6, comparison with
>> inter2Nx2N is used,
>> -   while at rdlevels 4 and neighbour costs are used to skip
>> recursion.
>> -   Provides minimal quality degradation at good performance gains
>> when enabled.
>> -
>> -   Default: enabled, disabled for :option:`--tune grain`
>> +.. option:: --rskip <0|1|2|3>
>> +
>> +   This option determines early exit from CU depth recursion in
>> modes 1, 2 and 3. When a skip CU is
>> +   found, additional heuristics (depending on RD level and rskip
>> mode) are used to decide whether
>> +   to terminate recursion. The following table summarizes the
>> behavior.
>> +
>> +
>>  
>> +--+++
>> +   | RD Level | Rskip Mode |   Skip Recursion Heuristic
>>|
>> +
>>  
>> +==+++
>> +   |   0 - 4  |  1 |   Neighbour costs.
>>|
>> +
>>  
>> +--+++
>> +   |   5 - 6  |  1 |   Comparison with inter2Nx2N.
>> |
>> +
>>  
>> +--+++
>> +   |   0 - 6  |  2 |   CU edge denstiy.
>>|
>> +
>>  
>> +--+++
>> +   |   0 - 6  |  3 |   CU edge denstiy with forceful skip
>> for lower levels of CTU.  |
>> +
>>  
>> +--+++
>> +
>> +   Provides minimal quality degradation at good performance gains
>> for non-zero modes.
>> +   :option:`--rskip mode 0` means disabled. Default: 1, disabled
>> when :option:`--tune grain` is used.
>> +
>> +.. option:: --edge-threshold <0..100>
>
>  Please change the CLI name. There is another edge-based threshold
> "hist-threshold". So, let's be clear with the naming.
>
>> +
>> +   Denotes the minimum expected edge-density percentage within the
>> CU, below which the recursion is skipped.
>> +   Default: 5, requires :option:`--rskip mode 2|3` to be enabled.
>>
>> I see that the corresponding x265_param entry is of float type. Any
> reason why this is an integer here?
>
>  .. option:: --splitrd-skip, --no-splitrd-skip
>>
>> diff -r fdbd4e4a2aff -r 30d303b38c7b source/CMakeLists.txt
>> --- a/source/CMakeLists.txt Sat Jan 25 18:08:03 2020 +0530
>> +++ b/source/CMakeLists.txt Wed Jan 29 12:19:07 2020 +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 188)
>> +set(X265_BUILD 189)
>>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>> "${PROJECT_BINARY_DIR}/x265.def")
>>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
>> diff -r fdbd4e4a2aff -r 30d303b38c7b 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-18 Thread Aruna Matheswaran
On Fri, Feb 7, 2020 at 3:37 PM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1580280547 -19800
> #  Wed Jan 29 12:19:07 2020 +0530
> # Node ID 30d303b38c7bd1733aedd01a3f738fb08ec1488c
> # Parent  fdbd4e4a2aff93bfc14b10efcd9e681a7ebae311
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion for quadtree establishment using edge information.
> 2. Adds modes for option "--rskip". Modes 0,1 for current usage and 2,3
> for edge
>  based recursion skip.
> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
> density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r fdbd4e4a2aff -r 30d303b38c7b doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Sat Jan 25 18:08:03 2020 +0530
> +++ b/doc/reST/cli.rst  Wed Jan 29 12:19:07 2020 +0530
> @@ -842,15 +842,31 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2|3>
> +
> +   This option determines early exit from CU depth recursion in modes
> 1, 2 and 3. When a skip CU is
> +   found, additional heuristics (depending on RD level and rskip
> mode) are used to decide whether
> +   to terminate recursion. The following table summarizes the
> behavior.
> +
> +
>  
> +--+++
> +   | RD Level | Rskip Mode |   Skip Recursion Heuristic
>|
> +
>  
> +==+++
> +   |   0 - 4  |  1 |   Neighbour costs.
>|
> +
>  
> +--+++
> +   |   5 - 6  |  1 |   Comparison with inter2Nx2N.
>   |
> +
>  
> +--+++
> +   |   0 - 6  |  2 |   CU edge denstiy.
>|
> +
>  
> +--+++
> +   |   0 - 6  |  3 |   CU edge denstiy with forceful skip for
> lower levels of CTU.  |
> +
>  
> +--+++
> +
> +   Provides minimal quality degradation at good performance gains for
> non-zero modes.
> +   :option:`--rskip mode 0` means disabled. Default: 1, disabled when
> :option:`--tune grain` is used.
> +
> +.. option:: --edge-threshold <0..100>

 Please change the CLI name. There is another edge-based threshold
"hist-threshold". So, let's be clear with the naming.

> +
> +   Denotes the minimum expected edge-density percentage within the
> CU, below which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2|3` to be enabled.
>
> I see that the corresponding x265_param entry is of float type. Any reason
why this is an integer here?

 .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r fdbd4e4a2aff -r 30d303b38c7b source/CMakeLists.txt
> --- a/source/CMakeLists.txt Sat Jan 25 18:08:03 2020 +0530
> +++ b/source/CMakeLists.txt Wed Jan 29 12:19:07 2020 +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 188)
> +set(X265_BUILD 189)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r fdbd4e4a2aff -r 30d303b38c7b source/common/common.h
> --- a/source/common/common.hSat Jan 25 18:08:03 2020 +0530
> +++ b/source/common/common.hWed Jan 29 12:19:07 2020 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #define SHIFT 1
>  #else
> @@ -137,6 +138,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #define SHIFT 0
>  #endif // if HIGH_BIT_DEPTH
> @@ -272,6 +274,9 @@
>  #define MAX_TR_SIZE (1 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-10 Thread Srikanth Kurapati
Thank you. @Aruna Matheswaran  please push the
above patch to the repo.

On Mon, Feb 10, 2020 at 3:00 PM Kavitha Sampath <
kavi...@multicorewareinc.com> wrote:

> Looks good to me.
>
> On Fri, Feb 7, 2020 at 3:37 PM 
> wrote:
>
>> # HG changeset patch
>> # User Srikanth Kurapati
>> # Date 1580280547 -19800
>> #  Wed Jan 29 12:19:07 2020 +0530
>> # Node ID 30d303b38c7bd1733aedd01a3f738fb08ec1488c
>> # Parent  fdbd4e4a2aff93bfc14b10efcd9e681a7ebae311
>> Edge Aware Quad Tree Establishment.
>>
>> This patch does the following:
>> 1. Terminates recursion for quadtree establishment using edge information.
>> 2. Adds modes for option "--rskip". Modes 0,1 for current usage and 2,3
>> for edge
>>  based recursion skip.
>> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
>> density.
>> 4. Re uses edge information when already available in encoder.
>>
>> diff -r fdbd4e4a2aff -r 30d303b38c7b doc/reST/cli.rst
>> --- a/doc/reST/cli.rst  Sat Jan 25 18:08:03 2020 +0530
>> +++ b/doc/reST/cli.rst  Wed Jan 29 12:19:07 2020 +0530
>> @@ -842,15 +842,31 @@
>> Measure 2Nx2N merge candidates first; if no residual is found,
>> additional modes at that depth are not analysed. Default disabled
>>
>> -.. option:: --rskip, --no-rskip
>> -
>> -   This option determines early exit from CU depth recursion. When a
>> skip CU is
>> -   found, additional heuristics (depending on rd-level) are used to
>> decide whether
>> -   to terminate recursion. In rdlevels 5 and 6, comparison with
>> inter2Nx2N is used,
>> -   while at rdlevels 4 and neighbour costs are used to skip
>> recursion.
>> -   Provides minimal quality degradation at good performance gains
>> when enabled.
>> -
>> -   Default: enabled, disabled for :option:`--tune grain`
>> +.. option:: --rskip <0|1|2|3>
>> +
>> +   This option determines early exit from CU depth recursion in
>> modes 1, 2 and 3. When a skip CU is
>> +   found, additional heuristics (depending on RD level and rskip
>> mode) are used to decide whether
>> +   to terminate recursion. The following table summarizes the
>> behavior.
>> +
>> +
>>  
>> +--+++
>> +   | RD Level | Rskip Mode |   Skip Recursion Heuristic
>>|
>> +
>>  
>> +==+++
>> +   |   0 - 4  |  1 |   Neighbour costs.
>>|
>> +
>>  
>> +--+++
>> +   |   5 - 6  |  1 |   Comparison with inter2Nx2N.
>> |
>> +
>>  
>> +--+++
>> +   |   0 - 6  |  2 |   CU edge denstiy.
>>|
>> +
>>  
>> +--+++
>> +   |   0 - 6  |  3 |   CU edge denstiy with forceful skip
>> for lower levels of CTU.  |
>> +
>>  
>> +--+++
>> +
>> +   Provides minimal quality degradation at good performance gains
>> for non-zero modes.
>> +   :option:`--rskip mode 0` means disabled. Default: 1, disabled
>> when :option:`--tune grain` is used.
>> +
>> +.. option:: --edge-threshold <0..100>
>> +
>> +   Denotes the minimum expected edge-density percentage within the
>> CU, below which the recursion is skipped.
>> +   Default: 5, requires :option:`--rskip mode 2|3` to be enabled.
>>
>>  .. option:: --splitrd-skip, --no-splitrd-skip
>>
>> diff -r fdbd4e4a2aff -r 30d303b38c7b source/CMakeLists.txt
>> --- a/source/CMakeLists.txt Sat Jan 25 18:08:03 2020 +0530
>> +++ b/source/CMakeLists.txt Wed Jan 29 12:19:07 2020 +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 188)
>> +set(X265_BUILD 189)
>>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>> "${PROJECT_BINARY_DIR}/x265.def")
>>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
>> diff -r fdbd4e4a2aff -r 30d303b38c7b source/common/common.h
>> --- a/source/common/common.hSat Jan 25 18:08:03 2020 +0530
>> +++ b/source/common/common.hWed Jan 29 12:19:07 2020 +0530
>> @@ -129,6 +129,7 @@
>>  typedef uint64_t sum2_t;
>>  typedef uint64_t pixel4;
>>  typedef int64_t  ssum2_t;
>> +#define SHIFT_TO_BITPLANE 9
>>  #define HISTOGRAM_BINS 1024
>>  #define SHIFT 1
>>  #else
>> @@ -137,6 +138,7 @@
>>  typedef uint32_t sum2_t;
>>  typedef uint32_t pixel4;
>>  typedef int32_t  ssum2_t; // Signed sum
>> +#define SHIFT_TO_BITPLANE 7
>>  #define HISTOGRAM_BINS 256
>>  #define 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-10 Thread Kavitha Sampath
Looks good to me.

On Fri, Feb 7, 2020 at 3:37 PM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1580280547 -19800
> #  Wed Jan 29 12:19:07 2020 +0530
> # Node ID 30d303b38c7bd1733aedd01a3f738fb08ec1488c
> # Parent  fdbd4e4a2aff93bfc14b10efcd9e681a7ebae311
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion for quadtree establishment using edge information.
> 2. Adds modes for option "--rskip". Modes 0,1 for current usage and 2,3
> for edge
>  based recursion skip.
> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
> density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r fdbd4e4a2aff -r 30d303b38c7b doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Sat Jan 25 18:08:03 2020 +0530
> +++ b/doc/reST/cli.rst  Wed Jan 29 12:19:07 2020 +0530
> @@ -842,15 +842,31 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2|3>
> +
> +   This option determines early exit from CU depth recursion in modes
> 1, 2 and 3. When a skip CU is
> +   found, additional heuristics (depending on RD level and rskip
> mode) are used to decide whether
> +   to terminate recursion. The following table summarizes the
> behavior.
> +
> +
>  
> +--+++
> +   | RD Level | Rskip Mode |   Skip Recursion Heuristic
>|
> +
>  
> +==+++
> +   |   0 - 4  |  1 |   Neighbour costs.
>|
> +
>  
> +--+++
> +   |   5 - 6  |  1 |   Comparison with inter2Nx2N.
>   |
> +
>  
> +--+++
> +   |   0 - 6  |  2 |   CU edge denstiy.
>|
> +
>  
> +--+++
> +   |   0 - 6  |  3 |   CU edge denstiy with forceful skip for
> lower levels of CTU.  |
> +
>  
> +--+++
> +
> +   Provides minimal quality degradation at good performance gains for
> non-zero modes.
> +   :option:`--rskip mode 0` means disabled. Default: 1, disabled when
> :option:`--tune grain` is used.
> +
> +.. option:: --edge-threshold <0..100>
> +
> +   Denotes the minimum expected edge-density percentage within the
> CU, below which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2|3` to be enabled.
>
>  .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r fdbd4e4a2aff -r 30d303b38c7b source/CMakeLists.txt
> --- a/source/CMakeLists.txt Sat Jan 25 18:08:03 2020 +0530
> +++ b/source/CMakeLists.txt Wed Jan 29 12:19:07 2020 +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 188)
> +set(X265_BUILD 189)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r fdbd4e4a2aff -r 30d303b38c7b source/common/common.h
> --- a/source/common/common.hSat Jan 25 18:08:03 2020 +0530
> +++ b/source/common/common.hWed Jan 29 12:19:07 2020 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #define SHIFT 1
>  #else
> @@ -137,6 +138,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #define SHIFT 0
>  #endif // if HIGH_BIT_DEPTH
> @@ -272,6 +274,9 @@
>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>
> +#define RDCOST_BASED_RSKIP 1
> +#define EDGE_BASED_RSKIP 2
> +
>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-07 Thread Srikanth Kurapati
On Tue, Feb 4, 2020 at 5:10 PM Srikanth Kurapati <
srikanth.kurap...@multicorewareinc.com> wrote:

> On Wed, Jan 29, 2020 at 12:20 PM 
> wrote:
>
>> # HG changeset patch
>> # User Srikanth Kurapati
>> # Date 1580280547 -19800
>> #  Wed Jan 29 12:19:07 2020 +0530
>> # Node ID e9c8c0089bddc9e9e47774b5fda1f4dff1fb45e4
>> # Parent  fdbd4e4a2aff93bfc14b10efcd9e681a7ebae311
>> Edge Aware Quad Tree Establishment.
>>
>> This patch does the following:
>> 1. Terminates recursion using edge information.
>> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2,3 for edge
>> based
>> rskips for RD levels 0 to 6.
>>
> [KS] Since there are only 0 to 6 levels, should we mention?
> [Srikanth] edited.
> [KS] CLI option  is --rskip, not --r-skip
> [srikanth] edited
> [KS] We do malloc_zero here including the margins instead of copying the
> last row/column values to the padding. IIRC, copying last row/column values
> has some significance for interpolation/MC. Can you verify if this is right
> to do ?
> How is this question relevant here ? I don't understand.
>
[KS] I basically wanted you to confirm if the pixel value of padding has an
impact on the edge based depth decisions your algorithm is taking
[Srikanth] we are marking the margin pixels as dark pixels just like in AQ
mode 4. Taking this up as an evaluation step for later. Refer JIRA: X265-848

>  if (m_fencPic->create(param, !!m_param->bCopyPicToFrame) &&
>> m_lowres.create(param, m_fencPic, param->rc.qgSize))
>>  {
>>  X265_CHECK((m_reconColCount == NULL), "m_reconColCount was
>> initialized");
>> @@ -267,4 +282,10 @@
>>  X265_FREE(m_gaussianPic);
>>  X265_FREE(m_thetaPic);
>>  }
>> +
>> +if (m_param->bEnableRecursionSkip >= EDGE_BASED_RSKIP)
>> +{
>> +X265_FREE_ZERO(m_edgeBitPlane);
>> +m_edgeBitPic = NULL;
>> +}
>>  }
>> diff -r fdbd4e4a2aff -r e9c8c0089bdd source/common/frame.h
>> --- a/source/common/frame.h Sat Jan 25 18:08:03 2020 +0530
>> +++ b/source/common/frame.h Wed Jan 29 12:19:07 2020 +0530
>> @@ -137,6 +137,9 @@
>>  pixel* m_gaussianPic;
>>  pixel* m_thetaPic;
>>
>> +pixel* m_edgeBitPlane;
>> +pixel* m_edgeBitPic;
>>
> [KS] Do we need 2 pointers? m_edgeBitPlane is used only for
> allocation/freeing, in all other places only edgepic is used.
> [Srikanth] Yes. This is a fix to avoid unnecessary computation of the
> edgepic pointer for every CU.
>
[KS] I understand that from your code. My suggestion is to see if you can
find an alternate way to do the same logic without adding a member to Frame
class.

> +uint32_t   m_bitPlaneSize;
>>
> [KS] when bitPlaneSize can be a local variable, what is the significance
> for making it part of Frame?
> [Srikanth] to avoid duplication of the computation in the future.
>
[KS] Is there any followup patch that uses this size? If not, I recommend
making it local for now
[Srikanth] Addressed.

> [KS]   bEnableRecursionSkip ==  RDCOST/EDGE_BASED_RSKIP is checked twice
> unnecessarily (you do it once before complexityCheck CU call). Can you
> optimize this code?
> [KS] same here
> [Srikanth] No. currently the idea is to run both the algorithms
> independently in different modes and not simultaneously.  We cannot
> optimize further here even if I replace with a switch we will still be
> doing the same number of integer comparisons.
>
[KS] I feel it can be a little cleaner. I will let you take the call on
code optimization.
[Srikanth] cleaned up the code here.
[KS] The function is called only if  rskip >= EDGE_BASED_RSKIP ||
rskip == RDCOST_BASED_RSKIP, in that case can help me understand why you
need a else-if? Rewriting the conditional statements appropriately should
resolve compiler warnings.
[Srikanth] Resolved.


On Tue, Feb 4, 2020 at 6:18 PM Kavitha Sampath 
wrote:

>
>
> On Tue, Feb 4, 2020 at 5:10 PM Srikanth Kurapati <
> srikanth.kurap...@multicorewareinc.com> wrote:
>
>> On Wed, Jan 29, 2020 at 12:20 PM 
>> wrote:
>>
>>> # HG changeset patch
>>> # User Srikanth Kurapati
>>> # Date 1580280547 -19800
>>> #  Wed Jan 29 12:19:07 2020 +0530
>>> # Node ID e9c8c0089bddc9e9e47774b5fda1f4dff1fb45e4
>>> # Parent  fdbd4e4a2aff93bfc14b10efcd9e681a7ebae311
>>> Edge Aware Quad Tree Establishment.
>>>
>>> This patch does the following:
>>> 1. Terminates recursion using edge information.
>>> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2,3 for
>>> edge based
>>> rskips for RD levels 0 to 6.
>>>
>> [KS] Since there are only 0 to 6 levels, should we mention?
>> [Srikanth] edited.
>> [KS] CLI option  is --rskip, not --r-skip
>> [srikanth] edited
>> [KS] We do malloc_zero here including the margins instead of copying the
>> last row/column values to the padding. IIRC, copying last row/column values
>> has some significance for interpolation/MC. Can you verify if this is right
>> to do ?
>> How is this question relevant here ? I don't 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-04 Thread Kavitha Sampath
On Tue, Feb 4, 2020 at 5:10 PM Srikanth Kurapati <
srikanth.kurap...@multicorewareinc.com> wrote:

> On Wed, Jan 29, 2020 at 12:20 PM 
> wrote:
>
>> # HG changeset patch
>> # User Srikanth Kurapati
>> # Date 1580280547 -19800
>> #  Wed Jan 29 12:19:07 2020 +0530
>> # Node ID e9c8c0089bddc9e9e47774b5fda1f4dff1fb45e4
>> # Parent  fdbd4e4a2aff93bfc14b10efcd9e681a7ebae311
>> Edge Aware Quad Tree Establishment.
>>
>> This patch does the following:
>> 1. Terminates recursion using edge information.
>> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2,3 for edge
>> based
>> rskips for RD levels 0 to 6.
>>
> [KS] Since there are only 0 to 6 levels, should we mention?
> [Srikanth] edited.
> [KS] CLI option  is --rskip, not --r-skip
> [srikanth] edited
> [KS] We do malloc_zero here including the margins instead of copying the
> last row/column values to the padding. IIRC, copying last row/column values
> has some significance for interpolation/MC. Can you verify if this is right
> to do ?
> How is this question relevant here ? I don't understand.
>
[KS] I basically wanted you to confirm if the pixel value of padding has an
impact on the edge based depth decisions your algorithm is taking

>  if (m_fencPic->create(param, !!m_param->bCopyPicToFrame) &&
>> m_lowres.create(param, m_fencPic, param->rc.qgSize))
>>  {
>>  X265_CHECK((m_reconColCount == NULL), "m_reconColCount was
>> initialized");
>> @@ -267,4 +282,10 @@
>>  X265_FREE(m_gaussianPic);
>>  X265_FREE(m_thetaPic);
>>  }
>> +
>> +if (m_param->bEnableRecursionSkip >= EDGE_BASED_RSKIP)
>> +{
>> +X265_FREE_ZERO(m_edgeBitPlane);
>> +m_edgeBitPic = NULL;
>> +}
>>  }
>> diff -r fdbd4e4a2aff -r e9c8c0089bdd source/common/frame.h
>> --- a/source/common/frame.h Sat Jan 25 18:08:03 2020 +0530
>> +++ b/source/common/frame.h Wed Jan 29 12:19:07 2020 +0530
>> @@ -137,6 +137,9 @@
>>  pixel* m_gaussianPic;
>>  pixel* m_thetaPic;
>>
>> +pixel* m_edgeBitPlane;
>> +pixel* m_edgeBitPic;
>>
> [KS] Do we need 2 pointers? m_edgeBitPlane is used only for
> allocation/freeing, in all other places only edgepic is used.
> [Srikanth] Yes. This is a fix to avoid unnecessary computation of the
> edgepic pointer for every CU.
>
[KS] I understand that from your code. My suggestion is to see if you can
find an alternate way to do the same logic without adding a member to Frame
class.

> +uint32_t   m_bitPlaneSize;
>>
> [KS] when bitPlaneSize can be a local variable, what is the significance
> for making it part of Frame?
> [Srikanth] to avoid duplication of the computation in the future.
>
[KS] Is there any followup patch that uses this size? If not, I recommend
making it local for now

> [KS]   bEnableRecursionSkip ==  RDCOST/EDGE_BASED_RSKIP is checked twice
> unnecessarily (you do it once before complexityCheck CU call). Can you
> optimize this code?
> [KS] same here
> [Srikanth] No. currently the idea is to run both the algorithms
> independently in different modes and not simultaneously.  We cannot
> optimize further here even if I replace with a switch we will still be
> doing the same number of integer comparisons.
>
[KS] I feel it can be a little cleaner. I will let you take the call on
code optimization.

> +{
>> +int blockType = bestMode.cu.m_log2CUSize[0] - 2;
>> +int shift = bestMode.cu.m_log2CUSize[0] * 2;
>> +intptr_t stride = m_frame->m_fencPic->m_stride;
>> +intptr_t blockOffsetLuma = bestMode.cu.m_cuPelX +
>> bestMode.cu.m_cuPelY * stride;
>> +uint64_t sum_ss = primitives.cu[blockType].var(m_frame->m_edgeBitPic
>> + blockOffsetLuma, stride);
>> +uint32_t sum = (uint32_t)sum_ss;
>> +uint32_t ss = (uint32_t)(sum_ss >> 32);
>> +uint32_t pixelCount = 1 << shift;
>> +double cuEdgeVariance = (ss - ((double)sum * sum / pixelCount))
>> / pixelCount;
>> +if (cuEdgeVariance > (double)m_param->edgeThreshold)
>> +return false;
>> +else
>> +return true;
>>  }
>>
> [KS] Earlier for my question to combine edgeRecursion with
> complexityCheck, you mentioned that - Homogeneity and variance are two
> different metrics and they don't do the same functionality and so you
> didn't combine. I would like to understand the reasoning behind combining
> them in this patch.
> [Srikanth] the function prototypes turned out to be the same and they are
> for similar purpose.
>
>> -homo = homo / (cuSize * cuSize);
>> -
>> -if (homo < (.1 * mean))
>> -return true;
>> -
>> -return false;
>> +else
>> +return false;
>>
> [KS] When does the encoder hit this final "else"?
> [Srikanth] It's just a safety mechanism which will otherwise lead to
> compiler warnings.
>
[KS] The function is called only if  rskip >= EDGE_BASED_RSKIP ||
rskip == RDCOST_BASED_RSKIP, in that case can help me 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-04 Thread Srikanth Kurapati
On Wed, Jan 29, 2020 at 12:20 PM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1580280547 -19800
> #  Wed Jan 29 12:19:07 2020 +0530
> # Node ID e9c8c0089bddc9e9e47774b5fda1f4dff1fb45e4
> # Parent  fdbd4e4a2aff93bfc14b10efcd9e681a7ebae311
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion using edge information.
> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2,3 for edge
> based
> rskips for RD levels 0 to 6.
>
[KS] Since there are only 0 to 6 levels, should we mention?
[Srikanth] edited.
[KS] CLI option  is --rskip, not --r-skip
[srikanth] edited
[KS] We do malloc_zero here including the margins instead of copying the
last row/column values to the padding. IIRC, copying last row/column values
has some significance for interpolation/MC. Can you verify if this is right
to do ?
How is this question relevant here ? I don't understand.

>  if (m_fencPic->create(param, !!m_param->bCopyPicToFrame) &&
> m_lowres.create(param, m_fencPic, param->rc.qgSize))
>  {
>  X265_CHECK((m_reconColCount == NULL), "m_reconColCount was
> initialized");
> @@ -267,4 +282,10 @@
>  X265_FREE(m_gaussianPic);
>  X265_FREE(m_thetaPic);
>  }
> +
> +if (m_param->bEnableRecursionSkip >= EDGE_BASED_RSKIP)
> +{
> +X265_FREE_ZERO(m_edgeBitPlane);
> +m_edgeBitPic = NULL;
> +}
>  }
> diff -r fdbd4e4a2aff -r e9c8c0089bdd source/common/frame.h
> --- a/source/common/frame.h Sat Jan 25 18:08:03 2020 +0530
> +++ b/source/common/frame.h Wed Jan 29 12:19:07 2020 +0530
> @@ -137,6 +137,9 @@
>  pixel* m_gaussianPic;
>  pixel* m_thetaPic;
>
> +pixel* m_edgeBitPlane;
> +pixel* m_edgeBitPic;
>
[KS] Do we need 2 pointers? m_edgeBitPlane is used only for
allocation/freeing, in all other places only edgepic is used.
[Srikanth] Yes. This is a fix to avoid unnecessary computation of the
edgepic pointer for every CU.

> +uint32_t   m_bitPlaneSize;
>
[KS] when bitPlaneSize can be a local variable, what is the significance
for making it part of Frame?
[Srikanth] to avoid duplication of the computation in the future.
[KS]   bEnableRecursionSkip ==  RDCOST/EDGE_BASED_RSKIP is checked twice
unnecessarily (you do it once before complexityCheck CU call). Can you
optimize this code?
[KS] same here
[Srikanth] No. currently the idea is to run both the algorithms
independently in different modes and not simultaneously.  We cannot
optimize further here even if I replace with a switch we will still be
doing the same number of integer comparisons.

> +{
> +int blockType = bestMode.cu.m_log2CUSize[0] - 2;
> +int shift = bestMode.cu.m_log2CUSize[0] * 2;
> +intptr_t stride = m_frame->m_fencPic->m_stride;
> +intptr_t blockOffsetLuma = bestMode.cu.m_cuPelX +
> bestMode.cu.m_cuPelY * stride;
> +uint64_t sum_ss = primitives.cu[blockType].var(m_frame->m_edgeBitPic
> + blockOffsetLuma, stride);
> +uint32_t sum = (uint32_t)sum_ss;
> +uint32_t ss = (uint32_t)(sum_ss >> 32);
> +uint32_t pixelCount = 1 << shift;
> +double cuEdgeVariance = (ss - ((double)sum * sum / pixelCount)) /
> pixelCount;
> +if (cuEdgeVariance > (double)m_param->edgeThreshold)
> +return false;
> +else
> +return true;
>  }
>
[KS] Earlier for my question to combine edgeRecursion with complexityCheck,
you mentioned that - Homogeneity and variance are two different metrics and
they don't do the same functionality and so you didn't combine. I would
like to understand the reasoning behind combining them in this patch.
[Srikanth] the function prototypes turned out to be the same and they are
for similar purpose.

> -homo = homo / (cuSize * cuSize);
> -
> -if (homo < (.1 * mean))
> -return true;
> -
> -return false;
> +else
> +return false;
>
[KS] When does the encoder hit this final "else"?
[Srikanth] It's just a safety mechanism which will otherwise lead to
compiler warnings.

On Mon, Feb 3, 2020 at 3:46 PM Kavitha Sampath 
wrote:

>
>
> On Wed, Jan 29, 2020 at 12:20 PM 
> wrote:
>
>> # HG changeset patch
>> # User Srikanth Kurapati
>> # Date 1580280547 -19800
>> #  Wed Jan 29 12:19:07 2020 +0530
>> # Node ID e9c8c0089bddc9e9e47774b5fda1f4dff1fb45e4
>> # Parent  fdbd4e4a2aff93bfc14b10efcd9e681a7ebae311
>> Edge Aware Quad Tree Establishment.
>>
>> This patch does the following:
>> 1. Terminates recursion using edge information.
>> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2,3 for edge
>> based
>> rskips for RD levels 0 to 6.
>>
> [KS] Since there are only 0 to 6 levels, should we mention?
>
>> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
>> density.
>> 4. Re uses edge information when already available in encoder.
>>
>> diff -r fdbd4e4a2aff -r e9c8c0089bdd 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-03 Thread Kavitha Sampath
On Wed, Jan 29, 2020 at 12:20 PM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1580280547 -19800
> #  Wed Jan 29 12:19:07 2020 +0530
> # Node ID e9c8c0089bddc9e9e47774b5fda1f4dff1fb45e4
> # Parent  fdbd4e4a2aff93bfc14b10efcd9e681a7ebae311
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion using edge information.
> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2,3 for edge
> based
> rskips for RD levels 0 to 6.
>
[KS] Since there are only 0 to 6 levels, should we mention?

> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
> density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r fdbd4e4a2aff -r e9c8c0089bdd doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Sat Jan 25 18:08:03 2020 +0530
> +++ b/doc/reST/cli.rst  Wed Jan 29 12:19:07 2020 +0530
> @@ -842,15 +842,31 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2|3>
> +
> +   This option determines early exit from CU depth recursion in modes
> 1, 2 and 3. When a skip CU is
> +   found, additional heuristics (depending on RD level and rskip
> mode) are used to decide whether
> +   to terminate recursion. The following table summarizes the
> behavior.
> +
> +
>  
> +--+++
> +   | RD Level | Rskip Mode |   Skip Recursion Heuristic
>|
> +
>  
> +==+++
> +   |   0 - 4  |  1 |   Neighbour costs.
>|
> +
>  
> +--+++
> +   |   5 - 6  |  1 |   Comparison with inter2Nx2N.
>   |
> +
>  
> +--+++
> +   |   0 - 6  |  2 |   CU edge denstiy.
>|
> +
>  
> +--+++
> +   |   0 - 6  |  3 |   CU edge denstiy with forceful skip for
> lower levels of CTU.  |
> +
>  
> +--+++
> +
> +   Provides minimal quality degradation at good performance gains for
> non-zero modes.
> +   :option:`--r-skip mode 0` means disabled. Default: 1, disabled
> when :option:`--tune grain` is used.
>
[KS] CLI option  is --rskip, not --r-skip

> +
> +.. option:: --edge-threshold <0..100>
> +
> +   Denotes the minimum expected edge-density percentage within the
> CU, below which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2|3` to be enabled.
>
>  .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r fdbd4e4a2aff -r e9c8c0089bdd source/CMakeLists.txt
> --- a/source/CMakeLists.txt Sat Jan 25 18:08:03 2020 +0530
> +++ b/source/CMakeLists.txt Wed Jan 29 12:19:07 2020 +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 188)
> +set(X265_BUILD 189)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r fdbd4e4a2aff -r e9c8c0089bdd source/common/common.h
> --- a/source/common/common.hSat Jan 25 18:08:03 2020 +0530
> +++ b/source/common/common.hWed Jan 29 12:19:07 2020 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #define SHIFT 1
>  #else
> @@ -137,6 +138,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #define SHIFT 0
>  #endif // if HIGH_BIT_DEPTH
> @@ -272,6 +274,9 @@
>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>
> +#define RDCOST_BASED_RSKIP 1
> +#define EDGE_BASED_RSKIP 2
> +
>  

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-03 Thread Srikanth Kurapati
[KS] 4500 CUs covering contents with varied level of complexity ?
[Srikanth] Yes. The variance for the set  of CUs varies from (0,0.25) which
is the maximum range i have observed so far in the tests.

On Mon, Feb 3, 2020 at 2:38 PM Kavitha Sampath 
wrote:

>
>
> On Wed, Jan 29, 2020 at 12:38 PM Srikanth Kurapati <
> srikanth.kurap...@multicorewareinc.com> wrote:
>
>> [KS] Are we going to have the same default threshold for both flows -
>> (a)histogram based scenecut =1 && aqmode=0 (b)  histogram based scenecut =0
>> && aqmode=1
>> When the variance of the two flows can vary, shouldn't the thresholds
>> vary?
>> [KS] The docs isn't giving much guidance to users on how to set the
>> threshold for each of the flows you are handling
>> [Srikanth] No. The same threshold works as  On an avg the Denoised
>> variance is 0.036 lesser than unfiltered Edge(Hist based edge). So the
>> difference is too less. We checked this for 4500 CUs.  So user can use
>> same threshold irrespective of the flows.
>>
> [KS] 4500 CUs covering contents with varied level of complexity ?
>
>> [KS] edgePic's address is the same for every CU in a frame. Why are you
>> computing this initial offset every time?
>> [Srikanth] Addressed.
>>
>>> +intptr_t blockOffsetLuma = (ctu.m_cuPelX +
>>> g_zscanToPelX[cuGeom.absPartIdx]) + (ctu.m_cuPelY +
>>> g_zscanToPelY[cuGeom.absPartIdx]) * stride;
>>>
>> [KS] luma offset computation looks complex with g_zscanToPelX /Y
>> addition. Any specific reason for not using bestMode's data?
>> [Srikanth] reused best mode data and merged the implementation with
>> complexity check CU function
>> [KS] I don't understand the purpose to test veryslow with rskip 2 when
>> this algorithm works only for rd 0 to 4 (atleast this patch does only
>> that).
>> Please clarify your intention for adding this command
>> [Srikanth] This patch includes changes for RD Levels 5 and 6.  Changed
>> the command to preset slow as rd level 6 is enabled even in this mode.
>>
>> On Wed, Jan 22, 2020 at 4:30 PM Kavitha Sampath <
>> kavi...@multicorewareinc.com> wrote:
>>
>>>
>>>
>>> On Tue, Jan 21, 2020 at 11:32 AM 
>>> wrote:
>>>
 # HG changeset patch
 # User Srikanth Kurapati
 # Date 1579584229 -19800
 #  Tue Jan 21 10:53:49 2020 +0530
 # Node ID e0e0270ead4189a545821b00011c47d61e6b817a
 # Parent  acc5d16999e2faf6e75ecc1df9a01c1953ebaf8c
 Edge Aware Quad Tree Establishment.

 This patch does the following:
 1. Terminates recursion using edge information.
 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
 based
 rskip for RD levels 0 to 4.
 3. Adds option "edge-threshold" to decide recursion skip using CU edge
 density.
 4. Re uses edge information when already available in encoder.

 diff -r acc5d16999e2 -r e0e0270ead41 doc/reST/cli.rst
 --- a/doc/reST/cli.rst  Mon Jan 20 18:07:59 2020 +0530
 +++ b/doc/reST/cli.rst  Tue Jan 21 10:53:49 2020 +0530
 @@ -842,15 +842,20 @@
 Measure 2Nx2N merge candidates first; if no residual is found,
 additional modes at that depth are not analysed. Default
 disabled

 -.. option:: --rskip, --no-rskip
 -
 -   This option determines early exit from CU depth recursion. When
 a skip CU is
 -   found, additional heuristics (depending on rd-level) are used
 to decide whether
 -   to terminate recursion. In rdlevels 5 and 6, comparison with
 inter2Nx2N is used,
 -   while at rdlevels 4 and neighbour costs are used to skip
 recursion.
 -   Provides minimal quality degradation at good performance gains
 when enabled.
 -
 -   Default: enabled, disabled for :option:`--tune grain`
 +.. option:: --rskip <0|1|2>
 +
 +   This option determines early exit from CU depth recursion in
 modes 1 and 2. When a skip CU is
 +   found, additional heuristics (depending on RD level and rskip
 mode) are used to decide whether
 +   to terminate recursion. In RD levels 5 and 6, comparison with
 inter2Nx2N is used,
 +   while at RD levels 4 and below, neighbour costs are used to
 skip recursion in mode 1, and CU edge density in mode 2.
 +   Provides minimal quality degradation at good performance gains
 for non-zero modes. :option:`--r-skip mode 0` means disabled.
 +
 +   Default: 1, disabled when :option:`--tune grain` is used.
 +
 +.. option:: --edge-threshold <0..100>
 +
 +   Denotes the minimum expected edge-density percentage within the
 CU, below which the recursion is skipped.
 +   Default: 5, requires :option:`--rskip mode 2` to be enabled.

>>>  .. option:: --splitrd-skip, --no-splitrd-skip

 diff -r acc5d16999e2 -r e0e0270ead41 source/CMakeLists.txt
 --- a/source/CMakeLists.txt Mon Jan 20 18:07:59 2020 +0530
 +++ b/source/CMakeLists.txt Tue Jan 21 10:53:49 2020 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-02-03 Thread Kavitha Sampath
On Wed, Jan 29, 2020 at 12:38 PM Srikanth Kurapati <
srikanth.kurap...@multicorewareinc.com> wrote:

> [KS] Are we going to have the same default threshold for both flows -
> (a)histogram based scenecut =1 && aqmode=0 (b)  histogram based scenecut =0
> && aqmode=1
> When the variance of the two flows can vary, shouldn't the thresholds vary?
> [KS] The docs isn't giving much guidance to users on how to set the
> threshold for each of the flows you are handling
> [Srikanth] No. The same threshold works as  On an avg the Denoised
> variance is 0.036 lesser than unfiltered Edge(Hist based edge). So the
> difference is too less. We checked this for 4500 CUs.  So user can use
> same threshold irrespective of the flows.
>
[KS] 4500 CUs covering contents with varied level of complexity ?

> [KS] edgePic's address is the same for every CU in a frame. Why are you
> computing this initial offset every time?
> [Srikanth] Addressed.
>
>> +intptr_t blockOffsetLuma = (ctu.m_cuPelX +
>> g_zscanToPelX[cuGeom.absPartIdx]) + (ctu.m_cuPelY +
>> g_zscanToPelY[cuGeom.absPartIdx]) * stride;
>>
> [KS] luma offset computation looks complex with g_zscanToPelX /Y addition.
> Any specific reason for not using bestMode's data?
> [Srikanth] reused best mode data and merged the implementation with
> complexity check CU function
> [KS] I don't understand the purpose to test veryslow with rskip 2 when
> this algorithm works only for rd 0 to 4 (atleast this patch does only
> that).
> Please clarify your intention for adding this command
> [Srikanth] This patch includes changes for RD Levels 5 and 6.  Changed the
> command to preset slow as rd level 6 is enabled even in this mode.
>
> On Wed, Jan 22, 2020 at 4:30 PM Kavitha Sampath <
> kavi...@multicorewareinc.com> wrote:
>
>>
>>
>> On Tue, Jan 21, 2020 at 11:32 AM 
>> wrote:
>>
>>> # HG changeset patch
>>> # User Srikanth Kurapati
>>> # Date 1579584229 -19800
>>> #  Tue Jan 21 10:53:49 2020 +0530
>>> # Node ID e0e0270ead4189a545821b00011c47d61e6b817a
>>> # Parent  acc5d16999e2faf6e75ecc1df9a01c1953ebaf8c
>>> Edge Aware Quad Tree Establishment.
>>>
>>> This patch does the following:
>>> 1. Terminates recursion using edge information.
>>> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
>>> based
>>> rskip for RD levels 0 to 4.
>>> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
>>> density.
>>> 4. Re uses edge information when already available in encoder.
>>>
>>> diff -r acc5d16999e2 -r e0e0270ead41 doc/reST/cli.rst
>>> --- a/doc/reST/cli.rst  Mon Jan 20 18:07:59 2020 +0530
>>> +++ b/doc/reST/cli.rst  Tue Jan 21 10:53:49 2020 +0530
>>> @@ -842,15 +842,20 @@
>>> Measure 2Nx2N merge candidates first; if no residual is found,
>>> additional modes at that depth are not analysed. Default disabled
>>>
>>> -.. option:: --rskip, --no-rskip
>>> -
>>> -   This option determines early exit from CU depth recursion. When
>>> a skip CU is
>>> -   found, additional heuristics (depending on rd-level) are used to
>>> decide whether
>>> -   to terminate recursion. In rdlevels 5 and 6, comparison with
>>> inter2Nx2N is used,
>>> -   while at rdlevels 4 and neighbour costs are used to skip
>>> recursion.
>>> -   Provides minimal quality degradation at good performance gains
>>> when enabled.
>>> -
>>> -   Default: enabled, disabled for :option:`--tune grain`
>>> +.. option:: --rskip <0|1|2>
>>> +
>>> +   This option determines early exit from CU depth recursion in
>>> modes 1 and 2. When a skip CU is
>>> +   found, additional heuristics (depending on RD level and rskip
>>> mode) are used to decide whether
>>> +   to terminate recursion. In RD levels 5 and 6, comparison with
>>> inter2Nx2N is used,
>>> +   while at RD levels 4 and below, neighbour costs are used to skip
>>> recursion in mode 1, and CU edge density in mode 2.
>>> +   Provides minimal quality degradation at good performance gains
>>> for non-zero modes. :option:`--r-skip mode 0` means disabled.
>>> +
>>> +   Default: 1, disabled when :option:`--tune grain` is used.
>>> +
>>> +.. option:: --edge-threshold <0..100>
>>> +
>>> +   Denotes the minimum expected edge-density percentage within the
>>> CU, below which the recursion is skipped.
>>> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>>>
>>  .. option:: --splitrd-skip, --no-splitrd-skip
>>>
>>> diff -r acc5d16999e2 -r e0e0270ead41 source/CMakeLists.txt
>>> --- a/source/CMakeLists.txt Mon Jan 20 18:07:59 2020 +0530
>>> +++ b/source/CMakeLists.txt Tue Jan 21 10:53:49 2020 +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 188)
>>> +set(X265_BUILD 189)
>>>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>>> 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-28 Thread Srikanth Kurapati
[KS] Are we going to have the same default threshold for both flows -
(a)histogram based scenecut =1 && aqmode=0 (b)  histogram based scenecut =0
&& aqmode=1
When the variance of the two flows can vary, shouldn't the thresholds vary?
[KS] The docs isn't giving much guidance to users on how to set the
threshold for each of the flows you are handling
[Srikanth] No. The same threshold works as  On an avg the Denoised variance
is 0.036 lesser than unfiltered Edge(Hist based edge). So the difference is
too less. We checked this for 4500 CUs.  So user can use same threshold
irrespective of the flows.
[KS] edgePic's address is the same for every CU in a frame. Why are you
computing this initial offset every time?
[Srikanth] Addressed.

> +intptr_t blockOffsetLuma = (ctu.m_cuPelX +
> g_zscanToPelX[cuGeom.absPartIdx]) + (ctu.m_cuPelY +
> g_zscanToPelY[cuGeom.absPartIdx]) * stride;
>
[KS] luma offset computation looks complex with g_zscanToPelX /Y addition.
Any specific reason for not using bestMode's data?
[Srikanth] reused best mode data and merged the implementation with
complexity check CU function
[KS] I don't understand the purpose to test veryslow with rskip 2 when this
algorithm works only for rd 0 to 4 (atleast this patch does only that).
Please clarify your intention for adding this command
[Srikanth] This patch includes changes for RD Levels 5 and 6.  Changed the
command to preset slow as rd level 6 is enabled even in this mode.

On Wed, Jan 22, 2020 at 4:30 PM Kavitha Sampath <
kavi...@multicorewareinc.com> wrote:

>
>
> On Tue, Jan 21, 2020 at 11:32 AM 
> wrote:
>
>> # HG changeset patch
>> # User Srikanth Kurapati
>> # Date 1579584229 -19800
>> #  Tue Jan 21 10:53:49 2020 +0530
>> # Node ID e0e0270ead4189a545821b00011c47d61e6b817a
>> # Parent  acc5d16999e2faf6e75ecc1df9a01c1953ebaf8c
>> Edge Aware Quad Tree Establishment.
>>
>> This patch does the following:
>> 1. Terminates recursion using edge information.
>> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
>> based
>> rskip for RD levels 0 to 4.
>> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
>> density.
>> 4. Re uses edge information when already available in encoder.
>>
>> diff -r acc5d16999e2 -r e0e0270ead41 doc/reST/cli.rst
>> --- a/doc/reST/cli.rst  Mon Jan 20 18:07:59 2020 +0530
>> +++ b/doc/reST/cli.rst  Tue Jan 21 10:53:49 2020 +0530
>> @@ -842,15 +842,20 @@
>> Measure 2Nx2N merge candidates first; if no residual is found,
>> additional modes at that depth are not analysed. Default disabled
>>
>> -.. option:: --rskip, --no-rskip
>> -
>> -   This option determines early exit from CU depth recursion. When a
>> skip CU is
>> -   found, additional heuristics (depending on rd-level) are used to
>> decide whether
>> -   to terminate recursion. In rdlevels 5 and 6, comparison with
>> inter2Nx2N is used,
>> -   while at rdlevels 4 and neighbour costs are used to skip
>> recursion.
>> -   Provides minimal quality degradation at good performance gains
>> when enabled.
>> -
>> -   Default: enabled, disabled for :option:`--tune grain`
>> +.. option:: --rskip <0|1|2>
>> +
>> +   This option determines early exit from CU depth recursion in
>> modes 1 and 2. When a skip CU is
>> +   found, additional heuristics (depending on RD level and rskip
>> mode) are used to decide whether
>> +   to terminate recursion. In RD levels 5 and 6, comparison with
>> inter2Nx2N is used,
>> +   while at RD levels 4 and below, neighbour costs are used to skip
>> recursion in mode 1, and CU edge density in mode 2.
>> +   Provides minimal quality degradation at good performance gains
>> for non-zero modes. :option:`--r-skip mode 0` means disabled.
>> +
>> +   Default: 1, disabled when :option:`--tune grain` is used.
>> +
>> +.. option:: --edge-threshold <0..100>
>> +
>> +   Denotes the minimum expected edge-density percentage within the
>> CU, below which the recursion is skipped.
>> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>>
>  .. option:: --splitrd-skip, --no-splitrd-skip
>>
>> diff -r acc5d16999e2 -r e0e0270ead41 source/CMakeLists.txt
>> --- a/source/CMakeLists.txt Mon Jan 20 18:07:59 2020 +0530
>> +++ b/source/CMakeLists.txt Tue Jan 21 10:53:49 2020 +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 188)
>> +set(X265_BUILD 189)
>>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>> "${PROJECT_BINARY_DIR}/x265.def")
>>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
>> diff -r acc5d16999e2 -r e0e0270ead41 source/common/common.h
>> --- a/source/common/common.hMon Jan 20 18:07:59 2020 +0530
>> +++ b/source/common/common.hTue Jan 21 10:53:49 2020 +0530
>> @@ -129,6 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-22 Thread Srikanth Kurapati
This patch provided rskip=2 for rd levels 0 to 4. For rd levels 5 and 6 it
will be provided through a subsequent patch.

On Wed, Jan 22, 2020 at 5:53 PM Alex Giladi  wrote:

> Why would rskip=2 not work on rd > 4?
> Is there a technical reason, or is there an implicit assumption that the
> users won't want to use rskip at rd > 4?
>
> On Wed, Jan 22, 2020, 04:00 Kavitha Sampath 
> wrote:
>
>>
>>
>> On Tue, Jan 21, 2020 at 11:32 AM 
>> wrote:
>>
>>> # HG changeset patch
>>> # User Srikanth Kurapati
>>> # Date 1579584229 -19800
>>> #  Tue Jan 21 10:53:49 2020 +0530
>>> # Node ID e0e0270ead4189a545821b00011c47d61e6b817a
>>> # Parent  acc5d16999e2faf6e75ecc1df9a01c1953ebaf8c
>>> Edge Aware Quad Tree Establishment.
>>>
>>> This patch does the following:
>>> 1. Terminates recursion using edge information.
>>> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
>>> based
>>> rskip for RD levels 0 to 4.
>>> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
>>> density.
>>> 4. Re uses edge information when already available in encoder.
>>>
>>> diff -r acc5d16999e2 -r e0e0270ead41 doc/reST/cli.rst
>>> --- a/doc/reST/cli.rst  Mon Jan 20 18:07:59 2020 +0530
>>> +++ b/doc/reST/cli.rst  Tue Jan 21 10:53:49 2020 +0530
>>> @@ -842,15 +842,20 @@
>>> Measure 2Nx2N merge candidates first; if no residual is found,
>>> additional modes at that depth are not analysed. Default disabled
>>>
>>> -.. option:: --rskip, --no-rskip
>>> -
>>> -   This option determines early exit from CU depth recursion. When
>>> a skip CU is
>>> -   found, additional heuristics (depending on rd-level) are used to
>>> decide whether
>>> -   to terminate recursion. In rdlevels 5 and 6, comparison with
>>> inter2Nx2N is used,
>>> -   while at rdlevels 4 and neighbour costs are used to skip
>>> recursion.
>>> -   Provides minimal quality degradation at good performance gains
>>> when enabled.
>>> -
>>> -   Default: enabled, disabled for :option:`--tune grain`
>>> +.. option:: --rskip <0|1|2>
>>> +
>>> +   This option determines early exit from CU depth recursion in
>>> modes 1 and 2. When a skip CU is
>>> +   found, additional heuristics (depending on RD level and rskip
>>> mode) are used to decide whether
>>> +   to terminate recursion. In RD levels 5 and 6, comparison with
>>> inter2Nx2N is used,
>>> +   while at RD levels 4 and below, neighbour costs are used to skip
>>> recursion in mode 1, and CU edge density in mode 2.
>>> +   Provides minimal quality degradation at good performance gains
>>> for non-zero modes. :option:`--r-skip mode 0` means disabled.
>>> +
>>> +   Default: 1, disabled when :option:`--tune grain` is used.
>>> +
>>> +.. option:: --edge-threshold <0..100>
>>> +
>>> +   Denotes the minimum expected edge-density percentage within the
>>> CU, below which the recursion is skipped.
>>> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>>>
>>  .. option:: --splitrd-skip, --no-splitrd-skip
>>>
>>> diff -r acc5d16999e2 -r e0e0270ead41 source/CMakeLists.txt
>>> --- a/source/CMakeLists.txt Mon Jan 20 18:07:59 2020 +0530
>>> +++ b/source/CMakeLists.txt Tue Jan 21 10:53:49 2020 +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 188)
>>> +set(X265_BUILD 189)
>>>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>>> "${PROJECT_BINARY_DIR}/x265.def")
>>>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
>>> diff -r acc5d16999e2 -r e0e0270ead41 source/common/common.h
>>> --- a/source/common/common.hMon Jan 20 18:07:59 2020 +0530
>>> +++ b/source/common/common.hTue Jan 21 10:53:49 2020 +0530
>>> @@ -129,6 +129,7 @@
>>>  typedef uint64_t sum2_t;
>>>  typedef uint64_t pixel4;
>>>  typedef int64_t  ssum2_t;
>>> +#define SHIFT_TO_BITPLANE 9
>>>  #define HISTOGRAM_BINS 1024
>>>  #define SHIFT 1
>>>  #else
>>> @@ -137,6 +138,7 @@
>>>  typedef uint32_t sum2_t;
>>>  typedef uint32_t pixel4;
>>>  typedef int32_t  ssum2_t; // Signed sum
>>> +#define SHIFT_TO_BITPLANE 7
>>>  #define HISTOGRAM_BINS 256
>>>  #define SHIFT 0
>>>  #endif // if HIGH_BIT_DEPTH
>>> @@ -272,6 +274,9 @@
>>>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>>>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>>>
>>> +#define RDCOST_BASED_RSKIP 1
>>> +#define EDGE_BASED_RSKIP 2
>>> +
>>>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which
>>> the VLC
>>>// transitions from Golomb-Rice
>>> to TU+EG(k)
>>>
>>> diff -r acc5d16999e2 -r e0e0270ead41 source/common/frame.cpp
>>> --- a/source/common/frame.cpp   Mon Jan 20 18:07:59 2020 +0530
>>> +++ b/source/common/frame.cpp   Tue Jan 21 10:53:49 2020 +0530
>>> @@ -61,6 +61,7 @@
>>>  m_edgePic = NULL;

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-22 Thread Alex Giladi
Why would rskip=2 not work on rd > 4?
Is there a technical reason, or is there an implicit assumption that the
users won't want to use rskip at rd > 4?

On Wed, Jan 22, 2020, 04:00 Kavitha Sampath 
wrote:

>
>
> On Tue, Jan 21, 2020 at 11:32 AM 
> wrote:
>
>> # HG changeset patch
>> # User Srikanth Kurapati
>> # Date 1579584229 -19800
>> #  Tue Jan 21 10:53:49 2020 +0530
>> # Node ID e0e0270ead4189a545821b00011c47d61e6b817a
>> # Parent  acc5d16999e2faf6e75ecc1df9a01c1953ebaf8c
>> Edge Aware Quad Tree Establishment.
>>
>> This patch does the following:
>> 1. Terminates recursion using edge information.
>> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
>> based
>> rskip for RD levels 0 to 4.
>> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
>> density.
>> 4. Re uses edge information when already available in encoder.
>>
>> diff -r acc5d16999e2 -r e0e0270ead41 doc/reST/cli.rst
>> --- a/doc/reST/cli.rst  Mon Jan 20 18:07:59 2020 +0530
>> +++ b/doc/reST/cli.rst  Tue Jan 21 10:53:49 2020 +0530
>> @@ -842,15 +842,20 @@
>> Measure 2Nx2N merge candidates first; if no residual is found,
>> additional modes at that depth are not analysed. Default disabled
>>
>> -.. option:: --rskip, --no-rskip
>> -
>> -   This option determines early exit from CU depth recursion. When a
>> skip CU is
>> -   found, additional heuristics (depending on rd-level) are used to
>> decide whether
>> -   to terminate recursion. In rdlevels 5 and 6, comparison with
>> inter2Nx2N is used,
>> -   while at rdlevels 4 and neighbour costs are used to skip
>> recursion.
>> -   Provides minimal quality degradation at good performance gains
>> when enabled.
>> -
>> -   Default: enabled, disabled for :option:`--tune grain`
>> +.. option:: --rskip <0|1|2>
>> +
>> +   This option determines early exit from CU depth recursion in
>> modes 1 and 2. When a skip CU is
>> +   found, additional heuristics (depending on RD level and rskip
>> mode) are used to decide whether
>> +   to terminate recursion. In RD levels 5 and 6, comparison with
>> inter2Nx2N is used,
>> +   while at RD levels 4 and below, neighbour costs are used to skip
>> recursion in mode 1, and CU edge density in mode 2.
>> +   Provides minimal quality degradation at good performance gains
>> for non-zero modes. :option:`--r-skip mode 0` means disabled.
>> +
>> +   Default: 1, disabled when :option:`--tune grain` is used.
>> +
>> +.. option:: --edge-threshold <0..100>
>> +
>> +   Denotes the minimum expected edge-density percentage within the
>> CU, below which the recursion is skipped.
>> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>>
>  .. option:: --splitrd-skip, --no-splitrd-skip
>>
>> diff -r acc5d16999e2 -r e0e0270ead41 source/CMakeLists.txt
>> --- a/source/CMakeLists.txt Mon Jan 20 18:07:59 2020 +0530
>> +++ b/source/CMakeLists.txt Tue Jan 21 10:53:49 2020 +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 188)
>> +set(X265_BUILD 189)
>>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>> "${PROJECT_BINARY_DIR}/x265.def")
>>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
>> diff -r acc5d16999e2 -r e0e0270ead41 source/common/common.h
>> --- a/source/common/common.hMon Jan 20 18:07:59 2020 +0530
>> +++ b/source/common/common.hTue Jan 21 10:53:49 2020 +0530
>> @@ -129,6 +129,7 @@
>>  typedef uint64_t sum2_t;
>>  typedef uint64_t pixel4;
>>  typedef int64_t  ssum2_t;
>> +#define SHIFT_TO_BITPLANE 9
>>  #define HISTOGRAM_BINS 1024
>>  #define SHIFT 1
>>  #else
>> @@ -137,6 +138,7 @@
>>  typedef uint32_t sum2_t;
>>  typedef uint32_t pixel4;
>>  typedef int32_t  ssum2_t; // Signed sum
>> +#define SHIFT_TO_BITPLANE 7
>>  #define HISTOGRAM_BINS 256
>>  #define SHIFT 0
>>  #endif // if HIGH_BIT_DEPTH
>> @@ -272,6 +274,9 @@
>>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>>
>> +#define RDCOST_BASED_RSKIP 1
>> +#define EDGE_BASED_RSKIP 2
>> +
>>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which
>> the VLC
>>// transitions from Golomb-Rice to
>> TU+EG(k)
>>
>> diff -r acc5d16999e2 -r e0e0270ead41 source/common/frame.cpp
>> --- a/source/common/frame.cpp   Mon Jan 20 18:07:59 2020 +0530
>> +++ b/source/common/frame.cpp   Tue Jan 21 10:53:49 2020 +0530
>> @@ -61,6 +61,7 @@
>>  m_edgePic = NULL;
>>  m_gaussianPic = NULL;
>>  m_thetaPic = NULL;
>> +m_edgeBitPlane = NULL;
>>  }
>>
>>  bool Frame::create(x265_param *param, float* quantOffsets)
>> @@ -115,6 +116,18 @@
>>  m_thetaPic = X265_MALLOC(pixel, m_stride * (maxHeight +
>> (m_lumaMarginY * 2)));
>>  }
>>
>> +if 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-22 Thread Kavitha Sampath
On Tue, Jan 21, 2020 at 11:32 AM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1579584229 -19800
> #  Tue Jan 21 10:53:49 2020 +0530
> # Node ID e0e0270ead4189a545821b00011c47d61e6b817a
> # Parent  acc5d16999e2faf6e75ecc1df9a01c1953ebaf8c
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion using edge information.
> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
> based
> rskip for RD levels 0 to 4.
> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
> density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r acc5d16999e2 -r e0e0270ead41 doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Mon Jan 20 18:07:59 2020 +0530
> +++ b/doc/reST/cli.rst  Tue Jan 21 10:53:49 2020 +0530
> @@ -842,15 +842,20 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2>
> +
> +   This option determines early exit from CU depth recursion in modes
> 1 and 2. When a skip CU is
> +   found, additional heuristics (depending on RD level and rskip
> mode) are used to decide whether
> +   to terminate recursion. In RD levels 5 and 6, comparison with
> inter2Nx2N is used,
> +   while at RD levels 4 and below, neighbour costs are used to skip
> recursion in mode 1, and CU edge density in mode 2.
> +   Provides minimal quality degradation at good performance gains for
> non-zero modes. :option:`--r-skip mode 0` means disabled.
> +
> +   Default: 1, disabled when :option:`--tune grain` is used.
> +
> +.. option:: --edge-threshold <0..100>
> +
> +   Denotes the minimum expected edge-density percentage within the
> CU, below which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>
 .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r acc5d16999e2 -r e0e0270ead41 source/CMakeLists.txt
> --- a/source/CMakeLists.txt Mon Jan 20 18:07:59 2020 +0530
> +++ b/source/CMakeLists.txt Tue Jan 21 10:53:49 2020 +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 188)
> +set(X265_BUILD 189)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r acc5d16999e2 -r e0e0270ead41 source/common/common.h
> --- a/source/common/common.hMon Jan 20 18:07:59 2020 +0530
> +++ b/source/common/common.hTue Jan 21 10:53:49 2020 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #define SHIFT 1
>  #else
> @@ -137,6 +138,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #define SHIFT 0
>  #endif // if HIGH_BIT_DEPTH
> @@ -272,6 +274,9 @@
>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>
> +#define RDCOST_BASED_RSKIP 1
> +#define EDGE_BASED_RSKIP 2
> +
>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which the
> VLC
>// transitions from Golomb-Rice to
> TU+EG(k)
>
> diff -r acc5d16999e2 -r e0e0270ead41 source/common/frame.cpp
> --- a/source/common/frame.cpp   Mon Jan 20 18:07:59 2020 +0530
> +++ b/source/common/frame.cpp   Tue Jan 21 10:53:49 2020 +0530
> @@ -61,6 +61,7 @@
>  m_edgePic = NULL;
>  m_gaussianPic = NULL;
>  m_thetaPic = NULL;
> +m_edgeBitPlane = NULL;
>  }
>
>  bool Frame::create(x265_param *param, float* quantOffsets)
> @@ -115,6 +116,18 @@
>  m_thetaPic = X265_MALLOC(pixel, m_stride * (maxHeight +
> (m_lumaMarginY * 2)));
>  }
>
> +if (param->bEnableRecursionSkip == EDGE_BASED_RSKIP)
> +{
> +uint32_t numCuInWidth = (param->sourceWidth + param->maxCUSize -
> 1) / param->maxCUSize;
> +uint32_t numCuInHeight = (param->sourceHeight + param->maxCUSize
> - 1) / param->maxCUSize;
> +uint32_t lumaMarginX = param->maxCUSize + 32;
> +uint32_t 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-20 Thread Srikanth Kurapati
[KS] That is not the only requirement. pelx and pely provides the starting
offset of the buffer for which variance should be computed. parentCTU's
pelx and pely do not return the correct x,y coordinates of the CU
undergoing analysis.
I once again insist you to debug, understand the computation of pelx and
pely and fix this before sending the next updated patch.
[Srikanth] Addressed.



On Mon, Jan 20, 2020 at 1:44 PM Kavitha Sampath <
kavi...@multicorewareinc.com> wrote:

>
>
> On Mon, Jan 20, 2020 at 12:12 PM Srikanth Kurapati <
> srikanth.kurap...@multicorewareinc.com> wrote:
>
>> Patch does not apply on current x265 tip, please fix.
>> [Srikanth] - resolved
>> I am assuming the following will be sent as follow up patches
>> 1. Edge aware quadtree feature for Rd levels 5, 6
>> 2. Asm version of planecopy used for this feature
>> [Srikanth] - Yes, they will be addressed in follow up patches.
>> Check comments below
>>
>> On Fri, Jan 10, 2020 at 5:46 PM 
>> wrote:
>>
>>> # HG changeset patch
>>> # User Srikanth Kurapati
>>> # Date 1578656713 -19800
>>> #  Fri Jan 10 17:15:13 2020 +0530
>>> # Node ID 82a92c26b4429327c9038d822e02ad6c0de290d4
>>> # Parent  6b348d5b56d86ddfc3874d0f50f1283edab5fb4f
>>> Edge Aware Quad Tree Establishment.
>>>
>>> This patch does the following:
>>> 1. Terminates recursion using edge information.
>>> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
>>> based
>>> rskip for RD levels 0 to 4.
>>> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
>>> density.
>>> 4. Re uses edge information when already available in encoder.
>>>
>>> diff -r 6b348d5b56d8 -r 82a92c26b442 doc/reST/cli.rst
>>> --- a/doc/reST/cli.rst  Fri Jan 10 14:38:32 2020 +0530
>>> +++ b/doc/reST/cli.rst  Fri Jan 10 17:15:13 2020 +0530
>>> @@ -842,15 +842,20 @@
>>> Measure 2Nx2N merge candidates first; if no residual is found,
>>> additional modes at that depth are not analysed. Default disabled
>>>
>>> -.. option:: --rskip, --no-rskip
>>> -
>>> -   This option determines early exit from CU depth recursion. When
>>> a skip CU is
>>> -   found, additional heuristics (depending on rd-level) are used to
>>> decide whether
>>> -   to terminate recursion. In rdlevels 5 and 6, comparison with
>>> inter2Nx2N is used,
>>> -   while at rdlevels 4 and neighbour costs are used to skip
>>> recursion.
>>> -   Provides minimal quality degradation at good performance gains
>>> when enabled.
>>> -
>>> -   Default: enabled, disabled for :option:`--tune grain`
>>> +.. option:: --rskip <0|1|2>
>>> +
>>> +   This option determines early exit from CU depth recursion when
>>> enabled. When a skip CU is
>>> +   found, additional heuristics (depending on RD level and rskip
>>> mode) are used to decide whether
>>> +   to terminate recursion. In RD levels 5 and 6, comparison with
>>> inter2Nx2N is used,
>>> +   while at RD levels 4 and below, neighbour costs are used to skip
>>> recursion in mode 1, and CU edge density in mode 2.
>>> +   Provides minimal quality degradation at good performance gains
>>> when enabled. :option:`--r-skip mode 0` means disabled.
>>> +
>>> +   Default: 1, disabled when :option:`--tune grain` is used.
>>> +
>>> +.. option:: --edge-threshold <0..100>
>>> +
>>> +   Denotes the minimum edge-density percentage (computed as
>>> variance) within the CU, below which the recursion is skipped.
>>> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>>>
>> [KS] I don't think it's necessary to talk about variance here. And again
>> it is "minimum expected" (still not clear)
>> [Srikanth] Addressed and Resolved.
>>
>>
>>>  .. option:: --splitrd-skip, --no-splitrd-skip
>>>
>>> diff -r 6b348d5b56d8 -r 82a92c26b442 source/CMakeLists.txt
>>> --- a/source/CMakeLists.txt Fri Jan 10 14:38:32 2020 +0530
>>> +++ b/source/CMakeLists.txt Fri Jan 10 17:15:13 2020 +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 186)
>>> +set(X265_BUILD 187)
>>>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>>> "${PROJECT_BINARY_DIR}/x265.def")
>>>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
>>> diff -r 6b348d5b56d8 -r 82a92c26b442 source/common/common.h
>>> --- a/source/common/common.hFri Jan 10 14:38:32 2020 +0530
>>> +++ b/source/common/common.hFri Jan 10 17:15:13 2020 +0530
>>> @@ -129,6 +129,7 @@
>>>  typedef uint64_t sum2_t;
>>>  typedef uint64_t pixel4;
>>>  typedef int64_t  ssum2_t;
>>> +#define SHIFT_TO_BITPLANE 9
>>>  #define HISTOGRAM_BINS 1024
>>>  #define SHIFT 1
>>>  #else
>>> @@ -137,6 +138,7 @@
>>>  typedef uint32_t sum2_t;
>>>  typedef uint32_t pixel4;
>>>  typedef int32_t  ssum2_t; // Signed sum
>>> +#define SHIFT_TO_BITPLANE 7
>>>  

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-20 Thread Kavitha Sampath
On Mon, Jan 20, 2020 at 12:12 PM Srikanth Kurapati <
srikanth.kurap...@multicorewareinc.com> wrote:

> Patch does not apply on current x265 tip, please fix.
> [Srikanth] - resolved
> I am assuming the following will be sent as follow up patches
> 1. Edge aware quadtree feature for Rd levels 5, 6
> 2. Asm version of planecopy used for this feature
> [Srikanth] - Yes, they will be addressed in follow up patches.
> Check comments below
>
> On Fri, Jan 10, 2020 at 5:46 PM 
> wrote:
>
>> # HG changeset patch
>> # User Srikanth Kurapati
>> # Date 1578656713 -19800
>> #  Fri Jan 10 17:15:13 2020 +0530
>> # Node ID 82a92c26b4429327c9038d822e02ad6c0de290d4
>> # Parent  6b348d5b56d86ddfc3874d0f50f1283edab5fb4f
>> Edge Aware Quad Tree Establishment.
>>
>> This patch does the following:
>> 1. Terminates recursion using edge information.
>> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
>> based
>> rskip for RD levels 0 to 4.
>> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
>> density.
>> 4. Re uses edge information when already available in encoder.
>>
>> diff -r 6b348d5b56d8 -r 82a92c26b442 doc/reST/cli.rst
>> --- a/doc/reST/cli.rst  Fri Jan 10 14:38:32 2020 +0530
>> +++ b/doc/reST/cli.rst  Fri Jan 10 17:15:13 2020 +0530
>> @@ -842,15 +842,20 @@
>> Measure 2Nx2N merge candidates first; if no residual is found,
>> additional modes at that depth are not analysed. Default disabled
>>
>> -.. option:: --rskip, --no-rskip
>> -
>> -   This option determines early exit from CU depth recursion. When a
>> skip CU is
>> -   found, additional heuristics (depending on rd-level) are used to
>> decide whether
>> -   to terminate recursion. In rdlevels 5 and 6, comparison with
>> inter2Nx2N is used,
>> -   while at rdlevels 4 and neighbour costs are used to skip
>> recursion.
>> -   Provides minimal quality degradation at good performance gains
>> when enabled.
>> -
>> -   Default: enabled, disabled for :option:`--tune grain`
>> +.. option:: --rskip <0|1|2>
>> +
>> +   This option determines early exit from CU depth recursion when
>> enabled. When a skip CU is
>> +   found, additional heuristics (depending on RD level and rskip
>> mode) are used to decide whether
>> +   to terminate recursion. In RD levels 5 and 6, comparison with
>> inter2Nx2N is used,
>> +   while at RD levels 4 and below, neighbour costs are used to skip
>> recursion in mode 1, and CU edge density in mode 2.
>> +   Provides minimal quality degradation at good performance gains
>> when enabled. :option:`--r-skip mode 0` means disabled.
>> +
>> +   Default: 1, disabled when :option:`--tune grain` is used.
>> +
>> +.. option:: --edge-threshold <0..100>
>> +
>> +   Denotes the minimum edge-density percentage (computed as
>> variance) within the CU, below which the recursion is skipped.
>> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>>
> [KS] I don't think it's necessary to talk about variance here. And again
> it is "minimum expected" (still not clear)
> [Srikanth] Addressed and Resolved.
>
>
>>  .. option:: --splitrd-skip, --no-splitrd-skip
>>
>> diff -r 6b348d5b56d8 -r 82a92c26b442 source/CMakeLists.txt
>> --- a/source/CMakeLists.txt Fri Jan 10 14:38:32 2020 +0530
>> +++ b/source/CMakeLists.txt Fri Jan 10 17:15:13 2020 +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 186)
>> +set(X265_BUILD 187)
>>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>> "${PROJECT_BINARY_DIR}/x265.def")
>>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
>> diff -r 6b348d5b56d8 -r 82a92c26b442 source/common/common.h
>> --- a/source/common/common.hFri Jan 10 14:38:32 2020 +0530
>> +++ b/source/common/common.hFri Jan 10 17:15:13 2020 +0530
>> @@ -129,6 +129,7 @@
>>  typedef uint64_t sum2_t;
>>  typedef uint64_t pixel4;
>>  typedef int64_t  ssum2_t;
>> +#define SHIFT_TO_BITPLANE 9
>>  #define HISTOGRAM_BINS 1024
>>  #define SHIFT 1
>>  #else
>> @@ -137,6 +138,7 @@
>>  typedef uint32_t sum2_t;
>>  typedef uint32_t pixel4;
>>  typedef int32_t  ssum2_t; // Signed sum
>> +#define SHIFT_TO_BITPLANE 7
>>  #define HISTOGRAM_BINS 256
>>  #define SHIFT 0
>>  #endif // if HIGH_BIT_DEPTH
>> @@ -272,6 +274,9 @@
>>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>>
>> +#define RDCOST_BASED_RSKIP 1
>> +#define EDGE_BASED_RSKIP 2
>> +
>>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which
>> the VLC
>>// transitions from Golomb-Rice to
>> TU+EG(k)
>>
>> diff -r 6b348d5b56d8 -r 82a92c26b442 source/common/frame.cpp
>> --- a/source/common/frame.cpp   Fri Jan 10 14:38:32 2020 +0530
>> +++ 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-19 Thread Srikanth Kurapati
Patch does not apply on current x265 tip, please fix.
[Srikanth] - resolved
I am assuming the following will be sent as follow up patches
1. Edge aware quadtree feature for Rd levels 5, 6
2. Asm version of planecopy used for this feature
[Srikanth] - Yes, they will be addressed in follow up patches.
Check comments below

On Fri, Jan 10, 2020 at 5:46 PM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1578656713 -19800
> #  Fri Jan 10 17:15:13 2020 +0530
> # Node ID 82a92c26b4429327c9038d822e02ad6c0de290d4
> # Parent  6b348d5b56d86ddfc3874d0f50f1283edab5fb4f
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion using edge information.
> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
> based
> rskip for RD levels 0 to 4.
> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
> density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r 6b348d5b56d8 -r 82a92c26b442 doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Fri Jan 10 14:38:32 2020 +0530
> +++ b/doc/reST/cli.rst  Fri Jan 10 17:15:13 2020 +0530
> @@ -842,15 +842,20 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2>
> +
> +   This option determines early exit from CU depth recursion when
> enabled. When a skip CU is
> +   found, additional heuristics (depending on RD level and rskip
> mode) are used to decide whether
> +   to terminate recursion. In RD levels 5 and 6, comparison with
> inter2Nx2N is used,
> +   while at RD levels 4 and below, neighbour costs are used to skip
> recursion in mode 1, and CU edge density in mode 2.
> +   Provides minimal quality degradation at good performance gains
> when enabled. :option:`--r-skip mode 0` means disabled.
> +
> +   Default: 1, disabled when :option:`--tune grain` is used.
> +
> +.. option:: --edge-threshold <0..100>
> +
> +   Denotes the minimum edge-density percentage (computed as variance)
> within the CU, below which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>
[KS] I don't think it's necessary to talk about variance here. And again it
is "minimum expected" (still not clear)
[Srikanth] Addressed and Resolved.


>  .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r 6b348d5b56d8 -r 82a92c26b442 source/CMakeLists.txt
> --- a/source/CMakeLists.txt Fri Jan 10 14:38:32 2020 +0530
> +++ b/source/CMakeLists.txt Fri Jan 10 17:15:13 2020 +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 186)
> +set(X265_BUILD 187)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r 6b348d5b56d8 -r 82a92c26b442 source/common/common.h
> --- a/source/common/common.hFri Jan 10 14:38:32 2020 +0530
> +++ b/source/common/common.hFri Jan 10 17:15:13 2020 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #define SHIFT 1
>  #else
> @@ -137,6 +138,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #define SHIFT 0
>  #endif // if HIGH_BIT_DEPTH
> @@ -272,6 +274,9 @@
>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>
> +#define RDCOST_BASED_RSKIP 1
> +#define EDGE_BASED_RSKIP 2
> +
>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which the
> VLC
>// transitions from Golomb-Rice to
> TU+EG(k)
>
> diff -r 6b348d5b56d8 -r 82a92c26b442 source/common/frame.cpp
> --- a/source/common/frame.cpp   Fri Jan 10 14:38:32 2020 +0530
> +++ b/source/common/frame.cpp   Fri Jan 10 17:15:13 2020 +0530
> @@ -61,6 +61,7 @@
>  m_edgePic = NULL;
>  m_gaussianPic = NULL;
>  m_thetaPic = NULL;
> +m_edgeBitPlane = NULL;
>  }
>
>  bool Frame::create(x265_param *param, float* 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-13 Thread Kavitha Sampath
Patch does not apply on current x265 tip, please fix.

I am assuming the following will be sent as follow up patches
1. Edge aware quadtree feature for Rd levels 5, 6
2. Asm version of planecopy used for this feature

Check comments below

On Fri, Jan 10, 2020 at 5:46 PM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1578656713 -19800
> #  Fri Jan 10 17:15:13 2020 +0530
> # Node ID 82a92c26b4429327c9038d822e02ad6c0de290d4
> # Parent  6b348d5b56d86ddfc3874d0f50f1283edab5fb4f
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion using edge information.
> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
> based
> rskip for RD levels 0 to 4.
> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
> density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r 6b348d5b56d8 -r 82a92c26b442 doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Fri Jan 10 14:38:32 2020 +0530
> +++ b/doc/reST/cli.rst  Fri Jan 10 17:15:13 2020 +0530
> @@ -842,15 +842,20 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2>
> +
> +   This option determines early exit from CU depth recursion when
> enabled. When a skip CU is
> +   found, additional heuristics (depending on RD level and rskip
> mode) are used to decide whether
> +   to terminate recursion. In RD levels 5 and 6, comparison with
> inter2Nx2N is used,
> +   while at RD levels 4 and below, neighbour costs are used to skip
> recursion in mode 1, and CU edge density in mode 2.
> +   Provides minimal quality degradation at good performance gains
> when enabled. :option:`--r-skip mode 0` means disabled.
> +
> +   Default: 1, disabled when :option:`--tune grain` is used.
> +
> +.. option:: --edge-threshold <0..100>
> +
> +   Denotes the minimum edge-density percentage (computed as variance)
> within the CU, below which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>
[KS] I don't think it's necessary to talk about variance here. And again it
is "minimum expected" (still not clear)


>  .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r 6b348d5b56d8 -r 82a92c26b442 source/CMakeLists.txt
> --- a/source/CMakeLists.txt Fri Jan 10 14:38:32 2020 +0530
> +++ b/source/CMakeLists.txt Fri Jan 10 17:15:13 2020 +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 186)
> +set(X265_BUILD 187)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r 6b348d5b56d8 -r 82a92c26b442 source/common/common.h
> --- a/source/common/common.hFri Jan 10 14:38:32 2020 +0530
> +++ b/source/common/common.hFri Jan 10 17:15:13 2020 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #define SHIFT 1
>  #else
> @@ -137,6 +138,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #define SHIFT 0
>  #endif // if HIGH_BIT_DEPTH
> @@ -272,6 +274,9 @@
>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>
> +#define RDCOST_BASED_RSKIP 1
> +#define EDGE_BASED_RSKIP 2
> +
>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which the
> VLC
>// transitions from Golomb-Rice to
> TU+EG(k)
>
> diff -r 6b348d5b56d8 -r 82a92c26b442 source/common/frame.cpp
> --- a/source/common/frame.cpp   Fri Jan 10 14:38:32 2020 +0530
> +++ b/source/common/frame.cpp   Fri Jan 10 17:15:13 2020 +0530
> @@ -61,6 +61,7 @@
>  m_edgePic = NULL;
>  m_gaussianPic = NULL;
>  m_thetaPic = NULL;
> +m_edgeBitPlane = NULL;
>  }
>
>  bool Frame::create(x265_param *param, float* quantOffsets)
> @@ -115,6 +116,18 @@
>  m_thetaPic = X265_MALLOC(pixel, m_stride * (maxHeight +
> (m_lumaMarginY * 2)));
> 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-10 Thread Srikanth Kurapati
 [Srikanth] rephrased.

> There is no mention that this patch introduces rkip 2 only to rd0_4
>
[Srikanth] The above is clear in the documentation. Adding the same to
commit message.


> +   Default: 1, disabled when :option:`--tune grain` is used.
>> +
>> +.. option:: --edge-threshold <0..100>
>> +
>> +   Denotes the minimum percentage of edge density in the CU, below
>> which the recursion is skipped.
>> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>>
> [KS] It is the minimum edge density the CU is expected to possess.
>
[Srikanth] Addressed.

> Usage of density and variance is not consistent across the patch
>
[Srikanth] removed the confusing comment,
[Srikanth] The purpose is to make easily configurable by naive users for
providing the threshold and then normalizing the values to between 0 to
1.It's difficult for user to think in terms of normalized variance.

> And across the patch percent and double is used interchangeably providing
> less clarity.
>
 [Srikanth] Don't get this comment.
   [Srikanth] corrected.

> [KS] Where are you checking rkip mode 2 with edge threshold combination?
>
 [Srikanth] Added the same.
   - asm will follow in a subsequent patch.
   [Srikanth] when we use topskip the skip mechanism is applied on the
lower levels of the ctu where as without that we are doing it on the higher
levels.This increases the overall processing time per frame and hence the
fps as compared to optimizing at higher levels.

> +skipRecursion = edgeRecursionSkip(parentCTU, depth);
>> +}
>>  }
>>  }
>> +
>>  if (m_param->bAnalysisType == AVC_INFO && md.bestMode &&
>> cuGeom.numPartitions <= 16 && m_param->analysisReuseLevel == 7)
>>  skipRecursion = true;
>>  /* Step 2. Evaluate each of the 4 split sub-blocks in series */
>> @@ -3543,6 +3551,33 @@
>>  return false;
>>  }
>>
>> +bool Analysis::edgeRecursionSkip(const CUData& ctu, int depth)
>> +{
>> +int cuLen = m_param->maxCUSize >> depth;
>> +if (cuLen >= RSKIP2_MIN_CUSIZE)
>> +{
>> +uint8_t blockType = g_log2Size[cuLen] - 2;
>>
> [KS] Can you tell me the purpose of cuLen computation and its subsequent
> usage when we have cuGeom's log2size?
>
[Srikanth] Thank you. Addressed.

> +int shift = g_log2Size[cuLen] * 2;
>> +intptr_t stride = m_frame->m_fencPic->m_stride;
>> +pixel* edgePic = m_frame->m_edgeBitPlane +
>> m_frame->m_fencPic->m_lumaMarginY * m_frame->m_fencPic->m_stride +
>> m_frame->m_fencPic->m_lumaMarginX;
>> +intptr_t blockOffsetLuma = ctu.m_cuPelX + ctu.m_cuPelY * stride;
>> +uint64_t sum_ss = primitives.cu[blockType].var(edgePic +
>> blockOffsetLuma, stride);
>> +uint32_t sum = (uint32_t)sum_ss;
>> +uint32_t ss = (uint32_t)(sum_ss >> 32);
>> +double pixelCount = pow(2.0, shift);
>>
> [KS] When pixel count is pow of 2, what is the reason for using pow
> instead of shift?
>
[Srikanth] Addressed.

> +double cuEdgeVariance = (ss - (sum * sum / pixelCount)) /
>> pixelCount;
>>
> [KS] The difference between complexityCheckCU and this module's core
> functionality is sum of abs diff and sum of squared diff. Although squared
> diff is more accurate(as you mentioned), are you seeing a very big
> difference in accuracy of variance across these 2 functions? Have we
> measured this? I am skeptical about having new module doing same
> functionality
>
  [Srikanth] Homogeneity and variance are two different metrics hence we
are not doing the same functionality. Also the input parameters and
methodology of computation are totally different. Even if we try to combine
into one function it will result in too many default values for the input
parameters in the prior mode. So I am not venturing on the same for
simplicity and readability with ease.

> +
>> +if (cuEdgeVariance > m_param->edgeThreshold)
>> +return false;
>> +else
>> +return true;
>> +}
>> +else
>> +{
>> +return true;
>> +}
>>
> [KS] If the size < 32x32 you force recursion skipping? Why? What is the
> quality impact you are seeing?
> Can you share some results?
>
  [Srikanth] Does not give much fps gain.
   Shared the results offline.  Removed the same as I see improvements in
quality without the above but is substantial loss in fps gain due to the
same.

> +}
>> +
>>
> [KS] If CU size < 32x32 why do you even call this function? I see this as
> an overhead
>
   [Srikanth]  Addressed

>  uint32_t Analysis::calculateCUVariance(const CUData& ctu, const CUGeom&
>> cuGeom)
>>  {
>>  uint32_t cuVariance = 0;
>> @@ -3566,7 +3601,6 @@
>>  cnt++;
>>  }
>>  }
>> -
>>  return cuVariance / cnt;
>>  }
>>
>> diff -r 19f6ed165919 -r 3d60a9a728b3 source/encoder/analysis.h
>> --- a/source/encoder/analysis.h Mon Dec 30 11:58:44 2019 +0530
>> +++ b/source/encoder/analysis.h Fri Dec 27 13:17:09 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-07 Thread Kavitha Sampath
On Tue, Jan 7, 2020 at 8:16 AM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1577432829 -19800
> #  Fri Dec 27 13:17:09 2019 +0530
> # Node ID 3d60a9a728b37f14cbb9cb2332a1aebf87e66334
> # Parent  19f6ed1659197aaa4bd78b69eb58139e879230d9
> Edge Aware Quad Tree Establishment.

This patch does the following:
> 1. Terminates recursion using edge information.
> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
> based rskip.
> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
> density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r 19f6ed165919 -r 3d60a9a728b3 doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Mon Dec 30 11:58:44 2019 +0530
> +++ b/doc/reST/cli.rst  Fri Dec 27 13:17:09 2019 +0530
> @@ -842,15 +842,20 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2>
> +
> +   This option determines early exit from CU depth recursion when
> enabled. When a skip CU is
> +   found, additional heuristics (depending on rd-level and rskip
> mode) are used to decide whether
> +   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> +   while at rdlevels 4 and below, neighbour costs are used to skip
> recursion in mode 1, and CU edge density in mode 2.
> +   Provides minimal quality degradation at good performance gains
> when enabled. R-skip mode 0 means disabled.
>
[KS] R-skip mode 0 means disabled is implied. If necessary mentioning
rephrase
There is no mention that this patch introduces rkip 2 only to rd0_4

> +   Default: 1, disabled when :option:`--tune grain` is used.
> +
> +.. option:: --edge-threshold <0..100>
> +
> +   Denotes the minimum percentage of edge density in the CU, below
> which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>
[KS] It is the minimum edge density the CU is expected to possess.
Usage of density and variance is not consistent across the patch


>  .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r 19f6ed165919 -r 3d60a9a728b3 source/CMakeLists.txt
> --- a/source/CMakeLists.txt Mon Dec 30 11:58:44 2019 +0530
> +++ b/source/CMakeLists.txt Fri Dec 27 13:17:09 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 184)
> +set(X265_BUILD 185)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r 19f6ed165919 -r 3d60a9a728b3 source/common/common.h
> --- a/source/common/common.hMon Dec 30 11:58:44 2019 +0530
> +++ b/source/common/common.hFri Dec 27 13:17:09 2019 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #define SHIFT 1
>  #else
> @@ -137,6 +138,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #define SHIFT 0
>  #endif // if HIGH_BIT_DEPTH
> @@ -272,6 +274,9 @@
>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>
> +#define RDCOST_BASED_RSKIP 1
> +#define EDGE_BASED_RSKIP 2
> +
>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which the
> VLC
>// transitions from Golomb-Rice to
> TU+EG(k)
>
> diff -r 19f6ed165919 -r 3d60a9a728b3 source/common/frame.cpp
> --- a/source/common/frame.cpp   Mon Dec 30 11:58:44 2019 +0530
> +++ b/source/common/frame.cpp   Fri Dec 27 13:17:09 2019 +0530
> @@ -61,6 +61,7 @@
>  m_edgePic = NULL;
>  m_gaussianPic = NULL;
>  m_thetaPic = NULL;
> +m_edgeBitPlane = NULL;
>  }
>
>  bool Frame::create(x265_param *param, float* quantOffsets)
> @@ -115,6 +116,18 @@
>  m_thetaPic = X265_MALLOC(pixel, m_stride * (maxHeight +
> (m_lumaMarginY * 2)));
>  }
>
> +if (param->bEnableRecursionSkip == EDGE_BASED_RSKIP)
> +{
> +uint32_t numCuInWidth = (param->sourceWidth + 

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-07 Thread Srikanth Kurapati
Hi Kavitha,

Please provide your feedback for the above patch.

On Tue, Jan 7, 2020 at 8:16 AM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1577432829 -19800
> #  Fri Dec 27 13:17:09 2019 +0530
> # Node ID 3d60a9a728b37f14cbb9cb2332a1aebf87e66334
> # Parent  19f6ed1659197aaa4bd78b69eb58139e879230d9
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion using edge information.
> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
> based rskip.
> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
> density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r 19f6ed165919 -r 3d60a9a728b3 doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Mon Dec 30 11:58:44 2019 +0530
> +++ b/doc/reST/cli.rst  Fri Dec 27 13:17:09 2019 +0530
> @@ -842,15 +842,20 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2>
> +
> +   This option determines early exit from CU depth recursion when
> enabled. When a skip CU is
> +   found, additional heuristics (depending on rd-level and rskip
> mode) are used to decide whether
> +   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> +   while at rdlevels 4 and below, neighbour costs are used to skip
> recursion in mode 1, and CU edge density in mode 2.
> +   Provides minimal quality degradation at good performance gains
> when enabled. R-skip mode 0 means disabled.
> +
> +   Default: 1, disabled when :option:`--tune grain` is used.
> +
> +.. option:: --edge-threshold <0..100>
> +
> +   Denotes the minimum percentage of edge density in the CU, below
> which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>
>  .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r 19f6ed165919 -r 3d60a9a728b3 source/CMakeLists.txt
> --- a/source/CMakeLists.txt Mon Dec 30 11:58:44 2019 +0530
> +++ b/source/CMakeLists.txt Fri Dec 27 13:17:09 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 184)
> +set(X265_BUILD 185)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r 19f6ed165919 -r 3d60a9a728b3 source/common/common.h
> --- a/source/common/common.hMon Dec 30 11:58:44 2019 +0530
> +++ b/source/common/common.hFri Dec 27 13:17:09 2019 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #define SHIFT 1
>  #else
> @@ -137,6 +138,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #define SHIFT 0
>  #endif // if HIGH_BIT_DEPTH
> @@ -272,6 +274,9 @@
>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>
> +#define RDCOST_BASED_RSKIP 1
> +#define EDGE_BASED_RSKIP 2
> +
>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which the
> VLC
>// transitions from Golomb-Rice to
> TU+EG(k)
>
> diff -r 19f6ed165919 -r 3d60a9a728b3 source/common/frame.cpp
> --- a/source/common/frame.cpp   Mon Dec 30 11:58:44 2019 +0530
> +++ b/source/common/frame.cpp   Fri Dec 27 13:17:09 2019 +0530
> @@ -61,6 +61,7 @@
>  m_edgePic = NULL;
>  m_gaussianPic = NULL;
>  m_thetaPic = NULL;
> +m_edgeBitPlane = NULL;
>  }
>
>  bool Frame::create(x265_param *param, float* quantOffsets)
> @@ -115,6 +116,18 @@
>  m_thetaPic = X265_MALLOC(pixel, m_stride * (maxHeight +
> (m_lumaMarginY * 2)));
>  }
>
> +if (param->bEnableRecursionSkip == EDGE_BASED_RSKIP)
> +{
> +uint32_t numCuInWidth = (param->sourceWidth + param->maxCUSize -
> 1) / param->maxCUSize;
> +uint32_t numCuInHeight = (param->sourceHeight + param->maxCUSize
> - 1) / param->maxCUSize;
> +uint32_t lumaMarginX = param->maxCUSize + 32;
> +

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-06 Thread Srikanth Kurapati
Please ignore this email. I will resend the final one immediately.

On Mon, Jan 6, 2020 at 4:02 PM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1577432829 -19800
> #  Fri Dec 27 13:17:09 2019 +0530
> # Node ID 99c608bd88538ca77556fed672bc6302625dfdf0
> # Parent  19f6ed1659197aaa4bd78b69eb58139e879230d9
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion using edge information.
> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
> based rskip.
> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
> density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r 19f6ed165919 -r 99c608bd8853 doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Mon Dec 30 11:58:44 2019 +0530
> +++ b/doc/reST/cli.rst  Fri Dec 27 13:17:09 2019 +0530
> @@ -842,15 +842,20 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2>
> +
> +   This option determines early exit from CU depth recursion when
> enabled. When a skip CU is
> +   found, additional heuristics (depending on rd-level and rskip
> mode) are used to decide whether
> +   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> +   while at rdlevels 4 and below, neighbour costs are used to skip
> recursion in mode 1, and CU edge density in mode 2.
> +   Provides minimal quality degradation at good performance gains
> when enabled. R-skip mode 0 means disabled.
> +
> +   Default: 1, disabled when :option:`--tune grain` is used.
> +
> +.. option:: --edge-threshold <0..100>
> +
> +   Denotes the minimum percentage of edge density in the CU, below
> which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>
>  .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r 19f6ed165919 -r 99c608bd8853 source/CMakeLists.txt
> --- a/source/CMakeLists.txt Mon Dec 30 11:58:44 2019 +0530
> +++ b/source/CMakeLists.txt Fri Dec 27 13:17:09 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 184)
> +set(X265_BUILD 185)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r 19f6ed165919 -r 99c608bd8853 source/common/common.h
> --- a/source/common/common.hMon Dec 30 11:58:44 2019 +0530
> +++ b/source/common/common.hFri Dec 27 13:17:09 2019 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #define SHIFT 1
>  #else
> @@ -137,6 +138,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #define SHIFT 0
>  #endif // if HIGH_BIT_DEPTH
> @@ -272,6 +274,9 @@
>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>
> +#define RDCOST_BASED_RSKIP 1
> +#define EDGE_BASED_RSKIP 2
> +
>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which the
> VLC
>// transitions from Golomb-Rice to
> TU+EG(k)
>
> diff -r 19f6ed165919 -r 99c608bd8853 source/common/frame.cpp
> --- a/source/common/frame.cpp   Mon Dec 30 11:58:44 2019 +0530
> +++ b/source/common/frame.cpp   Fri Dec 27 13:17:09 2019 +0530
> @@ -61,6 +61,7 @@
>  m_edgePic = NULL;
>  m_gaussianPic = NULL;
>  m_thetaPic = NULL;
> +m_edgeBitPlane = NULL;
>  }
>
>  bool Frame::create(x265_param *param, float* quantOffsets)
> @@ -115,6 +116,18 @@
>  m_thetaPic = X265_MALLOC(pixel, m_stride * (maxHeight +
> (m_lumaMarginY * 2)));
>  }
>
> +if (param->bEnableRecursionSkip == EDGE_BASED_RSKIP)
> +{
> +uint32_t numCuInWidth = (param->sourceWidth + param->maxCUSize -
> 1) / param->maxCUSize;
> +uint32_t numCuInHeight = (param->sourceHeight + param->maxCUSize
> - 1) / param->maxCUSize;
> +uint32_t lumaMarginX = param->maxCUSize + 32;
> +

Re: [x265] [PATCH] Edge Aware Quad Tree Establishment

2020-01-06 Thread Srikanth Kurapati
Please ignore this email.

On Mon, Jan 6, 2020 at 12:44 PM 
wrote:

> # HG changeset patch
> # User Srikanth Kurapati
> # Date 1577432829 -19800
> #  Fri Dec 27 13:17:09 2019 +0530
> # Node ID 27d66318e16e7f522f2d01067629cd9f24c07f66
> # Parent  19f6ed1659197aaa4bd78b69eb58139e879230d9
> Edge Aware Quad Tree Establishment.
>
> This patch does the following:
> 1. Terminates recursion using edge information.
> 2. Adds modes for "--rskip". Modes 0,1 for current usage and 2 for edge
> based rskip.
> 3. Adds option "edge-threshold" to decide recursion skip using CU edge
> density.
> 4. Re uses edge information when already available in encoder.
>
> diff -r 19f6ed165919 -r 27d66318e16e doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Mon Dec 30 11:58:44 2019 +0530
> +++ b/doc/reST/cli.rst  Fri Dec 27 13:17:09 2019 +0530
> @@ -842,15 +842,20 @@
> Measure 2Nx2N merge candidates first; if no residual is found,
> additional modes at that depth are not analysed. Default disabled
>
> -.. option:: --rskip, --no-rskip
> -
> -   This option determines early exit from CU depth recursion. When a
> skip CU is
> -   found, additional heuristics (depending on rd-level) are used to
> decide whether
> -   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> -   while at rdlevels 4 and neighbour costs are used to skip recursion.
> -   Provides minimal quality degradation at good performance gains
> when enabled.
> -
> -   Default: enabled, disabled for :option:`--tune grain`
> +.. option:: --rskip <0|1|2>
> +
> +   This option determines early exit from CU depth recursion when
> enabled. When a skip CU is
> +   found, additional heuristics (depending on rd-level and rskip
> mode) are used to decide whether
> +   to terminate recursion. In rdlevels 5 and 6, comparison with
> inter2Nx2N is used,
> +   while at rdlevels 4 and below, neighbour costs are used to skip
> recursion in mode 1, and CU edge density in mode 2.
> +   Provides minimal quality degradation at good performance gains
> when enabled. R-skip mode 0 means disabled.
> +
> +   Default: 1, disabled when :option:`--tune grain` is used.
> +
> +.. option:: --edge-threshold <0..100>
> +
> +   Denotes the minimum percentage of edge density in the CU, below
> which the recursion is skipped.
> +   Default: 5, requires :option:`--rskip mode 2` to be enabled.
>
>  .. option:: --splitrd-skip, --no-splitrd-skip
>
> diff -r 19f6ed165919 -r 27d66318e16e source/CMakeLists.txt
> --- a/source/CMakeLists.txt Mon Dec 30 11:58:44 2019 +0530
> +++ b/source/CMakeLists.txt Fri Dec 27 13:17:09 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 184)
> +set(X265_BUILD 185)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r 19f6ed165919 -r 27d66318e16e source/common/common.h
> --- a/source/common/common.hMon Dec 30 11:58:44 2019 +0530
> +++ b/source/common/common.hFri Dec 27 13:17:09 2019 +0530
> @@ -129,6 +129,7 @@
>  typedef uint64_t sum2_t;
>  typedef uint64_t pixel4;
>  typedef int64_t  ssum2_t;
> +#define SHIFT_TO_BITPLANE 9
>  #define HISTOGRAM_BINS 1024
>  #define SHIFT 1
>  #else
> @@ -137,6 +138,7 @@
>  typedef uint32_t sum2_t;
>  typedef uint32_t pixel4;
>  typedef int32_t  ssum2_t; // Signed sum
> +#define SHIFT_TO_BITPLANE 7
>  #define HISTOGRAM_BINS 256
>  #define SHIFT 0
>  #endif // if HIGH_BIT_DEPTH
> @@ -272,6 +274,9 @@
>  #define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
>  #define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
>
> +#define RDCOST_BASED_RSKIP 1
> +#define EDGE_BASED_RSKIP 2
> +
>  #define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which the
> VLC
>// transitions from Golomb-Rice to
> TU+EG(k)
>
> diff -r 19f6ed165919 -r 27d66318e16e source/common/frame.cpp
> --- a/source/common/frame.cpp   Mon Dec 30 11:58:44 2019 +0530
> +++ b/source/common/frame.cpp   Fri Dec 27 13:17:09 2019 +0530
> @@ -61,6 +61,7 @@
>  m_edgePic = NULL;
>  m_gaussianPic = NULL;
>  m_thetaPic = NULL;
> +m_edgeBitPlane = NULL;
>  }
>
>  bool Frame::create(x265_param *param, float* quantOffsets)
> @@ -115,6 +116,18 @@
>  m_thetaPic = X265_MALLOC(pixel, m_stride * (maxHeight +
> (m_lumaMarginY * 2)));
>  }
>
> +if (param->bEnableRecursionSkip == EDGE_BASED_RSKIP)
> +{
> +uint32_t numCuInWidth = (param->sourceWidth + param->maxCUSize -
> 1) / param->maxCUSize;
> +uint32_t numCuInHeight = (param->sourceHeight + param->maxCUSize
> - 1) / param->maxCUSize;
> +uint32_t lumaMarginX = param->maxCUSize + 32;
> +uint32_t lumaMarginY = param->maxCUSize +