]> git.sesse.net Git - casparcg/commitdiff
Created template alias for std::vector<T, tbb::cache_aligned_allocator<T>> to caspar...
authorHelge Norberg <helge.norberg@svt.se>
Fri, 20 Feb 2015 20:47:19 +0000 (21:47 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Fri, 20 Feb 2015 20:47:19 +0000 (21:47 +0100)
16 files changed:
accelerator/cpu/image/image_mixer.cpp
accelerator/cpu/image/image_mixer.h
accelerator/ogl/image/image_mixer.cpp
common/cache_aligned_vector.h [new file with mode: 0644]
common/common.vcxproj
common/common.vcxproj.filters
core/frame/frame.h
core/mixer/audio/audio_mixer.cpp
core/mixer/audio/audio_mixer.h
core/mixer/audio/audio_util.h
core/producer/draw/freehand_producer.cpp
modules/decklink/consumer/decklink_consumer.cpp
modules/ffmpeg/consumer/ffmpeg_consumer.cpp
modules/ffmpeg/producer/audio/audio_decoder.cpp
modules/oal/consumer/oal_consumer.cpp
protocol/osc/client.cpp

index 1a04dfd3ec595b04271596430423f8cdc8a9d0a5..7862cf64533e50594632dc8575ebb211d2950c78 100644 (file)
@@ -41,7 +41,6 @@
 
 #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>
index dacb0817e8417c6961bb5d04c59950306100e4e2..039e932282be5cc74ea02feb54c6c3b1c6748143 100644 (file)
@@ -20,7 +20,7 @@ FORWARD2(caspar, core, struct frame_transform);
 
 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
 {
index fa9a900ef375b8073fc6c8aaa77f85ca8e2e3ff8..5e2287e41614fcca1efb644e3e7fcbed034a29f4 100644 (file)
@@ -92,7 +92,7 @@ public:
        {       
                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));
                }               
 
diff --git a/common/cache_aligned_vector.h b/common/cache_aligned_vector.h
new file mode 100644 (file)
index 0000000..4ea02b8
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+* 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>>;
+
+}
index f61987f7b843b9a4d3827f8586554d3744046521..87660101f58ad29315267f9aaecead9a508d591c 100644 (file)
     <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
index 779d388f80a1c549bab80bf8a097b6ed3edc0d89..7d5d85df6ebe0902ecd8783c01e5ba97ca753f5a 100644 (file)
     <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
index 8fdcb8d071959cd0a7b85da9b1e30a2a9bc68f2f..240c03f5328416ba2089d044b0cd4ee775696257 100644 (file)
@@ -9,12 +9,11 @@
 #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>
 
@@ -22,7 +21,7 @@ FORWARD1(boost, template<typename> class shared_future);
 
 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
index b0f404212e4b0f53bb42b65e12a681a4ea2fd1ee..a746375ca9b9b4006eadf0197263410fa5907e6b 100644 (file)
@@ -54,7 +54,7 @@ struct audio_item
        }
 };
 
-typedef std::vector<float, tbb::cache_aligned_allocator<float>> audio_buffer_ps;
+typedef cache_aligned_vector<float> audio_buffer_ps;
        
 struct audio_stream
 {
index 96b385ff85c035540f7d3578a0920cb7d94c73c5..8ad82c5075be4e3dd525eff87aea86485374c619 100644 (file)
 
 #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>
 
@@ -35,7 +34,7 @@ FORWARD2(caspar, diagnostics, class graph);
 
 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
 {
index 833da7e3ad1e0c0d0a9fce309869ad93b0f7e6ba..c4a9c648a4543b4aa65f58cb2bf1e3f6bb5ecd6d 100644 (file)
 #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)
@@ -48,11 +48,11 @@ std::vector<int8_t, tbb::cache_aligned_allocator<int8_t>> audio_32_to_24(const T
 }
 
 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)
index c0e032aea6315d0aec79eecab0bf193ab377b9da..d06640b6d90c412786ce26c5f03116b3a2160240 100644 (file)
 
 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);
@@ -45,13 +44,13 @@ std::vector<uint8_t, tbb::cache_aligned_allocator<uint8_t>> empty_drawing(
 
 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,
index d35c0b51ab922bdc47ca616c2301d00e4381747a..e7787b1dcb1af59a4c9c6d947ded906df2845c2f 100644 (file)
 #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>
@@ -82,12 +82,12 @@ struct configuration
 
 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)
index 2a60c6721a1e5a0243ce7e9306fb83ac4b4df21e..c8d0defa56e52c57b1c0c553252a616cec9de3f8 100644 (file)
@@ -253,7 +253,7 @@ struct output_format
        }
 };
 
-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
 {              
index 3442aa7c7e2cc0382ca899953b25fcd90e91953e..14059b2005ce5e851e277164108ca79526a3e085 100644 (file)
@@ -30,8 +30,7 @@
 #include <core/video_format.h>
 
 #include <common/log.h>
-
-#include <tbb/cache_aligned_allocator.h>
+#include <common/cache_aligned_vector.h>
 
 #include <queue>
 
@@ -79,7 +78,7 @@ struct audio_decoder::impl : boost::noncopyable
                                                                                                                                                                                [](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_;
        
index 60c87c781e303e32db5af930a21614512ad1aab4..e49e6661f35326a231140bb89a208222266b35ac 100644 (file)
@@ -50,7 +50,7 @@
 
 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
 {
index f5ddea1e1df0b767e2b57d32b585001864dadd40..61e577f85723933f5b1a6ac97fb8426920d8ad23 100644 (file)
@@ -30,7 +30,7 @@
 #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>
@@ -42,7 +42,6 @@
 #include <boost/thread.hpp>
 
 #include <tbb/spin_mutex.h>
-#include <tbb/cache_aligned_allocator.h>
 
 using namespace boost::asio::ip;
 
@@ -60,7 +59,7 @@ struct no_init_proxy
     }
 };
 
-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>