[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-common-dev
Subject:    [Common-dev] CN: Add UINT24 and double packing functions
From:       "Eric Hyche" <ehyche () real ! com>
Date:       2009-02-12 20:48:50
Message-ID: 016101c98d53$5017f880$f047e980$ () com
[Download RAW message or body]

This is now checked into HEAD, 310Atlas, and 204Cay.

=======================================
Eric Hyche (ehyche@real.com)
Principal Engineer
RealNetworks, Inc.


>-----Original Message-----
>From: Jamie Gordon [mailto:jgordon@real.com]
>Sent: Wednesday, February 11, 2009 12:36 PM
>To: ehyche@real.com
>Cc: common-dev@lists.helixcommunity.org
>Subject: Re: [Common-dev] CR: Add UINT24 and double packing functions
>
>ok
>
>Eric Hyche wrote:
>> Description
>> ------------------------------------
>> This change adds two packing functions:
>>
>> PackUINT24BEInc - takes a UINT32 but packs it into three bytes
>>    in big-endian format and advances the packing pointers
>>
>> PackDoubleBEInc - takes a double and packs it into eight bytes
>>    in big-endian format and advances the packing pointers
>>
>> Files Modified
>> ------------------------------------
>> common/util/pckunpck.cpp
>> common/util/pub/pckunpck.h
>>
>> Branches
>> ------------------------------------
>> HEAD, 310Atlas, and 204Cayenne
>>
>>
>> Index: pckunpck.cpp
>> ===================================================================
>> RCS file: /cvsroot/common/util/pckunpck.cpp,v
>> retrieving revision 1.43
>> diff -u -w -u -w -r1.43 pckunpck.cpp
>> --- pckunpck.cpp        20 Jan 2009 19:55:35 -0000      1.43
>> +++ pckunpck.cpp        11 Feb 2009 16:26:04 -0000
>> @@ -2779,6 +2779,23 @@
>>      return retVal;
>>  }
>>
>> +HX_RESULT PackUINT24BEInc(BYTE** ppBuf, UINT32* pulLen, UINT32 ulVal)
>> +{
>> +    HX_RESULT retVal = HXR_FAIL;
>> +
>> +    if (ppBuf && pulLen)
>> +    {
>> +        retVal = PackUINT24BE(*ppBuf, *pulLen, ulVal);
>> +        if (SUCCEEDED(retVal))
>> +        {
>> +            *ppBuf  += 3;
>> +            *pulLen -= 3;
>> +        }
>> +    }
>> +
>> +    return retVal;
>> +}
>> +
>>  HX_RESULT PackUINT32BE(BYTE* pBuf, UINT32 ulLen, UINT32 ulVal)
>>  {
>>      HX_RESULT retVal = HXR_FAIL;
>> @@ -2897,6 +2914,38 @@
>>      return retVal;
>>  }
>>
>> +HX_RESULT PackDoubleBEInc(BYTE** ppBuf, UINT32* pulLen, double dVal)
>> +{
>> +    HX_RESULT retVal = HXR_FAIL;
>> +
>> +    if (ppBuf && *ppBuf && pulLen && *pulLen >= 8)
>> +    {
>> +        // Copy the double into a temporary buffer
>> +        unsigned char ucTmp[8];
>> +        memcpy(&ucTmp[0], &dVal, 8); /* Flawfinder: ignore */
>> +        // Are we little endian?
>> +        if (!TestBigEndian())
>> +        {
>> +            // Swap the 8 bytes
>> +            for (UINT32 i = 0; i < 4; i++)
>> +            {
>> +                BYTE ucT   = ucTmp[i];
>> +                ucTmp[i]   = ucTmp[7-i];
>> +                ucTmp[7-i] = ucT;
>> +            }
>> +        }
>> +        // Copy the temporary buffer to the output
>> +        memcpy(*ppBuf, &ucTmp[0], 8);
>> +        // Advance the buffer
>> +        *ppBuf  += 8;
>> +        *pulLen -= 8;
>> +        // Clear the return value
>> +        retVal = HXR_OK;
>> +    }
>> +
>> +    return retVal;
>> +}
>> +
>>  HX_RESULT UnpackBits(BYTE** ppBuf, UINT32* pulLen, UINT32* pulBitPos, UINT32 ulNumBits, UINT32*
>pulVal)
>>  {
>>      HX_RESULT retVal = HXR_FAIL;
>>
>> Index: pub/pckunpck.h
>> ===================================================================
>> RCS file: /cvsroot/common/util/pub/pckunpck.h,v
>> retrieving revision 1.24
>> diff -u -w -u -w -r1.24 pckunpck.h
>> --- pub/pckunpck.h      2 Dec 2008 08:47:45 -0000       1.24
>> +++ pub/pckunpck.h      11 Feb 2009 16:26:04 -0000
>> @@ -395,6 +395,8 @@
>>  HX_RESULT PackUINT16LEInc(BYTE** ppBuf, UINT32* pulLen, UINT16 usVal);
>>  // Pack a UINT32 in big-endian format
>>  HX_RESULT PackUINT24BE(BYTE* pBuf, UINT32 ulLen, UINT32 ulVal);
>> +// Pack a UINT32 in big-endian format and advance the buffer
>> +HX_RESULT PackUINT24BEInc(BYTE** ppBuf, UINT32* pulLen, UINT32 ulVal);
>>  // Pack a UINT32 in big-endian format
>>  HX_RESULT PackUINT32BE(BYTE* pBuf, UINT32 ulLen, UINT32 ulVal);
>>  // Pack a UINT32 in big-endian format and advance the buffer
>> @@ -407,6 +409,8 @@
>>  HX_RESULT PackUINT64BE(BYTE* pBuf, UINT32 ulLen, UINT64 ulVal);
>>  // Unpack an 8-byte double in big-endian format
>>  HX_RESULT UnpackDoubleBEInc(BYTE** ppBuf, UINT32* pulLen, double* pdVal);
>> +// Pack an 8-byte double in big-endian format
>> +HX_RESULT PackDoubleBEInc(BYTE** ppBuf, UINT32* pulLen, double dVal);
>>  // Unpack a certain number of bits
>>  HX_RESULT UnpackBits(BYTE** ppBuf, UINT32* pulLen, UINT32* pulBitPos, UINT32 ulNumBits, UINT32*
>pulVal);
>>  // Pack a certain number of bits
>>
>>
>> =======================================
>> Eric Hyche (ehyche@real.com)
>> Principal Engineer
>> RealNetworks, Inc.
>>
>>
>>
>>
>> _______________________________________________
>> Common-dev mailing list
>> Common-dev@helixcommunity.org
>> http://lists.helixcommunity.org/mailman/listinfo/common-dev


_______________________________________________
Common-dev mailing list
Common-dev@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/common-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic