label
int64
0
1
func1
stringlengths
23
97k
id
int64
0
27.3k
0
void cpu_loop(CPUS390XState *env) { CPUState *cs = CPU(s390_env_get_cpu(env)); int trapnr, n, sig; target_siginfo_t info; target_ulong addr; while (1) { cpu_exec_start(cs); trapnr = cpu_s390x_exec(cs); cpu_exec_end(cs); switch (trapnr) { case EXCP_INTERRUPT: /* Just indicate that signals should be handled asap. */ break; case EXCP_SVC: n = env->int_svc_code; if (!n) { /* syscalls > 255 */ n = env->regs[1]; } env->psw.addr += env->int_svc_ilen; env->regs[2] = do_syscall(env, n, env->regs[2], env->regs[3], env->regs[4], env->regs[5], env->regs[6], env->regs[7], 0, 0); break; case EXCP_DEBUG: sig = gdb_handlesig(cs, TARGET_SIGTRAP); if (sig) { n = TARGET_TRAP_BRKPT; goto do_signal_pc; } break; case EXCP_PGM: n = env->int_pgm_code; switch (n) { case PGM_OPERATION: case PGM_PRIVILEGED: sig = TARGET_SIGILL; n = TARGET_ILL_ILLOPC; goto do_signal_pc; case PGM_PROTECTION: case PGM_ADDRESSING: sig = TARGET_SIGSEGV; /* XXX: check env->error_code */ n = TARGET_SEGV_MAPERR; addr = env->__excp_addr; goto do_signal; case PGM_EXECUTE: case PGM_SPECIFICATION: case PGM_SPECIAL_OP: case PGM_OPERAND: do_sigill_opn: sig = TARGET_SIGILL; n = TARGET_ILL_ILLOPN; goto do_signal_pc; case PGM_FIXPT_OVERFLOW: sig = TARGET_SIGFPE; n = TARGET_FPE_INTOVF; goto do_signal_pc; case PGM_FIXPT_DIVIDE: sig = TARGET_SIGFPE; n = TARGET_FPE_INTDIV; goto do_signal_pc; case PGM_DATA: n = (env->fpc >> 8) & 0xff; if (n == 0xff) { /* compare-and-trap */ goto do_sigill_opn; } else { /* An IEEE exception, simulated or otherwise. */ if (n & 0x80) { n = TARGET_FPE_FLTINV; } else if (n & 0x40) { n = TARGET_FPE_FLTDIV; } else if (n & 0x20) { n = TARGET_FPE_FLTOVF; } else if (n & 0x10) { n = TARGET_FPE_FLTUND; } else if (n & 0x08) { n = TARGET_FPE_FLTRES; } else { /* ??? Quantum exception; BFP, DFP error. */ goto do_sigill_opn; } sig = TARGET_SIGFPE; goto do_signal_pc; } default: fprintf(stderr, "Unhandled program exception: %#x\n", n); cpu_dump_state(cs, stderr, fprintf, 0); exit(EXIT_FAILURE); } break; do_signal_pc: addr = env->psw.addr; do_signal: info.si_signo = sig; info.si_errno = 0; info.si_code = n; info._sifields._sigfault._addr = addr; queue_signal(env, info.si_signo, &info); break; default: fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); cpu_dump_state(cs, stderr, fprintf, 0); exit(EXIT_FAILURE); } process_pending_signals (env); } }
25,633
0
Object *object_resolve_path_component(Object *parent, const gchar *part) { ObjectProperty *prop = object_property_find(parent, part, NULL); if (prop == NULL) { return NULL; } if (object_property_is_link(prop)) { LinkProperty *lprop = prop->opaque; return *lprop->child; } else if (object_property_is_child(prop)) { return prop->opaque; } else { return NULL; } }
25,634
0
static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq) { SCSIBus *bus = sreq->bus; VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus); VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s); VirtIOSCSIReq *req; uint32_t n; req = g_malloc(sizeof(*req)); qemu_get_be32s(f, &n); assert(n < vs->conf.num_queues); qemu_get_buffer(f, (unsigned char *)&req->elem, sizeof(req->elem)); /* TODO: add a way for SCSIBusInfo's load_request to fail, * and fail migration instead of asserting here. * When we do, we might be able to re-enable NDEBUG below. */ #ifdef NDEBUG #error building with NDEBUG is not supported #endif assert(req->elem.in_num <= ARRAY_SIZE(req->elem.in_sg)); assert(req->elem.out_num <= ARRAY_SIZE(req->elem.out_sg)); virtio_scsi_parse_req(s, vs->cmd_vqs[n], req); scsi_req_ref(sreq); req->sreq = sreq; if (req->sreq->cmd.mode != SCSI_XFER_NONE) { int req_mode = (req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV); assert(req->sreq->cmd.mode == req_mode); } return req; }
25,635
0
static void phys_sections_free(PhysPageMap *map) { while (map->sections_nb > 0) { MemoryRegionSection *section = &map->sections[--map->sections_nb]; phys_section_destroy(section->mr); } g_free(map->sections); g_free(map->nodes); g_free(map); }
25,637
0
static void fill_buffer(ByteIOContext *s) { int len; /* no need to do anything if EOF already reached */ if (s->eof_reached) return; if(s->update_checksum){ if(s->buf_end > s->checksum_ptr) s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_end - s->checksum_ptr); s->checksum_ptr= s->buffer; } len = s->read_packet(s->opaque, s->buffer, s->buffer_size); if (len <= 0) { /* do not modify buffer if EOF reached so that a seek back can be done without rereading data */ s->eof_reached = 1; if(len<0) s->error= len; } else { s->pos += len; s->buf_ptr = s->buffer; s->buf_end = s->buffer + len; } }
25,638
0
static int adx_encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, void *data) { ADXContext *c = avctx->priv_data; const int16_t *samples = data; uint8_t *dst = frame; int ch; if (!c->header_parsed) { int hdrsize = adx_encode_header(avctx, dst, buf_size); dst += hdrsize; c->header_parsed = 1; } for (ch = 0; ch < avctx->channels; ch++) { adx_encode(c, dst, samples + ch, &c->prev[ch], avctx->channels); dst += BLOCK_SIZE; } return dst - frame; }
25,639
0
static int bmp_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { BMPParseContext *bpc = s->priv_data; uint64_t state = bpc->pc.state64; int next = END_NOT_FOUND; int i = 0; *poutbuf_size = 0; restart: if (bpc->pc.frame_start_found <= 2+4+4) { for (; i < buf_size; i++) { state = (state << 8) | buf[i]; if (bpc->pc.frame_start_found == 0) { if ((state >> 48) == (('B' << 8) | 'M')) { bpc->fsize = av_bswap32(state >> 16); bpc->pc.frame_start_found = 1; } } else if (bpc->pc.frame_start_found == 2+4+4) { // unsigned hsize = av_bswap32(state>>32); unsigned ihsize = av_bswap32(state); if (ihsize < 12 || ihsize > 200) { bpc->pc.frame_start_found = 0; continue; } bpc->pc.frame_start_found++; bpc->remaining_size = bpc->fsize + i - 17; if (bpc->pc.index + i > 17) { next = i - 17; state = 0; break; } else { bpc->pc.state64 = 0; goto restart; } } else if (bpc->pc.frame_start_found) bpc->pc.frame_start_found++; } bpc->pc.state64 = state; } else { if (bpc->remaining_size) { i = FFMIN(bpc->remaining_size, buf_size); bpc->remaining_size -= i; if (bpc->remaining_size) goto flush; bpc->pc.frame_start_found = 0; goto restart; } } flush: if (ff_combine_frame(&bpc->pc, next, &buf, &buf_size) < 0) return buf_size; if (next != END_NOT_FOUND && next < 0) bpc->pc.frame_start_found = FFMAX(bpc->pc.frame_start_found - i - 1, 0); else bpc->pc.frame_start_found = 0; *poutbuf = buf; *poutbuf_size = buf_size; return next; }
25,640
0
static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { AVIContext *avi = s->priv_data; AVStream *st; int i, index; int64_t pos; AVIStream *ast; if (!avi->index_loaded) { /* we only load the index on demand */ avi_load_index(s); avi->index_loaded = 1; } assert(stream_index>= 0); st = s->streams[stream_index]; ast= st->priv_data; index= av_index_search_timestamp(st, timestamp * FFMAX(ast->sample_size, 1), flags); if(index<0) return -1; /* find the position */ pos = st->index_entries[index].pos; timestamp = st->index_entries[index].timestamp / FFMAX(ast->sample_size, 1); av_dlog(s, "XX %"PRId64" %d %"PRId64"\n", timestamp, index, st->index_entries[index].timestamp); if (CONFIG_DV_DEMUXER && avi->dv_demux) { /* One and only one real stream for DV in AVI, and it has video */ /* offsets. Calling with other stream indexes should have failed */ /* the av_index_search_timestamp call above. */ assert(stream_index == 0); /* Feed the DV video stream version of the timestamp to the */ /* DV demux so it can synthesize correct timestamps. */ ff_dv_offset_reset(avi->dv_demux, timestamp); avio_seek(s->pb, pos, SEEK_SET); avi->stream_index= -1; return 0; } for(i = 0; i < s->nb_streams; i++) { AVStream *st2 = s->streams[i]; AVIStream *ast2 = st2->priv_data; ast2->packet_size= ast2->remaining= 0; if (ast2->sub_ctx) { seek_subtitle(st, st2, timestamp); continue; } if (st2->nb_index_entries <= 0) continue; // assert(st2->codec->block_align); assert((int64_t)st2->time_base.num*ast2->rate == (int64_t)st2->time_base.den*ast2->scale); index = av_index_search_timestamp( st2, av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1), flags | AVSEEK_FLAG_BACKWARD); if(index<0) index=0; if(!avi->non_interleaved){ while(index>0 && st2->index_entries[index].pos > pos) index--; while(index+1 < st2->nb_index_entries && st2->index_entries[index].pos < pos) index++; } av_dlog(s, "%"PRId64" %d %"PRId64"\n", timestamp, index, st2->index_entries[index].timestamp); /* extract the current frame number */ ast2->frame_offset = st2->index_entries[index].timestamp; } /* do the seek */ avio_seek(s->pb, pos, SEEK_SET); avi->stream_index= -1; return 0; }
25,641
0
static int opt_streamid(const char *opt, const char *arg) { int idx; char *p; char idx_str[16]; av_strlcpy(idx_str, arg, sizeof(idx_str)); p = strchr(idx_str, ':'); if (!p) { fprintf(stderr, "Invalid value '%s' for option '%s', required syntax is 'index:value'\n", arg, opt); ffmpeg_exit(1); } *p++ = '\0'; idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, INT_MAX); streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1); streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX); return 0; }
25,642
0
static void avc_luma_midv_qrt_16w_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, int32_t height, uint8_t vert_offset) { uint32_t multiple8_cnt; for (multiple8_cnt = 2; multiple8_cnt--;) { avc_luma_midv_qrt_8w_msa(src, src_stride, dst, dst_stride, height, vert_offset); src += 8; dst += 8; } }
25,643
0
static void RENAME(yuv2rgb32_1)(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y) { const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5) YSCALEYUV2RGB1_ALPHA(%%REGBP) WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5) "pcmpeqd %%mm7, %%mm7 \n\t" WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } } else { if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5) YSCALEYUV2RGB1_ALPHA(%%REGBP) WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5) "pcmpeqd %%mm7, %%mm7 \n\t" WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } } }
25,645
0
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){ HYuvContext *s = avctx->priv_data; const int width= s->width; const int width2= s->width>>1; const int height= s->height; int fake_ystride, fake_ustride, fake_vstride; AVFrame * const p= &s->picture; AVFrame *picture = data; *data_size = 0; /* no supplementary picture */ if (buf_size == 0) return 0; bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4); init_get_bits(&s->gb, s->bitstream_buffer, buf_size); p->reference= 0; if(avctx->get_buffer(avctx, p) < 0){ fprintf(stderr, "get_buffer() failed\n"); return -1; } fake_ystride= s->interlaced ? p->linesize[0]*2 : p->linesize[0]; fake_ustride= s->interlaced ? p->linesize[1]*2 : p->linesize[1]; fake_vstride= s->interlaced ? p->linesize[2]*2 : p->linesize[2]; s->last_slice_end= 0; if(s->bitstream_bpp<24){ int y, cy; int lefty, leftu, leftv; int lefttopy, lefttopu, lefttopv; if(s->yuy2){ p->data[0][3]= get_bits(&s->gb, 8); p->data[0][2]= get_bits(&s->gb, 8); p->data[0][1]= get_bits(&s->gb, 8); p->data[0][0]= get_bits(&s->gb, 8); fprintf(stderr, "YUY2 output isnt implemenetd yet\n"); return -1; }else{ leftv= p->data[2][0]= get_bits(&s->gb, 8); lefty= p->data[0][1]= get_bits(&s->gb, 8); leftu= p->data[1][0]= get_bits(&s->gb, 8); p->data[0][0]= get_bits(&s->gb, 8); switch(s->predictor){ case LEFT: case PLANE: decode_422_bitstream(s, width-2); lefty= add_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= add_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu); leftv= add_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv); } for(cy=y=1; y<s->height; y++,cy++){ uint8_t *ydst, *udst, *vdst; if(s->bitstream_bpp==12){ decode_gray_bitstream(s, width); ydst= p->data[0] + p->linesize[0]*y; lefty= add_left_prediction(ydst, s->temp[0], width, lefty); if(s->predictor == PLANE){ if(y>s->interlaced) s->dsp.add_bytes(ydst, ydst - fake_ystride, width); } y++; if(y>=s->height) break; } draw_slice(s, y); ydst= p->data[0] + p->linesize[0]*y; udst= p->data[1] + p->linesize[1]*cy; vdst= p->data[2] + p->linesize[2]*cy; decode_422_bitstream(s, width); lefty= add_left_prediction(ydst, s->temp[0], width, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= add_left_prediction(udst, s->temp[1], width2, leftu); leftv= add_left_prediction(vdst, s->temp[2], width2, leftv); } if(s->predictor == PLANE){ if(cy>s->interlaced){ s->dsp.add_bytes(ydst, ydst - fake_ystride, width); if(!(s->flags&CODEC_FLAG_GRAY)){ s->dsp.add_bytes(udst, udst - fake_ustride, width2); s->dsp.add_bytes(vdst, vdst - fake_vstride, width2); } } } } draw_slice(s, height); break; case MEDIAN: /* first line except first 2 pixels is left predicted */ decode_422_bitstream(s, width-2); lefty= add_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= add_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu); leftv= add_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv); } cy=y=1; /* second line is left predicted for interlaced case */ if(s->interlaced){ decode_422_bitstream(s, width); lefty= add_left_prediction(p->data[0] + p->linesize[0], s->temp[0], width, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= add_left_prediction(p->data[1] + p->linesize[2], s->temp[1], width2, leftu); leftv= add_left_prediction(p->data[2] + p->linesize[1], s->temp[2], width2, leftv); } y++; cy++; } /* next 4 pixels are left predicted too */ decode_422_bitstream(s, 4); lefty= add_left_prediction(p->data[0] + fake_ystride, s->temp[0], 4, lefty); if(!(s->flags&CODEC_FLAG_GRAY)){ leftu= add_left_prediction(p->data[1] + fake_ustride, s->temp[1], 2, leftu); leftv= add_left_prediction(p->data[2] + fake_vstride, s->temp[2], 2, leftv); } /* next line except the first 4 pixels is median predicted */ lefttopy= p->data[0][3]; decode_422_bitstream(s, width-4); add_median_prediction(p->data[0] + fake_ystride+4, p->data[0]+4, s->temp[0], width-4, &lefty, &lefttopy); if(!(s->flags&CODEC_FLAG_GRAY)){ lefttopu= p->data[1][1]; lefttopv= p->data[2][1]; add_median_prediction(p->data[1] + fake_ustride+2, p->data[1]+2, s->temp[1], width2-2, &leftu, &lefttopu); add_median_prediction(p->data[2] + fake_vstride+2, p->data[2]+2, s->temp[2], width2-2, &leftv, &lefttopv); } y++; cy++; for(; y<height; y++,cy++){ uint8_t *ydst, *udst, *vdst; if(s->bitstream_bpp==12){ while(2*cy > y){ decode_gray_bitstream(s, width); ydst= p->data[0] + p->linesize[0]*y; add_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy); y++; } if(y>=height) break; } draw_slice(s, y); decode_422_bitstream(s, width); ydst= p->data[0] + p->linesize[0]*y; udst= p->data[1] + p->linesize[1]*cy; vdst= p->data[2] + p->linesize[2]*cy; add_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy); if(!(s->flags&CODEC_FLAG_GRAY)){ add_median_prediction(udst, udst - fake_ustride, s->temp[1], width2, &leftu, &lefttopu); add_median_prediction(vdst, vdst - fake_vstride, s->temp[2], width2, &leftv, &lefttopv); } } draw_slice(s, height); break; } } }else{ int y; int leftr, leftg, leftb; const int last_line= (height-1)*p->linesize[0]; if(s->bitstream_bpp==32){ p->data[0][last_line+3]= get_bits(&s->gb, 8); leftr= p->data[0][last_line+2]= get_bits(&s->gb, 8); leftg= p->data[0][last_line+1]= get_bits(&s->gb, 8); leftb= p->data[0][last_line+0]= get_bits(&s->gb, 8); }else{ leftr= p->data[0][last_line+2]= get_bits(&s->gb, 8); leftg= p->data[0][last_line+1]= get_bits(&s->gb, 8); leftb= p->data[0][last_line+0]= get_bits(&s->gb, 8); skip_bits(&s->gb, 8); } if(s->bgr32){ switch(s->predictor){ case LEFT: case PLANE: decode_bgr_bitstream(s, width-1); add_left_prediction_bgr32(p->data[0] + last_line+4, s->temp[0], width-1, &leftr, &leftg, &leftb); for(y=s->height-2; y>=0; y--){ //yes its stored upside down decode_bgr_bitstream(s, width); add_left_prediction_bgr32(p->data[0] + p->linesize[0]*y, s->temp[0], width, &leftr, &leftg, &leftb); if(s->predictor == PLANE){ if((y&s->interlaced)==0){ s->dsp.add_bytes(p->data[0] + p->linesize[0]*y, p->data[0] + p->linesize[0]*y + fake_ystride, fake_ystride); } } } draw_slice(s, height); // just 1 large slice as this isnt possible in reverse order break; default: fprintf(stderr, "prediction type not supported!\n"); } }else{ fprintf(stderr, "BGR24 output isnt implemenetd yet\n"); return -1; } } emms_c(); *picture= *p; avctx->release_buffer(avctx, p); *data_size = sizeof(AVFrame); return (get_bits_count(&s->gb)+7)>>3; }
25,646
1
static QemuOpts *opts_parse(QemuOptsList *list, const char *params, int permit_abbrev, bool defaults) { const char *firstname; char value[1024], *id = NULL; const char *p; QemuOpts *opts; Error *local_err = NULL; assert(!permit_abbrev || list->implied_opt_name); firstname = permit_abbrev ? list->implied_opt_name : NULL; if (strncmp(params, "id=", 3) == 0) { get_opt_value(value, sizeof(value), params+3); id = value; } else if ((p = strstr(params, ",id=")) != NULL) { get_opt_value(value, sizeof(value), p+4); id = value; } opts = qemu_opts_create(list, id, !defaults, &local_err); if (opts == NULL) { if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); } return NULL; } if (opts_do_parse(opts, params, firstname, defaults) != 0) { qemu_opts_del(opts); return NULL; } return opts; }
25,647
1
static int get_bool(QEMUFile *f, void *pv, size_t size) { bool *v = pv; *v = qemu_get_byte(f); return 0; }
25,648
1
int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) { int planar, channels; int ret = 0; *got_frame_ptr = 0; avctx->pkt = avpkt; if (!avpkt->data && avpkt->size) { av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n"); return AVERROR(EINVAL); } apply_param_change(avctx, avpkt); if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) { ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt); if (ret >= 0 && *got_frame_ptr) { avctx->frame_number++; frame->pkt_dts = avpkt->dts; if (frame->format == AV_SAMPLE_FMT_NONE) frame->format = avctx->sample_fmt; } } /* many decoders assign whole AVFrames, thus overwriting extended_data; * make sure it's set correctly; assume decoders that actually use * extended_data are doing it correctly */ planar = av_sample_fmt_is_planar(frame->format); channels = av_get_channel_layout_nb_channels(frame->channel_layout); if (!(planar && channels > AV_NUM_DATA_POINTERS)) frame->extended_data = frame->data; return ret; }
25,649
1
int ff_j2k_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy) { int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1; if (ret=ff_j2k_dwt_init(&comp->dwt, comp->coord, codsty->nreslevels-1, codsty->transform)) return ret; for (i = 0; i < 2; i++) csize *= comp->coord[i][1] - comp->coord[i][0]; comp->data = av_malloc(csize * sizeof(int)); if (!comp->data) return AVERROR(ENOMEM); comp->reslevel = av_malloc(codsty->nreslevels * sizeof(Jpeg2000ResLevel)); if (!comp->reslevel) return AVERROR(ENOMEM); for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) { int declvl = codsty->nreslevels - reslevelno; Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) reslevel->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j], declvl - 1); if (reslevelno == 0) reslevel->nbands = 1; else reslevel->nbands = 3; if (reslevel->coord[0][1] == reslevel->coord[0][0]) reslevel->num_precincts_x = 0; else reslevel->num_precincts_x = ff_jpeg2000_ceildivpow2(reslevel->coord[0][1], codsty->log2_prec_width) - (reslevel->coord[0][0] >> codsty->log2_prec_width); if (reslevel->coord[1][1] == reslevel->coord[1][0]) reslevel->num_precincts_y = 0; else reslevel->num_precincts_y = ff_jpeg2000_ceildivpow2(reslevel->coord[1][1], codsty->log2_prec_height) - (reslevel->coord[1][0] >> codsty->log2_prec_height); reslevel->band = av_malloc(reslevel->nbands * sizeof(Jpeg2000Band)); if (!reslevel->band) return AVERROR(ENOMEM); for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) { Jpeg2000Band *band = reslevel->band + bandno; int cblkno, precx, precy, precno; int x0, y0, x1, y1; int xi0, yi0, xi1, yi1; int cblkperprecw, cblkperprech; if (qntsty->quantsty != JPEG2000_QSTY_NONE) { static const uint8_t lut_gain[2][4] = {{0, 0, 0, 0}, {0, 1, 1, 2}}; int numbps; numbps = cbps + lut_gain[codsty->transform][bandno + reslevelno>0]; band->stepsize = SHL(2048 + qntsty->mant[gbandno], 2 + numbps - qntsty->expn[gbandno]); } else band->stepsize = 1 << 13; if (reslevelno == 0) { // the same everywhere band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width-1); band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height-1); for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j], declvl-1); } else{ band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width); band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height); for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j] - (((bandno+1>>i)&1) << declvl-1), declvl); } band->cblknx = ff_jpeg2000_ceildiv(band->coord[0][1], band->codeblock_width) - band->coord[0][0] / band->codeblock_width; band->cblkny = ff_jpeg2000_ceildiv(band->coord[1][1], band->codeblock_height) - band->coord[1][0] / band->codeblock_height; for (j = 0; j < 2; j++) band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx); for (j = 0; j < 2; j++) band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy); band->cblknx = ff_jpeg2000_ceildiv(band->cblknx, dx); band->cblkny = ff_jpeg2000_ceildiv(band->cblkny, dy); band->cblk = av_malloc(sizeof(Jpeg2000Cblk) * band->cblknx * band->cblkny); if (!band->cblk) return AVERROR(ENOMEM); band->prec = av_malloc(sizeof(Jpeg2000Cblk) * reslevel->num_precincts_x * reslevel->num_precincts_y); if (!band->prec) return AVERROR(ENOMEM); for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++) { Jpeg2000Cblk *cblk = band->cblk + cblkno; cblk->zero = 0; cblk->lblock = 3; cblk->length = 0; cblk->lengthinc = 0; cblk->npasses = 0; } y0 = band->coord[1][0]; y1 = ((band->coord[1][0] + (1<<codsty->log2_prec_height)) & ~((1<<codsty->log2_prec_height)-1)) - y0; yi0 = 0; yi1 = ff_jpeg2000_ceildivpow2(y1 - y0, codsty->log2_cblk_height) << codsty->log2_cblk_height; yi1 = FFMIN(yi1, band->cblkny); cblkperprech = 1<<(codsty->log2_prec_height - codsty->log2_cblk_height); for (precy = 0, precno = 0; precy < reslevel->num_precincts_y; precy++) { for (precx = 0; precx < reslevel->num_precincts_x; precx++, precno++) { band->prec[precno].yi0 = yi0; band->prec[precno].yi1 = yi1; } yi1 += cblkperprech; yi0 = yi1 - cblkperprech; yi1 = FFMIN(yi1, band->cblkny); } x0 = band->coord[0][0]; x1 = ((band->coord[0][0] + (1<<codsty->log2_prec_width)) & ~((1<<codsty->log2_prec_width)-1)) - x0; xi0 = 0; xi1 = ff_jpeg2000_ceildivpow2(x1 - x0, codsty->log2_cblk_width) << codsty->log2_cblk_width; xi1 = FFMIN(xi1, band->cblknx); cblkperprecw = 1<<(codsty->log2_prec_width - codsty->log2_cblk_width); for (precx = 0, precno = 0; precx < reslevel->num_precincts_x; precx++) { for (precy = 0; precy < reslevel->num_precincts_y; precy++, precno = 0) { Jpeg2000Prec *prec = band->prec + precno; prec->xi0 = xi0; prec->xi1 = xi1; prec->cblkincl = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0, prec->yi1 - prec->yi0); prec->zerobits = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0, prec->yi1 - prec->yi0); if (!prec->cblkincl || !prec->zerobits) return AVERROR(ENOMEM); } xi1 += cblkperprecw; xi0 = xi1 - cblkperprecw; xi1 = FFMIN(xi1, band->cblknx); } } } return 0; }
25,650
1
static int disas_cp_insn(CPUState *env, DisasContext *s, uint32_t insn) { TCGv tmp, tmp2; uint32_t rd = (insn >> 12) & 0xf; uint32_t cp = (insn >> 8) & 0xf; if (IS_USER(s)) { return 1; } if (insn & ARM_CP_RW_BIT) { if (!env->cp[cp].cp_read) return 1; gen_set_pc_im(s->pc); tmp = new_tmp(); tmp2 = tcg_const_i32(insn); gen_helper_get_cp(tmp, cpu_env, tmp2); tcg_temp_free(tmp2); store_reg(s, rd, tmp); } else { if (!env->cp[cp].cp_write) return 1; gen_set_pc_im(s->pc); tmp = load_reg(s, rd); tmp2 = tcg_const_i32(insn); gen_helper_set_cp(cpu_env, tmp2, tmp); tcg_temp_free(tmp2); dead_tmp(tmp); } return 0; }
25,651
1
static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) { AVStream *st; int len, ret, i; av_init_packet(pkt); for(;;) { /* select current input stream component */ st = s->cur_st; if (st) { if (!st->need_parsing || !st->parser) { /* no parsing needed: we just output the packet as is */ /* raw data support */ *pkt = st->cur_pkt; st->cur_pkt.data= NULL; compute_pkt_fields(s, st, NULL, pkt); s->cur_st = NULL; if ((s->iformat->flags & AVFMT_GENERIC_INDEX) && (pkt->flags & AV_PKT_FLAG_KEY) && pkt->dts != AV_NOPTS_VALUE) { ff_reduce_index(s, st->index); av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME); } break; } else if (st->cur_len > 0 && st->discard < AVDISCARD_ALL) { len = av_parser_parse2(st->parser, st->codec, &pkt->data, &pkt->size, st->cur_ptr, st->cur_len, st->cur_pkt.pts, st->cur_pkt.dts, st->cur_pkt.pos); st->cur_pkt.pts = AV_NOPTS_VALUE; st->cur_pkt.dts = AV_NOPTS_VALUE; /* increment read pointer */ st->cur_ptr += len; st->cur_len -= len; /* return packet if any */ if (pkt->size) { got_packet: pkt->duration = 0; pkt->stream_index = st->index; pkt->pts = st->parser->pts; pkt->dts = st->parser->dts; pkt->pos = st->parser->pos; if(pkt->data == st->cur_pkt.data && pkt->size == st->cur_pkt.size){ s->cur_st = NULL; pkt->destruct= st->cur_pkt.destruct; st->cur_pkt.destruct= NULL; st->cur_pkt.data = NULL; assert(st->cur_len == 0); }else{ pkt->destruct = NULL; } compute_pkt_fields(s, st, st->parser, pkt); if((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & AV_PKT_FLAG_KEY){ int64_t pos= (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->pos : st->parser->frame_offset; ff_reduce_index(s, st->index); av_add_index_entry(st, pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME); } break; } } else { /* free packet */ av_free_packet(&st->cur_pkt); s->cur_st = NULL; } } else { AVPacket cur_pkt; /* read next packet */ ret = av_read_packet(s, &cur_pkt); if (ret < 0) { if (ret == AVERROR(EAGAIN)) return ret; /* return the last frames, if any */ for(i = 0; i < s->nb_streams; i++) { st = s->streams[i]; if (st->parser && st->need_parsing) { av_parser_parse2(st->parser, st->codec, &pkt->data, &pkt->size, NULL, 0, AV_NOPTS_VALUE, AV_NOPTS_VALUE, AV_NOPTS_VALUE); if (pkt->size) goto got_packet; } } /* no more packets: really terminate parsing */ return ret; } st = s->streams[cur_pkt.stream_index]; st->cur_pkt= cur_pkt; if(st->cur_pkt.pts != AV_NOPTS_VALUE && st->cur_pkt.dts != AV_NOPTS_VALUE && st->cur_pkt.pts < st->cur_pkt.dts){ av_log(s, AV_LOG_WARNING, "Invalid timestamps stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d\n", st->cur_pkt.stream_index, st->cur_pkt.pts, st->cur_pkt.dts, st->cur_pkt.size); // av_free_packet(&st->cur_pkt); // return -1; } if(s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "av_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n", st->cur_pkt.stream_index, st->cur_pkt.pts, st->cur_pkt.dts, st->cur_pkt.size, st->cur_pkt.duration, st->cur_pkt.flags); s->cur_st = st; st->cur_ptr = st->cur_pkt.data; st->cur_len = st->cur_pkt.size; if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) { st->parser = av_parser_init(st->codec->codec_id); if (!st->parser) { av_log(s, AV_LOG_WARNING, "parser not found for codec " "%s, packets or times may be invalid.\n", avcodec_get_name(st->codec->codec_id)); /* no parser available: just output the raw packets */ st->need_parsing = AVSTREAM_PARSE_NONE; }else if(st->need_parsing == AVSTREAM_PARSE_HEADERS){ st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; }else if(st->need_parsing == AVSTREAM_PARSE_FULL_ONCE){ st->parser->flags |= PARSER_FLAG_ONCE; } } } } if(s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "read_frame_internal stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->size, pkt->duration, pkt->flags); return 0; }
25,652
1
void qemu_co_rwlock_unlock(CoRwlock *lock) { assert(qemu_in_coroutine()); if (lock->writer) { lock->writer = false; qemu_co_queue_restart_all(&lock->queue); } else { lock->reader--; assert(lock->reader >= 0); /* Wakeup only one waiting writer */ if (!lock->reader) { qemu_co_queue_next(&lock->queue); } } }
25,653
1
void do_addzeo (void) { T1 = T0; T0 += xer_ca; if (likely(!((T1 ^ (-1)) & (T1 ^ T0) & (1 << 31)))) { xer_ov = 0; } else { xer_so = 1; xer_ov = 1; } if (likely(T0 >= T1)) { xer_ca = 0; } else { xer_ca = 1; } }
25,654
1
void ide_atapi_cmd_reply_end(IDEState *s) { int byte_count_limit, size, ret; #ifdef DEBUG_IDE_ATAPI printf("reply: tx_size=%d elem_tx_size=%d index=%d\n", s->packet_transfer_size, s->elementary_transfer_size, s->io_buffer_index); #endif if (s->packet_transfer_size <= 0) { /* end of transfer */ ide_atapi_cmd_ok(s); ide_set_irq(s->bus); #ifdef DEBUG_IDE_ATAPI printf("status=0x%x\n", s->status); #endif } else { /* see if a new sector must be read */ if (s->lba != -1 && s->io_buffer_index >= s->cd_sector_size) { ret = cd_read_sector(s, s->lba, s->io_buffer, s->cd_sector_size); if (ret < 0) { ide_atapi_io_error(s, ret); return; } s->lba++; s->io_buffer_index = 0; } if (s->elementary_transfer_size > 0) { /* there are some data left to transmit in this elementary transfer */ size = s->cd_sector_size - s->io_buffer_index; if (size > s->elementary_transfer_size) size = s->elementary_transfer_size; s->packet_transfer_size -= size; s->elementary_transfer_size -= size; s->io_buffer_index += size; ide_transfer_start(s, s->io_buffer + s->io_buffer_index - size, size, ide_atapi_cmd_reply_end); } else { /* a new transfer is needed */ s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO; byte_count_limit = atapi_byte_count_limit(s); #ifdef DEBUG_IDE_ATAPI printf("byte_count_limit=%d\n", byte_count_limit); #endif size = s->packet_transfer_size; if (size > byte_count_limit) { /* byte count limit must be even if this case */ if (byte_count_limit & 1) byte_count_limit--; size = byte_count_limit; } s->lcyl = size; s->hcyl = size >> 8; s->elementary_transfer_size = size; /* we cannot transmit more than one sector at a time */ if (s->lba != -1) { if (size > (s->cd_sector_size - s->io_buffer_index)) size = (s->cd_sector_size - s->io_buffer_index); } s->packet_transfer_size -= size; s->elementary_transfer_size -= size; s->io_buffer_index += size; ide_transfer_start(s, s->io_buffer + s->io_buffer_index - size, size, ide_atapi_cmd_reply_end); ide_set_irq(s->bus); #ifdef DEBUG_IDE_ATAPI printf("status=0x%x\n", s->status); #endif } } }
25,655
1
static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr, unsigned int channel, unsigned int filter) { SubStream *s = &m->substream[substr]; FilterParams *fp = &s->channel_params[channel].filter_params[filter]; const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER; const char fchar = filter ? 'I' : 'F'; int i, order; // Filter is 0 for FIR, 1 for IIR. av_assert0(filter < 2); if (m->filter_changed[channel][filter]++ > 1) { av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n"); return AVERROR_INVALIDDATA; } order = get_bits(gbp, 4); if (order > max_order) { av_log(m->avctx, AV_LOG_ERROR, "%cIR filter order %d is greater than maximum %d.\n", fchar, order, max_order); return AVERROR_INVALIDDATA; } fp->order = order; if (order > 0) { int32_t *fcoeff = s->channel_params[channel].coeff[filter]; int coeff_bits, coeff_shift; fp->shift = get_bits(gbp, 4); coeff_bits = get_bits(gbp, 5); coeff_shift = get_bits(gbp, 3); if (coeff_bits < 1 || coeff_bits > 16) { av_log(m->avctx, AV_LOG_ERROR, "%cIR filter coeff_bits must be between 1 and 16.\n", fchar); return AVERROR_INVALIDDATA; } if (coeff_bits + coeff_shift > 16) { av_log(m->avctx, AV_LOG_ERROR, "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n", fchar); return AVERROR_INVALIDDATA; } for (i = 0; i < order; i++) fcoeff[i] = get_sbits(gbp, coeff_bits) * (1 << coeff_shift); if (get_bits1(gbp)) { int state_bits, state_shift; if (filter == FIR) { av_log(m->avctx, AV_LOG_ERROR, "FIR filter has state data specified.\n"); return AVERROR_INVALIDDATA; } state_bits = get_bits(gbp, 4); state_shift = get_bits(gbp, 4); /* TODO: Check validity of state data. */ for (i = 0; i < order; i++) fp->state[i] = state_bits ? get_sbits(gbp, state_bits) << state_shift : 0; } } return 0; }
25,656
1
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) { IlContext *il = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; AVFilterBufferRef *out; int ret; out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); if (!out) { avfilter_unref_bufferp(&inpicref); return AVERROR(ENOMEM); } avfilter_copy_buffer_ref_props(out, inpicref); interleave(out->data[0], inpicref->data[0], il->width, inlink->h, out->linesize[0], inpicref->linesize[0], il->luma_mode, il->luma_swap); if (il->nb_planes > 2) { interleave(out->data[1], inpicref->data[1], il->chroma_width, il->chroma_height, out->linesize[1], inpicref->linesize[1], il->chroma_mode, il->chroma_swap); interleave(out->data[2], inpicref->data[2], il->chroma_width, il->chroma_height, out->linesize[2], inpicref->linesize[2], il->chroma_mode, il->chroma_swap); } if (il->nb_planes == 2 && il->nb_planes == 4) { int comp = il->nb_planes - 1; interleave(out->data[comp], inpicref->data[comp], il->width, inlink->h, out->linesize[comp], inpicref->linesize[comp], il->alpha_mode, il->alpha_swap); } ret = ff_filter_frame(outlink, out); avfilter_unref_bufferp(&inpicref); return ret; }
25,657
1
decode_lpc(WmallDecodeCtx *s) { int ch, i, cbits; s->lpc_order = get_bits(&s->gb, 5) + 1; s->lpc_scaling = get_bits(&s->gb, 4); s->lpc_intbits = get_bits(&s->gb, 3) + 1; cbits = s->lpc_scaling + s->lpc_intbits; for(ch = 0; ch < s->num_channels; ch++) { for(i = 0; i < s->lpc_order; i++) { s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits); } } }
25,658
1
static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next) { FrameRateContext *s = ctx->priv; double ret = 0; ff_dlog(ctx, "get_scene_score()\n"); if (crnt->height == next->height && crnt->width == next->width) { int64_t sad; double mafd, diff; ff_dlog(ctx, "get_scene_score() process\n"); if (s->bitdepth == 8) sad = scene_sad8(s, crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->height); else sad = scene_sad16(s, (const uint16_t*)crnt->data[0], crnt->linesize[0] >> 1, (const uint16_t*)next->data[0], next->linesize[0] >> 1, crnt->height); mafd = (double)sad * 100.0 / (crnt->height * crnt->width) / (1 << s->bitdepth); diff = fabs(mafd - s->prev_mafd); ret = av_clipf(FFMIN(mafd, diff), 0, 100.0); s->prev_mafd = mafd; } ff_dlog(ctx, "get_scene_score() result is:%f\n", ret); return ret; }
25,659
0
int main(int argc,char* argv[]){ int i, j; uint64_t sse=0; uint64_t dev; FILE *f[2]; uint8_t buf[2][SIZE]; uint64_t psnr; int len= argc<4 ? 1 : atoi(argv[3]); int64_t max= (1<<(8*len))-1; int shift= argc<5 ? 0 : atoi(argv[4]); int skip_bytes = argc<6 ? 0 : atoi(argv[5]); if(argc<3){ printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\n"); printf("For WAV files use the following:\n"); printf("./tiny_psnr file1.wav file2.wav 2 0 44 to skip the header.\n"); return -1; } f[0]= fopen(argv[1], "rb"); f[1]= fopen(argv[2], "rb"); if(!f[0] || !f[1]){ fprintf(stderr, "Could not open input files.\n"); return -1; } fseek(f[shift<0], shift < 0 ? -shift : shift, SEEK_SET); fseek(f[0],skip_bytes,SEEK_CUR); fseek(f[1],skip_bytes,SEEK_CUR); for(i=0;;){ if( fread(buf[0], SIZE, 1, f[0]) != 1) break; if( fread(buf[1], SIZE, 1, f[1]) != 1) break; for(j=0; j<SIZE; i++,j++){ int64_t a= buf[0][j]; int64_t b= buf[1][j]; if(len==2){ a= (int16_t)(a | (buf[0][++j]<<8)); b= (int16_t)(b | (buf[1][ j]<<8)); } sse += (a-b) * (a-b); } } if(!i) i=1; dev= int_sqrt( ((sse/i)*F*F) + (((sse%i)*F*F) + i/2)/i ); if(sse) psnr= ((2*log16(max<<16) + log16(i) - log16(sse))*284619LL*F + (1<<31)) / (1LL<<32); else psnr= 100*F-1; //floating point free infinity :) printf("stddev:%3d.%02d PSNR:%2d.%02d bytes:%d\n", (int)(dev/F), (int)(dev%F), (int)(psnr/F), (int)(psnr%F), i*len); return 0; }
25,660
1
StrongARMState *sa1110_init(MemoryRegion *sysmem, unsigned int sdram_size, const char *rev) { StrongARMState *s; int i; s = g_new0(StrongARMState, 1); if (!rev) { rev = "sa1110-b5"; } if (strncmp(rev, "sa1110", 6)) { error_report("Machine requires a SA1110 processor."); exit(1); } s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, rev)); if (!s->cpu) { error_report("Unable to find CPU definition"); exit(1); } memory_region_allocate_system_memory(&s->sdram, NULL, "strongarm.sdram", sdram_size); memory_region_add_subregion(sysmem, SA_SDCS0, &s->sdram); s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000, qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ), qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ), NULL); sysbus_create_varargs("pxa25x-timer", 0x90000000, qdev_get_gpio_in(s->pic, SA_PIC_OSTC0), qdev_get_gpio_in(s->pic, SA_PIC_OSTC1), qdev_get_gpio_in(s->pic, SA_PIC_OSTC2), qdev_get_gpio_in(s->pic, SA_PIC_OSTC3), NULL); sysbus_create_simple(TYPE_STRONGARM_RTC, 0x90010000, qdev_get_gpio_in(s->pic, SA_PIC_RTC_ALARM)); s->gpio = strongarm_gpio_init(0x90040000, s->pic); s->ppc = sysbus_create_varargs(TYPE_STRONGARM_PPC, 0x90060000, NULL); for (i = 0; sa_serial[i].io_base; i++) { DeviceState *dev = qdev_create(NULL, TYPE_STRONGARM_UART); qdev_prop_set_chr(dev, "chardev", serial_hds[i]); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, sa_serial[i].io_base); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(s->pic, sa_serial[i].irq)); } s->ssp = sysbus_create_varargs(TYPE_STRONGARM_SSP, 0x80070000, qdev_get_gpio_in(s->pic, SA_PIC_SSP), NULL); s->ssp_bus = (SSIBus *)qdev_get_child_bus(s->ssp, "ssi"); return s; }
25,661
1
static int celt_header(AVFormatContext *s, int idx) { struct ogg *ogg = s->priv_data; struct ogg_stream *os = ogg->streams + idx; AVStream *st = s->streams[idx]; struct oggcelt_private *priv = os->private; uint8_t *p = os->buf + os->pstart; if (os->psize == 60 && !memcmp(p, ff_celt_codec.magic, ff_celt_codec.magicsize)) { /* Main header */ uint32_t version, sample_rate, nb_channels; uint32_t overlap, extra_headers; priv = av_malloc(sizeof(struct oggcelt_private)); if (!priv) return AVERROR(ENOMEM); if (ff_alloc_extradata(st->codecpar, 2 * sizeof(uint32_t)) < 0) { av_free(priv); return AVERROR(ENOMEM); } version = AV_RL32(p + 28); /* unused header size field skipped */ sample_rate = AV_RL32(p + 36); nb_channels = AV_RL32(p + 40); overlap = AV_RL32(p + 48); /* unused bytes per packet field skipped */ extra_headers = AV_RL32(p + 56); st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_id = AV_CODEC_ID_CELT; st->codecpar->sample_rate = sample_rate; st->codecpar->channels = nb_channels; if (sample_rate) avpriv_set_pts_info(st, 64, 1, sample_rate); priv->extra_headers_left = 1 + extra_headers; av_free(os->private); os->private = priv; AV_WL32(st->codecpar->extradata + 0, overlap); AV_WL32(st->codecpar->extradata + 4, version); return 1; } else if (priv && priv->extra_headers_left) { /* Extra headers (vorbiscomment) */ ff_vorbis_stream_comment(s, st, p, os->psize); priv->extra_headers_left--; return 1; } else { return 0; } }
25,662
1
static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, int flags, int send) { abi_long ret, len; struct msghdr msg; int count; struct iovec *vec; abi_ulong target_vec; if (msgp->msg_name) { msg.msg_namelen = tswap32(msgp->msg_namelen); msg.msg_name = alloca(msg.msg_namelen+1); ret = target_to_host_sockaddr(fd, msg.msg_name, tswapal(msgp->msg_name), msg.msg_namelen); if (ret) { goto out2; } } else { msg.msg_name = NULL; msg.msg_namelen = 0; } msg.msg_controllen = 2 * tswapal(msgp->msg_controllen); msg.msg_control = alloca(msg.msg_controllen); msg.msg_flags = tswap32(msgp->msg_flags); count = tswapal(msgp->msg_iovlen); target_vec = tswapal(msgp->msg_iov); vec = lock_iovec(send ? VERIFY_READ : VERIFY_WRITE, target_vec, count, send); if (vec == NULL) { ret = -host_to_target_errno(errno); goto out2; } msg.msg_iovlen = count; msg.msg_iov = vec; if (send) { if (fd_trans_target_to_host_data(fd)) { ret = fd_trans_target_to_host_data(fd)(msg.msg_iov->iov_base, msg.msg_iov->iov_len); } else { ret = target_to_host_cmsg(&msg, msgp); } if (ret == 0) { ret = get_errno(safe_sendmsg(fd, &msg, flags)); } } else { ret = get_errno(safe_recvmsg(fd, &msg, flags)); if (!is_error(ret)) { len = ret; if (fd_trans_host_to_target_data(fd)) { ret = fd_trans_host_to_target_data(fd)(msg.msg_iov->iov_base, len); } else { ret = host_to_target_cmsg(msgp, &msg); } if (!is_error(ret)) { msgp->msg_namelen = tswap32(msg.msg_namelen); if (msg.msg_name != NULL) { ret = host_to_target_sockaddr(tswapal(msgp->msg_name), msg.msg_name, msg.msg_namelen); if (ret) { goto out; } } ret = len; } } } out: unlock_iovec(vec, target_vec, count, !send); out2: return ret; }
25,663
0
static int decode_group3_1d_line(AVCodecContext *avctx, GetBitContext *gb, int pix_left, int *runs) { int mode = 0, run = 0; unsigned int t; for(;;){ t = get_vlc2(gb, ccitt_vlc[mode].table, 9, 2); run += t; if(t < 64){ pix_left -= run; *runs++ = run; if(pix_left <= 0){ if(!pix_left) break; runs[-1] = 0; av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return -1; } run = 0; mode = !mode; }else if((int)t == -1){ av_log(avctx, AV_LOG_ERROR, "Incorrect code\n"); return -1; } } *runs++ = 0; return 0; }
25,664
0
static int get_qcx(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q) { int i, x; if (s->buf_end - s->buf < 1) return AVERROR(EINVAL); x = bytestream_get_byte(&s->buf); // Sqcd q->nguardbits = x >> 5; q->quantsty = x & 0x1f; if (q->quantsty == JPEG2000_QSTY_NONE) { n -= 3; if (s->buf_end - s->buf < n || 32*3 < n) return AVERROR(EINVAL); for (i = 0; i < n; i++) q->expn[i] = bytestream_get_byte(&s->buf) >> 3; } else if (q->quantsty == JPEG2000_QSTY_SI) { if (s->buf_end - s->buf < 2) return AVERROR(EINVAL); x = bytestream_get_be16(&s->buf); q->expn[0] = x >> 11; q->mant[0] = x & 0x7ff; for (i = 1; i < 32 * 3; i++) { int curexpn = FFMAX(0, q->expn[0] - (i - 1) / 3); q->expn[i] = curexpn; q->mant[i] = q->mant[0]; } } else { n = (n - 3) >> 1; if (s->buf_end - s->buf < 2 * n || 32*3 < n) return AVERROR(EINVAL); for (i = 0; i < n; i++) { x = bytestream_get_be16(&s->buf); q->expn[i] = x >> 11; q->mant[i] = x & 0x7ff; } } return 0; }
25,665
1
void do_compare_and_swap32(void *cpu_env, int num) { #ifdef TARGET_I386 uint32_t old = ((CPUX86State*)cpu_env)->regs[R_EAX]; uint32_t *value = (uint32_t*)((CPUX86State*)cpu_env)->regs[R_ECX]; DPRINTF("commpage: compare_and_swap32(%x,new,%p)\n", old, value); if(value && old == tswap32(*value)) { uint32_t new = ((CPUX86State*)cpu_env)->regs[R_EDX]; *value = tswap32(new); /* set zf flag */ ((CPUX86State*)cpu_env)->eflags |= 0x40; } else { ((CPUX86State*)cpu_env)->regs[R_EAX] = tswap32(*value); /* unset zf flag */ ((CPUX86State*)cpu_env)->eflags &= ~0x40; } #else qerror("do_compare_and_swap32 unimplemented"); #endif }
25,666
1
static void ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc) { int i; assert(rc->type == 2); rc->maxes = av_mallocz(sizeof(float[2]) * rc->classifications); for (i = 0; i < rc->classifications; i++) { int j; vorbis_enc_codebook * cb; for (j = 0; j < 8; j++) if (rc->books[i][j] != -1) break; if (j == 8) // zero continue; cb = &venc->codebooks[rc->books[i][j]]; assert(cb->ndimentions >= 2); assert(cb->lookup); for (j = 0; j < cb->nentries; j++) { float a; if (!cb->lens[j]) continue; a = fabs(cb->dimentions[j * cb->ndimentions]); if (a > rc->maxes[i][0]) rc->maxes[i][0] = a; a = fabs(cb->dimentions[j * cb->ndimentions + 1]); if (a > rc->maxes[i][1]) rc->maxes[i][1] = a; } } // small bias for (i = 0; i < rc->classifications; i++) { rc->maxes[i][0] += 0.8; rc->maxes[i][1] += 0.8; } }
25,667
1
BlockDriverState *bdrv_all_find_vmstate_bs(void) { bool not_found = true; BlockDriverState *bs; BdrvNextIterator *it = NULL; while (not_found && (it = bdrv_next(it, &bs))) { AioContext *ctx = bdrv_get_aio_context(bs); aio_context_acquire(ctx); not_found = !bdrv_can_snapshot(bs); aio_context_release(ctx); } return bs; }
25,668
0
static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos, int *outFilterSize, int xInc, int srcW, int dstW, int filterAlign, int one, int flags, int cpu_flags, SwsVector *srcFilter, SwsVector *dstFilter, double param[2], int is_horizontal) { int i; int filterSize; int filter2Size; int minFilterSize; int64_t *filter = NULL; int64_t *filter2 = NULL; const int64_t fone = 1LL << 54; int ret = -1; emms_c(); // FIXME should not be required but IS (even for non-MMX versions) // NOTE: the +3 is for the MMX(+1) / SSE(+3) scaler which reads over the end FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW + 3) * sizeof(**filterPos), fail); if (FFABS(xInc - 0x10000) < 10) { // unscaled int i; filterSize = 1; FF_ALLOCZ_OR_GOTO(NULL, filter, dstW * sizeof(*filter) * filterSize, fail); for (i = 0; i < dstW; i++) { filter[i * filterSize] = fone; (*filterPos)[i] = i; } } else if (flags & SWS_POINT) { // lame looking point sampling mode int i; int xDstInSrc; filterSize = 1; FF_ALLOC_OR_GOTO(NULL, filter, dstW * sizeof(*filter) * filterSize, fail); xDstInSrc = xInc / 2 - 0x8000; for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16; (*filterPos)[i] = xx; filter[i] = fone; xDstInSrc += xInc; } } else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) || (flags & SWS_FAST_BILINEAR)) { // bilinear upscale int i; int xDstInSrc; filterSize = 2; FF_ALLOC_OR_GOTO(NULL, filter, dstW * sizeof(*filter) * filterSize, fail); xDstInSrc = xInc / 2 - 0x8000; for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16; int j; (*filterPos)[i] = xx; // bilinear upscale / linear interpolate / area averaging for (j = 0; j < filterSize; j++) { int64_t coeff = fone - FFABS((xx << 16) - xDstInSrc) * (fone >> 16); if (coeff < 0) coeff = 0; filter[i * filterSize + j] = coeff; xx++; } xDstInSrc += xInc; } } else { int64_t xDstInSrc; int sizeFactor; if (flags & SWS_BICUBIC) sizeFactor = 4; else if (flags & SWS_X) sizeFactor = 8; else if (flags & SWS_AREA) sizeFactor = 1; // downscale only, for upscale it is bilinear else if (flags & SWS_GAUSS) sizeFactor = 8; // infinite ;) else if (flags & SWS_LANCZOS) sizeFactor = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6; else if (flags & SWS_SINC) sizeFactor = 20; // infinite ;) else if (flags & SWS_SPLINE) sizeFactor = 20; // infinite ;) else if (flags & SWS_BILINEAR) sizeFactor = 2; else { sizeFactor = 0; // GCC warning killer assert(0); } if (xInc <= 1 << 16) filterSize = 1 + sizeFactor; // upscale else filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW; filterSize = FFMIN(filterSize, srcW - 2); filterSize = FFMAX(filterSize, 1); FF_ALLOC_OR_GOTO(NULL, filter, dstW * sizeof(*filter) * filterSize, fail); xDstInSrc = xInc - 0x10000; for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((filterSize - 2) << 16)) / (1 << 17); int j; (*filterPos)[i] = xx; for (j = 0; j < filterSize; j++) { int64_t d = (FFABS(((int64_t)xx << 17) - xDstInSrc)) << 13; double floatd; int64_t coeff; if (xInc > 1 << 16) d = d * dstW / srcW; floatd = d * (1.0 / (1 << 30)); if (flags & SWS_BICUBIC) { int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24); int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24); if (d >= 1LL << 31) { coeff = 0.0; } else { int64_t dd = (d * d) >> 30; int64_t ddd = (dd * d) >> 30; if (d < 1LL << 30) coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd + (-18 * (1 << 24) + 12 * B + 6 * C) * dd + (6 * (1 << 24) - 2 * B) * (1 << 30); else coeff = (-B - 6 * C) * ddd + (6 * B + 30 * C) * dd + (-12 * B - 48 * C) * d + (8 * B + 24 * C) * (1 << 30); } coeff *= fone >> (30 + 24); } #if 0 else if (flags & SWS_X) { double p = param ? param * 0.01 : 0.3; coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0; coeff *= pow(2.0, -p * d * d); } #endif else if (flags & SWS_X) { double A = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0; double c; if (floatd < 1.0) c = cos(floatd * M_PI); else c = -1.0; if (c < 0.0) c = -pow(-c, A); else c = pow(c, A); coeff = (c * 0.5 + 0.5) * fone; } else if (flags & SWS_AREA) { int64_t d2 = d - (1 << 29); if (d2 * xInc < -(1LL << (29 + 16))) coeff = 1.0 * (1LL << (30 + 16)); else if (d2 * xInc < (1LL << (29 + 16))) coeff = -d2 * xInc + (1LL << (29 + 16)); else coeff = 0.0; coeff *= fone >> (30 + 16); } else if (flags & SWS_GAUSS) { double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (pow(2.0, -p * floatd * floatd)) * fone; } else if (flags & SWS_SINC) { coeff = (d ? sin(floatd * M_PI) / (floatd * M_PI) : 1.0) * fone; } else if (flags & SWS_LANCZOS) { double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (d ? sin(floatd * M_PI) * sin(floatd * M_PI / p) / (floatd * floatd * M_PI * M_PI / p) : 1.0) * fone; if (floatd > p) coeff = 0; } else if (flags & SWS_BILINEAR) { coeff = (1 << 30) - d; if (coeff < 0) coeff = 0; coeff *= fone >> 30; } else if (flags & SWS_SPLINE) { double p = -2.196152422706632; coeff = getSplineCoeff(1.0, 0.0, p, -p - 1.0, floatd) * fone; } else { coeff = 0.0; // GCC warning killer assert(0); } filter[i * filterSize + j] = coeff; xx++; } xDstInSrc += 2 * xInc; } } /* apply src & dst Filter to filter -> filter2 * av_free(filter); */ assert(filterSize > 0); filter2Size = filterSize; if (srcFilter) filter2Size += srcFilter->length - 1; if (dstFilter) filter2Size += dstFilter->length - 1; assert(filter2Size > 0); FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size * dstW * sizeof(*filter2), fail); for (i = 0; i < dstW; i++) { int j, k; if (srcFilter) { for (k = 0; k < srcFilter->length; k++) { for (j = 0; j < filterSize; j++) filter2[i * filter2Size + k + j] += srcFilter->coeff[k] * filter[i * filterSize + j]; } } else { for (j = 0; j < filterSize; j++) filter2[i * filter2Size + j] = filter[i * filterSize + j]; } // FIXME dstFilter (*filterPos)[i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2; } av_freep(&filter); /* try to reduce the filter-size (step1 find size and shift left) */ // Assume it is near normalized (*0.5 or *2.0 is OK but * 0.001 is not). minFilterSize = 0; for (i = dstW - 1; i >= 0; i--) { int min = filter2Size; int j; int64_t cutOff = 0.0; /* get rid of near zero elements on the left by shifting left */ for (j = 0; j < filter2Size; j++) { int k; cutOff += FFABS(filter2[i * filter2Size]); if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone) break; /* preserve monotonicity because the core can't handle the * filter otherwise */ if (i < dstW - 1 && (*filterPos)[i] >= (*filterPos)[i + 1]) break; // move filter coefficients left for (k = 1; k < filter2Size; k++) filter2[i * filter2Size + k - 1] = filter2[i * filter2Size + k]; filter2[i * filter2Size + k - 1] = 0; (*filterPos)[i]++; } cutOff = 0; /* count near zeros on the right */ for (j = filter2Size - 1; j > 0; j--) { cutOff += FFABS(filter2[i * filter2Size + j]); if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone) break; min--; } if (min > minFilterSize) minFilterSize = min; } if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) { // we can handle the special case 4, so we don't want to go the full 8 if (minFilterSize < 5) filterAlign = 4; /* We really don't want to waste our time doing useless computation, so * fall back on the scalar C code for very small filters. * Vectorizing is worth it only if you have a decent-sized vector. */ if (minFilterSize < 3) filterAlign = 1; } if (INLINE_MMX(cpu_flags)) { // special case for unscaled vertical filtering if (minFilterSize == 1 && filterAlign == 2) filterAlign = 1; } assert(minFilterSize > 0); filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1)); assert(filterSize > 0); filter = av_malloc(filterSize * dstW * sizeof(*filter)); if (filterSize >= MAX_FILTER_SIZE * 16 / ((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter) goto fail; *outFilterSize = filterSize; if (flags & SWS_PRINT_INFO) av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", filter2Size, filterSize); /* try to reduce the filter-size (step2 reduce it) */ for (i = 0; i < dstW; i++) { int j; for (j = 0; j < filterSize; j++) { if (j >= filter2Size) filter[i * filterSize + j] = 0; else filter[i * filterSize + j] = filter2[i * filter2Size + j]; if ((flags & SWS_BITEXACT) && j >= minFilterSize) filter[i * filterSize + j] = 0; } } // FIXME try to align filterPos if possible // fix borders if (is_horizontal) { for (i = 0; i < dstW; i++) { int j; if ((*filterPos)[i] < 0) { // move filter coefficients left to compensate for filterPos for (j = 1; j < filterSize; j++) { int left = FFMAX(j + (*filterPos)[i], 0); filter[i * filterSize + left] += filter[i * filterSize + j]; filter[i * filterSize + j] = 0; } (*filterPos)[i] = 0; } if ((*filterPos)[i] + filterSize > srcW) { int shift = (*filterPos)[i] + filterSize - srcW; // move filter coefficients right to compensate for filterPos for (j = filterSize - 2; j >= 0; j--) { int right = FFMIN(j + shift, filterSize - 1); filter[i * filterSize + right] += filter[i * filterSize + j]; filter[i * filterSize + j] = 0; } (*filterPos)[i] = srcW - filterSize; } } } // Note the +1 is for the MMX scaler which reads over the end /* align at 16 for AltiVec (needed by hScale_altivec_real) */ FF_ALLOCZ_OR_GOTO(NULL, *outFilter, *outFilterSize * (dstW + 3) * sizeof(int16_t), fail); /* normalize & store in outFilter */ for (i = 0; i < dstW; i++) { int j; int64_t error = 0; int64_t sum = 0; for (j = 0; j < filterSize; j++) { sum += filter[i * filterSize + j]; } sum = (sum + one / 2) / one; for (j = 0; j < *outFilterSize; j++) { int64_t v = filter[i * filterSize + j] + error; int intV = ROUNDED_DIV(v, sum); (*outFilter)[i * (*outFilterSize) + j] = intV; error = v - intV * sum; } } (*filterPos)[dstW + 0] = (*filterPos)[dstW + 1] = (*filterPos)[dstW + 2] = (*filterPos)[dstW - 1]; /* the MMX/SSE scaler will * read over the end */ for (i = 0; i < *outFilterSize; i++) { int k = (dstW - 1) * (*outFilterSize) + i; (*outFilter)[k + 1 * (*outFilterSize)] = (*outFilter)[k + 2 * (*outFilterSize)] = (*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k]; } ret = 0; fail: av_free(filter); av_free(filter2); return ret; }
25,671
1
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags) { VLCcode *buf; int i, j, ret; vlc->bits = nb_bits; if (flags & INIT_VLC_USE_NEW_STATIC) { VLC dyn_vlc = *vlc; if (vlc->table_size) return 0; ret = ff_init_vlc_sparse(&dyn_vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, symbols, symbols_wrap, symbols_size, flags & ~INIT_VLC_USE_NEW_STATIC); av_assert0(ret >= 0); av_assert0(dyn_vlc.table_size <= vlc->table_allocated); if (dyn_vlc.table_size < vlc->table_allocated) av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", dyn_vlc.table_size, vlc->table_allocated); memcpy(vlc->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*vlc->table)); vlc->table_size = dyn_vlc.table_size; ff_free_vlc(&dyn_vlc); return 0; } else { vlc->table = NULL; vlc->table_allocated = 0; vlc->table_size = 0; } av_dlog(NULL, "build table nb_codes=%d\n", nb_codes); buf = av_malloc((nb_codes + 1) * sizeof(VLCcode)); av_assert0(symbols_size <= 2 || !symbols); j = 0; #define COPY(condition)\ for (i = 0; i < nb_codes; i++) { \ GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size); \ if (!(condition)) \ continue; \ if (buf[j].bits > 3*nb_bits || buf[j].bits>32) { \ av_log(NULL, AV_LOG_ERROR, "Too long VLC (%d) in init_vlc\n", buf[j].bits);\ av_free(buf); \ return -1; \ } \ GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \ if (buf[j].code >= (1LL<<buf[j].bits)) { \ av_log(NULL, AV_LOG_ERROR, "Invalid code in init_vlc\n"); \ av_free(buf); \ return -1; \ } \ if (flags & INIT_VLC_LE) \ buf[j].code = bitswap_32(buf[j].code); \ else \ buf[j].code <<= 32 - buf[j].bits; \ if (symbols) \ GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size) \ else \ buf[j].symbol = i; \ j++; \ } COPY(buf[j].bits > nb_bits); // qsort is the slowest part of init_vlc, and could probably be improved or avoided qsort(buf, j, sizeof(VLCcode), compare_vlcspec); COPY(buf[j].bits && buf[j].bits <= nb_bits); nb_codes = j; ret = build_table(vlc, nb_bits, nb_codes, buf, flags); av_free(buf); if (ret < 0) { av_freep(&vlc->table); return ret; } return 0; }
25,673
1
static uint64_t macio_nvram_readb(void *opaque, hwaddr addr, unsigned size) { MacIONVRAMState *s = opaque; uint32_t value; addr = (addr >> s->it_shift) & (s->size - 1); value = s->data[addr]; NVR_DPRINTF("readb addr %04x val %x\n", (int)addr, value); return value; }
25,674
1
void HELPER(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val) { ARMCPU *cpu = arm_env_get_cpu(env); switch (reg) { case 0: /* APSR */ xpsr_write(env, val, 0xf8000000); break; case 1: /* IAPSR */ xpsr_write(env, val, 0xf8000000); break; case 2: /* EAPSR */ xpsr_write(env, val, 0xfe00fc00); break; case 3: /* xPSR */ xpsr_write(env, val, 0xfe00fc00); break; case 5: /* IPSR */ /* IPSR bits are readonly. */ break; case 6: /* EPSR */ xpsr_write(env, val, 0x0600fc00); break; case 7: /* IEPSR */ xpsr_write(env, val, 0x0600fc00); break; case 8: /* MSP */ if (env->v7m.current_sp) env->v7m.other_sp = val; else env->regs[13] = val; break; case 9: /* PSP */ if (env->v7m.current_sp) env->regs[13] = val; else env->v7m.other_sp = val; break; case 16: /* PRIMASK */ if (val & 1) { env->daif |= PSTATE_I; } else { env->daif &= ~PSTATE_I; } break; case 17: /* BASEPRI */ env->v7m.basepri = val & 0xff; break; case 18: /* BASEPRI_MAX */ val &= 0xff; if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0)) env->v7m.basepri = val; break; case 19: /* FAULTMASK */ if (val & 1) { env->daif |= PSTATE_F; } else { env->daif &= ~PSTATE_F; } break; case 20: /* CONTROL */ env->v7m.control = val & 3; switch_v7m_sp(env, (val & 2) != 0); break; default: /* ??? For debugging only. */ cpu_abort(CPU(cpu), "Unimplemented system register write (%d)\n", reg); return; } }
25,675
0
AVRational av_d2q(double d, int max) { AVRational a; int exponent; int64_t den; if (isnan(d)) return (AVRational) { 0,0 }; if (fabs(d) > INT_MAX + 3LL) return (AVRational) { d < 0 ? -1 : 1, 0 }; frexp(d, &exponent); exponent = FFMAX(exponent-1, 0); den = 1LL << (61 - exponent); // (int64_t)rint() and llrint() do not work with gcc on ia64 and sparc64 av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max); if ((!a.num || !a.den) && d && max>0 && max<INT_MAX) av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, INT_MAX); return a; }
25,677
0
static unsigned tget(GetByteContext *gb, int type, int le) { switch (type) { case TIFF_BYTE : return bytestream2_get_byteu(gb); case TIFF_SHORT: return tget_short(gb, le); case TIFF_LONG : return tget_long(gb, le); default : return UINT_MAX; } }
25,678
1
PCIDevice *pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn) { PCNetState *d; uint8_t *pci_conf; #if 0 printf("sizeof(RMD)=%d, sizeof(TMD)=%d\n", sizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD)); #endif d = (PCNetState *)pci_register_device(bus, "PCNet", sizeof(PCNetState), devfn, NULL, NULL); pci_conf = d->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_AMD); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_AMD_LANCE); *(uint16_t *)&pci_conf[0x04] = cpu_to_le16(0x0007); *(uint16_t *)&pci_conf[0x06] = cpu_to_le16(0x0280); pci_conf[0x08] = 0x10; pci_conf[0x09] = 0x00; pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET); pci_conf[0x0e] = 0x00; // header_type *(uint32_t *)&pci_conf[0x10] = cpu_to_le32(0x00000001); *(uint32_t *)&pci_conf[0x14] = cpu_to_le32(0x00000000); pci_conf[0x3d] = 1; // interrupt pin 0 pci_conf[0x3e] = 0x06; pci_conf[0x3f] = 0xff; /* Handler for memory-mapped I/O */ d->mmio_index = cpu_register_io_memory(0, pcnet_mmio_read, pcnet_mmio_write, d); pci_register_io_region((PCIDevice *)d, 0, PCNET_IOPORT_SIZE, PCI_ADDRESS_SPACE_IO, pcnet_ioport_map); pci_register_io_region((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE, PCI_ADDRESS_SPACE_MEM, pcnet_mmio_map); d->irq = d->dev.irq[0]; d->phys_mem_read = pci_physical_memory_read; d->phys_mem_write = pci_physical_memory_write; d->pci_dev = &d->dev; pcnet_common_init(d, nd); return (PCIDevice *)d; }
25,679
1
void aio_notify(AioContext *ctx) { /* Write e.g. bh->scheduled before reading ctx->dispatching. */ smp_mb(); if (!ctx->dispatching) { event_notifier_set(&ctx->notifier); } }
25,680
1
static void tb_invalidate_phys_page(tb_page_addr_t addr, uintptr_t pc, void *puc) { TranslationBlock *tb; PageDesc *p; int n; #ifdef TARGET_HAS_PRECISE_SMC TranslationBlock *current_tb = NULL; CPUState *cpu = current_cpu; CPUArchState *env = NULL; int current_tb_modified = 0; target_ulong current_pc = 0; target_ulong current_cs_base = 0; int current_flags = 0; #endif addr &= TARGET_PAGE_MASK; p = page_find(addr >> TARGET_PAGE_BITS); if (!p) { return; } tb = p->first_tb; #ifdef TARGET_HAS_PRECISE_SMC if (tb && pc != 0) { current_tb = tb_find_pc(pc); } if (cpu != NULL) { env = cpu->env_ptr; } #endif while (tb != NULL) { n = (uintptr_t)tb & 3; tb = (TranslationBlock *)((uintptr_t)tb & ~3); #ifdef TARGET_HAS_PRECISE_SMC if (current_tb == tb && (current_tb->cflags & CF_COUNT_MASK) != 1) { /* If we are modifying the current TB, we must stop its execution. We could be more precise by checking that the modification is after the current PC, but it would require a specialized function to partially restore the CPU state */ current_tb_modified = 1; cpu_restore_state_from_tb(current_tb, env, pc); cpu_get_tb_cpu_state(env, &current_pc, &current_cs_base, &current_flags); } #endif /* TARGET_HAS_PRECISE_SMC */ tb_phys_invalidate(tb, addr); tb = tb->page_next[n]; } p->first_tb = NULL; #ifdef TARGET_HAS_PRECISE_SMC if (current_tb_modified) { /* we generate a block containing just the instruction modifying the memory. It will ensure that it cannot modify itself */ cpu->current_tb = NULL; tb_gen_code(env, current_pc, current_cs_base, current_flags, 1); cpu_resume_from_signal(env, puc); } #endif }
25,681
1
static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf) { int au_headers_length, au_header_size, i; GetBitContext getbitcontext; /* decode the first 2 bytes where the AUHeader sections are stored length in bits */ au_headers_length = AV_RB16(buf); if (au_headers_length > RTP_MAX_PACKET_LENGTH) return -1; data->au_headers_length_bytes = (au_headers_length + 7) / 8; /* skip AU headers length section (2 bytes) */ buf += 2; init_get_bits(&getbitcontext, buf, data->au_headers_length_bytes * 8); /* XXX: Wrong if optionnal additional sections are present (cts, dts etc...) */ au_header_size = data->sizelength + data->indexlength; if (au_header_size <= 0 || (au_headers_length % au_header_size != 0)) return -1; data->nb_au_headers = au_headers_length / au_header_size; if (!data->au_headers || data->au_headers_allocated < data->nb_au_headers) { av_free(data->au_headers); data->au_headers = av_malloc(sizeof(struct AUHeaders) * data->nb_au_headers); if (!data->au_headers) return AVERROR(ENOMEM); data->au_headers_allocated = data->nb_au_headers; } /* XXX: We handle multiple AU Section as only one (need to fix this for interleaving) In my test, the FAAD decoder does not behave correctly when sending each AU one by one but does when sending the whole as one big packet... */ data->au_headers[0].size = 0; data->au_headers[0].index = 0; for (i = 0; i < data->nb_au_headers; ++i) { data->au_headers[0].size += get_bits_long(&getbitcontext, data->sizelength); data->au_headers[0].index = get_bits_long(&getbitcontext, data->indexlength); } data->nb_au_headers = 1; return 0; }
25,683
1
static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width, uint32_t *pal) { int i; assert(src1 == src2); for(i=0; i<width; i++) { int p= pal[src1[i]]; dstU[i]= p>>8; dstV[i]= p>>16; } }
25,684
1
static uint64_t pl011_read(void *opaque, target_phys_addr_t offset, unsigned size) { pl011_state *s = (pl011_state *)opaque; uint32_t c; if (offset >= 0xfe0 && offset < 0x1000) { return s->id[(offset - 0xfe0) >> 2]; } switch (offset >> 2) { case 0: /* UARTDR */ s->flags &= ~PL011_FLAG_RXFF; c = s->read_fifo[s->read_pos]; if (s->read_count > 0) { s->read_count--; if (++s->read_pos == 16) s->read_pos = 0; } if (s->read_count == 0) { s->flags |= PL011_FLAG_RXFE; } if (s->read_count == s->read_trigger - 1) s->int_level &= ~ PL011_INT_RX; pl011_update(s); qemu_chr_accept_input(s->chr); return c; case 1: /* UARTCR */ return 0; case 6: /* UARTFR */ return s->flags; case 8: /* UARTILPR */ return s->ilpr; case 9: /* UARTIBRD */ return s->ibrd; case 10: /* UARTFBRD */ return s->fbrd; case 11: /* UARTLCR_H */ return s->lcr; case 12: /* UARTCR */ return s->cr; case 13: /* UARTIFLS */ return s->ifl; case 14: /* UARTIMSC */ return s->int_enabled; case 15: /* UARTRIS */ return s->int_level; case 16: /* UARTMIS */ return s->int_level & s->int_enabled; case 18: /* UARTDMACR */ return s->dmacr; default: hw_error("pl011_read: Bad offset %x\n", (int)offset); return 0; } }
25,685
1
static void icp_pit_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { icp_pit_state *s = (icp_pit_state *)opaque; int n; n = offset >> 8; if (n > 2) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad timer %d\n", __func__, n); } arm_timer_write(s->timer[n], offset & 0xff, value); }
25,688
1
static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, uint8_t *dst, int w, int h, int stride, int bpp) { int i, x, y; int depth = (bpp + 1) >> 3; int type, count; int diff; diff = stride - w * depth; x = y = 0; while(y < h){ type = *src++; count = (type & 0x7F) + 1; type &= 0x80; if((x + count > w) && (x + count + 1 > (h - y) * w)){ av_log(avctx, AV_LOG_ERROR, "Packet went out of bounds: position (%i,%i) size %i\n", x, y, count); return; } for(i = 0; i < count; i++){ switch(depth){ case 1: *dst = *src; break; case 2: *((uint16_t*)dst) = AV_RL16(src); break; case 3: dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2]; break; case 4: *((uint32_t*)dst) = AV_RL32(src); break; } dst += depth; if(!type) src += depth; x++; if(x == w){ x = 0; y++; dst += diff; } } if(type) src += depth; } }
25,689
1
static int aasc_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AascContext *s = avctx->priv_data; int compr, i, stride, psize; s->frame.reference = 3; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if (avctx->reget_buffer(avctx, &s->frame)) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; compr = AV_RL32(buf); buf += 4; buf_size -= 4; psize = avctx->bits_per_coded_sample / 8; switch (avctx->codec_tag) { case MKTAG('A', 'A', 'S', '4'): bytestream2_init(&s->gb, buf - 4, buf_size + 4); ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb); break; case MKTAG('A', 'A', 'S', 'C'): switch(compr){ case 0: stride = (avctx->width * psize + psize) & ~psize; for(i = avctx->height - 1; i >= 0; i--){ if(avctx->width * psize > buf_size){ av_log(avctx, AV_LOG_ERROR, "Next line is beyond buffer bounds\n"); break; memcpy(s->frame.data[0] + i*s->frame.linesize[0], buf, avctx->width * psize); buf += stride; buf_size -= stride; break; case 1: bytestream2_init(&s->gb, buf, buf_size); ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb); break; default: av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr); return -1; break; default: av_log(avctx, AV_LOG_ERROR, "Unknown FourCC: %X\n", avctx->codec_tag); return -1; if (avctx->pix_fmt == AV_PIX_FMT_PAL8) memcpy(s->frame.data[1], s->palette, s->palette_size); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; /* report that the buffer was completely consumed */ return buf_size;
25,690
1
int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset, int64_t size) { int ret = qcow2_check_metadata_overlap(bs, ign, offset, size); if (ret < 0) { return ret; } else if (ret > 0) { int metadata_ol_bitnr = ffs(ret) - 1; char *message; assert(metadata_ol_bitnr < QCOW2_OL_MAX_BITNR); fprintf(stderr, "qcow2: Preventing invalid write on metadata (overlaps " "with %s); image marked as corrupt.\n", metadata_ol_names[metadata_ol_bitnr]); message = g_strdup_printf("Prevented %s overwrite", metadata_ol_names[metadata_ol_bitnr]); qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs), message, true, offset, true, size, true, &error_abort); g_free(message); qcow2_mark_corrupt(bs); bs->drv = NULL; /* make BDS unusable */ return -EIO; } return 0; }
25,691
1
static int dmg_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVDMGState *s = bs->opaque; uint64_t info_begin, info_end, last_in_offset, last_out_offset; uint32_t count, tmp; uint32_t max_compressed_size = 1, max_sectors_per_chunk = 1, i; int64_t offset; int ret; bs->read_only = 1; s->n_chunks = 0; s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; /* read offset of info blocks */ offset = bdrv_getlength(bs->file); if (offset < 0) { ret = offset; offset -= 0x1d8; ret = read_uint64(bs, offset, &info_begin); if (ret < 0) { } else if (info_begin == 0) { ret = read_uint32(bs, info_begin, &tmp); if (ret < 0) { } else if (tmp != 0x100) { ret = read_uint32(bs, info_begin + 4, &count); if (ret < 0) { } else if (count == 0) { info_end = info_begin + count; offset = info_begin + 0x100; /* read offsets */ last_in_offset = last_out_offset = 0; while (offset < info_end) { uint32_t type; ret = read_uint32(bs, offset, &count); if (ret < 0) { } else if (count == 0) { offset += 4; ret = read_uint32(bs, offset, &type); if (ret < 0) { if (type == 0x6d697368 && count >= 244) { size_t new_size; uint32_t chunk_count; offset += 4; offset += 200; chunk_count = (count - 204) / 40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); s->types = g_realloc(s->types, new_size / 2); s->offsets = g_realloc(s->offsets, new_size); s->lengths = g_realloc(s->lengths, new_size); s->sectors = g_realloc(s->sectors, new_size); s->sectorcounts = g_realloc(s->sectorcounts, new_size); for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) { ret = read_uint32(bs, offset, &s->types[i]); if (ret < 0) { offset += 4; if (s->types[i] != 0x80000005 && s->types[i] != 1 && s->types[i] != 2) { if (s->types[i] == 0xffffffff && i > 0) { last_in_offset = s->offsets[i - 1] + s->lengths[i - 1]; last_out_offset = s->sectors[i - 1] + s->sectorcounts[i - 1]; chunk_count--; i--; offset += 36; continue; offset += 4; ret = read_uint64(bs, offset, &s->sectors[i]); if (ret < 0) { s->sectors[i] += last_out_offset; offset += 8; ret = read_uint64(bs, offset, &s->sectorcounts[i]); if (ret < 0) { offset += 8; if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { error_report("sector count %" PRIu64 " for chunk %u is " "larger than max (%u)", s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); ret = read_uint64(bs, offset, &s->offsets[i]); if (ret < 0) { s->offsets[i] += last_in_offset; offset += 8; ret = read_uint64(bs, offset, &s->lengths[i]); if (ret < 0) { offset += 8; if (s->lengths[i] > max_compressed_size) { max_compressed_size = s->lengths[i]; if (s->sectorcounts[i] > max_sectors_per_chunk) { max_sectors_per_chunk = s->sectorcounts[i]; s->n_chunks += chunk_count; /* initialize zlib engine */ s->compressed_chunk = g_malloc(max_compressed_size + 1); s->uncompressed_chunk = g_malloc(512 * max_sectors_per_chunk); if (inflateInit(&s->zstream) != Z_OK) { s->current_chunk = s->n_chunks; qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->types); g_free(s->offsets); g_free(s->lengths); g_free(s->sectors); g_free(s->sectorcounts); g_free(s->compressed_chunk); g_free(s->uncompressed_chunk); return ret;
25,692
0
int ff_mjpeg_decode_sof(MJpegDecodeContext *s) { int len, nb_components, i, width, height, pix_fmt_id; s->cur_scan = 0; s->upscale_h = s->upscale_v = 0; /* XXX: verify len field validity */ len = get_bits(&s->gb, 16); s->bits = get_bits(&s->gb, 8); if (s->pegasus_rct) s->bits = 9; if (s->bits == 9 && !s->pegasus_rct) s->rct = 1; // FIXME ugly if (s->bits != 8 && !s->lossless) { av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n"); return -1; } if(s->lossless && s->avctx->lowres){ av_log(s->avctx, AV_LOG_ERROR, "lowres is not possible with lossless jpeg\n"); return -1; } height = get_bits(&s->gb, 16); width = get_bits(&s->gb, 16); // HACK for odd_height.mov if (s->interlaced && s->width == width && s->height == height + 1) height= s->height; av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height); if (av_image_check_size(width, height, 0, s->avctx)) return AVERROR_INVALIDDATA; nb_components = get_bits(&s->gb, 8); if (nb_components <= 0 || nb_components > MAX_COMPONENTS) return -1; if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) { if (nb_components != s->nb_components) { av_log(s->avctx, AV_LOG_ERROR, "nb_components changing in interlaced picture\n"); return AVERROR_INVALIDDATA; } } if (s->ls && !(s->bits <= 8 || nb_components == 1)) { av_log_missing_feature(s->avctx, "For JPEG-LS anything except <= 8 bits/component" " or 16-bit gray", 0); return AVERROR_PATCHWELCOME; } s->nb_components = nb_components; s->h_max = 1; s->v_max = 1; memset(s->h_count, 0, sizeof(s->h_count)); memset(s->v_count, 0, sizeof(s->v_count)); for (i = 0; i < nb_components; i++) { /* component id */ s->component_id[i] = get_bits(&s->gb, 8) - 1; s->h_count[i] = get_bits(&s->gb, 4); s->v_count[i] = get_bits(&s->gb, 4); /* compute hmax and vmax (only used in interleaved case) */ if (s->h_count[i] > s->h_max) s->h_max = s->h_count[i]; if (s->v_count[i] > s->v_max) s->v_max = s->v_count[i]; if (!s->h_count[i] || !s->v_count[i]) { av_log(s->avctx, AV_LOG_ERROR, "h/v_count is 0\n"); return -1; } s->quant_index[i] = get_bits(&s->gb, 8); if (s->quant_index[i] >= 4) return AVERROR_INVALIDDATA; av_log(s->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n", i, s->h_count[i], s->v_count[i], s->component_id[i], s->quant_index[i]); } if (s->ls && (s->h_max > 1 || s->v_max > 1)) { av_log_missing_feature(s->avctx, "Subsampling in JPEG-LS", 0); return AVERROR_PATCHWELCOME; } if (s->v_max == 1 && s->h_max == 1 && s->lossless==1 && nb_components==3) s->rgb = 1; /* if different size, realloc/alloc picture */ /* XXX: also check h_count and v_count */ if (width != s->width || height != s->height) { av_freep(&s->qscale_table); s->width = width; s->height = height; s->interlaced = 0; /* test interlaced mode */ if (s->first_picture && s->org_height != 0 && s->height < ((s->org_height * 3) / 4)) { s->interlaced = 1; s->bottom_field = s->interlace_polarity; s->picture_ptr->interlaced_frame = 1; s->picture_ptr->top_field_first = !s->interlace_polarity; height *= 2; } avcodec_set_dimensions(s->avctx, width, height); s->qscale_table = av_mallocz((s->width + 15) / 16); s->first_picture = 0; } if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) { if (s->progressive) { av_log_ask_for_sample(s->avctx, "progressively coded interlaced pictures not supported\n"); return AVERROR_INVALIDDATA; } } else{ /* XXX: not complete test ! */ pix_fmt_id = (s->h_count[0] << 28) | (s->v_count[0] << 24) | (s->h_count[1] << 20) | (s->v_count[1] << 16) | (s->h_count[2] << 12) | (s->v_count[2] << 8) | (s->h_count[3] << 4) | s->v_count[3]; av_log(s->avctx, AV_LOG_DEBUG, "pix fmt id %x\n", pix_fmt_id); /* NOTE we do not allocate pictures large enough for the possible * padding of h/v_count being 4 */ if (!(pix_fmt_id & 0xD0D0D0D0)) pix_fmt_id -= (pix_fmt_id & 0xF0F0F0F0) >> 1; if (!(pix_fmt_id & 0x0D0D0D0D)) pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1; switch (pix_fmt_id) { case 0x11111100: if (s->rgb) s->avctx->pix_fmt = AV_PIX_FMT_BGR24; else { if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') { s->avctx->pix_fmt = AV_PIX_FMT_GBR24P; } else { s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; } } av_assert0(s->nb_components == 3); break; case 0x12121100: case 0x22122100: s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; s->upscale_v = 2; s->upscale_h = (pix_fmt_id == 0x22122100); s->chroma_height = s->height; break; case 0x21211100: case 0x22211200: s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; s->upscale_v = (pix_fmt_id == 0x22211200); s->upscale_h = 2; s->chroma_height = s->height; break; case 0x22221100: s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; s->upscale_v = 2; s->upscale_h = 2; s->chroma_height = s->height / 2; break; case 0x11000000: if(s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GRAY8; else s->avctx->pix_fmt = AV_PIX_FMT_GRAY16; break; case 0x12111100: case 0x22211100: case 0x22112100: s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; s->upscale_h = (pix_fmt_id == 0x22211100) * 2 + (pix_fmt_id == 0x22112100); s->chroma_height = s->height / 2; break; case 0x21111100: s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; break; case 0x22121100: case 0x22111200: s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; s->upscale_v = (pix_fmt_id == 0x22121100) + 1; break; case 0x22111100: s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; break; default: av_log(s->avctx, AV_LOG_ERROR, "Unhandled pixel format 0x%x\n", pix_fmt_id); return AVERROR_PATCHWELCOME; } if ((s->upscale_h || s->upscale_v) && s->avctx->lowres) { av_log(s->avctx, AV_LOG_ERROR, "lowres not supported for weird subsampling\n"); return AVERROR_PATCHWELCOME; } if (s->ls) { s->upscale_h = s->upscale_v = 0; if (s->nb_components > 1) s->avctx->pix_fmt = AV_PIX_FMT_RGB24; else if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GRAY8; else s->avctx->pix_fmt = AV_PIX_FMT_GRAY16; } if (s->picture_ptr->data[0]) s->avctx->release_buffer(s->avctx, s->picture_ptr); if (s->avctx->get_buffer(s->avctx, s->picture_ptr) < 0) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } s->picture_ptr->pict_type = AV_PICTURE_TYPE_I; s->picture_ptr->key_frame = 1; s->got_picture = 1; for (i = 0; i < 3; i++) s->linesize[i] = s->picture_ptr->linesize[i] << s->interlaced; av_dlog(s->avctx, "%d %d %d %d %d %d\n", s->width, s->height, s->linesize[0], s->linesize[1], s->interlaced, s->avctx->height); if (len != (8 + (3 * nb_components))) av_log(s->avctx, AV_LOG_DEBUG, "decode_sof0: error, len(%d) mismatch\n", len); } /* totally blank picture as progressive JPEG will only add details to it */ if (s->progressive) { int bw = (width + s->h_max * 8 - 1) / (s->h_max * 8); int bh = (height + s->v_max * 8 - 1) / (s->v_max * 8); for (i = 0; i < s->nb_components; i++) { int size = bw * bh * s->h_count[i] * s->v_count[i]; av_freep(&s->blocks[i]); av_freep(&s->last_nnz[i]); s->blocks[i] = av_malloc(size * sizeof(**s->blocks)); s->last_nnz[i] = av_mallocz(size * sizeof(**s->last_nnz)); s->block_stride[i] = bw * s->h_count[i]; } memset(s->coefs_finished, 0, sizeof(s->coefs_finished)); } return 0; }
25,695
0
void bdrv_set_on_error(BlockDriverState *bs, BlockdevOnError on_read_error, BlockdevOnError on_write_error) { bs->on_read_error = on_read_error; bs->on_write_error = on_write_error; }
25,696
0
static void test_acpi_one(const char *params, test_data *data) { char *args; uint8_t signature_low; uint8_t signature_high; uint16_t signature; int i; const char *device = ""; if (!g_strcmp0(data->machine, MACHINE_Q35)) { device = ",id=hd -device ide-hd,drive=hd"; } args = g_strdup_printf("-net none -display none %s -drive file=%s%s,", params ? params : "", disk, device); qtest_start(args); /* Wait at most 1 minute */ #define TEST_DELAY (1 * G_USEC_PER_SEC / 10) #define TEST_CYCLES MAX((60 * G_USEC_PER_SEC / TEST_DELAY), 1) /* Poll until code has run and modified memory. Once it has we know BIOS * initialization is done. TODO: check that IP reached the halt * instruction. */ for (i = 0; i < TEST_CYCLES; ++i) { signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET); signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1); signature = (signature_high << 8) | signature_low; if (signature == SIGNATURE) { break; } g_usleep(TEST_DELAY); } g_assert_cmphex(signature, ==, SIGNATURE); test_acpi_rsdp_address(data); test_acpi_rsdp_table(data); test_acpi_rsdt_table(data); test_acpi_fadt_table(data); test_acpi_facs_table(data); test_acpi_dsdt_table(data); test_acpi_ssdt_tables(data); if (iasl) { test_acpi_asl(data); } qtest_quit(global_qtest); g_free(args); }
25,697
0
static void rocker_io_writel(void *opaque, hwaddr addr, uint32_t val) { Rocker *r = opaque; if (rocker_addr_is_desc_reg(r, addr)) { unsigned index = ROCKER_RING_INDEX(addr); unsigned offset = addr & ROCKER_DMA_DESC_MASK; switch (offset) { case ROCKER_DMA_DESC_ADDR_OFFSET: r->lower32 = (uint64_t)val; break; case ROCKER_DMA_DESC_ADDR_OFFSET + 4: desc_ring_set_base_addr(r->rings[index], ((uint64_t)val) << 32 | r->lower32); r->lower32 = 0; break; case ROCKER_DMA_DESC_SIZE_OFFSET: desc_ring_set_size(r->rings[index], val); break; case ROCKER_DMA_DESC_HEAD_OFFSET: if (desc_ring_set_head(r->rings[index], val)) { rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[index])); } break; case ROCKER_DMA_DESC_CTRL_OFFSET: desc_ring_set_ctrl(r->rings[index], val); break; case ROCKER_DMA_DESC_CREDITS_OFFSET: if (desc_ring_ret_credits(r->rings[index], val)) { rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[index])); } break; default: DPRINTF("not implemented dma reg write(l) addr=0x" TARGET_FMT_plx " val=0x%08x (ring %d, addr=0x%02x)\n", addr, val, index, offset); break; } return; } switch (addr) { case ROCKER_TEST_REG: r->test_reg = val; break; case ROCKER_TEST_REG64: case ROCKER_TEST_DMA_ADDR: case ROCKER_PORT_PHYS_ENABLE: r->lower32 = (uint64_t)val; break; case ROCKER_TEST_REG64 + 4: r->test_reg64 = ((uint64_t)val) << 32 | r->lower32; r->lower32 = 0; break; case ROCKER_TEST_IRQ: rocker_msix_irq(r, val); break; case ROCKER_TEST_DMA_SIZE: r->test_dma_size = val; break; case ROCKER_TEST_DMA_ADDR + 4: r->test_dma_addr = ((uint64_t)val) << 32 | r->lower32; r->lower32 = 0; break; case ROCKER_TEST_DMA_CTRL: rocker_test_dma_ctrl(r, val); break; case ROCKER_CONTROL: rocker_control(r, val); break; case ROCKER_PORT_PHYS_ENABLE + 4: rocker_port_phys_enable_write(r, ((uint64_t)val) << 32 | r->lower32); r->lower32 = 0; break; default: DPRINTF("not implemented write(l) addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, val); break; } }
25,698
0
build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets) { AcpiRsdtDescriptorRev1 *rsdt; size_t rsdt_len; int i; const int table_data_len = (sizeof(uint32_t) * table_offsets->len); rsdt_len = sizeof(*rsdt) + table_data_len; rsdt = acpi_data_push(table_data, rsdt_len); memcpy(rsdt->table_offset_entry, table_offsets->data, table_data_len); for (i = 0; i < table_offsets->len; ++i) { /* rsdt->table_offset_entry to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, table_data, &rsdt->table_offset_entry[i], sizeof(uint32_t)); } build_header(linker, table_data, (void *)rsdt, "RSDT", rsdt_len, 1, NULL, NULL); }
25,699
0
int nbd_client_session_co_writev(NbdClientSession *client, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { int offset = 0; int ret; while (nb_sectors > NBD_MAX_SECTORS) { ret = nbd_co_writev_1(client, sector_num, NBD_MAX_SECTORS, qiov, offset); if (ret < 0) { return ret; } offset += NBD_MAX_SECTORS * 512; sector_num += NBD_MAX_SECTORS; nb_sectors -= NBD_MAX_SECTORS; } return nbd_co_writev_1(client, sector_num, nb_sectors, qiov, offset); }
25,700
0
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; bool dbd; int page, buflen, ret, page_control; uint8_t *p; uint8_t dev_specific_param; dbd = (r->req.cmd.buf[1] & 0x8) != 0; 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 (s->qdev.type == TYPE_DISK) { dev_specific_param = s->features & (1 << SCSI_DISK_F_DPOFUA) ? 0x10 : 0; if (bdrv_is_read_only(s->qdev.conf.bs)) { dev_specific_param |= 0x80; /* Readonly. */ } } else { /* MMC prescribes that CD/DVD drives have no block descriptors, * and defines no device-specific parameter. */ dev_specific_param = 0x00; dbd = true; } 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; } bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!dbd && 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; } return buflen; }
25,701
0
static void qemu_chr_parse_pipe(QemuOpts *opts, ChardevBackend *backend, Error **errp) { const char *device = qemu_opt_get(opts, "path"); ChardevHostdev *dev; if (device == NULL) { error_setg(errp, "chardev: pipe: no device path given"); return; } dev = backend->u.pipe = g_new0(ChardevHostdev, 1); qemu_chr_parse_common(opts, qapi_ChardevHostdev_base(dev)); dev->device = g_strdup(device); }
25,702
0
static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st = c->fc->streams[c->fc->nb_streams-1]; MOVStreamContext *sc = st->priv_data; unsigned int i, entries; int64_t duration=0; int64_t total_sample_count=0; get_byte(pb); /* version */ get_be24(pb); /* flags */ entries = get_be32(pb); dprintf(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries); if(entries >= UINT_MAX / sizeof(*sc->stts_data)) return -1; sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data)); if (!sc->stts_data) return AVERROR(ENOMEM); sc->stts_count = entries; for(i=0; i<entries; i++) { int sample_duration; int sample_count; sample_count=get_be32(pb); sample_duration = get_be32(pb); sc->stts_data[i].count= sample_count; sc->stts_data[i].duration= sample_duration; dprintf(c->fc, "sample_count=%d, sample_duration=%d\n",sample_count,sample_duration); duration+=(int64_t)sample_duration*sample_count; total_sample_count+=sample_count; } st->nb_frames= total_sample_count; if(duration) st->duration= duration; return 0; }
25,703
0
static void bt_submit_sco(struct HCIInfo *info, const uint8_t *data, int length) { struct bt_hci_s *hci = hci_from_info(info); uint16_t handle; int datalen; if (length < 3) return; handle = acl_handle((data[1] << 8) | data[0]); datalen = data[2]; length -= 3; if (bt_hci_handle_bad(hci, handle)) { fprintf(stderr, "%s: invalid SCO handle %03x\n", __FUNCTION__, handle); return; } if (datalen > length) { fprintf(stderr, "%s: SCO packet too short (%iB < %iB)\n", __FUNCTION__, length, datalen); return; } /* TODO */ /* TODO: increase counter and send EVT_NUM_COMP_PKTS if synchronous * Flow Control is enabled. * (See Read/Write_Synchronous_Flow_Control_Enable on page 513 and * page 514.) */ }
25,705
0
static void do_v7m_exception_exit(ARMCPU *cpu) { CPUARMState *env = &cpu->env; uint32_t type; uint32_t xpsr; bool ufault = false; bool return_to_sp_process = false; bool return_to_handler = false; bool rettobase = false; /* We can only get here from an EXCP_EXCEPTION_EXIT, and * gen_bx_excret() enforces the architectural rule * that jumps to magic addresses don't have magic behaviour unless * we're in Handler mode (compare pseudocode BXWritePC()). */ assert(arm_v7m_is_handler_mode(env)); /* In the spec pseudocode ExceptionReturn() is called directly * from BXWritePC() and gets the full target PC value including * bit zero. In QEMU's implementation we treat it as a normal * jump-to-register (which is then caught later on), and so split * the target value up between env->regs[15] and env->thumb in * gen_bx(). Reconstitute it. */ type = env->regs[15]; if (env->thumb) { type |= 1; } qemu_log_mask(CPU_LOG_INT, "Exception return: magic PC %" PRIx32 " previous exception %d\n", type, env->v7m.exception); if (extract32(type, 5, 23) != extract32(-1, 5, 23)) { qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero high bits in exception " "exit PC value 0x%" PRIx32 " are UNPREDICTABLE\n", type); } if (env->v7m.exception != ARMV7M_EXCP_NMI) { /* Auto-clear FAULTMASK on return from other than NMI. * If the security extension is implemented then this only * happens if the raw execution priority is >= 0; the * value of the ES bit in the exception return value indicates * which security state's faultmask to clear. (v8M ARM ARM R_KBNF.) */ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { int es = type & 1; if (armv7m_nvic_raw_execution_priority(env->nvic) >= 0) { env->v7m.faultmask[es] = 0; } } else { env->v7m.faultmask[M_REG_NS] = 0; } } switch (armv7m_nvic_complete_irq(env->nvic, env->v7m.exception)) { case -1: /* attempt to exit an exception that isn't active */ ufault = true; break; case 0: /* still an irq active now */ break; case 1: /* we returned to base exception level, no nesting. * (In the pseudocode this is written using "NestedActivation != 1" * where we have 'rettobase == false'.) */ rettobase = true; break; default: g_assert_not_reached(); } switch (type & 0xf) { case 1: /* Return to Handler */ return_to_handler = true; break; case 13: /* Return to Thread using Process stack */ return_to_sp_process = true; /* fall through */ case 9: /* Return to Thread using Main stack */ if (!rettobase && !(env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_NONBASETHRDENA_MASK)) { ufault = true; } break; default: ufault = true; } if (ufault) { /* Bad exception return: instead of popping the exception * stack, directly take a usage fault on the current stack. */ env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK; armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); v7m_exception_taken(cpu, type | 0xf0000000); qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " "stackframe: failed exception return integrity check\n"); return; } /* Switch to the target stack. */ switch_v7m_sp(env, return_to_sp_process); /* Pop registers. */ env->regs[0] = v7m_pop(env); env->regs[1] = v7m_pop(env); env->regs[2] = v7m_pop(env); env->regs[3] = v7m_pop(env); env->regs[12] = v7m_pop(env); env->regs[14] = v7m_pop(env); env->regs[15] = v7m_pop(env); if (env->regs[15] & 1) { qemu_log_mask(LOG_GUEST_ERROR, "M profile return from interrupt with misaligned " "PC is UNPREDICTABLE\n"); /* Actual hardware seems to ignore the lsbit, and there are several * RTOSes out there which incorrectly assume the r15 in the stack * frame should be a Thumb-style "lsbit indicates ARM/Thumb" value. */ env->regs[15] &= ~1U; } xpsr = v7m_pop(env); xpsr_write(env, xpsr, ~XPSR_SPREALIGN); /* Undo stack alignment. */ if (xpsr & XPSR_SPREALIGN) { env->regs[13] |= 4; } /* The restored xPSR exception field will be zero if we're * resuming in Thread mode. If that doesn't match what the * exception return type specified then this is a UsageFault. */ if (return_to_handler != arm_v7m_is_handler_mode(env)) { /* Take an INVPC UsageFault by pushing the stack again. */ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK; v7m_push_stack(cpu); v7m_exception_taken(cpu, type | 0xf0000000); qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on new stackframe: " "failed exception return integrity check\n"); return; } /* Otherwise, we have a successful exception exit. */ qemu_log_mask(CPU_LOG_INT, "...successful exception return\n"); }
25,707
0
static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int refcount_table_size, int64_t l2_offset, int flags) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table, l2_entry; uint64_t next_contiguous_offset = 0; int i, l2_size, nb_csectors; /* Read L2 table from disk */ l2_size = s->l2_size * sizeof(uint64_t); l2_table = g_malloc(l2_size); if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size) goto fail; /* Do the actual checks */ for(i = 0; i < s->l2_size; i++) { l2_entry = be64_to_cpu(l2_table[i]); switch (qcow2_get_cluster_type(l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: /* Compressed clusters don't have QCOW_OFLAG_COPIED */ if (l2_entry & QCOW_OFLAG_COPIED) { fprintf(stderr, "ERROR: cluster %" PRId64 ": " "copied flag must never be set for compressed " "clusters\n", l2_entry >> s->cluster_bits); l2_entry &= ~QCOW_OFLAG_COPIED; res->corruptions++; } /* Mark cluster as used */ nb_csectors = ((l2_entry >> s->csize_shift) & s->csize_mask) + 1; l2_entry &= s->cluster_offset_mask; inc_refcounts(bs, res, refcount_table, refcount_table_size, l2_entry & ~511, nb_csectors * 512); if (flags & CHECK_FRAG_INFO) { res->bfi.allocated_clusters++; res->bfi.compressed_clusters++; /* Compressed clusters are fragmented by nature. Since they * take up sub-sector space but we only have sector granularity * I/O we need to re-read the same sectors even for adjacent * compressed clusters. */ res->bfi.fragmented_clusters++; } break; case QCOW2_CLUSTER_ZERO: if ((l2_entry & L2E_OFFSET_MASK) == 0) { break; } /* fall through */ case QCOW2_CLUSTER_NORMAL: { uint64_t offset = l2_entry & L2E_OFFSET_MASK; if (flags & CHECK_FRAG_INFO) { res->bfi.allocated_clusters++; if (next_contiguous_offset && offset != next_contiguous_offset) { res->bfi.fragmented_clusters++; } next_contiguous_offset = offset + s->cluster_size; } /* Mark cluster as used */ inc_refcounts(bs, res, refcount_table,refcount_table_size, offset, s->cluster_size); /* Correct offsets are cluster aligned */ if (offset_into_cluster(s, offset)) { fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not " "properly aligned; L2 entry corrupted.\n", offset); res->corruptions++; } break; } case QCOW2_CLUSTER_UNALLOCATED: break; default: abort(); } } g_free(l2_table); return 0; fail: fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); g_free(l2_table); return -EIO; }
25,708
0
static inline void gen_op_fcmpq(int fccno) { switch (fccno) { case 0: gen_helper_fcmpq(cpu_env); break; case 1: gen_helper_fcmpq_fcc1(cpu_env); break; case 2: gen_helper_fcmpq_fcc2(cpu_env); break; case 3: gen_helper_fcmpq_fcc3(cpu_env); break; } }
25,709
0
static int proxy_closedir(FsContext *ctx, V9fsFidOpenState *fs) { return closedir(fs->dir); }
25,712
1
static int ne2000_can_receive(void *opaque) { NE2000State *s = opaque; int avail, index, boundary; if (s->cmd & E8390_STOP) return 0; index = s->curpag << 8; boundary = s->boundary << 8; if (index < boundary) avail = boundary - index; else avail = (s->stop - s->start) - (index - boundary); if (avail < (MAX_ETH_FRAME_SIZE + 4)) return 0; return MAX_ETH_FRAME_SIZE; }
25,715
1
static void test_qemu_strtoll_invalid(void) { const char *str = " xxxx \t abc"; char f = 'X'; const char *endptr = &f; int64_t res = 999; int err; err = qemu_strtoll(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert(endptr == str); }
25,716
1
static int decode_i_picture_secondary_header(VC9Context *v) { int status; #if HAS_ADVANCED_PROFILE if (v->profile > PROFILE_MAIN) { v->s.ac_pred = get_bits(&v->s.gb, 1); if (v->postprocflag) v->postproc = get_bits(&v->s.gb, 1); /* 7.1.1.34 + 8.5.2 */ if (v->overlap && v->pq<9) { v->condover = get_bits(&v->s.gb, 1); if (v->condover) { v->condover = 2+get_bits(&v->s.gb, 1); if (v->condover == 3) { status = bitplane_decoding(&v->over_flags_plane, v); if (status < 0) return -1; # if TRACE av_log(v->s.avctx, AV_LOG_DEBUG, "Overflags plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); # endif } } } } #endif /* Epilog (AC/DC syntax) should be done in caller */ return 0; }
25,718
1
void visit_type_enum(Visitor *v, int *obj, const char *strings[], const char *kind, const char *name, Error **errp) { if (!error_is_set(errp)) { v->type_enum(v, obj, strings, kind, name, errp); } }
25,719
1
static AVStream *get_subtitle_pkt(AVFormatContext *s, AVStream *next_st, AVPacket *pkt) { AVIStream *ast, *next_ast = next_st->priv_data; int64_t ts, next_ts, ts_min = INT64_MAX; AVStream *st, *sub_st = NULL; int i; next_ts = av_rescale_q(next_ast->frame_offset, next_st->time_base, AV_TIME_BASE_Q); for (i=0; i<s->nb_streams; i++) { st = s->streams[i]; ast = st->priv_data; if (st->discard < AVDISCARD_ALL && ast->sub_pkt.data) { ts = av_rescale_q(ast->sub_pkt.dts, st->time_base, AV_TIME_BASE_Q); if (ts <= next_ts && ts < ts_min) { ts_min = ts; sub_st = st; } } } if (sub_st) { ast = sub_st->priv_data; *pkt = ast->sub_pkt; pkt->stream_index = sub_st->index; if (av_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0) ast->sub_pkt.data = NULL; } return sub_st; }
25,720
1
static void adb_keyboard_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { KBDState *s = (KBDState *)dev; int qcode, keycode; qcode = qemu_input_key_value_to_qcode(evt->u.key.data->key); if (qcode >= ARRAY_SIZE(qcode_to_adb_keycode)) { return; } /* FIXME: take handler into account when translating qcode */ keycode = qcode_to_adb_keycode[qcode]; if (keycode == NO_KEY) { /* We don't want to send this to the guest */ ADB_DPRINTF("Ignoring NO_KEY\n"); return; } if (evt->u.key.data->down == false) { /* if key release event */ keycode = keycode | 0x80; /* create keyboard break code */ } adb_kbd_put_keycode(s, keycode); }
25,721
0
void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) { mm_flags = mm_support(); if (avctx->dsp_mask) { if (avctx->dsp_mask & FF_MM_FORCE) mm_flags |= (avctx->dsp_mask & 0xffff); else mm_flags &= ~(avctx->dsp_mask & 0xffff); } #if 0 av_log(avctx, AV_LOG_INFO, "libavcodec: CPU flags:"); if (mm_flags & MM_MMX) av_log(avctx, AV_LOG_INFO, " mmx"); if (mm_flags & MM_MMXEXT) av_log(avctx, AV_LOG_INFO, " mmxext"); if (mm_flags & MM_3DNOW) av_log(avctx, AV_LOG_INFO, " 3dnow"); if (mm_flags & MM_SSE) av_log(avctx, AV_LOG_INFO, " sse"); if (mm_flags & MM_SSE2) av_log(avctx, AV_LOG_INFO, " sse2"); av_log(avctx, AV_LOG_INFO, "\n"); #endif if (mm_flags & MM_MMX) { const int idct_algo= avctx->idct_algo; if(avctx->lowres==0){ if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){ c->idct_put= ff_simple_idct_put_mmx; c->idct_add= ff_simple_idct_add_mmx; c->idct = ff_simple_idct_mmx; c->idct_permutation_type= FF_SIMPLE_IDCT_PERM; #ifdef CONFIG_GPL }else if(idct_algo==FF_IDCT_LIBMPEG2MMX){ if(mm_flags & MM_MMXEXT){ c->idct_put= ff_libmpeg2mmx2_idct_put; c->idct_add= ff_libmpeg2mmx2_idct_add; c->idct = ff_mmxext_idct; }else{ c->idct_put= ff_libmpeg2mmx_idct_put; c->idct_add= ff_libmpeg2mmx_idct_add; c->idct = ff_mmx_idct; } c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; #endif }else if((ENABLE_VP3_DECODER || ENABLE_VP5_DECODER || ENABLE_VP6_DECODER || ENABLE_THEORA_DECODER) && idct_algo==FF_IDCT_VP3){ if(mm_flags & MM_SSE2){ c->idct_put= ff_vp3_idct_put_sse2; c->idct_add= ff_vp3_idct_add_sse2; c->idct = ff_vp3_idct_sse2; c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM; }else{ c->idct_put= ff_vp3_idct_put_mmx; c->idct_add= ff_vp3_idct_add_mmx; c->idct = ff_vp3_idct_mmx; c->idct_permutation_type= FF_PARTTRANS_IDCT_PERM; } }else if(idct_algo==FF_IDCT_CAVS){ c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM; }else if(idct_algo==FF_IDCT_XVIDMMX){ if(mm_flags & MM_SSE2){ c->idct_put= ff_idct_xvid_sse2_put; c->idct_add= ff_idct_xvid_sse2_add; c->idct = ff_idct_xvid_sse2; c->idct_permutation_type= FF_SSE2_IDCT_PERM; }else if(mm_flags & MM_MMXEXT){ c->idct_put= ff_idct_xvid_mmx2_put; c->idct_add= ff_idct_xvid_mmx2_add; c->idct = ff_idct_xvid_mmx2; }else{ c->idct_put= ff_idct_xvid_mmx_put; c->idct_add= ff_idct_xvid_mmx_add; c->idct = ff_idct_xvid_mmx; } } } c->put_pixels_clamped = put_pixels_clamped_mmx; c->put_signed_pixels_clamped = put_signed_pixels_clamped_mmx; c->add_pixels_clamped = add_pixels_clamped_mmx; c->clear_blocks = clear_blocks_mmx; #define SET_HPEL_FUNCS(PFX, IDX, SIZE, CPU) \ c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## SIZE ## _ ## CPU; \ c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## SIZE ## _x2_ ## CPU; \ c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \ c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU SET_HPEL_FUNCS(put, 0, 16, mmx); SET_HPEL_FUNCS(put_no_rnd, 0, 16, mmx); SET_HPEL_FUNCS(avg, 0, 16, mmx); SET_HPEL_FUNCS(avg_no_rnd, 0, 16, mmx); SET_HPEL_FUNCS(put, 1, 8, mmx); SET_HPEL_FUNCS(put_no_rnd, 1, 8, mmx); SET_HPEL_FUNCS(avg, 1, 8, mmx); SET_HPEL_FUNCS(avg_no_rnd, 1, 8, mmx); c->gmc= gmc_mmx; c->add_bytes= add_bytes_mmx; c->add_bytes_l2= add_bytes_l2_mmx; c->draw_edges = draw_edges_mmx; if (ENABLE_ANY_H263) { c->h263_v_loop_filter= h263_v_loop_filter_mmx; c->h263_h_loop_filter= h263_h_loop_filter_mmx; } if ((ENABLE_VP3_DECODER || ENABLE_THEORA_DECODER) && !(avctx->flags & CODEC_FLAG_BITEXACT)) { c->vp3_v_loop_filter= ff_vp3_v_loop_filter_mmx; c->vp3_h_loop_filter= ff_vp3_h_loop_filter_mmx; } c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_rnd; c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_mmx; c->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_nornd; c->h264_idct_dc_add= c->h264_idct_add= ff_h264_idct_add_mmx; c->h264_idct8_dc_add= c->h264_idct8_add= ff_h264_idct8_add_mmx; if (mm_flags & MM_SSE2) c->h264_idct8_add= ff_h264_idct8_add_sse2; if (mm_flags & MM_MMXEXT) { c->prefetch = prefetch_mmx2; c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2; c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2; c->avg_pixels_tab[0][0] = avg_pixels16_mmx2; c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2; c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2; c->put_pixels_tab[1][1] = put_pixels8_x2_mmx2; c->put_pixels_tab[1][2] = put_pixels8_y2_mmx2; c->avg_pixels_tab[1][0] = avg_pixels8_mmx2; c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2; c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2; c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2; c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2; c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2; c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2; c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2; c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2; c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2; } #define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU) \ c->PFX ## _pixels_tab[IDX][ 0] = PFX ## SIZE ## _mc00_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 1] = PFX ## SIZE ## _mc10_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 2] = PFX ## SIZE ## _mc20_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 3] = PFX ## SIZE ## _mc30_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 4] = PFX ## SIZE ## _mc01_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 5] = PFX ## SIZE ## _mc11_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 6] = PFX ## SIZE ## _mc21_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 7] = PFX ## SIZE ## _mc31_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 8] = PFX ## SIZE ## _mc02_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 9] = PFX ## SIZE ## _mc12_ ## CPU; \ c->PFX ## _pixels_tab[IDX][10] = PFX ## SIZE ## _mc22_ ## CPU; \ c->PFX ## _pixels_tab[IDX][11] = PFX ## SIZE ## _mc32_ ## CPU; \ c->PFX ## _pixels_tab[IDX][12] = PFX ## SIZE ## _mc03_ ## CPU; \ c->PFX ## _pixels_tab[IDX][13] = PFX ## SIZE ## _mc13_ ## CPU; \ c->PFX ## _pixels_tab[IDX][14] = PFX ## SIZE ## _mc23_ ## CPU; \ c->PFX ## _pixels_tab[IDX][15] = PFX ## SIZE ## _mc33_ ## CPU SET_QPEL_FUNCS(put_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(put_qpel, 1, 8, mmx2); SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmx2); SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2); SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2); SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2); SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmx2); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmx2); SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmx2); SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmx2); SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmx2); c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2_rnd; c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_mmx2; c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_mmx2; c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_mmx2; c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_mmx2; c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_mmx2; c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_mmx2; c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_mmx2; c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_mmx2; c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_mmx2; c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2; c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2; c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2; c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2; c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2; c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2; c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2; c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2; c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2; c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2; c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2; c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2; c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2; c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2; c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2; c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2; c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2; if (ENABLE_CAVS_DECODER) ff_cavsdsp_init_mmx2(c, avctx); if (ENABLE_VC1_DECODER || ENABLE_WMV3_DECODER) ff_vc1dsp_init_mmx(c, avctx); c->add_png_paeth_prediction= add_png_paeth_prediction_mmx2; } else if (mm_flags & MM_3DNOW) { c->prefetch = prefetch_3dnow; c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow; c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow; c->avg_pixels_tab[0][0] = avg_pixels16_3dnow; c->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow; c->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow; c->put_pixels_tab[1][1] = put_pixels8_x2_3dnow; c->put_pixels_tab[1][2] = put_pixels8_y2_3dnow; c->avg_pixels_tab[1][0] = avg_pixels8_3dnow; c->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow; c->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow; c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow; c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow; c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow; c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow; c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow; } SET_QPEL_FUNCS(put_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(put_qpel, 1, 8, 3dnow); SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, 3dnow); SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow); SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow); SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow); SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 3dnow); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 3dnow); SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, 3dnow); SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, 3dnow); SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow); c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow_rnd; c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_3dnow; if (ENABLE_CAVS_DECODER) ff_cavsdsp_init_3dnow(c, avctx); } #define H264_QPEL_FUNCS(x, y, CPU)\ c->put_h264_qpel_pixels_tab[0][x+y*4] = put_h264_qpel16_mc##x##y##_##CPU;\ c->put_h264_qpel_pixels_tab[1][x+y*4] = put_h264_qpel8_mc##x##y##_##CPU;\ c->avg_h264_qpel_pixels_tab[0][x+y*4] = avg_h264_qpel16_mc##x##y##_##CPU;\ c->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU; if((mm_flags & MM_SSE2) && !(mm_flags & MM_3DNOW)){ // these functions are slower than mmx on AMD, but faster on Intel /* FIXME works in most codecs, but crashes svq1 due to unaligned chroma c->put_pixels_tab[0][0] = put_pixels16_sse2; c->avg_pixels_tab[0][0] = avg_pixels16_sse2; */ H264_QPEL_FUNCS(0, 0, sse2); } if(mm_flags & MM_SSE2){ H264_QPEL_FUNCS(0, 1, sse2); H264_QPEL_FUNCS(0, 2, sse2); H264_QPEL_FUNCS(0, 3, sse2); H264_QPEL_FUNCS(1, 1, sse2); H264_QPEL_FUNCS(1, 2, sse2); H264_QPEL_FUNCS(1, 3, sse2); H264_QPEL_FUNCS(2, 1, sse2); H264_QPEL_FUNCS(2, 2, sse2); H264_QPEL_FUNCS(2, 3, sse2); H264_QPEL_FUNCS(3, 1, sse2); H264_QPEL_FUNCS(3, 2, sse2); H264_QPEL_FUNCS(3, 3, sse2); } #ifdef HAVE_SSSE3 if(mm_flags & MM_SSSE3){ H264_QPEL_FUNCS(1, 0, ssse3); H264_QPEL_FUNCS(1, 1, ssse3); H264_QPEL_FUNCS(1, 2, ssse3); H264_QPEL_FUNCS(1, 3, ssse3); H264_QPEL_FUNCS(2, 0, ssse3); H264_QPEL_FUNCS(2, 1, ssse3); H264_QPEL_FUNCS(2, 2, ssse3); H264_QPEL_FUNCS(2, 3, ssse3); H264_QPEL_FUNCS(3, 0, ssse3); H264_QPEL_FUNCS(3, 1, ssse3); H264_QPEL_FUNCS(3, 2, ssse3); H264_QPEL_FUNCS(3, 3, ssse3); c->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_nornd; c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_rnd; c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_ssse3_rnd; c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_ssse3; c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_ssse3; c->add_png_paeth_prediction= add_png_paeth_prediction_ssse3; } #endif #ifdef CONFIG_SNOW_DECODER if(mm_flags & MM_SSE2 & 0){ c->horizontal_compose97i = ff_snow_horizontal_compose97i_sse2; #ifdef HAVE_7REGS c->vertical_compose97i = ff_snow_vertical_compose97i_sse2; #endif c->inner_add_yblock = ff_snow_inner_add_yblock_sse2; } else{ if(mm_flags & MM_MMXEXT){ c->horizontal_compose97i = ff_snow_horizontal_compose97i_mmx; #ifdef HAVE_7REGS c->vertical_compose97i = ff_snow_vertical_compose97i_mmx; #endif } c->inner_add_yblock = ff_snow_inner_add_yblock_mmx; } #endif if(mm_flags & MM_3DNOW){ c->vorbis_inverse_coupling = vorbis_inverse_coupling_3dnow; c->vector_fmul = vector_fmul_3dnow; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->float_to_int16 = float_to_int16_3dnow; c->float_to_int16_interleave = float_to_int16_interleave_3dnow; } } if(mm_flags & MM_3DNOWEXT){ c->vector_fmul_reverse = vector_fmul_reverse_3dnow2; c->vector_fmul_window = vector_fmul_window_3dnow2; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->float_to_int16_interleave = float_to_int16_interleave_3dn2; } } if(mm_flags & MM_SSE){ c->vorbis_inverse_coupling = vorbis_inverse_coupling_sse; c->ac3_downmix = ac3_downmix_sse; c->vector_fmul = vector_fmul_sse; c->vector_fmul_reverse = vector_fmul_reverse_sse; c->vector_fmul_add_add = vector_fmul_add_add_sse; c->vector_fmul_window = vector_fmul_window_sse; c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse; c->float_to_int16 = float_to_int16_sse; c->float_to_int16_interleave = float_to_int16_interleave_sse; } if(mm_flags & MM_3DNOW) c->vector_fmul_add_add = vector_fmul_add_add_3dnow; // faster than sse if(mm_flags & MM_SSE2){ c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2; c->float_to_int16 = float_to_int16_sse2; c->float_to_int16_interleave = float_to_int16_interleave_sse2; c->add_int16 = add_int16_sse2; c->sub_int16 = sub_int16_sse2; c->scalarproduct_int16 = scalarproduct_int16_sse2; } } if (ENABLE_ENCODERS) dsputilenc_init_mmx(c, avctx); #if 0 // for speed testing get_pixels = just_return; put_pixels_clamped = just_return; add_pixels_clamped = just_return; pix_abs16x16 = just_return; pix_abs16x16_x2 = just_return; pix_abs16x16_y2 = just_return; pix_abs16x16_xy2 = just_return; put_pixels_tab[0] = just_return; put_pixels_tab[1] = just_return; put_pixels_tab[2] = just_return; put_pixels_tab[3] = just_return; put_no_rnd_pixels_tab[0] = just_return; put_no_rnd_pixels_tab[1] = just_return; put_no_rnd_pixels_tab[2] = just_return; put_no_rnd_pixels_tab[3] = just_return; avg_pixels_tab[0] = just_return; avg_pixels_tab[1] = just_return; avg_pixels_tab[2] = just_return; avg_pixels_tab[3] = just_return; avg_no_rnd_pixels_tab[0] = just_return; avg_no_rnd_pixels_tab[1] = just_return; avg_no_rnd_pixels_tab[2] = just_return; avg_no_rnd_pixels_tab[3] = just_return; //av_fdct = just_return; //ff_idct = just_return; #endif }
25,722
1
static void iscsi_retry_timer_expired(void *opaque) { struct IscsiTask *iTask = opaque; iTask->complete = 1; if (iTask->co) { qemu_coroutine_enter(iTask->co, NULL); } }
25,723
1
int qemu_shutdown_requested_get(void) { return shutdown_requested; }
25,725
1
static inline void RENAME(rgb15ToY)(uint8_t *dst, uint8_t *src, int width) { int i; for(i=0; i<width; i++) { int d= ((uint16_t*)src)[i]; int r= d&0x1F; int g= (d>>5)&0x1F; int b= (d>>10)&0x1F; dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16; } }
25,727
1
static int kvm_dirty_pages_log_change(target_phys_addr_t phys_addr, target_phys_addr_t end_addr, unsigned flags, unsigned mask) { KVMState *s = kvm_state; KVMSlot *mem = kvm_lookup_slot(s, phys_addr); if (mem == NULL) { dprintf("invalid parameters %llx-%llx\n", phys_addr, end_addr); return -EINVAL; } flags = (mem->flags & ~mask) | flags; /* Nothing changed, no need to issue ioctl */ if (flags == mem->flags) return 0; mem->flags = flags; return kvm_set_user_memory_region(s, mem); }
25,728
0
static void RENAME(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, long width, long height, long lumStride, long chromStride, long srcStride) { long y; const long chromWidth= -((-width)>>1); for (y=0; y<height; y++) { RENAME(extract_even)(src+1, ydst, width); if(y&1) { RENAME(extract_even2avg)(src-srcStride, src, udst, vdst, chromWidth); udst+= chromStride; vdst+= chromStride; } src += srcStride; ydst+= lumStride; } #if COMPILE_TEMPLATE_MMX __asm__( EMMS" \n\t" SFENCE" \n\t" ::: "memory" ); #endif }
25,730
0
static int bayer_to_yv12_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]) { const uint8_t *srcPtr= src[0]; uint8_t *dstY= dst[0]; uint8_t *dstU= dst[1]; uint8_t *dstV= dst[2]; int i; void (*copy) (const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv); void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv); switch(c->srcFormat) { #define CASE(pixfmt, prefix) \ case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \ interpolate = bayer_##prefix##_to_yv12_interpolate; \ break; CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8) CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le) CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be) CASE(AV_PIX_FMT_BAYER_RGGB8, rggb8) CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le) CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be) CASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8) CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le) CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be) CASE(AV_PIX_FMT_BAYER_GRBG8, grbg8) CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le) CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be) #undef CASE default: return 0; } copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table); srcPtr += 2 * srcStride[0]; dstY += 2 * dstStride[0]; dstU += dstStride[1]; dstV += dstStride[1]; for (i = 2; i < srcSliceH - 2; i += 2) { interpolate(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table); srcPtr += 2 * srcStride[0]; dstY += 2 * dstStride[0]; dstU += dstStride[1]; dstV += dstStride[1]; } copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table); return srcSliceH; }
25,731
0
static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *pic) { VAAPIEncodeContext *ctx = avctx->priv_data; VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params; VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params; VAAPIEncodeH264Context *priv = ctx->priv_data; int i; if (pic->type == PICTURE_TYPE_IDR) { av_assert0(pic->display_order == pic->encode_order); vpic->frame_num = 0; priv->next_frame_num = 1; priv->cpb_delay = 0; } else { vpic->frame_num = priv->next_frame_num; if (pic->type != PICTURE_TYPE_B) { // nal_ref_idc != 0 ++priv->next_frame_num; } ++priv->cpb_delay; } priv->dpb_delay = pic->display_order - pic->encode_order + 1; vpic->frame_num = vpic->frame_num & ((1 << (4 + vseq->seq_fields.bits.log2_max_frame_num_minus4)) - 1); vpic->CurrPic.picture_id = pic->recon_surface; vpic->CurrPic.frame_idx = vpic->frame_num; vpic->CurrPic.flags = 0; vpic->CurrPic.TopFieldOrderCnt = pic->display_order; vpic->CurrPic.BottomFieldOrderCnt = pic->display_order; for (i = 0; i < pic->nb_refs; i++) { VAAPIEncodePicture *ref = pic->refs[i]; av_assert0(ref && ref->encode_order < pic->encode_order); vpic->ReferenceFrames[i].picture_id = ref->recon_surface; vpic->ReferenceFrames[i].frame_idx = ref->encode_order; vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE; vpic->ReferenceFrames[i].TopFieldOrderCnt = ref->display_order; vpic->ReferenceFrames[i].BottomFieldOrderCnt = ref->display_order; } for (; i < FF_ARRAY_ELEMS(vpic->ReferenceFrames); i++) { vpic->ReferenceFrames[i].picture_id = VA_INVALID_ID; vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID; } vpic->coded_buf = pic->output_buffer; vpic->pic_fields.bits.idr_pic_flag = (pic->type == PICTURE_TYPE_IDR); vpic->pic_fields.bits.reference_pic_flag = (pic->type != PICTURE_TYPE_B); pic->nb_slices = 1; return 0; }
25,733
1
static inline int is_bit_set(BlockDriverState *bs, int64_t bitnum) { uint64_t offset = sizeof(struct cow_header_v2) + bitnum / 8; uint8_t bitmap; if (bdrv_pread(bs->file, offset, &bitmap, sizeof(bitmap)) != sizeof(bitmap)) { return -errno; } return !!(bitmap & (1 << (bitnum % 8))); }
25,735
1
bool st_init(const char *file) { pthread_t thread; pthread_attr_t attr; sigset_t set, oldset; int ret; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); sigfillset(&set); pthread_sigmask(SIG_SETMASK, &set, &oldset); ret = pthread_create(&thread, &attr, writeout_thread, NULL); pthread_sigmask(SIG_SETMASK, &oldset, NULL); if (ret != 0) { return false; } atexit(st_flush_trace_buffer); st_set_trace_file(file); return true; }
25,736
1
static int libquvi_close(AVFormatContext *s) { LibQuviContext *qc = s->priv_data; if (qc->fmtctx) avformat_close_input(&qc->fmtctx); return 0; }
25,739
1
static void aspeed_soc_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc); sc->info = (AspeedSoCInfo *) data; dc->realize = aspeed_soc_realize; }
25,740
1
static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, struct in_addr my_ip) { AVFormatContext *avc; AVStream avs[MAX_STREAMS]; int i; avc = avformat_alloc_context(); if (avc == NULL) { return -1; } av_metadata_set2(&avc->metadata, "title", stream->title[0] ? stream->title : "No Title", 0); avc->nb_streams = stream->nb_streams; if (stream->is_multicast) { snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d", inet_ntoa(stream->multicast_ip), stream->multicast_port, stream->multicast_ttl); } else { snprintf(avc->filename, 1024, "rtp://0.0.0.0"); } for(i = 0; i < stream->nb_streams; i++) { avc->streams[i] = &avs[i]; avc->streams[i]->codec = stream->streams[i]->codec; } *pbuffer = av_mallocz(2048); avf_sdp_create(&avc, 1, *pbuffer, 2048); av_free(avc); return strlen(*pbuffer); }
25,742
1
static int dvdsub_decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { DVDSubContext *ctx = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVSubtitle *sub = data; int is_menu; if (ctx->buf) { int ret = append_to_cached_buf(avctx, buf, buf_size); if (ret < 0) { *data_size = 0; return ret; } buf = ctx->buf; buf_size = ctx->buf_size; } is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size); if (is_menu == AVERROR(EAGAIN)) { *data_size = 0; return append_to_cached_buf(avctx, buf, buf_size); } if (is_menu < 0) { no_subtitle: reset_rects(sub); *data_size = 0; return buf_size; } if (!is_menu && find_smallest_bounding_rectangle(sub) == 0) goto no_subtitle; if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED)) goto no_subtitle; #if defined(DEBUG) { char ppm_name[32]; snprintf(ppm_name, sizeof(ppm_name), "/tmp/%05d.ppm", ctx->sub_id++); av_dlog(NULL, "start=%d ms end =%d ms\n", sub->start_display_time, sub->end_display_time); ppm_save(ppm_name, sub->rects[0]->pict.data[0], sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.data[1]); } #endif av_freep(&ctx->buf); ctx->buf_size = 0; *data_size = 1; return buf_size; }
25,745
1
static void ibm_40p_init(MachineState *machine) { CPUPPCState *env = NULL; uint16_t cmos_checksum; PowerPCCPU *cpu; DeviceState *dev; SysBusDevice *pcihost; Nvram *m48t59 = NULL; PCIBus *pci_bus; ISABus *isa_bus; void *fw_cfg; int i; uint32_t kernel_base = 0, initrd_base = 0; long kernel_size = 0, initrd_size = 0; char boot_device; /* init CPU */ if (!machine->cpu_model) { machine->cpu_model = "604"; } cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model)); if (!cpu) { error_report("could not initialize CPU '%s'", machine->cpu_model); exit(1); } env = &cpu->env; if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { error_report("only 6xx bus is supported on this machine"); exit(1); } if (env->flags & POWERPC_FLAG_RTC_CLK) { /* POWER / PowerPC 601 RTC clock frequency is 7.8125 MHz */ cpu_ppc_tb_init(env, 7812500UL); } else { /* Set time-base frequency to 100 Mhz */ cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); } qemu_register_reset(ppc_prep_reset, cpu); /* PCI host */ dev = qdev_create(NULL, "raven-pcihost"); if (!bios_name) { bios_name = BIOS_FILENAME; } qdev_prop_set_string(dev, "bios-name", bios_name); qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE); pcihost = SYS_BUS_DEVICE(dev); object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL); qdev_init_nofail(dev); pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci.0")); if (!pci_bus) { error_report("could not create PCI host controller"); exit(1); } /* PCI -> ISA bridge */ dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378")); qdev_connect_gpio_out(dev, 0, cpu->env.irq_inputs[PPC6xx_INPUT_INT]); sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(dev, 15)); sysbus_connect_irq(pcihost, 1, qdev_get_gpio_in(dev, 13)); sysbus_connect_irq(pcihost, 2, qdev_get_gpio_in(dev, 15)); sysbus_connect_irq(pcihost, 3, qdev_get_gpio_in(dev, 13)); isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0")); /* Memory controller */ dev = DEVICE(isa_create(isa_bus, "rs6000-mc")); qdev_prop_set_uint32(dev, "ram-size", machine->ram_size); qdev_init_nofail(dev); /* initialize CMOS checksums */ cmos_checksum = 0x6aa9; qbus_walk_children(BUS(isa_bus), prep_set_cmos_checksum, NULL, NULL, NULL, &cmos_checksum); /* add some more devices */ if (defaults_enabled()) { isa_create_simple(isa_bus, "i8042"); m48t59 = NVRAM(isa_create_simple(isa_bus, "isa-m48t59")); dev = DEVICE(isa_create(isa_bus, "cs4231a")); qdev_prop_set_uint32(dev, "iobase", 0x830); qdev_prop_set_uint32(dev, "irq", 10); qdev_init_nofail(dev); dev = DEVICE(isa_create(isa_bus, "pc87312")); qdev_prop_set_uint32(dev, "config", 12); qdev_init_nofail(dev); dev = DEVICE(isa_create(isa_bus, "prep-systemio")); qdev_prop_set_uint32(dev, "ibm-planar-id", 0xfc); qdev_prop_set_uint32(dev, "equipment", 0xc0); qdev_init_nofail(dev); pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "lsi53c810"); /* XXX: s3-trio at PCI_DEVFN(2, 0) */ pci_vga_init(pci_bus); for (i = 0; i < nb_nics; i++) { pci_nic_init_nofail(&nd_table[i], pci_bus, "pcnet", i == 0 ? "3" : NULL); } } /* Prepare firmware configuration for OpenBIOS */ fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2); if (machine->kernel_filename) { /* load kernel */ kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_image_targphys(machine->kernel_filename, kernel_base, machine->ram_size - kernel_base); if (kernel_size < 0) { error_report("could not load kernel '%s'", machine->kernel_filename); exit(1); } fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); /* load initrd */ if (machine->initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image_targphys(machine->initrd_filename, initrd_base, machine->ram_size - initrd_base); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", machine->initrd_filename); exit(1); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); } if (machine->kernel_cmdline && *machine->kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR); pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, machine->kernel_cmdline); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, machine->kernel_cmdline); fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(machine->kernel_cmdline) + 1); } boot_device = 'm'; } else { boot_device = machine->boot_order[0]; } fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_PREP); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled()); if (kvm_enabled()) { #ifdef CONFIG_KVM uint8_t *hypercall; fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq()); hypercall = g_malloc(16); kvmppc_get_hypercall(env, hypercall, 16); fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); #endif } else { fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, NANOSECONDS_PER_SECOND); } fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); /* Prepare firmware configuration for Open Hack'Ware */ if (m48t59) { PPC_NVRAM_set_params(m48t59, NVRAM_SIZE, "PREP", ram_size, boot_device, kernel_base, kernel_size, machine->kernel_cmdline, initrd_base, initrd_size, /* XXX: need an option to load a NVRAM image */ 0, graphic_width, graphic_height, graphic_depth); } }
25,746
1
static void *iommu_init(target_phys_addr_t addr, uint32_t version, qemu_irq irq) { DeviceState *dev; SysBusDevice *s; dev = qdev_create(NULL, "iommu"); qdev_prop_set_uint32(dev, "version", version); qdev_init(dev); s = sysbus_from_qdev(dev); sysbus_connect_irq(s, 0, irq); sysbus_mmio_map(s, 0, addr); return s; }
25,747
1
static void test_qemu_strtoull_full_empty(void) { const char *str = ""; uint64_t res = 999; int err; err = qemu_strtoull(str, NULL, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0); }
25,749
0
static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc) { int32_t *filterPos = c->hChrFilterPos; int16_t *filter = c->hChrFilter; void *mmx2FilterCode= c->chrMmx2FilterCode; int i; #if defined(PIC) DECLARE_ALIGNED(8, uint64_t, ebxsave); #endif __asm__ volatile( #if defined(PIC) "mov %%"REG_b", %7 \n\t" #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" // i PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE "xor %%"REG_a", %%"REG_a" \n\t" // i "mov %5, %%"REG_c" \n\t" // src "mov %6, %%"REG_D" \n\t" // buf2 PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE #if defined(PIC) "mov %7, %%"REG_b" \n\t" #endif :: "m" (src1), "m" (dst1), "m" (filter), "m" (filterPos), "m" (mmx2FilterCode), "m" (src2), "m"(dst2) #if defined(PIC) ,"m" (ebxsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) { dst1[i] = src1[srcW-1]*128; dst2[i] = src2[srcW-1]*128; } }
25,750
0
static void get_pointer(Object *obj, Visitor *v, Property *prop, const char *(*print)(void *ptr), const char *name, Error **errp) { DeviceState *dev = DEVICE(obj); void **ptr = qdev_get_prop_ptr(dev, prop); char *p; p = (char *) (*ptr ? print(*ptr) : ""); visit_type_str(v, &p, name, errp); }
25,751
0
static uint64_t jazz_led_read(void *opaque, target_phys_addr_t addr, unsigned int size) { LedState *s = opaque; uint8_t val; val = s->segments; trace_jazz_led_read(addr, val); return val; }
25,752
0
float32 HELPER(ucf64_divs)(float32 a, float32 b, CPUUniCore32State *env) { return float32_div(a, b, &env->ucf64.fp_status); }
25,754
0
static void scsi_generic_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass); sc->realize = scsi_generic_realize; sc->unrealize = scsi_unrealize; sc->alloc_req = scsi_new_request; sc->parse_cdb = scsi_generic_parse_cdb; dc->fw_name = "disk"; dc->desc = "pass through generic scsi device (/dev/sg*)"; dc->reset = scsi_generic_reset; dc->props = scsi_generic_properties; dc->vmsd = &vmstate_scsi_device; }
25,755
0
START_TEST(qlist_destroy_test) { int i; QList *qlist; qlist = qlist_new(); for (i = 0; i < 42; i++) qlist_append(qlist, qint_from_int(i)); QDECREF(qlist); }
25,756
0
static void vnc_client_read(void *opaque) { VncState *vs = opaque; long ret; buffer_reserve(&vs->input, 4096); #ifdef CONFIG_VNC_TLS if (vs->tls_session) { ret = gnutls_read(vs->tls_session, buffer_end(&vs->input), 4096); if (ret < 0) { if (ret == GNUTLS_E_AGAIN) errno = EAGAIN; else errno = EIO; ret = -1; } } else #endif /* CONFIG_VNC_TLS */ ret = recv(vs->csock, buffer_end(&vs->input), 4096, 0); ret = vnc_client_io_error(vs, ret, socket_error()); if (!ret) return; vs->input.offset += ret; while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) { size_t len = vs->read_handler_expect; int ret; ret = vs->read_handler(vs, vs->input.buffer, len); if (vs->csock == -1) return; if (!ret) { memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len)); vs->input.offset -= len; } else { vs->read_handler_expect = ret; } } }
25,757
0
POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); dc->desc = "e5500 core"; pcc->init_proc = init_proc_e5500; pcc->check_pow = check_pow_none; pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_WRTEE | PPC_RFDI | PPC_RFMCI | PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | PPC_CACHE_DCBA | PPC_FLOAT | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL | PPC_FLOAT_STFIWX | PPC_WAIT | PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC | PPC_64B | PPC_POPCNTB | PPC_POPCNTWD; pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206; pcc->msr_mask = (1ull << MSR_CM) | (1ull << MSR_GS) | (1ull << MSR_UCLE) | (1ull << MSR_CE) | (1ull << MSR_EE) | (1ull << MSR_PR) | (1ull << MSR_FP) | (1ull << MSR_ME) | (1ull << MSR_FE0) | (1ull << MSR_DE) | (1ull << MSR_FE1) | (1ull << MSR_IR) | (1ull << MSR_DR) | (1ull << MSR_PX) | (1ull << MSR_RI); pcc->mmu_model = POWERPC_MMU_BOOKE206; pcc->excp_model = POWERPC_EXCP_BOOKE; pcc->bus_model = PPC_FLAGS_INPUT_BookE; /* FIXME: figure out the correct flag for e5500 */ pcc->bfd_mach = bfd_mach_ppc_e500; pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE | POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; }
25,758
0
void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len) { const uint8_t *end; int j; j = ctx->len & 63; ctx->len += len; if (j) { int cnt = FFMIN(len, 64 - j); memcpy(ctx->block + j, src, cnt); src += cnt; len -= cnt; if (j + cnt < 64) return; body(ctx->ABCD, (uint32_t *)ctx->block); } end = src + (len & ~63); if (HAVE_BIGENDIAN || (!HAVE_FAST_UNALIGNED && ((intptr_t)src & 3))) { while (src < end) { memcpy(ctx->block, src, 64); body(ctx->ABCD, (uint32_t *) ctx->block); src += 64; } } else { while (src < end) { body(ctx->ABCD, (uint32_t *)src); src += 64; } } len &= 63; if (len > 0) memcpy(ctx->block, src, len); }
25,759
0
int main() { int rt, rs; int achi, acli; int dsp; int acho, aclo; int resulth, resultl; int resdsp; achi = 0x05; acli = 0xB4CB; rs = 0xFF06; rt = 0xCB00; resulth = 0x04; resultl = 0x947438CB; __asm ("mthi %2, $ac1\n\t" "mtlo %3, $ac1\n\t" "maq_s.w.phr $ac1, %4, %5\n\t" "mfhi %0, $ac1\n\t" "mflo %1, $ac1\n\t" : "=r"(acho), "=r"(aclo) : "r"(achi), "r"(acli), "r"(rs), "r"(rt) ); assert(resulth == acho); assert(resultl == aclo); achi = 0x06; acli = 0xB4CB; rs = 0x8000; rt = 0x8000; resulth = 0x6; resultl = 0x8000b4ca; resdsp = 1; __asm ("mthi %3, $ac1\n\t" "mtlo %4, $ac1\n\t" "maq_s.w.phr $ac1, %5, %6\n\t" "mfhi %0, $ac1\n\t" "mflo %1, $ac1\n\t" "rddsp %2\n\t" : "=r"(acho), "=r"(aclo), "=r"(dsp) : "r"(achi), "r"(acli), "r"(rs), "r"(rt) ); assert(resulth == acho); assert(resultl == aclo); assert(((dsp >> 17) & 0x01) == resdsp); return 0; }
25,760
0
int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind, const char *version, const char *serial) { int cylinders, heads, secs; uint64_t nb_sectors; s->bs = bs; s->drive_kind = kind; bdrv_get_geometry(bs, &nb_sectors); bdrv_guess_geometry(bs, &cylinders, &heads, &secs); if (cylinders < 1 || cylinders > 16383) { error_report("cyls must be between 1 and 16383"); return -1; } if (heads < 1 || heads > 16) { error_report("heads must be between 1 and 16"); return -1; } if (secs < 1 || secs > 63) { error_report("secs must be between 1 and 63"); return -1; } s->cylinders = cylinders; s->heads = heads; s->sectors = secs; s->nb_sectors = nb_sectors; /* The SMART values should be preserved across power cycles but they aren't. */ s->smart_enabled = 1; s->smart_autosave = 1; s->smart_errors = 0; s->smart_selftest_count = 0; if (kind == IDE_CD) { bdrv_set_dev_ops(bs, &ide_cd_block_ops, s); bdrv_set_buffer_alignment(bs, 2048); } else { if (!bdrv_is_inserted(s->bs)) { error_report("Device needs media, but drive is empty"); return -1; } if (bdrv_is_read_only(bs)) { error_report("Can't use a read-only drive"); return -1; } } if (serial) { strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str)); } else { snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), "QM%05d", s->drive_serial); } if (version) { pstrcpy(s->version, sizeof(s->version), version); } else { pstrcpy(s->version, sizeof(s->version), QEMU_VERSION); } ide_reset(s); bdrv_iostatus_enable(bs); return 0; }
25,761
0
int subch_device_load(SubchDev *s, QEMUFile *f) { SubchDev *old_s; Error *err = NULL; uint16_t old_schid = s->schid; uint16_t old_devno = s->devno; int i; s->cssid = qemu_get_byte(f); s->ssid = qemu_get_byte(f); s->schid = qemu_get_be16(f); s->devno = qemu_get_be16(f); if (s->devno != old_devno) { /* Only possible if machine < 2.7 (no css_dev_path) */ error_setg(&err, "%x != %x", old_devno, s->devno); error_append_hint(&err, "Devno mismatch, tried to load wrong section!" " Likely reason: some sequences of plug and unplug" " can break migration for machine versions prior to" " 2.7 (known design flaw).\n"); error_report_err(err); return -EINVAL; } /* Re-assign subch. */ if (old_schid != s->schid) { old_s = channel_subsys.css[s->cssid]->sch_set[s->ssid]->sch[old_schid]; /* * (old_s != s) means that some other device has its correct * subchannel already assigned (in load). */ if (old_s == s) { css_subch_assign(s->cssid, s->ssid, old_schid, s->devno, NULL); } /* It's OK to re-assign without a prior de-assign. */ css_subch_assign(s->cssid, s->ssid, s->schid, s->devno, s); } s->thinint_active = qemu_get_byte(f); /* SCHIB */ /* PMCW */ s->curr_status.pmcw.intparm = qemu_get_be32(f); s->curr_status.pmcw.flags = qemu_get_be16(f); s->curr_status.pmcw.devno = qemu_get_be16(f); s->curr_status.pmcw.lpm = qemu_get_byte(f); s->curr_status.pmcw.pnom = qemu_get_byte(f); s->curr_status.pmcw.lpum = qemu_get_byte(f); s->curr_status.pmcw.pim = qemu_get_byte(f); s->curr_status.pmcw.mbi = qemu_get_be16(f); s->curr_status.pmcw.pom = qemu_get_byte(f); s->curr_status.pmcw.pam = qemu_get_byte(f); qemu_get_buffer(f, s->curr_status.pmcw.chpid, 8); s->curr_status.pmcw.chars = qemu_get_be32(f); /* SCSW */ s->curr_status.scsw.flags = qemu_get_be16(f); s->curr_status.scsw.ctrl = qemu_get_be16(f); s->curr_status.scsw.cpa = qemu_get_be32(f); s->curr_status.scsw.dstat = qemu_get_byte(f); s->curr_status.scsw.cstat = qemu_get_byte(f); s->curr_status.scsw.count = qemu_get_be16(f); s->curr_status.mba = qemu_get_be64(f); qemu_get_buffer(f, s->curr_status.mda, 4); /* end SCHIB */ qemu_get_buffer(f, s->sense_data, 32); s->channel_prog = qemu_get_be64(f); /* last cmd */ s->last_cmd.cmd_code = qemu_get_byte(f); s->last_cmd.flags = qemu_get_byte(f); s->last_cmd.count = qemu_get_be16(f); s->last_cmd.cda = qemu_get_be32(f); s->last_cmd_valid = qemu_get_byte(f); s->id.reserved = qemu_get_byte(f); s->id.cu_type = qemu_get_be16(f); s->id.cu_model = qemu_get_byte(f); s->id.dev_type = qemu_get_be16(f); s->id.dev_model = qemu_get_byte(f); s->id.unused = qemu_get_byte(f); for (i = 0; i < ARRAY_SIZE(s->id.ciw); i++) { s->id.ciw[i].type = qemu_get_byte(f); s->id.ciw[i].command = qemu_get_byte(f); s->id.ciw[i].count = qemu_get_be16(f); } s->ccw_fmt_1 = qemu_get_byte(f); s->ccw_no_data_cnt = qemu_get_byte(f); /* * Hack alert. We don't migrate the channel subsystem status (no * device!), but we need to find out if the guest enabled mss/mcss-e. * If the subchannel is enabled, it certainly was able to access it, * so adjust the max_ssid/max_cssid values for relevant ssid/cssid * values. This is not watertight, but better than nothing. */ if (s->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA) { if (s->ssid) { channel_subsys.max_ssid = MAX_SSID; } if (s->cssid != channel_subsys.default_cssid) { channel_subsys.max_cssid = MAX_CSSID; } } return 0; }
25,762