From: ronag Date: Sun, 23 Oct 2011 14:52:08 +0000 (+0000) Subject: git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches... X-Git-Tag: 2.1.0_Beta1~1184 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=1c2cac1dd803d5f539c26f40c323081db948004a;p=casparcg git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0 concrt-experimental@1412 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- diff --git a/modules/ffmpeg/producer/filter/filter.cpp b/modules/ffmpeg/producer/filter/filter.cpp index e55524d91..8fc266a65 100644 --- a/modules/ffmpeg/producer/filter/filter.cpp +++ b/modules/ffmpeg/producer/filter/filter.cpp @@ -78,43 +78,51 @@ struct filter::implementation if(!graph_) { - graph_.reset(avfilter_graph_alloc(), [](AVFilterGraph* p){avfilter_graph_free(&p);}); + try + { + graph_.reset(avfilter_graph_alloc(), [](AVFilterGraph* p){avfilter_graph_free(&p);}); - // Input - std::stringstream args; - args << frame->width << ":" << frame->height << ":" << frame->format << ":" << 0 << ":" << 0 << ":" << 0 << ":" << 0; // don't care about pts and aspect_ratio - THROW_ON_ERROR2(avfilter_graph_create_filter(&buffersrc_ctx_, avfilter_get_by_name("buffer"), "src", args.str().c_str(), NULL, graph_.get()), "[filter]"); - - // OPIX_FMT_BGRAutput - AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc(); - buffersink_params->pixel_fmts = pix_fmts_.data(); - THROW_ON_ERROR2(avfilter_graph_create_filter(&buffersink_ctx_, avfilter_get_by_name("buffersink"), "out", NULL, buffersink_params, graph_.get()), "[filter]"); + // Input + std::stringstream args; + args << frame->width << ":" << frame->height << ":" << frame->format << ":" << 0 << ":" << 0 << ":" << 0 << ":" << 0; // don't care about pts and aspect_ratio + THROW_ON_ERROR2(avfilter_graph_create_filter(&buffersrc_ctx_, avfilter_get_by_name("buffer"), "src", args.str().c_str(), NULL, graph_.get()), "[filter]"); + + // OPIX_FMT_BGRAutput + AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc(); + buffersink_params->pixel_fmts = pix_fmts_.data(); + THROW_ON_ERROR2(avfilter_graph_create_filter(&buffersink_ctx_, avfilter_get_by_name("buffersink"), "out", NULL, buffersink_params, graph_.get()), "[filter]"); - AVFilterInOut* outputs = avfilter_inout_alloc(); - AVFilterInOut* inputs = avfilter_inout_alloc(); + AVFilterInOut* outputs = avfilter_inout_alloc(); + AVFilterInOut* inputs = avfilter_inout_alloc(); - outputs->name = av_strdup("in"); - outputs->filter_ctx = buffersrc_ctx_; - outputs->pad_idx = 0; - outputs->next = NULL; - - inputs->name = av_strdup("out"); - inputs->filter_ctx = buffersink_ctx_; - inputs->pad_idx = 0; - inputs->next = NULL; + outputs->name = av_strdup("in"); + outputs->filter_ctx = buffersrc_ctx_; + outputs->pad_idx = 0; + outputs->next = NULL; + + inputs->name = av_strdup("out"); + inputs->filter_ctx = buffersink_ctx_; + inputs->pad_idx = 0; + inputs->next = NULL; - THROW_ON_ERROR2(avfilter_graph_parse(graph_.get(), filters_.c_str(), &inputs, &outputs, NULL), "[filter]"); + THROW_ON_ERROR2(avfilter_graph_parse(graph_.get(), filters_.c_str(), &inputs, &outputs, NULL), "[filter]"); - avfilter_inout_free(&inputs); - avfilter_inout_free(&outputs); + avfilter_inout_free(&inputs); + avfilter_inout_free(&outputs); - THROW_ON_ERROR2(avfilter_graph_config(graph_.get(), NULL), "[filter]"); + THROW_ON_ERROR2(avfilter_graph_config(graph_.get(), NULL), "[filter]"); - for(size_t n = 0; n < graph_->filter_count; ++n) + for(size_t n = 0; n < graph_->filter_count; ++n) + { + auto filter_name = graph_->filters[n]->name; + if(strstr(filter_name, "yadif") != 0) + parallel_yadif_ctx_ = make_parallel_yadif(graph_->filters[n]); + } + } + catch(...) { - auto filter_name = graph_->filters[n]->name; - if(strstr(filter_name, "yadif") != 0) - parallel_yadif_ctx_ = make_parallel_yadif(graph_->filters[n]); + graph_ = nullptr; + throw; } }