summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/cfhd.c57
1 files changed, 21 insertions, 36 deletions
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 0acbbeb69c..657f8caf22 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -527,6 +527,25 @@ static int read_lowpass_coeffs(AVCodecContext *avctx, CFHDContext *s,
return 0;
}
+#define DECODE_SUBBAND_COEFFS(TABLE, COND) \
+ while (1) { \
+ UPDATE_CACHE(re, &s->gb); \
+ GET_RL_VLC(level, run, re, &s->gb, s->TABLE, VLC_BITS, 3, 1); \
+ \
+ /* escape */ \
+ if (COND) \
+ break; \
+ \
+ count += run; \
+ \
+ if (count > expected) \
+ break; \
+ \
+ coeff = dequant_and_decompand(level, s->quantisation); \
+ for (i = 0; i < run; i++) \
+ *coeff_data++ = coeff; \
+ } \
+
static int read_highpass_coeffs(AVCodecContext *avctx, CFHDContext *s,
GetByteContext *gb, int16_t *coeff_data)
{
@@ -559,43 +578,9 @@ static int read_highpass_coeffs(AVCodecContext *avctx, CFHDContext *s,
{
OPEN_READER(re, &s->gb);
if (!s->codebook) {
- while (1) {
- UPDATE_CACHE(re, &s->gb);
- GET_RL_VLC(level, run, re, &s->gb, s->table_9_rl_vlc,
- VLC_BITS, 3, 1);
-
- /* escape */
- if (level == 64)
- break;
-
- count += run;
-
- if (count > expected)
- break;
-
- coeff = dequant_and_decompand(level, s->quantisation);
- for (i = 0; i < run; i++)
- *coeff_data++ = coeff;
- }
+ DECODE_SUBBAND_COEFFS(table_9_rl_vlc, level == 64)
} else {
- while (1) {
- UPDATE_CACHE(re, &s->gb);
- GET_RL_VLC(level, run, re, &s->gb, s->table_18_rl_vlc,
- VLC_BITS, 3, 1);
-
- /* escape */
- if (level == 255 && run == 2)
- break;
-
- count += run;
-
- if (count > expected)
- break;
-
- coeff = dequant_and_decompand(level, s->quantisation);
- for (i = 0; i < run; i++)
- *coeff_data++ = coeff;
- }
+ DECODE_SUBBAND_COEFFS(table_18_rl_vlc, level == 255 && run == 2)
}
CLOSE_READER(re, &s->gb);
}