]> git.sesse.net Git - casparcg/blobdiff - modules/ffmpeg/producer/ffmpeg_producer.cpp
[ffmpeg_producer] Remove extraneous \
[casparcg] / modules / ffmpeg / producer / ffmpeg_producer.cpp
index a2d4afef0d204ca2c39a54e35fc9c99f2e07087e..ac4ae09e0233eef8e42e455f959c3efb07c3bee9 100644 (file)
@@ -425,7 +425,7 @@ public:
                static const boost::wregex loop_exp(LR"(LOOP\s*(?<VALUE>\d?)?)", boost::regex::icase);
                static const boost::wregex seek_exp(LR"(SEEK\s+(?<VALUE>(\+|-)?\d+)(\s+(?<WHENCE>REL|END))?)", boost::regex::icase);
                static const boost::wregex length_exp(LR"(LENGTH\s+(?<VALUE>\d+)?)", boost::regex::icase);
-               static const boost::wregex start_exp(LR"(START\\s+(?<VALUE>\\d+)?)", boost::regex::icase);
+               static const boost::wregex start_exp(LR"(START\s+(?<VALUE>\d+)?)", boost::regex::icase);
 
                auto param = boost::algorithm::join(params, L" ");
 
@@ -441,19 +441,21 @@ public:
                }
                else if(boost::regex_match(param, what, seek_exp))
                {
-                       auto value = boost::lexical_cast<uint32_t>(what["VALUE"].str());
+                       auto value = boost::lexical_cast<int64_t>(what["VALUE"].str());
                        auto whence = what["WHENCE"].str();
+                       auto total = file_nb_frames();
 
                        if(boost::iequals(whence, L"REL"))
-                       {
                                value = file_frame_number() + value;
-                       }
                        else if(boost::iequals(whence, L"END"))
-                       {
-                               value = file_nb_frames() - value;
-                       }
+                               value = total - value;
+
+                       if(value < 0)
+                               value = 0;
+                       else if(value >= total)
+                               value = total - 1;
 
-                       input_.seek(value);
+                       input_.seek(static_cast<uint32_t>(value));
                }
                else if(boost::regex_match(param, what, length_exp))
                {
@@ -521,20 +523,20 @@ public:
                                !video_decoder_->is_progressive()) : L"";
        }
 
-       bool not_all_audio_decoders_ready() const
+       bool all_audio_decoders_ready() const
        {
                for (auto& audio_decoder : audio_decoders_)
                        if (!audio_decoder->ready())
-                               return true;
+                               return false;
 
-               return false;
+               return true;
        }
 
        void try_decode_frame()
        {
                std::shared_ptr<AVPacket> pkt;
 
-               for (int n = 0; n < 32 && ((video_decoder_ && !video_decoder_->ready()) || not_all_audio_decoders_ready()) && input_.try_pop(pkt); ++n)
+               for (int n = 0; n < 32 && ((video_decoder_ && !video_decoder_->ready()) || !all_audio_decoders_ready()) && input_.try_pop(pkt); ++n)
                {
                        if (video_decoder_)
                                video_decoder_->push(pkt);