-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoder.h
More file actions
52 lines (44 loc) · 1.41 KB
/
decoder.h
File metadata and controls
52 lines (44 loc) · 1.41 KB
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
#ifndef DECODER_H
#define DECODER_H
#include <string>
#include <atomic>
#include "safe_queue.h"
#include "media_objects.h"
extern "C"
{
#include <libavutil/hwcontext.h>
}
class decoder
{
public:
decoder() = default;
~decoder();
decoder(const decoder &) = delete;
decoder &operator=(const decoder &) = delete;
public:
bool open(const AVCodecParameters *par,
safe_queue<std::shared_ptr<media_packet>> *packet_queue,
safe_queue<std::shared_ptr<media_frame>> *frame_queue,
const std::string &name,
bool try_hardware_decode = true);
void run();
void stop();
[[nodiscard]] bool using_hardware_decode() const { return using_hw_decode_; }
private:
static AVPixelFormat get_hw_format(AVCodecContext *ctx, const AVPixelFormat *pix_fmts);
bool open_codec_context(bool try_hardware);
bool reopen_software_decoder();
void close_codec_context();
private:
std::string name_;
AVCodecContext *codec_ctx_ = nullptr;
AVCodecParameters *codec_par_ = nullptr;
safe_queue<std::shared_ptr<media_frame>> *frame_queue_ = nullptr;
safe_queue<std::shared_ptr<media_packet>> *packet_queue_ = nullptr;
AVPixelFormat hw_pix_fmt_ = AV_PIX_FMT_NONE;
AVHWDeviceType hw_device_type_ = AV_HWDEVICE_TYPE_NONE;
bool video_decoder_ = false;
bool using_hw_decode_ = false;
std::atomic<bool> aborted_{false};
};
#endif