ref: 6b949925658e01e06a52c95d58d16bfc31d11912
parent: 440860780f767ae6af42ae2c9f49bcca46b6ceeb
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Jul 14 07:58:00 EDT 2021
inline small functions
--- a/minih264e.h
+++ b/minih264e.h
@@ -5729,32 +5729,9 @@
#if H264E_ENABLE_PLAIN_C
-static uint8_t byteclip_deblock(int x)
-{
- if (x > 255)
- {
- return 255;
- }
- if (x < 0)
- {
- return 0;
- }
- return (uint8_t)x;
-}
+#define byteclip(x) ((x) > 255 ? 255 : ((x) < 0 ? 0 : (x)))
+#define clip_range(range, src) ((src) > (range) ? (range) : ((src) < -range ? -(range) : (src)))
-static int clip_range(int range, int src)
-{
- if (src > range)
- {
- src = range;
- }
- if (src < -range)
- {
- src = -range;
- }
- return src;
-}
-
static void deblock_chroma(uint8_t *pix, int stride, int alpha, int beta, int thr, int strength)
{
int p1, p0, q0, q1;
@@ -5780,8 +5757,8 @@
int tC = thr + 1;
delta = (((q0 - p0)*4) + (p1 - q1) + 4) >> 3;
delta = clip_range(tC, delta);
- pix[-1*stride] = byteclip_deblock(p0 + delta);
- pix[ 0*stride] = byteclip_deblock(q0 - delta);
+ pix[-1*stride] = byteclip(p0 + delta);
+ pix[ 0*stride] = byteclip(q0 - delta);
} else
{
pix[-1*stride] = (pix_t)((2*p1 + p0 + q1 + 2) >> 2);
@@ -5827,8 +5804,8 @@
pix[ 1] = (pix_t)(q1 + d2);
tC = thr - sp - sq;
delta = clip_range(tC, delta);
- pix[-1] = byteclip_deblock(p0 + delta);
- pix[ 0] = byteclip_deblock(q0 - delta);
+ pix[-1] = byteclip(p0 + delta);
+ pix[ 0] = byteclip(q0 - delta);
}
pix += stride;
} while (--cloop);
@@ -5973,8 +5950,8 @@
tC = thr - sp - sq;
delta = clip_range(tC, delta);
- pix[-1*stride] = byteclip_deblock(p0 + delta);
- pix[ 0*stride] = byteclip_deblock(q0 - delta);
+ pix[-1*stride] = byteclip(p0 + delta);
+ pix[ 0*stride] = byteclip(q0 - delta);
}
pix += 1;
} while (--cloop);
@@ -6508,13 +6485,6 @@
return best_m + (best_sad << 4);
}
-static uint8_t byteclip(int x)
-{
- if (x > 255) x = 255;
- if (x < 0) x = 0;
- return (uint8_t)x;
-}
-
static int hpel_lpf(const uint8_t *p, int s)
{
return p[0] - 5*p[s] + 20*p[2*s] + 20*p[3*s] - 5*p[4*s] + p[5*s];
@@ -6800,18 +6770,6 @@
#define UNZIGSAG_IN_QUANT 0
#define SUM_DIF(a, b) { int t = a + b; b = a - b; a = t; }
-static int clip_byte(int x)
-{
- if (x > 255)
- {
- x = 255;
- } else if (x < 0)
- {
- x = 0;
- }
- return x;
-}
-
static void hadamar4_2d(int16_t *x)
{
int s = 1;
@@ -7212,7 +7170,7 @@
for (i = 0; i < 4; i++)
{
int Value = q->dq[j * 4 + i] + pred[j * 16 + i];
- out[j * out_stride + i] = (pix_t)clip_byte(Value);
+ out[j * out_stride + i] = (pix_t)byteclip(Value);
}
}
}