summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2016-06-16 18:26:43 +0200
committerAnton Khirnov <anton@khirnov.net>2016-07-25 13:57:01 +0200
commited3c8ff717a393f2cfa83c826eeac29e9b926c4d (patch)
tree91a968fd1895dc3040bcf0d997f4f72fe92faede
parent76d3d08409e5c69c96d65bdae49db474ddd4b0d1 (diff)
cfhd: Remove code duplication in read_highpass_coeffs()
-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);
}