2 * common functions for reordering audio channels
4 * Copyright (C) 2007 Ulion <ulion A gmail P com>
6 * This file is part of MPlayer.
8 * MPlayer is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * MPlayer is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef MPLAYER_REORDER_CH_H
24 #define MPLAYER_REORDER_CH_H
30 // Rs - Right Surround
31 // Cs - Center Surround
32 // Rls - Rear Left Surround
33 // Rrs - Rear Right Surround
37 #define AF_CHANNEL_LAYOUT_MONO ((100<<8)|1)
38 #define AF_CHANNEL_LAYOUT_STEREO ((101<<8)|2)
39 #define AF_CHANNEL_LAYOUT_1_0 AF_CHANNEL_LAYOUT_MONO // C
40 #define AF_CHANNEL_LAYOUT_2_0 AF_CHANNEL_LAYOUT_STEREO // L R
41 #define AF_CHANNEL_LAYOUT_2_1 ((102<<8)|3) // L R LFE
42 #define AF_CHANNEL_LAYOUT_3_0_A ((103<<8)|3) // L R C
43 #define AF_CHANNEL_LAYOUT_3_0_B ((104<<8)|3) // C L R
44 #define AF_CHANNEL_LAYOUT_4_0_A ((105<<8)|4) // L R C Cs
45 #define AF_CHANNEL_LAYOUT_4_0_B ((106<<8)|4) // C L R Cs
46 #define AF_CHANNEL_LAYOUT_4_0_C ((107<<8)|4) // L R Ls Rs
47 #define AF_CHANNEL_LAYOUT_5_0_A ((108<<8)|5) // L R C Ls Rs
48 #define AF_CHANNEL_LAYOUT_5_0_B ((109<<8)|5) // L R Ls Rs C
49 #define AF_CHANNEL_LAYOUT_5_0_C ((110<<8)|5) // L C R Ls Rs
50 #define AF_CHANNEL_LAYOUT_5_0_D ((111<<8)|5) // C L R Ls Rs
51 #define AF_CHANNEL_LAYOUT_5_1_A ((112<<8)|6|AF_LFE) // L R C LFE Ls Rs
52 #define AF_CHANNEL_LAYOUT_5_1_B ((113<<8)|6|AF_LFE) // L R Ls Rs C LFE
53 #define AF_CHANNEL_LAYOUT_5_1_C ((114<<8)|6|AF_LFE) // L C R Ls Rs LFE
54 #define AF_CHANNEL_LAYOUT_5_1_D ((115<<8)|6|AF_LFE) // C L R Ls Rs LFE
55 #define AF_CHANNEL_LAYOUT_5_1_E ((116<<8)|6|AF_LFE) // LFE L C R Ls Rs
56 #define AF_CHANNEL_LAYOUT_6_1_A ((117<<8)|7|AF_LFE) // L R C LFE Ls Rs Cs
57 #define AF_CHANNEL_LAYOUT_7_1_A ((118<<8)|8|AF_LFE) // L R C LFE Ls Rs Rls Rrs
60 #define AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_B
61 #define AF_CHANNEL_LAYOUT_ALSA_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_B
62 #define AF_CHANNEL_LAYOUT_MPLAYER_5CH_DEFAULT AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT
63 #define AF_CHANNEL_LAYOUT_MPLAYER_6CH_DEFAULT AF_CHANNEL_LAYOUT_ALSA_6CH_DEFAULT
64 #define AF_CHANNEL_LAYOUT_AAC_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_D
65 #define AF_CHANNEL_LAYOUT_AAC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_D
66 #define AF_CHANNEL_LAYOUT_WAVEEX_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_A
67 #define AF_CHANNEL_LAYOUT_WAVEEX_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_A
68 #define AF_CHANNEL_LAYOUT_LAVC_AC3_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_C
69 #define AF_CHANNEL_LAYOUT_LAVC_AC3_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_C
70 #define AF_CHANNEL_LAYOUT_LAVC_LIBA52_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_C
71 #define AF_CHANNEL_LAYOUT_LAVC_LIBA52_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_E
72 #define AF_CHANNEL_LAYOUT_LAVC_DCA_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_D
73 #define AF_CHANNEL_LAYOUT_LAVC_DCA_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_D
74 #define AF_CHANNEL_LAYOUT_VORBIS_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_C
75 #define AF_CHANNEL_LAYOUT_VORBIS_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_C
76 #define AF_CHANNEL_LAYOUT_FLAC_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_A
77 #define AF_CHANNEL_LAYOUT_FLAC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_A
79 #define AF_CHANNEL_MASK 0xFF
80 #define AF_GET_CH_NUM(A) ((A)&0x7F)
81 #define AF_GET_CH_NUM_WITH_LFE(A) ((A)&0xFF)
82 #define AF_IS_SAME_CH_NUM(A,B) (((A)&0xFF)==((B)&0xFF))
83 #define AF_IS_LAYOUT_SPECIFIED(A) ((A)&0xFFFFF800)
84 #define AF_IS_LAYOUT_UNSPECIFIED(A) (!AF_IS_LAYOUT_SPECIFIED(A))
86 /// Optimized channel reorder between channel layouts with same channel number.
87 void reorder_channel_copy(void *src
,
94 /// Same with reorder_channel_copy, but works on single buffer.
95 void reorder_channel(void *buf
,
101 // Channel layout definitions for different audio sources or targets
102 // When specified channel number, they will be map to the specific layouts.
103 #define AF_CHANNEL_LAYOUT_ALSA_DEFAULT 0
104 #define AF_CHANNEL_LAYOUT_AAC_DEFAULT 1
105 #define AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT 2
106 #define AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT 3
107 #define AF_CHANNEL_LAYOUT_LAVC_LIBA52_DEFAULT 4
108 #define AF_CHANNEL_LAYOUT_LAVC_DCA_DEFAULT 5
109 #define AF_CHANNEL_LAYOUT_VORBIS_DEFAULT 6
110 #define AF_CHANNEL_LAYOUT_FLAC_DEFAULT 7
111 #define AF_CHANNEL_LAYOUT_SOURCE_NUM 8
112 #define AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT AF_CHANNEL_LAYOUT_ALSA_DEFAULT
114 /// Optimized channel reorder between different audio sources and targets.
115 void reorder_channel_copy_nch(void *src
,
123 /// Same with reorder_channel_copy_nch, but works on single buffer.
124 void reorder_channel_nch(void *buf
,
131 #endif /* MPLAYER_REORDER_CH_H */