static void omap_prcm_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { struct omap_prcm_s *s = (struct omap_prcm_s *) opaque; if (size != 4) { omap_badwidth_write32(opaque, addr, value); return; } switch (addr) { case 0x000: /* PRCM_REVISION */ case 0x054: /* PRCM_VOLTST */ case 0x084: /* PRCM_CLKCFG_STATUS */ case 0x1e4: /* PM_PWSTST_MPU */ case 0x220: /* CM_IDLEST1_CORE */ case 0x224: /* CM_IDLEST2_CORE */ case 0x22c: /* CM_IDLEST4_CORE */ case 0x2c8: /* PM_WKDEP_CORE */ case 0x2e4: /* PM_PWSTST_CORE */ case 0x320: /* CM_IDLEST_GFX */ case 0x3e4: /* PM_PWSTST_GFX */ case 0x420: /* CM_IDLEST_WKUP */ case 0x520: /* CM_IDLEST_CKGEN */ case 0x820: /* CM_IDLEST_DSP */ case 0x8e4: /* PM_PWSTST_DSP */ OMAP_RO_REG(addr); return; case 0x010: /* PRCM_SYSCONFIG */ s->sysconfig = value & 1; break; case 0x018: /* PRCM_IRQSTATUS_MPU */ s->irqst[0] &= ~value; omap_prcm_int_update(s, 0); break; case 0x01c: /* PRCM_IRQENABLE_MPU */ s->irqen[0] = value & 0x3f; omap_prcm_int_update(s, 0); break; case 0x050: /* PRCM_VOLTCTRL */ s->voltctrl = value & 0xf1c3; break; case 0x060: /* PRCM_CLKSRC_CTRL */ s->clksrc[0] = value & 0xdb; /* TODO update clocks */ break; case 0x070: /* PRCM_CLKOUT_CTRL */ s->clkout[0] = value & 0xbbbb; /* TODO update clocks */ break; case 0x078: /* PRCM_CLKEMUL_CTRL */ s->clkemul[0] = value & 1; /* TODO update clocks */ break; case 0x080: /* PRCM_CLKCFG_CTRL */ break; case 0x090: /* PRCM_VOLTSETUP */ s->setuptime[0] = value & 0xffff; break; case 0x094: /* PRCM_CLKSSETUP */ s->setuptime[1] = value & 0xffff; break; case 0x098: /* PRCM_POLCTRL */ s->clkpol[0] = value & 0x701; break; case 0x0b0: /* GENERAL_PURPOSE1 */ case 0x0b4: /* GENERAL_PURPOSE2 */ case 0x0b8: /* GENERAL_PURPOSE3 */ case 0x0bc: /* GENERAL_PURPOSE4 */ case 0x0c0: /* GENERAL_PURPOSE5 */ case 0x0c4: /* GENERAL_PURPOSE6 */ case 0x0c8: /* GENERAL_PURPOSE7 */ case 0x0cc: /* GENERAL_PURPOSE8 */ case 0x0d0: /* GENERAL_PURPOSE9 */ case 0x0d4: /* GENERAL_PURPOSE10 */ case 0x0d8: /* GENERAL_PURPOSE11 */ case 0x0dc: /* GENERAL_PURPOSE12 */ case 0x0e0: /* GENERAL_PURPOSE13 */ case 0x0e4: /* GENERAL_PURPOSE14 */ case 0x0e8: /* GENERAL_PURPOSE15 */ case 0x0ec: /* GENERAL_PURPOSE16 */ case 0x0f0: /* GENERAL_PURPOSE17 */ case 0x0f4: /* GENERAL_PURPOSE18 */ case 0x0f8: /* GENERAL_PURPOSE19 */ case 0x0fc: /* GENERAL_PURPOSE20 */ s->scratch[(addr - 0xb0) >> 2] = value; break; case 0x140: /* CM_CLKSEL_MPU */ s->clksel[0] = value & 0x1f; /* TODO update clocks */ break; case 0x148: /* CM_CLKSTCTRL_MPU */ s->clkctrl[0] = value & 0x1f; break; case 0x158: /* RM_RSTST_MPU */ s->rst[0] &= ~value; break; case 0x1c8: /* PM_WKDEP_MPU */ s->wkup[0] = value & 0x15; break; case 0x1d4: /* PM_EVGENCTRL_MPU */ s->ev = value & 0x1f; break; case 0x1d8: /* PM_EVEGENONTIM_MPU */ s->evtime[0] = value; break; case 0x1dc: /* PM_EVEGENOFFTIM_MPU */ s->evtime[1] = value; break; case 0x1e0: /* PM_PWSTCTRL_MPU */ s->power[0] = value & 0xc0f; break; case 0x200: /* CM_FCLKEN1_CORE */ s->clken[0] = value & 0xbfffffff; /* TODO update clocks */ /* The EN_EAC bit only gets/puts func_96m_clk. */ break; case 0x204: /* CM_FCLKEN2_CORE */ s->clken[1] = value & 0x00000007; /* TODO update clocks */ break; case 0x210: /* CM_ICLKEN1_CORE */ s->clken[2] = value & 0xfffffff9; /* TODO update clocks */ /* The EN_EAC bit only gets/puts core_l4_iclk. */ break; case 0x214: /* CM_ICLKEN2_CORE */ s->clken[3] = value & 0x00000007; /* TODO update clocks */ break; case 0x21c: /* CM_ICLKEN4_CORE */ s->clken[4] = value & 0x0000001f; /* TODO update clocks */ break; case 0x230: /* CM_AUTOIDLE1_CORE */ s->clkidle[0] = value & 0xfffffff9; /* TODO update clocks */ break; case 0x234: /* CM_AUTOIDLE2_CORE */ s->clkidle[1] = value & 0x00000007; /* TODO update clocks */ break; case 0x238: /* CM_AUTOIDLE3_CORE */ s->clkidle[2] = value & 0x00000007; /* TODO update clocks */ break; case 0x23c: /* CM_AUTOIDLE4_CORE */ s->clkidle[3] = value & 0x0000001f; /* TODO update clocks */ break; case 0x240: /* CM_CLKSEL1_CORE */ s->clksel[1] = value & 0x0fffbf7f; /* TODO update clocks */ break; case 0x244: /* CM_CLKSEL2_CORE */ s->clksel[2] = value & 0x00fffffc; /* TODO update clocks */ break; case 0x248: /* CM_CLKSTCTRL_CORE */ s->clkctrl[1] = value & 0x7; break; case 0x2a0: /* PM_WKEN1_CORE */ s->wken[0] = value & 0x04667ff8; break; case 0x2a4: /* PM_WKEN2_CORE */ s->wken[1] = value & 0x00000005; break; case 0x2b0: /* PM_WKST1_CORE */ s->wkst[0] &= ~value; break; case 0x2b4: /* PM_WKST2_CORE */ s->wkst[1] &= ~value; break; case 0x2e0: /* PM_PWSTCTRL_CORE */ s->power[1] = (value & 0x00fc3f) | (1 << 2); break; case 0x300: /* CM_FCLKEN_GFX */ s->clken[5] = value & 6; /* TODO update clocks */ break; case 0x310: /* CM_ICLKEN_GFX */ s->clken[6] = value & 1; /* TODO update clocks */ break; case 0x340: /* CM_CLKSEL_GFX */ s->clksel[3] = value & 7; /* TODO update clocks */ break; case 0x348: /* CM_CLKSTCTRL_GFX */ s->clkctrl[2] = value & 1; break; case 0x350: /* RM_RSTCTRL_GFX */ s->rstctrl[0] = value & 1; /* TODO: reset */ break; case 0x358: /* RM_RSTST_GFX */ s->rst[1] &= ~value; break; case 0x3c8: /* PM_WKDEP_GFX */ s->wkup[1] = value & 0x13; break; case 0x3e0: /* PM_PWSTCTRL_GFX */ s->power[2] = (value & 0x00c0f) | (3 << 2); break; case 0x400: /* CM_FCLKEN_WKUP */ s->clken[7] = value & 0xd; /* TODO update clocks */ break; case 0x410: /* CM_ICLKEN_WKUP */ s->clken[8] = value & 0x3f; /* TODO update clocks */ break; case 0x430: /* CM_AUTOIDLE_WKUP */ s->clkidle[4] = value & 0x0000003f; /* TODO update clocks */ break; case 0x440: /* CM_CLKSEL_WKUP */ s->clksel[4] = value & 3; /* TODO update clocks */ break; case 0x450: /* RM_RSTCTRL_WKUP */ /* TODO: reset */ if (value & 2) qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); break; case 0x454: /* RM_RSTTIME_WKUP */ s->rsttime_wkup = value & 0x1fff; break; case 0x458: /* RM_RSTST_WKUP */ s->rst[2] &= ~value; break; case 0x4a0: /* PM_WKEN_WKUP */ s->wken[2] = value & 0x00000005; break; case 0x4b0: /* PM_WKST_WKUP */ s->wkst[2] &= ~value; break; case 0x500: /* CM_CLKEN_PLL */ if (value & 0xffffff30) fprintf(stderr, "%s: write 0s in CM_CLKEN_PLL for " "future compatibility\n", __FUNCTION__); if ((s->clken[9] ^ value) & 0xcc) { s->clken[9] &= ~0xcc; s->clken[9] |= value & 0xcc; omap_prcm_apll_update(s); } if ((s->clken[9] ^ value) & 3) { s->clken[9] &= ~3; s->clken[9] |= value & 3; omap_prcm_dpll_update(s); } break; case 0x530: /* CM_AUTOIDLE_PLL */ s->clkidle[5] = value & 0x000000cf; /* TODO update clocks */ break; case 0x540: /* CM_CLKSEL1_PLL */ if (value & 0xfc4000d7) fprintf(stderr, "%s: write 0s in CM_CLKSEL1_PLL for " "future compatibility\n", __FUNCTION__); if ((s->clksel[5] ^ value) & 0x003fff00) { s->clksel[5] = value & 0x03bfff28; omap_prcm_dpll_update(s); } /* TODO update the other clocks */ s->clksel[5] = value & 0x03bfff28; break; case 0x544: /* CM_CLKSEL2_PLL */ if (value & ~3) fprintf(stderr, "%s: write 0s in CM_CLKSEL2_PLL[31:2] for " "future compatibility\n", __FUNCTION__); if (s->clksel[6] != (value & 3)) { s->clksel[6] = value & 3; omap_prcm_dpll_update(s); } break; case 0x800: /* CM_FCLKEN_DSP */ s->clken[10] = value & 0x501; /* TODO update clocks */ break; case 0x810: /* CM_ICLKEN_DSP */ s->clken[11] = value & 0x2; /* TODO update clocks */ break; case 0x830: /* CM_AUTOIDLE_DSP */ s->clkidle[6] = value & 0x2; /* TODO update clocks */ break; case 0x840: /* CM_CLKSEL_DSP */ s->clksel[7] = value & 0x3fff; /* TODO update clocks */ break; case 0x848: /* CM_CLKSTCTRL_DSP */ s->clkctrl[3] = value & 0x101; break; case 0x850: /* RM_RSTCTRL_DSP */ /* TODO: reset */ break; case 0x858: /* RM_RSTST_DSP */ s->rst[3] &= ~value; break; case 0x8c8: /* PM_WKDEP_DSP */ s->wkup[2] = value & 0x13; break; case 0x8e0: /* PM_PWSTCTRL_DSP */ s->power[3] = (value & 0x03017) | (3 << 2); break; case 0x8f0: /* PRCM_IRQSTATUS_DSP */ s->irqst[1] &= ~value; omap_prcm_int_update(s, 1); break; case 0x8f4: /* PRCM_IRQENABLE_DSP */ s->irqen[1] = value & 0x7; omap_prcm_int_update(s, 1); break; case 0x8f8: /* PRCM_IRQSTATUS_IVA */ s->irqst[2] &= ~value; omap_prcm_int_update(s, 2); break; case 0x8fc: /* PRCM_IRQENABLE_IVA */ s->irqen[2] = value & 0x7; omap_prcm_int_update(s, 2); break; default: OMAP_BAD_REG(addr); return; } }


int kvm_arch_init(KVMState *s, int smp_cpus) { int ret; struct utsname utsname; uname(&utsname); lm_capable_kernel = strcmp(utsname.machine, "x86_64") == 0; /* create vm86 tss. KVM uses vm86 mode to emulate 16-bit code * directly. In order to use vm86 mode, a TSS is needed. Since this * must be part of guest physical memory, we need to allocate it. Older * versions of KVM just assumed that it would be at the end of physical * memory but that doesn't work with more than 4GB of memory. We simply * refuse to work with those older versions of KVM. */ ret = kvm_check_extension(s, KVM_CAP_SET_TSS_ADDR); if (ret <= 0) { fprintf(stderr, "kvm does not support KVM_CAP_SET_TSS_ADDR\n"); return ret; } /* this address is 3 pages before the bios, and the bios should present * as unavaible memory. FIXME, need to ensure the e820 map deals with * this? */ /* * Tell fw_cfg to notify the BIOS to reserve the range. */ if (e820_add_entry(0xfffbc000, 0x4000, E820_RESERVED) < 0) { perror("e820_add_entry() table is full"); exit(1); } ret = kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, 0xfffbd000); if (ret < 0) { return ret; } return kvm_init_identity_map_page(s); }


