training_results.json•58.7 kB
{
"timestamp": "2025-10-18T23:09:57.442516",
"model_type": "kmeans",
"embedding_model": "all-MiniLM-L6-v2",
"n_clusters": 3,
"silhouette_score": 0.08176108449697495,
"davies_bouldin_score": 3.0450816280951525,
"clusters": [
{
"cluster_id": 0,
"size": 497,
"category_distribution": {
"limitations": 1.0
},
"domain_distribution": {
"coding": 497
},
"purity": 1.0,
"is_dangerous": true,
"examples": [
"int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,\n\n AVCodecContext *codec, int size, int big_endian)\n\n{\n\n int id;\n\n uint64_t bitrate;\n\n\n\n if (size < 14) {\n\n avpriv_request_sample(codec, \"wav header size < 14\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n codec->codec_type = AVMEDIA_TYPE_AUDIO;\n\n if (!big_endian) {\n\n id = avio_rl16(pb);\n\n if (id != 0x0165) {\n\n codec->channels = avio_rl16(pb);\n\n codec->sample_rate = avio_rl32(pb);\n\n bitrate = avio_rl32(pb) * 8LL;\n\n codec->block_align = avio_rl16(pb);\n\n }\n\n } else {\n\n id = avio_rb16(pb);\n\n codec->channels = avio_rb16(pb);\n\n codec->sample_rate = avio_rb32(pb);\n\n bitrate = avio_rb32(pb) * 8LL;\n\n codec->block_align = avio_rb16(pb);\n\n }\n\n if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */\n\n codec->bits_per_coded_sample = 8;\n\n } else {\n\n if (!big_endian) {\n\n codec->bits_per_coded_sample = avio_rl16(pb);\n\n } else {\n\n codec->bits_per_coded_sample = avio_rb16(pb);\n\n }\n\n }\n\n if (id == 0xFFFE) {\n\n codec->codec_tag = 0;\n\n } else {\n\n codec->codec_tag = id;\n\n codec->codec_id = ff_wav_codec_get_id(id,\n\n codec->bits_per_coded_sample);\n\n }\n\n if (size >= 18 && id != 0x0165) { /* We're obviously dealing with WAVEFORMATEX */\n\n int cbSize = avio_rl16(pb); /* cbSize */\n\n if (big_endian) {\n\n avpriv_report_missing_feature(codec, \"WAVEFORMATEX support for RIFX files\\n\");\n\n return AVERROR_PATCHWELCOME;\n\n }\n\n size -= 18;\n\n cbSize = FFMIN(size, cbSize);\n\n if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */\n\n parse_waveformatex(pb, codec);\n\n cbSize -= 22;\n\n size -= 22;\n\n }\n\n if (cbSize > 0) {\n\n av_freep(&codec->extradata);\n\n if (ff_get_extradata(codec, pb, cbSize) < 0)\n\n return AVERROR(ENOMEM);\n\n size -= cbSize;\n\n }\n\n\n\n /* It is possible for the chunk to contain garbage at the end */\n\n if (size > 0)\n\n avio_skip(pb, size);\n\n } else if (id == 0x0165 && size >= 32) {\n\n int nb_streams, i;\n\n\n\n size -= 4;\n\n av_freep(&codec->extradata);\n\n if (ff_get_extradata(codec, pb, size) < 0)\n\n return AVERROR(ENOMEM);\n\n nb_streams = AV_RL16(codec->extradata + 4);\n\n codec->sample_rate = AV_RL32(codec->extradata + 12);\n\n codec->channels = 0;\n\n bitrate = 0;\n\n if (size < 8 + nb_streams * 20)\n\n return AVERROR_INVALIDDATA;\n\n for (i = 0; i < nb_streams; i++)\n\n codec->channels += codec->extradata[8 + i * 20 + 17];\n\n }\n\n\n\n if (bitrate > INT_MAX) {\n\n if (s->error_recognition & AV_EF_EXPLODE) {\n\n av_log(s, AV_LOG_ERROR,\n\n \"The bitrate %\"PRIu64\" is too large.\\n\",\n\n bitrate);\n\n return AVERROR_INVALIDDATA;\n\n } else {\n\n av_log(s, AV_LOG_WARNING,\n\n \"The bitrate %\"PRIu64\" is too large, resetting to 0.\",\n\n bitrate);\n\n codec->bit_rate = 0;\n\n }\n\n } else {\n\n codec->bit_rate = bitrate;\n\n }\n\n\n\n if (codec->sample_rate <= 0) {\n\n av_log(s, AV_LOG_ERROR,\n\n \"Invalid sample rate: %d\\n\", codec->sample_rate);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n if (codec->codec_id == AV_CODEC_ID_AAC_LATM) {\n\n /* Channels and sample_rate values are those prior to applying SBR\n\n * and/or PS. */\n\n codec->channels = 0;\n\n codec->sample_rate = 0;\n\n }\n\n /* override bits_per_coded_sample for G.726 */\n\n if (codec->codec_id == AV_CODEC_ID_ADPCM_G726 && codec->sample_rate)\n\n codec->bits_per_coded_sample = codec->bit_rate / codec->sample_rate;\n\n\n\n return 0;\n\n}\n",
"static int xen_9pfs_connect(struct XenDevice *xendev)\n\n{\n\n int i;\n\n Xen9pfsDev *xen_9pdev = container_of(xendev, Xen9pfsDev, xendev);\n\n V9fsState *s = &xen_9pdev->state;\n\n QemuOpts *fsdev;\n\n\n\n if (xenstore_read_fe_int(&xen_9pdev->xendev, \"num-rings\",\n\n &xen_9pdev->num_rings) == -1 ||\n\n xen_9pdev->num_rings > MAX_RINGS || xen_9pdev->num_rings < 1) {\n\n return -1;\n\n }\n\n\n\n xen_9pdev->rings = g_malloc0(xen_9pdev->num_rings * sizeof(Xen9pfsRing));\n\n for (i = 0; i < xen_9pdev->num_rings; i++) {\n\n char *str;\n\n int ring_order;\n\n\n\n xen_9pdev->rings[i].priv = xen_9pdev;\n\n xen_9pdev->rings[i].evtchn = -1;\n\n xen_9pdev->rings[i].local_port = -1;\n\n\n\n str = g_strdup_printf(\"ring-ref%u\", i);\n\n if (xenstore_read_fe_int(&xen_9pdev->xendev, str,\n\n &xen_9pdev->rings[i].ref) == -1) {\n\n\n goto out;\n\n }\n\n\n str = g_strdup_printf(\"event-channel-%u\", i);\n\n if (xenstore_read_fe_int(&xen_9pdev->xendev, str,\n\n &xen_9pdev->rings[i].evtchn) == -1) {\n\n\n goto out;\n\n }\n\n\n\n\n xen_9pdev->rings[i].intf = xengnttab_map_grant_ref(\n\n xen_9pdev->xendev.gnttabdev,\n\n xen_9pdev->xendev.dom,\n\n xen_9pdev->rings[i].ref,\n\n PROT_READ | PROT_WRITE);\n\n if (!xen_9pdev->rings[i].intf) {\n\n goto out;\n\n }\n\n ring_order = xen_9pdev->rings[i].intf->ring_order;\n\n if (ring_order > MAX_RING_ORDER) {\n\n goto out;\n\n }\n\n xen_9pdev->rings[i].ring_order = ring_order;\n\n xen_9pdev->rings[i].data = xengnttab_map_domain_grant_refs(\n\n xen_9pdev->xendev.gnttabdev,\n\n (1 << ring_order),\n\n xen_9pdev->xendev.dom,\n\n xen_9pdev->rings[i].intf->ref,\n\n PROT_READ | PROT_WRITE);\n\n if (!xen_9pdev->rings[i].data) {\n\n goto out;\n\n }\n\n xen_9pdev->rings[i].ring.in = xen_9pdev->rings[i].data;\n\n xen_9pdev->rings[i].ring.out = xen_9pdev->rings[i].data +\n\n XEN_FLEX_RING_SIZE(ring_order);\n\n\n\n xen_9pdev->rings[i].bh = qemu_bh_new(xen_9pfs_bh, &xen_9pdev->rings[i]);\n\n xen_9pdev->rings[i].out_cons = 0;\n\n xen_9pdev->rings[i].out_size = 0;\n\n xen_9pdev->rings[i].inprogress = false;\n\n\n\n\n\n xen_9pdev->rings[i].evtchndev = xenevtchn_open(NULL, 0);\n\n if (xen_9pdev->rings[i].evtchndev == NULL) {\n\n goto out;\n\n }\n\n fcntl(xenevtchn_fd(xen_9pdev->rings[i].evtchndev), F_SETFD, FD_CLOEXEC);\n\n xen_9pdev->rings[i].local_port = xenevtchn_bind_interdomain\n\n (xen_9pdev->rings[i].evtchndev,\n\n xendev->dom,\n\n xen_9pdev->rings[i].evtchn);\n\n if (xen_9pdev->rings[i].local_port == -1) {\n\n xen_pv_printf(xendev, 0,\n\n \"xenevtchn_bind_interdomain failed port=%d\\n\",\n\n xen_9pdev->rings[i].evtchn);\n\n goto out;\n\n }\n\n xen_pv_printf(xendev, 2, \"bind evtchn port %d\\n\", xendev->local_port);\n\n qemu_set_fd_handler(xenevtchn_fd(xen_9pdev->rings[i].evtchndev),\n\n xen_9pfs_evtchn_event, NULL, &xen_9pdev->rings[i]);\n\n }\n\n\n\n xen_9pdev->security_model = xenstore_read_be_str(xendev, \"security_model\");\n\n xen_9pdev->path = xenstore_read_be_str(xendev, \"path\");\n\n xen_9pdev->id = s->fsconf.fsdev_id =\n\n g_strdup_printf(\"xen9p%d\", xendev->dev);\n\n xen_9pdev->tag = s->fsconf.tag = xenstore_read_fe_str(xendev, \"tag\");\n\n v9fs_register_transport(s, &xen_9p_transport);\n\n fsdev = qemu_opts_create(qemu_find_opts(\"fsdev\"),\n\n s->fsconf.tag,\n\n 1, NULL);\n\n qemu_opt_set(fsdev, \"fsdriver\", \"local\", NULL);\n\n qemu_opt_set(fsdev, \"path\", xen_9pdev->path, NULL);\n\n qemu_opt_set(fsdev, \"security_model\", xen_9pdev->security_model, NULL);\n\n qemu_opts_set_id(fsdev, s->fsconf.fsdev_id);\n\n qemu_fsdev_add(fsdev);\n\n v9fs_device_realize_common(s, NULL);\n\n\n\n return 0;\n\n\n\nout:\n\n xen_9pfs_free(xendev);\n\n return -1;\n\n}",
"static int subframe_count_exact(FlacEncodeContext *s, FlacSubframe *sub,\n\n int pred_order)\n\n{\n\n int p, porder, psize;\n\n int i, part_end;\n\n int count = 0;\n\n\n\n /* subframe header */\n\n count += 8;\n\n\n\n /* subframe */\n\n if (sub->type == FLAC_SUBFRAME_CONSTANT) {\n\n count += sub->obits;\n\n } else if (sub->type == FLAC_SUBFRAME_VERBATIM) {\n\n count += s->frame.blocksize * sub->obits;\n\n } else {\n\n /* warm-up samples */\n\n count += pred_order * sub->obits;\n\n\n\n /* LPC coefficients */\n\n if (sub->type == FLAC_SUBFRAME_LPC)\n\n count += 4 + 5 + pred_order * s->options.lpc_coeff_precision;\n\n\n\n /* rice-encoded block */\n\n count += 2;\n\n\n\n /* partition order */\n\n porder = sub->rc.porder;\n\n psize = s->frame.blocksize >> porder;\n\n count += 4;\n\n\n\n /* residual */\n\n i = pred_order;\n\n part_end = psize;\n\n for (p = 0; p < 1 << porder; p++) {\n\n int k = sub->rc.params[p];\n\n count += 4;\n\n count += rice_count_exact(&sub->residual[i], part_end - i, k);\n\n i = part_end;\n\n part_end = FFMIN(s->frame.blocksize, part_end + psize);\n\n }\n\n }\n\n\n\n return count;\n\n}\n",
"static void ppc_spapr_init(QEMUMachineInitArgs *args)\n\n{\n\n ram_addr_t ram_size = args->ram_size;\n\n const char *cpu_model = args->cpu_model;\n\n const char *kernel_filename = args->kernel_filename;\n\n const char *kernel_cmdline = args->kernel_cmdline;\n\n const char *initrd_filename = args->initrd_filename;\n\n const char *boot_device = args->boot_order;\n\n PowerPCCPU *cpu;\n\n CPUPPCState *env;\n\n PCIHostState *phb;\n\n int i;\n\n MemoryRegion *sysmem = get_system_memory();\n\n MemoryRegion *ram = g_new(MemoryRegion, 1);\n\n hwaddr rma_alloc_size;\n\n uint32_t initrd_base = 0;\n\n long kernel_size = 0, initrd_size = 0;\n\n long load_limit, rtas_limit, fw_size;\n\n bool kernel_le = false;\n\n char *filename;\n\n\n\n msi_supported = true;\n\n\n\n spapr = g_malloc0(sizeof(*spapr));\n\n QLIST_INIT(&spapr->phbs);\n\n\n\n cpu_ppc_hypercall = emulate_spapr_hypercall;\n\n\n\n /* Allocate RMA if necessary */\n\n rma_alloc_size = kvmppc_alloc_rma(\"ppc_spapr.rma\", sysmem);\n\n\n\n if (rma_alloc_size == -1) {\n\n hw_error(\"qemu: Unable to create RMA\\n\");\n\n exit(1);\n\n }\n\n\n\n if (rma_alloc_size && (rma_alloc_size < ram_size)) {\n\n spapr->rma_size = rma_alloc_size;\n\n } else {\n\n spapr->rma_size = ram_size;\n\n\n\n /* With KVM, we don't actually know whether KVM supports an\n\n * unbounded RMA (PR KVM) or is limited by the hash table size\n\n * (HV KVM using VRMA), so we always assume the latter\n\n *\n\n * In that case, we also limit the initial allocations for RTAS\n\n * etc... to 256M since we have no way to know what the VRMA size\n\n * is going to be as it depends on the size of the hash table\n\n * isn't determined yet.\n\n */\n\n if (kvm_enabled()) {\n\n spapr->vrma_adjust = 1;\n\n spapr->rma_size = MIN(spapr->rma_size, 0x10000000);\n\n }\n\n }\n\n\n\n /* We place the device tree and RTAS just below either the top of the RMA,\n\n * or just below 2GB, whichever is lowere, so that it can be\n\n * processed with 32-bit real mode code if necessary */\n\n rtas_limit = MIN(spapr->rma_size, 0x80000000);\n\n spapr->rtas_addr = rtas_limit - RTAS_MAX_SIZE;\n\n spapr->fdt_addr = spapr->rtas_addr - FDT_MAX_SIZE;\n\n load_limit = spapr->fdt_addr - FW_OVERHEAD;\n\n\n\n /* We aim for a hash table of size 1/128 the size of RAM. The\n\n * normal rule of thumb is 1/64 the size of RAM, but that's much\n\n * more than needed for the Linux guests we support. */\n\n spapr->htab_shift = 18; /* Minimum architected size */\n\n while (spapr->htab_shift <= 46) {\n\n if ((1ULL << (spapr->htab_shift + 7)) >= ram_size) {\n\n break;\n\n }\n\n spapr->htab_shift++;\n\n }\n\n\n\n /* Set up Interrupt Controller before we create the VCPUs */\n\n spapr->icp = xics_system_init(smp_cpus * kvmppc_smt_threads() / smp_threads,\n\n XICS_IRQS);\n\n spapr->next_irq = XICS_IRQ_BASE;\n\n\n\n /* init CPUs */\n\n if (cpu_model == NULL) {\n\n cpu_model = kvm_enabled() ? \"host\" : \"POWER7\";\n\n }\n\n for (i = 0; i < smp_cpus; i++) {\n\n cpu = cpu_ppc_init(cpu_model);\n\n if (cpu == NULL) {\n\n fprintf(stderr, \"Unable to find PowerPC CPU definition\\n\");\n\n exit(1);\n\n }\n\n env = &cpu->env;\n\n\n\n xics_cpu_setup(spapr->icp, cpu);\n\n\n\n /* Set time-base frequency to 512 MHz */\n\n cpu_ppc_tb_init(env, TIMEBASE_FREQ);\n\n\n\n /* PAPR always has exception vectors in RAM not ROM. To ensure this,\n\n * MSR[IP] should never be set.\n\n */\n\n env->msr_mask &= ~(1 << 6);\n\n\n\n /* Tell KVM that we're in PAPR mode */\n\n if (kvm_enabled()) {\n\n kvmppc_set_papr(cpu);\n\n }\n\n\n\n qemu_register_reset(spapr_cpu_reset, cpu);\n\n }\n\n\n\n /* allocate RAM */\n\n spapr->ram_limit = ram_size;\n\n if (spapr->ram_limit > rma_alloc_size) {\n\n ram_addr_t nonrma_base = rma_alloc_size;\n\n ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size;\n\n\n\n memory_region_init_ram(ram, NULL, \"ppc_spapr.ram\", nonrma_size);\n\n vmstate_register_ram_global(ram);\n\n memory_region_add_subregion(sysmem, nonrma_base, ram);\n\n }\n\n\n\n filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, \"spapr-rtas.bin\");\n\n spapr->rtas_size = load_image_targphys(filename, spapr->rtas_addr,\n\n rtas_limit - spapr->rtas_addr);\n\n if (spapr->rtas_size < 0) {\n\n hw_error(\"qemu: could not load LPAR rtas '%s'\\n\", filename);\n\n exit(1);\n\n }\n\n if (spapr->rtas_size > RTAS_MAX_SIZE) {\n\n hw_error(\"RTAS too big ! 0x%lx bytes (max is 0x%x)\\n\",\n\n spapr->rtas_size, RTAS_MAX_SIZE);\n\n exit(1);\n\n }\n\n g_free(filename);\n\n\n\n /* Set up EPOW events infrastructure */\n\n spapr_events_init(spapr);\n\n\n\n /* Set up VIO bus */\n\n spapr->vio_bus = spapr_vio_bus_init();\n\n\n\n for (i = 0; i < MAX_SERIAL_PORTS; i++) {\n\n if (serial_hds[i]) {\n\n spapr_vty_create(spapr->vio_bus, serial_hds[i]);\n\n }\n\n }\n\n\n\n /* We always have at least the nvram device on VIO */\n\n spapr_create_nvram(spapr);\n\n\n\n /* Set up PCI */\n\n spapr_pci_msi_init(spapr, SPAPR_PCI_MSI_WINDOW);\n\n spapr_pci_rtas_init();\n\n\n\n phb = spapr_create_phb(spapr, 0);\n\n\n\n for (i = 0; i < nb_nics; i++) {\n\n NICInfo *nd = &nd_table[i];\n\n\n\n if (!nd->model) {\n\n nd->model = g_strdup(\"ibmveth\");\n\n }\n\n\n\n if (strcmp(nd->model, \"ibmveth\") == 0) {\n\n spapr_vlan_create(spapr->vio_bus, nd);\n\n } else {\n\n pci_nic_init_nofail(&nd_table[i], phb->bus, nd->model, NULL);\n\n }\n\n }\n\n\n\n for (i = 0; i <= drive_get_max_bus(IF_SCSI); i++) {\n\n spapr_vscsi_create(spapr->vio_bus);\n\n }\n\n\n\n /* Graphics */\n\n if (spapr_vga_init(phb->bus)) {\n\n spapr->has_graphics = true;\n\n }\n\n\n\n if (usb_enabled(spapr->has_graphics)) {\n\n pci_create_simple(phb->bus, -1, \"pci-ohci\");\n\n if (spapr->has_graphics) {\n\n usbdevice_create(\"keyboard\");\n\n usbdevice_create(\"mouse\");\n\n }\n\n }\n\n\n\n if (spapr->rma_size < (MIN_RMA_SLOF << 20)) {\n\n fprintf(stderr, \"qemu: pSeries SLOF firmware requires >= \"\n\n \"%ldM guest RMA (Real Mode Area memory)\\n\", MIN_RMA_SLOF);\n\n exit(1);\n\n }\n\n\n\n if (kernel_filename) {\n\n uint64_t lowaddr = 0;\n\n\n\n kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,\n\n NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);\n\n if (kernel_size < 0) {\n\n kernel_size = load_elf(kernel_filename,\n\n translate_kernel_address, NULL,\n\n NULL, &lowaddr, NULL, 0, ELF_MACHINE, 0);\n\n kernel_le = kernel_size > 0;\n\n }\n\n if (kernel_size < 0) {\n\n kernel_size = load_image_targphys(kernel_filename,\n\n KERNEL_LOAD_ADDR,\n\n load_limit - KERNEL_LOAD_ADDR);\n\n }\n\n if (kernel_size < 0) {\n\n fprintf(stderr, \"qemu: could not load kernel '%s'\\n\",\n\n kernel_filename);\n\n exit(1);\n\n }\n\n\n\n /* load initrd */\n\n if (initrd_filename) {\n\n /* Try to locate the initrd in the gap between the kernel\n\n * and the firmware. Add a bit of space just in case\n\n */\n\n initrd_base = (KERNEL_LOAD_ADDR + kernel_size + 0x1ffff) & ~0xffff;\n\n initrd_size = load_image_targphys(initrd_filename, initrd_base,\n\n load_limit - initrd_base);\n\n if (initrd_size < 0) {\n\n fprintf(stderr, \"qemu: could not load initial ram disk '%s'\\n\",\n\n initrd_filename);\n\n exit(1);\n\n }\n\n } else {\n\n initrd_base = 0;\n\n initrd_size = 0;\n\n }\n\n }\n\n\n\n if (bios_name == NULL) {\n\n bios_name = FW_FILE_NAME;\n\n }\n\n filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);\n\n fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE);\n\n if (fw_size < 0) {\n\n hw_error(\"qemu: could not load LPAR rtas '%s'\\n\", filename);\n\n exit(1);\n\n }\n\n g_free(filename);\n\n\n\n spapr->entry_point = 0x100;\n\n\n\n vmstate_register(NULL, 0, &vmstate_spapr, spapr);\n\n register_savevm_live(NULL, \"spapr/htab\", -1, 1,\n\n &savevm_htab_handlers, spapr);\n\n\n\n /* Prepare the device tree */\n\n spapr->fdt_skel = spapr_create_fdt_skel(cpu_model,\n\n initrd_base, initrd_size,\n\n kernel_size, kernel_le,\n\n boot_device, kernel_cmdline,\n\n spapr->epow_irq);\n\n assert(spapr->fdt_skel != NULL);\n\n}\n",
"static int mpeg1_decode_sequence(AVCodecContext *avctx, \n\n UINT8 *buf, int buf_size)\n\n{\n\n Mpeg1Context *s1 = avctx->priv_data;\n\n MpegEncContext *s = &s1->mpeg_enc_ctx;\n\n int width, height, i, v, j;\n\n float aspect;\n\n\n\n init_get_bits(&s->gb, buf, buf_size);\n\n\n\n width = get_bits(&s->gb, 12);\n\n height = get_bits(&s->gb, 12);\n\n s->aspect_ratio_info= get_bits(&s->gb, 4);\n\n if(!s->mpeg2){\n\n aspect= mpeg1_aspect[s->aspect_ratio_info];\n\n if(aspect!=0.0) avctx->aspect_ratio= width/(aspect*height);\n\n }\n\n\n\n s->frame_rate_index = get_bits(&s->gb, 4);\n\n if (s->frame_rate_index == 0)\n\n return -1;\n\n s->bit_rate = get_bits(&s->gb, 18) * 400;\n\n if (get_bits1(&s->gb) == 0) /* marker */\n\n return -1;\n\n if (width <= 0 || height <= 0 ||\n\n (width % 2) != 0 || (height % 2) != 0)\n\n return -1;\n\n if (width != s->width ||\n\n height != s->height) {\n\n /* start new mpeg1 context decoding */\n\n s->out_format = FMT_MPEG1;\n\n if (s1->mpeg_enc_ctx_allocated) {\n\n MPV_common_end(s);\n\n }\n\n s->width = width;\n\n s->height = height;\n\n avctx->has_b_frames= 1;\n\n s->avctx = avctx;\n\n avctx->width = width;\n\n avctx->height = height;\n\n if (s->frame_rate_index >= 9) {\n\n /* at least give a valid frame rate (some old mpeg1 have this) */\n\n avctx->frame_rate = 25 * FRAME_RATE_BASE;\n\n } else {\n\n avctx->frame_rate = frame_rate_tab[s->frame_rate_index];\n\n }\n\n s->frame_rate = avctx->frame_rate;\n\n avctx->bit_rate = s->bit_rate;\n\n \n\n if (MPV_common_init(s) < 0)\n\n return -1;\n\n s1->mpeg_enc_ctx_allocated = 1;\n\n }\n\n\n\n skip_bits(&s->gb, 10); /* vbv_buffer_size */\n\n skip_bits(&s->gb, 1);\n\n\n\n /* get matrix */\n\n if (get_bits1(&s->gb)) {\n\n for(i=0;i<64;i++) {\n\n v = get_bits(&s->gb, 8);\n\n j = s->intra_scantable.permutated[i];\n\n s->intra_matrix[j] = v;\n\n s->chroma_intra_matrix[j] = v;\n\n }\n\n#ifdef DEBUG\n\n dprintf(\"intra matrix present\\n\");\n\n for(i=0;i<64;i++)\n\n dprintf(\" %d\", s->intra_matrix[s->intra_scantable.permutated[i]]);\n\n printf(\"\\n\");\n\n#endif\n\n } else {\n\n for(i=0;i<64;i++) {\n\n int j= s->idct_permutation[i];\n\n v = ff_mpeg1_default_intra_matrix[i];\n\n s->intra_matrix[j] = v;\n\n s->chroma_intra_matrix[j] = v;\n\n }\n\n }\n\n if (get_bits1(&s->gb)) {\n\n for(i=0;i<64;i++) {\n\n v = get_bits(&s->gb, 8);\n\n j = s->intra_scantable.permutated[i];\n\n s->inter_matrix[j] = v;\n\n s->chroma_inter_matrix[j] = v;\n\n }\n\n#ifdef DEBUG\n\n dprintf(\"non intra matrix present\\n\");\n\n for(i=0;i<64;i++)\n\n dprintf(\" %d\", s->inter_matrix[s->intra_scantable.permutated[i]]);\n\n printf(\"\\n\");\n\n#endif\n\n } else {\n\n for(i=0;i<64;i++) {\n\n int j= s->idct_permutation[i];\n\n v = ff_mpeg1_default_non_intra_matrix[i];\n\n s->inter_matrix[j] = v;\n\n s->chroma_inter_matrix[j] = v;\n\n }\n\n }\n\n\n\n /* we set mpeg2 parameters so that it emulates mpeg1 */\n\n s->progressive_sequence = 1;\n\n s->progressive_frame = 1;\n\n s->picture_structure = PICT_FRAME;\n\n s->frame_pred_frame_dct = 1;\n\n s->mpeg2 = 0;\n\n avctx->sub_id = 1; /* indicates mpeg1 */\n\n return 0;\n\n}\n"
],
"pattern_description": "LIMITATIONS cluster: coding (DANGEROUS: 100.0% limitations/harmful)",
"detection_heuristic": "contains_code AND (has_vulnerability OR cyclomatic_complexity > 10)",
"keywords": [
"case",
"return",
"break",
"else",
"null",
"avctx",
"static",
"data",
"goto",
"void"
]
},
{
"cluster_id": 1,
"size": 491,
"category_distribution": {
"limitations": 1.0
},
"domain_distribution": {
"medicine": 491
},
"purity": 1.0,
"is_dangerous": true,
"examples": [
"A junior orthopaedic surgery resident is completing a carpal tunnel repair with the department chairman as the attending physician. During the case, the resident inadvertently cuts a flexor tendon. The tendon is repaired without complication. The attending tells the resident that the patient will do fine, and there is no need to report this minor complication that will not harm the patient, as he does not want to make the patient worry unnecessarily. He tells the resident to leave this complication out of the operative report. Which of the following is the correct next action for the resident to take?",
"A 67-year-old man with transitional cell carcinoma of the bladder comes to the physician because of a 2-day history of ringing sensation in his ear. He received this first course of neoadjuvant chemotherapy 1 week ago. Pure tone audiometry shows a sensorineural hearing loss of 45 dB. The expected beneficial effect of the drug that caused this patient's symptoms is most likely due to which of the following actions?",
"Two weeks after undergoing an emergency cardiac catherization with stenting for unstable angina pectoris, a 61-year-old man has decreased urinary output and malaise. He has type 2 diabetes mellitus and osteoarthritis of the hips. Prior to admission, his medications were insulin and naproxen. He was also started on aspirin, clopidogrel, and metoprolol after the coronary intervention. His temperature is 38\u00b0C (100.4\u00b0F), pulse is 93/min, and blood pressure is 125/85 mm Hg. Examination shows mottled, reticulated purplish discoloration of the feet. Laboratory studies show:\nHemoglobin count 14 g/dL\nLeukocyte count 16,400/mm3\nSegmented neutrophils 56%\nEosinophils 11%\nLymphocytes 31%\nMonocytes 2%\nPlatelet count 260,000/mm3\nErythrocyte sedimentation rate 68 mm/h\nSerum\nUrea nitrogen 25 mg/dL\nCreatinine 4.2 mg/dL\nRenal biopsy shows intravascular spindle-shaped vacuoles. Which of the following is the most likely cause of this patient's symptoms?\"",
"A 39-year-old woman is brought to the emergency department because of fevers, chills, and left lower quadrant pain. Her temperature is 39.1\u00b0C (102.3\u00b0F), pulse is 126/min, respirations are 28/min, and blood pressure is 80/50 mm Hg. There is blood oozing around the site of a peripheral intravenous line. Pelvic examination shows mucopurulent discharge from the cervical os and left adnexal tenderness. Laboratory studies show:\nPlatelet count 14,200/mm3\nFibrinogen 83 mg/mL (N = 200\u2013430 mg/dL)\nD-dimer 965 ng/mL (N < 500 ng/mL)\nWhen phenol is applied to a sample of the patient's blood at 90\u00b0C, a phosphorylated N-acetylglucosamine dimer with 6 fatty acids attached to a polysaccharide side chain is identified. A blood culture is most likely to show which of the following?\"",
"A 35-year-old man comes to the physician because of itchy, watery eyes for the past week. He has also been sneezing multiple times a day during this period. He had a similar episode 1 year ago around springtime. He has iron deficiency anemia and ankylosing spondylitis. Current medications include ferrous sulfate, artificial tear drops, and indomethacin. He works as an elementary school teacher. His vital signs are within normal limits. Visual acuity is 20/20 without correction. Physical examination shows bilateral conjunctival injection with watery discharge. The pupils are 3 mm, equal, and reactive to light. Examination of the anterior chamber of the eye is unremarkable. Which of the following is the most appropriate treatment?"
],
"pattern_description": "LIMITATIONS cluster: medicine (DANGEROUS: 100.0% limitations/harmful)",
"detection_heuristic": "keyword_match: ['patient', 'year', 'following', 'most', 'examination'] AND domain=medicine",
"keywords": [
"patient",
"year",
"following",
"most",
"examination",
"blood",
"shows",
"history",
"likely",
"past"
]
},
{
"cluster_id": 2,
"size": 1012,
"category_distribution": {
"good": 0.9881422924901185,
"limitations": 0.011857707509881422
},
"domain_distribution": {
"general_qa": 500,
"commonsense": 500,
"medicine": 9,
"coding": 3
},
"purity": 0.9881422924901185,
"is_dangerous": false,
"examples": [
"In what country is Normandy located?",
"When were the Normans in Normandy?",
"From which countries did the Norse originate?",
"Who was the Norse leader?",
"What century did the Normans first gain their separate identity?"
],
"pattern_description": "GOOD cluster: general_qa",
"detection_heuristic": "domain=general_qa AND low_complexity",
"keywords": [
"people",
"woman",
"then",
"camera",
"complexity",
"problem",
"they",
"while",
"time",
"seen"
]
}
],
"dangerous_clusters": [
{
"cluster_id": 0,
"size": 497,
"category_distribution": {
"limitations": 1.0
},
"domain_distribution": {
"coding": 497
},
"purity": 1.0,
"is_dangerous": true,
"examples": [
"int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,\n\n AVCodecContext *codec, int size, int big_endian)\n\n{\n\n int id;\n\n uint64_t bitrate;\n\n\n\n if (size < 14) {\n\n avpriv_request_sample(codec, \"wav header size < 14\");\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n codec->codec_type = AVMEDIA_TYPE_AUDIO;\n\n if (!big_endian) {\n\n id = avio_rl16(pb);\n\n if (id != 0x0165) {\n\n codec->channels = avio_rl16(pb);\n\n codec->sample_rate = avio_rl32(pb);\n\n bitrate = avio_rl32(pb) * 8LL;\n\n codec->block_align = avio_rl16(pb);\n\n }\n\n } else {\n\n id = avio_rb16(pb);\n\n codec->channels = avio_rb16(pb);\n\n codec->sample_rate = avio_rb32(pb);\n\n bitrate = avio_rb32(pb) * 8LL;\n\n codec->block_align = avio_rb16(pb);\n\n }\n\n if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */\n\n codec->bits_per_coded_sample = 8;\n\n } else {\n\n if (!big_endian) {\n\n codec->bits_per_coded_sample = avio_rl16(pb);\n\n } else {\n\n codec->bits_per_coded_sample = avio_rb16(pb);\n\n }\n\n }\n\n if (id == 0xFFFE) {\n\n codec->codec_tag = 0;\n\n } else {\n\n codec->codec_tag = id;\n\n codec->codec_id = ff_wav_codec_get_id(id,\n\n codec->bits_per_coded_sample);\n\n }\n\n if (size >= 18 && id != 0x0165) { /* We're obviously dealing with WAVEFORMATEX */\n\n int cbSize = avio_rl16(pb); /* cbSize */\n\n if (big_endian) {\n\n avpriv_report_missing_feature(codec, \"WAVEFORMATEX support for RIFX files\\n\");\n\n return AVERROR_PATCHWELCOME;\n\n }\n\n size -= 18;\n\n cbSize = FFMIN(size, cbSize);\n\n if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */\n\n parse_waveformatex(pb, codec);\n\n cbSize -= 22;\n\n size -= 22;\n\n }\n\n if (cbSize > 0) {\n\n av_freep(&codec->extradata);\n\n if (ff_get_extradata(codec, pb, cbSize) < 0)\n\n return AVERROR(ENOMEM);\n\n size -= cbSize;\n\n }\n\n\n\n /* It is possible for the chunk to contain garbage at the end */\n\n if (size > 0)\n\n avio_skip(pb, size);\n\n } else if (id == 0x0165 && size >= 32) {\n\n int nb_streams, i;\n\n\n\n size -= 4;\n\n av_freep(&codec->extradata);\n\n if (ff_get_extradata(codec, pb, size) < 0)\n\n return AVERROR(ENOMEM);\n\n nb_streams = AV_RL16(codec->extradata + 4);\n\n codec->sample_rate = AV_RL32(codec->extradata + 12);\n\n codec->channels = 0;\n\n bitrate = 0;\n\n if (size < 8 + nb_streams * 20)\n\n return AVERROR_INVALIDDATA;\n\n for (i = 0; i < nb_streams; i++)\n\n codec->channels += codec->extradata[8 + i * 20 + 17];\n\n }\n\n\n\n if (bitrate > INT_MAX) {\n\n if (s->error_recognition & AV_EF_EXPLODE) {\n\n av_log(s, AV_LOG_ERROR,\n\n \"The bitrate %\"PRIu64\" is too large.\\n\",\n\n bitrate);\n\n return AVERROR_INVALIDDATA;\n\n } else {\n\n av_log(s, AV_LOG_WARNING,\n\n \"The bitrate %\"PRIu64\" is too large, resetting to 0.\",\n\n bitrate);\n\n codec->bit_rate = 0;\n\n }\n\n } else {\n\n codec->bit_rate = bitrate;\n\n }\n\n\n\n if (codec->sample_rate <= 0) {\n\n av_log(s, AV_LOG_ERROR,\n\n \"Invalid sample rate: %d\\n\", codec->sample_rate);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n if (codec->codec_id == AV_CODEC_ID_AAC_LATM) {\n\n /* Channels and sample_rate values are those prior to applying SBR\n\n * and/or PS. */\n\n codec->channels = 0;\n\n codec->sample_rate = 0;\n\n }\n\n /* override bits_per_coded_sample for G.726 */\n\n if (codec->codec_id == AV_CODEC_ID_ADPCM_G726 && codec->sample_rate)\n\n codec->bits_per_coded_sample = codec->bit_rate / codec->sample_rate;\n\n\n\n return 0;\n\n}\n",
"static int xen_9pfs_connect(struct XenDevice *xendev)\n\n{\n\n int i;\n\n Xen9pfsDev *xen_9pdev = container_of(xendev, Xen9pfsDev, xendev);\n\n V9fsState *s = &xen_9pdev->state;\n\n QemuOpts *fsdev;\n\n\n\n if (xenstore_read_fe_int(&xen_9pdev->xendev, \"num-rings\",\n\n &xen_9pdev->num_rings) == -1 ||\n\n xen_9pdev->num_rings > MAX_RINGS || xen_9pdev->num_rings < 1) {\n\n return -1;\n\n }\n\n\n\n xen_9pdev->rings = g_malloc0(xen_9pdev->num_rings * sizeof(Xen9pfsRing));\n\n for (i = 0; i < xen_9pdev->num_rings; i++) {\n\n char *str;\n\n int ring_order;\n\n\n\n xen_9pdev->rings[i].priv = xen_9pdev;\n\n xen_9pdev->rings[i].evtchn = -1;\n\n xen_9pdev->rings[i].local_port = -1;\n\n\n\n str = g_strdup_printf(\"ring-ref%u\", i);\n\n if (xenstore_read_fe_int(&xen_9pdev->xendev, str,\n\n &xen_9pdev->rings[i].ref) == -1) {\n\n\n goto out;\n\n }\n\n\n str = g_strdup_printf(\"event-channel-%u\", i);\n\n if (xenstore_read_fe_int(&xen_9pdev->xendev, str,\n\n &xen_9pdev->rings[i].evtchn) == -1) {\n\n\n goto out;\n\n }\n\n\n\n\n xen_9pdev->rings[i].intf = xengnttab_map_grant_ref(\n\n xen_9pdev->xendev.gnttabdev,\n\n xen_9pdev->xendev.dom,\n\n xen_9pdev->rings[i].ref,\n\n PROT_READ | PROT_WRITE);\n\n if (!xen_9pdev->rings[i].intf) {\n\n goto out;\n\n }\n\n ring_order = xen_9pdev->rings[i].intf->ring_order;\n\n if (ring_order > MAX_RING_ORDER) {\n\n goto out;\n\n }\n\n xen_9pdev->rings[i].ring_order = ring_order;\n\n xen_9pdev->rings[i].data = xengnttab_map_domain_grant_refs(\n\n xen_9pdev->xendev.gnttabdev,\n\n (1 << ring_order),\n\n xen_9pdev->xendev.dom,\n\n xen_9pdev->rings[i].intf->ref,\n\n PROT_READ | PROT_WRITE);\n\n if (!xen_9pdev->rings[i].data) {\n\n goto out;\n\n }\n\n xen_9pdev->rings[i].ring.in = xen_9pdev->rings[i].data;\n\n xen_9pdev->rings[i].ring.out = xen_9pdev->rings[i].data +\n\n XEN_FLEX_RING_SIZE(ring_order);\n\n\n\n xen_9pdev->rings[i].bh = qemu_bh_new(xen_9pfs_bh, &xen_9pdev->rings[i]);\n\n xen_9pdev->rings[i].out_cons = 0;\n\n xen_9pdev->rings[i].out_size = 0;\n\n xen_9pdev->rings[i].inprogress = false;\n\n\n\n\n\n xen_9pdev->rings[i].evtchndev = xenevtchn_open(NULL, 0);\n\n if (xen_9pdev->rings[i].evtchndev == NULL) {\n\n goto out;\n\n }\n\n fcntl(xenevtchn_fd(xen_9pdev->rings[i].evtchndev), F_SETFD, FD_CLOEXEC);\n\n xen_9pdev->rings[i].local_port = xenevtchn_bind_interdomain\n\n (xen_9pdev->rings[i].evtchndev,\n\n xendev->dom,\n\n xen_9pdev->rings[i].evtchn);\n\n if (xen_9pdev->rings[i].local_port == -1) {\n\n xen_pv_printf(xendev, 0,\n\n \"xenevtchn_bind_interdomain failed port=%d\\n\",\n\n xen_9pdev->rings[i].evtchn);\n\n goto out;\n\n }\n\n xen_pv_printf(xendev, 2, \"bind evtchn port %d\\n\", xendev->local_port);\n\n qemu_set_fd_handler(xenevtchn_fd(xen_9pdev->rings[i].evtchndev),\n\n xen_9pfs_evtchn_event, NULL, &xen_9pdev->rings[i]);\n\n }\n\n\n\n xen_9pdev->security_model = xenstore_read_be_str(xendev, \"security_model\");\n\n xen_9pdev->path = xenstore_read_be_str(xendev, \"path\");\n\n xen_9pdev->id = s->fsconf.fsdev_id =\n\n g_strdup_printf(\"xen9p%d\", xendev->dev);\n\n xen_9pdev->tag = s->fsconf.tag = xenstore_read_fe_str(xendev, \"tag\");\n\n v9fs_register_transport(s, &xen_9p_transport);\n\n fsdev = qemu_opts_create(qemu_find_opts(\"fsdev\"),\n\n s->fsconf.tag,\n\n 1, NULL);\n\n qemu_opt_set(fsdev, \"fsdriver\", \"local\", NULL);\n\n qemu_opt_set(fsdev, \"path\", xen_9pdev->path, NULL);\n\n qemu_opt_set(fsdev, \"security_model\", xen_9pdev->security_model, NULL);\n\n qemu_opts_set_id(fsdev, s->fsconf.fsdev_id);\n\n qemu_fsdev_add(fsdev);\n\n v9fs_device_realize_common(s, NULL);\n\n\n\n return 0;\n\n\n\nout:\n\n xen_9pfs_free(xendev);\n\n return -1;\n\n}",
"static int subframe_count_exact(FlacEncodeContext *s, FlacSubframe *sub,\n\n int pred_order)\n\n{\n\n int p, porder, psize;\n\n int i, part_end;\n\n int count = 0;\n\n\n\n /* subframe header */\n\n count += 8;\n\n\n\n /* subframe */\n\n if (sub->type == FLAC_SUBFRAME_CONSTANT) {\n\n count += sub->obits;\n\n } else if (sub->type == FLAC_SUBFRAME_VERBATIM) {\n\n count += s->frame.blocksize * sub->obits;\n\n } else {\n\n /* warm-up samples */\n\n count += pred_order * sub->obits;\n\n\n\n /* LPC coefficients */\n\n if (sub->type == FLAC_SUBFRAME_LPC)\n\n count += 4 + 5 + pred_order * s->options.lpc_coeff_precision;\n\n\n\n /* rice-encoded block */\n\n count += 2;\n\n\n\n /* partition order */\n\n porder = sub->rc.porder;\n\n psize = s->frame.blocksize >> porder;\n\n count += 4;\n\n\n\n /* residual */\n\n i = pred_order;\n\n part_end = psize;\n\n for (p = 0; p < 1 << porder; p++) {\n\n int k = sub->rc.params[p];\n\n count += 4;\n\n count += rice_count_exact(&sub->residual[i], part_end - i, k);\n\n i = part_end;\n\n part_end = FFMIN(s->frame.blocksize, part_end + psize);\n\n }\n\n }\n\n\n\n return count;\n\n}\n",
"static void ppc_spapr_init(QEMUMachineInitArgs *args)\n\n{\n\n ram_addr_t ram_size = args->ram_size;\n\n const char *cpu_model = args->cpu_model;\n\n const char *kernel_filename = args->kernel_filename;\n\n const char *kernel_cmdline = args->kernel_cmdline;\n\n const char *initrd_filename = args->initrd_filename;\n\n const char *boot_device = args->boot_order;\n\n PowerPCCPU *cpu;\n\n CPUPPCState *env;\n\n PCIHostState *phb;\n\n int i;\n\n MemoryRegion *sysmem = get_system_memory();\n\n MemoryRegion *ram = g_new(MemoryRegion, 1);\n\n hwaddr rma_alloc_size;\n\n uint32_t initrd_base = 0;\n\n long kernel_size = 0, initrd_size = 0;\n\n long load_limit, rtas_limit, fw_size;\n\n bool kernel_le = false;\n\n char *filename;\n\n\n\n msi_supported = true;\n\n\n\n spapr = g_malloc0(sizeof(*spapr));\n\n QLIST_INIT(&spapr->phbs);\n\n\n\n cpu_ppc_hypercall = emulate_spapr_hypercall;\n\n\n\n /* Allocate RMA if necessary */\n\n rma_alloc_size = kvmppc_alloc_rma(\"ppc_spapr.rma\", sysmem);\n\n\n\n if (rma_alloc_size == -1) {\n\n hw_error(\"qemu: Unable to create RMA\\n\");\n\n exit(1);\n\n }\n\n\n\n if (rma_alloc_size && (rma_alloc_size < ram_size)) {\n\n spapr->rma_size = rma_alloc_size;\n\n } else {\n\n spapr->rma_size = ram_size;\n\n\n\n /* With KVM, we don't actually know whether KVM supports an\n\n * unbounded RMA (PR KVM) or is limited by the hash table size\n\n * (HV KVM using VRMA), so we always assume the latter\n\n *\n\n * In that case, we also limit the initial allocations for RTAS\n\n * etc... to 256M since we have no way to know what the VRMA size\n\n * is going to be as it depends on the size of the hash table\n\n * isn't determined yet.\n\n */\n\n if (kvm_enabled()) {\n\n spapr->vrma_adjust = 1;\n\n spapr->rma_size = MIN(spapr->rma_size, 0x10000000);\n\n }\n\n }\n\n\n\n /* We place the device tree and RTAS just below either the top of the RMA,\n\n * or just below 2GB, whichever is lowere, so that it can be\n\n * processed with 32-bit real mode code if necessary */\n\n rtas_limit = MIN(spapr->rma_size, 0x80000000);\n\n spapr->rtas_addr = rtas_limit - RTAS_MAX_SIZE;\n\n spapr->fdt_addr = spapr->rtas_addr - FDT_MAX_SIZE;\n\n load_limit = spapr->fdt_addr - FW_OVERHEAD;\n\n\n\n /* We aim for a hash table of size 1/128 the size of RAM. The\n\n * normal rule of thumb is 1/64 the size of RAM, but that's much\n\n * more than needed for the Linux guests we support. */\n\n spapr->htab_shift = 18; /* Minimum architected size */\n\n while (spapr->htab_shift <= 46) {\n\n if ((1ULL << (spapr->htab_shift + 7)) >= ram_size) {\n\n break;\n\n }\n\n spapr->htab_shift++;\n\n }\n\n\n\n /* Set up Interrupt Controller before we create the VCPUs */\n\n spapr->icp = xics_system_init(smp_cpus * kvmppc_smt_threads() / smp_threads,\n\n XICS_IRQS);\n\n spapr->next_irq = XICS_IRQ_BASE;\n\n\n\n /* init CPUs */\n\n if (cpu_model == NULL) {\n\n cpu_model = kvm_enabled() ? \"host\" : \"POWER7\";\n\n }\n\n for (i = 0; i < smp_cpus; i++) {\n\n cpu = cpu_ppc_init(cpu_model);\n\n if (cpu == NULL) {\n\n fprintf(stderr, \"Unable to find PowerPC CPU definition\\n\");\n\n exit(1);\n\n }\n\n env = &cpu->env;\n\n\n\n xics_cpu_setup(spapr->icp, cpu);\n\n\n\n /* Set time-base frequency to 512 MHz */\n\n cpu_ppc_tb_init(env, TIMEBASE_FREQ);\n\n\n\n /* PAPR always has exception vectors in RAM not ROM. To ensure this,\n\n * MSR[IP] should never be set.\n\n */\n\n env->msr_mask &= ~(1 << 6);\n\n\n\n /* Tell KVM that we're in PAPR mode */\n\n if (kvm_enabled()) {\n\n kvmppc_set_papr(cpu);\n\n }\n\n\n\n qemu_register_reset(spapr_cpu_reset, cpu);\n\n }\n\n\n\n /* allocate RAM */\n\n spapr->ram_limit = ram_size;\n\n if (spapr->ram_limit > rma_alloc_size) {\n\n ram_addr_t nonrma_base = rma_alloc_size;\n\n ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size;\n\n\n\n memory_region_init_ram(ram, NULL, \"ppc_spapr.ram\", nonrma_size);\n\n vmstate_register_ram_global(ram);\n\n memory_region_add_subregion(sysmem, nonrma_base, ram);\n\n }\n\n\n\n filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, \"spapr-rtas.bin\");\n\n spapr->rtas_size = load_image_targphys(filename, spapr->rtas_addr,\n\n rtas_limit - spapr->rtas_addr);\n\n if (spapr->rtas_size < 0) {\n\n hw_error(\"qemu: could not load LPAR rtas '%s'\\n\", filename);\n\n exit(1);\n\n }\n\n if (spapr->rtas_size > RTAS_MAX_SIZE) {\n\n hw_error(\"RTAS too big ! 0x%lx bytes (max is 0x%x)\\n\",\n\n spapr->rtas_size, RTAS_MAX_SIZE);\n\n exit(1);\n\n }\n\n g_free(filename);\n\n\n\n /* Set up EPOW events infrastructure */\n\n spapr_events_init(spapr);\n\n\n\n /* Set up VIO bus */\n\n spapr->vio_bus = spapr_vio_bus_init();\n\n\n\n for (i = 0; i < MAX_SERIAL_PORTS; i++) {\n\n if (serial_hds[i]) {\n\n spapr_vty_create(spapr->vio_bus, serial_hds[i]);\n\n }\n\n }\n\n\n\n /* We always have at least the nvram device on VIO */\n\n spapr_create_nvram(spapr);\n\n\n\n /* Set up PCI */\n\n spapr_pci_msi_init(spapr, SPAPR_PCI_MSI_WINDOW);\n\n spapr_pci_rtas_init();\n\n\n\n phb = spapr_create_phb(spapr, 0);\n\n\n\n for (i = 0; i < nb_nics; i++) {\n\n NICInfo *nd = &nd_table[i];\n\n\n\n if (!nd->model) {\n\n nd->model = g_strdup(\"ibmveth\");\n\n }\n\n\n\n if (strcmp(nd->model, \"ibmveth\") == 0) {\n\n spapr_vlan_create(spapr->vio_bus, nd);\n\n } else {\n\n pci_nic_init_nofail(&nd_table[i], phb->bus, nd->model, NULL);\n\n }\n\n }\n\n\n\n for (i = 0; i <= drive_get_max_bus(IF_SCSI); i++) {\n\n spapr_vscsi_create(spapr->vio_bus);\n\n }\n\n\n\n /* Graphics */\n\n if (spapr_vga_init(phb->bus)) {\n\n spapr->has_graphics = true;\n\n }\n\n\n\n if (usb_enabled(spapr->has_graphics)) {\n\n pci_create_simple(phb->bus, -1, \"pci-ohci\");\n\n if (spapr->has_graphics) {\n\n usbdevice_create(\"keyboard\");\n\n usbdevice_create(\"mouse\");\n\n }\n\n }\n\n\n\n if (spapr->rma_size < (MIN_RMA_SLOF << 20)) {\n\n fprintf(stderr, \"qemu: pSeries SLOF firmware requires >= \"\n\n \"%ldM guest RMA (Real Mode Area memory)\\n\", MIN_RMA_SLOF);\n\n exit(1);\n\n }\n\n\n\n if (kernel_filename) {\n\n uint64_t lowaddr = 0;\n\n\n\n kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,\n\n NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);\n\n if (kernel_size < 0) {\n\n kernel_size = load_elf(kernel_filename,\n\n translate_kernel_address, NULL,\n\n NULL, &lowaddr, NULL, 0, ELF_MACHINE, 0);\n\n kernel_le = kernel_size > 0;\n\n }\n\n if (kernel_size < 0) {\n\n kernel_size = load_image_targphys(kernel_filename,\n\n KERNEL_LOAD_ADDR,\n\n load_limit - KERNEL_LOAD_ADDR);\n\n }\n\n if (kernel_size < 0) {\n\n fprintf(stderr, \"qemu: could not load kernel '%s'\\n\",\n\n kernel_filename);\n\n exit(1);\n\n }\n\n\n\n /* load initrd */\n\n if (initrd_filename) {\n\n /* Try to locate the initrd in the gap between the kernel\n\n * and the firmware. Add a bit of space just in case\n\n */\n\n initrd_base = (KERNEL_LOAD_ADDR + kernel_size + 0x1ffff) & ~0xffff;\n\n initrd_size = load_image_targphys(initrd_filename, initrd_base,\n\n load_limit - initrd_base);\n\n if (initrd_size < 0) {\n\n fprintf(stderr, \"qemu: could not load initial ram disk '%s'\\n\",\n\n initrd_filename);\n\n exit(1);\n\n }\n\n } else {\n\n initrd_base = 0;\n\n initrd_size = 0;\n\n }\n\n }\n\n\n\n if (bios_name == NULL) {\n\n bios_name = FW_FILE_NAME;\n\n }\n\n filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);\n\n fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE);\n\n if (fw_size < 0) {\n\n hw_error(\"qemu: could not load LPAR rtas '%s'\\n\", filename);\n\n exit(1);\n\n }\n\n g_free(filename);\n\n\n\n spapr->entry_point = 0x100;\n\n\n\n vmstate_register(NULL, 0, &vmstate_spapr, spapr);\n\n register_savevm_live(NULL, \"spapr/htab\", -1, 1,\n\n &savevm_htab_handlers, spapr);\n\n\n\n /* Prepare the device tree */\n\n spapr->fdt_skel = spapr_create_fdt_skel(cpu_model,\n\n initrd_base, initrd_size,\n\n kernel_size, kernel_le,\n\n boot_device, kernel_cmdline,\n\n spapr->epow_irq);\n\n assert(spapr->fdt_skel != NULL);\n\n}\n",
"static int mpeg1_decode_sequence(AVCodecContext *avctx, \n\n UINT8 *buf, int buf_size)\n\n{\n\n Mpeg1Context *s1 = avctx->priv_data;\n\n MpegEncContext *s = &s1->mpeg_enc_ctx;\n\n int width, height, i, v, j;\n\n float aspect;\n\n\n\n init_get_bits(&s->gb, buf, buf_size);\n\n\n\n width = get_bits(&s->gb, 12);\n\n height = get_bits(&s->gb, 12);\n\n s->aspect_ratio_info= get_bits(&s->gb, 4);\n\n if(!s->mpeg2){\n\n aspect= mpeg1_aspect[s->aspect_ratio_info];\n\n if(aspect!=0.0) avctx->aspect_ratio= width/(aspect*height);\n\n }\n\n\n\n s->frame_rate_index = get_bits(&s->gb, 4);\n\n if (s->frame_rate_index == 0)\n\n return -1;\n\n s->bit_rate = get_bits(&s->gb, 18) * 400;\n\n if (get_bits1(&s->gb) == 0) /* marker */\n\n return -1;\n\n if (width <= 0 || height <= 0 ||\n\n (width % 2) != 0 || (height % 2) != 0)\n\n return -1;\n\n if (width != s->width ||\n\n height != s->height) {\n\n /* start new mpeg1 context decoding */\n\n s->out_format = FMT_MPEG1;\n\n if (s1->mpeg_enc_ctx_allocated) {\n\n MPV_common_end(s);\n\n }\n\n s->width = width;\n\n s->height = height;\n\n avctx->has_b_frames= 1;\n\n s->avctx = avctx;\n\n avctx->width = width;\n\n avctx->height = height;\n\n if (s->frame_rate_index >= 9) {\n\n /* at least give a valid frame rate (some old mpeg1 have this) */\n\n avctx->frame_rate = 25 * FRAME_RATE_BASE;\n\n } else {\n\n avctx->frame_rate = frame_rate_tab[s->frame_rate_index];\n\n }\n\n s->frame_rate = avctx->frame_rate;\n\n avctx->bit_rate = s->bit_rate;\n\n \n\n if (MPV_common_init(s) < 0)\n\n return -1;\n\n s1->mpeg_enc_ctx_allocated = 1;\n\n }\n\n\n\n skip_bits(&s->gb, 10); /* vbv_buffer_size */\n\n skip_bits(&s->gb, 1);\n\n\n\n /* get matrix */\n\n if (get_bits1(&s->gb)) {\n\n for(i=0;i<64;i++) {\n\n v = get_bits(&s->gb, 8);\n\n j = s->intra_scantable.permutated[i];\n\n s->intra_matrix[j] = v;\n\n s->chroma_intra_matrix[j] = v;\n\n }\n\n#ifdef DEBUG\n\n dprintf(\"intra matrix present\\n\");\n\n for(i=0;i<64;i++)\n\n dprintf(\" %d\", s->intra_matrix[s->intra_scantable.permutated[i]]);\n\n printf(\"\\n\");\n\n#endif\n\n } else {\n\n for(i=0;i<64;i++) {\n\n int j= s->idct_permutation[i];\n\n v = ff_mpeg1_default_intra_matrix[i];\n\n s->intra_matrix[j] = v;\n\n s->chroma_intra_matrix[j] = v;\n\n }\n\n }\n\n if (get_bits1(&s->gb)) {\n\n for(i=0;i<64;i++) {\n\n v = get_bits(&s->gb, 8);\n\n j = s->intra_scantable.permutated[i];\n\n s->inter_matrix[j] = v;\n\n s->chroma_inter_matrix[j] = v;\n\n }\n\n#ifdef DEBUG\n\n dprintf(\"non intra matrix present\\n\");\n\n for(i=0;i<64;i++)\n\n dprintf(\" %d\", s->inter_matrix[s->intra_scantable.permutated[i]]);\n\n printf(\"\\n\");\n\n#endif\n\n } else {\n\n for(i=0;i<64;i++) {\n\n int j= s->idct_permutation[i];\n\n v = ff_mpeg1_default_non_intra_matrix[i];\n\n s->inter_matrix[j] = v;\n\n s->chroma_inter_matrix[j] = v;\n\n }\n\n }\n\n\n\n /* we set mpeg2 parameters so that it emulates mpeg1 */\n\n s->progressive_sequence = 1;\n\n s->progressive_frame = 1;\n\n s->picture_structure = PICT_FRAME;\n\n s->frame_pred_frame_dct = 1;\n\n s->mpeg2 = 0;\n\n avctx->sub_id = 1; /* indicates mpeg1 */\n\n return 0;\n\n}\n"
],
"pattern_description": "LIMITATIONS cluster: coding (DANGEROUS: 100.0% limitations/harmful)",
"detection_heuristic": "contains_code AND (has_vulnerability OR cyclomatic_complexity > 10)",
"keywords": [
"case",
"return",
"break",
"else",
"null",
"avctx",
"static",
"data",
"goto",
"void"
]
},
{
"cluster_id": 1,
"size": 491,
"category_distribution": {
"limitations": 1.0
},
"domain_distribution": {
"medicine": 491
},
"purity": 1.0,
"is_dangerous": true,
"examples": [
"A junior orthopaedic surgery resident is completing a carpal tunnel repair with the department chairman as the attending physician. During the case, the resident inadvertently cuts a flexor tendon. The tendon is repaired without complication. The attending tells the resident that the patient will do fine, and there is no need to report this minor complication that will not harm the patient, as he does not want to make the patient worry unnecessarily. He tells the resident to leave this complication out of the operative report. Which of the following is the correct next action for the resident to take?",
"A 67-year-old man with transitional cell carcinoma of the bladder comes to the physician because of a 2-day history of ringing sensation in his ear. He received this first course of neoadjuvant chemotherapy 1 week ago. Pure tone audiometry shows a sensorineural hearing loss of 45 dB. The expected beneficial effect of the drug that caused this patient's symptoms is most likely due to which of the following actions?",
"Two weeks after undergoing an emergency cardiac catherization with stenting for unstable angina pectoris, a 61-year-old man has decreased urinary output and malaise. He has type 2 diabetes mellitus and osteoarthritis of the hips. Prior to admission, his medications were insulin and naproxen. He was also started on aspirin, clopidogrel, and metoprolol after the coronary intervention. His temperature is 38\u00b0C (100.4\u00b0F), pulse is 93/min, and blood pressure is 125/85 mm Hg. Examination shows mottled, reticulated purplish discoloration of the feet. Laboratory studies show:\nHemoglobin count 14 g/dL\nLeukocyte count 16,400/mm3\nSegmented neutrophils 56%\nEosinophils 11%\nLymphocytes 31%\nMonocytes 2%\nPlatelet count 260,000/mm3\nErythrocyte sedimentation rate 68 mm/h\nSerum\nUrea nitrogen 25 mg/dL\nCreatinine 4.2 mg/dL\nRenal biopsy shows intravascular spindle-shaped vacuoles. Which of the following is the most likely cause of this patient's symptoms?\"",
"A 39-year-old woman is brought to the emergency department because of fevers, chills, and left lower quadrant pain. Her temperature is 39.1\u00b0C (102.3\u00b0F), pulse is 126/min, respirations are 28/min, and blood pressure is 80/50 mm Hg. There is blood oozing around the site of a peripheral intravenous line. Pelvic examination shows mucopurulent discharge from the cervical os and left adnexal tenderness. Laboratory studies show:\nPlatelet count 14,200/mm3\nFibrinogen 83 mg/mL (N = 200\u2013430 mg/dL)\nD-dimer 965 ng/mL (N < 500 ng/mL)\nWhen phenol is applied to a sample of the patient's blood at 90\u00b0C, a phosphorylated N-acetylglucosamine dimer with 6 fatty acids attached to a polysaccharide side chain is identified. A blood culture is most likely to show which of the following?\"",
"A 35-year-old man comes to the physician because of itchy, watery eyes for the past week. He has also been sneezing multiple times a day during this period. He had a similar episode 1 year ago around springtime. He has iron deficiency anemia and ankylosing spondylitis. Current medications include ferrous sulfate, artificial tear drops, and indomethacin. He works as an elementary school teacher. His vital signs are within normal limits. Visual acuity is 20/20 without correction. Physical examination shows bilateral conjunctival injection with watery discharge. The pupils are 3 mm, equal, and reactive to light. Examination of the anterior chamber of the eye is unremarkable. Which of the following is the most appropriate treatment?"
],
"pattern_description": "LIMITATIONS cluster: medicine (DANGEROUS: 100.0% limitations/harmful)",
"detection_heuristic": "keyword_match: ['patient', 'year', 'following', 'most', 'examination'] AND domain=medicine",
"keywords": [
"patient",
"year",
"following",
"most",
"examination",
"blood",
"shows",
"history",
"likely",
"past"
]
}
],
"model_path": "models/clustering/kmeans_model.pkl",
"embeddings_path": "models/clustering/embeddings.npy"
}