⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datadecoder.cpp

📁 Dream.exe soft source (Visual C++)
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			{
				DataUnit[iPacketID].Reset();

				DataUnit[iPacketID].bOK = TRUE;
			}

			/* If all packets are received correctely, data unit is ready */
			if (biLastFlag == TRUE)
				if (DataUnit[iPacketID].bOK == TRUE)
					DataUnit[iPacketID].bReady = TRUE;


			/* Data field --------------------------------------------------- */
			/* Get size of new data block */
			if (biPadPackInd == TRUE)
			{
				/* Padding is present: the first byte gives the number of
				   useful data bytes in the data field. */
				iNewPacketDataSize =
					(int) (*pvecInputData).Separate(SIZEOF__BYTE) *
					SIZEOF__BYTE;

				if (iNewPacketDataSize > iMaxPacketDataSize)
				{
					/* Error, reset flags */
					DataUnit[iPacketID].bOK = FALSE;
					DataUnit[iPacketID].bReady = FALSE;

					/* Set values to read complete packet size */
					iNewPacketDataSize = iNewPacketDataSize;
					iNumSkipBytes = 2; /* Only CRC has to be skipped */
				}
				else
				{
					/* Number of unused bytes ("- 2" because we also have the
					   one byte which stored the size, the other byte is the
					   header) */
					iNumSkipBytes = iTotalPacketSize - 2 -
						iNewPacketDataSize / SIZEOF__BYTE;
				}

				/* Packets with no useful data are permitted if no packet
				   data is available to fill the logical frame. The PPI
				   shall be set to 1 and the first byte of the data field
				   shall be set to 0 to indicate no useful data. The first
				   and last flags shall be set to 1. The continuity index
				   shall be incremented for these empty packets */
				if ((biFirstFlag == TRUE) &&
					(biLastFlag == TRUE) &&
					(iNewPacketDataSize == 0))
				{
					/* Packet with no useful data, reset flag */
					DataUnit[iPacketID].bReady = FALSE;
				}
			}
			else
			{
				iNewPacketDataSize = iMaxPacketDataSize;

				/* All bytes are useful bytes, only CRC has to be skipped */
				iNumSkipBytes = 2;
			}

			/* Add new data to data unit vector (bit-wise copying) */
			iOldPacketDataSize = DataUnit[iPacketID].vecbiData.Size();

			DataUnit[iPacketID].vecbiData.Enlarge(iNewPacketDataSize);

			/* Read useful bits */
			for (i = 0; i < iNewPacketDataSize; i++)
				DataUnit[iPacketID].vecbiData[iOldPacketDataSize + i] =
					(_BINARY) (*pvecInputData).Separate(1);

			/* Read bytes which are not used */
			for (i = 0; i < iNumSkipBytes; i++)
				(*pvecInputData).Separate(SIZEOF__BYTE);


			/* Use data unit ------------------------------------------------ */
			if (DataUnit[iPacketID].bReady == TRUE)
			{
				/* Decode all IDs regardless whether activated or not
				   (iPacketID == or != iServPacketID) */
				/* Only DAB multimedia is supported */
				switch (eAppType)
				{
				case AT_MOTSLISHOW: /* MOTSlideshow */
					/* Packet unit decoding */
					MOTSlideShow[iPacketID].
						AddDataUnit(DataUnit[iPacketID].vecbiData);
					break;

				case AT_JOURNALINE:
					Journaline.AddDataUnit(DataUnit[iPacketID].vecbiData);
					break;
				}

				/* Packet was used, reset it now for new filling with new data
				   (this will also reset the flag
				   "DataUnit[iPacketID].bReady") */
				DataUnit[iPacketID].Reset();
			}
		}
		else
		{
			/* Skip incorrect packet */
			for (i = 0; i < iTotalPacketSize; i++)
				(*pvecInputData).Separate(SIZEOF__BYTE);
		}
	}
}