static void bootp_reply(Slirp *slirp, const struct bootp_t *bp) { BOOTPClient *bc = NULL; struct mbuf *m; struct bootp_t *rbp; struct sockaddr_in saddr, daddr; struct in_addr preq_addr; int dhcp_msg_type, val; uint8_t *q; uint8_t client_ethaddr[ETH_ALEN]; /* extract exact DHCP msg type */ dhcp_decode(bp, &dhcp_msg_type, &preq_addr); DPRINTF("bootp packet op=%d msgtype=%d", bp->bp_op, dhcp_msg_type); if (preq_addr.s_addr != htonl(0L)) DPRINTF(" req_addr=%08" PRIx32 "\n", ntohl(preq_addr.s_addr)); else DPRINTF("\n"); if (dhcp_msg_type == 0) dhcp_msg_type = DHCPREQUEST; /* Force reply for old BOOTP clients */ if (dhcp_msg_type != DHCPDISCOVER && dhcp_msg_type != DHCPREQUEST) return; /* Get client's hardware address from bootp request */ memcpy(client_ethaddr, bp->bp_hwaddr, ETH_ALEN); m = m_get(slirp); if (!m) { return; } m->m_data += IF_MAXLINKHDR; rbp = (struct bootp_t *)m->m_data; m->m_data += sizeof(struct udpiphdr); memset(rbp, 0, sizeof(struct bootp_t)); if (dhcp_msg_type == DHCPDISCOVER) { if (preq_addr.s_addr != htonl(0L)) { bc = request_addr(slirp, &preq_addr, client_ethaddr); if (bc) { daddr.sin_addr = preq_addr; } } if (!bc) { new_addr: bc = get_new_addr(slirp, &daddr.sin_addr, client_ethaddr); if (!bc) { DPRINTF("no address left\n"); return; } } memcpy(bc->macaddr, client_ethaddr, ETH_ALEN); } else if (preq_addr.s_addr != htonl(0L)) { bc = request_addr(slirp, &preq_addr, client_ethaddr); if (bc) { daddr.sin_addr = preq_addr; memcpy(bc->macaddr, client_ethaddr, ETH_ALEN); } else { /* DHCPNAKs should be sent to broadcast */ daddr.sin_addr.s_addr = 0xffffffff; } } else { bc = find_addr(slirp, &daddr.sin_addr, bp->bp_hwaddr); if (!bc) { /* if never assigned, behaves as if it was already assigned (windows fix because it remembers its address) */ goto new_addr; } } /* Update ARP table for this IP address */ arp_table_add(slirp, daddr.sin_addr.s_addr, client_ethaddr); saddr.sin_addr = slirp->vhost_addr; saddr.sin_port = htons(BOOTP_SERVER); daddr.sin_port = htons(BOOTP_CLIENT); rbp->bp_op = BOOTP_REPLY; rbp->bp_xid = bp->bp_xid; rbp->bp_htype = 1; rbp->bp_hlen = 6; memcpy(rbp->bp_hwaddr, bp->bp_hwaddr, ETH_ALEN); rbp->bp_yiaddr = daddr.sin_addr; /* Client IP address */ rbp->bp_siaddr = saddr.sin_addr; /* Server IP address */ q = rbp->bp_vend; memcpy(q, rfc1533_cookie, 4); q += 4; if (bc) { DPRINTF("%s addr=%08" PRIx32 "\n", (dhcp_msg_type == DHCPDISCOVER) ? "offered" : "ack'ed", ntohl(daddr.sin_addr.s_addr)); if (dhcp_msg_type == DHCPDISCOVER) { *q++ = RFC2132_MSG_TYPE; *q++ = 1; *q++ = DHCPOFFER; } else /* DHCPREQUEST */ { *q++ = RFC2132_MSG_TYPE; *q++ = 1; *q++ = DHCPACK; } if (slirp->bootp_filename) snprintf((char *)rbp->bp_file, sizeof(rbp->bp_file), "%s", slirp->bootp_filename); *q++ = RFC2132_SRV_ID; *q++ = 4; memcpy(q, &saddr.sin_addr, 4); q += 4; *q++ = RFC1533_NETMASK; *q++ = 4; memcpy(q, &slirp->vnetwork_mask, 4); q += 4; if (!slirp->restricted) { *q++ = RFC1533_GATEWAY; *q++ = 4; memcpy(q, &saddr.sin_addr, 4); q += 4; *q++ = RFC1533_DNS; *q++ = 4; memcpy(q, &slirp->vnameserver_addr, 4); q += 4; } *q++ = RFC2132_LEASE_TIME; *q++ = 4; val = htonl(LEASE_TIME); memcpy(q, &val, 4); q += 4; if (*slirp->client_hostname) { val = strlen(slirp->client_hostname); *q++ = RFC1533_HOSTNAME; *q++ = val; memcpy(q, slirp->client_hostname, val); q += val; } if (slirp->vdnssearch) { size_t spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend); val = slirp->vdnssearch_len; if (val + 1 > spaceleft) { g_warning("DHCP packet size exceeded, " "omitting domain-search option."); } else { memcpy(q, slirp->vdnssearch, val); q += val; } } } else { static const char nak_msg[] = "requested address not available"; DPRINTF("nak'ed addr=%08" PRIx32 "\n", ntohl(preq_addr.s_addr)); *q++ = RFC2132_MSG_TYPE; *q++ = 1; *q++ = DHCPNAK; *q++ = RFC2132_MESSAGE; *q++ = sizeof(nak_msg) - 1; memcpy(q, nak_msg, sizeof(nak_msg) - 1); q += sizeof(nak_msg) - 1; } *q = RFC1533_END; daddr.sin_addr.s_addr = 0xffffffffu; m->m_len = sizeof(struct bootp_t) - sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); }


static void hmp_logfile(Monitor *mon, const QDict *qdict) { qemu_set_log_filename(qdict_get_str(qdict, "filename")); }


iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data, void *private_data) { IscsiAIOCB *acb = (IscsiAIOCB *)private_data; scsi_free_scsi_task(acb->task); acb->task = NULL; }


int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs, Error **err) { int ret = 0; BlockDriverState *bs; BdrvNextIterator *it = NULL; QEMUSnapshotInfo sn1, *snapshot = &sn1; while (ret == 0 && (it = bdrv_next(it, &bs))) { AioContext *ctx = bdrv_get_aio_context(bs); aio_context_acquire(ctx); if (bdrv_can_snapshot(bs) && bdrv_snapshot_find(bs, snapshot, name) >= 0) { ret = bdrv_snapshot_delete_by_id_or_name(bs, name, err); } aio_context_release(ctx); } *first_bad_bs = bs; return ret; }


int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, int length, AVCodecContext *avctx, int is_nalff, int nal_length_size) { int consumed, ret = 0; pkt->nb_nals = 0; while (length >= 4) { HEVCNAL *nal; int extract_length = 0; if (is_nalff) { int i; for (i = 0; i < nal_length_size; i++) extract_length = (extract_length << 8) | buf[i]; buf += nal_length_size; length -= nal_length_size; if (extract_length > length) { av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n"); return AVERROR_INVALIDDATA; } } else { /* search start code */ while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { ++buf; --length; if (length < 4) { if (pkt->nb_nals > 0) { // No more start codes: we discarded some irrelevant // bytes at the end of the packet. return 0; } else { av_log(avctx, AV_LOG_ERROR, "No start code is found.\n"); return AVERROR_INVALIDDATA; } } } buf += 3; length -= 3; extract_length = length; } if (pkt->nals_allocated < pkt->nb_nals + 1) { int new_size = pkt->nals_allocated + 1; void *tmp = av_realloc_array(pkt->nals, new_size, sizeof(*pkt->nals)); if (!tmp) return AVERROR(ENOMEM); pkt->nals = tmp; memset(pkt->nals + pkt->nals_allocated, 0, (new_size - pkt->nals_allocated) * sizeof(*pkt->nals)); nal = &pkt->nals[pkt->nb_nals]; nal->skipped_bytes_pos_size = 1024; // initial buffer size nal->skipped_bytes_pos = av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); if (!nal->skipped_bytes_pos) return AVERROR(ENOMEM); pkt->nals_allocated = new_size; } nal = &pkt->nals[pkt->nb_nals]; consumed = ff_hevc_extract_rbsp(s, buf, extract_length, nal); if (consumed < 0) return consumed; pkt->nb_nals++; ret = init_get_bits8(&nal->gb, nal->data, nal->size); if (ret < 0) return ret; ret = hls_nal_unit(nal, avctx); if (ret <= 0) { if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n", nal->type); } pkt->nb_nals--; } buf += consumed; length -= consumed; } return 0; }


static int nvme_start_ctrl(NvmeCtrl *n) { uint32_t page_bits = NVME_CC_MPS(n->bar.cc) + 12; uint32_t page_size = 1 << page_bits; if (n->cq[0] || n->sq[0] || !n->bar.asq || !n->bar.acq || n->bar.asq & (page_size - 1) || n->bar.acq & (page_size - 1) || NVME_CC_MPS(n->bar.cc) < NVME_CAP_MPSMIN(n->bar.cap) || NVME_CC_MPS(n->bar.cc) > NVME_CAP_MPSMAX(n->bar.cap) || NVME_CC_IOCQES(n->bar.cc) < NVME_CTRL_CQES_MIN(n->id_ctrl.cqes) || NVME_CC_IOCQES(n->bar.cc) > NVME_CTRL_CQES_MAX(n->id_ctrl.cqes) || NVME_CC_IOSQES(n->bar.cc) < NVME_CTRL_SQES_MIN(n->id_ctrl.sqes) || NVME_CC_IOSQES(n->bar.cc) > NVME_CTRL_SQES_MAX(n->id_ctrl.sqes) || !NVME_AQA_ASQS(n->bar.aqa) || !NVME_AQA_ACQS(n->bar.aqa)) { return -1; } n->page_bits = page_bits; n->page_size = page_size; n->max_prp_ents = n->page_size / sizeof(uint64_t); n->cqe_size = 1 << NVME_CC_IOCQES(n->bar.cc); n->sqe_size = 1 << NVME_CC_IOSQES(n->bar.cc); nvme_init_cq(&n->admin_cq, n, n->bar.acq, 0, 0, NVME_AQA_ACQS(n->bar.aqa) + 1, 1); nvme_init_sq(&n->admin_sq, n, n->bar.asq, 0, 0, NVME_AQA_ASQS(n->bar.aqa) + 1); return 0; }


static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv) { static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b}; MXFContext *mxf = s->priv_data; AVIOContext *pb = s->pb; int64_t end = avio_tell(pb) + klv->length; uint64_t size; uint64_t orig_size; uint64_t plaintext_size; uint8_t ivec[16]; uint8_t tmpbuf[16]; int index; if (!mxf->aesc && s->key && s->keylen == 16) { mxf->aesc = av_malloc(av_aes_size); if (!mxf->aesc) return -1; av_aes_init(mxf->aesc, s->key, 128, 1); } // crypto context avio_skip(pb, klv_decode_ber_length(pb)); // plaintext offset klv_decode_ber_length(pb); plaintext_size = avio_rb64(pb); // source klv key klv_decode_ber_length(pb); avio_read(pb, klv->key, 16); if (!IS_KLV_KEY(klv, mxf_essence_element_key)) return -1; index = mxf_get_stream_index(s, klv); if (index < 0) return -1; // source size klv_decode_ber_length(pb); orig_size = avio_rb64(pb); if (orig_size < plaintext_size) return -1; // enc. code size = klv_decode_ber_length(pb); if (size < 32 || size - 32 < orig_size) return -1; avio_read(pb, ivec, 16); avio_read(pb, tmpbuf, 16); if (mxf->aesc) av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1); if (memcmp(tmpbuf, checkv, 16)) av_log(s, AV_LOG_ERROR, "probably incorrect decryption key\n"); size -= 32; av_get_packet(pb, pkt, size); size -= plaintext_size; if (mxf->aesc) av_aes_crypt(mxf->aesc, &pkt->data[plaintext_size], &pkt->data[plaintext_size], size >> 4, ivec, 1); pkt->size = orig_size; pkt->stream_index = index; avio_skip(pb, end - avio_tell(pb)); return 0; }


void avfilter_register_all(void) { static int initialized; if (initialized) return; initialized = 1; REGISTER_FILTER (ACONVERT, aconvert, af); REGISTER_FILTER (AFIFO, afifo, af); REGISTER_FILTER (AFORMAT, aformat, af); REGISTER_FILTER (AMERGE, amerge, af); REGISTER_FILTER (AMIX, amix, af); REGISTER_FILTER (ANULL, anull, af); REGISTER_FILTER (ARESAMPLE, aresample, af); REGISTER_FILTER (ASETNSAMPLES, asetnsamples, af); REGISTER_FILTER (ASETPTS, asetpts, af); REGISTER_FILTER (ASETTB, asettb, af); REGISTER_FILTER (ASHOWINFO, ashowinfo, af); REGISTER_FILTER (ASPLIT, asplit, af); REGISTER_FILTER (ASTREAMSYNC, astreamsync, af); REGISTER_FILTER (ASYNCTS, asyncts, af); REGISTER_FILTER (ATEMPO, atempo, af); REGISTER_FILTER (CHANNELMAP, channelmap, af); REGISTER_FILTER (CHANNELSPLIT,channelsplit,af); REGISTER_FILTER (EARWAX, earwax, af); REGISTER_FILTER (JOIN, join, af); REGISTER_FILTER (PAN, pan, af); REGISTER_FILTER (SILENCEDETECT, silencedetect, af); REGISTER_FILTER (VOLUME, volume, af); REGISTER_FILTER (VOLUMEDETECT,volumedetect,af); REGISTER_FILTER (RESAMPLE, resample, af); REGISTER_FILTER (AEVALSRC, aevalsrc, asrc); REGISTER_FILTER (ANULLSRC, anullsrc, asrc); REGISTER_FILTER (FLITE, flite, asrc); REGISTER_FILTER (ABUFFERSINK, abuffersink, asink); REGISTER_FILTER (ANULLSINK, anullsink, asink); REGISTER_FILTER (ALPHAEXTRACT, alphaextract, vf); REGISTER_FILTER (ALPHAMERGE, alphamerge, vf); REGISTER_FILTER (ASS, ass, vf); REGISTER_FILTER (BBOX, bbox, vf); REGISTER_FILTER (BLACKDETECT, blackdetect, vf); REGISTER_FILTER (BLACKFRAME, blackframe, vf); REGISTER_FILTER (BOXBLUR, boxblur, vf); REGISTER_FILTER (COLORMATRIX, colormatrix, vf); REGISTER_FILTER (COPY, copy, vf); REGISTER_FILTER (CROP, crop, vf); REGISTER_FILTER (CROPDETECT, cropdetect, vf); REGISTER_FILTER (DECIMATE, decimate, vf); REGISTER_FILTER (DELOGO, delogo, vf); REGISTER_FILTER (DESHAKE, deshake, vf); REGISTER_FILTER (DRAWBOX, drawbox, vf); REGISTER_FILTER (DRAWTEXT, drawtext, vf); REGISTER_FILTER (EDGEDETECT, edgedetect, vf); REGISTER_FILTER (FADE, fade, vf); REGISTER_FILTER (FIELDORDER, fieldorder, vf); REGISTER_FILTER (FIFO, fifo, vf); REGISTER_FILTER (FORMAT, format, vf); REGISTER_FILTER (FPS, fps, vf); REGISTER_FILTER (FRAMESTEP, framestep, vf); REGISTER_FILTER (FREI0R, frei0r, vf); REGISTER_FILTER (GRADFUN, gradfun, vf); REGISTER_FILTER (HFLIP, hflip, vf); REGISTER_FILTER (HQDN3D, hqdn3d, vf); REGISTER_FILTER (HUE, hue, vf); REGISTER_FILTER (IDET, idet, vf); REGISTER_FILTER (LUT, lut, vf); REGISTER_FILTER (LUTRGB, lutrgb, vf); REGISTER_FILTER (LUTYUV, lutyuv, vf); REGISTER_FILTER (MP, mp, vf); REGISTER_FILTER (NEGATE, negate, vf); REGISTER_FILTER (NOFORMAT, noformat, vf); REGISTER_FILTER (NULL, null, vf); REGISTER_FILTER (OCV, ocv, vf); REGISTER_FILTER (OVERLAY, overlay, vf); REGISTER_FILTER (PAD, pad, vf); REGISTER_FILTER (PIXDESCTEST, pixdesctest, vf); REGISTER_FILTER (REMOVELOGO, removelogo, vf); REGISTER_FILTER (SCALE, scale, vf); REGISTER_FILTER (SELECT, select, vf); REGISTER_FILTER (SETDAR, setdar, vf); REGISTER_FILTER (SETFIELD, setfield, vf); REGISTER_FILTER (SETPTS, setpts, vf); REGISTER_FILTER (SETSAR, setsar, vf); REGISTER_FILTER (SETTB, settb, vf); REGISTER_FILTER (SHOWINFO, showinfo, vf); REGISTER_FILTER (SLICIFY, slicify, vf); REGISTER_FILTER (SMARTBLUR, smartblur, vf); REGISTER_FILTER (SPLIT, split, vf); REGISTER_FILTER (SUPER2XSAI, super2xsai, vf); REGISTER_FILTER (SWAPUV, swapuv, vf); REGISTER_FILTER (THUMBNAIL, thumbnail, vf); REGISTER_FILTER (TILE, tile, vf); REGISTER_FILTER (TINTERLACE, tinterlace, vf); REGISTER_FILTER (TRANSPOSE, transpose, vf); REGISTER_FILTER (UNSHARP, unsharp, vf); REGISTER_FILTER (VFLIP, vflip, vf); REGISTER_FILTER (YADIF, yadif, vf); REGISTER_FILTER (CELLAUTO, cellauto, vsrc); REGISTER_FILTER (COLOR, color, vsrc); REGISTER_FILTER (FREI0R, frei0r_src, vsrc); REGISTER_FILTER (LIFE, life, vsrc); REGISTER_FILTER (MANDELBROT, mandelbrot, vsrc); REGISTER_FILTER (MPTESTSRC, mptestsrc, vsrc); REGISTER_FILTER (NULLSRC, nullsrc, vsrc); REGISTER_FILTER (RGBTESTSRC, rgbtestsrc, vsrc); REGISTER_FILTER (SMPTEBARS, smptebars, vsrc); REGISTER_FILTER (TESTSRC, testsrc, vsrc); REGISTER_FILTER (BUFFERSINK, buffersink, vsink); REGISTER_FILTER (FFBUFFERSINK,ffbuffersink,vsink); REGISTER_FILTER (NULLSINK, nullsink, vsink); /* multimedia filters */ REGISTER_FILTER (CONCAT, concat, avf); REGISTER_FILTER (SHOWSPECTRUM,showspectrum,avf); REGISTER_FILTER (SHOWWAVES, showwaves, avf); /* multimedia sources */ REGISTER_FILTER (AMOVIE, amovie, avsrc); REGISTER_FILTER (MOVIE, movie, avsrc); /* those filters are part of public or internal API => registered * unconditionally */ { extern AVFilter avfilter_vsrc_buffer; avfilter_register(&avfilter_vsrc_buffer); } { extern AVFilter avfilter_asrc_abuffer; avfilter_register(&avfilter_asrc_abuffer); } { extern AVFilter avfilter_vsink_buffer; avfilter_register(&avfilter_vsink_buffer); } { extern AVFilter avfilter_asink_abuffer; avfilter_register(&avfilter_asink_abuffer); } }


