-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqav.h
69 lines (60 loc) · 1.78 KB
/
qav.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* qpsnr (C) 2010-2020 E. Oriani, ema <AT> fastwebnet <DOT> it
*
* This file is part of qpsnr.
*
* qpsnr is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* qpsnr is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with qpsnr. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _QAV_H_
#define _QAV_H_
// libavcodec is a C library without C++ guards...
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
#include <string>
#include <vector>
namespace qav {
struct scr_size {
int x,
y;
scr_size(const int& _x = 0, const int& _y = 0) : x(_x), y(_y) {
}
inline friend bool operator==(const scr_size& lhs, const scr_size& rhs) {
return lhs.x==rhs.x && lhs.y==rhs.y;
}
};
class qvideo {
int frnum,
videoStream,
out_width,
out_height;
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame;
struct SwsContext *img_convert_ctx;
std::string fname;
void free_resources(void);
public:
qvideo(const char* file, int _out_width = -1, int _out_height = -1);
scr_size get_size(void) const;
int get_fps_k(void) const;
bool get_frame(std::vector<unsigned char>& out, int *_frnum = 0, const bool skip = false);
void save_frame(const unsigned char *buf, const char* __fname = 0);
~qvideo();
};
}
#endif /*_QAV_H_*/