当前位置: 首页>>代码示例>>C++>>正文


C++ CGolombBuffer::RemainingSize方法代码示例

本文整理汇总了C++中CGolombBuffer::RemainingSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CGolombBuffer::RemainingSize方法的具体用法?C++ CGolombBuffer::RemainingSize怎么用?C++ CGolombBuffer::RemainingSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGolombBuffer的用法示例。


在下文中一共展示了CGolombBuffer::RemainingSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ParseSample

HRESULT CDVBSub::ParseSample (IMediaSample* pSample)
{
    CheckPointer (pSample, E_POINTER);
    HRESULT				hr;
    BYTE*				pData = NULL;
    int					nSize;
    DVB_SEGMENT_TYPE	nCurSegment;

    hr = pSample->GetPointer(&pData);
    if(FAILED(hr) || pData == NULL) {
        return hr;
    }
    nSize = pSample->GetActualDataLength();

    if (*((LONG*)pData) == 0xBD010000) {
        CGolombBuffer	gb (pData, nSize);

        gb.SkipBytes(4);
        WORD	wLength	= (WORD)gb.BitRead(16);
        UNUSED_ALWAYS(wLength);

        if (gb.BitRead(2) != 2) {
            return E_FAIL;    // type
        }

        gb.BitRead(2);		// scrambling
        gb.BitRead(1);		// priority
        gb.BitRead(1);		// alignment
        gb.BitRead(1);		// copyright
        gb.BitRead(1);		// original
        BYTE fpts = (BYTE)gb.BitRead(1);		// fpts
        BYTE fdts = (BYTE)gb.BitRead(1);		// fdts
        gb.BitRead(1);	// escr
        gb.BitRead(1);	// esrate
        gb.BitRead(1);	// dsmtrickmode
        gb.BitRead(1);	// morecopyright
        gb.BitRead(1);	// crc
        gb.BitRead(1);	// extension
        gb.BitRead(8);	// hdrlen

        if(fpts) {
            BYTE b = (BYTE)gb.BitRead(4);
            if(!(fdts && b == 3 || !fdts && b == 2)) {
                ASSERT(0);
                return(E_FAIL);
            }

            REFERENCE_TIME	pts = 0;
            pts |= gb.BitRead(3) << 30;
            MARKER; // 32..30
            pts |= gb.BitRead(15) << 15;
            MARKER; // 29..15
            pts |= gb.BitRead(15);
            MARKER; // 14..0
            pts = 10000*pts/90;

            m_rtStart	= pts;
            m_rtStop	= pts+1;
        } else {
            m_rtStart	= INVALID_TIME;
            m_rtStop	= INVALID_TIME;
        }

        nSize -= 14;
        pData += 14;
        pSample->GetTime(&m_rtStart, &m_rtStop);
        pSample->GetMediaTime(&m_rtStart, &m_rtStop);
    } else if (SUCCEEDED (pSample->GetTime(&m_rtStart, &m_rtStop))) {
        pSample->SetTime(&m_rtStart, &m_rtStop);
    }

    //FILE* hFile = fopen ("D:\\Sources\\mpc-hc\\A garder\\TestSubRip\\dvbsub.dat", "ab");
    //if(hFile != NULL)
    //{
    //	//BYTE	Buff[5] = {48};

    //	//*((DWORD*)(Buff+1)) = lSampleLen;
    //	//fwrite (Buff,  1, sizeof(Buff), hFile);
    //	fwrite (pData, 1, lSampleLen, hFile);
    //	fclose(hFile);
    //}

    if (AddToBuffer (pData, nSize) == S_OK) {
        CGolombBuffer		gb (m_pBuffer+m_nBufferReadPos, m_nBufferWritePos-m_nBufferReadPos);
        int					nLastPos = 0;

        while (!gb.IsEOF()) {
            if (gb.ReadByte() == 0x0F) {
                WORD				wPageId;
                WORD				wSegLength;

                nCurSegment	= (DVB_SEGMENT_TYPE) gb.ReadByte();
                wPageId			= gb.ReadShort();
                wSegLength		= gb.ReadShort();

                if (gb.RemainingSize() < wSegLength) {
                    hr = S_FALSE;
                    break;
                }

//.........这里部分代码省略.........
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:101,代码来源:DVBSub.cpp

示例2: ParseSample

HRESULT CDVBSub::ParseSample(IMediaSample* pSample)
{
	CheckPointer (pSample, E_POINTER);
	HRESULT				hr;
	BYTE*				pData = NULL;
	int					nSize;
	DVB_SEGMENT_TYPE	nCurSegment;

	hr = pSample->GetPointer(&pData);
	if (FAILED(hr) || pData == NULL) {
		return hr;
	}
	nSize = pSample->GetActualDataLength();

	if (*((LONG*)pData) == 0xBD010000) {
		CGolombBuffer	gb (pData, nSize);

		gb.SkipBytes(4);
		WORD	wLength	= (WORD)gb.BitRead(16);
		UNREFERENCED_PARAMETER(wLength);

		if (gb.BitRead(2) != 2) {
			return E_FAIL;    // type
		}

		gb.BitRead(2);	// scrambling
		gb.BitRead(1);	// priority
		gb.BitRead(1);	// alignment
		gb.BitRead(1);	// copyright
		gb.BitRead(1);	// original
		BYTE fpts = (BYTE)gb.BitRead(1);	// fpts
		BYTE fdts = (BYTE)gb.BitRead(1);	// fdts
		gb.BitRead(1);	// escr
		gb.BitRead(1);	// esrate
		gb.BitRead(1);	// dsmtrickmode
		gb.BitRead(1);	// morecopyright
		gb.BitRead(1);	// crc
		gb.BitRead(1);	// extension
		gb.BitRead(8);	// hdrlen

		if (fpts) {
			BYTE b = (BYTE)gb.BitRead(4);
			if (!(fdts && b == 3 || !fdts && b == 2)) {
				ASSERT(0);
				return(E_FAIL);
			}

			REFERENCE_TIME	pts = 0;
			pts |= gb.BitRead(3) << 30;
			MARKER; // 32..30
			pts |= gb.BitRead(15) << 15;
			MARKER; // 29..15
			pts |= gb.BitRead(15);
			MARKER; // 14..0
			pts = 10000*pts/90;

			m_rtStart	= pts;
			m_rtStop	= pts+1;
		} else {
			m_rtStart	= INVALID_TIME;
			m_rtStop	= INVALID_TIME;
		}

		nSize -= 14;
		pData += 14;
		pSample->GetTime(&m_rtStart, &m_rtStop);
		pSample->GetMediaTime(&m_rtStart, &m_rtStop);
	} else if (SUCCEEDED (pSample->GetTime(&m_rtStart, &m_rtStop))) {
		pSample->SetTime(&m_rtStart, &m_rtStop);
	}

	if (AddToBuffer (pData, nSize) == S_OK) {
		CGolombBuffer	gb (m_pBuffer+m_nBufferReadPos, m_nBufferWritePos-m_nBufferReadPos);
		int				nLastPos = 0;

		while (!gb.IsEOF()) {
			if (gb.ReadByte() == 0x0F) {
				WORD	wPageId;
				WORD	wSegLength;

				nCurSegment	= (DVB_SEGMENT_TYPE) gb.ReadByte();
				wPageId		= gb.ReadShort();
				wSegLength	= gb.ReadShort();

				if (gb.RemainingSize() < wSegLength) {
					hr = S_FALSE;
					break;
				}

				TRACE_DVB (_T("DVB - ParseSample, Segment = [%ws], PageId = [%d], SegLength/Buffer = [%d]/[%d]\n"), GetSegmentType(nCurSegment), wPageId, wSegLength, gb.RemainingSize());

				switch (nCurSegment) {
					case PAGE : {
						CAutoPtr<DVB_PAGE>	pPage;
						ParsePage(gb, wSegLength, pPage);

						if (pPage->PageState == DPS_ACQUISITION || pPage->PageState == DPS_MODE) {
							TRACE_DVB (_T("DVB - Page start\n"));

							if (m_pCurrentPage != NULL) {
//.........这里部分代码省略.........
开发者ID:chinajeffery,项目名称:MPC-BE--1.2.3,代码行数:101,代码来源:DVBSub.cpp


注:本文中的CGolombBuffer::RemainingSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。