資源簡介
博客附件
ffmpeg快速解碼,超快打開rtsp的封裝 。附件包含源代碼的實現。
演示例子exe可見 SDK播放器加速\x64\Player64 瞬間打開CCTV
代碼片段和文件信息
#include?“stdafx.h“
#include?“CPlayer.h“
CGdiPlay::CGdiPlay(void)?:bStateFlag(false)
?pbit(NULL)
?hBitmap(NULL)
?out_bufRgb(NULL)
?m_hWnd(NULL)
{
????memset(&bmp?0?sizeof(BITMAP));
????memset(&screenRect?0?sizeof(RECT));
????memset(&rc?0?sizeof(RECT));
????packet?=?av_packet_alloc();
????pframe?=?av_frame_alloc();
????pframeRGB?=?av_frame_alloc();
}
CGdiPlay::CGdiPlay(HWND?_hWnd)?:bStateFlag(false)
?pbit(NULL)
?hBitmap(NULL)
?out_bufRgb(NULL)
?m_hWnd(_hWnd)
{
}
CGdiPlay::~CGdiPlay(void)
{
}
int?CGdiPlay::run()
{
????hdcDes?=?GetDC(m_hWnd);
????hdcSrc?=?CreateCompatibleDC(hdcDes);
????packet?=?av_packet_alloc();
????CalcVideoWH(m_hWnd);
????::CoInitialize(NULL);
????while?(bStateFlag)
????{
????????if?(packet?==?NULL)
????????{
????????????packet?=?av_packet_alloc();
????????????av_usleep(20?*?1000);
????????????continue;
????????}
????????if?(av_read_frame(pFormatCtx?packet)?>=?0)
????????{
????????????if?(packet->stream_index?==?vindex)
????????????{
????????????????//下面處理size
????????????????GetClientRect(m_hWnd?&rc);
????????????????if?(rc.left?!=?screenRect.left?||?rc.right?!=?screenRect.right?||?rc.top?!=?screenRect.top?||?rc.bottom?!=?screenRect.bottom)
????????????????????CalcVideoWH(m_hWnd);
????????????????if?(avcodec_send_packet(pCodecCtx?packet)?==?0)
????????????????{
????????????????????if?(avcodec_receive_frame(pCodecCtx?pframe)?==?0)
????????????????????{
????????????????????????sws_scale(img_convert_ctx?(const?unsigned?char*?const*)pframe->data?pframe->linesize?0?pCodecCtx->height
????????????????????????????pframeRGB->data?pframeRGB->linesize);
????????????????????????hBitmap?=?CreateDIBSection(hdcSrc?&bmpinfo?DIB_RGB_COLORS?&pbit?NULL?0);
????????????????????????Getobject(hBitmap?sizeof(BITMAP)?&bmp);
????????????????????????memcpy(pbit?out_bufRgb?(sW)*?(sH)?*?4);
????????????????????????Selectobject(hdcSrc?hBitmap);
????????????????????????BitBlt(hdcDes?0?0?sW?sH?hdcSrc?0?0?SRCCOPY);
????????????????????????Deleteobject(hBitmap);
????????????????????????av_usleep(40?*?1000);
????????????????????}
????????????????????else
????????????????????????continue;
????????????????}
????????????????else
????????????????????break;
????????????}
????????}
????????av_packet_unref(packet);
????}
????avformat_close_input(&pFormatCtx);
????av_packet_unref(packet);
????::CoUninitialize();
????return?0;
}
int?CGdiPlay::play(string?filepath)
{
????if?(bStateFlag)
????????stop();
????av_register_all();
????pFormatCtx?=?avformat_alloc_context();
????if?(avformat_open_input(&pFormatCtx?filepath.c_str()?NULL?NULL)?0)
????????return?0;
????//很卡
????//if?(avformat_find_stream_info(pFormatCtx?NULL)?0)
????//????return?0;
????for?(int?i?=?0;?i?(int)pFormatCtx->nb_streams;?i++)
????{
????????if?(pFormatCtx->streams[i]->codecpar->codec_type?==?AVMEDIA_TYPE_VIDEO)
????????????vindex?=?i;
????????if?(
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2020-05-27?14:01??SDK播放器加速\
?????文件????????4971??2020-03-16?17:55??SDK播放器加速\CPla
?????文件?????????971??2020-03-16?17:41??SDK播放器加速\CPla
?????目錄???????????0??2020-05-27?14:01??SDK播放器加速\include\
?????文件?????????494??2020-03-16?17:45??SDK播放器加速\include\rtspinc.h
?????文件????????1073??2020-03-13?09:21??SDK播放器加速\include\rtspinc_def.h
?????目錄???????????0??2020-05-27?14:01??SDK播放器加速\x64\
?????文件?????????448??2020-03-16?17:53??SDK播放器加速\x64\Pla
?????文件??????605184??2020-03-16?18:16??SDK播放器加速\x64\Pla
?????文件???????16410??2020-03-13?09:41??SDK播放器加速\x64\RTSP.lib
?????文件????46346752??2020-03-13?09:41??SDK播放器加速\x64\RTSP64.so
?????文件?????3457640??2020-03-13?09:40??SDK播放器加速\x64\RTSP_static.lib
?????目錄???????????0??2020-05-27?14:01??SDK播放器加速\x86\
?????文件???????15870??2020-03-13?09:42??SDK播放器加速\x86\RTSP.lib
?????文件????29331456??2020-03-13?09:42??SDK播放器加速\x86\RTSP.so
?????文件?????3226006??2020-03-13?09:23??SDK播放器加速\x86\RTSP_static.lib
- 上一篇:《設計模式》--劉偉 PPT課件+代碼
- 下一篇:概率論與數理統計陳希孺.pdf
評論
共有 條評論