问题已解决。参照
SDK_DIR/buildroot/package/auto下有sdk_demo。
SDK_DIR下执行.buildconfig后,执行./buildroot/package/auto/build.sh可以编译demo。
但是demo上的解码器如指导文档所说,解码出图滞后。所以解单帧h264时,demo不会出图。建议参照demo里的stopAndGetLeftFrame函数做修改,把滞后的图像取出。测试可行。
int stopAndGetLeftFrame()
{
int nRet;
int leftFrame = VideoStreamFrameNum(pVideoDec, 0);
ALOGD("VideoStreamFrameNum:%d", leftFrame);
if (leftFrame > 0) {
int waitLoop = 0;
while (leftFrame > 0) {
nRet = DecodeVideoStream(pVideoDec,
1 /*eos*/,
0/*key frame only*/,
0/*drop b frame*/,
0/*current time*/);
ALOGD("DecodeVideoStream:%d", nRet);
if ((nRet == VDECODE_RESULT_NO_FRAME_BUFFER) ||
(nRet == VDECODE_RESULT_NO_BITSTREAM)) {
break;
}
usleep(200);
waitLoop++;
leftFrame--;
if (waitLoop > 50) {
ALOGW("decode eos time out > 10 ms!");
break;
}
}
} else {
ALOGD("There is no left fream to decode!");
}
int nValidPicNum = ValidPictureNum(pVideoDec, 0);
ALOGD("ValidPictureNum:%d", nValidPicNum);
if (nValidPicNum <= 0) {
nRet = -2;
ALOGW("nValidPicNum:%d, no pic left.", nValidPicNum);
return nRet;
}
while(nValidPicNum > 0) {
pPicture = RequestPicture(pVideoDec, 0/*the major stream*/); //VdecH264:step6
if (pPicture != NULL) {
AVPacket outPacket;
outPacket.id = pPicture->nID;
outPacket.pts = pPicture->nPts;
outPacket.pAddrPhy0 = (unsigned char*)pPicture->phyYBufAddr;
outPacket.pAddrVir0 = (unsigned char*)pPicture->pData0;
outPacket.dataLen0 = pPicture->nWidth * pPicture->nHeight;
outPacket.pAddrPhy1 = (unsigned char*)pPicture->phyCBufAddr;
outPacket.pAddrVir1 = (unsigned char*)pPicture->pData1;
outPacket.dataLen1 = outPacket.dataLen0 / 2;
if (NULL != mDataCbk) {
mDataCbk->decoderDataReady(&outPacket);
}
ReturnPicture(pVideoDec, pPicture);
nValidPicNum--;
} else {
ALOGW("pPicture == NULL.");
return -2;
}
}
return nRet;
}