id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
7,082
static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) { CPUArchState *env = cpu->env_ptr; uintptr_t ret; TranslationBlock *last_tb; int tb_exit; uint8_t *tb_ptr = itb->tc_ptr; qemu_log_mask_and_addr(CPU_LOG_EXEC, itb->pc, "Trace %p [" TARGET_FMT_lx "] %s\n", itb->tc_ptr, itb->pc, lookup_symbol(itb->pc)); #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_CPU)) { #if defined(TARGET_I386) log_cpu_state(cpu, CPU_DUMP_CCOP); #elif defined(TARGET_M68K) /* ??? Should not modify env state for dumping. */ cpu_m68k_flush_flags(env, env->cc_op); env->cc_op = CC_OP_FLAGS; env->sr = (env->sr & 0xffe0) | env->cc_dest | (env->cc_x << 4); log_cpu_state(cpu, 0); #else log_cpu_state(cpu, 0); #endif } #endif /* DEBUG_DISAS */ cpu->can_do_io = !use_icount; ret = tcg_qemu_tb_exec(env, tb_ptr); cpu->can_do_io = 1; last_tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK); tb_exit = ret & TB_EXIT_MASK; trace_exec_tb_exit(last_tb, tb_exit); if (tb_exit > TB_EXIT_IDX1) { /* We didn't start executing this TB (eg because the instruction * counter hit zero); we must restore the guest PC to the address * of the start of the TB. */ CPUClass *cc = CPU_GET_CLASS(cpu); qemu_log_mask_and_addr(CPU_LOG_EXEC, last_tb->pc, "Stopped execution of TB chain before %p [" TARGET_FMT_lx "] %s\n", last_tb->tc_ptr, last_tb->pc, lookup_symbol(last_tb->pc)); if (cc->synchronize_from_tb) { cc->synchronize_from_tb(cpu, last_tb); } else { assert(cc->set_pc); cc->set_pc(cpu, last_tb->pc); } } if (tb_exit == TB_EXIT_REQUESTED) { /* We were asked to stop executing TBs (probably a pending * interrupt. We've now stopped, so clear the flag. */ cpu->tcg_exit_req = 0; } return ret; }
false
qemu
be2208e2a50f4b50980d92c26f2e12cb2bda4afc
7,084
static int get_para_features(CPUState *env) { int i, features = 0; for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) { if (kvm_check_extension(env->kvm_state, para_features[i].cap)) features |= (1 << para_features[i].feature); } return features; }
false
qemu
b9bec74bcb16519a876ec21cd5277c526a9b512d
7,085
int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries, uint8_t bar_nr) { int ret; char *name; /* * Migration compatibility dictates that this remains a 4k * BAR with the vector table in the lower half and PBA in * the upper half. Do not use these elsewhere! */ #define MSIX_EXCLUSIVE_BAR_SIZE 4096 #define MSIX_EXCLUSIVE_BAR_TABLE_OFFSET 0 #define MSIX_EXCLUSIVE_BAR_PBA_OFFSET (MSIX_EXCLUSIVE_BAR_SIZE / 2) #define MSIX_EXCLUSIVE_CAP_OFFSET 0 if (nentries * PCI_MSIX_ENTRY_SIZE > MSIX_EXCLUSIVE_BAR_PBA_OFFSET) { return -EINVAL; } name = g_strdup_printf("%s-msix", dev->name); memory_region_init(&dev->msix_exclusive_bar, OBJECT(dev), name, MSIX_EXCLUSIVE_BAR_SIZE); g_free(name); ret = msix_init(dev, nentries, &dev->msix_exclusive_bar, bar_nr, MSIX_EXCLUSIVE_BAR_TABLE_OFFSET, &dev->msix_exclusive_bar, bar_nr, MSIX_EXCLUSIVE_BAR_PBA_OFFSET, MSIX_EXCLUSIVE_CAP_OFFSET); if (ret) { return ret; } pci_register_bar(dev, bar_nr, PCI_BASE_ADDRESS_SPACE_MEMORY, &dev->msix_exclusive_bar); return 0; }
false
qemu
a0ccd2123ee2f83a1f081e4c39013c3316f9ec7a
7,086
static int armv7m_nvic_init(SysBusDevice *dev) { nvic_state *s = NVIC(dev); NVICClass *nc = NVIC_GET_CLASS(s); /* The NVIC always has only one CPU */ s->gic.num_cpu = 1; /* Tell the common code we're an NVIC */ s->gic.revision = 0xffffffff; s->gic.num_irq = s->num_irq; nc->parent_init(dev); gic_init_irqs_and_distributor(&s->gic, s->num_irq); /* The NVIC and system controller register area looks like this: * 0..0xff : system control registers, including systick * 0x100..0xcff : GIC-like registers * 0xd00..0xfff : system control registers * We use overlaying to put the GIC like registers * over the top of the system control register region. */ memory_region_init(&s->container, "nvic", 0x1000); /* The system register region goes at the bottom of the priority * stack as it covers the whole page. */ memory_region_init_io(&s->sysregmem, &nvic_sysreg_ops, s, "nvic_sysregs", 0x1000); memory_region_add_subregion(&s->container, 0, &s->sysregmem); /* Alias the GIC region so we can get only the section of it * we need, and layer it on top of the system register region. */ memory_region_init_alias(&s->gic_iomem_alias, "nvic-gic", &s->gic.iomem, 0x100, 0xc00); memory_region_add_subregion_overlap(&s->container, 0x100, &s->gic.iomem, 1); /* Map the whole thing into system memory at the location required * by the v7M architecture. */ memory_region_add_subregion(get_system_memory(), 0xe000e000, &s->container); s->systick.timer = qemu_new_timer_ns(vm_clock, systick_timer_tick, s); return 0; }
false
qemu
55e00a19b6dc8f20e5688866451bb4a60e649459
7,087
static int get_mmu_address(CPUState * env, target_ulong * physical, int *prot, target_ulong address, int rw, int access_type) { int use_asid, n; tlb_t *matching = NULL; use_asid = (env->mmucr & MMUCR_SV) == 0 || (env->sr & SR_MD) == 0; if (rw == 2) { n = find_itlb_entry(env, address, use_asid, 1); if (n >= 0) { matching = &env->itlb[n]; if ((env->sr & SR_MD) & !(matching->pr & 2)) n = MMU_ITLB_VIOLATION; else *prot = PAGE_READ; } } else { n = find_utlb_entry(env, address, use_asid); if (n >= 0) { matching = &env->utlb[n]; switch ((matching->pr << 1) | ((env->sr & SR_MD) ? 1 : 0)) { case 0: /* 000 */ case 2: /* 010 */ n = (rw == 1) ? MMU_DTLB_VIOLATION_WRITE : MMU_DTLB_VIOLATION_READ; break; case 1: /* 001 */ case 4: /* 100 */ case 5: /* 101 */ if (rw == 1) n = MMU_DTLB_VIOLATION_WRITE; else *prot = PAGE_READ; break; case 3: /* 011 */ case 6: /* 110 */ case 7: /* 111 */ *prot = (rw == 1)? PAGE_WRITE : PAGE_READ; break; } } else if (n == MMU_DTLB_MISS) { n = (rw == 1) ? MMU_DTLB_MISS_WRITE : MMU_DTLB_MISS_READ; } } if (n >= 0) { *physical = ((matching->ppn << 10) & ~(matching->size - 1)) | (address & (matching->size - 1)); if ((rw == 1) & !matching->d) n = MMU_DTLB_INITIAL_WRITE; else n = MMU_OK; } return n; }
false
qemu
4d1e4ff63ce7c23256b24c3f1722d1abccb26451
7,088
static void add_codec(FFStream *stream, AVCodecContext *av) { AVStream *st; if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams)) return; /* compute default parameters */ switch(av->codec_type) { case AVMEDIA_TYPE_AUDIO: if (av->bit_rate == 0) av->bit_rate = 64000; if (av->sample_rate == 0) av->sample_rate = 22050; if (av->channels == 0) av->channels = 1; break; case AVMEDIA_TYPE_VIDEO: if (av->bit_rate == 0) av->bit_rate = 64000; if (av->time_base.num == 0){ av->time_base.den = 5; av->time_base.num = 1; } if (av->width == 0 || av->height == 0) { av->width = 160; av->height = 128; } /* Bitrate tolerance is less for streaming */ if (av->bit_rate_tolerance == 0) av->bit_rate_tolerance = FFMAX(av->bit_rate / 4, (int64_t)av->bit_rate*av->time_base.num/av->time_base.den); if (av->qmin == 0) av->qmin = 3; if (av->qmax == 0) av->qmax = 31; if (av->max_qdiff == 0) av->max_qdiff = 3; av->qcompress = 0.5; av->qblur = 0.5; if (!av->nsse_weight) av->nsse_weight = 8; av->frame_skip_cmp = FF_CMP_DCTMAX; if (!av->me_method) av->me_method = ME_EPZS; av->rc_buffer_aggressivity = 1.0; if (!av->rc_eq) av->rc_eq = "tex^qComp"; if (!av->i_quant_factor) av->i_quant_factor = -0.8; if (!av->b_quant_factor) av->b_quant_factor = 1.25; if (!av->b_quant_offset) av->b_quant_offset = 1.25; if (!av->rc_max_rate) av->rc_max_rate = av->bit_rate * 2; if (av->rc_max_rate && !av->rc_buffer_size) { av->rc_buffer_size = av->rc_max_rate; } break; default: abort(); } st = av_mallocz(sizeof(AVStream)); if (!st) return; st->codec = avcodec_alloc_context3(NULL); stream->streams[stream->nb_streams++] = st; memcpy(st->codec, av, sizeof(AVCodecContext)); }
false
FFmpeg
e85771f26814ae192f511a1b01b17ae0d62d62ab
7,091
START_TEST(qdict_put_obj_test) { QInt *qi; QDict *qdict; QDictEntry *ent; const int num = 42; qdict = qdict_new(); // key "" will have tdb hash 12345 qdict_put_obj(qdict, "", QOBJECT(qint_from_int(num))); fail_unless(qdict_size(qdict) == 1); ent = QLIST_FIRST(&qdict->table[12345 % QDICT_BUCKET_MAX]); qi = qobject_to_qint(ent->value); fail_unless(qint_get_int(qi) == num); // destroy doesn't exit yet QDECREF(qi); g_free(ent->key); g_free(ent); g_free(qdict); }
false
qemu
ac531cb6e542b1e61d668604adf9dc5306a948c0
7,092
static int v9fs_do_mkdir(V9fsState *s, V9fsString *path, mode_t mode) { return s->ops->mkdir(&s->ctx, path->data, mode); }
false
qemu
00ec5c37601accb2b85b089d72fc7ddff2f4222e
7,093
static uint32_t slow_bar_readb(void *opaque, target_phys_addr_t addr) { AssignedDevRegion *d = opaque; uint8_t *in = d->u.r_virtbase + addr; uint32_t r; r = *in; DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r); return r; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
7,094
uint32_t HELPER(tprot)(uint64_t a1, uint64_t a2) { /* XXX implement */ return 0; }
false
qemu
bb8794307252be791f1723eae47983f815882376
7,095
static void ds1338_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); I2CSlaveClass *k = I2C_SLAVE_CLASS(klass); k->init = ds1338_init; k->event = ds1338_event; k->recv = ds1338_recv; k->send = ds1338_send; dc->reset = ds1338_reset; dc->vmsd = &vmstate_ds1338; }
false
qemu
9e41bade85ef338afd983c109368d1bbbe931f80
7,096
static void extend_solid_area(VncState *vs, int x, int y, int w, int h, uint32_t color, int *x_ptr, int *y_ptr, int *w_ptr, int *h_ptr) { int cx, cy; /* Try to extend the area upwards. */ for ( cy = *y_ptr - 1; cy >= y && check_solid_tile(vs, *x_ptr, cy, *w_ptr, 1, &color, true); cy-- ); *h_ptr += *y_ptr - (cy + 1); *y_ptr = cy + 1; /* ... downwards. */ for ( cy = *y_ptr + *h_ptr; cy < y + h && check_solid_tile(vs, *x_ptr, cy, *w_ptr, 1, &color, true); cy++ ); *h_ptr += cy - (*y_ptr + *h_ptr); /* ... to the left. */ for ( cx = *x_ptr - 1; cx >= x && check_solid_tile(vs, cx, *y_ptr, 1, *h_ptr, &color, true); cx-- ); *w_ptr += *x_ptr - (cx + 1); *x_ptr = cx + 1; /* ... to the right. */ for ( cx = *x_ptr + *w_ptr; cx < x + w && check_solid_tile(vs, cx, *y_ptr, 1, *h_ptr, &color, true); cx++ ); *w_ptr += cx - (*x_ptr + *w_ptr); }
false
qemu
245f7b51c0ea04fb2224b1127430a096c91aee70
7,097
static inline void RET_CHG_FLOW (DisasContext *ctx) { ctx->exception = EXCP_MTMSR; }
false
qemu
e1833e1f96456fd8fc17463246fe0b2050e68efb
7,098
static void setup_sigframe_v2(struct target_ucontext_v2 *uc, target_sigset_t *set, CPUState *env) { struct target_sigaltstack stack; int i; /* Clear all the bits of the ucontext we don't use. */ memset(uc, 0, offsetof(struct target_ucontext_v2, tuc_mcontext)); memset(&stack, 0, sizeof(stack)); __put_user(target_sigaltstack_used.ss_sp, &stack.ss_sp); __put_user(target_sigaltstack_used.ss_size, &stack.ss_size); __put_user(sas_ss_flags(get_sp_from_cpustate(env)), &stack.ss_flags); memcpy(&uc->tuc_stack, &stack, sizeof(stack)); setup_sigcontext(&uc->tuc_mcontext, env, set->sig[0]); /* FIXME: Save coprocessor signal frame. */ for(i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &uc->tuc_sigmask.sig[i]); } }
false
qemu
0d871bdbaac428601c84d29233a49f7cf6ecb6fc
7,100
static av_cold int vdadec_close(AVCodecContext *avctx) { VDADecoderContext *ctx = avctx->priv_data; /* release buffers and decoder */ ff_vda_destroy_decoder(&ctx->vda_ctx); /* close H.264 decoder */ if (ctx->h264_initialized) ff_h264_decoder.close(avctx); return 0; }
false
FFmpeg
973b1a6b9070e2bf17d17568cbaf4043ce931f51
7,101
void pci_bridge_write_config(PCIDevice *d, uint32_t address, uint32_t val, int len) { PCIBridge *s = PCI_BRIDGE(d); uint16_t oldctl = pci_get_word(d->config + PCI_BRIDGE_CONTROL); uint16_t newctl; pci_default_write_config(d, address, val, len); if (ranges_overlap(address, len, PCI_COMMAND, 2) || /* io base/limit */ ranges_overlap(address, len, PCI_IO_BASE, 2) || /* memory base/limit, prefetchable base/limit and io base/limit upper 16 */ ranges_overlap(address, len, PCI_MEMORY_BASE, 20) || /* vga enable */ ranges_overlap(address, len, PCI_BRIDGE_CONTROL, 2)) { pci_bridge_update_mappings(s); } newctl = pci_get_word(d->config + PCI_BRIDGE_CONTROL); if (~oldctl & newctl & PCI_BRIDGE_CTL_BUS_RESET) { /* Trigger hot reset on 0->1 transition. */ pci_bus_reset(&s->sec_bus); } }
false
qemu
81e3e75b6461c53724fe7c7918bc54468fcdaf9d
7,102
static inline int ucf64_exceptbits_to_host(int target_bits) { int host_bits = 0; if (target_bits & UCF64_FPSCR_FLAG_INVALID) { host_bits |= float_flag_invalid; } if (target_bits & UCF64_FPSCR_FLAG_DIVZERO) { host_bits |= float_flag_divbyzero; } if (target_bits & UCF64_FPSCR_FLAG_OVERFLOW) { host_bits |= float_flag_overflow; } if (target_bits & UCF64_FPSCR_FLAG_UNDERFLOW) { host_bits |= float_flag_underflow; } if (target_bits & UCF64_FPSCR_FLAG_INEXACT) { host_bits |= float_flag_inexact; } return host_bits; }
false
qemu
e8ede0a8bb5298a6979bcf7ed84ef64a64a4e3fe
7,103
static void qmp_output_start_list(Visitor *v, const char *name, Error **errp) { QmpOutputVisitor *qov = to_qov(v); QList *list = qlist_new(); qmp_output_add(qov, name, list); qmp_output_push(qov, list); }
false
qemu
d9f62dde1303286b24ac8ce88be27e2b9b9c5f46
7,104
static int scsi_hot_add(Monitor *mon, DeviceState *adapter, DriveInfo *dinfo, int printinfo) { SCSIBus *scsibus; SCSIDevice *scsidev; scsibus = DO_UPCAST(SCSIBus, qbus, QLIST_FIRST(&adapter->child_bus)); if (!scsibus || strcmp(scsibus->qbus.info->name, "SCSI") != 0) { error_report("Device is not a SCSI adapter"); return -1; } /* * drive_init() tries to find a default for dinfo->unit. Doesn't * work at all for hotplug though as we assign the device to a * specific bus instead of the first bus with spare scsi ids. * * Ditch the calculated value and reload from option string (if * specified). */ dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1); scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo, dinfo->unit); if (!scsidev) { return -1; } dinfo->unit = scsidev->id; if (printinfo) monitor_printf(mon, "OK bus %d, unit %d\n", scsibus->busnr, scsidev->id); return 0; }
false
qemu
f8b6cc0070aab8b75bd082582c829be1353f395f
7,106
float64 float64_round_to_int( float64 a STATUS_PARAM ) { flag aSign; int16 aExp; bits64 lastBitMask, roundBitsMask; int8 roundingMode; float64 z; aExp = extractFloat64Exp( a ); if ( 0x433 <= aExp ) { if ( ( aExp == 0x7FF ) && extractFloat64Frac( a ) ) { return propagateFloat64NaN( a, a STATUS_VAR ); } return a; } if ( aExp < 0x3FF ) { if ( (bits64) ( a<<1 ) == 0 ) return a; STATUS(float_exception_flags) |= float_flag_inexact; aSign = extractFloat64Sign( a ); switch ( STATUS(float_rounding_mode) ) { case float_round_nearest_even: if ( ( aExp == 0x3FE ) && extractFloat64Frac( a ) ) { return packFloat64( aSign, 0x3FF, 0 ); } break; case float_round_down: return aSign ? LIT64( 0xBFF0000000000000 ) : 0; case float_round_up: return aSign ? LIT64( 0x8000000000000000 ) : LIT64( 0x3FF0000000000000 ); } return packFloat64( aSign, 0, 0 ); } lastBitMask = 1; lastBitMask <<= 0x433 - aExp; roundBitsMask = lastBitMask - 1; z = a; roundingMode = STATUS(float_rounding_mode); if ( roundingMode == float_round_nearest_even ) { z += lastBitMask>>1; if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask; } else if ( roundingMode != float_round_to_zero ) { if ( extractFloat64Sign( z ) ^ ( roundingMode == float_round_up ) ) { z += roundBitsMask; } } z &= ~ roundBitsMask; if ( z != a ) STATUS(float_exception_flags) |= float_flag_inexact; return z; }
false
qemu
f090c9d4ad5812fb92843d6470a1111c15190c4c
7,107
static void scsi_cd_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass); sc->init = scsi_cd_initfn; sc->destroy = scsi_destroy; sc->alloc_req = scsi_new_request; sc->unit_attention_reported = scsi_disk_unit_attention_reported; dc->fw_name = "disk"; dc->desc = "virtual SCSI CD-ROM"; dc->reset = scsi_disk_reset; dc->props = scsi_cd_properties; dc->vmsd = &vmstate_scsi_disk_state; }
false
qemu
a818a4b69d47ca3826dee36878074395aeac2083
7,108
static int local_post_create_passthrough(FsContext *fs_ctx, const char *path, FsCred *credp) { char buffer[PATH_MAX]; if (chmod(rpath(fs_ctx, path, buffer), credp->fc_mode & 07777) < 0) { return -1; } if (lchown(rpath(fs_ctx, path, buffer), credp->fc_uid, credp->fc_gid) < 0) { /* * If we fail to change ownership and if we are * using security model none. Ignore the error */ if (fs_ctx->fs_sm != SM_NONE) { return -1; } } return 0; }
false
qemu
b97400caef60ccfb0bc81c59f8bd824c43a0d6c8
7,110
uint8_t cpu_inb(pio_addr_t addr) { uint8_t val; val = ioport_read(0, addr); trace_cpu_in(addr, val); LOG_IOPORT("inb : %04"FMT_pioaddr" %02"PRIx8"\n", addr, val); return val; }
false
qemu
b40acf99bef69fa8ab0f9092ff162fde945eec12
7,112
void s390_init_cpus(const char *cpu_model) { int i; if (cpu_model == NULL) { cpu_model = "host"; } ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus); for (i = 0; i < smp_cpus; i++) { S390CPU *cpu; CPUState *cs; cpu = cpu_s390x_init(cpu_model); cs = CPU(cpu); ipi_states[i] = cpu; cs->halted = 1; cs->exception_index = EXCP_HLT; } }
false
qemu
d2eae20790e825656b205dbe347826ff991fb3d8
7,113
static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) { SCSIDevice *d = virtio_scsi_device_find(s, req->req.tmf.lun); SCSIRequest *r, *next; BusChild *kid; int target; int ret = 0; if (s->dataplane_started && bdrv_get_aio_context(d->conf.bs) != s->ctx) { aio_context_acquire(s->ctx); bdrv_set_aio_context(d->conf.bs, s->ctx); aio_context_release(s->ctx); } /* Here VIRTIO_SCSI_S_OK means "FUNCTION COMPLETE". */ req->resp.tmf.response = VIRTIO_SCSI_S_OK; virtio_tswap32s(VIRTIO_DEVICE(s), &req->req.tmf.subtype); switch (req->req.tmf.subtype) { case VIRTIO_SCSI_T_TMF_ABORT_TASK: case VIRTIO_SCSI_T_TMF_QUERY_TASK: if (!d) { goto fail; } if (d->lun != virtio_scsi_get_lun(req->req.tmf.lun)) { goto incorrect_lun; } QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) { VirtIOSCSIReq *cmd_req = r->hba_private; if (cmd_req && cmd_req->req.cmd.tag == req->req.tmf.tag) { break; } } if (r) { /* * Assert that the request has not been completed yet, we * check for it in the loop above. */ assert(r->hba_private); if (req->req.tmf.subtype == VIRTIO_SCSI_T_TMF_QUERY_TASK) { /* "If the specified command is present in the task set, then * return a service response set to FUNCTION SUCCEEDED". */ req->resp.tmf.response = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED; } else { VirtIOSCSICancelNotifier *notifier; req->remaining = 1; notifier = g_slice_new(VirtIOSCSICancelNotifier); notifier->tmf_req = req; notifier->notifier.notify = virtio_scsi_cancel_notify; scsi_req_cancel_async(r, &notifier->notifier); ret = -EINPROGRESS; } } break; case VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET: if (!d) { goto fail; } if (d->lun != virtio_scsi_get_lun(req->req.tmf.lun)) { goto incorrect_lun; } s->resetting++; qdev_reset_all(&d->qdev); s->resetting--; break; case VIRTIO_SCSI_T_TMF_ABORT_TASK_SET: case VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET: case VIRTIO_SCSI_T_TMF_QUERY_TASK_SET: if (!d) { goto fail; } if (d->lun != virtio_scsi_get_lun(req->req.tmf.lun)) { goto incorrect_lun; } /* Add 1 to "remaining" until virtio_scsi_do_tmf returns. * This way, if the bus starts calling back to the notifiers * even before we finish the loop, virtio_scsi_cancel_notify * will not complete the TMF too early. */ req->remaining = 1; QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) { if (r->hba_private) { if (req->req.tmf.subtype == VIRTIO_SCSI_T_TMF_QUERY_TASK_SET) { /* "If there is any command present in the task set, then * return a service response set to FUNCTION SUCCEEDED". */ req->resp.tmf.response = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED; break; } else { VirtIOSCSICancelNotifier *notifier; req->remaining++; notifier = g_slice_new(VirtIOSCSICancelNotifier); notifier->notifier.notify = virtio_scsi_cancel_notify; notifier->tmf_req = req; scsi_req_cancel_async(r, &notifier->notifier); } } } if (--req->remaining > 0) { ret = -EINPROGRESS; } break; case VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET: target = req->req.tmf.lun[1]; s->resetting++; QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { d = DO_UPCAST(SCSIDevice, qdev, kid->child); if (d->channel == 0 && d->id == target) { qdev_reset_all(&d->qdev); } } s->resetting--; break; case VIRTIO_SCSI_T_TMF_CLEAR_ACA: default: req->resp.tmf.response = VIRTIO_SCSI_S_FUNCTION_REJECTED; break; } return ret; incorrect_lun: req->resp.tmf.response = VIRTIO_SCSI_S_INCORRECT_LUN; return ret; fail: req->resp.tmf.response = VIRTIO_SCSI_S_BAD_TARGET; return ret; }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
7,114
static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { RawAIOCB *acb; /* * If O_DIRECT is used and the buffer is not aligned fall back * to synchronous IO. */ BDRVRawState *s = bs->opaque; if (unlikely(s->aligned_buf != NULL && ((uintptr_t) buf % 512))) { QEMUBH *bh; acb = qemu_aio_get(bs, cb, opaque); acb->ret = raw_pwrite(bs, 512 * sector_num, buf, 512 * nb_sectors); bh = qemu_bh_new(raw_aio_em_cb, acb); qemu_bh_schedule(bh); return &acb->common; } acb = raw_aio_setup(bs, sector_num, (uint8_t*)buf, nb_sectors, cb, opaque); if (!acb) return NULL; if (aio_write(&acb->aiocb) < 0) { qemu_aio_release(acb); return NULL; } return &acb->common; }
false
qemu
3c529d935923a70519557d420db1d5a09a65086a
7,116
static void vnc_init_basic_info_from_remote_addr(QIOChannelSocket *ioc, VncBasicInfo *info, Error **errp) { SocketAddress *addr = NULL; addr = qio_channel_socket_get_remote_address(ioc, errp); if (!addr) { return; } vnc_init_basic_info(addr, info, errp); qapi_free_SocketAddress(addr); }
false
qemu
dfd100f242370886bb6732f70f1f7cbd8eb9fedc
7,117
static void vnc_write_u8(VncState *vs, uint8_t value) { vnc_write(vs, (char *)&value, 1); }
false
qemu
5fb6c7a8b26eab1a22207d24b4784bd2b39ab54b
7,118
void helper_mtc0_pagemask(CPUMIPSState *env, target_ulong arg1) { /* 1k pages not implemented */ env->CP0_PageMask = arg1 & (0x1FFFFFFF & (TARGET_PAGE_MASK << 1)); }
false
qemu
ba801af429aaa68f6cc03842c8b6be81a6ede65a
7,120
static void memory_region_prepare_ram_addr(MemoryRegion *mr) { if (mr->backend_registered) { return; } mr->destructor = memory_region_destructor_iomem; mr->ram_addr = cpu_register_io_memory(memory_region_read_thunk, memory_region_write_thunk, mr); mr->backend_registered = true; }
false
qemu
26a83ad0e793465b74a8b06a65f2f6fdc5615413
7,121
static void virtio_blk_reset(VirtIODevice *vdev) { VirtIOBlock *s = VIRTIO_BLK(vdev); AioContext *ctx; VirtIOBlockReq *req; ctx = blk_get_aio_context(s->blk); aio_context_acquire(ctx); blk_drain(s->blk); /* We drop queued requests after blk_drain() because blk_drain() itself can * produce them. */ while (s->rq) { req = s->rq; s->rq = req->next; virtqueue_detach_element(req->vq, &req->elem, 0); virtio_blk_free_request(req); } if (s->dataplane) { virtio_blk_data_plane_stop(s->dataplane); } aio_context_release(ctx); blk_set_enable_write_cache(s->blk, s->original_wce); }
false
qemu
9ffe337c08388d5c587eae1d77db1b0d1a47c7b1
7,123
static void avc_h_loop_filter_luma_mbaff_msa(uint8_t *in, int32_t stride, int32_t alpha_in, int32_t beta_in, int8_t *tc0) { uint8_t *data = in; uint32_t out0, out1, out2, out3; uint64_t load; uint32_t tc_val; v16u8 alpha, beta; v16i8 inp0 = { 0 }; v16i8 inp1 = { 0 }; v16i8 inp2 = { 0 }; v16i8 inp3 = { 0 }; v16i8 inp4 = { 0 }; v16i8 inp5 = { 0 }; v16i8 inp6 = { 0 }; v16i8 inp7 = { 0 }; v16i8 src0, src1, src2, src3; v8i16 src4, src5, src6, src7; v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, p2_asub_p0, q2_asub_q0; v16u8 is_less_than, is_less_than_alpha, is_less_than_beta; v16u8 is_less_than_beta1, is_less_than_beta2; v8i16 tc, tc_orig_r, tc_plus1; v16u8 is_tc_orig1, is_tc_orig2, tc_orig = { 0 }; v8i16 p0_ilvr_q0, p0_add_q0, q0_sub_p0, p1_sub_q1; v8u16 src2_r, src3_r; v8i16 p2_r, p1_r, q2_r, q1_r; v16u8 p2, q2, p0, q0; v4i32 dst0, dst1; v16i8 zeros = { 0 }; alpha = (v16u8) __msa_fill_b(alpha_in); beta = (v16u8) __msa_fill_b(beta_in); if (tc0[0] < 0) { data += (2 * stride); } else { load = LOAD_DWORD(data - 3); inp0 = (v16i8) __msa_insert_d((v2i64) inp0, 0, load); load = LOAD_DWORD(data - 3 + stride); inp1 = (v16i8) __msa_insert_d((v2i64) inp1, 0, load); data += (2 * stride); } if (tc0[1] < 0) { data += (2 * stride); } else { load = LOAD_DWORD(data - 3); inp2 = (v16i8) __msa_insert_d((v2i64) inp2, 0, load); load = LOAD_DWORD(data - 3 + stride); inp3 = (v16i8) __msa_insert_d((v2i64) inp3, 0, load); data += (2 * stride); } if (tc0[2] < 0) { data += (2 * stride); } else { load = LOAD_DWORD(data - 3); inp4 = (v16i8) __msa_insert_d((v2i64) inp4, 0, load); load = LOAD_DWORD(data - 3 + stride); inp5 = (v16i8) __msa_insert_d((v2i64) inp5, 0, load); data += (2 * stride); } if (tc0[3] < 0) { data += (2 * stride); } else { load = LOAD_DWORD(data - 3); inp6 = (v16i8) __msa_insert_d((v2i64) inp6, 0, load); load = LOAD_DWORD(data - 3 + stride); inp7 = (v16i8) __msa_insert_d((v2i64) inp7, 0, load); data += (2 * stride); } src0 = __msa_ilvr_b(inp1, inp0); src1 = __msa_ilvr_b(inp3, inp2); src2 = __msa_ilvr_b(inp5, inp4); src3 = __msa_ilvr_b(inp7, inp6); src4 = __msa_ilvr_h((v8i16) src1, (v8i16) src0); src5 = __msa_ilvl_h((v8i16) src1, (v8i16) src0); src6 = __msa_ilvr_h((v8i16) src3, (v8i16) src2); src7 = __msa_ilvl_h((v8i16) src3, (v8i16) src2); src0 = (v16i8) __msa_ilvr_w((v4i32) src6, (v4i32) src4); src1 = __msa_sldi_b(zeros, (v16i8) src0, 8); src2 = (v16i8) __msa_ilvl_w((v4i32) src6, (v4i32) src4); src3 = __msa_sldi_b(zeros, (v16i8) src2, 8); src4 = (v8i16) __msa_ilvr_w((v4i32) src7, (v4i32) src5); src5 = (v8i16) __msa_sldi_b(zeros, (v16i8) src4, 8); p0_asub_q0 = __msa_asub_u_b((v16u8) src2, (v16u8) src3); p1_asub_p0 = __msa_asub_u_b((v16u8) src1, (v16u8) src2); q1_asub_q0 = __msa_asub_u_b((v16u8) src4, (v16u8) src3); p2_asub_p0 = __msa_asub_u_b((v16u8) src0, (v16u8) src2); q2_asub_q0 = __msa_asub_u_b((v16u8) src5, (v16u8) src3); is_less_than_alpha = (p0_asub_q0 < alpha); is_less_than_beta = (p1_asub_p0 < beta); is_less_than = is_less_than_alpha & is_less_than_beta; is_less_than_beta = (q1_asub_q0 < beta); is_less_than = is_less_than_beta & is_less_than; is_less_than_beta1 = (p2_asub_p0 < beta); is_less_than_beta2 = (q2_asub_q0 < beta); p0_ilvr_q0 = (v8i16) __msa_ilvr_b((v16i8) src3, (v16i8) src2); p0_add_q0 = (v8i16) __msa_hadd_u_h((v16u8) p0_ilvr_q0, (v16u8) p0_ilvr_q0); p0_add_q0 = __msa_srari_h(p0_add_q0, 1); p2_r = (v8i16) __msa_ilvr_b(zeros, src0); p1_r = (v8i16) __msa_ilvr_b(zeros, src1); p2_r += p0_add_q0; p2_r >>= 1; p2_r -= p1_r; q2_r = (v8i16) __msa_ilvr_b(zeros, (v16i8) src5); q1_r = (v8i16) __msa_ilvr_b(zeros, (v16i8) src4); q2_r += p0_add_q0; q2_r >>= 1; q2_r -= q1_r; tc_val = LOAD_WORD(tc0); tc_orig = (v16u8) __msa_insert_w((v4i32) tc_orig, 0, tc_val); tc_orig = (v16u8) __msa_ilvr_b((v16i8) tc_orig, (v16i8) tc_orig); is_tc_orig1 = tc_orig; is_tc_orig2 = tc_orig; tc_orig_r = (v8i16) __msa_ilvr_b(zeros, (v16i8) tc_orig); tc = tc_orig_r; p2_r = CLIP_MIN_TO_MAX_H(p2_r, -tc_orig_r, tc_orig_r); q2_r = CLIP_MIN_TO_MAX_H(q2_r, -tc_orig_r, tc_orig_r); p2_r += p1_r; q2_r += q1_r; p2 = (v16u8) __msa_pckev_b((v16i8) p2_r, (v16i8) p2_r); q2 = (v16u8) __msa_pckev_b((v16i8) q2_r, (v16i8) q2_r); is_tc_orig1 = (zeros < is_tc_orig1); is_tc_orig2 = is_tc_orig1; is_tc_orig1 = is_less_than_beta1 & is_tc_orig1; is_tc_orig2 = is_less_than_beta2 & is_tc_orig2; is_tc_orig1 = is_less_than & is_tc_orig1; is_tc_orig2 = is_less_than & is_tc_orig2; p2 = __msa_bmnz_v((v16u8) src1, p2, is_tc_orig1); q2 = __msa_bmnz_v((v16u8) src4, q2, is_tc_orig2); q0_sub_p0 = __msa_hsub_u_h((v16u8) p0_ilvr_q0, (v16u8) p0_ilvr_q0); q0_sub_p0 <<= 2; p1_sub_q1 = p1_r - q1_r; q0_sub_p0 += p1_sub_q1; q0_sub_p0 = __msa_srari_h(q0_sub_p0, 3); tc_plus1 = tc + 1; is_less_than_beta1 = (v16u8) __msa_ilvr_b((v16i8) is_less_than_beta1, (v16i8) is_less_than_beta1); tc = (v8i16) __msa_bmnz_v((v16u8) tc, (v16u8) tc_plus1, is_less_than_beta1); tc_plus1 = tc + 1; is_less_than_beta2 = (v16u8) __msa_ilvr_b((v16i8) is_less_than_beta2, (v16i8) is_less_than_beta2); tc = (v8i16) __msa_bmnz_v((v16u8) tc, (v16u8) tc_plus1, is_less_than_beta2); q0_sub_p0 = CLIP_MIN_TO_MAX_H(q0_sub_p0, -tc, tc); src2_r = (v8u16) __msa_ilvr_b(zeros, src2); src3_r = (v8u16) __msa_ilvr_b(zeros, src3); src2_r += q0_sub_p0; src3_r -= q0_sub_p0; src2_r = (v8u16) CLIP_UNSIGNED_CHAR_H(src2_r); src3_r = (v8u16) CLIP_UNSIGNED_CHAR_H(src3_r); p0 = (v16u8) __msa_pckev_b((v16i8) src2_r, (v16i8) src2_r); q0 = (v16u8) __msa_pckev_b((v16i8) src3_r, (v16i8) src3_r); p0 = __msa_bmnz_v((v16u8) src2, p0, is_less_than); q0 = __msa_bmnz_v((v16u8) src3, q0, is_less_than); p2 = (v16u8) __msa_ilvr_b((v16i8) p0, (v16i8) p2); q2 = (v16u8) __msa_ilvr_b((v16i8) q2, (v16i8) q0); dst0 = (v4i32) __msa_ilvr_h((v8i16) q2, (v8i16) p2); dst1 = (v4i32) __msa_ilvl_h((v8i16) q2, (v8i16) p2); data = in; out0 = __msa_copy_u_w(dst0, 0); out1 = __msa_copy_u_w(dst0, 1); out2 = __msa_copy_u_w(dst0, 2); out3 = __msa_copy_u_w(dst0, 3); if (tc0[0] < 0) { data += (2 * stride); } else { STORE_WORD((data - 2), out0); data += stride; STORE_WORD((data - 2), out1); data += stride; } if (tc0[1] < 0) { data += (2 * stride); } else { STORE_WORD((data - 2), out2); data += stride; STORE_WORD((data - 2), out3); data += stride; } out0 = __msa_copy_u_w(dst1, 0); out1 = __msa_copy_u_w(dst1, 1); out2 = __msa_copy_u_w(dst1, 2); out3 = __msa_copy_u_w(dst1, 3); if (tc0[2] < 0) { data += (2 * stride); } else { STORE_WORD((data - 2), out0); data += stride; STORE_WORD((data - 2), out1); data += stride; } if (tc0[3] >= 0) { STORE_WORD((data - 2), out2); data += stride; STORE_WORD((data - 2), out3); } }
false
FFmpeg
bcd7bf7eeb09a395cc01698842d1b8be9af483fc
7,124
ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq) { DeviceState *dev; ISADevice *isadev; RTCState *s; isadev = isa_create(bus, TYPE_MC146818_RTC); dev = DEVICE(isadev); s = MC146818_RTC(isadev); qdev_prop_set_int32(dev, "base_year", base_year); qdev_init_nofail(dev); if (intercept_irq) { s->irq = intercept_irq; } else { isa_init_irq(isadev, &s->irq, RTC_ISA_IRQ); } QLIST_INSERT_HEAD(&rtc_devices, s, link); return isadev; }
false
qemu
3638439d541835f20fb76346f14549800046af76
7,126
static int decode_gop_header(IVI5DecContext *ctx, AVCodecContext *avctx) { int result, i, p, tile_size, pic_size_indx, mb_size, blk_size; int quant_mat, blk_size_changed = 0; IVIBandDesc *band, *band1, *band2; IVIPicConfig pic_conf; ctx->gop_flags = get_bits(&ctx->gb, 8); ctx->gop_hdr_size = (ctx->gop_flags & 1) ? get_bits(&ctx->gb, 16) : 0; if (ctx->gop_flags & IVI5_IS_PROTECTED) ctx->lock_word = get_bits_long(&ctx->gb, 32); tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0; if (tile_size > 256) { av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size); return -1; } /* decode number of wavelet bands */ /* num_levels * 3 + 1 */ pic_conf.luma_bands = get_bits(&ctx->gb, 2) * 3 + 1; pic_conf.chroma_bands = get_bits1(&ctx->gb) * 3 + 1; ctx->is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1; if (ctx->is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) { av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n", pic_conf.luma_bands, pic_conf.chroma_bands); return -1; } pic_size_indx = get_bits(&ctx->gb, 4); if (pic_size_indx == IVI5_PIC_SIZE_ESC) { pic_conf.pic_height = get_bits(&ctx->gb, 13); pic_conf.pic_width = get_bits(&ctx->gb, 13); } else { pic_conf.pic_height = ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2; pic_conf.pic_width = ivi5_common_pic_sizes[pic_size_indx * 2 ] << 2; } if (ctx->gop_flags & 2) { av_log(avctx, AV_LOG_ERROR, "YV12 picture format not supported!\n"); return -1; } pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2; pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2; if (!tile_size) { pic_conf.tile_height = pic_conf.pic_height; pic_conf.tile_width = pic_conf.pic_width; } else { pic_conf.tile_height = pic_conf.tile_width = tile_size; } /* check if picture layout was changed and reallocate buffers */ if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) { result = ff_ivi_init_planes(ctx->planes, &pic_conf); if (result) { av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n"); return -1; } ctx->pic_conf = pic_conf; blk_size_changed = 1; /* force reallocation of the internal structures */ } for (p = 0; p <= 1; p++) { for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) { band = &ctx->planes[p].bands[i]; band->is_halfpel = get_bits1(&ctx->gb); mb_size = get_bits1(&ctx->gb); blk_size = 8 >> get_bits1(&ctx->gb); mb_size = blk_size << !mb_size; blk_size_changed = mb_size != band->mb_size || blk_size != band->blk_size; if (blk_size_changed) { band->mb_size = mb_size; band->blk_size = blk_size; } if (get_bits1(&ctx->gb)) { av_log(avctx, AV_LOG_ERROR, "Extended transform info encountered!\n"); return -1; } /* select transform function and scan pattern according to plane and band number */ switch ((p << 2) + i) { case 0: band->inv_transform = ff_ivi_inverse_slant_8x8; band->dc_transform = ff_ivi_dc_slant_2d; band->scan = ff_zigzag_direct; break; case 1: band->inv_transform = ff_ivi_row_slant8; band->dc_transform = ff_ivi_dc_row_slant; band->scan = ff_ivi_vertical_scan_8x8; break; case 2: band->inv_transform = ff_ivi_col_slant8; band->dc_transform = ff_ivi_dc_col_slant; band->scan = ff_ivi_horizontal_scan_8x8; break; case 3: band->inv_transform = ff_ivi_put_pixels_8x8; band->dc_transform = ff_ivi_put_dc_pixel_8x8; band->scan = ff_ivi_horizontal_scan_8x8; break; case 4: band->inv_transform = ff_ivi_inverse_slant_4x4; band->dc_transform = ff_ivi_dc_slant_2d; band->scan = ff_ivi_direct_scan_4x4; break; } band->is_2d_trans = band->inv_transform == ff_ivi_inverse_slant_8x8 || band->inv_transform == ff_ivi_inverse_slant_4x4; /* select dequant matrix according to plane and band number */ if (!p) { quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0; } else { quant_mat = 5; } if (band->blk_size == 8) { band->intra_base = &ivi5_base_quant_8x8_intra[quant_mat][0]; band->inter_base = &ivi5_base_quant_8x8_inter[quant_mat][0]; band->intra_scale = &ivi5_scale_quant_8x8_intra[quant_mat][0]; band->inter_scale = &ivi5_scale_quant_8x8_inter[quant_mat][0]; } else { band->intra_base = ivi5_base_quant_4x4_intra; band->inter_base = ivi5_base_quant_4x4_inter; band->intra_scale = ivi5_scale_quant_4x4_intra; band->inter_scale = ivi5_scale_quant_4x4_inter; } if (get_bits(&ctx->gb, 2)) { av_log(avctx, AV_LOG_ERROR, "End marker missing!\n"); return -1; } } } /* copy chroma parameters into the 2nd chroma plane */ for (i = 0; i < pic_conf.chroma_bands; i++) { band1 = &ctx->planes[1].bands[i]; band2 = &ctx->planes[2].bands[i]; band2->width = band1->width; band2->height = band1->height; band2->mb_size = band1->mb_size; band2->blk_size = band1->blk_size; band2->is_halfpel = band1->is_halfpel; band2->intra_base = band1->intra_base; band2->inter_base = band1->inter_base; band2->intra_scale = band1->intra_scale; band2->inter_scale = band1->inter_scale; band2->scan = band1->scan; band2->inv_transform = band1->inv_transform; band2->dc_transform = band1->dc_transform; band2->is_2d_trans = band1->is_2d_trans; } /* reallocate internal structures if needed */ if (blk_size_changed) { result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width, pic_conf.tile_height); if (result) { av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate internal structures!\n"); return -1; } } if (ctx->gop_flags & 8) { if (get_bits(&ctx->gb, 3)) { av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n"); return -1; } if (get_bits1(&ctx->gb)) skip_bits_long(&ctx->gb, 24); /* skip transparency fill color */ } align_get_bits(&ctx->gb); skip_bits(&ctx->gb, 23); /* FIXME: unknown meaning */ /* skip GOP extension if any */ if (get_bits1(&ctx->gb)) { do { i = get_bits(&ctx->gb, 16); } while (i & 0x8000); } align_get_bits(&ctx->gb); return 0; }
true
FFmpeg
d46bc4133c104188dd6719365605e42bd1b5e2ff
7,127
static int build_huff(const uint8_t *src, VLC *vlc, int *fsym) { int i; HuffEntry he[256]; int last; uint32_t codes[256]; uint8_t bits[256]; uint8_t syms[256]; uint32_t code; *fsym = -1; for (i = 0; i < 256; i++) { he[i].sym = i; he[i].len = *src++; } qsort(he, 256, sizeof(*he), ff_ut_huff_cmp_len); if (!he[0].len) { *fsym = he[0].sym; return 0; } if (he[0].len > 32) return -1; last = 255; while (he[last].len == 255 && last) last--; code = 1; for (i = last; i >= 0; i--) { codes[i] = code >> (32 - he[i].len); bits[i] = he[i].len; syms[i] = he[i].sym; code += 0x80000000u >> (he[i].len - 1); } return ff_init_vlc_sparse(vlc, FFMIN(he[last].len, 11), last + 1, bits, sizeof(*bits), sizeof(*bits), codes, sizeof(*codes), sizeof(*codes), syms, sizeof(*syms), sizeof(*syms), 0); }
true
FFmpeg
48efe9ec86acf6dcf6aabef2114f8dd04e4fbce4
7,128
static int nist_read_header(AVFormatContext *s) { char buffer[32], coding[32] = "pcm", format[32] = "01"; int bps = 0, be = 0; int32_t header_size; AVStream *st; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; ff_get_line(s->pb, buffer, sizeof(buffer)); ff_get_line(s->pb, buffer, sizeof(buffer)); sscanf(buffer, "%"SCNd32, &header_size); if (header_size <= 0) return AVERROR_INVALIDDATA; while (!url_feof(s->pb)) { ff_get_line(s->pb, buffer, sizeof(buffer)); if (avio_tell(s->pb) >= header_size) return AVERROR_INVALIDDATA; if (!memcmp(buffer, "end_head", 8)) { if (!st->codec->bits_per_coded_sample) st->codec->bits_per_coded_sample = bps << 3; if (!av_strcasecmp(coding, "pcm")) { st->codec->codec_id = ff_get_pcm_codec_id(st->codec->bits_per_coded_sample, 0, be, 0xFFFF); } else if (!av_strcasecmp(coding, "alaw")) { st->codec->codec_id = AV_CODEC_ID_PCM_ALAW; } else if (!av_strcasecmp(coding, "ulaw") || !av_strcasecmp(coding, "mu-law")) { st->codec->codec_id = AV_CODEC_ID_PCM_MULAW; } else { avpriv_request_sample(s, "coding %s", coding); } avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); st->codec->block_align = st->codec->bits_per_coded_sample * st->codec->channels / 8; if (avio_tell(s->pb) > header_size) return AVERROR_INVALIDDATA; avio_skip(s->pb, header_size - avio_tell(s->pb)); return 0; } else if (!memcmp(buffer, "channel_count", 13)) { sscanf(buffer, "%*s %*s %"SCNd32, &st->codec->channels); } else if (!memcmp(buffer, "sample_byte_format", 18)) { sscanf(buffer, "%*s %*s %31s", format); if (!av_strcasecmp(format, "01")) { be = 0; } else if (!av_strcasecmp(format, "10")) { be = 1; } else if (av_strcasecmp(format, "1")) { avpriv_request_sample(s, "sample byte format %s", format); return AVERROR_PATCHWELCOME; } } else if (!memcmp(buffer, "sample_coding", 13)) { sscanf(buffer, "%*s %*s %31s", coding); } else if (!memcmp(buffer, "sample_count", 12)) { sscanf(buffer, "%*s %*s %"SCNd64, &st->duration); } else if (!memcmp(buffer, "sample_n_bytes", 14)) { sscanf(buffer, "%*s %*s %"SCNd32, &bps); } else if (!memcmp(buffer, "sample_rate", 11)) { sscanf(buffer, "%*s %*s %"SCNd32, &st->codec->sample_rate); } else if (!memcmp(buffer, "sample_sig_bits", 15)) { sscanf(buffer, "%*s %*s %"SCNd32, &st->codec->bits_per_coded_sample); } else { char key[32], value[32]; if (sscanf(buffer, "%31s %*s %31s", key, value) == 3) { av_dict_set(&s->metadata, key, value, AV_DICT_APPEND); } else { av_log(s, AV_LOG_ERROR, "Failed to parse '%s' as metadata\n", buffer); } } } return AVERROR_EOF; }
true
FFmpeg
632fdec9f4eb80dc8301cb938bce4b470fed0c11
7,129
static int pcm_read_header(AVFormatContext *s) { PCMAudioDemuxerContext *s1 = s->priv_data; AVStream *st; uint8_t *mime_type = NULL; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_id = s->iformat->raw_codec_id; st->codecpar->sample_rate = s1->sample_rate; st->codecpar->channels = s1->channels; av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type); if (mime_type && s->iformat->mime_type) { int rate = 0, channels = 0; size_t len = strlen(s->iformat->mime_type); if (!strncmp(s->iformat->mime_type, mime_type, len)) { uint8_t *options = mime_type + len; len = strlen(mime_type); while (options < mime_type + len) { options = strstr(options, ";"); if (!options++) break; if (!rate) sscanf(options, " rate=%d", &rate); if (!channels) sscanf(options, " channels=%d", &channels); } if (rate <= 0) { av_log(s, AV_LOG_ERROR, "Invalid sample_rate found in mime_type \"%s\"\n", mime_type); return AVERROR_INVALIDDATA; } st->codecpar->sample_rate = rate; if (channels > 0) st->codecpar->channels = channels; } } st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id); av_assert0(st->codecpar->bits_per_coded_sample > 0); st->codecpar->block_align = st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8; avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); return 0; }
true
FFmpeg
a5b5ce2658bf7506bb31f0b2b4cb44ddbf9a3955
7,131
static int amrnb_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AMRContext *p = avctx->priv_data; // pointer to private data const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; float *buf_out; // pointer to the output data buffer int i, subframe, ret; float fixed_gain_factor; AMRFixed fixed_sparse = {0}; // fixed vector up to anti-sparseness processing float spare_vector[AMR_SUBFRAME_SIZE]; // extra stack space to hold result from anti-sparseness processing float synth_fixed_gain; // the fixed gain that synthesis should use const float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use /* get output buffer */ p->avframe.nb_samples = AMR_BLOCK_SIZE; if ((ret = avctx->get_buffer(avctx, &p->avframe)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; buf_out = (float *)p->avframe.data[0]; p->cur_frame_mode = unpack_bitstream(p, buf, buf_size); if (p->cur_frame_mode == MODE_DTX) { av_log_missing_feature(avctx, "dtx mode", 1); return -1; if (p->cur_frame_mode == MODE_12k2) { lsf2lsp_5(p); } else lsf2lsp_3(p); for (i = 0; i < 4; i++) ff_acelp_lspd2lpc(p->lsp[i], p->lpc[i], 5); for (subframe = 0; subframe < 4; subframe++) { const AMRNBSubframe *amr_subframe = &p->frame.subframe[subframe]; decode_pitch_vector(p, amr_subframe, subframe); decode_fixed_sparse(&fixed_sparse, amr_subframe->pulses, p->cur_frame_mode, subframe); // The fixed gain (section 6.1.3) depends on the fixed vector // (section 6.1.2), but the fixed vector calculation uses // pitch sharpening based on the on the pitch gain (section 6.1.3). // So the correct order is: pitch gain, pitch sharpening, fixed gain. decode_gains(p, amr_subframe, p->cur_frame_mode, subframe, &fixed_gain_factor); pitch_sharpening(p, subframe, p->cur_frame_mode, &fixed_sparse); ff_set_fixed_vector(p->fixed_vector, &fixed_sparse, 1.0, AMR_SUBFRAME_SIZE); p->fixed_gain[4] = ff_amr_set_fixed_gain(fixed_gain_factor, ff_dot_productf(p->fixed_vector, p->fixed_vector, AMR_SUBFRAME_SIZE)/AMR_SUBFRAME_SIZE, p->prediction_error, energy_mean[p->cur_frame_mode], energy_pred_fac); // The excitation feedback is calculated without any processing such // as fixed gain smoothing. This isn't mentioned in the specification. for (i = 0; i < AMR_SUBFRAME_SIZE; i++) p->excitation[i] *= p->pitch_gain[4]; ff_set_fixed_vector(p->excitation, &fixed_sparse, p->fixed_gain[4], AMR_SUBFRAME_SIZE); // In the ref decoder, excitation is stored with no fractional bits. // This step prevents buzz in silent periods. The ref encoder can // emit long sequences with pitch factor greater than one. This // creates unwanted feedback if the excitation vector is nonzero. // (e.g. test sequence T19_795.COD in 3GPP TS 26.074) for (i = 0; i < AMR_SUBFRAME_SIZE; i++) p->excitation[i] = truncf(p->excitation[i]); // Smooth fixed gain. // The specification is ambiguous, but in the reference source, the // smoothed value is NOT fed back into later fixed gain smoothing. synth_fixed_gain = fixed_gain_smooth(p, p->lsf_q[subframe], p->lsf_avg, p->cur_frame_mode); synth_fixed_vector = anti_sparseness(p, &fixed_sparse, p->fixed_vector, synth_fixed_gain, spare_vector); if (synthesis(p, p->lpc[subframe], synth_fixed_gain, synth_fixed_vector, &p->samples_in[LP_FILTER_ORDER], 0)) // overflow detected -> rerun synthesis scaling pitch vector down // by a factor of 4, skipping pitch vector contribution emphasis // and adaptive gain control synthesis(p, p->lpc[subframe], synth_fixed_gain, synth_fixed_vector, &p->samples_in[LP_FILTER_ORDER], 1); postfilter(p, p->lpc[subframe], buf_out + subframe * AMR_SUBFRAME_SIZE); // update buffers and history ff_clear_fixed_vector(p->fixed_vector, &fixed_sparse, AMR_SUBFRAME_SIZE); update_state(p); ff_acelp_apply_order_2_transfer_function(buf_out, buf_out, highpass_zeros, highpass_poles, highpass_gain * AMR_SAMPLE_SCALE, p->high_pass_mem, AMR_BLOCK_SIZE); /* Update averaged lsf vector (used for fixed gain smoothing). * * Note that lsf_avg should not incorporate the current frame's LSFs * for fixed_gain_smooth. * The specification has an incorrect formula: the reference decoder uses * qbar(n-1) rather than qbar(n) in section 6.1(4) equation 71. */ ff_weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3], 0.84, 0.16, LP_FILTER_ORDER); *got_frame_ptr = 1; *(AVFrame *)data = p->avframe; /* return the amount of bytes consumed if everything was OK */ return frame_sizes_nb[p->cur_frame_mode] + 1; // +7 for rounding and +8 for TOC
true
FFmpeg
7f09791d28c82c9169d1612a6192851837341ca9
7,132
void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context) { bdrv_drain(bs); /* ensure there are no in-flight requests */ bdrv_detach_aio_context(bs); /* This function executes in the old AioContext so acquire the new one in * case it runs in a different thread. */ aio_context_acquire(new_context); bdrv_attach_aio_context(bs, new_context); aio_context_release(new_context);
true
qemu
c2b6428d388b3f03261be7b0be770919e4e3e5ec
7,133
static uint32_t fdctrl_read_data(FDCtrl *fdctrl) { FDrive *cur_drv; uint32_t retval = 0; int pos; cur_drv = get_cur_drv(fdctrl); fdctrl->dsr &= ~FD_DSR_PWRDOWN; if (!(fdctrl->msr & FD_MSR_RQM) || !(fdctrl->msr & FD_MSR_DIO)) { FLOPPY_DPRINTF("error: controller not ready for reading\n"); return 0; } pos = fdctrl->data_pos; if (fdctrl->msr & FD_MSR_NONDMA) { pos %= FD_SECTOR_LEN; if (pos == 0) { if (fdctrl->data_pos != 0) if (!fdctrl_seek_to_next_sect(fdctrl, cur_drv)) { FLOPPY_DPRINTF("error seeking to next sector %d\n", fd_sector(cur_drv)); return 0; } if (blk_read(cur_drv->blk, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) { FLOPPY_DPRINTF("error getting sector %d\n", fd_sector(cur_drv)); /* Sure, image size is too small... */ memset(fdctrl->fifo, 0, FD_SECTOR_LEN); } } } retval = fdctrl->fifo[pos]; if (++fdctrl->data_pos == fdctrl->data_len) { fdctrl->data_pos = 0; /* Switch from transfer mode to status mode * then from status mode to command mode */ if (fdctrl->msr & FD_MSR_NONDMA) { fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00); } else { fdctrl_reset_fifo(fdctrl); fdctrl_reset_irq(fdctrl); } } FLOPPY_DPRINTF("data register: 0x%02x\n", retval); return retval; }
true
qemu
e907746266721f305d67bc0718795fedee2e824c
7,134
static int decode_residuals(FLACContext *s, int channel, int pred_order) { int i, tmp, partition, method_type, rice_order; int sample = 0, samples; method_type = get_bits(&s->gb, 2); if (method_type != 0){ av_log(s->avctx, AV_LOG_DEBUG, "illegal residual coding method %d\n", method_type); rice_order = get_bits(&s->gb, 4); samples= s->blocksize >> rice_order; sample= i= pred_order; for (partition = 0; partition < (1 << rice_order); partition++) { tmp = get_bits(&s->gb, 4); if (tmp == 15) { av_log(s->avctx, AV_LOG_DEBUG, "fixed len partition\n"); tmp = get_bits(&s->gb, 5); for (; i < samples; i++, sample++) s->decoded[channel][sample] = get_sbits(&s->gb, tmp); else { // av_log(s->avctx, AV_LOG_DEBUG, "rice coded partition k=%d\n", tmp); for (; i < samples; i++, sample++){ s->decoded[channel][sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0); i= 0; // av_log(s->avctx, AV_LOG_DEBUG, "partitions: %d, samples: %d\n", 1 << rice_order, sample); return 0;
true
FFmpeg
5484dad7f6122a4d4dbc28e867a8c71d22ba2297
7,135
static void qemu_tcg_init_cpu_signals(void) { #ifdef CONFIG_IOTHREAD sigset_t set; struct sigaction sigact; memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = cpu_signal; sigaction(SIG_IPI, &sigact, NULL); sigemptyset(&set); sigaddset(&set, SIG_IPI); pthread_sigmask(SIG_UNBLOCK, &set, NULL); #endif }
true
qemu
12d4536f7d911b6d87a766ad7300482ea663cea2
7,136
static void test_aio_external_client(void) { int i, j; for (i = 1; i < 3; i++) { EventNotifierTestData data = { .n = 0, .active = 10, .auto_set = true }; event_notifier_init(&data.e, false); aio_set_event_notifier(ctx, &data.e, true, event_ready_cb); event_notifier_set(&data.e); for (j = 0; j < i; j++) { aio_disable_external(ctx); } for (j = 0; j < i; j++) { assert(!aio_poll(ctx, false)); assert(event_notifier_test_and_clear(&data.e)); event_notifier_set(&data.e); aio_enable_external(ctx); } assert(aio_poll(ctx, false)); event_notifier_cleanup(&data.e); } }
true
qemu
7595ed743914b9de1d146213dedc1e007283f723
7,137
static QemuConsole *new_console(DisplayState *ds, console_type_t console_type) { Error *local_err = NULL; Object *obj; QemuConsole *s; int i; if (nb_consoles >= MAX_CONSOLES) return NULL; obj = object_new(TYPE_QEMU_CONSOLE); s = QEMU_CONSOLE(obj); object_property_add_link(obj, "device", TYPE_DEVICE, (Object **)&s->device, object_property_allow_set_link, OBJ_PROP_LINK_UNREF_ON_RELEASE, &local_err); object_property_add_uint32_ptr(obj, "head", &s->head, &local_err); if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) && (console_type == GRAPHIC_CONSOLE))) { active_console = s; } s->ds = ds; s->console_type = console_type; if (console_type != GRAPHIC_CONSOLE) { s->index = nb_consoles; consoles[nb_consoles++] = s; } else { /* HACK: Put graphical consoles before text consoles. */ for (i = nb_consoles; i > 0; i--) { if (consoles[i - 1]->console_type == GRAPHIC_CONSOLE) break; consoles[i] = consoles[i - 1]; consoles[i]->index = i; } s->index = i; consoles[i] = s; nb_consoles++; } return s; }
true
qemu
afff2b15e89ac81c113f2ebfd729aaa02b40edb6
7,140
static void result_to_network(RDMARegisterResult *result) { result->rkey = htonl(result->rkey); result->host_addr = htonll(result->host_addr); };
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
7,141
static int nprobe(AVFormatContext *s, uint8_t *enc_header, int size, const uint8_t *n_val) { OMAContext *oc = s->priv_data; uint32_t pos, taglen, datalen; struct AVDES av_des; if (!enc_header || !n_val) return -1; pos = OMA_ENC_HEADER_SIZE + oc->k_size; if (!memcmp(&enc_header[pos], "EKB ", 4)) pos += 32; if (AV_RB32(&enc_header[pos]) != oc->rid) av_log(s, AV_LOG_DEBUG, "Mismatching RID\n"); taglen = AV_RB32(&enc_header[pos + 32]); datalen = AV_RB32(&enc_header[pos + 36]) >> 4; if (taglen + (((uint64_t)datalen) << 4) + 44 > size) return -1; pos += 44 + taglen; av_des_init(&av_des, n_val, 192, 1); while (datalen-- > 0) { av_des_crypt(&av_des, oc->r_val, &enc_header[pos], 2, NULL, 1); kset(s, oc->r_val, NULL, 16); if (!rprobe(s, enc_header, oc->r_val)) return 0; pos += 16; } return -1; }
true
FFmpeg
9d0b45ade864f3d2ccd8610149fe1fff53c4e937
7,142
static AVFrame *do_vmaf(AVFilterContext *ctx, AVFrame *main, const AVFrame *ref) { LIBVMAFContext *s = ctx->priv; pthread_mutex_lock(&s->lock); while (s->frame_set != 0) { pthread_cond_wait(&s->cond, &s->lock); } av_frame_ref(s->gref, ref); av_frame_ref(s->gmain, main); s->frame_set = 1; pthread_cond_signal(&s->cond); pthread_mutex_unlock(&s->lock); return main; }
true
FFmpeg
a8ab52fae7286d4e7eec9256a08b6ad0b1e39d6c
7,143
int ff_audio_interleave_init(AVFormatContext *s, const int *samples_per_frame, AVRational time_base) { int i; if (!samples_per_frame) return -1; if (!time_base.num) { av_log(s, AV_LOG_ERROR, "timebase not set for audio interleave\n"); return -1; } for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; AudioInterleaveContext *aic = st->priv_data; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { aic->sample_size = (st->codec->channels * av_get_bits_per_sample(st->codec->codec_id)) / 8; if (!aic->sample_size) { av_log(s, AV_LOG_ERROR, "could not compute sample size\n"); return -1; } aic->samples_per_frame = samples_per_frame; aic->samples = aic->samples_per_frame; aic->time_base = time_base; aic->fifo_size = 100* *aic->samples; aic->fifo= av_fifo_alloc_array(100, *aic->samples); } } return 0; }
true
FFmpeg
2ed9e17ed1793b3b66ed27c0a113676a46eb9871
7,144
static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, FsCred *credp) { char *path; int err = -1; int serrno = 0; V9fsString fullname; char *buffer = NULL; v9fs_string_init(&fullname); v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); path = fullname.data; /* Determine the security model */ if (fs_ctx->export_flags & V9FS_SM_MAPPED) { buffer = rpath(fs_ctx, path); err = mkdir(buffer, SM_LOCAL_DIR_MODE_BITS); if (err == -1) { goto out; } credp->fc_mode = credp->fc_mode|S_IFDIR; err = local_set_xattr(buffer, credp); if (err == -1) { serrno = errno; goto err_end; } } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { buffer = rpath(fs_ctx, path); err = mkdir(buffer, SM_LOCAL_DIR_MODE_BITS); if (err == -1) { goto out; } credp->fc_mode = credp->fc_mode|S_IFDIR; err = local_set_mapped_file_attr(fs_ctx, path, credp); if (err == -1) { serrno = errno; goto err_end; } } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { buffer = rpath(fs_ctx, path); err = mkdir(buffer, credp->fc_mode); if (err == -1) { goto out; } err = local_post_create_passthrough(fs_ctx, path, credp); if (err == -1) { serrno = errno; goto err_end; } } goto out; err_end: remove(buffer); errno = serrno; out: g_free(buffer); v9fs_string_free(&fullname); return err; }
true
qemu
3f3a16990b09e62d787bd2eb2dd51aafbe90019a
7,145
static void fd_revalidate(FDrive *drv) { int rc; FLOPPY_DPRINTF("revalidate\n"); if (drv->blk != NULL) { drv->ro = blk_is_read_only(drv->blk); if (!blk_is_inserted(drv->blk)) { FLOPPY_DPRINTF("No disk in drive\n"); drv->disk = FLOPPY_DRIVE_TYPE_NONE; } else if (!drv->media_validated) { rc = pick_geometry(drv); if (rc) { FLOPPY_DPRINTF("Could not validate floppy drive media"); } else { drv->media_validated = true; FLOPPY_DPRINTF("Floppy disk (%d h %d t %d s) %s\n", (drv->flags & FDISK_DBL_SIDES) ? 2 : 1, drv->max_track, drv->last_sect, drv->ro ? "ro" : "rw"); } } } else { FLOPPY_DPRINTF("No drive connected\n"); drv->last_sect = 0; drv->max_track = 0; drv->flags &= ~FDISK_DBL_SIDES; drv->drive = FLOPPY_DRIVE_TYPE_NONE; drv->disk = FLOPPY_DRIVE_TYPE_NONE; } }
true
qemu
fd9bdbd3459e5b9d51534f0747049bc5b6145e07
7,146
static coroutine_fn void reconnect_to_sdog(void *opaque) { Error *local_err = NULL; BDRVSheepdogState *s = opaque; AIOReq *aio_req, *next; aio_set_fd_handler(s->aio_context, s->fd, NULL, NULL, NULL); close(s->fd); s->fd = -1; /* Wait for outstanding write requests to be completed. */ while (s->co_send != NULL) { co_write_request(opaque); } /* Try to reconnect the sheepdog server every one second. */ while (s->fd < 0) { s->fd = get_sheep_fd(s, &local_err); if (s->fd < 0) { DPRINTF("Wait for connection to be established\n"); error_report("%s", error_get_pretty(local_err)); error_free(local_err); co_aio_sleep_ns(bdrv_get_aio_context(s->bs), QEMU_CLOCK_REALTIME, 1000000000ULL); } }; /* * Now we have to resend all the request in the inflight queue. However, * resend_aioreq() can yield and newly created requests can be added to the * inflight queue before the coroutine is resumed. To avoid mixing them, we * have to move all the inflight requests to the failed queue before * resend_aioreq() is called. */ QLIST_FOREACH_SAFE(aio_req, &s->inflight_aio_head, aio_siblings, next) { QLIST_REMOVE(aio_req, aio_siblings); QLIST_INSERT_HEAD(&s->failed_aio_head, aio_req, aio_siblings); } /* Resend all the failed aio requests. */ while (!QLIST_EMPTY(&s->failed_aio_head)) { aio_req = QLIST_FIRST(&s->failed_aio_head); QLIST_REMOVE(aio_req, aio_siblings); QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); resend_aioreq(s, aio_req); } }
true
qemu
a780dea0454d2820e31407c33f167acf00fe447d
7,147
static void set_frame_distances(MpegEncContext * s){ assert(s->current_picture_ptr->f.pts != AV_NOPTS_VALUE); s->time = s->current_picture_ptr->f.pts * s->avctx->time_base.num; if(s->pict_type==AV_PICTURE_TYPE_B){ s->pb_time= s->pp_time - (s->last_non_b_time - s->time); assert(s->pb_time > 0 && s->pb_time < s->pp_time); }else{ s->pp_time= s->time - s->last_non_b_time; s->last_non_b_time= s->time; assert(s->picture_number==0 || s->pp_time > 0); } }
true
FFmpeg
f6774f905fb3cfdc319523ac640be30b14c1bc55
7,148
static void load_tc(QEMUFile *f, TCState *tc) { int i; /* Save active TC */ for(i = 0; i < 32; i++) qemu_get_betls(f, &tc->gpr[i]); qemu_get_betls(f, &tc->PC); for(i = 0; i < MIPS_DSP_ACC; i++) qemu_get_betls(f, &tc->HI[i]); for(i = 0; i < MIPS_DSP_ACC; i++) qemu_get_betls(f, &tc->LO[i]); for(i = 0; i < MIPS_DSP_ACC; i++) qemu_get_betls(f, &tc->ACX[i]); qemu_get_betls(f, &tc->DSPControl); qemu_get_sbe32s(f, &tc->CP0_TCStatus); qemu_get_sbe32s(f, &tc->CP0_TCBind); qemu_get_betls(f, &tc->CP0_TCHalt); qemu_get_betls(f, &tc->CP0_TCContext); qemu_get_betls(f, &tc->CP0_TCSchedule); qemu_get_betls(f, &tc->CP0_TCScheFBack); qemu_get_sbe32s(f, &tc->CP0_Debug_tcstatus); }
true
qemu
d279279e2b5cd40dbcc863fb66a695990f304077
7,149
static inline void RENAME(rgb16to24)(const uint8_t *src, uint8_t *dst, long src_size) { const uint16_t *end; #ifdef HAVE_MMX const uint16_t *mm_end; #endif uint8_t *d = (uint8_t *)dst; const uint16_t *s = (const uint16_t *)src; end = s + src_size/2; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 7; while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movq %1, %%mm0\n\t" "movq %1, %%mm1\n\t" "movq %1, %%mm2\n\t" "pand %2, %%mm0\n\t" "pand %3, %%mm1\n\t" "pand %4, %%mm2\n\t" "psllq $3, %%mm0\n\t" "psrlq $3, %%mm1\n\t" "psrlq $8, %%mm2\n\t" "movq %%mm0, %%mm3\n\t" "movq %%mm1, %%mm4\n\t" "movq %%mm2, %%mm5\n\t" "punpcklwd %5, %%mm0\n\t" "punpcklwd %5, %%mm1\n\t" "punpcklwd %5, %%mm2\n\t" "punpckhwd %5, %%mm3\n\t" "punpckhwd %5, %%mm4\n\t" "punpckhwd %5, %%mm5\n\t" "psllq $8, %%mm1\n\t" "psllq $16, %%mm2\n\t" "por %%mm1, %%mm0\n\t" "por %%mm2, %%mm0\n\t" "psllq $8, %%mm4\n\t" "psllq $16, %%mm5\n\t" "por %%mm4, %%mm3\n\t" "por %%mm5, %%mm3\n\t" "movq %%mm0, %%mm6\n\t" "movq %%mm3, %%mm7\n\t" "movq 8%1, %%mm0\n\t" "movq 8%1, %%mm1\n\t" "movq 8%1, %%mm2\n\t" "pand %2, %%mm0\n\t" "pand %3, %%mm1\n\t" "pand %4, %%mm2\n\t" "psllq $3, %%mm0\n\t" "psrlq $3, %%mm1\n\t" "psrlq $8, %%mm2\n\t" "movq %%mm0, %%mm3\n\t" "movq %%mm1, %%mm4\n\t" "movq %%mm2, %%mm5\n\t" "punpcklwd %5, %%mm0\n\t" "punpcklwd %5, %%mm1\n\t" "punpcklwd %5, %%mm2\n\t" "punpckhwd %5, %%mm3\n\t" "punpckhwd %5, %%mm4\n\t" "punpckhwd %5, %%mm5\n\t" "psllq $8, %%mm1\n\t" "psllq $16, %%mm2\n\t" "por %%mm1, %%mm0\n\t" "por %%mm2, %%mm0\n\t" "psllq $8, %%mm4\n\t" "psllq $16, %%mm5\n\t" "por %%mm4, %%mm3\n\t" "por %%mm5, %%mm3\n\t" :"=m"(*d) :"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null) :"memory"); /* Borrowed 32 to 24 */ __asm __volatile( "movq %%mm0, %%mm4\n\t" "movq %%mm3, %%mm5\n\t" "movq %%mm6, %%mm0\n\t" "movq %%mm7, %%mm1\n\t" "movq %%mm4, %%mm6\n\t" "movq %%mm5, %%mm7\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm1, %%mm3\n\t" "psrlq $8, %%mm2\n\t" "psrlq $8, %%mm3\n\t" "psrlq $8, %%mm6\n\t" "psrlq $8, %%mm7\n\t" "pand %2, %%mm0\n\t" "pand %2, %%mm1\n\t" "pand %2, %%mm4\n\t" "pand %2, %%mm5\n\t" "pand %3, %%mm2\n\t" "pand %3, %%mm3\n\t" "pand %3, %%mm6\n\t" "pand %3, %%mm7\n\t" "por %%mm2, %%mm0\n\t" "por %%mm3, %%mm1\n\t" "por %%mm6, %%mm4\n\t" "por %%mm7, %%mm5\n\t" "movq %%mm1, %%mm2\n\t" "movq %%mm4, %%mm3\n\t" "psllq $48, %%mm2\n\t" "psllq $32, %%mm3\n\t" "pand %4, %%mm2\n\t" "pand %5, %%mm3\n\t" "por %%mm2, %%mm0\n\t" "psrlq $16, %%mm1\n\t" "psrlq $32, %%mm4\n\t" "psllq $16, %%mm5\n\t" "por %%mm3, %%mm1\n\t" "pand %6, %%mm5\n\t" "por %%mm5, %%mm4\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm1, 8%0\n\t" MOVNTQ" %%mm4, 16%0" :"=m"(*d) :"m"(*s),"m"(mask24l),"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh) :"memory"); d += 24; s += 8; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { register uint16_t bgr; bgr = *s++; *d++ = (bgr&0x1F)<<3; *d++ = (bgr&0x7E0)>>3; *d++ = (bgr&0xF800)>>8; } }
true
FFmpeg
6e42e6c4b410dbef8b593c2d796a5dad95f89ee4
7,151
int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps) { HEVCSPS *sps = NULL; int i, ret = 0; unsigned int pps_id = 0; ptrdiff_t nal_size; AVBufferRef *pps_buf; HEVCPPS *pps = av_mallocz(sizeof(*pps)); if (!pps) return AVERROR(ENOMEM); pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps), hevc_pps_free, NULL, 0); if (!pps_buf) { av_freep(&pps); return AVERROR(ENOMEM); } av_log(avctx, AV_LOG_DEBUG, "Decoding PPS\n"); nal_size = gb->buffer_end - gb->buffer; if (nal_size > sizeof(pps->data)) { av_log(avctx, AV_LOG_WARNING, "Truncating likely oversized PPS " "(%"PTRDIFF_SPECIFIER" > %"SIZE_SPECIFIER")\n", nal_size, sizeof(pps->data)); pps->data_size = sizeof(pps->data); } else { pps->data_size = nal_size; } memcpy(pps->data, gb->buffer, pps->data_size); // Default values pps->loop_filter_across_tiles_enabled_flag = 1; pps->num_tile_columns = 1; pps->num_tile_rows = 1; pps->uniform_spacing_flag = 1; pps->disable_dbf = 0; pps->beta_offset = 0; pps->tc_offset = 0; pps->log2_max_transform_skip_block_size = 2; // Coded parameters pps_id = get_ue_golomb_long(gb); if (pps_id >= HEVC_MAX_PPS_COUNT) { av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); ret = AVERROR_INVALIDDATA; goto err; } pps->sps_id = get_ue_golomb_long(gb); if (pps->sps_id >= HEVC_MAX_SPS_COUNT) { av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id); ret = AVERROR_INVALIDDATA; goto err; } if (!ps->sps_list[pps->sps_id]) { av_log(avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id); ret = AVERROR_INVALIDDATA; goto err; } sps = (HEVCSPS *)ps->sps_list[pps->sps_id]->data; pps->dependent_slice_segments_enabled_flag = get_bits1(gb); pps->output_flag_present_flag = get_bits1(gb); pps->num_extra_slice_header_bits = get_bits(gb, 3); pps->sign_data_hiding_flag = get_bits1(gb); pps->cabac_init_present_flag = get_bits1(gb); pps->num_ref_idx_l0_default_active = get_ue_golomb_long(gb) + 1; pps->num_ref_idx_l1_default_active = get_ue_golomb_long(gb) + 1; pps->pic_init_qp_minus26 = get_se_golomb(gb); pps->constrained_intra_pred_flag = get_bits1(gb); pps->transform_skip_enabled_flag = get_bits1(gb); pps->cu_qp_delta_enabled_flag = get_bits1(gb); pps->diff_cu_qp_delta_depth = 0; if (pps->cu_qp_delta_enabled_flag) pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb); if (pps->diff_cu_qp_delta_depth < 0 || pps->diff_cu_qp_delta_depth > sps->log2_diff_max_min_coding_block_size) { av_log(avctx, AV_LOG_ERROR, "diff_cu_qp_delta_depth %d is invalid\n", pps->diff_cu_qp_delta_depth); ret = AVERROR_INVALIDDATA; goto err; } pps->cb_qp_offset = get_se_golomb(gb); if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) { av_log(avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n", pps->cb_qp_offset); ret = AVERROR_INVALIDDATA; goto err; } pps->cr_qp_offset = get_se_golomb(gb); if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) { av_log(avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n", pps->cr_qp_offset); ret = AVERROR_INVALIDDATA; goto err; } pps->pic_slice_level_chroma_qp_offsets_present_flag = get_bits1(gb); pps->weighted_pred_flag = get_bits1(gb); pps->weighted_bipred_flag = get_bits1(gb); pps->transquant_bypass_enable_flag = get_bits1(gb); pps->tiles_enabled_flag = get_bits1(gb); pps->entropy_coding_sync_enabled_flag = get_bits1(gb); if (pps->tiles_enabled_flag) { pps->num_tile_columns = get_ue_golomb_long(gb) + 1; pps->num_tile_rows = get_ue_golomb_long(gb) + 1; if (pps->num_tile_columns <= 0 || pps->num_tile_columns >= sps->width) { av_log(avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n", pps->num_tile_columns - 1); ret = AVERROR_INVALIDDATA; goto err; } if (pps->num_tile_rows <= 0 || pps->num_tile_rows >= sps->height) { av_log(avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n", pps->num_tile_rows - 1); ret = AVERROR_INVALIDDATA; goto err; } pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width)); pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height)); if (!pps->column_width || !pps->row_height) { ret = AVERROR(ENOMEM); goto err; } pps->uniform_spacing_flag = get_bits1(gb); if (!pps->uniform_spacing_flag) { uint64_t sum = 0; for (i = 0; i < pps->num_tile_columns - 1; i++) { pps->column_width[i] = get_ue_golomb_long(gb) + 1; sum += pps->column_width[i]; } if (sum >= sps->ctb_width) { av_log(avctx, AV_LOG_ERROR, "Invalid tile widths.\n"); ret = AVERROR_INVALIDDATA; goto err; } pps->column_width[pps->num_tile_columns - 1] = sps->ctb_width - sum; sum = 0; for (i = 0; i < pps->num_tile_rows - 1; i++) { pps->row_height[i] = get_ue_golomb_long(gb) + 1; sum += pps->row_height[i]; } if (sum >= sps->ctb_height) { av_log(avctx, AV_LOG_ERROR, "Invalid tile heights.\n"); ret = AVERROR_INVALIDDATA; goto err; } pps->row_height[pps->num_tile_rows - 1] = sps->ctb_height - sum; } pps->loop_filter_across_tiles_enabled_flag = get_bits1(gb); } pps->seq_loop_filter_across_slices_enabled_flag = get_bits1(gb); pps->deblocking_filter_control_present_flag = get_bits1(gb); if (pps->deblocking_filter_control_present_flag) { pps->deblocking_filter_override_enabled_flag = get_bits1(gb); pps->disable_dbf = get_bits1(gb); if (!pps->disable_dbf) { int beta_offset_div2 = get_se_golomb(gb); int tc_offset_div2 = get_se_golomb(gb) ; if (beta_offset_div2 < -6 || beta_offset_div2 > 6) { av_log(avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n", beta_offset_div2); ret = AVERROR_INVALIDDATA; goto err; } if (tc_offset_div2 < -6 || tc_offset_div2 > 6) { av_log(avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n", tc_offset_div2); ret = AVERROR_INVALIDDATA; goto err; } pps->beta_offset = 2 * beta_offset_div2; pps->tc_offset = 2 * tc_offset_div2; } } pps->scaling_list_data_present_flag = get_bits1(gb); if (pps->scaling_list_data_present_flag) { set_default_scaling_list_data(&pps->scaling_list); ret = scaling_list_data(gb, avctx, &pps->scaling_list, sps); if (ret < 0) goto err; } pps->lists_modification_present_flag = get_bits1(gb); pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2; if (pps->log2_parallel_merge_level > sps->log2_ctb_size) { av_log(avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n", pps->log2_parallel_merge_level - 2); ret = AVERROR_INVALIDDATA; goto err; } pps->slice_header_extension_present_flag = get_bits1(gb); if (get_bits1(gb)) { // pps_extension_present_flag int pps_range_extensions_flag = get_bits1(gb); /* int pps_extension_7bits = */ get_bits(gb, 7); if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && pps_range_extensions_flag) { if ((ret = pps_range_extensions(gb, avctx, pps, sps)) < 0) goto err; } } ret = setup_pps(avctx, gb, pps, sps); if (ret < 0) goto err; if (get_bits_left(gb) < 0) { av_log(avctx, AV_LOG_ERROR, "Overread PPS by %d bits\n", -get_bits_left(gb)); goto err; } remove_pps(ps, pps_id); ps->pps_list[pps_id] = pps_buf; return 0; err: av_buffer_unref(&pps_buf); return ret; }
true
FFmpeg
74c1c22d7f0d25f527ed2ebf62493be5ad52c972
7,153
static inline int onenand_erase(OneNANDState *s, int sec, int num) { uint8_t *blankbuf, *tmpbuf; blankbuf = g_malloc(512); tmpbuf = g_malloc(512); memset(blankbuf, 0xff, 512); for (; num > 0; num--, sec++) { if (s->blk_cur) { int erasesec = s->secs_cur + (sec >> 5); if (blk_write(s->blk_cur, sec, blankbuf, 1) < 0) { goto fail; } if (blk_read(s->blk_cur, erasesec, tmpbuf, 1) < 0) { goto fail; } memcpy(tmpbuf + ((sec & 31) << 4), blankbuf, 1 << 4); if (blk_write(s->blk_cur, erasesec, tmpbuf, 1) < 0) { goto fail; } } else { if (sec + 1 > s->secs_cur) { goto fail; } memcpy(s->current + (sec << 9), blankbuf, 512); memcpy(s->current + (s->secs_cur << 9) + (sec << 4), blankbuf, 1 << 4); } } g_free(tmpbuf); g_free(blankbuf); return 0; fail: g_free(tmpbuf); g_free(blankbuf); return 1; }
true
qemu
441692ddd8321d5e0f09b163e86410e578d87236
7,154
static av_cold int cinepak_encode_init(AVCodecContext *avctx) { CinepakEncContext *s = avctx->priv_data; int x, mb_count, strip_buf_size, frame_buf_size; if (avctx->width & 3 || avctx->height & 3) { av_log(avctx, AV_LOG_ERROR, "width and height must be multiples of four (got %ix%i)\n", avctx->width, avctx->height); return AVERROR(EINVAL); } if (!(s->codebook_input = av_malloc(sizeof(int) * (avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4) * (avctx->width * avctx->height) >> 2))) return AVERROR(ENOMEM); if (!(s->codebook_closest = av_malloc(sizeof(int) * (avctx->width * avctx->height) >> 2))) goto enomem; for(x = 0; x < 3; x++) if(!(s->pict_bufs[x] = av_malloc((avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4) * (avctx->width * avctx->height) >> 2))) goto enomem; mb_count = avctx->width * avctx->height / MB_AREA; //the largest possible chunk is 0x31 with all MBs encoded in V4 mode, which is 34 bits per MB strip_buf_size = STRIP_HEADER_SIZE + 3 * CHUNK_HEADER_SIZE + 2 * VECTOR_MAX * CODEBOOK_MAX + 4 * (mb_count + (mb_count + 15) / 16); frame_buf_size = CVID_HEADER_SIZE + MAX_STRIPS * strip_buf_size; if (!(s->strip_buf = av_malloc(strip_buf_size))) goto enomem; if (!(s->frame_buf = av_malloc(frame_buf_size))) goto enomem; if (!(s->mb = av_malloc(mb_count*sizeof(mb_info)))) goto enomem; #ifdef CINEPAKENC_DEBUG if (!(s->best_mb = av_malloc(mb_count*sizeof(mb_info)))) goto enomem; #endif av_lfg_init(&s->randctx, 1); s->avctx = avctx; s->w = avctx->width; s->h = avctx->height; s->curframe = 0; s->keyint = avctx->keyint_min; s->pix_fmt = avctx->pix_fmt; //set up AVFrames s->last_frame.data[0] = s->pict_bufs[0]; s->last_frame.linesize[0] = s->w; s->best_frame.data[0] = s->pict_bufs[1]; s->best_frame.linesize[0] = s->w; s->scratch_frame.data[0] = s->pict_bufs[2]; s->scratch_frame.linesize[0] = s->w; if(s->pix_fmt == AV_PIX_FMT_YUV420P) { s->last_frame.data[1] = s->last_frame.data[0] + s->w * s->h; s->last_frame.data[2] = s->last_frame.data[1] + ((s->w * s->h) >> 2); s->last_frame.linesize[1] = s->last_frame.linesize[2] = s->w >> 1; s->best_frame.data[1] = s->best_frame.data[0] + s->w * s->h; s->best_frame.data[2] = s->best_frame.data[1] + ((s->w * s->h) >> 2); s->best_frame.linesize[1] = s->best_frame.linesize[2] = s->w >> 1; s->scratch_frame.data[1] = s->scratch_frame.data[0] + s->w * s->h; s->scratch_frame.data[2] = s->scratch_frame.data[1] + ((s->w * s->h) >> 2); s->scratch_frame.linesize[1] = s->scratch_frame.linesize[2] = s->w >> 1; } s->num_v1_mode = s->num_v4_mode = s->num_mc_mode = s->num_v1_encs = s->num_v4_encs = s->num_skips = 0; return 0; enomem: av_free(s->codebook_input); av_free(s->codebook_closest); av_free(s->strip_buf); av_free(s->frame_buf); av_free(s->mb); #ifdef CINEPAKENC_DEBUG av_free(s->best_mb); #endif for(x = 0; x < 3; x++) av_free(s->pict_bufs[x]); return AVERROR(ENOMEM); }
true
FFmpeg
7da9f4523159670d577a2808d4481e64008a8894
7,155
static int count_contiguous_clusters(int nb_clusters, int cluster_size, uint64_t *l2_table, uint64_t stop_flags) { int i; uint64_t mask = stop_flags | L2E_OFFSET_MASK | QCOW_OFLAG_COMPRESSED; uint64_t first_entry = be64_to_cpu(l2_table[0]); uint64_t offset = first_entry & mask; if (!offset) return 0; assert(qcow2_get_cluster_type(first_entry) != QCOW2_CLUSTER_COMPRESSED); for (i = 0; i < nb_clusters; i++) { uint64_t l2_entry = be64_to_cpu(l2_table[i]) & mask; if (offset + (uint64_t) i * cluster_size != l2_entry) { break; } } return i; }
true
qemu
a99dfb45f26bface6830ee5465e57bcdbc53c6c8
7,156
static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon, const char *devaddr, const char *opts_str) { Error *local_err = NULL; QemuOpts *opts; PCIBus *root = pci_find_primary_bus(); PCIBus *bus; int ret, devfn; if (!root) { monitor_printf(mon, "no primary PCI bus (if there are multiple" " PCI roots, you must use device_add instead)"); return NULL; } bus = pci_get_bus_devfn(&devfn, root, devaddr); if (!bus) { monitor_printf(mon, "Invalid PCI device address %s\n", devaddr); return NULL; } if (!qbus_is_hotpluggable(BUS(bus))) { monitor_printf(mon, "PCI bus doesn't support hotplug\n"); return NULL; } opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0); if (!opts) { return NULL; } qemu_opt_set(opts, "type", "nic"); ret = net_client_init(opts, 0, &local_err); if (local_err) { qerror_report_err(local_err); error_free(local_err); return NULL; } if (nd_table[ret].devaddr) { monitor_printf(mon, "Parameter addr not supported\n"); return NULL; } return pci_nic_init(&nd_table[ret], root, "rtl8139", devaddr); }
true
qemu
f51074cdc6e750daa3b6df727d83449a7e42b391
7,158
void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp) { MigrationState *s = opaque; Error *local_err = NULL, **temp = &local_err; RDMAContext *rdma = qemu_rdma_data_init(host_port, &local_err); int ret = 0; if (rdma == NULL) { ERROR(temp, "Failed to initialize RDMA data structures! %d", ret); goto err; } ret = qemu_rdma_source_init(rdma, &local_err, s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL]); if (ret) { goto err; } trace_rdma_start_outgoing_migration_after_rdma_source_init(); ret = qemu_rdma_connect(rdma, &local_err); if (ret) { goto err; } trace_rdma_start_outgoing_migration_after_rdma_connect(); s->to_dst_file = qemu_fopen_rdma(rdma, "wb"); migrate_fd_connect(s); return; err: error_propagate(errp, local_err); g_free(rdma); migrate_fd_error(s); }
true
qemu
d59ce6f34434bf47a9b26138c908650bf9a24be1
7,159
grlib_irqmp_writel(void *opaque, target_phys_addr_t addr, uint32_t value) { IRQMP *irqmp = opaque; IRQMPState *state; assert(irqmp != NULL); state = irqmp->state; assert(state != NULL); addr &= 0xff; /* global registers */ switch (addr) { case LEVEL_OFFSET: value &= 0xFFFF << 1; /* clean up the value */ state->level = value; return; case PENDING_OFFSET: /* Read Only */ return; case FORCE0_OFFSET: /* This register is an "alias" for the force register of CPU 0 */ value &= 0xFFFE; /* clean up the value */ state->force[0] = value; grlib_irqmp_check_irqs(irqmp->state); return; case CLEAR_OFFSET: value &= ~1; /* clean up the value */ state->pending &= ~value; return; case MP_STATUS_OFFSET: /* Read Only (no SMP support) */ return; case BROADCAST_OFFSET: value &= 0xFFFE; /* clean up the value */ state->broadcast = value; return; default: break; } /* mask registers */ if (addr >= MASK_OFFSET && addr < FORCE_OFFSET) { int cpu = (addr - MASK_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); value &= ~1; /* clean up the value */ state->mask[cpu] = value; grlib_irqmp_check_irqs(irqmp->state); return; } /* force registers */ if (addr >= FORCE_OFFSET && addr < EXTENDED_OFFSET) { int cpu = (addr - FORCE_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); uint32_t force = value & 0xFFFE; uint32_t clear = (value >> 16) & 0xFFFE; uint32_t old = state->force[cpu]; state->force[cpu] = (old | force) & ~clear; grlib_irqmp_check_irqs(irqmp->state); return; } /* extended (not supported) */ if (addr >= EXTENDED_OFFSET && addr < IRQMP_REG_SIZE) { int cpu = (addr - EXTENDED_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); value &= 0xF; /* clean up the value */ state->extended[cpu] = value; return; } trace_grlib_irqmp_unknown_register("write", addr); }
true
qemu
b4548fcc0314f5e118ed45b5774e9cd99f9a97d3
7,160
static void qvirtio_pci_queue_select(QVirtioDevice *d, uint16_t index) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; qpci_io_writeb(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_SEL, index); }
true
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
7,161
static int cbr_bit_allocation(AC3EncodeContext *s) { int ch; int bits_left; int snr_offset, snr_incr; bits_left = 8 * s->frame_size - (s->frame_bits + s->exponent_bits); snr_offset = s->coarse_snr_offset << 4; while (snr_offset >= 0 && bit_alloc(s, snr_offset) > bits_left) { snr_offset -= 64; } if (snr_offset < 0) return AVERROR(EINVAL); FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer); for (snr_incr = 64; snr_incr > 0; snr_incr >>= 2) { while (snr_offset + 64 <= 1023 && bit_alloc(s, snr_offset + snr_incr) <= bits_left) { snr_offset += snr_incr; FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer); } } FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer); reset_block_bap(s); s->coarse_snr_offset = snr_offset >> 4; for (ch = 0; ch < s->channels; ch++) s->fine_snr_offset[ch] = snr_offset & 0xF; return 0; }
false
FFmpeg
5128842ea2057c86550b833c9141c271df1bdc94
7,162
static int apng_encode_frame(AVCodecContext *avctx, const AVFrame *pict, APNGFctlChunk *best_fctl_chunk, APNGFctlChunk *best_last_fctl_chunk) { PNGEncContext *s = avctx->priv_data; int ret; unsigned int y; AVFrame* diffFrame; uint8_t bpp = (s->bits_per_pixel + 7) >> 3; uint8_t *original_bytestream, *original_bytestream_end; uint8_t *temp_bytestream = 0, *temp_bytestream_end; uint32_t best_sequence_number; uint8_t *best_bytestream; size_t best_bytestream_size = SIZE_MAX; APNGFctlChunk last_fctl_chunk = *best_last_fctl_chunk; APNGFctlChunk fctl_chunk = *best_fctl_chunk; if (avctx->frame_number == 0) { best_fctl_chunk->width = pict->width; best_fctl_chunk->height = pict->height; best_fctl_chunk->x_offset = 0; best_fctl_chunk->y_offset = 0; best_fctl_chunk->blend_op = APNG_BLEND_OP_SOURCE; return encode_frame(avctx, pict); } diffFrame = av_frame_alloc(); if (!diffFrame) return AVERROR(ENOMEM); diffFrame->format = pict->format; diffFrame->width = pict->width; diffFrame->height = pict->height; if ((ret = av_frame_get_buffer(diffFrame, 32)) < 0) goto fail; original_bytestream = s->bytestream; original_bytestream_end = s->bytestream_end; temp_bytestream = av_malloc(original_bytestream_end - original_bytestream); temp_bytestream_end = temp_bytestream + (original_bytestream_end - original_bytestream); if (!temp_bytestream) { ret = AVERROR(ENOMEM); goto fail; } for (last_fctl_chunk.dispose_op = 0; last_fctl_chunk.dispose_op < 3; ++last_fctl_chunk.dispose_op) { // 0: APNG_DISPOSE_OP_NONE // 1: APNG_DISPOSE_OP_BACKGROUND // 2: APNG_DISPOSE_OP_PREVIOUS for (fctl_chunk.blend_op = 0; fctl_chunk.blend_op < 2; ++fctl_chunk.blend_op) { // 0: APNG_BLEND_OP_SOURCE // 1: APNG_BLEND_OP_OVER uint32_t original_sequence_number = s->sequence_number, sequence_number; uint8_t *bytestream_start = s->bytestream; size_t bytestream_size; // Do disposal if (last_fctl_chunk.dispose_op != APNG_DISPOSE_OP_PREVIOUS) { diffFrame->width = pict->width; diffFrame->height = pict->height; av_frame_copy(diffFrame, s->last_frame); if (last_fctl_chunk.dispose_op == APNG_DISPOSE_OP_BACKGROUND) { for (y = last_fctl_chunk.y_offset; y < last_fctl_chunk.y_offset + last_fctl_chunk.height; ++y) { size_t row_start = diffFrame->linesize[0] * y + bpp * last_fctl_chunk.x_offset; memset(diffFrame->data[0] + row_start, 0, bpp * last_fctl_chunk.width); } } } else { if (!s->prev_frame) continue; diffFrame->width = pict->width; diffFrame->height = pict->height; av_frame_copy(diffFrame, s->prev_frame); } // Do inverse blending if (apng_do_inverse_blend(diffFrame, pict, &fctl_chunk, bpp) < 0) continue; // Do encoding ret = encode_frame(avctx, diffFrame); sequence_number = s->sequence_number; s->sequence_number = original_sequence_number; bytestream_size = s->bytestream - bytestream_start; s->bytestream = bytestream_start; if (ret < 0) goto fail; if (bytestream_size < best_bytestream_size) { *best_fctl_chunk = fctl_chunk; *best_last_fctl_chunk = last_fctl_chunk; best_sequence_number = sequence_number; best_bytestream = s->bytestream; best_bytestream_size = bytestream_size; if (best_bytestream == original_bytestream) { s->bytestream = temp_bytestream; s->bytestream_end = temp_bytestream_end; } else { s->bytestream = original_bytestream; s->bytestream_end = original_bytestream_end; } } } } s->sequence_number = best_sequence_number; s->bytestream = original_bytestream + best_bytestream_size; s->bytestream_end = original_bytestream_end; if (best_bytestream != original_bytestream) memcpy(original_bytestream, best_bytestream, best_bytestream_size); ret = 0; fail: av_freep(&temp_bytestream); av_frame_free(&diffFrame); return ret; }
false
FFmpeg
1490682bcb0fe359e05b85bb7198bb87be686054
7,163
static inline void transpose4x4(uint8_t *dst, uint8_t *src, x86_reg dst_stride, x86_reg src_stride){ __asm__ volatile( //FIXME could save 1 instruction if done as 8x4 ... "movd (%1), %%mm0 \n\t" "add %3, %1 \n\t" "movd (%1), %%mm1 \n\t" "movd (%1,%3,1), %%mm2 \n\t" "movd (%1,%3,2), %%mm3 \n\t" "punpcklbw %%mm1, %%mm0 \n\t" "punpcklbw %%mm3, %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "punpcklwd %%mm2, %%mm0 \n\t" "punpckhwd %%mm2, %%mm1 \n\t" "movd %%mm0, (%0) \n\t" "add %2, %0 \n\t" "punpckhdq %%mm0, %%mm0 \n\t" "movd %%mm0, (%0) \n\t" "movd %%mm1, (%0,%2,1) \n\t" "punpckhdq %%mm1, %%mm1 \n\t" "movd %%mm1, (%0,%2,2) \n\t" : "+&r" (dst), "+&r" (src) : "r" (dst_stride), "r" (src_stride) : "memory" ); }
false
FFmpeg
659d4ba5af5d72716ee370bb367c741bd15e75b4
7,165
uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign) { uint64_t ret = 0; #if defined(DEBUG_ASI) target_ulong last_addr = addr; #endif asi &= 0xff; if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) || ((env->def->features & CPU_FEATURE_HYPV) && asi >= 0x30 && asi < 0x80 && !(env->hpstate & HS_PRIV))) raise_exception(TT_PRIV_ACT); helper_check_align(addr, size - 1); switch (asi) { case 0x82: // Primary no-fault case 0x8a: // Primary no-fault LE case 0x83: // Secondary no-fault case 0x8b: // Secondary no-fault LE { /* secondary space access has lowest asi bit equal to 1 */ int access_mmu_idx = ( asi & 1 ) ? MMU_KERNEL_IDX : MMU_KERNEL_SECONDARY_IDX; if (cpu_get_phys_page_nofault(env, addr, access_mmu_idx) == -1ULL) { #ifdef DEBUG_ASI dump_asi("read ", last_addr, asi, size, ret); #endif return 0; } } // Fall through case 0x10: // As if user primary case 0x11: // As if user secondary case 0x18: // As if user primary LE case 0x19: // As if user secondary LE case 0x80: // Primary case 0x81: // Secondary case 0x88: // Primary LE case 0x89: // Secondary LE case 0xe2: // UA2007 Primary block init case 0xe3: // UA2007 Secondary block init if ((asi & 0x80) && (env->pstate & PS_PRIV)) { if ((env->def->features & CPU_FEATURE_HYPV) && env->hpstate & HS_PRIV) { switch(size) { case 1: ret = ldub_hypv(addr); break; case 2: ret = lduw_hypv(addr); break; case 4: ret = ldl_hypv(addr); break; default: case 8: ret = ldq_hypv(addr); break; } } else { /* secondary space access has lowest asi bit equal to 1 */ if (asi & 1) { switch(size) { case 1: ret = ldub_kernel_secondary(addr); break; case 2: ret = lduw_kernel_secondary(addr); break; case 4: ret = ldl_kernel_secondary(addr); break; default: case 8: ret = ldq_kernel_secondary(addr); break; } } else { switch(size) { case 1: ret = ldub_kernel(addr); break; case 2: ret = lduw_kernel(addr); break; case 4: ret = ldl_kernel(addr); break; default: case 8: ret = ldq_kernel(addr); break; } } } } else { /* secondary space access has lowest asi bit equal to 1 */ if (asi & 1) { switch(size) { case 1: ret = ldub_user_secondary(addr); break; case 2: ret = lduw_user_secondary(addr); break; case 4: ret = ldl_user_secondary(addr); break; default: case 8: ret = ldq_user_secondary(addr); break; } } else { switch(size) { case 1: ret = ldub_user(addr); break; case 2: ret = lduw_user(addr); break; case 4: ret = ldl_user(addr); break; default: case 8: ret = ldq_user(addr); break; } } } break; case 0x14: // Bypass case 0x15: // Bypass, non-cacheable case 0x1c: // Bypass LE case 0x1d: // Bypass, non-cacheable LE { switch(size) { case 1: ret = ldub_phys(addr); break; case 2: ret = lduw_phys(addr); break; case 4: ret = ldl_phys(addr); break; default: case 8: ret = ldq_phys(addr); break; } break; } case 0x24: // Nucleus quad LDD 128 bit atomic case 0x2c: // Nucleus quad LDD 128 bit atomic LE // Only ldda allowed raise_exception(TT_ILL_INSN); return 0; case 0x04: // Nucleus case 0x0c: // Nucleus Little Endian (LE) { switch(size) { case 1: ret = ldub_nucleus(addr); break; case 2: ret = lduw_nucleus(addr); break; case 4: ret = ldl_nucleus(addr); break; default: case 8: ret = ldq_nucleus(addr); break; } break; } case 0x4a: // UPA config // XXX break; case 0x45: // LSU ret = env->lsu; break; case 0x50: // I-MMU regs { int reg = (addr >> 3) & 0xf; if (reg == 0) { // I-TSB Tag Target register ret = ultrasparc_tag_target(env->immu.tag_access); } else { ret = env->immuregs[reg]; } break; } case 0x51: // I-MMU 8k TSB pointer { // env->immuregs[5] holds I-MMU TSB register value // env->immuregs[6] holds I-MMU Tag Access register value ret = ultrasparc_tsb_pointer(env->immu.tsb, env->immu.tag_access, 8*1024); break; } case 0x52: // I-MMU 64k TSB pointer { // env->immuregs[5] holds I-MMU TSB register value // env->immuregs[6] holds I-MMU Tag Access register value ret = ultrasparc_tsb_pointer(env->immu.tsb, env->immu.tag_access, 64*1024); break; } case 0x55: // I-MMU data access { int reg = (addr >> 3) & 0x3f; ret = env->itlb[reg].tte; break; } case 0x56: // I-MMU tag read { int reg = (addr >> 3) & 0x3f; ret = env->itlb[reg].tag; break; } case 0x58: // D-MMU regs { int reg = (addr >> 3) & 0xf; if (reg == 0) { // D-TSB Tag Target register ret = ultrasparc_tag_target(env->dmmu.tag_access); } else { ret = env->dmmuregs[reg]; } break; } case 0x59: // D-MMU 8k TSB pointer { // env->dmmuregs[5] holds D-MMU TSB register value // env->dmmuregs[6] holds D-MMU Tag Access register value ret = ultrasparc_tsb_pointer(env->dmmu.tsb, env->dmmu.tag_access, 8*1024); break; } case 0x5a: // D-MMU 64k TSB pointer { // env->dmmuregs[5] holds D-MMU TSB register value // env->dmmuregs[6] holds D-MMU Tag Access register value ret = ultrasparc_tsb_pointer(env->dmmu.tsb, env->dmmu.tag_access, 64*1024); break; } case 0x5d: // D-MMU data access { int reg = (addr >> 3) & 0x3f; ret = env->dtlb[reg].tte; break; } case 0x5e: // D-MMU tag read { int reg = (addr >> 3) & 0x3f; ret = env->dtlb[reg].tag; break; } case 0x46: // D-cache data case 0x47: // D-cache tag access case 0x4b: // E-cache error enable case 0x4c: // E-cache asynchronous fault status case 0x4d: // E-cache asynchronous fault address case 0x4e: // E-cache tag data case 0x66: // I-cache instruction access case 0x67: // I-cache tag access case 0x6e: // I-cache predecode case 0x6f: // I-cache LRU etc. case 0x76: // E-cache tag case 0x7e: // E-cache tag break; case 0x5b: // D-MMU data pointer case 0x48: // Interrupt dispatch, RO case 0x49: // Interrupt data receive case 0x7f: // Incoming interrupt vector, RO // XXX break; case 0x54: // I-MMU data in, WO case 0x57: // I-MMU demap, WO case 0x5c: // D-MMU data in, WO case 0x5f: // D-MMU demap, WO case 0x77: // Interrupt vector, WO default: do_unassigned_access(addr, 0, 0, 1, size); ret = 0; break; } /* Convert from little endian */ switch (asi) { case 0x0c: // Nucleus Little Endian (LE) case 0x18: // As if user primary LE case 0x19: // As if user secondary LE case 0x1c: // Bypass LE case 0x1d: // Bypass, non-cacheable LE case 0x88: // Primary LE case 0x89: // Secondary LE case 0x8a: // Primary no-fault LE case 0x8b: // Secondary no-fault LE switch(size) { case 2: ret = bswap16(ret); break; case 4: ret = bswap32(ret); break; case 8: ret = bswap64(ret); break; default: break; } default: break; } /* Convert to signed number */ if (sign) { switch(size) { case 1: ret = (int8_t) ret; break; case 2: ret = (int16_t) ret; break; case 4: ret = (int32_t) ret; break; default: break; } } #ifdef DEBUG_ASI dump_asi("read ", last_addr, asi, size, ret); #endif return ret; }
true
qemu
2aae2b8e0abd58e76d616bcbe93c6966d06d0188
7,166
static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int depth, AVFormatContext *s) { AVIOContext *pb; WtvFile *wf; uint8_t *buffer; if (avio_seek(s->pb, (int64_t)first_sector << WTV_SECTOR_BITS, SEEK_SET) < 0) return NULL; wf = av_mallocz(sizeof(WtvFile)); if (!wf) return NULL; if (depth == 0) { wf->sectors = av_malloc(sizeof(uint32_t)); if (!wf->sectors) { av_free(wf); return NULL; } wf->sectors[0] = first_sector; wf->nb_sectors = 1; } else if (depth == 1) { wf->sectors = av_malloc(WTV_SECTOR_SIZE); if (!wf->sectors) { av_free(wf); return NULL; } wf->nb_sectors = read_ints(s->pb, wf->sectors, WTV_SECTOR_SIZE / 4); } else if (depth == 2) { uint32_t sectors1[WTV_SECTOR_SIZE / 4]; int nb_sectors1 = read_ints(s->pb, sectors1, WTV_SECTOR_SIZE / 4); int i; wf->sectors = av_malloc(nb_sectors1 << WTV_SECTOR_BITS); if (!wf->sectors) { av_free(wf); return NULL; } wf->nb_sectors = 0; for (i = 0; i < nb_sectors1; i++) { if (avio_seek(s->pb, (int64_t)sectors1[i] << WTV_SECTOR_BITS, SEEK_SET) < 0) break; wf->nb_sectors += read_ints(s->pb, wf->sectors + i * WTV_SECTOR_SIZE / 4, WTV_SECTOR_SIZE / 4); } } else { av_log(s, AV_LOG_ERROR, "unsupported file allocation table depth (0x%x)\n", depth); av_free(wf); return NULL; } wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS; if (!wf->nb_sectors) { av_free(wf->sectors); av_free(wf); return NULL; } if (wf->sectors[wf->nb_sectors - 1] << WTV_SECTOR_BITS > avio_tell(s->pb)) av_log(s, AV_LOG_WARNING, "truncated file\n"); /* check length */ length &= 0xFFFFFFFFFFFF; if (length > ((int64_t)wf->nb_sectors << wf->sector_bits)) { av_log(s, AV_LOG_WARNING, "reported file length (0x%"PRIx64") exceeds number of available sectors (0x%"PRIx64")\n", length, (int64_t)wf->nb_sectors << wf->sector_bits); length = (int64_t)wf->nb_sectors << wf->sector_bits; } wf->length = length; /* seek to initial sector */ wf->position = 0; if (avio_seek(s->pb, (int64_t)wf->sectors[0] << WTV_SECTOR_BITS, SEEK_SET) < 0) { av_free(wf->sectors); av_free(wf); return NULL; } wf->pb_filesystem = s->pb; buffer = av_malloc(1 << wf->sector_bits); if (!buffer) { av_free(wf->sectors); av_free(wf); return NULL; } pb = avio_alloc_context(buffer, 1 << wf->sector_bits, 0, wf, wtvfile_read_packet, NULL, wtvfile_seek); if (!pb) { av_free(buffer); av_free(wf->sectors); av_free(wf); } return pb; }
true
FFmpeg
3317414fc11a9a187b474141f4ac13f895c0b493
7,167
static uint32_t ehci_mem_readb(void *ptr, target_phys_addr_t addr) { EHCIState *s = ptr; uint32_t val; val = s->mmio[addr]; return val; }
true
qemu
3e4f910c8d490a1490409a7e381dbbb229f9d272
7,170
static void gen_tlbli_74xx(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } gen_helper_74xx_tlbi(cpu_env, cpu_gpr[rB(ctx->opcode)]); #endif }
true
qemu
9b2fadda3e0196ffd485adde4fe9cdd6fae35300
7,172
int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){ int i, j; uint32_t c; if (bits < 8 || bits > 32 || poly >= (1LL<<bits)) return -1; if (ctx_size != sizeof(AVCRC)*257 && ctx_size != sizeof(AVCRC)*1024) return -1; for (i = 0; i < 256; i++) { if (le) { for (c = i, j = 0; j < 8; j++) c = (c>>1)^(poly & (-(c&1))); ctx[i] = c; } else { for (c = i << 24, j = 0; j < 8; j++) c = (c<<1) ^ ((poly<<(32-bits)) & (((int32_t)c)>>31) ); ctx[i] = av_bswap32(c); } } ctx[256]=1; #if !CONFIG_SMALL if(ctx_size >= sizeof(AVCRC)*1024) for (i = 0; i < 256; i++) for(j=0; j<3; j++) ctx[256*(j+1) + i]= (ctx[256*j + i]>>8) ^ ctx[ ctx[256*j + i]&0xFF ]; #endif return 0; }
true
FFmpeg
8b19ae07616bbd18969b94cbf5d74308a8f2bbdf
7,173
static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2]) { int e, k, m; // max gain limits : -3dB, 0dB, 3dB, inf dB (limiter off) static const SoftFloat limgain[4] = { { 760155524, 0 }, { 0x20000000, 1 }, { 758351638, 1 }, { 625000000, 34 } }; for (e = 0; e < ch_data->bs_num_env; e++) { int delta = !((e == e_a[1]) || (e == e_a[0])); for (k = 0; k < sbr->n_lim; k++) { SoftFloat gain_boost, gain_max; SoftFloat sum[2]; sum[0] = sum[1] = FLOAT_0; for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { const SoftFloat temp = av_div_sf(sbr->e_origmapped[e][m], av_add_sf(FLOAT_1, sbr->q_mapped[e][m])); sbr->q_m[e][m] = av_sqrt_sf(av_mul_sf(temp, sbr->q_mapped[e][m])); sbr->s_m[e][m] = av_sqrt_sf(av_mul_sf(temp, av_int2sf(ch_data->s_indexmapped[e + 1][m], 0))); if (!sbr->s_mapped[e][m]) { if (delta) { sbr->gain[e][m] = av_sqrt_sf(av_div_sf(sbr->e_origmapped[e][m], av_mul_sf(av_add_sf(FLOAT_1, sbr->e_curr[e][m]), av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); } else { sbr->gain[e][m] = av_sqrt_sf(av_div_sf(sbr->e_origmapped[e][m], av_add_sf(FLOAT_1, sbr->e_curr[e][m]))); } } else { sbr->gain[e][m] = av_sqrt_sf( av_div_sf( av_mul_sf(sbr->e_origmapped[e][m], sbr->q_mapped[e][m]), av_mul_sf( av_add_sf(FLOAT_1, sbr->e_curr[e][m]), av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); } } for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sum[0] = av_add_sf(sum[0], sbr->e_origmapped[e][m]); sum[1] = av_add_sf(sum[1], sbr->e_curr[e][m]); } gain_max = av_mul_sf(limgain[sbr->bs_limiter_gains], av_sqrt_sf( av_div_sf( av_add_sf(FLOAT_EPSILON, sum[0]), av_add_sf(FLOAT_EPSILON, sum[1])))); if (av_gt_sf(gain_max, FLOAT_100000)) gain_max = FLOAT_100000; for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { SoftFloat q_m_max = av_div_sf( av_mul_sf(sbr->q_m[e][m], gain_max), sbr->gain[e][m]); if (av_gt_sf(sbr->q_m[e][m], q_m_max)) sbr->q_m[e][m] = q_m_max; if (av_gt_sf(sbr->gain[e][m], gain_max)) sbr->gain[e][m] = gain_max; } sum[0] = sum[1] = FLOAT_0; for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sum[0] = av_add_sf(sum[0], sbr->e_origmapped[e][m]); sum[1] = av_add_sf(sum[1], av_mul_sf( av_mul_sf(sbr->e_curr[e][m], sbr->gain[e][m]), sbr->gain[e][m])); sum[1] = av_add_sf(sum[1], av_mul_sf(sbr->s_m[e][m], sbr->s_m[e][m])); if (delta && !sbr->s_m[e][m].mant) sum[1] = av_add_sf(sum[1], av_mul_sf(sbr->q_m[e][m], sbr->q_m[e][m])); } gain_boost = av_sqrt_sf( av_div_sf( av_add_sf(FLOAT_EPSILON, sum[0]), av_add_sf(FLOAT_EPSILON, sum[1]))); if (av_gt_sf(gain_boost, FLOAT_1584893192)) gain_boost = FLOAT_1584893192; for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sbr->gain[e][m] = av_mul_sf(sbr->gain[e][m], gain_boost); sbr->q_m[e][m] = av_mul_sf(sbr->q_m[e][m], gain_boost); sbr->s_m[e][m] = av_mul_sf(sbr->s_m[e][m], gain_boost); } } } }
true
FFmpeg
7d1dec466895eed12f2c79b7ab5447f5390fe869
7,175
void tcg_dump_ops(TCGContext *s) { char buf[128]; TCGOp *op; int oi; for (oi = s->gen_op_buf[0].next; oi != 0; oi = op->next) { int i, k, nb_oargs, nb_iargs, nb_cargs; const TCGOpDef *def; TCGOpcode c; int col = 0; op = &s->gen_op_buf[oi]; c = op->opc; def = &tcg_op_defs[c]; if (c == INDEX_op_insn_start) { col += qemu_log("%s ----", oi != s->gen_op_buf[0].next ? "\n" : ""); for (i = 0; i < TARGET_INSN_START_WORDS; ++i) { target_ulong a; #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS a = deposit64(op->args[i * 2], 32, 32, op->args[i * 2 + 1]); #else a = op->args[i]; #endif col += qemu_log(" " TARGET_FMT_lx, a); } } else if (c == INDEX_op_call) { /* variable number of arguments */ nb_oargs = op->callo; nb_iargs = op->calli; nb_cargs = def->nb_cargs; /* function name, flags, out args */ col += qemu_log(" %s %s,$0x%" TCG_PRIlx ",$%d", def->name, tcg_find_helper(s, op->args[nb_oargs + nb_iargs]), op->args[nb_oargs + nb_iargs + 1], nb_oargs); for (i = 0; i < nb_oargs; i++) { col += qemu_log(",%s", tcg_get_arg_str(s, buf, sizeof(buf), op->args[i])); } for (i = 0; i < nb_iargs; i++) { TCGArg arg = op->args[nb_oargs + i]; const char *t = "<dummy>"; if (arg != TCG_CALL_DUMMY_ARG) { t = tcg_get_arg_str(s, buf, sizeof(buf), arg); } col += qemu_log(",%s", t); } } else { col += qemu_log(" %s ", def->name); nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; nb_cargs = def->nb_cargs; k = 0; for (i = 0; i < nb_oargs; i++) { if (k != 0) { col += qemu_log(","); } col += qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf), op->args[k++])); } for (i = 0; i < nb_iargs; i++) { if (k != 0) { col += qemu_log(","); } col += qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf), op->args[k++])); } switch (c) { case INDEX_op_brcond_i32: case INDEX_op_setcond_i32: case INDEX_op_movcond_i32: case INDEX_op_brcond2_i32: case INDEX_op_setcond2_i32: case INDEX_op_brcond_i64: case INDEX_op_setcond_i64: case INDEX_op_movcond_i64: if (op->args[k] < ARRAY_SIZE(cond_name) && cond_name[op->args[k]]) { col += qemu_log(",%s", cond_name[op->args[k++]]); } else { col += qemu_log(",$0x%" TCG_PRIlx, op->args[k++]); } i = 1; break; case INDEX_op_qemu_ld_i32: case INDEX_op_qemu_st_i32: case INDEX_op_qemu_ld_i64: case INDEX_op_qemu_st_i64: { TCGMemOpIdx oi = op->args[k++]; TCGMemOp op = get_memop(oi); unsigned ix = get_mmuidx(oi); if (op & ~(MO_AMASK | MO_BSWAP | MO_SSIZE)) { col += qemu_log(",$0x%x,%u", op, ix); } else { const char *s_al, *s_op; s_al = alignment_name[(op & MO_AMASK) >> MO_ASHIFT]; s_op = ldst_name[op & (MO_BSWAP | MO_SSIZE)]; col += qemu_log(",%s%s,%u", s_al, s_op, ix); } i = 1; } break; default: i = 0; break; } switch (c) { case INDEX_op_set_label: case INDEX_op_br: case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: case INDEX_op_brcond2_i32: col += qemu_log("%s$L%d", k ? "," : "", arg_label(op->args[k])->id); i++, k++; break; default: break; } for (; i < nb_cargs; i++, k++) { col += qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", op->args[k]); } } if (op->life) { unsigned life = op->life; for (; col < 48; ++col) { putc(' ', qemu_logfile); } if (life & (SYNC_ARG * 3)) { qemu_log(" sync:"); for (i = 0; i < 2; ++i) { if (life & (SYNC_ARG << i)) { qemu_log(" %d", i); } } } life /= DEAD_ARG; if (life) { qemu_log(" dead:"); for (i = 0; life; ++i, life >>= 1) { if (life & 1) { qemu_log(" %d", i); } } } } qemu_log("\n"); } }
true
qemu
15fa08f8451babc88d733bd411d4c94976f9d0f8
7,176
static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index, VTDIrq *irq) { VTD_IRTE irte = { 0 }; int ret = 0; ret = vtd_irte_get(iommu, index, &irte); if (ret) { return ret; } irq->trigger_mode = irte.trigger_mode; irq->vector = irte.vector; irq->delivery_mode = irte.delivery_mode; /* Not support EIM yet: please refer to vt-d 9.10 DST bits */ #define VTD_IR_APIC_DEST_MASK (0xff00ULL) #define VTD_IR_APIC_DEST_SHIFT (8) irq->dest = (le32_to_cpu(irte.dest_id) & VTD_IR_APIC_DEST_MASK) >> \ VTD_IR_APIC_DEST_SHIFT; irq->dest_mode = irte.dest_mode; irq->redir_hint = irte.redir_hint; VTD_DPRINTF(IR, "remapping interrupt index %d: trig:%u,vec:%u," "deliver:%u,dest:%u,dest_mode:%u", index, irq->trigger_mode, irq->vector, irq->delivery_mode, irq->dest, irq->dest_mode); return 0; }
true
qemu
09cd058a2cf77bb7a3b10ff93c1f80ed88bca364
7,178
void exynos4210_init_board_irqs(Exynos4210Irq *s) { uint32_t grp, bit, irq_id, n; for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], s->ext_combiner_irq[n]); irq_id = 0; if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { /* MCT_G0 is passed to External GIC */ irq_id = EXT_GIC_ID_MCT_G0; } if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { /* MCT_G1 is passed to External and GIC */ irq_id = EXT_GIC_ID_MCT_G1; } if (irq_id) { s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], s->ext_gic_irq[irq_id-32]); } } for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { /* these IDs are passed to Internal Combiner and External GIC */ grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n); bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); irq_id = combiner_grp_to_gic_id[grp - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; if (irq_id) { s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], s->ext_gic_irq[irq_id-32]); } } }
true
qemu
9ff7f5bddbe5814bafe5e798d2cf1087b58dc7b6
7,179
static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *iov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, int is_write) { VectorTranslationAIOCB *s = qemu_aio_get_pool(&vectored_aio_pool, bs, cb, opaque); s->iov = iov; s->bounce = qemu_memalign(512, nb_sectors * 512); s->is_write = is_write; if (is_write) { qemu_iovec_to_buffer(s->iov, s->bounce); s->aiocb = bdrv_aio_write(bs, sector_num, s->bounce, nb_sectors, bdrv_aio_rw_vector_cb, s); } else { s->aiocb = bdrv_aio_read(bs, sector_num, s->bounce, nb_sectors, bdrv_aio_rw_vector_cb, s); return &s->common;
true
qemu
c240b9af599d20e06a58090366be682684bd8555
7,181
int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec) { if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init) return 0; if (ff_mutex_lock(&codec_mutex)) return -1; if (atomic_fetch_add(&entangled_thread_counter, 1)) { av_log(log_ctx, AV_LOG_ERROR, "Insufficient thread locking. At least %d threads are " "calling avcodec_open2() at the same time right now.\n", atomic_load(&entangled_thread_counter)); ff_avcodec_locked = 1; ff_unlock_avcodec(codec); return AVERROR(EINVAL); } av_assert0(!ff_avcodec_locked); ff_avcodec_locked = 1; return 0; }
true
FFmpeg
4ed66517c62c599701b3793fa2843d5a8530a4f4
7,182
static void do_mchk_interrupt(CPUS390XState *env) { S390CPU *cpu = s390_env_get_cpu(env); uint64_t mask, addr; LowCore *lowcore; MchkQueue *q; int i; if (!(env->psw.mask & PSW_MASK_MCHECK)) { cpu_abort(CPU(cpu), "Machine check w/o mchk mask\n"); } if (env->mchk_index < 0 || env->mchk_index > MAX_MCHK_QUEUE) { cpu_abort(CPU(cpu), "Mchk queue overrun: %d\n", env->mchk_index); } q = &env->mchk_queue[env->mchk_index]; if (q->type != 1) { /* Don't know how to handle this... */ cpu_abort(CPU(cpu), "Unknown machine check type %d\n", q->type); } if (!(env->cregs[14] & (1 << 28))) { /* CRW machine checks disabled */ return; } lowcore = cpu_map_lowcore(env); for (i = 0; i < 16; i++) { lowcore->floating_pt_save_area[i] = cpu_to_be64(env->fregs[i].ll); lowcore->gpregs_save_area[i] = cpu_to_be64(env->regs[i]); lowcore->access_regs_save_area[i] = cpu_to_be32(env->aregs[i]); lowcore->cregs_save_area[i] = cpu_to_be64(env->cregs[i]); } lowcore->prefixreg_save_area = cpu_to_be32(env->psa); lowcore->fpt_creg_save_area = cpu_to_be32(env->fpc); lowcore->tod_progreg_save_area = cpu_to_be32(env->todpr); lowcore->cpu_timer_save_area[0] = cpu_to_be32(env->cputm >> 32); lowcore->cpu_timer_save_area[1] = cpu_to_be32((uint32_t)env->cputm); lowcore->clock_comp_save_area[0] = cpu_to_be32(env->ckc >> 32); lowcore->clock_comp_save_area[1] = cpu_to_be32((uint32_t)env->ckc); lowcore->mcck_interruption_code[0] = cpu_to_be32(0x00400f1d); lowcore->mcck_interruption_code[1] = cpu_to_be32(0x40330000); lowcore->mcck_old_psw.mask = cpu_to_be64(get_psw_mask(env)); lowcore->mcck_old_psw.addr = cpu_to_be64(env->psw.addr); mask = be64_to_cpu(lowcore->mcck_new_psw.mask); addr = be64_to_cpu(lowcore->mcck_new_psw.addr); cpu_unmap_lowcore(lowcore); env->mchk_index--; if (env->mchk_index == -1) { env->pending_int &= ~INTERRUPT_MCHK; } DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__, env->psw.mask, env->psw.addr); load_psw(env, mask, addr); }
true
qemu
1a71992376792a0d11ea27688bd1a21cdffd1826
7,183
uint16_t acpi_pm1_evt_get_sts(ACPIREGS *ar, int64_t overflow_time) { int64_t d = acpi_pm_tmr_get_clock(); if (d >= overflow_time) { ar->pm1.evt.sts |= ACPI_BITMASK_TIMER_STATUS; } return ar->pm1.evt.sts; }
true
qemu
2886be1b01c274570fa139748a402207482405bd
7,184
static int ide_drive_pio_post_load(void *opaque, int version_id) { IDEState *s = opaque; if (s->end_transfer_fn_idx > ARRAY_SIZE(transfer_end_table)) { return -EINVAL; } s->end_transfer_func = transfer_end_table[s->end_transfer_fn_idx]; s->data_ptr = s->io_buffer + s->cur_io_buffer_offset; s->data_end = s->data_ptr + s->cur_io_buffer_len; return 0; }
true
qemu
fb60105d4942a26f571b1be92a8b9e7528d0c4d8
7,185
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size) { int ret= av_new_packet(pkt, size); if(ret<0) return ret; pkt->pos= avio_tell(s); ret= avio_read(s, pkt->data, size); if(ret<=0) av_free_packet(pkt); else av_shrink_packet(pkt, ret); return ret; }
false
FFmpeg
47572323f2f908913b4d031af733047d481fb1f6
7,186
void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size) { RTPMuxContext *s = s1->priv_data; int len, max_packet_size; uint8_t *p; /* skip ADTS header, if present */ if ((s1->streams[0]->codec->extradata_size) == 0) { size -= 7; buff += 7; } max_packet_size = s->max_payload_size - MAX_AU_HEADERS_SIZE; /* test if the packet must be sent */ len = (s->buf_ptr - s->buf); if ((s->num_frames == MAX_FRAMES_PER_PACKET) || (len && (len + size) > s->max_payload_size)) { int au_size = s->num_frames * 2; p = s->buf + MAX_AU_HEADERS_SIZE - au_size - 2; if (p != s->buf) { memmove(p + 2, s->buf + 2, au_size); } /* Write the AU header size */ p[0] = ((au_size * 8) & 0xFF) >> 8; p[1] = (au_size * 8) & 0xFF; ff_rtp_send_data(s1, p, s->buf_ptr - p, 1); s->num_frames = 0; } if (s->num_frames == 0) { s->buf_ptr = s->buf + MAX_AU_HEADERS_SIZE; s->timestamp = s->cur_timestamp; } if (size <= max_packet_size) { p = s->buf + s->num_frames++ * 2 + 2; *p++ = size >> 5; *p = (size & 0x1F) << 3; memcpy(s->buf_ptr, buff, size); s->buf_ptr += size; } else { if (s->buf_ptr != s->buf + MAX_AU_HEADERS_SIZE) { av_log(s1, AV_LOG_ERROR, "Strange...\n"); av_abort(); } max_packet_size = s->max_payload_size - 4; p = s->buf; p[0] = 0; p[1] = 16; while (size > 0) { len = FFMIN(size, max_packet_size); p[2] = len >> 5; p[3] = (size & 0x1F) << 3; memcpy(p + 4, buff, len); ff_rtp_send_data(s1, p, len + 4, len == size); size -= len; buff += len; } } }
false
FFmpeg
ddffcb2d3a81e203cff6f3e39e40bf5720f7391e
7,188
static int check_pes(uint8_t *p, uint8_t *end){ int pes1; int pes2= (p[3] & 0xC0) == 0x80 && (p[4] & 0xC0) != 0x40 &&((p[4] & 0xC0) == 0x00 || (p[4]&0xC0)>>2 == (p[6]&0xF0)); for(p+=3; p<end && *p == 0xFF; p++); if((*p&0xC0) == 0x40) p+=2; if((*p&0xF0) == 0x20){ pes1= p[0]&p[2]&p[4]&1; p+=5; }else if((*p&0xF0) == 0x30){ pes1= p[0]&p[2]&p[4]&p[5]&p[7]&p[9]&1; p+=10; }else pes1 = *p == 0x0F; return pes1||pes2; }
false
FFmpeg
e8c93839148a168aedc978388f14c3599dd072f8
7,189
static int dpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; const uint8_t *buf_end = buf + buf_size; DPCMContext *s = avctx->priv_data; int out = 0; int predictor[2]; int ch = 0; int stereo = s->channels - 1; int16_t *output_samples = data; if (!buf_size) return 0; /* calculate output size */ switch(avctx->codec->id) { case CODEC_ID_ROQ_DPCM: out = buf_size - 8; break; case CODEC_ID_INTERPLAY_DPCM: out = buf_size - 6 - s->channels; break; case CODEC_ID_XAN_DPCM: out = buf_size - 2 * s->channels; break; case CODEC_ID_SOL_DPCM: if (avctx->codec_tag != 3) out = buf_size * 2; else out = buf_size; break; } out *= av_get_bytes_per_sample(avctx->sample_fmt); if (out < 0) { av_log(avctx, AV_LOG_ERROR, "packet is too small\n"); return AVERROR(EINVAL); } if (*data_size < out) { av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); return AVERROR(EINVAL); } switch(avctx->codec->id) { case CODEC_ID_ROQ_DPCM: buf += 6; if (stereo) { predictor[1] = (int16_t)(bytestream_get_byte(&buf) << 8); predictor[0] = (int16_t)(bytestream_get_byte(&buf) << 8); } else { predictor[0] = (int16_t)bytestream_get_le16(&buf); } /* decode the samples */ while (buf < buf_end) { predictor[ch] += s->roq_square_array[*buf++]; predictor[ch] = av_clip_int16(predictor[ch]); *output_samples++ = predictor[ch]; /* toggle channel */ ch ^= stereo; } break; case CODEC_ID_INTERPLAY_DPCM: buf += 6; /* skip over the stream mask and stream length */ for (ch = 0; ch < s->channels; ch++) { predictor[ch] = (int16_t)bytestream_get_le16(&buf); *output_samples++ = predictor[ch]; } ch = 0; while (buf < buf_end) { predictor[ch] += interplay_delta_table[*buf++]; predictor[ch] = av_clip_int16(predictor[ch]); *output_samples++ = predictor[ch]; /* toggle channel */ ch ^= stereo; } break; case CODEC_ID_XAN_DPCM: { int shift[2] = { 4, 4 }; for (ch = 0; ch < s->channels; ch++) predictor[ch] = (int16_t)bytestream_get_le16(&buf); ch = 0; while (buf < buf_end) { uint8_t n = *buf++; int16_t diff = (n & 0xFC) << 8; if ((n & 0x03) == 3) shift[ch]++; else shift[ch] -= (2 * (n & 3)); /* saturate the shifter to a lower limit of 0 */ if (shift[ch] < 0) shift[ch] = 0; diff >>= shift[ch]; predictor[ch] += diff; predictor[ch] = av_clip_int16(predictor[ch]); *output_samples++ = predictor[ch]; /* toggle channel */ ch ^= stereo; } break; } case CODEC_ID_SOL_DPCM: if (avctx->codec_tag != 3) { uint8_t *output_samples_u8 = data; while (buf < buf_end) { uint8_t n = *buf++; s->sample[0] += s->sol_table[n >> 4]; s->sample[0] = av_clip_uint8(s->sample[0]); *output_samples_u8++ = s->sample[0]; s->sample[stereo] += s->sol_table[n & 0x0F]; s->sample[stereo] = av_clip_uint8(s->sample[stereo]); *output_samples_u8++ = s->sample[stereo]; } } else { while (buf < buf_end) { uint8_t n = *buf++; if (n & 0x80) s->sample[ch] -= sol_table_16[n & 0x7F]; else s->sample[ch] += sol_table_16[n & 0x7F]; s->sample[ch] = av_clip_int16(s->sample[ch]); *output_samples++ = s->sample[ch]; /* toggle channel */ ch ^= stereo; } } break; } *data_size = out; return buf_size; }
false
FFmpeg
e79da63282b354fb721ac4b763d268649f0efd76
7,190
static void gen_logicq_cc(TCGv_i64 val) { TCGv tmp = new_tmp(); gen_helper_logicq_cc(tmp, val); gen_logic_CC(tmp); dead_tmp(tmp); }
true
qemu
7d1b0095bff7157e856d1d0e6c4295641ced2752
7,192
static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVQcow2State *s = bs->opaque; int offset_in_cluster; int ret; unsigned int cur_bytes; /* number of sectors in current iteration */ uint64_t cluster_offset; QEMUIOVector hd_qiov; uint64_t bytes_done = 0; uint8_t *cluster_data = NULL; QCowL2Meta *l2meta = NULL; trace_qcow2_writev_start_req(qemu_coroutine_self(), offset, bytes); qemu_iovec_init(&hd_qiov, qiov->niov); s->cluster_cache_offset = -1; /* disable compressed cache */ qemu_co_mutex_lock(&s->lock); while (bytes != 0) { l2meta = NULL; trace_qcow2_writev_start_part(qemu_coroutine_self()); offset_in_cluster = offset_into_cluster(s, offset); cur_bytes = MIN(bytes, INT_MAX); if (bs->encrypted) { cur_bytes = MIN(cur_bytes, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size - offset_in_cluster); } ret = qcow2_alloc_cluster_offset(bs, offset, &cur_bytes, &cluster_offset, &l2meta); if (ret < 0) { goto fail; } assert((cluster_offset & 511) == 0); qemu_iovec_reset(&hd_qiov); qemu_iovec_concat(&hd_qiov, qiov, bytes_done, cur_bytes); if (bs->encrypted) { Error *err = NULL; assert(s->crypto); if (!cluster_data) { cluster_data = qemu_try_blockalign(bs->file->bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); if (cluster_data == NULL) { ret = -ENOMEM; goto fail; } } assert(hd_qiov.size <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); qemu_iovec_to_buf(&hd_qiov, 0, cluster_data, hd_qiov.size); if (qcrypto_block_encrypt(s->crypto, offset >> BDRV_SECTOR_BITS, cluster_data, cur_bytes, &err) < 0) { error_free(err); ret = -EIO; goto fail; } qemu_iovec_reset(&hd_qiov); qemu_iovec_add(&hd_qiov, cluster_data, cur_bytes); } ret = qcow2_pre_write_overlap_check(bs, 0, cluster_offset + offset_in_cluster, cur_bytes); if (ret < 0) { goto fail; } /* If we need to do COW, check if it's possible to merge the * writing of the guest data together with that of the COW regions. * If it's not possible (or not necessary) then write the * guest data now. */ if (!merge_cow(offset, cur_bytes, &hd_qiov, l2meta)) { qemu_co_mutex_unlock(&s->lock); BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); trace_qcow2_writev_data(qemu_coroutine_self(), cluster_offset + offset_in_cluster); ret = bdrv_co_pwritev(bs->file, cluster_offset + offset_in_cluster, cur_bytes, &hd_qiov, 0); qemu_co_mutex_lock(&s->lock); if (ret < 0) { goto fail; } } while (l2meta != NULL) { QCowL2Meta *next; ret = qcow2_alloc_cluster_link_l2(bs, l2meta); if (ret < 0) { goto fail; } /* Take the request off the list of running requests */ if (l2meta->nb_clusters != 0) { QLIST_REMOVE(l2meta, next_in_flight); } qemu_co_queue_restart_all(&l2meta->dependent_requests); next = l2meta->next; g_free(l2meta); l2meta = next; } bytes -= cur_bytes; offset += cur_bytes; bytes_done += cur_bytes; trace_qcow2_writev_done_part(qemu_coroutine_self(), cur_bytes); } ret = 0; fail: qemu_co_mutex_unlock(&s->lock); while (l2meta != NULL) { QCowL2Meta *next; if (l2meta->nb_clusters != 0) { QLIST_REMOVE(l2meta, next_in_flight); } qemu_co_queue_restart_all(&l2meta->dependent_requests); next = l2meta->next; g_free(l2meta); l2meta = next; } qemu_iovec_destroy(&hd_qiov); qemu_vfree(cluster_data); trace_qcow2_writev_done_req(qemu_coroutine_self(), ret); return ret; }
true
qemu
4652b8f3e1ec91bb9d6f00e40df7f96d1f1aafee
7,193
static int ape_probe(AVProbeData * p) { if (p->buf[0] == 'M' && p->buf[1] == 'A' && p->buf[2] == 'C' && p->buf[3] == ' ') return AVPROBE_SCORE_MAX; return 0; }
true
FFmpeg
b57083529650be5417056453fae8b2bf2dface59
7,194
static void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc) { int16_t *filterPos = c->hChrFilterPos; int16_t *filter = c->hChrFilter; void *mmx2FilterCode= c->chrMmx2FilterCode; int i; #if defined(PIC) DECLARE_ALIGNED(8, uint64_t, ebxsave); #endif #if ARCH_X86_64 DECLARE_ALIGNED(8, uint64_t, retsave); #endif __asm__ volatile( #if defined(PIC) "mov %%"REG_b", %7 \n\t" #if ARCH_X86_64 "mov -8(%%rsp), %%"REG_a" \n\t" "mov %%"REG_a", %8 \n\t" #endif #else #if ARCH_X86_64 "mov -8(%%rsp), %%"REG_a" \n\t" "mov %%"REG_a", %7 \n\t" #endif #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" // i PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE "xor %%"REG_a", %%"REG_a" \n\t" // i "mov %5, %%"REG_c" \n\t" // src "mov %6, %%"REG_D" \n\t" // buf2 PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE #if defined(PIC) "mov %7, %%"REG_b" \n\t" #if ARCH_X86_64 "mov %8, %%"REG_a" \n\t" "mov %%"REG_a", -8(%%rsp) \n\t" #endif #else #if ARCH_X86_64 "mov %7, %%"REG_a" \n\t" "mov %%"REG_a", -8(%%rsp) \n\t" #endif #endif :: "m" (src1), "m" (dst1), "m" (filter), "m" (filterPos), "m" (mmx2FilterCode), "m" (src2), "m"(dst2) #if defined(PIC) ,"m" (ebxsave) #endif #if ARCH_X86_64 ,"m"(retsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) { dst1[i] = src1[srcW-1]*128; dst2[i] = src2[srcW-1]*128; } }
true
FFmpeg
2254b559cbcfc0418135f09add37c0a5866b1981
7,195
static void ide_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); k->init = ide_qdev_init; set_bit(DEVICE_CATEGORY_STORAGE, k->categories); k->bus_type = TYPE_IDE_BUS; k->props = ide_props; }
true
qemu
ca44141d5fb801dd5903102acefd0f2d8e8bb6a1
7,196
void memory_region_del_eventfd(MemoryRegion *mr, hwaddr addr, unsigned size, bool match_data, uint64_t data, EventNotifier *e) { MemoryRegionIoeventfd mrfd = { .addr.start = int128_make64(addr), .addr.size = int128_make64(size), .match_data = match_data, .data = data, .e = e, }; unsigned i; adjust_endianness(mr, &mrfd.data, size); memory_region_transaction_begin(); for (i = 0; i < mr->ioeventfd_nb; ++i) { if (memory_region_ioeventfd_equal(mrfd, mr->ioeventfds[i])) { break; } } assert(i != mr->ioeventfd_nb); memmove(&mr->ioeventfds[i], &mr->ioeventfds[i+1], sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - (i+1))); --mr->ioeventfd_nb; mr->ioeventfds = g_realloc(mr->ioeventfds, sizeof(*mr->ioeventfds)*mr->ioeventfd_nb + 1); ioeventfd_update_pending |= mr->enabled; memory_region_transaction_commit(); }
true
qemu
b8aecea23aaccf39da54c77ef248f5fa50dcfbc1
7,197
void pc_system_firmware_init(MemoryRegion *rom_memory) { DriveInfo *pflash_drv; PcSysFwDevice *sysfw_dev; /* * TODO This device exists only so that users can switch between * use of flash and ROM for the BIOS. The ability to switch was * created because flash doesn't work with KVM. Once it does, we * should drop this device for new machine types. */ sysfw_dev = (PcSysFwDevice*) qdev_create(NULL, "pc-sysfw"); qdev_init_nofail(DEVICE(sysfw_dev)); if (sysfw_dev->rom_only) { old_pc_system_rom_init(rom_memory); return; } pflash_drv = drive_get(IF_PFLASH, 0, 0); /* Currently KVM cannot execute from device memory. Use old rom based firmware initialization for KVM. */ /* * This is a Bad Idea, because it makes enabling/disabling KVM * guest-visible. Do it only in bug-compatibility mode. */ if (pc_sysfw_flash_vs_rom_bug_compatible && kvm_enabled()) { if (pflash_drv != NULL) { fprintf(stderr, "qemu: pflash cannot be used with kvm enabled\n"); exit(1); } else { sysfw_dev->rom_only = 1; old_pc_system_rom_init(rom_memory); return; } } /* If a pflash drive is not found, then create one using the bios filename. */ if (pflash_drv == NULL) { pc_fw_add_pflash_drv(); pflash_drv = drive_get(IF_PFLASH, 0, 0); } if (pflash_drv != NULL) { pc_system_flash_init(rom_memory, pflash_drv); } else { fprintf(stderr, "qemu: PC system firmware (pflash) not available\n"); exit(1); } }
true
qemu
9e1c2ec8fd8d9a9ee299ea86c5f6c986fe25e838
7,198
static int32_t scalarproduct_and_madd_int32_c(int16_t *v1, const int32_t *v2, const int16_t *v3, int order, int mul) { int res = 0; while (order--) { res += *v1 * *v2++; *v1++ += mul * *v3++; } return res; }
true
FFmpeg
9ca16bdd3f0461b40d369080647747ae70715daf
7,199
static int spapr_nvram_init(VIOsPAPRDevice *dev) { sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(dev); if (nvram->drive) { nvram->size = bdrv_getlength(nvram->drive); } else { nvram->size = DEFAULT_NVRAM_SIZE; nvram->buf = g_malloc0(nvram->size); } if ((nvram->size < MIN_NVRAM_SIZE) || (nvram->size > MAX_NVRAM_SIZE)) { fprintf(stderr, "spapr-nvram must be between %d and %d bytes in size\n", MIN_NVRAM_SIZE, MAX_NVRAM_SIZE); return -1; } spapr_rtas_register("nvram-fetch", rtas_nvram_fetch); spapr_rtas_register("nvram-store", rtas_nvram_store); return 0; }
true
qemu
3a3b8502e6f0c8d30865c5f36d2c3ae4114000b5
7,200
static CharDriverState *qemu_chr_open_pp(QemuOpts *opts) { const char *filename = qemu_opt_get(opts, "path"); CharDriverState *chr; int fd; fd = open(filename, O_RDWR); if (fd < 0) return NULL; chr = g_malloc0(sizeof(CharDriverState)); chr->opaque = (void *)(intptr_t)fd; chr->chr_write = null_chr_write; chr->chr_ioctl = pp_ioctl; return chr; }
true
qemu
b181e04777da67acbc7448f87e4ae9f1518e08b2
7,201
static void pvpanic_fw_cfg(ISADevice *dev, FWCfgState *fw_cfg) { PVPanicState *s = ISA_PVPANIC_DEVICE(dev); fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", g_memdup(&s->ioport, sizeof(s->ioport)), sizeof(s->ioport)); }
true
qemu
fea7d5966a54a5e5400cd38897a95ea576b5af4d
7,202
int net_client_init(Monitor *mon, const char *device, const char *p) { char buf[1024]; int vlan_id, ret; VLANState *vlan; char *name = NULL; vlan_id = 0; if (get_param_value(buf, sizeof(buf), "vlan", p)) { vlan_id = strtol(buf, NULL, 0); } vlan = qemu_find_vlan(vlan_id, 1); if (get_param_value(buf, sizeof(buf), "name", p)) { name = qemu_strdup(buf); } if (!strcmp(device, "nic")) { static const char * const nic_params[] = { "vlan", "name", "macaddr", "model", "addr", "id", "vectors", NULL }; NICInfo *nd; uint8_t *macaddr; int idx = nic_get_free_idx(); if (check_params(buf, sizeof(buf), nic_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } if (idx == -1 || nb_nics >= MAX_NICS) { config_error(mon, "Too Many NICs\n"); ret = -1; goto out; } nd = &nd_table[idx]; memset(nd, 0, sizeof(*nd)); macaddr = nd->macaddr; macaddr[0] = 0x52; macaddr[1] = 0x54; macaddr[2] = 0x00; macaddr[3] = 0x12; macaddr[4] = 0x34; macaddr[5] = 0x56 + idx; if (get_param_value(buf, sizeof(buf), "macaddr", p)) { if (parse_macaddr(macaddr, buf) < 0) { config_error(mon, "invalid syntax for ethernet address\n"); ret = -1; goto out; } } if (get_param_value(buf, sizeof(buf), "model", p)) { nd->model = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "addr", p)) { nd->devaddr = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "id", p)) { nd->id = qemu_strdup(buf); } nd->nvectors = NIC_NVECTORS_UNSPECIFIED; if (get_param_value(buf, sizeof(buf), "vectors", p)) { char *endptr; long vectors = strtol(buf, &endptr, 0); if (*endptr) { config_error(mon, "invalid syntax for # of vectors\n"); ret = -1; goto out; } if (vectors < 0 || vectors > 0x7ffffff) { config_error(mon, "invalid # of vectors\n"); ret = -1; goto out; } nd->nvectors = vectors; } nd->vlan = vlan; nd->name = name; nd->used = 1; name = NULL; nb_nics++; vlan->nb_guest_devs++; ret = idx; } else if (!strcmp(device, "none")) { if (*p != '\0') { config_error(mon, "'none' takes no parameters\n"); ret = -1; goto out; } /* does nothing. It is needed to signal that no network cards are wanted */ ret = 0; } else #ifdef CONFIG_SLIRP if (!strcmp(device, "user")) { static const char * const slirp_params[] = { "vlan", "name", "hostname", "restrict", "ip", "net", "host", "tftp", "bootfile", "dhcpstart", "dns", "smb", "smbserver", "hostfwd", "guestfwd", NULL }; struct slirp_config_str *config; int restricted = 0; char *vnet = NULL; char *vhost = NULL; char *vhostname = NULL; char *tftp_export = NULL; char *bootfile = NULL; char *vdhcp_start = NULL; char *vnamesrv = NULL; char *smb_export = NULL; char *vsmbsrv = NULL; const char *q; if (check_params(buf, sizeof(buf), slirp_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } if (get_param_value(buf, sizeof(buf), "ip", p)) { int vnet_buflen = strlen(buf) + strlen("/24") + 1; /* emulate legacy parameter */ vnet = qemu_malloc(vnet_buflen); pstrcpy(vnet, vnet_buflen, buf); pstrcat(vnet, vnet_buflen, "/24"); } if (get_param_value(buf, sizeof(buf), "net", p)) { vnet = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "host", p)) { vhost = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "hostname", p)) { vhostname = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "restrict", p)) { restricted = (buf[0] == 'y') ? 1 : 0; } if (get_param_value(buf, sizeof(buf), "dhcpstart", p)) { vdhcp_start = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "dns", p)) { vnamesrv = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "tftp", p)) { tftp_export = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "bootfile", p)) { bootfile = qemu_strdup(buf); } if (get_param_value(buf, sizeof(buf), "smb", p)) { smb_export = qemu_strdup(buf); if (get_param_value(buf, sizeof(buf), "smbserver", p)) { vsmbsrv = qemu_strdup(buf); } } q = p; while (1) { config = qemu_malloc(sizeof(*config)); if (!get_next_param_value(config->str, sizeof(config->str), "hostfwd", &q)) { break; } config->flags = SLIRP_CFG_HOSTFWD; config->next = slirp_configs; slirp_configs = config; config = NULL; } q = p; while (1) { config = qemu_malloc(sizeof(*config)); if (!get_next_param_value(config->str, sizeof(config->str), "guestfwd", &q)) { break; } config->flags = 0; config->next = slirp_configs; slirp_configs = config; config = NULL; } qemu_free(config); vlan->nb_host_devs++; ret = net_slirp_init(mon, vlan, device, name, restricted, vnet, vhost, vhostname, tftp_export, bootfile, vdhcp_start, vnamesrv, smb_export, vsmbsrv); while (slirp_configs) { config = slirp_configs; slirp_configs = config->next; qemu_free(config); } qemu_free(vnet); qemu_free(vhost); qemu_free(vhostname); qemu_free(tftp_export); qemu_free(bootfile); qemu_free(vdhcp_start); qemu_free(vnamesrv); qemu_free(smb_export); qemu_free(vsmbsrv); } else if (!strcmp(device, "channel")) { if (QTAILQ_EMPTY(&slirp_stacks)) { struct slirp_config_str *config; config = qemu_malloc(sizeof(*config)); pstrcpy(config->str, sizeof(config->str), p); config->flags = SLIRP_CFG_LEGACY; config->next = slirp_configs; slirp_configs = config; } else { slirp_guestfwd(QTAILQ_FIRST(&slirp_stacks), mon, p, 1); } ret = 0; } else #endif #ifdef _WIN32 if (!strcmp(device, "tap")) { static const char * const tap_params[] = { "vlan", "name", "ifname", NULL }; char ifname[64]; if (check_params(buf, sizeof(buf), tap_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { config_error(mon, "tap: no interface name\n"); ret = -1; goto out; } vlan->nb_host_devs++; ret = tap_win32_init(vlan, device, name, ifname); } else #elif defined (_AIX) #else if (!strcmp(device, "tap")) { char ifname[64], chkbuf[64]; char setup_script[1024], down_script[1024]; TAPState *s; int fd; vlan->nb_host_devs++; if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { static const char * const fd_params[] = { "vlan", "name", "fd", "sndbuf", NULL }; ret = -1; if (check_params(chkbuf, sizeof(chkbuf), fd_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); goto out; } fd = net_handle_fd_param(mon, buf); if (fd == -1) { goto out; } fcntl(fd, F_SETFL, O_NONBLOCK); s = net_tap_fd_init(vlan, device, name, fd); if (!s) { close(fd); } } else { static const char * const tap_params[] = { "vlan", "name", "ifname", "script", "downscript", "sndbuf", NULL }; if (check_params(chkbuf, sizeof(chkbuf), tap_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { ifname[0] = '\0'; } if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) { pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT); } if (get_param_value(down_script, sizeof(down_script), "downscript", p) == 0) { pstrcpy(down_script, sizeof(down_script), DEFAULT_NETWORK_DOWN_SCRIPT); } s = net_tap_init(vlan, device, name, ifname, setup_script, down_script); } if (s != NULL) { const char *sndbuf_str = NULL; if (get_param_value(buf, sizeof(buf), "sndbuf", p)) { sndbuf_str = buf; } tap_set_sndbuf(s, sndbuf_str, mon); ret = 0; } else { ret = -1; } } else #endif if (!strcmp(device, "socket")) { char chkbuf[64]; if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { static const char * const fd_params[] = { "vlan", "name", "fd", NULL }; int fd; ret = -1; if (check_params(chkbuf, sizeof(chkbuf), fd_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); goto out; } fd = net_handle_fd_param(mon, buf); if (fd == -1) { goto out; } if (!net_socket_fd_init(vlan, device, name, fd, 1)) { close(fd); goto out; } ret = 0; } else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) { static const char * const listen_params[] = { "vlan", "name", "listen", NULL }; if (check_params(chkbuf, sizeof(chkbuf), listen_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } ret = net_socket_listen_init(vlan, device, name, buf); } else if (get_param_value(buf, sizeof(buf), "connect", p) > 0) { static const char * const connect_params[] = { "vlan", "name", "connect", NULL }; if (check_params(chkbuf, sizeof(chkbuf), connect_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } ret = net_socket_connect_init(vlan, device, name, buf); } else if (get_param_value(buf, sizeof(buf), "mcast", p) > 0) { static const char * const mcast_params[] = { "vlan", "name", "mcast", NULL }; if (check_params(chkbuf, sizeof(chkbuf), mcast_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } ret = net_socket_mcast_init(vlan, device, name, buf); } else { config_error(mon, "Unknown socket options: %s\n", p); ret = -1; goto out; } vlan->nb_host_devs++; } else #ifdef CONFIG_VDE if (!strcmp(device, "vde")) { static const char * const vde_params[] = { "vlan", "name", "sock", "port", "group", "mode", NULL }; char vde_sock[1024], vde_group[512]; int vde_port, vde_mode; if (check_params(buf, sizeof(buf), vde_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } vlan->nb_host_devs++; if (get_param_value(vde_sock, sizeof(vde_sock), "sock", p) <= 0) { vde_sock[0] = '\0'; } if (get_param_value(buf, sizeof(buf), "port", p) > 0) { vde_port = strtol(buf, NULL, 10); } else { vde_port = 0; } if (get_param_value(vde_group, sizeof(vde_group), "group", p) <= 0) { vde_group[0] = '\0'; } if (get_param_value(buf, sizeof(buf), "mode", p) > 0) { vde_mode = strtol(buf, NULL, 8); } else { vde_mode = 0700; } ret = net_vde_init(vlan, device, name, vde_sock, vde_port, vde_group, vde_mode); } else #endif if (!strcmp(device, "dump")) { int len = 65536; if (get_param_value(buf, sizeof(buf), "len", p) > 0) { len = strtol(buf, NULL, 0); } if (!get_param_value(buf, sizeof(buf), "file", p)) { snprintf(buf, sizeof(buf), "qemu-vlan%d.pcap", vlan_id); } ret = net_dump_init(mon, vlan, device, name, buf, len); } else { config_error(mon, "Unknown network device: %s\n", device); ret = -1; goto out; } if (ret < 0) { config_error(mon, "Could not initialize device '%s'\n", device); } out: qemu_free(name); return ret; }
true
qemu
0752706de257b38763006ff5bb6b39a97e669ba2
7,203
static void cmv_decode_intra(CmvContext * s, const uint8_t *buf, const uint8_t *buf_end){ unsigned char *dst = s->frame.data[0]; int i; for (i=0; i < s->avctx->height && buf+s->avctx->width<=buf_end; i++) { memcpy(dst, buf, s->avctx->width); dst += s->frame.linesize[0]; buf += s->avctx->width; } }
true
FFmpeg
e9064c9ce8ed18c3a3aab61e58e663b8f5b0c551
7,205
int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags) { BufferSinkContext *buf = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; int ret; AVFrame *cur_frame; /* no picref available, fetch it from the filterchain */ if (!av_fifo_size(buf->fifo)) { if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST) return AVERROR(EAGAIN); if ((ret = ff_request_frame(inlink)) < 0) return ret; } if (!av_fifo_size(buf->fifo)) return AVERROR(EINVAL); if (flags & AV_BUFFERSINK_FLAG_PEEK) { cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0)); av_frame_ref(frame, cur_frame); /* TODO check failure */ } else { av_fifo_generic_read(buf->fifo, &cur_frame, sizeof(cur_frame), NULL); av_frame_move_ref(frame, cur_frame); av_frame_free(&cur_frame); } return 0; }
true
FFmpeg
d8dccf69ff2df7014a2bb8e0e17828a820f45b27
7,207
static int dump_iterate(DumpState *s) { RAMBlock *block; int64_t size; int ret; while (1) { block = s->block; size = block->length; if (s->has_filter) { size -= s->start; if (s->begin + s->length < block->offset + block->length) { size -= block->offset + block->length - (s->begin + s->length); } } ret = write_memory(s, block, s->start, size); if (ret == -1) { return ret; } ret = get_next_block(s, block); if (ret == 1) { dump_completed(s); return 0; } } }
true
qemu
56c4bfb3f07f3107894c00281276aea4f5e8834d
7,208
static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val) { #define CASE_SET_REG24(name, addr) \ case addr : s->name &= 0xffffff00; s->name |= val; break; \ case addr + 1: s->name &= 0xffff00ff; s->name |= val << 8; break; \ case addr + 2: s->name &= 0xff00ffff; s->name |= val << 16; break; #define CASE_SET_REG32(name, addr) \ case addr : s->name &= 0xffffff00; s->name |= val; break; \ case addr + 1: s->name &= 0xffff00ff; s->name |= val << 8; break; \ case addr + 2: s->name &= 0xff00ffff; s->name |= val << 16; break; \ case addr + 3: s->name &= 0x00ffffff; s->name |= val << 24; break; #ifdef DEBUG_LSI_REG DPRINTF("Write reg %x = %02x\n", offset, val); #endif switch (offset) { case 0x00: /* SCNTL0 */ s->scntl0 = val; if (val & LSI_SCNTL0_START) { BADF("Start sequence not implemented\n"); } break; case 0x01: /* SCNTL1 */ s->scntl1 = val & ~LSI_SCNTL1_SST; if (val & LSI_SCNTL1_IARB) { BADF("Immediate Arbritration not implemented\n"); } if (val & LSI_SCNTL1_RST) { if (!(s->sstat0 & LSI_SSTAT0_RST)) { BusChild *kid; QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { DeviceState *dev = kid->child; device_reset(dev); } s->sstat0 |= LSI_SSTAT0_RST; lsi_script_scsi_interrupt(s, LSI_SIST0_RST, 0); } } else { s->sstat0 &= ~LSI_SSTAT0_RST; } break; case 0x02: /* SCNTL2 */ val &= ~(LSI_SCNTL2_WSR | LSI_SCNTL2_WSS); s->scntl2 = val; break; case 0x03: /* SCNTL3 */ s->scntl3 = val; break; case 0x04: /* SCID */ s->scid = val; break; case 0x05: /* SXFER */ s->sxfer = val; break; case 0x06: /* SDID */ if ((val & 0xf) != (s->ssid & 0xf)) BADF("Destination ID does not match SSID\n"); s->sdid = val & 0xf; break; case 0x07: /* GPREG0 */ break; case 0x08: /* SFBR */ /* The CPU is not allowed to write to this register. However the SCRIPTS register move instructions are. */ s->sfbr = val; break; case 0x0a: case 0x0b: /* Openserver writes to these readonly registers on startup */ return; case 0x0c: case 0x0d: case 0x0e: case 0x0f: /* Linux writes to these readonly registers on startup. */ return; CASE_SET_REG32(dsa, 0x10) case 0x14: /* ISTAT0 */ s->istat0 = (s->istat0 & 0x0f) | (val & 0xf0); if (val & LSI_ISTAT0_ABRT) { lsi_script_dma_interrupt(s, LSI_DSTAT_ABRT); } if (val & LSI_ISTAT0_INTF) { s->istat0 &= ~LSI_ISTAT0_INTF; lsi_update_irq(s); } if (s->waiting == 1 && val & LSI_ISTAT0_SIGP) { DPRINTF("Woken by SIGP\n"); s->waiting = 0; s->dsp = s->dnad; lsi_execute_script(s); } if (val & LSI_ISTAT0_SRST) { lsi_soft_reset(s); } break; case 0x16: /* MBOX0 */ s->mbox0 = val; break; case 0x17: /* MBOX1 */ s->mbox1 = val; break; case 0x1a: /* CTEST2 */ s->ctest2 = val & LSI_CTEST2_PCICIE; break; case 0x1b: /* CTEST3 */ s->ctest3 = val & 0x0f; break; CASE_SET_REG32(temp, 0x1c) case 0x21: /* CTEST4 */ if (val & 7) { BADF("Unimplemented CTEST4-FBL 0x%x\n", val); } s->ctest4 = val; break; case 0x22: /* CTEST5 */ if (val & (LSI_CTEST5_ADCK | LSI_CTEST5_BBCK)) { BADF("CTEST5 DMA increment not implemented\n"); } s->ctest5 = val; break; CASE_SET_REG24(dbc, 0x24) CASE_SET_REG32(dnad, 0x28) case 0x2c: /* DSP[0:7] */ s->dsp &= 0xffffff00; s->dsp |= val; break; case 0x2d: /* DSP[8:15] */ s->dsp &= 0xffff00ff; s->dsp |= val << 8; break; case 0x2e: /* DSP[16:23] */ s->dsp &= 0xff00ffff; s->dsp |= val << 16; break; case 0x2f: /* DSP[24:31] */ s->dsp &= 0x00ffffff; s->dsp |= val << 24; if ((s->dmode & LSI_DMODE_MAN) == 0 && (s->istat1 & LSI_ISTAT1_SRUN) == 0) lsi_execute_script(s); break; CASE_SET_REG32(dsps, 0x30) CASE_SET_REG32(scratch[0], 0x34) case 0x38: /* DMODE */ if (val & (LSI_DMODE_SIOM | LSI_DMODE_DIOM)) { BADF("IO mappings not implemented\n"); } s->dmode = val; break; case 0x39: /* DIEN */ s->dien = val; lsi_update_irq(s); break; case 0x3a: /* SBR */ s->sbr = val; break; case 0x3b: /* DCNTL */ s->dcntl = val & ~(LSI_DCNTL_PFF | LSI_DCNTL_STD); if ((val & LSI_DCNTL_STD) && (s->istat1 & LSI_ISTAT1_SRUN) == 0) lsi_execute_script(s); break; case 0x40: /* SIEN0 */ s->sien0 = val; lsi_update_irq(s); break; case 0x41: /* SIEN1 */ s->sien1 = val; lsi_update_irq(s); break; case 0x47: /* GPCNTL0 */ break; case 0x48: /* STIME0 */ s->stime0 = val; break; case 0x49: /* STIME1 */ if (val & 0xf) { DPRINTF("General purpose timer not implemented\n"); /* ??? Raising the interrupt immediately seems to be sufficient to keep the FreeBSD driver happy. */ lsi_script_scsi_interrupt(s, 0, LSI_SIST1_GEN); } break; case 0x4a: /* RESPID0 */ s->respid0 = val; break; case 0x4b: /* RESPID1 */ s->respid1 = val; break; case 0x4d: /* STEST1 */ s->stest1 = val; break; case 0x4e: /* STEST2 */ if (val & 1) { BADF("Low level mode not implemented\n"); } s->stest2 = val; break; case 0x4f: /* STEST3 */ if (val & 0x41) { BADF("SCSI FIFO test mode not implemented\n"); } s->stest3 = val; break; case 0x56: /* CCNTL0 */ s->ccntl0 = val; break; case 0x57: /* CCNTL1 */ s->ccntl1 = val; break; CASE_SET_REG32(mmrs, 0xa0) CASE_SET_REG32(mmws, 0xa4) CASE_SET_REG32(sfs, 0xa8) CASE_SET_REG32(drs, 0xac) CASE_SET_REG32(sbms, 0xb0) CASE_SET_REG32(dbms, 0xb4) CASE_SET_REG32(dnad64, 0xb8) CASE_SET_REG32(pmjad1, 0xc0) CASE_SET_REG32(pmjad2, 0xc4) CASE_SET_REG32(rbc, 0xc8) CASE_SET_REG32(ua, 0xcc) CASE_SET_REG32(ia, 0xd4) CASE_SET_REG32(sbc, 0xd8) CASE_SET_REG32(csbc, 0xdc) default: if (offset >= 0x5c && offset < 0xa0) { int n; int shift; n = (offset - 0x58) >> 2; shift = (offset & 3) * 8; s->scratch[n] &= ~(0xff << shift); s->scratch[n] |= (val & 0xff) << shift; } else { BADF("Unhandled writeb 0x%x = 0x%x\n", offset, val); } } #undef CASE_SET_REG24 #undef CASE_SET_REG32 }
true
qemu
2f0772c5b4818d4b2078be9dace0036d1030faee
7,209
static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, const int *const_args) { int c; switch (opc) { case INDEX_op_exit_tb: tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_I0, args[0]); tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I7) | INSN_IMM13(8)); tcg_out32(s, RESTORE | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_G0) | INSN_RS2(TCG_REG_G0)); break; case INDEX_op_goto_tb: if (s->tb_jmp_offset) { /* direct jump method */ if (ABS(args[0] - (unsigned long)s->code_ptr) == (ABS(args[0] - (unsigned long)s->code_ptr) & 0x1fffff)) { tcg_out32(s, BA | INSN_OFF22(args[0] - (unsigned long)s->code_ptr)); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_I5, args[0]); tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) | INSN_RS2(TCG_REG_G0)); } s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; } else { /* indirect jump method */ tcg_out_ld_ptr(s, TCG_REG_I5, (tcg_target_long)(s->tb_next + args[0])); tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) | INSN_RS2(TCG_REG_G0)); } tcg_out_nop(s); s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf; break; case INDEX_op_call: if (const_args[0]) { tcg_out32(s, CALL | ((((tcg_target_ulong)args[0] - (tcg_target_ulong)s->code_ptr) >> 2) & 0x3fffffff)); tcg_out_nop(s); } else { tcg_out_ld_ptr(s, TCG_REG_O7, (tcg_target_long)(s->tb_next + args[0])); tcg_out32(s, JMPL | INSN_RD(TCG_REG_O7) | INSN_RS1(TCG_REG_O7) | INSN_RS2(TCG_REG_G0)); tcg_out_nop(s); } break; case INDEX_op_jmp: fprintf(stderr, "unimplemented jmp\n"); break; case INDEX_op_br: fprintf(stderr, "unimplemented br\n"); break; case INDEX_op_movi_i32: tcg_out_movi(s, TCG_TYPE_I32, args[0], (uint32_t)args[1]); break; #if defined(__sparc_v9__) && !defined(__sparc_v8plus__) #define OP_32_64(x) \ glue(glue(case INDEX_op_, x), _i32:) \ glue(glue(case INDEX_op_, x), _i64:) #else #define OP_32_64(x) \ glue(glue(case INDEX_op_, x), _i32:) #endif OP_32_64(ld8u); tcg_out_ldst(s, args[0], args[1], args[2], LDUB); break; OP_32_64(ld8s); tcg_out_ldst(s, args[0], args[1], args[2], LDSB); break; OP_32_64(ld16u); tcg_out_ldst(s, args[0], args[1], args[2], LDUH); break; OP_32_64(ld16s); tcg_out_ldst(s, args[0], args[1], args[2], LDSH); break; case INDEX_op_ld_i32: #if defined(__sparc_v9__) && !defined(__sparc_v8plus__) case INDEX_op_ld32u_i64: #endif tcg_out_ldst(s, args[0], args[1], args[2], LDUW); break; OP_32_64(st8); tcg_out_ldst(s, args[0], args[1], args[2], STB); break; OP_32_64(st16); tcg_out_ldst(s, args[0], args[1], args[2], STH); break; case INDEX_op_st_i32: #if defined(__sparc_v9__) && !defined(__sparc_v8plus__) case INDEX_op_st32_i64: #endif tcg_out_ldst(s, args[0], args[1], args[2], STW); break; OP_32_64(add); c = ARITH_ADD; goto gen_arith32; OP_32_64(sub); c = ARITH_SUB; goto gen_arith32; OP_32_64(and); c = ARITH_AND; goto gen_arith32; OP_32_64(or); c = ARITH_OR; goto gen_arith32; OP_32_64(xor); c = ARITH_XOR; goto gen_arith32; case INDEX_op_shl_i32: c = SHIFT_SLL; goto gen_arith32; case INDEX_op_shr_i32: c = SHIFT_SRL; goto gen_arith32; case INDEX_op_sar_i32: c = SHIFT_SRA; goto gen_arith32; case INDEX_op_mul_i32: c = ARITH_UMUL; goto gen_arith32; case INDEX_op_div2_i32: #if defined(__sparc_v9__) || defined(__sparc_v8plus__) c = ARITH_SDIVX; goto gen_arith32; #else tcg_out_sety(s, 0); c = ARITH_SDIV; goto gen_arith32; #endif case INDEX_op_divu2_i32: #if defined(__sparc_v9__) || defined(__sparc_v8plus__) c = ARITH_UDIVX; goto gen_arith32; #else tcg_out_sety(s, 0); c = ARITH_UDIV; goto gen_arith32; #endif case INDEX_op_brcond_i32: fprintf(stderr, "unimplemented brcond\n"); break; case INDEX_op_qemu_ld8u: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_ld8s: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_ld16u: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_ld16s: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_ld32u: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_ld32s: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_st8: fprintf(stderr, "unimplemented qst\n"); break; case INDEX_op_qemu_st16: fprintf(stderr, "unimplemented qst\n"); break; case INDEX_op_qemu_st32: fprintf(stderr, "unimplemented qst\n"); break; #if defined(__sparc_v9__) && !defined(__sparc_v8plus__) case INDEX_op_movi_i64: tcg_out_movi(s, TCG_TYPE_I64, args[0], args[1]); break; case INDEX_op_ld32s_i64: tcg_out_ldst(s, args[0], args[1], args[2], LDSW); break; case INDEX_op_ld_i64: tcg_out_ldst(s, args[0], args[1], args[2], LDX); break; case INDEX_op_st_i64: tcg_out_ldst(s, args[0], args[1], args[2], STX); break; case INDEX_op_shl_i64: c = SHIFT_SLLX; goto gen_arith32; case INDEX_op_shr_i64: c = SHIFT_SRLX; goto gen_arith32; case INDEX_op_sar_i64: c = SHIFT_SRAX; goto gen_arith32; case INDEX_op_mul_i64: c = ARITH_MULX; goto gen_arith32; case INDEX_op_div2_i64: c = ARITH_SDIVX; goto gen_arith32; case INDEX_op_divu2_i64: c = ARITH_UDIVX; goto gen_arith32; case INDEX_op_brcond_i64: fprintf(stderr, "unimplemented brcond\n"); break; case INDEX_op_qemu_ld64: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_st64: fprintf(stderr, "unimplemented qst\n"); break; #endif gen_arith32: if (const_args[2]) { tcg_out_arithi(s, args[0], args[1], args[2], c); } else { tcg_out_arith(s, args[0], args[1], args[2], c); } break; default: fprintf(stderr, "unknown opcode 0x%x\n", opc); tcg_abort(); } }
false
qemu
f02ca5cbeaf86038834c1953247a1579d7921927