本文整理汇总了C++中shr函数的典型用法代码示例。如果您正苦于以下问题:C++ shr函数的具体用法?C++ shr怎么用?C++ shr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dec3_10
void dec3_10(
Shortword index, /* (i) : indx of 3 pulses (10 bits) */
Shortword cod[], /* (o) Q12: algebraic (fixed) codebook excitation */
Shortword l_subfr /* (i) : lenght of subframe (53 or 54) */
)
{
Shortword i, pos, gsign, sign;
for (i = 0; i < l_subfr; i++)
cod[i] = 0;
if ((index & 0x0200) != 0)
gsign = -1;
else
gsign = 1;
for (i = 4; i >= 0; i -= 2)
{
pos = add(shr(extract_l(L_mult((index & 0x0007), STEP)), 1), i);
if (i == 2)
sign = negate(gsign);
else
sign = gsign;
if (pos < l_subfr)
cod[pos] = sign;
index = shr(index, 3);
}
return;
}
示例2: decode_4i40_17bits
void decode_4i40_17bits(
Word16 sign, /* i : signs of 4 pulses. */
Word16 index, /* i : Positions of the 4 pulses. */
Word16 cod[] /* o : algebraic (fixed) codebook excitation */
)
{
Word16 i, j;
Word16 pos[NB_PULSE];
/* Decode the positions */
i = index & 7; logic16 ();
i = dgray[i]; move16 ();
pos[0] = add(i, shl(i, 2)); /* pos0 =i*5 */ move16 ();
index = shr(index, 3);
i = index & 7; logic16 ();
i = dgray[i]; move16 ();
i = add(i, shl(i, 2)); /* pos1 =i*5+1 */
pos[1] = add(i, 1); move16 ();
index = shr(index, 3);
i = index & 7; logic16 ();
i = dgray[i]; move16 ();
i = add(i, shl(i, 2)); /* pos2 =i*5+1 */
pos[2] = add(i, 2); move16 ();
index = shr(index, 3);
j = index & 1; logic16 ();
index = shr(index, 1);
i = index & 7; logic16 ();
i = dgray[i]; move16 ();
i = add(i, shl(i, 2)); /* pos3 =i*5+3+j */
i = add(i, 3);
pos[3] = add(i, j); move16 ();
/* decode the signs and build the codeword */
for (i = 0; i < L_SUBFR; i++) {
cod[i] = 0; move16 ();
}
for (j = 0; j < NB_PULSE; j++) {
i = sign & 1; logic16 ();
sign = shr(sign, 1);
test ();
if (i != 0) {
cod[pos[j]] = 8191; move16 ();
} else {
cod[pos[j]] = -8192; move16 ();
}
}
return;
}
示例3: decode64
int decode64 (unsigned char *dst, int size, char *src)
{
unsigned char *sptr = (unsigned char *) src;
unsigned char *dptr = dst;
unsigned char *end = dst + size;
unsigned char c1, c2, c3, c4;
do
{
c1 = char64(*sptr);
c2 = char64(*(sptr + 1));
if (c1 == 255 || c2 == 255) break;
*dptr++ = shl(c1, 2) | shr((c2 & 0x30), 4);
if (dptr >= end) break;
c3 = char64(*(sptr + 2));
if (c3 == 255) break;
*dptr++ = shl((c2 & 0x0f), 4) | shr((c3 & 0x3c), 2);
if (dptr >= end) break;
c4 = char64(*(sptr + 3));
if (c4 == 255) break;
*dptr++ = shl((c3 & 0x03), 6) | c4;
sptr += 4;
}
while (dptr < end);
return (dptr - dst);
}
示例4: sqrts
Word16 sqrts(Word16 x)
{
Word16 xb, y, exp, idx, sub_frac, sub_tab;
Word32 a0;
if(x <= 0){
y = 0;
}
else{
exp = norm_s(x);
/* use 65-entry table */
xb = shl(x, exp); // normalization of x
idx = shr(xb, 9); // for 65 entry table
a0 = L_deposit_h(tabsqrt[idx]); // Q31 table look-up value
sub_frac = shl((Word16)(xb & 0x01FF), 6); // Q15 sub-fraction
sub_tab = sub(tabsqrt[idx+1], tabsqrt[idx]); // Q15 table interval for interpolation
a0 = L_mac(a0, sub_frac, sub_tab); // Q31 linear interpolation between table entries
if(exp & 0x0001){
exp = shr(add(exp, 1), 1); // normalization of sqrt()
a0 = L_shr(a0, exp);
y = intround(a0); // Q15
a0 = L_mac(a0, 13573, y); // Q31 incorporate the missing "/sqrt(2)"
}
else{
exp = shr(exp, 1); // normalization of sqrt()
a0 = L_shr(a0, exp); // Q31
}
y = intround(a0); // Q15
}
return y;
}
示例5: Int_lpc
void Int_lpc(
Word16 lsp_old[], /* input : LSP vector of past frame */
Word16 lsp_new[], /* input : LSP vector of present frame */
Word16 lsf_int[], /* output: interpolated lsf coefficients */
Word16 lsf_new[],
Word16 Az[] /* output: interpolated Az() for the 2 subframes */
)
{
Word16 i;
Word16 lsp[M];
/* lsp[i] = lsp_new[i] * 0.5 + lsp_old[i] * 0.5 */
for (i = 0; i < M; i++) {
lsp[i] = add(shr(lsp_new[i], 1), shr(lsp_old[i], 1));
}
Lsp_Az(lsp, Az);
Lsp_lsf(lsp, lsf_int, M); /* transformation from LSP to LSF (freq.domain) */
Lsp_lsf(lsp_new, lsf_new, M); /* transformation from LSP to LSF (freq.domain) */
return;
}
示例6: Decod_ACELP
void Decod_ACELP(
Word16 sign, /* (i) : signs of 4 pulses. */
Word16 index, /* (i) : Positions of the 4 pulses. */
Word16 cod[] /* (o) Q13 : algebraic (fixed) codebook excitation */
)
{
Word16 i, j;
Word16 pos[4];
/* Decode the positions */
i = index & (Word16)7;
pos[0] = add(i, shl(i, 2)); /* pos0 =i*5 */
index = shr(index, 3);
i = index & (Word16)7;
i = add(i, shl(i, 2)); /* pos1 =i*5+1 */
pos[1] = add(i, 1);
index = shr(index, 3);
i = index & (Word16)7;
i = add(i, shl(i, 2)); /* pos2 =i*5+1 */
pos[2] = add(i, 2);
index = shr(index, 3);
j = index & (Word16)1;
index = shr(index, 1);
i = index & (Word16)7;
i = add(i, shl(i, 2)); /* pos3 =i*5+3+j */
i = add(i, 3);
pos[3] = add(i, j);
/* decode the signs and build the codeword */
for (i=0; i<L_SUBFR; i++) {
cod[i] = 0;
}
for (j=0; j<4; j++)
{
i = sign & (Word16)1;
sign = shr(sign, 1);
if (i != 0) {
cod[pos[j]] = 8191; /* Q13 +1.0 */
}
else {
cod[pos[j]] = -8192; /* Q13 -1.0 */
}
}
return;
}
示例7: Bitpack_newu
uint64_t Bitpack_newu(uint64_t word, unsigned width, unsigned lsb,
uint64_t value)
{
unsigned hi = lsb + width; /* one beyond the most significant bit */
assert(hi <= 64);
if (!Bitpack_fitsu(value, width))
RAISE(Bitpack_Overflow);
return shl(shr(word, hi), hi) /* high part */
| shr(shl(word, 64 - lsb), 64 - lsb) /* low part */
| (value << lsb); /* new part */
}
示例8: gmul
/** Performs a carryless multiplication of two 128bit integers modulo \f$ x^{128} + x^7 + x^2 + x + 1 \f$ */
static __m128i gmul(__m128i v, __m128i h) {
/* multiply */
__m128i z0, z1, z2, tmp;
z0 = _mm_clmulepi64_si128(v, h, 0x11);
z2 = _mm_clmulepi64_si128(v, h, 0x00);
__m128i tmpv = _mm_srli_si128(v, 8);
tmpv = _mm_xor_si128(tmpv, v);
__m128i tmph = _mm_srli_si128(h, 8);
tmph = _mm_xor_si128(tmph, h);
z1 = _mm_clmulepi64_si128(tmpv, tmph, 0x00);
z1 = _mm_xor_si128(z1, z0);
z1 = _mm_xor_si128(z1, z2);
tmp = _mm_srli_si128(z1, 8);
__m128i pl = _mm_xor_si128(z0, tmp);
tmp = _mm_slli_si128(z1, 8);
__m128i ph = _mm_xor_si128(z2, tmp);
tmp = _mm_srli_epi64(ph, 63);
tmp = _mm_srli_si128(tmp, 8);
pl = shl(pl, 1);
pl = _mm_xor_si128(pl, tmp);
ph = shl(ph, 1);
/* reduce */
__m128i b, c;
b = c = _mm_slli_si128(ph, 8);
b = _mm_slli_epi64(b, 62);
c = _mm_slli_epi64(c, 57);
tmp = _mm_xor_si128(b, c);
__m128i d = _mm_xor_si128(ph, tmp);
__m128i e = shr(d, 1);
__m128i f = shr(d, 2);
__m128i g = shr(d, 7);
pl = _mm_xor_si128(pl, d);
pl = _mm_xor_si128(pl, e);
pl = _mm_xor_si128(pl, f);
pl = _mm_xor_si128(pl, g);
return pl;
}
示例9: WebRtcG729fix_Lsf_lsp2
void WebRtcG729fix_Lsf_lsp2(
int16_t lsf[], /* (i) Q13 : lsf[m] (range: 0.0<=val<PI) */
int16_t lsp[], /* (o) Q15 : lsp[m] (range: -1<=val<1) */
int16_t m /* (i) : LPC order */
)
{
int16_t i, ind;
int16_t offset; /* in Q8 */
int16_t freq; /* normalized frequency in Q15 */
int32_t L_tmp;
for(i=0; i<m; i++)
{
/* freq = abs_s(freq);*/
freq = mult(lsf[i], 20861); /* 20861: 1.0/(2.0*PI) in Q17 */
ind = shr(freq, 8); /* ind = b8-b15 of freq */
offset = freq & (int16_t)0x00ff; /* offset = b0-b7 of freq */
if (ind > 63){
ind = 63; /* 0 <= ind <= 63 */
}
/* lsp[i] = table2[ind]+ (slope_cos[ind]*offset >> 12) */
L_tmp = L_mult(WebRtcG729fix_slope_cos[ind], offset); /* L_tmp in Q28 */
lsp[i] = WebRtcSpl_AddSatW16(WebRtcG729fix_table2[ind], extract_l(L_shr(L_tmp, 13)));
}
}
示例10: get_pq_polynomials
void get_pq_polynomials(
Word32 *f, /* Q23 */
Word16 *lsp) /* Q15 */
{
Word16 i, n, hi, lo;
Word16 index, offset, coslsp, c;
Word32 a0;
f[0] = L_mult(2048, 2048); // 1.0 Q23
for(i = 1; i <= LPCO ; i++)
f[i]= 0;
for(n=1; n<=(LPCO>>1); n++) {
/* cosine mapping */
index = shr(lsp[2*n-2],9); // Q6
offset = lsp[2*n-2]&(Word16)0x01ff; // Q9
a0 = L_mult(sub(costable[index+1], costable[index]), offset); // Q10
coslsp = add(costable[index], intround(L_shl(a0, 6))); // Q15 cos((double)PI*lsp[2*n-2])
c = coslsp; // Q14 c = 2. * cos((double)PI*lsp[2*n-2])
for(i = 2*n; i >= 2; i--) {
L_Extract(f[i-1], &hi, &lo);
f[i] = L_add(f[i], f[i-2]); // Q23 f[i] += f[i-2]
a0 = Mpy_32_16(hi, lo, c); // Q22
f[i] = L_sub(f[i], L_shl(a0,1)); // Q23 f[i] += f[i-2] - c*f[i-1];
}
f[1] = L_msu(f[1], c, 256); // Q23 f[1] -= c;
}
return;
}
示例11: ngen_CC_param
void ngen_CC_param(shil_opcode& op, shil_param& prm, CanonicalParamType tp) {
switch (tp)
{
case CPT_u32:
case CPT_ptr:
case CPT_f32:
{
CC_PS t = { tp, &prm };
CC_pars.push_back(t);
}
break;
//store from EAX
case CPT_u64rvL:
case CPT_u32rv:
mov(rcx, rax);
reg_to_sh(prm, ecx);
break;
case CPT_u64rvH:
shr(rcx, 32);
reg_to_sh(prm, ecx);
break;
//Store from ST(0)
case CPT_f32rv:
reg_to_sh_ss(prm, xmm0);
break;
}
}
示例12: build_CN_code
/***************************************************************************
*
* Function : build_CN_code
*
***************************************************************************/
void build_CN_code (
Word32 *seed, /* i/o : Old CN generator shift register state */
Word16 cod[] /* o : Generated CN fixed codebook vector */
)
{
Word16 i, j, k;
for (i = 0; i < L_SUBFR; i++)
{
cod[i] = 0;
}
for (k = 0; k < NB_PULSE10; k++)
{
i = pseudonoise (seed, 2); /* generate pulse position */
i = shr (extract_l (L_mult (i, 10)), 1);
i = i + k;
j = pseudonoise (seed, 1); /* generate sign */
if (j > 0)
{
cod[i] = 4096;
}
else
{
cod[i] = -4096;
}
}
return;
}
示例13: Code
Code()
{
Xbyak::Label label;
cmpss(xmm0, ptr[rip + label], 0);
test(dword[rip + label], 33);
bt(dword[rip + label ], 3);
vblendpd(xmm0, dword[rip + label], 3);
vpalignr(xmm0, qword[rip + label], 4);
vextractf128(dword[rip + label], ymm3, 12);
vperm2i128(ymm0, ymm1, qword[rip + label], 13);
vcvtps2ph(ptr[rip + label], xmm2, 44);
mov(dword[rip + label], 0x1234);
shl(dword[rip + label], 3);
shr(dword[rip + label], 1);
shld(qword[rip + label], rax, 3);
imul(rax, qword[rip + label], 21);
rorx(rax, qword[rip + label], 21);
test(dword[rip + label], 5);
pextrq(ptr[rip + label], xmm0, 3);
pinsrq(xmm2, ptr[rip + label], 5);
pextrw(ptr[rip + label], xmm1, 4);
adc(dword[rip + label], 0x12345);
bt(byte[rip + label], 0x34);
btc(word[rip + label], 0x34);
btr(dword[rip + label], 0x34);
rcl(dword[rip + label], 4);
shld(qword[rip + label], rax, 4);
palignr(mm0, ptr[rip + label], 4);
aeskeygenassist(xmm3, ptr[rip + label], 4);
vpcmpestrm(xmm2, ptr[rip + label], 7);
ret();
L(label);
dq(0x123456789abcdef0ull);
};
示例14: get_op_code
static inline uint32_t get_op_code(uint32_t word)
{
return shr(shl(word, 64 - 32), 64 - 4);
/*Bitpack_getu(word, OP_CODE_LENGTH,
(WORD_LENGTH - OP_CODE_LENGTH));*/
}
示例15: Int2bin
static void Int2bin (
Word16 value, /* input : value to be converted to binary */
Word16 no_of_bits, /* input : number of bits associated with value */
Word16 *bitstream /* output: address where bits are written */
)
{
Word16 *pt_bitstream, i, bit;
pt_bitstream = &bitstream[no_of_bits];
for (i = 0; i < no_of_bits; i++)
{
bit = value & MASK;
if (bit == 0)
{
*--pt_bitstream = BIT_0;
}
else
{
*--pt_bitstream = BIT_1;
}
value = shr (value, 1);
}
}