]> git.sesse.net Git - casparcg/blobdiff - modules/ffmpeg/producer/input/input.cpp
2.0.2: - Updated get_param.
[casparcg] / modules / ffmpeg / producer / input / input.cpp
index c0e5cdda86b858518520832e0aa59f52639687f5..ffa43eaddc1b247b93f73a3200431fc072808b8c 100644 (file)
@@ -1,25 +1,23 @@
 /*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
 *\r
-*  This file is part of CasparCG.\r
+* This file is part of CasparCG (www.casparcg.com).\r
 *\r
-*    CasparCG is free software: you can redistribute it and/or modify\r
-*    it under the terms of the GNU General Public License as published by\r
-*    the Free Software Foundation, either version 3 of the License, or\r
-*    (at your option) any later version.\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
 *\r
-*    CasparCG is distributed in the hope that it will be useful,\r
-*    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-*    GNU General Public License for more details.\r
-\r
-*    You should have received a copy of the GNU General Public License\r
-*    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
 *\r
+* Author: Robert Nagy, ronag89@gmail.com\r
 */\r
-#if defined(_MSC_VER)\r
-#pragma warning (disable : 4244)\r
-#endif\r
 \r
 #include "../../stdafx.h"\r
 \r
@@ -72,8 +70,8 @@ struct input::implementation : boost::noncopyable
                        \r
        const std::wstring                                                                                      filename_;\r
        tbb::atomic<bool>                                                                                       loop_;\r
-       const size_t                                                                                            start_;         \r
-       const size_t                                                                                            length_;\r
+       const uint64_t                                                                                          start_;         \r
+       const uint64_t                                                                                          length_;\r
        size_t                                                                                                          frame_number_;\r
        \r
        tbb::concurrent_bounded_queue<std::shared_ptr<AVPacket>>        buffer_;\r
@@ -87,7 +85,7 @@ struct input::implementation : boost::noncopyable
 \r
        tbb::recursive_mutex                                                                            mutex_;\r
 \r
-       explicit implementation(const safe_ptr<diagnostics::graph>& graph, const std::wstring& filename, bool loop, size_t start, size_t length) \r
+       explicit implementation(const safe_ptr<diagnostics::graph>& graph, const std::wstring& filename, bool loop, int64_t start, int64_t length) \r
                : graph_(graph)\r
                , format_context_(open_input(filename))         \r
                , default_stream_index_(av_find_default_stream_index(format_context_.get()))\r
@@ -180,7 +178,7 @@ struct input::implementation : boost::noncopyable
                        {\r
                                do_seek(start_);\r
                                graph_->add_tag("seek");                \r
-                               CASPAR_LOG(debug) << print() << " Looping.";                    \r
+                               CASPAR_LOG(trace) << print() << " Looping.";                    \r
                        }                                       \r
                }\r
                else\r
@@ -234,7 +232,7 @@ struct input::implementation : boost::noncopyable
                \r
                auto stream = format_context_->streams[default_stream_index_];\r
                auto codec  = stream->codec;\r
-               auto fixed_target = (target*stream->time_base.den*codec->time_base.num)/(stream->time_base.num*codec->time_base.den);\r
+               auto fixed_target = (target*stream->time_base.den*codec->time_base.num)/(stream->time_base.num*codec->time_base.den)*codec->ticks_per_frame;\r
                \r
                THROW_ON_ERROR2(avformat_seek_file(format_context_.get(), default_stream_index_, std::numeric_limits<int64_t>::min(), fixed_target, std::numeric_limits<int64_t>::max(), 0), print());          \r
 \r
@@ -266,7 +264,7 @@ struct input::implementation : boost::noncopyable
                if(ret == AVERROR(EIO))\r
                        CASPAR_LOG(trace) << print() << " Received EIO, assuming EOF. ";\r
                if(ret == AVERROR_EOF)\r
-                       CASPAR_LOG(debug) << print() << " Received EOF. ";\r
+                       CASPAR_LOG(trace) << print() << " Received EOF. ";\r
 \r
                return ret == AVERROR_EOF || ret == AVERROR(EIO) || frame_number_ >= length_; // av_read_frame doesn't always correctly return AVERROR_EOF;\r
        }\r
@@ -277,7 +275,7 @@ struct input::implementation : boost::noncopyable
        }\r
 };\r
 \r
-input::input(const safe_ptr<diagnostics::graph>& graph, const std::wstring& filename, bool loop, size_t start, size_t length) \r
+input::input(const safe_ptr<diagnostics::graph>& graph, const std::wstring& filename, bool loop, int64_t start, int64_t length) \r
        : impl_(new implementation(graph, filename, loop, start, length)){}\r
 bool input::eof() const {return impl_->is_eof_;}\r
 bool input::try_pop(std::shared_ptr<AVPacket>& packet){return impl_->try_pop(packet);}\r