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


C# org.unpack方法代码示例

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


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

示例1: decode

 /// <summary>Decode the given input bits.</summary>
 /// <remarks>Decode the given input bits.</remarks>
 /// <param name="bits">- Speex bits buffer.</param>
 /// <param name="out">- the decoded mono audio frame.</param>
 /// <returns>1 if a terminator was found, 0 if not.</returns>
 /// <exception cref="java.io.StreamCorruptedException">
 /// If there is an error detected in the
 /// data stream.
 /// </exception>
 public virtual int decode(org.xiph.speex.Bits bits, float[] @out)
 {
     int i;
     int sub;
     int pitch;
     int ol_pitch = 0;
     int m;
     float[] pitch_gain = new float[3];
     float ol_gain = 0.0f;
     float ol_pitch_coef = 0.0f;
     int best_pitch = 40;
     float best_pitch_gain = 0;
     float pitch_average = 0;
     if (bits == null && dtx_enabled != 0)
     {
         submodeID = 0;
     }
     else
     {
         if (bits == null)
         {
             decodeLost(@out);
             return 0;
         }
         do
         {
             if (bits.unpack(1) != 0)
             {
                 //Wideband
                 m = bits.unpack(org.xiph.speex.SbCodec.SB_SUBMODE_BITS);
                 int advance = org.xiph.speex.SbCodec.SB_FRAME_SIZE[m];
                 if (advance < 0)
                 {
                     throw new java.io.StreamCorruptedException("Invalid sideband mode encountered (1st sideband): "
                          + m);
                 }
                 //return -2;
                 advance -= (org.xiph.speex.SbCodec.SB_SUBMODE_BITS + 1);
                 bits.advance(advance);
                 if (bits.unpack(1) != 0)
                 {
                     m = bits.unpack(org.xiph.speex.SbCodec.SB_SUBMODE_BITS);
                     advance = org.xiph.speex.SbCodec.SB_FRAME_SIZE[m];
                     if (advance < 0)
                     {
                         throw new java.io.StreamCorruptedException("Invalid sideband mode encountered. (2nd sideband): "
                              + m);
                     }
                     //return -2;
                     advance -= (org.xiph.speex.SbCodec.SB_SUBMODE_BITS + 1);
                     bits.advance(advance);
                     if (bits.unpack(1) != 0)
                     {
                         throw new java.io.StreamCorruptedException("More than two sideband layers found");
                     }
                 }
             }
             //return -2;
             //*/
             m = bits.unpack(NB_SUBMODE_BITS);
             if (m == 15)
             {
                 return 1;
             }
             else
             {
                 if (m == 14)
                 {
                     inband.speexInbandRequest(bits);
                 }
                 else
                 {
                     if (m == 13)
                     {
                         inband.userInbandRequest(bits);
                     }
                     else
                     {
                         if (m > 8)
                         {
                             throw new java.io.StreamCorruptedException("Invalid mode encountered: " + m);
                         }
                     }
                 }
             }
         }
         while (m > 8);
         //return -2;
         submodeID = m;
     }
     System.Array.Copy(frmBuf, frameSize, frmBuf, 0, bufSize - frameSize);
//.........这里部分代码省略.........
开发者ID:sangnvus,项目名称:technical-docs,代码行数:101,代码来源:NbDecoder.cs

示例2: init

 /// <summary>Callback handler for intensity stereo info</summary>
 /// <param name="bits">- Speex bits buffer.</param>
 public virtual void init(org.xiph.speex.Bits bits)
 {
     float sign = 1;
     int tmp;
     if (bits.unpack(1) != 0)
     {
         sign = -1;
     }
     tmp = bits.unpack(5);
     balance = (float)System.Math.Exp(sign * .25 * tmp);
     tmp = bits.unpack(2);
     e_ratio = e_ratio_quant[tmp];
 }
开发者ID:sangnvus,项目名称:technical-docs,代码行数:15,代码来源:Stereo.cs

示例3: unquant

 /// <summary>Codebook Search Unquantification (Split Shape).</summary>
 /// <remarks>Codebook Search Unquantification (Split Shape).</remarks>
 /// <param name="exc">- excitation array.</param>
 /// <param name="es">- position in excitation array.</param>
 /// <param name="nsf">- number of samples in subframe.</param>
 /// <param name="bits">- Speex bits buffer.</param>
 public override sealed void unquant(float[] exc, int es, int nsf, org.xiph.speex.Bits
     bits)
 {
     int i;
     int j;
     for (i = 0; i < nb_subvect; i++)
     {
         if (have_sign != 0)
         {
             signs[i] = bits.unpack(1);
         }
         else
         {
             signs[i] = 0;
         }
         ind[i] = bits.unpack(shape_bits);
     }
     for (i = 0; i < nb_subvect; i++)
     {
         float s = 1.0f;
         if (signs[i] != 0)
         {
             s = -1.0f;
         }
         for (j = 0; j < subvect_size; j++)
         {
             exc[es + subvect_size * i + j] += s * 0.03125f * (float)shape_cb[ind[i] * subvect_size
                  + j];
         }
     }
 }
开发者ID:sangnvus,项目名称:technical-docs,代码行数:37,代码来源:SplitShapeSearch.cs

示例4: decode

 /// <summary>Decode the given input bits.</summary>
 /// <remarks>Decode the given input bits.</remarks>
 /// <param name="bits">- Speex bits buffer.</param>
 /// <param name="out">- the decoded mono audio frame.</param>
 /// <returns>1 if a terminator was found, 0 if not.</returns>
 /// <exception cref="java.io.StreamCorruptedException">
 /// If there is an error detected in the
 /// data stream.
 /// </exception>
 public virtual int decode(org.xiph.speex.Bits bits, float[] @out)
 {
     int i;
     int sub;
     int wideband;
     int ret;
     float[] low_pi_gain;
     float[] low_exc;
     float[] low_innov;
     ret = lowdec.decode(bits, x0d);
     if (ret != 0)
     {
         return ret;
     }
     bool dtx = lowdec.getDtx();
     if (bits == null)
     {
         decodeLost(@out, dtx);
         return 0;
     }
     wideband = bits.peek();
     if (wideband != 0)
     {
         wideband = bits.unpack(1);
         submodeID = bits.unpack(3);
     }
     else
     {
         submodeID = 0;
     }
     for (i = 0; i < frameSize; i++)
     {
         excBuf[i] = 0;
     }
     if (submodes[submodeID] == null)
     {
         if (dtx)
         {
             decodeLost(@out, true);
             return 0;
         }
         for (i = 0; i < frameSize; i++)
         {
             excBuf[i] = VERY_SMALL;
         }
         first = 1;
         org.xiph.speex.Filters.iir_mem2(excBuf, excIdx, interp_qlpc, high, 0, frameSize,
             lpcSize, mem_sp);
         filters.fir_mem_up(x0d, h0, y0, fullFrameSize, QMF_ORDER, g0_mem);
         filters.fir_mem_up(high, h1, y1, fullFrameSize, QMF_ORDER, g1_mem);
         for (i = 0; i < fullFrameSize; i++)
         {
             @out[i] = 2 * (y0[i] - y1[i]);
         }
         return 0;
     }
     low_pi_gain = lowdec.getPiGain();
     low_exc = lowdec.getExc();
     low_innov = lowdec.getInnov();
     submodes[submodeID].lsqQuant.unquant(qlsp, lpcSize, bits);
     if (first != 0)
     {
         for (i = 0; i < lpcSize; i++)
         {
             old_qlsp[i] = qlsp[i];
         }
     }
     for (sub = 0; sub < nbSubframes; sub++)
     {
         float tmp;
         float filter_ratio;
         float el = 0.0f;
         float rl = 0.0f;
         float rh = 0.0f;
         int subIdx = subframeSize * sub;
         tmp = (1.0f + sub) / nbSubframes;
         for (i = 0; i < lpcSize; i++)
         {
             interp_qlsp[i] = (1 - tmp) * old_qlsp[i] + tmp * qlsp[i];
         }
         org.xiph.speex.Lsp.enforce_margin(interp_qlsp, lpcSize, .05f);
         for (i = 0; i < lpcSize; i++)
         {
             interp_qlsp[i] = (float)System.Math.Cos(interp_qlsp[i]);
         }
         m_lsp.lsp2lpc(interp_qlsp, interp_qlpc, lpcSize);
         if (enhanced)
         {
             float k1;
             float k2;
             float k3;
//.........这里部分代码省略.........
开发者ID:sangnvus,项目名称:technical-docs,代码行数:101,代码来源:SbDecoder.cs

示例5: unquant

 /// <summary>Long Term Prediction Unquantification (3Tap).</summary>
 /// <remarks>Long Term Prediction Unquantification (3Tap).</remarks>
 /// <param name="exc">- Excitation</param>
 /// <param name="es">- Excitation offset</param>
 /// <param name="start">- Smallest pitch value allowed</param>
 /// <param name="pitch_coef">- Voicing (pitch) coefficient</param>
 /// <param name="nsf">- Number of samples in subframe</param>
 /// <param name="gain_val"></param>
 /// <param name="bits">- Speex bits buffer.</param>
 /// <param name="count_lost"></param>
 /// <param name="subframe_offset"></param>
 /// <param name="last_pitch_gain"></param>
 /// <returns>pitch</returns>
 public override sealed int unquant(float[] exc, int es, int start, float pitch_coef
     , int nsf, float[] gain_val, org.xiph.speex.Bits bits, int count_lost, int subframe_offset
     , float last_pitch_gain)
 {
     int i;
     int pitch;
     int gain_index;
     pitch = bits.unpack(pitch_bits);
     pitch += start;
     gain_index = bits.unpack(gain_bits);
     gain[0] = 0.015625f * (float)gain_cdbk[gain_index * 3] + .5f;
     gain[1] = 0.015625f * (float)gain_cdbk[gain_index * 3 + 1] + .5f;
     gain[2] = 0.015625f * (float)gain_cdbk[gain_index * 3 + 2] + .5f;
     if (count_lost != 0 && pitch > subframe_offset)
     {
         float gain_sum = System.Math.Abs(gain[1]);
         float tmp = count_lost < 4 ? last_pitch_gain : 0.4f * last_pitch_gain;
         if (tmp > .95f)
         {
             tmp = .95f;
         }
         if (gain[0] > 0)
         {
             gain_sum += gain[0];
         }
         else
         {
             gain_sum -= .5f * gain[0];
         }
         if (gain[2] > 0)
         {
             gain_sum += gain[2];
         }
         else
         {
             gain_sum -= .5f * gain[0];
         }
         if (gain_sum > tmp)
         {
             float fact = tmp / gain_sum;
             for (i = 0; i < 3; i++)
             {
                 gain[i] *= fact;
             }
         }
     }
     gain_val[0] = gain[0];
     gain_val[1] = gain[1];
     gain_val[2] = gain[2];
     for (i = 0; i < 3; i++)
     {
         int j;
         int pp = pitch + 1 - i;
         int tmp1;
         int tmp2;
         tmp1 = nsf;
         if (tmp1 > pp)
         {
             tmp1 = pp;
         }
         tmp2 = nsf;
         if (tmp2 > pp + pitch)
         {
             tmp2 = pp + pitch;
         }
         for (j = 0; j < tmp1; j++)
         {
             e[i][j] = exc[es + j - pp];
         }
         for (j = tmp1; j < tmp2; j++)
         {
             e[i][j] = exc[es + j - pp - pitch];
         }
         for (j = tmp2; j < nsf; j++)
         {
             e[i][j] = 0;
         }
     }
     for (i = 0; i < nsf; i++)
     {
         exc[es + i] = org.xiph.speex.NbCodec.VERY_SMALL + gain[0] * e[2][i] + gain[1] * e
             [1][i] + gain[2] * e[0][i];
     }
     return pitch;
 }
开发者ID:sangnvus,项目名称:technical-docs,代码行数:98,代码来源:Ltp3Tap.cs

示例6: unpackPlus

 /// <summary>
 /// Read the next 6 bits from the buffer, and using the value read and the
 /// given codebook, rebuild LSP table.
 /// </summary>
 /// <remarks>
 /// Read the next 6 bits from the buffer, and using the value read and the
 /// given codebook, rebuild LSP table.
 /// </remarks>
 /// <param name="lsp"></param>
 /// <param name="tab"></param>
 /// <param name="bits">- Speex bits buffer.</param>
 /// <param name="k"></param>
 /// <param name="ti"></param>
 /// <param name="li"></param>
 protected virtual void unpackPlus(float[] lsp, int[] tab, org.xiph.speex.Bits bits
     , float k, int ti, int li)
 {
     int id = bits.unpack(6);
     for (int i = 0; i < ti; i++)
     {
         lsp[i + li] += k * (float)tab[id * ti + i];
     }
 }
开发者ID:sangnvus,项目名称:technical-docs,代码行数:23,代码来源:LspQuant.cs

示例7: speexInbandRequest

        /// <summary>Speex in-band request (submode=14).</summary>
        /// <remarks>Speex in-band request (submode=14).</remarks>
        /// <param name="bits">- Speex bits buffer.</param>
        /// <exception cref="java.io.StreamCorruptedException">If stream seems corrupted.</exception>
        public virtual void speexInbandRequest(org.xiph.speex.Bits bits)
        {
            int code = bits.unpack(4);
            switch (code)
            {
                case 0:
                {
                    // asks the decoder to set perceptual enhancment off (0) or on (1)
                    bits.advance(1);
                    break;
                }

                case 1:
                {
                    // asks (if 1) the encoder to be less "aggressive" due to high packet loss
                    bits.advance(1);
                    break;
                }

                case 2:
                {
                    // asks the encoder to switch to mode N
                    bits.advance(4);
                    break;
                }

                case 3:
                {
                    // asks the encoder to switch to mode N for low-band
                    bits.advance(4);
                    break;
                }

                case 4:
                {
                    // asks the encoder to switch to mode N for high-band
                    bits.advance(4);
                    break;
                }

                case 5:
                {
                    // asks the encoder to switch to quality N for VBR
                    bits.advance(4);
                    break;
                }

                case 6:
                {
                    // request acknowledgement (0=no, 1=all, 2=only for inband data)
                    bits.advance(4);
                    break;
                }

                case 7:
                {
                    // asks the encoder to set CBR(0), VAD(1), DTX(3), VBR(5), VBR+DTX(7)
                    bits.advance(4);
                    break;
                }

                case 8:
                {
                    // transmit (8-bit) character to the other end
                    bits.advance(8);
                    break;
                }

                case 9:
                {
                    // intensity stereo information
                    // setup the stereo decoder; to skip: tmp = bits.unpack(8); break;
                    stereo.init(bits);
                    // read 8 bits
                    break;
                }

                case 10:
                {
                    // announce maximum bit-rate acceptable (N in byets/second)
                    bits.advance(16);
                    break;
                }

                case 11:
                {
                    // reserved
                    bits.advance(16);
                    break;
                }

                case 12:
                {
                    // Acknowledge receiving packet N
                    bits.advance(32);
                    break;
//.........这里部分代码省略.........
开发者ID:sangnvus,项目名称:technical-docs,代码行数:101,代码来源:Inband.cs

示例8: userInbandRequest

 /// <summary>User in-band request (submode=13).</summary>
 /// <remarks>User in-band request (submode=13).</remarks>
 /// <param name="bits">- Speex bits buffer.</param>
 /// <exception cref="java.io.StreamCorruptedException">If stream seems corrupted.</exception>
 public virtual void userInbandRequest(org.xiph.speex.Bits bits)
 {
     int req_size = bits.unpack(4);
     bits.advance(5 + 8 * req_size);
 }
开发者ID:sangnvus,项目名称:technical-docs,代码行数:9,代码来源:Inband.cs


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