summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-11-04 23:46:04 +0000
committerJens Arnold <amiconn@rockbox.org>2008-11-04 23:46:04 +0000
commit7a835ee0c64bb941f205a2eb915cf0aaf460f1bc (patch)
treefc06dddecf13ed3e83ae2061bb1921f372b5fb75
parent1e8be6f6b05f6cbe64ce47c8d7a7cd93cf1d1c80 (diff)
downloadrockbox-7a835ee0c64bb941f205a2eb915cf0aaf460f1bc.tar.gz
rockbox-7a835ee0c64bb941f205a2eb915cf0aaf460f1bc.zip
Some entropy decoder tweaks. Also removed unnecessary 'tmp' variables.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19008 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/demac/libdemac/entropy.c13
-rw-r--r--apps/codecs/demac/libdemac/rangecoding.h28
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
63static inline void skip_byte(void) 63static 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
73static inline int read_byte(void) 70static 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 */
124static inline int range_decode_culfreq(int tot_f) 121static 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
135static inline int range_decode_culshift(int shift) 128static 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) */
148static inline void range_decode_update(int sy_f, int lt_f) 139static 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