\r
#include "../../format/video_format.h"\r
\r
-#include "../../../common/gl/utility.h"\r
-#include "../../../common/gl/pixel_buffer_object.h"\r
-#include "../../../common/concurrency/executor.h"\r
+#include <common/gl/utility.h>\r
+#include <common/concurrency/executor.h>\r
\r
#include <boost/thread.hpp>\r
\r
struct consumer::implementation : boost::noncopyable\r
{ \r
implementation(const video_format_desc& format_desc, unsigned int screen_index, stretch stretch, bool windowed) \r
- : format_desc_(format_desc), stretch_(stretch), screen_width_(0), screen_height_(0), windowed_(windowed)\r
+ : format_desc_(format_desc), stretch_(stretch), screen_width_(0), screen_height_(0), windowed_(windowed), texture_(0)\r
{ \r
#ifdef _WIN32\r
DISPLAY_DEVICE d_device; \r
\r
wSize_ = target_ratio.first;\r
hSize_ = target_ratio.second;\r
- \r
- pbos_[0].create(format_desc_.width, format_desc_.height);\r
- pbos_[1].create(format_desc_.width, format_desc_.height);\r
+ \r
+ glGenTextures(1, &texture_);\r
+ glBindTexture(GL_TEXTURE_2D, texture_);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);\r
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, format_desc_.width, format_desc_.height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);\r
+ glBindTexture(GL_TEXTURE_2D, 0);\r
+ \r
+ GL(glGenBuffers(2, pbos_.data()));\r
+ \r
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbos_[0]);\r
+ glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, format_desc_.size, 0, GL_STREAM_DRAW_ARB);\r
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbos_[1]);\r
+ glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, format_desc_.size, 0, GL_STREAM_DRAW_ARB);\r
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);\r
});\r
}\r
\r
}\r
\r
void render(const safe_ptr<const read_frame>& frame)\r
- { \r
- auto ptr = pbos_.front().map_write();\r
- std::copy_n(frame->image_data().begin(), frame->image_data().size(), reinterpret_cast<char*>(ptr));\r
+ { \r
+ glBindTexture(GL_TEXTURE_2D, texture_);\r
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbos_[0]);\r
\r
- GL(glClear(GL_COLOR_BUFFER_BIT)); \r
- pbos_.back().bind_texture(); \r
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, format_desc_.width, format_desc_.height, GL_BGRA, GL_UNSIGNED_BYTE, 0);\r
+\r
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbos_[1]);\r
+\r
+ glBufferData(GL_PIXEL_UNPACK_BUFFER, format_desc_.size, 0, GL_STREAM_DRAW);\r
+\r
+ auto ptr = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);\r
+ if(ptr)\r
+ {\r
+ std::copy_n(frame->image_data().begin(), frame->image_data().size(), reinterpret_cast<char*>(ptr));\r
+ glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); // release the mapped buffer\r
+ }\r
+\r
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);\r
+ \r
+ GL(glClear(GL_COLOR_BUFFER_BIT)); \r
glBegin(GL_QUADS);\r
glTexCoord2f(0.0f, hratio_); glVertex2f(-wSize_, -hSize_);\r
glTexCoord2f(wratio_, hratio_); glVertex2f( wSize_, -hSize_);\r
glTexCoord2f(wratio_, 0.0f); glVertex2f( wSize_, hSize_);\r
glTexCoord2f(0.0f, 0.0f); glVertex2f(-wSize_, hSize_);\r
glEnd();\r
-\r
- pbos_.back().unmap_write();\r
+ \r
+ glBindTexture(GL_TEXTURE_2D, 0);\r
\r
std::rotate(pbos_.begin(), pbos_.begin() + 1, pbos_.end());\r
}\r
float wSize_;\r
float hSize_;\r
\r
- std::array<gl::pixel_buffer_object, 2> pbos_;\r
+ GLuint texture_;\r
+ std::array<GLuint, 2> pbos_;\r
\r
bool windowed_;\r
unsigned int screen_width_;\r
unsigned int screen_y_;\r
\r
stretch stretch_;\r
- video_format_desc format_desc_;\r
+ const video_format_desc format_desc_;\r
\r
sf::Window window_;\r
};\r
<ClInclude Include="format\pixel_format.h" />\r
<ClInclude Include="format\video_format.h" />\r
<ClInclude Include="processor\audio_processor.h" />\r
- <ClInclude Include="processor\buffer\read_buffer.h" />\r
- <ClInclude Include="processor\buffer\write_buffer.h" />\r
+ <ClInclude Include="processor\device_buffer.h" />\r
<ClInclude Include="processor\frame_processor_device.h" />\r
+ <ClInclude Include="processor\host_buffer.h" />\r
+ <ClInclude Include="processor\image_kernel.h" />\r
<ClInclude Include="processor\image_processor.h" />\r
<ClInclude Include="processor\fwd.h" />\r
<ClInclude Include="processor\read_frame.h" />\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
</ClCompile>\r
- <ClCompile Include="processor\buffer\read_buffer.cpp">\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../StdAfx.h</PrecompiledHeaderFile>\r
- </ClCompile>\r
- <ClCompile Include="processor\buffer\write_buffer.cpp">\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../StdAfx.h</PrecompiledHeaderFile>\r
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../StdAfx.h</PrecompiledHeaderFile>\r
+ <ClCompile Include="processor\device_buffer.cpp">\r
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
</ClCompile>\r
<ClCompile Include="processor\frame_processor_device.cpp">\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
</ClCompile>\r
+ <ClCompile Include="processor\host_buffer.cpp">\r
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
+ </ClCompile>\r
+ <ClCompile Include="processor\image_kernel.cpp">\r
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
+ </ClCompile>\r
<ClCompile Include="processor\image_processor.cpp">\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
<Filter Include="Source\channel\processor\audio">\r
<UniqueIdentifier>{e3d8bd98-8cb9-4f4a-8cf0-bd455ce9138d}</UniqueIdentifier>\r
</Filter>\r
- <Filter Include="Source\channel\processor\buffer">\r
- <UniqueIdentifier>{d6518ab7-eb0c-4cbe-b83c-a9e32c062b6f}</UniqueIdentifier>\r
- </Filter>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="StdAfx.h">\r
<ClInclude Include="processor\draw_frame.h">\r
<Filter>Source\channel\processor\frame</Filter>\r
</ClInclude>\r
- <ClInclude Include="processor\buffer\write_buffer.h">\r
- <Filter>Source\channel\processor\buffer</Filter>\r
+ <ClInclude Include="processor\image_kernel.h">\r
+ <Filter>Source\channel\processor\image</Filter>\r
</ClInclude>\r
- <ClInclude Include="processor\buffer\read_buffer.h">\r
- <Filter>Source\channel\processor\buffer</Filter>\r
+ <ClInclude Include="processor\device_buffer.h">\r
+ <Filter>Source\channel\processor\image</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="processor\host_buffer.h">\r
+ <Filter>Source\channel\processor\image</Filter>\r
</ClInclude>\r
</ItemGroup>\r
<ItemGroup>\r
<ClCompile Include="processor\draw_frame.cpp">\r
<Filter>Source\channel\processor\frame</Filter>\r
</ClCompile>\r
- <ClCompile Include="processor\buffer\read_buffer.cpp">\r
- <Filter>Source\channel\processor\buffer</Filter>\r
+ <ClCompile Include="processor\image_kernel.cpp">\r
+ <Filter>Source\channel\processor\image</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="processor\device_buffer.cpp">\r
+ <Filter>Source\channel\processor\image</Filter>\r
</ClCompile>\r
- <ClCompile Include="processor\buffer\write_buffer.cpp">\r
- <Filter>Source\channel\processor\buffer</Filter>\r
+ <ClCompile Include="processor\host_buffer.cpp">\r
+ <Filter>Source\channel\processor\image</Filter>\r
</ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
+++ /dev/null
-#include "../../StdAfx.h"\r
-\r
-#include "read_buffer.h"\r
-\r
-#include <common/gl/utility.h>\r
-\r
-namespace caspar { namespace core {\r
- \r
-struct read_buffer::implementation : boost::noncopyable\r
-{\r
- implementation(size_t width, size_t height) : width_(width), height_(height), size_(width*height*4), data_(nullptr), pbo_(0)\r
- {\r
- GL(glGenBuffers(1, &pbo_));\r
- GL(glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo_));\r
- GL(glBufferData(GL_PIXEL_PACK_BUFFER, size_, NULL, GL_STREAM_READ)); \r
- GL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));\r
-\r
- if(!pbo_)\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Failed to allocate buffer."));\r
- CASPAR_LOG(trace) << "[read_buffer] Allocated.";\r
- } \r
-\r
- ~implementation()\r
- {\r
- glDeleteBuffers(1, &pbo_);\r
- }\r
-\r
- void map()\r
- {\r
- if(data_)\r
- return;\r
-\r
- GL(glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo_));\r
- data_ = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); \r
- GL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));\r
- if(!data_)\r
- BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Failed to map GL_PIXEL_PACK_BUFFER OpenGL Pixel Buffer Object."));\r
- }\r
-\r
- void unmap()\r
- {\r
- if(!data_)\r
- return;\r
-\r
- GL(glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo_));\r
- GL(glUnmapBuffer(GL_PIXEL_PACK_BUFFER)); \r
- data_ = nullptr;\r
- GL(glBufferData(GL_PIXEL_PACK_BUFFER, size_, NULL, GL_STREAM_READ)); \r
- GL(glReadPixels(0, 0, width_, height_, GL_BGRA, GL_UNSIGNED_BYTE, NULL));\r
- GL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));\r
- }\r
- \r
- GLuint pbo_;\r
-\r
- const size_t size_;\r
- const size_t width_;\r
- const size_t height_;\r
-\r
- void* data_;\r
- std::vector<short> audio_data_;\r
-};\r
-\r
-read_buffer::read_buffer(size_t width, size_t height) : impl_(new implementation(width, height)){}\r
-const void* read_buffer::data() const {return impl_->data_;}\r
-void read_buffer::map(){impl_->map();}\r
-void read_buffer::unmap(){impl_->unmap();}\r
-size_t read_buffer::size() const { return impl_->size_; }\r
-size_t read_buffer::width() const { return impl_->width_; }\r
-size_t read_buffer::height() const { return impl_->height_; }\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-#include "../../StdAfx.h"\r
-\r
-#include "write_buffer.h"\r
-\r
-#include <common/exception/exceptions.h>\r
-#include <common/gl/utility.h>\r
-\r
-namespace caspar { namespace core {\r
-\r
-GLenum FORMAT[] = {0, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGR, GL_BGRA};\r
-GLenum INTERNAL_FORMAT[] = {0, GL_LUMINANCE8, GL_LUMINANCE8_ALPHA8, GL_RGB8, GL_RGBA8}; \r
-\r
-struct write_buffer::implementation : boost::noncopyable\r
-{\r
- implementation(size_t width, size_t height, size_t depth) : width_(width), height_(height), size_(width*height*depth), pbo_(0), format_(FORMAT[depth]), data_(nullptr), texture_(0)\r
- {\r
- GL(glGenBuffers(1, &pbo_));\r
- GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo_));\r
- GL(glBufferData(GL_PIXEL_UNPACK_BUFFER, size_, NULL, GL_STREAM_DRAW));\r
- GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));\r
- \r
- if(!pbo_)\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Failed to allocate buffer."));\r
-\r
- GL(glGenTextures(1, &texture_));\r
- GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));\r
- GL(glTexImage2D(GL_TEXTURE_2D, 0, INTERNAL_FORMAT[depth], width_, height_, 0, format_, GL_UNSIGNED_BYTE, NULL));\r
- GL(glBindTexture(GL_TEXTURE_2D, 0));\r
- \r
- if(!texture_)\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Failed to allocate texture."));\r
-\r
- CASPAR_LOG(trace) << "[write_buffer] Allocated.";\r
- }\r
-\r
- ~implementation()\r
- {\r
- glDeleteBuffers(1, &pbo_);\r
- glDeleteTextures(1, &texture_);\r
- } \r
- \r
- void unmap()\r
- {\r
- if(!data_)\r
- return;\r
-\r
- GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo_));\r
-\r
- GL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));\r
- data_ = nullptr;\r
-\r
- GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
- GL(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width_, height_, format_, GL_UNSIGNED_BYTE, NULL));\r
-\r
- GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));\r
- }\r
-\r
- void map()\r
- {\r
- if(data_)\r
- return;\r
- \r
- GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo_));\r
-\r
- GL(glBufferData(GL_PIXEL_UNPACK_BUFFER, size_, NULL, GL_STREAM_DRAW));\r
- data_= glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);\r
-\r
- GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));\r
-\r
- if(!data_)\r
- BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("glMapBuffer failed"));\r
- }\r
- \r
- GLuint pbo_;\r
- GLuint texture_;\r
-\r
- const size_t width_;\r
- const size_t height_;\r
- const size_t size_;\r
- \r
- GLenum format_;\r
- void* data_;\r
-};\r
-\r
-write_buffer::write_buffer(write_buffer&& other) : impl_(std::move(other.impl_)){}\r
-write_buffer::write_buffer(size_t width, size_t height, size_t depth) : impl_(new implementation(width, height, depth)){}\r
-write_buffer& write_buffer::operator=(write_buffer&& other)\r
-{\r
- impl_ = std::move(other.impl_);\r
- return *this;\r
-}\r
-void* write_buffer::data(){return impl_->data_;}\r
-void write_buffer::unmap() { impl_->unmap();}\r
-void write_buffer::map() {impl_->map();} \r
-size_t write_buffer::size() const {return impl_->size_;}\r
-size_t write_buffer::width() const {return impl_->width_;}\r
-size_t write_buffer::height() const {return impl_->height_;}\r
-}}
\ No newline at end of file
+++ /dev/null
-#pragma once\r
-\r
-#include <memory>\r
-\r
-#include <boost/noncopyable.hpp>\r
-\r
-#include <Glee.h>\r
-\r
-#include <boost/tuple/tuple.hpp>\r
-#include <boost/thread/future.hpp>\r
-\r
-namespace caspar { namespace core {\r
- \r
-class write_buffer : boost::noncopyable\r
-{\r
- friend class image_processor;\r
-public:\r
-\r
- write_buffer(write_buffer&& other);\r
- write_buffer(size_t width, size_t height, size_t depth);\r
- write_buffer& operator=(write_buffer&& other);\r
- \r
- void* data();\r
- size_t size() const;\r
- size_t width() const;\r
- size_t height() const;\r
- \r
- void map();\r
- void unmap();\r
-\r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-}}
\ No newline at end of file
--- /dev/null
+#include "../StdAfx.h"\r
+\r
+#include "device_buffer.h"\r
+\r
+#include <common/gl/utility.h>\r
+\r
+namespace caspar { namespace core {\r
+ \r
+GLenum FORMAT[] = {0, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGR, GL_BGRA};\r
+GLenum INTERNAL_FORMAT[] = {0, GL_LUMINANCE8, GL_LUMINANCE8_ALPHA8, GL_RGB8, GL_RGBA8}; \r
+\r
+struct device_buffer::implementation : boost::noncopyable\r
+{\r
+ implementation(size_t width, size_t height, size_t stride) : width_(width), height_(height), stride_(stride)\r
+ { \r
+ GL(glGenTextures(1, &id_));\r
+ GL(glBindTexture(GL_TEXTURE_2D, id_));\r
+ GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));\r
+ GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));\r
+ GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));\r
+ GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));\r
+ GL(glTexImage2D(GL_TEXTURE_2D, 0, INTERNAL_FORMAT[stride_], width_, height_, 0, FORMAT[stride_], GL_UNSIGNED_BYTE, NULL));\r
+ GL(glBindTexture(GL_TEXTURE_2D, 0)); \r
+ } \r
+\r
+ ~implementation()\r
+ {\r
+ glDeleteTextures(1, &id_);\r
+ }\r
+ \r
+ void bind()\r
+ {\r
+ GL(glBindTexture(GL_TEXTURE_2D, id_));\r
+ }\r
+\r
+ void unbind()\r
+ {\r
+ GL(glBindTexture(GL_TEXTURE_2D, 0));\r
+ }\r
+\r
+ void read(host_buffer& source)\r
+ {\r
+ GL(glBindTexture(GL_TEXTURE_2D, id_));\r
+ source.unmap();\r
+ source.bind();\r
+ GL(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width_, height_, FORMAT[stride_], GL_UNSIGNED_BYTE, NULL));\r
+ source.unbind();\r
+ GL(glBindTexture(GL_TEXTURE_2D, 0));\r
+ }\r
+ \r
+ void write(host_buffer& target)\r
+ {\r
+ GL(glBindTexture(GL_TEXTURE_2D, id_));\r
+ target.unmap();\r
+ target.bind();\r
+ GL(glReadPixels(0, 0, width_, height_, FORMAT[stride_], GL_UNSIGNED_BYTE, NULL));\r
+ target.unbind();\r
+ GL(glBindTexture(GL_TEXTURE_2D, 0));\r
+ }\r
+\r
+ void attach(int index)\r
+ {\r
+ GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT + index, GL_TEXTURE_2D, id_, 0));\r
+ }\r
+\r
+ GLuint id_;\r
+\r
+ const size_t width_;\r
+ const size_t height_;\r
+ const size_t stride_;\r
+};\r
+\r
+device_buffer::device_buffer(size_t width, size_t height, size_t stride) : impl_(new implementation(width, height, stride)){}\r
+size_t device_buffer::stride() const { return impl_->stride_; }\r
+size_t device_buffer::width() const { return impl_->width_; }\r
+size_t device_buffer::height() const { return impl_->height_; }\r
+void device_buffer::attach(int index){impl_->attach(index);}\r
+void device_buffer::bind(){impl_->bind();}\r
+void device_buffer::unbind(){impl_->unbind();}\r
+void device_buffer::read(host_buffer& source){impl_->read(source);}\r
+void device_buffer::write(host_buffer& target){impl_->write(target);}\r
+GLuint device_buffer::id() const { return impl_->id_; }\r
+\r
+}}
\ No newline at end of file
--- /dev/null
+#pragma once\r
+\r
+#include "host_buffer.h"\r
+\r
+#include <boost/noncopyable.hpp>\r
+\r
+#include <memory>\r
+\r
+namespace caspar { namespace core {\r
+ \r
+class device_buffer \r
+{\r
+public:\r
+ device_buffer(size_t width, size_t height, size_t stride);\r
+ \r
+ size_t stride() const; \r
+ size_t width() const;\r
+ size_t height() const;\r
+ \r
+ void bind();\r
+ void unbind();\r
+\r
+ void attach(int index);\r
+ void read(host_buffer& source);\r
+ void write(host_buffer& target);\r
+\r
+ GLuint id() const;\r
+\r
+private:\r
+ struct implementation;\r
+ std::shared_ptr<implementation> impl_;\r
+};\r
+\r
+}}
\ No newline at end of file
\r
#include "draw_frame.h"\r
\r
-#include "draw_frame.h"\r
#include "image_processor.h"\r
#include "audio_processor.h"\r
\r
#include "../format/pixel_format.h"\r
-#include "../../common/gl/utility.h"\r
-#include "../../common/gl/pixel_buffer_object.h"\r
#include "../../common/utility/singleton_pool.h"\r
\r
#include <boost/range/algorithm.hpp>\r
\r
-#include <tbb/parallel_for.h>\r
-\r
namespace caspar { namespace core {\r
\r
struct draw_frame::implementation\r
class draw_frame\r
{\r
public:\r
- draw_frame();\r
+ draw_frame(); \r
+ draw_frame(safe_ptr<write_frame>&& image, std::vector<short>&& audio);\r
draw_frame(const safe_ptr<draw_frame>& frame);\r
draw_frame(safe_ptr<draw_frame>&& frame);\r
draw_frame(const std::vector<safe_ptr<draw_frame>>& frames);\r
audio_processor audio_processor_;\r
image_processor image_processor_;\r
\r
- std::queue<boost::unique_future<safe_ptr<const read_buffer>>> image_buffer_;\r
+ std::queue<boost::unique_future<safe_ptr<const host_buffer>>> image_buffer_;\r
std::queue<std::vector<short>> audio_buffer_;\r
\r
const video_format_desc fmt_;\r
+++ /dev/null
-#pragma once\r
-\r
-#include "fwd.h"\r
-\r
-#include "../../common/exception/exceptions.h"\r
-\r
-#include <boost/noncopyable.hpp>\r
-\r
-#include <memory>\r
-#include <vector>\r
-\r
-namespace caspar { namespace core {\r
- \r
-class gpu_frame : boost::noncopyable\r
-{ \r
-public:\r
- virtual const std::vector<short>& audio_data() const = 0;\r
- virtual std::vector<short>& audio_data() = 0;\r
- \r
- virtual void begin_write() = 0;\r
- virtual void end_write() = 0;\r
- virtual void draw(frame_shader& shader) = 0;\r
-};\r
-typedef std::shared_ptr<gpu_frame> gpu_frame_ptr;\r
-\r
-\r
-}}
\ No newline at end of file
--- /dev/null
+#include "../StdAfx.h"\r
+\r
+#include "host_buffer.h"\r
+\r
+#include <common/gl/utility.h>\r
+\r
+namespace caspar { namespace core {\r
+ \r
+struct host_buffer::implementation : boost::noncopyable\r
+{\r
+ implementation(size_t size, usage_t usage) : size_(size), data_(nullptr), pbo_(0),\r
+ target_(usage == write_only ? GL_PIXEL_UNPACK_BUFFER : GL_PIXEL_PACK_BUFFER), usage_(usage == write_only ? GL_STREAM_DRAW : GL_STREAM_READ)\r
+ {\r
+ GL(glGenBuffers(1, &pbo_));\r
+ GL(glBindBuffer(target_, pbo_));\r
+ GL(glBufferData(target_, size_, NULL, usage_)); \r
+ GL(glBindBuffer(target_, 0));\r
+\r
+ if(!pbo_)\r
+ BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Failed to allocate buffer."));\r
+ CASPAR_LOG(trace) << "[host_buffer] Allocated.";\r
+ } \r
+\r
+ ~implementation()\r
+ {\r
+ glDeleteBuffers(1, &pbo_);\r
+ }\r
+\r
+ void map()\r
+ {\r
+ if(data_)\r
+ return;\r
+ \r
+ GL(glBindBuffer(target_, pbo_));\r
+ data_ = glMapBuffer(target_, usage_ == GL_STREAM_DRAW ? GL_WRITE_ONLY : GL_READ_ONLY); \r
+ GL(glBindBuffer(target_, 0)); \r
+ if(!data_)\r
+ BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Failed to map target_ OpenGL Pixel Buffer Object."));\r
+ }\r
+\r
+ void unmap()\r
+ {\r
+ if(!data_)\r
+ return;\r
+ \r
+ GL(glBindBuffer(target_, pbo_));\r
+ GL(glUnmapBuffer(target_)); \r
+ data_ = nullptr; \r
+ GL(glBindBuffer(target_, 0));\r
+ }\r
+\r
+ void bind()\r
+ {\r
+ GL(glBindBuffer(target_, pbo_));\r
+ }\r
+\r
+ void unbind()\r
+ {\r
+ GL(glBindBuffer(target_, 0));\r
+ }\r
+ \r
+ GLuint pbo_;\r
+\r
+ const size_t size_;\r
+\r
+ void* data_;\r
+ GLenum usage_;\r
+ GLenum target_;\r
+};\r
+\r
+host_buffer::host_buffer(size_t size, usage_t usage) : impl_(new implementation(size, usage)){}\r
+const void* host_buffer::data() const {return impl_->data_;}\r
+void* host_buffer::data() {return impl_->data_;}\r
+void host_buffer::map(){impl_->map();}\r
+void host_buffer::unmap(){impl_->unmap();}\r
+void host_buffer::bind(){impl_->bind();}\r
+void host_buffer::unbind(){impl_->unbind();}\r
+\r
+size_t host_buffer::size() const { return impl_->size_; }\r
+\r
+}}
\ No newline at end of file
#include <memory>\r
\r
namespace caspar { namespace core {\r
- \r
-class read_buffer \r
+ \r
+class host_buffer \r
{\r
- friend class image_processor;\r
public:\r
- read_buffer(size_t width, size_t height);\r
+ enum usage_t\r
+ {\r
+ write_only,\r
+ read_only\r
+ };\r
+ host_buffer(size_t size, usage_t usage);\r
\r
const void* data() const;\r
+ void* data();\r
size_t size() const; \r
- size_t width() const;\r
- size_t height() const;\r
- \r
+ \r
+ void bind();\r
+ void unbind();\r
void unmap();\r
void map();\r
private:\r
--- /dev/null
+#include "../StdAfx.h"\r
+\r
+#include "image_kernel.h"\r
+\r
+#include <common/exception/exceptions.h>\r
+#include <common/gl/utility.h>\r
+\r
+#include <Glee.h>\r
+\r
+#include <boost/noncopyable.hpp>\r
+\r
+#include <unordered_map>\r
+\r
+namespace caspar { namespace core {\r
+\r
+class shader_program\r
+{\r
+public:\r
+\r
+ shader_program() : program_(0) {}\r
+ shader_program(const std::string& vertex_source_str, const std::string& fragment_source_str) : program_(0)\r
+ {\r
+ GLint success;\r
+ \r
+ const char* vertex_source = vertex_source_str.c_str();\r
+ \r
+ auto vertex_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);\r
+ \r
+ GL(glShaderSourceARB(vertex_shader, 1, &vertex_source, NULL));\r
+ GL(glCompileShaderARB(vertex_shader));\r
+\r
+ GL(glGetObjectParameterivARB(vertex_shader, GL_OBJECT_COMPILE_STATUS_ARB, &success));\r
+ if (success == GL_FALSE)\r
+ {\r
+ char info[2048];\r
+ GL(glGetInfoLogARB(vertex_shader, sizeof(info), 0, info));\r
+ GL(glDeleteObjectARB(vertex_shader));\r
+ std::stringstream str;\r
+ str << "Failed to compile vertex shader:" << std::endl << info << std::endl;\r
+ BOOST_THROW_EXCEPTION(gl::gl_error() << msg_info(str.str()));\r
+ }\r
+ \r
+ const char* fragment_source = fragment_source_str.c_str();\r
+ \r
+ auto fragmemt_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);\r
+ \r
+ GL(glShaderSourceARB(fragmemt_shader, 1, &fragment_source, NULL));\r
+ GL(glCompileShaderARB(fragmemt_shader));\r
+\r
+ GL(glGetObjectParameterivARB(fragmemt_shader, GL_OBJECT_COMPILE_STATUS_ARB, &success));\r
+ if (success == GL_FALSE)\r
+ {\r
+ char info[2048];\r
+ GL(glGetInfoLogARB(fragmemt_shader, sizeof(info), 0, info));\r
+ GL(glDeleteObjectARB(fragmemt_shader));\r
+ std::stringstream str;\r
+ str << "Failed to compile fragment shader:" << std::endl << info << std::endl;\r
+ BOOST_THROW_EXCEPTION(gl::gl_error() << msg_info(str.str()));\r
+ }\r
+ \r
+ program_ = glCreateProgramObjectARB();\r
+ \r
+ GL(glAttachObjectARB(program_, vertex_shader));\r
+ GL(glAttachObjectARB(program_, fragmemt_shader));\r
+\r
+ GL(glLinkProgramARB(program_));\r
+ \r
+ GL(glDeleteObjectARB(vertex_shader));\r
+ GL(glDeleteObjectARB(fragmemt_shader));\r
+\r
+ GL(glGetObjectParameterivARB(program_, GL_OBJECT_LINK_STATUS_ARB, &success));\r
+ if (success == GL_FALSE)\r
+ {\r
+ char info[2048];\r
+ GL(glGetInfoLogARB(program_, sizeof(info), 0, info));\r
+ GL(glDeleteObjectARB(program_));\r
+ std::stringstream str;\r
+ str << "Failed to link shader program:" << std::endl << info << std::endl;\r
+ BOOST_THROW_EXCEPTION(gl::gl_error() << msg_info(str.str()));\r
+ }\r
+ GL(glUseProgramObjectARB(program_));\r
+ glUniform1i(glGetUniformLocation(program_, "plane[0]"), 0);\r
+ glUniform1i(glGetUniformLocation(program_, "plane[1]"), 1);\r
+ glUniform1i(glGetUniformLocation(program_, "plane[2]"), 2);\r
+ glUniform1i(glGetUniformLocation(program_, "plane[3]"), 3);\r
+ }\r
+\r
+ shader_program& operator=(shader_program&& other) \r
+ {\r
+ program_ = other.program_; \r
+ other.program_ = 0; \r
+ return *this;\r
+ }\r
+\r
+ ~shader_program()\r
+ {\r
+ glDeleteProgram(program_);\r
+ }\r
+\r
+ void use()\r
+ { \r
+ GL(glUseProgramObjectARB(program_)); \r
+ }\r
+\r
+private:\r
+ GLuint program_;\r
+};\r
+\r
+GLubyte progressive_pattern[] = {\r
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xFF, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\r
+ \r
+GLubyte upper_pattern[] = {\r
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00};\r
+ \r
+GLubyte lower_pattern[] = {\r
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, \r
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,\r
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,\r
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff};\r
+\r
+struct image_kernel::implementation\r
+{\r
+ std::unordered_map<pixel_format::type, shader_program>& shaders()\r
+ {\r
+ if(shaders_.empty())\r
+ {\r
+ std::string common_vertex = \r
+ "void main() "\r
+ "{ "\r
+ " gl_TexCoord[0] = gl_MultiTexCoord0; "\r
+ " gl_FrontColor = gl_Color; "\r
+ " gl_Position = ftransform(); "\r
+ "} ";\r
+\r
+ std::string common_fragment = \r
+ "uniform sampler2D plane[4]; "\r
+ "uniform vec4 plane_size[2]; "\r
+ \r
+ // NOTE: YCbCr, ITU-R, http://www.intersil.com/data/an/an9717.pdf \r
+ // TODO: Support for more yuv formats might be needed. \r
+ "vec4 ycbcra_to_bgra(float y, float cb, float cr, float a) "\r
+ "{ "\r
+ " cb -= 0.5; "\r
+ " cr -= 0.5; "\r
+ " y = 1.164*(y-0.0625); "\r
+ " "\r
+ " vec4 color; "\r
+ " color.r = y + 1.596 * cr; "\r
+ " color.g = y - 0.813 * cr - 0.337633 * cb; "\r
+ " color.b = y + 2.017 * cb; "\r
+ " color.a = a; "\r
+ " "\r
+ " return color; "\r
+ "} " \r
+ " ";\r
+ \r
+ shaders_[pixel_format::abgr] = shader_program(common_vertex, common_fragment +\r
+\r
+ "void main() "\r
+ "{ "\r
+ " vec4 abgr = texture2D(plane[0], gl_TexCoord[0].st);"\r
+ " gl_FragColor = abgr.argb * gl_Color; "\r
+ "} ");\r
+ \r
+ shaders_[pixel_format::argb]= shader_program(common_vertex, common_fragment +\r
+\r
+ "void main() " \r
+ "{ "\r
+ " vec4 argb = texture2D(plane[0], gl_TexCoord[0].st);"\r
+ " gl_FragColor = argb.grab * gl_Color; " \r
+ "} ");\r
+ \r
+ shaders_[pixel_format::bgra]= shader_program(common_vertex, common_fragment +\r
+\r
+ "void main() "\r
+ "{ "\r
+ " vec4 bgra = texture2D(plane[0], gl_TexCoord[0].st);"\r
+ " gl_FragColor = bgra.rgba * gl_Color; "\r
+ "} ");\r
+ \r
+ shaders_[pixel_format::rgba] = shader_program(common_vertex, common_fragment +\r
+\r
+ "void main() "\r
+ "{ "\r
+ " vec4 rgba = texture2D(plane[0], gl_TexCoord[0].st); "\r
+ " gl_FragColor = rgba.bgra * gl_Color; "\r
+ "} ");\r
+ \r
+ shaders_[pixel_format::ycbcr] = shader_program(common_vertex, common_fragment +\r
+\r
+ "void main() "\r
+ "{ "\r
+ " float y = texture2D(plane[0], gl_TexCoord[0].st).r;"\r
+ " float cb = texture2D(plane[1], gl_TexCoord[0].st).r;"\r
+ " float cr = texture2D(plane[2], gl_TexCoord[0].st).r;"\r
+ " float a = 1.0; " \r
+ " gl_FragColor = ycbcra_to_bgra(y, cb, cr, a) * gl_Color; "\r
+ "} ");\r
+ \r
+ shaders_[pixel_format::ycbcra] = shader_program(common_vertex, common_fragment +\r
+\r
+ "void main() "\r
+ "{ "\r
+ " float y = texture2D(plane[0], gl_TexCoord[0].st).r;"\r
+ " float cb = texture2D(plane[1], gl_TexCoord[0].st).r;"\r
+ " float cr = texture2D(plane[2], gl_TexCoord[0].st).r;"\r
+ " float a = texture2D(plane[3], gl_TexCoord[0].st).r;"\r
+ " gl_FragColor = ycbcra_to_bgra(y, cb, cr, a) * gl_Color; "\r
+ "} ");\r
+ }\r
+ return shaders_;\r
+ }\r
+ \r
+ std::unordered_map<pixel_format::type, shader_program> shaders_;\r
+};\r
+\r
+image_kernel::image_kernel() : impl_(new implementation()){}\r
+\r
+void image_kernel::use(pixel_format::type pix_fmt, video_mode::type mode)\r
+{\r
+ impl_->shaders()[pix_fmt].use();\r
+\r
+ if(mode == video_mode::upper)\r
+ glPolygonStipple(upper_pattern);\r
+ else if(mode == video_mode::lower)\r
+ glPolygonStipple(lower_pattern);\r
+ else\r
+ glPolygonStipple(progressive_pattern);\r
+}\r
+\r
+}}
\ No newline at end of file
--- /dev/null
+#pragma once\r
+\r
+#include "../format/pixel_format.h"\r
+#include "../format/video_format.h"\r
+\r
+#include <memory>\r
+\r
+namespace caspar { namespace core {\r
+ \r
+class image_kernel\r
+{\r
+public:\r
+ image_kernel();\r
+ void use(pixel_format::type pix_fmt, video_mode::type mode);\r
+\r
+private:\r
+ struct implementation;\r
+ std::shared_ptr<implementation> impl_;\r
+};\r
+\r
+}}
\ No newline at end of file
#include "../StdAfx.h"\r
\r
#include "image_processor.h"\r
+#include "image_kernel.h"\r
\r
-#include "buffer/read_buffer.h"\r
-#include "buffer/write_buffer.h"\r
+#include "host_buffer.h"\r
+#include "device_buffer.h"\r
\r
#include <common/exception/exceptions.h>\r
#include <common/gl/utility.h>\r
-#include <common/gl/shader_program.h>\r
-#include <common/gl/frame_buffer_object.h>\r
#include <common/concurrency/executor.h>\r
\r
#include <Glee.h>\r
\r
#include <unordered_map>\r
\r
-struct ogl_context\r
-{\r
- ogl_context(){context_.SetActive(true);};\r
- sf::Context context_;\r
-};\r
-\r
namespace caspar { namespace core {\r
\r
+class ogl_context\r
+{ \r
+public:\r
+ \r
+ ogl_context()\r
+ {\r
+ executor_.start();\r
+ invoke([=]\r
+ {\r
+ context_.reset(new sf::Context());\r
+ context_->SetActive(true);\r
+ });\r
+ }\r
+\r
+ template<typename Func>\r
+ auto begin_invoke(Func&& func) -> boost::unique_future<decltype(func())> // noexcept\r
+ { \r
+ return executor_.begin_invoke(std::forward<Func>(func));\r
+ }\r
+ \r
+ template<typename Func>\r
+ auto invoke(Func&& func) -> decltype(func())\r
+ {\r
+ return executor_.invoke(std::forward<Func>(func));\r
+ }\r
+ \r
+ safe_ptr<device_buffer> create_device_buffer(size_t width, size_t height, size_t stride)\r
+ {\r
+ auto pool = &device_pools_[stride][((width << 12) & 0x00FFF000) | ((height << 0) & 0x00000FFF)];\r
+ std::shared_ptr<device_buffer> buffer;\r
+ if(!pool->try_pop(buffer)) \r
+ {\r
+ executor_.invoke([&]\r
+ {\r
+ buffer = std::make_shared<device_buffer>(width, height, stride);\r
+ }); \r
+ }\r
+ \r
+ return safe_ptr<device_buffer>(buffer.get(), [=](device_buffer*){pool->push(buffer);});\r
+ }\r
+ \r
+ safe_ptr<host_buffer> create_host_buffer(size_t size, host_buffer::usage_t usage)\r
+ {\r
+ auto pool = &host_pools_[usage][size];\r
+ std::shared_ptr<host_buffer> buffer;\r
+ if(!pool->try_pop(buffer))\r
+ {\r
+ executor_.invoke([&]\r
+ {\r
+ buffer = std::make_shared<host_buffer>(size, usage);\r
+ if(usage == host_buffer::write_only)\r
+ buffer->map();\r
+ else\r
+ buffer->unmap();\r
+ }); \r
+ }\r
+\r
+ return safe_ptr<host_buffer>(buffer.get(), [=](host_buffer*)\r
+ {\r
+ executor_.begin_invoke([=]\r
+ {\r
+ if(usage == host_buffer::write_only)\r
+ buffer->map();\r
+ else\r
+ buffer->unmap();\r
+ pool->push(buffer);\r
+ });\r
+ });\r
+ }\r
+private:\r
+ executor executor_;\r
+ std::unique_ptr<sf::Context> context_;\r
+ \r
+ std::array<tbb::concurrent_unordered_map<size_t, tbb::concurrent_bounded_queue<std::shared_ptr<device_buffer>>>, 4> device_pools_;\r
+ std::array<tbb::concurrent_unordered_map<size_t, tbb::concurrent_bounded_queue<std::shared_ptr<host_buffer>>>, 2> host_pools_;\r
+};\r
+\r
image_transform& image_transform::operator*=(const image_transform &other)\r
{\r
alpha *= other.alpha;\r
return image_transform(*this) *= other;\r
}\r
\r
-GLubyte progressive_pattern[] = {\r
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xFF, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\r
- \r
-GLubyte upper_pattern[] = {\r
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00};\r
- \r
-GLubyte lower_pattern[] = {\r
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, \r
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,\r
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,\r
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff};\r
- \r
-\r
-struct renderer\r
+struct image_processor::implementation\r
{ \r
- renderer(const video_format_desc& format_desc) : fbo_(format_desc.width, format_desc.height), reading_(create_reading())\r
+ implementation(const video_format_desc& format_desc) : format_desc_(format_desc)\r
{\r
- transform_stack_.push(image_transform());\r
- transform_stack_.top().mode = video_mode::progressive;\r
- transform_stack_.top().uv = boost::make_tuple(0.0, 1.0, 1.0, 0.0);\r
-\r
- GL(glEnable(GL_POLYGON_STIPPLE));\r
- GL(glEnable(GL_TEXTURE_2D));\r
- GL(glEnable(GL_BLEND));\r
- GL(glDisable(GL_DEPTH_TEST));\r
- GL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); \r
- GL(glViewport(0, 0, format_desc.width, format_desc.height));\r
- reading_->unmap();\r
-\r
- std::string common_vertex = \r
- "void main() "\r
- "{ "\r
- " gl_TexCoord[0] = gl_MultiTexCoord0; "\r
- " gl_FrontColor = gl_Color; "\r
- " gl_Position = ftransform(); "\r
- "} ";\r
-\r
- std::string common_fragment = \r
- "uniform sampler2D plane[4]; "\r
- "uniform vec4 plane_size[2]; "\r
- \r
- // NOTE: YCbCr, ITU-R, http://www.intersil.com/data/an/an9717.pdf \r
- // TODO: Support for more yuv formats might be needed. \r
- "vec4 ycbcra_to_bgra(float y, float cb, float cr, float a) "\r
- "{ "\r
- " cb -= 0.5; "\r
- " cr -= 0.5; "\r
- " y = 1.164*(y-0.0625); "\r
- " "\r
- " vec4 color; "\r
- " color.r = y + 1.596 * cr; "\r
- " color.g = y - 0.813 * cr - 0.337633 * cb; "\r
- " color.b = y + 2.017 * cb; "\r
- " color.a = a; "\r
- " "\r
- " return color; "\r
- "} " \r
- " ";\r
+ context_.begin_invoke([=]\r
+ {\r
+ transform_stack_.push(image_transform());\r
+ transform_stack_.top().mode = video_mode::progressive;\r
+ transform_stack_.top().uv = boost::make_tuple(0.0, 1.0, 1.0, 0.0);\r
+\r
+ GL(glEnable(GL_POLYGON_STIPPLE));\r
+ GL(glEnable(GL_TEXTURE_2D));\r
+ GL(glEnable(GL_BLEND));\r
+ GL(glDisable(GL_DEPTH_TEST));\r
+ GL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); \r
+\r
+ render_targets_[0] = context_.create_device_buffer(format_desc.width, format_desc.height, 4);\r
+ render_targets_[1] = context_.create_device_buffer(format_desc.width, format_desc.height, 4);\r
\r
- shaders_[pixel_format::abgr] = gl::shader_program(common_vertex, common_fragment +\r
-\r
- "void main() "\r
- "{ "\r
- " vec4 abgr = texture2D(plane[0], gl_TexCoord[0].st);"\r
- " gl_FragColor = abgr.argb * gl_Color; "\r
- "} ");\r
- \r
- shaders_[pixel_format::argb]= gl::shader_program(common_vertex, common_fragment +\r
+ GL(glGenFramebuffers(1, &fbo_)); \r
+ GL(glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo_));\r
+ GL(glReadBuffer(GL_COLOR_ATTACHMENT0_EXT));\r
\r
- "void main() " \r
- "{ "\r
- " vec4 argb = texture2D(plane[0], gl_TexCoord[0].st);"\r
- " gl_FragColor = argb.grab * gl_Color; " \r
- "} ");\r
- \r
- shaders_[pixel_format::bgra]= gl::shader_program(common_vertex, common_fragment +\r
-\r
- "void main() "\r
- "{ "\r
- " vec4 bgra = texture2D(plane[0], gl_TexCoord[0].st);"\r
- " gl_FragColor = bgra.rgba * gl_Color; "\r
- "} ");\r
- \r
- shaders_[pixel_format::rgba] = gl::shader_program(common_vertex, common_fragment +\r
-\r
- "void main() "\r
- "{ "\r
- " vec4 rgba = texture2D(plane[0], gl_TexCoord[0].st); "\r
- " gl_FragColor = rgba.bgra * gl_Color; "\r
- "} ");\r
- \r
- shaders_[pixel_format::ycbcr] = gl::shader_program(common_vertex, common_fragment +\r
-\r
- "void main() "\r
- "{ "\r
- " float y = texture2D(plane[0], gl_TexCoord[0].st).r;"\r
- " float cb = texture2D(plane[1], gl_TexCoord[0].st).r;"\r
- " float cr = texture2D(plane[2], gl_TexCoord[0].st).r;"\r
- " float a = 1.0; " \r
- " gl_FragColor = ycbcra_to_bgra(y, cb, cr, a) * gl_Color; "\r
- "} ");\r
- \r
- shaders_[pixel_format::ycbcra] = gl::shader_program(common_vertex, common_fragment +\r
+ reading_ = context_.create_host_buffer(format_desc_.size, host_buffer::read_only);\r
+ });\r
+ }\r
\r
- "void main() "\r
- "{ "\r
- " float y = texture2D(plane[0], gl_TexCoord[0].st).r;"\r
- " float cb = texture2D(plane[1], gl_TexCoord[0].st).r;"\r
- " float cr = texture2D(plane[2], gl_TexCoord[0].st).r;"\r
- " float a = texture2D(plane[3], gl_TexCoord[0].st).r;"\r
- " gl_FragColor = ycbcra_to_bgra(y, cb, cr, a) * gl_Color; "\r
- "} ");\r
+ ~implementation()\r
+ {\r
+ glDeleteFramebuffersEXT(1, &fbo_);\r
}\r
\r
void begin(const image_transform& transform)\r
{\r
- glPushMatrix();\r
- transform_stack_.push(transform_stack_.top()*transform);\r
+ context_.begin_invoke([=]\r
+ {\r
+ glPushMatrix();\r
+ transform_stack_.push(transform_stack_.top()*transform);\r
\r
- glColor4d(1.0, 1.0, 1.0, transform_stack_.top().alpha);\r
- glTranslated(transform.pos.get<0>()*2.0, transform.pos.get<1>()*2.0, 0.0);\r
- \r
- set_mode(transform_stack_.top().mode);\r
+ glColor4d(1.0, 1.0, 1.0, transform_stack_.top().alpha);\r
+ glTranslated(transform.pos.get<0>()*2.0, transform.pos.get<1>()*2.0, 0.0);\r
+ });\r
}\r
\r
- void render(const pixel_format_desc& desc, std::vector<safe_ptr<write_buffer>>& buffers)\r
+ void render(const pixel_format_desc& desc, std::vector<safe_ptr<host_buffer>>& buffers)\r
{\r
- shaders_[desc.pix_fmt].use();\r
-\r
- for(size_t n = 0; n < buffers.size(); ++n)\r
+ context_.begin_invoke([=]\r
{\r
- auto buffer = buffers[n];\r
-\r
- glActiveTexture(GL_TEXTURE0+n);\r
- buffer->unmap();\r
- \r
- bool fit = buffer->width() == fbo_.width() && buffer->height() == fbo_.height();\r
- GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, fit ? GL_NEAREST : GL_LINEAR));\r
- GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, fit ? GL_NEAREST : GL_LINEAR));\r
- }\r
+ GL(glViewport(0, 0, format_desc_.width, format_desc_.height));\r
+ kernel_.use(desc.pix_fmt, transform_stack_.top().mode);\r
\r
- auto t = transform_stack_.top();\r
- glBegin(GL_QUADS);\r
- glTexCoord2d(t.uv.get<0>(), t.uv.get<3>()); glVertex2d(-1.0, -1.0);\r
- glTexCoord2d(t.uv.get<2>(), t.uv.get<3>()); glVertex2d( 1.0, -1.0);\r
- glTexCoord2d(t.uv.get<2>(), t.uv.get<1>()); glVertex2d( 1.0, 1.0);\r
- glTexCoord2d(t.uv.get<0>(), t.uv.get<1>()); glVertex2d(-1.0, 1.0);\r
- glEnd();\r
- }\r
-\r
- void end()\r
- {\r
- transform_stack_.pop();\r
- set_mode(transform_stack_.top().mode);\r
- glColor4d(1.0, 1.0, 1.0, transform_stack_.top().alpha);\r
- glPopMatrix();\r
- }\r
-\r
- safe_ptr<const read_buffer> begin_pass()\r
- {\r
- reading_->map();\r
- GL(glClear(GL_COLOR_BUFFER_BIT));\r
- return reading_;\r
- }\r
-\r
- void end_pass()\r
- {\r
- reading_ = create_reading();\r
- reading_->unmap(); // Start transfer from frame buffer to texture. End with map in next tick.\r
- }\r
- \r
- void set_mode(video_mode::type mode)\r
- {\r
- if(mode == video_mode::upper)\r
- glPolygonStipple(upper_pattern);\r
- else if(mode == video_mode::lower)\r
- glPolygonStipple(lower_pattern);\r
- else\r
- glPolygonStipple(progressive_pattern);\r
- }\r
-\r
- safe_ptr<read_buffer> create_reading()\r
- {\r
- std::shared_ptr<read_buffer> frame;\r
- if(!pool_.try_pop(frame)) \r
- frame = std::make_shared<read_buffer>(fbo_.width(), fbo_.height());\r
- return safe_ptr<read_buffer>(frame.get(), [=](read_buffer*){pool_.push(frame);});\r
- }\r
-\r
- const ogl_context context_;\r
- \r
- tbb::concurrent_bounded_queue<std::shared_ptr<read_buffer>> pool_;\r
-\r
- std::stack<image_transform> transform_stack_;\r
-\r
- std::unordered_map<pixel_format::type, gl::shader_program> shaders_;\r
- gl::fbo fbo_;\r
+ std::vector<safe_ptr<device_buffer>> device_buffers;\r
+ for(size_t n = 0; n < buffers.size(); ++n)\r
+ {\r
+ auto texture = context_.create_device_buffer(desc.planes[n].width, desc.planes[n].height, desc.planes[n].channels);\r
+ texture->read(*buffers[n]);\r
+ device_buffers.push_back(texture);\r
+ }\r
\r
- safe_ptr<read_buffer> reading_;\r
-};\r
+ for(size_t n = 0; n < buffers.size(); ++n)\r
+ {\r
+ glActiveTexture(GL_TEXTURE0+n);\r
+ device_buffers[n]->bind();\r
+ }\r
\r
-struct image_processor::implementation : boost::noncopyable\r
-{\r
- implementation(const video_format_desc& format_desc) : format_desc_(format_desc)\r
- {\r
- executor_.start();\r
- }\r
- \r
- void begin(const image_transform& transform)\r
- {\r
- executor_.begin_invoke([=]{get()->begin(transform);});\r
- }\r
- \r
- void render(const pixel_format_desc& desc, std::vector<safe_ptr<write_buffer>>& buffers)\r
- {\r
- executor_.begin_invoke([=]() mutable{get()->render(desc, buffers);});\r
+ auto t = transform_stack_.top();\r
+ glBegin(GL_QUADS);\r
+ glTexCoord2d(t.uv.get<0>(), t.uv.get<3>()); glVertex2d(-1.0, -1.0);\r
+ glTexCoord2d(t.uv.get<2>(), t.uv.get<3>()); glVertex2d( 1.0, -1.0);\r
+ glTexCoord2d(t.uv.get<2>(), t.uv.get<1>()); glVertex2d( 1.0, 1.0);\r
+ glTexCoord2d(t.uv.get<0>(), t.uv.get<1>()); glVertex2d(-1.0, 1.0);\r
+ glEnd();\r
+ });\r
}\r
\r
void end()\r
{\r
- executor_.begin_invoke([=]{get()->end();});\r
+ context_.begin_invoke([=]\r
+ {\r
+ transform_stack_.pop();\r
+ glColor4d(1.0, 1.0, 1.0, transform_stack_.top().alpha);\r
+ glPopMatrix();\r
+ });\r
}\r
\r
- boost::unique_future<safe_ptr<const read_buffer>> begin_pass()\r
+ boost::unique_future<safe_ptr<const host_buffer>> begin_pass()\r
{\r
- return executor_.begin_invoke([=]{return get()->begin_pass();});\r
+ return context_.begin_invoke([=]() -> safe_ptr<const host_buffer>\r
+ {\r
+ reading_->map();\r
+ render_targets_[0]->attach(0);\r
+ GL(glClear(GL_COLOR_BUFFER_BIT));\r
+ return safe_ptr<const host_buffer>(reading_);\r
+ });\r
}\r
\r
void end_pass()\r
{\r
- executor_.begin_invoke([=]{get()->end_pass();});\r
- }\r
-\r
- std::unique_ptr<renderer>& get()\r
- {\r
- if(!renderer_)\r
- renderer_.reset(new renderer(format_desc_));\r
- return renderer_;\r
+ context_.begin_invoke([=]\r
+ {\r
+ reading_ = context_.create_host_buffer(format_desc_.size, host_buffer::read_only);\r
+ render_targets_[0]->write(*reading_);\r
+ std::rotate(render_targets_.begin(), render_targets_.begin() + 1, render_targets_.end());\r
+ });\r
}\r
-\r
- std::vector<safe_ptr<write_buffer>> create_buffers(const pixel_format_desc& format)\r
+ \r
+ std::vector<safe_ptr<host_buffer>> create_buffers(const pixel_format_desc& format)\r
{\r
- std::vector<safe_ptr<write_buffer>> buffers;\r
- std::transform(format.planes.begin(), format.planes.end(), std::back_inserter(buffers), [&](const pixel_format_desc::plane& plane) -> safe_ptr<write_buffer>\r
+ std::vector<safe_ptr<host_buffer>> buffers;\r
+ std::transform(format.planes.begin(), format.planes.end(), std::back_inserter(buffers), [&](const pixel_format_desc::plane& plane) -> safe_ptr<host_buffer>\r
{\r
- size_t key = ((plane.channels << 24) & 0x0F000000) | ((plane.width << 12) & 0x00FFF000) | ((plane.height << 0) & 0x00000FFF);\r
- auto pool = &write_frames_[key];\r
- std::shared_ptr<write_buffer> buffer;\r
- if(!pool->try_pop(buffer))\r
- {\r
- executor_.begin_invoke([&]\r
- {\r
- buffer = std::make_shared<write_buffer>(plane.width, plane.height, plane.channels);\r
- buffer->map();\r
- }).get(); \r
- }\r
-\r
- return safe_ptr<write_buffer>(buffer.get(), [=](write_buffer*)\r
- {\r
- executor_.begin_invoke([=]\r
- {\r
- buffer->map();\r
- pool->push(buffer);\r
- });\r
- });\r
+ return context_.create_host_buffer(plane.size, host_buffer::write_only);\r
});\r
return buffers;\r
}\r
\r
- tbb::concurrent_unordered_map<size_t, tbb::concurrent_bounded_queue<std::shared_ptr<write_buffer>>> write_frames_;\r
-\r
const video_format_desc format_desc_;\r
- std::unique_ptr<renderer> renderer_;\r
- executor executor_; \r
+\r
+ ogl_context context_;\r
+\r
+ std::stack<image_transform> transform_stack_;\r
+\r
+ GLuint fbo_;\r
+ std::array<std::shared_ptr<device_buffer>, 2> render_targets_;\r
+\r
+ std::shared_ptr<host_buffer> reading_;\r
+\r
+ image_kernel kernel_;\r
};\r
\r
image_processor::image_processor(const video_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
void image_processor::begin(const image_transform& transform) { impl_->begin(transform);}\r
-void image_processor::process(const pixel_format_desc& desc, std::vector<safe_ptr<write_buffer>>& buffers){ impl_->render(desc, buffers);}\r
+void image_processor::process(const pixel_format_desc& desc, std::vector<safe_ptr<host_buffer>>& buffers){ impl_->render(desc, buffers);}\r
void image_processor::end(){impl_->end();}\r
-boost::unique_future<safe_ptr<const read_buffer>> image_processor::begin_pass(){ return impl_->begin_pass();}\r
+boost::unique_future<safe_ptr<const host_buffer>> image_processor::begin_pass(){ return impl_->begin_pass();}\r
void image_processor::end_pass(){impl_->end_pass();}\r
-std::vector<safe_ptr<write_buffer>> image_processor::create_buffers(const pixel_format_desc& format){return impl_->create_buffers(format);}\r
+std::vector<safe_ptr<host_buffer>> image_processor::create_buffers(const pixel_format_desc& format){return impl_->create_buffers(format);}\r
\r
}}
\ No newline at end of file
#pragma once\r
\r
-#include "buffer/write_buffer.h"\r
-#include "buffer/read_buffer.h"\r
+#include "host_buffer.h"\r
\r
#include "../format/video_format.h"\r
#include "../format/pixel_format.h"\r
image_processor(const video_format_desc& format_desc);\r
\r
void begin(const image_transform& transform);\r
- void process(const pixel_format_desc& desc, std::vector<safe_ptr<write_buffer>>& buffers);\r
+ void process(const pixel_format_desc& desc, std::vector<safe_ptr<host_buffer>>& buffers);\r
void end();\r
\r
- boost::unique_future<safe_ptr<const read_buffer>> begin_pass();\r
+ boost::unique_future<safe_ptr<const host_buffer>> begin_pass();\r
void end_pass();\r
\r
- std::vector<safe_ptr<write_buffer>> create_buffers(const pixel_format_desc& format);\r
+ std::vector<safe_ptr<host_buffer>> create_buffers(const pixel_format_desc& format);\r
\r
private:\r
struct implementation;\r
std::shared_ptr<implementation> impl_;\r
};\r
-typedef std::shared_ptr<image_processor> image_shader_ptr;\r
\r
}}
\ No newline at end of file
\r
#include "read_frame.h"\r
\r
-#include "buffer/read_buffer.h"\r
+#include "host_buffer.h"\r
\r
#include <common/gl/utility.h>\r
#include <common/utility/singleton_pool.h>\r
\r
struct read_frame::implementation : boost::noncopyable\r
{\r
- implementation(safe_ptr<const read_buffer>&& image_data, std::vector<short>&& audio_data) : image_data_(std::move(image_data)), audio_data_(std::move(audio_data)){} \r
+ implementation(safe_ptr<const host_buffer>&& image_data, std::vector<short>&& audio_data) : image_data_(std::move(image_data)), audio_data_(std::move(audio_data)){} \r
\r
- safe_ptr<const read_buffer> image_data_;\r
+ safe_ptr<const host_buffer> image_data_;\r
std::vector<short> audio_data_;\r
};\r
\r
read_frame::read_frame(){}\r
-read_frame::read_frame(safe_ptr<const read_buffer>&& image_data, std::vector<short>&& audio_data) : impl_(singleton_pool<implementation>::make_shared(image_data, audio_data)){}\r
+read_frame::read_frame(safe_ptr<const host_buffer>&& image_data, std::vector<short>&& audio_data) : impl_(singleton_pool<implementation>::make_shared(image_data, audio_data)){}\r
\r
const boost::iterator_range<const unsigned char*> read_frame::image_data() const\r
{\r
#pragma once\r
\r
-#include "buffer/read_buffer.h" \r
+#include "host_buffer.h" \r
\r
#include <boost/noncopyable.hpp>\r
#include <boost/range/iterator_range.hpp>\r
{\r
public:\r
read_frame();\r
- read_frame(safe_ptr<const read_buffer>&& image_data, std::vector<short>&& audio_data);\r
+ read_frame(safe_ptr<const host_buffer>&& image_data, std::vector<short>&& audio_data);\r
\r
const boost::iterator_range<const unsigned char*> image_data() const;\r
const boost::iterator_range<const short*> audio_data() const;\r
\r
#include "write_frame.h"\r
\r
-#include "buffer/write_buffer.h"\r
+#include "host_buffer.h"\r
\r
#include "draw_frame.h"\r
#include "image_processor.h"\r
\r
struct write_frame::implementation : boost::noncopyable\r
{\r
- implementation(const pixel_format_desc& desc, std::vector<safe_ptr<write_buffer>> buffers) : desc_(desc), buffers_(buffers){}\r
+ implementation(const pixel_format_desc& desc, std::vector<safe_ptr<host_buffer>> buffers) : desc_(desc), buffers_(buffers){}\r
\r
void process_image(image_processor& processor)\r
{\r
return boost::iterator_range<const unsigned char*>(ptr, ptr+buffers_[index]->size());\r
}\r
\r
- std::vector<safe_ptr<write_buffer>> buffers_;\r
+ std::vector<safe_ptr<host_buffer>> buffers_;\r
std::vector<short> audio_data_;\r
const pixel_format_desc desc_;\r
};\r
\r
-write_frame::write_frame(const pixel_format_desc& desc, std::vector<safe_ptr<write_buffer>> buffers) : impl_(singleton_pool<implementation>::make_shared(desc, buffers)){}\r
+write_frame::write_frame(const pixel_format_desc& desc, std::vector<safe_ptr<host_buffer>> buffers) : impl_(singleton_pool<implementation>::make_shared(desc, buffers)){}\r
write_frame::write_frame(write_frame&& other) : impl_(std::move(other.impl_)){}\r
void write_frame::swap(write_frame& other){impl_.swap(other.impl_);}\r
write_frame& write_frame::operator=(write_frame&& other)\r
\r
#include "fwd.h"\r
\r
-#include "buffer\write_buffer.h"\r
+#include "host_buffer.h"\r
\r
#include "draw_frame.h"\r
\r
class write_frame : public draw_frame, boost::noncopyable\r
{\r
public: \r
- explicit write_frame(const pixel_format_desc& desc, std::vector<safe_ptr<write_buffer>> buffers);\r
+ explicit write_frame(const pixel_format_desc& desc, std::vector<safe_ptr<host_buffer>> buffers);\r
write_frame(write_frame&& other);\r
write_frame& operator=(write_frame&& other);\r
\r