mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-19 10:02:45 -05:00
Some entropy decoder tweaks. Also removed unnecessary 'tmp' variables.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19008 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1e8be6f6b0
commit
7a835ee0c6
2 changed files with 17 additions and 24 deletions
|
|
@ -141,10 +141,13 @@ static inline void update_rice(struct rice_t* rice, int x)
|
||||||
|
|
||||||
if (rice->k == 0) {
|
if (rice->k == 0) {
|
||||||
rice->k = 1;
|
rice->k = 1;
|
||||||
} else if (rice->ksum < ((uint32_t)1 << (rice->k + 4))) {
|
} else {
|
||||||
rice->k--;
|
uint32_t lim = 1 << (rice->k + 4);
|
||||||
} else if (rice->ksum >= ((uint32_t)1 << (rice->k + 5))) {
|
if (rice->ksum < lim) {
|
||||||
rice->k++;
|
rice->k--;
|
||||||
|
} else if (rice->ksum >= 2 * lim) {
|
||||||
|
rice->k++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -178,7 +181,7 @@ static inline int entropy_decode3980(struct rice_t* rice)
|
||||||
base_hi = range_decode_culfreq((pivot >> lo_bits) + 1);
|
base_hi = range_decode_culfreq((pivot >> lo_bits) + 1);
|
||||||
range_decode_update(1, base_hi);
|
range_decode_update(1, base_hi);
|
||||||
|
|
||||||
base_lo = range_decode_culfreq(1 << lo_bits);
|
base_lo = range_decode_culshift(lo_bits);
|
||||||
range_decode_update(1, base_lo);
|
range_decode_update(1, base_lo);
|
||||||
|
|
||||||
base = (base_hi << lo_bits) + base_lo;
|
base = (base_hi << lo_bits) + base_lo;
|
||||||
|
|
|
||||||
|
|
@ -62,12 +62,9 @@ static int bytebufferoffset IBSS_ATTR;
|
||||||
|
|
||||||
static inline void skip_byte(void)
|
static inline void skip_byte(void)
|
||||||
{
|
{
|
||||||
if (bytebufferoffset) {
|
bytebufferoffset--;
|
||||||
bytebufferoffset--;
|
bytebuffer += bytebufferoffset & 4;
|
||||||
} else {
|
bytebufferoffset &= 3;
|
||||||
bytebufferoffset = 3;
|
|
||||||
bytebuffer += 4;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int read_byte(void)
|
static inline int read_byte(void)
|
||||||
|
|
@ -122,23 +119,17 @@ static inline void range_dec_normalize(void)
|
||||||
/* or: totf is (code_value)1<<shift */
|
/* or: totf is (code_value)1<<shift */
|
||||||
/* returns the culmulative frequency */
|
/* returns the culmulative frequency */
|
||||||
static inline int range_decode_culfreq(int tot_f)
|
static inline int range_decode_culfreq(int tot_f)
|
||||||
{ int tmp;
|
{
|
||||||
|
|
||||||
range_dec_normalize();
|
range_dec_normalize();
|
||||||
|
|
||||||
rc.help = rc.range / tot_f;
|
rc.help = rc.range / tot_f;
|
||||||
tmp = rc.low / rc.help;
|
return rc.low / rc.help;
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int range_decode_culshift(int shift)
|
static inline int range_decode_culshift(int shift)
|
||||||
{
|
{
|
||||||
int tmp;
|
|
||||||
range_dec_normalize();
|
range_dec_normalize();
|
||||||
rc.help = rc.range>>shift;
|
rc.help = rc.range >> shift;
|
||||||
tmp = rc.low/rc.help;
|
return rc.low / rc.help;
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -146,9 +137,8 @@ static inline int range_decode_culshift(int shift)
|
||||||
/* sy_f is the interval length (frequency of the symbol) */
|
/* sy_f is the interval length (frequency of the symbol) */
|
||||||
/* lt_f is the lower end (frequency sum of < symbols) */
|
/* lt_f is the lower end (frequency sum of < symbols) */
|
||||||
static inline void range_decode_update(int sy_f, int lt_f)
|
static inline void range_decode_update(int sy_f, int lt_f)
|
||||||
{ int tmp;
|
{
|
||||||
tmp = rc.help * lt_f;
|
rc.low -= rc.help * lt_f;
|
||||||
rc.low -= tmp;
|
|
||||||
rc.range = rc.help * sy_f;
|
rc.range = rc.help * sy_f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue