HxNvr/HxIVA/HxDecoder.h

101 lines
2.4 KiB
C
Raw Normal View History

2024-01-30 18:59:29 +08:00
#ifndef HXDECODER_H
#define HXDECODER_H
#include "main.h"
class HxDecoder
{
public:
HxDecoder();
void initialization(void);
void initialization(AVFormatContext *ifmt_ctx);
void release(void);
void _decode(AVPacket *packet, cv::Mat *mat);
void decode(AVPacket *packet, cv::Mat *mat);
private:
#if USE_ALGORITHM
size_t mpp_buffer_group_usage(MppBufferGroup group);
bool convert_to_mat(MppBuffer mpp_buffer, RK_U32 width, RK_U32 height, cv::Mat *mat);
#endif
public:
bool status = false;
private:
MppCtx mpp_ctx;
MppApi *mpp_mpi;
size_t max_usage;
RK_U32 frame_count = 0, frame_num, eos;
/* 缓冲区管理器 */
MppBufferGroup mpp_frame_group;
uint8_t *video_out_buffer = nullptr;
struct SwsContext *video_sws_context = nullptr;
AVCodecContext *video_dec_ctx = nullptr;
AVFrame *video_dec_frame = nullptr, *video_picture_frame = nullptr;
};
#endif // HXDECODER_H
// #ifndef HXDECODER_H
// #define HXDECODER_H
// #include "main.h"
// class HxDecoder
// {
// public:
// HxDecoder();
// // #ifndef USE_ALGORITHM
// void initialization(AVFormatContext *ifmt_ctx);
// // #else
// // void initialization(void);
// // #endif
// void release(void);
// void decode(AVPacket *packet, VideoFrameDataInfo* pDstImageDataInfo);
// // private:
// // #if USE_ALGORITHM
// // size_t mpp_buffer_group_usage(MppBufferGroup group);
// // bool convert_to_mat(MppBuffer mpp_buffer, RK_U32 width, RK_U32 height, cv::Mat *mat);
// // #endif
// private:
// bool mv_convert_image(VideoFrameDataInfo* pSrcImageDataInfo, VideoFrameDataInfo* pDstImageDataInfo);
// public:
// bool status = false;
// private:
// // #if USE_ALGORITHM
// // MppCtx mpp_ctx;
// // MppApi *mpp_mpi;
// // size_t max_usage;
// // RK_U32 frame_count = 0, frame_num, eos;
// // /* 缓冲区管理器 */
// // MppBufferGroup mpp_frame_group;
// // #else
// VideoFrameDataInfo bgr_frame_buffer;
// uint8_t *video_out_buffer = nullptr;
// struct SwsContext *video_sws_context = nullptr;
// AVCodecContext *video_dec_ctx = nullptr;
// AVFrame *video_dec_frame = nullptr, *video_picture_frame = nullptr;
// // #endif
// };
// #endif // HXDECODER_H