~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to intern/audaspace/intern/AUD_ChannelMapperFactory.cpp

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: AUD_ChannelMapperFactory.cpp 25643 2010-01-01 05:09:30Z nexyon $
3
 
 *
4
 
 * ***** BEGIN LGPL LICENSE BLOCK *****
5
 
 *
6
 
 * Copyright 2009 Jörg Hermann Müller
 
2
 * ***** BEGIN GPL LICENSE BLOCK *****
 
3
 *
 
4
 * Copyright 2009-2011 Jörg Hermann Müller
7
5
 *
8
6
 * This file is part of AudaSpace.
9
7
 *
10
 
 * AudaSpace is free software: you can redistribute it and/or modify
11
 
 * it under the terms of the GNU Lesser General Public License as published by
12
 
 * the Free Software Foundation, either version 3 of the License, or
 
8
 * Audaspace 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
13
11
 * (at your option) any later version.
14
12
 *
15
13
 * AudaSpace is distributed in the hope that it will be useful,
16
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 * GNU Lesser General Public License for more details.
19
 
 *
20
 
 * You should have received a copy of the GNU Lesser General Public License
21
 
 * along with AudaSpace.  If not, see <http://www.gnu.org/licenses/>.
22
 
 *
23
 
 * ***** END LGPL LICENSE BLOCK *****
24
 
 */
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with Audaspace; if not, write to the Free Software Foundation,
 
20
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
21
 *
 
22
 * ***** END GPL LICENSE BLOCK *****
 
23
 */
 
24
 
 
25
/** \file audaspace/intern/AUD_ChannelMapperFactory.cpp
 
26
 *  \ingroup audaspaceintern
 
27
 */
 
28
 
25
29
 
26
30
#include "AUD_ChannelMapperFactory.h"
27
31
#include "AUD_ChannelMapperReader.h"
28
32
 
29
33
#include <cstring>
30
34
 
31
 
AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(AUD_IReader* reader,
32
 
                                                                                                   AUD_DeviceSpecs specs) :
33
 
                AUD_MixerFactory(reader, specs)
34
 
{
35
 
        memset(m_mapping, 0, sizeof(m_mapping));
36
 
}
37
 
 
38
 
AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(AUD_IFactory* factory,
 
35
AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(AUD_Reference<AUD_IFactory> factory,
39
36
                                                                                                   AUD_DeviceSpecs specs) :
40
37
                AUD_MixerFactory(factory, specs)
41
38
{
42
 
        memset(m_mapping, 0, sizeof(m_mapping));
43
 
}
44
 
 
45
 
AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(AUD_DeviceSpecs specs) :
46
 
                AUD_MixerFactory(specs)
47
 
{
48
 
        memset(m_mapping, 0, sizeof(m_mapping));
49
 
}
50
 
 
51
 
AUD_ChannelMapperFactory::~AUD_ChannelMapperFactory()
52
 
{
53
 
        for(int i = 1; i < 10; i++)
54
 
                deleteMapping(i);
55
 
}
56
 
 
57
 
float** AUD_ChannelMapperFactory::getMapping(int ic)
58
 
{
59
 
        ic--;
60
 
        if(ic > 8 || ic < 0)
61
 
                return 0;
62
 
 
63
 
        if(m_mapping[ic])
64
 
        {
65
 
                int channels = -1;
66
 
                while(m_mapping[ic][++channels] != 0);
67
 
                if(channels != m_specs.channels)
68
 
                        deleteMapping(ic+1);
69
 
        }
70
 
 
71
 
        if(!m_mapping[ic])
72
 
        {
73
 
                int channels = m_specs.channels;
74
 
 
75
 
                m_mapping[ic] = new float*[channels+1]; AUD_NEW("mapping")
76
 
                m_mapping[ic][channels] = 0;
77
 
 
78
 
                for(int i = 0; i < channels; i++)
79
 
                {
80
 
                        m_mapping[ic][i] = new float[ic+1]; AUD_NEW("mapping")
81
 
                        for(int j = 0; j <= ic; j++)
82
 
                                m_mapping[ic][i][j] = ((i == j) || (channels == 1) ||
83
 
                                                                           (ic == 0)) ? 1.0f : 0.0f;
84
 
                }
85
 
        }
86
 
 
87
 
        return m_mapping[ic];
88
 
}
89
 
 
90
 
void AUD_ChannelMapperFactory::deleteMapping(int ic)
91
 
{
92
 
        ic--;
93
 
        if(ic > 8 || ic < 0)
94
 
                return;
95
 
 
96
 
        if(m_mapping[ic])
97
 
        {
98
 
                for(int i = 0; 1; i++)
99
 
                {
100
 
                        if(m_mapping[ic][i] != 0)
101
 
                        {
102
 
                                delete[] m_mapping[ic][i]; AUD_DELETE("mapping")
103
 
                        }
104
 
                        else
105
 
                                break;
106
 
                }
107
 
                delete[] m_mapping[ic]; AUD_DELETE("mapping")
108
 
                m_mapping[ic] = 0;
109
 
        }
110
 
}
111
 
 
112
 
AUD_IReader* AUD_ChannelMapperFactory::createReader()
113
 
{
114
 
        AUD_IReader* reader = getReader();
115
 
 
116
 
        if(reader != 0)
117
 
        {
118
 
                int ic = reader->getSpecs().channels;
119
 
 
120
 
                reader = new AUD_ChannelMapperReader(reader, getMapping(ic));
121
 
                AUD_NEW("reader")
122
 
        }
123
 
 
124
 
        return reader;
 
39
}
 
40
 
 
41
AUD_Reference<AUD_IReader> AUD_ChannelMapperFactory::createReader()
 
42
{
 
43
        AUD_Reference<AUD_IReader> reader = getReader();
 
44
        return new AUD_ChannelMapperReader(reader, m_specs.channels);
125
45
}