//硬件H264 ffmpeg解码 #ifndef _HARDDECODE_H #define _HARDDECODE_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif #include #include #include #include #include #include #include #include #include #include #include #ifdef __cplusplus }; #endif #define DUMP_FRAME(frame) { \ printf( "%s-%d AVFrame:format=%2d, key_frame=%d, pict_type=%d, width=%4d, height=%4d, data=(%d, %d, %d), linesize=(%4d, %4d, %4d)\n", \ __func__, __LINE__, \ frame->format, frame->key_frame, frame->pict_type, \ frame->width, frame->height, \ (frame->data[0] != NULL), \ (frame->data[1] != NULL), \ (frame->data[2] != NULL),\ frame->linesize[0], \ frame->linesize[1], \ frame->linesize[2] \ );} #define NVIDIA_H264_DECODER "h264_cuvid" // #define NVIDIA_H264_DECODER "h264_v4l2m2m" #include "Log.h" class HardDecode { public: HardDecode(); ~HardDecode(); int hardDecoderInit(unsigned int uiWidth, unsigned int uiHeight, unsigned int uiFrameRate = 30, AVCodecParameters *pCodecParameters = nullptr); int hardDecoderDeInit(); int hardDecoder(void* pOutputData, unsigned int* puiOutputDataSize); const AVCodec *pCodec_ = nullptr; //解码器 AVCodecContext *pCodecCtx_ = nullptr; //上下文 AVCodecParserContext *pCodecParserCtx_ = nullptr; //解析器上下文 AVFrame *pSrcFrame_ = nullptr; AVFrame *pDstFrame_ = nullptr; AVPacket *pPacket_ = nullptr; SwsContext *pSwsContext_ = nullptr; uint8_t *outBuffer_ = nullptr; private: unsigned int uiWidth_, uiHeight_; unsigned int uiFrameRate_; AVCodecParameters *pCodecParameters_ = nullptr; }; #endif