id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
7,210
void os_mem_prealloc(int fd, char *area, size_t memory) { int ret; struct sigaction act, oldact; sigset_t set, oldset; memset(&act, 0, sizeof(act)); act.sa_handler = &sigbus_handler; act.sa_flags = 0; ret = sigaction(SIGBUS, &act, &oldact); if (ret) { perror("os_mem_prealloc: failed to install signal handler"); exit(1); } /* unblock SIGBUS */ sigemptyset(&set); sigaddset(&set, SIGBUS); pthread_sigmask(SIG_UNBLOCK, &set, &oldset); if (sigsetjmp(sigjump, 1)) { fprintf(stderr, "os_mem_prealloc: Insufficient free host memory " "pages available to allocate guest RAM\n"); exit(1); } else { int i; size_t hpagesize = fd_getpagesize(fd); size_t numpages = DIV_ROUND_UP(memory, hpagesize); /* MAP_POPULATE silently ignores failures */ for (i = 0; i < numpages; i++) { memset(area + (hpagesize * i), 0, 1); } ret = sigaction(SIGBUS, &oldact, NULL); if (ret) { perror("os_mem_prealloc: failed to reinstall signal handler"); exit(1); } pthread_sigmask(SIG_SETMASK, &oldset, NULL); } }
false
qemu
7197fb4058bcb68986bae2bb2c04d6370f3e7218
7,212
int usb_handle_packet(USBDevice *dev, USBPacket *p) { int ret; if (dev == NULL) { return USB_RET_NODEV; } assert(dev->addr == p->devaddr); assert(dev->state == USB_STATE_DEFAULT); assert(p->state == USB_PACKET_SETUP); if (p->devep == 0) { /* control pipe */ switch (p->pid) { case USB_TOKEN_SETUP: ret = do_token_setup(dev, p); break; case USB_TOKEN_IN: ret = do_token_in(dev, p); break; case USB_TOKEN_OUT: ret = do_token_out(dev, p); break; default: ret = USB_RET_STALL; break; } } else { /* data pipe */ ret = usb_device_handle_data(dev, p); } if (ret == USB_RET_ASYNC) { p->ep = usb_ep_get(dev, p->pid, p->devep); p->state = USB_PACKET_ASYNC; } return ret; }
false
qemu
079d0b7f1eedcc634c371fe05b617fdc55c8b762
7,214
build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offset) { AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp); unsigned rsdt_pa_size = sizeof(rsdp->rsdt_physical_address); unsigned rsdt_pa_offset = (char *)&rsdp->rsdt_physical_address - rsdp_table->data; bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, rsdp_table, 16, true /* fseg memory */); memcpy(&rsdp->signature, "RSD PTR ", sizeof(rsdp->signature)); memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, sizeof(rsdp->oem_id)); rsdp->length = cpu_to_le32(sizeof(*rsdp)); rsdp->revision = 0x02; /* Address to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE, rsdt_pa_offset, rsdt_pa_size, ACPI_BUILD_TABLE_FILE, rsdt_tbl_offset); rsdp->checksum = 0; /* Checksum to be filled by Guest linker */ bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, rsdp, sizeof *rsdp, &rsdp->checksum); return rsdp_table; }
false
qemu
28213cb6a61a724e2cb1e3a76d2bb17aa0ce9b36
7,215
static inline uint32_t vmsvga_fifo_read_raw(struct vmsvga_state_s *s) { uint32_t cmd = s->fifo[CMD(stop) >> 2]; s->cmd->stop = cpu_to_le32(CMD(stop) + 4); if (CMD(stop) >= CMD(max)) s->cmd->stop = s->cmd->min; return cmd; }
false
qemu
0d7937974cd0504f30ad483c3368b21da426ddf9
7,216
static void rv40_loop_filter(RV34DecContext *r, int row) { MpegEncContext *s = &r->s; int mb_pos, mb_x; int i, j, k; uint8_t *Y, *C; int alpha, beta, betaY, betaC; int q; int mbtype[4]; ///< current macroblock and its neighbours types /** * flags indicating that macroblock can be filtered with strong filter * it is set only for intra coded MB and MB with DCs coded separately */ int mb_strong[4]; int clip[4]; ///< MB filter clipping value calculated from filtering strength /** * coded block patterns for luma part of current macroblock and its neighbours * Format: * LSB corresponds to the top left block, * each nibble represents one row of subblocks. */ int cbp[4]; /** * coded block patterns for chroma part of current macroblock and its neighbours * Format is the same as for luma with two subblocks in a row. */ int uvcbp[4][2]; /** * This mask represents the pattern of luma subblocks that should be filtered * in addition to the coded ones because because they lie at the edge of * 8x8 block with different enough motion vectors */ int mvmasks[4]; mb_pos = row * s->mb_stride; for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){ int mbtype = s->current_picture_ptr->f.mb_type[mb_pos]; if(IS_INTRA(mbtype) || IS_SEPARATE_DC(mbtype)) r->cbp_luma [mb_pos] = r->deblock_coefs[mb_pos] = 0xFFFF; if(IS_INTRA(mbtype)) r->cbp_chroma[mb_pos] = 0xFF; } mb_pos = row * s->mb_stride; for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){ int y_h_deblock, y_v_deblock; int c_v_deblock[2], c_h_deblock[2]; int clip_left; int avail[4]; int y_to_deblock, c_to_deblock[2]; q = s->current_picture_ptr->f.qscale_table[mb_pos]; alpha = rv40_alpha_tab[q]; beta = rv40_beta_tab [q]; betaY = betaC = beta * 3; if(s->width * s->height <= 176*144) betaY += beta; avail[0] = 1; avail[1] = row; avail[2] = mb_x; avail[3] = row < s->mb_height - 1; for(i = 0; i < 4; i++){ if(avail[i]){ int pos = mb_pos + neighbour_offs_x[i] + neighbour_offs_y[i]*s->mb_stride; mvmasks[i] = r->deblock_coefs[pos]; mbtype [i] = s->current_picture_ptr->f.mb_type[pos]; cbp [i] = r->cbp_luma[pos]; uvcbp[i][0] = r->cbp_chroma[pos] & 0xF; uvcbp[i][1] = r->cbp_chroma[pos] >> 4; }else{ mvmasks[i] = 0; mbtype [i] = mbtype[0]; cbp [i] = 0; uvcbp[i][0] = uvcbp[i][1] = 0; } mb_strong[i] = IS_INTRA(mbtype[i]) || IS_SEPARATE_DC(mbtype[i]); clip[i] = rv40_filter_clip_tbl[mb_strong[i] + 1][q]; } y_to_deblock = mvmasks[POS_CUR] | (mvmasks[POS_BOTTOM] << 16); /* This pattern contains bits signalling that horizontal edges of * the current block can be filtered. * That happens when either of adjacent subblocks is coded or lies on * the edge of 8x8 blocks with motion vectors differing by more than * 3/4 pel in any component (any edge orientation for some reason). */ y_h_deblock = y_to_deblock | ((cbp[POS_CUR] << 4) & ~MASK_Y_TOP_ROW) | ((cbp[POS_TOP] & MASK_Y_LAST_ROW) >> 12); /* This pattern contains bits signalling that vertical edges of * the current block can be filtered. * That happens when either of adjacent subblocks is coded or lies on * the edge of 8x8 blocks with motion vectors differing by more than * 3/4 pel in any component (any edge orientation for some reason). */ y_v_deblock = y_to_deblock | ((cbp[POS_CUR] << 1) & ~MASK_Y_LEFT_COL) | ((cbp[POS_LEFT] & MASK_Y_RIGHT_COL) >> 3); if(!mb_x) y_v_deblock &= ~MASK_Y_LEFT_COL; if(!row) y_h_deblock &= ~MASK_Y_TOP_ROW; if(row == s->mb_height - 1 || (mb_strong[POS_CUR] || mb_strong[POS_BOTTOM])) y_h_deblock &= ~(MASK_Y_TOP_ROW << 16); /* Calculating chroma patterns is similar and easier since there is * no motion vector pattern for them. */ for(i = 0; i < 2; i++){ c_to_deblock[i] = (uvcbp[POS_BOTTOM][i] << 4) | uvcbp[POS_CUR][i]; c_v_deblock[i] = c_to_deblock[i] | ((uvcbp[POS_CUR] [i] << 1) & ~MASK_C_LEFT_COL) | ((uvcbp[POS_LEFT][i] & MASK_C_RIGHT_COL) >> 1); c_h_deblock[i] = c_to_deblock[i] | ((uvcbp[POS_TOP][i] & MASK_C_LAST_ROW) >> 2) | (uvcbp[POS_CUR][i] << 2); if(!mb_x) c_v_deblock[i] &= ~MASK_C_LEFT_COL; if(!row) c_h_deblock[i] &= ~MASK_C_TOP_ROW; if(row == s->mb_height - 1 || mb_strong[POS_CUR] || mb_strong[POS_BOTTOM]) c_h_deblock[i] &= ~(MASK_C_TOP_ROW << 4); } for(j = 0; j < 16; j += 4){ Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize; for(i = 0; i < 4; i++, Y += 4){ int ij = i + j; int clip_cur = y_to_deblock & (MASK_CUR << ij) ? clip[POS_CUR] : 0; int dither = j ? ij : i*4; // if bottom block is coded then we can filter its top edge // (or bottom edge of this block, which is the same) if(y_h_deblock & (MASK_BOTTOM << ij)){ r->rdsp.rv40_h_loop_filter(Y+4*s->linesize, s->linesize, dither, y_to_deblock & (MASK_BOTTOM << ij) ? clip[POS_CUR] : 0, clip_cur, alpha, beta, betaY, 0, 0); } // filter left block edge in ordinary mode (with low filtering strength) if(y_v_deblock & (MASK_CUR << ij) && (i || !(mb_strong[POS_CUR] || mb_strong[POS_LEFT]))){ if(!i) clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0; else clip_left = y_to_deblock & (MASK_CUR << (ij-1)) ? clip[POS_CUR] : 0; r->rdsp.rv40_v_loop_filter(Y, s->linesize, dither, clip_cur, clip_left, alpha, beta, betaY, 0, 0); } // filter top edge of the current macroblock when filtering strength is high if(!j && y_h_deblock & (MASK_CUR << i) && (mb_strong[POS_CUR] || mb_strong[POS_TOP])){ r->rdsp.rv40_h_loop_filter(Y, s->linesize, dither, clip_cur, mvmasks[POS_TOP] & (MASK_TOP << i) ? clip[POS_TOP] : 0, alpha, beta, betaY, 0, 1); } // filter left block edge in edge mode (with high filtering strength) if(y_v_deblock & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] || mb_strong[POS_LEFT])){ clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0; r->rdsp.rv40_v_loop_filter(Y, s->linesize, dither, clip_cur, clip_left, alpha, beta, betaY, 0, 1); } } } for(k = 0; k < 2; k++){ for(j = 0; j < 2; j++){ C = s->current_picture_ptr->f.data[k + 1] + mb_x*8 + (row*8 + j*4) * s->uvlinesize; for(i = 0; i < 2; i++, C += 4){ int ij = i + j*2; int clip_cur = c_to_deblock[k] & (MASK_CUR << ij) ? clip[POS_CUR] : 0; if(c_h_deblock[k] & (MASK_CUR << (ij+2))){ int clip_bot = c_to_deblock[k] & (MASK_CUR << (ij+2)) ? clip[POS_CUR] : 0; r->rdsp.rv40_h_loop_filter(C+4*s->uvlinesize, s->uvlinesize, i*8, clip_bot, clip_cur, alpha, beta, betaC, 1, 0); } if((c_v_deblock[k] & (MASK_CUR << ij)) && (i || !(mb_strong[POS_CUR] || mb_strong[POS_LEFT]))){ if(!i) clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0; else clip_left = c_to_deblock[k] & (MASK_CUR << (ij-1)) ? clip[POS_CUR] : 0; r->rdsp.rv40_v_loop_filter(C, s->uvlinesize, j*8, clip_cur, clip_left, alpha, beta, betaC, 1, 0); } if(!j && c_h_deblock[k] & (MASK_CUR << ij) && (mb_strong[POS_CUR] || mb_strong[POS_TOP])){ int clip_top = uvcbp[POS_TOP][k] & (MASK_CUR << (ij+2)) ? clip[POS_TOP] : 0; r->rdsp.rv40_h_loop_filter(C, s->uvlinesize, i*8, clip_cur, clip_top, alpha, beta, betaC, 1, 1); } if(c_v_deblock[k] & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] || mb_strong[POS_LEFT])){ clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0; r->rdsp.rv40_v_loop_filter(C, s->uvlinesize, j*8, clip_cur, clip_left, alpha, beta, betaC, 1, 1); } } } } } }
false
FFmpeg
d8edf1b515ae9fbcea2103305241d130c16e1003
7,217
static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs) { BlockDriverState *old_bs = child->bs; if (old_bs) { if (old_bs->quiesce_counter && child->role->drained_end) { child->role->drained_end(child); } QLIST_REMOVE(child, next_parent); } child->bs = new_bs; if (new_bs) { QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent); if (new_bs->quiesce_counter && child->role->drained_begin) { child->role->drained_begin(child); } } }
false
qemu
33a610c398603efafd954c706ba07850835a5098
7,219
void qemu_ram_free(ram_addr_t addr) { RAMBlock *block; /* This assumes the iothread lock is taken here too. */ qemu_mutex_lock_ramlist(); QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (addr == block->offset) { QTAILQ_REMOVE(&ram_list.blocks, block, next); ram_list.mru_block = NULL; ram_list.version++; if (block->flags & RAM_PREALLOC_MASK) { ; } else if (xen_enabled()) { xen_invalidate_map_cache_entry(block->host); } else if (mem_path) { #if defined (__linux__) && !defined(TARGET_S390X) if (block->fd) { munmap(block->host, block->length); close(block->fd); } else { qemu_anon_ram_free(block->host, block->length); } #else abort(); #endif } else { qemu_anon_ram_free(block->host, block->length); } g_free(block); break; } } qemu_mutex_unlock_ramlist(); }
false
qemu
3435f39513a104294b5e3bbf3612047028d25cfc
7,220
static int block_job_finish_sync(BlockJob *job, void (*finish)(BlockJob *, Error **errp), Error **errp) { BlockDriverState *bs = job->bs; Error *local_err = NULL; int ret; assert(bs->job == job); block_job_ref(job); finish(job, &local_err); if (local_err) { error_propagate(errp, local_err); block_job_unref(job); return -EBUSY; } while (!job->completed) { aio_poll(bdrv_get_aio_context(bs), true); } ret = (job->cancelled && job->ret == 0) ? -ECANCELED : job->ret; block_job_unref(job); return ret; }
false
qemu
794f01414f9f4c4d0c6f1961154674961941c197
7,221
static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent) { char desc[DESC_SIZE]; uint32_t cid; const char *p_name, *cid_str; size_t cid_str_size; BDRVVmdkState *s = bs->opaque; if (bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE) != DESC_SIZE) { return 0; } if (parent) { cid_str = "parentCID"; cid_str_size = sizeof("parentCID"); } else { cid_str = "CID"; cid_str_size = sizeof("CID"); } if ((p_name = strstr(desc,cid_str)) != NULL) { p_name += cid_str_size; sscanf(p_name,"%x",&cid); } return cid; }
false
qemu
ae261c86aaed62e7acddafab8262a2bf286d40b7
7,223
int qemu_chr_fe_ioctl(CharDriverState *s, int cmd, void *arg) { if (!s->chr_ioctl) return -ENOTSUP; return s->chr_ioctl(s, cmd, arg); }
false
qemu
33577b47c64435fcc2a1bc01c7e82534256f1fc3
7,224
static void e1000_pre_save(void *opaque) { E1000State *s = opaque; NetClientState *nc = qemu_get_queue(s->nic); /* If the mitigation timer is active, emulate a timeout now. */ if (s->mit_timer_on) { e1000_mit_timer(s); } /* * If link is down and auto-negotiation is supported and ongoing, * complete auto-negotiation immediately. This allows us to look * at MII_SR_AUTONEG_COMPLETE to infer link status on load. */ if (nc->link_down && s->compat_flags & E1000_FLAG_AUTONEG && s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN && s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG) { s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE; } }
false
qemu
d7a4155265416a1c8f3067b59e68bf5fda1d6215
7,225
START_TEST(invalid_array_comma) { QObject *obj = qobject_from_json("[32,}"); fail_unless(obj == NULL); }
false
qemu
ef76dc59fa5203d146a2acf85a0ad5a5971a4824
7,226
static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len) { struct VirtIOSerialPort *port; struct virtio_console_control cpkt, *gcpkt; uint8_t *buffer; size_t buffer_len; gcpkt = buf; if (len < sizeof(cpkt)) { /* The guest sent an invalid control packet */ return; } cpkt.event = lduw_p(&gcpkt->event); cpkt.value = lduw_p(&gcpkt->value); port = find_port_by_id(vser, ldl_p(&gcpkt->id)); if (!port && cpkt.event != VIRTIO_CONSOLE_DEVICE_READY) return; switch(cpkt.event) { case VIRTIO_CONSOLE_DEVICE_READY: if (!cpkt.value) { error_report("virtio-serial-bus: Guest failure in adding device %s\n", vser->bus.qbus.name); break; } /* * The device is up, we can now tell the device about all the * ports we have here. */ QTAILQ_FOREACH(port, &vser->ports, next) { send_control_event(port, VIRTIO_CONSOLE_PORT_ADD, 1); } break; case VIRTIO_CONSOLE_PORT_READY: if (!cpkt.value) { error_report("virtio-serial-bus: Guest failure in adding port %u for device %s\n", port->id, vser->bus.qbus.name); break; } /* * Now that we know the guest asked for the port name, we're * sure the guest has initialised whatever state is necessary * for this port. Now's a good time to let the guest know if * this port is a console port so that the guest can hook it * up to hvc. */ if (port->is_console) { send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1); } if (port->name) { stw_p(&cpkt.event, VIRTIO_CONSOLE_PORT_NAME); stw_p(&cpkt.value, 1); buffer_len = sizeof(cpkt) + strlen(port->name) + 1; buffer = qemu_malloc(buffer_len); memcpy(buffer, &cpkt, sizeof(cpkt)); memcpy(buffer + sizeof(cpkt), port->name, strlen(port->name)); buffer[buffer_len - 1] = 0; send_control_msg(port, buffer, buffer_len); qemu_free(buffer); } if (port->host_connected) { send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1); } /* * When the guest has asked us for this information it means * the guest is all setup and has its virtqueues * initialised. If some app is interested in knowing about * this event, let it know. */ if (port->info->guest_ready) { port->info->guest_ready(port); } break; case VIRTIO_CONSOLE_PORT_OPEN: port->guest_connected = cpkt.value; if (cpkt.value && port->info->guest_open) { /* Send the guest opened notification if an app is interested */ port->info->guest_open(port); } if (!cpkt.value && port->info->guest_close) { /* Send the guest closed notification if an app is interested */ port->info->guest_close(port); } break; } }
false
qemu
2a3d57ce4278dfd898d8b5639ace21fa4a4fb9bd
7,227
static int mov_write_stbl_tag(ByteIOContext *pb, MOVTrack* track) { offset_t pos = url_ftell(pb); put_be32(pb, 0); /* size */ put_tag(pb, "stbl"); mov_write_stsd_tag(pb, track); mov_write_stts_tag(pb, track); if (track->enc->codec_type == CODEC_TYPE_VIDEO && track->hasKeyframes < track->entry) mov_write_stss_tag(pb, track); if (track->enc->codec_type == CODEC_TYPE_VIDEO && track->hasBframes) mov_write_ctts_tag(pb, track); mov_write_stsc_tag(pb, track); mov_write_stsz_tag(pb, track); mov_write_stco_tag(pb, track); return updateSize(pb, pos); }
false
FFmpeg
b371539a3d9be9b05cb9ea8065e8e3617a45b02f
7,228
static void gen_mtpr(int rb, int regno) { TCGv tmp; int data; if (rb == 31) { tmp = tcg_const_i64(0); } else { tmp = cpu_ir[rb]; } /* The basic registers are data only, and unknown registers are read-zero, write-ignore. */ data = cpu_pr_data(regno); if (data != 0) { if (data & PR_BYTE) { tcg_gen_st8_i64(tmp, cpu_env, data & ~PR_BYTE); } else if (data & PR_LONG) { tcg_gen_st32_i64(tmp, cpu_env, data & ~PR_LONG); } else { tcg_gen_st_i64(tmp, cpu_env, data); } } if (rb == 31) { tcg_temp_free(tmp); } }
false
qemu
3b4fefd6e65a7bdb994d10a9fa36c19b5749b502
7,229
void qemu_unregister_reset(QEMUResetHandler *func, void *opaque) { QEMUResetEntry *re; TAILQ_FOREACH(re, &reset_handlers, entry) { if (re->func == func && re->opaque == opaque) { TAILQ_REMOVE(&reset_handlers, re, entry); qemu_free(re); return; } } }
false
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
7,230
static void blizzard_reg_write(void *opaque, uint8_t reg, uint16_t value) { BlizzardState *s = (BlizzardState *) opaque; switch (reg) { case 0x04: /* PLL M-Divider */ s->pll = (value & 0x3f) + 1; break; case 0x06: /* PLL Lock Range Control */ s->pll_range = value & 3; break; case 0x08: /* PLL Lock Synthesis Control 0 */ s->pll_ctrl &= 0xf00; s->pll_ctrl |= (value << 0) & 0x0ff; break; case 0x0a: /* PLL Lock Synthesis Control 1 */ s->pll_ctrl &= 0x0ff; s->pll_ctrl |= (value << 8) & 0xf00; break; case 0x0c: /* PLL Mode Control 0 */ s->pll_mode = value & 0x77; if ((value & 3) == 0 || (value & 3) == 3) fprintf(stderr, "%s: wrong PLL Control bits (%i)\n", __FUNCTION__, value & 3); break; case 0x0e: /* Clock-Source Select */ s->clksel = value & 0xff; break; case 0x10: /* Memory Controller Activate */ s->memenable = value & 1; break; case 0x14: /* Memory Controller Bank 0 Status Flag */ break; case 0x18: /* Auto-Refresh Interval Setting 0 */ s->memrefresh &= 0xf00; s->memrefresh |= (value << 0) & 0x0ff; break; case 0x1a: /* Auto-Refresh Interval Setting 1 */ s->memrefresh &= 0x0ff; s->memrefresh |= (value << 8) & 0xf00; break; case 0x1c: /* Power-On Sequence Timing Control */ s->timing[0] = value & 0x7f; break; case 0x1e: /* Timing Control 0 */ s->timing[1] = value & 0x17; break; case 0x20: /* Timing Control 1 */ s->timing[2] = value & 0x35; break; case 0x24: /* Arbitration Priority Control */ s->priority = value & 1; break; case 0x28: /* LCD Panel Configuration */ s->lcd_config = value & 0xff; if (value & (1 << 7)) fprintf(stderr, "%s: data swap not supported!\n", __FUNCTION__); break; case 0x2a: /* LCD Horizontal Display Width */ s->x = value << 3; break; case 0x2c: /* LCD Horizontal Non-display Period */ s->hndp = value & 0xff; break; case 0x2e: /* LCD Vertical Display Height 0 */ s->y &= 0x300; s->y |= (value << 0) & 0x0ff; break; case 0x30: /* LCD Vertical Display Height 1 */ s->y &= 0x0ff; s->y |= (value << 8) & 0x300; break; case 0x32: /* LCD Vertical Non-display Period */ s->vndp = value & 0xff; break; case 0x34: /* LCD HS Pulse-width */ s->hsync = value & 0xff; break; case 0x36: /* LCD HS Pulse Start Position */ s->skipx = value & 0xff; break; case 0x38: /* LCD VS Pulse-width */ s->vsync = value & 0xbf; break; case 0x3a: /* LCD VS Pulse Start Position */ s->skipy = value & 0xff; break; case 0x3c: /* PCLK Polarity */ s->pclk = value & 0x82; /* Affects calculation of s->hndp, s->hsync and s->skipx. */ break; case 0x3e: /* High-speed Serial Interface Tx Configuration Port 0 */ s->hssi_config[0] = value; break; case 0x40: /* High-speed Serial Interface Tx Configuration Port 1 */ s->hssi_config[1] = value; if (((value >> 4) & 3) == 3) fprintf(stderr, "%s: Illegal active-data-links value\n", __FUNCTION__); break; case 0x42: /* High-speed Serial Interface Tx Mode */ s->hssi_config[2] = value & 0xbd; break; case 0x44: /* TV Display Configuration */ s->tv_config = value & 0xfe; break; case 0x46 ... 0x4c: /* TV Vertical Blanking Interval Data bits 0 */ s->tv_timing[(reg - 0x46) >> 1] = value; break; case 0x4e: /* VBI: Closed Caption / XDS Control / Status */ s->vbi = value; break; case 0x50: /* TV Horizontal Start Position */ s->tv_x = value; break; case 0x52: /* TV Vertical Start Position */ s->tv_y = value & 0x7f; break; case 0x54: /* TV Test Pattern Setting */ s->tv_test = value; break; case 0x56: /* TV Filter Setting */ s->tv_filter_config = value & 0xbf; break; case 0x58: /* TV Filter Coefficient Index */ s->tv_filter_idx = value & 0x1f; break; case 0x5a: /* TV Filter Coefficient Data */ if (s->tv_filter_idx < 0x20) s->tv_filter_coeff[s->tv_filter_idx ++] = value; break; case 0x60: /* Input YUV/RGB Translate Mode 0 */ s->yrc[0] = value & 0xb0; break; case 0x62: /* Input YUV/RGB Translate Mode 1 */ s->yrc[1] = value & 0x30; break; case 0x64: /* U Data Fix */ s->u = value & 0xff; break; case 0x66: /* V Data Fix */ s->v = value & 0xff; break; case 0x68: /* Display Mode */ if ((s->mode ^ value) & 3) s->invalidate = 1; s->mode = value & 0xb7; s->enable = value & 1; s->blank = (value >> 1) & 1; if (value & (1 << 4)) fprintf(stderr, "%s: Macrovision enable attempt!\n", __FUNCTION__); break; case 0x6a: /* Special Effects */ s->effect = value & 0xfb; break; case 0x6c: /* Input Window X Start Position 0 */ s->ix[0] &= 0x300; s->ix[0] |= (value << 0) & 0x0ff; break; case 0x6e: /* Input Window X Start Position 1 */ s->ix[0] &= 0x0ff; s->ix[0] |= (value << 8) & 0x300; break; case 0x70: /* Input Window Y Start Position 0 */ s->iy[0] &= 0x300; s->iy[0] |= (value << 0) & 0x0ff; break; case 0x72: /* Input Window Y Start Position 1 */ s->iy[0] &= 0x0ff; s->iy[0] |= (value << 8) & 0x300; break; case 0x74: /* Input Window X End Position 0 */ s->ix[1] &= 0x300; s->ix[1] |= (value << 0) & 0x0ff; break; case 0x76: /* Input Window X End Position 1 */ s->ix[1] &= 0x0ff; s->ix[1] |= (value << 8) & 0x300; break; case 0x78: /* Input Window Y End Position 0 */ s->iy[1] &= 0x300; s->iy[1] |= (value << 0) & 0x0ff; break; case 0x7a: /* Input Window Y End Position 1 */ s->iy[1] &= 0x0ff; s->iy[1] |= (value << 8) & 0x300; break; case 0x7c: /* Output Window X Start Position 0 */ s->ox[0] &= 0x300; s->ox[0] |= (value << 0) & 0x0ff; break; case 0x7e: /* Output Window X Start Position 1 */ s->ox[0] &= 0x0ff; s->ox[0] |= (value << 8) & 0x300; break; case 0x80: /* Output Window Y Start Position 0 */ s->oy[0] &= 0x300; s->oy[0] |= (value << 0) & 0x0ff; break; case 0x82: /* Output Window Y Start Position 1 */ s->oy[0] &= 0x0ff; s->oy[0] |= (value << 8) & 0x300; break; case 0x84: /* Output Window X End Position 0 */ s->ox[1] &= 0x300; s->ox[1] |= (value << 0) & 0x0ff; break; case 0x86: /* Output Window X End Position 1 */ s->ox[1] &= 0x0ff; s->ox[1] |= (value << 8) & 0x300; break; case 0x88: /* Output Window Y End Position 0 */ s->oy[1] &= 0x300; s->oy[1] |= (value << 0) & 0x0ff; break; case 0x8a: /* Output Window Y End Position 1 */ s->oy[1] &= 0x0ff; s->oy[1] |= (value << 8) & 0x300; break; case 0x8c: /* Input Data Format */ s->iformat = value & 0xf; s->bpp = blizzard_iformat_bpp[s->iformat]; if (!s->bpp) fprintf(stderr, "%s: Illegal or unsupported input format %x\n", __FUNCTION__, s->iformat); break; case 0x8e: /* Data Source Select */ s->source = value & 7; /* Currently all windows will be "destructive overlays". */ if ((!(s->effect & (1 << 3)) && (s->ix[0] != s->ox[0] || s->iy[0] != s->oy[0] || s->ix[1] != s->ox[1] || s->iy[1] != s->oy[1])) || !((s->ix[1] - s->ix[0]) & (s->iy[1] - s->iy[0]) & (s->ox[1] - s->ox[0]) & (s->oy[1] - s->oy[0]) & 1)) fprintf(stderr, "%s: Illegal input/output window positions\n", __FUNCTION__); blizzard_transfer_setup(s); break; case 0x90: /* Display Memory Data Port */ if (!s->data.len && !blizzard_transfer_setup(s)) break; *s->data.ptr ++ = value; if (-- s->data.len == 0) blizzard_window(s); break; case 0xa8: /* Border Color 0 */ s->border_r = value; break; case 0xaa: /* Border Color 1 */ s->border_g = value; break; case 0xac: /* Border Color 2 */ s->border_b = value; break; case 0xb4: /* Gamma Correction Enable */ s->gamma_config = value & 0x87; break; case 0xb6: /* Gamma Correction Table Index */ s->gamma_idx = value; break; case 0xb8: /* Gamma Correction Table Data */ s->gamma_lut[s->gamma_idx ++] = value; break; case 0xba: /* 3x3 Matrix Enable */ s->matrix_ena = value & 1; break; case 0xbc ... 0xde: /* Coefficient Registers */ s->matrix_coeff[(reg - 0xbc) >> 1] = value & ((reg & 2) ? 0x80 : 0xff); break; case 0xe0: /* 3x3 Matrix Red Offset */ s->matrix_r = value; break; case 0xe2: /* 3x3 Matrix Green Offset */ s->matrix_g = value; break; case 0xe4: /* 3x3 Matrix Blue Offset */ s->matrix_b = value; break; case 0xe6: /* Power-save */ s->pm = value & 0x83; if (value & s->mode & 1) fprintf(stderr, "%s: The display must be disabled before entering " "Standby Mode\n", __FUNCTION__); break; case 0xe8: /* Non-display Period Control / Status */ s->status = value & 0x1b; break; case 0xea: /* RGB Interface Control */ s->rgbgpio_dir = value & 0x8f; break; case 0xec: /* RGB Interface Status */ s->rgbgpio = value & 0xcf; break; case 0xee: /* General-purpose IO Pins Configuration */ s->gpio_dir = value; break; case 0xf0: /* General-purpose IO Pins Status / Control */ s->gpio = value; break; case 0xf2: /* GPIO Positive Edge Interrupt Trigger */ s->gpio_edge[0] = value; break; case 0xf4: /* GPIO Negative Edge Interrupt Trigger */ s->gpio_edge[1] = value; break; case 0xf6: /* GPIO Interrupt Status */ s->gpio_irq &= value; break; case 0xf8: /* GPIO Pull-down Control */ s->gpio_pdown = value; break; default: fprintf(stderr, "%s: unknown register %02x\n", __FUNCTION__, reg); break; } }
false
qemu
a89f364ae8740dfc31b321eed9ee454e996dc3c1
7,232
uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgorithm hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, Error **errp) { uint8_t out[32]; uint64_t iterations = (1 << 15); unsigned long long delta_ms, start_ms, end_ms; while (1) { if (qcrypto_pbkdf2_get_thread_cpu(&start_ms, errp) < 0) { return -1; } if (qcrypto_pbkdf2(hash, key, nkey, salt, nsalt, iterations, out, sizeof(out), errp) < 0) { return -1; } if (qcrypto_pbkdf2_get_thread_cpu(&end_ms, errp) < 0) { return -1; } delta_ms = end_ms - start_ms; if (delta_ms > 500) { break; } else if (delta_ms < 100) { iterations = iterations * 10; } else { iterations = (iterations * 1000 / delta_ms); } } iterations = iterations * 1000 / delta_ms; return iterations; }
false
qemu
8813800b7d995d8b54ef0a1e16d41fc13d8b5f3a
7,233
static int pci_device_hot_remove(Monitor *mon, const char *pci_addr) { PCIDevice *d; int dom, bus; unsigned slot; Error *local_err = NULL; if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) { return -1; } d = pci_find_device(pci_find_root_bus(dom), bus, PCI_DEVFN(slot, 0)); if (!d) { monitor_printf(mon, "slot %d empty\n", slot); return -1; } qdev_unplug(&d->qdev, &local_err); if (error_is_set(&local_err)) { monitor_printf(mon, "%s\n", error_get_pretty(local_err)); error_free(local_err); return -1; } return 0; }
false
qemu
79ca616f291124d166ca173e512c4ace1c2fe8b2
7,234
void hmp_info_memdev(Monitor *mon, const QDict *qdict) { Error *err = NULL; MemdevList *memdev_list = qmp_query_memdev(&err); MemdevList *m = memdev_list; StringOutputVisitor *ov; char *str; int i = 0; while (m) { ov = string_output_visitor_new(false); visit_type_uint16List(string_output_get_visitor(ov), NULL, &m->value->host_nodes, NULL); monitor_printf(mon, "memory backend: %d\n", i); monitor_printf(mon, " size: %" PRId64 "\n", m->value->size); monitor_printf(mon, " merge: %s\n", m->value->merge ? "true" : "false"); monitor_printf(mon, " dump: %s\n", m->value->dump ? "true" : "false"); monitor_printf(mon, " prealloc: %s\n", m->value->prealloc ? "true" : "false"); monitor_printf(mon, " policy: %s\n", HostMemPolicy_lookup[m->value->policy]); str = string_output_get_string(ov); monitor_printf(mon, " host nodes: %s\n", str); g_free(str); string_output_visitor_cleanup(ov); m = m->next; i++; } monitor_printf(mon, "\n"); qapi_free_MemdevList(memdev_list); }
false
qemu
e7ca56562990991bc614a43b9351ee0737f3045d
7,235
static void apply_motion_8x8(RoqContext *ri, int x, int y, unsigned char mv, signed char mean_x, signed char mean_y) { int mx, my, i, j, hw; unsigned char *pa, *pb; mx = x + 8 - (mv >> 4) - mean_x; my = y + 8 - (mv & 0xf) - mean_y; pa = ri->current_frame.data[0] + (y * ri->y_stride) + x; pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx; for(i = 0; i < 8; i++) { pa[0] = pb[0]; pa[1] = pb[1]; pa[2] = pb[2]; pa[3] = pb[3]; pa[4] = pb[4]; pa[5] = pb[5]; pa[6] = pb[6]; pa[7] = pb[7]; pa += ri->y_stride; pb += ri->y_stride; } #if 0 pa = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2; pb = ri->last_frame.data[1] + (my/2) * (ri->c_stride) + (mx + 1)/2; for(i = 0; i < 4; i++) { pa[0] = pb[0]; pa[1] = pb[1]; pa[2] = pb[2]; pa[3] = pb[3]; pa += ri->c_stride; pb += ri->c_stride; } pa = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2; pb = ri->last_frame.data[2] + (my/2) * (ri->c_stride) + (mx + 1)/2; for(i = 0; i < 4; i++) { pa[0] = pb[0]; pa[1] = pb[1]; pa[2] = pb[2]; pa[3] = pb[3]; pa += ri->c_stride; pb += ri->c_stride; } #else hw = ri->c_stride; pa = ri->current_frame.data[1] + (y * ri->y_stride)/4 + x/2; pb = ri->last_frame.data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2; for(j = 0; j < 2; j++) { for(i = 0; i < 4; i++) { switch(((my & 0x01) << 1) | (mx & 0x01)) { case 0: pa[0] = pb[0]; pa[1] = pb[1]; pa[2] = pb[2]; pa[3] = pb[3]; break; case 1: pa[0] = avg2(pb[0], pb[1]); pa[1] = avg2(pb[1], pb[2]); pa[2] = avg2(pb[2], pb[3]); pa[3] = avg2(pb[3], pb[4]); break; case 2: pa[0] = avg2(pb[0], pb[hw]); pa[1] = avg2(pb[1], pb[hw+1]); pa[2] = avg2(pb[2], pb[hw+2]); pa[3] = avg2(pb[3], pb[hw+3]); break; case 3: pa[0] = avg4(pb[0], pb[1], pb[hw], pb[hw+1]); pa[1] = avg4(pb[1], pb[2], pb[hw+1], pb[hw+2]); pa[2] = avg4(pb[2], pb[3], pb[hw+2], pb[hw+3]); pa[3] = avg4(pb[3], pb[4], pb[hw+3], pb[hw+4]); break; } pa += ri->c_stride; pb += ri->c_stride; } pa = ri->current_frame.data[2] + (y * ri->y_stride)/4 + x/2; pb = ri->last_frame.data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2; } #endif }
false
FFmpeg
b9029997d4694b6533556480fe0ab1f3f9779a56
7,236
void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { if (h&3) ff_avg_dirac_pixels16_c(dst, src, stride, h); else ff_avg_pixels16_sse2(dst, src[0], stride, h); }
false
FFmpeg
6a4832caaede15e3d918b1408ff83fe30324507b
7,237
int ff_ape_write_tag(AVFormatContext *s) { AVDictionaryEntry *e = NULL; int64_t start, end; int size, count = 0; if (!s->pb->seekable) return 0; start = avio_tell(s->pb); // header avio_write(s->pb, "APETAGEX", 8); // id avio_wl32 (s->pb, APE_TAG_VERSION); // version avio_wl32(s->pb, 0); // reserve space for size avio_wl32(s->pb, 0); // reserve space for tag count // flags avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_CONTAINS_FOOTER | APE_TAG_FLAG_IS_HEADER); ffio_fill(s->pb, 0, 8); // reserved while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) { int val_len = strlen(e->value); avio_wl32(s->pb, val_len); // value length avio_wl32(s->pb, 0); // item flags avio_put_str(s->pb, e->key); // key avio_write(s->pb, e->value, val_len); // value count++; } size = avio_tell(s->pb) - start; // footer avio_write(s->pb, "APETAGEX", 8); // id avio_wl32 (s->pb, APE_TAG_VERSION); // version avio_wl32(s->pb, size); // size avio_wl32(s->pb, count); // tag count // flags avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_CONTAINS_FOOTER); ffio_fill(s->pb, 0, 8); // reserved // update values in the header end = avio_tell(s->pb); avio_seek(s->pb, start + 12, SEEK_SET); avio_wl32(s->pb, size); avio_wl32(s->pb, count); avio_seek(s->pb, end, SEEK_SET); return 0; }
false
FFmpeg
83548fe894cdb455cc127f754d09905b6d23c173
7,238
static void gen_cp0 (CPUMIPSState *env, DisasContext *ctx, uint32_t opc, int rt, int rd) { const char *opn = "ldst"; switch (opc) { case OPC_MFC0: if (rt == 0) { /* Treat as NOP. */ return; } gen_mfc0(env, ctx, cpu_gpr[rt], rd, ctx->opcode & 0x7); opn = "mfc0"; break; case OPC_MTC0: { TCGv t0 = tcg_temp_new(); gen_load_gpr(t0, rt); gen_mtc0(env, ctx, t0, rd, ctx->opcode & 0x7); tcg_temp_free(t0); } opn = "mtc0"; break; #if defined(TARGET_MIPS64) case OPC_DMFC0: check_insn(env, ctx, ISA_MIPS3); if (rt == 0) { /* Treat as NOP. */ return; } gen_dmfc0(env, ctx, cpu_gpr[rt], rd, ctx->opcode & 0x7); opn = "dmfc0"; break; case OPC_DMTC0: check_insn(env, ctx, ISA_MIPS3); { TCGv t0 = tcg_temp_new(); gen_load_gpr(t0, rt); gen_dmtc0(env, ctx, t0, rd, ctx->opcode & 0x7); tcg_temp_free(t0); } opn = "dmtc0"; break; #endif case OPC_MFTR: check_insn(env, ctx, ASE_MT); if (rd == 0) { /* Treat as NOP. */ return; } gen_mftr(env, ctx, rt, rd, (ctx->opcode >> 5) & 1, ctx->opcode & 0x7, (ctx->opcode >> 4) & 1); opn = "mftr"; break; case OPC_MTTR: check_insn(env, ctx, ASE_MT); gen_mttr(env, ctx, rd, rt, (ctx->opcode >> 5) & 1, ctx->opcode & 0x7, (ctx->opcode >> 4) & 1); opn = "mttr"; break; case OPC_TLBWI: opn = "tlbwi"; if (!env->tlb->helper_tlbwi) goto die; gen_helper_tlbwi(); break; case OPC_TLBWR: opn = "tlbwr"; if (!env->tlb->helper_tlbwr) goto die; gen_helper_tlbwr(); break; case OPC_TLBP: opn = "tlbp"; if (!env->tlb->helper_tlbp) goto die; gen_helper_tlbp(); break; case OPC_TLBR: opn = "tlbr"; if (!env->tlb->helper_tlbr) goto die; gen_helper_tlbr(); break; case OPC_ERET: opn = "eret"; check_insn(env, ctx, ISA_MIPS2); gen_helper_eret(); ctx->bstate = BS_EXCP; break; case OPC_DERET: opn = "deret"; check_insn(env, ctx, ISA_MIPS32); if (!(ctx->hflags & MIPS_HFLAG_DM)) { MIPS_INVAL(opn); generate_exception(ctx, EXCP_RI); } else { gen_helper_deret(); ctx->bstate = BS_EXCP; } break; case OPC_WAIT: opn = "wait"; check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32); /* If we get an exception, we want to restart at next instruction */ ctx->pc += 4; save_cpu_state(ctx, 1); ctx->pc -= 4; gen_helper_wait(); ctx->bstate = BS_EXCP; break; default: die: MIPS_INVAL(opn); generate_exception(ctx, EXCP_RI); return; } (void)opn; /* avoid a compiler warning */ MIPS_DEBUG("%s %s %d", opn, regnames[rt], rd); }
true
qemu
2e15497c5b8d0d172dece0cf56e2d2e977a6b679
7,239
static inline uint64_t v4l2_get_pts(V4L2Buffer *avbuf) { V4L2m2mContext *s = buf_to_m2mctx(avbuf); AVRational v4l2_timebase = { 1, USEC_PER_SEC }; int64_t v4l2_pts; /* convert pts back to encoder timebase */ v4l2_pts = avbuf->buf.timestamp.tv_sec * USEC_PER_SEC + avbuf->buf.timestamp.tv_usec; return av_rescale_q(v4l2_pts, v4l2_timebase, s->avctx->time_base); }
true
FFmpeg
2e96f5278095d44f090a4d89507e62d27cccf3b9
7,240
static int parallels_create(const char *filename, QemuOpts *opts, Error **errp) { int64_t total_size, cl_size; uint8_t tmp[BDRV_SECTOR_SIZE]; Error *local_err = NULL; BlockBackend *file; uint32_t bat_entries, bat_sectors; ParallelsHeader header; int ret; total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); cl_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, DEFAULT_CLUSTER_SIZE), BDRV_SECTOR_SIZE); ret = bdrv_create_file(filename, opts, &local_err); if (ret < 0) { return ret; file = blk_new_open(filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, &local_err); if (file == NULL) { return -EIO; blk_set_allow_write_beyond_eof(file, true); ret = blk_truncate(file, 0); if (ret < 0) { goto exit; bat_entries = DIV_ROUND_UP(total_size, cl_size); bat_sectors = DIV_ROUND_UP(bat_entry_off(bat_entries), cl_size); bat_sectors = (bat_sectors * cl_size) >> BDRV_SECTOR_BITS; memset(&header, 0, sizeof(header)); memcpy(header.magic, HEADER_MAGIC2, sizeof(header.magic)); header.version = cpu_to_le32(HEADER_VERSION); /* don't care much about geometry, it is not used on image level */ header.heads = cpu_to_le32(16); header.cylinders = cpu_to_le32(total_size / BDRV_SECTOR_SIZE / 16 / 32); header.tracks = cpu_to_le32(cl_size >> BDRV_SECTOR_BITS); header.bat_entries = cpu_to_le32(bat_entries); header.nb_sectors = cpu_to_le64(DIV_ROUND_UP(total_size, BDRV_SECTOR_SIZE)); header.data_off = cpu_to_le32(bat_sectors); /* write all the data */ memset(tmp, 0, sizeof(tmp)); memcpy(tmp, &header, sizeof(header)); ret = blk_pwrite(file, 0, tmp, BDRV_SECTOR_SIZE, 0); if (ret < 0) { goto exit; ret = blk_pwrite_zeroes(file, BDRV_SECTOR_SIZE, (bat_sectors - 1) << BDRV_SECTOR_BITS, 0); if (ret < 0) { goto exit; ret = 0; done: blk_unref(file); return ret; exit: error_setg_errno(errp, -ret, "Failed to create Parallels image"); goto done;
true
qemu
555a608c5d5dcc44e45a483ca09b449d8db519d1
7,241
static int stdio_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int size) { QEMUFileStdio *s = opaque; return fwrite(buf, 1, size, s->stdio_file); }
true
qemu
aded6539d983280212e08d09f14157b1cb4d58cc
7,242
void *address_space_map(AddressSpace *as, hwaddr addr, hwaddr *plen, bool is_write) { hwaddr len = *plen; hwaddr done = 0; hwaddr l, xlat, base; MemoryRegion *mr, *this_mr; ram_addr_t raddr; if (len == 0) { return NULL; } l = len; mr = address_space_translate(as, addr, &xlat, &l, is_write); if (!memory_access_is_direct(mr, is_write)) { if (bounce.buffer) { return NULL; } /* Avoid unbounded allocations */ l = MIN(l, TARGET_PAGE_SIZE); bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, l); bounce.addr = addr; bounce.len = l; memory_region_ref(mr); bounce.mr = mr; if (!is_write) { address_space_read(as, addr, bounce.buffer, l); } *plen = l; return bounce.buffer; } base = xlat; raddr = memory_region_get_ram_addr(mr); for (;;) { len -= l; addr += l; done += l; if (len == 0) { break; } l = len; this_mr = address_space_translate(as, addr, &xlat, &l, is_write); if (this_mr != mr || xlat != base + done) { break; } } memory_region_ref(mr); *plen = done; return qemu_ram_ptr_length(raddr + base, plen); }
true
qemu
c2cba0ffe495b60c4cc58080281e99c7a6580d4b
7,244
void ff_aac_search_for_pred(AACEncContext *s, SingleChannelElement *sce) { int sfb, i, count = 0, cost_coeffs = 0, cost_pred = 0; const int pmax = FFMIN(sce->ics.max_sfb, ff_aac_pred_sfb_max[s->samplerate_index]); float *O34 = &s->scoefs[128*0], *P34 = &s->scoefs[128*1]; float *SENT = &s->scoefs[128*2], *S34 = &s->scoefs[128*3]; float *QERR = &s->scoefs[128*4]; if (sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE) { sce->ics.predictor_present = 0; return; } if (!sce->ics.predictor_initialized) { reset_all_predictors(sce->predictor_state); sce->ics.predictor_initialized = 1; memcpy(sce->prcoeffs, sce->coeffs, 1024*sizeof(float)); for (i = 1; i < 31; i++) sce->ics.predictor_reset_count[i] = i; } update_pred_resets(sce); memcpy(sce->band_alt, sce->band_type, sizeof(sce->band_type)); for (sfb = PRED_SFB_START; sfb < pmax; sfb++) { int cost1, cost2, cb_p; float dist1, dist2, dist_spec_err = 0.0f; const int cb_n = sce->band_type[sfb]; const int start_coef = sce->ics.swb_offset[sfb]; const int num_coeffs = sce->ics.swb_offset[sfb + 1] - start_coef; const FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[sfb]; if (start_coef + num_coeffs > MAX_PREDICTORS || (s->cur_channel && sce->band_type[sfb] >= INTENSITY_BT2) || sce->band_type[sfb] == NOISE_BT) continue; /* Normal coefficients */ abs_pow34_v(O34, &sce->coeffs[start_coef], num_coeffs); dist1 = quantize_and_encode_band_cost(s, NULL, &sce->coeffs[start_coef], NULL, O34, num_coeffs, sce->sf_idx[sfb], cb_n, s->lambda / band->threshold, INFINITY, &cost1, 0); cost_coeffs += cost1; /* Encoded coefficients - needed for #bits, band type and quant. error */ for (i = 0; i < num_coeffs; i++) SENT[i] = sce->coeffs[start_coef + i] - sce->prcoeffs[start_coef + i]; abs_pow34_v(S34, SENT, num_coeffs); if (cb_n < RESERVED_BT) cb_p = find_min_book(find_max_val(1, num_coeffs, S34), sce->sf_idx[sfb]); else cb_p = cb_n; quantize_and_encode_band_cost(s, NULL, SENT, QERR, S34, num_coeffs, sce->sf_idx[sfb], cb_p, s->lambda / band->threshold, INFINITY, &cost2, 0); /* Reconstructed coefficients - needed for distortion measurements */ for (i = 0; i < num_coeffs; i++) sce->prcoeffs[start_coef + i] += QERR[i] != 0.0f ? (sce->prcoeffs[start_coef + i] - QERR[i]) : 0.0f; abs_pow34_v(P34, &sce->prcoeffs[start_coef], num_coeffs); if (cb_n < RESERVED_BT) cb_p = find_min_book(find_max_val(1, num_coeffs, P34), sce->sf_idx[sfb]); else cb_p = cb_n; dist2 = quantize_and_encode_band_cost(s, NULL, &sce->prcoeffs[start_coef], NULL, P34, num_coeffs, sce->sf_idx[sfb], cb_p, s->lambda / band->threshold, INFINITY, NULL, 0); for (i = 0; i < num_coeffs; i++) dist_spec_err += (O34[i] - P34[i])*(O34[i] - P34[i]); dist_spec_err *= s->lambda / band->threshold; dist2 += dist_spec_err; if (dist2 <= dist1 && cb_p <= cb_n) { cost_pred += cost2; sce->ics.prediction_used[sfb] = 1; sce->band_alt[sfb] = cb_n; sce->band_type[sfb] = cb_p; count++; } else { cost_pred += cost1; sce->band_alt[sfb] = cb_p; } } if (count && cost_coeffs < cost_pred) { count = 0; for (sfb = PRED_SFB_START; sfb < pmax; sfb++) RESTORE_PRED(sce, sfb); memset(&sce->ics.prediction_used, 0, sizeof(sce->ics.prediction_used)); } sce->ics.predictor_present = !!count; }
true
FFmpeg
01ecb7172b684f1c4b3e748f95c5a9a494ca36ec
7,245
static void new_subtitle_stream(AVFormatContext *oc, int file_idx) { AVStream *st; OutputStream *ost; AVCodec *codec=NULL; AVCodecContext *subtitle_enc; enum CodecID codec_id = CODEC_ID_NONE; if(!subtitle_stream_copy){ if (subtitle_codec_name) { codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); codec = avcodec_find_encoder_by_name(subtitle_codec_name); } else { codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE); codec = avcodec_find_encoder(codec_id); } } ost = new_output_stream(oc, file_idx, codec); st = ost->st; subtitle_enc = st->codec; ost->bitstream_filters = subtitle_bitstream_filters; subtitle_bitstream_filters= NULL; subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE; if(subtitle_codec_tag) subtitle_enc->codec_tag= subtitle_codec_tag; if (oc->oformat->flags & AVFMT_GLOBALHEADER) { subtitle_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; } if (subtitle_stream_copy) { st->stream_copy = 1; } else { subtitle_enc->codec_id = codec_id; set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); } if (subtitle_language) { av_dict_set(&st->metadata, "language", subtitle_language, 0); av_freep(&subtitle_language); } subtitle_disable = 0; av_freep(&subtitle_codec_name); subtitle_stream_copy = 0; }
false
FFmpeg
a9eb4f0899de04a3093a04f461611c6f0664398e
7,246
static int compile_kernel_file(GPUEnv *gpu_env, const char *build_options) { cl_int status; char *temp, *source_str = NULL; size_t source_str_len = 0; int i, ret = 0; for (i = 0; i < gpu_env->kernel_code_count; i++) { if (!gpu_env->kernel_code[i].is_compiled) source_str_len += strlen(gpu_env->kernel_code[i].kernel_string); } if (!source_str_len) { return 0; } source_str = av_mallocz(source_str_len + 1); if (!source_str) { return AVERROR(ENOMEM); } temp = source_str; for (i = 0; i < gpu_env->kernel_code_count; i++) { if (!gpu_env->kernel_code[i].is_compiled) { memcpy(temp, gpu_env->kernel_code[i].kernel_string, strlen(gpu_env->kernel_code[i].kernel_string)); gpu_env->kernel_code[i].is_compiled = 1; temp += strlen(gpu_env->kernel_code[i].kernel_string); } } /* create a CL program using the kernel source */ gpu_env->programs[gpu_env->program_count] = clCreateProgramWithSource(gpu_env->context, 1, (const char **)(&source_str), &source_str_len, &status); if(status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not create OpenCL program with source code: %s\n", opencl_errstr(status)); ret = AVERROR_EXTERNAL; goto end; } if (!gpu_env->programs[gpu_env->program_count]) { av_log(&openclutils, AV_LOG_ERROR, "Created program is NULL\n"); ret = AVERROR_EXTERNAL; goto end; } i = 0; if (gpu_env->usr_spec_dev_info.dev_idx >= 0) i = gpu_env->usr_spec_dev_info.dev_idx; /* create a cl program executable for all the devices specified */ if (!gpu_env->is_user_created) status = clBuildProgram(gpu_env->programs[gpu_env->program_count], 1, &gpu_env->device_ids[i], build_options, NULL, NULL); else status = clBuildProgram(gpu_env->programs[gpu_env->program_count], 1, &(gpu_env->device_id), build_options, NULL, NULL); if (status != CL_SUCCESS) { av_log(&openclutils, AV_LOG_ERROR, "Could not compile OpenCL kernel: %s\n", opencl_errstr(status)); ret = AVERROR_EXTERNAL; goto end; } gpu_env->program_count++; end: av_free(source_str); return ret; }
false
FFmpeg
57d77b3963ce1023eaf5ada8cba58b9379405cc8
7,247
static void read_ttag(AVFormatContext *s, int taglen, const char *key) { char *q, dst[512]; int len, dstlen = sizeof(dst) - 1; unsigned genre; dst[0] = 0; if (taglen < 1) return; taglen--; /* account for encoding type byte */ switch (get_byte(s->pb)) { /* encoding type */ case 0: /* ISO-8859-1 (0 - 255 maps directly into unicode) */ q = dst; while (taglen--) { uint8_t tmp; PUT_UTF8(get_byte(s->pb), tmp, if (q - dst < dstlen - 1) *q++ = tmp;) } *q = '\0'; break; case 3: /* UTF-8 */ len = FFMIN(taglen, dstlen - 1); get_buffer(s->pb, dst, len); dst[len] = 0; break; } if (!strcmp(key, "genre") && (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d", &genre) == 1) && genre <= ID3v1_GENRE_MAX) av_strlcpy(dst, ff_id3v1_genre_str[genre], sizeof(dst)); if (*dst) av_metadata_set(&s->metadata, key, dst); }
false
FFmpeg
787f8fad00c66fc225662f7defb90e79c112ed40
7,248
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_SOD) { Jpeg2000Tile *tile = s->tile + s->curtileno; Jpeg2000TilePart *tp = tile->tile_part + tile->tp_idx; bytestream2_init(&tp->tpg, s->g.buffer, tp->tp_end - s->g.buffer); bytestream2_skip(&s->g, tp->tp_end - s->g.buffer); continue; } if (marker == JPEG2000_EOC) break; if (bytestream2_get_bytes_left(&s->g) < 2) return AVERROR(EINVAL); len = bytestream2_get_be16u(&s->g); switch (marker) { case JPEG2000_SIZ: ret = get_siz(s); if (!s->tile) s->numXtiles = s->numYtiles = 0; 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: if (!(ret = get_sot(s, len))) { av_assert1(s->curtileno >= 0); codsty = s->tile[s->curtileno].codsty; qntsty = s->tile[s->curtileno].qntsty; properties = s->tile[s->curtileno].properties; } 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 || ret) { av_log(s->avctx, AV_LOG_ERROR, "error during processing marker segment %.4x\n", marker); return ret ? ret : -1; } } return 0; }
false
FFmpeg
b26bcd08e670b90740f7253f21adddafb9d8c478
7,249
static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb) { int qpi, i, j, bit, run_length, blocks_decoded, num_blocks_at_qpi; int num_blocks = s->coded_fragment_list_index; for (qpi = 0; qpi < s->nqps-1 && num_blocks > 0; qpi++) { i = blocks_decoded = num_blocks_at_qpi = 0; bit = get_bits1(gb); do { run_length = get_vlc2(gb, s->superblock_run_length_vlc.table, 6, 2) + 1; if (run_length == 34) run_length += get_bits(gb, 12); blocks_decoded += run_length; if (!bit) num_blocks_at_qpi += run_length; for (j = 0; j < run_length; i++) { if (i > s->coded_fragment_list_index) return -1; if (s->all_fragments[s->coded_fragment_list[i]].qpi == qpi) { s->all_fragments[s->coded_fragment_list[i]].qpi += bit; j++; } } if (run_length == 4129) bit = get_bits1(gb); else bit ^= 1; } while (blocks_decoded < num_blocks); num_blocks -= num_blocks_at_qpi; } return 0; }
false
FFmpeg
310afddfe0c31ffd844eb640bdf2b3f052286dbe
7,251
static void v9fs_mkdir(void *opaque) { V9fsPDU *pdu = opaque; size_t offset = 7; int32_t fid; struct stat stbuf; V9fsQID qid; V9fsString name; V9fsFidState *fidp; gid_t gid; int mode; int err = 0; v9fs_string_init(&name); err = pdu_unmarshal(pdu, offset, "dsdd", &fid, &name, &mode, &gid); if (err < 0) { trace_v9fs_mkdir(pdu->tag, pdu->id, fid, name.data, mode, gid); fidp = get_fid(pdu, fid); if (fidp == NULL) { err = v9fs_co_mkdir(pdu, fidp, &name, mode, fidp->uid, gid, &stbuf); if (err < 0) { goto out; stat_to_qid(&stbuf, &qid); err = pdu_marshal(pdu, offset, "Q", &qid); if (err < 0) { goto out; err += offset; trace_v9fs_mkdir_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path, err); out: put_fid(pdu, fidp); out_nofid: pdu_complete(pdu, err); v9fs_string_free(&name);
true
qemu
fff39a7ad09da07ef490de05c92c91f22f8002f2
7,252
static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data) { PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); uint32_t vmx = kvmppc_get_vmx(); uint32_t dfp = kvmppc_get_dfp(); /* Now fix up the class with information we can query from the host */ if (vmx != -1) { /* Only override when we know what the host supports */ alter_insns(&pcc->insns_flags, PPC_ALTIVEC, vmx > 0); alter_insns(&pcc->insns_flags2, PPC2_VSX, vmx > 1); } if (dfp != -1) { /* Only override when we know what the host supports */ alter_insns(&pcc->insns_flags2, PPC2_DFP, dfp); } if (dcache_size != -1) { pcc->l1_dcache_size = dcache_size; } if (icache_size != -1) { pcc->l1_icache_size = icache_size; } }
true
qemu
0cbad81f70546b58f08de3225f1eca7a8b869b09
7,253
static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { const uint8_t *first_buf; int first_buf_index = 0, i; /* This is probably being paranoid, but handle cases of zero size vectors. */ for (i = 0; i < qiov->niov; i++) { if (qiov->iov[i].iov_len) { assert(qiov->iov[i].iov_len >= 512); first_buf_index = i; break; } } first_buf = qiov->iov[first_buf_index].iov_base; if (check_write_unsafe(bs, sector_num, first_buf, nb_sectors)) { RawScrubberBounce *b; int ret; /* write the first sector using sync I/O */ ret = raw_write_scrubbed_bootsect(bs, first_buf); if (ret < 0) { return NULL; } /* adjust request to be everything but first sector */ b = qemu_malloc(sizeof(*b)); b->cb = cb; b->opaque = opaque; qemu_iovec_init(&b->qiov, qiov->nalloc); qemu_iovec_concat(&b->qiov, qiov, qiov->size); b->qiov.size -= 512; b->qiov.iov[first_buf_index].iov_base += 512; b->qiov.iov[first_buf_index].iov_len -= 512; return bdrv_aio_writev(bs->file, sector_num + 1, &b->qiov, nb_sectors - 1, raw_aio_writev_scrubbed, b); } return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque); }
true
qemu
8b33d9eeba91422ee2d73b6936ad57262d18cf5a
7,254
void ppc_slb_invalidate_all (CPUPPCState *env) { target_phys_addr_t sr_base; uint64_t tmp64; int n, do_invalidate; do_invalidate = 0; sr_base = env->spr[SPR_ASR]; for (n = 0; n < env->slb_nr; n++) { tmp64 = ldq_phys(sr_base); if (slb_is_valid(tmp64)) { slb_invalidate(&tmp64); stq_phys(sr_base, tmp64); /* XXX: given the fact that segment size is 256 MB or 1TB, * and we still don't have a tlb_flush_mask(env, n, mask) * in Qemu, we just invalidate all TLBs */ do_invalidate = 1; } sr_base += 12; } if (do_invalidate) tlb_flush(env, 1); }
true
qemu
2c1ee068b469ef5dcd8ea8f9220256a737e2b810
7,255
static int dirac_header(AVFormatContext *s, int idx) { struct ogg *ogg = s->priv_data; struct ogg_stream *os = ogg->streams + idx; AVStream *st = s->streams[idx]; dirac_source_params source; GetBitContext gb; // already parsed the header if (st->codec->codec_id == AV_CODEC_ID_DIRAC) return 0; init_get_bits(&gb, os->buf + os->pstart + 13, (os->psize - 13) * 8); if (avpriv_dirac_parse_sequence_header(st->codec, &gb, &source) < 0) return -1; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_DIRAC; // dirac in ogg always stores timestamps as though the video were interlaced avpriv_set_pts_info(st, 64, st->codec->framerate.den, 2*st->codec->framerate.num); return 1; }
true
FFmpeg
4f5c2e651a95b950f6a3fb36f2342cbc32515f17
7,257
static int targa_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data){ AVFrame *p = data; int bpp, picsize, datasize; uint8_t *out; if(avctx->width > 0xffff || avctx->height > 0xffff) { av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n"); return -1; } picsize = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); if(buf_size < picsize + 45) { av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } p->pict_type= FF_I_TYPE; p->key_frame= 1; /* zero out the header and only set applicable fields */ memset(outbuf, 0, 11); AV_WL16(outbuf+12, avctx->width); AV_WL16(outbuf+14, avctx->height); outbuf[17] = 0x20; /* origin is top-left. no alpha */ /* TODO: support alpha channel */ switch(avctx->pix_fmt) { case PIX_FMT_GRAY8: outbuf[2] = 3; /* uncompressed grayscale image */ outbuf[16] = 8; /* bpp */ break; case PIX_FMT_RGB555: outbuf[2] = 2; /* uncompresses true-color image */ outbuf[16] = 16; /* bpp */ break; case PIX_FMT_BGR24: outbuf[2] = 2; /* uncompressed true-color image */ outbuf[16] = 24; /* bpp */ break; default: return -1; } bpp = outbuf[16] >> 3; out = outbuf + 18; /* skip past the header we just output */ /* try RLE compression */ datasize = targa_encode_rle(out, picsize, p, bpp, avctx->width, avctx->height); /* if that worked well, mark the picture as RLE compressed */ if(datasize >= 0) outbuf[2] |= 8; /* if RLE didn't make it smaller, go back to no compression */ else datasize = targa_encode_normal(out, p, bpp, avctx->width, avctx->height); out += datasize; /* The standard recommends including this section, even if we don't use * any of the features it affords. TODO: take advantage of the pixel * aspect ratio and encoder ID fields available? */ memcpy(out, "\0\0\0\0\0\0\0\0TRUEVISION-XFILE.", 26); return out + 26 - outbuf; }
false
FFmpeg
d010a2d5befcde4782c4498134bb380e9fb24af6
7,258
static void sdp_parse_fmtp(AVStream *st, const char *p) { char attr[256]; /* Vorbis setup headers can be up to 12KB and are sent base64 * encoded, giving a 12KB * (4/3) = 16KB FMTP line. */ char value[16384]; int i; RTSPStream *rtsp_st = st->priv_data; AVCodecContext *codec = st->codec; RTPPayloadData *rtp_payload_data = &rtsp_st->rtp_payload_data; /* loop on each attribute */ while(rtsp_next_attr_and_value(&p, attr, sizeof(attr), value, sizeof(value))) { /* grab the codec extra_data from the config parameter of the fmtp line */ sdp_parse_fmtp_config(codec, rtsp_st->dynamic_protocol_context, attr, value); /* Looking for a known attribute */ for (i = 0; attr_names[i].str; ++i) { if (!strcasecmp(attr, attr_names[i].str)) { if (attr_names[i].type == ATTR_NAME_TYPE_INT) *(int *)((char *)rtp_payload_data + attr_names[i].offset) = atoi(value); else if (attr_names[i].type == ATTR_NAME_TYPE_STR) *(char **)((char *)rtp_payload_data + attr_names[i].offset) = av_strdup(value); } } } }
false
FFmpeg
c89658008705d949c319df3fa6f400c481ad73e1
7,259
static int h261_decode_gob(H261Context *h){ MpegEncContext * const s = &h->s; int v; ff_set_qscale(s, s->qscale); /* check for empty gob */ v= show_bits(&s->gb, 15); if(get_bits_count(&s->gb) + 15 > s->gb.size_in_bits){ v>>= get_bits_count(&s->gb) + 15 - s->gb.size_in_bits; } if(v==0){ h261_decode_mb_skipped(h, 0, 33); return 0; } /* decode mb's */ while(h->current_mba <= MAX_MBA) { int ret; /* DCT & quantize */ ret= h261_decode_mb(h, s->block); if(ret<0){ const int xy= s->mb_x + s->mb_y*s->mb_stride; if(ret==SLICE_END){ MPV_decode_mb(s, s->block); if(h->loop_filter){ ff_h261_loop_filter(h); } h->loop_filter = 0; h261_decode_mb_skipped(h, h->current_mba-h->mba_diff, h->current_mba-1); h261_decode_mb_skipped(h, h->current_mba, 33); return 0; }else if(ret==SLICE_NOEND){ av_log(s->avctx, AV_LOG_ERROR, "Slice mismatch at MB: %d\n", xy); return -1; } av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy); return -1; } MPV_decode_mb(s, s->block); if(h->loop_filter){ ff_h261_loop_filter(h); } h->loop_filter = 0; h261_decode_mb_skipped(h, h->current_mba-h->mba_diff, h->current_mba-1); } return -1; }
true
FFmpeg
49e5dcbce5f9e08ec375fd54c413148beb81f1d7
7,260
static int parse_playlist(URLContext *h, const char *url) { HLSContext *s = h->priv_data; AVIOContext *in; int ret = 0, is_segment = 0, is_variant = 0, bandwidth = 0; int64_t duration = 0; char line[1024]; const char *ptr; if ((ret = avio_open2(&in, url, AVIO_FLAG_READ, &h->interrupt_callback, NULL)) < 0) return ret; read_chomp_line(in, line, sizeof(line)); if (strcmp(line, "#EXTM3U")) return AVERROR_INVALIDDATA; free_segment_list(s); s->finished = 0; while (!in->eof_reached) { read_chomp_line(in, line, sizeof(line)); if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) { struct variant_info info = {{0}}; is_variant = 1; ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_variant_args, &info); bandwidth = atoi(info.bandwidth); } else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) { s->target_duration = atoi(ptr) * AV_TIME_BASE; } else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) { s->start_seq_no = atoi(ptr); } else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) { s->finished = 1; } else if (av_strstart(line, "#EXTINF:", &ptr)) { is_segment = 1; duration = atof(ptr) * AV_TIME_BASE; } else if (av_strstart(line, "#", NULL)) { continue; } else if (line[0]) { if (is_segment) { struct segment *seg = av_malloc(sizeof(struct segment)); if (!seg) { ret = AVERROR(ENOMEM); goto fail; } seg->duration = duration; ff_make_absolute_url(seg->url, sizeof(seg->url), url, line); dynarray_add(&s->segments, &s->n_segments, seg); is_segment = 0; } else if (is_variant) { struct variant *var = av_malloc(sizeof(struct variant)); if (!var) { ret = AVERROR(ENOMEM); goto fail; } var->bandwidth = bandwidth; ff_make_absolute_url(var->url, sizeof(var->url), url, line); dynarray_add(&s->variants, &s->n_variants, var); is_variant = 0; } } } s->last_load_time = av_gettime_relative(); fail: avio_close(in); return ret; }
true
FFmpeg
7915e6741dbe1cf3a8781cead3e68a7666de14f4
7,261
static int dc1394_read_header(AVFormatContext *c, AVFormatParameters * ap) { dc1394_data* dc1394 = c->priv_data; AVStream* vst; nodeid_t* camera_nodes; int res; struct dc1394_frame_format *fmt; struct dc1394_frame_rate *fps; for (fmt = dc1394_frame_formats; fmt->width; fmt++) if (fmt->pix_fmt == ap->pix_fmt && fmt->width == ap->width && fmt->height == ap->height) break; for (fps = dc1394_frame_rates; fps->frame_rate; fps++) if (fps->frame_rate == av_rescale(1000, ap->time_base.den, ap->time_base.num)) break; /* create a video stream */ vst = av_new_stream(c, 0); if (!vst) return -1; av_set_pts_info(vst, 64, 1, 1000); vst->codec->codec_type = CODEC_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_RAWVIDEO; vst->codec->time_base.den = fps->frame_rate; vst->codec->time_base.num = 1000; vst->codec->width = fmt->width; vst->codec->height = fmt->height; vst->codec->pix_fmt = fmt->pix_fmt; /* packet init */ av_init_packet(&dc1394->packet); dc1394->packet.size = avpicture_get_size(fmt->pix_fmt, fmt->width, fmt->height); dc1394->packet.stream_index = vst->index; dc1394->packet.flags |= PKT_FLAG_KEY; dc1394->current_frame = 0; dc1394->fps = fps->frame_rate; vst->codec->bit_rate = av_rescale(dc1394->packet.size * 8, fps->frame_rate, 1000); /* Now lets prep the hardware */ dc1394->handle = dc1394_create_handle(0); /* FIXME: gotta have ap->port */ if (!dc1394->handle) { av_log(c, AV_LOG_ERROR, "Can't acquire dc1394 handle on port %d\n", 0 /* ap->port */); goto out; } camera_nodes = dc1394_get_camera_nodes(dc1394->handle, &res, 1); if (!camera_nodes || camera_nodes[ap->channel] == DC1394_NO_CAMERA) { av_log(c, AV_LOG_ERROR, "There's no IIDC camera on the channel %d\n", ap->channel); goto out_handle; } res = dc1394_dma_setup_capture(dc1394->handle, camera_nodes[ap->channel], 0, FORMAT_VGA_NONCOMPRESSED, fmt->frame_size_id, SPEED_400, fps->frame_rate_id, 8, 1, c->filename, &dc1394->camera); dc1394_free_camera_nodes(camera_nodes); if (res != DC1394_SUCCESS) { av_log(c, AV_LOG_ERROR, "Can't prepare camera for the DMA capture\n"); goto out_handle; } res = dc1394_start_iso_transmission(dc1394->handle, dc1394->camera.node); if (res != DC1394_SUCCESS) { av_log(c, AV_LOG_ERROR, "Can't start isochronous transmission\n"); goto out_handle_dma; } return 0; out_handle_dma: dc1394_dma_unlisten(dc1394->handle, &dc1394->camera); dc1394_dma_release_camera(dc1394->handle, &dc1394->camera); out_handle: dc1394_destroy_handle(dc1394->handle); out: return -1; }
true
FFmpeg
43d1a1c05a51dfa340c95319be2608df98e6c3f4
7,262
static void bdrv_aio_bh_cb(void *opaque) { BlockDriverAIOCBSync *acb = opaque; if (!acb->is_write) qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size); qemu_vfree(acb->bounce); acb->common.cb(acb->common.opaque, acb->ret); qemu_bh_delete(acb->bh); acb->bh = NULL; qemu_aio_release(acb); }
true
qemu
857d4f46c31d2f4d57d2f0fad9dfb584262bf9b9
7,264
static int send_sub_rect_jpeg(VncState *vs, int x, int y, int w, int h, int bg, int fg, int colors, VncPalette *palette) { int ret; if (colors == 0) { if (tight_detect_smooth_image(vs, w, h)) { int quality = tight_conf[vs->tight.quality].jpeg_quality; ret = send_jpeg_rect(vs, x, y, w, h, quality); ret = send_full_color_rect(vs, x, y, w, h); } } else if (colors == 1) { ret = send_solid_rect(vs); } else if (colors == 2) { ret = send_mono_rect(vs, x, y, w, h, bg, fg); } else if (colors <= 256) { if (colors > 96 && tight_detect_smooth_image(vs, w, h)) { int quality = tight_conf[vs->tight.quality].jpeg_quality; ret = send_jpeg_rect(vs, x, y, w, h, quality); ret = send_palette_rect(vs, x, y, w, h, palette); } } return ret; }
true
qemu
ad7ee4ad6c3a5388acf94dd532d291ea6d3a5972
7,265
static uint64_t htonll(uint64_t v) { union { uint32_t lv[2]; uint64_t llv; } u; u.lv[0] = htonl(v >> 32); u.lv[1] = htonl(v & 0xFFFFFFFFULL); return u.llv; }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
7,266
void op_addo (void) { target_ulong tmp; tmp = T0; T0 += T1; if ((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31)) { CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW); } RETURN(); }
true
qemu
76e050c2e62995f1d6905e28674dea3a7fcff1a5
7,268
static av_cold int adpcm_decode_init(AVCodecContext * avctx) { ADPCMDecodeContext *c = avctx->priv_data; unsigned int max_channels = 2; switch(avctx->codec->id) { case CODEC_ID_ADPCM_EA_R1: case CODEC_ID_ADPCM_EA_R2: case CODEC_ID_ADPCM_EA_R3: case CODEC_ID_ADPCM_EA_XAS: max_channels = 6; break; } if(avctx->channels > max_channels){ return -1; } switch(avctx->codec->id) { case CODEC_ID_ADPCM_CT: c->status[0].step = c->status[1].step = 511; break; case CODEC_ID_ADPCM_IMA_WAV: if (avctx->bits_per_coded_sample != 4) { av_log(avctx, AV_LOG_ERROR, "Only 4-bit ADPCM IMA WAV files are supported\n"); return -1; } break; case CODEC_ID_ADPCM_IMA_WS: if (avctx->extradata && avctx->extradata_size == 2 * 4) { c->status[0].predictor = AV_RL32(avctx->extradata); c->status[1].predictor = AV_RL32(avctx->extradata + 4); } break; default: break; } avctx->sample_fmt = AV_SAMPLE_FMT_S16; avcodec_get_frame_defaults(&c->frame); avctx->coded_frame = &c->frame; return 0; }
true
FFmpeg
e614fac2e6e185a247d722d4e92368b3c3bc4bdb
7,270
static void test_qemu_strtol_max(void) { const char *str = g_strdup_printf("%ld", LONG_MAX); char f = 'X'; const char *endptr = &f; long res = 999; int err; err = qemu_strtol(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, LONG_MAX); g_assert(endptr == str + strlen(str)); }
true
qemu
d6f723b513a0c3c4e58343b7c52a2f9850861fa0
7,271
static int build_vlc(AVCodecContext *avctx, VLC *vlc, const uint32_t *table) { Node nodes[512]; uint32_t bits[256]; int16_t lens[256]; uint8_t xlat[256]; int cur_node, i, j, pos = 0; ff_free_vlc(vlc); for (i = 0; i < 256; i++) { nodes[i].count = table[i]; nodes[i].sym = i; nodes[i].n0 = -2; nodes[i].l = i; nodes[i].r = i; } cur_node = 256; j = 0; do { for (i = 0; ; i++) { int new_node = j; int first_node = cur_node; int second_node = cur_node; int nd, st; nodes[cur_node].count = -1; do { int val = nodes[new_node].count; if (val && (val < nodes[first_node].count)) { if (val >= nodes[second_node].count) { first_node = new_node; } else { first_node = second_node; second_node = new_node; } } new_node += 1; } while (new_node != cur_node); if (first_node == cur_node) break; nd = nodes[second_node].count; st = nodes[first_node].count; nodes[second_node].count = 0; nodes[first_node].count = 0; nodes[cur_node].count = nd + st; nodes[cur_node].sym = -1; nodes[cur_node].n0 = cur_node; nodes[cur_node].l = first_node; nodes[cur_node].r = second_node; cur_node++; } j++; } while (cur_node - 256 == j); get_tree_codes(bits, lens, xlat, nodes, cur_node - 1, 0, 0, &pos); return ff_init_vlc_sparse(vlc, 10, pos, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0); }
true
FFmpeg
67b30decf7793523f7fdaef6fdf7f1179ef42b18
7,272
static inline void dv_guess_qnos(EncBlockInfo* blks, int* qnos) { int size[5]; int i, j, k, a, prev, a2; EncBlockInfo* b; size[0] = size[1] = size[2] = size[3] = size[4] = 1<<24; do { b = blks; for (i=0; i<5; i++) { if (!qnos[i]) continue; qnos[i]--; size[i] = 0; for (j=0; j<6; j++, b++) { for (a=0; a<4; a++) { if (b->area_q[a] != dv_quant_shifts[qnos[i] + dv_quant_offset[b->cno]][a]) { b->bit_size[a] = 1; // 4 areas 4 bits for EOB :) b->area_q[a]++; prev= b->prev[a]; for (k= b->next[prev] ; k<mb_area_start[a+1]; k= b->next[k]) { b->mb[k] >>= 1; if (b->mb[k]) { b->bit_size[a] += dv_rl2vlc_size(k - prev - 1, b->mb[k]); prev= k; } else { if(b->next[k] >= mb_area_start[a+1] && b->next[k]<64){ for(a2=a+1; b->next[k] >= mb_area_start[a2+1]; a2++) b->prev[a2] = prev; assert(a2<4); assert(b->mb[b->next[k]]); b->bit_size[a2] += dv_rl2vlc_size(b->next[k] - prev - 1, b->mb[b->next[k]]) -dv_rl2vlc_size(b->next[k] - k - 1, b->mb[b->next[k]]); for(; (b->prev[a2]==k) && (a2<4); a2++) b->prev[a2] = prev; } b->next[prev] = b->next[k]; } } b->prev[a+1]= prev; } size[i] += b->bit_size[a]; } } if(vs_total_ac_bits >= size[0] + size[1] + size[2] + size[3] + size[4]) return; } } while (qnos[0]|qnos[1]|qnos[2]|qnos[3]|qnos[4]); for(a=2; a==2 || vs_total_ac_bits < size[0]; a+=a){ b = blks; size[0] = 5*6*4; //EOB for (j=0; j<6*5; j++, b++) { prev= b->prev[0]; for (k= b->next[prev]; k<64; k= b->next[k]) { if(b->mb[k] < a && b->mb[k] > -a){ b->next[prev] = b->next[k]; }else{ size[0] += dv_rl2vlc_size(k - prev - 1, b->mb[k]); prev= k; } } } } }
false
FFmpeg
d676478c8d29a48f67526afef44c323b74946488
7,273
static int vtenc_cm_to_avpacket( AVCodecContext *avctx, CMSampleBufferRef sample_buffer, AVPacket *pkt, ExtraSEI *sei) { VTEncContext *vtctx = avctx->priv_data; int status; bool is_key_frame; bool add_header; size_t length_code_size; size_t header_size = 0; size_t in_buf_size; size_t out_buf_size; size_t sei_nalu_size = 0; int64_t dts_delta; int64_t time_base_num; int nalu_count; CMTime pts; CMTime dts; CMVideoFormatDescriptionRef vid_fmt; vtenc_get_frame_info(sample_buffer, &is_key_frame); status = get_length_code_size(avctx, sample_buffer, &length_code_size); if (status) return status; add_header = is_key_frame && !(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER); if (add_header) { vid_fmt = CMSampleBufferGetFormatDescription(sample_buffer); if (!vid_fmt) { av_log(avctx, AV_LOG_ERROR, "Cannot get format description.\n"); return AVERROR_EXTERNAL; } int status = get_params_size(avctx, vid_fmt, &header_size); if (status) return status; } status = count_nalus(length_code_size, sample_buffer, &nalu_count); if(status) return status; if (sei) { sei_nalu_size = sizeof(start_code) + 3 + sei->size + 1; } in_buf_size = CMSampleBufferGetTotalSampleSize(sample_buffer); out_buf_size = header_size + in_buf_size + sei_nalu_size + nalu_count * ((int)sizeof(start_code) - (int)length_code_size); status = ff_alloc_packet2(avctx, pkt, out_buf_size, out_buf_size); if (status < 0) return status; if (add_header) { status = copy_param_sets(avctx, vid_fmt, pkt->data, out_buf_size); if(status) return status; } status = copy_replace_length_codes( avctx, length_code_size, sample_buffer, pkt->data + header_size, pkt->size - header_size - sei_nalu_size ); if (status) { av_log(avctx, AV_LOG_ERROR, "Error copying packet data: %d", status); return status; } if (sei_nalu_size > 0) { uint8_t *sei_nalu = pkt->data + pkt->size - sei_nalu_size; memcpy(sei_nalu, start_code, sizeof(start_code)); sei_nalu += sizeof(start_code); sei_nalu[0] = H264_NAL_SEI; sei_nalu[1] = SEI_TYPE_USER_DATA_REGISTERED; sei_nalu[2] = sei->size; sei_nalu += 3; memcpy(sei_nalu, sei->data, sei->size); sei_nalu += sei->size; sei_nalu[0] = 1; // RBSP } if (is_key_frame) { pkt->flags |= AV_PKT_FLAG_KEY; } pts = CMSampleBufferGetPresentationTimeStamp(sample_buffer); dts = CMSampleBufferGetDecodeTimeStamp (sample_buffer); if (CMTIME_IS_INVALID(dts)) { if (!vtctx->has_b_frames) { dts = pts; } else { av_log(avctx, AV_LOG_ERROR, "DTS is invalid.\n"); return AVERROR_EXTERNAL; } } dts_delta = vtctx->dts_delta >= 0 ? vtctx->dts_delta : 0; time_base_num = avctx->time_base.num; pkt->pts = pts.value / time_base_num; pkt->dts = dts.value / time_base_num - dts_delta; pkt->size = out_buf_size; return 0; }
false
FFmpeg
9875695e2ceec413f072ac2ef7e8fbc6a4980294
7,274
AVFormatContext *avformat_alloc_context(void) { AVFormatContext *ic; ic = av_malloc(sizeof(AVFormatContext)); if (!ic) return ic; avformat_get_context_defaults(ic); ic->av_class = &av_format_context_class; return ic; }
false
FFmpeg
9ac1bf88c00dbe7eb2191e2d5325fb104b9d8341
7,275
offset_t url_filesize(URLContext *h) { offset_t pos, size; size= url_seek(h, 0, AVSEEK_SIZE); if(size<0){ pos = url_seek(h, 0, SEEK_CUR); size = url_seek(h, -1, SEEK_END)+1; url_seek(h, pos, SEEK_SET); } return size; }
false
FFmpeg
eabbae730cf732afeb7c2a085e0e5c1e7b1b8614
7,276
static av_noinline void FUNC(hl_decode_mb)(const H264Context *h, H264SliceContext *sl) { const int mb_x = sl->mb_x; const int mb_y = sl->mb_y; const int mb_xy = sl->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; const int *block_offset = &h->block_offset[0]; const int transform_bypass = !SIMPLE && (sl->qscale == 0 && h->sps.transform_bypass); 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 * sl->linesize) * 16; dest_cb = h->cur_pic.f->data[1] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * sl->uvlinesize * block_h; dest_cr = h->cur_pic.f->data[2] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * sl->uvlinesize * block_h; h->vdsp.prefetch(dest_y + (sl->mb_x & 3) * 4 * sl->linesize + (64 << PIXEL_SHIFT), sl->linesize, 4); h->vdsp.prefetch(dest_cb + (sl->mb_x & 7) * sl->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2); h->list_counts[mb_xy] = sl->list_count; if (!SIMPLE && MB_FIELD(sl)) { linesize = sl->mb_linesize = sl->linesize * 2; uvlinesize = sl->mb_uvlinesize = sl->uvlinesize * 2; block_offset = &h->block_offset[48]; if (mb_y & 1) { // FIXME move out of this function? dest_y -= sl->linesize * 15; dest_cb -= sl->uvlinesize * (block_h - 1); dest_cr -= sl->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) ^ (sl->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) ^ (sl->mb_y & 1), 1); } } } } } else { linesize = sl->mb_linesize = sl->linesize; uvlinesize = sl->mb_uvlinesize = sl->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 & AV_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 & AV_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 (sl->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 & AV_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, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest_y, 0); if (sl->deblocking_filter) xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, 0, SIMPLE, PIXEL_SHIFT); } else { 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, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest_y, 0); if ((SIMPLE || !CONFIG_GRAY || !(h->flags & AV_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 { 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); } } } }
false
FFmpeg
3176217c60ca7828712985092d9102d331ea4f3d
7,277
static int rtp_read(URLContext *h, uint8_t *buf, int size) { RTPContext *s = h->priv_data; struct sockaddr_storage from; socklen_t from_len; int len, fd_max, n; fd_set rfds; struct timeval tv; #if 0 for(;;) { from_len = sizeof(from); len = recvfrom (s->rtp_fd, buf, size, 0, (struct sockaddr *)&from, &from_len); if (len < 0) { if (ff_neterrno() == FF_NETERROR(EAGAIN) || ff_neterrno() == FF_NETERROR(EINTR)) continue; return AVERROR(EIO); } break; } #else for(;;) { if (url_interrupt_cb()) return AVERROR(EINTR); /* build fdset to listen to RTP and RTCP packets */ FD_ZERO(&rfds); fd_max = s->rtp_fd; FD_SET(s->rtp_fd, &rfds); if (s->rtcp_fd > fd_max) fd_max = s->rtcp_fd; FD_SET(s->rtcp_fd, &rfds); tv.tv_sec = 0; tv.tv_usec = 100 * 1000; n = select(fd_max + 1, &rfds, NULL, NULL, &tv); if (n > 0) { /* first try RTCP */ if (FD_ISSET(s->rtcp_fd, &rfds)) { from_len = sizeof(from); len = recvfrom (s->rtcp_fd, buf, size, 0, (struct sockaddr *)&from, &from_len); if (len < 0) { if (ff_neterrno() == FF_NETERROR(EAGAIN) || ff_neterrno() == FF_NETERROR(EINTR)) continue; return AVERROR(EIO); } break; } /* then RTP */ if (FD_ISSET(s->rtp_fd, &rfds)) { from_len = sizeof(from); len = recvfrom (s->rtp_fd, buf, size, 0, (struct sockaddr *)&from, &from_len); if (len < 0) { if (ff_neterrno() == FF_NETERROR(EAGAIN) || ff_neterrno() == FF_NETERROR(EINTR)) continue; return AVERROR(EIO); } break; } } else if (n < 0) { if (ff_neterrno() == FF_NETERROR(EINTR)) continue; return AVERROR(EIO); } } #endif return len; }
false
FFmpeg
d0eb91ad0451cdb6c062b2d4760bfa7f8bb4db6b
7,278
static int load_apply_palette(FFFrameSync *fs) { AVFilterContext *ctx = fs->parent; AVFilterLink *inlink = ctx->inputs[0]; PaletteUseContext *s = ctx->priv; AVFrame *master, *second, *out; int ret; // writable for error diffusal dithering ret = ff_framesync_dualinput_get_writable(fs, &master, &second); if (ret < 0) return ret; if (!master || !second) { ret = AVERROR_BUG; goto error; } if (!s->palette_loaded) { load_palette(s, second); } out = apply_palette(inlink, master); return ff_filter_frame(ctx->outputs[0], out); error: av_frame_free(&master); av_frame_free(&second); return ret; }
false
FFmpeg
6470abc740367cc881c181db866891f8dd1d342f
7,279
static void test_parse_invalid_path(void) { g_test_trap_subprocess ("/logging/parse_invalid_path/subprocess", 0, 0); g_test_trap_assert_passed(); g_test_trap_assert_stdout(""); g_test_trap_assert_stderr("Bad logfile format: /tmp/qemu-%d%d.log\n"); }
true
qemu
daa76aa416b1e18ab1fac650ff53d966d8f21f68
7,280
void bdrv_iterate_format(void (*it)(void *opaque, const char *name), void *opaque) { BlockDriver *drv; int count = 0; const char **formats = NULL; QLIST_FOREACH(drv, &bdrv_drivers, list) { if (drv->format_name) { bool found = false; int i = count; while (formats && i && !found) { found = !strcmp(formats[--i], drv->format_name); } if (!found) { formats = g_realloc(formats, (count + 1) * sizeof(char *)); formats[count++] = drv->format_name; it(opaque, drv->format_name); } } } g_free(formats); }
true
qemu
5839e53bbc0fec56021d758aab7610df421ed8c8
7,281
static int ea_read_header(AVFormatContext *s, AVFormatParameters *ap) { EaDemuxContext *ea = s->priv_data; AVStream *st; if (!process_ea_header(s)) return AVERROR(EIO); if (ea->video_codec) { /* initialize the video decoder stream */ st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); ea->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = ea->video_codec; st->codec->codec_tag = 0; /* no fourcc */ st->codec->time_base = ea->time_base; st->codec->width = ea->width; st->codec->height = ea->height; if (ea->audio_codec) { if (ea->num_channels <= 0) { av_log(s, AV_LOG_WARNING, "Unsupported number of channels: %d\n", ea->num_channels); ea->audio_codec = 0; if (ea->sample_rate <= 0) { av_log(s, AV_LOG_ERROR, "Unsupported sample rate: %d\n", ea->sample_rate); ea->audio_codec = 0; /* initialize the audio decoder stream */ st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 33, 1, ea->sample_rate); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = ea->audio_codec; st->codec->codec_tag = 0; /* no tag */ st->codec->channels = ea->num_channels; st->codec->sample_rate = ea->sample_rate; st->codec->bits_per_coded_sample = ea->bytes * 8; st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * st->codec->bits_per_coded_sample / 4; st->codec->block_align = st->codec->channels*st->codec->bits_per_coded_sample; ea->audio_stream_index = st->index; ea->audio_frame_counter = 0;
true
FFmpeg
73b16198b6cab1cdafa46143aae7a69e10e130fd
7,282
static int ac3_encode_frame(AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data) { AC3EncodeContext *s = avctx->priv_data; const SampleType *samples = data; int ret; if (s->bit_alloc.sr_code == 1) adjust_frame_size(s); deinterleave_input_samples(s, samples); apply_mdct(s); compute_rematrixing_strategy(s); scale_coefficients(s); apply_rematrixing(s); process_exponents(s); ret = compute_bit_allocation(s); if (ret) { av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n"); return ret; } quantize_mantissas(s); output_frame(s, frame); return s->frame_size; }
true
FFmpeg
323e6fead07c75f418e4b60704a4f437bb3483b2
7,283
static void rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, int read_all) { RMContext *rm = s->priv_data; ByteIOContext *pb = &s->pb; char buf[256]; uint32_t version; int i; /* ra type header */ version = get_be32(pb); /* version */ if (((version >> 16) & 0xff) == 3) { int64_t startpos = url_ftell(pb); /* very old version */ for(i = 0; i < 14; i++) get_byte(pb); get_str8(pb, s->title, sizeof(s->title)); get_str8(pb, s->author, sizeof(s->author)); get_str8(pb, s->copyright, sizeof(s->copyright)); get_str8(pb, s->comment, sizeof(s->comment)); if ((startpos + (version & 0xffff)) >= url_ftell(pb) + 2) { // fourcc (should always be "lpcJ") get_byte(pb); get_str8(pb, buf, sizeof(buf)); } // Skip extra header crap (this should never happen) if ((startpos + (version & 0xffff)) > url_ftell(pb)) url_fskip(pb, (version & 0xffff) + startpos - url_ftell(pb)); st->codec->sample_rate = 8000; st->codec->channels = 1; st->codec->codec_type = CODEC_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_RA_144; } else { int flavor, sub_packet_h, coded_framesize, sub_packet_size; /* old version (4) */ get_be32(pb); /* .ra4 */ get_be32(pb); /* data size */ get_be16(pb); /* version2 */ get_be32(pb); /* header size */ flavor= get_be16(pb); /* add codec info / flavor */ rm->coded_framesize = coded_framesize = get_be32(pb); /* coded frame size */ get_be32(pb); /* ??? */ get_be32(pb); /* ??? */ get_be32(pb); /* ??? */ rm->sub_packet_h = sub_packet_h = get_be16(pb); /* 1 */ st->codec->block_align= get_be16(pb); /* frame size */ rm->sub_packet_size = sub_packet_size = get_be16(pb); /* sub packet size */ get_be16(pb); /* ??? */ if (((version >> 16) & 0xff) == 5) { get_be16(pb); get_be16(pb); get_be16(pb); } st->codec->sample_rate = get_be16(pb); get_be32(pb); st->codec->channels = get_be16(pb); if (((version >> 16) & 0xff) == 5) { get_be32(pb); buf[0] = get_byte(pb); buf[1] = get_byte(pb); buf[2] = get_byte(pb); buf[3] = get_byte(pb); buf[4] = 0; } else { get_str8(pb, buf, sizeof(buf)); /* desc */ get_str8(pb, buf, sizeof(buf)); /* desc */ } st->codec->codec_type = CODEC_TYPE_AUDIO; if (!strcmp(buf, "dnet")) { st->codec->codec_id = CODEC_ID_AC3; } else if (!strcmp(buf, "28_8")) { st->codec->codec_id = CODEC_ID_RA_288; st->codec->extradata_size= 0; rm->audio_framesize = st->codec->block_align; st->codec->block_align = coded_framesize; if(rm->audio_framesize >= UINT_MAX / sub_packet_h){ av_log(s, AV_LOG_ERROR, "rm->audio_framesize * sub_packet_h too large\n"); return -1; } rm->audiobuf = av_malloc(rm->audio_framesize * sub_packet_h); } else if (!strcmp(buf, "cook")) { int codecdata_length, i; get_be16(pb); get_byte(pb); if (((version >> 16) & 0xff) == 5) get_byte(pb); codecdata_length = get_be32(pb); if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){ av_log(s, AV_LOG_ERROR, "codecdata_length too large\n"); return -1; } st->codec->codec_id = CODEC_ID_COOK; st->codec->extradata_size= codecdata_length; st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); for(i = 0; i < codecdata_length; i++) ((uint8_t*)st->codec->extradata)[i] = get_byte(pb); rm->audio_framesize = st->codec->block_align; st->codec->block_align = rm->sub_packet_size; if(rm->audio_framesize >= UINT_MAX / sub_packet_h){ av_log(s, AV_LOG_ERROR, "rm->audio_framesize * sub_packet_h too large\n"); return -1; } rm->audiobuf = av_malloc(rm->audio_framesize * sub_packet_h); } else if (!strcmp(buf, "raac") || !strcmp(buf, "racp")) { int codecdata_length, i; get_be16(pb); get_byte(pb); if (((version >> 16) & 0xff) == 5) get_byte(pb); st->codec->codec_id = CODEC_ID_AAC; codecdata_length = get_be32(pb); if (codecdata_length >= 1) { st->codec->extradata_size = codecdata_length - 1; st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); get_byte(pb); for(i = 0; i < st->codec->extradata_size; i++) ((uint8_t*)st->codec->extradata)[i] = get_byte(pb); } } else { st->codec->codec_id = CODEC_ID_NONE; pstrcpy(st->codec->codec_name, sizeof(st->codec->codec_name), buf); } if (read_all) { get_byte(pb); get_byte(pb); get_byte(pb); get_str8(pb, s->title, sizeof(s->title)); get_str8(pb, s->author, sizeof(s->author)); get_str8(pb, s->copyright, sizeof(s->copyright)); get_str8(pb, s->comment, sizeof(s->comment)); } } }
true
FFmpeg
a9d4a6ef3437d316450c2e30b9ed6a8fd4df4804
7,284
static void term_init(void) { #if HAVE_TERMIOS_H if(!run_as_daemon){ struct termios tty; tcgetattr (0, &tty); oldtty = tty; atexit(term_exit); tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP |INLCR|IGNCR|ICRNL|IXON); tty.c_oflag |= OPOST; tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN); tty.c_cflag &= ~(CSIZE|PARENB); tty.c_cflag |= CS8; tty.c_cc[VMIN] = 1; tty.c_cc[VTIME] = 0; tcsetattr (0, TCSANOW, &tty); signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */ } #endif avformat_network_deinit(); signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */ signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */ #ifdef SIGXCPU signal(SIGXCPU, sigterm_handler); #endif }
true
FFmpeg
71a2c9b26567e2294b54eedafeb23aee08563de7
7,285
static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) { RTSPState *rt = s->priv_data; AVFormatContext *rtpctx = rtsp_st->transport_priv; uint8_t *buf, *ptr; int size; uint8_t *interleave_header, *interleaved_packet; size = avio_close_dyn_buf(rtpctx->pb, &buf); ptr = buf; while (size > 4) { uint32_t packet_len = AV_RB32(ptr); int id; /* The interleaving header is exactly 4 bytes, which happens to be * the same size as the packet length header from * ffio_open_dyn_packet_buf. So by writing the interleaving header * over these bytes, we get a consecutive interleaved packet * that can be written in one call. */ interleaved_packet = interleave_header = ptr; ptr += 4; size -= 4; if (packet_len > size || packet_len < 2) break; if (RTP_PT_IS_RTCP(ptr[1])) id = rtsp_st->interleaved_max; /* RTCP */ else id = rtsp_st->interleaved_min; /* RTP */ interleave_header[0] = '$'; interleave_header[1] = id; AV_WB16(interleave_header + 2, packet_len); ffurl_write(rt->rtsp_hd_out, interleaved_packet, 4 + packet_len); ptr += packet_len; size -= packet_len; } av_free(buf); ffio_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); return 0; }
true
FFmpeg
f542dedf72091af8e6f32a12bd64289c58857c21
7,286
static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) { VirtIOBlock *s = opaque; if (version_id != 2) return -EINVAL; virtio_load(&s->vdev, f); while (qemu_get_sbyte(f)) { VirtIOBlockReq *req = virtio_blk_alloc_request(s); qemu_get_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem)); req->next = s->rq; s->rq = req; virtqueue_map_sg(req->elem.in_sg, req->elem.in_addr, req->elem.in_num, 1); virtqueue_map_sg(req->elem.out_sg, req->elem.out_addr, req->elem.out_num, 0); } return 0; }
true
qemu
2a633c461e96cb9a856292c46917653bd43959c8
7,287
static TRBCCode xhci_disable_ep(XHCIState *xhci, unsigned int slotid, unsigned int epid) { XHCISlot *slot; XHCIEPContext *epctx; int i; trace_usb_xhci_ep_disable(slotid, epid); assert(slotid >= 1 && slotid <= xhci->numslots); assert(epid >= 1 && epid <= 31); slot = &xhci->slots[slotid-1]; if (!slot->eps[epid-1]) { DPRINTF("xhci: slot %d ep %d already disabled\n", slotid, epid); return CC_SUCCESS; } xhci_ep_nuke_xfers(xhci, slotid, epid, 0); epctx = slot->eps[epid-1]; if (epctx->nr_pstreams) { xhci_free_streams(epctx); } for (i = 0; i < ARRAY_SIZE(epctx->transfers); i++) { usb_packet_cleanup(&epctx->transfers[i].packet); } xhci_set_ep_state(xhci, epctx, NULL, EP_DISABLED); timer_free(epctx->kick_timer); g_free(epctx); slot->eps[epid-1] = NULL; return CC_SUCCESS; }
true
qemu
491d68d9382dbb588f2ff5132ee3d87ce2f1b230
7,289
static void parse_mb_skip(Wmv2Context *w) { int mb_x, mb_y; MpegEncContext *const s = &w->s; uint32_t *const mb_type = s->current_picture_ptr->mb_type; w->skip_type = get_bits(&s->gb, 2); switch (w->skip_type) { case SKIP_TYPE_NONE: for (mb_y = 0; mb_y < s->mb_height; mb_y++) for (mb_x = 0; mb_x < s->mb_width; mb_x++) mb_type[mb_y * s->mb_stride + mb_x] = MB_TYPE_16x16 | MB_TYPE_L0; break; case SKIP_TYPE_MPEG: for (mb_y = 0; mb_y < s->mb_height; mb_y++) for (mb_x = 0; mb_x < s->mb_width; mb_x++) mb_type[mb_y * s->mb_stride + mb_x] = (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0; break; case SKIP_TYPE_ROW: for (mb_y = 0; mb_y < s->mb_height; mb_y++) { if (get_bits1(&s->gb)) { for (mb_x = 0; mb_x < s->mb_width; mb_x++) mb_type[mb_y * s->mb_stride + mb_x] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; } else { for (mb_x = 0; mb_x < s->mb_width; mb_x++) mb_type[mb_y * s->mb_stride + mb_x] = (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0; } } break; case SKIP_TYPE_COL: for (mb_x = 0; mb_x < s->mb_width; mb_x++) { if (get_bits1(&s->gb)) { for (mb_y = 0; mb_y < s->mb_height; mb_y++) mb_type[mb_y * s->mb_stride + mb_x] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; } else { for (mb_y = 0; mb_y < s->mb_height; mb_y++) mb_type[mb_y * s->mb_stride + mb_x] = (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0; } } break; } }
true
FFmpeg
65e0a7c473f23f1833538ffecf53c81fe500b5e4
7,290
static void qemu_chr_free_common(CharDriverState *chr) { g_free(chr->filename); g_free(chr->label); if (chr->logfd != -1) { close(chr->logfd); qemu_mutex_destroy(&chr->chr_write_lock); g_free(chr);
true
qemu
94a40fc56036b5058b0b194d9e372a22e65ce7be
7,291
void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, int is_asi, int size) { CPUState *saved_env; int fault_type; /* XXX: hack to restore env in all cases, even if not called from generated code */ saved_env = env; env = cpu_single_env; #ifdef DEBUG_UNASSIGNED if (is_asi) printf("Unassigned mem %s access of %d byte%s to " TARGET_FMT_plx " asi 0x%02x from " TARGET_FMT_lx "\n", is_exec ? "exec" : is_write ? "write" : "read", size, size == 1 ? "" : "s", addr, is_asi, env->pc); else printf("Unassigned mem %s access of %d byte%s to " TARGET_FMT_plx " from " TARGET_FMT_lx "\n", is_exec ? "exec" : is_write ? "write" : "read", size, size == 1 ? "" : "s", addr, env->pc); #endif /* Don't overwrite translation and access faults */ fault_type = (env->mmuregs[3] & 0x1c) >> 2; if ((fault_type > 4) || (fault_type == 0)) { env->mmuregs[3] = 0; /* Fault status register */ if (is_asi) env->mmuregs[3] |= 1 << 16; if (env->psrs) env->mmuregs[3] |= 1 << 5; if (is_exec) env->mmuregs[3] |= 1 << 6; if (is_write) env->mmuregs[3] |= 1 << 7; env->mmuregs[3] |= (5 << 2) | 2; /* SuperSPARC will never place instruction fault addresses in the FAR */ if (!is_exec) { env->mmuregs[4] = addr; /* Fault address register */ } } /* overflow (same type fault was not read before another fault) */ if (fault_type == ((env->mmuregs[3] & 0x1c)) >> 2) { env->mmuregs[3] |= 1; } if ((env->mmuregs[0] & MMU_E) && !(env->mmuregs[0] & MMU_NF)) { if (is_exec) raise_exception(TT_CODE_ACCESS); else raise_exception(TT_DATA_ACCESS); } /* flush neverland mappings created during no-fault mode, so the sequential MMU faults report proper fault types */ if (env->mmuregs[0] & MMU_NF) { tlb_flush(env, 1); } env = saved_env; }
true
qemu
b14ef7c9ab41ea824c3ccadb070ad95567cca84e
7,292
int coroutine_fn bdrv_co_flush(BlockDriverState *bs) { int ret; BdrvTrackedRequest req; if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs) || bdrv_is_sg(bs)) { return 0; } tracked_request_begin(&req, bs, 0, 0, BDRV_TRACKED_FLUSH); int current_gen = bs->write_gen; /* Wait until any previous flushes are completed */ while (bs->flush_started_gen != bs->flushed_gen) { qemu_co_queue_wait(&bs->flush_queue); } bs->flush_started_gen = current_gen; /* Write back all layers by calling one driver function */ if (bs->drv->bdrv_co_flush) { ret = bs->drv->bdrv_co_flush(bs); goto out; } /* Write back cached data to the OS even with cache=unsafe */ BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_OS); if (bs->drv->bdrv_co_flush_to_os) { ret = bs->drv->bdrv_co_flush_to_os(bs); if (ret < 0) { goto out; } } /* But don't actually force it to the disk with cache=unsafe */ if (bs->open_flags & BDRV_O_NO_FLUSH) { goto flush_parent; } /* Check if we really need to flush anything */ if (bs->flushed_gen == current_gen) { goto flush_parent; } BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_DISK); if (bs->drv->bdrv_co_flush_to_disk) { ret = bs->drv->bdrv_co_flush_to_disk(bs); } else if (bs->drv->bdrv_aio_flush) { BlockAIOCB *acb; CoroutineIOCompletion co = { .coroutine = qemu_coroutine_self(), }; acb = bs->drv->bdrv_aio_flush(bs, bdrv_co_io_em_complete, &co); if (acb == NULL) { ret = -EIO; } else { qemu_coroutine_yield(); ret = co.ret; } } else { /* * Some block drivers always operate in either writethrough or unsafe * mode and don't support bdrv_flush therefore. Usually qemu doesn't * know how the server works (because the behaviour is hardcoded or * depends on server-side configuration), so we can't ensure that * everything is safe on disk. Returning an error doesn't work because * that would break guests even if the server operates in writethrough * mode. * * Let's hope the user knows what he's doing. */ ret = 0; } if (ret < 0) { goto out; } /* Now flush the underlying protocol. It will also have BDRV_O_NO_FLUSH * in the case of cache=unsafe, so there are no useless flushes. */ flush_parent: ret = bs->file ? bdrv_co_flush(bs->file->bs) : 0; out: /* Notify any pending flushes that we have completed */ bs->flushed_gen = current_gen; qemu_co_queue_restart_all(&bs->flush_queue); tracked_request_end(&req); return ret; }
true
qemu
3ff2f67a7c24183fcbcfe1332e5223ac6f96438c
7,293
static int modify_current_stream(HTTPContext *c, char *rates) { int i; FFStream *req = c->stream; int action_required = 0; for (i = 0; i < req->nb_streams; i++) { AVCodecContext *codec = &req->streams[i]->codec; switch(rates[i]) { case 0: c->switch_feed_streams[i] = req->feed_streams[i]; break; case 1: c->switch_feed_streams[i] = find_stream_in_feed(req->feed, codec, codec->bit_rate / 2); break; case 2: /* Wants off or slow */ c->switch_feed_streams[i] = find_stream_in_feed(req->feed, codec, codec->bit_rate / 4); #ifdef WANTS_OFF /* This doesn't work well when it turns off the only stream! */ c->switch_feed_streams[i] = -2; c->feed_streams[i] = -2; #endif break; } if (c->switch_feed_streams[i] >= 0 && c->switch_feed_streams[i] != c->feed_streams[i]) action_required = 1; } return action_required; }
true
FFmpeg
001bcd29556b32c1afd686c03f6bdd65dd0e9a36
7,294
static int cirrus_bitblt_cputovideo(CirrusVGAState * s) { int w; if (blit_is_unsafe(s, true)) { return 0; } s->cirrus_blt_mode &= ~CIRRUS_BLTMODE_MEMSYSSRC; s->cirrus_srcptr = &s->cirrus_bltbuf[0]; s->cirrus_srcptr_end = &s->cirrus_bltbuf[0]; if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) { if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) { s->cirrus_blt_srcpitch = 8; } else { /* XXX: check for 24 bpp */ s->cirrus_blt_srcpitch = 8 * 8 * s->cirrus_blt_pixelwidth; } s->cirrus_srccounter = s->cirrus_blt_srcpitch; } else { if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) { w = s->cirrus_blt_width / s->cirrus_blt_pixelwidth; if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_DWORDGRANULARITY) s->cirrus_blt_srcpitch = ((w + 31) >> 5); else s->cirrus_blt_srcpitch = ((w + 7) >> 3); } else { /* always align input size to 32 bits */ s->cirrus_blt_srcpitch = (s->cirrus_blt_width + 3) & ~3; } s->cirrus_srccounter = s->cirrus_blt_srcpitch * s->cirrus_blt_height; } s->cirrus_srcptr = s->cirrus_bltbuf; s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; cirrus_update_memory_access(s); return 1; }
true
qemu
92f2b88cea48c6aeba8de568a45f2ed958f3c298
7,296
static void vfio_amd_xgbe_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VFIOAmdXgbeDeviceClass *vcxc = VFIO_AMD_XGBE_DEVICE_CLASS(klass); vcxc->parent_realize = dc->realize; dc->realize = amd_xgbe_realize; dc->desc = "VFIO AMD XGBE"; dc->vmsd = &vfio_platform_amd_xgbe_vmstate; }
true
qemu
e4f4fb1eca795e36f363b4647724221e774523c1
7,297
static int hls_window(AVFormatContext *s, int last) { HLSContext *hls = s->priv_data; HLSSegment *en; int target_duration = 0; int ret = 0; AVIOContext *out = NULL; AVIOContext *sub_out = NULL; char temp_filename[1024]; int64_t sequence = FFMAX(hls->start_sequence, hls->sequence - hls->nb_entries); int version = 3; const char *proto = avio_find_protocol_name(s->filename); int use_rename = proto && !strcmp(proto, "file"); static unsigned warned_non_file; char *key_uri = NULL; char *iv_string = NULL; AVDictionary *options = NULL; double prog_date_time = hls->initial_prog_date_time; int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0); if (byterange_mode) { version = 4; sequence = 0; } if (hls->segment_type == SEGMENT_TYPE_FMP4) { version = 7; } if (!use_rename && !warned_non_file++) av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, this may lead to races and temporary partial files\n"); set_http_options(s, &options, hls); snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : "%s", s->filename); if ((ret = s->io_open(s, &out, temp_filename, AVIO_FLAG_WRITE, &options)) < 0) goto fail; for (en = hls->segments; en; en = en->next) { if (target_duration <= en->duration) target_duration = get_int_from_double(en->duration); } hls->discontinuity_set = 0; write_m3u8_head_block(hls, out, version, target_duration, sequence); if (hls->pl_type == PLAYLIST_TYPE_EVENT) { avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n"); } else if (hls->pl_type == PLAYLIST_TYPE_VOD) { avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n"); } if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && hls->discontinuity_set==0 ){ avio_printf(out, "#EXT-X-DISCONTINUITY\n"); hls->discontinuity_set = 1; } for (en = hls->segments; en; en = en->next) { if ((hls->encrypt || hls->key_info_file) && (!key_uri || strcmp(en->key_uri, key_uri) || av_strcasecmp(en->iv_string, iv_string))) { avio_printf(out, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", en->key_uri); if (*en->iv_string) avio_printf(out, ",IV=0x%s", en->iv_string); avio_printf(out, "\n"); key_uri = en->key_uri; iv_string = en->iv_string; } if (en->discont) { avio_printf(out, "#EXT-X-DISCONTINUITY\n"); } if ((hls->segment_type == SEGMENT_TYPE_FMP4) && (en == hls->segments)) { avio_printf(out, "#EXT-X-MAP:URI=\"%s\"", hls->fmp4_init_filename); if (hls->flags & HLS_SINGLE_FILE) { avio_printf(out, ",BYTERANGE=\"%"PRId64"@%"PRId64"\"", en->size, en->pos); } avio_printf(out, "\n"); } else { if (hls->flags & HLS_ROUND_DURATIONS) avio_printf(out, "#EXTINF:%ld,\n", lrint(en->duration)); else avio_printf(out, "#EXTINF:%f,\n", en->duration); if (byterange_mode) avio_printf(out, "#EXT-X-BYTERANGE:%"PRId64"@%"PRId64"\n", en->size, en->pos); } if (hls->flags & HLS_PROGRAM_DATE_TIME) { time_t tt, wrongsecs; int milli; struct tm *tm, tmpbuf; char buf0[128], buf1[128]; tt = (int64_t)prog_date_time; milli = av_clip(lrint(1000*(prog_date_time - tt)), 0, 999); tm = localtime_r(&tt, &tmpbuf); strftime(buf0, sizeof(buf0), "%Y-%m-%dT%H:%M:%S", tm); if (!strftime(buf1, sizeof(buf1), "%z", tm) || buf1[1]<'0' ||buf1[1]>'2') { int tz_min, dst = tm->tm_isdst; tm = gmtime_r(&tt, &tmpbuf); tm->tm_isdst = dst; wrongsecs = mktime(tm); tz_min = (abs(wrongsecs - tt) + 30) / 60; snprintf(buf1, sizeof(buf1), "%c%02d%02d", wrongsecs <= tt ? '+' : '-', tz_min / 60, tz_min % 60); } avio_printf(out, "#EXT-X-PROGRAM-DATE-TIME:%s.%03d%s\n", buf0, milli, buf1); prog_date_time += en->duration; } if (!((hls->segment_type == SEGMENT_TYPE_FMP4) && (en == hls->segments))) { if (hls->baseurl) avio_printf(out, "%s", hls->baseurl); avio_printf(out, "%s\n", en->filename); } } if (last && (hls->flags & HLS_OMIT_ENDLIST)==0) avio_printf(out, "#EXT-X-ENDLIST\n"); if( hls->vtt_m3u8_name ) { if ((ret = s->io_open(s, &sub_out, hls->vtt_m3u8_name, AVIO_FLAG_WRITE, &options)) < 0) goto fail; write_m3u8_head_block(hls, sub_out, version, target_duration, sequence); for (en = hls->segments; en; en = en->next) { avio_printf(sub_out, "#EXTINF:%f,\n", en->duration); if (byterange_mode) avio_printf(sub_out, "#EXT-X-BYTERANGE:%"PRIi64"@%"PRIi64"\n", en->size, en->pos); if (hls->baseurl) avio_printf(sub_out, "%s", hls->baseurl); avio_printf(sub_out, "%s\n", en->sub_filename); } if (last) avio_printf(sub_out, "#EXT-X-ENDLIST\n"); } fail: av_dict_free(&options); ff_format_io_close(s, &out); ff_format_io_close(s, &sub_out); if (ret >= 0 && use_rename) ff_rename(temp_filename, s->filename, s); return ret; }
true
FFmpeg
c3e279e75227946046ccb447d355b557118a616c
7,298
static inline void RENAME(nv12ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { RENAME(nvXXtoUV)(dstU, dstV, src1, width); }
true
FFmpeg
c3ab0004ae4dffc32494ae84dd15cfaa909a7884
7,299
void blk_eject(BlockBackend *blk, bool eject_flag) { BlockDriverState *bs = blk_bs(blk); char *id; /* blk_eject is only called by qdevified devices */ assert(!blk->legacy_dev); if (bs) { bdrv_eject(bs, eject_flag); id = blk_get_attached_dev_id(blk); qapi_event_send_device_tray_moved(blk_name(blk), id, eject_flag, &error_abort); g_free(id); } }
true
qemu
c47ee043dc2cc85da710e87524144a720598c096
7,300
static void megasas_scsi_realize(PCIDevice *dev, Error **errp) { DeviceState *d = DEVICE(dev); MegasasState *s = MEGASAS(dev); MegasasBaseClass *b = MEGASAS_DEVICE_GET_CLASS(s); uint8_t *pci_conf; int i, bar_type; Error *err = NULL; int ret; pci_conf = dev->config; /* PCI latency timer = 0 */ pci_conf[PCI_LATENCY_TIMER] = 0; /* Interrupt pin 1 */ pci_conf[PCI_INTERRUPT_PIN] = 0x01; if (s->msi != ON_OFF_AUTO_OFF) { ret = msi_init(dev, 0x50, 1, true, false, &err); /* Any error other than -ENOTSUP(board's MSI support is broken) * is a programming error */ assert(!ret || ret == -ENOTSUP); if (ret && s->msi == ON_OFF_AUTO_ON) { /* Can't satisfy user's explicit msi=on request, fail */ error_append_hint(&err, "You have to use msi=auto (default) or " "msi=off with this machine type.\n"); error_propagate(errp, err); return; } else if (ret) { /* With msi=auto, we fall back to MSI off silently */ s->msi = ON_OFF_AUTO_OFF; error_free(err); } } memory_region_init_io(&s->mmio_io, OBJECT(s), &megasas_mmio_ops, s, "megasas-mmio", 0x4000); memory_region_init_io(&s->port_io, OBJECT(s), &megasas_port_ops, s, "megasas-io", 256); memory_region_init_io(&s->queue_io, OBJECT(s), &megasas_queue_ops, s, "megasas-queue", 0x40000); if (megasas_use_msix(s) && msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000, &s->mmio_io, b->mmio_bar, 0x3800, 0x68)) { s->msix = ON_OFF_AUTO_OFF; } if (pci_is_express(dev)) { pcie_endpoint_cap_init(dev, 0xa0); } bar_type = PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64; pci_register_bar(dev, b->ioport_bar, PCI_BASE_ADDRESS_SPACE_IO, &s->port_io); pci_register_bar(dev, b->mmio_bar, bar_type, &s->mmio_io); pci_register_bar(dev, 3, bar_type, &s->queue_io); if (megasas_use_msix(s)) { msix_vector_use(dev, 0); } s->fw_state = MFI_FWSTATE_READY; if (!s->sas_addr) { s->sas_addr = ((NAA_LOCALLY_ASSIGNED_ID << 24) | IEEE_COMPANY_LOCALLY_ASSIGNED) << 36; s->sas_addr |= (pci_bus_num(dev->bus) << 16); s->sas_addr |= (PCI_SLOT(dev->devfn) << 8); s->sas_addr |= PCI_FUNC(dev->devfn); } if (!s->hba_serial) { s->hba_serial = g_strdup(MEGASAS_HBA_SERIAL); } if (s->fw_sge >= MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE) { s->fw_sge = MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE; } else if (s->fw_sge >= 128 - MFI_PASS_FRAME_SIZE) { s->fw_sge = 128 - MFI_PASS_FRAME_SIZE; } else { s->fw_sge = 64 - MFI_PASS_FRAME_SIZE; } if (s->fw_cmds > MEGASAS_MAX_FRAMES) { s->fw_cmds = MEGASAS_MAX_FRAMES; } trace_megasas_init(s->fw_sge, s->fw_cmds, megasas_is_jbod(s) ? "jbod" : "raid"); if (megasas_is_jbod(s)) { s->fw_luns = MFI_MAX_SYS_PDS; } else { s->fw_luns = MFI_MAX_LD; } s->producer_pa = 0; s->consumer_pa = 0; for (i = 0; i < s->fw_cmds; i++) { s->frames[i].index = i; s->frames[i].context = -1; s->frames[i].pa = 0; s->frames[i].state = s; } scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev), &megasas_scsi_info, NULL); if (!d->hotplugged) { scsi_bus_legacy_handle_cmdline(&s->bus, errp); } }
true
qemu
ee640c625e190a0c0e6b8966adc0e4720fb75200
7,301
int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info) { int handle = 0; int n; if (arch_info->exception == 1) { if (arch_info->dr6 & (1 << 14)) { if (cpu_single_env->singlestep_enabled) handle = 1; } else { for (n = 0; n < 4; n++) if (arch_info->dr6 & (1 << n)) switch ((arch_info->dr7 >> (16 + n*4)) & 0x3) { case 0x0: handle = 1; break; case 0x1: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_WRITE; break; case 0x3: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_ACCESS; break; } } } else if (kvm_find_sw_breakpoint(cpu_single_env, arch_info->pc)) handle = 1; if (!handle) kvm_update_guest_debug(cpu_single_env, (arch_info->exception == 1) ? KVM_GUESTDBG_INJECT_DB : KVM_GUESTDBG_INJECT_BP); return handle; }
true
qemu
b0b1d69079fcb9453f45aade9e9f6b71422147b0
7,302
static int mpegts_read_packet(AVFormatContext *s, AVPacket *pkt) { MpegTSContext *ts = s->priv_data; int ret, i; ts->pkt = pkt; ret = handle_packets(ts, 0); if (ret < 0) { /* flush pes data left */ for (i = 0; i < NB_PID_MAX; i++) { if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) { PESContext *pes = ts->pids[i]->u.pes_filter.opaque; if (pes->state == MPEGTS_PAYLOAD && pes->data_index > 0) { new_pes_packet(pes, pkt); pes->state = MPEGTS_SKIP; ret = 0; break; } } } } if (!ret && pkt->size < 0) ret = AVERROR(EINTR); return ret; }
true
FFmpeg
df8aa4598c7cc1c2f863f6fc6b2d4b3e6dc7345e
7,303
static int qemu_savevm_state(QEMUFile *f) { SaveStateEntry *se; int len, ret; int64_t cur_pos, len_pos, total_len_pos; qemu_put_be32(f, QEMU_VM_FILE_MAGIC); qemu_put_be32(f, QEMU_VM_FILE_VERSION); total_len_pos = qemu_ftell(f); qemu_put_be64(f, 0); /* total size */ for(se = first_se; se != NULL; se = se->next) { if (se->save_state == NULL) /* this one has a loader only, for backwards compatibility */ continue; /* ID string */ len = strlen(se->idstr); qemu_put_byte(f, len); qemu_put_buffer(f, (uint8_t *)se->idstr, len); qemu_put_be32(f, se->instance_id); qemu_put_be32(f, se->version_id); /* record size: filled later */ len_pos = qemu_ftell(f); qemu_put_be32(f, 0); se->save_state(f, se->opaque); /* fill record size */ cur_pos = qemu_ftell(f); len = cur_pos - len_pos - 4; qemu_fseek(f, len_pos, SEEK_SET); qemu_put_be32(f, len); qemu_fseek(f, cur_pos, SEEK_SET); } cur_pos = qemu_ftell(f); qemu_fseek(f, total_len_pos, SEEK_SET); qemu_put_be64(f, cur_pos - total_len_pos - 8); qemu_fseek(f, cur_pos, SEEK_SET); ret = 0; return ret; }
true
qemu
9366f4186025e1d8fc3bebd41fb714521c170b6f
7,304
static void cmv_decode_inter(CmvContext * s, const uint8_t *buf, const uint8_t *buf_end){ const uint8_t *raw = buf + (s->avctx->width*s->avctx->height/16); int x,y,i; i = 0; for(y=0; y<s->avctx->height/4; y++) for(x=0; x<s->avctx->width/4 && buf+i<buf_end; x++) { if (buf[i]==0xFF) { unsigned char *dst = s->frame.data[0] + (y*4)*s->frame.linesize[0] + x*4; if (raw+16<buf_end && *raw==0xFF) { /* intra */ raw++; memcpy(dst, raw, 4); memcpy(dst+s->frame.linesize[0], raw+4, 4); memcpy(dst+2*s->frame.linesize[0], raw+8, 4); memcpy(dst+3*s->frame.linesize[0], raw+12, 4); raw+=16; }else if(raw<buf_end) { /* inter using second-last frame as reference */ int xoffset = (*raw & 0xF) - 7; int yoffset = ((*raw >> 4)) - 7; if (s->last2_frame.data[0]) cmv_motcomp(s->frame.data[0], s->frame.linesize[0], s->last2_frame.data[0], s->last2_frame.linesize[0], x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height); raw++; } }else{ /* inter using last frame as reference */ int xoffset = (buf[i] & 0xF) - 7; int yoffset = ((buf[i] >> 4)) - 7; cmv_motcomp(s->frame.data[0], s->frame.linesize[0], s->last_frame.data[0], s->last_frame.linesize[0], x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height); } i++; } }
true
FFmpeg
e9064c9ce8ed18c3a3aab61e58e663b8f5b0c551
7,305
int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, int flags, BlockDriver *drv, Error **errp) { int ret; /* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */ char tmp_filename[PATH_MAX + 1]; BlockDriverState *file = NULL; QDict *file_options = NULL; const char *drvname; Error *local_err = NULL; /* NULL means an empty set of options */ if (options == NULL) { options = qdict_new(); } bs->options = options; options = qdict_clone_shallow(options); /* For snapshot=on, create a temporary qcow2 overlay */ if (flags & BDRV_O_SNAPSHOT) { BlockDriverState *bs1; int64_t total_size; BlockDriver *bdrv_qcow2; QEMUOptionParameter *create_options; char backing_filename[PATH_MAX]; if (qdict_size(options) != 0) { error_setg(errp, "Can't use snapshot=on with driver-specific options"); ret = -EINVAL; goto fail; } assert(filename != NULL); /* if snapshot, we create a temporary backing file and open it instead of opening 'filename' directly */ /* if there is a backing file, use it */ bs1 = bdrv_new(""); ret = bdrv_open(bs1, filename, NULL, 0, drv, &local_err); if (ret < 0) { bdrv_unref(bs1); goto fail; } total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK; bdrv_unref(bs1); ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename)); if (ret < 0) { error_setg_errno(errp, -ret, "Could not get temporary filename"); goto fail; } /* Real path is meaningless for protocols */ if (path_has_protocol(filename)) { snprintf(backing_filename, sizeof(backing_filename), "%s", filename); } else if (!realpath(filename, backing_filename)) { error_setg_errno(errp, errno, "Could not resolve path '%s'", filename); ret = -errno; goto fail; } bdrv_qcow2 = bdrv_find_format("qcow2"); create_options = parse_option_parameters("", bdrv_qcow2->create_options, NULL); set_option_parameter_int(create_options, BLOCK_OPT_SIZE, total_size); set_option_parameter(create_options, BLOCK_OPT_BACKING_FILE, backing_filename); if (drv) { set_option_parameter(create_options, BLOCK_OPT_BACKING_FMT, drv->format_name); } ret = bdrv_create(bdrv_qcow2, tmp_filename, create_options, &local_err); free_option_parameters(create_options); if (ret < 0) { error_setg_errno(errp, -ret, "Could not create temporary overlay " "'%s': %s", tmp_filename, error_get_pretty(local_err)); error_free(local_err); local_err = NULL; goto fail; } filename = tmp_filename; drv = bdrv_qcow2; bs->is_temporary = 1; } /* Open image file without format layer */ if (flags & BDRV_O_RDWR) { flags |= BDRV_O_ALLOW_RDWR; } qdict_extract_subqdict(options, &file_options, "file."); ret = bdrv_file_open(&file, filename, file_options, bdrv_open_flags(bs, flags | BDRV_O_UNMAP), &local_err); if (ret < 0) { goto fail; } /* Find the right image format driver */ drvname = qdict_get_try_str(options, "driver"); if (drvname) { drv = bdrv_find_whitelisted_format(drvname, !(flags & BDRV_O_RDWR)); qdict_del(options, "driver"); } if (!drv) { ret = find_image_format(file, filename, &drv, &local_err); } if (!drv) { goto unlink_and_fail; } /* Open the image */ ret = bdrv_open_common(bs, file, options, flags, drv, &local_err); if (ret < 0) { goto unlink_and_fail; } if (bs->file != file) { bdrv_unref(file); file = NULL; } /* If there is a backing file, use it */ if ((flags & BDRV_O_NO_BACKING) == 0) { QDict *backing_options; qdict_extract_subqdict(options, &backing_options, "backing."); ret = bdrv_open_backing_file(bs, backing_options, &local_err); if (ret < 0) { goto close_and_fail; } } /* Check if any unknown options were used */ if (qdict_size(options) != 0) { const QDictEntry *entry = qdict_first(options); error_setg(errp, "Block format '%s' used by device '%s' doesn't " "support the option '%s'", drv->format_name, bs->device_name, entry->key); ret = -EINVAL; goto close_and_fail; } QDECREF(options); if (!bdrv_key_required(bs)) { bdrv_dev_change_media_cb(bs, true); } return 0; unlink_and_fail: if (file != NULL) { bdrv_unref(file); } if (bs->is_temporary) { unlink(filename); } fail: QDECREF(bs->options); QDECREF(options); bs->options = NULL; if (error_is_set(&local_err)) { error_propagate(errp, local_err); } return ret; close_and_fail: bdrv_close(bs); QDECREF(options); if (error_is_set(&local_err)) { error_propagate(errp, local_err); } return ret; }
true
qemu
8f94a6e40e46cbc8e8014da825d25824b1803b34
7,306
static int qdm2_parse_packet(AVFormatContext *s, PayloadContext *qdm, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, int flags) { int res = AVERROR_INVALIDDATA, n; const uint8_t *end = buf + len, *p = buf; if (len > 0) { if (len < 2) return AVERROR_INVALIDDATA; /* configuration block */ if (*p == 0xff) { if (qdm->n_pkts > 0) { av_log(s, AV_LOG_WARNING, "Out of sequence config - dropping queue\n"); qdm->n_pkts = 0; memset(qdm->len, 0, sizeof(qdm->len)); } if ((res = qdm2_parse_config(qdm, st, ++p, end)) < 0) return res; p += res; /* We set codec_id to CODEC_ID_NONE initially to * delay decoder initialization since extradata is * carried within the RTP stream, not SDP. Here, * by setting codec_id to CODEC_ID_QDM2, we are signalling * to the decoder that it is OK to initialize. */ st->codec->codec_id = CODEC_ID_QDM2; } /* subpackets */ while (end - p >= 4) { if ((res = qdm2_parse_subpacket(qdm, st, p, end)) < 0) return res; p += res; } qdm->timestamp = *timestamp; if (++qdm->n_pkts < qdm->subpkts_per_block) qdm->cache = 0; for (n = 0; n < 0x80; n++) if (qdm->len[n] > 0) qdm->cache++; } /* output the subpackets into freshly created superblock structures */ if (!qdm->cache || (res = qdm2_restore_block(qdm, st, pkt)) < 0) return res; if (--qdm->cache == 0) qdm->n_pkts = 0; *timestamp = qdm->timestamp; qdm->timestamp = RTP_NOTS_VALUE; return (qdm->cache > 0) ? 1 : 0; }
true
FFmpeg
552a99957f7c6f6ed13795caee7ab7b9deb5d76e
7,307
av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact) { int mm_flags = av_get_cpu_flags(); if (EXTERNAL_MMX(mm_flags)) { c->ac3_exponent_min = ff_ac3_exponent_min_mmx; c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmx; c->ac3_lshift_int16 = ff_ac3_lshift_int16_mmx; c->ac3_rshift_int32 = ff_ac3_rshift_int32_mmx; } if (EXTERNAL_AMD3DNOW(mm_flags)) { c->extract_exponents = ff_ac3_extract_exponents_3dnow; if (!bit_exact) { c->float_to_fixed24 = ff_float_to_fixed24_3dnow; } } if (EXTERNAL_MMXEXT(mm_flags)) { c->ac3_exponent_min = ff_ac3_exponent_min_mmxext; c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmxext; } if (EXTERNAL_SSE(mm_flags)) { c->float_to_fixed24 = ff_float_to_fixed24_sse; } if (EXTERNAL_SSE2(mm_flags)) { c->ac3_exponent_min = ff_ac3_exponent_min_sse2; c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_sse2; c->float_to_fixed24 = ff_float_to_fixed24_sse2; c->compute_mantissa_size = ff_ac3_compute_mantissa_size_sse2; c->extract_exponents = ff_ac3_extract_exponents_sse2; if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) { c->ac3_lshift_int16 = ff_ac3_lshift_int16_sse2; c->ac3_rshift_int32 = ff_ac3_rshift_int32_sse2; } } if (EXTERNAL_SSSE3(mm_flags)) { c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_ssse3; if (!(mm_flags & AV_CPU_FLAG_ATOM)) { c->extract_exponents = ff_ac3_extract_exponents_ssse3; } } #if HAVE_SSE_INLINE && HAVE_7REGS if (INLINE_SSE(mm_flags)) { c->downmix = ac3_downmix_sse; } #endif }
true
FFmpeg
7c00e9d8aed8511c44281d7b05562578a3fcd4c8
7,310
void tcg_context_init(TCGContext *s) { int op, total_args, n; TCGOpDef *def; TCGArgConstraint *args_ct; int *sorted_args; memset(s, 0, sizeof(*s)); s->nb_globals = 0; /* Count total number of arguments and allocate the corresponding space */ total_args = 0; for(op = 0; op < NB_OPS; op++) { def = &tcg_op_defs[op]; n = def->nb_iargs + def->nb_oargs; total_args += n; } args_ct = g_malloc(sizeof(TCGArgConstraint) * total_args); sorted_args = g_malloc(sizeof(int) * total_args); for(op = 0; op < NB_OPS; op++) { def = &tcg_op_defs[op]; def->args_ct = args_ct; def->sorted_args = sorted_args; n = def->nb_iargs + def->nb_oargs; sorted_args += n; args_ct += n; } /* Register helpers. */ #define GEN_HELPER 2 #include "helper.h" tcg_target_init(s); }
false
qemu
100b5e0170e86661aaf830869be930a1a201ed08
7,311
void macio_nvram_setup_bar(MacIONVRAMState *s, MemoryRegion *bar, target_phys_addr_t mem_base) { memory_region_add_subregion(bar, mem_base, &s->mem); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
7,312
int qemu_input_key_value_to_scancode(const KeyValue *value, bool down, int *codes) { int keycode = qemu_input_key_value_to_number(value); int count = 0; if (value->type == KEY_VALUE_KIND_QCODE && value->u.qcode == Q_KEY_CODE_PAUSE) { /* specific case */ int v = down ? 0 : 0x80; codes[count++] = 0xe1; codes[count++] = 0x1d | v; codes[count++] = 0x45 | v; return count; } if (keycode & SCANCODE_GREY) { codes[count++] = SCANCODE_EMUL0; keycode &= ~SCANCODE_GREY; } if (!down) { keycode |= SCANCODE_UP; } codes[count++] = keycode; return count; }
false
qemu
32bafa8fdd098d52fbf1102d5a5e48d29398c0aa
7,313
static void coroutine_fn verify_self(void *opaque) { g_assert(qemu_coroutine_self() == opaque); }
false
qemu
7e70cdba9f220bef3f3481c663c066c2b80469aa
7,314
void net_set_boot_mask(int net_boot_mask) { int i; /* Only the first four NICs may be bootable */ net_boot_mask = net_boot_mask & 0xF; for (i = 0; i < nb_nics; i++) { if (net_boot_mask & (1 << i)) { net_boot_mask &= ~(1 << i); } } if (net_boot_mask) { fprintf(stderr, "Cannot boot from non-existent NIC\n"); exit(1); } }
false
qemu
da1fcfda59a6bcbdf58d49243fbced455f2bf78a
7,317
void msix_reset(PCIDevice *dev) { if (!(dev->cap_present & QEMU_PCI_CAP_MSIX)) return; msix_free_irq_entries(dev); dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &= ~dev->wmask[dev->msix_cap + MSIX_CONTROL_OFFSET]; memset(dev->msix_table_page, 0, MSIX_PAGE_SIZE); msix_mask_all(dev, dev->msix_entries_nr); }
false
qemu
44701ab71ad854e6be567a6294f4665f36651076
7,318
static void pl110_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) { pl110_state *s = (pl110_state *)opaque; int n; /* For simplicity invalidate the display whenever a control register is written to. */ s->invalidate = 1; if (offset >= 0x200 && offset < 0x400) { /* Palette. */ n = (offset - 0x200) >> 2; s->raw_palette[(offset - 0x200) >> 2] = val; pl110_update_palette(s, n); return; } switch (offset >> 2) { case 0: /* LCDTiming0 */ s->timing[0] = val; n = ((val & 0xfc) + 4) * 4; pl110_resize(s, n, s->rows); break; case 1: /* LCDTiming1 */ s->timing[1] = val; n = (val & 0x3ff) + 1; pl110_resize(s, s->cols, n); break; case 2: /* LCDTiming2 */ s->timing[2] = val; break; case 3: /* LCDTiming3 */ s->timing[3] = val; break; case 4: /* LCDUPBASE */ s->upbase = val; break; case 5: /* LCDLPBASE */ s->lpbase = val; break; case 6: /* LCDIMSC */ if (s->version != PL110) { goto control; } imsc: s->int_mask = val; pl110_update(s); break; case 7: /* LCDControl */ if (s->version != PL110) { goto imsc; } control: s->cr = val; s->bpp = (val >> 1) & 7; if (pl110_enabled(s)) { qemu_console_resize(s->ds, s->cols, s->rows); } break; case 10: /* LCDICR */ s->int_status &= ~val; pl110_update(s); break; default: hw_error("pl110_write: Bad offset %x\n", (int)offset); } }
false
qemu
375cb560295484b88898262ebf400eff9a011206
7,319
static int process_input(void) { InputFile *ifile; AVFormatContext *is; InputStream *ist; AVPacket pkt; int ret, i, j; int file_index; /* select the stream that we must read now */ file_index = select_input_file(); /* if none, if is finished */ if (file_index == -2) { poll_filters() ; return AVERROR(EAGAIN); } if (file_index < 0) { if (got_eagain()) { reset_eagain(); av_usleep(10000); return AVERROR(EAGAIN); } av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from, finishing.\n"); return AVERROR_EOF; } ifile = input_files[file_index]; is = ifile->ctx; ret = get_input_packet(ifile, &pkt); if (ret == AVERROR(EAGAIN)) { ifile->eagain = 1; return ret; } if (ret < 0) { if (ret != AVERROR_EOF) { print_error(is->filename, ret); if (exit_on_error) exit_program(1); } ifile->eof_reached = 1; for (i = 0; i < ifile->nb_streams; i++) { ist = input_streams[ifile->ist_index + i]; if (ist->decoding_needed) output_packet(ist, NULL); poll_filters(); } if (opt_shortest) return AVERROR_EOF; else return AVERROR(EAGAIN); } reset_eagain(); if (do_pkt_dump) { av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump, is->streams[pkt.stream_index]); } /* the following test is needed in case new streams appear dynamically in stream : we ignore them */ if (pkt.stream_index >= ifile->nb_streams) { report_new_stream(file_index, &pkt); goto discard_packet; } ist = input_streams[ifile->ist_index + pkt.stream_index]; if (ist->discard) goto discard_packet; if(!ist->wrap_correction_done && input_files[file_index]->ctx->start_time != AV_NOPTS_VALUE && ist->st->pts_wrap_bits < 64){ uint64_t stime = av_rescale_q(input_files[file_index]->ctx->start_time, AV_TIME_BASE_Q, ist->st->time_base); uint64_t stime2= stime + (1LL<<ist->st->pts_wrap_bits); ist->wrap_correction_done = 1; if(pkt.dts != AV_NOPTS_VALUE && pkt.dts > stime && pkt.dts - stime > stime2 - pkt.dts) { pkt.dts -= 1LL<<ist->st->pts_wrap_bits; ist->wrap_correction_done = 0; } if(pkt.pts != AV_NOPTS_VALUE && pkt.pts > stime && pkt.pts - stime > stime2 - pkt.pts) { pkt.pts -= 1LL<<ist->st->pts_wrap_bits; ist->wrap_correction_done = 0; } } if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts *= ist->ts_scale; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts *= ist->ts_scale; if (debug_ts) { av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s " "next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%"PRId64"\n", ifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->st->codec->codec_type), av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &AV_TIME_BASE_Q), av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &AV_TIME_BASE_Q), av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base), input_files[ist->file_index]->ts_offset); } if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && !copy_ts) { int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta = pkt_dts - ist->next_dts; if (is->iformat->flags & AVFMT_TS_DISCONT) { if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE || (delta > 1LL*dts_delta_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_dts+1<ist->pts){ ifile->ts_offset -= delta; av_log(NULL, AV_LOG_DEBUG, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, ifile->ts_offset); pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); } } else { if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_dts+1<ist->pts){ av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index); pkt.dts = AV_NOPTS_VALUE; } if (pkt.pts != AV_NOPTS_VALUE){ int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q); delta = pkt_pts - ist->next_dts; if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_pts+1<ist->pts) { av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index); pkt.pts = AV_NOPTS_VALUE; } } } } sub2video_heartbeat(ist, pkt.pts); if ((ret = output_packet(ist, &pkt)) < 0 || ((ret = poll_filters()) < 0 && ret != AVERROR_EOF)) { char buf[128]; av_strerror(ret, buf, sizeof(buf)); av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", ist->file_index, ist->st->index, buf); if (exit_on_error) exit_program(1); av_free_packet(&pkt); return AVERROR(EAGAIN); } discard_packet: av_free_packet(&pkt); return 0; }
false
FFmpeg
c5ea3a009b15a3334ca469885303182e9f218836
7,320
static inline void gen_intermediate_code_internal(AlphaCPU *cpu, TranslationBlock *tb, bool search_pc) { CPUState *cs = CPU(cpu); CPUAlphaState *env = &cpu->env; DisasContext ctx, *ctxp = &ctx; target_ulong pc_start; target_ulong pc_mask; uint32_t insn; uint16_t *gen_opc_end; CPUBreakpoint *bp; int j, lj = -1; ExitStatus ret; int num_insns; int max_insns; pc_start = tb->pc; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; ctx.tb = tb; ctx.pc = pc_start; ctx.mem_idx = cpu_mmu_index(env); ctx.implver = env->implver; ctx.singlestep_enabled = cs->singlestep_enabled; /* ??? Every TB begins with unset rounding mode, to be initialized on the first fp insn of the TB. Alternately we could define a proper default for every TB (e.g. QUAL_RM_N or QUAL_RM_D) and make sure to reset the FP_STATUS to that default at the end of any TB that changes the default. We could even (gasp) dynamiclly figure out what default would be most efficient given the running program. */ ctx.tb_rm = -1; /* Similarly for flush-to-zero. */ ctx.tb_ftz = -1; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } if (in_superpage(&ctx, pc_start)) { pc_mask = (1ULL << 41) - 1; } else { pc_mask = ~TARGET_PAGE_MASK; } gen_tb_start(); do { if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { if (bp->pc == ctx.pc) { gen_excp(&ctx, EXCP_DEBUG, 0); break; } } } if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) tcg_ctx.gen_opc_instr_start[lj++] = 0; } tcg_ctx.gen_opc_pc[lj] = ctx.pc; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = num_insns; } if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } insn = cpu_ldl_code(env, ctx.pc); num_insns++; if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) { tcg_gen_debug_insn_start(ctx.pc); } TCGV_UNUSED_I64(ctx.zero); TCGV_UNUSED_I64(ctx.sink); TCGV_UNUSED_I64(ctx.lit); ctx.pc += 4; ret = translate_one(ctxp, insn); if (!TCGV_IS_UNUSED_I64(ctx.sink)) { tcg_gen_discard_i64(ctx.sink); tcg_temp_free(ctx.sink); } if (!TCGV_IS_UNUSED_I64(ctx.zero)) { tcg_temp_free(ctx.zero); } if (!TCGV_IS_UNUSED_I64(ctx.lit)) { tcg_temp_free(ctx.lit); } /* If we reach a page boundary, are single stepping, or exhaust instruction count, stop generation. */ if (ret == NO_EXIT && ((ctx.pc & pc_mask) == 0 || tcg_ctx.gen_opc_ptr >= gen_opc_end || num_insns >= max_insns || singlestep || ctx.singlestep_enabled)) { ret = EXIT_PC_STALE; } } while (ret == NO_EXIT); if (tb->cflags & CF_LAST_IO) { gen_io_end(); } switch (ret) { case EXIT_GOTO_TB: case EXIT_NORETURN: break; case EXIT_PC_STALE: tcg_gen_movi_i64(cpu_pc, ctx.pc); /* FALLTHRU */ case EXIT_PC_UPDATED: if (ctx.singlestep_enabled) { gen_excp_1(EXCP_DEBUG, 0); } else { tcg_gen_exit_tb(0); } break; default: abort(); } gen_tb_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; lj++; while (lj <= j) tcg_ctx.gen_opc_instr_start[lj++] = 0; } else { tb->size = ctx.pc - pc_start; tb->icount = num_insns; } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(env, pc_start, ctx.pc - pc_start, 1); qemu_log("\n"); } #endif }
false
qemu
cd42d5b23691ad73edfd6dbcfc935a960a9c5a65
7,321
uint64_t helper_fctiwz(CPUPPCState *env, uint64_t arg) { CPU_DoubleU farg; farg.ll = arg; if (unlikely(float64_is_signaling_nan(farg.d))) { /* sNaN conversion */ farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); } else if (unlikely(float64_is_quiet_nan(farg.d) || float64_is_infinity(farg.d))) { /* qNan / infinity conversion */ farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXCVI); } else { farg.ll = float64_to_int32_round_to_zero(farg.d, &env->fp_status); /* XXX: higher bits are not supposed to be significant. * to make tests easier, return the same as a real PowerPC 750 */ farg.ll |= 0xFFF80000ULL << 32; } return farg.ll; }
false
qemu
59800ec8e52bcfa271fa61fb0aae19205ef1b7f1
7,323
POWERPC_FAMILY(POWER8E)(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); dc->fw_name = "PowerPC,POWER8"; dc->desc = "POWER8E"; dc->props = powerpc_servercpu_properties; pcc->pvr_match = ppc_pvr_match_power8; pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06; pcc->init_proc = init_proc_POWER8; pcc->check_pow = check_pow_nocheck; pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | PPC_FLOAT_FRSQRTES | PPC_FLOAT_STFIWX | PPC_FLOAT_EXT | PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | PPC_MEM_SYNC | PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_64B | PPC_64BX | PPC_ALTIVEC | PPC_SEGMENT_64B | PPC_SLBI | PPC_POPCNTB | PPC_POPCNTWD; pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | PPC2_ISA205 | PPC2_ISA207S; pcc->msr_mask = (1ull << MSR_SF) | (1ull << MSR_TM) | (1ull << MSR_VR) | (1ull << MSR_VSX) | (1ull << MSR_EE) | (1ull << MSR_PR) | (1ull << MSR_FP) | (1ull << MSR_ME) | (1ull << MSR_FE0) | (1ull << MSR_SE) | (1ull << MSR_DE) | (1ull << MSR_FE1) | (1ull << MSR_IR) | (1ull << MSR_DR) | (1ull << MSR_PMM) | (1ull << MSR_RI) | (1ull << MSR_LE); pcc->mmu_model = POWERPC_MMU_2_06; #if defined(CONFIG_SOFTMMU) pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault; #endif pcc->excp_model = POWERPC_EXCP_POWER7; pcc->bus_model = PPC_FLAGS_INPUT_POWER7; pcc->bfd_mach = bfd_mach_ppc64; pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | POWERPC_FLAG_BE | POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | POWERPC_FLAG_VSX; pcc->l1_dcache_size = 0x8000; pcc->l1_icache_size = 0x8000; pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }
false
qemu
b60c60070c0df4ef01d5c727929fe0e93e6fdd09
7,328
static void patch_instruction(VAPICROMState *s, CPUX86State *env, target_ulong ip) { target_phys_addr_t paddr; VAPICHandlers *handlers; uint8_t opcode[2]; uint32_t imm32; if (smp_cpus == 1) { handlers = &s->rom_state.up; } else { handlers = &s->rom_state.mp; } pause_all_vcpus(); cpu_memory_rw_debug(env, ip, opcode, sizeof(opcode), 0); switch (opcode[0]) { case 0x89: /* mov r32 to r/m32 */ patch_byte(env, ip, 0x50 + modrm_reg(opcode[1])); /* push reg */ patch_call(s, env, ip + 1, handlers->set_tpr); break; case 0x8b: /* mov r/m32 to r32 */ patch_byte(env, ip, 0x90); patch_call(s, env, ip + 1, handlers->get_tpr[modrm_reg(opcode[1])]); break; case 0xa1: /* mov abs to eax */ patch_call(s, env, ip, handlers->get_tpr[0]); break; case 0xa3: /* mov eax to abs */ patch_call(s, env, ip, handlers->set_tpr_eax); break; case 0xc7: /* mov imm32, r/m32 (c7/0) */ patch_byte(env, ip, 0x68); /* push imm32 */ cpu_memory_rw_debug(env, ip + 6, (void *)&imm32, sizeof(imm32), 0); cpu_memory_rw_debug(env, ip + 1, (void *)&imm32, sizeof(imm32), 1); patch_call(s, env, ip + 5, handlers->set_tpr); break; case 0xff: /* push r/m32 */ patch_byte(env, ip, 0x50); /* push eax */ patch_call(s, env, ip + 1, handlers->get_tpr_stack); break; default: abort(); } resume_all_vcpus(); paddr = cpu_get_phys_page_debug(env, ip); paddr += ip & ~TARGET_PAGE_MASK; tb_invalidate_phys_page_range(paddr, paddr + 1, 1); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
7,329
void tlb_fill(unsigned long addr, int is_write, int is_user, void *retaddr) { TranslationBlock *tb; CPUState *saved_env; unsigned long pc; int ret; /* XXX: hack to restore env in all cases, even if not called from generated code */ saved_env = env; env = cpu_single_env; { unsigned long tlb_addrr, tlb_addrw; int index; index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); tlb_addrr = env->tlb_read[is_user][index].address; tlb_addrw = env->tlb_write[is_user][index].address; #if 0 if (loglevel) { fprintf(logfile, "%s 1 %p %p idx=%d addr=0x%08lx tbl_addr=0x%08lx 0x%08lx " "(0x%08lx 0x%08lx)\n", __func__, env, &env->tlb_read[is_user][index], index, addr, tlb_addrr, tlb_addrw, addr & TARGET_PAGE_MASK, tlb_addrr & (TARGET_PAGE_MASK | TLB_INVALID_MASK)); } #endif } ret = cpu_ppc_handle_mmu_fault(env, addr, is_write, is_user, 1); if (ret) { if (retaddr) { /* now we have a real cpu fault */ pc = (unsigned long)retaddr; tb = tb_find_pc(pc); if (tb) { /* the PC is inside the translated code. It means that we have a virtual CPU fault */ cpu_restore_state(tb, env, pc, NULL); } } do_raise_exception_err(env->exception_index, env->error_code); } { unsigned long tlb_addrr, tlb_addrw; int index; index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); tlb_addrr = env->tlb_read[is_user][index].address; tlb_addrw = env->tlb_write[is_user][index].address; #if 0 printf("%s 2 %p %p idx=%d addr=0x%08lx tbl_addr=0x%08lx 0x%08lx " "(0x%08lx 0x%08lx)\n", __func__, env, &env->tlb_read[is_user][index], index, addr, tlb_addrr, tlb_addrw, addr & TARGET_PAGE_MASK, tlb_addrr & (TARGET_PAGE_MASK | TLB_INVALID_MASK)); #endif } env = saved_env; }
false
qemu
b769d8fef6c06ddb39ef0337882a4f8872b9c2bc
7,330
static inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx ) { int nza, nzb; int ctx = 0; if( cat == 0 ) { nza = h->left_cbp&0x100; nzb = h-> top_cbp&0x100; } else if( cat == 1 || cat == 2 ) { nza = h->non_zero_count_cache[scan8[idx] - 1]; nzb = h->non_zero_count_cache[scan8[idx] - 8]; } else if( cat == 3 ) { nza = (h->left_cbp>>(6+idx))&0x01; nzb = (h-> top_cbp>>(6+idx))&0x01; } else { assert(cat == 4); nza = h->non_zero_count_cache[scan8[16+idx] - 1]; nzb = h->non_zero_count_cache[scan8[16+idx] - 8]; } if( nza > 0 ) ctx++; if( nzb > 0 ) ctx += 2; return ctx + 4 * cat; }
false
FFmpeg
9588ec340c3f33c7474b4cd2893046cfdaee42bf
7,333
static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features, uint32_t *ext_features, uint32_t *ext2_features, uint32_t *ext3_features, uint32_t *kvm_features) { int i; int found = 0; for ( i = 0 ; i < 32 ; i++ ) if (feature_name[i] && !strcmp (flagname, feature_name[i])) { *features |= 1 << i; found = 1; } for ( i = 0 ; i < 32 ; i++ ) if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) { *ext_features |= 1 << i; found = 1; } for ( i = 0 ; i < 32 ; i++ ) if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) { *ext2_features |= 1 << i; found = 1; } for ( i = 0 ; i < 32 ; i++ ) if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) { *ext3_features |= 1 << i; found = 1; } for ( i = 0 ; i < 32 ; i++ ) if (kvm_feature_name[i] && !strcmp (flagname, kvm_feature_name[i])) { *kvm_features |= 1 << i; found = 1; } if (!found) { fprintf(stderr, "CPU feature %s not found\n", flagname); } }
false
qemu
b5ec5ce0e39d6e7ea707d5604a5f6d567dfd2f48