#include <gl/glew.h>
-#include <tbb/cache_aligned_allocator.h>
#include <tbb/parallel_for.h>
#include <tbb/parallel_for_each.h>
#include <tbb/concurrent_queue.h>
namespace caspar { namespace accelerator { namespace cpu {
-typedef std::vector<uint8_t, tbb::cache_aligned_allocator<uint8_t>> buffer;
+typedef cache_aligned_vector<uint8_t> buffer;
class image_mixer final : public core::image_mixer
{
{
if(layers.empty())
{ // Bypass GPU with empty frame.
- auto buffer = spl::make_shared<const std::vector<uint8_t, tbb::cache_aligned_allocator<uint8_t>>>(format_desc.size, 0);
+ auto buffer = spl::make_shared<const cache_aligned_vector<uint8_t>>(format_desc.size, 0);
return make_ready_future(array<const std::uint8_t>(buffer->data(), format_desc.size, true, buffer));
}
--- /dev/null
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Helge Norberg, helge.norberg@svt.se
+*/
+
+#pragma once
+
+#include <tbb/cache_aligned_allocator.h>
+
+#include <vector>
+
+namespace caspar {
+
+template<typename T>
+using cache_aligned_vector = std::vector<T, tbb::cache_aligned_allocator<T>>;
+
+}
<ClInclude Include="base64.h" />\r
<ClInclude Include="blocking_bounded_queue_adapter.h" />\r
<ClInclude Include="blocking_priority_queue.h" />\r
+ <ClInclude Include="cache_aligned_vector.h" />\r
<ClInclude Include="compiler\vs\disable_silly_warnings.h" />\r
<ClInclude Include="compiler\vs\stack_walker.h" />\r
<ClInclude Include="diagnostics\graph.h" />\r
<ClInclude Include="base64.h">\r
<Filter>source</Filter>\r
</ClInclude>\r
+ <ClInclude Include="cache_aligned_vector.h">\r
+ <Filter>source</Filter>\r
+ </ClInclude>\r
</ItemGroup>\r
</Project>
\ No newline at end of file
#include <common/forward.h>
#include <common/array.h>
#include <common/future_fwd.h>
+#include <common/cache_aligned_vector.h>
#include <boost/range.hpp>
#include <boost/any.hpp>
-#include <tbb/cache_aligned_allocator.h>
-
#include <cstddef>
#include <cstdint>
namespace caspar { namespace core {
-typedef std::vector<int32_t, tbb::cache_aligned_allocator<int32_t>> audio_buffer;
+typedef cache_aligned_vector<int32_t> audio_buffer;
class frame_geometry;
class mutable_frame final
}
};
-typedef std::vector<float, tbb::cache_aligned_allocator<float>> audio_buffer_ps;
+typedef cache_aligned_vector<float> audio_buffer_ps;
struct audio_stream
{
#include <common/forward.h>
#include <common/memory.h>
+#include <common/cache_aligned_vector.h>
#include <core/frame/frame_visitor.h>
-#include <tbb/cache_aligned_allocator.h>
-
#include <vector>
#include <cstdint>
namespace caspar { namespace core {
-typedef std::vector<int32_t, tbb::cache_aligned_allocator<int32_t>> audio_buffer;
+typedef cache_aligned_vector<int32_t> audio_buffer;
class audio_mixer final : public frame_visitor
{
#include <vector>
#include <cstdint>
-#include <tbb/cache_aligned_allocator.h>
+#include <common/cache_aligned_vector.h>
namespace caspar { namespace core {
template<typename T>
-std::vector<int8_t, tbb::cache_aligned_allocator<int8_t>> audio_32_to_24(const T& audio_data)
+cache_aligned_vector<int8_t> audio_32_to_24(const T& audio_data)
{
- auto size = std::distance(std::begin(audio_data), std::end(audio_data));
- auto input8 = reinterpret_cast<const int8_t*>(&(*std::begin(audio_data)));
- auto output8 = std::vector<int8_t, tbb::cache_aligned_allocator<int8_t>>();
+ auto size = std::distance(std::begin(audio_data), std::end(audio_data));
+ auto input8 = reinterpret_cast<const int8_t*>(&(*std::begin(audio_data)));
+ auto output8 = cache_aligned_vector<int8_t>();
output8.reserve(size*3);
for(int n = 0; n < size; ++n)
}
template<typename T>
-std::vector<int16_t, tbb::cache_aligned_allocator<int16_t>> audio_32_to_16(const T& audio_data)
+cache_aligned_vector<int16_t> audio_32_to_16(const T& audio_data)
{
- auto size = std::distance(std::begin(audio_data), std::end(audio_data));
- auto input32 = &(*std::begin(audio_data));
- auto output16 = std::vector<int16_t, tbb::cache_aligned_allocator<int16_t>>();
+ auto size = std::distance(std::begin(audio_data), std::end(audio_data));
+ auto input32 = &(*std::begin(audio_data));
+ auto output16 = cache_aligned_vector<int16_t> ();
output16.reserve(size);
for(int n = 0; n < size; ++n)
namespace caspar { namespace core {
-std::vector<uint8_t, tbb::cache_aligned_allocator<uint8_t>> empty_drawing(
- int width, int height)
+cache_aligned_vector<uint8_t> empty_drawing(int width, int height)
{
- std::vector<uint8_t, tbb::cache_aligned_allocator<uint8_t>> result;
+ cache_aligned_vector<uint8_t> result;
result.resize(width * height * 4);
std::fill(result.begin(), result.end(), 0);
class freehand_producer : public frame_producer_base
{
- monitor::subject monitor_subject_;
- std::vector<uint8_t, tbb::cache_aligned_allocator<uint8_t>> drawing_;
- spl::shared_ptr<core::frame_factory> frame_factory_;
- constraints constraints_;
- draw_frame frame_;
- bool button_pressed_;
- bool modified_;
+ monitor::subject monitor_subject_;
+ cache_aligned_vector<uint8_t> drawing_;
+ spl::shared_ptr<core::frame_factory> frame_factory_;
+ constraints constraints_;
+ draw_frame frame_;
+ bool button_pressed_;
+ bool modified_;
public:
explicit freehand_producer(
const spl::shared_ptr<core::frame_factory>& frame_factory,
#include <common/memshfl.h>
#include <common/array.h>
#include <common/future.h>
+#include <common/cache_aligned_vector.h>
#include <core/consumer/frame_consumer.h>
#include <tbb/concurrent_queue.h>
-#include <tbb/cache_aligned_allocator.h>
#include <common/assert.h>
#include <boost/lexical_cast.hpp>
class decklink_frame : public IDeckLinkVideoFrame
{
- tbb::atomic<int> ref_count_;
- core::const_frame frame_;
- const core::video_format_desc format_desc_;
+ tbb::atomic<int> ref_count_;
+ core::const_frame frame_;
+ const core::video_format_desc format_desc_;
- const bool key_only_;
- std::vector<uint8_t, tbb::cache_aligned_allocator<uint8_t>> data_;
+ const bool key_only_;
+ cache_aligned_vector<uint8_t> data_;
public:
decklink_frame(core::const_frame frame, const core::video_format_desc& format_desc, bool key_only)
: frame_(frame)
}
};
-typedef std::vector<uint8_t, tbb::cache_aligned_allocator<uint8_t>> byte_vector;
+typedef cache_aligned_vector<uint8_t> byte_vector;
struct ffmpeg_consumer : boost::noncopyable
{
#include <core/video_format.h>
#include <common/log.h>
-
-#include <tbb/cache_aligned_allocator.h>
+#include <common/cache_aligned_vector.h>
#include <queue>
[](SwrContext* p){swr_free(&p); }
};
- std::vector<uint8_t, tbb::cache_aligned_allocator<int8_t>> buffer_;
+ cache_aligned_vector<uint8_t> buffer_;
std::shared_ptr<AVPacket> current_packet_;
namespace caspar { namespace oal {
-typedef std::vector<int16_t, tbb::cache_aligned_allocator<int16_t>> audio_buffer_16;
+typedef cache_aligned_vector<int16_t> audio_buffer_16;
class device
{
#include <common/utf.h>
#include <common/except.h>
#include <common/endian.h>
-
+#include <common/cache_aligned_vector.h>
#include <core/monitor/monitor.h>
#include <functional>
#include <boost/thread.hpp>
#include <tbb/spin_mutex.h>
-#include <tbb/cache_aligned_allocator.h>
using namespace boost::asio::ip;
}
};
-typedef std::vector<no_init_proxy<char>, tbb::cache_aligned_allocator<no_init_proxy<char>>> byte_vector;
+typedef cache_aligned_vector<no_init_proxy<char>> byte_vector;
template<typename T>
struct param_visitor : public boost::static_visitor<void>