Пример #1
0
static int
getNextNal(unsigned char *&inpf, unsigned char *inpf_end, unsigned char *inBuf)
{
    int inBuf_pos = 0;
    int StartCodeFound = 0;
    int info2 = 0;
    int info3 = 0;

    int nCount = 0;
    while ( inpf <= inpf_end &&++nCount <= 4)
    {
        inBuf[inBuf_pos++] = *inpf++;
    }

    if (!Check_StartCode(inBuf, inBuf_pos))
    {
        return 0;
    }


    //while (!feof(inpf) &&(inBuf[inBuf_pos++] = fgetc(inpf)) == 0);

    //find the next start code
    while (!StartCodeFound)
    {
        //end of file
        if (inpf>=inpf_end)
        {
            //			return -1;
            return inBuf_pos - 1;
        }
        inBuf[inBuf_pos++] = *inpf++;

        StartCodeFound = Check_StartCode(inBuf, inBuf_pos);
    }

    //fseek(inpf, -4, SEEK_CUR);
    inpf -= 4;

    // return the end(length) of this NALU
    return inBuf_pos - 4;
}
Пример #2
0
static int GetNextNal(FILE* pInFile, unsigned char* pBuf)  
{  
    int nPos   = 0;  
    int nCount = 0;  

    while (!feof(pInFile) && ++nCount <= 4) {  
        pBuf[nPos++] = fgetc(pInFile);  
    }  

    if (!Check_StartCode(pBuf, nPos)) {  
        return 0;  
    }  

    while (!feof(pInFile) && (pBuf[nPos++] = fgetc(pInFile)) == 0);

    bool bCheckNextByte  = false;
    bool bStartCodeFound = false;   

    while (!bStartCodeFound) {  
        if (feof(pInFile)) {  
            return nPos-1;  
        }

        pBuf[nPos++] = fgetc(pInFile);  
        if (bCheckNextByte) {
            if (pBuf[nPos-1] == 0x41 || pBuf[nPos-1] == 0x67) {
                bStartCodeFound = true;
                break;
            }
            else {
                bCheckNextByte = false;
            }
        }

        if (Check_StartCode(pBuf, nPos)) {
            bCheckNextByte = true;
        }
    }  

    fseek(pInFile, -5, SEEK_CUR);  
    return nPos - 5;  
}