2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Robert Nagy, ronag89@gmail.com
28 #include <common/cache_aligned_vector.h>
30 namespace caspar { namespace core {
33 cache_aligned_vector<int8_t> audio_32_to_24(const T& audio_data)
35 auto size = std::distance(std::begin(audio_data), std::end(audio_data));
36 auto input8 = reinterpret_cast<const int8_t*>(&(*std::begin(audio_data)));
37 auto output8 = cache_aligned_vector<int8_t>();
39 output8.reserve(size*3);
40 for(int n = 0; n < size; ++n)
42 output8.push_back(input8[n*4+1]);
43 output8.push_back(input8[n*4+2]);
44 output8.push_back(input8[n*4+3]);
51 cache_aligned_vector<int16_t> audio_32_to_16(const T& audio_data)
53 auto size = std::distance(std::begin(audio_data), std::end(audio_data));
54 auto input32 = &(*std::begin(audio_data));
55 auto output16 = cache_aligned_vector<int16_t> ();
57 output16.reserve(size);
58 for(int n = 0; n < size; ++n)
59 output16.push_back((input32[n] >> 16) & 0xFFFF);