id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
4,045
static void an5206_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; M68kCPU *cpu; CPUM68KState *env; int kernel_size; uint64_t elf_entry; hwaddr entry; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *sram = g_new(MemoryRegion, 1); if (!cpu_model) { cpu_model = "m5206"; } cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model)); if (!cpu) { error_report("Unable to find m68k CPU definition"); exit(1); } env = &cpu->env; /* Initialize CPU registers. */ env->vbr = 0; /* TODO: allow changing MBAR and RAMBAR. */ env->mbar = AN5206_MBAR_ADDR | 1; env->rambar0 = AN5206_RAMBAR_ADDR | 1; /* DRAM at address zero */ memory_region_allocate_system_memory(ram, NULL, "an5206.ram", ram_size); memory_region_add_subregion(address_space_mem, 0, ram); /* Internal SRAM. */ memory_region_init_ram(sram, NULL, "an5206.sram", 512, &error_fatal); memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram); mcf5206_init(address_space_mem, AN5206_MBAR_ADDR, cpu); /* Load kernel. */ if (!kernel_filename) { if (qtest_enabled()) { return; } fprintf(stderr, "Kernel image must be specified\n"); exit(1); } kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry, NULL, NULL, 1, EM_68K, 0, 0); entry = elf_entry; if (kernel_size < 0) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL, NULL, NULL); } if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, ram_size - KERNEL_LOAD_ADDR); entry = KERNEL_LOAD_ADDR; } if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } env->pc = entry; }
true
qemu
4482e05cbbb7e50e476f6a9500cf0b38913bd939
4,046
static int mv_read_header(AVFormatContext *avctx) { MvContext *mv = avctx->priv_data; AVIOContext *pb = avctx->pb; AVStream *ast = NULL, *vst = NULL; //initialization to suppress warning int version, i; avio_skip(pb, 4); version = avio_rb16(pb); if (version == 2) { uint64_t timestamp; int v; avio_skip(pb, 22); /* allocate audio track first to prevent unnecessary seeking (audio packet always precede video packet for a given frame) */ ast = avformat_new_stream(avctx, NULL); if (!ast) return AVERROR(ENOMEM); vst = avformat_new_stream(avctx, NULL); if (!vst) return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->time_base = (AVRational){1, 15}; vst->nb_frames = avio_rb32(pb); v = avio_rb32(pb); switch (v) { case 1: vst->codec->codec_id = AV_CODEC_ID_MVC1; break; case 2: vst->codec->pix_fmt = AV_PIX_FMT_ARGB; vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO; break; default: av_log_ask_for_sample(avctx, "unknown video compression %i\n", v); break; } vst->codec->codec_tag = 0; vst->codec->width = avio_rb32(pb); vst->codec->height = avio_rb32(pb); avio_skip(pb, 12); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->nb_frames = vst->nb_frames; ast->codec->sample_rate = avio_rb32(pb); avpriv_set_pts_info(ast, 33, 1, ast->codec->sample_rate); ast->codec->channels = avio_rb32(pb); ast->codec->channel_layout = (ast->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; v = avio_rb32(pb); if (v == AUDIO_FORMAT_SIGNED) { ast->codec->codec_id = AV_CODEC_ID_PCM_S16BE; } else { av_log_ask_for_sample(avctx, "unknown audio compression (format %i)\n", v); } avio_skip(pb, 12); var_read_metadata(avctx, "title", 0x80); var_read_metadata(avctx, "comment", 0x100); avio_skip(pb, 0x80); timestamp = 0; for (i = 0; i < vst->nb_frames; i++) { uint32_t pos = avio_rb32(pb); uint32_t asize = avio_rb32(pb); uint32_t vsize = avio_rb32(pb); avio_skip(pb, 8); av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME); av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME); timestamp += asize / (ast->codec->channels * 2); } } else if (!version && avio_rb16(pb) == 3) { avio_skip(pb, 4); read_table(avctx, NULL, parse_global_var); if (mv->nb_audio_tracks > 1) { av_log_ask_for_sample(avctx, "multiple audio streams\n"); return AVERROR_PATCHWELCOME; } else if (mv->nb_audio_tracks) { ast = avformat_new_stream(avctx, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; /* temporarily store compression value in codec_tag; format value in codec_id */ read_table(avctx, ast, parse_audio_var); if (ast->codec->codec_tag == 100 && ast->codec->codec_id == AUDIO_FORMAT_SIGNED && ast->codec->bits_per_coded_sample == 16) { ast->codec->codec_id = AV_CODEC_ID_PCM_S16BE; } else { av_log_ask_for_sample(avctx, "unknown audio compression %i (format %i, width %i)\n", ast->codec->codec_tag, ast->codec->codec_id, ast->codec->bits_per_coded_sample); ast->codec->codec_id = AV_CODEC_ID_NONE; } ast->codec->codec_tag = 0; } if (mv->nb_video_tracks > 1) { av_log_ask_for_sample(avctx, "multiple video streams\n"); return AVERROR_PATCHWELCOME; } else if (mv->nb_video_tracks) { vst = avformat_new_stream(avctx, NULL); if (!vst) return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; read_table(avctx, vst, parse_video_var); } if (mv->nb_audio_tracks) read_index(pb, ast); if (mv->nb_video_tracks) read_index(pb, vst); } else { av_log_ask_for_sample(avctx, "unknown version %i\n", version); return AVERROR_PATCHWELCOME; } return 0; }
true
FFmpeg
4c9f35bb7c94d20455d3fca3a184b892f1a0aa4e
4,047
void qsb_free(QEMUSizedBuffer *qsb) { size_t i; if (!qsb) { return; } for (i = 0; i < qsb->n_iov; i++) { g_free(qsb->iov[i].iov_base); } g_free(qsb->iov); g_free(qsb); }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
4,048
static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MPADecodeContext *s = avctx->priv_data; uint32_t header; int out_size; OUT_INT *out_samples = data; if(buf_size < HEADER_SIZE) return -1; header = AV_RB32(buf); if(ff_mpa_check_header(header) < 0){ av_log(avctx, AV_LOG_ERROR, "Header missing\n"); return -1; } if (ff_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) { /* free format: prepare to compute frame size */ s->frame_size = -1; return -1; } /* update codec info */ avctx->channels = s->nb_channels; avctx->bit_rate = s->bit_rate; avctx->sub_id = s->layer; if(*data_size < 1152*avctx->channels*sizeof(OUT_INT)) return -1; if(s->frame_size<=0 || s->frame_size > buf_size){ av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); return -1; }else if(s->frame_size < buf_size){ av_log(avctx, AV_LOG_ERROR, "incorrect frame size\n"); buf_size= s->frame_size; } out_size = mp_decode_frame(s, out_samples, buf, buf_size); if(out_size>=0){ *data_size = out_size; avctx->sample_rate = s->sample_rate; //FIXME maybe move the other codec info stuff from above here too }else av_log(avctx, AV_LOG_DEBUG, "Error while decoding MPEG audio frame.\n"); //FIXME return -1 / but also return the number of bytes consumed s->frame_size = 0; return buf_size; }
true
FFmpeg
45a014d75efd043aa432b87869f898e552cbbb75
4,049
static struct omap_32khz_timer_s *omap_os_timer_init(MemoryRegion *memory, hwaddr base, qemu_irq irq, omap_clk clk) { struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) g_malloc0(sizeof(struct omap_32khz_timer_s)); s->timer.irq = irq; s->timer.clk = clk; s->timer.timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_timer_tick, &s->timer); omap_os_timer_reset(s); omap_timer_clk_setup(&s->timer); memory_region_init_io(&s->iomem, NULL, &omap_os_timer_ops, s, "omap-os-timer", 0x800); memory_region_add_subregion(memory, base, &s->iomem); return s; }
true
qemu
b45c03f585ea9bb1af76c73e82195418c294919d
4,050
static bool check_irqchip_in_kernel(void) { if (kvm_irqchip_in_kernel()) { return true; } error_report("pci-assign: error: requires KVM with in-kernel irqchip " "enabled"); return false; }
true
qemu
665f119fbad97c05c2603673ac6b2dcbf0d0e9e1
4,051
static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_factor, int frame_num){ RateControlContext *rcc= &s->rc_context; AVCodecContext *a= s->avctx; double q, bits; const int pict_type= rce->new_pict_type; const double mb_num= s->mb_num; int i; double const_values[]={ M_PI, M_E, rce->i_tex_bits*rce->qscale, rce->p_tex_bits*rce->qscale, (rce->i_tex_bits + rce->p_tex_bits)*(double)rce->qscale, rce->mv_bits/mb_num, rce->pict_type == B_TYPE ? (rce->f_code + rce->b_code)*0.5 : rce->f_code, rce->i_count/mb_num, rce->mc_mb_var_sum/mb_num, rce->mb_var_sum/mb_num, rce->pict_type == I_TYPE, rce->pict_type == P_TYPE, rce->pict_type == B_TYPE, rcc->qscale_sum[pict_type] / (double)rcc->frame_count[pict_type], a->qcompress, /* rcc->last_qscale_for[I_TYPE], rcc->last_qscale_for[P_TYPE], rcc->last_qscale_for[B_TYPE], rcc->next_non_b_qscale,*/ rcc->i_cplx_sum[I_TYPE] / (double)rcc->frame_count[I_TYPE], rcc->i_cplx_sum[P_TYPE] / (double)rcc->frame_count[P_TYPE], rcc->p_cplx_sum[P_TYPE] / (double)rcc->frame_count[P_TYPE], rcc->p_cplx_sum[B_TYPE] / (double)rcc->frame_count[B_TYPE], (rcc->i_cplx_sum[pict_type] + rcc->p_cplx_sum[pict_type]) / (double)rcc->frame_count[pict_type], 0 }; bits= ff_parse_eval(rcc->rc_eq_eval, const_values, rce); if (isnan(bits)) { av_log(s->avctx, AV_LOG_ERROR, "Error evaluating rc_eq \"%s\"\n", s->avctx->rc_eq); return -1; } rcc->pass1_rc_eq_output_sum+= bits; bits*=rate_factor; if(bits<0.0) bits=0.0; bits+= 1.0; //avoid 1/0 issues /* user override */ for(i=0; i<s->avctx->rc_override_count; i++){ RcOverride *rco= s->avctx->rc_override; if(rco[i].start_frame > frame_num) continue; if(rco[i].end_frame < frame_num) continue; if(rco[i].qscale) bits= qp2bits(rce, rco[i].qscale); //FIXME move at end to really force it? else bits*= rco[i].quality_factor; } q= bits2qp(rce, bits); /* I/B difference */ if (pict_type==I_TYPE && s->avctx->i_quant_factor<0.0) q= -q*s->avctx->i_quant_factor + s->avctx->i_quant_offset; else if(pict_type==B_TYPE && s->avctx->b_quant_factor<0.0) q= -q*s->avctx->b_quant_factor + s->avctx->b_quant_offset; return q; }
true
FFmpeg
2711cb28f46463760f0326d806fe5ef9551ade2c
4,052
static int hpet_start_timer(struct qemu_alarm_timer *t) { struct hpet_info info; int r, fd; fd = open("/dev/hpet", O_RDONLY); if (fd < 0) return -1; /* Set frequency */ r = ioctl(fd, HPET_IRQFREQ, RTC_FREQ); if (r < 0) { fprintf(stderr, "Could not configure '/dev/hpet' to have a 1024Hz timer. This is not a fatal\n" "error, but for better emulation accuracy type:\n" "'echo 1024 > /proc/sys/dev/hpet/max-user-freq' as root.\n"); goto fail; } /* Check capabilities */ r = ioctl(fd, HPET_INFO, &info); if (r < 0) goto fail; /* Enable periodic mode */ r = ioctl(fd, HPET_EPI, 0); if (info.hi_flags && (r < 0)) goto fail; /* Enable interrupt */ r = ioctl(fd, HPET_IE_ON, 0); if (r < 0) goto fail; enable_sigio_timer(fd); t->priv = (void *)(long)fd; return 0; fail: close(fd); return -1; }
true
qemu
40ff6d7e8dceca227e7f8a3e8e0d58b2c66d19b4
4,053
static void cmd_read_cd(IDEState *s, uint8_t* buf) { int nb_sectors, lba, transfer_request; nb_sectors = (buf[6] << 16) | (buf[7] << 8) | buf[8]; lba = ube32_to_cpu(buf + 2); if (nb_sectors == 0) { ide_atapi_cmd_ok(s); return; } transfer_request = buf[9]; switch(transfer_request & 0xf8) { case 0x00: /* nothing */ ide_atapi_cmd_ok(s); break; case 0x10: /* normal read */ ide_atapi_cmd_read(s, lba, nb_sectors, 2048); break; case 0xf8: /* read all data */ ide_atapi_cmd_read(s, lba, nb_sectors, 2352); break; default: ide_atapi_cmd_error(s, ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET); break; } }
true
qemu
e7bd708ec85e40fd51569bb90c52d6613ffd8f45
4,054
static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end, const char *in, int x1, int y1, int x2, int y2) { char c, *param, buffer[128], tmp[128]; int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0; SrtStack stack[16]; stack[0].tag[0] = 0; strcpy(stack[0].param[PARAM_SIZE], "{\\fs}"); strcpy(stack[0].param[PARAM_COLOR], "{\\c}"); strcpy(stack[0].param[PARAM_FACE], "{\\fn}"); if (x1 >= 0 && y1 >= 0) { if (x2 >= 0 && y2 >= 0 && (x2 != x1 || y2 != y1)) out += snprintf(out, out_end-out, "{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2); else out += snprintf(out, out_end-out, "{\\an1}{\\pos(%d,%d)}", x1, y1); } for (; out < out_end && !end && *in; in++) { switch (*in) { case '\r': break; case '\n': if (line_start) { end = 1; break; } while (out[-1] == ' ') out--; out += snprintf(out, out_end-out, "\\N"); line_start = 1; break; case ' ': if (!line_start) *out++ = *in; break; case '{': /* skip all {\xxx} substrings except for {\an%d} and all microdvd like styles such as {Y:xxx} */ an += sscanf(in, "{\\an%*1u}%c", &c) == 1; if ((an != 1 && sscanf(in, "{\\%*[^}]}%n%c", &len, &c) > 0) || sscanf(in, "{%*1[CcFfoPSsYy]:%*[^}]}%n%c", &len, &c) > 0) { in += len - 1; } else *out++ = *in; break; case '<': tag_close = in[1] == '/'; if (sscanf(in+tag_close+1, "%127[^>]>%n%c", buffer, &len,&c) >= 2) { if ((param = strchr(buffer, ' '))) *param++ = 0; if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) || ( tag_close && sptr > 0 && !strcmp(stack[sptr-1].tag, buffer))) { int i, j, unknown = 0; in += len + tag_close; if (!tag_close) memset(stack+sptr, 0, sizeof(*stack)); if (!strcmp(buffer, "font")) { if (tag_close) { for (i=PARAM_NUMBER-1; i>=0; i--) if (stack[sptr-1].param[i][0]) for (j=sptr-2; j>=0; j--) if (stack[j].param[i][0]) { out += snprintf(out, out_end-out, stack[j].param[i]); break; } } else { while (param) { if (!strncmp(param, "size=", 5)) { unsigned font_size; param += 5 + (param[5] == '"'); if (sscanf(param, "%u", &font_size) == 1) { snprintf(stack[sptr].param[PARAM_SIZE], sizeof(stack[0].param[PARAM_SIZE]), "{\\fs%u}", font_size); } } else if (!strncmp(param, "color=", 6)) { param += 6 + (param[6] == '"'); snprintf(stack[sptr].param[PARAM_COLOR], sizeof(stack[0].param[PARAM_COLOR]), "{\\c&H%X&}", html_color_parse(avctx, param)); } else if (!strncmp(param, "face=", 5)) { param += 5 + (param[5] == '"'); len = strcspn(param, param[-1] == '"' ? "\"" :" "); av_strlcpy(tmp, param, FFMIN(sizeof(tmp), len+1)); param += len; snprintf(stack[sptr].param[PARAM_FACE], sizeof(stack[0].param[PARAM_FACE]), "{\\fn%s}", tmp); } if ((param = strchr(param, ' '))) param++; } for (i=0; i<PARAM_NUMBER; i++) if (stack[sptr].param[i][0]) out += snprintf(out, out_end-out, stack[sptr].param[i]); } } else if (!buffer[1] && strspn(buffer, "bisu") == 1) { out += snprintf(out, out_end-out, "{\\%c%d}", buffer[0], !tag_close); } else { unknown = 1; snprintf(tmp, sizeof(tmp), "</%s>", buffer); } if (tag_close) { sptr--; } else if (unknown && !strstr(in, tmp)) { in -= len + tag_close; *out++ = *in; } else av_strlcpy(stack[sptr++].tag, buffer, sizeof(stack[0].tag)); break; } } default: *out++ = *in; break; } if (*in != ' ' && *in != '\r' && *in != '\n') line_start = 0; } out = FFMIN(out, out_end-3); while (!strncmp(out-2, "\\N", 2)) out -= 2; while (out[-1] == ' ') out--; out += snprintf(out, out_end-out, "\r\n"); return in; }
true
FFmpeg
aaa1173de775b9b865a714abcc270816d2f59dff
4,055
void tcg_prologue_init(TCGContext *s) { /* init global prologue and epilogue */ s->code_buf = s->code_gen_prologue; s->code_ptr = s->code_buf; tcg_target_qemu_prologue(s); flush_icache_range((tcg_target_ulong)s->code_buf, (tcg_target_ulong)s->code_ptr);
true
qemu
d6b64b2b606fe0fe5f2208e84ff7a28445de666a
4,056
static int decode_slice(AVCodecContext *c, void *arg) { FFV1Context *fs = *(void **)arg; FFV1Context *f = fs->avctx->priv_data; int width, height, x, y, ret; const int ps = (av_pix_fmt_desc_get(c->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR) ? (c->bits_per_raw_sample > 8) + 1 : 4; AVFrame *const p = f->cur; if (f->version > 2) { if (decode_slice_header(f, fs) < 0) { fs->slice_damaged = 1; return AVERROR_INVALIDDATA; } } if ((ret = ffv1_init_slice_state(f, fs)) < 0) return ret; if (f->cur->key_frame) ffv1_clear_slice_state(f, fs); width = fs->slice_width; height = fs->slice_height; x = fs->slice_x; y = fs->slice_y; if (!fs->ac) { if (f->version == 3 && f->minor_version > 1 || f->version > 3) get_rac(&fs->c, (uint8_t[]) { 129 }); fs->ac_byte_count = f->version > 2 || (!x && !y) ? fs->c.bytestream - fs->c.bytestream_start - 1 : 0; init_get_bits(&fs->gb, fs->c.bytestream_start + fs->ac_byte_count, (fs->c.bytestream_end - fs->c.bytestream_start - fs->ac_byte_count) * 8); } av_assert1(width && height); if (f->colorspace == 0) { const int chroma_width = -((-width) >> f->chroma_h_shift); const int chroma_height = -((-height) >> f->chroma_v_shift); const int cx = x >> f->chroma_h_shift; const int cy = y >> f->chroma_v_shift; decode_plane(fs, p->data[0] + ps * x + y * p->linesize[0], width, height, p->linesize[0], 0); if (f->chroma_planes) { decode_plane(fs, p->data[1] + ps * cx + cy * p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1); decode_plane(fs, p->data[2] + ps * cx + cy * p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1); } if (fs->transparency) decode_plane(fs, p->data[3] + ps * x + y * p->linesize[3], width, height, p->linesize[3], 2); } else { uint8_t *planes[3] = { p->data[0] + ps * x + y * p->linesize[0], p->data[1] + ps * x + y * p->linesize[1], p->data[2] + ps * x + y * p->linesize[2] }; decode_rgb_frame(fs, planes, width, height, p->linesize); } if (fs->ac && f->version > 2) { int v; get_rac(&fs->c, (uint8_t[]) { 129 }); v = fs->c.bytestream_end - fs->c.bytestream - 2 - 5 * f->ec; if (v) { av_log(f->avctx, AV_LOG_ERROR, "bytestream end mismatching by %d\n", v); fs->slice_damaged = 1; } } emms_c(); return 0; }
false
FFmpeg
4bb1070c154e49d35805fbcdac9c9e92f702ef96
4,057
int text_console_init(QemuOpts *opts, CharDriverState **_chr) { CharDriverState *chr; TextConsole *s; unsigned width; unsigned height; chr = g_malloc0(sizeof(CharDriverState)); if (n_text_consoles == 128) { fprintf(stderr, "Too many text consoles\n"); exit(1); } text_consoles[n_text_consoles] = chr; n_text_consoles++; width = qemu_opt_get_number(opts, "width", 0); if (width == 0) width = qemu_opt_get_number(opts, "cols", 0) * FONT_WIDTH; height = qemu_opt_get_number(opts, "height", 0); if (height == 0) height = qemu_opt_get_number(opts, "rows", 0) * FONT_HEIGHT; if (width == 0 || height == 0) { s = new_console(NULL, TEXT_CONSOLE); } else { s = new_console(NULL, TEXT_CONSOLE_FIXED_SIZE); } if (!s) { g_free(chr); return -EBUSY; } s->chr = chr; s->g_width = width; s->g_height = height; chr->opaque = s; chr->chr_set_echo = text_console_set_echo; *_chr = chr; return 0; }
true
qemu
1f51470d044852592922f91000e741c381582cdc
4,058
_eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags, size_t rthdr_offset, struct ip6_ext_hdr *ext_hdr, struct in6_address *dst_addr) { struct ip6_ext_hdr_routing *rthdr = (struct ip6_ext_hdr_routing *) ext_hdr; if ((rthdr->rtype == 2) && (rthdr->len == sizeof(struct in6_address) / 8) && (rthdr->segleft == 1)) { size_t input_size = iov_size(pkt, pkt_frags); size_t bytes_read; if (input_size < rthdr_offset + sizeof(*ext_hdr)) { return false; } bytes_read = iov_to_buf(pkt, pkt_frags, rthdr_offset + sizeof(*ext_hdr), dst_addr, sizeof(*dst_addr)); return bytes_read == sizeof(dst_addr); } return false; }
true
qemu
b2caa3b82edca29ccb5e7d6311ffcf841b9b7786
4,059
USBPacket *usb_ep_find_packet_by_id(USBDevice *dev, int pid, int ep, uint64_t id) { struct USBEndpoint *uep = usb_ep_get(dev, pid, ep); USBPacket *p; while ((p = QTAILQ_FIRST(&uep->queue)) != NULL) { if (p->id == id) { return p; } } return NULL; }
true
qemu
6735d433729f80fab80c0a1f70ae131398645613
4,060
void pci_bridge_exitfn(PCIDevice *pci_dev) { PCIBridge *s = DO_UPCAST(PCIBridge, dev, pci_dev); assert(QLIST_EMPTY(&s->sec_bus.child)); QLIST_REMOVE(&s->sec_bus, sibling); pci_bridge_region_cleanup(s); memory_region_destroy(&s->address_space_mem); memory_region_destroy(&s->address_space_io); /* qbus_free() is called automatically by qdev_free() */ }
true
qemu
523a59f596a3e62f5a28eb171adba35e71310040
4,063
static void superh_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); CPUClass *cc = CPU_CLASS(oc); SuperHCPUClass *scc = SUPERH_CPU_CLASS(oc); scc->parent_realize = dc->realize; dc->realize = superh_cpu_realizefn; scc->parent_reset = cc->reset; cc->reset = superh_cpu_reset; cc->class_by_name = superh_cpu_class_by_name; cc->has_work = superh_cpu_has_work; cc->do_interrupt = superh_cpu_do_interrupt; cc->cpu_exec_interrupt = superh_cpu_exec_interrupt; cc->dump_state = superh_cpu_dump_state; cc->set_pc = superh_cpu_set_pc; cc->synchronize_from_tb = superh_cpu_synchronize_from_tb; cc->gdb_read_register = superh_cpu_gdb_read_register; cc->gdb_write_register = superh_cpu_gdb_write_register; #ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = superh_cpu_handle_mmu_fault; #else cc->get_phys_page_debug = superh_cpu_get_phys_page_debug; #endif cc->disas_set_info = superh_cpu_disas_set_info; cc->gdb_num_core_regs = 59; dc->vmsd = &vmstate_sh_cpu; /* * Reason: superh_cpu_initfn() calls cpu_exec_init(), which saves * the object in cpus -> dangling pointer after final * object_unref(). */ dc->cannot_destroy_with_object_finalize_yet = true; }
true
qemu
ce5b1bbf624b977a55ff7f85bb3871682d03baff
4,065
uint64_t HELPER(neon_abdl_u32)(uint32_t a, uint32_t b) { uint64_t tmp; uint64_t result; DO_ABD(result, a, b, uint16_t); DO_ABD(tmp, a >> 16, b >> 16, uint16_t); return result | (tmp << 32); }
true
qemu
4d9ad7f793605abd9806fc932b3e04e028894565
4,066
void RENAME(swri_noise_shaping)(SwrContext *s, AudioData *dsts, const AudioData *srcs, const AudioData *noises, int count){ int i, j, pos, ch; int taps = s->dither.ns_taps; float S = s->dither.ns_scale; float S_1 = s->dither.ns_scale_1; av_assert2((taps&3) != 2); av_assert2((taps&3) != 3 || s->dither.ns_coeffs[taps] == 0); for (ch=0; ch<srcs->ch_count; ch++) { const float *noise = ((const float *)noises->ch[ch]) + s->dither.noise_pos; const DELEM *src = (const DELEM*)srcs->ch[ch]; DELEM *dst = (DELEM*)dsts->ch[ch]; float *ns_errors = s->dither.ns_errors[ch]; const float *ns_coeffs = s->dither.ns_coeffs; pos = s->dither.ns_pos; for (i=0; i<count; i++) { double d1, d = src[i]*S_1; for(j=0; j<taps-2; j+=4) { d -= ns_coeffs[j ] * ns_errors[pos + j ] +ns_coeffs[j + 1] * ns_errors[pos + j + 1] +ns_coeffs[j + 2] * ns_errors[pos + j + 2] +ns_coeffs[j + 3] * ns_errors[pos + j + 3]; } if(j < taps) d -= ns_coeffs[j] * ns_errors[pos + j]; pos = pos ? pos - 1 : taps - 1; d1 = rint(d + noise[i]); ns_errors[pos + taps] = ns_errors[pos] = d1 - d; d1 *= S; CLIP(d1); dst[i] = d1; } } s->dither.ns_pos = pos; }
true
FFmpeg
cc4a41727e29a52a181e3d1c1a398f1da40969c3
4,067
static int64_t expr_unary(Monitor *mon) { int64_t n; char *p; int ret; switch(*pch) { case '+': next(); n = expr_unary(mon); break; case '-': next(); n = -expr_unary(mon); break; case '~': next(); n = ~expr_unary(mon); break; case '(': next(); n = expr_sum(mon); if (*pch != ')') { expr_error(mon, "')' expected"); } next(); break; case '\'': pch++; if (*pch == '\0') expr_error(mon, "character constant expected"); n = *pch; pch++; if (*pch != '\'') expr_error(mon, "missing terminating \' character"); next(); break; case '$': { char buf[128], *q; target_long reg=0; pch++; q = buf; while ((*pch >= 'a' && *pch <= 'z') || (*pch >= 'A' && *pch <= 'Z') || (*pch >= '0' && *pch <= '9') || *pch == '_' || *pch == '.') { if ((q - buf) < sizeof(buf) - 1) *q++ = *pch; pch++; } while (qemu_isspace(*pch)) pch++; *q = 0; ret = get_monitor_def(&reg, buf); if (ret == -1) expr_error(mon, "unknown register"); else if (ret == -2) expr_error(mon, "no cpu defined"); n = reg; } break; case '\0': expr_error(mon, "unexpected end of expression"); n = 0; break; default: #if TARGET_PHYS_ADDR_BITS > 32 n = strtoull(pch, &p, 0); #else n = strtoul(pch, &p, 0); #endif if (pch == p) { expr_error(mon, "invalid char in expression"); } pch = p; while (qemu_isspace(*pch)) pch++; break; } return n; }
true
qemu
09b9418c6d085a0728372aa760ebd10128a020b1
4,068
static av_cold void uninit(AVFilterContext *ctx) { DynamicAudioNormalizerContext *s = ctx->priv; int c; av_freep(&s->prev_amplification_factor); av_freep(&s->dc_correction_value); av_freep(&s->compress_threshold); av_freep(&s->fade_factors[0]); av_freep(&s->fade_factors[1]); for (c = 0; c < s->channels; c++) { cqueue_free(s->gain_history_original[c]); cqueue_free(s->gain_history_minimum[c]); cqueue_free(s->gain_history_smoothed[c]); } av_freep(&s->gain_history_original); av_freep(&s->gain_history_minimum); av_freep(&s->gain_history_smoothed); av_freep(&s->weights); ff_bufqueue_discard_all(&s->queue); }
true
FFmpeg
70df51112ccc8d281cdb96141f20b3fd8a5b11f8
4,069
static int RENAME(dct_quantize)(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow) { x86_reg last_non_zero_p1; int level=0, q; //=0 is because gcc says uninitialized ... const uint16_t *qmat, *bias; LOCAL_ALIGNED_16(int16_t, temp_block, [64]); av_assert2((7&(int)(&temp_block[0])) == 0); //did gcc align it correctly? //s->fdct (block); RENAMEl(ff_fdct) (block); //cannot be anything else ... if(s->dct_error_sum) s->denoise_dct(s, block); if (s->mb_intra) { int dummy; if (n < 4){ q = s->y_dc_scale; bias = s->q_intra_matrix16[qscale][1]; qmat = s->q_intra_matrix16[qscale][0]; }else{ q = s->c_dc_scale; bias = s->q_chroma_intra_matrix16[qscale][1]; qmat = s->q_chroma_intra_matrix16[qscale][0]; } /* note: block[0] is assumed to be positive */ if (!s->h263_aic) { __asm__ volatile ( "mul %%ecx \n\t" : "=d" (level), "=a"(dummy) : "a" ((block[0]>>2) + q), "c" (ff_inverse[q<<1]) ); } else /* For AIC we skip quant/dequant of INTRADC */ level = (block[0] + 4)>>3; block[0]=0; //avoid fake overflow // temp_block[0] = (block[0] + (q >> 1)) / q; last_non_zero_p1 = 1; } else { last_non_zero_p1 = 0; bias = s->q_inter_matrix16[qscale][1]; qmat = s->q_inter_matrix16[qscale][0]; } if((s->out_format == FMT_H263 || s->out_format == FMT_H261) && s->mpeg_quant==0){ __asm__ volatile( "movd %%"REG_a", "MM"3 \n\t" // last_non_zero_p1 SPREADW(MM"3") "pxor "MM"7, "MM"7 \n\t" // 0 "pxor "MM"4, "MM"4 \n\t" // 0 MOVQ" (%2), "MM"5 \n\t" // qmat[0] "pxor "MM"6, "MM"6 \n\t" "psubw (%3), "MM"6 \n\t" // -bias[0] "mov $-128, %%"REG_a" \n\t" ".p2align 4 \n\t" "1: \n\t" MOVQ" (%1, %%"REG_a"), "MM"0 \n\t" // block[i] SAVE_SIGN(MM"1", MM"0") // ABS(block[i]) "psubusw "MM"6, "MM"0 \n\t" // ABS(block[i]) + bias[0] "pmulhw "MM"5, "MM"0 \n\t" // (ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16 "por "MM"0, "MM"4 \n\t" RESTORE_SIGN(MM"1", MM"0") // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i]) MOVQ" "MM"0, (%5, %%"REG_a") \n\t" "pcmpeqw "MM"7, "MM"0 \n\t" // out==0 ? 0xFF : 0x00 MOVQ" (%4, %%"REG_a"), "MM"1 \n\t" MOVQ" "MM"7, (%1, %%"REG_a") \n\t" // 0 "pandn "MM"1, "MM"0 \n\t" PMAXW(MM"0", MM"3") "add $"MMREG_WIDTH", %%"REG_a" \n\t" " js 1b \n\t" PMAX(MM"3", MM"0") "movd "MM"3, %%"REG_a" \n\t" "movzbl %%al, %%eax \n\t" // last_non_zero_p1 : "+a" (last_non_zero_p1) : "r" (block+64), "r" (qmat), "r" (bias), "r" (inv_zigzag_direct16 + 64), "r" (temp_block + 64) XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7") ); }else{ // FMT_H263 __asm__ volatile( "movd %%"REG_a", "MM"3 \n\t" // last_non_zero_p1 SPREADW(MM"3") "pxor "MM"7, "MM"7 \n\t" // 0 "pxor "MM"4, "MM"4 \n\t" // 0 "mov $-128, %%"REG_a" \n\t" ".p2align 4 \n\t" "1: \n\t" MOVQ" (%1, %%"REG_a"), "MM"0 \n\t" // block[i] SAVE_SIGN(MM"1", MM"0") // ABS(block[i]) MOVQ" (%3, %%"REG_a"), "MM"6 \n\t" // bias[0] "paddusw "MM"6, "MM"0 \n\t" // ABS(block[i]) + bias[0] MOVQ" (%2, %%"REG_a"), "MM"5 \n\t" // qmat[i] "pmulhw "MM"5, "MM"0 \n\t" // (ABS(block[i])*qmat[0] + bias[0]*qmat[0])>>16 "por "MM"0, "MM"4 \n\t" RESTORE_SIGN(MM"1", MM"0") // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i]) MOVQ" "MM"0, (%5, %%"REG_a") \n\t" "pcmpeqw "MM"7, "MM"0 \n\t" // out==0 ? 0xFF : 0x00 MOVQ" (%4, %%"REG_a"), "MM"1 \n\t" MOVQ" "MM"7, (%1, %%"REG_a") \n\t" // 0 "pandn "MM"1, "MM"0 \n\t" PMAXW(MM"0", MM"3") "add $"MMREG_WIDTH", %%"REG_a" \n\t" " js 1b \n\t" PMAX(MM"3", MM"0") "movd "MM"3, %%"REG_a" \n\t" "movzbl %%al, %%eax \n\t" // last_non_zero_p1 : "+a" (last_non_zero_p1) : "r" (block+64), "r" (qmat+64), "r" (bias+64), "r" (inv_zigzag_direct16 + 64), "r" (temp_block + 64) XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7") ); } __asm__ volatile( "movd %1, "MM"1 \n\t" // max_qcoeff SPREADW(MM"1") "psubusw "MM"1, "MM"4 \n\t" "packuswb "MM"4, "MM"4 \n\t" #if COMPILE_TEMPLATE_SSE2 "packuswb "MM"4, "MM"4 \n\t" #endif "movd "MM"4, %0 \n\t" // *overflow : "=g" (*overflow) : "g" (s->max_qcoeff) ); if(s->mb_intra) block[0]= level; else block[0]= temp_block[0]; if(s->dsp.idct_permutation_type == FF_SIMPLE_IDCT_PERM){ if(last_non_zero_p1 <= 1) goto end; block[0x08] = temp_block[0x01]; block[0x10] = temp_block[0x08]; block[0x20] = temp_block[0x10]; if(last_non_zero_p1 <= 4) goto end; block[0x18] = temp_block[0x09]; block[0x04] = temp_block[0x02]; block[0x09] = temp_block[0x03]; if(last_non_zero_p1 <= 7) goto end; block[0x14] = temp_block[0x0A]; block[0x28] = temp_block[0x11]; block[0x12] = temp_block[0x18]; block[0x02] = temp_block[0x20]; if(last_non_zero_p1 <= 11) goto end; block[0x1A] = temp_block[0x19]; block[0x24] = temp_block[0x12]; block[0x19] = temp_block[0x0B]; block[0x01] = temp_block[0x04]; block[0x0C] = temp_block[0x05]; if(last_non_zero_p1 <= 16) goto end; block[0x11] = temp_block[0x0C]; block[0x29] = temp_block[0x13]; block[0x16] = temp_block[0x1A]; block[0x0A] = temp_block[0x21]; block[0x30] = temp_block[0x28]; block[0x22] = temp_block[0x30]; block[0x38] = temp_block[0x29]; block[0x06] = temp_block[0x22]; if(last_non_zero_p1 <= 24) goto end; block[0x1B] = temp_block[0x1B]; block[0x21] = temp_block[0x14]; block[0x1C] = temp_block[0x0D]; block[0x05] = temp_block[0x06]; block[0x0D] = temp_block[0x07]; block[0x15] = temp_block[0x0E]; block[0x2C] = temp_block[0x15]; block[0x13] = temp_block[0x1C]; if(last_non_zero_p1 <= 32) goto end; block[0x0B] = temp_block[0x23]; block[0x34] = temp_block[0x2A]; block[0x2A] = temp_block[0x31]; block[0x32] = temp_block[0x38]; block[0x3A] = temp_block[0x39]; block[0x26] = temp_block[0x32]; block[0x39] = temp_block[0x2B]; block[0x03] = temp_block[0x24]; if(last_non_zero_p1 <= 40) goto end; block[0x1E] = temp_block[0x1D]; block[0x25] = temp_block[0x16]; block[0x1D] = temp_block[0x0F]; block[0x2D] = temp_block[0x17]; block[0x17] = temp_block[0x1E]; block[0x0E] = temp_block[0x25]; block[0x31] = temp_block[0x2C]; block[0x2B] = temp_block[0x33]; if(last_non_zero_p1 <= 48) goto end; block[0x36] = temp_block[0x3A]; block[0x3B] = temp_block[0x3B]; block[0x23] = temp_block[0x34]; block[0x3C] = temp_block[0x2D]; block[0x07] = temp_block[0x26]; block[0x1F] = temp_block[0x1F]; block[0x0F] = temp_block[0x27]; block[0x35] = temp_block[0x2E]; if(last_non_zero_p1 <= 56) goto end; block[0x2E] = temp_block[0x35]; block[0x33] = temp_block[0x3C]; block[0x3E] = temp_block[0x3D]; block[0x27] = temp_block[0x36]; block[0x3D] = temp_block[0x2F]; block[0x2F] = temp_block[0x37]; block[0x37] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F]; }else if(s->dsp.idct_permutation_type == FF_LIBMPEG2_IDCT_PERM){ if(last_non_zero_p1 <= 1) goto end; block[0x04] = temp_block[0x01]; block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10]; if(last_non_zero_p1 <= 4) goto end; block[0x0C] = temp_block[0x09]; block[0x01] = temp_block[0x02]; block[0x05] = temp_block[0x03]; if(last_non_zero_p1 <= 7) goto end; block[0x09] = temp_block[0x0A]; block[0x14] = temp_block[0x11]; block[0x18] = temp_block[0x18]; block[0x20] = temp_block[0x20]; if(last_non_zero_p1 <= 11) goto end; block[0x1C] = temp_block[0x19]; block[0x11] = temp_block[0x12]; block[0x0D] = temp_block[0x0B]; block[0x02] = temp_block[0x04]; block[0x06] = temp_block[0x05]; if(last_non_zero_p1 <= 16) goto end; block[0x0A] = temp_block[0x0C]; block[0x15] = temp_block[0x13]; block[0x19] = temp_block[0x1A]; block[0x24] = temp_block[0x21]; block[0x28] = temp_block[0x28]; block[0x30] = temp_block[0x30]; block[0x2C] = temp_block[0x29]; block[0x21] = temp_block[0x22]; if(last_non_zero_p1 <= 24) goto end; block[0x1D] = temp_block[0x1B]; block[0x12] = temp_block[0x14]; block[0x0E] = temp_block[0x0D]; block[0x03] = temp_block[0x06]; block[0x07] = temp_block[0x07]; block[0x0B] = temp_block[0x0E]; block[0x16] = temp_block[0x15]; block[0x1A] = temp_block[0x1C]; if(last_non_zero_p1 <= 32) goto end; block[0x25] = temp_block[0x23]; block[0x29] = temp_block[0x2A]; block[0x34] = temp_block[0x31]; block[0x38] = temp_block[0x38]; block[0x3C] = temp_block[0x39]; block[0x31] = temp_block[0x32]; block[0x2D] = temp_block[0x2B]; block[0x22] = temp_block[0x24]; if(last_non_zero_p1 <= 40) goto end; block[0x1E] = temp_block[0x1D]; block[0x13] = temp_block[0x16]; block[0x0F] = temp_block[0x0F]; block[0x17] = temp_block[0x17]; block[0x1B] = temp_block[0x1E]; block[0x26] = temp_block[0x25]; block[0x2A] = temp_block[0x2C]; block[0x35] = temp_block[0x33]; if(last_non_zero_p1 <= 48) goto end; block[0x39] = temp_block[0x3A]; block[0x3D] = temp_block[0x3B]; block[0x32] = temp_block[0x34]; block[0x2E] = temp_block[0x2D]; block[0x23] = temp_block[0x26]; block[0x1F] = temp_block[0x1F]; block[0x27] = temp_block[0x27]; block[0x2B] = temp_block[0x2E]; if(last_non_zero_p1 <= 56) goto end; block[0x36] = temp_block[0x35]; block[0x3A] = temp_block[0x3C]; block[0x3E] = temp_block[0x3D]; block[0x33] = temp_block[0x36]; block[0x2F] = temp_block[0x2F]; block[0x37] = temp_block[0x37]; block[0x3B] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F]; }else{ if(last_non_zero_p1 <= 1) goto end; block[0x01] = temp_block[0x01]; block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10]; if(last_non_zero_p1 <= 4) goto end; block[0x09] = temp_block[0x09]; block[0x02] = temp_block[0x02]; block[0x03] = temp_block[0x03]; if(last_non_zero_p1 <= 7) goto end; block[0x0A] = temp_block[0x0A]; block[0x11] = temp_block[0x11]; block[0x18] = temp_block[0x18]; block[0x20] = temp_block[0x20]; if(last_non_zero_p1 <= 11) goto end; block[0x19] = temp_block[0x19]; block[0x12] = temp_block[0x12]; block[0x0B] = temp_block[0x0B]; block[0x04] = temp_block[0x04]; block[0x05] = temp_block[0x05]; if(last_non_zero_p1 <= 16) goto end; block[0x0C] = temp_block[0x0C]; block[0x13] = temp_block[0x13]; block[0x1A] = temp_block[0x1A]; block[0x21] = temp_block[0x21]; block[0x28] = temp_block[0x28]; block[0x30] = temp_block[0x30]; block[0x29] = temp_block[0x29]; block[0x22] = temp_block[0x22]; if(last_non_zero_p1 <= 24) goto end; block[0x1B] = temp_block[0x1B]; block[0x14] = temp_block[0x14]; block[0x0D] = temp_block[0x0D]; block[0x06] = temp_block[0x06]; block[0x07] = temp_block[0x07]; block[0x0E] = temp_block[0x0E]; block[0x15] = temp_block[0x15]; block[0x1C] = temp_block[0x1C]; if(last_non_zero_p1 <= 32) goto end; block[0x23] = temp_block[0x23]; block[0x2A] = temp_block[0x2A]; block[0x31] = temp_block[0x31]; block[0x38] = temp_block[0x38]; block[0x39] = temp_block[0x39]; block[0x32] = temp_block[0x32]; block[0x2B] = temp_block[0x2B]; block[0x24] = temp_block[0x24]; if(last_non_zero_p1 <= 40) goto end; block[0x1D] = temp_block[0x1D]; block[0x16] = temp_block[0x16]; block[0x0F] = temp_block[0x0F]; block[0x17] = temp_block[0x17]; block[0x1E] = temp_block[0x1E]; block[0x25] = temp_block[0x25]; block[0x2C] = temp_block[0x2C]; block[0x33] = temp_block[0x33]; if(last_non_zero_p1 <= 48) goto end; block[0x3A] = temp_block[0x3A]; block[0x3B] = temp_block[0x3B]; block[0x34] = temp_block[0x34]; block[0x2D] = temp_block[0x2D]; block[0x26] = temp_block[0x26]; block[0x1F] = temp_block[0x1F]; block[0x27] = temp_block[0x27]; block[0x2E] = temp_block[0x2E]; if(last_non_zero_p1 <= 56) goto end; block[0x35] = temp_block[0x35]; block[0x3C] = temp_block[0x3C]; block[0x3D] = temp_block[0x3D]; block[0x36] = temp_block[0x36]; block[0x2F] = temp_block[0x2F]; block[0x37] = temp_block[0x37]; block[0x3E] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F]; } end: return last_non_zero_p1 - 1; }
true
FFmpeg
c25d2cd20b7643ea2c864dea9f25eef322cf3fb2
4,073
static int mxf_read_sequence(void *arg, AVIOContext *pb, int tag, int size, UID uid) { MXFSequence *sequence = arg; switch(tag) { case 0x0202: sequence->duration = avio_rb64(pb); break; case 0x0201: avio_read(pb, sequence->data_definition_ul, 16); break; case 0x1001: sequence->structural_components_count = avio_rb32(pb); if (sequence->structural_components_count >= UINT_MAX / sizeof(UID)) return -1; sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID)); if (!sequence->structural_components_refs) return -1; avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */ avio_read(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID)); break; } return 0; }
true
FFmpeg
fd34dbea58e097609ff09cf7dcc59f74930195d3
4,074
World *world_alloc(Rocker *r, size_t sizeof_private, enum rocker_world_type type, WorldOps *ops) { World *w = g_malloc0(sizeof(World) + sizeof_private); if (w) { w->r = r; w->type = type; w->ops = ops; if (w->ops->init) { w->ops->init(w); } } return w; }
true
qemu
107e4b352cc309f9bd7588ef1a44549200620078
4,075
void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st, AVCodecParserContext *pc, AVPacket *pkt) { int frame_size; *pnum = 0; *pden = 0; switch(st->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: if (st->avg_frame_rate.num) { *pnum = st->avg_frame_rate.den; *pden = st->avg_frame_rate.num; } else if(st->time_base.num*1000LL > st->time_base.den) { *pnum = st->time_base.num; *pden = st->time_base.den; }else if(st->codec->time_base.num*1000LL > st->codec->time_base.den){ *pnum = st->codec->time_base.num; *pden = st->codec->time_base.den; if (pc && pc->repeat_pict) { *pnum = (*pnum) * (1 + pc->repeat_pict); } //If this codec can be interlaced or progressive then we need a parser to compute duration of a packet //Thus if we have no parser in such case leave duration undefined. if(st->codec->ticks_per_frame>1 && !pc){ *pnum = *pden = 0; } } break; case AVMEDIA_TYPE_AUDIO: frame_size = ff_get_audio_frame_size(st->codec, pkt->size, 0); if (frame_size <= 0 || st->codec->sample_rate <= 0) break; *pnum = frame_size; *pden = st->codec->sample_rate; break; default: break; } }
true
FFmpeg
7709ce029a7bc101b9ac1ceee607cda10dcb89dc
4,077
static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size) { SerialState *s = opaque; uint32_t ret; addr &= 7; switch(addr) { default: case 0: if (s->lcr & UART_LCR_DLAB) { ret = s->divider & 0xff; } else { if(s->fcr & UART_FCR_FE) { ret = fifo8_is_full(&s->recv_fifo) ? 0 : fifo8_pop(&s->recv_fifo); if (s->recv_fifo.num == 0) { s->lsr &= ~(UART_LSR_DR | UART_LSR_BI); } else { qemu_mod_timer(s->fifo_timeout_timer, qemu_get_clock_ns (vm_clock) + s->char_transmit_time * 4); } s->timeout_ipending = 0; } else { ret = s->rbr; s->lsr &= ~(UART_LSR_DR | UART_LSR_BI); } serial_update_irq(s); if (!(s->mcr & UART_MCR_LOOP)) { /* in loopback mode, don't receive any data */ qemu_chr_accept_input(s->chr); } } break; case 1: if (s->lcr & UART_LCR_DLAB) { ret = (s->divider >> 8) & 0xff; } else { ret = s->ier; } break; case 2: ret = s->iir; if ((ret & UART_IIR_ID) == UART_IIR_THRI) { s->thr_ipending = 0; serial_update_irq(s); } break; case 3: ret = s->lcr; break; case 4: ret = s->mcr; break; case 5: ret = s->lsr; /* Clear break and overrun interrupts */ if (s->lsr & (UART_LSR_BI|UART_LSR_OE)) { s->lsr &= ~(UART_LSR_BI|UART_LSR_OE); serial_update_irq(s); } break; case 6: if (s->mcr & UART_MCR_LOOP) { /* in loopback, the modem output pins are connected to the inputs */ ret = (s->mcr & 0x0c) << 4; ret |= (s->mcr & 0x02) << 3; ret |= (s->mcr & 0x01) << 5; } else { if (s->poll_msl >= 0) serial_update_msl(s); ret = s->msr; /* Clear delta bits & msr int after read, if they were set */ if (s->msr & UART_MSR_ANY_DELTA) { s->msr &= 0xF0; serial_update_irq(s); } } break; case 7: ret = s->scr; break; } DPRINTF("read addr=0x%" HWADDR_PRIx " val=0x%02x\n", addr, ret); return ret; }
true
qemu
b165b0d8e62bb65a02d7670d75ebb77a9280bde1
4,078
create_iovec(BlockBackend *blk, QEMUIOVector *qiov, char **argv, int nr_iov, int pattern) { size_t *sizes = g_new0(size_t, nr_iov); size_t count = 0; void *buf = NULL; void *p; int i; for (i = 0; i < nr_iov; i++) { char *arg = argv[i]; int64_t len; len = cvtnum(arg); if (len < 0) { print_cvtnum_err(len, arg); goto fail; } if (len > SIZE_MAX) { printf("Argument '%s' exceeds maximum size %llu\n", arg, (unsigned long long)SIZE_MAX); goto fail; } sizes[i] = len; count += len; } qemu_iovec_init(qiov, nr_iov); buf = p = qemu_io_alloc(blk, count, pattern); for (i = 0; i < nr_iov; i++) { qemu_iovec_add(qiov, p, sizes[i]); p += sizes[i]; } fail: g_free(sizes); return buf; }
true
qemu
3026c4688ca80d9c5cc1606368c4a1009a6f507d
4,079
static bool main_loop_should_exit(void) { RunState r; if (qemu_debug_requested()) { vm_stop(RUN_STATE_DEBUG); } if (qemu_suspend_requested()) { qemu_system_suspend(); } if (qemu_shutdown_requested()) { qemu_kill_report(); monitor_protocol_event(QEVENT_SHUTDOWN, NULL); if (no_shutdown) { vm_stop(RUN_STATE_SHUTDOWN); } else { return true; } } if (qemu_reset_requested()) { pause_all_vcpus(); cpu_synchronize_all_states(); qemu_system_reset(VMRESET_REPORT); resume_all_vcpus(); if (runstate_check(RUN_STATE_INTERNAL_ERROR) || runstate_check(RUN_STATE_SHUTDOWN)) { runstate_set(RUN_STATE_PAUSED); } } if (qemu_wakeup_requested()) { pause_all_vcpus(); cpu_synchronize_all_states(); qemu_system_reset(VMRESET_SILENT); resume_all_vcpus(); monitor_protocol_event(QEVENT_WAKEUP, NULL); } if (qemu_powerdown_requested()) { qemu_system_powerdown(); } if (qemu_vmstop_requested(&r)) { vm_stop(r); } return false; }
true
qemu
ede085b3fedfde36cb566968c4efcfbad4845af1
4,082
int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) { AVStream *st; MOVStreamContext *sc; int j, pseudo_stream_id; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; sc = st->priv_data; for (pseudo_stream_id=0; pseudo_stream_id<entries; pseudo_stream_id++) { //Parsing Sample description table enum CodecID id; int dref_id = 1; MOVAtom a = { AV_RL32("stsd") }; int64_t start_pos = avio_tell(pb); int size = avio_rb32(pb); /* size */ uint32_t format = avio_rl32(pb); /* data format */ if (size >= 16) { avio_rb32(pb); /* reserved */ avio_rb16(pb); /* reserved */ dref_id = avio_rb16(pb); } if (st->codec->codec_tag && st->codec->codec_tag != format && (c->fc->video_codec_id ? ff_codec_get_id(codec_movvideo_tags, format) != c->fc->video_codec_id : st->codec->codec_tag != MKTAG('j','p','e','g')) ){ /* Multiple fourcc, we skip JPEG. This is not correct, we should * export it as a separate AVStream but this needs a few changes * in the MOV demuxer, patch welcome. */ multiple_stsd: av_log(c->fc, AV_LOG_WARNING, "multiple fourcc not supported\n"); avio_skip(pb, size - (avio_tell(pb) - start_pos)); continue; } /* we cannot demux concatenated h264 streams because of different extradata */ if (st->codec->codec_tag && st->codec->codec_tag == AV_RL32("avc1")) goto multiple_stsd; sc->pseudo_stream_id = st->codec->codec_tag ? -1 : pseudo_stream_id; sc->dref_id= dref_id; st->codec->codec_tag = format; id = ff_codec_get_id(codec_movaudio_tags, format); if (id<=0 && ((format&0xFFFF) == 'm'+('s'<<8) || (format&0xFFFF) == 'T'+('S'<<8))) id = ff_codec_get_id(ff_codec_wav_tags, av_bswap32(format)&0xFFFF); if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO && id > 0) { st->codec->codec_type = AVMEDIA_TYPE_AUDIO; } else if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO && /* do not overwrite codec type */ format && format != MKTAG('m','p','4','s')) { /* skip old asf mpeg4 tag */ id = ff_codec_get_id(codec_movvideo_tags, format); if (id <= 0) id = ff_codec_get_id(ff_codec_bmp_tags, format); if (id > 0) st->codec->codec_type = AVMEDIA_TYPE_VIDEO; else if (st->codec->codec_type == AVMEDIA_TYPE_DATA){ id = ff_codec_get_id(ff_codec_movsubtitle_tags, format); if (id > 0) st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; } } av_dlog(c->fc, "size=%d 4CC= %c%c%c%c codec_type=%d\n", size, (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff, (format >> 24) & 0xff, st->codec->codec_type); if (st->codec->codec_type==AVMEDIA_TYPE_VIDEO) { unsigned int color_depth, len; int color_greyscale; st->codec->codec_id = id; avio_rb16(pb); /* version */ avio_rb16(pb); /* revision level */ avio_rb32(pb); /* vendor */ avio_rb32(pb); /* temporal quality */ avio_rb32(pb); /* spatial quality */ st->codec->width = avio_rb16(pb); /* width */ st->codec->height = avio_rb16(pb); /* height */ avio_rb32(pb); /* horiz resolution */ avio_rb32(pb); /* vert resolution */ avio_rb32(pb); /* data size, always 0 */ avio_rb16(pb); /* frames per samples */ len = avio_r8(pb); /* codec name, pascal string */ if (len > 31) len = 31; mov_read_mac_string(c, pb, len, st->codec->codec_name, 32); if (len < 31) avio_skip(pb, 31 - len); /* codec_tag YV12 triggers an UV swap in rawdec.c */ if (!memcmp(st->codec->codec_name, "Planar Y'CbCr 8-bit 4:2:0", 25)) st->codec->codec_tag=MKTAG('I', '4', '2', '0'); st->codec->bits_per_coded_sample = avio_rb16(pb); /* depth */ st->codec->color_table_id = avio_rb16(pb); /* colortable id */ av_dlog(c->fc, "depth %d, ctab id %d\n", st->codec->bits_per_coded_sample, st->codec->color_table_id); /* figure out the palette situation */ color_depth = st->codec->bits_per_coded_sample & 0x1F; color_greyscale = st->codec->bits_per_coded_sample & 0x20; /* if the depth is 2, 4, or 8 bpp, file is palettized */ if ((color_depth == 2) || (color_depth == 4) || (color_depth == 8)) { /* for palette traversal */ unsigned int color_start, color_count, color_end; unsigned char r, g, b; if (color_greyscale) { int color_index, color_dec; /* compute the greyscale palette */ st->codec->bits_per_coded_sample = color_depth; color_count = 1 << color_depth; color_index = 255; color_dec = 256 / (color_count - 1); for (j = 0; j < color_count; j++) { if (id == CODEC_ID_CINEPAK){ r = g = b = color_count - 1 - color_index; }else r = g = b = color_index; sc->palette[j] = (r << 16) | (g << 8) | (b); color_index -= color_dec; if (color_index < 0) color_index = 0; } } else if (st->codec->color_table_id) { const uint8_t *color_table; /* if flag bit 3 is set, use the default palette */ color_count = 1 << color_depth; if (color_depth == 2) color_table = ff_qt_default_palette_4; else if (color_depth == 4) color_table = ff_qt_default_palette_16; else color_table = ff_qt_default_palette_256; for (j = 0; j < color_count; j++) { r = color_table[j * 3 + 0]; g = color_table[j * 3 + 1]; b = color_table[j * 3 + 2]; sc->palette[j] = (r << 16) | (g << 8) | (b); } } else { /* load the palette from the file */ color_start = avio_rb32(pb); color_count = avio_rb16(pb); color_end = avio_rb16(pb); if ((color_start <= 255) && (color_end <= 255)) { for (j = color_start; j <= color_end; j++) { /* each R, G, or B component is 16 bits; * only use the top 8 bits; skip alpha bytes * up front */ avio_r8(pb); avio_r8(pb); r = avio_r8(pb); avio_r8(pb); g = avio_r8(pb); avio_r8(pb); b = avio_r8(pb); avio_r8(pb); sc->palette[j] = (r << 16) | (g << 8) | (b); } } } sc->has_palette = 1; } } else if (st->codec->codec_type==AVMEDIA_TYPE_AUDIO) { int bits_per_sample, flags; uint16_t version = avio_rb16(pb); st->codec->codec_id = id; avio_rb16(pb); /* revision level */ avio_rb32(pb); /* vendor */ st->codec->channels = avio_rb16(pb); /* channel count */ av_dlog(c->fc, "audio channels %d\n", st->codec->channels); st->codec->bits_per_coded_sample = avio_rb16(pb); /* sample size */ sc->audio_cid = avio_rb16(pb); avio_rb16(pb); /* packet size = 0 */ st->codec->sample_rate = ((avio_rb32(pb) >> 16)); //Read QT version 1 fields. In version 0 these do not exist. av_dlog(c->fc, "version =%d, isom =%d\n",version,c->isom); if (!c->isom) { if (version==1) { sc->samples_per_frame = avio_rb32(pb); avio_rb32(pb); /* bytes per packet */ sc->bytes_per_frame = avio_rb32(pb); avio_rb32(pb); /* bytes per sample */ } else if (version==2) { avio_rb32(pb); /* sizeof struct only */ st->codec->sample_rate = av_int2double(avio_rb64(pb)); /* float 64 */ st->codec->channels = avio_rb32(pb); avio_rb32(pb); /* always 0x7F000000 */ st->codec->bits_per_coded_sample = avio_rb32(pb); /* bits per channel if sound is uncompressed */ flags = avio_rb32(pb); /* lpcm format specific flag */ sc->bytes_per_frame = avio_rb32(pb); /* bytes per audio packet if constant */ sc->samples_per_frame = avio_rb32(pb); /* lpcm frames per audio packet if constant */ if (format == MKTAG('l','p','c','m')) st->codec->codec_id = ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags); } } switch (st->codec->codec_id) { case CODEC_ID_PCM_S8: case CODEC_ID_PCM_U8: if (st->codec->bits_per_coded_sample == 16) st->codec->codec_id = CODEC_ID_PCM_S16BE; break; case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: if (st->codec->bits_per_coded_sample == 8) st->codec->codec_id = CODEC_ID_PCM_S8; else if (st->codec->bits_per_coded_sample == 24) st->codec->codec_id = st->codec->codec_id == CODEC_ID_PCM_S16BE ? CODEC_ID_PCM_S24BE : CODEC_ID_PCM_S24LE; break; /* set values for old format before stsd version 1 appeared */ case CODEC_ID_MACE3: sc->samples_per_frame = 6; sc->bytes_per_frame = 2*st->codec->channels; break; case CODEC_ID_MACE6: sc->samples_per_frame = 6; sc->bytes_per_frame = 1*st->codec->channels; break; case CODEC_ID_ADPCM_IMA_QT: sc->samples_per_frame = 64; sc->bytes_per_frame = 34*st->codec->channels; break; case CODEC_ID_GSM: sc->samples_per_frame = 160; sc->bytes_per_frame = 33; break; default: break; } bits_per_sample = av_get_bits_per_sample(st->codec->codec_id); if (bits_per_sample) { st->codec->bits_per_coded_sample = bits_per_sample; sc->sample_size = (bits_per_sample >> 3) * st->codec->channels; } } else if (st->codec->codec_type==AVMEDIA_TYPE_SUBTITLE){ // ttxt stsd contains display flags, justification, background // color, fonts, and default styles, so fake an atom to read it MOVAtom fake_atom = { .size = size - (avio_tell(pb) - start_pos) }; if (format != AV_RL32("mp4s")) // mp4s contains a regular esds atom mov_read_glbl(c, pb, fake_atom); st->codec->codec_id= id; st->codec->width = sc->width; st->codec->height = sc->height; } else { if (st->codec->codec_tag == MKTAG('t','m','c','d')) { int val; avio_rb32(pb); /* reserved */ val = avio_rb32(pb); /* flags */ if (val & 1) st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE; avio_rb32(pb); avio_rb32(pb); st->codec->time_base.den = avio_r8(pb); st->codec->time_base.num = 1; } /* other codec type, just skip (rtp, mp4s, ...) */ avio_skip(pb, size - (avio_tell(pb) - start_pos)); } /* this will read extra atoms at the end (wave, alac, damr, avcC, SMI ...) */ a.size = size - (avio_tell(pb) - start_pos); if (a.size > 8) { if (mov_read_default(c, pb, a) < 0) } else if (a.size > 0) avio_skip(pb, a.size); } if (st->codec->codec_type==AVMEDIA_TYPE_AUDIO && st->codec->sample_rate==0 && sc->time_scale>1) st->codec->sample_rate= sc->time_scale; /* special codec parameters handling */ switch (st->codec->codec_id) { #if CONFIG_DV_DEMUXER case CODEC_ID_DVAUDIO: c->dv_fctx = avformat_alloc_context(); c->dv_demux = avpriv_dv_init_demux(c->dv_fctx); if (!c->dv_demux) { av_log(c->fc, AV_LOG_ERROR, "dv demux context init error\n"); } sc->dv_audio_container = 1; st->codec->codec_id = CODEC_ID_PCM_S16LE; break; #endif /* no ifdef since parameters are always those */ case CODEC_ID_QCELP: // force sample rate for qcelp when not stored in mov if (st->codec->codec_tag != MKTAG('Q','c','l','p')) st->codec->sample_rate = 8000; st->codec->frame_size= 160; st->codec->channels= 1; /* really needed */ break; case CODEC_ID_AMR_NB: st->codec->channels= 1; /* really needed */ /* force sample rate for amr, stsd in 3gp does not store sample rate */ st->codec->sample_rate = 8000; /* force frame_size, too, samples_per_frame isn't always set properly */ st->codec->frame_size = 160; break; case CODEC_ID_AMR_WB: st->codec->channels = 1; st->codec->sample_rate = 16000; st->codec->frame_size = 320; break; case CODEC_ID_MP2: case CODEC_ID_MP3: st->codec->codec_type = AVMEDIA_TYPE_AUDIO; /* force type after stsd for m1a hdlr */ st->need_parsing = AVSTREAM_PARSE_FULL; break; case CODEC_ID_GSM: case CODEC_ID_ADPCM_MS: case CODEC_ID_ADPCM_IMA_WAV: st->codec->frame_size = sc->samples_per_frame; st->codec->block_align = sc->bytes_per_frame; break; case CODEC_ID_ALAC: if (st->codec->extradata_size == 36) { st->codec->frame_size = AV_RB32(st->codec->extradata+12); st->codec->channels = AV_RB8 (st->codec->extradata+21); st->codec->sample_rate = AV_RB32(st->codec->extradata+32); } break; case CODEC_ID_AC3: st->need_parsing = AVSTREAM_PARSE_FULL; break; case CODEC_ID_MPEG1VIDEO: st->need_parsing = AVSTREAM_PARSE_FULL; break; default: break; } return 0; }
true
FFmpeg
5f95c130a020ec8f6eb7ade8808f59dac5834410
4,083
static void test_tco_max_timeout(void) { TestData d; const uint16_t ticks = 0xffff; uint32_t val; int ret; d.args = NULL; d.noreboot = true; test_init(&d); stop_tco(&d); clear_tco_status(&d); reset_on_second_timeout(false); set_tco_timeout(&d, ticks); load_tco(&d); start_tco(&d); clock_step(((ticks & TCO_TMR_MASK) - 1) * TCO_TICK_NSEC); val = qpci_io_readw(d.dev, d.tco_io_base + TCO_RLD); g_assert_cmpint(val & TCO_RLD_MASK, ==, 1); val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS); ret = val & TCO_TIMEOUT ? 1 : 0; g_assert(ret == 0); clock_step(TCO_TICK_NSEC); val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS); ret = val & TCO_TIMEOUT ? 1 : 0; g_assert(ret == 1); stop_tco(&d); qtest_end(); }
true
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
4,084
YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE) YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE) YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE) YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE) /* * Write out 2 RGB pixels in the target pixel format. This function takes a * R/G/B LUT as generated by ff_yuv2rgb_c_init_tables(), which takes care of * things like endianness conversion and shifting. The caller takes care of * setting the correct offset in these tables from the chroma (U/V) values. * This function then uses the luminance (Y1/Y2) values to write out the * correct RGB values into the destination buffer. */ static av_always_inline void yuv2rgb_write(uint8_t *_dest, int i, unsigned Y1, unsigned Y2, unsigned A1, unsigned A2, const void *_r, const void *_g, const void *_b, int y, enum PixelFormat target, int hasAlpha) { if (target == PIX_FMT_ARGB || target == PIX_FMT_RGBA || target == PIX_FMT_ABGR || target == PIX_FMT_BGRA) { uint32_t *dest = (uint32_t *) _dest; const uint32_t *r = (const uint32_t *) _r; const uint32_t *g = (const uint32_t *) _g; const uint32_t *b = (const uint32_t *) _b; #if CONFIG_SMALL int sh = hasAlpha ? ((target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24) : 0; dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0); dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0); #else if (hasAlpha) { int sh = (target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24; dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh); dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh); } else { dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1]; dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2]; } #endif } else if (target == PIX_FMT_RGB24 || target == PIX_FMT_BGR24) { uint8_t *dest = (uint8_t *) _dest; const uint8_t *r = (const uint8_t *) _r; const uint8_t *g = (const uint8_t *) _g; const uint8_t *b = (const uint8_t *) _b; #define r_b ((target == PIX_FMT_RGB24) ? r : b) #define b_r ((target == PIX_FMT_RGB24) ? b : r) dest[i * 6 + 0] = r_b[Y1]; dest[i * 6 + 1] = g[Y1]; dest[i * 6 + 2] = b_r[Y1]; dest[i * 6 + 3] = r_b[Y2]; dest[i * 6 + 4] = g[Y2]; dest[i * 6 + 5] = b_r[Y2]; #undef r_b #undef b_r } else if (target == PIX_FMT_RGB565 || target == PIX_FMT_BGR565 || target == PIX_FMT_RGB555 || target == PIX_FMT_BGR555 || target == PIX_FMT_RGB444 || target == PIX_FMT_BGR444) { uint16_t *dest = (uint16_t *) _dest; const uint16_t *r = (const uint16_t *) _r; const uint16_t *g = (const uint16_t *) _g; const uint16_t *b = (const uint16_t *) _b; int dr1, dg1, db1, dr2, dg2, db2; if (target == PIX_FMT_RGB565 || target == PIX_FMT_BGR565) { dr1 = dither_2x2_8[ y & 1 ][0]; dg1 = dither_2x2_4[ y & 1 ][0]; db1 = dither_2x2_8[(y & 1) ^ 1][0]; dr2 = dither_2x2_8[ y & 1 ][1]; dg2 = dither_2x2_4[ y & 1 ][1]; db2 = dither_2x2_8[(y & 1) ^ 1][1]; } else if (target == PIX_FMT_RGB555 || target == PIX_FMT_BGR555) { dr1 = dither_2x2_8[ y & 1 ][0]; dg1 = dither_2x2_8[ y & 1 ][1]; db1 = dither_2x2_8[(y & 1) ^ 1][0]; dr2 = dither_2x2_8[ y & 1 ][1]; dg2 = dither_2x2_8[ y & 1 ][0]; db2 = dither_2x2_8[(y & 1) ^ 1][1]; } else { dr1 = dither_4x4_16[ y & 3 ][0]; dg1 = dither_4x4_16[ y & 3 ][1]; db1 = dither_4x4_16[(y & 3) ^ 3][0]; dr2 = dither_4x4_16[ y & 3 ][1]; dg2 = dither_4x4_16[ y & 3 ][0]; db2 = dither_4x4_16[(y & 3) ^ 3][1]; } dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1]; dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]; } else /* 8/4-bit */ { uint8_t *dest = (uint8_t *) _dest; const uint8_t *r = (const uint8_t *) _r; const uint8_t *g = (const uint8_t *) _g; const uint8_t *b = (const uint8_t *) _b; int dr1, dg1, db1, dr2, dg2, db2; if (target == PIX_FMT_RGB8 || target == PIX_FMT_BGR8) { const uint8_t * const d64 = dither_8x8_73[y & 7]; const uint8_t * const d32 = dither_8x8_32[y & 7]; dr1 = dg1 = d32[(i * 2 + 0) & 7]; db1 = d64[(i * 2 + 0) & 7]; dr2 = dg2 = d32[(i * 2 + 1) & 7]; db2 = d64[(i * 2 + 1) & 7]; } else { const uint8_t * const d64 = dither_8x8_73 [y & 7]; const uint8_t * const d128 = dither_8x8_220[y & 7]; dr1 = db1 = d128[(i * 2 + 0) & 7]; dg1 = d64[(i * 2 + 0) & 7]; dr2 = db2 = d128[(i * 2 + 1) & 7]; dg2 = d64[(i * 2 + 1) & 7]; } if (target == PIX_FMT_RGB4 || target == PIX_FMT_BGR4) { dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] + ((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4); } else { dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1]; dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]; } } }
true
FFmpeg
5ab6f0fe5abf8c5fccede33f7b68c9f3a3864e3a
4,085
int vhost_set_vring_enable(NetClientState *nc, int enable) { VHostNetState *net = get_vhost_net(nc); const VhostOps *vhost_ops; nc->vring_enable = enable; if (!net) { return 0; } vhost_ops = net->dev.vhost_ops; if (vhost_ops->vhost_set_vring_enable) { return vhost_ops->vhost_set_vring_enable(&net->dev, enable); } return 0; }
true
qemu
bb12e761e8e7b5c3c3d77bd08de9f007727a941e
4,086
static int get_channel_idx(char **map, int *ch, char delim, int max_ch) { char *next = split(*map, delim); int len; int n = 0; if (!next && delim == '-') len = strlen(*map); sscanf(*map, "%d%n", ch, &n); if (n != len) if (*ch < 0 || *ch > max_ch) *map = next; return 0; }
true
FFmpeg
579795b2049bc8b0f291b302e7ab24f9561eaf24
4,087
static void piix3_xen_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); dc->desc = "ISA bridge"; dc->vmsd = &vmstate_piix3; dc->no_user = 1; k->no_hotplug = 1; k->init = piix3_initfn; k->config_write = piix3_write_config_xen; k->vendor_id = PCI_VENDOR_ID_INTEL; /* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */ k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0; k->class_id = PCI_CLASS_BRIDGE_ISA; };
true
qemu
efec3dd631d94160288392721a5f9c39e50fb2bc
4,088
qio_channel_websock_source_check(GSource *source) { QIOChannelWebsockSource *wsource = (QIOChannelWebsockSource *)source; GIOCondition cond = 0; if (wsource->wioc->rawinput.offset) { cond |= G_IO_IN; } if (wsource->wioc->rawoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) { cond |= G_IO_OUT; } return cond & wsource->condition; }
true
qemu
eefa3d8ef649f9055611361e2201cca49f8c3433
4,089
static int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { int i; int s; const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); const vector unsigned char permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0}; vector unsigned char perm1 = vec_lvsl(0, pix1); vector unsigned char perm2 = vec_lvsl(0, pix2); vector unsigned char t1, t2, t3,t4, t5; vector unsigned int sad; vector signed int sumdiffs; sad = (vector unsigned int)vec_splat_u32(0); for (i = 0; i < h; i++) { /* Read potentially unaligned pixels into t1 and t2 Since we're reading 16 pixels, and actually only want 8, mask out the last 8 pixels. The 0s don't change the sum. */ vector unsigned char pix1l = vec_ld( 0, pix1); vector unsigned char pix1r = vec_ld(15, pix1); vector unsigned char pix2l = vec_ld( 0, pix2); vector unsigned char pix2r = vec_ld(15, pix2); t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear); t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear); /* Calculate a sum of abs differences vector */ t3 = vec_max(t1, t2); t4 = vec_min(t1, t2); t5 = vec_sub(t3, t4); /* Add each 4 pixel group together and put 4 results into sad */ sad = vec_sum4s(t5, sad); pix1 += line_size; pix2 += line_size; } /* Sum up the four partial sums, and put the result into s */ sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); sumdiffs = vec_splat(sumdiffs, 3); vec_ste(sumdiffs, 0, &s); return s; }
true
FFmpeg
98fdfa99704f1cfef3d3a26c580b92749b6b64cb
4,092
static void move_audio(vorbis_enc_context *venc, float **audio, int *samples, int sf_size) { AVFrame *cur = NULL; int frame_size = 1 << (venc->log2_blocksize[1] - 1); int subframes = frame_size / sf_size; for (int sf = 0; sf < subframes; sf++) { cur = ff_bufqueue_get(&venc->bufqueue); *samples += cur->nb_samples; for (int ch = 0; ch < venc->channels; ch++) { const float *input = (float *) cur->extended_data[ch]; const size_t len = cur->nb_samples * sizeof(float); memcpy(&audio[ch][sf*sf_size], input, len); } av_frame_free(&cur); } }
true
FFmpeg
34c52005605d68f7cd1957b169b6732c7d2447d9
4,094
static void svq3_add_idct_c(uint8_t *dst, int16_t *block, int stride, int qp, int dc) { const int qmul = svq3_dequant_coeff[qp]; int i; if (dc) { dc = 13 * 13 * (dc == 1 ? 1538U* block[0] : qmul * (block[0] >> 3) / 2); block[0] = 0; } for (i = 0; i < 4; i++) { const int z0 = 13 * (block[0 + 4 * i] + block[2 + 4 * i]); const int z1 = 13 * (block[0 + 4 * i] - block[2 + 4 * i]); const int z2 = 7 * block[1 + 4 * i] - 17 * block[3 + 4 * i]; const int z3 = 17 * block[1 + 4 * i] + 7 * block[3 + 4 * i]; block[0 + 4 * i] = z0 + z3; block[1 + 4 * i] = z1 + z2; block[2 + 4 * i] = z1 - z2; block[3 + 4 * i] = z0 - z3; } for (i = 0; i < 4; i++) { const unsigned z0 = 13 * (block[i + 4 * 0] + block[i + 4 * 2]); const unsigned z1 = 13 * (block[i + 4 * 0] - block[i + 4 * 2]); const unsigned z2 = 7 * block[i + 4 * 1] - 17 * block[i + 4 * 3]; const unsigned z3 = 17 * block[i + 4 * 1] + 7 * block[i + 4 * 3]; const int rr = (dc + 0x80000); dst[i + stride * 0] = av_clip_uint8(dst[i + stride * 0] + ((int)((z0 + z3) * qmul + rr) >> 20)); dst[i + stride * 1] = av_clip_uint8(dst[i + stride * 1] + ((int)((z1 + z2) * qmul + rr) >> 20)); dst[i + stride * 2] = av_clip_uint8(dst[i + stride * 2] + ((int)((z1 - z2) * qmul + rr) >> 20)); dst[i + stride * 3] = av_clip_uint8(dst[i + stride * 3] + ((int)((z0 - z3) * qmul + rr) >> 20)); } memset(block, 0, 16 * sizeof(int16_t)); }
true
FFmpeg
2c933c51687db958d8045d25ed87848342e869f6
4,096
static char *vnc_socket_local_addr(const char *format, int fd) { struct sockaddr_storage sa; socklen_t salen; salen = sizeof(sa); if (getsockname(fd, (struct sockaddr*)&sa, &salen) < 0) return NULL; return addr_to_string(format, &sa, salen); }
true
qemu
2f9606b3736c3be4dbd606c46525c7b770ced119
4,097
static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) { /* Primary audio coding side information */ int j, k; if (get_bits_left(&s->gb) < 0) return AVERROR_INVALIDDATA; if (!base_channel) { s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1; s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3); } for (j = base_channel; j < s->prim_channels; j++) { for (k = 0; k < s->subband_activity[j]; k++) s->prediction_mode[j][k] = get_bits(&s->gb, 1); } /* Get prediction codebook */ for (j = base_channel; j < s->prim_channels; j++) { for (k = 0; k < s->subband_activity[j]; k++) { if (s->prediction_mode[j][k] > 0) { /* (Prediction coefficient VQ address) */ s->prediction_vq[j][k] = get_bits(&s->gb, 12); } } } /* Bit allocation index */ for (j = base_channel; j < s->prim_channels; j++) { for (k = 0; k < s->vq_start_subband[j]; k++) { if (s->bitalloc_huffman[j] == 6) s->bitalloc[j][k] = get_bits(&s->gb, 5); else if (s->bitalloc_huffman[j] == 5) s->bitalloc[j][k] = get_bits(&s->gb, 4); else if (s->bitalloc_huffman[j] == 7) { av_log(s->avctx, AV_LOG_ERROR, "Invalid bit allocation index\n"); return AVERROR_INVALIDDATA; } else { s->bitalloc[j][k] = get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]); } if (s->bitalloc[j][k] > 26) { // av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index [%i][%i] too big (%i)\n", // j, k, s->bitalloc[j][k]); return AVERROR_INVALIDDATA; } } } /* Transition mode */ for (j = base_channel; j < s->prim_channels; j++) { for (k = 0; k < s->subband_activity[j]; k++) { s->transition_mode[j][k] = 0; if (s->subsubframes[s->current_subframe] > 1 && k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) { s->transition_mode[j][k] = get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]); } } } if (get_bits_left(&s->gb) < 0) return AVERROR_INVALIDDATA; for (j = base_channel; j < s->prim_channels; j++) { const uint32_t *scale_table; int scale_sum, log_size; memset(s->scale_factor[j], 0, s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2); if (s->scalefactor_huffman[j] == 6) { scale_table = scale_factor_quant7; log_size = 7; } else { scale_table = scale_factor_quant6; log_size = 6; } /* When huffman coded, only the difference is encoded */ scale_sum = 0; for (k = 0; k < s->subband_activity[j]; k++) { if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) { scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum, log_size); s->scale_factor[j][k][0] = scale_table[scale_sum]; } if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) { /* Get second scale factor */ scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum, log_size); s->scale_factor[j][k][1] = scale_table[scale_sum]; } } } /* Joint subband scale factor codebook select */ for (j = base_channel; j < s->prim_channels; j++) { /* Transmitted only if joint subband coding enabled */ if (s->joint_intensity[j] > 0) s->joint_huff[j] = get_bits(&s->gb, 3); } if (get_bits_left(&s->gb) < 0) return AVERROR_INVALIDDATA; /* Scale factors for joint subband coding */ for (j = base_channel; j < s->prim_channels; j++) { int source_channel; /* Transmitted only if joint subband coding enabled */ if (s->joint_intensity[j] > 0) { int scale = 0; source_channel = s->joint_intensity[j] - 1; /* When huffman coded, only the difference is encoded * (is this valid as well for joint scales ???) */ for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) { scale = get_scale(&s->gb, s->joint_huff[j], 64 /* bias */, 7); s->joint_scale_factor[j][k] = scale; /*joint_scale_table[scale]; */ } if (!(s->debug_flag & 0x02)) { av_log(s->avctx, AV_LOG_DEBUG, "Joint stereo coding not supported\n"); s->debug_flag |= 0x02; } } } /* Stereo downmix coefficients */ if (!base_channel && s->prim_channels > 2) { if (s->downmix) { for (j = base_channel; j < s->prim_channels; j++) { s->downmix_coef[j][0] = get_bits(&s->gb, 7); s->downmix_coef[j][1] = get_bits(&s->gb, 7); } } else { int am = s->amode & DCA_CHANNEL_MASK; if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid channel mode %d\n", am); return AVERROR_INVALIDDATA; } for (j = base_channel; j < s->prim_channels; j++) { s->downmix_coef[j][0] = dca_default_coeffs[am][j][0]; s->downmix_coef[j][1] = dca_default_coeffs[am][j][1]; } } } /* Dynamic range coefficient */ if (!base_channel && s->dynrange) s->dynrange_coef = get_bits(&s->gb, 8); /* Side information CRC check word */ if (s->crc_present) { get_bits(&s->gb, 16); } /* * Primary audio data arrays */ /* VQ encoded high frequency subbands */ for (j = base_channel; j < s->prim_channels; j++) for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++) /* 1 vector -> 32 samples */ s->high_freq_vq[j][k] = get_bits(&s->gb, 10); /* Low frequency effect data */ if (!base_channel && s->lfe) { int quant7; /* LFE samples */ int lfe_samples = 2 * s->lfe * (4 + block_index); int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]); float lfe_scale; for (j = lfe_samples; j < lfe_end_sample; j++) { /* Signed 8 bits int */ s->lfe_data[j] = get_sbits(&s->gb, 8); } /* Scale factor index */ quant7 = get_bits(&s->gb, 8); if (quant7 > 127) { av_log_ask_for_sample(s->avctx, "LFEScaleIndex larger than 127\n"); return AVERROR_INVALIDDATA; } s->lfe_scale_factor = scale_factor_quant7[quant7]; /* Quantization step size * scale factor */ lfe_scale = 0.035 * s->lfe_scale_factor; for (j = lfe_samples; j < lfe_end_sample; j++) s->lfe_data[j] *= lfe_scale; } #ifdef TRACE av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", s->subsubframes[s->current_subframe]); av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n", s->partial_samples[s->current_subframe]); for (j = base_channel; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:"); for (k = 0; k < s->subband_activity[j]; k++) av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]); av_log(s->avctx, AV_LOG_DEBUG, "\n"); } for (j = base_channel; j < s->prim_channels; j++) { for (k = 0; k < s->subband_activity[j]; k++) av_log(s->avctx, AV_LOG_DEBUG, "prediction coefs: %f, %f, %f, %f\n", (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192, (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192, (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192, (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192); } for (j = base_channel; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: "); for (k = 0; k < s->vq_start_subband[j]; k++) av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]); av_log(s->avctx, AV_LOG_DEBUG, "\n"); } for (j = base_channel; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:"); for (k = 0; k < s->subband_activity[j]; k++) av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]); av_log(s->avctx, AV_LOG_DEBUG, "\n"); } for (j = base_channel; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:"); for (k = 0; k < s->subband_activity[j]; k++) { if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) av_log(s->avctx, AV_LOG_DEBUG, " %i", s->scale_factor[j][k][0]); if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) av_log(s->avctx, AV_LOG_DEBUG, " %i(t)", s->scale_factor[j][k][1]); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } for (j = base_channel; j < s->prim_channels; j++) { if (s->joint_intensity[j] > 0) { int source_channel = s->joint_intensity[j] - 1; av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n"); for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) av_log(s->avctx, AV_LOG_DEBUG, " %i", s->joint_scale_factor[j][k]); av_log(s->avctx, AV_LOG_DEBUG, "\n"); } } if (!base_channel && s->prim_channels > 2 && s->downmix) { av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n"); for (j = 0; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][0]]); av_log(s->avctx, AV_LOG_DEBUG, "Channel 1, %d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][1]]); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } for (j = base_channel; j < s->prim_channels; j++) for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++) av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\n", s->high_freq_vq[j][k]); if (!base_channel && s->lfe) { int lfe_samples = 2 * s->lfe * (4 + block_index); int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]); av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\n"); for (j = lfe_samples; j < lfe_end_sample; j++) av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]); av_log(s->avctx, AV_LOG_DEBUG, "\n"); } #endif return 0; }
true
FFmpeg
8e77c3846e91b1af9df4084736257d9899156eef
4,098
static void gen_neon_dup_u8(TCGv var, int shift) { TCGv tmp = new_tmp(); if (shift) tcg_gen_shri_i32(var, var, shift); tcg_gen_ext8u_i32(var, var); tcg_gen_shli_i32(tmp, var, 8); tcg_gen_or_i32(var, var, tmp); tcg_gen_shli_i32(tmp, var, 16); tcg_gen_or_i32(var, var, tmp); dead_tmp(tmp); }
true
qemu
7d1b0095bff7157e856d1d0e6c4295641ced2752
4,099
static target_ulong helper_udiv_common(CPUSPARCState *env, target_ulong a, target_ulong b, int cc) { SPARCCPU *cpu = sparc_env_get_cpu(env); int overflow = 0; uint64_t x0; uint32_t x1; x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32); x1 = (b & 0xffffffff); if (x1 == 0) { cpu_restore_state(CPU(cpu), GETPC()); helper_raise_exception(env, TT_DIV_ZERO); } x0 = x0 / x1; if (x0 > 0xffffffff) { x0 = 0xffffffff; overflow = 1; } if (cc) { env->cc_dst = x0; env->cc_src2 = overflow; env->cc_op = CC_OP_DIV; } return x0; }
true
qemu
6a5b69a959483c7404576a7dc54221ced41e6515
4,100
static BlockStats *bdrv_query_stats(const BlockDriverState *bs, bool query_backing) { BlockStats *s; s = g_malloc0(sizeof(*s)); if (bdrv_get_device_name(bs)[0]) { s->has_device = true; s->device = g_strdup(bdrv_get_device_name(bs)); } if (bdrv_get_node_name(bs)[0]) { s->has_node_name = true; s->node_name = g_strdup(bdrv_get_node_name(bs)); } s->stats = g_malloc0(sizeof(*s->stats)); if (bs->blk) { BlockAcctStats *stats = blk_get_stats(bs->blk); s->stats->rd_bytes = stats->nr_bytes[BLOCK_ACCT_READ]; s->stats->wr_bytes = stats->nr_bytes[BLOCK_ACCT_WRITE]; s->stats->rd_operations = stats->nr_ops[BLOCK_ACCT_READ]; s->stats->wr_operations = stats->nr_ops[BLOCK_ACCT_WRITE]; s->stats->failed_rd_operations = stats->failed_ops[BLOCK_ACCT_READ]; s->stats->failed_wr_operations = stats->failed_ops[BLOCK_ACCT_WRITE]; s->stats->failed_flush_operations = stats->failed_ops[BLOCK_ACCT_FLUSH]; s->stats->invalid_rd_operations = stats->invalid_ops[BLOCK_ACCT_READ]; s->stats->invalid_wr_operations = stats->invalid_ops[BLOCK_ACCT_WRITE]; s->stats->invalid_flush_operations = stats->invalid_ops[BLOCK_ACCT_FLUSH]; s->stats->rd_merged = stats->merged[BLOCK_ACCT_READ]; s->stats->wr_merged = stats->merged[BLOCK_ACCT_WRITE]; s->stats->flush_operations = stats->nr_ops[BLOCK_ACCT_FLUSH]; s->stats->wr_total_time_ns = stats->total_time_ns[BLOCK_ACCT_WRITE]; s->stats->rd_total_time_ns = stats->total_time_ns[BLOCK_ACCT_READ]; s->stats->flush_total_time_ns = stats->total_time_ns[BLOCK_ACCT_FLUSH]; s->stats->has_idle_time_ns = stats->last_access_time_ns > 0; if (s->stats->has_idle_time_ns) { s->stats->idle_time_ns = block_acct_idle_time_ns(stats); } } s->stats->wr_highest_offset = bs->wr_highest_offset; if (bs->file) { s->has_parent = true; s->parent = bdrv_query_stats(bs->file->bs, query_backing); } if (query_backing && bs->backing) { s->has_backing = true; s->backing = bdrv_query_stats(bs->backing->bs, query_backing); } return s; }
true
qemu
362e9299b34b3101aaa20f20363441c9f055fa5e
4,101
static uint64_t hb_regs_read(void *opaque, hwaddr offset, unsigned size) { uint32_t *regs = opaque; uint32_t value = regs[offset/4]; if ((offset == 0x100) || (offset == 0x108) || (offset == 0x10C)) { value |= 0x30000000; } return value; }
false
qemu
c5c752af8cddad3e4e51acef40a46db998638144
4,103
static unsigned acpi_data_len(GArray *table) { #if GLIB_CHECK_VERSION(2, 14, 0) assert(g_array_get_element_size(table) == 1); #endif return table->len; }
false
qemu
134d42d614768b2803e551621f6654dab1fdc2d2
4,105
static void init_excp_970 (CPUPPCState *env) { #if !defined(CONFIG_USER_ONLY) env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; env->excp_vectors[POWERPC_EXCP_DSEG] = 0x00000380; env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; env->excp_vectors[POWERPC_EXCP_ISEG] = 0x00000480; env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; #if defined(TARGET_PPC64H) /* PowerPC 64 with hypervisor mode support */ env->excp_vectors[POWERPC_EXCP_HDECR] = 0x00000980; #endif env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; env->excp_vectors[POWERPC_EXCP_VPU] = 0x00000F20; env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; env->excp_vectors[POWERPC_EXCP_MAINT] = 0x00001600; env->excp_vectors[POWERPC_EXCP_VPUA] = 0x00001700; env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001800; env->excp_prefix = 0x00000000FFF00000ULL; /* Hardware reset vector */ env->hreset_vector = 0x0000000000000100ULL; #endif }
false
qemu
b172c56a6d849554f7e43adc95983a9d6c042689
4,106
static int proxy_ioc_getversion(FsContext *fs_ctx, V9fsPath *path, mode_t st_mode, uint64_t *st_gen) { int err; /* Do not try to open special files like device nodes, fifos etc * we can get fd for regular files and directories only */ if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) { errno = ENOTTY; return -1; } err = v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, "s", path); if (err < 0) { errno = -err; err = -1; } return err; }
false
qemu
494a8ebe713055d3946183f4b395f85a18b43e9e
4,107
void vga_common_init(VGACommonState *s) { int i, j, v, b; for(i = 0;i < 256; i++) { v = 0; for(j = 0; j < 8; j++) { v |= ((i >> j) & 1) << (j * 4); } expand4[i] = v; v = 0; for(j = 0; j < 4; j++) { v |= ((i >> (2 * j)) & 3) << (j * 4); } expand2[i] = v; } for(i = 0; i < 16; i++) { v = 0; for(j = 0; j < 4; j++) { b = ((i >> j) & 1); v |= b << (2 * j); v |= b << (2 * j + 1); } expand4to8[i] = v; } /* valid range: 1 MB -> 256 MB */ s->vram_size = 1024 * 1024; while (s->vram_size < (s->vram_size_mb << 20) && s->vram_size < (256 << 20)) { s->vram_size <<= 1; } s->vram_size_mb = s->vram_size >> 20; s->is_vbe_vmstate = 1; memory_region_init_ram(&s->vram, "vga.vram", s->vram_size); vmstate_register_ram_global(&s->vram); xen_register_framebuffer(&s->vram); s->vram_ptr = memory_region_get_ram_ptr(&s->vram); s->get_bpp = vga_get_bpp; s->get_offsets = vga_get_offsets; s->get_resolution = vga_get_resolution; s->update = vga_update_display; s->invalidate = vga_invalidate_display; s->screen_dump = vga_screen_dump; s->text_update = vga_update_text; switch (vga_retrace_method) { case VGA_RETRACE_DUMB: s->retrace = vga_dumb_retrace; s->update_retrace_info = vga_dumb_update_retrace_info; break; case VGA_RETRACE_PRECISE: s->retrace = vga_precise_retrace; s->update_retrace_info = vga_precise_update_retrace_info; break; } vga_dirty_log_start(s); }
false
qemu
2c62f08ddbf3fa80dc7202eb9a2ea60ae44e2cc5
4,108
static uint32_t do_mac_read(lan9118_state *s, int reg) { switch (reg) { case MAC_CR: return s->mac_cr; case MAC_ADDRH: return s->conf.macaddr.a[4] | (s->conf.macaddr.a[5] << 8); case MAC_ADDRL: return s->conf.macaddr.a[0] | (s->conf.macaddr.a[1] << 8) | (s->conf.macaddr.a[2] << 16) | (s->conf.macaddr.a[3] << 24); case MAC_HASHH: return s->mac_hashh; break; case MAC_HASHL: return s->mac_hashl; break; case MAC_MII_ACC: return s->mac_mii_acc; case MAC_MII_DATA: return s->mac_mii_data; case MAC_FLOW: return s->mac_flow; default: hw_error("lan9118: Unimplemented MAC register read: %d\n", s->mac_cmd & 0xf); } }
false
qemu
52b4bb7383b32e4e7512f98c57738c8fc9cb35ba
4,109
void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp) { int64_t value; if (v->type_uint32) { v->type_uint32(v, obj, name, errp); } else { value = *obj; v->type_int64(v, &value, name, errp); if (value < 0 || value > UINT32_MAX) { /* FIXME questionable reuse of errp if callback changed value on error */ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null", "uint32_t"); return; } *obj = value; } }
false
qemu
f755dea79dc81b0d6a8f6414e0672e165e28d8ba
4,110
static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){ AVFormatContext *s= nut->avf; ByteIOContext *bc = &s->pb; int size, stream_id, flags, discard; int64_t pts, last_IP_pts; size= decode_frame_header(nut, &flags, &pts, &stream_id, frame_code); if(size < 0) return -1; if (flags & FLAG_KEY) nut->stream[stream_id].skip_until_key_frame=0; discard= s->streams[ stream_id ]->discard; last_IP_pts= s->streams[ stream_id ]->last_IP_pts; if( (discard >= AVDISCARD_NONKEY && !(flags & FLAG_KEY)) ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts) || discard >= AVDISCARD_ALL || nut->stream[stream_id].skip_until_key_frame){ url_fskip(bc, size); return 1; } av_get_packet(bc, pkt, size); pkt->stream_index = stream_id; if (flags & FLAG_KEY) pkt->flags |= PKT_FLAG_KEY; pkt->pts = pts; return 0; }
false
FFmpeg
06599638dd678c9939df0fd83ff693c43b25971d
4,113
static void bdrv_assign_node_name(BlockDriverState *bs, const char *node_name, Error **errp) { if (!node_name) { return; } /* empty string node name is invalid */ if (node_name[0] == '\0') { error_setg(errp, "Empty node name"); return; } /* takes care of avoiding namespaces collisions */ if (bdrv_find(node_name)) { error_setg(errp, "node-name=%s is conflicting with a device id", node_name); return; } /* takes care of avoiding duplicates node names */ if (bdrv_find_node(node_name)) { error_setg(errp, "Duplicate node name"); return; } /* copy node name into the bs and insert it into the graph list */ pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); }
false
qemu
9aebf3b89281a173d2dfeee379b800be5e3f363e
4,114
int bdrv_can_snapshot(BlockDriverState *bs) { BlockDriver *drv = bs->drv; if (!drv || bdrv_is_removable(bs) || bdrv_is_read_only(bs)) { return 0; } if (!drv->bdrv_snapshot_create) { if (bs->file != NULL) { return bdrv_can_snapshot(bs->file); } return 0; } return 1; }
false
qemu
07b70bfbb3f3aea9ce7a3a1da78cbfa8ae6bbce6
4,115
int float32_le_quiet( float32 a, float32 b STATUS_PARAM ) { flag aSign, bSign; if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) ) || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) ) ) { if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) { float_raise( float_flag_invalid STATUS_VAR); } return 0; } aSign = extractFloat32Sign( a ); bSign = extractFloat32Sign( b ); if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 ); return ( a == b ) || ( aSign ^ ( a < b ) ); }
false
qemu
f090c9d4ad5812fb92843d6470a1111c15190c4c
4,116
static AioContext *block_job_get_aio_context(BlockJob *job) { return job->deferred_to_main_loop ? qemu_get_aio_context() : blk_get_aio_context(job->blk); }
false
qemu
bae8196d9f97916de6323e70e3e374362ee16ec4
4,117
static int gen_jz_ecx_string(DisasContext *s, target_ulong next_eip) { int l1, l2; l1 = gen_new_label(); l2 = gen_new_label(); gen_op_jnz_ecx[s->aflag](l1); gen_set_label(l2); gen_jmp_tb(s, next_eip, 1); gen_set_label(l1); return l2; }
false
qemu
6e0d8677cb443e7408c0b7a25a93c6596d7fa380
4,119
const char *qjson_get_str(QJSON *json) { return qstring_get_str(json->str); }
false
qemu
17b74b98676aee5bc470b173b1e528d2fce2cf18
4,120
void arm_v7m_cpu_do_interrupt(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; uint32_t lr; arm_log_exception(cs->exception_index); /* For exceptions we just mark as pending on the NVIC, and let that handle it. */ switch (cs->exception_index) { case EXCP_UDEF: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK; break; case EXCP_NOCP: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK; break; case EXCP_INVSTATE: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK; break; case EXCP_SWI: /* The PC already points to the next instruction. */ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC); break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: /* Note that for M profile we don't have a guest facing FSR, but * the env->exception.fsr will be populated by the code that * raises the fault, in the A profile short-descriptor format. */ switch (env->exception.fsr & 0xf) { case 0x8: /* External Abort */ switch (cs->exception_index) { case EXCP_PREFETCH_ABORT: env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK; qemu_log_mask(CPU_LOG_INT, "...with CFSR.IBUSERR\n"); break; case EXCP_DATA_ABORT: env->v7m.cfsr[M_REG_NS] |= (R_V7M_CFSR_PRECISERR_MASK | R_V7M_CFSR_BFARVALID_MASK); env->v7m.bfar = env->exception.vaddress; qemu_log_mask(CPU_LOG_INT, "...with CFSR.PRECISERR and BFAR 0x%x\n", env->v7m.bfar); break; } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS); break; default: /* All other FSR values are either MPU faults or "can't happen * for M profile" cases. */ switch (cs->exception_index) { case EXCP_PREFETCH_ABORT: env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK; qemu_log_mask(CPU_LOG_INT, "...with CFSR.IACCVIOL\n"); break; case EXCP_DATA_ABORT: env->v7m.cfsr[env->v7m.secure] |= (R_V7M_CFSR_DACCVIOL_MASK | R_V7M_CFSR_MMARVALID_MASK); env->v7m.mmfar[env->v7m.secure] = env->exception.vaddress; qemu_log_mask(CPU_LOG_INT, "...with CFSR.DACCVIOL and MMFAR 0x%x\n", env->v7m.mmfar[env->v7m.secure]); break; } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM); break; } break; case EXCP_BKPT: if (semihosting_enabled()) { int nr; nr = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff; if (nr == 0xab) { env->regs[15] += 2; qemu_log_mask(CPU_LOG_INT, "...handling as semihosting call 0x%x\n", env->regs[0]); env->regs[0] = do_arm_semihosting(env); return; } } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG); break; case EXCP_IRQ: break; case EXCP_EXCEPTION_EXIT: do_v7m_exception_exit(cpu); return; default: cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); return; /* Never happens. Keep compiler happy. */ } lr = 0xfffffff1; if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) { lr |= 4; } if (!arm_v7m_is_handler_mode(env)) { lr |= 8; } v7m_push_stack(cpu); v7m_exception_taken(cpu, lr); qemu_log_mask(CPU_LOG_INT, "... as %d\n", env->v7m.exception); }
false
qemu
4d1e7a4745c050f7ccac49a1c01437526b5130b5
4,122
static av_cold int find_component(OMXContext *omx_context, void *logctx, const char *role, char *str, int str_size) { OMX_U32 i, num = 0; char **components; int ret = 0; #if CONFIG_OMX_RPI if (av_strstart(role, "video_encoder.", NULL)) { av_strlcpy(str, "OMX.broadcom.video_encode", str_size); return 0; } #endif omx_context->ptr_GetComponentsOfRole((OMX_STRING) role, &num, NULL); if (!num) { av_log(logctx, AV_LOG_WARNING, "No component for role %s found\n", role); return AVERROR_ENCODER_NOT_FOUND; } components = av_mallocz(sizeof(char*) * num); if (!components) return AVERROR(ENOMEM); for (i = 0; i < num; i++) { components[i] = av_mallocz(OMX_MAX_STRINGNAME_SIZE); if (!components) { ret = AVERROR(ENOMEM); goto end; } } omx_context->ptr_GetComponentsOfRole((OMX_STRING) role, &num, (OMX_U8**) components); av_strlcpy(str, components[0], str_size); end: for (i = 0; i < num; i++) av_free(components[i]); av_free(components); return ret; }
false
FFmpeg
16a75304fe42d3a007c78126b6370c94ccf891f6
4,123
set_mdic(E1000State *s, int index, uint32_t val) { uint32_t data = val & E1000_MDIC_DATA_MASK; uint32_t addr = ((val & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT); if ((val & E1000_MDIC_PHY_MASK) >> E1000_MDIC_PHY_SHIFT != 1) // phy # val = s->mac_reg[MDIC] | E1000_MDIC_ERROR; else if (val & E1000_MDIC_OP_READ) { DBGOUT(MDIC, "MDIC read reg 0x%x\n", addr); if (!(phy_regcap[addr] & PHY_R)) { DBGOUT(MDIC, "MDIC read reg %x unhandled\n", addr); val |= E1000_MDIC_ERROR; } else val = (val ^ data) | s->phy_reg[addr]; } else if (val & E1000_MDIC_OP_WRITE) { DBGOUT(MDIC, "MDIC write reg 0x%x, value 0x%x\n", addr, data); if (!(phy_regcap[addr] & PHY_W)) { DBGOUT(MDIC, "MDIC write reg %x unhandled\n", addr); val |= E1000_MDIC_ERROR; } else { if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) { phyreg_writeops[addr](s, index, data); } s->phy_reg[addr] = data; } } s->mac_reg[MDIC] = val | E1000_MDIC_READY; if (val & E1000_MDIC_INT_EN) { set_ics(s, 0, E1000_ICR_MDAC); } }
false
qemu
1195fed9e6790bd8fd86b0dc33e2442d70355ac6
4,124
void phys_mem_set_alloc(void *(*alloc)(size_t)) { phys_mem_alloc = alloc; }
false
qemu
a2b257d6212ade772473f86bf0637480b2578a7e
4,126
VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) { V9fsState *s; int i, len; struct stat stat; FsTypeEntry *fse; s = (V9fsState *)virtio_common_init("virtio-9p", VIRTIO_ID_9P, sizeof(struct virtio_9p_config)+ MAX_TAG_LEN, sizeof(V9fsState)); /* initialize pdu allocator */ QLIST_INIT(&s->free_list); for (i = 0; i < (MAX_REQ - 1); i++) { QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next); } s->vq = virtio_add_queue(&s->vdev, MAX_REQ, handle_9p_output); fse = get_fsdev_fsentry(conf->fsdev_id); if (!fse) { /* We don't have a fsdev identified by fsdev_id */ fprintf(stderr, "Virtio-9p device couldn't find fsdev " "with the id %s\n", conf->fsdev_id); exit(1); } if (!fse->path || !conf->tag) { /* we haven't specified a mount_tag or the path */ fprintf(stderr, "fsdev with id %s needs path " "and Virtio-9p device needs mount_tag arguments\n", conf->fsdev_id); exit(1); } if (!strcmp(fse->security_model, "passthrough")) { /* Files on the Fileserver set to client user credentials */ s->ctx.fs_sm = SM_PASSTHROUGH; } else if (!strcmp(fse->security_model, "mapped")) { /* Files on the fileserver are set to QEMU credentials. * Client user credentials are saved in extended attributes. */ s->ctx.fs_sm = SM_MAPPED; } else if (!strcmp(fse->security_model, "none")) { /* * Files on the fileserver are set to QEMU credentials. */ s->ctx.fs_sm = SM_NONE; } else { fprintf(stderr, "Default to security_model=none. You may want" " enable advanced security model using " "security option:\n\t security_model=passthrough \n\t " "security_model=mapped\n"); s->ctx.fs_sm = SM_NONE; } if (lstat(fse->path, &stat)) { fprintf(stderr, "share path %s does not exist\n", fse->path); exit(1); } else if (!S_ISDIR(stat.st_mode)) { fprintf(stderr, "share path %s is not a directory \n", fse->path); exit(1); } s->ctx.fs_root = qemu_strdup(fse->path); len = strlen(conf->tag); if (len > MAX_TAG_LEN) { len = MAX_TAG_LEN; } /* s->tag is non-NULL terminated string */ s->tag = qemu_malloc(len); memcpy(s->tag, conf->tag, len); s->tag_len = len; s->ctx.uid = -1; s->ops = fse->ops; s->vdev.get_features = virtio_9p_get_features; s->config_size = sizeof(struct virtio_9p_config) + s->tag_len; s->vdev.get_config = virtio_9p_get_config; return &s->vdev; }
false
qemu
fc22118d9bb56ec71655b936a29513c140e6c289
4,127
static void coroutine_fn aio_read_response(void *opaque) { SheepdogObjRsp rsp; BDRVSheepdogState *s = opaque; int fd = s->fd; int ret; AIOReq *aio_req = NULL; SheepdogAIOCB *acb; uint64_t idx; if (QLIST_EMPTY(&s->inflight_aio_head)) { goto out; } /* read a header */ ret = qemu_co_recv(fd, &rsp, sizeof(rsp)); if (ret < 0) { error_report("failed to get the header, %s", strerror(errno)); goto out; } /* find the right aio_req from the inflight aio list */ QLIST_FOREACH(aio_req, &s->inflight_aio_head, aio_siblings) { if (aio_req->id == rsp.id) { break; } } if (!aio_req) { error_report("cannot find aio_req %x", rsp.id); goto out; } acb = aio_req->aiocb; switch (acb->aiocb_type) { case AIOCB_WRITE_UDATA: /* this coroutine context is no longer suitable for co_recv * because we may send data to update vdi objects */ s->co_recv = NULL; if (!is_data_obj(aio_req->oid)) { break; } idx = data_oid_to_idx(aio_req->oid); if (s->inode.data_vdi_id[idx] != s->inode.vdi_id) { /* * If the object is newly created one, we need to update * the vdi object (metadata object). min_dirty_data_idx * and max_dirty_data_idx are changed to include updated * index between them. */ if (rsp.result == SD_RES_SUCCESS) { s->inode.data_vdi_id[idx] = s->inode.vdi_id; s->max_dirty_data_idx = MAX(idx, s->max_dirty_data_idx); s->min_dirty_data_idx = MIN(idx, s->min_dirty_data_idx); } /* * Some requests may be blocked because simultaneous * create requests are not allowed, so we search the * pending requests here. */ send_pending_req(s, aio_req->oid); } break; case AIOCB_READ_UDATA: ret = qemu_co_recvv(fd, acb->qiov->iov, acb->qiov->niov, aio_req->iov_offset, rsp.data_length); if (ret < 0) { error_report("failed to get the data, %s", strerror(errno)); goto out; } break; case AIOCB_FLUSH_CACHE: if (rsp.result == SD_RES_INVALID_PARMS) { DPRINTF("disable cache since the server doesn't support it\n"); s->cache_flags = SD_FLAG_CMD_DIRECT; rsp.result = SD_RES_SUCCESS; } break; case AIOCB_DISCARD_OBJ: switch (rsp.result) { case SD_RES_INVALID_PARMS: error_report("sheep(%s) doesn't support discard command", s->host_spec); rsp.result = SD_RES_SUCCESS; s->discard_supported = false; break; case SD_RES_SUCCESS: idx = data_oid_to_idx(aio_req->oid); s->inode.data_vdi_id[idx] = 0; break; default: break; } } switch (rsp.result) { case SD_RES_SUCCESS: break; case SD_RES_READONLY: ret = resend_aioreq(s, aio_req); if (ret == SD_RES_SUCCESS) { goto out; } /* fall through */ default: acb->ret = -EIO; error_report("%s", sd_strerror(rsp.result)); break; } free_aio_req(s, aio_req); if (!acb->nr_pending) { /* * We've finished all requests which belong to the AIOCB, so * we can switch back to sd_co_readv/writev now. */ acb->aio_done_func(acb); } out: s->co_recv = NULL; }
false
qemu
80731d9da560461bbdcda5ad4b05f4a8a846fccd
4,128
static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, uint32_t *ext_features, uint32_t *ext2_features, uint32_t *ext3_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; } if (!found) { fprintf(stderr, "CPU feature %s not found\n", flagname); } }
false
qemu
6d2edc43731d0e804c1c846db1e07bddfb158ebd
4,129
static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, const char *replaces, int64_t speed, uint32_t granularity, int64_t buf_size, BlockdevOnError on_source_error, BlockdevOnError on_target_error, bool unmap, BlockCompletionFunc *cb, void *opaque, Error **errp, const BlockJobDriver *driver, bool is_none_mode, BlockDriverState *base) { MirrorBlockJob *s; BlockDriverState *replaced_bs; if (granularity == 0) { granularity = bdrv_get_default_bitmap_granularity(target); } assert ((granularity & (granularity - 1)) == 0); if (buf_size < 0) { error_setg(errp, "Invalid parameter 'buf-size'"); return; } if (buf_size == 0) { buf_size = DEFAULT_MIRROR_BUF_SIZE; } /* We can't support this case as long as the block layer can't handle * multiple BlockBackends per BlockDriverState. */ if (replaces) { replaced_bs = bdrv_lookup_bs(replaces, replaces, errp); if (replaced_bs == NULL) { return; } } else { replaced_bs = bs; } if (replaced_bs->blk && target->blk) { error_setg(errp, "Can't create node with two BlockBackends"); return; } s = block_job_create(driver, bs, speed, cb, opaque, errp); if (!s) { return; } s->replaces = g_strdup(replaces); s->on_source_error = on_source_error; s->on_target_error = on_target_error; s->target = target; s->is_none_mode = is_none_mode; s->base = base; s->granularity = granularity; s->buf_size = ROUND_UP(buf_size, granularity); s->unmap = unmap; s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp); if (!s->dirty_bitmap) { g_free(s->replaces); block_job_unref(&s->common); return; } bdrv_op_block_all(s->target, s->common.blocker); s->common.co = qemu_coroutine_create(mirror_run); trace_mirror_start(bs, s, s->common.co, opaque); qemu_coroutine_enter(s->common.co, s); }
false
qemu
1f0c461b82d5ec2664ca0cfc9548f80da87a8f8a
4,130
DisplaySurface *qemu_create_displaysurface_from(int width, int height, int bpp, int linesize, uint8_t *data) { DisplaySurface *surface = g_new0(DisplaySurface, 1); surface->pf = qemu_default_pixelformat(bpp); surface->format = qemu_pixman_get_format(&surface->pf); assert(surface->format != 0); surface->image = pixman_image_create_bits(surface->format, width, height, (void *)data, linesize); assert(surface->image != NULL); #ifdef HOST_WORDS_BIGENDIAN surface->flags = QEMU_BIG_ENDIAN_FLAG; #endif return surface; }
false
qemu
b1424e0381a7f1c9969079eca4458d5f20bf1859
4,131
static void spapr_phb_reset(DeviceState *qdev) { SysBusDevice *s = SYS_BUS_DEVICE(qdev); sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(s); /* Reset the IOMMU state */ spapr_tce_reset(sphb->tcet); }
false
qemu
a83000f5e3fac30a7f213af1ba6a8f827622854d
4,132
static int64_t coroutine_fn vvfat_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int* n) { BDRVVVFATState* s = bs->opaque; *n = s->sector_count - sector_num; if (*n > nb_sectors) { *n = nb_sectors; } else if (*n < 0) { return 0; } return BDRV_BLOCK_DATA; }
false
qemu
67a0fd2a9bca204d2b39f910a97c7137636a0715
4,133
static av_cold int nvenc_check_cuda(AVCodecContext *avctx) { int device_count = 0; CUdevice cu_device = 0; char gpu_name[128]; int smminor = 0, smmajor = 0; int i, smver, target_smver; NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; switch (avctx->codec->id) { case AV_CODEC_ID_H264: target_smver = ctx->data_pix_fmt == AV_PIX_FMT_YUV444P ? 0x52 : 0x30; break; case AV_CODEC_ID_H265: target_smver = 0x52; break; default: av_log(avctx, AV_LOG_FATAL, "Unknown codec name\n"); goto error; } if (ctx->preset >= PRESET_LOSSLESS_DEFAULT) target_smver = 0x52; if (!nvenc_dyload_cuda(avctx)) return 0; if (dl_fn->nvenc_device_count > 0) return 1; check_cuda_errors(dl_fn->cu_init(0)); check_cuda_errors(dl_fn->cu_device_get_count(&device_count)); if (!device_count) { av_log(avctx, AV_LOG_FATAL, "No CUDA capable devices found\n"); goto error; } av_log(avctx, AV_LOG_VERBOSE, "%d CUDA capable devices found\n", device_count); dl_fn->nvenc_device_count = 0; for (i = 0; i < device_count; ++i) { check_cuda_errors(dl_fn->cu_device_get(&cu_device, i)); check_cuda_errors(dl_fn->cu_device_get_name(gpu_name, sizeof(gpu_name), cu_device)); check_cuda_errors(dl_fn->cu_device_compute_capability(&smmajor, &smminor, cu_device)); smver = (smmajor << 4) | smminor; av_log(avctx, AV_LOG_VERBOSE, "[ GPU #%d - < %s > has Compute SM %d.%d, NVENC %s ]\n", i, gpu_name, smmajor, smminor, (smver >= target_smver) ? "Available" : "Not Available"); if (smver >= target_smver) dl_fn->nvenc_devices[dl_fn->nvenc_device_count++] = cu_device; } if (!dl_fn->nvenc_device_count) { av_log(avctx, AV_LOG_FATAL, "No NVENC capable devices found\n"); goto error; } return 1; error: dl_fn->nvenc_device_count = 0; return 0; }
false
FFmpeg
0d021cc8b30a6f81c27fbeca7f99f1ee7a20acf8
4,134
static void gic_dist_writeb(void *opaque, hwaddr offset, uint32_t value, MemTxAttrs attrs) { GICState *s = (GICState *)opaque; int irq; int i; int cpu; cpu = gic_get_current_cpu(s); if (offset < 0x100) { if (offset == 0) { s->enabled = (value & 1); DPRINTF("Distribution %sabled\n", s->enabled ? "En" : "Dis"); } else if (offset < 4) { /* ignored. */ } else if (offset >= 0x80) { /* Interrupt Security Registers, RAZ/WI */ } else { goto bad_reg; } } else if (offset < 0x180) { /* Interrupt Set Enable. */ irq = (offset - 0x100) * 8 + GIC_BASE_IRQ; if (irq >= s->num_irq) goto bad_reg; if (irq < GIC_NR_SGIS) { value = 0xff; } for (i = 0; i < 8; i++) { if (value & (1 << i)) { int mask = (irq < GIC_INTERNAL) ? (1 << cpu) : GIC_TARGET(irq + i); int cm = (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MASK; if (!GIC_TEST_ENABLED(irq + i, cm)) { DPRINTF("Enabled IRQ %d\n", irq + i); } GIC_SET_ENABLED(irq + i, cm); /* If a raised level triggered IRQ enabled then mark is as pending. */ if (GIC_TEST_LEVEL(irq + i, mask) && !GIC_TEST_EDGE_TRIGGER(irq + i)) { DPRINTF("Set %d pending mask %x\n", irq + i, mask); GIC_SET_PENDING(irq + i, mask); } } } } else if (offset < 0x200) { /* Interrupt Clear Enable. */ irq = (offset - 0x180) * 8 + GIC_BASE_IRQ; if (irq >= s->num_irq) goto bad_reg; if (irq < GIC_NR_SGIS) { value = 0; } for (i = 0; i < 8; i++) { if (value & (1 << i)) { int cm = (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MASK; if (GIC_TEST_ENABLED(irq + i, cm)) { DPRINTF("Disabled IRQ %d\n", irq + i); } GIC_CLEAR_ENABLED(irq + i, cm); } } } else if (offset < 0x280) { /* Interrupt Set Pending. */ irq = (offset - 0x200) * 8 + GIC_BASE_IRQ; if (irq >= s->num_irq) goto bad_reg; if (irq < GIC_NR_SGIS) { value = 0; } for (i = 0; i < 8; i++) { if (value & (1 << i)) { GIC_SET_PENDING(irq + i, GIC_TARGET(irq + i)); } } } else if (offset < 0x300) { /* Interrupt Clear Pending. */ irq = (offset - 0x280) * 8 + GIC_BASE_IRQ; if (irq >= s->num_irq) goto bad_reg; if (irq < GIC_NR_SGIS) { value = 0; } for (i = 0; i < 8; i++) { /* ??? This currently clears the pending bit for all CPUs, even for per-CPU interrupts. It's unclear whether this is the corect behavior. */ if (value & (1 << i)) { GIC_CLEAR_PENDING(irq + i, ALL_CPU_MASK); } } } else if (offset < 0x400) { /* Interrupt Active. */ goto bad_reg; } else if (offset < 0x800) { /* Interrupt Priority. */ irq = (offset - 0x400) + GIC_BASE_IRQ; if (irq >= s->num_irq) goto bad_reg; gic_set_priority(s, cpu, irq, value); } else if (offset < 0xc00) { /* Interrupt CPU Target. RAZ/WI on uniprocessor GICs, with the * annoying exception of the 11MPCore's GIC. */ if (s->num_cpu != 1 || s->revision == REV_11MPCORE) { irq = (offset - 0x800) + GIC_BASE_IRQ; if (irq >= s->num_irq) { goto bad_reg; } if (irq < 29) { value = 0; } else if (irq < GIC_INTERNAL) { value = ALL_CPU_MASK; } s->irq_target[irq] = value & ALL_CPU_MASK; } } else if (offset < 0xf00) { /* Interrupt Configuration. */ irq = (offset - 0xc00) * 4 + GIC_BASE_IRQ; if (irq >= s->num_irq) goto bad_reg; if (irq < GIC_NR_SGIS) value |= 0xaa; for (i = 0; i < 4; i++) { if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) { if (value & (1 << (i * 2))) { GIC_SET_MODEL(irq + i); } else { GIC_CLEAR_MODEL(irq + i); } } if (value & (2 << (i * 2))) { GIC_SET_EDGE_TRIGGER(irq + i); } else { GIC_CLEAR_EDGE_TRIGGER(irq + i); } } } else if (offset < 0xf10) { /* 0xf00 is only handled for 32-bit writes. */ goto bad_reg; } else if (offset < 0xf20) { /* GICD_CPENDSGIRn */ if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) { goto bad_reg; } irq = (offset - 0xf10); s->sgi_pending[irq][cpu] &= ~value; if (s->sgi_pending[irq][cpu] == 0) { GIC_CLEAR_PENDING(irq, 1 << cpu); } } else if (offset < 0xf30) { /* GICD_SPENDSGIRn */ if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) { goto bad_reg; } irq = (offset - 0xf20); GIC_SET_PENDING(irq, 1 << cpu); s->sgi_pending[irq][cpu] |= value; } else { goto bad_reg; } gic_update(s); return; bad_reg: qemu_log_mask(LOG_GUEST_ERROR, "gic_dist_writeb: Bad offset %x\n", (int)offset); }
false
qemu
c27a5ba94874cb3a29e21b3ad4bd5e504aea93b2
4,135
static int colo_packet_compare(Packet *ppkt, Packet *spkt) { trace_colo_compare_ip_info(ppkt->size, inet_ntoa(ppkt->ip->ip_src), inet_ntoa(ppkt->ip->ip_dst), spkt->size, inet_ntoa(spkt->ip->ip_src), inet_ntoa(spkt->ip->ip_dst)); if (ppkt->size == spkt->size) { return memcmp(ppkt->data, spkt->data, spkt->size); } else { return -1; } }
false
qemu
2ad7ca4c81733cba5c5c464078a643aba61044f8
4,136
BlockAIOCB *bdrv_aio_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors, BlockCompletionFunc *cb, void *opaque) { Coroutine *co; BlockAIOCBCoroutine *acb; trace_bdrv_aio_discard(bs, sector_num, nb_sectors, opaque); acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque); acb->need_bh = true; acb->req.error = -EINPROGRESS; acb->req.sector = sector_num; acb->req.nb_sectors = nb_sectors; co = qemu_coroutine_create(bdrv_aio_discard_co_entry); qemu_coroutine_enter(co, acb); bdrv_co_maybe_schedule_bh(acb); return &acb->common; }
false
qemu
61007b316cd71ee7333ff7a0a749a8949527575f
4,138
static void bdrv_drain_poll(BlockDriverState *bs) { while (bdrv_requests_pending(bs)) { /* Keep iterating */ aio_poll(bdrv_get_aio_context(bs), true); } }
false
qemu
d42cf28837801cd1f835089fe9db2a42a1af55cd
4,139
static void quorum_aio_cb(void *opaque, int ret) { QuorumChildRequest *sacb = opaque; QuorumAIOCB *acb = sacb->parent; BDRVQuorumState *s = acb->common.bs->opaque; sacb->ret = ret; acb->count++; if (ret == 0) { acb->success_count++; } else { quorum_report_bad(acb, sacb->aiocb->bs->node_name, ret); } assert(acb->count <= s->num_children); assert(acb->success_count <= s->num_children); if (acb->count < s->num_children) { return; } /* Do the vote on read */ if (acb->is_read) { quorum_vote(acb); } else { quorum_has_too_much_io_failed(acb); } quorum_aio_finalize(acb); }
true
qemu
cf29a570a7aa7abab66bf256fdf9540873590811
4,140
static const uint8_t *pcx_rle_decode(const uint8_t *src, const uint8_t *end, uint8_t *dst, unsigned int bytes_per_scanline, int compressed) { unsigned int i = 0; unsigned char run, value; if (compressed) { while (i < bytes_per_scanline && src < end) { run = 1; value = *src++; if (value >= 0xc0 && src < end) { run = value & 0x3f; value = *src++; } while (i < bytes_per_scanline && run--) dst[i++] = value; } } else { memcpy(dst, src, bytes_per_scanline); src += bytes_per_scanline; } return src; }
true
FFmpeg
09b23786b3986502ee88d4907356979127169bdd
4,142
void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp) { int64_t value; if (!error_is_set(errp)) { if (v->type_int16) { v->type_int16(v, obj, name, errp); } else { value = *obj; v->type_int(v, &value, name, errp); if (value < INT16_MIN || value > INT16_MAX) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null", "int16_t"); return; } *obj = value; } } }
true
qemu
297a3646c2947ee64a6d42ca264039732c6218e0
4,143
static void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename) { GlobalProperty *prop; QTAILQ_FOREACH(prop, &global_props, next) { Error *err = NULL; if (strcmp(typename, prop->driver) != 0) { continue; } prop->used = true; object_property_parse(OBJECT(dev), prop->value, prop->property, &err); if (err != NULL) { assert(prop->user_provided); error_reportf_err(err, "Warning: global %s.%s=%s ignored: ", prop->driver, prop->property, prop->value); return; } } }
true
qemu
f9a8b5530d438f836f9697639814f585aaec554d
4,145
static unsigned char get_ref_idx(AVFrame *frame) { FrameDecodeData *fdd; NVDECFrame *cf; if (!frame || !frame->private_ref) return 255; fdd = (FrameDecodeData*)frame->private_ref->data; cf = (NVDECFrame*)fdd->hwaccel_priv; return cf->idx; }
false
FFmpeg
5a0f6b099f3e8fcb95a80e3ffe52b3bf369efe24
4,146
static av_cold int dnxhd_encode_end(AVCodecContext *avctx) { DNXHDEncContext *ctx = avctx->priv_data; int max_level = 1 << (ctx->cid_table->bit_depth + 2); int i; av_free(ctx->vlc_codes - max_level * 2); av_free(ctx->vlc_bits - max_level * 2); av_freep(&ctx->run_codes); av_freep(&ctx->run_bits); av_freep(&ctx->mb_bits); av_freep(&ctx->mb_qscale); av_freep(&ctx->mb_rc); av_freep(&ctx->mb_cmp); av_freep(&ctx->slice_size); av_freep(&ctx->slice_offs); av_freep(&ctx->qmatrix_c); av_freep(&ctx->qmatrix_l); av_freep(&ctx->qmatrix_c16); av_freep(&ctx->qmatrix_l16); for (i = 1; i < avctx->thread_count; i++) av_freep(&ctx->thread[i]); av_frame_free(&avctx->coded_frame); return 0; }
false
FFmpeg
d6604b29ef544793479d7fb4e05ef6622bb3e534
4,147
static void *sigwait_compat(void *opaque) { struct sigfd_compat_info *info = opaque; int err; sigset_t all; sigfillset(&all); sigprocmask(SIG_BLOCK, &all, NULL); do { siginfo_t siginfo; err = sigwaitinfo(&info->mask, &siginfo); if (err == -1 && errno == EINTR) { err = 0; continue; } if (err > 0) { char buffer[128]; size_t offset = 0; memcpy(buffer, &err, sizeof(err)); while (offset < sizeof(buffer)) { ssize_t len; len = write(info->fd, buffer + offset, sizeof(buffer) - offset); if (len == -1 && errno == EINTR) continue; if (len <= 0) { err = -1; break; } offset += len; } } } while (err >= 0); return NULL; }
true
qemu
9e472e101f37233f4e32d181d2fee29014c1cf2f
4,148
static bool qvirtio_pci_get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; QVirtQueuePCI *vqpci = (QVirtQueuePCI *)vq; uint32_t data; if (dev->pdev->msix_enabled) { g_assert_cmpint(vqpci->msix_entry, !=, -1); if (qpci_msix_masked(dev->pdev, vqpci->msix_entry)) { /* No ISR checking should be done if masked, but read anyway */ return qpci_msix_pending(dev->pdev, vqpci->msix_entry); } else { data = readl(vqpci->msix_addr); writel(vqpci->msix_addr, 0); return data == vqpci->msix_data; } } else { return qpci_io_readb(dev->pdev, dev->addr + QVIRTIO_PCI_ISR_STATUS) & 1; } }
true
qemu
1e34cf9681ec549e26f30daaabc1ce58d60446f7
4,149
static void pxa2xx_pcmcia_realize(DeviceState *dev, Error **errp) { PXA2xxPCMCIAState *s = PXA2XX_PCMCIA(dev); pcmcia_socket_register(&s->slot); }
true
qemu
7797a73947d5c0e63dd5552b348cf66c384b4555
4,150
static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun, MegasasCmd *cmd) { struct mfi_ld_info *info = cmd->iov_buf; size_t dcmd_size = sizeof(struct mfi_ld_info); uint8_t cdb[6]; SCSIRequest *req; ssize_t len, resid; uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF); uint64_t ld_size; if (!cmd->iov_buf) { cmd->iov_buf = g_malloc0(dcmd_size); info = cmd->iov_buf; megasas_setup_inquiry(cdb, 0x83, sizeof(info->vpd_page83)); req = scsi_req_new(sdev, cmd->index, lun, cdb, cmd); if (!req) { trace_megasas_dcmd_req_alloc_failed(cmd->index, "LD get info vpd inquiry"); g_free(cmd->iov_buf); cmd->iov_buf = NULL; return MFI_STAT_FLASH_ALLOC_FAIL; } trace_megasas_dcmd_internal_submit(cmd->index, "LD get info vpd inquiry", lun); len = scsi_req_enqueue(req); if (len > 0) { cmd->iov_size = len; scsi_req_continue(req); } return MFI_STAT_INVALID_STATUS; } info->ld_config.params.state = MFI_LD_STATE_OPTIMAL; info->ld_config.properties.ld.v.target_id = lun; info->ld_config.params.stripe_size = 3; info->ld_config.params.num_drives = 1; info->ld_config.params.is_consistent = 1; /* Logical device size is in blocks */ blk_get_geometry(sdev->conf.blk, &ld_size); info->size = cpu_to_le64(ld_size); memset(info->ld_config.span, 0, sizeof(info->ld_config.span)); info->ld_config.span[0].start_block = 0; info->ld_config.span[0].num_blocks = info->size; info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id); resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg); g_free(cmd->iov_buf); cmd->iov_size = dcmd_size - resid; cmd->iov_buf = NULL; return MFI_STAT_OK; }
true
qemu
87e459a810d7b1ec1638085b5a80ea3d9b43119a
4,151
static void *migration_thread(void *opaque) { MigrationState *s = opaque; int64_t initial_time = qemu_get_clock_ms(rt_clock); int64_t initial_bytes = 0; int64_t max_size = 0; int64_t start_time = initial_time; bool old_vm_running = false; DPRINTF("beginning savevm\n"); qemu_savevm_state_begin(s->file, &s->params); while (s->state == MIG_STATE_ACTIVE) { int64_t current_time; uint64_t pending_size; if (!qemu_file_rate_limit(s->file)) { DPRINTF("iterate\n"); pending_size = qemu_savevm_state_pending(s->file, max_size); DPRINTF("pending size %lu max %lu\n", pending_size, max_size); if (pending_size && pending_size >= max_size) { qemu_savevm_state_iterate(s->file); } else { int ret; DPRINTF("done iterating\n"); qemu_mutex_lock_iothread(); start_time = qemu_get_clock_ms(rt_clock); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); old_vm_running = runstate_is_running(); ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); if (ret >= 0) { qemu_file_set_rate_limit(s->file, INT_MAX); qemu_savevm_state_complete(s->file); } qemu_mutex_unlock_iothread(); if (ret < 0) { migrate_finish_set_state(s, MIG_STATE_ERROR); break; } if (!qemu_file_get_error(s->file)) { migrate_finish_set_state(s, MIG_STATE_COMPLETED); break; } } } if (qemu_file_get_error(s->file)) { migrate_finish_set_state(s, MIG_STATE_ERROR); break; } current_time = qemu_get_clock_ms(rt_clock); if (current_time >= initial_time + BUFFER_DELAY) { uint64_t transferred_bytes = qemu_ftell(s->file) - initial_bytes; uint64_t time_spent = current_time - initial_time; double bandwidth = transferred_bytes / time_spent; max_size = bandwidth * migrate_max_downtime() / 1000000; s->mbps = time_spent ? (((double) transferred_bytes * 8.0) / ((double) time_spent / 1000.0)) / 1000.0 / 1000.0 : -1; DPRINTF("transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %g max_size %" PRId64 "\n", transferred_bytes, time_spent, bandwidth, max_size); /* if we haven't sent anything, we don't want to recalculate 10000 is a small enough number for our purposes */ if (s->dirty_bytes_rate && transferred_bytes > 10000) { s->expected_downtime = s->dirty_bytes_rate / bandwidth; } qemu_file_reset_rate_limit(s->file); initial_time = current_time; initial_bytes = qemu_ftell(s->file); } if (qemu_file_rate_limit(s->file)) { /* usleep expects microseconds */ g_usleep((initial_time + BUFFER_DELAY - current_time)*1000); } } qemu_mutex_lock_iothread(); if (s->state == MIG_STATE_COMPLETED) { int64_t end_time = qemu_get_clock_ms(rt_clock); s->total_time = end_time - s->total_time; s->downtime = end_time - start_time; runstate_set(RUN_STATE_POSTMIGRATE); } else { if (old_vm_running) { vm_start(); } } qemu_bh_schedule(s->cleanup_bh); qemu_mutex_unlock_iothread(); return NULL; }
true
qemu
d58f574bf39796ed2396dfd1e308352fbb03f944
4,152
static av_always_inline void dnxhd_decode_dct_block(const DNXHDContext *ctx, RowContext *row, int n, int index_bits, int level_bias, int level_shift) { int i, j, index1, index2, len, flags; int level, component, sign; const int *scale; const uint8_t *weight_matrix; const uint8_t *ac_level = ctx->cid_table->ac_level; const uint8_t *ac_flags = ctx->cid_table->ac_flags; int16_t *block = row->blocks[n]; const int eob_index = ctx->cid_table->eob_index; OPEN_READER(bs, &row->gb); ctx->bdsp.clear_block(block); if (!ctx->is_444) { if (n & 2) { component = 1 + (n & 1); scale = row->chroma_scale; weight_matrix = ctx->cid_table->chroma_weight; } else { component = 0; scale = row->luma_scale; weight_matrix = ctx->cid_table->luma_weight; } } else { component = (n >> 1) % 3; if (component) { scale = row->chroma_scale; weight_matrix = ctx->cid_table->chroma_weight; } else { scale = row->luma_scale; weight_matrix = ctx->cid_table->luma_weight; } } UPDATE_CACHE(bs, &row->gb); GET_VLC(len, bs, &row->gb, ctx->dc_vlc.table, DNXHD_DC_VLC_BITS, 1); if (len) { level = GET_CACHE(bs, &row->gb); LAST_SKIP_BITS(bs, &row->gb, len); sign = ~level >> 31; level = (NEG_USR32(sign ^ level, len) ^ sign) - sign; row->last_dc[component] += level; } block[0] = row->last_dc[component]; i = 0; UPDATE_CACHE(bs, &row->gb); GET_VLC(index1, bs, &row->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2); while (index1 != eob_index) { level = ac_level[index1]; flags = ac_flags[index1]; sign = SHOW_SBITS(bs, &row->gb, 1); SKIP_BITS(bs, &row->gb, 1); if (flags & 1) { level += SHOW_UBITS(bs, &row->gb, index_bits) << 7; SKIP_BITS(bs, &row->gb, index_bits); } if (flags & 2) { UPDATE_CACHE(bs, &row->gb); GET_VLC(index2, bs, &row->gb, ctx->run_vlc.table, DNXHD_VLC_BITS, 2); i += ctx->cid_table->run[index2]; } if (++i > 63) { av_log(ctx->avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", n, i); break; } j = ctx->scantable.permutated[i]; level *= scale[i]; if (level_bias < 32 || weight_matrix[i] != level_bias) level += level_bias; level >>= level_shift; block[j] = (level ^ sign) - sign; UPDATE_CACHE(bs, &row->gb); GET_VLC(index1, bs, &row->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2); } CLOSE_READER(bs, &row->gb); }
true
FFmpeg
b8b8e82ea14016b2cb04b49ecea57f836e6ee7f8
4,153
static void coroutine_fn qed_co_pwrite_zeroes_cb(void *opaque, int ret) { QEDWriteZeroesCB *cb = opaque; cb->done = true; cb->ret = ret; if (cb->co) { qemu_coroutine_enter(cb->co, NULL); } }
true
qemu
0b8b8753e4d94901627b3e86431230f2319215c4
4,154
static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size, AVSubtitle *sub) { DVBSubContext *ctx = avctx->priv_data; DVBSubDisplayDefinition *display_def = ctx->display_definition; DVBSubRegion *region; DVBSubRegionDisplay *display; AVSubtitleRect *rect; DVBSubCLUT *clut; uint32_t *clut_table; int i; int offset_x=0, offset_y=0; sub->rects = NULL; sub->start_display_time = 0; sub->end_display_time = ctx->time_out * 1000; sub->format = 0; if (display_def) { offset_x = display_def->x; offset_y = display_def->y; } sub->num_rects = ctx->display_list_size; if (sub->num_rects <= 0) return AVERROR_INVALIDDATA; sub->rects = av_mallocz_array(sub->num_rects * sub->num_rects, sizeof(*sub->rects)); if (!sub->rects) return AVERROR(ENOMEM); i = 0; for (display = ctx->display_list; display; display = display->next) { region = get_region(ctx, display->region_id); rect = sub->rects[i]; if (!region) continue; rect->x = display->x_pos + offset_x; rect->y = display->y_pos + offset_y; rect->w = region->width; rect->h = region->height; rect->nb_colors = 16; rect->type = SUBTITLE_BITMAP; rect->linesize[0] = region->width; clut = get_clut(ctx, region->clut); if (!clut) clut = &default_clut; switch (region->depth) { case 2: clut_table = clut->clut4; break; case 8: clut_table = clut->clut256; break; case 4: default: clut_table = clut->clut16; break; } rect->data[1] = av_mallocz(AVPALETTE_SIZE); if (!rect->data[1]) { av_free(sub->rects); return AVERROR(ENOMEM); } memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t)); rect->data[0] = av_malloc(region->buf_size); if (!rect->data[0]) { av_free(rect->data[1]); av_free(sub->rects); return AVERROR(ENOMEM); } memcpy(rect->data[0], region->pbuf, region->buf_size); #if FF_API_AVPICTURE FF_DISABLE_DEPRECATION_WARNINGS { int j; for (j = 0; j < 4; j++) { rect->pict.data[j] = rect->data[j]; rect->pict.linesize[j] = rect->linesize[j]; } } FF_ENABLE_DEPRECATION_WARNINGS #endif i++; } sub->num_rects = i; #ifdef DEBUG save_display_set(ctx); #endif return 1; }
true
FFmpeg
1cfd566324f4a9be066ea400685b81c0695e64d9
4,155
DisplayState *init_displaystate(void) { gchar *name; int i; if (!display_state) { display_state = g_new0(DisplayState, 1); } for (i = 0; i < nb_consoles; i++) { if (consoles[i]->console_type != GRAPHIC_CONSOLE && consoles[i]->ds == NULL) { text_console_do_init(consoles[i]->chr, display_state); } /* Hook up into the qom tree here (not in new_console()), once * all QemuConsoles are created and the order / numbering * doesn't change any more */ name = g_strdup_printf("console[%d]", i); object_property_add_child(container_get(object_get_root(), "/backend"), name, OBJECT(consoles[i]), &error_abort); g_free(name); } return display_state; }
true
qemu
333cb18ff4aaf249b2e81a376bee2b15370f4784
4,156
static void e1000e_device_init(QPCIBus *bus, e1000e_device *d) { uint32_t val; d->pci_dev = e1000e_device_find(bus); /* Enable the device */ qpci_device_enable(d->pci_dev); /* Map BAR0 (mac registers) */ d->mac_regs = qpci_iomap(d->pci_dev, 0, NULL); g_assert_nonnull(d->mac_regs); /* Reset the device */ val = e1000e_macreg_read(d, E1000E_CTRL); e1000e_macreg_write(d, E1000E_CTRL, val | E1000E_CTRL_RESET); /* Enable and configure MSI-X */ qpci_msix_enable(d->pci_dev); e1000e_macreg_write(d, E1000E_IVAR, E1000E_IVAR_TEST_CFG); /* Check the device status - link and speed */ val = e1000e_macreg_read(d, E1000E_STATUS); g_assert_cmphex(val & (E1000E_STATUS_LU | E1000E_STATUS_ASDV1000), ==, E1000E_STATUS_LU | E1000E_STATUS_ASDV1000); /* Initialize TX/RX logic */ e1000e_macreg_write(d, E1000E_RCTL, 0); e1000e_macreg_write(d, E1000E_TCTL, 0); /* Notify the device that the driver is ready */ val = e1000e_macreg_read(d, E1000E_CTRL_EXT); e1000e_macreg_write(d, E1000E_CTRL_EXT, val | E1000E_CTRL_EXT_DRV_LOAD | E1000E_CTRL_EXT_TXLSFLOW); /* Allocate and setup TX ring */ d->tx_ring = guest_alloc(test_alloc, E1000E_RING_LEN); g_assert(d->tx_ring != 0); e1000e_macreg_write(d, E1000E_TDBAL, (uint32_t) d->tx_ring); e1000e_macreg_write(d, E1000E_TDBAH, (uint32_t) (d->tx_ring >> 32)); e1000e_macreg_write(d, E1000E_TDLEN, E1000E_RING_LEN); e1000e_macreg_write(d, E1000E_TDT, 0); e1000e_macreg_write(d, E1000E_TDH, 0); /* Enable transmit */ e1000e_macreg_write(d, E1000E_TCTL, E1000E_TCTL_EN); /* Allocate and setup RX ring */ d->rx_ring = guest_alloc(test_alloc, E1000E_RING_LEN); g_assert(d->rx_ring != 0); e1000e_macreg_write(d, E1000E_RDBAL, (uint32_t)d->rx_ring); e1000e_macreg_write(d, E1000E_RDBAH, (uint32_t)(d->rx_ring >> 32)); e1000e_macreg_write(d, E1000E_RDLEN, E1000E_RING_LEN); e1000e_macreg_write(d, E1000E_RDT, 0); e1000e_macreg_write(d, E1000E_RDH, 0); /* Enable receive */ e1000e_macreg_write(d, E1000E_RFCTL, E1000E_RFCTL_EXTEN); e1000e_macreg_write(d, E1000E_RCTL, E1000E_RCTL_EN | E1000E_RCTL_UPE | E1000E_RCTL_MPE); /* Enable all interrupts */ e1000e_macreg_write(d, E1000E_IMS, 0xFFFFFFFF); }
true
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
4,157
static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r, uint8_t *outbuf) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint64_t nb_sectors; int page, dbd, buflen, ret, page_control; uint8_t *p; uint8_t dev_specific_param; dbd = r->req.cmd.buf[1] & 0x8; page = r->req.cmd.buf[2] & 0x3f; page_control = (r->req.cmd.buf[2] & 0xc0) >> 6; DPRINTF("Mode Sense(%d) (page %d, xfer %zd, page_control %d)\n", (r->req.cmd.buf[0] == MODE_SENSE) ? 6 : 10, page, r->req.cmd.xfer, page_control); memset(outbuf, 0, r->req.cmd.xfer); p = outbuf; if (bdrv_is_read_only(s->qdev.conf.bs)) { dev_specific_param = 0x80; /* Readonly. */ } else { dev_specific_param = 0x00; } if (r->req.cmd.buf[0] == MODE_SENSE) { p[1] = 0; /* Default media type. */ p[2] = dev_specific_param; p[3] = 0; /* Block descriptor length. */ p += 4; } else { /* MODE_SENSE_10 */ p[2] = 0; /* Default media type. */ p[3] = dev_specific_param; p[6] = p[7] = 0; /* Block descriptor length. */ p += 8; } /* MMC prescribes that CD/DVD drives have no block descriptors. */ bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!dbd && s->qdev.type == TYPE_DISK && nb_sectors) { if (r->req.cmd.buf[0] == MODE_SENSE) { outbuf[3] = 8; /* Block descriptor length */ } else { /* MODE_SENSE_10 */ outbuf[7] = 8; /* Block descriptor length */ } nb_sectors /= (s->qdev.blocksize / 512); if (nb_sectors > 0xffffff) { nb_sectors = 0; } p[0] = 0; /* media density code */ p[1] = (nb_sectors >> 16) & 0xff; p[2] = (nb_sectors >> 8) & 0xff; p[3] = nb_sectors & 0xff; p[4] = 0; /* reserved */ p[5] = 0; /* bytes 5-7 are the sector size in bytes */ p[6] = s->qdev.blocksize >> 8; p[7] = 0; p += 8; } if (page_control == 3) { /* Saved Values */ scsi_check_condition(r, SENSE_CODE(SAVING_PARAMS_NOT_SUPPORTED)); return -1; } if (page == 0x3f) { for (page = 0; page <= 0x3e; page++) { mode_sense_page(s, page, &p, page_control); } } else { ret = mode_sense_page(s, page, &p, page_control); if (ret == -1) { return -1; } } buflen = p - outbuf; /* * The mode data length field specifies the length in bytes of the * following data that is available to be transferred. The mode data * length does not include itself. */ if (r->req.cmd.buf[0] == MODE_SENSE) { outbuf[0] = buflen - 1; } else { /* MODE_SENSE_10 */ outbuf[0] = ((buflen - 2) >> 8) & 0xff; outbuf[1] = (buflen - 2) & 0xff; } if (buflen > r->req.cmd.xfer) { buflen = r->req.cmd.xfer; } return buflen; }
true
qemu
e2f0c49ffae8d3a00272c3cbc68850cc5aafbffa
4,158
static int decode_block(MJpegDecodeContext *s, DCTELEM *block, int component, int dc_index, int ac_index, int16_t *quant_matrix) { int code, i, j, level, val; /* DC coef */ val = mjpeg_decode_dc(s, dc_index); if (val == 0xffff) { av_log(s->avctx, AV_LOG_ERROR, "error dc\n"); return -1; } val = val * quant_matrix[0] + s->last_dc[component]; s->last_dc[component] = val; block[0] = val; /* AC coefs */ i = 0; {OPEN_READER(re, &s->gb) for(;;) { UPDATE_CACHE(re, &s->gb); GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2) /* EOB */ if (code == 0x10) break; i += ((unsigned)code) >> 4; code &= 0xf; if(code){ if(code > MIN_CACHE_BITS - 16){ UPDATE_CACHE(re, &s->gb) } { int cache=GET_CACHE(re,&s->gb); int sign=(~cache)>>31; level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign; } LAST_SKIP_BITS(re, &s->gb, code) if (i >= 63) { if(i == 63){ j = s->scantable.permutated[63]; block[j] = level * quant_matrix[j]; break; } av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i); return -1; } j = s->scantable.permutated[i]; block[j] = level * quant_matrix[j]; } } CLOSE_READER(re, &s->gb)} return 0; }
true
FFmpeg
2111a191ebec422cf7781225cbcfdd69e71afce1
4,160
static int decode_ext_header(Wmv2Context *w){ MpegEncContext * const s= &w->s; GetBitContext gb; int fps; int code; if(s->avctx->extradata_size<4) return -1; init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8); fps = get_bits(&gb, 5); s->bit_rate = get_bits(&gb, 11)*1024; w->mspel_bit = get_bits1(&gb); s->loop_filter = get_bits1(&gb); w->abt_flag = get_bits1(&gb); w->j_type_bit = get_bits1(&gb); w->top_left_mv_flag= get_bits1(&gb); w->per_mb_rl_bit = get_bits1(&gb); code = get_bits(&gb, 3); if(code==0) return -1; s->slice_height = s->mb_height / code; if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, tl_mv_flag:%d, mbrl_bit:%d, code:%d, loop_filter:%d, slices:%d\n", fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit, w->top_left_mv_flag, w->per_mb_rl_bit, code, s->loop_filter, code); } return 0; }
true
FFmpeg
3b99e00c7549ccad90c57b5bcd6e3456650a994a
4,161
static void tlb_flush_nocheck(CPUState *cpu) { CPUArchState *env = cpu->env_ptr; /* The QOM tests will trigger tlb_flushes without setting up TCG * so we bug out here in that case. */ if (!tcg_enabled()) { return; } assert_cpu_is_self(cpu); tlb_debug("(count: %d)\n", tlb_flush_count++); tb_lock(); memset(env->tlb_table, -1, sizeof(env->tlb_table)); memset(env->tlb_v_table, -1, sizeof(env->tlb_v_table)); memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache)); env->vtlb_index = 0; env->tlb_flush_addr = -1; env->tlb_flush_mask = 0; tb_unlock(); atomic_mb_set(&cpu->pending_tlb_flush, 0); }
true
qemu
f3ced3c59287dabc253f83f0c70aa4934470c15e
4,162
static void liveness_pass_1(TCGContext *s) { int nb_globals = s->nb_globals; int oi, oi_prev; tcg_la_func_end(s); for (oi = s->gen_op_buf[0].prev; oi != 0; oi = oi_prev) { int i, nb_iargs, nb_oargs; TCGOpcode opc_new, opc_new2; bool have_opc_new2; TCGLifeData arg_life = 0; TCGTemp *arg_ts; TCGOp * const op = &s->gen_op_buf[oi]; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; oi_prev = op->prev; switch (opc) { case INDEX_op_call: { int call_flags; nb_oargs = op->callo; nb_iargs = op->calli; call_flags = op->args[nb_oargs + nb_iargs + 1]; /* pure functions can be removed if their result is unused */ if (call_flags & TCG_CALL_NO_SIDE_EFFECTS) { for (i = 0; i < nb_oargs; i++) { arg_ts = arg_temp(op->args[i]); if (arg_ts->state != TS_DEAD) { goto do_not_remove_call; } } goto do_remove; } else { do_not_remove_call: /* output args are dead */ for (i = 0; i < nb_oargs; i++) { arg_ts = arg_temp(op->args[i]); if (arg_ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } if (arg_ts->state & TS_MEM) { arg_life |= SYNC_ARG << i; } arg_ts->state = TS_DEAD; } if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | TCG_CALL_NO_READ_GLOBALS))) { /* globals should go back to memory */ for (i = 0; i < nb_globals; i++) { s->temps[i].state = TS_DEAD | TS_MEM; } } else if (!(call_flags & TCG_CALL_NO_READ_GLOBALS)) { /* globals should be synced to memory */ for (i = 0; i < nb_globals; i++) { s->temps[i].state |= TS_MEM; } } /* record arguments that die in this helper */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { arg_ts = arg_temp(op->args[i]); if (arg_ts && arg_ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } } /* input arguments are live for preceding opcodes */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { arg_ts = arg_temp(op->args[i]); if (arg_ts) { arg_ts->state &= ~TS_DEAD; } } } } break; case INDEX_op_insn_start: break; case INDEX_op_discard: /* mark the temporary as dead */ arg_temp(op->args[0])->state = TS_DEAD; break; case INDEX_op_add2_i32: opc_new = INDEX_op_add_i32; goto do_addsub2; case INDEX_op_sub2_i32: opc_new = INDEX_op_sub_i32; goto do_addsub2; case INDEX_op_add2_i64: opc_new = INDEX_op_add_i64; goto do_addsub2; case INDEX_op_sub2_i64: opc_new = INDEX_op_sub_i64; do_addsub2: nb_iargs = 4; nb_oargs = 2; /* Test if the high part of the operation is dead, but not the low part. The result can be optimized to a simple add or sub. This happens often for x86_64 guest when the cpu mode is set to 32 bit. */ if (arg_temp(op->args[1])->state == TS_DEAD) { if (arg_temp(op->args[0])->state == TS_DEAD) { goto do_remove; } /* Replace the opcode and adjust the args in place, leaving 3 unused args at the end. */ op->opc = opc = opc_new; op->args[1] = op->args[2]; op->args[2] = op->args[4]; /* Fall through and mark the single-word operation live. */ nb_iargs = 2; nb_oargs = 1; } goto do_not_remove; case INDEX_op_mulu2_i32: opc_new = INDEX_op_mul_i32; opc_new2 = INDEX_op_muluh_i32; have_opc_new2 = TCG_TARGET_HAS_muluh_i32; goto do_mul2; case INDEX_op_muls2_i32: opc_new = INDEX_op_mul_i32; opc_new2 = INDEX_op_mulsh_i32; have_opc_new2 = TCG_TARGET_HAS_mulsh_i32; goto do_mul2; case INDEX_op_mulu2_i64: opc_new = INDEX_op_mul_i64; opc_new2 = INDEX_op_muluh_i64; have_opc_new2 = TCG_TARGET_HAS_muluh_i64; goto do_mul2; case INDEX_op_muls2_i64: opc_new = INDEX_op_mul_i64; opc_new2 = INDEX_op_mulsh_i64; have_opc_new2 = TCG_TARGET_HAS_mulsh_i64; goto do_mul2; do_mul2: nb_iargs = 2; nb_oargs = 2; if (arg_temp(op->args[1])->state == TS_DEAD) { if (arg_temp(op->args[0])->state == TS_DEAD) { /* Both parts of the operation are dead. */ goto do_remove; } /* The high part of the operation is dead; generate the low. */ op->opc = opc = opc_new; op->args[1] = op->args[2]; op->args[2] = op->args[3]; } else if (arg_temp(op->args[0])->state == TS_DEAD && have_opc_new2) { /* The low part of the operation is dead; generate the high. */ op->opc = opc = opc_new2; op->args[0] = op->args[1]; op->args[1] = op->args[2]; op->args[2] = op->args[3]; } else { goto do_not_remove; } /* Mark the single-word operation live. */ nb_oargs = 1; goto do_not_remove; default: /* XXX: optimize by hardcoding common cases (e.g. triadic ops) */ nb_iargs = def->nb_iargs; nb_oargs = def->nb_oargs; /* Test if the operation can be removed because all its outputs are dead. We assume that nb_oargs == 0 implies side effects */ if (!(def->flags & TCG_OPF_SIDE_EFFECTS) && nb_oargs != 0) { for (i = 0; i < nb_oargs; i++) { if (arg_temp(op->args[i])->state != TS_DEAD) { goto do_not_remove; } } do_remove: tcg_op_remove(s, op); } else { do_not_remove: /* output args are dead */ for (i = 0; i < nb_oargs; i++) { arg_ts = arg_temp(op->args[i]); if (arg_ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } if (arg_ts->state & TS_MEM) { arg_life |= SYNC_ARG << i; } arg_ts->state = TS_DEAD; } /* if end of basic block, update */ if (def->flags & TCG_OPF_BB_END) { tcg_la_bb_end(s); } else if (def->flags & TCG_OPF_SIDE_EFFECTS) { /* globals should be synced to memory */ for (i = 0; i < nb_globals; i++) { s->temps[i].state |= TS_MEM; } } /* record arguments that die in this opcode */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { arg_ts = arg_temp(op->args[i]); if (arg_ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } } /* input arguments are live for preceding opcodes */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { arg_temp(op->args[i])->state &= ~TS_DEAD; } } break; } op->life = arg_life; } }
true
qemu
15fa08f8451babc88d733bd411d4c94976f9d0f8
4,163
static uint64_t addrrange_end(AddrRange r) { return r.start + r.size; }
true
qemu
8417cebfda193c7f9ca70be5e308eaa92cf84b94
4,164
static void cqueue_free(cqueue *q) { av_free(q->elements); av_free(q); }
true
FFmpeg
70df51112ccc8d281cdb96141f20b3fd8a5b11f8
4,167
static int alloc_scratch_buffers(H264SliceContext *sl, int linesize) { const H264Context *h = sl->h264; int alloc_size = FFALIGN(FFABS(linesize) + 32, 32); av_fast_malloc(&sl->bipred_scratchpad, &sl->bipred_scratchpad_allocated, 16 * 6 * alloc_size); // edge emu needs blocksize + filter length - 1 // (= 21x21 for h264) av_fast_malloc(&sl->edge_emu_buffer, &sl->edge_emu_buffer_allocated, alloc_size * 2 * 21); av_fast_malloc(&sl->top_borders[0], &sl->top_borders_allocated[0], h->mb_width * 16 * 3 * sizeof(uint8_t) * 2); av_fast_malloc(&sl->top_borders[1], &sl->top_borders_allocated[1], h->mb_width * 16 * 3 * sizeof(uint8_t) * 2); if (!sl->bipred_scratchpad || !sl->edge_emu_buffer || !sl->top_borders[0] || !sl->top_borders[1]) { av_freep(&sl->bipred_scratchpad); av_freep(&sl->edge_emu_buffer); av_freep(&sl->top_borders[0]); av_freep(&sl->top_borders[1]); sl->bipred_scratchpad_allocated = 0; sl->edge_emu_buffer_allocated = 0; sl->top_borders_allocated[0] = 0; sl->top_borders_allocated[1] = 0; return AVERROR(ENOMEM); } return 0; }
true
FFmpeg
6f37226b687f969bcf6e47a4fb5c28a32d107aa3
4,168
static inline void RENAME(nv21ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { RENAME(nvXXtoUV)(dstV, dstU, src1, width); }
true
FFmpeg
c3ab0004ae4dffc32494ae84dd15cfaa909a7884
4,169
static void ehci_advance_periodic_state(EHCIState *ehci) { uint32_t entry; uint32_t list; const int async = 0; // 4.6 switch(ehci_get_state(ehci, async)) { case EST_INACTIVE: if ( !(ehci->frindex & 7) && (ehci->usbcmd & USBCMD_PSE)) { ehci_set_usbsts(ehci, USBSTS_PSS); ehci_set_state(ehci, async, EST_ACTIVE); // No break, fall through to ACTIVE } else break; case EST_ACTIVE: if ( !(ehci->frindex & 7) && !(ehci->usbcmd & USBCMD_PSE)) { ehci_clear_usbsts(ehci, USBSTS_PSS); ehci_set_state(ehci, async, EST_INACTIVE); break; } list = ehci->periodiclistbase & 0xfffff000; /* check that register has been set */ if (list == 0) { break; } list |= ((ehci->frindex & 0x1ff8) >> 1); pci_dma_read(&ehci->dev, list, &entry, sizeof entry); entry = le32_to_cpu(entry); DPRINTF("PERIODIC state adv fr=%d. [%08X] -> %08X\n", ehci->frindex / 8, list, entry); ehci_set_fetch_addr(ehci, async,entry); ehci_set_state(ehci, async, EST_FETCHENTRY); ehci_advance_state(ehci, async); ehci_queues_rip_unused(ehci, async); break; default: /* this should only be due to a developer mistake */ fprintf(stderr, "ehci: Bad periodic state %d. " "Resetting to active\n", ehci->pstate); assert(0); } }
true
qemu
4be23939ab0d7019c7e59a37485b416fbbf0f073
4,171
static void close_connection(HTTPContext *c) { HTTPContext **cp, *c1; int i, nb_streams; AVFormatContext *ctx; URLContext *h; AVStream *st; /* remove connection from list */ cp = &first_http_ctx; while ((*cp) != NULL) { c1 = *cp; if (c1 == c) { *cp = c->next; } else { cp = &c1->next; /* remove connection associated resources */ if (c->fd >= 0) close(c->fd); if (c->fmt_in) { /* close each frame parser */ for(i=0;i<c->fmt_in->nb_streams;i++) { st = c->fmt_in->streams[i]; if (st->codec.codec) { avcodec_close(&st->codec); av_close_input_file(c->fmt_in); /* free RTP output streams if any */ nb_streams = 0; if (c->stream) nb_streams = c->stream->nb_streams; for(i=0;i<nb_streams;i++) { ctx = c->rtp_ctx[i]; if (ctx) { av_free(ctx); h = c->rtp_handles[i]; if (h) { url_close(h); if (c->stream) current_bandwidth -= c->stream->bandwidth; av_freep(&c->pb_buffer); av_free(c->buffer); av_free(c); nb_connections--;
true
FFmpeg
87638494cac0e58178a445b2c6436264b3af31e9