- while(ouput_channel_.empty() && !input_->is_eof())\r
- { \r
- aligned_buffer video_packet;\r
- if(video_frame_channel_.size() < 3 && video_decoder_) \r
- video_packet = input_->get_video_packet(); \r
- \r
- aligned_buffer audio_packet;\r
- if(audio_chunk_channel_.size() < 3 && audio_decoder_) \r
- audio_packet = input_->get_audio_packet(); \r
-\r
- tbb::parallel_invoke(\r
- [&]\r
- { // Video Decoding and Scaling\r
- if(!video_packet.empty() && video_decoder_)\r
- {\r
- try\r
- {\r
- auto frame = video_decoder_->execute(video_packet);\r
- frame->tag(reinterpret_cast<int>(this));\r
- video_frame_channel_.push_back(std::move(frame));\r
- }\r
- catch(...)\r
- {\r
- CASPAR_LOG_CURRENT_EXCEPTION();\r
- video_decoder_.reset();\r
- CASPAR_LOG(warning) << print() << " removed video-stream.";\r
- }\r
- }\r
- }, \r
- [&] \r
- { // Audio Decoding\r
- if(!audio_packet.empty() && audio_decoder_)\r
- {\r
- try\r
- {\r
- auto chunks = audio_decoder_->execute(audio_packet);\r
- audio_chunk_channel_.insert(audio_chunk_channel_.end(), chunks.begin(), chunks.end());\r
- }\r
- catch(...)\r
- {\r
- CASPAR_LOG_CURRENT_EXCEPTION();\r
- audio_decoder_.reset();\r
- CASPAR_LOG(warning) << print() << " removed audio-stream.";\r
- }\r
- }\r
- });\r
-\r
- while((!video_frame_channel_.empty() || !video_decoder_) && (!audio_chunk_channel_.empty() || !audio_decoder_))\r
+ void decode_frame(int hints)\r
+ {\r
+ for(int n = 0; n < 16 && ((!muxer_.video_ready() && !video_decoder_.ready()) || (!muxer_.audio_ready() && !audio_decoder_.ready())); ++n) \r
+ {\r
+ std::shared_ptr<AVPacket> pkt;\r
+ if(input_.try_pop(pkt))\r