]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blobdiff - libavcodec/ac3tab.c
frsh: Export information about the last RTP contract and VRES
[frescor/ffmpeg.git] / libavcodec / ac3tab.c
index c87200b1df69c421d38cac907be58689d9591086..ba7b204b2173007d0300b2e6cafcb5e399818c95 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * AC3 tables
+ * AC-3 tables
  * copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  */
 
 /**
- * @file ac3tab.c
- * tables taken directly from AC3 spec.
+ * @file libavcodec/ac3tab.c
+ * tables taken directly from the AC-3 spec.
  */
 
+#include "avcodec.h"
 #include "ac3tab.h"
 
 /**
@@ -79,6 +80,48 @@ 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,            } },\
+    { { 0, 1,          }, { 0, 1, 2,         } },\
+    { { 0, 2, 1,       }, { 0, 2, 1, 3,      } },\
+    { { 0, 1, 2,       }, { 0, 1, 3, 2,      } },\
+    { { 0, 2, 1, 3,    }, { 0, 2, 1, 4, 3,   } },
+
+/**
+ * Table to remap channels from SMPTE order to AC-3 order.
+ * [channel_mode][lfe][ch]
+ */
+const uint8_t ff_ac3_enc_channel_map[8][2][6] = {
+    COMMON_CHANNEL_MAP
+    { { 0, 1, 2, 3, 4, }, { 0, 1, 3, 4, 2,   } },
+    { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 4, 5, 3 } },
+};
+
+/**
+ * Table to remap channels from from AC-3 order to SMPTE order.
+ * [channel_mode][lfe][ch]
+ */
+const uint8_t ff_ac3_dec_channel_map[8][2][6] = {
+    COMMON_CHANNEL_MAP
+    { { 0, 1, 2, 3, 4, }, { 0, 1, 4, 2, 3,   } },
+    { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 5, 3, 4 } },
+};
+
 /* possible frequencies */
 const uint16_t ff_ac3_sample_rate_tab[3] = { 48000, 44100, 32000 };
 
@@ -88,7 +131,7 @@ const uint16_t ff_ac3_bitrate_tab[19] = {
     160, 192, 224, 256, 320, 384, 448, 512, 576, 640
 };
 
-/* AC3 MDCT window */
+/* AC-3 MDCT window */
 
 /* MDCT window */
 const int16_t ff_ac3_window[256] = {
@@ -247,3 +290,16 @@ const uint8_t ff_ac3_critical_band_size_tab[50]={
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
     3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24
 };
+/**
+ * Default channel map for a dependent substream defined by acmod
+ */
+const uint16_t ff_eac3_default_chmap[8] = {
+    AC3_CHMAP_L |               AC3_CHMAP_R, // FIXME Ch1+Ch2
+                  AC3_CHMAP_C,
+    AC3_CHMAP_L |               AC3_CHMAP_R,
+    AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R,
+    AC3_CHMAP_L |               AC3_CHMAP_R |                   AC3_CHMAP_C_SUR,
+    AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R |                   AC3_CHMAP_C_SUR,
+    AC3_CHMAP_L |               AC3_CHMAP_R | AC3_CHMAP_L_SUR |                  AC3_CHMAP_R_SUR,
+    AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_L_SUR |                  AC3_CHMAP_R_SUR
+};