project
stringclasses 2
values | commit_id
stringlengths 40
40
| target
int64 0
1
| func
stringlengths 26
142k
| idx
int64 0
27.3k
|
---|---|---|---|---|
FFmpeg | 143685a42bbc8861b626457ce4cb8b1ce4b0c436 | 0 | static av_cold int ffat_close_encoder(AVCodecContext *avctx)
{
ATDecodeContext *at = avctx->priv_data;
AudioConverterDispose(at->converter);
av_frame_unref(&at->new_in_frame);
av_frame_unref(&at->in_frame);
ff_af_queue_close(&at->afq);
return 0;
}
| 11,206 |
FFmpeg | f6161fccf8c5720ceac1ed1df8ba60ff8fed69f5 | 0 | static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
uint8_t *buf, int buf_size, int64_t wait_end)
{
RTSPState *rt = s->priv_data;
RTSPStream *rtsp_st;
int n, i, ret, timeout_cnt = 0;
struct pollfd *p = rt->p;
int *fds = NULL, fdsnum, fdsidx;
if (!p) {
p = rt->p = av_malloc_array(2 * (rt->nb_rtsp_streams + 1), sizeof(struct pollfd));
if (!p)
return AVERROR(ENOMEM);
if (rt->rtsp_hd) {
p[rt->max_p].fd = ffurl_get_file_handle(rt->rtsp_hd);
p[rt->max_p++].events = POLLIN;
}
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st->rtp_handle) {
if (ret = ffurl_get_multi_file_handle(rtsp_st->rtp_handle,
&fds, &fdsnum)) {
av_log(s, AV_LOG_ERROR, "Unable to recover rtp ports\n");
return ret;
}
if (fdsnum != 2) {
av_log(s, AV_LOG_ERROR,
"Number of fds %d not supported\n", fdsnum);
return AVERROR_INVALIDDATA;
}
for (fdsidx = 0; fdsidx < fdsnum; fdsidx++) {
p[rt->max_p].fd = fds[fdsidx];
p[rt->max_p++].events = POLLIN;
}
av_free(fds);
}
}
}
for (;;) {
if (ff_check_interrupt(&s->interrupt_callback))
return AVERROR_EXIT;
if (wait_end && wait_end - av_gettime_relative() < 0)
return AVERROR(EAGAIN);
n = poll(p, rt->max_p, POLL_TIMEOUT_MS);
if (n > 0) {
int j = rt->rtsp_hd ? 1 : 0;
timeout_cnt = 0;
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st->rtp_handle) {
if (p[j].revents & POLLIN || p[j+1].revents & POLLIN) {
ret = ffurl_read(rtsp_st->rtp_handle, buf, buf_size);
if (ret > 0) {
*prtsp_st = rtsp_st;
return ret;
}
}
j+=2;
}
}
#if CONFIG_RTSP_DEMUXER
if (rt->rtsp_hd && p[0].revents & POLLIN) {
return parse_rtsp_message(s);
}
#endif
} else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) {
return AVERROR(ETIMEDOUT);
} else if (n < 0 && errno != EINTR)
return AVERROR(errno);
}
}
| 11,207 |
qemu | ab8131afee34d6aa427bd56ac18c4d3b6df80728 | 1 | static void booke_update_fixed_timer(CPUPPCState *env,
uint8_t target_bit,
uint64_t *next,
struct QEMUTimer *timer)
{
ppc_tb_t *tb_env = env->tb_env;
uint64_t lapse;
uint64_t tb;
uint64_t period = 1 << (target_bit + 1);
uint64_t now;
now = qemu_get_clock_ns(vm_clock);
tb = cpu_ppc_get_tb(tb_env, now, tb_env->tb_offset);
lapse = period - ((tb - (1 << target_bit)) & (period - 1));
*next = now + muldiv64(lapse, get_ticks_per_sec(), tb_env->tb_freq);
/* XXX: If expire time is now. We can't run the callback because we don't
* have access to it. So we just set the timer one nanosecond later.
*/
if (*next == now) {
(*next)++;
}
qemu_mod_timer(timer, *next);
}
| 11,208 |
qemu | 33face6b8981add8eba1f7cdaf4cf6cede415d2e | 1 | static void spapr_machine_init(MachineState *machine)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
const char *kernel_filename = machine->kernel_filename;
const char *initrd_filename = machine->initrd_filename;
PCIHostState *phb;
int i;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *rma_region;
void *rma = NULL;
hwaddr rma_alloc_size;
hwaddr node0_size = spapr_node0_size(machine);
long load_limit, fw_size;
char *filename;
Error *resize_hpt_err = NULL;
msi_nonbroken = true;
QLIST_INIT(&spapr->phbs);
QTAILQ_INIT(&spapr->pending_dimm_unplugs);
/* Check HPT resizing availability */
kvmppc_check_papr_resize_hpt(&resize_hpt_err);
if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DEFAULT) {
/*
* If the user explicitly requested a mode we should either
* supply it, or fail completely (which we do below). But if
* it's not set explicitly, we reset our mode to something
* that works
*/
if (resize_hpt_err) {
spapr->resize_hpt = SPAPR_RESIZE_HPT_DISABLED;
error_free(resize_hpt_err);
resize_hpt_err = NULL;
} else {
spapr->resize_hpt = smc->resize_hpt_default;
}
}
assert(spapr->resize_hpt != SPAPR_RESIZE_HPT_DEFAULT);
if ((spapr->resize_hpt != SPAPR_RESIZE_HPT_DISABLED) && resize_hpt_err) {
/*
* User requested HPT resize, but this host can't supply it. Bail out
*/
error_report_err(resize_hpt_err);
exit(1);
}
/* Allocate RMA if necessary */
rma_alloc_size = kvmppc_alloc_rma(&rma);
if (rma_alloc_size == -1) {
error_report("Unable to create RMA");
exit(1);
}
if (rma_alloc_size && (rma_alloc_size < node0_size)) {
spapr->rma_size = rma_alloc_size;
} else {
spapr->rma_size = node0_size;
/* With KVM, we don't actually know whether KVM supports an
* unbounded RMA (PR KVM) or is limited by the hash table size
* (HV KVM using VRMA), so we always assume the latter
*
* In that case, we also limit the initial allocations for RTAS
* etc... to 256M since we have no way to know what the VRMA size
* is going to be as it depends on the size of the hash table
* isn't determined yet.
*/
if (kvm_enabled()) {
spapr->vrma_adjust = 1;
spapr->rma_size = MIN(spapr->rma_size, 0x10000000);
}
/* Actually we don't support unbounded RMA anymore since we
* added proper emulation of HV mode. The max we can get is
* 16G which also happens to be what we configure for PAPR
* mode so make sure we don't do anything bigger than that
*/
spapr->rma_size = MIN(spapr->rma_size, 0x400000000ull);
}
if (spapr->rma_size > node0_size) {
error_report("Numa node 0 has to span the RMA (%#08"HWADDR_PRIx")",
spapr->rma_size);
exit(1);
}
/* Setup a load limit for the ramdisk leaving room for SLOF and FDT */
load_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR) - FW_OVERHEAD;
/* Set up Interrupt Controller before we create the VCPUs */
xics_system_init(machine, XICS_IRQS_SPAPR, &error_fatal);
/* Set up containers for ibm,client-architecture-support negotiated options
*/
spapr->ov5 = spapr_ovec_new();
spapr->ov5_cas = spapr_ovec_new();
if (smc->dr_lmb_enabled) {
spapr_ovec_set(spapr->ov5, OV5_DRCONF_MEMORY);
spapr_validate_node_memory(machine, &error_fatal);
}
spapr_ovec_set(spapr->ov5, OV5_FORM1_AFFINITY);
if (!kvm_enabled() || kvmppc_has_cap_mmu_radix()) {
/* KVM and TCG always allow GTSE with radix... */
spapr_ovec_set(spapr->ov5, OV5_MMU_RADIX_GTSE);
}
/* ... but not with hash (currently). */
/* advertise support for dedicated HP event source to guests */
if (spapr->use_hotplug_event_source) {
spapr_ovec_set(spapr->ov5, OV5_HP_EVT);
}
/* advertise support for HPT resizing */
if (spapr->resize_hpt != SPAPR_RESIZE_HPT_DISABLED) {
spapr_ovec_set(spapr->ov5, OV5_HPT_RESIZE);
}
/* init CPUs */
spapr_set_vsmt_mode(spapr, &error_fatal);
spapr_init_cpus(spapr);
if (kvm_enabled()) {
/* Enable H_LOGICAL_CI_* so SLOF can talk to in-kernel devices */
kvmppc_enable_logical_ci_hcalls();
kvmppc_enable_set_mode_hcall();
/* H_CLEAR_MOD/_REF are mandatory in PAPR, but off by default */
kvmppc_enable_clear_ref_mod_hcalls();
}
/* allocate RAM */
memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram",
machine->ram_size);
memory_region_add_subregion(sysmem, 0, ram);
if (rma_alloc_size && rma) {
rma_region = g_new(MemoryRegion, 1);
memory_region_init_ram_ptr(rma_region, NULL, "ppc_spapr.rma",
rma_alloc_size, rma);
vmstate_register_ram_global(rma_region);
memory_region_add_subregion(sysmem, 0, rma_region);
}
/* initialize hotplug memory address space */
if (machine->ram_size < machine->maxram_size) {
ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
/*
* Limit the number of hotpluggable memory slots to half the number
* slots that KVM supports, leaving the other half for PCI and other
* devices. However ensure that number of slots doesn't drop below 32.
*/
int max_memslots = kvm_enabled() ? kvm_get_max_memslots() / 2 :
SPAPR_MAX_RAM_SLOTS;
if (max_memslots < SPAPR_MAX_RAM_SLOTS) {
max_memslots = SPAPR_MAX_RAM_SLOTS;
}
if (machine->ram_slots > max_memslots) {
error_report("Specified number of memory slots %"
PRIu64" exceeds max supported %d",
machine->ram_slots, max_memslots);
exit(1);
}
spapr->hotplug_memory.base = ROUND_UP(machine->ram_size,
SPAPR_HOTPLUG_MEM_ALIGN);
memory_region_init(&spapr->hotplug_memory.mr, OBJECT(spapr),
"hotplug-memory", hotplug_mem_size);
memory_region_add_subregion(sysmem, spapr->hotplug_memory.base,
&spapr->hotplug_memory.mr);
}
if (smc->dr_lmb_enabled) {
spapr_create_lmb_dr_connectors(spapr);
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin");
if (!filename) {
error_report("Could not find LPAR rtas '%s'", "spapr-rtas.bin");
exit(1);
}
spapr->rtas_size = get_image_size(filename);
if (spapr->rtas_size < 0) {
error_report("Could not get size of LPAR rtas '%s'", filename);
exit(1);
}
spapr->rtas_blob = g_malloc(spapr->rtas_size);
if (load_image_size(filename, spapr->rtas_blob, spapr->rtas_size) < 0) {
error_report("Could not load LPAR rtas '%s'", filename);
exit(1);
}
if (spapr->rtas_size > RTAS_MAX_SIZE) {
error_report("RTAS too big ! 0x%zx bytes (max is 0x%x)",
(size_t)spapr->rtas_size, RTAS_MAX_SIZE);
exit(1);
}
g_free(filename);
/* Set up RTAS event infrastructure */
spapr_events_init(spapr);
/* Set up the RTC RTAS interfaces */
spapr_rtc_create(spapr);
/* Set up VIO bus */
spapr->vio_bus = spapr_vio_bus_init();
for (i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
spapr_vty_create(spapr->vio_bus, serial_hds[i]);
}
}
/* We always have at least the nvram device on VIO */
spapr_create_nvram(spapr);
/* Set up PCI */
spapr_pci_rtas_init();
phb = spapr_create_phb(spapr, 0);
for (i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
if (!nd->model) {
nd->model = g_strdup("ibmveth");
}
if (strcmp(nd->model, "ibmveth") == 0) {
spapr_vlan_create(spapr->vio_bus, nd);
} else {
pci_nic_init_nofail(&nd_table[i], phb->bus, nd->model, NULL);
}
}
for (i = 0; i <= drive_get_max_bus(IF_SCSI); i++) {
spapr_vscsi_create(spapr->vio_bus);
}
/* Graphics */
if (spapr_vga_init(phb->bus, &error_fatal)) {
spapr->has_graphics = true;
machine->usb |= defaults_enabled() && !machine->usb_disabled;
}
if (machine->usb) {
if (smc->use_ohci_by_default) {
pci_create_simple(phb->bus, -1, "pci-ohci");
} else {
pci_create_simple(phb->bus, -1, "nec-usb-xhci");
}
if (spapr->has_graphics) {
USBBus *usb_bus = usb_bus_find(-1);
usb_create_simple(usb_bus, "usb-kbd");
usb_create_simple(usb_bus, "usb-mouse");
}
}
if (spapr->rma_size < (MIN_RMA_SLOF << 20)) {
error_report(
"pSeries SLOF firmware requires >= %ldM guest RMA (Real Mode Area memory)",
MIN_RMA_SLOF);
exit(1);
}
if (kernel_filename) {
uint64_t lowaddr = 0;
spapr->kernel_size = load_elf(kernel_filename, translate_kernel_address,
NULL, NULL, &lowaddr, NULL, 1,
PPC_ELF_MACHINE, 0, 0);
if (spapr->kernel_size == ELF_LOAD_WRONG_ENDIAN) {
spapr->kernel_size = load_elf(kernel_filename,
translate_kernel_address, NULL, NULL,
&lowaddr, NULL, 0, PPC_ELF_MACHINE,
0, 0);
spapr->kernel_le = spapr->kernel_size > 0;
}
if (spapr->kernel_size < 0) {
error_report("error loading %s: %s", kernel_filename,
load_elf_strerror(spapr->kernel_size));
exit(1);
}
/* load initrd */
if (initrd_filename) {
/* Try to locate the initrd in the gap between the kernel
* and the firmware. Add a bit of space just in case
*/
spapr->initrd_base = (KERNEL_LOAD_ADDR + spapr->kernel_size
+ 0x1ffff) & ~0xffff;
spapr->initrd_size = load_image_targphys(initrd_filename,
spapr->initrd_base,
load_limit
- spapr->initrd_base);
if (spapr->initrd_size < 0) {
error_report("could not load initial ram disk '%s'",
initrd_filename);
exit(1);
}
}
}
if (bios_name == NULL) {
bios_name = FW_FILE_NAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (!filename) {
error_report("Could not find LPAR firmware '%s'", bios_name);
exit(1);
}
fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE);
if (fw_size <= 0) {
error_report("Could not load LPAR firmware '%s'", filename);
exit(1);
}
g_free(filename);
/* FIXME: Should register things through the MachineState's qdev
* interface, this is a legacy from the sPAPREnvironment structure
* which predated MachineState but had a similar function */
vmstate_register(NULL, 0, &vmstate_spapr, spapr);
register_savevm_live(NULL, "spapr/htab", -1, 1,
&savevm_htab_handlers, spapr);
qemu_register_boot_set(spapr_boot_set, spapr);
if (kvm_enabled()) {
/* to stop and start vmclock */
qemu_add_vm_change_state_handler(cpu_ppc_clock_vm_state_change,
&spapr->tb);
kvmppc_spapr_enable_inkernel_multitce();
}
} | 11,209 |
FFmpeg | e55376a1fd5abebbb0a082aa20739d58c2260a37 | 1 | static int append_flv_data(RTMPContext *rt, RTMPPacket *pkt, int skip)
{
int old_flv_size, ret;
PutByteContext pbc;
const uint8_t *data = pkt->data + skip;
const int size = pkt->size - skip;
uint32_t ts = pkt->timestamp;
if (pkt->type == RTMP_PT_AUDIO) {
rt->has_audio = 1;
} else if (pkt->type == RTMP_PT_VIDEO) {
rt->has_video = 1;
}
old_flv_size = update_offset(rt, size + 15);
if ((ret = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) {
rt->flv_size = rt->flv_off = 0;
return ret;
}
bytestream2_init_writer(&pbc, rt->flv_data, rt->flv_size);
bytestream2_skip_p(&pbc, old_flv_size);
bytestream2_put_byte(&pbc, pkt->type);
bytestream2_put_be24(&pbc, size);
bytestream2_put_be24(&pbc, ts);
bytestream2_put_byte(&pbc, ts >> 24);
bytestream2_put_be24(&pbc, 0);
bytestream2_put_buffer(&pbc, data, size);
bytestream2_put_be32(&pbc, 0);
return 0;
}
| 11,210 |
FFmpeg | a30a8beeb3dc44b666d0e1aefbd823752f321ac1 | 1 | static void decode_b(AVCodecContext *ctx, int row, int col,
struct VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl, enum BlockPartition bp)
{
VP9Context *s = ctx->priv_data;
VP9Block *b = s->b;
enum BlockSize bs = bl * 3 + bp;
int bytesperpixel = s->bytesperpixel;
int w4 = bwh_tab[1][bs][0], h4 = bwh_tab[1][bs][1], lvl;
int emu[2];
AVFrame *f = s->frames[CUR_FRAME].tf.f;
s->row = row;
s->row7 = row & 7;
s->col = col;
s->col7 = col & 7;
s->min_mv.x = -(128 + col * 64);
s->min_mv.y = -(128 + row * 64);
s->max_mv.x = 128 + (s->cols - col - w4) * 64;
s->max_mv.y = 128 + (s->rows - row - h4) * 64;
if (s->pass < 2) {
b->bs = bs;
b->bl = bl;
b->bp = bp;
decode_mode(ctx);
b->uvtx = b->tx - ((s->ss_h && w4 * 2 == (1 << b->tx)) ||
(s->ss_v && h4 * 2 == (1 << b->tx)));
if (!b->skip) {
int has_coeffs;
if (bytesperpixel == 1) {
has_coeffs = decode_coeffs_8bpp(ctx);
} else {
has_coeffs = decode_coeffs_16bpp(ctx);
}
if (!has_coeffs && b->bs <= BS_8x8 && !b->intra) {
b->skip = 1;
memset(&s->above_skip_ctx[col], 1, w4);
memset(&s->left_skip_ctx[s->row7], 1, h4);
}
} else {
int row7 = s->row7;
#define SPLAT_ZERO_CTX(v, n) \
switch (n) { \
case 1: v = 0; break; \
case 2: AV_ZERO16(&v); break; \
case 4: AV_ZERO32(&v); break; \
case 8: AV_ZERO64(&v); break; \
case 16: AV_ZERO128(&v); break; \
}
#define SPLAT_ZERO_YUV(dir, var, off, n, dir2) \
do { \
SPLAT_ZERO_CTX(s->dir##_y_##var[off * 2], n * 2); \
if (s->ss_##dir2) { \
SPLAT_ZERO_CTX(s->dir##_uv_##var[0][off], n); \
SPLAT_ZERO_CTX(s->dir##_uv_##var[1][off], n); \
} else { \
SPLAT_ZERO_CTX(s->dir##_uv_##var[0][off * 2], n * 2); \
SPLAT_ZERO_CTX(s->dir##_uv_##var[1][off * 2], n * 2); \
} \
} while (0)
switch (w4) {
case 1: SPLAT_ZERO_YUV(above, nnz_ctx, col, 1, h); break;
case 2: SPLAT_ZERO_YUV(above, nnz_ctx, col, 2, h); break;
case 4: SPLAT_ZERO_YUV(above, nnz_ctx, col, 4, h); break;
case 8: SPLAT_ZERO_YUV(above, nnz_ctx, col, 8, h); break;
}
switch (h4) {
case 1: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 1, v); break;
case 2: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 2, v); break;
case 4: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 4, v); break;
case 8: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 8, v); break;
}
}
if (s->pass == 1) {
s->b++;
s->block += w4 * h4 * 64 * bytesperpixel;
s->uvblock[0] += w4 * h4 * 64 * bytesperpixel >> (s->ss_h + s->ss_v);
s->uvblock[1] += w4 * h4 * 64 * bytesperpixel >> (s->ss_h + s->ss_v);
s->eob += 4 * w4 * h4;
s->uveob[0] += 4 * w4 * h4 >> (s->ss_h + s->ss_v);
s->uveob[1] += 4 * w4 * h4 >> (s->ss_h + s->ss_v);
return;
}
}
// emulated overhangs if the stride of the target buffer can't hold. This
// makes it possible to support emu-edge and so on even if we have large block
// overhangs
emu[0] = (col + w4) * 8 > f->linesize[0] ||
(row + h4) > s->rows;
emu[1] = (col + w4) * 4 > f->linesize[1] ||
(row + h4) > s->rows;
if (emu[0]) {
s->dst[0] = s->tmp_y;
s->y_stride = 128;
} else {
s->dst[0] = f->data[0] + yoff;
s->y_stride = f->linesize[0];
}
if (emu[1]) {
s->dst[1] = s->tmp_uv[0];
s->dst[2] = s->tmp_uv[1];
s->uv_stride = 128;
} else {
s->dst[1] = f->data[1] + uvoff;
s->dst[2] = f->data[2] + uvoff;
s->uv_stride = f->linesize[1];
}
if (b->intra) {
if (s->bpp > 8) {
intra_recon_16bpp(ctx, yoff, uvoff);
} else {
intra_recon_8bpp(ctx, yoff, uvoff);
}
} else {
if (s->bpp > 8) {
inter_recon_16bpp(ctx);
} else {
inter_recon_8bpp(ctx);
}
}
if (emu[0]) {
int w = FFMIN(s->cols - col, w4) * 8, h = FFMIN(s->rows - row, h4) * 8, n, o = 0;
for (n = 0; o < w; n++) {
int bw = 64 >> n;
av_assert2(n <= 4);
if (w & bw) {
s->dsp.mc[n][0][0][0][0](f->data[0] + yoff + o * bytesperpixel, f->linesize[0],
s->tmp_y + o * bytesperpixel, 128, h, 0, 0);
o += bw;
}
}
}
if (emu[1]) {
int w = FFMIN(s->cols - col, w4) * 8 >> s->ss_h;
int h = FFMIN(s->rows - row, h4) * 8 >> s->ss_v, n, o = 0;
for (n = s->ss_h; o < w; n++) {
int bw = 64 >> n;
av_assert2(n <= 4);
if (w & bw) {
s->dsp.mc[n][0][0][0][0](f->data[1] + uvoff + o * bytesperpixel, f->linesize[1],
s->tmp_uv[0] + o * bytesperpixel, 128, h, 0, 0);
s->dsp.mc[n][0][0][0][0](f->data[2] + uvoff + o * bytesperpixel, f->linesize[2],
s->tmp_uv[1] + o * bytesperpixel, 128, h, 0, 0);
o += bw;
}
}
}
// pick filter level and find edges to apply filter to
if (s->filter.level &&
(lvl = s->segmentation.feat[b->seg_id].lflvl[b->intra ? 0 : b->ref[0] + 1]
[b->mode[3] != ZEROMV]) > 0) {
int x_end = FFMIN(s->cols - col, w4), y_end = FFMIN(s->rows - row, h4);
int skip_inter = !b->intra && b->skip, col7 = s->col7, row7 = s->row7;
setctx_2d(&lflvl->level[row7 * 8 + col7], w4, h4, 8, lvl);
mask_edges(lflvl->mask[0], 0, 0, row7, col7, x_end, y_end, 0, 0, b->tx, skip_inter);
if (s->ss_h || s->ss_v)
mask_edges(lflvl->mask[1], s->ss_h, s->ss_v, row7, col7, x_end, y_end,
s->cols & 1 && col + w4 >= s->cols ? s->cols & 7 : 0,
s->rows & 1 && row + h4 >= s->rows ? s->rows & 7 : 0,
b->uvtx, skip_inter);
if (!s->filter.lim_lut[lvl]) {
int sharp = s->filter.sharpness;
int limit = lvl;
if (sharp > 0) {
limit >>= (sharp + 3) >> 2;
limit = FFMIN(limit, 9 - sharp);
}
limit = FFMAX(limit, 1);
s->filter.lim_lut[lvl] = limit;
s->filter.mblim_lut[lvl] = 2 * (lvl + 2) + limit;
}
}
if (s->pass == 2) {
s->b++;
s->block += w4 * h4 * 64 * bytesperpixel;
s->uvblock[0] += w4 * h4 * 64 * bytesperpixel >> (s->ss_v + s->ss_h);
s->uvblock[1] += w4 * h4 * 64 * bytesperpixel >> (s->ss_v + s->ss_h);
s->eob += 4 * w4 * h4;
s->uveob[0] += 4 * w4 * h4 >> (s->ss_v + s->ss_h);
s->uveob[1] += 4 * w4 * h4 >> (s->ss_v + s->ss_h);
}
}
| 11,211 |
qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | 1 | static void unset_dirty_tracking(void)
{
BlkMigDevState *bmds;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
bdrv_release_dirty_bitmap(bmds->bs, bmds->dirty_bitmap);
}
}
| 11,212 |
qemu | 4f298a4b2957b7833bc607c951ca27c458d98d88 | 1 | static void get_sel_entry(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
unsigned int val;
IPMI_CHECK_CMD_LEN(8);
if (cmd[6]) {
IPMI_CHECK_RESERVATION(2, ibs->sel.reservation);
}
if (ibs->sel.next_free == 0) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return;
}
if (cmd[6] > 15) {
rsp[2] = IPMI_CC_INVALID_DATA_FIELD;
return;
}
if (cmd[7] == 0xff) {
cmd[7] = 16;
} else if ((cmd[7] + cmd[6]) > 16) {
rsp[2] = IPMI_CC_INVALID_DATA_FIELD;
return;
} else {
cmd[7] += cmd[6];
}
val = cmd[4] | (cmd[5] << 8);
if (val == 0xffff) {
val = ibs->sel.next_free - 1;
} else if (val >= ibs->sel.next_free) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return;
}
if ((val + 1) == ibs->sel.next_free) {
IPMI_ADD_RSP_DATA(0xff);
IPMI_ADD_RSP_DATA(0xff);
} else {
IPMI_ADD_RSP_DATA((val + 1) & 0xff);
IPMI_ADD_RSP_DATA(((val + 1) >> 8) & 0xff);
}
for (; cmd[6] < cmd[7]; cmd[6]++) {
IPMI_ADD_RSP_DATA(ibs->sel.sel[val][cmd[6]]);
}
}
| 11,213 |
qemu | 3de3d698d942d1116152417f882c897b26b44e41 | 1 | int inet_dgram_opts(QemuOpts *opts, Error **errp)
{
struct addrinfo ai, *peer = NULL, *local = NULL;
const char *addr;
const char *port;
int sock = -1, rc;
/* lookup peer addr */
memset(&ai,0, sizeof(ai));
ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
ai.ai_family = PF_UNSPEC;
ai.ai_socktype = SOCK_DGRAM;
addr = qemu_opt_get(opts, "host");
port = qemu_opt_get(opts, "port");
if (addr == NULL || strlen(addr) == 0) {
addr = "localhost";
}
if (port == NULL || strlen(port) == 0) {
error_setg(errp, "remote port not specified");
return -1;
}
if (qemu_opt_get_bool(opts, "ipv4", 0))
ai.ai_family = PF_INET;
if (qemu_opt_get_bool(opts, "ipv6", 0))
ai.ai_family = PF_INET6;
if (0 != (rc = getaddrinfo(addr, port, &ai, &peer))) {
error_setg(errp, "address resolution failed for %s:%s: %s", addr, port,
gai_strerror(rc));
return -1;
}
/* lookup local addr */
memset(&ai,0, sizeof(ai));
ai.ai_flags = AI_PASSIVE;
ai.ai_family = peer->ai_family;
ai.ai_socktype = SOCK_DGRAM;
addr = qemu_opt_get(opts, "localaddr");
port = qemu_opt_get(opts, "localport");
if (addr == NULL || strlen(addr) == 0) {
addr = NULL;
}
if (!port || strlen(port) == 0)
port = "0";
if (0 != (rc = getaddrinfo(addr, port, &ai, &local))) {
error_setg(errp, "address resolution failed for %s:%s: %s", addr, port,
gai_strerror(rc));
goto err;
}
/* create socket */
sock = qemu_socket(peer->ai_family, peer->ai_socktype, peer->ai_protocol);
if (sock < 0) {
error_setg_errno(errp, errno, "Failed to create socket");
goto err;
}
socket_set_fast_reuse(sock);
/* bind socket */
if (bind(sock, local->ai_addr, local->ai_addrlen) < 0) {
error_setg_errno(errp, errno, "Failed to bind socket");
goto err;
}
/* connect to peer */
if (connect(sock,peer->ai_addr,peer->ai_addrlen) < 0) {
error_setg_errno(errp, errno, "Failed to connect socket");
goto err;
}
freeaddrinfo(local);
freeaddrinfo(peer);
return sock;
err:
if (-1 != sock)
closesocket(sock);
if (local)
freeaddrinfo(local);
if (peer)
freeaddrinfo(peer);
return -1;
}
| 11,214 |
qemu | de5dca1b792ada25c29a95c8f84e01f4300aef9c | 1 | e1000e_io_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
E1000EState *s = opaque;
uint32_t idx;
switch (addr) {
case E1000_IOADDR:
trace_e1000e_io_write_addr(val);
s->ioaddr = (uint32_t) val;
return;
case E1000_IODATA:
if (e1000e_io_get_reg_index(s, &idx)) {
trace_e1000e_io_write_data(idx, val);
e1000e_core_write(&s->core, idx, val, sizeof(val));
}
return;
default:
trace_e1000e_wrn_io_write_unknown(addr);
return;
}
}
| 11,215 |
qemu | b6353bea572f8cc0f35fb7dc438ce74c08dda9e7 | 1 | static int find_partition(BlockDriverState *bs, int partition,
off_t *offset, off_t *size)
{
struct partition_record mbr[4];
uint8_t data[512];
int i;
int ext_partnum = 4;
if (bdrv_read(bs, 0, data, 1))
errx(EINVAL, "error while reading");
if (data[510] != 0x55 || data[511] != 0xaa) {
errno = -EINVAL;
return -1;
}
for (i = 0; i < 4; i++) {
read_partition(&data[446 + 16 * i], &mbr[i]);
if (!mbr[i].nb_sectors_abs)
continue;
if (mbr[i].system == 0xF || mbr[i].system == 0x5) {
struct partition_record ext[4];
uint8_t data1[512];
int j;
if (bdrv_read(bs, mbr[i].start_sector_abs, data1, 1))
errx(EINVAL, "error while reading");
for (j = 0; j < 4; j++) {
read_partition(&data1[446 + 16 * j], &ext[j]);
if (!ext[j].nb_sectors_abs)
continue;
if ((ext_partnum + j + 1) == partition) {
*offset = (uint64_t)ext[j].start_sector_abs << 9;
*size = (uint64_t)ext[j].nb_sectors_abs << 9;
return 0;
}
}
ext_partnum += 4;
} else if ((i + 1) == partition) {
*offset = (uint64_t)mbr[i].start_sector_abs << 9;
*size = (uint64_t)mbr[i].nb_sectors_abs << 9;
return 0;
}
}
errno = -ENOENT;
return -1;
}
| 11,216 |
qemu | 97f3ad35517e0d02c0149637d1bb10713c52b057 | 1 | int register_savevm_live(DeviceState *dev,
const char *idstr,
int instance_id,
int version_id,
SaveVMHandlers *ops,
void *opaque)
{
SaveStateEntry *se;
se = g_malloc0(sizeof(SaveStateEntry));
se->version_id = version_id;
se->section_id = savevm_state.global_section_id++;
se->ops = ops;
se->opaque = opaque;
se->vmsd = NULL;
/* if this is a live_savem then set is_ram */
if (ops->save_live_setup != NULL) {
se->is_ram = 1;
}
if (dev) {
char *id = qdev_get_dev_path(dev);
if (id) {
pstrcpy(se->idstr, sizeof(se->idstr), id);
pstrcat(se->idstr, sizeof(se->idstr), "/");
g_free(id);
se->compat = g_malloc0(sizeof(CompatEntry));
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), idstr);
se->compat->instance_id = instance_id == -1 ?
calculate_compat_instance_id(idstr) : instance_id;
instance_id = -1;
}
}
pstrcat(se->idstr, sizeof(se->idstr), idstr);
if (instance_id == -1) {
se->instance_id = calculate_new_instance_id(se->idstr);
} else {
se->instance_id = instance_id;
}
assert(!se->compat || se->instance_id == 0);
/* add at the end of list */
QTAILQ_INSERT_TAIL(&savevm_state.handlers, se, entry);
return 0;
}
| 11,217 |
qemu | 1c02e2a17104fe7fc11893125864dc0daf1e6d5b | 1 | static int l2_load(BlockDriverState *bs, uint64_t l2_offset,
uint64_t **l2_table)
{
BDRVQcowState *s = bs->opaque;
int min_index;
int ret;
/* seek if the table for the given offset is in the cache */
*l2_table = seek_l2_table(s, l2_offset);
if (*l2_table != NULL) {
return 0;
}
/* not found: load a new entry in the least used one */
min_index = l2_cache_new_entry(bs);
*l2_table = s->l2_cache + (min_index << s->l2_bits);
BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD);
ret = bdrv_pread(bs->file, l2_offset, *l2_table,
s->l2_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
s->l2_cache_offsets[min_index] = l2_offset;
s->l2_cache_counts[min_index] = 1;
return 0;
} | 11,218 |
qemu | af18078d8057203b1ed26ac5534d233aabb36886 | 1 | print_operand_value (char *buf, size_t bufsize, int hex, bfd_vma disp)
{
if (address_mode == mode_64bit)
{
if (hex)
{
char tmp[30];
int i;
buf[0] = '0';
buf[1] = 'x';
snprintf_vma (tmp, sizeof(tmp), disp);
for (i = 0; tmp[i] == '0' && tmp[i + 1]; i++);
pstrcpy (buf + 2, bufsize - 2, tmp + i);
}
else
{
bfd_signed_vma v = disp;
char tmp[30];
int i;
if (v < 0)
{
*(buf++) = '-';
v = -disp;
/* Check for possible overflow on 0x8000000000000000. */
if (v < 0)
{
pstrcpy (buf, bufsize, "9223372036854775808");
return;
}
}
if (!v)
{
pstrcpy (buf, bufsize, "0");
return;
}
i = 0;
tmp[29] = 0;
while (v)
{
tmp[28 - i] = (v % 10) + '0';
v /= 10;
i++;
}
pstrcpy (buf, bufsize, tmp + 29 - i);
}
}
else
{
if (hex)
snprintf (buf, bufsize, "0x%x", (unsigned int) disp);
else
snprintf (buf, bufsize, "%d", (int) disp);
}
}
| 11,219 |
qemu | 6f2d8978728c48ca46f5c01835438508aace5c64 | 1 | void OPPROTO op_4xx_tlbsx_check (void)
{
int tmp;
tmp = xer_so;
if (T0 != -1)
tmp |= 0x02;
env->crf[0] = tmp;
RETURN();
}
| 11,220 |
qemu | 2d896b454a0e19ec4c1ddbb0e0b65b7e54fcedf3 | 1 | type_init(boston_register_types)
static void gen_firmware(uint32_t *p, hwaddr kernel_entry, hwaddr fdt_addr,
bool is_64b)
{
const uint32_t cm_base = 0x16100000;
const uint32_t gic_base = 0x16120000;
const uint32_t cpc_base = 0x16200000;
/* Move CM GCRs */
if (is_64b) {
stl_p(p++, 0x40287803); /* dmfc0 $8, CMGCRBase */
stl_p(p++, 0x00084138); /* dsll $8, $8, 4 */
} else {
stl_p(p++, 0x40087803); /* mfc0 $8, CMGCRBase */
stl_p(p++, 0x00084100); /* sll $8, $8, 4 */
}
stl_p(p++, 0x3c09a000); /* lui $9, 0xa000 */
stl_p(p++, 0x01094025); /* or $8, $9 */
stl_p(p++, 0x3c0a0000 | (cm_base >> 16)); /* lui $10, cm_base >> 16 */
if (is_64b) {
stl_p(p++, 0xfd0a0008); /* sd $10, 0x8($8) */
} else {
stl_p(p++, 0xad0a0008); /* sw $10, 0x8($8) */
}
stl_p(p++, 0x012a4025); /* or $8, $10 */
/* Move & enable GIC GCRs */
stl_p(p++, 0x3c090000 | (gic_base >> 16)); /* lui $9, gic_base >> 16 */
stl_p(p++, 0x35290001); /* ori $9, 0x1 */
if (is_64b) {
stl_p(p++, 0xfd090080); /* sd $9, 0x80($8) */
} else {
stl_p(p++, 0xad090080); /* sw $9, 0x80($8) */
}
/* Move & enable CPC GCRs */
stl_p(p++, 0x3c090000 | (cpc_base >> 16)); /* lui $9, cpc_base >> 16 */
stl_p(p++, 0x35290001); /* ori $9, 0x1 */
if (is_64b) {
stl_p(p++, 0xfd090088); /* sd $9, 0x88($8) */
} else {
stl_p(p++, 0xad090088); /* sw $9, 0x88($8) */
}
/*
* Setup argument registers to follow the UHI boot protocol:
*
* a0/$4 = -2
* a1/$5 = virtual address of FDT
* a2/$6 = 0
* a3/$7 = 0
*/
stl_p(p++, 0x2404fffe); /* li $4, -2 */
/* lui $5, hi(fdt_addr) */
stl_p(p++, 0x3c050000 | ((fdt_addr >> 16) & 0xffff));
if (fdt_addr & 0xffff) { /* ori $5, lo(fdt_addr) */
stl_p(p++, 0x34a50000 | (fdt_addr & 0xffff));
}
stl_p(p++, 0x34060000); /* li $6, 0 */
stl_p(p++, 0x34070000); /* li $7, 0 */
/* Load kernel entry address & jump to it */
/* lui $25, hi(kernel_entry) */
stl_p(p++, 0x3c190000 | ((kernel_entry >> 16) & 0xffff));
/* ori $25, lo(kernel_entry) */
stl_p(p++, 0x37390000 | (kernel_entry & 0xffff));
stl_p(p++, 0x03200009); /* jr $25 */
}
| 11,221 |
FFmpeg | 9ea242962c4093a5523deef124a98193bbb36730 | 1 | Jpeg2000TgtNode *ff_j2k_tag_tree_init(int w, int h)
{
int pw = w, ph = h;
Jpeg2000TgtNode *res, *t, *t2;
int32_t tt_size;
tt_size = tag_tree_size(w, h);
t = res = av_mallocz(tt_size, sizeof(*t));
if (!res)
return NULL;
while (w > 1 || h > 1) {
int i, j;
pw = w;
ph = h;
w = (w + 1) >> 1;
h = (h + 1) >> 1;
t2 = t + pw * ph;
for (i = 0; i < ph; i++)
for (j = 0; j < pw; j++)
t[i * pw + j].parent = &t2[(i >> 1) * w + (j >> 1)];
t = t2;
}
t[0].parent = NULL;
return res;
}
| 11,222 |
qemu | 8c0a6dc96cd14c48da4a61fe35431f36d6e6e467 | 1 | static void test_hmac_speed(const void *opaque)
{
size_t chunk_size = (size_t)opaque;
QCryptoHmac *hmac = NULL;
uint8_t *in = NULL, *out = NULL;
size_t out_len = 0;
double total = 0.0;
struct iovec iov;
Error *err = NULL;
int ret;
if (!qcrypto_hmac_supports(QCRYPTO_HASH_ALG_SHA256)) {
return;
}
in = g_new0(uint8_t, chunk_size);
memset(in, g_test_rand_int(), chunk_size);
iov.iov_base = (char *)in;
iov.iov_len = chunk_size;
g_test_timer_start();
do {
hmac = qcrypto_hmac_new(QCRYPTO_HASH_ALG_SHA256,
(const uint8_t *)KEY, strlen(KEY), &err);
g_assert(err == NULL);
g_assert(hmac != NULL);
ret = qcrypto_hmac_bytesv(hmac, &iov, 1, &out, &out_len, &err);
g_assert(ret == 0);
g_assert(err == NULL);
qcrypto_hmac_free(hmac);
total += chunk_size;
} while (g_test_timer_elapsed() < 5.0);
total /= 1024 * 1024; /* to MB */
g_print("hmac(sha256): ");
g_print("Testing chunk_size %ld bytes ", chunk_size);
g_print("done: %.2f MB in %.2f secs: ", total, g_test_timer_last());
g_print("%.2f MB/sec\n", total / g_test_timer_last());
g_free(out);
g_free(in);
}
| 11,223 |
FFmpeg | d98364edcedb71662cb1761bd30d67053d60a3c6 | 1 | static int smush_read_packet(AVFormatContext *ctx, AVPacket *pkt)
{
SMUSHContext *smush = ctx->priv_data;
AVIOContext *pb = ctx->pb;
int done = 0;
while (!done) {
uint32_t sig, size;
if (url_feof(pb))
return AVERROR_EOF;
sig = avio_rb32(pb);
size = avio_rb32(pb);
switch (sig) {
case MKBETAG('F', 'R', 'M', 'E'):
if (smush->version)
break;
if (av_get_packet(pb, pkt, size) < 0)
return AVERROR(EIO);
pkt->stream_index = smush->video_stream_index;
done = 1;
break;
case MKBETAG('B', 'l', '1', '6'):
if (av_get_packet(pb, pkt, size) < 0)
return AVERROR(EIO);
pkt->stream_index = smush->video_stream_index;
pkt->duration = 1;
done = 1;
break;
case MKBETAG('W', 'a', 'v', 'e'):
if (size < 13)
return AVERROR_INVALIDDATA;
if (av_get_packet(pb, pkt, size) < 0)
return AVERROR(EIO);
pkt->stream_index = smush->audio_stream_index;
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->duration = AV_RB32(pkt->data);
if (pkt->duration == 0xFFFFFFFFu)
pkt->duration = AV_RB32(pkt->data + 8);
done = 1;
break;
default:
avio_skip(pb, size);
break;
}
}
return 0;
}
| 11,224 |
FFmpeg | 486637af8ef29ec215e0e0b7ecd3b5470f0e04e5 | 0 | static inline void mix_dualmono_to_stereo(AC3DecodeContext *ctx)
{
int i;
float tmp;
float (*output)[256] = ctx->audio_block.block_output;
for (i = 0; i < 256; i++) {
tmp = output[1][i] + output[2][i];
output[1][i] = output[2][i] = tmp;
}
}
| 11,225 |
FFmpeg | 143685a42bbc8861b626457ce4cb8b1ce4b0c436 | 0 | static OSStatus ffat_encode_callback(AudioConverterRef converter, UInt32 *nb_packets,
AudioBufferList *data,
AudioStreamPacketDescription **packets,
void *inctx)
{
AVCodecContext *avctx = inctx;
ATDecodeContext *at = avctx->priv_data;
if (at->eof) {
*nb_packets = 0;
return 0;
}
av_frame_unref(&at->in_frame);
av_frame_move_ref(&at->in_frame, &at->new_in_frame);
if (!at->in_frame.data[0]) {
*nb_packets = 0;
return 1;
}
data->mNumberBuffers = 1;
data->mBuffers[0].mNumberChannels = avctx->channels;
data->mBuffers[0].mDataByteSize = at->in_frame.nb_samples *
av_get_bytes_per_sample(avctx->sample_fmt) *
avctx->channels;
data->mBuffers[0].mData = at->in_frame.data[0];
if (*nb_packets > at->in_frame.nb_samples)
*nb_packets = at->in_frame.nb_samples;
return 0;
}
| 11,226 |
FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | 1 | void rgb16tobgr16(const uint8_t *src, uint8_t *dst, long src_size)
{
long i;
long num_pixels = src_size >> 1;
for(i=0; i<num_pixels; i++)
{
unsigned b,g,r;
register uint16_t rgb;
rgb = src[2*i];
r = rgb&0x1F;
g = (rgb&0x7E0)>>5;
b = (rgb&0xF800)>>11;
dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);
}
}
| 11,227 |
qemu | 3e4f910c8d490a1490409a7e381dbbb229f9d272 | 1 | static uint32_t ehci_mem_readl(void *ptr, target_phys_addr_t addr)
{
EHCIState *s = ptr;
uint32_t val;
val = s->mmio[addr] | (s->mmio[addr+1] << 8) |
(s->mmio[addr+2] << 16) | (s->mmio[addr+3] << 24);
trace_usb_ehci_mmio_readl(addr, addr2str(addr), val);
return val;
}
| 11,228 |
qemu | fcf73f66a67f5e58c18216f8c8651e38cf4d90af | 1 | static void qmp_input_type_number(Visitor *v, double *obj, const char *name,
Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (!qobj || (qobject_type(qobj) != QTYPE_QFLOAT &&
qobject_type(qobj) != QTYPE_QINT)) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"number");
return;
}
if (qobject_type(qobj) == QTYPE_QINT) {
*obj = qint_get_int(qobject_to_qint(qobj));
} else {
*obj = qfloat_get_double(qobject_to_qfloat(qobj));
}
}
| 11,229 |
qemu | 88be7b4be4aa17c88247e162bdd7577ea79db94f | 1 | int bdrv_all_find_snapshot(const char *name, BlockDriverState **first_bad_bs)
{
QEMUSnapshotInfo sn;
int err = 0;
BlockDriverState *bs;
BdrvNextIterator *it = NULL;
while (err == 0 && (it = bdrv_next(it, &bs))) {
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
if (bdrv_can_snapshot(bs)) {
err = bdrv_snapshot_find(bs, &sn, name);
}
aio_context_release(ctx);
}
*first_bad_bs = bs;
return err;
}
| 11,230 |
qemu | 81145834d39897c6f153ac26a4077f90f269c5fc | 1 | static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, int *num_same)
{
int changed;
if (nb_sectors == 0) {
*num_same = nb_sectors;
return 0;
}
changed = is_bit_set(bs, sector_num);
if (changed < 0) {
return 0; /* XXX: how to return I/O errors? */
}
for (*num_same = 1; *num_same < nb_sectors; (*num_same)++) {
if (is_bit_set(bs, sector_num + *num_same) != changed)
break;
}
return changed;
}
| 11,231 |
qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | 1 | static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
{
TranslationBlock *tb;
tb = ctx->tb;
if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {
if (n == 0)
gen_op_goto_tb0(TBPARAM(tb));
else
gen_op_goto_tb1(TBPARAM(tb));
gen_op_set_T1(dest);
gen_op_b_T1();
gen_op_set_T0((long)tb + n);
if (ctx->singlestep_enabled)
gen_op_debug();
gen_op_exit_tb();
} else {
gen_op_set_T1(dest);
gen_op_b_T1();
gen_op_reset_T0();
if (ctx->singlestep_enabled)
gen_op_debug();
gen_op_exit_tb();
}
}
| 11,232 |
qemu | c01dbccbad647be5784be39eb8fa0144732295db | 1 | int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
{
BDRVQcowState *s = bs->opaque;
int i, j = 0, l2_index, ret;
uint64_t *old_cluster, *l2_table;
uint64_t cluster_offset = m->alloc_offset;
trace_qcow2_cluster_link_l2(qemu_coroutine_self(), m->nb_clusters);
assert(m->nb_clusters > 0);
old_cluster = g_malloc(m->nb_clusters * sizeof(uint64_t));
/* copy content of unmodified sectors */
ret = perform_cow(bs, m, &m->cow_start);
if (ret < 0) {
goto err;
}
ret = perform_cow(bs, m, &m->cow_end);
if (ret < 0) {
goto err;
}
/* Update L2 table. */
if (s->use_lazy_refcounts) {
qcow2_mark_dirty(bs);
}
if (qcow2_need_accurate_refcounts(s)) {
qcow2_cache_set_dependency(bs, s->l2_table_cache,
s->refcount_block_cache);
}
ret = get_cluster_table(bs, m->offset, &l2_table, &l2_index);
if (ret < 0) {
goto err;
}
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
for (i = 0; i < m->nb_clusters; i++) {
/* if two concurrent writes happen to the same unallocated cluster
* each write allocates separate cluster and writes data concurrently.
* The first one to complete updates l2 table with pointer to its
* cluster the second one has to do RMW (which is done above by
* copy_sectors()), update l2 table with its cluster pointer and free
* old cluster. This is what this loop does */
if(l2_table[l2_index + i] != 0)
old_cluster[j++] = l2_table[l2_index + i];
l2_table[l2_index + i] = cpu_to_be64((cluster_offset +
(i << s->cluster_bits)) | QCOW_OFLAG_COPIED);
}
ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
if (ret < 0) {
goto err;
}
/*
* If this was a COW, we need to decrease the refcount of the old cluster.
* Also flush bs->file to get the right order for L2 and refcount update.
*
* Don't discard clusters that reach a refcount of 0 (e.g. compressed
* clusters), the next write will reuse them anyway.
*/
if (j != 0) {
for (i = 0; i < j; i++) {
qcow2_free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1,
QCOW2_DISCARD_NEVER);
}
}
ret = 0;
err:
g_free(old_cluster);
return ret;
} | 11,233 |
FFmpeg | ac4b32df71bd932838043a4838b86d11e169707f | 1 | int ff_vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
VP8Context *s = avctx->priv_data;
int ret, i, referenced, num_jobs;
enum AVDiscard skip_thresh;
VP8Frame *av_uninit(curframe), *prev_frame;
if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0)
goto err;
prev_frame = s->framep[VP56_FRAME_CURRENT];
referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT ||
s->update_altref == VP56_FRAME_CURRENT;
skip_thresh = !referenced ? AVDISCARD_NONREF
: !s->keyframe ? AVDISCARD_NONKEY
: AVDISCARD_ALL;
if (avctx->skip_frame >= skip_thresh) {
s->invisible = 1;
memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4);
goto skip_decode;
}
s->deblock_filter = s->filter.level && avctx->skip_loop_filter < skip_thresh;
// release no longer referenced frames
for (i = 0; i < 5; i++)
if (s->frames[i].tf.f->data[0] &&
&s->frames[i] != prev_frame &&
&s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] &&
&s->frames[i] != s->framep[VP56_FRAME_GOLDEN] &&
&s->frames[i] != s->framep[VP56_FRAME_GOLDEN2])
vp8_release_frame(s, &s->frames[i]);
// find a free buffer
for (i = 0; i < 5; i++)
if (&s->frames[i] != prev_frame &&
&s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] &&
&s->frames[i] != s->framep[VP56_FRAME_GOLDEN] &&
&s->frames[i] != s->framep[VP56_FRAME_GOLDEN2]) {
curframe = s->framep[VP56_FRAME_CURRENT] = &s->frames[i];
break;
}
if (i == 5) {
av_log(avctx, AV_LOG_FATAL, "Ran out of free frames!\n");
abort();
}
if (curframe->tf.f->data[0])
vp8_release_frame(s, curframe);
/* Given that arithmetic probabilities are updated every frame, it's quite
* likely that the values we have on a random interframe are complete
* junk if we didn't start decode on a keyframe. So just don't display
* anything rather than junk. */
if (!s->keyframe && (!s->framep[VP56_FRAME_PREVIOUS] ||
!s->framep[VP56_FRAME_GOLDEN] ||
!s->framep[VP56_FRAME_GOLDEN2])) {
av_log(avctx, AV_LOG_WARNING,
"Discarding interframe without a prior keyframe!\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
curframe->tf.f->key_frame = s->keyframe;
curframe->tf.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I
: AV_PICTURE_TYPE_P;
if ((ret = vp8_alloc_frame(s, curframe, referenced))) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed!\n");
goto err;
}
// check if golden and altref are swapped
if (s->update_altref != VP56_FRAME_NONE)
s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[s->update_altref];
else
s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[VP56_FRAME_GOLDEN2];
if (s->update_golden != VP56_FRAME_NONE)
s->next_framep[VP56_FRAME_GOLDEN] = s->framep[s->update_golden];
else
s->next_framep[VP56_FRAME_GOLDEN] = s->framep[VP56_FRAME_GOLDEN];
if (s->update_last)
s->next_framep[VP56_FRAME_PREVIOUS] = curframe;
else
s->next_framep[VP56_FRAME_PREVIOUS] = s->framep[VP56_FRAME_PREVIOUS];
s->next_framep[VP56_FRAME_CURRENT] = curframe;
ff_thread_finish_setup(avctx);
s->linesize = curframe->tf.f->linesize[0];
s->uvlinesize = curframe->tf.f->linesize[1];
memset(s->top_nnz, 0, s->mb_width * sizeof(*s->top_nnz));
/* Zero macroblock structures for top/top-left prediction
* from outside the frame. */
if (!s->mb_layout)
memset(s->macroblocks + s->mb_height * 2 - 1, 0,
(s->mb_width + 1) * sizeof(*s->macroblocks));
if (!s->mb_layout && s->keyframe)
memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width * 4);
memset(s->ref_count, 0, sizeof(s->ref_count));
if (s->mb_layout == 1) {
// Make sure the previous frame has read its segmentation map,
// if we re-use the same map.
if (prev_frame && s->segmentation.enabled &&
!s->segmentation.update_map)
ff_thread_await_progress(&prev_frame->tf, 1, 0);
vp8_decode_mv_mb_modes(avctx, curframe, prev_frame);
}
if (avctx->active_thread_type == FF_THREAD_FRAME)
num_jobs = 1;
else
num_jobs = FFMIN(s->num_coeff_partitions, avctx->thread_count);
s->num_jobs = num_jobs;
s->curframe = curframe;
s->prev_frame = prev_frame;
s->mv_min.y = -MARGIN;
s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;
for (i = 0; i < MAX_THREADS; i++) {
s->thread_data[i].thread_mb_pos = 0;
s->thread_data[i].wait_mb_pos = INT_MAX;
}
avctx->execute2(avctx, vp8_decode_mb_row_sliced,
s->thread_data, NULL, num_jobs);
ff_thread_report_progress(&curframe->tf, INT_MAX, 0);
memcpy(&s->framep[0], &s->next_framep[0], sizeof(s->framep[0]) * 4);
skip_decode:
// if future frames don't use the updated probabilities,
// reset them to the values we saved
if (!s->update_probabilities)
s->prob[0] = s->prob[1];
if (!s->invisible) {
if ((ret = av_frame_ref(data, curframe->tf.f)) < 0)
return ret;
*got_frame = 1;
}
return avpkt->size;
err:
memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4);
return ret;
}
| 11,234 |
qemu | cbd8acf38f37544b830086af840bfb1015ce10e0 | 1 | static void test_visitor_in_null(TestInputVisitorData *data,
const void *unused)
{
Visitor *v;
Error *err = NULL;
char *tmp;
/*
* FIXME: Since QAPI doesn't know the 'null' type yet, we can't
* test visit_type_null() by reading into a QAPI struct then
* checking that it was populated correctly. The best we can do
* for now is ensure that we consumed null from the input, proven
* by the fact that we can't re-read the key; and that we detect
* when input is not null.
*/
v = visitor_input_test_init(data, "{ 'a': null, 'b': '', 'c': null }");
visit_start_struct(v, NULL, NULL, 0, &error_abort);
visit_type_null(v, "a", &error_abort);
visit_type_null(v, "b", &err);
error_free_or_abort(&err);
visit_type_str(v, "c", &tmp, &err);
g_assert(!tmp);
error_free_or_abort(&err);
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
}
| 11,236 |
FFmpeg | c6a905b91d935f78f5c33f6ce2dbe294b3353b77 | 1 | static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
{
DNXHDContext *ctx = avctx->priv_data;
ctx->avctx = avctx;
ctx->cid = -1;
avctx->colorspace = AVCOL_SPC_BT709;
avctx->coded_width = FFALIGN(avctx->width, 16);
avctx->coded_height = FFALIGN(avctx->height, 16);
ctx->rows = av_mallocz_array(avctx->thread_count, sizeof(RowContext));
if (!ctx->rows)
return AVERROR(ENOMEM);
return 0;
}
| 11,237 |
qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | 1 | static int usb_net_handle_statusin(USBNetState *s, USBPacket *p)
{
int ret = 8;
if (p->len < 8)
return USB_RET_STALL;
((le32 *) p->data)[0] = cpu_to_le32(1);
((le32 *) p->data)[1] = cpu_to_le32(0);
if (!s->rndis_resp.tqh_first)
ret = USB_RET_NAK;
#ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: interrupt poll len %u return %d", p->len, ret);
{
int i;
fprintf(stderr, ":");
for (i = 0; i < ret; i++) {
if (!(i & 15))
fprintf(stderr, "\n%04x:", i);
fprintf(stderr, " %02x", p->data[i]);
}
fprintf(stderr, "\n\n");
}
#endif
return ret;
}
| 11,238 |
FFmpeg | fc49f22c3b735db5aaac5f98e40b7124a2be13b8 | 1 | static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, int source_index)
{
int n;
AVStream *st;
OutputStream *ost;
AVCodecContext *audio_enc;
ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index);
st = ost->st;
audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
if (!ost->stream_copy) {
char *sample_fmt = NULL;
MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, oc, st);
MATCH_PER_STREAM_OPT(sample_fmts, str, sample_fmt, oc, st);
if (sample_fmt &&
(audio_enc->sample_fmt = av_get_sample_fmt(sample_fmt)) == AV_SAMPLE_FMT_NONE) {
av_log(NULL, AV_LOG_FATAL, "Invalid sample format '%s'\n", sample_fmt);
exit_program(1);
}
MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, st);
ost->rematrix_volume=1.0;
MATCH_PER_STREAM_OPT(rematrix_volume, f, ost->rematrix_volume, oc, st);
}
/* check for channel mapping for this audio stream */
for (n = 0; n < o->nb_audio_channel_maps; n++) {
AudioChannelMap *map = &o->audio_channel_maps[n];
InputStream *ist = input_streams[ost->source_index];
if ((map->channel_idx == -1 || (ist->file_index == map->file_idx && ist->st->index == map->stream_idx)) &&
(map->ofile_idx == -1 || ost->file_index == map->ofile_idx) &&
(map->ostream_idx == -1 || ost->st->index == map->ostream_idx)) {
if (ost->audio_channels_mapped < FF_ARRAY_ELEMS(ost->audio_channels_map))
ost->audio_channels_map[ost->audio_channels_mapped++] = map->channel_idx;
else
av_log(NULL, AV_LOG_FATAL, "Max channel mapping for output %d.%d reached\n",
ost->file_index, ost->st->index);
}
}
return ost;
}
| 11,239 |
FFmpeg | 1e3f77b53a803a6c63fa64829f1be557b8226288 | 1 | static void RENAME(uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
int width, int height,
int lumStride, int chromStride, int srcStride)
{
int y;
const int chromWidth = FF_CEIL_RSHIFT(width, 1);
for (y=0; y<height; y++) {
RENAME(extract_even)(src+1, ydst, width);
RENAME(extract_even2)(src, udst, vdst, chromWidth);
src += srcStride;
ydst+= lumStride;
udst+= chromStride;
vdst+= chromStride;
}
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
}
| 11,240 |
qemu | 4d1628e832dfc6ec02b0d196f6cc250aaa7bf3b3 | 1 | uint64_t helper_subqv(CPUAlphaState *env, uint64_t op1, uint64_t op2)
{
uint64_t res;
res = op1 - op2;
if (unlikely((op1 ^ op2) & (res ^ op1) & (1ULL << 63))) {
arith_excp(env, GETPC(), EXC_M_IOV, 0);
}
return res;
}
| 11,242 |
FFmpeg | 478f1c3d5e5463a284ea7efecfc62d47ba3be11a | 1 | static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
uint32_t length, AVFrame *p)
{
int ret;
size_t byte_depth = s->bit_depth > 8 ? 2 : 1;
if (!(s->state & PNG_IHDR)) {
av_log(avctx, AV_LOG_ERROR, "IDAT without IHDR\n");
return AVERROR_INVALIDDATA;
}
if (!(s->state & PNG_IDAT)) {
/* init image info */
avctx->width = s->width;
avctx->height = s->height;
s->channels = ff_png_get_nb_channels(s->color_type);
s->bits_per_pixel = s->bit_depth * s->channels;
s->bpp = (s->bits_per_pixel + 7) >> 3;
s->row_size = (s->cur_w * s->bits_per_pixel + 7) >> 3;
if ((s->bit_depth == 2 || s->bit_depth == 4 || s->bit_depth == 8) &&
s->color_type == PNG_COLOR_TYPE_RGB) {
avctx->pix_fmt = AV_PIX_FMT_RGB24;
} else if ((s->bit_depth == 2 || s->bit_depth == 4 || s->bit_depth == 8) &&
s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
avctx->pix_fmt = AV_PIX_FMT_RGBA;
} else if ((s->bit_depth == 2 || s->bit_depth == 4 || s->bit_depth == 8) &&
s->color_type == PNG_COLOR_TYPE_GRAY) {
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
} else if (s->bit_depth == 16 &&
s->color_type == PNG_COLOR_TYPE_GRAY) {
avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
} else if (s->bit_depth == 16 &&
s->color_type == PNG_COLOR_TYPE_RGB) {
avctx->pix_fmt = AV_PIX_FMT_RGB48BE;
} else if (s->bit_depth == 16 &&
s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
avctx->pix_fmt = AV_PIX_FMT_RGBA64BE;
} else if ((s->bits_per_pixel == 1 || s->bits_per_pixel == 2 || s->bits_per_pixel == 4 || s->bits_per_pixel == 8) &&
s->color_type == PNG_COLOR_TYPE_PALETTE) {
avctx->pix_fmt = AV_PIX_FMT_PAL8;
} else if (s->bit_depth == 1 && s->bits_per_pixel == 1 && avctx->codec_id != AV_CODEC_ID_APNG) {
avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
} else if (s->bit_depth == 8 &&
s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
avctx->pix_fmt = AV_PIX_FMT_YA8;
} else if (s->bit_depth == 16 &&
s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
avctx->pix_fmt = AV_PIX_FMT_YA16BE;
} else {
av_log(avctx, AV_LOG_ERROR, "unsupported bit depth %d "
"and color type %d\n",
s->bit_depth, s->color_type);
return AVERROR_INVALIDDATA;
}
if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE) {
switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGB24:
avctx->pix_fmt = AV_PIX_FMT_RGBA;
break;
case AV_PIX_FMT_RGB48BE:
avctx->pix_fmt = AV_PIX_FMT_RGBA64BE;
break;
case AV_PIX_FMT_GRAY8:
avctx->pix_fmt = AV_PIX_FMT_YA8;
break;
case AV_PIX_FMT_GRAY16BE:
avctx->pix_fmt = AV_PIX_FMT_YA16BE;
break;
default:
avpriv_request_sample(avctx, "bit depth %d "
"and color type %d with TRNS",
s->bit_depth, s->color_type);
return AVERROR_INVALIDDATA;
}
s->bpp += byte_depth;
}
if ((ret = ff_thread_get_buffer(avctx, &s->picture, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
if (avctx->codec_id == AV_CODEC_ID_APNG && s->last_dispose_op != APNG_DISPOSE_OP_PREVIOUS) {
ff_thread_release_buffer(avctx, &s->previous_picture);
if ((ret = ff_thread_get_buffer(avctx, &s->previous_picture, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
}
ff_thread_finish_setup(avctx);
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
p->interlaced_frame = !!s->interlace_type;
/* compute the compressed row size */
if (!s->interlace_type) {
s->crow_size = s->row_size + 1;
} else {
s->pass = 0;
s->pass_row_size = ff_png_pass_row_size(s->pass,
s->bits_per_pixel,
s->cur_w);
s->crow_size = s->pass_row_size + 1;
}
ff_dlog(avctx, "row_size=%d crow_size =%d\n",
s->row_size, s->crow_size);
s->image_buf = p->data[0];
s->image_linesize = p->linesize[0];
/* copy the palette if needed */
if (avctx->pix_fmt == AV_PIX_FMT_PAL8)
memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t));
/* empty row is used if differencing to the first row */
av_fast_padded_mallocz(&s->last_row, &s->last_row_size, s->row_size);
if (!s->last_row)
return AVERROR_INVALIDDATA;
if (s->interlace_type ||
s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
av_fast_padded_malloc(&s->tmp_row, &s->tmp_row_size, s->row_size);
if (!s->tmp_row)
return AVERROR_INVALIDDATA;
}
/* compressed row */
av_fast_padded_malloc(&s->buffer, &s->buffer_size, s->row_size + 16);
if (!s->buffer)
return AVERROR(ENOMEM);
/* we want crow_buf+1 to be 16-byte aligned */
s->crow_buf = s->buffer + 15;
s->zstream.avail_out = s->crow_size;
s->zstream.next_out = s->crow_buf;
}
s->state |= PNG_IDAT;
/* set image to non-transparent bpp while decompressing */
if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE)
s->bpp -= byte_depth;
ret = png_decode_idat(s, length);
if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE)
s->bpp += byte_depth;
if (ret < 0)
return ret;
bytestream2_skip(&s->gb, 4); /* crc */
return 0;
}
| 11,243 |
qemu | 503b3b33feca818baa4459aba286e54a528e5567 | 1 | static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)
{
VGACommonState *vga = &qxl->vga;
DisplaySurface *surface;
int i;
if (qxl->guest_primary.resized) {
qxl->guest_primary.resized = 0;
qxl->guest_primary.data = qxl_phys2virt(qxl,
qxl->guest_primary.surface.mem,
MEMSLOT_GROUP_GUEST);
if (!qxl->guest_primary.data) {
return;
}
qxl_set_rect_to_surface(qxl, &qxl->dirty[0]);
qxl->num_dirty_rects = 1;
trace_qxl_render_guest_primary_resized(
qxl->guest_primary.surface.width,
qxl->guest_primary.surface.height,
qxl->guest_primary.qxl_stride,
qxl->guest_primary.bytes_pp,
qxl->guest_primary.bits_pp);
if (qxl->guest_primary.qxl_stride > 0) {
surface = qemu_create_displaysurface_from
(qxl->guest_primary.surface.width,
qxl->guest_primary.surface.height,
qxl->guest_primary.bits_pp,
qxl->guest_primary.abs_stride,
qxl->guest_primary.data,
false);
} else {
surface = qemu_create_displaysurface
(qxl->guest_primary.surface.width,
qxl->guest_primary.surface.height);
}
dpy_gfx_replace_surface(vga->con, surface);
}
if (!qxl->guest_primary.data) {
return;
}
for (i = 0; i < qxl->num_dirty_rects; i++) {
if (qemu_spice_rect_is_empty(qxl->dirty+i)) {
break;
}
if (qxl->dirty[i].left > qxl->dirty[i].right ||
qxl->dirty[i].top > qxl->dirty[i].bottom ||
qxl->dirty[i].right > qxl->guest_primary.surface.width ||
qxl->dirty[i].bottom > qxl->guest_primary.surface.height) {
continue;
}
qxl_blit(qxl, qxl->dirty+i);
dpy_gfx_update(vga->con,
qxl->dirty[i].left, qxl->dirty[i].top,
qxl->dirty[i].right - qxl->dirty[i].left,
qxl->dirty[i].bottom - qxl->dirty[i].top);
}
qxl->num_dirty_rects = 0;
}
| 11,244 |
qemu | 4abc796d41ee01a698032e74ac17c1cdc5d290c3 | 1 | void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,
ram_addr_t vga_ram_offset, int vga_ram_size)
{
int i, j, v, b;
for(i = 0;i < 256; i++) {
v = 0;
for(j = 0; j < 8; j++) {
v |= ((i >> j) & 1) << (j * 4);
}
expand4[i] = v;
v = 0;
for(j = 0; j < 4; j++) {
v |= ((i >> (2 * j)) & 3) << (j * 4);
}
expand2[i] = v;
}
for(i = 0; i < 16; i++) {
v = 0;
for(j = 0; j < 4; j++) {
b = ((i >> j) & 1);
v |= b << (2 * j);
v |= b << (2 * j + 1);
}
expand4to8[i] = v;
}
s->vram_ptr = vga_ram_base;
s->vram_offset = vga_ram_offset;
s->vram_size = vga_ram_size;
s->ds = ds;
s->get_bpp = vga_get_bpp;
s->get_offsets = vga_get_offsets;
s->get_resolution = vga_get_resolution;
s->update = vga_update_display;
s->invalidate = vga_invalidate_display;
s->screen_dump = vga_screen_dump;
s->text_update = vga_update_text;
switch (vga_retrace_method) {
case VGA_RETRACE_DUMB:
s->retrace = vga_dumb_retrace;
s->update_retrace_info = vga_dumb_update_retrace_info;
break;
case VGA_RETRACE_PRECISE:
s->retrace = vga_precise_retrace;
s->update_retrace_info = vga_precise_update_retrace_info;
break;
}
qemu_register_reset(vga_reset, s);
vga_reset(s);
}
| 11,245 |
FFmpeg | 81ef5192529dd9ff6b7dc34b6528b9d8dafdd100 | 1 | static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
const uint8_t *buf, int len)
{
unsigned int ssrc, h;
int payload_type, seq, ret, flags = 0;
int ext;
AVStream *st;
uint32_t timestamp;
int rv = 0;
ext = buf[0] & 0x10;
payload_type = buf[1] & 0x7f;
if (buf[1] & 0x80)
flags |= RTP_FLAG_MARKER;
seq = AV_RB16(buf + 2);
timestamp = AV_RB32(buf + 4);
ssrc = AV_RB32(buf + 8);
/* store the ssrc in the RTPDemuxContext */
s->ssrc = ssrc;
/* NOTE: we can handle only one payload type */
if (s->payload_type != payload_type)
return -1;
st = s->st;
// only do something with this if all the rtp checks pass...
if (!rtp_valid_packet_in_sequence(&s->statistics, seq)) {
av_log(st ? st->codec : NULL, AV_LOG_ERROR,
"RTP: PT=%02x: bad cseq %04x expected=%04x\n",
payload_type, seq, ((s->seq + 1) & 0xffff));
return -1;
}
if (buf[0] & 0x20) {
int padding = buf[len - 1];
if (len >= 12 + padding)
len -= padding;
}
s->seq = seq;
len -= 12;
buf += 12;
/* RFC 3550 Section 5.3.1 RTP Header Extension handling */
if (ext) {
if (len < 4)
return -1;
/* calculate the header extension length (stored as number
* of 32-bit words) */
ext = (AV_RB16(buf + 2) + 1) << 2;
if (len < ext)
return -1;
// skip past RTP header extension
len -= ext;
buf += ext;
}
if (!st) {
/* specific MPEG2-TS demux support */
ret = ff_mpegts_parse_packet(s->ts, pkt, buf, len);
/* The only error that can be returned from ff_mpegts_parse_packet
* is "no more data to return from the provided buffer", so return
* AVERROR(EAGAIN) for all errors */
if (ret < 0)
return AVERROR(EAGAIN);
if (ret < len) {
s->read_buf_size = len - ret;
memcpy(s->buf, buf + ret, s->read_buf_size);
s->read_buf_index = 0;
return 1;
}
return 0;
} else if (s->parse_packet) {
rv = s->parse_packet(s->ic, s->dynamic_protocol_context,
s->st, pkt, ×tamp, buf, len, flags);
} else {
/* At this point, the RTP header has been stripped;
* This is ASSUMING that there is only 1 CSRC, which isn't wise. */
switch (st->codec->codec_id) {
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
/* better than nothing: skip MPEG audio RTP header */
if (len <= 4)
return -1;
h = AV_RB32(buf);
len -= 4;
buf += 4;
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
/* better than nothing: skip MPEG video RTP header */
if (len <= 4)
return -1;
h = AV_RB32(buf);
buf += 4;
len -= 4;
if (h & (1 << 26)) {
/* MPEG-2 */
if (len <= 4)
return -1;
buf += 4;
len -= 4;
}
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
break;
default:
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
break;
}
pkt->stream_index = st->index;
}
// now perform timestamp things....
finalize_packet(s, pkt, timestamp);
return rv;
}
| 11,246 |
FFmpeg | d381249bb86d5a4b1a99bb292a7aed034d6d12de | 1 | static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *buf, const uint8_t *end_buf)
{
int tag, type, count, off, value = 0;
int i, j;
uint32_t *pal;
const uint8_t *rp, *gp, *bp;
tag = tget_short(&buf, s->le);
type = tget_short(&buf, s->le);
count = tget_long(&buf, s->le);
off = tget_long(&buf, s->le);
if(count == 1){
switch(type){
case TIFF_BYTE:
case TIFF_SHORT:
buf -= 4;
value = tget(&buf, type, s->le);
buf = NULL;
break;
case TIFF_LONG:
value = off;
buf = NULL;
break;
case TIFF_STRING:
if(count <= 4){
buf -= 4;
break;
}
default:
value = -1;
buf = start + off;
}
}else if(type_sizes[type] * count <= 4){
buf -= 4;
}else{
buf = start + off;
}
if(buf && (buf < start || buf > end_buf)){
av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n");
return -1;
}
switch(tag){
case TIFF_WIDTH:
s->width = value;
break;
case TIFF_HEIGHT:
s->height = value;
break;
case TIFF_BPP:
if(count == 1) s->bpp = value;
else{
switch(type){
case TIFF_BYTE:
s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) + ((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
s->bpp = 0;
for(i = 0; i < count; i++) s->bpp += tget(&buf, type, s->le);
break;
default:
s->bpp = -1;
}
}
if(count > 4){
av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);
return -1;
}
switch(s->bpp*10 + count){
case 11:
s->avctx->pix_fmt = PIX_FMT_MONOBLACK;
break;
case 81:
s->avctx->pix_fmt = PIX_FMT_PAL8;
break;
case 243:
s->avctx->pix_fmt = PIX_FMT_RGB24;
break;
case 161:
s->avctx->pix_fmt = PIX_FMT_GRAY16BE;
break;
case 324:
s->avctx->pix_fmt = PIX_FMT_RGBA;
break;
case 483:
s->avctx->pix_fmt = s->le ? PIX_FMT_RGB48LE : PIX_FMT_RGB48BE;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);
return -1;
}
if(s->width != s->avctx->width || s->height != s->avctx->height){
if(av_image_check_size(s->width, s->height, 0, s->avctx))
return -1;
avcodec_set_dimensions(s->avctx, s->width, s->height);
}
if(s->picture.data[0])
s->avctx->release_buffer(s->avctx, &s->picture);
if(s->avctx->get_buffer(s->avctx, &s->picture) < 0){
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if(s->bpp == 8){
/* make default grayscale pal */
pal = (uint32_t *) s->picture.data[1];
for(i = 0; i < 256; i++)
pal[i] = i * 0x010101;
}
break;
case TIFF_COMPR:
s->compr = value;
s->predictor = 0;
switch(s->compr){
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
s->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return -1;
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
av_log(s->avctx, AV_LOG_ERROR, "JPEG compression is not supported\n");
return -1;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n", s->compr);
return -1;
}
break;
case TIFF_ROWSPERSTRIP:
if(type == TIFF_LONG && value == -1)
value = s->avctx->height;
if(value < 1){
av_log(s->avctx, AV_LOG_ERROR, "Incorrect value of rows per strip\n");
return -1;
}
s->rps = value;
break;
case TIFF_STRIP_OFFS:
if(count == 1){
s->stripdata = NULL;
s->stripoff = value;
}else
s->stripdata = start + off;
s->strips = count;
if(s->strips == 1) s->rps = s->height;
s->sot = type;
if(s->stripdata > end_buf){
av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_STRIP_SIZE:
if(count == 1){
s->stripsizes = NULL;
s->stripsize = value;
s->strips = 1;
}else{
s->stripsizes = start + off;
}
s->strips = count;
s->sstype = type;
if(s->stripsizes > end_buf){
av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_PREDICTOR:
s->predictor = value;
break;
case TIFF_INVERT:
switch(value){
case 0:
s->invert = 1;
break;
case 1:
s->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n", value);
return -1;
}
break;
case TIFF_FILL_ORDER:
if(value < 1 || value > 2){
av_log(s->avctx, AV_LOG_ERROR, "Unknown FillOrder value %d, trying default one\n", value);
value = 1;
}
s->fill_order = value - 1;
break;
case TIFF_PAL:
if(s->avctx->pix_fmt != PIX_FMT_PAL8){
av_log(s->avctx, AV_LOG_ERROR, "Palette met but this is not palettized format\n");
return -1;
}
pal = (uint32_t *) s->picture.data[1];
off = type_sizes[type];
rp = buf;
gp = buf + count / 3 * off;
bp = buf + count / 3 * off * 2;
off = (type_sizes[type] - 1) << 3;
for(i = 0; i < count / 3; i++){
j = (tget(&rp, type, s->le) >> off) << 16;
j |= (tget(&gp, type, s->le) >> off) << 8;
j |= tget(&bp, type, s->le) >> off;
pal[i] = j;
}
break;
case TIFF_PLANAR:
if(value == 2){
av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n");
return -1;
}
break;
case TIFF_T4OPTIONS:
if(s->compr == TIFF_G3)
s->fax_opts = value;
break;
case TIFF_T6OPTIONS:
if(s->compr == TIFF_G4)
s->fax_opts = value;
break;
}
return 0;
}
| 11,247 |
qemu | a1b3955c9415b1e767c130a2f59fee6aa28e575b | 1 | static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcowState *s = bs->opaque;
int len, i, ret = 0;
QCowHeader header;
QemuOpts *opts;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
const char *opt_overlap_check;
int overlap_check_template = 0;
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read qcow2 header");
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image is not in qcow2 format");
if (header.version < 2 || header.version > 3) {
report_unsupported(bs, errp, "QCOW version %d", header.version);
ret = -ENOTSUP;
s->qcow_version = header.version;
/* Initialise cluster size */
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(errp, "Unsupported cluster size: 2^%i", header.cluster_bits);
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
/* Initialise version 3 header fields */
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
if (header.header_length < 104) {
error_setg(errp, "qcow2 header too short");
if (header.header_length > s->cluster_size) {
error_setg(errp, "qcow2 header exceeds cluster size");
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
/* Handle feature bits */
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *feature_table = NULL;
qcow2_read_extensions(bs, header.header_length, ext_end,
&feature_table, NULL);
report_unsupported_feature(bs, errp, feature_table,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
ret = -ENOTSUP;
g_free(feature_table);
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
/* Corrupt images may not be written to unless they are being repaired
*/
if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {
error_setg(errp, "qcow2: Image is corrupt; cannot be opened "
"read/write");
ret = -EACCES;
/* Check support for various header values */
if (header.refcount_order != 4) {
report_unsupported(bs, errp, "%d bit reference counts",
1 << header.refcount_order);
ret = -ENOTSUP;
s->refcount_order = header.refcount_order;
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "Unsupported encryption method: %i",
header.crypt_method);
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
bs->encrypted = 1;
s->l2_bits = s->cluster_bits - 3; /* L2 is always one cluster */
s->l2_size = 1 << s->l2_bits;
bs->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
/* read the level 1 table */
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(errp, "Image is too big");
ret = -EFBIG;
s->l1_vm_state_index = l1_vm_state_index;
/* the L1 table must contain at least enough entries to put
header.size bytes */
if (s->l1_size < s->l1_vm_state_index) {
error_setg(errp, "L1 table is too small");
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = g_malloc0(
align_offset(s->l1_size * sizeof(uint64_t), 512));
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read L1 table");
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
/* alloc L2 table/refcount block cache */
s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE);
s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE);
s->cluster_cache = g_malloc(s->cluster_size);
/* one more sector for decompressed data alignment */
s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ 512);
s->cluster_cache_offset = -1;
s->flags = flags;
ret = qcow2_refcount_init(bs);
if (ret != 0) {
error_setg_errno(errp, -ret, "Could not initialize refcount handling");
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
/* read qcow2 extensions */
if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,
&local_err)) {
error_propagate(errp, local_err);
/* read the backing file name */
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > 1023) {
len = 1023;
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read backing file name");
bs->backing_file[len] = '\0';
ret = qcow2_read_snapshots(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read snapshots");
/* Clear unknown autoclear feature bits */
if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features) {
s->autoclear_features = 0;
ret = qcow2_update_header(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not update qcow2 header");
/* Initialise locks */
qemu_co_mutex_init(&s->lock);
/* Repair image if dirty */
if (!(flags & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !bs->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not repair dirty image");
/* Enable lazy_refcounts according to image and command line options */
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,
(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;
s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;
s->discard_passthrough[QCOW2_DISCARD_REQUEST] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,
flags & BDRV_O_UNMAP);
s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
opt_overlap_check = qemu_opt_get(opts, "overlap-check") ?: "cached";
if (!strcmp(opt_overlap_check, "none")) {
overlap_check_template = 0;
} else if (!strcmp(opt_overlap_check, "constant")) {
overlap_check_template = QCOW2_OL_CONSTANT;
} else if (!strcmp(opt_overlap_check, "cached")) {
overlap_check_template = QCOW2_OL_CACHED;
} else if (!strcmp(opt_overlap_check, "all")) {
overlap_check_template = QCOW2_OL_ALL;
} else {
error_setg(errp, "Unsupported value '%s' for qcow2 option "
"'overlap-check'. Allowed are either of the following: "
"none, constant, cached, all", opt_overlap_check);
qemu_opts_del(opts);
s->overlap_check = 0;
for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) {
/* overlap-check defines a template bitmask, but every flag may be
* overwritten through the associated boolean option */
s->overlap_check |=
qemu_opt_get_bool(opts, overlap_bool_option_names[i],
overlap_check_template & (1 << i)) << i;
qemu_opts_del(opts);
if (s->use_lazy_refcounts && s->qcow_version < 3) {
error_setg(errp, "Lazy refcounts require a qcow2 image with at least "
"qemu 1.1 compatibility level");
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result, 0);
#endif
return ret;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(bs);
qcow2_free_snapshots(bs);
qcow2_refcount_close(bs);
g_free(s->l1_table);
/* else pre-write overlap checks in cache_destroy may crash */
s->l1_table = NULL;
if (s->l2_table_cache) {
qcow2_cache_destroy(bs, s->l2_table_cache);
if (s->refcount_block_cache) {
qcow2_cache_destroy(bs, s->refcount_block_cache);
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
return ret; | 11,249 |
FFmpeg | b164d66e35d349de414e2f0d7365a147aba8a620 | 0 | static void ape_unpack_mono(APEContext *ctx, int count)
{
if (ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) {
/* We are pure silence, so we're done. */
av_log(ctx->avctx, AV_LOG_DEBUG, "pure silence mono\n");
return;
}
entropy_decode(ctx, count, 0);
ape_apply_filters(ctx, ctx->decoded[0], NULL, count);
/* Now apply the predictor decoding */
predictor_decode_mono(ctx, count);
/* Pseudo-stereo - just copy left channel to right channel */
if (ctx->channels == 2) {
memcpy(ctx->decoded[1], ctx->decoded[0], count * sizeof(*ctx->decoded[1]));
}
}
| 11,250 |
FFmpeg | 0058584580b87feb47898e60e4b80c7f425882ad | 0 | static int _do_bit_allocation(AC3DecodeContext *ctx, int chnl)
{
ac3_audio_block *ab = &ctx->audio_block;
int16_t sdecay, fdecay, sgain, dbknee, floor;
int16_t lowcomp, fgain, snroffset, fastleak, slowleak;
int16_t psd[256], bndpsd[50], excite[50], mask[50], delta;
uint8_t start, end, bin, i, j, k, lastbin, bndstrt, bndend, begin, deltnseg, band, seg, address;
uint8_t fscod = ctx->sync_info.fscod;
uint8_t *exps, *deltoffst, *deltlen, *deltba;
uint8_t *baps;
int do_delta = 0;
/* initialization */
sdecay = sdecaytab[ab->sdcycod];
fdecay = fdecaytab[ab->fdcycod];
sgain = sgaintab[ab->sgaincod];
dbknee = dbkneetab[ab->dbpbcod];
floor = floortab[ab->floorcod];
if (chnl == 5) {
start = ab->cplstrtmant;
end = ab->cplendmant;
fgain = fgaintab[ab->cplfgaincod];
snroffset = (((ab->csnroffst - 15) << 4) + ab->cplfsnroffst) << 2;
fastleak = (ab->cplfleak << 8) + 768;
slowleak = (ab->cplsleak << 8) + 768;
exps = ab->dcplexps;
baps = ab->cplbap;
if (ab->cpldeltbae == 0 || ab->cpldeltbae == 1) {
do_delta = 1;
deltnseg = ab->cpldeltnseg;
deltoffst = ab->cpldeltoffst;
deltlen = ab->cpldeltlen;
deltba = ab->cpldeltba;
}
}
else if (chnl == 6) {
start = 0;
end = 7;
lowcomp = 0;
fgain = fgaintab[ab->lfefgaincod];
snroffset = (((ab->csnroffst - 15) << 4) + ab->lfefsnroffst) << 2;
exps = ab->dlfeexps;
baps = ab->lfebap;
}
else {
start = 0;
end = ab->endmant[chnl];
lowcomp = 0;
fgain = fgaintab[ab->fgaincod[chnl]];
snroffset = (((ab->csnroffst - 15) << 4) + ab->fsnroffst[chnl]) << 2;
exps = ab->dexps[chnl];
baps = ab->bap[chnl];
if (ab->deltbae[chnl] == 0 || ab->deltbae[chnl] == 1) {
do_delta = 1;
deltnseg = ab->deltnseg[chnl];
deltoffst = ab->deltoffst[chnl];
deltlen = ab->deltlen[chnl];
deltba = ab->deltba[chnl];
}
}
for (bin = start; bin < end; bin++) /* exponent mapping into psd */
psd[bin] = (3072 - ((int16_t) (exps[bin] << 7)));
/* psd integration */
j = start;
k = masktab[start];
do {
lastbin = FFMIN(bndtab[k] + bndsz[k], end);
bndpsd[k] = psd[j];
j++;
for (i = j; i < lastbin; i++) {
bndpsd[k] = logadd(bndpsd[k], psd[j]);
j++;
}
k++;
} while (end > lastbin);
/* compute the excite function */
bndstrt = masktab[start];
bndend = masktab[end - 1] + 1;
if (bndstrt == 0) {
lowcomp = calc_lowcomp(lowcomp, bndpsd[0], bndpsd[1], 0);
excite[0] = bndpsd[0] - fgain - lowcomp;
lowcomp = calc_lowcomp(lowcomp, bndpsd[1], bndpsd[2], 1);
excite[1] = bndpsd[1] - fgain - lowcomp;
begin = 7;
for (bin = 2; bin < 7; bin++) {
if (bndend != 7 || bin != 6)
lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin + 1], bin);
fastleak = bndpsd[bin] - fgain;
slowleak = bndpsd[bin] - sgain;
excite[bin] = fastleak - lowcomp;
if (bndend != 7 || bin != 6)
if (bndpsd[bin] <= bndpsd[bin + 1]) {
begin = bin + 1;
break;
}
}
for (bin = begin; bin < (FFMIN(bndend, 22)); bin++) {
if (bndend != 7 || bin != 6)
lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin + 1], bin);
fastleak -= fdecay;
fastleak = FFMAX(fastleak, bndpsd[bin] - fgain);
slowleak -= sdecay;
slowleak = FFMAX(slowleak, bndpsd[bin] - sgain);
excite[bin] = FFMAX(fastleak - lowcomp, slowleak);
}
begin = 22;
}
else {
begin = bndstrt;
}
for (bin = begin; bin < bndend; bin++) {
fastleak -= fdecay;
fastleak = FFMAX(fastleak, bndpsd[bin] - fgain);
slowleak -= sdecay;
slowleak = FFMAX(slowleak, bndpsd[bin] - sgain);
excite[bin] = FFMAX(fastleak, slowleak);
}
/* compute the masking curve */
for (bin = bndstrt; bin < bndend; bin++) {
if (bndpsd[bin] < dbknee)
excite[bin] += ((dbknee - bndpsd[bin]) >> 2);
mask[bin] = FFMAX(excite[bin], hth[bin][fscod]);
}
/* apply the delta bit allocation */
if (do_delta) {
band = 0;
for (seg = 0; seg < deltnseg + 1; seg++) {
band += deltoffst[seg];
if (deltba[seg] >= 4)
delta = (deltba[seg] - 3) << 7;
else
delta = (deltba[seg] - 4) << 7;
for (k = 0; k < deltlen[seg]; k++) {
mask[band] += delta;
band++;
}
}
}
/*compute the bit allocation */
i = start;
j = masktab[start];
do {
lastbin = FFMIN(bndtab[j] + bndsz[j], end);
mask[j] -= snroffset;
mask[j] -= floor;
if (mask[j] < 0)
mask[j] = 0;
mask[j] &= 0x1fe0;
mask[j] += floor;
for (k = i; k < lastbin; k++) {
address = (psd[i] - mask[j]) >> 5;
address = FFMIN(63, (FFMAX(0, address)));
baps[i] = baptab[address];
i++;
}
j++;
} while (end > lastbin);
return 0;
}
| 11,251 |
qemu | b45c03f585ea9bb1af76c73e82195418c294919d | 1 | struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum,
qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk)
{
struct omap_mcspi_s *s = (struct omap_mcspi_s *)
g_malloc0(sizeof(struct omap_mcspi_s));
struct omap_mcspi_ch_s *ch = s->ch;
s->irq = irq;
s->chnum = chnum;
while (chnum --) {
ch->txdrq = *drq ++;
ch->rxdrq = *drq ++;
ch ++;
}
omap_mcspi_reset(s);
memory_region_init_io(&s->iomem, NULL, &omap_mcspi_ops, s, "omap.mcspi",
omap_l4_region_size(ta, 0));
omap_l4_attach(ta, 0, &s->iomem);
return s;
}
| 11,252 |
qemu | e23a1b33b53d25510320b26d9f154e19c6c99725 | 1 | int pci_vga_init(PCIBus *bus,
unsigned long vga_bios_offset, int vga_bios_size)
{
PCIDevice *dev;
dev = pci_create(bus, -1, "VGA");
qdev_prop_set_uint32(&dev->qdev, "bios-offset", vga_bios_offset);
qdev_prop_set_uint32(&dev->qdev, "bios-size", vga_bios_offset);
qdev_init(&dev->qdev);
return 0;
}
| 11,253 |
qemu | 6d0ceb80ffe18ad4b28aab7356f440636c0be7be | 1 | void vm_start(void)
{
RunState requested;
qemu_vmstop_requested(&requested);
if (runstate_is_running() && requested == RUN_STATE__MAX) {
return;
}
/* Ensure that a STOP/RESUME pair of events is emitted if a
* vmstop request was pending. The BLOCK_IO_ERROR event, for
* example, according to documentation is always followed by
* the STOP event.
*/
if (runstate_is_running()) {
qapi_event_send_stop(&error_abort);
} else {
cpu_enable_ticks();
runstate_set(RUN_STATE_RUNNING);
vm_state_notify(1, RUN_STATE_RUNNING);
resume_all_vcpus();
}
qapi_event_send_resume(&error_abort);
} | 11,255 |
FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | 1 | static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
#ifdef HAVE_MMX
/* TODO: unroll this loop */
asm volatile (
"xor %%"REG_a", %%"REG_a" \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 32(%0, %%"REG_a") \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"pslld $16, %%mm0 \n\t"
"psrld $16, %%mm1 \n\t"
"pand "MANGLE(mask32r)", %%mm0 \n\t"
"pand "MANGLE(mask32g)", %%mm2 \n\t"
"pand "MANGLE(mask32b)", %%mm1 \n\t"
"por %%mm0, %%mm2 \n\t"
"por %%mm1, %%mm2 \n\t"
MOVNTQ" %%mm2, (%1, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "r"(dst), "r" ((long)src_size-7)
: "%"REG_a
);
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#else
unsigned i;
unsigned num_pixels = src_size >> 2;
for(i=0; i<num_pixels; i++)
{
#ifdef WORDS_BIGENDIAN
dst[4*i + 1] = src[4*i + 3];
dst[4*i + 2] = src[4*i + 2];
dst[4*i + 3] = src[4*i + 1];
#else
dst[4*i + 0] = src[4*i + 2];
dst[4*i + 1] = src[4*i + 1];
dst[4*i + 2] = src[4*i + 0];
#endif
}
#endif
}
| 11,256 |
qemu | c572f23a3e7180dbeab5e86583e43ea2afed6271 | 1 | static void v9fs_xattrcreate(void *opaque)
{
int flags;
int32_t fid;
int64_t size;
ssize_t err = 0;
V9fsString name;
size_t offset = 7;
V9fsFidState *file_fidp;
V9fsFidState *xattr_fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dsqd",
&fid, &name, &size, &flags);
file_fidp = get_fid(pdu, fid);
if (file_fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
/* Make the file fid point to xattr */
xattr_fidp = file_fidp;
xattr_fidp->fid_type = P9_FID_XATTR;
xattr_fidp->fs.xattr.copied_len = 0;
xattr_fidp->fs.xattr.len = size;
xattr_fidp->fs.xattr.flags = flags;
v9fs_string_init(&xattr_fidp->fs.xattr.name);
v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
if (size) {
xattr_fidp->fs.xattr.value = g_malloc(size);
} else {
xattr_fidp->fs.xattr.value = NULL;
}
err = offset;
put_fid(pdu, file_fidp);
out_nofid:
complete_pdu(s, pdu, err);
v9fs_string_free(&name);
} | 11,257 |
qemu | bb593904c18e22ea0671dfa1b02e24982f2bf0ea | 0 | static void spr_read_sdr1 (void *opaque, int gprn, int sprn)
{
tcg_gen_ld_tl(cpu_gpr[gprn], cpu_env, offsetof(CPUState, sdr1));
}
| 11,258 |
qemu | 4efe27556dea874030f1cd53a6d70452ee064fba | 0 | void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size)
{
CirrusVGAState *s;
s = qemu_mallocz(sizeof(CirrusVGAState));
vga_common_init((VGAState *)s,
ds, vga_ram_base, vga_ram_offset, vga_ram_size);
cirrus_init_common(s, CIRRUS_ID_CLGD5430, 0);
s->console = graphic_console_init(s->ds, s->update, s->invalidate,
s->screen_dump, s->text_update, s);
/* XXX ISA-LFB support */
}
| 11,259 |
qemu | d9f62dde1303286b24ac8ce88be27e2b9b9c5f46 | 0 | StringInputVisitor *string_input_visitor_new(const char *str)
{
StringInputVisitor *v;
v = g_malloc0(sizeof(*v));
v->visitor.type = VISITOR_INPUT;
v->visitor.type_int64 = parse_type_int64;
v->visitor.type_uint64 = parse_type_uint64;
v->visitor.type_size = parse_type_size;
v->visitor.type_bool = parse_type_bool;
v->visitor.type_str = parse_type_str;
v->visitor.type_number = parse_type_number;
v->visitor.start_list = start_list;
v->visitor.next_list = next_list;
v->visitor.end_list = end_list;
v->visitor.optional = parse_optional;
v->string = str;
v->head = true;
return v;
}
| 11,260 |
qemu | 3954d33ab7f82f5a5fa0ced231849920265a5fec | 0 | void spapr_vio_bus_register_withprop(VIOsPAPRDeviceInfo *info)
{
info->qdev.init = spapr_vio_busdev_init;
info->qdev.bus_info = &spapr_vio_bus_info;
assert(info->qdev.size >= sizeof(VIOsPAPRDevice));
qdev_register(&info->qdev);
}
| 11,262 |
qemu | eabb7b91b36b202b4dac2df2d59d698e3aff197a | 0 | static inline void tcg_out_adr(TCGContext *s, TCGReg rd, void *target)
{
ptrdiff_t offset = tcg_pcrel_diff(s, target);
assert(offset == sextract64(offset, 0, 21));
tcg_out_insn(s, 3406, ADR, rd, offset);
}
| 11,265 |
qemu | ddcd55316fb2851e144e719171621ad2816487dc | 0 | static int pc_boot_set(void *opaque, const char *boot_device)
{
return set_boot_dev(opaque, boot_device);
}
| 11,266 |
qemu | 95ede84f4de18747d03d79c148013cff99acd60b | 0 | static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi,
TCGMemOp opc, int mem_index, bool is_load)
{
TCGReg base = TCG_AREG0;
int cmp_off =
(is_load
? offsetof(CPUArchState, tlb_table[mem_index][0].addr_read)
: offsetof(CPUArchState, tlb_table[mem_index][0].addr_write));
int add_off = offsetof(CPUArchState, tlb_table[mem_index][0].addend);
unsigned s_bits = opc & MO_SIZE;
unsigned a_bits = get_alignment_bits(opc);
/* V7 generates the following:
* ubfx r0, addrlo, #TARGET_PAGE_BITS, #CPU_TLB_BITS
* add r2, env, #high
* add r2, r2, r0, lsl #CPU_TLB_ENTRY_BITS
* ldr r0, [r2, #cmp]
* ldr r2, [r2, #add]
* movw tmp, #page_align_mask
* bic tmp, addrlo, tmp
* cmp r0, tmp
*
* Otherwise we generate:
* shr tmp, addrlo, #TARGET_PAGE_BITS
* add r2, env, #high
* and r0, tmp, #(CPU_TLB_SIZE - 1)
* add r2, r2, r0, lsl #CPU_TLB_ENTRY_BITS
* ldr r0, [r2, #cmp]
* ldr r2, [r2, #add]
* tst addrlo, #s_mask
* cmpeq r0, tmp, lsl #TARGET_PAGE_BITS
*/
if (use_armv7_instructions) {
tcg_out_extract(s, COND_AL, TCG_REG_R0, addrlo,
TARGET_PAGE_BITS, CPU_TLB_BITS);
} else {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV, TCG_REG_TMP,
0, addrlo, SHIFT_IMM_LSR(TARGET_PAGE_BITS));
}
/* We checked that the offset is contained within 16 bits above. */
if (add_off > 0xfff || (use_armv6_instructions && cmp_off > 0xff)) {
tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R2, base,
(24 << 7) | (cmp_off >> 8));
base = TCG_REG_R2;
add_off -= cmp_off & 0xff00;
cmp_off &= 0xff;
}
if (!use_armv7_instructions) {
tcg_out_dat_imm(s, COND_AL, ARITH_AND,
TCG_REG_R0, TCG_REG_TMP, CPU_TLB_SIZE - 1);
}
tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_R2, base,
TCG_REG_R0, SHIFT_IMM_LSL(CPU_TLB_ENTRY_BITS));
/* Load the tlb comparator. Use ldrd if needed and available,
but due to how the pointer needs setting up, ldm isn't useful.
Base arm5 doesn't have ldrd, but armv5te does. */
if (use_armv6_instructions && TARGET_LONG_BITS == 64) {
tcg_out_ldrd_8(s, COND_AL, TCG_REG_R0, TCG_REG_R2, cmp_off);
} else {
tcg_out_ld32_12(s, COND_AL, TCG_REG_R0, TCG_REG_R2, cmp_off);
if (TARGET_LONG_BITS == 64) {
tcg_out_ld32_12(s, COND_AL, TCG_REG_R1, TCG_REG_R2, cmp_off + 4);
}
}
/* Load the tlb addend. */
tcg_out_ld32_12(s, COND_AL, TCG_REG_R2, TCG_REG_R2, add_off);
/* Check alignment. We don't support inline unaligned acceses,
but we can easily support overalignment checks. */
if (a_bits < s_bits) {
a_bits = s_bits;
}
if (use_armv7_instructions) {
tcg_target_ulong mask = ~(TARGET_PAGE_MASK | ((1 << a_bits) - 1));
int rot = encode_imm(mask);
if (rot >= 0) {
tcg_out_dat_imm(s, COND_AL, ARITH_BIC, TCG_REG_TMP, addrlo,
rotl(mask, rot) | (rot << 7));
} else {
tcg_out_movi32(s, COND_AL, TCG_REG_TMP, mask);
tcg_out_dat_reg(s, COND_AL, ARITH_BIC, TCG_REG_TMP,
addrlo, TCG_REG_TMP, 0);
}
tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, TCG_REG_R0, TCG_REG_TMP, 0);
} else {
if (a_bits) {
tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, addrlo,
(1 << a_bits) - 1);
}
tcg_out_dat_reg(s, (a_bits ? COND_EQ : COND_AL), ARITH_CMP,
0, TCG_REG_R0, TCG_REG_TMP,
SHIFT_IMM_LSL(TARGET_PAGE_BITS));
}
if (TARGET_LONG_BITS == 64) {
tcg_out_dat_reg(s, COND_EQ, ARITH_CMP, 0, TCG_REG_R1, addrhi, 0);
}
return TCG_REG_R2;
}
| 11,267 |
qemu | 97a79eb70dd35a24fda87d86196afba5e6f21c5d | 0 | static void tcg_opt_gen_movi(TCGContext *s, TCGOp *op, TCGArg *args,
TCGArg dst, TCGArg val)
{
TCGOpcode new_op = op_to_movi(op->opc);
tcg_target_ulong mask;
op->opc = new_op;
reset_temp(dst);
temps[dst].state = TCG_TEMP_CONST;
temps[dst].val = val;
mask = val;
if (TCG_TARGET_REG_BITS > 32 && new_op == INDEX_op_mov_i32) {
/* High bits of the destination are now garbage. */
mask |= ~0xffffffffull;
}
temps[dst].mask = mask;
args[0] = dst;
args[1] = val;
}
| 11,269 |
qemu | a91246c95f913dc6fd391eee32f6c9796de70183 | 0 | static int colo_do_checkpoint_transaction(MigrationState *s)
{
Error *local_err = NULL;
colo_send_message(s->to_dst_file, COLO_MESSAGE_CHECKPOINT_REQUEST,
&local_err);
if (local_err) {
goto out;
}
colo_receive_check_message(s->rp_state.from_dst_file,
COLO_MESSAGE_CHECKPOINT_REPLY, &local_err);
if (local_err) {
goto out;
}
/* TODO: suspend and save vm state to colo buffer */
colo_send_message(s->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_err);
if (local_err) {
goto out;
}
/* TODO: send vmstate to Secondary */
colo_receive_check_message(s->rp_state.from_dst_file,
COLO_MESSAGE_VMSTATE_RECEIVED, &local_err);
if (local_err) {
goto out;
}
colo_receive_check_message(s->rp_state.from_dst_file,
COLO_MESSAGE_VMSTATE_LOADED, &local_err);
if (local_err) {
goto out;
}
/* TODO: resume Primary */
return 0;
out:
if (local_err) {
error_report_err(local_err);
}
return -EINVAL;
}
| 11,271 |
FFmpeg | ba2c385006e3100d6cd506f61c53186ba054a06d | 0 | static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
AVPacket *pkt) {
int chunk_type;
if (s->audio_chunk_offset && s->audio_channels && s->audio_bits) {
if (s->audio_type == AV_CODEC_ID_NONE) {
av_log(s->avf, AV_LOG_ERROR, "Can not read audio packet before"
"audio codec is known\n");
return CHUNK_BAD;
}
/* adjust for PCM audio by skipping chunk header */
if (s->audio_type != AV_CODEC_ID_INTERPLAY_DPCM) {
s->audio_chunk_offset += 6;
s->audio_chunk_size -= 6;
}
avio_seek(pb, s->audio_chunk_offset, SEEK_SET);
s->audio_chunk_offset = 0;
if (s->audio_chunk_size != av_get_packet(pb, pkt, s->audio_chunk_size))
return CHUNK_EOF;
pkt->stream_index = s->audio_stream_index;
pkt->pts = s->audio_frame_count;
/* audio frame maintenance */
if (s->audio_type != AV_CODEC_ID_INTERPLAY_DPCM)
s->audio_frame_count +=
(s->audio_chunk_size / s->audio_channels / (s->audio_bits / 8));
else
s->audio_frame_count +=
(s->audio_chunk_size - 6 - s->audio_channels) / s->audio_channels;
av_log(s->avf, AV_LOG_TRACE, "sending audio frame with pts %"PRId64" (%d audio frames)\n",
pkt->pts, s->audio_frame_count);
chunk_type = CHUNK_VIDEO;
} else if (s->decode_map_chunk_offset) {
/* send both the decode map and the video data together */
if (av_new_packet(pkt, 2 + s->decode_map_chunk_size + s->video_chunk_size))
return CHUNK_NOMEM;
if (s->has_palette) {
uint8_t *pal;
pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
AVPALETTE_SIZE);
if (pal) {
memcpy(pal, s->palette, AVPALETTE_SIZE);
s->has_palette = 0;
}
}
if (s->changed) {
ff_add_param_change(pkt, 0, 0, 0, s->video_width, s->video_height);
s->changed = 0;
}
pkt->pos= s->decode_map_chunk_offset;
avio_seek(pb, s->decode_map_chunk_offset, SEEK_SET);
s->decode_map_chunk_offset = 0;
AV_WL16(pkt->data, s->decode_map_chunk_size);
if (avio_read(pb, pkt->data + 2, s->decode_map_chunk_size) !=
s->decode_map_chunk_size) {
av_packet_unref(pkt);
return CHUNK_EOF;
}
avio_seek(pb, s->video_chunk_offset, SEEK_SET);
s->video_chunk_offset = 0;
if (avio_read(pb, pkt->data + 2 + s->decode_map_chunk_size,
s->video_chunk_size) != s->video_chunk_size) {
av_packet_unref(pkt);
return CHUNK_EOF;
}
pkt->stream_index = s->video_stream_index;
pkt->pts = s->video_pts;
av_log(s->avf, AV_LOG_TRACE, "sending video frame with pts %"PRId64"\n", pkt->pts);
s->video_pts += s->frame_pts_inc;
chunk_type = CHUNK_VIDEO;
} else {
avio_seek(pb, s->next_chunk_offset, SEEK_SET);
chunk_type = CHUNK_DONE;
}
return chunk_type;
}
| 11,272 |
qemu | a0b753dfd3920df146a5f4d05e442e3c522900c7 | 0 | static void verdex_init(ram_addr_t ram_size, int vga_ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
struct pxa2xx_state_s *cpu;
int index;
uint32_t verdex_rom = 0x02000000;
uint32_t verdex_ram = 0x10000000;
if (ram_size < (verdex_ram + verdex_rom + PXA2XX_INTERNAL_SIZE)) {
fprintf(stderr, "This platform requires %i bytes of memory\n",
verdex_ram + verdex_rom + PXA2XX_INTERNAL_SIZE);
exit(1);
}
cpu = pxa270_init(verdex_ram, cpu_model ?: "pxa270-c0");
index = drive_get_index(IF_PFLASH, 0, 0);
if (index == -1) {
fprintf(stderr, "A flash image must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(verdex_rom),
drives_table[index].bdrv, sector_len, verdex_rom / sector_len,
2, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
cpu->env->regs[15] = 0x00000000;
/* Interrupt line of NIC is connected to GPIO line 99 */
smc91c111_init(&nd_table[0], 0x04000300,
pxa2xx_gpio_in_get(cpu->gpio)[99]);
}
| 11,273 |
qemu | 73534f2f682f2957fabb25e3890481098cc5dcee | 0 | void pci_device_save(PCIDevice *s, QEMUFile *f)
{
int i;
qemu_put_be32(f, s->version_id); /* PCI device version */
qemu_put_buffer(f, s->config, 256);
for (i = 0; i < 4; i++)
qemu_put_be32(f, s->irq_state[i]);
}
| 11,274 |
qemu | 0e2487bd6f56445b43307536a465ee2ba810aed9 | 0 | static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect)
{
uint8_t *src = qxl->guest_primary.data;
uint8_t *dst = qxl->guest_primary.flipped;
int len, i;
src += (qxl->guest_primary.surface.height - rect->top - 1) *
qxl->guest_primary.stride;
dst += rect->top * qxl->guest_primary.stride;
src += rect->left * qxl->guest_primary.bytes_pp;
dst += rect->left * qxl->guest_primary.bytes_pp;
len = (rect->right - rect->left) * qxl->guest_primary.bytes_pp;
for (i = rect->top; i < rect->bottom; i++) {
memcpy(dst, src, len);
dst += qxl->guest_primary.stride;
src -= qxl->guest_primary.stride;
}
}
| 11,275 |
qemu | ac531cb6e542b1e61d668604adf9dc5306a948c0 | 0 | START_TEST(qdict_destroy_simple_test)
{
QDict *qdict;
qdict = qdict_new();
qdict_put_obj(qdict, "num", QOBJECT(qint_from_int(0)));
qdict_put_obj(qdict, "str", QOBJECT(qstring_from_str("foo")));
QDECREF(qdict);
}
| 11,276 |
qemu | 81e3e75b6461c53724fe7c7918bc54468fcdaf9d | 0 | static int pcibus_reset(BusState *qbus)
{
pci_bus_reset(DO_UPCAST(PCIBus, qbus, qbus));
/* topology traverse is done by pci_bus_reset().
Tell qbus/qdev walker not to traverse the tree */
return 1;
}
| 11,277 |
FFmpeg | bcaf64b605442e1622d16da89d4ec0e7730b8a8c | 0 | int AC3_NAME(encode_frame)(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
AC3EncodeContext *s = avctx->priv_data;
int ret;
if (s->options.allow_per_frame_metadata) {
ret = ff_ac3_validate_metadata(s);
if (ret)
return ret;
}
if (s->bit_alloc.sr_code == 1 || s->eac3)
ff_ac3_adjust_frame_size(s);
copy_input_samples(s, (SampleType **)frame->extended_data);
apply_mdct(s);
if (s->fixed_point)
scale_coefficients(s);
clip_coefficients(&s->dsp, s->blocks[0].mdct_coef[1],
AC3_MAX_COEFS * s->num_blocks * s->channels);
s->cpl_on = s->cpl_enabled;
ff_ac3_compute_coupling_strategy(s);
if (s->cpl_on)
apply_channel_coupling(s);
compute_rematrixing_strategy(s);
if (!s->fixed_point)
scale_coefficients(s);
ff_ac3_apply_rematrixing(s);
ff_ac3_process_exponents(s);
ret = ff_ac3_compute_bit_allocation(s);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n");
return ret;
}
ff_ac3_group_exponents(s);
ff_ac3_quantize_mantissas(s);
if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size)))
return ret;
ff_ac3_output_frame(s, avpkt->data);
if (frame->pts != AV_NOPTS_VALUE)
avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay);
*got_packet_ptr = 1;
return 0;
}
| 11,278 |
FFmpeg | 125cf771f6d17b9b9db7588cbf8f36619bc41f35 | 0 | static int read_channel_params(MLPDecodeContext *m, unsigned int substr,
GetBitContext *gbp, unsigned int ch)
{
ChannelParams *cp = &m->channel_params[ch];
FilterParams *fir = &cp->filter_params[FIR];
FilterParams *iir = &cp->filter_params[IIR];
SubStream *s = &m->substream[substr];
if (s->param_presence_flags & PARAM_FIR)
if (get_bits1(gbp))
if (read_filter_params(m, gbp, ch, FIR) < 0)
return -1;
if (s->param_presence_flags & PARAM_IIR)
if (get_bits1(gbp))
if (read_filter_params(m, gbp, ch, IIR) < 0)
return -1;
if (fir->order && iir->order &&
fir->shift != iir->shift) {
av_log(m->avctx, AV_LOG_ERROR,
"FIR and IIR filters must use the same precision.\n");
return -1;
}
/* The FIR and IIR filters must have the same precision.
* To simplify the filtering code, only the precision of the
* FIR filter is considered. If only the IIR filter is employed,
* the FIR filter precision is set to that of the IIR filter, so
* that the filtering code can use it. */
if (!fir->order && iir->order)
fir->shift = iir->shift;
if (s->param_presence_flags & PARAM_HUFFOFFSET)
if (get_bits1(gbp))
cp->huff_offset = get_sbits(gbp, 15);
cp->codebook = get_bits(gbp, 2);
cp->huff_lsbs = get_bits(gbp, 5);
cp->sign_huff_offset = calculate_sign_huff(m, substr, ch);
/* TODO: validate */
return 0;
}
| 11,279 |
FFmpeg | 7e4111cfe2f5d03af8d608757e897145aa252af8 | 0 | static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
int64_t *ppos, int64_t pos_limit)
{
RMDemuxContext *rm = s->priv_data;
int64_t pos, dts;
int stream_index2, flags, len, h;
pos = *ppos;
if(rm->old_format)
return AV_NOPTS_VALUE;
avio_seek(s->pb, pos, SEEK_SET);
rm->remaining_len=0;
for(;;){
int seq=1;
AVStream *st;
len=sync(s, &dts, &flags, &stream_index2, &pos);
if(len<0)
return AV_NOPTS_VALUE;
st = s->streams[stream_index2];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
h= avio_r8(s->pb); len--;
if(!(h & 0x40)){
seq = avio_r8(s->pb); len--;
}
}
if((flags&2) && (seq&0x7F) == 1){
// av_log(s, AV_LOG_DEBUG, "%d %d-%d %"PRId64" %d\n", flags, stream_index2, stream_index, dts, seq);
av_add_index_entry(st, pos, dts, 0, 0, AVINDEX_KEYFRAME);
if(stream_index2 == stream_index)
break;
}
avio_skip(s->pb, len);
}
*ppos = pos;
return dts;
}
| 11,280 |
FFmpeg | 09f59d6adfa19d1ad5049416c1d0fbc996f509fd | 0 | static int gif_image_write_header(AVIOContext *pb, int width, int height,
int loop_count, uint32_t *palette)
{
int i;
avio_write(pb, "GIF", 3);
avio_write(pb, "89a", 3);
avio_wl16(pb, width);
avio_wl16(pb, height);
if (palette) {
avio_w8(pb, 0xf7); /* flags: global clut, 256 entries */
avio_w8(pb, 0x1f); /* background color index */
avio_w8(pb, 0); /* aspect ratio */
for (i = 0; i < 256; i++) {
const uint32_t v = palette[i] & 0xffffff;
avio_wb24(pb, v);
}
} else {
avio_w8(pb, 0); /* flags */
avio_w8(pb, 0); /* background color index */
avio_w8(pb, 0); /* aspect ratio */
}
/* "NETSCAPE EXTENSION" for looped animation GIF */
avio_w8(pb, 0x21); /* GIF Extension code */
avio_w8(pb, 0xff); /* Application Extension Label */
avio_w8(pb, 0x0b); /* Length of Application Block */
avio_write(pb, "NETSCAPE2.0", sizeof("NETSCAPE2.0") - 1);
avio_w8(pb, 0x03); /* Length of Data Sub-Block */
avio_w8(pb, 0x01);
avio_wl16(pb, (uint16_t)loop_count);
avio_w8(pb, 0x00); /* Data Sub-block Terminator */
return 0;
}
| 11,281 |
FFmpeg | 5c2fb561d94fc51d76ab21d6f7cc5b6cc3aa599c | 0 | static av_cold int omx_encode_init(AVCodecContext *avctx)
{
OMXCodecContext *s = avctx->priv_data;
int ret = AVERROR_ENCODER_NOT_FOUND;
const char *role;
OMX_BUFFERHEADERTYPE *buffer;
OMX_ERRORTYPE err;
#if CONFIG_OMX_RPI
s->input_zerocopy = 1;
#endif
s->omx_context = omx_init(avctx, s->libname, s->libprefix);
if (!s->omx_context)
return AVERROR_ENCODER_NOT_FOUND;
pthread_mutex_init(&s->state_mutex, NULL);
pthread_cond_init(&s->state_cond, NULL);
pthread_mutex_init(&s->input_mutex, NULL);
pthread_cond_init(&s->input_cond, NULL);
pthread_mutex_init(&s->output_mutex, NULL);
pthread_cond_init(&s->output_cond, NULL);
s->mutex_cond_inited = 1;
s->avctx = avctx;
s->state = OMX_StateLoaded;
s->error = OMX_ErrorNone;
switch (avctx->codec->id) {
case AV_CODEC_ID_MPEG4:
role = "video_encoder.mpeg4";
break;
case AV_CODEC_ID_H264:
role = "video_encoder.avc";
break;
default:
return AVERROR(ENOSYS);
}
if ((ret = find_component(s->omx_context, avctx, role, s->component_name, sizeof(s->component_name))) < 0)
goto fail;
av_log(avctx, AV_LOG_INFO, "Using %s\n", s->component_name);
if ((ret = omx_component_init(avctx, role)) < 0)
goto fail;
if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
while (1) {
buffer = get_buffer(&s->output_mutex, &s->output_cond,
&s->num_done_out_buffers, s->done_out_buffers, 1);
if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) {
if ((ret = av_reallocp(&avctx->extradata, avctx->extradata_size + buffer->nFilledLen + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) {
avctx->extradata_size = 0;
goto fail;
}
memcpy(avctx->extradata + avctx->extradata_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen);
avctx->extradata_size += buffer->nFilledLen;
memset(avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
}
err = OMX_FillThisBuffer(s->handle, buffer);
if (err != OMX_ErrorNone) {
append_buffer(&s->output_mutex, &s->output_cond,
&s->num_done_out_buffers, s->done_out_buffers, buffer);
av_log(avctx, AV_LOG_ERROR, "OMX_FillThisBuffer failed: %x\n", err);
ret = AVERROR_UNKNOWN;
goto fail;
}
if (avctx->codec->id == AV_CODEC_ID_H264) {
// For H.264, the extradata can be returned in two separate buffers
// (the videocore encoder on raspberry pi does this);
// therefore check that we have got both SPS and PPS before continuing.
int nals[32] = { 0 };
int i;
for (i = 0; i + 4 < avctx->extradata_size; i++) {
if (!avctx->extradata[i + 0] &&
!avctx->extradata[i + 1] &&
!avctx->extradata[i + 2] &&
avctx->extradata[i + 3] == 1) {
nals[avctx->extradata[i + 4] & 0x1f]++;
}
}
if (nals[NAL_SPS] && nals[NAL_PPS])
break;
} else {
if (avctx->extradata_size > 0)
break;
}
}
}
return 0;
fail:
return ret;
}
| 11,282 |
FFmpeg | ffc58b2ce27e140b47900d1ead304663f7b385ae | 1 | static int check_pkt(AVFormatContext *s, AVPacket *pkt)
{
MOVMuxContext *mov = s->priv_data;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
int64_t ref;
uint64_t duration;
if (trk->entry) {
ref = trk->cluster[trk->entry - 1].dts;
} else if ( trk->start_dts != AV_NOPTS_VALUE
&& !trk->frag_discont) {
ref = trk->start_dts + trk->track_duration;
} else
ref = pkt->dts; // Skip tests for the first packet
duration = pkt->dts - ref;
if (pkt->dts < ref || duration >= INT_MAX) {
av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" / timestamp: %"PRId64" is out of range for mov/mp4 format\n",
duration, pkt->dts
);
pkt->dts = ref + 1;
pkt->pts = AV_NOPTS_VALUE;
if (pkt->duration < 0 || pkt->duration > INT_MAX) {
av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" is invalid\n", pkt->duration);
return AVERROR(EINVAL);
return 0; | 11,283 |
FFmpeg | bf2bc926f04dcdde0a22c137d08a0bb546e0179e | 1 | static int vc9_init_common(VC9Context *v)
{
static int done = 0;
int i;
/* Set the bit planes */
v->mv_type_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 };
v->direct_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 };
v->skip_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 };
#if HAS_ADVANCED_PROFILE
v->ac_pred_plane = v->over_flags_plane = (struct BitPlane) { NULL, 0, 0, 0 };
v->hrd_rate = v->hrd_buffer = NULL;
#endif
/* VLC tables */
#if VLC_NORM6_METH0D == 1
# if 0 // spec -> actual tables converter
for(i=0; i<64; i++){
int code= (vc9_norm6_spec[i][1] << vc9_norm6_spec[i][4]) + vc9_norm6_spec[i][3];
av_log(NULL, AV_LOG_DEBUG, "0x%03X, ", code);
if(i%16==15) av_log(NULL, AV_LOG_DEBUG, "\n");
}
for(i=0; i<64; i++){
int code= vc9_norm6_spec[i][2] + vc9_norm6_spec[i][4];
av_log(NULL, AV_LOG_DEBUG, "%2d, ", code);
if(i%16==15) av_log(NULL, AV_LOG_DEBUG, "\n");
}
# endif
#endif
if(!done)
{
done = 1;
INIT_VLC(&vc9_bfraction_vlc, VC9_BFRACTION_VLC_BITS, 23,
vc9_bfraction_bits, 1, 1,
vc9_bfraction_codes, 1, 1, 1);
INIT_VLC(&vc9_norm2_vlc, VC9_NORM2_VLC_BITS, 4,
vc9_norm2_bits, 1, 1,
vc9_norm2_codes, 1, 1, 1);
#if VLC_NORM6_METH0D == 1
INIT_VLC(&vc9_norm6_vlc, VC9_NORM6_VLC_BITS, 64,
vc9_norm6_bits, 1, 1,
vc9_norm6_codes, 2, 2, 1);
#endif
#if VLC_NORM6_METH0D == 2
INIT_VLC(&vc9_norm6_first_vlc, VC9_NORM6_FIRST_BITS, 24,
&vc9_norm6_first[0][1], 1, 1,
&vc9_norm6_first[0][0], 1, 1, 1);
INIT_VLC(&vc9_norm6_second_vlc, VC9_NORM6_SECOND_BITS, 22,
&vc9_norm6_second[0][1], 1, 1,
&vc9_norm6_second[0][0], 1, 1, 1);
#endif
INIT_VLC(&vc9_imode_vlc, VC9_IMODE_VLC_BITS, 7,
vc9_imode_bits, 1, 1,
vc9_imode_codes, 1, 1, 1);
for (i=0; i<3; i++)
{
INIT_VLC(&vc9_ttmb_vlc[i], VC9_TTMB_VLC_BITS, 16,
vc9_ttmb_bits[i], 1, 1,
vc9_ttmb_codes[i], 2, 2, 1);
}
for(i=0; i<4; i++)
{
INIT_VLC(&vc9_4mv_block_pattern_vlc[i], VC9_4MV_BLOCK_PATTERN_VLC_BITS, 16,
vc9_4mv_block_pattern_bits[i], 1, 1,
vc9_4mv_block_pattern_codes[i], 1, 1, 1);
INIT_VLC(&vc9_cbpcy_p_vlc[i], VC9_CBPCY_P_VLC_BITS, 64,
vc9_cbpcy_p_bits[i], 1, 1,
vc9_cbpcy_p_codes[i], 2, 2, 1);
INIT_VLC(&vc9_mv_diff_vlc[i], VC9_MV_DIFF_VLC_BITS, 73,
vc9_mv_diff_bits[i], 1, 1,
vc9_mv_diff_codes[i], 2, 2, 1);
}
}
/* Other defaults */
v->pq = -1;
v->mvrange = 0; /* 7.1.1.18, p80 */
return 0;
}
| 11,284 |
FFmpeg | 2c00b373024054e0779ef67fc54b763d624db3e8 | 1 | int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict)
{
const uint8_t *end = data + size;
int ret = 0;
if (!dict || !data || !size)
return ret;
if (size && end[-1])
return AVERROR_INVALIDDATA;
while (data < end) {
const uint8_t *key = data;
const uint8_t *val = data + strlen(key) + 1;
if (val >= end)
return AVERROR_INVALIDDATA;
ret = av_dict_set(dict, key, val, 0);
if (ret < 0)
break;
data = val + strlen(val) + 1;
}
return ret;
}
| 11,285 |
qemu | be214e6c0557139ffa5551f77e339c07495bfec3 | 1 | void cpu_interrupt(CPUState *env, int mask)
{
#if !defined(USE_NPTL)
TranslationBlock *tb;
static spinlock_t interrupt_lock = SPIN_LOCK_UNLOCKED;
#endif
int old_mask;
old_mask = env->interrupt_request;
/* FIXME: This is probably not threadsafe. A different thread could
be in the middle of a read-modify-write operation. */
env->interrupt_request |= mask;
#if defined(USE_NPTL)
/* FIXME: TB unchaining isn't SMP safe. For now just ignore the
problem and hope the cpu will stop of its own accord. For userspace
emulation this often isn't actually as bad as it sounds. Often
signals are used primarily to interrupt blocking syscalls. */
#else
if (use_icount) {
env->icount_decr.u16.high = 0xffff;
#ifndef CONFIG_USER_ONLY
/* CPU_INTERRUPT_EXIT isn't a real interrupt. It just means
an async event happened and we need to process it. */
if (!can_do_io(env)
&& (mask & ~(old_mask | CPU_INTERRUPT_EXIT)) != 0) {
cpu_abort(env, "Raised interrupt while not in I/O function");
}
#endif
} else {
tb = env->current_tb;
/* if the cpu is currently executing code, we must unlink it and
all the potentially executing TB */
if (tb && !testandset(&interrupt_lock)) {
env->current_tb = NULL;
tb_reset_jump_recursive(tb);
resetlock(&interrupt_lock);
}
}
#endif
}
| 11,286 |
qemu | 1304ca878a4e091c193bd4ae273e0b5cb6142237 | 1 | static always_inline int translate_one (DisasContext *ctx, uint32_t insn)
{
uint32_t palcode;
int32_t disp21, disp16, disp12;
uint16_t fn11, fn16;
uint8_t opc, ra, rb, rc, sbz, fpfn, fn7, fn2, islit;
uint8_t lit;
int ret;
/* Decode all instruction fields */
opc = insn >> 26;
ra = (insn >> 21) & 0x1F;
rb = (insn >> 16) & 0x1F;
rc = insn & 0x1F;
sbz = (insn >> 13) & 0x07;
islit = (insn >> 12) & 1;
if (rb == 31 && !islit) {
islit = 1;
lit = 0;
} else
lit = (insn >> 13) & 0xFF;
palcode = insn & 0x03FFFFFF;
disp21 = ((int32_t)((insn & 0x001FFFFF) << 11)) >> 11;
disp16 = (int16_t)(insn & 0x0000FFFF);
disp12 = (int32_t)((insn & 0x00000FFF) << 20) >> 20;
fn16 = insn & 0x0000FFFF;
fn11 = (insn >> 5) & 0x000007FF;
fpfn = fn11 & 0x3F;
fn7 = (insn >> 5) & 0x0000007F;
fn2 = (insn >> 5) & 0x00000003;
ret = 0;
#if defined ALPHA_DEBUG_DISAS
if (logfile != NULL) {
fprintf(logfile, "opc %02x ra %d rb %d rc %d disp16 %04x\n",
opc, ra, rb, rc, disp16);
}
#endif
switch (opc) {
case 0x00:
/* CALL_PAL */
if (palcode >= 0x80 && palcode < 0xC0) {
/* Unprivileged PAL call */
gen_excp(ctx, EXCP_CALL_PAL + ((palcode & 0x1F) << 6), 0);
#if !defined (CONFIG_USER_ONLY)
} else if (palcode < 0x40) {
/* Privileged PAL code */
if (ctx->mem_idx & 1)
goto invalid_opc;
else
gen_excp(ctx, EXCP_CALL_PALP + ((palcode & 0x1F) << 6), 0);
#endif
} else {
/* Invalid PAL call */
goto invalid_opc;
}
ret = 3;
break;
case 0x01:
/* OPC01 */
goto invalid_opc;
case 0x02:
/* OPC02 */
goto invalid_opc;
case 0x03:
/* OPC03 */
goto invalid_opc;
case 0x04:
/* OPC04 */
goto invalid_opc;
case 0x05:
/* OPC05 */
goto invalid_opc;
case 0x06:
/* OPC06 */
goto invalid_opc;
case 0x07:
/* OPC07 */
goto invalid_opc;
case 0x08:
/* LDA */
if (likely(ra != 31)) {
if (rb != 31)
tcg_gen_addi_i64(cpu_ir[ra], cpu_ir[rb], disp16);
else
tcg_gen_movi_i64(cpu_ir[ra], disp16);
}
break;
case 0x09:
/* LDAH */
if (likely(ra != 31)) {
if (rb != 31)
tcg_gen_addi_i64(cpu_ir[ra], cpu_ir[rb], disp16 << 16);
else
tcg_gen_movi_i64(cpu_ir[ra], disp16 << 16);
}
break;
case 0x0A:
/* LDBU */
if (!(ctx->amask & AMASK_BWX))
goto invalid_opc;
gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);
break;
case 0x0B:
/* LDQ_U */
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);
break;
case 0x0C:
/* LDWU */
if (!(ctx->amask & AMASK_BWX))
goto invalid_opc;
gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 1);
break;
case 0x0D:
/* STW */
gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);
break;
case 0x0E:
/* STB */
gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);
break;
case 0x0F:
/* STQ_U */
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);
break;
case 0x10:
switch (fn7) {
case 0x00:
/* ADDL */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit) {
tcg_gen_addi_i64(cpu_ir[rc], cpu_ir[ra], lit);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
} else {
tcg_gen_add_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x02:
/* S4ADDL */
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
if (islit)
tcg_gen_addi_i64(tmp, tmp, lit);
else
tcg_gen_add_i64(tmp, tmp, cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x09:
/* SUBL */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_subi_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_sub_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else {
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
}
break;
case 0x0B:
/* S4SUBL */
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
if (islit)
tcg_gen_subi_i64(tmp, tmp, lit);
else
tcg_gen_sub_i64(tmp, tmp, cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else {
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
}
}
break;
case 0x0F:
/* CMPBGE */
gen_arith3(helper_cmpbge, ra, rb, rc, islit, lit);
break;
case 0x12:
/* S8ADDL */
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
if (islit)
tcg_gen_addi_i64(tmp, tmp, lit);
else
tcg_gen_add_i64(tmp, tmp, cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x1B:
/* S8SUBL */
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
if (islit)
tcg_gen_subi_i64(tmp, tmp, lit);
else
tcg_gen_sub_i64(tmp, tmp, cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
}
}
break;
case 0x1D:
/* CMPULT */
gen_cmp(TCG_COND_LTU, ra, rb, rc, islit, lit);
break;
case 0x20:
/* ADDQ */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_addi_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_add_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x22:
/* S4ADDQ */
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
if (islit)
tcg_gen_addi_i64(cpu_ir[rc], tmp, lit);
else
tcg_gen_add_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x29:
/* SUBQ */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_subi_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_sub_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x2B:
/* S4SUBQ */
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
if (islit)
tcg_gen_subi_i64(cpu_ir[rc], tmp, lit);
else
tcg_gen_sub_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x2D:
/* CMPEQ */
gen_cmp(TCG_COND_EQ, ra, rb, rc, islit, lit);
break;
case 0x32:
/* S8ADDQ */
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
if (islit)
tcg_gen_addi_i64(cpu_ir[rc], tmp, lit);
else
tcg_gen_add_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x3B:
/* S8SUBQ */
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
if (islit)
tcg_gen_subi_i64(cpu_ir[rc], tmp, lit);
else
tcg_gen_sub_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x3D:
/* CMPULE */
gen_cmp(TCG_COND_LEU, ra, rb, rc, islit, lit);
break;
case 0x40:
/* ADDL/V */
gen_arith3(helper_addlv, ra, rb, rc, islit, lit);
break;
case 0x49:
/* SUBL/V */
gen_arith3(helper_sublv, ra, rb, rc, islit, lit);
break;
case 0x4D:
/* CMPLT */
gen_cmp(TCG_COND_LT, ra, rb, rc, islit, lit);
break;
case 0x60:
/* ADDQ/V */
gen_arith3(helper_addqv, ra, rb, rc, islit, lit);
break;
case 0x69:
/* SUBQ/V */
gen_arith3(helper_subqv, ra, rb, rc, islit, lit);
break;
case 0x6D:
/* CMPLE */
gen_cmp(TCG_COND_LE, ra, rb, rc, islit, lit);
break;
default:
goto invalid_opc;
}
break;
case 0x11:
switch (fn7) {
case 0x00:
/* AND */
if (likely(rc != 31)) {
if (ra == 31)
tcg_gen_movi_i64(cpu_ir[rc], 0);
else if (islit)
tcg_gen_andi_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_and_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
}
break;
case 0x08:
/* BIC */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_andi_i64(cpu_ir[rc], cpu_ir[ra], ~lit);
else
tcg_gen_andc_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
break;
case 0x14:
/* CMOVLBS */
gen_cmov(TCG_COND_EQ, ra, rb, rc, islit, lit, 1);
break;
case 0x16:
/* CMOVLBC */
gen_cmov(TCG_COND_NE, ra, rb, rc, islit, lit, 1);
break;
case 0x20:
/* BIS */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_ori_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_or_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x24:
/* CMOVEQ */
gen_cmov(TCG_COND_NE, ra, rb, rc, islit, lit, 0);
break;
case 0x26:
/* CMOVNE */
gen_cmov(TCG_COND_EQ, ra, rb, rc, islit, lit, 0);
break;
case 0x28:
/* ORNOT */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_ori_i64(cpu_ir[rc], cpu_ir[ra], ~lit);
else
tcg_gen_orc_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], ~lit);
else
tcg_gen_not_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x40:
/* XOR */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_xori_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_xor_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x44:
/* CMOVLT */
gen_cmov(TCG_COND_GE, ra, rb, rc, islit, lit, 0);
break;
case 0x46:
/* CMOVGE */
gen_cmov(TCG_COND_LT, ra, rb, rc, islit, lit, 0);
break;
case 0x48:
/* EQV */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_xori_i64(cpu_ir[rc], cpu_ir[ra], ~lit);
else
tcg_gen_eqv_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], ~lit);
else
tcg_gen_not_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x61:
/* AMASK */
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], helper_amask(lit));
else
tcg_gen_helper_1_1(helper_amask, cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x64:
/* CMOVLE */
gen_cmov(TCG_COND_GT, ra, rb, rc, islit, lit, 0);
break;
case 0x66:
/* CMOVGT */
gen_cmov(TCG_COND_LE, ra, rb, rc, islit, lit, 0);
break;
case 0x6C:
/* IMPLVER */
if (rc != 31)
tcg_gen_helper_1_0(helper_load_implver, cpu_ir[rc]);
break;
default:
goto invalid_opc;
}
break;
case 0x12:
switch (fn7) {
case 0x02:
/* MSKBL */
gen_arith3(helper_mskbl, ra, rb, rc, islit, lit);
break;
case 0x06:
/* EXTBL */
gen_ext_l(&tcg_gen_ext8u_i64, ra, rb, rc, islit, lit);
break;
case 0x0B:
/* INSBL */
gen_arith3(helper_insbl, ra, rb, rc, islit, lit);
break;
case 0x12:
/* MSKWL */
gen_arith3(helper_mskwl, ra, rb, rc, islit, lit);
break;
case 0x16:
/* EXTWL */
gen_ext_l(&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit);
break;
case 0x1B:
/* INSWL */
gen_arith3(helper_inswl, ra, rb, rc, islit, lit);
break;
case 0x22:
/* MSKLL */
gen_arith3(helper_mskll, ra, rb, rc, islit, lit);
break;
case 0x26:
/* EXTLL */
gen_ext_l(&tcg_gen_ext32u_i64, ra, rb, rc, islit, lit);
break;
case 0x2B:
/* INSLL */
gen_arith3(helper_insll, ra, rb, rc, islit, lit);
break;
case 0x30:
/* ZAP */
gen_arith3(helper_zap, ra, rb, rc, islit, lit);
break;
case 0x31:
/* ZAPNOT */
gen_arith3(helper_zapnot, ra, rb, rc, islit, lit);
break;
case 0x32:
/* MSKQL */
gen_arith3(helper_mskql, ra, rb, rc, islit, lit);
break;
case 0x34:
/* SRL */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_shri_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
else {
TCGv shift = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
tcg_gen_shr_i64(cpu_ir[rc], cpu_ir[ra], shift);
tcg_temp_free(shift);
}
} else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
break;
case 0x36:
/* EXTQL */
gen_ext_l(NULL, ra, rb, rc, islit, lit);
break;
case 0x39:
/* SLL */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_shli_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
else {
TCGv shift = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
tcg_gen_shl_i64(cpu_ir[rc], cpu_ir[ra], shift);
tcg_temp_free(shift);
}
} else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
break;
case 0x3B:
/* INSQL */
gen_arith3(helper_insql, ra, rb, rc, islit, lit);
break;
case 0x3C:
/* SRA */
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_sari_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
else {
TCGv shift = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
tcg_gen_sar_i64(cpu_ir[rc], cpu_ir[ra], shift);
tcg_temp_free(shift);
}
} else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
break;
case 0x52:
/* MSKWH */
gen_arith3(helper_mskwh, ra, rb, rc, islit, lit);
break;
case 0x57:
/* INSWH */
gen_arith3(helper_inswh, ra, rb, rc, islit, lit);
break;
case 0x5A:
/* EXTWH */
gen_ext_h(&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit);
break;
case 0x62:
/* MSKLH */
gen_arith3(helper_msklh, ra, rb, rc, islit, lit);
break;
case 0x67:
/* INSLH */
gen_arith3(helper_inslh, ra, rb, rc, islit, lit);
break;
case 0x6A:
/* EXTLH */
gen_ext_h(&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit);
break;
case 0x72:
/* MSKQH */
gen_arith3(helper_mskqh, ra, rb, rc, islit, lit);
break;
case 0x77:
/* INSQH */
gen_arith3(helper_insqh, ra, rb, rc, islit, lit);
break;
case 0x7A:
/* EXTQH */
gen_ext_h(NULL, ra, rb, rc, islit, lit);
break;
default:
goto invalid_opc;
}
break;
case 0x13:
switch (fn7) {
case 0x00:
/* MULL */
if (likely(rc != 31)) {
if (ra == 31)
tcg_gen_movi_i64(cpu_ir[rc], 0);
else {
if (islit)
tcg_gen_muli_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_mul_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
}
break;
case 0x20:
/* MULQ */
if (likely(rc != 31)) {
if (ra == 31)
tcg_gen_movi_i64(cpu_ir[rc], 0);
else if (islit)
tcg_gen_muli_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_mul_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
}
break;
case 0x30:
/* UMULH */
gen_arith3(helper_umulh, ra, rb, rc, islit, lit);
break;
case 0x40:
/* MULL/V */
gen_arith3(helper_mullv, ra, rb, rc, islit, lit);
break;
case 0x60:
/* MULQ/V */
gen_arith3(helper_mulqv, ra, rb, rc, islit, lit);
break;
default:
goto invalid_opc;
}
break;
case 0x14:
switch (fpfn) { /* f11 & 0x3F */
case 0x04:
/* ITOFS */
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I32);
tcg_gen_trunc_i64_i32(tmp, cpu_ir[ra]);
tcg_gen_helper_1_1(helper_memory_to_s, cpu_fir[rc], tmp);
tcg_temp_free(tmp);
} else
tcg_gen_movi_i64(cpu_fir[rc], 0);
}
break;
case 0x0A:
/* SQRTF */
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
gen_farith2(&helper_sqrtf, rb, rc);
break;
case 0x0B:
/* SQRTS */
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
gen_farith2(&helper_sqrts, rb, rc);
break;
case 0x14:
/* ITOFF */
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I32);
tcg_gen_trunc_i64_i32(tmp, cpu_ir[ra]);
tcg_gen_helper_1_1(helper_memory_to_f, cpu_fir[rc], tmp);
tcg_temp_free(tmp);
} else
tcg_gen_movi_i64(cpu_fir[rc], 0);
}
break;
case 0x24:
/* ITOFT */
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (ra != 31)
tcg_gen_mov_i64(cpu_fir[rc], cpu_ir[ra]);
else
tcg_gen_movi_i64(cpu_fir[rc], 0);
}
break;
case 0x2A:
/* SQRTG */
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
gen_farith2(&helper_sqrtg, rb, rc);
break;
case 0x02B:
/* SQRTT */
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
gen_farith2(&helper_sqrtt, rb, rc);
break;
default:
goto invalid_opc;
}
break;
case 0x15:
/* VAX floating point */
/* XXX: rounding mode and trap are ignored (!) */
switch (fpfn) { /* f11 & 0x3F */
case 0x00:
/* ADDF */
gen_farith3(&helper_addf, ra, rb, rc);
break;
case 0x01:
/* SUBF */
gen_farith3(&helper_subf, ra, rb, rc);
break;
case 0x02:
/* MULF */
gen_farith3(&helper_mulf, ra, rb, rc);
break;
case 0x03:
/* DIVF */
gen_farith3(&helper_divf, ra, rb, rc);
break;
case 0x1E:
/* CVTDG */
#if 0 // TODO
gen_farith2(&helper_cvtdg, rb, rc);
#else
goto invalid_opc;
#endif
break;
case 0x20:
/* ADDG */
gen_farith3(&helper_addg, ra, rb, rc);
break;
case 0x21:
/* SUBG */
gen_farith3(&helper_subg, ra, rb, rc);
break;
case 0x22:
/* MULG */
gen_farith3(&helper_mulg, ra, rb, rc);
break;
case 0x23:
/* DIVG */
gen_farith3(&helper_divg, ra, rb, rc);
break;
case 0x25:
/* CMPGEQ */
gen_farith3(&helper_cmpgeq, ra, rb, rc);
break;
case 0x26:
/* CMPGLT */
gen_farith3(&helper_cmpglt, ra, rb, rc);
break;
case 0x27:
/* CMPGLE */
gen_farith3(&helper_cmpgle, ra, rb, rc);
break;
case 0x2C:
/* CVTGF */
gen_farith2(&helper_cvtgf, rb, rc);
break;
case 0x2D:
/* CVTGD */
#if 0 // TODO
gen_farith2(ctx, &helper_cvtgd, rb, rc);
#else
goto invalid_opc;
#endif
break;
case 0x2F:
/* CVTGQ */
gen_farith2(&helper_cvtgq, rb, rc);
break;
case 0x3C:
/* CVTQF */
gen_farith2(&helper_cvtqf, rb, rc);
break;
case 0x3E:
/* CVTQG */
gen_farith2(&helper_cvtqg, rb, rc);
break;
default:
goto invalid_opc;
}
break;
case 0x16:
/* IEEE floating-point */
/* XXX: rounding mode and traps are ignored (!) */
switch (fpfn) { /* f11 & 0x3F */
case 0x00:
/* ADDS */
gen_farith3(&helper_adds, ra, rb, rc);
break;
case 0x01:
/* SUBS */
gen_farith3(&helper_subs, ra, rb, rc);
break;
case 0x02:
/* MULS */
gen_farith3(&helper_muls, ra, rb, rc);
break;
case 0x03:
/* DIVS */
gen_farith3(&helper_divs, ra, rb, rc);
break;
case 0x20:
/* ADDT */
gen_farith3(&helper_addt, ra, rb, rc);
break;
case 0x21:
/* SUBT */
gen_farith3(&helper_subt, ra, rb, rc);
break;
case 0x22:
/* MULT */
gen_farith3(&helper_mult, ra, rb, rc);
break;
case 0x23:
/* DIVT */
gen_farith3(&helper_divt, ra, rb, rc);
break;
case 0x24:
/* CMPTUN */
gen_farith3(&helper_cmptun, ra, rb, rc);
break;
case 0x25:
/* CMPTEQ */
gen_farith3(&helper_cmpteq, ra, rb, rc);
break;
case 0x26:
/* CMPTLT */
gen_farith3(&helper_cmptlt, ra, rb, rc);
break;
case 0x27:
/* CMPTLE */
gen_farith3(&helper_cmptle, ra, rb, rc);
break;
case 0x2C:
/* XXX: incorrect */
if (fn11 == 0x2AC) {
/* CVTST */
gen_farith2(&helper_cvtst, rb, rc);
} else {
/* CVTTS */
gen_farith2(&helper_cvtts, rb, rc);
}
break;
case 0x2F:
/* CVTTQ */
gen_farith2(&helper_cvttq, rb, rc);
break;
case 0x3C:
/* CVTQS */
gen_farith2(&helper_cvtqs, rb, rc);
break;
case 0x3E:
/* CVTQT */
gen_farith2(&helper_cvtqt, rb, rc);
break;
default:
goto invalid_opc;
}
break;
case 0x17:
switch (fn11) {
case 0x010:
/* CVTLQ */
gen_farith2(&helper_cvtlq, rb, rc);
break;
case 0x020:
if (likely(rc != 31)) {
if (ra == rb)
/* FMOV */
tcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]);
else
/* CPYS */
gen_farith3(&helper_cpys, ra, rb, rc);
}
break;
case 0x021:
/* CPYSN */
gen_farith3(&helper_cpysn, ra, rb, rc);
break;
case 0x022:
/* CPYSE */
gen_farith3(&helper_cpyse, ra, rb, rc);
break;
case 0x024:
/* MT_FPCR */
if (likely(ra != 31))
tcg_gen_helper_0_1(helper_store_fpcr, cpu_fir[ra]);
else {
TCGv tmp = tcg_const_i64(0);
tcg_gen_helper_0_1(helper_store_fpcr, tmp);
tcg_temp_free(tmp);
}
break;
case 0x025:
/* MF_FPCR */
if (likely(ra != 31))
tcg_gen_helper_1_0(helper_load_fpcr, cpu_fir[ra]);
break;
case 0x02A:
/* FCMOVEQ */
gen_fcmov(&helper_cmpfeq, ra, rb, rc);
break;
case 0x02B:
/* FCMOVNE */
gen_fcmov(&helper_cmpfne, ra, rb, rc);
break;
case 0x02C:
/* FCMOVLT */
gen_fcmov(&helper_cmpflt, ra, rb, rc);
break;
case 0x02D:
/* FCMOVGE */
gen_fcmov(&helper_cmpfge, ra, rb, rc);
break;
case 0x02E:
/* FCMOVLE */
gen_fcmov(&helper_cmpfle, ra, rb, rc);
break;
case 0x02F:
/* FCMOVGT */
gen_fcmov(&helper_cmpfgt, ra, rb, rc);
break;
case 0x030:
/* CVTQL */
gen_farith2(&helper_cvtql, rb, rc);
break;
case 0x130:
/* CVTQL/V */
gen_farith2(&helper_cvtqlv, rb, rc);
break;
case 0x530:
/* CVTQL/SV */
gen_farith2(&helper_cvtqlsv, rb, rc);
break;
default:
goto invalid_opc;
}
break;
case 0x18:
switch ((uint16_t)disp16) {
case 0x0000:
/* TRAPB */
/* No-op. Just exit from the current tb */
ret = 2;
break;
case 0x0400:
/* EXCB */
/* No-op. Just exit from the current tb */
ret = 2;
break;
case 0x4000:
/* MB */
/* No-op */
break;
case 0x4400:
/* WMB */
/* No-op */
break;
case 0x8000:
/* FETCH */
/* No-op */
break;
case 0xA000:
/* FETCH_M */
/* No-op */
break;
case 0xC000:
/* RPCC */
if (ra != 31)
tcg_gen_helper_1_0(helper_load_pcc, cpu_ir[ra]);
break;
case 0xE000:
/* RC */
if (ra != 31)
tcg_gen_helper_1_0(helper_rc, cpu_ir[ra]);
break;
case 0xE800:
/* ECB */
/* XXX: TODO: evict tb cache at address rb */
#if 0
ret = 2;
#else
goto invalid_opc;
#endif
break;
case 0xF000:
/* RS */
if (ra != 31)
tcg_gen_helper_1_0(helper_rs, cpu_ir[ra]);
break;
case 0xF800:
/* WH64 */
/* No-op */
break;
default:
goto invalid_opc;
}
break;
case 0x19:
/* HW_MFPR (PALcode) */
#if defined (CONFIG_USER_ONLY)
goto invalid_opc;
#else
if (!ctx->pal_mode)
goto invalid_opc;
if (ra != 31) {
TCGv tmp = tcg_const_i32(insn & 0xFF);
tcg_gen_helper_1_2(helper_mfpr, cpu_ir[ra], tmp, cpu_ir[ra]);
tcg_temp_free(tmp);
}
break;
#endif
case 0x1A:
if (ra != 31)
tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
if (rb != 31)
tcg_gen_andi_i64(cpu_pc, cpu_ir[rb], ~3);
else
tcg_gen_movi_i64(cpu_pc, 0);
/* Those four jumps only differ by the branch prediction hint */
switch (fn2) {
case 0x0:
/* JMP */
break;
case 0x1:
/* JSR */
break;
case 0x2:
/* RET */
break;
case 0x3:
/* JSR_COROUTINE */
break;
}
ret = 1;
break;
case 0x1B:
/* HW_LD (PALcode) */
#if defined (CONFIG_USER_ONLY)
goto invalid_opc;
#else
if (!ctx->pal_mode)
goto invalid_opc;
if (ra != 31) {
TCGv addr = tcg_temp_new(TCG_TYPE_I64);
if (rb != 31)
tcg_gen_addi_i64(addr, cpu_ir[rb], disp12);
else
tcg_gen_movi_i64(addr, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
/* Longword physical access */
tcg_gen_helper_0_2(helper_ldl_raw, cpu_ir[ra], addr);
break;
case 0x1:
/* Quadword physical access */
tcg_gen_helper_0_2(helper_ldq_raw, cpu_ir[ra], addr);
break;
case 0x2:
/* Longword physical access with lock */
tcg_gen_helper_0_2(helper_ldl_l_raw, cpu_ir[ra], addr);
break;
case 0x3:
/* Quadword physical access with lock */
tcg_gen_helper_0_2(helper_ldq_l_raw, cpu_ir[ra], addr);
break;
case 0x4:
/* Longword virtual PTE fetch */
tcg_gen_helper_0_2(helper_ldl_kernel, cpu_ir[ra], addr);
break;
case 0x5:
/* Quadword virtual PTE fetch */
tcg_gen_helper_0_2(helper_ldq_kernel, cpu_ir[ra], addr);
break;
case 0x6:
/* Incpu_ir[ra]id */
goto incpu_ir[ra]id_opc;
case 0x7:
/* Incpu_ir[ra]id */
goto incpu_ir[ra]id_opc;
case 0x8:
/* Longword virtual access */
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_ldl_raw, cpu_ir[ra], addr);
break;
case 0x9:
/* Quadword virtual access */
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_ldq_raw, cpu_ir[ra], addr);
break;
case 0xA:
/* Longword virtual access with protection check */
tcg_gen_qemu_ld32s(cpu_ir[ra], addr, ctx->flags);
break;
case 0xB:
/* Quadword virtual access with protection check */
tcg_gen_qemu_ld64(cpu_ir[ra], addr, ctx->flags);
break;
case 0xC:
/* Longword virtual access with altenate access mode */
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_ldl_raw, cpu_ir[ra], addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
case 0xD:
/* Quadword virtual access with altenate access mode */
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_ldq_raw, cpu_ir[ra], addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
case 0xE:
/* Longword virtual access with alternate access mode and
* protection checks
*/
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_0_2(helper_ldl_data, cpu_ir[ra], addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
case 0xF:
/* Quadword virtual access with alternate access mode and
* protection checks
*/
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_0_2(helper_ldq_data, cpu_ir[ra], addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
}
tcg_temp_free(addr);
}
break;
#endif
case 0x1C:
switch (fn7) {
case 0x00:
/* SEXTB */
if (!(ctx->amask & AMASK_BWX))
goto invalid_opc;
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], (int64_t)((int8_t)lit));
else
tcg_gen_ext8s_i64(cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x01:
/* SEXTW */
if (!(ctx->amask & AMASK_BWX))
goto invalid_opc;
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], (int64_t)((int16_t)lit));
else
tcg_gen_ext16s_i64(cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x30:
/* CTPOP */
if (!(ctx->amask & AMASK_CIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], ctpop64(lit));
else
tcg_gen_helper_1_1(helper_ctpop, cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x31:
/* PERR */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x32:
/* CTLZ */
if (!(ctx->amask & AMASK_CIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], clz64(lit));
else
tcg_gen_helper_1_1(helper_ctlz, cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x33:
/* CTTZ */
if (!(ctx->amask & AMASK_CIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], ctz64(lit));
else
tcg_gen_helper_1_1(helper_cttz, cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x34:
/* UNPKBW */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x35:
/* UNPKWL */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x36:
/* PKWB */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x37:
/* PKLB */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x38:
/* MINSB8 */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x39:
/* MINSW4 */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x3A:
/* MINUB8 */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x3B:
/* MINUW4 */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x3C:
/* MAXUB8 */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x3D:
/* MAXUW4 */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x3E:
/* MAXSB8 */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x3F:
/* MAXSW4 */
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
/* XXX: TODO */
goto invalid_opc;
break;
case 0x70:
/* FTOIT */
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (ra != 31)
tcg_gen_mov_i64(cpu_ir[rc], cpu_fir[ra]);
else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
break;
case 0x78:
/* FTOIS */
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
if (rc != 31) {
TCGv tmp1 = tcg_temp_new(TCG_TYPE_I32);
if (ra != 31)
tcg_gen_helper_1_1(helper_s_to_memory, tmp1, cpu_fir[ra]);
else {
TCGv tmp2 = tcg_const_i64(0);
tcg_gen_helper_1_1(helper_s_to_memory, tmp1, tmp2);
tcg_temp_free(tmp2);
}
tcg_gen_ext_i32_i64(cpu_ir[rc], tmp1);
tcg_temp_free(tmp1);
}
break;
default:
goto invalid_opc;
}
break;
case 0x1D:
/* HW_MTPR (PALcode) */
#if defined (CONFIG_USER_ONLY)
goto invalid_opc;
#else
if (!ctx->pal_mode)
goto invalid_opc;
else {
TCGv tmp1 = tcg_const_i32(insn & 0xFF);
if (ra != 31)
tcg_gen_helper(helper_mtpr, tmp1, cpu_ir[ra]);
else {
TCGv tmp2 = tcg_const_i64(0);
tcg_gen_helper(helper_mtpr, tmp1, tmp2);
tcg_temp_free(tmp2);
}
tcg_temp_free(tmp1);
ret = 2;
}
break;
#endif
case 0x1E:
/* HW_REI (PALcode) */
#if defined (CONFIG_USER_ONLY)
goto invalid_opc;
#else
if (!ctx->pal_mode)
goto invalid_opc;
if (rb == 31) {
/* "Old" alpha */
tcg_gen_helper_0_0(helper_hw_rei);
} else {
TCGv tmp;
if (ra != 31) {
tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_addi_i64(tmp, cpu_ir[rb], (((int64_t)insn << 51) >> 51));
} else
tmp = tcg_const_i64(((int64_t)insn << 51) >> 51);
tcg_gen_helper_0_1(helper_hw_ret, tmp);
tcg_temp_free(tmp);
}
ret = 2;
break;
#endif
case 0x1F:
/* HW_ST (PALcode) */
#if defined (CONFIG_USER_ONLY)
goto invalid_opc;
#else
if (!ctx->pal_mode)
goto invalid_opc;
else {
TCGv addr, val;
addr = tcg_temp_new(TCG_TYPE_I64);
if (rb != 31)
tcg_gen_addi_i64(addr, cpu_ir[rb], disp12);
else
tcg_gen_movi_i64(addr, disp12);
if (ra != 31)
val = cpu_ir[ra];
else {
val = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_movi_i64(val, 0);
}
switch ((insn >> 12) & 0xF) {
case 0x0:
/* Longword physical access */
tcg_gen_helper_0_2(helper_stl_raw, val, addr);
break;
case 0x1:
/* Quadword physical access */
tcg_gen_helper_0_2(helper_stq_raw, val, addr);
break;
case 0x2:
/* Longword physical access with lock */
tcg_gen_helper_1_2(helper_stl_c_raw, val, val, addr);
break;
case 0x3:
/* Quadword physical access with lock */
tcg_gen_helper_1_2(helper_stq_c_raw, val, val, addr);
break;
case 0x4:
/* Longword virtual access */
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_stl_raw, val, addr);
break;
case 0x5:
/* Quadword virtual access */
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_stq_raw, val, addr);
break;
case 0x6:
/* Invalid */
goto invalid_opc;
case 0x7:
/* Invalid */
goto invalid_opc;
case 0x8:
/* Invalid */
goto invalid_opc;
case 0x9:
/* Invalid */
goto invalid_opc;
case 0xA:
/* Invalid */
goto invalid_opc;
case 0xB:
/* Invalid */
goto invalid_opc;
case 0xC:
/* Longword virtual access with alternate access mode */
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_stl_raw, val, addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
case 0xD:
/* Quadword virtual access with alternate access mode */
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_stl_raw, val, addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
case 0xE:
/* Invalid */
goto invalid_opc;
case 0xF:
/* Invalid */
goto invalid_opc;
}
if (ra != 31)
tcg_temp_free(val);
tcg_temp_free(addr);
}
ret = 2;
break;
#endif
case 0x20:
/* LDF */
gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);
break;
case 0x21:
/* LDG */
gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);
break;
case 0x22:
/* LDS */
gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);
break;
case 0x23:
/* LDT */
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);
break;
case 0x24:
/* STF */
gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);
break;
case 0x25:
/* STG */
gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);
break;
case 0x26:
/* STS */
gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);
break;
case 0x27:
/* STT */
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);
break;
case 0x28:
/* LDL */
gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);
break;
case 0x29:
/* LDQ */
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);
break;
case 0x2A:
/* LDL_L */
gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);
break;
case 0x2B:
/* LDQ_L */
gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);
break;
case 0x2C:
/* STL */
gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);
break;
case 0x2D:
/* STQ */
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);
break;
case 0x2E:
/* STL_C */
gen_store_mem(ctx, &gen_qemu_stl_c, ra, rb, disp16, 0, 0);
break;
case 0x2F:
/* STQ_C */
gen_store_mem(ctx, &gen_qemu_stq_c, ra, rb, disp16, 0, 0);
break;
case 0x30:
/* BR */
if (ra != 31)
tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp21 << 2));
ret = 1;
break;
case 0x31:
/* FBEQ */
gen_fbcond(ctx, &helper_cmpfeq, ra, disp16);
ret = 1;
break;
case 0x32:
/* FBLT */
gen_fbcond(ctx, &helper_cmpflt, ra, disp16);
ret = 1;
break;
case 0x33:
/* FBLE */
gen_fbcond(ctx, &helper_cmpfle, ra, disp16);
ret = 1;
break;
case 0x34:
/* BSR */
if (ra != 31)
tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp21 << 2));
ret = 1;
break;
case 0x35:
/* FBNE */
gen_fbcond(ctx, &helper_cmpfne, ra, disp16);
ret = 1;
break;
case 0x36:
/* FBGE */
gen_fbcond(ctx, &helper_cmpfge, ra, disp16);
ret = 1;
break;
case 0x37:
/* FBGT */
gen_fbcond(ctx, &helper_cmpfgt, ra, disp16);
ret = 1;
break;
case 0x38:
/* BLBC */
gen_bcond(ctx, TCG_COND_EQ, ra, disp16, 1);
ret = 1;
break;
case 0x39:
/* BEQ */
gen_bcond(ctx, TCG_COND_EQ, ra, disp16, 0);
ret = 1;
break;
case 0x3A:
/* BLT */
gen_bcond(ctx, TCG_COND_LT, ra, disp16, 0);
ret = 1;
break;
case 0x3B:
/* BLE */
gen_bcond(ctx, TCG_COND_LE, ra, disp16, 0);
ret = 1;
break;
case 0x3C:
/* BLBS */
gen_bcond(ctx, TCG_COND_NE, ra, disp16, 1);
ret = 1;
break;
case 0x3D:
/* BNE */
gen_bcond(ctx, TCG_COND_NE, ra, disp16, 0);
ret = 1;
break;
case 0x3E:
/* BGE */
gen_bcond(ctx, TCG_COND_GE, ra, disp16, 0);
ret = 1;
break;
case 0x3F:
/* BGT */
gen_bcond(ctx, TCG_COND_GT, ra, disp16, 0);
ret = 1;
break;
invalid_opc:
gen_invalid(ctx);
ret = 3;
break;
}
return ret;
}
| 11,287 |
FFmpeg | 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec | 1 | void ff_aac_search_for_is(AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe)
{
SingleChannelElement *sce0 = &cpe->ch[0];
SingleChannelElement *sce1 = &cpe->ch[1];
int start = 0, count = 0, w, w2, g, i;
const float freq_mult = avctx->sample_rate/(1024.0f/sce0->ics.num_windows)/2.0f;
if (!cpe->common_window)
return;
for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) {
start = 0;
for (g = 0; g < sce0->ics.num_swb; g++) {
if (start*freq_mult > INT_STEREO_LOW_LIMIT*(s->lambda/170.0f) &&
cpe->ch[0].band_type[w*16+g] != NOISE_BT && !cpe->ch[0].zeroes[w*16+g] &&
cpe->ch[1].band_type[w*16+g] != NOISE_BT && !cpe->ch[1].zeroes[w*16+g]) {
float ener0 = 0.0f, ener1 = 0.0f, ener01 = 0.0f;
struct AACISError ph_err1, ph_err2, *erf;
if (sce0->band_type[w*16+g] == NOISE_BT ||
sce1->band_type[w*16+g] == NOISE_BT) {
start += sce0->ics.swb_sizes[g];
continue;
}
for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
float coef0 = fabsf(sce0->pcoeffs[start+(w+w2)*128+i]);
float coef1 = fabsf(sce1->pcoeffs[start+(w+w2)*128+i]);
ener0 += coef0*coef0;
ener1 += coef1*coef1;
ener01 += (coef0 + coef1)*(coef0 + coef1);
}
}
ph_err1 = ff_aac_is_encoding_err(s, cpe, start, w, g,
ener0, ener1, ener01, 0, -1);
ph_err2 = ff_aac_is_encoding_err(s, cpe, start, w, g,
ener0, ener1, ener01, 0, +1);
erf = ph_err1.error < ph_err2.error ? &ph_err1 : &ph_err2;
if (erf->pass) {
cpe->is_mask[w*16+g] = 1;
cpe->ch[0].is_ener[w*16+g] = sqrt(ener0/ener01);
cpe->ch[1].is_ener[w*16+g] = ener0/ener1;
cpe->ch[1].band_type[w*16+g] = erf->phase ? INTENSITY_BT : INTENSITY_BT2;
count++;
}
}
start += sce0->ics.swb_sizes[g];
}
}
cpe->is_mode = !!count;
}
| 11,289 |
FFmpeg | 1f95fb58137951941d8d74bd47b1635b6d2399ec | 1 | static int yuv4_write_header(AVFormatContext *s)
{
int* first_pkt = s->priv_data;
if (s->nb_streams != 1)
return AVERROR(EIO);
if (s->streams[0]->codec->pix_fmt == PIX_FMT_YUV411P) {
av_log(s, AV_LOG_ERROR, "Warning: generating rarely used 4:1:1 YUV stream, some mjpegtools might not work.\n");
else if ((s->streams[0]->codec->pix_fmt != PIX_FMT_YUV420P) &&
(s->streams[0]->codec->pix_fmt != PIX_FMT_YUV422P) &&
(s->streams[0]->codec->pix_fmt != PIX_FMT_GRAY8) &&
(s->streams[0]->codec->pix_fmt != PIX_FMT_YUV444P)) {
av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg only handles yuv444p, yuv422p, yuv420p, yuv411p and gray pixel formats. Use -pix_fmt to select one.\n");
return AVERROR(EIO);
*first_pkt = 1;
return 0; | 11,290 |
qemu | efec3dd631d94160288392721a5f9c39e50fb2bc | 1 | static void vmmouse_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = vmmouse_realizefn;
dc->no_user = 1;
dc->reset = vmmouse_reset;
dc->vmsd = &vmstate_vmmouse;
dc->props = vmmouse_properties;
}
| 11,291 |
qemu | ce137829e7e58fcdc5ba63b5e256f972e80be438 | 1 | static inline void array_free(array_t* array)
{
if(array->pointer)
free(array->pointer);
array->size=array->next=0;
}
| 11,292 |
qemu | 4656e1f01289cc3aa20986deb6a407165826abe5 | 1 | int get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, target_ulong eaddr,
int rw, int access_type)
{
int ret;
#if 0
qemu_log("%s\n", __func__);
#endif
if ((access_type == ACCESS_CODE && msr_ir == 0) ||
(access_type != ACCESS_CODE && msr_dr == 0)) {
if (env->mmu_model == POWERPC_MMU_BOOKE) {
/* The BookE MMU always performs address translation. The
IS and DS bits only affect the address space. */
ret = mmubooke_get_physical_address(env, ctx, eaddr,
rw, access_type);
} else if (env->mmu_model == POWERPC_MMU_BOOKE206) {
ret = mmubooke206_get_physical_address(env, ctx, eaddr, rw,
access_type);
} else {
/* No address translation. */
ret = check_physical(env, ctx, eaddr, rw);
}
} else {
ret = -1;
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
/* Try to find a BAT */
if (env->nb_BATs != 0) {
ret = get_bat(env, ctx, eaddr, rw, access_type);
}
#if defined(TARGET_PPC64)
case POWERPC_MMU_620:
case POWERPC_MMU_64B:
case POWERPC_MMU_2_06:
#endif
if (ret < 0) {
/* We didn't match any BAT entry or don't have BATs */
ret = get_segment(env, ctx, eaddr, rw, access_type);
}
break;
case POWERPC_MMU_SOFT_4xx:
case POWERPC_MMU_SOFT_4xx_Z:
ret = mmu40x_get_physical_address(env, ctx, eaddr,
rw, access_type);
break;
case POWERPC_MMU_BOOKE:
ret = mmubooke_get_physical_address(env, ctx, eaddr,
rw, access_type);
break;
case POWERPC_MMU_BOOKE206:
ret = mmubooke206_get_physical_address(env, ctx, eaddr, rw,
access_type);
break;
case POWERPC_MMU_MPC8xx:
/* XXX: TODO */
cpu_abort(env, "MPC8xx MMU model is not implemented\n");
break;
case POWERPC_MMU_REAL:
cpu_abort(env, "PowerPC in real mode do not do any translation\n");
return -1;
default:
cpu_abort(env, "Unknown or invalid MMU model\n");
return -1;
}
}
#if 0
qemu_log("%s address " TARGET_FMT_lx " => %d " TARGET_FMT_plx "\n",
__func__, eaddr, ret, ctx->raddr);
#endif
return ret;
} | 11,294 |
FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | 1 | static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
{
Mpeg4DecContext *ctx = avctx->priv_data;
MpegEncContext * const s = &ctx->m;
struct vaapi_context * const vactx = avctx->hwaccel_context;
VAPictureParameterBufferMPEG4 *pic_param;
VAIQMatrixBufferMPEG4 *iq_matrix;
int i;
av_dlog(avctx, "vaapi_mpeg4_start_frame()\n");
vactx->slice_param_size = sizeof(VASliceParameterBufferMPEG4);
/* Fill in VAPictureParameterBufferMPEG4 */
pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferMPEG4));
if (!pic_param)
return -1;
pic_param->vop_width = s->width;
pic_param->vop_height = s->height;
pic_param->forward_reference_picture = VA_INVALID_ID;
pic_param->backward_reference_picture = VA_INVALID_ID;
pic_param->vol_fields.value = 0; /* reset all bits */
pic_param->vol_fields.bits.short_video_header = avctx->codec->id == AV_CODEC_ID_H263;
pic_param->vol_fields.bits.chroma_format = CHROMA_420;
pic_param->vol_fields.bits.interlaced = !s->progressive_sequence;
pic_param->vol_fields.bits.obmc_disable = 1;
pic_param->vol_fields.bits.sprite_enable = ctx->vol_sprite_usage;
pic_param->vol_fields.bits.sprite_warping_accuracy = s->sprite_warping_accuracy;
pic_param->vol_fields.bits.quant_type = s->mpeg_quant;
pic_param->vol_fields.bits.quarter_sample = s->quarter_sample;
pic_param->vol_fields.bits.data_partitioned = s->data_partitioning;
pic_param->vol_fields.bits.reversible_vlc = ctx->rvlc;
pic_param->vol_fields.bits.resync_marker_disable = !ctx->resync_marker;
pic_param->no_of_sprite_warping_points = ctx->num_sprite_warping_points;
for (i = 0; i < ctx->num_sprite_warping_points && i < 3; i++) {
pic_param->sprite_trajectory_du[i] = ctx->sprite_traj[i][0];
pic_param->sprite_trajectory_dv[i] = ctx->sprite_traj[i][1];
}
pic_param->quant_precision = s->quant_precision;
pic_param->vop_fields.value = 0; /* reset all bits */
pic_param->vop_fields.bits.vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I;
pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == AV_PICTURE_TYPE_B ? s->next_picture.f.pict_type - AV_PICTURE_TYPE_I : 0;
pic_param->vop_fields.bits.vop_rounding_type = s->no_rounding;
pic_param->vop_fields.bits.intra_dc_vlc_thr = mpeg4_get_intra_dc_vlc_thr(ctx);
pic_param->vop_fields.bits.top_field_first = s->top_field_first;
pic_param->vop_fields.bits.alternate_vertical_scan_flag = s->alternate_scan;
pic_param->vop_fcode_forward = s->f_code;
pic_param->vop_fcode_backward = s->b_code;
pic_param->vop_time_increment_resolution = avctx->time_base.den;
pic_param->num_macroblocks_in_gob = s->mb_width * ff_h263_get_gob_height(s);
pic_param->num_gobs_in_vop = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob;
pic_param->TRB = s->pb_time;
pic_param->TRD = s->pp_time;
if (s->pict_type == AV_PICTURE_TYPE_B)
pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture.f);
if (s->pict_type != AV_PICTURE_TYPE_I)
pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture.f);
/* Fill in VAIQMatrixBufferMPEG4 */
/* Only the first inverse quantisation method uses the weighting matrices */
if (pic_param->vol_fields.bits.quant_type) {
iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferMPEG4));
if (!iq_matrix)
return -1;
iq_matrix->load_intra_quant_mat = 1;
iq_matrix->load_non_intra_quant_mat = 1;
for (i = 0; i < 64; i++) {
int n = s->dsp.idct_permutation[ff_zigzag_direct[i]];
iq_matrix->intra_quant_mat[i] = s->intra_matrix[n];
iq_matrix->non_intra_quant_mat[i] = s->inter_matrix[n];
}
}
return 0;
}
| 11,296 |
FFmpeg | 746350ea0f7bde1e9fd23270e104af8897197293 | 0 | static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
{
int level, dc, diff, j, run;
int component;
RLTable *rl;
uint8_t * scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
/* DC coefficient */
if (n < 4) {
quant_matrix = s->intra_matrix;
component = 0;
} else {
quant_matrix = s->chroma_intra_matrix;
component = (n & 1) + 1;
}
diff = decode_dc(&s->gb, component);
if (diff >= 0xffff)
return -1;
dc = s->last_dc[component];
dc += diff;
s->last_dc[component] = dc;
block[0] = dc << (3 - s->intra_dc_precision);
if (s->intra_vlc_format)
rl = &ff_rl_mpeg2;
else
rl = &ff_rl_mpeg1;
{
OPEN_READER(re, &s->gb);
/* now quantify & encode AC coefficients */
for (;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (level == 127) {
break;
} else if (level != 0) {
scantable += run;
j = *scantable;
level = (level * qscale * quant_matrix[j]) >> 4;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
scantable += run;
j = *scantable;
if (level < 0) {
level = (-level * qscale * quant_matrix[j]) >> 4;
level = -level;
} else {
level = (level * qscale * quant_matrix[j]) >> 4;
}
}
block[j] = level;
}
CLOSE_READER(re, &s->gb);
}
s->block_last_index[n] = scantable - s->intra_scantable.permutated;
return 0;
}
| 11,297 |
qemu | faadf50e2962dd54175647a80bd6fc4319c91973 | 1 | target_phys_addr_t cpu_get_phys_page_debug (CPUState *env, target_ulong addr)
{
mmu_ctx_t ctx;
if (unlikely(get_physical_address(env, &ctx, addr, 0, ACCESS_INT, 1) != 0))
return -1;
return ctx.raddr & TARGET_PAGE_MASK;
}
| 11,298 |
FFmpeg | 0a467a9b594dd67aa96bad687d05f8845b009f18 | 1 | static unsigned tget_long(const uint8_t **p, int le)
{
unsigned v = le ? AV_RL32(*p) : AV_RB32(*p);
*p += 4;
return v;
}
| 11,299 |
qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | 0 | static unsigned int dec_move_r(DisasContext *dc)
{
int size = memsize_zz(dc);
DIS(fprintf (logfile, "move.%c $r%u, $r%u\n",
memsize_char(size), dc->op1, dc->op2));
cris_cc_mask(dc, CC_MASK_NZ);
if (size == 4) {
dec_prep_move_r(dc, dc->op1, dc->op2, size, 0, cpu_R[dc->op2]);
cris_cc_mask(dc, CC_MASK_NZ);
cris_update_cc_op(dc, CC_OP_MOVE, 4);
cris_update_cc_x(dc);
cris_update_result(dc, cpu_R[dc->op2]);
}
else {
TCGv t0;
t0 = tcg_temp_new(TCG_TYPE_TL);
dec_prep_move_r(dc, dc->op1, dc->op2, size, 0, t0);
cris_alu(dc, CC_OP_MOVE,
cpu_R[dc->op2],
cpu_R[dc->op2], t0, size);
tcg_temp_free(t0);
}
return 2;
}
| 11,300 |
qemu | d68a6f3a6deb2f5eee198b6fa46877a20227d86e | 0 | static void gen_neon_zip_u16(TCGv t0, TCGv t1)
{
TCGv tmp, tmp2;
tmp = new_tmp();
tmp2 = new_tmp();
tcg_gen_andi_i32(tmp, t0, 0xffff);
tcg_gen_shli_i32(tmp2, t1, 16);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_gen_andi_i32(t1, t1, 0xffff0000);
tcg_gen_shri_i32(tmp2, t0, 16);
tcg_gen_or_i32(t1, t1, tmp2);
tcg_gen_mov_i32(t0, tmp);
dead_tmp(tmp2);
dead_tmp(tmp);
}
| 11,301 |
qemu | e634b89c6ed2309814de7a89bd7c5ced96f59291 | 0 | static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,
int drc_index, const char *drc_name,
void *fdt, int node_offset)
{
int offset, ret;
int slot = PCI_SLOT(dev->devfn);
int func = PCI_FUNC(dev->devfn);
char nodename[FDT_NAME_MAX];
if (func != 0) {
snprintf(nodename, FDT_NAME_MAX, "pci@%x,%x", slot, func);
} else {
snprintf(nodename, FDT_NAME_MAX, "pci@%x", slot);
}
offset = fdt_add_subnode(fdt, node_offset, nodename);
ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb->index, drc_index,
phb);
g_assert(!ret);
if (ret) {
return 0;
}
return offset;
}
| 11,302 |
qemu | 5cd5e7015962d8d559afb5154888fd34a8526ddd | 0 | void shpc_cleanup(PCIDevice *d, MemoryRegion *bar)
{
SHPCDevice *shpc = d->shpc;
d->cap_present &= ~QEMU_PCI_CAP_SHPC;
memory_region_del_subregion(bar, &shpc->mmio);
object_unparent(OBJECT(&shpc->mmio));
/* TODO: cleanup config space changes? */
g_free(shpc->config);
g_free(shpc->cmask);
g_free(shpc->wmask);
g_free(shpc->w1cmask);
g_free(shpc);
}
| 11,304 |
qemu | e859eda58501cd20a2e6988fb4acc1756bc4d278 | 0 | static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp)
{
int flags, in = -1, out = -1;
flags = O_WRONLY | O_TRUNC | O_CREAT | O_BINARY;
out = qmp_chardev_open_file_source(file->out, flags, errp);
if (error_is_set(errp)) {
return NULL;
}
if (file->in) {
flags = O_RDONLY;
in = qmp_chardev_open_file_source(file->in, flags, errp);
if (error_is_set(errp)) {
qemu_close(out);
return NULL;
}
}
return qemu_chr_open_fd(in, out);
}
| 11,305 |
qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | 0 | static unsigned int dec_bound_r(DisasContext *dc)
{
TCGv l0;
int size = memsize_zz(dc);
DIS(fprintf (logfile, "bound.%c $r%u, $r%u\n",
memsize_char(size), dc->op1, dc->op2));
cris_cc_mask(dc, CC_MASK_NZ);
l0 = tcg_temp_local_new(TCG_TYPE_TL);
dec_prep_move_r(dc, dc->op1, dc->op2, size, 0, l0);
cris_alu(dc, CC_OP_BOUND, cpu_R[dc->op2], cpu_R[dc->op2], l0, 4);
tcg_temp_free(l0);
return 2;
}
| 11,306 |
qemu | a980a065fb5e86d6dec337e6cb6ff432f1a143c9 | 0 | static int usb_wacom_handle_control(USBDevice *dev, int request, int value,
int index, int length, uint8_t *data)
{
USBWacomState *s = (USBWacomState *) dev;
int ret;
ret = usb_desc_handle_control(dev, request, value, index, length, data);
if (ret >= 0) {
return ret;
}
ret = 0;
switch (request) {
case DeviceRequest | USB_REQ_GET_STATUS:
data[0] = (1 << USB_DEVICE_SELF_POWERED) |
(dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
data[1] = 0x00;
ret = 2;
break;
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 0;
} else {
goto fail;
}
ret = 0;
break;
case DeviceOutRequest | USB_REQ_SET_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 1;
} else {
goto fail;
}
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
data[0] = 1;
ret = 1;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_INTERFACE:
data[0] = 0;
ret = 1;
break;
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
ret = 0;
break;
case WACOM_SET_REPORT:
if (s->mouse_grabbed) {
qemu_remove_mouse_event_handler(s->eh_entry);
s->mouse_grabbed = 0;
}
s->mode = data[0];
ret = 0;
break;
case WACOM_GET_REPORT:
data[0] = 0;
data[1] = s->mode;
ret = 2;
break;
/* USB HID requests */
case HID_GET_REPORT:
if (s->mode == WACOM_MODE_HID)
ret = usb_mouse_poll(s, data, length);
else if (s->mode == WACOM_MODE_WACOM)
ret = usb_wacom_poll(s, data, length);
break;
case HID_GET_IDLE:
ret = 1;
data[0] = s->idle;
break;
case HID_SET_IDLE:
s->idle = (uint8_t) (value >> 8);
ret = 0;
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| 11,307 |
qemu | 7f6613cedc59fa849105668ae971dc31004bca1c | 0 | static void gen_store_fpr32h(TCGv_i32 t, int reg)
{
TCGv_i64 t64 = tcg_temp_new_i64();
tcg_gen_extu_i32_i64(t64, t);
tcg_gen_deposit_i64(fpu_f64[reg], fpu_f64[reg], t64, 32, 32);
tcg_temp_free_i64(t64);
}
| 11,308 |
FFmpeg | 6a63ff19b6a7fe3bc32c7fb4a62fca8f65786432 | 0 | static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
if((uint64_t)atom.size > (1<<30))
return -1;
// currently SVQ3 decoder expect full STSD header - so let's fake it
// this should be fixed and just SMI header should be passed
av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(atom.size + 0x5a + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = 0x5a + atom.size;
memcpy(st->codec->extradata, "SVQ3", 4); // fake
get_buffer(pb, st->codec->extradata + 0x5a, atom.size);
dprintf(c->fc, "Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a);
return 0;
}
| 11,310 |
qemu | aa7f9966dfdff500bbbf1956d9e115b1fa8987a6 | 0 | static inline void ne2000_mem_writel(NE2000State *s, uint32_t addr,
uint32_t val)
{
addr &= ~1; /* XXX: check exact behaviour if not even */
if (addr < 32 ||
(addr >= NE2000_PMEM_START && addr < NE2000_MEM_SIZE)) {
stl_le_p(s->mem + addr, val);
}
}
| 11,311 |
qemu | 12f86b5b3e1bdf75e0a467d771c16cc42f3a1f1a | 0 | static void nvdimm_build_fit_buffer(NvdimmFitBuffer *fit_buf)
{
qemu_mutex_lock(&fit_buf->lock);
g_array_free(fit_buf->fit, true);
fit_buf->fit = nvdimm_build_device_structure();
fit_buf->dirty = true;
qemu_mutex_unlock(&fit_buf->lock);
}
| 11,312 |
qemu | 5fb6c7a8b26eab1a22207d24b4784bd2b39ab54b | 0 | static void vnc_debug_gnutls_log(int level, const char* str) {
VNC_DEBUG("%d %s", level, str);
}
| 11,315 |
qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | 0 | static uint64_t subpage_read(void *opaque, target_phys_addr_t addr,
unsigned len)
{
subpage_t *mmio = opaque;
unsigned int idx = SUBPAGE_IDX(addr);
MemoryRegionSection *section;
#if defined(DEBUG_SUBPAGE)
printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d\n", __func__,
mmio, len, addr, idx);
#endif
section = &phys_sections[mmio->sub_section[idx]];
addr += mmio->base;
addr -= section->offset_within_address_space;
addr += section->offset_within_region;
return io_mem_read(section->mr, addr, len);
}
| 11,317 |
qemu | 59b060be184aff59cfa101c937c8139e66f452f2 | 0 | int qcrypto_pbkdf2(QCryptoHashAlgorithm hash,
const uint8_t *key, size_t nkey,
const uint8_t *salt, size_t nsalt,
unsigned int iterations,
uint8_t *out, size_t nout,
Error **errp)
{
static const int hash_map[QCRYPTO_HASH_ALG__MAX] = {
[QCRYPTO_HASH_ALG_MD5] = GCRY_MD_MD5,
[QCRYPTO_HASH_ALG_SHA1] = GCRY_MD_SHA1,
[QCRYPTO_HASH_ALG_SHA256] = GCRY_MD_SHA256,
};
int ret;
if (hash >= G_N_ELEMENTS(hash_map) ||
hash_map[hash] == GCRY_MD_NONE) {
error_setg(errp, "Unexpected hash algorithm %d", hash);
return -1;
}
ret = gcry_kdf_derive(key, nkey, GCRY_KDF_PBKDF2,
hash_map[hash],
salt, nsalt, iterations,
nout, out);
if (ret != 0) {
error_setg(errp, "Cannot derive password: %s",
gcry_strerror(ret));
return -1;
}
return 0;
}
| 11,318 |
qemu | 185698715dfb18c82ad2a5dbc169908602d43e81 | 0 | uint32_t helper_efdctui (uint64_t val)
{
CPU_DoubleU u;
u.ll = val;
/* NaN are not treated the same way IEEE 754 does */
if (unlikely(float64_is_nan(u.d)))
return 0;
return float64_to_uint32(u.d, &env->vec_status);
}
| 11,319 |
qemu | 9be385980d37e8f4fd33f605f5fb1c3d144170a8 | 0 | Aml *init_aml_allocator(void)
{
Aml *var;
assert(!alloc_list);
alloc_list = g_ptr_array_new();
var = aml_alloc();
return var;
}
| 11,320 |
FFmpeg | 220494ad0b2e9e980ef703b46b69308236f29be5 | 0 | static void dca_downmix(float **samples, int srcfmt, int lfe_present,
float coef[DCA_PRIM_CHANNELS_MAX + 1][2],
const int8_t *channel_mapping)
{
int c, l, r, sl, sr, s;
int i;
float t, u, v;
switch (srcfmt) {
case DCA_MONO:
case DCA_CHANNEL:
case DCA_STEREO_TOTAL:
case DCA_STEREO_SUMDIFF:
case DCA_4F2R:
av_log(NULL, 0, "Not implemented!\n");
break;
case DCA_STEREO:
break;
case DCA_3F:
c = channel_mapping[0];
l = channel_mapping[1];
r = channel_mapping[2];
DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), );
break;
case DCA_2F1R:
s = channel_mapping[2];
DOWNMIX_TO_STEREO(MIX_REAR1(samples, s, 2, coef), );
break;
case DCA_3F1R:
c = channel_mapping[0];
l = channel_mapping[1];
r = channel_mapping[2];
s = channel_mapping[3];
DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),
MIX_REAR1(samples, s, 3, coef));
break;
case DCA_2F2R:
sl = channel_mapping[2];
sr = channel_mapping[3];
DOWNMIX_TO_STEREO(MIX_REAR2(samples, sl, sr, 2, coef), );
break;
case DCA_3F2R:
c = channel_mapping[0];
l = channel_mapping[1];
r = channel_mapping[2];
sl = channel_mapping[3];
sr = channel_mapping[4];
DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),
MIX_REAR2(samples, sl, sr, 3, coef));
break;
}
if (lfe_present) {
int lf_buf = dca_lfe_index[srcfmt];
int lf_idx = dca_channels [srcfmt];
for (i = 0; i < 256; i++) {
samples[0][i] += samples[lf_buf][i] * coef[lf_idx][0];
samples[1][i] += samples[lf_buf][i] * coef[lf_idx][1];
}
}
}
| 11,321 |
qemu | a83000f5e3fac30a7f213af1ba6a8f827622854d | 0 | void spapr_tce_free(sPAPRTCETable *tcet)
{
QLIST_REMOVE(tcet, list);
if (!kvm_enabled() ||
(kvmppc_remove_spapr_tce(tcet->table, tcet->fd,
tcet->window_size) != 0)) {
g_free(tcet->table);
}
g_free(tcet);
}
| 11,322 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.