-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathh264_decoder.hpp
More file actions
46 lines (34 loc) · 974 Bytes
/
h264_decoder.hpp
File metadata and controls
46 lines (34 loc) · 974 Bytes
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
//
// Created by pengx on 2026/2/9.
//
#ifndef GB28181_H264_DECODER_HPP
#define GB28181_H264_DECODER_HPP
#include <QObject>
#include <vector>
#include <opencv2/core/mat.hpp>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/frame.h>
#include <libswscale/swscale.h>
}
class H264Decoder final : public QObject {
Q_OBJECT
public:
explicit H264Decoder(QObject* parent = nullptr);
~H264Decoder() override;
public slots:
// 解码H.264数据为cv::Mat帧
void decodeH264Data(const std::vector<uint8_t>& h264Data, uint32_t pts);
signals:
// 解码后的帧数据
void frameDecoded(const cv::Mat& frame);
private:
// ffmpeg库内部有指针管理,无需智能指针
AVCodecContext* _codecContextPtr = nullptr;
AVFrame* _framePtr = nullptr;
AVPacket* _packetPtr = nullptr;
SwsContext* _swsContextPtr = nullptr;
bool initializeDecoder();
void cleanupDecoder();
};
#endif //GB28181_H264_DECODER_HPP