Exemplo n.º 1
0
 public void Decode2(DataBits data)
 {
     for (uint i = 0; i < Count; ++i)
     {
         float f;
         int   s       = Scale[i];
         int   bitSize = ChannelTables.Decode2List1[s];
         int   v       = data.GetBit(bitSize);
         if (s < 8)
         {
             v += s << 4;
             data.AddBit(ChannelTables.Decode2List2[v] - bitSize);
             f = ChannelTables.Decode2List3[v];
         }
         else
         {
             v = (1 - ((v & 1) << 1)) * (v >> 1);
             if (v == 0)
             {
                 data.AddBit(-1);
             }
             f = v;
         }
         Block[i] = Base[i] * f;
     }
     for (var i = Count; i < Block.Length; ++i)
     {
         Block[i] = 0;
     }
 }
Exemplo n.º 2
0
        public void Decode2(int channelIndex, DataBits data)
        {
            var pCount = GetPtrOfCount(channelIndex);
            var pScale = GetPtrOfScale(channelIndex);
            var pBlock = GetPtrOfBlock(channelIndex);
            var pBase  = GetPtrOfBase(channelIndex);

            for (var i = 0; i < *pCount; ++i)
            {
                int   s       = pScale[i];
                int   bitSize = ChannelTables.Decode2List1[s];
                var   v       = data.GetBit(bitSize);
                float f;

                if (s < 8)
                {
                    v += s << 4;
                    data.AddBit(ChannelTables.Decode2List2[v] - bitSize);
                    f = ChannelTables.Decode2List3[v];
                }
                else
                {
                    v = (1 - ((v & 1) << 1)) * (v >> 1);

                    if (v == 0)
                    {
                        data.AddBit(-1);
                    }

                    f = v;
                }

                pBlock[i] = pBase[i] * f;
            }

            ZeroMemory(&pBlock[*pCount], sizeof(float) * (int)(0x80 - *pCount));
        }