From: ronag Date: Mon, 20 Jun 2011 21:21:00 +0000 (+0000) Subject: git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches... X-Git-Tag: 2.0.1~386 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ce2b97c07b781d108d65530af5e18fcd6766c99d;p=casparcg git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@930 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- diff --git a/core/mixer/image/image_mixer.cpp b/core/mixer/image/image_mixer.cpp index 9a5edc880..8cfc85a95 100644 --- a/core/mixer/image/image_mixer.cpp +++ b/core/mixer/image/image_mixer.cpp @@ -243,7 +243,7 @@ public: local_key_ = stream.back().transform.get_is_key(); // Keep for next layer if last frame is key } - safe_ptr create_frame(void* tag, const core::pixel_format_desc& desc) + safe_ptr create_frame(const void* tag, const core::pixel_format_desc& desc) { return make_safe(channel_.ogl(), reinterpret_cast(tag), desc); } @@ -254,7 +254,7 @@ void image_mixer::begin(const core::basic_frame& frame){impl_->begin(frame);} void image_mixer::visit(core::write_frame& frame){impl_->visit(frame);} void image_mixer::end(){impl_->end();} safe_ptr image_mixer::render(){return impl_->render();} -safe_ptr image_mixer::create_frame(void* tag, const core::pixel_format_desc& desc){return impl_->create_frame(tag, desc);} +safe_ptr image_mixer::create_frame(const void* tag, const core::pixel_format_desc& desc){return impl_->create_frame(tag, desc);} void image_mixer::begin_layer(){impl_->begin_layer();} void image_mixer::end_layer(){impl_->end_layer();} image_mixer& image_mixer::operator=(image_mixer&& other) diff --git a/core/mixer/image/image_mixer.h b/core/mixer/image/image_mixer.h index b8c337389..927097cec 100644 --- a/core/mixer/image/image_mixer.h +++ b/core/mixer/image/image_mixer.h @@ -48,7 +48,7 @@ public: safe_ptr render(); - safe_ptr create_frame(void* tag, const core::pixel_format_desc& format); + safe_ptr create_frame(const void* tag, const core::pixel_format_desc& format); private: struct implementation; diff --git a/core/mixer/mixer.cpp b/core/mixer/mixer.cpp index f56f98f25..749bf040e 100644 --- a/core/mixer/mixer.cpp +++ b/core/mixer/mixer.cpp @@ -127,7 +127,7 @@ public: } } - safe_ptr create_frame(void* tag, const core::pixel_format_desc& desc) + safe_ptr create_frame(const void* tag, const core::pixel_format_desc& desc) { return image_mixer_.create_frame(tag, desc); } @@ -259,8 +259,8 @@ private: mixer::mixer(video_channel_context& video_channel) : impl_(new implementation(video_channel)){} safe_ptr mixer::execute(const std::map>& frames){ return impl_->execute(frames);} core::video_format_desc mixer::get_video_format_desc() const { return impl_->channel_.get_format_desc(); } -safe_ptr mixer::create_frame(void* tag, const core::pixel_format_desc& desc){ return impl_->create_frame(tag, desc); } -safe_ptr mixer::create_frame(void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt) +safe_ptr mixer::create_frame(const void* tag, const core::pixel_format_desc& desc){ return impl_->create_frame(tag, desc); } +safe_ptr mixer::create_frame(const void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt) { // Create bgra frame core::pixel_format_desc desc; diff --git a/core/mixer/mixer.h b/core/mixer/mixer.h index 317a6f17e..3958a36ba 100644 --- a/core/mixer/mixer.h +++ b/core/mixer/mixer.h @@ -46,8 +46,8 @@ public: safe_ptr execute(const std::map>& frames); // nothrow - safe_ptr create_frame(void* tag, const core::pixel_format_desc& desc); - safe_ptr create_frame(void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt = core::pixel_format::bgra); + safe_ptr create_frame(const void* tag, const core::pixel_format_desc& desc); + safe_ptr create_frame(const void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt = core::pixel_format::bgra); core::video_format_desc get_video_format_desc() const; // nothrow diff --git a/core/producer/frame/frame_factory.h b/core/producer/frame/frame_factory.h index 30e7bcfc9..c8880155b 100644 --- a/core/producer/frame/frame_factory.h +++ b/core/producer/frame/frame_factory.h @@ -33,8 +33,8 @@ struct video_format_desc; struct frame_factory : boost::noncopyable { - virtual safe_ptr create_frame(void* video_stream_tag, const pixel_format_desc& desc) = 0; - virtual safe_ptr create_frame(void* video_stream_tag, size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra) = 0; + virtual safe_ptr create_frame(const void* video_stream_tag, const pixel_format_desc& desc) = 0; + virtual safe_ptr create_frame(const void* video_stream_tag, size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra) = 0; virtual video_format_desc get_video_format_desc() const = 0; // nothrow }; diff --git a/modules/bluefish/bluefish.cpp b/modules/bluefish/bluefish.cpp index b9b027c44..8cd7bf9a9 100644 --- a/modules/bluefish/bluefish.cpp +++ b/modules/bluefish/bluefish.cpp @@ -39,7 +39,7 @@ void init_bluefish() } catch(...) { - CASPAR_LOG_CURRENT_EXCEPTION(); + //CASPAR_LOG_CURRENT_EXCEPTION(); CASPAR_LOG(info) << L"Bluefish not supported."; } } diff --git a/modules/ffmpeg/producer/util.h b/modules/ffmpeg/producer/util.h index ddad50c31..b7d478d1b 100644 --- a/modules/ffmpeg/producer/util.h +++ b/modules/ffmpeg/producer/util.h @@ -88,11 +88,10 @@ static core::pixel_format_desc get_pixel_format_desc(PixelFormat pix_fmt, size_t } } -safe_ptr make_write_frame(const void* tag, const safe_ptr& decoded_frame, const safe_ptr& frame_factory) +static safe_ptr make_write_frame(const void* tag, const safe_ptr& decoded_frame, const safe_ptr& frame_factory) { static tbb::concurrent_unordered_map>> sws_contexts_; - // We don't know what the filter output might give until we received the first frame. Initialize everything on first frame. auto width = decoded_frame->width; auto height = decoded_frame->height; auto pix_fmt = static_cast(decoded_frame->format); @@ -153,7 +152,7 @@ safe_ptr make_write_frame(const void* tag, const safe_ptrinterlaced_frame) { switch(frame_factory->get_video_format_desc().mode) diff --git a/modules/ffmpeg/util/filter.cpp b/modules/ffmpeg/util/filter.cpp deleted file mode 100644 index 90d49f9b9..000000000 --- a/modules/ffmpeg/util/filter.cpp +++ /dev/null @@ -1,168 +0,0 @@ -#include "../stdafx.h" - -#include "filter.h" - -#include "../ffmpeg_error.h" -#include "util.h" - -#include -#include -#include -#include - -#include - -#include -#include - -extern "C" -{ - #define __STDC_CONSTANT_MACROS - #define __STDC_LIMIT_MACROS - #include - #include - #include - #include - #include - #include -} - -namespace caspar { - -struct filter::implementation -{ - std::string filters_; - std::shared_ptr graph_; - AVFilterContext* video_in_filter_; - AVFilterContext* video_out_filter_; - - boost::circular_buffer> buffers_; - - implementation(const std::string& filters) - : filters_(filters) - { - std::transform(filters_.begin(), filters_.end(), filters_.begin(), ::tolower); - - buffers_.set_capacity(3); - } - - std::vector> execute(const safe_ptr& frame) - { - int errn = 0; - - if(!graph_) - { - graph_.reset(avfilter_graph_alloc(), [](AVFilterGraph* p){avfilter_graph_free(&p);}); - - // Input - std::stringstream buffer_ss; - buffer_ss << frame->width << ":" << frame->height << ":" << frame->format << ":" << 0 << ":" << 0 << ":" << 0 << ":" << 0; // don't care about pts and aspect_ratio - errn = avfilter_graph_create_filter(&video_in_filter_, avfilter_get_by_name("buffer"), "src", buffer_ss.str().c_str(), NULL, graph_.get()); - if(errn < 0 || !video_in_filter_) - { - BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) << - boost::errinfo_api_function("avfilter_graph_create_filter") << boost::errinfo_errno(AVUNERROR(errn))); - } - - // Output - errn = avfilter_graph_create_filter(&video_out_filter_, avfilter_get_by_name("nullsink"), "out", NULL, NULL, graph_.get()); - if(errn < 0 || !video_out_filter_) - { - BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) << - boost::errinfo_api_function("avfilter_graph_create_filter") << boost::errinfo_errno(AVUNERROR(errn))); - } - - AVFilterInOut* outputs = reinterpret_cast(av_malloc(sizeof(AVFilterInOut))); - AVFilterInOut* inputs = reinterpret_cast(av_malloc(sizeof(AVFilterInOut))); - - outputs->name = av_strdup("in"); - outputs->filter_ctx = video_in_filter_; - outputs->pad_idx = 0; - outputs->next = NULL; - - inputs->name = av_strdup("out"); - inputs->filter_ctx = video_out_filter_; - inputs->pad_idx = 0; - inputs->next = NULL; - - errn = avfilter_graph_parse(graph_.get(), filters_.c_str(), inputs, outputs, NULL); - if(errn < 0) - { - BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) << - boost::errinfo_api_function("avfilter_graph_parse") << boost::errinfo_errno(AVUNERROR(errn))); - } - -// av_free(outputs); -// av_free(inputs); - - errn = avfilter_graph_config(graph_.get(), NULL); - if(errn < 0) - { - BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) - << boost::errinfo_api_function("avfilter_graph_config") << boost::errinfo_errno(AVUNERROR(errn))); - } - } - - errn = av_vsrc_buffer_add_frame(video_in_filter_, frame.get(), AV_VSRC_BUF_FLAG_OVERWRITE); - if(errn < 0) - { - BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) << - boost::errinfo_api_function("av_vsrc_buffer_add_frame") << boost::errinfo_errno(AVUNERROR(errn))); - } - - errn = avfilter_poll_frame(video_out_filter_->inputs[0]); - if(errn < 0) - { - BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) << - boost::errinfo_api_function("avfilter_poll_frame") << boost::errinfo_errno(AVUNERROR(errn))); - } - - std::vector> result; - - std::generate_n(std::back_inserter(result), errn, [&]{return get_frame();}); - - return result; - } - - safe_ptr get_frame() - { - auto link = video_out_filter_->inputs[0]; - - CASPAR_ASSERT(link); - - int errn = avfilter_request_frame(link); - if(errn < 0) - { - BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) << - boost::errinfo_api_function("avfilter_request_frame") << boost::errinfo_errno(AVUNERROR(errn))); - } - - auto pic = reinterpret_cast(link->cur_buf->buf); - - safe_ptr frame(avcodec_alloc_frame(), av_free); - avcodec_get_frame_defaults(frame.get()); - - for(size_t n = 0; n < 4; ++n) - { - frame->data[n] = pic->data[n]; - frame->linesize[n] = pic->linesize[n]; - } - - // FIXME - frame->width = link->cur_buf->video->w; - frame->height = link->cur_buf->video->h; - frame->format = link->cur_buf->format; - frame->interlaced_frame = link->cur_buf->video->interlaced; - frame->top_field_first = link->cur_buf->video->top_field_first; - frame->key_frame = link->cur_buf->video->key_frame; - - buffers_.push_back(std::shared_ptr(link->cur_buf, avfilter_unref_buffer)); - - return frame; - } -}; - -filter::filter(const std::string& filters) : impl_(new implementation(filters)){} -std::vector> filter::execute(const safe_ptr& frame) {return impl_->execute(frame);} - -} \ No newline at end of file diff --git a/modules/ffmpeg/util/filter.h b/modules/ffmpeg/util/filter.h deleted file mode 100644 index c964f487a..000000000 --- a/modules/ffmpeg/util/filter.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include - -#include - -struct AVFrame; - -namespace caspar { - -class filter -{ -public: - filter(const std::string& filters); - - std::vector> execute(const safe_ptr& frame); - -private: - struct implementation; - safe_ptr impl_; -}; - -} \ No newline at end of file diff --git a/modules/ffmpeg/util/util.h b/modules/ffmpeg/util/util.h deleted file mode 100644 index d24a5f185..000000000 --- a/modules/ffmpeg/util/util.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include -#include - -namespace caspar { - -static core::pixel_format::type get_pixel_format(PixelFormat pix_fmt) -{ - switch(pix_fmt) - { - case PIX_FMT_GRAY8: return core::pixel_format::gray; - case PIX_FMT_BGRA: return core::pixel_format::bgra; - case PIX_FMT_ARGB: return core::pixel_format::argb; - case PIX_FMT_RGBA: return core::pixel_format::rgba; - case PIX_FMT_ABGR: return core::pixel_format::abgr; - case PIX_FMT_YUV444P: return core::pixel_format::ycbcr; - case PIX_FMT_YUV422P: return core::pixel_format::ycbcr; - case PIX_FMT_YUV420P: return core::pixel_format::ycbcr; - case PIX_FMT_YUV411P: return core::pixel_format::ycbcr; - case PIX_FMT_YUV410P: return core::pixel_format::ycbcr; - case PIX_FMT_YUVA420P: return core::pixel_format::ycbcra; - default: return core::pixel_format::invalid; - } -} - -static core::pixel_format_desc get_pixel_format_desc(PixelFormat pix_fmt, size_t width, size_t height) -{ - // Get linesizes - AVPicture dummy_pict; - avpicture_fill(&dummy_pict, nullptr, pix_fmt, width, height); - - core::pixel_format_desc desc; - desc.pix_fmt = get_pixel_format(pix_fmt); - - switch(desc.pix_fmt) - { - case core::pixel_format::gray: - { - desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[0]/4, height, 1)); - return desc; - } - case core::pixel_format::bgra: - case core::pixel_format::argb: - case core::pixel_format::rgba: - case core::pixel_format::abgr: - { - desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[0]/4, height, 4)); - return desc; - } - case core::pixel_format::ycbcr: - case core::pixel_format::ycbcra: - { - // Find chroma height - size_t size2 = dummy_pict.data[2] - dummy_pict.data[1]; - size_t h2 = size2/dummy_pict.linesize[1]; - - desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[0], height, 1)); - desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[1], h2, 1)); - desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[2], h2, 1)); - - if(desc.pix_fmt == core::pixel_format::ycbcra) - desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[3], height, 1)); - return desc; - } - default: - desc.pix_fmt = core::pixel_format::invalid; - return desc; - } -} - -} \ No newline at end of file diff --git a/shell/casparcg.config b/shell/casparcg.config index 8438d3a96..d19572fc3 100644 --- a/shell/casparcg.config +++ b/shell/casparcg.config @@ -12,7 +12,7 @@ - 1080i5000 + PAL