aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-12 01:47:34 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-12 03:06:57 +0100
commite3618cd4a805a6260ac516105206391bfab6a319 (patch)
tree607857877a334c5c59725df5e4495dcd14c780ea /libavcodec
parent35fd7b2968834c5994bfd2a93edfbf0dea5e667e (diff)
downloadffmpeg-e3618cd4a805a6260ac516105206391bfab6a319.tar.gz
vble: remove vble_read_reverse_unary(), the code is a bit simpler this way
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/vble.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/libavcodec/vble.c b/libavcodec/vble.c
index 5f78e6a198..41d78dc6cd 100644
--- a/libavcodec/vble.c
+++ b/libavcodec/vble.c
@@ -38,8 +38,9 @@ typedef struct {
uint8_t *val;
} VBLEContext;
-static uint8_t vble_read_reverse_unary(GetBitContext *gb)
+static int vble_unpack(VBLEContext *ctx, GetBitContext *gb)
{
+ int i;
static const uint8_t LUT[256] = {
8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
@@ -50,33 +51,23 @@ static uint8_t vble_read_reverse_unary(GetBitContext *gb)
6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
};
- /* At most we need to read 9 bits total to get indices up to 8 */
- int val = show_bits(gb, 8);
-
- if (val) {
- val = LUT[val];
- skip_bits(gb, val + 1);
- return val;
- } else {
- skip_bits(gb, 8);
- if (get_bits1(gb))
- return 8;
- }
-
- /* Return something larger than 8 on error */
- return UINT8_MAX;
-}
-
-static int vble_unpack(VBLEContext *ctx, GetBitContext *gb)
-{
- int i;
/* Read all the lengths in first */
for (i = 0; i < ctx->size; i++) {
- ctx->len[i] = vble_read_reverse_unary(gb);
-
- if (ctx->len[i] == UINT8_MAX)
- return -1;
+ /* At most we need to read 9 bits total to get indices up to 8 */
+ int val = show_bits(gb, 8);
+
+ // read reverse unary
+ if (val) {
+ val = LUT[val];
+ skip_bits(gb, val + 1);
+ ctx->len[i] = val;
+ } else {
+ skip_bits(gb, 8);
+ if (!get_bits1(gb))
+ return -1;
+ ctx->len[i] = 8;
+ }
}
/* For any values that have length 0 */