changeset 12145:9109a7e48d6e libavcodec

Move XCH parameters into context structure. Patch by Nick Brereton $name AT n$surname DOT net
author benoit
date Mon, 12 Jul 2010 09:00:17 +0000
parents 846779f6b164
children 36f7c2d7b3fb
files dca.c
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/dca.c	Sun Jul 11 22:53:01 2010 +0000
+++ b/dca.c	Mon Jul 12 09:00:17 2010 +0000
@@ -288,6 +288,10 @@
     int current_subframe;
     int current_subsubframe;
 
+    /* XCh extension information */
+    int xch_present;
+    int xch_base_channel;       ///< index of first (only) channel containing XCH data
+
     int debug_flag;             ///< used for suppressing repeated error messages output
     DSPContext dsp;
     FFTContext imdct;
@@ -1260,12 +1264,12 @@
     int lfe_samples;
     int num_core_channels = 0;
     int i;
-    int xch_present = 0;
     int16_t *samples = data;
     DCAContext *s = avctx->priv_data;
     int channels;
 
 
+    s->xch_present = 0;
     s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE);
     if (s->dca_buffer_size == -1) {
         av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n");
@@ -1297,9 +1301,10 @@
 
         switch(bits) {
         case 0x5a5a5a5a: {
-            int ext_base_ch = s->prim_channels;
             int ext_amode, xch_fsize;
 
+            s->xch_base_channel = s->prim_channels;
+
             /* validate sync word using XCHFSIZE field */
             xch_fsize = show_bits(&s->gb, 10);
             if((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) &&
@@ -1318,13 +1323,13 @@
             }
 
             /* much like core primary audio coding header */
-            dca_parse_audio_coding_header(s, ext_base_ch);
+            dca_parse_audio_coding_header(s, s->xch_base_channel);
 
             for (i = 0; i < (s->sample_blocks / 8); i++) {
-                dca_decode_block(s, ext_base_ch, i);
+                dca_decode_block(s, s->xch_base_channel, i);
             }
 
-            xch_present = 1;
+            s->xch_present = 1;
             break;
         }
         case 0x1d95f262:
@@ -1342,7 +1347,7 @@
     if (s->amode<16) {
         avctx->channel_layout = dca_core_channel_layout[s->amode];
 
-        if (xch_present && (!avctx->request_channels ||
+        if (s->xch_present && (!avctx->request_channels ||
                             avctx->request_channels > num_core_channels)) {
             avctx->channel_layout |= CH_BACK_CENTER;
             if (s->lfe) {