]> git.sesse.net Git - casparcg/blob - modules/ffmpeg/producer/util/util.h
2.0.2 ffmpeg_producer: Fixed seeking for some files with invalid stream time_base...
[casparcg] / modules / ffmpeg / producer / util / util.h
1 #pragma once\r
2 \r
3 #include <common/memory/safe_ptr.h>\r
4 \r
5 #include <core/video_format.h>\r
6 #include <core/producer/frame/pixel_format.h>\r
7 #include <core/mixer/audio/audio_mixer.h>\r
8 \r
9 \r
10 #if defined(_MSC_VER)\r
11 #pragma warning (push)\r
12 #pragma warning (disable : 4244)\r
13 #endif\r
14 extern "C" \r
15 {\r
16         #include <libavutil/pixfmt.h>\r
17         #include <libavcodec/avcodec.h>\r
18 }\r
19 #if defined(_MSC_VER)\r
20 #pragma warning (pop)\r
21 #endif\r
22 \r
23 struct AVFrame;\r
24 struct AVFormatContext;\r
25 struct AVPacket;\r
26 \r
27 namespace caspar {\r
28 \r
29 namespace core {\r
30 \r
31 struct pixel_format_desc;\r
32 class write_frame;\r
33 struct frame_factory;\r
34 \r
35 }\r
36 \r
37 namespace ffmpeg {\r
38         \r
39         \r
40 safe_ptr<AVPacket> flush_packet();\r
41 std::shared_ptr<core::audio_buffer> flush_audio();\r
42 std::shared_ptr<core::audio_buffer> empty_audio();\r
43 std::shared_ptr<AVFrame>                        flush_video();\r
44 std::shared_ptr<AVFrame>                        empty_video();\r
45 \r
46 // Utils\r
47 \r
48 static const PixelFormat        CASPAR_PIX_FMT_LUMA = PIX_FMT_MONOBLACK; // Just hijack some unual pixel format.\r
49 \r
50 core::field_mode::type          get_mode(const AVFrame& frame);\r
51 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
52 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
53 \r
54 safe_ptr<AVPacket> create_packet();\r
55 \r
56 safe_ptr<AVCodecContext> open_codec(AVFormatContext& context,  enum AVMediaType type, int& index);\r
57 safe_ptr<AVFormatContext> open_input(const std::wstring& filename);\r
58 \r
59 bool is_sane_fps(AVRational time_base);\r
60 AVRational fix_time_base(AVRational time_base);\r
61 \r
62 //void av_dup_frame(AVFrame* frame);\r
63 \r
64 }}