void CDataDecoder::InitInternal(CParameter& ReceiverParam)
{
	int iTotalNumInputBits;
	int iTotalNumInputBytes;
	int	iCurDataStreamID;
	int iCurSelDataServ;

	/* Init error flag */
	DoNotProcessData = FALSE;

	/* Get current selected data service */
	iCurSelDataServ = ReceiverParam.GetCurSelDataService();

	/* Get current data stream ID */
	iCurDataStreamID =
		ReceiverParam.Service[iCurSelDataServ].DataParam.iStreamID;

	/* Get number of total input bits (and bytes) for this module */
	iTotalNumInputBits = ReceiverParam.iNumDataDecoderBits;
	iTotalNumInputBytes = iTotalNumInputBits / SIZEOF__BYTE;

	/* Init application type (will be overwritten by correct type later */
	eAppType = AT_NOT_SUP;

	/* Check, if service is activated. Also, only packet services can be
	   decoded */
	if ((iCurDataStreamID != STREAM_ID_NOT_USED) &&
		(ReceiverParam.Service[iCurSelDataServ].DataParam.
		ePacketModInd == CParameter::PM_PACKET_MODE))
	{
		/* Calculate total packet size. DRM standard: packet length: this
		   field indicates the length in bytes of the data field of each
		   packet specified as an unsigned binary number (the total packet
		   length is three bytes longer as it includes the header and CRC
		   fields) */
		iTotalPacketSize =
			ReceiverParam.Service[iCurSelDataServ].DataParam.iPacketLen + 3;

		/* Check total packet size, could be wrong due to wrong SDC */
		if ((iTotalPacketSize <= 0) ||
			(iTotalPacketSize > iTotalNumInputBytes))
		{
			/* Set error flag */
			DoNotProcessData = TRUE;
		}
		else
		{
			/* Maximum number of bits for the data part in a packet
			   ("- 3" because two bits for CRC and one for the header) */
 			iMaxPacketDataSize = (iTotalPacketSize - 3) * SIZEOF__BYTE;
	
			/* Number of data packets in one data block */
			iNumDataPackets = iTotalNumInputBytes / iTotalPacketSize;

			/* Get the packet ID of the selected service */
			iServPacketID =
				ReceiverParam.Service[iCurSelDataServ].DataParam.iPacketID;

			/* Only DAB application supported */
			if (ReceiverParam.Service[iCurSelDataServ].DataParam.eAppDomain ==
				CParameter::AD_DAB_SPEC_APP)
			{
				/* Get application identifier of current selected service, only
				   used with DAB */
				const int iDABUserAppIdent = ReceiverParam.
					Service[iCurSelDataServ].DataParam.iUserAppIdent;

				switch (iDABUserAppIdent)
				{
				case 2: /* MOTSlideshow */
					eAppType = AT_MOTSLISHOW;
					break;

				/* The preliminary 11-bit user Application Type ID for the
				   NewsService Journaline shall be 0x44A */
				case 0x44A: /* Journaline */
					eAppType = AT_JOURNALINE;

					/* Check, if service ID of Journaline application has
					   changed, that indicates that a new transmission is
					   received -> reset decoder in this case. Otherwise
					   use old buffer. That ensures that the decoder keeps
					   old data in buffer when synchronization was lost for
					   a short time */
					const uint32_t iNewServID =
						ReceiverParam.Service[iCurSelDataServ].iServiceID;

					if (iOldJournalineServiceID != iNewServID)
					{

// Problem: if two different services point to the same stream, they have different
// IDs and the Journaline is reset! TODO: fix this problem...

						/* Reset Journaline decoder and store the new service
						   ID number */
						Journaline.Reset();
						iOldJournalineServiceID = iNewServID;
					}
					break;
				}
			}

			/* Init vector for storing the CRC results for each packet */
			veciCRCOk.Init(iNumDataPackets);

			/* Reset data units for all possible data IDs */
			for (int i = 0; i < MAX_NUM_PACK_PER_STREAM; i++)
			{
				DataUnit[i].Reset();

				/* Reset continuity index (CI) */
				iContInd[i] = 0;
			}
		}
	}
	else
		DoNotProcessData = TRUE;

	/* Set input block size */
	iInputBlockSize = iTotalNumInputBits;
}

_BOOLEAN CDataDecoder::GetSlideShowPicture(CMOTObject& NewPic)
{
	_BOOLEAN bReturn = FALSE;

	/* Lock resources */
	Lock();

	/* Check if data service is SlideShow application */
	if ((DoNotProcessData == FALSE) && (eAppType == AT_MOTSLISHOW))
		bReturn = MOTSlideShow[iServPacketID].GetPicture(NewPic);

	/* Release resources */
	Unlock();

	return bReturn;
}

void CDataDecoder::GetNews(const int iObjID, CNews& News)
{
	/* Lock resources */
	Lock();

	/* Check if data service is Journaline application */
	if ((DoNotProcessData == FALSE) && (eAppType == AT_JOURNALINE))
		Journaline.GetNews(iObjID, News);

	/* Release resources */
	Unlock();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -