project
stringclasses
2 values
commit_id
stringlengths
40
40
target
int64
0
1
func
stringlengths
26
142k
idx
int64
0
27.3k
qemu
f0c9d64a68b776374ec4732424a3e27753ce37b6
1
void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, PCIBus *root_bus, MemoryRegion *address_space_io, bool bridges_enabled) { s->io_len = ACPI_PCIHP_SIZE; s->io_base = ACPI_PCIHP_ADDR; s->root= root_bus; s->legacy_piix = !bridges_enabled; if (s->legacy_piix) { unsigned *bus_bsel = g_malloc(sizeof *bus_bsel); s->io_len = ACPI_PCIHP_LEGACY_SIZE; *bus_bsel = ACPI_PCIHP_BSEL_DEFAULT; object_property_add_uint32_ptr(OBJECT(root_bus), ACPI_PCIHP_PROP_BSEL, bus_bsel, NULL); } memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s, "acpi-pci-hotplug", s->io_len); memory_region_add_subregion(address_space_io, s->io_base, &s->io); object_property_add_uint16_ptr(owner, ACPI_PCIHP_IO_BASE_PROP, &s->io_base, &error_abort); object_property_add_uint16_ptr(owner, ACPI_PCIHP_IO_LEN_PROP, &s->io_len, &error_abort); }
13,336
FFmpeg
1ee8fadb811f3b1ef370c7d6c7bf62088f1cc954
1
paint_mouse_pointer(XImage *image, struct x11grab *s) { int x_off = s->x_off; int y_off = s->y_off; int width = s->width; int height = s->height; Display *dpy = s->dpy; XFixesCursorImage *xcim; int x, y; int line, column; int to_line, to_column; int pixstride = image->bits_per_pixel >> 3; /* Warning: in its insanity, xlib provides unsigned image data through a * char* pointer, so we have to make it uint8_t to make things not break. * Anyone who performs further investigation of the xlib API likely risks * permanent brain damage. */ uint8_t *pix = image->data; Cursor c; Window w; XSetWindowAttributes attr; /* Code doesn't currently support 16-bit or PAL8 */ if (image->bits_per_pixel != 24 && image->bits_per_pixel != 32) return; c = XCreateFontCursor(dpy, XC_left_ptr); w = DefaultRootWindow(dpy); attr.cursor = c; XChangeWindowAttributes(dpy, w, CWCursor, &attr); xcim = XFixesGetCursorImage(dpy); x = xcim->x - xcim->xhot; y = xcim->y - xcim->yhot; to_line = FFMIN((y + xcim->height), (height + y_off)); to_column = FFMIN((x + xcim->width), (width + x_off)); for (line = FFMAX(y, y_off); line < to_line; line++) { for (column = FFMAX(x, x_off); column < to_column; column++) { int xcim_addr = (line - y) * xcim->width + column - x; int image_addr = ((line - y_off) * width + column - x_off) * pixstride; int r = (uint8_t)(xcim->pixels[xcim_addr] >> 0); int g = (uint8_t)(xcim->pixels[xcim_addr] >> 8); int b = (uint8_t)(xcim->pixels[xcim_addr] >> 16); int a = (uint8_t)(xcim->pixels[xcim_addr] >> 24); if (a == 255) { pix[image_addr+0] = r; pix[image_addr+1] = g; pix[image_addr+2] = b; } else if (a) { /* pixel values from XFixesGetCursorImage come premultiplied by alpha */ pix[image_addr+0] = r + (pix[image_addr+0]*(255-a) + 255/2) / 255; pix[image_addr+1] = g + (pix[image_addr+1]*(255-a) + 255/2) / 255; pix[image_addr+2] = b + (pix[image_addr+2]*(255-a) + 255/2) / 255; } } } XFree(xcim); xcim = NULL; }
13,338
qemu
d470ad42acfc73c45d3e8ed5311a491160b4c100
1
int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { BdrvTrackedRequest req; int max_pdiscard, ret; int head, tail, align; return -ENOMEDIUM; if (bdrv_has_readonly_bitmaps(bs)) { return -EPERM; ret = bdrv_check_byte_request(bs, offset, bytes); if (ret < 0) { return ret; } else if (bs->read_only) { return -EPERM; assert(!(bs->open_flags & BDRV_O_INACTIVE)); /* Do nothing if disabled. */ if (!(bs->open_flags & BDRV_O_UNMAP)) { return 0; if (!bs->drv->bdrv_co_pdiscard && !bs->drv->bdrv_aio_pdiscard) { return 0; /* Discard is advisory, but some devices track and coalesce * unaligned requests, so we must pass everything down rather than * round here. Still, most devices will just silently ignore * unaligned requests (by returning -ENOTSUP), so we must fragment * the request accordingly. */ align = MAX(bs->bl.pdiscard_alignment, bs->bl.request_alignment); assert(align % bs->bl.request_alignment == 0); head = offset % align; tail = (offset + bytes) % align; bdrv_inc_in_flight(bs); tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_DISCARD); ret = notifier_with_return_list_notify(&bs->before_write_notifiers, &req); if (ret < 0) { max_pdiscard = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscard, INT_MAX), align); assert(max_pdiscard >= bs->bl.request_alignment); while (bytes > 0) { int num = bytes; if (head) { /* Make small requests to get to alignment boundaries. */ num = MIN(bytes, align - head); if (!QEMU_IS_ALIGNED(num, bs->bl.request_alignment)) { num %= bs->bl.request_alignment; head = (head + num) % align; assert(num < max_pdiscard); } else if (tail) { if (num > align) { /* Shorten the request to the last aligned cluster. */ num -= tail; } else if (!QEMU_IS_ALIGNED(tail, bs->bl.request_alignment) && tail > bs->bl.request_alignment) { tail %= bs->bl.request_alignment; num -= tail; /* limit request size */ if (num > max_pdiscard) { num = max_pdiscard; if (bs->drv->bdrv_co_pdiscard) { ret = bs->drv->bdrv_co_pdiscard(bs, offset, num); } else { BlockAIOCB *acb; CoroutineIOCompletion co = { .coroutine = qemu_coroutine_self(), }; acb = bs->drv->bdrv_aio_pdiscard(bs, offset, num, bdrv_co_io_em_complete, &co); if (acb == NULL) { ret = -EIO; } else { qemu_coroutine_yield(); ret = co.ret; if (ret && ret != -ENOTSUP) { offset += num; bytes -= num; ret = 0; out: atomic_inc(&bs->write_gen); bdrv_set_dirty(bs, req.offset, req.bytes); tracked_request_end(&req); bdrv_dec_in_flight(bs); return ret;
13,340
FFmpeg
31fe3c4d23aab8b43614b1ea825603080775677e
1
int ff_mediacodec_dec_close(AVCodecContext *avctx, MediaCodecDecContext *s) { if (s->codec) { ff_AMediaCodec_delete(s->codec); s->codec = NULL; } if (s->format) { ff_AMediaFormat_delete(s->format); s->format = NULL; } return 0; }
13,341
qemu
66a08cbe6ad1aebec8eecf58b3ba042e19dd1649
1
static void uhci_async_validate_end(UHCIState *s) { UHCIQueue *queue, *n; QTAILQ_FOREACH_SAFE(queue, &s->queues, next, n) { if (!queue->valid) { uhci_queue_free(queue); } } }
13,342
FFmpeg
73f863d751df84db7a0ca1bd83cdff1b95dc94dd
1
static int fic_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { FICContext *ctx = avctx->priv_data; uint8_t *src = avpkt->data; int ret; int slice, nslices; int msize; int tsize; int cur_x, cur_y; int skip_cursor = ctx->skip_cursor; uint8_t *sdata; if ((ret = ff_reget_buffer(avctx, ctx->frame)) < 0) return ret; /* Header + at least one slice (4) */ if (avpkt->size < FIC_HEADER_SIZE + 4) { av_log(avctx, AV_LOG_ERROR, "Frame data is too small.\n"); return AVERROR_INVALIDDATA; } /* Check for header. */ if (memcmp(src, fic_header, 7)) av_log(avctx, AV_LOG_WARNING, "Invalid FIC Header.\n"); /* Is it a skip frame? */ if (src[17]) { if (!ctx->final_frame) { av_log(avctx, AV_LOG_WARNING, "Initial frame is skipped\n"); return AVERROR_INVALIDDATA; } goto skip; } nslices = src[13]; if (!nslices) { av_log(avctx, AV_LOG_ERROR, "Zero slices found.\n"); return AVERROR_INVALIDDATA; } /* High or Low Quality Matrix? */ ctx->qmat = src[23] ? fic_qmat_hq : fic_qmat_lq; /* Skip cursor data. */ tsize = AV_RB24(src + 24); if (tsize > avpkt->size - FIC_HEADER_SIZE) { av_log(avctx, AV_LOG_ERROR, "Packet is too small to contain cursor (%d vs %d bytes).\n", tsize, avpkt->size - FIC_HEADER_SIZE); return AVERROR_INVALIDDATA; } if (!tsize || !AV_RL16(src + 37) || !AV_RL16(src + 39)) skip_cursor = 1; if (!skip_cursor && tsize < 32) { av_log(avctx, AV_LOG_WARNING, "Cursor data too small. Skipping cursor.\n"); skip_cursor = 1; } /* Cursor position. */ cur_x = AV_RL16(src + 33); cur_y = AV_RL16(src + 35); if (!skip_cursor && (cur_x > avctx->width || cur_y > avctx->height)) { av_log(avctx, AV_LOG_DEBUG, "Invalid cursor position: (%d,%d). Skipping cursor.\n", cur_x, cur_y); skip_cursor = 1; } if (!skip_cursor && (AV_RL16(src + 37) != 32 || AV_RL16(src + 39) != 32)) { av_log(avctx, AV_LOG_WARNING, "Invalid cursor size. Skipping cursor.\n"); skip_cursor = 1; } /* Slice height for all but the last slice. */ ctx->slice_h = 16 * (ctx->aligned_height >> 4) / nslices; if (ctx->slice_h % 16) ctx->slice_h = FFALIGN(ctx->slice_h - 16, 16); /* First slice offset and remaining data. */ sdata = src + tsize + FIC_HEADER_SIZE + 4 * nslices; msize = avpkt->size - nslices * 4 - tsize - FIC_HEADER_SIZE; if (msize <= 0) { av_log(avctx, AV_LOG_ERROR, "Not enough frame data to decode.\n"); return AVERROR_INVALIDDATA; } /* * Set the frametype to I initially. It will be set to P if the frame * has any dependencies (skip blocks). There will be a race condition * inside the slice decode function to set these, but we do not care. * since they will only ever be set to 0/P. */ ctx->frame->key_frame = 1; ctx->frame->pict_type = AV_PICTURE_TYPE_I; /* Allocate slice data. */ av_fast_malloc(&ctx->slice_data, &ctx->slice_data_size, nslices * sizeof(ctx->slice_data[0])); if (!ctx->slice_data_size) { av_log(avctx, AV_LOG_ERROR, "Could not allocate slice data.\n"); return AVERROR(ENOMEM); } memset(ctx->slice_data, 0, nslices * sizeof(ctx->slice_data[0])); for (slice = 0; slice < nslices; slice++) { unsigned slice_off = AV_RB32(src + tsize + FIC_HEADER_SIZE + slice * 4); unsigned slice_size; int y_off = ctx->slice_h * slice; int slice_h = ctx->slice_h; /* * Either read the slice size, or consume all data left. * Also, special case the last slight height. */ if (slice == nslices - 1) { slice_size = msize; slice_h = FFALIGN(avctx->height - ctx->slice_h * (nslices - 1), 16); } else { slice_size = AV_RB32(src + tsize + FIC_HEADER_SIZE + slice * 4 + 4); } if (slice_size < slice_off || slice_size > msize) continue; slice_size -= slice_off; ctx->slice_data[slice].src = sdata + slice_off; ctx->slice_data[slice].src_size = slice_size; ctx->slice_data[slice].slice_h = slice_h; ctx->slice_data[slice].y_off = y_off; } if ((ret = avctx->execute(avctx, fic_decode_slice, ctx->slice_data, NULL, nslices, sizeof(ctx->slice_data[0]))) < 0) return ret; av_frame_free(&ctx->final_frame); ctx->final_frame = av_frame_clone(ctx->frame); if (!ctx->final_frame) { av_log(avctx, AV_LOG_ERROR, "Could not clone frame buffer.\n"); return AVERROR(ENOMEM); } /* Make sure we use a user-supplied buffer. */ if ((ret = ff_reget_buffer(avctx, ctx->final_frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "Could not make frame writable.\n"); return ret; } /* Draw cursor. */ if (!skip_cursor) { memcpy(ctx->cursor_buf, src + 59, 32 * 32 * 4); fic_draw_cursor(avctx, cur_x, cur_y); } skip: *got_frame = 1; if ((ret = av_frame_ref(data, ctx->final_frame)) < 0) return ret; return avpkt->size; }
13,343
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
1
static void cdrom_pio_impl(int nblocks) { QPCIDevice *dev; void *bmdma_base, *ide_base; FILE *fh; int patt_blocks = MAX(16, nblocks); size_t patt_len = ATAPI_BLOCK_SIZE * patt_blocks; char *pattern = g_malloc(patt_len); size_t rxsize = ATAPI_BLOCK_SIZE * nblocks; uint16_t *rx = g_malloc0(rxsize); int i, j; uint8_t data; uint16_t limit; /* Prepopulate the CDROM with an interesting pattern */ generate_pattern(pattern, patt_len, ATAPI_BLOCK_SIZE); fh = fopen(tmp_path, "w+"); fwrite(pattern, ATAPI_BLOCK_SIZE, patt_blocks, fh); fclose(fh); ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 " "-device ide-cd,drive=sr0,bus=ide.0", tmp_path); dev = get_pci_device(&bmdma_base, &ide_base); qtest_irq_intercept_in(global_qtest, "ioapic"); /* PACKET command on device 0 */ qpci_io_writeb(dev, ide_base + reg_device, 0); qpci_io_writeb(dev, ide_base + reg_lba_middle, BYTE_COUNT_LIMIT & 0xFF); qpci_io_writeb(dev, ide_base + reg_lba_high, (BYTE_COUNT_LIMIT >> 8 & 0xFF)); qpci_io_writeb(dev, ide_base + reg_command, CMD_PACKET); /* HP0: Check_Status_A State */ nsleep(400); data = ide_wait_clear(BSY); /* HP1: Send_Packet State */ assert_bit_set(data, DRQ | DRDY); assert_bit_clear(data, ERR | DF | BSY); /* SCSI CDB (READ10) -- read n*2048 bytes from block 0 */ send_scsi_cdb_read10(dev, ide_base, 0, nblocks); /* Read data back: occurs in bursts of 'BYTE_COUNT_LIMIT' bytes. * If BYTE_COUNT_LIMIT is odd, we transfer BYTE_COUNT_LIMIT - 1 bytes. * We allow an odd limit only when the remaining transfer size is * less than BYTE_COUNT_LIMIT. However, SCSI's read10 command can only * request n blocks, so our request size is always even. * For this reason, we assume there is never a hanging byte to fetch. */ g_assert(!(rxsize & 1)); limit = BYTE_COUNT_LIMIT & ~1; for (i = 0; i < DIV_ROUND_UP(rxsize, limit); i++) { size_t offset = i * (limit / 2); size_t rem = (rxsize / 2) - offset; /* HP3: INTRQ_Wait */ ide_wait_intr(IDE_PRIMARY_IRQ); /* HP2: Check_Status_B (and clear IRQ) */ data = ide_wait_clear(BSY); assert_bit_set(data, DRQ | DRDY); assert_bit_clear(data, ERR | DF | BSY); /* HP4: Transfer_Data */ for (j = 0; j < MIN((limit / 2), rem); j++) { rx[offset + j] = cpu_to_le16(qpci_io_readw(dev, ide_base + reg_data)); } } /* Check for final completion IRQ */ ide_wait_intr(IDE_PRIMARY_IRQ); /* Sanity check final state */ data = ide_wait_clear(DRQ); assert_bit_set(data, DRDY); assert_bit_clear(data, DRQ | ERR | DF | BSY); g_assert_cmpint(memcmp(pattern, rx, rxsize), ==, 0); g_free(pattern); g_free(rx); test_bmdma_teardown(); }
13,344
FFmpeg
816577716bc6170bccfea3b9e865618b69a4b426
1
static int append_to_cached_buf(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { DVDSubContext *ctx = avctx->priv_data; if (ctx->buf_size > 0xffff - buf_size) { av_log(avctx, AV_LOG_WARNING, "Attempt to reconstruct " "too large SPU packets aborted.\n"); av_freep(&ctx->buf); return AVERROR_INVALIDDATA; } ctx->buf = av_realloc(ctx->buf, ctx->buf_size + buf_size); if (!ctx->buf) return AVERROR(ENOMEM); memcpy(ctx->buf + ctx->buf_size, buf, buf_size); ctx->buf_size += buf_size; return 0; }
13,345
qemu
ef546f1275f6563e8934dd5e338d29d9f9909ca6
0
static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc) { VirtIONet *n = qemu_get_nic_opaque(nc); VirtIODevice *vdev = VIRTIO_DEVICE(n); RxFilterInfo *info; strList *str_list, *entry; int i; info = g_malloc0(sizeof(*info)); info->name = g_strdup(nc->name); info->promiscuous = n->promisc; if (n->nouni) { info->unicast = RX_STATE_NONE; } else if (n->alluni) { info->unicast = RX_STATE_ALL; } else { info->unicast = RX_STATE_NORMAL; } if (n->nomulti) { info->multicast = RX_STATE_NONE; } else if (n->allmulti) { info->multicast = RX_STATE_ALL; } else { info->multicast = RX_STATE_NORMAL; } info->broadcast_allowed = n->nobcast; info->multicast_overflow = n->mac_table.multi_overflow; info->unicast_overflow = n->mac_table.uni_overflow; info->main_mac = mac_strdup_printf(n->mac); str_list = NULL; for (i = 0; i < n->mac_table.first_multi; i++) { entry = g_malloc0(sizeof(*entry)); entry->value = mac_strdup_printf(n->mac_table.macs + i * ETH_ALEN); entry->next = str_list; str_list = entry; } info->unicast_table = str_list; str_list = NULL; for (i = n->mac_table.first_multi; i < n->mac_table.in_use; i++) { entry = g_malloc0(sizeof(*entry)); entry->value = mac_strdup_printf(n->mac_table.macs + i * ETH_ALEN); entry->next = str_list; str_list = entry; } info->multicast_table = str_list; info->vlan_table = get_vlan_table(n); if (!((1 << VIRTIO_NET_F_CTRL_VLAN) & vdev->guest_features)) { info->vlan = RX_STATE_ALL; } else if (!info->vlan_table) { info->vlan = RX_STATE_NONE; } else { info->vlan = RX_STATE_NORMAL; } /* enable event notification after query */ nc->rxfilter_notify_enabled = 1; return info; }
13,348
qemu
304ee9174f4761d3f4da611352a815ab27baba06
0
static inline int64_t get_sector_offset(BlockDriverState *bs, int64_t sector_num, int write) { BDRVVPCState *s = bs->opaque; uint64_t offset = sector_num * 512; uint64_t bitmap_offset, block_offset; uint32_t pagetable_index, pageentry_index; pagetable_index = offset / s->block_size; pageentry_index = (offset % s->block_size) / 512; if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff) return -1; // not allocated bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index]; block_offset = bitmap_offset + s->bitmap_size + (512 * pageentry_index); // We must ensure that we don't write to any sectors which are marked as // unused in the bitmap. We get away with setting all bits in the block // bitmap each time we write to a new block. This might cause Virtual PC to // miss sparse read optimization, but it's not a problem in terms of // correctness. if (write && (s->last_bitmap_offset != bitmap_offset)) { uint8_t bitmap[s->bitmap_size]; s->last_bitmap_offset = bitmap_offset; memset(bitmap, 0xff, s->bitmap_size); bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size); } // printf("sector: %" PRIx64 ", index: %x, offset: %x, bioff: %" PRIx64 ", bloff: %" PRIx64 "\n", // sector_num, pagetable_index, pageentry_index, // bitmap_offset, block_offset); // disabled by reason #if 0 #ifdef CACHE if (bitmap_offset != s->last_bitmap) { lseek(s->fd, bitmap_offset, SEEK_SET); s->last_bitmap = bitmap_offset; // Scary! Bitmap is stored as big endian 32bit entries, // while we used to look it up byte by byte read(s->fd, s->pageentry_u8, 512); for (i = 0; i < 128; i++) be32_to_cpus(&s->pageentry_u32[i]); } if ((s->pageentry_u8[pageentry_index / 8] >> (pageentry_index % 8)) & 1) return -1; #else lseek(s->fd, bitmap_offset + (pageentry_index / 8), SEEK_SET); read(s->fd, &bitmap_entry, 1); if ((bitmap_entry >> (pageentry_index % 8)) & 1) return -1; // not allocated #endif #endif return block_offset; }
13,349
FFmpeg
4cb6964244fd6c099383d8b7e99731e72cc844b9
0
av_cold void ff_dcadsp_init_x86(DCADSPContext *s) { int cpu_flags = av_get_cpu_flags(); if (EXTERNAL_SSE(cpu_flags)) { #if ARCH_X86_32 s->int8x8_fmul_int32 = ff_int8x8_fmul_int32_sse; #endif s->lfe_fir[0] = ff_dca_lfe_fir0_sse; s->lfe_fir[1] = ff_dca_lfe_fir1_sse; } if (EXTERNAL_SSE2(cpu_flags)) { s->int8x8_fmul_int32 = ff_int8x8_fmul_int32_sse2; } if (EXTERNAL_SSE4(cpu_flags)) { s->int8x8_fmul_int32 = ff_int8x8_fmul_int32_sse4; } }
13,350
qemu
a03ef88f77af045a2eb9629b5ce774a3fb973c5e
0
vpc_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVVPCState *s = bs->opaque; int ret; int64_t image_offset; int64_t n_bytes; int64_t bytes_done = 0; VHDFooter *footer = (VHDFooter *) s->footer_buf; QEMUIOVector local_qiov; if (be32_to_cpu(footer->type) == VHD_FIXED) { return bdrv_co_preadv(bs->file->bs, offset, bytes, qiov, 0); } qemu_co_mutex_lock(&s->lock); qemu_iovec_init(&local_qiov, qiov->niov); while (bytes > 0) { image_offset = get_image_offset(bs, offset, false); n_bytes = MIN(bytes, s->block_size - (offset % s->block_size)); if (image_offset == -1) { qemu_iovec_memset(qiov, bytes_done, 0, n_bytes); } else { qemu_iovec_reset(&local_qiov); qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes); ret = bdrv_co_preadv(bs->file->bs, image_offset, n_bytes, &local_qiov, 0); if (ret < 0) { goto fail; } } bytes -= n_bytes; offset += n_bytes; bytes_done += n_bytes; } ret = 0; fail: qemu_iovec_destroy(&local_qiov); qemu_co_mutex_unlock(&s->lock); return ret; }
13,351
qemu
e1833e1f96456fd8fc17463246fe0b2050e68efb
0
void do_store_dcr (void) { if (unlikely(env->dcr_env == NULL)) { if (loglevel != 0) { fprintf(logfile, "No DCR environment\n"); } do_raise_exception_err(EXCP_PROGRAM, EXCP_INVAL | EXCP_INVAL_INVAL); } else if (unlikely(ppc_dcr_write(env->dcr_env, T0, T1) != 0)) { if (loglevel != 0) { fprintf(logfile, "DCR write error %d %03x\n", (int)T0, (int)T0); } do_raise_exception_err(EXCP_PROGRAM, EXCP_INVAL | EXCP_PRIV_REG); } }
13,352
qemu
65afd211c71fc91750d8a18f9604c1e57a5202fb
0
static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, int flags) { BlockDriver *drv = bs->drv; BdrvTrackedRequest req; int ret; int64_t sector_num = offset >> BDRV_SECTOR_BITS; unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS; assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); if (bs->copy_on_read_in_flight) { wait_for_overlapping_requests(bs, offset, bytes); } tracked_request_begin(&req, bs, offset, bytes, true); ret = notifier_with_return_list_notify(&bs->before_write_notifiers, &req); if (ret < 0) { /* Do nothing, write notifier decided to fail this request */ } else if (flags & BDRV_REQ_ZERO_WRITE) { ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors, flags); } else { ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); } if (ret == 0 && !bs->enable_write_cache) { ret = bdrv_co_flush(bs); } bdrv_set_dirty(bs, sector_num, nb_sectors); if (bs->wr_highest_sector < sector_num + nb_sectors - 1) { bs->wr_highest_sector = sector_num + nb_sectors - 1; } if (bs->growable && ret >= 0) { bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors); } tracked_request_end(&req); return ret; }
13,353
qemu
f090c9d4ad5812fb92843d6470a1111c15190c4c
0
INLINE flag extractFloat64Sign( float64 a ) { return a>>63; }
13,354
qemu
b02ef3d92b19ad304a84433d3817f0903296ebc7
0
static void read_storage_element1_info(SCLPDevice *sclp, SCCB *sccb) { ReadStorageElementInfo *storage_info = (ReadStorageElementInfo *) sccb; sclpMemoryHotplugDev *mhd = get_sclp_memory_hotplug_dev(); assert(mhd); if ((mhd->standby_mem_size >> mhd->increment_size) >= 0x10000) { sccb->h.response_code = cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_VIOLATION); return; } /* Return information regarding standby memory */ storage_info->max_id = cpu_to_be16(mhd->standby_mem_size ? 1 : 0); storage_info->assigned = cpu_to_be16(mhd->standby_mem_size >> mhd->increment_size); storage_info->standby = cpu_to_be16(mhd->standby_mem_size >> mhd->increment_size); sccb->h.response_code = cpu_to_be16(SCLP_RC_STANDBY_READ_COMPLETION); }
13,355
qemu
3f26c1227e3b08010f2a65379cecf4cb4b5933fa
0
uint32_t HELPER(get_cp15)(CPUState *env, uint32_t insn) { cpu_abort(env, "cp15 insn %08x\n", insn); return 0; }
13,356
qemu
eabb7b91b36b202b4dac2df2d59d698e3aff197a
0
static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1, intptr_t arg2) { uint8_t *old_code_ptr = s->code_ptr; if (type == TCG_TYPE_I32) { tcg_out_op_t(s, INDEX_op_st_i32); tcg_out_r(s, arg); tcg_out_r(s, arg1); tcg_out32(s, arg2); } else { assert(type == TCG_TYPE_I64); #if TCG_TARGET_REG_BITS == 64 tcg_out_op_t(s, INDEX_op_st_i64); tcg_out_r(s, arg); tcg_out_r(s, arg1); tcg_out32(s, arg2); #else TODO(); #endif } old_code_ptr[1] = s->code_ptr - old_code_ptr; }
13,358
qemu
b6dcbe086c77ec683f5ff0b693593cda1d61f3a1
0
static void sdram_unmap_bcr (ppc4xx_sdram_t *sdram) { int i; for (i = 0; i < sdram->nbanks; i++) { #ifdef DEBUG_SDRAM printf("%s: Unmap RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n", __func__, sdram_base(sdram->bcr[i]), sdram_size(sdram->bcr[i])); #endif cpu_register_physical_memory(sdram_base(sdram->bcr[i]), sdram_size(sdram->bcr[i]), IO_MEM_UNASSIGNED); } }
13,359
qemu
91cda45b69e45a089f9989979a65db3f710c9925
0
static int find_pte64(CPUPPCState *env, struct mmu_ctx_hash64 *ctx, int h, int rw, int type, int target_page_bits) { hwaddr pteg_off; target_ulong pte0, pte1; int i, good = -1; int ret, r; ret = -1; /* No entry found */ pteg_off = (ctx->hash[h] * HASH_PTEG_SIZE_64) & env->htab_mask; for (i = 0; i < HPTES_PER_GROUP; i++) { pte0 = ppc_hash64_load_hpte0(env, pteg_off + i*HASH_PTE_SIZE_64); pte1 = ppc_hash64_load_hpte1(env, pteg_off + i*HASH_PTE_SIZE_64); r = pte64_check(ctx, pte0, pte1, h, rw, type); LOG_MMU("Load pte from %016" HWADDR_PRIx " => " TARGET_FMT_lx " " TARGET_FMT_lx " %d %d %d " TARGET_FMT_lx "\n", pteg_off + (i * 16), pte0, pte1, (int)(pte0 & 1), h, (int)((pte0 >> 1) & 1), ctx->ptem); switch (r) { case -3: /* PTE inconsistency */ return -1; case -2: /* Access violation */ ret = -2; good = i; break; case -1: default: /* No PTE match */ break; case 0: /* access granted */ /* XXX: we should go on looping to check all PTEs consistency * but if we can speed-up the whole thing as the * result would be undefined if PTEs are not consistent. */ ret = 0; good = i; goto done; } } if (good != -1) { done: LOG_MMU("found PTE at addr %08" HWADDR_PRIx " prot=%01x ret=%d\n", ctx->raddr, ctx->prot, ret); /* Update page flags */ pte1 = ctx->raddr; if (ppc_hash64_pte_update_flags(ctx, &pte1, ret, rw) == 1) { ppc_hash64_store_hpte1(env, pteg_off + good * HASH_PTE_SIZE_64, pte1); } } /* We have a TLB that saves 4K pages, so let's * split a huge page to 4k chunks */ if (target_page_bits != TARGET_PAGE_BITS) { ctx->raddr |= (ctx->eaddr & ((1 << target_page_bits) - 1)) & TARGET_PAGE_MASK; } return ret; }
13,362
qemu
88b062c2036cfd05b5111147736a08ba05ea05a9
0
int qed_read_l2_table_sync(BDRVQEDState *s, QEDRequest *request, uint64_t offset) { int ret = -EINPROGRESS; qed_read_l2_table(s, request, offset, qed_sync_cb, &ret); while (ret == -EINPROGRESS) { aio_poll(bdrv_get_aio_context(s->bs), true); } return ret; }
13,364
qemu
b9bec74bcb16519a876ec21cd5277c526a9b512d
0
static void kvm_getput_reg(__u64 *kvm_reg, target_ulong *qemu_reg, int set) { if (set) *kvm_reg = *qemu_reg; else *qemu_reg = *kvm_reg; }
13,368
qemu
7b7258f810d2bd40e2fb99c469c5db318d6c3d92
0
static bool sensor_type_is_dr(uint32_t sensor_type) { switch (sensor_type) { case RTAS_SENSOR_TYPE_ISOLATION_STATE: case RTAS_SENSOR_TYPE_DR: case RTAS_SENSOR_TYPE_ALLOCATION_STATE: return true; } return false; }
13,369
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
0
static uint64_t omap_mpuio_read(void *opaque, target_phys_addr_t addr, unsigned size) { struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque; int offset = addr & OMAP_MPUI_REG_MASK; uint16_t ret; if (size != 2) { return omap_badwidth_read16(opaque, addr); } switch (offset) { case 0x00: /* INPUT_LATCH */ return s->inputs; case 0x04: /* OUTPUT_REG */ return s->outputs; case 0x08: /* IO_CNTL */ return s->dir; case 0x10: /* KBR_LATCH */ return s->row_latch; case 0x14: /* KBC_REG */ return s->cols; case 0x18: /* GPIO_EVENT_MODE_REG */ return s->event; case 0x1c: /* GPIO_INT_EDGE_REG */ return s->edge; case 0x20: /* KBD_INT */ return (~s->row_latch & 0x1f) && !s->kbd_mask; case 0x24: /* GPIO_INT */ ret = s->ints; s->ints &= s->mask; if (ret) qemu_irq_lower(s->irq); return ret; case 0x28: /* KBD_MASKIT */ return s->kbd_mask; case 0x2c: /* GPIO_MASKIT */ return s->mask; case 0x30: /* GPIO_DEBOUNCING_REG */ return s->debounce; case 0x34: /* GPIO_LATCH_REG */ return s->latch; } OMAP_BAD_REG(addr); return 0; }
13,370
qemu
cbcfa0418f0c196afa765f5c9837b9344d1adcf3
0
int64_t qemu_get_clock_ns(QEMUClock *clock) { return 0; }
13,371
qemu
a7812ae412311d7d47f8aa85656faadac9d64b56
0
static always_inline void gen_qemu_stf (TCGv t0, TCGv t1, int flags) { TCGv tmp = tcg_temp_new(TCG_TYPE_I32); tcg_gen_helper_1_1(helper_f_to_memory, tmp, t0); tcg_gen_qemu_st32(tmp, t1, flags); tcg_temp_free(tmp); }
13,374
qemu
b47d8efa9f430c332bf96ce6eede169eb48422ad
0
static void vfio_put_group(VFIOGroup *group) { if (!QLIST_EMPTY(&group->device_list)) { return; } vfio_kvm_device_del_group(group); vfio_disconnect_container(group); QLIST_REMOVE(group, next); trace_vfio_put_group(group->fd); close(group->fd); g_free(group); if (QLIST_EMPTY(&group_list)) { qemu_unregister_reset(vfio_pci_reset_handler, NULL); } }
13,376
qemu
8dfbaa6ac450c4ec2646b1ca08a4017052a90c1d
0
static void virtio_ccw_start_ioeventfd(VirtioCcwDevice *dev) { VirtIODevice *vdev; int n, r; if (!(dev->flags & VIRTIO_CCW_FLAG_USE_IOEVENTFD) || dev->ioeventfd_disabled || dev->ioeventfd_started) { return; } vdev = virtio_bus_get_device(&dev->bus); for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { if (!virtio_queue_get_num(vdev, n)) { continue; } r = virtio_ccw_set_guest2host_notifier(dev, n, true, true); if (r < 0) { goto assign_error; } } dev->ioeventfd_started = true; return; assign_error: while (--n >= 0) { if (!virtio_queue_get_num(vdev, n)) { continue; } r = virtio_ccw_set_guest2host_notifier(dev, n, false, false); assert(r >= 0); } dev->ioeventfd_started = false; /* Disable ioeventfd for this device. */ dev->flags &= ~VIRTIO_CCW_FLAG_USE_IOEVENTFD; error_report("%s: failed. Fallback to userspace (slower).", __func__); }
13,378
qemu
e2b8247a322cd92945785edf25f09e6b3e8285f9
0
void bdrv_set_read_only(BlockDriverState *bs, bool read_only) { bs->read_only = read_only; }
13,379
qemu
f1ecb913d81199758383b8cbc15f4eb435b91753
0
void HELPER(crypto_aesmc)(CPUARMState *env, uint32_t rd, uint32_t rm, uint32_t decrypt) { static uint32_t const mc[][256] = { { /* MixColumns lookup table */ 0x00000000, 0x03010102, 0x06020204, 0x05030306, 0x0c040408, 0x0f05050a, 0x0a06060c, 0x0907070e, 0x18080810, 0x1b090912, 0x1e0a0a14, 0x1d0b0b16, 0x140c0c18, 0x170d0d1a, 0x120e0e1c, 0x110f0f1e, 0x30101020, 0x33111122, 0x36121224, 0x35131326, 0x3c141428, 0x3f15152a, 0x3a16162c, 0x3917172e, 0x28181830, 0x2b191932, 0x2e1a1a34, 0x2d1b1b36, 0x241c1c38, 0x271d1d3a, 0x221e1e3c, 0x211f1f3e, 0x60202040, 0x63212142, 0x66222244, 0x65232346, 0x6c242448, 0x6f25254a, 0x6a26264c, 0x6927274e, 0x78282850, 0x7b292952, 0x7e2a2a54, 0x7d2b2b56, 0x742c2c58, 0x772d2d5a, 0x722e2e5c, 0x712f2f5e, 0x50303060, 0x53313162, 0x56323264, 0x55333366, 0x5c343468, 0x5f35356a, 0x5a36366c, 0x5937376e, 0x48383870, 0x4b393972, 0x4e3a3a74, 0x4d3b3b76, 0x443c3c78, 0x473d3d7a, 0x423e3e7c, 0x413f3f7e, 0xc0404080, 0xc3414182, 0xc6424284, 0xc5434386, 0xcc444488, 0xcf45458a, 0xca46468c, 0xc947478e, 0xd8484890, 0xdb494992, 0xde4a4a94, 0xdd4b4b96, 0xd44c4c98, 0xd74d4d9a, 0xd24e4e9c, 0xd14f4f9e, 0xf05050a0, 0xf35151a2, 0xf65252a4, 0xf55353a6, 0xfc5454a8, 0xff5555aa, 0xfa5656ac, 0xf95757ae, 0xe85858b0, 0xeb5959b2, 0xee5a5ab4, 0xed5b5bb6, 0xe45c5cb8, 0xe75d5dba, 0xe25e5ebc, 0xe15f5fbe, 0xa06060c0, 0xa36161c2, 0xa66262c4, 0xa56363c6, 0xac6464c8, 0xaf6565ca, 0xaa6666cc, 0xa96767ce, 0xb86868d0, 0xbb6969d2, 0xbe6a6ad4, 0xbd6b6bd6, 0xb46c6cd8, 0xb76d6dda, 0xb26e6edc, 0xb16f6fde, 0x907070e0, 0x937171e2, 0x967272e4, 0x957373e6, 0x9c7474e8, 0x9f7575ea, 0x9a7676ec, 0x997777ee, 0x887878f0, 0x8b7979f2, 0x8e7a7af4, 0x8d7b7bf6, 0x847c7cf8, 0x877d7dfa, 0x827e7efc, 0x817f7ffe, 0x9b80801b, 0x98818119, 0x9d82821f, 0x9e83831d, 0x97848413, 0x94858511, 0x91868617, 0x92878715, 0x8388880b, 0x80898909, 0x858a8a0f, 0x868b8b0d, 0x8f8c8c03, 0x8c8d8d01, 0x898e8e07, 0x8a8f8f05, 0xab90903b, 0xa8919139, 0xad92923f, 0xae93933d, 0xa7949433, 0xa4959531, 0xa1969637, 0xa2979735, 0xb398982b, 0xb0999929, 0xb59a9a2f, 0xb69b9b2d, 0xbf9c9c23, 0xbc9d9d21, 0xb99e9e27, 0xba9f9f25, 0xfba0a05b, 0xf8a1a159, 0xfda2a25f, 0xfea3a35d, 0xf7a4a453, 0xf4a5a551, 0xf1a6a657, 0xf2a7a755, 0xe3a8a84b, 0xe0a9a949, 0xe5aaaa4f, 0xe6abab4d, 0xefacac43, 0xecadad41, 0xe9aeae47, 0xeaafaf45, 0xcbb0b07b, 0xc8b1b179, 0xcdb2b27f, 0xceb3b37d, 0xc7b4b473, 0xc4b5b571, 0xc1b6b677, 0xc2b7b775, 0xd3b8b86b, 0xd0b9b969, 0xd5baba6f, 0xd6bbbb6d, 0xdfbcbc63, 0xdcbdbd61, 0xd9bebe67, 0xdabfbf65, 0x5bc0c09b, 0x58c1c199, 0x5dc2c29f, 0x5ec3c39d, 0x57c4c493, 0x54c5c591, 0x51c6c697, 0x52c7c795, 0x43c8c88b, 0x40c9c989, 0x45caca8f, 0x46cbcb8d, 0x4fcccc83, 0x4ccdcd81, 0x49cece87, 0x4acfcf85, 0x6bd0d0bb, 0x68d1d1b9, 0x6dd2d2bf, 0x6ed3d3bd, 0x67d4d4b3, 0x64d5d5b1, 0x61d6d6b7, 0x62d7d7b5, 0x73d8d8ab, 0x70d9d9a9, 0x75dadaaf, 0x76dbdbad, 0x7fdcdca3, 0x7cdddda1, 0x79dedea7, 0x7adfdfa5, 0x3be0e0db, 0x38e1e1d9, 0x3de2e2df, 0x3ee3e3dd, 0x37e4e4d3, 0x34e5e5d1, 0x31e6e6d7, 0x32e7e7d5, 0x23e8e8cb, 0x20e9e9c9, 0x25eaeacf, 0x26ebebcd, 0x2fececc3, 0x2cededc1, 0x29eeeec7, 0x2aefefc5, 0x0bf0f0fb, 0x08f1f1f9, 0x0df2f2ff, 0x0ef3f3fd, 0x07f4f4f3, 0x04f5f5f1, 0x01f6f6f7, 0x02f7f7f5, 0x13f8f8eb, 0x10f9f9e9, 0x15fafaef, 0x16fbfbed, 0x1ffcfce3, 0x1cfdfde1, 0x19fefee7, 0x1affffe5, }, { /* Inverse MixColumns lookup table */ 0x00000000, 0x0b0d090e, 0x161a121c, 0x1d171b12, 0x2c342438, 0x27392d36, 0x3a2e3624, 0x31233f2a, 0x58684870, 0x5365417e, 0x4e725a6c, 0x457f5362, 0x745c6c48, 0x7f516546, 0x62467e54, 0x694b775a, 0xb0d090e0, 0xbbdd99ee, 0xa6ca82fc, 0xadc78bf2, 0x9ce4b4d8, 0x97e9bdd6, 0x8afea6c4, 0x81f3afca, 0xe8b8d890, 0xe3b5d19e, 0xfea2ca8c, 0xf5afc382, 0xc48cfca8, 0xcf81f5a6, 0xd296eeb4, 0xd99be7ba, 0x7bbb3bdb, 0x70b632d5, 0x6da129c7, 0x66ac20c9, 0x578f1fe3, 0x5c8216ed, 0x41950dff, 0x4a9804f1, 0x23d373ab, 0x28de7aa5, 0x35c961b7, 0x3ec468b9, 0x0fe75793, 0x04ea5e9d, 0x19fd458f, 0x12f04c81, 0xcb6bab3b, 0xc066a235, 0xdd71b927, 0xd67cb029, 0xe75f8f03, 0xec52860d, 0xf1459d1f, 0xfa489411, 0x9303e34b, 0x980eea45, 0x8519f157, 0x8e14f859, 0xbf37c773, 0xb43ace7d, 0xa92dd56f, 0xa220dc61, 0xf66d76ad, 0xfd607fa3, 0xe07764b1, 0xeb7a6dbf, 0xda595295, 0xd1545b9b, 0xcc434089, 0xc74e4987, 0xae053edd, 0xa50837d3, 0xb81f2cc1, 0xb31225cf, 0x82311ae5, 0x893c13eb, 0x942b08f9, 0x9f2601f7, 0x46bde64d, 0x4db0ef43, 0x50a7f451, 0x5baafd5f, 0x6a89c275, 0x6184cb7b, 0x7c93d069, 0x779ed967, 0x1ed5ae3d, 0x15d8a733, 0x08cfbc21, 0x03c2b52f, 0x32e18a05, 0x39ec830b, 0x24fb9819, 0x2ff69117, 0x8dd64d76, 0x86db4478, 0x9bcc5f6a, 0x90c15664, 0xa1e2694e, 0xaaef6040, 0xb7f87b52, 0xbcf5725c, 0xd5be0506, 0xdeb30c08, 0xc3a4171a, 0xc8a91e14, 0xf98a213e, 0xf2872830, 0xef903322, 0xe49d3a2c, 0x3d06dd96, 0x360bd498, 0x2b1ccf8a, 0x2011c684, 0x1132f9ae, 0x1a3ff0a0, 0x0728ebb2, 0x0c25e2bc, 0x656e95e6, 0x6e639ce8, 0x737487fa, 0x78798ef4, 0x495ab1de, 0x4257b8d0, 0x5f40a3c2, 0x544daacc, 0xf7daec41, 0xfcd7e54f, 0xe1c0fe5d, 0xeacdf753, 0xdbeec879, 0xd0e3c177, 0xcdf4da65, 0xc6f9d36b, 0xafb2a431, 0xa4bfad3f, 0xb9a8b62d, 0xb2a5bf23, 0x83868009, 0x888b8907, 0x959c9215, 0x9e919b1b, 0x470a7ca1, 0x4c0775af, 0x51106ebd, 0x5a1d67b3, 0x6b3e5899, 0x60335197, 0x7d244a85, 0x7629438b, 0x1f6234d1, 0x146f3ddf, 0x097826cd, 0x02752fc3, 0x335610e9, 0x385b19e7, 0x254c02f5, 0x2e410bfb, 0x8c61d79a, 0x876cde94, 0x9a7bc586, 0x9176cc88, 0xa055f3a2, 0xab58faac, 0xb64fe1be, 0xbd42e8b0, 0xd4099fea, 0xdf0496e4, 0xc2138df6, 0xc91e84f8, 0xf83dbbd2, 0xf330b2dc, 0xee27a9ce, 0xe52aa0c0, 0x3cb1477a, 0x37bc4e74, 0x2aab5566, 0x21a65c68, 0x10856342, 0x1b886a4c, 0x069f715e, 0x0d927850, 0x64d90f0a, 0x6fd40604, 0x72c31d16, 0x79ce1418, 0x48ed2b32, 0x43e0223c, 0x5ef7392e, 0x55fa3020, 0x01b79aec, 0x0aba93e2, 0x17ad88f0, 0x1ca081fe, 0x2d83bed4, 0x268eb7da, 0x3b99acc8, 0x3094a5c6, 0x59dfd29c, 0x52d2db92, 0x4fc5c080, 0x44c8c98e, 0x75ebf6a4, 0x7ee6ffaa, 0x63f1e4b8, 0x68fcedb6, 0xb1670a0c, 0xba6a0302, 0xa77d1810, 0xac70111e, 0x9d532e34, 0x965e273a, 0x8b493c28, 0x80443526, 0xe90f427c, 0xe2024b72, 0xff155060, 0xf418596e, 0xc53b6644, 0xce366f4a, 0xd3217458, 0xd82c7d56, 0x7a0ca137, 0x7101a839, 0x6c16b32b, 0x671bba25, 0x5638850f, 0x5d358c01, 0x40229713, 0x4b2f9e1d, 0x2264e947, 0x2969e049, 0x347efb5b, 0x3f73f255, 0x0e50cd7f, 0x055dc471, 0x184adf63, 0x1347d66d, 0xcadc31d7, 0xc1d138d9, 0xdcc623cb, 0xd7cb2ac5, 0xe6e815ef, 0xede51ce1, 0xf0f207f3, 0xfbff0efd, 0x92b479a7, 0x99b970a9, 0x84ae6bbb, 0x8fa362b5, 0xbe805d9f, 0xb58d5491, 0xa89a4f83, 0xa397468d, } }; union AES_STATE st = { .l = { float64_val(env->vfp.regs[rm]), float64_val(env->vfp.regs[rm + 1]) } }; int i; assert(decrypt < 2); for (i = 0; i < 16; i += 4) { st.cols[i >> 2] = cpu_to_le32( mc[decrypt][st.bytes[i]] ^ rol32(mc[decrypt][st.bytes[i + 1]], 8) ^ rol32(mc[decrypt][st.bytes[i + 2]], 16) ^ rol32(mc[decrypt][st.bytes[i + 3]], 24)); } env->vfp.regs[rd] = make_float64(st.l[0]); env->vfp.regs[rd + 1] = make_float64(st.l[1]); }
13,380
qemu
a97c67ee6c1546b985c1048c7a1f9e4fc13d9ee1
0
int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num, uint64_t *cluster_offset) { BDRVQcowState *s = bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset, *l2_table; int l1_bits, c; unsigned int index_in_cluster, nb_clusters; uint64_t nb_available, nb_needed; int ret; index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1); nb_needed = *num + index_in_cluster; l1_bits = s->l2_bits + s->cluster_bits; /* compute how many bytes there are between the offset and * the end of the l1 entry */ nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1)); /* compute the number of available sectors */ nb_available = (nb_available >> 9) + index_in_cluster; if (nb_needed > nb_available) { nb_needed = nb_available; } *cluster_offset = 0; /* seek the the l2 offset in the l1 table */ l1_index = offset >> l1_bits; if (l1_index >= s->l1_size) { ret = QCOW2_CLUSTER_UNALLOCATED; goto out; } l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK; if (!l2_offset) { ret = QCOW2_CLUSTER_UNALLOCATED; goto out; } /* load the l2 table in memory */ ret = l2_load(bs, l2_offset, &l2_table); if (ret < 0) { return ret; } /* find the cluster offset for the given disk offset */ l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *cluster_offset = be64_to_cpu(l2_table[l2_index]); nb_clusters = size_to_clusters(s, nb_needed << 9); ret = qcow2_get_cluster_type(*cluster_offset); switch (ret) { case QCOW2_CLUSTER_COMPRESSED: /* Compressed clusters can only be processed one by one */ c = 1; *cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK; break; case QCOW2_CLUSTER_ZERO: if (s->qcow_version < 3) { qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); return -EIO; } c = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], QCOW_OFLAG_ZERO); *cluster_offset = 0; break; case QCOW2_CLUSTER_UNALLOCATED: /* how many empty clusters ? */ c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]); *cluster_offset = 0; break; case QCOW2_CLUSTER_NORMAL: /* how many allocated clusters ? */ c = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], QCOW_OFLAG_ZERO); *cluster_offset &= L2E_OFFSET_MASK; break; default: abort(); } qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); nb_available = (c * s->cluster_sectors); out: if (nb_available > nb_needed) nb_available = nb_needed; *num = nb_available - index_in_cluster; return ret; }
13,381
qemu
364031f17932814484657e5551ba12957d993d7e
0
static int v9fs_synth_mkdir(FsContext *fs_ctx, V9fsPath *path, const char *buf, FsCred *credp) { errno = EPERM; return -1; }
13,382
FFmpeg
3c895fc098f7637f6d5ec3a9d6766e724a8b9e41
0
static int rm_write_packet(AVFormatContext *s, AVPacket *pkt) { if (s->streams[pkt->stream_index]->codec.codec_type == CODEC_TYPE_AUDIO) return rm_write_audio(s, pkt->data, pkt->size); else return rm_write_video(s, pkt->data, pkt->size); }
13,383
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
0
static uint64_t cs_mem_read(void *opaque, target_phys_addr_t addr, unsigned size) { CSState *s = opaque; uint32_t saddr, ret; saddr = addr >> 2; switch (saddr) { case 1: switch (CS_RAP(s)) { case 3: // Write only ret = 0; break; default: ret = s->dregs[CS_RAP(s)]; break; } trace_cs4231_mem_readl_dreg(CS_RAP(s), ret); break; default: ret = s->regs[saddr]; trace_cs4231_mem_readl_reg(saddr, ret); break; } return ret; }
13,384
FFmpeg
2e59142fa9a0db5fab8aa2e676ba524f61280b83
0
static int sctp_write(URLContext *h, const uint8_t *buf, int size) { SCTPContext *s = h->priv_data; int ret; if (!(h->flags & AVIO_FLAG_NONBLOCK)) { ret = sctp_wait_fd(s->fd, 1); if (ret < 0) return ret; } if (s->max_streams) { /*StreamId is introduced as a 2byte code into the stream*/ struct sctp_sndrcvinfo info = { 0 }; info.sinfo_stream = AV_RB16(buf); if (info.sinfo_stream > s->max_streams) abort(); ret = ff_sctp_send(s->fd, buf + 2, size - 2, &info, MSG_EOR); } else ret = send(s->fd, buf, size, 0); return ret < 0 ? ff_neterrno() : ret; }
13,386
FFmpeg
631c56a8e46dea41585f3e7b3ef9c52b49faa385
0
int avformat_network_init(void) { #if CONFIG_NETWORK int ret; ff_network_inited_globally = 1; if ((ret = ff_network_init()) < 0) return ret; if ((ret = ff_tls_init()) < 0) return ret; #endif return 0; }
13,387
FFmpeg
582552fb56ba6559cb1d094a7e7ae5dde3073c5c
0
static inline void cvtyuvtoRGB (SwsContext *c, vector signed short Y, vector signed short U, vector signed short V, vector signed short *R, vector signed short *G, vector signed short *B) { vector signed short vx,ux,uvx; Y = vec_mradds (Y, c->CY, c->OY); U = vec_sub (U,(vector signed short)(128)); V = vec_sub (V,(vector signed short)(128)); // ux = (CBU*(u<<c->CSHIFT)+0x4000)>>15; ux = vec_sl (U, c->CSHIFT); *B = vec_mradds (ux, c->CBU, Y); // vx = (CRV*(v<<c->CSHIFT)+0x4000)>>15; vx = vec_sl (V, c->CSHIFT); *R = vec_mradds (vx, c->CRV, Y); // uvx = ((CGU*u) + (CGV*v))>>15; uvx = vec_mradds (U, c->CGU, Y); *G = vec_mradds (V, c->CGV, uvx); }
13,390
FFmpeg
5c2fb561d94fc51d76ab21d6f7cc5b6cc3aa599c
0
static void vaapi_encode_h264_write_sei(PutBitContext *pbc, VAAPIEncodeContext *ctx, VAAPIEncodePicture *pic) { VAAPIEncodeH264Context *priv = ctx->priv_data; PutBitContext payload_bits; char payload[256]; int payload_type, payload_size, i; void (*write_payload)(PutBitContext *pbc, VAAPIEncodeContext *ctx, VAAPIEncodePicture *pic) = NULL; vaapi_encode_h264_write_nal_header(pbc, NAL_SEI, 0); for (payload_type = 0; payload_type < 64; payload_type++) { switch (payload_type) { case SEI_TYPE_BUFFERING_PERIOD: if (!priv->send_timing_sei || pic->type != PICTURE_TYPE_IDR) continue; write_payload = &vaapi_encode_h264_write_buffering_period; break; case SEI_TYPE_PIC_TIMING: if (!priv->send_timing_sei) continue; write_payload = &vaapi_encode_h264_write_pic_timing; break; case SEI_TYPE_USER_DATA_UNREGISTERED: if (pic->encode_order != 0) continue; write_payload = &vaapi_encode_h264_write_identifier; break; default: continue; } init_put_bits(&payload_bits, payload, sizeof(payload)); write_payload(&payload_bits, ctx, pic); if (put_bits_count(&payload_bits) & 7) { write_u(&payload_bits, 1, 1, bit_equal_to_one); while (put_bits_count(&payload_bits) & 7) write_u(&payload_bits, 1, 0, bit_equal_to_zero); } payload_size = put_bits_count(&payload_bits) / 8; flush_put_bits(&payload_bits); u(8, payload_type, last_payload_type_byte); u(8, payload_size, last_payload_size_byte); for (i = 0; i < payload_size; i++) u(8, payload[i] & 0xff, sei_payload); } vaapi_encode_h264_write_trailing_rbsp(pbc); }
13,391
qemu
0920a17199d23b3def3a60fa1fbbdeadcdda452d
1
Visitor *visitor_input_test_init(TestInputVisitorData *data, const char *json_string, ...) { Visitor *v; va_list ap; va_start(ap, json_string); data->obj = qobject_from_jsonv(json_string, &ap); va_end(ap); g_assert(data->obj != NULL); data->qiv = qmp_input_visitor_new(data->obj); g_assert(data->qiv != NULL); v = qmp_input_get_visitor(data->qiv); g_assert(v != NULL); return v; }
13,392
qemu
d9bce9d99f4656ae0b0127f7472db9067b8f84ab
1
static void dump_syscall(CPUState *env) { fprintf(logfile, "syscall r0=0x%08x r3=0x%08x r4=0x%08x " "r5=0x%08x r6=0x%08x nip=0x%08x\n", env->gpr[0], env->gpr[3], env->gpr[4], env->gpr[5], env->gpr[6], env->nip); }
13,393
qemu
7364dbdabb7824d5bde1e341bb6d928282f01c83
1
static int vnc_auth_sasl_check_ssf(VncState *vs) { const void *val; int err, ssf; if (!vs->sasl.wantSSF) return 1; err = sasl_getprop(vs->sasl.conn, SASL_SSF, &val); if (err != SASL_OK) return 0; ssf = *(const int *)val; VNC_DEBUG("negotiated an SSF of %d\n", ssf); if (ssf < 56) return 0; /* 56 is good for Kerberos */ /* Only setup for read initially, because we're about to send an RPC * reply which must be in plain text. When the next incoming RPC * arrives, we'll switch on writes too * * cf qemudClientReadSASL in qemud.c */ vs->sasl.runSSF = 1; /* We have a SSF that's good enough */ return 1; }
13,394
FFmpeg
5e715b583dab85735660b15a8d217a69164675fe
1
static int parse_metadata(DBEContext *s) { int i, ret, key = parse_key(s), mtd_size; if ((ret = convert_input(s, 1, key)) < 0) return ret; skip_bits(&s->gb, 4); mtd_size = get_bits(&s->gb, 10); if (!mtd_size) { av_log(s->avctx, AV_LOG_ERROR, "Invalid metadata size\n"); return AVERROR_INVALIDDATA; } if ((ret = convert_input(s, mtd_size, key)) < 0) return ret; skip_bits(&s->gb, 14); s->prog_conf = get_bits(&s->gb, 6); if (s->prog_conf > MAX_PROG_CONF) { av_log(s->avctx, AV_LOG_ERROR, "Invalid program configuration\n"); return AVERROR_INVALIDDATA; } s->nb_channels = nb_channels_tab[s->prog_conf]; s->nb_programs = nb_programs_tab[s->prog_conf]; s->fr_code = get_bits(&s->gb, 4); s->fr_code_orig = get_bits(&s->gb, 4); if (!sample_rate_tab[s->fr_code] || !sample_rate_tab[s->fr_code_orig]) { av_log(s->avctx, AV_LOG_ERROR, "Invalid frame rate code\n"); return AVERROR_INVALIDDATA; } skip_bits_long(&s->gb, 88); for (i = 0; i < s->nb_channels; i++) s->ch_size[i] = get_bits(&s->gb, 10); s->mtd_ext_size = get_bits(&s->gb, 8); s->meter_size = get_bits(&s->gb, 8); skip_bits_long(&s->gb, 10 * s->nb_programs); for (i = 0; i < s->nb_channels; i++) { s->rev_id[i] = get_bits(&s->gb, 4); skip_bits1(&s->gb); s->begin_gain[i] = get_bits(&s->gb, 10); s->end_gain[i] = get_bits(&s->gb, 10); } if (get_bits_left(&s->gb) < 0) { av_log(s->avctx, AV_LOG_ERROR, "Read past end of metadata\n"); return AVERROR_INVALIDDATA; } skip_input(s, mtd_size + 1); return 0; }
13,395
FFmpeg
bfa0f96586fe2c257cfa574ffb991da493a54da1
1
static void vp8_release_frame(VP8Context *s, AVFrame *f, int is_close) { if (!is_close) { if (f->ref_index[0]) { assert(s->num_maps_to_be_freed < FF_ARRAY_ELEMS(s->segmentation_maps)); s->segmentation_maps[s->num_maps_to_be_freed++] = f->ref_index[0]; f->ref_index[0] = NULL; } } else { av_freep(&f->ref_index[0]); } ff_thread_release_buffer(s->avctx, f); }
13,397
qemu
3a03bfa5a219fe06779706315f2555622b51193c
1
int qemu_socket(int domain, int type, int protocol) { int ret; #ifdef SOCK_CLOEXEC ret = socket(domain, type | SOCK_CLOEXEC, protocol); #else ret = socket(domain, type, protocol); if (ret >= 0) { qemu_set_cloexec(ret); } #endif return ret; }
13,398
FFmpeg
0062869ae25007c8506517dcfcbe6f439dc6958a
1
static int smacker_probe(AVProbeData *p) { if(p->buf[0] == 'S' && p->buf[1] == 'M' && p->buf[2] == 'K' && (p->buf[3] == '2' || p->buf[3] == '4')) return AVPROBE_SCORE_MAX; else return 0; }
13,399
FFmpeg
e6c90ce94f1b07f50cea2babf7471af455cca0ff
0
static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl) { const int mb_x = h->mb_x; const int mb_y = h->mb_y; const int mb_xy = h->mb_xy; const int mb_type = h->cur_pic.mb_type[mb_xy]; uint8_t *dest_y, *dest_cb, *dest_cr; int linesize, uvlinesize /*dct_offset*/; int i, j; int *block_offset = &h->block_offset[0]; const int transform_bypass = !SIMPLE && (sl->qscale == 0 && h->sps.transform_bypass); /* is_h264 should always be true if SVQ3 is disabled. */ const int is_h264 = !CONFIG_SVQ3_DECODER || SIMPLE || h->avctx->codec_id == AV_CODEC_ID_H264; void (*idct_add)(uint8_t *dst, int16_t *block, int stride); const int block_h = 16 >> h->chroma_y_shift; const int chroma422 = CHROMA422(h); dest_y = h->cur_pic.f.data[0] + ((mb_x << PIXEL_SHIFT) + mb_y * h->linesize) * 16; dest_cb = h->cur_pic.f.data[1] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h; dest_cr = h->cur_pic.f.data[2] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * h->uvlinesize * block_h; h->vdsp.prefetch(dest_y + (h->mb_x & 3) * 4 * h->linesize + (64 << PIXEL_SHIFT), h->linesize, 4); h->vdsp.prefetch(dest_cb + (h->mb_x & 7) * h->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2); h->list_counts[mb_xy] = sl->list_count; if (!SIMPLE && MB_FIELD(h)) { linesize = sl->mb_linesize = h->linesize * 2; uvlinesize = sl->mb_uvlinesize = h->uvlinesize * 2; block_offset = &h->block_offset[48]; if (mb_y & 1) { // FIXME move out of this function? dest_y -= h->linesize * 15; dest_cb -= h->uvlinesize * (block_h - 1); dest_cr -= h->uvlinesize * (block_h - 1); } if (FRAME_MBAFF(h)) { int list; for (list = 0; list < sl->list_count; list++) { if (!USES_LIST(mb_type, list)) continue; if (IS_16X16(mb_type)) { int8_t *ref = &sl->ref_cache[list][scan8[0]]; fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (h->mb_y & 1), 1); } else { for (i = 0; i < 16; i += 4) { int ref = sl->ref_cache[list][scan8[i]]; if (ref >= 0) fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2, 8, (16 + ref) ^ (h->mb_y & 1), 1); } } } } } else { linesize = sl->mb_linesize = h->linesize; uvlinesize = sl->mb_uvlinesize = h->uvlinesize; // dct_offset = s->linesize * 16; } if (!SIMPLE && IS_INTRA_PCM(mb_type)) { if (PIXEL_SHIFT) { const int bit_depth = h->sps.bit_depth_luma; int j; GetBitContext gb; init_get_bits(&gb, sl->intra_pcm_ptr, ff_h264_mb_sizes[h->sps.chroma_format_idc] * bit_depth); for (i = 0; i < 16; i++) { uint16_t *tmp_y = (uint16_t *)(dest_y + i * linesize); for (j = 0; j < 16; j++) tmp_y[j] = get_bits(&gb, bit_depth); } if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { if (!h->sps.chroma_format_idc) { for (i = 0; i < block_h; i++) { uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cb[j] = 1 << (bit_depth - 1); } for (i = 0; i < block_h; i++) { uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cr[j] = 1 << (bit_depth - 1); } } else { for (i = 0; i < block_h; i++) { uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cb[j] = get_bits(&gb, bit_depth); } for (i = 0; i < block_h; i++) { uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cr[j] = get_bits(&gb, bit_depth); } } } } else { for (i = 0; i < 16; i++) memcpy(dest_y + i * linesize, sl->intra_pcm_ptr + i * 16, 16); if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { if (!h->sps.chroma_format_idc) { for (i = 0; i < block_h; i++) { memset(dest_cb + i * uvlinesize, 128, 8); memset(dest_cr + i * uvlinesize, 128, 8); } } else { const uint8_t *src_cb = sl->intra_pcm_ptr + 256; const uint8_t *src_cr = sl->intra_pcm_ptr + 256 + block_h * 8; for (i = 0; i < block_h; i++) { memcpy(dest_cb + i * uvlinesize, src_cb + i * 8, 8); memcpy(dest_cr + i * uvlinesize, src_cr + i * 8, 8); } } } } } else { if (IS_INTRA(mb_type)) { if (h->deblocking_filter) xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, 0, SIMPLE, PIXEL_SHIFT); if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { h->hpc.pred8x8[sl->chroma_pred_mode](dest_cb, uvlinesize); h->hpc.pred8x8[sl->chroma_pred_mode](dest_cr, uvlinesize); } hl_decode_mb_predict_luma(h, sl, mb_type, is_h264, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest_y, 0); if (h->deblocking_filter) xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, 0, SIMPLE, PIXEL_SHIFT); } else if (is_h264) { if (chroma422) { FUNC(hl_motion_422)(h, sl, dest_y, dest_cb, dest_cr, h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab, h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab, h->h264dsp.weight_h264_pixels_tab, h->h264dsp.biweight_h264_pixels_tab); } else { FUNC(hl_motion_420)(h, sl, dest_y, dest_cb, dest_cr, h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab, h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab, h->h264dsp.weight_h264_pixels_tab, h->h264dsp.biweight_h264_pixels_tab); } } hl_decode_mb_idct_luma(h, sl, mb_type, is_h264, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest_y, 0); if ((SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) && (sl->cbp & 0x30)) { uint8_t *dest[2] = { dest_cb, dest_cr }; if (transform_bypass) { if (IS_INTRA(mb_type) && h->sps.profile_idc == 244 && (sl->chroma_pred_mode == VERT_PRED8x8 || sl->chroma_pred_mode == HOR_PRED8x8)) { h->hpc.pred8x8_add[sl->chroma_pred_mode](dest[0], block_offset + 16, sl->mb + (16 * 16 * 1 << PIXEL_SHIFT), uvlinesize); h->hpc.pred8x8_add[sl->chroma_pred_mode](dest[1], block_offset + 32, sl->mb + (16 * 16 * 2 << PIXEL_SHIFT), uvlinesize); } else { idct_add = h->h264dsp.h264_add_pixels4_clear; for (j = 1; j < 3; j++) { for (i = j * 16; i < j * 16 + 4; i++) if (sl->non_zero_count_cache[scan8[i]] || dctcoef_get(sl->mb, PIXEL_SHIFT, i * 16)) idct_add(dest[j - 1] + block_offset[i], sl->mb + (i * 16 << PIXEL_SHIFT), uvlinesize); if (chroma422) { for (i = j * 16 + 4; i < j * 16 + 8; i++) if (sl->non_zero_count_cache[scan8[i + 4]] || dctcoef_get(sl->mb, PIXEL_SHIFT, i * 16)) idct_add(dest[j - 1] + block_offset[i + 4], sl->mb + (i * 16 << PIXEL_SHIFT), uvlinesize); } } } } else { if (is_h264) { int qp[2]; if (chroma422) { qp[0] = sl->chroma_qp[0] + 3; qp[1] = sl->chroma_qp[1] + 3; } else { qp[0] = sl->chroma_qp[0]; qp[1] = sl->chroma_qp[1]; } if (sl->non_zero_count_cache[scan8[CHROMA_DC_BLOCK_INDEX + 0]]) h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + (16 * 16 * 1 << PIXEL_SHIFT), h->dequant4_coeff[IS_INTRA(mb_type) ? 1 : 4][qp[0]][0]); if (sl->non_zero_count_cache[scan8[CHROMA_DC_BLOCK_INDEX + 1]]) h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + (16 * 16 * 2 << PIXEL_SHIFT), h->dequant4_coeff[IS_INTRA(mb_type) ? 2 : 5][qp[1]][0]); h->h264dsp.h264_idct_add8(dest, block_offset, sl->mb, uvlinesize, sl->non_zero_count_cache); } else if (CONFIG_SVQ3_DECODER) { h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + 16 * 16 * 1, h->dequant4_coeff[IS_INTRA(mb_type) ? 1 : 4][sl->chroma_qp[0]][0]); h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + 16 * 16 * 2, h->dequant4_coeff[IS_INTRA(mb_type) ? 2 : 5][sl->chroma_qp[1]][0]); for (j = 1; j < 3; j++) { for (i = j * 16; i < j * 16 + 4; i++) if (sl->non_zero_count_cache[scan8[i]] || sl->mb[i * 16]) { uint8_t *const ptr = dest[j - 1] + block_offset[i]; ff_svq3_add_idct_c(ptr, sl->mb + i * 16, uvlinesize, ff_h264_chroma_qp[0][sl->qscale + 12] - 12, 2); } } } } } } }
13,400
FFmpeg
803e82276b3716bf6012ec69e8854dae14a4fd2b
1
static int hds_write_header(AVFormatContext *s) { HDSContext *c = s->priv_data; int ret = 0, i; AVOutputFormat *oformat; mkdir(s->filename, 0777); oformat = av_guess_format("flv", NULL, NULL); if (!oformat) { ret = AVERROR_MUXER_NOT_FOUND; goto fail; } c->streams = av_mallocz(sizeof(*c->streams) * s->nb_streams); if (!c->streams) { ret = AVERROR(ENOMEM); goto fail; } for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[c->nb_streams]; AVFormatContext *ctx; AVStream *st = s->streams[i]; if (!st->codec->bit_rate) { av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i); ret = AVERROR(EINVAL); goto fail; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (os->has_video) { c->nb_streams++; os++; } os->has_video = 1; } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if (os->has_audio) { c->nb_streams++; os++; } os->has_audio = 1; } else { av_log(s, AV_LOG_ERROR, "Unsupported stream type in stream %d\n", i); ret = AVERROR(EINVAL); goto fail; } os->bitrate += s->streams[i]->codec->bit_rate; if (!os->ctx) { os->first_stream = i; ctx = avformat_alloc_context(); if (!ctx) { ret = AVERROR(ENOMEM); goto fail; } os->ctx = ctx; ctx->oformat = oformat; ctx->interrupt_callback = s->interrupt_callback; ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), AVIO_FLAG_WRITE, os, NULL, hds_write, NULL); if (!ctx->pb) { ret = AVERROR(ENOMEM); goto fail; } } else { ctx = os->ctx; } s->streams[i]->id = c->nb_streams; if (!(st = avformat_new_stream(ctx, NULL))) { ret = AVERROR(ENOMEM); goto fail; } avcodec_copy_context(st->codec, s->streams[i]->codec); st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; } if (c->streams[c->nb_streams].ctx) c->nb_streams++; for (i = 0; i < c->nb_streams; i++) { OutputStream *os = &c->streams[i]; int j; if ((ret = avformat_write_header(os->ctx, NULL)) < 0) { goto fail; } os->ctx_inited = 1; avio_flush(os->ctx->pb); for (j = 0; j < os->ctx->nb_streams; j++) s->streams[os->first_stream + j]->time_base = os->ctx->streams[j]->time_base; snprintf(os->temp_filename, sizeof(os->temp_filename), "%s/stream%d_temp", s->filename, i); ret = init_file(s, os, 0); if (ret < 0) goto fail; if (!os->has_video && c->min_frag_duration <= 0) { av_log(s, AV_LOG_WARNING, "No video stream in output stream %d and no min frag duration set\n", i); ret = AVERROR(EINVAL); } os->fragment_index = 1; write_abst(s, os, 0); } ret = write_manifest(s, 0); fail: if (ret) hds_free(s); return ret; }
13,401
qemu
3977ee5d7a9f2e3664dd8b233f3224694e23b62b
1
static int disas_coproc_insn(DisasContext *s, uint32_t insn) { int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2; const ARMCPRegInfo *ri; cpnum = (insn >> 8) & 0xf; /* First check for coprocessor space used for XScale/iwMMXt insns */ if (arm_dc_feature(s, ARM_FEATURE_XSCALE) && (cpnum < 2)) { if (extract32(s->c15_cpar, cpnum, 1) == 0) { return 1; } if (arm_dc_feature(s, ARM_FEATURE_IWMMXT)) { return disas_iwmmxt_insn(s, insn); } else if (arm_dc_feature(s, ARM_FEATURE_XSCALE)) { return disas_dsp_insn(s, insn); } return 1; } /* Otherwise treat as a generic register access */ is64 = (insn & (1 << 25)) == 0; if (!is64 && ((insn & (1 << 4)) == 0)) { /* cdp */ return 1; } crm = insn & 0xf; if (is64) { crn = 0; opc1 = (insn >> 4) & 0xf; opc2 = 0; rt2 = (insn >> 16) & 0xf; } else { crn = (insn >> 16) & 0xf; opc1 = (insn >> 21) & 7; opc2 = (insn >> 5) & 7; rt2 = 0; } isread = (insn >> 20) & 1; rt = (insn >> 12) & 0xf; ri = get_arm_cp_reginfo(s->cp_regs, ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2)); if (ri) { /* Check access permissions */ if (!cp_access_ok(s->current_el, ri, isread)) { return 1; } if (ri->accessfn || (arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) { /* Emit code to perform further access permissions checks at * runtime; this may result in an exception. * Note that on XScale all cp0..c13 registers do an access check * call in order to handle c15_cpar. */ TCGv_ptr tmpptr; TCGv_i32 tcg_syn; uint32_t syndrome; /* Note that since we are an implementation which takes an * exception on a trapped conditional instruction only if the * instruction passes its condition code check, we can take * advantage of the clause in the ARM ARM that allows us to set * the COND field in the instruction to 0xE in all cases. * We could fish the actual condition out of the insn (ARM) * or the condexec bits (Thumb) but it isn't necessary. */ switch (cpnum) { case 14: if (is64) { syndrome = syn_cp14_rrt_trap(1, 0xe, opc1, crm, rt, rt2, isread, s->thumb); } else { syndrome = syn_cp14_rt_trap(1, 0xe, opc1, opc2, crn, crm, rt, isread, s->thumb); } break; case 15: if (is64) { syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2, isread, s->thumb); } else { syndrome = syn_cp15_rt_trap(1, 0xe, opc1, opc2, crn, crm, rt, isread, s->thumb); } break; default: /* ARMv8 defines that only coprocessors 14 and 15 exist, * so this can only happen if this is an ARMv7 or earlier CPU, * in which case the syndrome information won't actually be * guest visible. */ assert(!arm_dc_feature(s, ARM_FEATURE_V8)); syndrome = syn_uncategorized(); break; } gen_set_pc_im(s, s->pc); tmpptr = tcg_const_ptr(ri); tcg_syn = tcg_const_i32(syndrome); gen_helper_access_check_cp_reg(cpu_env, tmpptr, tcg_syn); tcg_temp_free_ptr(tmpptr); tcg_temp_free_i32(tcg_syn); } /* Handle special cases first */ switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { case ARM_CP_NOP: return 0; case ARM_CP_WFI: if (isread) { return 1; } gen_set_pc_im(s, s->pc); s->is_jmp = DISAS_WFI; return 0; default: break; } if ((s->tb->cflags & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { gen_io_start(); } if (isread) { /* Read */ if (is64) { TCGv_i64 tmp64; TCGv_i32 tmp; if (ri->type & ARM_CP_CONST) { tmp64 = tcg_const_i64(ri->resetvalue); } else if (ri->readfn) { TCGv_ptr tmpptr; tmp64 = tcg_temp_new_i64(); tmpptr = tcg_const_ptr(ri); gen_helper_get_cp_reg64(tmp64, cpu_env, tmpptr); tcg_temp_free_ptr(tmpptr); } else { tmp64 = tcg_temp_new_i64(); tcg_gen_ld_i64(tmp64, cpu_env, ri->fieldoffset); } tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); store_reg(s, rt, tmp); tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); store_reg(s, rt2, tmp); } else { TCGv_i32 tmp; if (ri->type & ARM_CP_CONST) { tmp = tcg_const_i32(ri->resetvalue); } else if (ri->readfn) { TCGv_ptr tmpptr; tmp = tcg_temp_new_i32(); tmpptr = tcg_const_ptr(ri); gen_helper_get_cp_reg(tmp, cpu_env, tmpptr); tcg_temp_free_ptr(tmpptr); } else { tmp = load_cpu_offset(ri->fieldoffset); } if (rt == 15) { /* Destination register of r15 for 32 bit loads sets * the condition codes from the high 4 bits of the value */ gen_set_nzcv(tmp); tcg_temp_free_i32(tmp); } else { store_reg(s, rt, tmp); } } } else { /* Write */ if (ri->type & ARM_CP_CONST) { /* If not forbidden by access permissions, treat as WI */ return 0; } if (is64) { TCGv_i32 tmplo, tmphi; TCGv_i64 tmp64 = tcg_temp_new_i64(); tmplo = load_reg(s, rt); tmphi = load_reg(s, rt2); tcg_gen_concat_i32_i64(tmp64, tmplo, tmphi); tcg_temp_free_i32(tmplo); tcg_temp_free_i32(tmphi); if (ri->writefn) { TCGv_ptr tmpptr = tcg_const_ptr(ri); gen_helper_set_cp_reg64(cpu_env, tmpptr, tmp64); tcg_temp_free_ptr(tmpptr); } else { tcg_gen_st_i64(tmp64, cpu_env, ri->fieldoffset); } tcg_temp_free_i64(tmp64); } else { if (ri->writefn) { TCGv_i32 tmp; TCGv_ptr tmpptr; tmp = load_reg(s, rt); tmpptr = tcg_const_ptr(ri); gen_helper_set_cp_reg(cpu_env, tmpptr, tmp); tcg_temp_free_ptr(tmpptr); tcg_temp_free_i32(tmp); } else { TCGv_i32 tmp = load_reg(s, rt); store_cpu_offset(tmp, ri->fieldoffset); } } } if ((s->tb->cflags & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { /* I/O operations must end the TB here (whether read or write) */ gen_io_end(); gen_lookup_tb(s); } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { /* We default to ending the TB on a coprocessor register write, * but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). */ gen_lookup_tb(s); } return 0; } /* Unknown register; this might be a guest error or a QEMU * unimplemented feature. */ if (is64) { qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " "64 bit system register cp:%d opc1: %d crm:%d " "(%s)\n", isread ? "read" : "write", cpnum, opc1, crm, s->ns ? "non-secure" : "secure"); } else { qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " "system register cp:%d opc1:%d crn:%d crm:%d opc2:%d " "(%s)\n", isread ? "read" : "write", cpnum, opc1, crn, crm, opc2, s->ns ? "non-secure" : "secure"); } return 1; }
13,402
FFmpeg
92ea249d7db4baf64680f412c6bd99ff85860723
0
static inline int round_sample(int64_t *sum) { int sum1; sum1 = (int)((*sum) >> OUT_SHIFT); *sum &= (1<<OUT_SHIFT)-1; return av_clip(sum1, OUT_MIN, OUT_MAX); }
13,403
qemu
9807caccd605d09a72495637959568d690e10175
0
bool virtio_is_big_endian(void) { #if defined(TARGET_WORDS_BIGENDIAN) return true; #else return false; #endif }
13,404
qemu
eb159d13ee36a9ef2a83e3ab66f1b2ae1cc2d9f1
0
static int check_opt(const CmdArgs *cmd_args, const char *name, QDict *args) { if (!cmd_args->optional) { qerror_report(QERR_MISSING_PARAMETER, name); return -1; } if (cmd_args->type == '-') { /* handlers expect a value, they need to be changed */ qdict_put(args, name, qint_from_int(0)); } return 0; }
13,405
qemu
a0efbf16604770b9d805bcf210ec29942321134f
0
static void i440fx_pcihost_get_pci_hole_end(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { I440FXState *s = I440FX_PCI_HOST_BRIDGE(obj); uint32_t value = s->pci_hole.end; visit_type_uint32(v, name, &value, errp); }
13,406
qemu
ef546f1275f6563e8934dd5e338d29d9f9909ca6
0
bool vring_enable_notification(VirtIODevice *vdev, Vring *vring) { if (vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX)) { vring_avail_event(&vring->vr) = vring->vr.avail->idx; } else { vring_clear_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY); } smp_mb(); /* ensure update is seen before reading avail_idx */ return !vring_more_avail(vdev, vring); }
13,407
qemu
185698715dfb18c82ad2a5dbc169908602d43e81
0
void helper_fcmpu (uint64_t arg1, uint64_t arg2, uint32_t crfD) { CPU_DoubleU farg1, farg2; uint32_t ret = 0; farg1.ll = arg1; farg2.ll = arg2; if (unlikely(float64_is_nan(farg1.d) || float64_is_nan(farg2.d))) { ret = 0x01UL; } else if (float64_lt(farg1.d, farg2.d, &env->fp_status)) { ret = 0x08UL; } else if (!float64_le(farg1.d, farg2.d, &env->fp_status)) { ret = 0x04UL; } else { ret = 0x02UL; } env->fpscr &= ~(0x0F << FPSCR_FPRF); env->fpscr |= ret << FPSCR_FPRF; env->crf[crfD] = ret; if (unlikely(ret == 0x01UL && (float64_is_signaling_nan(farg1.d) || float64_is_signaling_nan(farg2.d)))) { /* sNaN comparison */ fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); } }
13,408
qemu
97f90cbfe810bb153fc44bde732d9639610783bb
0
static void dec_fpu(DisasContext *dc) { if ((dc->tb_flags & MSR_EE_FLAG) && !(dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) && !((dc->env->pvr.regs[2] & PVR2_USE_FPU_MASK))) { tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); t_gen_raise_exception(dc, EXCP_HW_EXCP); return; } qemu_log ("unimplemented FPU insn pc=%x opc=%x\n", dc->pc, dc->opcode); dc->abort_at_next_insn = 1; }
13,409
qemu
543f8f13e256a081dd820375e9575439b659ccd8
0
static void cdrom_pio_impl(int nblocks) { QPCIDevice *dev; QPCIBar bmdma_bar, ide_bar; FILE *fh; int patt_blocks = MAX(16, nblocks); size_t patt_len = ATAPI_BLOCK_SIZE * patt_blocks; char *pattern = g_malloc(patt_len); size_t rxsize = ATAPI_BLOCK_SIZE * nblocks; uint16_t *rx = g_malloc0(rxsize); int i, j; uint8_t data; uint16_t limit; /* Prepopulate the CDROM with an interesting pattern */ generate_pattern(pattern, patt_len, ATAPI_BLOCK_SIZE); fh = fopen(tmp_path, "w+"); fwrite(pattern, ATAPI_BLOCK_SIZE, patt_blocks, fh); fclose(fh); ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 " "-device ide-cd,drive=sr0,bus=ide.0", tmp_path); dev = get_pci_device(&bmdma_bar, &ide_bar); qtest_irq_intercept_in(global_qtest, "ioapic"); /* PACKET command on device 0 */ qpci_io_writeb(dev, ide_bar, reg_device, 0); qpci_io_writeb(dev, ide_bar, reg_lba_middle, BYTE_COUNT_LIMIT & 0xFF); qpci_io_writeb(dev, ide_bar, reg_lba_high, (BYTE_COUNT_LIMIT >> 8 & 0xFF)); qpci_io_writeb(dev, ide_bar, reg_command, CMD_PACKET); /* HP0: Check_Status_A State */ nsleep(400); data = ide_wait_clear(BSY); /* HP1: Send_Packet State */ assert_bit_set(data, DRQ | DRDY); assert_bit_clear(data, ERR | DF | BSY); /* SCSI CDB (READ10) -- read n*2048 bytes from block 0 */ send_scsi_cdb_read10(dev, ide_bar, 0, nblocks); /* Read data back: occurs in bursts of 'BYTE_COUNT_LIMIT' bytes. * If BYTE_COUNT_LIMIT is odd, we transfer BYTE_COUNT_LIMIT - 1 bytes. * We allow an odd limit only when the remaining transfer size is * less than BYTE_COUNT_LIMIT. However, SCSI's read10 command can only * request n blocks, so our request size is always even. * For this reason, we assume there is never a hanging byte to fetch. */ g_assert(!(rxsize & 1)); limit = BYTE_COUNT_LIMIT & ~1; for (i = 0; i < DIV_ROUND_UP(rxsize, limit); i++) { size_t offset = i * (limit / 2); size_t rem = (rxsize / 2) - offset; /* HP3: INTRQ_Wait */ ide_wait_intr(IDE_PRIMARY_IRQ); /* HP2: Check_Status_B (and clear IRQ) */ data = ide_wait_clear(BSY); assert_bit_set(data, DRQ | DRDY); assert_bit_clear(data, ERR | DF | BSY); /* HP4: Transfer_Data */ for (j = 0; j < MIN((limit / 2), rem); j++) { rx[offset + j] = cpu_to_le16(qpci_io_readw(dev, ide_bar, reg_data)); } } /* Check for final completion IRQ */ ide_wait_intr(IDE_PRIMARY_IRQ); /* Sanity check final state */ data = ide_wait_clear(DRQ); assert_bit_set(data, DRDY); assert_bit_clear(data, DRQ | ERR | DF | BSY); g_assert_cmpint(memcmp(pattern, rx, rxsize), ==, 0); g_free(pattern); g_free(rx); test_bmdma_teardown(); free_pci_device(dev); }
13,410
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
0
static uint32_t m5206_mbar_readw(void *opaque, target_phys_addr_t offset) { m5206_mbar_state *s = (m5206_mbar_state *)opaque; int width; offset &= 0x3ff; if (offset >= 0x200) { hw_error("Bad MBAR read offset 0x%x", (int)offset); } width = m5206_mbar_width[offset >> 2]; if (width > 2) { uint32_t val; val = m5206_mbar_readl(opaque, offset & ~3); if ((offset & 3) == 0) val >>= 16; return val & 0xffff; } else if (width < 2) { uint16_t val; val = m5206_mbar_readb(opaque, offset) << 8; val |= m5206_mbar_readb(opaque, offset + 1); return val; } return m5206_mbar_read(s, offset, 2); }
13,411
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
0
static void test_visitor_out_bool(TestOutputVisitorData *data, const void *unused) { bool value = true; QObject *obj; visit_type_bool(data->ov, NULL, &value, &error_abort); obj = visitor_get(data); g_assert(qobject_type(obj) == QTYPE_QBOOL); g_assert(qbool_get_bool(qobject_to_qbool(obj)) == value); }
13,412
qemu
18b21a2f83a26c3d6a9e7f0bdc4e8eb2b177e8f6
0
static void do_dcbz(target_ulong addr, int dcache_line_size) { addr &= ~(dcache_line_size - 1); int i; for (i = 0 ; i < dcache_line_size ; i += 4) { stl(addr + i , 0); } if (env->reserve == addr) env->reserve = (target_ulong)-1ULL; }
13,413
FFmpeg
f44b08a5a0ee46b52a9a608cbf2d075eab93db61
0
static void render_slice(Vp3DecodeContext *s, int slice) { int x, y; int m, n; int i; /* indicates current fragment */ int16_t *dequantizer; DCTELEM __align16 block[64]; unsigned char *output_plane; unsigned char *last_plane; unsigned char *golden_plane; int stride; int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef; int upper_motion_limit, lower_motion_limit; int motion_halfpel_index; uint8_t *motion_source; int plane; int plane_width; int plane_height; int slice_height; int current_macroblock_entry = slice * s->macroblock_width * 6; if (slice >= s->macroblock_height) return; for (plane = 0; plane < 3; plane++) { /* set up plane-specific parameters */ if (plane == 0) { output_plane = s->current_frame.data[0]; last_plane = s->last_frame.data[0]; golden_plane = s->golden_frame.data[0]; stride = s->current_frame.linesize[0]; if (!s->flipped_image) stride = -stride; upper_motion_limit = 7 * s->current_frame.linesize[0]; lower_motion_limit = s->height * s->current_frame.linesize[0] + s->width - 8; y = slice * FRAGMENT_PIXELS * 2; plane_width = s->width; plane_height = s->height; slice_height = y + FRAGMENT_PIXELS * 2; i = s->macroblock_fragments[current_macroblock_entry + 0]; } else if (plane == 1) { output_plane = s->current_frame.data[1]; last_plane = s->last_frame.data[1]; golden_plane = s->golden_frame.data[1]; stride = s->current_frame.linesize[1]; if (!s->flipped_image) stride = -stride; upper_motion_limit = 7 * s->current_frame.linesize[1]; lower_motion_limit = (s->height / 2) * s->current_frame.linesize[1] + (s->width / 2) - 8; y = slice * FRAGMENT_PIXELS; plane_width = s->width / 2; plane_height = s->height / 2; slice_height = y + FRAGMENT_PIXELS; i = s->macroblock_fragments[current_macroblock_entry + 4]; } else { output_plane = s->current_frame.data[2]; last_plane = s->last_frame.data[2]; golden_plane = s->golden_frame.data[2]; stride = s->current_frame.linesize[2]; if (!s->flipped_image) stride = -stride; upper_motion_limit = 7 * s->current_frame.linesize[2]; lower_motion_limit = (s->height / 2) * s->current_frame.linesize[2] + (s->width / 2) - 8; y = slice * FRAGMENT_PIXELS; plane_width = s->width / 2; plane_height = s->height / 2; slice_height = y + FRAGMENT_PIXELS; i = s->macroblock_fragments[current_macroblock_entry + 5]; } if(ABS(stride) > 2048) return; //various tables are fixed size /* for each fragment row in the slice (both of them)... */ for (; y < slice_height; y += 8) { /* for each fragment in a row... */ for (x = 0; x < plane_width; x += 8, i++) { if ((i < 0) || (i >= s->fragment_count)) { av_log(s->avctx, AV_LOG_ERROR, " vp3:render_slice(): bad fragment number (%d)\n", i); return; } /* transform if this block was coded */ if ((s->all_fragments[i].coding_method != MODE_COPY) && !((s->avctx->flags & CODEC_FLAG_GRAY) && plane)) { if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) || (s->all_fragments[i].coding_method == MODE_GOLDEN_MV)) motion_source= golden_plane; else motion_source= last_plane; motion_source += s->all_fragments[i].first_pixel; motion_halfpel_index = 0; /* sort out the motion vector if this fragment is coded * using a motion vector method */ if ((s->all_fragments[i].coding_method > MODE_INTRA) && (s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) { int src_x, src_y; motion_x = s->all_fragments[i].motion_x; motion_y = s->all_fragments[i].motion_y; if(plane){ motion_x= (motion_x>>1) | (motion_x&1); motion_y= (motion_y>>1) | (motion_y&1); } src_x= (motion_x>>1) + x; src_y= (motion_y>>1) + y; if ((motion_x == 127) || (motion_y == 127)) av_log(s->avctx, AV_LOG_ERROR, " help! got invalid motion vector! (%X, %X)\n", motion_x, motion_y); motion_halfpel_index = motion_x & 0x01; motion_source += (motion_x >> 1); motion_halfpel_index |= (motion_y & 0x01) << 1; motion_source += ((motion_y >> 1) * stride); if(src_x<0 || src_y<0 || src_x + 9 >= plane_width || src_y + 9 >= plane_height){ uint8_t *temp= s->edge_emu_buffer; if(stride<0) temp -= 9*stride; else temp += 9*stride; ff_emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, plane_width, plane_height); motion_source= temp; } } /* first, take care of copying a block from either the * previous or the golden frame */ if (s->all_fragments[i].coding_method != MODE_INTRA) { /* Note, it is possible to implement all MC cases with put_no_rnd_pixels_l2 which would look more like the VP3 source but this would be slower as put_no_rnd_pixels_tab is better optimzed */ if(motion_halfpel_index != 3){ s->dsp.put_no_rnd_pixels_tab[1][motion_halfpel_index]( output_plane + s->all_fragments[i].first_pixel, motion_source, stride, 8); }else{ int d= (motion_x ^ motion_y)>>31; // d is 0 if motion_x and _y have the same sign, else -1 s->dsp.put_no_rnd_pixels_l2[1]( output_plane + s->all_fragments[i].first_pixel, motion_source - d, motion_source + stride + 1 + d, stride, 8); } dequantizer = s->inter_dequant; }else{ if (plane == 0) dequantizer = s->intra_y_dequant; else dequantizer = s->intra_c_dequant; } /* dequantize the DCT coefficients */ debug_idct("fragment %d, coding mode %d, DC = %d, dequant = %d:\n", i, s->all_fragments[i].coding_method, DC_COEFF(i), dequantizer[0]); if(s->avctx->idct_algo==FF_IDCT_VP3){ Coeff *coeff= s->coeffs + i; memset(block, 0, sizeof(block)); while(coeff->next){ block[coeff->index]= coeff->coeff * dequantizer[coeff->index]; coeff= coeff->next; } }else{ Coeff *coeff= s->coeffs + i; memset(block, 0, sizeof(block)); while(coeff->next){ block[coeff->index]= (coeff->coeff * dequantizer[coeff->index] + 2)>>2; coeff= coeff->next; } } /* invert DCT and place (or add) in final output */ if (s->all_fragments[i].coding_method == MODE_INTRA) { if(s->avctx->idct_algo!=FF_IDCT_VP3) block[0] += 128<<3; s->dsp.idct_put( output_plane + s->all_fragments[i].first_pixel, stride, block); } else { s->dsp.idct_add( output_plane + s->all_fragments[i].first_pixel, stride, block); } debug_idct("block after idct_%s():\n", (s->all_fragments[i].coding_method == MODE_INTRA)? "put" : "add"); for (m = 0; m < 8; m++) { for (n = 0; n < 8; n++) { debug_idct(" %3d", *(output_plane + s->all_fragments[i].first_pixel + (m * stride + n))); } debug_idct("\n"); } debug_idct("\n"); } else { /* copy directly from the previous frame */ s->dsp.put_pixels_tab[1][0]( output_plane + s->all_fragments[i].first_pixel, last_plane + s->all_fragments[i].first_pixel, stride, 8); } } } } /* future loop filter logic goes here... */ /* algorithm: * if (slice != 0) * run filter on 1st row of Y slice * run filter on U slice * run filter on V slice * run filter on 2nd row of Y slice */ /* this looks like a good place for slice dispatch... */ /* algorithm: * if (slice > 0) * dispatch (slice - 1); * if (slice == s->macroblock_height - 1) * dispatch (slice); // handle last slice */ emms_c(); }
13,414
qemu
d14a68b6dc0cc01ddd4c1c7c5907b95c3938679c
0
match_insn_m68k (bfd_vma memaddr, disassemble_info * info, const struct m68k_opcode * best, struct private * priv) { unsigned char *save_p; unsigned char *p; const char *d; bfd_byte *buffer = priv->the_buffer; fprintf_ftype save_printer = info->fprintf_func; void (* save_print_address) (bfd_vma, struct disassemble_info *) = info->print_address_func; /* Point at first word of argument data, and at descriptor for first argument. */ p = buffer + 2; /* Figure out how long the fixed-size portion of the instruction is. The only place this is stored in the opcode table is in the arguments--look for arguments which specify fields in the 2nd or 3rd words of the instruction. */ for (d = best->args; *d; d += 2) { /* I don't think it is necessary to be checking d[0] here; I suspect all this could be moved to the case statement below. */ if (d[0] == '#') { if (d[1] == 'l' && p - buffer < 6) p = buffer + 6; else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8') p = buffer + 4; } if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4) p = buffer + 4; switch (d[1]) { case '1': case '2': case '3': case '7': case '8': case '9': case 'i': if (p - buffer < 4) p = buffer + 4; break; case '4': case '5': case '6': if (p - buffer < 6) p = buffer + 6; break; default: break; } } /* pflusha is an exceptions. It takes no arguments but is two words long. Recognize it by looking at the lower 16 bits of the mask. */ if (p - buffer < 4 && (best->match & 0xFFFF) != 0) p = buffer + 4; /* lpstop is another exception. It takes a one word argument but is three words long. */ if (p - buffer < 6 && (best->match & 0xffff) == 0xffff && best->args[0] == '#' && best->args[1] == 'w') { /* Copy the one word argument into the usual location for a one word argument, to simplify printing it. We can get away with this because we know exactly what the second word is, and we aren't going to print anything based on it. */ p = buffer + 6; FETCH_DATA (info, p); buffer[2] = buffer[4]; buffer[3] = buffer[5]; } FETCH_DATA (info, p); d = best->args; save_p = p; info->print_address_func = dummy_print_address; info->fprintf_func = (fprintf_ftype) dummy_printer; /* We scan the operands twice. The first time we don't print anything, but look for errors. */ for (; *d; d += 2) { int eaten = print_insn_arg (d, buffer, p, memaddr + (p - buffer), info); if (eaten >= 0) p += eaten; else if (eaten == -1) { info->fprintf_func = save_printer; info->print_address_func = save_print_address; return 0; } else { info->fprintf_func (info->stream, /* xgettext:c-format */ _("<internal error in opcode table: %s %s>\n"), best->name, best->args); info->fprintf_func = save_printer; info->print_address_func = save_print_address; return 2; } } p = save_p; info->fprintf_func = save_printer; info->print_address_func = save_print_address; d = best->args; info->fprintf_func (info->stream, "%s", best->name); if (*d) info->fprintf_func (info->stream, " "); while (*d) { p += print_insn_arg (d, buffer, p, memaddr + (p - buffer), info); d += 2; if (*d && *(d - 2) != 'I' && *d != 'k') info->fprintf_func (info->stream, ","); } return p - buffer; }
13,416
qemu
8a5956ad6392f115521dad774055c737c49fb0dd
0
static void rcu_qtest_init(void) { struct list_element *new_el; int i; nthreadsrunning = 0; srand(time(0)); for (i = 0; i < RCU_Q_LEN; i++) { new_el = g_new(struct list_element, 1); new_el->val = i; QLIST_INSERT_HEAD_RCU(&Q_list_head, new_el, entry); } atomic_add(&n_nodes, RCU_Q_LEN); }
13,417
qemu
d1b4259f1ab18af24e6a297edb6a8f71691f3256
0
static void virtio_ccw_bus_class_init(ObjectClass *klass, void *data) { VirtioBusClass *k = VIRTIO_BUS_CLASS(klass); BusClass *bus_class = BUS_CLASS(klass); bus_class->max_dev = 1; k->notify = virtio_ccw_notify; k->vmstate_change = virtio_ccw_vmstate_change; k->query_guest_notifiers = virtio_ccw_query_guest_notifiers; k->set_guest_notifiers = virtio_ccw_set_guest_notifiers; k->save_queue = virtio_ccw_save_queue; k->load_queue = virtio_ccw_load_queue; k->save_config = virtio_ccw_save_config; k->load_config = virtio_ccw_load_config; k->device_plugged = virtio_ccw_device_plugged; k->post_plugged = virtio_ccw_post_plugged; k->device_unplugged = virtio_ccw_device_unplugged; k->ioeventfd_started = virtio_ccw_ioeventfd_started; k->ioeventfd_set_started = virtio_ccw_ioeventfd_set_started; k->ioeventfd_disabled = virtio_ccw_ioeventfd_disabled; k->ioeventfd_set_disabled = virtio_ccw_ioeventfd_set_disabled; k->ioeventfd_assign = virtio_ccw_ioeventfd_assign; }
13,418
qemu
57407ea44cc0a3d630b9b89a2be011f1955ce5c1
0
static void lan9118_cleanup(NetClientState *nc) { lan9118_state *s = qemu_get_nic_opaque(nc); s->nic = NULL; }
13,419
qemu
4efe27556dea874030f1cd53a6d70452ee064fba
0
void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, unsigned long vga_ram_offset, int vga_ram_size) { PCICirrusVGAState *d; uint8_t *pci_conf; CirrusVGAState *s; int device_id; device_id = CIRRUS_ID_CLGD5446; /* setup PCI configuration registers */ d = (PCICirrusVGAState *)pci_register_device(bus, "Cirrus VGA", sizeof(PCICirrusVGAState), -1, NULL, NULL); pci_conf = d->dev.config; pci_conf[0x00] = (uint8_t) (PCI_VENDOR_CIRRUS & 0xff); pci_conf[0x01] = (uint8_t) (PCI_VENDOR_CIRRUS >> 8); pci_conf[0x02] = (uint8_t) (device_id & 0xff); pci_conf[0x03] = (uint8_t) (device_id >> 8); pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS; pci_conf[0x0a] = PCI_CLASS_SUB_VGA; pci_conf[0x0b] = PCI_CLASS_BASE_DISPLAY; pci_conf[0x0e] = PCI_CLASS_HEADERTYPE_00h; /* setup VGA */ s = &d->cirrus_vga; vga_common_init((VGAState *)s, ds, vga_ram_base, vga_ram_offset, vga_ram_size); cirrus_init_common(s, device_id, 1); s->console = graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump, s->text_update, s); s->pci_dev = (PCIDevice *)d; /* setup memory space */ /* memory #0 LFB */ /* memory #1 memory-mapped I/O */ /* XXX: s->vram_size must be a power of two */ pci_register_io_region((PCIDevice *)d, 0, 0x2000000, PCI_ADDRESS_SPACE_MEM_PREFETCH, cirrus_pci_lfb_map); if (device_id == CIRRUS_ID_CLGD5446) { pci_register_io_region((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE, PCI_ADDRESS_SPACE_MEM, cirrus_pci_mmio_map); } /* XXX: ROM BIOS */ }
13,420
qemu
a178274efabcbbc5d44805b51def874e47051325
0
static void spapr_io_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { switch (size) { case 1: cpu_outb(addr, data); return; case 2: cpu_outw(addr, data); return; case 4: cpu_outl(addr, data); return; } assert(0); }
13,421
qemu
8cfacf079047c50d272ce64e45a78d816db8b36e
0
static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); int buflen = 0; if (req->cmd.buf[1] & 0x2) { /* Command support data - optional, not implemented */ BADF("optional INQUIRY command support request not implemented\n"); return -1; } if (req->cmd.buf[1] & 0x1) { /* Vital product data */ uint8_t page_code = req->cmd.buf[2]; if (req->cmd.xfer < 4) { BADF("Error: Inquiry (EVPD[%02X]) buffer size %zd is " "less than 4\n", page_code, req->cmd.xfer); return -1; } if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) { outbuf[buflen++] = 5; } else { outbuf[buflen++] = 0; } outbuf[buflen++] = page_code ; // this page outbuf[buflen++] = 0x00; switch (page_code) { case 0x00: /* Supported page codes, mandatory */ DPRINTF("Inquiry EVPD[Supported pages] " "buffer size %zd\n", req->cmd.xfer); outbuf[buflen++] = 4; // number of pages outbuf[buflen++] = 0x00; // list of supported pages (this page) outbuf[buflen++] = 0x80; // unit serial number outbuf[buflen++] = 0x83; // device identification outbuf[buflen++] = 0xb0; // block device characteristics break; case 0x80: /* Device serial number, optional */ { const char *serial = req->dev->conf.dinfo->serial ? req->dev->conf.dinfo->serial : "0"; int l = strlen(serial); if (l > req->cmd.xfer) l = req->cmd.xfer; if (l > 20) l = 20; DPRINTF("Inquiry EVPD[Serial number] " "buffer size %zd\n", req->cmd.xfer); outbuf[buflen++] = l; memcpy(outbuf+buflen, serial, l); buflen += l; break; } case 0x83: /* Device identification page, mandatory */ { int max_len = 255 - 8; int id_len = strlen(bdrv_get_device_name(s->bs)); if (id_len > max_len) id_len = max_len; DPRINTF("Inquiry EVPD[Device identification] " "buffer size %zd\n", req->cmd.xfer); outbuf[buflen++] = 3 + id_len; outbuf[buflen++] = 0x2; // ASCII outbuf[buflen++] = 0; // not officially assigned outbuf[buflen++] = 0; // reserved outbuf[buflen++] = id_len; // length of data following memcpy(outbuf+buflen, bdrv_get_device_name(s->bs), id_len); buflen += id_len; break; } case 0xb0: /* block device characteristics */ { unsigned int min_io_size = s->qdev.conf.min_io_size >> 9; unsigned int opt_io_size = s->qdev.conf.opt_io_size >> 9; /* required VPD size with unmap support */ outbuf[3] = buflen = 0x3c; memset(outbuf + 4, 0, buflen - 4); /* optimal transfer length granularity */ outbuf[6] = (min_io_size >> 8) & 0xff; outbuf[7] = min_io_size & 0xff; /* optimal transfer length */ outbuf[12] = (opt_io_size >> 24) & 0xff; outbuf[13] = (opt_io_size >> 16) & 0xff; outbuf[14] = (opt_io_size >> 8) & 0xff; outbuf[15] = opt_io_size & 0xff; break; } default: BADF("Error: unsupported Inquiry (EVPD[%02X]) " "buffer size %zd\n", page_code, req->cmd.xfer); return -1; } /* done with EVPD */ return buflen; } /* Standard INQUIRY data */ if (req->cmd.buf[2] != 0) { BADF("Error: Inquiry (STANDARD) page or code " "is non-zero [%02X]\n", req->cmd.buf[2]); return -1; } /* PAGE CODE == 0 */ if (req->cmd.xfer < 5) { BADF("Error: Inquiry (STANDARD) buffer size %zd " "is less than 5\n", req->cmd.xfer); return -1; } buflen = req->cmd.xfer; if (buflen > SCSI_MAX_INQUIRY_LEN) buflen = SCSI_MAX_INQUIRY_LEN; memset(outbuf, 0, buflen); if (req->lun || req->cmd.buf[1] >> 5) { outbuf[0] = 0x7f; /* LUN not supported */ return buflen; } if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) { outbuf[0] = 5; outbuf[1] = 0x80; memcpy(&outbuf[16], "QEMU CD-ROM ", 16); } else { outbuf[0] = 0; memcpy(&outbuf[16], "QEMU HARDDISK ", 16); } memcpy(&outbuf[8], "QEMU ", 8); memcpy(&outbuf[32], s->version ? s->version : QEMU_VERSION, 4); /* * We claim conformance to SPC-3, which is required for guests * to ask for modern features like READ CAPACITY(16) or the * block characteristics VPD page by default. Not all of SPC-3 * is actually implemented, but we're good enough. */ outbuf[2] = 5; outbuf[3] = 2; /* Format 2 */ if (buflen > 36) { outbuf[4] = buflen - 5; /* Additional Length = (Len - 1) - 4 */ } else { /* If the allocation length of CDB is too small, the additional length is not adjusted */ outbuf[4] = 36 - 5; } /* Sync data transfer and TCQ. */ outbuf[7] = 0x10 | (req->bus->tcq ? 0x02 : 0); return buflen; }
13,422
qemu
eed2bacfd2519e45498b585a147f11b0fd01c3c7
0
static AddressSpace *memory_region_to_address_space(MemoryRegion *mr) { AddressSpace *as; while (mr->container) { mr = mr->container; } QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { if (mr == as->root) { return as; } } abort(); }
13,423
FFmpeg
c49c5e23dc3fb273b46440656f74d416bcc9ab41
0
static void bastardized_rice_decompress(ALACContext *alac, int32_t *output_buffer, int output_size, int readsamplesize, /* arg_10 */ int rice_initialhistory, /* arg424->b */ int rice_kmodifier, /* arg424->d */ int rice_historymult, /* arg424->c */ int rice_kmodifier_mask /* arg424->e */ ) { int output_count; unsigned int history = rice_initialhistory; int sign_modifier = 0; for (output_count = 0; output_count < output_size; output_count++) { int32_t x; int32_t x_modified; int32_t final_val; /* read x - number of 1s before 0 represent the rice */ x = get_unary_0_9(&alac->gb); if (x > 8) { /* RICE THRESHOLD */ /* use alternative encoding */ x = get_bits(&alac->gb, readsamplesize); } else { /* standard rice encoding */ int extrabits; int k; /* size of extra bits */ /* read k, that is bits as is */ k = 31 - count_leading_zeros((history >> 9) + 3); if (k >= rice_kmodifier) k = rice_kmodifier; if (k != 1) { extrabits = show_bits(&alac->gb, k); /* multiply x by 2^k - 1, as part of their strange algorithm */ x = (x << k) - x; if (extrabits > 1) { x += extrabits - 1; skip_bits(&alac->gb, k); } else skip_bits(&alac->gb, k - 1); } } x_modified = sign_modifier + x; final_val = (x_modified + 1) / 2; if (x_modified & 1) final_val *= -1; output_buffer[output_count] = final_val; sign_modifier = 0; /* now update the history */ history += x_modified * rice_historymult - ((history * rice_historymult) >> 9); if (x_modified > 0xffff) history = 0xffff; /* special case: there may be compressed blocks of 0 */ if ((history < 128) && (output_count+1 < output_size)) { int block_size; sign_modifier = 1; x = get_unary_0_9(&alac->gb); if (x > 8) { block_size = get_bits(&alac->gb, 16); } else { int k; int extrabits; k = count_leading_zeros(history) + ((history + 16) >> 6 /* / 64 */) - 24; extrabits = show_bits(&alac->gb, k); block_size = (((1 << k) - 1) & rice_kmodifier_mask) * x + extrabits - 1; if (extrabits < 2) { x = 1 - extrabits; block_size += x; skip_bits(&alac->gb, k - 1); } else { skip_bits(&alac->gb, k); } } if (block_size > 0) { memset(&output_buffer[output_count+1], 0, block_size * 4); output_count += block_size; } if (block_size > 0xffff) sign_modifier = 0; history = 0; } } }
13,425
qemu
504e56ebdca53bf8e8d379aa994e90a2e3b0d564
0
void OPPROTO op_int_im(void) { EIP = PARAM1; raise_exception(EXCP0D_GPF); }
13,428
qemu
7d1b0095bff7157e856d1d0e6c4295641ced2752
1
static inline TCGv gen_ld16s(TCGv addr, int index) { TCGv tmp = new_tmp(); tcg_gen_qemu_ld16s(tmp, addr, index); return tmp; }
13,430
FFmpeg
b88be742fac7a77a8095e8155ba8790db4b77568
1
static av_cold int vc2_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { int ret; int max_frame_bytes, sig_size = 256; VC2EncContext *s = avctx->priv_data; const char aux_data[] = LIBAVCODEC_IDENT; const int aux_data_size = sizeof(aux_data); const int header_size = 100 + aux_data_size; int64_t r_bitrate = avctx->bit_rate >> (s->interlaced); s->avctx = avctx; s->size_scaler = 1; s->prefix_bytes = 0; s->last_parse_code = 0; s->next_parse_offset = 0; /* Rate control */ max_frame_bytes = (av_rescale(r_bitrate, s->avctx->time_base.num, s->avctx->time_base.den) >> 3) - header_size; /* Find an appropriate size scaler */ while (sig_size > 255) { s->slice_max_bytes = FFALIGN(av_rescale(max_frame_bytes, 1, s->num_x*s->num_y), s->size_scaler); s->slice_max_bytes += 4 + s->prefix_bytes; sig_size = s->slice_max_bytes/s->size_scaler; /* Signalled slize size */ s->size_scaler <<= 1; } s->slice_min_bytes = s->slice_max_bytes - s->slice_max_bytes*(s->tolerance/100.0f); ret = ff_alloc_packet2(avctx, avpkt, max_frame_bytes*3, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return ret; } else { init_put_bits(&s->pb, avpkt->data, avpkt->size); } encode_frame(s, frame, aux_data, s->interlaced); if (s->interlaced) encode_frame(s, frame, NULL, 2); flush_put_bits(&s->pb); avpkt->size = put_bits_count(&s->pb) >> 3; *got_packet_ptr = 1; return 0; }
13,431
qemu
898248a32915024a4f01ce4f0c3519509fb703cb
1
static inline int xhci_running(XHCIState *xhci) { return !(xhci->usbsts & USBSTS_HCH) && !xhci->intr[0].er_full; }
13,432
qemu
a33eda0dd99e00faa3bacae43d19490bb9500e07
1
static int local_utimensat(FsContext *s, V9fsPath *fs_path, const struct timespec *buf) { char *buffer; int ret; char *path = fs_path->data; buffer = rpath(s, path); ret = qemu_utimens(buffer, buf); g_free(buffer); return ret; }
13,433
qemu
1f51470d044852592922f91000e741c381582cdc
1
static int qemu_chr_open_stdio(QemuOpts *opts, CharDriverState **_chr) { CharDriverState *chr; if (stdio_nb_clients >= STDIO_MAX_CLIENTS) { return -EBUSY; } if (stdio_nb_clients == 0) { old_fd0_flags = fcntl(0, F_GETFL); tcgetattr (0, &oldtty); fcntl(0, F_SETFL, O_NONBLOCK); atexit(term_exit); } chr = qemu_chr_open_fd(0, 1); chr->chr_close = qemu_chr_close_stdio; chr->chr_set_echo = qemu_chr_set_echo_stdio; qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr); stdio_nb_clients++; stdio_allow_signal = qemu_opt_get_bool(opts, "signal", display_type != DT_NOGRAPHIC); qemu_chr_fe_set_echo(chr, false); *_chr = chr; return 0; }
13,434
qemu
5839e53bbc0fec56021d758aab7610df421ed8c8
1
static int qemu_gluster_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { int ret = 0; BDRVGlusterReopenState *reop_s; GlusterConf *gconf = NULL; int open_flags = 0; assert(state != NULL); assert(state->bs != NULL); state->opaque = g_malloc0(sizeof(BDRVGlusterReopenState)); reop_s = state->opaque; qemu_gluster_parse_flags(state->flags, &open_flags); gconf = g_malloc0(sizeof(GlusterConf)); reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, errp); if (reop_s->glfs == NULL) { ret = -errno; goto exit; } reop_s->fd = glfs_open(reop_s->glfs, gconf->image, open_flags); if (reop_s->fd == NULL) { /* reops->glfs will be cleaned up in _abort */ ret = -errno; goto exit; } exit: /* state->opaque will be freed in either the _abort or _commit */ qemu_gluster_gconf_free(gconf); return ret; }
13,435
FFmpeg
4ff94558f23a5de43aed4ca3429963dd1d995250
1
static void cabac_reinit(HEVCLocalContext *lc) { skip_bytes(&lc->cc, 0); }
13,436
FFmpeg
636ced8e1dc8248a1353b416240b93d70ad03edb
1
static int write_option(void *optctx, const OptionDef *po, const char *opt, const char *arg) { /* new-style options contain an offset into optctx, old-style address of * a global var*/ void *dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? (uint8_t *)optctx + po->u.off : po->u.dst_ptr; int *dstcount; if (po->flags & OPT_SPEC) { SpecifierOpt **so = dst; char *p = strchr(opt, ':'); dstcount = (int *)(so + 1); *so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1); (*so)[*dstcount - 1].specifier = av_strdup(p ? p + 1 : ""); dst = &(*so)[*dstcount - 1].u; } if (po->flags & OPT_STRING) { char *str; str = av_strdup(arg); av_freep(dst); *(char **)dst = str; } else if (po->flags & OPT_BOOL || po->flags & OPT_INT) { *(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); } else if (po->flags & OPT_INT64) { *(int64_t *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); } else if (po->flags & OPT_TIME) { *(int64_t *)dst = parse_time_or_die(opt, arg, 1); } else if (po->flags & OPT_FLOAT) { *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); } else if (po->flags & OPT_DOUBLE) { *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); } else if (po->u.func_arg) { int ret = po->u.func_arg(optctx, opt, arg); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Failed to set value '%s' for option '%s'\n", arg, opt); return ret; } } if (po->flags & OPT_EXIT) exit(0); return 0; }
13,438
qemu
81174dae3f9189519cd60c7b79e91c291b021bbe
1
static uint32_t serial_ioport_read(void *opaque, uint32_t addr) { SerialState *s = opaque; uint32_t ret; addr &= 7; switch(addr) { default: case 0: if (s->lcr & UART_LCR_DLAB) { ret = s->divider & 0xff; } else { ret = s->rbr; s->lsr &= ~(UART_LSR_DR | UART_LSR_BI); serial_update_irq(s); if (!(s->mcr & UART_MCR_LOOP)) { /* in loopback mode, don't receive any data */ qemu_chr_accept_input(s->chr); } } break; case 1: if (s->lcr & UART_LCR_DLAB) { ret = (s->divider >> 8) & 0xff; } else { ret = s->ier; } break; case 2: ret = s->iir; /* reset THR pending bit */ if ((ret & 0x7) == UART_IIR_THRI) s->thr_ipending = 0; serial_update_irq(s); break; case 3: ret = s->lcr; break; case 4: ret = s->mcr; break; case 5: ret = s->lsr; break; case 6: if (s->mcr & UART_MCR_LOOP) { /* in loopback, the modem output pins are connected to the inputs */ ret = (s->mcr & 0x0c) << 4; ret |= (s->mcr & 0x02) << 3; ret |= (s->mcr & 0x01) << 5; } else { ret = s->msr; } break; case 7: ret = s->scr; break; } #ifdef DEBUG_SERIAL printf("serial: read addr=0x%02x val=0x%02x\n", addr, ret); #endif return ret; }
13,439
qemu
ee640c625e190a0c0e6b8966adc0e4720fb75200
1
e1000e_init_msix(E1000EState *s) { PCIDevice *d = PCI_DEVICE(s); int res = msix_init(PCI_DEVICE(s), E1000E_MSIX_VEC_NUM, &s->msix, E1000E_MSIX_IDX, E1000E_MSIX_TABLE, &s->msix, E1000E_MSIX_IDX, E1000E_MSIX_PBA, 0xA0); if (res < 0) { trace_e1000e_msix_init_fail(res); } else { if (!e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM)) { msix_uninit(d, &s->msix, &s->msix); } } }
13,440
FFmpeg
857cd1f33bcf86005529af2a77f861f884327be5
0
static int RENAME(resample_linear)(ResampleContext *c, DELEM *dst, const DELEM *src, int n, int update_ctx) { int dst_index; int index= c->index; int frac= c->frac; int sample_index = index >> c->phase_shift; #if FILTER_SHIFT == 0 double inv_src_incr = 1.0 / c->src_incr; #endif index &= c->phase_mask; for (dst_index = 0; dst_index < n; dst_index++) { FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index; FELEM2 val=0, v2 = 0; int i; for (i = 0; i < c->filter_length; i++) { val += src[sample_index + i] * (FELEM2)filter[i]; v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_alloc]; } #ifdef FELEML val += (v2 - val) * (FELEML) frac / c->src_incr; #else # if FILTER_SHIFT == 0 val += (v2 - val) * inv_src_incr * frac; # else val += (v2 - val) / c->src_incr * frac; # endif #endif OUT(dst[dst_index], val); frac += c->dst_incr_mod; index += c->dst_incr_div; if (frac >= c->src_incr) { frac -= c->src_incr; index++; } sample_index += index >> c->phase_shift; index &= c->phase_mask; } if(update_ctx){ c->frac= frac; c->index= index; } return sample_index; }
13,441
FFmpeg
68f593b48433842f3407586679fe07f3e5199ab9
0
int ff_h263_resync(MpegEncContext *s){ int left, ret; if(s->codec_id==CODEC_ID_MPEG4) skip_bits1(&s->gb); align_get_bits(&s->gb); if(show_bits(&s->gb, 16)==0){ if(s->codec_id==CODEC_ID_MPEG4) ret= mpeg4_decode_video_packet_header(s); else ret= h263_decode_gob_header(s); if(ret>=0) return 0; } //ok, its not where its supposed to be ... s->gb= s->last_resync_gb; align_get_bits(&s->gb); left= s->gb.size*8 - get_bits_count(&s->gb); for(;left>16+1+5+5; left-=8){ if(show_bits(&s->gb, 16)==0){ GetBitContext bak= s->gb; if(s->codec_id==CODEC_ID_MPEG4) ret= mpeg4_decode_video_packet_header(s); else ret= h263_decode_gob_header(s); if(ret>=0) return 0; s->gb= bak; } skip_bits(&s->gb, 8); } return -1; }
13,443
qemu
9e559533bd825a3e371497875576137a8586c831
1
static void aio_write_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; struct timeval t2; gettimeofday(&t2, NULL); if (ret < 0) { printf("aio_write failed: %s\n", strerror(-ret)); goto out; } if (ctx->qflag) { goto out; } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, ctx->t1); print_report("wrote", &t2, ctx->offset, ctx->qiov.size, ctx->qiov.size, 1, ctx->Cflag); out: qemu_io_free(ctx->buf); g_free(ctx); }
13,444
FFmpeg
c23acbaed40101c677dfcfbbfe0d2c230a8e8f44
1
static void add_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels, int line_size) { int i; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; /* read the pixels */ for(i=0;i<2;i++) { pixels[0] = cm[pixels[0] + block[0]]; pixels[1] = cm[pixels[1] + block[1]]; pixels += line_size; block += 8; } }
13,445
FFmpeg
fd54dd028bc9f7bfb80ebf823a533dc84b73f936
1
static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s) { Jpeg2000CodingStyle *codsty = s->codsty; Jpeg2000QuantStyle *qntsty = s->qntsty; uint8_t *properties = s->properties; for (;;) { int len, ret = 0; uint16_t marker; int oldpos; if (bytestream2_get_bytes_left(&s->g) < 2) { av_log(s->avctx, AV_LOG_ERROR, "Missing EOC\n"); break; } marker = bytestream2_get_be16u(&s->g); oldpos = bytestream2_tell(&s->g); if (marker == JPEG2000_EOC) break; if (bytestream2_get_bytes_left(&s->g) < 2) return AVERROR_INVALIDDATA; len = bytestream2_get_be16u(&s->g); switch (marker) { case JPEG2000_SIZ: ret = get_siz(s); break; case JPEG2000_COC: ret = get_coc(s, codsty, properties); break; case JPEG2000_COD: ret = get_cod(s, codsty, properties); break; case JPEG2000_QCC: ret = get_qcc(s, len, qntsty, properties); break; case JPEG2000_QCD: ret = get_qcd(s, len, qntsty, properties); break; case JPEG2000_SOT: ret = get_sot(s, len); break; case JPEG2000_COM: // the comment is ignored bytestream2_skip(&s->g, len - 2); break; case JPEG2000_TLM: // Tile-part lengths ret = get_tlm(s, len); break; default: av_log(s->avctx, AV_LOG_ERROR, "unsupported marker 0x%.4X at pos 0x%X\n", marker, bytestream2_tell(&s->g) - 4); bytestream2_skip(&s->g, len - 2); break; } if (((bytestream2_tell(&s->g) - oldpos != len) && (marker != JPEG2000_SOT)) || ret) { av_log(s->avctx, AV_LOG_ERROR, "error during processing marker segment %.4x\n", marker); return ret ? ret : -1; } } return 0; }
13,446
qemu
3e4f910c8d490a1490409a7e381dbbb229f9d272
1
static void ehci_reset(void *opaque) { EHCIState *s = opaque; int i; USBDevice *devs[NB_PORTS]; trace_usb_ehci_reset(); /* * Do the detach before touching portsc, so that it correctly gets send to * us or to our companion based on PORTSC_POWNER before the reset. */ for(i = 0; i < NB_PORTS; i++) { devs[i] = s->ports[i].dev; if (devs[i] && devs[i]->attached) { usb_detach(&s->ports[i]); } } memset(&s->mmio[OPREGBASE], 0x00, MMIO_SIZE - OPREGBASE); s->usbcmd = NB_MAXINTRATE << USBCMD_ITC_SH; s->usbsts = USBSTS_HALT; s->usbsts_pending = 0; s->usbsts_frindex = 0; s->astate = EST_INACTIVE; s->pstate = EST_INACTIVE; for(i = 0; i < NB_PORTS; i++) { if (s->companion_ports[i]) { s->portsc[i] = PORTSC_POWNER | PORTSC_PPOWER; } else { s->portsc[i] = PORTSC_PPOWER; } if (devs[i] && devs[i]->attached) { usb_attach(&s->ports[i]); usb_device_reset(devs[i]); } } ehci_queues_rip_all(s, 0); ehci_queues_rip_all(s, 1); qemu_del_timer(s->frame_timer); qemu_bh_cancel(s->async_bh); }
13,447
qemu
6f2d8978728c48ca46f5c01835438508aace5c64
1
void OPPROTO op_POWER_slq (void) { uint32_t msk = -1, tmp; msk = msk << (T1 & 0x1FUL); if (T1 & 0x20UL) msk = ~msk; T1 &= 0x1FUL; tmp = rotl32(T0, T1); T0 = tmp & msk; env->spr[SPR_MQ] = tmp; RETURN(); }
13,450
FFmpeg
5e885275f1eda3f0281747d9c78d072adb8bc940
1
int ff_MPV_lowest_referenced_row(MpegEncContext *s, int dir) { int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->quarter_sample; int my, off, i, mvs; if (s->picture_structure != PICT_FRAME) goto unhandled; switch (s->mv_type) { case MV_TYPE_16X16: mvs = 1; break; case MV_TYPE_16X8: mvs = 2; break; case MV_TYPE_8X8: mvs = 4; break; default: goto unhandled; } for (i = 0; i < mvs; i++) { my = s->mv[dir][i][1]<<qpel_shift; my_max = FFMAX(my_max, my); my_min = FFMIN(my_min, my); } off = (FFMAX(-my_min, my_max) + 63) >> 6; return FFMIN(FFMAX(s->mb_y + off, 0), s->mb_height-1); unhandled: return s->mb_height-1; }
13,451
FFmpeg
0d21a84605bad4e75dacb8196e5859902ed36f01
0
static inline int snake_search(MpegEncContext * s, int *best, int dmin, UINT8 *new_pic, UINT8 *old_pic, int pic_stride, int pred_x, int pred_y, UINT16 *mv_penalty, int quant, int xmin, int ymin, int xmax, int ymax, int shift) { int dir=0; int c=1; static int x_dir[8]= {1,1,0,-1,-1,-1, 0, 1}; static int y_dir[8]= {0,1,1, 1, 0,-1,-1,-1}; int fails=0; int last_d[2]={dmin, dmin}; /*static int good=0; static int bad=0; static int point=0; point++; if(256*256*256*64%point==0) { printf("%d %d %d\n", good, bad, point); }*/ for(;;){ int x= best[0]; int y= best[1]; int d; x+=x_dir[dir]; y+=y_dir[dir]; if(x>=xmin && x<=xmax && y>=ymin && y<=ymax){ d = pix_abs16x16(new_pic, old_pic + (x) + (y)*pic_stride, pic_stride); d += (mv_penalty[((x)<<shift)-pred_x] + mv_penalty[((y)<<shift)-pred_y])*quant; }else{ d = dmin + 10000; //FIXME smarter boundary handling } if(d<dmin){ best[0]=x; best[1]=y; dmin=d; if(last_d[1] - last_d[0] > last_d[0] - d) c= -c; dir+=c; fails=0; //good++; last_d[1]=last_d[0]; last_d[0]=d; }else{ //bad++; if(fails){ if(fails>=3) return dmin; }else{ c= -c; } dir+=c*2; fails++; } dir&=7; } }
13,452
qemu
e155494cf0b876c45c3c68a9ab6c641aac22dfdf
1
static int qio_channel_command_close(QIOChannel *ioc, Error **errp) { QIOChannelCommand *cioc = QIO_CHANNEL_COMMAND(ioc); int rv = 0; /* We close FDs before killing, because that * gives a better chance of clean shutdown */ if (close(cioc->writefd) < 0) { rv = -1; } if (close(cioc->readfd) < 0) { rv = -1; } #ifndef WIN32 if (qio_channel_command_abort(cioc, errp) < 0) { return -1; } #endif if (rv < 0) { error_setg_errno(errp, errno, "%s", "Unable to close command"); } return rv; }
13,453
FFmpeg
c3b6454d801638b091b51fe62937e6831a3a37b2
1
AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact) { AVFixedDSPContext * fdsp = av_malloc(sizeof(AVFixedDSPContext)); fdsp->vector_fmul_window_scaled = vector_fmul_window_fixed_scaled_c; fdsp->vector_fmul_window = vector_fmul_window_fixed_c; return fdsp; }
13,454
FFmpeg
f6774f905fb3cfdc319523ac640be30b14c1bc55
1
static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, int motion_y, int mb_block_height, int mb_block_count) { int16_t weight[8][64]; int16_t orig[8][64]; const int mb_x = s->mb_x; const int mb_y = s->mb_y; int i; int skip_dct[8]; int dct_offset = s->linesize * 8; // default for progressive frames uint8_t *ptr_y, *ptr_cb, *ptr_cr; ptrdiff_t wrap_y, wrap_c; for (i = 0; i < mb_block_count; i++) skip_dct[i] = s->skipdct; if (s->adaptive_quant) { const int last_qp = s->qscale; const int mb_xy = mb_x + mb_y * s->mb_stride; s->lambda = s->lambda_table[mb_xy]; update_qscale(s); if (!(s->mpv_flags & FF_MPV_FLAG_QP_RD)) { s->qscale = s->current_picture_ptr->qscale_table[mb_xy]; s->dquant = s->qscale - last_qp; if (s->out_format == FMT_H263) { s->dquant = av_clip(s->dquant, -2, 2); if (s->codec_id == AV_CODEC_ID_MPEG4) { if (!s->mb_intra) { if (s->pict_type == AV_PICTURE_TYPE_B) { if (s->dquant & 1 || s->mv_dir & MV_DIRECT) s->dquant = 0; } if (s->mv_type == MV_TYPE_8X8) s->dquant = 0; } } } } ff_set_qscale(s, last_qp + s->dquant); } else if (s->mpv_flags & FF_MPV_FLAG_QP_RD) ff_set_qscale(s, s->qscale + s->dquant); wrap_y = s->linesize; wrap_c = s->uvlinesize; ptr_y = s->new_picture.f.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16; ptr_cb = s->new_picture.f.data[1] + (mb_y * mb_block_height * wrap_c) + mb_x * 8; ptr_cr = s->new_picture.f.data[2] + (mb_y * mb_block_height * wrap_c) + mb_x * 8; if (mb_x * 16 + 16 > s->width || mb_y * 16 + 16 > s->height) { uint8_t *ebuf = s->edge_emu_buffer + 32; s->vdsp.emulated_edge_mc(ebuf, ptr_y, wrap_y, wrap_y, 16, 16, mb_x * 16, mb_y * 16, s->width, s->height); ptr_y = ebuf; s->vdsp.emulated_edge_mc(ebuf + 18 * wrap_y, ptr_cb, wrap_c, wrap_c, 8, mb_block_height, mb_x * 8, mb_y * 8, s->width >> 1, s->height >> 1); ptr_cb = ebuf + 18 * wrap_y; s->vdsp.emulated_edge_mc(ebuf + 18 * wrap_y + 8, ptr_cr, wrap_c, wrap_c, 8, mb_block_height, mb_x * 8, mb_y * 8, s->width >> 1, s->height >> 1); ptr_cr = ebuf + 18 * wrap_y + 8; } if (s->mb_intra) { if (s->flags & CODEC_FLAG_INTERLACED_DCT) { int progressive_score, interlaced_score; s->interlaced_dct = 0; progressive_score = s->dsp.ildct_cmp[4](s, ptr_y, NULL, wrap_y, 8) + s->dsp.ildct_cmp[4](s, ptr_y + wrap_y * 8, NULL, wrap_y, 8) - 400; if (progressive_score > 0) { interlaced_score = s->dsp.ildct_cmp[4](s, ptr_y, NULL, wrap_y * 2, 8) + s->dsp.ildct_cmp[4](s, ptr_y + wrap_y, NULL, wrap_y * 2, 8); if (progressive_score > interlaced_score) { s->interlaced_dct = 1; dct_offset = wrap_y; wrap_y <<= 1; if (s->chroma_format == CHROMA_422) wrap_c <<= 1; } } } s->dsp.get_pixels(s->block[0], ptr_y , wrap_y); s->dsp.get_pixels(s->block[1], ptr_y + 8 , wrap_y); s->dsp.get_pixels(s->block[2], ptr_y + dct_offset , wrap_y); s->dsp.get_pixels(s->block[3], ptr_y + dct_offset + 8 , wrap_y); if (s->flags & CODEC_FLAG_GRAY) { skip_dct[4] = 1; skip_dct[5] = 1; } else { s->dsp.get_pixels(s->block[4], ptr_cb, wrap_c); s->dsp.get_pixels(s->block[5], ptr_cr, wrap_c); if (!s->chroma_y_shift) { /* 422 */ s->dsp.get_pixels(s->block[6], ptr_cb + (dct_offset >> 1), wrap_c); s->dsp.get_pixels(s->block[7], ptr_cr + (dct_offset >> 1), wrap_c); } } } else { op_pixels_func (*op_pix)[4]; qpel_mc_func (*op_qpix)[16]; uint8_t *dest_y, *dest_cb, *dest_cr; dest_y = s->dest[0]; dest_cb = s->dest[1]; dest_cr = s->dest[2]; if ((!s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) { op_pix = s->hdsp.put_pixels_tab; op_qpix = s->dsp.put_qpel_pixels_tab; } else { op_pix = s->hdsp.put_no_rnd_pixels_tab; op_qpix = s->dsp.put_no_rnd_qpel_pixels_tab; } if (s->mv_dir & MV_DIR_FORWARD) { ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix, op_qpix); op_pix = s->hdsp.avg_pixels_tab; op_qpix = s->dsp.avg_qpel_pixels_tab; } if (s->mv_dir & MV_DIR_BACKWARD) { ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix, op_qpix); } if (s->flags & CODEC_FLAG_INTERLACED_DCT) { int progressive_score, interlaced_score; s->interlaced_dct = 0; progressive_score = s->dsp.ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) + s->dsp.ildct_cmp[0](s, dest_y + wrap_y * 8, ptr_y + wrap_y * 8, wrap_y, 8) - 400; if (s->avctx->ildct_cmp == FF_CMP_VSSE) progressive_score -= 400; if (progressive_score > 0) { interlaced_score = s->dsp.ildct_cmp[0](s, dest_y, ptr_y, wrap_y * 2, 8) + s->dsp.ildct_cmp[0](s, dest_y + wrap_y, ptr_y + wrap_y, wrap_y * 2, 8); if (progressive_score > interlaced_score) { s->interlaced_dct = 1; dct_offset = wrap_y; wrap_y <<= 1; if (s->chroma_format == CHROMA_422) wrap_c <<= 1; } } } s->dsp.diff_pixels(s->block[0], ptr_y, dest_y, wrap_y); s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, wrap_y); s->dsp.diff_pixels(s->block[2], ptr_y + dct_offset, dest_y + dct_offset, wrap_y); s->dsp.diff_pixels(s->block[3], ptr_y + dct_offset + 8, dest_y + dct_offset + 8, wrap_y); if (s->flags & CODEC_FLAG_GRAY) { skip_dct[4] = 1; skip_dct[5] = 1; } else { s->dsp.diff_pixels(s->block[4], ptr_cb, dest_cb, wrap_c); s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, wrap_c); if (!s->chroma_y_shift) { /* 422 */ s->dsp.diff_pixels(s->block[6], ptr_cb + (dct_offset >> 1), dest_cb + (dct_offset >> 1), wrap_c); s->dsp.diff_pixels(s->block[7], ptr_cr + (dct_offset >> 1), dest_cr + (dct_offset >> 1), wrap_c); } } /* pre quantization */ if (s->current_picture.mc_mb_var[s->mb_stride * mb_y + mb_x] < 2 * s->qscale * s->qscale) { // FIXME optimize if (s->dsp.sad[1](NULL, ptr_y , dest_y, wrap_y, 8) < 20 * s->qscale) skip_dct[0] = 1; if (s->dsp.sad[1](NULL, ptr_y + 8, dest_y + 8, wrap_y, 8) < 20 * s->qscale) skip_dct[1] = 1; if (s->dsp.sad[1](NULL, ptr_y + dct_offset, dest_y + dct_offset, wrap_y, 8) < 20 * s->qscale) skip_dct[2] = 1; if (s->dsp.sad[1](NULL, ptr_y + dct_offset + 8, dest_y + dct_offset + 8, wrap_y, 8) < 20 * s->qscale) skip_dct[3] = 1; if (s->dsp.sad[1](NULL, ptr_cb, dest_cb, wrap_c, 8) < 20 * s->qscale) skip_dct[4] = 1; if (s->dsp.sad[1](NULL, ptr_cr, dest_cr, wrap_c, 8) < 20 * s->qscale) skip_dct[5] = 1; if (!s->chroma_y_shift) { /* 422 */ if (s->dsp.sad[1](NULL, ptr_cb + (dct_offset >> 1), dest_cb + (dct_offset >> 1), wrap_c, 8) < 20 * s->qscale) skip_dct[6] = 1; if (s->dsp.sad[1](NULL, ptr_cr + (dct_offset >> 1), dest_cr + (dct_offset >> 1), wrap_c, 8) < 20 * s->qscale) skip_dct[7] = 1; } } } if (s->quantizer_noise_shaping) { if (!skip_dct[0]) get_visual_weight(weight[0], ptr_y , wrap_y); if (!skip_dct[1]) get_visual_weight(weight[1], ptr_y + 8, wrap_y); if (!skip_dct[2]) get_visual_weight(weight[2], ptr_y + dct_offset , wrap_y); if (!skip_dct[3]) get_visual_weight(weight[3], ptr_y + dct_offset + 8, wrap_y); if (!skip_dct[4]) get_visual_weight(weight[4], ptr_cb , wrap_c); if (!skip_dct[5]) get_visual_weight(weight[5], ptr_cr , wrap_c); if (!s->chroma_y_shift) { /* 422 */ if (!skip_dct[6]) get_visual_weight(weight[6], ptr_cb + (dct_offset >> 1), wrap_c); if (!skip_dct[7]) get_visual_weight(weight[7], ptr_cr + (dct_offset >> 1), wrap_c); } memcpy(orig[0], s->block[0], sizeof(int16_t) * 64 * mb_block_count); } /* DCT & quantize */ assert(s->out_format != FMT_MJPEG || s->qscale == 8); { for (i = 0; i < mb_block_count; i++) { if (!skip_dct[i]) { int overflow; s->block_last_index[i] = s->dct_quantize(s, s->block[i], i, s->qscale, &overflow); // FIXME we could decide to change to quantizer instead of // clipping // JS: I don't think that would be a good idea it could lower // quality instead of improve it. Just INTRADC clipping // deserves changes in quantizer if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]); } else s->block_last_index[i] = -1; } if (s->quantizer_noise_shaping) { for (i = 0; i < mb_block_count; i++) { if (!skip_dct[i]) { s->block_last_index[i] = dct_quantize_refine(s, s->block[i], weight[i], orig[i], i, s->qscale); } } } if (s->luma_elim_threshold && !s->mb_intra) for (i = 0; i < 4; i++) dct_single_coeff_elimination(s, i, s->luma_elim_threshold); if (s->chroma_elim_threshold && !s->mb_intra) for (i = 4; i < mb_block_count; i++) dct_single_coeff_elimination(s, i, s->chroma_elim_threshold); if (s->mpv_flags & FF_MPV_FLAG_CBP_RD) { for (i = 0; i < mb_block_count; i++) { if (s->block_last_index[i] == -1) s->coded_score[i] = INT_MAX / 256; } } } if ((s->flags & CODEC_FLAG_GRAY) && s->mb_intra) { s->block_last_index[4] = s->block_last_index[5] = 0; s->block[4][0] = s->block[5][0] = (1024 + s->c_dc_scale / 2) / s->c_dc_scale; } // non c quantize code returns incorrect block_last_index FIXME if (s->alternate_scan && s->dct_quantize != ff_dct_quantize_c) { for (i = 0; i < mb_block_count; i++) { int j; if (s->block_last_index[i] > 0) { for (j = 63; j > 0; j--) { if (s->block[i][s->intra_scantable.permutated[j]]) break; } s->block_last_index[i] = j; } } } /* huffman encode */ switch(s->codec_id){ //FIXME funct ptr could be slightly faster case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG2VIDEO: if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) ff_mpeg1_encode_mb(s, s->block, motion_x, motion_y); break; case AV_CODEC_ID_MPEG4: if (CONFIG_MPEG4_ENCODER) ff_mpeg4_encode_mb(s, s->block, motion_x, motion_y); break; case AV_CODEC_ID_MSMPEG4V2: case AV_CODEC_ID_MSMPEG4V3: case AV_CODEC_ID_WMV1: if (CONFIG_MSMPEG4_ENCODER) ff_msmpeg4_encode_mb(s, s->block, motion_x, motion_y); break; case AV_CODEC_ID_WMV2: if (CONFIG_WMV2_ENCODER) ff_wmv2_encode_mb(s, s->block, motion_x, motion_y); break; case AV_CODEC_ID_H261: if (CONFIG_H261_ENCODER) ff_h261_encode_mb(s, s->block, motion_x, motion_y); break; case AV_CODEC_ID_H263: case AV_CODEC_ID_H263P: case AV_CODEC_ID_FLV1: case AV_CODEC_ID_RV10: case AV_CODEC_ID_RV20: if (CONFIG_H263_ENCODER) ff_h263_encode_mb(s, s->block, motion_x, motion_y); break; case AV_CODEC_ID_MJPEG: if (CONFIG_MJPEG_ENCODER) ff_mjpeg_encode_mb(s, s->block); break; default: assert(0); } }
13,455
qemu
6f9faa91f5fb3a866f5bf592207c9498a017740d
1
void sh_intc_register_sources(struct intc_desc *desc, struct intc_vect *vectors, int nr_vectors, struct intc_group *groups, int nr_groups) { unsigned int i, k; struct intc_source *s; for (i = 0; i < nr_vectors; i++) { struct intc_vect *vect = vectors + i; sh_intc_register_source(desc, vect->enum_id, groups, nr_groups); s = sh_intc_source(desc, vect->enum_id); if (s) s->vect = vect->vect; #ifdef DEBUG_INTC_SOURCES printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n", vect->enum_id, s->vect, s->enable_count, s->enable_max); #endif } if (groups) { for (i = 0; i < nr_groups; i++) { struct intc_group *gr = groups + i; s = sh_intc_source(desc, gr->enum_id); s->next_enum_id = gr->enum_ids[0]; for (k = 1; k < ARRAY_SIZE(gr->enum_ids); k++) { if (!gr->enum_ids[k]) continue; s = sh_intc_source(desc, gr->enum_ids[k - 1]); s->next_enum_id = gr->enum_ids[k]; } #ifdef DEBUG_INTC_SOURCES printf("sh_intc: registered group %d (%d/%d)\n", gr->enum_id, s->enable_count, s->enable_max); #endif } } }
13,456
qemu
3d3efba020da1de57a715e2087cf761ed0ad0904
1
void sparc64_get_context(CPUSPARCState *env) { abi_ulong ucp_addr; struct target_ucontext *ucp; target_mc_gregset_t *grp; target_mcontext_t *mcp; abi_ulong fp, i7, w_addr; int err; unsigned int i; target_sigset_t target_set; sigset_t set; ucp_addr = env->regwptr[UREG_I0]; if (!lock_user_struct(VERIFY_WRITE, ucp, ucp_addr, 0)) { goto do_sigsegv; } mcp = &ucp->tuc_mcontext; grp = &mcp->mc_gregs; /* Skip over the trap instruction, first. */ env->pc = env->npc; env->npc += 4; err = 0; do_sigprocmask(0, NULL, &set); host_to_target_sigset_internal(&target_set, &set); if (TARGET_NSIG_WORDS == 1) { __put_user(target_set.sig[0], (abi_ulong *)&ucp->tuc_sigmask); } else { abi_ulong *src, *dst; src = target_set.sig; dst = ucp->tuc_sigmask.sig; for (i = 0; i < TARGET_NSIG_WORDS; i++, dst++, src++) { __put_user(*src, dst); } if (err) goto do_sigsegv; } /* XXX: tstate must be saved properly */ // __put_user(env->tstate, &((*grp)[MC_TSTATE])); __put_user(env->pc, &((*grp)[MC_PC])); __put_user(env->npc, &((*grp)[MC_NPC])); __put_user(env->y, &((*grp)[MC_Y])); __put_user(env->gregs[1], &((*grp)[MC_G1])); __put_user(env->gregs[2], &((*grp)[MC_G2])); __put_user(env->gregs[3], &((*grp)[MC_G3])); __put_user(env->gregs[4], &((*grp)[MC_G4])); __put_user(env->gregs[5], &((*grp)[MC_G5])); __put_user(env->gregs[6], &((*grp)[MC_G6])); __put_user(env->gregs[7], &((*grp)[MC_G7])); __put_user(env->regwptr[UREG_I0], &((*grp)[MC_O0])); __put_user(env->regwptr[UREG_I1], &((*grp)[MC_O1])); __put_user(env->regwptr[UREG_I2], &((*grp)[MC_O2])); __put_user(env->regwptr[UREG_I3], &((*grp)[MC_O3])); __put_user(env->regwptr[UREG_I4], &((*grp)[MC_O4])); __put_user(env->regwptr[UREG_I5], &((*grp)[MC_O5])); __put_user(env->regwptr[UREG_I6], &((*grp)[MC_O6])); __put_user(env->regwptr[UREG_I7], &((*grp)[MC_O7])); w_addr = TARGET_STACK_BIAS+env->regwptr[UREG_I6]; fp = i7 = 0; if (get_user(fp, w_addr + offsetof(struct target_reg_window, ins[6]), abi_ulong) != 0) { goto do_sigsegv; } if (get_user(i7, w_addr + offsetof(struct target_reg_window, ins[7]), abi_ulong) != 0) { goto do_sigsegv; } __put_user(fp, &(mcp->mc_fp)); __put_user(i7, &(mcp->mc_i7)); { uint32_t *dst = ucp->tuc_mcontext.mc_fpregs.mcfpu_fregs.sregs; for (i = 0; i < 64; i++, dst++) { if (i & 1) { __put_user(env->fpr[i/2].l.lower, dst); } else { __put_user(env->fpr[i/2].l.upper, dst); } } } __put_user(env->fsr, &(mcp->mc_fpregs.mcfpu_fsr)); __put_user(env->gsr, &(mcp->mc_fpregs.mcfpu_gsr)); __put_user(env->fprs, &(mcp->mc_fpregs.mcfpu_fprs)); if (err) goto do_sigsegv; unlock_user_struct(ucp, ucp_addr, 1); return; do_sigsegv: unlock_user_struct(ucp, ucp_addr, 1); force_sig(TARGET_SIGSEGV); }
13,458
FFmpeg
a8dbe9514f865f6a8efb304a720025cb1ef9ae3f
0
void av_close_input_file(AVFormatContext *s) { int i; if (s->iformat->read_close) s->iformat->read_close(s); for(i=0;i<s->nb_streams;i++) { av_free(s->streams[i]); } if (s->packet_buffer) { AVPacketList *p, *p1; p = s->packet_buffer; while (p != NULL) { p1 = p->next; av_free_packet(&p->pkt); av_free(p); p = p1; } s->packet_buffer = NULL; } if (!(s->iformat->flags & AVFMT_NOFILE)) { url_fclose(&s->pb); } av_free(s->priv_data); av_free(s); }
13,461
qemu
ad0ebb91cd8b5fdc4a583b03645677771f420a46
1
void stw_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t val) { val = tswap32(val); spapr_tce_dma_write(dev, taddr, &val, sizeof(val)); }
13,463
FFmpeg
6e42e6c4b410dbef8b593c2d796a5dad95f89ee4
1
static inline void RENAME(rgb32to24)(const uint8_t *src,uint8_t *dst,long src_size) { uint8_t *dest = dst; const uint8_t *s = src; const uint8_t *end; #ifdef HAVE_MMX const uint8_t *mm_end; #endif end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 31; while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movq %1, %%mm0\n\t" "movq 8%1, %%mm1\n\t" "movq 16%1, %%mm4\n\t" "movq 24%1, %%mm5\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm1, %%mm3\n\t" "movq %%mm4, %%mm6\n\t" "movq %%mm5, %%mm7\n\t" "psrlq $8, %%mm2\n\t" "psrlq $8, %%mm3\n\t" "psrlq $8, %%mm6\n\t" "psrlq $8, %%mm7\n\t" "pand %2, %%mm0\n\t" "pand %2, %%mm1\n\t" "pand %2, %%mm4\n\t" "pand %2, %%mm5\n\t" "pand %3, %%mm2\n\t" "pand %3, %%mm3\n\t" "pand %3, %%mm6\n\t" "pand %3, %%mm7\n\t" "por %%mm2, %%mm0\n\t" "por %%mm3, %%mm1\n\t" "por %%mm6, %%mm4\n\t" "por %%mm7, %%mm5\n\t" "movq %%mm1, %%mm2\n\t" "movq %%mm4, %%mm3\n\t" "psllq $48, %%mm2\n\t" "psllq $32, %%mm3\n\t" "pand %4, %%mm2\n\t" "pand %5, %%mm3\n\t" "por %%mm2, %%mm0\n\t" "psrlq $16, %%mm1\n\t" "psrlq $32, %%mm4\n\t" "psllq $16, %%mm5\n\t" "por %%mm3, %%mm1\n\t" "pand %6, %%mm5\n\t" "por %%mm5, %%mm4\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm1, 8%0\n\t" MOVNTQ" %%mm4, 16%0" :"=m"(*dest) :"m"(*s),"m"(mask24l), "m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh) :"memory"); dest += 24; s += 32; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { #ifdef WORDS_BIGENDIAN /* RGB32 (= A,B,G,R) -> RGB24 (= R,G,B) */ s++; dest[2] = *s++; dest[1] = *s++; dest[0] = *s++; dest += 3; #else *dest++ = *s++; *dest++ = *s++; *dest++ = *s++; s++; #endif } }
13,464
qemu
788cf9f8c8cbda53843e060540f3e91a060eb744
1
static void term_exit(void) { tcsetattr(0, TCSANOW, &oldtty); }
13,465
qemu
86e18cae209f8101ff9a6013a1ff6ae620c06944
1
static inline int ohci_put_hcca(OHCIState *ohci, uint32_t addr, struct ohci_hcca *hcca) { cpu_physical_memory_write(addr + ohci->localmem_base, hcca, sizeof(*hcca)); return 1; }
13,466
FFmpeg
cb08687180683a755d0fe9d425280d0e4d1e6db2
1
static int vqf_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { VqfContext *c = s->priv_data; AVStream *st; int ret; int64_t pos; st = s->streams[stream_index]; pos = av_rescale_rnd(timestamp * st->codec->bit_rate, st->time_base.num, st->time_base.den * (int64_t)c->frame_bit_len, (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP); pos *= c->frame_bit_len; st->cur_dts = av_rescale(pos, st->time_base.den, st->codec->bit_rate * (int64_t)st->time_base.num); if ((ret = avio_seek(s->pb, ((pos-7) >> 3) + s->internal->data_offset, SEEK_SET)) < 0) return ret; c->remaining_bits = -7 - ((pos-7)&7); return 0; }
13,469