]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2: Added comments.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 3 Jun 2011 07:30:13 +0000 (07:30 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 3 Jun 2011 07:30:13 +0000 (07:30 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@837 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

modules/ffmpeg/producer/audio/audio_decoder.cpp
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/ffmpeg/producer/video/video_decoder.cpp

index a9ef991d0d25af6ad325694759e221ad23745eca..0aab9c8958bef33d2c162a8fa9b19d685edcc9de 100644 (file)
@@ -45,14 +45,14 @@ struct audio_decoder::implementation : boost::noncopyable
        const core::video_format_desc   format_desc_;\r
        std::vector<int16_t>                    current_chunk_; \r
        size_t                                                  frame_number_;\r
-       bool                                                    restarting_;\r
+       bool                                                    wait_for_eof_;\r
 public:\r
        explicit implementation(input& input, const core::video_format_desc& format_desc) \r
                : input_(input)\r
                , codec_context_(*input_.get_audio_codec_context())\r
                , format_desc_(format_desc)     \r
                , frame_number_(0)\r
-               , restarting_(false)\r
+               , wait_for_eof_(false)\r
        {\r
                if(codec_context_.sample_rate != static_cast<int>(format_desc_.audio_sample_rate) || \r
                   codec_context_.channels != static_cast<int>(format_desc_.audio_channels))\r
@@ -80,16 +80,16 @@ public:
        {                       \r
                std::deque<std::pair<int, std::vector<int16_t>>> result;\r
 \r
-               if(!audio_packet)\r
+               if(!audio_packet) // eof\r
                {       \r
                        avcodec_flush_buffers(&codec_context_);\r
                        current_chunk_.clear();\r
                        frame_number_ = 0;\r
-                       restarting_ = false;\r
+                       wait_for_eof_ = false;\r
                        return result;\r
                }\r
 \r
-               if(restarting_)\r
+               if(wait_for_eof_)\r
                        return result;\r
                                \r
                auto s = current_chunk_.size();\r
@@ -119,7 +119,7 @@ public:
 \r
        void restart()\r
        {\r
-               restarting_ = true;\r
+               wait_for_eof_ = true;\r
        }\r
 };\r
 \r
index 362851b621998ca6189f63f0133d56eed7010a44..525098479a1c70243f0f9919081c1da8a240ae76 100644 (file)
@@ -119,10 +119,11 @@ public:
                        }\r
                );\r
                \r
+               // If video is on first frame, sync with audio\r
                if(audio_decoder_ && video_decoder_ && !video_frames_.empty() && !audio_chunks_.empty() &&\r
                   video_frames_.front().first == 0 && audio_chunks_.front().first != 0)\r
                {\r
-                       audio_decoder_->restart();\r
+                       audio_decoder_->restart(); // Notify decoder to wait for eof which was sent with video eof.\r
                        audio_chunks_ = audio_decoder_->receive();              \r
                }\r
                \r
index 8de4ec71411347738035516d4373c54921f0f967..36850d0fcc5da0101407b7516b727113cd8878c9 100644 (file)
@@ -169,7 +169,7 @@ public:
        {                       \r
                std::deque<std::pair<int, safe_ptr<core::write_frame>>> result;\r
 \r
-               if(!video_packet)\r
+               if(!video_packet) // eof\r
                {       \r
                        avcodec_flush_buffers(&codec_context_);\r
                        frame_number_ = 0;\r