void show_banner(void) { fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmpeg developers\n", program_name, program_birth_year, this_year); fprintf(stderr, " built on %s %s with %s %s\n", __DATE__, __TIME__, CC_TYPE, CC_VERSION); fprintf(stderr, " configuration: " FFMPEG_CONFIGURATION "\n"); print_all_libs_info(stderr, INDENT|SHOW_CONFIG); print_all_libs_info(stderr, INDENT|SHOW_VERSION); }


static int decode_delta_block (bit_buffer_t *bitbuf, uint8_t *current, uint8_t *previous, int pitch, svq1_pmv_t *motion, int x, int y) { uint32_t bit_cache; uint32_t block_type; int result = 0; /* get block type */ bit_cache = get_bit_cache (bitbuf); bit_cache >>= (32 - 3); block_type = block_type_table[bit_cache].value; skip_bits(bitbuf,block_type_table[bit_cache].length); /* reset motion vectors */ if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) { motion[0].x = 0; motion[0].y = 0; motion[(x / 8) + 2].x = 0; motion[(x / 8) + 2].y = 0; motion[(x / 8) + 3].x = 0; motion[(x / 8) + 3].y = 0; } switch (block_type) { case SVQ1_BLOCK_SKIP: skip_block (current, previous, pitch, x, y); break; case SVQ1_BLOCK_INTER: result = motion_inter_block (bitbuf, current, previous, pitch, motion, x, y); if (result != 0) { #ifdef DEBUG_SVQ1 printf("Error in motion_inter_block %i\n",result); #endif break; } result = decode_svq1_block (bitbuf, current, pitch, 0); break; case SVQ1_BLOCK_INTER_4V: result = motion_inter_4v_block (bitbuf, current, previous, pitch, motion, x, y); if (result != 0) { #ifdef DEBUG_SVQ1 printf("Error in motion_inter_4v_block %i\n",result); #endif break; } result = decode_svq1_block (bitbuf, current, pitch, 0); break; case SVQ1_BLOCK_INTRA: result = decode_svq1_block (bitbuf, current, pitch, 1); break; } return result; }


static int pci_ich9_uninit(PCIDevice *dev) { struct AHCIPCIState *d; d = DO_UPCAST(struct AHCIPCIState, card, dev); if (msi_enabled(dev)) { msi_uninit(dev); } qemu_unregister_reset(ahci_reset, d); ahci_uninit(&d->ahci); return 0; }


void powerpc_display_perf_report(void) { int i; #ifndef POWERPC_PERF_USE_PMC fprintf(stderr, "PowerPC performance report\n Values are from the Time Base register, and represent 4 bus cycles.\n"); #else /* POWERPC_PERF_USE_PMC */ fprintf(stderr, "PowerPC performance report\n Values are from the PMC registers, and represent whatever the registers are set to record.\n"); #endif /* POWERPC_PERF_USE_PMC */ for(i = 0 ; i < powerpc_perf_total ; i++) { if (perfdata[i][powerpc_data_num] != (unsigned long long)0) fprintf(stderr, " Function \"%s\" (pmc1):\n\tmin: %llu\n\tmax: %llu\n\tavg: %1.2lf (%llu)\n", perfname[i], perfdata[i][powerpc_data_min], perfdata[i][powerpc_data_max], (double)perfdata[i][powerpc_data_sum] / (double)perfdata[i][powerpc_data_num], perfdata[i][powerpc_data_num]); #ifdef POWERPC_PERF_USE_PMC if (perfdata_pmc2[i][powerpc_data_num] != (unsigned long long)0) fprintf(stderr, " Function \"%s\" (pmc2):\n\tmin: %llu\n\tmax: %llu\n\tavg: %1.2lf (%llu)\n", perfname[i], perfdata_pmc2[i][powerpc_data_min], perfdata_pmc2[i][powerpc_data_max], (double)perfdata_pmc2[i][powerpc_data_sum] / (double)perfdata_pmc2[i][powerpc_data_num], perfdata_pmc2[i][powerpc_data_num]); if (perfdata_pmc3[i][powerpc_data_num] != (unsigned long long)0) fprintf(stderr, " Function \"%s\" (pmc3):\n\tmin: %llu\n\tmax: %llu\n\tavg: %1.2lf (%llu)\n", perfname[i], perfdata_pmc3[i][powerpc_data_min], perfdata_pmc3[i][powerpc_data_max], (double)perfdata_pmc3[i][powerpc_data_sum] / (double)perfdata_pmc3[i][powerpc_data_num], perfdata_pmc3[i][powerpc_data_num]); #endif } }


void ccw_dstream_init(CcwDataStream *cds, CCW1 const *ccw, ORB const *orb) { /* * We don't support MIDA (an optional facility) yet and we * catch this earlier. Just for expressing the precondition. */ g_assert(!(orb->ctrl1 & ORB_CTRL1_MASK_MIDAW)); cds->flags = (orb->ctrl0 & ORB_CTRL0_MASK_I2K ? CDS_F_I2K : 0) | (orb->ctrl0 & ORB_CTRL0_MASK_C64 ? CDS_F_C64 : 0) | (ccw->flags & CCW_FLAG_IDA ? CDS_F_IDA : 0); cds->count = ccw->count; cds->cda_orig = ccw->cda; ccw_dstream_rewind(cds); if (!(cds->flags & CDS_F_IDA)) { cds->op_handler = ccw_dstream_rw_noflags; } else { assert(false); } }


static int msrle_decode_pal4(AVCodecContext *avctx, AVPicture *pic, const uint8_t *data, int data_size) { int stream_ptr = 0; unsigned char rle_code; unsigned char extra_byte, odd_pixel; unsigned char stream_byte; int pixel_ptr = 0; int row_dec = pic->linesize[0]; int row_ptr = (avctx->height - 1) * row_dec; int frame_size = row_dec * avctx->height; int i; while (row_ptr >= 0) { FETCH_NEXT_STREAM_BYTE(); rle_code = stream_byte; if (rle_code == 0) { /* fetch the next byte to see how to handle escape code */ FETCH_NEXT_STREAM_BYTE(); if (stream_byte == 0) { /* line is done, goto the next one */ row_ptr -= row_dec; pixel_ptr = 0; } else if (stream_byte == 1) { /* decode is done */ return 0; } else if (stream_byte == 2) { /* reposition frame decode coordinates */ FETCH_NEXT_STREAM_BYTE(); pixel_ptr += stream_byte; FETCH_NEXT_STREAM_BYTE(); row_ptr -= stream_byte * row_dec; } else { // copy pixels from encoded stream odd_pixel = stream_byte & 1; rle_code = (stream_byte + 1) / 2; extra_byte = rle_code & 0x01; if (row_ptr + pixel_ptr + stream_byte > frame_size) { av_log(avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (1)\n"); return -1; } for (i = 0; i < rle_code; i++) { if (pixel_ptr >= avctx->width) break; FETCH_NEXT_STREAM_BYTE(); pic->data[0][row_ptr + pixel_ptr] = stream_byte >> 4; pixel_ptr++; if (i + 1 == rle_code && odd_pixel) break; if (pixel_ptr >= avctx->width) break; pic->data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F; pixel_ptr++; } // if the RLE code is odd, skip a byte in the stream if (extra_byte) stream_ptr++; } } else { // decode a run of data if (row_ptr + pixel_ptr + stream_byte > frame_size) { av_log(avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (1)\n"); return -1; } FETCH_NEXT_STREAM_BYTE(); for (i = 0; i < rle_code; i++) { if (pixel_ptr >= avctx->width) break; if ((i & 1) == 0) pic->data[0][row_ptr + pixel_ptr] = stream_byte >> 4; else pic->data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F; pixel_ptr++; } } } /* one last sanity check on the way out */ if (stream_ptr < data_size) { av_log(avctx, AV_LOG_ERROR, " MS RLE: ended frame decode with bytes left over (%d < %d)\n", stream_ptr, data_size); return -1; } return 0; }


static int vnc_update_client(VncState *vs, int has_dirty, bool sync) { vs->has_dirty += has_dirty; if (vs->need_update && vs->ioc != NULL) { VncDisplay *vd = vs->vd; VncJob *job; int y; int height, width; int n = 0; if (vs->output.offset && !vs->audio_cap && !vs->force_update) /* kernel send buffers are full -> drop frames to throttle */ return 0; if (!vs->has_dirty && !vs->audio_cap && !vs->force_update) return 0; /* * Send screen updates to the vnc client using the server * surface and server dirty map. guest surface updates * happening in parallel don't disturb us, the next pass will * send them to the client. */ job = vnc_job_new(vs); height = pixman_image_get_height(vd->server); width = pixman_image_get_width(vd->server); y = 0; for (;;) { int x, h; unsigned long x2; unsigned long offset = find_next_bit((unsigned long *) &vs->dirty, height * VNC_DIRTY_BPL(vs), y * VNC_DIRTY_BPL(vs)); if (offset == height * VNC_DIRTY_BPL(vs)) { /* no more dirty bits */ break; } y = offset / VNC_DIRTY_BPL(vs); x = offset % VNC_DIRTY_BPL(vs); x2 = find_next_zero_bit((unsigned long *) &vs->dirty[y], VNC_DIRTY_BPL(vs), x); bitmap_clear(vs->dirty[y], x, x2 - x); h = find_and_clear_dirty_height(vs, y, x, x2, height); x2 = MIN(x2, width / VNC_DIRTY_PIXELS_PER_BIT); if (x2 > x) { n += vnc_job_add_rect(job, x * VNC_DIRTY_PIXELS_PER_BIT, y, (x2 - x) * VNC_DIRTY_PIXELS_PER_BIT, h); } if (!x && x2 == width / VNC_DIRTY_PIXELS_PER_BIT) { y += h; if (y == height) { break; } } } vnc_job_push(job); if (sync) { vnc_jobs_join(vs); } vs->force_update = 0; vs->has_dirty = 0; return n; } if (vs->disconnecting) { vnc_disconnect_finish(vs); } else if (sync) { vnc_jobs_join(vs); } return 0; }


static void vc1_mc_4mv_chroma4(VC1Context *v) { MpegEncContext *s = &v->s; DSPContext *dsp = &v->s.dsp; uint8_t *srcU, *srcV; int uvsrc_x, uvsrc_y; int uvmx_field[4], uvmy_field[4]; int i, off, tx, ty; int fieldmv = v->blk_mv_type[s->block_index[0]]; static const int s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 }; int v_dist = fieldmv ? 1 : 4; // vertical offset for lower sub-blocks int v_edge_pos = s->v_edge_pos >> 1; if (!v->s.last_picture.f.data[0]) return; if (s->flags & CODEC_FLAG_GRAY) return; for (i = 0; i < 4; i++) { tx = s->mv[0][i][0]; uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1; ty = s->mv[0][i][1]; if (fieldmv) uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF]; else uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1; } for (i = 0; i < 4; i++) { off = (i & 1) * 4 + ((i & 2) ? v_dist * s->uvlinesize : 0); uvsrc_x = s->mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2); uvsrc_y = s->mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2); // FIXME: implement proper pull-back (see vc1cropmv.c, vc1CROPMV_ChromaPullBack()) uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; uvmx_field[i] = (uvmx_field[i] & 3) << 1; uvmy_field[i] = (uvmy_field[i] & 3) << 1; if (fieldmv && !(uvsrc_y & 1)) v_edge_pos--; if (fieldmv && (uvsrc_y & 1) && uvsrc_y < 2) uvsrc_y--; if ((v->mv_mode == MV_PMODE_INTENSITY_COMP) || s->h_edge_pos < 10 || v_edge_pos < (5 << fieldmv) || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 5 || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) { s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcU, s->uvlinesize, 5, (5 << fieldmv), uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos); s->dsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize, 5, (5 << fieldmv), uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos); srcU = s->edge_emu_buffer; srcV = s->edge_emu_buffer + 16; /* if we deal with intensity compensation we need to scale source blocks */ if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { int i, j; uint8_t *src, *src2; src = srcU; src2 = srcV; for (j = 0; j < 5; j++) { for (i = 0; i < 5; i++) { src[i] = v->lutuv[src[i]]; src2[i] = v->lutuv[src2[i]]; } src += s->uvlinesize << 1; src2 += s->uvlinesize << 1; } } } if (!v->rnd) { dsp->put_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); dsp->put_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); } else { v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); } } }


static void vga_invalidate_display(void *opaque) { VGAState *s = (VGAState *)opaque; s->last_width = -1; s->last_height = -1; }


static void virtio_setup(uint64_t dev_info) { struct schib schib; int ssid; bool found = false; uint16_t dev_no; /* * We unconditionally enable mss support. In every sane configuration, * this will succeed; and even if it doesn't, stsch_err() can deal * with the consequences. */ enable_mss_facility(); if (dev_info != -1) { dev_no = dev_info & 0xffff; debug_print_int("device no. ", dev_no); blk_schid.ssid = (dev_info >> 16) & 0x3; debug_print_int("ssid ", blk_schid.ssid); found = find_dev(&schib, dev_no); } else { for (ssid = 0; ssid < 0x3; ssid++) { blk_schid.ssid = ssid; found = find_dev(&schib, -1); if (found) { break; } } } if (!found) { virtio_panic("No virtio-blk device found!\n"); } virtio_setup_block(blk_schid); if (!virtio_ipl_disk_is_valid()) { virtio_panic("No valid hard disk detected.\n"); } }


static void qemu_cleanup_net_client(NetClientState *nc) { QTAILQ_REMOVE(&net_clients, nc, next); nc->info->cleanup(nc); }


static void tcg_out_op (TCGContext *s, int opc, const TCGArg *args, const int *const_args) { int c; switch (opc) { case INDEX_op_exit_tb: tcg_out_movi (s, TCG_TYPE_I64, TCG_REG_R3, args[0]); tcg_out_b (s, 0, (tcg_target_long) tb_ret_addr); break; case INDEX_op_goto_tb: if (s->tb_jmp_offset) { /* direct jump method */ s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; s->code_ptr += 28; } else { tcg_abort (); } s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf; break; case INDEX_op_br: { TCGLabel *l = &s->labels[args[0]]; if (l->has_value) { tcg_out_b (s, 0, l->u.value); } else { uint32_t val = *(uint32_t *) s->code_ptr; /* Thanks to Andrzej Zaborowski */ tcg_out32 (s, B | (val & 0x3fffffc)); tcg_out_reloc (s, s->code_ptr - 4, R_PPC_REL24, args[0], 0); } } break; case INDEX_op_call: tcg_out_call (s, args[0], const_args[0]); break; case INDEX_op_jmp: if (const_args[0]) { tcg_out_b (s, 0, args[0]); } else { tcg_out32 (s, MTSPR | RS (args[0]) | CTR); tcg_out32 (s, BCCTR | BO_ALWAYS); } break; case INDEX_op_movi_i32: tcg_out_movi (s, TCG_TYPE_I32, args[0], args[1]); break; case INDEX_op_movi_i64: tcg_out_movi (s, TCG_TYPE_I64, args[0], args[1]); break; case INDEX_op_ld8u_i32: case INDEX_op_ld8u_i64: tcg_out_ldst (s, args[0], args[1], args[2], LBZ, LBZX); break; case INDEX_op_ld8s_i32: case INDEX_op_ld8s_i64: tcg_out_ldst (s, args[0], args[1], args[2], LBZ, LBZX); tcg_out32 (s, EXTSB | RS (args[0]) | RA (args[0])); break; case INDEX_op_ld16u_i32: case INDEX_op_ld16u_i64: tcg_out_ldst (s, args[0], args[1], args[2], LHZ, LHZX); break; case INDEX_op_ld16s_i32: case INDEX_op_ld16s_i64: tcg_out_ldst (s, args[0], args[1], args[2], LHA, LHAX); break; case INDEX_op_ld_i32: case INDEX_op_ld32u_i64: tcg_out_ldst (s, args[0], args[1], args[2], LWZ, LWZX); break; case INDEX_op_ld32s_i64: tcg_out_ldst (s, args[0], args[1], args[2], LWA, LWAX); break; case INDEX_op_ld_i64: tcg_out_ldst (s, args[0], args[1], args[2], LD, LDX); break; case INDEX_op_st8_i32: case INDEX_op_st8_i64: tcg_out_ldst (s, args[0], args[1], args[2], STB, STBX); break; case INDEX_op_st16_i32: case INDEX_op_st16_i64: tcg_out_ldst (s, args[0], args[1], args[2], STH, STHX); break; case INDEX_op_st_i32: case INDEX_op_st32_i64: tcg_out_ldst (s, args[0], args[1], args[2], STW, STWX); break; case INDEX_op_st_i64: tcg_out_ldst (s, args[0], args[1], args[2], STD, STDX); break; case INDEX_op_add_i32: if (const_args[2]) ppc_addi32 (s, args[0], args[1], args[2]); else tcg_out32 (s, ADD | TAB (args[0], args[1], args[2])); break; case INDEX_op_sub_i32: if (const_args[2]) ppc_addi32 (s, args[0], args[1], -args[2]); else tcg_out32 (s, SUBF | TAB (args[0], args[2], args[1])); break; case INDEX_op_and_i64: case INDEX_op_and_i32: if (const_args[2]) { if ((args[2] & 0xffff) == args[2]) tcg_out32 (s, ANDI | RS (args[1]) | RA (args[0]) | args[2]); else if ((args[2] & 0xffff0000) == args[2]) tcg_out32 (s, ANDIS | RS (args[1]) | RA (args[0]) | ((args[2] >> 16) & 0xffff)); else { tcg_out_movi (s, (opc == INDEX_op_and_i32 ? TCG_TYPE_I32 : TCG_TYPE_I64), 0, args[2]); tcg_out32 (s, AND | SAB (args[1], args[0], 0)); } } else tcg_out32 (s, AND | SAB (args[1], args[0], args[2])); break; case INDEX_op_or_i64: case INDEX_op_or_i32: if (const_args[2]) { if (args[2] & 0xffff) { tcg_out32 (s, ORI | RS (args[1]) | RA (args[0]) | (args[2] & 0xffff)); if (args[2] >> 16) tcg_out32 (s, ORIS | RS (args[0]) | RA (args[0]) | ((args[2] >> 16) & 0xffff)); } else { tcg_out32 (s, ORIS | RS (args[1]) | RA (args[0]) | ((args[2] >> 16) & 0xffff)); } } else tcg_out32 (s, OR | SAB (args[1], args[0], args[2])); break; case INDEX_op_xor_i64: case INDEX_op_xor_i32: if (const_args[2]) { if ((args[2] & 0xffff) == args[2]) tcg_out32 (s, XORI | RS (args[1]) | RA (args[0]) | (args[2] & 0xffff)); else if ((args[2] & 0xffff0000) == args[2]) tcg_out32 (s, XORIS | RS (args[1]) | RA (args[0]) | ((args[2] >> 16) & 0xffff)); else { tcg_out_movi (s, (opc == INDEX_op_and_i32 ? TCG_TYPE_I32 : TCG_TYPE_I64), 0, args[2]); tcg_out32 (s, XOR | SAB (args[1], args[0], 0)); } } else tcg_out32 (s, XOR | SAB (args[1], args[0], args[2])); break; case INDEX_op_mul_i32: if (const_args[2]) { if (args[2] == (int16_t) args[2]) tcg_out32 (s, MULLI | RT (args[0]) | RA (args[1]) | (args[2] & 0xffff)); else { tcg_out_movi (s, TCG_TYPE_I32, 0, args[2]); tcg_out32 (s, MULLW | TAB (args[0], args[1], 0)); } } else tcg_out32 (s, MULLW | TAB (args[0], args[1], args[2])); break; case INDEX_op_div_i32: tcg_out32 (s, DIVW | TAB (args[0], args[1], args[2])); break; case INDEX_op_divu_i32: tcg_out32 (s, DIVWU | TAB (args[0], args[1], args[2])); break; case INDEX_op_rem_i32: tcg_out32 (s, DIVW | TAB (0, args[1], args[2])); tcg_out32 (s, MULLW | TAB (0, 0, args[2])); tcg_out32 (s, SUBF | TAB (args[0], 0, args[1])); break; case INDEX_op_remu_i32: tcg_out32 (s, DIVWU | TAB (0, args[1], args[2])); tcg_out32 (s, MULLW | TAB (0, 0, args[2])); tcg_out32 (s, SUBF | TAB (args[0], 0, args[1])); break; case INDEX_op_shl_i32: if (const_args[2]) { tcg_out32 (s, (RLWINM | RA (args[0]) | RS (args[1]) | SH (args[2]) | MB (0) | ME (31 - args[2]) ) ); } else tcg_out32 (s, SLW | SAB (args[1], args[0], args[2])); break; case INDEX_op_shr_i32: if (const_args[2]) { tcg_out32 (s, (RLWINM | RA (args[0]) | RS (args[1]) | SH (32 - args[2]) | MB (args[2]) | ME (31) ) ); } else tcg_out32 (s, SRW | SAB (args[1], args[0], args[2])); break; case INDEX_op_sar_i32: if (const_args[2]) tcg_out32 (s, SRAWI | RS (args[1]) | RA (args[0]) | SH (args[2])); else tcg_out32 (s, SRAW | SAB (args[1], args[0], args[2])); break; case INDEX_op_brcond_i32: tcg_out_brcond (s, args[2], args[0], args[1], const_args[1], args[3], 0); break; case INDEX_op_brcond_i64: tcg_out_brcond (s, args[2], args[0], args[1], const_args[1], args[3], 1); break; case INDEX_op_neg_i32: case INDEX_op_neg_i64: tcg_out32 (s, NEG | RT (args[0]) | RA (args[1])); break; case INDEX_op_add_i64: if (const_args[2]) ppc_addi64 (s, args[0], args[1], args[2]); else tcg_out32 (s, ADD | TAB (args[0], args[1], args[2])); break; case INDEX_op_sub_i64: if (const_args[2]) ppc_addi64 (s, args[0], args[1], -args[2]); else tcg_out32 (s, SUBF | TAB (args[0], args[2], args[1])); break; case INDEX_op_shl_i64: if (const_args[2]) tcg_out_rld (s, RLDICR, args[0], args[1], args[2], 63 - args[2]); else tcg_out32 (s, SLD | SAB (args[1], args[0], args[2])); break; case INDEX_op_shr_i64: if (const_args[2]) tcg_out_rld (s, RLDICL, args[0], args[1], 64 - args[2], args[2]); else tcg_out32 (s, SRD | SAB (args[1], args[0], args[2])); break; case INDEX_op_sar_i64: if (const_args[2]) { int sh = SH (args[2] & 0x1f) | (((args[2] >> 5) & 1) << 1); tcg_out32 (s, SRADI | RA (args[0]) | RS (args[1]) | sh); } else tcg_out32 (s, SRAD | SAB (args[1], args[0], args[2])); break; case INDEX_op_mul_i64: tcg_out32 (s, MULLD | TAB (args[0], args[1], args[2])); break; case INDEX_op_div_i64: tcg_out32 (s, DIVD | TAB (args[0], args[1], args[2])); break; case INDEX_op_divu_i64: tcg_out32 (s, DIVDU | TAB (args[0], args[1], args[2])); break; case INDEX_op_rem_i64: tcg_out32 (s, DIVD | TAB (0, args[1], args[2])); tcg_out32 (s, MULLD | TAB (0, 0, args[2])); tcg_out32 (s, SUBF | TAB (args[0], 0, args[1])); break; case INDEX_op_remu_i64: tcg_out32 (s, DIVDU | TAB (0, args[1], args[2])); tcg_out32 (s, MULLD | TAB (0, 0, args[2])); tcg_out32 (s, SUBF | TAB (args[0], 0, args[1])); break; case INDEX_op_qemu_ld8u: tcg_out_qemu_ld (s, args, 0); break; case INDEX_op_qemu_ld8s: tcg_out_qemu_ld (s, args, 0 | 4); break; case INDEX_op_qemu_ld16u: tcg_out_qemu_ld (s, args, 1); break; case INDEX_op_qemu_ld16s: tcg_out_qemu_ld (s, args, 1 | 4); break; case INDEX_op_qemu_ld32u: tcg_out_qemu_ld (s, args, 2); break; case INDEX_op_qemu_ld32s: tcg_out_qemu_ld (s, args, 2 | 4); break; case INDEX_op_qemu_ld64: tcg_out_qemu_ld (s, args, 3); break; case INDEX_op_qemu_st8: tcg_out_qemu_st (s, args, 0); break; case INDEX_op_qemu_st16: tcg_out_qemu_st (s, args, 1); break; case INDEX_op_qemu_st32: tcg_out_qemu_st (s, args, 2); break; case INDEX_op_qemu_st64: tcg_out_qemu_st (s, args, 3); break; case INDEX_op_ext8s_i32: case INDEX_op_ext8s_i64: c = EXTSB; goto gen_ext; case INDEX_op_ext16s_i32: case INDEX_op_ext16s_i64: c = EXTSH; goto gen_ext; case INDEX_op_ext32s_i64: c = EXTSW; goto gen_ext; gen_ext: tcg_out32 (s, c | RS (args[1]) | RA (args[0])); break; default: tcg_dump_ops (s, stderr); tcg_abort (); } }


static int socket_accept(int sock) { struct sockaddr_un addr; socklen_t addrlen; int ret; addrlen = sizeof(addr); do { ret = accept(sock, (struct sockaddr *)&addr, &addrlen); } while (ret == -1 && errno == EINTR); g_assert_no_errno(ret); close(sock); return ret; }


ivshmem_server_handle_new_conn(IvshmemServer *server) { IvshmemServerPeer *peer, *other_peer; struct sockaddr_un unaddr; socklen_t unaddr_len; int newfd; unsigned i; /* accept the incoming connection */ unaddr_len = sizeof(unaddr); newfd = qemu_accept(server->sock_fd, (struct sockaddr *)&unaddr, &unaddr_len); if (newfd < 0) { IVSHMEM_SERVER_DEBUG(server, "cannot accept() %s\n", strerror(errno)); return -1; } qemu_set_nonblock(newfd); IVSHMEM_SERVER_DEBUG(server, "accept()=%d\n", newfd); /* allocate new structure for this peer */ peer = g_malloc0(sizeof(*peer)); peer->sock_fd = newfd; /* get an unused peer id */ /* XXX: this could use id allocation such as Linux IDA, or simply * a free-list */ for (i = 0; i < G_MAXUINT16; i++) { if (ivshmem_server_search_peer(server, server->cur_id) == NULL) { break; } server->cur_id++; } if (i == G_MAXUINT16) { IVSHMEM_SERVER_DEBUG(server, "cannot allocate new client id\n"); goto fail; } peer->id = server->cur_id++; /* create eventfd, one per vector */ peer->vectors_count = server->n_vectors; for (i = 0; i < peer->vectors_count; i++) { if (event_notifier_init(&peer->vectors[i], FALSE) < 0) { IVSHMEM_SERVER_DEBUG(server, "cannot create eventfd\n"); goto fail; } } /* send peer id and shm fd */ if (ivshmem_server_send_initial_info(server, peer) < 0) { IVSHMEM_SERVER_DEBUG(server, "cannot send initial info\n"); goto fail; } /* advertise the new peer to others */ QTAILQ_FOREACH(other_peer, &server->peer_list, next) { for (i = 0; i < peer->vectors_count; i++) { ivshmem_server_send_one_msg(other_peer->sock_fd, peer->id, peer->vectors[i].wfd); } } /* advertise the other peers to the new one */ QTAILQ_FOREACH(other_peer, &server->peer_list, next) { for (i = 0; i < peer->vectors_count; i++) { ivshmem_server_send_one_msg(peer->sock_fd, other_peer->id, other_peer->vectors[i].wfd); } } /* advertise the new peer to itself */ for (i = 0; i < peer->vectors_count; i++) { ivshmem_server_send_one_msg(peer->sock_fd, peer->id, event_notifier_get_fd(&peer->vectors[i])); } QTAILQ_INSERT_TAIL(&server->peer_list, peer, next); IVSHMEM_SERVER_DEBUG(server, "new peer id = %" PRId64 "\n", peer->id); return 0; fail: while (i--) { event_notifier_cleanup(&peer->vectors[i]); } close(newfd); g_free(peer); return -1; }


static int mjpegb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, UINT8 *buf, int buf_size) { MJpegDecodeContext *s = avctx->priv_data; UINT8 *buf_end, *buf_ptr; int i; AVPicture *picture = data; GetBitContext hgb; /* for the header */ uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs; uint32_t field_size; *data_size = 0; /* no supplementary picture */ if (buf_size == 0) return 0; buf_ptr = buf; buf_end = buf + buf_size; read_header: /* reset on every SOI */ s->restart_interval = 0; init_get_bits(&hgb, buf_ptr, /*buf_size*/buf_end - buf_ptr); skip_bits(&hgb, 32); /* reserved zeros */ if (get_bits(&hgb, 32) != be2me_32(ff_get_fourcc("mjpg"))) { dprintf("not mjpeg-b (bad fourcc)\n"); return 0; } field_size = get_bits(&hgb, 32); /* field size */ dprintf("field size: 0x%x\n", field_size); skip_bits(&hgb, 32); /* padded field size */ second_field_offs = get_bits(&hgb, 32); dprintf("second field offs: 0x%x\n", second_field_offs); if (second_field_offs) s->interlaced = 1; dqt_offs = get_bits(&hgb, 32); dprintf("dqt offs: 0x%x\n", dqt_offs); if (dqt_offs) { init_get_bits(&s->gb, buf+dqt_offs, buf_end - (buf+dqt_offs)); s->start_code = DQT; mjpeg_decode_dqt(s); } dht_offs = get_bits(&hgb, 32); dprintf("dht offs: 0x%x\n", dht_offs); if (dht_offs) { init_get_bits(&s->gb, buf+dht_offs, buf_end - (buf+dht_offs)); s->start_code = DHT; mjpeg_decode_dht(s); } sof_offs = get_bits(&hgb, 32); dprintf("sof offs: 0x%x\n", sof_offs); if (sof_offs) { init_get_bits(&s->gb, buf+sof_offs, buf_end - (buf+sof_offs)); s->start_code = SOF0; if (mjpeg_decode_sof0(s) < 0) return -1; } sos_offs = get_bits(&hgb, 32); dprintf("sos offs: 0x%x\n", sos_offs); if (sos_offs) { // init_get_bits(&s->gb, buf+sos_offs, buf_end - (buf+sos_offs)); init_get_bits(&s->gb, buf+sos_offs, field_size); s->start_code = SOS; mjpeg_decode_sos(s); } skip_bits(&hgb, 32); /* start of data offset */ if (s->interlaced) { s->bottom_field ^= 1; /* if not bottom field, do not output image yet */ if (s->bottom_field && second_field_offs) { buf_ptr = buf + second_field_offs; second_field_offs = 0; goto read_header; } } for(i=0;i<3;i++) { picture->data[i] = s->current_picture[i]; picture->linesize[i] = (s->interlaced) ? s->linesize[i] >> 1 : s->linesize[i]; } *data_size = sizeof(AVPicture); avctx->height = s->height; if (s->interlaced) avctx->height *= 2; avctx->width = s->width; /* XXX: not complete test ! */ switch((s->h_count[0] << 4) | s->v_count[0]) { case 0x11: avctx->pix_fmt = PIX_FMT_YUV444P; break; case 0x21: avctx->pix_fmt = PIX_FMT_YUV422P; break; default: case 0x22: avctx->pix_fmt = PIX_FMT_YUV420P; break; } /* dummy quality */ /* XXX: infer it with matrix */ // avctx->quality = 3; return buf_ptr - buf; }


static int idcin_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { IdcinDemuxContext *idcin = s->priv_data; if (idcin->first_pkt_pos > 0) { int ret = avio_seek(s->pb, idcin->first_pkt_pos, SEEK_SET); if (ret < 0) return ret; ff_update_cur_dts(s, s->streams[idcin->video_stream_index], 0); idcin->next_chunk_is_video = 1; idcin->current_audio_chunk = 0; return 0; } return -1; }


static int multiwrite_req_compare(const void *a, const void *b) { return (((BlockRequest*) a)->sector - ((BlockRequest*) b)->sector); }


static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp) { AVFrame *src = srcp->f; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(src->format); int i; int ret = av_frame_ref(dst, src); if (ret < 0) return ret; av_dict_set(&dst->metadata, "stereo_mode", ff_h264_sei_stereo_mode(h), 0); if (srcp->sei_recovery_frame_cnt == 0) dst->key_frame = 1; if (!srcp->crop) return 0; for (i = 0; i < desc->nb_components; i++) { int hshift = (i > 0) ? desc->log2_chroma_w : 0; int vshift = (i > 0) ? desc->log2_chroma_h : 0; int off = ((srcp->crop_left >> hshift) << h->pixel_shift) + (srcp->crop_top >> vshift) * dst->linesize[i]; dst->data[i] += off; } return 0; }


int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MJpegDecodeContext *s = avctx->priv_data; const uint8_t *buf_end, *buf_ptr; const uint8_t *unescaped_buf_ptr; int hshift, vshift; int unescaped_buf_size; int start_code; int i, index; int ret = 0; int is16bit; av_dict_free(&s->exif_metadata); av_freep(&s->stereo3d); s->adobe_transform = -1; buf_ptr = buf; buf_end = buf + buf_size; while (buf_ptr < buf_end) { /* find start next marker */ start_code = ff_mjpeg_find_marker(s, &buf_ptr, buf_end, &unescaped_buf_ptr, &unescaped_buf_size); /* EOF */ if (start_code < 0) { break; } else if (unescaped_buf_size > INT_MAX / 8) { av_log(avctx, AV_LOG_ERROR, "MJPEG packet 0x%x too big (%d/%d), corrupt data?\n", start_code, unescaped_buf_size, buf_size); return AVERROR_INVALIDDATA; } av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%"PTRDIFF_SPECIFIER"\n", start_code, buf_end - buf_ptr); ret = init_get_bits8(&s->gb, unescaped_buf_ptr, unescaped_buf_size); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "invalid buffer\n"); goto fail; } s->start_code = start_code; if (s->avctx->debug & FF_DEBUG_STARTCODE) av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code); /* process markers */ if (start_code >= 0xd0 && start_code <= 0xd7) av_log(avctx, AV_LOG_DEBUG, "restart marker: %d\n", start_code & 0x0f); /* APP fields */ else if (start_code >= APP0 && start_code <= APP15) mjpeg_decode_app(s); /* Comment */ else if (start_code == COM) mjpeg_decode_com(s); ret = -1; if (!CONFIG_JPEGLS_DECODER && (start_code == SOF48 || start_code == LSE)) { av_log(avctx, AV_LOG_ERROR, "JPEG-LS support not enabled.\n"); return AVERROR(ENOSYS); } if (avctx->skip_frame == AVDISCARD_ALL) { switch(start_code) { case SOF0: case SOF1: case SOF2: case SOF3: case SOF48: case SOI: case SOS: case EOI: break; default: goto skip; } } switch (start_code) { case SOI: s->restart_interval = 0; s->restart_count = 0; /* nothing to do on SOI */ break; case DQT: ff_mjpeg_decode_dqt(s); break; case DHT: if ((ret = ff_mjpeg_decode_dht(s)) < 0) { av_log(avctx, AV_LOG_ERROR, "huffman table decode error\n"); goto fail; } break; case SOF0: case SOF1: s->lossless = 0; s->ls = 0; s->progressive = 0; if ((ret = ff_mjpeg_decode_sof(s)) < 0) goto fail; break; case SOF2: s->lossless = 0; s->ls = 0; s->progressive = 1; if ((ret = ff_mjpeg_decode_sof(s)) < 0) goto fail; break; case SOF3: s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS; s->lossless = 1; s->ls = 0; s->progressive = 0; if ((ret = ff_mjpeg_decode_sof(s)) < 0) goto fail; break; case SOF48: s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS; s->lossless = 1; s->ls = 1; s->progressive = 0; if ((ret = ff_mjpeg_decode_sof(s)) < 0) goto fail; break; case LSE: if (!CONFIG_JPEGLS_DECODER || (ret = ff_jpegls_decode_lse(s)) < 0) goto fail; break; case EOI: eoi_parser: s->cur_scan = 0; if (!s->got_picture) { av_log(avctx, AV_LOG_WARNING, "Found EOI before any SOF, ignoring\n"); break; } if (s->interlaced) { s->bottom_field ^= 1; /* if not bottom field, do not output image yet */ if (s->bottom_field == !s->interlace_polarity) break; } if (avctx->skip_frame == AVDISCARD_ALL) { s->got_picture = 0; goto the_end_no_picture; } if ((ret = av_frame_ref(frame, s->picture_ptr)) < 0) return ret; *got_frame = 1; s->got_picture = 0; if (!s->lossless) { int qp = FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]); int qpw = (s->width + 15) / 16; AVBufferRef *qp_table_buf = av_buffer_alloc(qpw); if (qp_table_buf) { memset(qp_table_buf->data, qp, qpw); av_frame_set_qp_table(data, qp_table_buf, 0, FF_QSCALE_TYPE_MPEG1); } if(avctx->debug & FF_DEBUG_QP) av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", qp); } goto the_end; case SOS: s->cur_scan++; if (avctx->skip_frame == AVDISCARD_ALL) break; if ((ret = ff_mjpeg_decode_sos(s, NULL, 0, NULL)) < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) goto fail; break; case DRI: mjpeg_decode_dri(s); break; case SOF5: case SOF6: case SOF7: case SOF9: case SOF10: case SOF11: case SOF13: case SOF14: case SOF15: case JPG: av_log(avctx, AV_LOG_ERROR, "mjpeg: unsupported coding type (%x)\n", start_code); break; } skip: /* eof process start code */ buf_ptr += (get_bits_count(&s->gb) + 7) / 8; av_log(avctx, AV_LOG_DEBUG, "marker parser used %d bytes (%d bits)\n", (get_bits_count(&s->gb) + 7) / 8, get_bits_count(&s->gb)); } if (s->got_picture && s->cur_scan) { av_log(avctx, AV_LOG_WARNING, "EOI missing, emulating\n"); goto eoi_parser; } av_log(avctx, AV_LOG_FATAL, "No JPEG data found in image\n"); return AVERROR_INVALIDDATA; fail: s->got_picture = 0; return ret; the_end: is16bit = av_pix_fmt_desc_get(s->avctx->pix_fmt)->comp[0].step > 1; if (AV_RB32(s->upscale_h)) { int p; av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P || avctx->pix_fmt == AV_PIX_FMT_YUV444P || avctx->pix_fmt == AV_PIX_FMT_YUVJ440P || avctx->pix_fmt == AV_PIX_FMT_YUV440P || avctx->pix_fmt == AV_PIX_FMT_YUVA444P || avctx->pix_fmt == AV_PIX_FMT_YUVJ420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P16|| avctx->pix_fmt == AV_PIX_FMT_YUVA420P || avctx->pix_fmt == AV_PIX_FMT_YUVA420P16|| avctx->pix_fmt == AV_PIX_FMT_GBRP || avctx->pix_fmt == AV_PIX_FMT_GBRAP ); avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift); for (p = 0; p<4; p++) { uint8_t *line = s->picture_ptr->data[p]; int w = s->width; int h = s->height; if (!s->upscale_h[p]) continue; if (p==1 || p==2) { w = AV_CEIL_RSHIFT(w, hshift); h = AV_CEIL_RSHIFT(h, vshift); } if (s->upscale_v[p]) h = (h+1)>>1; av_assert0(w > 0); for (i = 0; i < h; i++) { if (s->upscale_h[p] == 1) { if (is16bit) ((uint16_t*)line)[w - 1] = ((uint16_t*)line)[(w - 1) / 2]; else line[w - 1] = line[(w - 1) / 2]; for (index = w - 2; index > 0; index--) { if (is16bit) ((uint16_t*)line)[index] = (((uint16_t*)line)[index / 2] + ((uint16_t*)line)[(index + 1) / 2]) >> 1; else line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1; } } else if (s->upscale_h[p] == 2) { if (is16bit) { ((uint16_t*)line)[w - 1] = ((uint16_t*)line)[(w - 1) / 3]; if (w > 1) ((uint16_t*)line)[w - 2] = ((uint16_t*)line)[w - 1]; } else { line[w - 1] = line[(w - 1) / 3]; if (w > 1) line[w - 2] = line[w - 1]; } for (index = w - 3; index > 0; index--) { line[index] = (line[index / 3] + line[(index + 1) / 3] + line[(index + 2) / 3] + 1) / 3; } } line += s->linesize[p]; } } } if (AV_RB32(s->upscale_v)) { int p; av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P || avctx->pix_fmt == AV_PIX_FMT_YUV444P || avctx->pix_fmt == AV_PIX_FMT_YUVJ422P || avctx->pix_fmt == AV_PIX_FMT_YUV422P || avctx->pix_fmt == AV_PIX_FMT_YUVJ420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV440P || avctx->pix_fmt == AV_PIX_FMT_YUVJ440P || avctx->pix_fmt == AV_PIX_FMT_YUVA444P || avctx->pix_fmt == AV_PIX_FMT_YUVA420P || avctx->pix_fmt == AV_PIX_FMT_YUVA420P16|| avctx->pix_fmt == AV_PIX_FMT_GBRP || avctx->pix_fmt == AV_PIX_FMT_GBRAP ); avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift); for (p = 0; p < 4; p++) { uint8_t *dst; int w = s->width; int h = s->height; if (!s->upscale_v[p]) continue; if (p==1 || p==2) { w = AV_CEIL_RSHIFT(w, hshift); h = AV_CEIL_RSHIFT(h, vshift); } dst = &((uint8_t *)s->picture_ptr->data[p])[(h - 1) * s->linesize[p]]; for (i = h - 1; i; i--) { uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[p])[i / 2 * s->linesize[p]]; uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[p])[(i + 1) / 2 * s->linesize[p]]; if (src1 == src2 || i == h - 1) { memcpy(dst, src1, w); } else { for (index = 0; index < w; index++) dst[index] = (src1[index] + src2[index]) >> 1; } dst -= s->linesize[p]; } } } if (s->flipped) { int j; avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift); for (index=0; index<4; index++) { uint8_t *dst = s->picture_ptr->data[index]; int w = s->picture_ptr->width; int h = s->picture_ptr->height; if(index && index<3){ w = AV_CEIL_RSHIFT(w, hshift); h = AV_CEIL_RSHIFT(h, vshift); } if(dst){ uint8_t *dst2 = dst + s->picture_ptr->linesize[index]*(h-1); for (i=0; i<h/2; i++) { for (j=0; j<w; j++) FFSWAP(int, dst[j], dst2[j]); dst += s->picture_ptr->linesize[index]; dst2 -= s->picture_ptr->linesize[index]; } } } } if (s->adobe_transform == 0 && s->avctx->pix_fmt == AV_PIX_FMT_GBRAP) { int w = s->picture_ptr->width; int h = s->picture_ptr->height; for (i=0; i<h; i++) { int j; uint8_t *dst[4]; for (index=0; index<4; index++) { dst[index] = s->picture_ptr->data[index] + s->picture_ptr->linesize[index]*i; } for (j=0; j<w; j++) { int k = dst[3][j]; int r = dst[0][j] * k; int g = dst[1][j] * k; int b = dst[2][j] * k; dst[0][j] = g*257 >> 16; dst[1][j] = b*257 >> 16; dst[2][j] = r*257 >> 16; dst[3][j] = 255; } } } if (s->adobe_transform == 2 && s->avctx->pix_fmt == AV_PIX_FMT_YUVA444P) { int w = s->picture_ptr->width; int h = s->picture_ptr->height; for (i=0; i<h; i++) { int j; uint8_t *dst[4]; for (index=0; index<4; index++) { dst[index] = s->picture_ptr->data[index] + s->picture_ptr->linesize[index]*i; } for (j=0; j<w; j++) { int k = dst[3][j]; int r = (255 - dst[0][j]) * k; int g = (128 - dst[1][j]) * k; int b = (128 - dst[2][j]) * k; dst[0][j] = r*257 >> 16; dst[1][j] = (g*257 >> 16) + 128; dst[2][j] = (b*257 >> 16) + 128; dst[3][j] = 255; } } } if (s->stereo3d) { AVStereo3D *stereo = av_stereo3d_create_side_data(data); if (stereo) { stereo->type = s->stereo3d->type; stereo->flags = s->stereo3d->flags; } av_freep(&s->stereo3d); } av_dict_copy(avpriv_frame_get_metadatap(data), s->exif_metadata, 0); av_dict_free(&s->exif_metadata); the_end_no_picture: av_log(avctx, AV_LOG_DEBUG, "decode frame unused %"PTRDIFF_SPECIFIER" bytes\n", buf_end - buf_ptr); // return buf_end - buf_ptr; return buf_ptr - buf; }


