]> git.sesse.net Git - casparcg/commitdiff
2.0. ffmepg_producer: Fixed filter loop crash.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 19 Jun 2011 13:09:49 +0000 (13:09 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 19 Jun 2011 13:09:49 +0000 (13:09 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@915 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/ffmpeg/producer/video/video_decoder.cpp
modules/ffmpeg/util/filter.cpp
shell/casparcg.config

index 2ad423be07c4177c6b5a30475bd837f5aad9d1d1..8a963d8c2955694b4cadf6647cfe159c9a1fee32 100644 (file)
@@ -132,6 +132,7 @@ public:
                                      video_frames_.front().first == audio_chunks_.front().first);\r
        }\r
 \r
+       // FIXME: Don't re-interlace when going from 50i to 50p, maybe do this inside decoder?\r
        safe_ptr<core::basic_frame> get_video_frame(std::vector<int16_t>&& audio_chunk)\r
        {\r
                auto frame = std::move(video_frames_.front().second);   \r
index 0879869227f5b213b8d7a136a47d1e6bd431f1ae..3f2c41d798f6d191e8ee0d8bd2a55818b67d1a62 100644 (file)
@@ -67,6 +67,7 @@ struct video_decoder::implementation : boost::noncopyable
        size_t                                                                          filter_delay_;\r
 \r
        safe_ptr<AVFrame>                                                       last_frame_;\r
+       std::string filter_str_;\r
 \r
 public:\r
        explicit implementation(input& input, const safe_ptr<core::frame_factory>& frame_factory, const std::string& filter_str) \r
@@ -77,6 +78,7 @@ public:
                , filter_(filter_str.empty() ? nullptr : new filter(filter_str))\r
                , filter_delay_(0)\r
                , last_frame_(avcodec_alloc_frame(), av_free)\r
+               , filter_str_(filter_str)\r
        {\r
        }\r
 \r
@@ -100,6 +102,9 @@ public:
                        for(size_t n = 0; n < filter_delay_; ++n)\r
                                boost::range::push_back(result, get_frames(last_frame_));\r
                        \r
+                       // FIXME: Unnecessary reinitialization\r
+                       filter_.reset(filter_str_.empty() ? nullptr : new filter(filter_str_));\r
+\r
                        frame_number_ = 0;\r
                        filter_delay_ = 0;\r
                        avcodec_flush_buffers(&codec_context_);\r
index 2b5cfcf6db363a9f7d828553e11efe7b11922777..040fe6e5a61c210abf9330ad334cf75ab8e4e132 100644 (file)
@@ -52,7 +52,7 @@ struct filter::implementation
                        std::stringstream buffer_ss;\r
                        buffer_ss << frame->width << ":" << frame->height << ":" << frame->format << ":" << 0 << ":" << 0 << ":" << 0 << ":" << 0; // don't care about pts and aspect_ratio\r
                        errn = avfilter_graph_create_filter(&video_in_filter_, avfilter_get_by_name("buffer"), "src", buffer_ss.str().c_str(), NULL, graph_.get());\r
-                       if(errn < 0)\r
+                       if(errn < 0 || !video_in_filter_)\r
                        {\r
                                BOOST_THROW_EXCEPTION(caspar_exception() <<     msg_info(av_error_str(errn)) <<\r
                                        boost::errinfo_api_function("avfilter_graph_create_filter") <<  boost::errinfo_errno(AVUNERROR(errn)));\r
@@ -60,7 +60,7 @@ struct filter::implementation
 \r
                        // Output\r
                        errn = avfilter_graph_create_filter(&video_out_filter_, avfilter_get_by_name("nullsink"), "out", NULL, NULL, graph_.get());\r
-                       if(errn < 0)\r
+                       if(errn < 0 || !video_out_filter_)\r
                        {\r
                                BOOST_THROW_EXCEPTION(caspar_exception() <<     msg_info(av_error_str(errn)) <<\r
                                        boost::errinfo_api_function("avfilter_graph_create_filter") << boost::errinfo_errno(AVUNERROR(errn)));\r
@@ -95,6 +95,8 @@ struct filter::implementation
                                BOOST_THROW_EXCEPTION(caspar_exception() <<     msg_info(av_error_str(errn)) \r
                                        <<      boost::errinfo_api_function("avfilter_graph_config") << boost::errinfo_errno(AVUNERROR(errn)));\r
                        }\r
+\r
+                       CASPAR_LOG(info) << "Successfully initialized filter.";\r
                }\r
        \r
                errn = av_vsrc_buffer_add_frame(video_in_filter_, frame.get(), 0);\r
@@ -122,6 +124,8 @@ struct filter::implementation
        {               \r
                auto link = video_out_filter_->inputs[0];\r
 \r
+               CASPAR_ASSERT(link);\r
+\r
                int errn = avfilter_request_frame(link);                        \r
                if(errn < 0)\r
                {\r
index 4f6e99a5d5c16a0c5c3df55a96cb19e67ee6807d..c160edc921afb879ce9c3fd9e59269b2f99cd680 100644 (file)
@@ -12,7 +12,7 @@
   </diagnostics>\r
   <channels>\r
     <channel>\r
-      <video-mode>PAL</video-mode>\r
+      <video-mode>1080i5000</video-mode>\r
       <consumers>\r
         <screen>                      \r
         </screen>\r