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
\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
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
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