Showing the changes to codec/processing/src/adaptivequantization/AdaptiveQuantization.cpp (1 of 85 files). Show all
Unified · Split
| @@ -142,8 +142,8 @@ EResult CAdaptiveQuantization::Process (int32_t iType, SPixMap* pSrcPixMap, SPix · 141 unmodified lines | |||
| 142 | pCurFrameY += (iCurStride) << 4; | 142 | pCurFrameY += (iCurStride) << 4; |
| 143 | } | 143 | } |
| 144 | } | 144 | } |
| 145 | iAverageMotionIndex = WELS_DIV_ROUND64(iAverageMotionIndex * AQ_INT_MULTIPLY,iMbTotalNum); | 145 | iAverageMotionIndex = WELS_DIV_ROUND64 (iAverageMotionIndex * AQ_INT_MULTIPLY, iMbTotalNum); |
| 146 | iAverageTextureIndex = WELS_DIV_ROUND64(iAverageTextureIndex * AQ_INT_MULTIPLY, iMbTotalNum); | 146 | iAverageTextureIndex = WELS_DIV_ROUND64 (iAverageTextureIndex * AQ_INT_MULTIPLY, iMbTotalNum); |
| 147 | if ((iAverageMotionIndex <= AQ_PESN) && (iAverageMotionIndex >= -AQ_PESN)) { | 147 | if ((iAverageMotionIndex <= AQ_PESN) && (iAverageMotionIndex >= -AQ_PESN)) { |
| 148 | iAverageMotionIndex = AQ_INT_MULTIPLY; | 148 | iAverageMotionIndex = AQ_INT_MULTIPLY; |
| 149 | } | 149 | } |
| @@ -153,34 +153,37 @@ EResult CAdaptiveQuantization::Process (int32_t iType, SPixMap* pSrcPixMap, SPix · 3 unmodified lines | |||
| 153 | // motion mb residual map to QP | 153 | // motion mb residual map to QP |
| 154 | // texture mb original map to QP | 154 | // texture mb original map to QP |
| 155 | iAverMotionTextureIndexToDeltaQp = 0; | 155 | iAverMotionTextureIndexToDeltaQp = 0; |
| 156 | iAverageMotionIndex = WELS_DIV_ROUND64(AVERAGE_TIME_MOTION * iAverageMotionIndex, AQ_TIME_INT_MULTIPLY); | 156 | iAverageMotionIndex = WELS_DIV_ROUND64 (AVERAGE_TIME_MOTION * iAverageMotionIndex, AQ_TIME_INT_MULTIPLY); |
| 157 | 157 | ||
| 158 | if (m_sAdaptiveQuantParam.iAdaptiveQuantMode == AQ_QUALITY_MODE) { | 158 | if (m_sAdaptiveQuantParam.iAdaptiveQuantMode == AQ_QUALITY_MODE) { |
| 159 | iAverageTextureIndex = WELS_DIV_ROUND64(AVERAGE_TIME_TEXTURE_QUALITYMODE * iAverageTextureIndex, AQ_TIME_INT_MULTIPLY); | 159 | iAverageTextureIndex = WELS_DIV_ROUND64 (AVERAGE_TIME_TEXTURE_QUALITYMODE * iAverageTextureIndex, AQ_TIME_INT_MULTIPLY); |
| 160 | } else { | 160 | } else { |
| 161 | iAverageTextureIndex = WELS_DIV_ROUND64(AVERAGE_TIME_TEXTURE_BITRATEMODE * iAverageTextureIndex, AQ_TIME_INT_MULTIPLY); | 161 | iAverageTextureIndex = WELS_DIV_ROUND64 (AVERAGE_TIME_TEXTURE_BITRATEMODE * iAverageTextureIndex, AQ_TIME_INT_MULTIPLY); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | int64_t iAQ_EPSN = -((int64_t)AQ_PESN*AQ_TIME_INT_MULTIPLY*AQ_QSTEP_INT_MULTIPLY/AQ_INT_MULTIPLY); | 164 | int64_t iAQ_EPSN = - ((int64_t)AQ_PESN * AQ_TIME_INT_MULTIPLY * AQ_QSTEP_INT_MULTIPLY / AQ_INT_MULTIPLY); |
| 165 | pMotionTexture = m_sAdaptiveQuantParam.pMotionTextureUnit; | 165 | pMotionTexture = m_sAdaptiveQuantParam.pMotionTextureUnit; |
| 166 | for (j = 0; j < iMbHeight; j ++) { | 166 | for (j = 0; j < iMbHeight; j ++) { |
| 167 | for (i = 0; i < iMbWidth; i++) { | 167 | for (i = 0; i < iMbWidth; i++) { |
| 168 | int64_t a = WELS_DIV_ROUND64((int64_t)(pMotionTexture->uiTextureIndex) *AQ_INT_MULTIPLY * AQ_TIME_INT_MULTIPLY, iAverageTextureIndex); | 168 | int64_t a = WELS_DIV_ROUND64 ((int64_t) (pMotionTexture->uiTextureIndex) * AQ_INT_MULTIPLY * AQ_TIME_INT_MULTIPLY, |
| 169 | iQStep = WELS_DIV_ROUND64((a - AQ_TIME_INT_MULTIPLY) * AQ_QSTEP_INT_MULTIPLY, (a + MODEL_ALPHA)); | 169 | iAverageTextureIndex); |
| 170 | iQStep = WELS_DIV_ROUND64 ((a - AQ_TIME_INT_MULTIPLY) * AQ_QSTEP_INT_MULTIPLY, (a + MODEL_ALPHA)); | ||
| 170 | iLumaTextureDeltaQp = MODEL_TIME * iQStep;// range +- 6 | 171 | iLumaTextureDeltaQp = MODEL_TIME * iQStep;// range +- 6 |
| 171 | 172 | ||
| 172 | iMotionTextureIndexToDeltaQp = ((int32_t)(iLumaTextureDeltaQp/(AQ_TIME_INT_MULTIPLY))); | 173 | iMotionTextureIndexToDeltaQp = ((int32_t) (iLumaTextureDeltaQp / (AQ_TIME_INT_MULTIPLY))); |
| 173 | 174 | ||
| 174 | a = WELS_DIV_ROUND64(((int64_t)pMotionTexture->uiMotionIndex)*AQ_INT_MULTIPLY * AQ_TIME_INT_MULTIPLY, iAverageMotionIndex); | 175 | a = WELS_DIV_ROUND64 (((int64_t)pMotionTexture->uiMotionIndex) * AQ_INT_MULTIPLY * AQ_TIME_INT_MULTIPLY, |
| 175 | iQStep = WELS_DIV_ROUND64((a - AQ_TIME_INT_MULTIPLY) * AQ_QSTEP_INT_MULTIPLY, (a + MODEL_ALPHA)); | 176 | iAverageMotionIndex); |
| 177 | iQStep = WELS_DIV_ROUND64 ((a - AQ_TIME_INT_MULTIPLY) * AQ_QSTEP_INT_MULTIPLY, (a + MODEL_ALPHA)); | ||
| 176 | iLumaMotionDeltaQp = MODEL_TIME * iQStep;// range +- 6 | 178 | iLumaMotionDeltaQp = MODEL_TIME * iQStep;// range +- 6 |
| 177 | 179 | ||
| 178 | if ((m_sAdaptiveQuantParam.iAdaptiveQuantMode == AQ_QUALITY_MODE && iLumaMotionDeltaQp < iAQ_EPSN) | 180 | if ((m_sAdaptiveQuantParam.iAdaptiveQuantMode == AQ_QUALITY_MODE && iLumaMotionDeltaQp < iAQ_EPSN) |
| 179 | || (m_sAdaptiveQuantParam.iAdaptiveQuantMode == AQ_BITRATE_MODE)) { | 181 | || (m_sAdaptiveQuantParam.iAdaptiveQuantMode == AQ_BITRATE_MODE)) { |
| 180 | iMotionTextureIndexToDeltaQp += ((int32_t)(iLumaMotionDeltaQp/(AQ_TIME_INT_MULTIPLY))); | 182 | iMotionTextureIndexToDeltaQp += ((int32_t) (iLumaMotionDeltaQp / (AQ_TIME_INT_MULTIPLY))); |
| 181 | } | 183 | } |
| 182 | 184 | ||
| 183 | m_sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[j * iMbWidth + i] = (int8_t)(iMotionTextureIndexToDeltaQp/AQ_QSTEP_INT_MULTIPLY); | 185 | m_sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[j * iMbWidth + i] = (int8_t) (iMotionTextureIndexToDeltaQp / |
| 186 | AQ_QSTEP_INT_MULTIPLY); | ||
| 184 | iAverMotionTextureIndexToDeltaQp += iMotionTextureIndexToDeltaQp; | 187 | iAverMotionTextureIndexToDeltaQp += iMotionTextureIndexToDeltaQp; |
| 185 | pMotionTexture++; | 188 | pMotionTexture++; |
| 186 | } | 189 | } |