]> 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>
Wed, 17 Aug 2011 12:25:14 +0000 (12:25 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 17 Aug 2011 12:25:14 +0000 (12:25 +0000)
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/ffmpeg/producer/video/video_decoder.cpp
modules/ffmpeg/producer/video/video_decoder.h

index 84863760efd79d0b9c705d1b79056312fb089809..4a9ad443f9b903f66777ca01b6bfcdd513b6d0db 100644 (file)
@@ -74,6 +74,7 @@ struct ffmpeg_producer : public core::frame_producer
        input                                                                                   input_; \r
        video_decoder                                                                   video_decoder_;\r
        audio_decoder                                                                   audio_decoder_; \r
+       double                                                                                  fps_;\r
        frame_muxer                                                                             muxer_;\r
 \r
        int                                                                                             late_frames_;\r
@@ -81,21 +82,29 @@ struct ffmpeg_producer : public core::frame_producer
        const bool                                                                              loop_;\r
 \r
        safe_ptr<core::basic_frame>                                             last_frame_;\r
+\r
+       const size_t                                                                    width_;\r
+       const size_t                                                                    height_;\r
+       bool                                                                                    progressive_;\r
        \r
 public:\r
        explicit ffmpeg_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::wstring& filename, const std::wstring& filter, bool loop, int start, int length) \r
                : filename_(filename)\r
-               , graph_(diagnostics::create_graph(narrow(print())))\r
+               , graph_(diagnostics::create_graph([this]{return print();}))\r
                , frame_factory_(frame_factory)         \r
                , format_desc_(frame_factory->get_video_format_desc())\r
                , input_(graph_, filename_, loop, start, length)\r
                , video_decoder_(input_.context(), frame_factory, filter)\r
                , audio_decoder_(input_.context(), frame_factory->get_video_format_desc())\r
-               , muxer_(validate_fps(video_decoder_.fps(), video_decoder_.nb_frames(), audio_decoder_.duration()), frame_factory)\r
+               , fps_(validate_fps(video_decoder_.fps(), video_decoder_.nb_frames(), audio_decoder_.duration()))\r
+               , muxer_(fps_, frame_factory)\r
                , late_frames_(0)\r
                , start_(start)\r
                , loop_(loop)\r
                , last_frame_(core::basic_frame::empty())\r
+               , width_(video_decoder_.width())\r
+               , height_(video_decoder_.height())\r
+               , progressive_(true)\r
        {\r
                graph_->add_guide("frame-time", 0.5);\r
                graph_->set_color("frame-time", diagnostics::color(0.1f, 1.0f, 0.1f));\r
@@ -156,8 +165,11 @@ public:
                                return;\r
 \r
                        auto video_frames = video_decoder_.poll();\r
-                       BOOST_FOREACH(auto& video, video_frames)                \r
+                       BOOST_FOREACH(auto& video, video_frames)        \r
+                       {\r
+                               progressive_ &= video->interlaced_frame != 0;\r
                                muxer_.push(video, hints);      \r
+                       }\r
                },\r
                [&]\r
                {\r
@@ -197,7 +209,9 @@ public:
                                \r
        virtual std::wstring print() const\r
        {\r
-               return L"ffmpeg[" + boost::filesystem::wpath(filename_).filename() + L"]";\r
+               return L"ffmpeg[" + boost::filesystem::wpath(filename_).filename() + L"|" \r
+                                                 + boost::lexical_cast<std::wstring>(fps_) + (progressive_ ? L"p" : L"i") +L"|"\r
+                                                 + boost::lexical_cast<std::wstring>(width_) + L"x" + boost::lexical_cast<std::wstring>(height_) + L"]";\r
        }\r
 };\r
 \r
index e2549ecf4ae7027975b62b08fa54595c2947b497..d78361f678db523817fdbb35578c523be52c463f 100644 (file)
@@ -61,12 +61,18 @@ struct video_decoder::implementation : boost::noncopyable
 \r
        double                                                                  fps_;\r
        int64_t                                                                 nb_frames_;\r
+\r
+       size_t                                                                  width_;\r
+       size_t                                                                  height_;\r
+\r
 public:\r
        explicit implementation(const safe_ptr<AVFormatContext>& context, const safe_ptr<core::frame_factory>& frame_factory, const std::wstring& filter) \r
                : frame_factory_(frame_factory)\r
                , filter_(filter)\r
                , fps_(frame_factory_->get_video_format_desc().fps)\r
                , nb_frames_(0)\r
+               , width_(0)\r
+               , height_(0)\r
        {\r
                try\r
                {\r
@@ -90,6 +96,9 @@ public:
                        fps_ = static_cast<double>(codec_context_->time_base.den) / static_cast<double>(codec_context_->time_base.num);\r
                        if(double_rate(filter))\r
                                fps_ *= 2;\r
+\r
+                       width_  = codec_context_->width;\r
+                       height_ = codec_context_->height;\r
                }\r
                catch(...)\r
                {\r
@@ -205,4 +214,6 @@ std::vector<std::shared_ptr<AVFrame>> video_decoder::poll(){return impl_->poll()
 bool video_decoder::ready() const{return impl_->ready();}\r
 double video_decoder::fps() const{return impl_->fps();}\r
 int64_t video_decoder::nb_frames() const{return impl_->nb_frames_;}\r
+size_t video_decoder::width() const{return impl_->width_;}\r
+size_t video_decoder::height() const{return impl_->height_;}\r
 }
\ No newline at end of file
index dd91216aa4af28ec8bc77edf36bea528d428fc5b..743bf749ae449323b84bca289a7b24a6dd44f663 100644 (file)
@@ -47,6 +47,9 @@ public:
        bool ready() const;\r
        std::vector<std::shared_ptr<AVFrame>> poll();\r
        \r
+       size_t width() const;\r
+       size_t height() const;\r
+\r
        int64_t nb_frames() const;\r
 \r
        double fps() const;\r