diff options
Diffstat (limited to 'apps/codecs/demac/libdemac')
-rw-r--r-- | apps/codecs/demac/libdemac/entropy.c | 13 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/rangecoding.h | 28 |
2 files changed, 17 insertions, 24 deletions
diff --git a/apps/codecs/demac/libdemac/entropy.c b/apps/codecs/demac/libdemac/entropy.c index 1ef5bc4dc1..86ea06d389 100644 --- a/apps/codecs/demac/libdemac/entropy.c +++ b/apps/codecs/demac/libdemac/entropy.c | |||
@@ -141,10 +141,13 @@ static inline void update_rice(struct rice_t* rice, int x) | |||
141 | 141 | ||
142 | if (rice->k == 0) { | 142 | if (rice->k == 0) { |
143 | rice->k = 1; | 143 | rice->k = 1; |
144 | } else if (rice->ksum < ((uint32_t)1 << (rice->k + 4))) { | 144 | } else { |
145 | rice->k--; | 145 | uint32_t lim = 1 << (rice->k + 4); |
146 | } else if (rice->ksum >= ((uint32_t)1 << (rice->k + 5))) { | 146 | if (rice->ksum < lim) { |
147 | rice->k++; | 147 | rice->k--; |
148 | } else if (rice->ksum >= 2 * lim) { | ||
149 | rice->k++; | ||
150 | } | ||
148 | } | 151 | } |
149 | } | 152 | } |
150 | 153 | ||
@@ -178,7 +181,7 @@ static inline int entropy_decode3980(struct rice_t* rice) | |||
178 | base_hi = range_decode_culfreq((pivot >> lo_bits) + 1); | 181 | base_hi = range_decode_culfreq((pivot >> lo_bits) + 1); |
179 | range_decode_update(1, base_hi); | 182 | range_decode_update(1, base_hi); |
180 | 183 | ||
181 | base_lo = range_decode_culfreq(1 << lo_bits); | 184 | base_lo = range_decode_culshift(lo_bits); |
182 | range_decode_update(1, base_lo); | 185 | range_decode_update(1, base_lo); |
183 | 186 | ||
184 | base = (base_hi << lo_bits) + base_lo; | 187 | base = (base_hi << lo_bits) + base_lo; |
diff --git a/apps/codecs/demac/libdemac/rangecoding.h b/apps/codecs/demac/libdemac/rangecoding.h index 9c26344ec5..c96886e32b 100644 --- a/apps/codecs/demac/libdemac/rangecoding.h +++ b/apps/codecs/demac/libdemac/rangecoding.h | |||
@@ -62,12 +62,9 @@ static int bytebufferoffset IBSS_ATTR; | |||
62 | 62 | ||
63 | static inline void skip_byte(void) | 63 | static inline void skip_byte(void) |
64 | { | 64 | { |
65 | if (bytebufferoffset) { | 65 | bytebufferoffset--; |
66 | bytebufferoffset--; | 66 | bytebuffer += bytebufferoffset & 4; |
67 | } else { | 67 | bytebufferoffset &= 3; |
68 | bytebufferoffset = 3; | ||
69 | bytebuffer += 4; | ||
70 | } | ||
71 | } | 68 | } |
72 | 69 | ||
73 | static inline int read_byte(void) | 70 | static inline int read_byte(void) |
@@ -122,23 +119,17 @@ static inline void range_dec_normalize(void) | |||
122 | /* or: totf is (code_value)1<<shift */ | 119 | /* or: totf is (code_value)1<<shift */ |
123 | /* returns the culmulative frequency */ | 120 | /* returns the culmulative frequency */ |
124 | static inline int range_decode_culfreq(int tot_f) | 121 | static inline int range_decode_culfreq(int tot_f) |
125 | { int tmp; | 122 | { |
126 | |||
127 | range_dec_normalize(); | 123 | range_dec_normalize(); |
128 | |||
129 | rc.help = rc.range / tot_f; | 124 | rc.help = rc.range / tot_f; |
130 | tmp = rc.low / rc.help; | 125 | return rc.low / rc.help; |
131 | |||
132 | return tmp; | ||
133 | } | 126 | } |
134 | 127 | ||
135 | static inline int range_decode_culshift(int shift) | 128 | static inline int range_decode_culshift(int shift) |
136 | { | 129 | { |
137 | int tmp; | ||
138 | range_dec_normalize(); | 130 | range_dec_normalize(); |
139 | rc.help = rc.range>>shift; | 131 | rc.help = rc.range >> shift; |
140 | tmp = rc.low/rc.help; | 132 | return rc.low / rc.help; |
141 | return tmp; | ||
142 | } | 133 | } |
143 | 134 | ||
144 | 135 | ||
@@ -146,9 +137,8 @@ static inline int range_decode_culshift(int shift) | |||
146 | /* sy_f is the interval length (frequency of the symbol) */ | 137 | /* sy_f is the interval length (frequency of the symbol) */ |
147 | /* lt_f is the lower end (frequency sum of < symbols) */ | 138 | /* lt_f is the lower end (frequency sum of < symbols) */ |
148 | static inline void range_decode_update(int sy_f, int lt_f) | 139 | static inline void range_decode_update(int sy_f, int lt_f) |
149 | { int tmp; | 140 | { |
150 | tmp = rc.help * lt_f; | 141 | rc.low -= rc.help * lt_f; |
151 | rc.low -= tmp; | ||
152 | rc.range = rc.help * sy_f; | 142 | rc.range = rc.help * sy_f; |
153 | } | 143 | } |
154 | 144 | ||