[FFmpeg-cvslog] r24604 - trunk/libavcodec/flacenc.c

jbr subversion
Fri Jul 30 22:24:15 CEST 2010


Author: jbr
Date: Fri Jul 30 22:24:15 2010
New Revision: 24604

Log:
Combine and simplify output_subframe_constant() and output_subframe_verbatim().

Modified:
   trunk/libavcodec/flacenc.c

Modified: trunk/libavcodec/flacenc.c
==============================================================================
--- trunk/libavcodec/flacenc.c	Fri Jul 30 22:09:14 2010	(r24603)
+++ trunk/libavcodec/flacenc.c	Fri Jul 30 22:24:15 2010	(r24604)
@@ -1101,26 +1101,14 @@ static void output_frame_header(FlacEnco
 }
 
 
-static void output_subframe_constant(FlacEncodeContext *s, FlacSubframe *sub)
-{
-    int32_t res;
-
-    res = sub->residual[0];
-    put_sbits(&s->pb, sub->obits, res);
-}
-
-
 static void output_subframe_verbatim(FlacEncodeContext *s, FlacSubframe *sub)
 {
-    int i;
-    FlacFrame *frame;
-    int32_t res;
-
-    frame = &s->frame;
+    put_sbits(&s->pb, sub->obits, sub->residual[0]);
 
-    for (i = 0; i < frame->blocksize; i++) {
-        res = sub->residual[i];
-        put_sbits(&s->pb, sub->obits, res);
+    if (sub->type == FLAC_SUBFRAME_VERBATIM) {
+        int i;
+        for (i = 0; i < s->frame.blocksize; i++)
+            put_sbits(&s->pb, sub->obits, sub->residual[i]);
     }
 }
 
@@ -1212,14 +1200,12 @@ static void output_subframes(FlacEncodeC
         put_bits(&s->pb, 1, 0); /* no wasted bits */
 
         /* subframe */
-        if(sub->type == FLAC_SUBFRAME_CONSTANT)
-            output_subframe_constant(s, sub);
-        else if(sub->type == FLAC_SUBFRAME_VERBATIM)
-            output_subframe_verbatim(s, sub);
-        else if(sub->type == FLAC_SUBFRAME_FIXED)
-            output_subframe_fixed(s, sub);
-        else if(sub->type == FLAC_SUBFRAME_LPC)
-            output_subframe_lpc(s, sub);
+        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_LPC:      output_subframe_lpc(     s, sub); break;
+        }
     }
 }
 



More information about the ffmpeg-cvslog mailing list