forked from edman007/chiton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_util.hpp
50 lines (43 loc) · 1.94 KB
/
image_util.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
44
45
46
47
48
49
50
#ifndef __IMAGE_UTIL_HPP__
#define __IMAGE_UTIL_HPP__
/**************************************************************************
*
* This file is part of Chiton.
*
* Chiton 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.
*
* Chiton 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 Chiton. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright 2020 Ed Martin <[email protected]>
*
**************************************************************************
*/
#include "chiton_config.hpp"
#include "chiton_ffmpeg.hpp"
#include "database.hpp"
class ImageUtil {
public:
ImageUtil(Database &db, Config &cfg);
~ImageUtil();
//write out the source coordinates as a jpeg
//name is a prefix, full path will be autogenerated based on arguments (date based if start_time is not null)
//if starttime and fileid is non-null, the database ID is written to file id
bool write_frame_jpg(const AVFrame *frame, std::string &name, const struct timeval *start_time = NULL, rect src = {-1, -1, 0, 0}, long *file_id = NULL);
bool write_frame_png(const AVFrame *frame, std::string &name, const struct timeval *start_time = NULL, rect src = {-1, -1, 0, 0}, long *file_id = NULL);
private:
Database &db;
Config &cfg;
//Returns a clone of the frame with the new rect applied
AVFrame* apply_rect(const AVFrame *frame, rect &src);
bool format_supported(const AVFrame *frame, const AVCodec *codec);//return true if the source is in a native format
};
#endif