﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
777	Mismatch on the shift value in BCW	wangyang.cs		"**In JVET-P2001-vE, the prediction samples for BCW are derived as follows:**

8.5.6.6.2 Default weighted sample prediction process
…
Variables shift1, shift2, offset1, offset2, and offset3 are derived as follows:
    -The variable shift1 is set equal to Max( 2, 14 − bitDepth ) and the variable shift2 is set equal to Max( 3, 15 − bitDepth ).
    -The variable offset1 is set equal to 1  <<  ( shift1 − 1 ).
    -The variable offset2 is set equal to 1  <<  ( shift2 − 1 ).
    -[[span(style=color: #FF0000, The variable offset3 is set equal to 1  <<  ( shift2 + 2 ).)]]
…
        -Otherwise (bcwIdx is not equal to 0 and ciip_flag[ xCb ][ yCb ] is equal to 0), the following applies:
            -The variable w1 is set equal to bcwWLut[ bcwIdx ] with bcwWLut[ k ] = { 4, 5, 3, 10, −2 }.
            -The variable w0 is set equal to ( 8 − w1 ).
            -The prediction sample values are derived as follows.
                pbSamples[ x ][ y ] = Clip3( 0, ( 1  <<  bitDepth ) − 1, 	(1009)
		( w0*predSamplesL0[ x ][ y ] + w1*predSamplesL1[ x ][ y ] + [[span(style=color: #FF0000, offset3 )  >>  (shift2+3) ) )]]

**In spec, the shift value for BCW is Max( 6, 18 − bitDepth ) (i.e., shift2+3).
However, in VTM7.0, the shift value for BCW is Max( 5, 17 − bitDepth ).**

In {{{void AreaBuf<Pel>::addWeightedAvg()}}}
...
  const int8_t log2WeightBase = g_GbiLog2WeightBase;
...
  const int clipbd = clpRng.bd;
  [[span(style=color: #FF0000,const int shiftNum = std::max<int>(2, (IF_INTERNAL_PREC - clipbd)) + log2WeightBase;)]]
  const int offset = (1 << (shiftNum - 1)) + (IF_INTERNAL_OFFS << log2WeightBase);
…


**Suggested fix is to align the shift value for BCW in spec with VTM.
The modified draft is described as follows:**

8.5.6.6.2 Default weighted sample prediction process
…
Variables shift1, shift2, offset1, offset2, and offset3 are derived as follows:
    -The variable shift1 is set equal to Max( 2, 14 − bitDepth ) and the variable shift2 is set equal to Max( 3, 15 − bitDepth ).
    -The variable offset1 is set equal to 1  <<  ( shift1 − 1 ).
    -The variable offset2 is set equal to 1  <<  ( shift2 − 1 ).
    -The variable offset3 is set equal to 1  <<  ( shift[[span(style=color: #FF0000, ~~2~~)]][[span(style=color: #00FF00, 1)]] + 2 ).
…
        -Otherwise (bcwIdx is not equal to 0 and ciip_flag[ xCb ][ yCb ] is equal to 0), the following applies:
            -The variable w1 is set equal to bcwWLut[ bcwIdx ] with bcwWLut[ k ] = { 4, 5, 3, 10, −2 }.
            -The variable w0 is set equal to ( 8 − w1 ).
            -The prediction sample values are derived as follows.
                pbSamples[ x ][ y ] = Clip3( 0, ( 1  <<  bitDepth ) − 1, 	(1009)
		( w0*predSamplesL0[ x ][ y ] + w1*predSamplesL1[ x ][ y ] + offset3 )  >>  (shift[[span(style=color: #FF0000, ~~2~~)]][[span(style=color: #00FF00, 1)]]+3) )


"	defect	closed	minor		spec	VVC D7 vE	fixed	shift, BCW	ksuehring bbross XiangLi fbossen jvet@… jvet@…
