Last active
September 8, 2022 09:14
-
-
Save 3outeille/310cc7f707b3324e7f5c7bfdfa482618 to your computer and use it in GitHub Desktop.
fg_compute_block_avg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int16_t fg_compute_block_avg(int16_t *dstSampleBlk8, uint32_t widthComp, uint16_t *pNumSamples, | |
uint8_t ySize, uint8_t xSize, uint8_t bitDepth) | |
{ | |
uint32_t blockAvg = 0; | |
uint16_t numSamples = 0; | |
uint8_t k, l; | |
for (k = 0; k < ySize; k++) | |
{ | |
for (l = 0; l < xSize; l++) | |
{ | |
blockAvg += dstSampleBlk8[(k*widthComp)+l]; | |
numSamples++; | |
} | |
} | |
if (numSamples > 0) | |
{ | |
blockAvg /= numSamples; | |
blockAvg >>= (bitDepth - 8); /* to handle high bit depths */ | |
} | |
*pNumSamples = numSamples; | |
blockAvg = (int16_t) ov_clip_uintp2(blockAvg, 8 ); | |
return blockAvg; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment