Skip to content
Snippets Groups Projects
Commit 4f0c3ecc authored by Anand Meher Kotra's avatar Anand Meher Kotra
Browse files

JVET-R0208: Rounding offset fix for ALF virtual boundary processing

parent 9429d13d
No related branches found
No related tags found
No related merge requests found
......@@ -1262,7 +1262,11 @@ void AdaptiveLoopFilter::filterBlk(AlfClassifier **classifier, const PelUnitBuf
}
else
{
#if JVET_R0208_ALF_VB_ROUNDING_FIX
sum = (sum + (1 << ((shift + 3) - 1))) >> (shift + 3);
#else
sum = (sum + offset) >> (shift + 3);
#endif
}
sum += curr;
pRec1[jj] = ClipPel( sum, clpRng );
......
......@@ -53,6 +53,7 @@
//########### place macros to be removed in next cycle below this line ###############
#define JVET_Q0471_CHROMA_QT_SPLIT 1 // JVET-Q0471: Chroma QT split
#define JVET_R0208_ALF_VB_ROUNDING_FIX 1 // JVET-R0208: Rounding offset fix for ALF virtual boundary processing
//########### place macros to be be kept below this line ###############
......
......@@ -313,6 +313,9 @@ static void simdFilter5x5Blk(AlfClassifier **classifier, const PelUnitBuf &recDs
constexpr int SHIFT = AdaptiveLoopFilter::m_NUM_BITS - 1;
constexpr int ROUND = 1 << (SHIFT - 1);
#if JVET_R0208_ALF_VB_ROUNDING_FIX
const __m128i mmOffset1 = _mm_set1_epi32((1 << ((SHIFT + 3) - 1)) - ROUND);
#endif
const size_t width = blk.width;
const size_t height = blk.height;
......@@ -425,8 +428,13 @@ static void simdFilter5x5Blk(AlfClassifier **classifier, const PelUnitBuf &recDs
}
else
{
#if JVET_R0208_ALF_VB_ROUNDING_FIX
accumA = _mm_srai_epi32(_mm_add_epi32(accumA, mmOffset1), SHIFT + 3);
accumB = _mm_srai_epi32(_mm_add_epi32(accumB, mmOffset1), SHIFT + 3);
#else
accumA = _mm_srai_epi32(accumA, SHIFT + 3);
accumB = _mm_srai_epi32(accumB, SHIFT + 3);
#endif
}
accumA = _mm_packs_epi32(accumA, accumB);
accumA = _mm_add_epi16(accumA, cur);
......@@ -507,6 +515,9 @@ static void simdFilter7x7Blk(AlfClassifier **classifier, const PelUnitBuf &recDs
Pel * dst = dstBuffer.buf + blkDst.y * dstStride + blkDst.x;
const __m128i mmOffset = _mm_set1_epi32(ROUND);
#if JVET_R0208_ALF_VB_ROUNDING_FIX
const __m128i mmOffset1 = _mm_set1_epi32((1 << ((SHIFT + 3) - 1)) - ROUND);
#endif
const __m128i mmMin = _mm_set1_epi16( clpRng.min );
const __m128i mmMax = _mm_set1_epi16( clpRng.max );
......@@ -655,8 +666,13 @@ static void simdFilter7x7Blk(AlfClassifier **classifier, const PelUnitBuf &recDs
}
else
{
#if JVET_R0208_ALF_VB_ROUNDING_FIX
accumA = _mm_srai_epi32(_mm_add_epi32(accumA, mmOffset1), SHIFT + 3);
accumB = _mm_srai_epi32(_mm_add_epi32(accumB, mmOffset1), SHIFT + 3);
#else
accumA = _mm_srai_epi32(accumA, SHIFT + 3);
accumB = _mm_srai_epi32(accumB, SHIFT + 3);
#endif
}
accumA = _mm_packs_epi32(accumA, accumB);
accumA = _mm_add_epi16(accumA, cur);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment