]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 22 Oct 2011 23:23:12 +0000 (23:23 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 22 Oct 2011 23:23:12 +0000 (23:23 +0000)
modules/ffmpeg/producer/util.h
modules/ogl/consumer/ogl_consumer.cpp

index f33d88f3aaa2adc5cf64da3e7925dcc7e6f4225b..7b6665f48e3e9612ea1824bd948e94cc6896c1ac 100644 (file)
@@ -68,4 +68,24 @@ safe_ptr<AVPacket> create_packet();
 safe_ptr<AVCodecContext> open_codec(AVFormatContext& context,  enum AVMediaType type, int& index);\r
 safe_ptr<AVFormatContext> open_input(const std::wstring& filename);\r
 \r
+\r
+//safe_ptr<AVFrame> copy_av_frame(safe_ptr<AVFrame> av_frame)\r
+//{\r
+//     const uint8_t *src_data[4] = {0};\r
+//     memcpy(const_cast<uint8_t**>(&src_data[0]), av_frame->data, 4);\r
+//     const int src_linesizes[4] = {0};\r
+//     memcpy(const_cast<int*>(&src_linesizes[0]), av_frame->linesize, 4);\r
+//\r
+//     auto av_frame2 = get_av_frame();\r
+//     av_image_alloc(av_frame2->data, av_frame2->linesize, av_frame2->width, av_frame2->height, PIX_FMT_BGRA, 16);\r
+//     av_frame = safe_ptr<AVFrame>(av_frame2.get(), [=](AVFrame*)\r
+//     {\r
+//             av_freep(&av_frame2->data[0]);\r
+//     });\r
+//\r
+//     av_image_copy(av_frame2->data, av_frame2->linesize, src_data, src_linesizes, PIX_FMT_BGRA, av_frame2->width, av_frame2->height);\r
+//\r
+//     return av_frame;\r
+//}\r
+\r
 }}
\ No newline at end of file
index a4e098e9c1aa475396e019fc8479f387c02feaae..928c9eb5267d1567b41a328c6810990cc4c6dbba 100644 (file)
@@ -287,7 +287,7 @@ public:
 \r
                return av_frame;\r
        }\r
-\r
+       \r
        void render(const safe_ptr<core::read_frame>& frame)\r
        {                       \r
                if(frame->image_data().empty())\r
@@ -303,24 +303,7 @@ public:
                        return;\r
 \r
                av_frame = frames[0];\r
-\r
-               if(av_frame->linesize[0] != static_cast<int>(format_desc_.width*4))\r
-               {\r
-                       const uint8_t *src_data[4] = {0};\r
-                       memcpy(const_cast<uint8_t**>(&src_data[0]), av_frame->data, 4);\r
-                       const int src_linesizes[4] = {0};\r
-                       memcpy(const_cast<int*>(&src_linesizes[0]), av_frame->linesize, 4);\r
-\r
-                       auto av_frame2 = get_av_frame();\r
-                       av_image_alloc(av_frame2->data, av_frame2->linesize, av_frame2->width, av_frame2->height, PIX_FMT_BGRA, 16);\r
-                       av_frame = safe_ptr<AVFrame>(av_frame2.get(), [=](AVFrame*)\r
-                       {\r
-                               av_freep(&av_frame2->data[0]);\r
-                       });\r
-\r
-                       av_image_copy(av_frame2->data, av_frame2->linesize, src_data, src_linesizes, PIX_FMT_BGRA, av_frame2->width, av_frame2->height);\r
-               }\r
-\r
+               \r
                glBindTexture(GL_TEXTURE_2D, texture_);\r
 \r
                glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbos_[0]);\r
@@ -333,10 +316,20 @@ public:
                if(ptr)\r
                {\r
                        if(config_.key_only)\r
-                               fast_memshfl(reinterpret_cast<char*>(ptr), av_frame->data[0], frame->image_data().size(), 0x0F0F0F0F, 0x0B0B0B0B, 0x07070707, 0x03030303);\r
+                       {\r
+                               Concurrency::parallel_for(0, av_frame->height, [&](int n)\r
+                               {\r
+                                       fast_memshfl(reinterpret_cast<char*>(ptr)+n*format_desc_.width*4, av_frame->data[0]+n*av_frame->linesize[0], format_desc_.width*4, 0x0F0F0F0F, 0x0B0B0B0B, 0x07070707, 0x03030303);\r
+                               });\r
+                       }\r
                        else\r
-                               fast_memcpy(reinterpret_cast<char*>(ptr), av_frame->data[0], frame->image_data().size());\r
-\r
+                       {\r
+                               Concurrency::parallel_for(0, av_frame->height, [&](int n)\r
+                               {\r
+                                       fast_memcpy(reinterpret_cast<char*>(ptr)+n*format_desc_.width*4, av_frame->data[0]+n*av_frame->linesize[0], format_desc_.width*4);\r
+                               });\r
+                       }\r
+                       \r
                        glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); // release the mapped buffer\r
                }\r
 \r