資源簡介
vs2010 環境下pc端實時解碼h264碼流,調試測試通過,歡迎大家下載!
代碼片段和文件信息
#include?
#include?
#include?“stdafx.h“
#include?“Capture.h“
#include?“CaptureDlg.h“
#if?defined(WIN32)?&&?!defined(__cplusplus)
#define?inline?__inline
#endif
#ifdef?__cplusplus
?extern?“C“
?{
#endif
?
?#include?“libavcodec/avcodec.h“
?#include?“libavformat/avformat.h“
?#include?“libswscale/swscale.h“
?#include?“libavutil/avutil.h“
#ifdef?__cplusplus
?}
#endif
AVPacket?avpkt;
AVCodec*?codec;
AVCodecContext*?pCodecCtx;
AVCodecParserContext*?pCodecParserCtx;
AVframe *pframe?*pframeRGB;
struct?SwsContext*?pImgCtx;
uint8_t*?pRGBBuf;
int?RGBBufBytes;
AVPacket?avpkt1;
AVCodec*?codec1;
AVCodecContext*?pCodecCtx1;
AVCodecParserContext*?pCodecParserCtx1;
AVframe *pframe1?*pframeRGB1;
struct?SwsContext*?pImgCtx1;
uint8_t*?pRGBBuf1;
int?RGBBufBytes1;
#define SAVE_RGB 0
#if?SAVE_RGB
FILE?*fp_rgb;
char?filepath_rgb[]?=?“\\ch0.rgb“;
FILE?*fp_rgb1;
char?filepath_rgb1[]?=?“\\ch1.rgb“;
#endif
#define?TRACE??
int?init_h264_decode()
{
av_init_packet(&avpkt);
avcodec_register_all();
????codec?=?avcodec_find_decoder(AV_CODEC_ID_H264);
????if(!codec){
????????TRACE(“Codec?not?found\n“);
????????return?-1;
????}
????pCodecCtx?=?avcodec_alloc_context3(codec);
????if(!pCodecCtx){
????????TRACE(“Could?not?allocate?video?codec?context\n“);
????????return?-1;
????}
?
????pCodecParserCtx=av_parser_init(AV_CODEC_ID_H264);
????if?(!pCodecParserCtx){
????????TRACE(“Could?not?allocate?video?parser?context\n“);
????????return?-1;
????}
?????
????if(codec->capabilities&AV_CODEC_CAP_TRUNCATED)
????????pCodecCtx->flags|=?AV_CODEC_FLAG_TRUNCATED;?
?
????if?(avcodec_open2(pCodecCtx?codec?NULL)?0)?{
????????TRACE(“Could?not?open?codec\n“);
????????return?-1;
????}
????pframe?=?av_frame_alloc();
????pframeRGB?=?av_frame_alloc();
????if(!pframe?||?!pframeRGB){
????????TRACE(“Could?not?allocate?video?frame\n“);
????????return?-1;
????}
?
????RGBBufBytes?=?0;
????pRGBBuf?=?NULL;
????pImgCtx?=?NULL;
#if?SAVE_RGB
if(fp_rgb)
{
fclose?(fp_rgb);
fp_rgb?=?NULL;
}
fp_rgb?=?fopen(filepath_rgb?“wb“);
if?(!fp_rgb)?{
TRACE(“Could?not?open?output?RGB?file\n“);
return?-1;
}
#endif
? return?0;?
}
int?init_h264_decode1()
{
av_init_packet(&avpkt1);
avcodec_register_all();
????codec1?=?avcodec_find_decoder(AV_CODEC_ID_H264);
????if(!codec1){
????????TRACE(“Codec?not?found\n“);
????????return?-1;
????}
????pCodecCtx1?=?avcodec_alloc_context3(codec1);
????if(!pCodecCtx1){
????????TRACE(“Could?not?allocate?video?codec?context\n“);
????????return?-1;
????}
?
????pCodecParserCtx1=av_parser_init(AV_CODEC_ID_H264);
????if?(!pCodecParserCtx1){
????????TRACE(“Could?not?allocate?video?parser?context\n“);
????????return?-1;
????}
?????
????if(codec1->capabilities&AV_CODEC_CAP_TRUNCATED)
????????pCodecCtx1->flags|=?AV_CODEC_FLAG_TRUNCATED;?
?
????if?(avcodec_open2(pCodecCtx1?codec1?NULL)?0)?{
????????TRACE(
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????617273??2019-01-22?17:04??ffmpeg實時解碼h264碼流\ffmpeg-4.1-win32-dev.zip
?????文件???20671077??2019-01-22?17:03??ffmpeg實時解碼h264碼流\ffmpeg-4.1-win32-shared.zip
?????文件???????9815??2019-01-28?13:31??ffmpeg實時解碼h264碼流\xm_h264_decoder.cpp
?????目錄??????????0??2019-01-30?10:25??ffmpeg實時解碼h264碼流
-----------?---------??----------?-----??----
?????????????21298165????????????????????4
- 上一篇:西門子PLC工程實習
- 下一篇:精倫電子開發包最新開發包帶網頁插件
評論
共有 條評論