]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2: Moved ffmpeg initialization to main.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 23 Jan 2011 12:15:46 +0000 (12:15 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 23 Jan 2011 12:15:46 +0000 (12:15 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@421 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/consumer/ffmpeg/ffmpeg_consumer.cpp
core/producer/ffmpeg/input.cpp
core/producer/ffmpeg/video/video_decoder.cpp
mixer/gpu/ogl_device.cpp
shell/main.cpp

index 3edd3eaf326b71d54adbf714109fdfd271eb8c80..f70d70b3e4243bbc8d5902f73017b7443968b5a9 100644 (file)
@@ -118,12 +118,6 @@ public:
                executor_.start();\r
                active_ = executor_.begin_invoke([]{});\r
 \r
-               static boost::once_flag av_register_all_flag = BOOST_ONCE_INIT;\r
-               boost::call_once(av_register_all, av_register_all_flag);        \r
-               \r
-               static boost::once_flag avcodec_init_flag = BOOST_ONCE_INIT;\r
-               boost::call_once(avcodec_init, avcodec_init_flag);      \r
-\r
                fmt_ = av_guess_format(nullptr, filename_.c_str(), nullptr);\r
                if (!fmt_) \r
                {\r
index fda49c9982a15b8fdf742399d0910f74df54da94..59d4fd63a5e7a18f9346af5bfb92134310ad26da 100644 (file)
@@ -55,13 +55,7 @@ public:
                , video_s_index_(-1)\r
                , audio_s_index_(-1)\r
                , filename_(filename)\r
-       {               \r
-               static boost::once_flag av_register_all_flag = BOOST_ONCE_INIT;\r
-               boost::call_once(av_register_all, av_register_all_flag);        \r
-               \r
-               static boost::once_flag avcodec_init_flag = BOOST_ONCE_INIT;\r
-               boost::call_once(avcodec_init, avcodec_init_flag);      \r
-                               \r
+       {                                               \r
                int errn;\r
                AVFormatContext* weak_format_context_;\r
                if((errn = -av_open_input_file(&weak_format_context_, narrow(filename).c_str(), nullptr, 0, nullptr)) > 0)\r
index 2fa5e0ae7d6f188c0bb3fc7609a0ad7d08f6a493..ea40eb1663c725649f420540cd5c5737f890a85e 100644 (file)
@@ -121,9 +121,9 @@ public:
                        double param;\r
                        sws_context_.reset(sws_getContext(width_, height_, pix_fmt_, width_, height_, PIX_FMT_BGRA, SWS_BILINEAR, nullptr, nullptr, &param), sws_freeContext);\r
                        if(!sws_context_)\r
-                               BOOST_THROW_EXCEPTION(  operation_failed() <<\r
-                                                                               msg_info("Could not create software scaling context.") << \r
-                                                                               boost::errinfo_api_function("sws_getContext"));\r
+                               BOOST_THROW_EXCEPTION(operation_failed() <<\r
+                                                                         msg_info("Could not create software scaling context.") << \r
+                                                                         boost::errinfo_api_function("sws_getContext"));\r
                }\r
        }\r
        \r
@@ -152,9 +152,6 @@ public:
                                        std::copy_n(decoded + y*decoded_linesize, plane.linesize, result + y*plane.linesize);\r
                                });\r
                        });\r
-\r
-                       if(codec_context_->codec_id == CODEC_ID_DVVIDEO && frame_factory_->get_video_format_desc().mode == video_mode::upper)\r
-                               write->get_image_transform().set_image_translation(0.0f, 1.0/static_cast<double>(height_));\r
                }\r
                else\r
                {\r
@@ -164,6 +161,10 @@ public:
                 \r
                        sws_scale(sws_context_.get(), decoded_frame->data, decoded_frame->linesize, 0, height_, av_frame->data, av_frame->linesize);    \r
                }       \r
+\r
+               if(codec_context_->codec_id == CODEC_ID_DVVIDEO && frame_factory_->get_video_format_desc().mode == video_mode::upper)\r
+                       write->get_image_transform().set_image_translation(0.0f, 1.0/static_cast<double>(height_));\r
+\r
                return write;\r
        }\r
 };\r
index 66f3b02e6c306cfc52a7621ff0011ad50679ac22..109ea1a40c1b0ebdc3816678adea1e28e4dab8dd 100644 (file)
@@ -2,6 +2,8 @@
 \r
 #include "ogl_device.h"\r
 \r
+#include <common/utility/assert.h>\r
+\r
 #include <Glee.h>\r
 #include <SFML/Window.hpp>\r
 \r
@@ -32,6 +34,8 @@ ogl_device::~ogl_device()
                                \r
 safe_ptr<device_buffer> ogl_device::create_device_buffer(size_t width, size_t height, size_t stride)\r
 {\r
+       CASPAR_ASSERT(stride > 0 && stride < 5);\r
+       CASPAR_ASSERT(width > 0 && height > 0);\r
        auto pool = &device_pools_[stride-1][((width << 16) & 0xFFFF0000) | (height & 0x0000FFFF)];\r
        std::shared_ptr<device_buffer> buffer;\r
        if(!pool->try_pop(buffer))              \r
@@ -47,6 +51,8 @@ safe_ptr<device_buffer> ogl_device::create_device_buffer(size_t width, size_t he
        \r
 safe_ptr<host_buffer> ogl_device::create_host_buffer(size_t size, host_buffer::usage_t usage)\r
 {\r
+       CASPAR_ASSERT(usage == host_buffer::write_only || usage == host_buffer::read_only);\r
+       CASPAR_ASSERT(size > 0);\r
        auto pool = &host_pools_[usage][size];\r
        std::shared_ptr<host_buffer> buffer;\r
        if(!pool->try_pop(buffer))\r
index 2c36ce3975536e5f931527cba1ae305284006502..613449ca97878c37aecae9f15134a8e8b7e02c6d 100644 (file)
 #include <common/utility/assert.h>\r
 #include <protocol/amcp/AMCPProtocolStrategy.h>\r
 \r
+#if defined(_MSC_VER)\r
+#pragma warning (disable : 4244)\r
+#endif\r
+\r
+extern "C" \r
+{\r
+       #define __STDC_CONSTANT_MACROS\r
+       #define __STDC_LIMIT_MACROS\r
+       #include <libavformat/avformat.h>\r
+}\r
+\r
 #include <atlbase.h>\r
 \r
 using namespace caspar;\r
@@ -67,8 +78,14 @@ public:
  \r
 int main(int argc, wchar_t* argv[])\r
 {\r
+       // Init FFMPEG\r
+       av_register_all();\r
+       avcodec_init();\r
+\r
+       // Increase time precision\r
        timeBeginPeriod(1);\r
 \r
+       // Start caspar\r
        std::wstringstream str;\r
        str << "CasparCG " << env::version() << " " << env::version_tag();\r
        SetConsoleTitle(str.str().c_str());\r