[codec,avc] chroma reverse filter cutoff threshold

This commit is contained in:
akallabeth 2022-11-24 13:00:53 +01:00 committed by Norbert Federa
parent 860d002794
commit d768796163
4 changed files with 32 additions and 12 deletions

View File

@ -116,8 +116,10 @@ static pstatus_t general_ChromaFilter(BYTE* pDst[3], const UINT32 dstStep[3],
{ {
const UINT32 val2x = (x * 2); const UINT32 val2x = (x * 2);
const UINT32 val2x1 = val2x + 1; const UINT32 val2x1 = val2x + 1;
const INT32 up = pU[val2x] * 4; const BYTE inU = pU[val2x];
const INT32 vp = pV[val2x] * 4; const BYTE inV = pV[val2x];
const INT32 up = inU * 4;
const INT32 vp = inV * 4;
INT32 u2020; INT32 u2020;
INT32 v2020; INT32 v2020;
@ -126,8 +128,9 @@ static pstatus_t general_ChromaFilter(BYTE* pDst[3], const UINT32 dstStep[3],
u2020 = up - pU[val2x1] - pU1[val2x] - pU1[val2x1]; u2020 = up - pU[val2x1] - pU1[val2x] - pU1[val2x1];
v2020 = vp - pV[val2x1] - pV1[val2x] - pV1[val2x1]; v2020 = vp - pV[val2x1] - pV1[val2x] - pV1[val2x1];
pU[val2x] = CLIP(u2020);
pV[val2x] = CLIP(v2020); pU[val2x] = CONDITIONAL_CLIP(u2020, inU);
pV[val2x] = CONDITIONAL_CLIP(v2020, inV);
} }
} }

View File

@ -515,8 +515,10 @@ static pstatus_t neon_ChromaFilter(BYTE* pDst[3], const UINT32 dstStep[3], const
{ {
const UINT32 val2x = (x * 2); const UINT32 val2x = (x * 2);
const UINT32 val2x1 = val2x + 1; const UINT32 val2x1 = val2x + 1;
const INT32 up = pU[val2x] * 4; const BYTE inU = pU[val2x];
const INT32 vp = pV[val2x] * 4; const BYTE inV = pV[val2x];
const INT32 up = inU * 4;
const INT32 vp = inV * 4;
INT32 u2020; INT32 u2020;
INT32 v2020; INT32 v2020;
@ -525,8 +527,8 @@ static pstatus_t neon_ChromaFilter(BYTE* pDst[3], const UINT32 dstStep[3], const
u2020 = up - pU[val2x1] - pU1[val2x] - pU1[val2x1]; u2020 = up - pU[val2x1] - pU1[val2x] - pU1[val2x1];
v2020 = vp - pV[val2x1] - pV1[val2x] - pV1[val2x1]; v2020 = vp - pV[val2x1] - pV1[val2x] - pV1[val2x1];
pU[val2x] = CLIP(u2020); pU[val2x] = CONDITIONAL_CLIP(u2020, inU);
pV[val2x] = CLIP(v2020); pV[val2x] = CONDITIONAL_CLIP(v2020, inV);
} }
} }

View File

@ -1192,8 +1192,10 @@ static pstatus_t ssse3_ChromaFilter(BYTE* pDst[3], const UINT32 dstStep[3], cons
{ {
const UINT32 val2x = (x * 2); const UINT32 val2x = (x * 2);
const UINT32 val2x1 = val2x + 1; const UINT32 val2x1 = val2x + 1;
const INT32 up = pU[val2x] * 4; const BYTE inU = pU[val2x];
const INT32 vp = pV[val2x] * 4; const BYTE inV = pV[val2x];
const INT32 up = inU * 4;
const INT32 vp = inV * 4;
INT32 u2020; INT32 u2020;
INT32 v2020; INT32 v2020;
@ -1202,8 +1204,8 @@ static pstatus_t ssse3_ChromaFilter(BYTE* pDst[3], const UINT32 dstStep[3], cons
u2020 = up - pU[val2x1] - pU1[val2x] - pU1[val2x1]; u2020 = up - pU[val2x1] - pU1[val2x] - pU1[val2x1];
v2020 = vp - pV[val2x1] - pV1[val2x] - pV1[val2x1]; v2020 = vp - pV[val2x1] - pV1[val2x] - pV1[val2x1];
pU[val2x] = CLIP(u2020); pU[val2x] = CONDITIONAL_CLIP(u2020, inU);
pV[val2x] = CLIP(v2020); pV[val2x] = CONDITIONAL_CLIP(v2020, inV);
} }
} }

View File

@ -209,6 +209,19 @@ static INLINE BYTE CLIP(INT64 X)
return (BYTE)X; return (BYTE)X;
} }
static INLINE BYTE CONDITIONAL_CLIP(INT32 in, BYTE original)
{
BYTE out = CLIP(in);
BYTE diff;
if (out > original)
diff = out - original;
else
diff = original - out;
if (diff < 30)
return original;
return out;
}
/** /**
* | R | ( | 256 0 403 | | Y | ) * | R | ( | 256 0 403 | | Y | )
* | G | = ( | 256 -48 -120 | | U - 128 | ) >> 8 * | G | = ( | 256 -48 -120 | | U - 128 | ) >> 8