changeset 12308:7bb34d5cb22f libavcodec

Combine and simplify output_subframe_fixed() and output_subframe_lpc().
author jbr
date Fri, 30 Jul 2010 20:28:46 +0000
parents a2de400ccd30
children 0a496c73c434
files flacenc.c
diffstat 1 files changed, 5 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/flacenc.c	Fri Jul 30 20:24:15 2010 +0000
+++ b/flacenc.c	Fri Jul 30 20:28:46 2010 +0000
@@ -1147,7 +1147,7 @@
 }
 
 
-static void output_subframe_fixed(FlacEncodeContext *s, FlacSubframe *sub)
+static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub)
 {
     int i;
 
@@ -1155,28 +1155,14 @@
     for (i = 0; i < sub->order; i++)
         put_sbits(&s->pb, sub->obits, sub->residual[i]);
 
-    /* residual */
-    output_residual(s, sub);
-}
-
-
-static void output_subframe_lpc(FlacEncodeContext *s, FlacSubframe *sub)
-{
-    int i, cbits;
-    FlacFrame *frame;
-
-    frame = &s->frame;
-
-    /* warm-up samples */
-    for (i = 0; i < sub->order; i++)
-        put_sbits(&s->pb, sub->obits, sub->residual[i]);
-
     /* LPC coefficients */
-    cbits = s->options.lpc_coeff_precision;
+    if (sub->type == FLAC_SUBFRAME_LPC) {
+    int cbits = s->options.lpc_coeff_precision;
     put_bits( &s->pb, 4, cbits-1);
     put_sbits(&s->pb, 5, sub->shift);
     for (i = 0; i < sub->order; i++)
         put_sbits(&s->pb, cbits, sub->coefs[i]);
+    }
 
     /* residual */
     output_residual(s, sub);
@@ -1203,7 +1189,7 @@
         switch (sub->type) {
         case FLAC_SUBFRAME_CONSTANT:
         case FLAC_SUBFRAME_VERBATIM: output_subframe_verbatim(s, sub); break;
-        case FLAC_SUBFRAME_FIXED:    output_subframe_fixed(   s, sub); break;
+        case FLAC_SUBFRAME_FIXED:
         case FLAC_SUBFRAME_LPC:      output_subframe_lpc(     s, sub); break;
         }
     }