[FFmpeg-cvslog] avcodec/mlp_parse: move TrueHD channel layout and sample rate related code to the header

James Almer git at videolan.org
Sun Aug 25 05:15:42 EEST 2019


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Jul 31 17:54:28 2019 -0300| [21d7eeafc134b111bb992ee51b02e7ca00d76e23] | committer: James Almer

avcodec/mlp_parse: move TrueHD channel layout and sample rate related code to the header

It will be needed by the next commit.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=21d7eeafc134b111bb992ee51b02e7ca00d76e23
---

 libavcodec/mlp_parse.c | 50 --------------------------------------------------
 libavcodec/mlp_parse.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 50 deletions(-)

diff --git a/libavcodec/mlp_parse.c b/libavcodec/mlp_parse.c
index 067735303c..3a71f2c0b7 100644
--- a/libavcodec/mlp_parse.c
+++ b/libavcodec/mlp_parse.c
@@ -60,56 +60,6 @@ static const uint64_t mlp_layout[32] = {
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 };
 
-static const uint8_t thd_chancount[13] = {
-//  LR    C   LFE  LRs LRvh  LRc LRrs  Cs   Ts  LRsd  LRw  Cvh  LFE2
-     2,   1,   1,   2,   2,   2,   2,   1,   1,   2,   2,   1,   1
-};
-
-static const uint64_t thd_layout[13] = {
-    AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT,                     // LR
-    AV_CH_FRONT_CENTER,                                     // C
-    AV_CH_LOW_FREQUENCY,                                    // LFE
-    AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRs
-    AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT,             // LRvh
-    AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, // LRc
-    AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT,                       // LRrs
-    AV_CH_BACK_CENTER,                                      // Cs
-    AV_CH_TOP_CENTER,                                       // Ts
-    AV_CH_SURROUND_DIRECT_LEFT|AV_CH_SURROUND_DIRECT_RIGHT, // LRsd
-    AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT,                       // LRw
-    AV_CH_TOP_FRONT_CENTER,                                 // Cvh
-    AV_CH_LOW_FREQUENCY_2,                                  // LFE2
-};
-
-static int mlp_samplerate(int in)
-{
-    if (in == 0xF)
-        return 0;
-
-    return (in & 8 ? 44100 : 48000) << (in & 7) ;
-}
-
-static int truehd_channels(int chanmap)
-{
-    int channels = 0, i;
-
-    for (i = 0; i < 13; i++)
-        channels += thd_chancount[i] * ((chanmap >> i) & 1);
-
-    return channels;
-}
-
-static uint64_t truehd_layout(int chanmap)
-{
-    int i;
-    uint64_t layout = 0;
-
-    for (i = 0; i < 13; i++)
-        layout |= thd_layout[i] * ((chanmap >> i) & 1);
-
-    return layout;
-}
-
 static int mlp_get_major_sync_size(const uint8_t * buf, int bufsize)
 {
     int has_extension, extensions = 0;
diff --git a/libavcodec/mlp_parse.h b/libavcodec/mlp_parse.h
index c6025d1a18..a0790ae8c7 100644
--- a/libavcodec/mlp_parse.h
+++ b/libavcodec/mlp_parse.h
@@ -56,6 +56,55 @@ typedef struct MLPHeaderInfo
     int num_substreams;                     ///< Number of substreams within stream
 } MLPHeaderInfo;
 
+static const uint8_t thd_chancount[13] = {
+//  LR    C   LFE  LRs LRvh  LRc LRrs  Cs   Ts  LRsd  LRw  Cvh  LFE2
+     2,   1,   1,   2,   2,   2,   2,   1,   1,   2,   2,   1,   1
+};
+
+static const uint64_t thd_layout[13] = {
+    AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT,                     // LR
+    AV_CH_FRONT_CENTER,                                     // C
+    AV_CH_LOW_FREQUENCY,                                    // LFE
+    AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRs
+    AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT,             // LRvh
+    AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, // LRc
+    AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT,                       // LRrs
+    AV_CH_BACK_CENTER,                                      // Cs
+    AV_CH_TOP_CENTER,                                       // Ts
+    AV_CH_SURROUND_DIRECT_LEFT|AV_CH_SURROUND_DIRECT_RIGHT, // LRsd
+    AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT,                       // LRw
+    AV_CH_TOP_FRONT_CENTER,                                 // Cvh
+    AV_CH_LOW_FREQUENCY_2,                                  // LFE2
+};
+
+static inline int mlp_samplerate(int in)
+{
+    if (in == 0xF)
+        return 0;
+
+    return (in & 8 ? 44100 : 48000) << (in & 7) ;
+}
+
+static inline int truehd_channels(int chanmap)
+{
+    int channels = 0, i;
+
+    for (i = 0; i < 13; i++)
+        channels += thd_chancount[i] * ((chanmap >> i) & 1);
+
+    return channels;
+}
+
+static inline uint64_t truehd_layout(int chanmap)
+{
+    int i;
+    uint64_t layout = 0;
+
+    for (i = 0; i < 13; i++)
+        layout |= thd_layout[i] * ((chanmap >> i) & 1);
+
+    return layout;
+}
 
 int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb);
 



More information about the ffmpeg-cvslog mailing list