id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
6,450
void idct_put_altivec(uint8_t* dest, int stride, vector_s16_t* block) { POWERPC_TBL_DECLARE(altivec_idct_put_num, 1); #ifdef ALTIVEC_USE_REFERENCE_C_CODE POWERPC_TBL_START_COUNT(altivec_idct_put_num, 1); void simple_idct_put(uint8_t *dest, int line_size, int16_t *block); simple_idct_put(dest, stride, (int16_t*)block); POWERPC_TBL_STOP_COUNT(altivec_idct_put_num, 1); #else /* ALTIVEC_USE_REFERENCE_C_CODE */ vector_u8_t tmp; POWERPC_TBL_START_COUNT(altivec_idct_put_num, 1); IDCT #define COPY(dest,src) \ tmp = vec_packsu (src, src); \ vec_ste ((vector_u32_t)tmp, 0, (unsigned int *)dest); \ vec_ste ((vector_u32_t)tmp, 4, (unsigned int *)dest); COPY (dest, vx0) dest += stride; COPY (dest, vx1) dest += stride; COPY (dest, vx2) dest += stride; COPY (dest, vx3) dest += stride; COPY (dest, vx4) dest += stride; COPY (dest, vx5) dest += stride; COPY (dest, vx6) dest += stride; COPY (dest, vx7) POWERPC_TBL_STOP_COUNT(altivec_idct_put_num, 1); #endif /* ALTIVEC_USE_REFERENCE_C_CODE */ }
false
FFmpeg
e45a2872fafe631c14aee9f79d0963d68c4fc1fd
6,451
static void opt_top_field_first(const char *arg) { top_field_first= atoi(arg); }
false
FFmpeg
bdf3d3bf9dce398acce608de77da205e08bdace3
6,453
static int mjpegb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MJpegDecodeContext *s = avctx->priv_data; const uint8_t *buf_end, *buf_ptr; AVFrame *picture = data; GetBitContext hgb; /* for the header */ uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs; uint32_t field_size, sod_offs; buf_ptr = buf; buf_end = buf + buf_size; read_header: /* reset on every SOI */ s->restart_interval = 0; s->restart_count = 0; s->mjpb_skiptosod = 0; if (buf_end - buf_ptr >= 1 << 28) return AVERROR_INVALIDDATA; init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8); skip_bits(&hgb, 32); /* reserved zeros */ if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g')) { av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n"); return AVERROR_INVALIDDATA; } field_size = get_bits_long(&hgb, 32); /* field size */ av_log(avctx, AV_LOG_DEBUG, "field size: 0x%x\n", field_size); skip_bits(&hgb, 32); /* padded field size */ second_field_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "second_field_offs is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "second field offs: 0x%x\n", second_field_offs); dqt_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dqt is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%x\n", dqt_offs); if (dqt_offs) { init_get_bits(&s->gb, buf_ptr+dqt_offs, (buf_end - (buf_ptr+dqt_offs))*8); s->start_code = DQT; if (ff_mjpeg_decode_dqt(s) < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; } dht_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dht is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%x\n", dht_offs); if (dht_offs) { init_get_bits(&s->gb, buf_ptr+dht_offs, (buf_end - (buf_ptr+dht_offs))*8); s->start_code = DHT; ff_mjpeg_decode_dht(s); } sof_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%x\n", sof_offs); if (sof_offs) { init_get_bits(&s->gb, buf_ptr+sof_offs, (buf_end - (buf_ptr+sof_offs))*8); s->start_code = SOF0; if (ff_mjpeg_decode_sof(s) < 0) return -1; } sos_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sos is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%x\n", sos_offs); sod_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs); if (sos_offs) { init_get_bits(&s->gb, buf_ptr + sos_offs, 8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs)); s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16)); s->start_code = SOS; if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; } if (s->interlaced) { s->bottom_field ^= 1; /* if not bottom field, do not output image yet */ if (s->bottom_field != s->interlace_polarity && second_field_offs) { buf_ptr = buf + second_field_offs; goto read_header; } } //XXX FIXME factorize, this looks very similar to the EOI code *picture= *s->picture_ptr; *data_size = sizeof(AVFrame); if(!s->lossless){ picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]); picture->qstride= 0; picture->qscale_table= s->qscale_table; memset(picture->qscale_table, picture->quality, (s->width+15)/16); if(avctx->debug & FF_DEBUG_QP) av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality); picture->quality*= FF_QP2LAMBDA; } return buf_size; }
true
FFmpeg
9a4f5b76169a71156819dbaa8ee0b6ea25dc7195
6,454
static void pl110_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); k->init = pl110_initfn; set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); dc->no_user = 1; dc->vmsd = &vmstate_pl110; }
true
qemu
efec3dd631d94160288392721a5f9c39e50fb2bc
6,456
static always_inline void fload_invalid_op_excp (int op) { int ve; ve = fpscr_ve; if (op & POWERPC_EXCP_FP_VXSNAN) { /* Operation on signaling NaN */ env->fpscr |= 1 << FPSCR_VXSNAN; } if (op & POWERPC_EXCP_FP_VXSOFT) { /* Software-defined condition */ env->fpscr |= 1 << FPSCR_VXSOFT; } switch (op & ~(POWERPC_EXCP_FP_VXSOFT | POWERPC_EXCP_FP_VXSNAN)) { case POWERPC_EXCP_FP_VXISI: /* Magnitude subtraction of infinities */ env->fpscr |= 1 << FPSCR_VXISI; goto update_arith; case POWERPC_EXCP_FP_VXIDI: /* Division of infinity by infinity */ env->fpscr |= 1 << FPSCR_VXIDI; goto update_arith; case POWERPC_EXCP_FP_VXZDZ: /* Division of zero by zero */ env->fpscr |= 1 << FPSCR_VXZDZ; goto update_arith; case POWERPC_EXCP_FP_VXIMZ: /* Multiplication of zero by infinity */ env->fpscr |= 1 << FPSCR_VXIMZ; goto update_arith; case POWERPC_EXCP_FP_VXVC: /* Ordered comparison of NaN */ env->fpscr |= 1 << FPSCR_VXVC; env->fpscr &= ~(0xF << FPSCR_FPCC); env->fpscr |= 0x11 << FPSCR_FPCC; /* We must update the target FPR before raising the exception */ if (ve != 0) { env->exception_index = POWERPC_EXCP_PROGRAM; env->error_code = POWERPC_EXCP_FP | POWERPC_EXCP_FP_VXVC; /* Update the floating-point enabled exception summary */ env->fpscr |= 1 << FPSCR_FEX; /* Exception is differed */ ve = 0; } break; case POWERPC_EXCP_FP_VXSQRT: /* Square root of a negative number */ env->fpscr |= 1 << FPSCR_VXSQRT; update_arith: env->fpscr &= ~((1 << FPSCR_FR) | (1 << FPSCR_FI)); if (ve == 0) { /* Set the result to quiet NaN */ FT0 = (uint64_t)-1; env->fpscr &= ~(0xF << FPSCR_FPCC); env->fpscr |= 0x11 << FPSCR_FPCC; } break; case POWERPC_EXCP_FP_VXCVI: /* Invalid conversion */ env->fpscr |= 1 << FPSCR_VXCVI; env->fpscr &= ~((1 << FPSCR_FR) | (1 << FPSCR_FI)); if (ve == 0) { /* Set the result to quiet NaN */ FT0 = (uint64_t)-1; env->fpscr &= ~(0xF << FPSCR_FPCC); env->fpscr |= 0x11 << FPSCR_FPCC; } break; } /* Update the floating-point invalid operation summary */ env->fpscr |= 1 << FPSCR_VX; /* Update the floating-point exception summary */ env->fpscr |= 1 << FPSCR_FX; if (ve != 0) { /* Update the floating-point enabled exception summary */ env->fpscr |= 1 << FPSCR_FEX; if (msr_fe0 != 0 || msr_fe1 != 0) do_raise_exception_err(POWERPC_EXCP_PROGRAM, POWERPC_EXCP_FP | op); } }
true
qemu
6f2d8978728c48ca46f5c01835438508aace5c64
6,457
void gd_egl_scanout(DisplayChangeListener *dcl, uint32_t backing_id, bool backing_y_0_top, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); vc->gfx.x = x; vc->gfx.y = y; vc->gfx.w = w; vc->gfx.h = h; vc->gfx.tex_id = backing_id; vc->gfx.y0_top = backing_y_0_top; eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); if (vc->gfx.tex_id == 0 || vc->gfx.w == 0 || vc->gfx.h == 0) { gtk_egl_set_scanout_mode(vc, false); return; } gtk_egl_set_scanout_mode(vc, true); if (!vc->gfx.fbo_id) { glGenFramebuffers(1, &vc->gfx.fbo_id); } glBindFramebuffer(GL_FRAMEBUFFER_EXT, vc->gfx.fbo_id); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, vc->gfx.tex_id, 0); }
true
qemu
9d8256ebc0ef88fb1f35d0405893962d20cc10ad
6,458
static av_cold int vaapi_encode_check_config(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; VAStatus vas; int i, n, err; VAProfile *profiles = NULL; VAEntrypoint *entrypoints = NULL; VAConfigAttrib attr[] = { { VAConfigAttribRateControl }, { VAConfigAttribEncMaxRefFrames }, }; n = vaMaxNumProfiles(ctx->hwctx->display); profiles = av_malloc_array(n, sizeof(VAProfile)); if (!profiles) { err = AVERROR(ENOMEM); goto fail; } vas = vaQueryConfigProfiles(ctx->hwctx->display, profiles, &n); if (vas != VA_STATUS_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Failed to query profiles: %d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(ENOSYS); goto fail; } for (i = 0; i < n; i++) { if (profiles[i] == ctx->va_profile) break; } if (i >= n) { av_log(ctx, AV_LOG_ERROR, "Encoding profile not found (%d).\n", ctx->va_profile); err = AVERROR(ENOSYS); goto fail; } n = vaMaxNumEntrypoints(ctx->hwctx->display); entrypoints = av_malloc_array(n, sizeof(VAEntrypoint)); if (!entrypoints) { err = AVERROR(ENOMEM); goto fail; } vas = vaQueryConfigEntrypoints(ctx->hwctx->display, ctx->va_profile, entrypoints, &n); if (vas != VA_STATUS_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Failed to query entrypoints for " "profile %u: %d (%s).\n", ctx->va_profile, vas, vaErrorStr(vas)); err = AVERROR(ENOSYS); goto fail; } for (i = 0; i < n; i++) { if (entrypoints[i] == ctx->va_entrypoint) break; } if (i >= n) { av_log(ctx, AV_LOG_ERROR, "Encoding entrypoint not found " "(%d / %d).\n", ctx->va_profile, ctx->va_entrypoint); err = AVERROR(ENOSYS); goto fail; } vas = vaGetConfigAttributes(ctx->hwctx->display, ctx->va_profile, ctx->va_entrypoint, attr, FF_ARRAY_ELEMS(attr)); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to fetch config " "attributes: %d (%s).\n", vas, vaErrorStr(vas)); return AVERROR(EINVAL); } for (i = 0; i < FF_ARRAY_ELEMS(attr); i++) { if (attr[i].value == VA_ATTRIB_NOT_SUPPORTED) { // Unfortunately we have to treat this as "don't know" and hope // for the best, because the Intel MJPEG encoder returns this // for all the interesting attributes. continue; } switch (attr[i].type) { case VAConfigAttribRateControl: if (!(ctx->va_rc_mode & attr[i].value)) { av_log(avctx, AV_LOG_ERROR, "Rate control mode is not " "supported: %x\n", attr[i].value); err = AVERROR(EINVAL); goto fail; } break; case VAConfigAttribEncMaxRefFrames: { unsigned int ref_l0 = attr[i].value & 0xffff; unsigned int ref_l1 = (attr[i].value >> 16) & 0xffff; if (avctx->gop_size > 1 && ref_l0 < 1) { av_log(avctx, AV_LOG_ERROR, "P frames are not " "supported (%x).\n", attr[i].value); err = AVERROR(EINVAL); goto fail; } if (avctx->max_b_frames > 0 && ref_l1 < 1) { av_log(avctx, AV_LOG_ERROR, "B frames are not " "supported (%x).\n", attr[i].value); err = AVERROR(EINVAL); goto fail; } } break; } } err = 0; fail: av_freep(&profiles); av_freep(&entrypoints); return err; }
false
FFmpeg
80a5d05108cb218e8cd2e25c6621a3bfef0a832e
6,459
static int64_t qemu_icount_delta(void) { if (!use_icount) { return 5000 * (int64_t) 1000000; } else if (use_icount == 1) { /* When not using an adaptive execution frequency we tend to get badly out of sync with real time, so just delay for a reasonable amount of time. */ return 0; } else { return cpu_get_icount() - cpu_get_clock(); } }
true
qemu
12d4536f7d911b6d87a766ad7300482ea663cea2
6,460
static int unpack_parse_unit(DiracParseUnit *pu, DiracParseContext *pc, int offset) { uint8_t *start = pc->buffer + offset; uint8_t *end = pc->buffer + pc->index; if (start < pc->buffer || (start + 13 > end)) return 0; pu->pu_type = start[4]; pu->next_pu_offset = AV_RB32(start + 5); pu->prev_pu_offset = AV_RB32(start + 9); if (pu->pu_type == 0x10 && pu->next_pu_offset == 0) pu->next_pu_offset = 13; return 1; }
true
FFmpeg
79798f7c57b098c78e0bbc6becd64b9888b013d1
6,462
int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index, uint64_t *refcount) { BDRVQcowState *s = bs->opaque; uint64_t refcount_table_index, block_index; int64_t refcount_block_offset; int ret; uint16_t *refcount_block; refcount_table_index = cluster_index >> s->refcount_block_bits; if (refcount_table_index >= s->refcount_table_size) { *refcount = 0; return 0; } refcount_block_offset = s->refcount_table[refcount_table_index] & REFT_OFFSET_MASK; if (!refcount_block_offset) { *refcount = 0; return 0; } if (offset_into_cluster(s, refcount_block_offset)) { qcow2_signal_corruption(bs, true, -1, -1, "Refblock offset %#" PRIx64 " unaligned (reftable index: %#" PRIx64 ")", refcount_block_offset, refcount_table_index); return -EIO; } ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset, (void**) &refcount_block); if (ret < 0) { return ret; } block_index = cluster_index & (s->refcount_block_size - 1); *refcount = be16_to_cpu(refcount_block[block_index]); ret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) &refcount_block); if (ret < 0) { return ret; } return 0; }
true
qemu
7453c96b78c2b09aa72924f933bb9616e5474194
6,463
static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len) { unsigned char response[VNC_AUTH_CHALLENGE_SIZE]; size_t i, pwlen; unsigned char key[8]; time_t now = time(NULL); QCryptoCipher *cipher = NULL; Error *err = NULL; if (!vs->vd->password) { VNC_DEBUG("No password configured on server"); goto reject; } if (vs->vd->expires < now) { VNC_DEBUG("Password is expired"); goto reject; } memcpy(response, vs->challenge, VNC_AUTH_CHALLENGE_SIZE); /* Calculate the expected challenge response */ pwlen = strlen(vs->vd->password); for (i=0; i<sizeof(key); i++) key[i] = i<pwlen ? vs->vd->password[i] : 0; cipher = qcrypto_cipher_new( QCRYPTO_CIPHER_ALG_DES_RFB, QCRYPTO_CIPHER_MODE_ECB, key, G_N_ELEMENTS(key), &err); if (!cipher) { VNC_DEBUG("Cannot initialize cipher %s", error_get_pretty(err)); error_free(err); goto reject; } if (qcrypto_cipher_encrypt(cipher, vs->challenge, response, VNC_AUTH_CHALLENGE_SIZE, &err) < 0) { VNC_DEBUG("Cannot encrypt challenge %s", error_get_pretty(err)); error_free(err); goto reject; } /* Compare expected vs actual challenge response */ if (memcmp(response, data, VNC_AUTH_CHALLENGE_SIZE) != 0) { VNC_DEBUG("Client challenge response did not match\n"); goto reject; } else { VNC_DEBUG("Accepting VNC challenge response\n"); vnc_write_u32(vs, 0); /* Accept auth */ vnc_flush(vs); start_client_init(vs); } qcrypto_cipher_free(cipher); return 0; reject: vnc_write_u32(vs, 1); /* Reject auth */ if (vs->minor >= 8) { static const char err[] = "Authentication failed"; vnc_write_u32(vs, sizeof(err)); vnc_write(vs, err, sizeof(err)); } vnc_flush(vs); vnc_client_error(vs); qcrypto_cipher_free(cipher); return 0; }
true
qemu
7364dbdabb7824d5bde1e341bb6d928282f01c83
6,464
QapiDeallocVisitor *qapi_dealloc_visitor_new(void) { QapiDeallocVisitor *v; v = g_malloc0(sizeof(*v)); v->visitor.start_struct = qapi_dealloc_start_struct; v->visitor.end_struct = qapi_dealloc_end_struct; v->visitor.start_implicit_struct = qapi_dealloc_start_implicit_struct; v->visitor.end_implicit_struct = qapi_dealloc_end_implicit_struct; v->visitor.start_list = qapi_dealloc_start_list; v->visitor.next_list = qapi_dealloc_next_list; v->visitor.end_list = qapi_dealloc_end_list; v->visitor.type_enum = qapi_dealloc_type_enum; v->visitor.type_int64 = qapi_dealloc_type_int64; v->visitor.type_uint64 = qapi_dealloc_type_uint64; v->visitor.type_bool = qapi_dealloc_type_bool; v->visitor.type_str = qapi_dealloc_type_str; v->visitor.type_number = qapi_dealloc_type_number; v->visitor.type_any = qapi_dealloc_type_anything; v->visitor.start_union = qapi_dealloc_start_union; QTAILQ_INIT(&v->stack); return v; }
true
qemu
544a3731591f5d53e15f22de00ce5ac758d490b3
6,465
static void test_qemu_strtoll_empty(void) { const char *str = ""; 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_cmpint(res, ==, 0); g_assert(endptr == str); }
true
qemu
47d4be12c3997343e436c6cca89aefbbbeb70863
6,466
static void adb_kbd_realizefn(DeviceState *dev, Error **errp) { ADBKeyboardClass *akc = ADB_KEYBOARD_GET_CLASS(dev); akc->parent_realize(dev, errp); qemu_input_handler_register(dev, &adb_keyboard_handler); }
true
qemu
77cb0f5aafc8e6d0c6d3c339f381c9b7921648e0
6,468
static int h264_init_context(AVCodecContext *avctx, H264Context *h) { int i; h->avctx = avctx; h->picture_structure = PICT_FRAME; h->workaround_bugs = avctx->workaround_bugs; h->flags = avctx->flags; h->poc.prev_poc_msb = 1 << 16; h->recovery_frame = -1; h->frame_recovered = 0; h->next_outputed_poc = INT_MIN; for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) h->last_pocs[i] = INT_MIN; ff_h264_sei_uninit(&h->sei); avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? avctx->thread_count : 1; h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx)); if (!h->slice_ctx) { h->nb_slice_ctx = 0; return AVERROR(ENOMEM); } for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) { h->DPB[i].f = av_frame_alloc(); if (!h->DPB[i].f) return AVERROR(ENOMEM); } h->cur_pic.f = av_frame_alloc(); if (!h->cur_pic.f) return AVERROR(ENOMEM); h->output_frame = av_frame_alloc(); if (!h->output_frame) return AVERROR(ENOMEM); for (i = 0; i < h->nb_slice_ctx; i++) h->slice_ctx[i].h264 = h; return 0; }
true
FFmpeg
4fded0480f20f4d7ca5e776a85574de34dfead14
6,469
static int xcbgrab_reposition(AVFormatContext *s, xcb_query_pointer_reply_t *p, xcb_get_geometry_reply_t *geo) { XCBGrabContext *c = s->priv_data; int x = c->x, y = c->y, p_x = p->win_x, p_y = p->win_y; int w = c->width, h = c->height, f = c->follow_mouse; if (!p || !geo) return AVERROR(EIO); if (f == FOLLOW_CENTER) { x = p_x - w / 2; y = p_y - h / 2; } else { int left = x + f; int right = x + w - f; int top = y + f; int bottom = y + h + f; if (p_x > right) { x += p_x - right; } else if (p_x < left) { x -= left - p_x; } if (p_y > bottom) { y += p_y - bottom; } else if (p_y < top) { y -= top - p_y; } } c->x = FFMIN(FFMAX(0, x), geo->width - w); c->y = FFMIN(FFMAX(0, y), geo->height - h); return 0; }
false
FFmpeg
e86df0206f06b8d1e97e2b60db8f74a398d53127
6,470
clk_setup_cb cpu_ppc_tb_init (CPUPPCState *env, uint32_t freq) { PowerPCCPU *cpu = ppc_env_get_cpu(env); ppc_tb_t *tb_env; tb_env = g_malloc0(sizeof(ppc_tb_t)); env->tb_env = tb_env; tb_env->flags = PPC_DECR_UNDERFLOW_TRIGGERED; if (env->insns_flags & PPC_SEGMENT_64B) { /* All Book3S 64bit CPUs implement level based DEC logic */ tb_env->flags |= PPC_DECR_UNDERFLOW_LEVEL; } /* Create new timer */ tb_env->decr_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, &cpu_ppc_decr_cb, cpu); if (0) { /* XXX: find a suitable condition to enable the hypervisor decrementer */ tb_env->hdecr_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, &cpu_ppc_hdecr_cb, cpu); } else { tb_env->hdecr_timer = NULL; } cpu_ppc_set_tb_clk(env, freq); return &cpu_ppc_set_tb_clk; }
true
qemu
4b236b621bf090509c4a0be372edfd31d13b289a
6,471
static int tscc2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TSCC2Context *c = avctx->priv_data; GetByteContext gb; uint32_t frame_type, size; int i, val, len, pos = 0; int num_mb = c->mb_width * c->mb_height; int ret; bytestream2_init(&gb, buf, buf_size); frame_type = bytestream2_get_byte(&gb); if (frame_type > 1) { av_log(avctx, AV_LOG_ERROR, "Incorrect frame type %"PRIu32"\n", frame_type); return AVERROR_INVALIDDATA; } if ((ret = ff_reget_buffer(avctx, c->pic)) < 0) { return ret; } if (frame_type == 0) { *got_frame = 1; if ((ret = av_frame_ref(data, c->pic)) < 0) return ret; return buf_size; } if (bytestream2_get_bytes_left(&gb) < 4) { av_log(avctx, AV_LOG_ERROR, "Frame is too short\n"); return AVERROR_INVALIDDATA; } c->quant[0] = bytestream2_get_byte(&gb); c->quant[1] = bytestream2_get_byte(&gb); if (c->quant[0] < 2 || c->quant[0] > NUM_VLC_SETS + 1 || c->quant[1] < 2 || c->quant[1] > NUM_VLC_SETS + 1) { av_log(avctx, AV_LOG_ERROR, "Invalid quantisers %d / %d\n", c->quant[0], c->quant[1]); return AVERROR_INVALIDDATA; } for (i = 0; i < 3; i++) { c->q[0][i] = tscc2_quants[c->quant[0] - 2][i]; c->q[1][i] = tscc2_quants[c->quant[1] - 2][i]; } bytestream2_skip(&gb, 1); size = bytestream2_get_le32(&gb); if (size > bytestream2_get_bytes_left(&gb)) { av_log(avctx, AV_LOG_ERROR, "Slice properties chunk is too large\n"); return AVERROR_INVALIDDATA; } for (i = 0; i < size; i++) { val = bytestream2_get_byte(&gb); len = val & 0x3F; val >>= 6; if (pos + len > num_mb) { av_log(avctx, AV_LOG_ERROR, "Too many slice properties\n"); return AVERROR_INVALIDDATA; } memset(c->slice_quants + pos, val, len); pos += len; } if (pos < num_mb) { av_log(avctx, AV_LOG_ERROR, "Too few slice properties (%d / %d)\n", pos, num_mb); return AVERROR_INVALIDDATA; } for (i = 0; i < c->mb_height; i++) { size = bytestream2_peek_byte(&gb); if (size & 1) { size = bytestream2_get_byte(&gb) - 1; } else { size = bytestream2_get_le32(&gb) >> 1; } if (!size) { int skip_row = 1, j, off = i * c->mb_width; for (j = 0; j < c->mb_width; j++) { if (c->slice_quants[off + j] == 1 || c->slice_quants[off + j] == 2) { skip_row = 0; break; } } if (!skip_row) { av_log(avctx, AV_LOG_ERROR, "Non-skip row with zero size\n"); return AVERROR_INVALIDDATA; } } if (bytestream2_get_bytes_left(&gb) < size) { av_log(avctx, AV_LOG_ERROR, "Invalid slice size (%"PRIu32"/%u)\n", size, bytestream2_get_bytes_left(&gb)); return AVERROR_INVALIDDATA; } ret = tscc2_decode_slice(c, i, buf + bytestream2_tell(&gb), size); if (ret) { av_log(avctx, AV_LOG_ERROR, "Error decoding slice %d\n", i); return ret; } bytestream2_skip(&gb, size); } *got_frame = 1; if ((ret = av_frame_ref(data, c->pic)) < 0) return ret; /* always report that the buffer was completely consumed */ return buf_size; }
true
FFmpeg
4dc3714c48e74e75a3a9c7d9fb52fd5917107508
6,472
static void test_ide_mbr(bool use_device, MBRcontents mbr) { char *argv[256]; int argc; Backend i; const char *dev; argc = setup_common(argv, ARRAY_SIZE(argv)); for (i = 0; i < backend_last; i++) { cur_ide[i] = &hd_chst[i][mbr]; dev = use_device ? (is_hd(cur_ide[i]) ? "ide-hd" : "ide-cd") : NULL; argc = setup_ide(argc, argv, ARRAY_SIZE(argv), i, dev, i, mbr, ""); } qtest_start(g_strjoinv(" ", argv)); test_cmos(); qtest_end(); }
true
qemu
2c8f86961b6eaac705be21bc98299f5517eb0b6b
6,473
static int ram_save_block(QEMUFile *f, bool last_stage) { RAMBlock *block = last_seen_block; ram_addr_t offset = last_offset; bool complete_round = false; int bytes_sent = 0; MemoryRegion *mr; ram_addr_t current_addr; if (!block) block = QTAILQ_FIRST(&ram_list.blocks); while (true) { mr = block->mr; offset = migration_bitmap_find_and_reset_dirty(mr, offset); if (complete_round && block == last_seen_block && offset >= last_offset) { break; } if (offset >= block->length) { offset = 0; block = QTAILQ_NEXT(block, next); if (!block) { block = QTAILQ_FIRST(&ram_list.blocks); complete_round = true; ram_bulk_stage = false; } } else { int ret; uint8_t *p; int cont = (block == last_sent_block) ? RAM_SAVE_FLAG_CONTINUE : 0; p = memory_region_get_ram_ptr(mr) + offset; /* In doubt sent page as normal */ bytes_sent = -1; ret = ram_control_save_page(f, block->offset, offset, TARGET_PAGE_SIZE, &bytes_sent); if (ret != RAM_SAVE_CONTROL_NOT_SUPP) { if (ret != RAM_SAVE_CONTROL_DELAYED) { if (bytes_sent > 0) { acct_info.norm_pages++; } else if (bytes_sent == 0) { acct_info.dup_pages++; } } } else if (is_zero_range(p, TARGET_PAGE_SIZE)) { acct_info.dup_pages++; bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_COMPRESS); qemu_put_byte(f, 0); bytes_sent++; } else if (!ram_bulk_stage && migrate_use_xbzrle()) { current_addr = block->offset + offset; bytes_sent = save_xbzrle_page(f, p, current_addr, block, offset, cont, last_stage); if (!last_stage) { p = get_cached_data(XBZRLE.cache, current_addr); } } /* XBZRLE overflow or normal page */ if (bytes_sent == -1) { bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_PAGE); qemu_put_buffer_async(f, p, TARGET_PAGE_SIZE); bytes_sent += TARGET_PAGE_SIZE; acct_info.norm_pages++; } /* if page is unmodified, continue to the next */ if (bytes_sent > 0) { last_sent_block = block; break; } } } last_seen_block = block; last_offset = offset; return bytes_sent; }
true
qemu
6d3cb1f970ee85361618f7ff02869180394e012d
6,474
static inline void RENAME(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, unsigned src_size) { const uint8_t *s = src; const uint8_t *end; #ifdef HAVE_MMX const uint8_t *mm_end; #endif uint16_t *d = (uint16_t *)dst; end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); __asm __volatile( "movq %0, %%mm7\n\t" "movq %1, %%mm6\n\t" ::"m"(red_15mask),"m"(green_15mask)); mm_end = end - 15; while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movd %1, %%mm0\n\t" "movd 4%1, %%mm3\n\t" "punpckldq 8%1, %%mm0\n\t" "punpckldq 12%1, %%mm3\n\t" "movq %%mm0, %%mm1\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm3, %%mm4\n\t" "movq %%mm3, %%mm5\n\t" "psllq $7, %%mm0\n\t" "psllq $7, %%mm3\n\t" "pand %%mm7, %%mm0\n\t" "pand %%mm7, %%mm3\n\t" "psrlq $6, %%mm1\n\t" "psrlq $6, %%mm4\n\t" "pand %%mm6, %%mm1\n\t" "pand %%mm6, %%mm4\n\t" "psrlq $19, %%mm2\n\t" "psrlq $19, %%mm5\n\t" "pand %2, %%mm2\n\t" "pand %2, %%mm5\n\t" "por %%mm1, %%mm0\n\t" "por %%mm4, %%mm3\n\t" "por %%mm2, %%mm0\n\t" "por %%mm5, %%mm3\n\t" "psllq $16, %%mm3\n\t" "por %%mm3, %%mm0\n\t" MOVNTQ" %%mm0, %0\n\t" :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); d += 4; s += 16; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { // FIXME on bigendian const int src= *s; s += 4; *d++ = ((src&0xF8)<<7) + ((src&0xF800)>>6) + ((src&0xF80000)>>19); } }
true
FFmpeg
7f526efd17973ec6d2204f7a47b6923e2be31363
6,475
static int vp3_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { Vp3DecodeContext *s = avctx->priv_data; GetBitContext gb; static int counter = 0; *data_size = 0; init_get_bits(&gb, buf, buf_size * 8); s->keyframe = get_bits(&gb, 1); s->keyframe ^= 1; skip_bits(&gb, 1); s->last_quality_index = s->quality_index; s->quality_index = get_bits(&gb, 6); if (s->quality_index != s->last_quality_index) init_dequantizer(s); debug_vp3(" VP3 frame #%d: Q index = %d", counter, s->quality_index); counter++; if (s->keyframe) { if ((s->golden_frame.data[0]) && (s->last_frame.data[0] == s->golden_frame.data[0])) avctx->release_buffer(avctx, &s->golden_frame); else if (s->last_frame.data[0]) avctx->release_buffer(avctx, &s->last_frame); s->golden_frame.reference = 0; if(avctx->get_buffer(avctx, &s->golden_frame) < 0) { printf("vp3: get_buffer() failed\n"); return -1; } /* golden frame is also the current frame */ memcpy(&s->current_frame, &s->golden_frame, sizeof(AVFrame)); /* time to figure out pixel addresses? */ if (!s->pixel_addresses_inited) vp3_calculate_pixel_addresses(s); } else { /* allocate a new current frame */ s->current_frame.reference = 0; if(avctx->get_buffer(avctx, &s->current_frame) < 0) { printf("vp3: get_buffer() failed\n"); return -1; } } if (s->keyframe) { debug_vp3(", keyframe\n"); /* skip the other 2 header bytes for now */ skip_bits(&gb, 16); } else debug_vp3("\n"); init_frame(s, &gb); #if KEYFRAMES_ONLY if (!s->keyframe) { memcpy(s->current_frame.data[0], s->golden_frame.data[0], s->current_frame.linesize[0] * s->height); memcpy(s->current_frame.data[1], s->golden_frame.data[1], s->current_frame.linesize[1] * s->height / 2); memcpy(s->current_frame.data[2], s->golden_frame.data[2], s->current_frame.linesize[2] * s->height / 2); } else { #endif if (unpack_superblocks(s, &gb) || unpack_modes(s, &gb) || unpack_vectors(s, &gb) || unpack_dct_coeffs(s, &gb)) { printf(" vp3: could not decode frame\n"); return -1; } reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height); reverse_dc_prediction(s, s->u_fragment_start, s->fragment_width / 2, s->fragment_height / 2); reverse_dc_prediction(s, s->v_fragment_start, s->fragment_width / 2, s->fragment_height / 2); render_fragments(s, 0, s->width, s->height, 0); render_fragments(s, s->u_fragment_start, s->width / 2, s->height / 2, 1); render_fragments(s, s->v_fragment_start, s->width / 2, s->height / 2, 2); #if KEYFRAMES_ONLY } #endif *data_size=sizeof(AVFrame); *(AVFrame*)data= s->current_frame; /* release the last frame, if it is allocated and if it is not the * golden frame */ if ((s->last_frame.data[0]) && (s->last_frame.data[0] != s->golden_frame.data[0])) avctx->release_buffer(avctx, &s->last_frame); /* shuffle frames (last = current) */ memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame)); return buf_size; }
true
FFmpeg
74c0ac127407847525a7fe38818de0dd772a20b9
6,476
static int ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p) { CCID_Header *ccid_header; if (p->len + s->bulk_out_pos > BULK_OUT_DATA_SIZE) { return USB_RET_STALL; } ccid_header = (CCID_Header *)s->bulk_out_data; memcpy(s->bulk_out_data + s->bulk_out_pos, p->data, p->len); s->bulk_out_pos += p->len; if (p->len == CCID_MAX_PACKET_SIZE) { DPRINTF(s, D_VERBOSE, "usb-ccid: bulk_in: expecting more packets (%d/%d)\n", p->len, ccid_header->dwLength); return 0; } if (s->bulk_out_pos < 10) { DPRINTF(s, 1, "%s: bad USB_TOKEN_OUT length, should be at least 10 bytes\n", __func__); } else { DPRINTF(s, D_MORE_INFO, "%s %x\n", __func__, ccid_header->bMessageType); switch (ccid_header->bMessageType) { case CCID_MESSAGE_TYPE_PC_to_RDR_GetSlotStatus: ccid_write_slot_status(s, ccid_header); break; case CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOn: DPRINTF(s, 1, "PowerOn: %d\n", ((CCID_IccPowerOn *)(ccid_header))->bPowerSelect); s->powered = true; if (!ccid_card_inserted(s)) { ccid_report_error_failed(s, ERROR_ICC_MUTE); } /* atr is written regardless of error. */ ccid_write_data_block_atr(s, ccid_header); break; case CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOff: DPRINTF(s, 1, "PowerOff\n"); ccid_reset_error_status(s); s->powered = false; ccid_write_slot_status(s, ccid_header); break; case CCID_MESSAGE_TYPE_PC_to_RDR_XfrBlock: ccid_on_apdu_from_guest(s, (CCID_XferBlock *)s->bulk_out_data); break; case CCID_MESSAGE_TYPE_PC_to_RDR_SetParameters: ccid_reset_error_status(s); ccid_set_parameters(s, ccid_header); ccid_write_parameters(s, ccid_header); break; case CCID_MESSAGE_TYPE_PC_to_RDR_ResetParameters: ccid_reset_error_status(s); ccid_reset_parameters(s); ccid_write_parameters(s, ccid_header); break; case CCID_MESSAGE_TYPE_PC_to_RDR_GetParameters: ccid_reset_error_status(s); ccid_write_parameters(s, ccid_header); break; default: DPRINTF(s, 1, "handle_data: ERROR: unhandled message type %Xh\n", ccid_header->bMessageType); /* * The caller is expecting the device to respond, tell it we * don't support the operation. */ ccid_report_error_failed(s, ERROR_CMD_NOT_SUPPORTED); ccid_write_slot_status(s, ccid_header); break; } } s->bulk_out_pos = 0; return 0; }
true
qemu
4f4321c11ff6e98583846bfd6f0e81954924b003
6,477
static int vp9_alloc_frame(AVCodecContext *ctx, VP9Frame *f) { VP9Context *s = ctx->priv_data; int ret, sz; if ((ret = ff_thread_get_buffer(ctx, &f->tf, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; sz = 64 * s->sb_cols * s->sb_rows; if (!(f->extradata = av_buffer_allocz(sz * (1 + sizeof(struct VP9mvrefPair))))) { ff_thread_release_buffer(ctx, &f->tf); return AVERROR(ENOMEM); } f->segmentation_map = f->extradata->data; f->mv = (struct VP9mvrefPair *) (f->extradata->data + sz); // retain segmentation map if it doesn't update if (s->segmentation.enabled && !s->segmentation.update_map && !s->keyframe && !s->intraonly) { memcpy(f->segmentation_map, s->frames[LAST_FRAME].segmentation_map, sz); } return 0; }
true
FFmpeg
0c67864a37a5a6dee19341da6e6cfa369c52d1db
6,478
static int usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p, uint8_t ep) { AsyncURB *aurb = async_alloc(dev, p); struct usb_redir_bulk_packet_header bulk_packet; DPRINTF("bulk-out ep %02X len %d id %u\n", ep, p->len, aurb->packet_id); bulk_packet.endpoint = ep; bulk_packet.length = p->len; bulk_packet.stream_id = 0; aurb->bulk_packet = bulk_packet; if (ep & USB_DIR_IN) { usbredirparser_send_bulk_packet(dev->parser, aurb->packet_id, &bulk_packet, NULL, 0); } else { usbredir_log_data(dev, "bulk data out:", p->data, p->len); usbredirparser_send_bulk_packet(dev->parser, aurb->packet_id, &bulk_packet, p->data, p->len); } usbredirparser_do_write(dev->parser); return USB_RET_ASYNC; }
true
qemu
4f4321c11ff6e98583846bfd6f0e81954924b003
6,479
void do_info_vnc(void) { if (vnc_state == NULL) term_printf("VNC server disabled\n"); else { term_printf("VNC server active on: "); term_print_filename(vnc_state->display); term_printf("\n"); if (vnc_state->csock == -1) term_printf("No client connected\n"); else term_printf("Client connected\n"); } }
true
qemu
13412c9d2fce7c402e93a08177abdbc593208140
6,480
static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) { int ret = 0, i, got_packet = 0; AVDictionary *metadata = NULL; av_init_packet(pkt); while (!got_packet && !s->parse_queue) { AVStream *st; AVPacket cur_pkt; /* read next packet */ ret = ff_read_packet(s, &cur_pkt); if (ret < 0) { if (ret == AVERROR(EAGAIN)) return ret; /* flush the parsers */ for (i = 0; i < s->nb_streams; i++) { st = s->streams[i]; if (st->parser && st->need_parsing) parse_packet(s, NULL, st->index); } /* all remaining packets are now in parse_queue => * really terminate parsing */ break; } ret = 0; st = s->streams[cur_pkt.stream_index]; if (cur_pkt.pts != AV_NOPTS_VALUE && cur_pkt.dts != AV_NOPTS_VALUE && cur_pkt.pts < cur_pkt.dts) { av_log(s, AV_LOG_WARNING, "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n", cur_pkt.stream_index, av_ts2str(cur_pkt.pts), av_ts2str(cur_pkt.dts), cur_pkt.size); } if (s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n", cur_pkt.stream_index, av_ts2str(cur_pkt.pts), av_ts2str(cur_pkt.dts), cur_pkt.size, cur_pkt.duration, cur_pkt.flags); 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_VERBOSE, "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; else if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW) st->parser->flags |= PARSER_FLAG_USE_CODEC_TS; } if (!st->need_parsing || !st->parser) { /* no parsing needed: we just output the packet as is */ *pkt = cur_pkt; compute_pkt_fields(s, st, NULL, pkt); 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); } got_packet = 1; } else if (st->discard < AVDISCARD_ALL) { if ((ret = parse_packet(s, &cur_pkt, cur_pkt.stream_index)) < 0) return ret; } else { /* free packet */ av_free_packet(&cur_pkt); } if (pkt->flags & AV_PKT_FLAG_KEY) st->skip_to_keyframe = 0; if (st->skip_to_keyframe) { av_free_packet(&cur_pkt); if (got_packet) { *pkt = cur_pkt; } got_packet = 0; } } if (!got_packet && s->parse_queue) ret = read_from_packet_buffer(&s->parse_queue, &s->parse_queue_end, pkt); if (ret >= 0) { AVStream *st = s->streams[pkt->stream_index]; int discard_padding = 0; if (st->end_discard_sample && pkt->pts != AV_NOPTS_VALUE) { int64_t pts = pkt->pts - (is_relative(pkt->pts) ? RELATIVE_TS_BASE : 0); int64_t sample = ts_to_samples(st, pts); int duration = ts_to_samples(st, pkt->duration); int64_t end_sample = sample + duration; if (duration > 0 && end_sample >= st->end_discard_sample) discard_padding = FFMIN(end_sample - st->end_discard_sample, duration); } if (st->skip_samples || discard_padding) { uint8_t *p = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10); if (p) { AV_WL32(p, st->skip_samples); AV_WL32(p + 4, discard_padding); av_log(s, AV_LOG_DEBUG, "demuxer injecting skip %d\n", st->skip_samples); } st->skip_samples = 0; } if (st->inject_global_side_data) { for (i = 0; i < st->nb_side_data; i++) { AVPacketSideData *src_sd = &st->side_data[i]; uint8_t *dst_data; if (av_packet_get_side_data(pkt, src_sd->type, NULL)) continue; dst_data = av_packet_new_side_data(pkt, src_sd->type, src_sd->size); if (!dst_data) { av_log(s, AV_LOG_WARNING, "Could not inject global side data\n"); continue; } memcpy(dst_data, src_sd->data, src_sd->size); } st->inject_global_side_data = 0; } if (!(s->flags & AVFMT_FLAG_KEEP_SIDE_DATA)) av_packet_merge_side_data(pkt); } av_opt_get_dict_val(s, "metadata", AV_OPT_SEARCH_CHILDREN, &metadata); if (metadata) { s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; av_dict_copy(&s->metadata, metadata, 0); av_dict_free(&metadata); av_opt_set_dict_val(s, "metadata", NULL, AV_OPT_SEARCH_CHILDREN); } if (s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "read_frame_internal stream=%d, pts=%s, dts=%s, " "size=%d, duration=%d, flags=%d\n", pkt->stream_index, av_ts2str(pkt->pts), av_ts2str(pkt->dts), pkt->size, pkt->duration, pkt->flags); return ret; }
false
FFmpeg
6c7f1155bb648eced8e5aa08b1fd490df2f8b325
6,481
void ff_hevcdsp_init_x86(HEVCDSPContext *c, const int bit_depth) { int mm_flags = av_get_cpu_flags(); if (bit_depth == 8) { if (EXTERNAL_MMX(mm_flags)) { if (EXTERNAL_MMXEXT(mm_flags)) { if (EXTERNAL_SSSE3(mm_flags) && ARCH_X86_64) { EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 8); EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h, 8); EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v, 8); EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv, 8); QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 8); QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h, 8); QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v, 8); QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 8); } } } } else if (bit_depth == 10) { if (EXTERNAL_MMX(mm_flags)) { if (EXTERNAL_MMXEXT(mm_flags) && ARCH_X86_64) { if (EXTERNAL_SSSE3(mm_flags)) { EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 10); EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h, 10); EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v, 10); EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv, 10); QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 10); QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h, 10); QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v, 10); QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 10); } } } } }
false
FFmpeg
fc7d0d82017d67a1bbc0c1664144b756dc4ba6e3
6,482
static void postfilter(EVRCContext *e, float *in, const float *coeff, float *out, int idx, const struct PfCoeff *pfc, int length) { float wcoef1[FILTER_ORDER], wcoef2[FILTER_ORDER], scratch[SUBFRAME_SIZE], temp[SUBFRAME_SIZE], mem[SUBFRAME_SIZE]; float sum1 = 0.0, sum2 = 0.0, gamma, gain; float tilt = pfc->tilt; int i, n, best; bandwidth_expansion(wcoef1, coeff, pfc->p1); bandwidth_expansion(wcoef2, coeff, pfc->p2); /* Tilt compensation filter, TIA/IS-127 5.9.1 */ for (i = 0; i < length - 1; i++) sum2 += in[i] * in[i + 1]; if (sum2 < 0.0) tilt = 0.0; for (i = 0; i < length; i++) { scratch[i] = in[i] - tilt * e->last; e->last = in[i]; } /* Short term residual filter, TIA/IS-127 5.9.2 */ residual_filter(&e->postfilter_residual[ACB_SIZE], scratch, wcoef1, e->postfilter_fir, length); /* Long term postfilter */ best = idx; for (i = FFMIN(MIN_DELAY, idx - 3); i <= FFMAX(MAX_DELAY, idx + 3); i++) { for (n = ACB_SIZE, sum2 = 0; n < ACB_SIZE + length; n++) sum2 += e->postfilter_residual[n] * e->postfilter_residual[n - i]; if (sum2 > sum1) { sum1 = sum2; best = i; } } for (i = ACB_SIZE, sum1 = 0; i < ACB_SIZE + length; i++) sum1 += e->postfilter_residual[i - best] * e->postfilter_residual[i - best]; for (i = ACB_SIZE, sum2 = 0; i < ACB_SIZE + length; i++) sum2 += e->postfilter_residual[i] * e->postfilter_residual[i - best]; if (sum2 * sum1 == 0 || e->bitrate == RATE_QUANT) { memcpy(temp, e->postfilter_residual + ACB_SIZE, length * sizeof(float)); } else { gamma = sum2 / sum1; if (gamma < 0.5) memcpy(temp, e->postfilter_residual + ACB_SIZE, length * sizeof(float)); else { gamma = FFMIN(gamma, 1.0); for (i = 0; i < length; i++) { temp[i] = e->postfilter_residual[ACB_SIZE + i] + gamma * pfc->ltgain * e->postfilter_residual[ACB_SIZE + i - best]; } } } memcpy(scratch, temp, length * sizeof(float)); memcpy(mem, e->postfilter_iir, FILTER_ORDER * sizeof(float)); synthesis_filter(scratch, wcoef2, mem, length, scratch); /* Gain computation, TIA/IS-127 5.9.4-2 */ for (i = 0, sum1 = 0, sum2 = 0; i < length; i++) { sum1 += in[i] * in[i]; sum2 += scratch[i] * scratch[i]; } gain = sum2 ? sqrt(sum1 / sum2) : 1.0; for (i = 0; i < length; i++) temp[i] *= gain; /* Short term postfilter */ synthesis_filter(temp, wcoef2, e->postfilter_iir, length, out); memcpy(e->postfilter_residual, e->postfilter_residual + length, ACB_SIZE * sizeof(float)); }
false
FFmpeg
5ae484e350e4f1b20b31802dac59ca3519627c0a
6,483
int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type) { int f_code; if(s->me_method>=ME_EPZS){ int mv_num[8]; int i, y; int loose=0; UINT8 * fcode_tab= s->fcode_tab; for(i=0; i<8; i++) mv_num[i]=0; for(y=0; y<s->mb_height; y++){ int x; int xy= (y+1)* (s->mb_width+2) + 1; i= y*s->mb_width; for(x=0; x<s->mb_width; x++){ if(s->mb_type[i] & type){ mv_num[ fcode_tab[mv_table[xy][0] + MAX_MV] ]++; mv_num[ fcode_tab[mv_table[xy][1] + MAX_MV] ]++; //printf("%d %d %d\n", s->mv_table[0][i], fcode_tab[s->mv_table[0][i] + MAX_MV], i); } i++; xy++; } } for(i=MAX_FCODE; i>1; i--){ int threshold; loose+= mv_num[i]; if(s->pict_type==B_TYPE) threshold= 0; else threshold= s->mb_num/20; //FIXME if(loose > threshold) break; } // printf("fcode: %d type: %d\n", i, s->pict_type); return i; /* for(i=0; i<=MAX_FCODE; i++){ printf("%d ", mv_num[i]); } printf("\n");*/ }else{ return 1; } }
false
FFmpeg
0d21a84605bad4e75dacb8196e5859902ed36f01
6,484
static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; unsigned int i, entries; int64_t duration=0; int64_t total_sample_count=0; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; sc = st->priv_data; avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ entries = avio_rb32(pb); av_dlog(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries); if (!entries) return 0; if (entries >= UINT_MAX / sizeof(*sc->stts_data)) return AVERROR(EINVAL); 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=avio_rb32(pb); sample_duration = avio_rb32(pb); sc->stts_data[i].count= sample_count; sc->stts_data[i].duration= sample_duration; av_dlog(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; sc->track_end = duration; return 0; }
false
FFmpeg
9888ffb1ce5e0a17f711b01933d504c72ea29d3b
6,485
static void start_frame(AVFilterLink *link, AVFilterPicRef *picref) { CropContext *crop = link->dst->priv; AVFilterPicRef *ref2 = avfilter_ref_pic(picref, ~0); int i; ref2->w = crop->w; ref2->h = crop->h; ref2->data[0] += crop->y * ref2->linesize[0]; ref2->data[0] += (crop->x * crop->bpp) >> 3; if (link->format != PIX_FMT_PAL8 && link->format != PIX_FMT_BGR4_BYTE && link->format != PIX_FMT_RGB4_BYTE && link->format != PIX_FMT_BGR8 && link->format != PIX_FMT_RGB8) { for (i = 1; i < 3; i ++) { if (ref2->data[i]) { ref2->data[i] += (crop->y >> crop->vsub) * ref2->linesize[i]; ref2->data[i] += ((crop->x * crop->bpp) >> 3) >> crop->hsub; } } } /* alpha plane */ if (ref2->data[3]) { ref2->data[3] += crop->y * ref2->linesize[3]; ref2->data[3] += (crop->x * crop->bpp) >> 3; } avfilter_start_frame(link->dst->outputs[0], ref2); }
false
FFmpeg
ef9f8dd7305e39f5579b33abeec425c11f4f1b6d
6,487
static void lsi_execute_script(LSIState *s) { uint32_t insn; uint32_t addr; int opcode; s->istat1 |= LSI_ISTAT1_SRUN; again: insn = read_dword(s, s->dsp); addr = read_dword(s, s->dsp + 4); DPRINTF("SCRIPTS dsp=%08x opcode %08x arg %08x\n", s->dsp, insn, addr); s->dsps = addr; s->dcmd = insn >> 24; s->dsp += 8; switch (insn >> 30) { case 0: /* Block move. */ if (s->sist1 & LSI_SIST1_STO) { DPRINTF("Delayed select timeout\n"); lsi_stop_script(s); break; } s->dbc = insn & 0xffffff; s->rbc = s->dbc; if (insn & (1 << 29)) { /* Indirect addressing. */ addr = read_dword(s, addr); } else if (insn & (1 << 28)) { uint32_t buf[2]; int32_t offset; /* Table indirect addressing. */ offset = sxt24(addr); cpu_physical_memory_read(s->dsa + offset, (uint8_t *)buf, 8); s->dbc = cpu_to_le32(buf[0]); s->rbc = s->dbc; addr = cpu_to_le32(buf[1]); } if ((s->sstat1 & PHASE_MASK) != ((insn >> 24) & 7)) { DPRINTF("Wrong phase got %d expected %d\n", s->sstat1 & PHASE_MASK, (insn >> 24) & 7); lsi_script_scsi_interrupt(s, LSI_SIST0_MA, 0); break; } s->dnad = addr; /* ??? Set ESA. */ s->ia = s->dsp - 8; switch (s->sstat1 & 0x7) { case PHASE_DO: s->waiting = 2; lsi_do_dma(s, 1); if (s->waiting) s->waiting = 3; break; case PHASE_DI: s->waiting = 2; lsi_do_dma(s, 0); if (s->waiting) s->waiting = 3; break; case PHASE_CMD: lsi_do_command(s); break; case PHASE_ST: lsi_do_status(s); break; case PHASE_MO: lsi_do_msgout(s); break; case PHASE_MI: lsi_do_msgin(s); break; default: BADF("Unimplemented phase %d\n", s->sstat1 & PHASE_MASK); exit(1); } s->dfifo = s->dbc & 0xff; s->ctest5 = (s->ctest5 & 0xfc) | ((s->dbc >> 8) & 3); s->sbc = s->dbc; s->rbc -= s->dbc; s->ua = addr + s->dbc; break; case 1: /* IO or Read/Write instruction. */ opcode = (insn >> 27) & 7; if (opcode < 5) { uint32_t id; if (insn & (1 << 25)) { id = read_dword(s, s->dsa + sxt24(insn)); } else { id = addr; } id = (id >> 16) & 0xf; if (insn & (1 << 26)) { addr = s->dsp + sxt24(addr); } s->dnad = addr; switch (opcode) { case 0: /* Select */ s->sdid = id; if (s->current_dma_len && (s->ssid & 0xf) == id) { DPRINTF("Already reselected by target %d\n", id); break; } s->sstat0 |= LSI_SSTAT0_WOA; s->scntl1 &= ~LSI_SCNTL1_IARB; if (id >= LSI_MAX_DEVS || !s->scsi_dev[id]) { DPRINTF("Selected absent target %d\n", id); lsi_script_scsi_interrupt(s, 0, LSI_SIST1_STO); lsi_disconnect(s); break; } DPRINTF("Selected target %d%s\n", id, insn & (1 << 3) ? " ATN" : ""); /* ??? Linux drivers compain when this is set. Maybe it only applies in low-level mode (unimplemented). lsi_script_scsi_interrupt(s, LSI_SIST0_CMP, 0); */ s->current_dev = s->scsi_dev[id]; s->current_tag = id << 8; s->scntl1 |= LSI_SCNTL1_CON; if (insn & (1 << 3)) { s->socl |= LSI_SOCL_ATN; } lsi_set_phase(s, PHASE_MO); break; case 1: /* Disconnect */ DPRINTF("Wait Disconect\n"); s->scntl1 &= ~LSI_SCNTL1_CON; break; case 2: /* Wait Reselect */ lsi_wait_reselect(s); break; case 3: /* Set */ DPRINTF("Set%s%s%s%s\n", insn & (1 << 3) ? " ATN" : "", insn & (1 << 6) ? " ACK" : "", insn & (1 << 9) ? " TM" : "", insn & (1 << 10) ? " CC" : ""); if (insn & (1 << 3)) { s->socl |= LSI_SOCL_ATN; lsi_set_phase(s, PHASE_MO); } if (insn & (1 << 9)) { BADF("Target mode not implemented\n"); exit(1); } if (insn & (1 << 10)) s->carry = 1; break; case 4: /* Clear */ DPRINTF("Clear%s%s%s%s\n", insn & (1 << 3) ? " ATN" : "", insn & (1 << 6) ? " ACK" : "", insn & (1 << 9) ? " TM" : "", insn & (1 << 10) ? " CC" : ""); if (insn & (1 << 3)) { s->socl &= ~LSI_SOCL_ATN; } if (insn & (1 << 10)) s->carry = 0; break; } } else { uint8_t op0; uint8_t op1; uint8_t data8; int reg; int operator; #ifdef DEBUG_LSI static const char *opcode_names[3] = {"Write", "Read", "Read-Modify-Write"}; static const char *operator_names[8] = {"MOV", "SHL", "OR", "XOR", "AND", "SHR", "ADD", "ADC"}; #endif reg = ((insn >> 16) & 0x7f) | (insn & 0x80); data8 = (insn >> 8) & 0xff; opcode = (insn >> 27) & 7; operator = (insn >> 24) & 7; DPRINTF("%s reg 0x%x %s data8=0x%02x sfbr=0x%02x%s\n", opcode_names[opcode - 5], reg, operator_names[operator], data8, s->sfbr, (insn & (1 << 23)) ? " SFBR" : ""); op0 = op1 = 0; switch (opcode) { case 5: /* From SFBR */ op0 = s->sfbr; op1 = data8; break; case 6: /* To SFBR */ if (operator) op0 = lsi_reg_readb(s, reg); op1 = data8; break; case 7: /* Read-modify-write */ if (operator) op0 = lsi_reg_readb(s, reg); if (insn & (1 << 23)) { op1 = s->sfbr; } else { op1 = data8; } break; } switch (operator) { case 0: /* move */ op0 = op1; break; case 1: /* Shift left */ op1 = op0 >> 7; op0 = (op0 << 1) | s->carry; s->carry = op1; break; case 2: /* OR */ op0 |= op1; break; case 3: /* XOR */ op0 ^= op1; break; case 4: /* AND */ op0 &= op1; break; case 5: /* SHR */ op1 = op0 & 1; op0 = (op0 >> 1) | (s->carry << 7); s->carry = op1; break; case 6: /* ADD */ op0 += op1; s->carry = op0 < op1; break; case 7: /* ADC */ op0 += op1 + s->carry; if (s->carry) s->carry = op0 <= op1; else s->carry = op0 < op1; break; } switch (opcode) { case 5: /* From SFBR */ case 7: /* Read-modify-write */ lsi_reg_writeb(s, reg, op0); break; case 6: /* To SFBR */ s->sfbr = op0; break; } } break; case 2: /* Transfer Control. */ { int cond; int jmp; if ((insn & 0x002e0000) == 0) { DPRINTF("NOP\n"); break; } if (s->sist1 & LSI_SIST1_STO) { DPRINTF("Delayed select timeout\n"); lsi_stop_script(s); break; } cond = jmp = (insn & (1 << 19)) != 0; if (cond == jmp && (insn & (1 << 21))) { DPRINTF("Compare carry %d\n", s->carry == jmp); cond = s->carry != 0; } if (cond == jmp && (insn & (1 << 17))) { DPRINTF("Compare phase %d %c= %d\n", (s->sstat1 & PHASE_MASK), jmp ? '=' : '!', ((insn >> 24) & 7)); cond = (s->sstat1 & PHASE_MASK) == ((insn >> 24) & 7); } if (cond == jmp && (insn & (1 << 18))) { uint8_t mask; mask = (~insn >> 8) & 0xff; DPRINTF("Compare data 0x%x & 0x%x %c= 0x%x\n", s->sfbr, mask, jmp ? '=' : '!', insn & mask); cond = (s->sfbr & mask) == (insn & mask); } if (cond == jmp) { if (insn & (1 << 23)) { /* Relative address. */ addr = s->dsp + sxt24(addr); } switch ((insn >> 27) & 7) { case 0: /* Jump */ DPRINTF("Jump to 0x%08x\n", addr); s->dsp = addr; break; case 1: /* Call */ DPRINTF("Call 0x%08x\n", addr); s->temp = s->dsp; s->dsp = addr; break; case 2: /* Return */ DPRINTF("Return to 0x%08x\n", s->temp); s->dsp = s->temp; break; case 3: /* Interrupt */ DPRINTF("Interrupt 0x%08x\n", s->dsps); if ((insn & (1 << 20)) != 0) { s->istat0 |= LSI_ISTAT0_INTF; lsi_update_irq(s); } else { lsi_script_dma_interrupt(s, LSI_DSTAT_SIR); } break; default: DPRINTF("Illegal transfer control\n"); lsi_script_dma_interrupt(s, LSI_DSTAT_IID); break; } } else { DPRINTF("Control condition failed\n"); } } break; case 3: if ((insn & (1 << 29)) == 0) { /* Memory move. */ uint32_t dest; /* ??? The docs imply the destination address is loaded into the TEMP register. However the Linux drivers rely on the value being presrved. */ dest = read_dword(s, s->dsp); s->dsp += 4; lsi_memcpy(s, dest, addr, insn & 0xffffff); } else { uint8_t data[7]; int reg; int n; int i; if (insn & (1 << 28)) { addr = s->dsa + sxt24(addr); } n = (insn & 7); reg = (insn >> 16) & 0xff; if (insn & (1 << 24)) { cpu_physical_memory_read(addr, data, n); DPRINTF("Load reg 0x%x size %d addr 0x%08x = %08x\n", reg, n, addr, *(int *)data); for (i = 0; i < n; i++) { lsi_reg_writeb(s, reg + i, data[i]); } } else { DPRINTF("Store reg 0x%x size %d addr 0x%08x\n", reg, n, addr); for (i = 0; i < n; i++) { data[i] = lsi_reg_readb(s, reg + i); } cpu_physical_memory_write(addr, data, n); } } } /* ??? Need to avoid infinite loops. */ if (s->istat1 & LSI_ISTAT1_SRUN && !s->waiting) { if (s->dcntl & LSI_DCNTL_SSM) { lsi_script_dma_interrupt(s, LSI_DSTAT_SSI); } else { goto again; } } DPRINTF("SCRIPTS execution stopped\n"); }
true
qemu
ee4d919f30f1378cda697dd94d5a21b2a7f4d90d
6,488
static void handle_arg_cpu(const char *arg) { cpu_model = strdup(arg); if (cpu_model == NULL || strcmp(cpu_model, "?") == 0) { /* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list_id) cpu_list_id(stdout, &fprintf, ""); #elif defined(cpu_list) cpu_list(stdout, &fprintf); /* deprecated */ #endif exit(1); } }
true
qemu
c8057f951d64de93bfd01569c0a725baa9f94372
6,490
static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, AVCodecContext *dec_ctx) { AVPacket enc_pkt; AVFrame *in_frame, *out_frame; uint8_t *raw_in = NULL, *raw_out = NULL; int in_offset = 0, out_offset = 0; int frame_data_size = 0; int result = 0; int got_output = 0; int i = 0; in_frame = av_frame_alloc(); if (!in_frame) { av_log(NULL, AV_LOG_ERROR, "Can't allocate input frame\n"); return AVERROR(ENOMEM); } in_frame->nb_samples = enc_ctx->frame_size; in_frame->format = enc_ctx->sample_fmt; in_frame->channel_layout = enc_ctx->channel_layout; if (av_frame_get_buffer(in_frame, 32) != 0) { av_log(NULL, AV_LOG_ERROR, "Can't allocate a buffer for input frame\n"); return AVERROR(ENOMEM); } out_frame = av_frame_alloc(); if (!out_frame) { av_log(NULL, AV_LOG_ERROR, "Can't allocate output frame\n"); return AVERROR(ENOMEM); } raw_in = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES); if (!raw_in) { av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_in\n"); return AVERROR(ENOMEM); } raw_out = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES); if (!raw_out) { av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_out\n"); return AVERROR(ENOMEM); } for (i = 0; i < NUMBER_OF_FRAMES; i++) { av_init_packet(&enc_pkt); enc_pkt.data = NULL; enc_pkt.size = 0; generate_raw_frame((uint16_t*)(in_frame->data[0]), i, enc_ctx->sample_rate, enc_ctx->channels, enc_ctx->frame_size); memcpy(raw_in + in_offset, in_frame->data[0], in_frame->linesize[0]); in_offset += in_frame->linesize[0]; result = avcodec_encode_audio2(enc_ctx, &enc_pkt, in_frame, &got_output); if (result < 0) { av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n"); return result; } /* if we get an encoded packet, feed it straight to the decoder */ if (got_output) { result = avcodec_decode_audio4(dec_ctx, out_frame, &got_output, &enc_pkt); if (result < 0) { av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n"); return result; } if (got_output) { if (result != enc_pkt.size) { av_log(NULL, AV_LOG_INFO, "Decoder consumed only part of a packet, it is allowed to do so -- need to update this test\n"); return AVERROR_UNKNOWN; } if (in_frame->nb_samples != out_frame->nb_samples) { av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different number of samples\n"); return AVERROR_UNKNOWN; } if (in_frame->channel_layout != out_frame->channel_layout) { av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different channel layout\n"); return AVERROR_UNKNOWN; } if (in_frame->format != out_frame->format) { av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different sample format\n"); return AVERROR_UNKNOWN; } memcpy(raw_out + out_offset, out_frame->data[0], out_frame->linesize[0]); out_offset += out_frame->linesize[0]; } } av_free_packet(&enc_pkt); } if (memcmp(raw_in, raw_out, frame_data_size * NUMBER_OF_FRAMES) != 0) { av_log(NULL, AV_LOG_ERROR, "Output differs\n"); return 1; } av_log(NULL, AV_LOG_INFO, "OK\n"); av_freep(&raw_in); av_freep(&raw_out); av_frame_free(&in_frame); av_frame_free(&out_frame); return 0; }
true
FFmpeg
86fb20324690a80f763b7de6d78749c17ad3f482
6,492
static av_cold int pcm_encode_init(AVCodecContext *avctx) { avctx->frame_size = 0; switch(avctx->codec->id) { case CODEC_ID_PCM_ALAW: pcm_alaw_tableinit(); break; case CODEC_ID_PCM_MULAW: pcm_ulaw_tableinit(); break; default: break; } avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id); avctx->block_align = avctx->channels * avctx->bits_per_coded_sample/8; avctx->coded_frame= avcodec_alloc_frame(); return 0; }
true
FFmpeg
a8bdf2405c6027f45a899eaaa6ba74e97c1c2701
6,493
static int vorbis_encode_frame(AVCodecContext *avccontext, unsigned char *packets, int buf_size, void *data) { vorbis_enc_context *venc = avccontext->priv_data; const signed short *audio = data; int samples = data ? avccontext->frame_size : 0; vorbis_enc_mode *mode; vorbis_enc_mapping *mapping; PutBitContext pb; int i; if (!apply_window_and_mdct(venc, audio, samples)) return 0; samples = 1 << (venc->log2_blocksize[0] - 1); init_put_bits(&pb, packets, buf_size); put_bits(&pb, 1, 0); // magic bit put_bits(&pb, ilog(venc->nmodes - 1), 0); // 0 bits, the mode mode = &venc->modes[0]; mapping = &venc->mappings[mode->mapping]; if (mode->blockflag) { put_bits(&pb, 1, 0); put_bits(&pb, 1, 0); } for (i = 0; i < venc->channels; i++) { vorbis_enc_floor *fc = &venc->floors[mapping->floor[mapping->mux[i]]]; uint16_t posts[MAX_FLOOR_VALUES]; floor_fit(venc, fc, &venc->coeffs[i * samples], posts, samples); floor_encode(venc, fc, &pb, posts, &venc->floor[i * samples], samples); } for (i = 0; i < venc->channels * samples; i++) venc->coeffs[i] /= venc->floor[i]; for (i = 0; i < mapping->coupling_steps; i++) { float *mag = venc->coeffs + mapping->magnitude[i] * samples; float *ang = venc->coeffs + mapping->angle[i] * samples; int j; for (j = 0; j < samples; j++) { float a = ang[j]; ang[j] -= mag[j]; if (mag[j] > 0) ang[j] = -ang[j]; if (ang[j] < 0) mag[j] = a; } } residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]], &pb, venc->coeffs, samples, venc->channels); avccontext->coded_frame->pts = venc->sample_count; venc->sample_count += avccontext->frame_size; flush_put_bits(&pb); return put_bits_count(&pb) >> 3; }
true
FFmpeg
1ba08c94f5bb4d1c3c2d3651b5e01edb4ce172e2
6,494
void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *pci_dev, uint32_t max_frags, bool has_virt_hdr) { struct NetTxPkt *p = g_malloc0(sizeof *p); p->pci_dev = pci_dev; p->vec = g_malloc((sizeof *p->vec) * (max_frags + NET_TX_PKT_PL_START_FRAG)); p->raw = g_malloc((sizeof *p->raw) * max_frags); p->max_payload_frags = max_frags; p->max_raw_frags = max_frags; p->has_virt_hdr = has_virt_hdr; p->vec[NET_TX_PKT_VHDR_FRAG].iov_base = &p->virt_hdr; p->vec[NET_TX_PKT_VHDR_FRAG].iov_len = p->has_virt_hdr ? sizeof p->virt_hdr : 0; p->vec[NET_TX_PKT_L2HDR_FRAG].iov_base = &p->l2_hdr; p->vec[NET_TX_PKT_L3HDR_FRAG].iov_base = &p->l3_hdr; *pkt = p; }
true
qemu
47882fa4975bf0b58dd74474329fdd7154e8f04c
6,496
static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, uint16_t *val, uint16_t dev_value, uint16_t valid_mask) { XenPTRegInfo *reg = cfg_entry->reg; uint16_t writable_mask = 0; uint16_t throughable_mask = 0; uint16_t emu_mask = reg->emu_mask; if (s->is_virtfn) { emu_mask |= PCI_COMMAND_MEMORY; } /* modify emulate register */ writable_mask = ~reg->ro_mask & valid_mask; cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask); /* create value for writing to I/O device register */ throughable_mask = ~emu_mask & valid_mask; if (*val & PCI_COMMAND_INTX_DISABLE) { throughable_mask |= PCI_COMMAND_INTX_DISABLE; } else { if (s->machine_irq) { throughable_mask |= PCI_COMMAND_INTX_DISABLE; } } *val = XEN_PT_MERGE_VALUE(*val, dev_value, throughable_mask); return 0; }
true
qemu
81b23ef82cd1be29ca3d69ab7e98b5b5e55926ce
6,497
static int rv34_decode_cbp(GetBitContext *gb, RV34VLC *vlc, int table) { int pattern, code, cbp=0; int ones; static const int cbp_masks[3] = {0x100000, 0x010000, 0x110000}; static const int shifts[4] = { 0, 2, 8, 10 }; const int *curshift = shifts; int i, t, mask; code = get_vlc2(gb, vlc->cbppattern[table].table, 9, 2); pattern = code & 0xF; code >>= 4; ones = rv34_count_ones[pattern]; for(mask = 8; mask; mask >>= 1, curshift++){ if(pattern & mask) cbp |= get_vlc2(gb, vlc->cbp[table][ones].table, vlc->cbp[table][ones].bits, 1) << curshift[0]; } for(i = 0; i < 4; i++){ t = modulo_three_table[code][i]; if(t == 1) cbp |= cbp_masks[get_bits1(gb)] << i; if(t == 2) cbp |= cbp_masks[2] << i; } return cbp; }
false
FFmpeg
3faa303a47e0c3b59a53988e0f76018930c6cb1a
6,498
static int mtv_read_header(AVFormatContext *s) { MTVDemuxContext *mtv = s->priv_data; AVIOContext *pb = s->pb; AVStream *st; unsigned int audio_subsegments; avio_skip(pb, 3); mtv->file_size = avio_rl32(pb); mtv->segments = avio_rl32(pb); avio_skip(pb, 32); mtv->audio_identifier = avio_rl24(pb); mtv->audio_br = avio_rl16(pb); mtv->img_colorfmt = avio_rl24(pb); mtv->img_bpp = avio_r8(pb); mtv->img_width = avio_rl16(pb); mtv->img_height = avio_rl16(pb); mtv->img_segment_size = avio_rl16(pb); /* Calculate width and height if missing from header */ if(!mtv->img_width) mtv->img_width=mtv->img_segment_size / (mtv->img_bpp>>3) / mtv->img_height; if(!mtv->img_height) mtv->img_height=mtv->img_segment_size / (mtv->img_bpp>>3) / mtv->img_width; avio_skip(pb, 4); audio_subsegments = avio_rl16(pb); if (audio_subsegments == 0) { avpriv_request_sample(s, "MTV files without audio"); return AVERROR_PATCHWELCOME; } mtv->full_segment_size = audio_subsegments * (MTV_AUDIO_PADDING_SIZE + MTV_ASUBCHUNK_DATA_SIZE) + mtv->img_segment_size; mtv->video_fps = (mtv->audio_br / 4) / audio_subsegments; // FIXME Add sanity check here // all systems go! init decoders // video - raw rgb565 st = avformat_new_stream(s, NULL); if(!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 64, 1, mtv->video_fps); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; st->codec->pix_fmt = AV_PIX_FMT_RGB565BE; st->codec->width = mtv->img_width; st->codec->height = mtv->img_height; st->codec->extradata = av_strdup("BottomUp"); st->codec->extradata_size = 9; // audio - mp3 st = avformat_new_stream(s, NULL); if(!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 64, 1, AUDIO_SAMPLING_RATE); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = AV_CODEC_ID_MP3; st->codec->bit_rate = mtv->audio_br; st->need_parsing = AVSTREAM_PARSE_FULL; // Jump over header if(avio_seek(pb, MTV_HEADER_SIZE, SEEK_SET) != MTV_HEADER_SIZE) return AVERROR(EIO); return 0; }
true
FFmpeg
f64d7e919eabd427f3e6dd4a1219e448c78deb42
6,499
static int check_refcounts_l2(BlockDriverState *bs, uint16_t *refcount_table, int refcount_table_size, int64_t l2_offset, int check_copied) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table, offset; int i, l2_size, nb_csectors, refcount; int errors = 0; /* Read L2 table from disk */ l2_size = s->l2_size * sizeof(uint64_t); l2_table = qemu_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++) { offset = be64_to_cpu(l2_table[i]); if (offset != 0) { if (offset & QCOW_OFLAG_COMPRESSED) { /* Compressed clusters don't have QCOW_OFLAG_COPIED */ if (offset & QCOW_OFLAG_COPIED) { fprintf(stderr, "ERROR: cluster %" PRId64 ": " "copied flag must never be set for compressed " "clusters\n", offset >> s->cluster_bits); offset &= ~QCOW_OFLAG_COPIED; errors++; } /* Mark cluster as used */ nb_csectors = ((offset >> s->csize_shift) & s->csize_mask) + 1; offset &= s->cluster_offset_mask; errors += inc_refcounts(bs, refcount_table, refcount_table_size, offset & ~511, nb_csectors * 512); } else { /* QCOW_OFLAG_COPIED must be set iff refcount == 1 */ if (check_copied) { uint64_t entry = offset; offset &= ~QCOW_OFLAG_COPIED; refcount = get_refcount(bs, offset >> s->cluster_bits); if (refcount < 0) { fprintf(stderr, "Can't get refcount for offset %" PRIx64 ": %s\n", entry, strerror(-refcount)); } if ((refcount == 1) != ((entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED: offset=%" PRIx64 " refcount=%d\n", entry, refcount); errors++; } } /* Mark cluster as used */ offset &= ~QCOW_OFLAG_COPIED; errors += inc_refcounts(bs, refcount_table, refcount_table_size, offset, s->cluster_size); /* Correct offsets are cluster aligned */ if (offset & (s->cluster_size - 1)) { fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not " "properly aligned; L2 entry corrupted.\n", offset); errors++; } } } } qemu_free(l2_table); return errors; fail: fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n"); qemu_free(l2_table); return -EIO; }
true
qemu
9ac228e02cf16202547e7025ef300369e0db7781
6,501
static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, int plane_idx, int is_chroma) { int blk, ret; int i, j, bx, by; uint8_t *dst, *prev, *ref, *ref_start, *ref_end; int v, col[2]; const uint8_t *scan; int xoff, yoff; LOCAL_ALIGNED_16(int16_t, block, [64]); LOCAL_ALIGNED_16(uint8_t, ublock, [64]); LOCAL_ALIGNED_16(int32_t, dctblock, [64]); int coordmap[64]; const int stride = frame->linesize[plane_idx]; int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3; int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3; int width = c->avctx->width >> is_chroma; init_lengths(c, FFMAX(width, 8), bw); for (i = 0; i < BINK_NB_SRC; i++) read_bundle(gb, c, i); ref_start = c->last->data[plane_idx] ? c->last->data[plane_idx] : frame->data[plane_idx]; ref_end = ref_start + (bw - 1 + c->last->linesize[plane_idx] * (bh - 1)) * 8; for (i = 0; i < 64; i++) coordmap[i] = (i & 7) + (i >> 3) * stride; for (by = 0; by < bh; by++) { if ((ret = read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_BLOCK_TYPES])) < 0) return ret; if ((ret = read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES])) < 0) return ret; if ((ret = read_colors(gb, &c->bundle[BINK_SRC_COLORS], c)) < 0) return ret; if ((ret = read_patterns(c->avctx, gb, &c->bundle[BINK_SRC_PATTERN])) < 0) return ret; if ((ret = read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_X_OFF])) < 0) return ret; if ((ret = read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_Y_OFF])) < 0) return ret; if ((ret = read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0)) < 0) return ret; if ((ret = read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1)) < 0) return ret; if ((ret = read_runs(c->avctx, gb, &c->bundle[BINK_SRC_RUN])) < 0) return ret; if (by == bh) break; dst = frame->data[plane_idx] + 8*by*stride; prev = (c->last->data[plane_idx] ? c->last->data[plane_idx] : frame->data[plane_idx]) + 8*by*stride; for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) { blk = get_value(c, BINK_SRC_BLOCK_TYPES); // 16x16 block type on odd line means part of the already decoded block, so skip it if ((by & 1) && blk == SCALED_BLOCK) { bx++; dst += 8; prev += 8; continue; } switch (blk) { case SKIP_BLOCK: c->hdsp.put_pixels_tab[1][0](dst, prev, stride, 8); break; case SCALED_BLOCK: blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES); switch (blk) { case RUN_BLOCK: scan = bink_patterns[get_bits(gb, 4)]; i = 0; do { int run = get_value(c, BINK_SRC_RUN) + 1; i += run; if (i > 64) { av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return AVERROR_INVALIDDATA; } if (get_bits1(gb)) { v = get_value(c, BINK_SRC_COLORS); for (j = 0; j < run; j++) ublock[*scan++] = v; } else { for (j = 0; j < run; j++) ublock[*scan++] = get_value(c, BINK_SRC_COLORS); } } while (i < 63); if (i == 63) ublock[*scan++] = get_value(c, BINK_SRC_COLORS); break; case INTRA_BLOCK: memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = get_value(c, BINK_SRC_INTRA_DC); read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1); c->binkdsp.idct_put(ublock, 8, dctblock); break; case FILL_BLOCK: v = get_value(c, BINK_SRC_COLORS); c->bdsp.fill_block_tab[0](dst, v, stride, 16); break; case PATTERN_BLOCK: for (i = 0; i < 2; i++) col[i] = get_value(c, BINK_SRC_COLORS); for (j = 0; j < 8; j++) { v = get_value(c, BINK_SRC_PATTERN); for (i = 0; i < 8; i++, v >>= 1) ublock[i + j*8] = col[v & 1]; } break; case RAW_BLOCK: for (j = 0; j < 8; j++) for (i = 0; i < 8; i++) ublock[i + j*8] = get_value(c, BINK_SRC_COLORS); break; default: av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk); return AVERROR_INVALIDDATA; } if (blk != FILL_BLOCK) c->binkdsp.scale_block(ublock, dst, stride); bx++; dst += 8; prev += 8; break; case MOTION_BLOCK: xoff = get_value(c, BINK_SRC_X_OFF); yoff = get_value(c, BINK_SRC_Y_OFF); ref = prev + xoff + yoff * stride; if (ref < ref_start || ref > ref_end) { av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n", bx*8 + xoff, by*8 + yoff); return AVERROR_INVALIDDATA; } c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8); break; case RUN_BLOCK: scan = bink_patterns[get_bits(gb, 4)]; i = 0; do { int run = get_value(c, BINK_SRC_RUN) + 1; i += run; if (i > 64) { av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return AVERROR_INVALIDDATA; } if (get_bits1(gb)) { v = get_value(c, BINK_SRC_COLORS); for (j = 0; j < run; j++) dst[coordmap[*scan++]] = v; } else { for (j = 0; j < run; j++) dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS); } } while (i < 63); if (i == 63) dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS); break; case RESIDUE_BLOCK: xoff = get_value(c, BINK_SRC_X_OFF); yoff = get_value(c, BINK_SRC_Y_OFF); ref = prev + xoff + yoff * stride; if (ref < ref_start || ref > ref_end) { av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n", bx*8 + xoff, by*8 + yoff); return AVERROR_INVALIDDATA; } c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8); c->bdsp.clear_block(block); v = get_bits(gb, 7); read_residue(gb, block, v); c->binkdsp.add_pixels8(dst, block, stride); break; case INTRA_BLOCK: memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = get_value(c, BINK_SRC_INTRA_DC); read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1); c->binkdsp.idct_put(dst, stride, dctblock); break; case FILL_BLOCK: v = get_value(c, BINK_SRC_COLORS); c->bdsp.fill_block_tab[1](dst, v, stride, 8); break; case INTER_BLOCK: xoff = get_value(c, BINK_SRC_X_OFF); yoff = get_value(c, BINK_SRC_Y_OFF); ref = prev + xoff + yoff * stride; c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8); memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = get_value(c, BINK_SRC_INTER_DC); read_dct_coeffs(gb, dctblock, bink_scan, bink_inter_quant, -1); c->binkdsp.idct_add(dst, stride, dctblock); break; case PATTERN_BLOCK: for (i = 0; i < 2; i++) col[i] = get_value(c, BINK_SRC_COLORS); for (i = 0; i < 8; i++) { v = get_value(c, BINK_SRC_PATTERN); for (j = 0; j < 8; j++, v >>= 1) dst[i*stride + j] = col[v & 1]; } break; case RAW_BLOCK: for (i = 0; i < 8; i++) memcpy(dst + i*stride, c->bundle[BINK_SRC_COLORS].cur_ptr + i*8, 8); c->bundle[BINK_SRC_COLORS].cur_ptr += 64; break; default: av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk); return AVERROR_INVALIDDATA; } } } if (get_bits_count(gb) & 0x1F) //next plane data starts at 32-bit boundary skip_bits_long(gb, 32 - (get_bits_count(gb) & 0x1F)); return 0; }
false
FFmpeg
7f596368a404363d72b1be6d16c51420a71bc523
6,502
static void unterminated_string(void) { QObject *obj = qobject_from_json("\"abc", NULL); g_assert(obj == NULL); }
true
qemu
aec4b054ea36c53c8b887da99f20010133b84378
6,503
int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size) { int ret = -ENOSYS; #ifdef KVM_CAP_COALESCED_MMIO KVMState *s = kvm_state; if (s->coalesced_mmio) { struct kvm_coalesced_mmio_zone zone; zone.addr = start; zone.size = size; ret = kvm_vm_ioctl(s, KVM_REGISTER_COALESCED_MMIO, &zone); } #endif return ret; }
true
qemu
94a8d39afd8ccfdbf578af04c3385fdb5f545af1
6,505
void do_srad (void) { int64_t ret; if (likely(!(T1 & 0x40UL))) { if (likely((uint64_t)T1 != 0)) { ret = (int64_t)T0 >> (T1 & 0x3FUL); if (likely(ret >= 0 || ((int64_t)T0 & ((1 << T1) - 1)) == 0)) { xer_ca = 0; } else { xer_ca = 1; } } else { ret = T0; xer_ca = 0; } } else { ret = (-1) * ((uint64_t)T0 >> 63); if (likely(ret >= 0 || ((uint64_t)T0 & ~0x8000000000000000ULL) == 0)) { xer_ca = 0; } else { xer_ca = 1; } } T0 = ret; }
true
qemu
6f2d8978728c48ca46f5c01835438508aace5c64
6,506
static void test_visitor_in_errors(TestInputVisitorData *data, const void *unused) { TestStruct *p = NULL; Error *err = NULL; Visitor *v; v = visitor_input_test_init(data, "{ 'integer': false, 'boolean': 'foo', 'string': -42 }"); visit_type_TestStruct(v, &p, NULL, &err); error_free_or_abort(&err); /* FIXME - a failed parse should not leave a partially-allocated p * for us to clean up; this could cause callers to leak memory. */ g_assert(p->string == NULL); g_free(p->string); g_free(p); }
true
qemu
dd5ee2c2d3e3a17647ddd9bfa97935b8cb5dfa40
6,510
static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { WMAVoiceContext *s = ctx->priv_data; GetBitContext *gb = &s->gb; int size, res, pos; /* Packets are sometimes a multiple of ctx->block_align, with a packet * header at each ctx->block_align bytes. However, FFmpeg's ASF demuxer * feeds us ASF packets, which may concatenate multiple "codec" packets * in a single "muxer" packet, so we artificially emulate that by * capping the packet size at ctx->block_align. */ for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align); if (!size) { *got_frame_ptr = 0; return 0; } init_get_bits(&s->gb, avpkt->data, size << 3); /* size == ctx->block_align is used to indicate whether we are dealing with * a new packet or a packet of which we already read the packet header * previously. */ if (size == ctx->block_align) { // new packet header if ((res = parse_packet_header(s)) < 0) return res; /* If the packet header specifies a s->spillover_nbits, then we want * to push out all data of the previous packet (+ spillover) before * continuing to parse new superframes in the current packet. */ if (s->spillover_nbits > 0) { if (s->sframe_cache_size > 0) { int cnt = get_bits_count(gb); copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits); flush_put_bits(&s->pb); s->sframe_cache_size += s->spillover_nbits; if ((res = synth_superframe(ctx, data, got_frame_ptr)) == 0 && *got_frame_ptr) { cnt += s->spillover_nbits; s->skip_bits_next = cnt & 7; return cnt >> 3; } else skip_bits_long (gb, s->spillover_nbits - cnt + get_bits_count(gb)); // resync } else skip_bits_long(gb, s->spillover_nbits); // resync } } else if (s->skip_bits_next) skip_bits(gb, s->skip_bits_next); /* Try parsing superframes in current packet */ s->sframe_cache_size = 0; s->skip_bits_next = 0; pos = get_bits_left(gb); if ((res = synth_superframe(ctx, data, got_frame_ptr)) < 0) { return res; } else if (*got_frame_ptr) { int cnt = get_bits_count(gb); s->skip_bits_next = cnt & 7; return cnt >> 3; } else if ((s->sframe_cache_size = pos) > 0) { /* rewind bit reader to start of last (incomplete) superframe... */ init_get_bits(gb, avpkt->data, size << 3); skip_bits_long(gb, (size << 3) - pos); av_assert1(get_bits_left(gb) == pos); /* ...and cache it for spillover in next packet */ init_put_bits(&s->pb, s->sframe_cache, SFRAME_CACHE_MAXSIZE); copy_bits(&s->pb, avpkt->data, size, gb, s->sframe_cache_size); // FIXME bad - just copy bytes as whole and add use the // skip_bits_next field } return size; }
false
FFmpeg
2a4700a4f03280fa8ba4fc0f8a9987bb550f0d1e
6,511
static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) { MOVContext *mov = s->priv_data; MOVStreamContext *sc; AVIndexEntry *sample; AVStream *st = NULL; int ret; mov->fc = s; retry: sample = mov_find_next_sample(s, &st); if (!sample) { mov->found_mdat = 0; if (!mov->next_root_atom) return AVERROR_EOF; avio_seek(s->pb, mov->next_root_atom, SEEK_SET); mov->next_root_atom = 0; if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || avio_feof(s->pb)) return AVERROR_EOF; av_log(s, AV_LOG_TRACE, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); goto retry; } sc = st->priv_data; /* must be done just before reading, to avoid infinite loop on sample */ sc->current_sample++; if (mov->next_root_atom) { sample->pos = FFMIN(sample->pos, mov->next_root_atom); sample->size = FFMIN(sample->size, (mov->next_root_atom - sample->pos)); } if (st->discard != AVDISCARD_ALL) { if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n", sc->ffindex, sample->pos); return AVERROR_INVALIDDATA; } ret = av_get_packet(sc->pb, pkt, sample->size); if (ret < 0) return ret; if (sc->has_palette) { uint8_t *pal; pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); if (!pal) { av_log(mov->fc, AV_LOG_ERROR, "Cannot append palette to packet\n"); } else { memcpy(pal, sc->palette, AVPALETTE_SIZE); sc->has_palette = 0; } } #if CONFIG_DV_DEMUXER if (mov->dv_demux && sc->dv_audio_container) { avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); av_freep(&pkt->data); pkt->size = 0; ret = avpriv_dv_get_packet(mov->dv_demux, pkt); if (ret < 0) return ret; } #endif } pkt->stream_index = sc->ffindex; pkt->dts = sample->timestamp; if (sc->ctts_data && sc->ctts_index < sc->ctts_count) { pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration; /* update ctts context */ sc->ctts_sample++; if (sc->ctts_index < sc->ctts_count && sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) { sc->ctts_index++; sc->ctts_sample = 0; } if (sc->wrong_dts) pkt->dts = AV_NOPTS_VALUE; } else { int64_t next_dts = (sc->current_sample < st->nb_index_entries) ? st->index_entries[sc->current_sample].timestamp : st->duration; pkt->duration = next_dts - pkt->dts; pkt->pts = pkt->dts; } if (st->discard == AVDISCARD_ALL) goto retry; pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0; pkt->pos = sample->pos; return 0; }
false
FFmpeg
c886dd2f5875e01a5949fddd0388c965c7766cfb
6,512
static int test_vector_fmac_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, const float *v1, const float *src0, float scale) { LOCAL_ALIGNED(32, float, cdst, [LEN]); LOCAL_ALIGNED(32, float, odst, [LEN]); int ret; memcpy(cdst, v1, LEN * sizeof(*v1)); memcpy(odst, v1, LEN * sizeof(*v1)); cdsp->vector_fmac_scalar(cdst, src0, scale, LEN); fdsp->vector_fmac_scalar(odst, src0, scale, LEN); if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMAC_SCALAR_CONST)) av_log(NULL, AV_LOG_ERROR, "vector_fmac_scalar failed\n"); return ret; }
false
FFmpeg
e53c9065ca08a9153ecc73a6a8940bcc6d667e58
6,513
static void add_pc_test_cases(void) { QDict *response, *minfo; QList *list; const QListEntry *p; QObject *qobj; QString *qstr; const char *mname, *path; PCTestData *data; qtest_start("-machine none"); response = qmp("{ 'execute': 'query-machines' }"); g_assert(response); list = qdict_get_qlist(response, "return"); g_assert(list); for (p = qlist_first(list); p; p = qlist_next(p)) { minfo = qobject_to_qdict(qlist_entry_obj(p)); g_assert(minfo); qobj = qdict_get(minfo, "name"); g_assert(qobj); qstr = qobject_to_qstring(qobj); g_assert(qstr); mname = qstring_get_str(qstr); if (!g_str_has_prefix(mname, "pc-")) { continue; } data = g_malloc(sizeof(PCTestData)); data->machine = mname; data->cpu_model = "Haswell"; /* 1.3+ theoretically */ data->sockets = 1; data->cores = 3; data->threads = 2; data->maxcpus = data->sockets * data->cores * data->threads * 2; if (g_str_has_suffix(mname, "-1.4") || (strcmp(mname, "pc-1.3") == 0) || (strcmp(mname, "pc-1.2") == 0) || (strcmp(mname, "pc-1.1") == 0) || (strcmp(mname, "pc-1.0") == 0) || (strcmp(mname, "pc-0.15") == 0) || (strcmp(mname, "pc-0.14") == 0) || (strcmp(mname, "pc-0.13") == 0) || (strcmp(mname, "pc-0.12") == 0) || (strcmp(mname, "pc-0.11") == 0) || (strcmp(mname, "pc-0.10") == 0)) { path = g_strdup_printf("cpu/%s/init/%ux%ux%u&maxcpus=%u", mname, data->sockets, data->cores, data->threads, data->maxcpus); qtest_add_data_func(path, data, test_pc_without_cpu_add); } else { path = g_strdup_printf("cpu/%s/add/%ux%ux%u&maxcpus=%u", mname, data->sockets, data->cores, data->threads, data->maxcpus); qtest_add_data_func(path, data, test_pc_with_cpu_add); } } qtest_end(); }
true
qemu
34e46f604d3cf26144b4e02989f2f096e3dc2a41
6,514
static void test_qga_set_time(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret; int64_t current, time; gchar *cmd; /* get current time */ ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-time'}"); g_assert_nonnull(ret); qmp_assert_no_error(ret); current = qdict_get_int(ret, "return"); g_assert_cmpint(current, >, 0); QDECREF(ret); /* set some old time */ ret = qmp_fd(fixture->fd, "{'execute': 'guest-set-time'," " 'arguments': { 'time': 1000 } }"); g_assert_nonnull(ret); qmp_assert_no_error(ret); QDECREF(ret); /* check old time */ ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-time'}"); g_assert_nonnull(ret); qmp_assert_no_error(ret); time = qdict_get_int(ret, "return"); g_assert_cmpint(time / 1000, <, G_USEC_PER_SEC * 10); QDECREF(ret); /* set back current time */ cmd = g_strdup_printf("{'execute': 'guest-set-time'," " 'arguments': { 'time': %" PRId64 " } }", current + time * 1000); ret = qmp_fd(fixture->fd, cmd); g_free(cmd); g_assert_nonnull(ret); qmp_assert_no_error(ret); QDECREF(ret); }
true
qemu
f94b3f64e6572c8cec73a538588f7cd754bcfa88
6,516
static void bus_set_realized(Object *obj, bool value, Error **errp) { BusState *bus = BUS(obj); BusClass *bc = BUS_GET_CLASS(bus); Error *local_err = NULL; if (value && !bus->realized) { if (bc->realize) { bc->realize(bus, &local_err); } } else if (!value && bus->realized) { if (bc->unrealize) { bc->unrealize(bus, &local_err); } } if (local_err != NULL) { error_propagate(errp, local_err); return; } bus->realized = value; }
true
qemu
5942a19040fed313b316ab7b6e3d2d8e7b1625bb
6,518
static inline void asv2_encode_block(ASV1Context *a, int16_t block[64]) { int i; int count = 0; for (count = 63; count > 3; count--) { const int index = ff_asv_scantab[count]; if ((block[index] * a->q_intra_matrix[index] + (1 << 15)) >> 16) break; } count >>= 2; asv2_put_bits(&a->pb, 4, count); asv2_put_bits(&a->pb, 8, (block[0] + 32) >> 6); block[0] = 0; for (i = 0; i <= count; i++) { const int index = ff_asv_scantab[4 * i]; int ccp = 0; if ((block[index + 0] = (block[index + 0] * a->q_intra_matrix[index + 0] + (1 << 15)) >> 16)) ccp |= 8; if ((block[index + 8] = (block[index + 8] * a->q_intra_matrix[index + 8] + (1 << 15)) >> 16)) ccp |= 4; if ((block[index + 1] = (block[index + 1] * a->q_intra_matrix[index + 1] + (1 << 15)) >> 16)) ccp |= 2; if ((block[index + 9] = (block[index + 9] * a->q_intra_matrix[index + 9] + (1 << 15)) >> 16)) ccp |= 1; av_assert2(i || ccp < 8); if (i) put_bits(&a->pb, ff_asv_ac_ccp_tab[ccp][1], ff_asv_ac_ccp_tab[ccp][0]); else put_bits(&a->pb, ff_asv_dc_ccp_tab[ccp][1], ff_asv_dc_ccp_tab[ccp][0]); if (ccp) { if (ccp & 8) asv2_put_level(&a->pb, block[index + 0]); if (ccp & 4) asv2_put_level(&a->pb, block[index + 8]); if (ccp & 2) asv2_put_level(&a->pb, block[index + 1]); if (ccp & 1) asv2_put_level(&a->pb, block[index + 9]); } } }
true
FFmpeg
0bb5ad7a06ebcda9102357f8755d18b63f56aa29
6,520
static void gen_tlbilx_booke206(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } t0 = tcg_temp_new(); gen_addr_reg_index(ctx, t0); switch((ctx->opcode >> 21) & 0x3) { case 0: gen_helper_booke206_tlbilx0(cpu_env, t0); break; case 1: gen_helper_booke206_tlbilx1(cpu_env, t0); break; case 3: gen_helper_booke206_tlbilx3(cpu_env, t0); break; default: gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); break; } tcg_temp_free(t0); #endif }
true
qemu
9b2fadda3e0196ffd485adde4fe9cdd6fae35300
6,521
static void probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt) { if(st->request_probe>0){ AVProbeData *pd = &st->probe_data; int end; av_log(s, AV_LOG_DEBUG, "probing stream %d pp:%d\n", st->index, st->probe_packets); --st->probe_packets; if (pkt) { pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE); memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size); pd->buf_size += pkt->size; memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE); } else { st->probe_packets = 0; } end= s->raw_packet_buffer_remaining_size <= 0 || st->probe_packets<=0; if(end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){ int score= set_codec_from_probe_data(s, st, pd); if( (st->codec->codec_id != CODEC_ID_NONE && score > AVPROBE_SCORE_MAX/4) || end){ pd->buf_size=0; av_freep(&pd->buf); st->request_probe= -1; if(st->codec->codec_id != CODEC_ID_NONE){ av_log(s, AV_LOG_DEBUG, "probed stream %d\n", st->index); }else av_log(s, AV_LOG_WARNING, "probed stream %d failed\n", st->index); } } } }
true
FFmpeg
9054f6b66b3883d615177c738cb69c6337c4375c
6,522
static void pci_basic(void) { QVirtioPCIDevice *dev; QPCIBus *bus; QVirtQueuePCI *vqpci; QGuestAllocator *alloc; void *addr; bus = pci_test_start(); dev = virtio_blk_pci_init(bus, PCI_SLOT); alloc = pc_alloc_init(); vqpci = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev, alloc, 0); /* MSI-X is not enabled */ addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(false); test_basic(&qvirtio_pci, &dev->vdev, alloc, &vqpci->vq, (uint64_t)(uintptr_t)addr); /* End test */ guest_free(alloc, vqpci->vq.desc); pc_alloc_uninit(alloc); qvirtio_pci_device_disable(dev); g_free(dev); qpci_free_pc(bus); test_end(); }
true
qemu
f1d3b99154138741161fc52f5a8c373bf71613c6
6,525
static void gen_spr_440 (CPUPPCState *env) { /* Cache control */ /* XXX : not implemented */ spr_register(env, SPR_440_DNV0, "DNV0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_DNV1, "DNV1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_DNV2, "DNV2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_DNV3, "DNV3", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_DVT0, "DVT0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_DVT1, "DVT1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_DVT2, "DVT2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_DVT3, "DVT3", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_DVLIM, "DVLIM", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_INV0, "INV0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_INV1, "INV1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_INV2, "INV2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_INV3, "INV3", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_IVT0, "IVT0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_IVT1, "IVT1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_IVT2, "IVT2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_IVT3, "IVT3", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_IVLIM, "IVLIM", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* Cache debug */ /* XXX : not implemented */ spr_register(env, SPR_BOOKE_DCBTRH, "DCBTRH", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, SPR_NOACCESS, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_BOOKE_DCBTRL, "DCBTRL", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, SPR_NOACCESS, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_BOOKE_ICBDR, "ICBDR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, SPR_NOACCESS, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_BOOKE_ICBTRH, "ICBTRH", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, SPR_NOACCESS, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_BOOKE_ICBTRL, "ICBTRL", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, SPR_NOACCESS, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_440_DBDR, "DBDR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* Processor control */ spr_register(env, SPR_4xx_CCR0, "CCR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_440_RSTCFG, "RSTCFG", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, SPR_NOACCESS, 0x00000000); /* Storage control */ spr_register(env, SPR_440_MMUCR, "MMUCR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); }
false
qemu
2662a059aa2affddfbe42e78b11c802cf30a970f
6,526
static void get_cpuid_vendor(CPUX86State *env, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { *ebx = env->cpuid_vendor1; *edx = env->cpuid_vendor2; *ecx = env->cpuid_vendor3; /* sysenter isn't supported on compatibility mode on AMD, syscall * isn't supported in compatibility mode on Intel. * Normally we advertise the actual cpu vendor, but you can override * this if you want to use KVM's sysenter/syscall emulation * in compatibility mode and when doing cross vendor migration */ if (kvm_enabled() && env->cpuid_vendor_override) { host_cpuid(0, 0, NULL, ebx, ecx, edx); } }
false
qemu
8935499831312ec3e108287d3d49614915847ab2
6,527
void qmp_blockdev_change_medium(const char *device, const char *filename, bool has_format, const char *format, bool has_read_only, BlockdevChangeReadOnlyMode read_only, Error **errp) { BlockBackend *blk; BlockDriverState *medium_bs = NULL; int bdrv_flags, ret; QDict *options = NULL; Error *err = NULL; blk = blk_by_name(device); if (!blk) { error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", device); goto fail; } if (blk_bs(blk)) { blk_update_root_state(blk); } bdrv_flags = blk_get_open_flags_from_root_state(blk); bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_PROTOCOL); if (!has_read_only) { read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; } switch (read_only) { case BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN: break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_ONLY: bdrv_flags &= ~BDRV_O_RDWR; break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_WRITE: bdrv_flags |= BDRV_O_RDWR; break; default: abort(); } if (has_format) { options = qdict_new(); qdict_put(options, "driver", qstring_from_str(format)); } assert(!medium_bs); ret = bdrv_open(&medium_bs, filename, NULL, options, bdrv_flags, errp); if (ret < 0) { goto fail; } blk_apply_root_state(blk, medium_bs); bdrv_add_key(medium_bs, NULL, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_blockdev_open_tray(device, false, false, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_x_blockdev_remove_medium(device, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_blockdev_insert_anon_medium(device, medium_bs, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_blockdev_close_tray(device, errp); fail: /* If the medium has been inserted, the device has its own reference, so * ours must be relinquished; and if it has not been inserted successfully, * the reference must be relinquished anyway */ bdrv_unref(medium_bs); }
false
qemu
a5614993d79584af93bb845f69f59872b3f76cf8
6,528
static inline int ppcemb_tlb_check(CPUState *env, ppcemb_tlb_t *tlb, target_phys_addr_t *raddrp, target_ulong address, uint32_t pid, int ext, int i) { target_ulong mask; /* Check valid flag */ if (!(tlb->prot & PAGE_VALID)) { qemu_log("%s: TLB %d not valid\n", __func__, i); return -1; } mask = ~(tlb->size - 1); LOG_SWTLB("%s: TLB %d address " TARGET_FMT_lx " PID %u <=> " TARGET_FMT_lx " " TARGET_FMT_lx " %u\n", __func__, i, address, pid, tlb->EPN, mask, (uint32_t)tlb->PID); /* Check PID */ if (tlb->PID != 0 && tlb->PID != pid) return -1; /* Check effective address */ if ((address & mask) != tlb->EPN) return -1; *raddrp = (tlb->RPN & mask) | (address & ~mask); #if (TARGET_PHYS_ADDR_BITS >= 36) if (ext) { /* Extend the physical address to 36 bits */ *raddrp |= (target_phys_addr_t)(tlb->RPN & 0xF) << 32; } #endif return 0; }
false
qemu
24e0e38b83616ee7b540a270d8c4f24edf94f802
6,529
void ppc_slb_invalidate_one (CPUPPCState *env, uint64_t T0) { /* XXX: TODO */ tlb_flush(env, 1); }
false
qemu
eacc324914c2dc7aecec3b4ea920252b685b5c8e
6,530
static void validate_test_add(const char *testpath, TestInputVisitorData *data, void (*test_func)(TestInputVisitorData *data, const void *user_data)) { g_test_add(testpath, TestInputVisitorData, data, NULL, test_func, validate_teardown); }
false
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
6,531
static void omap_ulpd_pm_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; int64_t now, ticks; int div, mult; static const int bypass_div[4] = { 1, 2, 4, 4 }; uint16_t diff; if (size != 2) { return omap_badwidth_write16(opaque, addr, value); } switch (addr) { case 0x00: /* COUNTER_32_LSB */ case 0x04: /* COUNTER_32_MSB */ case 0x08: /* COUNTER_HIGH_FREQ_LSB */ case 0x0c: /* COUNTER_HIGH_FREQ_MSB */ case 0x14: /* IT_STATUS */ case 0x40: /* STATUS_REQ */ OMAP_RO_REG(addr); break; case 0x10: /* GAUGING_CTRL */ /* Bits 0 and 1 seem to be confused in the OMAP 310 TRM */ if ((s->ulpd_pm_regs[addr >> 2] ^ value) & 1) { now = qemu_get_clock_ns(vm_clock); if (value & 1) s->ulpd_gauge_start = now; else { now -= s->ulpd_gauge_start; /* 32-kHz ticks */ ticks = muldiv64(now, 32768, get_ticks_per_sec()); s->ulpd_pm_regs[0x00 >> 2] = (ticks >> 0) & 0xffff; s->ulpd_pm_regs[0x04 >> 2] = (ticks >> 16) & 0xffff; if (ticks >> 32) /* OVERFLOW_32K */ s->ulpd_pm_regs[0x14 >> 2] |= 1 << 2; /* High frequency ticks */ ticks = muldiv64(now, 12000000, get_ticks_per_sec()); s->ulpd_pm_regs[0x08 >> 2] = (ticks >> 0) & 0xffff; s->ulpd_pm_regs[0x0c >> 2] = (ticks >> 16) & 0xffff; if (ticks >> 32) /* OVERFLOW_HI_FREQ */ s->ulpd_pm_regs[0x14 >> 2] |= 1 << 1; s->ulpd_pm_regs[0x14 >> 2] |= 1 << 0; /* IT_GAUGING */ qemu_irq_raise(qdev_get_gpio_in(s->ih[1], OMAP_INT_GAUGE_32K)); } } s->ulpd_pm_regs[addr >> 2] = value; break; case 0x18: /* Reserved */ case 0x1c: /* Reserved */ case 0x20: /* Reserved */ case 0x28: /* Reserved */ case 0x2c: /* Reserved */ OMAP_BAD_REG(addr); case 0x24: /* SETUP_ANALOG_CELL3_ULPD1 */ case 0x38: /* COUNTER_32_FIQ */ case 0x48: /* LOCL_TIME */ case 0x50: /* POWER_CTRL */ s->ulpd_pm_regs[addr >> 2] = value; break; case 0x30: /* CLOCK_CTRL */ diff = s->ulpd_pm_regs[addr >> 2] ^ value; s->ulpd_pm_regs[addr >> 2] = value & 0x3f; omap_ulpd_clk_update(s, diff, value); break; case 0x34: /* SOFT_REQ */ diff = s->ulpd_pm_regs[addr >> 2] ^ value; s->ulpd_pm_regs[addr >> 2] = value & 0x1f; omap_ulpd_req_update(s, diff, value); break; case 0x3c: /* DPLL_CTRL */ /* XXX: OMAP310 TRM claims bit 3 is PLL_ENABLE, and bit 4 is * omitted altogether, probably a typo. */ /* This register has identical semantics with DPLL(1:3) control * registers, see omap_dpll_write() */ diff = s->ulpd_pm_regs[addr >> 2] & value; s->ulpd_pm_regs[addr >> 2] = value & 0x2fff; if (diff & (0x3ff << 2)) { if (value & (1 << 4)) { /* PLL_ENABLE */ div = ((value >> 5) & 3) + 1; /* PLL_DIV */ mult = MIN((value >> 7) & 0x1f, 1); /* PLL_MULT */ } else { div = bypass_div[((value >> 2) & 3)]; /* BYPASS_DIV */ mult = 1; } omap_clk_setrate(omap_findclk(s, "dpll4"), div, mult); } /* Enter the desired mode. */ s->ulpd_pm_regs[addr >> 2] = (s->ulpd_pm_regs[addr >> 2] & 0xfffe) | ((s->ulpd_pm_regs[addr >> 2] >> 4) & 1); /* Act as if the lock is restored. */ s->ulpd_pm_regs[addr >> 2] |= 2; break; case 0x4c: /* APLL_CTRL */ diff = s->ulpd_pm_regs[addr >> 2] & value; s->ulpd_pm_regs[addr >> 2] = value & 0xf; if (diff & (1 << 0)) /* APLL_NDPLL_SWITCH */ omap_clk_reparent(omap_findclk(s, "ck_48m"), omap_findclk(s, (value & (1 << 0)) ? "apll" : "dpll4")); break; default: OMAP_BAD_REG(addr); } }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
6,533
void cpu_dump_state (CPUState *env, FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...), int flags) { #define RGPL 4 #define RFPL 4 int i; cpu_fprintf(f, "NIP " ADDRX " LR " ADDRX " CTR " ADDRX " XER %08x\n", env->nip, env->lr, env->ctr, env->xer); cpu_fprintf(f, "MSR " ADDRX " HID0 " ADDRX " HF " ADDRX " idx %d\n", env->msr, env->spr[SPR_HID0], env->hflags, env->mmu_idx); #if !defined(NO_TIMER_DUMP) cpu_fprintf(f, "TB %08x %08x " #if !defined(CONFIG_USER_ONLY) "DECR %08x" #endif "\n", cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env) #if !defined(CONFIG_USER_ONLY) , cpu_ppc_load_decr(env) #endif ); #endif for (i = 0; i < 32; i++) { if ((i & (RGPL - 1)) == 0) cpu_fprintf(f, "GPR%02d", i); cpu_fprintf(f, " " REGX, ppc_dump_gpr(env, i)); if ((i & (RGPL - 1)) == (RGPL - 1)) cpu_fprintf(f, "\n"); } cpu_fprintf(f, "CR "); for (i = 0; i < 8; i++) cpu_fprintf(f, "%01x", env->crf[i]); cpu_fprintf(f, " ["); for (i = 0; i < 8; i++) { char a = '-'; if (env->crf[i] & 0x08) a = 'L'; else if (env->crf[i] & 0x04) a = 'G'; else if (env->crf[i] & 0x02) a = 'E'; cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' '); } cpu_fprintf(f, " ] RES " ADDRX "\n", env->reserve); for (i = 0; i < 32; i++) { if ((i & (RFPL - 1)) == 0) cpu_fprintf(f, "FPR%02d", i); cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i])); if ((i & (RFPL - 1)) == (RFPL - 1)) cpu_fprintf(f, "\n"); } cpu_fprintf(f, "FPSCR %08x\n", env->fpscr); #if !defined(CONFIG_USER_ONLY) cpu_fprintf(f, "SRR0 " ADDRX " SRR1 " ADDRX " SDR1 " ADDRX "\n", env->spr[SPR_SRR0], env->spr[SPR_SRR1], env->sdr1); #endif #undef RGPL #undef RFPL }
false
qemu
18b21a2f83a26c3d6a9e7f0bdc4e8eb2b177e8f6
6,534
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) { UnsharpContext *unsharp = ctx->priv; int lmsize_x = 5, cmsize_x = 0; int lmsize_y = 5, cmsize_y = 0; double lamount = 1.0f, camount = 0.0f; if (args) sscanf(args, "%d:%d:%lf:%d:%d:%lf", &lmsize_x, &lmsize_y, &lamount, &cmsize_x, &cmsize_y, &camount); if ((lamount && (lmsize_x < 2 || lmsize_y < 2)) || (camount && (cmsize_x < 2 || cmsize_y < 2))) { av_log(ctx, AV_LOG_ERROR, "Invalid value <2 for lmsize_x:%d or lmsize_y:%d or cmsize_x:%d or cmsize_y:%d\n", lmsize_x, lmsize_y, cmsize_x, cmsize_y); return AVERROR(EINVAL); } set_filter_param(&unsharp->luma, lmsize_x, lmsize_y, lamount); set_filter_param(&unsharp->chroma, cmsize_x, cmsize_y, camount); return 0; }
false
FFmpeg
1ee20141900c98f9dc25eca121c66c3ff468c1e4
6,536
int ff_h264_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { H264Context *h = dst->priv_data, *h1 = src->priv_data; int inited = h->context_initialized, err = 0; int need_reinit = 0; int i, ret; if (dst == src || !h1->context_initialized) return 0; if (!h1->ps.sps) return AVERROR_INVALIDDATA; if (inited && (h->width != h1->width || h->height != h1->height || h->mb_width != h1->mb_width || h->mb_height != h1->mb_height || !h->ps.sps || h->ps.sps->bit_depth_luma != h1->ps.sps->bit_depth_luma || h->ps.sps->chroma_format_idc != h1->ps.sps->chroma_format_idc || h->ps.sps->colorspace != h1->ps.sps->colorspace)) { need_reinit = 1; } // SPS/PPS for (i = 0; i < FF_ARRAY_ELEMS(h->ps.sps_list); i++) { av_buffer_unref(&h->ps.sps_list[i]); if (h1->ps.sps_list[i]) { h->ps.sps_list[i] = av_buffer_ref(h1->ps.sps_list[i]); if (!h->ps.sps_list[i]) return AVERROR(ENOMEM); } } for (i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++) { av_buffer_unref(&h->ps.pps_list[i]); if (h1->ps.pps_list[i]) { h->ps.pps_list[i] = av_buffer_ref(h1->ps.pps_list[i]); if (!h->ps.pps_list[i]) return AVERROR(ENOMEM); } } h->ps.sps = h1->ps.sps; if (need_reinit || !inited) { h->width = h1->width; h->height = h1->height; h->mb_height = h1->mb_height; h->mb_width = h1->mb_width; h->mb_num = h1->mb_num; h->mb_stride = h1->mb_stride; h->b_stride = h1->b_stride; if ((err = h264_slice_header_init(h)) < 0) { av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed"); return err; } /* copy block_offset since frame_start may not be called */ memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset)); } h->avctx->coded_height = h1->avctx->coded_height; h->avctx->coded_width = h1->avctx->coded_width; h->avctx->width = h1->avctx->width; h->avctx->height = h1->avctx->height; h->coded_picture_number = h1->coded_picture_number; h->first_field = h1->first_field; h->picture_structure = h1->picture_structure; h->droppable = h1->droppable; h->low_delay = h1->low_delay; for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) { ff_h264_unref_picture(h, &h->DPB[i]); if (h1->DPB[i].f->buf[0] && (ret = ff_h264_ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0) return ret; } h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1); ff_h264_unref_picture(h, &h->cur_pic); if (h1->cur_pic.f->buf[0]) { ret = ff_h264_ref_picture(h, &h->cur_pic, &h1->cur_pic); if (ret < 0) return ret; } h->enable_er = h1->enable_er; h->workaround_bugs = h1->workaround_bugs; h->low_delay = h1->low_delay; h->droppable = h1->droppable; // extradata/NAL handling h->is_avc = h1->is_avc; h->nal_length_size = h1->nal_length_size; // POC timing copy_fields(h, h1, poc_lsb, current_slice); copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1); copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1); copy_picture_range(h->delayed_pic, h1->delayed_pic, MAX_DELAYED_PIC_COUNT + 2, h, h1); if (!h->cur_pic_ptr) return 0; if (!h->droppable) { err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); h->prev_poc_msb = h->poc_msb; h->prev_poc_lsb = h->poc_lsb; } h->prev_frame_num_offset = h->frame_num_offset; h->prev_frame_num = h->frame_num; h->recovery_frame = h1->recovery_frame; h->frame_recovered = h1->frame_recovered; return err; }
false
FFmpeg
c8dcff0cdb17d0aa03ac729eba12d1a20f1f59c8
6,537
static int find_partition(BlockDriverState *bs, int partition, off_t *offset, off_t *size) { struct partition_record mbr[4]; uint8_t data[512]; int i; int ext_partnum = 4; int ret; if ((ret = bdrv_read(bs, 0, data, 1)) < 0) { errno = -ret; err(EXIT_FAILURE, "error while reading"); } if (data[510] != 0x55 || data[511] != 0xaa) { errno = -EINVAL; return -1; } for (i = 0; i < 4; i++) { read_partition(&data[446 + 16 * i], &mbr[i]); if (!mbr[i].nb_sectors_abs) continue; if (mbr[i].system == 0xF || mbr[i].system == 0x5) { struct partition_record ext[4]; uint8_t data1[512]; int j; if ((ret = bdrv_read(bs, mbr[i].start_sector_abs, data1, 1)) < 0) { errno = -ret; err(EXIT_FAILURE, "error while reading"); } for (j = 0; j < 4; j++) { read_partition(&data1[446 + 16 * j], &ext[j]); if (!ext[j].nb_sectors_abs) continue; if ((ext_partnum + j + 1) == partition) { *offset = (uint64_t)ext[j].start_sector_abs << 9; *size = (uint64_t)ext[j].nb_sectors_abs << 9; return 0; } } ext_partnum += 4; } else if ((i + 1) == partition) { *offset = (uint64_t)mbr[i].start_sector_abs << 9; *size = (uint64_t)mbr[i].nb_sectors_abs << 9; return 0; } } errno = -ENOENT; return -1; }
false
qemu
185b43386ad999c80bdc58e41b87f05e5b3e8463
6,538
static void thread_pool_cancel(BlockDriverAIOCB *acb) { ThreadPoolElement *elem = (ThreadPoolElement *)acb; ThreadPool *pool = elem->pool; trace_thread_pool_cancel(elem, elem->common.opaque); qemu_mutex_lock(&pool->lock); if (elem->state == THREAD_QUEUED && /* No thread has yet started working on elem. we can try to "steal" * the item from the worker if we can get a signal from the * semaphore. Because this is non-blocking, we can do it with * the lock taken and ensure that elem will remain THREAD_QUEUED. */ qemu_sem_timedwait(&pool->sem, 0) == 0) { QTAILQ_REMOVE(&pool->request_list, elem, reqs); elem->state = THREAD_CANCELED; event_notifier_set(&pool->notifier); } else { pool->pending_cancellations++; while (elem->state != THREAD_CANCELED && elem->state != THREAD_DONE) { qemu_cond_wait(&pool->check_cancel, &pool->lock); } pool->pending_cancellations--; } qemu_mutex_unlock(&pool->lock); event_notifier_ready(&pool->notifier); }
false
qemu
c2e50e3d11a0bf4c973cc30478c1af0f2d5f8e81
6,539
void qemu_fflush(QEMUFile *f) { if (!f->is_writable) return; if (f->buf_index > 0) { if (f->is_file) { fseek(f->outfile, f->buf_offset, SEEK_SET); fwrite(f->buf, 1, f->buf_index, f->outfile); } else { bdrv_pwrite(f->bs, f->base_offset + f->buf_offset, f->buf, f->buf_index); } f->buf_offset += f->buf_index; f->buf_index = 0; } }
false
qemu
5dafc53f1fb091d242f2179ffcb43bb28af36d1e
6,540
uint64_t ram_bytes_transferred(void) { return bytes_transferred; }
false
qemu
ad96090a01d848df67d70c5259ed8aa321fa8716
6,542
static void qxl_spice_destroy_surface_wait(PCIQXLDevice *qxl, uint32_t id, qxl_async_io async) { if (async) { #if SPICE_INTERFACE_QXL_MINOR < 1 abort(); #else spice_qxl_destroy_surface_async(&qxl->ssd.qxl, id, (uint64_t)id); #endif } else { qxl->ssd.worker->destroy_surface_wait(qxl->ssd.worker, id); qxl_spice_destroy_surface_wait_complete(qxl, id); } }
false
qemu
4295e15aa730a95003a3639d6dad2eb1e65a59e2
6,544
static inline void copy_backptr(LZOContext *c, int back, int cnt) { register const uint8_t *src = &c->out[-back]; register uint8_t *dst = c->out; if (src < c->out_start || src > dst) { c->error |= AV_LZO_INVALID_BACKPTR; return; } if (cnt > c->out_end - dst) { cnt = FFMAX(c->out_end - dst, 0); c->error |= AV_LZO_OUTPUT_FULL; } av_memcpy_backptr(dst, back, cnt); c->out = dst + cnt; }
true
FFmpeg
ca6c3f2c53be70aa3c38e8f1292809db89ea1ba6
6,546
bool guest_validate_base(unsigned long guest_base) { return 1; }
true
qemu
806d102141b99d4f1e55a97d68b7ea8c8ba3129f
6,548
static inline int mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, int n) { int level, dc, diff, i, j, run; int component; RLTable *rl = &ff_rl_mpeg1; uint8_t * const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix = s->intra_matrix; const int qscale = s->qscale; /* DC coefficient */ component = (n <= 3 ? 0 : n - 4 + 1); diff = decode_dc(&s->gb, component); if (diff >= 0xffff) return -1; dc = s->last_dc[component]; dc += diff; s->last_dc[component] = dc; block[0] = dc * quant_matrix[0]; av_dlog(s->avctx, "dc=%d diff=%d\n", dc, diff); i = 0; { OPEN_READER(re, &s->gb); /* now quantify & encode AC coefficients */ for (;;) { UPDATE_CACHE(re, &s->gb); GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); if (level == 127) { break; } else if (level != 0) { i += run; j = scantable[i]; level = (level * qscale * quant_matrix[j]) >> 4; level = (level - 1) | 1; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); } else { /* escape */ run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6); UPDATE_CACHE(re, &s->gb); level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8); if (level == -128) { level = SHOW_UBITS(re, &s->gb, 8) - 256; LAST_SKIP_BITS(re, &s->gb, 8); } else if (level == 0) { level = SHOW_UBITS(re, &s->gb, 8) ; LAST_SKIP_BITS(re, &s->gb, 8); } i += run; j = scantable[i]; if (level < 0) { level = -level; level = (level * qscale * quant_matrix[j]) >> 4; level = (level - 1) | 1; level = -level; } else { level = (level * qscale * quant_matrix[j]) >> 4; level = (level - 1) | 1; } } if (i > 63) { av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y); return -1; } block[j] = level; } CLOSE_READER(re, &s->gb); } s->block_last_index[n] = i; return 0; }
true
FFmpeg
6d93307f8df81808f0dcdbc064b848054a6e83b3
6,549
int qemu_strtoull(const char *nptr, const char **endptr, int base, uint64_t *result) { char *p; int err = 0; if (!nptr) { if (endptr) { *endptr = nptr; } err = -EINVAL; } else { errno = 0; *result = strtoull(nptr, &p, base); err = check_strtox_error(endptr, p, errno); } return err; }
true
qemu
47d4be12c3997343e436c6cca89aefbbbeb70863
6,550
static void gen_rac(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } t0 = tcg_temp_new(); gen_addr_reg_index(ctx, t0); gen_helper_rac(cpu_gpr[rD(ctx->opcode)], cpu_env, t0); tcg_temp_free(t0); #endif }
true
qemu
9b2fadda3e0196ffd485adde4fe9cdd6fae35300
6,551
static void kvm_s390_stattrib_synchronize(S390StAttribState *sa) { KVMS390StAttribState *sas = KVM_S390_STATTRIB(sa); MachineState *machine = MACHINE(qdev_get_machine()); unsigned long max = machine->maxram_size / TARGET_PAGE_SIZE; unsigned long cx, len = 1 << 19; int r; struct kvm_s390_cmma_log clog = { .flags = 0, .mask = ~0ULL, }; if (sas->incoming_buffer) { for (cx = 0; cx + len <= max; cx += len) { clog.start_gfn = cx; clog.count = len; clog.values = (uint64_t)(sas->incoming_buffer + cx * len); r = kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog); if (r) { error_report("KVM_S390_SET_CMMA_BITS failed: %s", strerror(-r)); return; } } if (cx < max) { clog.start_gfn = cx; clog.count = max - cx; clog.values = (uint64_t)(sas->incoming_buffer + cx * len); r = kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog); if (r) { error_report("KVM_S390_SET_CMMA_BITS failed: %s", strerror(-r)); } } g_free(sas->incoming_buffer); sas->incoming_buffer = NULL; } }
true
qemu
46fa893355e0bd88f3c59b886f0d75cbd5f0bbbe
6,552
static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) { QObject *req, *rsp = NULL, *id = NULL; QDict *qdict = NULL; const char *cmd_name; Monitor *mon = cur_mon; Error *err = NULL; req = json_parser_parse_err(tokens, NULL, &err); if (!req && !err) { /* json_parser_parse_err() sucks: can fail without setting @err */ error_setg(&err, QERR_JSON_PARSING); } if (err) { goto err_out; } qdict = qmp_check_input_obj(req, &err); if (!qdict) { goto err_out; } id = qdict_get(qdict, "id"); qobject_incref(id); qdict_del(qdict, "id"); cmd_name = qdict_get_str(qdict, "execute"); trace_handle_qmp_command(mon, cmd_name); rsp = qmp_dispatch(cur_mon->qmp.commands, req); if (mon->qmp.commands == &qmp_cap_negotiation_commands) { qdict = qdict_get_qdict(qobject_to_qdict(rsp), "error"); if (qdict && !g_strcmp0(qdict_get_try_str(qdict, "class"), QapiErrorClass_lookup[ERROR_CLASS_COMMAND_NOT_FOUND])) { /* Provide a more useful error message */ qdict_del(qdict, "desc"); qdict_put(qdict, "desc", qstring_from_str("Expecting capabilities negotiation" " with 'qmp_capabilities'")); } } err_out: if (err) { qdict = qdict_new(); qdict_put_obj(qdict, "error", qmp_build_error_object(err)); error_free(err); rsp = QOBJECT(qdict); } if (rsp) { if (id) { qdict_put_obj(qobject_to_qdict(rsp), "id", id); id = NULL; } monitor_json_emitter(mon, rsp); } qobject_decref(id); qobject_decref(rsp); qobject_decref(req); }
true
qemu
104fc3027960dd2aa9d310936a6cb201c60e1088
6,554
static void test_blk_read(BlockBackend *blk, long pattern, int64_t pattern_offset, int64_t pattern_count, int64_t offset, int64_t count, bool expect_failed) { void *pattern_buf = NULL; QEMUIOVector qiov; void *cmp_buf = NULL; int async_ret = NOT_DONE; if (pattern) { cmp_buf = g_malloc(pattern_count); memset(cmp_buf, pattern, pattern_count); } pattern_buf = g_malloc(count); if (pattern) { memset(pattern_buf, pattern, count); } else { memset(pattern_buf, 0x00, count); } qemu_iovec_init(&qiov, 1); qemu_iovec_add(&qiov, pattern_buf, count); blk_aio_preadv(blk, offset, &qiov, 0, blk_rw_done, &async_ret); while (async_ret == NOT_DONE) { main_loop_wait(false); } if (expect_failed) { g_assert(async_ret != 0); } else { g_assert(async_ret == 0); if (pattern) { g_assert(memcmp(pattern_buf + pattern_offset, cmp_buf, pattern_count) <= 0); } } g_free(pattern_buf); }
true
qemu
baf905e580ab9c8eaf228822c4a7b257493b4998
6,555
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int ignore_truncation) { AVBufferRef *sps_buf; int profile_idc, level_idc, constraint_set_flags = 0; unsigned int sps_id; int i, log2_max_frame_num_minus4; SPS *sps; sps_buf = av_buffer_allocz(sizeof(*sps)); if (!sps_buf) return AVERROR(ENOMEM); sps = (SPS*)sps_buf->data; sps->data_size = gb->buffer_end - gb->buffer; if (sps->data_size > sizeof(sps->data)) { av_log(avctx, AV_LOG_WARNING, "Truncating likely oversized SPS\n"); sps->data_size = sizeof(sps->data); } memcpy(sps->data, gb->buffer, sps->data_size); profile_idc = get_bits(gb, 8); constraint_set_flags |= get_bits1(gb) << 0; // constraint_set0_flag constraint_set_flags |= get_bits1(gb) << 1; // constraint_set1_flag constraint_set_flags |= get_bits1(gb) << 2; // constraint_set2_flag constraint_set_flags |= get_bits1(gb) << 3; // constraint_set3_flag constraint_set_flags |= get_bits1(gb) << 4; // constraint_set4_flag constraint_set_flags |= get_bits1(gb) << 5; // constraint_set5_flag skip_bits(gb, 2); // reserved_zero_2bits level_idc = get_bits(gb, 8); sps_id = get_ue_golomb_31(gb); if (sps_id >= MAX_SPS_COUNT) { av_log(avctx, AV_LOG_ERROR, "sps_id %u out of range\n", sps_id); goto fail; } sps->sps_id = sps_id; sps->time_offset_length = 24; sps->profile_idc = profile_idc; sps->constraint_set_flags = constraint_set_flags; sps->level_idc = level_idc; sps->full_range = -1; memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4)); memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8)); sps->scaling_matrix_present = 0; sps->colorspace = 2; //AVCOL_SPC_UNSPECIFIED if (sps->profile_idc == 100 || // High profile sps->profile_idc == 110 || // High10 profile sps->profile_idc == 122 || // High422 profile sps->profile_idc == 244 || // High444 Predictive profile sps->profile_idc == 44 || // Cavlc444 profile sps->profile_idc == 83 || // Scalable Constrained High profile (SVC) sps->profile_idc == 86 || // Scalable High Intra profile (SVC) sps->profile_idc == 118 || // Stereo High profile (MVC) sps->profile_idc == 128 || // Multiview High profile (MVC) sps->profile_idc == 138 || // Multiview Depth High profile (MVCD) sps->profile_idc == 144) { // old High444 profile sps->chroma_format_idc = get_ue_golomb_31(gb); if (sps->chroma_format_idc > 3U) { avpriv_request_sample(avctx, "chroma_format_idc %u", sps->chroma_format_idc); goto fail; } else if (sps->chroma_format_idc == 3) { sps->residual_color_transform_flag = get_bits1(gb); if (sps->residual_color_transform_flag) { av_log(avctx, AV_LOG_ERROR, "separate color planes are not supported\n"); goto fail; } } sps->bit_depth_luma = get_ue_golomb(gb) + 8; sps->bit_depth_chroma = get_ue_golomb(gb) + 8; if (sps->bit_depth_chroma != sps->bit_depth_luma) { avpriv_request_sample(avctx, "Different chroma and luma bit depth"); goto fail; } if (sps->bit_depth_luma < 8 || sps->bit_depth_luma > 14 || sps->bit_depth_chroma < 8 || sps->bit_depth_chroma > 14) { av_log(avctx, AV_LOG_ERROR, "illegal bit depth value (%d, %d)\n", sps->bit_depth_luma, sps->bit_depth_chroma); goto fail; } sps->transform_bypass = get_bits1(gb); sps->scaling_matrix_present |= decode_scaling_matrices(gb, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8); } else { sps->chroma_format_idc = 1; sps->bit_depth_luma = 8; sps->bit_depth_chroma = 8; } log2_max_frame_num_minus4 = get_ue_golomb(gb); if (log2_max_frame_num_minus4 < MIN_LOG2_MAX_FRAME_NUM - 4 || log2_max_frame_num_minus4 > MAX_LOG2_MAX_FRAME_NUM - 4) { av_log(avctx, AV_LOG_ERROR, "log2_max_frame_num_minus4 out of range (0-12): %d\n", log2_max_frame_num_minus4); goto fail; } sps->log2_max_frame_num = log2_max_frame_num_minus4 + 4; sps->poc_type = get_ue_golomb_31(gb); if (sps->poc_type == 0) { // FIXME #define unsigned t = get_ue_golomb(gb); if (t>12) { av_log(avctx, AV_LOG_ERROR, "log2_max_poc_lsb (%d) is out of range\n", t); goto fail; } sps->log2_max_poc_lsb = t + 4; } else if (sps->poc_type == 1) { // FIXME #define sps->delta_pic_order_always_zero_flag = get_bits1(gb); sps->offset_for_non_ref_pic = get_se_golomb(gb); sps->offset_for_top_to_bottom_field = get_se_golomb(gb); sps->poc_cycle_length = get_ue_golomb(gb); if ((unsigned)sps->poc_cycle_length >= FF_ARRAY_ELEMS(sps->offset_for_ref_frame)) { av_log(avctx, AV_LOG_ERROR, "poc_cycle_length overflow %d\n", sps->poc_cycle_length); goto fail; } for (i = 0; i < sps->poc_cycle_length; i++) sps->offset_for_ref_frame[i] = get_se_golomb(gb); } else if (sps->poc_type != 2) { av_log(avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type); goto fail; } sps->ref_frame_count = get_ue_golomb_31(gb); if (avctx->codec_tag == MKTAG('S', 'M', 'V', '2')) sps->ref_frame_count = FFMAX(2, sps->ref_frame_count); if (sps->ref_frame_count > MAX_DELAYED_PIC_COUNT) { av_log(avctx, AV_LOG_ERROR, "too many reference frames %d\n", sps->ref_frame_count); goto fail; } sps->gaps_in_frame_num_allowed_flag = get_bits1(gb); sps->mb_width = get_ue_golomb(gb) + 1; sps->mb_height = get_ue_golomb(gb) + 1; sps->frame_mbs_only_flag = get_bits1(gb); if (sps->mb_height >= INT_MAX / 2) { av_log(avctx, AV_LOG_ERROR, "height overflow\n"); goto fail; } sps->mb_height *= 2 - sps->frame_mbs_only_flag; if (!sps->frame_mbs_only_flag) sps->mb_aff = get_bits1(gb); else sps->mb_aff = 0; if ((unsigned)sps->mb_width >= INT_MAX / 16 || (unsigned)sps->mb_height >= INT_MAX / 16 || av_image_check_size(16 * sps->mb_width, 16 * sps->mb_height, 0, avctx)) { av_log(avctx, AV_LOG_ERROR, "mb_width/height overflow\n"); goto fail; } sps->direct_8x8_inference_flag = get_bits1(gb); #ifndef ALLOW_INTERLACE if (sps->mb_aff) av_log(avctx, AV_LOG_ERROR, "MBAFF support not included; enable it at compile-time.\n"); #endif sps->crop = get_bits1(gb); if (sps->crop) { unsigned int crop_left = get_ue_golomb(gb); unsigned int crop_right = get_ue_golomb(gb); unsigned int crop_top = get_ue_golomb(gb); unsigned int crop_bottom = get_ue_golomb(gb); int width = 16 * sps->mb_width; int height = 16 * sps->mb_height; if (avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) { av_log(avctx, AV_LOG_DEBUG, "discarding sps cropping, original " "values are l:%d r:%d t:%d b:%d\n", crop_left, crop_right, crop_top, crop_bottom); sps->crop_left = sps->crop_right = sps->crop_top = sps->crop_bottom = 0; } else { int vsub = (sps->chroma_format_idc == 1) ? 1 : 0; int hsub = (sps->chroma_format_idc == 1 || sps->chroma_format_idc == 2) ? 1 : 0; int step_x = 1 << hsub; int step_y = (2 - sps->frame_mbs_only_flag) << vsub; if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) && !(avctx->flags & AV_CODEC_FLAG_UNALIGNED)) { crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8)); av_log(avctx, AV_LOG_WARNING, "Reducing left cropping to %d " "chroma samples to preserve alignment.\n", crop_left); } if (crop_left > (unsigned)INT_MAX / 4 / step_x || crop_right > (unsigned)INT_MAX / 4 / step_x || crop_top > (unsigned)INT_MAX / 4 / step_y || crop_bottom> (unsigned)INT_MAX / 4 / step_y || (crop_left + crop_right ) * step_x >= width || (crop_top + crop_bottom) * step_y >= height ) { av_log(avctx, AV_LOG_ERROR, "crop values invalid %d %d %d %d / %d %d\n", crop_left, crop_right, crop_top, crop_bottom, width, height); goto fail; } sps->crop_left = crop_left * step_x; sps->crop_right = crop_right * step_x; sps->crop_top = crop_top * step_y; sps->crop_bottom = crop_bottom * step_y; } } else { sps->crop_left = sps->crop_right = sps->crop_top = sps->crop_bottom = sps->crop = 0; } sps->vui_parameters_present_flag = get_bits1(gb); if (sps->vui_parameters_present_flag) { int ret = decode_vui_parameters(gb, avctx, sps); if (ret < 0) goto fail; } if (get_bits_left(gb) < 0) { av_log(avctx, ignore_truncation ? AV_LOG_WARNING : AV_LOG_ERROR, "Overread %s by %d bits\n", sps->vui_parameters_present_flag ? "VUI" : "SPS", -get_bits_left(gb)); if (!ignore_truncation) goto fail; } /* if the maximum delay is not stored in the SPS, derive it based on the * level */ if (!sps->bitstream_restriction_flag && (sps->ref_frame_count || avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT)) { sps->num_reorder_frames = MAX_DELAYED_PIC_COUNT - 1; for (i = 0; i < FF_ARRAY_ELEMS(level_max_dpb_mbs); i++) { if (level_max_dpb_mbs[i][0] == sps->level_idc) { sps->num_reorder_frames = FFMIN(level_max_dpb_mbs[i][1] / (sps->mb_width * sps->mb_height), sps->num_reorder_frames); break; } } } if (!sps->sar.den) sps->sar.den = 1; if (avctx->debug & FF_DEBUG_PICT_INFO) { static const char csp[4][5] = { "Gray", "420", "422", "444" }; av_log(avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%u/%u/%u/%u %s %s %"PRId32"/%"PRId32" b%d reo:%d\n", sps_id, sps->profile_idc, sps->level_idc, sps->poc_type, sps->ref_frame_count, sps->mb_width, sps->mb_height, sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"), sps->direct_8x8_inference_flag ? "8B8" : "", sps->crop_left, sps->crop_right, sps->crop_top, sps->crop_bottom, sps->vui_parameters_present_flag ? "VUI" : "", csp[sps->chroma_format_idc], sps->timing_info_present_flag ? sps->num_units_in_tick : 0, sps->timing_info_present_flag ? sps->time_scale : 0, sps->bit_depth_luma, sps->bitstream_restriction_flag ? sps->num_reorder_frames : -1 ); } /* check if this is a repeat of an already parsed SPS, then keep the * original one. * otherwise drop all PPSes that depend on it */ if (ps->sps_list[sps_id] && !memcmp(ps->sps_list[sps_id]->data, sps_buf->data, sps_buf->size)) { av_buffer_unref(&sps_buf); } else { remove_sps(ps, sps_id); ps->sps_list[sps_id] = sps_buf; } return 0; fail: av_buffer_unref(&sps_buf); return AVERROR_INVALIDDATA; }
true
FFmpeg
59e5b05ef6f26064fc399f8e23aa05f962b8ae48
6,558
static int vhost_user_start(VhostUserState *s) { VhostNetOptions options; if (vhost_user_running(s)) { return 0; } options.backend_type = VHOST_BACKEND_TYPE_USER; options.net_backend = &s->nc; options.opaque = s->chr; options.force = true; s->vhost_net = vhost_net_init(&options); return vhost_user_running(s) ? 0 : -1; }
true
qemu
1e7398a140f7a6bd9f5a438e7ad0f1ef50990e25
6,559
FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, hwaddr data_addr, uint32_t data_width, hwaddr dma_addr, AddressSpace *dma_as) { DeviceState *dev; SysBusDevice *sbd; FWCfgState *s; bool dma_requested = dma_addr && dma_as; dev = qdev_create(NULL, TYPE_FW_CFG_MEM); qdev_prop_set_uint32(dev, "data_width", data_width); if (!dma_requested) { qdev_prop_set_bit(dev, "dma_enabled", false); } fw_cfg_init1(dev); sbd = SYS_BUS_DEVICE(dev); sysbus_mmio_map(sbd, 0, ctl_addr); sysbus_mmio_map(sbd, 1, data_addr); s = FW_CFG(dev); if (s->dma_enabled) { s->dma_as = dma_as; s->dma_addr = 0; sysbus_mmio_map(sbd, 2, dma_addr); } return s; }
true
qemu
38f3adc34de83bf75d2023831dc520d32568a2d9
6,560
static int protocol_client_auth_sasl_step(VncState *vs, uint8_t *data, size_t len) { uint32_t datalen = len; const char *serverout; unsigned int serveroutlen; int err; char *clientdata = NULL; /* NB, distinction of NULL vs "" is *critical* in SASL */ if (datalen) { clientdata = (char*)data; clientdata[datalen-1] = '\0'; /* Wire includes '\0', but make sure */ datalen--; /* Don't count NULL byte when passing to _start() */ } VNC_DEBUG("Step using SASL Data %p (%d bytes)\n", clientdata, datalen); err = sasl_server_step(vs->sasl.conn, clientdata, datalen, &serverout, &serveroutlen); if (err != SASL_OK && err != SASL_CONTINUE) { VNC_DEBUG("sasl step failed %d (%s)\n", err, sasl_errdetail(vs->sasl.conn)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } if (serveroutlen > SASL_DATA_MAX_LEN) { VNC_DEBUG("sasl step reply data too long %d\n", serveroutlen); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } VNC_DEBUG("SASL return data %d bytes, nil; %d\n", serveroutlen, serverout ? 0 : 1); if (serveroutlen) { vnc_write_u32(vs, serveroutlen + 1); vnc_write(vs, serverout, serveroutlen + 1); } else { vnc_write_u32(vs, 0); } /* Whether auth is complete */ vnc_write_u8(vs, err == SASL_CONTINUE ? 0 : 1); if (err == SASL_CONTINUE) { VNC_DEBUG("%s", "Authentication must continue\n"); /* Wait for step length */ vnc_read_when(vs, protocol_client_auth_sasl_step_len, 4); } else { if (!vnc_auth_sasl_check_ssf(vs)) { VNC_DEBUG("Authentication rejected for weak SSF %p\n", vs->ioc); goto authreject; } /* Check username whitelist ACL */ if (vnc_auth_sasl_check_access(vs) < 0) { VNC_DEBUG("Authentication rejected for ACL %p\n", vs->ioc); goto authreject; } VNC_DEBUG("Authentication successful %p\n", vs->ioc); vnc_write_u32(vs, 0); /* Accept auth */ /* * Delay writing in SSF encoded mode until pending output * buffer is written */ if (vs->sasl.runSSF) vs->sasl.waitWriteSSF = vs->output.offset; start_client_init(vs); } return 0; authreject: vnc_write_u32(vs, 1); /* Reject auth */ vnc_write_u32(vs, sizeof("Authentication failed")); vnc_write(vs, "Authentication failed", sizeof("Authentication failed")); vnc_flush(vs); vnc_client_error(vs); return -1; authabort: vnc_client_error(vs); return -1; }
true
qemu
7364dbdabb7824d5bde1e341bb6d928282f01c83
6,561
static void sdl_switch(DisplayChangeListener *dcl, DisplaySurface *new_surface) { PixelFormat pf = qemu_pixelformat_from_pixman(new_surface->format); /* temporary hack: allows to call sdl_switch to handle scaling changes */ if (new_surface) { surface = new_surface; } if (!scaling_active) { do_sdl_resize(surface_width(surface), surface_height(surface), 0); } else if (real_screen->format->BitsPerPixel != surface_bits_per_pixel(surface)) { do_sdl_resize(real_screen->w, real_screen->h, surface_bits_per_pixel(surface)); } if (guest_screen != NULL) { SDL_FreeSurface(guest_screen); } #ifdef DEBUG_SDL printf("SDL: Creating surface with masks: %08x %08x %08x %08x\n", pf.rmask, pf.gmask, pf.bmask, pf.amask); #endif guest_screen = SDL_CreateRGBSurfaceFrom (surface_data(surface), surface_width(surface), surface_height(surface), surface_bits_per_pixel(surface), surface_stride(surface), pf.rmask, pf.gmask, pf.bmask, pf.amask); }
true
qemu
d28d6505bd72f0d6e3e7a968c60c27f893da976e
6,562
static inline uint16_t mipsdsp_sat16_sub(int16_t a, int16_t b, CPUMIPSState *env) { int16_t temp; temp = a - b; if (MIPSDSP_OVERFLOW(a, -b, temp, 0x8000)) { if (a > 0) { temp = 0x7FFF; } else { temp = 0x8000; } set_DSPControl_overflow_flag(1, 20, env); } return temp; }
true
qemu
20c334a797bf46a4ee59a6e42be6d5e7c3cda585
6,564
void vhost_net_ack_features(struct vhost_net *net, unsigned features) { vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features); }
true
qemu
b49ae9138d5cadb47fb868297fbcdac8292fb666
6,565
void scsi_req_unref(SCSIRequest *req) { assert(req->refcount > 0); if (--req->refcount == 0) { BusState *qbus = req->dev->qdev.parent_bus; SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, qbus); if (bus->info->free_request && req->hba_private) { bus->info->free_request(bus, req->hba_private); } if (req->ops->free_req) { req->ops->free_req(req); } object_unref(OBJECT(req->dev)); object_unref(OBJECT(qbus->parent)); g_free(req); } }
true
qemu
61e68b3fbd3e2b7beb636bc56f78d9c1ca25e8f9
6,566
static void gen_tlbwe_440(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } switch (rB(ctx->opcode)) { case 0: case 1: case 2: { TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode)); gen_helper_440_tlbwe(cpu_env, t0, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); tcg_temp_free_i32(t0); } break; default: gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); break; } #endif }
true
qemu
9b2fadda3e0196ffd485adde4fe9cdd6fae35300
6,567
static void tcg_out_tlb_check (TCGContext *s, int r0, int r1, int r2, int addr_reg, int addr_reg2, int s_bits, int offset1, int offset2, uint8_t **label_ptr) { uint16_t retranst; tcg_out32 (s, (RLWINM | RA (r0) | RS (addr_reg) | SH (32 - (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS)) | MB (32 - (CPU_TLB_BITS + CPU_TLB_ENTRY_BITS)) | ME (31 - CPU_TLB_ENTRY_BITS) ) ); tcg_out32 (s, ADD | RT (r0) | RA (r0) | RB (TCG_AREG0)); tcg_out32 (s, (LWZU | RT (r1) | RA (r0) | offset1 ) ); tcg_out32 (s, (RLWINM | RA (r2) | RS (addr_reg) | SH (0) | MB ((32 - s_bits) & 31) | ME (31 - TARGET_PAGE_BITS) ) ); tcg_out32 (s, CMP | BF (7) | RA (r2) | RB (r1)); #if TARGET_LONG_BITS == 64 tcg_out32 (s, LWZ | RT (r1) | RA (r0) | 4); tcg_out32 (s, CMP | BF (6) | RA (addr_reg2) | RB (r1)); tcg_out32 (s, CRAND | BT (7, CR_EQ) | BA (6, CR_EQ) | BB (7, CR_EQ)); #endif /* Use a conditional branch-and-link so that we load a pointer to somewhere within the current opcode, for passing on to the helper. This address cannot be used for a tail call, but it's shorter than forming an address from scratch. */ *label_ptr = s->code_ptr; retranst = ((uint16_t *) s->code_ptr)[1] & ~3; tcg_out32(s, BC | BI(7, CR_EQ) | retranst | BO_COND_FALSE | LK); /* r0 now contains &env->tlb_table[mem_index][index].addr_x */ tcg_out32 (s, (LWZ | RT (r0) | RA (r0) | offset2 ) ); /* r0 = env->tlb_table[mem_index][index].addend */ tcg_out32 (s, ADD | RT (r0) | RA (r0) | RB (addr_reg)); /* r0 = env->tlb_table[mem_index][index].addend + addr */ }
true
qemu
8f50c841b374dc90ea604888ca92c37f469c428a
6,568
rgb48funcs(rgb, LE, PIX_FMT_RGB48LE) rgb48funcs(rgb, BE, PIX_FMT_RGB48BE) rgb48funcs(bgr, LE, PIX_FMT_BGR48LE) rgb48funcs(bgr, BE, PIX_FMT_BGR48BE) #define input_pixel(i) ((origin == PIX_FMT_RGBA || origin == PIX_FMT_BGRA || \ origin == PIX_FMT_ARGB || origin == PIX_FMT_ABGR) ? AV_RN32A(&src[(i)*4]) : \ (isBE(origin) ? AV_RB16(&src[(i)*2]) : AV_RL16(&src[(i)*2]))) static av_always_inline void rgb16_32ToY_c_template(uint8_t *dst, const uint8_t *src, int width, enum PixelFormat origin, int shr, int shg, int shb, int shp, int maskr, int maskg, int maskb, int rsh, int gsh, int bsh, int S) { const int ry = RY << rsh, gy = GY << gsh, by = BY << bsh, rnd = 33 << (S - 1); int i; for (i = 0; i < width; i++) { int px = input_pixel(i) >> shp; int b = (px & maskb) >> shb; int g = (px & maskg) >> shg; int r = (px & maskr) >> shr; dst[i] = (ry * r + gy * g + by * b + rnd) >> S; } }
true
FFmpeg
4391805916a1557278351f25428d0145b1073520
6,570
static void patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { tcg_insn_unit *target; tcg_insn_unit old; value += addend; target = (tcg_insn_unit *)value; switch (type) { case R_PPC_REL14: reloc_pc14(code_ptr, target); break; case R_PPC_REL24: reloc_pc24(code_ptr, target); break; case R_PPC_ADDR16: assert(value == (int16_t)value); old = *code_ptr; old = deposit32(old, 0, 16, value); *code_ptr = old; break; default: tcg_abort(); } }
true
qemu
030ffe39dd4128eb90483af82a5b23b23054a466
6,571
static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, unsigned int global_gain, IndividualChannelStream *ics, enum BandType band_type[120], int band_type_run_end[120]) { int g, i, idx = 0; int offset[3] = { global_gain, global_gain - 90, 0 }; int clipped_offset; int noise_flag = 1; static const char *const sf_str[3] = { "Global gain", "Noise gain", "Intensity stereo position" }; for (g = 0; g < ics->num_window_groups; g++) { for (i = 0; i < ics->max_sfb;) { int run_end = band_type_run_end[idx]; if (band_type[idx] == ZERO_BT) { for (; i < run_end; i++, idx++) sf[idx] = 0.; } else if ((band_type[idx] == INTENSITY_BT) || (band_type[idx] == INTENSITY_BT2)) { for (; i < run_end; i++, idx++) { offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; clipped_offset = av_clip(offset[2], -155, 100); if (offset[2] != clipped_offset) { av_log_ask_for_sample(ac->avctx, "Intensity stereo " "position clipped (%d -> %d).\nIf you heard an " "audible artifact, there may be a bug in the " "decoder. ", offset[2], clipped_offset); } sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO]; } } else if (band_type[idx] == NOISE_BT) { for (; i < run_end; i++, idx++) { if (noise_flag-- > 0) offset[1] += get_bits(gb, 9) - 256; else offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; clipped_offset = av_clip(offset[1], -100, 155); if (offset[1] != clipped_offset) { av_log_ask_for_sample(ac->avctx, "Noise gain clipped " "(%d -> %d).\nIf you heard an audible " "artifact, there may be a bug in the decoder. ", offset[1], clipped_offset); } sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO]; } } else { for (; i < run_end; i++, idx++) { offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; if (offset[0] > 255U) { av_log(ac->avctx, AV_LOG_ERROR, "%s (%d) out of range.\n", sf_str[0], offset[0]); return -1; } sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO]; } } } } return 0; }
true
FFmpeg
5e239c7f9e57d09c6a4c1d5762f441950f8d979c
6,572
void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins, const char *name, int n) { NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name); assert(gpio_list->num_in == 0 || !name); assert(gpio_list->num_out == 0); gpio_list->num_out = n; gpio_list->out = pins;
true
qemu
688b057aece53003f9d5a1dadc8961482dc2d948
6,573
static av_always_inline int check_block(SnowContext *s, int mb_x, int mb_y, int p[3], int intra, const uint8_t *obmc_edged, int *best_rd){ const int b_stride= s->b_width << s->block_max_depth; BlockNode *block= &s->block[mb_x + mb_y * b_stride]; BlockNode backup= *block; int rd, index, value; assert(mb_x>=0 && mb_y>=0); assert(mb_x<b_stride); if(intra){ block->color[0] = p[0]; block->color[1] = p[1]; block->color[2] = p[2]; block->type |= BLOCK_INTRA; }else{ index= (p[0] + 31*p[1]) & (ME_CACHE_SIZE-1); value= s->me_cache_generation + (p[0]>>10) + (p[1]<<6) + (block->ref<<12); if(s->me_cache[index] == value) return 0; s->me_cache[index]= value; block->mx= p[0]; block->my= p[1]; block->type &= ~BLOCK_INTRA; } rd= get_block_rd(s, mb_x, mb_y, 0, obmc_edged); //FIXME chroma if(rd < *best_rd){ *best_rd= rd; return 1; }else{ *block= backup; return 0; } }
true
FFmpeg
8540dcfd7af14da4080770dfbfa997cffdd0878b
6,574
static int vp3_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { Vp3DecodeContext *s = avctx->priv_data; GetBitContext gb; static int counter = 0; int i; init_get_bits(&gb, buf, buf_size * 8); if (s->theora && get_bits1(&gb)) { #if 1 av_log(avctx, AV_LOG_ERROR, "Header packet passed to frame decoder, skipping\n"); #else int ptype = get_bits(&gb, 7); skip_bits(&gb, 6*8); /* "theora" */ switch(ptype) { case 1: theora_decode_comments(avctx, &gb); break; case 2: theora_decode_tables(avctx, &gb); init_dequantizer(s); break; default: av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype); return buf_size; #endif s->keyframe = !get_bits1(&gb); if (!s->theora) skip_bits(&gb, 1); s->last_quality_index = s->quality_index; s->nqis=0; do{ s->qis[s->nqis++]= get_bits(&gb, 6); } while(s->theora >= 0x030200 && s->nqis<3 && get_bits1(&gb)); s->quality_index= s->qis[0]; if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n", s->keyframe?"key":"", counter, s->quality_index); counter++; if (s->quality_index != s->last_quality_index) { init_dequantizer(s); init_loop_filter(s); if (s->keyframe) { if (!s->theora) { skip_bits(&gb, 4); /* width code */ skip_bits(&gb, 4); /* height code */ if (s->version) { s->version = get_bits(&gb, 5); if (counter == 1) av_log(s->avctx, AV_LOG_DEBUG, "VP version: %d\n", s->version); if (s->version || s->theora) { if (get_bits1(&gb)) av_log(s->avctx, AV_LOG_ERROR, "Warning, unsupported keyframe coding type?!\n"); skip_bits(&gb, 2); /* reserved? */ if (s->last_frame.data[0] == s->golden_frame.data[0]) { if (s->golden_frame.data[0]) avctx->release_buffer(avctx, &s->golden_frame); s->last_frame= s->golden_frame; /* ensure that we catch any access to this released frame */ } else { if (s->golden_frame.data[0]) avctx->release_buffer(avctx, &s->golden_frame); if (s->last_frame.data[0]) avctx->release_buffer(avctx, &s->last_frame); s->golden_frame.reference = 3; if(avctx->get_buffer(avctx, &s->golden_frame) < 0) { av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n"); /* golden frame is also the current frame */ s->current_frame= s->golden_frame; /* time to figure out pixel addresses? */ if (!s->pixel_addresses_inited) { if (!s->flipped_image) vp3_calculate_pixel_addresses(s); else theora_calculate_pixel_addresses(s); } else { /* allocate a new current frame */ s->current_frame.reference = 3; if(avctx->get_buffer(avctx, &s->current_frame) < 0) { av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n"); s->current_frame.qscale_table= s->qscale_table; //FIXME allocate individual tables per AVFrame s->current_frame.qstride= 0; {START_TIMER init_frame(s, &gb); STOP_TIMER("init_frame")} #if KEYFRAMES_ONLY if (!s->keyframe) { memcpy(s->current_frame.data[0], s->golden_frame.data[0], s->current_frame.linesize[0] * s->height); memcpy(s->current_frame.data[1], s->golden_frame.data[1], s->current_frame.linesize[1] * s->height / 2); memcpy(s->current_frame.data[2], s->golden_frame.data[2], s->current_frame.linesize[2] * s->height / 2); } else { #endif {START_TIMER if (unpack_superblocks(s, &gb)){ av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n"); STOP_TIMER("unpack_superblocks")} {START_TIMER if (unpack_modes(s, &gb)){ av_log(s->avctx, AV_LOG_ERROR, "error in unpack_modes\n"); STOP_TIMER("unpack_modes")} {START_TIMER if (unpack_vectors(s, &gb)){ av_log(s->avctx, AV_LOG_ERROR, "error in unpack_vectors\n"); STOP_TIMER("unpack_vectors")} {START_TIMER if (unpack_dct_coeffs(s, &gb)){ av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n"); STOP_TIMER("unpack_dct_coeffs")} {START_TIMER reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height); if ((avctx->flags & CODEC_FLAG_GRAY) == 0) { reverse_dc_prediction(s, s->fragment_start[1], s->fragment_width / 2, s->fragment_height / 2); reverse_dc_prediction(s, s->fragment_start[2], s->fragment_width / 2, s->fragment_height / 2); STOP_TIMER("reverse_dc_prediction")} {START_TIMER for (i = 0; i < s->macroblock_height; i++) render_slice(s, i); STOP_TIMER("render_fragments")} {START_TIMER apply_loop_filter(s); STOP_TIMER("apply_loop_filter")} #if KEYFRAMES_ONLY #endif *data_size=sizeof(AVFrame); *(AVFrame*)data= s->current_frame; /* release the last frame, if it is allocated and if it is not the * golden frame */ if ((s->last_frame.data[0]) && (s->last_frame.data[0] != s->golden_frame.data[0])) avctx->release_buffer(avctx, &s->last_frame); /* shuffle frames (last = current) */ s->last_frame= s->current_frame; s->current_frame.data[0]= NULL; /* ensure that we catch any access to this released frame */ return buf_size;
true
FFmpeg
bc185f72c0ef515d1d077df5bad2fb1336f70d5e
6,576
static int swScale(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]) { /* load a few things into local vars to make the code more readable? and faster */ const int srcW= c->srcW; const int dstW= c->dstW; const int dstH= c->dstH; const int chrDstW= c->chrDstW; const int chrSrcW= c->chrSrcW; const int lumXInc= c->lumXInc; const int chrXInc= c->chrXInc; const enum PixelFormat dstFormat= c->dstFormat; const int flags= c->flags; int16_t *vLumFilterPos= c->vLumFilterPos; int16_t *vChrFilterPos= c->vChrFilterPos; int16_t *hLumFilterPos= c->hLumFilterPos; int16_t *hChrFilterPos= c->hChrFilterPos; int16_t *vLumFilter= c->vLumFilter; int16_t *vChrFilter= c->vChrFilter; int16_t *hLumFilter= c->hLumFilter; int16_t *hChrFilter= c->hChrFilter; int32_t *lumMmxFilter= c->lumMmxFilter; int32_t *chrMmxFilter= c->chrMmxFilter; const int vLumFilterSize= c->vLumFilterSize; const int vChrFilterSize= c->vChrFilterSize; const int hLumFilterSize= c->hLumFilterSize; const int hChrFilterSize= c->hChrFilterSize; int16_t **lumPixBuf= c->lumPixBuf; int16_t **chrUPixBuf= c->chrUPixBuf; int16_t **chrVPixBuf= c->chrVPixBuf; int16_t **alpPixBuf= c->alpPixBuf; const int vLumBufSize= c->vLumBufSize; const int vChrBufSize= c->vChrBufSize; uint8_t *formatConvBuffer= c->formatConvBuffer; const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample; const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); int lastDstY; uint32_t *pal=c->pal_yuv; yuv2planar1_fn yuv2plane1 = c->yuv2plane1; yuv2planarX_fn yuv2planeX = c->yuv2planeX; yuv2interleavedX_fn yuv2nv12cX = c->yuv2nv12cX; yuv2packed1_fn yuv2packed1 = c->yuv2packed1; yuv2packed2_fn yuv2packed2 = c->yuv2packed2; yuv2packedX_fn yuv2packedX = c->yuv2packedX; int should_dither = is9_OR_10BPS(c->srcFormat) || is16BPS(c->srcFormat); /* vars which will change and which we need to store back in the context */ int dstY= c->dstY; int lumBufIndex= c->lumBufIndex; int chrBufIndex= c->chrBufIndex; int lastInLumBuf= c->lastInLumBuf; int lastInChrBuf= c->lastInChrBuf; if (isPacked(c->srcFormat)) { src[0]= src[1]= src[2]= src[3]= src[0]; srcStride[0]= srcStride[1]= srcStride[2]= srcStride[3]= srcStride[0]; } srcStride[1]<<= c->vChrDrop; srcStride[2]<<= c->vChrDrop; DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n", src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3], dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]); DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n", srcSliceY, srcSliceH, dstY, dstH); DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n", vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize); if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) { static int warnedAlready=0; //FIXME move this into the context perhaps if (flags & SWS_PRINT_INFO && !warnedAlready) { av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n" " ->cannot do aligned memory accesses anymore\n"); warnedAlready=1; } } /* Note the user might start scaling the picture in the middle so this will not get executed. This is not really intended but works currently, so people might do it. */ if (srcSliceY ==0) { lumBufIndex=-1; chrBufIndex=-1; dstY=0; lastInLumBuf= -1; lastInChrBuf= -1; } if (!should_dither) { c->chrDither8 = c->lumDither8 = ff_sws_pb_64; } lastDstY= dstY; for (;dstY < dstH; dstY++) { const int chrDstY= dstY>>c->chrDstVSubSample; uint8_t *dest[4] = { dst[0] + dstStride[0] * dstY, dst[1] + dstStride[1] * chrDstY, dst[2] + dstStride[2] * chrDstY, (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL, }; const int firstLumSrcY= FFMAX(1 - vLumFilterSize, vLumFilterPos[dstY]); //First line needed as input const int firstLumSrcY2= FFMAX(1 - vLumFilterSize, vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)]); const int firstChrSrcY= FFMAX(1 - vChrFilterSize, vChrFilterPos[chrDstY]); //First line needed as input // Last line needed as input int lastLumSrcY = FFMIN(c->srcH, firstLumSrcY + vLumFilterSize) - 1; int lastLumSrcY2 = FFMIN(c->srcH, firstLumSrcY2 + vLumFilterSize) - 1; int lastChrSrcY = FFMIN(c->chrSrcH, firstChrSrcY + vChrFilterSize) - 1; int enough_lines; //handle holes (FAST_BILINEAR & weird filters) if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1; assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1); assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1); DEBUG_BUFFERS("dstY: %d\n", dstY); DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n", firstLumSrcY, lastLumSrcY, lastInLumBuf); DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n", firstChrSrcY, lastChrSrcY, lastInChrBuf); // Do we have enough lines in this slice to output the dstY line enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample); if (!enough_lines) { lastLumSrcY = srcSliceY + srcSliceH - 1; lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1; DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n", lastLumSrcY, lastChrSrcY); } //Do horizontal scaling while(lastInLumBuf < lastLumSrcY) { const uint8_t *src1[4] = { src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0], src[1] + (lastInLumBuf + 1 - srcSliceY) * srcStride[1], src[2] + (lastInLumBuf + 1 - srcSliceY) * srcStride[2], src[3] + (lastInLumBuf + 1 - srcSliceY) * srcStride[3], }; lumBufIndex++; assert(lumBufIndex < 2*vLumBufSize); assert(lastInLumBuf + 1 - srcSliceY < srcSliceH); assert(lastInLumBuf + 1 - srcSliceY >= 0); hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, formatConvBuffer, pal, 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf) hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, formatConvBuffer, pal, 1); lastInLumBuf++; DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n", lumBufIndex, lastInLumBuf); } while(lastInChrBuf < lastChrSrcY) { const uint8_t *src1[4] = { src[0] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[0], src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1], src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2], src[3] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[3], }; chrBufIndex++; assert(chrBufIndex < 2*vChrBufSize); assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH)); assert(lastInChrBuf + 1 - chrSrcSliceY >= 0); //FIXME replace parameters through context struct (some at least) if (c->needs_hcscale) hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex], chrDstW, src1, chrSrcW, chrXInc, hChrFilter, hChrFilterPos, hChrFilterSize, formatConvBuffer, pal); lastInChrBuf++; DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n", chrBufIndex, lastInChrBuf); } //wrap buf index around to stay inside the ring buffer if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize; if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize; if (!enough_lines) break; //we can't output a dstY line so let's try with the next slice #if HAVE_MMX updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf); #endif if (should_dither) { c->chrDither8 = dither_8x8_128[chrDstY & 7]; c->lumDither8 = dither_8x8_128[dstY & 7]; } if (dstY >= dstH-2) { // hmm looks like we can't use MMX here without overwriting this array's tail ff_sws_init_output_funcs(c, &yuv2plane1, &yuv2planeX, &yuv2nv12cX, &yuv2packed1, &yuv2packed2, &yuv2packedX); } { const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) { const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize; int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize); for (i = 0; i < neg; i++) tmpY[i] = lumSrcPtr[neg]; for ( ; i < end; i++) tmpY[i] = lumSrcPtr[i]; for ( ; i < vLumFilterSize; i++) tmpY[i] = tmpY[i-1]; lumSrcPtr = tmpY; if (alpSrcPtr) { const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize; for (i = 0; i < neg; i++) tmpA[i] = alpSrcPtr[neg]; for ( ; i < end; i++) tmpA[i] = alpSrcPtr[i]; for ( ; i < vLumFilterSize; i++) tmpA[i] = tmpA[i - 1]; alpSrcPtr = tmpA; } } if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) { const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize, **tmpV = (const int16_t **) chrVPixBuf + 2 * vChrBufSize; int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize); for (i = 0; i < neg; i++) { tmpU[i] = chrUSrcPtr[neg]; tmpV[i] = chrVSrcPtr[neg]; } for ( ; i < end; i++) { tmpU[i] = chrUSrcPtr[i]; tmpV[i] = chrVSrcPtr[i]; } for ( ; i < vChrFilterSize; i++) { tmpU[i] = tmpU[i - 1]; tmpV[i] = tmpV[i - 1]; } chrUSrcPtr = tmpU; chrVSrcPtr = tmpV; } if (isPlanarYUV(dstFormat) || (isGray(dstFormat) && !isALPHA(dstFormat))) { //YV12 like const int chrSkipMask= (1<<c->chrDstVSubSample)-1; if (vLumFilterSize == 1) { yuv2plane1(lumSrcPtr[0], dest[0], dstW, c->lumDither8, 0); } else { yuv2planeX(vLumFilter + dstY * vLumFilterSize, vLumFilterSize, lumSrcPtr, dest[0], dstW, c->lumDither8, 0); } if (!((dstY&chrSkipMask) || isGray(dstFormat))) { if (yuv2nv12cX) { yuv2nv12cX(c, vChrFilter + chrDstY * vChrFilterSize, vChrFilterSize, chrUSrcPtr, chrVSrcPtr, dest[1], chrDstW); } else if (vChrFilterSize == 1) { yuv2plane1(chrUSrcPtr[0], dest[1], chrDstW, c->chrDither8, 0); yuv2plane1(chrVSrcPtr[0], dest[2], chrDstW, c->chrDither8, 3); } else { yuv2planeX(vChrFilter + chrDstY * vChrFilterSize, vChrFilterSize, chrUSrcPtr, dest[1], chrDstW, c->chrDither8, 0); yuv2planeX(vChrFilter + chrDstY * vChrFilterSize, vChrFilterSize, chrVSrcPtr, dest[2], chrDstW, c->chrDither8, 3); } } if (CONFIG_SWSCALE_ALPHA && alpPixBuf){ if (vLumFilterSize == 1) { yuv2plane1(alpSrcPtr[0], dest[3], dstW, c->lumDither8, 0); } else { yuv2planeX(vLumFilter + dstY * vLumFilterSize, vLumFilterSize, alpSrcPtr, dest[3], dstW, c->lumDither8, 0); } } } else { assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize <= 2) { //unscaled RGB int chrAlpha = vChrFilterSize == 1 ? 0 : vChrFilter[2 * dstY + 1]; yuv2packed1(c, *lumSrcPtr, chrUSrcPtr, chrVSrcPtr, alpPixBuf ? *alpSrcPtr : NULL, dest[0], dstW, chrAlpha, dstY); } else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB int lumAlpha = vLumFilter[2 * dstY + 1]; int chrAlpha = vChrFilter[2 * dstY + 1]; lumMmxFilter[2] = lumMmxFilter[3] = vLumFilter[2 * dstY ] * 0x10001; chrMmxFilter[2] = chrMmxFilter[3] = vChrFilter[2 * chrDstY] * 0x10001; yuv2packed2(c, lumSrcPtr, chrUSrcPtr, chrVSrcPtr, alpPixBuf ? alpSrcPtr : NULL, dest[0], dstW, lumAlpha, chrAlpha, dstY); } else { //general RGB yuv2packedX(c, vLumFilter + dstY * vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter + dstY * vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, alpSrcPtr, dest[0], dstW, dstY); } } } } if (isPlanar(dstFormat) && isALPHA(dstFormat) && !alpPixBuf) fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255); #if HAVE_MMX2 if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2) __asm__ volatile("sfence":::"memory"); #endif emms_c(); /* store changed local vars back in the context */ c->dstY= dstY; c->lumBufIndex= lumBufIndex; c->chrBufIndex= chrBufIndex; c->lastInLumBuf= lastInLumBuf; c->lastInChrBuf= lastInChrBuf; return dstY - lastDstY; }
true
FFmpeg
2254b559cbcfc0418135f09add37c0a5866b1981
6,578
void tcg_op_remove(TCGContext *s, TCGOp *op) { int next = op->next; int prev = op->prev; /* We should never attempt to remove the list terminator. */ tcg_debug_assert(op != &s->gen_op_buf[0]); s->gen_op_buf[next].prev = prev; s->gen_op_buf[prev].next = next; memset(op, 0, sizeof(*op)); #ifdef CONFIG_PROFILER atomic_set(&s->prof.del_op_count, s->prof.del_op_count + 1); #endif }
true
qemu
15fa08f8451babc88d733bd411d4c94976f9d0f8
6,579
static void avc_luma_midv_qrt_8w_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, int32_t height, uint8_t ver_offset) { uint32_t loop_cnt; v16i8 src0, src1, src2, src3, src4; v16i8 mask0, mask1, mask2; v8i16 hz_out0, hz_out1, hz_out2, hz_out3; v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8; v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; v16u8 out; LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); LD_SB5(src, src_stride, src0, src1, src2, src3, src4); XORI_B5_128_SB(src0, src1, src2, src3, src4); src += (5 * src_stride); hz_out0 = AVC_HORZ_FILTER_SH(src0, mask0, mask1, mask2); hz_out1 = AVC_HORZ_FILTER_SH(src1, mask0, mask1, mask2); hz_out2 = AVC_HORZ_FILTER_SH(src2, mask0, mask1, mask2); hz_out3 = AVC_HORZ_FILTER_SH(src3, mask0, mask1, mask2); hz_out4 = AVC_HORZ_FILTER_SH(src4, mask0, mask1, mask2); for (loop_cnt = (height >> 2); loop_cnt--;) { LD_SB4(src, src_stride, src0, src1, src2, src3); XORI_B4_128_SB(src0, src1, src2, src3); src += (4 * src_stride); hz_out5 = AVC_HORZ_FILTER_SH(src0, mask0, mask1, mask2); hz_out6 = AVC_HORZ_FILTER_SH(src1, mask0, mask1, mask2); hz_out7 = AVC_HORZ_FILTER_SH(src2, mask0, mask1, mask2); hz_out8 = AVC_HORZ_FILTER_SH(src3, mask0, mask1, mask2); dst0 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5); dst2 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6); dst4 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out2, hz_out3, hz_out4, hz_out5, hz_out6, hz_out7); dst6 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out3, hz_out4, hz_out5, hz_out6, hz_out7, hz_out8); if (ver_offset) { dst1 = __msa_srari_h(hz_out3, 5); dst3 = __msa_srari_h(hz_out4, 5); dst5 = __msa_srari_h(hz_out5, 5); dst7 = __msa_srari_h(hz_out6, 5); } else { dst1 = __msa_srari_h(hz_out2, 5); dst3 = __msa_srari_h(hz_out3, 5); dst5 = __msa_srari_h(hz_out4, 5); dst7 = __msa_srari_h(hz_out5, 5); } SAT_SH4_SH(dst1, dst3, dst5, dst7, 7); dst0 = __msa_aver_s_h(dst0, dst1); dst1 = __msa_aver_s_h(dst2, dst3); dst2 = __msa_aver_s_h(dst4, dst5); dst3 = __msa_aver_s_h(dst6, dst7); out = PCKEV_XORI128_UB(dst0, dst0); ST8x1_UB(out, dst); dst += dst_stride; out = PCKEV_XORI128_UB(dst1, dst1); ST8x1_UB(out, dst); dst += dst_stride; out = PCKEV_XORI128_UB(dst2, dst2); ST8x1_UB(out, dst); dst += dst_stride; out = PCKEV_XORI128_UB(dst3, dst3); ST8x1_UB(out, dst); dst += dst_stride; hz_out0 = hz_out4; hz_out1 = hz_out5; hz_out2 = hz_out6; hz_out3 = hz_out7; hz_out4 = hz_out8; } }
false
FFmpeg
662234a9a22f1cd0f0ac83b8bb1ffadedca90c0a
6,581
static int gif_parse_next_image(GifState *s) { for (;;) { int code = bytestream_get_byte(&s->bytestream); #ifdef DEBUG dprintf(s->avctx, "gif: code=%02x '%c'\n", code, code); #endif switch (code) { case ',': if (gif_read_image(s) < 0) return -1; return 0; case ';': /* end of image */ return -1; case '!': if (gif_read_extension(s) < 0) return -1; break; default: /* error or errneous EOF */ return -1; } } }
false
FFmpeg
7a28b7714e4503149f773782a19708c773f3d62d