private (bool, int) DecodeTag(string content, Regex reg, StringBuilder text, Func <Match, Inline> process)
        {
            var match = reg.Match(content);

            if (match.Groups[0].Index == 0)
            {
                if (text.Length > 0)
                {
                    Inlines.Add(new Run(text.ToString())); text.Clear();
                }
                Inlines.Add(process(match));
                return(true, match.Length);
            }
            return(false, 0);
        }
Ejemplo n.º 2
0
 private void HighlightKeyText()
 {
     if (!string.IsNullOrEmpty(this.Text) && this.HighlightKeys != null && this.HighlightKeys.Length > 0)
     {
         Dictionary <string, bool> dictionary;
         List <string>             list = this.Split(this.Text, this.HighlightKeys, out dictionary);
         Inlines.Clear();
         foreach (string text in list)
         {
             Run run = new Run(text);
             run.Foreground = (dictionary.ContainsKey(text) ? this.HightlightForeground : this.Foreground);
             base.Inlines.Add(run);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// This is a faster version of ec_tell_frac() that takes advantage
        /// of the low(1/8 bit) resolution to use just a linear function
        /// followed by a lookup to determine the exact transition thresholds.
        /// </summary>
        /// <param name="this"></param>
        /// <returns></returns>
        internal uint tell_frac()
        {
            int  nbits;
            int  r;
            int  l;
            uint b;

            nbits = this.nbits_total << EntropyCoder.BITRES;
            l     = Inlines.EC_ILOG(this.rng);
            r     = (int)(this.rng >> (l - 16));
            b     = (uint)((r >> 12) - 8);
            b    += (r > correction[b] ? 1u : 0);
            l     = (int)((l << 3) + b);
            return((uint)(nbits - l));
        }
Ejemplo n.º 4
0
        internal static unsafe int pitch_xcorr(
            short[] _x,
            int _x_ptr,
            short[] _y,
            int _y_ptr,
            int[] xcorr,
            int len,
            int max_pitch)
        {
            int i;
            int maxcorr = 1;

            Inlines.OpusAssert(max_pitch > 0);
            fixed(int *pxcorr = xcorr)
            {
                fixed(short *px_base = _x, py_base = _y)
                {
                    short *px = px_base + _x_ptr;

                    for (i = 0; i < max_pitch - 3; i += 4)
                    {
                        int    sum0 = 0, sum1 = 0, sum2 = 0, sum3 = 0;
                        short *py = py_base + _y_ptr + i;
                        Kernels.xcorr_kernel(px, py, ref sum0, ref sum1, ref sum2, ref sum3, len);

                        int *pxcorr2 = pxcorr + i;
                        pxcorr2[0] = sum0;
                        pxcorr2[1] = sum1;
                        pxcorr2[2] = sum2;
                        pxcorr2[3] = sum3;
                        sum0       = Inlines.MAX32(sum0, sum1);
                        sum2       = Inlines.MAX32(sum2, sum3);
                        sum0       = Inlines.MAX32(sum0, sum2);
                        maxcorr    = Inlines.MAX32(maxcorr, sum0);
                    }
                    /* In case max_pitch isn't a multiple of 4, do non-unrolled version. */
                    for (; i < max_pitch; i++)
                    {
                        short *py        = py_base + _y_ptr + i;
                        int    inner_sum = Kernels.celt_inner_prod(px, py, len);
                        xcorr[i] = inner_sum;
                        maxcorr  = Inlines.MAX32(maxcorr, inner_sum);
                    }
                }
            }

            return(maxcorr);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Resample with a 2nd order AR filter followed by FIR interpolation
        /// </summary>
        /// <param name="S">I/O  Resampler state</param>
        /// <param name="output">O    Output signal</param>
        /// <param name="output_ptr"></param>
        /// <param name="input">I    Input signal</param>
        /// <param name="input_ptr"></param>
        /// <param name="inLen">I    Number of input samples</param>
        internal static void silk_resampler_private_down_FIR(
            SilkResamplerState S,
            short[] output,
            int output_ptr,
            short[] input,
            int input_ptr,
            int inLen)
        {
            int nSamplesIn;
            int max_index_Q16, index_increment_Q16;

            int[] buf = new int[S.batchSize + S.FIR_Order];

            /* Copy buffered samples to start of buffer */
            Array.Copy(S.sFIR_i32, buf, S.FIR_Order);

            /* Iterate over blocks of frameSizeIn input samples */
            index_increment_Q16 = S.invRatio_Q16;
            while (true)
            {
                nSamplesIn = Inlines.silk_min(inLen, S.batchSize);

                /* Second-order AR filter (output in Q8) */
                silk_resampler_private_AR2(S.sIIR, 0, buf, S.FIR_Order, input, input_ptr, S.Coefs, nSamplesIn);

                max_index_Q16 = Inlines.silk_LSHIFT32(nSamplesIn, 16);

                /* Interpolate filtered signal */
                output_ptr = silk_resampler_private_down_FIR_INTERPOL(output, output_ptr, buf, S.Coefs, 2, S.FIR_Order,
                                                                      S.FIR_Fracs, max_index_Q16, index_increment_Q16);

                input_ptr += nSamplesIn;
                inLen     -= nSamplesIn;

                if (inLen > 1)
                {
                    /* More iterations to do; copy last part of filtered signal to beginning of buffer */
                    Array.Copy(buf, nSamplesIn, buf, 0, S.FIR_Order);
                }
                else
                {
                    break;
                }
            }

            /* Copy last part of filtered signal to the state for the next call */
            Array.Copy(buf, nSamplesIn, S.sFIR_i32, 0, S.FIR_Order);
        }
Ejemplo n.º 6
0
        public NoXmlComments(ReflectedMember entry)
        {
            Resources.MergedDictionaries.Add(DocumentationResources.BaseResources);
            Style = (Style)FindResource("NoComments");

            Inlines.Add(new Run(
                            string.Format("No XML comments file found for declaring assembly '{0}'. ",
                                          System.IO.Path.GetFileName(entry.Assembly.FileName))
                            ));

            Hyperlink info = new Hyperlink(new Run("More information."));

            info.NavigateUri      = new Uri(HelpUri);
            info.RequestNavigate += info_RequestNavigate;
            Inlines.Add(info);
        }
Ejemplo n.º 7
0
        /** Decode pulse vector and combine the result with the pitch vector to produce
         *  the final normalised signal in the current band. */
        internal static uint alg_unquant(int[] X, int X_ptr, int N, int K, int spread, int B,
                                         EntropyCoder dec, int gain)
        {
            int  Ryy;
            uint collapse_mask;

            int[] iy = new int[N];
            Inlines.OpusAssert(K > 0, "alg_unquant() needs at least one pulse");
            Inlines.OpusAssert(N > 1, "alg_unquant() needs at least two dimensions");
            Ryy = CWRS.decode_pulses(iy, N, K, dec);
            normalise_residual(iy, X, X_ptr, N, Ryy, gain);
            exp_rotation(X, X_ptr, N, -1, B, K, spread);
            collapse_mask = extract_collapse_mask(iy, N, B);

            return(collapse_mask);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Chirp (bw expand) LP AR filter (Fixed point implementation)
        /// </summary>
        /// <param name="ar">I/O  AR filter to be expanded (without leading 1)</param>
        /// <param name="d">I length of ar</param>
        /// <param name="chirp">I    chirp factor (typically in range (0..1) )</param>
        internal static void silk_bwexpander_32(
            int[] ar,       /* I/O  AR filter to be expanded (without leading 1)                */
            int d,          /* I    Length of ar                                                */
            int chirp_Q16   /* I    Chirp factor in Q16                                         */
            )
        {
            int i;
            int chirp_minus_one_Q16 = chirp_Q16 - 65536;

            for (i = 0; i < d - 1; i++)
            {
                ar[i]      = Inlines.silk_SMULWW(chirp_Q16, ar[i]);
                chirp_Q16 += Inlines.silk_RSHIFT_ROUND(Inlines.silk_MUL(chirp_Q16, chirp_minus_one_Q16), 16);
            }
            ar[d - 1] = Inlines.silk_SMULWW(chirp_Q16, ar[d - 1]);
        }
Ejemplo n.º 9
0
        private void Parse(string html)
        {
            Inlines.Clear();
            if (html == null)
            {
                return;
            }
            HtmlTagTree tree   = new HtmlTagTree();
            HtmlParser  parser = new HtmlParser(tree);   //output

            parser.Parse(new StringReader(html));        //input

            HtmlUpdater updater = new HtmlUpdater(this); //output

            updater.Update(tree);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Entropy code the mid/side quantization indices
        /// </summary>
        /// <param name="psRangeEnc">I/O  Compressor data structure</param>
        /// <param name="ix">I    Quantization indices [ 2 ][ 3 ]</param>
        internal static void silk_stereo_encode_pred(EntropyCoder psRangeEnc, sbyte[][] ix)
        {
            int n;

            /* Entropy coding */
            n = 5 * ix[0][2] + ix[1][2];
            Inlines.OpusAssert(n < 25);
            psRangeEnc.enc_icdf(n, Tables.silk_stereo_pred_joint_iCDF, 8);
            for (n = 0; n < 2; n++)
            {
                Inlines.OpusAssert(ix[n][0] < 3);
                Inlines.OpusAssert(ix[n][1] < SilkConstants.STEREO_QUANT_SUB_STEPS);
                psRangeEnc.enc_icdf(ix[n][0], Tables.silk_uniform3_iCDF, 8);
                psRangeEnc.enc_icdf(ix[n][1], Tables.silk_uniform5_iCDF, 8);
            }
        }
        protected override void Parse(string html)
        {
            Inlines.Clear();

            if (!string.IsNullOrEmpty(Highlight))
            {
                var index = html.IndexOf(Highlight, StringComparison.InvariantCultureIgnoreCase);
                while (index != -1)
                {
                    html  = string.Format("{0}[b]{1}[/b]{2}", html.Substring(0, index), html.Substring(index, Highlight.Length), html.Substring(index + Highlight.Length));
                    index = html.IndexOf(Highlight, index + 7 + Highlight.Length, StringComparison.InvariantCultureIgnoreCase);
                }
            }

            this.UpdateWith(html);
        }
Ejemplo n.º 12
0
        internal static void silk_decode_pitch(
            short lagIndex,             /* I                                                                */
            sbyte contourIndex,         /* O                                                                */
            int[] pitch_lags,           /* O    4 pitch values                                              */
            int Fs_kHz,                 /* I    sampling frequency (kHz)                                    */
            int nb_subfr                /* I    number of sub frames                                        */
            )
        {
            int lag, k, min_lag, max_lag;

            sbyte[][] Lag_CB_ptr;

            if (Fs_kHz == 8)
            {
                if (nb_subfr == SilkConstants.PE_MAX_NB_SUBFR)
                {
                    Lag_CB_ptr = Tables.silk_CB_lags_stage2;
                }
                else
                {
                    Inlines.OpusAssert(nb_subfr == SilkConstants.PE_MAX_NB_SUBFR >> 1);
                    Lag_CB_ptr = Tables.silk_CB_lags_stage2_10_ms;
                }
            }
            else
            {
                if (nb_subfr == SilkConstants.PE_MAX_NB_SUBFR)
                {
                    Lag_CB_ptr = Tables.silk_CB_lags_stage3;
                }
                else
                {
                    Inlines.OpusAssert(nb_subfr == SilkConstants.PE_MAX_NB_SUBFR >> 1);
                    Lag_CB_ptr = Tables.silk_CB_lags_stage3_10_ms;
                }
            }

            min_lag = Inlines.silk_SMULBB(SilkConstants.PE_MIN_LAG_MS, Fs_kHz);
            max_lag = Inlines.silk_SMULBB(SilkConstants.PE_MAX_LAG_MS, Fs_kHz);
            lag     = min_lag + lagIndex;

            for (k = 0; k < nb_subfr; k++)
            {
                pitch_lags[k] = lag + Lag_CB_ptr[k][contourIndex];
                pitch_lags[k] = Inlines.silk_LIMIT(pitch_lags[k], min_lag, max_lag);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// LPC analysis filter
        /// NB! State is kept internally and the
        /// filter always starts with zero state
        /// first d output samples are set to zero
        /// </summary>
        /// <param name="output">O    Output signal</param>
        /// <param name="output_ptr"></param>
        /// <param name="input">I    Input signal</param>
        /// <param name="input_ptr"></param>
        /// <param name="B">I    MA prediction coefficients, Q12 [order]</param>
        /// <param name="B_ptr"></param>
        /// <param name="len">I    Signal length</param>
        /// <param name="d">I    Filter order</param>
        internal static void silk_LPC_analysis_filter(
            short[] output,
            int output_ptr,
            short[] input,
            int input_ptr,
            short[] B,
            int B_ptr,
            int len,
            int d)
        {
            int j;

            short[] mem = new short[SilkConstants.SILK_MAX_ORDER_LPC];
            short[] num = new short[SilkConstants.SILK_MAX_ORDER_LPC];

            Inlines.OpusAssert(d >= 6);
            Inlines.OpusAssert((d & 1) == 0);
            Inlines.OpusAssert(d <= len);

            Inlines.OpusAssert(d <= SilkConstants.SILK_MAX_ORDER_LPC);
            for (j = 0; j < d; j++)
            {
                num[j] = (short)(0 - B[B_ptr + j]);
            }
            for (j = 0; j < d; j++)
            {
                mem[j] = input[input_ptr + d - j - 1];
            }
#if UNSAFE
            unsafe
            {
                fixed(short *pinput_base = input, poutput_base = output)
                {
                    short *pinput  = pinput_base + input_ptr + d;
                    short *poutput = poutput_base + output_ptr + d;

                    Kernels.celt_fir(pinput, num, poutput, len - d, d, mem);
                }
            }
#else
            Kernels.celt_fir(input, input_ptr + d, num, output, output_ptr + d, len - d, d, mem);
#endif
            for (j = output_ptr; j < output_ptr + d; j++)
            {
                output[j] = 0;
            }
        }
Ejemplo n.º 14
0
        /* Add noise to matrix diagonal */
        internal static void silk_regularize_correlations(
            int[] XX,                                   /* I/O  Correlation matrices                                                        */
            int XX_ptr,
            int[] xx,                                   /* I/O  Correlation values                                                          */
            int xx_ptr,
            int noise,                                  /* I    Noise to add                                                                */
            int D                                       /* I    Dimension of XX                                                             */
            )
        {
            int i;

            for (i = 0; i < D; i++)
            {
                Inlines.MatrixSet(XX, XX_ptr, i, i, D, Inlines.silk_ADD32(Inlines.MatrixGet(XX, XX_ptr, i, i, D), noise));
            }
            xx[xx_ptr] += noise;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Find least-squares prediction gain for one signal based on another and quantize it
        /// </summary>
        /// <param name="ratio_Q14">O    Ratio of residual and mid energies</param>
        /// <param name="x">I    Basis signal</param>
        /// <param name="y">I    Target signal</param>
        /// <param name="mid_res_amp_Q0">I/O  Smoothed mid, residual norms</param>
        /// <param name="mid_res_amp_Q0_ptr"></param>
        /// <param name="length">I    Number of samples</param>
        /// <param name="smooth_coef_Q16">I    Smoothing coefficient</param>
        /// <returns>O    Returns predictor in Q13</returns>
        internal static int silk_stereo_find_predictor(
            BoxedValueInt ratio_Q14,
            short[] x,
            short[] y,
            int[] mid_res_amp_Q0,
            int mid_res_amp_Q0_ptr,
            int length,
            int smooth_coef_Q16)
        {
            int scale;
            int nrgx, nrgy, scale1, scale2;
            int corr, pred_Q13, pred2_Q10;

            /* Find predictor */
            SumSqrShift.silk_sum_sqr_shift(out nrgx, out scale1, x, length);
            SumSqrShift.silk_sum_sqr_shift(out nrgy, out scale2, y, length);
            scale     = Inlines.silk_max_int(scale1, scale2);
            scale     = scale + (scale & 1);      /* make even */
            nrgy      = Inlines.silk_RSHIFT32(nrgy, scale - scale2);
            nrgx      = Inlines.silk_RSHIFT32(nrgx, scale - scale1);
            nrgx      = Inlines.silk_max_int(nrgx, 1);
            corr      = Inlines.silk_inner_prod_aligned_scale(x, y, scale, length);
            pred_Q13  = Inlines.silk_DIV32_varQ(corr, nrgx, 13);
            pred_Q13  = Inlines.silk_LIMIT(pred_Q13, -(1 << 14), 1 << 14);
            pred2_Q10 = Inlines.silk_SMULWB(pred_Q13, pred_Q13);

            /* Faster update for signals with large prediction parameters */
            smooth_coef_Q16 = (int)Inlines.silk_max_int(smooth_coef_Q16, Inlines.silk_abs(pred2_Q10));

            /* Smoothed mid and residual norms */
            Inlines.OpusAssert(smooth_coef_Q16 < 32768);
            scale = Inlines.silk_RSHIFT(scale, 1);
            mid_res_amp_Q0[mid_res_amp_Q0_ptr] = Inlines.silk_SMLAWB(mid_res_amp_Q0[mid_res_amp_Q0_ptr],
                                                                     Inlines.silk_LSHIFT(Inlines.silk_SQRT_APPROX(nrgx), scale) - mid_res_amp_Q0[mid_res_amp_Q0_ptr], smooth_coef_Q16);
            /* Residual energy = nrgy - 2 * pred * corr + pred^2 * nrgx */
            nrgy = Inlines.silk_SUB_LSHIFT32(nrgy, Inlines.silk_SMULWB(corr, pred_Q13), 3 + 1);
            nrgy = Inlines.silk_ADD_LSHIFT32(nrgy, Inlines.silk_SMULWB(nrgx, pred2_Q10), 6);
            mid_res_amp_Q0[mid_res_amp_Q0_ptr + 1] = Inlines.silk_SMLAWB(mid_res_amp_Q0[mid_res_amp_Q0_ptr + 1],
                                                                         Inlines.silk_LSHIFT(Inlines.silk_SQRT_APPROX(nrgy), scale) - mid_res_amp_Q0[mid_res_amp_Q0_ptr + 1], smooth_coef_Q16);

            /* Ratio of smoothed residual and mid norms */
            ratio_Q14.Val = Inlines.silk_DIV32_varQ(mid_res_amp_Q0[mid_res_amp_Q0_ptr + 1], Inlines.silk_max(mid_res_amp_Q0[mid_res_amp_Q0_ptr], 1), 14);
            ratio_Q14.Val = Inlines.silk_LIMIT(ratio_Q14.Val, 0, 32767);

            return(pred_Q13);
        }
Ejemplo n.º 16
0
    private void OnValueChanged(object sender, EventArgs eventArgs)
    {
        if (_isUpdating)
        {
            return;
        }
        _isUpdating = true;
        var text = Text;

        if (string.IsNullOrEmpty(text))
        {
            return;
        }
        Inlines.Clear();
        UpdateInlines(text);
        _isUpdating = false;
    }
Ejemplo n.º 17
0
        internal static void ec_laplace_encode(EntropyCoder enc, ref int value, uint fs, int decay)
        {
            uint fl;
            int  val = value;

            fl = 0;
            if (val != 0)
            {
                int s;
                int i;
                s   = 0 - (val < 0 ? 1 : 0);
                val = (val + s) ^ s;
                fl  = fs;
                fs  = ec_laplace_get_freq1(fs, decay);

                /* Search the decaying part of the PDF.*/
                for (i = 1; fs > 0 && i < val; i++)
                {
                    fs *= 2;
                    fl += fs + 2 * LAPLACE_MINP;
                    fs  = (uint)((fs * (int)decay) >> 15);
                }

                /* Everything beyond that has probability LAPLACE_MINP. */
                if (fs == 0)
                {
                    int di;
                    int ndi_max;
                    ndi_max = (int)(32768 - fl + LAPLACE_MINP - 1) >> LAPLACE_LOG_MINP;
                    ndi_max = (ndi_max - s) >> 1;
                    di      = Inlines.IMIN(val - i, ndi_max - 1);
                    fl     += (uint)(2 * di + 1 + s) * LAPLACE_MINP;
                    fs      = Inlines.IMIN(LAPLACE_MINP, 32768 - fl);
                    value   = (i + di + s) ^ s;
                }
                else
                {
                    fs += LAPLACE_MINP;
                    fl += (uint)(fs & ~s);
                }
                Inlines.OpusAssert(fl + fs <= 32768);
                Inlines.OpusAssert(fs > 0);
            }

            enc.encode_bin(fl, fl + fs, 15);
        }
Ejemplo n.º 18
0
        internal static void smooth_fade(short[] in1, int in1_ptr, short[] in2, int in2_ptr,
                                         short[] output, int output_ptr, int overlap, int channels,
                                         int[] window, int Fs)
        {
            int i, c;
            int inc = 48000 / Fs;

            for (c = 0; c < channels; c++)
            {
                for (i = 0; i < overlap; i++)
                {
                    int w = Inlines.MULT16_16_Q15(window[i * inc], window[i * inc]);
                    output[output_ptr + (i * channels) + c] = (short)(Inlines.SHR32(Inlines.MAC16_16(Inlines.MULT16_16(w, in2[in2_ptr + (i * channels) + c]),
                                                                                                     CeltConstants.Q15ONE - w, in1[in1_ptr + (i * channels) + c]), 15));
                }
            }
        }
Ejemplo n.º 19
0
        internal static int loss_distortion(int[][] eBands, int[][] oldEBands, int start, int end, int len, int C)
        {
            int c, i;
            int dist = 0;

            c = 0;
            do
            {
                for (i = start; i < end; i++)
                {
                    int d = Inlines.SUB16(Inlines.SHR16(eBands[c][i], 3), Inlines.SHR16(oldEBands[c][i], 3));
                    dist = Inlines.MAC16_16(dist, d, d);
                }
            } while (++c < C);

            return(Inlines.MIN32(200, Inlines.SHR32(dist, 2 * CeltConstants.DB_SHIFT - 6)));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Chirp (bw expand) LP AR filter (Fixed point implementation)
        /// </summary>
        /// <param name="ar">I/O  AR filter to be expanded (without leading 1)</param>
        /// <param name="d">I length of ar</param>
        /// <param name="chirp">I    chirp factor (typically in range (0..1) )</param>
        internal static void silk_bwexpander(
            short[] ar,
            int d,
            int chirp_Q16)
        {
            int i;
            int chirp_minus_one_Q16 = chirp_Q16 - 65536;

            /* NB: Dont use silk_SMULWB, instead of silk_RSHIFT_ROUND( silk_MUL(), 16 ), below.  */
            /* Bias in silk_SMULWB can lead to unstable filters                                */
            for (i = 0; i < d - 1; i++)
            {
                ar[i]      = (short)Inlines.silk_RSHIFT_ROUND(Inlines.silk_MUL(chirp_Q16, ar[i]), 16);
                chirp_Q16 += Inlines.silk_RSHIFT_ROUND(Inlines.silk_MUL(chirp_Q16, chirp_minus_one_Q16), 16);
            }
            ar[d - 1] = (short)Inlines.silk_RSHIFT_ROUND(Inlines.silk_MUL(chirp_Q16, ar[d - 1]), 16);
        }
Ejemplo n.º 21
0
        internal static unsafe void kf_bfly2(int *Fout, int m, int N)
        {
            int *Fout2;
            int  i;
            {
                short tw;
                tw = ((short)(0.5 + (0.7071067812f) * (((int)1) << (15)))) /*Inlines.QCONST16(0.7071067812f, 15)*/;
                /* We know that m==4 here because the radix-2 is just after a radix-4 */
                Inlines.OpusAssert(m == 4);
                for (i = 0; i < N; i++)
                {
                    int t_r, t_i;
                    Fout2 = Fout + 8;
                    t_r   = *(Fout2);
                    t_i   = *(Fout2 + 1);
                    *Fout2 = (*Fout) - t_r;
                    *(Fout2 + 1) = *(Fout + 1) - t_i;
                    *Fout += t_r;
                    *(Fout + 1) += t_i;

                    t_r          = S_MUL(*(Fout2 + 2) + *(Fout2 + 3), tw);
                    t_i          = S_MUL(*(Fout2 + 3) - *(Fout2 + 2), tw);
                    *(Fout2 + 2) = *(Fout + 2) - t_r;
                    *(Fout2 + 3) = *(Fout + 3) - t_i;
                    *(Fout + 2) += t_r;
                    *(Fout + 3) += t_i;

                    t_r          = *(Fout2 + 5);
                    t_i          = 0 - *(Fout2 + 4);
                    *(Fout2 + 4) = *(Fout + 4) - t_r;
                    *(Fout2 + 5) = *(Fout + 5) - t_i;
                    *(Fout + 4) += t_r;
                    *(Fout + 5) += t_i;

                    t_r          = S_MUL(*(Fout2 + 7) - *(Fout2 + 6), tw);
                    t_i          = S_MUL(0 - *(Fout2 + 7) - *(Fout2 + 6), tw);
                    *(Fout2 + 6) = *(Fout + 6) - t_r;
                    *(Fout2 + 7) = *(Fout + 7) - t_i;
                    *(Fout + 6) += t_r;
                    *(Fout + 7) += t_i;

                    Fout += 16;
                }
            }
        }
Ejemplo n.º 22
0
        internal static void silk_warped_LPC_analysis_filter(
            int[] state,                    /* I/O  State [order + 1]                   */
            int[] res_Q2,                   /* O    Residual signal [length]            */
            short[] coef_Q13,               /* I    Coefficients [order]                */
            int coef_Q13_ptr,
            short[] input,                  /* I    Input signal [length]               */
            int input_ptr,
            short lambda_Q16,               /* I    Warping factor                      */
            int length,                     /* I    Length of input signal              */
            int order                       /* I    Filter order (even)                 */
            )
        {
            int n, i;
            int acc_Q11, tmp1, tmp2;

            /* Order must be even */
            Inlines.OpusAssert((order & 1) == 0);

            for (n = 0; n < length; n++)
            {
                /* Output of lowpass section */
                tmp2     = Inlines.silk_SMLAWB(state[0], state[1], lambda_Q16);
                state[0] = Inlines.silk_LSHIFT(input[input_ptr + n], 14);
                /* Output of allpass section */
                tmp1     = Inlines.silk_SMLAWB(state[1], state[2] - tmp2, lambda_Q16);
                state[1] = tmp2;
                acc_Q11  = Inlines.silk_RSHIFT(order, 1);
                acc_Q11  = Inlines.silk_SMLAWB(acc_Q11, tmp2, coef_Q13[coef_Q13_ptr]);
                /* Loop over allpass sections */
                for (i = 2; i < order; i += 2)
                {
                    /* Output of allpass section */
                    tmp2     = Inlines.silk_SMLAWB(state[i], state[i + 1] - tmp1, lambda_Q16);
                    state[i] = tmp1;
                    acc_Q11  = Inlines.silk_SMLAWB(acc_Q11, tmp1, coef_Q13[coef_Q13_ptr + i - 1]);
                    /* Output of allpass section */
                    tmp1         = Inlines.silk_SMLAWB(state[i + 1], state[i + 2] - tmp2, lambda_Q16);
                    state[i + 1] = tmp2;
                    acc_Q11      = Inlines.silk_SMLAWB(acc_Q11, tmp2, coef_Q13[coef_Q13_ptr + i]);
                }
                state[order] = tmp1;
                acc_Q11      = Inlines.silk_SMLAWB(acc_Q11, tmp1, coef_Q13[coef_Q13_ptr + order - 1]);
                res_Q2[n]    = Inlines.silk_LSHIFT((int)input[input_ptr + n], 2) - Inlines.silk_RSHIFT_ROUND(acc_Q11, 9);
            }
        }
Ejemplo n.º 23
0
        private void InitializeComponent()
        {
            foreach (var block in Splitter.Blocks)
            {
                Brush brush = null;
                switch (CurrentColor)
                {
                case 1:
                {
                    brush = Brushes.Blue;
                    CurrentColor++;
                    break;
                }

                case 2:
                {
                    brush = Brushes.Red;
                    CurrentColor++;
                    break;
                }

                case 3:
                {
                    brush = Brushes.Black;
                    CurrentColor++;
                    break;
                }

                case 4:
                {
                    brush        = Brushes.Green;
                    CurrentColor = 1;
                    break;
                }
                }
                var run = new Run(block.Block)
                {
                    Foreground = brush
                };
                Inlines.Add(run);
                //var dot = new Dot(this, run, brush);
                //Layer.Add(dot);
                //Dots.Add(dot);
            }
        }
Ejemplo n.º 24
0
        internal static void downmix_float(float[] x, int x_ptr, int[] sub, int sub_ptr, int subframe, int offset, int c1, int c2, int C)
        {
            int scale;
            int j;
            int c1x = c1 + x_ptr;

            for (j = 0; j < subframe; j++)
            {
                sub[sub_ptr + j] = Inlines.FLOAT2INT16(x[(j + offset) * C + c1x]);
            }
            if (c2 > -1)
            {
                int c2x = c2 + x_ptr;
                for (j = 0; j < subframe; j++)
                {
                    sub[sub_ptr + j] += Inlines.FLOAT2INT16(x[(j + offset) * C + c2x]);
                }
            }
            else if (c2 == -2)
            {
                int c;
                int cx;
                for (c = 1; c < C; c++)
                {
                    cx = c + x_ptr;
                    for (j = 0; j < subframe; j++)
                    {
                        sub[sub_ptr + j] += Inlines.FLOAT2INT16(x[(j + offset) * C + cx]);
                    }
                }
            }
            scale = (1 << CeltConstants.SIG_SHIFT);
            if (C == -2)
            {
                scale /= C;
            }
            else
            {
                scale /= 2;
            }
            for (j = 0; j < subframe; j++)
            {
                sub[sub_ptr + j] *= scale;
            }
        }
Ejemplo n.º 25
0
    private void UpdateInlines(string text)
    {
        //text = @"{Customer.Panel.field}";
        var runs = new List <Run>();
        var sb   = new StringBuilder();

        foreach (var current in text)
        {
            if (current.Equals('}') || current.Equals('{'))
            {
                if (sb.Length == 0)
                {
                    runs.Add(new Run
                    {
                        Text = current.ToString()
                    });
                }
                else
                {
                    runs.Add(new Run
                    {
                        Text       = sb.ToString(),
                        Foreground = Brushes.Red
                    });
                    runs.Add(new Run
                    {
                        Text = current.ToString()
                    });
                    sb.Clear();
                }
            }
            else
            {
                sb.Append(current);
            }
        }
        if (sb.Length > 0)
        {
            runs.Add(new Run {
                Text = sb.ToString(), Foreground = Brushes.Red
            });
        }
        runs.ForEach(run =>
                     Inlines.Add(run));
    }
Ejemplo n.º 26
0
        internal static void kf_bfly2(int[] Fout, int fout_ptr, int m, int N)
        {
            int Fout2;
            int i;
            {
                short tw;
                tw = ((short)(0.5 + (0.7071067812f) * (((int)1) << (15)))) /*Inlines.QCONST16(0.7071067812f, 15)*/;
                /* We know that m==4 here because the radix-2 is just after a radix-4 */
                Inlines.OpusAssert(m == 4);
                for (i = 0; i < N; i++)
                {
                    int t_r, t_i;
                    Fout2               = fout_ptr + 8;
                    t_r                 = Fout[Fout2 + 0];
                    t_i                 = Fout[Fout2 + 1];
                    Fout[Fout2 + 0]     = Fout[fout_ptr + 0] - t_r;
                    Fout[Fout2 + 1]     = Fout[fout_ptr + 1] - t_i;
                    Fout[fout_ptr + 0] += t_r;
                    Fout[fout_ptr + 1] += t_i;

                    t_r                 = S_MUL(Fout[Fout2 + 2] + Fout[Fout2 + 3], tw);
                    t_i                 = S_MUL(Fout[Fout2 + 3] - Fout[Fout2 + 2], tw);
                    Fout[Fout2 + 2]     = Fout[fout_ptr + 2] - t_r;
                    Fout[Fout2 + 3]     = Fout[fout_ptr + 3] - t_i;
                    Fout[fout_ptr + 2] += t_r;
                    Fout[fout_ptr + 3] += t_i;

                    t_r                 = Fout[Fout2 + 5];
                    t_i                 = 0 - Fout[Fout2 + 4];
                    Fout[Fout2 + 4]     = Fout[fout_ptr + 4] - t_r;
                    Fout[Fout2 + 5]     = Fout[fout_ptr + 5] - t_i;
                    Fout[fout_ptr + 4] += t_r;
                    Fout[fout_ptr + 5] += t_i;

                    t_r                 = S_MUL(Fout[Fout2 + 7] - Fout[Fout2 + 6], tw);
                    t_i                 = S_MUL(0 - Fout[Fout2 + 7] - Fout[Fout2 + 6], tw);
                    Fout[Fout2 + 6]     = Fout[fout_ptr + 6] - t_r;
                    Fout[Fout2 + 7]     = Fout[fout_ptr + 7] - t_i;
                    Fout[fout_ptr + 6] += t_r;
                    Fout[fout_ptr + 7] += t_i;

                    fout_ptr += 16;
                }
            }
        }
Ejemplo n.º 27
0
        private void UpdateContent(string newText)
        {
            Inlines.Clear();

            if (string.IsNullOrEmpty(newText))
            {
                return;
            }

            var patternGroup = HyperlinkPattern.GetPatternGroup(PatternType);

            var matches = new List <Tuple <Match, HyperlinkPattern> >();

            foreach (var pattern in patternGroup.Patterns)
            {
                var regex = new Regex(pattern.Pattern);

                foreach (Match match in regex.Matches(newText))
                {
                    matches.Add(new Tuple <Match, HyperlinkPattern>(match, pattern));
                }
            }

            matches = matches.OrderBy(m => m.Item1.Index).ToList();

            int last_pos = 0;

            foreach (var match in matches)
            {
                if (match.Item1.Index != last_pos)
                {
                    var raw_text = newText.Substring(last_pos, match.Item1.Index - last_pos);
                    Inlines.Add(new Run(raw_text));
                }

                Inlines.Add(MakeHyperlink(match.Item2.Url(match.Item1), match.Item2.Text(match.Item1)));

                last_pos = match.Item1.Index + match.Item1.Length;
            }

            if (last_pos < newText.Length)
            {
                Inlines.Add(new Run(newText.Substring(last_pos)));
            }
        }
Ejemplo n.º 28
0
        internal static int stereo_itheta(int[] X, int X_ptr, int[] Y, int Y_ptr, int stereo, int N)
        {
            int i;
            int itheta;
            int mid, side;
            int Emid, Eside;

            Emid = Eside = CeltConstants.EPSILON;
            if (stereo != 0)
            {
                for (i = 0; i < N; i++)
                {
                    int m, s;
                    m     = Inlines.ADD16(Inlines.SHR16(X[X_ptr + i], 1), Inlines.SHR16(Y[Y_ptr + i], 1));
                    s     = Inlines.SUB16(Inlines.SHR16(X[X_ptr + i], 1), Inlines.SHR16(Y[Y_ptr + i], 1));
                    Emid  = Inlines.MAC16_16(Emid, m, m);
                    Eside = Inlines.MAC16_16(Eside, s, s);
                }
            }
            else
            {
#if UNSAFE
                unsafe
                {
                    fixed(int *px_base = X, py_base = Y)
                    {
                        int *px = px_base + X_ptr;
                        int *py = py_base + Y_ptr;

                        Emid  += Kernels.celt_inner_prod(px, px, N);
                        Eside += Kernels.celt_inner_prod(py, py, N);
                    }
                }
#else
                Emid  += Kernels.celt_inner_prod(X, X_ptr, X, X_ptr, N);
                Eside += Kernels.celt_inner_prod(Y, Y_ptr, Y, Y_ptr, N);
#endif
            }
            mid  = (Inlines.celt_sqrt(Emid));
            side = (Inlines.celt_sqrt(Eside));
            /* 0.63662 = 2/pi */
            itheta = Inlines.MULT16_16_Q15(((short)(0.5 + (0.63662f) * (((int)1) << (15)))) /*Inlines.QCONST16(0.63662f, 15)*/, Inlines.celt_atan2p(side, mid));

            return(itheta);
        }
Ejemplo n.º 29
0
        protected void SetPlaceholder()
        {
            Inlines.Clear();
            var placeholder = Placeholder;

            if (!string.IsNullOrEmpty(placeholder))
            {
                var inline = new Run {
                    Text = placeholder
                };
                inline.SetBinding(TextElement.ForegroundProperty, new Binding {
                    Path      = new PropertyPath(nameof(Foreground)),
                    Source    = this,
                    Converter = this
                });
                Inlines.Add(inline);
            }
        }
Ejemplo n.º 30
0
        internal static void opus_fft(FFTState st, int[] fin, int[] fout)
        {
            int i;
            /* Allows us to scale with MULT16_32_Q16() */
            int   scale_shift = st.scale_shift - 1;
            short scale       = st.scale;

            Inlines.OpusAssert(fin != fout, "In-place FFT not supported");

            /* Bit-reverse the input */
            for (i = 0; i < st.nfft; i++)
            {
                fout[(2 * st.bitrev[i])]     = Inlines.SHR32(Inlines.MULT16_32_Q16(scale, fin[(2 * i)]), scale_shift);
                fout[(2 * st.bitrev[i] + 1)] = Inlines.SHR32(Inlines.MULT16_32_Q16(scale, fin[(2 * i) + 1]), scale_shift);
            }

            opus_fft_impl(st, fout, 0);
        }