代码修改
如下函数,是从文件中获取特定的数据保存到Buf,如何修改成从一个缓冲区(char inBuf[])中获取数据保存到Buf?int getNextNal(FILE* inpf, unsigned char* Buf)
{
int pos = 0;
int StartCodeFound = 0;
int info2 = 0;
int info3 = 0;
while(!feof(inpf) && (Buf[pos++]=fgetc(inpf))==0);
while (!StartCodeFound)
{
if (feof (inpf))
{
return pos-1;
}
Buf[pos++] = fgetc (inpf);
info3 = FindStartCode(&Buf[pos-4], 3);
if(info3 != 1)
info2 = FindStartCode(&Buf[pos-3], 2);
StartCodeFound = (info2 == 1 || info3 == 1);
}
fseek (inpf, -4, SEEK_CUR);
return pos - 4;
}