\r
struct audio_decoder::implementation : public agent, boost::noncopyable\r
{ \r
+ ITarget<audio_decoder::target_element_t>& target_;\r
+\r
int index_;\r
- std::shared_ptr<AVCodecContext> codec_context_; \r
+ const safe_ptr<AVCodecContext> codec_context_; \r
\r
audio_resampler resampler_;\r
\r
std::vector<int8_t, tbb::cache_aligned_allocator<int8_t>> buffer1_;\r
\r
unbounded_buffer<audio_decoder::source_element_t> source_;\r
- ITarget<audio_decoder::target_element_t>& target_;\r
\r
governor governor_;\r
\r
\r
public:\r
explicit implementation(audio_decoder::source_t& source, audio_decoder::target_t& target, AVFormatContext& context, const core::video_format_desc& format_desc) \r
- : codec_context_(open_codec(context, AVMEDIA_TYPE_AUDIO, index_))\r
+ : target_(target)\r
+ , codec_context_(open_codec(context, AVMEDIA_TYPE_AUDIO, index_))\r
, resampler_(format_desc.audio_channels, codec_context_->channels,\r
format_desc.audio_sample_rate, codec_context_->sample_rate,\r
AV_SAMPLE_FMT_S32, codec_context_->sample_fmt)\r
, buffer1_(AVCODEC_MAX_AUDIO_FRAME_SIZE*2)\r
, source_([this](const audio_decoder::source_element_t& packet){return packet->stream_index == index_;})\r
- , target_(target)\r
, governor_(2)\r
{ \r
CASPAR_LOG(debug) << "[audio_decoder] " << context.streams[index_]->codec->codec->long_name;\r
, boost::noncopyable\r
{\r
input::target_t& target_;\r
+ safe_ptr<diagnostics::graph> graph_;\r
\r
const std::wstring filename_;\r
const safe_ptr<AVFormatContext> format_context_; // Destroy this last\r
- int default_stream_index_;\r
+ const int default_stream_index_;\r
const boost::iterator_range<AVStream**> streams_;\r
-\r
- safe_ptr<diagnostics::graph> graph_;\r
- \r
- tbb::atomic<bool> loop_;\r
const size_t start_; \r
const size_t length_;\r
+ \r
size_t frame_number_;\r
+ tbb::atomic<bool> loop_;\r
\r
tbb::atomic<size_t> nb_frames_;\r
tbb::atomic<size_t> nb_loops_; \r
size_t start,\r
size_t length)\r
: target_(target)\r
+ , graph_(graph)\r
, filename_(filename)\r
, format_context_(open_input(filename)) \r
, default_stream_index_(av_find_default_stream_index(format_context_.get()))\r
, streams_(format_context_->streams, format_context_->streams + format_context_->nb_streams)\r
- , graph_(graph)\r
, start_(start)\r
, length_(length)\r
, frame_number_(0)\r
\r
try\r
{\r
- for(auto packet = read_next_packet(); packet && is_running_; packet = read_next_packet())\r
+ for(auto packet = read_next_packet(); is_running_ && packet; packet = read_next_packet())\r
{ \r
Concurrency::asend(target_, make_safe_ptr(packet));\r
Context::Yield();\r
\r
struct video_decoder::implementation : public Concurrency::agent, boost::noncopyable\r
{ \r
- int index_;\r
- const safe_ptr<AVCodecContext> codec_context_;\r
+ unbounded_buffer<video_decoder::source_element_t> source_;\r
+ ITarget<video_decoder::target_element_t>& target_;\r
+\r
+ int index_;\r
+ const safe_ptr<AVCodecContext> codec_context_;\r
\r
const double fps_;\r
const int64_t nb_frames_;\r
const size_t height_;\r
bool is_progressive_;\r
\r
- unbounded_buffer<video_decoder::source_element_t> source_;\r
- ITarget<video_decoder::target_element_t>& target_;\r
-\r
governor governor_;\r
\r
tbb::atomic<bool> is_running_;\r
\r
public:\r
explicit implementation(video_decoder::source_t& source, video_decoder::target_t& target, AVFormatContext& context) \r
- : codec_context_(open_codec(context, AVMEDIA_TYPE_VIDEO, index_))\r
+ : source_([this](const video_decoder::source_element_t& packet){return packet->stream_index == index_;})\r
+ , target_(target)\r
+ , codec_context_(open_codec(context, AVMEDIA_TYPE_VIDEO, index_))\r
, fps_(static_cast<double>(codec_context_->time_base.den) / static_cast<double>(codec_context_->time_base.num))\r
, nb_frames_(context.streams[index_]->nb_frames)\r
, width_(codec_context_->width)\r
, height_(codec_context_->height)\r
, is_progressive_(true)\r
- , source_([this](const video_decoder::source_element_t& packet){return packet->stream_index == index_;})\r
- , target_(target)\r
, governor_(1) // IMPORTANT: Must be 1 since avcodec_decode_video2 reuses memory.\r
{ \r
CASPAR_LOG(debug) << "[video_decoder] " << context.streams[index_]->codec->codec->long_name;\r