-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcdecodehelper.cpp
More file actions
38 lines (32 loc) · 832 Bytes
/
cdecodehelper.cpp
File metadata and controls
38 lines (32 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "cdecodehelper.h"
#include <iostream>
CDecodeHelper::CDecodeHelper(AVCodecContext *pAVCodecCtx) : m_pAVCodecCtx(pAVCodecCtx)
{
}
bool CDecodeHelper::Decode(AVPacket* pAVPacket, AVFrame* pFrame)
{
bool bRet = false;
std::cout << "before decode. " << std::endl;
if ( 0 != avcodec_send_packet(m_pAVCodecCtx, pAVPacket) )
{
std::cerr << "avcodec_send_packet failed. "<< std::endl;
bRet = false;
}
//获取编码结果保存到输出流
int iRet = 0;
iRet = avcodec_receive_frame(m_pAVCodecCtx, pFrame);
switch(iRet)
{
case 0:
bRet = true;
break;
case AVERROR(EAGAIN):
bRet = false;
break;
default:
std::cout << "avcodec_receive_frame error."<< std::endl;
bRet = false;
break;
}
return bRet;
}