From 7a02ddecaaa82eda897569b70afa2dc45165a793 Mon Sep 17 00:00:00 2001 From: Christopher Degawa Date: Fri, 15 Nov 2019 21:32:44 +0000 Subject: [PATCH] conflicts: Fix conflicts with SVT-AV1 --- Source/App/EbTime.h | 8 +- .../Lib/ASM_AVX2/EbMCP16bit_Intrinsic_AVX2.c | 9 +- Source/Lib/ASM_AVX2/EbNoiseExtractAVX2.c | 14 +- .../ASM_AVX2/EbTransforms_Intrinsic_AVX2.c | 145 +- .../Lib/ASM_SSE2/EbMcp16bit_Intrinsic_SSE2.c | 70 +- .../Lib/ASM_SSE2/EbPictureOperators_SSE2.asm | 9 +- .../ASM_SSE2/EbTransforms_Intrinsic_SSE2.c | 42 +- Source/Lib/ASM_SSE2/x64RegisterUtil.asm | 12 +- .../ASM_SSSE3/EbAvcStyleMcp_Intrinsic_SSSE3.c | 22 +- Source/Lib/ASM_SSSE3/EbMcp_Intrinsic_SSSE3.c | 88 +- .../ASM_SSSE3/EbTransforms_Intrinsic_SSSE3.c | 444 +++--- Source/Lib/Codec/EbCodingLoop.c | 16 +- Source/Lib/Codec/EbCodingUnit.h | 26 +- Source/Lib/Codec/EbDefinitions.h | 2 +- Source/Lib/Codec/EbEncDecProcess.c | 144 +- Source/Lib/Codec/EbEncHandle.c | 38 +- Source/Lib/Codec/EbEntropyCoding.c | 146 +- .../Lib/Codec/EbInitialRateControlProcess.c | 145 +- .../Lib/Codec/EbInitialRateControlProcess.h | 6 +- Source/Lib/Codec/EbIntraPrediction.c | 1233 ++++++++--------- Source/Lib/Codec/EbMdRateEstimation.c | 8 +- Source/Lib/Codec/EbMdRateEstimation.h | 26 +- Source/Lib/Codec/EbModeDecision.c | 94 +- .../Lib/Codec/EbModeDecisionConfiguration.c | 59 +- .../EbModeDecisionConfigurationProcess.c | 176 +-- Source/Lib/Codec/EbModeDecisionProcess.c | 24 +- Source/Lib/Codec/EbMotionEstimation.c | 271 ++-- Source/Lib/Codec/EbMotionEstimation.h | 6 +- Source/Lib/Codec/EbMotionEstimationContext.c | 28 +- Source/Lib/Codec/EbMotionEstimationProcess.c | 92 +- Source/Lib/Codec/EbPacketizationProcess.c | 118 +- Source/Lib/Codec/EbPictureAnalysisProcess.c | 134 +- Source/Lib/Codec/EbPictureDecisionProcess.c | 410 +++--- Source/Lib/Codec/EbPictureManagerProcess.c | 292 ++-- Source/Lib/Codec/EbPictureOperators.c | 72 +- Source/Lib/Codec/EbPictureOperators.h | 48 +- Source/Lib/Codec/EbProductCodingLoop.c | 277 ++-- Source/Lib/Codec/EbRateDistortionCost.c | 86 +- Source/Lib/Codec/EbReferenceObject.c | 51 +- .../Lib/Codec/EbResourceCoordinationProcess.c | 42 +- .../Codec/EbSourceBasedOperationsProcess.c | 58 +- Source/Lib/Codec/EbString.c | 46 +- Source/Lib/Codec/EbString.h | 22 +- Source/Lib/Codec/EbTransforms.c | 112 +- Source/Lib/Codec/EbUtility.c | 14 +- Source/Lib/Codec/EbUtility.h | 26 +- 46 files changed, 2592 insertions(+), 2619 deletions(-) diff --git a/Source/App/EbTime.h b/Source/App/EbTime.h index c58e2e860..12e755754 100644 --- a/Source/App/EbTime.h +++ b/Source/App/EbTime.h @@ -6,13 +6,13 @@ #ifndef EbTime_h #define EbTime_h -void EbStartTime(uint64_t *Startseconds, uint64_t *Startuseconds); -void EbFinishTime(uint64_t *Finishseconds, uint64_t *Finishuseconds); -void EbComputeOverallElapsedTime(uint64_t Startseconds, uint64_t Startuseconds,uint64_t Finishseconds, uint64_t Finishuseconds, double *duration); +void EbHevcStartTime(uint64_t *Startseconds, uint64_t *Startuseconds); +void EbHevcFinishTime(uint64_t *Finishseconds, uint64_t *Finishuseconds); +void EbHevcComputeOverallElapsedTime(uint64_t Startseconds, uint64_t Startuseconds,uint64_t Finishseconds, uint64_t Finishuseconds, double *duration); void EbAppStartTime(uint64_t *Startseconds, uint64_t *Startuseconds); void EbAppFinishTime(uint64_t *Finishseconds, uint64_t *Finishuseconds); void EbAppComputeOverallElapsedTime(uint64_t Startseconds, uint64_t Startuseconds,uint64_t Finishseconds, uint64_t Finishuseconds, double *duration); -void EbComputeOverallElapsedTimeMs(uint64_t Startseconds, uint64_t Startuseconds, uint64_t Finishseconds, uint64_t Finishuseconds, double *duration); +void EbHevcComputeOverallElapsedTimeMs(uint64_t Startseconds, uint64_t Startuseconds, uint64_t Finishseconds, uint64_t Finishuseconds, double *duration); void EbSleep(uint64_t milliSeconds); void EbInjector(uint64_t processedFrameCount, uint32_t injectorFrameRate); diff --git a/Source/Lib/ASM_AVX2/EbMCP16bit_Intrinsic_AVX2.c b/Source/Lib/ASM_AVX2/EbMCP16bit_Intrinsic_AVX2.c index 0017013d6..862744316 100644 --- a/Source/Lib/ASM_AVX2/EbMCP16bit_Intrinsic_AVX2.c +++ b/Source/Lib/ASM_AVX2/EbMCP16bit_Intrinsic_AVX2.c @@ -8,7 +8,7 @@ #include "EbMcp_SSE2.h" #include "EbDefinitions.h" -EB_EXTERN EB_ALIGN(16) const EB_S16 chromaFilterCoeffSR1_AVX[8][4] = +EB_EXTERN EB_ALIGN(16) const EB_S16 EbHevcchromaFilterCoeffSR1_AVX[8][4] = { { 0, 32, 0, 0 }, { -1, 29, 5, -1 }, @@ -40,7 +40,7 @@ void ChromaInterpolationFilterTwoD16bit_AVX2_INTRIN( ChromaInterpolationFilterOneDOutRaw16bitHorizontal_AVX2_INTRIN(refPic - ((MaxChromaFilterTag - 1) >> 1)*srcStride, srcStride, firstPassIFDst, puWidth, puHeight + MaxChromaFilterTag - 1, (EB_S16 *)EB_NULL, fracPosx, 0); #endif - + //vertical filtering ChromaInterpolationFilterTwoDInRaw16bit_SSE2_INTRIN(firstPassIFDst, dst, dstStride, puWidth, puHeight, fracPosy); } @@ -62,7 +62,7 @@ void ChromaInterpolationFilterTwoDOutRaw16bit_AVX2_INTRIN( //on-the-fly scheme ChromaInterpolationFilterOneDOutRaw16bitHorizontal_AVX2_INTRIN(refPic - ((MaxChromaFilterTag - 1) >> 1)*srcStride, srcStride, firstPassIFDst, puWidth, puHeight + MaxChromaFilterTag - 1, (EB_S16 *)EB_NULL, fracPosx, 0); #endif - + //vertical filtering ChromaInterpolationFilterTwoDInRawOutRaw_SSE2_INTRIN(firstPassIFDst, dst, puWidth, puHeight, fracPosy); } @@ -92,7 +92,7 @@ void ChromaInterpolationFilterOneDOutRaw16bitHorizontal_AVX2_INTRIN( refPic--; //PrefetchBlock(refPic, srcStride, puWidth+8, puHeight); - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeffSR1_AVX[fracPosx]); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeffSR1_AVX[fracPosx]); c0 = _mm_unpacklo_epi16(c0, c0); c3 = _mm_shuffle_epi32(c0, 0xff); c2 = _mm_shuffle_epi32(c0, 0xaa); @@ -267,4 +267,3 @@ void ChromaInterpolationFilterOneDOutRaw16bitHorizontal_AVX2_INTRIN( } } - diff --git a/Source/Lib/ASM_AVX2/EbNoiseExtractAVX2.c b/Source/Lib/ASM_AVX2/EbNoiseExtractAVX2.c index aaa1813e9..ecd1f9a1b 100644 --- a/Source/Lib/ASM_AVX2/EbNoiseExtractAVX2.c +++ b/Source/Lib/ASM_AVX2/EbNoiseExtractAVX2.c @@ -9,11 +9,11 @@ #include "immintrin.h" #include "EbUtility.h" -EB_EXTERN EB_ALIGN(16) const EB_U8 filterType[] = { +EB_EXTERN EB_ALIGN(16) const EB_U8 EbHevcfilterType[] = { 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4 }; -EB_EXTERN EB_ALIGN(16) const EB_U8 WeakChromafilter[2][32] = { +EB_EXTERN EB_ALIGN(16) const EB_U8 EbHevcWeakChromafilter[2][32] = { { 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4 }, { 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 }, }; @@ -39,7 +39,7 @@ inline void lumaWeakFilter_AVX2_INTRIN( currPrevPermutation = _mm256_permute4x64_epi64(currPrev, 216); currPermutation = _mm256_permute4x64_epi64(curr, 216); currLeftMidFirstHalflo = _mm256_unpacklo_epi8(currPrevPermutation, currPermutation); - weights = _mm256_loadu_si256((__m256i*)filterType); + weights = _mm256_loadu_si256((__m256i*)EbHevcfilterType); currLeftMidFirstHalfWeight = _mm256_maddubs_epi16(currLeftMidFirstHalflo, weights); currNextPermutation = _mm256_permute4x64_epi64(currNext, 88); currNextFirstHalf = _mm256_unpacklo_epi8(currNextPermutation, _mm256_setzero_si256()); @@ -100,7 +100,7 @@ inline void chromaWeakLumaStrongFilter_AVX2_INTRIN( currPrevPermutation = _mm256_permute4x64_epi64(currPrev, 216); currPermutation = _mm256_permute4x64_epi64(curr, 216); currLeftMidFirstHalflo = _mm256_unpacklo_epi8(currPrevPermutation, currPermutation); - weights = _mm256_loadu_si256((__m256i*)WeakChromafilter[0]); + weights = _mm256_loadu_si256((__m256i*)EbHevcWeakChromafilter[0]); currLeftMidFirstHalfWeight = _mm256_maddubs_epi16(currLeftMidFirstHalflo, weights); currNextPermutation = _mm256_permute4x64_epi64(currNext, 88); currNextFirstHalf = _mm256_unpacklo_epi8(currNextPermutation, _mm256_setzero_si256()); @@ -118,7 +118,7 @@ inline void chromaWeakLumaStrongFilter_AVX2_INTRIN( topPrevPermutation = _mm256_permute4x64_epi64(topPrev, 216); topPermutation = _mm256_permute4x64_epi64(top, 216); topLeftMidFirstHalflo = _mm256_unpacklo_epi8(topPrevPermutation, topPermutation); - weights = _mm256_loadu_si256((__m256i*)WeakChromafilter[1]); + weights = _mm256_loadu_si256((__m256i*)EbHevcWeakChromafilter[1]); topLeftMidFirstHalfWeight = _mm256_maddubs_epi16(topLeftMidFirstHalflo, weights); topNextPermutation = _mm256_permute4x64_epi64(topNext, 88); topNextFirstHalf = _mm256_unpacklo_epi8(topNextPermutation, _mm256_setzero_si256()); @@ -135,7 +135,7 @@ inline void chromaWeakLumaStrongFilter_AVX2_INTRIN( bottomPrevPermutation = _mm256_permute4x64_epi64(bottomPrev, 216); bottomPermutation = _mm256_permute4x64_epi64(bottom, 216); bottomLeftMidFirstHalflo = _mm256_unpacklo_epi8(bottomPrevPermutation, bottomPermutation); - weights = _mm256_loadu_si256((__m256i*)WeakChromafilter[1]); + weights = _mm256_loadu_si256((__m256i*)EbHevcWeakChromafilter[1]); bottomLeftMidFirstHalfWeight = _mm256_maddubs_epi16(bottomLeftMidFirstHalflo, weights); bottomNextPermutation = _mm256_permute4x64_epi64(bottomNext, 88); bottomNextFirstHalf = _mm256_unpacklo_epi8(bottomNextPermutation, _mm256_setzero_si256()); @@ -305,7 +305,7 @@ void noiseExtractLumaWeak_AVX2_INTRIN( // p[1 + 2 * stride]) / 8; top = curr = secondtop = secondcurr = _mm256_setzero_si256(); - + for (kk = 0; kk + MAX_LCU_SIZE <= picWidth; kk += MAX_LCU_SIZE) { for (jj = 0; jj < lcuHeight; jj++) diff --git a/Source/Lib/ASM_AVX2/EbTransforms_Intrinsic_AVX2.c b/Source/Lib/ASM_AVX2/EbTransforms_Intrinsic_AVX2.c index 71cea045c..50ab58080 100644 --- a/Source/Lib/ASM_AVX2/EbTransforms_Intrinsic_AVX2.c +++ b/Source/Lib/ASM_AVX2/EbTransforms_Intrinsic_AVX2.c @@ -13,7 +13,7 @@ #ifdef __GNUC__ __attribute__((aligned(16))) #endif -EB_ALIGN(32) const EB_S16 coeff_tbl_AVX2[48 * 16] = +EB_ALIGN(32) const EB_S16 EbHevccoeff_tbl_AVX2[48 * 16] = { 64, 64, 89, 75, 83, 36, 75, -18, 64, 64, 89, 75, 83, 36, 75, -18, 64, -64, 50, -89, 36, -83, 18, -50, 64, -64, 50, -89, 36, -83, 18, -50, 64, 64, 50, 18, -36, -83, -89, -50, 64, 64, 50, 18, -36, -83, -89, -50, -64, 64, 18, 75, 83, -36, 75, -89, -64, 64, 18, 75, 83, -36, 75, -89, @@ -282,7 +282,7 @@ void QuantizeInvQuantize8x8_AVX2_INTRIN( // transpose 16x16 block of data -void transpose16_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride) +void EbHevctranspose16_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride) { EB_U32 i; for (i = 0; i < 2; i++) @@ -346,7 +346,7 @@ void transpose16_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 } // transpose 32x32 block of data -void transpose32_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride) +void EbHevctranspose32_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride) { EB_U32 i, j; for (i = 0; i < 4; i++) @@ -553,7 +553,7 @@ void transform16_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m256i o0 = _mm256_set1_epi32(1 << (shift - 1)); - const __m256i *coeff32 = (const __m256i *)coeff_tbl_AVX2; + const __m256i *coeff32 = (const __m256i *)EbHevccoeff_tbl_AVX2; for (i = 0; i < 16; i += 2) { @@ -610,12 +610,12 @@ void transform16_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 } // 32-point forward transform (32 rows) -void transform32_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride, EB_U32 shift) +void EbHevctransform32_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride, EB_U32 shift) { EB_U32 i; __m128i s0; __m256i o0; - const __m256i *coeff32 = (const __m256i *)coeff_tbl_AVX2; + const __m256i *coeff32 = (const __m256i *)EbHevccoeff_tbl_AVX2; shift &= 0x0000FFFF; // Redundant code to fix Visual Studio 2012 AVX2 compiler error s0 = _mm_cvtsi32_si128(shift); @@ -755,7 +755,7 @@ void Pfreq1DTransform32_AVX2_INTRIN( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m256i o0 = _mm256_set1_epi32(1 << (shift - 1)); - const __m256i *coeff32 = (const __m256i *)coeff_tbl_AVX2; + const __m256i *coeff32 = (const __m256i *)EbHevccoeff_tbl_AVX2; for (i = 0; i < 32; i += 2) { @@ -889,7 +889,7 @@ void Pfreq2DTransform32_AVX2_INTRIN( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m256i o0 = _mm256_set1_epi32(1 << (shift - 1)); - const __m256i *coeff32 = (const __m256i *)coeff_tbl_AVX2; + const __m256i *coeff32 = (const __m256i *)EbHevccoeff_tbl_AVX2; for (i = 0; i < 16; i += 2) { @@ -1038,7 +1038,7 @@ void PfreqN41DTransform32_AVX2_INTRIN( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m256i o0 = _mm256_set1_epi32(1 << (shift - 1)); - const __m256i *coeff32 = (const __m256i *)coeff_tbl_AVX2; + const __m256i *coeff32 = (const __m256i *)EbHevccoeff_tbl_AVX2; for (i = 0; i < 32; i += 2) { @@ -1175,7 +1175,7 @@ void PfreqN42DTransform32_AVX2_INTRIN( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m256i o0 = _mm256_set1_epi32(1 << (shift - 1)); - const __m256i *coeff32 = (const __m256i *)coeff_tbl_AVX2; + const __m256i *coeff32 = (const __m256i *)EbHevccoeff_tbl_AVX2; //for (i = 0; i < 16; i += 2) for (i = 0; i < 8; i += 2) @@ -1291,8 +1291,8 @@ void PfreqN42DTransform32_AVX2_INTRIN( //x2 = _mm256_unpacklo_epi16(y1, y3); //x3 = _mm256_unpackhi_epi16(y1, y3); - //---// y0 = _mm256_insertf128_si256(_mm256_castsi128_si256(_mm256_extracti128_si256(x0, 0)), _mm256_extracti128_si256(x1, 0), 0x1); - //---//y2 = _mm256_insertf128_si256(_mm256_castsi128_si256(_mm256_extracti128_si256(x0, 1)), _mm256_extracti128_si256(x1, 1), 0x1); + //---// y0 = _mm256_insertf128_si256(_mm256_castsi128_si256(_mm256_extracti128_si256(x0, 0)), _mm256_extracti128_si256(x1, 0), 0x1); + //---//y2 = _mm256_insertf128_si256(_mm256_castsi128_si256(_mm256_extracti128_si256(x0, 1)), _mm256_extracti128_si256(x1, 1), 0x1); //---// _mm256_storeu_si256((__m256i *)(dst + i*dst_stride), y0); //---// _mm256_storeu_si256((__m256i *)(dst + (i + 1)*dst_stride), y2); @@ -1458,20 +1458,20 @@ void PfreqN4Transform32x32_AVX2_INTRIN( EB_EXTERN void lowPrecisionTransform16x16_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride, EB_S16 *intermediate, EB_U32 addshift) { transform16_AVX2_INTRIN(src, src_stride, intermediate, 16, (EB_S16)(4 + addshift)); - transpose16_AVX2_INTRIN(intermediate, 16, dst, dst_stride); + EbHevctranspose16_AVX2_INTRIN(intermediate, 16, dst, dst_stride); transform16_AVX2_INTRIN(dst, dst_stride, intermediate, 16, 9); - transpose16_AVX2_INTRIN(intermediate, 16, dst, dst_stride); + EbHevctranspose16_AVX2_INTRIN(intermediate, 16, dst, dst_stride); } // forward 32x32 transform EB_EXTERN void lowPrecisionTransform32x32_AVX2_INTRIN(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride, EB_S16 *intermediate, EB_U32 addshift) { - transform32_AVX2_INTRIN(src, src_stride, intermediate, 32, 6 + addshift); - transpose32_AVX2_INTRIN(intermediate, 32, dst, dst_stride); - transform32_AVX2_INTRIN(dst, dst_stride, intermediate, 32, 9); - transpose32_AVX2_INTRIN(intermediate, 32, dst, dst_stride); + EbHevctransform32_AVX2_INTRIN(src, src_stride, intermediate, 32, 6 + addshift); + EbHevctranspose32_AVX2_INTRIN(intermediate, 32, dst, dst_stride); + EbHevctransform32_AVX2_INTRIN(dst, dst_stride, intermediate, 32, 9); + EbHevctranspose32_AVX2_INTRIN(intermediate, 32, dst, dst_stride); } void MatMult4x4_OutBuff_AVX2_INTRIN( @@ -1480,10 +1480,10 @@ void MatMult4x4_OutBuff_AVX2_INTRIN( EB_S16* coeffOut, const EB_U32 coeffOutStride, const EB_U16 *maskingMatrix, - const EB_U32 maskingMatrixStride, - const EB_U32 computeSize, - const EB_S32 offset, - const EB_S32 shiftNum, + const EB_U32 maskingMatrixStride, + const EB_U32 computeSize, + const EB_S32 offset, + const EB_S32 shiftNum, EB_U32* nonzerocoeff) { @@ -1549,7 +1549,7 @@ void MatMult4x4_OutBuff_AVX2_INTRIN( void MatMult4x4_AVX2_INTRIN( EB_S16* coeff, const EB_U32 coeffStride, - const EB_U16 *maskingMatrix, + const EB_U16 *maskingMatrix, const EB_U32 maskingMatrixStride, //Matrix size const EB_U32 computeSize, //Computation area size const EB_S32 offset, //(PMP_MAX >> 1) @@ -1563,52 +1563,52 @@ void MatMult4x4_AVX2_INTRIN( (void)computeSize; coeffTemp = a0 = a1 = b0 = b1 = ymm_computed = MaskingMatrix = offsetREG = _mm256_setzero_si256(); - + // prepare Shift REG __m128i PMP_PRECISION_REG = _mm_set_epi16(0, 0, 0, 0, 0, 0, 0, (EB_S16)shiftNum); //_mm_set1_epi16((EB_U16)shiftNum);//_mm_set1_epi32(shiftNum); - + //prepare the offset offsetREG = _mm256_set1_epi32(offset); - + //load maskingMatrix_new MaskingMatrix = _mm256_insertf128_si256(_mm256_castsi128_si256(_mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*)maskingMatrix), _mm_loadl_epi64((__m128i*)(maskingMatrix + maskingMatrixStride)))), _mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*)(maskingMatrix + 2 * maskingMatrixStride)), _mm_loadl_epi64((__m128i*)(maskingMatrix + 3 * maskingMatrixStride))), 0x1); - + //load coefftemp a = _mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*)coeff), _mm_loadl_epi64((__m128i*)(coeff + coeffStride))); // 1st and 2nd row of the 4x4 block b = _mm_unpacklo_epi64(_mm_loadl_epi64((__m128i*)(coeff + 2 * coeffStride)), _mm_loadl_epi64((__m128i*)(coeff + 3 * coeffStride))); // 3rd and 4th row of the 4x4 block coeffTemp = _mm256_insertf128_si256(_mm256_castsi128_si256( a),b,0x1); // the 4x4 block is now loaded - + coeffTempORG = coeffTemp; //Absolute val coeffTemp = _mm256_abs_epi16(coeffTemp); - + a0 = _mm256_mullo_epi16(coeffTemp, MaskingMatrix); a1 = _mm256_mulhi_epi16(coeffTemp, MaskingMatrix); - - + + b0 = _mm256_unpacklo_epi16(a0, a1); b1 = _mm256_unpackhi_epi16(a0, a1); - + b0 = _mm256_add_epi32(b0, offsetREG); b1 = _mm256_add_epi32(b1, offsetREG); - + //Shift right by PMP_PRECISION_REG b0 = _mm256_sra_epi32(b0, PMP_PRECISION_REG); b1 = _mm256_sra_epi32(b1, PMP_PRECISION_REG); - + //coefftemp in c ymm_computed = _mm256_packs_epi32(b0, b1);//Convert packed 32-bit integers from a and b to packed 16-bit integers using signed saturation, and store the results in dst. z = _mm256_sub_epi16(z, _mm256_cmpgt_epi16(ymm_computed, _mm256_setzero_si256())); //coeffTemp = (coeff[coeffLocation] < 0)? -coeffTemp : coeffTemp; ymm_computed = _mm256_sign_epi16(ymm_computed, coeffTempORG);// coeffTemp); - + a = _mm256_extracti128_si256(ymm_computed, 0); b = _mm256_extracti128_si256(ymm_computed, 1); _mm_storel_epi64((__m128i *)coeff, a); _mm_storel_epi64((__m128i *)(coeff + coeffStride), _mm_srli_si128(a, 8)); _mm_storel_epi64((__m128i *)(coeff + 2 * coeffStride), b); _mm_storel_epi64((__m128i *)(coeff + 3 * coeffStride), _mm_srli_si128(b, 8)); - + z = _mm256_sad_epu8(z, _mm256_srli_si256(z, 8)); *nonzerocoeff = _mm_cvtsi128_si32(_mm_add_epi32(_mm256_extracti128_si256(z, 0), _mm256_extracti128_si256(z, 1))); @@ -1633,15 +1633,15 @@ void MatMult8x8_AVX2_INTRIN( // prepare Shift REG __m128i PMP_PRECISION_REG = _mm_set_epi16(0, 0, 0, 0, 0, 0, 0, (EB_S16)shiftNum);//_mm_set1_epi32(shiftNum); - + //prepare the offset - __m256i offsetREG = _mm256_set1_epi32(offset); + __m256i offsetREG = _mm256_set1_epi32(offset); row = 0; do { - + //load maskingMatrix_new MaskingMatrix = _mm256_insertf128_si256(_mm256_castsi128_si256(_mm_loadu_si128((__m128i*)(maskingMatrix + maskingMatrixStride*row))), _mm_loadu_si128((__m128i*)(maskingMatrix + maskingMatrixStride*(row + 1))), 0x1); - + //load coefftemp coeffTemp = _mm256_insertf128_si256(_mm256_castsi128_si256(_mm_loadu_si128((__m128i*)(coeff + coeffStride*row))), _mm_loadu_si128((__m128i*)(coeff + coeffStride*(row + 1))), 0x1); @@ -1649,38 +1649,38 @@ void MatMult8x8_AVX2_INTRIN( coeffTempORG = coeffTemp; //Absolute val coeffTemp = _mm256_abs_epi16(coeffTemp); - + //Multiply a0 = _mm256_mullo_epi16(coeffTemp, MaskingMatrix); a1 = _mm256_mulhi_epi16(coeffTemp, MaskingMatrix); - - + + b0 = _mm256_unpacklo_epi16(a0, a1); b1 = _mm256_unpackhi_epi16(a0, a1); - + //Add b0 = _mm256_add_epi32(b0, offsetREG); b1 = _mm256_add_epi32(b1, offsetREG); - + //Shift right by PMP_PRECISION_REG b0 = _mm256_sra_epi32(b0, PMP_PRECISION_REG); b1 = _mm256_sra_epi32(b1, PMP_PRECISION_REG); - + //coefftemp in c ymm_computed = _mm256_packs_epi32(b0, b1);//Convert packed 32-bit integers from b0 and b1 to packed 16-bit integers using signed saturation, and store the results in dst. z = _mm256_sub_epi16(z, _mm256_cmpgt_epi16(ymm_computed, _mm256_setzero_si256())); //coeffTemp = (coeff[coeffLocation] < 0)? -coeffTemp : coeffTemp; - + ymm_computed = _mm256_sign_epi16(ymm_computed, coeffTempORG);// coeffTemp); - + _mm_storeu_si128((__m128i *)(coeff + coeffStride*row), _mm256_extracti128_si256(ymm_computed, 0)); _mm_storeu_si128((__m128i *)(coeff + coeffStride*(row + 1)), _mm256_extracti128_si256(ymm_computed, 1)); - + row += 2; } while (row < computeSize); - + z = _mm256_sad_epu8(z, _mm256_srli_si256(z, 7)); *nonzerocoeff = _mm_cvtsi128_si32(_mm_add_epi32(_mm256_extracti128_si256(z, 0), _mm256_extracti128_si256(z, 1))); - + } /***************************************MatMultNxN_AVX2_INTRIN****************************************************/ void MatMultNxN_AVX2_INTRIN( @@ -1693,68 +1693,67 @@ void MatMultNxN_AVX2_INTRIN( const EB_S32 shiftNum, //PMP_PRECISION EB_U32* nonzerocoeff) { - + unsigned row,col; __m256i z = _mm256_setzero_si256(); //__m128i a, b; __m256i coeffTemp,a0,a1,b0,b1,ymm_computed,MaskingMatrix,coeffTempORG; coeffTemp = a0 = a1 = b0 = b1 = ymm_computed =MaskingMatrix = _mm256_setzero_si256(); - + // prepare Shift REG __m128i PMP_PRECISION_REG = _mm_set_epi16(0, 0, 0, 0, 0, 0, 0, (EB_S16)shiftNum);//_mm_set1_epi32(shiftNum); - + //prepare the offset - __m256i offsetREG = _mm256_set1_epi32(offset); - + __m256i offsetREG = _mm256_set1_epi32(offset); + row = 0; do { col = 0; do { - + //load coefftemp coeffTemp = _mm256_loadu_si256((__m256i *)(coeff + coeffStride*row + col)); - + //load maskingMatrix_new MaskingMatrix = _mm256_loadu_si256((__m256i *) (maskingMatrix + maskingMatrixStride*row + col)); - + coeffTempORG = coeffTemp; - + //Absolute val coeffTemp = _mm256_abs_epi16(coeffTemp); - + //Multiply a0 = _mm256_mullo_epi16(coeffTemp, MaskingMatrix); a1 = _mm256_mulhi_epi16(coeffTemp, MaskingMatrix); - - + + b0 = _mm256_unpacklo_epi16(a0, a1); b1 = _mm256_unpackhi_epi16(a0, a1); - + //Add b0 = _mm256_add_epi32(b0, offsetREG); b1 = _mm256_add_epi32(b1, offsetREG); - + //Shift right by PMP_PRECISION_REG b0 = _mm256_sra_epi32(b0, PMP_PRECISION_REG); b1 = _mm256_sra_epi32(b1, PMP_PRECISION_REG); - + //coefftemp in c ymm_computed = _mm256_packs_epi32(b0, b1);//Convert packed 32-bit integers from b0 and b1 to packed 16-bit integers using signed saturation, and store the results in dst. z = _mm256_sub_epi16(z, _mm256_cmpgt_epi16(ymm_computed, _mm256_setzero_si256())); //coeffTemp = (coeff[coeffLocation] < 0)? -coeffTemp : coeffTemp; - + ymm_computed = _mm256_sign_epi16(ymm_computed, coeffTempORG);// coeffTemp); - + _mm256_storeu_si256((__m256i *)(coeff + coeffStride*row + col), ymm_computed); - + col += 16; } while (col < computeSize); row++; } while (row < computeSize); - + z = _mm256_sad_epu8(z, _mm256_srli_si256(z, 7)); - *nonzerocoeff = _mm_cvtsi128_si32(_mm_add_epi32(_mm256_extracti128_si256(z, 0), _mm256_extracti128_si256(z, 1))); - -} + *nonzerocoeff = _mm_cvtsi128_si32(_mm_add_epi32(_mm256_extracti128_si256(z, 0), _mm256_extracti128_si256(z, 1))); +} diff --git a/Source/Lib/ASM_SSE2/EbMcp16bit_Intrinsic_SSE2.c b/Source/Lib/ASM_SSE2/EbMcp16bit_Intrinsic_SSE2.c index ec241a346..1dadb33c8 100644 --- a/Source/Lib/ASM_SSE2/EbMcp16bit_Intrinsic_SSE2.c +++ b/Source/Lib/ASM_SSE2/EbMcp16bit_Intrinsic_SSE2.c @@ -16,7 +16,7 @@ EB_EXTERN EB_ALIGN(16) const EB_S16 lumaIFCoeff16_SSE2_INTRIN[]= { -10, 4, -10, 4, -10, 4, -10, 4, }; -EB_EXTERN EB_ALIGN(16) const EB_S16 chromaFilterCoeffSR1[8][4] = +EB_EXTERN EB_ALIGN(16) const EB_S16 EbHevcchromaFilterCoeffSR1[8][4] = { { 0, 32, 0, 0}, {-1, 29, 5, -1}, @@ -28,7 +28,7 @@ EB_EXTERN EB_ALIGN(16) const EB_S16 chromaFilterCoeffSR1[8][4] = {-1, 5, 29, -1}, }; -//extern const EB_S16 chromaFilterCoeff[8][4]; +//extern const EB_S16 EbHevcchromaFilterCoeff[8][4]; void PictureCopyKernelOutRaw16bit_SSE2_INTRIN( EB_U16 *refPic, @@ -36,12 +36,12 @@ void PictureCopyKernelOutRaw16bit_SSE2_INTRIN( EB_S16 *dst, EB_U32 puWidth, EB_U32 puHeight) -{ +{ EB_U32 rowCount, colCount; __m128i a0, a1, a2, a3; //PrefetchBlock(refPic, srcStride, puWidth, puHeight); - + if (puWidth & 2) { EB_U16 *ptr = refPic; rowCount = puHeight; @@ -56,20 +56,20 @@ void PictureCopyKernelOutRaw16bit_SSE2_INTRIN( a0 = _mm_slli_epi16(a0, BI_SHIFT_10BIT); a0 = _mm_sub_epi16(a0, _mm_set1_epi16(BI_OFFSET_10BIT)); _mm_storeu_si128((__m128i *)dst, a0); - + dst += 8; rowCount -= 4; } while (rowCount != 0); - + puWidth -= 2; if (puWidth == 0) { return; } - + refPic += 2; } - + if (puWidth & 4) { EB_U16 *ptr = refPic; rowCount = puHeight; @@ -81,20 +81,20 @@ void PictureCopyKernelOutRaw16bit_SSE2_INTRIN( a0 = _mm_slli_epi16(a0, BI_SHIFT_10BIT); a0 = _mm_sub_epi16(a0, _mm_set1_epi16(BI_OFFSET_10BIT)); _mm_storeu_si128((__m128i *)dst, a0); - + dst += 8; rowCount -= 2; } while (rowCount != 0); - + puWidth -= 4; if (puWidth == 0) { return; } - + refPic += 4; } - + colCount = puWidth; do { __m128i a0; @@ -108,7 +108,7 @@ void PictureCopyKernelOutRaw16bit_SSE2_INTRIN( dst += 8; } while (--rowCount != 0); - + colCount -= 8; refPic += 8; } @@ -1982,8 +1982,8 @@ EB_U16 *refPic, EB_U32 srcStride, EB_U16 *dst, EB_U32 dstStride, EB_U32 puWidth, refPic--; //PrefetchBlock(refPic, srcStride, puWidth+8, puHeight); - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeffSR1[fracPosx]); - c0 = _mm_unpacklo_epi16(c0, c0); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeffSR1[fracPosx]); + c0 = _mm_unpacklo_epi16(c0, c0); c3 = _mm_shuffle_epi32(c0, 0xff); c2 = _mm_shuffle_epi32(c0, 0xaa); c1 = _mm_shuffle_epi32(c0, 0x55); @@ -2111,8 +2111,8 @@ EB_U16 *refPic, EB_U32 srcStride, EB_U16 *dst, EB_U32 dstStride, EB_U32 puWidth, (void)firstPassIFDst; (void)fracPosx; - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeffSR1[fracPosy]); - c0 = _mm_unpacklo_epi16(c0, c0); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeffSR1[fracPosy]); + c0 = _mm_unpacklo_epi16(c0, c0); c3 = _mm_shuffle_epi32(c0, 0xff); c2 = _mm_shuffle_epi32(c0, 0xaa); c1 = _mm_shuffle_epi32(c0, 0x55); @@ -2248,8 +2248,8 @@ void ChromaInterpolationFilterOneDOutRaw16bitHorizontal_SSE2_INTRIN( refPic--; //PrefetchBlock(refPic, srcStride, puWidth+8, puHeight); - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeffSR1[fracPosx]); - c0 = _mm_unpacklo_epi16(c0, c0); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeffSR1[fracPosx]); + c0 = _mm_unpacklo_epi16(c0, c0); c3 = _mm_shuffle_epi32(c0, 0xff); c2 = _mm_shuffle_epi32(c0, 0xaa); c1 = _mm_shuffle_epi32(c0, 0x55); @@ -2374,8 +2374,8 @@ void ChromaInterpolationFilterOneDOutRaw16bitVertical_SSE2_INTRIN( (void)firstPassIFDst; (void)fracPosx; - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeffSR1[fracPosy]); - c0 = _mm_unpacklo_epi16(c0, c0); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeffSR1[fracPosy]); + c0 = _mm_unpacklo_epi16(c0, c0); c3 = _mm_shuffle_epi32(c0, 0xff); c2 = _mm_shuffle_epi32(c0, 0xaa); c1 = _mm_shuffle_epi32(c0, 0x55); @@ -2494,7 +2494,7 @@ void ChromaInterpolationFilterTwoDInRaw16bit_SSE2_INTRIN( //PrefetchBlock(refPic, srcStride, puWidth+8, puHeight); - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeffSR1[fracPosy]); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeffSR1[fracPosy]); c1 = _mm_shuffle_epi32(c0, 0x55); c0 = _mm_shuffle_epi32(c0, 0); @@ -2622,7 +2622,7 @@ void ChromaInterpolationFilterTwoDInRawOutRaw_SSE2_INTRIN( //PrefetchBlock(refPic, srcStride, puWidth+8, puHeight); - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeffSR1[fracPosy]); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeffSR1[fracPosy]); c1 = _mm_shuffle_epi32(c0, 0x55); c0 = _mm_shuffle_epi32(c0, 0); @@ -2728,7 +2728,7 @@ void BiPredClipping16bit_SSE2_INTRIN( { EB_U32 rowCount, colCount; __m128i a0, a1; - + if (puWidth & 2) { EB_U16 *qtr = dst; rowCount = puHeight; @@ -2737,12 +2737,12 @@ void BiPredClipping16bit_SSE2_INTRIN( a1 = _mm_load_si128((__m128i *)list1Src); list0Src += 8; list1Src += 8; - + a0 = _mm_adds_epi16(a0, a1); a0 = _mm_adds_epi16(a0, _mm_set1_epi16(BI_AVG_OFFSET_10BIT)); a0 = _mm_srai_epi16(a0, BI_AVG_SHIFT_10BIT); a0 = _mm_max_epi16(a0, _mm_setzero_si128()); - + *(EB_U32 *)qtr = _mm_cvtsi128_si32(a0); a0 = _mm_srli_si128(a0, 4); qtr += dstStride; *(EB_U32 *)qtr = _mm_cvtsi128_si32(a0); a0 = _mm_srli_si128(a0, 4); qtr += dstStride; *(EB_U32 *)qtr = _mm_cvtsi128_si32(a0); a0 = _mm_srli_si128(a0, 4); qtr += dstStride; @@ -2750,14 +2750,14 @@ void BiPredClipping16bit_SSE2_INTRIN( rowCount -= 4; } while (rowCount != 0); - + puWidth -= 2; if (puWidth == 0) { return; - } + } dst += 2; } - + if (puWidth & 4) { EB_U16 *qtr = dst; rowCount = puHeight; @@ -2766,7 +2766,7 @@ void BiPredClipping16bit_SSE2_INTRIN( a1 = _mm_load_si128((__m128i *)list1Src); list0Src += 8; list1Src += 8; - + a0 = _mm_adds_epi16(a0, a1); a0 = _mm_adds_epi16(a0, _mm_set1_epi16(BI_AVG_OFFSET_10BIT)); a0 = _mm_srai_epi16(a0, BI_AVG_SHIFT_10BIT); @@ -2777,14 +2777,14 @@ void BiPredClipping16bit_SSE2_INTRIN( rowCount -= 2; } while (rowCount != 0); - + puWidth -= 4; if (puWidth == 0) { return; - } + } dst += 4; } - + colCount = puWidth; do { __m128i a2, a3; @@ -2812,11 +2812,11 @@ void BiPredClipping16bit_SSE2_INTRIN( _mm_storeu_si128((__m128i *)qtr, a0); _mm_storeu_si128((__m128i *)(qtr+dstStride), a2); qtr += 2*dstStride; - + rowCount -= 2; } while (rowCount != 0); - + colCount -= 8; dst += 8; } diff --git a/Source/Lib/ASM_SSE2/EbPictureOperators_SSE2.asm b/Source/Lib/ASM_SSE2/EbPictureOperators_SSE2.asm index 0b75519b1..9f2a8682b 100644 --- a/Source/Lib/ASM_SSE2/EbPictureOperators_SSE2.asm +++ b/Source/Lib/ASM_SSE2/EbPictureOperators_SSE2.asm @@ -1,7 +1,7 @@ -; +; ; Copyright(c) 2018 Intel Corporation ; SPDX - License - Identifier: BSD - 2 - Clause - Patent -; +; %include "x64inc.asm" %include "x64Macro.asm" @@ -520,7 +520,7 @@ Label_PictureAverageKernel_SSE2_WIDTH48: pavgb xmm0, xmm6 movdqu xmm6, [src1+16] pavgb xmm1, xmm6 - movdqu xmm6, [src1+32] + movdqu xmm6, [src1+32] pavgb xmm2, xmm6 movdqu xmm6, [src1+src1Stride] pavgb xmm3, xmm6 @@ -620,7 +620,6 @@ Label_PictureAverageKernel_SSE2_WIDTH16: ret ; ---------------------------------------------------------------------------------------- - cglobal Log2f_SSE2 + cglobal EbHevcLog2f_SSE2 bsr rax, r0 ret - diff --git a/Source/Lib/ASM_SSE2/EbTransforms_Intrinsic_SSE2.c b/Source/Lib/ASM_SSE2/EbTransforms_Intrinsic_SSE2.c index 3c25f4b41..ffd752c94 100644 --- a/Source/Lib/ASM_SSE2/EbTransforms_Intrinsic_SSE2.c +++ b/Source/Lib/ASM_SSE2/EbTransforms_Intrinsic_SSE2.c @@ -13,8 +13,8 @@ *****************************/ #define MACRO_TRANS_2MAC_NO_SAVE(XMM_1, XMM_2, XMM_3, XMM_4, XMM_OFFSET, OFFSET1, OFFSET2, SHIFT)\ - XMM_3 = _mm_load_si128((__m128i *)(TransformAsmConst + OFFSET1));\ - XMM_4 = _mm_load_si128((__m128i *)(TransformAsmConst + OFFSET2));\ + XMM_3 = _mm_load_si128((__m128i *)(EbHevcTransformAsmConst + OFFSET1));\ + XMM_4 = _mm_load_si128((__m128i *)(EbHevcTransformAsmConst + OFFSET2));\ XMM_3 = _mm_madd_epi16(XMM_3, XMM_1);\ XMM_4 = _mm_madd_epi16(XMM_4, XMM_2);\ XMM_3 = _mm_srai_epi32(_mm_add_epi32(XMM_4, _mm_add_epi32(XMM_3, XMM_OFFSET)), SHIFT);\ @@ -337,7 +337,7 @@ EB_ALIGN(16) const EB_S16 InvDstTransformAsmConst_SSE2[] = { // Coefficients for inverse 32-point transform -EB_EXTERN const EB_S16 coeff_tbl2[48 * 8] = +EB_EXTERN const EB_S16 EbHevccoeff_tbl2[48 * 8] = { 64, 89, 64, 75, 64, 50, 64, 18, 64, -18, 64, -50, 64, -75, 64, -89, 83, 75, 36, -18, -36, -89, -83, -50, -83, 50, -36, 89, 36, 18, 83, -75, @@ -370,7 +370,7 @@ EB_EXTERN const EB_S16 coeff_tbl2[48 * 8] = __attribute__((visibility("hidden"))) #endif #endif -EB_EXTERN const EB_S16 coeff_tbl[48 * 8] = +EB_EXTERN const EB_S16 EbHevccoeff_tbl[48 * 8] = { 64, 64, 89, 75, 83, 36, 75, -18, 64, -64, 50, -89, 36, -83, 18, -50, 64, 64, 50, 18, -36, -83, -89, -50, -64, 64, 18, 75, 83, -36, 75, -89, @@ -412,7 +412,7 @@ static void Transform16(short *src, int src_stride, short *dst, int dst_stride, int i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; for (i = 0; i < 16; i++) { @@ -478,7 +478,7 @@ static void InvTransform16( int i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl2; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl2; for (i = 0; i < 16; i++) { @@ -801,7 +801,7 @@ static void PfreqN4FirstTranspose32_SSE2( } } -void PfreqTranspose32Type1_SSE2( +void EbHevcPfreqTranspose32Type1_SSE2( EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, @@ -996,7 +996,7 @@ void Pfreq2DInvTransform32_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl2; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl2; for (i = 0; i < 32; i++) { @@ -1105,7 +1105,7 @@ void Pfreq1DInvTransform32_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl2; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl2; for (i = 0; i < 16; i++) { @@ -1213,7 +1213,7 @@ void PfreqEstimateInvTransform32x32_SSE2( EB_S16 *intermediate, EB_U32 addshift) { - PfreqTranspose32Type1_SSE2(src, src_stride, intermediate, 32); + EbHevcPfreqTranspose32Type1_SSE2(src, src_stride, intermediate, 32); Pfreq1DInvTransform32_SSE2(intermediate, 32, dst, dst_stride, 7); PfreqTranspose32Type2_SSE2(dst, dst_stride, intermediate, 32); Pfreq2DInvTransform32_SSE2(intermediate, 32, dst, dst_stride, 12 - addshift); @@ -1230,7 +1230,7 @@ static void InvTransform32_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl2; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl2; for (i = 0; i < 32; i++) { @@ -1420,7 +1420,7 @@ static void Transform32_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; for (i = 0; i < 32; i++) { @@ -1549,7 +1549,7 @@ static void Pfreq1DTransform32_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; for (i = 0; i < 32; i++) { @@ -1685,7 +1685,7 @@ static void Pfreq2DTransform32_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; for (i = 0; i < 16; i++) { @@ -1821,7 +1821,7 @@ static void PfreqN41DTransform32_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; for (i = 0; i < 32; i++) { @@ -1958,7 +1958,7 @@ static void PfreqN42DTransform32_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; for (i = 0; i < 8; i++) @@ -2129,7 +2129,7 @@ static void Pfreq1DTransform16_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; for (i = 0; i < 16; i++) { @@ -2183,7 +2183,7 @@ static void Pfreq2DTransform16_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; for (i = 0; i < 8; i++) { @@ -2315,7 +2315,7 @@ static void PfreqN42DTransform16_SSE2( EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; for (i = 0; i < 4; i++) @@ -2525,7 +2525,7 @@ void Transform4x4_SSE2_INTRIN( 36, -83, 36, -83, 36, -83, 36, -83, 83, -36, 83, -36, 83, -36, 83, -36 }; - EB_ALIGN(16) const EB_S16 * TransformAsmConst = transformIntrinConst_SSE2; + EB_ALIGN(16) const EB_S16 * EbHevcTransformAsmConst = transformIntrinConst_SSE2; __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm_offset, xmm_shift; xmm_shift = _mm_cvtsi32_si128(5 - bitIncrement); @@ -2612,7 +2612,7 @@ void DstTransform4x4_SSE2_INTRIN( __m128i xmm_temp; EB_U32 shift = bitIncrement + 1; - EB_ALIGN(16) const EB_S16 * TransformAsmConst = DstTransformAsmConst_SSE2; + EB_ALIGN(16) const EB_S16 * EbHevcTransformAsmConst = DstTransformAsmConst_SSE2; xmm_res0 = _mm_loadl_epi64((__m128i *)(residual)); xmm_res1 = _mm_loadl_epi64((__m128i *)(residual + srcStride)); diff --git a/Source/Lib/ASM_SSE2/x64RegisterUtil.asm b/Source/Lib/ASM_SSE2/x64RegisterUtil.asm index 295fb81c1..663418699 100644 --- a/Source/Lib/ASM_SSE2/x64RegisterUtil.asm +++ b/Source/Lib/ASM_SSE2/x64RegisterUtil.asm @@ -1,7 +1,7 @@ -; +; ; Copyright(c) 2018 Intel Corporation ; SPDX - License - Identifier: BSD - 2 - Clause - Patent -; +; %include "x64inc.asm" @@ -18,16 +18,16 @@ section .text ; threads in cooperative operating systems, unless it is certain that more MMX ; instructions will be executed before any x87 FPU code. -; So if RunEmms() is called according to the above cases, +; So if EbHevcRunEmms() is called according to the above cases, ; then the "emms" instruction in all other assembly functions can be removed. -cglobal RunEmms +cglobal EbHevcRunEmms emms ret ; ---------------------------------------------------------------------------------------- -cglobal SaveRegister +cglobal EbHevcSaveRegister %ifdef WIN64 movdqa [r0], xmm6 movdqa [r0+0x10], xmm7 @@ -44,7 +44,7 @@ cglobal SaveRegister ; ---------------------------------------------------------------------------------------- -cglobal RestoreRegister +cglobal EbHevcRestoreRegister %ifdef WIN64 movdqa xmm6, [r0] movdqa xmm7, [r0+0x10] diff --git a/Source/Lib/ASM_SSSE3/EbAvcStyleMcp_Intrinsic_SSSE3.c b/Source/Lib/ASM_SSSE3/EbAvcStyleMcp_Intrinsic_SSSE3.c index f4970c085..3c9775379 100644 --- a/Source/Lib/ASM_SSSE3/EbAvcStyleMcp_Intrinsic_SSSE3.c +++ b/Source/Lib/ASM_SSSE3/EbAvcStyleMcp_Intrinsic_SSSE3.c @@ -11,7 +11,7 @@ #include "tmmintrin.h" -EB_EXTERN EB_ALIGN(16) const EB_S8 AvcStyleLumaIFCoeff8_SSSE3[]= { +EB_EXTERN EB_ALIGN(16) const EB_S8 EbHevcAvcStyleLumaIFCoeff8_SSSE3[]= { -1, 25, -1, 25, -1, 25, -1, 25, -1, 25, -1, 25, -1, 25, -1, 25, 9, -1, 9, -1, 9, -1, 9, -1, 9, -1, 9, -1, 9, -1, 9, -1, -2, 18, -2, 18, -2, 18, -2, 18, -2, 18, -2, 18, -2, 18, -2, 18, @@ -47,8 +47,8 @@ void AvcStyleLumaInterpolationFilterHorizontal_SSSE3_INTRIN( fracPos <<= 5; IFOffset = _mm_set1_epi16(0x0010); - IFCoeff_1_0 = _mm_load_si128((__m128i *)(AvcStyleLumaIFCoeff8_SSSE3 + fracPos - 32)); - IFCoeff_3_2 = _mm_load_si128((__m128i *)(AvcStyleLumaIFCoeff8_SSSE3 + fracPos - 16)); + IFCoeff_1_0 = _mm_load_si128((__m128i *)(EbHevcAvcStyleLumaIFCoeff8_SSSE3 + fracPos - 32)); + IFCoeff_3_2 = _mm_load_si128((__m128i *)(EbHevcAvcStyleLumaIFCoeff8_SSSE3 + fracPos - 16)); if (!(puWidth & 15)) { // 16x __m128i ref0, ref1, ref2, ref3, ref01_lo, ref01_hi, ref23_lo, ref23_hi, sum_lo, sum_hi; @@ -117,12 +117,12 @@ void AvcStyleLumaInterpolationFilterVertical_SSSE3_INTRIN( fracPos <<= 5; refPic -= srcStride; IFOffset = _mm_set1_epi16(0x0010); - IFCoeff_1_0 = _mm_load_si128((__m128i *)(AvcStyleLumaIFCoeff8_SSSE3 + fracPos - 32)); - IFCoeff_3_2 = _mm_load_si128((__m128i *)(AvcStyleLumaIFCoeff8_SSSE3 + fracPos - 16)); + IFCoeff_1_0 = _mm_load_si128((__m128i *)(EbHevcAvcStyleLumaIFCoeff8_SSSE3 + fracPos - 32)); + IFCoeff_3_2 = _mm_load_si128((__m128i *)(EbHevcAvcStyleLumaIFCoeff8_SSSE3 + fracPos - 16)); if (!(puWidth & 15)) { //16x __m128i sum_lo, sum_hi, ref0, refs, ref2s, ref3s; - + for (width_cnt = 0; width_cnt < puWidth; width_cnt += 16) { refPicTemp = refPic; @@ -133,7 +133,7 @@ void AvcStyleLumaInterpolationFilterVertical_SSSE3_INTRIN( refs = _mm_loadu_si128((__m128i *)(refPicTemp + srcStride)); ref2s = _mm_loadu_si128((__m128i *)(refPicTemp + 2 * srcStride)); ref3s = _mm_loadu_si128((__m128i *)(refPicTemp + 3 * srcStride)); - + sum_lo = _mm_add_epi16(_mm_maddubs_epi16(_mm_unpacklo_epi8(ref0, refs), IFCoeff_1_0), _mm_maddubs_epi16(_mm_unpacklo_epi8(ref2s, ref3s), IFCoeff_3_2)); @@ -155,21 +155,21 @@ void AvcStyleLumaInterpolationFilterVertical_SSSE3_INTRIN( __m128i sum, sum01, sum23; for (width_cnt = 0; width_cnt < puWidth; width_cnt += 8) { - + refPicTemp = refPic; dstTemp = dst; - + for (height_cnt = 0; height_cnt < puHeight; ++height_cnt) { sum01 = _mm_maddubs_epi16(_mm_unpacklo_epi8(_mm_loadl_epi64((__m128i *)(refPicTemp)), _mm_loadl_epi64((__m128i *)(refPicTemp + srcStride))), IFCoeff_1_0); sum23 = _mm_maddubs_epi16(_mm_unpacklo_epi8(_mm_loadl_epi64((__m128i *)(refPicTemp + 2 * srcStride)), _mm_loadl_epi64((__m128i *)(refPicTemp + 3 * srcStride))), IFCoeff_3_2); - + sum = _mm_srai_epi16(_mm_add_epi16(_mm_add_epi16(sum01, sum23), IFOffset), IFShift); sum_clip_U8 = _mm_packus_epi16(sum, sum); _mm_storel_epi64((__m128i *)(dstTemp), sum_clip_U8); - + dstTemp += dstStride; refPicTemp += srcStrideSkip; } diff --git a/Source/Lib/ASM_SSSE3/EbMcp_Intrinsic_SSSE3.c b/Source/Lib/ASM_SSSE3/EbMcp_Intrinsic_SSSE3.c index 26c6a4171..c697a1cbc 100644 --- a/Source/Lib/ASM_SSSE3/EbMcp_Intrinsic_SSSE3.c +++ b/Source/Lib/ASM_SSSE3/EbMcp_Intrinsic_SSSE3.c @@ -23,7 +23,7 @@ __attribute__((visibility("hidden"))) #endif #endif -const EB_S16 lumaFilterCoeff[4][8] = +const EB_S16 EbHevclumaFilterCoeff[4][8] = { { 0, 0, 0, 64, 0, 0, 0, 0}, {-1, 4,-10, 58, 17, -5, 1, 0}, @@ -36,7 +36,7 @@ const EB_S16 lumaFilterCoeff[4][8] = __attribute__((visibility("hidden"))) #endif #endif -const EB_S16 lumaFilterCoeff7[4][8] = +const EB_S16 EbHevclumaFilterCoeff7[4][8] = { { 0, 0, 0, 64, 0, 0, 0, 0}, {-1, 4,-10, 58, 17, -5, 1, 0}, @@ -49,7 +49,7 @@ const EB_S16 lumaFilterCoeff7[4][8] = __attribute__((visibility("hidden"))) #endif #endif -const EB_S16 chromaFilterCoeff[8][4] = +const EB_S16 EbHevcchromaFilterCoeff[8][4] = { { 0, 64, 0, 0}, {-2, 58, 10, -2}, @@ -231,7 +231,7 @@ void LumaInterpolationCopy_SSSE3( PictureCopyKernel_SSSE3(refPic, srcStride, dst, dstStride, puWidth, puHeight, 1); } -void LumaInterpolationFilterTwoDInRaw7_SSSE3(EB_S16 *firstPassIFDst, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_U32 fracPosy) +void EbHevcLumaInterpolationFilterTwoDInRaw7_SSSE3(EB_S16 *firstPassIFDst, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_U32 fracPosy) { EB_S32 rowCount, colCount; __m128i c0, c1, c2; @@ -241,7 +241,7 @@ void LumaInterpolationFilterTwoDInRaw7_SSSE3(EB_S16 *firstPassIFDst, EB_BYTE dst EB_BYTE qtr; - c0 = _mm_loadu_si128((__m128i *)lumaFilterCoeff7[fracPosy]); + c0 = _mm_loadu_si128((__m128i *)EbHevclumaFilterCoeff7[fracPosy]); c2 = _mm_shuffle_epi32(c0, 0xaa); c1 = _mm_shuffle_epi32(c0, 0x55); c0 = _mm_shuffle_epi32(c0, 0x00); @@ -350,13 +350,13 @@ void LumaInterpolationFilterTwoDInRaw7_SSSE3(EB_S16 *firstPassIFDst, EB_BYTE dst while (colCount > 0); } -void LumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(EB_S16 *firstPassIFDst, EB_S16 *dst, EB_U32 puWidth, EB_U32 puHeight, EB_U32 fracPosy) +void EbHevcLumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(EB_S16 *firstPassIFDst, EB_S16 *dst, EB_U32 puWidth, EB_U32 puHeight, EB_U32 fracPosy) { EB_S32 rowCount, colCount; __m128i a0, a1, a2, a3, a4, a5, a6; __m128i c0, c1, c2; - c0 = _mm_loadu_si128((__m128i *)lumaFilterCoeff7[fracPosy]); + c0 = _mm_loadu_si128((__m128i *)EbHevclumaFilterCoeff7[fracPosy]); c2 = _mm_shuffle_epi32(c0, 0xaa); c1 = _mm_shuffle_epi32(c0, 0x55); c0 = _mm_shuffle_epi32(c0, 0x00); @@ -455,7 +455,7 @@ void LumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(EB_S16 *firstPassIFDst, EB_S1 while (colCount > 0); } -void LumaInterpolationFilterTwoDInRawM_SSSE3(EB_S16 *firstPassIFDst, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight) +void EbHevcLumaInterpolationFilterTwoDInRawM_SSSE3(EB_S16 *firstPassIFDst, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight) { EB_S32 rowCount, colCount; @@ -465,7 +465,7 @@ void LumaInterpolationFilterTwoDInRawM_SSSE3(EB_S16 *firstPassIFDst, EB_BYTE dst EB_BYTE qtr; - c0 = _mm_loadu_si128((__m128i *)lumaFilterCoeff7[2]); + c0 = _mm_loadu_si128((__m128i *)EbHevclumaFilterCoeff7[2]); c1 = _mm_shuffle_epi32(c0, 0x55); c0 = _mm_shuffle_epi32(c0, 0x00); @@ -566,13 +566,13 @@ void LumaInterpolationFilterTwoDInRawM_SSSE3(EB_S16 *firstPassIFDst, EB_BYTE dst while (colCount > 0); } -void LumaInterpolationFilterTwoDInRawOutRawM_SSSE3(EB_S16 *firstPassIFDst, EB_S16 *dst, EB_U32 puWidth, EB_U32 puHeight) +void EbHevcLumaInterpolationFilterTwoDInRawOutRawM_SSSE3(EB_S16 *firstPassIFDst, EB_S16 *dst, EB_U32 puWidth, EB_U32 puHeight) { EB_S32 rowCount, colCount; __m128i a0, a1, a2, a3, a4, a5, a6, a7; __m128i c0, c1; - c0 = _mm_loadu_si128((__m128i *)lumaFilterCoeff7[2]); + c0 = _mm_loadu_si128((__m128i *)EbHevclumaFilterCoeff7[2]); c1 = _mm_shuffle_epi32(c0, 0x55); c0 = _mm_shuffle_epi32(c0, 0x00); @@ -662,7 +662,7 @@ void LumaInterpolationFilterTwoDInRawOutRawM_SSSE3(EB_S16 *firstPassIFDst, EB_S1 while (colCount > 0); } -void PictureCopyKernelOutRaw_SSSE3( +void EbHevcPictureCopyKernelOutRaw_SSSE3( EB_BYTE refPic, EB_U32 srcStride, EB_S16 *dst, @@ -776,7 +776,7 @@ void ChromaInterpolationCopyOutRaw_SSSE3( (void)firstPassIFDst; (void)fracPosx; (void)fracPosy; - PictureCopyKernelOutRaw_SSSE3(refPic, srcStride, dst, puWidth, puHeight, 0); + EbHevcPictureCopyKernelOutRaw_SSSE3(refPic, srcStride, dst, puWidth, puHeight, 0); } void ChromaInterpolationFilterTwoDInRaw_SSSE3(EB_S16 *firstPassIFDst, EB_BYTE dst, EB_U32 dstStride, EB_U32 puWidth, EB_U32 puHeight, EB_U32 fracPosy) { @@ -787,7 +787,7 @@ void ChromaInterpolationFilterTwoDInRaw_SSSE3(EB_S16 *firstPassIFDst, EB_BYTE ds __m128i a0,a1,a2,a3,b0, b1, b2, b3; __m128i sum0, sum1; - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeff[fracPosy]); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeff[fracPosy]); c1 = _mm_shuffle_epi32(c0, 0x55); c0 = _mm_shuffle_epi32(c0, 0); offset = _mm_set1_epi32(1 << 11); @@ -955,7 +955,7 @@ void ChromaInterpolationFilterOneDHorizontal_SSSE3( PrefetchBlock(refPic, srcStride, puWidth+8, puHeight); - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeff[fracPosx]); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeff[fracPosx]); c0 = _mm_packs_epi16(c0, c0); c0 = _mm_unpacklo_epi16(c0, c0); c2 = _mm_shuffle_epi32(c0, 0x55); @@ -1099,7 +1099,7 @@ void ChromaInterpolationFilterOneDOutRawHorizontal_SSSE3( refPic--; PrefetchBlock(refPic, srcStride, puWidth+8, puHeight); - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeff[fracPosx]); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeff[fracPosx]); c0 = _mm_packs_epi16(c0, c0); c0 = _mm_unpacklo_epi16(c0, c0); c2 = _mm_shuffle_epi32(c0, 0x55); @@ -1228,7 +1228,7 @@ void ChromaInterpolationFilterOneDVertical_SSSE3( PrefetchBlock(refPic, srcStride, puWidth, puHeight+3); - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeff[fracPosy]); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeff[fracPosy]); c0 = _mm_packs_epi16(c0, c0); c0 = _mm_unpacklo_epi16(c0, c0); c2 = _mm_shuffle_epi32(c0, 0x55); @@ -1381,7 +1381,7 @@ void ChromaInterpolationFilterOneDOutRawVertical_SSSE3( refPic -= srcStride; PrefetchBlock(refPic, srcStride, puWidth, puHeight+3); - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeff[fracPosy]); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeff[fracPosy]); c0 = _mm_packs_epi16(c0, c0); c0 = _mm_unpacklo_epi16(c0, c0); c2 = _mm_shuffle_epi32(c0, 0x55); @@ -1511,7 +1511,7 @@ void ChromaInterpolationFilterTwoDInRawOutRaw_SSSE3(EB_S16 *firstPassIFDst, EB_S EB_S32 rowCount, colCount; __m128i c0, c1; // coeffs - c0 = _mm_loadl_epi64((__m128i *)chromaFilterCoeff[fracPosy]); + c0 = _mm_loadl_epi64((__m128i *)EbHevcchromaFilterCoeff[fracPosy]); c1 = _mm_shuffle_epi32(c0, 0x55); c0 = _mm_shuffle_epi32(c0, 0); @@ -1671,7 +1671,7 @@ void LumaInterpolationFilterOneDHorizontal_SSSE3( PrefetchBlock(refPic, srcStride, (puWidth == 4) ? 16 : puWidth+8, (puWidth == 4) ? ((puHeight+1)&~1) : puHeight); - c0 = _mm_loadu_si128((__m128i *)lumaFilterCoeff[fracPosx]); + c0 = _mm_loadu_si128((__m128i *)EbHevclumaFilterCoeff[fracPosx]); c0 = _mm_packs_epi16(c0, c0); c0 = _mm_unpacklo_epi16(c0, c0); c3 = _mm_shuffle_epi32(c0, 0xff); @@ -1769,7 +1769,7 @@ void LumaInterpolationFilterOneDOutRawHorizontal_SSSE3( PrefetchBlock(refPic, srcStride, (puWidth == 4) ? 16 : puWidth+8, (puWidth == 4) ? ((puHeight+1)&~1) : puHeight); - c0 = _mm_loadu_si128((__m128i *)lumaFilterCoeff[fracPosx]); + c0 = _mm_loadu_si128((__m128i *)EbHevclumaFilterCoeff[fracPosx]); c0 = _mm_packs_epi16(c0, c0); c0 = _mm_unpacklo_epi16(c0, c0); c3 = _mm_shuffle_epi32(c0, 0xff); @@ -1859,7 +1859,7 @@ void LumaInterpolationFilterOneDOutRawHorizontalOut_SSSE3( PrefetchBlock(refPic, srcStride, (puWidth == 4) ? 16 : puWidth+8, (puWidth == 4) ? ((puHeight+1)&~1) : puHeight); - c0 = _mm_loadu_si128((__m128i *)lumaFilterCoeff[fracPosx]); + c0 = _mm_loadu_si128((__m128i *)EbHevclumaFilterCoeff[fracPosx]); c0 = _mm_packs_epi16(c0, c0); c0 = _mm_unpacklo_epi16(c0, c0); c3 = _mm_shuffle_epi32(c0, 0xff); @@ -1950,7 +1950,7 @@ void LumaInterpolationFilterOneDVertical_SSSE3( PrefetchBlock(refPic, srcStride, puWidth, puHeight+7); - c0 = _mm_loadu_si128((__m128i *)lumaFilterCoeff[fracPosx]); + c0 = _mm_loadu_si128((__m128i *)EbHevclumaFilterCoeff[fracPosx]); c0 = _mm_packs_epi16(c0, c0); // Convert 16-bit coefficients to 8 bits c0 = _mm_unpacklo_epi16(c0, c0); c3 = _mm_shuffle_epi32(c0, 0xff); @@ -2099,7 +2099,7 @@ void LumaInterpolationFilterOneDOutRawVertical_SSSE3( PrefetchBlock(refPic, srcStride, puWidth, puHeight+7); - c0 = _mm_loadu_si128((__m128i *)lumaFilterCoeff[fracPosx]); + c0 = _mm_loadu_si128((__m128i *)EbHevclumaFilterCoeff[fracPosx]); c0 = _mm_packs_epi16(c0, c0); // Convert 16-bit coefficients to 8 bits c0 = _mm_unpacklo_epi16(c0, c0); c3 = _mm_shuffle_epi32(c0, 0xff); @@ -2314,7 +2314,7 @@ void LumaInterpolationFilterPose_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-3*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+6, 1); - LumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 1); + EbHevcLumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 1); } @@ -2330,7 +2330,7 @@ void LumaInterpolationFilterPosf_SSSE3( EB_U32 puHeight1 = puHeight + 6; EB_BYTE refPic1 = refPic - 3 * srcStride; LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic1, srcStride, firstPassIFDst, puWidth, puHeight1, 2); - LumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 1); + EbHevcLumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 1); } void LumaInterpolationFilterPosg_SSSE3( @@ -2343,7 +2343,7 @@ void LumaInterpolationFilterPosg_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-3*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+6, 3); - LumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 1); + EbHevcLumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 1); } void LumaInterpolationFilterPosi_SSSE3( @@ -2356,7 +2356,7 @@ void LumaInterpolationFilterPosi_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-3*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+7, 1); - LumaInterpolationFilterTwoDInRawM_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight); + EbHevcLumaInterpolationFilterTwoDInRawM_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight); } @@ -2371,7 +2371,7 @@ void LumaInterpolationFilterPosj_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-3*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+7, 2); - LumaInterpolationFilterTwoDInRawM_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight); + EbHevcLumaInterpolationFilterTwoDInRawM_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight); } void LumaInterpolationFilterPosk_SSSE3( @@ -2384,7 +2384,7 @@ void LumaInterpolationFilterPosk_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-3*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+7, 3); - LumaInterpolationFilterTwoDInRawM_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight); + EbHevcLumaInterpolationFilterTwoDInRawM_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight); } void LumaInterpolationFilterPosp_SSSE3( @@ -2397,7 +2397,7 @@ void LumaInterpolationFilterPosp_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-2*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+6, 1); - LumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 3); + EbHevcLumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 3); } void LumaInterpolationFilterPosq_SSSE3( @@ -2412,7 +2412,7 @@ void LumaInterpolationFilterPosq_SSSE3( EB_U32 puHeight1 = puHeight + 6; EB_BYTE refPic1 = refPic - 2 * srcStride; LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic1, srcStride, firstPassIFDst, puWidth, puHeight1, 2); - LumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 3); + EbHevcLumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 3); } void LumaInterpolationFilterPosr_SSSE3( @@ -2425,7 +2425,7 @@ void LumaInterpolationFilterPosr_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-2*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+6, 3); - LumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 3); + EbHevcLumaInterpolationFilterTwoDInRaw7_SSSE3(firstPassIFDst, dst, dstStride, puWidth, puHeight, 3); } @@ -2438,7 +2438,7 @@ void LumaInterpolationCopyOutRaw_SSSE3( EB_S16 *firstPassIFDst) { (void)firstPassIFDst; - PictureCopyKernelOutRaw_SSSE3(refPic, srcStride, dst, puWidth, puHeight, 128*64); + EbHevcPictureCopyKernelOutRaw_SSSE3(refPic, srcStride, dst, puWidth, puHeight, 128*64); } @@ -2822,7 +2822,7 @@ void LumaInterpolationFilterPoseOutRaw_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-3*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+6, 1); - LumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 1); + EbHevcLumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 1); } void LumaInterpolationFilterPosfOutRaw_SSSE3( @@ -2836,7 +2836,7 @@ void LumaInterpolationFilterPosfOutRaw_SSSE3( EB_U32 puHeight1 = puHeight + 6; EB_BYTE refPic1 = refPic - 3 * srcStride; LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic1, srcStride, firstPassIFDst, puWidth, puHeight1, 2); - LumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 1); + EbHevcLumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 1); } void LumaInterpolationFilterPosgOutRaw_SSSE3( @@ -2848,7 +2848,7 @@ void LumaInterpolationFilterPosgOutRaw_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-3*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+6, 3); - LumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 1); + EbHevcLumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 1); } void LumaInterpolationFilterPosiOutRaw_SSSE3( @@ -2860,7 +2860,7 @@ void LumaInterpolationFilterPosiOutRaw_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-3*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+7, 1); - LumaInterpolationFilterTwoDInRawOutRawM_SSSE3(firstPassIFDst, dst, puWidth, puHeight); + EbHevcLumaInterpolationFilterTwoDInRawOutRawM_SSSE3(firstPassIFDst, dst, puWidth, puHeight); } void LumaInterpolationFilterPosjOutRaw_SSSE3( @@ -2872,7 +2872,7 @@ void LumaInterpolationFilterPosjOutRaw_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-3*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+7, 2); - LumaInterpolationFilterTwoDInRawOutRawM_SSSE3(firstPassIFDst, dst, puWidth, puHeight); + EbHevcLumaInterpolationFilterTwoDInRawOutRawM_SSSE3(firstPassIFDst, dst, puWidth, puHeight); } void LumaInterpolationFilterPoskOutRaw_SSSE3( @@ -2884,7 +2884,7 @@ void LumaInterpolationFilterPoskOutRaw_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-3*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+7, 3); - LumaInterpolationFilterTwoDInRawOutRawM_SSSE3(firstPassIFDst, dst, puWidth, puHeight); + EbHevcLumaInterpolationFilterTwoDInRawOutRawM_SSSE3(firstPassIFDst, dst, puWidth, puHeight); } void LumaInterpolationFilterPospOutRaw_SSSE3( @@ -2896,7 +2896,7 @@ void LumaInterpolationFilterPospOutRaw_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-2*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+6, 1); - LumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 3); + EbHevcLumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 3); } void LumaInterpolationFilterPosqOutRaw_SSSE3( @@ -2910,7 +2910,7 @@ void LumaInterpolationFilterPosqOutRaw_SSSE3( EB_U32 puHeight1 = puHeight + 6; EB_BYTE refPic1 = refPic - 2 * srcStride; LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic1, srcStride, firstPassIFDst, puWidth, puHeight1, 2); - LumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 3); + EbHevcLumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 3); } void LumaInterpolationFilterPosrOutRaw_SSSE3( @@ -2922,7 +2922,5 @@ void LumaInterpolationFilterPosrOutRaw_SSSE3( EB_S16 *firstPassIFDst) { LumaInterpolationFilterOneDOutRawHorizontal_SSSE3(refPic-2*srcStride, srcStride, firstPassIFDst, puWidth, puHeight+6, 3); - LumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 3); + EbHevcLumaInterpolationFilterTwoDInRawOutRaw7_SSSE3(firstPassIFDst, dst, puWidth, puHeight, 3); } - - diff --git a/Source/Lib/ASM_SSSE3/EbTransforms_Intrinsic_SSSE3.c b/Source/Lib/ASM_SSSE3/EbTransforms_Intrinsic_SSSE3.c index bebd0fa26..ab01e153f 100644 --- a/Source/Lib/ASM_SSSE3/EbTransforms_Intrinsic_SSSE3.c +++ b/Source/Lib/ASM_SSSE3/EbTransforms_Intrinsic_SSSE3.c @@ -16,11 +16,11 @@ #ifdef __cplusplus -extern "C" const EB_S16 coeff_tbl[48*8]; -extern "C" const EB_S16 coeff_tbl2[48*8]; +extern "C" const EB_S16 EbHevccoeff_tbl[48*8]; +extern "C" const EB_S16 EbHevccoeff_tbl2[48*8]; #else -extern const EB_S16 coeff_tbl[48*8]; -extern const EB_S16 coeff_tbl2[48*8]; +extern const EB_S16 EbHevccoeff_tbl[48*8]; +extern const EB_S16 EbHevccoeff_tbl2[48*8]; #endif @@ -49,7 +49,7 @@ static void transpose16(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ { __m128i a0, a1, a2, a3, a4, a5, a6, a7; __m128i b0, b1, b2, b3, b4, b5, b6, b7; - + a0 = _mm_loadu_si128((const __m128i *)(src + (8*i+0)*src_stride + 8*j)); a1 = _mm_loadu_si128((const __m128i *)(src + (8*i+1)*src_stride + 8*j)); a2 = _mm_loadu_si128((const __m128i *)(src + (8*i+2)*src_stride + 8*j)); @@ -58,7 +58,7 @@ static void transpose16(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ a5 = _mm_loadu_si128((const __m128i *)(src + (8*i+5)*src_stride + 8*j)); a6 = _mm_loadu_si128((const __m128i *)(src + (8*i+6)*src_stride + 8*j)); a7 = _mm_loadu_si128((const __m128i *)(src + (8*i+7)*src_stride + 8*j)); - + b0 = _mm_unpacklo_epi16(a0, a4); b1 = _mm_unpacklo_epi16(a1, a5); b2 = _mm_unpacklo_epi16(a2, a6); @@ -67,7 +67,7 @@ static void transpose16(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ b5 = _mm_unpackhi_epi16(a1, a5); b6 = _mm_unpackhi_epi16(a2, a6); b7 = _mm_unpackhi_epi16(a3, a7); - + a0 = _mm_unpacklo_epi16(b0, b2); a1 = _mm_unpacklo_epi16(b1, b3); a2 = _mm_unpackhi_epi16(b0, b2); @@ -76,7 +76,7 @@ static void transpose16(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ a5 = _mm_unpacklo_epi16(b5, b7); a6 = _mm_unpackhi_epi16(b4, b6); a7 = _mm_unpackhi_epi16(b5, b7); - + b0 = _mm_unpacklo_epi16(a0, a1); b1 = _mm_unpackhi_epi16(a0, a1); b2 = _mm_unpacklo_epi16(a2, a3); @@ -85,7 +85,7 @@ static void transpose16(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ b5 = _mm_unpackhi_epi16(a4, a5); b6 = _mm_unpacklo_epi16(a6, a7); b7 = _mm_unpackhi_epi16(a6, a7); - + _mm_storeu_si128((__m128i *)(dst + (8*j+0)*dst_stride + 8*i), b0); _mm_storeu_si128((__m128i *)(dst + (8*j+1)*dst_stride + 8*i), b1); _mm_storeu_si128((__m128i *)(dst + (8*j+2)*dst_stride + 8*i), b2); @@ -102,14 +102,14 @@ static void transpose16Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U { EB_U32 j; EB_U32 numRows = 2 - (pattern & 1); - + do { for (j = 0; j < 2; j++) { __m128i a0, a1, a2, a3, a4, a5, a6, a7; __m128i b0, b1, b2, b3, b4, b5, b6, b7; - + a0 = _mm_loadu_si128((const __m128i *)(src + (0)*src_stride + 8*j)); a1 = _mm_loadu_si128((const __m128i *)(src + (1)*src_stride + 8*j)); a2 = _mm_loadu_si128((const __m128i *)(src + (2)*src_stride + 8*j)); @@ -118,7 +118,7 @@ static void transpose16Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U a5 = _mm_loadu_si128((const __m128i *)(src + (5)*src_stride + 8*j)); a6 = _mm_loadu_si128((const __m128i *)(src + (6)*src_stride + 8*j)); a7 = _mm_loadu_si128((const __m128i *)(src + (7)*src_stride + 8*j)); - + b0 = _mm_unpacklo_epi16(a0, a4); b1 = _mm_unpacklo_epi16(a1, a5); b2 = _mm_unpacklo_epi16(a2, a6); @@ -127,7 +127,7 @@ static void transpose16Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U b5 = _mm_unpackhi_epi16(a1, a5); b6 = _mm_unpackhi_epi16(a2, a6); b7 = _mm_unpackhi_epi16(a3, a7); - + a0 = _mm_unpacklo_epi16(b0, b2); a1 = _mm_unpacklo_epi16(b1, b3); a2 = _mm_unpackhi_epi16(b0, b2); @@ -136,7 +136,7 @@ static void transpose16Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U a5 = _mm_unpacklo_epi16(b5, b7); a6 = _mm_unpackhi_epi16(b4, b6); a7 = _mm_unpackhi_epi16(b5, b7); - + b0 = _mm_unpacklo_epi16(a0, a1); b1 = _mm_unpackhi_epi16(a0, a1); b2 = _mm_unpacklo_epi16(a2, a3); @@ -145,7 +145,7 @@ static void transpose16Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U b5 = _mm_unpackhi_epi16(a4, a5); b6 = _mm_unpacklo_epi16(a6, a7); b7 = _mm_unpackhi_epi16(a6, a7); - + _mm_storeu_si128((__m128i *)(dst + (8*j+0)*dst_stride), b0); _mm_storeu_si128((__m128i *)(dst + (8*j+1)*dst_stride), b1); _mm_storeu_si128((__m128i *)(dst + (8*j+2)*dst_stride), b2); @@ -155,7 +155,7 @@ static void transpose16Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U _mm_storeu_si128((__m128i *)(dst + (8*j+6)*dst_stride), b6); _mm_storeu_si128((__m128i *)(dst + (8*j+7)*dst_stride), b7); } - + src += 8*src_stride; dst += 8; } @@ -175,7 +175,7 @@ static EB_U32 transpose16Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB __m128i a0, a1, a2, a3, a4, a5, a6, a7; __m128i b0, b1, b2, b3, b4, b5, b6, b7; __m128i c0; - + a0 = _mm_loadu_si128((const __m128i *)(src + (8*i+0)*src_stride + 8*j)); a1 = _mm_loadu_si128((const __m128i *)(src + (8*i+1)*src_stride + 8*j)); a2 = _mm_loadu_si128((const __m128i *)(src + (8*i+2)*src_stride + 8*j)); @@ -184,7 +184,7 @@ static EB_U32 transpose16Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB a5 = _mm_loadu_si128((const __m128i *)(src + (8*i+5)*src_stride + 8*j)); a6 = _mm_loadu_si128((const __m128i *)(src + (8*i+6)*src_stride + 8*j)); a7 = _mm_loadu_si128((const __m128i *)(src + (8*i+7)*src_stride + 8*j)); - + c0 = _mm_or_si128(a0, a4); c0 = _mm_or_si128(c0, a1); c0 = _mm_or_si128(c0, a5); @@ -192,11 +192,11 @@ static EB_U32 transpose16Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB c0 = _mm_or_si128(c0, a6); c0 = _mm_or_si128(c0, a3); c0 = _mm_or_si128(c0, a7); - + c0 = _mm_cmpeq_epi8(c0, _mm_setzero_si128()); - + zeroPattern = 2 * zeroPattern + ((_mm_movemask_epi8(c0)+1) >> 16); // add a '1' bit if all zeros - + b0 = _mm_unpacklo_epi16(a0, a4); b1 = _mm_unpacklo_epi16(a1, a5); b2 = _mm_unpacklo_epi16(a2, a6); @@ -205,7 +205,7 @@ static EB_U32 transpose16Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB b5 = _mm_unpackhi_epi16(a1, a5); b6 = _mm_unpackhi_epi16(a2, a6); b7 = _mm_unpackhi_epi16(a3, a7); - + a0 = _mm_unpacklo_epi16(b0, b2); a1 = _mm_unpacklo_epi16(b1, b3); a2 = _mm_unpackhi_epi16(b0, b2); @@ -214,7 +214,7 @@ static EB_U32 transpose16Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB a5 = _mm_unpacklo_epi16(b5, b7); a6 = _mm_unpackhi_epi16(b4, b6); a7 = _mm_unpackhi_epi16(b5, b7); - + b0 = _mm_unpacklo_epi16(a0, a1); b1 = _mm_unpackhi_epi16(a0, a1); b2 = _mm_unpacklo_epi16(a2, a3); @@ -223,7 +223,7 @@ static EB_U32 transpose16Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB b5 = _mm_unpackhi_epi16(a4, a5); b6 = _mm_unpacklo_epi16(a6, a7); b7 = _mm_unpackhi_epi16(a6, a7); - + _mm_storeu_si128((__m128i *)(dst + (8*j+0)*dst_stride + 8*i), b0); _mm_storeu_si128((__m128i *)(dst + (8*j+1)*dst_stride + 8*i), b1); _mm_storeu_si128((__m128i *)(dst + (8*j+2)*dst_stride + 8*i), b2); @@ -234,7 +234,7 @@ static EB_U32 transpose16Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB _mm_storeu_si128((__m128i *)(dst + (8*j+7)*dst_stride + 8*i), b7); } } - + if ((zeroPattern & 3) == 3) result |= 1; // can do half transforms 1st pass if ((zeroPattern & 5) == 5) result |= 2; // can do half rows 1st pass, and half transforms 2nd pass return result; @@ -246,56 +246,56 @@ static void transform16(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ EB_U32 i; __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; - + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; + for (i = 0; i < 16; i++) { __m128i x0, x1; __m128i y0, y1; __m128i a0, a1, a2, a3; __m128i b0, b1, b2, b3; - + y0 = _mm_loadu_si128((const __m128i *)(src+i*src_stride+0x00)); y1 = _mm_loadu_si128((const __m128i *)(src+i*src_stride+0x08)); - - + + // 16-point butterfly y1 = reverse_epi16(y1); - + x0 = _mm_add_epi16(y0, y1); x1 = _mm_sub_epi16(y0, y1); - + a0 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[0]); a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[2])); a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[4])); a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[6])); - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[3])); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[5])); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[7])); - + a2 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[8]); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[10])); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[12])); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[14])); - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[9]); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[11])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[13])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[15])); - + b0 = _mm_sra_epi32(_mm_add_epi32(a0, o0), s0); b1 = _mm_sra_epi32(_mm_add_epi32(a1, o0), s0); b2 = _mm_sra_epi32(_mm_add_epi32(a2, o0), s0); b3 = _mm_sra_epi32(_mm_add_epi32(a3, o0), s0); - + x0 = _mm_packs_epi32(b0, b1); x1 = _mm_packs_epi32(b2, b3); - + y0 = _mm_unpacklo_epi16(x0, x1); y1 = _mm_unpackhi_epi16(x0, x1); - + _mm_storeu_si128((__m128i *)(dst+i*dst_stride+0x00), y0); _mm_storeu_si128((__m128i *)(dst+i*dst_stride+0x08), y1); } @@ -306,8 +306,8 @@ static void invTransform16(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d { __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl2; - + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl2; + do { __m128i x0, x1; @@ -315,7 +315,7 @@ static void invTransform16(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d __m128i b0, b1, b2, b3; x0 = _mm_loadu_si128((const __m128i *)(src+0x00)); // 00 01 02 03 04 05 06 07 x1 = _mm_loadu_si128((const __m128i *)(src+0x08)); // 08 09 0a 0b 0c 0d 0e 0f - + #ifdef SSSE3/// __SSSE3__ x0 = _mm_shuffle_epi8(x0, _mm_setr_epi8(0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15)); x1 = _mm_shuffle_epi8(x1, _mm_setr_epi8(0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15)); @@ -325,51 +325,51 @@ static void invTransform16(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d x0 = _mm_shufflehi_epi16(x0, 0xd8); x1 = _mm_shufflehi_epi16(x1, 0xd8); #endif - + a0 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[0]); // 00 02 a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[2])); // 04 06 a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[4])); // 08 0a a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[6])); // 0c 0e - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[3])); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[5])); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[7])); - + a2 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[8]); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[10])); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[12])); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[14])); - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[9]); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[11])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[13])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[15])); - + a0 = _mm_add_epi32(a0, o0); a1 = _mm_add_epi32(a1, o0); - + b0 = _mm_add_epi32(a0, a2); b1 = _mm_add_epi32(a1, a3); b2 = _mm_sub_epi32(a0, a2); b3 = _mm_sub_epi32(a1, a3); - + a0 = b0; a1 = b1; a2 = _mm_shuffle_epi32(b3, 0x1b); // 00011011 a3 = _mm_shuffle_epi32(b2, 0x1b); - + a0 = _mm_sra_epi32(a0, s0); a1 = _mm_sra_epi32(a1, s0); a2 = _mm_sra_epi32(a2, s0); a3 = _mm_sra_epi32(a3, s0); - + x0 = _mm_packs_epi32(a0, a1); x1 = _mm_packs_epi32(a2, a3); - + _mm_storeu_si128((__m128i *)(dst+0x00), x0); _mm_storeu_si128((__m128i *)(dst+0x08), x1); - + src += src_stride; dst += dst_stride; } @@ -381,58 +381,58 @@ static void invTransform16Half(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U { __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl2; - + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl2; + do { __m128i x0, x1; __m128i a0, a1, a2, a3; __m128i b0, b1, b2, b3; x0 = _mm_loadu_si128((const __m128i *)(src+0x00)); // 00 01 02 03 04 05 06 07 - + #ifdef SSSE3/// __SSSE3__ x0 = _mm_shuffle_epi8(x0, _mm_setr_epi8(0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15)); #else x0 = _mm_shufflelo_epi16(x0, 0xd8); // 00 02 01 03 04 06 05 07 x0 = _mm_shufflehi_epi16(x0, 0xd8); #endif - + a0 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[0]); // 00 02 a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[2])); // 04 06 - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[3])); - + a2 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[8]); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[10])); - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[9]); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[11])); - + a0 = _mm_add_epi32(a0, o0); a1 = _mm_add_epi32(a1, o0); - + b0 = _mm_add_epi32(a0, a2); b1 = _mm_add_epi32(a1, a3); b2 = _mm_sub_epi32(a0, a2); b3 = _mm_sub_epi32(a1, a3); - + a0 = b0; a1 = b1; a2 = _mm_shuffle_epi32(b3, 0x1b); // 00011011 a3 = _mm_shuffle_epi32(b2, 0x1b); - + a0 = _mm_sra_epi32(a0, s0); a1 = _mm_sra_epi32(a1, s0); a2 = _mm_sra_epi32(a2, s0); a3 = _mm_sra_epi32(a3, s0); - + x0 = _mm_packs_epi32(a0, a1); x1 = _mm_packs_epi32(a2, a3); - + _mm_storeu_si128((__m128i *)(dst+0x00), x0); _mm_storeu_si128((__m128i *)(dst+0x08), x1); - + src += src_stride; dst += dst_stride; } @@ -476,7 +476,7 @@ static void transpose32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ { __m128i a0, a1, a2, a3, a4, a5, a6, a7; __m128i b0, b1, b2, b3, b4, b5, b6, b7; - + a0 = _mm_loadu_si128((const __m128i *)(src + (8*i+0)*src_stride + 8*j)); a1 = _mm_loadu_si128((const __m128i *)(src + (8*i+1)*src_stride + 8*j)); a2 = _mm_loadu_si128((const __m128i *)(src + (8*i+2)*src_stride + 8*j)); @@ -485,7 +485,7 @@ static void transpose32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ a5 = _mm_loadu_si128((const __m128i *)(src + (8*i+5)*src_stride + 8*j)); a6 = _mm_loadu_si128((const __m128i *)(src + (8*i+6)*src_stride + 8*j)); a7 = _mm_loadu_si128((const __m128i *)(src + (8*i+7)*src_stride + 8*j)); - + b0 = _mm_unpacklo_epi16(a0, a4); b1 = _mm_unpacklo_epi16(a1, a5); b2 = _mm_unpacklo_epi16(a2, a6); @@ -494,7 +494,7 @@ static void transpose32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ b5 = _mm_unpackhi_epi16(a1, a5); b6 = _mm_unpackhi_epi16(a2, a6); b7 = _mm_unpackhi_epi16(a3, a7); - + a0 = _mm_unpacklo_epi16(b0, b2); a1 = _mm_unpacklo_epi16(b1, b3); a2 = _mm_unpackhi_epi16(b0, b2); @@ -503,7 +503,7 @@ static void transpose32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ a5 = _mm_unpacklo_epi16(b5, b7); a6 = _mm_unpackhi_epi16(b4, b6); a7 = _mm_unpackhi_epi16(b5, b7); - + b0 = _mm_unpacklo_epi16(a0, a1); b1 = _mm_unpackhi_epi16(a0, a1); b2 = _mm_unpacklo_epi16(a2, a3); @@ -512,7 +512,7 @@ static void transpose32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ b5 = _mm_unpackhi_epi16(a4, a5); b6 = _mm_unpacklo_epi16(a6, a7); b7 = _mm_unpackhi_epi16(a6, a7); - + _mm_storeu_si128((__m128i *)(dst + (8*j+0)*dst_stride + 8*i), b0); _mm_storeu_si128((__m128i *)(dst + (8*j+1)*dst_stride + 8*i), b1); _mm_storeu_si128((__m128i *)(dst + (8*j+2)*dst_stride + 8*i), b2); @@ -529,14 +529,14 @@ static void transpose32Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U { EB_U32 j; EB_U32 numRows = 4 - (pattern & 3); - + do { for (j = 0; j < 4; j++) { __m128i a0, a1, a2, a3, a4, a5, a6, a7; __m128i b0, b1, b2, b3, b4, b5, b6, b7; - + a0 = _mm_loadu_si128((const __m128i *)(src + (0)*src_stride + 8*j)); a1 = _mm_loadu_si128((const __m128i *)(src + (1)*src_stride + 8*j)); a2 = _mm_loadu_si128((const __m128i *)(src + (2)*src_stride + 8*j)); @@ -545,7 +545,7 @@ static void transpose32Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U a5 = _mm_loadu_si128((const __m128i *)(src + (5)*src_stride + 8*j)); a6 = _mm_loadu_si128((const __m128i *)(src + (6)*src_stride + 8*j)); a7 = _mm_loadu_si128((const __m128i *)(src + (7)*src_stride + 8*j)); - + b0 = _mm_unpacklo_epi16(a0, a4); b1 = _mm_unpacklo_epi16(a1, a5); b2 = _mm_unpacklo_epi16(a2, a6); @@ -554,7 +554,7 @@ static void transpose32Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U b5 = _mm_unpackhi_epi16(a1, a5); b6 = _mm_unpackhi_epi16(a2, a6); b7 = _mm_unpackhi_epi16(a3, a7); - + a0 = _mm_unpacklo_epi16(b0, b2); a1 = _mm_unpacklo_epi16(b1, b3); a2 = _mm_unpackhi_epi16(b0, b2); @@ -563,7 +563,7 @@ static void transpose32Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U a5 = _mm_unpacklo_epi16(b5, b7); a6 = _mm_unpackhi_epi16(b4, b6); a7 = _mm_unpackhi_epi16(b5, b7); - + b0 = _mm_unpacklo_epi16(a0, a1); b1 = _mm_unpackhi_epi16(a0, a1); b2 = _mm_unpacklo_epi16(a2, a3); @@ -572,7 +572,7 @@ static void transpose32Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U b5 = _mm_unpackhi_epi16(a4, a5); b6 = _mm_unpacklo_epi16(a6, a7); b7 = _mm_unpackhi_epi16(a6, a7); - + _mm_storeu_si128((__m128i *)(dst + (8*j+0)*dst_stride), b0); _mm_storeu_si128((__m128i *)(dst + (8*j+1)*dst_stride), b1); _mm_storeu_si128((__m128i *)(dst + (8*j+2)*dst_stride), b2); @@ -582,7 +582,7 @@ static void transpose32Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U _mm_storeu_si128((__m128i *)(dst + (8*j+6)*dst_stride), b6); _mm_storeu_si128((__m128i *)(dst + (8*j+7)*dst_stride), b7); } - + src += 8 * src_stride; dst += 8; } @@ -594,7 +594,7 @@ static EB_U32 transpose32Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB EB_U32 i, j; EB_U32 zeroPattern = 0; EB_U32 result = 0; - + for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) @@ -602,7 +602,7 @@ static EB_U32 transpose32Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB __m128i a0, a1, a2, a3, a4, a5, a6, a7; __m128i b0, b1, b2, b3, b4, b5, b6, b7; __m128i c0; - + a0 = _mm_loadu_si128((const __m128i *)(src + (8*i+0)*src_stride + 8*j)); a1 = _mm_loadu_si128((const __m128i *)(src + (8*i+1)*src_stride + 8*j)); a2 = _mm_loadu_si128((const __m128i *)(src + (8*i+2)*src_stride + 8*j)); @@ -611,7 +611,7 @@ static EB_U32 transpose32Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB a5 = _mm_loadu_si128((const __m128i *)(src + (8*i+5)*src_stride + 8*j)); a6 = _mm_loadu_si128((const __m128i *)(src + (8*i+6)*src_stride + 8*j)); a7 = _mm_loadu_si128((const __m128i *)(src + (8*i+7)*src_stride + 8*j)); - + c0 = _mm_or_si128(a0, a4); c0 = _mm_or_si128(c0, a1); c0 = _mm_or_si128(c0, a5); @@ -619,11 +619,11 @@ static EB_U32 transpose32Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB c0 = _mm_or_si128(c0, a6); c0 = _mm_or_si128(c0, a3); c0 = _mm_or_si128(c0, a7); - + c0 = _mm_cmpeq_epi8(c0, _mm_setzero_si128()); - + zeroPattern = 2 * zeroPattern + ((_mm_movemask_epi8(c0)+1) >> 16); // add a '1' bit if all zeros - + b0 = _mm_unpacklo_epi16(a0, a4); b1 = _mm_unpacklo_epi16(a1, a5); b2 = _mm_unpacklo_epi16(a2, a6); @@ -632,7 +632,7 @@ static EB_U32 transpose32Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB b5 = _mm_unpackhi_epi16(a1, a5); b6 = _mm_unpackhi_epi16(a2, a6); b7 = _mm_unpackhi_epi16(a3, a7); - + a0 = _mm_unpacklo_epi16(b0, b2); a1 = _mm_unpacklo_epi16(b1, b3); a2 = _mm_unpackhi_epi16(b0, b2); @@ -641,7 +641,7 @@ static EB_U32 transpose32Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB a5 = _mm_unpacklo_epi16(b5, b7); a6 = _mm_unpackhi_epi16(b4, b6); a7 = _mm_unpackhi_epi16(b5, b7); - + b0 = _mm_unpacklo_epi16(a0, a1); b1 = _mm_unpackhi_epi16(a0, a1); b2 = _mm_unpacklo_epi16(a2, a3); @@ -650,7 +650,7 @@ static EB_U32 transpose32Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB b5 = _mm_unpackhi_epi16(a4, a5); b6 = _mm_unpacklo_epi16(a6, a7); b7 = _mm_unpackhi_epi16(a6, a7); - + _mm_storeu_si128((__m128i *)(dst + (8*j+0)*dst_stride + 8*i), b0); _mm_storeu_si128((__m128i *)(dst + (8*j+1)*dst_stride + 8*i), b1); _mm_storeu_si128((__m128i *)(dst + (8*j+2)*dst_stride + 8*i), b2); @@ -661,15 +661,15 @@ static EB_U32 transpose32Check0s(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB _mm_storeu_si128((__m128i *)(dst + (8*j+7)*dst_stride + 8*i), b7); } } - + if ((zeroPattern & 0xfff) == 0xfff) result |= 3; else if ((zeroPattern & 0xff) == 0xff) result |= 2; else if ((zeroPattern & 0xf) == 0xf) result |= 1; - + if ((zeroPattern & 0x7777) == 0x7777) result |= 3*4; else if ((zeroPattern & 0x3333) == 0x3333) result |= 2*4; else if ((zeroPattern & 0x1111) == 0x1111) result |= 1*4; - + return result; } @@ -678,8 +678,8 @@ static void transform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ { __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl; - + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl; + EB_U32 numRows = 32; do { @@ -692,25 +692,25 @@ static void transform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ x1 = _mm_loadu_si128((const __m128i *)(src+0x08)); x2 = _mm_loadu_si128((const __m128i *)(src+0x10)); x3 = _mm_loadu_si128((const __m128i *)(src+0x18)); - - + + // 32-point butterfly x2 = reverse_epi16(x2); x3 = reverse_epi16(x3); - + y0 = _mm_add_epi16(x0, x3); y1 = _mm_add_epi16(x1, x2); - + y2 = _mm_sub_epi16(x0, x3); y3 = _mm_sub_epi16(x1, x2); - + // 16-point butterfly y1 = reverse_epi16(y1); - + x0 = _mm_add_epi16(y0, y1); x1 = _mm_sub_epi16(y0, y1); - - + + x2 = y2; x3 = y3; @@ -728,7 +728,7 @@ static void transform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[10])); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[12])); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[14])); - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[9]); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[11])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[13])); @@ -760,7 +760,7 @@ static void transform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x55), coeff32[38])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xaa), coeff32[42])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xff), coeff32[46])); - + a7 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[19]); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[23])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[27])); @@ -778,12 +778,12 @@ static void transform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ b5 = _mm_sra_epi32(_mm_add_epi32(a5, o0), s0); b6 = _mm_sra_epi32(_mm_add_epi32(a6, o0), s0); b7 = _mm_sra_epi32(_mm_add_epi32(a7, o0), s0); - + x0 = _mm_packs_epi32(b0, b1); x1 = _mm_packs_epi32(b2, b3); x2 = _mm_packs_epi32(b4, b5); x3 = _mm_packs_epi32(b6, b7); - + y0 = _mm_unpacklo_epi16(x0, x1); y1 = _mm_unpackhi_epi16(x0, x1); y2 = x2; @@ -792,12 +792,12 @@ static void transform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_ x1 = _mm_unpackhi_epi16(y0, y2); x2 = _mm_unpacklo_epi16(y1, y3); x3 = _mm_unpackhi_epi16(y1, y3); - + _mm_storeu_si128((__m128i *)(dst+0x00), x0); _mm_storeu_si128((__m128i *)(dst+0x08), x1); _mm_storeu_si128((__m128i *)(dst+0x10), x2); _mm_storeu_si128((__m128i *)(dst+0x18), x3); - + src += src_stride; dst += dst_stride; } @@ -809,7 +809,7 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d { __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl2; + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl2; do { @@ -834,7 +834,7 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[2])); a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[4])); a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x00), coeff32[6])); - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[3])); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[5])); @@ -844,12 +844,12 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[10])); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[12])); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x55), coeff32[14])); - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[9]); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[11])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[13])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x55), coeff32[15])); - + a4 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[16]); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[20])); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[24])); @@ -876,7 +876,7 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[38])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xaa), coeff32[42])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xff), coeff32[46])); - + a7 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[19]); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[23])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[27])); @@ -891,42 +891,42 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d y1 = _mm_unpackhi_epi16(x0, x1); // 04 0c 05 0d 06 0e 07 0f y2 = _mm_unpacklo_epi16(x2, x3); // 10 18 y3 = _mm_unpackhi_epi16(x2, x3); // 24 2c - + x0 = _mm_unpacklo_epi16(y0, y1); // 00 04 08 0c 01 05 09 0d x1 = _mm_unpackhi_epi16(y0, y1); // 02 06 0a 0e 03 07 0b 0f x2 = _mm_unpacklo_epi16(y2, y3); // 10 14 x3 = _mm_unpackhi_epi16(y2, y3); // 12 16 - + y0 = _mm_unpacklo_epi64(x0, x2); // 00 04 08 0c 10 14 18 1c y1 = _mm_unpacklo_epi64(x1, x3); // 02 06 0a 0e 12 16 1a 1e y2 = _mm_unpackhi_epi16(x0, x1); // 01 03 05 07 09 0b 0d 0f y3 = _mm_unpackhi_epi16(x2, x3); // 11 13 15 17 19 1b 1d 1f - + x0 = y0; x1 = y1; x2 = y2; x3 = y3; - + a0 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[0]); // 00 04 a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[2])); // 08 0c a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[4])); // 10 14 a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[6])); // 18 1c - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[3])); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[5])); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[7])); - + a2 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[8]); // 02 06 a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[10])); // 0a 0e a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[12])); // 12 16 a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[14])); // 1a 1e - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[9]); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[11])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[13])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[15])); - + a4 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[16]); // 01 03 a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[20])); // 05 07 a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[24])); // 09 0b @@ -935,7 +935,7 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x55), coeff32[36])); // 15 17 a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xaa), coeff32[40])); // 19 1b a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xff), coeff32[44])); // 1d 1f - + a5 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[17]); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[21])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[25])); @@ -944,7 +944,7 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x55), coeff32[37])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xaa), coeff32[41])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xff), coeff32[45])); - + a6 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[18]); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[22])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[26])); @@ -953,7 +953,7 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x55), coeff32[38])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xaa), coeff32[42])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xff), coeff32[46])); - + a7 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[19]); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[23])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[27])); @@ -963,15 +963,15 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xaa), coeff32[43])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0xff), coeff32[47])); #endif - + a0 = _mm_add_epi32(a0, o0); a1 = _mm_add_epi32(a1, o0); - + b0 = _mm_add_epi32(a0, a2); b1 = _mm_add_epi32(a1, a3); b2 = _mm_sub_epi32(a0, a2); b3 = _mm_sub_epi32(a1, a3); - + a0 = b0; a1 = b1; a2 = _mm_shuffle_epi32(b3, 0x1b); // 00011011 @@ -985,7 +985,7 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d b5 = _mm_sub_epi32(a1, a5); b6 = _mm_sub_epi32(a2, a6); b7 = _mm_sub_epi32(a3, a7); - + a0 = _mm_sra_epi32(b0, s0); a1 = _mm_sra_epi32(b1, s0); a2 = _mm_sra_epi32(b2, s0); @@ -994,7 +994,7 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d a5 = _mm_sra_epi32(_mm_shuffle_epi32(b6, 0x1b), s0); a6 = _mm_sra_epi32(_mm_shuffle_epi32(b5, 0x1b), s0); a7 = _mm_sra_epi32(_mm_shuffle_epi32(b4, 0x1b), s0); - + x0 = _mm_packs_epi32(a0, a1); x1 = _mm_packs_epi32(a2, a3); x2 = _mm_packs_epi32(a4, a5); @@ -1004,7 +1004,7 @@ static void invTransform32(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 d _mm_storeu_si128((__m128i *)(dst+0x08), x1); _mm_storeu_si128((__m128i *)(dst+0x10), x2); _mm_storeu_si128((__m128i *)(dst+0x18), x3); - + src += src_stride; dst += dst_stride; } @@ -1015,8 +1015,8 @@ static void invTransform32ThreeQuarter(EB_S16 *src, EB_U32 src_stride, EB_S16 *d { __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl2; - + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl2; + do { __m128i x0, x1, x2, x3; @@ -1029,114 +1029,114 @@ static void invTransform32ThreeQuarter(EB_S16 *src, EB_U32 src_stride, EB_S16 *d x1 = _mm_loadu_si128((const __m128i *)(src+0x08)); // 08 09 0a 0b 0c 0d 0e 0f x2 = _mm_loadu_si128((const __m128i *)(src+0x10)); // 10 11 12 13 14 15 16 17 x3 = _mm_setzero_si128(); - + #ifdef SSSE3/// __SSSE3__ x0 = _mm_shuffle_epi8(x0, _mm_setr_epi8(0, 1, 8, 9, 4, 5, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15)); // 00 04 02 06 01 03 05 07 x1 = _mm_shuffle_epi8(x1, _mm_setr_epi8(0, 1, 8, 9, 4, 5, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15)); // 08 0c 0a 0e 09 0b 0d 0f x2 = _mm_shuffle_epi8(x2, _mm_setr_epi8(0, 1, 8, 9, 4, 5, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15)); // 10 14 12 16 11 13 15 17 - + a0 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[0]); a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[2])); a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[4])); - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[3])); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[5])); - + a2 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[8]); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[10])); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[12])); - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[9]); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[11])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[13])); - + a4 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[16]); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[20])); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[24])); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[28])); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[32])); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[36])); - + a5 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[17]); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[21])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[25])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[29])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[33])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[37])); - + a6 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[18]); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[22])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[26])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[30])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[34])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[38])); - + a7 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[19]); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[23])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[27])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[31])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[35])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[39])); - + #else y0 = _mm_unpacklo_epi16(x0, x1); // 00 08 01 09 02 0a 03 0b y1 = _mm_unpackhi_epi16(x0, x1); // 04 0c 05 0d 06 0e 07 0f y2 = _mm_unpacklo_epi16(x2, x3); // 10 18 y3 = _mm_unpackhi_epi16(x2, x3); // 24 2c - + x0 = _mm_unpacklo_epi16(y0, y1); // 00 04 08 0c 01 05 09 0d x1 = _mm_unpackhi_epi16(y0, y1); // 02 06 0a 0e 03 07 0b 0f x2 = _mm_unpacklo_epi16(y2, y3); // 10 14 x3 = _mm_unpackhi_epi16(y2, y3); // 12 16 - + y0 = _mm_unpacklo_epi64(x0, x2); // 00 04 08 0c 10 14 18 1c y1 = _mm_unpacklo_epi64(x1, x3); // 02 06 0a 0e 12 16 1a 1e y2 = _mm_unpackhi_epi16(x0, x1); // 01 03 05 07 09 0b 0d 0f y3 = _mm_unpackhi_epi16(x2, x3); // 11 13 15 17 19 1b 1d 1f - + x0 = y0; x1 = y1; x2 = y2; x3 = y3; - + a0 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[0]); // 00 04 a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[2])); // 08 0c a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[4])); // 10 14 - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[3])); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[5])); - + a2 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[8]); // 02 06 a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[10])); // 0a 0e a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[12])); // 12 16 - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[9]); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[11])); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[13])); - + a4 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[16]); // 01 03 a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[20])); // 05 07 a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[24])); // 09 0b a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[28])); // 0d 0f a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x00), coeff32[32])); // 11 13 a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x55), coeff32[36])); // 15 17 - + a5 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[17]); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[21])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[25])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[29])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x00), coeff32[33])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x55), coeff32[37])); - + a6 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[18]); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[22])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[26])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[30])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x00), coeff32[34])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x55), coeff32[38])); - + a7 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[19]); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[23])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[27])); @@ -1144,20 +1144,20 @@ static void invTransform32ThreeQuarter(EB_S16 *src, EB_U32 src_stride, EB_S16 *d a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x00), coeff32[35])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x3, 0x55), coeff32[39])); #endif - + a0 = _mm_add_epi32(a0, o0); a1 = _mm_add_epi32(a1, o0); - + b0 = _mm_add_epi32(a0, a2); b1 = _mm_add_epi32(a1, a3); b2 = _mm_sub_epi32(a0, a2); b3 = _mm_sub_epi32(a1, a3); - + a0 = b0; a1 = b1; a2 = _mm_shuffle_epi32(b3, 0x1b); // 00011011 a3 = _mm_shuffle_epi32(b2, 0x1b); - + b0 = _mm_add_epi32(a0, a4); b1 = _mm_add_epi32(a1, a5); b2 = _mm_add_epi32(a2, a6); @@ -1166,7 +1166,7 @@ static void invTransform32ThreeQuarter(EB_S16 *src, EB_U32 src_stride, EB_S16 *d b5 = _mm_sub_epi32(a1, a5); b6 = _mm_sub_epi32(a2, a6); b7 = _mm_sub_epi32(a3, a7); - + a0 = _mm_sra_epi32(b0, s0); a1 = _mm_sra_epi32(b1, s0); a2 = _mm_sra_epi32(b2, s0); @@ -1175,17 +1175,17 @@ static void invTransform32ThreeQuarter(EB_S16 *src, EB_U32 src_stride, EB_S16 *d a5 = _mm_sra_epi32(_mm_shuffle_epi32(b6, 0x1b), s0); a6 = _mm_sra_epi32(_mm_shuffle_epi32(b5, 0x1b), s0); a7 = _mm_sra_epi32(_mm_shuffle_epi32(b4, 0x1b), s0); - + x0 = _mm_packs_epi32(a0, a1); x1 = _mm_packs_epi32(a2, a3); x2 = _mm_packs_epi32(a4, a5); x3 = _mm_packs_epi32(a6, a7); - + _mm_storeu_si128((__m128i *)(dst+0x00), x0); _mm_storeu_si128((__m128i *)(dst+0x08), x1); _mm_storeu_si128((__m128i *)(dst+0x10), x2); _mm_storeu_si128((__m128i *)(dst+0x18), x3); - + src += src_stride; dst += dst_stride; } @@ -1196,8 +1196,8 @@ static void invTransform32Half(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U { __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl2; - + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl2; + do { __m128i x0, x1, x2, x3; @@ -1210,104 +1210,104 @@ static void invTransform32Half(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U x1 = _mm_loadu_si128((const __m128i *)(src+0x08)); // 08 09 0a 0b 0c 0d 0e 0f x2 = _mm_setzero_si128(); x3 = _mm_setzero_si128(); - + #ifdef SSSE3/// __SSSE3__ x0 = _mm_shuffle_epi8(x0, _mm_setr_epi8(0, 1, 8, 9, 4, 5, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15)); // 00 04 02 06 01 03 05 07 x1 = _mm_shuffle_epi8(x1, _mm_setr_epi8(0, 1, 8, 9, 4, 5, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15)); // 08 0c 0a 0e 09 0b 0d 0f - + a0 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[0]); a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[2])); - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[3])); - + a2 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[8]); a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[10])); - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[9]); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[11])); - + a4 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[16]); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[20])); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[24])); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[28])); - + a5 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[17]); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[21])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[25])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[29])); - + a6 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[18]); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[22])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[26])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[30])); - + a7 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[19]); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[23])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xaa), coeff32[27])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0xff), coeff32[31])); - + #else y0 = _mm_unpacklo_epi16(x0, x1); // 00 08 01 09 02 0a 03 0b y1 = _mm_unpackhi_epi16(x0, x1); // 04 0c 05 0d 06 0e 07 0f - + x0 = _mm_unpacklo_epi16(y0, y1); // 00 04 08 0c 01 05 09 0d x1 = _mm_unpackhi_epi16(y0, y1); // 02 06 0a 0e 03 07 0b 0f - + y0 = _mm_unpacklo_epi64(x0, x2); // 00 04 08 0c 10 14 18 1c y1 = _mm_unpacklo_epi64(x1, x3); // 02 06 0a 0e 12 16 1a 1e y2 = _mm_unpackhi_epi16(x0, x1); // 01 03 05 07 09 0b 0d 0f - + x0 = y0; x1 = y1; x2 = y2; - + a0 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[0]); // 00 04 a0 = _mm_add_epi32(a0, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[2])); // 08 0c - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); a1 = _mm_add_epi32(a1, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[3])); - + a2 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[8]); // 02 06 a2 = _mm_add_epi32(a2, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[10])); // 0a 0e - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[9]); a3 = _mm_add_epi32(a3, _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x55), coeff32[11])); - + a4 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[16]); // 01 03 a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[20])); // 05 07 a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[24])); // 09 0b a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[28])); // 0d 0f - + a5 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[17]); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[21])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[25])); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[29])); - + a6 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[18]); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[22])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[26])); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[30])); - + a7 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[19]); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[23])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xaa), coeff32[27])); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0xff), coeff32[31])); #endif - + a0 = _mm_add_epi32(a0, o0); a1 = _mm_add_epi32(a1, o0); - + b0 = _mm_add_epi32(a0, a2); b1 = _mm_add_epi32(a1, a3); b2 = _mm_sub_epi32(a0, a2); b3 = _mm_sub_epi32(a1, a3); - + a0 = b0; a1 = b1; a2 = _mm_shuffle_epi32(b3, 0x1b); // 00011011 a3 = _mm_shuffle_epi32(b2, 0x1b); - + b0 = _mm_add_epi32(a0, a4); b1 = _mm_add_epi32(a1, a5); b2 = _mm_add_epi32(a2, a6); @@ -1316,7 +1316,7 @@ static void invTransform32Half(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U b5 = _mm_sub_epi32(a1, a5); b6 = _mm_sub_epi32(a2, a6); b7 = _mm_sub_epi32(a3, a7); - + a0 = _mm_sra_epi32(b0, s0); a1 = _mm_sra_epi32(b1, s0); a2 = _mm_sra_epi32(b2, s0); @@ -1325,17 +1325,17 @@ static void invTransform32Half(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U a5 = _mm_sra_epi32(_mm_shuffle_epi32(b6, 0x1b), s0); a6 = _mm_sra_epi32(_mm_shuffle_epi32(b5, 0x1b), s0); a7 = _mm_sra_epi32(_mm_shuffle_epi32(b4, 0x1b), s0); - + x0 = _mm_packs_epi32(a0, a1); x1 = _mm_packs_epi32(a2, a3); x2 = _mm_packs_epi32(a4, a5); x3 = _mm_packs_epi32(a6, a7); - + _mm_storeu_si128((__m128i *)(dst+0x00), x0); _mm_storeu_si128((__m128i *)(dst+0x08), x1); _mm_storeu_si128((__m128i *)(dst+0x10), x2); _mm_storeu_si128((__m128i *)(dst+0x18), x3); - + src += src_stride; dst += dst_stride; } @@ -1346,8 +1346,8 @@ static void invTransform32Quarter(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, E { __m128i s0 = _mm_cvtsi32_si128(shift); __m128i o0 = _mm_set1_epi32(1 << (shift - 1)); - const __m128i *coeff32 = (const __m128i *)coeff_tbl2; - + const __m128i *coeff32 = (const __m128i *)EbHevccoeff_tbl2; + do { __m128i x0, x1, x2, x3; @@ -1357,77 +1357,77 @@ static void invTransform32Quarter(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, E __m128i a0, a1, a2, a3, a4, a5, a6, a7; __m128i b0, b1, b2, b3, b4, b5, b6, b7; x0 = _mm_loadu_si128((const __m128i *)(src+0x00)); // 00 01 02 03 04 05 06 07 - + #ifdef SSSE3/// __SSSE3__ x0 = _mm_shuffle_epi8(x0, _mm_setr_epi8(0, 1, 8, 9, 4, 5, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15)); // 00 04 02 06 01 03 05 07 - + a0 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[0]); - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); - + a2 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[8]); - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x55), coeff32[9]); - + a4 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[16]); a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[20])); - + a5 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[17]); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[21])); - + a6 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[18]); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[22])); - + a7 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xaa), coeff32[19]); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x0, 0xff), coeff32[23])); #else y0 = _mm_unpacklo_epi16(x0, x0); // 00 08 01 09 02 0a 03 0b y1 = _mm_unpackhi_epi16(x0, x0); // 04 0c 05 0d 06 0e 07 0f - + x0 = _mm_unpacklo_epi16(y0, y1); // 00 04 08 0c 01 05 09 0d x1 = _mm_unpackhi_epi16(y0, y1); // 02 06 0a 0e 03 07 0b 0f - + y0 = _mm_unpacklo_epi64(x0, x0); // 00 04 08 0c 10 14 18 1c y1 = _mm_unpacklo_epi64(x1, x1); // 02 06 0a 0e 12 16 1a 1e x2 = _mm_unpackhi_epi16(x0, x1); // 01 03 05 07 09 0b 0d 0f - + x0 = y0; x1 = y1; - + a0 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[0]); // 00 04 - + a1 = _mm_madd_epi16(_mm_shuffle_epi32(x0, 0x00), coeff32[1]); - + a2 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[8]); // 02 06 - + a3 = _mm_madd_epi16(_mm_shuffle_epi32(x1, 0x00), coeff32[9]); - + a4 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[16]); // 01 03 a4 = _mm_add_epi32(a4, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[20])); // 05 07 - + a5 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[17]); a5 = _mm_add_epi32(a5, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[21])); - + a6 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[18]); a6 = _mm_add_epi32(a6, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[22])); - + a7 = _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x00), coeff32[19]); a7 = _mm_add_epi32(a7, _mm_madd_epi16(_mm_shuffle_epi32(x2, 0x55), coeff32[23])); #endif - + a0 = _mm_add_epi32(a0, o0); a1 = _mm_add_epi32(a1, o0); - + b0 = _mm_add_epi32(a0, a2); b1 = _mm_add_epi32(a1, a3); b2 = _mm_sub_epi32(a0, a2); b3 = _mm_sub_epi32(a1, a3); - + a0 = b0; a1 = b1; a2 = _mm_shuffle_epi32(b3, 0x1b); // 00011011 a3 = _mm_shuffle_epi32(b2, 0x1b); - + b0 = _mm_add_epi32(a0, a4); b1 = _mm_add_epi32(a1, a5); b2 = _mm_add_epi32(a2, a6); @@ -1436,7 +1436,7 @@ static void invTransform32Quarter(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, E b5 = _mm_sub_epi32(a1, a5); b6 = _mm_sub_epi32(a2, a6); b7 = _mm_sub_epi32(a3, a7); - + a0 = _mm_sra_epi32(b0, s0); a1 = _mm_sra_epi32(b1, s0); a2 = _mm_sra_epi32(b2, s0); @@ -1445,17 +1445,17 @@ static void invTransform32Quarter(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, E a5 = _mm_sra_epi32(_mm_shuffle_epi32(b6, 0x1b), s0); a6 = _mm_sra_epi32(_mm_shuffle_epi32(b5, 0x1b), s0); a7 = _mm_sra_epi32(_mm_shuffle_epi32(b4, 0x1b), s0); - + x0 = _mm_packs_epi32(a0, a1); x1 = _mm_packs_epi32(a2, a3); x2 = _mm_packs_epi32(a4, a5); x3 = _mm_packs_epi32(a6, a7); - + _mm_storeu_si128((__m128i *)(dst+0x00), x0); _mm_storeu_si128((__m128i *)(dst+0x08), x1); _mm_storeu_si128((__m128i *)(dst+0x10), x2); _mm_storeu_si128((__m128i *)(dst+0x18), x3); - + src += src_stride; dst += dst_stride; } @@ -1465,7 +1465,7 @@ static void invTransform32Quarter(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, E static void invTransform32Partial(EB_S16 *src, EB_U32 src_stride, EB_S16 *dst, EB_U32 dst_stride, EB_U32 shift, EB_U32 pattern) { EB_U32 numRows = 32 - 2 * (pattern & 12); - + switch (pattern & 3) { case 3: diff --git a/Source/Lib/Codec/EbCodingLoop.c b/Source/Lib/Codec/EbCodingLoop.c index 9267a6e4c..6d75f568f 100644 --- a/Source/Lib/Codec/EbCodingLoop.c +++ b/Source/Lib/Codec/EbCodingLoop.c @@ -573,7 +573,7 @@ static void EncodePassUpdateReconSampleNeighborArrays( /************************************************************ * Update Intra Luma Neighbor Modes ************************************************************/ -void GeneratePuIntraLumaNeighborModes( +void EbHevcGeneratePuIntraLumaNeighborModes( CodingUnit_t *cuPtr, EB_U32 puOriginX, EB_U32 puOriginY, @@ -1901,12 +1901,12 @@ static void EncodePassMvPrediction( xMvdIdx0 = (contextPtr->cuPtr->predictionUnitArray->mv[REF_LIST_0].x - contextPtr->xMvAmvpCandidateArrayList0[0]); yMvdIdx0 = (contextPtr->cuPtr->predictionUnitArray->mv[REF_LIST_0].y - contextPtr->yMvAmvpCandidateArrayList0[0]); - GetMvdFractionBits(xMvdIdx0, yMvdIdx0, contextPtr->mdRateEstimationPtr, &mvdBitsIdx0); + EbHevcGetMvdFractionBits(xMvdIdx0, yMvdIdx0, contextPtr->mdRateEstimationPtr, &mvdBitsIdx0); if (contextPtr->amvpCandidateCountRefList0 > 1) { xMvdIdx1 = (contextPtr->cuPtr->predictionUnitArray->mv[REF_LIST_0].x - contextPtr->xMvAmvpCandidateArrayList0[1]); yMvdIdx1 = (contextPtr->cuPtr->predictionUnitArray->mv[REF_LIST_0].y - contextPtr->yMvAmvpCandidateArrayList0[1]); - GetMvdFractionBits(xMvdIdx1, yMvdIdx1, contextPtr->mdRateEstimationPtr, &mvdBitsIdx1); + EbHevcGetMvdFractionBits(xMvdIdx1, yMvdIdx1, contextPtr->mdRateEstimationPtr, &mvdBitsIdx1); // Assign the AMVP predictor index contextPtr->cuPtr->predictionUnitArray->mvd[REF_LIST_0].predIdx = (mvdBitsIdx1 < mvdBitsIdx0); @@ -1949,12 +1949,12 @@ static void EncodePassMvPrediction( // Assign the MV Predictor xMvdIdx0 = (contextPtr->cuPtr->predictionUnitArray->mv[REF_LIST_1].x - contextPtr->xMvAmvpCandidateArrayList1[0]); yMvdIdx0 = (contextPtr->cuPtr->predictionUnitArray->mv[REF_LIST_1].y - contextPtr->yMvAmvpCandidateArrayList1[0]); - GetMvdFractionBits(xMvdIdx0, yMvdIdx0, contextPtr->mdRateEstimationPtr, &mvdBitsIdx0); + EbHevcGetMvdFractionBits(xMvdIdx0, yMvdIdx0, contextPtr->mdRateEstimationPtr, &mvdBitsIdx0); if (contextPtr->amvpCandidateCountRefList1 > 1) { xMvdIdx1 = (contextPtr->cuPtr->predictionUnitArray->mv[REF_LIST_1].x - contextPtr->xMvAmvpCandidateArrayList1[1]); yMvdIdx1 = (contextPtr->cuPtr->predictionUnitArray->mv[REF_LIST_1].y - contextPtr->yMvAmvpCandidateArrayList1[1]); - GetMvdFractionBits(xMvdIdx1, yMvdIdx1, contextPtr->mdRateEstimationPtr, &mvdBitsIdx1); + EbHevcGetMvdFractionBits(xMvdIdx1, yMvdIdx1, contextPtr->mdRateEstimationPtr, &mvdBitsIdx1); // Assign the AMVP predictor index contextPtr->cuPtr->predictionUnitArray->mvd[REF_LIST_1].predIdx = (mvdBitsIdx1 < mvdBitsIdx0); @@ -3262,7 +3262,7 @@ EB_EXTERN void EncodePass( // Set the PU Loop Variables puPtr = cuPtr->predictionUnitArray; // Generate Intra Luma Neighbor Modes - GeneratePuIntraLumaNeighborModes( // HT done + EbHevcGeneratePuIntraLumaNeighborModes( // HT done cuPtr, contextPtr->cuOriginX, contextPtr->cuOriginY, @@ -3362,7 +3362,7 @@ EB_EXTERN void EncodePass( lcuStatPtr->stationaryEdgeOverTimeFlag, pictureControlSetPtr->temporalLayerIndex > 0 ? lcuStatPtr->pmStationaryEdgeOverTimeFlag : lcuStatPtr->stationaryEdgeOverTimeFlag); - // Set Fast El coef shaping method + // Set Fast El coef shaping method contextPtr->transCoeffShapeLuma = DEFAULT_SHAPE; contextPtr->transCoeffShapeChroma = DEFAULT_SHAPE; if (fastEl && contextPtr->pmpMaskingLevelEncDec > MASK_THSHLD_1) { @@ -3586,7 +3586,7 @@ EB_EXTERN void EncodePass( puPtr = cuPtr->predictionUnitArray; // Generate Intra Luma Neighbor Modes - GeneratePuIntraLumaNeighborModes( // HT done + EbHevcGeneratePuIntraLumaNeighborModes( // HT done cuPtr, partitionOriginX, partitionOriginY, diff --git a/Source/Lib/Codec/EbCodingUnit.h b/Source/Lib/Codec/EbCodingUnit.h index 51fadfcda..2d1aad10d 100644 --- a/Source/Lib/Codec/EbCodingUnit.h +++ b/Source/Lib/Codec/EbCodingUnit.h @@ -55,11 +55,11 @@ struct PictureControlSet_s; #define MAX_CU_COST (0xFFFFFFFFFFFFFFFFull >> 1) #define INVALID_FAST_CANDIDATE_INDEX ~0 -#define MAX_OIS_0 7 // when I Slice -#define MAX_OIS_1 9 // when P/B Slice and oisKernelLevel = 0 -#define MAX_OIS_2 18 // when P/B Slice and oisKernelLevel = 1 +#define MAX_OIS_0 7 // when I Slice +#define MAX_OIS_1 9 // when P/B Slice and oisKernelLevel = 0 +#define MAX_OIS_2 18 // when P/B Slice and oisKernelLevel = 1 -typedef struct CodingUnit_s +typedef struct CodingUnit_s { TransformUnit_t transformUnitArray[TRANSFORM_UNIT_MAX_COUNT]; // 2-bytes * 21 = 42-bytes PredictionUnit_t predictionUnitArray[MAX_NUM_OF_PU_PER_CU]; // 35-bytes * 4 = 140 bytes @@ -99,7 +99,7 @@ typedef struct OisCandidate_s { }; } OisCandidate_t; -typedef struct OisLcuResults_s +typedef struct OisLcuResults_s { EB_U8 totalIntraLumaMode[CU_MAX_COUNT]; OisCandidate_t sortedOisCandidate[CU_MAX_COUNT][MAX_OIS_2]; @@ -109,9 +109,9 @@ typedef struct OisLcuResults_s typedef struct OisCu32Cu16Results_s { - EB_U8 totalIntraLumaMode[21]; - OisCandidate_t* sortedOisCandidate[21]; - + EB_U8 totalIntraLumaMode[21]; + OisCandidate_t* sortedOisCandidate[21]; + } OisCu32Cu16Results_t; typedef struct OisCu8Results_s @@ -138,7 +138,7 @@ typedef struct SaoParameters_s { // SAO EB_BOOL saoMergeLeftFlag; EB_BOOL saoMergeUpFlag; - EB_U32 saoTypeIndex[2]; + EB_U32 saoTypeIndex[2]; EB_S32 saoOffset[3][4]; EB_U32 saoBandPosition[3]; @@ -184,10 +184,10 @@ typedef struct LcuTileInfo_s { typedef struct LargestCodingUnit_s { struct PictureControlSet_s *pictureControlSetPtr; - CodingUnit_t **codedLeafArrayPtr; - - // Coding Units - EB_AURA_STATUS auraStatus; + CodingUnit_t **codedLeafArrayPtr; + + // Coding Units + EB_AURA_STATUS auraStatus; unsigned qp : 8; unsigned size : 8; diff --git a/Source/Lib/Codec/EbDefinitions.h b/Source/Lib/Codec/EbDefinitions.h index a1700a758..662f2b152 100644 --- a/Source/Lib/Codec/EbDefinitions.h +++ b/Source/Lib/Codec/EbDefinitions.h @@ -339,7 +339,7 @@ FORCE_INLINE void eb_memcpy(void *dstPtr, void *srcPtr, size_t size) #define EB_TYPE_PIC_STRUCT 5 // It is a requirement (for the application) that if pictureStruct is present for 1 picture it shall be present for every picture -#define Log2f Log2f_SSE2 +#define Log2f EbHevcLog2f_SSE2 extern EB_U32 Log2f(EB_U32 x); diff --git a/Source/Lib/Codec/EbEncDecProcess.c b/Source/Lib/Codec/EbEncDecProcess.c index a19a44dfb..ebdf209de 100644 --- a/Source/Lib/Codec/EbEncDecProcess.c +++ b/Source/Lib/Codec/EbEncDecProcess.c @@ -18,19 +18,19 @@ void PrecomputeCabacCost(CabacCost_t *CabacCostPtr, CabacEncodeContext_t *cabacEncodeCtxPtr); -const EB_S16 encMinDeltaQpWeightTab[MAX_TEMPORAL_LAYERS] = { 100, 100, 100, 100, 100, 100 }; -const EB_S16 encMaxDeltaQpWeightTab[MAX_TEMPORAL_LAYERS] = { 100, 100, 100, 100, 100, 100 }; +const EB_S16 EbHevcencMinDeltaQpWeightTab[MAX_TEMPORAL_LAYERS] = { 100, 100, 100, 100, 100, 100 }; +const EB_S16 EbHevcencMaxDeltaQpWeightTab[MAX_TEMPORAL_LAYERS] = { 100, 100, 100, 100, 100, 100 }; -const EB_S8 encMinDeltaQpISliceTab[4] = { -5, -5, -3, -2 }; +const EB_S8 EbHevcencMinDeltaQpISliceTab[4] = { -5, -5, -3, -2 }; -const EB_S8 encMinDeltaQpTab[4][MAX_TEMPORAL_LAYERS] = { +const EB_S8 EbHevcencMinDeltaQpTab[4][MAX_TEMPORAL_LAYERS] = { { -4, -2, -2, -1, -1, -1 }, { -4, -2, -2, -1, -1, -1 }, { -3, -1, -1, -1, -1, -1 }, { -1, -0, -0, -0, -0, -0 }, }; -const EB_S8 encMaxDeltaQpTab[4][MAX_TEMPORAL_LAYERS] = { +const EB_S8 EbHevcencMaxDeltaQpTab[4][MAX_TEMPORAL_LAYERS] = { { 4, 5, 5, 5, 5, 5 }, { 4, 5, 5, 5, 5, 5 }, { 4, 5, 5, 5, 5, 5 }, @@ -159,8 +159,8 @@ EB_ERRORTYPE EncDecContextCtor( // Mode Decision Context return_error = ModeDecisionContextCtor( - &contextPtr->mdContext, - 0, + &contextPtr->mdContext, + 0, 0, is16bit); if (return_error == EB_ErrorInsufficientResources){ @@ -506,7 +506,7 @@ static EB_ERRORTYPE ApplySaoOffsetsLcu( break; } - + return return_error; } @@ -560,7 +560,7 @@ static EB_ERRORTYPE ApplySaoOffsetsPicture( if (pictureControlSetPtr->saoFlag[0]) { lcuIndex = 0; - for (lcuNumberInHeight = 0; lcuNumberInHeight < pictureHeightInLcu; ++lcuNumberInHeight) { + for (lcuNumberInHeight = 0; lcuNumberInHeight < pictureHeightInLcu; ++lcuNumberInHeight) { for (lcuNumberInWidth = 0; lcuNumberInWidth < pictureWidthInLcu; ++lcuNumberInWidth, ++lcuIndex) { @@ -1048,7 +1048,7 @@ static EB_ERRORTYPE ApplySaoOffsetsLcu16bit( EB_ENC_SAO_ERROR1); break; } - + return return_error; } /******************************************** @@ -1118,7 +1118,7 @@ static EB_ERRORTYPE ApplySaoOffsetsPicture16bit( reconSampleYPtr = (EB_U16*)(recBuf16bit->bufferY) + reconSampleLumaIndex + (lcuHeight - 1)*recBuf16bit->strideY; //Save last pixel row of this LCU row for next LCU row - memcpy16bit(contextPtr->saoUpBuffer16[pingpongIdxUp], reconSampleYPtr, sequenceControlSetPtr->lumaWidth); + EbHevcmemcpy16bit(contextPtr->saoUpBuffer16[pingpongIdxUp], reconSampleYPtr, sequenceControlSetPtr->lumaWidth); } @@ -1187,7 +1187,7 @@ static EB_ERRORTYPE ApplySaoOffsetsPicture16bit( reconSampleCbPtr = (EB_U16*)(recBuf16bit->bufferCb) + reconSampleChromaIndex + (lcuHeight - 1)*recBuf16bit->strideCb; //Save last pixel row of this LCU row for next LCU row - memcpy16bit(contextPtr->saoUpBuffer16[pingpongIdxUp], reconSampleCbPtr, sequenceControlSetPtr->chromaWidth); + EbHevcmemcpy16bit(contextPtr->saoUpBuffer16[pingpongIdxUp], reconSampleCbPtr, sequenceControlSetPtr->chromaWidth); } //Save last pixel colunm of this LCU for next LCU @@ -1251,7 +1251,7 @@ static EB_ERRORTYPE ApplySaoOffsetsPicture16bit( reconSampleCrPtr = (EB_U16*)(recBuf16bit->bufferCr) + reconSampleChromaIndex + (lcuHeight - 1)*recBuf16bit->strideCr; //Save last pixel row of this LCU row for next LCU row - memcpy16bit(contextPtr->saoUpBuffer16[pingpongIdxUp], reconSampleCrPtr, sequenceControlSetPtr->chromaWidth); + EbHevcmemcpy16bit(contextPtr->saoUpBuffer16[pingpongIdxUp], reconSampleCrPtr, sequenceControlSetPtr->chromaWidth); } //Save last pixel colunm of this LCU for next LCU @@ -1364,7 +1364,7 @@ static void ResetEncDec( // QP contextPtr->qp = pictureControlSetPtr->pictureQp; - // Asuming cb and cr offset to be the same for chroma QP in both slice and pps for lambda computation + // Asuming cb and cr offset to be the same for chroma QP in both slice and pps for lambda computation EB_U8 qpScaled = CLIP3(MIN_QP_VALUE, MAX_CHROMA_MAP_QP_VALUE, (EB_S32)(contextPtr->qp + pictureControlSetPtr->cbQpOffset + pictureControlSetPtr->sliceCbQpOffset)); contextPtr->chromaQp = (EB_U8)MapChromaQp(qpScaled); @@ -1423,7 +1423,7 @@ static void ResetEncDec( if (contextPtr->mdContext->coeffCabacUpdate) { ContextModelEncContext_t *cabacCtxModelArray = (ContextModelEncContext_t*)sequenceControlSetPtr->encodeContextPtr->cabacContextModelArray; - // Increment the context model array pointer to point to the right address based on the QP and slice type + // Increment the context model array pointer to point to the right address based on the QP and slice type cabacCtxModelArray += pictureControlSetPtr->sliceType * TOTAL_NUMBER_OF_QP_VALUES + entropyCodingQp; //LatestValid <-- init @@ -1561,7 +1561,7 @@ static EB_BOOL AssignEncDecSegments( // The entire picture is provided by the MDC process, so // no logic is necessary to clear input dependencies. - // Start on Segment 0 immediately + // Start on Segment 0 immediately *segmentInOutIndex = segmentPtr->rowArray[0].currentSegIndex; taskPtr->inputType = ENCDEC_TASKS_CONTINUE; ++segmentPtr->rowArray[0].currentSegIndex; @@ -1679,7 +1679,7 @@ static void ReconOutput( const EB_U16 subHeightCMinus1 = (colorFormat >= EB_YUV422 ? 1 : 2) - 1; // Get Recon Buffer - EbGetEmptyObject( + EbGetEmptyObject( sequenceControlSetPtr->encodeContextPtr->reconOutputFifoPtr, &outputReconWrapperPtr); outputReconPtr = (EB_BUFFERHEADERTYPE*)outputReconWrapperPtr->objectPtr; @@ -1864,7 +1864,7 @@ static void PadRefAndSetFlags( refPic16BitPtr->width << (1 - subWidthCMinus1), refPic16BitPtr->height >> subHeightCMinus1, refPic16BitPtr->originX << (1 - subWidthCMinus1), - refPic16BitPtr->originY >> subHeightCMinus1); + refPic16BitPtr->originY >> subHeightCMinus1); } } @@ -1888,7 +1888,7 @@ static void CopyStatisticsToRefObject( EbReferenceObject_t * refObjL0, *refObjL1; ((EbReferenceObject_t*)pictureControlSetPtr->ParentPcsPtr->referencePictureWrapperPtr->objectPtr)->penalizeSkipflag = EB_FALSE; - if (pictureControlSetPtr->sliceType == EB_B_PICTURE){ + if (pictureControlSetPtr->sliceType == EB_B_PICTURE){ refObjL0 = (EbReferenceObject_t*)pictureControlSetPtr->refPicPtrArray[REF_LIST_0]->objectPtr; refObjL1 = (EbReferenceObject_t*)pictureControlSetPtr->refPicPtrArray[REF_LIST_1]->objectPtr; @@ -1913,8 +1913,8 @@ EB_ERRORTYPE QpmDeriveWeightsMinAndMax( { EB_ERRORTYPE return_error = EB_ErrorNone; EB_U32 cuDepth; - contextPtr->minDeltaQpWeight = encMinDeltaQpWeightTab[pictureControlSetPtr->temporalLayerIndex]; - contextPtr->maxDeltaQpWeight = encMaxDeltaQpWeightTab[pictureControlSetPtr->temporalLayerIndex]; + contextPtr->minDeltaQpWeight = EbHevcencMinDeltaQpWeightTab[pictureControlSetPtr->temporalLayerIndex]; + contextPtr->maxDeltaQpWeight = EbHevcencMaxDeltaQpWeightTab[pictureControlSetPtr->temporalLayerIndex]; //QpmDeriveDeltaQpMapWeights @@ -1955,15 +1955,15 @@ EB_ERRORTYPE QpmDeriveWeightsMinAndMax( } } - // Refine maxDeltaQpWeight; apply conservative max_degrade_weight when most of the picture is homogenous over time. + // Refine maxDeltaQpWeight; apply conservative max_degrade_weight when most of the picture is homogenous over time. if (pictureControlSetPtr->ParentPcsPtr->picHomogenousOverTimeLcuPercentage > 90) { contextPtr->maxDeltaQpWeight = contextPtr->maxDeltaQpWeight >> 1; } for (cuDepth = 0; cuDepth < 4; cuDepth++){ - contextPtr->minDeltaQp[cuDepth] = pictureControlSetPtr->sliceType == EB_I_PICTURE ? encMinDeltaQpISliceTab[cuDepth] : encMinDeltaQpTab[cuDepth][pictureControlSetPtr->temporalLayerIndex]; - contextPtr->maxDeltaQp[cuDepth] = encMaxDeltaQpTab[cuDepth][pictureControlSetPtr->temporalLayerIndex]; + contextPtr->minDeltaQp[cuDepth] = pictureControlSetPtr->sliceType == EB_I_PICTURE ? EbHevcencMinDeltaQpISliceTab[cuDepth] : EbHevcencMinDeltaQpTab[cuDepth][pictureControlSetPtr->temporalLayerIndex]; + contextPtr->maxDeltaQp[cuDepth] = EbHevcencMaxDeltaQpTab[cuDepth][pictureControlSetPtr->temporalLayerIndex]; } return return_error; @@ -1980,7 +1980,7 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( EncDecContext_t *contextPtr) { EB_ERRORTYPE return_error = EB_ErrorNone; - + // Set MD Open Loop Flag if (pictureControlSetPtr->encMode <= ENC_MODE_2) { contextPtr->mdContext->intraMdOpenLoopFlag = EB_FALSE; @@ -2004,8 +2004,8 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( } // Derive INTRA Injection Method // 0 : Default (OIS) - // 1 : Enhanced I_PICTURE, Default (OIS) otherwise - // 2 : 35 modes + // 1 : Enhanced I_PICTURE, Default (OIS) otherwise + // 2 : 35 modes if (pictureControlSetPtr->encMode <= ENC_MODE_2) { contextPtr->mdContext->intraInjectionMethod = 2; } @@ -2015,7 +2015,7 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( else { contextPtr->mdContext->intraInjectionMethod = 0; } - + // Derive Spatial SSE Flag if (pictureControlSetPtr->sliceType == EB_I_PICTURE && contextPtr->mdContext->intraMdOpenLoopFlag == EB_FALSE && pictureControlSetPtr->ParentPcsPtr->encMode <= ENC_MODE_2) { contextPtr->mdContext->spatialSseFullLoop = EB_TRUE; @@ -2023,7 +2023,7 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( else { contextPtr->mdContext->spatialSseFullLoop = EB_FALSE; } - + // Set Allow EncDec Mismatch Flag if (pictureControlSetPtr->ParentPcsPtr->encMode <= ENC_MODE_6) { contextPtr->allowEncDecMismatch = EB_FALSE; @@ -2046,7 +2046,7 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( // Set CHROMA Level // 0: Full Search Chroma for All LCUs - // 1: Best Search Chroma for All LCUs; Chroma OFF if I_PICTURE, Chroma for only MV_Merge if P/B_PICTURE + // 1: Best Search Chroma for All LCUs; Chroma OFF if I_PICTURE, Chroma for only MV_Merge if P/B_PICTURE // 2: Full vs. Best Swicth Method 0: chromaCond0 || chromaCond1 || chromaCond2 // 3: Full vs. Best Swicth Method 1: chromaCond0 || chromaCond1 // 4: Full vs. Best Swicth Method 2: chromaCond2 || chromaCond3 @@ -2112,7 +2112,7 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( else { contextPtr->mdContext->coeffCabacUpdate = EB_FALSE; } - + // Set INTRA8x8 Restriction @ P/B Slices if (pictureControlSetPtr->encMode <= ENC_MODE_3) { contextPtr->mdContext->intra8x8RestrictionInterSlice = EB_FALSE; @@ -2171,7 +2171,7 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( else { contextPtr->mdContext->amvpInjection = EB_FALSE; } - + // Set Unipred 3x3 Injection Flag if (pictureControlSetPtr->encMode <= ENC_MODE_1) { contextPtr->mdContext->unipred3x3Injection = EB_TRUE; @@ -2179,7 +2179,7 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( else { contextPtr->mdContext->unipred3x3Injection = EB_FALSE; } - + // Set Bipred 3x3 Injection Flag if (pictureControlSetPtr->encMode <= ENC_MODE_1) { contextPtr->mdContext->bipred3x3Injection = EB_TRUE; @@ -2201,11 +2201,11 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( // Set Fast EL Flag contextPtr->fastEl = (pictureControlSetPtr->encMode <= ENC_MODE_10) ? EB_FALSE : EB_TRUE; contextPtr->yBitsThsld = (pictureControlSetPtr->encMode <= ENC_MODE_10) ? YBITS_THSHLD_1(0) : YBITS_THSHLD_1(12); - + // Set SAO Mode contextPtr->saoMode = (pictureControlSetPtr->ParentPcsPtr->encMode <= ENC_MODE_10) ? 1 : 0; - - // Set Exit Partitioning Flag + + // Set Exit Partitioning Flag if (pictureControlSetPtr->encMode >= ENC_MODE_10) { if (sequenceControlSetPtr->inputResolution == INPUT_SIZE_4K_RANGE) { contextPtr->mdContext->enableExitPartitioning = EB_TRUE; @@ -2218,7 +2218,7 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( contextPtr->mdContext->enableExitPartitioning = EB_FALSE; } - // Set Limit INTRA Flag + // Set Limit INTRA Flag if (pictureControlSetPtr->encMode <= ENC_MODE_4) { contextPtr->mdContext->limitIntra = EB_FALSE; } @@ -2232,10 +2232,10 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( } // Set MPM Level - // Level Settings + // Level Settings // 0 Full MPM: 3 // 1 ON but 1 - // 2 OFF + // 2 OFF if (pictureControlSetPtr->encMode <= ENC_MODE_4) { contextPtr->mdContext->mpmLevel = 0; } @@ -2265,9 +2265,9 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( } // Set PF @ MD Level - // Level Settings + // Level Settings // 0 OFF - // 1 N2 + // 1 N2 // 2 M2 if 8x8 or 16x16 or Detector, N4 otherwise // 3 M2 if 8x8, N4 otherwise if (pictureControlSetPtr->encMode <= ENC_MODE_6) { @@ -2324,9 +2324,9 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( } // Set INTRA4x4 Search Level - // Level Settings - // 0 INLINE if not BDP, refinment otherwise - // 1 REFINMENT + // Level Settings + // 0 INLINE if not BDP, refinment otherwise + // 1 REFINMENT // 2 OFF if (pictureControlSetPtr->encMode <= ENC_MODE_2) { contextPtr->mdContext->intra4x4Level = 0; @@ -2342,7 +2342,7 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( else { contextPtr->mdContext->intra4x4Nfl = 2; } - + // Set INTRA4x4 Injection // 0: 35 mdoes // 1: up to 4: DC, Best INTR8x8, +3, -0 @@ -2483,14 +2483,14 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( // NFL Level Pillar/8x8 Refinement Settings // 0 4 // 1 4 if depthRefinment, 3 if 32x32, 2 otherwise - // 2 3 + // 2 3 // 3 3 if depthRefinment or 32x32, 2 otherwise // 4 3 if 32x32, 2 otherwise - // 5 2 + // 5 2 // 6 2 if Detectors, 1 otherwise // 7 2 if 64x64 or 32x32 or 16x16, 1 otherwise // 8 2 if 64x64 or 332x32, 1 otherwise - // 9 1 + // 9 1 if (pictureControlSetPtr->encMode <= ENC_MODE_2) { contextPtr->mdContext->nflLevelPillar8x8ref = 0; } @@ -2551,14 +2551,14 @@ static EB_ERRORTYPE SignalDerivationEncDecKernelOq( // NFL Level MvMerge/64x64 Refinement Settings // 0 4 - // 1 3 + // 1 3 // 2 3 if depthRefinment or 32x32, 2 otherwise // 3 3 if 32x32, 2 otherwise - // 4 2 + // 4 2 // 5 2 if Detectors, 1 otherwise // 6 2 if 64x64 or 32x32 or 16x16, 1 otherwise // 7 2 if 64x64 or 332x32, 1 otherwise - // 8 1 + // 8 1 if (pictureControlSetPtr->encMode <= ENC_MODE_2) { contextPtr->mdContext->nflLevelMvMerge64x64ref = 0; } @@ -2625,18 +2625,18 @@ void* EncDecKernel(void *inputPtr) PictureControlSet_t *pictureControlSetPtr; PictureParentControlSet_t *ppcsPtr; SequenceControlSet_t *sequenceControlSetPtr; - - // Input + + // Input EbObjectWrapper_t *encDecTasksWrapperPtr; EncDecTasks_t *encDecTasksPtr; - - // Output + + // Output EbObjectWrapper_t *encDecResultsWrapperPtr; EncDecResults_t *encDecResultsPtr; EbObjectWrapper_t *pictureDemuxResultsWrapperPtr; PictureDemuxResults_t *pictureDemuxResultsPtr; - - // LCU Loop variables + + // LCU Loop variables LargestCodingUnit_t *lcuPtr; EB_U16 lcuIndex; EB_U8 lcuSize; @@ -2655,8 +2655,8 @@ void* EncDecKernel(void *inputPtr) // Variables EB_BOOL enableSaoFlag = EB_TRUE; EB_BOOL is16bit; - - // Segments + + // Segments //EB_BOOL initialProcessCall; EB_U16 segmentIndex = 0; EB_U32 xLcuStartIndex; @@ -2713,7 +2713,7 @@ void* EncDecKernel(void *inputPtr) pictureControlSetPtr, contextPtr); - // Derive Interpoldation Method @ Fast-Loop + // Derive Interpoldation Method @ Fast-Loop contextPtr->mdContext->interpolationMethod = (pictureControlSetPtr->ParentPcsPtr->useSubpelFlag == EB_FALSE) ? INTERPOLATION_FREE_PATH : INTERPOLATION_METHOD_HEVC; @@ -2723,12 +2723,12 @@ void* EncDecKernel(void *inputPtr) PM_MODE_1: PM_MODE_0; - // Set Constrained INTRA Flag + // Set Constrained INTRA Flag pictureControlSetPtr->constrainedIntraFlag = (sequenceControlSetPtr->staticConfig.constrainedIntra == EB_TRUE && pictureControlSetPtr->ParentPcsPtr->isUsedAsReferenceFlag == EB_FALSE) ? EB_TRUE : EB_FALSE; - // Jing: Reset picture-wise parameters + // Jing: Reset picture-wise parameters EbBlockOnMutex(pictureControlSetPtr->intraMutex); if (!pictureControlSetPtr->resetDone) { pictureControlSetPtr->resetDone = EB_TRUE; @@ -2736,7 +2736,7 @@ void* EncDecKernel(void *inputPtr) EB_U16 tileCnt = pictureControlSetPtr->ParentPcsPtr->tileColumnCount * pictureControlSetPtr->ParentPcsPtr->tileRowCount; for (EB_U16 tileIdx = 0; tileIdx < tileCnt; tileIdx++) { - // MD neighbors + // MD neighbors ResetModeDecisionNeighborArrays(pictureControlSetPtr, tileIdx); ResetMdRefinmentNeighborArrays(pictureControlSetPtr, tileIdx); @@ -2802,7 +2802,7 @@ void* EncDecKernel(void *inputPtr) // Reset Coding Loop State - ProductResetModeDecision( // HT done + ProductResetModeDecision( // HT done contextPtr->mdContext, pictureControlSetPtr, sequenceControlSetPtr); @@ -2835,7 +2835,7 @@ void* EncDecKernel(void *inputPtr) lcuOriginX = (xLcuIndex+tileGroupLcuStartX) << lcuSizeLog2; lcuOriginY = (yLcuIndex+tileGroupLcuStartY) << lcuSizeLog2; //printf("Process lcu (%d, %d), lcuIndex %d, segmentIndex %d\n", lcuOriginX, lcuOriginY, lcuIndex, segmentIndex); - + // Set current LCU tile Index contextPtr->mdContext->tileIndex = lcuPtr->lcuEdgeInfoPtr->tileIndexInRaster; contextPtr->encDecTileIndex = lcuPtr->lcuEdgeInfoPtr->tileIndexInRaster; @@ -2867,9 +2867,9 @@ void* EncDecKernel(void *inputPtr) LcuParams_t * lcuParamPtr = &sequenceControlSetPtr->lcuParamsArray[lcuIndex]; - if ( - pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_FULL85_DEPTH_MODE || - pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_FULL84_DEPTH_MODE || + if ( + pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_FULL85_DEPTH_MODE || + pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_FULL84_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_OPEN_LOOP_DEPTH_MODE || (pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_LCU_SWITCH_DEPTH_MODE && (pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_FULL85_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_FULL84_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_LIGHT_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_AVC_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_LIGHT_AVC_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_PRED_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_PRED_OPEN_LOOP_1_NFL_DEPTH_MODE))) { @@ -2997,8 +2997,8 @@ void* EncDecKernel(void *inputPtr) xLcuStartIndex = (xLcuStartIndex > 0) ? xLcuStartIndex - 1 : 0; } - // Jing: Send to entropy at end of each segment (if tile line ends) - // Shall we + // Jing: Send to entropy at end of each segment (if tile line ends) + // Shall we // 1). consider the case that one segment will may cover 2 tiles? // 2). Or just assume segments is smaller than tiles // For simplicity just use the 2). assumption @@ -3160,9 +3160,9 @@ void* EncDecKernel(void *inputPtr) double latency = 0.0; EB_U64 finishTimeSeconds = 0; EB_U64 finishTimeuSeconds = 0; - EbFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); + EbHevcFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); - EbComputeOverallElapsedTimeMs( + EbHevcComputeOverallElapsedTimeMs( pictureControlSetPtr->ParentPcsPtr->startTimeSeconds, pictureControlSetPtr->ParentPcsPtr->startTimeuSeconds, finishTimeSeconds, diff --git a/Source/Lib/Codec/EbEncHandle.c b/Source/Lib/Codec/EbEncHandle.c index 41ee11645..9fb9d8a49 100644 --- a/Source/Lib/Codec/EbEncHandle.c +++ b/Source/Lib/Codec/EbEncHandle.c @@ -166,7 +166,7 @@ int CheckXcr0Ymm() #endif return ((xcr0 & 6) == 6); /* checking if xmm and ymm state are enabled in XCR0 */ } -EB_S32 Check4thGenIntelCoreFeatures() +static EB_S32 Check4thGenIntelCoreFeatures() { int abcd[4]; #define ECX_REG_FMA BIT(12) @@ -271,7 +271,7 @@ static EB_S32 CanUseIntelAVX512() // Returns ASM Type based on system configuration. AVX512 - 111, AVX2 - 011, NONAVX2 - 001, C - 000 // Using bit-fields, the fastest function will always be selected based on the available functions in the function arrays -EB_U32 GetCpuAsmType() +EB_U32 EbHevcGetCpuAsmType() { EB_U32 asmType = 0; @@ -292,7 +292,7 @@ EB_U32 GetCpuAsmType() } //Get Number of logical processors -EB_U32 GetNumProcessors() { +EB_U32 EbHevcGetNumProcessors() { #ifdef WIN32 SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); @@ -393,7 +393,7 @@ static EB_U32 EncDecPortTotalCount(void) return totalCount; } -EB_ERRORTYPE InitThreadManagmentParams(){ +EB_ERRORTYPE EbHevcInitThreadManagmentParams(){ #ifdef _WIN32 // Initialize groupAffinity structure with Current thread info GetThreadGroupAffinity(GetCurrentThread(),&groupAffinity); @@ -478,7 +478,7 @@ static EB_ERRORTYPE EbEncHandleCtor( return EB_ErrorInsufficientResources; } - return_error = InitThreadManagmentParams(); + return_error = EbHevcInitThreadManagmentParams(); if (return_error == EB_ErrorInsufficientResources) { return EB_ErrorInsufficientResources; } @@ -626,7 +626,7 @@ EB_U64 GetAffinityMask(EB_U32 lpnum) { } #endif -void SwitchToRealTime() +void EbHevcSwitchToRealTime() { #ifndef _WIN32 @@ -641,14 +641,14 @@ void SwitchToRealTime() #endif } -void EbSetThreadManagementParameters( +void EbHevcSetThreadManagementParameters( EB_H265_ENC_CONFIGURATION *configPtr) { if (configPtr->switchThreadsToRtPriority == 1) - SwitchToRealTime(); + EbHevcSwitchToRealTime(); #ifdef _WIN32 - EB_U32 numLogicProcessors = GetNumProcessors(); + EB_U32 numLogicProcessors = EbHevcGetNumProcessors(); // For system with a single processor group(no more than 64 logic processors all together) // Affinity of the thread can be set to one or more logical processors if (numGroups == 1) { @@ -682,7 +682,7 @@ void EbSetThreadManagementParameters( } } #elif defined(__linux__) - EB_U32 numLogicProcessors = GetNumProcessors(); + EB_U32 numLogicProcessors = EbHevcGetNumProcessors(); CPU_ZERO(&groupAffinity); if (numGroups == 1) { EB_U32 lps = configPtr->logicalProcessors == 0 ? numLogicProcessors: @@ -746,7 +746,7 @@ EB_API EB_ERRORTYPE EbInitEncoder(EB_COMPONENTTYPE *h265EncComponent) * Plateform detection ************************************/ if (encHandlePtr->sequenceControlSetInstanceArray[0]->sequenceControlSetPtr->staticConfig.asmType == EB_ASM_AUTO) { - ASM_TYPES = GetCpuAsmType(); // Use highest assembly + ASM_TYPES = EbHevcGetCpuAsmType(); // Use highest assembly } else if (encHandlePtr->sequenceControlSetInstanceArray[0]->sequenceControlSetPtr->staticConfig.asmType == EB_ASM_C) { ASM_TYPES = EB_ASM_C; // Use C_only @@ -1495,7 +1495,7 @@ EB_API EB_ERRORTYPE EbInitEncoder(EB_COMPONENTTYPE *h265EncComponent) ************************************/ EB_H265_ENC_CONFIGURATION *configPtr = &encHandlePtr->sequenceControlSetInstanceArray[0]->sequenceControlSetPtr->staticConfig; - EbSetThreadManagementParameters(configPtr); + EbHevcSetThreadManagementParameters(configPtr); // Resource Coordination EB_CREATETHREAD(EB_HANDLE, encHandlePtr->resourceCoordinationThreadHandle, sizeof(EB_HANDLE), EB_THREAD, ResourceCoordinationKernel, encHandlePtr->resourceCoordinationContextPtr); @@ -1787,7 +1787,7 @@ void LoadDefaultBufferConfigurationSettings( EB_U32 inputPic = SetParentPcs(&sequenceControlSetPtr->staticConfig); - unsigned int lpCount = GetNumProcessors(); + unsigned int lpCount = EbHevcGetNumProcessors(); unsigned int coreCount = lpCount; unsigned int totalThreadCount; @@ -2078,7 +2078,7 @@ EB_ERRORTYPE EbAppVideoUsabilityInfoInit( } // Set configurations for the hardcoded parameters -void SetDefaultConfigurationParameters( +void EbHevcSetDefaultConfigurationParameters( SequenceControlSet_t *sequenceControlSetPtr) { @@ -2115,7 +2115,7 @@ EB_U32 ComputeDefaultLookAhead( return lad; } -void SetParamBasedOnInput( +void EbHevcSetParamBasedOnInput( SequenceControlSet_t *sequenceControlSetPtr) { @@ -2192,7 +2192,7 @@ void SetParamBasedOnInput( } -void CopyApiFromApp( +void EbHevcCopyApiFromApp( SequenceControlSet_t *sequenceControlSetPtr, EB_H265_ENC_CONFIGURATION* pComponentParameterStructure ) @@ -3110,10 +3110,10 @@ EB_API EB_ERRORTYPE EbH265EncSetParameter( // Acquire Config Mutex EbBlockOnMutex(pEncCompData->sequenceControlSetInstanceArray[instanceIndex]->configMutex); - SetDefaultConfigurationParameters( + EbHevcSetDefaultConfigurationParameters( pEncCompData->sequenceControlSetInstanceArray[instanceIndex]->sequenceControlSetPtr); - CopyApiFromApp( + EbHevcCopyApiFromApp( pEncCompData->sequenceControlSetInstanceArray[instanceIndex]->sequenceControlSetPtr, (EB_H265_ENC_CONFIGURATION*)pComponentParameterStructure); @@ -3124,7 +3124,7 @@ EB_API EB_ERRORTYPE EbH265EncSetParameter( return EB_ErrorBadParameter; } - SetParamBasedOnInput( + EbHevcSetParamBasedOnInput( pEncCompData->sequenceControlSetInstanceArray[instanceIndex]->sequenceControlSetPtr); // Initialize the Prediction Structure Group diff --git a/Source/Lib/Codec/EbEntropyCoding.c b/Source/Lib/Codec/EbEntropyCoding.c index a32231955..0116b4cae 100644 --- a/Source/Lib/Codec/EbEntropyCoding.c +++ b/Source/Lib/Codec/EbEntropyCoding.c @@ -16,7 +16,7 @@ #include "EbErrorCodes.h" #include "EbErrorHandling.h" -// SSE2 Intrinsics +// SSE2 Intrinsics #include "emmintrin.h" /***************************** @@ -32,8 +32,8 @@ enum COEFF_SCAN_TYPE { SCAN_ZIGZAG = 0, // zigzag scan - SCAN_HOR, // first scan is horizontal - SCAN_VER, // first scan is vertical + SCAN_HOR, // first scan is horizontal + SCAN_VER, // first scan is vertical SCAN_DIAG // up-right diagonal scan }; @@ -41,7 +41,7 @@ enum COEFF_SCAN_TYPE /***************************** * Static consts *****************************/ -//LUT used for LPSxRange calculation +//LUT used for LPSxRange calculation static EB_U64 maxLumaPictureSize[TOTAL_LEVEL_COUNT] = { 36864U, 122880U, 245760U, 552960U, 983040U, 2228224U, 2228224U, 8912896U, 8912896U, 8912896U, 35651584U, 35651584U, 35651584U }; @@ -97,7 +97,7 @@ static void BacEncContextFinish(BacEncContext_t *bacEncContextPtr) /************************************************ * CABAC Encoder Constructor ************************************************/ -void CabacCtor( +void EbHevcCabacCtor( CabacEncodeContext_t *cabacEncContextPtr) { EB_MEMSET(cabacEncContextPtr, 0, sizeof(CabacEncodeContext_t)); @@ -522,7 +522,7 @@ static void EncodeIntraLumaModeFirstStage( lumaPredictionArray[1] = topNeighborMode; if (leftNeighborMode && topNeighborMode) { - lumaPredictionArray[2] = EB_INTRA_PLANAR; // when both modes are non planar + lumaPredictionArray[2] = EB_INTRA_PLANAR; // when both modes are non planar } else { lumaPredictionArray[2] = (leftNeighborMode + topNeighborMode) < 2 ? EB_INTRA_VERTICAL : EB_INTRA_DC; @@ -587,7 +587,7 @@ static void EncodeIntraLumaModeSecondStage( lumaPredictionArray[1] = topNeighborMode; if (leftNeighborMode && topNeighborMode) { - lumaPredictionArray[2] = EB_INTRA_PLANAR; // when both modes are non planar + lumaPredictionArray[2] = EB_INTRA_PLANAR; // when both modes are non planar } else { lumaPredictionArray[2] = (leftNeighborMode + topNeighborMode) < 2 ? EB_INTRA_VERTICAL : EB_INTRA_DC; @@ -1016,7 +1016,7 @@ EB_ERRORTYPE EncodeSaoOffsets( EB_U32 *saoType, EB_S32 *offset, EB_U32 bandPosition, - + EB_U8 bitdepth) { EB_ERRORTYPE return_error = EB_ErrorNone; @@ -1249,7 +1249,7 @@ void EncodeQuantizedCoefficients_generic( EB_S32 numCoeffWithCodedGt1Flag; // Number of coefficients for which >1 flag is coded - EB_U32 numNonZeroCoeffs = tuPtr->nzCoefCount[ (componentType == COMPONENT_LUMA) ? 0 : + EB_U32 numNonZeroCoeffs = tuPtr->nzCoefCount[ (componentType == COMPONENT_LUMA) ? 0 : (componentType == COMPONENT_CHROMA_CB) ? 1 : 2 ]; numNonZeroCoeffs = (componentType == COMPONENT_CHROMA_CB2) ? tuPtr->nzCoefCount2[0] : @@ -1359,7 +1359,7 @@ void EncodeQuantizedCoefficients_generic( if (type == INTRA_MODE) { // The test on partition size should be commented out to get conformance for Intra 4x4 ! - // if (partitionSize == SIZE_2Nx2N) To do - update asm + // if (partitionSize == SIZE_2Nx2N) To do - update asm { // note that for Intra 2Nx2N, each CU is one PU. So this mode is the same as // the mode of upper-left corner of current CU @@ -1900,14 +1900,14 @@ void EncodeQuantizedCoefficients_SSE2( EB_BOOL isCGin; - if(isChroma==EB_FALSE){ + if(isChroma==EB_FALSE){ isCGin = ((EB_U32)coeffGroupPositionY < (size >>(tuPtr->transCoeffShapeLuma+2))) && ((EB_U32)coeffGroupPositionX < (size >>(tuPtr->transCoeffShapeLuma+2))); }else{ isCGin = ((EB_U32)coeffGroupPositionY < (size >>(transCoeffShapeChroma+2))) && ((EB_U32)coeffGroupPositionX < (size >>(transCoeffShapeChroma+2))); } - + if(isCGin == EB_FALSE){ - + a0 = _mm_setzero_si128(); a1 = _mm_setzero_si128(); a2 = _mm_setzero_si128(); @@ -2913,7 +2913,7 @@ EB_ERRORTYPE EstimateQuantizedCoefficients_SSE2( // Loop over coefficients until base value of Exp-Golomb coding changes // Base value changes after either // - 8th coefficient - // - a coefficient larger than 1 + // - a coefficient larger than 1 for (index = 0; index < numCoeffWithCodedGt1Flag; index++) { @@ -3972,7 +3972,7 @@ EB_ERRORTYPE EstimateQuantizedCoefficients_generic( * pointer to the CABAC structure passed as input * *********************************************************************/ -// The functionality of coding delta Qp is implemented for HM 7.0 and needs to be updated for HM 8.0 +// The functionality of coding delta Qp is implemented for HM 7.0 and needs to be updated for HM 8.0 EB_ERRORTYPE EncodeDeltaQp( CabacEncodeContext_t *cabacEncodeCtxPtr, EB_S32 deltaQp) @@ -4245,7 +4245,7 @@ static EB_ERRORTYPE EncodeTuCoeff( subDivContext = 5 - Log2f(tuSize); if (GetCodedUnitStats(cuPtr->leafIndex)->size != 64) { - // Encode split flag + // Encode split flag EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), tuPtr->splitFlag, @@ -4255,13 +4255,13 @@ static EB_ERRORTYPE EncodeTuCoeff( if (tuPtr->splitFlag) { // Jing: only comes here for inter 64x64 - // Cb CBF + // Cb CBF EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), (tuPtr->cbCbf | tuPtr->cbCbf2), &(cabacEncodeCtxPtr->contextModelEncContext.cbfContextModel[cbfContext + NUMBER_OF_CBF_CONTEXT_MODELS])); - // Cr CBF + // Cr CBF EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), (tuPtr->crCbf | tuPtr->crCbf2), @@ -4278,7 +4278,7 @@ static EB_ERRORTYPE EncodeTuCoeff( if (GetCodedUnitStats(cuPtr->leafIndex)->size != 8) { subDivContext = 5 - Log2f(tuSize); - // Encode split flag + // Encode split flag EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), tuPtr->splitFlag, @@ -4290,7 +4290,7 @@ static EB_ERRORTYPE EncodeTuCoeff( cbfContext = tuPtr->chromaCbfContext; if (cuPtr->transformUnitArray[0].cbCbf | cuPtr->transformUnitArray[0].cbCbf2) { - // Cb CBF + // Cb CBF EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), tuPtr->cbCbf, @@ -4298,7 +4298,7 @@ static EB_ERRORTYPE EncodeTuCoeff( } if (cuPtr->transformUnitArray[0].crCbf | cuPtr->transformUnitArray[0].crCbf2){ - // Cr CBF + // Cr CBF EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), tuPtr->crCbf, @@ -4317,7 +4317,7 @@ static EB_ERRORTYPE EncodeTuCoeff( tuOriginX = TU_ORIGIN_ADJUST(cuStatsPtr->originX, cuStatsPtr->size, tuStatsPtr->offsetX); tuOriginY = TU_ORIGIN_ADJUST(cuStatsPtr->originY, cuStatsPtr->size, tuStatsPtr->offsetY); - // Cb CBF + // Cb CBF if ((cuPtr->transformUnitArray[tuIndex].cbCbf) && (tuSize != 8)){ EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), @@ -4325,7 +4325,7 @@ static EB_ERRORTYPE EncodeTuCoeff( &(cabacEncodeCtxPtr->contextModelEncContext.cbfContextModel[cbfContext + NUMBER_OF_CBF_CONTEXT_MODELS])); } - // Cr CBF + // Cr CBF if ((cuPtr->transformUnitArray[tuIndex].crCbf) && (tuSize != 8)){ EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), @@ -4368,7 +4368,7 @@ static EB_ERRORTYPE EncodeTuCoeff( tuOriginX = TU_ORIGIN_ADJUST(cuStatsPtr->originX, cuStatsPtr->size, tuStatsPtr->offsetX); tuOriginY = TU_ORIGIN_ADJUST(cuStatsPtr->originY, cuStatsPtr->size, tuStatsPtr->offsetY); - // Cb CBF + // Cb CBF if ((cuPtr->transformUnitArray[tuIndex].cbCbf) && (tuSize != 8)){ EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), @@ -4376,7 +4376,7 @@ static EB_ERRORTYPE EncodeTuCoeff( &(cabacEncodeCtxPtr->contextModelEncContext.cbfContextModel[cbfContext + NUMBER_OF_CBF_CONTEXT_MODELS])); } - // Cr CBF + // Cr CBF if ((cuPtr->transformUnitArray[tuIndex].crCbf) && (tuSize != 8)){ EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), @@ -4419,7 +4419,7 @@ static EB_ERRORTYPE EncodeTuCoeff( tuOriginX = TU_ORIGIN_ADJUST(cuStatsPtr->originX, cuStatsPtr->size, tuStatsPtr->offsetX); tuOriginY = TU_ORIGIN_ADJUST(cuStatsPtr->originY, cuStatsPtr->size, tuStatsPtr->offsetY); - // Cb CBF + // Cb CBF if ((cuPtr->transformUnitArray[tuIndex].cbCbf) && (tuSize != 8)){ EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), @@ -4427,7 +4427,7 @@ static EB_ERRORTYPE EncodeTuCoeff( &(cabacEncodeCtxPtr->contextModelEncContext.cbfContextModel[cbfContext + NUMBER_OF_CBF_CONTEXT_MODELS])); } - // Cr CBF + // Cr CBF if ((cuPtr->transformUnitArray[tuIndex].crCbf) && (tuSize != 8)){ EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), @@ -4461,7 +4461,7 @@ static EB_ERRORTYPE EncodeTuCoeff( tuIndexDepth2++; - + tuPtr = (tuIndexDepth2 < TRANSFORM_UNIT_MAX_COUNT) ? &cuPtr->transformUnitArray[tuIndexDepth2] : tuPtr; cbfContext = tuPtr->chromaCbfContext; @@ -4470,7 +4470,7 @@ static EB_ERRORTYPE EncodeTuCoeff( tuOriginX = TU_ORIGIN_ADJUST(cuStatsPtr->originX, cuStatsPtr->size, tuStatsPtr->offsetX); tuOriginY = TU_ORIGIN_ADJUST(cuStatsPtr->originY, cuStatsPtr->size, tuStatsPtr->offsetY); - // Cb CBF + // Cb CBF if ((cuPtr->transformUnitArray[tuIndex].cbCbf) && (tuSize != 8)) { EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), @@ -4478,7 +4478,7 @@ static EB_ERRORTYPE EncodeTuCoeff( &(cabacEncodeCtxPtr->contextModelEncContext.cbfContextModel[cbfContext + NUMBER_OF_CBF_CONTEXT_MODELS])); } - // Cr CBF + // Cr CBF if ((cuPtr->transformUnitArray[tuIndex].crCbf) && (tuSize != 8)){ EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), @@ -4516,7 +4516,7 @@ static EB_ERRORTYPE EncodeTuCoeff( cbfContext = tuPtr->chromaCbfContext; - // Cb CBF + // Cb CBF if (cuPtr->transformUnitArray[0].cbCbf | cuPtr->transformUnitArray[0].cbCbf2) { EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), @@ -4530,7 +4530,7 @@ static EB_ERRORTYPE EncodeTuCoeff( } } - // Cr CBF + // Cr CBF if (cuPtr->transformUnitArray[0].crCbf | cuPtr->transformUnitArray[0].crCbf2) { EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), @@ -4591,7 +4591,7 @@ static EB_ERRORTYPE EncodeTuCoeff( &(cabacEncodeCtxPtr->contextModelEncContext.cbfContextModel[cbfContext + NUMBER_OF_CBF_CONTEXT_MODELS])); } - // Cr CBF + // Cr CBF EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), tuPtr->crCbf, @@ -4666,8 +4666,8 @@ static EB_ERRORTYPE EncodeTuSplitCoeff( EB_U32 writtenBitsBeforeQuantizedCoeff; EB_U32 writtenBitsAfterQuantizedCoeff; - //store the number of written bits before coding quantized coeffs (flush is not called yet): - // The total number of bits is + //store the number of written bits before coding quantized coeffs (flush is not called yet): + // The total number of bits is // number of written bits // + 32 - bits remaining in interval Low Value // + number of buffered byte * 8 @@ -4695,8 +4695,8 @@ static EB_ERRORTYPE EncodeTuSplitCoeff( isdeltaQpNotCoded); } - //store the number of written bits after coding quantized coeffs (flush is not called yet): - // The total number of bits is + //store the number of written bits after coding quantized coeffs (flush is not called yet): + // The total number of bits is // number of written bits // + 32 - bits remaining in interval Low Value // + number of buffered byte * 8 @@ -4816,7 +4816,7 @@ static void CodeNALUnitHeader( //bsNALUHeader.write(nalu.m_temporalId+1, 3); // nuh_temporal_id_plus1 WriteCodeCavlc(bitstreamPtr, 0, 1); // forbidden_zero_bit - WriteCodeCavlc(bitstreamPtr, eNalUnitType, 6); // nal_unit_type + WriteCodeCavlc(bitstreamPtr, eNalUnitType, 6); // nal_unit_type WriteCodeCavlc(bitstreamPtr, 0, 6); // nuh_reserved_zero_6bits WriteCodeCavlc(bitstreamPtr, TemporalId + 1, 3); // nuh_temporal_id_plus1 @@ -5064,7 +5064,7 @@ EB_ERRORTYPE ComputeProfileTierLevelInfo( else if ((lumaSampleRate <= maxLumaSampleRate[2]) && (lumaPictureSize <= maxLumaPictureSize[2]) && (lumaWidthSquare <= maxLumaPictureSize[2] * 8) && (lumaHeightSquare <= maxLumaPictureSize[2] * 8)) scsPtr->levelIdc = 63;//2.1*30 else if ((lumaSampleRate <= maxLumaSampleRate[3]) && (lumaPictureSize <= maxLumaPictureSize[3]) && (lumaWidthSquare <= maxLumaPictureSize[3] * 8) && (lumaHeightSquare <= maxLumaPictureSize[3] * 8)) - scsPtr->levelIdc = 90;//3*30 + scsPtr->levelIdc = 90;//3*30 else if ((lumaSampleRate <= maxLumaSampleRate[4]) && (lumaPictureSize <= maxLumaPictureSize[4]) && (lumaWidthSquare <= maxLumaPictureSize[4] * 8) && (lumaHeightSquare <= maxLumaPictureSize[4] * 8)) scsPtr->levelIdc = 93;//3.1*30 else if ((lumaSampleRate <= maxLumaSampleRate[5]) && (lumaPictureSize <= maxLumaPictureSize[5]) && (lumaWidthSquare <= maxLumaPictureSize[5] * 8) && (lumaHeightSquare <= maxLumaPictureSize[5] * 8)) @@ -5119,7 +5119,7 @@ EB_ERRORTYPE ComputeProfileTierLevelInfo( } else if ((lumaSampleRate <= maxLumaSampleRate[3]) && (lumaPictureSize <= maxLumaPictureSize[3]) && (lumaWidthSquare <= maxLumaPictureSize[3] * 8) && (lumaHeightSquare <= maxLumaPictureSize[3] * 8) && ((scsPtr->staticConfig.targetBitRate * 2) <= highTierMaxBitrate[3]) && ((scsPtr->staticConfig.targetBitRate * 3) <= highTierMaxCPBsize[3])){ - scsPtr->levelIdc = 90;//3*30 + scsPtr->levelIdc = 90;//3*30 if (((scsPtr->staticConfig.targetBitRate * 2) <= mainTierMaxBitrate[3]) && ((scsPtr->staticConfig.targetBitRate * 3) <= mainTierMaxCPBsize[3])) scsPtr->tierIdc = 0; @@ -5470,12 +5470,12 @@ static void CodeVPS( 32); } - // vps_poc_proportional_to_timing_flag + // vps_poc_proportional_to_timing_flag WriteFlagCavlc( bitstreamPtr, 0); - // vps_num_hrd_parameters + // vps_num_hrd_parameters WriteUvlc( bitstreamPtr, 0); @@ -5625,7 +5625,7 @@ static void CodeHrdParameters( //CHECK_REPORT_ERROR( // (hrdParamterPtr->cpbCountMinus1[layerIndex] < MAX_CPB_COUNT), - // encodeContextPtr->appCallbackPtr, + // encodeContextPtr->appCallbackPtr, // EB_ENC_EC_ERROR14); for (cpbIndex = 0; cpbIndex <= hrdParamterPtr->cpbCountMinus1[layerIndex]; ++cpbIndex){ @@ -6008,7 +6008,7 @@ static void CodeSPS( } - // Luma Bit Increment + // Luma Bit Increment // "bit_depth_luma_minus8" WriteUvlc( bitstreamPtr, @@ -6346,7 +6346,7 @@ static void CodePPS( // "deblocking_filter_control_present_flag" WriteFlagCavlc( bitstreamPtr, - 1); + 1); //if(pcPPS->getDeblockingFilterControlPresentFlag()) { @@ -6453,10 +6453,10 @@ static void CodeSliceHeader( NalUnitType nalUnit = pcsPtr->ParentPcsPtr->nalUnit; - // here someone can add an appropriated NalRefIdc type + // here someone can add an appropriated NalRefIdc type //CodeNALUnitHeader (pcSlice->getNalUnitType(), NAL_REF_IDC_PRIORITY_HIGHEST, 1, true); - // *Note - there seems to be a bug with the temporal layers in the NALU or I don't + // *Note - there seems to be a bug with the temporal layers in the NALU or I don't // understand what the issue is. Hardcoding to 0 for now... // Note - The NAL unit type has to be more sophisticated than this @@ -6506,7 +6506,7 @@ static void CodeSliceHeader( // "slice_type" - // Slice Type + // Slice Type WriteUvlc( bitstreamPtr, sliceType); @@ -6886,7 +6886,7 @@ static void EntropyCodingUpdateQp( EB_U8 *prevCodedQp, EB_U8 *prevQuantGroupCodedQp, EB_U8 lcuQp, - + PictureControlSet_t *pictureControlSetPtr, EB_U32 pictureOriginX, EB_U32 pictureOriginY) @@ -7177,8 +7177,8 @@ static EB_ERRORTYPE Intra4x4EncodeCoeff( EB_BOOL sum_cbCbf; EB_BOOL sum_crCbf; - //store the number of written bits before coding quantized coeffs (flush is not called yet): - // The total number of bits is + //store the number of written bits before coding quantized coeffs (flush is not called yet): + // The total number of bits is // number of written bits // + 32 - bits remaining in interval Low Value // + number of buffered byte * 8 @@ -7216,7 +7216,7 @@ static EB_ERRORTYPE Intra4x4EncodeCoeff( (&cuPtr->transformUnitArray[3])->cbCbf, &(cabacEncodeCtxPtr->contextModelEncContext.cbfContextModel[cbfContext + NUMBER_OF_CBF_CONTEXT_MODELS])); } - // Cr CBF + // Cr CBF EncodeOneBin( &(cabacEncodeCtxPtr->bacEncContext), sum_crCbf, @@ -7293,7 +7293,7 @@ static EB_ERRORTYPE Intra4x4EncodeCoeff( } if (cabacEncodeCtxPtr->colorFormat != EB_YUV444) { - // Encode Chroma coeff for non-444 case, + // Encode Chroma coeff for non-444 case, // Jing TODO: see if can move to above loop tuStatsPtr = GetTransformUnitStats(1); tuOriginX = TU_ORIGIN_ADJUST(cuStatsPtr->originX, cuStatsPtr->size, tuStatsPtr->offsetX); @@ -7309,8 +7309,8 @@ static EB_ERRORTYPE Intra4x4EncodeCoeff( coeffPtr); } - //store the number of written bits after coding quantized coeffs (flush is not called yet): - // The total number of bits is + //store the number of written bits after coding quantized coeffs (flush is not called yet): + // The total number of bits is // number of written bits // + 32 - bits remaining in interval Low Value // + number of buffered byte * 8 @@ -7390,7 +7390,7 @@ EB_ERRORTYPE EncodeLcu( cuOriginY = lcuOriginY + cuStatsPtr->originY; cuDepth = (EB_U8)cuStatsPtr->depth; - // Code Split Flag + // Code Split Flag EncodeSplitFlag( cabacEncodeCtxPtr, cuDepth, @@ -7490,7 +7490,7 @@ EB_ERRORTYPE EncodeLcu( } switch (cuPtr->predictionModeFlag) { - case INTRA_MODE: + case INTRA_MODE: if (cuPtr->predictionModeFlag == INTRA_MODE && cuPtr->predictionUnitArray->intraLumaMode == EB_INTRA_MODE_4x4) { // Code Partition Size @@ -7502,7 +7502,7 @@ EB_ERRORTYPE EncodeLcu( // Get the PU Ptr puPtr = cuPtr->predictionUnitArray; - + EB_U8 partitionIndex; EB_U8 intraLumaLeftModeArray[4]; @@ -7531,7 +7531,7 @@ EB_ERRORTYPE EncodeLcu( intraLumaMode, modeTypeNeighborArray, intraLumaModeNeighborArray); - + intraLumaLeftModeArray[partitionIndex] = intraLumaLeftMode; intraLumaTopModeArray[partitionIndex] = intraLumaTopMode; @@ -7543,7 +7543,7 @@ EB_ERRORTYPE EncodeLcu( MIN_PU_SIZE, MIN_PU_SIZE, NEIGHBOR_ARRAY_UNIT_TOP_AND_LEFT_ONLY_MASK); - + NeighborArrayUnitModeWrite( modeTypeNeighborArray, &predictionModeFlag, @@ -7565,7 +7565,7 @@ EB_ERRORTYPE EncodeLcu( intraLumaTopModeArray[partitionIndex], intraLumaMode); } - + // Code Chroma Mode for Intra for (partitionIndex = 0; partitionIndex < ((cabacEncodeCtxPtr->colorFormat == EB_YUV444) ? 4 : 1); @@ -8067,7 +8067,7 @@ EB_ERRORTYPE TuEstimateCoeffBits_R( if (crCountNonZeroCoeffs) { - if (coeffCabacUpdate) + if (coeffCabacUpdate) EstimateQuantizedCoefficientsUpdate[!!(ASM_TYPES & PREAVX2_MASK)]( updatedCoeffCtxModel, CabacCost, @@ -8183,13 +8183,13 @@ EB_ERRORTYPE ResetEntropyCoder( CabacEncodeContext_t *cabacEncCtxPtr = (CabacEncodeContext_t*)entropyCoderPtr->cabacEncodeContextPtr; ContextModelEncContext_t *cabacCtxModelArray = (ContextModelEncContext_t*)encodeContextPtr->cabacContextModelArray; - // Increment the context model array pointer to point to the right address based on the QP and slice type + // Increment the context model array pointer to point to the right address based on the QP and slice type cabacCtxModelArray += sliceType * TOTAL_NUMBER_OF_QP_VALUES + qp; // Reset context models to initial values by copying from cabacContextModelArray EB_MEMCPY(&(cabacEncCtxPtr->contextModelEncContext.splitFlagContextModel[0]), &(cabacCtxModelArray->splitFlagContextModel[0]), sizeof(EB_ContextModel)* TOTAL_NUMBER_OF_CABAC_CONTEXT_MODELS); - // Reset Binary Arithmetic Coder (BAC) to initial values + // Reset Binary Arithmetic Coder (BAC) to initial values ResetBacEnc( &(cabacEncCtxPtr->bacEncContext)); @@ -8646,7 +8646,7 @@ EB_ERRORTYPE EncodePictureTimingSEI( pictStruct); - // Byte Align the Bitstream + // Byte Align the Bitstream OutputBitstreamWrite( outputBitstreamPtr, 1, @@ -8710,7 +8710,7 @@ EB_ERRORTYPE EncodeBufferingPeriodSEI( vuiPtr, encodeContextPtr); - // Byte Align the Bitstream + // Byte Align the Bitstream OutputBitstreamWrite( outputBitstreamPtr, 1, @@ -8857,7 +8857,7 @@ EB_ERRORTYPE EncodeRegUserDataSEI( } } - // Byte Align the Bitstream + // Byte Align the Bitstream OutputBitstreamWrite( outputBitstreamPtr, 1, @@ -8945,7 +8945,7 @@ EB_ERRORTYPE EncodeUnregUserDataSEI( } } - // Byte Align the Bitstream + // Byte Align the Bitstream OutputBitstreamWrite( outputBitstreamPtr, 1, @@ -9028,7 +9028,7 @@ EB_ERRORTYPE EncodeRecoveryPointSEI( } } - // Byte Align the Bitstream + // Byte Align the Bitstream OutputBitstreamWrite( outputBitstreamPtr, 1, @@ -9295,7 +9295,7 @@ EB_ERRORTYPE BitstreamCtor( } - + EB_ERRORTYPE EntropyCoderCtor( EntropyCoder_t **entropyCoderDblPtr, @@ -9306,7 +9306,7 @@ EB_ERRORTYPE EntropyCoderCtor( EB_MALLOC(EB_PTR, (*entropyCoderDblPtr)->cabacEncodeContextPtr, sizeof(CabacEncodeContext_t), EB_N_PTR); - CabacCtor( + EbHevcCabacCtor( (CabacEncodeContext_t *)(*entropyCoderDblPtr)->cabacEncodeContextPtr); @@ -9760,11 +9760,11 @@ EB_ERRORTYPE EstimateQuantizedCoefficients_Update_SSE2( numCoeffWithCodedGt1Flag = MIN(GREATER_THAN1_MAX_NUMBER, numNonZero); coeffBits += ONE_BIT * numNonZero; // Add bits for coeff_sign_flag (all coefficients in subblock) - + // Loop over coefficients until base value of Exp-Golomb coding changes // Base value changes after either // - 8th coefficient - // - a coefficient larger than 1 + // - a coefficient larger than 1 for (index = 0; index < numCoeffWithCodedGt1Flag; index++) { diff --git a/Source/Lib/Codec/EbInitialRateControlProcess.c b/Source/Lib/Codec/EbInitialRateControlProcess.c index 5ba8f4e82..6cb33be4d 100644 --- a/Source/Lib/Codec/EbInitialRateControlProcess.c +++ b/Source/Lib/Codec/EbInitialRateControlProcess.c @@ -33,9 +33,9 @@ static EB_BOOL CheckMvForPanHighAmp( EB_S32 *xCurrentMv, EB_S32 *xCandidateMv) { - if (*xCurrentMv * *xCandidateMv > 0 // both negative or both positives and both different than 0 i.e. same direction and non Stationary) - && ABS(*xCurrentMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude - && ABS(*xCandidateMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude + if (*xCurrentMv * *xCandidateMv > 0 // both negative or both positives and both different than 0 i.e. same direction and non Stationary) + && ABS(*xCurrentMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude + && ABS(*xCandidateMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude && ABS(*xCurrentMv - *xCandidateMv) < LOW_AMPLITUDE_TH) { // close amplitude return(EB_TRUE); @@ -53,9 +53,9 @@ static EB_BOOL CheckMvForTiltHighAmp( EB_S32 *yCurrentMv, EB_S32 *yCandidateMv) { - if (*yCurrentMv * *yCandidateMv > 0 // both negative or both positives and both different than 0 i.e. same direction and non Stationary) - && ABS(*yCurrentMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude - && ABS(*yCandidateMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude + if (*yCurrentMv * *yCandidateMv > 0 // both negative or both positives and both different than 0 i.e. same direction and non Stationary) + && ABS(*yCurrentMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude + && ABS(*yCandidateMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude && ABS(*yCurrentMv - *yCandidateMv) < LOW_AMPLITUDE_TH) { // close amplitude return(EB_TRUE); @@ -77,9 +77,9 @@ static EB_BOOL CheckMvForPan( { if (*yCurrentMv < LOW_AMPLITUDE_TH && *yCandidateMv < LOW_AMPLITUDE_TH - && *xCurrentMv * *xCandidateMv > 0 // both negative or both positives and both different than 0 i.e. same direction and non Stationary) - && ABS(*xCurrentMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude - && ABS(*xCandidateMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude + && *xCurrentMv * *xCandidateMv > 0 // both negative or both positives and both different than 0 i.e. same direction and non Stationary) + && ABS(*xCurrentMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude + && ABS(*xCandidateMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude && ABS(*xCurrentMv - *xCandidateMv) < LOW_AMPLITUDE_TH) { // close amplitude return(EB_TRUE); @@ -101,9 +101,9 @@ static EB_BOOL CheckMvForTilt( { if (*xCurrentMv < LOW_AMPLITUDE_TH && *xCandidateMv < LOW_AMPLITUDE_TH - && *yCurrentMv * *yCandidateMv > 0 // both negative or both positives and both different than 0 i.e. same direction and non Stationary) - && ABS(*yCurrentMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude - && ABS(*yCandidateMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude + && *yCurrentMv * *yCandidateMv > 0 // both negative or both positives and both different than 0 i.e. same direction and non Stationary) + && ABS(*yCurrentMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude + && ABS(*yCandidateMv) >= GLOBAL_MOTION_THRESHOLD[hierarchicalLevels][temporalLayerIndex] // high amplitude && ABS(*yCurrentMv - *yCandidateMv) < LOW_AMPLITUDE_TH) { // close amplitude return(EB_TRUE); @@ -164,49 +164,49 @@ static void CheckForNonUniformMotionVectorField( if (lcuParams->isCompleteLcu) { - // Current MV - GetMv(pictureControlSetPtr, lcuIndex, &xCurrentMv, &yCurrentMv); + // Current MV + EbHevcGetMv(pictureControlSetPtr, lcuIndex, &xCurrentMv, &yCurrentMv); - // Left MV + // Left MV if (lcuOriginX == 0) { xLeftMv = 0; yLeftMv = 0; } else { - GetMv(pictureControlSetPtr, lcuIndex - 1, &xLeftMv, &yLeftMv); + EbHevcGetMv(pictureControlSetPtr, lcuIndex - 1, &xLeftMv, &yLeftMv); } countOfNonUniformNeighbors += CheckMvForNonUniformMotion(&xCurrentMv, &yCurrentMv, &xLeftMv, &yLeftMv); - // Top MV + // Top MV if (lcuOriginY == 0) { xTopMv = 0; yTopMv = 0; } else { - GetMv(pictureControlSetPtr, lcuIndex - pictureWidthInLcu, &xTopMv, &yTopMv); + EbHevcGetMv(pictureControlSetPtr, lcuIndex - pictureWidthInLcu, &xTopMv, &yTopMv); } countOfNonUniformNeighbors += CheckMvForNonUniformMotion(&xCurrentMv, &yCurrentMv, &xTopMv, &yTopMv); - // Right MV + // Right MV if ((lcuOriginX + (MAX_LCU_SIZE << 1)) > pictureControlSetPtr->enhancedPicturePtr->width) { xRightMv = 0; yRightMv = 0; } else { - GetMv(pictureControlSetPtr, lcuIndex + 1, &xRightMv, &yRightMv); + EbHevcGetMv(pictureControlSetPtr, lcuIndex + 1, &xRightMv, &yRightMv); } countOfNonUniformNeighbors += CheckMvForNonUniformMotion(&xCurrentMv, &yCurrentMv, &xRightMv, &yRightMv); - // Bottom MV + // Bottom MV if ((lcuOriginY + (MAX_LCU_SIZE << 1)) > pictureControlSetPtr->enhancedPicturePtr->height) { xBottomMv = 0; yBottomMv = 0; } else { - GetMv(pictureControlSetPtr, lcuIndex + pictureWidthInLcu, &xBottomMv, &yBottomMv); + EbHevcGetMv(pictureControlSetPtr, lcuIndex + pictureWidthInLcu, &xBottomMv, &yBottomMv); } countOfNonUniformNeighbors += CheckMvForNonUniformMotion(&xCurrentMv, &yCurrentMv, &xBottomMv, &yBottomMv); @@ -215,7 +215,7 @@ static void CheckForNonUniformMotionVectorField( } -void DetectGlobalMotion( +void EbHevcDetectGlobalMotion( SequenceControlSet_t *sequenceControlSetPtr, PictureParentControlSet_t *pictureControlSetPtr) { @@ -252,45 +252,45 @@ void DetectGlobalMotion( lcuOriginX = lcuParams->originX; lcuOriginY = lcuParams->originY; - if (lcuParams->isCompleteLcu) { + if (lcuParams->isCompleteLcu) { - // Current MV - GetMv(pictureControlSetPtr, lcuIndex, &xCurrentMv, &yCurrentMv); + // Current MV + EbHevcGetMv(pictureControlSetPtr, lcuIndex, &xCurrentMv, &yCurrentMv); - // Left MV + // Left MV if (lcuOriginX == 0) { xLeftMv = 0; yLeftMv = 0; } else { - GetMv(pictureControlSetPtr, lcuIndex - 1, &xLeftMv, &yLeftMv); + EbHevcGetMv(pictureControlSetPtr, lcuIndex - 1, &xLeftMv, &yLeftMv); } - // Top MV + // Top MV if (lcuOriginY == 0) { xTopMv = 0; yTopMv = 0; } else { - GetMv(pictureControlSetPtr, lcuIndex - pictureWidthInLcu, &xTopMv, &yTopMv); + EbHevcGetMv(pictureControlSetPtr, lcuIndex - pictureWidthInLcu, &xTopMv, &yTopMv); } - // Right MV + // Right MV if ((lcuOriginX + (MAX_LCU_SIZE << 1)) > pictureControlSetPtr->enhancedPicturePtr->width) { xRightMv = 0; yRightMv = 0; } else { - GetMv(pictureControlSetPtr, lcuIndex + 1, &xRightMv, &yRightMv); + EbHevcGetMv(pictureControlSetPtr, lcuIndex + 1, &xRightMv, &yRightMv); } - // Bottom MV + // Bottom MV if ((lcuOriginY + (MAX_LCU_SIZE << 1)) > pictureControlSetPtr->enhancedPicturePtr->height) { xBottomMv = 0; yBottomMv = 0; } else { - GetMv(pictureControlSetPtr, lcuIndex + pictureWidthInLcu, &xBottomMv, &yBottomMv); + EbHevcGetMv(pictureControlSetPtr, lcuIndex + pictureWidthInLcu, &xBottomMv, &yBottomMv); } totalCheckedLcus++; @@ -375,7 +375,7 @@ EB_ERRORTYPE InitialRateControlContextCtor( ** Check if reference pictures are needed ** release them when appropriate ************************************************/ -void ReleasePaReferenceObjects( +void EbHevcReleasePaReferenceObjects( PictureParentControlSet_t *pictureControlSetPtr) { // PA Reference Pictures @@ -385,7 +385,7 @@ void ReleasePaReferenceObjects( numOfListToSearch = (pictureControlSetPtr->sliceType == EB_P_PICTURE) ? REF_LIST_0 : REF_LIST_1; - // List Loop + // List Loop for (listIndex = REF_LIST_0; listIndex <= numOfListToSearch; ++listIndex) { // Release PA Reference Pictures @@ -398,11 +398,11 @@ void ReleasePaReferenceObjects( } if (pictureControlSetPtr->paReferencePictureWrapperPtr != EB_NULL) { - + EbReleaseObject(pictureControlSetPtr->pPcsWrapperPtr); EbReleaseObject(pictureControlSetPtr->paReferencePictureWrapperPtr); } - + return; } @@ -412,7 +412,7 @@ void ReleasePaReferenceObjects( ** Mark pictures for tilt ** No lookahead information used in this function ************************************************/ -void MeBasedGlobalMotionDetection( +void EbHevcMeBasedGlobalMotionDetection( SequenceControlSet_t *sequenceControlSetPtr, PictureParentControlSet_t *pictureControlSetPtr) { @@ -421,7 +421,7 @@ void MeBasedGlobalMotionDetection( pictureControlSetPtr->isTilt = EB_FALSE; if (pictureControlSetPtr->sliceType != EB_I_PICTURE) { - DetectGlobalMotion( + EbHevcDetectGlobalMotion( sequenceControlSetPtr, pictureControlSetPtr); } @@ -430,7 +430,7 @@ void MeBasedGlobalMotionDetection( } -void StationaryEdgeCountLcu( +void EbHevcStationaryEdgeCountLcu( SequenceControlSet_t *sequenceControlSetPtr, PictureParentControlSet_t *pictureControlSetPtr, PictureParentControlSet_t *temporalPictureControlSetPtr, @@ -477,7 +477,7 @@ void StationaryEdgeCountLcu( ** Mark pictures for tilt ** LAD Window: min (8 or sliding window size) ************************************************/ -void UpdateGlobalMotionDetectionOverTime( +void EbHevcUpdateGlobalMotionDetectionOverTime( EncodeContext_t *encodeContextPtr, SequenceControlSet_t *sequenceControlSetPtr, PictureParentControlSet_t *pictureControlSetPtr) @@ -555,7 +555,7 @@ void UpdateGlobalMotionDetectionOverTime( ** LAD Window: min (2xmgpos+1 or sliding window size) ************************************************/ -void UpdateBeaInfoOverTime( +void EbHevcUpdateBeaInfoOverTime( EncodeContext_t *encodeContextPtr, PictureParentControlSet_t *pictureControlSetPtr) { @@ -609,7 +609,7 @@ void UpdateBeaInfoOverTime( * Init ZZ Cost array to default values ** Used when no Lookahead is available ****************************************/ -void InitZzCostInfo( +void EbHevcInitZzCostInfo( PictureParentControlSet_t *pictureControlSetPtr) { EB_U16 lcuIdx; @@ -634,7 +634,7 @@ void InitZzCostInfo( ** collocated LCUs infor in lookahead pictures ** LAD Window: min (2xmgpos+1 or sliding window size) ************************************************/ -void UpdateMotionFieldUniformityOverTime( +void EbHevcUpdateMotionFieldUniformityOverTime( EncodeContext_t *encodeContextPtr, SequenceControlSet_t *sequenceControlSetPtr, PictureParentControlSet_t *pictureControlSetPtr) @@ -662,7 +662,7 @@ void UpdateMotionFieldUniformityOverTime( } // The values are calculated for every 4th frame if ((temporaryPictureControlSetPtr->pictureNumber & 3) == 0){ - StationaryEdgeCountLcu( + EbHevcStationaryEdgeCountLcu( sequenceControlSetPtr, pictureControlSetPtr, temporaryPictureControlSetPtr, @@ -708,7 +708,7 @@ void UpdateHomogeneityOverTime( meanSqrvariance64x64Based = 0; meanvariance64x64Based = 0; - // Initialize + // Initialize pictureControlSetPtr->lcuVarianceOfVarianceOverTime[lcuIdx] = 0xFFFFFFFFFFFFFFFF; pictureControlSetPtr->isLcuHomogeneousOverTime[lcuIdx] = EB_FALSE; @@ -767,7 +767,7 @@ void ResetHomogeneityStructures( pictureControlSetPtr->picHomogenousOverTimeLcuPercentage = 0; - // Reset the structure + // Reset the structure for (lcuIdx = 0; lcuIdx < pictureControlSetPtr->lcuTotalCount; ++lcuIdx) { pictureControlSetPtr->lcuVarianceOfVarianceOverTime[lcuIdx] = 0xFFFFFFFFFFFFFFFF; pictureControlSetPtr->isLcuHomogeneousOverTime[lcuIdx] = EB_FALSE; @@ -776,7 +776,7 @@ void ResetHomogeneityStructures( return; } -InitialRateControlReorderEntry_t * DeterminePictureOffsetInQueue( +InitialRateControlReorderEntry_t * EbHevcDeterminePictureOffsetInQueue( EncodeContext_t *encodeContextPtr, PictureParentControlSet_t *pictureControlSetPtr, MotionEstimationResults_t *inputResultsPtr) @@ -797,7 +797,7 @@ InitialRateControlReorderEntry_t * DeterminePictureOffsetInQueue( return queueEntryPtr; } -void GetHistogramQueueData( +void EbHevcGetHistogramQueueData( SequenceControlSet_t *sequenceControlSetPtr, EncodeContext_t *encodeContextPtr, PictureParentControlSet_t *pictureControlSetPtr) @@ -805,7 +805,7 @@ void GetHistogramQueueData( HlRateControlHistogramEntry_t *histogramQueueEntryPtr; EB_S32 histogramQueueEntryIndex; - // Determine offset from the Head Ptr for HLRC histogram queue + // Determine offset from the Head Ptr for HLRC histogram queue EbBlockOnMutex(sequenceControlSetPtr->encodeContextPtr->hlRateControlHistorgramQueueMutex); histogramQueueEntryIndex = (EB_S32)(pictureControlSetPtr->pictureNumber - encodeContextPtr->hlRateControlHistorgramQueue[encodeContextPtr->hlRateControlHistorgramQueueHeadIndex]->pictureNumber); histogramQueueEntryIndex += encodeContextPtr->hlRateControlHistorgramQueueHeadIndex; @@ -843,7 +843,7 @@ void GetHistogramQueueData( } -void UpdateHistogramQueueEntry( +void EbHevcUpdateHistogramQueueEntry( SequenceControlSet_t *sequenceControlSetPtr, EncodeContext_t *encodeContextPtr, PictureParentControlSet_t *pictureControlSetPtr) @@ -927,20 +927,20 @@ void* InitialRateControlKernel(void *inputPtr) // Mark picture when global motion is detected using ME results //reset intraCodedEstimationLcu - MeBasedGlobalMotionDetection( + EbHevcMeBasedGlobalMotionDetection( sequenceControlSetPtr, pictureControlSetPtr); - // Release Pa Ref pictures when not needed - ReleasePaReferenceObjects( + // Release Pa Ref pictures when not needed + EbHevcReleasePaReferenceObjects( pictureControlSetPtr); //**************************************************** // Input Motion Analysis Results into Reordering Queue //**************************************************** - // Determine offset from the Head Ptr - queueEntryPtr = DeterminePictureOffsetInQueue( + // Determine offset from the Head Ptr + queueEntryPtr = EbHevcDeterminePictureOffsetInQueue( encodeContextPtr, pictureControlSetPtr, inputResultsPtr); @@ -949,8 +949,8 @@ void* InitialRateControlKernel(void *inputPtr) { if (sequenceControlSetPtr->staticConfig.lookAheadDistance != 0){ - // Getting the Histogram Queue Data - GetHistogramQueueData( + // Getting the Histogram Queue Data + EbHevcGetHistogramQueueData( sequenceControlSetPtr, encodeContextPtr, pictureControlSetPtr); @@ -964,7 +964,7 @@ void* InitialRateControlKernel(void *inputPtr) pictureControlSetPtr->framesInSw = 0; pictureControlSetPtr->historgramLifeCount = 0; pictureControlSetPtr->sceneChangeInGop = EB_FALSE; - + moveSlideWondowFlag = EB_TRUE; while (moveSlideWondowFlag){ @@ -1025,7 +1025,7 @@ void* InitialRateControlKernel(void *inputPtr) queueEntryIndexTemp++; } - + if ((sequenceControlSetPtr->staticConfig.lookAheadDistance != 0) && (framesInSw < (sequenceControlSetPtr->staticConfig.lookAheadDistance + 1))) pictureControlSetPtr->endOfSequenceRegion = EB_TRUE; @@ -1038,7 +1038,7 @@ void* InitialRateControlKernel(void *inputPtr) if (sequenceControlSetPtr->staticConfig.lookAheadDistance != 0){ // Update Histogram Queue Entry Life count - UpdateHistogramQueueEntry( + EbHevcUpdateHistogramQueueEntry( sequenceControlSetPtr, encodeContextPtr, pictureControlSetPtr); @@ -1050,30 +1050,30 @@ void* InitialRateControlKernel(void *inputPtr) if (!pictureControlSetPtr->endOfSequenceFlag && sequenceControlSetPtr->staticConfig.lookAheadDistance != 0) { // Check for Pan,Tilt, Zoom and other global motion detectors over the future pictures in the lookahead - UpdateGlobalMotionDetectionOverTime( + EbHevcUpdateGlobalMotionDetectionOverTime( encodeContextPtr, sequenceControlSetPtr, pictureControlSetPtr); } else { if (pictureControlSetPtr->sliceType != EB_I_PICTURE) { - DetectGlobalMotion( - sequenceControlSetPtr, + EbHevcDetectGlobalMotion( + sequenceControlSetPtr, pictureControlSetPtr); } } - // BACKGROUND ENHANCEMENT PART II + // BACKGROUND ENHANCEMENT PART II if (!pictureControlSetPtr->endOfSequenceFlag && sequenceControlSetPtr->staticConfig.lookAheadDistance != 0) { // Update BEA information based on Lookahead information - UpdateBeaInfoOverTime( + EbHevcUpdateBeaInfoOverTime( encodeContextPtr, pictureControlSetPtr); } else { // Reset zzCost information to default When there's no lookahead available - InitZzCostInfo( + EbHevcInitZzCostInfo( pictureControlSetPtr); } @@ -1081,7 +1081,7 @@ void* InitialRateControlKernel(void *inputPtr) if (!pictureControlSetPtr->endOfSequenceFlag && sequenceControlSetPtr->staticConfig.lookAheadDistance != 0) { // Updat uniformly moving LCUs based on Collocated LCUs in LookAhead window - UpdateMotionFieldUniformityOverTime( + EbHevcUpdateMotionFieldUniformityOverTime( encodeContextPtr, sequenceControlSetPtr, pictureControlSetPtr); @@ -1115,7 +1115,7 @@ void* InitialRateControlKernel(void *inputPtr) sequenceControlSetPtr->encodeContextPtr->streamOutputFifoPtr, &outputStreamWrapperPtr); - pictureControlSetPtr->outputStreamWrapperPtr = outputStreamWrapperPtr; + pictureControlSetPtr->outputStreamWrapperPtr = outputStreamWrapperPtr; // Get Empty Results Object EbGetEmptyObject( @@ -1131,9 +1131,9 @@ void* InitialRateControlKernel(void *inputPtr) double latency = 0.0; EB_U64 finishTimeSeconds = 0; EB_U64 finishTimeuSeconds = 0; - EbFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); + EbHevcFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); - EbComputeOverallElapsedTimeMs( + EbHevcComputeOverallElapsedTimeMs( pictureControlSetPtr->startTimeSeconds, pictureControlSetPtr->startTimeuSeconds, finishTimeSeconds, @@ -1167,4 +1167,3 @@ void* InitialRateControlKernel(void *inputPtr) } return EB_NULL; } - diff --git a/Source/Lib/Codec/EbInitialRateControlProcess.h b/Source/Lib/Codec/EbInitialRateControlProcess.h index 2bd9051ba..e4443c18f 100644 --- a/Source/Lib/Codec/EbInitialRateControlProcess.h +++ b/Source/Lib/Codec/EbInitialRateControlProcess.h @@ -18,7 +18,7 @@ extern "C" { * Context **************************************/ typedef struct InitialRateControlContext_s -{ +{ EbFifo_t *motionEstimationResultsInputFifoPtr; EbFifo_t *initialrateControlResultsOutputFifoPtr; @@ -31,10 +31,10 @@ extern EB_ERRORTYPE InitialRateControlContextCtor( InitialRateControlContext_t **contextDblPtr, EbFifo_t *motionEstimationResultsInputFifoPtr, EbFifo_t *pictureDemuxResultsOutputFifoPtr); - + extern void* InitialRateControlKernel(void *inputPtr); -extern void MeBasedGlobalMotionDetection( +extern void EbHevcMeBasedGlobalMotionDetection( SequenceControlSet_t *sequenceControlSetPtr, PictureParentControlSet_t *pictureControlSetPtr); diff --git a/Source/Lib/Codec/EbIntraPrediction.c b/Source/Lib/Codec/EbIntraPrediction.c index 1816f1dc8..26213895e 100644 --- a/Source/Lib/Codec/EbIntraPrediction.c +++ b/Source/Lib/Codec/EbIntraPrediction.c @@ -86,7 +86,7 @@ EB_ERRORTYPE IntraReferenceSamplesCtor(IntraReferenceSamples_t **contextDblPtr, EB_MALLOC(EB_U8*, contextPtr->crIntraReferenceArray, sizeof(EB_U8) * (4 * MAX_LCU_SIZE + 1), EB_N_PTR); EB_MALLOC(EB_U8*, contextPtr->yIntraFilteredReferenceArray, sizeof(EB_U8) * (4 * MAX_LCU_SIZE + 1), EB_N_PTR); - + EB_MALLOC(EB_U8*, contextPtr->yIntraReferenceArrayReverse, sizeof(EB_U8) * (4 * MAX_LCU_SIZE + 2), EB_N_PTR); EB_MALLOC(EB_U8*, contextPtr->yIntraFilteredReferenceArrayReverse, sizeof(EB_U8) * (4 * MAX_LCU_SIZE + 2), EB_N_PTR); @@ -127,7 +127,7 @@ EB_ERRORTYPE IntraReference16bitSamplesCtor( IntraReference16bitSamples_t *contextPtr; EB_MALLOC(IntraReference16bitSamples_t*, contextPtr, sizeof(IntraReference16bitSamples_t), EB_N_PTR); *contextDblPtr = contextPtr; - + EB_MALLOC(EB_U16*, contextPtr->yIntraReferenceArray, sizeof(EB_U16) * (4 * MAX_LCU_SIZE + 1), EB_N_PTR); EB_MALLOC(EB_U16*, contextPtr->cbIntraReferenceArray, sizeof(EB_U16) * (4 * MAX_LCU_SIZE + 1), EB_N_PTR); @@ -200,7 +200,7 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( EB_U8 *yBorderFiltReverse = intraRefPtr->yIntraFilteredReferenceArrayReverse; EB_U8 *cbBorderReverse = intraRefPtr->cbIntraReferenceArrayReverse; EB_U8 *crBorderReverse = intraRefPtr->crIntraReferenceArrayReverse; - + const EB_U32 sizeLog2 = Log2f(size); const EB_U32 puChromaSize = size >> 1; @@ -214,7 +214,7 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( EB_U8 *sampleWriteLocCr; EB_U32 i; EB_U8 *sampleWriteLocFilt; - + // This internal LCU availability check will be performed for top right and bottom left neighbors only. // It is always set to true for top, left and top left neighbors EB_BOOL bottomLeftAvailabilityPreCalc; @@ -228,11 +228,11 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( const EB_U32 topLeftBlockEnd = 2 * (size >> LOG_MIN_PU_SIZE) + 1; const EB_U32 topRightBlockBegin = 3 * (size >> LOG_MIN_PU_SIZE) + 1; const EB_U32 topBlockEnd = 4 * (size >> LOG_MIN_PU_SIZE) + 1; - + EB_U32 reconArrayIndex; EB_U32 modeArrayIndex; - + EB_U8 lumaPadValue = 0; EB_U8 cbPadValue = 0; EB_U8 crPadValue = 0; @@ -240,7 +240,7 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( EB_U8 *lumaWritePtr = yBorder; EB_U8 *cbWritePtr = cbBorder; EB_U8 *crWritePtr = crBorder; - + EB_U32 writeCountLuma; EB_U32 writeCountChroma; @@ -262,7 +262,7 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( // The Generate Intra Reference sample process is a single pass algorithm // that runs through the neighbor arrays from the bottom left to top right - // and analyzes which samples are available via a spatial availability + // and analyzes which samples are available via a spatial availability // check and various mode checks. Un-available samples at the beginning // of the run (top-right side) are padded with the first valid sample and // all other missing samples are padded with the last valid sample. @@ -270,39 +270,39 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( // * - valid sample // x - missing sample // | - sample used for padding - // <- - padding (copy) operation - // + // <- - padding (copy) operation + // // TOP // 0 - // TOP-LEFT |-------> |---------------> - // * * * * * * * * * x x x x * * * * x x x x x x x x - // * - // * - // * - // * - // ^ x - // | x - // | x - // | x - // - * - // LEFT * - // * - // - * - // | x - // | x - // | x - // v x END - // + // TOP-LEFT |-------> |---------------> + // * * * * * * * * * x x x x * * * * x x x x x x x x + // * + // * + // * + // * + // ^ x + // | x + // | x + // | x + // - * + // LEFT * + // * + // - * + // | x + // | x + // | x + // v x END + // // Skeleton: // 1. Start at position 0 // 2. Loop until first valid position // a. Separate loop for Left, Top-left, and Top neighbor arrays // 3. If no valid samples found, write mid-range value (128 for 8-bit) // 4. Else, write the first valid sample into the invalid range - // 5. Left Loop + // 5. Left Loop // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value - // 6. Top-left Sample (no loop) + // 6. Top-left Sample (no loop) // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value // 7. Top Loop @@ -322,7 +322,7 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( //************************************************* // Part 1: Initial Invalid Sample Loops //************************************************* - + // Left Block Loop blockIndex = 0; reconArrayIndex = originY + 2 * size - MIN_PU_SIZE; @@ -333,13 +333,13 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex); - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -364,14 +364,14 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( originX, originY); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + // Set pad value (end of block) lumaPadValue = topLeftLumaReconNeighborArray[reconArrayIndex]; cbPadValue = topLeftCbReconNeighborArray[((MAX_PICTURE_HEIGHT_SIZE- originY)>>subHeightCMinus1) + (originX>>subWidthCMinus1)]; @@ -385,23 +385,23 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( // Top Block Loop reconArrayIndex = originX; while(blockIndex < topBlockEnd && neighborAvailable == EB_FALSE) { - + modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex); - - neighborAvailable = + + neighborAvailable = (modeArrayIndex >= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check (topModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureTopBoundary == EB_TRUE) ? EB_FALSE : // top picture boundary check (pictureRightBoundary == EB_TRUE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // right picture boundary check - (topModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check - + if(neighborAvailable == EB_TRUE) { - + // Set pad value (beginning of block) lumaPadValue = topLumaReconNeighborArray[reconArrayIndex]; cbPadValue = topCbReconNeighborArray[reconArrayIndex >> subWidthCMinus1]; @@ -411,7 +411,7 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } - + } // Check for no valid border samples @@ -424,18 +424,18 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( EB_MEMSET(lumaWritePtr, MIDRANGE_VALUE_8BIT, writeCountLuma); EB_MEMSET(cbWritePtr, MIDRANGE_VALUE_8BIT, writeCountChroma); EB_MEMSET(crWritePtr, MIDRANGE_VALUE_8BIT, writeCountChroma); - } + } else { - - // Write Pad Value - adjust for the TopLeft block being 1-sample + + // Write Pad Value - adjust for the TopLeft block being 1-sample writeCountLuma = (blockIndex >= topLeftBlockEnd) ? (blockIndex-1) * MIN_PU_SIZE + 1 : blockIndex * MIN_PU_SIZE; - + writeCountChroma = (blockIndex >= topLeftBlockEnd) ? (((blockIndex-1) * MIN_PU_SIZE) >> 1) + 1 : ((blockIndex * MIN_PU_SIZE) >> 1); - + EB_MEMSET(lumaWritePtr, lumaPadValue, writeCountLuma); EB_MEMSET(cbWritePtr, cbPadValue, writeCountChroma); EB_MEMSET(crWritePtr, crPadValue, writeCountChroma); @@ -457,13 +457,13 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex); - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -473,12 +473,12 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( lumaWritePtr[1] = leftLumaReconNeighborArray[reconArrayIndex + 2]; lumaWritePtr[2] = leftLumaReconNeighborArray[reconArrayIndex + 1]; lumaWritePtr[3] = leftLumaReconNeighborArray[reconArrayIndex + 0]; - + cbWritePtr[0] = leftCbReconNeighborArray[(reconArrayIndex >> subHeightCMinus1) + 1]; cbWritePtr[1] = leftCbReconNeighborArray[(reconArrayIndex >> subHeightCMinus1) + 0]; crWritePtr[0] = leftCrReconNeighborArray[(reconArrayIndex >> subHeightCMinus1) + 1]; crWritePtr[1] = leftCrReconNeighborArray[(reconArrayIndex >> subHeightCMinus1) + 0]; - + // Set pad value (beginning of block) lumaPadValue = leftLumaReconNeighborArray[reconArrayIndex]; cbPadValue = leftCbReconNeighborArray[reconArrayIndex >> subHeightCMinus1]; @@ -509,14 +509,14 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( originX, originY); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + // Copy sample *lumaWritePtr = topLeftLumaReconNeighborArray[reconArrayIndex]; *cbWritePtr = topLeftCbReconNeighborArray[((MAX_PICTURE_HEIGHT_SIZE- originY)>>subHeightCMinus1) + (originX>>subWidthCMinus1)]; @@ -528,7 +528,7 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( crPadValue = topLeftCrReconNeighborArray[((MAX_PICTURE_HEIGHT_SIZE- originY)>>subHeightCMinus1) + (originX>>subWidthCMinus1)]; } else { - + // Copy pad value *lumaWritePtr = lumaPadValue; *cbWritePtr = cbPadValue; @@ -545,23 +545,23 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( // Top Block Loop reconArrayIndex = originX + (blockIndex - topLeftBlockEnd) * MIN_PU_SIZE; while(blockIndex < topBlockEnd) { - + modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex); - - neighborAvailable = + + neighborAvailable = (modeArrayIndex >= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check (topModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureTopBoundary == EB_TRUE) ? EB_FALSE : // picture boundary check (pictureRightBoundary == EB_TRUE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // right picture boundary check - (topModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check - + if(neighborAvailable == EB_TRUE) { - + EB_MEMCPY(lumaWritePtr, &topLumaReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); EB_MEMCPY(cbWritePtr, &topCbReconNeighborArray[reconArrayIndex >> subWidthCMinus1], MIN_PU_SIZE >> subWidthCMinus1); EB_MEMCPY(crWritePtr, &topCrReconNeighborArray[reconArrayIndex >> subWidthCMinus1], MIN_PU_SIZE >> subWidthCMinus1); @@ -572,21 +572,21 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( crPadValue = topCrReconNeighborArray[(reconArrayIndex + MIN_PU_SIZE - 1) >> subWidthCMinus1]; } else { - + // Copy pad value EB_MEMSET(lumaWritePtr, lumaPadValue, MIN_PU_SIZE); EB_MEMSET(cbWritePtr, cbPadValue, MIN_PU_SIZE >> subWidthCMinus1); EB_MEMSET(crWritePtr, crPadValue, MIN_PU_SIZE >> subWidthCMinus1); } - + lumaWritePtr += MIN_PU_SIZE; cbWritePtr += MIN_PU_SIZE >> subWidthCMinus1; crWritePtr += MIN_PU_SIZE >> subWidthCMinus1; - + ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } - + //************************************************* // Part 3: Strong Intra Filter Samples //************************************************* @@ -650,30 +650,30 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( //************************************************* // Part 4: Create Reversed Reference Samples //************************************************* - + //at the begining of a CU Loop, the Above/Left scratch buffers are not ready to be used. intraRefPtr->AboveReadyFlagY = EB_FALSE; intraRefPtr->AboveReadyFlagCb = EB_FALSE; intraRefPtr->AboveReadyFlagCr = EB_FALSE; - + intraRefPtr->LeftReadyFlagY = EB_FALSE; intraRefPtr->LeftReadyFlagCb = EB_FALSE; intraRefPtr->LeftReadyFlagCr = EB_FALSE; - //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples + //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples /* TL T0 T1 T2 T3 T4 T5 T6 T7 TL T0 T1 T2 T3 T4 T5 T6 T7 L0 |----------------| L7 |----------------| - L1 | | =======> L6 | | + L1 | | =======> L6 | | L2 | | L5 | | L3 |----------------| L4 |----------------| - L4 L3 + L4 L3 L5 L2 L6 L1 - L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order + L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order junk - */ - + */ + //Luma EB_MEMCPY(yBorderReverse + (size<<1), yBorder + (size<<1), (size<<1)+1); EB_MEMCPY(yBorderFiltReverse + (size<<1), yBorderFilt + (size<<1), (size<<1)+1); @@ -681,22 +681,22 @@ EB_ERRORTYPE GenerateIntraReferenceSamplesEncodePass( sampleWriteLoc = yBorderReverse + (size<<1) - 1 ; sampleWriteLocFilt = yBorderFiltReverse + (size<<1) - 1 ; for(i=0; i<(size<<1) ;i++){ - + *sampleWriteLoc = yBorder[i]; *sampleWriteLocFilt = yBorderFilt[i] ; sampleWriteLoc--; sampleWriteLocFilt--; } - //Chroma + //Chroma EB_MEMCPY(cbBorderReverse + (puChromaSize<<1), cbBorder + (puChromaSize<<1), (puChromaSize<<1)+1); EB_MEMCPY(crBorderReverse + (puChromaSize<<1), crBorder + (puChromaSize<<1), (puChromaSize<<1)+1); sampleWriteLocCb = cbBorderReverse + (puChromaSize<<1) - 1 ; sampleWriteLocCr = crBorderReverse + (puChromaSize<<1) - 1 ; - + for(i=0; i<(puChromaSize<<1) ;i++){ - + *sampleWriteLocCb = cbBorder[i]; *sampleWriteLocCr = crBorder[i]; sampleWriteLocCb--; @@ -733,7 +733,7 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( EB_U8 *yBorderReverse = intraRefPtr->yIntraReferenceArrayReverse; EB_U8 *yBorderFiltReverse = intraRefPtr->yIntraFilteredReferenceArrayReverse; - + const EB_U32 sizeLog2 = Log2f(size); EB_U32 yLoadCounter; @@ -741,12 +741,12 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( EB_U8 *sampleWriteLoc; EB_U32 i; EB_U8 *sampleWriteLocFilt; - + // This internal LCU availability check will be performed for top right and bottom left neighbors only. // It is always set to true for top, left and top left neighbors EB_BOOL bottomLeftAvailabilityPreCalc; EB_BOOL topRightAvailabilityPreCalc; - + EB_U32 partitionDepth = (size == MIN_PU_SIZE) ? cuDepth + 1 : cuDepth; const EB_U32 cuIndex = ((originY & (lcuSize - 1)) >> sizeLog2) * (1 << partitionDepth) + ((originX & (lcuSize - 1)) >> sizeLog2); @@ -758,15 +758,15 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( const EB_U32 topLeftBlockEnd = 2 * (size >> LOG_MIN_PU_SIZE) + 1; const EB_U32 topRightBlockBegin = 3 * (size >> LOG_MIN_PU_SIZE) + 1; const EB_U32 topBlockEnd = 4 * (size >> LOG_MIN_PU_SIZE) + 1; - + EB_U32 reconArrayIndex; EB_U32 modeArrayIndex; - + EB_U8 lumaPadValue = 0; EB_U8 *lumaWritePtr = yBorder; - + EB_U32 writeCountLuma; // Neighbor Arrays @@ -784,7 +784,7 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( // The Generate Intra Reference sample process is a single pass algorithm // that runs through the neighbor arrays from the bottom left to top right - // and analyzes which samples are available via a spatial availability + // and analyzes which samples are available via a spatial availability // check and various mode checks. Un-available samples at the beginning // of the run (top-right side) are padded with the first valid sample and // all other missing samples are padded with the last valid sample. @@ -792,39 +792,39 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( // * - valid sample // x - missing sample // | - sample used for padding - // <- - padding (copy) operation - // + // <- - padding (copy) operation + // // TOP // 0 - // TOP-LEFT |-------> |---------------> - // * * * * * * * * * x x x x * * * * x x x x x x x x - // * - // * - // * - // * - // ^ x - // | x - // | x - // | x - // - * - // LEFT * - // * - // - * - // | x - // | x - // | x - // v x END - // + // TOP-LEFT |-------> |---------------> + // * * * * * * * * * x x x x * * * * x x x x x x x x + // * + // * + // * + // * + // ^ x + // | x + // | x + // | x + // - * + // LEFT * + // * + // - * + // | x + // | x + // | x + // v x END + // // Skeleton: // 1. Start at position 0 // 2. Loop until first valid position // a. Separate loop for Left, Top-left, and Top neighbor arrays // 3. If no valid samples found, write mid-range value (128 for 8-bit) // 4. Else, write the first valid sample into the invalid range - // 5. Left Loop + // 5. Left Loop // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value - // 6. Top-left Sample (no loop) + // 6. Top-left Sample (no loop) // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value // 7. Top Loop @@ -844,7 +844,7 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( //************************************************* // Part 1: Initial Invalid Sample Loops //************************************************* - + // Left Block Loop blockIndex = 0; reconArrayIndex = originY + 2 * size - MIN_PU_SIZE; @@ -854,13 +854,13 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex); - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -884,14 +884,14 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( originX, originY); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + // Set pad value (end of block) lumaPadValue = topLeftLumaReconNeighborArray[reconArrayIndex]; @@ -904,23 +904,23 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( // Top Block Loop reconArrayIndex = originX; while(blockIndex < topBlockEnd && neighborAvailable == EB_FALSE) { - + modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex); - - neighborAvailable = + + neighborAvailable = (modeArrayIndex >= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check (topModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureTopBoundary == EB_TRUE) ? EB_FALSE : // top picture boundary check (pictureRightBoundary == EB_TRUE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // right picture boundary check - (topModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check - + if(neighborAvailable == EB_TRUE) { - + // Set pad value (beginning of block) lumaPadValue = topLumaReconNeighborArray[reconArrayIndex]; } @@ -928,7 +928,7 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } - + } // Check for no valid border samples @@ -938,14 +938,14 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( // Write Midrange EB_MEMSET(lumaWritePtr, MIDRANGE_VALUE_8BIT, writeCountLuma); - } + } else { - - // Write Pad Value - adjust for the TopLeft block being 1-sample + + // Write Pad Value - adjust for the TopLeft block being 1-sample writeCountLuma = (blockIndex >= topLeftBlockEnd) ? (blockIndex-1) * MIN_PU_SIZE + 1 : blockIndex * MIN_PU_SIZE; - + EB_MEMSET(lumaWritePtr, lumaPadValue, writeCountLuma); } @@ -963,13 +963,13 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex); - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -979,7 +979,7 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( lumaWritePtr[1] = leftLumaReconNeighborArray[reconArrayIndex + 2]; lumaWritePtr[2] = leftLumaReconNeighborArray[reconArrayIndex + 1]; lumaWritePtr[3] = leftLumaReconNeighborArray[reconArrayIndex + 0]; - + // Set pad value (beginning of block) lumaPadValue = leftLumaReconNeighborArray[reconArrayIndex]; } @@ -1004,14 +1004,14 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( originX, originY); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + // Copy sample *lumaWritePtr = topLeftLumaReconNeighborArray[reconArrayIndex]; @@ -1019,7 +1019,7 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( lumaPadValue = topLeftLumaReconNeighborArray[reconArrayIndex]; } else { - + // Copy pad value *lumaWritePtr = lumaPadValue; } @@ -1033,42 +1033,42 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( reconArrayIndex = originX + (blockIndex - topLeftBlockEnd)*MIN_PU_SIZE; while(blockIndex < topBlockEnd) { - + modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex); - - neighborAvailable = + + neighborAvailable = (modeArrayIndex >= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check (topModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureTopBoundary == EB_TRUE) ? EB_FALSE : // top picture boundary check (pictureRightBoundary == EB_TRUE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // right picture boundary check - (topModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check - + if(neighborAvailable == EB_TRUE) { - + // Copy samples in reverse order EB_MEMCPY(lumaWritePtr, &topLumaReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); // Set pad value (end of block) lumaPadValue = topLumaReconNeighborArray[reconArrayIndex + MIN_PU_SIZE - 1]; - + } else { - + // Copy pad value EB_MEMSET(lumaWritePtr, lumaPadValue, MIN_PU_SIZE); } - + lumaWritePtr += MIN_PU_SIZE; - + ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } - + //************************************************* // Part 3: Strong Intra Filter Samples //************************************************* @@ -1131,24 +1131,24 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( //************************************************* // Part 4: Create Reversed Reference Samples //************************************************* - + //at the begining of a CU Loop, the Above/Left scratch buffers are not ready to be used. intraRefPtr->AboveReadyFlagY = EB_FALSE; intraRefPtr->LeftReadyFlagY = EB_FALSE; - //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples + //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples /* TL T0 T1 T2 T3 T4 T5 T6 T7 TL T0 T1 T2 T3 T4 T5 T6 T7 L0 |----------------| L7 |----------------| - L1 | | =======> L6 | | + L1 | | =======> L6 | | L2 | | L5 | | L3 |----------------| L4 |----------------| - L4 L3 + L4 L3 L5 L2 L6 L1 - L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order + L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order junk - */ + */ EB_MEMCPY(yBorderReverse + (size<<1), yBorder + (size<<1), (size<<1)+1); EB_MEMCPY(yBorderFiltReverse + (size<<1), yBorderFilt + (size<<1), (size<<1)+1); @@ -1156,7 +1156,7 @@ EB_ERRORTYPE GenerateLumaIntraReferenceSamplesEncodePass( sampleWriteLoc = yBorderReverse + (size<<1) - 1 ; sampleWriteLocFilt = yBorderFiltReverse + (size<<1) - 1 ; for(i=0; i<(size<<1) ;i++){ - + *sampleWriteLoc = yBorder[i]; *sampleWriteLocFilt = yBorderFilt[i] ; sampleWriteLoc--; @@ -1200,7 +1200,7 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( EB_U8 *cbBorderFiltReverse = intraRefPtr->cbIntraFilteredReferenceArrayReverse; EB_U8 *crBorderReverse = intraRefPtr->crIntraReferenceArrayReverse; EB_U8 *crBorderFiltReverse = intraRefPtr->crIntraFilteredReferenceArrayReverse; - + const EB_U32 sizeLog2 = Log2f(size); const EB_U32 puChromaSize = size >> ((colorFormat==EB_YUV420 || colorFormat==EB_YUV422) ? 1 : 0); const EB_U16 subWidthCMinus1 = (colorFormat == EB_YUV444 ? 1 : 2) - 1; @@ -1215,7 +1215,7 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( EB_U8 *sampleWriteLocCr; EB_U8 *sampleWriteLocCbFilt; EB_U8 *sampleWriteLocCrFilt; - + // This internal LCU availability check will be performed for top right and bottom left neighbors only. // It is always set to true for top, left and top left neighbors EB_BOOL bottomLeftAvailabilityPreCalc; @@ -1232,7 +1232,7 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( EB_U32 topLeftBlockEnd = 2 * (puChromaSize >> LOG_MIN_PU_SIZE) + 1; EB_U32 topRightBlockBegin = 3 * (puChromaSize >> LOG_MIN_PU_SIZE) + 1; EB_U32 topBlockEnd = 4 * (puChromaSize >> LOG_MIN_PU_SIZE) + 1; - + EB_U32 reconArrayIndex; EB_U32 modeArrayIndex; @@ -1263,7 +1263,7 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( // The Generate Intra Reference sample process is a single pass algorithm // that runs through the neighbor arrays from the bottom left to top right - // and analyzes which samples are available via a spatial availability + // and analyzes which samples are available via a spatial availability // check and various mode checks. Un-available samples at the beginning // of the run (top-right side) are padded with the first valid sample and // all other missing samples are padded with the last valid sample. @@ -1271,39 +1271,39 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( // * - valid sample // x - missing sample // | - sample used for padding - // <- - padding (copy) operation - // + // <- - padding (copy) operation + // // TOP // 0 - // TOP-LEFT |-------> |---------------> - // * * * * * * * * * x x x x * * * * x x x x x x x x - // * - // * - // * - // * - // ^ x - // | x - // | x - // | x - // - * - // LEFT * - // * - // - * - // | x - // | x - // | x - // v x END - // + // TOP-LEFT |-------> |---------------> + // * * * * * * * * * x x x x * * * * x x x x x x x x + // * + // * + // * + // * + // ^ x + // | x + // | x + // | x + // - * + // LEFT * + // * + // - * + // | x + // | x + // | x + // v x END + // // Skeleton: // 1. Start at position 0 // 2. Loop until first valid position // a. Separate loop for Left, Top-left, and Top neighbor arrays // 3. If no valid samples found, write mid-range value (128 for 8-bit) // 4. Else, write the first valid sample into the invalid range - // 5. Left Loop + // 5. Left Loop // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value - // 6. Top-left Sample (no loop) + // 6. Top-left Sample (no loop) // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value // 7. Top Loop @@ -1332,7 +1332,7 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( //************************************************* // Part 1: Initial Invalid Sample Loops //************************************************* - + // Left Block Loop blockIndex = 0; @@ -1347,13 +1347,13 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex << subHeightCMinus1); //mode is stored as luma, so convert to luma axis - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -1375,10 +1375,10 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( cuOriginX, cuOriginY + chromaOffset); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -1398,8 +1398,8 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex << subWidthCMinus1); - - neighborAvailable = + + neighborAvailable = (modeArrayIndex >= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check @@ -1410,7 +1410,7 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + // Set pad value (beginning of block) cbPadValue = topCbReconNeighborArray[reconArrayIndex]; crPadValue = topCrReconNeighborArray[reconArrayIndex]; @@ -1419,7 +1419,7 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } - + } // Check for no valid border samples @@ -1429,9 +1429,9 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( // Write Midrange EB_MEMSET(cbWritePtr, MIDRANGE_VALUE_8BIT, writeCountChroma); EB_MEMSET(crWritePtr, MIDRANGE_VALUE_8BIT, writeCountChroma); - } + } else { - // Write Pad Value - adjust for the TopLeft block being 1-sample + // Write Pad Value - adjust for the TopLeft block being 1-sample writeCountChroma = (blockIndex >= topLeftBlockEnd) ? ((blockIndex-1) * MIN_PU_SIZE) + 1 : (blockIndex * MIN_PU_SIZE); @@ -1456,18 +1456,18 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex << subHeightCMinus1); - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - // Copy samples (Reverse the order) + // Copy samples (Reverse the order) cbWritePtr[0] = leftCbReconNeighborArray[(reconArrayIndex) + 3]; cbWritePtr[1] = leftCbReconNeighborArray[(reconArrayIndex) + 2]; cbWritePtr[2] = leftCbReconNeighborArray[(reconArrayIndex) + 1]; @@ -1501,10 +1501,10 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( cuOriginX, cuOriginY+chromaOffset); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -1533,8 +1533,8 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex << subWidthCMinus1); - - neighborAvailable = + + neighborAvailable = (modeArrayIndex >= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check @@ -1545,7 +1545,7 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + EB_MEMCPY(cbWritePtr, &topCbReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); EB_MEMCPY(crWritePtr, &topCrReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); @@ -1593,7 +1593,7 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( //************************************************* // Part 3: Create Reversed Reference Samples //************************************************* - + //at the begining of a CU Loop, the Above/Left scratch buffers are not ready to be used. intraRefPtr->AboveReadyFlagCb = EB_FALSE; intraRefPtr->AboveReadyFlagCr = EB_FALSE; @@ -1601,26 +1601,26 @@ EB_ERRORTYPE GenerateChromaIntraReferenceSamplesEncodePass( intraRefPtr->LeftReadyFlagCb = EB_FALSE; intraRefPtr->LeftReadyFlagCr = EB_FALSE; - //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples + //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples /* TL T0 T1 T2 T3 T4 T5 T6 T7 TL T0 T1 T2 T3 T4 T5 T6 T7 L0 |----------------| L7 |----------------| - L1 | | =======> L6 | | + L1 | | =======> L6 | | L2 | | L5 | | L3 |----------------| L4 |----------------| - L4 L3 + L4 L3 L5 L2 L6 L1 - L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order + L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order junk - */ + */ EB_MEMCPY(cbBorderReverse + (puChromaSize<<1), cbBorder + (puChromaSize<<1), (puChromaSize<<1)+1); EB_MEMCPY(crBorderReverse + (puChromaSize<<1), crBorder + (puChromaSize<<1), (puChromaSize<<1)+1); sampleWriteLocCb = cbBorderReverse + (puChromaSize << 1) - 1 ; sampleWriteLocCr = crBorderReverse + (puChromaSize << 1) - 1 ; - + for(i = 0; i < (puChromaSize << 1) ;i++){ *sampleWriteLocCb = cbBorder[i]; *sampleWriteLocCr = crBorder[i]; @@ -1676,7 +1676,7 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( EB_U16 *yBorderFiltReverse = intraRefPtr->yIntraFilteredReferenceArrayReverse; EB_U16 *cbBorderReverse = intraRefPtr->cbIntraReferenceArrayReverse; EB_U16 *crBorderReverse = intraRefPtr->crIntraReferenceArrayReverse; - + const EB_U32 sizeLog2 = Log2f(size); const EB_U32 chromaRatio = (colorFormat==EB_YUV420 || colorFormat==EB_YUV422)?1:0; const EB_U32 puChromaSize = size >> chromaRatio; @@ -1688,7 +1688,7 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( EB_U16 *sampleWriteLocCr; EB_U32 i; EB_U16 *sampleWriteLocFilt; - + // This internal LCU availability check will be performed for top right and bottom left neighbors only. // It is always set to true for top, left and top left neighbors EB_BOOL bottomLeftAvailabilityPreCalc; @@ -1703,11 +1703,11 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( const EB_U32 topLeftBlockEnd = 2 * (size >> LOG_MIN_PU_SIZE) + 1; const EB_U32 topRightBlockBegin = 3 * (size >> LOG_MIN_PU_SIZE) + 1; const EB_U32 topBlockEnd = 4 * (size >> LOG_MIN_PU_SIZE) + 1; - + EB_U32 reconArrayIndex; EB_U32 modeArrayIndex; - + EB_U16 lumaPadValue = 0; EB_U16 cbPadValue = 0; EB_U16 crPadValue = 0; @@ -1715,7 +1715,7 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( EB_U16 *lumaWritePtr = yBorder; EB_U16 *cbWritePtr = cbBorder; EB_U16 *crWritePtr = crBorder; - + EB_U32 writeCountLuma; EB_U32 writeCountChroma; @@ -1725,7 +1725,7 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( EB_U32 leftModeNeighborArraySize = modeTypeNeighborArray->leftArraySize; EB_U8 *leftModeNeighborArray = modeTypeNeighborArray->leftArray; EB_U8 *topLeftModeNeighborArray = modeTypeNeighborArray->topLeftArray; - + EB_U16 *topLumaReconNeighborArray = (EB_U16*)lumaReconNeighborArray->topArray; EB_U16 *leftLumaReconNeighborArray = (EB_U16*)lumaReconNeighborArray->leftArray; EB_U16 *topLeftLumaReconNeighborArray = (EB_U16*)lumaReconNeighborArray->topLeftArray; @@ -1738,7 +1738,7 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( // The Generate Intra Reference sample process is a single pass algorithm // that runs through the neighbor arrays from the bottom left to top right - // and analyzes which samples are available via a spatial availability + // and analyzes which samples are available via a spatial availability // check and various mode checks. Un-available samples at the beginning // of the run (top-right side) are padded with the first valid sample and // all other missing samples are padded with the last valid sample. @@ -1746,39 +1746,39 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( // * - valid sample // x - missing sample // | - sample used for padding - // <- - padding (copy) operation - // + // <- - padding (copy) operation + // // TOP // 0 - // TOP-LEFT |-------> |---------------> - // * * * * * * * * * x x x x * * * * x x x x x x x x - // * - // * - // * - // * - // ^ x - // | x - // | x - // | x - // - * - // LEFT * - // * - // - * - // | x - // | x - // | x - // v x END - // + // TOP-LEFT |-------> |---------------> + // * * * * * * * * * x x x x * * * * x x x x x x x x + // * + // * + // * + // * + // ^ x + // | x + // | x + // | x + // - * + // LEFT * + // * + // - * + // | x + // | x + // | x + // v x END + // // Skeleton: // 1. Start at position 0 // 2. Loop until first valid position // a. Separate loop for Left, Top-left, and Top neighbor arrays // 3. If no valid samples found, write mid-range value (128 for 8-bit) // 4. Else, write the first valid sample into the invalid range - // 5. Left Loop + // 5. Left Loop // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value - // 6. Top-left Sample (no loop) + // 6. Top-left Sample (no loop) // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value // 7. Top Loop @@ -1798,7 +1798,7 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( //************************************************* // Part 1: Initial Invalid Sample Loops //************************************************* - + // Left Block Loop blockIndex = 0; reconArrayIndex = originY + 2 * size - MIN_PU_SIZE; @@ -1809,13 +1809,13 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex); - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -1841,14 +1841,14 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( originX, originY); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + // Set pad value (end of block) lumaPadValue = topLeftLumaReconNeighborArray[reconArrayIndex]; cbPadValue = topLeftCbReconNeighborArray[reconArrayIndex >> chromaRatio]; @@ -1862,23 +1862,23 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( // Top Block Loop reconArrayIndex = originX; while(blockIndex < topBlockEnd && neighborAvailable == EB_FALSE) { - + modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex); - - neighborAvailable = + + neighborAvailable = (modeArrayIndex >= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check (topModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureTopBoundary == EB_TRUE) ? EB_FALSE : // top picture boundary check (pictureRightBoundary == EB_TRUE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // right picture boundary check - (topModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check - + if(neighborAvailable == EB_TRUE) { - + // Set pad value (beginning of block) lumaPadValue = topLumaReconNeighborArray[reconArrayIndex]; cbPadValue = topCbReconNeighborArray[reconArrayIndex >> chromaRatio]; @@ -1888,7 +1888,7 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } - + } // Check for no valid border samples @@ -1897,22 +1897,22 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( writeCountLuma = 4*size + 1; writeCountChroma = 4*(size>>chromaRatio) + 1; - // Write Midrange + // Write Midrange memset16bit(lumaWritePtr, MIDRANGE_VALUE_10BIT, writeCountLuma); memset16bit(cbWritePtr, MIDRANGE_VALUE_10BIT, writeCountChroma); memset16bit(crWritePtr, MIDRANGE_VALUE_10BIT, writeCountChroma); - } + } else { - - // Write Pad Value - adjust for the TopLeft block being 1-sample + + // Write Pad Value - adjust for the TopLeft block being 1-sample writeCountLuma = (blockIndex >= topLeftBlockEnd) ? (blockIndex-1) * MIN_PU_SIZE + 1 : blockIndex * MIN_PU_SIZE; - + writeCountChroma = (blockIndex >= topLeftBlockEnd) ? (((blockIndex-1) * MIN_PU_SIZE) >> chromaRatio) + 1 : ((blockIndex * MIN_PU_SIZE) >> chromaRatio); - + memset16bit(lumaWritePtr, lumaPadValue, writeCountLuma); memset16bit(cbWritePtr, cbPadValue, writeCountChroma); memset16bit(crWritePtr, crPadValue, writeCountChroma); @@ -1934,13 +1934,13 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex); - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -1950,13 +1950,13 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( lumaWritePtr[1] = leftLumaReconNeighborArray[reconArrayIndex + 2]; lumaWritePtr[2] = leftLumaReconNeighborArray[reconArrayIndex + 1]; lumaWritePtr[3] = leftLumaReconNeighborArray[reconArrayIndex + 0]; - + cbWritePtr[0] = leftCbReconNeighborArray[(reconArrayIndex >> chromaRatio) + 1]; cbWritePtr[1] = leftCbReconNeighborArray[(reconArrayIndex >> chromaRatio) + 0]; - + crWritePtr[0] = leftCrReconNeighborArray[(reconArrayIndex >> chromaRatio) + 1]; crWritePtr[1] = leftCrReconNeighborArray[(reconArrayIndex >> chromaRatio) + 0]; - + // Set pad value (beginning of block) lumaPadValue = leftLumaReconNeighborArray[reconArrayIndex]; cbPadValue = leftCbReconNeighborArray[reconArrayIndex >> chromaRatio]; @@ -1987,14 +1987,14 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( originX, originY); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + // Copy sample *lumaWritePtr = topLeftLumaReconNeighborArray[reconArrayIndex]; *cbWritePtr = topLeftCbReconNeighborArray[reconArrayIndex >> chromaRatio]; @@ -2006,7 +2006,7 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( crPadValue = topLeftCrReconNeighborArray[reconArrayIndex >> chromaRatio]; } else { - + // Copy pad value *lumaWritePtr = lumaPadValue; *cbWritePtr = cbPadValue; @@ -2023,27 +2023,27 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( // Top Block Loop reconArrayIndex = originX + (blockIndex - topLeftBlockEnd) * MIN_PU_SIZE; while(blockIndex < topBlockEnd) { - + modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex); - - neighborAvailable = + + neighborAvailable = (modeArrayIndex >= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check (topModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureTopBoundary == EB_TRUE) ? EB_FALSE : // top picture boundary check (pictureRightBoundary == EB_TRUE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // right picture boundary check - (topModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check - + if(neighborAvailable == EB_TRUE) { - + // Copy samples in reverse order - memcpy16bit(lumaWritePtr, &topLumaReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); - memcpy16bit(cbWritePtr, &topCbReconNeighborArray[reconArrayIndex >> chromaRatio], MIN_PU_SIZE >> chromaRatio); - memcpy16bit(crWritePtr, &topCrReconNeighborArray[reconArrayIndex >> chromaRatio], MIN_PU_SIZE >> chromaRatio); + EbHevcmemcpy16bit(lumaWritePtr, &topLumaReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); + EbHevcmemcpy16bit(cbWritePtr, &topCbReconNeighborArray[reconArrayIndex >> chromaRatio], MIN_PU_SIZE >> chromaRatio); + EbHevcmemcpy16bit(crWritePtr, &topCrReconNeighborArray[reconArrayIndex >> chromaRatio], MIN_PU_SIZE >> chromaRatio); // Set pad value (end of block) lumaPadValue = topLumaReconNeighborArray[reconArrayIndex + MIN_PU_SIZE - 1]; @@ -2051,21 +2051,21 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( crPadValue = topCrReconNeighborArray[(reconArrayIndex + MIN_PU_SIZE - 1) >> chromaRatio]; } else { - + // Copy pad value memset16bit(lumaWritePtr, lumaPadValue, MIN_PU_SIZE); memset16bit(cbWritePtr, cbPadValue, MIN_PU_SIZE >> chromaRatio); memset16bit(crWritePtr, crPadValue, MIN_PU_SIZE >> chromaRatio); } - + lumaWritePtr += MIN_PU_SIZE; cbWritePtr += MIN_PU_SIZE >> chromaRatio; crWritePtr += MIN_PU_SIZE >> chromaRatio; - + ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } - + //************************************************* // Part 3: Strong Intra Filter Samples //************************************************* @@ -2128,53 +2128,53 @@ EB_ERRORTYPE GenerateIntraReference16bitSamplesEncodePass( //************************************************* // Part 4: Create Reversed Reference Samples //************************************************* - + //at the begining of a CU Loop, the Above/Left scratch buffers are not ready to be used. intraRefPtr->AboveReadyFlagY = EB_FALSE; intraRefPtr->AboveReadyFlagCb = EB_FALSE; intraRefPtr->AboveReadyFlagCr = EB_FALSE; - + intraRefPtr->LeftReadyFlagY = EB_FALSE; intraRefPtr->LeftReadyFlagCb = EB_FALSE; intraRefPtr->LeftReadyFlagCr = EB_FALSE; - //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples + //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples /* TL T0 T1 T2 T3 T4 T5 T6 T7 TL T0 T1 T2 T3 T4 T5 T6 T7 L0 |----------------| L7 |----------------| - L1 | | =======> L6 | | + L1 | | =======> L6 | | L2 | | L5 | | L3 |----------------| L4 |----------------| - L4 L3 + L4 L3 L5 L2 L6 L1 - L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order + L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order junk - */ - + */ + //Luma - memcpy16bit(yBorderReverse + (size<<1), yBorder + (size<<1), (size<<1)+1); - memcpy16bit(yBorderFiltReverse + (size<<1), yBorderFilt + (size<<1), (size<<1)+1); + EbHevcmemcpy16bit(yBorderReverse + (size<<1), yBorder + (size<<1), (size<<1)+1); + EbHevcmemcpy16bit(yBorderFiltReverse + (size<<1), yBorderFilt + (size<<1), (size<<1)+1); sampleWriteLoc = yBorderReverse + (size<<1) - 1 ; sampleWriteLocFilt = yBorderFiltReverse + (size<<1) - 1 ; for(i=0; i<(size<<1) ;i++){ - + *sampleWriteLoc = yBorder[i]; *sampleWriteLocFilt = yBorderFilt[i] ; sampleWriteLoc--; sampleWriteLocFilt--; } - //Chroma - memcpy16bit(cbBorderReverse + (puChromaSize<<1), cbBorder + (puChromaSize<<1), (puChromaSize<<1)+1); - memcpy16bit(crBorderReverse + (puChromaSize<<1), crBorder + (puChromaSize<<1), (puChromaSize<<1)+1); + //Chroma + EbHevcmemcpy16bit(cbBorderReverse + (puChromaSize<<1), cbBorder + (puChromaSize<<1), (puChromaSize<<1)+1); + EbHevcmemcpy16bit(crBorderReverse + (puChromaSize<<1), crBorder + (puChromaSize<<1), (puChromaSize<<1)+1); sampleWriteLocCb = cbBorderReverse + (puChromaSize<<1) - 1 ; sampleWriteLocCr = crBorderReverse + (puChromaSize<<1) - 1 ; - + for(i=0; i<(puChromaSize<<1) ;i++){ - + *sampleWriteLocCb = cbBorder[i]; *sampleWriteLocCr = crBorder[i]; sampleWriteLocCb--; @@ -2224,7 +2224,7 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( // It is always set to true for top, left and top left neighbors EB_BOOL bottomLeftAvailabilityPreCalc; EB_BOOL topRightAvailabilityPreCalc; - + EB_U32 partitionDepth = (size == MIN_PU_SIZE) ? cuDepth + 1 : cuDepth; const EB_U32 cuIndex = ((originY & (lcuSize - 1)) >> sizeLog2) * (1 << partitionDepth) + ((originX & (lcuSize - 1)) >> sizeLog2); @@ -2236,14 +2236,14 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( const EB_U32 topLeftBlockEnd = 2 * (size >> LOG_MIN_PU_SIZE) + 1; const EB_U32 topRightBlockBegin = 3 * (size >> LOG_MIN_PU_SIZE) + 1; const EB_U32 topBlockEnd = 4 * (size >> LOG_MIN_PU_SIZE) + 1; - + EB_U32 reconArrayIndex; EB_U32 modeArrayIndex; - + EB_U16 lumaPadValue = 0; EB_U16 *lumaWritePtr = yBorder; - + EB_U32 writeCountLuma; // Neighbor Arrays @@ -2261,7 +2261,7 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( // The Generate Intra Reference sample process is a single pass algorithm // that runs through the neighbor arrays from the bottom left to top right - // and analyzes which samples are available via a spatial availability + // and analyzes which samples are available via a spatial availability // check and various mode checks. Un-available samples at the beginning // of the run (top-right side) are padded with the first valid sample and // all other missing samples are padded with the last valid sample. @@ -2269,39 +2269,39 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( // * - valid sample // x - missing sample // | - sample used for padding - // <- - padding (copy) operation - // + // <- - padding (copy) operation + // // TOP // 0 - // TOP-LEFT |-------> |---------------> - // * * * * * * * * * x x x x * * * * x x x x x x x x - // * - // * - // * - // * - // ^ x - // | x - // | x - // | x - // - * - // LEFT * - // * - // - * - // | x - // | x - // | x - // v x END - // + // TOP-LEFT |-------> |---------------> + // * * * * * * * * * x x x x * * * * x x x x x x x x + // * + // * + // * + // * + // ^ x + // | x + // | x + // | x + // - * + // LEFT * + // * + // - * + // | x + // | x + // | x + // v x END + // // Skeleton: // 1. Start at position 0 // 2. Loop until first valid position // a. Separate loop for Left, Top-left, and Top neighbor arrays // 3. If no valid samples found, write mid-range value (128 for 8-bit) // 4. Else, write the first valid sample into the invalid range - // 5. Left Loop + // 5. Left Loop // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value - // 6. Top-left Sample (no loop) + // 6. Top-left Sample (no loop) // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value // 7. Top Loop @@ -2321,7 +2321,7 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( //************************************************* // Part 1: Initial Invalid Sample Loops //************************************************* - + // Left Block Loop blockIndex = 0; reconArrayIndex = originY + 2 * size - MIN_PU_SIZE; @@ -2332,13 +2332,13 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex); - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -2362,14 +2362,14 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( originX, originY); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + // Set pad value (end of block) lumaPadValue = topLeftLumaReconNeighborArray[reconArrayIndex]; @@ -2382,23 +2382,23 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( // Top Block Loop reconArrayIndex = originX; while(blockIndex < topBlockEnd && neighborAvailable == EB_FALSE) { - + modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex); - - neighborAvailable = + + neighborAvailable = (modeArrayIndex >= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check (topModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureTopBoundary == EB_TRUE) ? EB_FALSE : // top picture boundary check (pictureRightBoundary == EB_TRUE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // right picture boundary check - (topModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check - + if(neighborAvailable == EB_TRUE) { - + // Set pad value (beginning of block) lumaPadValue = topLumaReconNeighborArray[reconArrayIndex]; } @@ -2406,7 +2406,7 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } - + } // Check for no valid border samples @@ -2416,14 +2416,14 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( // Write Midrange memset16bit(lumaWritePtr, MIDRANGE_VALUE_10BIT, writeCountLuma); - } + } else { - - // Write Pad Value - adjust for the TopLeft block being 1-sample + + // Write Pad Value - adjust for the TopLeft block being 1-sample writeCountLuma = (blockIndex >= topLeftBlockEnd) ? (blockIndex-1) * MIN_PU_SIZE + 1 : blockIndex * MIN_PU_SIZE; - + memset16bit(lumaWritePtr, lumaPadValue, writeCountLuma); } @@ -2441,13 +2441,13 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex); - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -2457,7 +2457,7 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( lumaWritePtr[1] = leftLumaReconNeighborArray[reconArrayIndex + 2]; lumaWritePtr[2] = leftLumaReconNeighborArray[reconArrayIndex + 1]; lumaWritePtr[3] = leftLumaReconNeighborArray[reconArrayIndex + 0]; - + // Set pad value (beginning of block) lumaPadValue = leftLumaReconNeighborArray[reconArrayIndex]; } @@ -2482,14 +2482,14 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( originX, originY); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + // Copy sample *lumaWritePtr = topLeftLumaReconNeighborArray[reconArrayIndex]; @@ -2497,7 +2497,7 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( lumaPadValue = topLeftLumaReconNeighborArray[reconArrayIndex]; } else { - + // Copy pad value *lumaWritePtr = lumaPadValue; } @@ -2511,41 +2511,41 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( reconArrayIndex = originX + (blockIndex - topLeftBlockEnd)*MIN_PU_SIZE; while(blockIndex < topBlockEnd) { - + modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex); - - neighborAvailable = + + neighborAvailable = (modeArrayIndex >= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check (topModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureTopBoundary == EB_TRUE) ? EB_FALSE : // top picture boundary check (pictureRightBoundary == EB_TRUE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // right picture boundary check - (topModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check - + if(neighborAvailable == EB_TRUE) { - + // Copy samples in reverse order - memcpy16bit(lumaWritePtr, &topLumaReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); + EbHevcmemcpy16bit(lumaWritePtr, &topLumaReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); // Set pad value (end of block) lumaPadValue = topLumaReconNeighborArray[reconArrayIndex + MIN_PU_SIZE - 1]; - + } else { // Copy pad value memset16bit(lumaWritePtr, lumaPadValue, MIN_PU_SIZE); } - + lumaWritePtr += MIN_PU_SIZE; - + ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } - + //************************************************* // Part 3: Strong Intra Filter Samples //************************************************* @@ -2609,27 +2609,27 @@ EB_ERRORTYPE GenerateLumaIntraReference16bitSamplesEncodePass( //************************************************* // Part 4: Create Reversed Reference Samples //************************************************* - + //at the begining of a CU Loop, the Above/Left scratch buffers are not ready to be used. intraRefPtr->AboveReadyFlagY = EB_FALSE; intraRefPtr->LeftReadyFlagY = EB_FALSE; - //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples + //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples /* TL T0 T1 T2 T3 T4 T5 T6 T7 TL T0 T1 T2 T3 T4 T5 T6 T7 L0 |----------------| L7 |----------------| - L1 | | =======> L6 | | + L1 | | =======> L6 | | L2 | | L5 | | L3 |----------------| L4 |----------------| - L4 L3 + L4 L3 L5 L2 L6 L1 - L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order + L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order junk - */ + */ - memcpy16bit(yBorderReverse + (size<<1), yBorder + (size<<1), (size<<1)+1); - memcpy16bit(yBorderFiltReverse + (size<<1), yBorderFilt + (size<<1), (size<<1)+1); + EbHevcmemcpy16bit(yBorderReverse + (size<<1), yBorder + (size<<1), (size<<1)+1); + EbHevcmemcpy16bit(yBorderFiltReverse + (size<<1), yBorderFilt + (size<<1), (size<<1)+1); sampleWriteLoc = yBorderReverse + (size<<1) - 1 ; sampleWriteLocFilt = yBorderFiltReverse + (size<<1) - 1 ; @@ -2679,7 +2679,7 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( EB_U16 *crBorderReverse = intraRefPtr->crIntraReferenceArrayReverse; EB_U16 *crBorderFiltReverse = intraRefPtr->crIntraFilteredReferenceArrayReverse; - + const EB_U32 sizeLog2 = Log2f(size); const EB_U32 puChromaSize = size >> ((colorFormat == EB_YUV420 || colorFormat == EB_YUV422) ? 1 : 0); const EB_U16 subWidthCMinus1 = (colorFormat == EB_YUV444 ? 1 : 2) - 1; @@ -2694,7 +2694,7 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( EB_U16 *sampleWriteLocCr; EB_U16 *sampleWriteLocCbFilt; EB_U16 *sampleWriteLocCrFilt; - + // This internal LCU availability check will be performed for top right and bottom left neighbors only. // It is always set to true for top, left and top left neighbors EB_BOOL bottomLeftAvailabilityPreCalc; @@ -2711,7 +2711,7 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( EB_U32 topLeftBlockEnd = 2 * (puChromaSize >> LOG_MIN_PU_SIZE) + 1; EB_U32 topRightBlockBegin = 3 * (puChromaSize >> LOG_MIN_PU_SIZE) + 1; EB_U32 topBlockEnd = 4 * (puChromaSize >> LOG_MIN_PU_SIZE) + 1; - + EB_U32 reconArrayIndex; EB_U32 modeArrayIndex; @@ -2742,7 +2742,7 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( // The Generate Intra Reference sample process is a single pass algorithm // that runs through the neighbor arrays from the bottom left to top right - // and analyzes which samples are available via a spatial availability + // and analyzes which samples are available via a spatial availability // check and various mode checks. Un-available samples at the beginning // of the run (top-right side) are padded with the first valid sample and // all other missing samples are padded with the last valid sample. @@ -2750,39 +2750,39 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( // * - valid sample // x - missing sample // | - sample used for padding - // <- - padding (copy) operation - // + // <- - padding (copy) operation + // // TOP // 0 - // TOP-LEFT |-------> |---------------> - // * * * * * * * * * x x x x * * * * x x x x x x x x - // * - // * - // * - // * - // ^ x - // | x - // | x - // | x - // - * - // LEFT * - // * - // - * - // | x - // | x - // | x - // v x END - // + // TOP-LEFT |-------> |---------------> + // * * * * * * * * * x x x x * * * * x x x x x x x x + // * + // * + // * + // * + // ^ x + // | x + // | x + // | x + // - * + // LEFT * + // * + // - * + // | x + // | x + // | x + // v x END + // // Skeleton: // 1. Start at position 0 // 2. Loop until first valid position // a. Separate loop for Left, Top-left, and Top neighbor arrays // 3. If no valid samples found, write mid-range value (128 for 8-bit) // 4. Else, write the first valid sample into the invalid range - // 5. Left Loop + // 5. Left Loop // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value - // 6. Top-left Sample (no loop) + // 6. Top-left Sample (no loop) // a. If block is valid, copy recon values & update pad value // b. Else, copy pad value // 7. Top Loop @@ -2811,7 +2811,7 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( //************************************************* // Part 1: Initial Invalid Sample Loops //************************************************* - + // Left Block Loop blockIndex = 0; @@ -2827,13 +2827,13 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex<= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -2855,10 +2855,10 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( cuOriginX, cuOriginY + chromaOffset); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -2877,8 +2877,8 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex<= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check @@ -2889,17 +2889,17 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - + // Set pad value (beginning of block) cbPadValue = topCbReconNeighborArray[reconArrayIndex]; crPadValue = topCrReconNeighborArray[reconArrayIndex]; - + } else { ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } - + } // Check for no valid border samples @@ -2910,10 +2910,10 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( // Write Midrange memset16bit(cbWritePtr, MIDRANGE_VALUE_10BIT, writeCountChroma); memset16bit(crWritePtr, MIDRANGE_VALUE_10BIT, writeCountChroma); - } + } else { - - // Write Pad Value - adjust for the TopLeft block being 1-sample + + // Write Pad Value - adjust for the TopLeft block being 1-sample writeCountChroma = (blockIndex >= topLeftBlockEnd) ? ((blockIndex-1) * MIN_PU_SIZE) + 1 : (blockIndex * MIN_PU_SIZE); @@ -2938,17 +2938,17 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( modeTypeNeighborArray, reconArrayIndex << subHeightCMinus1); - neighborAvailable = + neighborAvailable = (modeArrayIndex >= leftModeNeighborArraySize) ? EB_FALSE : // array boundary check (bottomLeftAvailabilityPreCalc == EB_FALSE && blockIndex < bottomLeftEnd) ? EB_FALSE : // internal scan-order check (leftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (leftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - // Copy samples (Reverse the order) + // Copy samples (Reverse the order) cbWritePtr[0] = leftCbReconNeighborArray[(reconArrayIndex) + 3]; cbWritePtr[1] = leftCbReconNeighborArray[(reconArrayIndex) + 2]; cbWritePtr[2] = leftCbReconNeighborArray[(reconArrayIndex) + 1]; @@ -2983,10 +2983,10 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( cuOriginX, cuOriginY + chromaOffset); - neighborAvailable = + neighborAvailable = (topLeftModeNeighborArray[modeArrayIndex] == (EB_U8) INVALID_MODE) ? EB_FALSE : // slice boundary check (pictureLeftBoundary == EB_TRUE || pictureTopBoundary == EB_TRUE) ? EB_FALSE : // left picture boundary check - (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && + (topLeftModeNeighborArray[modeArrayIndex] == INTER_MODE && constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { @@ -3017,8 +3017,8 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( modeArrayIndex = GetNeighborArrayUnitTopIndex( modeTypeNeighborArray, reconArrayIndex<= topModeNeighborArraySize) ? EB_FALSE : // array boundary check (topRightAvailabilityPreCalc == EB_FALSE && blockIndex >= topRightBlockBegin) ? EB_FALSE : // internal scan-order check @@ -3029,16 +3029,16 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( constrainedIntraFlag == EB_TRUE) ? EB_FALSE : EB_TRUE; // contrained intra check if(neighborAvailable == EB_TRUE) { - - memcpy16bit(cbWritePtr, &topCbReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); - memcpy16bit(crWritePtr, &topCrReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); + + EbHevcmemcpy16bit(cbWritePtr, &topCbReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); + EbHevcmemcpy16bit(crWritePtr, &topCrReconNeighborArray[reconArrayIndex], MIN_PU_SIZE); // Set pad value (end of block) cbPadValue = topCbReconNeighborArray[reconArrayIndex + MIN_PU_SIZE - 1]; crPadValue = topCrReconNeighborArray[reconArrayIndex + MIN_PU_SIZE - 1]; } else { - + // Copy pad value memset16bit(cbWritePtr, cbPadValue, MIN_PU_SIZE); memset16bit(crWritePtr, crPadValue, MIN_PU_SIZE); @@ -3046,7 +3046,7 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( cbWritePtr += MIN_PU_SIZE; crWritePtr += MIN_PU_SIZE; - + ++blockIndex; reconArrayIndex += MIN_PU_SIZE; } @@ -3082,7 +3082,7 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( //************************************************* // Part 3: Create Reversed Reference Samples //************************************************* - + //at the begining of a CU Loop, the Above/Left scratch buffers are not ready to be used. intraRefPtr->AboveReadyFlagCb = EB_FALSE; intraRefPtr->AboveReadyFlagCr = EB_FALSE; @@ -3090,26 +3090,26 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( intraRefPtr->LeftReadyFlagCb = EB_FALSE; intraRefPtr->LeftReadyFlagCr = EB_FALSE; - //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples + //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples /* TL T0 T1 T2 T3 T4 T5 T6 T7 TL T0 T1 T2 T3 T4 T5 T6 T7 L0 |----------------| L7 |----------------| - L1 | | =======> L6 | | + L1 | | =======> L6 | | L2 | | L5 | | L3 |----------------| L4 |----------------| - L4 L3 + L4 L3 L5 L2 L6 L1 - L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order + L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order junk - */ + */ - memcpy16bit(cbBorderReverse + (puChromaSize << 1), cbBorder + (puChromaSize << 1), (puChromaSize << 1) + 1); - memcpy16bit(crBorderReverse + (puChromaSize << 1), crBorder + (puChromaSize << 1), (puChromaSize << 1) + 1); + EbHevcmemcpy16bit(cbBorderReverse + (puChromaSize << 1), cbBorder + (puChromaSize << 1), (puChromaSize << 1) + 1); + EbHevcmemcpy16bit(crBorderReverse + (puChromaSize << 1), crBorder + (puChromaSize << 1), (puChromaSize << 1) + 1); sampleWriteLocCb = cbBorderReverse + (puChromaSize<<1) - 1 ; sampleWriteLocCr = crBorderReverse + (puChromaSize<<1) - 1 ; - + for(i=0; i<(puChromaSize<<1); i++){ *sampleWriteLocCb = cbBorder[i]; *sampleWriteLocCr = crBorder[i]; @@ -3118,9 +3118,9 @@ EB_ERRORTYPE GenerateChromaIntraReference16bitSamplesEncodePass( } if (colorFormat == EB_YUV444) { - memcpy16bit(cbBorderFiltReverse + (puChromaSize<<1), + EbHevcmemcpy16bit(cbBorderFiltReverse + (puChromaSize<<1), cbBorderFilt + (puChromaSize << 1), (puChromaSize << 1) + 1); - memcpy16bit(crBorderFiltReverse + (puChromaSize<<1), + EbHevcmemcpy16bit(crBorderFiltReverse + (puChromaSize<<1), crBorderFilt + (puChromaSize << 1), (puChromaSize << 1) + 1); sampleWriteLocCbFilt = cbBorderFiltReverse + (puChromaSize << 1) - 1 ; @@ -3151,9 +3151,9 @@ static void IntraModeAngular_27To33( refSampMain = refSamples + (size << 1); IntraAngVertical_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( - size, + size, refSampMain, - predictionPtr, + predictionPtr, predictionBufferStride, EB_FALSE, intraPredAngle); @@ -3170,11 +3170,11 @@ static void IntraModeAngular16bit_27To33( EB_U16 *refSampMain; EB_S32 intraPredAngle = intraModeAngularTable[mode - INTRA_VERTICAL_MODE]; refSampMain = refSamples + (size << 1); - + IntraAngVertical_16bit_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( - size, + size, refSampMain, - predictionPtr, + predictionPtr, predictionBufferStride, EB_FALSE, intraPredAngle); @@ -3193,7 +3193,7 @@ static void IntraModeAngular_19To25( const EB_U32 predictionBufferStride, //input parameter, denotes the stride for the prediction ptr EB_U8 *refAbove, EB_BOOL *AboveReadyFlag - ) + ) { EB_U8 *refSampMain; EB_U8 *refSampSide; @@ -3205,12 +3205,12 @@ static void IntraModeAngular_19To25( EB_U32 invAngleSum = 128; // rounding used for (shift by 8) EB_S32 idx; EB_U32 index; - + if (INTRA_VERTICAL_MODE - mode < 9 ) { // check for index range, has to be less than size of array intraPredAngle = intraModeAngularTableNegative[INTRA_VERTICAL_MODE - mode]; invAngle = invIntraModeAngularTable[INTRA_VERTICAL_MODE - mode]; } - + //We just need to copy above Reference pixels only for ONE TIME for all modes of this group //where Filtered or non-Filtered are always used (8x8,32x32) if( (*AboveReadyFlag == EB_FALSE) || (size==16) ){ @@ -3220,8 +3220,8 @@ static void IntraModeAngular_19To25( for(index = 0; index < numberOfSamples; index++) { refAbove[index+size-1] = refSamples[refOffset + index]; } - } - + } + refSampMain = refAbove + (size - 1); // Extend the Main reference to the left for angles with negative slope @@ -3232,11 +3232,11 @@ static void IntraModeAngular_19To25( refSampMain[signIndex] = refSampSide[idx]; } - + IntraAngVertical_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( - size, + size, refSampMain, - predictionPtr, + predictionPtr, predictionBufferStride, EB_FALSE, intraPredAngle); @@ -3254,7 +3254,7 @@ static void IntraModeAngular16bit_19To25( const EB_U32 predictionBufferStride, //input parameter, denotes the stride for the prediction ptr EB_U16 *refAbove, EB_BOOL *AboveReadyFlag - ) + ) { EB_U16 *refSampMain; EB_U16 *refSampSide; @@ -3266,12 +3266,12 @@ static void IntraModeAngular16bit_19To25( EB_U32 invAngleSum = 128; // rounding used for (shift by 8) EB_S32 idx; EB_U32 index; - + if (INTRA_VERTICAL_MODE - mode < 9) { // check for index range, has to be less than size of array intraPredAngle = intraModeAngularTableNegative[INTRA_VERTICAL_MODE - mode]; invAngle = invIntraModeAngularTable[INTRA_VERTICAL_MODE - mode]; } - + //We just need to copy above Reference pixels only for ONE TIME for all modes of this group //where Filtered or non-Filtered are always used (8x8,32x32) if( (*AboveReadyFlag == EB_FALSE) || (size==16) ){ @@ -3281,8 +3281,8 @@ static void IntraModeAngular16bit_19To25( for(index = 0; index < numberOfSamples; index++) { refAbove[index+size-1] = refSamples[refOffset + index]; } - } - + } + refSampMain = refAbove + (size - 1); // Extend the Main reference to the left for angles with negative slope @@ -3293,11 +3293,11 @@ static void IntraModeAngular16bit_19To25( refSampMain[signIndex] = refSampSide[idx]; } - + IntraAngVertical_16bit_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( - size, + size, refSampMain, - predictionPtr, + predictionPtr, predictionBufferStride, EB_FALSE, intraPredAngle); @@ -3316,7 +3316,7 @@ static void IntraModeAngular_11To17( EB_U8 *predictionPtr, //output parameter, pointer to the prediction const EB_U32 predictionBufferStride, //input parameter, denotes the stride for the prediction ptr EB_U8 *refLeft, - EB_BOOL *LeftReadyFlag) + EB_BOOL *LeftReadyFlag) { EB_U8 *refSampMain; EB_U8 *refSampSide; @@ -3324,7 +3324,7 @@ static void IntraModeAngular_11To17( EB_S32 signIndex; const EB_U32 refOffset = (size << 1); EB_U32 index; - + EB_S32 intraPredAngle = intraModeAngularTableNegative[ mode - INTRA_HORIZONTAL_MODE]; EB_U32 invAngle = invIntraModeAngularTable[mode - INTRA_HORIZONTAL_MODE]; EB_U32 invAngleSum = 128; // rounding used for (shift by 8) @@ -3337,24 +3337,24 @@ static void IntraModeAngular_11To17( // Copy left reference samples (inc top left)(DO we really need all the data including topright??) for(index = 0; index < numberOfSamples; index++) { refLeft[index+size-1] = refSamples[refOffset - index]; - } + } } - + refSampMain = refLeft + (size - 1); - // Extend the Main reference to the left for angles with negative slope + // Extend the Main reference to the left for angles with negative slope refSampSide = refSamples + (size << 1); for(signIndex = -1; signIndex > (EB_S32)((EB_S32)size*intraPredAngle >> 5); --signIndex) { invAngleSum += invAngle; refSampMain[signIndex] = refSampSide[invAngleSum >> 8]; - } + } + - IntraAngHorizontal_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( - size, + size, refSampMain, - predictionPtr, + predictionPtr, predictionBufferStride, EB_FALSE, intraPredAngle); @@ -3371,7 +3371,7 @@ static void IntraModeAngular16bit_11To17( EB_U16 *predictionPtr, //output parameter, pointer to the prediction const EB_U32 predictionBufferStride, //input parameter, denotes the stride for the prediction ptr EB_U16 *refLeft, - EB_BOOL *LeftReadyFlag) + EB_BOOL *LeftReadyFlag) { EB_U16 *refSampMain; EB_U16 *refSampSide; @@ -3379,7 +3379,7 @@ static void IntraModeAngular16bit_11To17( EB_S32 signIndex; const EB_U32 refOffset = (size << 1); EB_U32 index; - + EB_S32 intraPredAngle = intraModeAngularTableNegative[ mode - INTRA_HORIZONTAL_MODE]; EB_U32 invAngle = invIntraModeAngularTable[mode - INTRA_HORIZONTAL_MODE]; EB_U32 invAngleSum = 128; // rounding used for (shift by 8) @@ -3392,24 +3392,24 @@ static void IntraModeAngular16bit_11To17( // Copy left reference samples (inc top left)(DO we really need all the data including topright??) for(index = 0; index < numberOfSamples; index++) { refLeft[index+size-1] = refSamples[refOffset - index]; - } + } } - + refSampMain = refLeft + (size - 1); - // Extend the Main reference to the left for angles with negative slope + // Extend the Main reference to the left for angles with negative slope refSampSide = refSamples + (size << 1); for(signIndex = -1; signIndex > (EB_S32)((EB_S32)size*intraPredAngle >> 5); --signIndex) { invAngleSum += invAngle; refSampMain[signIndex] = refSampSide[invAngleSum >> 8]; - } + } + - IntraAngHorizontal_16bit_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( - size, + size, refSampMain, - predictionPtr, + predictionPtr, predictionBufferStride, EB_FALSE, intraPredAngle); @@ -3428,15 +3428,15 @@ static void IntraModeAngular_3To9( const EB_U32 predictionBufferStride) //input parameter, denotes the stride for the prediction ptr { EB_U8 *refSampMain; - + EB_S32 intraPredAngle = (INTRA_HORIZONTAL_MODE - mode) < 9 ? intraModeAngularTable[INTRA_HORIZONTAL_MODE - mode]:0; - + refSampMain = refSamples-1; - + IntraAngHorizontal_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( - size, + size, refSampMain, - predictionPtr, + predictionPtr, predictionBufferStride, EB_FALSE, intraPredAngle); @@ -3454,16 +3454,16 @@ static void IntraModeAngular16bit_3To9( const EB_U32 predictionBufferStride) //input parameter, denotes the stride for the prediction ptr { EB_U16 *refSampMain; - + EB_S32 intraPredAngle = (INTRA_HORIZONTAL_MODE - mode) < 9 ? intraModeAngularTable[INTRA_HORIZONTAL_MODE - mode] : 0; - + refSampMain = refSamples-1; - + IntraAngHorizontal_16bit_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( - size, + size, refSampMain, - predictionPtr, + predictionPtr, predictionBufferStride, EB_FALSE, intraPredAngle); @@ -3488,7 +3488,7 @@ static inline void IntraModeAngular_all( EB_BOOL *LeftReadyFlag) { - + switch(mode){ case 34: @@ -3501,15 +3501,15 @@ static inline void IntraModeAngular_all( break; case 33: case 32: case 31: case 30: case 29: case 28: case 27: - IntraModeAngular_27To33( + IntraModeAngular_27To33( mode, puSize, refSamples, predictionPtr, predictionBufferStride); break; - case 25: case 24: case 23: case 22: case 21: case 20: case 19: - IntraModeAngular_19To25( + case 25: case 24: case 23: case 22: case 21: case 20: case 19: + IntraModeAngular_19To25( mode, puSize, refSamples, @@ -3527,7 +3527,7 @@ static inline void IntraModeAngular_all( EB_FALSE); break; case 17: case 16: case 15: case 14: case 13: case 12: case 11: - IntraModeAngular_11To17( + IntraModeAngular_11To17( mode, puSize, refSamples, @@ -3537,7 +3537,7 @@ static inline void IntraModeAngular_all( LeftReadyFlag); break; case 9: case 8: case 7: case 6: case 5: case 4: case 3: - IntraModeAngular_3To9( + IntraModeAngular_3To9( mode, puSize, refSamplesReverse, @@ -3545,7 +3545,7 @@ static inline void IntraModeAngular_all( predictionBufferStride); break; case 2: - + IntraAng2_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( puSize, refSamplesReverse, @@ -3571,7 +3571,7 @@ static inline void IntraModeAngular16bit_all( EB_BOOL *LeftReadyFlag) { - + switch(mode){ case 34: @@ -3591,8 +3591,8 @@ static inline void IntraModeAngular16bit_all( predictionPtr, predictionBufferStride); break; - case 25: case 24: case 23: case 22: case 21: case 20: case 19: - IntraModeAngular16bit_19To25( + case 25: case 24: case 23: case 22: case 21: case 20: case 19: + IntraModeAngular16bit_19To25( mode, puSize, refSamples, @@ -3620,7 +3620,7 @@ static inline void IntraModeAngular16bit_all( LeftReadyFlag); break; case 9: case 8: case 7: case 6: case 5: case 4: case 3: - IntraModeAngular16bit_3To9( + IntraModeAngular16bit_3To9( mode, puSize, refSamplesReverse, @@ -3628,7 +3628,7 @@ static inline void IntraModeAngular16bit_all( predictionBufferStride); break; case 2: - + IntraAng2_16bit_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( puSize, refSamplesReverse, @@ -3683,7 +3683,7 @@ EB_ERRORTYPE IntraPredictionCl( CHECK_REPORT_ERROR( (puWidth == puHeight), - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_INTRA_PRED_ERROR2); @@ -3726,7 +3726,7 @@ EB_ERRORTYPE IntraPredictionCl( case 1: yIntraReferenceArray = contextPtr->yIntraReferenceArrayReverse; - + IntraDCLuma_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( puSize, yIntraReferenceArray, @@ -3737,11 +3737,11 @@ EB_ERRORTYPE IntraPredictionCl( break; case 2: - + yIntraReferenceArray = (diffMode > intraLumaFilterTable[Log2f(puWidth)-2])? contextPtr->yIntraFilteredReferenceArrayReverse : contextPtr->yIntraReferenceArrayReverse; - - + + IntraVerticalLuma_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( puSize, yIntraReferenceArray, @@ -3763,15 +3763,15 @@ EB_ERRORTYPE IntraPredictionCl( EB_FALSE); break; - + case 4: - + yIntraReferenceArray = (diffMode > intraLumaFilterTable[Log2f(puWidth)-2])? contextPtr->yIntraFilteredReferenceArray : contextPtr->yIntraReferenceArray; yIntraReferenceArrayReverse = (diffMode > intraLumaFilterTable[Log2f(puWidth)-2])? contextPtr->yIntraFilteredReferenceArrayReverse : contextPtr->yIntraReferenceArrayReverse; - IntraModeAngular_all( + IntraModeAngular_all( lumaMode, puSize, yIntraReferenceArray, @@ -3788,7 +3788,7 @@ EB_ERRORTYPE IntraPredictionCl( default: break; } - } + } if (componentMask & PICTURE_BUFFER_DESC_CHROMA_MASK) { @@ -3815,7 +3815,7 @@ EB_ERRORTYPE IntraPredictionCl( switch(funcIndex) { case 0: - + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraPlanar_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( @@ -3825,7 +3825,7 @@ EB_ERRORTYPE IntraPredictionCl( candidateBufferPtr->predictionPtr->strideCb, EB_FALSE); } - + // Cr Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cr_FLAG) { IntraPlanar_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( @@ -3839,7 +3839,7 @@ EB_ERRORTYPE IntraPredictionCl( break; case 2: - + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraVerticalChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -3849,7 +3849,7 @@ EB_ERRORTYPE IntraPredictionCl( candidateBufferPtr->predictionPtr->strideCb, EB_FALSE); } - + // Cr Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cr_FLAG) { IntraVerticalChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -3863,7 +3863,7 @@ EB_ERRORTYPE IntraPredictionCl( break; case 3: - + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraHorzChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -3887,7 +3887,7 @@ EB_ERRORTYPE IntraPredictionCl( break; case 1: - + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraDCChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -3897,7 +3897,7 @@ EB_ERRORTYPE IntraPredictionCl( candidateBufferPtr->predictionPtr->strideCb, EB_FALSE); } - + // Cr Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cr_FLAG) { IntraDCChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -3912,7 +3912,7 @@ EB_ERRORTYPE IntraPredictionCl( case 4: - // Cb Intra Prediction + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraModeAngular_all( chromaMode, @@ -3927,7 +3927,7 @@ EB_ERRORTYPE IntraPredictionCl( & contextPtr->LeftReadyFlagCb); } - // Cr Intra Prediction + // Cr Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cr_FLAG) { IntraModeAngular_all( chromaMode, @@ -3995,11 +3995,11 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( CHECK_REPORT_ERROR( (puWidth == puHeight), - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_INTRA_PRED_ERROR2); if (componentMask & PICTURE_BUFFER_DESC_LUMA_MASK) { - + lumaMode = candidateBufferPtr->candidatePtr->intraLumaMode; puOriginIndex = ((puOriginY & (lcuSize-1)) * candidateBufferPtr->predictionPtr->strideY) + (puOriginX & (lcuSize-1)); @@ -4031,7 +4031,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( case 1: yIntraReferenceArray = contextPtr->yIntraReferenceArrayReverse; - + IntraDCLuma_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( puSize, yIntraReferenceArray, @@ -4042,11 +4042,11 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( break; case 2: - + yIntraReferenceArray = (diffMode > intraLumaFilterTable[Log2f(puWidth)-2])? contextPtr->yIntraFilteredReferenceArrayReverse : contextPtr->yIntraReferenceArrayReverse; - - + + IntraVerticalLuma_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( puSize, yIntraReferenceArray, @@ -4068,15 +4068,15 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( EB_FALSE); break; - + case 4: - + yIntraReferenceArray = (diffMode > intraLumaFilterTable[Log2f(puWidth)-2])? contextPtr->yIntraFilteredReferenceArray : contextPtr->yIntraReferenceArray; yIntraReferenceArrayReverse = (diffMode > intraLumaFilterTable[Log2f(puWidth)-2])? contextPtr->yIntraFilteredReferenceArrayReverse : contextPtr->yIntraReferenceArrayReverse; - IntraModeAngular_all( + IntraModeAngular_all( lumaMode, puSize, yIntraReferenceArray, @@ -4093,7 +4093,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( default: break; } - } + } if (componentMask & PICTURE_BUFFER_DESC_CHROMA_MASK) { @@ -4111,7 +4111,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( switch(funcIndex) { case 0: - + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraPlanar_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( @@ -4121,7 +4121,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( candidateBufferPtr->predictionPtr->strideCb, EB_FALSE); } - + // Cr Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cr_FLAG) { IntraPlanar_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( @@ -4135,7 +4135,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( break; case 2: - + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraVerticalChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -4145,7 +4145,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( candidateBufferPtr->predictionPtr->strideCb, EB_FALSE); } - + // Cr Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cr_FLAG) { IntraVerticalChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -4159,7 +4159,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( break; case 3: - + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraHorzChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -4183,7 +4183,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( break; case 1: - + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraDCChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -4193,7 +4193,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( candidateBufferPtr->predictionPtr->strideCb, EB_FALSE); } - + // Cr Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cr_FLAG) { IntraDCChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -4208,7 +4208,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( case 4: - // Cb Intra Prediction + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraModeAngular_all( chromaMode, @@ -4223,7 +4223,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionCl( & contextPtr->LeftReadyFlagCb); } - // Cr Intra Prediction + // Cr Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cr_FLAG) { IntraModeAngular_all( chromaMode, @@ -4257,14 +4257,14 @@ EB_ERRORTYPE Intra4x4IntraPredictionOl( EB_U32 lcuSize, EB_U32 componentMask, PictureControlSet_t *pictureControlSetPtr, - ModeDecisionCandidateBuffer_t *candidateBufferPtr, - EB_PTR predictionContextPtr) + ModeDecisionCandidateBuffer_t *candidateBufferPtr, + EB_PTR predictionContextPtr) { EB_ERRORTYPE return_error = EB_ErrorNone; EB_U32 openLoopIntraCandidateIndex = candidateBufferPtr->candidatePtr->intraLumaMode; const EB_U32 puOriginIndex = ((puOriginY & (lcuSize-1)) * candidateBufferPtr->predictionPtr->strideY) + (puOriginX & (lcuSize-1)); const EB_U32 puSize = puWidth; - + // Map the mode to the function table index EB_U32 funcIndex = (openLoopIntraCandidateIndex < 2) ? openLoopIntraCandidateIndex : @@ -4282,7 +4282,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionOl( switch(funcIndex) { case 0: - + IntraPlanar_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( puSize, intraRefPtr->yIntraReferenceArrayReverse, @@ -4293,7 +4293,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionOl( break; case 1: - + IntraDCLuma_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( puSize, intraRefPtr->yIntraReferenceArrayReverse, @@ -4304,7 +4304,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionOl( break; case 2: - + IntraVerticalLuma_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( puSize, intraRefPtr->yIntraReferenceArrayReverse, @@ -4315,7 +4315,7 @@ EB_ERRORTYPE Intra4x4IntraPredictionOl( break; case 3: - + IntraHorzLuma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( puSize, intraRefPtr->yIntraReferenceArrayReverse, @@ -4326,8 +4326,8 @@ EB_ERRORTYPE Intra4x4IntraPredictionOl( break; case 4: - - IntraModeAngular_all( + + IntraModeAngular_all( openLoopIntraCandidateIndex, puSize, intraRefPtr->yIntraReferenceArray, @@ -4344,14 +4344,14 @@ EB_ERRORTYPE Intra4x4IntraPredictionOl( default: break; } - + return return_error; } /********************************************* * Encode Pass Intra Prediction - * Calculates a conformant H.265 prediction + * Calculates a conformant H.265 prediction * for an Intra Prediction Unit *********************************************/ EB_ERRORTYPE EncodePassIntraPrediction( @@ -4447,7 +4447,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( break; default: - IntraModeAngular_all( + IntraModeAngular_all( lumaMode, puSize, yIntraReferenceArray, @@ -4466,7 +4466,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( } } - + //*********************************** // Chroma //*********************************** @@ -4480,7 +4480,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( } chromaModeAdj = lumaMode; - chromaModeAdj = + chromaModeAdj = (chromaMode == EB_INTRA_CHROMA_PLANAR) ? EB_INTRA_PLANAR : (chromaMode == EB_INTRA_CHROMA_VERTICAL) ? EB_INTRA_VERTICAL : (chromaMode == EB_INTRA_CHROMA_HORIZONTAL) ? EB_INTRA_HORIZONTAL : @@ -4528,7 +4528,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( break; case EB_INTRA_VERTICAL: - + // Cb Intra Prediction IntraVerticalChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( puChromaSize, @@ -4536,7 +4536,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( predictionPtr->bufferCb + chromaOffset, predictionPtr->strideCb, EB_FALSE); - + // Cr Intra Prediction IntraVerticalChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( puChromaSize, @@ -4548,7 +4548,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( break; case EB_INTRA_HORIZONTAL: - + // Cb Intra Prediction IntraHorzChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( puChromaSize, @@ -4556,7 +4556,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( predictionPtr->bufferCb + chromaOffset, predictionPtr->strideCb, EB_FALSE); - + // Cr Intra Prediction IntraHorzChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( @@ -4569,7 +4569,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( break; case EB_INTRA_DC: - + // Cb Intra Prediction IntraDCChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( puChromaSize, @@ -4578,7 +4578,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( predictionPtr->strideCb, EB_FALSE); - + // Cr Intra Prediction IntraDCChroma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( puChromaSize, @@ -4594,9 +4594,9 @@ EB_ERRORTYPE EncodePassIntraPrediction( // *Note - For Chroma DM mode, use the Luma Angular mode // to generate the prediction. - // Cb Intra Prediction + // Cb Intra Prediction IntraModeAngular_all( - chromaModeAdj, + chromaModeAdj, puChromaSize, cbIntraReferenceArray, cbIntraReferenceArrayReverse, @@ -4607,7 +4607,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( referenceSamples->ReferenceLeftLineCb, &referenceSamples->LeftReadyFlagCb); - // Cr Intra Prediction + // Cr Intra Prediction IntraModeAngular_all( chromaModeAdj, puChromaSize, @@ -4632,7 +4632,7 @@ EB_ERRORTYPE EncodePassIntraPrediction( /********************************************* * Encode Pass Intra Prediction 16bit - * Calculates a conformant H.265 prediction + * Calculates a conformant H.265 prediction * for an Intra Prediction Unit *********************************************/ EB_ERRORTYPE EncodePassIntraPrediction16bit( @@ -4725,7 +4725,7 @@ EB_ERRORTYPE EncodePassIntraPrediction16bit( break; default: - IntraModeAngular16bit_all( + IntraModeAngular16bit_all( lumaMode, puSize, yIntraReferenceArray, @@ -4744,7 +4744,7 @@ EB_ERRORTYPE EncodePassIntraPrediction16bit( } } - + //*********************************** // Chroma //*********************************** @@ -4758,7 +4758,7 @@ EB_ERRORTYPE EncodePassIntraPrediction16bit( } chromaModeAdj = lumaMode; - chromaModeAdj = + chromaModeAdj = (chromaMode == EB_INTRA_CHROMA_PLANAR) ? EB_INTRA_PLANAR : (chromaMode == EB_INTRA_CHROMA_VERTICAL) ? EB_INTRA_VERTICAL : (chromaMode == EB_INTRA_CHROMA_HORIZONTAL) ? EB_INTRA_HORIZONTAL : @@ -4809,7 +4809,7 @@ EB_ERRORTYPE EncodePassIntraPrediction16bit( (EB_U16*)predictionPtr->bufferCb + chromaOffset, predictionPtr->strideCb, EB_FALSE); - + IntraVerticalChroma_16bit_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( puChromaSize, crIntraReferenceArrayReverse, @@ -4825,7 +4825,7 @@ EB_ERRORTYPE EncodePassIntraPrediction16bit( (EB_U16*)predictionPtr->bufferCb + chromaOffset, predictionPtr->strideCb, EB_FALSE); - + IntraHorzChroma_16bit_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( puChromaSize, crIntraReferenceArrayReverse, @@ -4855,7 +4855,7 @@ EB_ERRORTYPE EncodePassIntraPrediction16bit( // *Note - For Chroma DM mode, use the Luma Angular mode // to generate the prediction. IntraModeAngular16bit_all( - chromaModeAdj, + chromaModeAdj, puChromaSize, cbIntraReferenceArray, cbIntraReferenceArrayReverse, @@ -4899,19 +4899,19 @@ EB_ERRORTYPE IntraOpenLoopReferenceSamplesCtor( *contextDblPtr = contextPtr; EB_MALLOC(EB_U8*, contextPtr->yIntraReferenceArray, sizeof(EB_U8) * (4 * MAX_LCU_SIZE + 1), EB_N_PTR); - + EB_MALLOC(EB_U8*, contextPtr->yIntraReferenceArrayReverse, sizeof(EB_U8) * (4 * MAX_LCU_SIZE + 2), EB_N_PTR); contextPtr->yIntraReferenceArrayReverse++; - + return EB_ErrorNone; } - + EB_ERRORTYPE UpdateNeighborSamplesArrayOL( IntraReferenceSamples_t *intraRefPtr, - EbPictureBufferDesc_t *inputPtr, + EbPictureBufferDesc_t *inputPtr, EB_U32 stride, EB_U32 srcOriginX, EB_U32 srcOriginY, @@ -4948,10 +4948,10 @@ EB_ERRORTYPE UpdateNeighborSamplesArrayOL( // Get the left-column count = blockSizeHalf; if (pictureLeftBoundary == EB_FALSE) { - + readPtr = srcPtr - 1; count = ((srcOriginY + count) > height) ? count - ((srcOriginY + count) - height) : count; - + for(idx = 0; idx < count; ++idx) { *dstPtr = *readPtr; @@ -4962,10 +4962,10 @@ EB_ERRORTYPE UpdateNeighborSamplesArrayOL( dstPtr += (blockSizeHalf- count); } else { - + dstPtr += count; } - + // Get the upper left sample if (pictureLeftBoundary == EB_FALSE && pictureTopBoundary == EB_FALSE) { @@ -4976,45 +4976,45 @@ EB_ERRORTYPE UpdateNeighborSamplesArrayOL( dstPtr ++; } - + // Get the top-row count = blockSizeHalf; if (pictureTopBoundary == EB_FALSE) { readPtr = srcPtr - stride; - + count = ((srcOriginX + count) > width) ? count - ((srcOriginX + count) - width) : count; EB_MEMCPY(dstPtr, readPtr, count); dstPtr += (blockSizeHalf - count); } else { - + dstPtr += count; } - + //at the begining of a CU Loop, the Above/Left scratch buffers are not ready to be used. intraRefPtr->AboveReadyFlagY = EB_FALSE; intraRefPtr->LeftReadyFlagY = EB_FALSE; - //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples + //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples /* TL T0 T1 T2 T3 T4 T5 T6 T7 TL T0 T1 T2 T3 T4 T5 T6 T7 L0 |----------------| L7 |----------------| - L1 | | <======= L6 | | + L1 | | <======= L6 | | L2 | | L5 | | L3 |----------------| L4 |----------------| - L4 L3 + L4 L3 L5 L2 L6 L1 - L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order + L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order junk - */ + */ EB_MEMCPY(yBorder + blockSizeHalf, yBorderReverse + blockSizeHalf, blockSizeHalf + 1); yBorderLoc = yBorder + blockSizeHalf - 1 ; for(count = 0; count< blockSizeHalf; count++){ - + *yBorderLoc = yBorderReverse[count]; yBorderLoc--; } @@ -5024,7 +5024,7 @@ EB_ERRORTYPE UpdateNeighborSamplesArrayOL( EB_ERRORTYPE UpdateChromaNeighborSamplesArrayOL( IntraReferenceSamples_t *intraRefPtr, - EbPictureBufferDesc_t *inputPtr, + EbPictureBufferDesc_t *inputPtr, EB_U32 stride, EB_U32 srcOriginX, EB_U32 srcOriginY, @@ -5077,11 +5077,11 @@ EB_ERRORTYPE UpdateChromaNeighborSamplesArrayOL( // Get the left-column count = blockSizeHalf; if (pictureLeftBoundary == EB_FALSE) { - + cbReadPtr = cbSrcPtr - 1; crReadPtr = crSrcPtr - 1; count = ((cuChromaOriginY + count) > height) ? count - ((cuChromaOriginY + count) - height) : count; - + for(idx = 0; idx < count; ++idx) { *cbDstPtr = *cbReadPtr; @@ -5097,11 +5097,11 @@ EB_ERRORTYPE UpdateChromaNeighborSamplesArrayOL( crDstPtr += (blockSizeHalf- count); } else { - + cbDstPtr += count; crDstPtr += count; } - + // Get the upper left sample if (pictureLeftBoundary == EB_FALSE && pictureTopBoundary == EB_FALSE) { cbReadPtr = cbSrcPtr - cbStride- 1 ; @@ -5116,13 +5116,13 @@ EB_ERRORTYPE UpdateChromaNeighborSamplesArrayOL( cbDstPtr ++; crDstPtr ++; } - + // Get the top-row count = blockSizeHalf; if (pictureTopBoundary == EB_FALSE) { cbReadPtr = cbSrcPtr - cbStride; - + count = ((cuChromaOriginX + count) > width) ? count - ((cuChromaOriginX + count) - width) : count; EB_MEMCPY(cbDstPtr, cbReadPtr, count); cbDstPtr += (blockSizeHalf - count); @@ -5133,10 +5133,10 @@ EB_ERRORTYPE UpdateChromaNeighborSamplesArrayOL( crDstPtr += (blockSizeHalf - count); } else { - + crDstPtr += count; } - + //at the begining of a CU Loop, the Above/Left scratch buffers are not ready to be used. intraRefPtr->AboveReadyFlagCb = EB_FALSE; @@ -5145,19 +5145,19 @@ EB_ERRORTYPE UpdateChromaNeighborSamplesArrayOL( intraRefPtr->AboveReadyFlagCr = EB_FALSE; intraRefPtr->LeftReadyFlagCr = EB_FALSE; - //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples + //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples /* TL T0 T1 T2 T3 T4 T5 T6 T7 TL T0 T1 T2 T3 T4 T5 T6 T7 L0 |----------------| L7 |----------------| - L1 | | <======= L6 | | + L1 | | <======= L6 | | L2 | | L5 | | L3 |----------------| L4 |----------------| - L4 L3 + L4 L3 L5 L2 L6 L1 - L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order + L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order junk - */ + */ EB_MEMCPY(cbBorder + blockSizeHalf, cbBorderReverse + blockSizeHalf, blockSizeHalf + 1); EB_MEMCPY(crBorder + blockSizeHalf, crBorderReverse + blockSizeHalf, blockSizeHalf + 1); @@ -5165,7 +5165,7 @@ EB_ERRORTYPE UpdateChromaNeighborSamplesArrayOL( crBorderLoc = crBorder + blockSizeHalf - 1 ; for(count = 0; count< blockSizeHalf; count++){ - + *cbBorderLoc = cbBorderReverse[count]; cbBorderLoc--; @@ -5181,7 +5181,7 @@ EB_ERRORTYPE UpdateChromaNeighborSamplesArrayOL( */ EB_ERRORTYPE UpdateNeighborSamplesArrayOpenLoop( IntraReferenceSamplesOpenLoop_t *intraRefPtr, - EbPictureBufferDesc_t *inputPtr, + EbPictureBufferDesc_t *inputPtr, EB_U32 stride, EB_U32 srcOriginX, EB_U32 srcOriginY, @@ -5196,7 +5196,7 @@ EB_ERRORTYPE UpdateNeighborSamplesArrayOpenLoop( EB_U8 *readPtr; EB_U32 count; - + EB_U8 *yBorderReverse = intraRefPtr->yIntraReferenceArrayReverse; EB_U8 *yBorder = intraRefPtr->yIntraReferenceArray; EB_U8 *yBorderLoc; @@ -5218,10 +5218,10 @@ EB_ERRORTYPE UpdateNeighborSamplesArrayOpenLoop( count = blockSizeHalf; if (srcOriginX != 0) { - + readPtr = srcPtr - 1; count = ((srcOriginY + count) > height) ? count - ((srcOriginY + count) - height) : count; - + for(idx = 0; idx < count; ++idx) { *dstPtr = *readPtr; @@ -5232,10 +5232,10 @@ EB_ERRORTYPE UpdateNeighborSamplesArrayOpenLoop( dstPtr += (blockSizeHalf- count); } else { - + dstPtr += count; } - + // Get the upper left sample if (srcOriginX != 0 && srcOriginY != 0) { @@ -5246,46 +5246,46 @@ EB_ERRORTYPE UpdateNeighborSamplesArrayOpenLoop( dstPtr ++; } - + // Get the top-row count = blockSizeHalf; if (srcOriginY != 0) { readPtr = srcPtr - stride; - + count = ((srcOriginX + count) > width) ? count - ((srcOriginX + count) - width) : count; EB_MEMCPY(dstPtr, readPtr, count); dstPtr += (blockSizeHalf - count); } else { - + dstPtr += count; } - + //at the begining of a CU Loop, the Above/Left scratch buffers are not ready to be used. intraRefPtr->AboveReadyFlagY = EB_FALSE; intraRefPtr->LeftReadyFlagY = EB_FALSE; - //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples + //For SIMD purposes, provide a copy of the reference buffer with reverse order of Left samples /* TL T0 T1 T2 T3 T4 T5 T6 T7 TL T0 T1 T2 T3 T4 T5 T6 T7 L0 |----------------| L7 |----------------| - L1 | | <======= L6 | | + L1 | | <======= L6 | | L2 | | L5 | | L3 |----------------| L4 |----------------| - L4 L3 + L4 L3 L5 L2 L6 L1 - L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order + L7 <-- pointer (Regular Order) L0<-- pointer Reverse Order junk - */ + */ EB_MEMCPY(yBorder + blockSizeHalf, yBorderReverse + blockSizeHalf, blockSizeHalf + 1); yBorderLoc = yBorder + blockSizeHalf - 1 ; for(count = 0; countintraRefPtr->yIntraReferenceArrayReverse, @@ -5325,7 +5325,7 @@ EB_ERRORTYPE IntraPredictionOpenLoop( break; case 1: - + IntraDCLuma_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( cuSize, contextPtr->intraRefPtr->yIntraReferenceArrayReverse, @@ -5336,7 +5336,7 @@ EB_ERRORTYPE IntraPredictionOpenLoop( break; case 2: - + IntraVerticalLuma_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( cuSize, contextPtr->intraRefPtr->yIntraReferenceArrayReverse, @@ -5347,7 +5347,7 @@ EB_ERRORTYPE IntraPredictionOpenLoop( break; case 3: - + IntraHorzLuma_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)]( cuSize, contextPtr->intraRefPtr->yIntraReferenceArrayReverse, @@ -5358,8 +5358,8 @@ EB_ERRORTYPE IntraPredictionOpenLoop( break; case 4: - - IntraModeAngular_all( + + IntraModeAngular_all( openLoopIntraCandidateIndex, cuSize, contextPtr->intraRefPtr->yIntraReferenceArray, @@ -5376,7 +5376,7 @@ EB_ERRORTYPE IntraPredictionOpenLoop( default: break; } - + return return_error; } @@ -5400,10 +5400,10 @@ EB_ERRORTYPE IntraPredictionOl( const EB_U32 puOriginIndex = ((puOriginY & (63)) * 64) + (puOriginX & (63)); EB_U32 openLoopIntraCandidateIndex = candidateBufferPtr->candidatePtr->intraLumaMode; - + const EB_U32 puSize = puWidth; const EB_U32 puIndex = mdContextPtr->puItr; - + // Map the mode to the function table index EB_U32 funcIndex = (openLoopIntraCandidateIndex < 2) ? openLoopIntraCandidateIndex : @@ -5620,7 +5620,7 @@ EB_ERRORTYPE IntraPredictionOl( case 4: - // Cb Intra Prediction + // Cb Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { IntraModeAngular_all( chromaMode, @@ -5635,7 +5635,7 @@ EB_ERRORTYPE IntraPredictionOl( &intraRefPtr->LeftReadyFlagCb); } - // Cr Intra Prediction + // Cr Intra Prediction if (componentMask & PICTURE_BUFFER_DESC_Cr_FLAG) { IntraModeAngular_all( chromaMode, @@ -5656,7 +5656,7 @@ EB_ERRORTYPE IntraPredictionOl( break; } } - + return return_error; } @@ -5775,4 +5775,3 @@ EB_ERRORTYPE IntraPredOnSrc( } return return_error; } - diff --git a/Source/Lib/Codec/EbMdRateEstimation.c b/Source/Lib/Codec/EbMdRateEstimation.c index 62a2f63c9..723ae5ab3 100644 --- a/Source/Lib/Codec/EbMdRateEstimation.c +++ b/Source/Lib/Codec/EbMdRateEstimation.c @@ -65,7 +65,7 @@ EB_ERRORTYPE GetRefIndexFractionBits( return return_error; } /********************************************************************* - * GetMvdFractionBits + * EbHevcGetMvdFractionBits * Gets the motion vector difference Fraction Bits * * mvdX @@ -80,7 +80,7 @@ EB_ERRORTYPE GetRefIndexFractionBits( * fractionBitNum * output for the fraction number of bits needed for motion vector difference *********************************************************************/ -EB_ERRORTYPE GetMvdFractionBits( +EB_ERRORTYPE EbHevcGetMvdFractionBits( EB_S32 mvdX, EB_S32 mvdY, MdRateEstimationContext_t *mdRateEstimationArray, @@ -154,7 +154,7 @@ EB_ERRORTYPE GetMvdFractionBits( return return_error; } /********************************************************************* - * MeGetMvdFractionBits + * MeEbHevcGetMvdFractionBits * Gets the motion vector difference Fraction Bits for ME * * mvdX @@ -169,7 +169,7 @@ EB_ERRORTYPE GetMvdFractionBits( * fractionBitNum * output for the fraction number of bits needed for motion vector difference *********************************************************************/ -EB_ERRORTYPE MeGetMvdFractionBits( +EB_ERRORTYPE MeEbHevcGetMvdFractionBits( EB_S32 mvdX, EB_S32 mvdY, EB_BitFraction *mvdBitsPtr, diff --git a/Source/Lib/Codec/EbMdRateEstimation.h b/Source/Lib/Codec/EbMdRateEstimation.h index 3062e03a5..e31c7bb0d 100644 --- a/Source/Lib/Codec/EbMdRateEstimation.h +++ b/Source/Lib/Codec/EbMdRateEstimation.h @@ -19,18 +19,18 @@ extern "C" { #define NUMBER_OF_SKIP_FLAG_CASES 6 // number of cases for bit estimation for skip flag -#define NUMBER_OF_MERGE_FLAG_CASES 2 // number of cases for bit estimation for merge flag +#define NUMBER_OF_MERGE_FLAG_CASES 2 // number of cases for bit estimation for merge flag -#define NUMBER_OF_MERGE_INDEX_CASES 5 // number of cases for bit estimation for merge index +#define NUMBER_OF_MERGE_INDEX_CASES 5 // number of cases for bit estimation for merge index #define NUMBER_OF_ALF_CTRL_FLAG_CASES 0 // number of cases for bit estimation for ALF control flag #define NUMBER_OF_INTRA_PART_SIZE_CASES 2 // number of cases for bit estimation for Intra partition size //Note ** to be modified after adding all AMP modes -#define NUMBER_OF_INTER_PART_SIZE_CASES 8 // number of cases for bit estimation for Inter partition size +#define NUMBER_OF_INTER_PART_SIZE_CASES 8 // number of cases for bit estimation for Inter partition size -#define NUMBER_OF_AMP_XPOS_CASES 0 // number of cases for bit estimation for asymmetric motion partition size +#define NUMBER_OF_AMP_XPOS_CASES 0 // number of cases for bit estimation for asymmetric motion partition size #define NUMBER_OF_AMP_YPOS_CASES 0 // number of cases for bit estimation for asymmetric motion partition size @@ -42,7 +42,7 @@ extern "C" { #define NUMBER_OF_INTER_BI_DIR_CASES 8 // number of cases for bit estimation for inter bi-prediction direction : unipred - bipred per depth -#define NUMBER_OF_INTER_UNI_DIR_CASES 2 // number of cases for bit estimation for inter uni-prediction direction : unipred List 0 - unipred List 1 +#define NUMBER_OF_INTER_UNI_DIR_CASES 2 // number of cases for bit estimation for inter uni-prediction direction : unipred List 0 - unipred List 1 #define NUMBER_OF_MVD_CASES 12 // number of cases for bit estimation for motion vector difference @@ -64,7 +64,7 @@ extern "C" { #define NUMBER_OF_LAST_SIG_XY_CASES 0 // number of cases for bit estimation for last significant XY flag -#define TOTAL_NUMBER_OF_LAST_SIG_XY_CASES 0 // total number of cases for bit estimation for luma and chroma +#define TOTAL_NUMBER_OF_LAST_SIG_XY_CASES 0 // total number of cases for bit estimation for luma and chroma #define NUMBER_OF_GREATER_ONE_COEFF_CASES 0 // number of cases for bit estimation for coefficients greater than one @@ -84,7 +84,7 @@ extern "C" { #define NUMBER_OF_SAO_MERGE_FLAG_CASES 2 // number of cases for bit estimation for SAO merge flags -#define NUMBER_OF_SAO_TYPE_INDEX_FLAG_CASES 6 // number of cases for bit estimation for SAO Type +#define NUMBER_OF_SAO_TYPE_INDEX_FLAG_CASES 6 // number of cases for bit estimation for SAO Type #define NUMBER_OF_SAO_OFFSET_TRUNUNARY_CASES 8 // number of cases for bit estimation for SAO Offset trun unary case @@ -144,10 +144,10 @@ typedef struct MdRateEstimationContext_s { EB_BitFraction transSubDivFlagBits [NUMBER_OF_TRANSFORM_SUBDIV_FLAG_CASES]; EB_BitFraction mergeFlagBits [NUMBER_OF_MERGE_FLAG_CASES]; EB_BitFraction mergeIndexBits [NUMBER_OF_MERGE_INDEX_CASES]; - - EB_BitFraction saoMergeFlagBits [NUMBER_OF_SAO_MERGE_FLAG_CASES]; - EB_BitFraction saoTypeIndexBits [NUMBER_OF_SAO_TYPE_INDEX_FLAG_CASES]; - EB_BitFraction saoOffsetTrunUnaryBits [NUMBER_OF_SAO_OFFSET_TRUNUNARY_CASES]; + + EB_BitFraction saoMergeFlagBits [NUMBER_OF_SAO_MERGE_FLAG_CASES]; + EB_BitFraction saoTypeIndexBits [NUMBER_OF_SAO_TYPE_INDEX_FLAG_CASES]; + EB_BitFraction saoOffsetTrunUnaryBits [NUMBER_OF_SAO_OFFSET_TRUNUNARY_CASES]; EB_BitFraction interBiDirBits [NUMBER_OF_INTER_BI_DIR_CASES]; EB_BitFraction interUniDirBits [NUMBER_OF_INTER_UNI_DIR_CASES]; @@ -181,7 +181,7 @@ typedef struct MdRateEstimationContext_s { extern EB_ERRORTYPE MdRateEstimationContextCtor(MdRateEstimationContext_t *mdRateEstimationArray, ContextModelEncContext_t *cabacContextModelArray); -extern EB_ERRORTYPE GetMvdFractionBits( +extern EB_ERRORTYPE EbHevcGetMvdFractionBits( EB_S32 mvdX, EB_S32 mvdY, MdRateEstimationContext_t *mdRateEstimationArray, @@ -191,7 +191,7 @@ EB_ERRORTYPE GetRefIndexFractionBits( MdRateEstimationContext_t *mdRateEstimationArray, EB_U64 *fractionBitNum); -extern EB_ERRORTYPE MeGetMvdFractionBits( +extern EB_ERRORTYPE MeEbHevcGetMvdFractionBits( EB_S32 mvdX, EB_S32 mvdY, EB_BitFraction *mvdBitsPtr, diff --git a/Source/Lib/Codec/EbModeDecision.c b/Source/Lib/Codec/EbModeDecision.c index 86c2a5c3d..7086fe2fa 100644 --- a/Source/Lib/Codec/EbModeDecision.c +++ b/Source/Lib/Codec/EbModeDecision.c @@ -42,7 +42,7 @@ EB_BOOL AntiContouringIntraModeValidityPerDepth[35] = }; -const EB_U32 parentIndex[85] = { 0, 0, 0, 2, 2, 2, 2, 0, 7, 7, 7, 7, 0, 12, 12, 12, 12, 0, 17, 17, 17, 17, 0, 0, +const EB_U32 EbHevcparentIndex[85] = { 0, 0, 0, 2, 2, 2, 2, 0, 7, 7, 7, 7, 0, 12, 12, 12, 12, 0, 17, 17, 17, 17, 0, 0, 23, 23, 23, 23, 0, 28, 28, 28, 28, 0, 33, 33, 33, 33, 0, 38, 38, 38, 38, 0, 0, 44, 44, 44, 44, 0, 49, 49, 49, 49, 0, 54, 54, 54, 54, 0, 59, 59, 59, 59, 0, 0, 65, 65, 65, 65, 0, 70, 70, 70, 70, 0, 75, 75, 75, 75, 0, 80, 80, 80, 80 }; @@ -68,13 +68,13 @@ EB_U8 GetNumOfIntraModesFromOisPoint( ); extern EB_U32 stage1ModesArray[]; -void intraSearchTheseModesOutputBest( +void intraSearchTheseModesOutputBest( ModeDecisionContext_t *contextPtr, PictureControlSet_t *pictureControlSetPtr, EB_U8 *src, EB_U32 srcStride, - EB_U8 NumOfModesToTest, - EB_U32 *bestMode, + EB_U8 NumOfModesToTest, + EB_U32 *bestMode, EB_U32 *bestSADOut ) { @@ -84,7 +84,7 @@ void intraSearchTheseModesOutputBest( EB_U32 bestSAD = 32 * 32 * 255; EB_U32 sadCurr; - + for (candidateIndex = 0; candidateIndex < NumOfModesToTest; candidateIndex++) { mode = stage1ModesArray[candidateIndex]; @@ -92,7 +92,7 @@ void intraSearchTheseModesOutputBest( // Intra Prediction IntraPredOnSrc( contextPtr, - PICTURE_BUFFER_DESC_LUMA_MASK, + PICTURE_BUFFER_DESC_LUMA_MASK, pictureControlSetPtr, contextPtr->predictionBuffer, mode); @@ -340,7 +340,7 @@ EB_ERRORTYPE PreModeDecision( fullReconCandidateCount = MAX(1, (*fullCandidateTotalCountPtr) - 1); } - //With N buffers, we get here with the best N-1, plus the last candidate. We need to exclude the worst, and keep the best N-1. + //With N buffers, we get here with the best N-1, plus the last candidate. We need to exclude the worst, and keep the best N-1. highestCost = *(bufferPtrArray[0]->fastCostPtr); highestCostIndex = 0; @@ -545,7 +545,7 @@ void Me2Nx2NCandidatesInjection( cuOriginX, cuOriginY, 0, - sequenceControlSetPtr->lcuSize, + sequenceControlSetPtr->lcuSize, pictureControlSetPtr ); @@ -760,10 +760,10 @@ void Amvp2Nx2NCandidatesInjection( #define BIPRED_3x3_REFINMENT_POSITIONS 8 -EB_S8 BIPRED_3x3_X_POS[BIPRED_3x3_REFINMENT_POSITIONS] = {-1, -1, 0, 1, 1, 1, 0, -1}; -EB_S8 BIPRED_3x3_Y_POS[BIPRED_3x3_REFINMENT_POSITIONS] = { 0, 1, 1, 1, 0, -1, -1, -1}; +EB_S8 EbHevcBIPRED_3x3_X_POS[BIPRED_3x3_REFINMENT_POSITIONS] = {-1, -1, 0, 1, 1, 1, 0, -1}; +EB_S8 EbHevcBIPRED_3x3_Y_POS[BIPRED_3x3_REFINMENT_POSITIONS] = { 0, 1, 1, 1, 0, -1, -1, -1}; -void Unipred3x3CandidatesInjection( +void EbHevcUnipred3x3CandidatesInjection( PictureControlSet_t *pictureControlSetPtr, ModeDecisionContext_t *contextPtr, const SequenceControlSet_t *sequenceControlSetPtr, @@ -794,8 +794,8 @@ void Unipred3x3CandidatesInjection( candidateArray[canTotalCnt].motionVector_x_L0 = mePuResult->xMvL0; candidateArray[canTotalCnt].motionVector_y_L0 = mePuResult->yMvL0; - candidateArray[canTotalCnt].motionVector_x_L1 = mePuResult->xMvL1 + BIPRED_3x3_X_POS[bipredIndex]; - candidateArray[canTotalCnt].motionVector_y_L1 = mePuResult->yMvL1 + BIPRED_3x3_Y_POS[bipredIndex]; + candidateArray[canTotalCnt].motionVector_x_L1 = mePuResult->xMvL1 + EbHevcBIPRED_3x3_X_POS[bipredIndex]; + candidateArray[canTotalCnt].motionVector_y_L1 = mePuResult->yMvL1 + EbHevcBIPRED_3x3_Y_POS[bipredIndex]; if (pictureControlSetPtr->ParentPcsPtr->useSubpelFlag == 0) { RoundMv(candidateArray, @@ -864,8 +864,8 @@ void Unipred3x3CandidatesInjection( { const EB_U32 interDirection = UNI_PRED_LIST_0; - candidateArray[canTotalCnt].motionVector_x_L0 = mePuResult->xMvL0 + BIPRED_3x3_X_POS[bipredIndex]; - candidateArray[canTotalCnt].motionVector_y_L0 = mePuResult->yMvL0 + BIPRED_3x3_Y_POS[bipredIndex]; + candidateArray[canTotalCnt].motionVector_x_L0 = mePuResult->xMvL0 + EbHevcBIPRED_3x3_X_POS[bipredIndex]; + candidateArray[canTotalCnt].motionVector_y_L0 = mePuResult->yMvL0 + EbHevcBIPRED_3x3_Y_POS[bipredIndex]; candidateArray[canTotalCnt].motionVector_x_L1 = mePuResult->xMvL1; candidateArray[canTotalCnt].motionVector_y_L1 = mePuResult->yMvL1; @@ -938,7 +938,7 @@ void Unipred3x3CandidatesInjection( return; } -void Bipred3x3CandidatesInjection( +void EbHevcBipred3x3CandidatesInjection( PictureControlSet_t *pictureControlSetPtr, ModeDecisionContext_t *contextPtr, const SequenceControlSet_t *sequenceControlSetPtr, @@ -970,8 +970,8 @@ void Bipred3x3CandidatesInjection( candidateArray[canTotalCnt].motionVector_x_L0 = mePuResult->xMvL0; candidateArray[canTotalCnt].motionVector_y_L0 = mePuResult->yMvL0; - candidateArray[canTotalCnt].motionVector_x_L1 = mePuResult->xMvL1 + BIPRED_3x3_X_POS[bipredIndex]; - candidateArray[canTotalCnt].motionVector_y_L1 = mePuResult->yMvL1 + BIPRED_3x3_Y_POS[bipredIndex]; + candidateArray[canTotalCnt].motionVector_x_L1 = mePuResult->xMvL1 + EbHevcBIPRED_3x3_X_POS[bipredIndex]; + candidateArray[canTotalCnt].motionVector_y_L1 = mePuResult->yMvL1 + EbHevcBIPRED_3x3_Y_POS[bipredIndex]; if (pictureControlSetPtr->ParentPcsPtr->useSubpelFlag == 0) { @@ -1034,15 +1034,15 @@ void Bipred3x3CandidatesInjection( canTotalCnt++; - } + } // (8 Best_L0 neighbors, Best_L1) : for (bipredIndex = 0; bipredIndex < BIPRED_3x3_REFINMENT_POSITIONS; ++bipredIndex) { const EB_U32 interDirection = BI_PRED; - candidateArray[canTotalCnt].motionVector_x_L0 = mePuResult->xMvL0 + BIPRED_3x3_X_POS[bipredIndex]; - candidateArray[canTotalCnt].motionVector_y_L0 = mePuResult->yMvL0 + BIPRED_3x3_Y_POS[bipredIndex]; + candidateArray[canTotalCnt].motionVector_x_L0 = mePuResult->xMvL0 + EbHevcBIPRED_3x3_X_POS[bipredIndex]; + candidateArray[canTotalCnt].motionVector_y_L0 = mePuResult->yMvL0 + EbHevcBIPRED_3x3_Y_POS[bipredIndex]; candidateArray[canTotalCnt].motionVector_x_L1 = mePuResult->xMvL1; candidateArray[canTotalCnt].motionVector_y_L1 = mePuResult->yMvL1; @@ -1156,7 +1156,7 @@ void ProductIntraCandidateInjection( const EB_BOOL limitIntra = contextPtr->limitIntra; const EB_U8 limitLeftMode = cuSize < 32 ? EB_INTRA_MODE_27 : EB_INTRA_VERTICAL; const EB_U8 limitTopMode = cuSize < 32 ? EB_INTRA_MODE_9 : EB_INTRA_HORIZONTAL; - + EB_BOOL skipOis8x8 = (pictureControlSetPtr->ParentPcsPtr->skipOis8x8 && cuSize == 8); if (pictureControlSetPtr->ParentPcsPtr->complexLcuArray[lcuPtr->index] == LCU_COMPLEXITY_STATUS_2) { @@ -1222,12 +1222,12 @@ void ProductIntraCandidateInjection( } } else { - // No Intra 64x64 + // No Intra 64x64 if (cuDepth != 0) { //---------------------- // I Slice - //---------------------- + //---------------------- if (sliceType == EB_I_PICTURE) { if (cuSize == 32) { @@ -1326,11 +1326,11 @@ void ProductIntraCandidateInjection( //---------------------- // P/B Slice - //---------------------- + //---------------------- else { if ((cuSize >= 16 && pictureControlSetPtr->ParentPcsPtr->cu16x16Mode == CU_16x16_MODE_0 && pictureControlSetPtr->encMode < ENC_MODE_11) - || (cuSize == 32)) + || (cuSize == 32)) { { if (pictureControlSetPtr->ParentPcsPtr->limitOisToDcModeFlag) @@ -1464,7 +1464,7 @@ void ProductIntraCandidateInjection( if (lcuParams->isCompleteLcu) { - const CodedUnitStats_t *cuStats = GetCodedUnitStats(parentIndex[leafIndex]); + const CodedUnitStats_t *cuStats = GetCodedUnitStats(EbHevcparentIndex[leafIndex]); const EB_U32 me2Nx2NTableOffset = cuStats->cuNumInDepth + me2Nx2NOffset[cuStats->depth]; OisCu32Cu16Results_t *oisCu32Cu16ResultsPtr = pictureControlSetPtr->ParentPcsPtr->oisCu32Cu16Results[lcuAddr]; const OisCandidate_t *oisCandidate = oisCu32Cu16ResultsPtr->sortedOisCandidate[me2Nx2NTableOffset]; @@ -1727,7 +1727,7 @@ void ProductMpmCandidatesInjection( { const EB_U32 cuDepth = contextPtr->cuStats->depth; EB_U32 canTotalCnt = (*candidateTotalCnt); - EB_U32 fastLoopCandidate = 0; + EB_U32 fastLoopCandidate = 0; EB_U32 candidateIndex; EB_U32 mostProbableModeCount; EB_BOOL mpmPresentFlag; @@ -1842,7 +1842,7 @@ EB_ERRORTYPE ProductGenerateAmvpMergeInterIntraMdCandidatesCU( //---------------------- // Intra - //---------------------- + //---------------------- if (cuDepth != 0 && (sliceType == EB_I_PICTURE || cuDepth == 3 || contextPtr->restrictIntraGlobalMotion == EB_FALSE)) { const EB_BOOL isLeftCu = contextPtr->cuStats->originX == 0; const EB_BOOL isTopCu = contextPtr->cuStats->originY == 0; @@ -1891,7 +1891,7 @@ EB_ERRORTYPE ProductGenerateAmvpMergeInterIntraMdCandidatesCU( //---------------------- // Me2Nx2N - //---------------------- + //---------------------- Me2Nx2NCandidatesInjection( // HT not much to do pictureControlSetPtr, contextPtr, @@ -1907,7 +1907,7 @@ EB_ERRORTYPE ProductGenerateAmvpMergeInterIntraMdCandidatesCU( //---------------------- // Amvp2Nx2N - //---------------------- + //---------------------- Amvp2Nx2NCandidatesInjection( pictureControlSetPtr, contextPtr, @@ -1917,14 +1917,14 @@ EB_ERRORTYPE ProductGenerateAmvpMergeInterIntraMdCandidatesCU( firstPuAMVPCandArray_y, firstPuNumAvailableAMVPCand); } - + if (pictureControlSetPtr->sliceType == EB_B_PICTURE) { if (contextPtr->bipred3x3Injection) { //---------------------- // Bipred2Nx2N - //---------------------- + //---------------------- - Bipred3x3CandidatesInjection( // HT not much to do + EbHevcBipred3x3CandidatesInjection( // HT not much to do pictureControlSetPtr, contextPtr, sequenceControlSetPtr, @@ -1939,8 +1939,8 @@ EB_ERRORTYPE ProductGenerateAmvpMergeInterIntraMdCandidatesCU( if (contextPtr->unipred3x3Injection) { //---------------------- // Unipred2Nx2N - //---------------------- - Unipred3x3CandidatesInjection( // HT not much to do + //---------------------- + EbHevcUnipred3x3CandidatesInjection( // HT not much to do pictureControlSetPtr, contextPtr, sequenceControlSetPtr, @@ -1971,7 +1971,7 @@ EB_ERRORTYPE ProductGenerateAmvpMergeInterIntraMdCandidatesCU( // Set BufferTotalCount: determines the number of candidates to fully reconstruct *bufferTotalCountPtr = fullReconSearchCount; - // Mark MPM candidates, and update the number of full recon - MPM candidates are going to get pushed to the full, + // Mark MPM candidates, and update the number of full recon - MPM candidates are going to get pushed to the full, // however they still need to be tested in the fast loop where the predicted, and the fast rate are going to get computed #ifdef LIMITINRA_MPM_PATCH const EB_BOOL isLeftCu = contextPtr->cuStats->originX == 0; @@ -2031,8 +2031,8 @@ EB_U8 ProductFullModeDecision( for (i = 0; i < candidateTotalCount; ++i) { candidateIndex = bestCandidateIndexArray[i]; - - // Compute fullCostBis + + // Compute fullCostBis if (( *(bufferPtrArray[candidateIndex]->fullCostPtr) < lowestIntraCost) && bufferPtrArray[candidateIndex]->candidatePtr->type == INTRA_MODE){ *bestIntraMode = bufferPtrArray[candidateIndex]->candidatePtr->intraLumaMode; @@ -2150,7 +2150,7 @@ EB_U8 ProductFullModeDecision( // Set TU variables tuPtr->cbCbf2 = EB_FALSE; tuPtr->crCbf2 = EB_FALSE; - tuPtr->chromaCbfContext = 0; //at TU level + tuPtr->chromaCbfContext = 0; //at TU level } else { tuTotalCount = 1; @@ -2175,10 +2175,10 @@ EB_U8 ProductFullModeDecision( tuPtr->crCbf = (EB_BOOL)(((candidatePtr->crCbf) & (1 << (tuIndex))) > 0); tuPtr->cbCbf2 = EB_FALSE; tuPtr->crCbf2 = EB_FALSE; - - //CHKN tuPtr->chromaCbfContext = (tuIndex == 0 || (cuPtr->partitionMode == SIZE_NxN)) ? 0 : (cuSizeLog2 - Log2f(tuSize)); //at TU level - tuPtr->chromaCbfContext = (tuIndex == 0 || (0)) ? 0 : (cuSizeLog2 - Log2f(tuSize)); //at TU level - + + //CHKN tuPtr->chromaCbfContext = (tuIndex == 0 || (cuPtr->partitionMode == SIZE_NxN)) ? 0 : (cuSizeLog2 - Log2f(tuSize)); //at TU level + tuPtr->chromaCbfContext = (tuIndex == 0 || (0)) ? 0 : (cuSizeLog2 - Log2f(tuSize)); //at TU level + tuPtr->lumaCbfContext = (cuSizeLog2 - Log2f(tuSize)) == 0 ? 1 : 0; if (tuPtr->cbCbf){ @@ -2197,9 +2197,3 @@ EB_U8 ProductFullModeDecision( return lowestCostIndex; } - - - - - - diff --git a/Source/Lib/Codec/EbModeDecisionConfiguration.c b/Source/Lib/Codec/EbModeDecisionConfiguration.c index a9b5c5f71..556ab37d0 100644 --- a/Source/Lib/Codec/EbModeDecisionConfiguration.c +++ b/Source/Lib/Codec/EbModeDecisionConfiguration.c @@ -42,7 +42,7 @@ static const EB_U8 parentCuIndex[85] = 36, 0, 0, 1, 2, 3, 5, 0, 1, 2, 3, 10, 0, 1, 2, 3, 15, 0, 1, 2, 3, }; -const EB_U8 incrementalCount[85] = { +const EB_U8 EbHevcincrementalCount[85] = { //64x64 0, @@ -79,7 +79,7 @@ mdcSetDepth : set depth to be tested -EB_ERRORTYPE MdcRefinement( +EB_ERRORTYPE EbHevcMdcRefinement( MdcpLocalCodingUnit_t *localCuArray, EB_U32 cuIndex, EB_U32 depth, @@ -100,7 +100,7 @@ EB_ERRORTYPE MdcRefinement( } if (refinementLevel & REFINEMENT_Pp1){ - + if (depth < 3 && cuIndex < 81){ localCuArray[cuIndex + 1].slectedCu = EB_TRUE; localCuArray[cuIndex + 1 + DepthOffset[depth + 1]].slectedCu = EB_TRUE; @@ -265,7 +265,7 @@ EB_ERRORTYPE MdcIntraCuRate( EB_U64 chromaRate; EncodeContext_t *encodeContextPtr = ((SequenceControlSet_t*)(pictureControlSetPtr->sequenceControlSetWrapperPtr->objectPtr))->encodeContextPtr; - + CHECK_REPORT_ERROR( (partitionMode == SIZE_2Nx2N), encodeContextPtr->appCallbackPtr, @@ -325,7 +325,7 @@ EB_U64 MdcInterCuRate( // Estimate the Motion Vector Prediction Index Bits rate += 23196; - // Estimate the Motion Vector Difference Bits + // Estimate the Motion Vector Difference Bits MVs_0 = ABS(xMvL0); MVs_1 = ABS(yMvL0); MVs_0 = MVs_0 > 499 ? 499 : MVs_0; @@ -338,7 +338,7 @@ EB_U64 MdcInterCuRate( // Estimate the Motion Vector Prediction Index Bits rate += 23196; - // Estimate the Motion Vector Difference Bits + // Estimate the Motion Vector Difference Bits MVs_2 = ABS(xMvL1); MVs_3 = ABS(yMvL1); @@ -360,7 +360,7 @@ EB_U64 MdcInterCuRate( rate += 46392; - // Estimate the Motion Vector Difference Bits + // Estimate the Motion Vector Difference Bits MVs_0 = ABS(xMvL0); MVs_1 = ABS(yMvL0); @@ -370,7 +370,7 @@ EB_U64 MdcInterCuRate( rate += mvBitTable[MVs_0][MVs_1]; - // Estimate the Motion Vector Difference Bits + // Estimate the Motion Vector Difference Bits MVs_2 = ABS(xMvL1); MVs_3 = ABS(yMvL1); MVs_2 = MVs_2 > 499 ? 499 : MVs_2; @@ -433,7 +433,7 @@ EB_U8 DeriveContouringClass( } -void RefinementPredictionLoop( +void EbHevcRefinementPredictionLoop( SequenceControlSet_t *sequenceControlSetPtr, PictureControlSet_t *pictureControlSetPtr, LargestCodingUnit_t *lcuPtr, @@ -463,7 +463,7 @@ void RefinementPredictionLoop( EB_U8 lowestLevel = 0x00; if (sequenceControlSetPtr->inputResolution == INPUT_SIZE_4K_RANGE) - refinementLevel = NdpRefinementControl_ISLICE[depth]; + refinementLevel = NdpRefinementControl_ISLICE[depth]; else refinementLevel = NdpRefinementControl_ISLICE_Sub4K[depth]; @@ -478,7 +478,7 @@ void RefinementPredictionLoop( (refinementLevel & REFINEMENT_P) ? REFINEMENT_P : (refinementLevel & REFINEMENT_Pm1) ? REFINEMENT_Pm1 : (refinementLevel & REFINEMENT_Pm2) ? REFINEMENT_Pm2 : (refinementLevel & REFINEMENT_Pm3) ? REFINEMENT_Pm3 : 0x00; - MdcRefinement( + EbHevcMdcRefinement( &(*contextPtr->localCuArray), cuIndex, depth, @@ -490,8 +490,8 @@ void RefinementPredictionLoop( if (pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_LCU_SWITCH_DEPTH_MODE && (pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_PRED_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_PRED_OPEN_LOOP_1_NFL_DEPTH_MODE)) { refinementLevel = Pred; } - else - + else + if (pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_OPEN_LOOP_DEPTH_MODE || (pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_LCU_SWITCH_DEPTH_MODE && pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_OPEN_LOOP_DEPTH_MODE)) @@ -511,7 +511,7 @@ void RefinementPredictionLoop( (refinementLevel & REFINEMENT_P) ? REFINEMENT_P : (refinementLevel & REFINEMENT_Pm1) ? REFINEMENT_Pm1 : (refinementLevel & REFINEMENT_Pm2) ? REFINEMENT_Pm2 : (refinementLevel & REFINEMENT_Pm3) ? REFINEMENT_Pm3 : 0x00; - MdcRefinement( + EbHevcMdcRefinement( &(*contextPtr->localCuArray), cuIndex, depth, @@ -568,7 +568,7 @@ void PrePredictionRefinement( } - // S-LOGO + // S-LOGO if (stationaryEdgeOverTimeFlag > 0){ @@ -583,7 +583,7 @@ void PrePredictionRefinement( } -void ForwardCuToModeDecision( +void EbHevcForwardCuToModeDecision( SequenceControlSet_t *sequenceControlSetPtr, PictureControlSet_t *pictureControlSetPtr, @@ -650,7 +650,7 @@ void ForwardCuToModeDecision( } - // Take into account MAX CU size & MAX intra size (from the API) + // Take into account MAX CU size & MAX intra size (from the API) cuClass = (cuStatsPtr->size > MAX_CU_SIZE || (sliceType == EB_I_PICTURE && cuStatsPtr->size > MAX_INTRA_SIZE)) ? DO_NOT_ADD_CU_CONTINUE_SPLIT : cuClass; @@ -712,7 +712,7 @@ void ForwardCuToModeDecision( -void MdcInterDepthDecision( +void EbHevcMdcInterDepthDecision( ModeDecisionConfigurationContext_t *contextPtr, EB_U32 originX, EB_U32 originY, @@ -845,7 +845,7 @@ void MdcInterDepthDecision( } } - // Stage 2: Inter depth decision: depth 0 vs depth 1 + // Stage 2: Inter depth decision: depth 0 vs depth 1 // Walks to the last coded 32x32 block for merging // Stage 2 isn't performed in I slices since the abcense of 64x64 candidates @@ -900,7 +900,7 @@ void MdcInterDepthDecision( contextPtr->groupOf16x16BlocksCount = groupOf16x16BlocksCount; } -void PredictionPartitionLoop( +void EbHevcPredictionPartitionLoop( SequenceControlSet_t *sequenceControlSetPtr, PictureControlSet_t *pictureControlSetPtr, EB_U32 lcuIndex, @@ -1001,7 +1001,7 @@ void PredictionPartitionLoop( } } } - + cuIntraCost = (cuIntraSad << COST_PRECISION) + ((contextPtr->lambda * cuIntraRate + MD_OFFSET) >> MD_SHIFT); cuPtr->earlyCost = cuIntraCost; @@ -1010,7 +1010,7 @@ void PredictionPartitionLoop( if (pictureControlSetPtr->sliceType != EB_I_PICTURE){ - + MeCuResults_t * mePuResult = &pictureControlSetPtr->ParentPcsPtr->meResults[lcuIndex][cuIndexInRaterScan]; cuInterRate = MdcInterCuRate( @@ -1030,13 +1030,13 @@ void PredictionPartitionLoop( cuPtr->earlyCost = pictureControlSetPtr->sliceType == EB_I_PICTURE ? cuIntraCost : cuInterCost; if (endDepth == 2){ - contextPtr->groupOf8x8BlocksCount = depth == 2 ? incrementalCount[cuIndexInRaterScan] : 0; + contextPtr->groupOf8x8BlocksCount = depth == 2 ? EbHevcincrementalCount[cuIndexInRaterScan] : 0; } if (endDepth == 1){ - contextPtr->groupOf16x16BlocksCount = depth == 1 ? incrementalCount[cuIndexInRaterScan] : 0; + contextPtr->groupOf16x16BlocksCount = depth == 1 ? EbHevcincrementalCount[cuIndexInRaterScan] : 0; } - MdcInterDepthDecision( + EbHevcMdcInterDepthDecision( contextPtr, cuStatsPtr->originX, cuStatsPtr->originY, @@ -1089,7 +1089,7 @@ EB_ERRORTYPE EarlyModeDecisionLcu( &endDepth); } - PredictionPartitionLoop( + EbHevcPredictionPartitionLoop( sequenceControlSetPtr, pictureControlSetPtr, lcuIndex, @@ -1100,14 +1100,14 @@ EB_ERRORTYPE EarlyModeDecisionLcu( contextPtr ); - RefinementPredictionLoop( + EbHevcRefinementPredictionLoop( sequenceControlSetPtr, pictureControlSetPtr, lcuPtr, lcuIndex, contextPtr); - ForwardCuToModeDecision( + EbHevcForwardCuToModeDecision( sequenceControlSetPtr, pictureControlSetPtr, @@ -1117,6 +1117,3 @@ EB_ERRORTYPE EarlyModeDecisionLcu( return return_error; } - - - diff --git a/Source/Lib/Codec/EbModeDecisionConfigurationProcess.c b/Source/Lib/Codec/EbModeDecisionConfigurationProcess.c index 14653bfd8..bc2c00d49 100644 --- a/Source/Lib/Codec/EbModeDecisionConfigurationProcess.c +++ b/Source/Lib/Codec/EbModeDecisionConfigurationProcess.c @@ -23,35 +23,35 @@ #define UNDER_SHOOTING 0 #define OVER_SHOOTING 1 #define TBD_SHOOTING 2 - + // Set a cost to each search method (could be modified) // EB30 @ Revision 12879 -#define PRED_OPEN_LOOP_1_NFL_COST 97 // PRED_OPEN_LOOP_1_NFL_COST is ~03% faster than PRED_OPEN_LOOP_COST +#define PRED_OPEN_LOOP_1_NFL_COST 97 // PRED_OPEN_LOOP_1_NFL_COST is ~03% faster than PRED_OPEN_LOOP_COST #define U_099 99 -#define PRED_OPEN_LOOP_COST 100 // Let's assume PRED_OPEN_LOOP_COST costs ~100 U +#define PRED_OPEN_LOOP_COST 100 // Let's assume PRED_OPEN_LOOP_COST costs ~100 U #define U_101 101 #define U_102 102 #define U_103 103 -#define U_104 104 +#define U_104 104 #define U_105 105 -#define LIGHT_OPEN_LOOP_COST 106 // L_MDC is ~06% slower than PRED_OPEN_LOOP_COST -#define U_107 107 -#define U_108 108 +#define LIGHT_OPEN_LOOP_COST 106 // L_MDC is ~06% slower than PRED_OPEN_LOOP_COST +#define U_107 107 +#define U_108 108 #define U_109 109 #define OPEN_LOOP_COST 110 // F_MDC is ~10% slower than PRED_OPEN_LOOP_COST #define U_111 111 #define U_112 112 #define U_113 113 #define U_114 114 -#define U_115 115 +#define U_115 115 #define U_116 116 #define U_117 117 #define U_119 119 #define U_120 120 #define U_121 121 #define U_122 122 -#define LIGHT_AVC_COST 122 +#define LIGHT_AVC_COST 122 #define LIGHT_BDP_COST 123 // L_BDP is ~23% slower than PRED_OPEN_LOOP_COST #define U_125 125 #define U_127 127 @@ -107,7 +107,7 @@ static const EB_U8 AdpLuminosityChangeThArray[MAX_HIERARCHICAL_LEVEL][MAX_TEMPOR /****************************************************** -* Compute picture and slice level chroma QP offsets +* Compute picture and slice level chroma QP offsets ******************************************************/ static void SetSliceAndPictureChromaQpOffsets( PictureControlSet_t *pictureControlSetPtr, @@ -211,7 +211,7 @@ static void AdaptiveDlfParameterComputation( } if (pictureControlSetPtr->sliceType == EB_B_PICTURE){ - + refObjL0 = (EbReferenceObject_t*)pictureControlSetPtr->refPicPtrArray[REF_LIST_0]->objectPtr; refObjL1 = (EbReferenceObject_t*)pictureControlSetPtr->refPicPtrArray[REF_LIST_1]->objectPtr; @@ -220,7 +220,7 @@ static void AdaptiveDlfParameterComputation( } else{ highIntra = (refObjL0->penalizeSkipflag || refObjL1->penalizeSkipflag) ? 1 : 0; } - + } if (tcBetaOffsetManipulation){ @@ -266,7 +266,7 @@ EB_ERRORTYPE ModeDecisionConfigurationContextCtor( EB_MALLOC(ModeDecisionConfigurationContext_t*, contextPtr, sizeof(ModeDecisionConfigurationContext_t), EB_N_PTR); *contextDblPtr = contextPtr; - + // Input/Output System Resource Manager FIFOs contextPtr->rateControlInputFifoPtr = rateControlInputFifoPtr; contextPtr->modeDecisionConfigurationOutputFifoPtr = modeDecisionConfigurationOutputFifoPtr; @@ -274,7 +274,7 @@ EB_ERRORTYPE ModeDecisionConfigurationContextCtor( EB_MALLOC(MdRateEstimationContext_t*, contextPtr->mdRateEstimationPtr, sizeof(MdRateEstimationContext_t), EB_N_PTR); - // Budgeting + // Budgeting EB_MALLOC(EB_U32*,contextPtr->lcuScoreArray,sizeof(EB_U32) * lcuTotalCount, EB_N_PTR); EB_MALLOC(EB_U8 *,contextPtr->lcuCostArray ,sizeof(EB_U8 ) * lcuTotalCount, EB_N_PTR); @@ -329,7 +329,7 @@ static void PerformEarlyLcuPartitionning( lcuPtr = pictureControlSetPtr->lcuPtrArray[lcuIndex]; { - lcuPtr->qp = (EB_U8)pictureControlSetPtr->ParentPcsPtr->pictureQp; + lcuPtr->qp = (EB_U8)pictureControlSetPtr->ParentPcsPtr->pictureQp; } EarlyModeDecisionLcu( @@ -388,7 +388,7 @@ static void Forward85CuToModeDecisionLCU( { switch (cuStatsPtr->depth){ - case 0: + case 0: resultsPtr->leafDataArray[resultsPtr->leafCount].leafIndex = cuIndex; resultsPtr->leafDataArray[resultsPtr->leafCount++].splitFlag = splitFlag = EB_TRUE; break; @@ -442,7 +442,7 @@ static void Forward84CuToModeDecisionLCU( { switch (cuStatsPtr->depth){ - case 0: + case 0: splitFlag = EB_TRUE; break; @@ -702,7 +702,7 @@ static void Forward16x16CuToModeDecisionLCU( } // End CU Loop } -static void PartitioningInitialization( +static void PartitioningInitialization( SequenceControlSet_t *sequenceControlSetPtr, PictureControlSet_t *pictureControlSetPtr, ModeDecisionConfigurationContext_t *contextPtr) { @@ -768,14 +768,14 @@ static void DetectComplexNonFlatMovingLcu( if (condition){ EB_U32 counter = 0; - if (!lcuParams->isEdgeLcu){ - // Top + if (!lcuParams->isEdgeLcu){ + // Top if (pictureControlSetPtr->ParentPcsPtr->edgeResultsPtr[lcuIndex - pictureWidthInLcu].edgeBlockNum == 0) counter++; // Bottom if (pictureControlSetPtr->ParentPcsPtr->edgeResultsPtr[lcuIndex + pictureWidthInLcu].edgeBlockNum == 0) counter++; - // Left + // Left if (pictureControlSetPtr->ParentPcsPtr->edgeResultsPtr[lcuIndex - 1].edgeBlockNum == 0) counter++; // right @@ -783,7 +783,7 @@ static void DetectComplexNonFlatMovingLcu( counter++; } } - } + } } } @@ -813,7 +813,7 @@ static EB_AURA_STATUS AuraDetection64x64( LcuParams_t *lcuParams = &sequenceControlSetPtr->lcuParamsArray[lcuIndex]; - distThresh0 = pictureControlSetPtr->ParentPcsPtr->isUsedAsReferenceFlag ||sequenceControlSetPtr->inputResolution == INPUT_SIZE_4K_RANGE ? 15 : 14; + distThresh0 = pictureControlSetPtr->ParentPcsPtr->isUsedAsReferenceFlag ||sequenceControlSetPtr->inputResolution == INPUT_SIZE_4K_RANGE ? 15 : 14; distThresh1 = 23; @@ -822,13 +822,13 @@ static EB_AURA_STATUS AuraDetection64x64( distThresh1 = distThresh1 << 2; } - if (!lcuParams->isEdgeLcu){ - - EB_U32 k; + if (!lcuParams->isEdgeLcu){ + + EB_U32 k; MeCuResults_t * mePuResult = &pictureControlSetPtr->ParentPcsPtr->meResults[lcuIndex][0]; - //Curr Block + //Curr Block for (k = 0; k < mePuResult->totalMeCandidateIndex; k++) { @@ -856,30 +856,30 @@ static EB_AURA_STATUS AuraDetection64x64( abs(yMv1) > GLOBAL_MOTION_THRESHOLD[pictureControlSetPtr->ParentPcsPtr->hierarchicalLevels][pictureControlSetPtr->ParentPcsPtr->temporalLayerIndex])) { - //Top Distortion + //Top Distortion lcuOffset = -pictureWidthInLcu; topDist = pictureControlSetPtr->ParentPcsPtr->meResults[lcuIndex + lcuOffset]->distortionDirection[0].distortion; - //TopLeft Distortion + //TopLeft Distortion lcuOffset = -pictureWidthInLcu - 1; topLDist = pictureControlSetPtr->ParentPcsPtr->meResults[lcuIndex + lcuOffset]->distortionDirection[0].distortion; - //TopRightDistortion + //TopRightDistortion lcuOffset = -pictureWidthInLcu + 1; topRDist = pictureControlSetPtr->ParentPcsPtr->meResults[lcuIndex + lcuOffset]->distortionDirection[0].distortion; topRDist = (lcuParams->horizontalIndex < (EB_U32)(pictureWidthInLcu - 2)) ? topRDist : currDist; - //left Distortion + //left Distortion lcuOffset = -1; leftDist = pictureControlSetPtr->ParentPcsPtr->meResults[lcuIndex + lcuOffset]->distortionDirection[0].distortion; - //RightDistortion + //RightDistortion lcuOffset = 1; rightDist = pictureControlSetPtr->ParentPcsPtr->meResults[lcuIndex + lcuOffset]->distortionDirection[0].distortion; @@ -926,7 +926,7 @@ static void AuraDetection( lcu_X = lcuParams->horizontalIndex; lcu_Y = lcuParams->verticalIndex; - if (pictureControlSetPtr->sliceType == EB_B_PICTURE){ + if (pictureControlSetPtr->sliceType == EB_B_PICTURE){ if ((lcu_X > 0) && (lcu_X < pictureWidthInLcu - 1) && (lcu_Y < pictureHeightInLcu - 1)){ lcuPtr->auraStatus = AuraDetection64x64( pictureControlSetPtr, @@ -962,17 +962,17 @@ static EB_ERRORTYPE DeriveDefaultSegments( contextPtr->intervalCost[1] = contextPtr->costDepthMode[LCU_BDP_DEPTH_MODE - 1]; } - } - else { + } + else { if (contextPtr->budget > (EB_U32) (pictureControlSetPtr->ParentPcsPtr->lcuTotalCount * BDP_COST)) { - + contextPtr->numberOfSegments = 2; - + contextPtr->scoreTh[0] = (EB_S8)((1 * 100) / contextPtr->numberOfSegments); contextPtr->intervalCost[0] = contextPtr->costDepthMode[LCU_BDP_DEPTH_MODE - 1]; contextPtr->intervalCost[1] = contextPtr->costDepthMode[LCU_FULL84_DEPTH_MODE - 1]; - } + } else if (contextPtr->budget > (EB_U32)(pictureControlSetPtr->ParentPcsPtr->lcuTotalCount * OPEN_LOOP_COST)) { @@ -1001,7 +1001,7 @@ static EB_ERRORTYPE DeriveDefaultSegments( contextPtr->intervalCost[3] = contextPtr->costDepthMode[LCU_LIGHT_BDP_DEPTH_MODE - 1]; contextPtr->intervalCost[4] = contextPtr->costDepthMode[LCU_BDP_DEPTH_MODE - 1]; } - + } } else { @@ -1022,7 +1022,7 @@ static EB_ERRORTYPE DeriveDefaultSegments( contextPtr->intervalCost[3] = contextPtr->costDepthMode[LCU_LIGHT_BDP_DEPTH_MODE - 1]; contextPtr->intervalCost[4] = contextPtr->costDepthMode[LCU_BDP_DEPTH_MODE - 1]; contextPtr->intervalCost[5] = contextPtr->costDepthMode[LCU_FULL85_DEPTH_MODE - 1]; - } + } else if (contextPtr->budget > (EB_U32)(pictureControlSetPtr->ParentPcsPtr->lcuTotalCount * U_115)) { contextPtr->numberOfSegments = 5; @@ -1065,7 +1065,7 @@ static EB_ERRORTYPE DeriveDefaultSegments( contextPtr->intervalCost[3] = contextPtr->costDepthMode[LCU_OPEN_LOOP_DEPTH_MODE - 1]; } } - + return return_error; } @@ -1081,7 +1081,7 @@ static void SetTargetBudgetOq( ModeDecisionConfigurationContext_t *contextPtr) { EB_U32 budget; - + if (contextPtr->adpLevel <= ENC_MODE_3) { if (sequenceControlSetPtr->inputResolution <= INPUT_SIZE_1080i_RANGE) { if (pictureControlSetPtr->temporalLayerIndex == 0) @@ -1221,8 +1221,8 @@ static void SetTargetBudgetOq( /****************************************************** * IsAvcPartitioningMode() - * Returns TRUE for LCUs where only Depth2 & Depth3 - * (AVC Partitioning) are goind to be tested by MD + * Returns TRUE for LCUs where only Depth2 & Depth3 + * (AVC Partitioning) are goind to be tested by MD * The LCU is marked if Sharpe Edge or Potential Aura/Grass * or B-Logo or S-Logo or Potential Blockiness Area * Input: Sharpe Edge, Potential Aura/Grass, B-Logo, S-Logo, Potential Blockiness Area signals @@ -1264,7 +1264,7 @@ static EB_BOOL IsAvcPartitioningMode( if (pictureControlSetPtr->ParentPcsPtr->logoPicFlag && edgeBlockNum) return EB_TRUE; - // S-Logo + // S-Logo if (stationaryEdgeOverTimeFlag > 0) return EB_TRUE; @@ -1282,7 +1282,7 @@ static EB_BOOL IsAvcPartitioningMode( ******************************************************/ static void ConfigureAdp( PictureControlSet_t *pictureControlSetPtr, - ModeDecisionConfigurationContext_t *contextPtr) + ModeDecisionConfigurationContext_t *contextPtr) { contextPtr->costDepthMode[LCU_FULL85_DEPTH_MODE - 1] = FULL_SEARCH_COST; contextPtr->costDepthMode[LCU_FULL84_DEPTH_MODE - 1] = FULL_SEARCH_COST; @@ -1310,7 +1310,7 @@ static void ConfigureAdp( // Initialize the predicted budget contextPtr->predictedCost = (EB_U32)~0; - // Derive the sensitive picture flag + // Derive the sensitive picture flag contextPtr->adpDepthSensitivePictureClass = DEPTH_SENSITIVE_PIC_CLASS_0; EB_BOOL luminosityChange = EB_FALSE; @@ -1325,11 +1325,11 @@ static void ConfigureAdp( } } - if (pictureControlSetPtr->ParentPcsPtr->nonMovingIndexAverage != INVALID_ZZ_COST && pictureControlSetPtr->ParentPcsPtr->nonMovingIndexAverage < ADP_CONFIG_NON_MOVING_INDEX_TH_1) { // could not seen by the eye if very active + if (pictureControlSetPtr->ParentPcsPtr->nonMovingIndexAverage != INVALID_ZZ_COST && pictureControlSetPtr->ParentPcsPtr->nonMovingIndexAverage < ADP_CONFIG_NON_MOVING_INDEX_TH_1) { // could not seen by the eye if very active if (pictureControlSetPtr->ParentPcsPtr->picNoiseClass > PIC_NOISE_CLASS_3 || pictureControlSetPtr->ParentPcsPtr->highDarkLowLightAreaDensityFlag ||luminosityChange) { // potential complex picture: luminosity Change (e.g. fade, light..) contextPtr->adpDepthSensitivePictureClass = DEPTH_SENSITIVE_PIC_CLASS_2; - } - // potential complex picture: light foreground and dark background(e.g.flash, light..) or moderate activity and high variance (noise or a lot of edge) + } + // potential complex picture: light foreground and dark background(e.g.flash, light..) or moderate activity and high variance (noise or a lot of edge) else if ( (pictureControlSetPtr->ParentPcsPtr->nonMovingIndexAverage >= ADP_CONFIG_NON_MOVING_INDEX_TH_0 && pictureControlSetPtr->ParentPcsPtr->picNoiseClass == PIC_NOISE_CLASS_3)) { contextPtr->adpDepthSensitivePictureClass = DEPTH_SENSITIVE_PIC_CLASS_1; } @@ -1339,7 +1339,7 @@ static void ConfigureAdp( } /****************************************************** -* Assign a search method based on the allocated cost +* Assign a search method based on the allocated cost Input : allocated budget per LCU Output : search method per LCU ******************************************************/ @@ -1347,7 +1347,7 @@ static void DeriveSearchMethod( PictureControlSet_t *pictureControlSetPtr, ModeDecisionConfigurationContext_t *contextPtr) { - + EB_U32 lcuIndex; @@ -1481,16 +1481,16 @@ static void DeriveOptimalBudgetPerLcu( { EB_U32 lcuIndex; - // Initialize the deviation between the picture predicted cost & the target budget to 100, - EB_U32 deviationToTarget = 1000; - - // Set the adjustment step to 1 (could be increased for faster convergence), + // Initialize the deviation between the picture predicted cost & the target budget to 100, + EB_U32 deviationToTarget = 1000; + + // Set the adjustment step to 1 (could be increased for faster convergence), EB_S8 adjustementStep = 1; - + // Set the initial shooting state & the final shooting state to TBD EB_U32 initialShooting = TBD_SHOOTING; EB_U32 finalShooting = TBD_SHOOTING; - + EB_U8 maxAdjustementIteration = 100; EB_U8 adjustementIteration = 0; @@ -1517,7 +1517,7 @@ static void DeriveOptimalBudgetPerLcu( contextPtr); } - // Compute the deviation between the predicted budget & the target budget + // Compute the deviation between the predicted budget & the target budget deviationToTarget = (ABS((EB_S32)(contextPtr->predictedCost - contextPtr->budget)) * 1000) / contextPtr->budget; // Derive shooting status if (contextPtr->predictedCost < contextPtr->budget) { @@ -1548,14 +1548,14 @@ static void DeriveOptimalBudgetPerLcu( /****************************************************** * Compute the refinment cost Input : budget per picture, and the cost of the refinment - Output : the refinment flag + Output : the refinment flag ******************************************************/ static void ComputeRefinementCost( SequenceControlSet_t *sequenceControlSetPtr, PictureControlSet_t *pictureControlSetPtr, ModeDecisionConfigurationContext_t *contextPtr) { - + EB_U32 lcuIndex; EB_U32 avcRefinementCost = 0; EB_U32 lightAvcRefinementCost = 0; @@ -1656,7 +1656,7 @@ static void DeriveLcuScore( lcuScore = distortion; - // Use uncovered area + // Use uncovered area if (pictureControlSetPtr->ParentPcsPtr->failingMotionLcuFlag[lcuIndex]) { lcuScore = pictureControlSetPtr->ParentPcsPtr->interComplexityMaxPre; @@ -1665,7 +1665,7 @@ static void DeriveLcuScore( else if ( // LCU @ a picture boundary lcuParams->isEdgeLcu - && pictureControlSetPtr->ParentPcsPtr->nonMovingIndexArray[lcuIndex] != INVALID_ZZ_COST + && pictureControlSetPtr->ParentPcsPtr->nonMovingIndexArray[lcuIndex] != INVALID_ZZ_COST && pictureControlSetPtr->ParentPcsPtr->nonMovingIndexAverage != INVALID_ZZ_COST // Active LCU && pictureControlSetPtr->ParentPcsPtr->nonMovingIndexArray[lcuIndex] >= ADP_CLASS_NON_MOVING_INDEX_TH_0 @@ -1679,7 +1679,7 @@ static void DeriveLcuScore( } else { - // Use LCU variance & activity + // Use LCU variance & activity if (pictureControlSetPtr->ParentPcsPtr->nonMovingIndexArray[lcuIndex] == ADP_CLASS_NON_MOVING_INDEX_TH_2 && pictureControlSetPtr->ParentPcsPtr->variance[lcuIndex][RASTER_SCAN_CU_INDEX_64x64] > IS_COMPLEX_LCU_VARIANCE_TH && (sequenceControlSetPtr->staticConfig.frameRate >> 16) > 30) lcuScore -= (((lcuScore - pictureControlSetPtr->ParentPcsPtr->interComplexityMinPre) * ADP_CLASS_SHIFT_DIST_0) / 100); @@ -1697,7 +1697,7 @@ static void DeriveLcuScore( if (pictureControlSetPtr->ParentPcsPtr->yMean[lcuIndex][RASTER_SCAN_CU_INDEX_64x64] < ADP_DARK_LCU_TH ) lcuScore -= (((lcuScore - pictureControlSetPtr->ParentPcsPtr->interComplexityMinPre) * ADP_CLASS_SHIFT_DIST_0) / 100); else - lcuScore += (((pictureControlSetPtr->ParentPcsPtr->interComplexityMaxPre - lcuScore) * ADP_CLASS_SHIFT_DIST_0) / 100); + lcuScore += (((pictureControlSetPtr->ParentPcsPtr->interComplexityMaxPre - lcuScore) * ADP_CLASS_SHIFT_DIST_0) / 100); } } @@ -1713,7 +1713,7 @@ static void DeriveLcuScore( } - + } /****************************************************** @@ -1792,7 +1792,7 @@ static void PerformOutlierRemoval( } } } - + // Zero-out the bin if percentage lower than VALID_SLOT_TH for (slot = 0; slot < 10; slot++){ if (processedlcuCount > 0) { @@ -1818,7 +1818,7 @@ static void PerformOutlierRemoval( } } /****************************************************** -* Assign a search method for each LCU +* Assign a search method for each LCU Input : LCU score, detection signals Output : search method for each LCU ******************************************************/ @@ -1827,7 +1827,7 @@ static void DeriveLcuMdMode( PictureControlSet_t *pictureControlSetPtr, ModeDecisionConfigurationContext_t *contextPtr) { - // Configure ADP + // Configure ADP ConfigureAdp( pictureControlSetPtr, contextPtr); @@ -1843,7 +1843,7 @@ static void DeriveLcuMdMode( pictureControlSetPtr, contextPtr); - // Compute the cost of the refinements + // Compute the cost of the refinements ComputeRefinementCost( sequenceControlSetPtr, pictureControlSetPtr, @@ -1855,7 +1855,7 @@ static void DeriveLcuMdMode( pictureControlSetPtr, contextPtr); - // Remove the outliers + // Remove the outliers PerformOutlierRemoval( sequenceControlSetPtr, pictureControlSetPtr->ParentPcsPtr, @@ -1888,12 +1888,12 @@ static EB_ERRORTYPE SignalDerivationModeDecisionConfigKernelOq( EB_ERRORTYPE return_error = EB_ErrorNone; contextPtr->adpLevel = pictureControlSetPtr->ParentPcsPtr->encMode; - + // Derive chroma Qp Offset - // 0 : 2 Layer1 0 OW + // 0 : 2 Layer1 0 OW // 1 : MOD_QP_OFFSET -3 contextPtr->chromaQpOffsetLevel = 1; - + return return_error; } @@ -1955,7 +1955,7 @@ void* ModeDecisionConfigurationKernel(void *inputPtr) (pictureControlSetPtr->ParentPcsPtr->grassPercentageInPicture <= 35) && (pictureControlSetPtr->ParentPcsPtr->picNoiseClass >= picNoiseClassTH) && (pictureControlSetPtr->ParentPcsPtr->picHomogenousOverTimeLcuPercentage < 50)) ? EB_FRAME_CARAC_1 : pictureControlSetPtr->sceneCaracteristicId; - + pictureControlSetPtr->sceneCaracteristicId = ( (pictureControlSetPtr->ParentPcsPtr->isPan) && (!pictureControlSetPtr->ParentPcsPtr->isTilt) && @@ -1975,7 +1975,7 @@ void* ModeDecisionConfigurationKernel(void *inputPtr) // Aura Detection // Still is using the picture QP to derive aura thresholds, there fore it could not move to the open loop - AuraDetection( // HT done + AuraDetection( // HT done sequenceControlSetPtr, pictureControlSetPtr, pictureWidthInLcu, @@ -1987,13 +1987,13 @@ void* ModeDecisionConfigurationKernel(void *inputPtr) pictureControlSetPtr, pictureWidthInLcu); - // Compute picture and slice level chroma QP offsets - SetSliceAndPictureChromaQpOffsets( // HT done + // Compute picture and slice level chroma QP offsets + SetSliceAndPictureChromaQpOffsets( // HT done pictureControlSetPtr, contextPtr); // Compute Tc, and Beta offsets for a given picture - AdaptiveDlfParameterComputation( // HT done + AdaptiveDlfParameterComputation( // HT done contextPtr, pictureControlSetPtr); @@ -2045,17 +2045,17 @@ void* ModeDecisionConfigurationKernel(void *inputPtr) else if (pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_LIGHT_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_PRED_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuIndex] == LCU_PRED_OPEN_LOOP_1_NFL_DEPTH_MODE) { // Predict the LCU partitionning - PerformEarlyLcuPartitionningLcu( // HT done + PerformEarlyLcuPartitionningLcu( // HT done contextPtr, sequenceControlSetPtr, pictureControlSetPtr, - lcuIndex); + lcuIndex); } } } else if (pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_FULL85_DEPTH_MODE){ - Forward85CuToModeDecision( + Forward85CuToModeDecision( sequenceControlSetPtr, pictureControlSetPtr); } @@ -2068,13 +2068,13 @@ void* ModeDecisionConfigurationKernel(void *inputPtr) else if (pictureControlSetPtr->ParentPcsPtr->depthMode >= PICT_OPEN_LOOP_DEPTH_MODE){ // Predict the LCU partitionning - PerformEarlyLcuPartitionning( // HT done + PerformEarlyLcuPartitionning( // HT done contextPtr, sequenceControlSetPtr, - pictureControlSetPtr); + pictureControlSetPtr); } else { // (pictureControlSetPtr->ParentPcsPtr->mdMode == PICT_BDP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->mdMode == PICT_LIGHT_BDP_DEPTH_MODE ) - pictureControlSetPtr->ParentPcsPtr->averageQp = (EB_U8)pictureControlSetPtr->ParentPcsPtr->pictureQp; + pictureControlSetPtr->ParentPcsPtr->averageQp = (EB_U8)pictureControlSetPtr->ParentPcsPtr->pictureQp; } #if DEADLOCK_DEBUG @@ -2082,7 +2082,7 @@ void* ModeDecisionConfigurationKernel(void *inputPtr) #endif // Post the results to the MD processes EB_U16 tileGroupRowCnt = sequenceControlSetPtr->tileGroupRowCountArray[pictureControlSetPtr->temporalLayerIndex]; - EB_U16 tileGroupColCnt = sequenceControlSetPtr->tileGroupColCountArray[pictureControlSetPtr->temporalLayerIndex]; + EB_U16 tileGroupColCnt = sequenceControlSetPtr->tileGroupColCountArray[pictureControlSetPtr->temporalLayerIndex]; for (EB_U16 r = 0; r < tileGroupRowCnt; r++) { for (EB_U16 c = 0; c < tileGroupColCnt; c++) { @@ -2104,9 +2104,9 @@ void* ModeDecisionConfigurationKernel(void *inputPtr) double latency = 0.0; EB_U64 finishTimeSeconds = 0; EB_U64 finishTimeuSeconds = 0; - EbFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); + EbHevcFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); - EbComputeOverallElapsedTimeMs( + EbHevcComputeOverallElapsedTimeMs( pictureControlSetPtr->ParentPcsPtr->startTimeSeconds, pictureControlSetPtr->ParentPcsPtr->startTimeuSeconds, finishTimeSeconds, diff --git a/Source/Lib/Codec/EbModeDecisionProcess.c b/Source/Lib/Codec/EbModeDecisionProcess.c index 44509110e..b06b44d0c 100644 --- a/Source/Lib/Codec/EbModeDecisionProcess.c +++ b/Source/Lib/Codec/EbModeDecisionProcess.c @@ -44,7 +44,7 @@ EB_ERRORTYPE ModeDecisionContextCtor( EB_MALLOC(ModeDecisionCandidate_t*, contextPtr->fastCandidateArray, sizeof(ModeDecisionCandidate_t) * MODE_DECISION_CANDIDATE_MAX_COUNT, EB_N_PTR); EB_MALLOC(ModeDecisionCandidate_t**, contextPtr->fastCandidatePtrArray, sizeof(ModeDecisionCandidate_t*) * MODE_DECISION_CANDIDATE_MAX_COUNT, EB_N_PTR); - + for(candidateIndex = 0; candidateIndex < MODE_DECISION_CANDIDATE_MAX_COUNT; ++candidateIndex) { contextPtr->fastCandidatePtrArray[candidateIndex] = &contextPtr->fastCandidateArray[candidateIndex]; contextPtr->fastCandidatePtrArray[candidateIndex]->mdRateEstimationPtr = contextPtr->mdRateEstimationPtr; @@ -249,7 +249,7 @@ void lambdaAssignRandomAccess( } -void lambdaAssignISlice( +void EbHevclambdaAssignISlice( PictureParentControlSet_t *pictureControlSetPtr, EB_U32 *fastLambda, EB_U32 *fullLambda, @@ -279,7 +279,7 @@ const EB_LAMBDA_ASSIGN_FUNC lambdaAssignmentFunctionTable[4] = { lambdaAssignLowDelay, // low delay P lambdaAssignLowDelay, // low delay B lambdaAssignRandomAccess, // Random Access - lambdaAssignISlice // I_SLICE + EbHevclambdaAssignISlice // I_SLICE }; void ProductResetModeDecision( @@ -289,7 +289,7 @@ void ProductResetModeDecision( { EB_PICTURE sliceType; MdRateEstimationContext_t *mdRateEstimationArray; - + // SAO pictureControlSetPtr->saoFlag[0] = EB_TRUE; pictureControlSetPtr->saoFlag[1] = EB_TRUE; @@ -394,7 +394,7 @@ void ConfigureChroma( EB_BOOL chromaCond2 = !lcuStatPtr->cuStatArray[0].highLuma; EB_BOOL chromaCond3 = ((pictureControlSetPtr->ParentPcsPtr->grassPercentageInPicture > 60) || (lcuPtr->auraStatus == AURA_STATUS_1) || (pictureControlSetPtr->ParentPcsPtr->isPan)); - // 0: Full Search Chroma for All + // 0: Full Search Chroma for All // 1: Best Search Chroma for All LCUs; Chroma OFF if I_SLICE, Chroma for only MV_Merge if P/B_SLICE // 2: Full vs. Best Swicth Method 0: chromaCond0 || chromaCond1 || chromaCond2 // 3: Full vs. Best Swicth Method 1: chromaCond0 || chromaCond1 @@ -578,9 +578,9 @@ void DeriveIntra4x4SearchMethod( if (pictureControlSetPtr->ParentPcsPtr->lcuFlatNoiseArray[lcuPtr->index] == EB_FALSE) { // Set INTRA4x4 Search Level - // Level Settings - // 0 INLINE if not BDP, refinment otherwise - // 1 REFINMENT + // Level Settings + // 0 INLINE if not BDP, refinment otherwise + // 1 REFINMENT // 2 OFF if (contextPtr->intra4x4Level == 0) { if ((pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_FULL85_DEPTH_MODE || @@ -616,12 +616,12 @@ void DeriveDepthRefinment( EB_U32 lcuAddr = lcuPtr->index; LcuStat_t *lcuStatPtr = &(pictureControlSetPtr->ParentPcsPtr->lcuStatArray[lcuAddr]); - + EB_U8 stationaryEdgeOverTimeFlag = lcuStatPtr->stationaryEdgeOverTimeFlag; contextPtr->depthRefinment = 0; - // S-LOGO + // S-LOGO if (stationaryEdgeOverTimeFlag > 0) { if (lcuStatPtr->lowDistLogo) contextPtr->depthRefinment = 1; @@ -663,7 +663,7 @@ void ModeDecisionConfigureLcu( pictureControlSetPtr, contextPtr, lcuPtr); - + // Load MPM Settings ConfigureMpm( contextPtr); @@ -685,7 +685,7 @@ void ModeDecisionConfigureLcu( contextPtr, lcuPtr); - if (sequenceControlSetPtr->staticConfig.rateControlMode == 0 && sequenceControlSetPtr->staticConfig.improveSharpness == 0) { + if (sequenceControlSetPtr->staticConfig.rateControlMode == 0 && sequenceControlSetPtr->staticConfig.improveSharpness == 0) { contextPtr->qp = (EB_U8)pictureQp; lcuPtr->qp = (EB_U8)contextPtr->qp; } diff --git a/Source/Lib/Codec/EbMotionEstimation.c b/Source/Lib/Codec/EbMotionEstimation.c index da62d1965..955387def 100644 --- a/Source/Lib/Codec/EbMotionEstimation.c +++ b/Source/Lib/Codec/EbMotionEstimation.c @@ -23,7 +23,7 @@ #define OIS_TH_COUNT 4 -EB_S32 OisPointTh[3][MAX_TEMPORAL_LAYERS][OIS_TH_COUNT] = { +EB_S32 EbHevcOisPointTh[3][MAX_TEMPORAL_LAYERS][OIS_TH_COUNT] = { { // Light OIS { -20, 50, 150, 200 }, @@ -33,7 +33,7 @@ EB_S32 OisPointTh[3][MAX_TEMPORAL_LAYERS][OIS_TH_COUNT] = { { -20, 50, 200, 300 }, { -20, 50, 200, 300 } }, - { + { // Default OIS { -150, 0, 150, 200 }, { -150, 0, 150, 200 }, @@ -43,7 +43,7 @@ EB_S32 OisPointTh[3][MAX_TEMPORAL_LAYERS][OIS_TH_COUNT] = { { -50, 50, 200, 300 } } , - { + { // Heavy OIS { -400, -300, -200, 0 }, { -400, -300, -200, 0 }, @@ -54,7 +54,7 @@ EB_S32 OisPointTh[3][MAX_TEMPORAL_LAYERS][OIS_TH_COUNT] = { } }; - + /******************************************** @@ -67,13 +67,13 @@ EB_S32 OisPointTh[3][MAX_TEMPORAL_LAYERS][OIS_TH_COUNT] = { * Constants ********************************************/ -#define TOP_LEFT_POSITION 0 -#define TOP_POSITION 1 -#define TOP_RIGHT_POSITION 2 -#define RIGHT_POSITION 3 -#define BOTTOM_RIGHT_POSITION 4 -#define BOTTOM_POSITION 5 -#define BOTTOM_LEFT_POSITION 6 +#define TOP_LEFT_POSITION 0 +#define TOP_POSITION 1 +#define TOP_RIGHT_POSITION 2 +#define RIGHT_POSITION 3 +#define BOTTOM_RIGHT_POSITION 4 +#define BOTTOM_POSITION 5 +#define BOTTOM_LEFT_POSITION 6 #define LEFT_POSITION 7 // The interpolation is performed using a set of three 4 tap filters @@ -160,7 +160,7 @@ static void GetEightHorizontalSearchPointResultsAll85PUs_C( EB_U32 listIndex, EB_U32 searchRegionIndex, EB_U32 xSearchIndex, - EB_U32 ySearchIndex + EB_U32 ySearchIndex ) { EB_U8 *srcPtr = contextPtr->lcuSrcPtr; @@ -451,11 +451,11 @@ static EB_FPSEARCH_FUNC FUNC_TABLE GetEightHorizontalSearchPointResultsAll85PUs_ * GetSearchPointResults *******************************************/ static void GetSearchPointResults( - MeContext_t *contextPtr, // input parameter, ME context Ptr, used to get LCU Ptr + MeContext_t *contextPtr, // input parameter, ME context Ptr, used to get LCU Ptr EB_U32 listIndex, // input parameter, reference list index EB_U32 searchRegionIndex, // input parameter, search area origin, used to point to reference samples EB_U32 xSearchIndex, // input parameter, search region position in the horizontal direction, used to derive xMV - EB_U32 ySearchIndex) // input parameter, search region position in the vertical direction, used to derive yMV + EB_U32 ySearchIndex) // input parameter, search region position in the vertical direction, used to derive yMV { EB_U8 *srcPtr = contextPtr->lcuSrcPtr; @@ -642,7 +642,7 @@ static void FullPelSearch_LCU( * F1: {-4, 36, 36, -4} * F2: {-2, 16, 54, -4} ********************************************/ -void InterpolateSearchRegionAVC( +void EbHevcInterpolateSearchRegionAVC( MeContext_t *contextPtr, // input/output parameter, ME context ptr, used to get/set interpolated search area Ptr EB_U32 listIndex, // Refrence picture list index EB_U8 *searchRegionBuffer, // input parameter, search region index, used to point to reference samples @@ -731,7 +731,7 @@ void InterpolateSearchRegionAVC( * performs Half Pel refinement for one PU *******************************************/ static void PU_HalfPelRefinement( - SequenceControlSet_t *sequenceControlSetPtr, // input parameter, Sequence control set Ptr + SequenceControlSet_t *sequenceControlSetPtr, // input parameter, Sequence control set Ptr MeContext_t *contextPtr, // input parameter, ME context Ptr, used to get LCU Ptr EB_U8 *refBuffer, EB_U32 refStride, @@ -812,7 +812,7 @@ static void PU_HalfPelRefinement( // L position searchRegionIndex = xSearchIndex + (EB_S16)contextPtr->interpolatedStride * ySearchIndex; - distortionLeftPosition = (contextPtr->fractionalSearchMethod == SSD_SEARCH) ? + distortionLeftPosition = (contextPtr->fractionalSearchMethod == SSD_SEARCH) ? SpatialFullDistortionKernel_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)][Log2f(puWidth) - 2](&(contextPtr->lcuSrcPtr[puLcuBufferIndex]), contextPtr->lcuSrcStride, &(posbBuffer[searchRegionIndex]), contextPtr->interpolatedStride, puHeight, puWidth) : (contextPtr->fractionalSearchMethod == SUB_SAD_SEARCH) ? (NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][puWidth >> 3](&(contextPtr->lcuSrcPtr[puLcuBufferIndex]), contextPtr->lcuSrcStride << 1, &(posbBuffer[searchRegionIndex]), contextPtr->interpolatedStride << 1, puHeight >> 1, puWidth)) << 1 : @@ -835,7 +835,7 @@ static void PU_HalfPelRefinement( // R position searchRegionIndex++; - distortionRightPosition = (contextPtr->fractionalSearchMethod == SSD_SEARCH) ? + distortionRightPosition = (contextPtr->fractionalSearchMethod == SSD_SEARCH) ? SpatialFullDistortionKernel_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)][Log2f(puWidth) - 2](&(contextPtr->lcuSrcPtr[puLcuBufferIndex]), contextPtr->lcuSrcStride, &(posbBuffer[searchRegionIndex]), contextPtr->interpolatedStride, puHeight, puWidth) : (contextPtr->fractionalSearchMethod == SUB_SAD_SEARCH) ? (NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][puWidth >> 3](&(contextPtr->lcuSrcPtr[puLcuBufferIndex]), contextPtr->lcuSrcStride << 1, &(posbBuffer[searchRegionIndex]), contextPtr->interpolatedStride << 1, puHeight >> 1, puWidth)) << 1 : @@ -853,13 +853,13 @@ static void PU_HalfPelRefinement( if (distortionRightPosition < *pBestSad) { *pBestSad = (EB_U32)distortionRightPosition; *pBestMV = ((EB_U16)yMvHalf[1] << 16) | ((EB_U16)xMvHalf[1]); - } + } } // T position searchRegionIndex = xSearchIndex + (EB_S16)contextPtr->interpolatedStride * ySearchIndex; - distortionTopPosition = (contextPtr->fractionalSearchMethod == SSD_SEARCH) ? + distortionTopPosition = (contextPtr->fractionalSearchMethod == SSD_SEARCH) ? SpatialFullDistortionKernel_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)][Log2f(puWidth) - 2](&(contextPtr->lcuSrcPtr[puLcuBufferIndex]), contextPtr->lcuSrcStride, &(poshBuffer[searchRegionIndex]), contextPtr->interpolatedStride, puHeight, puWidth) : (contextPtr->fractionalSearchMethod == SUB_SAD_SEARCH) ? (NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][puWidth >> 3](&(contextPtr->lcuSrcPtr[puLcuBufferIndex]), contextPtr->lcuSrcStride << 1, &(poshBuffer[searchRegionIndex]), contextPtr->interpolatedStride << 1, puHeight >> 1, puWidth)) << 1 : @@ -872,7 +872,7 @@ static void PU_HalfPelRefinement( *pBestSsd = (EB_U32)distortionTopPosition; } } - else { + else { if (distortionTopPosition < *pBestSad) { *pBestSad = (EB_U32)distortionTopPosition; *pBestMV = ((EB_U16)yMvHalf[2] << 16) | ((EB_U16)xMvHalf[2]); @@ -882,7 +882,7 @@ static void PU_HalfPelRefinement( // B position searchRegionIndex += (EB_S16)contextPtr->interpolatedStride; - distortionBottomPosition = (contextPtr->fractionalSearchMethod == SSD_SEARCH) ? + distortionBottomPosition = (contextPtr->fractionalSearchMethod == SSD_SEARCH) ? SpatialFullDistortionKernel_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)][Log2f(puWidth) - 2](&(contextPtr->lcuSrcPtr[puLcuBufferIndex]), contextPtr->lcuSrcStride, &(poshBuffer[searchRegionIndex]), contextPtr->interpolatedStride, puHeight, puWidth) : (contextPtr->fractionalSearchMethod == SUB_SAD_SEARCH) ? (NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][puWidth >> 3](&(contextPtr->lcuSrcPtr[puLcuBufferIndex]), contextPtr->lcuSrcStride << 1, &(poshBuffer[searchRegionIndex]), contextPtr->interpolatedStride << 1, puHeight >> 1, puWidth)) << 1 : @@ -905,7 +905,7 @@ static void PU_HalfPelRefinement( //TL position searchRegionIndex = xSearchIndex + (EB_S16)contextPtr->interpolatedStride * ySearchIndex; - distortionTopLeftPosition = (contextPtr->fractionalSearchMethod == SSD_SEARCH) ? + distortionTopLeftPosition = (contextPtr->fractionalSearchMethod == SSD_SEARCH) ? SpatialFullDistortionKernel_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)][Log2f(puWidth) - 2](&(contextPtr->lcuSrcPtr[puLcuBufferIndex]), contextPtr->lcuSrcStride, &(posjBuffer[searchRegionIndex]), contextPtr->interpolatedStride, puHeight, puWidth) : (contextPtr->fractionalSearchMethod == SUB_SAD_SEARCH) ? (NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][puWidth >> 3](&(contextPtr->lcuSrcPtr[puLcuBufferIndex]), contextPtr->lcuSrcStride << 1, &(posjBuffer[searchRegionIndex]), contextPtr->interpolatedStride << 1, puHeight >> 1, puWidth)) << 1 : @@ -923,7 +923,7 @@ static void PU_HalfPelRefinement( *pBestSad = (EB_U32)distortionTopLeftPosition; *pBestMV = ((EB_U16)yMvHalf[4] << 16) | ((EB_U16)xMvHalf[4]); } - + } //TR position @@ -965,11 +965,11 @@ static void PU_HalfPelRefinement( *pBestSsd = (EB_U32)distortionBottomRightPosition; } } - else { + else { if (distortionBottomRightPosition < *pBestSad) { *pBestSad = (EB_U32)distortionBottomRightPosition; *pBestMV = ((EB_U16)yMvHalf[6] << 16) | ((EB_U16)xMvHalf[6]); - } + } } //BL position @@ -1030,14 +1030,14 @@ static void PU_HalfPelRefinement( /******************************************* - * HalfPelSearch_LCU + * EbHevcHalfPelSearch_LCU * performs Half Pel refinement for the 85 PUs *******************************************/ -void HalfPelSearch_LCU( - SequenceControlSet_t *sequenceControlSetPtr, // input parameter, Sequence control set Ptr +void EbHevcHalfPelSearch_LCU( + SequenceControlSet_t *sequenceControlSetPtr, // input parameter, Sequence control set Ptr MeContext_t *contextPtr, // input/output parameter, ME context Ptr, used to get/update ME results - EB_U8 *refBuffer, - EB_U32 refStride, + EB_U8 *refBuffer, + EB_U32 refStride, EB_U8 *posbBuffer, // input parameter, position "b" interpolated search area Ptr EB_U8 *poshBuffer, // input parameter, position "h" interpolated search area Ptr EB_U8 *posjBuffer, // input parameter, position "j" interpolated search area Ptr @@ -1077,7 +1077,7 @@ void HalfPelSearch_LCU( &contextPtr->psubPelDirection64x64); } - if ( enableHalfPel32x32 ) + if ( enableHalfPel32x32 ) { // 32x32 [4 partitions] for (puIndex = 0; puIndex < 4; ++puIndex) { @@ -1227,9 +1227,9 @@ static void PU_QuarterPelRefinementOnTheFly( MeContext_t *contextPtr, // [IN] ME context Ptr, used to get LCU Ptr EB_U32 *pBestSsd, EB_U32 puLcuBufferIndex, // [IN] PU origin, used to point to source samples - EB_U8 **buf1, // [IN] + EB_U8 **buf1, // [IN] EB_U32 *buf1Stride, - EB_U8 **buf2, // [IN] + EB_U8 **buf2, // [IN] EB_U32 *buf2Stride, EB_U32 puWidth, // [IN] PU width EB_U32 puHeight, // [IN] PU height @@ -1352,7 +1352,7 @@ static void PU_QuarterPelRefinementOnTheFly( if (dist < *pBestSad) { *pBestSad = (EB_U32)dist; *pBestMV = ((EB_U16)yMvQuarter[1] << 16) | ((EB_U16)xMvQuarter[1]); - } + } } } @@ -1434,7 +1434,7 @@ static void PU_QuarterPelRefinementOnTheFly( *pBestSad = (EB_U32)dist; *pBestMV = ((EB_U16)yMvQuarter[4] << 16) | ((EB_U16)xMvQuarter[4]); } - + } } @@ -1488,7 +1488,7 @@ static void PU_QuarterPelRefinementOnTheFly( if (dist < *pBestSad) { *pBestSad = (EB_U32)dist; *pBestMV = ((EB_U16)yMvQuarter[6] << 16) | ((EB_U16)xMvQuarter[6]); - } + } } } @@ -1530,24 +1530,24 @@ static void PU_QuarterPelRefinementOnTheFly( averaging for Quarter Pel Refinement *******************************************/ static void SetQuarterPelRefinementInputsOnTheFly( - EB_U8 * pos_Full, //[IN] points to A - EB_U32 FullStride, //[IN] - EB_U8 * pos_b, //[IN] points to b - EB_U8 * pos_h, //[IN] points to h - EB_U8 * pos_j, //[IN] points to j + EB_U8 * pos_Full, //[IN] points to A + EB_U32 FullStride, //[IN] + EB_U8 * pos_b, //[IN] points to b + EB_U8 * pos_h, //[IN] points to h + EB_U8 * pos_j, //[IN] points to j EB_U32 Stride, //[IN] - EB_S16 xMv, //[IN] - EB_S16 yMv, //[IN] - EB_U8 **buf1, //[OUT] - EB_U32 * buf1Stride, //[OUT] - EB_U8 **buf2, //[OUT] - EB_U32* buf2Stride //[OUT] + EB_S16 xMv, //[IN] + EB_S16 yMv, //[IN] + EB_U8 **buf1, //[OUT] + EB_U32 * buf1Stride, //[OUT] + EB_U8 **buf2, //[OUT] + EB_U32* buf2Stride //[OUT] ) { EB_U32 quarterPelRefinementMethod = (yMv & 2) + ((xMv & 2) >> 1); - //for each one of the 8 postions, we need to determine the 2 half pel buffers to do averaging + //for each one of the 8 postions, we need to determine the 2 half pel buffers to do averaging // A a b c // d e f g @@ -1622,8 +1622,8 @@ static void SetQuarterPelRefinementInputsOnTheFly( *******************************************/ static void QuarterPelSearch_LCU( MeContext_t *contextPtr, //[IN/OUT] ME context Ptr, used to get/update ME results - EB_U8 *pos_Full, //[IN] - EB_U32 FullStride, //[IN] + EB_U8 *pos_Full, //[IN] + EB_U32 FullStride, //[IN] EB_U8 *pos_b, //[IN] EB_U8 *pos_h, //[IN] EB_U8 *pos_j, //[IN] @@ -1844,15 +1844,15 @@ static void QuarterPelSearch_LCU( } -void HmeOneQuadrantLevel0( +void EbHevcHmeOneQuadrantLevel0( MeContext_t *contextPtr, // input/output parameter, ME context Ptr, used to get/update ME results EB_S16 originX, // input parameter, LCU position in the horizontal direction- sixteenth resolution EB_S16 originY, // input parameter, LCU position in the vertical direction- sixteenth resolution - EB_U32 lcuWidth, // input parameter, LCU pwidth - sixteenth resolution + EB_U32 lcuWidth, // input parameter, LCU pwidth - sixteenth resolution EB_U32 lcuHeight, // input parameter, LCU height - sixteenth resolution EB_S16 xHmeSearchCenter, // input parameter, HME search center in the horizontal direction EB_S16 yHmeSearchCenter, // input parameter, HME search center in the vertical direction - EbPictureBufferDesc_t *sixteenthRefPicPtr, // input parameter, sixteenth reference Picture Ptr + EbPictureBufferDesc_t *sixteenthRefPicPtr, // input parameter, sixteenth reference Picture Ptr EB_U64 *level0BestSad, // output parameter, Level0 SAD at (searchRegionNumberInWidth, searchRegionNumberInHeight) EB_S16 *xLevel0SearchCenter, // output parameter, Level0 xMV at (searchRegionNumberInWidth, searchRegionNumberInHeight) EB_S16 *yLevel0SearchCenter, // output parameter, Level0 yMV at (searchRegionNumberInWidth, searchRegionNumberInHeight) @@ -1947,11 +1947,11 @@ void HmeOneQuadrantLevel0( &sixteenthRefPicPtr->bufferY[searchRegionIndex], sixteenthRefPicPtr->strideY * 2, lcuHeight >> 1, lcuWidth, - // results + // results level0BestSad, xLevel0SearchCenter, yLevel0SearchCenter, - // range + // range sixteenthRefPicPtr->strideY, searchAreaWidth, searchAreaHeight @@ -1977,7 +1977,7 @@ void HmeOneQuadrantLevel0( } else { { - // Only width equals 16 (LCU equals 64) is updated + // Only width equals 16 (LCU equals 64) is updated // other width sizes work with the old code as the one in"SadLoopKernel_SSE4_1_INTRIN" SadLoopKernel( @@ -2009,11 +2009,11 @@ void HmeOneQuadrantLevel0( } -void HmeLevel0( +void EbHevcHmeLevel0( MeContext_t *contextPtr, // input/output parameter, ME context Ptr, used to get/update ME results EB_S16 originX, // input parameter, LCU position in the horizontal direction- sixteenth resolution EB_S16 originY, // input parameter, LCU position in the vertical direction- sixteenth resolution - EB_U32 lcuWidth, // input parameter, LCU pwidth - sixteenth resolution + EB_U32 lcuWidth, // input parameter, LCU pwidth - sixteenth resolution EB_U32 lcuHeight, // input parameter, LCU height - sixteenth resolution EB_S16 xHmeSearchCenter, // input parameter, HME search center in the horizontal direction EB_S16 yHmeSearchCenter, // input parameter, HME search center in the vertical direction @@ -2100,7 +2100,7 @@ void HmeLevel0( xTopLeftSearchRegion = ((EB_S16)sixteenthRefPicPtr->originX + originX) + xSearchAreaOrigin; yTopLeftSearchRegion = ((EB_S16)sixteenthRefPicPtr->originY + originY) + ySearchAreaOrigin; searchRegionIndex = xTopLeftSearchRegion + yTopLeftSearchRegion * sixteenthRefPicPtr->strideY; - + if (((lcuWidth & 7) == 0) || (lcuWidth == 4)) { #ifndef NON_AVX512_SUPPORT @@ -2116,11 +2116,11 @@ void HmeLevel0( &sixteenthRefPicPtr->bufferY[searchRegionIndex], sixteenthRefPicPtr->strideY * 2, lcuHeight >> 1, lcuWidth, - // results + // results level0BestSad, xLevel0SearchCenter, yLevel0SearchCenter, - // range + // range sixteenthRefPicPtr->strideY, searchAreaWidth, searchAreaHeight @@ -2191,11 +2191,11 @@ void HmeLevel0( return; } -void HmeLevel1( +void EbHevcHmeLevel1( MeContext_t *contextPtr, // input/output parameter, ME context Ptr, used to get/update ME results EB_S16 originX, // input parameter, LCU position in the horizontal direction - quarter resolution EB_S16 originY, // input parameter, LCU position in the vertical direction - quarter resolution - EB_U32 lcuWidth, // input parameter, LCU pwidth - quarter resolution + EB_U32 lcuWidth, // input parameter, LCU pwidth - quarter resolution EB_U32 lcuHeight, // input parameter, LCU height - quarter resolution EbPictureBufferDesc_t *quarterRefPicPtr, // input parameter, quarter reference Picture Ptr EB_S16 hmeLevel1SearchAreaInWidth, // input parameter, hme level 1 search area in width @@ -2264,7 +2264,7 @@ void HmeLevel1( xTopLeftSearchRegion = ((EB_S16)quarterRefPicPtr->originX + originX) + xSearchAreaOrigin; yTopLeftSearchRegion = ((EB_S16)quarterRefPicPtr->originY + originY) + ySearchAreaOrigin; searchRegionIndex = xTopLeftSearchRegion + yTopLeftSearchRegion * quarterRefPicPtr->strideY; - + if (((lcuWidth & 7) == 0) || (lcuWidth == 4)) { // Put the first search location into level0 results @@ -2312,11 +2312,11 @@ void HmeLevel1( return; } -void HmeLevel2( +void EbHevcHmeLevel2( MeContext_t *contextPtr, // input/output parameter, ME context Ptr, used to get/update ME results EB_S16 originX, // input parameter, LCU position in the horizontal direction EB_S16 originY, // input parameter, LCU position in the vertical direction - EB_U32 lcuWidth, // input parameter, LCU pwidth - full resolution + EB_U32 lcuWidth, // input parameter, LCU pwidth - full resolution EB_U32 lcuHeight, // input parameter, LCU height - full resolution EbPictureBufferDesc_t *refPicPtr, // input parameter, reference Picture Ptr EB_U32 searchRegionNumberInWidth, // input parameter, search region number in the horizontal direction @@ -2408,7 +2408,7 @@ void HmeLevel2( ); } else - { + { // Put the first search location into level0 results SadLoopKernel( contextPtr->lcuSrcPtr, @@ -2442,7 +2442,7 @@ static void SelectBuffer( EB_U8 fracPosition, //[IN] EB_U32 puWidth, //[IN] Refrence picture list index EB_U32 puHeight, //[IN] Refrence picture index in the list - EB_U8 *pos_Full, //[IN] + EB_U8 *pos_Full, //[IN] EB_U8 *pos_b, //[IN] EB_U8 *pos_h, //[IN] EB_U8 *pos_j, //[IN] @@ -2496,7 +2496,7 @@ static void QuarterPelCompensation( EB_U8 fracPosition, //[IN] EB_U32 puWidth, //[IN] Refrence picture list index EB_U32 puHeight, //[IN] Refrence picture index in the list - EB_U8 *pos_Full, //[IN] + EB_U8 *pos_Full, //[IN] EB_U8 *pos_b, //[IN] EB_U8 *pos_h, //[IN] EB_U8 *pos_j, //[IN] @@ -2605,7 +2605,7 @@ static void QuarterPelCompensation( * Requirement (x86 only): dst->strideY % 16 = 0 when puWidth %16 = 0 * Requirement (x86 only): dst->chromaStride % 16 = 0 when puWidth %32 = 0 *******************************************************************************/ -EB_U32 BiPredAverging( +EB_U32 EbHevcBiPredAverging( MeContext_t *contextPtr, MePredUnit_t *meCandidate, EB_U32 puIndex, @@ -2739,7 +2739,7 @@ EB_U32 BiPredAverging( * List1 Candidates and then compute the * average *******************************************/ -EB_ERRORTYPE BiPredictionCompensation( +EB_ERRORTYPE EbHevcBiPredictionCompensation( MeContext_t *contextPtr, EB_U32 puIndex, MePredUnit_t *meCandidate, @@ -2833,9 +2833,9 @@ EB_ERRORTYPE BiPredictionCompensation( EB_U32 nIndex = puIndex > 20 ? tab8x8[puIndex-21] + 21 : puIndex > 4 ? tab32x32[puIndex-5] + 5 : puIndex; - contextPtr->pLcuBipredSad[nIndex] = + contextPtr->pLcuBipredSad[nIndex] = - BiPredAverging( + EbHevcBiPredAverging( contextPtr, meCandidate, puIndex, @@ -2863,11 +2863,11 @@ EB_ERRORTYPE BiPredictionCompensation( } /******************************************* - * BiPredictionSearch + * EbHevcBiPredictionSearch * performs Bi-Prediction Search (LCU) *******************************************/ // This function enables all 16 Bipred candidates when MRP is ON -EB_ERRORTYPE BiPredictionSearch( +EB_ERRORTYPE EbHevcBiPredictionSearch( MeContext_t *contextPtr, EB_U32 puIndex, EB_U8 candidateIndex, @@ -2883,13 +2883,13 @@ EB_ERRORTYPE BiPredictionSearch( (void)pictureControlSetPtr; EB_U32 nIndex = puIndex > 20 ? tab8x8[puIndex-21] + 21 : - puIndex > 4 ? tab32x32[puIndex-5] + 5 : puIndex; + puIndex > 4 ? tab32x32[puIndex-5] + 5 : puIndex; for (firstListRefPictdx = 0; firstListRefPictdx < activeRefPicFirstLisNum; firstListRefPictdx++) { for (secondListRefPictdx = 0; secondListRefPictdx < activeRefPicSecondLisNum; secondListRefPictdx++) { { - BiPredictionCompensation( + EbHevcBiPredictionCompensation( contextPtr, puIndex, &(contextPtr->meCandidate[candidateIndex].pu[puIndex]), @@ -2919,22 +2919,22 @@ EB_ERRORTYPE BiPredictionSearch( EB_S8 Sort3Elements(EB_U32 a, EB_U32 b, EB_U32 c){ EB_U8 sortCode = 0; - if (a <= b && a <= c){ + if (a <= b && a <= c){ if (b <= c) { sortCode = a_b_c; - }else{ + }else{ sortCode = a_c_b; } }else if (b <= a && b <= c) { - if (a <= c) { + if (a <= c) { sortCode = b_a_c; - }else { + }else { sortCode = b_c_a; } - }else if (a <= b){ + }else if (a <= b){ sortCode = c_a_b; - } else{ + } else{ sortCode = c_b_a; } @@ -2943,7 +2943,7 @@ EB_S8 Sort3Elements(EB_U32 a, EB_U32 b, EB_U32 c){ } -EB_ERRORTYPE CheckZeroZeroCenter( +EB_ERRORTYPE EbHevcCheckZeroZeroCenter( EbPictureBufferDesc_t *refPicPtr, MeContext_t *contextPtr, EB_U32 lcuOriginX, @@ -3017,7 +3017,7 @@ EB_ERRORTYPE CheckZeroZeroCenter( hmeMvdRate = 0; - MeGetMvdFractionBits( + MeEbHevcGetMvdFractionBits( ABS(*xSearchCenter << 2), ABS(*ySearchCenter << 2), contextPtr->mvdBitsArray, @@ -3441,7 +3441,7 @@ static void TestSearchAreaBounds( MvASad = MvASad << subsampleSad; EB_U32 MvAdRate = 0; - MeGetMvdFractionBits( + MeEbHevcGetMvdFractionBits( ABS(xSearchCenter << 2), ABS(ySearchCenter << 2), contextPtr->mvdBitsArray, @@ -3487,7 +3487,7 @@ static void TestSearchAreaBounds( EB_U32 MvBdRate = 0; - MeGetMvdFractionBits( + MeEbHevcGetMvdFractionBits( ABS(xSearchCenter << 2), ABS(ySearchCenter << 2), contextPtr->mvdBitsArray, @@ -3533,7 +3533,7 @@ static void TestSearchAreaBounds( EB_U32 MvCdRate = 0; - MeGetMvdFractionBits( + MeEbHevcGetMvdFractionBits( ABS(xSearchCenter << 2), ABS(ySearchCenter << 2), contextPtr->mvdBitsArray, @@ -3571,7 +3571,7 @@ static void TestSearchAreaBounds( MvDSad = MvDSad << subsampleSad; EB_U32 MvDdRate = 0; - MeGetMvdFractionBits( + MeEbHevcGetMvdFractionBits( ABS(xSearchCenter << 2), ABS(ySearchCenter << 2), contextPtr->mvdBitsArray, @@ -3616,7 +3616,7 @@ static void TestSearchAreaBounds( EB_U32 direcMvdRate = 0; - MeGetMvdFractionBits( + MeEbHevcGetMvdFractionBits( ABS(xSearchCenter << 2), ABS(ySearchCenter << 2), contextPtr->mvdBitsArray, @@ -3668,7 +3668,7 @@ static void TestSearchAreaBounds( *******************************************/ EB_ERRORTYPE MotionEstimateLcu( PictureParentControlSet_t *pictureControlSetPtr, // input parameter, Picture Control Set Ptr - EB_U32 lcuIndex, // input parameter, LCU Index + EB_U32 lcuIndex, // input parameter, LCU Index EB_U32 lcuOriginX, // input parameter, LCU Origin X EB_U32 lcuOriginY, // input parameter, LCU Origin X MeContext_t *contextPtr, // input parameter, ME Context Ptr, used to store decimated/interpolated LCU/SR @@ -3734,13 +3734,13 @@ EB_ERRORTYPE MotionEstimateLcu( EB_S16 tempXHmeSearchCenter = 0; EB_S16 tempYHmeSearchCenter = 0; - + EB_U32 numQuadInWidth; EB_U32 totalMeQuad; EB_U32 quadIndex; EB_U32 nextQuadIndex; EB_U64 tempXHmeSad; - + EB_U64 ref0Poc = 0; EB_U64 ref1Poc = 0; @@ -3772,7 +3772,7 @@ EB_ERRORTYPE MotionEstimateLcu( } // Uni-Prediction motion estimation loop - // List Loop + // List Loop for (listIndex = REF_LIST_0; listIndex <= numOfListToSearch; ++listIndex) { // Ref Picture Loop @@ -3836,7 +3836,7 @@ EB_ERRORTYPE MotionEstimateLcu( searchRegionNumberInHeight = 0; searchRegionNumberInWidth = 0; - HmeOneQuadrantLevel0( + EbHevcHmeOneQuadrantLevel0( contextPtr, originX >> 2, originY >> 2, @@ -3844,7 +3844,7 @@ EB_ERRORTYPE MotionEstimateLcu( lcuHeight >> 2, xSearchCenter >> 2, ySearchCenter >> 2, - sixteenthRefPicPtr, + sixteenthRefPicPtr, &(hmeLevel0Sad[searchRegionNumberInWidth][searchRegionNumberInHeight]), &(xHmeLevel0SearchCenter[searchRegionNumberInWidth][searchRegionNumberInHeight]), &(yHmeLevel0SearchCenter[searchRegionNumberInWidth][searchRegionNumberInHeight]), @@ -3861,7 +3861,7 @@ EB_ERRORTYPE MotionEstimateLcu( while (searchRegionNumberInHeight < contextPtr->numberHmeSearchRegionInHeight) { while (searchRegionNumberInWidth < contextPtr->numberHmeSearchRegionInWidth) { - HmeLevel0( + EbHevcHmeLevel0( contextPtr, originX >> 2, originY >> 2, @@ -3882,7 +3882,7 @@ EB_ERRORTYPE MotionEstimateLcu( } searchRegionNumberInWidth = 0; searchRegionNumberInHeight++; - } + } } } @@ -3897,7 +3897,7 @@ EB_ERRORTYPE MotionEstimateLcu( // When HME level 0 has been disabled, increase the search area width and height for level 1 to (32x12) hmeLevel1SearchAreaInWidth = (EB_S16)contextPtr->hmeLevel1SearchAreaInWidthArray[searchRegionNumberInWidth]; hmeLevel1SearchAreaInHeight = (EB_S16)contextPtr->hmeLevel1SearchAreaInHeightArray[searchRegionNumberInHeight]; - HmeLevel1( + EbHevcHmeLevel1( contextPtr, originX >> 1, originY >> 1, @@ -3930,7 +3930,7 @@ EB_ERRORTYPE MotionEstimateLcu( while (searchRegionNumberInWidth < contextPtr->numberHmeSearchRegionInWidth) { - HmeLevel2( + EbHevcHmeLevel2( contextPtr, originX, originY, @@ -4071,7 +4071,7 @@ EB_ERRORTYPE MotionEstimateLcu( searchAreaHeight = (EB_S16)MIN(contextPtr->searchAreaHeight, 127); if (xSearchCenter != 0 || ySearchCenter != 0) { - CheckZeroZeroCenter( + EbHevcCheckZeroZeroCenter( refPicPtr, contextPtr, lcuOriginX, @@ -4105,7 +4105,7 @@ EB_ERRORTYPE MotionEstimateLcu( //Jing: Get tile index where this LCU belongs //Jing: TODO - //Clean up this mess + //Clean up this mess if (sequenceControlSetPtr->staticConfig.unrestrictedMotionVector == 0 && (sequenceControlSetPtr->staticConfig.tileRowCount * sequenceControlSetPtr->staticConfig.tileColumnCount) > 1) { EB_U16 lcuTileIdx = pictureControlSetPtr->lcuEdgeInfoArray[lcuIndex].tileIndexInRaster; @@ -4271,9 +4271,9 @@ EB_ERRORTYPE MotionEstimateLcu( yTopLeftSearchRegion = (EB_S16)(refPicPtr->originY + lcuOriginY) + ySearchAreaOrigin; searchRegionIndex = xTopLeftSearchRegion + yTopLeftSearchRegion * refPicPtr->strideY; - // Interpolate the search region for Half-Pel Refinements + // Interpolate the search region for Half-Pel Refinements // H - AVC Style - InterpolateSearchRegionAVC( + EbHevcInterpolateSearchRegionAVC( contextPtr, listIndex, contextPtr->integerBufferPtr[listIndex][0] + (ME_FILTER_TAP >> 1) + ((ME_FILTER_TAP >> 1) * contextPtr->interpolatedFullStride[listIndex][0]), @@ -4282,7 +4282,7 @@ EB_ERRORTYPE MotionEstimateLcu( (EB_U32)searchAreaHeight + (MAX_LCU_SIZE - 1)); // Half-Pel Refinement [8 search positions] - HalfPelSearch_LCU( + EbHevcHalfPelSearch_LCU( sequenceControlSetPtr, contextPtr, contextPtr->integerBufferPtr[listIndex][0] + (ME_FILTER_TAP >> 1) + ((ME_FILTER_TAP >> 1) * contextPtr->interpolatedFullStride[listIndex][0]), @@ -4312,7 +4312,7 @@ EB_ERRORTYPE MotionEstimateLcu( enableHalfPel16x16 && pictureControlSetPtr->cu16x16Mode == CU_16x16_MODE_0, enableHalfPel8x8, enableQuarterPel); - } + } } } @@ -4320,7 +4320,7 @@ EB_ERRORTYPE MotionEstimateLcu( for (puIndex = 0; puIndex < maxNumberOfPusPerLcu; ++puIndex) { candidateIndex = 0; EB_U32 nIdx = puIndex > 20 ? tab8x8[puIndex-21] + 21 : - puIndex > 4 ? tab32x32[puIndex-5] + 5 : puIndex; + puIndex > 4 ? tab32x32[puIndex-5] + 5 : puIndex; for (listIndex = REF_LIST_0; listIndex <= numOfListToSearch; ++listIndex) { candidateIndex++; @@ -4332,7 +4332,7 @@ EB_ERRORTYPE MotionEstimateLcu( EB_BOOL condition = (EB_BOOL)((pictureControlSetPtr->cu8x8Mode == CU_8x8_MODE_0 || puIndex < 21) && (pictureControlSetPtr->cu16x16Mode == CU_16x16_MODE_0 || puIndex < 5)); if (condition) { - BiPredictionSearch( + EbHevcBiPredictionSearch( contextPtr, puIndex, candidateIndex, @@ -4479,7 +4479,7 @@ void IntraOpenLoopSearchTheseModesOutputBest( (EB_U32)mode); //Distortion - sadArray[candidateIndex] = (EB_U32)NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][cuSize >> 3]( // Always SAD without weighting + sadArray[candidateIndex] = (EB_U32)NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][cuSize >> 3]( // Always SAD without weighting src, srcStride, &(contextPtr->meContextPtr->lcuBuffer[0]), @@ -4503,14 +4503,14 @@ void InjectIntraCandidatesBasedOnBestModeIslice( EB_U32 bestMode, EB_U8 *count) { - + oisCuPtr[(*count)].validDistortion = EB_TRUE; oisCuPtr[(*count)].distortion = stage1SadArray[0]; oisCuPtr[(*count)++].intraMode = EB_INTRA_PLANAR; oisCuPtr[(*count)++].intraMode = EB_INTRA_DC; switch (bestMode){ - + case EB_INTRA_PLANAR: case EB_INTRA_DC: @@ -4794,7 +4794,7 @@ EB_S32 GetInterIntraSadDistance( (EB_U32)1); //Distortion - stage1SadArray[0] = (EB_U32)NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][cuSize >> 3]( // Always SAD without weighting + stage1SadArray[0] = (EB_U32)NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][cuSize >> 3]( // Always SAD without weighting src, inputPtr->strideY, &(contextPtr->meContextPtr->lcuBuffer[0]), @@ -4819,18 +4819,18 @@ EB_IOS_POINT GetOisPoint( { EB_IOS_POINT oisPoint = OIS_VERY_COMPLEX_MODE; // Intra points switcher - if (stage1SadArray[0] == 0 || meSad == 0 || interIntraSadDistance <= OisPointTh[oisThSet][temporalLayerIndex][0]){ + if (stage1SadArray[0] == 0 || meSad == 0 || interIntraSadDistance <= EbHevcOisPointTh[oisThSet][temporalLayerIndex][0]){ oisPoint = OIS_VERY_FAST_MODE; } else { - if (interIntraSadDistance <= OisPointTh[oisThSet][temporalLayerIndex][1]){ + if (interIntraSadDistance <= EbHevcOisPointTh[oisThSet][temporalLayerIndex][1]){ oisPoint = OIS_FAST_MODE; } - else if (interIntraSadDistance <= OisPointTh[oisThSet][temporalLayerIndex][2]){ + else if (interIntraSadDistance <= EbHevcOisPointTh[oisThSet][temporalLayerIndex][2]){ oisPoint = OIS_MEDUIM_MODE; } - else if (interIntraSadDistance <= OisPointTh[oisThSet][temporalLayerIndex][3]){ + else if (interIntraSadDistance <= EbHevcOisPointTh[oisThSet][temporalLayerIndex][3]){ oisPoint = OIS_COMPLEX_MODE; } } @@ -4867,10 +4867,10 @@ EB_ERRORTYPE SortOisCandidateOpenLoop( } EB_ERRORTYPE SortIntraModesOpenLoop( - PictureParentControlSet_t *pictureControlSetPtr, // input parameter, pointer to the current lcu + PictureParentControlSet_t *pictureControlSetPtr, // input parameter, pointer to the current lcu EB_U32 lcuIndex, // input parameter, lcu Index EB_U32 cuIndex, // input parameter, cu index - EB_U32 sadDistortion, // input parameter, SAD + EB_U32 sadDistortion, // input parameter, SAD EB_U32 openLoopIntraCandidateIndex) // input parameter, intra mode { EB_ERRORTYPE return_error = EB_ErrorNone; @@ -4893,7 +4893,7 @@ EB_ERRORTYPE SortIntraModesOpenLoop( oisCuPtr[openLoopIntraCandidateIndex].distortion = sadDistortion; oisCuPtr[openLoopIntraCandidateIndex].intraMode = openLoopIntraCandidateIndex; - // Get a copy of the OIS SAD and mode - This array will be sorted + // Get a copy of the OIS SAD and mode - This array will be sorted // This array is not used in RC and DeltaQP oisCuPtr[openLoopIntraCandidateIndex].distortion = sadDistortion; oisCuPtr[openLoopIntraCandidateIndex].intraMode = openLoopIntraCandidateIndex; @@ -4901,7 +4901,7 @@ EB_ERRORTYPE SortIntraModesOpenLoop( } else { EB_U32 intraIndex; - // Determine max SAD distortion + // Determine max SAD distortion worstSadDistortion = oisCuPtr[0].distortion; worstIntraCandidateIndex = EB_INTRA_PLANAR; @@ -4949,7 +4949,7 @@ EB_U32 UpdateNeighborDcIntraPred( contextPtr, (EB_U32)INTRA_DC_MODE); - distortion = (EB_U32)NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][cuSize >> 3]( // Always SAD without weighting + distortion = (EB_U32)NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][cuSize >> 3]( // Always SAD without weighting &(inputPtr->bufferY[(inputPtr->originY + cuOriginY) * inputPtr->strideY + (inputPtr->originX + cuOriginX)]), inputPtr->strideY, &(contextPtr->meContextPtr->lcuBuffer[0]), @@ -5029,22 +5029,22 @@ EB_ERRORTYPE OpenLoopIntraDC( EB_U8 GetNumOfIntraModesFromOisPoint( PictureParentControlSet_t *pictureControlSetPtr, EB_U32 meSad, - EB_U32 oisDcSad + EB_U32 oisDcSad ) -{ - +{ + EB_S32 sadDiff = (EB_S32)(meSad - oisDcSad) * 100; EB_S32 interIntraSadDistance = oisDcSad ? (sadDiff / (EB_S32)oisDcSad) : 0; - + EB_U8 oisPoint = GetOisPoint( 0, meSad, pictureControlSetPtr->temporalLayerIndex, interIntraSadDistance, &oisDcSad); - - return numberOfOisModePoints[oisPoint]; + + return numberOfOisModePoints[oisPoint]; } @@ -5069,7 +5069,7 @@ EB_ERRORTYPE OpenLoopIntraSearchLcu( EB_U32 sadDistortion; EB_U32 intraCandidateIndex; EB_U32 bestMode = EB_INTRA_PLANAR; - + LcuParams_t *lcuParams = &sequenceControlSetPtr->lcuParamsArray[lcuIndex]; @@ -5085,7 +5085,7 @@ EB_ERRORTYPE OpenLoopIntraSearchLcu( OisCandidate_t *oisCuPtr = rasterScanCuIndex < RASTER_SCAN_CU_INDEX_8x8_0 ? oisCu32Cu16ResultsPtr->sortedOisCandidate[rasterScanCuIndex] : oisCu8ResultsPtr->sortedOisCandidate[rasterScanCuIndex - RASTER_SCAN_CU_INDEX_8x8_0]; - // Initialize valid distortion flag + // Initialize valid distortion flag for (intraCandidateIndex = 0; intraCandidateIndex < MAX_OIS_0; intraCandidateIndex++) { oisCuPtr[intraCandidateIndex].validDistortion = EB_FALSE; } @@ -5160,7 +5160,7 @@ EB_ERRORTYPE OpenLoopIntraSearchLcu( EB_U32 maxCuIndex = (skipOis8x8 || pictureControlSetPtr->cu8x8Mode == CU_8x8_MODE_1) ? RASTER_SCAN_CU_INDEX_16x16_15 : RASTER_SCAN_CU_INDEX_8x8_63; for (rasterScanCuIndex = RASTER_SCAN_CU_INDEX_32x32_0; rasterScanCuIndex <= maxCuIndex; rasterScanCuIndex++) { - + EB_IOS_POINT oisPoint = OIS_VERY_COMPLEX_MODE; cuSize = RASTER_SCAN_CU_SIZE[rasterScanCuIndex]; @@ -5186,7 +5186,7 @@ EB_ERRORTYPE OpenLoopIntraSearchLcu( if (contextPtr->oisKernelLevel) { - // Initialize valid distortion flag + // Initialize valid distortion flag for (intraCandidateIndex = 0; intraCandidateIndex < MAX_OIS_2; intraCandidateIndex++) { oisCuPtr[intraCandidateIndex].validDistortion = EB_FALSE; } @@ -5231,7 +5231,7 @@ EB_ERRORTYPE OpenLoopIntraSearchLcu( else { - // Initialize valid distortion flag + // Initialize valid distortion flag for (intraCandidateIndex = 0; intraCandidateIndex < MAX_OIS_1; intraCandidateIndex++) { oisCuPtr[intraCandidateIndex].validDistortion = EB_FALSE; } @@ -5318,8 +5318,3 @@ EB_ERRORTYPE OpenLoopIntraSearchLcu( return return_error; } - - - - - diff --git a/Source/Lib/Codec/EbMotionEstimation.h b/Source/Lib/Codec/EbMotionEstimation.h index 3945e5c3e..3ab2f7b79 100644 --- a/Source/Lib/Codec/EbMotionEstimation.h +++ b/Source/Lib/Codec/EbMotionEstimation.h @@ -19,7 +19,7 @@ extern "C" { #endif extern EB_ERRORTYPE MotionEstimateLcu( - PictureParentControlSet_t *pictureControlSetPtr, + PictureParentControlSet_t *pictureControlSetPtr, EB_U32 lcuIndex, EB_U32 lcuOriginX, EB_U32 lcuOriginY, @@ -47,13 +47,13 @@ extern EB_ERRORTYPE OpenLoopIntraSearchLcu( MotionEstimationContext_t *contextPtr, EbPictureBufferDesc_t *inputPtr); -extern void GetMv( +extern void EbHevcGetMv( PictureParentControlSet_t *pictureControlSetPtr, EB_U32 lcuIndex, EB_S32 *xCurrentMv, EB_S32 *yCurrentMv); -extern void GetMeDist( +extern void EbHevcGetMeDist( PictureParentControlSet_t *pictureControlSetPtr, EB_U32 lcuIndex, EB_U32 *distortion); diff --git a/Source/Lib/Codec/EbMotionEstimationContext.c b/Source/Lib/Codec/EbMotionEstimationContext.c index 6fc326239..671e98f5d 100644 --- a/Source/Lib/Codec/EbMotionEstimationContext.c +++ b/Source/Lib/Codec/EbMotionEstimationContext.c @@ -9,7 +9,7 @@ #include "EbMotionEstimationContext.h" -void MotionEstimetionPredUnitCtor( +void EbHevcMotionEstimetionPredUnitCtor( MePredUnit_t *pu) { @@ -42,19 +42,19 @@ EB_ERRORTYPE MeContextCtor( // Intermediate LCU-sized buffer to retain the input samples (*objectDblPtr)->lcuBufferStride = MAX_LCU_SIZE; EB_ALLIGN_MALLOC(EB_U8 *, (*objectDblPtr)->lcuBuffer, sizeof(EB_U8) * MAX_LCU_SIZE * (*objectDblPtr)->lcuBufferStride, EB_A_PTR); - + (*objectDblPtr)->hmeLcuBufferStride = (MAX_LCU_SIZE + HME_DECIM_FILTER_TAP - 1); EB_MALLOC(EB_U8 *, (*objectDblPtr)->hmeLcuBuffer, sizeof(EB_U8) * (MAX_LCU_SIZE + HME_DECIM_FILTER_TAP - 1) * (*objectDblPtr)->hmeLcuBufferStride, EB_N_PTR); - + (*objectDblPtr)->quarterLcuBufferStride = (MAX_LCU_SIZE >> 1); EB_MALLOC(EB_U8 *, (*objectDblPtr)->quarterLcuBuffer, sizeof(EB_U8) * (MAX_LCU_SIZE >> 1) * (*objectDblPtr)->quarterLcuBufferStride, EB_N_PTR); (*objectDblPtr)->sixteenthLcuBufferStride = (MAX_LCU_SIZE >> 2); EB_ALLIGN_MALLOC(EB_U8 *, (*objectDblPtr)->sixteenthLcuBuffer, sizeof(EB_U8) * (MAX_LCU_SIZE >> 2) * (*objectDblPtr)->sixteenthLcuBufferStride, EB_A_PTR); - + (*objectDblPtr)->interpolatedStride = MAX_SEARCH_AREA_WIDTH; EB_MALLOC(EB_U8 *, (*objectDblPtr)->hmeBuffer, sizeof(EB_U8) * (*objectDblPtr)->interpolatedStride * MAX_SEARCH_AREA_HEIGHT, EB_N_PTR); - + (*objectDblPtr)->hmeBufferStride = MAX_SEARCH_AREA_WIDTH; EB_MEMSET((*objectDblPtr)->lcuBuffer, 0 , sizeof(EB_U8) * MAX_LCU_SIZE * (*objectDblPtr)->lcuBufferStride); @@ -106,30 +106,30 @@ EB_ERRORTYPE MeContextCtor( for( refPicIndex = 0; refPicIndex < MAX_REF_IDX; refPicIndex++) { EB_MALLOC(EB_U8 *, (*objectDblPtr)->integerBuffer[listIndex][refPicIndex], sizeof(EB_U8) * (*objectDblPtr)->interpolatedStride * MAX_SEARCH_AREA_HEIGHT, EB_N_PTR); - + EB_MALLOC(EB_U8 *, (*objectDblPtr)->posbBuffer[listIndex][refPicIndex], sizeof(EB_U8) * (*objectDblPtr)->interpolatedStride * MAX_SEARCH_AREA_HEIGHT, EB_N_PTR); - + EB_MALLOC(EB_U8 *, (*objectDblPtr)->poshBuffer[listIndex][refPicIndex], sizeof(EB_U8) * (*objectDblPtr)->interpolatedStride * MAX_SEARCH_AREA_HEIGHT, EB_N_PTR); - + EB_MALLOC(EB_U8 *, (*objectDblPtr)->posjBuffer[listIndex][refPicIndex], sizeof(EB_U8) * (*objectDblPtr)->interpolatedStride * MAX_SEARCH_AREA_HEIGHT, EB_N_PTR); - + } } EB_MALLOC(EB_BYTE, (*objectDblPtr)->oneDIntermediateResultsBuf0, sizeof(EB_U8)*MAX_LCU_SIZE*MAX_LCU_SIZE, EB_N_PTR); - + EB_MALLOC(EB_BYTE, (*objectDblPtr)->oneDIntermediateResultsBuf1, sizeof(EB_U8)*MAX_LCU_SIZE*MAX_LCU_SIZE, EB_N_PTR); - + for(puIndex= 0; puIndex < MAX_ME_PU_COUNT; puIndex++) { for( meCandidateIndex = 0; meCandidateIndex < MAX_ME_CANDIDATE_PER_PU; meCandidateIndex++) { - MotionEstimetionPredUnitCtor(&((*objectDblPtr)->meCandidate[meCandidateIndex]).pu[puIndex]); + EbHevcMotionEstimetionPredUnitCtor(&((*objectDblPtr)->meCandidate[meCandidateIndex]).pu[puIndex]); } } EB_MALLOC(EB_U8 *, (*objectDblPtr)->avctempBuffer, sizeof(EB_U8) * (*objectDblPtr)->interpolatedStride * MAX_SEARCH_AREA_HEIGHT, EB_N_PTR); - + EB_MALLOC(EB_U16 *, (*objectDblPtr)->pEightPosSad16x16, sizeof(EB_U16) * 8 * 16, EB_N_PTR);//16= 16 16x16 blocks in a LCU. 8=8search points - + return EB_ErrorNone; } diff --git a/Source/Lib/Codec/EbMotionEstimationProcess.c b/Source/Lib/Codec/EbMotionEstimationProcess.c index dfd8d0bb8..01744c4e2 100644 --- a/Source/Lib/Codec/EbMotionEstimationProcess.c +++ b/Source/Lib/Codec/EbMotionEstimationProcess.c @@ -46,7 +46,7 @@ |42||43||46||47| |58||59||62||63| -------------------------------------*/ - + /************************************************ * Set ME/HME Params ************************************************/ @@ -66,11 +66,11 @@ static void* SetMeHmeParamsOq( (inputResolution <= INPUT_SIZE_1080i_RANGE && inputRatio > 3) ? 2 : // 1080I (inputResolution <= INPUT_SIZE_1080p_RANGE) ? 3 : // 1080I 4; // 4K - + // HME/ME default settings meContextPtr->numberHmeSearchRegionInWidth = EB_HME_SEARCH_AREA_COLUMN_MAX_COUNT; meContextPtr->numberHmeSearchRegionInHeight = EB_HME_SEARCH_AREA_ROW_MAX_COUNT; - + // HME Level0 meContextPtr->hmeLevel0TotalSearchAreaWidth = HmeLevel0TotalSearchAreaWidthOq[resolutionIndex][hmeMeLevel]; meContextPtr->hmeLevel0TotalSearchAreaHeight = HmeLevel0TotalSearchAreaHeightOq[resolutionIndex][hmeMeLevel]; @@ -101,7 +101,7 @@ static void* SetMeHmeParamsOq( if (hmeMeLevel == ENC_MODE_6 || hmeMeLevel == ENC_MODE_7) { meContextPtr->hmeLevel0TotalSearchAreaWidth = MAX(96 , meContextPtr->hmeLevel0TotalSearchAreaWidth ); meContextPtr->hmeLevel0TotalSearchAreaHeight = MAX(64 , meContextPtr->hmeLevel0TotalSearchAreaHeight ); - meContextPtr->hmeLevel0SearchAreaInWidthArray[0] = MAX(48 , meContextPtr->hmeLevel0SearchAreaInWidthArray[0] ); + meContextPtr->hmeLevel0SearchAreaInWidthArray[0] = MAX(48 , meContextPtr->hmeLevel0SearchAreaInWidthArray[0] ); meContextPtr->hmeLevel0SearchAreaInWidthArray[1] = MAX(48 , meContextPtr->hmeLevel0SearchAreaInWidthArray[1] ); meContextPtr->hmeLevel0SearchAreaInHeightArray[0] = MAX(32 , meContextPtr->hmeLevel0SearchAreaInHeightArray[0] ); meContextPtr->hmeLevel0SearchAreaInHeightArray[1] = MAX(32 , meContextPtr->hmeLevel0SearchAreaInHeightArray[1] ); @@ -109,7 +109,7 @@ static void* SetMeHmeParamsOq( else if (hmeMeLevel >= ENC_MODE_8) { meContextPtr->hmeLevel0TotalSearchAreaWidth = MAX(64 , meContextPtr->hmeLevel0TotalSearchAreaWidth ); meContextPtr->hmeLevel0TotalSearchAreaHeight = MAX(48 , meContextPtr->hmeLevel0TotalSearchAreaHeight ); - meContextPtr->hmeLevel0SearchAreaInWidthArray[0] = MAX(32 , meContextPtr->hmeLevel0SearchAreaInWidthArray[0] ); + meContextPtr->hmeLevel0SearchAreaInWidthArray[0] = MAX(32 , meContextPtr->hmeLevel0SearchAreaInWidthArray[0] ); meContextPtr->hmeLevel0SearchAreaInWidthArray[1] = MAX(32 , meContextPtr->hmeLevel0SearchAreaInWidthArray[1] ); meContextPtr->hmeLevel0SearchAreaInHeightArray[0] = MAX(24 , meContextPtr->hmeLevel0SearchAreaInHeightArray[0] ); meContextPtr->hmeLevel0SearchAreaInHeightArray[1] = MAX(24 , meContextPtr->hmeLevel0SearchAreaInHeightArray[1] ); @@ -232,7 +232,7 @@ static EB_ERRORTYPE ComputeDecimatedZzSad( blkDisplacementDecimated = (sixteenthDecimatedPicturePtr->originY + (lcuOriginY >> 2)) * sixteenthDecimatedPicturePtr->strideY + sixteenthDecimatedPicturePtr->originX + (lcuOriginX >> 2); blkDisplacementFull = (previousInputPictureFull->originY + lcuOriginY)* previousInputPictureFull->strideY + (previousInputPictureFull->originX + lcuOriginX); - // 1/16 collocated LCU decimation + // 1/16 collocated LCU decimation Decimation2D( &previousInputPictureFull->bufferY[blkDisplacementFull], previousInputPictureFull->strideY, @@ -254,7 +254,7 @@ static EB_ERRORTYPE ComputeDecimatedZzSad( // Classification is important to: // 1. Avoid improving moving objects. // 2. Do not modulate when all the picture is background - // 3. Do give different importance to different regions + // 3. Do give different importance to different regions if (decimatedLcuCollocatedSad < BEA_CLASS_0_0_DEC_TH) { previousPictureControlSetWrapperPtr->zzCostArray[lcuIndex] = BEA_CLASS_0_ZZ_COST; } @@ -363,22 +363,22 @@ EB_ERRORTYPE SignalDerivationMeKernelOq( else { contextPtr->oisKernelLevel = EB_FALSE; } - + // Set OIS TH - // 0: Agressive + // 0: Agressive // 1: Default // 2: Conservative if (sequenceControlSetPtr->inputResolution == INPUT_SIZE_4K_RANGE) { if (pictureControlSetPtr->encMode <= ENC_MODE_5) { if (pictureControlSetPtr->isUsedAsReferenceFlag == EB_TRUE) { - contextPtr->oisThSet = 2; + contextPtr->oisThSet = 2; } else { - contextPtr->oisThSet = 1; + contextPtr->oisThSet = 1; } } else { - contextPtr->oisThSet = 1; + contextPtr->oisThSet = 1; } } else { @@ -386,15 +386,15 @@ EB_ERRORTYPE SignalDerivationMeKernelOq( contextPtr->oisThSet = 2; } else { - contextPtr->oisThSet = 1; + contextPtr->oisThSet = 1; } } - + // Set valid flag for the best OIS contextPtr->setBestOisDistortionToValid = EB_FALSE; // Set fractional search model - // 0: search all blocks + // 0: search all blocks // 1: selective based on Full-Search SAD & MV. // 2: off if (pictureControlSetPtr->useSubpelFlag == 1) { @@ -415,18 +415,18 @@ EB_ERRORTYPE SignalDerivationMeKernelOq( } else { contextPtr->meContextPtr->fractionalSearchModel = 2; - } + } return return_error; } /****************************************************** -* GetMv +* EbHevcGetMv Input : LCU Index Output : List0 MV ******************************************************/ -void GetMv( +void EbHevcGetMv( PictureParentControlSet_t *pictureControlSetPtr, EB_U32 lcuIndex, EB_S32 *xCurrentMv, @@ -440,11 +440,11 @@ void GetMv( } /****************************************************** -* GetMeDist +* EbHevcGetMeDist Input : LCU Index Output : Best ME Distortion ******************************************************/ -void GetMeDist( +void EbHevcGetMeDist( PictureParentControlSet_t *pictureControlSetPtr, EB_U32 lcuIndex, EB_U32 *distortion) @@ -510,9 +510,9 @@ static void StationaryEdgeOverUpdateOverTimeLcuPart1( if (lcuParams->potentialLogoLcu && lcuParams->isCompleteLcu) { - // Current MV + // Current MV if (pictureControlSetPtr->temporalLayerIndex > 0) - GetMv(pictureControlSetPtr, lcuIndex, &xCurrentMv, &yCurrentMv); + EbHevcGetMv(pictureControlSetPtr, lcuIndex, &xCurrentMv, &yCurrentMv); EB_BOOL lowMotion = pictureControlSetPtr->temporalLayerIndex == 0 ? EB_TRUE : (ABS(xCurrentMv) < 16) && (ABS(yCurrentMv) < 16) ? EB_TRUE : EB_FALSE; EB_U16 *yVariancePtr = pictureControlSetPtr->variance[lcuIndex]; @@ -558,36 +558,36 @@ static void StationaryEdgeOverUpdateOverTimeLcuPart2( LcuParams_t *lcuParams = &sequenceControlSetPtr->lcuParamsArray[lcuIndex]; LcuStat_t *lcuStatPtr = &pictureControlSetPtr->lcuStatArray[lcuIndex]; - + if (lcuParams->potentialLogoLcu && lcuParams->isCompleteLcu) { EB_U32 meDist = 0; - + EB_BOOL lowSad = EB_FALSE; - + if (pictureControlSetPtr->sliceType == EB_B_PICTURE) { - GetMeDist(pictureControlSetPtr, lcuIndex, &meDist); + EbHevcGetMeDist(pictureControlSetPtr, lcuIndex, &meDist); } lowSad = (pictureControlSetPtr->sliceType != EB_B_PICTURE) ? - + EB_FALSE : (meDist < 64 * 64 * lowSadTh) ? EB_TRUE : EB_FALSE; - + if (lowSad) { lcuStatPtr->check2ForLogoStationaryEdgeOverTimeFlag = 0; lcuStatPtr->lowDistLogo = 1; } else { lcuStatPtr->check2ForLogoStationaryEdgeOverTimeFlag = 1; - + lcuStatPtr->lowDistLogo = 0; } } else { lcuStatPtr->check2ForLogoStationaryEdgeOverTimeFlag = 0; - + lcuStatPtr->lowDistLogo = 0; } lcuStatPtr->check2ForLogoStationaryEdgeOverTimeFlag = 1; - + } /************************************************ @@ -677,7 +677,7 @@ void* MotionEstimationKernel(void *inputPtr) xLcuEndIndex = SEGMENT_END_IDX(xSegmentIndex, pictureWidthInLcu, pictureControlSetPtr->meSegmentsColumnCount); yLcuStartIndex = SEGMENT_START_IDX(ySegmentIndex, pictureHeightInLcu, pictureControlSetPtr->meSegmentsRowCount); yLcuEndIndex = SEGMENT_END_IDX(ySegmentIndex, pictureHeightInLcu, pictureControlSetPtr->meSegmentsRowCount); - // Increment the MD Rate Estimation array pointer to point to the right address based on the QP and slice type + // Increment the MD Rate Estimation array pointer to point to the right address based on the QP and slice type mdRateEstimationArray = (MdRateEstimationContext_t*)sequenceControlSetPtr->encodeContextPtr->mdRateEstimationArray; mdRateEstimationArray += pictureControlSetPtr->sliceType * TOTAL_NUMBER_OF_QP_VALUES + pictureControlSetPtr->pictureQp; // Reset MD rate Estimation table to initial values by copying from mdRateEstimationArray @@ -686,7 +686,7 @@ void* MotionEstimationKernel(void *inputPtr) SignalDerivationMeKernelOq( sequenceControlSetPtr, pictureControlSetPtr, - contextPtr); + contextPtr); // Lambda Assignement if (pictureControlSetPtr->temporalLayerIndex == 0) { @@ -830,7 +830,7 @@ void* MotionEstimationKernel(void *inputPtr) xLcuEndIndex, yLcuStartIndex, yLcuEndIndex); - + } } } @@ -849,14 +849,14 @@ void* MotionEstimationKernel(void *inputPtr) lcuWidth = (sequenceControlSetPtr->lumaWidth - lcuOriginX) < MAX_LCU_SIZE ? sequenceControlSetPtr->lumaWidth - lcuOriginX : MAX_LCU_SIZE; lcuHeight = (sequenceControlSetPtr->lumaHeight - lcuOriginY) < MAX_LCU_SIZE ? sequenceControlSetPtr->lumaHeight - lcuOriginY : MAX_LCU_SIZE; - lcuIndex = (EB_U16)(xLcuIndex + yLcuIndex * pictureWidthInLcu); + lcuIndex = (EB_U16)(xLcuIndex + yLcuIndex * pictureWidthInLcu); pictureControlSetPtr->interSadIntervalIndex[lcuIndex] = 0; pictureControlSetPtr->intraSadIntervalIndex[lcuIndex] = 0; if (lcuWidth == MAX_LCU_SIZE && lcuHeight == MAX_LCU_SIZE) { - sadIntervalIndex = (EB_U16)(pictureControlSetPtr->rcMEdistortion[lcuIndex] >> (12 - SAD_PRECISION_INTERVAL));//change 12 to 2*log2(64) + sadIntervalIndex = (EB_U16)(pictureControlSetPtr->rcMEdistortion[lcuIndex] >> (12 - SAD_PRECISION_INTERVAL));//change 12 to 2*log2(64) sadIntervalIndex = (EB_U16)(sadIntervalIndex >> 2); if (sadIntervalIndex > (NUMBER_OF_SAD_INTERVALS>>1) -1){ @@ -867,12 +867,12 @@ void* MotionEstimationKernel(void *inputPtr) } if (sadIntervalIndex >= NUMBER_OF_SAD_INTERVALS - 1) sadIntervalIndex = NUMBER_OF_SAD_INTERVALS - 1; - - - pictureControlSetPtr->interSadIntervalIndex[lcuIndex] = sadIntervalIndex; + + + pictureControlSetPtr->interSadIntervalIndex[lcuIndex] = sadIntervalIndex; pictureControlSetPtr->meDistortionHistogram[sadIntervalIndex] ++; - + EB_U32 bestOisCuIndex = 0; //DOUBLE CHECK THIS PIECE OF CODE @@ -892,9 +892,9 @@ void* MotionEstimationKernel(void *inputPtr) if (intraSadIntervalIndex >= NUMBER_OF_SAD_INTERVALS - 1) intraSadIntervalIndex = NUMBER_OF_SAD_INTERVALS - 1; - - pictureControlSetPtr->intraSadIntervalIndex[lcuIndex] = intraSadIntervalIndex; - pictureControlSetPtr->oisDistortionHistogram[intraSadIntervalIndex] ++; + + pictureControlSetPtr->intraSadIntervalIndex[lcuIndex] = intraSadIntervalIndex; + pictureControlSetPtr->oisDistortionHistogram[intraSadIntervalIndex] ++; @@ -917,7 +917,7 @@ void* MotionEstimationKernel(void *inputPtr) lcuHeight = (sequenceControlSetPtr->lumaHeight - lcuOriginY) < MAX_LCU_SIZE ? sequenceControlSetPtr->lumaHeight - lcuOriginY : MAX_LCU_SIZE; lcuIndex = (EB_U16)(xLcuIndex + yLcuIndex * pictureWidthInLcu); - + pictureControlSetPtr->interSadIntervalIndex[lcuIndex] = 0; pictureControlSetPtr->intraSadIntervalIndex[lcuIndex] = 0; @@ -925,13 +925,13 @@ void* MotionEstimationKernel(void *inputPtr) //DOUBLE CHECK THIS PIECE OF CODE - + intraSadIntervalIndex = (EB_U32) (((pictureControlSetPtr->oisCu32Cu16Results[lcuIndex]->sortedOisCandidate[1][bestOisCuIndex].distortion + pictureControlSetPtr->oisCu32Cu16Results[lcuIndex]->sortedOisCandidate[2][bestOisCuIndex].distortion + pictureControlSetPtr->oisCu32Cu16Results[lcuIndex]->sortedOisCandidate[3][bestOisCuIndex].distortion + pictureControlSetPtr->oisCu32Cu16Results[lcuIndex]->sortedOisCandidate[4][bestOisCuIndex].distortion)) >> (12 - SAD_PRECISION_INTERVAL));//change 12 to 2*log2(64) ; - + intraSadIntervalIndex = (EB_U16)(intraSadIntervalIndex >> 2); if (intraSadIntervalIndex > (NUMBER_OF_SAD_INTERVALS >> 1) - 1){ EB_U32 sadIntervalIndexTemp = intraSadIntervalIndex - ((NUMBER_OF_SAD_INTERVALS >> 1) - 1); diff --git a/Source/Lib/Codec/EbPacketizationProcess.c b/Source/Lib/Codec/EbPacketizationProcess.c index a2652e3ec..76074559b 100644 --- a/Source/Lib/Codec/EbPacketizationProcess.c +++ b/Source/Lib/Codec/EbPacketizationProcess.c @@ -103,13 +103,13 @@ EB_ERRORTYPE PacketizationContextCtor( PacketizationContext_t *contextPtr; EB_MALLOC(PacketizationContext_t*, contextPtr, sizeof(PacketizationContext_t), EB_N_PTR); *contextDblPtr = contextPtr; - + contextPtr->entropyCodingInputFifoPtr = entropyCodingInputFifoPtr; contextPtr->rateControlTasksOutputFifoPtr = rateControlTasksOutputFifoPtr; contextPtr->pictureManagerOutputFifoPtr = pictureManagerOutputFifoPtr; EB_MALLOC(EbPPSConfig_t*, contextPtr->ppsConfig, sizeof(EbPPSConfig_t), EB_N_PTR); - + return EB_ErrorNone; } @@ -117,15 +117,15 @@ void* PacketizationKernel(void *inputPtr) { // Context PacketizationContext_t *contextPtr = (PacketizationContext_t*) inputPtr; - + PictureControlSet_t *pictureControlSetPtr; - + // Config SequenceControlSet_t *sequenceControlSetPtr; - + // Encoding Context EncodeContext_t *encodeContextPtr; - + // Input EbObjectWrapper_t *entropyCodingResultsWrapperPtr; EntropyCodingResults_t *entropyCodingResultsPtr; @@ -139,7 +139,7 @@ void* PacketizationKernel(void *inputPtr) PictureDemuxResults_t *pictureManagerResultPtr; // Bitstream copy to output buffer Bitstream_t bitstream; - + // Queue variables EB_S32 queueEntryIndex; PacketizationReorderEntry_t *queueEntryPtr; @@ -148,9 +148,9 @@ void* PacketizationKernel(void *inputPtr) EB_U32 lcuWidth; EB_U32 intraSadIntervalIndex; EB_U32 sadIntervalIndex; - EB_U32 refQpIndex = 0; + EB_U32 refQpIndex = 0; EB_U32 packetizationQp; - + EB_U64 refDecOrder = 0; EB_U64 filler; EB_U32 fillerBytes; @@ -159,9 +159,9 @@ void* PacketizationKernel(void *inputPtr) EB_U16 tileCnt; EB_BOOL toInsertHeaders; - + for(;;) { - + // Get EntropyCoding Results EbGetFullObject( contextPtr->entropyCodingInputFifoPtr, @@ -171,7 +171,7 @@ void* PacketizationKernel(void *inputPtr) pictureControlSetPtr = (PictureControlSet_t*) entropyCodingResultsPtr->pictureControlSetWrapperPtr->objectPtr; sequenceControlSetPtr = (SequenceControlSet_t*) pictureControlSetPtr->sequenceControlSetWrapperPtr->objectPtr; encodeContextPtr = (EncodeContext_t*) sequenceControlSetPtr->encodeContextPtr; - tileCnt = pictureControlSetPtr->ParentPcsPtr->tileRowCount * pictureControlSetPtr->ParentPcsPtr->tileColumnCount; + tileCnt = pictureControlSetPtr->ParentPcsPtr->tileRowCount * pictureControlSetPtr->ParentPcsPtr->tileColumnCount; #if DEADLOCK_DEBUG SVT_LOG("POC %lld PK IN \n", pictureControlSetPtr->pictureNumber); #endif @@ -179,27 +179,27 @@ void* PacketizationKernel(void *inputPtr) //**************************************************** // Input Entropy Results into Reordering Queue //**************************************************** - + //get a new entry spot - queueEntryIndex = pictureControlSetPtr->ParentPcsPtr->decodeOrder % PACKETIZATION_REORDER_QUEUE_MAX_DEPTH; + queueEntryIndex = pictureControlSetPtr->ParentPcsPtr->decodeOrder % PACKETIZATION_REORDER_QUEUE_MAX_DEPTH; queueEntryPtr = encodeContextPtr->packetizationReorderQueue[queueEntryIndex]; queueEntryPtr->startTimeSeconds = pictureControlSetPtr->ParentPcsPtr->startTimeSeconds; queueEntryPtr->startTimeuSeconds = pictureControlSetPtr->ParentPcsPtr->startTimeuSeconds; queueEntryPtr->isUsedAsReferenceFlag = pictureControlSetPtr->ParentPcsPtr->isUsedAsReferenceFlag; queueEntryPtr->sliceType = pictureControlSetPtr->sliceType; - //TODO: buffer should be big enough to avoid a deadlock here. Add an assert that make the warning + //TODO: buffer should be big enough to avoid a deadlock here. Add an assert that make the warning // Get Output Bitstream buffer outputStreamWrapperPtr = pictureControlSetPtr->ParentPcsPtr->outputStreamWrapperPtr; outputStreamPtr = (EB_BUFFERHEADERTYPE*) outputStreamWrapperPtr->objectPtr; - outputStreamPtr->nFlags = 0; + outputStreamPtr->nFlags = 0; EbBlockOnMutex(encodeContextPtr->terminatingConditionsMutex); outputStreamPtr->nFlags |= (encodeContextPtr->terminatingSequenceFlagReceived == EB_TRUE && pictureControlSetPtr->ParentPcsPtr->decodeOrder == encodeContextPtr->terminatingPictureNumber) ? EB_BUFFERFLAG_EOS : 0; EbReleaseMutex(encodeContextPtr->terminatingConditionsMutex); outputStreamPtr->nFilledLen = 0; outputStreamPtr->pts = pictureControlSetPtr->ParentPcsPtr->ebInputPtr->pts; outputStreamPtr->dts = pictureControlSetPtr->ParentPcsPtr->decodeOrder - (EB_U64)(1 << sequenceControlSetPtr->staticConfig.hierarchicalLevels) + 1; - outputStreamPtr->sliceType = pictureControlSetPtr->ParentPcsPtr->isUsedAsReferenceFlag ? + outputStreamPtr->sliceType = pictureControlSetPtr->ParentPcsPtr->isUsedAsReferenceFlag ? pictureControlSetPtr->ParentPcsPtr->idrFlag ? EB_IDR_PICTURE : pictureControlSetPtr->sliceType : EB_NON_REF_PICTURE; @@ -208,7 +208,7 @@ void* PacketizationKernel(void *inputPtr) EbGetEmptyObject( contextPtr->rateControlTasksOutputFifoPtr, &rateControlTasksWrapperPtr); - rateControlTasksPtr = (RateControlTasks_t*) rateControlTasksWrapperPtr->objectPtr; + rateControlTasksPtr = (RateControlTasks_t*) rateControlTasksWrapperPtr->objectPtr; rateControlTasksPtr->pictureControlSetWrapperPtr = pictureControlSetPtr->PictureParentControlSetWrapperPtr; rateControlTasksPtr->taskType = RC_PACKETIZATION_FEEDBACK_RESULT; @@ -279,8 +279,8 @@ void* PacketizationKernel(void *inputPtr) EncodeSPS( pictureControlSetPtr->bitstreamPtr, sequenceControlSetPtr); - - // Code the PPS + + // Code the PPS // *Note - when tiles are enabled, we send a separate PPS for each // temporal layer since Tiles vary across temporal layers @@ -328,7 +328,7 @@ void* PacketizationKernel(void *inputPtr) // Flush the Bitstream FlushBitstream( pictureControlSetPtr->bitstreamPtr->outputBitstreamPtr); - + // Copy SPS & PPS to the Output Bitstream CopyRbspBitstreamToPayload( pictureControlSetPtr->bitstreamPtr, @@ -338,8 +338,8 @@ void* PacketizationKernel(void *inputPtr) encodeContextPtr, NAL_UNIT_INVALID); } - - + + // Bitstream Written Loop // This loop writes the result of entropy coding into the bitstream { @@ -356,11 +356,11 @@ void* PacketizationKernel(void *inputPtr) EB_U32 count[NUMBER_OF_SAD_INTERVALS] = {0}; sequenceControlSetPtr->encodeContextPtr->rateControlTablesArrayUpdated = EB_TRUE; - + for(lcuCodingOrder = 0; lcuCodingOrder < lcuTotalCount; ++lcuCodingOrder) { - lcuPtr = pictureControlSetPtr->lcuPtrArray[lcuCodingOrder]; - + lcuPtr = pictureControlSetPtr->lcuPtrArray[lcuCodingOrder]; + // updating initial rate control tables based on the bits used for encoding LCUs lcuWidth = (sequenceControlSetPtr->lumaWidth - lcuPtr->originX >= (EB_U16)MAX_LCU_SIZE) ? lcuPtr->size : sequenceControlSetPtr->lumaWidth - lcuPtr->originX; @@ -372,12 +372,12 @@ void* PacketizationKernel(void *inputPtr) if (( lcuWidth == MAX_LCU_SIZE) && (lcuHeight == MAX_LCU_SIZE)){ if(pictureControlSetPtr->sliceType == EB_I_PICTURE){ - + intraSadIntervalIndex = pictureControlSetPtr->ParentPcsPtr->intraSadIntervalIndex[lcuCodingOrder]; sadBits[intraSadIntervalIndex] += lcuPtr->totalBits; count[intraSadIntervalIndex] ++; - + } else{ sadIntervalIndex = pictureControlSetPtr->ParentPcsPtr->interSadIntervalIndex[lcuCodingOrder]; @@ -435,7 +435,7 @@ void* PacketizationKernel(void *inputPtr) if(count[sadIntervalIndex]> (10*64*64/blkSize/blkSize) ){ sadBits[sadIntervalIndex] /= count[sadIntervalIndex]; for(qpIndex = sequenceControlSetPtr->staticConfig.minQpAllowed; qpIndex <= (EB_S32)sequenceControlSetPtr->staticConfig.maxQpAllowed; qpIndex++){ - encodeContextPtr->rateControlTablesArray[qpIndex].intraSadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = + encodeContextPtr->rateControlTablesArray[qpIndex].intraSadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = (EB_Bit_Number)(((( 8*sadBits[sadIntervalIndex]* TWO_TO_POWER_X_OVER_SIX[(EB_S32)refQpIndex-qpIndex+51] +(1<15))>>16) + 2*(EB_U32)encodeContextPtr->rateControlTablesArray[qpIndex].intraSadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] +5)/10); encodeContextPtr->rateControlTablesArray[qpIndex].intraSadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = @@ -496,7 +496,7 @@ void* PacketizationKernel(void *inputPtr) MIN((EB_U16)encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex], (EB_U16)((1 << 15) - 1)); } - } + } else if ((sadIntervalIndex > ((NUMBER_OF_SAD_INTERVALS >> 1) - 1) && count[sadIntervalIndex] > (1 * 64 * 64 / blkSize / blkSize)) || (count[sadIntervalIndex] == (1 * 64 * 64 / blkSize / blkSize))){ sadBits[sadIntervalIndex] /= count[sadIntervalIndex]; @@ -517,11 +517,11 @@ void* PacketizationKernel(void *inputPtr) if(count[sadIntervalIndex]> (10*64*64/blkSize/blkSize) ){ sadBits[sadIntervalIndex] /= count[sadIntervalIndex]; for(qpIndex = sequenceControlSetPtr->staticConfig.minQpAllowed; qpIndex <= (EB_S32)sequenceControlSetPtr->staticConfig.maxQpAllowed; qpIndex++){ - encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = + encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = (EB_Bit_Number)(((( 7*sadBits[sadIntervalIndex]* TWO_TO_POWER_X_OVER_SIX[(EB_S32)refQpIndex-qpIndex+51] +(1<15))>>16) + 3*(EB_U32)encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] +5)/10); // intrinsics used in initial RC are assuming signed 16 bits is the maximum - encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = + encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = MIN((EB_U16)encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex], (EB_U16)((1<<15)-1)); } @@ -529,11 +529,11 @@ void* PacketizationKernel(void *inputPtr) else if(count[sadIntervalIndex]>(5*64*64/blkSize/blkSize)){ sadBits[sadIntervalIndex] /= count[sadIntervalIndex]; for(qpIndex = sequenceControlSetPtr->staticConfig.minQpAllowed; qpIndex <= (EB_S32)sequenceControlSetPtr->staticConfig.maxQpAllowed; qpIndex++){ - encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = + encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = (EB_Bit_Number)(((( 5*sadBits[sadIntervalIndex]* TWO_TO_POWER_X_OVER_SIX[(EB_S32)refQpIndex-qpIndex+51] +(1<15))>>16) + 5*(EB_U32)encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] +5)/10); // intrinsics used in initial RC are assuming signed 16 bits is the maximum - encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = + encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = MIN((EB_U16)encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex], (EB_U16)((1<<15)-1)); } @@ -542,12 +542,12 @@ void* PacketizationKernel(void *inputPtr) sadBits[sadIntervalIndex] /= count[sadIntervalIndex]; for(qpIndex = sequenceControlSetPtr->staticConfig.minQpAllowed; qpIndex <= (EB_S32)sequenceControlSetPtr->staticConfig.maxQpAllowed; qpIndex++){ - encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = + encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = (EB_Bit_Number)(((( 1*sadBits[sadIntervalIndex]* TWO_TO_POWER_X_OVER_SIX[(EB_S32)refQpIndex-qpIndex+51] +(1<15))>>16) + 9*(EB_U32)encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] +5)/10); // intrinsics used in initial RC are assuming signed 16 bits is the maximum - encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = + encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex] = MIN((EB_U16)encodeContextPtr->rateControlTablesArray[qpIndex].sadBitsArray[pictureControlSetPtr->temporalLayerIndex][sadIntervalIndex], (EB_U16)((1<<15)-1)); } } @@ -568,8 +568,8 @@ void* PacketizationKernel(void *inputPtr) // Encode slice header and write it into the bitstream. packetizationQp = pictureControlSetPtr->pictureQp; - - if(sequenceControlSetPtr->staticConfig.accessUnitDelimiter && (pictureControlSetPtr->pictureNumber > 0)) + + if(sequenceControlSetPtr->staticConfig.accessUnitDelimiter && (pictureControlSetPtr->pictureNumber > 0)) { EncodeAUD( pictureControlSetPtr->bitstreamPtr, @@ -579,10 +579,10 @@ void* PacketizationKernel(void *inputPtr) // Parsing the linked list and find the user data SEI msgs and code them sequenceControlSetPtr->picTimingSei.picStruct = 0; - if( sequenceControlSetPtr->staticConfig.bufferingPeriodSEI && - pictureControlSetPtr->sliceType == EB_I_PICTURE && + if( sequenceControlSetPtr->staticConfig.bufferingPeriodSEI && + pictureControlSetPtr->sliceType == EB_I_PICTURE && sequenceControlSetPtr->staticConfig.videoUsabilityInfo && - (sequenceControlSetPtr->videoUsabilityInfoPtr->hrdParametersPtr->nalHrdParametersPresentFlag || sequenceControlSetPtr->videoUsabilityInfoPtr->hrdParametersPtr->vclHrdParametersPresentFlag)) + (sequenceControlSetPtr->videoUsabilityInfoPtr->hrdParametersPtr->nalHrdParametersPresentFlag || sequenceControlSetPtr->videoUsabilityInfoPtr->hrdParametersPtr->vclHrdParametersPresentFlag)) { //Calculating the hrdfullness based on the vbv buffer fill status if (sequenceControlSetPtr->staticConfig.hrdFlag == 1) @@ -593,7 +593,7 @@ void* PacketizationKernel(void *inputPtr) pictureControlSetPtr->bitstreamPtr, &sequenceControlSetPtr->bufferingPeriod, sequenceControlSetPtr->videoUsabilityInfoPtr, - sequenceControlSetPtr->encodeContextPtr); + sequenceControlSetPtr->encodeContextPtr); } // Flush the Bitstream @@ -664,7 +664,7 @@ void* PacketizationKernel(void *inputPtr) // Flush the Bitstream FlushBitstream( - pictureControlSetPtr->bitstreamPtr->outputBitstreamPtr); + pictureControlSetPtr->bitstreamPtr->outputBitstreamPtr); // Copy Slice Header to the Output Bitstream CopyRbspBitstreamToPayload( @@ -711,9 +711,9 @@ void* PacketizationKernel(void *inputPtr) } } - + // Send the number of bytes per frame to RC - pictureControlSetPtr->ParentPcsPtr->totalNumBits = outputStreamPtr->nFilledLen << 3; + pictureControlSetPtr->ParentPcsPtr->totalNumBits = outputStreamPtr->nFilledLen << 3; queueEntryPtr->actualBits = pictureControlSetPtr->ParentPcsPtr->totalNumBits; pictureControlSetPtr->ParentPcsPtr->totalNumBits += queueEntryPtr->fillerBitsSent; @@ -741,7 +741,7 @@ void* PacketizationKernel(void *inputPtr) } // Code EOS NUT - if (outputStreamPtr->nFlags & EB_BUFFERFLAG_EOS && sequenceControlSetPtr->staticConfig.codeEosNal == 1) + if (outputStreamPtr->nFlags & EB_BUFFERFLAG_EOS && sequenceControlSetPtr->staticConfig.codeEosNal == 1) { // Reset the bitstream ResetBitstream(pictureControlSetPtr->bitstreamPtr->outputBitstreamPtr); @@ -760,9 +760,9 @@ void* PacketizationKernel(void *inputPtr) ((SequenceControlSet_t*)(pictureControlSetPtr->sequenceControlSetWrapperPtr->objectPtr))->encodeContextPtr, NAL_UNIT_INVALID); } - + //Store the buffer in the Queue - queueEntryPtr->outputStreamWrapperPtr = outputStreamWrapperPtr; + queueEntryPtr->outputStreamWrapperPtr = outputStreamWrapperPtr; if (sequenceControlSetPtr->staticConfig.speedControlFlag){ // update speed control variables @@ -771,8 +771,8 @@ void* PacketizationKernel(void *inputPtr) EbReleaseMutex(encodeContextPtr->scBufferMutex); } - // Post Rate Control Taks - EbPostFullObject(rateControlTasksWrapperPtr); + // Post Rate Control Taks + EbPostFullObject(rateControlTasksWrapperPtr); if (sequenceControlSetPtr->staticConfig.rateControlMode) { // Post the Full Results Object @@ -787,7 +787,7 @@ void* PacketizationKernel(void *inputPtr) //**************************************************** // Process the head of the queue - //**************************************************** + //**************************************************** // Look at head of queue and see if any picture is ready to go queueEntryPtr = encodeContextPtr->packetizationReorderQueue[encodeContextPtr->packetizationReorderQueueHeadIndex]; @@ -803,9 +803,9 @@ void* PacketizationKernel(void *inputPtr) EB_U32 bufferWrittenBytesCount = 0; EB_U32 startinBytes = 0; EB_U32 totalBytes = 0; - EbFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); + EbHevcFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); - EbComputeOverallElapsedTimeMs( + EbHevcComputeOverallElapsedTimeMs( queueEntryPtr->startTimeSeconds, queueEntryPtr->startTimeuSeconds, finishTimeSeconds, @@ -867,7 +867,7 @@ void* PacketizationKernel(void *inputPtr) } /* update VBV plan */ if (encodeContextPtr->vbvMaxrate && encodeContextPtr->vbvBufsize) - { + { EbBlockOnMutex(encodeContextPtr->bufferFillMutex); EB_S64 bufferfill_temp = (EB_S64)(encodeContextPtr->bufferFill); bufferfill_temp -= queueEntryPtr->actualBits; @@ -949,20 +949,20 @@ void* PacketizationKernel(void *inputPtr) } EbPostFullObject(outputStreamWrapperPtr); // Reset the Reorder Queue Entry - queueEntryPtr->pictureNumber += PACKETIZATION_REORDER_QUEUE_MAX_DEPTH; + queueEntryPtr->pictureNumber += PACKETIZATION_REORDER_QUEUE_MAX_DEPTH; queueEntryPtr->outputStreamWrapperPtr = (EbObjectWrapper_t *)EB_NULL; // Increment the Reorder Queue head Ptr - encodeContextPtr->packetizationReorderQueueHeadIndex = + encodeContextPtr->packetizationReorderQueueHeadIndex = (encodeContextPtr->packetizationReorderQueueHeadIndex == PACKETIZATION_REORDER_QUEUE_MAX_DEPTH - 1) ? 0 : encodeContextPtr->packetizationReorderQueueHeadIndex + 1; - + queueEntryPtr = encodeContextPtr->packetizationReorderQueue[encodeContextPtr->packetizationReorderQueueHeadIndex]; - + } #if DEADLOCK_DEBUG SVT_LOG("POC %lld PK OUT \n", pictureControlSetPtr->pictureNumber); -#endif +#endif } return EB_NULL; } diff --git a/Source/Lib/Codec/EbPictureAnalysisProcess.c b/Source/Lib/Codec/EbPictureAnalysisProcess.c index fe1827962..7ca083c0c 100644 --- a/Source/Lib/Codec/EbPictureAnalysisProcess.c +++ b/Source/Lib/Codec/EbPictureAnalysisProcess.c @@ -179,10 +179,10 @@ void Decimation2D( EB_U8 * inputSamples, // input parameter, input samples Ptr EB_U32 inputStride, // input parameter, input stride EB_U32 inputAreaWidth, // input parameter, input area width - EB_U32 inputAreaHeight, // input parameter, input area height + EB_U32 inputAreaHeight, // input parameter, input area height EB_U8 * decimSamples, // output parameter, decimated samples Ptr EB_U32 decimStride, // input parameter, output stride - EB_U32 decimStep) // input parameter, area height + EB_U32 decimStep) // input parameter, area height { EB_U32 horizontalIndex; @@ -209,9 +209,9 @@ void Decimation2D( static void CalculateHistogram( EB_U8 * inputSamples, // input parameter, input samples Ptr EB_U32 inputAreaWidth, // input parameter, input area width - EB_U32 inputAreaHeight, // input parameter, input area height + EB_U32 inputAreaHeight, // input parameter, input area height EB_U32 stride, // input parameter, input stride - EB_U8 decimStep, // input parameter, area height + EB_U8 decimStep, // input parameter, area height EB_U32 *histogram, // output parameter, output histogram EB_U64 *sum) @@ -234,7 +234,7 @@ static void CalculateHistogram( static EB_U64 ComputeVariance32x32( - EbPictureBufferDesc_t *inputPaddedPicturePtr, // input parameter, Input Padded Picture + EbPictureBufferDesc_t *inputPaddedPicturePtr, // input parameter, Input Padded Picture EB_U32 inputLumaOriginIndex, // input parameter, LCU index, used to point to source/reference samples EB_U64 *variance8x8) { @@ -271,7 +271,7 @@ static EB_U64 ComputeVariance32x32( meanOf8x8Blocks[3] = ComputeMeanFunc[0][!!(ASM_TYPES & AVX2_MASK)](&(inputPaddedPicturePtr->bufferY[blockIndex]), inputPaddedPicturePtr->strideY, 8, 8); meanOf8x8SquaredValuesBlocks[3] = ComputeMeanFunc[1][!!(ASM_TYPES & AVX2_MASK)](&(inputPaddedPicturePtr->bufferY[blockIndex]), inputPaddedPicturePtr->strideY, 8, 8); - + // (1,0) blockIndex = inputLumaOriginIndex + (inputPaddedPicturePtr->strideY << 3); @@ -293,7 +293,7 @@ static EB_U64 ComputeVariance32x32( meanOf8x8Blocks[7] = ComputeMeanFunc[0][!!(ASM_TYPES & AVX2_MASK)](&(inputPaddedPicturePtr->bufferY[blockIndex]), inputPaddedPicturePtr->strideY, 8, 8); meanOf8x8SquaredValuesBlocks[7] = ComputeMeanFunc[1][!!(ASM_TYPES & AVX2_MASK)](&(inputPaddedPicturePtr->bufferY[blockIndex]), inputPaddedPicturePtr->strideY, 8, 8); - + // (2,0) blockIndex = inputLumaOriginIndex + (inputPaddedPicturePtr->strideY << 4); @@ -315,7 +315,7 @@ static EB_U64 ComputeVariance32x32( meanOf8x8Blocks[11] = ComputeMeanFunc[0][!!(ASM_TYPES & AVX2_MASK)](&(inputPaddedPicturePtr->bufferY[blockIndex]), inputPaddedPicturePtr->strideY, 8, 8); meanOf8x8SquaredValuesBlocks[11] = ComputeMeanFunc[1][!!(ASM_TYPES & AVX2_MASK)](&(inputPaddedPicturePtr->bufferY[blockIndex]), inputPaddedPicturePtr->strideY, 8, 8); - + // (3,0) blockIndex = inputLumaOriginIndex + (inputPaddedPicturePtr->strideY << 3) + (inputPaddedPicturePtr->strideY << 4); @@ -363,7 +363,7 @@ static EB_U64 ComputeVariance32x32( meanOf16x16Blocks[2] = (meanOf8x8Blocks[4] + meanOf8x8Blocks[5] + meanOf8x8Blocks[12] + meanOf8x8Blocks[13]) >> 2; meanOf16x16Blocks[3] = (meanOf8x8Blocks[6] + meanOf8x8Blocks[7] + meanOf8x8Blocks[14] + meanOf8x8Blocks[15]) >> 2; - + meanOf16x16SquaredValuesBlocks[0] = (meanOf8x8SquaredValuesBlocks[0] + meanOf8x8SquaredValuesBlocks[1] + meanOf8x8SquaredValuesBlocks[8] + meanOf8x8SquaredValuesBlocks[9]) >> 2; meanOf16x16SquaredValuesBlocks[1] = (meanOf8x8SquaredValuesBlocks[2] + meanOf8x8SquaredValuesBlocks[3] + meanOf8x8SquaredValuesBlocks[10] + meanOf8x8SquaredValuesBlocks[11]) >> 2; meanOf16x16SquaredValuesBlocks[2] = (meanOf8x8SquaredValuesBlocks[4] + meanOf8x8SquaredValuesBlocks[5] + meanOf8x8SquaredValuesBlocks[12] + meanOf8x8SquaredValuesBlocks[13]) >> 2; @@ -371,16 +371,16 @@ static EB_U64 ComputeVariance32x32( // 32x32 meanOf32x32Blocks = (meanOf16x16Blocks[0] + meanOf16x16Blocks[1] + meanOf16x16Blocks[2] + meanOf16x16Blocks[3]) >> 2; - + meanOf32x32SquaredValuesBlocks = (meanOf16x16SquaredValuesBlocks[0] + meanOf16x16SquaredValuesBlocks[1] + meanOf16x16SquaredValuesBlocks[2] + meanOf16x16SquaredValuesBlocks[3]) >> 2; - + return (meanOf32x32SquaredValuesBlocks - (meanOf32x32Blocks * meanOf32x32Blocks)); } static EB_U64 ComputeVariance16x16( - EbPictureBufferDesc_t *inputPaddedPicturePtr, // input parameter, Input Padded Picture + EbPictureBufferDesc_t *inputPaddedPicturePtr, // input parameter, Input Padded Picture EB_U32 inputLumaOriginIndex, // input parameter, LCU index, used to point to source/reference samples EB_U64 *variance8x8) { @@ -434,7 +434,7 @@ does not store data for every block, just returns the 64x64 data point *******************************************/ static EB_U64 ComputeVariance64x64( - EbPictureBufferDesc_t *inputPaddedPicturePtr, // input parameter, Input Padded Picture + EbPictureBufferDesc_t *inputPaddedPicturePtr, // input parameter, Input Padded Picture EB_U32 inputLumaOriginIndex, // input parameter, LCU index, used to point to source/reference samples EB_U64 *variance32x32) { @@ -877,8 +877,8 @@ static EB_U64 ComputeVariance64x64( blockIndex = blockIndex + 8; meanOf8x8Blocks[63] = ComputeSubMean8x8_SSE2_INTRIN(&(inputPaddedPicturePtr->bufferY[blockIndex]), strideY); meanOf8x8SquaredValuesBlocks[63] = ComputeSubdMeanOfSquaredValues8x8_SSE2_INTRIN(&(inputPaddedPicturePtr->bufferY[blockIndex]), strideY); - - + + } @@ -952,13 +952,13 @@ static EB_U64 ComputeVariance64x64( static EB_U8 getFilteredTypes(EB_U8 *ptr, EB_U32 stride, - EB_U8 filterType) + EB_U8 EbHevcfilterType) { EB_U8 *p = ptr - 1 - stride; EB_U32 a = 0; - if (filterType == 0){ + if (EbHevcfilterType == 0){ //Luma a = (p[1] + @@ -966,24 +966,24 @@ static EB_U8 getFilteredTypes(EB_U8 *ptr, p[1 + 2 * stride]) / 8; } - else if (filterType == 1){ + else if (EbHevcfilterType == 1){ a = ( 2 * p[1] + 2 * p[0 + stride] + 4 * p[1 + stride] + 2 * p[2 + stride] + - 2 * p[1 + 2 * stride] ); - + 2 * p[1 + 2 * stride] ); + a = (( (EB_U32)((a *2730) >> 14) + 1) >> 1) & 0xFFFF; //fixed point version of a=a/12 to mimic x86 instruction _mm256_mulhrs_epi16; //a= (a*2730)>>15; } - else if (filterType == 2){ + else if (EbHevcfilterType == 2){ a = (4 * p[1] + 4 * p[0 + stride] + 4 * p[1 + stride] + 4 * p[2 + stride] + 4 * p[1 + 2 * stride]) / 20; } - else if (filterType == 3){ + else if (EbHevcfilterType == 3){ a = (1 * p[0] + 1 * p[1] + 1 * p[2] + 1 * p[0 + stride] + 4 * p[1 + stride] + 1 * p[2 + stride] + @@ -991,7 +991,7 @@ static EB_U8 getFilteredTypes(EB_U8 *ptr, } - else if (filterType == 4){ + else if (EbHevcfilterType == 4){ //gaussian matrix(Chroma) a = (1 * p[0] + 2 * p[1] + 1 * p[2] + @@ -999,14 +999,14 @@ static EB_U8 getFilteredTypes(EB_U8 *ptr, 1 * p[0 + 2 * stride] + 2 * p[1 + 2 * stride] + 1 * p[2 + 2 * stride]) / 16; } - else if (filterType == 5){ + else if (EbHevcfilterType == 5){ a = (2 * p[0] + 2 * p[1] + 2 * p[2] + 2 * p[0 + stride] + 4 * p[1 + stride] + 2 * p[2 + stride] + 2 * p[0 + 2 * stride] + 2 * p[1 + 2 * stride] + 2 * p[2 + 2 * stride]) / 20; } - else if (filterType == 6){ + else if (EbHevcfilterType == 6){ a = (4 * p[0] + 4 * p[1] + 4 * p[2] + 4 * p[0 + stride] + 4 * p[1 + stride] + 4 * p[2 + stride] + @@ -1392,7 +1392,7 @@ static EB_ERRORTYPE ZeroOutChromaBlockMean( { EB_ERRORTYPE return_error = EB_ErrorNone; - // 16x16 mean + // 16x16 mean pictureControlSetPtr->cbMean[lcuCodingOrder][ME_TIER_ZERO_PU_16x16_0] = 0; pictureControlSetPtr->cbMean[lcuCodingOrder][ME_TIER_ZERO_PU_16x16_1] = 0; pictureControlSetPtr->cbMean[lcuCodingOrder][ME_TIER_ZERO_PU_16x16_2] = 0; @@ -1590,7 +1590,7 @@ static EB_ERRORTYPE ComputeChromaBlockMean( // 64x64 cbMeanOf64x64Blocks = (cbMeanOf32x32Blocks[0] + cbMeanOf32x32Blocks[1] + cbMeanOf32x32Blocks[3] + cbMeanOf32x32Blocks[3]) >> 2; crMeanOf64x64Blocks = (crMeanOf32x32Blocks[0] + crMeanOf32x32Blocks[1] + crMeanOf32x32Blocks[3] + crMeanOf32x32Blocks[3]) >> 2; - // 16x16 mean + // 16x16 mean pictureControlSetPtr->cbMean[lcuCodingOrder][ME_TIER_ZERO_PU_16x16_0] = (EB_U8) (cbMeanOf16x16Blocks[0] >> MEAN_PRECISION); pictureControlSetPtr->cbMean[lcuCodingOrder][ME_TIER_ZERO_PU_16x16_1] = (EB_U8) (cbMeanOf16x16Blocks[1] >> MEAN_PRECISION); pictureControlSetPtr->cbMean[lcuCodingOrder][ME_TIER_ZERO_PU_16x16_2] = (EB_U8) (cbMeanOf16x16Blocks[2] >> MEAN_PRECISION); @@ -1787,7 +1787,7 @@ static EB_ERRORTYPE ComputeBlockMeanComputeVariance( ComputeIntermVarFour8x8_AVX2_INTRIN(&(inputPaddedPicturePtr->bufferY[blockIndex]), strideY, &meanOf8x8Blocks[60], &meanOf8x8SquaredValuesBlocks[60]); - + } else{ meanOf8x8Blocks[0] = ComputeSubMean8x8_SSE2_INTRIN(&(inputPaddedPicturePtr->bufferY[blockIndex]), strideY); @@ -2232,7 +2232,7 @@ static EB_ERRORTYPE ComputeBlockMeanComputeVariance( pictureControlSetPtr->yMean[lcuIndex][ME_TIER_ZERO_PU_8x8_62] = (EB_U8)(meanOf8x8Blocks[62] >> MEAN_PRECISION); pictureControlSetPtr->yMean[lcuIndex][ME_TIER_ZERO_PU_8x8_63] = (EB_U8)(meanOf8x8Blocks[63] >> MEAN_PRECISION); - // 16x16 mean + // 16x16 mean pictureControlSetPtr->yMean[lcuIndex][ME_TIER_ZERO_PU_16x16_0] = (EB_U8)(meanOf16x16Blocks[0] >> MEAN_PRECISION); pictureControlSetPtr->yMean[lcuIndex][ME_TIER_ZERO_PU_16x16_1] = (EB_U8)(meanOf16x16Blocks[1] >> MEAN_PRECISION); pictureControlSetPtr->yMean[lcuIndex][ME_TIER_ZERO_PU_16x16_2] = (EB_U8)(meanOf16x16Blocks[2] >> MEAN_PRECISION); @@ -2371,7 +2371,7 @@ static EB_ERRORTYPE DenoiseInputPicture( EB_U32 colorFormat = inputPicturePtr->colorFormat; EB_U16 subWidthCMinus1 = (colorFormat == EB_YUV444 ? 1 : 2) - 1; EB_U16 subHeightCMinus1 = (colorFormat >= EB_YUV422 ? 1 : 2) - 1; - //use denoised input if the source is extremly noisy + //use denoised input if the source is extremly noisy if (pictureControlSetPtr->picNoiseClass >= PIC_NOISE_CLASS_4){ EB_U32 inLumaOffSet = inputPicturePtr->originX + inputPicturePtr->originY * inputPicturePtr->strideY; @@ -2596,12 +2596,12 @@ static EB_ERRORTYPE DetectInputPictureNoise( } //do it only for complete 64x64 blocks - if (lcuParams->isCompleteLcu) + if (lcuParams->isCompleteLcu) { EB_U64 noiseBlkVar32x32[4], denoiseBlkVar32x32[4]; - EB_U64 noiseBlkVar = ComputeVariance64x64( + EB_U64 noiseBlkVar = ComputeVariance64x64( noisePicturePtr, noiseOriginIndex, noiseBlkVar32x32); @@ -2616,7 +2616,7 @@ static EB_ERRORTYPE DetectInputPictureNoise( picNoiseVariance += (noiseBlkVar >> 16); - EB_U64 denBlkVar = ComputeVariance64x64( + EB_U64 denBlkVar = ComputeVariance64x64( denoisedPicturePtr, inputLumaOriginIndex, denoiseBlkVar32x32) >> 16; @@ -2817,7 +2817,7 @@ static EB_ERRORTYPE SubSampleFilterNoise( EB_U32 newTotFN = 0; - //for each LCU ,re check the FN information for only the FNdecim ones + //for each LCU ,re check the FN information for only the FNdecim ones for (lcuIndex = 0; lcuIndex < pictureControlSetPtr->lcuTotalCount; ++lcuIndex) { LcuParams_t *lcuParams = &sequenceControlSetPtr->lcuParamsArray[lcuIndex]; @@ -2850,7 +2850,7 @@ static EB_ERRORTYPE SubSampleFilterNoise( EB_U64 noiseBlkVar32x32[4], denoiseBlkVar32x32[4]; EB_U64 noiseBlkVar = ComputeVariance64x64( noisePicturePtr, noiseOriginIndex, noiseBlkVar32x32); - EB_U64 denBlkVar = ComputeVariance64x64( + EB_U64 denBlkVar = ComputeVariance64x64( denoisedPicturePtr, inputLumaOriginIndex, denoiseBlkVar32x32) >> 16; EB_U64 noiseBlkVarTh ; @@ -3036,9 +3036,9 @@ static EB_ERRORTYPE QuarterSampleDetectNoise( //else noiseTh = 0; - //look for extreme noise or big enough flat noisy area to be denoised. + //look for extreme noise or big enough flat noisy area to be denoised. if (picNoiseVariance > 60) - pictureControlSetPtr->picNoiseClass = PIC_NOISE_CLASS_3_1; //Noise+Edge information is too big, so may be this is all noise (action: frame based denoising) + pictureControlSetPtr->picNoiseClass = PIC_NOISE_CLASS_3_1; //Noise+Edge information is too big, so may be this is all noise (action: frame based denoising) else if (picNoiseVariance >= 10 + noiseTh) pictureControlSetPtr->picNoiseClass = PIC_NOISE_CLASS_3; //Noise+Edge information is big enough, so there is no big enough flat noisy area (action : no denoising) else if (picNoiseVariance >= 5 + noiseTh) @@ -3047,7 +3047,7 @@ static EB_ERRORTYPE QuarterSampleDetectNoise( pictureControlSetPtr->picNoiseClass = PIC_NOISE_CLASS_1; //Noise+Edge information is very small, so no noise nor edge area (action : no denoising) - + return return_error; } @@ -3180,9 +3180,9 @@ static EB_ERRORTYPE SubSampleDetectNoise( else noiseTh = 0; - //look for extreme noise or big enough flat noisy area to be denoised. + //look for extreme noise or big enough flat noisy area to be denoised. if (picNoiseVariance >= 55 + noiseTh) - pictureControlSetPtr->picNoiseClass = PIC_NOISE_CLASS_3_1; //Noise+Edge information is too big, so may be this is all noise (action: frame based denoising) + pictureControlSetPtr->picNoiseClass = PIC_NOISE_CLASS_3_1; //Noise+Edge information is too big, so may be this is all noise (action: frame based denoising) else if (picNoiseVariance >= 10 + noiseTh) pictureControlSetPtr->picNoiseClass = PIC_NOISE_CLASS_3; //Noise+Edge information is big enough, so there is no big enough flat noisy area (action : no denoising) else if (picNoiseVariance >= 5 + noiseTh) @@ -3237,7 +3237,7 @@ static EB_ERRORTYPE QuarterSampleDenoise( pictureWidthInLcu); if (denoiseFlag == EB_TRUE) { - + // Turn OFF the de-noiser for Class 2 at QP=29 and lower (for Fixed_QP) and at the target rate of 14Mbps and higher (for RC=ON) if ((pictureControlSetPtr->picNoiseClass == PIC_NOISE_CLASS_3_1) || ((pictureControlSetPtr->picNoiseClass == PIC_NOISE_CLASS_2) && ((sequenceControlSetPtr->staticConfig.rateControlMode == 0 && sequenceControlSetPtr->qp > DENOISER_QP_TH) || (sequenceControlSetPtr->staticConfig.rateControlMode != 0 && sequenceControlSetPtr->staticConfig.targetBitRate < DENOISER_BITRATE_TH)))) { @@ -3278,7 +3278,7 @@ static EB_ERRORTYPE HalfSampleDenoise( } pictureControlSetPtr->picNoiseClass = PIC_NOISE_CLASS_INV; //this init is for both REAL-TIME and BEST-QUALITY - + Decimation2D( &inputPicturePtr->bufferY[inputPicturePtr->originX + inputPicturePtr->originY * inputPicturePtr->strideY], inputPicturePtr->strideY, @@ -3369,14 +3369,14 @@ static void PicturePreProcessingOperations( lcuTotalCount, pictureControlSetPtr->enableDenoiseSrcFlag, pictureWidthInLcu); - } else { + } else { FullSampleDenoise( contextPtr, sequenceControlSetPtr, pictureControlSetPtr, lcuTotalCount, pictureControlSetPtr->enableDenoiseSrcFlag - ); + ); } return; @@ -3420,7 +3420,7 @@ static void SubSampleLumaGeneratePixelIntensityHistogramBins( inputPicturePtr->height - (sequenceControlSetPtr->pictureAnalysisNumberOfRegionsPerHeight * regionHeight) : 0; - // Y Histogram + // Y Histogram CalculateHistogram( &inputPicturePtr->bufferY[(inputPicturePtr->originX + regionInPictureWidthIndex * regionWidth) + ((inputPicturePtr->originY + regionInPictureHeightIndex * regionHeight) * inputPicturePtr->strideY)], regionWidth + regionWidthOffset, @@ -3595,7 +3595,7 @@ static void EdgeDetectionMeanLumaChroma16x16( } grady = grady / nbcompy; - + contextPtr->grad[lcuIndex][rasterScanCuIndex] = (EB_U16) (ABS(gradx) + ABS(grady)); if (contextPtr->grad[lcuIndex][rasterScanCuIndex] > maxGrad){ maxGrad = contextPtr->grad[lcuIndex][rasterScanCuIndex]; @@ -3649,7 +3649,7 @@ static void EdgeDetection( EB_U32 lcu_Y = 0; EB_U32 lcuIndex; EB_BOOL highVarianceLucFlag; - + EB_U32 rasterScanCuIndex = 0; EB_U32 numberOfEdgeLcu = 0; EB_BOOL highIntensityLcuFlag; @@ -3671,7 +3671,7 @@ static void EdgeDetection( EdgeLcuResults_t *edgeResultsPtr = pictureControlSetPtr->edgeResultsPtr; pictureControlSetPtr->edgeResultsPtr[lcuIndex].edgeBlockNum = 0; - pictureControlSetPtr->edgeResultsPtr[lcuIndex].isolatedHighIntensityLcu = 0; + pictureControlSetPtr->edgeResultsPtr[lcuIndex].isolatedHighIntensityLcu = 0; pictureControlSetPtr->sharpEdgeLcuFlag[lcuIndex] = 0; if (lcu_X > 0 && lcu_X < (EB_U32)(pictureWidthInLcu - 1) && lcu_Y > 0 && lcu_Y < (EB_U32)(pictureHeightInLcu - 1)){ @@ -3689,7 +3689,7 @@ static void EdgeDetection( EB_U8 sharpEdge = 0; for (rasterScanCuIndex = RASTER_SCAN_CU_INDEX_16x16_0; rasterScanCuIndex <= RASTER_SCAN_CU_INDEX_16x16_15; rasterScanCuIndex++) { sharpEdge = (variancePtr[rasterScanCuIndex] < veryLowIntensityTh) ? sharpEdge + 1 : sharpEdge; - + } if (sharpEdge > 4) { @@ -3724,7 +3724,7 @@ static void EdgeDetection( similarityCount3 = (neighbourLcuMean < lowIntensityTh) ? 1 : 0; similarityCount = similarityCount0 + similarityCount1 + similarityCount2 + similarityCount3; - + if (similarityCount > 0){ @@ -3739,7 +3739,7 @@ static void EdgeDetection( } - if (highVarianceLucFlag){ + if (highVarianceLucFlag){ numberOfEdgeLcu += edgeResultsPtr[lcuIndex].edgeBlockNum; } } @@ -3783,7 +3783,7 @@ static inline void DetermineHomogeneousRegionInPicture( if (lcuParams->isCompleteLcu){ nullVarCnt += (variancePtr[ME_TIER_ZERO_PU_64x64] == 0) ? 1 : 0; - + varLcuCnt++; veryLowVarCnt += ((variancePtr[ME_TIER_ZERO_PU_64x64]) < LCU_LOW_VAR_TH) ? 1 : 0; @@ -3988,7 +3988,7 @@ static void CalculateInputAverageIntensity( pictureControlSetPtr->averageIntensity[1] = (EB_U8)((sumAverageIntensityTotalRegionsCb + ((inputPicturePtr->width*inputPicturePtr->height) >> 3)) / ((inputPicturePtr->width*inputPicturePtr->height) >> 2)); pictureControlSetPtr->averageIntensity[2] = (EB_U8)((sumAverageIntensityTotalRegionsCr + ((inputPicturePtr->width*inputPicturePtr->height) >> 3)) / ((inputPicturePtr->width*inputPicturePtr->height) >> 2)); } - + return; } @@ -4013,7 +4013,7 @@ static void GatheringPictureStatistics( // Histogram bins // Use 1/16 Luma for Histogram generation - // 1/16 input ready + // 1/16 input ready SubSampleLumaGeneratePixelIntensityHistogramBins( sequenceControlSetPtr, pictureControlSetPtr, @@ -4021,14 +4021,14 @@ static void GatheringPictureStatistics( &sumAverageIntensityTotalRegionsLuma); // Use 1/4 Chroma for Histogram generation - // 1/4 input not ready => perform operation on the fly + // 1/4 input not ready => perform operation on the fly SubSampleChromaGeneratePixelIntensityHistogramBins( sequenceControlSetPtr, pictureControlSetPtr, inputPicturePtr, &sumAverageIntensityTotalRegionsCb, &sumAverageIntensityTotalRegionsCr); - + // Calculate the LUMA average intensity CalculateInputAverageIntensity( sequenceControlSetPtr, @@ -4150,7 +4150,7 @@ static void DecimateInputPicture( // Decimate input picture for HME L1 EB_BOOL preformQuarterPellDecimationFlag; - if (sequenceControlSetPtr->staticConfig.speedControlFlag){ + if (sequenceControlSetPtr->staticConfig.speedControlFlag){ preformQuarterPellDecimationFlag = EB_TRUE; } else{ @@ -4183,7 +4183,7 @@ static void DecimateInputPicture( } // Decimate input picture for HME L0 - // Sixteenth Input Picture Decimation + // Sixteenth Input Picture Decimation Decimation2D( &inputPaddedPicturePtr->bufferY[inputPaddedPicturePtr->originX + inputPaddedPicturePtr->originY * inputPaddedPicturePtr->strideY], inputPaddedPicturePtr->strideY, @@ -4228,7 +4228,7 @@ void* PictureAnalysisKernel(void *inputPtr) EbPictureBufferDesc_t *sixteenthDecimatedPicturePtr; EbPictureBufferDesc_t *inputPicturePtr; - // Variance + // Variance EB_U32 pictureWidthInLcu; EB_U32 pictureHeighInLcu; EB_U32 lcuTotalCount; @@ -4253,7 +4253,7 @@ void* PictureAnalysisKernel(void *inputPtr) quarterDecimatedPicturePtr = (EbPictureBufferDesc_t*)paReferenceObject->quarterDecimatedPicturePtr; sixteenthDecimatedPicturePtr = (EbPictureBufferDesc_t*)paReferenceObject->sixteenthDecimatedPicturePtr; - // Variance + // Variance pictureWidthInLcu = (sequenceControlSetPtr->lumaWidth + sequenceControlSetPtr->lcuSize - 1) / sequenceControlSetPtr->lcuSize; pictureHeighInLcu = (sequenceControlSetPtr->lumaHeight + sequenceControlSetPtr->lcuSize - 1) / sequenceControlSetPtr->lcuSize; lcuTotalCount = pictureWidthInLcu * pictureHeighInLcu; @@ -4267,7 +4267,7 @@ void* PictureAnalysisKernel(void *inputPtr) sequenceControlSetPtr, inputPicturePtr); - // Pre processing operations performed on the input picture + // Pre processing operations performed on the input picture PicturePreProcessingOperations( pictureControlSetPtr, contextPtr, @@ -4276,7 +4276,7 @@ void* PictureAnalysisKernel(void *inputPtr) sixteenthDecimatedPicturePtr, lcuTotalCount, pictureWidthInLcu); - + if (inputPicturePtr->colorFormat >= EB_YUV422) { // Jing: Do the conversion of 422/444=>420 here since it's multi-threaded kernel // Reuse the Y, only add cb/cr in the newly created buffer desc @@ -4291,8 +4291,8 @@ void* PictureAnalysisKernel(void *inputPtr) PadPictureToMultipleOfLcuDimensions( inputPaddedPicturePtr ); - - // 1/4 & 1/16 input picture decimation + + // 1/4 & 1/16 input picture decimation DecimateInputPicture( sequenceControlSetPtr, pictureControlSetPtr, @@ -4311,7 +4311,7 @@ void* PictureAnalysisKernel(void *inputPtr) lcuTotalCount); - // Hold the 64x64 variance and mean in the reference frame + // Hold the 64x64 variance and mean in the reference frame EB_U32 lcuIndex; for (lcuIndex = 0; lcuIndex < pictureControlSetPtr->lcuTotalCount; ++lcuIndex){ paReferenceObject->variance[lcuIndex] = pictureControlSetPtr->variance[lcuIndex][ME_TIER_ZERO_PU_64x64]; @@ -4338,9 +4338,9 @@ void* PictureAnalysisKernel(void *inputPtr) double latency = 0.0; EB_U64 finishTimeSeconds = 0; EB_U64 finishTimeuSeconds = 0; - EbFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); + EbHevcFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); - EbComputeOverallElapsedTimeMs( + EbHevcComputeOverallElapsedTimeMs( pictureControlSetPtr->startTimeSeconds, pictureControlSetPtr->startTimeuSeconds, finishTimeSeconds, diff --git a/Source/Lib/Codec/EbPictureDecisionProcess.c b/Source/Lib/Codec/EbPictureDecisionProcess.c index acee83494..3a7f6fe5f 100644 --- a/Source/Lib/Codec/EbPictureDecisionProcess.c +++ b/Source/Lib/Codec/EbPictureDecisionProcess.c @@ -53,7 +53,7 @@ EB_ERRORTYPE PictureDecisionContextCtor( contextPtr->pictureAnalysisResultsInputFifoPtr = pictureAnalysisResultsInputFifoPtr; contextPtr->pictureDecisionResultsOutputFifoPtr = pictureDecisionResultsOutputFifoPtr; - + EB_MALLOC(EB_U32**, contextPtr->ahdRunningAvgCb, sizeof(EB_U32*) * MAX_NUMBER_OF_REGIONS_IN_WIDTH, EB_N_PTR); EB_MALLOC(EB_U32**, contextPtr->ahdRunningAvgCr, sizeof(EB_U32*) * MAX_NUMBER_OF_REGIONS_IN_WIDTH, EB_N_PTR); @@ -120,7 +120,7 @@ static EB_BOOL SceneTransitionDetector( EB_U32 **ahdRunningAvgCb = contextPtr->ahdRunningAvgCb; EB_U32 **ahdRunningAvgCr = contextPtr->ahdRunningAvgCr; EB_U32 **ahdRunningAvg = contextPtr->ahdRunningAvg; - + EB_U32 ahdError = 0; // the difference between the ahd and the running average at the current frame. EB_U8 aidFuturePast = 0; // this variable denotes the average intensity difference between the next and the past frames @@ -143,19 +143,19 @@ static EB_BOOL SceneTransitionDetector( EB_U32 regionCountThreshold = (sequenceControlSetPtr->scdMode == SCD_MODE_2) ? (EB_U32)(((float)((sequenceControlSetPtr->pictureAnalysisNumberOfRegionsPerWidth * sequenceControlSetPtr->pictureAnalysisNumberOfRegionsPerHeight) * 75) / 100) + 0.5) : (EB_U32)(((float)((sequenceControlSetPtr->pictureAnalysisNumberOfRegionsPerWidth * sequenceControlSetPtr->pictureAnalysisNumberOfRegionsPerHeight) * 50) / 100) + 0.5) ; - + regionWidth = ParentPcsWindow[1]->enhancedPicturePtr->width / sequenceControlSetPtr->pictureAnalysisNumberOfRegionsPerWidth; regionHeight = ParentPcsWindow[1]->enhancedPicturePtr->height / sequenceControlSetPtr->pictureAnalysisNumberOfRegionsPerHeight; - + // Loop over regions inside the picture for (regionInPictureWidthIndex = 0; regionInPictureWidthIndex < sequenceControlSetPtr->pictureAnalysisNumberOfRegionsPerWidth; regionInPictureWidthIndex++){ // loop over horizontal regions for (regionInPictureHeightIndex = 0; regionInPictureHeightIndex < sequenceControlSetPtr->pictureAnalysisNumberOfRegionsPerHeight; regionInPictureHeightIndex++){ // loop over vertical regions - isAbruptChange = EB_FALSE; + isAbruptChange = EB_FALSE; isSceneChange = EB_FALSE; isFlash = EB_FALSE; - gradualChange = EB_FALSE; - + gradualChange = EB_FALSE; + // Reset accumulative histogram (absolute) differences between the past and current frame ahd = 0; ahdCb = 0; @@ -175,7 +175,7 @@ static EB_BOOL SceneTransitionDetector( regionThreshHold = ( // Noise insertion/removal detection ((ABS((EB_S64)currentPictureControlSetPtr->picAvgVariance - (EB_S64)previousPictureControlSetPtr->picAvgVariance)) > NOISE_VARIANCE_TH) && - (currentPictureControlSetPtr->picAvgVariance > HIGH_PICTURE_VARIANCE_TH || previousPictureControlSetPtr->picAvgVariance > HIGH_PICTURE_VARIANCE_TH)) ? + (currentPictureControlSetPtr->picAvgVariance > HIGH_PICTURE_VARIANCE_TH || previousPictureControlSetPtr->picAvgVariance > HIGH_PICTURE_VARIANCE_TH)) ? NOISY_SCENE_TH * NUM64x64INPIC(regionWidth, regionHeight) : // SCD TH function of noise insertion/removal. SCENE_TH * NUM64x64INPIC(regionWidth, regionHeight) ; @@ -267,17 +267,17 @@ static EB_BOOL SceneTransitionDetector( if ((isSceneChangeCount >= regionCountThreshold)){ return(EB_TRUE); - } + } else { return(EB_FALSE); } - + } /*************************************************************************************************** -* ReleasePrevPictureFromReorderQueue +* EbHevcReleasePrevPictureFromReorderQueue ***************************************************************************************************/ -EB_ERRORTYPE ReleasePrevPictureFromReorderQueue( +EB_ERRORTYPE EbHevcReleasePrevPictureFromReorderQueue( EncodeContext_t *encodeContextPtr) { EB_ERRORTYPE return_error = EB_ErrorNone; @@ -285,17 +285,17 @@ EB_ERRORTYPE ReleasePrevPictureFromReorderQueue( PictureDecisionReorderEntry_t *queuePreviousEntryPtr; EB_S32 previousEntryIndex; - + // Get the previous entry from the Picture Decision Reordering Queue (Entry N-1) // P.S. The previous entry in display order is needed for Scene Change Detection previousEntryIndex = (encodeContextPtr->pictureDecisionReorderQueueHeadIndex == 0) ? PICTURE_DECISION_REORDER_QUEUE_MAX_DEPTH - 1 : encodeContextPtr->pictureDecisionReorderQueueHeadIndex - 1; queuePreviousEntryPtr = encodeContextPtr->pictureDecisionReorderQueue[previousEntryIndex]; - // LCU activity classification based on (0,0) SAD & picture activity derivation + // LCU activity classification based on (0,0) SAD & picture activity derivation if (queuePreviousEntryPtr->parentPcsWrapperPtr) { // Reset the Picture Decision Reordering Queue Entry - // P.S. The reset of the Picture Decision Reordering Queue Entry could not be done before running the Scene Change Detector + // P.S. The reset of the Picture Decision Reordering Queue Entry could not be done before running the Scene Change Detector queuePreviousEntryPtr->pictureNumber += PICTURE_DECISION_REORDER_QUEUE_MAX_DEPTH; queuePreviousEntryPtr->parentPcsWrapperPtr = (EbObjectWrapper_t *)EB_NULL; } @@ -307,9 +307,9 @@ EB_ERRORTYPE ReleasePrevPictureFromReorderQueue( /*************************************************************************************************** * Generates mini GOP RPSs * -* +* ***************************************************************************************************/ -EB_ERRORTYPE GenerateMiniGopRps( +EB_ERRORTYPE EbHevcGenerateMiniGopRps( PictureDecisionContext_t *contextPtr, EncodeContext_t *encodeContextPtr) { @@ -355,7 +355,7 @@ EB_U8 PictureLevelSubPelSettingsOq( EB_BOOL isUsedAsReferenceFlag) { EB_U8 subPelMode; - + if (encMode <= ENC_MODE_8) { subPelMode = 1; } @@ -422,7 +422,7 @@ EB_ERRORTYPE SignalDerivationMultiProcessesOq( pictureControlSetPtr->depthMode = PICT_LCU_SWITCH_DEPTH_MODE; } } - + // Set the default settings of subpel pictureControlSetPtr->useSubpelFlag = PictureLevelSubPelSettingsOq( sequenceControlSetPtr->inputResolution, @@ -464,7 +464,7 @@ EB_ERRORTYPE SignalDerivationMultiProcessesOq( else { pictureControlSetPtr->cu8x8Mode = CU_8x8_MODE_1; } - + // CU_16x16 Search Mode pictureControlSetPtr->cu16x16Mode = CU_16x16_MODE_0; @@ -477,109 +477,109 @@ EB_ERRORTYPE SignalDerivationMultiProcessesOq( /*************************************************************************************************** * Picture Decision Kernel - * - * Notes on the Picture Decision: - * - * The Picture Decision process performs multi-picture level decisions, including setting of the prediction structure, + * + * Notes on the Picture Decision: + * + * The Picture Decision process performs multi-picture level decisions, including setting of the prediction structure, * setting the picture type and scene change detection. * * Inputs: - * Input Picture - * -Input Picture Data - * - * Outputs: - * -Picture Control Set with fully available PA Reference List - * - * For Low Delay Sequences, pictures are started into the encoder pipeline immediately. - * + * Input Picture + * -Input Picture Data + * + * Outputs: + * -Picture Control Set with fully available PA Reference List + * + * For Low Delay Sequences, pictures are started into the encoder pipeline immediately. + * * For Random Access Sequences, pictures are held for up to a PredictionStructurePeriod - * in order to determine if a Scene Change or Intra Frame is forthcoming. Either of - * those events (and additionally a End of Sequence Flag) will change the expected + * in order to determine if a Scene Change or Intra Frame is forthcoming. Either of + * those events (and additionally a End of Sequence Flag) will change the expected * prediction structure. * - * Below is an example worksheet for how Intra Flags and Scene Change Flags interact + * Below is an example worksheet for how Intra Flags and Scene Change Flags interact * together to affect the prediction structure. * - * The base prediction structure for this example is a 3-Level Hierarchical Random Access, - * Single Reference Prediction Structure: - * - * b b - * / \ / \ - * / B \ - * / / \ \ - * I-----------B - * - * From this base structure, the following RPS positions are derived: - * - * p p b b p p - * \ \ / \ / \ / / - * P \ / B \ / P - * \ \ / / \ \ / / - * ----I-----------B---- - * - * L L L I [ Normal ] T T T - * 2 1 0 n 0 1 2 - * t - * r - * a - * + * The base prediction structure for this example is a 3-Level Hierarchical Random Access, + * Single Reference Prediction Structure: + * + * b b + * / \ / \ + * / B \ + * / / \ \ + * I-----------B + * + * From this base structure, the following RPS positions are derived: + * + * p p b b p p + * \ \ / \ / \ / / + * P \ / B \ / P + * \ \ / / \ \ / / + * ----I-----------B---- + * + * L L L I [ Normal ] T T T + * 2 1 0 n 0 1 2 + * t + * r + * a + * * The RPS is composed of Leading Picture [L2-L0], Intra (CRA), Base/Normal Pictures, * and Trailing Pictures [T0-T2]. Generally speaking, Leading Pictures are useful - * for handling scene changes without adding extraneous I-pictures and the Trailing + * for handling scene changes without adding extraneous I-pictures and the Trailing * pictures are useful for terminating GOPs. * * Here is a table of possible combinations of pictures needed to handle intra and * scene changes happening in quick succession. - * - * Distance to scene change ------------> - * - * 0 1 2 3+ - * I - * n - * t 0 I I n/a n/a n/a - * r - * a p p - * \ / - * P 1 I I I I n/a n/a - * e - * r p p - * i \ / - * o p \ p p / p - * d \ \ / \ / / + * + * Distance to scene change ------------> + * + * 0 1 2 3+ + * I + * n + * t 0 I I n/a n/a n/a + * r + * a p p + * \ / + * P 1 I I I I n/a n/a + * e + * r p p + * i \ / + * o p \ p p / p + * d \ \ / \ / / * 2 I -----I I I I---- I n/a - * | - * | p p p p p p p p - * | \ \ / \ / \ / / - * | P \ / p \ / p \ / P - * | \ \ / \ \ / / \ / / - * V 3+ I ----I I ----I I---- I I---- I - * - * The table is interpreted as follows: - * - * If there are no SCs or Intras encountered for a PredPeriod, then the normal - * prediction structure is applied. - * + * | + * | p p p p p p p p + * | \ \ / \ / \ / / + * | P \ / p \ / p \ / P + * | \ \ / \ \ / / \ / / + * V 3+ I ----I I ----I I---- I I---- I + * + * The table is interpreted as follows: + * + * If there are no SCs or Intras encountered for a PredPeriod, then the normal + * prediction structure is applied. + * * If there is an intra in the PredPeriod, then one of the above combinations of * Leading and Trailing pictures is used. If there is no scene change, the last * valid column consisting of Trailing Pictures only is used. However, if there - * is an upcoming scene change before the next intra, then one of the above patterns + * is an upcoming scene change before the next intra, then one of the above patterns * is used. In the case of End of Sequence flags, only the last valid column of Trailing * Pictures is used. The intention here is that any combination of Intra Flag and Scene - * Change flag can be coded. - * + * Change flag can be coded. + * ***************************************************************************************************/ void* PictureDecisionKernel(void *inputPtr) { - PictureDecisionContext_t *contextPtr = (PictureDecisionContext_t*) inputPtr; + PictureDecisionContext_t *contextPtr = (PictureDecisionContext_t*) inputPtr; - PictureParentControlSet_t *pictureControlSetPtr; + PictureParentControlSet_t *pictureControlSetPtr; EncodeContext_t *encodeContextPtr; SequenceControlSet_t *sequenceControlSetPtr; - + EbObjectWrapper_t *inputResultsWrapperPtr; PictureAnalysisResults_t *inputResultsPtr; - + EbObjectWrapper_t *outputResultsWrapperPtr; PictureDecisionResults_t *outputResultsPtr; @@ -587,17 +587,17 @@ void* PictureDecisionKernel(void *inputPtr) EB_BOOL preAssignmentBufferFirstPassFlag; EB_PICTURE pictureType; - - PictureDecisionReorderEntry_t *queueEntryPtr; + + PictureDecisionReorderEntry_t *queueEntryPtr; EB_S32 queueEntryIndex; - EB_S32 previousEntryIndex; + EB_S32 previousEntryIndex; PaReferenceQueueEntry_t *inputEntryPtr; EB_U32 inputQueueIndex; PaReferenceQueueEntry_t *paReferenceEntryPtr; - EB_U32 paReferenceQueueIndex; + EB_U32 paReferenceQueueIndex; EB_U64 refPoc; @@ -617,16 +617,16 @@ void* PictureDecisionKernel(void *inputPtr) // Debug EB_U64 loopCount = 0; - + for(;;) { - + // Get Input Full Object EbGetFullObject( contextPtr->pictureAnalysisResultsInputFifoPtr, &inputResultsWrapperPtr); EB_CHECK_END_OBJ(inputResultsWrapperPtr); - - inputResultsPtr = (PictureAnalysisResults_t*) inputResultsWrapperPtr->objectPtr; + + inputResultsPtr = (PictureAnalysisResults_t*) inputResultsWrapperPtr->objectPtr; pictureControlSetPtr = (PictureParentControlSet_t*) inputResultsPtr->pictureControlSetWrapperPtr->objectPtr; sequenceControlSetPtr = (SequenceControlSet_t*) pictureControlSetPtr->sequenceControlSetWrapperPtr->objectPtr; encodeContextPtr = (EncodeContext_t*) sequenceControlSetPtr->encodeContextPtr; @@ -638,29 +638,29 @@ void* PictureDecisionKernel(void *inputPtr) loopCount ++; // Input Picture Analysis Results into the Picture Decision Reordering Queue - // P.S. Since the prior Picture Analysis processes stage is multithreaded, inputs to the Picture Decision Process - // can arrive out-of-display-order, so a the Picture Decision Reordering Queue is used to enforce processing of + // P.S. Since the prior Picture Analysis processes stage is multithreaded, inputs to the Picture Decision Process + // can arrive out-of-display-order, so a the Picture Decision Reordering Queue is used to enforce processing of // pictures in display order - queueEntryIndex = (EB_S32) (pictureControlSetPtr->pictureNumber - encodeContextPtr->pictureDecisionReorderQueue[encodeContextPtr->pictureDecisionReorderQueueHeadIndex]->pictureNumber); + queueEntryIndex = (EB_S32) (pictureControlSetPtr->pictureNumber - encodeContextPtr->pictureDecisionReorderQueue[encodeContextPtr->pictureDecisionReorderQueueHeadIndex]->pictureNumber); queueEntryIndex += encodeContextPtr->pictureDecisionReorderQueueHeadIndex; - queueEntryIndex = (queueEntryIndex > PICTURE_DECISION_REORDER_QUEUE_MAX_DEPTH - 1) ? queueEntryIndex - PICTURE_DECISION_REORDER_QUEUE_MAX_DEPTH : queueEntryIndex; - queueEntryPtr = encodeContextPtr->pictureDecisionReorderQueue[queueEntryIndex]; + queueEntryIndex = (queueEntryIndex > PICTURE_DECISION_REORDER_QUEUE_MAX_DEPTH - 1) ? queueEntryIndex - PICTURE_DECISION_REORDER_QUEUE_MAX_DEPTH : queueEntryIndex; + queueEntryPtr = encodeContextPtr->pictureDecisionReorderQueue[queueEntryIndex]; // Parent PCS could be NULL, especailly when the 1st frame is an EOS one. if ((queueEntryPtr->parentPcsWrapperPtr != NULL) && !pictureControlSetPtr->endOfSequenceFlag) { CHECK_REPORT_ERROR_NC( - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_PD_ERROR8); }else{ queueEntryPtr->parentPcsWrapperPtr = inputResultsPtr->pictureControlSetWrapperPtr; queueEntryPtr->pictureNumber = pictureControlSetPtr->pictureNumber; } - // Process the head of the Picture Decision Reordering Queue (Entry N) + // Process the head of the Picture Decision Reordering Queue (Entry N) // P.S. The Picture Decision Reordering Queue should be parsed in the display order to be able to construct a pred structure queueEntryPtr = encodeContextPtr->pictureDecisionReorderQueue[encodeContextPtr->pictureDecisionReorderQueueHeadIndex]; - + while(queueEntryPtr->parentPcsWrapperPtr != EB_NULL) { - + if(queueEntryPtr->pictureNumber == 0 || sequenceControlSetPtr->staticConfig.sceneChangeDetection == 0 || ((PictureParentControlSet_t *)(queueEntryPtr->parentPcsWrapperPtr->objectPtr))->endOfSequenceFlag == EB_TRUE){ @@ -668,8 +668,8 @@ void* PictureDecisionKernel(void *inputPtr) }else{ framePasseThru = EB_FALSE; } - windowAvail = EB_TRUE; - previousEntryIndex = QUEUE_GET_PREVIOUS_SPOT(encodeContextPtr->pictureDecisionReorderQueueHeadIndex); + windowAvail = EB_TRUE; + previousEntryIndex = QUEUE_GET_PREVIOUS_SPOT(encodeContextPtr->pictureDecisionReorderQueueHeadIndex); if(encodeContextPtr->pictureDecisionReorderQueue[previousEntryIndex]->parentPcsWrapperPtr == NULL){ windowAvail = EB_FALSE; @@ -691,7 +691,7 @@ void* PictureDecisionKernel(void *inputPtr) ParentPcsWindow[2+windowIndex] =(PictureParentControlSet_t *) encodeContextPtr->pictureDecisionReorderQueue[entryIndex]->parentPcsWrapperPtr->objectPtr; } } - } + } pictureControlSetPtr = (PictureParentControlSet_t*) queueEntryPtr->parentPcsWrapperPtr->objectPtr; if(pictureControlSetPtr->idrFlag == EB_TRUE) @@ -717,10 +717,10 @@ void* PictureDecisionKernel(void *inputPtr) // Place the PCS into the Pre-Assignment Buffer // P.S. The Pre-Assignment Buffer is used to store a whole pre-structure encodeContextPtr->preAssignmentBuffer[encodeContextPtr->preAssignmentBufferCount] = queueEntryPtr->parentPcsWrapperPtr; - + // Setup the PCS & SCS pictureControlSetPtr = (PictureParentControlSet_t*) encodeContextPtr->preAssignmentBuffer[encodeContextPtr->preAssignmentBufferCount]->objectPtr; - + // Set the POC Number pictureControlSetPtr->pictureNumber = (encodeContextPtr->currentInputPoc + 1) /*& ((1 << sequenceControlSetPtr->bitsForPictureOrderCount)-1)*/; encodeContextPtr->currentInputPoc = pictureControlSetPtr->pictureNumber; @@ -729,13 +729,13 @@ void* PictureDecisionKernel(void *inputPtr) pictureControlSetPtr->predStructure = sequenceControlSetPtr->staticConfig.predStructure; pictureControlSetPtr->hierarchicalLayersDiff = 0; - + pictureControlSetPtr->initPredStructPositionFlag = EB_FALSE; - + pictureControlSetPtr->targetBitRate = sequenceControlSetPtr->staticConfig.targetBitRate; - pictureControlSetPtr->droppedFramesNumber = 0; + pictureControlSetPtr->droppedFramesNumber = 0; - ReleasePrevPictureFromReorderQueue( + EbHevcReleasePrevPictureFromReorderQueue( encodeContextPtr); // If the Intra period length is 0, then introduce an intra for every picture @@ -783,7 +783,7 @@ void* PictureDecisionKernel(void *inputPtr) (pictureControlSetPtr->predStructure == EB_PRED_LOW_DELAY_B)) { - // Initialize Picture Block Params + // Initialize Picture Block Params contextPtr->miniGopStartIndex[0] = 0; contextPtr->miniGopEndIndex [0] = encodeContextPtr->preAssignmentBufferCount - 1; contextPtr->miniGopLenght [0] = encodeContextPtr->preAssignmentBufferCount; @@ -792,16 +792,16 @@ void* PictureDecisionKernel(void *inputPtr) contextPtr->miniGopIntraCount[0] = encodeContextPtr->preAssignmentBufferIntraCount; contextPtr->miniGopIdrCount [0] = encodeContextPtr->preAssignmentBufferIdrCount; contextPtr->totalNumberOfMiniGops = 1; - + encodeContextPtr->previousMiniGopHierarchicalLevels = (pictureControlSetPtr->pictureNumber == 0) ? sequenceControlSetPtr->staticConfig.hierarchicalLevels : encodeContextPtr->previousMiniGopHierarchicalLevels; - GenerateMiniGopRps( + EbHevcGenerateMiniGopRps( contextPtr, encodeContextPtr); - - // Loop over Mini GOPs + + // Loop over Mini GOPs for (miniGopIndex = 0; miniGopIndex < contextPtr->totalNumberOfMiniGops; ++miniGopIndex) { @@ -813,7 +813,7 @@ void* PictureDecisionKernel(void *inputPtr) pictureControlSetPtr = (PictureParentControlSet_t*)encodeContextPtr->preAssignmentBuffer[pictureIndex]->objectPtr; sequenceControlSetPtr = (SequenceControlSet_t*)pictureControlSetPtr->sequenceControlSetWrapperPtr->objectPtr; - // Keep track of the mini GOP size to which the input picture belongs - needed @ PictureManagerProcess() + // Keep track of the mini GOP size to which the input picture belongs - needed @ PictureManagerProcess() pictureControlSetPtr->preAssignmentBufferCount = contextPtr->miniGopLenght[miniGopIndex]; // Update the Pred Structure if cutting short a Random Access period @@ -899,9 +899,9 @@ void* PictureDecisionKernel(void *inputPtr) } // The poc number of the latest IDR picture is stored so that lastIdrPicture (present in PCS) for the incoming pictures can be updated. - // The lastIdrPicture is used in reseting the poc (in entropy coding) whenever IDR is encountered. - // Note IMP: This logic only works when display and decode order are the same. Currently for Random Access, IDR is inserted (similar to CRA) by using trailing P pictures (low delay fashion) and breaking prediction structure. - // Note: When leading P pictures are implemented, this logic has to change.. + // The lastIdrPicture is used in reseting the poc (in entropy coding) whenever IDR is encountered. + // Note IMP: This logic only works when display and decode order are the same. Currently for Random Access, IDR is inserted (similar to CRA) by using trailing P pictures (low delay fashion) and breaking prediction structure. + // Note: When leading P pictures are implemented, this logic has to change.. if (pictureControlSetPtr->idrFlag == EB_TRUE) { encodeContextPtr->lastIdrPicture = pictureControlSetPtr->pictureNumber; } @@ -924,7 +924,7 @@ void* PictureDecisionKernel(void *inputPtr) else if (pictureControlSetPtr->craFlag == EB_TRUE) { pictureControlSetPtr->nalUnit = NAL_UNIT_CODED_SLICE_CRA; } - // User specify of use of non-reference picture is OFF + // User specify of use of non-reference picture is OFF else { // If we have an open GOP situation, where pictures are forward-referencing to a CRA, then those pictures have to be tagged as RASL. if ((contextPtr->miniGopIntraCount[miniGopIndex] > 0) && (contextPtr->miniGopIdrCount[miniGopIndex] == 0) && @@ -955,7 +955,7 @@ void* PictureDecisionKernel(void *inputPtr) case EB_I_PICTURE: - // Reset Prediction Structure Position & Reference Struct Position + // Reset Prediction Structure Position & Reference Struct Position if (pictureControlSetPtr->pictureNumber == 0){ encodeContextPtr->intraPeriodPosition = 0; } @@ -1038,18 +1038,18 @@ void* PictureDecisionKernel(void *inputPtr) } EbBlockOnMutex(encodeContextPtr->terminatingConditionsMutex); - encodeContextPtr->terminatingSequenceFlagReceived = (pictureControlSetPtr->endOfSequenceFlag == EB_TRUE) ? - EB_TRUE : + encodeContextPtr->terminatingSequenceFlagReceived = (pictureControlSetPtr->endOfSequenceFlag == EB_TRUE) ? + EB_TRUE : encodeContextPtr->terminatingSequenceFlagReceived; - encodeContextPtr->terminatingPictureNumber = (pictureControlSetPtr->endOfSequenceFlag == EB_TRUE) ? + encodeContextPtr->terminatingPictureNumber = (pictureControlSetPtr->endOfSequenceFlag == EB_TRUE) ? pictureControlSetPtr->pictureNumber : encodeContextPtr->terminatingPictureNumber; EbReleaseMutex(encodeContextPtr->terminatingConditionsMutex); preAssignmentBufferFirstPassFlag = EB_FALSE; - + // Update the Dependant List Count - If there was an I-frame or Scene Change, then cleanup the Picture Decision PA Reference Queue Dependent Counts if (pictureControlSetPtr->sliceType == EB_I_PICTURE) { @@ -1057,25 +1057,25 @@ void* PictureDecisionKernel(void *inputPtr) inputQueueIndex = encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex; while(inputQueueIndex != encodeContextPtr->pictureDecisionPaReferenceQueueTailIndex) { - + inputEntryPtr = encodeContextPtr->pictureDecisionPaReferenceQueue[inputQueueIndex]; - + // Modify Dependent List0 depListCount = inputEntryPtr->list0.listCount; for(depIdx=0; depIdx < depListCount; ++depIdx) { - - // Adjust the latest currentInputPoc in case we're in a POC rollover scenario + + // Adjust the latest currentInputPoc in case we're in a POC rollover scenario // currentInputPoc += (currentInputPoc < inputEntryPtr->pocNumber) ? (1 << sequenceControlSetPtr->bitsForPictureOrderCount) : 0; - + depPoc = POC_CIRCULAR_ADD( inputEntryPtr->pictureNumber, // can't use a value that gets reset inputEntryPtr->list0.list[depIdx]/*, sequenceControlSetPtr->bitsForPictureOrderCount*/); - + // If Dependent POC is greater or equal to the IDR POC if(depPoc >= pictureControlSetPtr->pictureNumber && inputEntryPtr->list0.list[depIdx]) { - + inputEntryPtr->list0.list[depIdx] = 0; // Decrement the Reference's referenceCount @@ -1083,23 +1083,23 @@ void* PictureDecisionKernel(void *inputPtr) CHECK_REPORT_ERROR( (inputEntryPtr->dependentCount != ~0u), - encodeContextPtr->appCallbackPtr, - EB_ENC_PD_ERROR3); + encodeContextPtr->appCallbackPtr, + EB_ENC_PD_ERROR3); } } - + // Modify Dependent List1 depListCount = inputEntryPtr->list1.listCount; for(depIdx=0; depIdx < depListCount; ++depIdx) { - - // Adjust the latest currentInputPoc in case we're in a POC rollover scenario + + // Adjust the latest currentInputPoc in case we're in a POC rollover scenario // currentInputPoc += (currentInputPoc < inputEntryPtr->pocNumber) ? (1 << sequenceControlSetPtr->bitsForPictureOrderCount) : 0; - + depPoc = POC_CIRCULAR_ADD( inputEntryPtr->pictureNumber, inputEntryPtr->list1.list[depIdx]/*, sequenceControlSetPtr->bitsForPictureOrderCount*/); - + // If Dependent POC is greater or equal to the IDR POC if(((depPoc >= pictureControlSetPtr->pictureNumber) || (((pictureControlSetPtr->preAssignmentBufferCount != pictureControlSetPtr->predStructPtr->predStructPeriod) || (pictureControlSetPtr->idrFlag == EB_TRUE)) && (depPoc > (pictureControlSetPtr->pictureNumber - pictureControlSetPtr->preAssignmentBufferCount)))) && inputEntryPtr->list1.list[depIdx]) { inputEntryPtr->list1.list[depIdx] = 0; @@ -1109,18 +1109,18 @@ void* PictureDecisionKernel(void *inputPtr) CHECK_REPORT_ERROR( (inputEntryPtr->dependentCount != ~0u), - encodeContextPtr->appCallbackPtr, - EB_ENC_PD_ERROR3); + encodeContextPtr->appCallbackPtr, + EB_ENC_PD_ERROR3); } - - } - + + } + // Increment the inputQueueIndex Iterator inputQueueIndex = (inputQueueIndex == PICTURE_DECISION_PA_REFERENCE_QUEUE_MAX_DEPTH - 1) ? 0 : inputQueueIndex + 1; - } - + } + } else if(pictureControlSetPtr->idrFlag == EB_TRUE) { - + // Set the Picture Decision PA Reference Entry pointer inputEntryPtr = (PaReferenceQueueEntry_t*) EB_NULL; } @@ -1130,25 +1130,25 @@ void* PictureDecisionKernel(void *inputPtr) inputEntryPtr->inputObjectPtr = pictureControlSetPtr->paReferencePictureWrapperPtr; inputEntryPtr->pictureNumber = pictureControlSetPtr->pictureNumber; inputEntryPtr->referenceEntryIndex = encodeContextPtr->pictureDecisionPaReferenceQueueTailIndex; - inputEntryPtr->pPcsPtr = pictureControlSetPtr; - encodeContextPtr->pictureDecisionPaReferenceQueueTailIndex = + inputEntryPtr->pPcsPtr = pictureControlSetPtr; + encodeContextPtr->pictureDecisionPaReferenceQueueTailIndex = (encodeContextPtr->pictureDecisionPaReferenceQueueTailIndex == PICTURE_DECISION_PA_REFERENCE_QUEUE_MAX_DEPTH - 1) ? 0 : encodeContextPtr->pictureDecisionPaReferenceQueueTailIndex + 1; - + // Check if the Picture Decision PA Reference is full CHECK_REPORT_ERROR( (((encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex != encodeContextPtr->pictureDecisionPaReferenceQueueTailIndex) || (encodeContextPtr->pictureDecisionPaReferenceQueue[encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex]->inputObjectPtr == EB_NULL))), - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_PD_ERROR4); - // Copy the reference lists into the inputEntry and + // Copy the reference lists into the inputEntry and // set the Reference Counts Based on Temporal Layer and how many frames are active pictureControlSetPtr->refList0Count = (pictureType == EB_I_PICTURE) ? 0 : (EB_U8)predPositionPtr->refList0.referenceListCount; pictureControlSetPtr->refList1Count = (pictureType == EB_I_PICTURE) ? 0 : (EB_U8)predPositionPtr->refList1.referenceListCount; inputEntryPtr->list0Ptr = &predPositionPtr->refList0; inputEntryPtr->list1Ptr = &predPositionPtr->refList1; - + { // Copy the Dependent Lists @@ -1189,61 +1189,61 @@ void* PictureDecisionKernel(void *inputPtr) CHECK_REPORT_ERROR( (pictureControlSetPtr->predStructPtr->predStructPeriod < MAX_ELAPSED_IDR_COUNT), - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_PD_ERROR5); // Reset the PA Reference Lists EB_MEMSET(pictureControlSetPtr->refPaPicPtrArray, 0, 2 * sizeof(EbObjectWrapper_t*)); - + EB_MEMSET(pictureControlSetPtr->refPaPicPtrArray, 0, 2 * sizeof(EB_U32)); - + } - + // 2nd Loop over Pictures in the Pre-Assignment Buffer for (pictureIndex = contextPtr->miniGopStartIndex[miniGopIndex]; pictureIndex <= contextPtr->miniGopEndIndex[miniGopIndex]; ++pictureIndex) { - + pictureControlSetPtr = (PictureParentControlSet_t*) encodeContextPtr->preAssignmentBuffer[pictureIndex]->objectPtr; // Find the Reference in the Picture Decision PA Reference Queue inputQueueIndex = encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex; do { - + // Setup the Picture Decision PA Reference Queue Entry inputEntryPtr = encodeContextPtr->pictureDecisionPaReferenceQueue[inputQueueIndex]; - + // Increment the referenceQueueIndex Iterator inputQueueIndex = (inputQueueIndex == PICTURE_DECISION_PA_REFERENCE_QUEUE_MAX_DEPTH - 1) ? 0 : inputQueueIndex + 1; - + } while ((inputQueueIndex != encodeContextPtr->pictureDecisionPaReferenceQueueTailIndex) && (inputEntryPtr->pictureNumber != pictureControlSetPtr->pictureNumber)); CHECK_REPORT_ERROR( (inputEntryPtr->pictureNumber == pictureControlSetPtr->pictureNumber), - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_PD_ERROR7); // Reset the PA Reference Lists EB_MEMSET(pictureControlSetPtr->refPaPicPtrArray, 0, 2 * sizeof(EbObjectWrapper_t*)); - + EB_MEMSET(pictureControlSetPtr->refPicPocArray, 0, 2 * sizeof(EB_U64)); - + // Configure List0 if ((pictureControlSetPtr->sliceType == EB_P_PICTURE) || (pictureControlSetPtr->sliceType == EB_B_PICTURE)) { - + if (pictureControlSetPtr->refList0Count){ paReferenceQueueIndex = (EB_U32) CIRCULAR_ADD( - ((EB_S32) inputEntryPtr->referenceEntryIndex) - inputEntryPtr->list0Ptr->referenceList, + ((EB_S32) inputEntryPtr->referenceEntryIndex) - inputEntryPtr->list0Ptr->referenceList, PICTURE_DECISION_PA_REFERENCE_QUEUE_MAX_DEPTH); // Max - + paReferenceEntryPtr = encodeContextPtr->pictureDecisionPaReferenceQueue[paReferenceQueueIndex]; - + // Calculate the Ref POC refPoc = POC_CIRCULAR_ADD( pictureControlSetPtr->pictureNumber, -inputEntryPtr->list0Ptr->referenceList/*, sequenceControlSetPtr->bitsForPictureOrderCount*/); - + // Set the Reference Object pictureControlSetPtr->refPaPicPtrArray[REF_LIST_0] = paReferenceEntryPtr->inputObjectPtr; pictureControlSetPtr->refPicPocArray[REF_LIST_0] = refPoc; @@ -1259,21 +1259,21 @@ void* PictureDecisionKernel(void *inputPtr) EbObjectIncLiveCount( paReferenceEntryPtr->pPcsPtr->pPcsWrapperPtr, 1); - + --paReferenceEntryPtr->dependentCount; } } - + // Configure List1 if (pictureControlSetPtr->sliceType == EB_B_PICTURE) { - + if (pictureControlSetPtr->refList1Count){ paReferenceQueueIndex = (EB_U32) CIRCULAR_ADD( - ((EB_S32) inputEntryPtr->referenceEntryIndex) - inputEntryPtr->list1Ptr->referenceList, + ((EB_S32) inputEntryPtr->referenceEntryIndex) - inputEntryPtr->list1Ptr->referenceList, PICTURE_DECISION_PA_REFERENCE_QUEUE_MAX_DEPTH); // Max - + paReferenceEntryPtr = encodeContextPtr->pictureDecisionPaReferenceQueue[paReferenceQueueIndex]; - + // Calculate the Ref POC refPoc = POC_CIRCULAR_ADD( pictureControlSetPtr->pictureNumber, @@ -1283,7 +1283,7 @@ void* PictureDecisionKernel(void *inputPtr) // Set the Reference Object pictureControlSetPtr->refPaPicPtrArray[REF_LIST_1] = paReferenceEntryPtr->inputObjectPtr; pictureControlSetPtr->refPicPocArray[REF_LIST_1] = refPoc; - + // Increment the PA Reference's liveCount by the number of tiles in the input picture EbObjectIncLiveCount( paReferenceEntryPtr->inputObjectPtr, @@ -1294,19 +1294,19 @@ void* PictureDecisionKernel(void *inputPtr) EbObjectIncLiveCount( paReferenceEntryPtr->pPcsPtr->pPcsWrapperPtr, 1); - + --paReferenceEntryPtr->dependentCount; } } - + // Initialize Segments pictureControlSetPtr->meSegmentsColumnCount = (EB_U8)(sequenceControlSetPtr->meSegmentColumnCountArray[pictureControlSetPtr->temporalLayerIndex]); pictureControlSetPtr->meSegmentsRowCount = (EB_U8)(sequenceControlSetPtr->meSegmentRowCountArray[pictureControlSetPtr->temporalLayerIndex]); pictureControlSetPtr->meSegmentsTotalCount = (EB_U16)(pictureControlSetPtr->meSegmentsColumnCount * pictureControlSetPtr->meSegmentsRowCount); pictureControlSetPtr->meSegmentsCompletionMask = 0; - // Post the results to the ME processes + // Post the results to the ME processes { EB_U32 segmentIndex; @@ -1321,8 +1321,8 @@ void* PictureDecisionKernel(void *inputPtr) outputResultsPtr->pictureControlSetWrapperPtr = encodeContextPtr->preAssignmentBuffer[pictureIndex]; - outputResultsPtr->segmentIndex = segmentIndex; - + outputResultsPtr->segmentIndex = segmentIndex; + // Post the Full Results Object EbPostFullObject(outputResultsWrapperPtr); } @@ -1335,7 +1335,7 @@ void* PictureDecisionKernel(void *inputPtr) } if (pictureIndex == encodeContextPtr->preAssignmentBufferCount - 1) { - + // Reset the Pre-Assignment Buffer encodeContextPtr->preAssignmentBufferCount = 0; encodeContextPtr->preAssignmentBufferIdrCount = 0; @@ -1348,25 +1348,25 @@ void* PictureDecisionKernel(void *inputPtr) } // End MINI GOPs loop } - + // Walk the pictureDecisionPaReferenceQueue and remove entries that have been completely referenced. inputQueueIndex = encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex; while(inputQueueIndex != encodeContextPtr->pictureDecisionPaReferenceQueueTailIndex) { - + inputEntryPtr = encodeContextPtr->pictureDecisionPaReferenceQueue[inputQueueIndex]; - + // Remove the entry if((inputEntryPtr->dependentCount == 0) && - (inputEntryPtr->inputObjectPtr)) { + (inputEntryPtr->inputObjectPtr)) { EbReleaseObject(inputEntryPtr->pPcsPtr->pPcsWrapperPtr); // Release the nominal liveCount value EbReleaseObject(inputEntryPtr->inputObjectPtr); inputEntryPtr->inputObjectPtr = (EbObjectWrapper_t*) EB_NULL; } - + // Increment the HeadIndex if the head is null - encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex = + encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex = (encodeContextPtr->pictureDecisionPaReferenceQueue[encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex]->inputObjectPtr) ? encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex : (encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex == PICTURE_DECISION_PA_REFERENCE_QUEUE_MAX_DEPTH - 1) ? 0 : encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex + 1; @@ -1374,29 +1374,29 @@ void* PictureDecisionKernel(void *inputPtr) CHECK_REPORT_ERROR( (((encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex != encodeContextPtr->pictureDecisionPaReferenceQueueTailIndex) || (encodeContextPtr->pictureDecisionPaReferenceQueue[encodeContextPtr->pictureDecisionPaReferenceQueueHeadIndex]->inputObjectPtr == EB_NULL))), - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_PD_ERROR4); // Increment the inputQueueIndex Iterator inputQueueIndex = (inputQueueIndex == PICTURE_DECISION_PA_REFERENCE_QUEUE_MAX_DEPTH - 1) ? 0 : inputQueueIndex + 1; } - + // Increment the Picture Decision Reordering Queue Head Ptr encodeContextPtr->pictureDecisionReorderQueueHeadIndex = (encodeContextPtr->pictureDecisionReorderQueueHeadIndex == PICTURE_DECISION_REORDER_QUEUE_MAX_DEPTH - 1) ? 0 : encodeContextPtr->pictureDecisionReorderQueueHeadIndex + 1; - - // Get the next entry from the Picture Decision Reordering Queue (Entry N+1) + + // Get the next entry from the Picture Decision Reordering Queue (Entry N+1) queueEntryPtr = encodeContextPtr->pictureDecisionReorderQueue[encodeContextPtr->pictureDecisionReorderQueueHeadIndex]; } if(windowAvail == EB_FALSE && framePasseThru == EB_FALSE) break; - } + } #if DEADLOCK_DEBUG SVT_LOG("POC %lld PD OUT \n", pictureControlSetPtr->pictureNumber); -#endif +#endif // Release the Input Results EbReleaseObject(inputResultsWrapperPtr); } - + return EB_NULL; } diff --git a/Source/Lib/Codec/EbPictureManagerProcess.c b/Source/Lib/Codec/EbPictureManagerProcess.c index ec5b86470..b5266ebec 100644 --- a/Source/Lib/Codec/EbPictureManagerProcess.c +++ b/Source/Lib/Codec/EbPictureManagerProcess.c @@ -34,18 +34,18 @@ EB_ERRORTYPE PictureManagerContextCtor( PictureManagerContext_t **contextDblPtr, EbFifo_t *pictureInputFifoPtr, - EbFifo_t *pictureManagerOutputFifoPtr, + EbFifo_t *pictureManagerOutputFifoPtr, EbFifo_t **pictureControlSetFifoPtrArray) { PictureManagerContext_t *contextPtr; EB_MALLOC(PictureManagerContext_t*, contextPtr, sizeof(PictureManagerContext_t), EB_N_PTR); *contextDblPtr = contextPtr; - + contextPtr->pictureInputFifoPtr = pictureInputFifoPtr; - contextPtr->pictureManagerOutputFifoPtr = pictureManagerOutputFifoPtr; + contextPtr->pictureManagerOutputFifoPtr = pictureManagerOutputFifoPtr; contextPtr->pictureControlSetFifoPtrArray = pictureControlSetFifoPtrArray; - + return EB_ErrorNone; } @@ -118,32 +118,32 @@ static void ConfigureTileGroupInfo(PictureParentControlSet_t *ppcsPtr, EB_U16 tg return; } - + /*************************************************************************************************** * Picture Manager Kernel - * - * Notes on the Picture Manager: + * + * Notes on the Picture Manager: * * The Picture Manager Process performs the function of managing both the Input Picture buffers and - * the Reference Picture buffers and subdividing the Input Picture into Tiles. Both the Input Picture - * and Reference Picture buffers particular management depends on the GoP structure already implemented in - * the Picture decision. Also note that the Picture Manager sets up the RPS for Entropy Coding as well. + * the Reference Picture buffers and subdividing the Input Picture into Tiles. Both the Input Picture + * and Reference Picture buffers particular management depends on the GoP structure already implemented in + * the Picture decision. Also note that the Picture Manager sets up the RPS for Entropy Coding as well. * * Inputs: - * Input Picture - * -Input Picture Data - * - * Reference Picture - * -Reference Picture Data - * - * Outputs: - * -Picture Control Set with fully available Reference List - * + * Input Picture + * -Input Picture Data + * + * Reference Picture + * -Reference Picture Data + * + * Outputs: + * -Picture Control Set with fully available Reference List + * ***************************************************************************************************/ void* PictureManagerKernel(void *inputPtr) { PictureManagerContext_t *contextPtr = (PictureManagerContext_t*) inputPtr; - + EbObjectWrapper_t *ChildPictureControlSetWrapperPtr; PictureControlSet_t *ChildPictureControlSetPtr; PictureParentControlSet_t *pictureControlSetPtr; @@ -156,14 +156,14 @@ void* PictureManagerKernel(void *inputPtr) EbObjectWrapper_t *outputWrapperPtr; RateControlTasks_t *rateControlTasksPtr; - + // LCU EB_U32 lcuAddr; EB_BOOL availabilityFlag; - + PredictionStructureEntry_t *predPositionPtr; - + // Dynamic GOP PredictionStructure_t *nextPredStructPtr; PredictionStructureEntry_t *nextBaseLayerPredPositionPtr; @@ -174,27 +174,27 @@ void* PictureManagerKernel(void *inputPtr) InputQueueEntry_t *inputEntryPtr; EB_U32 inputQueueIndex; EB_U64 currentInputPoc; - + ReferenceQueueEntry_t *referenceEntryPtr; EB_U32 referenceQueueIndex; EB_U64 refPoc; - + EB_U32 depIdx; EB_U64 depPoc; EB_U32 depListCount; PictureParentControlSet_t *entryPictureControlSetPtr; SequenceControlSet_t *entrySequenceControlSetPtr; - + // Initialization PictureManagerReorderEntry_t *queueEntryPtr; EB_S32 queueEntryIndex; // Debug EB_U32 loopCount = 0; - + for(;;) { - + // Get Input Full Object EbGetFullObject( contextPtr->pictureInputFifoPtr, @@ -202,18 +202,18 @@ void* PictureManagerKernel(void *inputPtr) EB_CHECK_END_OBJ(inputPictureDemuxWrapperPtr); inputPictureDemuxPtr = (PictureDemuxResults_t*) inputPictureDemuxWrapperPtr->objectPtr; - + // *Note - This should be overhauled and/or replaced when we - // need hierarchical support. + // need hierarchical support. loopCount++; - + switch(inputPictureDemuxPtr->pictureType) { - - case EB_PIC_INPUT: + + case EB_PIC_INPUT: pictureControlSetPtr = (PictureParentControlSet_t*) inputPictureDemuxPtr->pictureControlSetWrapperPtr->objectPtr; sequenceControlSetPtr = (SequenceControlSet_t*) pictureControlSetPtr->sequenceControlSetWrapperPtr->objectPtr; - encodeContextPtr = sequenceControlSetPtr->encodeContextPtr; + encodeContextPtr = sequenceControlSetPtr->encodeContextPtr; #if DEADLOCK_DEBUG SVT_LOG("POC %lld PM IN \n", pictureControlSetPtr->pictureNumber); @@ -249,7 +249,7 @@ void* PictureManagerKernel(void *inputPtr) referenceEntryPtr = encodeContextPtr->referencePictureQueue[referenceQueueIndex]; - if (referenceEntryPtr->pictureNumber == (pictureControlSetPtr->pictureNumber - 1)) { // Picture where the change happened + if (referenceEntryPtr->pictureNumber == (pictureControlSetPtr->pictureNumber - 1)) { // Picture where the change happened // Get the prediction struct entry of the next GOP structure nextPredStructPtr = GetPredictionStructure( @@ -307,7 +307,7 @@ void* PictureManagerKernel(void *inputPtr) for (depIdx = 0; depIdx < depListCount; ++depIdx) { - // Adjust the latest currentInputPoc in case we're in a POC rollover scenario + // Adjust the latest currentInputPoc in case we're in a POC rollover scenario // currentInputPoc += (currentInputPoc < referenceEntryPtr->pocNumber) ? (1 << sequenceControlSetPtr->bitsForPictureOrderCount) : 0; depPoc = POC_CIRCULAR_ADD( @@ -334,7 +334,7 @@ void* PictureManagerKernel(void *inputPtr) depListCount = referenceEntryPtr->list1.listCount; for (depIdx = 0; depIdx < depListCount; ++depIdx) { - // Adjust the latest currentInputPoc in case we're in a POC rollover scenario + // Adjust the latest currentInputPoc in case we're in a POC rollover scenario // currentInputPoc += (currentInputPoc < referenceEntryPtr->pocNumber) ? (1 << sequenceControlSetPtr->bitsForPictureOrderCount) : 0; depPoc = POC_CIRCULAR_ADD( @@ -377,7 +377,7 @@ void* PictureManagerKernel(void *inputPtr) currentInputPoc = pictureControlSetPtr->pictureNumber; - // Adjust the latest currentInputPoc in case we're in a POC rollover scenario + // Adjust the latest currentInputPoc in case we're in a POC rollover scenario // currentInputPoc += (currentInputPoc < referenceEntryPtr->pictureNumber) ? (1 << sequenceControlSetPtr->bitsForPictureOrderCount) : 0; depPoc = POC_CIRCULAR_ADD( @@ -405,7 +405,7 @@ void* PictureManagerKernel(void *inputPtr) currentInputPoc = pictureControlSetPtr->pictureNumber; - // Adjust the latest currentInputPoc in case we're in a POC rollover scenario + // Adjust the latest currentInputPoc in case we're in a POC rollover scenario // currentInputPoc += (currentInputPoc < referenceEntryPtr->pictureNumber) ? (1 << sequenceControlSetPtr->bitsForPictureOrderCount) : 0; depPoc = POC_CIRCULAR_ADD( @@ -439,7 +439,7 @@ void* PictureManagerKernel(void *inputPtr) referenceEntryPtr = (ReferenceQueueEntry_t*)EB_NULL; } - // Check if the EnhancedPictureQueue is full. + // Check if the EnhancedPictureQueue is full. // *Note - Having the number of Enhanced Pictures less than the InputQueueSize should ensure this never gets hit CHECK_REPORT_ERROR( @@ -454,14 +454,14 @@ void* PictureManagerKernel(void *inputPtr) encodeContextPtr->inputPictureQueueTailIndex = (encodeContextPtr->inputPictureQueueTailIndex == INPUT_QUEUE_MAX_DEPTH - 1) ? 0 : encodeContextPtr->inputPictureQueueTailIndex + 1; - // Copy the reference lists into the inputEntry and + // Copy the reference lists into the inputEntry and // set the Reference Counts Based on Temporal Layer and how many frames are active pictureControlSetPtr->refList0Count = (pictureControlSetPtr->sliceType == EB_I_PICTURE) ? 0 : (EB_U8)predPositionPtr->refList0.referenceListCount; pictureControlSetPtr->refList1Count = (pictureControlSetPtr->sliceType == EB_I_PICTURE) ? 0 : (EB_U8)predPositionPtr->refList1.referenceListCount; inputEntryPtr->list0Ptr = &predPositionPtr->refList0; inputEntryPtr->list1Ptr = &predPositionPtr->refList1; - // Check if the ReferencePictureQueue is full. + // Check if the ReferencePictureQueue is full. CHECK_REPORT_ERROR( (((encodeContextPtr->referencePictureQueueHeadIndex != encodeContextPtr->referencePictureQueueTailIndex) || (encodeContextPtr->referencePictureQueue[encodeContextPtr->referencePictureQueueHeadIndex]->referenceObjectPtr == EB_NULL))), encodeContextPtr->appCallbackPtr, @@ -517,54 +517,54 @@ void* PictureManagerKernel(void *inputPtr) // Increment the Picture Manager Reorder Queue encodeContextPtr->pictureManagerReorderQueueHeadIndex = (encodeContextPtr->pictureManagerReorderQueueHeadIndex == PICTURE_MANAGER_REORDER_QUEUE_MAX_DEPTH - 1) ? 0 : encodeContextPtr->pictureManagerReorderQueueHeadIndex + 1; - // Get the next entry from the Picture Manager Reorder Queue (Entry N+1) + // Get the next entry from the Picture Manager Reorder Queue (Entry N+1) queueEntryPtr = encodeContextPtr->pictureManagerReorderQueue[encodeContextPtr->pictureManagerReorderQueueHeadIndex]; } break; - + case EB_PIC_REFERENCE: - + sequenceControlSetPtr = (SequenceControlSet_t*) inputPictureDemuxPtr->sequenceControlSetWrapperPtr->objectPtr; encodeContextPtr = sequenceControlSetPtr->encodeContextPtr; - + // Check if Reference Queue is full CHECK_REPORT_ERROR( (encodeContextPtr->referencePictureQueueHeadIndex != encodeContextPtr->referencePictureQueueTailIndex), - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_PM_ERROR7); - + referenceQueueIndex = encodeContextPtr->referencePictureQueueHeadIndex; - - // Find the Reference in the Reference Queue + + // Find the Reference in the Reference Queue do { - - referenceEntryPtr = encodeContextPtr->referencePictureQueue[referenceQueueIndex]; - + + referenceEntryPtr = encodeContextPtr->referencePictureQueue[referenceQueueIndex]; + if(referenceEntryPtr->pictureNumber == inputPictureDemuxPtr->pictureNumber) { - + // Assign the reference object if there is a match referenceEntryPtr->referenceObjectPtr = inputPictureDemuxPtr->referencePictureWrapperPtr; - + // Set the reference availability referenceEntryPtr->referenceAvailable = EB_TRUE; } - + // Increment the referenceQueueIndex Iterator referenceQueueIndex = (referenceQueueIndex == REFERENCE_QUEUE_MAX_DEPTH - 1) ? 0 : referenceQueueIndex + 1; - + } while ((referenceQueueIndex != encodeContextPtr->referencePictureQueueTailIndex) && (referenceEntryPtr->pictureNumber != inputPictureDemuxPtr->pictureNumber)); - + CHECK_REPORT_ERROR( (referenceEntryPtr->pictureNumber == inputPictureDemuxPtr->pictureNumber), - encodeContextPtr->appCallbackPtr, - EB_ENC_PM_ERROR8); - + encodeContextPtr->appCallbackPtr, + EB_ENC_PM_ERROR8); + //keep the relase of SCS here because we still need the encodeContext strucutre here - // Release the Reference's SequenceControlSet + // Release the Reference's SequenceControlSet EbReleaseObject(inputPictureDemuxPtr->sequenceControlSetWrapperPtr); - + break; case EB_PIC_FEEDBACK: @@ -585,104 +585,104 @@ void* PictureManagerKernel(void *inputPtr) } while ((referenceQueueIndex != encodeContextPtr->referencePictureQueueTailIndex) && (referenceEntryPtr->pictureNumber != inputPictureDemuxPtr->pictureNumber)); //keep the relase of SCS here because we still need the encodeContext strucutre here - // Release the Reference's SequenceControlSet + // Release the Reference's SequenceControlSet EbReleaseObject(inputPictureDemuxPtr->sequenceControlSetWrapperPtr); break; default: - + sequenceControlSetPtr = (SequenceControlSet_t*) inputPictureDemuxPtr->sequenceControlSetWrapperPtr->objectPtr; encodeContextPtr = sequenceControlSetPtr->encodeContextPtr; CHECK_REPORT_ERROR_NC( - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_PM_ERROR9); pictureControlSetPtr = (PictureParentControlSet_t*) EB_NULL; encodeContextPtr = (EncodeContext_t*) EB_NULL; - + break; } - + // *********************************** // Common Code // ************************************* - + // Walk the input queue and start all ready pictures. Mark entry as null after started. Increment the head as you go. if (encodeContextPtr != (EncodeContext_t*)EB_NULL) { inputQueueIndex = encodeContextPtr->inputPictureQueueHeadIndex; while (inputQueueIndex != encodeContextPtr->inputPictureQueueTailIndex) { - + inputEntryPtr = encodeContextPtr->inputPictureQueue[inputQueueIndex]; - + if(inputEntryPtr->inputObjectPtr != EB_NULL) { - + entryPictureControlSetPtr = (PictureParentControlSet_t*) inputEntryPtr->inputObjectPtr->objectPtr; entrySequenceControlSetPtr = (SequenceControlSet_t*) entryPictureControlSetPtr->sequenceControlSetWrapperPtr->objectPtr; - + availabilityFlag = EB_TRUE; - + // Check RefList0 Availability if (entryPictureControlSetPtr->refList0Count){ referenceQueueIndex = (EB_U32) CIRCULAR_ADD( ((EB_S32) inputEntryPtr->referenceEntryIndex) - // Base inputEntryPtr->list0Ptr->referenceList, // Offset REFERENCE_QUEUE_MAX_DEPTH); // Max - + referenceEntryPtr = encodeContextPtr->referencePictureQueue[referenceQueueIndex]; - + CHECK_REPORT_ERROR( (referenceEntryPtr), - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_PM_ERROR10); - + refPoc = POC_CIRCULAR_ADD( entryPictureControlSetPtr->pictureNumber, -inputEntryPtr->list0Ptr->referenceList/*, entrySequenceControlSetPtr->bitsForPictureOrderCount*/); - - // Increment the currentInputPoc is the case of POC rollover + + // Increment the currentInputPoc is the case of POC rollover currentInputPoc = encodeContextPtr->currentInputPoc; - + availabilityFlag = - (availabilityFlag == EB_FALSE) ? EB_FALSE : // Don't update if already False + (availabilityFlag == EB_FALSE) ? EB_FALSE : // Don't update if already False (refPoc > currentInputPoc) ? EB_FALSE : // The Reference has not been received as an Input Picture yet, then its availability is false (!encodeContextPtr->terminatingSequenceFlagReceived && (entrySequenceControlSetPtr->staticConfig.rateControlMode && entryPictureControlSetPtr->sliceType != EB_I_PICTURE && entryPictureControlSetPtr->temporalLayerIndex == 0 && !referenceEntryPtr->feedbackArrived)) ? EB_FALSE : (referenceEntryPtr->referenceAvailable) ? EB_TRUE : // The Reference has been completed EB_FALSE; // The Reference has not been completed } - + // Check RefList1 Availability if(entryPictureControlSetPtr->sliceType == EB_B_PICTURE) { if (entryPictureControlSetPtr->refList1Count){ // If Reference is valid (non-zero), update the availability if(inputEntryPtr->list1Ptr->referenceList != (EB_S32) INVALID_POC) { - + referenceQueueIndex = (EB_U32) CIRCULAR_ADD( ((EB_S32) inputEntryPtr->referenceEntryIndex) - // Base inputEntryPtr->list1Ptr->referenceList, // Offset REFERENCE_QUEUE_MAX_DEPTH); // Max - + referenceEntryPtr = encodeContextPtr->referencePictureQueue[referenceQueueIndex]; CHECK_REPORT_ERROR( (referenceEntryPtr), - encodeContextPtr->appCallbackPtr, + encodeContextPtr->appCallbackPtr, EB_ENC_PM_ERROR10); - + refPoc = POC_CIRCULAR_ADD( entryPictureControlSetPtr->pictureNumber, -inputEntryPtr->list1Ptr->referenceList/*, entrySequenceControlSetPtr->bitsForPictureOrderCount*/); - - // Increment the currentInputPoc is the case of POC rollover + + // Increment the currentInputPoc is the case of POC rollover currentInputPoc = encodeContextPtr->currentInputPoc; //currentInputPoc += ((currentInputPoc < refPoc && inputEntryPtr->list1Ptr->referenceList[refIdx] > 0)) ? // (1 << entrySequenceControlSetPtr->bitsForPictureOrderCount) : // 0; - + availabilityFlag = - (availabilityFlag == EB_FALSE) ? EB_FALSE : // Don't update if already False + (availabilityFlag == EB_FALSE) ? EB_FALSE : // Don't update if already False (refPoc > currentInputPoc) ? EB_FALSE : // The Reference has not been received as an Input Picture yet, then its availability is false (!encodeContextPtr->terminatingSequenceFlagReceived && (entrySequenceControlSetPtr->staticConfig.rateControlMode && entryPictureControlSetPtr->sliceType != EB_I_PICTURE && entryPictureControlSetPtr->temporalLayerIndex == 0 && !referenceEntryPtr->feedbackArrived)) ? EB_FALSE : (referenceEntryPtr->referenceAvailable) ? EB_TRUE : // The Reference has been completed @@ -690,15 +690,15 @@ void* PictureManagerKernel(void *inputPtr) } } } - - if(availabilityFlag == EB_TRUE) { + + if(availabilityFlag == EB_TRUE) { //printf("PICTURE MANAGER RELEASE %d\n", (int)entryPictureControlSetPtr->pictureNumber); // Get New Empty Child PCS from PCS Pool EbGetEmptyObject( contextPtr->pictureControlSetFifoPtrArray[0], &ChildPictureControlSetWrapperPtr); - + // Child PCS is released by Packetization EbObjectIncLiveCount( ChildPictureControlSetWrapperPtr, @@ -709,37 +709,37 @@ void* PictureManagerKernel(void *inputPtr) //1.Link The Child PCS to its Parent ChildPictureControlSetPtr->PictureParentControlSetWrapperPtr = inputEntryPtr->inputObjectPtr; ChildPictureControlSetPtr->ParentPcsPtr = entryPictureControlSetPtr; - - + + //2. Have some common information between ChildPCS and ParentPCS. - ChildPictureControlSetPtr->sequenceControlSetWrapperPtr = entryPictureControlSetPtr->sequenceControlSetWrapperPtr; + ChildPictureControlSetPtr->sequenceControlSetWrapperPtr = entryPictureControlSetPtr->sequenceControlSetWrapperPtr; ChildPictureControlSetPtr->pictureQp = entryPictureControlSetPtr->pictureQp; - ChildPictureControlSetPtr->pictureNumber = entryPictureControlSetPtr->pictureNumber; + ChildPictureControlSetPtr->pictureNumber = entryPictureControlSetPtr->pictureNumber; ChildPictureControlSetPtr->sliceType = entryPictureControlSetPtr->sliceType ; ChildPictureControlSetPtr->temporalLayerIndex = entryPictureControlSetPtr->temporalLayerIndex ; ChildPictureControlSetPtr->ParentPcsPtr->totalNumBits = 0; ChildPictureControlSetPtr->ParentPcsPtr->pictureQp = entryPictureControlSetPtr->pictureQp; ChildPictureControlSetPtr->ParentPcsPtr->sadMe = 0; - ChildPictureControlSetPtr->ParentPcsPtr->quantizedCoeffNumBits = 0; - ChildPictureControlSetPtr->encMode = entryPictureControlSetPtr->encMode; + ChildPictureControlSetPtr->ParentPcsPtr->quantizedCoeffNumBits = 0; + ChildPictureControlSetPtr->encMode = entryPictureControlSetPtr->encMode; ChildPictureControlSetPtr->encDecCodedLcuCount = 0; ChildPictureControlSetPtr->resetDone = EB_FALSE; - + // printf("POC [%lu], use pcs %p\n", ChildPictureControlSetPtr->pictureNumber, ChildPictureControlSetPtr); // Update temporal ID - if(entrySequenceControlSetPtr->staticConfig.enableTemporalId) { + if(entrySequenceControlSetPtr->staticConfig.enableTemporalId) { ChildPictureControlSetPtr->temporalId = (entryPictureControlSetPtr->nalUnit == NAL_UNIT_CODED_SLICE_IDR_W_RADL) ? 0 : - (entryPictureControlSetPtr->nalUnit == NAL_UNIT_CODED_SLICE_CRA) ? 0 : + (entryPictureControlSetPtr->nalUnit == NAL_UNIT_CODED_SLICE_CRA) ? 0 : entryPictureControlSetPtr->temporalLayerIndex; } //3.make all init for ChildPCS EB_U16 tileGroupRowCnt = entrySequenceControlSetPtr->tileGroupRowCountArray[entryPictureControlSetPtr->temporalLayerIndex]; - EB_U16 tileGroupColCnt = entrySequenceControlSetPtr->tileGroupColCountArray[entryPictureControlSetPtr->temporalLayerIndex]; + EB_U16 tileGroupColCnt = entrySequenceControlSetPtr->tileGroupColCountArray[entryPictureControlSetPtr->temporalLayerIndex]; ConfigureTileGroupInfo(entryPictureControlSetPtr, tileGroupColCnt, tileGroupRowCnt); // Configure tile group and segments for EncDec @@ -784,7 +784,7 @@ void* PictureManagerKernel(void *inputPtr) //Configure tile/picture edges ConfigureLcuInfo(ChildPictureControlSetPtr); - + // Reset the qp array for DLF EB_MEMSET(ChildPictureControlSetPtr->qpArray, 0, sizeof(EB_U8)*ChildPictureControlSetPtr->qpArraySize); // Set all the elements in the vertical/horizontal edge bS arraies to 0 for DLF @@ -799,7 +799,7 @@ void* PictureManagerKernel(void *inputPtr) ChildPictureControlSetPtr->isLowDelay = (EB_BOOL)( ChildPictureControlSetPtr->ParentPcsPtr->predStructPtr->predStructEntryPtrArray[ChildPictureControlSetPtr->ParentPcsPtr->predStructIndex]->positiveRefPicsTotalCount == 0); - // Rate Control + // Rate Control ChildPictureControlSetPtr->useDeltaQp = (EB_U8)(entrySequenceControlSetPtr->staticConfig.improveSharpness || entrySequenceControlSetPtr->staticConfig.bitRateReduction); @@ -808,7 +808,7 @@ void* PictureManagerKernel(void *inputPtr) ChildPictureControlSetPtr->difCuDeltaQpDepth = 2; else ChildPictureControlSetPtr->difCuDeltaQpDepth = 3; - + // Reset the Reference Lists EB_MEMSET(ChildPictureControlSetPtr->refPicPtrArray, 0, 2 * sizeof(EbObjectWrapper_t*)); @@ -818,12 +818,12 @@ void* PictureManagerKernel(void *inputPtr) // Configure List0 if ((entryPictureControlSetPtr->sliceType == EB_P_PICTURE) || (entryPictureControlSetPtr->sliceType == EB_B_PICTURE)) { - + if (entryPictureControlSetPtr->refList0Count){ referenceQueueIndex = (EB_U32) CIRCULAR_ADD( - ((EB_S32) inputEntryPtr->referenceEntryIndex) - inputEntryPtr->list0Ptr->referenceList, + ((EB_S32) inputEntryPtr->referenceEntryIndex) - inputEntryPtr->list0Ptr->referenceList, REFERENCE_QUEUE_MAX_DEPTH); // Max - + referenceEntryPtr = encodeContextPtr->referencePictureQueue[referenceQueueIndex]; // Set the Reference Object @@ -836,26 +836,26 @@ void* PictureManagerKernel(void *inputPtr) EbObjectIncLiveCount( referenceEntryPtr->referenceObjectPtr, 1); - + // Decrement the Reference's dependentCount Count --referenceEntryPtr->dependentCount; CHECK_REPORT_ERROR( (referenceEntryPtr->dependentCount != ~0u), - encodeContextPtr->appCallbackPtr, - EB_ENC_PM_ERROR1); - + encodeContextPtr->appCallbackPtr, + EB_ENC_PM_ERROR1); + } } - + // Configure List1 if (entryPictureControlSetPtr->sliceType == EB_B_PICTURE) { - + if (entryPictureControlSetPtr->refList1Count){ referenceQueueIndex = (EB_U32) CIRCULAR_ADD( - ((EB_S32) inputEntryPtr->referenceEntryIndex) - inputEntryPtr->list1Ptr->referenceList, + ((EB_S32) inputEntryPtr->referenceEntryIndex) - inputEntryPtr->list1Ptr->referenceList, REFERENCE_QUEUE_MAX_DEPTH); // Max - + referenceEntryPtr = encodeContextPtr->referencePictureQueue[referenceQueueIndex]; // Set the Reference Object @@ -870,50 +870,50 @@ void* PictureManagerKernel(void *inputPtr) EbObjectIncLiveCount( referenceEntryPtr->referenceObjectPtr, 1); - + // Decrement the Reference's dependentCount Count --referenceEntryPtr->dependentCount; CHECK_REPORT_ERROR( (referenceEntryPtr->dependentCount != ~0u), - encodeContextPtr->appCallbackPtr, - EB_ENC_PM_ERROR1); + encodeContextPtr->appCallbackPtr, + EB_ENC_PM_ERROR1); } } // Adjust the Slice-type if the Lists are Empty, but don't reset the Prediction Structure entryPictureControlSetPtr->sliceType = (entryPictureControlSetPtr->refList1Count > 0) ? EB_B_PICTURE : - (entryPictureControlSetPtr->refList0Count > 0) ? EB_P_PICTURE : + (entryPictureControlSetPtr->refList0Count > 0) ? EB_P_PICTURE : EB_I_PICTURE; // Increment the sequenceControlSet Wrapper's live count by 1 for only the pictures which are used as reference - if(ChildPictureControlSetPtr->ParentPcsPtr->isUsedAsReferenceFlag) { + if(ChildPictureControlSetPtr->ParentPcsPtr->isUsedAsReferenceFlag) { EbObjectIncLiveCount( ChildPictureControlSetPtr->ParentPcsPtr->sequenceControlSetWrapperPtr, 1); } - + // Get Empty Results Object EbGetEmptyObject( contextPtr->pictureManagerOutputFifoPtr, &outputWrapperPtr); - + rateControlTasksPtr = (RateControlTasks_t*) outputWrapperPtr->objectPtr; rateControlTasksPtr->pictureControlSetWrapperPtr = ChildPictureControlSetWrapperPtr; rateControlTasksPtr->taskType = RC_PICTURE_MANAGER_RESULT; - + // Post the Full Results Object EbPostFullObject(outputWrapperPtr); #if LATENCY_PROFILE double latency = 0.0; EB_U64 finishTimeSeconds = 0; EB_U64 finishTimeuSeconds = 0; - EbFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); + EbHevcFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); - EbComputeOverallElapsedTimeMs( + EbHevcComputeOverallElapsedTimeMs( ChildPictureControlSetPtr->ParentPcsPtr->startTimeSeconds, ChildPictureControlSetPtr->ParentPcsPtr->startTimeuSeconds, finishTimeSeconds, @@ -928,43 +928,43 @@ void* PictureManagerKernel(void *inputPtr) // Remove the Input Entry from the Input Queue inputEntryPtr->inputObjectPtr = (EbObjectWrapper_t*) EB_NULL; - + } } - + // Increment the HeadIndex if the head is null - encodeContextPtr->inputPictureQueueHeadIndex = + encodeContextPtr->inputPictureQueueHeadIndex = (encodeContextPtr->inputPictureQueue[encodeContextPtr->inputPictureQueueHeadIndex]->inputObjectPtr) ? encodeContextPtr->inputPictureQueueHeadIndex : (encodeContextPtr->inputPictureQueueHeadIndex == INPUT_QUEUE_MAX_DEPTH - 1) ? 0 : encodeContextPtr->inputPictureQueueHeadIndex + 1; - + // Increment the inputQueueIndex Iterator inputQueueIndex = (inputQueueIndex == INPUT_QUEUE_MAX_DEPTH - 1) ? 0 : inputQueueIndex + 1; - + } - + // Walk the reference queue and remove entries that have been completely referenced. referenceQueueIndex = encodeContextPtr->referencePictureQueueHeadIndex; while(referenceQueueIndex != encodeContextPtr->referencePictureQueueTailIndex) { - + referenceEntryPtr = encodeContextPtr->referencePictureQueue[referenceQueueIndex]; - + // Remove the entry & release the reference if there are no remaining references if((referenceEntryPtr->dependentCount == 0) && (referenceEntryPtr->referenceAvailable) && (referenceEntryPtr->releaseEnable) && - (referenceEntryPtr->referenceObjectPtr)) - { + (referenceEntryPtr->referenceObjectPtr)) + { // Release the nominal liveCount value EbReleaseObject(referenceEntryPtr->referenceObjectPtr); - + referenceEntryPtr->referenceObjectPtr = (EbObjectWrapper_t*) EB_NULL; referenceEntryPtr->referenceAvailable = EB_FALSE; referenceEntryPtr->isUsedAsReferenceFlag = EB_FALSE; } - - // Increment the HeadIndex if the head is empty - encodeContextPtr->referencePictureQueueHeadIndex = + + // Increment the HeadIndex if the head is empty + encodeContextPtr->referencePictureQueueHeadIndex = (encodeContextPtr->referencePictureQueue[encodeContextPtr->referencePictureQueueHeadIndex]->releaseEnable == EB_FALSE)? encodeContextPtr->referencePictureQueueHeadIndex: (encodeContextPtr->referencePictureQueue[encodeContextPtr->referencePictureQueueHeadIndex]->referenceAvailable == EB_FALSE && encodeContextPtr->referencePictureQueue[encodeContextPtr->referencePictureQueueHeadIndex]->isUsedAsReferenceFlag == EB_TRUE) ? encodeContextPtr->referencePictureQueueHeadIndex: @@ -975,10 +975,10 @@ void* PictureManagerKernel(void *inputPtr) referenceQueueIndex = (referenceQueueIndex == REFERENCE_QUEUE_MAX_DEPTH - 1) ? 0 : referenceQueueIndex + 1; } } - + // Release the Input Picture Demux Results - EbReleaseObject(inputPictureDemuxWrapperPtr); - + EbReleaseObject(inputPictureDemuxWrapperPtr); + } -return EB_NULL; +return EB_NULL; } diff --git a/Source/Lib/Codec/EbPictureOperators.c b/Source/Lib/Codec/EbPictureOperators.c index 936739da7..5a3041159 100644 --- a/Source/Lib/Codec/EbPictureOperators.c +++ b/Source/Lib/Codec/EbPictureOperators.c @@ -100,7 +100,7 @@ EB_ERRORTYPE PictureCopy8Bit( /******************************************* * Picture Residue : subsampled version - Computes the residual data + Computes the residual data *******************************************/ void PictureSubSampledResidual( EB_U8 *input, @@ -183,7 +183,7 @@ void PictureResidual16bit( return; } -EB_U64 ComputeNxMSatd8x8Units_U8( +EB_U64 EbHevcComputeNxMSatd8x8Units_U8( EB_U8 *src, //EB_S16 *diff, // input parameter, diff samples Ptr EB_U32 srcStride, //EB_U32 diffStride, // input parameter, source stride EB_U32 width, // input parameter, block width (N) @@ -205,7 +205,7 @@ EB_U64 ComputeNxMSatd8x8Units_U8( } -EB_U64 ComputeNxMSatd4x4Units_U8( +EB_U64 EbHevcComputeNxMSatd4x4Units_U8( EB_U8 *src, //EB_S16 *diff, // input parameter, diff samples Ptr EB_U32 srcStride, //EB_U32 diffStride, // input parameter, source stride EB_U32 width, // input parameter, block width (N) @@ -233,14 +233,14 @@ EB_U64 ComputeNxMSatdSadLCU( EB_U8 *src, // input parameter, source samples Ptr EB_U32 srcStride, // input parameter, source stride EB_U32 width, // input parameter, block width (N) - EB_U32 height) // input parameter, block height (M) + EB_U32 height) // input parameter, block height (M) { EB_U64 satd = 0; EB_U64 dcValue = 0; EB_U64 acValue = 0; if (width >= 8 && height >= 8){ - satd = ComputeNxMSatd8x8Units_U8( + satd = EbHevcComputeNxMSatd8x8Units_U8( src, srcStride, width, @@ -249,7 +249,7 @@ EB_U64 ComputeNxMSatdSadLCU( } else{ satd = - ComputeNxMSatd4x4Units_U8( + EbHevcComputeNxMSatd4x4Units_U8( src, srcStride, width, @@ -348,25 +348,25 @@ EB_ERRORTYPE PictureFullDistortion_R( // Y if (componentMask & PICTURE_BUFFER_DESC_Y_FLAG) { - + FullDistortionIntrinsic_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)][countNonZeroCoeffs[0] != 0][mode == INTRA_MODE][areaSize>>3]( &(((EB_S16*) coeff->bufferY)[coeffLumaOriginIndex]), coeff->strideY, &(((EB_S16*) reconCoeff->bufferY)[coeffLumaOriginIndex]), - reconCoeff->strideY, + reconCoeff->strideY, lumaDistortion, - areaSize, + areaSize, areaSize); } // Cb if (componentMask & PICTURE_BUFFER_DESC_Cb_FLAG) { - + FullDistortionIntrinsic_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)][countNonZeroCoeffs[1] != 0][mode == INTRA_MODE][chromaAreaSize >> 3]( &(((EB_S16*) coeff->bufferCb)[coeffChromaOriginIndex]), coeff->strideCb, &(((EB_S16*) reconCoeff->bufferCb)[coeffChromaOriginIndex]), - reconCoeff->strideCb, + reconCoeff->strideCb, cbDistortion, chromaAreaSize, chromaAreaSize); @@ -379,7 +379,7 @@ EB_ERRORTYPE PictureFullDistortion_R( &(((EB_S16*) coeff->bufferCr)[coeffChromaOriginIndex]), coeff->strideCr, &(((EB_S16*) reconCoeff->bufferCr)[coeffChromaOriginIndex]), - reconCoeff->strideCr, + reconCoeff->strideCr, crDistortion, chromaAreaSize, chromaAreaSize); @@ -405,17 +405,17 @@ EB_ERRORTYPE PictureFullDistortionLuma( EB_MODETYPE mode) { EB_ERRORTYPE return_error = EB_ErrorNone; - + //TODO due to a change in full kernel distortion , ASM has to be updated to not accumulate the input distortion by the output lumaDistortion[0] = 0; lumaDistortion[1] = 0; - + // Y FullDistortionIntrinsic_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)][countNonZeroCoeffsY != 0][mode == INTRA_MODE][areaSize >> 3]( &(((EB_S16*) coeff->bufferY)[coeffLumaOriginIndex]), coeff->strideY, &(((EB_S16*) reconCoeff->bufferY)[reconCoeffLumaOriginIndex]), - reconCoeff->strideY, + reconCoeff->strideY, lumaDistortion, areaSize, areaSize); @@ -429,17 +429,17 @@ void extract8Bitdata( EB_U16 *in16BitBuffer, EB_U32 inStride, EB_U8 *out8BitBuffer, - EB_U32 out8Stride, + EB_U32 out8Stride, EB_U32 width, EB_U32 height ) { - + UnPack8BIT_funcPtrArray_16Bit[((width & 3) == 0) && ((height & 1)== 0)][!!(ASM_TYPES & PREAVX2_MASK)]( in16BitBuffer, inStride, - out8BitBuffer, - out8Stride, + out8BitBuffer, + out8Stride, width, height); } @@ -449,28 +449,28 @@ void UnpackL0L1Avg( EB_U16 *ref16L1, EB_U32 refL1Stride, EB_U8 *dstPtr, - EB_U32 dstStride, + EB_U32 dstStride, EB_U32 width, EB_U32 height) { - + UnPackAvg_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( ref16L0, refL0Stride, ref16L1, refL1Stride, dstPtr, - dstStride, + dstStride, width, height); - - + + } void Extract8BitdataSafeSub( EB_U16 *in16BitBuffer, EB_U32 inStride, EB_U8 *out8BitBuffer, - EB_U32 out8Stride, + EB_U32 out8Stride, EB_U32 width, EB_U32 height ) @@ -479,8 +479,8 @@ void Extract8BitdataSafeSub( UnPack8BITSafeSub_funcPtrArray_16Bit[!!(ASM_TYPES & AVX2_MASK)]( in16BitBuffer, inStride, - out8BitBuffer, - out8Stride, + out8BitBuffer, + out8Stride, width, height ); @@ -491,7 +491,7 @@ void UnpackL0L1AvgSafeSub( EB_U16 *ref16L1, EB_U32 refL1Stride, EB_U8 *dstPtr, - EB_U32 dstStride, + EB_U32 dstStride, EB_U32 width, EB_U32 height) { @@ -503,11 +503,11 @@ void UnpackL0L1AvgSafeSub( ref16L1, refL1Stride, dstPtr, - dstStride, + dstStride, width, height); - - + + } void UnPack2D( EB_U16 *in16BitBuffer, @@ -546,7 +546,7 @@ void Pack2D_SRC( EB_U32 height ) { - + Pack2D_funcPtrArray_16Bit_SRC[((width & 3) == 0) && ((height & 1)== 0)][!!(ASM_TYPES & AVX2_MASK)]( in8BitBuffer, in8Stride, @@ -644,9 +644,9 @@ void memset16bit( } } /******************************************* - * memcpy16bit + * EbHevcmemcpy16bit *******************************************/ -void memcpy16bit( +void EbHevcmemcpy16bit( EB_U16 * outPtr, EB_U16 * inPtr, EB_U64 numOfElements ) @@ -658,7 +658,7 @@ void memcpy16bit( } } - + EB_S32 sumResidual( EB_S16 * inPtr, EB_U32 size, EB_U32 strideIn ) @@ -686,7 +686,7 @@ void memset16bitBlock ( for (i = 0; i < size; i++) memset16bit((EB_U16*)inPtr + i*strideIn, value, size); -} +} void UnusedVariablevoidFunc_PicOper() diff --git a/Source/Lib/Codec/EbPictureOperators.h b/Source/Lib/Codec/EbPictureOperators.h index aa9eb3725..3f6595393 100644 --- a/Source/Lib/Codec/EbPictureOperators.h +++ b/Source/Lib/Codec/EbPictureOperators.h @@ -166,30 +166,30 @@ void CompressedPackLcu( EB_U32 width, EB_U32 height); -void Pack2D_SRC( +void Pack2D_SRC( EB_U8 *in8BitBuffer, - EB_U32 in8Stride, - EB_U8 *innBitBuffer, - EB_U32 innStride, - EB_U16 *out16BitBuffer, - EB_U32 outStride, + EB_U32 in8Stride, + EB_U8 *innBitBuffer, + EB_U32 innStride, + EB_U16 *out16BitBuffer, + EB_U32 outStride, EB_U32 width, EB_U32 height); -void UnPack2D( +void UnPack2D( EB_U16 *in16BitBuffer, - EB_U32 inStride, + EB_U32 inStride, EB_U8 *out8BitBuffer, - EB_U32 out8Stride, - EB_U8 *outnBitBuffer, - EB_U32 outnStride, + EB_U32 out8Stride, + EB_U8 *outnBitBuffer, + EB_U32 outnStride, EB_U32 width, EB_U32 height); void extract8Bitdata( EB_U16 *in16BitBuffer, EB_U32 inStride, EB_U8 *out8BitBuffer, - EB_U32 out8Stride, + EB_U32 out8Stride, EB_U32 width, EB_U32 height ); @@ -199,14 +199,14 @@ void UnpackL0L1Avg( EB_U16 *ref16L1, EB_U32 refL1Stride, EB_U8 *dstPtr, - EB_U32 dstStride, + EB_U32 dstStride, EB_U32 width, EB_U32 height); void Extract8BitdataSafeSub( EB_U16 *in16BitBuffer, EB_U32 inStride, EB_U8 *out8BitBuffer, - EB_U32 out8Stride, + EB_U32 out8Stride, EB_U32 width, EB_U32 height ); @@ -216,13 +216,13 @@ void UnpackL0L1AvgSafeSub( EB_U16 *ref16L1, EB_U32 refL1Stride, EB_U8 *dstPtr, - EB_U32 dstStride, + EB_U32 dstStride, EB_U32 width, EB_U32 height); -void memcpy16bit( +void EbHevcmemcpy16bit( EB_U16 * outPtr, - EB_U16 * inPtr, + EB_U16 * inPtr, EB_U64 numOfElements ); void memset16bit( EB_U16 * inPtr, @@ -422,8 +422,8 @@ typedef void(*EB_RESDKERNELSUBSAMPLED_TYPE)( EB_S16 *residual, EB_U32 residualStride, EB_U32 areaWidth, - EB_U32 areaHeight , - EB_U8 lastLine + EB_U32 areaHeight , + EB_U8 lastLine ); static EB_RESDKERNELSUBSAMPLED_TYPE FUNC_TABLE ResidualKernelSubSampled_funcPtrArray[EB_ASM_TYPE_TOTAL][9] = { // C_DEFAULT @@ -481,9 +481,9 @@ static EB_RESDKERNEL_TYPE FUNC_TABLE ResidualKernel_funcPtrArray[EB_ASM_TYPE_TOT static EB_RESDKERNEL_TYPE_16BIT FUNC_TABLE ResidualKernel_funcPtrArray16Bit[EB_ASM_TYPE_TOTAL] = { - // C_DEFAULT + // C_DEFAULT ResidualKernel16bit, - // AVX2 + // AVX2 ResidualKernel16bit_SSE2_INTRIN }; @@ -506,7 +506,7 @@ static EB_ZEROCOEFF_TYPE FUNC_TABLE PicZeroOutCoef_funcPtrArray[EB_ASM_TYPE_TOTA }, }; -static EB_FULLDIST_TYPE FUNC_TABLE FullDistortionIntrinsic_funcPtrArray[EB_ASM_TYPE_TOTAL][2][2][9] = { +static EB_FULLDIST_TYPE FUNC_TABLE FullDistortionIntrinsic_funcPtrArray[EB_ASM_TYPE_TOTAL][2][2][9] = { // C_DEFAULT // It was found that the SSE2 intrinsic code is much faster (~2x) than the SSE4.1 code { @@ -559,7 +559,7 @@ static EB_FULLDIST_TYPE FUNC_TABLE FullDistortionIntrinsic_funcPtrArray[EB_ASM_T } } - }, + }, // AVX2 // It was found that the SSE2 intrinsic code is much faster (~2x) than the SSE4.1 code { @@ -611,7 +611,7 @@ static EB_FULLDIST_TYPE FUNC_TABLE FullDistortionIntrinsic_funcPtrArray[EB_ASM_T /*8 64x64 */ FullDistortionKernelIntra16MxN_32bit_BT_SSE2, } } - }, + }, }; static EB_SATD_TYPE FUNC_TABLE Compute8x8Satd_funcPtrArray[EB_ASM_TYPE_TOTAL] = { diff --git a/Source/Lib/Codec/EbProductCodingLoop.c b/Source/Lib/Codec/EbProductCodingLoop.c index 36333980b..4108f4e81 100644 --- a/Source/Lib/Codec/EbProductCodingLoop.c +++ b/Source/Lib/Codec/EbProductCodingLoop.c @@ -217,12 +217,12 @@ const EB_FULL_COST_FUNC fullCostFuncTable[3][3] = const EB_PREDICTION_FUNC PredictionFunTableOl[2][3] = { - { NULL, Inter2Nx2NPuPredictionInterpolationFree, IntraPredictionOl }, // Interpolation-free path + { NULL, Inter2Nx2NPuPredictionInterpolationFree, IntraPredictionOl }, // Interpolation-free path { NULL, Inter2Nx2NPuPredictionHevc, IntraPredictionOl } // HEVC Interpolation path }; const EB_PREDICTION_FUNC PredictionFunTableCl[2][3] = { - { NULL, Inter2Nx2NPuPredictionInterpolationFree , IntraPredictionCl }, // Interpolation-free path + { NULL, Inter2Nx2NPuPredictionInterpolationFree , IntraPredictionCl }, // Interpolation-free path { NULL, Inter2Nx2NPuPredictionHevc, IntraPredictionCl } // HEVC Interpolation path }; @@ -501,7 +501,7 @@ void MvMergePassUpdateNeighborArrays( EB_U16 tileIdx, EB_BOOL useIntraChromaflag) { - + NeighborArrayUnitDepthSkipWrite( leafDepthNeighborArray, @@ -522,7 +522,7 @@ void MvMergePassUpdateNeighborArrays( (EB_U8*)lumaMode, originX, originY, - size); + size); // *Note - this has to be changed for non-square PU support -- JMJ NeighborArrayUnitMvWrite( @@ -919,7 +919,7 @@ void SetNfl( // 3 2 if Detectors, 1 otherwise // 4 2 if 64x64 or 32x32 or 16x16, 1 otherwise // 5 2 if 64x64 or 332x32, 1 otherwise - // 6 1 + // 6 1 if (pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_LCU_SWITCH_DEPTH_MODE && pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuPtr->index] == LCU_PRED_OPEN_LOOP_1_NFL_DEPTH_MODE) { contextPtr->fullReconSearchCount = 1; } @@ -961,18 +961,18 @@ void SetNfl( break; case BDP_PILLAR_STAGE: - case BDP_16X16_8X8_REF_STAGE: + case BDP_16X16_8X8_REF_STAGE: // NFL Level Pillar/8x8 Refinement Settings // 0 4 // 1 4 if depthRefinment, 3 if 32x32, 2 otherwise - // 2 3 + // 2 3 // 3 3 if depthRefinment or 32x32, 2 otherwise // 4 3 if 32x32, 2 otherwise - // 5 2 + // 5 2 // 6 2 if Detectors, 1 otherwise // 7 2 if 64x64 or 32x32 or 16x16, 1 otherwise // 8 2 if 64x64 or 332x32, 1 otherwise - // 9 1 + // 9 1 if (contextPtr->nflLevelPillar8x8ref == 0) { contextPtr->fullReconSearchCount = 4; } @@ -1029,14 +1029,14 @@ void SetNfl( // NFL Level MvMerge/64x64 Refinement Settings // 0 4 - // 1 3 + // 1 3 // 2 3 if depthRefinment or 32x32, 2 otherwise // 3 3 if 32x32, 2 otherwise - // 4 2 + // 4 2 // 5 2 if Detectors, 1 otherwise // 6 2 if 64x64 or 32x32 or 16x16, 1 otherwise // 7 2 if 64x64 or 332x32, 1 otherwise - // 8 1 + // 8 1 if (contextPtr->nflLevelMvMerge64x64ref == 0) { contextPtr->fullReconSearchCount = 4; } @@ -1076,7 +1076,7 @@ void SetNfl( } break; - + default: break; } @@ -1148,7 +1148,7 @@ void SetNmm( if (contextPtr->cuSize == 32) contextPtr->mvMergeSkipModeCount = 3; else - contextPtr->mvMergeSkipModeCount = 2; + contextPtr->mvMergeSkipModeCount = 2; } else { contextPtr->mvMergeSkipModeCount = 2; @@ -1160,15 +1160,15 @@ void SetNmm( break; } } - + void CheckHighCostPartition( SequenceControlSet_t *sequenceControlSetPtr, ModeDecisionContext_t *contextPtr, LargestCodingUnit_t *lcuPtr, EB_U8 leafIndex, - EB_U8 *parentLeafIndexPtr, + EB_U8 *parentLeafIndexPtr, EB_BOOL enableExitPartitioning, - EB_U8 *exitPartitionPtr + EB_U8 *exitPartitionPtr ) { @@ -1192,7 +1192,7 @@ void CheckHighCostPartition( if (contextPtr->mdLocalCuUnit[parentLeafIndex].testedCuFlag) { - //get parent cost. + //get parent cost. EB_U64 depthNRate = 0; SplitFlagRate( contextPtr, @@ -1283,7 +1283,7 @@ EB_U32 CalculateNextCuIndex( break; } - + } return stepSplitFalse; } @@ -1307,7 +1307,7 @@ void ConstructMdCuArray( do { CodingUnit_t * const cuPtr = lcuPtr->codedLeafArrayPtr[cuIdx]; - contextPtr->mdLocalCuUnit[cuIdx].testedCuFlag = EB_FALSE; + contextPtr->mdLocalCuUnit[cuIdx].testedCuFlag = EB_FALSE; cuPtr->splitFlag = EB_TRUE; ++cuIdx; @@ -1362,7 +1362,7 @@ void PerformInverseTransformRecon( tuSize = cuStatsPtr->size >> tuStatPtr->depth; tuOriginIndex = tuOriginX + tuOriginY * 64; - // Skip T-1 if 8x8 and INTRA4x4 is the winner as T-1 already performed @ INTRA4x4 search + // Skip T-1 if 8x8 and INTRA4x4 is the winner as T-1 already performed @ INTRA4x4 search if (!(cuPtr->predictionModeFlag == INTRA_MODE && contextPtr->cuStats->size == MIN_CU_SIZE && cuPtr->predictionUnitArray->intraLumaMode == EB_INTRA_MODE_4x4)) { @@ -1421,8 +1421,8 @@ void PerformInverseTransformRecon( EB_U32 crTuChromaOriginIndex = ((tuOriginX + tuOriginY * candidateBuffer->residualQuantCoeffPtr->strideCr) >> 1); - // Skip T-1 if 8x8 and INTRA4x4 is the winner and INTRA4x4 Chroma performed as T-1 already performed @ INTRA4x4 search - //if (!(cuPtr->predictionModeFlag == INTRA_MODE && contextPtr->cuStats->size == MIN_CU_SIZE && cuPtr->predictionUnitArray->intraLumaMode == EB_INTRA_MODE_4x4 && contextPtr->use4x4ChromaInformationInFullLoop)) + // Skip T-1 if 8x8 and INTRA4x4 is the winner and INTRA4x4 Chroma performed as T-1 already performed @ INTRA4x4 search + //if (!(cuPtr->predictionModeFlag == INTRA_MODE && contextPtr->cuStats->size == MIN_CU_SIZE && cuPtr->predictionUnitArray->intraLumaMode == EB_INTRA_MODE_4x4 && contextPtr->use4x4ChromaInformationInFullLoop)) { if (tuPtr->cbCbf) { @@ -1551,7 +1551,7 @@ void PerformInverseTransformRecon( /******************************************* * Coding Loop - Fast Loop Initialization *******************************************/ -void ProductCodingLoopInitFastLoop( +void EbHevcProductCodingLoopInitFastLoop( ModeDecisionContext_t *contextPtr, NeighborArrayUnit_t *intraLumaNeighborArray, NeighborArrayUnit_t *skipFlagNeighborArray, @@ -1607,7 +1607,7 @@ static inline EB_ERRORTYPE ChromaPrediction( (void) cuChromaOriginIndex; - if (candidateBuffer->candidatePtr->predictionIsReady == EB_FALSE) + if (candidateBuffer->candidatePtr->predictionIsReady == EB_FALSE) { const EB_U8 type = candidateBuffer->candidatePtr->type; @@ -1627,7 +1627,7 @@ static inline EB_ERRORTYPE ChromaPrediction( contextPtr, PICTURE_BUFFER_DESC_CHROMA_MASK, pictureControlSetPtr, - candidateBuffer); + candidateBuffer); } else{ PredictionFunTableCl[contextPtr->interpolationMethod][type]( @@ -1654,7 +1654,7 @@ void ProductMdFastPuPrediction( contextPtr->puItr = 0; // Prediction - if (contextPtr->intraMdOpenLoopFlag){ + if (contextPtr->intraMdOpenLoopFlag){ EB_U32 predMask = useChromaInformationInFastLoop ? PICTURE_BUFFER_DESC_FULL_MASK : PICTURE_BUFFER_DESC_LUMA_MASK; if (fastLoopCandidateIndex == bestFirstFastCostSearchCandidateIndex && candidatePtr->type == INTRA_MODE) @@ -1963,7 +1963,7 @@ void ProductPerformFastLoop( lumaFastDistortion = candidatePtr->meDistortion; firstFastCandidateTotalCount++; - + // Fast Cost Calc ProductFastCostFuncOptTable[type][sliceType]( contextPtr, @@ -1982,7 +1982,7 @@ void ProductPerformFastLoop( } // Initialize Fast Cost - to do not interact with the second Fast-Cost Search - *(candidateBuffer->fastCostPtr) = 0xFFFFFFFFFFFFFFFFull; + *(candidateBuffer->fastCostPtr) = 0xFFFFFFFFFFFFFFFFull; } } while (--fastLoopCandidateIndex >= 0); } @@ -2043,7 +2043,7 @@ void ProductPerformFastLoop( lumaFastDistortion = candidatePtr->meDistortion; else // Y - lumaFastDistortion += (NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][cuSize >> 3] ( + lumaFastDistortion += (NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][cuSize >> 3] ( inputBufferY, inputStrideY, predBufferY, @@ -2057,7 +2057,7 @@ void ProductPerformFastLoop( EB_U8 * const inputBufferCb = inputPicturePtr->bufferCb + inputCbOriginIndex; EB_U8 * const predBufferCb = candidateBuffer->predictionPtr->bufferCb + cuChromaOriginIndex; - chromaFastDistortion += NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][cuSize >> 4] ( + chromaFastDistortion += NxMSadKernel_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][cuSize >> 4] ( inputBufferCb, inputPicturePtr->strideCb, predBufferCb, @@ -2104,7 +2104,7 @@ void ProductPerformFastLoop( chromaFastDistortion, contextPtr->fastLambda, pictureControlSetPtr); - + candidateBuffer->candidatePtr->fastLoopLumaDistortion = (EB_U32)lumaFastDistortion; if (contextPtr->useIntraInterBias){ if (candidatePtr->type == INTRA_MODE) @@ -2124,7 +2124,7 @@ void ProductPerformFastLoop( } } } - } + } if (sequenceControlSetPtr->staticConfig.improveSharpness) ApplyMvOverBoundariesBias( @@ -2141,7 +2141,7 @@ void ProductPerformFastLoop( (*secondFastCostSearchCandidateTotalCount)++; } - // Find the buffer with the highest cost + // Find the buffer with the highest cost if (fastLoopCandidateIndex) { // maxCost is volatile to prevent the compiler from loading 0xFFFFFFFFFFFFFF @@ -2285,7 +2285,7 @@ void PerformIntraPrediction( else{ SVT_LOG("ERR: prediction not ready"); } - + } // Skip smaller CU sizes if the current tested CU has the same depth as the TOP and LEFT CU @@ -2367,7 +2367,7 @@ void Intra4x4VsIntra8x8( cuPtr->predictionUnitArray->intraLumaMode = EB_INTRA_MODE_4x4; for (puIndex = 0; puIndex < 4; puIndex++) { - + lcuPtr->intra4x4Mode[((MD_SCAN_TO_RASTER_SCAN[cuPtr->leafIndex] - 21) << 2) + puIndex] = intra4x4LumaMode[puIndex]; } } @@ -2438,7 +2438,7 @@ EB_ERRORTYPE Intra4x4ModeDecisionControl( candidatePtrArray[canTotalCnt]->distortionReady = 0; canTotalCnt++; } - } + } else { // DC candidatePtrArray[canTotalCnt]->type = INTRA_MODE; @@ -2503,7 +2503,7 @@ EB_ERRORTYPE Intra4x4PreModeDecision( //Note/TODO: in the case number of fast candidate is less or equal to the number of buffers, N buffers would be enough fullReconCandidateCount = MAX(1, (*fullCandidateTotalCountPtr) - 1); - //With N buffers, we get here with the best N-1, plus the last candidate. We need to exclude the worst, and keep the best N-1. + //With N buffers, we get here with the best N-1, plus the last candidate. We need to exclude the worst, and keep the best N-1. highestCost = *(bufferPtrArray[0]->fastCostPtr); highestCostIndex = 0; @@ -2688,14 +2688,14 @@ EB_EXTERN EB_ERRORTYPE PerformIntra4x4Search( EB_U32 bufferTotalCount; - // Fast loop + // Fast loop EB_S32 fastLoopCandidateIndex; EB_U32 fastCandidateTotalCount; EB_U64 lumaFastDistortion; //EB_U64 chromaFastDistortion; EB_U64 highestCost; - // Full Loop + // Full Loop EB_U32 fullLoopCandidateIndex; EB_U32 fullCandidateTotalCount; EB_U64 yFullDistortion[DIST_CALC_TOTAL]; @@ -2730,7 +2730,7 @@ EB_EXTERN EB_ERRORTYPE PerformIntra4x4Search( EB_U32 crCountNonZeroCoeffs; EB_U64 crCoeffBits; EB_U32 chromaShift; - + if (contextPtr->coeffCabacUpdate) EB_MEMCPY(&(contextPtr->i4x4CoeffCtxModel), &(contextPtr->latestValidCoeffCtxModel), sizeof(CoeffCtxtMdl_t)); @@ -2763,7 +2763,7 @@ EB_EXTERN EB_ERRORTYPE PerformIntra4x4Search( use4x4ChromaInformation, partitionIndex); - // To move out of the PU loop in case all PUs are going to share same number of fast/full loop candidates + // To move out of the PU loop in case all PUs are going to share same number of fast/full loop candidates Intra4x4ModeDecisionControl( contextPtr, &bufferTotalCount, @@ -2785,7 +2785,7 @@ EB_EXTERN EB_ERRORTYPE PerformIntra4x4Search( maxBuffers = MIN((bufferTotalCount + 1), contextPtr->bufferDepthIndexWidth[MAX_LEVEL_COUNT - 1]); // Fast-Cost Search Candidate Loop - // -Prediction + // -Prediction // -(Input - Prediction) & SAD // -Fast cost calc @@ -2795,7 +2795,7 @@ EB_EXTERN EB_ERRORTYPE PerformIntra4x4Search( chromaFastDistortion = 0; - // Find the buffer with the highest cost + // Find the buffer with the highest cost highestCostIndex = contextPtr->bufferDepthIndexStart[MAX_LEVEL_COUNT - 1]; bufferIndex = highestCostIndex + 1; bufferIndexEnd = highestCostIndex + maxBuffers; @@ -2936,9 +2936,9 @@ EB_EXTERN EB_ERRORTYPE PerformIntra4x4Search( crCoeffBits = 0; crCountNonZeroCoeffs = 0; - // Set the Candidate Buffer + // Set the Candidate Buffer candidateBuffer = candidateBufferPtrArray[candidateIndex]; - candidatePtr = candidateBuffer->candidatePtr;//this is the FastCandidateStruct + candidatePtr = candidateBuffer->candidatePtr;//this is the FastCandidateStruct //4x4CandBuff <-- latest4x4 if (contextPtr->coeffCabacUpdate) @@ -3030,7 +3030,7 @@ EB_EXTERN EB_ERRORTYPE PerformIntra4x4Search( transformBuffer = contextPtr->transQuantBuffersPtr->tuTransCoeff2Nx2NPtr; // *Full Distortion (SSE) // *Note - there are known issues with how this distortion metric is currently - // calculated. The amount of scaling between the two arrays is not + // calculated. The amount of scaling between the two arrays is not // equivalent. PictureFullDistortionLuma( transformBuffer, @@ -3147,7 +3147,7 @@ EB_EXTERN EB_ERRORTYPE PerformIntra4x4Search( transformBuffer = contextPtr->transQuantBuffersPtr->tuTransCoeff2Nx2NPtr; // *Full Distortion (SSE) // *Note - there are known issues with how this distortion metric is currently - // calculated. The amount of scaling between the two arrays is not + // calculated. The amount of scaling between the two arrays is not EB_U32 nonZCoef[3]; EB_U64 zeroDis[2] = { 0 }; @@ -3437,7 +3437,7 @@ EB_EXTERN EB_ERRORTYPE PerformIntra4x4Search( fullCandidateTotalCount, contextPtr->bestCandidateIndexArray); - // Set Candidate Buffer to the selected mode + // Set Candidate Buffer to the selected mode candidateBuffer = candidateBufferPtrArray[candidateIndex]; //latest4x4 <-- 4x4CandBuff @@ -3693,7 +3693,7 @@ void ModeDecisionRefinementUpdateNeighborArrays( size, size, NEIGHBOR_ARRAY_UNIT_FULL_MASK); - + } return; @@ -3831,7 +3831,7 @@ EB_EXTERN EB_ERRORTYPE LinkBdptoMd( EB_U8 predictionModeFlag = (EB_U8)contextPtr->cuPtr->predictionModeFlag; - // intraLumaMode 36 is used to signal INTRA4x4, and when INTRA4x4 is selected intra4x4Mode should be read from intra4x4Mode array + // intraLumaMode 36 is used to signal INTRA4x4, and when INTRA4x4 is selected intra4x4Mode should be read from intra4x4Mode array // the upper right INTRA4x4 mode (partition index 0) is used to update the intra mode neighbor array EB_U8 intraLumaMode = (cuPtr->predictionModeFlag == INTRA_MODE && contextPtr->cuStats->size == MIN_CU_SIZE && cuPtr->predictionUnitArray->intraLumaMode == EB_INTRA_MODE_4x4) ? (EB_U8)lcuPtr->intra4x4Mode[((MD_SCAN_TO_RASTER_SCAN[leafIndex] - 21) << 2)] : @@ -3999,7 +3999,7 @@ EB_EXTERN EB_ERRORTYPE LinkMdtoBdp( EB_U8 predictionModeFlag = (EB_U8)contextPtr->cuPtr->predictionModeFlag; - // intraLumaMode 36 is used to signal INTRA4x4, and when INTRA4x4 is selected intra4x4Mode should be read from intra4x4Mode array + // intraLumaMode 36 is used to signal INTRA4x4, and when INTRA4x4 is selected intra4x4Mode should be read from intra4x4Mode array // the upper right INTRA4x4 mode (partition index 0) is used to update the intra mode neighbor array EB_U8 intraLumaMode = (cuPtr->predictionModeFlag == INTRA_MODE && contextPtr->cuStats->size == MIN_CU_SIZE && cuPtr->predictionUnitArray->intraLumaMode == EB_INTRA_MODE_4x4) ? (EB_U8)lcuPtr->intra4x4Mode[((MD_SCAN_TO_RASTER_SCAN[leafIndex] - 21) << 2)] : @@ -4059,7 +4059,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionRefinementLcu( if (cuPtr->splitFlag == EB_FALSE) { const CodedUnitStats_t *cuStatsPtr = contextPtr->cuStats = GetCodedUnitStats(leafIndex); - + // Initialize CU info contextPtr->cuSizeLog2 = cuStatsPtr->sizeLog2; contextPtr->cuOriginX = (EB_U16) (lcuOriginX + cuStatsPtr->originX); @@ -4112,7 +4112,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionRefinementLcu( leafIndex++; } } - + return return_error; } @@ -4166,7 +4166,7 @@ void AddChromaEncDec( EB_U32 cuChromaOriginIndex, EB_U32 candIdxInput) { - + EB_U64 yFullDistortion[DIST_CALC_TOTAL]; EB_U32 countNonZeroCoeffs[3][MAX_NUM_OF_TU_PER_CU]; @@ -4182,16 +4182,16 @@ void AddChromaEncDec( ModeDecisionCandidateBuffer_t **candidateBufferPtrArrayBase = contextPtr->candidateBufferPtrArray; ModeDecisionCandidateBuffer_t **candidateBufferPtrArray = &(candidateBufferPtrArrayBase[contextPtr->bufferDepthIndexStart[cuStatsPtr->depth]]); ModeDecisionCandidateBuffer_t *candidateBuffer; - ModeDecisionCandidate_t *candidatePtr; + ModeDecisionCandidate_t *candidatePtr; - // Set the Candidate Buffer + // Set the Candidate Buffer candidateBuffer = candidateBufferPtrArray[candIdxInput]; candidatePtr = candidateBuffer->candidatePtr; candidatePtr->type = INTER_MODE; candidatePtr->mergeFlag = EB_TRUE; candidatePtr->predictionIsReady = EB_FALSE; - + PredictionUnit_t *puPtr = & cuPtr->predictionUnitArray[0]; @@ -4203,7 +4203,7 @@ void AddChromaEncDec( if (puPtr->interPredDirectionIndex == UNI_PRED_LIST_0) - { + { //EB_MEMCPY(&candidatePtr->MVsL0,&puPtr->mv[REF_LIST_0].x,4); candidatePtr->motionVector_x_L0 = puPtr->mv[REF_LIST_0].x; candidatePtr->motionVector_y_L0 = puPtr->mv[REF_LIST_0].y; @@ -4280,7 +4280,7 @@ void AddChromaEncDec( contextPtr->cuSize >> 1, contextPtr->cuSize >> 1); - + EB_U8 qpScaled = CLIP3((EB_S8)MIN_QP_VALUE, (EB_S8)MAX_CHROMA_MAP_QP_VALUE, (EB_S8)(contextPtr->qp + pictureControlSetPtr->cbQpOffset + pictureControlSetPtr->sliceCbQpOffset)); EB_U8 cbQp = MapChromaQp(qpScaled); @@ -4294,7 +4294,7 @@ void AddChromaEncDec( contextPtr, cuStatsPtr, inputPicturePtr, - pictureControlSetPtr, + pictureControlSetPtr, PICTURE_BUFFER_DESC_CHROMA_MASK, cbQp, crQp, @@ -4374,7 +4374,7 @@ static void PerformFullLoop( EB_U64 yCoeffBits; EB_U64 cbCoeffBits = 0; - EB_U64 crCoeffBits = 0; + EB_U64 crCoeffBits = 0; LcuStat_t *lcuStatPtr = &(pictureControlSetPtr->ParentPcsPtr->lcuStatArray[lcuPtr->index]); const CodedUnitStats_t *cuStatsPtr = contextPtr->cuStats = GetCodedUnitStats(contextPtr->cuPtr->leafIndex); @@ -4396,9 +4396,9 @@ static void PerformFullLoop( yFullDistortion[DIST_CALC_PREDICTION] = 0; yCoeffBits = 0; - // Set the Candidate Buffer + // Set the Candidate Buffer candidateBuffer = candidateBufferPtrArray[candidateIndex]; - candidatePtr = candidateBuffer->candidatePtr;//this is the FastCandidateStruct + candidatePtr = candidateBuffer->candidatePtr;//this is the FastCandidateStruct candidatePtr->fullDistortion = 0; //CandBuff <-- CU @@ -4407,7 +4407,7 @@ static void PerformFullLoop( candidatePtr->chromaDistortion = 0; candidatePtr->chromaDistortionInterDepth = 0; - + if (pictureControlSetPtr->sliceType != EB_I_PICTURE) { if (candidatePtr->type == INTRA_MODE && prevRootCbf == 0) { continue; @@ -4700,10 +4700,10 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( { EB_ERRORTYPE return_error = EB_ErrorNone; - // CU + // CU EB_U32 cuIdx; - // Input + // Input EbPictureBufferDesc_t *inputPicturePtr = pictureControlSetPtr->ParentPcsPtr->chromaDownSamplePicturePtr; @@ -4714,17 +4714,17 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( ModeDecisionCandidateBuffer_t *candidateBuffer; ModeDecisionCandidateBuffer_t *bestCandidateBuffers[EB_MAX_LCU_DEPTH]; - // Mode Decision Search Candidates + // Mode Decision Search Candidates EB_U8 candidateIndex; EB_U32 fastCandidateTotalCount; EB_U32 fullCandidateTotalCount; EB_U32 secondFastCostSearchCandidateTotalCount; - // CTB merge + // CTB merge EB_U32 lastCuIndex; - // Pre Intra Search + // Pre Intra Search const EB_U32 lcuHeight = MIN(MAX_LCU_SIZE, (EB_U32)(sequenceControlSetPtr->lumaHeight - lcuOriginY)); const EB_PICTURE sliceType = pictureControlSetPtr->sliceType; const EB_U32 leafCount = mdcResultTbPtr->leafCount; @@ -4754,7 +4754,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( // Keep track of the LCU Ptr contextPtr->lcuPtr = lcuPtr; - + contextPtr->groupOf8x8BlocksCount = 0; contextPtr->groupOf16x16BlocksCount = 0; @@ -4774,7 +4774,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( contextPtr->cbReconNeighborArray = pictureControlSetPtr->mdCbReconNeighborArray[MD_NEIGHBOR_ARRAY_INDEX][tileIdx]; contextPtr->crReconNeighborArray = pictureControlSetPtr->mdCrReconNeighborArray[MD_NEIGHBOR_ARRAY_INDEX][tileIdx]; contextPtr->edgeBlockNumFlag = (EB_BOOL)pictureControlSetPtr->ParentPcsPtr->edgeResultsPtr[lcuAddr].edgeBlockNum; - // First CU Loop + // First CU Loop cuIdx = 0; do { @@ -4807,7 +4807,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( cuPtr->leafIndex = leafIndex; cuPtr->splitFlag = (EB_U16)( (sliceType == EB_I_PICTURE) && (cuStatsPtr->depth == 0) ? EB_TRUE : - leafDataPtr->splitFlag); + leafDataPtr->splitFlag); cuPtr->qp = contextPtr->qp; candidateBufferPtrArray = &(candidateBufferPtrArrayBase[contextPtr->bufferDepthIndexStart[cuStatsPtr->depth]]); @@ -4818,7 +4818,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( contextPtr); // Initialize Fast Loop - ProductCodingLoopInitFastLoop( // HT to be rechecked especially for fullCostArray + EbHevcProductCodingLoopInitFastLoop( // HT to be rechecked especially for fullCostArray contextPtr, contextPtr->intraLumaModeNeighborArray, contextPtr->skipFlagNeighborArray, @@ -4826,8 +4826,8 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( contextPtr->leafDepthNeighborArray); if ( - (pictureControlSetPtr->ParentPcsPtr->depthMode >= PICT_OPEN_LOOP_DEPTH_MODE || - (pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_LCU_SWITCH_DEPTH_MODE && (pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuAddr] == LCU_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuAddr] == LCU_LIGHT_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuAddr] == LCU_AVC_DEPTH_MODE))) && + (pictureControlSetPtr->ParentPcsPtr->depthMode >= PICT_OPEN_LOOP_DEPTH_MODE || + (pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_LCU_SWITCH_DEPTH_MODE && (pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuAddr] == LCU_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuAddr] == LCU_LIGHT_OPEN_LOOP_DEPTH_MODE || pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuAddr] == LCU_AVC_DEPTH_MODE))) && lcuParams->isCompleteLcu ){ @@ -4840,7 +4840,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( // Perform MPM search if (contextPtr->mpmSearch) { - DeriveMpmModes( + DeriveMpmModes( contextPtr, cuPtr); } @@ -4918,7 +4918,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( inputCbOriginIndex, cuOriginIndex, cuChromaOriginIndex, - MIN(fullCandidateTotalCount, bufferTotalCount)); // fullCandidateTotalCount to number of buffers to process + MIN(fullCandidateTotalCount, bufferTotalCount)); // fullCandidateTotalCount to number of buffers to process // Full Mode Decision (choose the best mode) candidateIndex = ProductFullModeDecision( @@ -4930,7 +4930,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( contextPtr->bestCandidateIndexArray, &bestIntraMode); - // Set Candidate Buffer to the selected mode + // Set Candidate Buffer to the selected mode // If Intra 4x4 is selected then candidateBuffer for depth 3 is not going to get used // No MD-Recon: iTransform Loop + Recon, and no lumaReconSampleNeighborArray update @@ -4953,7 +4953,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( candidateBuffer = candidateBufferPtrArray[candidateIndex]; - + bestCandidateBuffers[contextPtr->cuStats->depth] = candidateBuffer; contextPtr->mdEpPipeLcu[cuPtr->leafIndex].yCoeffBits = candidateBuffer->yCoeffBits; contextPtr->mdEpPipeLcu[cuPtr->leafIndex].yDc[0] = candidateBuffer->yDc[0]; @@ -5070,7 +5070,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( contextPtr->crReconNeighborArray, candidateBuffer->reconPtr, MAX_LCU_SIZE, - contextPtr->intraMdOpenLoopFlag, + contextPtr->intraMdOpenLoopFlag, (cuPtr->predictionModeFlag == INTRA_MODE && contextPtr->cuStats->size == MIN_CU_SIZE && cuPtr->predictionUnitArray->intraLumaMode == EB_INTRA_MODE_4x4), (EB_U8*)&contextPtr->cuStats->depth, &predictionModeFlag, @@ -5094,7 +5094,7 @@ EB_EXTERN EB_ERRORTYPE ModeDecisionLcu( } } - + if (cuPtr->splitFlag == EB_TRUE){ cuIdx++; } @@ -5130,7 +5130,7 @@ void ConstructPillarCuArray( CodingUnit_t * const cuPtr = lcuPtr->codedLeafArrayPtr[cuIndex]; splitFlag = EB_TRUE; - cuPtr->splitFlag = EB_TRUE; + cuPtr->splitFlag = EB_TRUE; contextPtr->mdLocalCuUnit[cuIndex].testedCuFlag = EB_FALSE; if (lcuParamPtr->rasterScanCuValidity[MD_SCAN_TO_RASTER_SCAN[cuIndex]]) @@ -5150,7 +5150,7 @@ void ConstructPillarCuArray( } else if (cuStatsPtr->depth == 2) { - + splitFlag = EB_FALSE; cuPtr->splitFlag = EB_FALSE; contextPtr->mdLocalCuUnit[cuIndex].testedCuFlag = EB_FALSE; @@ -5176,18 +5176,18 @@ void ConstructPillarCuArray( EB_EXTERN EB_ERRORTYPE BdpPillar( SequenceControlSet_t *sequenceControlSetPtr, - PictureControlSet_t *pictureControlSetPtr, - LcuParams_t *lcuParamPtr, + PictureControlSet_t *pictureControlSetPtr, + LcuParams_t *lcuParamPtr, LargestCodingUnit_t *lcuPtr, EB_U16 lcuAddr, ModeDecisionContext_t *contextPtr) { EB_ERRORTYPE return_error = EB_ErrorNone; - - // CU + + // CU EB_U32 cuIdx; - // Input + // Input EbPictureBufferDesc_t *inputPicturePtr = pictureControlSetPtr->ParentPcsPtr->chromaDownSamplePicturePtr; EB_U16 tileIdx = lcuPtr->lcuEdgeInfoPtr->tileIndexInRaster; @@ -5197,22 +5197,22 @@ EB_EXTERN EB_ERRORTYPE BdpPillar( ModeDecisionCandidateBuffer_t *candidateBuffer; ModeDecisionCandidateBuffer_t *bestCandidateBuffers[EB_MAX_LCU_DEPTH]; - // Mode Decision Search Candidates + // Mode Decision Search Candidates EB_U8 candidateIndex; EB_U32 fastCandidateTotalCount; EB_U32 fullCandidateTotalCount; EB_U32 secondFastCostSearchCandidateTotalCount; - - // CTB merge + + // CTB merge EB_U32 lastCuIndex; - - // Pre Intra Search + + // Pre Intra Search ModeDecisionCandidate_t *fastCandidateArray = contextPtr->fastCandidateArray; ModeDecisionCandidateBuffer_t **candidateBufferPtrArrayBase = contextPtr->candidateBufferPtrArray; EB_U32 bestIntraMode = EB_INTRA_MODE_INVALID; - + ModeDecisionCandidateBuffer_t **candidateBufferPtrArray; EB_U32 maxBuffers; @@ -5231,7 +5231,7 @@ EB_EXTERN EB_ERRORTYPE BdpPillar( // Keep track of the LCU Ptr contextPtr->lcuPtr = lcuPtr; - + contextPtr->groupOf8x8BlocksCount = 0; contextPtr->groupOf16x16BlocksCount = 0; @@ -5247,7 +5247,7 @@ EB_EXTERN EB_ERRORTYPE BdpPillar( contextPtr->edgeBlockNumFlag = (EB_BOOL)pictureControlSetPtr->ParentPcsPtr->edgeResultsPtr[lcuAddr].edgeBlockNum; - // First CU Loop + // First CU Loop cuIdx = 0; do { @@ -5277,7 +5277,7 @@ EB_EXTERN EB_ERRORTYPE BdpPillar( contextPtr->cuChromaOriginX = contextPtr->cuOriginX >> 1; contextPtr->cuChromaOriginY = contextPtr->cuOriginY >> 1; contextPtr->mdLocalCuUnit[leafIndex].testedCuFlag = EB_TRUE; - cuPtr->leafIndex = leafIndex; + cuPtr->leafIndex = leafIndex; cuPtr->qp = contextPtr->qp; candidateBufferPtrArray = &(candidateBufferPtrArrayBase[contextPtr->bufferDepthIndexStart[cuStatsPtr->depth]]); @@ -5286,9 +5286,9 @@ EB_EXTERN EB_ERRORTYPE BdpPillar( DerivePartialFrequencyN2Flag( pictureControlSetPtr, contextPtr); - + // Initialize Fast Loop - ProductCodingLoopInitFastLoop( // HT to be rechecked especially for fullCostArray + EbHevcProductCodingLoopInitFastLoop( // HT to be rechecked especially for fullCostArray contextPtr, contextPtr->intraLumaModeNeighborArray, contextPtr->skipFlagNeighborArray, @@ -5375,7 +5375,7 @@ EB_EXTERN EB_ERRORTYPE BdpPillar( inputCbOriginIndex, cuOriginIndex, cuChromaOriginIndex, - MIN(fullCandidateTotalCount, bufferTotalCount)); // fullCandidateTotalCount to number of buffers to process + MIN(fullCandidateTotalCount, bufferTotalCount)); // fullCandidateTotalCount to number of buffers to process // Full Mode Decision (choose the best mode) candidateIndex = ProductFullModeDecision( @@ -5388,7 +5388,7 @@ EB_EXTERN EB_ERRORTYPE BdpPillar( &bestIntraMode); candidateBuffer = candidateBufferPtrArray[candidateIndex]; - + bestCandidateBuffers[contextPtr->cuStats->depth] = candidateBuffer; contextPtr->mdEpPipeLcu[cuPtr->leafIndex].yCoeffBits = candidateBuffer->yCoeffBits; contextPtr->mdEpPipeLcu[cuPtr->leafIndex].yDc[0] = candidateBuffer->yDc[0]; @@ -5410,9 +5410,9 @@ EB_EXTERN EB_ERRORTYPE BdpPillar( } EB_U8 parentLeafIndex; - EB_BOOL exitPartition = EB_FALSE; + EB_BOOL exitPartition = EB_FALSE; contextPtr->mdLocalCuUnit[leafIndex].mdcArrayIndex = (EB_U8)cuIdx; - + CheckHighCostPartition( sequenceControlSetPtr, contextPtr, @@ -5503,7 +5503,7 @@ EB_EXTERN EB_ERRORTYPE BdpPillar( &skipFlag, contextPtr->cuOriginX, contextPtr->cuOriginY, - contextPtr->cuStats->size, + contextPtr->cuStats->size, contextPtr->useChromaInformationInFullLoop ? EB_TRUE : EB_FALSE); } @@ -5534,7 +5534,7 @@ EB_EXTERN EB_ERRORTYPE BdpPillar( } while (cuIdx < contextPtr->pillarCuArray.leafCount); return return_error; -} +} void SplitParentCu( @@ -5591,7 +5591,7 @@ EB_EXTERN EB_ERRORTYPE Bdp64x64vs32x32RefinementProcess( { EB_ERRORTYPE return_error = EB_ErrorNone; - // Input + // Input EbPictureBufferDesc_t *inputPicturePtr = pictureControlSetPtr->ParentPcsPtr->chromaDownSamplePicturePtr; // Mode Decision Candidate Buffers @@ -5599,14 +5599,14 @@ EB_EXTERN EB_ERRORTYPE Bdp64x64vs32x32RefinementProcess( ModeDecisionCandidateBuffer_t *candidateBuffer; ModeDecisionCandidateBuffer_t *bestCandidateBuffers[EB_MAX_LCU_DEPTH]; - // Mode Decision Search Candidates + // Mode Decision Search Candidates EB_U8 candidateIndex; EB_U32 fastCandidateTotalCount; EB_U32 fullCandidateTotalCount; EB_U32 secondFastCostSearchCandidateTotalCount; - // Pre Intra Search + // Pre Intra Search ModeDecisionCandidate_t *fastCandidateArray = contextPtr->fastCandidateArray; ModeDecisionCandidateBuffer_t **candidateBufferPtrArrayBase = contextPtr->candidateBufferPtrArray; @@ -5659,7 +5659,7 @@ EB_EXTERN EB_ERRORTYPE Bdp64x64vs32x32RefinementProcess( contextPtr); // Initialize Fast Loop - ProductCodingLoopInitFastLoop( // HT to be rechecked especially for fullCostArray + EbHevcProductCodingLoopInitFastLoop( // HT to be rechecked especially for fullCostArray contextPtr, contextPtr->intraLumaModeNeighborArray, contextPtr->skipFlagNeighborArray, @@ -5745,7 +5745,7 @@ EB_EXTERN EB_ERRORTYPE Bdp64x64vs32x32RefinementProcess( inputCbOriginIndex, cuOriginIndex, cuChromaOriginIndex, - MIN(fullCandidateTotalCount, bufferTotalCount)); // fullCandidateTotalCount to number of buffers to process + MIN(fullCandidateTotalCount, bufferTotalCount)); // fullCandidateTotalCount to number of buffers to process // Full Mode Decision (choose the best mode) candidateIndex = ProductFullModeDecision( @@ -5862,14 +5862,14 @@ EB_EXTERN EB_ERRORTYPE Bdp64x64vs32x32RefinementProcess( EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( SequenceControlSet_t *sequenceControlSetPtr, PictureControlSet_t *pictureControlSetPtr, - LcuParams_t *lcuParamPtr, + LcuParams_t *lcuParamPtr, LargestCodingUnit_t *lcuPtr, EB_U16 lcuAddr, ModeDecisionContext_t *contextPtr) { EB_ERRORTYPE return_error = EB_ErrorNone; - // Input + // Input EbPictureBufferDesc_t *inputPicturePtr = pictureControlSetPtr->ParentPcsPtr->chromaDownSamplePicturePtr; EB_U16 tileIdx = contextPtr->tileIndex; @@ -5878,15 +5878,15 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( EB_U32 bufferTotalCount; ModeDecisionCandidateBuffer_t *candidateBuffer; ModeDecisionCandidateBuffer_t *bestCandidateBuffers[EB_MAX_LCU_DEPTH] = {NULL}; - - // Mode Decision Search Candidates + + // Mode Decision Search Candidates EB_U8 candidateIndex; EB_U32 fastCandidateTotalCount; EB_U32 fullCandidateTotalCount; EB_U32 secondFastCostSearchCandidateTotalCount; - // Pre Intra Search + // Pre Intra Search ModeDecisionCandidate_t *fastCandidateArray = contextPtr->fastCandidateArray; ModeDecisionCandidateBuffer_t **candidateBufferPtrArrayBase = contextPtr->candidateBufferPtrArray; @@ -5903,7 +5903,7 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( // Keep track of the LCU Ptr - contextPtr->lcuPtr = lcuPtr; + contextPtr->lcuPtr = lcuPtr; contextPtr->intraLumaModeNeighborArray = pictureControlSetPtr->mdIntraLumaModeNeighborArray[REFINEMENT_NEIGHBOR_ARRAY_INDEX][tileIdx]; contextPtr->mvNeighborArray = pictureControlSetPtr->mdMvNeighborArray[REFINEMENT_NEIGHBOR_ARRAY_INDEX][tileIdx]; @@ -5915,14 +5915,14 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( contextPtr->crReconNeighborArray = pictureControlSetPtr->mdCrReconNeighborArray[REFINEMENT_NEIGHBOR_ARRAY_INDEX][tileIdx]; EB_U8 parentLeafIndex = 0; - + while (parentLeafIndex < CU_MAX_COUNT) { if (lcuPtr->codedLeafArrayPtr[parentLeafIndex]->splitFlag == EB_FALSE) { EB_U8 parentDepthOffset = DepthOffset[GetCodedUnitStats(parentLeafIndex)->depth]; EB_U8 childDepthOffset = DepthOffset[GetCodedUnitStats(parentLeafIndex)->depth + 1]; - EB_BOOL cu16x16RefinementFlag; + EB_BOOL cu16x16RefinementFlag; if (pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_LIGHT_BDP_DEPTH_MODE || (pictureControlSetPtr->ParentPcsPtr->depthMode == PICT_LCU_SWITCH_DEPTH_MODE && (pictureControlSetPtr->ParentPcsPtr->lcuMdModeArray[lcuAddr] == LCU_LIGHT_BDP_DEPTH_MODE))){ @@ -5948,7 +5948,7 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( leafIndexArray[2] = parentLeafIndex + 1 + childDepthOffset * 2; leafIndexArray[3] = parentLeafIndex + 1 + childDepthOffset * 3; - + EB_BOOL exitPartition = EB_FALSE; EB_U64 cu16x16Cost = MAX_CU_COST; if (enableExitPartitioning) @@ -6000,10 +6000,10 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( // Set PF Mode - should be done per TU (and not per CU) to avoid the correction DerivePartialFrequencyN2Flag( pictureControlSetPtr, - contextPtr); + contextPtr); // Initialize Fast Loop - ProductCodingLoopInitFastLoop( // HT to be rechecked especially for fullCostArray + EbHevcProductCodingLoopInitFastLoop( // HT to be rechecked especially for fullCostArray contextPtr, contextPtr->intraLumaModeNeighborArray, contextPtr->skipFlagNeighborArray, @@ -6089,7 +6089,7 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( inputCbOriginIndex, cuOriginIndex, cuChromaOriginIndex, - MIN(fullCandidateTotalCount, bufferTotalCount)); // fullCandidateTotalCount to number of buffers to process + MIN(fullCandidateTotalCount, bufferTotalCount)); // fullCandidateTotalCount to number of buffers to process // Full Mode Decision (choose the best mode) candidateIndex = ProductFullModeDecision( @@ -6134,7 +6134,7 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( neighborLeafIndex = leafIndex; } - + if (enableExitPartitioning){ if (leafCount < 3 && totalChildCost > cu16x16Cost && lcuParams->isCompleteLcu) { @@ -6150,7 +6150,7 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( EB_U64 depthNPlusOneCost = 0; parentLeafIndex = (parentLeafIndex == (CU_MAX_COUNT - 1)) ? CU_MAX_COUNT - 5 : parentLeafIndex; - + SplitParentCu( contextPtr, lcuPtr, @@ -6168,9 +6168,9 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( lcuPtr->codedLeafArrayPtr[parentLeafIndex + 1 + childDepthOffset]->splitFlag = EB_FALSE; lcuPtr->codedLeafArrayPtr[parentLeafIndex + 1 + childDepthOffset * 2]->splitFlag = EB_FALSE; lcuPtr->codedLeafArrayPtr[parentLeafIndex + 1 + childDepthOffset * 3]->splitFlag = EB_FALSE; - + contextPtr->cu8x8RefinementOnFlag = EB_TRUE; - + } else { neighborLeafIndex = parentLeafIndex; @@ -6203,7 +6203,7 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( contextPtr->pillarReconBuffer : candidateBuffer->reconPtr ; - ModeDecisionUpdateNeighborArrays( + ModeDecisionUpdateNeighborArrays( contextPtr->leafDepthNeighborArray, contextPtr->modeTypeNeighborArray, contextPtr->intraLumaModeNeighborArray, @@ -6265,7 +6265,7 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( EB_U8 intraLumaMode = (EB_U8)(&contextPtr->cuPtr->predictionUnitArray[0])->intraLumaMode; EB_U8 skipFlag = (EB_U8)contextPtr->cuPtr->skipFlag; - Bdp16x16vs8x8RefinementUpdateNeighborArrays( + Bdp16x16vs8x8RefinementUpdateNeighborArrays( pictureControlSetPtr, contextPtr->leafDepthNeighborArray, @@ -6307,7 +6307,7 @@ EB_EXTERN EB_ERRORTYPE Bdp16x16vs8x8RefinementProcess( parentLeafIndex++; } - } + } return return_error; } @@ -6321,22 +6321,22 @@ EB_EXTERN EB_ERRORTYPE BdpMvMergePass( { EB_ERRORTYPE return_error = EB_ErrorNone; - // Input + // Input EbPictureBufferDesc_t *inputPicturePtr = pictureControlSetPtr->ParentPcsPtr->chromaDownSamplePicturePtr; // Mode Decision Candidate Buffers EB_U32 bufferTotalCount; ModeDecisionCandidateBuffer_t *candidateBuffer; ModeDecisionCandidateBuffer_t *bestCandidateBuffers[EB_MAX_LCU_DEPTH] = {NULL}; - - // Mode Decision Search Candidates + + // Mode Decision Search Candidates EB_U8 candidateIndex; EB_U32 fastCandidateTotalCount; EB_U32 fullCandidateTotalCount; EB_U32 secondFastCostSearchCandidateTotalCount; - // Pre Intra Search + // Pre Intra Search ModeDecisionCandidate_t *fastCandidateArray = contextPtr->fastCandidateArray; ModeDecisionCandidateBuffer_t **candidateBufferPtrArrayBase = contextPtr->candidateBufferPtrArray; @@ -6358,7 +6358,7 @@ EB_EXTERN EB_ERRORTYPE BdpMvMergePass( contextPtr->cbReconNeighborArray = pictureControlSetPtr->mdCbReconNeighborArray[MV_MERGE_PASS_NEIGHBOR_ARRAY_INDEX][tileIdx]; contextPtr->crReconNeighborArray = pictureControlSetPtr->mdCrReconNeighborArray[MV_MERGE_PASS_NEIGHBOR_ARRAY_INDEX][tileIdx]; - // First CU Loop + // First CU Loop EB_U8 leafIndex = 0; while (leafIndex < CU_MAX_COUNT) { @@ -6399,7 +6399,7 @@ EB_EXTERN EB_ERRORTYPE BdpMvMergePass( contextPtr); // Initialize Fast Loop - ProductCodingLoopInitFastLoop( // HT to be rechecked especially for fullCostArray + EbHevcProductCodingLoopInitFastLoop( // HT to be rechecked especially for fullCostArray contextPtr, contextPtr->intraLumaModeNeighborArray, contextPtr->skipFlagNeighborArray, @@ -6486,7 +6486,7 @@ EB_EXTERN EB_ERRORTYPE BdpMvMergePass( inputCbOriginIndex, cuOriginIndex, cuChromaOriginIndex, - MIN(fullCandidateTotalCount, bufferTotalCount)); // fullCandidateTotalCount to number of buffers to process + MIN(fullCandidateTotalCount, bufferTotalCount)); // fullCandidateTotalCount to number of buffers to process // Full Mode Decision (choose the best mode) candidateIndex = ProductFullModeDecision( @@ -6545,7 +6545,7 @@ EB_EXTERN EB_ERRORTYPE BdpMvMergePass( EB_U8 predictionModeFlag = (EB_U8)contextPtr->cuPtr->predictionModeFlag; EB_U8 intraLumaMode = (EB_U8)(&contextPtr->cuPtr->predictionUnitArray[0])->intraLumaMode; EB_U8 skipFlag = (EB_U8)contextPtr->cuPtr->skipFlag; - + MvMergePassUpdateNeighborArrays( pictureControlSetPtr, contextPtr->leafDepthNeighborArray, @@ -6636,4 +6636,3 @@ EB_EXTERN EB_ERRORTYPE BdpMvMergePass( } return return_error; } - diff --git a/Source/Lib/Codec/EbRateDistortionCost.c b/Source/Lib/Codec/EbRateDistortionCost.c index 0cd414e69..1a3c19f72 100644 --- a/Source/Lib/Codec/EbRateDistortionCost.c +++ b/Source/Lib/Codec/EbRateDistortionCost.c @@ -17,7 +17,7 @@ static const EB_U32 interBiDirBits[8] = { 29856, 36028, 15752, 59703, 8692, 8442 static const EB_U32 interUniDirBits[2] = { 2742, 136034 }; static const EB_U32 mvpIndexBits[2] = { 23196, 44891 }; -#define WEIGHT_FACTOR_FOR_AURA_CU 4 +#define WEIGHT_FACTOR_FOR_AURA_CU 4 EB_ERRORTYPE MergeSkipFullLumaCost( CodingUnit_t *cuPtr, @@ -289,7 +289,7 @@ EB_ERRORTYPE TuCalcCost( EB_ERRORTYPE TuCalcCostLuma( EB_U32 cuSize, ModeDecisionCandidate_t *candidatePtr, // input parameter, prediction result Ptr - EB_U32 tuIndex, // input parameter, TU index inside the CU + EB_U32 tuIndex, // input parameter, TU index inside the CU EB_U32 transformSize, EB_U32 yCountNonZeroCoeffs, // input parameter, number of non zero Y quantized coefficients EB_U64 yTuDistortion[DIST_CALC_TOTAL], // input parameter, Y distortion for both Normal and Cbf zero modes @@ -326,13 +326,13 @@ EB_ERRORTYPE TuCalcCostLuma( (void)qp; // **Compute distortion - // Non Zero Distortion - // *Note - As of Oct 2011, the JCT-VC uses the PSNR forumula + // Non Zero Distortion + // *Note - As of Oct 2011, the JCT-VC uses the PSNR forumula // PSNR = (LUMA_WEIGHT * PSNRy + PSNRu + PSNRv) / (2+LUMA_WEIGHT) yNonZeroCbfDistortion = LUMA_WEIGHT * (yNonZeroCbfDistortion << COST_PRECISION); // Zero distortion - // *Note - As of Oct 2011, the JCT-VC uses the PSNR forumula + // *Note - As of Oct 2011, the JCT-VC uses the PSNR forumula // PSNR = (LUMA_WEIGHT * PSNRy + PSNRu + PSNRv) / (2+LUMA_WEIGHT) yZeroCbfDistortion = LUMA_WEIGHT * (yZeroCbfDistortion << COST_PRECISION); @@ -476,7 +476,7 @@ struct ModeDecisionCandidateBuffer_s *candidateBufferPtr, candidateBufferPtr->residualLumaSad = lumaDistortion; // include luma only in total distortion - + lumaSad = (LUMA_WEIGHT * lumaDistortion) << COST_PRECISION; chromaSad = (((chromaDistortion * ChromaWeightFactorLd[qp]) + CHROMA_WEIGHT_OFFSET) >> CHROMA_WEIGHT_SHIFT); // Low delay and Random access have the same value of chroma weight totalDistortion = lumaSad + chromaSad; @@ -603,7 +603,7 @@ EB_ERRORTYPE Intra2Nx2NFastCostPsliceOpt( // Estimate Chroma Mode Bits chromaRate = 12368; // mdRateEstimationPtr->intraChromaBits[chromaMode]; - // Estimate Partition Size Bits + // Estimate Partition Size Bits lumaRate = contextPtr->cuStats->depth == 3 ? 31523 : ZERO_COST; // Estimate Pred Mode Bits @@ -935,7 +935,7 @@ EB_ERRORTYPE IntraFullCostPslice( *candidateBufferPtr->fullCostPtr = distortion + (((lambda * coeffRate + lambda * lumaRate + lambdaChroma * chromaRate) + MD_OFFSET) >> MD_SHIFT); candidateBufferPtr->fullLambdaRate = *candidateBufferPtr->fullCostPtr - distortion; - + (void)lcuPtr; coeffRate = (*yCoeffBits) << 15; @@ -1222,7 +1222,7 @@ EB_ERRORTYPE InterFastCostPsliceOpt( mvRefX = candidatePtr->motionVector_x_L0; mvRefY = candidatePtr->motionVector_y_L0; - + EB_S32 mvdX = EB_ABS_DIFF(predRefX, mvRefX); EB_S32 mvdY = EB_ABS_DIFF(predRefY, mvRefY); @@ -1233,8 +1233,8 @@ EB_ERRORTYPE InterFastCostPsliceOpt( lumaRate += mvBitTable[mvdX][mvdY]; lumaRate += mvpIndexBits[amvpIdx]; - - + + // *Note- store the fast rate to avoid the recomputation of the rate of each syntax element // the full cost module candidatePtr->fastLumaRate = lumaRate; @@ -1309,7 +1309,7 @@ EB_ERRORTYPE InterFastCostBsliceOpt( EB_ERRORTYPE return_error = EB_ErrorNone; ModeDecisionCandidate_t *candidatePtr = candidateBufferPtr->candidatePtr; // Luma rate - EB_U64 lumaRate; + EB_U64 lumaRate; EB_U64 distortion; // Luma and chroma distortion EB_U64 lumaSad, chromaSad; if (candidatePtr->mergeFlag == EB_TRUE){ @@ -1358,13 +1358,13 @@ EB_ERRORTYPE InterFastCostBsliceOpt( lumaRate = 86440; // mergeFlagBits + skipFlagBits + predModeBits + interPartSizeBits; lumaRate += interBiDirBits[(contextPtr->cuStats->depth << 1) + biPred]; - + if (predDirection < 2 && predDirection != BI_PRED) { - + lumaRate += interUniDirBits[predDirection]; if (predDirection == UNI_PRED_LIST_0){ - + amvpIdx = candidatePtr->motionVectorPredIdx[REF_LIST_0]; predRefX = candidatePtr->motionVectorPred_x[REF_LIST_0]; predRefY = candidatePtr->motionVectorPred_y[REF_LIST_0]; @@ -1389,10 +1389,10 @@ EB_ERRORTYPE InterFastCostBsliceOpt( mvdY = mvdY > 499 ? 499 : mvdY; lumaRate += mvBitTable[mvdX][mvdY]; lumaRate += mvpIndexBits[amvpIdx]; - + } else{ - + // LIST 0 Rate Estimation amvpIdx = candidatePtr->motionVectorPredIdx[REF_LIST_0]; predRefX = candidatePtr->motionVectorPred_x[REF_LIST_0]; @@ -1422,7 +1422,7 @@ EB_ERRORTYPE InterFastCostBsliceOpt( lumaRate += mvBitTable[mvdX][mvdY]; lumaRate += mvpIndexBits[amvpIdx]; - + } // *Note- store the fast rate to avoid the recomputation of the rate of each syntax element @@ -1508,7 +1508,7 @@ EB_ERRORTYPE EstimateTuFlags( tuPtr->splitFlag = EB_TRUE; tuPtr->cbCbf = EB_FALSE; tuPtr->crCbf = EB_FALSE; - tuPtr->chromaCbfContext = 0; //at TU level + tuPtr->chromaCbfContext = 0; //at TU level } else { tuTotalCount = 1; @@ -1529,7 +1529,7 @@ EB_ERRORTYPE EstimateTuFlags( tuPtr->lumaCbf = (EB_BOOL)(((candidatePtr->yCbf) & (1 << tuIndex)) > 0); tuPtr->cbCbf = (EB_BOOL)(((candidatePtr->cbCbf) & (1 << (tuIndex))) > 0); tuPtr->crCbf = (EB_BOOL)(((candidatePtr->crCbf) & (1 << (tuIndex))) > 0); - tuPtr->chromaCbfContext = (tuIndex == 0) ? 0 : (cuSizeLog2 - Log2f(tuSize)); //at TU level + tuPtr->chromaCbfContext = (tuIndex == 0) ? 0 : (cuSizeLog2 - Log2f(tuSize)); //at TU level tuPtr->lumaCbfContext = (cuSizeLog2 - Log2f(tuSize)) == 0 ? 1 : 0; if (tuPtr->cbCbf){ @@ -1554,7 +1554,7 @@ EB_ERRORTYPE EstimateTuFlags( subDivContext = 5 - Log2f(tuSize); if (cuSize != 64) { - // Encode split flag + // Encode split flag *tranSubDivFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->transSubDivFlagBits[(EB_U32)(tuPtr->splitFlag) * (NUMBER_OF_TRANSFORM_SUBDIV_FLAG_CASES >> 1) + subDivContext]; } @@ -1572,7 +1572,7 @@ EB_ERRORTYPE EstimateTuFlags( if (GetCodedUnitStats(cuPtr->leafIndex)->size != 8) { subDivContext = 5 - Log2f(tuSize); - // Encode split flag + // Encode split flag *tranSubDivFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->transSubDivFlagBits[(EB_U32)(tuPtr->splitFlag) * (NUMBER_OF_TRANSFORM_SUBDIV_FLAG_CASES >> 1) + subDivContext]; } @@ -1580,13 +1580,13 @@ EB_ERRORTYPE EstimateTuFlags( if (tuPtr->splitFlag) { cbfContext = tuPtr->chromaCbfContext; if ((cuPtr->transformUnitArray[0].cbCbf) != 0){ - // Cb CBF + // Cb CBF *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->cbCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; } if ((cuPtr->transformUnitArray[0].crCbf) != 0){ - // Cr CBF + // Cr CBF *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->crCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; @@ -1599,13 +1599,13 @@ EB_ERRORTYPE EstimateTuFlags( tuPtr = (tuIndexDepth2 < TRANSFORM_UNIT_MAX_COUNT) ? &cuPtr->transformUnitArray[tuIndexDepth2] : tuPtr; cbfContext = tuPtr->chromaCbfContext; - // Cb CBF + // Cb CBF if ((cuPtr->transformUnitArray[tuIndex].cbCbf) && (tuSize != 8)){ *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->cbCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; } - // Cr CBF + // Cr CBF if ((cuPtr->transformUnitArray[tuIndex].crCbf) && (tuSize != 8)){ *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->crCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; @@ -1619,13 +1619,13 @@ EB_ERRORTYPE EstimateTuFlags( tuIndexDepth2++; tuPtr = (tuIndexDepth2 < TRANSFORM_UNIT_MAX_COUNT) ? &cuPtr->transformUnitArray[tuIndexDepth2] : tuPtr; cbfContext = tuPtr->chromaCbfContext; - // Cb CBF + // Cb CBF if ((cuPtr->transformUnitArray[tuIndex].cbCbf) && (tuSize != 8)){ *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->cbCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; } - // Cr CBF + // Cr CBF if ((cuPtr->transformUnitArray[tuIndex].crCbf) && (tuSize != 8)){ *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->crCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; @@ -1641,13 +1641,13 @@ EB_ERRORTYPE EstimateTuFlags( tuPtr = (tuIndexDepth2 < TRANSFORM_UNIT_MAX_COUNT) ? &cuPtr->transformUnitArray[tuIndexDepth2] : tuPtr; cbfContext = tuPtr->chromaCbfContext; - // Cb CBF + // Cb CBF if ((cuPtr->transformUnitArray[tuIndex].cbCbf) && (tuSize != 8)){ *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->cbCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; } - // Cr CBF + // Cr CBF if ((cuPtr->transformUnitArray[tuIndex].crCbf) && (tuSize != 8)){ *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->crCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; @@ -1664,13 +1664,13 @@ EB_ERRORTYPE EstimateTuFlags( tuPtr = (tuIndexDepth2 < TRANSFORM_UNIT_MAX_COUNT) ? &cuPtr->transformUnitArray[tuIndexDepth2] : tuPtr; cbfContext = tuPtr->chromaCbfContext; - // Cb CBF + // Cb CBF if ((cuPtr->transformUnitArray[tuIndex].cbCbf) && (tuSize != 8)){ *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->cbCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; } - // Cr CBF + // Cr CBF if ((cuPtr->transformUnitArray[tuIndex].crCbf) && (tuSize != 8)){ *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->crCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; @@ -1687,13 +1687,13 @@ EB_ERRORTYPE EstimateTuFlags( cbfContext = tuPtr->chromaCbfContext; - // Cb CBF + // Cb CBF if ((cuPtr->transformUnitArray[0].cbCbf) && (tuSize != 8)){ *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->cbCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; } - // Cr CBF + // Cr CBF if ((cuPtr->transformUnitArray[0].crCbf) && (tuSize != 8)){ *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->crCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; @@ -1714,7 +1714,7 @@ EB_ERRORTYPE EstimateTuFlags( *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->cbCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; - // Cr CBF + // Cr CBF *cbfChromaFlagBitsNum += candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[(tuPtr->crCbf > 0) * (NUMBER_OF_CBF_CASES >> 1) + cbfContext]; @@ -2225,7 +2225,7 @@ EB_ERRORTYPE MergeSkipFullCost( cbfChromaFlagBitsNum += (crCbf > 0) ? candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[crCbfBlock * (NUMBER_OF_CBF_CASES >> 1) + chromaCbfCtx] : 0; cbfChromaFlagBitsNum += (cbCbf > 0) ? candidateBufferPtr->candidatePtr->mdRateEstimationPtr->chromaCbfBits[cbCbfBlock * (NUMBER_OF_CBF_CASES >> 1) + chromaCbfCtx] : 0; tuIndex += 1; - + } } else { @@ -2617,7 +2617,7 @@ EB_ERRORTYPE EncodeTuCalcCost( // Luma and chroma transform size shift for the distortion - + // **Compute distortion @@ -2681,13 +2681,13 @@ EB_ERRORTYPE EncodeTuCalcCost( return return_error; } -EB_U64 GetPMCost( - EB_U64 lambda, +EB_U64 EbHevcGetPMCost( + EB_U64 lambda, EB_U64 tuDistortion, - EB_U64 yTuCoeffBits + EB_U64 yTuCoeffBits ) { - + EB_U64 yNonZeroCbfDistortion = LUMA_WEIGHT * (tuDistortion << COST_PRECISION); EB_U64 yNonZeroCbfRate = (yTuCoeffBits ); EB_U64 yNonZeroCbfCost = yNonZeroCbfDistortion + (((lambda * yNonZeroCbfRate) + MD_OFFSET) >> MD_SHIFT); @@ -3145,7 +3145,7 @@ EB_ERRORTYPE IntraNxNFastCostIslice( candidateBufferPtr->residualLumaSad = lumaDistortion; totalDistortion = (LUMA_WEIGHT * (lumaDistortion + chromaDistortion)) << COST_PRECISION; - + // include luma only in rate calculation rate = ((lambda * (lumaRate + chromaRate)) + MD_OFFSET) >> MD_SHIFT; @@ -3232,7 +3232,7 @@ EB_ERRORTYPE IntraNxNFastCostPslice( // include luma only in total distortion totalDistortion = (LUMA_WEIGHT * (lumaDistortion + chromaDistortion)) << COST_PRECISION; - + // include luma only in rate calculation rate = ((lambda * (lumaRate + chromaRate)) + MD_OFFSET) >> MD_SHIFT; diff --git a/Source/Lib/Codec/EbReferenceObject.c b/Source/Lib/Codec/EbReferenceObject.c index f098abc20..1cfd81ed5 100644 --- a/Source/Lib/Codec/EbReferenceObject.c +++ b/Source/Lib/Codec/EbReferenceObject.c @@ -9,7 +9,7 @@ #include "EbPictureBufferDesc.h" #include "EbReferenceObject.h" -void InitializeSamplesNeighboringReferencePicture16Bit( +void EbHevcInitializeSamplesNeighboringReferencePicture16Bit( EB_BYTE reconSamplesBufferPtr, EB_U16 stride, EB_U16 reconWidth, @@ -25,9 +25,9 @@ void InitializeSamplesNeighboringReferencePicture16Bit( EB_MEMSET((EB_U8*)reconSamplesPtr, 0, sizeof(EB_U16)*(1 + reconWidth + 1)); // 2. Zero out the bottom row - reconSamplesPtr = (EB_U16*)reconSamplesBufferPtr + (topPadding + reconHeight) * stride + leftPadding - 1; + reconSamplesPtr = (EB_U16*)reconSamplesBufferPtr + (topPadding + reconHeight) * stride + leftPadding - 1; EB_MEMSET((EB_U8*)reconSamplesPtr, 0, sizeof(EB_U16)*(1 + reconWidth + 1)); - + // 3. Zero out the left column reconSamplesPtr = (EB_U16*)reconSamplesBufferPtr + topPadding * stride + leftPadding - 1; for (sampleCount = 0; sampleCount < reconHeight; sampleCount++) { @@ -41,7 +41,7 @@ void InitializeSamplesNeighboringReferencePicture16Bit( } } -void InitializeSamplesNeighboringReferencePicture8Bit( +void EbHevcInitializeSamplesNeighboringReferencePicture8Bit( EB_BYTE reconSamplesBufferPtr, EB_U16 stride, EB_U16 reconWidth, @@ -57,9 +57,9 @@ void InitializeSamplesNeighboringReferencePicture8Bit( EB_MEMSET(reconSamplesPtr, 0, sizeof(EB_U8)*(1 + reconWidth + 1)); // 2. Zero out the bottom row - reconSamplesPtr = reconSamplesBufferPtr + (topPadding + reconHeight) * stride + leftPadding - 1; + reconSamplesPtr = reconSamplesBufferPtr + (topPadding + reconHeight) * stride + leftPadding - 1; EB_MEMSET(reconSamplesPtr, 0, sizeof(EB_U8)*(1 + reconWidth + 1)); - + // 3. Zero out the left column reconSamplesPtr = reconSamplesBufferPtr + topPadding * stride + leftPadding - 1; for (sampleCount = 0; sampleCount < reconHeight; sampleCount++) { @@ -73,14 +73,14 @@ void InitializeSamplesNeighboringReferencePicture8Bit( } } -void InitializeSamplesNeighboringReferencePicture( +void EbHevcInitializeSamplesNeighboringReferencePicture( EbReferenceObject_t *referenceObject, EbPictureBufferDescInitData_t *pictureBufferDescInitDataPtr, EB_BITDEPTH bitDepth) { if (bitDepth == EB_10BIT){ - InitializeSamplesNeighboringReferencePicture16Bit( + EbHevcInitializeSamplesNeighboringReferencePicture16Bit( referenceObject->referencePicture16bit->bufferY, referenceObject->referencePicture16bit->strideY, referenceObject->referencePicture16bit->width, @@ -88,7 +88,7 @@ void InitializeSamplesNeighboringReferencePicture( pictureBufferDescInitDataPtr->leftPadding, pictureBufferDescInitDataPtr->topPadding); - InitializeSamplesNeighboringReferencePicture16Bit( + EbHevcInitializeSamplesNeighboringReferencePicture16Bit( referenceObject->referencePicture16bit->bufferCb, referenceObject->referencePicture16bit->strideCb, referenceObject->referencePicture16bit->width >> 1, @@ -96,7 +96,7 @@ void InitializeSamplesNeighboringReferencePicture( pictureBufferDescInitDataPtr->leftPadding >> 1, pictureBufferDescInitDataPtr->topPadding >> 1); - InitializeSamplesNeighboringReferencePicture16Bit( + EbHevcInitializeSamplesNeighboringReferencePicture16Bit( referenceObject->referencePicture16bit->bufferCr, referenceObject->referencePicture16bit->strideCr, referenceObject->referencePicture16bit->width >> 1, @@ -105,8 +105,8 @@ void InitializeSamplesNeighboringReferencePicture( pictureBufferDescInitDataPtr->topPadding >> 1); } else { - - InitializeSamplesNeighboringReferencePicture8Bit( + + EbHevcInitializeSamplesNeighboringReferencePicture8Bit( referenceObject->referencePicture->bufferY, referenceObject->referencePicture->strideY, referenceObject->referencePicture->width, @@ -114,7 +114,7 @@ void InitializeSamplesNeighboringReferencePicture( pictureBufferDescInitDataPtr->leftPadding, pictureBufferDescInitDataPtr->topPadding); - InitializeSamplesNeighboringReferencePicture8Bit( + EbHevcInitializeSamplesNeighboringReferencePicture8Bit( referenceObject->referencePicture->bufferCb, referenceObject->referencePicture->strideCb, referenceObject->referencePicture->width >> 1, @@ -122,7 +122,7 @@ void InitializeSamplesNeighboringReferencePicture( pictureBufferDescInitDataPtr->leftPadding >> 1, pictureBufferDescInitDataPtr->topPadding >> 1); - InitializeSamplesNeighboringReferencePicture8Bit( + EbHevcInitializeSamplesNeighboringReferencePicture8Bit( referenceObject->referencePicture->bufferCr, referenceObject->referencePicture->strideCr, referenceObject->referencePicture->width >> 1, @@ -135,12 +135,12 @@ void InitializeSamplesNeighboringReferencePicture( /***************************************** * EbPictureBufferDescCtor - * Initializes the Buffer Descriptor's + * Initializes the Buffer Descriptor's * values that are fixed for the life of * the descriptor. *****************************************/ EB_ERRORTYPE EbReferenceObjectCtor( - EB_PTR *objectDblPtr, + EB_PTR *objectDblPtr, EB_PTR objectInitDataPtr) { @@ -160,7 +160,7 @@ EB_ERRORTYPE EbReferenceObjectCtor( (EB_PTR*)&(referenceObject->referencePicture16bit), (EB_PTR)&pictureBufferDescInitData16BitPtr); - InitializeSamplesNeighboringReferencePicture( + EbHevcInitializeSamplesNeighboringReferencePicture( referenceObject, &pictureBufferDescInitData16BitPtr, pictureBufferDescInitData16BitPtr.bitDepth); @@ -172,7 +172,7 @@ EB_ERRORTYPE EbReferenceObjectCtor( (EB_PTR*)&(referenceObject->referencePicture), (EB_PTR)pictureBufferDescInitDataPtr); - InitializeSamplesNeighboringReferencePicture( + EbHevcInitializeSamplesNeighboringReferencePicture( referenceObject, pictureBufferDescInitDataPtr, pictureBufferDescInitData16BitPtr.bitDepth); @@ -184,7 +184,7 @@ EB_ERRORTYPE EbReferenceObjectCtor( - // Allocate LCU based TMVP map + // Allocate LCU based TMVP map EB_MALLOC(TmvpUnit_t *, referenceObject->tmvpMap, (sizeof(TmvpUnit_t) * (((pictureBufferDescInitDataPtr->maxWidth + (64 - 1)) >> 6) * ((pictureBufferDescInitDataPtr->maxHeight + (64 - 1)) >> 6))), EB_N_PTR); //RESTRICT THIS TO M4 @@ -194,7 +194,7 @@ EB_ERRORTYPE EbReferenceObjectCtor( bufDesc.maxWidth = pictureBufferDescInitDataPtr->maxWidth; bufDesc.maxHeight = pictureBufferDescInitDataPtr->maxHeight; bufDesc.bitDepth = EB_8BIT; - bufDesc.bufferEnableMask = PICTURE_BUFFER_DESC_FULL_MASK; + bufDesc.bufferEnableMask = PICTURE_BUFFER_DESC_FULL_MASK; bufDesc.leftPadding = pictureBufferDescInitDataPtr->leftPadding; bufDesc.rightPadding = pictureBufferDescInitDataPtr->rightPadding; bufDesc.topPadding = pictureBufferDescInitDataPtr->topPadding; @@ -207,19 +207,19 @@ EB_ERRORTYPE EbReferenceObjectCtor( (EB_PTR)&bufDesc); if (return_error == EB_ErrorInsufficientResources) return EB_ErrorInsufficientResources; - } + } return EB_ErrorNone; } /***************************************** * EbPaReferenceObjectCtor - * Initializes the Buffer Descriptor's + * Initializes the Buffer Descriptor's * values that are fixed for the life of * the descriptor. *****************************************/ EB_ERRORTYPE EbPaReferenceObjectCtor( - EB_PTR *objectDblPtr, + EB_PTR *objectDblPtr, EB_PTR objectInitDataPtr) { @@ -254,9 +254,6 @@ EB_ERRORTYPE EbPaReferenceObjectCtor( if (return_error == EB_ErrorInsufficientResources){ return EB_ErrorInsufficientResources; } - + return EB_ErrorNone; } - - - diff --git a/Source/Lib/Codec/EbResourceCoordinationProcess.c b/Source/Lib/Codec/EbResourceCoordinationProcess.c index 2b91fd016..7f90fa827 100644 --- a/Source/Lib/Codec/EbResourceCoordinationProcess.c +++ b/Source/Lib/Codec/EbResourceCoordinationProcess.c @@ -105,7 +105,7 @@ static void SpeedBufferControl( EB_S8 changeCond = 0; EB_S64 targetFps = (sequenceControlSetPtr->staticConfig.injectorFrameRate >> 16); - + EB_S64 bufferTrshold1 = SC_FRAMES_INTERVAL_T1; EB_S64 bufferTrshold2 = SC_FRAMES_INTERVAL_T2; EB_S64 bufferTrshold3 = SC_FRAMES_INTERVAL_T3; @@ -113,23 +113,23 @@ static void SpeedBufferControl( EbBlockOnMutex(sequenceControlSetPtr->encodeContextPtr->scBufferMutex); if (sequenceControlSetPtr->encodeContextPtr->scFrameIn == 0) { - EbStartTime((uint64_t*)&contextPtr->firstInPicArrivedTimeSeconds, (uint64_t*)&contextPtr->firstInPicArrivedTimeuSeconds); + EbHevcStartTime((uint64_t*)&contextPtr->firstInPicArrivedTimeSeconds, (uint64_t*)&contextPtr->firstInPicArrivedTimeuSeconds); } else if (sequenceControlSetPtr->encodeContextPtr->scFrameIn == SC_FRAMES_TO_IGNORE) { contextPtr->startFlag = EB_TRUE; } // Compute duration since the start of the encode and since the previous checkpoint - EbFinishTime((uint64_t*)&cursTimeSeconds, (uint64_t*)&cursTimeuSeconds); + EbHevcFinishTime((uint64_t*)&cursTimeSeconds, (uint64_t*)&cursTimeuSeconds); - EbComputeOverallElapsedTimeMs( + EbHevcComputeOverallElapsedTimeMs( contextPtr->firstInPicArrivedTimeSeconds, contextPtr->firstInPicArrivedTimeuSeconds, cursTimeSeconds, cursTimeuSeconds, &overallDuration); - EbComputeOverallElapsedTimeMs( + EbHevcComputeOverallElapsedTimeMs( contextPtr->prevsTimeSeconds, contextPtr->prevsTimeuSeconds, cursTimeSeconds, @@ -266,7 +266,7 @@ static EB_ERRORTYPE SignalDerivationPreAnalysisOq( PictureParentControlSet_t *pictureControlSetPtr) { EB_ERRORTYPE return_error = EB_ErrorNone; - + EB_U8 inputResolution = sequenceControlSetPtr->inputResolution; @@ -290,7 +290,7 @@ static EB_ERRORTYPE SignalDerivationPreAnalysisOq( else { pictureControlSetPtr->noiseDetectionMethod = NOISE_DETECT_FULL_PRECISION; } - + // Derive Noise Detection Threshold if (pictureControlSetPtr->encMode <= ENC_MODE_3) { @@ -393,7 +393,7 @@ void* ResourceCoordinationKernel(void *inputPtr) &ebInputWrapperPtr); EB_CHECK_END_OBJ(ebInputWrapperPtr); ebInputPtr = (EB_BUFFERHEADERTYPE*) ebInputWrapperPtr->objectPtr; - + sequenceControlSetPtr = contextPtr->sequenceControlSetInstanceArray[instanceIndex]->sequenceControlSetPtr; // Get source video bit depth @@ -439,9 +439,9 @@ void* ResourceCoordinationKernel(void *inputPtr) } else { vuiPtr->vuiTimeScale = (sequenceControlSetPtr->staticConfig.frameRate) > 1000 ? (sequenceControlSetPtr->staticConfig.frameRate) : (sequenceControlSetPtr->staticConfig.frameRate)<<16; - vuiPtr->vuiNumUnitsInTick = 1 << 16; + vuiPtr->vuiNumUnitsInTick = 1 << 16; } - + } // Get empty SequenceControlSet [BLOCKING] EbGetEmptyObject( @@ -472,7 +472,7 @@ void* ResourceCoordinationKernel(void *inputPtr) } // Set the current SequenceControlSet sequenceControlSetPtr = (SequenceControlSet_t*) contextPtr->sequenceControlSetActiveArray[instanceIndex]->objectPtr; - + //Move to pcs init stage //InitTileInfo(sequenceControlSetPtr); @@ -504,7 +504,7 @@ void* ResourceCoordinationKernel(void *inputPtr) pictureControlSetPtr->pPcsWrapperPtr = pictureControlSetWrapperPtr; // Set the Encoder mode - pictureControlSetPtr->encMode = sequenceControlSetPtr->staticConfig.encMode; + pictureControlSetPtr->encMode = sequenceControlSetPtr->staticConfig.encMode; // Keep track of the previous input for the ZZ SADs computation pictureControlSetPtr->previousPictureControlSetWrapperPtr = (contextPtr->sequenceControlSetInstanceArray[instanceIndex]->encodeContextPtr->initialPicture) ? @@ -524,7 +524,7 @@ void* ResourceCoordinationKernel(void *inputPtr) pictureControlSetPtr->startTimeSeconds = 0; pictureControlSetPtr->startTimeuSeconds = 0; - EbStartTime((uint64_t*)&pictureControlSetPtr->startTimeSeconds, (uint64_t*)&pictureControlSetPtr->startTimeuSeconds); + EbHevcStartTime((uint64_t*)&pictureControlSetPtr->startTimeSeconds, (uint64_t*)&pictureControlSetPtr->startTimeuSeconds); inputPicturePtr = pictureControlSetPtr->enhancedPicturePtr; @@ -549,7 +549,7 @@ void* ResourceCoordinationKernel(void *inputPtr) inputPicturePtr->strideBitIncY = inputPicturePtr->strideY; inputPicturePtr->strideBitIncCb = inputPicturePtr->strideCb; inputPicturePtr->strideBitIncCr = inputPicturePtr->strideCr; - + pictureControlSetPtr->ebInputPtr = ebInputPtr; pictureControlSetPtr->ebInputWrapperPtr = ebInputWrapperPtr; @@ -564,7 +564,7 @@ void* ResourceCoordinationKernel(void *inputPtr) pictureControlSetPtr->sceneChangeFlag = EB_FALSE; pictureControlSetPtr->qpOnTheFly = EB_FALSE; - + //pictureControlSetPtr->lcuTotalCount = sequenceControlSetPtr->lcuTotalCount; if (sequenceControlSetPtr->staticConfig.speedControlFlag) { @@ -581,12 +581,12 @@ void* ResourceCoordinationKernel(void *inputPtr) sequenceControlSetPtr->scdMode = sequenceControlSetPtr->staticConfig.sceneChangeDetection == 0 ? SCD_MODE_0 : SCD_MODE_1 ; - + SignalDerivationPreAnalysisOq( sequenceControlSetPtr, pictureControlSetPtr); - // Rate Control + // Rate Control // Set the ME Distortion and OIS Historgrams to zero if (sequenceControlSetPtr->staticConfig.rateControlMode){ EB_MEMSET(pictureControlSetPtr->meDistortionHistogram, 0, NUMBER_OF_SAD_INTERVALS*sizeof(EB_U16)); @@ -610,10 +610,10 @@ void* ResourceCoordinationKernel(void *inputPtr) #if DEADLOCK_DEBUG SVT_LOG("POC %lld RESCOOR IN \n", pictureControlSetPtr->pictureNumber); -#endif +#endif // Set the picture structure: 0: progressive, 1: top, 2: bottom - pictureControlSetPtr->pictStruct = sequenceControlSetPtr->interlacedVideo == EB_FALSE ? - PROGRESSIVE_PICT_STRUCT : + pictureControlSetPtr->pictStruct = sequenceControlSetPtr->interlacedVideo == EB_FALSE ? + PROGRESSIVE_PICT_STRUCT : pictureControlSetPtr->pictureNumber % 2 == 0 ? TOP_FIELD_PICT_STRUCT : BOTTOM_FIELD_PICT_STRUCT ; @@ -631,7 +631,7 @@ void* ResourceCoordinationKernel(void *inputPtr) EbObjectIncLiveCount( pictureControlSetPtr->paReferencePictureWrapperPtr, 2); - + EbObjectIncLiveCount( pictureControlSetWrapperPtr, 2); diff --git a/Source/Lib/Codec/EbSourceBasedOperationsProcess.c b/Source/Lib/Codec/EbSourceBasedOperationsProcess.c index fc2b6f631..c53257991 100644 --- a/Source/Lib/Codec/EbSourceBasedOperationsProcess.c +++ b/Source/Lib/Codec/EbSourceBasedOperationsProcess.c @@ -43,19 +43,19 @@ #define MIN_DELTA_QP_SHAPE_TH 1 #define MIN_BLACK_AREA_PERCENTAGE 20 -#define LOW_MEAN_TH_0 25 +#define LOW_MEAN_TH_0 25 #define MIN_WHITE_AREA_PERCENTAGE 1 -#define LOW_MEAN_TH_1 40 +#define LOW_MEAN_TH_1 40 #define HIGH_MEAN_TH 210 #define NORM_FACTOR 10 // Used ComplexityClassifier32x32 const EB_U32 THRESHOLD_NOISE[MAX_TEMPORAL_LAYERS] = { 33, 28, 27, 26, 26, 26 }; // [Temporal Layer Index] // Used ComplexityClassifier32x32 // Outlier removal threshold per depth {2%, 2%, 4%, 4%} -const EB_S8 MinDeltaQPdefault[3] = { +const EB_S8 EbHevcMinDeltaQPdefault[3] = { -4, -3, -2 }; -const EB_U8 MaxDeltaQPdefault[3] = { +const EB_U8 EbHevcMaxDeltaQPdefault[3] = { 4, 5, 6 }; @@ -88,7 +88,7 @@ static void DerivePictureActivityStatistics( { EB_U64 nonMovingIndexSum = 0; - + EB_U32 lcuIndex; EB_U32 zzSum = 0; @@ -210,7 +210,7 @@ static void FailingMotionLcu( sortedcuOisSAD = oisResultsPtr->sortedOisCandidate[rasterScanCuIndex][0].distortion; } - + EB_S64 meToOisSadDiff = (EB_S32)cuMeSAD - (EB_S32)sortedcuOisSAD; meToOisSadDeviation = (sortedcuOisSAD == 0) || (meToOisSadDiff < 0) ? 0 : (meToOisSadDiff * 100) / sortedcuOisSAD; @@ -277,7 +277,7 @@ static void DetectUncoveredLcu( sortedcuOisSAD = oisResultsPtr->sortedOisCandidate[rasterScanCuIndex][0].distortion; } - + EB_S64 meToOisSadDiff = (EB_S32)cuMeSAD - (EB_S32)sortedcuOisSAD; meToOisSadDeviation = (sortedcuOisSAD == 0) || (meToOisSadDiff < 0) ? 0 : (meToOisSadDiff * 100) / sortedcuOisSAD; @@ -592,7 +592,7 @@ static inline void DetermineIsolatedNonHomogeneousRegionInPicture( } } - // To determine current lcu is isolated non-homogeneous, at least 2 neighbors must be homogeneous + // To determine current lcu is isolated non-homogeneous, at least 2 neighbors must be homogeneous if (countOfHomogeneousNeighborLcus >= 2){ for (cuuIndex = 0; cuuIndex < 4; cuuIndex++) { @@ -617,16 +617,16 @@ static void SetDefaultDeltaQpRange( EB_S8 minDeltaQP; EB_U8 maxDeltaQP; if (pictureControlSetPtr->temporalLayerIndex == 0) { - minDeltaQP = MinDeltaQPdefault[0]; - maxDeltaQP = MaxDeltaQPdefault[0]; + minDeltaQP = EbHevcMinDeltaQPdefault[0]; + maxDeltaQP = EbHevcMaxDeltaQPdefault[0]; } else if (pictureControlSetPtr->isUsedAsReferenceFlag) { - minDeltaQP = MinDeltaQPdefault[1]; - maxDeltaQP = MaxDeltaQPdefault[1]; + minDeltaQP = EbHevcMinDeltaQPdefault[1]; + maxDeltaQP = EbHevcMaxDeltaQPdefault[1]; } else { - minDeltaQP = MinDeltaQPdefault[2]; - maxDeltaQP = MaxDeltaQPdefault[2]; + minDeltaQP = EbHevcMinDeltaQPdefault[2]; + maxDeltaQP = EbHevcMaxDeltaQPdefault[2]; } // Shape the min degrade @@ -716,7 +716,7 @@ static void DeriveHighDarkAreaDensityFlag( for (lumaHistogramBin = 0; lumaHistogramBin < LOW_MEAN_TH_1; lumaHistogramBin++){ // loop over the 1st LOW_MEAN_THLD bins blackSamplesCount += pictureControlSetPtr->pictureHistogram[regionInPictureWidthIndex][regionInPictureHeightIndex][0][lumaHistogramBin]; } - for (lumaHistogramBin = HIGH_MEAN_TH; lumaHistogramBin < HISTOGRAM_NUMBER_OF_BINS; lumaHistogramBin++){ + for (lumaHistogramBin = HIGH_MEAN_TH; lumaHistogramBin < HISTOGRAM_NUMBER_OF_BINS; lumaHistogramBin++){ whiteSamplesCount += pictureControlSetPtr->pictureHistogram[regionInPictureWidthIndex][regionInPictureHeightIndex][0][lumaHistogramBin]; } } @@ -754,17 +754,17 @@ static void TemporalHighContrastClassifier( EB_U32 nsad; EB_U32 meDist = 0; - if (pictureControlSetPtr->sliceType == EB_B_PICTURE){ + if (pictureControlSetPtr->sliceType == EB_B_PICTURE){ + - for (blkIt = 0; blkIt < 4; blkIt++) { - + nsad = ((EB_U32)pictureControlSetPtr->meResults[lcuIndex][1 + blkIt].distortionDirection[0].distortion) >> NORM_FACTOR; if (nsad >= nsadTable[pictureControlSetPtr->temporalLayerIndex] + thRes) meDist++; } - + } contextPtr->highDist = meDist>0 ? EB_TRUE : EB_FALSE; } @@ -788,7 +788,7 @@ static void SpatialHighContrastClassifier( EB_U16 var = pictureControlSetPtr->variance[lcuIndex][5 + blkIt]; - if (var>VAR_MIN && varVAR_MIN && varMIN_Y && ymean < MAX_Y && //medium brightness(not too dark and not too bright) ABS((EB_S64)umean - MID_CB) < TH_CB && //middle of the color plane ABS((EB_S64)vmean - MID_CR) < TH_CR //middle of the color plane @@ -978,14 +978,14 @@ static void DeriveBlockinessPresentFlag( lcuParamPtr->originY) && pictureControlSetPtr->nonMovingIndexArray[lcuIndex] != INVALID_ZZ_COST && pictureControlSetPtr->nonMovingIndexAverage != INVALID_ZZ_COST - + ) { - // Active LCU within an active scene (added a check on 4K & non-BASE to restrict the action - could be generated for all resolutions/layers) + // Active LCU within an active scene (added a check on 4K & non-BASE to restrict the action - could be generated for all resolutions/layers) if (pictureControlSetPtr->nonMovingIndexArray[lcuIndex] == LCU_COMPLEXITY_NON_MOVING_INDEX_TH_0 && pictureControlSetPtr->nonMovingIndexAverage >= LCU_COMPLEXITY_NON_MOVING_INDEX_TH_1 && pictureControlSetPtr->temporalLayerIndex > 0 && sequenceControlSetPtr->inputResolution == INPUT_SIZE_4K_RANGE) { pictureControlSetPtr->complexLcuArray[lcuIndex] = LCU_COMPLEXITY_STATUS_2; } - // Active LCU within a scene with a moderate acitivity (eg. active foregroud & static background) + // Active LCU within a scene with a moderate acitivity (eg. active foregroud & static background) else if (pictureControlSetPtr->nonMovingIndexArray[lcuIndex] == LCU_COMPLEXITY_NON_MOVING_INDEX_TH_0 && pictureControlSetPtr->nonMovingIndexAverage >= LCU_COMPLEXITY_NON_MOVING_INDEX_TH_2 && pictureControlSetPtr->nonMovingIndexAverage < LCU_COMPLEXITY_NON_MOVING_INDEX_TH_1) { pictureControlSetPtr->complexLcuArray[lcuIndex] = LCU_COMPLEXITY_STATUS_1; } @@ -1455,7 +1455,7 @@ void* SourceBasedOperationsKernel(void *inputPtr) contextPtr->crMeanPtr = crMeanPtr; contextPtr->cbMeanPtr = cbMeanPtr; - // Grass & Skin detection + // Grass & Skin detection GrassSkinLcu( contextPtr, sequenceControlSetPtr, @@ -1532,7 +1532,7 @@ void* SourceBasedOperationsKernel(void *inputPtr) contextPtr, pictureControlSetPtr); - // Delta QP range adjustments + // Delta QP range adjustments SetDefaultDeltaQpRange( contextPtr, pictureControlSetPtr); @@ -1563,7 +1563,7 @@ void* SourceBasedOperationsKernel(void *inputPtr) sequenceControlSetPtr, pictureControlSetPtr); - // Skin & Grass detection + // Skin & Grass detection GrassSkinPicture( contextPtr, pictureControlSetPtr); @@ -1574,7 +1574,7 @@ void* SourceBasedOperationsKernel(void *inputPtr) pictureControlSetPtr); - // Stationary edge over time (final stage) + // Stationary edge over time (final stage) if (!pictureControlSetPtr->endOfSequenceFlag && sequenceControlSetPtr->staticConfig.lookAheadDistance != 0) { StationaryEdgeOverUpdateOverTimeLcu( sequenceControlSetPtr, @@ -1689,9 +1689,9 @@ void* SourceBasedOperationsKernel(void *inputPtr) double latency = 0.0; EB_U64 finishTimeSeconds = 0; EB_U64 finishTimeuSeconds = 0; - EbFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); + EbHevcFinishTime((uint64_t*)&finishTimeSeconds, (uint64_t*)&finishTimeuSeconds); - EbComputeOverallElapsedTimeMs( + EbHevcComputeOverallElapsedTimeMs( pictureControlSetPtr->startTimeSeconds, pictureControlSetPtr->startTimeuSeconds, finishTimeSeconds, diff --git a/Source/Lib/Codec/EbString.c b/Source/Lib/Codec/EbString.c index 3f11e6f69..9e7a56607 100644 --- a/Source/Lib/Codec/EbString.c +++ b/Source/Lib/Codec/EbString.c @@ -50,7 +50,7 @@ static constraint_handler_t str_handler = NULL; void -eb_hevc_invoke_safe_str_constraint_handler(const char *msg, +EbHevcinvoke_safe_str_constraint_handler(const char *msg, void *ptr, errno_t error) { @@ -60,7 +60,7 @@ errno_t error) sl_default_handler(msg, ptr, error); } -void eb_hevc_ignore_handler_s(const char *msg, void *ptr, errno_t error) +void EbHevcignore_handler_s(const char *msg, void *ptr, errno_t error) { (void)msg; (void)ptr; @@ -71,26 +71,26 @@ void eb_hevc_ignore_handler_s(const char *msg, void *ptr, errno_t error) } errno_t -eb_hevc_strncpy_ss(char *dest, rsize_t dmax, const char *src, rsize_t slen) +EbHevcstrncpy_ss(char *dest, rsize_t dmax, const char *src, rsize_t slen) { rsize_t orig_dmax; char *orig_dest; const char *overlap_bumper; if (dest == NULL) { - eb_hevc_invoke_safe_str_constraint_handler("strncpy_ss: dest is null", + EbHevcinvoke_safe_str_constraint_handler("strncpy_ss: dest is null", NULL, ESNULLP); return RCNEGATE(ESNULLP); } if (dmax == 0) { - eb_hevc_invoke_safe_str_constraint_handler("strncpy_ss: dmax is 0", + EbHevcinvoke_safe_str_constraint_handler("strncpy_ss: dmax is 0", NULL, ESZEROL); return RCNEGATE(ESZEROL); } if (dmax > RSIZE_MAX_STR) { - eb_hevc_invoke_safe_str_constraint_handler("strncpy_ss: dmax exceeds max", + EbHevcinvoke_safe_str_constraint_handler("strncpy_ss: dmax exceeds max", NULL, ESLEMAX); return RCNEGATE(ESLEMAX); } @@ -100,21 +100,21 @@ eb_hevc_strncpy_ss(char *dest, rsize_t dmax, const char *src, rsize_t slen) orig_dest = dest; if (src == NULL) { - eb_hevc_handle_error(orig_dest, orig_dmax, (char*) ("strncpy_ss: " + EbHevchandle_error(orig_dest, orig_dmax, (char*) ("strncpy_ss: " "src is null"), ESNULLP); return RCNEGATE(ESNULLP); } if (slen == 0) { - eb_hevc_handle_error(orig_dest, orig_dmax, (char*)("strncpy_ss: " + EbHevchandle_error(orig_dest, orig_dmax, (char*)("strncpy_ss: " "slen is zero"), ESZEROL); return RCNEGATE(ESZEROL); } if (slen > RSIZE_MAX_STR) { - eb_hevc_handle_error(orig_dest, orig_dmax, (char*)("strncpy_ss: " + EbHevchandle_error(orig_dest, orig_dmax, (char*)("strncpy_ss: " "slen exceeds max"), ESLEMAX); return RCNEGATE(ESLEMAX); @@ -125,7 +125,7 @@ eb_hevc_strncpy_ss(char *dest, rsize_t dmax, const char *src, rsize_t slen) while (dmax > 0) { if (dest == overlap_bumper) { - eb_hevc_handle_error(orig_dest, orig_dmax, (char*)("strncpy_ss: " + EbHevchandle_error(orig_dest, orig_dmax, (char*)("strncpy_ss: " "overlapping objects"), ESOVRLP); return RCNEGATE(ESOVRLP); @@ -154,7 +154,7 @@ eb_hevc_strncpy_ss(char *dest, rsize_t dmax, const char *src, rsize_t slen) while (dmax > 0) { if (src == overlap_bumper) { - eb_hevc_handle_error(orig_dest, orig_dmax, (char*)( "strncpy_s: " + EbHevchandle_error(orig_dest, orig_dmax, (char*)( "strncpy_s: " "overlapping objects"), ESOVRLP); return RCNEGATE(ESOVRLP); @@ -182,40 +182,40 @@ eb_hevc_strncpy_ss(char *dest, rsize_t dmax, const char *src, rsize_t slen) /* * the entire src was not copied, so zero the string */ - eb_hevc_handle_error(orig_dest, orig_dmax, (char*)("strncpy_ss: not enough " + EbHevchandle_error(orig_dest, orig_dmax, (char*)("strncpy_ss: not enough " "space for src"), ESNOSPC); return RCNEGATE(ESNOSPC); } errno_t -eb_hevc_strcpy_ss(char *dest, rsize_t dmax, const char *src) +EbHevcstrcpy_ss(char *dest, rsize_t dmax, const char *src) { rsize_t orig_dmax; char *orig_dest; const char *overlap_bumper; if (dest == NULL) { - eb_hevc_invoke_safe_str_constraint_handler((char*)("strcpy_ss: dest is null"), + EbHevcinvoke_safe_str_constraint_handler((char*)("strcpy_ss: dest is null"), NULL, ESNULLP); return RCNEGATE(ESNULLP); } if (dmax == 0) { - eb_hevc_invoke_safe_str_constraint_handler((char*)("strcpy_ss: dmax is 0"), + EbHevcinvoke_safe_str_constraint_handler((char*)("strcpy_ss: dmax is 0"), NULL, ESZEROL); return RCNEGATE(ESZEROL); } if (dmax > RSIZE_MAX_STR) { - eb_hevc_invoke_safe_str_constraint_handler((char*)("strcpy_ss: dmax exceeds max"), + EbHevcinvoke_safe_str_constraint_handler((char*)("strcpy_ss: dmax exceeds max"), NULL, ESLEMAX); return RCNEGATE(ESLEMAX); } if (src == NULL) { *dest = '\0'; - eb_hevc_invoke_safe_str_constraint_handler((char*)("strcpy_ss: src is null"), + EbHevcinvoke_safe_str_constraint_handler((char*)("strcpy_ss: src is null"), NULL, ESNULLP); return RCNEGATE(ESNULLP); } @@ -231,7 +231,7 @@ eb_hevc_strcpy_ss(char *dest, rsize_t dmax, const char *src) while (dmax > 0) { if (dest == overlap_bumper) { - eb_hevc_handle_error(orig_dest, orig_dmax, (char*)("strcpy_ss: " + EbHevchandle_error(orig_dest, orig_dmax, (char*)("strcpy_ss: " "overlapping objects"), ESOVRLP); return RCNEGATE(ESOVRLP); @@ -250,7 +250,7 @@ eb_hevc_strcpy_ss(char *dest, rsize_t dmax, const char *src) while (dmax > 0) { if (src == overlap_bumper) { - eb_hevc_handle_error(orig_dest, orig_dmax, (char*)("strcpy_ss: " + EbHevchandle_error(orig_dest, orig_dmax, (char*)("strcpy_ss: " "overlapping objects"), ESOVRLP); return RCNEGATE(ESOVRLP); @@ -269,27 +269,27 @@ eb_hevc_strcpy_ss(char *dest, rsize_t dmax, const char *src) * the entire src must have been copied, if not reset dest * to null the string. */ - eb_hevc_handle_error(orig_dest, orig_dmax, (char*)("strcpy_ss: not " + EbHevchandle_error(orig_dest, orig_dmax, (char*)("strcpy_ss: not " "enough space for src"), ESNOSPC); return RCNEGATE(ESNOSPC); } rsize_t -eb_hevc_strnlen_ss(const char *dest, rsize_t dmax) +EbHevcstrnlen_ss(const char *dest, rsize_t dmax) { rsize_t count; if (dest == NULL) return RCNEGATE(0); if (dmax == 0) { - eb_hevc_invoke_safe_str_constraint_handler((char*)("strnlen_ss: dmax is 0"), + EbHevcinvoke_safe_str_constraint_handler((char*)("strnlen_ss: dmax is 0"), NULL, ESZEROL); return RCNEGATE(0); } if (dmax > RSIZE_MAX_STR) { - eb_hevc_invoke_safe_str_constraint_handler((char*)("strnlen_ss: dmax exceeds max"), + EbHevcinvoke_safe_str_constraint_handler((char*)("strnlen_ss: dmax exceeds max"), NULL, ESLEMAX); return RCNEGATE(0); } diff --git a/Source/Lib/Codec/EbString.h b/Source/Lib/Codec/EbString.h index 699ea9f04..f4e3e0e9d 100644 --- a/Source/Lib/Codec/EbString.h +++ b/Source/Lib/Codec/EbString.h @@ -122,47 +122,47 @@ typedef void(*constraint_handler_t) (const char * /* msg */, * Function used by the libraries to invoke the registered * runtime-constraint handler. Always needed. */ -extern void eb_hevc_invoke_safe_str_constraint_handler( +extern void EbHevcinvoke_safe_str_constraint_handler( const char *msg, void *ptr, errno_t error); -static inline void eb_hevc_handle_error(char *orig_dest, rsize_t orig_dmax, +static inline void EbHevchandle_error(char *orig_dest, rsize_t orig_dmax, char *err_msg, errno_t err_code) { (void)orig_dmax; *orig_dest = '\0'; - eb_hevc_invoke_safe_str_constraint_handler(err_msg, NULL, err_code); + EbHevcinvoke_safe_str_constraint_handler(err_msg, NULL, err_code); return; } -#define sl_default_handler eb_hevc_ignore_handler_s -extern void eb_hevc_ignore_handler_s(const char *msg, void *ptr, errno_t error); +#define sl_default_handler EbHevcignore_handler_s +extern void EbHevcignore_handler_s(const char *msg, void *ptr, errno_t error); /* string copy */ -errno_t eb_hevc_strcpy_ss( +errno_t EbHevcstrcpy_ss( char *dest, rsize_t dmax, const char *src); /* fitted string copy */ -errno_t eb_hevc_strncpy_ss( +errno_t EbHevcstrncpy_ss( char *dest, rsize_t dmax, const char *src, rsize_t slen); /* string length */ -rsize_t eb_hevc_strnlen_ss( +rsize_t EbHevcstrnlen_ss( const char *s, rsize_t smax); #define EB_STRNCPY(dst, dst_size, src, count) \ - eb_hevc_strncpy_ss(dst, dst_size, src, count) + EbHevcstrncpy_ss(dst, dst_size, src, count) #define EB_STRCPY(dst, size, src) \ - eb_hevc_strcpy_ss(dst, size, src) + EbHevcstrcpy_ss(dst, size, src) #define EB_STRCMP(target,token) \ strcmp(target,token) #define EB_STRLEN(target, max_size) \ - eb_hevc_strnlen_ss(target, max_size) + EbHevcstrnlen_ss(target, max_size) #ifdef __cplusplus } diff --git a/Source/Lib/Codec/EbTransforms.c b/Source/Lib/Codec/EbTransforms.c index 9ac0d7b55..3968ffbf3 100644 --- a/Source/Lib/Codec/EbTransforms.c +++ b/Source/Lib/Codec/EbTransforms.c @@ -98,9 +98,9 @@ EB_ERRORTYPE PmEstimateQuantCoeffChroma_SSE2( typedef EB_ERRORTYPE(*PM_RATE_EST_TYPE)( - CabacCost_t *CabacCost, + CabacCost_t *CabacCost, CabacEncodeContext_t *cabacEncodeCtxPtr, - EB_U32 size, + EB_U32 size, EB_MODETYPE type, // Input: CU type (INTRA, INTER) EB_U32 intraLumaMode, EB_U32 intraChromaMode, @@ -121,7 +121,7 @@ static PM_RATE_EST_TYPE FUNC_TABLE CoeffRateEst4x4_funcPtrArray[EB_ASM_TYPE_TOTA * function header *****************************/ -EB_U64 GetPMCost( +EB_U64 EbHevcGetPMCost( EB_U64 lambda, EB_U64 tuDistortion, EB_U64 yTuCoeffBits @@ -180,7 +180,7 @@ const EB_U8 ChromaQpMap[] = }; -EB_EXTERN EB_ALIGN(16) const EB_S16 TransformAsmConst[] = { +EB_EXTERN EB_ALIGN(16) const EB_S16 EbHevcTransformAsmConst[] = { 2, 0, 2, 0, 2, 0, 2, 0, 4, 0, 4, 0, 4, 0, 4, 0, 8, 0, 8, 0, 8, 0, 8, 0, @@ -949,7 +949,7 @@ static const EB_U16 MaskingMatrix32x32_Level2_1080p[] = { // Level3 -// 4K +// 4K // 4x4 static const EB_U16 MaskingMatrix4x4_Level3_4K[] = { M_100, M_90, M_0, M_0, @@ -1849,37 +1849,37 @@ static const EB_U16 MaskingMatrix32x32_4[] = { M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_080, M_080, M_080, M_080, M_080, M_080, M_080, M_080, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_080, M_080, M_080, M_080, M_080, M_080, M_080, M_080, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_080, M_080, M_080, M_080, M_080, M_080, M_080, M_080, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_090, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_080, M_080, M_080, M_080, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_080, M_080, M_080, M_080, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_080, M_080, M_080, M_080, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_080, M_080, M_080, M_080, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_080, M_080, M_080, M_080, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_080, M_080, M_080, M_080, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_080, M_080, M_080, M_080, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_080, M_080, M_080, M_080, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_070, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, @@ -1913,17 +1913,17 @@ static const EB_U16 MaskingMatrix16x16_5[] = { M_100, M_100, M_100, M_100, M_040, M_040, M_040, M_040, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, @@ -1935,37 +1935,37 @@ static const EB_U16 MaskingMatrix32x32_5[] = { M_100, M_100, M_100, M_100, M_060, M_060, M_060, M_060, M_040, M_040, M_040, M_040, M_040, M_040, M_040, M_040, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_050, M_050, M_050, M_050, M_040, M_040, M_040, M_040, M_040, M_040, M_040, M_040, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_050, M_050, M_050, M_050, M_040, M_040, M_040, M_040, M_040, M_040, M_040, M_040, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_060, M_060, M_050, M_050, M_050, M_050, M_050, M_050, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_060, M_060, M_050, M_050, M_050, M_050, M_050, M_050, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_060, M_060, M_050, M_050, M_050, M_050, M_050, M_050, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_060, M_060, M_050, M_050, M_050, M_050, M_050, M_050, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_040, M_040, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_040, M_040, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_040, M_040, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_040, M_040, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_040, M_040, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_040, M_040, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_040, M_040, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_040, M_040, M_040, M_040, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, @@ -2024,22 +2024,22 @@ static const EB_U16 MaskingMatrix32x32_6[] = { M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_100, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_100, M_100, M_100, M_100, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_100, M_100, M_100, M_100, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + + M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - M_025, M_025, M_025, M_025, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, - + M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, M_000, @@ -2120,10 +2120,10 @@ static const EB_U16 *MaskingMatrixSet2[8][4] = { MaskingMatrix4x4_1, MaskingMatrix8x8_1, MaskingMatrix16x16_1, MaskingMatrix32x32_2 }, { MaskingMatrix4x4_1, MaskingMatrix8x8_1, MaskingMatrix16x16_1, MaskingMatrix32x32_2 }, /************************* L45_SETTING *************************/ - { MaskingMatrix4x4_5, MaskingMatrix8x8_5, MaskingMatrix16x16_5, MaskingMatrix32x32_5}, + { MaskingMatrix4x4_5, MaskingMatrix8x8_5, MaskingMatrix16x16_5, MaskingMatrix32x32_5}, { MaskingMatrix4x4_6, MaskingMatrix8x8_6, MaskingMatrix16x16_6, MaskingMatrix32x32_6 }, /************************* L67_SETTING *************************/ - { MaskingMatrix4x4_5, MaskingMatrix8x8_5, MaskingMatrix16x16_5, MaskingMatrix32x32_5}, + { MaskingMatrix4x4_5, MaskingMatrix8x8_5, MaskingMatrix16x16_5, MaskingMatrix32x32_5}, { MaskingMatrix4x4_6, MaskingMatrix8x8_6, MaskingMatrix16x16_6, MaskingMatrix32x32_6 }, }; @@ -2192,7 +2192,7 @@ void MaskTransformCoeffs( SequenceControlSet_t *sequenceControlSetPtr = (SequenceControlSet_t*)pictureControlSetPtr->ParentPcsPtr->sequenceControlSetWrapperPtr->objectPtr; EB_U8 pmpMaskingClass = (sequenceControlSetPtr->inputResolution == INPUT_SIZE_4K_RANGE) ? 0 : 1; depthIndex = LOG2F(areaSize) - 2; - + depthIndex = depthIndex < 4 ? depthIndex : 0; MatMul_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][activeAreaSize >> 3]( @@ -2210,11 +2210,11 @@ void MaskTransformCoeffs( /********************************************************************* * PerformTwoStagePm * - * First phase (non-core): three different PM candidates are determined to be evaluated in the second phase. The PM candidates are distinct in term of VQ (i.e. the susceptibility to cause VQ artifact(s)), + * First phase (non-core): three different PM candidates are determined to be evaluated in the second phase. The PM candidates are distinct in term of VQ (i.e. the susceptibility to cause VQ artifact(s)), * and in term of bitrate (i.e. the capability to save bits). The PM candidates are constructed among pre-defined sets of matrices that are derived offline. - * Second stage (core), the provided PM candidates are evaluated based on the rate distortion optimization (RDO) metric and the best candidate is selected at a 4x4 block basis. - * In this process, each TU is divided into 4x4 blocks, and each 4x4 is evaluated with up to three masking matrices provided from the first phase. - * Weighting factors are used to bias the decisions based on HVS concepts like distance from DC, temporal layer and the block mode. + * Second stage (core), the provided PM candidates are evaluated based on the rate distortion optimization (RDO) metric and the best candidate is selected at a 4x4 block basis. + * In this process, each TU is divided into 4x4 blocks, and each 4x4 is evaluated with up to three masking matrices provided from the first phase. + * Weighting factors are used to bias the decisions based on HVS concepts like distance from DC, temporal layer and the block mode. *********************************************************************/ void PerformTwoStagePm( SequenceControlSet_t *sequenceControlSetPtr, @@ -2231,7 +2231,7 @@ void PerformTwoStagePm( const EB_S32 iq_offset, const EB_S32 shiftNum, EB_U32 areaSize, - const EB_U32 activeAreaSize, + const EB_U32 activeAreaSize, EB_U32 *yCountNonZeroCoeffs, EB_U8 pmpMaskingLevelEncDec, EB_MODETYPE type, @@ -2311,7 +2311,7 @@ void PerformTwoStagePm( EB_U32 alpha = ALPHA_1000; EB_U32 matrixBlkOffset = colBlkIter * 4 + (rowBlkIter * 4 * areaSize); - if (contextPtr->pmMode == PM_MODE_0){ // 4K + if (contextPtr->pmMode == PM_MODE_0){ // 4K MaskingMap4x4Ptr[0] = &MaskingMatrixSet0[pmpMaskingLevelEncDec][depthIndex][matrixBlkOffset]; MaskingMap4x4Ptr[1] = &MaskingMatrixSet1[pmpMaskingLevelEncDec][depthIndex][matrixBlkOffset]; MaskingMap4x4Ptr[2] = &maskingMatrixPtr[matrixBlkOffset]; @@ -2509,7 +2509,7 @@ void PerformTwoStagePm( { EbPMCand_t *pmCand = &pmCandBuffer[canDi]; - + //There is Mismatch between ASM vs C ! MatMulOut_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)]( &coeff[blkOffset], @@ -2560,22 +2560,22 @@ void PerformTwoStagePm( EB_U32 shift = 2 * (7 - Log2f(areaSize)); sse[DIST_CALC_RESIDUAL] = (sse[DIST_CALC_RESIDUAL] + (EB_U64)(1 << (shift - 1))) >> shift; - if (pmCand->nzCoeff) + if (pmCand->nzCoeff) CoeffRateEst4x4_funcPtrArray[!!(ASM_TYPES & PREAVX2_MASK)][componentType != COMPONENT_LUMA]( pictureControlSetPtr->cabacCost, NULL, 4, type, 0, - 0, + 0, pmCand->quCoeff, - PM_STRIDE, + PM_STRIDE, componentType, pmCand->nzCoeff, &coeffBits - ); + ); - pmCand->cost = GetPMCost( + pmCand->cost = EbHevcGetPMCost( (EB_U64)contextPtr->fullLambda*alpha*betta / 100 / 100, @@ -2632,7 +2632,7 @@ void DecoupledQuantizeInvQuantizeLoops( EB_U32 coeffLocation = 0; EB_U32 rowIndex, colIndex; - + EB_U32 adptive_qp_offset = q_offset; @@ -2799,9 +2799,9 @@ void DecoupledQuantizeInvQuantizeLoops( if (useRdoType == EB_PMCORE){ if (*nonzerocoeff && (componentType == COMPONENT_LUMA)){ - + #define NUM_PM_CANDIDATE 3 - + EB_U8 canDi; EB_U8 candCount = 0; EB_U64 bestCost = MAX_CU_COST; @@ -2833,7 +2833,7 @@ void DecoupledQuantizeInvQuantizeLoops( candCount = 0; bestCost = MAX_CU_COST; bestCand = 0; - + MaskingMap4x4Ptr[0] = &MaskingMatrix4x4_100[0]; MaskingMap4x4Ptr[1] = &MaskingMatrix4x4_70[0]; MaskingMap4x4Ptr[2] = &MaskingMatrix4x4_50[0]; @@ -2842,7 +2842,7 @@ void DecoupledQuantizeInvQuantizeLoops( pmCandBuffer[candCount++].maskingLevel = 1; pmCandBuffer[candCount++].maskingLevel = 2; - + // Loop over candidates for (canDi = 0; canDi < candCount; canDi++) @@ -3022,7 +3022,7 @@ void UnifiedQuantizeInvQuantize( //for the iQuant const EB_S32 shiftedFFunc = (qpPer > 8) ? (EB_S32)FFunc[qpRem] << (qpPer - 2) : (EB_S32)FFunc[qpRem] << qpPer; // this is 6+8+TRANS_BIT_INCREMENT const EB_S32 shiftNum = (qpPer > 8) ? QUANT_IQUANT_SHIFT - QUANT_SHIFT - transformShiftNum - 2 : QUANT_IQUANT_SHIFT - QUANT_SHIFT - transformShiftNum; - const EB_S32 iq_offset = 1 << (shiftNum - 1); + const EB_S32 iq_offset = 1 << (shiftNum - 1); DecoupledQuantizeInvQuantizeLoops( coeff, @@ -3122,7 +3122,7 @@ void UnifiedQuantizeInvQuantize( EB_U32 activeAreaSize = areaSize >> transCoeffShape; if (contextPtr->pmMethod && componentType != COMPONENT_LUMA) { - + if (pmpMaskingLevelEncDec) { MaskTransformCoeffs( @@ -3134,8 +3134,8 @@ void UnifiedQuantizeInvQuantize( pictureControlSetPtr, &(*yCountNonZeroCoeffs)); } - //QiQ SSSE3 is hardcoded - //QiQ Use this for SW + //QiQ SSSE3 is hardcoded + //QiQ Use this for SW QiQ_funcPtrArray[!!(ASM_TYPES & AVX2_MASK)][activeAreaSize >> 3]( coeff, coeffStride, @@ -3436,7 +3436,7 @@ EB_ERRORTYPE EncodeTransform( EB_U32 shift2nd = Log2f(transformSize) + 6; EB_S32 offset2nd = 1 << (shift2nd - 1); - + EB_S16 dcCoeff; EB_S32 dcCoeffTemp; dcCoeffTemp = (EB_S32)((64 * sumResidual + offset1st) >> shift1st); @@ -3519,12 +3519,12 @@ EB_ERRORTYPE EncodeInvTransform( EB_U32 shift1st = SHIFT_INV_1ST; EB_U32 shift2nd = SHIFT_INV_2ND - bitIncrement; - + EB_S32 offset1st = 1 << (shift1st - 1); EB_S32 offset2nd = 1 << (shift2nd - 1); EB_S16 invTranformedDcCoef; - + invTranformedDcCoef = (EB_S16) CLIP3(MIN_NEG_16BIT_NUM, MAX_POS_16BIT_NUM,((64 * dcCoef + offset1st) >> shift1st)); invTranformedDcCoef = (EB_S16) CLIP3(MIN_NEG_16BIT_NUM, MAX_POS_16BIT_NUM,((64 * invTranformedDcCoef + offset2nd) >> shift2nd)); @@ -3532,7 +3532,7 @@ EB_ERRORTYPE EncodeInvTransform( reconBuffer, reconStride, transformSize, - invTranformedDcCoef); + invTranformedDcCoef); } else @@ -3651,5 +3651,3 @@ void PfZeroOutUselessQuadrants( quadrantSize); } - - diff --git a/Source/Lib/Codec/EbUtility.c b/Source/Lib/Codec/EbUtility.c index f4f651286..95b903289 100644 --- a/Source/Lib/Codec/EbUtility.c +++ b/Source/Lib/Codec/EbUtility.c @@ -62,7 +62,7 @@ EB_ERRORTYPE ZOrderIncrement( * the true CU size, multiple the xLoc, yLoc * by the smallest CU size. *****************************************/ -void ZOrderIncrementWithLevel( +void EbHevcZOrderIncrementWithLevel( EB_U32 *xLoc, // x location, units of smallest block size EB_U32 *yLoc, // y location, units of smallest block size EB_U32 *level, // level, number of block size-steps from the smallest block size @@ -304,7 +304,7 @@ const TransformUnitStats_t* GetTransformUnitStats(const EB_U32 tuIdx) * Leading Zeros (NLZ) algorithm to get * the log2f of a 64-bit number *****************************************/ -inline EB_U64 Log2f64(EB_U64 x) +inline EB_U64 EbHevcLog2f64(EB_U64 x) { EB_U64 y; EB_S64 n = 64, c = 32; @@ -340,7 +340,7 @@ EB_U32 EndianSwap(EB_U32 ui) EB_U64 Log2fHighPrecision(EB_U64 x, EB_U8 precision) { - EB_U64 sigBitLocation = Log2f64(x); + EB_U64 sigBitLocation = EbHevcLog2f64(x); EB_U64 Remainder = x - ((EB_U64)1 << (EB_U8) sigBitLocation); EB_U64 result; @@ -377,7 +377,7 @@ const MiniGopStats_t* GetMiniGopStats(const EB_U32 miniGopIndex) { return &MiniGopStatsArray[miniGopIndex]; } -void EbStartTime(EB_U64 *Startseconds, EB_U64 *Startuseconds) +void EbHevcStartTime(EB_U64 *Startseconds, EB_U64 *Startuseconds) { #ifdef _WIN32 *Startseconds = (unsigned long long)clock(); @@ -390,7 +390,7 @@ void EbStartTime(EB_U64 *Startseconds, EB_U64 *Startuseconds) #endif } -void EbFinishTime(EB_U64 *Finishseconds, EB_U64 *Finishuseconds) +void EbHevcFinishTime(EB_U64 *Finishseconds, EB_U64 *Finishuseconds) { #ifdef _WIN32 *Finishseconds = (unsigned long long)clock(); @@ -403,7 +403,7 @@ void EbFinishTime(EB_U64 *Finishseconds, EB_U64 *Finishuseconds) #endif } -void EbComputeOverallElapsedTime(EB_U64 Startseconds, EB_U64 Startuseconds, EB_U64 Finishseconds, EB_U64 Finishuseconds, double *duration) +void EbHevcComputeOverallElapsedTime(EB_U64 Startseconds, EB_U64 Startuseconds, EB_U64 Finishseconds, EB_U64 Finishuseconds, double *duration) { #ifdef _WIN32 //double duration; @@ -421,7 +421,7 @@ void EbComputeOverallElapsedTime(EB_U64 Startseconds, EB_U64 Startuseconds, EB_U #endif } -void EbComputeOverallElapsedTimeMs(EB_U64 Startseconds, EB_U64 Startuseconds, EB_U64 Finishseconds, EB_U64 Finishuseconds, double *duration) +void EbHevcComputeOverallElapsedTimeMs(EB_U64 Startseconds, EB_U64 Startuseconds, EB_U64 Finishseconds, EB_U64 Finishuseconds, double *duration) { #ifdef _WIN32 //double duration; diff --git a/Source/Lib/Codec/EbUtility.h b/Source/Lib/Codec/EbUtility.h index 00910b992..d21e45f73 100644 --- a/Source/Lib/Codec/EbUtility.h +++ b/Source/Lib/Codec/EbUtility.h @@ -15,7 +15,7 @@ extern "C" { ****************************/ // CU Stats Helper Functions -typedef struct CodedUnitStats_s +typedef struct CodedUnitStats_s { EB_U8 depth; EB_U8 size; @@ -31,14 +31,14 @@ typedef struct CodedUnitStats_s typedef struct PredictionUnitStats_t { EB_U8 width; - EB_U8 height; + EB_U8 height; EB_U8 offsetX; EB_U8 offsetY; } PredictionUnitStats_t; // TU Stats Helper Functions -typedef struct TransformUnitStats_s +typedef struct TransformUnitStats_s { EB_U8 depth; EB_U8 offsetX; @@ -58,14 +58,14 @@ extern const TransformUnitStats_t* GetTransformUnitStats(const EB_U32 tuIdx); #define TU_SIZE_ADJUST(cuSize, tuDepth) ((cuSize) >> (tuDepth)) extern EB_ERRORTYPE ZOrderIncrement(EB_U32 *xLoc, EB_U32 *yLoc); -extern void ZOrderIncrementWithLevel( - EB_U32 *xLoc, - EB_U32 *yLoc, - EB_U32 *level, +extern void EbHevcZOrderIncrementWithLevel( + EB_U32 *xLoc, + EB_U32 *yLoc, + EB_U32 *level, EB_U32 *index); extern EB_U32 Log2f(EB_U32 x); -extern EB_U64 Log2f64(EB_U64 x); +extern EB_U64 EbHevcLog2f64(EB_U64 x); extern EB_U32 EndianSwap(EB_U32 ui); /**************************** @@ -151,7 +151,7 @@ extern EB_U32 EndianSwap(EB_U32 ui); #define TWO_D_INDEX(x, y, stride) \ (((y) * (stride)) + (x)) - + // MAX_CU_COUNT is used to find the total number of partitions for the max partition depth and for // each parent partition up to the root partition level (i.e. LCU level). @@ -199,10 +199,10 @@ typedef enum MINI_GOP_INDEX { L3_7_INDEX = 14 } MINI_GOP_INDEX; -void EbStartTime(EB_U64 *Startseconds, EB_U64 *Startuseconds); -void EbFinishTime(EB_U64 *Finishseconds, EB_U64 *Finishuseconds); -void EbComputeOverallElapsedTime(EB_U64 Startseconds, EB_U64 Startuseconds, EB_U64 Finishseconds, EB_U64 Finishuseconds, double *duration); -void EbComputeOverallElapsedTimeMs(EB_U64 Startseconds, EB_U64 Startuseconds, EB_U64 Finishseconds, EB_U64 Finishuseconds, double *duration); +void EbHevcStartTime(EB_U64 *Startseconds, EB_U64 *Startuseconds); +void EbHevcFinishTime(EB_U64 *Finishseconds, EB_U64 *Finishuseconds); +void EbHevcComputeOverallElapsedTime(EB_U64 Startseconds, EB_U64 Startuseconds, EB_U64 Finishseconds, EB_U64 Finishuseconds, double *duration); +void EbHevcComputeOverallElapsedTimeMs(EB_U64 Startseconds, EB_U64 Startuseconds, EB_U64 Finishseconds, EB_U64 Finishuseconds, double *duration); #ifdef __cplusplus } #endif