Fix all current known multi-channel wrong order problems by adding
[mplayer/greg.git] / libaf / reorder_ch.h
blob857b9d708e8cb396470dbb9b291fceddfea22e6b
1 /*
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
19 * along with MPlayer; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef REORDER_CH_H
24 #define REORDER_CH_H
26 // L - Left
27 // R - Right
28 // C - Center
29 // Ls - Left Surround
30 // Rs - Right Surround
31 // Cs - Center Surround
32 // Rls - Rear Left Surround
33 // Rrs - Rear Right Surround
35 #define AF_LFE (1<<7)
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
75 #define AF_CHANNEL_MASK 0xFF
76 #define AF_GET_CH_NUM(A) ((A)&0x7F)
77 #define AF_GET_CH_NUM_WITH_LFE(A) ((A)&0xFF)
78 #define AF_IS_SAME_CH_NUM(A,B) (((A)&0xFF)==((B)&0xFF))
79 #define AF_IS_LAYOUT_SPECIFIED(A) ((A)&0xFFFFF800)
80 #define AF_IS_LAYOUT_UNSPECIFIED(A) (!AF_IS_LAYOUT_SPECIFIED(A))
82 /// Optimized channel reorder between channel layouts with same channel number.
83 void reorder_channel_copy(void *src,
84 int src_layout,
85 void *dest,
86 int dest_layout,
87 int samples,
88 int samplesize);
90 /// Same with reorder_channel_copy, but works on single buffer.
91 void reorder_channel(void *buf,
92 int src_layout,
93 int dest_layout,
94 int samples,
95 int samplesize);
97 // Channel layout definitions for different audio sources or targets
98 // When specified channel number, they will be map to the specific layouts.
99 #define AF_CHANNEL_LAYOUT_ALSA_DEFAULT 0
100 #define AF_CHANNEL_LAYOUT_AAC_DEFAULT 1
101 #define AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT 2
102 #define AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT 3
103 #define AF_CHANNEL_LAYOUT_LAVC_LIBA52_DEFAULT 4
104 #define AF_CHANNEL_LAYOUT_LAVC_DCA_DEFAULT 5
105 #define AF_CHANNEL_LAYOUT_SOURCE_NUM 6
106 #define AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT AF_CHANNEL_LAYOUT_ALSA_DEFAULT
108 /// Optimized channel reorder between different audio sources and targets.
109 void reorder_channel_copy_nch(void *src,
110 int src_layout,
111 void *dest,
112 int dest_layout,
113 int chnum,
114 int samples,
115 int samplesize);
117 /// Same with reorder_channel_copy_nch, but works on single buffer.
118 void reorder_channel_nch(void *buf,
119 int src_layout,
120 int dest_layout,
121 int chnum,
122 int samples,
123 int samplesize);
125 #endif /* REORDER_CH_H */