Exemplo n.º 1
0
mfxStatus AVC_Spl::GetFrame(mfxBitstream * bs_in, FrameSplitterInfo ** frame)
{
    *frame = 0;

    do
    {
        if (m_pLastSlice)
        {
            AVCSlice * pSlice = m_pLastSlice;
            mfxStatus sts = AddSlice(pSlice);
            AddSliceNalUnit(m_lastNalUnit, pSlice);
            m_lastNalUnit = 0;
            if (sts == MFX_ERR_NONE)
                return MFX_ERR_NONE;
        }

        mfxBitstream * destination;
        mfxI32 nalType = m_pNALSplitter->GetNalUnits(bs_in, destination);
        mfxStatus sts = ProcessNalUnit(nalType, destination);

        if (sts == MFX_ERR_NONE || (!bs_in && m_frame.SliceNum))
        {
            m_currentInfo = 0;
            *frame = &m_frame;
            return MFX_ERR_NONE;
        }

    } while (bs_in && bs_in->DataLength > MINIMAL_DATA_SIZE);

    return MFX_ERR_MORE_DATA;
}
Exemplo n.º 2
0
mfxStatus AVC_Spl::ProcessNalUnit(mfxI32 nalType, mfxBitstream * nalUnit)
{
    if (!nalUnit)
        return MFX_ERR_MORE_DATA;

    switch (nalType)
    {
    case NAL_UT_IDR_SLICE:
    case NAL_UT_SLICE:
    case NAL_UT_CODED_SLICE_EXTENSION:
        {
            AVCSlice * pSlice = DecodeSliceHeader(nalUnit);
            if (pSlice)
            {
                mfxStatus sts = AddSlice(pSlice);
                if (sts == MFX_ERR_NOT_ENOUGH_BUFFER)
                {
                    return sts;
                }

                if (!m_pLastSlice)
                {
                    AddSliceNalUnit(nalUnit, pSlice);
                }
                else
                {
                    m_lastNalUnit = nalUnit;
                }

                if (sts == MFX_ERR_NONE)
                {
                    return sts;
                }
            }
        }
        break;

    case NAL_UT_SPS:
    case NAL_UT_PPS:
    case NAL_UT_SPS_EX:
    case NAL_UNIT_SUBSET_SPS:
    case NAL_UNIT_PREFIX:
        DecodeHeader(nalUnit);
        AddNalUnit(nalUnit);
        break;

    case NAL_UT_SEI:
        DecodeSEI(nalUnit);
        AddNalUnit(nalUnit);
        break;
    case NAL_UT_AUD:
        AddNalUnit(nalUnit);
        break;

    case NAL_UT_DPA:
    case NAL_UT_DPB:
    case NAL_UT_DPC:
    case NAL_UT_FD:
    case NAL_UT_UNSPECIFIED:
        break;

    case NAL_END_OF_STREAM:
    case NAL_END_OF_SEQ:
        {
            AddNalUnit(nalUnit);
        }
        break;

    default:
        break;
    };

    return MFX_ERR_MORE_DATA;
}
Exemplo n.º 3
0
void C4Shader::AddFragmentSlice(int iPos, const char *szText, const char *szSource, int iSourceTime)
{
	AddSlice(FragmentSlices, iPos, szText, szSource, iSourceTime);
}
Exemplo n.º 4
0
void C4Shader::AddSlices(ShaderSliceList& slices, const char *szWhat, const char *szText, const char *szSource, int iSourceTime)
{
	const char *pStart = szText, *pPos = szText;
	int iDepth = -1;
	int iPosition = -1;
	bool fGotContent = false; // Anything in the slice apart from comments and white-space?

	// Find slices
	while(*pPos) {

		// Comment? Might seem silly, but we don't want to get confused by braces in comments...
		if (*pPos == '/' && *(pPos + 1) == '/') {
			pPos += 2;
			while (*pPos && *pPos != '\n') pPos++;
			continue;
		}
		if (*pPos == '/' && *(pPos + 1) == '*') {
			pPos += 2;
			while (*pPos && (*pPos != '*' || *(pPos+1) != '/')) pPos++;
			if (*pPos) pPos += 2;
			continue;
		}

		// Opening brace?
		if (*pPos == '{') {
			iDepth++; pPos++;
			continue;
		}
		if (*pPos == '}') {
			// End of slice?
			if (iPosition != -1 && !iDepth) {

				// Have a new slice!
				if (fGotContent)
				{
					StdStrBuf Str; Str.Copy(pStart, pPos - pStart);
					AddSlice(slices, iPosition, Str.getData(), szSource, iSourceTime);
				}

				iPosition = -1;
				pStart = pPos+1;
				fGotContent = false;
			}
			if (iDepth >= 0)
				iDepth--;
			pPos++;
			continue;
		}

		// New slice? We need a newline followed by "slice". Don't do
		// the depth check, so that we also recognize slices inside
		// an ifdefed-out "void main() {" block.
		if (*pPos == '\n') {
			if (SEqual2(pPos+1, "slice") && !isalnum(*(pPos+6))) {
				const char *pSliceEnd = pPos; pPos += 6;
				while(isspace(*pPos)) pPos++;
				if(*pPos != '(') { pPos++; continue; }
				pPos++;

				// Now let's parse the position
				iPosition = ParsePosition(szWhat, &pPos);
				if (iPosition != -1) {
					// Make sure a closing parenthesis
					while(isspace(*pPos)) pPos++;
					if(*pPos != ')') { pPos++; continue; }
					pPos++;

					// Make sure an opening brace follows
					while(isspace(*pPos)) pPos++;
					if (*pPos == '{') {

						// Add code before "slice" as new slice
						if (fGotContent)
						{
							StdStrBuf Str; Str.Copy(pStart, pSliceEnd - pStart);
							AddSlice(slices, -1, Str.getData(), szSource, iSourceTime);
						}

						iDepth = 0;
						pStart = pPos+1;
						fGotContent = false;
					} else {
						ShaderLogF("  gl: Missing opening brace in %s!", szWhat);
					}
					pPos++;
					continue;
				}
			}
		}

		// Otherwise: Continue
		if (!isspace(*pPos)) fGotContent = true;
		pPos++;
	}

	// Add final slice
	if (fGotContent)
	{
		StdStrBuf Str; Str.Copy(pStart, pPos - pStart);
		AddSlice(slices, iPosition, Str.getData(), szSource, iSourceTime);
	}

}
Exemplo n.º 5
0
void C4Shader::AddVertexSlice(int iPos, const char *szText)
{
	AddSlice(VertexSlices, iPos, szText, NULL, 0);
}