]> git.sesse.net Git - casparcg/commitdiff
2.0. frame_muxer: Fixed looping for files with less audio-chunks than frames.
authorRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 11 Aug 2011 19:49:07 +0000 (19:49 +0000)
committerRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 11 Aug 2011 19:49:07 +0000 (19:49 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1146 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

modules/ffmpeg/producer/frame_muxer.cpp

index 7f6a0324f20e3de3bac024b0f9ffcae8354353a8..29c3de9bc3e841d2aee98847dc2cbeb77f394f1d 100644 (file)
@@ -284,8 +284,7 @@ struct frame_muxer::implementation : boost::noncopyable
        \r
        void commit()\r
        {\r
-               if(video_streams_.size() > 1 && audio_streams_.size() > 1 &&\r
-                       (video_streams_.front().empty() || audio_streams_.front().empty()))\r
+               if(video_streams_.size() > 1 && audio_streams_.size() > 1 && !ready())\r
                {\r
                        if(!video_streams_.front().empty() || !audio_streams_.front().empty())\r
                                CASPAR_LOG(debug) << "Truncating: " << video_streams_.front().size() << L" video-frames, " << audio_streams_.front().size() << L" audio-samples.";\r
@@ -294,7 +293,7 @@ struct frame_muxer::implementation : boost::noncopyable
                        audio_streams_.pop_front();\r
                }\r
 \r
-               if(video_streams_.front().empty() || audio_streams_.front().size() < format_desc_.audio_samples_per_frame)\r
+               if(!ready())\r
                        return;\r
                \r
                switch(display_mode_)\r
@@ -310,11 +309,23 @@ struct frame_muxer::implementation : boost::noncopyable
                }\r
        }\r
 \r
-       void simple(std::deque<safe_ptr<basic_frame>>& dest)\r
+       bool ready()\r
        {\r
-               if(video_streams_.front().empty() || audio_streams_.front().size() < format_desc_.audio_samples_per_frame)\r
-                       return;\r
-               \r
+               switch(display_mode_)\r
+               {\r
+               case display_mode::deinterlace_bob:\r
+               case display_mode::deinterlace:\r
+               case display_mode::simple:                                              return !video_streams_.front().empty() && audio_streams_.front().size() >= format_desc_.audio_samples_per_frame;\r
+               case display_mode::duplicate:                                   return !video_streams_.front().empty() && audio_streams_.front().size()/2 >= format_desc_.audio_samples_per_frame;\r
+               case display_mode::half:        \r
+               case display_mode::deinterlace_bob_reinterlace:                                 \r
+               case display_mode::interlace:                                   return video_streams_.front().size() >= 2 && audio_streams_.front().size() >= format_desc_.audio_samples_per_frame;\r
+               default:                                                                                return false;\r
+               }\r
+       }\r
+\r
+       void simple(std::deque<safe_ptr<basic_frame>>& dest)\r
+       {               \r
                auto frame1 = pop_video();\r
                frame1->audio_data() = pop_audio();\r
 \r
@@ -323,9 +334,6 @@ struct frame_muxer::implementation : boost::noncopyable
 \r
        void duplicate(std::deque<safe_ptr<basic_frame>>& dest)\r
        {               \r
-               if(video_streams_.front().empty() || audio_streams_.front().size()/2 < format_desc_.audio_samples_per_frame)\r
-                       return;\r
-\r
                auto frame = pop_video();\r
 \r
                auto frame1 = make_safe<core::write_frame>(*frame); // make a copy\r
@@ -339,10 +347,7 @@ struct frame_muxer::implementation : boost::noncopyable
        }\r
 \r
        void half(std::deque<safe_ptr<basic_frame>>& dest)\r
-       {       \r
-               if(video_streams_.front().size() < 2 || audio_streams_.front().size() < format_desc_.audio_samples_per_frame)\r
-                       return;\r
-                                               \r
+       {                                                       \r
                auto frame1 = pop_video();\r
                frame1->audio_data() = pop_audio();\r
                                \r
@@ -352,10 +357,7 @@ struct frame_muxer::implementation : boost::noncopyable
        }\r
        \r
        void interlace(std::deque<safe_ptr<basic_frame>>& dest)\r
-       {               \r
-               if(video_streams_.front().size() < 2 || audio_streams_.front().size() < format_desc_.audio_samples_per_frame)\r
-                       return;\r
-               \r
+       {                               \r
                auto frame1 = pop_video();\r
                frame1->audio_data() = pop_audio();\r
                                \r