static void a15_daughterboard_init(const VexpressMachineState *vms, ram_addr_t ram_size, const char *cpu_model, qemu_irq *pic) { MemoryRegion *sysmem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *sram = g_new(MemoryRegion, 1); if (!cpu_model) { cpu_model = "cortex-a15"; } { /* We have to use a separate 64 bit variable here to avoid the gcc * "comparison is always false due to limited range of data type" * warning if we are on a host where ram_addr_t is 32 bits. */ uint64_t rsz = ram_size; if (rsz > (30ULL * 1024 * 1024 * 1024)) { fprintf(stderr, "vexpress-a15: cannot model more than 30GB RAM\n"); exit(1); } } memory_region_allocate_system_memory(ram, NULL, "vexpress.highmem", ram_size); /* RAM is from 0x80000000 upwards; there is no low-memory alias for it. */ memory_region_add_subregion(sysmem, 0x80000000, ram); /* 0x2c000000 A15MPCore private memory region (GIC) */ init_cpus(cpu_model, "a15mpcore_priv", 0x2c000000, pic, vms->secure); /* A15 daughterboard peripherals: */ /* 0x20000000: CoreSight interfaces: not modelled */ /* 0x2a000000: PL301 AXI interconnect: not modelled */ /* 0x2a420000: SCC: not modelled */ /* 0x2a430000: system counter: not modelled */ /* 0x2b000000: HDLCD controller: not modelled */ /* 0x2b060000: SP805 watchdog: not modelled */ /* 0x2b0a0000: PL341 dynamic memory controller: not modelled */ /* 0x2e000000: system SRAM */ memory_region_init_ram(sram, NULL, "vexpress.a15sram", 0x10000, &error_abort); vmstate_register_ram_global(sram); memory_region_add_subregion(sysmem, 0x2e000000, sram); /* 0x7ffb0000: DMA330 DMA controller: not modelled */ /* 0x7ffd0000: PL354 static memory controller: not modelled */ }


