changeset 9263:62774b28cde0 libavcodec

mlpdec: Split read_channel_params() into its own function.
author ramiro
date Fri, 27 Mar 2009 23:42:22 +0000
parents 3c9a424163ee
children 230dac9ec1d4
files mlpdec.c
diffstat 1 files changed, 49 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/mlpdec.c	Fri Mar 27 23:32:32 2009 +0000
+++ b/mlpdec.c	Fri Mar 27 23:42:22 2009 +0000
@@ -545,6 +545,54 @@
     return 0;
 }
 
+/** Read channel parameters. */
+
+static int read_channel_params(MLPDecodeContext *m, unsigned int substr,
+                               GetBitContext *gbp, unsigned int ch)
+{
+    ChannelParams *cp = &m->channel_params[ch];
+    FilterParams *fir = &cp->filter_params[FIR];
+    FilterParams *iir = &cp->filter_params[IIR];
+    SubStream *s = &m->substream[substr];
+
+    if (s->param_presence_flags & PARAM_FIR)
+        if (get_bits1(gbp))
+            if (read_filter_params(m, gbp, ch, FIR) < 0)
+                return -1;
+
+    if (s->param_presence_flags & PARAM_IIR)
+        if (get_bits1(gbp))
+            if (read_filter_params(m, gbp, ch, IIR) < 0)
+                return -1;
+
+    if (fir->order && iir->order &&
+        fir->shift != iir->shift) {
+        av_log(m->avctx, AV_LOG_ERROR,
+                "FIR and IIR filters must use the same precision.\n");
+        return -1;
+    }
+    /* The FIR and IIR filters must have the same precision.
+        * To simplify the filtering code, only the precision of the
+        * FIR filter is considered. If only the IIR filter is employed,
+        * the FIR filter precision is set to that of the IIR filter, so
+        * that the filtering code can use it. */
+    if (!fir->order && iir->order)
+        fir->shift = iir->shift;
+
+    if (s->param_presence_flags & PARAM_HUFFOFFSET)
+        if (get_bits1(gbp))
+            cp->huff_offset = get_sbits(gbp, 15);
+
+    cp->codebook  = get_bits(gbp, 2);
+    cp->huff_lsbs = get_bits(gbp, 5);
+
+    cp->sign_huff_offset = calculate_sign_huff(m, substr, ch);
+
+    /* TODO: validate */
+
+    return 0;
+}
+
 /** Read decoding parameters that change more often than those in the restart
  *  header. */
 
@@ -596,44 +644,8 @@
 
     for (ch = s->min_channel; ch <= s->max_channel; ch++)
         if (get_bits1(gbp)) {
-            ChannelParams *cp = &m->channel_params[ch];
-            FilterParams *fir = &cp->filter_params[FIR];
-            FilterParams *iir = &cp->filter_params[IIR];
-
-            if (s->param_presence_flags & PARAM_FIR)
-                if (get_bits1(gbp))
-                    if (read_filter_params(m, gbp, ch, FIR) < 0)
-                        return -1;
-
-            if (s->param_presence_flags & PARAM_IIR)
-                if (get_bits1(gbp))
-                    if (read_filter_params(m, gbp, ch, IIR) < 0)
-                        return -1;
-
-            if (fir->order && iir->order &&
-                fir->shift != iir->shift) {
-                av_log(m->avctx, AV_LOG_ERROR,
-                       "FIR and IIR filters must use the same precision.\n");
+            if (read_channel_params(m, substr, gbp, ch) < 0)
                 return -1;
-            }
-            /* The FIR and IIR filters must have the same precision.
-             * To simplify the filtering code, only the precision of the
-             * FIR filter is considered. If only the IIR filter is employed,
-             * the FIR filter precision is set to that of the IIR filter, so
-             * that the filtering code can use it. */
-            if (!fir->order && iir->order)
-                fir->shift = iir->shift;
-
-            if (s->param_presence_flags & PARAM_HUFFOFFSET)
-                if (get_bits1(gbp))
-                    cp->huff_offset = get_sbits(gbp, 15);
-
-            cp->codebook  = get_bits(gbp, 2);
-            cp->huff_lsbs = get_bits(gbp, 5);
-
-            cp->sign_huff_offset = calculate_sign_huff(m, substr, ch);
-
-            /* TODO: validate */
         }
 
     return 0;