project
stringclasses
2 values
commit_id
stringlengths
40
40
target
int64
0
1
func
stringlengths
26
142k
idx
int64
0
27.3k
qemu
2d896b454a0e19ec4c1ddbb0e0b65b7e54fcedf3
1
static void boston_mach_init(MachineState *machine) { DeviceState *dev; BostonState *s; Error *err = NULL; const char *cpu_model; MemoryRegion *flash, *ddr, *ddr_low_alias, *lcd, *platreg; MemoryRegion *sys_mem = get_system_memory(); XilinxPCIEHost *pcie2; PCIDevice *ahci; DriveInfo *hd[6]; Chardev *chr; int fw_size, fit_err; bool is_64b; if ((machine->ram_size % G_BYTE) || (machine->ram_size > (2 * G_BYTE))) { error_report("Memory size must be 1GB or 2GB"); exit(1); } cpu_model = machine->cpu_model ?: "I6400"; dev = qdev_create(NULL, TYPE_MIPS_BOSTON); qdev_init_nofail(dev); s = BOSTON(dev); s->mach = machine; s->cps = g_new0(MIPSCPSState, 1); if (!cpu_supports_cps_smp(cpu_model)) { error_report("Boston requires CPUs which support CPS"); exit(1); } is_64b = cpu_supports_isa(cpu_model, ISA_MIPS64); object_initialize(s->cps, sizeof(MIPSCPSState), TYPE_MIPS_CPS); qdev_set_parent_bus(DEVICE(s->cps), sysbus_get_default()); object_property_set_str(OBJECT(s->cps), cpu_model, "cpu-model", &err); object_property_set_int(OBJECT(s->cps), smp_cpus, "num-vp", &err); object_property_set_bool(OBJECT(s->cps), true, "realized", &err); if (err != NULL) { error_report("%s", error_get_pretty(err)); exit(1); } sysbus_mmio_map_overlap(SYS_BUS_DEVICE(s->cps), 0, 0, 1); flash = g_new(MemoryRegion, 1); memory_region_init_rom_device(flash, NULL, &boston_flash_ops, s, "boston.flash", 128 * M_BYTE, &err); memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0); ddr = g_new(MemoryRegion, 1); memory_region_allocate_system_memory(ddr, NULL, "boston.ddr", machine->ram_size); memory_region_add_subregion_overlap(sys_mem, 0x80000000, ddr, 0); ddr_low_alias = g_new(MemoryRegion, 1); memory_region_init_alias(ddr_low_alias, NULL, "boston_low.ddr", ddr, 0, MIN(machine->ram_size, (256 * M_BYTE))); memory_region_add_subregion_overlap(sys_mem, 0, ddr_low_alias, 0); xilinx_pcie_init(sys_mem, 0, 0x10000000, 32 * M_BYTE, 0x40000000, 1 * G_BYTE, get_cps_irq(s->cps, 2), false); xilinx_pcie_init(sys_mem, 1, 0x12000000, 32 * M_BYTE, 0x20000000, 512 * M_BYTE, get_cps_irq(s->cps, 1), false); pcie2 = xilinx_pcie_init(sys_mem, 2, 0x14000000, 32 * M_BYTE, 0x16000000, 1 * M_BYTE, get_cps_irq(s->cps, 0), true); platreg = g_new(MemoryRegion, 1); memory_region_init_io(platreg, NULL, &boston_platreg_ops, s, "boston-platregs", 0x1000); memory_region_add_subregion_overlap(sys_mem, 0x17ffd000, platreg, 0); if (!serial_hds[0]) { serial_hds[0] = qemu_chr_new("serial0", "null"); } s->uart = serial_mm_init(sys_mem, 0x17ffe000, 2, get_cps_irq(s->cps, 3), 10000000, serial_hds[0], DEVICE_NATIVE_ENDIAN); lcd = g_new(MemoryRegion, 1); memory_region_init_io(lcd, NULL, &boston_lcd_ops, s, "boston-lcd", 0x8); memory_region_add_subregion_overlap(sys_mem, 0x17fff000, lcd, 0); chr = qemu_chr_new("lcd", "vc:320x240"); qemu_chr_fe_init(&s->lcd_display, chr, NULL); qemu_chr_fe_set_handlers(&s->lcd_display, NULL, NULL, boston_lcd_event, s, NULL, true); ahci = pci_create_simple_multifunction(&PCI_BRIDGE(&pcie2->root)->sec_bus, PCI_DEVFN(0, 0), true, TYPE_ICH9_AHCI); g_assert(ARRAY_SIZE(hd) == ICH_AHCI(ahci)->ahci.ports); ide_drive_get(hd, ICH_AHCI(ahci)->ahci.ports); ahci_ide_create_devs(ahci, hd); if (machine->firmware) { fw_size = load_image_targphys(machine->firmware, 0x1fc00000, 4 * M_BYTE); if (fw_size == -1) { error_printf("unable to load firmware image '%s'\n", machine->firmware); exit(1); } } else if (machine->kernel_filename) { fit_err = load_fit(&boston_fit_loader, machine->kernel_filename, s); if (fit_err) { error_printf("unable to load FIT image\n"); exit(1); } gen_firmware(memory_region_get_ram_ptr(flash) + 0x7c00000, s->kernel_entry, s->fdt_base, is_64b); } else if (!qtest_enabled()) { error_printf("Please provide either a -kernel or -bios argument\n"); exit(1); } }
1,479
FFmpeg
e7b9d136a1ba2d048b1a17df5778e426b825676d
1
static int cng_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AVFrame *frame = data; CNGContext *p = avctx->priv_data; int buf_size = avpkt->size; int ret, i; int16_t *buf_out; float e = 1.0; float scaling; if (avpkt->size) { int dbov = -avpkt->data[0]; p->target_energy = 1081109975 * ff_exp10(dbov / 10.0) * 0.75; memset(p->target_refl_coef, 0, p->order * sizeof(*p->target_refl_coef)); for (i = 0; i < FFMIN(avpkt->size - 1, p->order); i++) { p->target_refl_coef[i] = (avpkt->data[1 + i] - 127) / 128.0; if (p->inited) { p->energy = p->energy / 2 + p->target_energy / 2; for (i = 0; i < p->order; i++) p->refl_coef[i] = 0.6 *p->refl_coef[i] + 0.4 * p->target_refl_coef[i]; } else { p->energy = p->target_energy; memcpy(p->refl_coef, p->target_refl_coef, p->order * sizeof(*p->refl_coef)); p->inited = 1; make_lpc_coefs(p->lpc_coef, p->refl_coef, p->order); for (i = 0; i < p->order; i++) e *= 1.0 - p->refl_coef[i]*p->refl_coef[i]; scaling = sqrt(e * p->energy / 1081109975); for (i = 0; i < avctx->frame_size; i++) { int r = (av_lfg_get(&p->lfg) & 0xffff) - 0x8000; p->excitation[i] = scaling * r; ff_celp_lp_synthesis_filterf(p->filter_out + p->order, p->lpc_coef, p->excitation, avctx->frame_size, p->order); frame->nb_samples = avctx->frame_size; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; buf_out = (int16_t *)frame->data[0]; for (i = 0; i < avctx->frame_size; i++) buf_out[i] = p->filter_out[i + p->order]; memcpy(p->filter_out, p->filter_out + avctx->frame_size, p->order * sizeof(*p->filter_out)); *got_frame_ptr = 1; return buf_size;
1,480
qemu
b47d8efa9f430c332bf96ce6eede169eb48422ad
0
static int vfio_pci_hot_reset_multi(VFIOPCIDevice *vdev) { return vfio_pci_hot_reset(vdev, false); }
1,481
qemu
2a74440547ea0a15195224fa2b7784b267cbfe15
0
void qerror_print(QError *qerror) { QString *qstring = qerror_human(qerror); loc_push_restore(&qerror->loc); error_report("%s", qstring_get_str(qstring)); loc_pop(&qerror->loc); QDECREF(qstring); }
1,482
qemu
d4551293d68a1876df87400be6c71c657756d0bb
0
static int is_async_return(const QObject *data) { if (data && qobject_type(data) == QTYPE_QDICT) { return qdict_haskey(qobject_to_qdict(data), "__mon_async"); } return 0; }
1,483
FFmpeg
bf1945af301aff54c33352e75f17aec6cb5269d7
0
static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34) { int e, b, k, n; float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; int8_t *opd_hist = ps->opd_hist; int8_t *ipd_hist = ps->ipd_hist; int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf; int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf; int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf; int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf; const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; //Remapping if (ps->num_env_old) { memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); } if (is34) { remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); if (ps->enable_ipdopd) { remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); } if (!ps->is34bands_old) { map_val_20_to_34(H11[0][0]); map_val_20_to_34(H11[1][0]); map_val_20_to_34(H12[0][0]); map_val_20_to_34(H12[1][0]); map_val_20_to_34(H21[0][0]); map_val_20_to_34(H21[1][0]); map_val_20_to_34(H22[0][0]); map_val_20_to_34(H22[1][0]); ipdopd_reset(ipd_hist, opd_hist); } } else { remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); if (ps->enable_ipdopd) { remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); } if (ps->is34bands_old) { map_val_34_to_20(H11[0][0]); map_val_34_to_20(H11[1][0]); map_val_34_to_20(H12[0][0]); map_val_34_to_20(H12[1][0]); map_val_34_to_20(H21[0][0]); map_val_34_to_20(H21[1][0]); map_val_34_to_20(H22[0][0]); map_val_34_to_20(H22[1][0]); ipdopd_reset(ipd_hist, opd_hist); } } //Mixing for (e = 0; e < ps->num_env; e++) { for (b = 0; b < NR_PAR_BANDS[is34]; b++) { float h11, h12, h21, h22; h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0]; h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1]; h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2]; h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3]; if (!PS_BASELINE && ps->enable_ipdopd && b < ps->nr_ipdopd_par) { //The spec say says to only run this smoother when enable_ipdopd //is set but the reference decoder appears to run it constantly float h11i, h12i, h21i, h22i; float ipd_adj_re, ipd_adj_im; int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b]; int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b]; float opd_re = pd_re_smooth[opd_idx]; float opd_im = pd_im_smooth[opd_idx]; float ipd_re = pd_re_smooth[ipd_idx]; float ipd_im = pd_im_smooth[ipd_idx]; opd_hist[b] = opd_idx & 0x3F; ipd_hist[b] = ipd_idx & 0x3F; ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im; ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im; h11i = h11 * opd_im; h11 = h11 * opd_re; h12i = h12 * ipd_adj_im; h12 = h12 * ipd_adj_re; h21i = h21 * opd_im; h21 = h21 * opd_re; h22i = h22 * ipd_adj_im; h22 = h22 * ipd_adj_re; H11[1][e+1][b] = h11i; H12[1][e+1][b] = h12i; H21[1][e+1][b] = h21i; H22[1][e+1][b] = h22i; } H11[0][e+1][b] = h11; H12[0][e+1][b] = h12; H21[0][e+1][b] = h21; H22[0][e+1][b] = h22; } for (k = 0; k < NR_BANDS[is34]; k++) { float h11r, h12r, h21r, h22r; float h11i, h12i, h21i, h22i; float h11r_step, h12r_step, h21r_step, h22r_step; float h11i_step, h12i_step, h21i_step, h22i_step; int start = ps->border_position[e]; int stop = ps->border_position[e+1]; float width = 1.f / (stop - start); b = k_to_i[k]; h11r = H11[0][e][b]; h12r = H12[0][e][b]; h21r = H21[0][e][b]; h22r = H22[0][e][b]; if (!PS_BASELINE && ps->enable_ipdopd) { //Is this necessary? ps_04_new seems unchanged if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) { h11i = -H11[1][e][b]; h12i = -H12[1][e][b]; h21i = -H21[1][e][b]; h22i = -H22[1][e][b]; } else { h11i = H11[1][e][b]; h12i = H12[1][e][b]; h21i = H21[1][e][b]; h22i = H22[1][e][b]; } } //Interpolation h11r_step = (H11[0][e+1][b] - h11r) * width; h12r_step = (H12[0][e+1][b] - h12r) * width; h21r_step = (H21[0][e+1][b] - h21r) * width; h22r_step = (H22[0][e+1][b] - h22r) * width; if (!PS_BASELINE && ps->enable_ipdopd) { h11i_step = (H11[1][e+1][b] - h11i) * width; h12i_step = (H12[1][e+1][b] - h12i) * width; h21i_step = (H21[1][e+1][b] - h21i) * width; h22i_step = (H22[1][e+1][b] - h22i) * width; } for (n = start + 1; n <= stop; n++) { //l is s, r is d float l_re = l[k][n][0]; float l_im = l[k][n][1]; float r_re = r[k][n][0]; float r_im = r[k][n][1]; h11r += h11r_step; h12r += h12r_step; h21r += h21r_step; h22r += h22r_step; if (!PS_BASELINE && ps->enable_ipdopd) { h11i += h11i_step; h12i += h12i_step; h21i += h21i_step; h22i += h22i_step; l[k][n][0] = h11r*l_re + h21r*r_re - h11i*l_im - h21i*r_im; l[k][n][1] = h11r*l_im + h21r*r_im + h11i*l_re + h21i*r_re; r[k][n][0] = h12r*l_re + h22r*r_re - h12i*l_im - h22i*r_im; r[k][n][1] = h12r*l_im + h22r*r_im + h12i*l_re + h22i*r_re; } else { l[k][n][0] = h11r*l_re + h21r*r_re; l[k][n][1] = h11r*l_im + h21r*r_im; r[k][n][0] = h12r*l_re + h22r*r_re; r[k][n][1] = h12r*l_im + h22r*r_im; } } } } }
1,484
qemu
94171e119cb6f7bab2578896643b0daff1d9b184
0
static int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, void *opaque) { if (mon->rs) { readline_start(mon->rs, "Password: ", 1, readline_func, opaque); /* prompt is printed on return from the command handler */ return 0; } else { monitor_printf(mon, "terminal does not support password prompting\n"); return -ENOTTY; } }
1,485
qemu
27a69bb088bee6d4efea254659422fb9c751b3c7
0
static inline void gen_efdnabs(DisasContext *ctx) { if (unlikely(!ctx->spe_enabled)) { gen_exception(ctx, POWERPC_EXCP_APU); return; } #if defined(TARGET_PPC64) tcg_gen_ori_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], 0x8000000000000000LL); #else tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); tcg_gen_ori_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], 0x80000000); #endif }
1,486
qemu
b931bfbf042983f311b3b09894d8030b2755a638
0
int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type) { uint64_t features; int i, r; if (vhost_set_backend_type(hdev, backend_type) < 0) { close((uintptr_t)opaque); return -1; } if (hdev->vhost_ops->vhost_backend_init(hdev, opaque) < 0) { close((uintptr_t)opaque); return -errno; } r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_OWNER, NULL); if (r < 0) { goto fail; } r = hdev->vhost_ops->vhost_call(hdev, VHOST_GET_FEATURES, &features); if (r < 0) { goto fail; } for (i = 0; i < hdev->nvqs; ++i) { r = vhost_virtqueue_init(hdev, hdev->vqs + i, i); if (r < 0) { goto fail_vq; } } hdev->features = features; hdev->memory_listener = (MemoryListener) { .begin = vhost_begin, .commit = vhost_commit, .region_add = vhost_region_add, .region_del = vhost_region_del, .region_nop = vhost_region_nop, .log_start = vhost_log_start, .log_stop = vhost_log_stop, .log_sync = vhost_log_sync, .log_global_start = vhost_log_global_start, .log_global_stop = vhost_log_global_stop, .eventfd_add = vhost_eventfd_add, .eventfd_del = vhost_eventfd_del, .priority = 10 }; hdev->migration_blocker = NULL; if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { error_setg(&hdev->migration_blocker, "Migration disabled: vhost lacks VHOST_F_LOG_ALL feature."); migrate_add_blocker(hdev->migration_blocker); } hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions)); hdev->n_mem_sections = 0; hdev->mem_sections = NULL; hdev->log = NULL; hdev->log_size = 0; hdev->log_enabled = false; hdev->started = false; hdev->memory_changed = false; memory_listener_register(&hdev->memory_listener, &address_space_memory); return 0; fail_vq: while (--i >= 0) { vhost_virtqueue_cleanup(hdev->vqs + i); } fail: r = -errno; hdev->vhost_ops->vhost_backend_cleanup(hdev); return r; }
1,488
qemu
03fc0548b70393b0c8d43703591a9e34fb8e3123
0
static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1, tcg_target_long arg2) { uint8_t *old_code_ptr = s->code_ptr; if (type == TCG_TYPE_I32) { tcg_out_op_t(s, INDEX_op_ld_i32); tcg_out_r(s, ret); tcg_out_r(s, arg1); tcg_out32(s, arg2); } else { assert(type == TCG_TYPE_I64); #if TCG_TARGET_REG_BITS == 64 tcg_out_op_t(s, INDEX_op_ld_i64); tcg_out_r(s, ret); tcg_out_r(s, arg1); assert(arg2 == (uint32_t)arg2); tcg_out32(s, arg2); #else TODO(); #endif } old_code_ptr[1] = s->code_ptr - old_code_ptr; }
1,489
qemu
368d25881c94f9e09ef19a3d93e8fec797dbcd05
0
static int tight_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) { int max_rows; if (vs->clientds.pf.bytes_per_pixel == 4 && vs->clientds.pf.rmax == 0xFF && vs->clientds.pf.bmax == 0xFF && vs->clientds.pf.gmax == 0xFF) { vs->tight.pixel24 = true; } else { vs->tight.pixel24 = false; } if (vs->tight.quality != -1) { double freq = vnc_update_freq(vs, x, y, w, h); if (freq > tight_jpeg_conf[vs->tight.quality].jpeg_freq_threshold) { return send_rect_simple(vs, x, y, w, h, false); } } if (w * h < VNC_TIGHT_MIN_SPLIT_RECT_SIZE) { return send_rect_simple(vs, x, y, w, h, true); } /* Calculate maximum number of rows in one non-solid rectangle. */ max_rows = tight_conf[vs->tight.compression].max_rect_size; max_rows /= MIN(tight_conf[vs->tight.compression].max_rect_width, w); return find_large_solid_color_rect(vs, x, y, w, h, max_rows); }
1,490
qemu
2e569845bd314fc1dde83d65dc9b87e71b4d29b4
0
void helper_booke206_tlbwe(CPUPPCState *env) { PowerPCCPU *cpu = ppc_env_get_cpu(env); uint32_t tlbncfg, tlbn; ppcmas_tlb_t *tlb; uint32_t size_tlb, size_ps; target_ulong mask; switch (env->spr[SPR_BOOKE_MAS0] & MAS0_WQ_MASK) { case MAS0_WQ_ALWAYS: /* good to go, write that entry */ break; case MAS0_WQ_COND: /* XXX check if reserved */ if (0) { return; } break; case MAS0_WQ_CLR_RSRV: /* XXX clear entry */ return; default: /* no idea what to do */ return; } if (((env->spr[SPR_BOOKE_MAS0] & MAS0_ATSEL) == MAS0_ATSEL_LRAT) && !msr_gs) { /* XXX we don't support direct LRAT setting yet */ fprintf(stderr, "cpu: don't support LRAT setting yet\n"); return; } tlbn = (env->spr[SPR_BOOKE_MAS0] & MAS0_TLBSEL_MASK) >> MAS0_TLBSEL_SHIFT; tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn]; tlb = booke206_cur_tlb(env); if (!tlb) { raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL, GETPC()); } /* check that we support the targeted size */ size_tlb = (env->spr[SPR_BOOKE_MAS1] & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT; size_ps = booke206_tlbnps(env, tlbn); if ((env->spr[SPR_BOOKE_MAS1] & MAS1_VALID) && (tlbncfg & TLBnCFG_AVAIL) && !(size_ps & (1 << size_tlb))) { raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL, GETPC()); } if (msr_gs) { cpu_abort(CPU(cpu), "missing HV implementation\n"); } tlb->mas7_3 = ((uint64_t)env->spr[SPR_BOOKE_MAS7] << 32) | env->spr[SPR_BOOKE_MAS3]; tlb->mas1 = env->spr[SPR_BOOKE_MAS1]; if ((env->spr[SPR_MMUCFG] & MMUCFG_MAVN) == MMUCFG_MAVN_V2) { /* For TLB which has a fixed size TSIZE is ignored with MAV2 */ booke206_fixed_size_tlbn(env, tlbn, tlb); } else { if (!(tlbncfg & TLBnCFG_AVAIL)) { /* force !AVAIL TLB entries to correct page size */ tlb->mas1 &= ~MAS1_TSIZE_MASK; /* XXX can be configured in MMUCSR0 */ tlb->mas1 |= (tlbncfg & TLBnCFG_MINSIZE) >> 12; } } /* Make a mask from TLB size to discard invalid bits in EPN field */ mask = ~(booke206_tlb_to_page_size(env, tlb) - 1); /* Add a mask for page attributes */ mask |= MAS2_ACM | MAS2_VLE | MAS2_W | MAS2_I | MAS2_M | MAS2_G | MAS2_E; if (!msr_cm) { /* Executing a tlbwe instruction in 32-bit mode will set * bits 0:31 of the TLB EPN field to zero. */ mask &= 0xffffffff; } tlb->mas2 = env->spr[SPR_BOOKE_MAS2] & mask; if (!(tlbncfg & TLBnCFG_IPROT)) { /* no IPROT supported by TLB */ tlb->mas1 &= ~MAS1_IPROT; } if (booke206_tlb_to_page_size(env, tlb) == TARGET_PAGE_SIZE) { tlb_flush_page(CPU(cpu), tlb->mas2 & MAS2_EPN_MASK); } else { tlb_flush(CPU(cpu)); } }
1,491
qemu
4a1418e07bdcfaa3177739e04707ecaec75d89e1
0
static uint32_t qpi_mem_readl(void *opaque, target_phys_addr_t addr) { CPUState *env; env = cpu_single_env; if (!env) return 0; return env->eflags & (IF_MASK | IOPL_MASK); }
1,492
qemu
8978b34af3250354e0b67340a7e920f909beda13
0
static void test_visitor_out_number(TestOutputVisitorData *data, const void *unused) { double value = 3.14; QObject *obj; visit_type_number(data->ov, NULL, &value, &error_abort); obj = visitor_get(data); g_assert(qobject_type(obj) == QTYPE_QFLOAT); g_assert(qfloat_get_double(qobject_to_qfloat(obj)) == value); }
1,493
qemu
f95d7cc7fecbc0e320e83c864ce2d99fee3d9236
0
static int find_pte32(CPUPPCState *env, struct mmu_ctx_hash32 *ctx, target_ulong eaddr, int h, int rwx, int target_page_bits) { hwaddr pteg_off; target_ulong pte0, pte1; int i, good = -1; int ret, r; ret = -1; /* No entry found */ pteg_off = get_pteg_offset32(env, ctx->hash[h]); for (i = 0; i < HPTES_PER_GROUP; i++) { pte0 = ppc_hash32_load_hpte0(env, pteg_off + i*HASH_PTE_SIZE_32); pte1 = ppc_hash32_load_hpte1(env, pteg_off + i*HASH_PTE_SIZE_32); r = pte_check_hash32(ctx, pte0, pte1, h, rwx); LOG_MMU("Load pte from %08" HWADDR_PRIx " => " TARGET_FMT_lx " " TARGET_FMT_lx " %d %d %d " TARGET_FMT_lx "\n", pteg_off + (i * 8), pte0, pte1, (int)(pte0 >> 31), h, (int)((pte0 >> 6) & 1), ctx->ptem); switch (r) { case -3: /* PTE inconsistency */ return -1; case -2: /* Access violation */ ret = -2; good = i; break; case -1: default: /* No PTE match */ break; case 0: /* access granted */ /* XXX: we should go on looping to check all PTEs consistency * but if we can speed-up the whole thing as the * result would be undefined if PTEs are not consistent. */ ret = 0; good = i; goto done; } } if (good != -1) { done: LOG_MMU("found PTE at addr %08" HWADDR_PRIx " prot=%01x ret=%d\n", ctx->raddr, ctx->prot, ret); /* Update page flags */ pte1 = ctx->raddr; if (ppc_hash32_pte_update_flags(ctx, &pte1, ret, rwx) == 1) { ppc_hash32_store_hpte1(env, pteg_off + good * HASH_PTE_SIZE_32, pte1); } } /* We have a TLB that saves 4K pages, so let's * split a huge page to 4k chunks */ if (target_page_bits != TARGET_PAGE_BITS) { ctx->raddr |= (eaddr & ((1 << target_page_bits) - 1)) & TARGET_PAGE_MASK; } return ret; }
1,494
FFmpeg
e2ad0b66fa273c5c823978e8f601f2c0d9ee42f8
0
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); AVPicture dummy_pict; int ret; if (!desc) return AVERROR(EINVAL); if ((ret = av_image_check_size(width, height, 0, NULL)) < 0) return ret; if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) // do not include palette for these pseudo-paletted formats return width * height; return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height); }
1,495
qemu
2bcf018340cbf233f7145e643fc1bb367f23fd90
0
uint32_t HELPER(testblock)(CPUS390XState *env, uint64_t real_addr) { uintptr_t ra = GETPC(); CPUState *cs = CPU(s390_env_get_cpu(env)); int i; real_addr = wrap_address(env, real_addr) & TARGET_PAGE_MASK; /* Check low-address protection */ if ((env->cregs[0] & CR0_LOWPROT) && real_addr < 0x2000) { cpu_restore_state(cs, ra); program_interrupt(env, PGM_PROTECTION, 4); return 1; } for (i = 0; i < TARGET_PAGE_SIZE; i += 8) { cpu_stq_real_ra(env, real_addr + i, 0, ra); } return 0; }
1,496
qemu
32bafa8fdd098d52fbf1102d5a5e48d29398c0aa
0
static void block_dirty_bitmap_add_prepare(BlkActionState *common, Error **errp) { Error *local_err = NULL; BlockDirtyBitmapAdd *action; BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState, common, common); if (action_check_completion_mode(common, errp) < 0) { return; } action = common->action->u.block_dirty_bitmap_add; /* AIO context taken and released within qmp_block_dirty_bitmap_add */ qmp_block_dirty_bitmap_add(action->node, action->name, action->has_granularity, action->granularity, &local_err); if (!local_err) { state->prepared = true; } else { error_propagate(errp, local_err); } }
1,498
qemu
c39ce112b60ffafbaf700853e32bea74cbb2c148
0
int32_t scsi_req_enqueue(SCSIRequest *req, uint8_t *buf) { int32_t rc; assert(!req->enqueued); scsi_req_ref(req); req->enqueued = true; QTAILQ_INSERT_TAIL(&req->dev->requests, req, next); scsi_req_ref(req); rc = req->ops->send_command(req, buf); scsi_req_unref(req); return rc; }
1,499
qemu
89e2a31d337f96ab8d5b7bdfe4bcce0a25181ed1
0
static int sd_parse_uri(BDRVSheepdogState *s, const char *filename, char *vdi, uint32_t *snapid, char *tag) { URI *uri; QueryParams *qp = NULL; int ret = 0; uri = uri_parse(filename); if (!uri) { return -EINVAL; } /* transport */ if (!strcmp(uri->scheme, "sheepdog")) { s->is_unix = false; } else if (!strcmp(uri->scheme, "sheepdog+tcp")) { s->is_unix = false; } else if (!strcmp(uri->scheme, "sheepdog+unix")) { s->is_unix = true; } else { ret = -EINVAL; goto out; } if (uri->path == NULL || !strcmp(uri->path, "/")) { ret = -EINVAL; goto out; } pstrcpy(vdi, SD_MAX_VDI_LEN, uri->path + 1); qp = query_params_parse(uri->query); if (qp->n > 1 || (s->is_unix && !qp->n) || (!s->is_unix && qp->n)) { ret = -EINVAL; goto out; } if (s->is_unix) { /* sheepdog+unix:///vdiname?socket=path */ if (uri->server || uri->port || strcmp(qp->p[0].name, "socket")) { ret = -EINVAL; goto out; } s->host_spec = g_strdup(qp->p[0].value); } else { /* sheepdog[+tcp]://[host:port]/vdiname */ s->host_spec = g_strdup_printf("%s:%d", uri->server ?: SD_DEFAULT_ADDR, uri->port ?: SD_DEFAULT_PORT); } /* snapshot tag */ if (uri->fragment) { *snapid = strtoul(uri->fragment, NULL, 10); if (*snapid == 0) { pstrcpy(tag, SD_MAX_VDI_TAG_LEN, uri->fragment); } } else { *snapid = CURRENT_VDI_ID; /* search current vdi */ } out: if (qp) { query_params_free(qp); } uri_free(uri); return ret; }
1,501
qemu
210b580b106fa798149e28aa13c66b325a43204e
0
static void rtas_ibm_query_interrupt_source_number(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t config_addr = rtas_ld(args, 0); uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2); unsigned int intr_src_num = -1, ioa_intr_num = rtas_ld(args, 3); int ndev; sPAPRPHBState *phb = NULL; /* Fins sPAPRPHBState */ phb = find_phb(spapr, buid); if (!phb) { rtas_st(rets, 0, -3); /* Parameter error */ return; } /* Find device descriptor and start IRQ */ ndev = spapr_msicfg_find(phb, config_addr, false); if (ndev < 0) { trace_spapr_pci_msi("MSI has not been enabled", -1, config_addr); rtas_st(rets, 0, -1); /* Hardware error */ return; } intr_src_num = phb->msi_table[ndev].irq + ioa_intr_num; trace_spapr_pci_rtas_ibm_query_interrupt_source_number(ioa_intr_num, intr_src_num); rtas_st(rets, 0, 0); rtas_st(rets, 1, intr_src_num); rtas_st(rets, 2, 1);/* 0 == level; 1 == edge */ }
1,502
qemu
5861a33898bbddfd1a80c2e202cb9352e3b1ba62
0
static void mpic_irq_raise(openpic_t *mpp, int n_CPU, IRQ_src_t *src) { int n_ci = IDR_CI0 - n_CPU; if(test_bit(&src->ide, n_ci)) { qemu_irq_raise(mpp->dst[n_CPU].irqs[OPENPIC_OUTPUT_CINT]); } else { qemu_irq_raise(mpp->dst[n_CPU].irqs[OPENPIC_OUTPUT_INT]); } }
1,503
qemu
786a4ea82ec9c87e3a895cf41081029b285a5fe5
0
static void tc6393xb_gpio_handler_update(TC6393xbState *s) { uint32_t level, diff; int bit; level = s->gpio_level & s->gpio_dir; for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) { bit = ffs(diff) - 1; qemu_set_irq(s->handler[bit], (level >> bit) & 1); } s->prev_level = level; }
1,504
qemu
94ad93bd976841c26af75322301f5aad925114d6
0
static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) { /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user * tries to add a sPAPR CPU core to a non-pseries machine. */ sPAPRMachineState *spapr = (sPAPRMachineState *) object_dynamic_cast(qdev_get_machine(), TYPE_SPAPR_MACHINE); sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev)); sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev)); CPUCore *cc = CPU_CORE(OBJECT(dev)); size_t size; Error *local_err = NULL; void *obj; int i, j; if (!spapr) { error_setg(errp, TYPE_SPAPR_CPU_CORE " needs a pseries machine"); return; } size = object_type_get_instance_size(scc->cpu_type); sc->threads = g_malloc0(size * cc->nr_threads); for (i = 0; i < cc->nr_threads; i++) { char id[32]; CPUState *cs; PowerPCCPU *cpu; obj = sc->threads + i * size; object_initialize(obj, size, scc->cpu_type); cs = CPU(obj); cpu = POWERPC_CPU(cs); cs->cpu_index = cc->core_id + i; cpu->vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i; if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->vcpu_id)) { error_setg(&local_err, "Can't create CPU with id %d in KVM", cpu->vcpu_id); error_append_hint(&local_err, "Adjust the number of cpus to %d " "or try to raise the number of threads per core\n", cpu->vcpu_id * smp_threads / spapr->vsmt); goto err; } /* Set NUMA node for the threads belonged to core */ cpu->node_id = sc->node_id; snprintf(id, sizeof(id), "thread[%d]", i); object_property_add_child(OBJECT(sc), id, obj, &local_err); if (local_err) { goto err; } object_unref(obj); } for (j = 0; j < cc->nr_threads; j++) { obj = sc->threads + j * size; spapr_cpu_core_realize_child(obj, spapr, &local_err); if (local_err) { goto err; } } return; err: while (--i >= 0) { obj = sc->threads + i * size; object_unparent(obj); } g_free(sc->threads); error_propagate(errp, local_err); }
1,505
FFmpeg
6086731299e4d249ddc459e406b2ebb0cb71f6f4
1
static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb) { int qpi, i, j, bit, run_length, blocks_decoded, num_blocks_at_qpi; int num_blocks = s->total_num_coded_frags; for (qpi = 0; qpi < s->nqps-1 && num_blocks > 0; qpi++) { i = blocks_decoded = num_blocks_at_qpi = 0; bit = get_bits1(gb); do { run_length = get_vlc2(gb, s->superblock_run_length_vlc.table, 6, 2) + 1; if (run_length == 34) run_length += get_bits(gb, 12); blocks_decoded += run_length; if (!bit) num_blocks_at_qpi += run_length; for (j = 0; j < run_length; i++) { if (i >= s->total_num_coded_frags) return -1; if (s->all_fragments[s->coded_fragment_list[0][i]].qpi == qpi) { s->all_fragments[s->coded_fragment_list[0][i]].qpi += bit; j++; } } if (run_length == MAXIMUM_LONG_BIT_RUN) bit = get_bits1(gb); else bit ^= 1; } while (blocks_decoded < num_blocks); num_blocks -= num_blocks_at_qpi; } return 0; }
1,506
qemu
b544c1aba8681c2fe5d6715fbd37cf6caf1bc7bb
1
static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs) { BDRVSheepdogState *s = bs->opaque; SheepdogAIOCB *acb; AIOReq *aio_req; if (s->cache_flags != SD_FLAG_CMD_CACHE) { return 0; } acb = sd_aio_setup(bs, NULL, 0, 0); acb->aiocb_type = AIOCB_FLUSH_CACHE; acb->aio_done_func = sd_finish_aiocb; aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id), 0, 0, 0, 0, 0); QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); add_aio_request(s, aio_req, NULL, 0, false, acb->aiocb_type); qemu_coroutine_yield(); return acb->ret; }
1,510
qemu
12d4536f7d911b6d87a766ad7300482ea663cea2
1
void qemu_notify_event(void) { CPUState *env = cpu_single_env; qemu_event_increment (); if (env) { cpu_exit(env); } if (next_cpu && env != next_cpu) { cpu_exit(next_cpu); } exit_request = 1; }
1,511
qemu
cd3b29b745b0ff393b2d37317837bc726b8dacc8
1
static void tcg_out_qemu_ld(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, TCGMemOpIdx oi) { TCGMemOp opc = get_memop(oi); #ifdef CONFIG_SOFTMMU unsigned mem_index = get_mmuidx(oi); tcg_insn_unit *label_ptr; TCGReg base_reg; base_reg = tcg_out_tlb_read(s, addr_reg, opc, mem_index, 1); label_ptr = s->code_ptr + 1; tcg_out_insn(s, RI, BRC, S390_CC_NE, 0); tcg_out_qemu_ld_direct(s, opc, data_reg, base_reg, TCG_REG_R2, 0); add_qemu_ldst_label(s, 1, oi, data_reg, addr_reg, s->code_ptr, label_ptr); #else TCGReg index_reg; tcg_target_long disp; tcg_prepare_user_ldst(s, &addr_reg, &index_reg, &disp); tcg_out_qemu_ld_direct(s, opc, data_reg, addr_reg, index_reg, disp); #endif }
1,512
qemu
11b7b07f8a15879134a54e73fade98d5e11e04f8
1
char *qdist_pr_plain(const struct qdist *dist, size_t n) { struct qdist binned; char *ret; if (dist->n == 0) { return NULL; } qdist_bin__internal(&binned, dist, n); ret = qdist_pr_internal(&binned); qdist_destroy(&binned); return ret; }
1,513
FFmpeg
aa06658248a49f6ebf381894b9426cdfb377cd32
1
static int dvvideo_encode_frame(AVCodecContext *c, uint8_t *buf, int buf_size, void *data) { DVVideoContext *s = c->priv_data; s->sys = dv_codec_profile(c); if (!s->sys) return -1; if(buf_size < s->sys->frame_size) return -1; c->pix_fmt = s->sys->pix_fmt; s->picture = *((AVFrame *)data); s->picture.key_frame = 1; s->picture.pict_type = FF_I_TYPE; s->buf = buf; c->execute(c, dv_encode_mt, (void**)&s->dv_anchor[0], NULL, s->sys->difseg_size * 27); emms_c(); return s->sys->frame_size; }
1,514
FFmpeg
852859ff7cd29a926a9a7e811d77192b61a6956e
1
static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) { AVStream *st = c->fc->streams[c->fc->nb_streams-1]; int tag, len; get_be32(pb); /* version + flags */ len = mp4_read_descr(c, pb, &tag); if (tag == MP4ESDescrTag) { get_be16(pb); /* ID */ get_byte(pb); /* priority */ } else get_be16(pb); /* ID */ len = mp4_read_descr(c, pb, &tag); if (tag == MP4DecConfigDescrTag) { int object_type_id = get_byte(pb); get_byte(pb); /* stream type */ get_be24(pb); /* buffer size db */ get_be32(pb); /* max bitrate */ get_be32(pb); /* avg bitrate */ st->codec->codec_id= codec_get_id(ff_mp4_obj_type, object_type_id); dprintf(c->fc, "esds object type id %d\n", object_type_id); len = mp4_read_descr(c, pb, &tag); if (tag == MP4DecSpecificDescrTag) { dprintf(c->fc, "Specific MPEG4 header len=%d\n", len); st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); get_buffer(pb, st->codec->extradata, len); st->codec->extradata_size = len; /* from mplayer */ if ((*st->codec->extradata >> 3) == 29) { st->codec->codec_id = CODEC_ID_MP3ON4; } } } return 0; }
1,515
qemu
3d4d16f4dc101e16f643acc44dfffdbaf2a8f01c
1
static void audio_run_in (AudioState *s) { HWVoiceIn *hw = NULL; while ((hw = audio_pcm_hw_find_any_enabled_in (hw))) { SWVoiceIn *sw; int captured, min; captured = hw->pcm_ops->run_in (hw); min = audio_pcm_hw_find_min_in (hw); hw->total_samples_captured += captured - min; hw->ts_helper += captured; for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) { sw->total_hw_samples_acquired -= min; if (sw->active) { int avail; avail = audio_get_avail (sw); if (avail > 0) { sw->callback.fn (sw->callback.opaque, avail); } } } } }
1,516
FFmpeg
5d44c061cf511d97be5fac8d76be2f3915c6e798
1
static int avs_read_packet(AVFormatContext * s, AVPacket * pkt) { AvsFormat *avs = s->priv_data; int sub_type = 0, size = 0; AvsBlockType type = AVS_NONE; int palette_size = 0; uint8_t palette[4 + 3 * 256]; int ret; if (avs->remaining_audio_size > 0) if (avs_read_audio_packet(s, pkt) > 0) return 0; while (1) { if (avs->remaining_frame_size <= 0) { if (!avio_rl16(s->pb)) /* found EOF */ return AVERROR(EIO); avs->remaining_frame_size = avio_rl16(s->pb) - 4; } while (avs->remaining_frame_size > 0) { sub_type = avio_r8(s->pb); type = avio_r8(s->pb); size = avio_rl16(s->pb); if (size < 4) avs->remaining_frame_size -= size; switch (type) { case AVS_PALETTE: ret = avio_read(s->pb, palette, size - 4); if (ret < size - 4) return AVERROR(EIO); palette_size = size; break; case AVS_VIDEO: if (!avs->st_video) { avs->st_video = av_new_stream(s, AVS_VIDEO); if (avs->st_video == NULL) return AVERROR(ENOMEM); avs->st_video->codec->codec_type = AVMEDIA_TYPE_VIDEO; avs->st_video->codec->codec_id = CODEC_ID_AVS; avs->st_video->codec->width = avs->width; avs->st_video->codec->height = avs->height; avs->st_video->codec->bits_per_coded_sample=avs->bits_per_sample; avs->st_video->nb_frames = avs->nb_frames; avs->st_video->codec->time_base = (AVRational) { 1, avs->fps}; } return avs_read_video_packet(s, pkt, type, sub_type, size, palette, palette_size); case AVS_AUDIO: if (!avs->st_audio) { avs->st_audio = av_new_stream(s, AVS_AUDIO); if (avs->st_audio == NULL) return AVERROR(ENOMEM); avs->st_audio->codec->codec_type = AVMEDIA_TYPE_AUDIO; } avs->remaining_audio_size = size - 4; size = avs_read_audio_packet(s, pkt); if (size != 0) return size; break; default: avio_skip(s->pb, size - 4); } } } }
1,517
qemu
e7eee62a90c671d22d50964b7de05e3f4fd96f5f
1
void HELPER(simcall)(CPUXtensaState *env) { uint32_t *regs = env->regs; switch (regs[2]) { case TARGET_SYS_exit: qemu_log("exit(%d) simcall\n", regs[3]); exit(regs[3]); break; case TARGET_SYS_read: case TARGET_SYS_write: { bool is_write = regs[2] == TARGET_SYS_write; uint32_t fd = regs[3]; uint32_t vaddr = regs[4]; uint32_t len = regs[5]; while (len > 0) { target_phys_addr_t paddr = cpu_get_phys_page_debug(env, vaddr); uint32_t page_left = TARGET_PAGE_SIZE - (vaddr & (TARGET_PAGE_SIZE - 1)); uint32_t io_sz = page_left < len ? page_left : len; target_phys_addr_t sz = io_sz; void *buf = cpu_physical_memory_map(paddr, &sz, is_write); if (buf) { vaddr += io_sz; len -= io_sz; regs[2] = is_write ? write(fd, buf, io_sz) : read(fd, buf, io_sz); regs[3] = errno; cpu_physical_memory_unmap(buf, sz, is_write, sz); if (regs[2] == -1) { break; } } else { regs[3] = EINVAL; break; } } } break; case TARGET_SYS_open: { char name[1024]; int rc; int i; for (i = 0; i < ARRAY_SIZE(name); ++i) { rc = cpu_memory_rw_debug( env, regs[3] + i, (uint8_t *)name + i, 1, 0); if (rc != 0 || name[i] == 0) { break; } } if (rc == 0 && i < ARRAY_SIZE(name)) { regs[2] = open(name, regs[4], regs[5]); regs[3] = errno; } else { regs[3] = EINVAL; } } break; case TARGET_SYS_close: if (regs[3] < 3) { regs[2] = regs[3] = 0; } else { regs[2] = close(regs[3]); regs[3] = errno; } break; case TARGET_SYS_lseek: regs[2] = lseek(regs[3], (off_t)(int32_t)regs[4], regs[5]); regs[3] = errno; break; case TARGET_SYS_select_one: { uint32_t fd = regs[3]; uint32_t rq = regs[4]; uint32_t target_tv = regs[5]; uint32_t target_tvv[2]; struct timeval tv = {0}; fd_set fdset; FD_ZERO(&fdset); FD_SET(fd, &fdset); if (target_tv) { cpu_memory_rw_debug(env, target_tv, (uint8_t *)target_tvv, sizeof(target_tvv), 0); tv.tv_sec = (int32_t)tswap32(target_tvv[0]); tv.tv_usec = (int32_t)tswap32(target_tvv[1]); } regs[2] = select(fd + 1, rq == SELECT_ONE_READ ? &fdset : NULL, rq == SELECT_ONE_WRITE ? &fdset : NULL, rq == SELECT_ONE_EXCEPT ? &fdset : NULL, target_tv ? &tv : NULL); regs[3] = errno; } break; case TARGET_SYS_argc: regs[2] = 1; regs[3] = 0; break; case TARGET_SYS_argv_sz: regs[2] = 128; regs[3] = 0; break; case TARGET_SYS_argv: { struct Argv { uint32_t argptr[2]; char text[120]; } argv = { {0, 0}, "test" }; argv.argptr[0] = tswap32(regs[3] + offsetof(struct Argv, text)); cpu_memory_rw_debug( env, regs[3], (uint8_t *)&argv, sizeof(argv), 1); } break; case TARGET_SYS_memset: { uint32_t base = regs[3]; uint32_t sz = regs[5]; while (sz) { target_phys_addr_t len = sz; void *buf = cpu_physical_memory_map(base, &len, 1); if (buf && len) { memset(buf, regs[4], len); cpu_physical_memory_unmap(buf, len, 1, len); } else { len = 1; } base += len; sz -= len; } regs[2] = regs[3]; regs[3] = 0; } break; default: qemu_log("%s(%d): not implemented\n", __func__, regs[2]); break; } }
1,518
FFmpeg
5d31f03a0264cac24434c8108daef4ccba6d28f9
1
static void decode_lpc(int32_t *coeffs, int mode, int length) { int i; if (length < 2) return; if (mode == 1) { unsigned a1 = *coeffs++; for (i = 0; i < length - 1 >> 1; i++) { *coeffs += a1; coeffs[1] += *coeffs; a1 = coeffs[1]; coeffs += 2; } if (length - 1 & 1) *coeffs += a1; } else if (mode == 2) { unsigned a1 = coeffs[1]; unsigned a2 = a1 + *coeffs; coeffs[1] = a2; if (length > 2) { coeffs += 2; for (i = 0; i < length - 2 >> 1; i++) { unsigned a3 = *coeffs + a1; unsigned a4 = a3 + a2; *coeffs = a4; a1 = coeffs[1] + a3; a2 = a1 + a4; coeffs[1] = a2; coeffs += 2; } if (length & 1) *coeffs += a1 + a2; } } else if (mode == 3) { unsigned a1 = coeffs[1]; unsigned a2 = a1 + *coeffs; coeffs[1] = a2; if (length > 2) { unsigned a3 = coeffs[2]; unsigned a4 = a3 + a1; unsigned a5 = a4 + a2; coeffs[2] = a5; coeffs += 3; for (i = 0; i < length - 3; i++) { a3 += *coeffs; a4 += a3; a5 += a4; *coeffs = a5; coeffs++; } } } }
1,520
FFmpeg
e16e49ac90f6da9e019fdf23084cbb256d14bd9c
0
static void term_init(void) { #ifndef __MINGW32__ struct termios tty; tcgetattr (0, &tty); oldtty = tty; tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP |INLCR|IGNCR|ICRNL|IXON); tty.c_oflag |= OPOST; tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN); tty.c_cflag &= ~(CSIZE|PARENB); tty.c_cflag |= CS8; tty.c_cc[VMIN] = 1; tty.c_cc[VTIME] = 0; tcsetattr (0, TCSANOW, &tty); signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */ #endif signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */ signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */ /* register a function to be called at normal program termination */ atexit(term_exit); #ifdef CONFIG_BEOS_NETSERVER fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK); #endif }
1,521
FFmpeg
77693c541a541661357a0edd5bbaae69c64b2039
0
static int xan_decode_frame_type0(AVCodecContext *avctx) { XanContext *s = avctx->priv_data; uint8_t *ybuf, *prev_buf, *src = s->scratch_buffer; unsigned chroma_off, corr_off; int cur, last; int i, j; int ret; chroma_off = bytestream2_get_le32(&s->gb); corr_off = bytestream2_get_le32(&s->gb); if ((ret = xan_decode_chroma(avctx, chroma_off)) != 0) return ret; if (corr_off >= bytestream2_size(&s->gb)) { av_log(avctx, AV_LOG_WARNING, "Ignoring invalid correction block position\n"); corr_off = 0; } bytestream2_seek(&s->gb, 12, SEEK_SET); ret = xan_unpack_luma(s, src, s->buffer_size >> 1); if (ret) { av_log(avctx, AV_LOG_ERROR, "Luma decoding failed\n"); return ret; } ybuf = s->y_buffer; last = *src++; ybuf[0] = last << 1; for (j = 1; j < avctx->width - 1; j += 2) { cur = (last + *src++) & 0x1F; ybuf[j] = last + cur; ybuf[j+1] = cur << 1; last = cur; } ybuf[j] = last << 1; prev_buf = ybuf; ybuf += avctx->width; for (i = 1; i < avctx->height; i++) { last = ((prev_buf[0] >> 1) + *src++) & 0x1F; ybuf[0] = last << 1; for (j = 1; j < avctx->width - 1; j += 2) { cur = ((prev_buf[j + 1] >> 1) + *src++) & 0x1F; ybuf[j] = last + cur; ybuf[j+1] = cur << 1; last = cur; } if(j < avctx->width) ybuf[j] = last << 1; prev_buf = ybuf; ybuf += avctx->width; } if (corr_off) { int dec_size; bytestream2_seek(&s->gb, 8 + corr_off, SEEK_SET); dec_size = xan_unpack(s, s->scratch_buffer, s->buffer_size); if (dec_size < 0) dec_size = 0; else dec_size = FFMIN(dec_size, s->buffer_size/2 - 1); for (i = 0; i < dec_size; i++) s->y_buffer[i*2+1] = (s->y_buffer[i*2+1] + (s->scratch_buffer[i] << 1)) & 0x3F; } src = s->y_buffer; ybuf = s->pic.data[0]; for (j = 0; j < avctx->height; j++) { for (i = 0; i < avctx->width; i++) ybuf[i] = (src[i] << 2) | (src[i] >> 3); src += avctx->width; ybuf += s->pic.linesize[0]; } return 0; }
1,522
FFmpeg
f320fb894c695044ef15239d27844d9ac01c9d16
0
static int bethsoftvid_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { BethsoftvidContext * vid = avctx->priv_data; char block_type; uint8_t * dst; uint8_t * frame_end; int remaining = avctx->width; // number of bytes remaining on a line const int wrap_to_next_line = vid->frame.linesize[0] - avctx->width; int code; int yoffset; if (avctx->reget_buffer(avctx, &vid->frame)) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } bytestream2_init(&vid->g, avpkt->data, avpkt->size); dst = vid->frame.data[0]; frame_end = vid->frame.data[0] + vid->frame.linesize[0] * avctx->height; switch(block_type = bytestream2_get_byte(&vid->g)){ case PALETTE_BLOCK: { int ret; *data_size = 0; if ((ret = set_palette(vid)) < 0) { av_log(avctx, AV_LOG_ERROR, "error reading palette\n"); return ret; } return bytestream2_tell(&vid->g); } case VIDEO_YOFF_P_FRAME: yoffset = bytestream2_get_le16(&vid->g); if(yoffset >= avctx->height) return -1; dst += vid->frame.linesize[0] * yoffset; } // main code while((code = bytestream2_get_byte(&vid->g))){ int length = code & 0x7f; // copy any bytes starting at the current position, and ending at the frame width while(length > remaining){ if(code < 0x80) bytestream2_get_buffer(&vid->g, dst, remaining); else if(block_type == VIDEO_I_FRAME) memset(dst, bytestream2_peek_byte(&vid->g), remaining); length -= remaining; // decrement the number of bytes to be copied dst += remaining + wrap_to_next_line; // skip over extra bytes at end of frame remaining = avctx->width; if(dst == frame_end) goto end; } // copy any remaining bytes after / if line overflows if(code < 0x80) bytestream2_get_buffer(&vid->g, dst, length); else if(block_type == VIDEO_I_FRAME) memset(dst, bytestream2_get_byte(&vid->g), length); remaining -= length; dst += length; } end: *data_size = sizeof(AVFrame); *(AVFrame*)data = vid->frame; return avpkt->size; }
1,523
FFmpeg
810a8ba5b67389e808ed2f124e1cd54b8a26e679
0
static void decode_delta_d(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int flag, int bpp, int dst_size) { int planepitch = FFALIGN(w, 16) >> 3; int pitch = planepitch * bpp; int planepitch_byte = (w + 7) / 8; unsigned entries, ofssrc; GetByteContext gb, ptrs; PutByteContext pb; int k; if (buf_end - buf <= 4 * bpp) return; bytestream2_init_writer(&pb, dst, dst_size); bytestream2_init(&ptrs, buf, bpp * 4); for (k = 0; k < bpp; k++) { ofssrc = bytestream2_get_be32(&ptrs); if (!ofssrc) continue; if (ofssrc >= buf_end - buf) continue; bytestream2_init(&gb, buf + ofssrc, buf_end - (buf + ofssrc)); entries = bytestream2_get_be32(&gb); while (entries) { int32_t opcode = bytestream2_get_be32(&gb); unsigned offset = bytestream2_get_be32(&gb); bytestream2_seek_p(&pb, (offset / planepitch_byte) * pitch + (offset % planepitch_byte) + k * planepitch, SEEK_SET); if (opcode >= 0) { uint32_t x = bytestream2_get_be32(&gb); while (opcode && bytestream2_get_bytes_left_p(&pb) > 0) { bytestream2_put_be32(&pb, x); bytestream2_skip_p(&pb, pitch - 4); opcode--; } } else { opcode = -opcode; while (opcode && bytestream2_get_bytes_left(&gb) > 0) { bytestream2_put_be32(&pb, bytestream2_get_be32(&gb)); bytestream2_skip_p(&pb, pitch - 4); opcode--; } } entries--; } } }
1,524
FFmpeg
662234a9a22f1cd0f0ac83b8bb1ffadedca90c0a
0
static void avc_luma_hv_qrt_and_aver_dst_8x8_msa(const uint8_t *src_x, const uint8_t *src_y, int32_t src_stride, uint8_t *dst, int32_t dst_stride) { uint32_t loop_cnt; v16i8 src_hz0, src_hz1, src_hz2, src_hz3; v16u8 dst0, dst1, dst2, dst3; v16i8 src_vt0, src_vt1, src_vt2, src_vt3; v16i8 src_vt4, src_vt5, src_vt6, src_vt7, src_vt8; v16i8 mask0, mask1, mask2; v8i16 hz_out0, hz_out1, hz_out2, hz_out3; v8i16 vert_out0, vert_out1, vert_out2, vert_out3; v8i16 out0, out1, out2, out3; LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); LD_SB5(src_y, src_stride, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4); src_y += (5 * src_stride); src_vt0 = (v16i8) __msa_insve_d((v2i64) src_vt0, 1, (v2i64) src_vt1); src_vt1 = (v16i8) __msa_insve_d((v2i64) src_vt1, 1, (v2i64) src_vt2); src_vt2 = (v16i8) __msa_insve_d((v2i64) src_vt2, 1, (v2i64) src_vt3); src_vt3 = (v16i8) __msa_insve_d((v2i64) src_vt3, 1, (v2i64) src_vt4); XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3); for (loop_cnt = 2; loop_cnt--;) { LD_SB4(src_x, src_stride, src_hz0, src_hz1, src_hz2, src_hz3); XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3); src_x += (4 * src_stride); LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); hz_out0 = AVC_HORZ_FILTER_SH(src_hz0, mask0, mask1, mask2); hz_out1 = AVC_HORZ_FILTER_SH(src_hz1, mask0, mask1, mask2); hz_out2 = AVC_HORZ_FILTER_SH(src_hz2, mask0, mask1, mask2); hz_out3 = AVC_HORZ_FILTER_SH(src_hz3, mask0, mask1, mask2); SRARI_H4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 5); SAT_SH4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 7); LD_SB4(src_y, src_stride, src_vt5, src_vt6, src_vt7, src_vt8); src_y += (4 * src_stride); src_vt4 = (v16i8) __msa_insve_d((v2i64) src_vt4, 1, (v2i64) src_vt5); src_vt5 = (v16i8) __msa_insve_d((v2i64) src_vt5, 1, (v2i64) src_vt6); src_vt6 = (v16i8) __msa_insve_d((v2i64) src_vt6, 1, (v2i64) src_vt7); src_vt7 = (v16i8) __msa_insve_d((v2i64) src_vt7, 1, (v2i64) src_vt8); XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7); AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt0, src_vt1, src_vt2, src_vt3, src_vt4, src_vt5, vert_out0, vert_out1); AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt2, src_vt3, src_vt4, src_vt5, src_vt6, src_vt7, vert_out2, vert_out3); SRARI_H4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 5); SAT_SH4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 7); out0 = __msa_srari_h((hz_out0 + vert_out0), 1); out1 = __msa_srari_h((hz_out1 + vert_out1), 1); out2 = __msa_srari_h((hz_out2 + vert_out2), 1); out3 = __msa_srari_h((hz_out3 + vert_out3), 1); SAT_SH4_SH(out0, out1, out2, out3, 7); ILVR_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1); CONVERT_UB_AVG_ST8x4_UB(out0, out1, out2, out3, dst0, dst1, dst, dst_stride); dst += (4 * dst_stride); src_vt0 = src_vt4; src_vt1 = src_vt5; src_vt2 = src_vt6; src_vt3 = src_vt7; src_vt4 = src_vt8; } }
1,526
FFmpeg
2254b559cbcfc0418135f09add37c0a5866b1981
1
static void hScale8To19_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *src, const int16_t *filter, const int16_t *filterPos, int filterSize) { int i; int32_t *dst = (int32_t *) _dst; for (i=0; i<dstW; i++) { int j; int srcPos= filterPos[i]; int val=0; for (j=0; j<filterSize; j++) { val += ((int)src[srcPos + j])*filter[filterSize*i + j]; } //filter += hFilterSize; dst[i] = FFMIN(val>>3, (1<<19)-1); // the cubic equation does overflow ... //dst[i] = val>>7; } }
1,527
qemu
e95205e1f9cd2c4262b7a7b1c992a94512c86d0e
1
static void cpu_notify_map_clients_locked(void) { MapClient *client; while (!QLIST_EMPTY(&map_client_list)) { client = QLIST_FIRST(&map_client_list); client->callback(client->opaque); cpu_unregister_map_client(client); } }
1,529
FFmpeg
5ef19590802f000299e418143fc2301e3f43affe
1
int show_bsfs(void *optctx, const char *opt, const char *arg) { AVBitStreamFilter *bsf = NULL; printf("Bitstream filters:\n"); while ((bsf = av_bitstream_filter_next(bsf))) printf("%s\n", bsf->name); printf("\n"); return 0; }
1,530
FFmpeg
3aa661ec561d7a20812b84b353b0d7855ac346c8
1
static inline int decode_vui_parameters(H264Context *h, SPS *sps){ MpegEncContext * const s = &h->s; int aspect_ratio_info_present_flag; unsigned int aspect_ratio_idc; aspect_ratio_info_present_flag= get_bits1(&s->gb); if( aspect_ratio_info_present_flag ) { aspect_ratio_idc= get_bits(&s->gb, 8); if( aspect_ratio_idc == EXTENDED_SAR ) { sps->sar.num= get_bits(&s->gb, 16); sps->sar.den= get_bits(&s->gb, 16); }else if(aspect_ratio_idc < FF_ARRAY_ELEMS(pixel_aspect)){ sps->sar= pixel_aspect[aspect_ratio_idc]; }else{ av_log(h->s.avctx, AV_LOG_ERROR, "illegal aspect ratio\n"); return -1; } }else{ sps->sar.num= sps->sar.den= 0; } // s->avctx->aspect_ratio= sar_width*s->width / (float)(s->height*sar_height); if(get_bits1(&s->gb)){ /* overscan_info_present_flag */ get_bits1(&s->gb); /* overscan_appropriate_flag */ } sps->video_signal_type_present_flag = get_bits1(&s->gb); if(sps->video_signal_type_present_flag){ get_bits(&s->gb, 3); /* video_format */ sps->full_range = get_bits1(&s->gb); /* video_full_range_flag */ sps->colour_description_present_flag = get_bits1(&s->gb); if(sps->colour_description_present_flag){ sps->color_primaries = get_bits(&s->gb, 8); /* colour_primaries */ sps->color_trc = get_bits(&s->gb, 8); /* transfer_characteristics */ sps->colorspace = get_bits(&s->gb, 8); /* matrix_coefficients */ if (sps->color_primaries >= AVCOL_PRI_NB) sps->color_primaries = AVCOL_PRI_UNSPECIFIED; if (sps->color_trc >= AVCOL_TRC_NB) sps->color_trc = AVCOL_TRC_UNSPECIFIED; if (sps->colorspace >= AVCOL_SPC_NB) sps->colorspace = AVCOL_SPC_UNSPECIFIED; } } if(get_bits1(&s->gb)){ /* chroma_location_info_present_flag */ s->avctx->chroma_sample_location = get_ue_golomb(&s->gb)+1; /* chroma_sample_location_type_top_field */ get_ue_golomb(&s->gb); /* chroma_sample_location_type_bottom_field */ } sps->timing_info_present_flag = get_bits1(&s->gb); if(sps->timing_info_present_flag){ sps->num_units_in_tick = get_bits_long(&s->gb, 32); sps->time_scale = get_bits_long(&s->gb, 32); if(!sps->num_units_in_tick || !sps->time_scale){ av_log(h->s.avctx, AV_LOG_ERROR, "time_scale/num_units_in_tick invalid or unsupported (%d/%d)\n", sps->time_scale, sps->num_units_in_tick); return -1; } sps->fixed_frame_rate_flag = get_bits1(&s->gb); } sps->nal_hrd_parameters_present_flag = get_bits1(&s->gb); if(sps->nal_hrd_parameters_present_flag) if(decode_hrd_parameters(h, sps) < 0) return -1; sps->vcl_hrd_parameters_present_flag = get_bits1(&s->gb); if(sps->vcl_hrd_parameters_present_flag) if(decode_hrd_parameters(h, sps) < 0) return -1; if(sps->nal_hrd_parameters_present_flag || sps->vcl_hrd_parameters_present_flag) get_bits1(&s->gb); /* low_delay_hrd_flag */ sps->pic_struct_present_flag = get_bits1(&s->gb); sps->bitstream_restriction_flag = get_bits1(&s->gb); if(sps->bitstream_restriction_flag){ get_bits1(&s->gb); /* motion_vectors_over_pic_boundaries_flag */ get_ue_golomb(&s->gb); /* max_bytes_per_pic_denom */ get_ue_golomb(&s->gb); /* max_bits_per_mb_denom */ get_ue_golomb(&s->gb); /* log2_max_mv_length_horizontal */ get_ue_golomb(&s->gb); /* log2_max_mv_length_vertical */ sps->num_reorder_frames= get_ue_golomb(&s->gb); get_ue_golomb(&s->gb); /*max_dec_frame_buffering*/ if (get_bits_left(&s->gb) < 0) { av_log(h->s.avctx, AV_LOG_ERROR, "Overread VUI by %d bits\n", -get_bits_left(&s->gb)); sps->num_reorder_frames=0; sps->bitstream_restriction_flag= 0; } if(sps->num_reorder_frames > 16U /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){ av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", sps->num_reorder_frames); return -1; } } return 0; }
1,531
qemu
e122636562218b3d442cd2cd18fbc188dd9ce709
1
void migration_set_incoming_channel(MigrationState *s, QIOChannel *ioc) { QEMUFile *f = qemu_fopen_channel_input(ioc); process_incoming_migration(f); }
1,532
qemu
1e973051b96bac5eef46393eec15b68796e7c7d3
1
static int buffered_rate_limit(void *opaque) { MigrationState *s = opaque; int ret; ret = qemu_file_get_error(s->file); if (ret) { return ret; } if (s->bytes_xfer > s->xfer_limit) { return 1; } return 0; }
1,534
FFmpeg
5d7e3d71673d64a16b58430a0027afadb6b3a54e
1
static const unsigned char *seq_decode_op2(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst) { int i; for (i = 0; i < 8; i++) { memcpy(dst, src, 8); src += 8; dst += seq->frame.linesize[0]; } return src; }
1,535
FFmpeg
f3abdf4392a146462dc679846c061b8bf2b5c7a0
1
int opt_default(void *optctx, const char *opt, const char *arg) { const AVOption *o; int consumed = 0; char opt_stripped[128]; const char *p; const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(); const av_unused AVClass *rc_class; const AVClass *sc, *swr_class; if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug")) av_log_set_level(AV_LOG_DEBUG); if (!(p = strchr(opt, ':'))) p = opt + strlen(opt); av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1)); if ((o = av_opt_find(&cc, opt_stripped, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) || ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && (o = av_opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) { av_dict_set(&codec_opts, opt, arg, FLAGS); consumed = 1; } if ((o = av_opt_find(&fc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { av_dict_set(&format_opts, opt, arg, FLAGS); if(consumed) av_log(NULL, AV_LOG_VERBOSE, "Routing %s to codec and muxer layer\n", opt); consumed = 1; } #if CONFIG_SWSCALE sc = sws_get_class(); if (!consumed && av_opt_find(&sc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { // XXX we only support sws_flags, not arbitrary sws options int ret = av_opt_set(sws_opts, opt, arg, 0); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); return ret; } consumed = 1; } #endif #if CONFIG_SWRESAMPLE swr_class = swr_get_class(); if (!consumed && av_opt_find(&swr_class, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { int ret = av_opt_set(swr_opts, opt, arg, 0); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); return ret; } consumed = 1; } #endif #if CONFIG_AVRESAMPLE rc_class = avresample_get_class(); if (av_opt_find(&rc_class, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { av_dict_set(&resample_opts, opt, arg, FLAGS); consumed = 1; } #endif if (consumed) return 0; return AVERROR_OPTION_NOT_FOUND; }
1,536
qemu
4b32e11a59e34c5cf570c1fd102a78d9351e71f5
1
static void event_test_emit(test_QAPIEvent event, QDict *d, Error **errp) { QObject *obj; QDict *t; int64_t s, ms; /* Verify that we have timestamp, then remove it to compare other fields */ obj = qdict_get(d, "timestamp"); g_assert(obj); t = qobject_to_qdict(obj); g_assert(t); obj = qdict_get(t, "seconds"); g_assert(obj && qobject_type(obj) == QTYPE_QINT); s = qint_get_int(qobject_to_qint(obj)); obj = qdict_get(t, "microseconds"); g_assert(obj && qobject_type(obj) == QTYPE_QINT); ms = qint_get_int(qobject_to_qint(obj)); if (s == -1) { g_assert(ms == -1); } else { g_assert(ms >= 0 && ms <= 999999); } g_assert(qdict_size(t) == 2); qdict_del(d, "timestamp"); g_assert(qdict_cmp_simple(d, test_event_data->expect)); }
1,537
FFmpeg
6796a1dd8c14843b77925cb83a3ef88706ae1dd0
0
void ff_put_h264_qpel8_mc20_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hz_8w_msa(src - 2, stride, dst, stride, 8); }
1,538
FFmpeg
aeb23fc4549a25ef32ff085d2a76227f90caf403
0
static void ini_print_object_header(const char *name) { int i; PrintElement *el = octx.prefix + octx.level -1; if (el->nb_elems) avio_printf(probe_out, "\n"); avio_printf(probe_out, "["); for (i = 1; i < octx.level; i++) { el = octx.prefix + i; avio_printf(probe_out, "%s.", el->name); if (el->index >= 0) avio_printf(probe_out, "%"PRId64".", el->index); } avio_printf(probe_out, "%s", name); if (el && el->type == ARRAY) avio_printf(probe_out, ".%"PRId64"", el->nb_elems); avio_printf(probe_out, "]\n"); }
1,539
FFmpeg
0f87b42b44f8da7234e8e43b27d1dc5e4dce7582
0
int avformat_queue_attached_pictures(AVFormatContext *s) { int i; for (i = 0; i < s->nb_streams; i++) if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC && s->streams[i]->discard < AVDISCARD_ALL) { AVPacket copy = s->streams[i]->attached_pic; if (copy.size <= 0) return AVERROR(EINVAL); copy.buf = av_buffer_ref(copy.buf); if (!copy.buf) return AVERROR(ENOMEM); add_to_pktbuf(&s->raw_packet_buffer, &copy, &s->raw_packet_buffer_end); } return 0; }
1,541
FFmpeg
486637af8ef29ec215e0e0b7ecd3b5470f0e04e5
0
static inline void mix_dualmono_to_mono(AC3DecodeContext *ctx) { int i; float (*output)[256] = ctx->audio_block.block_output; for (i = 0; i < 256; i++) output[1][i] += output[2][i]; memset(output[2], 0, sizeof(output[2])); }
1,542
FFmpeg
1e763454322f7fbc7799f6009bf2e11d7a3b9821
0
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { PNGDecContext *const s = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVFrame *p = data; uint8_t *crow_buf_base = NULL; uint32_t tag, length; int ret; /* check signature */ if (buf_size < 8 || memcmp(buf, ff_pngsig, 8) != 0 && memcmp(buf, ff_mngsig, 8) != 0) return -1; bytestream2_init(&s->gb, buf + 8, buf_size - 8); s->y = s->state = 0; /* init the zlib */ s->zstream.zalloc = ff_png_zalloc; s->zstream.zfree = ff_png_zfree; s->zstream.opaque = NULL; ret = inflateInit(&s->zstream); if (ret != Z_OK) return -1; for (;;) { if (bytestream2_get_bytes_left(&s->gb) <= 0) goto fail; length = bytestream2_get_be32(&s->gb); if (length > 0x7fffffff) goto fail; tag = bytestream2_get_le32(&s->gb); av_dlog(avctx, "png: tag=%c%c%c%c length=%u\n", (tag & 0xff), ((tag >> 8) & 0xff), ((tag >> 16) & 0xff), ((tag >> 24) & 0xff), length); switch (tag) { case MKTAG('I', 'H', 'D', 'R'): if (length != 13) goto fail; s->width = bytestream2_get_be32(&s->gb); s->height = bytestream2_get_be32(&s->gb); if (av_image_check_size(s->width, s->height, 0, avctx)) { s->width = s->height = 0; goto fail; } s->bit_depth = bytestream2_get_byte(&s->gb); s->color_type = bytestream2_get_byte(&s->gb); s->compression_type = bytestream2_get_byte(&s->gb); s->filter_type = bytestream2_get_byte(&s->gb); s->interlace_type = bytestream2_get_byte(&s->gb); bytestream2_skip(&s->gb, 4); /* crc */ s->state |= PNG_IHDR; av_dlog(avctx, "width=%d height=%d depth=%d color_type=%d " "compression_type=%d filter_type=%d interlace_type=%d\n", s->width, s->height, s->bit_depth, s->color_type, s->compression_type, s->filter_type, s->interlace_type); break; case MKTAG('I', 'D', 'A', 'T'): if (!(s->state & PNG_IHDR)) goto fail; if (!(s->state & PNG_IDAT)) { /* init image info */ avctx->width = s->width; avctx->height = s->height; s->channels = ff_png_get_nb_channels(s->color_type); s->bits_per_pixel = s->bit_depth * s->channels; s->bpp = (s->bits_per_pixel + 7) >> 3; s->row_size = (avctx->width * s->bits_per_pixel + 7) >> 3; if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_RGB) { avctx->pix_fmt = AV_PIX_FMT_RGB24; } else if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { avctx->pix_fmt = AV_PIX_FMT_RGB32; } else if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_GRAY) { avctx->pix_fmt = AV_PIX_FMT_GRAY8; } else if (s->bit_depth == 16 && s->color_type == PNG_COLOR_TYPE_GRAY) { avctx->pix_fmt = AV_PIX_FMT_GRAY16BE; } else if (s->bit_depth == 16 && s->color_type == PNG_COLOR_TYPE_RGB) { avctx->pix_fmt = AV_PIX_FMT_RGB48BE; } else if (s->bit_depth == 1 && s->color_type == PNG_COLOR_TYPE_GRAY) { avctx->pix_fmt = AV_PIX_FMT_MONOBLACK; } else if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_PALETTE) { avctx->pix_fmt = AV_PIX_FMT_PAL8; } else if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { avctx->pix_fmt = AV_PIX_FMT_YA8; } else if (s->bit_depth == 16 && s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { avctx->pix_fmt = AV_PIX_FMT_YA16BE; } else { goto fail; } if (ff_get_buffer(avctx, p, AV_GET_BUFFER_FLAG_REF) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); goto fail; } p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; p->interlaced_frame = !!s->interlace_type; /* compute the compressed row size */ if (!s->interlace_type) { s->crow_size = s->row_size + 1; } else { s->pass = 0; s->pass_row_size = ff_png_pass_row_size(s->pass, s->bits_per_pixel, s->width); s->crow_size = s->pass_row_size + 1; } av_dlog(avctx, "row_size=%d crow_size =%d\n", s->row_size, s->crow_size); s->image_buf = p->data[0]; s->image_linesize = p->linesize[0]; /* copy the palette if needed */ if (s->color_type == PNG_COLOR_TYPE_PALETTE) memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t)); /* empty row is used if differencing to the first row */ s->last_row = av_mallocz(s->row_size); if (!s->last_row) goto fail; if (s->interlace_type || s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { s->tmp_row = av_malloc(s->row_size); if (!s->tmp_row) goto fail; } /* compressed row */ crow_buf_base = av_malloc(s->row_size + 16); if (!crow_buf_base) goto fail; /* we want crow_buf+1 to be 16-byte aligned */ s->crow_buf = crow_buf_base + 15; s->zstream.avail_out = s->crow_size; s->zstream.next_out = s->crow_buf; } s->state |= PNG_IDAT; if (png_decode_idat(s, length) < 0) goto fail; bytestream2_skip(&s->gb, 4); /* crc */ break; case MKTAG('P', 'L', 'T', 'E'): { int n, i, r, g, b; if ((length % 3) != 0 || length > 256 * 3) goto skip_tag; /* read the palette */ n = length / 3; for (i = 0; i < n; i++) { r = bytestream2_get_byte(&s->gb); g = bytestream2_get_byte(&s->gb); b = bytestream2_get_byte(&s->gb); s->palette[i] = (0xff << 24) | (r << 16) | (g << 8) | b; } for (; i < 256; i++) s->palette[i] = (0xff << 24); s->state |= PNG_PLTE; bytestream2_skip(&s->gb, 4); /* crc */ } break; case MKTAG('t', 'R', 'N', 'S'): { int v, i; /* read the transparency. XXX: Only palette mode supported */ if (s->color_type != PNG_COLOR_TYPE_PALETTE || length > 256 || !(s->state & PNG_PLTE)) goto skip_tag; for (i = 0; i < length; i++) { v = bytestream2_get_byte(&s->gb); s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24); } bytestream2_skip(&s->gb, 4); /* crc */ } break; case MKTAG('I', 'E', 'N', 'D'): if (!(s->state & PNG_ALLIMAGE)) goto fail; bytestream2_skip(&s->gb, 4); /* crc */ goto exit_loop; default: /* skip tag */ skip_tag: bytestream2_skip(&s->gb, length + 4); break; } } exit_loop: /* handle p-frames only if a predecessor frame is available */ if (s->prev->data[0]) { if (!(avpkt->flags & AV_PKT_FLAG_KEY)) { int i, j; uint8_t *pd = p->data[0]; uint8_t *pd_last = s->prev->data[0]; for (j = 0; j < s->height; j++) { for (i = 0; i < s->width * s->bpp; i++) pd[i] += pd_last[i]; pd += s->image_linesize; pd_last += s->image_linesize; } } } av_frame_unref(s->prev); if ((ret = av_frame_ref(s->prev, p)) < 0) goto fail; *got_frame = 1; ret = bytestream2_tell(&s->gb); the_end: inflateEnd(&s->zstream); av_free(crow_buf_base); s->crow_buf = NULL; av_freep(&s->last_row); av_freep(&s->tmp_row); return ret; fail: ret = -1; goto the_end; }
1,543
qemu
79853e18d904b0a4bcef62701d48559688007c93
0
static bool rtas_event_log_contains(uint32_t event_mask) { sPAPREventLogEntry *entry = NULL; /* we only queue EPOW events atm. */ if ((event_mask & EVENT_MASK_EPOW) == 0) { return false; } QTAILQ_FOREACH(entry, &spapr->pending_events, next) { /* EPOW and hotplug events are surfaced in the same manner */ if (entry->log_type == RTAS_LOG_TYPE_EPOW || entry->log_type == RTAS_LOG_TYPE_HOTPLUG) { return true; } } return false; }
1,544
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
0
static void test_visitor_out_native_list_int16(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S16); }
1,545
qemu
9a78eead0c74333a394c0f7bbfc4423ac746fcd5
0
void sh4_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) { int i; for (i = 0; i < ARRAY_SIZE(sh4_defs); i++) (*cpu_fprintf)(f, "%s\n", sh4_defs[i].name); }
1,546
qemu
7c7e9df0232a1ce5c411f0f348038d2e72097ae1
0
static int qemu_rbd_set_conf(rados_t cluster, const char *conf) { char *p, *buf; char name[RBD_MAX_CONF_NAME_SIZE]; char value[RBD_MAX_CONF_VAL_SIZE]; int ret = 0; buf = g_strdup(conf); p = buf; while (p) { ret = qemu_rbd_next_tok(name, sizeof(name), p, '=', "conf option name", &p); if (ret < 0) { break; } if (!p) { error_report("conf option %s has no value", name); ret = -EINVAL; break; } ret = qemu_rbd_next_tok(value, sizeof(value), p, ':', "conf option value", &p); if (ret < 0) { break; } if (strcmp(name, "conf")) { ret = rados_conf_set(cluster, name, value); if (ret < 0) { error_report("invalid conf option %s", name); ret = -EINVAL; break; } } else { ret = rados_conf_read_file(cluster, value); if (ret < 0) { error_report("error reading conf file %s", value); break; } } } g_free(buf); return ret; }
1,547
qemu
eabb7b91b36b202b4dac2df2d59d698e3aff197a
0
static void patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { assert(type == R_ARM_PC24); assert(addend == 0); reloc_pc24(code_ptr, (tcg_insn_unit *)value); }
1,548
FFmpeg
1181d93231e9b807965724587d363c1cfd5a1d0d
0
void ff_avg_h264_qpel8_mc13_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hv_qrt_and_aver_dst_8x8_msa(src + stride - 2, src - (stride * 2), stride, dst, stride); }
1,549
qemu
879c28133dfa54b780dffbb29e4dcfc6581f6281
0
static int v9fs_do_symlink(V9fsState *s, V9fsString *oldpath, V9fsString *newpath) { return s->ops->symlink(&s->ctx, oldpath->data, newpath->data); }
1,550
qemu
b227a8e9aa5f27d29f77ba90d5eb9d0662a1175e
0
static int find_pte32 (mmu_ctx_t *ctx, int h, int rw) { return _find_pte(ctx, 0, h, rw); }
1,551
qemu
3706c43f021918684cf19fe0f6ef8498815e4313
0
static int nic_load(QEMUFile * f, void *opaque, int version_id) { EEPRO100State *s = opaque; int i; int ret; if (version_id > 3) return -EINVAL; if (version_id >= 3) { ret = pci_device_load(&s->dev, f); if (ret < 0) return ret; } if (version_id >= 2) { qemu_get_8s(f, &s->rxcr); } else { s->rxcr = 0x0c; } qemu_get_8s(f, &s->cmd); qemu_get_be32s(f, &s->start); qemu_get_be32s(f, &s->stop); qemu_get_8s(f, &s->boundary); qemu_get_8s(f, &s->tsr); qemu_get_8s(f, &s->tpsr); qemu_get_be16s(f, &s->tcnt); qemu_get_be16s(f, &s->rcnt); qemu_get_be32s(f, &s->rsar); qemu_get_8s(f, &s->rsr); qemu_get_8s(f, &s->isr); qemu_get_8s(f, &s->dcfg); qemu_get_8s(f, &s->imr); qemu_get_buffer(f, s->phys, 6); qemu_get_8s(f, &s->curpag); qemu_get_buffer(f, s->mult, 8); qemu_get_buffer(f, s->mem, sizeof(s->mem)); /* Restore all members of struct between scv_stat and mem. */ qemu_get_8s(f, &s->scb_stat); qemu_get_8s(f, &s->int_stat); for (i = 0; i < 3; i++) { qemu_get_be32s(f, &s->region[i]); } qemu_get_buffer(f, s->macaddr, 6); for (i = 0; i < 19; i++) { qemu_get_be32s(f, &s->statcounter[i]); } for (i = 0; i < 32; i++) { qemu_get_be16s(f, &s->mdimem[i]); } /* The eeprom should be saved and restored by its own routines. */ qemu_get_be32s(f, &s->device); qemu_get_be32s(f, &s->pointer); qemu_get_be32s(f, &s->cu_base); qemu_get_be32s(f, &s->cu_offset); qemu_get_be32s(f, &s->ru_base); qemu_get_be32s(f, &s->ru_offset); qemu_get_be32s(f, &s->statsaddr); /* Restore epro100_stats_t statistics. */ qemu_get_be32s(f, &s->statistics.tx_good_frames); qemu_get_be32s(f, &s->statistics.tx_max_collisions); qemu_get_be32s(f, &s->statistics.tx_late_collisions); qemu_get_be32s(f, &s->statistics.tx_underruns); qemu_get_be32s(f, &s->statistics.tx_lost_crs); qemu_get_be32s(f, &s->statistics.tx_deferred); qemu_get_be32s(f, &s->statistics.tx_single_collisions); qemu_get_be32s(f, &s->statistics.tx_multiple_collisions); qemu_get_be32s(f, &s->statistics.tx_total_collisions); qemu_get_be32s(f, &s->statistics.rx_good_frames); qemu_get_be32s(f, &s->statistics.rx_crc_errors); qemu_get_be32s(f, &s->statistics.rx_alignment_errors); qemu_get_be32s(f, &s->statistics.rx_resource_errors); qemu_get_be32s(f, &s->statistics.rx_overrun_errors); qemu_get_be32s(f, &s->statistics.rx_cdt_errors); qemu_get_be32s(f, &s->statistics.rx_short_frame_errors); qemu_get_be32s(f, &s->statistics.fc_xmt_pause); qemu_get_be32s(f, &s->statistics.fc_rcv_pause); qemu_get_be32s(f, &s->statistics.fc_rcv_unsupported); qemu_get_be16s(f, &s->statistics.xmt_tco_frames); qemu_get_be16s(f, &s->statistics.rcv_tco_frames); qemu_get_be32s(f, &s->statistics.complete); #if 0 qemu_get_be16s(f, &s->status); #endif /* Configuration bytes. */ qemu_get_buffer(f, s->configuration, sizeof(s->configuration)); return 0; }
1,552
qemu
b3ceef24f4fee8d5ed96b8c4a5d3e80c0a651f0b
0
static uint32_t slavio_serial_mem_readb(void *opaque, target_phys_addr_t addr) { SerialState *ser = opaque; ChannelState *s; uint32_t saddr; uint32_t ret; int channel; saddr = (addr & 3) >> 1; channel = (addr & SERIAL_MAXADDR) >> 2; s = &ser->chn[channel]; switch (saddr) { case 0: SER_DPRINTF("Read channel %c, reg[%d] = %2.2x\n", CHN_C(s), s->reg, s->rregs[s->reg]); ret = s->rregs[s->reg]; s->reg = 0; return ret; case 1: s->rregs[0] &= ~1; clr_rxint(s); if (s->type == kbd || s->type == mouse) ret = get_queue(s); else ret = s->rx; SER_DPRINTF("Read channel %c, ch %d\n", CHN_C(s), ret); return ret; default: break; } return 0; }
1,553
qemu
b769d8fef6c06ddb39ef0337882a4f8872b9c2bc
0
int cpu_sparc_handle_mmu_fault (CPUState *env, uint32_t address, int rw, int is_user, int is_softmmu) { int exception = 0; int access_type, access_perms = 0, access_index = 0; uint8_t *pde_ptr; uint32_t pde, virt_addr; int error_code = 0, is_dirty, prot, ret = 0; unsigned long paddr, vaddr, page_offset; access_type = env->access_type; if (env->user_mode_only) { /* user mode only emulation */ ret = -2; goto do_fault; } virt_addr = address & TARGET_PAGE_MASK; if ((env->mmuregs[0] & MMU_E) == 0) { /* MMU disabled */ paddr = address; page_offset = address & (TARGET_PAGE_SIZE - 1); prot = PAGE_READ | PAGE_WRITE; goto do_mapping; } /* SPARC reference MMU table walk: Context table->L1->L2->PTE */ /* Context base + context number */ pde_ptr = phys_ram_base + (env->mmuregs[1] << 4) + (env->mmuregs[2] << 4); env->access_type = ACCESS_MMU; pde = ldl_raw(pde_ptr); /* Ctx pde */ switch (pde & PTE_ENTRYTYPE_MASK) { case 0: /* Invalid */ error_code = 1; goto do_fault; case 2: /* PTE, maybe should not happen? */ case 3: /* Reserved */ error_code = 4; goto do_fault; case 1: /* L1 PDE */ pde_ptr = phys_ram_base + ((address >> 22) & ~3) + ((pde & ~3) << 4); pde = ldl_raw(pde_ptr); switch (pde & PTE_ENTRYTYPE_MASK) { case 0: /* Invalid */ error_code = 1; goto do_fault; case 3: /* Reserved */ error_code = 4; goto do_fault; case 1: /* L2 PDE */ pde_ptr = phys_ram_base + ((address & 0xfc0000) >> 16) + ((pde & ~3) << 4); pde = ldl_raw(pde_ptr); switch (pde & PTE_ENTRYTYPE_MASK) { case 0: /* Invalid */ error_code = 1; goto do_fault; case 3: /* Reserved */ error_code = 4; goto do_fault; case 1: /* L3 PDE */ pde_ptr = phys_ram_base + ((address & 0x3f000) >> 10) + ((pde & ~3) << 4); pde = ldl_raw(pde_ptr); switch (pde & PTE_ENTRYTYPE_MASK) { case 0: /* Invalid */ error_code = 1; goto do_fault; case 1: /* PDE, should not happen */ case 3: /* Reserved */ error_code = 4; goto do_fault; case 2: /* L3 PTE */ virt_addr = address & TARGET_PAGE_MASK; page_offset = (address & TARGET_PAGE_MASK) & (TARGET_PAGE_SIZE - 1); } break; case 2: /* L2 PTE */ virt_addr = address & ~0x3ffff; page_offset = address & 0x3ffff; } break; case 2: /* L1 PTE */ virt_addr = address & ~0xffffff; page_offset = address & 0xffffff; } } /* update page modified and dirty bits */ is_dirty = rw && !(pde & PG_MODIFIED_MASK); if (!(pde & PG_ACCESSED_MASK) || is_dirty) { pde |= PG_ACCESSED_MASK; if (is_dirty) pde |= PG_MODIFIED_MASK; stl_raw(pde_ptr, pde); } /* check access */ access_index = (rw << 2) | ((access_type == ACCESS_CODE)? 2 : 0) | (is_user? 0 : 1); access_perms = (pde & PTE_ACCESS_MASK) >> PTE_ACCESS_SHIFT; error_code = access_table[access_index][access_perms]; if (error_code) goto do_fault; /* the page can be put in the TLB */ prot = PAGE_READ; if (pde & PG_MODIFIED_MASK) { /* only set write access if already dirty... otherwise wait for dirty access */ if (rw_table[is_user][access_perms]) prot |= PAGE_WRITE; } /* Even if large ptes, we map only one 4KB page in the cache to avoid filling it too fast */ virt_addr = address & TARGET_PAGE_MASK; paddr = ((pde & PTE_ADDR_MASK) << 4) + page_offset; do_mapping: env->access_type = access_type; vaddr = virt_addr + ((address & TARGET_PAGE_MASK) & (TARGET_PAGE_SIZE - 1)); ret = tlb_set_page(env, vaddr, paddr, prot, is_user, is_softmmu); return ret; do_fault: env->access_type = access_type; if (env->mmuregs[3]) /* Fault status register */ env->mmuregs[3] = 1; /* overflow (not read before another fault) */ env->mmuregs[3] |= (access_index << 5) | (error_code << 2) | 2; env->mmuregs[4] = address; /* Fault address register */ if (env->mmuregs[0] & MMU_NF) // No fault return 0; env->exception_index = exception; env->error_code = error_code; return error_code; }
1,554
qemu
7f6613cedc59fa849105668ae971dc31004bca1c
0
static void gen_farith (DisasContext *ctx, enum fopcode op1, int ft, int fs, int fd, int cc) { const char *opn = "farith"; const char *condnames[] = { "c.f", "c.un", "c.eq", "c.ueq", "c.olt", "c.ult", "c.ole", "c.ule", "c.sf", "c.ngle", "c.seq", "c.ngl", "c.lt", "c.nge", "c.le", "c.ngt", }; const char *condnames_abs[] = { "cabs.f", "cabs.un", "cabs.eq", "cabs.ueq", "cabs.olt", "cabs.ult", "cabs.ole", "cabs.ule", "cabs.sf", "cabs.ngle", "cabs.seq", "cabs.ngl", "cabs.lt", "cabs.nge", "cabs.le", "cabs.ngt", }; enum { BINOP, CMPOP, OTHEROP } optype = OTHEROP; uint32_t func = ctx->opcode & 0x3f; switch (op1) { case OPC_ADD_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_add_s(fp0, cpu_env, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "add.s"; optype = BINOP; break; case OPC_SUB_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_sub_s(fp0, cpu_env, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "sub.s"; optype = BINOP; break; case OPC_MUL_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_mul_s(fp0, cpu_env, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "mul.s"; optype = BINOP; break; case OPC_DIV_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_div_s(fp0, cpu_env, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "div.s"; optype = BINOP; break; case OPC_SQRT_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_sqrt_s(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "sqrt.s"; break; case OPC_ABS_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_abs_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "abs.s"; break; case OPC_MOV_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "mov.s"; break; case OPC_NEG_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_chs_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "neg.s"; break; case OPC_ROUND_L_S: check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_roundl_s(fp64, cpu_env, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "round.l.s"; break; case OPC_TRUNC_L_S: check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_truncl_s(fp64, cpu_env, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "trunc.l.s"; break; case OPC_CEIL_L_S: check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_ceill_s(fp64, cpu_env, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "ceil.l.s"; break; case OPC_FLOOR_L_S: check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_floorl_s(fp64, cpu_env, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "floor.l.s"; break; case OPC_ROUND_W_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_roundw_s(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "round.w.s"; break; case OPC_TRUNC_W_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_truncw_s(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "trunc.w.s"; break; case OPC_CEIL_W_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_ceilw_s(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "ceil.w.s"; break; case OPC_FLOOR_W_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_floorw_s(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "floor.w.s"; break; case OPC_MOVCF_S: gen_movcf_s(fs, fd, (ft >> 2) & 0x7, ft & 0x1); opn = "movcf.s"; break; case OPC_MOVZ_S: { int l1 = gen_new_label(); TCGv_i32 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[ft], 0, l1); } fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); gen_set_label(l1); } opn = "movz.s"; break; case OPC_MOVN_S: { int l1 = gen_new_label(); TCGv_i32 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); gen_set_label(l1); } } opn = "movn.s"; break; case OPC_RECIP_S: check_cop1x(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_recip_s(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "recip.s"; break; case OPC_RSQRT_S: check_cop1x(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_rsqrt_s(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "rsqrt.s"; break; case OPC_RECIP2_S: check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_recip2_s(fp0, cpu_env, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "recip2.s"; break; case OPC_RECIP1_S: check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_recip1_s(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "recip1.s"; break; case OPC_RSQRT1_S: check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_rsqrt1_s(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "rsqrt1.s"; break; case OPC_RSQRT2_S: check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_rsqrt2_s(fp0, cpu_env, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "rsqrt2.s"; break; case OPC_CVT_D_S: check_cp1_registers(ctx, fd); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_cvtd_s(fp64, cpu_env, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.d.s"; break; case OPC_CVT_W_S: { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_cvtw_s(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.w.s"; break; case OPC_CVT_L_S: check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_cvtl_s(fp64, cpu_env, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.l.s"; break; case OPC_CVT_PS_S: check_cp1_64bitmode(ctx); { TCGv_i64 fp64 = tcg_temp_new_i64(); TCGv_i32 fp32_0 = tcg_temp_new_i32(); TCGv_i32 fp32_1 = tcg_temp_new_i32(); gen_load_fpr32(fp32_0, fs); gen_load_fpr32(fp32_1, ft); tcg_gen_concat_i32_i64(fp64, fp32_1, fp32_0); tcg_temp_free_i32(fp32_1); tcg_temp_free_i32(fp32_0); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.ps.s"; break; case OPC_CMP_F_S: case OPC_CMP_UN_S: case OPC_CMP_EQ_S: case OPC_CMP_UEQ_S: case OPC_CMP_OLT_S: case OPC_CMP_ULT_S: case OPC_CMP_OLE_S: case OPC_CMP_ULE_S: case OPC_CMP_SF_S: case OPC_CMP_NGLE_S: case OPC_CMP_SEQ_S: case OPC_CMP_NGL_S: case OPC_CMP_LT_S: case OPC_CMP_NGE_S: case OPC_CMP_LE_S: case OPC_CMP_NGT_S: if (ctx->opcode & (1 << 6)) { gen_cmpabs_s(ctx, func-48, ft, fs, cc); opn = condnames_abs[func-48]; } else { gen_cmp_s(ctx, func-48, ft, fs, cc); opn = condnames[func-48]; } break; case OPC_ADD_D: check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_add_d(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "add.d"; optype = BINOP; break; case OPC_SUB_D: check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_sub_d(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "sub.d"; optype = BINOP; break; case OPC_MUL_D: check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_mul_d(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mul.d"; optype = BINOP; break; case OPC_DIV_D: check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_div_d(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "div.d"; optype = BINOP; break; case OPC_SQRT_D: check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_sqrt_d(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "sqrt.d"; break; case OPC_ABS_D: check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_abs_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "abs.d"; break; case OPC_MOV_D: check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mov.d"; break; case OPC_NEG_D: check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_chs_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "neg.d"; break; case OPC_ROUND_L_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_roundl_d(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "round.l.d"; break; case OPC_TRUNC_L_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_truncl_d(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "trunc.l.d"; break; case OPC_CEIL_L_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_ceill_d(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "ceil.l.d"; break; case OPC_FLOOR_L_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_floorl_d(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "floor.l.d"; break; case OPC_ROUND_W_D: check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_roundw_d(fp32, cpu_env, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "round.w.d"; break; case OPC_TRUNC_W_D: check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_truncw_d(fp32, cpu_env, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "trunc.w.d"; break; case OPC_CEIL_W_D: check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_ceilw_d(fp32, cpu_env, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "ceil.w.d"; break; case OPC_FLOOR_W_D: check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_floorw_d(fp32, cpu_env, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "floor.w.d"; break; case OPC_MOVCF_D: gen_movcf_d(ctx, fs, fd, (ft >> 2) & 0x7, ft & 0x1); opn = "movcf.d"; break; case OPC_MOVZ_D: { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[ft], 0, l1); } fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } opn = "movz.d"; break; case OPC_MOVN_D: { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } } opn = "movn.d"; break; case OPC_RECIP_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_recip_d(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip.d"; break; case OPC_RSQRT_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_rsqrt_d(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt.d"; break; case OPC_RECIP2_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_recip2_d(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip2.d"; break; case OPC_RECIP1_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_recip1_d(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip1.d"; break; case OPC_RSQRT1_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_rsqrt1_d(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt1.d"; break; case OPC_RSQRT2_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_rsqrt2_d(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt2.d"; break; case OPC_CMP_F_D: case OPC_CMP_UN_D: case OPC_CMP_EQ_D: case OPC_CMP_UEQ_D: case OPC_CMP_OLT_D: case OPC_CMP_ULT_D: case OPC_CMP_OLE_D: case OPC_CMP_ULE_D: case OPC_CMP_SF_D: case OPC_CMP_NGLE_D: case OPC_CMP_SEQ_D: case OPC_CMP_NGL_D: case OPC_CMP_LT_D: case OPC_CMP_NGE_D: case OPC_CMP_LE_D: case OPC_CMP_NGT_D: if (ctx->opcode & (1 << 6)) { gen_cmpabs_d(ctx, func-48, ft, fs, cc); opn = condnames_abs[func-48]; } else { gen_cmp_d(ctx, func-48, ft, fs, cc); opn = condnames[func-48]; } break; case OPC_CVT_S_D: check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_cvts_d(fp32, cpu_env, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "cvt.s.d"; break; case OPC_CVT_W_D: check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_cvtw_d(fp32, cpu_env, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "cvt.w.d"; break; case OPC_CVT_L_D: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtl_d(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.l.d"; break; case OPC_CVT_S_W: { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_cvts_w(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.s.w"; break; case OPC_CVT_D_W: check_cp1_registers(ctx, fd); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_cvtd_w(fp64, cpu_env, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.d.w"; break; case OPC_CVT_S_L: check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_cvts_l(fp32, cpu_env, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "cvt.s.l"; break; case OPC_CVT_D_L: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtd_l(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.d.l"; break; case OPC_CVT_PS_PW: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtps_pw(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.ps.pw"; break; case OPC_ADD_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_add_ps(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "add.ps"; break; case OPC_SUB_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_sub_ps(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "sub.ps"; break; case OPC_MUL_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_mul_ps(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mul.ps"; break; case OPC_ABS_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_abs_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "abs.ps"; break; case OPC_MOV_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mov.ps"; break; case OPC_NEG_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_chs_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "neg.ps"; break; case OPC_MOVCF_PS: check_cp1_64bitmode(ctx); gen_movcf_ps(fs, fd, (ft >> 2) & 0x7, ft & 0x1); opn = "movcf.ps"; break; case OPC_MOVZ_PS: check_cp1_64bitmode(ctx); { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } opn = "movz.ps"; break; case OPC_MOVN_PS: check_cp1_64bitmode(ctx); { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } } opn = "movn.ps"; break; case OPC_ADDR_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, ft); gen_load_fpr64(ctx, fp1, fs); gen_helper_float_addr_ps(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "addr.ps"; break; case OPC_MULR_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, ft); gen_load_fpr64(ctx, fp1, fs); gen_helper_float_mulr_ps(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mulr.ps"; break; case OPC_RECIP2_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_recip2_ps(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip2.ps"; break; case OPC_RECIP1_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_recip1_ps(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip1.ps"; break; case OPC_RSQRT1_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_rsqrt1_ps(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt1.ps"; break; case OPC_RSQRT2_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_rsqrt2_ps(fp0, cpu_env, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt2.ps"; break; case OPC_CVT_S_PU: check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32h(fp0, fs); gen_helper_float_cvts_pu(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.s.pu"; break; case OPC_CVT_PW_PS: check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtpw_ps(fp0, cpu_env, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.pw.ps"; break; case OPC_CVT_S_PL: check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_cvts_pl(fp0, cpu_env, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.s.pl"; break; case OPC_PLL_PS: check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_store_fpr32h(fp0, fd); gen_store_fpr32(fp1, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "pll.ps"; break; case OPC_PLU_PS: check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32h(fp1, ft); gen_store_fpr32(fp1, fd); gen_store_fpr32h(fp0, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "plu.ps"; break; case OPC_PUL_PS: check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32h(fp0, fs); gen_load_fpr32(fp1, ft); gen_store_fpr32(fp1, fd); gen_store_fpr32h(fp0, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "pul.ps"; break; case OPC_PUU_PS: check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32h(fp0, fs); gen_load_fpr32h(fp1, ft); gen_store_fpr32(fp1, fd); gen_store_fpr32h(fp0, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "puu.ps"; break; case OPC_CMP_F_PS: case OPC_CMP_UN_PS: case OPC_CMP_EQ_PS: case OPC_CMP_UEQ_PS: case OPC_CMP_OLT_PS: case OPC_CMP_ULT_PS: case OPC_CMP_OLE_PS: case OPC_CMP_ULE_PS: case OPC_CMP_SF_PS: case OPC_CMP_NGLE_PS: case OPC_CMP_SEQ_PS: case OPC_CMP_NGL_PS: case OPC_CMP_LT_PS: case OPC_CMP_NGE_PS: case OPC_CMP_LE_PS: case OPC_CMP_NGT_PS: if (ctx->opcode & (1 << 6)) { gen_cmpabs_ps(ctx, func-48, ft, fs, cc); opn = condnames_abs[func-48]; } else { gen_cmp_ps(ctx, func-48, ft, fs, cc); opn = condnames[func-48]; } break; default: MIPS_INVAL(opn); generate_exception (ctx, EXCP_RI); return; } (void)opn; /* avoid a compiler warning */ switch (optype) { case BINOP: MIPS_DEBUG("%s %s, %s, %s", opn, fregnames[fd], fregnames[fs], fregnames[ft]); break; case CMPOP: MIPS_DEBUG("%s %s,%s", opn, fregnames[fs], fregnames[ft]); break; default: MIPS_DEBUG("%s %s,%s", opn, fregnames[fd], fregnames[fs]); break; } }
1,555
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
0
static uint64_t ecc_mem_read(void *opaque, target_phys_addr_t addr, unsigned size) { ECCState *s = opaque; uint32_t ret = 0; switch (addr >> 2) { case ECC_MER: ret = s->regs[ECC_MER]; trace_ecc_mem_readl_mer(ret); break; case ECC_MDR: ret = s->regs[ECC_MDR]; trace_ecc_mem_readl_mdr(ret); break; case ECC_MFSR: ret = s->regs[ECC_MFSR]; trace_ecc_mem_readl_mfsr(ret); break; case ECC_VCR: ret = s->regs[ECC_VCR]; trace_ecc_mem_readl_vcr(ret); break; case ECC_MFAR0: ret = s->regs[ECC_MFAR0]; trace_ecc_mem_readl_mfar0(ret); break; case ECC_MFAR1: ret = s->regs[ECC_MFAR1]; trace_ecc_mem_readl_mfar1(ret); break; case ECC_DR: ret = s->regs[ECC_DR]; trace_ecc_mem_readl_dr(ret); break; case ECC_ECR0: ret = s->regs[ECC_ECR0]; trace_ecc_mem_readl_ecr0(ret); break; case ECC_ECR1: ret = s->regs[ECC_ECR0]; trace_ecc_mem_readl_ecr1(ret); break; } return ret; }
1,556
qemu
079d0b7f1eedcc634c371fe05b617fdc55c8b762
0
static int usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in) { AsyncURB *aurb; int i, j, ret, max_packet_size, offset, len = 0; uint8_t *buf; max_packet_size = usb_ep_get_max_packet_size(&s->dev, p->pid, p->devep); if (max_packet_size == 0) return USB_RET_NAK; aurb = get_iso_urb(s, p->pid, p->devep); if (!aurb) { aurb = usb_host_alloc_iso(s, p->pid, p->devep); } i = get_iso_urb_idx(s, p->pid, p->devep); j = aurb[i].iso_frame_idx; if (j >= 0 && j < ISO_FRAME_DESC_PER_URB) { if (in) { /* Check urb status */ if (aurb[i].urb.status) { len = urb_status_to_usb_ret(aurb[i].urb.status); /* Move to the next urb */ aurb[i].iso_frame_idx = ISO_FRAME_DESC_PER_URB - 1; /* Check frame status */ } else if (aurb[i].urb.iso_frame_desc[j].status) { len = urb_status_to_usb_ret( aurb[i].urb.iso_frame_desc[j].status); /* Check the frame fits */ } else if (aurb[i].urb.iso_frame_desc[j].actual_length > p->iov.size) { printf("husb: received iso data is larger then packet\n"); len = USB_RET_NAK; /* All good copy data over */ } else { len = aurb[i].urb.iso_frame_desc[j].actual_length; buf = aurb[i].urb.buffer + j * aurb[i].urb.iso_frame_desc[0].length; usb_packet_copy(p, buf, len); } } else { len = p->iov.size; offset = (j == 0) ? 0 : get_iso_buffer_used(s, p->pid, p->devep); /* Check the frame fits */ if (len > max_packet_size) { printf("husb: send iso data is larger then max packet size\n"); return USB_RET_NAK; } /* All good copy data over */ usb_packet_copy(p, aurb[i].urb.buffer + offset, len); aurb[i].urb.iso_frame_desc[j].length = len; offset += len; set_iso_buffer_used(s, p->pid, p->devep, offset); /* Start the stream once we have buffered enough data */ if (!is_iso_started(s, p->pid, p->devep) && i == 1 && j == 8) { set_iso_started(s, p->pid, p->devep); } } aurb[i].iso_frame_idx++; if (aurb[i].iso_frame_idx == ISO_FRAME_DESC_PER_URB) { i = (i + 1) % s->iso_urb_count; set_iso_urb_idx(s, p->pid, p->devep, i); } } else { if (in) { set_iso_started(s, p->pid, p->devep); } else { DPRINTF("hubs: iso out error no free buffer, dropping packet\n"); } } if (is_iso_started(s, p->pid, p->devep)) { /* (Re)-submit all fully consumed / filled urbs */ for (i = 0; i < s->iso_urb_count; i++) { if (aurb[i].iso_frame_idx == ISO_FRAME_DESC_PER_URB) { ret = ioctl(s->fd, USBDEVFS_SUBMITURB, &aurb[i]); if (ret < 0) { perror("USBDEVFS_SUBMITURB"); if (!in || len == 0) { switch(errno) { case ETIMEDOUT: len = USB_RET_NAK; break; case EPIPE: default: len = USB_RET_STALL; } } break; } aurb[i].iso_frame_idx = -1; change_iso_inflight(s, p->pid, p->devep, 1); } } } return len; }
1,558
qemu
007ac6faed12abdd4113e2460ba4464aacb7f4dd
0
static void gen_farith (DisasContext *ctx, uint32_t op1, int ft, int fs, int fd, int cc) { const char *opn = "farith"; const char *condnames[] = { "c.f", "c.un", "c.eq", "c.ueq", "c.olt", "c.ult", "c.ole", "c.ule", "c.sf", "c.ngle", "c.seq", "c.ngl", "c.lt", "c.nge", "c.le", "c.ngt", }; const char *condnames_abs[] = { "cabs.f", "cabs.un", "cabs.eq", "cabs.ueq", "cabs.olt", "cabs.ult", "cabs.ole", "cabs.ule", "cabs.sf", "cabs.ngle", "cabs.seq", "cabs.ngl", "cabs.lt", "cabs.nge", "cabs.le", "cabs.ngt", }; enum { BINOP, CMPOP, OTHEROP } optype = OTHEROP; uint32_t func = ctx->opcode & 0x3f; switch (ctx->opcode & FOP(0x3f, 0x1f)) { case FOP(0, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_add_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "add.s"; optype = BINOP; break; case FOP(1, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_sub_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "sub.s"; optype = BINOP; break; case FOP(2, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_mul_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "mul.s"; optype = BINOP; break; case FOP(3, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_div_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "div.s"; optype = BINOP; break; case FOP(4, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_sqrt_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "sqrt.s"; break; case FOP(5, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_abs_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "abs.s"; break; case FOP(6, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "mov.s"; break; case FOP(7, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_chs_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "neg.s"; break; case FOP(8, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_roundl_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "round.l.s"; break; case FOP(9, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_truncl_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "trunc.l.s"; break; case FOP(10, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_ceill_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "ceil.l.s"; break; case FOP(11, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_floorl_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "floor.l.s"; break; case FOP(12, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_roundw_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "round.w.s"; break; case FOP(13, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_truncw_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "trunc.w.s"; break; case FOP(14, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_ceilw_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "ceil.w.s"; break; case FOP(15, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_floorw_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "floor.w.s"; break; case FOP(17, 16): gen_movcf_s(fs, fd, (ft >> 2) & 0x7, ft & 0x1); opn = "movcf.s"; break; case FOP(18, 16): { int l1 = gen_new_label(); TCGv_i32 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[ft], 0, l1); } fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); gen_set_label(l1); } opn = "movz.s"; break; case FOP(19, 16): { int l1 = gen_new_label(); TCGv_i32 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); gen_set_label(l1); } } opn = "movn.s"; break; case FOP(21, 16): check_cop1x(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_recip_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "recip.s"; break; case FOP(22, 16): check_cop1x(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_rsqrt_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "rsqrt.s"; break; case FOP(28, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, fd); gen_helper_float_recip2_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "recip2.s"; break; case FOP(29, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_recip1_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "recip1.s"; break; case FOP(30, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_rsqrt1_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "rsqrt1.s"; break; case FOP(31, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_rsqrt2_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "rsqrt2.s"; break; case FOP(33, 16): check_cp1_registers(ctx, fd); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_cvtd_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.d.s"; break; case FOP(36, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_cvtw_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.w.s"; break; case FOP(37, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_cvtl_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.l.s"; break; case FOP(38, 16): check_cp1_64bitmode(ctx); { TCGv_i64 fp64 = tcg_temp_new_i64(); TCGv_i32 fp32_0 = tcg_temp_new_i32(); TCGv_i32 fp32_1 = tcg_temp_new_i32(); gen_load_fpr32(fp32_0, fs); gen_load_fpr32(fp32_1, ft); tcg_gen_concat_i32_i64(fp64, fp32_0, fp32_1); tcg_temp_free_i32(fp32_1); tcg_temp_free_i32(fp32_0); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.ps.s"; break; case FOP(48, 16): case FOP(49, 16): case FOP(50, 16): case FOP(51, 16): case FOP(52, 16): case FOP(53, 16): case FOP(54, 16): case FOP(55, 16): case FOP(56, 16): case FOP(57, 16): case FOP(58, 16): case FOP(59, 16): case FOP(60, 16): case FOP(61, 16): case FOP(62, 16): case FOP(63, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); if (ctx->opcode & (1 << 6)) { check_cop1x(ctx); gen_cmpabs_s(func-48, fp0, fp1, cc); opn = condnames_abs[func-48]; } else { gen_cmp_s(func-48, fp0, fp1, cc); opn = condnames[func-48]; } tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } break; case FOP(0, 17): check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_add_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "add.d"; optype = BINOP; break; case FOP(1, 17): check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_sub_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "sub.d"; optype = BINOP; break; case FOP(2, 17): check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_mul_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mul.d"; optype = BINOP; break; case FOP(3, 17): check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_div_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "div.d"; optype = BINOP; break; case FOP(4, 17): check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_sqrt_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "sqrt.d"; break; case FOP(5, 17): check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_abs_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "abs.d"; break; case FOP(6, 17): check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mov.d"; break; case FOP(7, 17): check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_chs_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "neg.d"; break; case FOP(8, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_roundl_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "round.l.d"; break; case FOP(9, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_truncl_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "trunc.l.d"; break; case FOP(10, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_ceill_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "ceil.l.d"; break; case FOP(11, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_floorl_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "floor.l.d"; break; case FOP(12, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_roundw_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "round.w.d"; break; case FOP(13, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_truncw_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "trunc.w.d"; break; case FOP(14, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_ceilw_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "ceil.w.d"; break; case FOP(15, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_floorw_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "floor.w.d"; break; case FOP(17, 17): gen_movcf_d(ctx, fs, fd, (ft >> 2) & 0x7, ft & 0x1); opn = "movcf.d"; break; case FOP(18, 17): { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[ft], 0, l1); } fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } opn = "movz.d"; break; case FOP(19, 17): { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } } opn = "movn.d"; break; case FOP(21, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_recip_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip.d"; break; case FOP(22, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_rsqrt_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt.d"; break; case FOP(28, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_recip2_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip2.d"; break; case FOP(29, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_recip1_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip1.d"; break; case FOP(30, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_rsqrt1_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt1.d"; break; case FOP(31, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_rsqrt2_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt2.d"; break; case FOP(48, 17): case FOP(49, 17): case FOP(50, 17): case FOP(51, 17): case FOP(52, 17): case FOP(53, 17): case FOP(54, 17): case FOP(55, 17): case FOP(56, 17): case FOP(57, 17): case FOP(58, 17): case FOP(59, 17): case FOP(60, 17): case FOP(61, 17): case FOP(62, 17): case FOP(63, 17): { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); if (ctx->opcode & (1 << 6)) { check_cop1x(ctx); check_cp1_registers(ctx, fs | ft); gen_cmpabs_d(func-48, fp0, fp1, cc); opn = condnames_abs[func-48]; } else { check_cp1_registers(ctx, fs | ft); gen_cmp_d(func-48, fp0, fp1, cc); opn = condnames[func-48]; } tcg_temp_free_i64(fp0); tcg_temp_free_i64(fp1); } break; case FOP(32, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_cvts_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "cvt.s.d"; break; case FOP(36, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_cvtw_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "cvt.w.d"; break; case FOP(37, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtl_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.l.d"; break; case FOP(32, 20): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_cvts_w(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.s.w"; break; case FOP(33, 20): check_cp1_registers(ctx, fd); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_cvtd_w(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.d.w"; break; case FOP(32, 21): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_cvts_l(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "cvt.s.l"; break; case FOP(33, 21): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtd_l(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.d.l"; break; case FOP(38, 20): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtps_pw(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.ps.pw"; break; case FOP(0, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_add_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "add.ps"; break; case FOP(1, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_sub_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "sub.ps"; break; case FOP(2, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_mul_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mul.ps"; break; case FOP(5, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_abs_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "abs.ps"; break; case FOP(6, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mov.ps"; break; case FOP(7, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_chs_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "neg.ps"; break; case FOP(17, 22): check_cp1_64bitmode(ctx); gen_movcf_ps(fs, fd, (ft >> 2) & 0x7, ft & 0x1); opn = "movcf.ps"; break; case FOP(18, 22): check_cp1_64bitmode(ctx); { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } opn = "movz.ps"; break; case FOP(19, 22): check_cp1_64bitmode(ctx); { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } } opn = "movn.ps"; break; case FOP(24, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, ft); gen_load_fpr64(ctx, fp1, fs); gen_helper_float_addr_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "addr.ps"; break; case FOP(26, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, ft); gen_load_fpr64(ctx, fp1, fs); gen_helper_float_mulr_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mulr.ps"; break; case FOP(28, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, fd); gen_helper_float_recip2_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip2.ps"; break; case FOP(29, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_recip1_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip1.ps"; break; case FOP(30, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_rsqrt1_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt1.ps"; break; case FOP(31, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_rsqrt2_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt2.ps"; break; case FOP(32, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32h(fp0, fs); gen_helper_float_cvts_pu(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.s.pu"; break; case FOP(36, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtpw_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.pw.ps"; break; case FOP(40, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_cvts_pl(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.s.pl"; break; case FOP(44, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_store_fpr32h(fp0, fd); gen_store_fpr32(fp1, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "pll.ps"; break; case FOP(45, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32h(fp1, ft); gen_store_fpr32(fp1, fd); gen_store_fpr32h(fp0, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "plu.ps"; break; case FOP(46, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32h(fp0, fs); gen_load_fpr32(fp1, ft); gen_store_fpr32(fp1, fd); gen_store_fpr32h(fp0, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "pul.ps"; break; case FOP(47, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32h(fp0, fs); gen_load_fpr32h(fp1, ft); gen_store_fpr32(fp1, fd); gen_store_fpr32h(fp0, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "puu.ps"; break; case FOP(48, 22): case FOP(49, 22): case FOP(50, 22): case FOP(51, 22): case FOP(52, 22): case FOP(53, 22): case FOP(54, 22): case FOP(55, 22): case FOP(56, 22): case FOP(57, 22): case FOP(58, 22): case FOP(59, 22): case FOP(60, 22): case FOP(61, 22): case FOP(62, 22): case FOP(63, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); if (ctx->opcode & (1 << 6)) { gen_cmpabs_ps(func-48, fp0, fp1, cc); opn = condnames_abs[func-48]; } else { gen_cmp_ps(func-48, fp0, fp1, cc); opn = condnames[func-48]; } tcg_temp_free_i64(fp0); tcg_temp_free_i64(fp1); } break; default: MIPS_INVAL(opn); generate_exception (ctx, EXCP_RI); return; } switch (optype) { case BINOP: MIPS_DEBUG("%s %s, %s, %s", opn, fregnames[fd], fregnames[fs], fregnames[ft]); break; case CMPOP: MIPS_DEBUG("%s %s,%s", opn, fregnames[fs], fregnames[ft]); break; default: MIPS_DEBUG("%s %s,%s", opn, fregnames[fd], fregnames[fs]); break; } }
1,559
FFmpeg
8f6b919d99687416deaedb2df6b8b5f49645a291
0
static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, unsigned int blockid, AVPacket *pkt, int flags) { MatroskaMuxContext *mkv = s->priv_data; AVCodecContext *codec = s->streams[pkt->stream_index]->codec; uint8_t *data = NULL, *side_data = NULL; int offset = 0, size = pkt->size, side_data_size = 0; int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts; uint64_t additional_id = 0; int64_t discard_padding = 0; ebml_master block_group, block_additions, block_more; av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, " "pts %" PRId64 ", dts %" PRId64 ", duration %d, flags %d\n", avio_tell(pb), pkt->size, pkt->pts, pkt->dts, pkt->duration, flags); if (codec->codec_id == AV_CODEC_ID_H264 && codec->extradata_size > 0 && (AV_RB24(codec->extradata) == 1 || AV_RB32(codec->extradata) == 1)) ff_avc_parse_nal_units_buf(pkt->data, &data, &size); else if (codec->codec_id == AV_CODEC_ID_HEVC && codec->extradata_size > 6 && (AV_RB24(codec->extradata) == 1 || AV_RB32(codec->extradata) == 1)) /* extradata is Annex B, assume the bitstream is too and convert it */ ff_hevc_annexb2mp4_buf(pkt->data, &data, &size, 0, NULL); else if (codec->codec_id == AV_CODEC_ID_WAVPACK) { int ret = mkv_strip_wavpack(pkt->data, &data, &size); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Error stripping a WavPack packet.\n"); return; } } else data = pkt->data; if (codec->codec_id == AV_CODEC_ID_PRORES) { /* Matroska specification requires to remove the first QuickTime atom */ size -= 8; offset = 8; } side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_data_size); if (side_data && side_data_size >= 10) { discard_padding = av_rescale_q(AV_RL32(side_data + 4), (AVRational){1, codec->sample_rate}, (AVRational){1, 1000000000}); } side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size); if (side_data) { additional_id = AV_RB64(side_data); side_data += 8; side_data_size -= 8; } if ((side_data_size && additional_id == 1) || discard_padding) { block_group = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, 0); blockid = MATROSKA_ID_BLOCK; } put_ebml_id(pb, blockid); put_ebml_num(pb, size + 4, 0); // this assumes stream_index is less than 126 avio_w8(pb, 0x80 | (mkv->is_dash ? mkv->dash_track_number : (pkt->stream_index + 1))); avio_wb16(pb, ts - mkv->cluster_pts); avio_w8(pb, flags); avio_write(pb, data + offset, size); if (data != pkt->data) av_free(data); if (discard_padding) { put_ebml_sint(pb, MATROSKA_ID_DISCARDPADDING, discard_padding); } if (side_data_size && additional_id == 1) { block_additions = start_ebml_master(pb, MATROSKA_ID_BLOCKADDITIONS, 0); block_more = start_ebml_master(pb, MATROSKA_ID_BLOCKMORE, 0); put_ebml_uint(pb, MATROSKA_ID_BLOCKADDID, 1); put_ebml_id(pb, MATROSKA_ID_BLOCKADDITIONAL); put_ebml_num(pb, side_data_size, 0); avio_write(pb, side_data, side_data_size); end_ebml_master(pb, block_more); end_ebml_master(pb, block_additions); } if ((side_data_size && additional_id == 1) || discard_padding) { end_ebml_master(pb, block_group); } }
1,560
qemu
0919ac787641db11024912651f3bc5764d4f1286
0
static void omap2_mpu_reset(void *opaque) { struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque; omap_inth_reset(mpu->ih[0]); omap_dma_reset(mpu->dma); omap_prcm_reset(mpu->prcm); omap_sysctl_reset(mpu->sysc); omap_gp_timer_reset(mpu->gptimer[0]); omap_gp_timer_reset(mpu->gptimer[1]); omap_gp_timer_reset(mpu->gptimer[2]); omap_gp_timer_reset(mpu->gptimer[3]); omap_gp_timer_reset(mpu->gptimer[4]); omap_gp_timer_reset(mpu->gptimer[5]); omap_gp_timer_reset(mpu->gptimer[6]); omap_gp_timer_reset(mpu->gptimer[7]); omap_gp_timer_reset(mpu->gptimer[8]); omap_gp_timer_reset(mpu->gptimer[9]); omap_gp_timer_reset(mpu->gptimer[10]); omap_gp_timer_reset(mpu->gptimer[11]); omap_synctimer_reset(mpu->synctimer); omap_sdrc_reset(mpu->sdrc); omap_gpmc_reset(mpu->gpmc); omap_dss_reset(mpu->dss); omap_uart_reset(mpu->uart[0]); omap_uart_reset(mpu->uart[1]); omap_uart_reset(mpu->uart[2]); omap_mmc_reset(mpu->mmc); omap_mcspi_reset(mpu->mcspi[0]); omap_mcspi_reset(mpu->mcspi[1]); omap_i2c_reset(mpu->i2c[0]); omap_i2c_reset(mpu->i2c[1]); cpu_reset(mpu->env); }
1,561
qemu
79ca616f291124d166ca173e512c4ace1c2fe8b2
0
void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict) { pci_device_hot_remove(mon, qdict_get_str(qdict, "pci_addr")); }
1,562
qemu
53cb28cbfea038f8ad50132dc8a684e638c7d48b
0
static void register_multipage(AddressSpaceDispatch *d, MemoryRegionSection *section) { hwaddr start_addr = section->offset_within_address_space; uint16_t section_index = phys_section_add(section); uint64_t num_pages = int128_get64(int128_rshift(section->size, TARGET_PAGE_BITS)); assert(num_pages); phys_page_set(d, start_addr >> TARGET_PAGE_BITS, num_pages, section_index); }
1,564
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
0
static void test_visitor_in_errors(TestInputVisitorData *data, const void *unused) { TestStruct *p = NULL; Error *err = NULL; Visitor *v; strList *q = NULL; UserDefTwo *r = NULL; WrapAlternate *s = NULL; v = visitor_input_test_init(data, "{ 'integer': false, 'boolean': 'foo', " "'string': -42 }"); visit_type_TestStruct(v, NULL, &p, &err); error_free_or_abort(&err); g_assert(!p); v = visitor_input_test_init(data, "[ '1', '2', false, '3' ]"); visit_type_strList(v, NULL, &q, &err); error_free_or_abort(&err); assert(!q); v = visitor_input_test_init(data, "{ 'str':'hi' }"); visit_type_UserDefTwo(v, NULL, &r, &err); error_free_or_abort(&err); assert(!r); v = visitor_input_test_init(data, "{ }"); visit_type_WrapAlternate(v, NULL, &s, &err); error_free_or_abort(&err); assert(!s); }
1,566
qemu
5a2223ca26b1a34e131b5b9a63599d9426d2c25c
0
static void acpi_pcihp_update_hotplug_bus(AcpiPciHpState *s, int bsel) { BusChild *kid, *next; PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel); /* Execute any pending removes during reset */ while (s->acpi_pcihp_pci_status[bsel].down) { acpi_pcihp_eject_slot(s, bsel, s->acpi_pcihp_pci_status[bsel].down); } s->acpi_pcihp_pci_status[bsel].hotplug_enable = ~0; s->acpi_pcihp_pci_status[bsel].device_present = 0; if (!bus) { return; } QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { DeviceState *qdev = kid->child; PCIDevice *pdev = PCI_DEVICE(qdev); int slot = PCI_SLOT(pdev->devfn); if (acpi_pcihp_pc_no_hotplug(s, pdev)) { s->acpi_pcihp_pci_status[bsel].hotplug_enable &= ~(1U << slot); } s->acpi_pcihp_pci_status[bsel].device_present |= (1U << slot); } }
1,567
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
0
static void ahci_idp_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { AHCIState *s = opaque; if (addr == s->idp_offset) { /* index register - mask off reserved bits */ s->idp_index = (uint32_t)val & ((AHCI_MEM_BAR_SIZE - 1) & ~3); } else if (addr == s->idp_offset + 4) { /* data register - do memory write at location selected by index */ ahci_mem_write(opaque, s->idp_index, val, size); } }
1,568
qemu
9445673ea67c272616b9f718396e267caa6446b7
0
static void nbd_refresh_filename(BlockDriverState *bs, QDict *options) { BDRVNBDState *s = bs->opaque; QDict *opts = qdict_new(); QObject *saddr_qdict; Visitor *ov; const char *host = NULL, *port = NULL, *path = NULL; if (s->saddr->type == SOCKET_ADDRESS_KIND_INET) { const InetSocketAddress *inet = s->saddr->u.inet.data; if (!inet->has_ipv4 && !inet->has_ipv6 && !inet->has_to) { host = inet->host; port = inet->port; } } else if (s->saddr->type == SOCKET_ADDRESS_KIND_UNIX) { path = s->saddr->u.q_unix.data->path; } qdict_put(opts, "driver", qstring_from_str("nbd")); if (path && s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix:///%s?socket=%s", s->export, path); } else if (path && !s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix://?socket=%s", path); } else if (host && s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd://%s:%s/%s", host, port, s->export); } else if (host && !s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd://%s:%s", host, port); } ov = qobject_output_visitor_new(&saddr_qdict); visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort); visit_complete(ov, &saddr_qdict); visit_free(ov); qdict_put_obj(opts, "server", saddr_qdict); if (s->export) { qdict_put(opts, "export", qstring_from_str(s->export)); } if (s->tlscredsid) { qdict_put(opts, "tls-creds", qstring_from_str(s->tlscredsid)); } qdict_flatten(opts); bs->full_open_options = opts; }
1,569
qemu
51b19ebe4320f3dcd93cea71235c1219318ddfd2
0
static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq) { VirtIOBalloon *s = VIRTIO_BALLOON(vdev); VirtQueueElement *elem = &s->stats_vq_elem; VirtIOBalloonStat stat; size_t offset = 0; qemu_timeval tv; if (!virtqueue_pop(vq, elem)) { goto out; } /* Initialize the stats to get rid of any stale values. This is only * needed to handle the case where a guest supports fewer stats than it * used to (ie. it has booted into an old kernel). */ reset_stats(s); while (iov_to_buf(elem->out_sg, elem->out_num, offset, &stat, sizeof(stat)) == sizeof(stat)) { uint16_t tag = virtio_tswap16(vdev, stat.tag); uint64_t val = virtio_tswap64(vdev, stat.val); offset += sizeof(stat); if (tag < VIRTIO_BALLOON_S_NR) s->stats[tag] = val; } s->stats_vq_offset = offset; if (qemu_gettimeofday(&tv) < 0) { fprintf(stderr, "warning: %s: failed to get time of day\n", __func__); goto out; } s->stats_last_update = tv.tv_sec; out: if (balloon_stats_enabled(s)) { balloon_stats_change_timer(s, s->stats_poll_interval); } }
1,570
qemu
e23a1b33b53d25510320b26d9f154e19c6c99725
1
ISABus *isa_bus_new(DeviceState *dev) { if (isabus) { fprintf(stderr, "Can't create a second ISA bus\n"); return NULL; } if (NULL == dev) { dev = qdev_create(NULL, "isabus-bridge"); qdev_init(dev); } isabus = FROM_QBUS(ISABus, qbus_create(&isa_bus_info, dev, NULL)); return isabus; }
1,574
qemu
3eadc68ebd174f5bad51fe6e0bbcf6d6651c784c
1
void os_set_proc_name(const char *s) { #if defined(PR_SET_NAME) char name[16]; if (!s) return; name[sizeof(name) - 1] = 0; strncpy(name, s, sizeof(name)); /* Could rewrite argv[0] too, but that's a bit more complicated. This simple way is enough for `top'. */ if (prctl(PR_SET_NAME, name)) { perror("unable to change process name"); exit(1); } #else fprintf(stderr, "Change of process name not supported by your OS\n"); exit(1); #endif }
1,575
qemu
b027a538c6790bcfc93ef7f4819fe3e581445959
1
static int oss_poll_out (HWVoiceOut *hw) { OSSVoiceOut *oss = (OSSVoiceOut *) hw; return qemu_set_fd_handler (oss->fd, NULL, oss_helper_poll_out, NULL); }
1,576
qemu
d9bce9d99f4656ae0b0127f7472db9067b8f84ab
1
void OPPROTO op_addzeo (void) { do_addzeo(); RETURN(); }
1,577
FFmpeg
bcd7bf7eeb09a395cc01698842d1b8be9af483fc
0
static void avc_loopfilter_cb_or_cr_inter_edge_hor_msa(uint8_t *data, uint8_t bs0, uint8_t bs1, uint8_t bs2, uint8_t bs3, uint8_t tc0, uint8_t tc1, uint8_t tc2, uint8_t tc3, uint8_t alpha_in, uint8_t beta_in, uint32_t img_width) { v16u8 alpha, beta; v8i16 tmp_vec; v8i16 bs = { 0 }; v8i16 tc = { 0 }; v16u8 p0, q0, p0_asub_q0, p1_asub_p0, q1_asub_q0; v16u8 is_less_than; v16u8 is_less_than_beta, is_less_than_alpha, is_bs_greater_than0; v8i16 p0_r, q0_r; v16u8 p1_org, p0_org, q0_org, q1_org; v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r; v16i8 negate_tc, sign_negate_tc; v8i16 tc_r, negate_tc_r; v16i8 zero = { 0 }; tmp_vec = (v8i16) __msa_fill_b(bs0); bs = __msa_insve_h(bs, 0, tmp_vec); tmp_vec = (v8i16) __msa_fill_b(bs1); bs = __msa_insve_h(bs, 1, tmp_vec); tmp_vec = (v8i16) __msa_fill_b(bs2); bs = __msa_insve_h(bs, 2, tmp_vec); tmp_vec = (v8i16) __msa_fill_b(bs3); bs = __msa_insve_h(bs, 3, tmp_vec); if (!__msa_test_bz_v((v16u8) bs)) { tmp_vec = (v8i16) __msa_fill_b(tc0); tc = __msa_insve_h(tc, 0, tmp_vec); tmp_vec = (v8i16) __msa_fill_b(tc1); tc = __msa_insve_h(tc, 1, tmp_vec); tmp_vec = (v8i16) __msa_fill_b(tc2); tc = __msa_insve_h(tc, 2, tmp_vec); tmp_vec = (v8i16) __msa_fill_b(tc3); tc = __msa_insve_h(tc, 3, tmp_vec); is_bs_greater_than0 = (v16u8) (zero < (v16i8) bs); alpha = (v16u8) __msa_fill_b(alpha_in); beta = (v16u8) __msa_fill_b(beta_in); p1_org = LOAD_UB(data - (img_width << 1)); p0_org = LOAD_UB(data - img_width); q0_org = LOAD_UB(data); q1_org = LOAD_UB(data + img_width); p0_asub_q0 = __msa_asub_u_b(p0_org, q0_org); p1_asub_p0 = __msa_asub_u_b(p1_org, p0_org); q1_asub_q0 = __msa_asub_u_b(q1_org, q0_org); is_less_than_alpha = (p0_asub_q0 < alpha); is_less_than_beta = (p1_asub_p0 < beta); is_less_than = is_less_than_beta & is_less_than_alpha; is_less_than_beta = (q1_asub_q0 < beta); is_less_than = is_less_than_beta & is_less_than; is_less_than = is_less_than & is_bs_greater_than0; is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than); if (!__msa_test_bz_v(is_less_than)) { negate_tc = zero - (v16i8) tc; sign_negate_tc = __msa_clti_s_b(negate_tc, 0); negate_tc_r = (v8i16) __msa_ilvr_b(sign_negate_tc, negate_tc); tc_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc); p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_org); p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_org); q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_org); q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_org); AVC_LOOP_FILTER_P0Q0(q0_org_r, p0_org_r, p1_org_r, q1_org_r, negate_tc_r, tc_r, p0_r, q0_r); p0 = (v16u8) __msa_pckev_b(zero, (v16i8) p0_r); q0 = (v16u8) __msa_pckev_b(zero, (v16i8) q0_r); p0_org = __msa_bmnz_v(p0_org, p0, is_less_than); q0_org = __msa_bmnz_v(q0_org, q0, is_less_than); STORE_UB(q0_org, data); STORE_UB(p0_org, (data - img_width)); } } }
1,579
FFmpeg
cc276c85d15272df6e44fb3252657a43cbd49555
0
static int64_t truehd_layout(int chanmap) { int layout = 0, i; for (i = 0; i < 13; i++) layout |= thd_layout[i] * ((chanmap >> i) & 1); return layout; }
1,580
FFmpeg
3af1060319b46005dbfb3b01f9104539caf30146
0
void copy_picture_field(TInterlaceContext *tinterlace, uint8_t *dst[4], int dst_linesize[4], const uint8_t *src[4], int src_linesize[4], enum AVPixelFormat format, int w, int src_h, int src_field, int interleave, int dst_field, int flags) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format); int hsub = desc->log2_chroma_w; int plane, vsub = desc->log2_chroma_h; int k = src_field == FIELD_UPPER_AND_LOWER ? 1 : 2; int h; for (plane = 0; plane < desc->nb_components; plane++) { int lines = plane == 1 || plane == 2 ? AV_CEIL_RSHIFT(src_h, vsub) : src_h; int cols = plane == 1 || plane == 2 ? AV_CEIL_RSHIFT( w, hsub) : w; uint8_t *dstp = dst[plane]; const uint8_t *srcp = src[plane]; int srcp_linesize = src_linesize[plane] * k; int dstp_linesize = dst_linesize[plane] * (interleave ? 2 : 1); lines = (lines + (src_field == FIELD_UPPER)) / k; if (src_field == FIELD_LOWER) srcp += src_linesize[plane]; if (interleave && dst_field == FIELD_LOWER) dstp += dst_linesize[plane]; // Low-pass filtering is required when creating an interlaced destination from // a progressive source which contains high-frequency vertical detail. // Filtering will reduce interlace 'twitter' and Moire patterning. if (flags & TINTERLACE_FLAG_VLPF || flags & TINTERLACE_FLAG_CVLPF) { int x = 0; if (flags & TINTERLACE_FLAG_CVLPF) x = 1; for (h = lines; h > 0; h--) { ptrdiff_t pref = src_linesize[plane]; ptrdiff_t mref = -pref; if (h >= (lines - x)) mref = 0; // there is no line above else if (h <= (1 + x)) pref = 0; // there is no line below tinterlace->lowpass_line(dstp, cols, srcp, mref, pref); dstp += dstp_linesize; srcp += srcp_linesize; } } else { av_image_copy_plane(dstp, dstp_linesize, srcp, srcp_linesize, cols, lines); } } }
1,581
FFmpeg
a5202bc968cf3ca5b64c623b9271f76e8fa02211
0
static double bessel(double x){ double lastv=0; double t, v; int i; static const double inv[100]={ 1.0/( 1* 1), 1.0/( 2* 2), 1.0/( 3* 3), 1.0/( 4* 4), 1.0/( 5* 5), 1.0/( 6* 6), 1.0/( 7* 7), 1.0/( 8* 8), 1.0/( 9* 9), 1.0/(10*10), 1.0/(11*11), 1.0/(12*12), 1.0/(13*13), 1.0/(14*14), 1.0/(15*15), 1.0/(16*16), 1.0/(17*17), 1.0/(18*18), 1.0/(19*19), 1.0/(20*20), 1.0/(21*21), 1.0/(22*22), 1.0/(23*23), 1.0/(24*24), 1.0/(25*25), 1.0/(26*26), 1.0/(27*27), 1.0/(28*28), 1.0/(29*29), 1.0/(30*30), 1.0/(31*31), 1.0/(32*32), 1.0/(33*33), 1.0/(34*34), 1.0/(35*35), 1.0/(36*36), 1.0/(37*37), 1.0/(38*38), 1.0/(39*39), 1.0/(40*40), 1.0/(41*41), 1.0/(42*42), 1.0/(43*43), 1.0/(44*44), 1.0/(45*45), 1.0/(46*46), 1.0/(47*47), 1.0/(48*48), 1.0/(49*49), 1.0/(50*50), 1.0/(51*51), 1.0/(52*52), 1.0/(53*53), 1.0/(54*54), 1.0/(55*55), 1.0/(56*56), 1.0/(57*57), 1.0/(58*58), 1.0/(59*59), 1.0/(60*60), 1.0/(61*61), 1.0/(62*62), 1.0/(63*63), 1.0/(64*64), 1.0/(65*65), 1.0/(66*66), 1.0/(67*67), 1.0/(68*68), 1.0/(69*69), 1.0/(70*70), 1.0/(71*71), 1.0/(72*72), 1.0/(73*73), 1.0/(74*74), 1.0/(75*75), 1.0/(76*76), 1.0/(77*77), 1.0/(78*78), 1.0/(79*79), 1.0/(80*80), 1.0/(81*81), 1.0/(82*82), 1.0/(83*83), 1.0/(84*84), 1.0/(85*85), 1.0/(86*86), 1.0/(87*87), 1.0/(88*88), 1.0/(89*89), 1.0/(90*90), 1.0/(91*91), 1.0/(92*92), 1.0/(93*93), 1.0/(94*94), 1.0/(95*95), 1.0/(96*96), 1.0/(97*97), 1.0/(98*98), 1.0/(99*99), 1.0/(10000) }; x= x*x/4; t = x; v = 1 + x; for(i=1; v != lastv; i+=2){ t *= x*inv[i]; v += t; lastv=v; t *= x*inv[i + 1]; v += t; av_assert2(i<98); } return v; }
1,582
FFmpeg
33d69a90085d30af8a292d9364b835a26565d6b9
0
static int check_jni_invocation(void *log_ctx) { int ret = AVERROR_EXTERNAL; void *handle = NULL; void **jni_invocation = NULL; handle = dlopen(NULL, RTLD_LOCAL); if (!handle) { goto done; } jni_invocation = (void **)dlsym(handle, "_ZN13JniInvocation15jni_invocation_E"); if (!jni_invocation) { av_log(log_ctx, AV_LOG_ERROR, "Could not find JniInvocation::jni_invocation_ symbol\n"); goto done; } ret = !(jni_invocation != NULL && *jni_invocation != NULL); done: if (handle) { dlclose(handle); } return ret; }
1,583
FFmpeg
c33030bd7b81f7ef7d7ff9da9bfa1a3b4bfbafa1
0
static int gif_image_write_header(uint8_t **bytestream, int width, int height, int loop_count, uint32_t *palette) { int i; unsigned int v; bytestream_put_buffer(bytestream, "GIF", 3); bytestream_put_buffer(bytestream, "89a", 3); bytestream_put_le16(bytestream, width); bytestream_put_le16(bytestream, height); bytestream_put_byte(bytestream, 0xf7); /* flags: global clut, 256 entries */ bytestream_put_byte(bytestream, 0x1f); /* background color index */ bytestream_put_byte(bytestream, 0); /* aspect ratio */ /* the global palette */ if (!palette) { bytestream_put_buffer(bytestream, (const unsigned char *)gif_clut, 216*3); for(i=0;i<((256-216)*3);i++) bytestream_put_byte(bytestream, 0); } else { for(i=0;i<256;i++) { v = palette[i]; bytestream_put_be24(bytestream, v); } } /* update: this is the 'NETSCAPE EXTENSION' that allows for looped animated gif see http://members.aol.com/royalef/gifabout.htm#net-extension byte 1 : 33 (hex 0x21) GIF Extension code byte 2 : 255 (hex 0xFF) Application Extension Label byte 3 : 11 (hex (0x0B) Length of Application Block (eleven bytes of data to follow) bytes 4 to 11 : "NETSCAPE" bytes 12 to 14 : "2.0" byte 15 : 3 (hex 0x03) Length of Data Sub-Block (three bytes of data to follow) byte 16 : 1 (hex 0x01) bytes 17 to 18 : 0 to 65535, an unsigned integer in lo-hi byte format. This indicate the number of iterations the loop should be executed. bytes 19 : 0 (hex 0x00) a Data Sub-block Terminator */ /* application extension header */ #ifdef GIF_ADD_APP_HEADER if (loop_count >= 0 && loop_count <= 65535) { bytestream_put_byte(bytestream, 0x21); bytestream_put_byte(bytestream, 0xff); bytestream_put_byte(bytestream, 0x0b); bytestream_put_buffer(bytestream, "NETSCAPE2.0", 11); // bytes 4 to 14 bytestream_put_byte(bytestream, 0x03); // byte 15 bytestream_put_byte(bytestream, 0x01); // byte 16 bytestream_put_le16(bytestream, (uint16_t)loop_count); bytestream_put_byte(bytestream, 0x00); // byte 19 } #endif return 0; }
1,584
FFmpeg
e5540b3fd30367ce3cc33b2f34a04b660dbc4b38
0
static int decode_p_mbs(VC9Context *v) { int x, y, current_mb = 0, i; /* MB/Block Position info */ int skip_mb_bit = 0, cbpcy; /* MB/B skip */ int hybrid_pred, ac_pred; /* Prediction types */ int mb_has_coeffs = 1 /* last_flag */, mb_is_intra; int dmv_x, dmv_y; /* Differential MV components */ int mv_mode_bit = 0; /* mv_mode_bit: 1MV=0, 4MV=0 */ int mqdiff, mquant; /* MB quantization */ int tt_block; /* MB Transform type */ static const int size_table[6] = { 0, 2, 3, 4, 5, 8 }, offset_table[6] = { 0, 1, 3, 7, 15, 31 }; int k_x, k_y; /* Long MV fixed bitlength */ int hpel_flag, intra_flag; /* Some MB properties */ int index, index1; /* LUT indices */ int val, sign; /* Select ttmb table depending on pq */ if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0]; else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1]; else v->ttmb_vlc = &vc9_ttmb_vlc[2]; /* Select proper long MV range */ switch (v->mvrange) { case 1: k_x = 10; k_y = 9; break; case 2: k_x = 12; k_y = 10; break; case 3: k_x = 13; k_y = 11; break; default: /*case 0 too */ k_x = 9; k_y = 8; break; } hpel_flag = v->mv_mode & 1; //MV_PMODE is HPEL k_x -= hpel_flag; k_y -= hpel_flag; for (y=0; y<v->height_mb; y++) { for (x=0; x<v->width_mb; x++) { if (v->mv_type_mb_plane[current_mb]) mv_mode_bit = get_bits(&v->gb, 1); if (0) //skipmb is rawmode skip_mb_bit = get_bits(&v->gb, 1); if (!mv_mode_bit) /* 1MV mode */ { if (!v->skip_mb_plane[current_mb]) { GET_MVDATA(); /* hybrid mv pred, 8.3.5.3.4 */ if (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV) hybrid_pred = get_bits(&v->gb, 1); if (mb_is_intra && !mb_has_coeffs) { GET_MQUANT(); ac_pred = get_bits(&v->gb, 1); } else if (mb_has_coeffs) { if (mb_is_intra) ac_pred = get_bits(&v->gb, 1); cbpcy = get_vlc2(&v->gb, v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2); GET_MQUANT(); } if (!v->ttmbf) v->ttfrm = get_vlc2(&v->gb, v->ttmb_vlc->table, VC9_TTMB_VLC_BITS, 2); //Decode blocks from that mb wrt cbpcy } else //Skipped { /* hybrid mv pred, 8.3.5.3.4 */ if (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV) hybrid_pred = get_bits(&v->gb, 1); } } //1MV mode else //4MV mode { if (!v->skip_mb_plane[current_mb] /* unskipped MB */) { cbpcy = get_vlc2(&v->gb, v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2); for (i=0; i<4; i++) //For all 4 Y blocks { if (cbpcy & (1<<6) /* cbpcy set for this block */) { GET_MVDATA(); } if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) hybrid_pred = get_bits(&v->gb, 1); GET_MQUANT(); if (mb_is_intra /* One of the 4 blocks is intra */ && index /* non-zero pred for that block */) ac_pred = get_bits(&v->gb, 1); if (!v->ttmbf) tt_block = get_vlc2(&v->gb, v->ttmb_vlc->table, VC9_TTMB_VLC_BITS, 2); /* TODO: Process blocks wrt cbpcy */ /* Prepare cbpcy for next block */ cbpcy <<= 1; } } else //Skipped MB { for (i=0; i<4; i++) //All 4 Y blocks { if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) hybrid_pred = get_bits(&v->gb, 1); /* FIXME: do something */ } } } } current_mb++; } return 0; }
1,585
FFmpeg
9c3e2f78a04200e604add6139ba6f64078fa2274
0
matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t duration, int is_keyframe, int is_bframe) { int res = 0; int track; AVStream *st; AVPacket *pkt; uint8_t *origdata = data; int16_t block_time; uint32_t *lace_size = NULL; int n, flags, laces = 0; uint64_t num; /* first byte(s): tracknum */ if ((n = matroska_ebmlnum_uint(data, size, &num)) < 0) { av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n"); av_free(origdata); return res; } data += n; size -= n; /* fetch track from num */ track = matroska_find_track_by_num(matroska, num); if (size <= 3 || track < 0 || track >= matroska->num_tracks) { av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %d or size %u\n", track, size); av_free(origdata); return res; } if (matroska->tracks[track]->stream_index < 0) return res; st = matroska->ctx->streams[matroska->tracks[track]->stream_index]; if (st->discard >= AVDISCARD_ALL) { av_free(origdata); return res; } if (duration == AV_NOPTS_VALUE) duration = matroska->tracks[track]->default_duration; /* block_time (relative to cluster time) */ block_time = AV_RB16(data); data += 2; flags = *data++; size -= 3; if (is_keyframe == -1) is_keyframe = flags & 1 ? PKT_FLAG_KEY : 0; if (matroska->skip_to_keyframe) { if (!is_keyframe || st != matroska->skip_to_stream) return res; matroska->skip_to_keyframe = 0; } switch ((flags & 0x06) >> 1) { case 0x0: /* no lacing */ laces = 1; lace_size = av_mallocz(sizeof(int)); lace_size[0] = size; break; case 0x1: /* xiph lacing */ case 0x2: /* fixed-size lacing */ case 0x3: /* EBML lacing */ if (size == 0) { res = -1; break; } laces = (*data) + 1; data += 1; size -= 1; lace_size = av_mallocz(laces * sizeof(int)); switch ((flags & 0x06) >> 1) { case 0x1: /* xiph lacing */ { uint8_t temp; uint32_t total = 0; for (n = 0; res == 0 && n < laces - 1; n++) { while (1) { if (size == 0) { res = -1; break; } temp = *data; lace_size[n] += temp; data += 1; size -= 1; if (temp != 0xff) break; } total += lace_size[n]; } lace_size[n] = size - total; break; } case 0x2: /* fixed-size lacing */ for (n = 0; n < laces; n++) lace_size[n] = size / laces; break; case 0x3: /* EBML lacing */ { uint32_t total; n = matroska_ebmlnum_uint(data, size, &num); if (n < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); break; } data += n; size -= n; total = lace_size[0] = num; for (n = 1; res == 0 && n < laces - 1; n++) { int64_t snum; int r; r = matroska_ebmlnum_sint (data, size, &snum); if (r < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); break; } data += r; size -= r; lace_size[n] = lace_size[n - 1] + snum; total += lace_size[n]; } lace_size[n] = size - total; break; } } break; } if (res == 0) { int real_v = matroska->tracks[track]->flags & MATROSKA_TRACK_REAL_V; uint64_t timecode = AV_NOPTS_VALUE; if (cluster_time != (uint64_t)-1 && cluster_time + block_time >= 0) timecode = cluster_time + block_time; for (n = 0; n < laces; n++) { int slice, slices = 1; if (real_v) { slices = *data++ + 1; lace_size[n]--; } for (slice=0; slice<slices; slice++) { int slice_size, slice_offset = 0; if (real_v) slice_offset = rv_offset(data, slice, slices); if (slice+1 == slices) slice_size = lace_size[n] - slice_offset; else slice_size = rv_offset(data, slice+1, slices) - slice_offset; if (st->codec->codec_id == CODEC_ID_RA_288 || st->codec->codec_id == CODEC_ID_COOK || st->codec->codec_id == CODEC_ID_ATRAC3) { MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)matroska->tracks[track]; int a = st->codec->block_align; int sps = audiotrack->sub_packet_size; int cfs = audiotrack->coded_framesize; int h = audiotrack->sub_packet_h; int y = audiotrack->sub_packet_cnt; int w = audiotrack->frame_size; int x; if (!audiotrack->pkt_cnt) { if (st->codec->codec_id == CODEC_ID_RA_288) for (x=0; x<h/2; x++) memcpy(audiotrack->buf+x*2*w+y*cfs, data+x*cfs, cfs); else for (x=0; x<w/sps; x++) memcpy(audiotrack->buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps); if (++audiotrack->sub_packet_cnt >= h) { audiotrack->sub_packet_cnt = 0; audiotrack->pkt_cnt = h*w / a; } } while (audiotrack->pkt_cnt) { pkt = av_mallocz(sizeof(AVPacket)); av_new_packet(pkt, a); memcpy(pkt->data, audiotrack->buf + a * (h*w / a - audiotrack->pkt_cnt--), a); pkt->pos = pos; pkt->stream_index = matroska->tracks[track]->stream_index; matroska_queue_packet(matroska, pkt); } } else { int offset = 0; if (st->codec->codec_id == CODEC_ID_TEXT && ((MatroskaSubtitleTrack *)(matroska->tracks[track]))->ass) { int i; for (i=0; i<8 && data[slice_offset+offset]; offset++) if (data[slice_offset+offset] == ',') i++; } pkt = av_mallocz(sizeof(AVPacket)); /* XXX: prevent data copy... */ if (av_new_packet(pkt, slice_size-offset) < 0) { res = AVERROR(ENOMEM); n = laces-1; break; } memcpy (pkt->data, data+slice_offset+offset, slice_size-offset); if (n == 0) pkt->flags = is_keyframe; pkt->stream_index = matroska->tracks[track]->stream_index; pkt->pts = timecode; pkt->pos = pos; pkt->duration = duration; matroska_queue_packet(matroska, pkt); } if (timecode != AV_NOPTS_VALUE) timecode = duration ? timecode + duration : AV_NOPTS_VALUE; } data += lace_size[n]; } } av_free(lace_size); av_free(origdata); return res; }
1,586
qemu
87ca1f77b1c406137fe36ab73b2dc91fb75f8d0a
1
static void vfio_listener_region_add(MemoryListener *listener, MemoryRegionSection *section) { VFIOContainer *container = container_of(listener, VFIOContainer, iommu_data.listener); hwaddr iova, end; void *vaddr; int ret; assert(!memory_region_is_iommu(section->mr)); if (vfio_listener_skipped_section(section)) { DPRINTF("SKIPPING region_add %"HWADDR_PRIx" - %"PRIx64"\n", section->offset_within_address_space, section->offset_within_address_space + int128_get64(int128_sub(section->size, int128_one()))); return; } if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) != (section->offset_within_region & ~TARGET_PAGE_MASK))) { error_report("%s received unaligned region", __func__); return; } iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); end = (section->offset_within_address_space + int128_get64(section->size)) & TARGET_PAGE_MASK; if (iova >= end) { return; } vaddr = memory_region_get_ram_ptr(section->mr) + section->offset_within_region + (iova - section->offset_within_address_space); DPRINTF("region_add %"HWADDR_PRIx" - %"HWADDR_PRIx" [%p]\n", iova, end - 1, vaddr); memory_region_ref(section->mr); ret = vfio_dma_map(container, iova, end - iova, vaddr, section->readonly); if (ret) { error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", " "0x%"HWADDR_PRIx", %p) = %d (%m)", container, iova, end - iova, vaddr, ret); } }
1,587
FFmpeg
fd6e513ee1dc13174256de8adaeeb2c2691eee95
1
static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) { AVStream *st = c->fc->streams[c->fc->nb_streams-1]; int len = 0; uint8_t *buf; uint32_t type; uint32_t ctype; print_atom("hdlr", atom); get_byte(pb); /* version */ get_byte(pb); get_byte(pb); get_byte(pb); /* flags */ /* component type */ ctype = get_le32(pb); type = get_le32(pb); /* component subtype */ #ifdef DEBUG printf("ctype= %c%c%c%c (0x%08lx)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], (long) ctype); printf("stype= %c%c%c%c\n", *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]); #endif #ifdef DEBUG /* XXX: yeah this is ugly... */ if(ctype == MKTAG('m', 'h', 'l', 'r')) { /* MOV */ if(type == MKTAG('v', 'i', 'd', 'e')) puts("hdlr: vide"); else if(type == MKTAG('s', 'o', 'u', 'n')) puts("hdlr: soun"); } else if(ctype == 0) { /* MP4 */ if(type == MKTAG('v', 'i', 'd', 'e')) puts("hdlr: vide"); else if(type == MKTAG('s', 'o', 'u', 'n')) puts("hdlr: soun"); else if(type == MKTAG('o', 'd', 's', 'm')) puts("hdlr: odsm"); else if(type == MKTAG('s', 'd', 's', 'm')) puts("hdlr: sdsm"); } else puts("hdlr: meta"); #endif if(ctype == MKTAG('m', 'h', 'l', 'r')) { /* MOV */ /* helps parsing the string hereafter... */ c->mp4 = 0; if(type == MKTAG('v', 'i', 'd', 'e')) st->codec.codec_type = CODEC_TYPE_VIDEO; else if(type == MKTAG('s', 'o', 'u', 'n')) st->codec.codec_type = CODEC_TYPE_AUDIO; } else if(ctype == 0) { /* MP4 */ /* helps parsing the string hereafter... */ c->mp4 = 1; if(type == MKTAG('v', 'i', 'd', 'e')) st->codec.codec_type = CODEC_TYPE_VIDEO; else if(type == MKTAG('s', 'o', 'u', 'n')) st->codec.codec_type = CODEC_TYPE_AUDIO; } get_be32(pb); /* component manufacture */ get_be32(pb); /* component flags */ get_be32(pb); /* component flags mask */ if(atom.size <= 24) return 0; /* nothing left to read */ /* XXX: MP4 uses a C string, not a pascal one */ /* component name */ if(c->mp4) { /* .mp4: C string */ while(get_byte(pb) && (++len < (atom.size - 24))); } else { /* .mov: PASCAL string */ len = get_byte(pb); #ifdef DEBUG buf = (uint8_t*) av_malloc(len+1); if (buf) { get_buffer(pb, buf, len); buf[len] = '\0'; printf("**buf='%s'\n", buf); av_free(buf); } else #endif url_fskip(pb, len); } return 0; }
1,588
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
1
static void qemu_rdma_dump_gid(const char *who, struct rdma_cm_id *id) { char sgid[33]; char dgid[33]; inet_ntop(AF_INET6, &id->route.addr.addr.ibaddr.sgid, sgid, sizeof sgid); inet_ntop(AF_INET6, &id->route.addr.addr.ibaddr.dgid, dgid, sizeof dgid); DPRINTF("%s Source GID: %s, Dest GID: %s\n", who, sgid, dgid); }
1,589
FFmpeg
11ca3416f92744f376c08e5f31bcbe5d9b44acb2
1
static int v410_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { AVFrame *pic = avctx->coded_frame; uint8_t *src = avpkt->data; uint16_t *y, *u, *v; uint32_t val; int i, j; if (pic->data[0]) avctx->release_buffer(avctx, pic); pic->reference = 0; if (avctx->get_buffer(avctx, pic) < 0) { av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n"); return AVERROR(ENOMEM); pic->key_frame = 1; pic->pict_type = FF_I_TYPE; y = (uint16_t *)pic->data[0]; u = (uint16_t *)pic->data[1]; v = (uint16_t *)pic->data[2]; for (i = 0; i < avctx->height; i++) { for (j = 0; j < avctx->width; j++) { val = AV_RL32(src); u[j] = (val >> 2) & 0x3FF; y[j] = (val >> 12) & 0x3FF; v[j] = (val >> 22); src += 4; y += pic->linesize[0] >> 1; u += pic->linesize[1] >> 1; v += pic->linesize[2] >> 1; *data_size = sizeof(AVFrame); *(AVFrame *)data = *pic; return avpkt->size;
1,590
qemu
6b2699672d5b56f8c2902fb9db9879e8cafb2afe
1
static void host_memory_backend_init(Object *obj) { HostMemoryBackend *backend = MEMORY_BACKEND(obj); backend->merge = qemu_opt_get_bool(qemu_get_machine_opts(), "mem-merge", true); backend->dump = qemu_opt_get_bool(qemu_get_machine_opts(), "dump-guest-core", true); backend->prealloc = mem_prealloc; object_property_add_bool(obj, "merge", host_memory_backend_get_merge, host_memory_backend_set_merge, NULL); object_property_add_bool(obj, "dump", host_memory_backend_get_dump, host_memory_backend_set_dump, NULL); object_property_add_bool(obj, "prealloc", host_memory_backend_get_prealloc, host_memory_backend_set_prealloc, NULL); object_property_add(obj, "size", "int", host_memory_backend_get_size, host_memory_backend_set_size, NULL, NULL, NULL); object_property_add(obj, "host-nodes", "int", host_memory_backend_get_host_nodes, host_memory_backend_set_host_nodes, NULL, NULL, NULL); object_property_add_enum(obj, "policy", "HostMemPolicy", HostMemPolicy_lookup, host_memory_backend_get_policy, host_memory_backend_set_policy, NULL); }
1,591
FFmpeg
33d7f822f8ed2d1870babc1d04d4d48cf8b6f240
1
static void adaptive_gain_control(float *out, const float *in, const float *speech_synth, int size, float alpha, float *gain_mem) { int i; float speech_energy = 0.0, postfilter_energy = 0.0, gain_scale_factor; float mem = *gain_mem; for (i = 0; i < size; i++) { speech_energy += fabsf(speech_synth[i]); postfilter_energy += fabsf(in[i]); } gain_scale_factor = (1.0 - alpha) * speech_energy / postfilter_energy; for (i = 0; i < size; i++) { mem = alpha * mem + gain_scale_factor; out[i] = in[i] * mem; } *gain_mem = mem; }
1,592
qemu
4b635c59b04cae594f49d9aa45d31b3f318def8f
1
void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id) { uint64_t phys = le64_to_cpu(pqxl); uint32_t slot = (phys >> (64 - 8)) & 0xff; uint64_t offset = phys & 0xffffffffffff; switch (group_id) { case MEMSLOT_GROUP_HOST: return (void *)(intptr_t)offset; case MEMSLOT_GROUP_GUEST: PANIC_ON(slot >= NUM_MEMSLOTS); PANIC_ON(!qxl->guest_slots[slot].active); PANIC_ON(offset < qxl->guest_slots[slot].delta); offset -= qxl->guest_slots[slot].delta; PANIC_ON(offset > qxl->guest_slots[slot].size) return qxl->guest_slots[slot].ptr + offset; default: PANIC_ON(1); } }
1,593
FFmpeg
0181b202cc42133eacd74bad33745cf1ba699e6b
1
static void ps_add_squares_c(INTFLOAT *dst, const INTFLOAT (*src)[2], int n) { int i; for (i = 0; i < n; i++) dst[i] += AAC_MADD28(src[i][0], src[i][0], src[i][1], src[i][1]); }
1,594
qemu
ce266b75febdeee5b91ab630a7158ddff3e002fb
1
static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t config_addr = rtas_ld(args, 0); uint64_t buid = rtas_ldq(args, 1); unsigned int func = rtas_ld(args, 3); unsigned int req_num = rtas_ld(args, 4); /* 0 == remove all */ unsigned int seq_num = rtas_ld(args, 5); unsigned int ret_intr_type; unsigned int irq, max_irqs = 0; sPAPRPHBState *phb = NULL; PCIDevice *pdev = NULL; spapr_pci_msi *msi; int *config_addr_key; switch (func) { case RTAS_CHANGE_MSI_FN: case RTAS_CHANGE_FN: ret_intr_type = RTAS_TYPE_MSI; break; case RTAS_CHANGE_MSIX_FN: ret_intr_type = RTAS_TYPE_MSIX; break; default: error_report("rtas_ibm_change_msi(%u) is not implemented", func); rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } /* Fins sPAPRPHBState */ phb = spapr_pci_find_phb(spapr, buid); if (phb) { pdev = spapr_pci_find_dev(spapr, buid, config_addr); } if (!phb || !pdev) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } /* Releasing MSIs */ if (!req_num) { msi = (spapr_pci_msi *) g_hash_table_lookup(phb->msi, &config_addr); if (!msi) { trace_spapr_pci_msi("Releasing wrong config", config_addr); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } xics_free(spapr->icp, msi->first_irq, msi->num); if (msi_present(pdev)) { spapr_msi_setmsg(pdev, 0, false, 0, 0); } if (msix_present(pdev)) { spapr_msi_setmsg(pdev, 0, true, 0, 0); } g_hash_table_remove(phb->msi, &config_addr); trace_spapr_pci_msi("Released MSIs", config_addr); rtas_st(rets, 0, RTAS_OUT_SUCCESS); rtas_st(rets, 1, 0); return; } /* Enabling MSI */ /* Check if the device supports as many IRQs as requested */ if (ret_intr_type == RTAS_TYPE_MSI) { max_irqs = msi_nr_vectors_allocated(pdev); } else if (ret_intr_type == RTAS_TYPE_MSIX) { max_irqs = pdev->msix_entries_nr; } if (!max_irqs) { error_report("Requested interrupt type %d is not enabled for device %x", ret_intr_type, config_addr); rtas_st(rets, 0, -1); /* Hardware error */ return; } /* Correct the number if the guest asked for too many */ if (req_num > max_irqs) { trace_spapr_pci_msi_retry(config_addr, req_num, max_irqs); req_num = max_irqs; irq = 0; /* to avoid misleading trace */ goto out; } /* Allocate MSIs */ irq = xics_alloc_block(spapr->icp, 0, req_num, false, ret_intr_type == RTAS_TYPE_MSI); if (!irq) { error_report("Cannot allocate MSIs for device %x", config_addr); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } /* Setup MSI/MSIX vectors in the device (via cfgspace or MSIX BAR) */ spapr_msi_setmsg(pdev, SPAPR_PCI_MSI_WINDOW, ret_intr_type == RTAS_TYPE_MSIX, irq, req_num); /* Add MSI device to cache */ msi = g_new(spapr_pci_msi, 1); msi->first_irq = irq; msi->num = req_num; config_addr_key = g_new(int, 1); *config_addr_key = config_addr; g_hash_table_insert(phb->msi, config_addr_key, msi); out: rtas_st(rets, 0, RTAS_OUT_SUCCESS); rtas_st(rets, 1, req_num); rtas_st(rets, 2, ++seq_num); if (nret > 3) { rtas_st(rets, 3, ret_intr_type); } trace_spapr_pci_rtas_ibm_change_msi(config_addr, func, req_num, irq); }
1,595
qemu
7372c2b926200db295412efbb53f93773b7f1754
1
static inline TCGv gen_extend(TCGv val, int opsize, int sign) { TCGv tmp; switch (opsize) { case OS_BYTE: tmp = tcg_temp_new(); if (sign) tcg_gen_ext8s_i32(tmp, val); else tcg_gen_ext8u_i32(tmp, val); break; case OS_WORD: tmp = tcg_temp_new(); if (sign) tcg_gen_ext16s_i32(tmp, val); else tcg_gen_ext16u_i32(tmp, val); break; case OS_LONG: case OS_SINGLE: tmp = val; break; default: qemu_assert(0, "Bad operand size"); } return tmp; }
1,596