static void dec_sl(DisasContext *dc) { if (dc->format == OP_FMT_RI) { LOG_DIS("sli r%d, r%d, %d\n", dc->r1, dc->r0, dc->imm5); } else { LOG_DIS("sl r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1); } if (!(dc->env->features & LM32_FEATURE_SHIFT)) { cpu_abort(dc->env, "hardware shifter is not available\n"); } if (dc->format == OP_FMT_RI) { tcg_gen_shli_tl(cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5); } else { TCGv t0 = tcg_temp_new(); tcg_gen_andi_tl(t0, cpu_R[dc->r1], 0x1f); tcg_gen_shl_tl(cpu_R[dc->r2], cpu_R[dc->r0], t0); tcg_temp_free(t0); } }


void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint) { qiov->iov = g_malloc(alloc_hint * sizeof(struct iovec)); qiov->niov = 0; qiov->nalloc = alloc_hint; qiov->size = 0; }


static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data; int qps_changed = 0, i, err; #define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field) if (!s1->current_frame.data[0] ||s->width != s1->width ||s->height!= s1->height) { if (s != s1) copy_fields(s, s1, golden_frame, current_frame); return -1; } if (s != s1) { // init tables if the first frame hasn't been decoded if (!s->current_frame.data[0]) { int y_fragment_count, c_fragment_count; s->avctx = dst; err = allocate_tables(dst); if (err) return err; y_fragment_count = s->fragment_width[0] * s->fragment_height[0]; c_fragment_count = s->fragment_width[1] * s->fragment_height[1]; memcpy(s->motion_val[0], s1->motion_val[0], y_fragment_count * sizeof(*s->motion_val[0])); memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1])); } // copy previous frame data copy_fields(s, s1, golden_frame, dsp); // copy qscale data if necessary for (i = 0; i < 3; i++) { if (s->qps[i] != s1->qps[1]) { qps_changed = 1; memcpy(&s->qmat[i], &s1->qmat[i], sizeof(s->qmat[i])); } } if (s->qps[0] != s1->qps[0]) memcpy(&s->bounding_values_array, &s1->bounding_values_array, sizeof(s->bounding_values_array)); if (qps_changed) copy_fields(s, s1, qps, superblock_count); #undef copy_fields } update_frames(dst); return 0; }


static int write_reftable_entry(BlockDriverState *bs, int rt_index) { BDRVQcowState *s = bs->opaque; uint64_t buf[RT_ENTRIES_PER_SECTOR]; int rt_start_index; int i, ret; rt_start_index = rt_index & ~(RT_ENTRIES_PER_SECTOR - 1); for (i = 0; i < RT_ENTRIES_PER_SECTOR; i++) { buf[i] = cpu_to_be64(s->refcount_table[rt_start_index + i]); } ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_TABLE, s->refcount_table_offset + rt_start_index * sizeof(uint64_t), sizeof(buf)); if (ret < 0) { return ret; } BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_UPDATE); ret = bdrv_pwrite_sync(bs->file, s->refcount_table_offset + rt_start_index * sizeof(uint64_t), buf, sizeof(buf)); if (ret < 0) { return ret; } return 0; }


