]> git.sesse.net Git - casparcg/blob - modules/ffmpeg/producer/util/util.h
2.0.2: - Updated get_param.
[casparcg] / modules / ffmpeg / producer / util / util.h
1 /*\r
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 * This file is part of CasparCG (www.casparcg.com).\r
5 *\r
6 * CasparCG is free software: you can redistribute it and/or modify\r
7 * it under the terms of the GNU General Public License as published by\r
8 * the Free Software Foundation, either version 3 of the License, or\r
9 * (at your option) any later version.\r
10 *\r
11 * CasparCG is distributed in the hope that it will be useful,\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 * GNU General Public License for more details.\r
15 *\r
16 * You should have received a copy of the GNU General Public License\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 * Author: Robert Nagy, ronag89@gmail.com\r
20 */\r
21 \r
22 #pragma once\r
23 \r
24 #include <common/memory/safe_ptr.h>\r
25 \r
26 #include <core/video_format.h>\r
27 #include <core/producer/frame/pixel_format.h>\r
28 #include <core/mixer/audio/audio_mixer.h>\r
29 \r
30 enum PixelFormat;\r
31 struct AVFrame;\r
32 struct AVFormatContext;\r
33 struct AVPacket;\r
34 struct AVRational;\r
35 struct AVCodecContext;\r
36 \r
37 namespace caspar {\r
38 \r
39 namespace core {\r
40 \r
41 struct pixel_format_desc;\r
42 class write_frame;\r
43 struct frame_factory;\r
44 \r
45 }\r
46 \r
47 namespace ffmpeg {\r
48                 \r
49 std::shared_ptr<core::audio_buffer> flush_audio();\r
50 std::shared_ptr<core::audio_buffer> empty_audio();\r
51 std::shared_ptr<AVFrame>                        flush_video();\r
52 std::shared_ptr<AVFrame>                        empty_video();\r
53 \r
54 // Utils\r
55 \r
56 static const int CASPAR_PIX_FMT_LUMA = 10; // Just hijack some unual pixel format.\r
57 \r
58 core::field_mode::type          get_mode(const AVFrame& frame);\r
59 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
60 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
61 \r
62 safe_ptr<AVPacket> create_packet();\r
63 \r
64 safe_ptr<AVCodecContext> open_codec(AVFormatContext& context,  enum AVMediaType type, int& index);\r
65 safe_ptr<AVFormatContext> open_input(const std::wstring& filename);\r
66 \r
67 bool is_sane_fps(AVRational time_base);\r
68 AVRational fix_time_base(AVRational time_base);\r
69 \r
70 double read_fps(AVFormatContext& context, double fail_value);\r
71 \r
72 std::wstring print_mode(size_t width, size_t height, double fps, bool interlaced);\r
73 \r
74 std::wstring probe_stem(const std::wstring stem);\r
75 bool is_valid_file(const std::wstring filename);\r
76 \r
77 }}