本文整理汇总了C#中org.pack方法的典型用法代码示例。如果您正苦于以下问题:C# org.pack方法的具体用法?C# org.pack怎么用?C# org.pack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org
的用法示例。
在下文中一共展示了org.pack方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: quant
/// <summary>Line Spectral Pair Quantification (Lbr).</summary>
/// <remarks>Line Spectral Pair Quantification (Lbr).</remarks>
/// <param name="lsp">- Line Spectral Pairs table.</param>
/// <param name="qlsp">- Quantified Line Spectral Pairs table.</param>
/// <param name="order"></param>
/// <param name="bits">- Speex bits buffer.</param>
public override sealed void quant(float[] lsp, float[] qlsp, int order, org.xiph.speex.Bits
bits)
{
int i;
float tmp1;
float tmp2;
int id;
float[] quant_weight = new float[MAX_LSP_SIZE];
for (i = 0; i < order; i++)
{
qlsp[i] = lsp[i];
}
quant_weight[0] = 1 / (qlsp[1] - qlsp[0]);
quant_weight[order - 1] = 1 / (qlsp[order - 1] - qlsp[order - 2]);
for (i = 1; i < order - 1; i++)
{
tmp1 = 1 / ((.15f + qlsp[i] - qlsp[i - 1]) * (.15f + qlsp[i] - qlsp[i - 1]));
tmp2 = 1 / ((.15f + qlsp[i + 1] - qlsp[i]) * (.15f + qlsp[i + 1] - qlsp[i]));
quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
}
for (i = 0; i < order; i++)
{
qlsp[i] -= (.25f * i + .25f);
}
for (i = 0; i < order; i++)
{
qlsp[i] *= 256;
}
id = lsp_quant(qlsp, 0, cdbk_nb, NB_CDBK_SIZE, order);
bits.pack(id, 6);
for (i = 0; i < order; i++)
{
qlsp[i] *= 2;
}
id = lsp_weight_quant(qlsp, 0, quant_weight, 0, cdbk_nb_low1, NB_CDBK_SIZE_LOW1,
5);
bits.pack(id, 6);
id = lsp_weight_quant(qlsp, 5, quant_weight, 5, cdbk_nb_high1, NB_CDBK_SIZE_HIGH1
, 5);
bits.pack(id, 6);
for (i = 0; i < order; i++)
{
qlsp[i] *= 0.0019531f;
}
for (i = 0; i < order; i++)
{
qlsp[i] = lsp[i] - qlsp[i];
}
}
示例2: quant
/// <summary>Line Spectral Pair Quantification (high).</summary>
/// <remarks>Line Spectral Pair Quantification (high).</remarks>
/// <param name="lsp">- Line Spectral Pairs table.</param>
/// <param name="qlsp">- Quantified Line Spectral Pairs table.</param>
/// <param name="order"></param>
/// <param name="bits">- Speex bits buffer.</param>
public override sealed void quant(float[] lsp, float[] qlsp, int order, org.xiph.speex.Bits
bits)
{
int i;
float tmp1;
float tmp2;
int id;
float[] quant_weight = new float[MAX_LSP_SIZE];
for (i = 0; i < order; i++)
{
qlsp[i] = lsp[i];
}
quant_weight[0] = 1 / (qlsp[1] - qlsp[0]);
quant_weight[order - 1] = 1 / (qlsp[order - 1] - qlsp[order - 2]);
for (i = 1; i < order - 1; i++)
{
tmp1 = 1 / (qlsp[i] - qlsp[i - 1]);
tmp2 = 1 / (qlsp[i + 1] - qlsp[i]);
quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
}
for (i = 0; i < order; i++)
{
qlsp[i] -= (.3125f * i + .75f);
}
for (i = 0; i < order; i++)
{
qlsp[i] *= 256;
}
id = lsp_quant(qlsp, 0, high_lsp_cdbk, 64, order);
bits.pack(id, 6);
for (i = 0; i < order; i++)
{
qlsp[i] *= 2;
}
id = lsp_weight_quant(qlsp, 0, quant_weight, 0, high_lsp_cdbk2, 64, order);
bits.pack(id, 6);
for (i = 0; i < order; i++)
{
qlsp[i] *= 0.0019531f;
}
for (i = 0; i < order; i++)
{
qlsp[i] = lsp[i] - qlsp[i];
}
}
示例3: encode
// private float reserved1; /** Reserved for future use */
// private float reserved2; /** Reserved for future use */
/// <summary>
/// Transforms a stereo frame into a mono frame and stores intensity stereo
/// info in 'bits'.
/// </summary>
/// <remarks>
/// Transforms a stereo frame into a mono frame and stores intensity stereo
/// info in 'bits'.
/// </remarks>
/// <param name="bits">- Speex bits buffer.</param>
/// <param name="data"></param>
/// <param name="frameSize"></param>
public static void encode(org.xiph.speex.Bits bits, float[] data, int frameSize)
{
int i;
int tmp;
float e_left = 0;
float e_right = 0;
float e_tot = 0;
float balance;
float e_ratio;
for (i = 0; i < frameSize; i++)
{
e_left += data[2 * i] * data[2 * i];
e_right += data[2 * i + 1] * data[2 * i + 1];
data[i] = .5f * (data[2 * i] + data[2 * i + 1]);
e_tot += data[i] * data[i];
}
balance = (e_left + 1) / (e_right + 1);
e_ratio = e_tot / (1 + e_left + e_right);
bits.pack(14, 5);
bits.pack(SPEEX_INBAND_STEREO, 4);
balance = (float)(4 * System.Math.Log(balance));
if (balance > 0)
{
bits.pack(0, 1);
}
else
{
bits.pack(1, 1);
}
balance = (float)System.Math.Floor(.5f + System.Math.Abs(balance));
if (balance > 30)
{
balance = 31;
}
bits.pack((int)balance, 5);
tmp = org.xiph.speex.VQ.index(e_ratio, e_ratio_quant, 4);
bits.pack(tmp, 2);
}
示例4: quant
//.........这里部分代码省略.........
{
float g;
//int rind;
//float sign = 1;
sign = 1;
rind = best_index[k];
if (rind >= shape_cb_size)
{
sign = -1;
rind -= shape_cb_size;
}
g = sign * 0.03125f * shape_cb[rind * subvect_size + m];
q = subvect_size - m;
for (n = offset + subvect_size; n < nsf; n++, q++)
{
t[n] -= g * r[q];
}
}
for (m = 0; m < N; m++)
{
if (err < ndist[m] || ndist[m] < -0.5f)
{
for (n = N - 1; n > m; n--)
{
for (q = offset + subvect_size; q < nsf; q++)
{
nt[n][q] = nt[n - 1][q];
}
for (q = 0; q < nb_subvect; q++)
{
nind[n][q] = nind[n - 1][q];
}
ndist[n] = ndist[n - 1];
}
for (q = offset + subvect_size; q < nsf; q++)
{
nt[m][q] = t[q];
}
for (q = 0; q < nb_subvect; q++)
{
nind[m][q] = oind[j][q];
}
nind[m][i] = best_index[k];
ndist[m] = err;
break;
}
}
}
}
if (i == 0)
{
break;
}
}
float[][] tmp2;
tmp2 = ot;
ot = nt;
nt = tmp2;
for (j = 0; j < N; j++)
{
for (m = 0; m < nb_subvect; m++)
{
oind[j][m] = nind[j][m];
}
}
for (j = 0; j < N; j++)
{
odist[j] = ndist[j];
}
}
for (i = 0; i < nb_subvect; i++)
{
ind[i] = nind[0][i];
bits.pack(ind[i], shape_bits + have_sign);
}
for (i = 0; i < nb_subvect; i++)
{
int rind;
float sign = 1;
rind = ind[i];
if (rind >= shape_cb_size)
{
sign = -1;
rind -= shape_cb_size;
}
for (j = 0; j < subvect_size; j++)
{
e[subvect_size * i + j] = sign * 0.03125f * shape_cb[rind * subvect_size + j];
}
}
for (j = 0; j < nsf; j++)
{
exc[es + j] += e[j];
}
org.xiph.speex.Filters.syn_percep_zero(e, 0, ak, awk1, awk2, r2, nsf, p);
for (j = 0; j < nsf; j++)
{
target[j] -= r2[j];
}
}
示例5: encode
//.........这里部分代码省略.........
abr_drift += (bitrate - abr_enabled);
abr_drift2 = .95f * abr_drift2 + .05f * (bitrate - abr_enabled);
abr_count += 1.0f;
}
}
else
{
int mode;
if (relative_quality < 2)
{
if (dtx_count == 0 || lsp_dist > .05 || dtx_enabled == 0 || dtx_count > 20)
{
dtx_count = 1;
mode = 1;
}
else
{
mode = 0;
dtx_count++;
}
}
else
{
dtx_count = 0;
mode = submodeSelect;
}
submodeID = mode;
}
}
else
{
relative_quality = -1;
}
bits.pack(0, 1);
bits.pack(submodeID, NB_SUBMODE_BITS);
if (submodes[submodeID] == null)
{
for (i = 0; i < frameSize; i++)
{
excBuf[excIdx + i] = exc2Buf[exc2Idx + i] = swBuf[swIdx + i] = VERY_SMALL;
}
for (i = 0; i < lpcSize; i++)
{
mem_sw[i] = 0;
}
first = 1;
bounded_pitch = 1;
org.xiph.speex.Filters.iir_mem2(excBuf, excIdx, interp_qlpc, frmBuf, frmIdx, frameSize
, lpcSize, mem_sp);
@in[0] = frmBuf[frmIdx] + preemph * pre_mem2;
for (i = 1; i < frameSize; i++)
{
@in[i] = frmBuf[frmIdx + i] + preemph * @in[i - 1];
}
pre_mem2 = @in[frameSize - 1];
return 0;
}
if (first != 0)
{
for (i = 0; i < lpcSize; i++)
{
old_lsp[i] = lsp[i];
}
}
//#if 1 /*0 for unquantized*/
submodes[submodeID].lsqQuant.quant(lsp, qlsp, lpcSize, bits);
示例6: quant
/// <summary>Long Term Prediction Quantification (3Tap).</summary>
/// <remarks>Long Term Prediction Quantification (3Tap).</remarks>
/// <returns>pitch</returns>
public override sealed int quant(float[] target, float[] sw, int sws, float[] ak,
float[] awk1, float[] awk2, float[] exc, int es, int start, int end, float pitch_coef
, int p, int nsf, org.xiph.speex.Bits bits, float[] exc2, int e2s, float[] r, int
complexity)
{
int i;
int j;
int[] cdbk_index = new int[1];
int pitch = 0;
int best_gain_index = 0;
float[] best_exc;
int best_pitch = 0;
float err;
float best_err = -1;
int N;
int[] nbest;
float[] gains;
N = complexity;
if (N > 10)
{
N = 10;
}
nbest = new int[N];
gains = new float[N];
if (N == 0 || end < start)
{
bits.pack(0, pitch_bits);
bits.pack(0, gain_bits);
for (i = 0; i < nsf; i++)
{
exc[es + i] = 0;
}
return start;
}
best_exc = new float[nsf];
if (N > end - start + 1)
{
N = end - start + 1;
}
open_loop_nbest_pitch(sw, sws, start, end, nsf, nbest, gains, N);
for (i = 0; i < N; i++)
{
pitch = nbest[i];
for (j = 0; j < nsf; j++)
{
exc[es + j] = 0;
}
err = pitch_gain_search_3tap(target, ak, awk1, awk2, exc, es, pitch, p, nsf, bits
, exc2, e2s, r, cdbk_index);
if (err < best_err || best_err < 0)
{
for (j = 0; j < nsf; j++)
{
best_exc[j] = exc[es + j];
}
best_err = err;
best_pitch = pitch;
best_gain_index = cdbk_index[0];
}
}
bits.pack(best_pitch - start, pitch_bits);
bits.pack(best_gain_index, gain_bits);
for (i = 0; i < nsf; i++)
{
exc[es + i] = best_exc[i];
}
return pitch;
}
示例7: encode
//.........这里部分代码省略.........
thresh = (vbr_quality - v1) * org.xiph.speex.Vbr.hb_thresh[modeid][v1 + 1] + (1 +
v1 - vbr_quality) * org.xiph.speex.Vbr.hb_thresh[modeid][v1];
}
if (relative_quality >= thresh)
{
break;
}
modeid--;
}
setMode(modeid);
if (abr_enabled != 0)
{
int bitrate;
bitrate = getBitRate();
abr_drift += (bitrate - abr_enabled);
abr_drift2 = .95f * abr_drift2 + .05f * (bitrate - abr_enabled);
abr_count += 1.0f;
}
}
else
{
int modeid;
if (relative_quality < 2.0)
{
modeid = 1;
}
else
{
modeid = submodeSelect;
}
submodeID = modeid;
}
}
bits.pack(1, 1);
if (dtx != 0)
{
bits.pack(0, SB_SUBMODE_BITS);
}
else
{
bits.pack(submodeID, SB_SUBMODE_BITS);
}
if (dtx != 0 || submodes[submodeID] == null)
{
for (i = 0; i < frameSize; i++)
{
excBuf[excIdx + i] = swBuf[i] = VERY_SMALL;
}
for (i = 0; i < lpcSize; i++)
{
mem_sw[i] = 0;
}
first = 1;
org.xiph.speex.Filters.iir_mem2(excBuf, excIdx, interp_qlpc, high, 0, subframeSize
, 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++)
{
@in[i] = 2 * (y0[i] - y1[i]);
}
if (dtx != 0)
{
return 0;
}
else