changed: update version strings for beta4
[xbmc.git] / xbmc / utils / PCMRemap.h
blob55367b289ea5d72dd4330788ad2de566fff968e9
1 #ifndef __PCM_REMAP__H__
2 #define __PCM_REMAP__H__
4 /*
5 * Copyright (C) 2005-2010 Team XBMC
6 * http://www.xbmc.org
8 * This Program 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, or (at your option)
11 * any later version.
13 * This Program 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 XBMC; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 * http://www.gnu.org/copyleft/gpl.html
25 #include <stdint.h>
26 #include <vector>
27 #include "guilib/StdString.h"
29 #define PCM_MAX_CH 18
30 enum PCMChannels
32 PCM_INVALID = -1,
33 PCM_FRONT_LEFT,
34 PCM_FRONT_RIGHT,
35 PCM_FRONT_CENTER,
36 PCM_LOW_FREQUENCY,
37 PCM_BACK_LEFT,
38 PCM_BACK_RIGHT,
39 PCM_FRONT_LEFT_OF_CENTER,
40 PCM_FRONT_RIGHT_OF_CENTER,
41 PCM_BACK_CENTER,
42 PCM_SIDE_LEFT,
43 PCM_SIDE_RIGHT,
44 PCM_TOP_FRONT_LEFT,
45 PCM_TOP_FRONT_RIGHT,
46 PCM_TOP_FRONT_CENTER,
47 PCM_TOP_CENTER,
48 PCM_TOP_BACK_LEFT,
49 PCM_TOP_BACK_RIGHT,
50 PCM_TOP_BACK_CENTER
53 #define PCM_MAX_LAYOUT 10
54 enum PCMLayout
56 PCM_LAYOUT_2_0 = 0,
57 PCM_LAYOUT_2_1,
58 PCM_LAYOUT_3_0,
59 PCM_LAYOUT_3_1,
60 PCM_LAYOUT_4_0,
61 PCM_LAYOUT_4_1,
62 PCM_LAYOUT_5_0,
63 PCM_LAYOUT_5_1,
64 PCM_LAYOUT_7_0,
65 PCM_LAYOUT_7_1
68 struct PCMMapInfo
70 enum PCMChannels channel;
71 float level;
72 bool ifExists;
73 int in_offset;
74 bool copy;
77 class CPCMRemap
79 protected:
80 bool m_inSet, m_outSet;
81 enum PCMLayout m_channelLayout;
82 unsigned int m_inChannels, m_outChannels;
83 unsigned int m_inSampleSize;
84 enum PCMChannels m_inMap [PCM_MAX_CH];
85 enum PCMChannels m_outMap[PCM_MAX_CH];
86 enum PCMChannels m_layoutMap[PCM_MAX_CH + 1];
88 bool m_ignoreLayout;
89 bool m_useable [PCM_MAX_CH];
90 int m_inStride, m_outStride;
91 struct PCMMapInfo m_lookupMap[PCM_MAX_CH + 1][PCM_MAX_CH + 1];
92 int m_counts[PCM_MAX_CH];
94 struct PCMMapInfo* ResolveChannel(enum PCMChannels channel, float level, bool ifExists, std::vector<enum PCMChannels> path, struct PCMMapInfo *tablePtr);
95 void ResolveChannels(); //!< Partial BuildMap(), just enough to see which output channels are active
96 void BuildMap();
97 void DumpMap(CStdString info, int unsigned channels, enum PCMChannels *channelMap);
98 void Dispose();
99 CStdString PCMChannelStr(enum PCMChannels ename);
100 CStdString PCMLayoutStr(enum PCMLayout ename);
101 public:
103 CPCMRemap();
104 ~CPCMRemap();
106 void Reset();
107 enum PCMChannels *SetInputFormat (unsigned int channels, enum PCMChannels *channelMap, unsigned int sampleSize);
108 void SetOutputFormat(unsigned int channels, enum PCMChannels *channelMap, bool ignoreLayout = false);
109 void Remap(void *data, void *out, unsigned int samples);
110 bool CanRemap();
111 int InBytesToFrames (int bytes );
112 int FramesToOutBytes(int frames);
113 int FramesToInBytes (int frames);
116 #endif