[FFmpeg-cvslog] r18622 - in trunk/libavcodec: aac_ac3_parser.c aac_ac3_parser.h ac3.h ac3_parser.c ac3dec.c ac3dec.h ac3tab.c ac3tab.h

jbr subversion
Sun Apr 19 17:05:32 CEST 2009


Author: jbr
Date: Sun Apr 19 17:05:32 2009
New Revision: 18622

Log:
Add channel layout support to the AC-3 decoder and AC-3 parser.

Modified:
   trunk/libavcodec/aac_ac3_parser.c
   trunk/libavcodec/aac_ac3_parser.h
   trunk/libavcodec/ac3.h
   trunk/libavcodec/ac3_parser.c
   trunk/libavcodec/ac3dec.c
   trunk/libavcodec/ac3dec.h
   trunk/libavcodec/ac3tab.c
   trunk/libavcodec/ac3tab.h

Modified: trunk/libavcodec/aac_ac3_parser.c
==============================================================================
--- trunk/libavcodec/aac_ac3_parser.c	Sun Apr 19 16:05:55 2009	(r18621)
+++ trunk/libavcodec/aac_ac3_parser.c	Sun Apr 19 17:05:32 2009	(r18622)
@@ -85,6 +85,7 @@ get_next:
         avctx->channels = avctx->request_channels;
     } else {
         avctx->channels = s->channels;
+        avctx->channel_layout = s->channel_layout;
     }
     avctx->bit_rate = s->bit_rate;
     avctx->frame_size = s->samples;

Modified: trunk/libavcodec/aac_ac3_parser.h
==============================================================================
--- trunk/libavcodec/aac_ac3_parser.h	Sun Apr 19 16:05:55 2009	(r18621)
+++ trunk/libavcodec/aac_ac3_parser.h	Sun Apr 19 17:05:32 2009	(r18622)
@@ -48,6 +48,7 @@ typedef struct AACAC3ParseContext {
     int sample_rate;
     int bit_rate;
     int samples;
+    int64_t channel_layout;
 
     int remaining_size;
     uint64_t state;

Modified: trunk/libavcodec/ac3.h
==============================================================================
--- trunk/libavcodec/ac3.h	Sun Apr 19 16:05:55 2009	(r18621)
+++ trunk/libavcodec/ac3.h	Sun Apr 19 17:05:32 2009	(r18622)
@@ -100,6 +100,7 @@ typedef struct {
     uint32_t bit_rate;
     uint8_t channels;
     uint16_t frame_size;
+    int64_t channel_layout;
     /** @} */
 } AC3HeaderInfo;
 

Modified: trunk/libavcodec/ac3_parser.c
==============================================================================
--- trunk/libavcodec/ac3_parser.c	Sun Apr 19 16:05:55 2009	(r18621)
+++ trunk/libavcodec/ac3_parser.c	Sun Apr 19 17:05:32 2009	(r18622)
@@ -121,6 +121,9 @@ int ff_ac3_parse_header(GetBitContext *g
                         (hdr->num_blocks * 256.0));
         hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
     }
+    hdr->channel_layout = ff_ac3_channel_layout_tab[hdr->channel_mode];
+    if (hdr->lfe_on)
+        hdr->channel_layout |= CH_LOW_FREQUENCY;
 
     return 0;
 }
