ur: refactors ur_bsr_bit* functions
@@ -1455,22 +1455,13 @@ ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out)
return ur_cue_gone;
}
else {
- uint8_t byt = bsr->bytes[0];
+ const uint8_t *b = bsr->bytes;
uint8_t off = bsr->off;
- uint8_t bit = (byt >> off) & 1;
+ uint8_t bit = (b[0] >> off) & 1;
if ( 7 == off ) {
- left--;
-
- if ( left ) {
- bsr->bytes++;
+ bsr->bytes = ( --left ) ? (b + 1) : 0;
bsr->left = left;
- }
- else {
- bsr->bytes = 0;
- bsr->left = 0;
- }
-
bsr->off = 0;
}
else {
@@ -1480,7 +1471,6 @@ ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out)
bsr->bits++;
*out = bit;
-
return ur_cue_good;
}
}
@@ -1496,22 +1486,13 @@ ur_bsr_bit_any(ur_bsr_t *bsr)
return 0;
}
else {
- uint8_t byt = bsr->bytes[0];
+ const uint8_t *b = bsr->bytes;
uint8_t off = bsr->off;
- uint8_t bit = (byt >> off) & 1;
+ uint8_t bit = (b[0] >> off) & 1;
if ( 7 == off ) {
- left--;
-
- if ( left ) {
- bsr->bytes++;
+ bsr->bytes = ( --left ) ? (b + 1) : 0;
bsr->left = left;
- }
- else {
- bsr->bytes = 0;
- bsr->left = 0;
- }
-
bsr->off = 0;
}
else {
