H.264——C++实现了图像的编码功能

Home / C++ MrLee 2015-12-30 3338

H.264,同时也是MPEG-4第十部分,是由ITU-T视频编码专家组(VCEG)和ISO/IEC动态图像专家组(MPEG)联合组成的联合视频组(JVT,Joint Video Team)提出的高度压缩数字视频编解码器标准。这个标准通常被称之为H.264/AVC(或者AVC/H.264或者H.264/MPEG-4 AVC或MPEG-4/H.264 AVC)而明确的说明它两方面的开发者。 H264标准各主要部分有Access Unit delimiter(访问单元分割符),SEI(附加增强信息),primary coded picture(基本图像编码),Redundant Coded Picture(冗余图像编码)。还有Instantaneous Decoding Refresh(IDR,即时解码刷新)、Hypothetical Reference Decoder(HRD,假想参考解码)、Hypothetical Stream Scheduler(HSS,假想码流调度器)
只贴出部分源码,需要在末尾下载。
// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the ENCODER264_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// ENCODER264_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef ENCODER264_EXPORTS
#define ENCODER264_API __declspec(dllexport)
#else
#define ENCODER264_API __declspec(dllimport)
#endif
// This class is exported from the Encoder264.dll
class ENCODER264_API CEncoder264 {
public:
	CEncoder264(void);
	// TODO: add your methods here.
};
extern ENCODER264_API int nEncoder264;
ENCODER264_API int fnEncoder264(void);
//压缩完成事件
typedef int (* En_CompressEndHandler_t)(unsigned char* outBuf,int size);
//错误事件
typedef int (* En_CompressErrHandler_t)(int errNo);
extern "C" ENCODER264_API int En_Init();							//初始化
extern "C" ENCODER264_API int En_Exit();							//退出
extern "C" ENCODER264_API int En_SetDeFilter(bool bFilter);			//是否去块效应过滤器
extern "C" ENCODER264_API int En_SetDeSave(bool bDeSave);			//是否解码存储
extern "C" ENCODER264_API int En_SetHadama(bool bHadama);			//是否哈德码变换
extern "C" ENCODER264_API int En_SetFormat(int format);				//图形格式,0 QCIF,1 CIF
extern "C" ENCODER264_API int En_SetDrop(int dropNum);				//跳帧设置
extern "C" ENCODER264_API int En_SetSearchRange(int range);			//设置搜索范围
extern "C" ENCODER264_API int En_SetQP(int qp);						//设置量化参数,默认28
extern "C" ENCODER264_API int En_SetForce(int force);				//设置强制更新帧间隔
extern "C" ENCODER264_API int En_SetDisplay(bool b);					//压缩时是否显示
extern "C" ENCODER264_API int En_StartSaveEncoder(char *saveFile);		//开启存储264流
extern "C" ENCODER264_API int En_StopSaveEncoder();						//停止存储264流

extern "C" ENCODER264_API int En_SetCompressIn(char *InBuf);		//设置原始图像缓冲区
//extern ENCODER264_API int En_SetCompressOut(char *OutBuf);		//设置压缩图像压缩后缓冲区
extern "C" ENCODER264_API int En_StartEncoder(void);				//开始压缩
extern "C" ENCODER264_API int En_StopEncoder(void);					//停止压缩
extern "C" ENCODER264_API int En_RegCompressHandler(En_CompressEndHandler_t compressHandler);//注册压缩完成后事件处理函数
extern "C" ENCODER264_API int En_RegErrHandler(En_CompressErrHandler_t CompressErrHandler);//注册错误事件处理函数

有一个.lib库直接加载即可使用。源码比较早,不过很有参考的价值。
下载地址: Encoder

本文链接:https://www.it72.com/7418.htm

推荐阅读
最新回复 (0)
返回