本文整理汇总了C++中sign_extend函数的典型用法代码示例。如果您正苦于以下问题:C++ sign_extend函数的具体用法?C++ sign_extend怎么用?C++ sign_extend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sign_extend函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dec_bi
static void dec_bi(DisasContext *dc)
{
LOG_DIS("bi %d\n", sign_extend(dc->imm26 << 2, 26));
gen_goto_tb(dc, 0, dc->pc + (sign_extend(dc->imm26 << 2, 26)));
dc->is_jmp = DISAS_TB_JUMP;
}
示例2: dec_calli
static void dec_calli(DisasContext *dc)
{
LOG_DIS("calli %d\n", sign_extend(dc->imm26, 26) * 4);
tcg_gen_movi_tl(cpu_R[R_RA], dc->pc + 4);
gen_goto_tb(dc, 0, dc->pc + (sign_extend(dc->imm26 << 2, 26)));
dc->is_jmp = DISAS_TB_JUMP;
}
示例3: dec_lw
static void dec_lw(DisasContext *dc)
{
TCGv t0;
LOG_DIS("lw r%d, (r%d+%d)\n", dc->r1, dc->r0, sign_extend(dc->imm16, 16));
t0 = tcg_temp_new();
tcg_gen_addi_tl(t0, cpu_R[dc->r0], sign_extend(dc->imm16, 16));
tcg_gen_qemu_ld32s(cpu_R[dc->r1], t0, MEM_INDEX);
tcg_temp_free(t0);
}
示例4: dec_sw
static void dec_sw(DisasContext *dc)
{
TCGv t0;
LOG_DIS("sw (r%d+%d), r%d\n", dc->r0, sign_extend(dc->imm16, 16), dc->r1);
t0 = tcg_temp_new();
tcg_gen_addi_tl(t0, cpu_R[dc->r0], sign_extend(dc->imm16, 16));
tcg_gen_qemu_st32(cpu_R[dc->r1], t0, MEM_INDEX);
tcg_temp_free(t0);
}
示例5: sensor_convert_from_raw
/**
* sensor_convert_from_raw: convert raw sensor values to interpreted values.
* It can be used to convert raw data, raw thresholds or raw hysteresis of a sensor
* to human readable format.
*
* @sensor: sensor.
* @val: raw sensor value.
* @result: the interpreted value
*
* Return value: SA_OK if conversion possible
**/
SaErrorT
sensor_convert_from_raw (SaHpiSensorRecT *sensor,
SaHpiUint32T val,
SaHpiFloat32T *result)
{
SaHpiFloat32T m, b, b_exp, r_exp, fval;
linearizer c_func;
SaHpiSensorFactorsT *factors = &sensor->DataFormat.Factors;
if ( factors->Linearization == SAHPI_SL_NONLINEAR )
c_func = c_linear;
else if ( factors->Linearization <= 11 )
c_func = linearize[factors->Linearization];
else
return SA_ERR_HPI_INVALID_DATA;
val &= 0xff;
m = (SaHpiFloat32T)factors->M_Factor;
b = (SaHpiFloat32T)factors->B_Factor;
r_exp = (SaHpiFloat32T)factors->ExpR;
b_exp = (SaHpiFloat32T)factors->ExpB;
switch( sensor->DataFormat.SignFormat ) {
case SAHPI_SDF_UNSIGNED:
fval = (SaHpiFloat32T)val;
break;
case SAHPI_SDF_1S_COMPLEMENT:
val = sign_extend( val, 8 );
if ( val < 0 )
val += 1;
fval = (SaHpiFloat32T)val;
break;
case SAHPI_SDF_2S_COMPLEMENT:
fval = (SaHpiFloat32T)sign_extend( val, 8 );
break;
default:
return SA_ERR_HPI_INVALID_DATA;
}
*result = c_func( ((m * fval) + (b * pow(10, b_exp)))
* pow(10, r_exp) );
return SA_OK;
}
示例6: dec_bg
static void dec_bg(DisasContext *dc)
{
LOG_DIS("bg r%d, r%d, %d\n", dc->r0, dc->r1,
sign_extend(dc->imm16, 16 * 4));
gen_cond_branch(dc, TCG_COND_GT);
}
示例7: paf_audio_decode
static int paf_audio_decode(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *pkt)
{
AVFrame *frame = data;
int16_t *output_samples;
const uint8_t *src = pkt->data;
int frames, ret, i, j;
int16_t cb[256];
frames = pkt->size / PAF_SOUND_FRAME_SIZE;
if (frames < 1)
return AVERROR_INVALIDDATA;
frame->nb_samples = PAF_SOUND_SAMPLES * frames;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
output_samples = (int16_t *)frame->data[0];
// codebook of 256 16-bit samples and 8-bit indices to it
for (j = 0; j < frames; j++) {
for (i = 0; i < 256; i++)
cb[i] = sign_extend(AV_RL16(src + i * 2), 16);
src += 256 * 2;
// always 2 channels
for (i = 0; i < PAF_SOUND_SAMPLES * 2; i++)
*output_samples++ = cb[*src++];
}
*got_frame = 1;
return pkt->size;
}
示例8: cinaudio_decode_frame
static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
CinAudioContext *cin = avctx->priv_data;
const uint8_t *buf_end = buf + avpkt->size;
int16_t *samples;
int delta, ret;
/* get output buffer */
frame->nb_samples = avpkt->size - cin->initial_decode_frame;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
samples = (int16_t *)frame->data[0];
delta = cin->delta;
if (cin->initial_decode_frame) {
cin->initial_decode_frame = 0;
delta = sign_extend(AV_RL16(buf), 16);
buf += 2;
*samples++ = delta;
}
while (buf < buf_end) {
delta += cinaudio_delta16_table[*buf++];
delta = av_clip_int16(delta);
*samples++ = delta;
}
cin->delta = delta;
*got_frame_ptr = 1;
return avpkt->size;
}
示例9: dec_bne
static void dec_bne(DisasContext *dc)
{
LOG_DIS("bne r%d, r%d, %d\n", dc->r0, dc->r1,
sign_extend(dc->imm16, 16) * 4);
gen_cond_branch(dc, TCG_COND_NE);
}
示例10: dec_bgeu
static void dec_bgeu(DisasContext *dc)
{
LOG_DIS("bgeu r%d, r%d, %d\n", dc->r1, dc->r0,
sign_extend(dc->imm16, 16) * 4);
gen_cond_branch(dc, TCG_COND_GEU);
}
示例11: ff_h263_decode_motion
int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code)
{
int code, val, sign, shift;
code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
if (code == 0)
return pred;
if (code < 0)
return 0xffff;
sign = get_bits1(&s->gb);
shift = f_code - 1;
val = code;
if (shift) {
val = (val - 1) << shift;
val |= get_bits(&s->gb, shift);
val++;
}
if (sign)
val = -val;
val += pred;
/* modulo decoding */
if (!s->h263_long_vectors) {
val = sign_extend(val, 5 + f_code);
} else {
/* horrible h263 long vector mode */
if (pred < -31 && val < -63)
val += 64;
if (pred > 32 && val > 63)
val -= 64;
}
return val;
}
示例12: arm_wince_skip_main_prologue
CORE_ADDR
arm_wince_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST this_instr;
this_instr = read_memory_unsigned_integer (pc, 4, byte_order);
/* bl offset <__gccmain> */
if ((this_instr & 0xfff00000) == 0xeb000000)
{
#define sign_extend(V, N) \
(((long) (V) ^ (1L << ((N) - 1))) - (1L << ((N) - 1)))
long offset = sign_extend (this_instr & 0x000fffff, 23) << 2;
CORE_ADDR call_dest = (pc + 8 + offset) & 0xffffffffU;
struct minimal_symbol *s = lookup_minimal_symbol_by_pc (call_dest);
if (s != NULL
&& SYMBOL_LINKAGE_NAME (s) != NULL
&& strcmp (SYMBOL_LINKAGE_NAME (s), "__gccmain") == 0)
pc += 4;
}
return pc;
}
示例13: MTS_PROTO
/* LB: Load Byte */
fastcall void MTS_PROTO(lb)(cpu_mips_t *cpu,m_uint64_t vaddr,u_int reg)
{
m_uint64_t data;
void *haddr;
haddr = MTS_PROTO(access)(cpu,vaddr,MIPS_MEMOP_LB,1,MTS_READ,&data);
if (likely(haddr != NULL)) data = *(m_uint8_t *)haddr;
cpu->gpr[reg] = sign_extend(data,8);
}
示例14: mips_cp0_exec_mfc0_fastcall
void fastcall mips_cp0_exec_mfc0_fastcall (cpu_mips_t * cpu,
mips_insn_t insn)
{
int rt = bits (insn, 16, 20);
int rd = bits (insn, 11, 15);
int sel = bits (insn, 0, 2);
cpu->reg_set (cpu, rt, sign_extend (mips_cp0_get_reg_fast (cpu, rd, sel), 32));
}
示例15: gen_cond_branch
static inline void gen_cond_branch(DisasContext *dc, int cond)
{
TCGLabel *l1 = gen_new_label();
tcg_gen_brcond_tl(cond, cpu_R[dc->r0], cpu_R[dc->r1], l1);
gen_goto_tb(dc, 0, dc->pc + 4);
gen_set_label(l1);
gen_goto_tb(dc, 1, dc->pc + (sign_extend(dc->imm16 << 2, 16)));
dc->is_jmp = DISAS_TB_JUMP;
}