summaryrefslogtreecommitdiff
path: root/libavcodec/vp3.c
diff options
context:
space:
mode:
authorPeter Ross <pross@xvid.org>2019-06-08 10:55:51 +1000
committerPeter Ross <pross@xvid.org>2019-06-12 20:06:20 +1000
commita212c8da48fea89bff3e26324aef257e5663233e (patch)
treea99a5f9f76fb19d470e776bad436ec3f266177be /libavcodec/vp3.c
parent442375fee7f1fb15e42fbc128dc38bdfcc2cc105 (diff)
avcodec/vp3: spin off get_eob_run and get_coeff coeff functions
these reoutines are shared by vp3 and vp4.
Diffstat (limited to 'libavcodec/vp3.c')
-rw-r--r--libavcodec/vp3.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 63f60c9109..65aa0f353c 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -931,6 +931,30 @@ static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb)
return 0;
}
+static inline int get_eob_run(GetBitContext *gb, int token)
+{
+ int v = eob_run_table[token].base;
+ if (eob_run_table[token].bits)
+ v += get_bits(gb, eob_run_table[token].bits);
+ return v;
+}
+
+static inline int get_coeff(GetBitContext *gb, int token, int16_t *coeff)
+{
+ int bits_to_get, zero_run;
+
+ bits_to_get = coeff_get_bits[token];
+ if (bits_to_get)
+ bits_to_get = get_bits(gb, bits_to_get);
+ *coeff = coeff_tables[token][bits_to_get];
+
+ zero_run = zero_run_base[token];
+ if (zero_run_get_bits[token])
+ zero_run += get_bits(gb, zero_run_get_bits[token]);
+
+ return zero_run;
+}
+
/*
* This function is called by unpack_dct_coeffs() to extract the VLCs from
* the bitstream. The VLCs encode tokens which are used to unpack DCT
@@ -952,7 +976,6 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
int token;
int zero_run = 0;
int16_t coeff = 0;
- int bits_to_get;
int blocks_ended;
int coeff_i = 0;
int num_coeffs = s->num_coded_frags[plane][coeff_index];
@@ -988,10 +1011,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
token = get_vlc2(gb, vlc_table, 11, 3);
/* use the token to get a zero run, a coefficient, and an eob run */
if ((unsigned) token <= 6U) {
- eob_run = eob_run_table[token].base;
- if (eob_run_table[token].bits)
- eob_run += get_bits(gb, eob_run_table[token].bits);
-
+ eob_run = get_eob_run(gb, token);
if (!eob_run)
eob_run = INT_MAX;
@@ -1009,14 +1029,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
eob_run = 0;
}
} else if (token >= 0) {
- bits_to_get = coeff_get_bits[token];
- if (bits_to_get)
- bits_to_get = get_bits(gb, bits_to_get);
- coeff = coeff_tables[token][bits_to_get];
-
- zero_run = zero_run_base[token];
- if (zero_run_get_bits[token])
- zero_run += get_bits(gb, zero_run_get_bits[token]);
+ zero_run = get_coeff(gb, token, &coeff);
if (zero_run) {
dct_tokens[j++] = TOKEN_ZERO_RUN(coeff, zero_run);