local_key_ = stream.back().transform.get_is_key(); // Keep for next layer if last frame is key\r
}\r
\r
- safe_ptr<write_frame> create_frame(void* tag, const core::pixel_format_desc& desc)\r
+ safe_ptr<write_frame> create_frame(const void* tag, const core::pixel_format_desc& desc)\r
{\r
return make_safe<write_frame>(channel_.ogl(), reinterpret_cast<int>(tag), desc);\r
}\r
void image_mixer::visit(core::write_frame& frame){impl_->visit(frame);}\r
void image_mixer::end(){impl_->end();}\r
safe_ptr<host_buffer> image_mixer::render(){return impl_->render();}\r
-safe_ptr<write_frame> image_mixer::create_frame(void* tag, const core::pixel_format_desc& desc){return impl_->create_frame(tag, desc);}\r
+safe_ptr<write_frame> image_mixer::create_frame(const void* tag, const core::pixel_format_desc& desc){return impl_->create_frame(tag, desc);}\r
void image_mixer::begin_layer(){impl_->begin_layer();}\r
void image_mixer::end_layer(){impl_->end_layer();}\r
image_mixer& image_mixer::operator=(image_mixer&& other)\r
\r
safe_ptr<host_buffer> render();\r
\r
- safe_ptr<write_frame> create_frame(void* tag, const core::pixel_format_desc& format);\r
+ safe_ptr<write_frame> create_frame(const void* tag, const core::pixel_format_desc& format);\r
\r
private:\r
struct implementation;\r
}\r
}\r
\r
- safe_ptr<core::write_frame> create_frame(void* tag, const core::pixel_format_desc& desc)\r
+ safe_ptr<core::write_frame> create_frame(const void* tag, const core::pixel_format_desc& desc)\r
{ \r
return image_mixer_.create_frame(tag, desc);\r
}\r
mixer::mixer(video_channel_context& video_channel) : impl_(new implementation(video_channel)){}\r
safe_ptr<core::read_frame> mixer::execute(const std::map<int, safe_ptr<core::basic_frame>>& frames){ return impl_->execute(frames);}\r
core::video_format_desc mixer::get_video_format_desc() const { return impl_->channel_.get_format_desc(); }\r
-safe_ptr<core::write_frame> mixer::create_frame(void* tag, const core::pixel_format_desc& desc){ return impl_->create_frame(tag, desc); } \r
-safe_ptr<core::write_frame> mixer::create_frame(void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt)\r
+safe_ptr<core::write_frame> mixer::create_frame(const void* tag, const core::pixel_format_desc& desc){ return impl_->create_frame(tag, desc); } \r
+safe_ptr<core::write_frame> mixer::create_frame(const void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt)\r
{\r
// Create bgra frame\r
core::pixel_format_desc desc;\r
\r
safe_ptr<core::read_frame> execute(const std::map<int, safe_ptr<core::basic_frame>>& frames); // nothrow\r
\r
- safe_ptr<core::write_frame> create_frame(void* tag, const core::pixel_format_desc& desc); \r
- safe_ptr<core::write_frame> create_frame(void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt = core::pixel_format::bgra); \r
+ safe_ptr<core::write_frame> create_frame(const void* tag, const core::pixel_format_desc& desc); \r
+ safe_ptr<core::write_frame> create_frame(const void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt = core::pixel_format::bgra); \r
\r
core::video_format_desc get_video_format_desc() const; // nothrow\r
\r
\r
struct frame_factory : boost::noncopyable\r
{\r
- virtual safe_ptr<write_frame> create_frame(void* video_stream_tag, const pixel_format_desc& desc) = 0;\r
- virtual safe_ptr<write_frame> create_frame(void* video_stream_tag, size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra) = 0; \r
+ virtual safe_ptr<write_frame> create_frame(const void* video_stream_tag, const pixel_format_desc& desc) = 0;\r
+ virtual safe_ptr<write_frame> create_frame(const void* video_stream_tag, size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra) = 0; \r
\r
virtual video_format_desc get_video_format_desc() const = 0; // nothrow\r
};\r
}\r
catch(...)\r
{\r
- CASPAR_LOG_CURRENT_EXCEPTION();\r
+ //CASPAR_LOG_CURRENT_EXCEPTION();\r
CASPAR_LOG(info) << L"Bluefish not supported.";\r
}\r
}\r
}\r
}\r
\r
-safe_ptr<core::write_frame> make_write_frame(const void* tag, const safe_ptr<AVFrame>& decoded_frame, const safe_ptr<core::frame_factory>& frame_factory)\r
+static safe_ptr<core::write_frame> make_write_frame(const void* tag, const safe_ptr<AVFrame>& decoded_frame, const safe_ptr<core::frame_factory>& frame_factory)\r
{ \r
static tbb::concurrent_unordered_map<size_t, tbb::concurrent_queue<std::shared_ptr<SwsContext>>> sws_contexts_;\r
\r
- // We don't know what the filter output might give until we received the first frame. Initialize everything on first frame.\r
auto width = decoded_frame->width;\r
auto height = decoded_frame->height;\r
auto pix_fmt = static_cast<PixelFormat>(decoded_frame->format);\r
});\r
}\r
\r
- // Fix field-order if needed. DVVIDEO is in lower field. Make it upper field if needed.\r
+ // Fix field-order if needed\r
if(decoded_frame->interlaced_frame)\r
{\r
switch(frame_factory->get_video_format_desc().mode)\r
+++ /dev/null
-#include "../stdafx.h"\r
-\r
-#include "filter.h"\r
-\r
-#include "../ffmpeg_error.h"\r
-#include "util.h"\r
-\r
-#include <common/exception/exceptions.h>\r
-#include <core/producer/frame/basic_frame.h>\r
-#include <core/producer/frame/frame_factory.h>\r
-#include <core/mixer/write_frame.h>\r
-\r
-#include <boost/circular_buffer.hpp>\r
-\r
-#include <cstdio>\r
-#include <sstream>\r
-\r
-extern "C" \r
-{\r
- #define __STDC_CONSTANT_MACROS\r
- #define __STDC_LIMIT_MACROS\r
- #include <libavutil/avutil.h>\r
- #include <libavutil/imgutils.h>\r
- #include <libavfilter/avfilter.h>\r
- #include <libavfilter/avcodec.h>\r
- #include <libavfilter/vsrc_buffer.h>\r
- #include <libavfilter/avfiltergraph.h>\r
-}\r
-\r
-namespace caspar {\r
- \r
-struct filter::implementation\r
-{\r
- std::string filters_;\r
- std::shared_ptr<AVFilterGraph> graph_;\r
- AVFilterContext* video_in_filter_;\r
- AVFilterContext* video_out_filter_;\r
-\r
- boost::circular_buffer<std::shared_ptr<AVFilterBufferRef>> buffers_;\r
- \r
- implementation(const std::string& filters) \r
- : filters_(filters)\r
- {\r
- std::transform(filters_.begin(), filters_.end(), filters_.begin(), ::tolower);\r
-\r
- buffers_.set_capacity(3);\r
- }\r
-\r
- std::vector<safe_ptr<AVFrame>> execute(const safe_ptr<AVFrame>& frame)\r
- { \r
- int errn = 0; \r
-\r
- if(!graph_)\r
- {\r
- graph_.reset(avfilter_graph_alloc(), [](AVFilterGraph* p){avfilter_graph_free(&p);});\r
- \r
- // Input\r
- std::stringstream buffer_ss;\r
- buffer_ss << frame->width << ":" << frame->height << ":" << frame->format << ":" << 0 << ":" << 0 << ":" << 0 << ":" << 0; // don't care about pts and aspect_ratio\r
- errn = avfilter_graph_create_filter(&video_in_filter_, avfilter_get_by_name("buffer"), "src", buffer_ss.str().c_str(), NULL, graph_.get());\r
- if(errn < 0 || !video_in_filter_)\r
- {\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) <<\r
- boost::errinfo_api_function("avfilter_graph_create_filter") << boost::errinfo_errno(AVUNERROR(errn)));\r
- }\r
-\r
- // Output\r
- errn = avfilter_graph_create_filter(&video_out_filter_, avfilter_get_by_name("nullsink"), "out", NULL, NULL, graph_.get());\r
- if(errn < 0 || !video_out_filter_)\r
- {\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) <<\r
- boost::errinfo_api_function("avfilter_graph_create_filter") << boost::errinfo_errno(AVUNERROR(errn)));\r
- }\r
- \r
- AVFilterInOut* outputs = reinterpret_cast<AVFilterInOut*>(av_malloc(sizeof(AVFilterInOut)));\r
- AVFilterInOut* inputs = reinterpret_cast<AVFilterInOut*>(av_malloc(sizeof(AVFilterInOut)));\r
-\r
- outputs->name = av_strdup("in");\r
- outputs->filter_ctx = video_in_filter_;\r
- outputs->pad_idx = 0;\r
- outputs->next = NULL;\r
-\r
- inputs->name = av_strdup("out");\r
- inputs->filter_ctx = video_out_filter_;\r
- inputs->pad_idx = 0;\r
- inputs->next = NULL;\r
- \r
- errn = avfilter_graph_parse(graph_.get(), filters_.c_str(), inputs, outputs, NULL);\r
- if(errn < 0)\r
- {\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) <<\r
- boost::errinfo_api_function("avfilter_graph_parse") << boost::errinfo_errno(AVUNERROR(errn)));\r
- }\r
-\r
-// av_free(outputs);\r
-// av_free(inputs);\r
-\r
- errn = avfilter_graph_config(graph_.get(), NULL);\r
- if(errn < 0)\r
- {\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) \r
- << boost::errinfo_api_function("avfilter_graph_config") << boost::errinfo_errno(AVUNERROR(errn)));\r
- }\r
- }\r
- \r
- errn = av_vsrc_buffer_add_frame(video_in_filter_, frame.get(), AV_VSRC_BUF_FLAG_OVERWRITE);\r
- if(errn < 0)\r
- {\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) <<\r
- boost::errinfo_api_function("av_vsrc_buffer_add_frame") << boost::errinfo_errno(AVUNERROR(errn)));\r
- }\r
-\r
- errn = avfilter_poll_frame(video_out_filter_->inputs[0]);\r
- if(errn < 0)\r
- {\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) <<\r
- boost::errinfo_api_function("avfilter_poll_frame") << boost::errinfo_errno(AVUNERROR(errn)));\r
- }\r
-\r
- std::vector<safe_ptr<AVFrame>> result;\r
-\r
- std::generate_n(std::back_inserter(result), errn, [&]{return get_frame();});\r
-\r
- return result;\r
- }\r
- \r
- safe_ptr<AVFrame> get_frame()\r
- { \r
- auto link = video_out_filter_->inputs[0];\r
-\r
- CASPAR_ASSERT(link);\r
-\r
- int errn = avfilter_request_frame(link); \r
- if(errn < 0)\r
- {\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(av_error_str(errn)) <<\r
- boost::errinfo_api_function("avfilter_request_frame") << boost::errinfo_errno(AVUNERROR(errn)));\r
- }\r
- \r
- auto pic = reinterpret_cast<AVPicture*>(link->cur_buf->buf);\r
- \r
- safe_ptr<AVFrame> frame(avcodec_alloc_frame(), av_free);\r
- avcodec_get_frame_defaults(frame.get()); \r
-\r
- for(size_t n = 0; n < 4; ++n)\r
- {\r
- frame->data[n] = pic->data[n];\r
- frame->linesize[n] = pic->linesize[n];\r
- }\r
-\r
- // FIXME\r
- frame->width = link->cur_buf->video->w;\r
- frame->height = link->cur_buf->video->h;\r
- frame->format = link->cur_buf->format;\r
- frame->interlaced_frame = link->cur_buf->video->interlaced;\r
- frame->top_field_first = link->cur_buf->video->top_field_first;\r
- frame->key_frame = link->cur_buf->video->key_frame;\r
-\r
- buffers_.push_back(std::shared_ptr<AVFilterBufferRef>(link->cur_buf, avfilter_unref_buffer));\r
-\r
- return frame;\r
- }\r
-};\r
-\r
-filter::filter(const std::string& filters) : impl_(new implementation(filters)){}\r
-std::vector<safe_ptr<AVFrame>> filter::execute(const safe_ptr<AVFrame>& frame) {return impl_->execute(frame);}\r
-\r
-}
\ No newline at end of file
+++ /dev/null
-#pragma once\r
-\r
-#include <common/memory/safe_ptr.h>\r
-\r
-#include <vector>\r
-\r
-struct AVFrame;\r
-\r
-namespace caspar {\r
- \r
-class filter\r
-{\r
-public:\r
- filter(const std::string& filters);\r
-\r
- std::vector<safe_ptr<AVFrame>> execute(const safe_ptr<AVFrame>& frame);\r
-\r
-private:\r
- struct implementation;\r
- safe_ptr<implementation> impl_;\r
-};\r
-\r
-}
\ No newline at end of file
+++ /dev/null
-#pragma once\r
-\r
-#include <core/video_format.h>\r
-#include <core/producer/frame/pixel_format.h>\r
-\r
-namespace caspar {\r
- \r
-static core::pixel_format::type get_pixel_format(PixelFormat pix_fmt)\r
-{\r
- switch(pix_fmt)\r
- {\r
- case PIX_FMT_GRAY8: return core::pixel_format::gray;\r
- case PIX_FMT_BGRA: return core::pixel_format::bgra;\r
- case PIX_FMT_ARGB: return core::pixel_format::argb;\r
- case PIX_FMT_RGBA: return core::pixel_format::rgba;\r
- case PIX_FMT_ABGR: return core::pixel_format::abgr;\r
- case PIX_FMT_YUV444P: return core::pixel_format::ycbcr;\r
- case PIX_FMT_YUV422P: return core::pixel_format::ycbcr;\r
- case PIX_FMT_YUV420P: return core::pixel_format::ycbcr;\r
- case PIX_FMT_YUV411P: return core::pixel_format::ycbcr;\r
- case PIX_FMT_YUV410P: return core::pixel_format::ycbcr;\r
- case PIX_FMT_YUVA420P: return core::pixel_format::ycbcra;\r
- default: return core::pixel_format::invalid;\r
- }\r
-}\r
-\r
-static core::pixel_format_desc get_pixel_format_desc(PixelFormat pix_fmt, size_t width, size_t height)\r
-{\r
- // Get linesizes\r
- AVPicture dummy_pict; \r
- avpicture_fill(&dummy_pict, nullptr, pix_fmt, width, height);\r
-\r
- core::pixel_format_desc desc;\r
- desc.pix_fmt = get_pixel_format(pix_fmt);\r
- \r
- switch(desc.pix_fmt)\r
- {\r
- case core::pixel_format::gray:\r
- {\r
- desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[0]/4, height, 1)); \r
- return desc;\r
- }\r
- case core::pixel_format::bgra:\r
- case core::pixel_format::argb:\r
- case core::pixel_format::rgba:\r
- case core::pixel_format::abgr:\r
- {\r
- desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[0]/4, height, 4)); \r
- return desc;\r
- }\r
- case core::pixel_format::ycbcr:\r
- case core::pixel_format::ycbcra:\r
- { \r
- // Find chroma height\r
- size_t size2 = dummy_pict.data[2] - dummy_pict.data[1];\r
- size_t h2 = size2/dummy_pict.linesize[1]; \r
-\r
- desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[0], height, 1));\r
- desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[1], h2, 1));\r
- desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[2], h2, 1));\r
-\r
- if(desc.pix_fmt == core::pixel_format::ycbcra) \r
- desc.planes.push_back(core::pixel_format_desc::plane(dummy_pict.linesize[3], height, 1)); \r
- return desc;\r
- } \r
- default: \r
- desc.pix_fmt = core::pixel_format::invalid;\r
- return desc;\r
- }\r
-}\r
-\r
-}
\ No newline at end of file
</diagnostics>\r
<channels>\r
<channel>\r
- <video-mode>1080i5000</video-mode>\r
+ <video-mode>PAL</video-mode>\r
<consumers>\r
<screen> \r
</screen>\r