]> git.tdb.fi Git - libs/core.git/blob - source/codecutils.cpp
6afbf95850356e61e3c4738e4029f3d1921f18f1
[libs/core.git] / source / codecutils.cpp
1 /* $Id$
2
3 This file is part of libmspstrings
4 Copyright © 2006-2007 Mikko Rasa
5 Distributed under the LGPL
6 */
7
8 #include "codecutils.h"
9
10 namespace Msp {
11 namespace Codecs {
12
13 int transform_mapping_or_direct(const int *mapping, unsigned map_size, int ch, bool reverse)
14 {
15         for(unsigned i=0; i<map_size*2; i+=2)
16         {
17                 if(mapping[i+reverse]==ch)
18                         return mapping[i+1-reverse];
19                 else if(mapping[i+1-reverse]==ch)
20                         return -1;
21         }
22
23         return ch;
24 }
25
26 } // namespace Codecs
27 } // namespace Msp