@@ -174,6 +177,7 @@ static int ac3_sync(uint64_t state, AACA
     hdr_info->sample_rate = hdr.sample_rate;
     hdr_info->bit_rate = hdr.bit_rate;
     hdr_info->channels = hdr.channels;
+    hdr_info->channel_layout = hdr.channel_layout;
     hdr_info->samples = hdr.num_blocks * 256;
     if(hdr.bitstream_id>10)
         hdr_info->codec_id = CODEC_ID_EAC3;

Modified: trunk/libavcodec/ac3dec.c
==============================================================================
--- trunk/libavcodec/ac3dec.c	Sun Apr 19 16:05:55 2009	(r18621)
+++ trunk/libavcodec/ac3dec.c	Sun Apr 19 17:05:32 2009	(r18622)
@@ -285,6 +285,7 @@ static int parse_frame_header(AC3DecodeC
     /* get decoding parameters from header info */
     s->bit_alloc_params.sr_code     = hdr.sr_code;
     s->channel_mode                 = hdr.channel_mode;
+    s->channel_layout               = hdr.channel_layout;
     s->lfe_on                       = hdr.lfe_on;
     s->bit_alloc_params.sr_shift    = hdr.sr_shift;
     s->sample_rate                  = hdr.sample_rate;
@@ -1307,8 +1308,10 @@ static int ac3_decode_frame(AVCodecConte
                 avctx->request_channels < s->channels) {
             s->out_channels = avctx->request_channels;
             s->output_mode  = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
+            s->channel_layout = ff_ac3_channel_layout_tab[s->output_mode];
         }
         avctx->channels = s->out_channels;
+        avctx->channel_layout = s->channel_layout;
 
         /* set downmixing coefficients if needed */
         if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) &&

Modified: trunk/libavcodec/ac3dec.h
==============================================================================
--- trunk/libavcodec/ac3dec.h	Sun Apr 19 16:05:55 2009	(r18621)
+++ trunk/libavcodec/ac3dec.h	Sun Apr 19 17:05:32 2009	(r18622)
@@ -58,6 +58,7 @@ typedef struct {
     int sample_rate;                        ///< sample frequency, in Hz
     int num_blocks;                         ///< number of audio blocks
     int channel_mode;                       ///< channel mode                           (acmod)
+    int channel_layout;                     ///< channel layout
     int lfe_on;                             ///< lfe channel in use
     int channel_map;                        ///< custom channel map
     int center_mix_level;                   ///< Center mix level index

Modified: trunk/libavcodec/ac3tab.c
==============================================================================
--- trunk/libavcodec/ac3tab.c	Sun Apr 19 16:05:55 2009	(r18621)
+++ trunk/libavcodec/ac3tab.c	Sun Apr 19 17:05:32 2009	(r18622)
@@ -24,6 +24,7 @@
  * tables taken directly from the AC-3 spec.
  */
 
+#include "avcodec.h"
 #include "ac3tab.h"
 
 /**
@@ -79,6 +80,20 @@ const uint8_t ff_ac3_channels_tab[8] = {
     2, 1, 2, 3, 3, 4, 4, 5
 };
 
+/**
+ * Maps audio coding mode (acmod) to channel layout mask.
+ */
+const uint16_t ff_ac3_channel_layout_tab[8] = {
+    CH_LAYOUT_STEREO,
+    CH_LAYOUT_MONO,
+    CH_LAYOUT_STEREO,
+    CH_LAYOUT_SURROUND,
+    CH_LAYOUT_2_1,
+    CH_LAYOUT_4POINT0,
+    CH_LAYOUT_2_2,
+    CH_LAYOUT_5POINT0
+};
+
 #define COMMON_CHANNEL_MAP \
     { { 0, 1,          }, { 0, 1, 2,         } },\
     { { 0,             }, { 0, 1,            } },\

Modified: trunk/libavcodec/ac3tab.h
==============================================================================
--- trunk/libavcodec/ac3tab.h	Sun Apr 19 16:05:55 2009	(r18621)
+++ trunk/libavcodec/ac3tab.h	Sun Apr 19 17:05:32 2009	(r18622)
@@ -26,6 +26,7 @@
 
 extern const uint16_t ff_ac3_frame_size_tab[38][3];
 extern const uint8_t  ff_ac3_channels_tab[8];
+extern const uint16_t ff_ac3_channel_layout_tab[8];
 extern const uint8_t  ff_ac3_enc_channel_map[8][2][6];
 extern const uint8_t  ff_ac3_dec_channel_map[8][2][6];
 extern const uint16_t ff_ac3_sample_rate_tab[3];



More information about the ffmpeg-cvslog mailing list