]> git.sesse.net Git - casparcg/blobdiff - modules/ffmpeg/producer/util/util.h
2.1.0: -data_frame: Added field_mode and frame_rate meta-data.
[casparcg] / modules / ffmpeg / producer / util / util.h
index 79920fd80b5a9a5b70c78264e7b4ae8180b204c8..13573965dc731aa979e32939f3713af3e339cdaa 100644 (file)
 \r
 #pragma once\r
 \r
-#include <common/memory/safe_ptr.h>\r
+#include <common/forward.h>\r
+#include <common/spl/memory.h>\r
 \r
 #include <core/video_format.h>\r
-#include <core/producer/frame/pixel_format.h>\r
+#include <core/frame/pixel_format.h>\r
 #include <core/mixer/audio/audio_mixer.h>\r
 \r
+#include <array>\r
+\r
 enum PixelFormat;\r
 struct AVFrame;\r
 struct AVFormatContext;\r
@@ -34,17 +37,12 @@ struct AVPacket;
 struct AVRational;\r
 struct AVCodecContext;\r
 \r
-namespace caspar {\r
-\r
-namespace core {\r
+FORWARD2(caspar, core, struct pixel_format_desc);\r
+FORWARD2(caspar, core, class write_frame);\r
+FORWARD2(caspar, core, class data_frame);\r
+FORWARD2(caspar, core, class frame_factory);\r
 \r
-struct pixel_format_desc;\r
-class write_frame;\r
-struct frame_factory;\r
-\r
-}\r
-\r
-namespace ffmpeg {\r
+namespace caspar { namespace ffmpeg {\r
                \r
 std::shared_ptr<core::audio_buffer> flush_audio();\r
 std::shared_ptr<core::audio_buffer> empty_audio();\r
@@ -55,23 +53,37 @@ std::shared_ptr<AVFrame>                    empty_video();
 \r
 static const int CASPAR_PIX_FMT_LUMA = 10; // Just hijack some unual pixel format.\r
 \r
-core::field_mode::type         get_mode(const AVFrame& frame);\r
-int                                                    make_alpha_format(int format); // NOTE: Be careful about CASPAR_PIX_FMT_LUMA, change it to PIX_FMT_GRAY8 if you want to use the frame inside some ffmpeg function.\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, int hints);\r
+core::field_mode                                       get_mode(const AVFrame& frame);\r
+int                                                                    make_alpha_format(int format); // NOTE: Be careful about CASPAR_PIX_FMT_LUMA, change it to PIX_FMT_GRAY8 if you want to use the frame inside some ffmpeg function.\r
+spl::shared_ptr<core::write_frame>     make_write_frame(const void* tag, const spl::shared_ptr<AVFrame>& decoded_frame, double fps, const spl::shared_ptr<core::frame_factory>& frame_factory, int flags);\r
+spl::shared_ptr<AVFrame>                       make_av_frame(caspar::core::data_frame& frame);\r
+spl::shared_ptr<AVFrame>                       make_av_frame(std::array<void*, 4> data, const core::pixel_format_desc& pix_desc);\r
+\r
+template<typename C>\r
+std::shared_ptr<AVFrame> make_av_frame(const C& container, const core::pixel_format_desc& pix_desc)\r
+{      \r
+       std::array<void*, 4> data = {};\r
+       int n = 0;\r
+       for(auto it = std::begin(container); it != std::end(container); ++it)\r
+               data[n++] = (*it)->data();\r
+       return make_av_frame(data, pix_desc);\r
+}\r
+\r
+core::pixel_format_desc                                get_pixel_format_desc(PixelFormat pix_fmt, int width, int height);\r
 \r
-safe_ptr<AVPacket> create_packet();\r
+spl::shared_ptr<AVPacket> create_packet();\r
 \r
-safe_ptr<AVCodecContext> open_codec(AVFormatContext& context,  enum AVMediaType type, int& index);\r
-safe_ptr<AVFormatContext> open_input(const std::string& filename);\r
+spl::shared_ptr<AVCodecContext> open_codec(AVFormatContext& context,  enum AVMediaType type, int& index);\r
+spl::shared_ptr<AVFormatContext> open_input(const std::wstring& filename);\r
 \r
 bool is_sane_fps(AVRational time_base);\r
 AVRational fix_time_base(AVRational time_base);\r
 \r
 double read_fps(AVFormatContext& context, double fail_value);\r
 \r
-std::string print_mode(size_t width, size_t height, double fps, bool interlaced);\r
+std::wstring print_mode(int width, int height, double fps, bool interlaced);\r
 \r
-std::string probe_stem(const std::string stem);\r
-bool is_valid_file(const std::string filename);\r
+std::wstring probe_stem(const std::wstring stem);\r
+bool is_valid_file(const std::wstring filename);\r
 \r
 }}
\ No newline at end of file