[FFmpeg-cvslog] r25994 - trunk/libavcodec/ac3enc.c

jbr subversion
Tue Dec 14 15:53:14 CET 2010


Author: jbr
Date: Tue Dec 14 15:53:13 2010
New Revision: 25994

Log:
Move writing of frame to the output bitstream to a separate function.

Modified:
   trunk/libavcodec/ac3enc.c

Modified: trunk/libavcodec/ac3enc.c
==============================================================================
--- trunk/libavcodec/ac3enc.c	Tue Dec 14 15:53:10 2010	(r25993)
+++ trunk/libavcodec/ac3enc.c	Tue Dec 14 15:53:13 2010	(r25994)
@@ -914,10 +914,8 @@ static int compute_bit_allocation(AC3Enc
 /**
  * Write the AC-3 frame header to the output bitstream.
  */
-static void output_frame_header(AC3EncodeContext *s, unsigned char *frame)
+static void output_frame_header(AC3EncodeContext *s)
 {
-    init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
-
     put_bits(&s->pb, 16, 0x0b77);   /* frame header */
     put_bits(&s->pb, 16, 0);        /* crc1: will be filled later */
     put_bits(&s->pb, 2,  s->bit_alloc.sr_code);
@@ -1295,6 +1293,32 @@ static void output_frame_end(AC3EncodeCo
 
 
 /**
+ * Write the frame to the output bitstream.
+ */
+static void output_frame(AC3EncodeContext *s,
+                         unsigned char *frame,
+                         uint8_t exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS],
+                         uint8_t encoded_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
+                         uint8_t bap[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
+                         int32_t mdct_coef[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
+                         int8_t exp_shift[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS])
+{
+    int blk;
+
+    init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
+
+    output_frame_header(s);
+
+    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+        output_audio_block(s, exp_strategy[blk], encoded_exp[blk],
+                           bap[blk], mdct_coef[blk], exp_shift[blk], blk);
+    }
+
+    output_frame_end(s);
+}
+
+
+/**
  * Encode a single AC-3 frame.
  */
 static int ac3_encode_frame(AVCodecContext *avctx,
@@ -1302,7 +1326,6 @@ static int ac3_encode_frame(AVCodecConte
 {
     AC3EncodeContext *s = avctx->priv_data;
     const int16_t *samples = data;
-    int blk;
     int16_t planar_samples[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE+AC3_FRAME_SIZE];
     int32_t mdct_coef[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];
     uint8_t exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];
@@ -1323,14 +1346,7 @@ static int ac3_encode_frame(AVCodecConte
 
     compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits);
 
-    output_frame_header(s, frame);
-
-    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
-        output_audio_block(s, exp_strategy[blk], encoded_exp[blk],
-                           bap[blk], mdct_coef[blk], exp_shift[blk], blk);
-    }
-
-    output_frame_end(s);
+    output_frame(s, frame, exp_strategy, encoded_exp, bap, mdct_coef, exp_shift);
 
     return s->frame_size;
 }



More information about the ffmpeg-cvslog mailing list