From 0b28d7ab08969db8e186d2143790276682efd59b Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 9 Oct 2013 11:43:19 +0200 Subject: [PATCH] use a macrofunc for setting NzCoeffs bits (avoids code dup) Change-Id: I776f065538e562673ca08f3bc43c7167d13254d9 --- src/dec/vp8.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dec/vp8.c b/src/dec/vp8.c index 6612d137..91337db4 100644 --- a/src/dec/vp8.c +++ b/src/dec/vp8.c @@ -500,6 +500,12 @@ static int GetCoeffs(VP8BitReader* const br, const VP8BandProbas* const prob, return 16; } +static WEBP_INLINE uint32_t NzCodeBits(uint32_t nz_coeffs, int nz, int dc_nz) { + nz_coeffs <<= 2; + nz_coeffs |= (nz > 3) ? 3 : (nz > 1) ? 2 : dc_nz; + return nz_coeffs; +} + static int ParseResiduals(VP8Decoder* const dec, VP8MB* const mb, VP8BitReader* const token_br) { VP8BandProbas (* const bands)[NUM_BANDS] = dec->proba_.bands_; @@ -545,10 +551,7 @@ static int ParseResiduals(VP8Decoder* const dec, const int nz = GetCoeffs(token_br, ac_proba, ctx, q->y1_mat_, first, dst); l = (nz > first); tnz = (tnz >> 1) | (l << 7); - nz_coeffs <<= 2; - if (nz > 3) nz_coeffs |= 3; - else if (nz > 1) nz_coeffs |= 2; - else if (dst[0] != 0) nz_coeffs |= 1; + nz_coeffs = NzCodeBits(nz_coeffs, nz, dst[0] != 0); dst += 16; } tnz >>= 4; @@ -569,10 +572,7 @@ static int ParseResiduals(VP8Decoder* const dec, const int nz = GetCoeffs(token_br, bands[2], ctx, q->uv_mat_, 0, dst); l = (nz > 0); tnz = (tnz >> 1) | (l << 3); - nz_coeffs <<= 2; - if (nz > 3) nz_coeffs |= 3; - else if (nz > 1) nz_coeffs |= 2; - else if (dst[0] != 0) nz_coeffs |= 1; + nz_coeffs = NzCodeBits(nz_coeffs, nz, dst[0] != 0); dst += 16; } tnz >>= 2;