为何 mingw 跨平台编译 linux 原生 C 代码程序进行单步调试输出结果完全跟直接执行完全不同? 调用了一个外部 dll 的 openh264.dll ,执行后无数据输出,dbg 单步调试不过,哪位高人帮忙改下代码,非软件专业实在感觉编写吃力
#include<stdio.h> #include<stdlib.h> #include<stdint.h> #include<string.h> #include<wels/codec_api.h> int WinMain(){ int width=176; int height=144; int inputwidth=width; int inputheight=height; size_t yuvsize=inputwidth*inputheight*3/2; FILE*FSoucre=fopen("source.yuv","rb"); FILE*FSink=fopen("output.264","wb"); ISVCEncoder*pEncoder=NULL; SEncParamBase param; SFrameBSInfo info; SSourcePicture pic; int i=0; int ret=0; char*buffer=(char*)malloc(yuvsize); memset (¶m, 0, sizeof (SEncParamBase)); memset (&info, 0, sizeof (SFrameBSInfo)); memset (&pic, 0, sizeof (SSourcePicture)); ret=WelsCreateSVCEncoder(&pEncoder); printf("WelsCreateSVCEncoder:%d\n",ret); param.iPicHeight=inputheight; param.iPicWidth=inputwidth; param.fMaxFrameRate=25; param.iUsageType=CAMERA_VIDEO_REAL_TIME; param.iTargetBitrate = 1000000; ret=(*pEncoder)->Initialize(pEncoder,¶m); printf("Initialize:%d\n",ret); do{ int videoFormat = videoFormatI420; (*pEncoder)->SetOption (pEncoder,ENCODER_OPTION_DATAFORMAT, &videoFormat); }while(0); pic.iPicWidth = width; pic.iPicHeight = height; pic.iColorFormat = videoFormatI420; pic.iStride[0] = pic.iPicWidth; pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1; pic.pData[0] = buffer; pic.pData[1] = pic.pData[0] + width * height; pic.pData[2] = pic.pData[1] + (width * height >> 2); while(fread(buffer,1,yuvsize,FSoucre)==yuvsize){ pic.uiTimeStamp=40*i; i++; (*pEncoder)->EncodeFrame (pEncoder,&pic, &info); if (info.eFrameType != videoFrameTypeSkip) { //output bitstream int iLayerNum=0; while(iLayerNum<info.iLayerNum){ int iNalCount=0; int pos=0; while (iNalCount<info.sLayerInfo[iLayerNum].iNalCount){ #if 0 printf("I:%d LayerNum:%d(%d) Size:%d Type:%d NalCount:%d(%d) NalSize:%d\n",i, iLayerNum,info.iLayerNum,info.iFrameSizeInBytes, info.sLayerInfo[iLayerNum].eFrameType, iNalCount,info.sLayerInfo[iLayerNum].iNalCount,info.sLayerInfo[iLayerNum].pNalLengthInByte[iNalCount]); #endif fwrite(info.sLayerInfo[iLayerNum].pBsBuf+pos,1,info.sLayerInfo[iLayerNum].pNalLengthInByte[iNalCount],FSink); pos+=info.sLayerInfo[iLayerNum].pNalLengthInByte[iNalCount]; iNalCount++; } iLayerNum++; } } } (*pEncoder)->Uninitialize(pEncoder); WelsDestroySVCEncoder(pEncoder); fclose(FSoucre); fclose(FSink); return 0; } 