本文整理匯總了C++中GetBits函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetBits函數的具體用法?C++ GetBits怎麽用?C++ GetBits使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetBits函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: DecodeFillElement
/**************************************************************************************
* Function: DecodeFillElement
*
* Description: decode one fill element
*
* Inputs: BitStreamInfo struct pointing to start of fill element
* (14496-3, table 4.4.11)
*
* Outputs: updated element instance tag
* unpacked extension payload
*
* Return: 0 if successful, -1 if error
**************************************************************************************/
static int DecodeFillElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
{
unsigned int fillCount;
unsigned char *fillBuf;
PSInfoBase *psi;
/* validate pointers */
if (!aacDecInfo || !aacDecInfo->psInfoBase)
return -1;
psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
fillCount = GetBits(bsi, 4);
if (fillCount == 15)
fillCount += (GetBits(bsi, 8) - 1);
psi->fillCount = fillCount;
fillBuf = psi->fillBuf;
while (fillCount--)
*fillBuf++ = GetBits(bsi, 8);
aacDecInfo->currInstTag = -1; /* fill elements don't have instance tag */
aacDecInfo->fillExtType = 0;
#ifdef AAC_ENABLE_SBR
/* check for SBR
* aacDecInfo->sbrEnabled is sticky (reset each raw_data_block), so for multichannel
* need to verify that all SCE/CPE/ICCE have valid SBR fill element following, and
* must upsample by 2 for LFE
*/
if (psi->fillCount > 0) {
aacDecInfo->fillExtType = (int)((psi->fillBuf[0] >> 4) & 0x0f);
if (aacDecInfo->fillExtType == EXT_SBR_DATA || aacDecInfo->fillExtType == EXT_SBR_DATA_CRC)
aacDecInfo->sbrEnabled = 1;
}
示例2: QVariant
void AVRStudioXMLParser::Parse(QString configDirPath, Part *pPart)
{
QXmlQuery query;
QString result;
query.bindVariable("partName", QVariant(configDirPath));
query.setQuery(GetXQuery());
query.evaluateTo(&result);
// for future use
QString errorMsg;
int line;
int col;
QDomDocument doc;
if(!doc.setContent(result, &errorMsg, &line, &col))
return;
QDomNode root = doc.firstChild();
QDomNode fuses = root.firstChild();
QDomNode locks = fuses.nextSibling();
QDomNode interfaces = locks.nextSibling();
pPart->SetFuseBits(GetBits(fuses.firstChild()));
pPart->SetLockBits(GetBits(locks.firstChild()));
pPart->SetProgrammingInterfaces(GetInterfaces(interfaces.firstChild()));
}
示例3: CPulseData_Read
/*
The function reads the elements for pulse data from
the bitstream.
*/
void CPulseData_Read(HANDLE_BIT_BUF bs, /*!< pointer to bitstream */
CPulseData *PulseData) /*!< pointer to pulse data side info */
{
int i;
FLC_sub_start("CPulseData_Read");
FUNC(2); INDIRECT(1); STORE(1); BRANCH(1);
if ((PulseData->PulseDataPresent = (char) GetBits(bs,1)))
{
FUNC(2); INDIRECT(2); STORE(1);
PulseData->NumberPulse = (char) GetBits(bs,2);
FUNC(2); INDIRECT(2); STORE(1);
PulseData->PulseStartBand = (char) GetBits(bs,6);
PTR_INIT(2); /* PulseData->PulseOffset[i]
PulseData->PulseAmp[i]
*/
LOOP(1);
for (i=0; i<=PulseData->NumberPulse; i++)
{
FUNC(2); STORE(1);
PulseData->PulseOffset[i] = (char) GetBits(bs,5);
FUNC(2); STORE(1);
PulseData->PulseAmp[i] = (char) GetBits(bs,4);
}
}
FLC_sub_end();
}
示例4: DecodeDataStreamElement
/**************************************************************************************
* Function: DecodeDataStreamElement
*
* Description: decode one DSE
*
* Inputs: BitStreamInfo struct pointing to start of DSE (14496-3, table 4.4.10)
*
* Outputs: updated element instance tag
* filled in data stream buffer
*
* Return: 0 if successful, -1 if error
**************************************************************************************/
static int DecodeDataStreamElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
{
unsigned int byteAlign, dataCount;
unsigned char *dataBuf;
PSInfoBase *psi;
/* validate pointers */
if (!aacDecInfo || !aacDecInfo->psInfoBase)
return -1;
psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
byteAlign = GetBits(bsi, 1);
dataCount = GetBits(bsi, 8);
if (dataCount == 255)
dataCount += GetBits(bsi, 8);
if (byteAlign)
ByteAlignBitstream(bsi);
psi->dataCount = dataCount;
dataBuf = psi->dataBuf;
while (dataCount--)
*dataBuf++ = GetBits(bsi, 8);
return 0;
}
示例5: rfx_rlgr_get_gr_code
static uint32
rfx_rlgr_get_gr_code(RFX_BITSTREAM * bs, int * krp, int * kr)
{
int vk;
uint32 mag;
/* chew up/count leading 1s and escape 0 */
for (vk = 0; GetBits(1) == 1;)
vk++;
/* get next *kr bits, and combine with leading 1s */
mag = (vk << *kr) | GetBits(*kr);
/* adjust krp and kr based on vk */
if (!vk)
{
UpdateParam(*krp, -2, *kr);
}
else if (vk != 1)
{
/* at 1, no change! */
UpdateParam(*krp, vk, *kr);
}
return mag;
}
示例6: CodeToFile
//把出現過的字符編碼表經過壓縮寫進文件
short CodeToFile(FILE *fp,char **hc,short n,SeqQueue *Q,MyType *length)
{
int i;
char *p;
MyType j,bits;
short count=0;
for(i = 0;i < n;i++)// 將n個葉子壓縮並寫入文件
{
for(p = hc[i]; '\0' != *p; p++)
In_seqQueue( Q,*p );
while(Q->length > 8)
{
bits = GetBits(Q);//出隊8個元素
fputc(bits,fp);
count++;
}
}
*length = Q->length;
i = 8 - *length;
bits = GetBits(Q);//取8個如果隊不空
for(j = 0;j < i;j++)
bits = bits << 1;
fputc(bits,fp);
count++;
InitQueue(Q);
return count;
}
示例7: ntohs
bool CxImageSKA::Decode(CxFile *hFile)
{
if (hFile==NULL)
return false;
// read the header
SKAHEADER ska_header;
hFile->Read(&ska_header,sizeof(SKAHEADER),1);
ska_header.Width = ntohs(ska_header.Width);
ska_header.Height = ntohs(ska_header.Height);
ska_header.dwUnknown = ntohl(ska_header.dwUnknown);
// check header
if (ska_header.dwUnknown != 0x01000000 ||
ska_header.Width > 0x7FFF || ska_header.Height > 0x7FFF ||
ska_header.BppExp != 3)
return false;
if (info.nEscape == -1){
head.biWidth = ska_header.Width ;
head.biHeight= ska_header.Height;
info.dwType = CXIMAGE_FORMAT_SKA;
return true;
}
int bpp = 1<<ska_header.BppExp;
Create(ska_header.Width,ska_header.Height,bpp,CXIMAGE_FORMAT_SKA);
if (!IsValid())
return false;
// read the palette
int nColors = 1<<bpp;
rgb_color* ppal = (rgb_color*)malloc(nColors*sizeof(rgb_color));
if (!ppal) return false;
hFile->Read(ppal,nColors*sizeof(rgb_color),1);
SetPalette(ppal,nColors);
free(ppal);
//read the image
hFile->Read(GetBits(),ska_header.Width*ska_header.Height,1);
//reorder rows
if (GetEffWidth() != ska_header.Width){
BYTE *src,*dst;
src = GetBits() + ska_header.Width*(ska_header.Height-1);
dst = GetBits(ska_header.Height-1);
for(int y=0;y<ska_header.Height;y++){
memcpy(dst,src,ska_header.Width);
src -= ska_header.Width;
dst -= GetEffWidth();
}
}
Flip();
return true;
}
示例8: UninstDbgBreakfromThrd
DWORD
UninstDbgBreakfromThrd( DWORD dwThreadId, DWORD dwLineAddr, DWORD dwAccessType)
{
HANDLE hThread;
hThread = OpenThread( THREAD_SET_CONTEXT|THREAD_GET_CONTEXT|THREAD_SUSPEND_RESUME,
FALSE, dwThreadId );
if ( hThread == NULL )
return GetLastError();
if ( -1 == SuspendThread( hThread ))
return GetLastError();
CONTEXT cxt = {0};
cxt.ContextFlags = CONTEXT_DEBUG_REGISTERS|CONTEXT_FULL;
if (!GetThreadContext( hThread, &cxt ))
return GetLastError();
if (cxt.Dr0 == dwLineAddr)
{
if (dwAccessType == GetBits(cxt.Dr7, 16, 2))
{
SetBits(cxt.Dr7, DR7_L0, 1, 0);
}
}
if (cxt.Dr1 == dwLineAddr)
{
if (dwAccessType == GetBits(cxt.Dr7, 20, 2))
{
SetBits(cxt.Dr7, DR7_L1, 1, 0);
}
}
if (cxt.Dr2 == dwLineAddr)
{
if (dwAccessType == GetBits(cxt.Dr7, 24, 2))
{
SetBits(cxt.Dr7, DR7_L2, 1, 0);
}
}
if (cxt.Dr3 == dwLineAddr)
{
if (dwAccessType == GetBits(cxt.Dr7, 28, 2))
{
SetBits(cxt.Dr7, DR7_L3, 1, 0);
}
}
cxt.ContextFlags = CONTEXT_DEBUG_REGISTERS;
if(!SetThreadContext( hThread, &cxt ))
return GetLastError();
if(-1 == ResumeThread( hThread ))
return GetLastError();
return 0;
}
示例9: GetDCFCounter
/*
* GetDCFCounter
*
* Description:
* This function will read a counter from a specified
* position in a dynamic count filter.
*
* Parameters:
* dcf: [in]
* The dynamic count filter whose counter is to be read.
* index: [in]
* The index of the counter to be read.
*
* Returns:
* The counter in the specified position.
*
* Comments:
*
*/
unsigned GetDCFCounter(DynamicCountFilter *dcf, unsigned index)
{
unsigned ofvCounter;
unsigned cbfvCounter = GetBits((unsigned *)dcf->CBFV,
index * dcf->CBFV_Counter_Size,
dcf->CBFV_Counter_Size);
if (dcf->OFV == NULL)
return cbfvCounter;
ofvCounter = GetBits((unsigned *)dcf->OFV,
index * dcf->OFV_Counter_Size,
dcf->OFV_Counter_Size);
return (ofvCounter << dcf->CBFV_Counter_Size) | cbfvCounter;
}
示例10: DecodeChannelPairElement
/**************************************************************************************
* Function: DecodeChannelPairElement
*
* Description: decode one CPE
*
* Inputs: BitStreamInfo struct pointing to start of CPE (14496-3, table 4.4.5)
*
* Outputs: updated element instance tag
* updated commonWin
* updated ICS info, if commonWin == 1
* updated mid-side stereo info, if commonWin == 1
*
* Return: 0 if successful, -1 if error
*
* Notes: doesn't decode individual channel stream (part of DecodeNoiselessData)
**************************************************************************************/
static int DecodeChannelPairElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
{
int sfb, gp, maskOffset;
unsigned char currBit, *maskPtr;
PSInfoBase *psi;
ICSInfo *icsInfo;
/* validate pointers */
if (!aacDecInfo || !aacDecInfo->psInfoBase)
return -1;
psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
icsInfo = psi->icsInfo;
/* read instance tag */
aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
/* read common window flag and mid-side info (if present)
* store msMask bits in psi->msMaskBits[] as follows:
* long blocks - pack bits for each SFB in range [0, maxSFB) starting with lsb of msMaskBits[0]
* short blocks - pack bits for each SFB in range [0, maxSFB), for each group [0, 7]
* msMaskPresent = 0 means no M/S coding
* = 1 means psi->msMaskBits contains 1 bit per SFB to toggle M/S coding
* = 2 means all SFB's are M/S coded (so psi->msMaskBits is not needed)
*/
psi->commonWin = GetBits(bsi, 1);
if (psi->commonWin) {
DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx);
psi->msMaskPresent = GetBits(bsi, 2);
if (psi->msMaskPresent == 1) {
maskPtr = psi->msMaskBits;
*maskPtr = 0;
maskOffset = 0;
for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
currBit = (unsigned char)GetBits(bsi, 1);
*maskPtr |= currBit << maskOffset;
if (++maskOffset == 8) {
maskPtr++;
*maskPtr = 0;
maskOffset = 0;
}
}
}
}
}
return 0;
}
示例11: GetWidth
bool CImageEx::SetGray()
{
int nWidth = GetWidth();
int nHeight = GetHeight();
BYTE* pArray = (BYTE*)GetBits();
int nPitch = GetPitch();
int nBitCount = GetBPP() / 8;
for (int i = 0; i < nHeight; i++)
{
for (int j = 0; j < nWidth; j++)
{
int grayVal = (BYTE)(((*(pArray + nPitch * i + j * nBitCount) * 306)
+ (*(pArray + nPitch * i + j * nBitCount + 1) * 601)
+ (*(pArray + nPitch * i + j * nBitCount + 2) * 117) + 512 ) >> 10); // ¼ÆËã»Ò¶ÈÖµ
*(pArray + nPitch * i + j * nBitCount) = grayVal; // ¸³»Ò¶ÈÖµ
*(pArray + nPitch * i + j * nBitCount + 1) = grayVal;
*(pArray + nPitch * i + j * nBitCount + 2) = grayVal;
}
}
return true;
}
示例12: GetImageSize
oexINT CImage::GetBits( oexPVOID x_buf, oexINT x_nSize )
{
#if !defined( OEX_ENABLE_XIMAGE )
return 0;
#else
// Sanity checks
if ( !x_buf || !x_nSize )
return 0;
// Get image size
oexINT nSize = GetImageSize();
if ( nSize > x_nSize )
nSize = x_nSize;
// Get destination buffer
oexPVOID pBits = GetBits();
if ( !pBits )
return 0;
// Copy the data
memcpy( x_buf, pBits, nSize );
return nSize;
#endif
}
示例13: GetBits
BYTE CxDib::GetPixelIndex(long x,long y)
{
if ((hDib==NULL)||(m_nColors==0)||
(x<0)||(y<0)||(x>=m_bi.biWidth)||(y>=m_bi.biHeight)) return 0;
BYTE* iDst = GetBits();
return iDst[(m_bi.biHeight - y)*m_LineWidth + x];
}
示例14: DecodeEnvelope
/**************************************************************************************
* Function: DecodeEnvelope
*
* Description: decode the power envelope
*
* Inputs: pointer to initialized Gecko2Info struct
* number of bits remaining in bitstream for this frame
* index of current channel
*
* Outputs: rmsIndex[0, ..., cregsions-1] has power index for each region
* updated rmsMax with largest value of rmsImdex for this channel
*
* Return: number of bits remaining in bitstream, -1 if out-of-bits
**************************************************************************************/
int DecodeEnvelope(Gecko2Info *gi, int availbits, int ch)
{
int r, code, nbits, rprime, cache, rmsMax;
int *rmsIndex = gi->db.rmsIndex;
BitStreamInfo *bsi = &(gi->bsi);
if (availbits < RMS0BITS)
return -1;
/* unpack first index */
code = GetBits(bsi, RMS0BITS, 1);
availbits -= RMS0BITS;
rmsIndex[0] = CODE2RMS(code);
/* check for escape code */
/* ASSERT(rmsIndex[0] != 0); */
rmsMax = rmsIndex[0];
for (r = 1; r < gi->cRegions; r++) {
/* for interleaved regions, choose a reasonable table */
if (r < 2 * gi->cplStart) {
rprime = r >> 1;
if (rprime < 1)
rprime = 1;
} else {
示例15: GetWidth
void
Dib::Render (/*[in]*/ HDC hdc,
/*[in]*/ int x,
/*[in]*/ int y,
/*[in]*/ int cx,
/*[in]*/ int cy)
{
if (cx < 0)
{
cx = GetWidth();
}
if (cy < 0)
{
cy = GetHeight();
}
SetStretchBltMode (hdc, COLORONCOLOR);
if (StretchDIBits(hdc,
x,
y,
cx,
cy,
0,
0,
GetWidth(),
GetHeight(),
GetBits(),
GetBitmapInfo(),
DIB_RGB_COLORS,
SRCCOPY)
== GDI_ERROR)
{
FATAL_WINDOWS_ERROR ("StretchDIBits", 0);
}
}