blob: 1a118132a77ad6e46cf4b440e0a7e5762ae6ee2d
1 | /* ***** BEGIN LICENSE BLOCK ***** |
2 | * Source last modified: $Id: aac_reorder.c,v 1.1.1.1.2.1 2005/05/04 18:21:58 hubbe Exp $ |
3 | * |
4 | * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM |
5 | * Portions Copyright (c) 1995-2005 RealNetworks, Inc. |
6 | * All Rights Reserved. |
7 | * |
8 | * The contents of this file, and the files included with this file, |
9 | * are subject to the current version of the Real Format Source Code |
10 | * Porting and Optimization License, available at |
11 | * https://helixcommunity.org/2005/license/realformatsource (unless |
12 | * RealNetworks otherwise expressly agrees in writing that you are |
13 | * subject to a different license). You may also obtain the license |
14 | * terms directly from RealNetworks. You may not use this file except |
15 | * in compliance with the Real Format Source Code Porting and |
16 | * Optimization License. There are no redistribution rights for the |
17 | * source code of this file. Please see the Real Format Source Code |
18 | * Porting and Optimization License for the rights, obligations and |
19 | * limitations governing use of the contents of the file. |
20 | * |
21 | * RealNetworks is the developer of the Original Code and owns the |
22 | * copyrights in the portions it created. |
23 | * |
24 | * This file, and the files included with this file, is distributed and |
25 | * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, |
26 | * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL |
27 | * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF |
28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT |
29 | * OR NON-INFRINGEMENT. |
30 | * |
31 | * Technology Compatibility Kit Test Suite(s) Location: |
32 | * https://rarvcode-tck.helixcommunity.org |
33 | * |
34 | * Contributor(s): |
35 | * |
36 | * ***** END LICENSE BLOCK ***** */ |
37 | |
38 | #include "aac_reorder.h" |
39 | |
40 | void AACReorderPCMChannels(INT16 *pcmBuf, int nSamps, int nChans) |
41 | { |
42 | int i, ch, chanMap[6]; |
43 | INT16 tmpBuf[6]; |
44 | |
45 | switch (nChans) { |
46 | case 3: |
47 | chanMap[0] = 1; /* L */ |
48 | chanMap[1] = 2; /* R */ |
49 | chanMap[2] = 0; /* C */ |
50 | break; |
51 | case 4: |
52 | chanMap[0] = 1; /* L */ |
53 | chanMap[1] = 2; /* R */ |
54 | chanMap[2] = 0; /* C */ |
55 | chanMap[3] = 3; /* S */ |
56 | break; |
57 | case 5: |
58 | chanMap[0] = 1; /* L */ |
59 | chanMap[1] = 2; /* R */ |
60 | chanMap[2] = 0; /* C */ |
61 | chanMap[3] = 3; /* LS */ |
62 | chanMap[4] = 4; /* RS */ |
63 | break; |
64 | case 6: |
65 | chanMap[0] = 1; /* L */ |
66 | chanMap[1] = 2; /* R */ |
67 | chanMap[2] = 0; /* C */ |
68 | chanMap[3] = 5; /* LFE */ |
69 | chanMap[4] = 3; /* LS */ |
70 | chanMap[5] = 4; /* RS */ |
71 | break; |
72 | default: |
73 | return; |
74 | } |
75 | |
76 | for (i = 0; i < nSamps; i += nChans) { |
77 | for (ch = 0; ch < nChans; ch++) { |
78 | tmpBuf[ch] = pcmBuf[chanMap[ch]]; |
79 | } |
80 | for (ch = 0; ch < nChans; ch++) { |
81 | pcmBuf[ch] = tmpBuf[ch]; |
82 | } |
83 | pcmBuf += nChans; |
84 | } |
85 | } |
86 |