Skip to content

Commit e9d5cc6

Browse files
committed
Micro optimization
1 parent 4aca6a6 commit e9d5cc6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/entropy/AdaptiveProbMap.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ namespace kanzi {
7070

7171
// Return interpolated probabibility
7272
const uint16 w = uint16(pr & 127);
73-
return int(_data[_index] * (128 - w) + _data[_index + 1] * w) >> 11;
73+
return ((_data[_index] << 7) +
74+
(int(_data[_index + 1]) - int(_data[_index])) * int(w)) >> 11;
7475
}
7576

7677

@@ -120,7 +121,8 @@ namespace kanzi {
120121

121122
// Return interpolated probabibility
122123
const uint16 w = uint16(pr & 127);
123-
return int(_data[_index] * (128 - w) + _data[_index + 1] * w) >> 11;
124+
return ((_data[_index] << 7) +
125+
(int(_data[_index + 1]) - int(_data[_index])) * int(w)) >> 11;
124126
} else {
125127
_index = ((Global::stretch(pr) + 2048) >> 7) + 32 * ctx;
126128
return int(_data[_index]) >> 4;

0 commit comments

Comments
 (0)