資源簡介
需要下載分,是希望大家能夠更好的分享和使用本資源,畢竟上傳也不容易。希望得到理解。
其中包含了VS2010解決方案,使用其他版本VS的朋友可以修改工程文件。相關說明見原文:
http://blog.csdn.net/luofl1992/article/details/8293405
代碼片段和文件信息
#include?“stdafx.h“
#include?“NcMCodec.h“
extern?double?pts;
static?void?CodecInit(void)
{
static?bool?bInitialed(false);
if?(?true?==?bInitialed?)
return;
av_register_all();
}
/*
static?void?packet_queue_flush(PacketQueue?*q)
{
AVPacketList?*pkt?*pkt1;
SDL_LockMutex(q->mutex);
for(pkt?=?q->first_pkt;?pkt?!=?NULL;?pkt?=?pkt1)
{
pkt1?=?pkt->next;
av_free_packet(&pkt->pkt);
av_freep(&pkt);
}
q->last_pkt?=?NULL;
q->first_pkt?=?NULL;
q->nb_packets?=?0;
q->size?=?0;
SDL_UnlockMutex(q->mutex);
}
static?int?packet_queue_put(PacketQueue?*q?AVPacket?*pkt)?
{
AVPacketList?*pkt1;
if(pkt?!=?&flush_pkt?&&?av_dup_packet(pkt)?0)?{
return?-1;
}
if(packet_queue_get(&is->audioq?pkt?1)?0)?{
return?-1;
}
if(packet->data?==?flush_pkt.data)?{
avcodec_flush_buffers(is->audio_st->codec);
continue;
}
}
*/
CNcMCodec::CNcMCodec(void)
:?frameNo(0)
{
pFormatCtx?=?NULL;
pCodecCtx?=?NULL;
CodecInit();
}
CNcMCodec::~CNcMCodec(void)
{
}
bool?CNcMCodec::OpenFile(LPCTSTR?lpFilePath?BITMAPINFO?&bmpInfo)
{
char?path[MAX_PATH];
#ifdef?_UNICODE
USES_CONVERSION;
strcpy_s(?path?T2A(lpFilePath)?);
#else
strcpy_s(?path?lpFilePath?);
#endif
if?(?av_open_input_file(?&pFormatCtx?path?NULL?0?NULL??)?)
return?false; //?文件打開失敗
if?(?av_find_stream_info(pFormatCtx)?0?)
return?0; //?無法找到流信息
dump_format(?pFormatCtx?0?path?0?);
size_t?i?=?0;
videoStream?=?-1;
for?(?i?=?0;?i?nb_streams;?i++?)
{
if?(?pFormatCtx->streams[i]->codec->codec_type?==?CODEC_TYPE_VIDEO?)
{
videoStream?=?i;
break;
}
}
if?(?-1?==?videoStream?)
return?false;
pCodecCtx?=?pFormatCtx->streams[videoStream]->codec;
pCodec?=?avcodec_find_decoder(?pCodecCtx->codec_id?);
if?(?NULL?==?pCodec?)
return?false;
if?(?avcodec_open(pCodecCtx?pCodec)?0?)
return?false; //?無法打開解碼器
pframe?=?avcodec_alloc_frame();
pframeRGB?=?avcodec_alloc_frame();
if?(?NULL?==?pframe?)
return?false;
int?bytes?=?avpicture_get_size(PIX_FMT_RGB24?pCodecCtx->width?pCodecCtx->height);
void?*buffer?=?av_malloc(bytes?*?sizeof(uint8_t));
avpicture_fill(?(AVPicture?*)pframeRGB?(uint8_t?*)buffer?PIX_FMT_RGB24?pCodecCtx->width?pCodecCtx->height?);
// av_free(?buffer?);
//?設置位圖信息頭數據
BITMAPINFOHEADER?&infoHeader(bmpInfo.bmiHeader);
infoHeader.biBitCount?=?24;
infoHeader.biClrImportant?=?0;
infoHeader.biClrUsed?=?0;
infoHeader.biCompression?=?0;
infoHeader.biHeight?=?0?-?pCodecCtx->height; //?這里要是負數,否則圖像是倒著的
infoHeader.biWidth?=??pCodecCtx->width;
infoHeader.biPlanes?=?1;
infoHeader.biSize?=?40;
infoHeader.biSizeImage?=?0;
infoHeader.biXPelsPerMeter?=?0;
infoHeader.biYPelsPerMeter?=?0;
return?true;
}
AVPicture?*CNcMCodec::GetNextframe(void)
{
AVPacket?packet;
int?frameFinished?=?0;
//?Convert?the?image?from?its?native?format?to?RGB
/*
AVPacket?flush_pkt;
av_init_packet(&flus
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1915??2013-02-26?13:29??NcMPla
?????文件????7276032??2008-04-12?22:21??Bin\avcodec.dll
?????文件??????10752??2008-04-12?22:21??Bin\avdevice.dll
?????文件??????14336??2008-04-12?22:21??Bin\avfilter.dll
?????文件?????666624??2008-04-12?22:21??Bin\avformat.dll
?????文件??????57344??2008-04-12?22:21??Bin\avutil.dll
?????文件??????54542??2008-04-12?22:21??Bin\cws2fws.exe
?????文件??????83968??2008-04-12?22:21??Bin\ffmpeg.exe
?????文件??????38912??2008-04-12?22:21??Bin\ffplay.exe
?????文件?????456241??2012-12-13?09:11??Bin\libmp3lame-0.dll
?????文件??????80471??2008-04-12?22:21??Bin\output_example.exe
?????文件??????68936??2008-04-12?22:21??Bin\pktdumper.exe
?????文件??????89273??2008-02-16?17:18??Bin\pthreadGC2.dll
?????文件??????27762??2008-04-12?22:21??Bin\qt-faststart.exe
?????文件????1760356??2008-02-16?17:03??Bin\SDL.dll
?????文件?????158208??2008-04-12?22:21??Bin\swscale.dll
?????文件????6193066??2012-12-12?11:46??Bin\test.264
?????文件??????25267??2008-04-12?22:21??Bin\trasher.exe
?????文件?????742220??2008-03-02?20:40??Bin\xvidcore.dll
?????文件????7276032??2008-04-12?22:21??FFmpeg-full-SDK-3.2\bin\avcodec.dll
?????文件??????10752??2008-04-12?22:21??FFmpeg-full-SDK-3.2\bin\avdevice.dll
?????文件??????14336??2008-04-12?22:21??FFmpeg-full-SDK-3.2\bin\avfilter.dll
?????文件?????666624??2008-04-12?22:21??FFmpeg-full-SDK-3.2\bin\avformat.dll
?????文件??????57344??2008-04-12?22:21??FFmpeg-full-SDK-3.2\bin\avutil.dll
?????文件??????54542??2008-04-12?22:21??FFmpeg-full-SDK-3.2\bin\cws2fws.exe
?????文件??????83968??2008-04-12?22:21??FFmpeg-full-SDK-3.2\bin\ffmpeg.exe
?????文件??????38912??2008-04-12?22:21??FFmpeg-full-SDK-3.2\bin\ffplay.exe
?????文件??????80471??2008-04-12?22:21??FFmpeg-full-SDK-3.2\bin\output_example.exe
?????文件??????68936??2008-04-12?22:21??FFmpeg-full-SDK-3.2\bin\pktdumper.exe
?????文件??????89273??2008-02-16?17:18??FFmpeg-full-SDK-3.2\bin\pthreadGC2.dll
............此處省略164個文件信息
評論
共有 條評論