void ff_init_elbg(int *points, int dim, int numpoints, int *codebook, int numCB, int max_steps, int *closest_cb, AVLFG *rand_state) { int i, k; if (numpoints > 24*numCB) { /* ELBG is very costly for a big number of points. So if we have a lot of them, get a good initial codebook to save on iterations */ int *temp_points = av_malloc(dim*(numpoints/8)*sizeof(int)); for (i=0; i<numpoints/8; i++) { k = (i*BIG_PRIME) % numpoints; memcpy(temp_points + i*dim, points + k*dim, dim*sizeof(int)); } ff_init_elbg(temp_points, dim, numpoints/8, codebook, numCB, 2*max_steps, closest_cb, rand_state); ff_do_elbg(temp_points, dim, numpoints/8, codebook, numCB, 2*max_steps, closest_cb, rand_state); av_free(temp_points); } else // If not, initialize the codebook with random positions for (i=0; i < numCB; i++) memcpy(codebook + i*dim, points + ((i*BIG_PRIME)%numpoints)*dim, dim*sizeof(int)); }


av_cold void ff_lpc_init_x86(LPCContext *c) { #if HAVE_SSE2_INLINE int cpu_flags = av_get_cpu_flags(); if (INLINE_SSE2(cpu_flags) && (cpu_flags & AV_CPU_FLAG_SSE2SLOW)) { c->lpc_apply_welch_window = lpc_apply_welch_window_sse2; c->lpc_compute_autocorr = lpc_compute_autocorr_sse2; } #endif /* HAVE_SSE2_INLINE */ }


int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size; size= RAW_SAMPLES*s->streams[0]->codec->block_align; if (size <= 0) return AVERROR(EINVAL); ret= av_get_packet(s->pb, pkt, size); pkt->flags &= ~AV_PKT_FLAG_CORRUPT; pkt->stream_index = 0; if (ret < 0) return ret; return ret; }


static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { MpegEncContext * const s = &h->s; int mba_xy, mbb_xy; int ctx = 0; if(FRAME_MBAFF){ //FIXME merge with the stuff in fill_caches? int mb_xy = mb_x + (mb_y&~1)*s->mb_stride; mba_xy = mb_xy - 1; if( (mb_y&1) && h->slice_table[mba_xy] == h->slice_num && MB_FIELD == !!IS_INTERLACED( s->current_picture.mb_type[mba_xy] ) ) mba_xy += s->mb_stride; if( MB_FIELD ){ mbb_xy = mb_xy - s->mb_stride; if( !(mb_y&1) && h->slice_table[mbb_xy] == h->slice_num && IS_INTERLACED( s->current_picture.mb_type[mbb_xy] ) ) mbb_xy -= s->mb_stride; }else mbb_xy = mb_x + (mb_y-1)*s->mb_stride; }else{ int mb_xy = mb_x + mb_y*s->mb_stride; mba_xy = mb_xy - 1; mbb_xy = mb_xy - s->mb_stride; } if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] )) ctx++; if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] )) ctx++; if( h->slice_type == B_TYPE ) ctx += 13; return get_cabac( &h->cabac, &h->cabac_state[11+ctx] ); }


static int handle_packets(AVFormatContext *s, int nb_packets) { MpegTSContext *ts = s->priv_data; ByteIOContext *pb = &s->pb; uint8_t packet[TS_FEC_PACKET_SIZE]; int packet_num, len; ts->stop_parse = 0; packet_num = 0; for(;;) { if (ts->stop_parse) break; packet_num++; if (nb_packets != 0 && packet_num >= nb_packets) break; len = get_buffer(pb, packet, ts->raw_packet_size); if (len != ts->raw_packet_size) return AVERROR_IO; /* check paquet sync byte */ /* XXX: accept to resync ? */ if (packet[0] != 0x47) return AVERROR_INVALIDDATA; handle_packet(s, packet); } return 0; }


QTestState *qtest_init(const char *extra_args) { QTestState *s; int sock, qmpsock, i; gchar *socket_path; gchar *qmp_socket_path; gchar *command; const char *qemu_binary; struct sigaction sigact; qemu_binary = getenv("QTEST_QEMU_BINARY"); g_assert(qemu_binary != NULL); s = g_malloc(sizeof(*s)); socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid()); qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid()); sock = init_socket(socket_path); qmpsock = init_socket(qmp_socket_path); /* Catch SIGABRT to clean up on g_assert() failure */ sigact = (struct sigaction){ .sa_handler = sigabrt_handler, .sa_flags = SA_RESETHAND, }; sigemptyset(&sigact.sa_mask); sigaction(SIGABRT, &sigact, &s->sigact_old); s->qemu_pid = fork(); if (s->qemu_pid == 0) { command = g_strdup_printf("exec %s " "-qtest unix:%s,nowait " "-qtest-log /dev/null " "-qmp unix:%s,nowait " "-machine accel=qtest " "-display none " "%s", qemu_binary, socket_path, qmp_socket_path, extra_args ?: ""); execlp("/bin/sh", "sh", "-c", command, NULL); exit(1); } s->fd = socket_accept(sock); s->qmp_fd = socket_accept(qmpsock); unlink(socket_path); unlink(qmp_socket_path); g_free(socket_path); g_free(qmp_socket_path); s->rx = g_string_new(""); for (i = 0; i < MAX_IRQ; i++) { s->irq_level[i] = false; } /* Read the QMP greeting and then do the handshake */ qtest_qmp_discard_response(s, ""); qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }"); if (getenv("QTEST_STOP")) { kill(s->qemu_pid, SIGSTOP); } return s; }


static void qxl_init_ramsize(PCIQXLDevice *qxl) { /* vga mode framebuffer / primary surface (bar 0, first part) */ if (qxl->vgamem_size_mb < 8) { qxl->vgamem_size_mb = 8; qxl->vgamem_size = qxl->vgamem_size_mb * 1024 * 1024; /* vga ram (bar 0, total) */ if (qxl->ram_size_mb != -1) { qxl->vga.vram_size = qxl->ram_size_mb * 1024 * 1024; if (qxl->vga.vram_size < qxl->vgamem_size * 2) { qxl->vga.vram_size = qxl->vgamem_size * 2; /* vram32 (surfaces, 32bit, bar 1) */ if (qxl->vram32_size_mb != -1) { qxl->vram32_size = qxl->vram32_size_mb * 1024 * 1024; if (qxl->vram32_size < 4096) { qxl->vram32_size = 4096; /* vram (surfaces, 64bit, bar 4+5) */ if (qxl->vram_size_mb != -1) { qxl->vram_size = qxl->vram_size_mb * 1024 * 1024; if (qxl->vram_size < qxl->vram32_size) { qxl->vram_size = qxl->vram32_size; if (qxl->revision == 1) { qxl->vram32_size = 4096; qxl->vram_size = 4096; qxl->vgamem_size = msb_mask(qxl->vgamem_size * 2 - 1); qxl->vga.vram_size = msb_mask(qxl->vga.vram_size * 2 - 1); qxl->vram32_size = msb_mask(qxl->vram32_size * 2 - 1); qxl->vram_size = msb_mask(qxl->vram_size * 2 - 1);


static int decode_packet(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kResLevel *rlevel, int precno, int layno, uint8_t *expn, int numgbits) { int bandno, cblkny, cblknx, cblkno, ret; if (!(ret = get_bits(s, 1))){ j2k_flush(s); return 0; } else if (ret < 0) return ret; for (bandno = 0; bandno < rlevel->nbands; bandno++){ J2kBand *band = rlevel->band + bandno; J2kPrec *prec = band->prec + precno; int pos = 0; if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1]) continue; for (cblkny = prec->yi0; cblkny < prec->yi1; cblkny++) for(cblknx = prec->xi0, cblkno = cblkny * band->cblknx + cblknx; cblknx < prec->xi1; cblknx++, cblkno++, pos++){ J2kCblk *cblk = band->cblk + cblkno; int incl, newpasses, llen; if (cblk->npasses) incl = get_bits(s, 1); else incl = tag_tree_decode(s, prec->cblkincl + pos, layno+1) == layno; if (!incl) continue; else if (incl < 0) return incl; if (!cblk->npasses) cblk->nonzerobits = expn[bandno] + numgbits - 1 - tag_tree_decode(s, prec->zerobits + pos, 100); if ((newpasses = getnpasses(s)) < 0) return newpasses; if ((llen = getlblockinc(s)) < 0) return llen; cblk->lblock += llen; if ((ret = get_bits(s, av_log2(newpasses) + cblk->lblock)) < 0) return ret; cblk->lengthinc = ret; cblk->npasses += newpasses; } } j2k_flush(s); if (codsty->csty & J2K_CSTY_EPH) { if (AV_RB16(s->buf) == J2K_EPH) { s->buf += 2; } else { av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found.\n"); } } for (bandno = 0; bandno < rlevel->nbands; bandno++){ J2kBand *band = rlevel->band + bandno; int yi, cblknw = band->prec[precno].xi1 - band->prec[precno].xi0; for (yi = band->prec[precno].yi0; yi < band->prec[precno].yi1; yi++){ int xi; for (xi = band->prec[precno].xi0; xi < band->prec[precno].xi1; xi++){ J2kCblk *cblk = band->cblk + yi * cblknw + xi; if (s->buf_end - s->buf < cblk->lengthinc) return AVERROR(EINVAL); bytestream_get_buffer(&s->buf, cblk->data, cblk->lengthinc); cblk->length += cblk->lengthinc; cblk->lengthinc = 0; } } } return 0; }


static SoftFloat sbr_sum_square_c(int (*x)[2], int n) { SoftFloat ret; uint64_t accu = 0, round; int i, nz; unsigned u; for (i = 0; i < n; i += 2) { // Larger values are inavlid and could cause overflows of accu. av_assert2(FFABS(x[i + 0][0]) >> 29 == 0); accu += (int64_t)x[i + 0][0] * x[i + 0][0]; av_assert2(FFABS(x[i + 0][1]) >> 29 == 0); accu += (int64_t)x[i + 0][1] * x[i + 0][1]; av_assert2(FFABS(x[i + 1][0]) >> 29 == 0); accu += (int64_t)x[i + 1][0] * x[i + 1][0]; av_assert2(FFABS(x[i + 1][1]) >> 29 == 0); accu += (int64_t)x[i + 1][1] * x[i + 1][1]; } u = accu >> 32; if (u == 0) { nz = 1; } else { nz = -1; while (u < 0x80000000U) { u <<= 1; nz++; } nz = 32 - nz; } round = 1ULL << (nz-1); u = ((accu + round) >> nz); u >>= 1; ret = av_int2sf(u, 15 - nz); return ret; }


int kvm_log_stop(target_phys_addr_t phys_addr, target_phys_addr_t end_addr) { return kvm_dirty_pages_log_change(phys_addr, end_addr, 0, KVM_MEM_LOG_DIRTY_PAGES); }


int qemu_strtoll(const char *nptr, const char **endptr, int base, int64_t *result) { char *p; int err = 0; if (!nptr) { if (endptr) { *endptr = nptr; } err = -EINVAL; } else { errno = 0; *result = strtoll(nptr, &p, base); err = check_strtox_error(endptr, p, errno); } return err; }


static int sofalizer_convolute(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { SOFAlizerContext *s = ctx->priv; ThreadData *td = arg; AVFrame *in = td->in, *out = td->out; int offset = jobnr; int *write = &td->write[jobnr]; const int *const delay = td->delay[jobnr]; const float *const ir = td->ir[jobnr]; int *n_clippings = &td->n_clippings[jobnr]; float *ringbuffer = td->ringbuffer[jobnr]; float *temp_src = td->temp_src[jobnr]; const int n_samples = s->sofa.n_samples; /* length of one IR */ const float *src = (const float *)in->data[0]; /* get pointer to audio input buffer */ float *dst = (float *)out->data[0]; /* get pointer to audio output buffer */ const int in_channels = s->n_conv; /* number of input channels */ /* ring buffer length is: longest IR plus max. delay -> next power of 2 */ const int buffer_length = s->buffer_length; /* -1 for AND instead of MODULO (applied to powers of 2): */ const uint32_t modulo = (uint32_t)buffer_length - 1; float *buffer[16]; /* holds ringbuffer for each input channel */ int wr = *write; int read; int i, l; dst += offset; for (l = 0; l < in_channels; l++) { /* get starting address of ringbuffer for each input channel */ buffer[l] = ringbuffer + l * buffer_length; } for (i = 0; i < in->nb_samples; i++) { const float *temp_ir = ir; /* using same set of IRs for each sample */ *dst = 0; for (l = 0; l < in_channels; l++) { /* write current input sample to ringbuffer (for each channel) */ *(buffer[l] + wr) = src[l]; } /* loop goes through all channels to be convolved */ for (l = 0; l < in_channels; l++) { const float *const bptr = buffer[l]; if (l == s->lfe_channel) { /* LFE is an input channel but requires no convolution */ /* apply gain to LFE signal and add to output buffer */ *dst += *(buffer[s->lfe_channel] + wr) * s->gain_lfe; temp_ir += n_samples; continue; } /* current read position in ringbuffer: input sample write position * - delay for l-th ch. + diff. betw. IR length and buffer length * (mod buffer length) */ read = (wr - *(delay + l) - (n_samples - 1) + buffer_length) & modulo; if (read + n_samples < buffer_length) { memcpy(temp_src, bptr + read, n_samples * sizeof(*temp_src)); } else { int len = FFMIN(n_samples - (read % n_samples), buffer_length - read); memcpy(temp_src, bptr + read, len * sizeof(*temp_src)); memcpy(temp_src + len, bptr, (n_samples - len) * sizeof(*temp_src)); } /* multiply signal and IR, and add up the results */ dst[0] += s->fdsp->scalarproduct_float(temp_ir, temp_src, n_samples); temp_ir += n_samples; } /* clippings counter */ if (fabs(*dst) > 1) *n_clippings += 1; /* move output buffer pointer by +2 to get to next sample of processed channel: */ dst += 2; src += in_channels; wr = (wr + 1) & modulo; /* update ringbuffer write position */ } *write = wr; /* remember write position in ringbuffer for next call */ return 0; }


int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in) { char *param, buffer[128], tmp[128]; int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0; SrtStack stack[16]; int closing_brace_missing = 0; stack[0].tag[0] = 0; strcpy(stack[0].param[PARAM_SIZE], "{\\fs}"); strcpy(stack[0].param[PARAM_COLOR], "{\\c}"); strcpy(stack[0].param[PARAM_FACE], "{\\fn}"); for (; !end && *in; in++) { switch (*in) { case '\r': break; case '\n': if (line_start) { end = 1; break; } rstrip_spaces_buf(dst); av_bprintf(dst, "\\N"); line_start = 1; break; case ' ': if (!line_start) av_bprint_chars(dst, *in, 1); break; case '{': handle_open_brace(dst, &in, &an, &closing_brace_missing); break; case '<': tag_close = in[1] == '/'; len = 0; if (sscanf(in+tag_close+1, "%127[^>]>%n", buffer, &len) >= 1 && len > 0) { const char *tagname = buffer; while (*tagname == ' ') tagname++; if ((param = strchr(tagname, ' '))) *param++ = 0; if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) || ( tag_close && sptr > 0 && !av_strcasecmp(stack[sptr-1].tag, tagname))) { int i, j, unknown = 0; in += len + tag_close; if (!tag_close) memset(stack+sptr, 0, sizeof(*stack)); if (!av_strcasecmp(tagname, "font")) { if (tag_close) { for (i=PARAM_NUMBER-1; i>=0; i--) if (stack[sptr-1].param[i][0]) for (j=sptr-2; j>=0; j--) if (stack[j].param[i][0]) { av_bprintf(dst, "%s", stack[j].param[i]); break; } } else { while (param) { if (!av_strncasecmp(param, "size=", 5)) { unsigned font_size; param += 5 + (param[5] == '"'); if (sscanf(param, "%u", &font_size) == 1) { snprintf(stack[sptr].param[PARAM_SIZE], sizeof(stack[0].param[PARAM_SIZE]), "{\\fs%u}", font_size); } } else if (!av_strncasecmp(param, "color=", 6)) { param += 6 + (param[6] == '"'); snprintf(stack[sptr].param[PARAM_COLOR], sizeof(stack[0].param[PARAM_COLOR]), "{\\c&H%X&}", html_color_parse(log_ctx, param)); } else if (!av_strncasecmp(param, "face=", 5)) { param += 5 + (param[5] == '"'); len = strcspn(param, param[-1] == '"' ? "\"" :" "); av_strlcpy(tmp, param, FFMIN(sizeof(tmp), len+1)); param += len; snprintf(stack[sptr].param[PARAM_FACE], sizeof(stack[0].param[PARAM_FACE]), "{\\fn%s}", tmp); } if ((param = strchr(param, ' '))) param++; } for (i=0; i<PARAM_NUMBER; i++) if (stack[sptr].param[i][0]) av_bprintf(dst, "%s", stack[sptr].param[i]); } } else if (tagname[0] && !tagname[1] && av_stristr("bisu", tagname)) { av_bprintf(dst, "{\\%c%d}", (char)av_tolower(tagname[0]), !tag_close); } else if (!av_strcasecmp(tagname, "br")) { av_bprintf(dst, "\\N"); } else { unknown = 1; snprintf(tmp, sizeof(tmp), "</%s>", tagname); } if (tag_close) { sptr--; } else if (unknown && !strstr(in, tmp)) { in -= len + tag_close; av_bprint_chars(dst, *in, 1); } else av_strlcpy(stack[sptr++].tag, tagname, sizeof(stack[0].tag)); break; } } default: av_bprint_chars(dst, *in, 1); break; } if (*in != ' ' && *in != '\r' && *in != '\n') line_start = 0; } if (!av_bprint_is_complete(dst)) return AVERROR(ENOMEM); while (dst->len >= 2 && !strncmp(&dst->str[dst->len - 2], "\\N", 2)) dst->len -= 2; dst->str[dst->len] = 0; rstrip_spaces_buf(dst); return 0; }


void qemu_mutex_destroy(QemuMutex *mutex) { assert(mutex->owner == 0); DeleteCriticalSection(&mutex->lock); }


static int usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in) { AsyncURB *aurb; int i, j, ret, max_packet_size, offset, len = 0; max_packet_size = get_max_packet_size(s, p->devep); if (max_packet_size == 0) return USB_RET_NAK; aurb = get_iso_urb(s, p->devep); if (!aurb) { aurb = usb_host_alloc_iso(s, p->devep, in); } i = get_iso_urb_idx(s, p->devep); j = aurb[i].iso_frame_idx; if (j >= 0 && j < ISO_FRAME_DESC_PER_URB) { if (in) { /* Check urb status */ if (aurb[i].urb.status) { len = urb_status_to_usb_ret(aurb[i].urb.status); /* Move to the next urb */ aurb[i].iso_frame_idx = ISO_FRAME_DESC_PER_URB - 1; /* Check frame status */ } else if (aurb[i].urb.iso_frame_desc[j].status) { len = urb_status_to_usb_ret( aurb[i].urb.iso_frame_desc[j].status); /* Check the frame fits */ } else if (aurb[i].urb.iso_frame_desc[j].actual_length > p->len) { printf("husb: received iso data is larger then packet\n"); len = USB_RET_NAK; /* All good copy data over */ } else { len = aurb[i].urb.iso_frame_desc[j].actual_length; memcpy(p->data, aurb[i].urb.buffer + j * aurb[i].urb.iso_frame_desc[0].length, len); } } else { len = p->len; offset = (j == 0) ? 0 : get_iso_buffer_used(s, p->devep); /* Check the frame fits */ if (len > max_packet_size) { printf("husb: send iso data is larger then max packet size\n"); return USB_RET_NAK; } /* All good copy data over */ memcpy(aurb[i].urb.buffer + offset, p->data, len); aurb[i].urb.iso_frame_desc[j].length = len; offset += len; set_iso_buffer_used(s, p->devep, offset); /* Start the stream once we have buffered enough data */ if (!is_iso_started(s, p->devep) && i == 1 && j == 8) { set_iso_started(s, p->devep); } } aurb[i].iso_frame_idx++; if (aurb[i].iso_frame_idx == ISO_FRAME_DESC_PER_URB) { i = (i + 1) % s->iso_urb_count; set_iso_urb_idx(s, p->devep, i); } } else { if (in) { set_iso_started(s, p->devep); } else { DPRINTF("hubs: iso out error no free buffer, dropping packet\n"); } } if (is_iso_started(s, p->devep)) { /* (Re)-submit all fully consumed / filled urbs */ for (i = 0; i < s->iso_urb_count; i++) { if (aurb[i].iso_frame_idx == ISO_FRAME_DESC_PER_URB) { ret = ioctl(s->fd, USBDEVFS_SUBMITURB, &aurb[i]); if (ret < 0) { printf("husb error submitting iso urb %d: %d\n", i, errno); if (!in || len == 0) { switch(errno) { case ETIMEDOUT: len = USB_RET_NAK; break; case EPIPE: default: len = USB_RET_STALL; } } break; } aurb[i].iso_frame_idx = -1; change_iso_inflight(s, p->devep, +1); } } } return len; }


static void pcie_pci_bridge_realize(PCIDevice *d, Error **errp) { PCIBridge *br = PCI_BRIDGE(d); PCIEPCIBridge *pcie_br = PCIE_PCI_BRIDGE_DEV(d); int rc, pos; pci_bridge_initfn(d, TYPE_PCI_BUS); d->config[PCI_INTERRUPT_PIN] = 0x1; memory_region_init(&pcie_br->shpc_bar, OBJECT(d), "shpc-bar", shpc_bar_size(d)); rc = shpc_init(d, &br->sec_bus, &pcie_br->shpc_bar, 0, errp); if (rc) { goto error; } rc = pcie_cap_init(d, 0, PCI_EXP_TYPE_PCI_BRIDGE, 0, errp); if (rc < 0) { goto cap_error; } pos = pci_add_capability(d, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF, errp); if (pos < 0) { goto pm_error; } d->exp.pm_cap = pos; pci_set_word(d->config + pos + PCI_PM_PMC, 0x3); pcie_cap_arifwd_init(d); pcie_cap_deverr_init(d); rc = pcie_aer_init(d, PCI_ERR_VER, 0x100, PCI_ERR_SIZEOF, errp); if (rc < 0) { goto aer_error; } if (pcie_br->msi != ON_OFF_AUTO_OFF) { rc = msi_init(d, 0, 1, true, true, errp); if (rc < 0) { goto msi_error; } } pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, &pcie_br->shpc_bar); return; msi_error: pcie_aer_exit(d); aer_error: pm_error: pcie_cap_exit(d); cap_error: shpc_free(d); error: pci_bridge_exitfn(d); }


static int qcrypto_cipher_init_aes(QCryptoCipher *cipher, const uint8_t *key, size_t nkey, Error **errp) { QCryptoCipherBuiltin *ctxt; if (cipher->mode != QCRYPTO_CIPHER_MODE_CBC && cipher->mode != QCRYPTO_CIPHER_MODE_ECB) { error_setg(errp, "Unsupported cipher mode %d", cipher->mode); return -1; } ctxt = g_new0(QCryptoCipherBuiltin, 1); if (AES_set_encrypt_key(key, nkey * 8, &ctxt->state.aes.encrypt_key) != 0) { error_setg(errp, "Failed to set encryption key"); goto error; } if (AES_set_decrypt_key(key, nkey * 8, &ctxt->state.aes.decrypt_key) != 0) { error_setg(errp, "Failed to set decryption key"); goto error; } ctxt->free = qcrypto_cipher_free_aes; ctxt->setiv = qcrypto_cipher_setiv_aes; ctxt->encrypt = qcrypto_cipher_encrypt_aes; ctxt->decrypt = qcrypto_cipher_decrypt_aes; cipher->opaque = ctxt; return 0; error: g_free(ctxt); return -1; }


static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid) { MXFContext *mxf = arg; MXFPartition *partition; UID op; uint64_t footer_partition; if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions)) return AVERROR(ENOMEM); mxf->partitions = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions)); if (!mxf->partitions) return AVERROR(ENOMEM); if (mxf->parsing_backward) { /* insert the new partition pack in the middle * this makes the entries in mxf->partitions sorted by offset */ memmove(&mxf->partitions[mxf->last_forward_partition+1], &mxf->partitions[mxf->last_forward_partition], (mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions)); partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition]; } else { mxf->last_forward_partition++; partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count]; } memset(partition, 0, sizeof(*partition)); mxf->partitions_count++; switch(uid[13]) { case 2: partition->type = Header; break; case 3: partition->type = BodyPartition; break; case 4: partition->type = Footer; break; default: av_log(mxf->fc, AV_LOG_ERROR, "unknown partition type %i\n", uid[13]); return AVERROR_INVALIDDATA; } /* consider both footers to be closed (there is only Footer and CompleteFooter) */ partition->closed = partition->type == Footer || !(uid[14] & 1); partition->complete = uid[14] > 2; avio_skip(pb, 8); partition->this_partition = avio_rb64(pb); partition->previous_partition = avio_rb64(pb); footer_partition = avio_rb64(pb); avio_skip(pb, 16); partition->index_sid = avio_rb32(pb); avio_skip(pb, 8); partition->body_sid = avio_rb32(pb); avio_read(pb, op, sizeof(UID)); /* some files don'thave FooterPartition set in every partition */ if (footer_partition) { if (mxf->footer_partition && mxf->footer_partition != footer_partition) { av_log(mxf->fc, AV_LOG_ERROR, "inconsistent FooterPartition value: %li != %li\n", mxf->footer_partition, footer_partition); } else { mxf->footer_partition = footer_partition; } } av_dlog(mxf->fc, "PartitionPack: ThisPartition = 0x%lx, PreviousPartition = 0x%lx, " "FooterPartition = 0x%lx, IndexSID = %i, BodySID = %i\n", partition->this_partition, partition->previous_partition, footer_partition, partition->index_sid, partition->body_sid); if (op[12] == 1 && op[13] == 1) mxf->op = OP1a; else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b; else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c; else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a; else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b; else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c; else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a; else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b; else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c; else if (op[12] == 0x10) mxf->op = OPAtom; else av_log(mxf->fc, AV_LOG_ERROR, "unknown operational pattern: %02xh %02xh\n", op[12], op[13]); return 0; }


static uint64_t getSSD(uint8_t *src1, uint8_t *src2, int stride1, int stride2, int w, int h){ int x,y; uint64_t ssd=0; //printf("%d %d\n", w, h); for(y=0; y<h; y++){ for(x=0; x<w; x++){ int d= src1[x + y*stride1] - src2[x + y*stride2]; ssd+= d*d; //printf("%d", abs(src1[x + y*stride1] - src2[x + y*stride2])/26 ); } //printf("\n"); } return ssd; }


static inline void test_server_connect(TestServer *server) { test_server_create_chr(server, ",reconnect=1"); }


static int put_system_header(AVFormatContext *ctx, uint8_t *buf,int only_for_stream_id) { MpegMuxContext *s = ctx->priv_data; int size, i, private_stream_coded, id; PutBitContext pb; init_put_bits(&pb, buf, 128); put_bits(&pb, 32, SYSTEM_HEADER_START_CODE); put_bits(&pb, 16, 0); put_bits(&pb, 1, 1); put_bits(&pb, 22, s->mux_rate); /* maximum bit rate of the multiplexed stream */ put_bits(&pb, 1, 1); /* marker */ if (s->is_vcd && only_for_stream_id==VIDEO_ID) { /* This header applies only to the video stream (see VCD standard p. IV-7)*/ put_bits(&pb, 6, 0); } else put_bits(&pb, 6, s->audio_bound); if (s->is_vcd) { /* see VCD standard, p. IV-7*/ put_bits(&pb, 1, 0); put_bits(&pb, 1, 1); } else { put_bits(&pb, 1, 0); /* variable bitrate*/ put_bits(&pb, 1, 0); /* non constrainted bit stream */ } if (s->is_vcd || s->is_dvd) { /* see VCD standard p IV-7 */ put_bits(&pb, 1, 1); /* audio locked */ put_bits(&pb, 1, 1); /* video locked */ } else { put_bits(&pb, 1, 0); /* audio locked */ put_bits(&pb, 1, 0); /* video locked */ } put_bits(&pb, 1, 1); /* marker */ if (s->is_vcd && only_for_stream_id==AUDIO_ID) { /* This header applies only to the audio stream (see VCD standard p. IV-7)*/ put_bits(&pb, 5, 0); } else put_bits(&pb, 5, s->video_bound); if (s->is_dvd) { put_bits(&pb, 1, 0); /* packet_rate_restriction_flag */ put_bits(&pb, 7, 0x7f); /* reserved byte */ } else put_bits(&pb, 8, 0xff); /* reserved byte */ /* DVD-Video Stream_bound entries id (0xB9) video, maximum P-STD for stream 0xE0. (P-STD_buffer_bound_scale = 1) id (0xB8) audio, maximum P-STD for any MPEG audio (0xC0 to 0xC7) streams. If there are none set to 4096 (32x128). (P-STD_buffer_bound_scale = 0) id (0xBD) private stream 1 (audio other than MPEG and subpictures). (P-STD_buffer_bound_scale = 1) id (0xBF) private stream 2, NAV packs, set to 2x1024. */ if (s->is_dvd) { int P_STD_max_video = 0; int P_STD_max_mpeg_audio = 0; int P_STD_max_mpeg_PS1 = 0; for(i=0;i<ctx->nb_streams;i++) { StreamInfo *stream = ctx->streams[i]->priv_data; id = stream->id; if (id == 0xbd && stream->max_buffer_size > P_STD_max_mpeg_PS1) { P_STD_max_mpeg_PS1 = stream->max_buffer_size; } else if (id >= 0xc0 && id <= 0xc7 && stream->max_buffer_size > P_STD_max_mpeg_audio) { P_STD_max_mpeg_audio = stream->max_buffer_size; } else if (id == 0xe0 && stream->max_buffer_size > P_STD_max_video) { P_STD_max_video = stream->max_buffer_size; } } /* video */ put_bits(&pb, 8, 0xb9); /* stream ID */ put_bits(&pb, 2, 3); put_bits(&pb, 1, 1); put_bits(&pb, 13, P_STD_max_video / 1024); /* audio */ if (P_STD_max_mpeg_audio == 0) P_STD_max_mpeg_audio = 4096; put_bits(&pb, 8, 0xb8); /* stream ID */ put_bits(&pb, 2, 3); put_bits(&pb, 1, 0); put_bits(&pb, 13, P_STD_max_mpeg_audio / 128); /* private stream 1 */ put_bits(&pb, 8, 0xbd); /* stream ID */ put_bits(&pb, 2, 3); put_bits(&pb, 1, 0); put_bits(&pb, 13, P_STD_max_mpeg_PS1 / 128); /* private stream 2 */ put_bits(&pb, 8, 0xbf); /* stream ID */ put_bits(&pb, 2, 3); put_bits(&pb, 1, 1); put_bits(&pb, 13, 2); } else { /* audio stream info */ private_stream_coded = 0; for(i=0;i<ctx->nb_streams;i++) { StreamInfo *stream = ctx->streams[i]->priv_data; /* For VCDs, only include the stream info for the stream that the pack which contains this system belongs to. (see VCD standard p. IV-7) */ if ( !s->is_vcd || stream->id==only_for_stream_id || only_for_stream_id==0) { id = stream->id; if (id < 0xc0) { /* special case for private streams (AC-3 uses that) */ if (private_stream_coded) continue; private_stream_coded = 1; id = 0xbd; } put_bits(&pb, 8, id); /* stream ID */ put_bits(&pb, 2, 3); if (id < 0xe0) { /* audio */ put_bits(&pb, 1, 0); put_bits(&pb, 13, stream->max_buffer_size / 128); } else { /* video */ put_bits(&pb, 1, 1); put_bits(&pb, 13, stream->max_buffer_size / 1024); } } } } flush_put_bits(&pb); size = put_bits_ptr(&pb) - pb.buf; /* patch packet size */ buf[4] = (size - 6) >> 8; buf[5] = (size - 6) & 0xff; return size; }


static int standard_decode_i_mbs(VC9Context *v) { int x, y, ac_pred, cbpcy; /* Select ttmb table depending on pq */ if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0]; else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1]; else v->ttmb_vlc = &vc9_ttmb_vlc[2]; for (y=0; y<v->height_mb; y++) { for (x=0; x<v->width_mb; x++) { cbpcy = get_vlc2(&v->gb, vc9_cbpcy_i_vlc.table, VC9_CBPCY_I_VLC_BITS, 2); ac_pred = get_bits(&v->gb, 1); //Decode blocks from that mb wrt cbpcy } } return 0; }


static void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride) { int dc = (block[0] + 32) >> 6; int y; __asm__ volatile( "movd %0, %%mm0 \n\t" "pshufw $0, %%mm0, %%mm0 \n\t" "pxor %%mm1, %%mm1 \n\t" "psubw %%mm0, %%mm1 \n\t" "packuswb %%mm0, %%mm0 \n\t" "packuswb %%mm1, %%mm1 \n\t" ::"r"(dc) ); for(y=2; y--; dst += 4*stride){ __asm__ volatile( "movq %0, %%mm2 \n\t" "movq %1, %%mm3 \n\t" "movq %2, %%mm4 \n\t" "movq %3, %%mm5 \n\t" "paddusb %%mm0, %%mm2 \n\t" "paddusb %%mm0, %%mm3 \n\t" "paddusb %%mm0, %%mm4 \n\t" "paddusb %%mm0, %%mm5 \n\t" "psubusb %%mm1, %%mm2 \n\t" "psubusb %%mm1, %%mm3 \n\t" "psubusb %%mm1, %%mm4 \n\t" "psubusb %%mm1, %%mm5 \n\t" "movq %%mm2, %0 \n\t" "movq %%mm3, %1 \n\t" "movq %%mm4, %2 \n\t" "movq %%mm5, %3 \n\t" :"+m"(*(uint64_t*)(dst+0*stride)), "+m"(*(uint64_t*)(dst+1*stride)), "+m"(*(uint64_t*)(dst+2*stride)), "+m"(*(uint64_t*)(dst+3*stride)) ); } }


static int movie_get_frame(AVFilterLink *outlink) { MovieContext *movie = outlink->src->priv; AVPacket pkt; int ret, frame_decoded; AVStream *st = movie->format_ctx->streams[movie->stream_index]; if (movie->is_done == 1) return 0; while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) { // Is this a packet from the video stream? if (pkt.stream_index == movie->stream_index) { avcodec_decode_video2(movie->codec_ctx, movie->frame, &frame_decoded, &pkt); if (frame_decoded) { /* FIXME: avoid the memcpy */ movie->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE | AV_PERM_PRESERVE | AV_PERM_REUSE2, outlink->w, outlink->h); av_image_copy(movie->picref->data, movie->picref->linesize, (void*)movie->frame->data, movie->frame->linesize, movie->picref->format, outlink->w, outlink->h); avfilter_copy_frame_props(movie->picref, movie->frame); /* FIXME: use a PTS correction mechanism as that in * ffplay.c when some API will be available for that */ /* use pkt_dts if pkt_pts is not available */ movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ? movie->frame->pkt_dts : movie->frame->pkt_pts; if (!movie->frame->sample_aspect_ratio.num) movie->picref->video->sample_aspect_ratio = st->sample_aspect_ratio; av_dlog(outlink->src, "movie_get_frame(): file:'%s' pts:%"PRId64" time:%lf pos:%"PRId64" aspect:%d/%d\n", movie->file_name, movie->picref->pts, (double)movie->picref->pts * av_q2d(st->time_base), movie->picref->pos, movie->picref->video->sample_aspect_ratio.num, movie->picref->video->sample_aspect_ratio.den); // We got it. Free the packet since we are returning av_free_packet(&pkt); return 0; } } // Free the packet that was allocated by av_read_frame av_free_packet(&pkt); } // On multi-frame source we should stop the mixing process when // the movie source does not have more frames if (ret == AVERROR_EOF) movie->is_done = 1; return ret; }


static void do_io_interrupt(CPUS390XState *env) { S390CPU *cpu = s390_env_get_cpu(env); LowCore *lowcore; IOIntQueue *q; uint8_t isc; int disable = 1; int found = 0; if (!(env->psw.mask & PSW_MASK_IO)) { cpu_abort(CPU(cpu), "I/O int w/o I/O mask\n"); } for (isc = 0; isc < ARRAY_SIZE(env->io_index); isc++) { uint64_t isc_bits; if (env->io_index[isc] < 0) { continue; } if (env->io_index[isc] > MAX_IO_QUEUE) { cpu_abort(CPU(cpu), "I/O queue overrun for isc %d: %d\n", isc, env->io_index[isc]); } q = &env->io_queue[env->io_index[isc]][isc]; isc_bits = ISC_TO_ISC_BITS(IO_INT_WORD_ISC(q->word)); if (!(env->cregs[6] & isc_bits)) { disable = 0; continue; } if (!found) { uint64_t mask, addr; found = 1; lowcore = cpu_map_lowcore(env); lowcore->subchannel_id = cpu_to_be16(q->id); lowcore->subchannel_nr = cpu_to_be16(q->nr); lowcore->io_int_parm = cpu_to_be32(q->parm); lowcore->io_int_word = cpu_to_be32(q->word); lowcore->io_old_psw.mask = cpu_to_be64(get_psw_mask(env)); lowcore->io_old_psw.addr = cpu_to_be64(env->psw.addr); mask = be64_to_cpu(lowcore->io_new_psw.mask); addr = be64_to_cpu(lowcore->io_new_psw.addr); cpu_unmap_lowcore(lowcore); env->io_index[isc]--; DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__, env->psw.mask, env->psw.addr); load_psw(env, mask, addr); } if (env->io_index[isc] >= 0) { disable = 0; } continue; } if (disable) { env->pending_int &= ~INTERRUPT_IO; } }


static int rtp_new_av_stream(HTTPContext *c, int stream_index, struct sockaddr_in *dest_addr, HTTPContext *rtsp_c) { AVFormatContext *ctx; AVStream *st; char *ipaddr; URLContext *h = NULL; uint8_t *dummy_buf; int max_packet_size; /* now we can open the relevant output stream */ ctx = avformat_alloc_context(); if (!ctx) return -1; ctx->oformat = av_guess_format("rtp", NULL, NULL); st = av_mallocz(sizeof(AVStream)); if (!st) goto fail; st->codec= avcodec_alloc_context(); ctx->nb_streams = 1; ctx->streams[0] = st; if (!c->stream->feed || c->stream->feed == c->stream) memcpy(st, c->stream->streams[stream_index], sizeof(AVStream)); else memcpy(st, c->stream->feed->streams[c->stream->feed_streams[stream_index]], sizeof(AVStream)); st->priv_data = NULL; /* build destination RTP address */ ipaddr = inet_ntoa(dest_addr->sin_addr); switch(c->rtp_protocol) { case RTSP_LOWER_TRANSPORT_UDP: case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: /* RTP/UDP case */ /* XXX: also pass as parameter to function ? */ if (c->stream->is_multicast) { int ttl; ttl = c->stream->multicast_ttl; if (!ttl) ttl = 16; snprintf(ctx->filename, sizeof(ctx->filename), "rtp://%s:%d?multicast=1&ttl=%d", ipaddr, ntohs(dest_addr->sin_port), ttl); } else { snprintf(ctx->filename, sizeof(ctx->filename), "rtp://%s:%d", ipaddr, ntohs(dest_addr->sin_port)); } if (url_open(&h, ctx->filename, URL_WRONLY) < 0) goto fail; c->rtp_handles[stream_index] = h; max_packet_size = url_get_max_packet_size(h); break; case RTSP_LOWER_TRANSPORT_TCP: /* RTP/TCP case */ c->rtsp_c = rtsp_c; max_packet_size = RTSP_TCP_MAX_PACKET_SIZE; break; default: goto fail; } http_log("%s:%d - - \"PLAY %s/streamid=%d %s\"\n", ipaddr, ntohs(dest_addr->sin_port), c->stream->filename, stream_index, c->protocol); /* normally, no packets should be output here, but the packet size may be checked */ if (url_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) { /* XXX: close stream */ goto fail; } av_set_parameters(ctx, NULL); if (av_write_header(ctx) < 0) { fail: if (h) url_close(h); av_free(ctx); return -1; } url_close_dyn_buf(ctx->pb, &dummy_buf); av_free(dummy_buf); c->rtp_ctx[stream_index] = ctx; return 0; }


void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp) { unix_nonblocking_connect(path, unix_wait_for_connect, s, errp); }


static void *mptsas_load_request(QEMUFile *f, SCSIRequest *sreq) { SCSIBus *bus = sreq->bus; MPTSASState *s = container_of(bus, MPTSASState, bus); PCIDevice *pci = PCI_DEVICE(s); MPTSASRequest *req; int i, n; req = g_new(MPTSASRequest, 1); qemu_get_buffer(f, (unsigned char *)&req->scsi_io, sizeof(req->scsi_io)); n = qemu_get_be32(f); /* TODO: add a way for SCSIBusInfo's load_request to fail, * and fail migration instead of asserting here. * When we do, we might be able to re-enable NDEBUG below. */ #ifdef NDEBUG #error building with NDEBUG is not supported #endif assert(n >= 0); pci_dma_sglist_init(&req->qsg, pci, n); for (i = 0; i < n; i++) { uint64_t base = qemu_get_be64(f); uint64_t len = qemu_get_be64(f); qemu_sglist_add(&req->qsg, base, len); } scsi_req_ref(sreq); req->sreq = sreq; req->dev = s; return req; }