]> 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, 26 Oct 2011 14:09:48 +0000 (14:09 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 26 Oct 2011 14:09:48 +0000 (14:09 +0000)
modules/ffmpeg/producer/input.cpp

index 98b7bf6f9c4902b21dd697b1870ef33a9f61c724..a5f2e8b0835018c0a82e9262bff8ee7588461cea 100644 (file)
@@ -83,9 +83,6 @@ struct input::implementation : public Concurrency::agent, boost::noncopyable
 \r
        overwrite_buffer<bool>                                  is_running_;\r
        governor                                                                governor_;\r
-\r
-       const int                                                               video_index_;\r
-       const int                                                               audio_index_;\r
                \r
 public:\r
        explicit implementation(input::target_t& target,\r
@@ -103,9 +100,7 @@ public:
                , start_(start)\r
                , length_(length)\r
                , frame_number_(0)\r
-               , governor_(4)\r
-               , video_index_(av_find_best_stream(format_context_.get(), AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0))\r
-               , audio_index_(av_find_best_stream(format_context_.get(), AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0))\r
+               , governor_(8)\r
        {               \r
                loop_                   = loop;\r
                packets_count_  = 0;\r
@@ -138,27 +133,16 @@ public:
        {\r
                try\r
                {\r
-                       double current_dts = 0;\r
-                       std::map<int, double> dts;\r
+                       int last_stream_index = -1;\r
 \r
                        send(is_running_, true);\r
                        for(auto packet = read_next_packet(); packet && is_running_.value(); packet = read_next_packet())\r
                        {                               \r
                                ticket_t ticket;\r
-                               \r
-                               if(packet->stream_index > 0 && (packet->stream_index == video_index_ || packet->stream_index == audio_index_))\r
-                                       dts[packet->stream_index] = packet->dts*av_q2d(format_context_->streams[packet->stream_index]->time_base);\r
-\r
-                               auto it = std::min_element(dts.begin(), dts.end(), [](const std::pair<int, double>& lhs, const std::pair<int, double>& rhs)\r
-                               {\r
-                                       return lhs.second < rhs.second;\r
-                               });\r
 \r
-                               if(it != dts.end() && it->second > current_dts)\r
-                               {\r
+                               if((format_context_->nb_streams < 2 || last_stream_index != packet->stream_index) && packet->stream_index == default_stream_index_)\r
                                        ticket = governor_.acquire();\r
-                                       current_dts = it->second;\r
-                               }\r
+                               last_stream_index = packet->stream_index;\r
 \r
                                Concurrency::asend(target_, input::target_element_t(packet, ticket));\r
                                Context::Yield();\r