-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathavutils.hpp
43 lines (30 loc) · 1.27 KB
/
avutils.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef AVUTILS_HPP_L0JIDQTW
#define AVUTILS_HPP_L0JIDQTW
#include <opencv2/core.hpp>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/imgutils.h>
#include <libavutil/opt.h>
#include <libswscale/swscale.h>
}
constexpr int KB = 1024;
namespace avutils {
std::string av_strerror2(int errnum);
int initialize_avformat_context(AVFormatContext *&fctx,
AVOutputFormat *format = nullptr,
const char *out_file = nullptr);
void set_codec_params(AVCodecContext *&codec_ctx, double width, double height,
int fps, int target_bitrate = 0, int gop_size = 12);
int initialize_codec_stream(AVStream *&stream, AVCodecContext *&codec_ctx,
AVCodec *&codec);
SwsContext *initialize_sample_scaler(AVCodecContext *codec_ctx, double width,
double height);
AVFrame *allocate_frame_buffer(AVCodecContext *codec_ctx, double width,
double height);
int write_frame(AVCodecContext *codec_ctx, AVFormatContext *fmt_ctx,
AVFrame *frame);
void generatePattern(cv::Mat &image, unsigned char i);
cv::Mat avframeYUV402p2Mat(const AVFrame *frame);
} // namespace avutils
#endif