diff options
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -92,4 +92,11 @@ static int scalei_rem(int x, int srcmax, int dstmax, short *rem); __value [ax] \ __modify [ax cx dx si] +/** Sign extend x from b bits to 16. */ +static inline int16_t sign_extend(int16_t x, int b) +{ + int m = 16 - b; + return (x << m) >> m; +} + #endif |