diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2018-09-22 18:13:59 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2018-09-24 00:49:30 +0200 |
commit | d3a9cb6bc870063ab0e79241f3e51c94613b6c03 (patch) | |
tree | 6815b9685bc7d5ec07f4752c5b0c9e78ffe0259f | |
parent | f24701b073ca5381ad1ca5d7c1ccec30c3104cf6 (diff) | |
download | ffmpeg-d3a9cb6bc870063ab0e79241f3e51c94613b6c03.tar.gz |
avcodec/prosumer: Factorize the 2 loops in fill_elements()
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/prosumer.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c index cf2a4afbf6..46031aa0c0 100644 --- a/libavcodec/prosumer.c +++ b/libavcodec/prosumer.c @@ -282,29 +282,24 @@ static void fill_elements(uint32_t idx, uint32_t shift, int size, uint32_t *e0, { uint32_t b, h = idx << (32 - shift); - for (int i = 0; i < size; i++) { - b = 4 * (table[2 * i + 1] & 0xF); - if (shift >= b && (h & (0xFFF00000u << (12 - b))) == (table[2 * i + 1] & 0xFFFF0000u)) { - if (table[2 * i] >> 8 == 0x80u) { - return; - } else { - *e1 = table[2 * i]; - *e0 = (*e0 & 0xFFFFFFu) | (((12 + b - shift) & 0xFFFFFFFCu | 0x40u) << 22); - shift -= b; - h <<= b; - break; - } - } - } - for (int i = 0; i < size; i++) { - b = 4 * (table[2 * i + 1] & 0xF); - if (shift >= b && (h & (0xFFF00000u << (12 - b))) == (table[2 * i + 1] & 0xFFFF0000u)) { - if (table[2 * i] >> 8 == 0x80u) { - return; - } else { - *e1 |= table[2 * i] << 16; - *e0 = (*e0 & 0xFFFFFFu) | (((12 + b - shift) & 0xFFFFFFFCu | 0x80u) << 22); - break; + for (int j = 0; j < 2; j++) { + for (int i = 0; i < size; i++) { + b = 4 * (table[2 * i + 1] & 0xF); + if (shift >= b && (h & (0xFFF00000u << (12 - b))) == (table[2 * i + 1] & 0xFFFF0000u)) { + if (table[2 * i] >> 8 == 0x80u) { + return; + } else { + if (j == 0) { + *e1 = table[2 * i]; + *e0 = (*e0 & 0xFFFFFFu) | (((12 + b - shift) & 0xFFFFFFFCu | 0x40u) << 22); + shift -= b; + h <<= b; + } else { + *e1 |= table[2 * i] << 16; + *e0 = (*e0 & 0xFFFFFFu) | (((12 + b - shift) & 0xFFFFFFFCu | 0x80u) << 22); + } + break; + } } } } |