project
stringclasses
2 values
commit_id
stringlengths
40
40
target
int64
0
1
func
stringlengths
26
142k
idx
int64
0
27.3k
qemu
61007b316cd71ee7333ff7a0a749a8949527575f
0
void bdrv_init(void) { module_call_init(MODULE_INIT_BLOCK); }
25,763
qemu
eef5ad1086403d8ac8d91208a0e8dc34734b671c
0
void hmp_change(Monitor *mon, const QDict *qdict) { const char *device = qdict_get_str(qdict, "device"); const char *target = qdict_get_str(qdict, "target"); const char *arg = qdict_get_try_str(qdict, "arg"); Error *err = NULL; if (strcmp(device, "vnc") == 0 && (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0)) { if (!arg) { monitor_read_password(mon, hmp_change_read_arg, NULL); return; } } qmp_change(device, target, !!arg, arg, &err); if (error_is_type(err, QERR_DEVICE_ENCRYPTED)) { monitor_printf(mon, "%s (%s) is encrypted.\n", error_get_field(err, "device"), error_get_field(err, "filename")); if (!monitor_get_rs(mon)) { monitor_printf(mon, "terminal does not support password prompting\n"); error_free(err); return; } readline_start(monitor_get_rs(mon), "Password: ", 1, cb_hmp_change_bdrv_pwd, err); return; } hmp_handle_error(mon, &err); }
25,764
qemu
42a268c241183877192c376d03bd9b6d527407c7
0
static void gen_loop(DisasContext *ctx, int r1, int32_t offset) { int l1; l1 = gen_new_label(); tcg_gen_subi_tl(cpu_gpr_a[r1], cpu_gpr_a[r1], 1); tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr_a[r1], -1, l1); gen_goto_tb(ctx, 1, ctx->pc + offset); gen_set_label(l1); gen_goto_tb(ctx, 0, ctx->next_pc); }
25,765
qemu
245f7b51c0ea04fb2224b1127430a096c91aee70
0
static void tight_send_compact_size(VncState *vs, size_t len) { int lpc = 0; int bytes = 0; char buf[3] = {0, 0, 0}; buf[bytes++] = len & 0x7F; if (len > 0x7F) { buf[bytes-1] |= 0x80; buf[bytes++] = (len >> 7) & 0x7F; if (len > 0x3FFF) { buf[bytes-1] |= 0x80; buf[bytes++] = (len >> 14) & 0xFF; } } for (lpc = 0; lpc < bytes; lpc++) { vnc_write_u8(vs, buf[lpc]); } }
25,766
qemu
27a69bb088bee6d4efea254659422fb9c751b3c7
0
static inline void gen_evmwsmi(DisasContext *ctx) { TCGv_i64 t0, t1; if (unlikely(!ctx->spe_enabled)) { gen_exception(ctx, POWERPC_EXCP_APU); return; } t0 = tcg_temp_new_i64(); t1 = tcg_temp_new_i64(); /* t0 := rA; t1 := rB */ #if defined(TARGET_PPC64) tcg_gen_ext32s_tl(t0, cpu_gpr[rA(ctx->opcode)]); tcg_gen_ext32s_tl(t1, cpu_gpr[rB(ctx->opcode)]); #else tcg_gen_ext_tl_i64(t0, cpu_gpr[rA(ctx->opcode)]); tcg_gen_ext_tl_i64(t1, cpu_gpr[rB(ctx->opcode)]); #endif tcg_gen_mul_i64(t0, t0, t1); /* t0 := rA * rB */ gen_store_gpr64(rD(ctx->opcode), t0); /* rD := t0 */ tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); }
25,767
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
0
static uint64_t subpage_ram_read(void *opaque, target_phys_addr_t addr, unsigned size) { ram_addr_t raddr = addr; void *ptr = qemu_get_ram_ptr(raddr); switch (size) { case 1: return ldub_p(ptr); case 2: return lduw_p(ptr); case 4: return ldl_p(ptr); default: abort(); } }
25,768
FFmpeg
ca16618b01abfde44b4eaf92dc89b01aa1b4a91e
0
static int xan_decode_init(AVCodecContext *avctx) { XanContext *s = avctx->priv_data; int i; s->avctx = avctx; if ((avctx->codec->id == CODEC_ID_XAN_WC3) && (s->avctx->palctrl == NULL)) { av_log(avctx, AV_LOG_ERROR, " WC3 Xan video: palette expected.\n"); return -1; } avctx->pix_fmt = PIX_FMT_PAL8; avctx->has_b_frames = 0; dsputil_init(&s->dsp, avctx); /* initialize the RGB -> YUV tables */ for (i = 0; i < 256; i++) { y_r_table[i] = Y_R * i; y_g_table[i] = Y_G * i; y_b_table[i] = Y_B * i; u_r_table[i] = U_R * i; u_g_table[i] = U_G * i; u_b_table[i] = U_B * i; v_r_table[i] = V_R * i; v_g_table[i] = V_G * i; v_b_table[i] = V_B * i; } if(avcodec_check_dimensions(avctx, avctx->width, avctx->height)) return -1; s->buffer1 = av_malloc(avctx->width * avctx->height); s->buffer2 = av_malloc(avctx->width * avctx->height); if (!s->buffer1 || !s->buffer2) return -1; return 0; }
25,770
qemu
42a268c241183877192c376d03bd9b6d527407c7
0
void gen_intermediate_code_internal(XtensaCPU *cpu, TranslationBlock *tb, bool search_pc) { CPUState *cs = CPU(cpu); CPUXtensaState *env = &cpu->env; DisasContext dc; int insn_count = 0; int j, lj = -1; int max_insns = tb->cflags & CF_COUNT_MASK; uint32_t pc_start = tb->pc; uint32_t next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } dc.config = env->config; dc.singlestep_enabled = cs->singlestep_enabled; dc.tb = tb; dc.pc = pc_start; dc.ring = tb->flags & XTENSA_TBFLAG_RING_MASK; dc.cring = (tb->flags & XTENSA_TBFLAG_EXCM) ? 0 : dc.ring; dc.lbeg = env->sregs[LBEG]; dc.lend = env->sregs[LEND]; dc.is_jmp = DISAS_NEXT; dc.ccount_delta = 0; dc.debug = tb->flags & XTENSA_TBFLAG_DEBUG; dc.icount = tb->flags & XTENSA_TBFLAG_ICOUNT; dc.cpenable = (tb->flags & XTENSA_TBFLAG_CPENABLE_MASK) >> XTENSA_TBFLAG_CPENABLE_SHIFT; dc.window = ((tb->flags & XTENSA_TBFLAG_WINDOW_MASK) >> XTENSA_TBFLAG_WINDOW_SHIFT); init_litbase(&dc); init_sar_tracker(&dc); if (dc.icount) { dc.next_icount = tcg_temp_local_new_i32(); } gen_tb_start(tb); if (tb->flags & XTENSA_TBFLAG_EXCEPTION) { tcg_gen_movi_i32(cpu_pc, dc.pc); gen_exception(&dc, EXCP_DEBUG); } do { check_breakpoint(env, &dc); if (search_pc) { j = tcg_op_buf_count(); if (lj < j) { lj++; while (lj < j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } tcg_ctx.gen_opc_pc[lj] = dc.pc; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = insn_count; } if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) { tcg_gen_debug_insn_start(dc.pc); } ++dc.ccount_delta; if (insn_count + 1 == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } if (dc.icount) { int label = gen_new_label(); tcg_gen_addi_i32(dc.next_icount, cpu_SR[ICOUNT], 1); tcg_gen_brcondi_i32(TCG_COND_NE, dc.next_icount, 0, label); tcg_gen_mov_i32(dc.next_icount, cpu_SR[ICOUNT]); if (dc.debug) { gen_debug_exception(&dc, DEBUGCAUSE_IC); } gen_set_label(label); } if (dc.debug) { gen_ibreak_check(env, &dc); } disas_xtensa_insn(env, &dc); ++insn_count; if (dc.icount) { tcg_gen_mov_i32(cpu_SR[ICOUNT], dc.next_icount); } if (cs->singlestep_enabled) { tcg_gen_movi_i32(cpu_pc, dc.pc); gen_exception(&dc, EXCP_DEBUG); break; } } while (dc.is_jmp == DISAS_NEXT && insn_count < max_insns && dc.pc < next_page_start && dc.pc + xtensa_insn_len(env, &dc) <= next_page_start && !tcg_op_buf_full()); reset_litbase(&dc); reset_sar_tracker(&dc); if (dc.icount) { tcg_temp_free(dc.next_icount); } if (tb->cflags & CF_LAST_IO) { gen_io_end(); } if (dc.is_jmp == DISAS_NEXT) { gen_jumpi(&dc, dc.pc, 0); } gen_tb_end(tb, insn_count); #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(env, pc_start, dc.pc - pc_start, 0); qemu_log("\n"); } #endif if (search_pc) { j = tcg_op_buf_count(); memset(tcg_ctx.gen_opc_instr_start + lj + 1, 0, (j - lj) * sizeof(tcg_ctx.gen_opc_instr_start[0])); } else { tb->size = dc.pc - pc_start; tb->icount = insn_count; } }
25,771
FFmpeg
0ce3a0f9d9523a9bcad4c6d451ca5bbd7a4f420d
1
static void restore_median_il(uint8_t *src, int step, int stride, int width, int height, int slices, int rmode) { int i, j, slice; int A, B, C; uint8_t *bsrc; int slice_start, slice_height; const int cmask = ~(rmode ? 3 : 1); const int stride2 = stride << 1; for (slice = 0; slice < slices; slice++) { slice_start = ((slice * height) / slices) & cmask; slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start; slice_height >>= 1; bsrc = src + slice_start * stride; // first line - left neighbour prediction bsrc[0] += 0x80; A = bsrc[0]; for (i = step; i < width * step; i += step) { bsrc[i] += A; A = bsrc[i]; } for (i = 0; i < width * step; i += step) { bsrc[stride + i] += A; A = bsrc[stride + i]; } bsrc += stride2; if (slice_height == 1) // second line - first element has top prediction, the rest uses median C = bsrc[-stride2]; bsrc[0] += C; A = bsrc[0]; for (i = step; i < width * step; i += step) { B = bsrc[i - stride2]; bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); C = B; A = bsrc[i]; } for (i = 0; i < width * step; i += step) { B = bsrc[i - stride]; bsrc[stride + i] += mid_pred(A, B, (uint8_t)(A + B - C)); C = B; A = bsrc[stride + i]; } bsrc += stride2; // the rest of lines use continuous median prediction for (j = 2; j < slice_height; j++) { for (i = 0; i < width * step; i += step) { B = bsrc[i - stride2]; bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); C = B; A = bsrc[i]; } for (i = 0; i < width * step; i += step) { B = bsrc[i - stride]; bsrc[i + stride] += mid_pred(A, B, (uint8_t)(A + B - C)); C = B; A = bsrc[i + stride]; } bsrc += stride2; } } }
25,772
qemu
4d9ab7d4ed46c63d047862d11946996005742a09
1
static target_ulong h_put_tce_indirect(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { int i; target_ulong liobn = args[0]; target_ulong ioba = args[1]; target_ulong ioba1 = ioba; target_ulong tce_list = args[2]; target_ulong npages = args[3]; target_ulong ret = H_PARAMETER, tce = 0; sPAPRTCETable *tcet = spapr_tce_find_by_liobn(liobn); CPUState *cs = CPU(cpu); hwaddr page_mask, page_size; if (!tcet) { return H_PARAMETER; } if ((npages > 512) || (tce_list & SPAPR_TCE_PAGE_MASK)) { return H_PARAMETER; } page_mask = IOMMU_PAGE_MASK(tcet->page_shift); page_size = IOMMU_PAGE_SIZE(tcet->page_shift); ioba &= page_mask; for (i = 0; i < npages; ++i, ioba += page_size) { target_ulong off = (tce_list & ~SPAPR_TCE_RW) + i * sizeof(target_ulong); tce = ldq_be_phys(cs->as, off); ret = put_tce_emu(tcet, ioba, tce); if (ret) { break; } } /* Trace last successful or the first problematic entry */ i = i ? (i - 1) : 0; if (SPAPR_IS_PCI_LIOBN(liobn)) { trace_spapr_iommu_pci_indirect(liobn, ioba1, tce_list, i, tce, ret); } else { trace_spapr_iommu_indirect(liobn, ioba1, tce_list, i, tce, ret); } return ret; }
25,773
qemu
45b00c44ceffeac8143fb8857a12677234114f2b
1
ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[]) { int c; unsigned long long v; Error *errp = NULL; while ((c = getopt(argc, argv, "h" /* help */ "v" /* verbose */ "F" /* foreground */ "p:" /* pid_file */ "S:" /* unix_socket_path */ "m:" /* shm_path */ "l:" /* shm_size */ "n:" /* n_vectors */ )) != -1) { switch (c) { case 'h': /* help */ ivshmem_server_usage(argv[0], 0); break; case 'v': /* verbose */ args->verbose = 1; break; case 'F': /* foreground */ args->foreground = 1; break; case 'p': /* pid_file */ args->pid_file = strdup(optarg); break; case 'S': /* unix_socket_path */ args->unix_socket_path = strdup(optarg); break; case 'm': /* shm_path */ args->shm_path = strdup(optarg); break; case 'l': /* shm_size */ parse_option_size("shm_size", optarg, &args->shm_size, &errp); if (errp) { fprintf(stderr, "cannot parse shm size: %s\n", error_get_pretty(errp)); error_free(errp); ivshmem_server_usage(argv[0], 1); } break; case 'n': /* n_vectors */ if (parse_uint_full(optarg, &v, 0) < 0) { fprintf(stderr, "cannot parse n_vectors\n"); ivshmem_server_usage(argv[0], 1); } args->n_vectors = v; break; default: ivshmem_server_usage(argv[0], 1); break; } } if (args->n_vectors > IVSHMEM_SERVER_MAX_VECTORS) { fprintf(stderr, "too many requested vectors (max is %d)\n", IVSHMEM_SERVER_MAX_VECTORS); ivshmem_server_usage(argv[0], 1); } if (args->verbose == 1 && args->foreground == 0) { fprintf(stderr, "cannot use verbose in daemon mode\n"); ivshmem_server_usage(argv[0], 1); } }
25,774
qemu
894e02804c862c6940b43a0a488164655d3fb3f0
1
static int nbd_negotiate_options(NBDClient *client, uint16_t myflags, Error **errp) { uint32_t flags; bool fixedNewstyle = false; bool no_zeroes = false; /* Client sends: [ 0 .. 3] client flags Then we loop until NBD_OPT_EXPORT_NAME or NBD_OPT_GO: [ 0 .. 7] NBD_OPTS_MAGIC [ 8 .. 11] NBD option [12 .. 15] Data length ... Rest of request [ 0 .. 7] NBD_OPTS_MAGIC [ 8 .. 11] Second NBD option [12 .. 15] Data length ... Rest of request */ if (nbd_read(client->ioc, &flags, sizeof(flags), errp) < 0) { error_prepend(errp, "read failed: "); return -EIO; } be32_to_cpus(&flags); trace_nbd_negotiate_options_flags(flags); if (flags & NBD_FLAG_C_FIXED_NEWSTYLE) { fixedNewstyle = true; flags &= ~NBD_FLAG_C_FIXED_NEWSTYLE; } if (flags & NBD_FLAG_C_NO_ZEROES) { no_zeroes = true; flags &= ~NBD_FLAG_C_NO_ZEROES; } if (flags != 0) { error_setg(errp, "Unknown client flags 0x%" PRIx32 " received", flags); return -EINVAL; } while (1) { int ret; uint32_t option, length; uint64_t magic; if (nbd_read(client->ioc, &magic, sizeof(magic), errp) < 0) { error_prepend(errp, "read failed: "); return -EINVAL; } magic = be64_to_cpu(magic); trace_nbd_negotiate_options_check_magic(magic); if (magic != NBD_OPTS_MAGIC) { error_setg(errp, "Bad magic received"); return -EINVAL; } if (nbd_read(client->ioc, &option, sizeof(option), errp) < 0) { error_prepend(errp, "read failed: "); return -EINVAL; } option = be32_to_cpu(option); client->opt = option; if (nbd_read(client->ioc, &length, sizeof(length), errp) < 0) { error_prepend(errp, "read failed: "); return -EINVAL; } length = be32_to_cpu(length); client->optlen = length; if (length > NBD_MAX_BUFFER_SIZE) { error_setg(errp, "len (%" PRIu32" ) is larger than max len (%u)", length, NBD_MAX_BUFFER_SIZE); return -EINVAL; } trace_nbd_negotiate_options_check_option(option, nbd_opt_lookup(option)); if (client->tlscreds && client->ioc == (QIOChannel *)client->sioc) { QIOChannel *tioc; if (!fixedNewstyle) { error_setg(errp, "Unsupported option 0x%" PRIx32, option); return -EINVAL; } switch (option) { case NBD_OPT_STARTTLS: if (length) { /* Unconditionally drop the connection if the client * can't start a TLS negotiation correctly */ return nbd_reject_length(client, true, errp); } tioc = nbd_negotiate_handle_starttls(client, errp); if (!tioc) { return -EIO; } ret = 0; object_unref(OBJECT(client->ioc)); client->ioc = QIO_CHANNEL(tioc); break; case NBD_OPT_EXPORT_NAME: /* No way to return an error to client, so drop connection */ error_setg(errp, "Option 0x%x not permitted before TLS", option); return -EINVAL; default: if (nbd_drop(client->ioc, length, errp) < 0) { return -EIO; } ret = nbd_negotiate_send_rep_err(client, NBD_REP_ERR_TLS_REQD, errp, "Option 0x%" PRIx32 "not permitted before TLS", option); /* Let the client keep trying, unless they asked to * quit. In this mode, we've already sent an error, so * we can't ack the abort. */ if (option == NBD_OPT_ABORT) { return 1; } break; } } else if (fixedNewstyle) { switch (option) { case NBD_OPT_LIST: if (length) { ret = nbd_reject_length(client, false, errp); } else { ret = nbd_negotiate_handle_list(client, errp); } break; case NBD_OPT_ABORT: /* NBD spec says we must try to reply before * disconnecting, but that we must also tolerate * guests that don't wait for our reply. */ nbd_negotiate_send_rep(client, NBD_REP_ACK, NULL); return 1; case NBD_OPT_EXPORT_NAME: return nbd_negotiate_handle_export_name(client, myflags, no_zeroes, errp); case NBD_OPT_INFO: case NBD_OPT_GO: ret = nbd_negotiate_handle_info(client, myflags, errp); if (ret == 1) { assert(option == NBD_OPT_GO); return 0; } break; case NBD_OPT_STARTTLS: if (length) { ret = nbd_reject_length(client, false, errp); } else if (client->tlscreds) { ret = nbd_negotiate_send_rep_err(client, NBD_REP_ERR_INVALID, errp, "TLS already enabled"); } else { ret = nbd_negotiate_send_rep_err(client, NBD_REP_ERR_POLICY, errp, "TLS not configured"); } break; case NBD_OPT_STRUCTURED_REPLY: if (length) { ret = nbd_reject_length(client, false, errp); } else if (client->structured_reply) { ret = nbd_negotiate_send_rep_err( client, NBD_REP_ERR_INVALID, errp, "structured reply already negotiated"); } else { ret = nbd_negotiate_send_rep(client, NBD_REP_ACK, errp); client->structured_reply = true; myflags |= NBD_FLAG_SEND_DF; } break; default: if (nbd_drop(client->ioc, length, errp) < 0) { return -EIO; } ret = nbd_negotiate_send_rep_err(client, NBD_REP_ERR_UNSUP, errp, "Unsupported option 0x%" PRIx32 " (%s)", option, nbd_opt_lookup(option)); break; } } else { /* * If broken new-style we should drop the connection * for anything except NBD_OPT_EXPORT_NAME */ switch (option) { case NBD_OPT_EXPORT_NAME: return nbd_negotiate_handle_export_name(client, myflags, no_zeroes, errp); default: error_setg(errp, "Unsupported option 0x%" PRIx32 " (%s)", option, nbd_opt_lookup(option)); return -EINVAL; } } if (ret < 0) { return ret; } } }
25,776
FFmpeg
7b9fc769e40a7709fa59a54e2a810f76364eee4b
0
static int svq1_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MpegEncContext *s = avctx->priv_data; uint8_t *current, *previous; int result, i, x, y, width, height; AVFrame *pict = data; svq1_pmv *pmv; /* initialize bit buffer */ init_get_bits(&s->gb, buf, buf_size * 8); /* decode frame header */ s->f_code = get_bits(&s->gb, 22); if ((s->f_code & ~0x70) || !(s->f_code & 0x60)) return AVERROR_INVALIDDATA; /* swap some header bytes (why?) */ if (s->f_code != 0x20) { uint32_t *src = (uint32_t *)(buf + 4); if (buf_size < 36) return AVERROR_INVALIDDATA; for (i = 0; i < 4; i++) src[i] = ((src[i] << 16) | (src[i] >> 16)) ^ src[7 - i]; } result = svq1_decode_frame_header(&s->gb, s); if (result != 0) { av_dlog(s->avctx, "Error in svq1_decode_frame_header %i\n", result); return result; } avcodec_set_dimensions(avctx, s->width, s->height); /* FIXME: This avoids some confusion for "B frames" without 2 references. * This should be removed after libavcodec can handle more flexible * picture types & ordering */ if (s->pict_type == AV_PICTURE_TYPE_B && s->last_picture_ptr == NULL) return buf_size; if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) return buf_size; if ((result = ff_MPV_frame_start(s, avctx)) < 0) return result; pmv = av_malloc((FFALIGN(s->width, 16) / 8 + 3) * sizeof(*pmv)); if (!pmv) return AVERROR(ENOMEM); /* decode y, u and v components */ for (i = 0; i < 3; i++) { int linesize; if (i == 0) { width = FFALIGN(s->width, 16); height = FFALIGN(s->height, 16); linesize = s->linesize; } else { if (s->flags & CODEC_FLAG_GRAY) break; width = FFALIGN(s->width / 4, 16); height = FFALIGN(s->height / 4, 16); linesize = s->uvlinesize; } current = s->current_picture.f.data[i]; if (s->pict_type == AV_PICTURE_TYPE_B) previous = s->next_picture.f.data[i]; else previous = s->last_picture.f.data[i]; if (s->pict_type == AV_PICTURE_TYPE_I) { /* keyframe */ for (y = 0; y < height; y += 16) { for (x = 0; x < width; x += 16) { result = svq1_decode_block_intra(&s->gb, &current[x], linesize); if (result != 0) { av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n", result); goto err; } } current += 16 * linesize; } } else { /* delta frame */ memset(pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv)); for (y = 0; y < height; y += 16) { for (x = 0; x < width; x += 16) { result = svq1_decode_delta_block(s, &s->gb, &current[x], previous, linesize, pmv, x, y); if (result != 0) { av_dlog(s->avctx, "Error in svq1_decode_delta_block %i\n", result); goto err; } } pmv[0].x = pmv[0].y = 0; current += 16 * linesize; } } } *pict = s->current_picture.f; ff_MPV_frame_end(s); *data_size = sizeof(AVFrame); result = buf_size; err: av_free(pmv); return result; }
25,778
qemu
5839e53bbc0fec56021d758aab7610df421ed8c8
1
static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) { BDRVSheepdogState *s = bs->opaque; BDRVSheepdogState *old_s; char tag[SD_MAX_VDI_TAG_LEN]; uint32_t snapid = 0; int ret = 0; old_s = g_malloc(sizeof(BDRVSheepdogState)); memcpy(old_s, s, sizeof(BDRVSheepdogState)); snapid = strtoul(snapshot_id, NULL, 10); if (snapid) { tag[0] = 0; } else { pstrcpy(tag, sizeof(tag), snapshot_id); } ret = reload_inode(s, snapid, tag); if (ret) { goto out; } ret = sd_create_branch(s); if (ret) { goto out; } g_free(old_s); return 0; out: /* recover bdrv_sd_state */ memcpy(s, old_s, sizeof(BDRVSheepdogState)); g_free(old_s); error_report("failed to open. recover old bdrv_sd_state."); return ret; }
25,779
FFmpeg
a443a2530d00b7019269202ac0f5ca8ba0a021c7
1
static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) { RMContext *rm = s->priv_data; AVStream *st; ByteIOContext *pb = &s->pb; unsigned int tag, v; int tag_size, size, codec_data_size, i; int64_t codec_pos; unsigned int h263_hack_version, start_time, duration; char buf[128]; int flags = 0; tag = get_le32(pb); if (tag == MKTAG('.', 'r', 'a', 0xfd)) { /* very old .ra format */ return rm_read_header_old(s, ap); } else if (tag != MKTAG('.', 'R', 'M', 'F')) { return AVERROR_IO; get_be32(pb); /* header size */ get_be16(pb); get_be32(pb); get_be32(pb); /* number of headers */ for(;;) { if (url_feof(pb)) goto fail; tag = get_le32(pb); tag_size = get_be32(pb); get_be16(pb); #if 0 printf("tag=%c%c%c%c (%08x) size=%d\n", (tag) & 0xff, (tag >> 8) & 0xff, (tag >> 16) & 0xff, (tag >> 24) & 0xff, tag, tag_size); #endif if (tag_size < 10 && tag != MKTAG('D', 'A', 'T', 'A')) goto fail; switch(tag) { case MKTAG('P', 'R', 'O', 'P'): /* file header */ get_be32(pb); /* max bit rate */ get_be32(pb); /* avg bit rate */ get_be32(pb); /* max packet size */ get_be32(pb); /* avg packet size */ get_be32(pb); /* nb packets */ get_be32(pb); /* duration */ get_be32(pb); /* preroll */ get_be32(pb); /* index offset */ get_be32(pb); /* data offset */ get_be16(pb); /* nb streams */ flags = get_be16(pb); /* flags */ break; case MKTAG('C', 'O', 'N', 'T'): get_str(pb, s->title, sizeof(s->title)); get_str(pb, s->author, sizeof(s->author)); get_str(pb, s->copyright, sizeof(s->copyright)); get_str(pb, s->comment, sizeof(s->comment)); break; case MKTAG('M', 'D', 'P', 'R'): st = av_new_stream(s, 0); if (!st) goto fail; st->id = get_be16(pb); get_be32(pb); /* max bit rate */ st->codec->bit_rate = get_be32(pb); /* bit rate */ get_be32(pb); /* max packet size */ get_be32(pb); /* avg packet size */ start_time = get_be32(pb); /* start time */ get_be32(pb); /* preroll */ duration = get_be32(pb); /* duration */ st->start_time = start_time; st->duration = duration; get_str8(pb, buf, sizeof(buf)); /* desc */ get_str8(pb, buf, sizeof(buf)); /* mimetype */ codec_data_size = get_be32(pb); codec_pos = url_ftell(pb); st->codec->codec_type = CODEC_TYPE_DATA; av_set_pts_info(st, 64, 1, 1000); v = get_be32(pb); if (v == MKTAG(0xfd, 'a', 'r', '.')) { /* ra type header */ rm_read_audio_stream_info(s, st, 0); } else { int fps, fps2; if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) { fail1: av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n"); goto skip; st->codec->codec_tag = get_le32(pb); // av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0')); if ( st->codec->codec_tag != MKTAG('R', 'V', '1', '0') && st->codec->codec_tag != MKTAG('R', 'V', '2', '0') && st->codec->codec_tag != MKTAG('R', 'V', '3', '0') && st->codec->codec_tag != MKTAG('R', 'V', '4', '0')) goto fail1; st->codec->width = get_be16(pb); st->codec->height = get_be16(pb); st->codec->time_base.num= 1; fps= get_be16(pb); st->codec->codec_type = CODEC_TYPE_VIDEO; get_be32(pb); fps2= get_be16(pb); get_be16(pb); st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); get_buffer(pb, st->codec->extradata, st->codec->extradata_size); // av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2); st->codec->time_base.den = fps * st->codec->time_base.num; /* modification of h263 codec version (!) */ #ifdef WORDS_BIGENDIAN h263_hack_version = ((uint32_t*)st->codec->extradata)[1]; #else h263_hack_version = bswap_32(((uint32_t*)st->codec->extradata)[1]); #endif st->codec->sub_id = h263_hack_version; switch((h263_hack_version>>28)){ case 1: st->codec->codec_id = CODEC_ID_RV10; break; case 2: st->codec->codec_id = CODEC_ID_RV20; break; case 3: st->codec->codec_id = CODEC_ID_RV30; break; case 4: st->codec->codec_id = CODEC_ID_RV40; break; default: goto fail1; skip: /* skip codec info */ size = url_ftell(pb) - codec_pos; url_fskip(pb, codec_data_size - size); break; case MKTAG('D', 'A', 'T', 'A'): goto header_end; default: /* unknown tag: skip it */ url_fskip(pb, tag_size - 10); break; header_end: rm->nb_packets = get_be32(pb); /* number of packets */ if (!rm->nb_packets && (flags & 4)) rm->nb_packets = 3600 * 25; get_be32(pb); /* next data header */ return 0; fail: for(i=0;i<s->nb_streams;i++) { av_free(s->streams[i]); return AVERROR_IO;
25,780
qemu
86d1bd70987cd11d85d01f52aa5824c63d910471
1
static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVParallelsState *s = bs->opaque; uint32_t idx, to_allocate, i; int64_t pos, space; pos = block_status(s, sector_num, nb_sectors, pnum); if (pos > 0) { return pos; } idx = sector_num / s->tracks; if (idx >= s->bat_size) { return -EINVAL; } to_allocate = DIV_ROUND_UP(sector_num + *pnum, s->tracks) - idx; space = to_allocate * s->tracks; if (s->data_end + space > bdrv_getlength(bs->file->bs) >> BDRV_SECTOR_BITS) { int ret; space += s->prealloc_size; if (s->prealloc_mode == PRL_PREALLOC_MODE_FALLOCATE) { ret = bdrv_pwrite_zeroes(bs->file, s->data_end << BDRV_SECTOR_BITS, space << BDRV_SECTOR_BITS, 0); } else { ret = bdrv_truncate(bs->file, (s->data_end + space) << BDRV_SECTOR_BITS); } if (ret < 0) { return ret; } } for (i = 0; i < to_allocate; i++) { s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier); s->data_end += s->tracks; bitmap_set(s->bat_dirty_bmap, bat_entry_off(idx + i) / s->bat_dirty_block, 1); } return bat2sect(s, idx) + sector_num % s->tracks; }
25,781
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
1
static void send_scsi_cdb_read10(QPCIDevice *dev, void *ide_base, uint64_t lba, int nblocks) { Read10CDB pkt = { .padding = 0 }; int i; g_assert_cmpint(lba, <=, UINT32_MAX); g_assert_cmpint(nblocks, <=, UINT16_MAX); g_assert_cmpint(nblocks, >=, 0); /* Construct SCSI CDB packet */ pkt.opcode = 0x28; pkt.lba = cpu_to_be32(lba); pkt.nblocks = cpu_to_be16(nblocks); /* Send Packet */ for (i = 0; i < sizeof(Read10CDB)/2; i++) { qpci_io_writew(dev, ide_base + reg_data, le16_to_cpu(((uint16_t *)&pkt)[i])); } }
25,783
FFmpeg
cba92a2226151abf0e3c24ed594e127203d485b8
1
static int vobsub_read_header(AVFormatContext *s) { int i, ret = 0, header_parsed = 0, langidx = 0; MpegDemuxContext *vobsub = s->priv_data; char *sub_name = NULL; size_t fname_len; char *ext, *header_str; AVBPrint header; int64_t delay = 0; AVStream *st = NULL; sub_name = av_strdup(s->filename); fname_len = strlen(sub_name); ext = sub_name - 3 + fname_len; if (fname_len < 4 || *(ext - 1) != '.') { av_log(s, AV_LOG_ERROR, "The input index filename is too short " "to guess the associated .SUB file\n"); ret = AVERROR_INVALIDDATA; goto end; } memcpy(ext, !strncmp(ext, "IDX", 3) ? "SUB" : "sub", 3); av_log(s, AV_LOG_VERBOSE, "IDX/SUB: %s -> %s\n", s->filename, sub_name); ret = avformat_open_input(&vobsub->sub_ctx, sub_name, &ff_mpegps_demuxer, NULL); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Unable to open %s as MPEG subtitles\n", sub_name); goto end; } av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED); while (!url_feof(s->pb)) { char line[2048]; int len = ff_get_line(s->pb, line, sizeof(line)); if (!len) break; line[strcspn(line, "\r\n")] = 0; if (!strncmp(line, "id:", 3)) { int n, stream_id = 0; char id[64] = {0}; n = sscanf(line, "id: %63[^,], index: %u", id, &stream_id); if (n != 2) { av_log(s, AV_LOG_WARNING, "Unable to parse index line '%s', " "assuming 'id: und, index: 0'\n", line); strcpy(id, "und"); stream_id = 0; } if (stream_id >= FF_ARRAY_ELEMS(vobsub->q)) { av_log(s, AV_LOG_ERROR, "Maximum number of subtitles streams reached\n"); ret = AVERROR(EINVAL); goto end; } st = avformat_new_stream(s, NULL); if (!st) { ret = AVERROR(ENOMEM); goto end; } st->id = stream_id; st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codec->codec_id = AV_CODEC_ID_DVD_SUBTITLE; avpriv_set_pts_info(st, 64, 1, 1000); av_dict_set(&st->metadata, "language", id, 0); av_log(s, AV_LOG_DEBUG, "IDX stream[%d] id=%s\n", stream_id, id); header_parsed = 1; } else if (st && !strncmp(line, "timestamp:", 10)) { AVPacket *sub; int hh, mm, ss, ms; int64_t pos, timestamp; const char *p = line + 10; if (!s->nb_streams) { av_log(s, AV_LOG_ERROR, "Timestamp declared before any stream\n"); ret = AVERROR_INVALIDDATA; goto end; } if (sscanf(p, "%02d:%02d:%02d:%03d, filepos: %"SCNx64, &hh, &mm, &ss, &ms, &pos) != 5) { av_log(s, AV_LOG_ERROR, "Unable to parse timestamp line '%s', " "abort parsing\n", line); break; } timestamp = (hh*3600LL + mm*60LL + ss) * 1000LL + ms + delay; timestamp = av_rescale_q(timestamp, av_make_q(1, 1000), st->time_base); sub = ff_subtitles_queue_insert(&vobsub->q[s->nb_streams - 1], "", 0, 0); if (!sub) { ret = AVERROR(ENOMEM); goto end; } sub->pos = pos; sub->pts = timestamp; sub->stream_index = s->nb_streams - 1; } else if (st && !strncmp(line, "alt:", 4)) { const char *p = line + 4; while (*p == ' ') p++; av_dict_set(&st->metadata, "title", p, 0); av_log(s, AV_LOG_DEBUG, "IDX stream[%d] name=%s\n", st->id, p); header_parsed = 1; } else if (!strncmp(line, "delay:", 6)) { int sign = 1, hh = 0, mm = 0, ss = 0, ms = 0; const char *p = line + 6; while (*p == ' ') p++; if (*p == '-' || *p == '+') { sign = *p == '-' ? -1 : 1; p++; } sscanf(p, "%d:%d:%d:%d", &hh, &mm, &ss, &ms); delay = ((hh*3600LL + mm*60LL + ss) * 1000LL + ms) * sign; } else if (!strncmp(line, "langidx:", 8)) { const char *p = line + 8; if (sscanf(p, "%d", &langidx) != 1) av_log(s, AV_LOG_ERROR, "Invalid langidx specified\n"); } else if (!header_parsed) { if (line[0] && line[0] != '#') av_bprintf(&header, "%s\n", line); } } if (langidx < s->nb_streams) s->streams[langidx]->disposition |= AV_DISPOSITION_DEFAULT; for (i = 0; i < s->nb_streams; i++) { vobsub->q[i].sort = SUB_SORT_POS_TS; ff_subtitles_queue_finalize(&vobsub->q[i]); } if (!av_bprint_is_complete(&header)) { av_bprint_finalize(&header, NULL); ret = AVERROR(ENOMEM); goto end; } av_bprint_finalize(&header, &header_str); for (i = 0; i < s->nb_streams; i++) { AVStream *sub_st = s->streams[i]; sub_st->codec->extradata = av_strdup(header_str); sub_st->codec->extradata_size = header.len; } av_free(header_str); end: av_free(sub_name); return ret; }
25,784
qemu
14b6160099f0caf5dc9d62e637b007bc5d719a96
1
QBool *qobject_to_qbool(const QObject *obj) { if (qobject_type(obj) != QTYPE_QBOOL) return NULL; return container_of(obj, QBool, base); }
25,786
FFmpeg
d5028f61e44b7607b6a547f218f7d85217490a5b
1
static av_always_inline int mvd_decode(HEVCContext *s) { int ret = 2; int k = 1; while (k < CABAC_MAX_BIN && get_cabac_bypass(&s->HEVClc->cc)) { ret += 1 << k; k++; } if (k == CABAC_MAX_BIN) av_log(s->avctx, AV_LOG_ERROR, "CABAC_MAX_BIN : %d\n", k); while (k--) ret += get_cabac_bypass(&s->HEVClc->cc) << k; return get_cabac_bypass_sign(&s->HEVClc->cc, -ret); }
25,788
qemu
77319f22635e3f0ef86730503b4d18dd9a833529
1
static int handle_hypercall(S390CPU *cpu, struct kvm_run *run) { CPUS390XState *env = &cpu->env; cpu_synchronize_state(CPU(cpu)); env->regs[2] = s390_virtio_hypercall(env); return 0; }
25,789
FFmpeg
01f0e6a0c9270f1d5bef08459a6f167cf55e0596
1
av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v) { MpegEncContext *s = &v->s; int i; int mb_height = FFALIGN(s->mb_height, 2); /* Allocate mb bitplanes */ v->mv_type_mb_plane = av_malloc (s->mb_stride * mb_height); v->direct_mb_plane = av_malloc (s->mb_stride * mb_height); v->forward_mb_plane = av_malloc (s->mb_stride * mb_height); v->fieldtx_plane = av_mallocz(s->mb_stride * mb_height); v->acpred_plane = av_malloc (s->mb_stride * mb_height); v->over_flags_plane = av_malloc (s->mb_stride * mb_height); v->n_allocated_blks = s->mb_width + 2; v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks); v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride); v->cbp = v->cbp_base + s->mb_stride; v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 2 * s->mb_stride); v->ttblk = v->ttblk_base + s->mb_stride; v->is_intra_base = av_mallocz(sizeof(v->is_intra_base[0]) * 2 * s->mb_stride); v->is_intra = v->is_intra_base + s->mb_stride; v->luma_mv_base = av_malloc(sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride); v->luma_mv = v->luma_mv_base + s->mb_stride; /* allocate block type info in that way so it could be used with s->block_index[] */ v->mb_type_base = av_malloc(s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2); v->mb_type[0] = v->mb_type_base + s->b8_stride + 1; v->mb_type[1] = v->mb_type_base + s->b8_stride * (mb_height * 2 + 1) + s->mb_stride + 1; v->mb_type[2] = v->mb_type[1] + s->mb_stride * (mb_height + 1); /* allocate memory to store block level MV info */ v->blk_mv_type_base = av_mallocz( s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2); v->blk_mv_type = v->blk_mv_type_base + s->b8_stride + 1; v->mv_f_base = av_mallocz(2 * (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2)); v->mv_f[0] = v->mv_f_base + s->b8_stride + 1; v->mv_f[1] = v->mv_f[0] + (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2); v->mv_f_next_base = av_mallocz(2 * (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2)); v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1; v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2); ff_intrax8_common_init(&v->x8,s); if (s->avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || s->avctx->codec_id == AV_CODEC_ID_VC1IMAGE) { for (i = 0; i < 4; i++) if (!(v->sr_rows[i >> 1][i & 1] = av_malloc(v->output_width))) return -1; } if (!v->mv_type_mb_plane || !v->direct_mb_plane || !v->acpred_plane || !v->over_flags_plane || !v->block || !v->cbp_base || !v->ttblk_base || !v->is_intra_base || !v->luma_mv_base || !v->mb_type_base) { goto error; } return 0; error: ff_vc1_decode_end(s->avctx); return AVERROR(ENOMEM); }
25,790
qemu
18e5eec4db96a00907eb588a2b803401637c7f67
1
static int vapic_prepare(VAPICROMState *s) { vapic_map_rom_writable(s); if (patch_hypercalls(s) < 0) { return -1; } vapic_enable_tpr_reporting(true); return 0; }
25,791
qemu
955f5c7ba127746345a3d43b4d7c885ca159ae6b
1
void ahci_uninit(AHCIState *s) { int i, j; for (i = 0; i < s->ports; i++) { AHCIDevice *ad = &s->dev[i]; for (j = 0; j < 2; j++) { IDEState *s = &ad->port.ifs[j]; ide_exit(s); } } g_free(s->dev); }
25,792
FFmpeg
efd6b80b402a54923f007378a7dc5397676a8f3a
1
int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size; size = RAW_PACKET_SIZE; if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM); pkt->pos= avio_tell(s->pb); pkt->stream_index = 0; ret = ffio_read_partial(s->pb, pkt->data, size); if (ret < 0) { av_free_packet(pkt); return ret; } pkt->size = ret; return ret; }
25,793
FFmpeg
b6ee25e300420a3c98b78a1c2e983250ff065038
1
static inline struct rgbvec interp_tetrahedral(const LUT3DContext *lut3d, const struct rgbvec *s) { const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)}; const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)]; const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)]; const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)]; const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)]; const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)]; const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)]; const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)]; const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)]; struct rgbvec c; if (d.r > d.g) { if (d.g > d.b) { c.r = (1-d.r) * c000.r + (d.r-d.g) * c100.r + (d.g-d.b) * c110.r + (d.b) * c111.r; c.g = (1-d.r) * c000.g + (d.r-d.g) * c100.g + (d.g-d.b) * c110.g + (d.b) * c111.g; c.b = (1-d.r) * c000.b + (d.r-d.g) * c100.b + (d.g-d.b) * c110.b + (d.b) * c111.b; } else if (d.r > d.b) { c.r = (1-d.r) * c000.r + (d.r-d.b) * c100.r + (d.b-d.g) * c101.r + (d.g) * c111.r; c.g = (1-d.r) * c000.g + (d.r-d.b) * c100.g + (d.b-d.g) * c101.g + (d.g) * c111.g; c.b = (1-d.r) * c000.b + (d.r-d.b) * c100.b + (d.b-d.g) * c101.b + (d.g) * c111.b; } else { c.r = (1-d.b) * c000.r + (d.b-d.r) * c001.r + (d.r-d.g) * c101.r + (d.g) * c111.r; c.g = (1-d.b) * c000.g + (d.b-d.r) * c001.g + (d.r-d.g) * c101.g + (d.g) * c111.g; c.b = (1-d.b) * c000.b + (d.b-d.r) * c001.b + (d.r-d.g) * c101.b + (d.g) * c111.b; } } else { if (d.b > d.g) { c.r = (1-d.b) * c000.r + (d.b-d.g) * c001.r + (d.g-d.r) * c011.r + (d.r) * c111.r; c.g = (1-d.b) * c000.g + (d.b-d.g) * c001.g + (d.g-d.r) * c011.g + (d.r) * c111.g; c.b = (1-d.b) * c000.b + (d.b-d.g) * c001.b + (d.g-d.r) * c011.b + (d.r) * c111.b; } else if (d.b > d.r) { c.r = (1-d.g) * c000.r + (d.g-d.b) * c010.r + (d.b-d.r) * c011.r + (d.r) * c111.r; c.g = (1-d.g) * c000.g + (d.g-d.b) * c010.g + (d.b-d.r) * c011.g + (d.r) * c111.g; c.b = (1-d.g) * c000.b + (d.g-d.b) * c010.b + (d.b-d.r) * c011.b + (d.r) * c111.b; } else { c.r = (1-d.g) * c000.r + (d.g-d.r) * c010.r + (d.r-d.b) * c110.r + (d.b) * c111.r; c.g = (1-d.g) * c000.g + (d.g-d.r) * c010.g + (d.r-d.b) * c110.g + (d.b) * c111.g; c.b = (1-d.g) * c000.b + (d.g-d.r) * c010.b + (d.r-d.b) * c110.b + (d.b) * c111.b; } } return c; }
25,794
FFmpeg
0d021cc8b30a6f81c27fbeca7f99f1ee7a20acf8
0
static av_cold int nvenc_setup_device(AVCodecContext *avctx) { NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; CUresult cu_res; CUcontext cu_context_curr; switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->init_encode_params.encodeGUID = NV_ENC_CODEC_H264_GUID; break; case AV_CODEC_ID_HEVC: ctx->init_encode_params.encodeGUID = NV_ENC_CODEC_HEVC_GUID; break; default: return AVERROR_BUG; } ctx->data_pix_fmt = avctx->pix_fmt; #if CONFIG_CUDA if (avctx->pix_fmt == AV_PIX_FMT_CUDA) { AVHWFramesContext *frames_ctx; AVCUDADeviceContext *device_hwctx; if (!avctx->hw_frames_ctx) { av_log(avctx, AV_LOG_ERROR, "hw_frames_ctx must be set when using GPU frames as input\n"); return AVERROR(EINVAL); } frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; device_hwctx = frames_ctx->device_ctx->hwctx; ctx->cu_context = device_hwctx->cuda_ctx; ctx->data_pix_fmt = frames_ctx->sw_format; return 0; } #endif if (ctx->gpu >= dl_fn->nvenc_device_count) { av_log(avctx, AV_LOG_FATAL, "Requested GPU %d, but only %d GPUs are available!\n", ctx->gpu, dl_fn->nvenc_device_count); return AVERROR(EINVAL); } ctx->cu_context = NULL; cu_res = dl_fn->cu_ctx_create(&ctx->cu_context_internal, 4, dl_fn->nvenc_devices[ctx->gpu]); // CU_CTX_SCHED_BLOCKING_SYNC=4, avoid CPU spins if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed creating CUDA context for NVENC: 0x%x\n", (int)cu_res); return AVERROR_EXTERNAL; } cu_res = dl_fn->cu_ctx_pop_current(&cu_context_curr); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed popping CUDA context: 0x%x\n", (int)cu_res); return AVERROR_EXTERNAL; } ctx->cu_context = ctx->cu_context_internal; return 0; }
25,795
FFmpeg
ca488ad480360dfafcb5766f7bfbb567a0638979
1
static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c) { GetBitContext *gb = &ctx->gb; ALSChannelData *current = cd; unsigned int channels = ctx->avctx->channels; int entries = 0; while (entries < channels && !(current->stop_flag = get_bits1(gb))) { current->master_channel = get_bits_long(gb, av_ceil_log2(channels)); if (current->master_channel >= channels) { av_log(ctx->avctx, AV_LOG_ERROR, "Invalid master channel!\n"); return -1; } if (current->master_channel != c) { current->time_diff_flag = get_bits1(gb); current->weighting[0] = als_weighting(gb, 1, 16); current->weighting[1] = als_weighting(gb, 2, 14); current->weighting[2] = als_weighting(gb, 1, 16); if (current->time_diff_flag) { current->weighting[3] = als_weighting(gb, 1, 16); current->weighting[4] = als_weighting(gb, 1, 16); current->weighting[5] = als_weighting(gb, 1, 16); current->time_diff_sign = get_bits1(gb); current->time_diff_index = get_bits(gb, ctx->ltp_lag_length - 3) + 3; } } current++; entries++; } if (entries == channels) { av_log(ctx->avctx, AV_LOG_ERROR, "Damaged channel data!\n"); return -1; } align_get_bits(gb); return 0; }
25,796
qemu
e95205e1f9cd2c4262b7a7b1c992a94512c86d0e
1
static void cpu_unregister_map_client(void *_client) { MapClient *client = (MapClient *)_client; QLIST_REMOVE(client, link); g_free(client); }
25,797
FFmpeg
ea1e630c47e70672a7933c048090601ce09c8195
1
static int rv34_decoder_alloc(RV34DecContext *r) { r->intra_types_stride = r->s.mb_width * 4 + 4; r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma)); r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma)); r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs)); r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type)); if (!(r->cbp_chroma && r->cbp_luma && r->deblock_coefs && r->intra_types_hist && r->mb_type)) { rv34_decoder_free(r); return AVERROR(ENOMEM); } r->intra_types = r->intra_types_hist + r->intra_types_stride * 4; return 0; }
25,798
FFmpeg
de41d5372faa4ad7ad439e71975fc6f4ea0c0efc
1
static int dvbsub_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { DVBSubParseContext *pc = s->priv_data; uint8_t *p, *p_end; int i, len, buf_pos = 0; av_dlog(avctx, "DVB parse packet pts=%"PRIx64", lpts=%"PRIx64", cpts=%"PRIx64":\n", s->pts, s->last_pts, s->cur_frame_pts[s->cur_frame_start_index]); for (i=0; i < buf_size; i++) { av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) av_dlog(avctx, "\n"); } if (i % 16 != 0) av_dlog(avctx, "\n"); *poutbuf = NULL; *poutbuf_size = 0; s->fetch_timestamp = 1; if (s->last_pts != s->pts && s->pts != AV_NOPTS_VALUE) /* Start of a new packet */ { if (pc->packet_index != pc->packet_start) { av_dlog(avctx, "Discarding %d bytes\n", pc->packet_index - pc->packet_start); } pc->packet_start = 0; pc->packet_index = 0; if (buf_size < 2 || buf[0] != 0x20 || buf[1] != 0x00) { av_dlog(avctx, "Bad packet header\n"); return -1; } buf_pos = 2; pc->in_packet = 1; } else { if (pc->packet_start != 0) { if (pc->packet_index != pc->packet_start) { memmove(pc->packet_buf, pc->packet_buf + pc->packet_start, pc->packet_index - pc->packet_start); pc->packet_index -= pc->packet_start; pc->packet_start = 0; } else { pc->packet_start = 0; pc->packet_index = 0; } } } if (buf_size - buf_pos + pc->packet_index > PARSE_BUF_SIZE) return -1; /* if not currently in a packet, discard data */ if (pc->in_packet == 0) return buf_size; memcpy(pc->packet_buf + pc->packet_index, buf + buf_pos, buf_size - buf_pos); pc->packet_index += buf_size - buf_pos; p = pc->packet_buf; p_end = pc->packet_buf + pc->packet_index; while (p < p_end) { if (*p == 0x0f) { if (p + 6 <= p_end) { len = AV_RB16(p + 4); if (p + len + 6 <= p_end) { *poutbuf_size += len + 6; p += len + 6; } else break; } else break; } else if (*p == 0xff) { if (p + 1 < p_end) { av_dlog(avctx, "Junk at end of packet\n"); } pc->packet_index = p - pc->packet_buf; pc->in_packet = 0; break; } else { av_log(avctx, AV_LOG_ERROR, "Junk in packet\n"); pc->packet_index = p - pc->packet_buf; pc->in_packet = 0; break; } } if (*poutbuf_size > 0) { *poutbuf = pc->packet_buf; pc->packet_start = *poutbuf_size; } if (s->pts == AV_NOPTS_VALUE) s->pts = s->last_pts; return buf_size; }
25,799
FFmpeg
0e0f6bd4a5796f4f668092d7925a31b9b30fedd4
1
static void id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags, ID3v2ExtraMeta **extra_meta) { int isv34, unsync; unsigned tlen; char tag[5]; int64_t next, end = avio_tell(s->pb) + len; int taghdrlen; const char *reason = NULL; AVIOContext pb; AVIOContext *pbx; unsigned char *buffer = NULL; int buffer_size = 0; const ID3v2EMFunc *extra_func = NULL; unsigned char *uncompressed_buffer = NULL; int uncompressed_buffer_size = 0; av_log(s, AV_LOG_DEBUG, "id3v2 ver:%d flags:%02X len:%d\n", version, flags, len); switch (version) { case 2: if (flags & 0x40) { reason = "compression"; goto error; } isv34 = 0; taghdrlen = 6; break; case 3: case 4: isv34 = 1; taghdrlen = 10; break; default: reason = "version"; goto error; } unsync = flags & 0x80; if (isv34 && flags & 0x40) { /* Extended header present, just skip over it */ int extlen = get_size(s->pb, 4); if (version == 4) /* In v2.4 the length includes the length field we just read. */ extlen -= 4; if (extlen < 0) { reason = "invalid extended header length"; goto error; } avio_skip(s->pb, extlen); len -= extlen + 4; if (len < 0) { reason = "extended header too long."; goto error; } } while (len >= taghdrlen) { unsigned int tflags = 0; int tunsync = 0; int tcomp = 0; int tencr = 0; unsigned long dlen; if (isv34) { avio_read(s->pb, tag, 4); tag[4] = 0; if (version == 3) { tlen = avio_rb32(s->pb); } else tlen = get_size(s->pb, 4); tflags = avio_rb16(s->pb); tunsync = tflags & ID3v2_FLAG_UNSYNCH; } else { avio_read(s->pb, tag, 3); tag[3] = 0; tlen = avio_rb24(s->pb); } if (tlen > (1<<28)) break; len -= taghdrlen + tlen; if (len < 0) break; next = avio_tell(s->pb) + tlen; if (!tlen) { if (tag[0]) av_log(s, AV_LOG_DEBUG, "Invalid empty frame %s, skipping.\n", tag); continue; } if (tflags & ID3v2_FLAG_DATALEN) { if (tlen < 4) break; dlen = avio_rb32(s->pb); tlen -= 4; } else dlen = tlen; tcomp = tflags & ID3v2_FLAG_COMPRESSION; tencr = tflags & ID3v2_FLAG_ENCRYPTION; /* skip encrypted tags and, if no zlib, compressed tags */ if (tencr || (!CONFIG_ZLIB && tcomp)) { const char *type; if (!tcomp) type = "encrypted"; else if (!tencr) type = "compressed"; else type = "encrypted and compressed"; av_log(s, AV_LOG_WARNING, "Skipping %s ID3v2 frame %s.\n", type, tag); avio_skip(s->pb, tlen); /* check for text tag or supported special meta tag */ } else if (tag[0] == 'T' || (extra_meta && (extra_func = get_extra_meta_func(tag, isv34)))) { pbx = s->pb; if (unsync || tunsync || tcomp) { av_fast_malloc(&buffer, &buffer_size, tlen); if (!buffer) { av_log(s, AV_LOG_ERROR, "Failed to alloc %d bytes\n", tlen); goto seek; } } if (unsync || tunsync) { int64_t end = avio_tell(s->pb) + tlen; uint8_t *b; b = buffer; while (avio_tell(s->pb) < end && b - buffer < tlen && !s->pb->eof_reached) { *b++ = avio_r8(s->pb); if (*(b - 1) == 0xff && avio_tell(s->pb) < end - 1 && b - buffer < tlen && !s->pb->eof_reached ) { uint8_t val = avio_r8(s->pb); *b++ = val ? val : avio_r8(s->pb); } } ffio_init_context(&pb, buffer, b - buffer, 0, NULL, NULL, NULL, NULL); tlen = b - buffer; pbx = &pb; // read from sync buffer } #if CONFIG_ZLIB if (tcomp) { int err; av_log(s, AV_LOG_DEBUG, "Compresssed frame %s tlen=%d dlen=%ld\n", tag, tlen, dlen); av_fast_malloc(&uncompressed_buffer, &uncompressed_buffer_size, dlen); if (!uncompressed_buffer) { av_log(s, AV_LOG_ERROR, "Failed to alloc %ld bytes\n", dlen); goto seek; } if (!(unsync || tunsync)) { err = avio_read(s->pb, buffer, tlen); if (err < 0) { av_log(s, AV_LOG_ERROR, "Failed to read compressed tag\n"); goto seek; } tlen = err; } err = uncompress(uncompressed_buffer, &dlen, buffer, tlen); if (err != Z_OK) { av_log(s, AV_LOG_ERROR, "Failed to uncompress tag: %d\n", err); goto seek; } ffio_init_context(&pb, uncompressed_buffer, dlen, 0, NULL, NULL, NULL, NULL); tlen = dlen; pbx = &pb; // read from sync buffer } #endif if (tag[0] == 'T') /* parse text tag */ read_ttag(s, pbx, tlen, &s->metadata, tag); else /* parse special meta tag */ extra_func->read(s, pbx, tlen, tag, extra_meta); } else if (!tag[0]) { if (tag[1]) av_log(s, AV_LOG_WARNING, "invalid frame id, assuming padding\n"); avio_skip(s->pb, tlen); break; } /* Skip to end of tag */ seek: avio_seek(s->pb, next, SEEK_SET); } /* Footer preset, always 10 bytes, skip over it */ if (version == 4 && flags & 0x10) end += 10; error: if (reason) av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n", version, reason); avio_seek(s->pb, end, SEEK_SET); av_free(buffer); av_free(uncompressed_buffer); return; }
25,800
FFmpeg
f23dc1e1f9ee3a00db951d3dec7d5bfb0e04dae8
1
static void decode_band_structure(GetBitContext *gbc, int blk, int eac3, int ecpl, int start_subband, int end_subband, const uint8_t *default_band_struct, uint8_t *band_struct, int *num_subbands, int *num_bands, uint8_t *band_sizes) { int subbnd, bnd, n_subbands, n_bands; uint8_t bnd_sz[22]; n_subbands = end_subband - start_subband; /* decode band structure from bitstream or use default */ if (!eac3 || get_bits1(gbc)) { for (subbnd = 0; subbnd < n_subbands - 1; subbnd++) { band_struct[subbnd] = get_bits1(gbc); } } else if (!blk) { memcpy(band_struct, &default_band_struct[start_subband+1], n_subbands-1); } band_struct[n_subbands-1] = 0; /* calculate number of bands and band sizes based on band structure. note that the first 4 subbands in enhanced coupling span only 6 bins instead of 12. */ if (num_bands || band_sizes ) { n_bands = n_subbands; bnd_sz[0] = ecpl ? 6 : 12; for (bnd = 0, subbnd = 1; subbnd < n_subbands; subbnd++) { int subbnd_size = (ecpl && subbnd < 4) ? 6 : 12; if (band_struct[subbnd-1]) { n_bands--; bnd_sz[bnd] += subbnd_size; } else { bnd_sz[++bnd] = subbnd_size; } } } /* set optional output params */ if (num_subbands) *num_subbands = n_subbands; if (num_bands) *num_bands = n_bands; if (band_sizes) memcpy(band_sizes, bnd_sz, n_bands); }
25,801
qemu
08a655be71d0a130a5d9bf7816d096ec31c4f055
1
static void dump_iterate(DumpState *s, Error **errp) { GuestPhysBlock *block; int64_t size; int ret; Error *local_err = NULL; while (1) { block = s->next_block; size = block->target_end - block->target_start; if (s->has_filter) { size -= s->start; if (s->begin + s->length < block->target_end) { size -= block->target_end - (s->begin + s->length); } } write_memory(s, block, s->start, size, &local_err); if (local_err) { error_propagate(errp, local_err); return; } ret = get_next_block(s, block); if (ret == 1) { dump_completed(s); } } }
25,802
qemu
e23a1b33b53d25510320b26d9f154e19c6c99725
1
fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann, target_phys_addr_t mmio_base, DriveInfo **fds) { fdctrl_t *fdctrl; DeviceState *dev; fdctrl_sysbus_t *sys; dev = qdev_create(NULL, "sysbus-fdc"); sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev); fdctrl = &sys->state; fdctrl->dma_chann = dma_chann; /* FIXME */ qdev_prop_set_drive(dev, "driveA", fds[0]); qdev_prop_set_drive(dev, "driveB", fds[1]); if (qdev_init(dev) != 0) return NULL; sysbus_connect_irq(&sys->busdev, 0, irq); sysbus_mmio_map(&sys->busdev, 0, mmio_base); return fdctrl; }
25,803
qemu
9a16c5950d9ce38671a1ac259dcde3e707767922
0
static void uhci_async_complete(USBPort *port, USBPacket *packet) { UHCIAsync *async = container_of(packet, UHCIAsync, packet); UHCIState *s = async->queue->uhci; if (async->isoc) { UHCI_TD td; uint32_t link = async->td; uint32_t int_mask = 0, val; pci_dma_read(&s->dev, link & ~0xf, &td, sizeof(td)); le32_to_cpus(&td.link); le32_to_cpus(&td.ctrl); le32_to_cpus(&td.token); le32_to_cpus(&td.buffer); uhci_async_unlink(async); uhci_complete_td(s, &td, async, &int_mask); s->pending_int_mask |= int_mask; /* update the status bits of the TD */ val = cpu_to_le32(td.ctrl); pci_dma_write(&s->dev, (link & ~0xf) + 4, &val, sizeof(val)); uhci_async_free(async); } else { async->done = 1; uhci_process_frame(s); } }
25,804
qemu
c4d9d19645a484298a67e9021060bc7c2b081d0f
0
int coroutine_fn thread_pool_submit_co(ThreadPoolFunc *func, void *arg) { ThreadPoolCo tpc = { .co = qemu_coroutine_self(), .ret = -EINPROGRESS }; assert(qemu_in_coroutine()); thread_pool_submit_aio(func, arg, thread_pool_co_cb, &tpc); qemu_coroutine_yield(); return tpc.ret; }
25,805
qemu
fff23ee9a5de74ab111b3cea9eec56782e7d7c50
0
static void uhci_process_frame(UHCIState *s) { uint32_t frame_addr, link, old_td_ctrl, val, int_mask; uint32_t curr_qh; int cnt, ret; UHCI_TD td; UHCI_QH qh; QhDb qhdb; frame_addr = s->fl_base_addr + ((s->frnum & 0x3ff) << 2); DPRINTF("uhci: processing frame %d addr 0x%x\n" , s->frnum, frame_addr); cpu_physical_memory_read(frame_addr, (uint8_t *)&link, 4); le32_to_cpus(&link); int_mask = 0; curr_qh = 0; qhdb_reset(&qhdb); for (cnt = FRAME_MAX_LOOPS; is_valid(link) && cnt; cnt--) { if (is_qh(link)) { /* QH */ if (qhdb_insert(&qhdb, link)) { /* * We're going in circles. Which is not a bug because * HCD is allowed to do that as part of the BW management. * In our case though it makes no sense to spin here. Sync transations * are already done, and async completion handler will re-process * the frame when something is ready. */ DPRINTF("uhci: detected loop. qh 0x%x\n", link); break; } cpu_physical_memory_read(link & ~0xf, (uint8_t *) &qh, sizeof(qh)); le32_to_cpus(&qh.link); le32_to_cpus(&qh.el_link); DPRINTF("uhci: QH 0x%x load. link 0x%x elink 0x%x\n", link, qh.link, qh.el_link); if (!is_valid(qh.el_link)) { /* QH w/o elements */ curr_qh = 0; link = qh.link; } else { /* QH with elements */ curr_qh = link; link = qh.el_link; } continue; } /* TD */ cpu_physical_memory_read(link & ~0xf, (uint8_t *) &td, sizeof(td)); le32_to_cpus(&td.link); le32_to_cpus(&td.ctrl); le32_to_cpus(&td.token); le32_to_cpus(&td.buffer); DPRINTF("uhci: TD 0x%x load. link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", link, td.link, td.ctrl, td.token, curr_qh); old_td_ctrl = td.ctrl; ret = uhci_handle_td(s, link, &td, &int_mask); if (old_td_ctrl != td.ctrl) { /* update the status bits of the TD */ val = cpu_to_le32(td.ctrl); cpu_physical_memory_write((link & ~0xf) + 4, (const uint8_t *)&val, sizeof(val)); } if (ret < 0) { /* interrupted frame */ break; } if (ret == 2 || ret == 1) { DPRINTF("uhci: TD 0x%x %s. link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", link, ret == 2 ? "pend" : "skip", td.link, td.ctrl, td.token, curr_qh); link = curr_qh ? qh.link : td.link; continue; } /* completed TD */ DPRINTF("uhci: TD 0x%x done. link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", link, td.link, td.ctrl, td.token, curr_qh); link = td.link; if (curr_qh) { /* update QH element link */ qh.el_link = link; val = cpu_to_le32(qh.el_link); cpu_physical_memory_write((curr_qh & ~0xf) + 4, (const uint8_t *)&val, sizeof(val)); if (!depth_first(link)) { /* done with this QH */ DPRINTF("uhci: QH 0x%x done. link 0x%x elink 0x%x\n", curr_qh, qh.link, qh.el_link); curr_qh = 0; link = qh.link; } } /* go to the next entry */ } s->pending_int_mask |= int_mask; }
25,806
FFmpeg
8ab80707841a73ca7708e1e1aa97f3513fff3d35
0
int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { AVFrame tmp; AVFrame *padded_frame = NULL; int ret; AVPacket user_pkt = *avpkt; int needs_realloc = !user_pkt.data; *got_packet_ptr = 0; if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) { av_free_packet(avpkt); av_init_packet(avpkt); return 0; } /* ensure that extended_data is properly set */ if (frame && !frame->extended_data) { if (av_sample_fmt_is_planar(avctx->sample_fmt) && avctx->channels > AV_NUM_DATA_POINTERS) { av_log(avctx, AV_LOG_ERROR, "Encoding to a planar sample format, " "with more than %d channels, but extended_data is not set.\n", AV_NUM_DATA_POINTERS); return AVERROR(EINVAL); } av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n"); tmp = *frame; tmp.extended_data = tmp.data; frame = &tmp; } /* check for valid frame size */ if (frame) { if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) { if (frame->nb_samples > avctx->frame_size) { av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)\n"); return AVERROR(EINVAL); } } else if (!(avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) { if (frame->nb_samples < avctx->frame_size && !avctx->internal->last_audio_frame) { ret = pad_last_frame(avctx, &padded_frame, frame); if (ret < 0) return ret; frame = padded_frame; avctx->internal->last_audio_frame = 1; } if (frame->nb_samples != avctx->frame_size) { av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) != frame_size (%d) (avcodec_encode_audio2)\n", frame->nb_samples, avctx->frame_size); ret = AVERROR(EINVAL); goto end; } } } ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr); if (!ret) { if (*got_packet_ptr) { if (!(avctx->codec->capabilities & CODEC_CAP_DELAY)) { if (avpkt->pts == AV_NOPTS_VALUE) avpkt->pts = frame->pts; if (!avpkt->duration) avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); } avpkt->dts = avpkt->pts; } else { avpkt->size = 0; } } if (avpkt->data && avpkt->data == avctx->internal->byte_buffer) { needs_realloc = 0; if (user_pkt.data) { if (user_pkt.size >= avpkt->size) { memcpy(user_pkt.data, avpkt->data, avpkt->size); } else { av_log(avctx, AV_LOG_ERROR, "Provided packet is too small, needs to be %d\n", avpkt->size); avpkt->size = user_pkt.size; ret = -1; } avpkt->buf = user_pkt.buf; avpkt->data = user_pkt.data; avpkt->destruct = user_pkt.destruct; } else { if (av_dup_packet(avpkt) < 0) { ret = AVERROR(ENOMEM); } } } if (!ret) { if (needs_realloc && avpkt->data) { ret = av_buffer_realloc(&avpkt->buf, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE); if (ret >= 0) avpkt->data = avpkt->buf->data; } avctx->frame_number++; } if (ret < 0 || !*got_packet_ptr) { av_free_packet(avpkt); av_init_packet(avpkt); goto end; } /* NOTE: if we add any audio encoders which output non-keyframe packets, * this needs to be moved to the encoders, but for now we can do it * here to simplify things */ avpkt->flags |= AV_PKT_FLAG_KEY; end: av_frame_free(&padded_frame); return ret; }
25,807
qemu
51b19ebe4320f3dcd93cea71235c1219318ddfd2
0
static void virtio_input_handle_sts(VirtIODevice *vdev, VirtQueue *vq) { VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(vdev); VirtIOInput *vinput = VIRTIO_INPUT(vdev); virtio_input_event event; VirtQueueElement elem; int len; while (virtqueue_pop(vinput->sts, &elem)) { memset(&event, 0, sizeof(event)); len = iov_to_buf(elem.out_sg, elem.out_num, 0, &event, sizeof(event)); if (vic->handle_status) { vic->handle_status(vinput, &event); } virtqueue_push(vinput->sts, &elem, len); } virtio_notify(vdev, vinput->sts); }
25,808
qemu
3ac4b7c51e3ba181a86983ba2601a595ed8f3b1d
0
void qmp_guest_file_close(int64_t handle, Error **err) { GuestFileHandle *gfh = guest_file_handle_find(handle, err); int ret; slog("guest-file-close called, handle: %ld", handle); if (!gfh) { return; } ret = fclose(gfh->fh); if (ret == -1) { error_set(err, QERR_QGA_COMMAND_FAILED, "fclose() failed"); return; } QTAILQ_REMOVE(&guest_file_state.filehandles, gfh, next); g_free(gfh); }
25,809
qemu
aad15de4275d2fc90acdf6101493dfee4e39b803
0
static int convert_read(ImgConvertState *s, int64_t sector_num, int nb_sectors, uint8_t *buf) { int n; int ret; if (s->status == BLK_ZERO || s->status == BLK_BACKING_FILE) { return 0; } assert(nb_sectors <= s->buf_sectors); while (nb_sectors > 0) { BlockBackend *blk; int64_t bs_sectors; /* In the case of compression with multiple source files, we can get a * nb_sectors that spreads into the next part. So we must be able to * read across multiple BDSes for one convert_read() call. */ convert_select_part(s, sector_num); blk = s->src[s->src_cur]; bs_sectors = s->src_sectors[s->src_cur]; n = MIN(nb_sectors, bs_sectors - (sector_num - s->src_cur_offset)); ret = blk_read(blk, sector_num - s->src_cur_offset, buf, n); if (ret < 0) { return ret; } sector_num += n; nb_sectors -= n; buf += n * BDRV_SECTOR_SIZE; } return 0; }
25,811
qemu
7bd427d801e1e3293a634d3c83beadaa90ffb911
0
static void qemu_announce_self_once(void *opaque) { static int count = SELF_ANNOUNCE_ROUNDS; QEMUTimer *timer = *(QEMUTimer **)opaque; qemu_foreach_nic(qemu_announce_self_iter, NULL); if (--count) { /* delay 50ms, 150ms, 250ms, ... */ qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 50 + (SELF_ANNOUNCE_ROUNDS - count - 1) * 100); } else { qemu_del_timer(timer); qemu_free_timer(timer); } }
25,812
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
0
static int nvme_init(PCIDevice *pci_dev) { NvmeCtrl *n = NVME(pci_dev); NvmeIdCtrl *id = &n->id_ctrl; int i; int64_t bs_size; uint8_t *pci_conf; if (!(n->conf.bs)) { return -1; } bs_size = bdrv_getlength(n->conf.bs); if (bs_size < 0) { return -1; } blkconf_serial(&n->conf, &n->serial); if (!n->serial) { return -1; } pci_conf = pci_dev->config; pci_conf[PCI_INTERRUPT_PIN] = 1; pci_config_set_prog_interface(pci_dev->config, 0x2); pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS); pcie_endpoint_cap_init(&n->parent_obj, 0x80); n->num_namespaces = 1; n->num_queues = 64; n->reg_size = 1 << qemu_fls(0x1004 + 2 * (n->num_queues + 1) * 4); n->ns_size = bs_size / (uint64_t)n->num_namespaces; n->namespaces = g_new0(NvmeNamespace, n->num_namespaces); n->sq = g_new0(NvmeSQueue *, n->num_queues); n->cq = g_new0(NvmeCQueue *, n->num_queues); memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n, "nvme", n->reg_size); pci_register_bar(&n->parent_obj, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, &n->iomem); msix_init_exclusive_bar(&n->parent_obj, n->num_queues, 4); id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID)); id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID)); strpadcpy((char *)id->mn, sizeof(id->mn), "QEMU NVMe Ctrl", ' '); strpadcpy((char *)id->fr, sizeof(id->fr), "1.0", ' '); strpadcpy((char *)id->sn, sizeof(id->sn), n->serial, ' '); id->rab = 6; id->ieee[0] = 0x00; id->ieee[1] = 0x02; id->ieee[2] = 0xb3; id->oacs = cpu_to_le16(0); id->frmw = 7 << 1; id->lpa = 1 << 0; id->sqes = (0x6 << 4) | 0x6; id->cqes = (0x4 << 4) | 0x4; id->nn = cpu_to_le32(n->num_namespaces); id->psd[0].mp = cpu_to_le16(0x9c4); id->psd[0].enlat = cpu_to_le32(0x10); id->psd[0].exlat = cpu_to_le32(0x4); n->bar.cap = 0; NVME_CAP_SET_MQES(n->bar.cap, 0x7ff); NVME_CAP_SET_CQR(n->bar.cap, 1); NVME_CAP_SET_AMS(n->bar.cap, 1); NVME_CAP_SET_TO(n->bar.cap, 0xf); NVME_CAP_SET_CSS(n->bar.cap, 1); n->bar.vs = 0x00010001; n->bar.intmc = n->bar.intms = 0; for (i = 0; i < n->num_namespaces; i++) { NvmeNamespace *ns = &n->namespaces[i]; NvmeIdNs *id_ns = &ns->id_ns; id_ns->nsfeat = 0; id_ns->nlbaf = 0; id_ns->flbas = 0; id_ns->mc = 0; id_ns->dpc = 0; id_ns->dps = 0; id_ns->lbaf[0].ds = BDRV_SECTOR_BITS; id_ns->ncap = id_ns->nuse = id_ns->nsze = cpu_to_le64(n->ns_size >> id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas)].ds); } return 0; }
25,815
qemu
24ce9a20260713e86377cfa78fb8699335759f4f
0
int blk_get_max_transfer_length(BlockBackend *blk) { BlockDriverState *bs = blk_bs(blk); if (bs) { return bs->bl.max_transfer_length; } else { return 0; } }
25,816
qemu
0ac7cc2af500b948510f2481c22e84a57b0a2447
0
START_TEST(qstring_append_chr_test) { int i; QString *qstring; const char *str = "qstring append char unit-test"; qstring = qstring_new(); for (i = 0; str[i]; i++) qstring_append_chr(qstring, str[i]); fail_unless(strcmp(str, qstring_get_str(qstring)) == 0); QDECREF(qstring); }
25,817
FFmpeg
247e658784ead984f96021acb9c95052ba599f26
0
static int ftp_get_line(FTPContext *s, char *line, int line_size) { int ch; char *q = line; int ori_block_flag = s->conn_control_block_flag; for (;;) { ch = ftp_getc(s); if (ch < 0) { s->conn_control_block_flag = ori_block_flag; return ch; } if (ch == '\n') { /* process line */ if (q > line && q[-1] == '\r') q--; *q = '\0'; s->conn_control_block_flag = ori_block_flag; return 0; } else { s->conn_control_block_flag = 0; /* line need to be finished */ if ((q - line) < line_size - 1) *q++ = ch; } } }
25,818
qemu
2e6fc7eb1a4af1b127df5f07b8bb28af891946fa
0
static int raw_co_ioctl(BlockDriverState *bs, unsigned long int req, void *buf) { BDRVRawState *s = bs->opaque; if (s->offset || s->has_size) { return -ENOTSUP; } return bdrv_co_ioctl(bs->file->bs, req, buf); }
25,819
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
0
static void lsi_io_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { LSIState *s = opaque; lsi_reg_writeb(s, addr & 0xff, val); }
25,820
qemu
94c3db85b4cc1d4e078859834a761bcc9d988780
0
void input_type_enum(Visitor *v, int *obj, const char *strings[], const char *kind, const char *name, Error **errp) { int64_t value = 0; char *enum_str; assert(strings); visit_type_str(v, &enum_str, name, errp); if (error_is_set(errp)) { return; } while (strings[value] != NULL) { if (strcmp(strings[value], enum_str) == 0) { break; } value++; } if (strings[value] == NULL) { error_set(errp, QERR_INVALID_PARAMETER, name ? name : "null"); g_free(enum_str); return; } g_free(enum_str); *obj = value; }
25,821
qemu
c19c1578f8a9b894f5e368e35139620a98bf6a69
0
int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info) { CPUState *cpu = ENV_GET_CPU(env); TaskState *ts = cpu->opaque; struct emulated_sigtable *k; struct sigqueue *q, **pq; abi_ulong handler; int queue; trace_user_queue_signal(env, sig); k = &ts->sigtab[sig - 1]; queue = gdb_queuesig (); handler = sigact_table[sig - 1]._sa_handler; if (sig == TARGET_SIGSEGV && sigismember(&ts->signal_mask, SIGSEGV)) { /* Guest has blocked SIGSEGV but we got one anyway. Assume this * is a forced SIGSEGV (ie one the kernel handles via force_sig_info * because it got a real MMU fault). A blocked SIGSEGV in that * situation is treated as if using the default handler. This is * not correct if some other process has randomly sent us a SIGSEGV * via kill(), but that is not easy to distinguish at this point, * so we assume it doesn't happen. */ handler = TARGET_SIG_DFL; } if (!queue && handler == TARGET_SIG_DFL) { if (sig == TARGET_SIGTSTP || sig == TARGET_SIGTTIN || sig == TARGET_SIGTTOU) { kill(getpid(),SIGSTOP); return 0; } else /* default handler : ignore some signal. The other are fatal */ if (sig != TARGET_SIGCHLD && sig != TARGET_SIGURG && sig != TARGET_SIGWINCH && sig != TARGET_SIGCONT) { force_sig(sig); } else { return 0; /* indicate ignored */ } } else if (!queue && handler == TARGET_SIG_IGN) { /* ignore signal */ return 0; } else if (!queue && handler == TARGET_SIG_ERR) { force_sig(sig); } else { pq = &k->first; if (sig < TARGET_SIGRTMIN) { /* if non real time signal, we queue exactly one signal */ if (!k->pending) q = &k->info; else return 0; } else { if (!k->pending) { /* first signal */ q = &k->info; } else { q = alloc_sigqueue(env); if (!q) return -EAGAIN; while (*pq != NULL) pq = &(*pq)->next; } } *pq = q; q->info = *info; q->next = NULL; k->pending = 1; /* signal that a new signal is pending */ atomic_set(&ts->signal_pending, 1); return 1; /* indicates that the signal was queued */ } }
25,822
FFmpeg
5b67307a6898d9b1b1b78034d4f4fa79932d91bf
1
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ int i; int w= s->width; int h= s->height; InternalBuffer *buf; int *picture_number; if(pic->data[0]!=NULL) { av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n"); return -1; } if(s->internal_buffer_count >= INTERNAL_BUFFER_SIZE) { av_log(s, AV_LOG_ERROR, "internal_buffer_count overflow (missing release_buffer?)\n"); return -1; } if(avcodec_check_dimensions(s,w,h)) return -1; if(s->internal_buffer==NULL){ s->internal_buffer= av_mallocz(INTERNAL_BUFFER_SIZE*sizeof(InternalBuffer)); } #if 0 s->internal_buffer= av_fast_realloc( s->internal_buffer, &s->internal_buffer_size, sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/ ); #endif buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num; //FIXME ugly hack (*picture_number)++; if(buf->base[0]){ pic->age= *picture_number - buf->last_pic_num; buf->last_pic_num= *picture_number; }else{ int h_chroma_shift, v_chroma_shift; int pixel_size, size[3]; AVPicture picture; avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); if(!(s->flags&CODEC_FLAG_EMU_EDGE)){ w+= EDGE_WIDTH*2; h+= EDGE_WIDTH*2; } avpicture_fill(&picture, NULL, s->pix_fmt, w, h); pixel_size= picture.linesize[0]*8 / w; //av_log(NULL, AV_LOG_ERROR, "%d %d %d %d\n", (int)picture.data[1], w, h, s->pix_fmt); assert(pixel_size>=1); //FIXME next ensures that linesize= 2^x uvlinesize, thats needed because some MC code assumes it if(pixel_size == 3*8) w= ALIGN(w, STRIDE_ALIGN<<h_chroma_shift); else w= ALIGN(pixel_size*w, STRIDE_ALIGN<<(h_chroma_shift+3)) / pixel_size; size[1] = avpicture_fill(&picture, NULL, s->pix_fmt, w, h); size[0] = picture.linesize[0] * h; size[1] -= size[0]; if(picture.data[2]) size[1]= size[2]= size[1]/2; else size[2]= 0; buf->last_pic_num= -256*256*256*64; memset(buf->base, 0, sizeof(buf->base)); memset(buf->data, 0, sizeof(buf->data)); for(i=0; i<3 && size[i]; i++){ const int h_shift= i==0 ? 0 : h_chroma_shift; const int v_shift= i==0 ? 0 : v_chroma_shift; buf->linesize[i]= picture.linesize[i]; buf->base[i]= av_malloc(size[i]+16); //FIXME 16 if(buf->base[i]==NULL) return -1; memset(buf->base[i], 128, size[i]); // no edge if EDEG EMU or not planar YUV, we check for PAL8 redundantly to protect against a exploitable bug regression ... if((s->flags&CODEC_FLAG_EMU_EDGE) || (s->pix_fmt == PIX_FMT_PAL8) || !size[2]) buf->data[i] = buf->base[i]; else buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), STRIDE_ALIGN); } pic->age= 256*256*256*64; } pic->type= FF_BUFFER_TYPE_INTERNAL; for(i=0; i<4; i++){ pic->base[i]= buf->base[i]; pic->data[i]= buf->data[i]; pic->linesize[i]= buf->linesize[i]; } s->internal_buffer_count++; return 0; }
25,823
FFmpeg
b7b1509d06d3696d3b944791227fe198ded0654b
1
static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code) { TM2Huff huff; int res = 0; huff.val_bits = get_bits(&ctx->gb, 5); huff.max_bits = get_bits(&ctx->gb, 5); huff.min_bits = get_bits(&ctx->gb, 5); huff.nodes = get_bits_long(&ctx->gb, 17); huff.num = 0; /* check for correct codes parameters */ if((huff.val_bits < 1) || (huff.val_bits > 32) || (huff.max_bits < 0) || (huff.max_bits > 32)) { av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal length: %i, max code length: %i\n", huff.val_bits, huff.max_bits); return -1; } if((huff.nodes <= 0) || (huff.nodes > 0x10000)) { av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of Huffman tree nodes: %i\n", huff.nodes); return -1; } /* one-node tree */ if(huff.max_bits == 0) huff.max_bits = 1; /* allocate space for codes - it is exactly ceil(nodes / 2) entries */ huff.max_num = (huff.nodes + 1) >> 1; huff.nums = av_mallocz(huff.max_num * sizeof(int)); huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t)); huff.lens = av_mallocz(huff.max_num * sizeof(int)); if(tm2_read_tree(ctx, 0, 0, &huff) == -1) res = -1; if(huff.num != huff.max_num) { av_log(ctx->avctx, AV_LOG_ERROR, "Got less codes than expected: %i of %i\n", huff.num, huff.max_num); res = -1; } /* convert codes to vlc_table */ if(res != -1) { int i; res = init_vlc(&code->vlc, huff.max_bits, huff.max_num, huff.lens, sizeof(int), sizeof(int), huff.bits, sizeof(uint32_t), sizeof(uint32_t), 0); if(res < 0) { av_log(ctx->avctx, AV_LOG_ERROR, "Cannot build VLC table\n"); res = -1; } else res = 0; if(res != -1) { code->bits = huff.max_bits; code->length = huff.max_num; code->recode = av_malloc(code->length * sizeof(int)); for(i = 0; i < code->length; i++) code->recode[i] = huff.nums[i]; } } /* free allocated memory */ av_free(huff.nums); av_free(huff.bits); av_free(huff.lens); return res; }
25,824
qemu
2db59a76c421cdd1039d10e32a9798952d3ff5ba
1
void gen_intermediate_code_internal(XtensaCPU *cpu, TranslationBlock *tb, bool search_pc) { CPUState *cs = CPU(cpu); CPUXtensaState *env = &cpu->env; DisasContext dc; int insn_count = 0; int j, lj = -1; uint16_t *gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; int max_insns = tb->cflags & CF_COUNT_MASK; uint32_t pc_start = tb->pc; uint32_t next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } dc.config = env->config; dc.singlestep_enabled = cs->singlestep_enabled; dc.tb = tb; dc.pc = pc_start; dc.ring = tb->flags & XTENSA_TBFLAG_RING_MASK; dc.cring = (tb->flags & XTENSA_TBFLAG_EXCM) ? 0 : dc.ring; dc.lbeg = env->sregs[LBEG]; dc.lend = env->sregs[LEND]; dc.is_jmp = DISAS_NEXT; dc.ccount_delta = 0; dc.debug = tb->flags & XTENSA_TBFLAG_DEBUG; dc.icount = tb->flags & XTENSA_TBFLAG_ICOUNT; dc.cpenable = (tb->flags & XTENSA_TBFLAG_CPENABLE_MASK) >> XTENSA_TBFLAG_CPENABLE_SHIFT; init_litbase(&dc); init_sar_tracker(&dc); reset_used_window(&dc); if (dc.icount) { dc.next_icount = tcg_temp_local_new_i32(); } gen_tb_start(); if (tb->flags & XTENSA_TBFLAG_EXCEPTION) { tcg_gen_movi_i32(cpu_pc, dc.pc); gen_exception(&dc, EXCP_DEBUG); } do { check_breakpoint(env, &dc); if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } tcg_ctx.gen_opc_pc[lj] = dc.pc; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = insn_count; } if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) { tcg_gen_debug_insn_start(dc.pc); } ++dc.ccount_delta; if (insn_count + 1 == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } if (dc.icount) { int label = gen_new_label(); tcg_gen_addi_i32(dc.next_icount, cpu_SR[ICOUNT], 1); tcg_gen_brcondi_i32(TCG_COND_NE, dc.next_icount, 0, label); tcg_gen_mov_i32(dc.next_icount, cpu_SR[ICOUNT]); if (dc.debug) { gen_debug_exception(&dc, DEBUGCAUSE_IC); } gen_set_label(label); } if (dc.debug) { gen_ibreak_check(env, &dc); } disas_xtensa_insn(env, &dc); ++insn_count; if (dc.icount) { tcg_gen_mov_i32(cpu_SR[ICOUNT], dc.next_icount); } if (cs->singlestep_enabled) { tcg_gen_movi_i32(cpu_pc, dc.pc); gen_exception(&dc, EXCP_DEBUG); break; } } while (dc.is_jmp == DISAS_NEXT && insn_count < max_insns && dc.pc < next_page_start && dc.pc + xtensa_insn_len(env, &dc) <= next_page_start && tcg_ctx.gen_opc_ptr < gen_opc_end); reset_litbase(&dc); reset_sar_tracker(&dc); if (dc.icount) { tcg_temp_free(dc.next_icount); } if (tb->cflags & CF_LAST_IO) { gen_io_end(); } if (dc.is_jmp == DISAS_NEXT) { gen_jumpi(&dc, dc.pc, 0); } gen_tb_end(tb, insn_count); *tcg_ctx.gen_opc_ptr = INDEX_op_end; #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(env, pc_start, dc.pc - pc_start, 0); qemu_log("\n"); } #endif if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; memset(tcg_ctx.gen_opc_instr_start + lj + 1, 0, (j - lj) * sizeof(tcg_ctx.gen_opc_instr_start[0])); } else { tb->size = dc.pc - pc_start; tb->icount = insn_count; } }
25,825
qemu
c745bfb4300206280ce6156b4bafe765f610057c
1
static void dump_map_entry(OutputFormat output_format, MapEntry *e, MapEntry *next) { switch (output_format) { case OFORMAT_HUMAN: if ((e->flags & BDRV_BLOCK_DATA) && !(e->flags & BDRV_BLOCK_OFFSET_VALID)) { error_report("File contains external, encrypted or compressed clusters."); exit(1); } if ((e->flags & (BDRV_BLOCK_DATA|BDRV_BLOCK_ZERO)) == BDRV_BLOCK_DATA) { printf("%#-16"PRIx64"%#-16"PRIx64"%#-16"PRIx64"%s\n", e->start, e->length, e->offset, e->bs->filename); } /* This format ignores the distinction between 0, ZERO and ZERO|DATA. * Modify the flags here to allow more coalescing. */ if (next && (next->flags & (BDRV_BLOCK_DATA|BDRV_BLOCK_ZERO)) != BDRV_BLOCK_DATA) { next->flags &= ~BDRV_BLOCK_DATA; next->flags |= BDRV_BLOCK_ZERO; } break; case OFORMAT_JSON: printf("%s{ \"start\": %"PRId64", \"length\": %"PRId64", \"depth\": %d," " \"zero\": %s, \"data\": %s", (e->start == 0 ? "[" : ",\n"), e->start, e->length, e->depth, (e->flags & BDRV_BLOCK_ZERO) ? "true" : "false", (e->flags & BDRV_BLOCK_DATA) ? "true" : "false"); if (e->flags & BDRV_BLOCK_OFFSET_VALID) { printf(", 'offset': %"PRId64"", e->offset); } putchar('}'); if (!next) { printf("]\n"); } break; } }
25,826
qemu
e23a1b33b53d25510320b26d9f154e19c6c99725
1
int escc_init(target_phys_addr_t base, qemu_irq irqA, qemu_irq irqB, CharDriverState *chrA, CharDriverState *chrB, int clock, int it_shift) { DeviceState *dev; SysBusDevice *s; SerialState *d; dev = qdev_create(NULL, "escc"); qdev_prop_set_uint32(dev, "disabled", 0); qdev_prop_set_uint32(dev, "frequency", clock); qdev_prop_set_uint32(dev, "it_shift", it_shift); qdev_prop_set_chr(dev, "chrB", chrB); qdev_prop_set_chr(dev, "chrA", chrA); qdev_prop_set_uint32(dev, "chnBtype", ser); qdev_prop_set_uint32(dev, "chnAtype", ser); qdev_init(dev); s = sysbus_from_qdev(dev); sysbus_connect_irq(s, 0, irqB); sysbus_connect_irq(s, 1, irqA); if (base) { sysbus_mmio_map(s, 0, base); } d = FROM_SYSBUS(SerialState, s); return d->mmio_index; }
25,827
FFmpeg
df640dbbc949d0f4deefaf43e86b8bd50ae997cc
1
static void wmv2_idct_row(short * b) { int s1, s2; int a0, a1, a2, a3, a4, a5, a6, a7; /* step 1 */ a1 = W1 * b[1] + W7 * b[7]; a7 = W7 * b[1] - W1 * b[7]; a5 = W5 * b[5] + W3 * b[3]; a3 = W3 * b[5] - W5 * b[3]; a2 = W2 * b[2] + W6 * b[6]; a6 = W6 * b[2] - W2 * b[6]; a0 = W0 * b[0] + W0 * b[4]; a4 = W0 * b[0] - W0 * b[4]; /* step 2 */ s1 = (181 * (a1 - a5 + a7 - a3) + 128) >> 8; // 1, 3, 5, 7 s2 = (181 * (a1 - a5 - a7 + a3) + 128) >> 8; /* step 3 */ b[0] = (a0 + a2 + a1 + a5 + (1 << 7)) >> 8; b[1] = (a4 + a6 + s1 + (1 << 7)) >> 8; b[2] = (a4 - a6 + s2 + (1 << 7)) >> 8; b[3] = (a0 - a2 + a7 + a3 + (1 << 7)) >> 8; b[4] = (a0 - a2 - a7 - a3 + (1 << 7)) >> 8; b[5] = (a4 - a6 - s2 + (1 << 7)) >> 8; b[6] = (a4 + a6 - s1 + (1 << 7)) >> 8; b[7] = (a0 + a2 - a1 - a5 + (1 << 7)) >> 8; }
25,829
qemu
35914dc7240f7d81e22219217cfa826c2c383e7b
1
static void init_dev(tc58128_dev * dev, const char *filename) { int ret, blocks; dev->state = WAIT; dev->flash_contents = g_malloc0(FLASH_SIZE); memset(dev->flash_contents, 0xff, FLASH_SIZE); if (!dev->flash_contents) { fprintf(stderr, "could not alloc memory for flash\n"); exit(1); } if (filename) { /* Load flash image skipping the first block */ ret = load_image(filename, dev->flash_contents + 528 * 32); if (ret < 0) { fprintf(stderr, "ret=%d\n", ret); fprintf(stderr, "qemu: could not load flash image %s\n", filename); exit(1); } else { /* Build first block with number of blocks */ blocks = (ret + 528 * 32 - 1) / (528 * 32); dev->flash_contents[0] = blocks & 0xff; dev->flash_contents[1] = (blocks >> 8) & 0xff; dev->flash_contents[2] = (blocks >> 16) & 0xff; dev->flash_contents[3] = (blocks >> 24) & 0xff; fprintf(stderr, "loaded %d bytes for %s into flash\n", ret, filename); } } }
25,830
FFmpeg
45b7bd7c53b41bc5ff6fc2158831f2b1b1256113
1
int ff_h264_decode_mb_cavlc(H264Context *h){ MpegEncContext * const s = &h->s; int mb_xy; int partition_count; unsigned int mb_type, cbp; int dct8x8_allowed= h->pps.transform_8x8_mode; int decode_chroma = h->sps.chroma_format_idc == 1 || h->sps.chroma_format_idc == 2; const int pixel_shift = h->pixel_shift; mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride; tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); cbp = 0; /* avoid warning. FIXME: find a solution without slowing down the code */ if(h->slice_type_nos != AV_PICTURE_TYPE_I){ if(s->mb_skip_run==-1) s->mb_skip_run= get_ue_golomb(&s->gb); if (s->mb_skip_run--) { if(FRAME_MBAFF && (s->mb_y&1) == 0){ if(s->mb_skip_run==0) h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&s->gb); } decode_mb_skip(h); return 0; } } if(FRAME_MBAFF){ if( (s->mb_y&1) == 0 ) h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&s->gb); } h->prev_mb_skipped= 0; mb_type= get_ue_golomb(&s->gb); if(h->slice_type_nos == AV_PICTURE_TYPE_B){ if(mb_type < 23){ partition_count= b_mb_type_info[mb_type].partition_count; mb_type= b_mb_type_info[mb_type].type; }else{ mb_type -= 23; goto decode_intra_mb; } }else if(h->slice_type_nos == AV_PICTURE_TYPE_P){ if(mb_type < 5){ partition_count= p_mb_type_info[mb_type].partition_count; mb_type= p_mb_type_info[mb_type].type; }else{ mb_type -= 5; goto decode_intra_mb; } }else{ assert(h->slice_type_nos == AV_PICTURE_TYPE_I); if(h->slice_type == AV_PICTURE_TYPE_SI && mb_type) mb_type--; decode_intra_mb: if(mb_type > 25){ av_log(h->s.avctx, AV_LOG_ERROR, "mb_type %d in %c slice too large at %d %d\n", mb_type, av_get_picture_type_char(h->slice_type), s->mb_x, s->mb_y); return -1; } partition_count=0; cbp= i_mb_type_info[mb_type].cbp; h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode; mb_type= i_mb_type_info[mb_type].type; } if(MB_FIELD) mb_type |= MB_TYPE_INTERLACED; h->slice_table[ mb_xy ]= h->slice_num; if(IS_INTRA_PCM(mb_type)){ unsigned int x; static const uint16_t mb_sizes[4] = {256,384,512,768}; const int mb_size = mb_sizes[h->sps.chroma_format_idc]*h->sps.bit_depth_luma >> 3; // We assume these blocks are very rare so we do not optimize it. align_get_bits(&s->gb); // The pixels are stored in the same order as levels in h->mb array. for(x=0; x < mb_size; x++){ ((uint8_t*)h->mb)[x]= get_bits(&s->gb, 8); } // In deblocking, the quantizer is 0 s->current_picture.f.qscale_table[mb_xy] = 0; // All coeffs are present memset(h->non_zero_count[mb_xy], 16, 48); s->current_picture.f.mb_type[mb_xy] = mb_type; return 0; } if(MB_MBAFF){ h->ref_count[0] <<= 1; h->ref_count[1] <<= 1; } fill_decode_neighbors(h, mb_type); fill_decode_caches(h, mb_type); //mb_pred if(IS_INTRA(mb_type)){ int pred_mode; // init_top_left_availability(h); if(IS_INTRA4x4(mb_type)){ int i; int di = 1; if(dct8x8_allowed && get_bits1(&s->gb)){ mb_type |= MB_TYPE_8x8DCT; di = 4; } // fill_intra4x4_pred_table(h); for(i=0; i<16; i+=di){ int mode= pred_intra_mode(h, i); if(!get_bits1(&s->gb)){ const int rem_mode= get_bits(&s->gb, 3); mode = rem_mode + (rem_mode >= mode); } if(di==4) fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 ); else h->intra4x4_pred_mode_cache[ scan8[i] ] = mode; } write_back_intra_pred_mode(h); if( ff_h264_check_intra4x4_pred_mode(h) < 0) return -1; }else{ h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode(h, h->intra16x16_pred_mode); if(h->intra16x16_pred_mode < 0) return -1; } if(decode_chroma){ pred_mode= ff_h264_check_intra_pred_mode(h, get_ue_golomb_31(&s->gb)); if(pred_mode < 0) return -1; h->chroma_pred_mode= pred_mode; } else { h->chroma_pred_mode = DC_128_PRED8x8; } }else if(partition_count==4){ int i, j, sub_partition_count[4], list, ref[2][4]; if(h->slice_type_nos == AV_PICTURE_TYPE_B){ for(i=0; i<4; i++){ h->sub_mb_type[i]= get_ue_golomb_31(&s->gb); if(h->sub_mb_type[i] >=13){ av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); return -1; } sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type; } if( IS_DIRECT(h->sub_mb_type[0]|h->sub_mb_type[1]|h->sub_mb_type[2]|h->sub_mb_type[3])) { ff_h264_pred_direct_motion(h, &mb_type); h->ref_cache[0][scan8[4]] = h->ref_cache[1][scan8[4]] = h->ref_cache[0][scan8[12]] = h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE; } }else{ assert(h->slice_type_nos == AV_PICTURE_TYPE_P); //FIXME SP correct ? for(i=0; i<4; i++){ h->sub_mb_type[i]= get_ue_golomb_31(&s->gb); if(h->sub_mb_type[i] >=4){ av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); return -1; } sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type; } } for(list=0; list<h->list_count; list++){ int ref_count= IS_REF0(mb_type) ? 1 : h->ref_count[list]; for(i=0; i<4; i++){ if(IS_DIRECT(h->sub_mb_type[i])) continue; if(IS_DIR(h->sub_mb_type[i], 0, list)){ unsigned int tmp; if(ref_count == 1){ tmp= 0; }else if(ref_count == 2){ tmp= get_bits1(&s->gb)^1; }else{ tmp= get_ue_golomb_31(&s->gb); if(tmp>=ref_count){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp); return -1; } } ref[list][i]= tmp; }else{ //FIXME ref[list][i] = -1; } } } if(dct8x8_allowed) dct8x8_allowed = get_dct8x8_allowed(h); for(list=0; list<h->list_count; list++){ for(i=0; i<4; i++){ if(IS_DIRECT(h->sub_mb_type[i])) { h->ref_cache[list][ scan8[4*i] ] = h->ref_cache[list][ scan8[4*i]+1 ]; continue; } h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ]= h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i]; if(IS_DIR(h->sub_mb_type[i], 0, list)){ const int sub_mb_type= h->sub_mb_type[i]; const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1; for(j=0; j<sub_partition_count[i]; j++){ int mx, my; const int index= 4*i + block_width*j; int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ]; pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); if(IS_SUB_8X8(sub_mb_type)){ mv_cache[ 1 ][0]= mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx; mv_cache[ 1 ][1]= mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my; }else if(IS_SUB_8X4(sub_mb_type)){ mv_cache[ 1 ][0]= mx; mv_cache[ 1 ][1]= my; }else if(IS_SUB_4X8(sub_mb_type)){ mv_cache[ 8 ][0]= mx; mv_cache[ 8 ][1]= my; } mv_cache[ 0 ][0]= mx; mv_cache[ 0 ][1]= my; } }else{ uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0]; p[0] = p[1]= p[8] = p[9]= 0; } } } }else if(IS_DIRECT(mb_type)){ ff_h264_pred_direct_motion(h, &mb_type); dct8x8_allowed &= h->sps.direct_8x8_inference_flag; }else{ int list, mx, my, i; //FIXME we should set ref_idx_l? to 0 if we use that later ... if(IS_16X16(mb_type)){ for(list=0; list<h->list_count; list++){ unsigned int val; if(IS_DIR(mb_type, 0, list)){ if(h->ref_count[list]==1){ val= 0; }else if(h->ref_count[list]==2){ val= get_bits1(&s->gb)^1; }else{ val= get_ue_golomb_31(&s->gb); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } } fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1); } } for(list=0; list<h->list_count; list++){ if(IS_DIR(mb_type, 0, list)){ pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4); } } } else if(IS_16X8(mb_type)){ for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ if(h->ref_count[list] == 1){ val= 0; }else if(h->ref_count[list] == 2){ val= get_bits1(&s->gb)^1; }else{ val= get_ue_golomb_31(&s->gb); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1); } } for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 4); } } }else{ assert(IS_8X16(mb_type)); for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ //FIXME optimize if(h->ref_count[list]==1){ val= 0; }else if(h->ref_count[list]==2){ val= get_bits1(&s->gb)^1; }else{ val= get_ue_golomb_31(&s->gb); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1); } } for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 4); } } } } if(IS_INTER(mb_type)) write_back_motion(h, mb_type); if(!IS_INTRA16x16(mb_type)){ cbp= get_ue_golomb(&s->gb); if(decode_chroma){ if(cbp > 47){ av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, s->mb_x, s->mb_y); return -1; } if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp[cbp]; else cbp= golomb_to_inter_cbp [cbp]; }else{ if(cbp > 15){ av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, s->mb_x, s->mb_y); return -1; } if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp_gray[cbp]; else cbp= golomb_to_inter_cbp_gray[cbp]; } } if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){ mb_type |= MB_TYPE_8x8DCT*get_bits1(&s->gb); } h->cbp= h->cbp_table[mb_xy]= cbp; s->current_picture.f.mb_type[mb_xy] = mb_type; if(cbp || IS_INTRA16x16(mb_type)){ int i4x4, i8x8, chroma_idx; int dquant; int ret; GetBitContext *gb= IS_INTRA(mb_type) ? h->intra_gb_ptr : h->inter_gb_ptr; const uint8_t *scan, *scan8x8; const int max_qp = 51 + 6*(h->sps.bit_depth_luma-8); if(IS_INTERLACED(mb_type)){ scan8x8= s->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0; scan= s->qscale ? h->field_scan : h->field_scan_q0; }else{ scan8x8= s->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0; scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0; } dquant= get_se_golomb(&s->gb); s->qscale += dquant; if(((unsigned)s->qscale) > max_qp){ if(s->qscale<0) s->qscale+= max_qp+1; else s->qscale-= max_qp+1; if(((unsigned)s->qscale) > max_qp){ av_log(h->s.avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y); return -1; } } h->chroma_qp[0]= get_chroma_qp(h, 0, s->qscale); h->chroma_qp[1]= get_chroma_qp(h, 1, s->qscale); if( (ret = decode_luma_residual(h, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 0)) < 0 ){ return -1; } h->cbp_table[mb_xy] |= ret << 12; if(CHROMA444){ if( decode_luma_residual(h, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 1) < 0 ){ return -1; } if( decode_luma_residual(h, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 2) < 0 ){ return -1; } } else if (CHROMA422) { if(cbp&0x30){ for(chroma_idx=0; chroma_idx<2; chroma_idx++) if (decode_residual(h, gb, h->mb + ((256 + 16*16*chroma_idx) << pixel_shift), CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma422_dc_scan, NULL, 8) < 0) { return -1; } } if(cbp&0x20){ for(chroma_idx=0; chroma_idx<2; chroma_idx++){ const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[chroma_idx]]; DCTELEM *mb = h->mb + (16*(16 + 16*chroma_idx) << pixel_shift); for (i8x8 = 0; i8x8 < 2; i8x8++) { for (i4x4 = 0; i4x4 < 4; i4x4++) { const int index = 16 + 16*chroma_idx + 8*i8x8 + i4x4; if (decode_residual(h, gb, mb, index, scan + 1, qmul, 15) < 0) return -1; mb += 16 << pixel_shift; } } } }else{ fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); } } else /* yuv420 */ { if(cbp&0x30){ for(chroma_idx=0; chroma_idx<2; chroma_idx++) if( decode_residual(h, gb, h->mb + ((256 + 16*16*chroma_idx) << pixel_shift), CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma_dc_scan, NULL, 4) < 0){ return -1; } } if(cbp&0x20){ for(chroma_idx=0; chroma_idx<2; chroma_idx++){ const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[chroma_idx]]; for(i4x4=0; i4x4<4; i4x4++){ const int index= 16 + 16*chroma_idx + i4x4; if( decode_residual(h, gb, h->mb + (16*index << pixel_shift), index, scan + 1, qmul, 15) < 0){ return -1; } } } }else{ fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); } } }else{ fill_rectangle(&h->non_zero_count_cache[scan8[ 0]], 4, 4, 8, 0, 1); fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); } s->current_picture.f.qscale_table[mb_xy] = s->qscale; write_back_non_zero_count(h); if(MB_MBAFF){ h->ref_count[0] >>= 1; h->ref_count[1] >>= 1; } return 0; }
25,832
FFmpeg
1509d739a036b9838e12f28dac9f09ac37bc3928
1
static void d3d11va_frames_uninit(AVHWFramesContext *ctx) { AVD3D11VAFramesContext *frames_hwctx = ctx->hwctx; D3D11VAFramesContext *s = ctx->internal->priv; if (frames_hwctx->texture) ID3D11Texture2D_Release(frames_hwctx->texture); if (s->staging_texture) ID3D11Texture2D_Release(s->staging_texture); }
25,833
FFmpeg
697400eac07c0614f6b9f2e7615563982dbcbe4a
0
static void mov_read_chapters(AVFormatContext *s) { MOVContext *mov = s->priv_data; AVStream *st = NULL; MOVStreamContext *sc; int64_t cur_pos; int i; for (i = 0; i < s->nb_streams; i++) if (s->streams[i]->id == mov->chapter_track) { st = s->streams[i]; break; } if (!st) { av_log(s, AV_LOG_ERROR, "Referenced QT chapter track not found\n"); return; } st->discard = AVDISCARD_ALL; sc = st->priv_data; cur_pos = avio_tell(sc->pb); for (i = 0; i < st->nb_index_entries; i++) { AVIndexEntry *sample = &st->index_entries[i]; int64_t end = i+1 < st->nb_index_entries ? st->index_entries[i+1].timestamp : st->duration; uint8_t *title; uint16_t ch; int len, title_len; if (end < sample->timestamp) { av_log(s, AV_LOG_WARNING, "ignoring stream duration which is shorter than chapters\n"); end = AV_NOPTS_VALUE; } if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { av_log(s, AV_LOG_ERROR, "Chapter %d not found in file\n", i); goto finish; } // the first two bytes are the length of the title len = avio_rb16(sc->pb); if (len > sample->size-2) continue; title_len = 2*len + 1; if (!(title = av_mallocz(title_len))) goto finish; // The samples could theoretically be in any encoding if there's an encd // atom following, but in practice are only utf-8 or utf-16, distinguished // instead by the presence of a BOM if (!len) { title[0] = 0; } else { ch = avio_rb16(sc->pb); if (ch == 0xfeff) avio_get_str16be(sc->pb, len, title, title_len); else if (ch == 0xfffe) avio_get_str16le(sc->pb, len, title, title_len); else { AV_WB16(title, ch); if (len == 1 || len == 2) title[len] = 0; else avio_get_str(sc->pb, INT_MAX, title + 2, len - 1); } } avpriv_new_chapter(s, i, st->time_base, sample->timestamp, end, title); av_freep(&title); } finish: avio_seek(sc->pb, cur_pos, SEEK_SET); }
25,834
FFmpeg
e856ac23732822ac04fe5dd959cff94c7249c17e
0
static int msrle_decode_pal4(AVCodecContext *avctx, AVFrame *pic, GetByteContext *gb) { unsigned char rle_code; unsigned char extra_byte, odd_pixel; unsigned char stream_byte; int pixel_ptr = 0; int line = avctx->height - 1; int i; while (line >= 0 && pixel_ptr <= avctx->width) { if (bytestream2_get_bytes_left(gb) <= 0) { av_log(avctx, AV_LOG_ERROR, "MS RLE: bytestream overrun, %dx%d left\n", avctx->width - pixel_ptr, line); return AVERROR_INVALIDDATA; } rle_code = stream_byte = bytestream2_get_byteu(gb); if (rle_code == 0) { /* fetch the next byte to see how to handle escape code */ stream_byte = bytestream2_get_byte(gb); if (stream_byte == 0) { /* line is done, goto the next one */ line--; pixel_ptr = 0; } else if (stream_byte == 1) { /* decode is done */ return 0; } else if (stream_byte == 2) { /* reposition frame decode coordinates */ stream_byte = bytestream2_get_byte(gb); pixel_ptr += stream_byte; stream_byte = bytestream2_get_byte(gb); avpriv_request_sample(avctx, "Unused stream byte %X", stream_byte); } else { // copy pixels from encoded stream odd_pixel = stream_byte & 1; rle_code = (stream_byte + 1) / 2; extra_byte = rle_code & 0x01; if (pixel_ptr + 2*rle_code - odd_pixel > avctx->width || bytestream2_get_bytes_left(gb) < rle_code) { av_log(avctx, AV_LOG_ERROR, "MS RLE: frame/stream ptr just went out of bounds (copy)\n"); return AVERROR_INVALIDDATA; } for (i = 0; i < rle_code; i++) { if (pixel_ptr >= avctx->width) break; stream_byte = bytestream2_get_byteu(gb); pic->data[0][line * pic->linesize[0] + pixel_ptr] = stream_byte >> 4; pixel_ptr++; if (i + 1 == rle_code && odd_pixel) break; if (pixel_ptr >= avctx->width) break; pic->data[0][line * pic->linesize[0] + pixel_ptr] = stream_byte & 0x0F; pixel_ptr++; } // if the RLE code is odd, skip a byte in the stream if (extra_byte) bytestream2_skip(gb, 1); } } else { // decode a run of data if (pixel_ptr + rle_code > avctx->width + 1) { av_log(avctx, AV_LOG_ERROR, "MS RLE: frame ptr just went out of bounds (run) %d %d %d\n", pixel_ptr, rle_code, avctx->width); return AVERROR_INVALIDDATA; } stream_byte = bytestream2_get_byte(gb); for (i = 0; i < rle_code; i++) { if (pixel_ptr >= avctx->width) break; if ((i & 1) == 0) pic->data[0][line * pic->linesize[0] + pixel_ptr] = stream_byte >> 4; else pic->data[0][line * pic->linesize[0] + pixel_ptr] = stream_byte & 0x0F; pixel_ptr++; } } } /* one last sanity check on the way out */ if (bytestream2_get_bytes_left(gb)) { av_log(avctx, AV_LOG_ERROR, "MS RLE: ended frame decode with %d bytes left over\n", bytestream2_get_bytes_left(gb)); return AVERROR_INVALIDDATA; } return 0; }
25,835
FFmpeg
3206ea4ba31ebf446a3c4f1220adb895b3272c15
0
static void update_initial_durations(AVFormatContext *s, AVStream *st, int stream_index, int duration) { AVPacketList *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue; int64_t cur_dts = RELATIVE_TS_BASE; if (st->first_dts != AV_NOPTS_VALUE) { if (st->update_initial_durations_done) return; st->update_initial_durations_done = 1; cur_dts = st->first_dts; for (; pktl; pktl = get_next_pkt(s, st, pktl)) { if (pktl->pkt.stream_index == stream_index) { if (pktl->pkt.pts != pktl->pkt.dts || pktl->pkt.dts != AV_NOPTS_VALUE || pktl->pkt.duration) break; cur_dts -= duration; } } if (pktl && pktl->pkt.dts != st->first_dts) { av_log(s, AV_LOG_DEBUG, "first_dts %s not matching first dts %s (pts %s, duration %"PRId64") in the queue\n", av_ts2str(st->first_dts), av_ts2str(pktl->pkt.dts), av_ts2str(pktl->pkt.pts), pktl->pkt.duration); return; } if (!pktl) { av_log(s, AV_LOG_DEBUG, "first_dts %s but no packet with dts in the queue\n", av_ts2str(st->first_dts)); return; } pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue; st->first_dts = cur_dts; } else if (st->cur_dts != RELATIVE_TS_BASE) return; for (; pktl; pktl = get_next_pkt(s, st, pktl)) { if (pktl->pkt.stream_index != stream_index) continue; if (pktl->pkt.pts == pktl->pkt.dts && (pktl->pkt.dts == AV_NOPTS_VALUE || pktl->pkt.dts == st->first_dts) && !pktl->pkt.duration) { pktl->pkt.dts = cur_dts; if (!st->internal->avctx->has_b_frames) pktl->pkt.pts = cur_dts; // if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) pktl->pkt.duration = duration; } else break; cur_dts = pktl->pkt.dts + pktl->pkt.duration; } if (!pktl) st->cur_dts = cur_dts; }
25,836
FFmpeg
6ff3f3e7cec7cd78a01d0bf76cbccfbe68dc0894
0
int poll(struct pollfd *fds, nfds_t numfds, int timeout) { fd_set read_set; fd_set write_set; fd_set exception_set; nfds_t i; int n; int rc; #ifdef __MINGW32__ if (numfds >= FD_SETSIZE) { errno = EINVAL; return -1; } #endif FD_ZERO(&read_set); FD_ZERO(&write_set); FD_ZERO(&exception_set); n = -1; for(i = 0; i < numfds; i++) { if (fds[i].fd < 0) continue; #ifndef __MINGW32__ if (fds[i].fd >= FD_SETSIZE) { errno = EINVAL; return -1; } #endif if (fds[i].events & POLLIN) FD_SET(fds[i].fd, &read_set); if (fds[i].events & POLLOUT) FD_SET(fds[i].fd, &write_set); if (fds[i].events & POLLERR) FD_SET(fds[i].fd, &exception_set); if (fds[i].fd > n) n = fds[i].fd; }; if (n == -1) /* Hey!? Nothing to poll, in fact!!! */ return 0; if (timeout < 0) rc = select(n+1, &read_set, &write_set, &exception_set, NULL); else { struct timeval tv; tv.tv_sec = timeout / 1000; tv.tv_usec = 1000 * (timeout % 1000); rc = select(n+1, &read_set, &write_set, &exception_set, &tv); }; if (rc < 0) return rc; for(i = 0; i < (nfds_t) n; i++) { fds[i].revents = 0; if (FD_ISSET(fds[i].fd, &read_set)) fds[i].revents |= POLLIN; if (FD_ISSET(fds[i].fd, &write_set)) fds[i].revents |= POLLOUT; if (FD_ISSET(fds[i].fd, &exception_set)) fds[i].revents |= POLLERR; }; return rc; }
25,837
FFmpeg
42c41e96ff6dc4fa24d98e1913aff925b8122776
0
int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, AVCodec **decoder_ret, int flags) { int i, nb_streams = ic->nb_streams; int ret = AVERROR_STREAM_NOT_FOUND, best_count = -1, best_bitrate = -1, best_multiframe = -1, count, bitrate, multiframe; unsigned *program = NULL; const AVCodec *decoder = NULL, *best_decoder = NULL; if (related_stream >= 0 && wanted_stream_nb < 0) { AVProgram *p = av_find_program_from_stream(ic, NULL, related_stream); if (p) { program = p->stream_index; nb_streams = p->nb_stream_indexes; } } for (i = 0; i < nb_streams; i++) { int real_stream_index = program ? program[i] : i; AVStream *st = ic->streams[real_stream_index]; AVCodecContext *avctx = st->codec; if (avctx->codec_type != type) continue; if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb) continue; if (wanted_stream_nb != real_stream_index && st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED | AV_DISPOSITION_VISUAL_IMPAIRED)) continue; if (type == AVMEDIA_TYPE_AUDIO && !avctx->channels) continue; if (decoder_ret) { decoder = find_decoder(ic, st, st->codec->codec_id); if (!decoder) { if (ret < 0) ret = AVERROR_DECODER_NOT_FOUND; continue; } } count = st->codec_info_nb_frames; bitrate = avctx->bit_rate; if (!bitrate) bitrate = avctx->rc_max_rate; multiframe = FFMIN(5, count); if ((best_multiframe > multiframe) || (best_multiframe == multiframe && best_bitrate > bitrate) || (best_multiframe == multiframe && best_bitrate == bitrate && best_count >= count)) continue; best_count = count; best_bitrate = bitrate; best_multiframe = multiframe; ret = real_stream_index; best_decoder = decoder; if (program && i == nb_streams - 1 && ret < 0) { program = NULL; nb_streams = ic->nb_streams; /* no related stream found, try again with everything */ i = 0; } } if (decoder_ret) *decoder_ret = (AVCodec*)best_decoder; return ret; }
25,838
FFmpeg
28af284cfb44cb198c1b1c01e61c90b10fd9e395
1
static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len) { MpegTSContext *ts = filter->u.section_filter.opaque; SectionHeader h1, *h = &h1; PESContext *pes; AVStream *st; const uint8_t *p, *p_end, *desc_list_end, *desc_end; int program_info_length, pcr_pid, pid, stream_type; int desc_list_len, desc_len, desc_tag; int comp_page = 0, anc_page = 0; /* initialize to kill warnings */ char language[4] = {0}; /* initialize to kill warnings */ #ifdef DEBUG_SI av_log(ts->stream, AV_LOG_DEBUG, "PMT: len %i\n", section_len); av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len); #endif p_end = section + section_len - 4; p = section; if (parse_section_header(h, &p, p_end) < 0) return; #ifdef DEBUG_SI av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x sec_num=%d/%d\n", h->id, h->sec_num, h->last_sec_num); #endif if (h->tid != PMT_TID) return; clear_program(ts, h->id); pcr_pid = get16(&p, p_end) & 0x1fff; if (pcr_pid < 0) return; add_pid_to_pmt(ts, h->id, pcr_pid); #ifdef DEBUG_SI av_log(ts->stream, AV_LOG_DEBUG, "pcr_pid=0x%x\n", pcr_pid); #endif program_info_length = get16(&p, p_end) & 0xfff; if (program_info_length < 0) return; p += program_info_length; if (p >= p_end) return; for(;;) { language[0] = 0; st = 0; stream_type = get8(&p, p_end); if (stream_type < 0) break; pid = get16(&p, p_end) & 0x1fff; if (pid < 0) break; desc_list_len = get16(&p, p_end) & 0xfff; if (desc_list_len < 0) break; desc_list_end = p + desc_list_len; if (desc_list_end > p_end) break; for(;;) { desc_tag = get8(&p, desc_list_end); if (desc_tag < 0) break; if (stream_type == STREAM_TYPE_PRIVATE_DATA) { if((desc_tag == 0x6A) || (desc_tag == 0x7A)) { /*assume DVB AC-3 Audio*/ stream_type = STREAM_TYPE_AUDIO_AC3; } else if(desc_tag == 0x7B) { /* DVB DTS audio */ stream_type = STREAM_TYPE_AUDIO_DTS; } } desc_len = get8(&p, desc_list_end); desc_end = p + desc_len; if (desc_end > desc_list_end) break; #ifdef DEBUG_SI av_log(ts->stream, AV_LOG_DEBUG, "tag: 0x%02x len=%d\n", desc_tag, desc_len); #endif switch(desc_tag) { case DVB_SUBT_DESCID: if (stream_type == STREAM_TYPE_PRIVATE_DATA) stream_type = STREAM_TYPE_SUBTITLE_DVB; language[0] = get8(&p, desc_end); language[1] = get8(&p, desc_end); language[2] = get8(&p, desc_end); language[3] = 0; get8(&p, desc_end); comp_page = get16(&p, desc_end); anc_page = get16(&p, desc_end); break; case 0x0a: /* ISO 639 language descriptor */ language[0] = get8(&p, desc_end); language[1] = get8(&p, desc_end); language[2] = get8(&p, desc_end); language[3] = 0; break; default: break; } p = desc_end; } p = desc_list_end; #ifdef DEBUG_SI av_log(ts->stream, AV_LOG_DEBUG, "stream_type=%d pid=0x%x\n", stream_type, pid); #endif /* now create ffmpeg stream */ switch(stream_type) { case STREAM_TYPE_AUDIO_MPEG1: case STREAM_TYPE_AUDIO_MPEG2: case STREAM_TYPE_VIDEO_MPEG1: case STREAM_TYPE_VIDEO_MPEG2: case STREAM_TYPE_VIDEO_MPEG4: case STREAM_TYPE_VIDEO_H264: case STREAM_TYPE_VIDEO_VC1: case STREAM_TYPE_AUDIO_AAC: case STREAM_TYPE_AUDIO_AC3: case STREAM_TYPE_AUDIO_DTS: case STREAM_TYPE_SUBTITLE_DVB: if(ts->pids[pid]){ assert(ts->pids[pid]->type == MPEGTS_PES); pes= ts->pids[pid]->u.pes_filter.opaque; st= pes->st; }else{ pes = add_pes_stream(ts, pid, pcr_pid, stream_type); if (pes) st = new_pes_av_stream(pes, 0); } add_pid_to_pmt(ts, h->id, pid); if(st) av_program_add_stream_index(ts->stream, h->id, st->index); break; default: /* we ignore the other streams */ break; } if (st) { if (language[0] != 0) { memcpy(st->language, language, 4); } if (stream_type == STREAM_TYPE_SUBTITLE_DVB) { st->codec->sub_id = (anc_page << 16) | comp_page; } } } /* all parameters are there */ ts->stop_parse++; mpegts_close_filter(ts, filter); }
25,840
FFmpeg
c3ab0004ae4dffc32494ae84dd15cfaa909a7884
1
static inline void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW) { #if COMPILE_TEMPLATE_MMX if(!(c->flags & SWS_BITEXACT)) { if (c->flags & SWS_ACCURATE_RND) { if (uDest) { YSCALEYUV2YV12X_ACCURATE( "0", CHR_MMX_FILTER_OFFSET, uDest, chrDstW) YSCALEYUV2YV12X_ACCURATE(AV_STRINGIFY(VOF), CHR_MMX_FILTER_OFFSET, vDest, chrDstW) } if (CONFIG_SWSCALE_ALPHA && aDest) { YSCALEYUV2YV12X_ACCURATE( "0", ALP_MMX_FILTER_OFFSET, aDest, dstW) } YSCALEYUV2YV12X_ACCURATE("0", LUM_MMX_FILTER_OFFSET, dest, dstW) } else { if (uDest) { YSCALEYUV2YV12X( "0", CHR_MMX_FILTER_OFFSET, uDest, chrDstW) YSCALEYUV2YV12X(AV_STRINGIFY(VOF), CHR_MMX_FILTER_OFFSET, vDest, chrDstW) } if (CONFIG_SWSCALE_ALPHA && aDest) { YSCALEYUV2YV12X( "0", ALP_MMX_FILTER_OFFSET, aDest, dstW) } YSCALEYUV2YV12X("0", LUM_MMX_FILTER_OFFSET, dest, dstW) } return; } #endif #if COMPILE_TEMPLATE_ALTIVEC yuv2yuvX_altivec_real(lumFilter, lumSrc, lumFilterSize, chrFilter, chrSrc, chrFilterSize, dest, uDest, vDest, dstW, chrDstW); #else //COMPILE_TEMPLATE_ALTIVEC yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize, chrFilter, chrSrc, chrFilterSize, alpSrc, dest, uDest, vDest, aDest, dstW, chrDstW); #endif //!COMPILE_TEMPLATE_ALTIVEC }
25,841
qemu
5e5557d97026d1d3325e0e7b0ba593366da2f3dc
1
static int qcow_make_empty(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; uint32_t l1_length = s->l1_size * sizeof(uint64_t); int ret; memset(s->l1_table, 0, l1_length); if (bdrv_pwrite(bs->file, s->l1_table_offset, s->l1_table, l1_length) < 0) return -1; ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length); if (ret < 0) return ret; memset(s->l2_cache, 0, s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t)); memset(s->l2_cache_offsets, 0, L2_CACHE_SIZE * sizeof(uint64_t)); memset(s->l2_cache_counts, 0, L2_CACHE_SIZE * sizeof(uint32_t)); return 0; }
25,842
FFmpeg
6c5bd7d785ffb796b8cfbae677ab54755b26a22b
1
static inline void vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y, int mvn, int r_x, int r_y, uint8_t* is_intra, int dir) { MpegEncContext *s = &v->s; int xy, wrap, off = 0; int A[2], B[2], C[2]; int px, py; int a_valid = 0, b_valid = 0, c_valid = 0; int field_a, field_b, field_c; // 0: same, 1: opposit int total_valid, num_samefield, num_oppfield; int pos_c, pos_b, n_adj; wrap = s->b8_stride; xy = s->block_index[n]; if (s->mb_intra) { s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = 0; s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = 0; s->current_picture.motion_val[1][xy][0] = 0; s->current_picture.motion_val[1][xy][1] = 0; if (mvn == 1) { /* duplicate motion data for 1-MV block */ s->current_picture.motion_val[0][xy + 1][0] = 0; s->current_picture.motion_val[0][xy + 1][1] = 0; s->current_picture.motion_val[0][xy + wrap][0] = 0; s->current_picture.motion_val[0][xy + wrap][1] = 0; s->current_picture.motion_val[0][xy + wrap + 1][0] = 0; s->current_picture.motion_val[0][xy + wrap + 1][1] = 0; v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; s->current_picture.motion_val[1][xy + 1][0] = 0; s->current_picture.motion_val[1][xy + 1][1] = 0; s->current_picture.motion_val[1][xy + wrap][0] = 0; s->current_picture.motion_val[1][xy + wrap][1] = 0; s->current_picture.motion_val[1][xy + wrap + 1][0] = 0; s->current_picture.motion_val[1][xy + wrap + 1][1] = 0; } return; } off = ((n == 0) || (n == 1)) ? 1 : -1; /* predict A */ if (s->mb_x || (n == 1) || (n == 3)) { if ((v->blk_mv_type[xy]) // current block (MB) has a field MV || (!v->blk_mv_type[xy] && !v->blk_mv_type[xy - 1])) { // or both have frame MV A[0] = s->current_picture.motion_val[dir][xy - 1][0]; A[1] = s->current_picture.motion_val[dir][xy - 1][1]; a_valid = 1; } else { // current block has frame mv and cand. has field MV (so average) A[0] = (s->current_picture.motion_val[dir][xy - 1][0] + s->current_picture.motion_val[dir][xy - 1 + off * wrap][0] + 1) >> 1; A[1] = (s->current_picture.motion_val[dir][xy - 1][1] + s->current_picture.motion_val[dir][xy - 1 + off * wrap][1] + 1) >> 1; a_valid = 1; } if (!(n & 1) && v->is_intra[s->mb_x - 1]) { a_valid = 0; A[0] = A[1] = 0; } } else A[0] = A[1] = 0; /* Predict B and C */ B[0] = B[1] = C[0] = C[1] = 0; if (n == 0 || n == 1 || v->blk_mv_type[xy]) { if (!s->first_slice_line) { if (!v->is_intra[s->mb_x - s->mb_stride]) { b_valid = 1; n_adj = n | 2; pos_b = s->block_index[n_adj] - 2 * wrap; if (v->blk_mv_type[pos_b] && v->blk_mv_type[xy]) { n_adj = (n & 2) | (n & 1); } B[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap][0]; B[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap][1]; if (v->blk_mv_type[pos_b] && !v->blk_mv_type[xy]) { B[0] = (B[0] + s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap][0] + 1) >> 1; B[1] = (B[1] + s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap][1] + 1) >> 1; } } if (s->mb_width > 1) { if (!v->is_intra[s->mb_x - s->mb_stride + 1]) { c_valid = 1; n_adj = 2; pos_c = s->block_index[2] - 2 * wrap + 2; if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) { n_adj = n & 2; } C[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap + 2][0]; C[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap + 2][1]; if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) { C[0] = (1 + C[0] + (s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap + 2][0])) >> 1; C[1] = (1 + C[1] + (s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap + 2][1])) >> 1; } if (s->mb_x == s->mb_width - 1) { if (!v->is_intra[s->mb_x - s->mb_stride - 1]) { c_valid = 1; n_adj = 3; pos_c = s->block_index[3] - 2 * wrap - 2; if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) { n_adj = n | 1; } C[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap - 2][0]; C[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap - 2][1]; if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) { C[0] = (1 + C[0] + s->current_picture.motion_val[dir][s->block_index[1] - 2 * wrap - 2][0]) >> 1; C[1] = (1 + C[1] + s->current_picture.motion_val[dir][s->block_index[1] - 2 * wrap - 2][1]) >> 1; } } else c_valid = 0; } } } } } else { pos_b = s->block_index[1]; b_valid = 1; B[0] = s->current_picture.motion_val[dir][pos_b][0]; B[1] = s->current_picture.motion_val[dir][pos_b][1]; pos_c = s->block_index[0]; c_valid = 1; C[0] = s->current_picture.motion_val[dir][pos_c][0]; C[1] = s->current_picture.motion_val[dir][pos_c][1]; } total_valid = a_valid + b_valid + c_valid; // check if predictor A is out of bounds if (!s->mb_x && !(n == 1 || n == 3)) { A[0] = A[1] = 0; } // check if predictor B is out of bounds if ((s->first_slice_line && v->blk_mv_type[xy]) || (s->first_slice_line && !(n & 2))) { B[0] = B[1] = C[0] = C[1] = 0; } if (!v->blk_mv_type[xy]) { if (s->mb_width == 1) { px = B[0]; py = B[1]; } else { if (total_valid >= 2) { px = mid_pred(A[0], B[0], C[0]); py = mid_pred(A[1], B[1], C[1]); } else if (total_valid) { if (a_valid) { px = A[0]; py = A[1]; } else if (b_valid) { px = B[0]; py = B[1]; } else if (c_valid) { px = C[0]; py = C[1]; } else av_assert2(0); } else px = py = 0; } } else { if (a_valid) field_a = (A[1] & 4) ? 1 : 0; else field_a = 0; if (b_valid) field_b = (B[1] & 4) ? 1 : 0; else field_b = 0; if (c_valid) field_c = (C[1] & 4) ? 1 : 0; else field_c = 0; num_oppfield = field_a + field_b + field_c; num_samefield = total_valid - num_oppfield; if (total_valid == 3) { if ((num_samefield == 3) || (num_oppfield == 3)) { px = mid_pred(A[0], B[0], C[0]); py = mid_pred(A[1], B[1], C[1]); } else if (num_samefield >= num_oppfield) { /* take one MV from same field set depending on priority the check for B may not be necessary */ px = !field_a ? A[0] : B[0]; py = !field_a ? A[1] : B[1]; } else { px = field_a ? A[0] : B[0]; py = field_a ? A[1] : B[1]; } } else if (total_valid == 2) { if (num_samefield >= num_oppfield) { if (!field_a && a_valid) { px = A[0]; py = A[1]; } else if (!field_b && b_valid) { px = B[0]; py = B[1]; } else if (c_valid) { px = C[0]; py = C[1]; } else px = py = 0; } else { if (field_a && a_valid) { px = A[0]; py = A[1]; } else if (field_b && b_valid) { px = B[0]; py = B[1]; } else if (c_valid) { px = C[0]; py = C[1]; } else px = py = 0; } } else if (total_valid == 1) { px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]); py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]); } else px = py = 0; } /* store MV using signed modulus of MV range defined in 4.11 */ s->mv[dir][n][0] = s->current_picture.motion_val[dir][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x; s->mv[dir][n][1] = s->current_picture.motion_val[dir][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y; if (mvn == 1) { /* duplicate motion data for 1-MV block */ s->current_picture.motion_val[dir][xy + 1 ][0] = s->current_picture.motion_val[dir][xy][0]; s->current_picture.motion_val[dir][xy + 1 ][1] = s->current_picture.motion_val[dir][xy][1]; s->current_picture.motion_val[dir][xy + wrap ][0] = s->current_picture.motion_val[dir][xy][0]; s->current_picture.motion_val[dir][xy + wrap ][1] = s->current_picture.motion_val[dir][xy][1]; s->current_picture.motion_val[dir][xy + wrap + 1][0] = s->current_picture.motion_val[dir][xy][0]; s->current_picture.motion_val[dir][xy + wrap + 1][1] = s->current_picture.motion_val[dir][xy][1]; } else if (mvn == 2) { /* duplicate motion data for 2-Field MV block */ s->current_picture.motion_val[dir][xy + 1][0] = s->current_picture.motion_val[dir][xy][0]; s->current_picture.motion_val[dir][xy + 1][1] = s->current_picture.motion_val[dir][xy][1]; s->mv[dir][n + 1][0] = s->mv[dir][n][0]; s->mv[dir][n + 1][1] = s->mv[dir][n][1]; } }
25,843
qemu
1ba4b6a553ad9ff4645af7fab8adfc6e810fcc69
1
void bdrv_append_temp_snapshot(BlockDriverState *bs, Error **errp) { /* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */ char tmp_filename[PATH_MAX + 1]; int64_t total_size; BlockDriver *bdrv_qcow2; QEMUOptionParameter *create_options; QDict *snapshot_options; BlockDriverState *bs_snapshot; Error *local_err; int ret; /* if snapshot, we create a temporary backing file and open it instead of opening 'filename' directly */ /* Get the required size from the image */ total_size = bdrv_getlength(bs); if (total_size < 0) { error_setg_errno(errp, -total_size, "Could not get image size"); return; } total_size &= BDRV_SECTOR_MASK; /* Create the temporary image */ ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename)); if (ret < 0) { error_setg_errno(errp, -ret, "Could not get temporary filename"); return; } bdrv_qcow2 = bdrv_find_format("qcow2"); create_options = parse_option_parameters("", bdrv_qcow2->create_options, NULL); set_option_parameter_int(create_options, BLOCK_OPT_SIZE, total_size); ret = bdrv_create(bdrv_qcow2, tmp_filename, create_options, &local_err); free_option_parameters(create_options); if (ret < 0) { error_setg_errno(errp, -ret, "Could not create temporary overlay " "'%s': %s", tmp_filename, error_get_pretty(local_err)); error_free(local_err); return; } /* Prepare a new options QDict for the temporary file */ snapshot_options = qdict_new(); qdict_put(snapshot_options, "file.driver", qstring_from_str("file")); qdict_put(snapshot_options, "file.filename", qstring_from_str(tmp_filename)); bs_snapshot = bdrv_new("", &error_abort); bs_snapshot->is_temporary = 1; ret = bdrv_open(&bs_snapshot, NULL, NULL, snapshot_options, bs->open_flags & ~BDRV_O_SNAPSHOT, bdrv_qcow2, &local_err); if (ret < 0) { error_propagate(errp, local_err); return; } bdrv_append(bs_snapshot, bs); }
25,844
qemu
6bdcc018a6ed760b9dfe43539124e420aed83092
1
int nbd_client_co_flush(BlockDriverState *bs) { NBDClientSession *client = nbd_get_client_session(bs); NBDRequest request = { .type = NBD_CMD_FLUSH }; NBDReply reply; ssize_t ret; if (!(client->nbdflags & NBD_FLAG_SEND_FLUSH)) { return 0; } request.from = 0; request.len = 0; nbd_coroutine_start(client, &request); ret = nbd_co_send_request(bs, &request, NULL); if (ret < 0) { reply.error = -ret; } else { nbd_co_receive_reply(client, &request, &reply, NULL); } nbd_coroutine_end(bs, &request); return -reply.error; }
25,845
qemu
773b93ee0684a9b9d1f0029a936a251411289027
1
int do_sigaction(int sig, const struct target_sigaction *act, struct target_sigaction *oact) { struct emulated_sigaction *k; if (sig < 1 || sig > TARGET_NSIG) return -EINVAL; k = &sigact_table[sig - 1]; #if defined(DEBUG_SIGNAL) && 0 fprintf(stderr, "sigaction sig=%d act=0x%08x, oact=0x%08x\n", sig, (int)act, (int)oact); #endif if (oact) { oact->_sa_handler = tswapl(k->sa._sa_handler); oact->sa_flags = tswapl(k->sa.sa_flags); oact->sa_restorer = tswapl(k->sa.sa_restorer); oact->sa_mask = k->sa.sa_mask; } if (act) { k->sa._sa_handler = tswapl(act->_sa_handler); k->sa.sa_flags = tswapl(act->sa_flags); k->sa.sa_restorer = tswapl(act->sa_restorer); k->sa.sa_mask = act->sa_mask; } return 0; }
25,846
qemu
4ed658ca925249021789d6a51fd6f99f68213f28
1
DeviceState *qdev_try_create(BusState *bus, const char *name) { DeviceState *dev; dev = DEVICE(object_new(name)); if (!dev) { if (!bus) { bus = sysbus_get_default(); qdev_set_parent_bus(dev, bus); qdev_prop_set_globals(dev); return dev;
25,847
FFmpeg
24cdc39e9dfd2b98e96c96387903bd41313bd0dd
1
const AVOption *av_set_string(void *obj, const char *name, const char *val){ const AVOption *o= av_find_opt(obj, name, NULL, 0, 0); if(o && o->offset==0 && o->type == FF_OPT_TYPE_CONST && o->unit){ return set_all_opt(obj, o->unit, o->default_val); } if(!o || !val || o->offset<=0) return NULL; if(o->type != FF_OPT_TYPE_STRING){ for(;;){ int i; char buf[256]; int cmd=0; double d; char *error = NULL; if(*val == '+' || *val == '-') cmd= *(val++); for(i=0; i<sizeof(buf)-1 && val[i] && val[i]!='+' && val[i]!='-'; i++) buf[i]= val[i]; buf[i]=0; val+= i; d = ff_eval2(buf, const_values, const_names, NULL, NULL, NULL, NULL, NULL, &error); if(isnan(d)) { const AVOption *o_named= av_find_opt(obj, buf, o->unit, 0, 0); if(o_named && o_named->type == FF_OPT_TYPE_CONST) d= o_named->default_val; else if(!strcmp(buf, "default")) d= o->default_val; else if(!strcmp(buf, "max" )) d= o->max; else if(!strcmp(buf, "min" )) d= o->min; else if(!strcmp(buf, "none" )) d= 0; else if(!strcmp(buf, "all" )) d= ~0; else { if (!error) av_log(NULL, AV_LOG_ERROR, "Unable to parse option value \"%s\": %s\n", val, error); return NULL; } } if(o->type == FF_OPT_TYPE_FLAGS){ if (cmd=='+') d= av_get_int(obj, name, NULL) | (int64_t)d; else if(cmd=='-') d= av_get_int(obj, name, NULL) &~(int64_t)d; }else if(cmd=='-') d= -d; av_set_number(obj, name, d, 1, 1); if(!*val) return o; } return NULL; } memcpy(((uint8_t*)obj) + o->offset, val, sizeof(val)); return o; }
25,848
FFmpeg
382a68b0088b06b8df20d0133d767d53d8f161ef
1
int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645NAL *nal, int small_padding) { int i, si, di; uint8_t *dst; int64_t padding = small_padding ? AV_INPUT_BUFFER_PADDING_SIZE : MAX_MBPAIR_SIZE; nal->skipped_bytes = 0; #define STARTCODE_TEST \ if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \ if (src[i + 2] != 3 && src[i + 2] != 0) { \ /* startcode, so we must be past the end */ \ length = i; \ } \ break; \ } #if HAVE_FAST_UNALIGNED #define FIND_FIRST_ZERO \ if (i > 0 && !src[i]) \ i--; \ while (src[i]) \ i++ #if HAVE_FAST_64BIT for (i = 0; i + 1 < length; i += 9) { if (!((~AV_RN64A(src + i) & (AV_RN64A(src + i) - 0x0100010001000101ULL)) & 0x8000800080008080ULL)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; i -= 7; } #else for (i = 0; i + 1 < length; i += 5) { if (!((~AV_RN32A(src + i) & (AV_RN32A(src + i) - 0x01000101U)) & 0x80008080U)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; i -= 3; } #endif /* HAVE_FAST_64BIT */ #else for (i = 0; i + 1 < length; i += 2) { if (src[i]) continue; if (i > 0 && src[i - 1] == 0) i--; STARTCODE_TEST; } #endif /* HAVE_FAST_UNALIGNED */ if (i >= length - 1 && small_padding) { // no escaped 0 nal->data = nal->raw_data = src; nal->size = nal->raw_size = length; return length; } av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size, length + padding); if (!nal->rbsp_buffer) return AVERROR(ENOMEM); dst = nal->rbsp_buffer; memcpy(dst, src, i); si = di = i; while (si + 2 < length) { // remove escapes (very rare 1:2^22) if (src[si + 2] > 3) { dst[di++] = src[si++]; dst[di++] = src[si++]; } else if (src[si] == 0 && src[si + 1] == 0 && src[si + 2] != 0) { if (src[si + 2] == 3) { // escape dst[di++] = 0; dst[di++] = 0; si += 3; if (nal->skipped_bytes_pos) { nal->skipped_bytes++; if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { nal->skipped_bytes_pos_size *= 2; av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes); av_reallocp_array(&nal->skipped_bytes_pos, nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); if (!nal->skipped_bytes_pos) { nal->skipped_bytes_pos_size = 0; return AVERROR(ENOMEM); } } if (nal->skipped_bytes_pos) nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1; } continue; } else // next start code goto nsc; } dst[di++] = src[si++]; } while (si < length) dst[di++] = src[si++]; nsc: memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE); nal->data = dst; nal->size = di; nal->raw_data = src; nal->raw_size = si; return si; }
25,849
qemu
7453c96b78c2b09aa72924f933bb9616e5474194
1
static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, bool *rebuild, uint16_t **refcount_table, int64_t *nb_clusters) { BDRVQcowState *s = bs->opaque; int64_t i, size; int ret; for(i = 0; i < s->refcount_table_size; i++) { uint64_t offset, cluster; offset = s->refcount_table[i]; cluster = offset >> s->cluster_bits; /* Refcount blocks are cluster aligned */ if (offset_into_cluster(s, offset)) { fprintf(stderr, "ERROR refcount block %" PRId64 " is not " "cluster aligned; refcount table entry corrupted\n", i); res->corruptions++; *rebuild = true; continue; } if (cluster >= *nb_clusters) { fprintf(stderr, "%s refcount block %" PRId64 " is outside image\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); if (fix & BDRV_FIX_ERRORS) { int64_t new_nb_clusters; if (offset > INT64_MAX - s->cluster_size) { ret = -EINVAL; goto resize_fail; } ret = bdrv_truncate(bs->file, offset + s->cluster_size); if (ret < 0) { goto resize_fail; } size = bdrv_getlength(bs->file); if (size < 0) { ret = size; goto resize_fail; } new_nb_clusters = size_to_clusters(s, size); assert(new_nb_clusters >= *nb_clusters); ret = realloc_refcount_array(s, refcount_table, nb_clusters, new_nb_clusters); if (ret < 0) { res->check_errors++; return ret; } if (cluster >= *nb_clusters) { ret = -EINVAL; goto resize_fail; } res->corruptions_fixed++; ret = inc_refcounts(bs, res, refcount_table, nb_clusters, offset, s->cluster_size); if (ret < 0) { return ret; } /* No need to check whether the refcount is now greater than 1: * This area was just allocated and zeroed, so it can only be * exactly 1 after inc_refcounts() */ continue; resize_fail: res->corruptions++; *rebuild = true; fprintf(stderr, "ERROR could not resize image: %s\n", strerror(-ret)); } else { res->corruptions++; } continue; } if (offset != 0) { ret = inc_refcounts(bs, res, refcount_table, nb_clusters, offset, s->cluster_size); if (ret < 0) { return ret; } if ((*refcount_table)[cluster] != 1) { fprintf(stderr, "ERROR refcount block %" PRId64 " refcount=%d\n", i, (*refcount_table)[cluster]); res->corruptions++; *rebuild = true; } } } return 0; }
25,850
FFmpeg
b5ef6f8eb452c37b19d973d61548725d7b91113e
1
static void choose_pixel_fmt(AVStream *st, AVCodec *codec) { if(codec && codec->pix_fmts){ const enum PixelFormat *p= codec->pix_fmts; if(st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL){ if(st->codec->codec_id==CODEC_ID_MJPEG){ p= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE}; }else if(st->codec->codec_id==CODEC_ID_LJPEG){ p= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE}; } } for(; *p!=-1; p++){ if(*p == st->codec->pix_fmt) break; } if (*p == -1) { av_log(NULL, AV_LOG_WARNING, "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n", av_pix_fmt_descriptors[st->codec->pix_fmt].name, codec->name, av_pix_fmt_descriptors[codec->pix_fmts[0]].name); st->codec->pix_fmt = codec->pix_fmts[0]; } } }
25,851
qemu
79d16c21a565927943486b26789caa62413ff371
1
static void virtio_gpu_reset(VirtIODevice *vdev) { VirtIOGPU *g = VIRTIO_GPU(vdev); struct virtio_gpu_simple_resource *res, *tmp; int i; g->enable = 0; QTAILQ_FOREACH_SAFE(res, &g->reslist, next, tmp) { virtio_gpu_resource_destroy(g, res); } for (i = 0; i < g->conf.max_outputs; i++) { #if 0 g->req_state[i].x = 0; g->req_state[i].y = 0; if (i == 0) { g->req_state[0].width = 1024; g->req_state[0].height = 768; } else { g->req_state[i].width = 0; g->req_state[i].height = 0; } #endif g->scanout[i].resource_id = 0; g->scanout[i].width = 0; g->scanout[i].height = 0; g->scanout[i].x = 0; g->scanout[i].y = 0; g->scanout[i].ds = NULL; } g->enabled_output_bitmask = 1; #ifdef CONFIG_VIRGL if (g->use_virgl_renderer) { virtio_gpu_virgl_reset(g); g->use_virgl_renderer = 0; } #endif }
25,852
qemu
9745807191a81c45970f780166f44a7f93b18653
1
static void gen_divu(DisasContext *dc, TCGv dest, TCGv srca, TCGv srcb) { TCGv sr_cy = tcg_temp_new(); TCGv t0 = tcg_temp_new(); tcg_gen_setcondi_tl(TCG_COND_EQ, sr_cy, srcb, 0); /* The result of divide-by-zero is undefined. Supress the host-side exception by dividing by 1. */ tcg_gen_or_tl(t0, srcb, sr_cy); tcg_gen_divu_tl(dest, srca, t0); tcg_temp_free(t0); tcg_gen_deposit_tl(cpu_sr, cpu_sr, sr_cy, ctz32(SR_CY), 1); gen_ove_cy(dc, sr_cy); tcg_temp_free(sr_cy); }
25,853
FFmpeg
0a41faa9a77dc83d8d933e99f1ba902ecd146e79
1
av_cold int vp56_free(AVCodecContext *avctx) { VP56Context *s = avctx->priv_data; int pt; av_freep(&s->qscale_table); av_freep(&s->above_blocks); av_freep(&s->macroblocks); av_freep(&s->edge_emu_buffer_alloc); if (s->framep[VP56_FRAME_GOLDEN]->data[0]) avctx->release_buffer(avctx, s->framep[VP56_FRAME_GOLDEN]); if (s->framep[VP56_FRAME_GOLDEN2]->data[0]) avctx->release_buffer(avctx, s->framep[VP56_FRAME_GOLDEN2]); if (s->framep[VP56_FRAME_PREVIOUS]->data[0]) avctx->release_buffer(avctx, s->framep[VP56_FRAME_PREVIOUS]); return 0;
25,855
FFmpeg
b5995856a4236c27f231210bb08d70688e045192
1
static void decode_block_params(DiracContext *s, DiracArith arith[8], DiracBlock *block, int stride, int x, int y) { int i; block->ref = pred_block_mode(block, stride, x, y, DIRAC_REF_MASK_REF1); block->ref ^= dirac_get_arith_bit(arith, CTX_PMODE_REF1); if (s->num_refs == 2) { block->ref |= pred_block_mode(block, stride, x, y, DIRAC_REF_MASK_REF2); block->ref ^= dirac_get_arith_bit(arith, CTX_PMODE_REF2) << 1; } if (!block->ref) { pred_block_dc(block, stride, x, y); for (i = 0; i < 3; i++) block->u.dc[i] += dirac_get_arith_int(arith+1+i, CTX_DC_F1, CTX_DC_DATA); return; } if (s->globalmc_flag) { block->ref |= pred_block_mode(block, stride, x, y, DIRAC_REF_MASK_GLOBAL); block->ref ^= dirac_get_arith_bit(arith, CTX_GLOBAL_BLOCK) << 2; } for (i = 0; i < s->num_refs; i++) if (block->ref & (i+1)) { if (block->ref & DIRAC_REF_MASK_GLOBAL) { global_mv(s, block, x, y, i); } else { pred_mv(block, stride, x, y, i); block->u.mv[i][0] += dirac_get_arith_int(arith + 4 + 2 * i, CTX_MV_F1, CTX_MV_DATA); block->u.mv[i][1] += dirac_get_arith_int(arith + 5 + 2 * i, CTX_MV_F1, CTX_MV_DATA); } } }
25,857
qemu
77cb0f5aafc8e6d0c6d3c339f381c9b7921648e0
1
static void adb_mouse_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); ADBDeviceClass *adc = ADB_DEVICE_CLASS(oc); ADBMouseClass *amc = ADB_MOUSE_CLASS(oc); amc->parent_realize = dc->realize; dc->realize = adb_mouse_realizefn; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); adc->devreq = adb_mouse_request; dc->reset = adb_mouse_reset; dc->vmsd = &vmstate_adb_mouse; }
25,858
qemu
3178e2755ec5a7fb1afe583fb6ac2622c2c42184
1
static int do_sd_create(char *filename, int64_t vdi_size, uint32_t base_vid, uint32_t *vdi_id, int snapshot, const char *addr, const char *port) { SheepdogVdiReq hdr; SheepdogVdiRsp *rsp = (SheepdogVdiRsp *)&hdr; int fd, ret; unsigned int wlen, rlen = 0; char buf[SD_MAX_VDI_LEN]; fd = connect_to_sdog(addr, port); if (fd < 0) { return fd; } memset(buf, 0, sizeof(buf)); strncpy(buf, filename, SD_MAX_VDI_LEN); memset(&hdr, 0, sizeof(hdr)); hdr.opcode = SD_OP_NEW_VDI; hdr.base_vdi_id = base_vid; wlen = SD_MAX_VDI_LEN; hdr.flags = SD_FLAG_CMD_WRITE; hdr.snapid = snapshot; hdr.data_length = wlen; hdr.vdi_size = vdi_size; ret = do_req(fd, (SheepdogReq *)&hdr, buf, &wlen, &rlen); closesocket(fd); if (ret) { return ret; } if (rsp->result != SD_RES_SUCCESS) { error_report("%s, %s", sd_strerror(rsp->result), filename); return -EIO; } if (vdi_id) { *vdi_id = rsp->vdi_id; } return 0; }
25,860
FFmpeg
68def00a6330e46eea2ee6735fa4ae91317e8f5c
1
int ff_rv34_decode_frame(AVCodecContext *avctx, void *data, int *got_picture_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; RV34DecContext *r = avctx->priv_data; MpegEncContext *s = &r->s; AVFrame *pict = data; SliceInfo si; int i; int slice_count; const uint8_t *slices_hdr = NULL; int last = 0; /* no supplementary picture */ if (buf_size == 0) { /* special case for last picture */ if (s->low_delay==0 && s->next_picture_ptr) { *pict = s->next_picture_ptr->f; s->next_picture_ptr = NULL; *got_picture_ptr = 1; } return 0; } if(!avctx->slice_count){ slice_count = (*buf++) + 1; slices_hdr = buf + 4; buf += 8 * slice_count; buf_size -= 1 + 8 * slice_count; }else slice_count = avctx->slice_count; //parse first slice header to check whether this frame can be decoded if(get_slice_offset(avctx, slices_hdr, 0) < 0 || get_slice_offset(avctx, slices_hdr, 0) > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n"); } init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), (buf_size-get_slice_offset(avctx, slices_hdr, 0))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){ av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n"); } if ((!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) && si.type == AV_PICTURE_TYPE_B) { av_log(avctx, AV_LOG_ERROR, "Invalid decoder state: B-frame without " "reference data.\n"); } if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) return avpkt->size; /* first slice */ if (si.start == 0) { if (s->mb_num_left > 0) { av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.\n", s->mb_num_left); ff_er_frame_end(s); ff_MPV_frame_end(s); } if (s->width != si.width || s->height != si.height) { int err; av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n", si.width, si.height); s->width = si.width; s->height = si.height; avcodec_set_dimensions(s->avctx, s->width, s->height); if ((err = ff_MPV_common_frame_size_change(s)) < 0) return err; if ((err = rv34_decoder_realloc(r)) < 0) return err; } s->pict_type = si.type ? si.type : AV_PICTURE_TYPE_I; if (ff_MPV_frame_start(s, s->avctx) < 0) return -1; ff_er_frame_start(s); if (!r->tmp_b_block_base) { int i; r->tmp_b_block_base = av_malloc(s->linesize * 48); for (i = 0; i < 2; i++) r->tmp_b_block_y[i] = r->tmp_b_block_base + i * 16 * s->linesize; for (i = 0; i < 4; i++) r->tmp_b_block_uv[i] = r->tmp_b_block_base + 32 * s->linesize + (i >> 1) * 8 * s->uvlinesize + (i & 1) * 16; } r->cur_pts = si.pts; if (s->pict_type != AV_PICTURE_TYPE_B) { r->last_pts = r->next_pts; r->next_pts = r->cur_pts; } else { int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts); int dist0 = GET_PTS_DIFF(r->cur_pts, r->last_pts); int dist1 = GET_PTS_DIFF(r->next_pts, r->cur_pts); if(!refdist){ r->mv_weight1 = r->mv_weight2 = r->weight1 = r->weight2 = 8192; r->scaled_weight = 0; }else{ r->mv_weight1 = (dist0 << 14) / refdist; r->mv_weight2 = (dist1 << 14) / refdist; if((r->mv_weight1|r->mv_weight2) & 511){ r->weight1 = r->mv_weight1; r->weight2 = r->mv_weight2; r->scaled_weight = 0; }else{ r->weight1 = r->mv_weight1 >> 9; r->weight2 = r->mv_weight2 >> 9; r->scaled_weight = 1; } } } s->mb_x = s->mb_y = 0; ff_thread_finish_setup(s->avctx); } else if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) { av_log(s->avctx, AV_LOG_ERROR, "Decoder needs full frames in frame " "multithreading mode (start MB is %d).\n", si.start); } for(i = 0; i < slice_count; i++){ int offset = get_slice_offset(avctx, slices_hdr, i); int size; if(i+1 == slice_count) size = buf_size - offset; else size = get_slice_offset(avctx, slices_hdr, i+1) - offset; if(offset < 0 || offset > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n"); break; } r->si.end = s->mb_width * s->mb_height; s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start; if(i+1 < slice_count){ if (get_slice_offset(avctx, slices_hdr, i+1) < 0 || get_slice_offset(avctx, slices_hdr, i+1) > buf_size) { av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n"); break; } init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0){ if(i+2 < slice_count) size = get_slice_offset(avctx, slices_hdr, i+2) - offset; else size = buf_size - offset; }else r->si.end = si.start; } if (size < 0 || size > buf_size - offset) { av_log(avctx, AV_LOG_ERROR, "Slice size is invalid\n"); break; } last = rv34_decode_slice(r, r->si.end, buf + offset, size); if(last) break; } if (s->current_picture_ptr) { if (last) { if(r->loop_filter) r->loop_filter(r, s->mb_height - 1); *got_picture_ptr = finish_frame(avctx, pict); } else if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) { av_log(avctx, AV_LOG_INFO, "marking unfished frame as finished\n"); /* always mark the current frame as finished, frame-mt supports * only complete frames */ ff_er_frame_end(s); ff_MPV_frame_end(s); s->mb_num_left = 0; ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0); } } return avpkt->size; }
25,861
FFmpeg
355e27e24dc88d6ba8f27501a34925d9d937a399
1
static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, void *data, int *got_frame, const uint8_t *buf, int buf_size) { /* Note, the only difference between the 15Bpp and 16Bpp */ /* Format is the pixel format, the packets are processed the same. */ FlicDecodeContext *s = avctx->priv_data; GetByteContext g2; int pixel_ptr; unsigned char palette_idx1; unsigned int frame_size; int num_chunks; unsigned int chunk_size; int chunk_type; int i, j, ret; int lines; int compressed_lines; signed short line_packets; int y_ptr; int byte_run; int pixel_skip; int pixel_countdown; unsigned char *pixels; int pixel; unsigned int pixel_limit; bytestream2_init(&g2, buf, buf_size); if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) return ret; pixels = s->frame->data[0]; pixel_limit = s->avctx->height * s->frame->linesize[0]; frame_size = bytestream2_get_le32(&g2); bytestream2_skip(&g2, 2); /* skip the magic number */ num_chunks = bytestream2_get_le16(&g2); bytestream2_skip(&g2, 8); /* skip padding */ if (frame_size > buf_size) frame_size = buf_size; frame_size -= 16; /* iterate through the chunks */ while ((frame_size > 0) && (num_chunks > 0) && bytestream2_get_bytes_left(&g2) >= 4) { int stream_ptr_after_chunk; chunk_size = bytestream2_get_le32(&g2); if (chunk_size > frame_size) { av_log(avctx, AV_LOG_WARNING, "Invalid chunk_size = %u > frame_size = %u\n", chunk_size, frame_size); chunk_size = frame_size; } stream_ptr_after_chunk = bytestream2_tell(&g2) - 4 + chunk_size; chunk_type = bytestream2_get_le16(&g2); switch (chunk_type) { case FLI_256_COLOR: case FLI_COLOR: /* For some reason, it seems that non-palettized flics do * include one of these chunks in their first frame. * Why I do not know, it seems rather extraneous. */ ff_dlog(avctx, "Unexpected Palette chunk %d in non-palettized FLC\n", chunk_type); bytestream2_skip(&g2, chunk_size - 6); break; case FLI_DELTA: case FLI_DTA_LC: y_ptr = 0; compressed_lines = bytestream2_get_le16(&g2); while (compressed_lines > 0) { if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk) break; line_packets = bytestream2_get_le16(&g2); if (line_packets < 0) { line_packets = -line_packets; y_ptr += line_packets * s->frame->linesize[0]; } else { compressed_lines--; pixel_ptr = y_ptr; CHECK_PIXEL_PTR(0); pixel_countdown = s->avctx->width; for (i = 0; i < line_packets; i++) { /* account for the skip bytes */ if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk) break; pixel_skip = bytestream2_get_byte(&g2); pixel_ptr += (pixel_skip*2); /* Pixel is 2 bytes wide */ pixel_countdown -= pixel_skip; byte_run = sign_extend(bytestream2_get_byte(&g2), 8); if (byte_run < 0) { byte_run = -byte_run; pixel = bytestream2_get_le16(&g2); CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++, pixel_countdown -= 2) { *((signed short*)(&pixels[pixel_ptr])) = pixel; pixel_ptr += 2; } } else { if (bytestream2_tell(&g2) + 2*byte_run > stream_ptr_after_chunk) break; CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++, pixel_countdown--) { *((signed short*)(&pixels[pixel_ptr])) = bytestream2_get_le16(&g2); pixel_ptr += 2; } } } y_ptr += s->frame->linesize[0]; } } break; case FLI_LC: av_log(avctx, AV_LOG_ERROR, "Unexpected FLI_LC chunk in non-palettized FLC\n"); bytestream2_skip(&g2, chunk_size - 6); break; case FLI_BLACK: /* set the whole frame to 0x0000 which is black in both 15Bpp and 16Bpp modes. */ memset(pixels, 0x0000, s->frame->linesize[0] * s->avctx->height); break; case FLI_BRUN: y_ptr = 0; for (lines = 0; lines < s->avctx->height; lines++) { pixel_ptr = y_ptr; /* disregard the line packets; instead, iterate through all * pixels on a row */ bytestream2_skip(&g2, 1); pixel_countdown = (s->avctx->width * 2); while (pixel_countdown > 0) { if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk) break; byte_run = sign_extend(bytestream2_get_byte(&g2), 8); if (byte_run > 0) { palette_idx1 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++) { pixels[pixel_ptr++] = palette_idx1; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) (linea%d)\n", pixel_countdown, lines); } } else { /* copy bytes if byte_run < 0 */ byte_run = -byte_run; if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk) break; CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++) { palette_idx1 = bytestream2_get_byte(&g2); pixels[pixel_ptr++] = palette_idx1; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n", pixel_countdown, lines); } } } /* Now FLX is strange, in that it is "byte" as opposed to "pixel" run length compressed. * This does not give us any good opportunity to perform word endian conversion * during decompression. So if it is required (i.e., this is not a LE target, we do * a second pass over the line here, swapping the bytes. */ #if HAVE_BIGENDIAN pixel_ptr = y_ptr; pixel_countdown = s->avctx->width; while (pixel_countdown > 0) { *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[pixel_ptr]); pixel_ptr += 2; } #endif y_ptr += s->frame->linesize[0]; } break; case FLI_DTA_BRUN: y_ptr = 0; for (lines = 0; lines < s->avctx->height; lines++) { pixel_ptr = y_ptr; /* disregard the line packets; instead, iterate through all * pixels on a row */ bytestream2_skip(&g2, 1); pixel_countdown = s->avctx->width; /* Width is in pixels, not bytes */ while (pixel_countdown > 0) { if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk) break; byte_run = sign_extend(bytestream2_get_byte(&g2), 8); if (byte_run > 0) { pixel = bytestream2_get_le16(&g2); CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++) { *((signed short*)(&pixels[pixel_ptr])) = pixel; pixel_ptr += 2; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", pixel_countdown); } } else { /* copy pixels if byte_run < 0 */ byte_run = -byte_run; if (bytestream2_tell(&g2) + 2 * byte_run > stream_ptr_after_chunk) break; CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++) { *((signed short*)(&pixels[pixel_ptr])) = bytestream2_get_le16(&g2); pixel_ptr += 2; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", pixel_countdown); } } } y_ptr += s->frame->linesize[0]; } break; case FLI_COPY: case FLI_DTA_COPY: /* copy the chunk (uncompressed frame) */ if (chunk_size - 6 > (unsigned int)(FFALIGN(s->avctx->width, 2) * s->avctx->height)*2) { av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \ "bigger than image, skipping chunk\n", chunk_size - 6); bytestream2_skip(&g2, chunk_size - 6); } else { for (y_ptr = 0; y_ptr < s->frame->linesize[0] * s->avctx->height; y_ptr += s->frame->linesize[0]) { pixel_countdown = s->avctx->width; pixel_ptr = 0; while (pixel_countdown > 0) { *((signed short*)(&pixels[y_ptr + pixel_ptr])) = bytestream2_get_le16(&g2); pixel_ptr += 2; pixel_countdown--; } if (s->avctx->width & 1) bytestream2_skip(&g2, 2); } } break; case FLI_MINI: /* some sort of a thumbnail? disregard this chunk... */ bytestream2_skip(&g2, chunk_size - 6); break; default: av_log(avctx, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", chunk_type); break; } if (stream_ptr_after_chunk - bytestream2_tell(&g2) >= 0) { bytestream2_skip(&g2, stream_ptr_after_chunk - bytestream2_tell(&g2)); } else { av_log(avctx, AV_LOG_ERROR, "Chunk overread\n"); break; } frame_size -= chunk_size; num_chunks--; } /* by the end of the chunk, the stream ptr should equal the frame * size (minus 1, possibly); if it doesn't, issue a warning */ if ((bytestream2_get_bytes_left(&g2) != 0) && (bytestream2_get_bytes_left(&g2) != 1)) av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \ "and final chunk ptr = %d\n", buf_size, bytestream2_tell(&g2)); if ((ret = av_frame_ref(data, s->frame)) < 0) return ret; *got_frame = 1; return buf_size; }
25,863
qemu
c5a49c63fa26e8825ad101dfe86339ae4c216539
1
void gen_intermediate_code(CPUState *cs, TranslationBlock * tb) { CPUSPARCState *env = cs->env_ptr; target_ulong pc_start, last_pc; DisasContext dc1, *dc = &dc1; int num_insns; int max_insns; unsigned int insn; memset(dc, 0, sizeof(DisasContext)); dc->tb = tb; pc_start = tb->pc; dc->pc = pc_start; last_pc = dc->pc; dc->npc = (target_ulong) tb->cs_base; dc->cc_op = CC_OP_DYNAMIC; dc->mem_idx = tb->flags & TB_FLAG_MMU_MASK; dc->def = &env->def; dc->fpu_enabled = tb_fpu_enabled(tb->flags); dc->address_mask_32bit = tb_am_enabled(tb->flags); dc->singlestep = (cs->singlestep_enabled || singlestep); #ifndef CONFIG_USER_ONLY dc->supervisor = (tb->flags & TB_FLAG_SUPER) != 0; #endif #ifdef TARGET_SPARC64 dc->fprs_dirty = 0; dc->asi = (tb->flags >> TB_FLAG_ASI_SHIFT) & 0xff; #ifndef CONFIG_USER_ONLY dc->hypervisor = (tb->flags & TB_FLAG_HYPER) != 0; #endif #endif num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } if (max_insns > TCG_MAX_INSNS) { max_insns = TCG_MAX_INSNS; } gen_tb_start(tb); do { if (dc->npc & JUMP_PC) { assert(dc->jump_pc[1] == dc->pc + 4); tcg_gen_insn_start(dc->pc, dc->jump_pc[0] | JUMP_PC); } else { tcg_gen_insn_start(dc->pc, dc->npc); } num_insns++; last_pc = dc->pc; if (unlikely(cpu_breakpoint_test(cs, dc->pc, BP_ANY))) { if (dc->pc != pc_start) { save_state(dc); } gen_helper_debug(cpu_env); tcg_gen_exit_tb(0); dc->is_br = 1; goto exit_gen_loop; } if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } insn = cpu_ldl_code(env, dc->pc); disas_sparc_insn(dc, insn); if (dc->is_br) break; /* if the next PC is different, we abort now */ if (dc->pc != (last_pc + 4)) break; /* if we reach a page boundary, we stop generation so that the PC of a TT_TFAULT exception is always in the right page */ if ((dc->pc & (TARGET_PAGE_SIZE - 1)) == 0) break; /* if single step mode, we generate only one instruction and generate an exception */ if (dc->singlestep) { break; } } while (!tcg_op_buf_full() && (dc->pc - pc_start) < (TARGET_PAGE_SIZE - 32) && num_insns < max_insns); exit_gen_loop: if (tb->cflags & CF_LAST_IO) { gen_io_end(); } if (!dc->is_br) { if (dc->pc != DYNAMIC_PC && (dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) { /* static PC and NPC: we can use direct chaining */ gen_goto_tb(dc, 0, dc->pc, dc->npc); } else { if (dc->pc != DYNAMIC_PC) { tcg_gen_movi_tl(cpu_pc, dc->pc); } save_npc(dc); tcg_gen_exit_tb(0); } } gen_tb_end(tb, num_insns); tb->size = last_pc + 4 - pc_start; tb->icount = num_insns; #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("--------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(cs, pc_start, last_pc + 4 - pc_start, 0); qemu_log("\n"); qemu_log_unlock(); } #endif }
25,864
qemu
de9b05b807918d40db9e26ddd6a54ad2978ac5b7
1
static void cortex_a15_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); set_feature(&cpu->env, ARM_FEATURE_V7); set_feature(&cpu->env, ARM_FEATURE_VFP4); set_feature(&cpu->env, ARM_FEATURE_VFP_FP16); set_feature(&cpu->env, ARM_FEATURE_NEON); set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); set_feature(&cpu->env, ARM_FEATURE_ARM_DIV); set_feature(&cpu->env, ARM_FEATURE_V7MP); set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); cpu->midr = 0x412fc0f1; cpu->reset_fpsid = 0x410430f0; cpu->mvfr0 = 0x10110222; cpu->mvfr1 = 0x11111111; cpu->ctr = 0x8444c004; cpu->reset_sctlr = 0x00c50078; cpu->id_pfr0 = 0x00001131; cpu->id_pfr1 = 0x00011011; cpu->id_dfr0 = 0x02010555; cpu->id_afr0 = 0x00000000; cpu->id_mmfr0 = 0x10201105; cpu->id_mmfr1 = 0x20000000; cpu->id_mmfr2 = 0x01240000; cpu->id_mmfr3 = 0x02102211; cpu->id_isar0 = 0x02101110; cpu->id_isar1 = 0x13112111; cpu->id_isar2 = 0x21232041; cpu->id_isar3 = 0x11112131; cpu->id_isar4 = 0x10011142; cpu->clidr = 0x0a200023; cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ define_arm_cp_regs(cpu, cortexa15_cp_reginfo); }
25,866
qemu
6f2d8978728c48ca46f5c01835438508aace5c64
1
void OPPROTO op_check_reservation_64 (void) { if ((uint64_t)env->reserve == (uint64_t)(T0 & ~0x00000003)) env->reserve = -1; RETURN(); }
25,867
FFmpeg
fb90785e98ac405198c0ca9fec133227f6d82826
1
static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { VP8Context *s = avctx->priv_data; int ret, mb_x, mb_y, i, y, referenced; enum AVDiscard skip_thresh; AVFrame *av_uninit(curframe), *prev_frame; release_queued_segmaps(s, 0); if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0) return ret; prev_frame = s->framep[VP56_FRAME_CURRENT]; referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT || s->update_altref == VP56_FRAME_CURRENT; skip_thresh = !referenced ? AVDISCARD_NONREF : !s->keyframe ? AVDISCARD_NONKEY : AVDISCARD_ALL; if (avctx->skip_frame >= skip_thresh) { s->invisible = 1; goto skip_decode; } s->deblock_filter = s->filter.level && avctx->skip_loop_filter < skip_thresh; // release no longer referenced frames for (i = 0; i < 5; i++) if (s->frames[i].data[0] && &s->frames[i] != prev_frame && &s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] && &s->frames[i] != s->framep[VP56_FRAME_GOLDEN] && &s->frames[i] != s->framep[VP56_FRAME_GOLDEN2]) vp8_release_frame(s, &s->frames[i], 1, 0); // find a free buffer for (i = 0; i < 5; i++) if (&s->frames[i] != prev_frame && &s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] && &s->frames[i] != s->framep[VP56_FRAME_GOLDEN] && &s->frames[i] != s->framep[VP56_FRAME_GOLDEN2]) { curframe = s->framep[VP56_FRAME_CURRENT] = &s->frames[i]; break; } if (i == 5) { av_log(avctx, AV_LOG_FATAL, "Ran out of free frames!\n"); abort(); } if (curframe->data[0]) vp8_release_frame(s, curframe, 1, 0); curframe->key_frame = s->keyframe; curframe->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; curframe->reference = referenced ? 3 : 0; if ((ret = vp8_alloc_frame(s, curframe))) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed!\n"); return ret; } // check if golden and altref are swapped if (s->update_altref != VP56_FRAME_NONE) { s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[s->update_altref]; } else { s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[VP56_FRAME_GOLDEN2]; } if (s->update_golden != VP56_FRAME_NONE) { s->next_framep[VP56_FRAME_GOLDEN] = s->framep[s->update_golden]; } else { s->next_framep[VP56_FRAME_GOLDEN] = s->framep[VP56_FRAME_GOLDEN]; } if (s->update_last) { s->next_framep[VP56_FRAME_PREVIOUS] = curframe; } else { s->next_framep[VP56_FRAME_PREVIOUS] = s->framep[VP56_FRAME_PREVIOUS]; } s->next_framep[VP56_FRAME_CURRENT] = curframe; ff_thread_finish_setup(avctx); // Given that arithmetic probabilities are updated every frame, it's quite likely // that the values we have on a random interframe are complete junk if we didn't // start decode on a keyframe. So just don't display anything rather than junk. if (!s->keyframe && (!s->framep[VP56_FRAME_PREVIOUS] || !s->framep[VP56_FRAME_GOLDEN] || !s->framep[VP56_FRAME_GOLDEN2])) { av_log(avctx, AV_LOG_WARNING, "Discarding interframe without a prior keyframe!\n"); return AVERROR_INVALIDDATA; } s->linesize = curframe->linesize[0]; s->uvlinesize = curframe->linesize[1]; if (!s->edge_emu_buffer) s->edge_emu_buffer = av_malloc(21*s->linesize); memset(s->top_nnz, 0, s->mb_width*sizeof(*s->top_nnz)); /* Zero macroblock structures for top/top-left prediction from outside the frame. */ memset(s->macroblocks + s->mb_height*2 - 1, 0, (s->mb_width+1)*sizeof(*s->macroblocks)); // top edge of 127 for intra prediction if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) { s->top_border[0][15] = s->top_border[0][23] = 127; memset(s->top_border[1]-1, 127, s->mb_width*sizeof(*s->top_border)+1); } memset(s->ref_count, 0, sizeof(s->ref_count)); if (s->keyframe) memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width*4); #define MARGIN (16 << 2) s->mv_min.y = -MARGIN; s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN; for (mb_y = 0; mb_y < s->mb_height; mb_y++) { VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions-1)]; VP8Macroblock *mb = s->macroblocks + (s->mb_height - mb_y - 1)*2; int mb_xy = mb_y*s->mb_width; uint8_t *dst[3] = { curframe->data[0] + 16*mb_y*s->linesize, curframe->data[1] + 8*mb_y*s->uvlinesize, curframe->data[2] + 8*mb_y*s->uvlinesize }; memset(mb - 1, 0, sizeof(*mb)); // zero left macroblock memset(s->left_nnz, 0, sizeof(s->left_nnz)); AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED*0x01010101); // left edge of 129 for intra prediction if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) { for (i = 0; i < 3; i++) for (y = 0; y < 16>>!!i; y++) dst[i][y*curframe->linesize[i]-1] = 129; if (mb_y == 1) // top left edge is also 129 s->top_border[0][15] = s->top_border[0][23] = s->top_border[0][31] = 129; } s->mv_min.x = -MARGIN; s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN; if (prev_frame && s->segmentation.enabled && !s->segmentation.update_map) ff_thread_await_progress(prev_frame, mb_y, 0); for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) { /* Prefetch the current frame, 4 MBs ahead */ s->dsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4); s->dsp.prefetch(dst[1] + (mb_x&7)*s->uvlinesize + 64, dst[2] - dst[1], 2); decode_mb_mode(s, mb, mb_x, mb_y, curframe->ref_index[0] + mb_xy, prev_frame && prev_frame->ref_index[0] ? prev_frame->ref_index[0] + mb_xy : NULL); prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_PREVIOUS); if (!mb->skip) decode_mb_coeffs(s, c, mb, s->top_nnz[mb_x], s->left_nnz); if (mb->mode <= MODE_I4x4) intra_predict(s, dst, mb, mb_x, mb_y); else inter_predict(s, dst, mb, mb_x, mb_y); prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN); if (!mb->skip) { idct_mb(s, dst, mb); } else { AV_ZERO64(s->left_nnz); AV_WN64(s->top_nnz[mb_x], 0); // array of 9, so unaligned // Reset DC block predictors if they would exist if the mb had coefficients if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) { s->left_nnz[8] = 0; s->top_nnz[mb_x][8] = 0; } } if (s->deblock_filter) filter_level_for_mb(s, mb, &s->filter_strength[mb_x]); prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN2); dst[0] += 16; dst[1] += 8; dst[2] += 8; s->mv_min.x -= 64; s->mv_max.x -= 64; } if (s->deblock_filter) { if (s->filter.simple) filter_mb_row_simple(s, curframe, mb_y); else filter_mb_row(s, curframe, mb_y); } s->mv_min.y -= 64; s->mv_max.y -= 64; ff_thread_report_progress(curframe, mb_y, 0); } ff_thread_report_progress(curframe, INT_MAX, 0); skip_decode: // if future frames don't use the updated probabilities, // reset them to the values we saved if (!s->update_probabilities) s->prob[0] = s->prob[1]; memcpy(&s->framep[0], &s->next_framep[0], sizeof(s->framep[0]) * 4); if (!s->invisible) { *(AVFrame*)data = *curframe; *data_size = sizeof(AVFrame); } return avpkt->size; }
25,870
qemu
3592fe0c919cf27a81d8e9f9b4f269553418bb01
1
static void serial_update_parameters(SerialState *s) { int speed, parity, data_bits, stop_bits, frame_size; QEMUSerialSetParams ssp; if (s->divider == 0) return; /* Start bit. */ frame_size = 1; if (s->lcr & 0x08) { /* Parity bit. */ frame_size++; if (s->lcr & 0x10) parity = 'E'; else parity = 'O'; } else { parity = 'N'; } if (s->lcr & 0x04) stop_bits = 2; else stop_bits = 1; data_bits = (s->lcr & 0x03) + 5; frame_size += data_bits + stop_bits; speed = s->baudbase / s->divider; ssp.speed = speed; ssp.parity = parity; ssp.data_bits = data_bits; ssp.stop_bits = stop_bits; s->char_transmit_time = (NANOSECONDS_PER_SECOND / speed) * frame_size; qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp); DPRINTF("speed=%d parity=%c data=%d stop=%d\n", speed, parity, data_bits, stop_bits); }
25,871
FFmpeg
ccce2248bf56692fc7bd436ca2c9acca772d486a
1
static void vp7_luma_dc_wht_c(int16_t block[4][4][16], int16_t dc[16]) { int i, a1, b1, c1, d1; int16_t tmp[16]; for (i = 0; i < 4; i++) { a1 = (dc[i * 4 + 0] + dc[i * 4 + 2]) * 23170; b1 = (dc[i * 4 + 0] - dc[i * 4 + 2]) * 23170; c1 = dc[i * 4 + 1] * 12540 - dc[i * 4 + 3] * 30274; d1 = dc[i * 4 + 1] * 30274 + dc[i * 4 + 3] * 12540; tmp[i * 4 + 0] = (a1 + d1) >> 14; tmp[i * 4 + 3] = (a1 - d1) >> 14; tmp[i * 4 + 1] = (b1 + c1) >> 14; tmp[i * 4 + 2] = (b1 - c1) >> 14; } for (i = 0; i < 4; i++) { a1 = (tmp[i + 0] + tmp[i + 8]) * 23170; b1 = (tmp[i + 0] - tmp[i + 8]) * 23170; c1 = tmp[i + 4] * 12540 - tmp[i + 12] * 30274; d1 = tmp[i + 4] * 30274 + tmp[i + 12] * 12540; AV_ZERO64(dc + i * 4); block[0][i][0] = (a1 + d1 + 0x20000) >> 18; block[3][i][0] = (a1 - d1 + 0x20000) >> 18; block[1][i][0] = (b1 + c1 + 0x20000) >> 18; block[2][i][0] = (b1 - c1 + 0x20000) >> 18; } }
25,873
FFmpeg
d3088e0fd8749788818cb5df92abaa3b12e409e1
1
static void generate_noise(G723_1_Context *p) { int i, j, idx, t; int off[SUBFRAMES]; int signs[SUBFRAMES / 2 * 11], pos[SUBFRAMES / 2 * 11]; int tmp[SUBFRAME_LEN * 2]; int16_t *vector_ptr; int64_t sum; int b0, c, delta, x, shift; p->pitch_lag[0] = cng_rand(&p->cng_random_seed, 21) + 123; p->pitch_lag[1] = cng_rand(&p->cng_random_seed, 19) + 123; for (i = 0; i < SUBFRAMES; i++) { p->subframe[i].ad_cb_gain = cng_rand(&p->cng_random_seed, 50) + 1; p->subframe[i].ad_cb_lag = cng_adaptive_cb_lag[i]; } for (i = 0; i < SUBFRAMES / 2; i++) { t = cng_rand(&p->cng_random_seed, 1 << 13); off[i * 2] = t & 1; off[i * 2 + 1] = ((t >> 1) & 1) + SUBFRAME_LEN; t >>= 2; for (j = 0; j < 11; j++) { signs[i * 11 + j] = (t & 1) * 2 - 1 << 14; t >>= 1; } } idx = 0; for (i = 0; i < SUBFRAMES; i++) { for (j = 0; j < SUBFRAME_LEN / 2; j++) tmp[j] = j; t = SUBFRAME_LEN / 2; for (j = 0; j < pulses[i]; j++, idx++) { int idx2 = cng_rand(&p->cng_random_seed, t); pos[idx] = tmp[idx2] * 2 + off[i]; tmp[idx2] = tmp[--t]; } } vector_ptr = p->audio + LPC_ORDER; memcpy(vector_ptr, p->prev_excitation, PITCH_MAX * sizeof(*p->excitation)); for (i = 0; i < SUBFRAMES; i += 2) { ff_g723_1_gen_acb_excitation(vector_ptr, vector_ptr, p->pitch_lag[i >> 1], &p->subframe[i], p->cur_rate); ff_g723_1_gen_acb_excitation(vector_ptr + SUBFRAME_LEN, vector_ptr + SUBFRAME_LEN, p->pitch_lag[i >> 1], &p->subframe[i + 1], p->cur_rate); t = 0; for (j = 0; j < SUBFRAME_LEN * 2; j++) t |= FFABS(vector_ptr[j]); t = FFMIN(t, 0x7FFF); if (!t) { shift = 0; } else { shift = -10 + av_log2(t); if (shift < -2) shift = -2; } sum = 0; if (shift < 0) { for (j = 0; j < SUBFRAME_LEN * 2; j++) { t = vector_ptr[j] << -shift; sum += t * t; tmp[j] = t; } } else { for (j = 0; j < SUBFRAME_LEN * 2; j++) { t = vector_ptr[j] >> shift; sum += t * t; tmp[j] = t; } } b0 = 0; for (j = 0; j < 11; j++) b0 += tmp[pos[(i / 2) * 11 + j]] * signs[(i / 2) * 11 + j]; b0 = b0 * 2 * 2979LL + (1 << 29) >> 30; // approximated division by 11 c = p->cur_gain * (p->cur_gain * SUBFRAME_LEN >> 5); if (shift * 2 + 3 >= 0) c >>= shift * 2 + 3; else c <<= -(shift * 2 + 3); c = (av_clipl_int32(sum << 1) - c) * 2979LL >> 15; delta = b0 * b0 * 2 - c; if (delta <= 0) { x = -b0; } else { delta = square_root(delta); x = delta - b0; t = delta + b0; if (FFABS(t) < FFABS(x)) x = -t; } shift++; if (shift < 0) x >>= -shift; else x <<= shift; x = av_clip(x, -10000, 10000); for (j = 0; j < 11; j++) { idx = (i / 2) * 11 + j; vector_ptr[pos[idx]] = av_clip_int16(vector_ptr[pos[idx]] + (x * signs[idx] >> 15)); } /* copy decoded data to serve as a history for the next decoded subframes */ memcpy(vector_ptr + PITCH_MAX, vector_ptr, sizeof(*vector_ptr) * SUBFRAME_LEN * 2); vector_ptr += SUBFRAME_LEN * 2; } /* Save the excitation for the next frame */ memcpy(p->prev_excitation, p->audio + LPC_ORDER + FRAME_LEN, PITCH_MAX * sizeof(*p->excitation)); }
25,874
qemu
f3a06403b82c7f036564e4caf18b52ce6885fcfb
1
struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count, int64_t count, Error **errp) { GuestFileHandle *gfh = guest_file_handle_find(handle, errp); GuestFileRead *read_data = NULL; guchar *buf; FILE *fh; size_t read_count; if (!gfh) { return NULL; } if (!has_count) { count = QGA_READ_COUNT_DEFAULT; } else if (count < 0) { error_setg(errp, "value '%" PRId64 "' is invalid for argument count", count); return NULL; } fh = gfh->fh; buf = g_malloc0(count+1); read_count = fread(buf, 1, count, fh); if (ferror(fh)) { error_setg_errno(errp, errno, "failed to read file"); slog("guest-file-read failed, handle: %" PRId64, handle); } else { buf[read_count] = 0; read_data = g_malloc0(sizeof(GuestFileRead)); read_data->count = read_count; read_data->eof = feof(fh); if (read_count) { read_data->buf_b64 = g_base64_encode(buf, read_count); } } g_free(buf); clearerr(fh); return read_data; }
25,875
qemu
908bb9497bcb5543930cc345326afff939a6ffa4
1
static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, int is_read) { BlockInterfaceErrorAction action = drive_get_on_error(req->dev->bs, is_read); VirtIOBlock *s = req->dev; if (action == BLOCK_ERR_IGNORE) { bdrv_mon_event(req->dev->bs, BDRV_ACTION_IGNORE, is_read); return 0; } if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC) || action == BLOCK_ERR_STOP_ANY) { req->next = s->rq; s->rq = req; bdrv_mon_event(req->dev->bs, BDRV_ACTION_STOP, is_read); vm_stop(0); } else { virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); bdrv_mon_event(req->dev->bs, BDRV_ACTION_REPORT, is_read); } return 1; }
25,876
FFmpeg
fd2982a0a01942091b2f08e17486ff4562f675a6
0
int av_read_pause(AVFormatContext *s) { if (s->iformat->read_pause) return s->iformat->read_pause(s); if (s->pb && s->pb->read_pause) return av_url_read_fpause(s->pb, 1); return AVERROR(ENOSYS); }
25,877
qemu
a6b3167fa0e825aebb5a7cd8b437b6d41584a196
1
static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf, BlockCompletionFunc *cb, void *opaque) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = iscsilun->iscsi; struct iscsi_data data; IscsiAIOCB *acb; acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); acb->iscsilun = iscsilun; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; acb->ioh = buf; if (req != SG_IO) { iscsi_ioctl_handle_emulated(acb, req, buf); return &acb->common; acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s", iscsi_get_error(iscsi)); memset(acb->task, 0, sizeof(struct scsi_task)); switch (acb->ioh->dxfer_direction) { case SG_DXFER_TO_DEV: acb->task->xfer_dir = SCSI_XFER_WRITE; break; case SG_DXFER_FROM_DEV: acb->task->xfer_dir = SCSI_XFER_READ; break; default: acb->task->xfer_dir = SCSI_XFER_NONE; break; acb->task->cdb_size = acb->ioh->cmd_len; memcpy(&acb->task->cdb[0], acb->ioh->cmdp, acb->ioh->cmd_len); acb->task->expxferlen = acb->ioh->dxfer_len; data.size = 0; if (acb->task->xfer_dir == SCSI_XFER_WRITE) { if (acb->ioh->iovec_count == 0) { data.data = acb->ioh->dxferp; data.size = acb->ioh->dxfer_len; } else { scsi_task_set_iov_out(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task, iscsi_aio_ioctl_cb, (data.size > 0) ? &data : NULL, acb) != 0) { scsi_free_scsi_task(acb->task); /* tell libiscsi to read straight into the buffer we got from ioctl */ if (acb->task->xfer_dir == SCSI_XFER_READ) { if (acb->ioh->iovec_count == 0) { scsi_task_add_data_in_buffer(acb->task, acb->ioh->dxfer_len, acb->ioh->dxferp); } else { scsi_task_set_iov_in(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); iscsi_set_events(iscsilun); return &acb->common;
25,878
qemu
9732baf67850dac57dfc7dc8980bf408889a8973
1
static void *thread_function(void *data) { GMainLoop *loop; loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(loop); return NULL; }
25,879
qemu
63ea491d4efc1e02cda3d335db3a46c81adf14ee
1
static DisplaySurface* sdl_create_displaysurface(int width, int height) { DisplaySurface *surface = (DisplaySurface*) g_malloc0(sizeof(DisplaySurface)); if (surface == NULL) { fprintf(stderr, "sdl_create_displaysurface: malloc failed\n"); exit(1); } surface->width = width; surface->height = height; if (scaling_active) { int linesize; PixelFormat pf; if (host_format.BytesPerPixel != 2 && host_format.BytesPerPixel != 4) { linesize = width * 4; pf = qemu_default_pixelformat(32); } else { linesize = width * host_format.BytesPerPixel; pf = sdl_to_qemu_pixelformat(&host_format); } qemu_alloc_display(surface, width, height, linesize, pf, 0); return surface; } if (host_format.BitsPerPixel == 16) do_sdl_resize(width, height, 16); else do_sdl_resize(width, height, 32); surface->pf = sdl_to_qemu_pixelformat(real_screen->format); surface->linesize = real_screen->pitch; surface->data = real_screen->pixels; #ifdef HOST_WORDS_BIGENDIAN surface->flags = QEMU_REALPIXELS_FLAG | QEMU_BIG_ENDIAN_FLAG; #else surface->flags = QEMU_REALPIXELS_FLAG; #endif allocator = 1; return surface; }
25,880
FFmpeg
0058584580b87feb47898e60e4b80c7f425882ad
0
static int _get_transform_coeffs(uint8_t *exps, uint8_t *bap, float chcoeff, float *samples, int start, int end, int dith_flag, GetBitContext *gb, dither_state *state) { int16_t mantissa; int i; int gcode; mant_group l3_grp, l5_grp, l11_grp; for (i = 0; i < 3; i++) l3_grp.gcodes[i] = l5_grp.gcodes[i] = l11_grp.gcodes[i] = -1; l3_grp.gcptr = l5_grp.gcptr = 3; l11_grp.gcptr = 2; i = 0; while (i < start) samples[i++] = 0; for (i = start; i < end; i++) { switch (bap[i]) { case 0: if (!dith_flag) mantissa = 0; else mantissa = dither_int16(state); samples[i] = to_float(exps[i], mantissa) * chcoeff; break; case 1: if (l3_grp.gcptr > 2) { gcode = get_bits(gb, qntztab[1]); if (gcode > 26) return -1; l3_grp.gcodes[0] = gcode / 9; l3_grp.gcodes[1] = (gcode % 9) / 3; l3_grp.gcodes[2] = (gcode % 9) % 3; l3_grp.gcptr = 0; } mantissa = l3_q_tab[l3_grp.gcodes[l3_grp.gcptr++]]; samples[i] = to_float(exps[i], mantissa) * chcoeff; break; case 2: if (l5_grp.gcptr > 2) { gcode = get_bits(gb, qntztab[2]); if (gcode > 124) return -1; l5_grp.gcodes[0] = gcode / 25; l5_grp.gcodes[1] = (gcode % 25) / 5; l5_grp.gcodes[2] = (gcode % 25) % 5; l5_grp.gcptr = 0; } mantissa = l5_q_tab[l5_grp.gcodes[l5_grp.gcptr++]]; samples[i] = to_float(exps[i], mantissa) * chcoeff; break; case 3: mantissa = get_bits(gb, qntztab[3]); if (mantissa > 6) return -1; mantissa = l7_q_tab[mantissa]; samples[i] = to_float(exps[i], mantissa); break; case 4: if (l11_grp.gcptr > 1) { gcode = get_bits(gb, qntztab[4]); if (gcode > 120) return -1; l11_grp.gcodes[0] = gcode / 11; l11_grp.gcodes[1] = gcode % 11; } mantissa = l11_q_tab[l11_grp.gcodes[l11_grp.gcptr++]]; samples[i] = to_float(exps[i], mantissa) * chcoeff; break; case 5: mantissa = get_bits(gb, qntztab[5]); if (mantissa > 14) return -1; mantissa = l15_q_tab[mantissa]; samples[i] = to_float(exps[i], mantissa) * chcoeff; break; default: mantissa = get_bits(gb, qntztab[bap[i]]) << (16 - qntztab[bap[i]]); samples[i] = to_float(exps[i], mantissa) * chcoeff; break; } } i = end; while (i < 256) samples[i++] = 0; return 0; }
25,881
FFmpeg
0493e42eb2f9fbf42d0aee0b48a84f81f19fb7fa
0
static void DEF(avg, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h) { MOVQ_BFE(mm6); __asm__ volatile( "lea (%3, %3), %%"REG_a" \n\t" "movq (%1), %%mm0 \n\t" ".p2align 3 \n\t" "1: \n\t" "movq (%1, %3), %%mm1 \n\t" "movq (%1, %%"REG_a"), %%mm2 \n\t" PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5) "movq (%2), %%mm3 \n\t" PAVGB_MMX(%%mm3, %%mm4, %%mm0, %%mm6) "movq (%2, %3), %%mm3 \n\t" PAVGB_MMX(%%mm3, %%mm5, %%mm1, %%mm6) "movq %%mm0, (%2) \n\t" "movq %%mm1, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "movq (%1, %3), %%mm1 \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5) "movq (%2), %%mm3 \n\t" PAVGB_MMX(%%mm3, %%mm4, %%mm2, %%mm6) "movq (%2, %3), %%mm3 \n\t" PAVGB_MMX(%%mm3, %%mm5, %%mm1, %%mm6) "movq %%mm2, (%2) \n\t" "movq %%mm1, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "subl $4, %0 \n\t" "jnz 1b \n\t" :"+g"(h), "+S"(pixels), "+D"(block) :"r"((x86_reg)line_size) :REG_a, "memory"); }
25,882