label
int64 0
1
| func1
stringlengths 23
97k
| id
int64 0
27.3k
|
---|---|---|
0 | static void virtio_setup(uint64_t dev_info) { struct schib schib; int i; int r; bool found = false; bool check_devno = false; uint16_t dev_no = -1; blk_schid.one = 1; if (dev_info != -1) { check_devno = true; dev_no = dev_info & 0xffff; debug_print_int("device no. ", dev_no); blk_schid.ssid = (dev_info >> 16) & 0x3; if (blk_schid.ssid != 0) { debug_print_int("ssid ", blk_schid.ssid); if (enable_mss_facility() != 0) { virtio_panic("Failed to enable mss facility\n"); } } } for (i = 0; i < 0x10000; i++) { blk_schid.sch_no = i; r = stsch_err(blk_schid, &schib); if (r == 3) { break; } if (schib.pmcw.dnv) { if (!check_devno || (schib.pmcw.dev == dev_no)) { if (virtio_is_blk(blk_schid)) { found = true; break; } } } } if (!found) { virtio_panic("No virtio-blk device found!\n"); } virtio_setup_block(blk_schid); } | 26,002 |
0 | void memory_region_init_ram(MemoryRegion *mr, const char *name, uint64_t size) { memory_region_init(mr, name, size); mr->ram = true; mr->terminates = true; mr->destructor = memory_region_destructor_ram; mr->ram_addr = qemu_ram_alloc(size, mr); mr->backend_registered = true; } | 26,004 |
0 | static uint64_t pchip_read(void *opaque, hwaddr addr, unsigned size) { TyphoonState *s = opaque; uint64_t ret = 0; if (addr & 4) { return s->latch_tmp; } switch (addr) { case 0x0000: /* WSBA0: Window Space Base Address Register. */ ret = s->pchip.win[0].base_addr; break; case 0x0040: /* WSBA1 */ ret = s->pchip.win[1].base_addr; break; case 0x0080: /* WSBA2 */ ret = s->pchip.win[2].base_addr; break; case 0x00c0: /* WSBA3 */ ret = s->pchip.win[3].base_addr; break; case 0x0100: /* WSM0: Window Space Mask Register. */ ret = s->pchip.win[0].mask; break; case 0x0140: /* WSM1 */ ret = s->pchip.win[1].mask; break; case 0x0180: /* WSM2 */ ret = s->pchip.win[2].mask; break; case 0x01c0: /* WSM3 */ ret = s->pchip.win[3].mask; break; case 0x0200: /* TBA0: Translated Base Address Register. */ ret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10; break; case 0x0240: /* TBA1 */ ret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10; break; case 0x0280: /* TBA2 */ ret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10; break; case 0x02c0: /* TBA3 */ ret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10; break; case 0x0300: /* PCTL: Pchip Control Register. */ ret = s->pchip.ctl; break; case 0x0340: /* PLAT: Pchip Master Latency Register. */ break; case 0x03c0: /* PERROR: Pchip Error Register. */ break; case 0x0400: /* PERRMASK: Pchip Error Mask Register. */ break; case 0x0440: /* PERRSET: Pchip Error Set Register. */ break; case 0x0480: /* TLBIV: Translation Buffer Invalidate Virtual Register (WO). */ break; case 0x04c0: /* TLBIA: Translation Buffer Invalidate All Register (WO). */ break; case 0x0500: /* PMONCTL */ case 0x0540: /* PMONCNT */ case 0x0800: /* SPRST */ break; default: cpu_unassigned_access(current_cpu, addr, false, false, 0, size); return -1; } s->latch_tmp = ret >> 32; return ret; } | 26,005 |
0 | void cpu_x86_update_dr7(CPUX86State *env, uint32_t new_dr7) { int i; for (i = 0; i < DR7_MAX_BP; i++) { hw_breakpoint_remove(env, i); } env->dr[7] = new_dr7; for (i = 0; i < DR7_MAX_BP; i++) { hw_breakpoint_insert(env, i); } } | 26,006 |
0 | int ffurl_get_file_handle(URLContext *h) { if (!h->prot->url_get_file_handle) return -1; return h->prot->url_get_file_handle(h); } | 26,009 |
0 | static void cmd_read_toc_pma_atip(IDEState *s, uint8_t* buf) { int format, msf, start_track, len; uint64_t total_sectors = s->nb_sectors >> 2; int max_len; if (total_sectors == 0) { ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); return; } max_len = ube16_to_cpu(buf + 7); format = buf[9] >> 6; msf = (buf[1] >> 1) & 1; start_track = buf[6]; switch(format) { case 0: len = cdrom_read_toc(total_sectors, buf, msf, start_track); if (len < 0) goto error_cmd; ide_atapi_cmd_reply(s, len, max_len); break; case 1: /* multi session : only a single session defined */ memset(buf, 0, 12); buf[1] = 0x0a; buf[2] = 0x01; buf[3] = 0x01; ide_atapi_cmd_reply(s, 12, max_len); break; case 2: len = cdrom_read_toc_raw(total_sectors, buf, msf, start_track); if (len < 0) goto error_cmd; ide_atapi_cmd_reply(s, len, max_len); break; default: error_cmd: ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET); } } | 26,010 |
0 | av_cold void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp) { ff_rv34dsp_init(c, dsp); c->put_pixels_tab[0][ 0] = dsp->put_h264_qpel_pixels_tab[0][0]; c->put_pixels_tab[0][ 1] = put_rv40_qpel16_mc10_c; c->put_pixels_tab[0][ 2] = dsp->put_h264_qpel_pixels_tab[0][2]; c->put_pixels_tab[0][ 3] = put_rv40_qpel16_mc30_c; c->put_pixels_tab[0][ 4] = put_rv40_qpel16_mc01_c; c->put_pixels_tab[0][ 5] = put_rv40_qpel16_mc11_c; c->put_pixels_tab[0][ 6] = put_rv40_qpel16_mc21_c; c->put_pixels_tab[0][ 7] = put_rv40_qpel16_mc31_c; c->put_pixels_tab[0][ 8] = dsp->put_h264_qpel_pixels_tab[0][8]; c->put_pixels_tab[0][ 9] = put_rv40_qpel16_mc12_c; c->put_pixels_tab[0][10] = put_rv40_qpel16_mc22_c; c->put_pixels_tab[0][11] = put_rv40_qpel16_mc32_c; c->put_pixels_tab[0][12] = put_rv40_qpel16_mc03_c; c->put_pixels_tab[0][13] = put_rv40_qpel16_mc13_c; c->put_pixels_tab[0][14] = put_rv40_qpel16_mc23_c; c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_c; c->avg_pixels_tab[0][ 0] = dsp->avg_h264_qpel_pixels_tab[0][0]; c->avg_pixels_tab[0][ 1] = avg_rv40_qpel16_mc10_c; c->avg_pixels_tab[0][ 2] = dsp->avg_h264_qpel_pixels_tab[0][2]; c->avg_pixels_tab[0][ 3] = avg_rv40_qpel16_mc30_c; c->avg_pixels_tab[0][ 4] = avg_rv40_qpel16_mc01_c; c->avg_pixels_tab[0][ 5] = avg_rv40_qpel16_mc11_c; c->avg_pixels_tab[0][ 6] = avg_rv40_qpel16_mc21_c; c->avg_pixels_tab[0][ 7] = avg_rv40_qpel16_mc31_c; c->avg_pixels_tab[0][ 8] = dsp->avg_h264_qpel_pixels_tab[0][8]; c->avg_pixels_tab[0][ 9] = avg_rv40_qpel16_mc12_c; c->avg_pixels_tab[0][10] = avg_rv40_qpel16_mc22_c; c->avg_pixels_tab[0][11] = avg_rv40_qpel16_mc32_c; c->avg_pixels_tab[0][12] = avg_rv40_qpel16_mc03_c; c->avg_pixels_tab[0][13] = avg_rv40_qpel16_mc13_c; c->avg_pixels_tab[0][14] = avg_rv40_qpel16_mc23_c; c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_c; c->put_pixels_tab[1][ 0] = dsp->put_h264_qpel_pixels_tab[1][0]; c->put_pixels_tab[1][ 1] = put_rv40_qpel8_mc10_c; c->put_pixels_tab[1][ 2] = dsp->put_h264_qpel_pixels_tab[1][2]; c->put_pixels_tab[1][ 3] = put_rv40_qpel8_mc30_c; c->put_pixels_tab[1][ 4] = put_rv40_qpel8_mc01_c; c->put_pixels_tab[1][ 5] = put_rv40_qpel8_mc11_c; c->put_pixels_tab[1][ 6] = put_rv40_qpel8_mc21_c; c->put_pixels_tab[1][ 7] = put_rv40_qpel8_mc31_c; c->put_pixels_tab[1][ 8] = dsp->put_h264_qpel_pixels_tab[1][8]; c->put_pixels_tab[1][ 9] = put_rv40_qpel8_mc12_c; c->put_pixels_tab[1][10] = put_rv40_qpel8_mc22_c; c->put_pixels_tab[1][11] = put_rv40_qpel8_mc32_c; c->put_pixels_tab[1][12] = put_rv40_qpel8_mc03_c; c->put_pixels_tab[1][13] = put_rv40_qpel8_mc13_c; c->put_pixels_tab[1][14] = put_rv40_qpel8_mc23_c; c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_c; c->avg_pixels_tab[1][ 0] = dsp->avg_h264_qpel_pixels_tab[1][0]; c->avg_pixels_tab[1][ 1] = avg_rv40_qpel8_mc10_c; c->avg_pixels_tab[1][ 2] = dsp->avg_h264_qpel_pixels_tab[1][2]; c->avg_pixels_tab[1][ 3] = avg_rv40_qpel8_mc30_c; c->avg_pixels_tab[1][ 4] = avg_rv40_qpel8_mc01_c; c->avg_pixels_tab[1][ 5] = avg_rv40_qpel8_mc11_c; c->avg_pixels_tab[1][ 6] = avg_rv40_qpel8_mc21_c; c->avg_pixels_tab[1][ 7] = avg_rv40_qpel8_mc31_c; c->avg_pixels_tab[1][ 8] = dsp->avg_h264_qpel_pixels_tab[1][8]; c->avg_pixels_tab[1][ 9] = avg_rv40_qpel8_mc12_c; c->avg_pixels_tab[1][10] = avg_rv40_qpel8_mc22_c; c->avg_pixels_tab[1][11] = avg_rv40_qpel8_mc32_c; c->avg_pixels_tab[1][12] = avg_rv40_qpel8_mc03_c; c->avg_pixels_tab[1][13] = avg_rv40_qpel8_mc13_c; c->avg_pixels_tab[1][14] = avg_rv40_qpel8_mc23_c; c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_c; c->put_chroma_pixels_tab[0] = put_rv40_chroma_mc8_c; c->put_chroma_pixels_tab[1] = put_rv40_chroma_mc4_c; c->avg_chroma_pixels_tab[0] = avg_rv40_chroma_mc8_c; c->avg_chroma_pixels_tab[1] = avg_rv40_chroma_mc4_c; c->rv40_weight_pixels_tab[0][0] = rv40_weight_func_rnd_16; c->rv40_weight_pixels_tab[0][1] = rv40_weight_func_rnd_8; c->rv40_weight_pixels_tab[1][0] = rv40_weight_func_nornd_16; c->rv40_weight_pixels_tab[1][1] = rv40_weight_func_nornd_8; c->rv40_weak_loop_filter[0] = rv40_h_weak_loop_filter; c->rv40_weak_loop_filter[1] = rv40_v_weak_loop_filter; c->rv40_strong_loop_filter[0] = rv40_h_strong_loop_filter; c->rv40_strong_loop_filter[1] = rv40_v_strong_loop_filter; c->rv40_loop_filter_strength[0] = rv40_h_loop_filter_strength; c->rv40_loop_filter_strength[1] = rv40_v_loop_filter_strength; if (ARCH_X86) ff_rv40dsp_init_x86(c, dsp); if (HAVE_NEON) ff_rv40dsp_init_neon(c, dsp); } | 26,011 |
0 | static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) { int i, consumed, ret = 0; s->ref = NULL; s->eos = 0; /* split the input packet into NAL units, so we know the upper bound on the * number of slices in the frame */ s->nb_nals = 0; while (length >= 4) { HEVCNAL *nal; int extract_length = 0; if (s->is_nalff) { int i; for (i = 0; i < s->nal_length_size; i++) extract_length = (extract_length << 8) | buf[i]; buf += s->nal_length_size; length -= s->nal_length_size; if (extract_length > length) { av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n"); ret = AVERROR_INVALIDDATA; goto fail; } } else { if (buf[2] == 0) { length--; buf++; continue; } if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { ret = AVERROR_INVALIDDATA; goto fail; } buf += 3; length -= 3; } if (!s->is_nalff) extract_length = length; if (s->nals_allocated < s->nb_nals + 1) { int new_size = s->nals_allocated + 1; HEVCNAL *tmp = av_realloc_array(s->nals, new_size, sizeof(*tmp)); if (!tmp) { ret = AVERROR(ENOMEM); goto fail; } s->nals = tmp; memset(s->nals + s->nals_allocated, 0, (new_size - s->nals_allocated) * sizeof(*tmp)); av_reallocp_array(&s->skipped_bytes_nal, new_size, sizeof(*s->skipped_bytes_nal)); av_reallocp_array(&s->skipped_bytes_pos_size_nal, new_size, sizeof(*s->skipped_bytes_pos_size_nal)); av_reallocp_array(&s->skipped_bytes_pos_nal, new_size, sizeof(*s->skipped_bytes_pos_nal)); s->skipped_bytes_pos_size_nal[s->nals_allocated] = 1024; // initial buffer size s->skipped_bytes_pos_nal[s->nals_allocated] = av_malloc_array(s->skipped_bytes_pos_size_nal[s->nals_allocated], sizeof(*s->skipped_bytes_pos)); s->nals_allocated = new_size; } s->skipped_bytes_pos_size = s->skipped_bytes_pos_size_nal[s->nb_nals]; s->skipped_bytes_pos = s->skipped_bytes_pos_nal[s->nb_nals]; nal = &s->nals[s->nb_nals]; consumed = extract_rbsp(s, buf, extract_length, nal); s->skipped_bytes_nal[s->nb_nals] = s->skipped_bytes; s->skipped_bytes_pos_size_nal[s->nb_nals] = s->skipped_bytes_pos_size; s->skipped_bytes_pos_nal[s->nb_nals++] = s->skipped_bytes_pos; if (consumed < 0) { ret = consumed; goto fail; } ret = init_get_bits8(&s->HEVClc->gb, nal->data, nal->size); if (ret < 0) goto fail; hls_nal_unit(s); if (s->nal_unit_type == NAL_EOS_NUT || s->nal_unit_type == NAL_EOB_NUT) s->eos = 1; buf += consumed; length -= consumed; } /* parse the NAL units */ for (i = 0; i < s->nb_nals; i++) { int ret; s->skipped_bytes = s->skipped_bytes_nal[i]; s->skipped_bytes_pos = s->skipped_bytes_pos_nal[i]; ret = decode_nal_unit(s, s->nals[i].data, s->nals[i].size); if (ret < 0) { av_log(s->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", i); if (s->avctx->err_recognition & AV_EF_EXPLODE) goto fail; } } fail: if (s->ref && s->threads_type == FF_THREAD_FRAME) ff_thread_report_progress(&s->ref->tf, INT_MAX, 0); return ret; } | 26,012 |
0 | static always_inline void gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, int search_pc) { DisasContext ctx, *ctxp = &ctx; opc_handler_t **table, *handler; target_ulong pc_start; uint16_t *gen_opc_end; CPUBreakpoint *bp; int j, lj = -1; int num_insns; int max_insns; pc_start = tb->pc; gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; ctx.nip = pc_start; ctx.tb = tb; ctx.exception = POWERPC_EXCP_NONE; ctx.spr_cb = env->spr_cb; ctx.mem_idx = env->mmu_idx; ctx.access_type = -1; ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0; #if defined(TARGET_PPC64) ctx.sf_mode = msr_sf; #endif ctx.fpu_enabled = msr_fp; if ((env->flags & POWERPC_FLAG_SPE) && msr_spe) ctx.spe_enabled = msr_spe; else ctx.spe_enabled = 0; if ((env->flags & POWERPC_FLAG_VRE) && msr_vr) ctx.altivec_enabled = msr_vr; else ctx.altivec_enabled = 0; if ((env->flags & POWERPC_FLAG_SE) && msr_se) ctx.singlestep_enabled = CPU_SINGLE_STEP; else ctx.singlestep_enabled = 0; if ((env->flags & POWERPC_FLAG_BE) && msr_be) ctx.singlestep_enabled |= CPU_BRANCH_STEP; if (unlikely(env->singlestep_enabled)) ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP; #if defined (DO_SINGLE_STEP) && 0 /* Single step trace mode */ msr_se = 1; #endif num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) max_insns = CF_COUNT_MASK; gen_icount_start(); /* Set env in case of segfault during code fetch */ while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) { if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { TAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == ctx.nip) { gen_debug_exception(ctxp); break; } } } if (unlikely(search_pc)) { j = gen_opc_ptr - gen_opc_buf; if (lj < j) { lj++; while (lj < j) gen_opc_instr_start[lj++] = 0; gen_opc_pc[lj] = ctx.nip; gen_opc_instr_start[lj] = 1; gen_opc_icount[lj] = num_insns; } } LOG_DISAS("----------------\n"); LOG_DISAS("nip=" ADDRX " super=%d ir=%d\n", ctx.nip, ctx.mem_idx, (int)msr_ir); if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) gen_io_start(); if (unlikely(ctx.le_mode)) { ctx.opcode = bswap32(ldl_code(ctx.nip)); } else { ctx.opcode = ldl_code(ctx.nip); } LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n", ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), little_endian ? "little" : "big"); ctx.nip += 4; table = env->opcodes; num_insns++; handler = table[opc1(ctx.opcode)]; if (is_indirect_opcode(handler)) { table = ind_table(handler); handler = table[opc2(ctx.opcode)]; if (is_indirect_opcode(handler)) { table = ind_table(handler); handler = table[opc3(ctx.opcode)]; } } /* Is opcode *REALLY* valid ? */ if (unlikely(handler->handler == &gen_invalid)) { if (qemu_log_enabled()) { qemu_log("invalid/unsupported opcode: " "%02x - %02x - %02x (%08x) " ADDRX " %d\n", opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir); } else { printf("invalid/unsupported opcode: " "%02x - %02x - %02x (%08x) " ADDRX " %d\n", opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir); } } else { if (unlikely((ctx.opcode & handler->inval) != 0)) { if (qemu_log_enabled()) { qemu_log("invalid bits: %08x for opcode: " "%02x - %02x - %02x (%08x) " ADDRX "\n", ctx.opcode & handler->inval, opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.opcode, ctx.nip - 4); } else { printf("invalid bits: %08x for opcode: " "%02x - %02x - %02x (%08x) " ADDRX "\n", ctx.opcode & handler->inval, opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.opcode, ctx.nip - 4); } gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL); break; } } (*(handler->handler))(&ctx); #if defined(DO_PPC_STATISTICS) handler->count++; #endif /* Check trace mode exceptions */ if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP && (ctx.nip <= 0x100 || ctx.nip > 0xF00) && ctx.exception != POWERPC_SYSCALL && ctx.exception != POWERPC_EXCP_TRAP && ctx.exception != POWERPC_EXCP_BRANCH)) { gen_exception(ctxp, POWERPC_EXCP_TRACE); } else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) || (env->singlestep_enabled) || num_insns >= max_insns)) { /* if we reach a page boundary or are single stepping, stop * generation */ break; } #if defined (DO_SINGLE_STEP) break; #endif } if (tb->cflags & CF_LAST_IO) gen_io_end(); if (ctx.exception == POWERPC_EXCP_NONE) { gen_goto_tb(&ctx, 0, ctx.nip); } else if (ctx.exception != POWERPC_EXCP_BRANCH) { if (unlikely(env->singlestep_enabled)) { gen_debug_exception(ctxp); } /* Generate the return instruction */ tcg_gen_exit_tb(0); } gen_icount_end(tb, num_insns); *gen_opc_ptr = INDEX_op_end; if (unlikely(search_pc)) { j = gen_opc_ptr - gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; } else { tb->size = ctx.nip - pc_start; tb->icount = num_insns; } #if defined(DEBUG_DISAS) qemu_log_mask(CPU_LOG_TB_CPU, "---------------- excp: %04x\n", ctx.exception); log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0); if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { int flags; flags = env->bfd_mach; flags |= ctx.le_mode << 16; qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(pc_start, ctx.nip - pc_start, flags); qemu_log("\n"); } #endif } | 26,013 |
0 | static int slb_lookup (CPUPPCState *env, target_ulong eaddr, target_ulong *vsid, target_ulong *page_mask, int *attr) { target_phys_addr_t sr_base; target_ulong mask; uint64_t tmp64; uint32_t tmp; int n, ret; int slb_nr; ret = -5; sr_base = env->spr[SPR_ASR]; #if defined(DEBUG_SLB) if (loglevel != 0) { fprintf(logfile, "%s: eaddr " ADDRX " base " PADDRX "\n", __func__, eaddr, sr_base); } #endif mask = 0x0000000000000000ULL; /* Avoid gcc warning */ slb_nr = env->slb_nr; for (n = 0; n < slb_nr; n++) { tmp64 = ldq_phys(sr_base); tmp = ldl_phys(sr_base + 8); #if defined(DEBUG_SLB) if (loglevel != 0) { fprintf(logfile, "%s: seg %d " PADDRX " %016" PRIx64 " %08" PRIx32 "\n", __func__, n, sr_base, tmp64, tmp); } #endif if (tmp64 & 0x0000000008000000ULL) { /* SLB entry is valid */ switch (tmp64 & 0x0000000006000000ULL) { case 0x0000000000000000ULL: /* 256 MB segment */ mask = 0xFFFFFFFFF0000000ULL; break; case 0x0000000002000000ULL: /* 1 TB segment */ mask = 0xFFFF000000000000ULL; break; case 0x0000000004000000ULL: case 0x0000000006000000ULL: /* Reserved => segment is invalid */ continue; } if ((eaddr & mask) == (tmp64 & mask)) { /* SLB match */ *vsid = ((tmp64 << 24) | (tmp >> 8)) & 0x0003FFFFFFFFFFFFULL; *page_mask = ~mask; *attr = tmp & 0xFF; ret = 0; break; } } sr_base += 12; } return ret; } | 26,014 |
0 | static const mon_cmd_t *monitor_parse_command(Monitor *mon, const char *cmdline, QDict *qdict) { const char *p, *typestr; int c; const mon_cmd_t *cmd; char cmdname[256]; char buf[1024]; char *key; #ifdef DEBUG monitor_printf(mon, "command='%s'\n", cmdline); #endif /* extract the command name */ p = get_command_name(cmdline, cmdname, sizeof(cmdname)); if (!p) return NULL; /* find the command */ for(cmd = mon_cmds; cmd->name != NULL; cmd++) { if (compare_cmd(cmdname, cmd->name)) break; } if (cmd->name == NULL) { monitor_printf(mon, "unknown command: '%s'\n", cmdname); return NULL; } /* parse the parameters */ typestr = cmd->args_type; for(;;) { typestr = key_get_info(typestr, &key); if (!typestr) break; c = *typestr; typestr++; switch(c) { case 'F': case 'B': case 's': { int ret; while (qemu_isspace(*p)) p++; if (*typestr == '?') { typestr++; if (*p == '\0') { /* no optional string: NULL argument */ break; } } ret = get_str(buf, sizeof(buf), &p); if (ret < 0) { switch(c) { case 'F': monitor_printf(mon, "%s: filename expected\n", cmdname); break; case 'B': monitor_printf(mon, "%s: block device name expected\n", cmdname); break; default: monitor_printf(mon, "%s: string expected\n", cmdname); break; } goto fail; } qdict_put(qdict, key, qstring_from_str(buf)); } break; case '/': { int count, format, size; while (qemu_isspace(*p)) p++; if (*p == '/') { /* format found */ p++; count = 1; if (qemu_isdigit(*p)) { count = 0; while (qemu_isdigit(*p)) { count = count * 10 + (*p - '0'); p++; } } size = -1; format = -1; for(;;) { switch(*p) { case 'o': case 'd': case 'u': case 'x': case 'i': case 'c': format = *p++; break; case 'b': size = 1; p++; break; case 'h': size = 2; p++; break; case 'w': size = 4; p++; break; case 'g': case 'L': size = 8; p++; break; default: goto next; } } next: if (*p != '\0' && !qemu_isspace(*p)) { monitor_printf(mon, "invalid char in format: '%c'\n", *p); goto fail; } if (format < 0) format = default_fmt_format; if (format != 'i') { /* for 'i', not specifying a size gives -1 as size */ if (size < 0) size = default_fmt_size; default_fmt_size = size; } default_fmt_format = format; } else { count = 1; format = default_fmt_format; if (format != 'i') { size = default_fmt_size; } else { size = -1; } } qdict_put(qdict, "count", qint_from_int(count)); qdict_put(qdict, "format", qint_from_int(format)); qdict_put(qdict, "size", qint_from_int(size)); } break; case 'i': case 'l': { int64_t val; while (qemu_isspace(*p)) p++; if (*typestr == '?' || *typestr == '.') { if (*typestr == '?') { if (*p == '\0') { typestr++; break; } } else { if (*p == '.') { p++; while (qemu_isspace(*p)) p++; } else { typestr++; break; } } typestr++; } if (get_expr(mon, &val, &p)) goto fail; /* Check if 'i' is greater than 32-bit */ if ((c == 'i') && ((val >> 32) & 0xffffffff)) { monitor_printf(mon, "\'%s\' has failed: ", cmdname); monitor_printf(mon, "integer is for 32-bit values\n"); goto fail; } qdict_put(qdict, key, qint_from_int(val)); } break; case '-': { const char *tmp = p; int has_option, skip_key = 0; /* option */ c = *typestr++; if (c == '\0') goto bad_type; while (qemu_isspace(*p)) p++; has_option = 0; if (*p == '-') { p++; if(c != *p) { if(!is_valid_option(p, typestr)) { monitor_printf(mon, "%s: unsupported option -%c\n", cmdname, *p); goto fail; } else { skip_key = 1; } } if(skip_key) { p = tmp; } else { p++; has_option = 1; } } qdict_put(qdict, key, qint_from_int(has_option)); } break; default: bad_type: monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c); goto fail; } qemu_free(key); key = NULL; } /* check that all arguments were parsed */ while (qemu_isspace(*p)) p++; if (*p != '\0') { monitor_printf(mon, "%s: extraneous characters at the end of line\n", cmdname); goto fail; } return cmd; fail: qemu_free(key); return NULL; } | 26,015 |
0 | static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { BDRVQcowState *s = bs->opaque; int index_in_cluster; uint64_t cluster_offset; int ret = 0, n; struct iovec hd_iov; QEMUIOVector hd_qiov; uint8_t *buf; void *orig_buf; s->cluster_cache_offset = -1; /* disable compressed cache */ /* We must always copy the iov when encrypting, so we * don't modify the original data buffer during encryption */ if (bs->encrypted || qiov->niov > 1) { buf = orig_buf = qemu_try_blockalign(bs, qiov->size); if (buf == NULL) { return -ENOMEM; } qemu_iovec_to_buf(qiov, 0, buf, qiov->size); } else { orig_buf = NULL; buf = (uint8_t *)qiov->iov->iov_base; } qemu_co_mutex_lock(&s->lock); while (nb_sectors != 0) { index_in_cluster = sector_num & (s->cluster_sectors - 1); n = s->cluster_sectors - index_in_cluster; if (n > nb_sectors) { n = nb_sectors; } cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0, index_in_cluster, index_in_cluster + n); if (!cluster_offset || (cluster_offset & 511) != 0) { ret = -EIO; break; } if (bs->encrypted) { Error *err = NULL; assert(s->cipher); if (encrypt_sectors(s, sector_num, buf, n, true, &err) < 0) { error_free(err); ret = -EIO; break; } } hd_iov.iov_base = (void *)buf; hd_iov.iov_len = n * 512; qemu_iovec_init_external(&hd_qiov, &hd_iov, 1); qemu_co_mutex_unlock(&s->lock); ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + index_in_cluster, n, &hd_qiov); qemu_co_mutex_lock(&s->lock); if (ret < 0) { break; } ret = 0; nb_sectors -= n; sector_num += n; buf += n * 512; } qemu_co_mutex_unlock(&s->lock); qemu_vfree(orig_buf); return ret; } | 26,016 |
0 | static void start_auth_vencrypt_subauth(VncState *vs) { switch (vs->vd->subauth) { case VNC_AUTH_VENCRYPT_TLSNONE: case VNC_AUTH_VENCRYPT_X509NONE: VNC_DEBUG("Accept TLS auth none\n"); vnc_write_u32(vs, 0); /* Accept auth completion */ start_client_init(vs); break; case VNC_AUTH_VENCRYPT_TLSVNC: case VNC_AUTH_VENCRYPT_X509VNC: VNC_DEBUG("Start TLS auth VNC\n"); start_auth_vnc(vs); break; #ifdef CONFIG_VNC_SASL case VNC_AUTH_VENCRYPT_TLSSASL: case VNC_AUTH_VENCRYPT_X509SASL: VNC_DEBUG("Start TLS auth SASL\n"); return start_auth_sasl(vs); #endif /* CONFIG_VNC_SASL */ default: /* Should not be possible, but just in case */ VNC_DEBUG("Reject subauth %d server bug\n", vs->vd->auth); vnc_write_u8(vs, 1); if (vs->minor >= 8) { static const char err[] = "Unsupported authentication type"; vnc_write_u32(vs, sizeof(err)); vnc_write(vs, err, sizeof(err)); } vnc_client_error(vs); } } | 26,017 |
0 | static void disas_test_b_imm(DisasContext *s, uint32_t insn) { unsigned int bit_pos, op, rt; uint64_t addr; int label_match; TCGv_i64 tcg_cmp; bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5); op = extract32(insn, 24, 1); /* 0: TBZ; 1: TBNZ */ addr = s->pc + sextract32(insn, 5, 14) * 4 - 4; rt = extract32(insn, 0, 5); tcg_cmp = tcg_temp_new_i64(); tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, rt), (1ULL << bit_pos)); label_match = gen_new_label(); tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, tcg_cmp, 0, label_match); tcg_temp_free_i64(tcg_cmp); gen_goto_tb(s, 0, s->pc); gen_set_label(label_match); gen_goto_tb(s, 1, addr); } | 26,019 |
0 | static QObject *parse_escape(JSONParserContext *ctxt, QList **tokens, va_list *ap) { QObject *token = NULL, *obj; QList *working = qlist_copy(*tokens); if (ap == NULL) { goto out; } token = qlist_pop(working); if (token == NULL) { goto out; } if (token_is_escape(token, "%p")) { obj = va_arg(*ap, QObject *); } else if (token_is_escape(token, "%i")) { obj = QOBJECT(qbool_from_int(va_arg(*ap, int))); } else if (token_is_escape(token, "%d")) { obj = QOBJECT(qint_from_int(va_arg(*ap, int))); } else if (token_is_escape(token, "%ld")) { obj = QOBJECT(qint_from_int(va_arg(*ap, long))); } else if (token_is_escape(token, "%lld") || token_is_escape(token, "%I64d")) { obj = QOBJECT(qint_from_int(va_arg(*ap, long long))); } else if (token_is_escape(token, "%s")) { obj = QOBJECT(qstring_from_str(va_arg(*ap, const char *))); } else if (token_is_escape(token, "%f")) { obj = QOBJECT(qfloat_from_double(va_arg(*ap, double))); } else { goto out; } qobject_decref(token); QDECREF(*tokens); *tokens = working; return obj; out: qobject_decref(token); QDECREF(working); return NULL; } | 26,020 |
0 | ParallelState *parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, CharDriverState *chr) { ParallelState *s; int io_sw; s = qemu_mallocz(sizeof(ParallelState)); s->irq = irq; s->chr = chr; s->it_shift = it_shift; qemu_register_reset(parallel_reset, s); io_sw = cpu_register_io_memory(parallel_mm_read_sw, parallel_mm_write_sw, s, DEVICE_NATIVE_ENDIAN); cpu_register_physical_memory(base, 8 << it_shift, io_sw); return s; } | 26,021 |
0 | int float32_le( float32 a, float32 b STATUS_PARAM ) { flag aSign, bSign; if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) ) || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) ) ) { float_raise( float_flag_invalid STATUS_VAR); return 0; } aSign = extractFloat32Sign( a ); bSign = extractFloat32Sign( b ); if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 ); return ( a == b ) || ( aSign ^ ( a < b ) ); } | 26,022 |
0 | static void ttafilter_init(TTAContext *s, TTAFilter *c, int32_t shift) { memset(c, 0, sizeof(TTAFilter)); if (s->pass) { int i; for (i = 0; i < 8; i++) c->qm[i] = sign_extend(s->crc_pass[i], 8); } c->shift = shift; c->round = shift_1[shift-1]; // c->round = 1 << (shift - 1); } | 26,023 |
0 | USBDevice *usb_msd_init(const char *filename, BlockDriverState **pbs) { MSDState *s; BlockDriverState *bdrv; BlockDriver *drv = NULL; const char *p1; char fmt[32]; p1 = strchr(filename, ':'); if (p1++) { const char *p2; if (strstart(filename, "format=", &p2)) { int len = MIN(p1 - p2, sizeof(fmt)); pstrcpy(fmt, len, p2); drv = bdrv_find_format(fmt); if (!drv) { printf("invalid format %s\n", fmt); return NULL; } } else if (*filename != ':') { printf("unrecognized USB mass-storage option %s\n", filename); return NULL; } filename = p1; } if (!*filename) { printf("block device specification needed\n"); return NULL; } s = qemu_mallocz(sizeof(MSDState)); bdrv = bdrv_new("usb"); if (bdrv_open2(bdrv, filename, 0, drv) < 0) goto fail; s->bs = bdrv; *pbs = bdrv; s->dev.speed = USB_SPEED_FULL; s->dev.handle_packet = usb_generic_handle_packet; s->dev.handle_reset = usb_msd_handle_reset; s->dev.handle_control = usb_msd_handle_control; s->dev.handle_data = usb_msd_handle_data; s->dev.handle_destroy = usb_msd_handle_destroy; snprintf(s->dev.devname, sizeof(s->dev.devname), "QEMU USB MSD(%.16s)", filename); s->scsi_dev = scsi_disk_init(bdrv, 0, usb_msd_command_complete, s); usb_msd_handle_reset((USBDevice *)s); return (USBDevice *)s; fail: qemu_free(s); return NULL; } | 26,024 |
0 | static int buffered_rate_limit(void *opaque) { QEMUFileBuffered *s = opaque; int ret; ret = qemu_file_get_error(s->file); if (ret) { return ret; } if (s->bytes_xfer > s->xfer_limit) return 1; return 0; } | 26,025 |
0 | static int alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index, void **refcount_block) { BDRVQcowState *s = bs->opaque; unsigned int refcount_table_index; int ret; BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC); /* Find the refcount block for the given cluster */ refcount_table_index = cluster_index >> s->refcount_block_bits; if (refcount_table_index < s->refcount_table_size) { uint64_t refcount_block_offset = s->refcount_table[refcount_table_index] & REFT_OFFSET_MASK; /* If it's already there, we're done */ if (refcount_block_offset) { if (offset_into_cluster(s, refcount_block_offset)) { qcow2_signal_corruption(bs, true, -1, -1, "Refblock offset %#" PRIx64 " unaligned (reftable index: " "%#x)", refcount_block_offset, refcount_table_index); return -EIO; } return load_refcount_block(bs, refcount_block_offset, refcount_block); } } /* * If we came here, we need to allocate something. Something is at least * a cluster for the new refcount block. It may also include a new refcount * table if the old refcount table is too small. * * Note that allocating clusters here needs some special care: * * - We can't use the normal qcow2_alloc_clusters(), it would try to * increase the refcount and very likely we would end up with an endless * recursion. Instead we must place the refcount blocks in a way that * they can describe them themselves. * * - We need to consider that at this point we are inside update_refcounts * and potentially doing an initial refcount increase. This means that * some clusters have already been allocated by the caller, but their * refcount isn't accurate yet. If we allocate clusters for metadata, we * need to return -EAGAIN to signal the caller that it needs to restart * the search for free clusters. * * - alloc_clusters_noref and qcow2_free_clusters may load a different * refcount block into the cache */ *refcount_block = NULL; /* We write to the refcount table, so we might depend on L2 tables */ ret = qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { return ret; } /* Allocate the refcount block itself and mark it as used */ int64_t new_block = alloc_clusters_noref(bs, s->cluster_size); if (new_block < 0) { return new_block; } #ifdef DEBUG_ALLOC2 fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64 " at %" PRIx64 "\n", refcount_table_index, cluster_index << s->cluster_bits, new_block); #endif if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) { /* Zero the new refcount block before updating it */ ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block, refcount_block); if (ret < 0) { goto fail_block; } memset(*refcount_block, 0, s->cluster_size); /* The block describes itself, need to update the cache */ int block_index = (new_block >> s->cluster_bits) & (s->refcount_block_size - 1); s->set_refcount(*refcount_block, block_index, 1); } else { /* Described somewhere else. This can recurse at most twice before we * arrive at a block that describes itself. */ ret = update_refcount(bs, new_block, s->cluster_size, 1, false, QCOW2_DISCARD_NEVER); if (ret < 0) { goto fail_block; } ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail_block; } /* Initialize the new refcount block only after updating its refcount, * update_refcount uses the refcount cache itself */ ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block, refcount_block); if (ret < 0) { goto fail_block; } memset(*refcount_block, 0, s->cluster_size); } /* Now the new refcount block needs to be written to disk */ BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE); qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, *refcount_block); ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail_block; } /* If the refcount table is big enough, just hook the block up there */ if (refcount_table_index < s->refcount_table_size) { uint64_t data64 = cpu_to_be64(new_block); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP); ret = bdrv_pwrite_sync(bs->file, s->refcount_table_offset + refcount_table_index * sizeof(uint64_t), &data64, sizeof(data64)); if (ret < 0) { goto fail_block; } s->refcount_table[refcount_table_index] = new_block; /* The new refcount block may be where the caller intended to put its * data, so let it restart the search. */ return -EAGAIN; } ret = qcow2_cache_put(bs, s->refcount_block_cache, refcount_block); if (ret < 0) { goto fail_block; } /* * If we come here, we need to grow the refcount table. Again, a new * refcount table needs some space and we can't simply allocate to avoid * endless recursion. * * Therefore let's grab new refcount blocks at the end of the image, which * will describe themselves and the new refcount table. This way we can * reference them only in the new table and do the switch to the new * refcount table at once without producing an inconsistent state in * between. */ BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW); /* Calculate the number of refcount blocks needed so far; this will be the * basis for calculating the index of the first cluster used for the * self-describing refcount structures which we are about to create. * * Because we reached this point, there cannot be any refcount entries for * cluster_index or higher indices yet. However, because new_block has been * allocated to describe that cluster (and it will assume this role later * on), we cannot use that index; also, new_block may actually have a higher * cluster index than cluster_index, so it needs to be taken into account * here (and 1 needs to be added to its value because that cluster is used). */ uint64_t blocks_used = DIV_ROUND_UP(MAX(cluster_index + 1, (new_block >> s->cluster_bits) + 1), s->refcount_block_size); if (blocks_used > QCOW_MAX_REFTABLE_SIZE / sizeof(uint64_t)) { return -EFBIG; } /* And now we need at least one block more for the new metadata */ uint64_t table_size = next_refcount_table_size(s, blocks_used + 1); uint64_t last_table_size; uint64_t blocks_clusters; do { uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t)); blocks_clusters = 1 + ((table_clusters + s->refcount_block_size - 1) / s->refcount_block_size); uint64_t meta_clusters = table_clusters + blocks_clusters; last_table_size = table_size; table_size = next_refcount_table_size(s, blocks_used + ((meta_clusters + s->refcount_block_size - 1) / s->refcount_block_size)); } while (last_table_size != table_size); #ifdef DEBUG_ALLOC2 fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n", s->refcount_table_size, table_size); #endif /* Create the new refcount table and blocks */ uint64_t meta_offset = (blocks_used * s->refcount_block_size) * s->cluster_size; uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size; uint64_t *new_table = g_try_new0(uint64_t, table_size); void *new_blocks = g_try_malloc0(blocks_clusters * s->cluster_size); assert(table_size > 0 && blocks_clusters > 0); if (new_table == NULL || new_blocks == NULL) { ret = -ENOMEM; goto fail_table; } /* Fill the new refcount table */ memcpy(new_table, s->refcount_table, s->refcount_table_size * sizeof(uint64_t)); new_table[refcount_table_index] = new_block; int i; for (i = 0; i < blocks_clusters; i++) { new_table[blocks_used + i] = meta_offset + (i * s->cluster_size); } /* Fill the refcount blocks */ uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t)); int block = 0; for (i = 0; i < table_clusters + blocks_clusters; i++) { s->set_refcount(new_blocks, block++, 1); } /* Write refcount blocks to disk */ BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS); ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks, blocks_clusters * s->cluster_size); g_free(new_blocks); new_blocks = NULL; if (ret < 0) { goto fail_table; } /* Write refcount table to disk */ for(i = 0; i < table_size; i++) { cpu_to_be64s(&new_table[i]); } BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE); ret = bdrv_pwrite_sync(bs->file, table_offset, new_table, table_size * sizeof(uint64_t)); if (ret < 0) { goto fail_table; } for(i = 0; i < table_size; i++) { be64_to_cpus(&new_table[i]); } /* Hook up the new refcount table in the qcow2 header */ uint8_t data[12]; cpu_to_be64w((uint64_t*)data, table_offset); cpu_to_be32w((uint32_t*)(data + 8), table_clusters); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE); ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset), data, sizeof(data)); if (ret < 0) { goto fail_table; } /* And switch it in memory */ uint64_t old_table_offset = s->refcount_table_offset; uint64_t old_table_size = s->refcount_table_size; g_free(s->refcount_table); s->refcount_table = new_table; s->refcount_table_size = table_size; s->refcount_table_offset = table_offset; /* Free old table. */ qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t), QCOW2_DISCARD_OTHER); ret = load_refcount_block(bs, new_block, refcount_block); if (ret < 0) { return ret; } /* If we were trying to do the initial refcount update for some cluster * allocation, we might have used the same clusters to store newly * allocated metadata. Make the caller search some new space. */ return -EAGAIN; fail_table: g_free(new_blocks); g_free(new_table); fail_block: if (*refcount_block != NULL) { qcow2_cache_put(bs, s->refcount_block_cache, refcount_block); } return ret; } | 26,026 |
0 | static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, int a_avail, int c_avail, int16_t **dc_val_ptr, int *dir_ptr) { int a, b, c, wrap, pred; int16_t *dc_val; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int q1, q2 = 0; wrap = s->block_wrap[n]; dc_val = s->dc_val[0] + s->block_index[n]; /* B A * C X */ c = dc_val[ - 1]; b = dc_val[ - 1 - wrap]; a = dc_val[ - wrap]; /* scale predictors if needed */ q1 = s->current_picture.f.qscale_table[mb_pos]; if (c_avail && (n != 1 && n != 3)) { q2 = s->current_picture.f.qscale_table[mb_pos - 1]; if (q2 && q2 != q1) c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; } if (a_avail && (n != 2 && n != 3)) { q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride]; if (q2 && q2 != q1) a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; } if (a_avail && c_avail && (n != 3)) { int off = mb_pos; if (n != 1) off--; if (n != 2) off -= s->mb_stride; q2 = s->current_picture.f.qscale_table[off]; if (q2 && q2 != q1) b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; } if (a_avail && c_avail) { if (abs(a - b) <= abs(b - c)) { pred = c; *dir_ptr = 1; // left } else { pred = a; *dir_ptr = 0; // top } } else if (a_avail) { pred = a; *dir_ptr = 0; // top } else if (c_avail) { pred = c; *dir_ptr = 1; // left } else { pred = 0; *dir_ptr = 1; // left } /* update predictor */ *dc_val_ptr = &dc_val[0]; return pred; } | 26,028 |
1 | static void external_snapshot_prepare(BlkTransactionState *common, Error **errp) { BlockDriver *drv; int flags, ret; QDict *options = NULL; Error *local_err = NULL; bool has_device = false; const char *device; bool has_node_name = false; const char *node_name; bool has_snapshot_node_name = false; const char *snapshot_node_name; const char *new_image_file; const char *format = "qcow2"; enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; ExternalSnapshotState *state = DO_UPCAST(ExternalSnapshotState, common, common); TransactionAction *action = common->action; /* get parameters */ g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); has_device = action->blockdev_snapshot_sync->has_device; device = action->blockdev_snapshot_sync->device; has_node_name = action->blockdev_snapshot_sync->has_node_name; node_name = action->blockdev_snapshot_sync->node_name; has_snapshot_node_name = action->blockdev_snapshot_sync->has_snapshot_node_name; snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name; new_image_file = action->blockdev_snapshot_sync->snapshot_file; if (action->blockdev_snapshot_sync->has_format) { format = action->blockdev_snapshot_sync->format; } if (action->blockdev_snapshot_sync->has_mode) { mode = action->blockdev_snapshot_sync->mode; } /* start processing */ drv = bdrv_find_format(format); if (!drv) { error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); return; } state->old_bs = bdrv_lookup_bs(has_device ? device : NULL, has_node_name ? node_name : NULL, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); return; } if (has_node_name && !has_snapshot_node_name) { error_setg(errp, "New snapshot node name missing"); return; } if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) { error_setg(errp, "New snapshot node name already existing"); return; } if (!bdrv_is_inserted(state->old_bs)) { error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); return; } if (bdrv_in_use(state->old_bs)) { error_set(errp, QERR_DEVICE_IN_USE, device); return; } if (!bdrv_is_read_only(state->old_bs)) { if (bdrv_flush(state->old_bs)) { error_set(errp, QERR_IO_ERROR); return; } } if (!bdrv_is_first_non_filter(state->old_bs)) { error_set(errp, QERR_FEATURE_DISABLED, "snapshot"); return; } flags = state->old_bs->open_flags; /* create new image w/backing file */ if (mode != NEW_IMAGE_MODE_EXISTING) { bdrv_img_create(new_image_file, format, state->old_bs->filename, state->old_bs->drv->format_name, NULL, -1, flags, &local_err, false); if (error_is_set(&local_err)) { error_propagate(errp, local_err); return; } } if (has_snapshot_node_name) { options = qdict_new(); qdict_put(options, "node-name", qstring_from_str(snapshot_node_name)); } /* We will manually add the backing_hd field to the bs later */ state->new_bs = bdrv_new(""); /* TODO Inherit bs->options or only take explicit options with an * extended QMP command? */ ret = bdrv_open(state->new_bs, new_image_file, options, flags | BDRV_O_NO_BACKING, drv, &local_err); if (ret != 0) { error_propagate(errp, local_err); } QDECREF(options); } | 26,029 |
0 | int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) { int i; // reserve 1 byte for terminating 0 buflen = FFMIN(buflen - 1, maxlen); for (i = 0; i < buflen; i++) if (!(buf[i] = avio_r8(s))) return i + 1; if (buflen) buf[i] = 0; for (; i < maxlen; i++) if (!avio_r8(s)) return i + 1; return maxlen; } | 26,032 |
0 | static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]) { /* load a few things into local vars to make the code more readable? and faster */ const int srcW= c->srcW; const int dstW= c->dstW; const int dstH= c->dstH; const int chrDstW= c->chrDstW; const int chrSrcW= c->chrSrcW; const int lumXInc= c->lumXInc; const int chrXInc= c->chrXInc; const enum PixelFormat dstFormat= c->dstFormat; const int flags= c->flags; int16_t *vLumFilterPos= c->vLumFilterPos; int16_t *vChrFilterPos= c->vChrFilterPos; int16_t *hLumFilterPos= c->hLumFilterPos; int16_t *hChrFilterPos= c->hChrFilterPos; int16_t *vLumFilter= c->vLumFilter; int16_t *vChrFilter= c->vChrFilter; int16_t *hLumFilter= c->hLumFilter; int16_t *hChrFilter= c->hChrFilter; int32_t *lumMmxFilter= c->lumMmxFilter; int32_t *chrMmxFilter= c->chrMmxFilter; int32_t av_unused *alpMmxFilter= c->alpMmxFilter; const int vLumFilterSize= c->vLumFilterSize; const int vChrFilterSize= c->vChrFilterSize; const int hLumFilterSize= c->hLumFilterSize; const int hChrFilterSize= c->hChrFilterSize; int16_t **lumPixBuf= c->lumPixBuf; int16_t **chrPixBuf= c->chrPixBuf; int16_t **alpPixBuf= c->alpPixBuf; const int vLumBufSize= c->vLumBufSize; const int vChrBufSize= c->vChrBufSize; uint8_t *formatConvBuffer= c->formatConvBuffer; const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample; const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); int lastDstY; uint32_t *pal=c->pal_yuv; /* vars which will change and which we need to store back in the context */ int dstY= c->dstY; int lumBufIndex= c->lumBufIndex; int chrBufIndex= c->chrBufIndex; int lastInLumBuf= c->lastInLumBuf; int lastInChrBuf= c->lastInChrBuf; if (isPacked(c->srcFormat)) { src[0]= src[1]= src[2]= src[3]= src[0]; srcStride[0]= srcStride[1]= srcStride[2]= srcStride[3]= srcStride[0]; } srcStride[1]<<= c->vChrDrop; srcStride[2]<<= c->vChrDrop; DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n", src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3], dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]); DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n", srcSliceY, srcSliceH, dstY, dstH); DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n", vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize); if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) { static int warnedAlready=0; //FIXME move this into the context perhaps if (flags & SWS_PRINT_INFO && !warnedAlready) { av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n" " ->cannot do aligned memory accesses anymore\n"); warnedAlready=1; } } /* Note the user might start scaling the picture in the middle so this will not get executed. This is not really intended but works currently, so people might do it. */ if (srcSliceY ==0) { lumBufIndex=-1; chrBufIndex=-1; dstY=0; lastInLumBuf= -1; lastInChrBuf= -1; } lastDstY= dstY; for (;dstY < dstH; dstY++) { unsigned char *dest =dst[0]+dstStride[0]*dstY; const int chrDstY= dstY>>c->chrDstVSubSample; unsigned char *uDest=dst[1]+dstStride[1]*chrDstY; unsigned char *vDest=dst[2]+dstStride[2]*chrDstY; unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL; const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)]; const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1; // Last line needed as input int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input int enough_lines; //handle holes (FAST_BILINEAR & weird filters) if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1; assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1); assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1); DEBUG_BUFFERS("dstY: %d\n", dstY); DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n", firstLumSrcY, lastLumSrcY, lastInLumBuf); DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n", firstChrSrcY, lastChrSrcY, lastInChrBuf); // Do we have enough lines in this slice to output the dstY line enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample); if (!enough_lines) { lastLumSrcY = srcSliceY + srcSliceH - 1; lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1; DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n", lastLumSrcY, lastChrSrcY); } //Do horizontal scaling while(lastInLumBuf < lastLumSrcY) { const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3]; lumBufIndex++; assert(lumBufIndex < 2*vLumBufSize); assert(lastInLumBuf + 1 - srcSliceY < srcSliceH); assert(lastInLumBuf + 1 - srcSliceY >= 0); RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, formatConvBuffer, pal, 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf) RENAME(hyscale)(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, formatConvBuffer, pal, 1); lastInLumBuf++; DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n", lumBufIndex, lastInLumBuf); } while(lastInChrBuf < lastChrSrcY) { const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1]; const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2]; chrBufIndex++; assert(chrBufIndex < 2*vChrBufSize); assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH)); assert(lastInChrBuf + 1 - chrSrcSliceY >= 0); //FIXME replace parameters through context struct (some at least) if (c->needs_hcscale) RENAME(hcscale)(c, chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc, hChrFilter, hChrFilterPos, hChrFilterSize, formatConvBuffer, pal); lastInChrBuf++; DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n", chrBufIndex, lastInChrBuf); } //wrap buf index around to stay inside the ring buffer if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize; if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize; if (!enough_lines) break; //we can't output a dstY line so let's try with the next slice #if COMPILE_TEMPLATE_MMX c->blueDither= ff_dither8[dstY&1]; if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555) c->greenDither= ff_dither8[dstY&1]; else c->greenDither= ff_dither4[dstY&1]; c->redDither= ff_dither8[(dstY+1)&1]; #endif if (dstY < dstH-2) { const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; const int16_t **chrSrcPtr= (const int16_t **) chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; #if COMPILE_TEMPLATE_MMX int i; if (flags & SWS_ACCURATE_RND) { int s= APCK_SIZE / 8; for (i=0; i<vLumFilterSize; i+=2) { *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ]; *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)]; lumMmxFilter[s*i+APCK_COEF/4 ]= lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ] + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ]; *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)]; alpMmxFilter[s*i+APCK_COEF/4 ]= alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ]; } } for (i=0; i<vChrFilterSize; i+=2) { *(const void**)&chrMmxFilter[s*i ]= chrSrcPtr[i ]; *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrSrcPtr[i+(vChrFilterSize>1)]; chrMmxFilter[s*i+APCK_COEF/4 ]= chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ] + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0); } } else { for (i=0; i<vLumFilterSize; i++) { lumMmxFilter[4*i+0]= (int32_t)lumSrcPtr[i]; lumMmxFilter[4*i+1]= (uint64_t)lumSrcPtr[i] >> 32; lumMmxFilter[4*i+2]= lumMmxFilter[4*i+3]= ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001; if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { alpMmxFilter[4*i+0]= (int32_t)alpSrcPtr[i]; alpMmxFilter[4*i+1]= (uint64_t)alpSrcPtr[i] >> 32; alpMmxFilter[4*i+2]= alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2]; } } for (i=0; i<vChrFilterSize; i++) { chrMmxFilter[4*i+0]= (int32_t)chrSrcPtr[i]; chrMmxFilter[4*i+1]= (uint64_t)chrSrcPtr[i] >> 32; chrMmxFilter[4*i+2]= chrMmxFilter[4*i+3]= ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001; } } #endif if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { const int chrSkipMask= (1<<c->chrDstVSubSample)-1; if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi c->yuv2nv12X(c, vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, dest, uDest, dstW, chrDstW, dstFormat); } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like const int chrSkipMask= (1<<c->chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi if (is16BPS(dstFormat) || isNBPS(dstFormat)) { yuv2yuvX16inC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW, dstFormat); } else if (vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12 const int16_t *lumBuf = lumSrcPtr[0]; const int16_t *chrBuf= chrSrcPtr[0]; const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL; c->yuv2yuv1(c, lumBuf, chrBuf, alpBuf, dest, uDest, vDest, aDest, dstW, chrDstW); } else { //General YV12 c->yuv2yuvX(c, vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW); } } else { assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); assert(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); if (vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB int chrAlpha= vChrFilter[2*dstY+1]; if(flags & SWS_FULL_CHR_H_INT) { yuv2rgbXinC_full(c, //FIXME write a packed1_full function vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } else { c->yuv2packed1(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1), alpPixBuf ? *alpSrcPtr : NULL, dest, dstW, chrAlpha, dstFormat, flags, dstY); } } else if (vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB int lumAlpha= vLumFilter[2*dstY+1]; int chrAlpha= vChrFilter[2*dstY+1]; lumMmxFilter[2]= lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001; chrMmxFilter[2]= chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001; if(flags & SWS_FULL_CHR_H_INT) { yuv2rgbXinC_full(c, //FIXME write a packed2_full function vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } else { c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1), alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL, dest, dstW, lumAlpha, chrAlpha, dstY); } } else { //general RGB if(flags & SWS_FULL_CHR_H_INT) { yuv2rgbXinC_full(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } else { c->yuv2packedX(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } } } } else { // hmm looks like we can't use MMX here without overwriting this array's tail const int16_t **lumSrcPtr= (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; const int16_t **chrSrcPtr= (const int16_t **)chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { const int chrSkipMask= (1<<c->chrDstVSubSample)-1; if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi yuv2nv12XinC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, dest, uDest, dstW, chrDstW, dstFormat); } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 const int chrSkipMask= (1<<c->chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi if (is16BPS(dstFormat) || isNBPS(dstFormat)) { yuv2yuvX16inC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW, dstFormat); } else { yuv2yuvXinC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW); } } else { assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); assert(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); if(flags & SWS_FULL_CHR_H_INT) { yuv2rgbXinC_full(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } else { yuv2packedXinC(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } } } } if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf) fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255); #if COMPILE_TEMPLATE_MMX if (flags & SWS_CPU_CAPS_MMX2 ) __asm__ volatile("sfence":::"memory"); /* On K6 femms is faster than emms. On K7 femms is directly mapped to emms. */ if (flags & SWS_CPU_CAPS_3DNOW) __asm__ volatile("femms" :::"memory"); else __asm__ volatile("emms" :::"memory"); #endif /* store changed local vars back in the context */ c->dstY= dstY; c->lumBufIndex= lumBufIndex; c->chrBufIndex= chrBufIndex; c->lastInLumBuf= lastInLumBuf; c->lastInChrBuf= lastInChrBuf; return dstY - lastDstY; } | 26,033 |
1 | static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void *dst, const int type) { int i, j, count = 0; int last, t; int A, S, T; int pos = s->pos; uint32_t crc = s->sc.crc; uint32_t crc_extra_bits = s->extra_sc.crc; int16_t *dst16 = dst; int32_t *dst32 = dst; float *dstfl = dst; s->one = s->zero = s->zeroes = 0; do { T = wv_get_value(s, gb, 0, &last); S = 0; if (last) break; for (i = 0; i < s->terms; i++) { t = s->decorr[i].value; if (t > 8) { if (t & 1) A = 2U * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]; else A = (int)(3U * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]) >> 1; s->decorr[i].samplesA[1] = s->decorr[i].samplesA[0]; j = 0; } else { A = s->decorr[i].samplesA[pos]; j = (pos + t) & 7; } if (type != AV_SAMPLE_FMT_S16P) S = T + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10); else S = T + ((s->decorr[i].weightA * A + 512) >> 10); if (A && T) s->decorr[i].weightA -= ((((T ^ A) >> 30) & 2) - 1) * s->decorr[i].delta; s->decorr[i].samplesA[j] = T = S; } pos = (pos + 1) & 7; crc = crc * 3 + S; if (type == AV_SAMPLE_FMT_FLTP) { *dstfl++ = wv_get_value_float(s, &crc_extra_bits, S); } else if (type == AV_SAMPLE_FMT_S32P) { *dst32++ = wv_get_value_integer(s, &crc_extra_bits, S); } else { *dst16++ = wv_get_value_integer(s, &crc_extra_bits, S); } count++; } while (!last && count < s->samples); wv_reset_saved_context(s); if (last && count < s->samples) { int size = av_get_bytes_per_sample(type); memset((uint8_t*)dst + count*size, 0, (s->samples-count)*size); } if (s->avctx->err_recognition & AV_EF_CRCCHECK) { int ret = wv_check_crc(s, crc, crc_extra_bits); if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE) return ret; } return 0; } | 26,034 |
1 | static void mmu_init (CPUMIPSState *env, const mips_def_t *def) { env->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext)); switch (def->mmu_type) { case MMU_TYPE_NONE: no_mmu_init(env, def); break; case MMU_TYPE_R4000: r4k_mmu_init(env, def); break; case MMU_TYPE_FMT: fixed_mmu_init(env, def); break; case MMU_TYPE_R3000: case MMU_TYPE_R6000: case MMU_TYPE_R8000: default: cpu_abort(env, "MMU type not supported\n"); } env->CP0_Random = env->tlb->nb_tlb - 1; env->tlb->tlb_in_use = env->tlb->nb_tlb; } | 26,035 |
1 | static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size, int sample) { /* No need to keep track of smaller samples, since describing them * with immediates is more efficient. */ if (size <= 14) return; if (!queue->samples || queue->len >= queue->size) { HintSample *samples; samples = av_realloc(queue->samples, sizeof(HintSample) * (queue->size + 10)); if (!samples) return; queue->size += 10; queue->samples = samples; } queue->samples[queue->len].data = data; queue->samples[queue->len].size = size; queue->samples[queue->len].sample_number = sample; queue->samples[queue->len].offset = 0; queue->samples[queue->len].own_data = 0; queue->len++; } | 26,036 |
1 | static void gen_spr_power8_tce_address_control(CPUPPCState *env) { spr_register(env, SPR_TAR, "TAR", &spr_read_generic, &spr_write_generic, &spr_read_generic, &spr_write_generic, 0x00000000); } | 26,039 |
1 | static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block, int n, int coded, int intra) { int level, i, last, run; int dc_pred_dir; RLTable * rl; RL_VLC_ELEM * rl_vlc; const UINT8 * scan_table; int qmul, qadd; if(intra) { /* DC coef */ if(s->partitioned_frame){ level = s->dc_val[0][ s->block_index[n] ]; if(n<4) level= (level + (s->y_dc_scale>>1))/s->y_dc_scale; //FIXME optimizs else level= (level + (s->c_dc_scale>>1))/s->c_dc_scale; dc_pred_dir= (s->pred_dir_table[s->mb_x + s->mb_y*s->mb_width]<<n)&32; }else{ level = mpeg4_decode_dc(s, n, &dc_pred_dir); if (level < 0) return -1; } block[0] = level; i = 0; if (!coded) goto not_coded; rl = &rl_intra; rl_vlc = rl_intra.rl_vlc[0]; if (s->ac_pred) { if (dc_pred_dir == 0) scan_table = s->intra_v_scantable.permutated; /* left */ else scan_table = s->intra_h_scantable.permutated; /* top */ } else { scan_table = s->intra_scantable.permutated; } qmul=1; qadd=0; } else { i = -1; if (!coded) { s->block_last_index[n] = i; return 0; } rl = &rl_inter; scan_table = s->intra_scantable.permutated; if(s->mpeg_quant){ qmul=1; qadd=0; rl_vlc = rl_inter.rl_vlc[0]; }else{ qmul = s->qscale << 1; qadd = (s->qscale - 1) | 1; rl_vlc = rl_inter.rl_vlc[s->qscale]; } } { OPEN_READER(re, &s->gb); for(;;) { UPDATE_CACHE(re, &s->gb); GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2); if (level==0) { int cache; cache= GET_CACHE(re, &s->gb); /* escape */ if (cache&0x80000000) { if (cache&0x40000000) { /* third escape */ SKIP_CACHE(re, &s->gb, 2); last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1); run= SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6); SKIP_COUNTER(re, &s->gb, 2+1+6); UPDATE_CACHE(re, &s->gb); if(SHOW_UBITS(re, &s->gb, 1)==0){ fprintf(stderr, "1. marker bit missing in 3. esc\n"); return -1; }; SKIP_CACHE(re, &s->gb, 1); level= SHOW_SBITS(re, &s->gb, 12); SKIP_CACHE(re, &s->gb, 12); if(SHOW_UBITS(re, &s->gb, 1)==0){ fprintf(stderr, "2. marker bit missing in 3. esc\n"); return -1; }; LAST_SKIP_CACHE(re, &s->gb, 1); SKIP_COUNTER(re, &s->gb, 1+12+1); if(level*s->qscale>1024 || level*s->qscale<-1024){ fprintf(stderr, "|level| overflow in 3. esc, qp=%d\n", s->qscale); return -1; } #if 1 { const int abs_level= ABS(level); if(abs_level<=MAX_LEVEL && run<=MAX_RUN && ((s->workaround_bugs&FF_BUG_AC_VLC)==0)){ const int run1= run - rl->max_run[last][abs_level] - 1; if(abs_level <= rl->max_level[last][run]){ fprintf(stderr, "illegal 3. esc, vlc encoding possible\n"); return -1; } if(abs_level <= rl->max_level[last][run]*2){ fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n"); return -1; } if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){ fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n"); return -1; } } } #endif if (level>0) level= level * qmul + qadd; else level= level * qmul - qadd; i+= run + 1; if(last) i+=192; } else { /* second escape */ #if MIN_CACHE_BITS < 20 LAST_SKIP_BITS(re, &s->gb, 2); UPDATE_CACHE(re, &s->gb); #else SKIP_BITS(re, &s->gb, 2); #endif GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2); i+= run + rl->max_run[run>>7][level/qmul] +1; //FIXME opt indexing level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); } } else { /* first escape */ #if MIN_CACHE_BITS < 19 LAST_SKIP_BITS(re, &s->gb, 1); UPDATE_CACHE(re, &s->gb); #else SKIP_BITS(re, &s->gb, 1); #endif GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2); i+= run; level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); } } else { i+= run; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); } if (i > 62){ i-= 192; if(i&(~63)){ fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y); return -1; } block[scan_table[i]] = level; break; } block[scan_table[i]] = level; } CLOSE_READER(re, &s->gb); } not_coded: if (s->mb_intra) { mpeg4_pred_ac(s, block, n, dc_pred_dir); if (s->ac_pred) { i = 63; /* XXX: not optimal */ } } s->block_last_index[n] = i; return 0; } | 26,040 |
1 | int load_uboot(const char *filename, target_ulong *ep, int *is_linux) { int fd; int size; uboot_image_header_t h; uboot_image_header_t *hdr = &h; uint8_t *data = NULL; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) return -1; size = read(fd, hdr, sizeof(uboot_image_header_t)); if (size < 0) goto fail; bswap_uboot_header(hdr); if (hdr->ih_magic != IH_MAGIC) goto fail; /* TODO: Implement Multi-File images. */ if (hdr->ih_type == IH_TYPE_MULTI) { fprintf(stderr, "Unable to load multi-file u-boot images\n"); goto fail; } /* TODO: Implement compressed images. */ if (hdr->ih_comp != IH_COMP_NONE) { fprintf(stderr, "Unable to load compressed u-boot images\n"); goto fail; } /* TODO: Check CPU type. */ if (is_linux) { if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX) *is_linux = 1; else *is_linux = 0; } *ep = hdr->ih_ep; data = qemu_malloc(hdr->ih_size); if (!data) goto fail; if (read(fd, data, hdr->ih_size) != hdr->ih_size) { fprintf(stderr, "Error reading file\n"); goto fail; } cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size); return hdr->ih_size; fail: if (data) qemu_free(data); close(fd); return -1; } | 26,041 |
1 | static int64_t alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index) { BDRVQcowState *s = bs->opaque; unsigned int refcount_table_index; int ret; BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC); /* Find the refcount block for the given cluster */ refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT); if (refcount_table_index < s->refcount_table_size) { uint64_t refcount_block_offset = s->refcount_table[refcount_table_index]; /* If it's already there, we're done */ if (refcount_block_offset) { if (refcount_block_offset != s->refcount_block_cache_offset) { ret = load_refcount_block(bs, refcount_block_offset); if (ret < 0) { return ret; } } return refcount_block_offset; } } /* * If we came here, we need to allocate something. Something is at least * a cluster for the new refcount block. It may also include a new refcount * table if the old refcount table is too small. * * Note that allocating clusters here needs some special care: * * - We can't use the normal qcow2_alloc_clusters(), it would try to * increase the refcount and very likely we would end up with an endless * recursion. Instead we must place the refcount blocks in a way that * they can describe them themselves. * * - We need to consider that at this point we are inside update_refcounts * and doing the initial refcount increase. This means that some clusters * have already been allocated by the caller, but their refcount isn't * accurate yet. free_cluster_index tells us where this allocation ends * as long as we don't overwrite it by freeing clusters. * * - alloc_clusters_noref and qcow2_free_clusters may load a different * refcount block into the cache */ if (cache_refcount_updates) { ret = write_refcount_block(bs); if (ret < 0) { return ret; } } /* Allocate the refcount block itself and mark it as used */ uint64_t new_block = alloc_clusters_noref(bs, s->cluster_size); memset(s->refcount_block_cache, 0, s->cluster_size); s->refcount_block_cache_offset = new_block; #ifdef DEBUG_ALLOC2 fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64 " at %" PRIx64 "\n", refcount_table_index, cluster_index << s->cluster_bits, new_block); #endif if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) { /* The block describes itself, need to update the cache */ int block_index = (new_block >> s->cluster_bits) & ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1); s->refcount_block_cache[block_index] = cpu_to_be16(1); } else { /* Described somewhere else. This can recurse at most twice before we * arrive at a block that describes itself. */ ret = update_refcount(bs, new_block, s->cluster_size, 1); if (ret < 0) { goto fail_block; } } /* Now the new refcount block needs to be written to disk */ BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE); ret = bdrv_pwrite(bs->file, new_block, s->refcount_block_cache, s->cluster_size); if (ret < 0) { goto fail_block; } /* If the refcount table is big enough, just hook the block up there */ if (refcount_table_index < s->refcount_table_size) { uint64_t data64 = cpu_to_be64(new_block); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP); ret = bdrv_pwrite(bs->file, s->refcount_table_offset + refcount_table_index * sizeof(uint64_t), &data64, sizeof(data64)); if (ret < 0) { goto fail_block; } s->refcount_table[refcount_table_index] = new_block; return new_block; } /* * If we come here, we need to grow the refcount table. Again, a new * refcount table needs some space and we can't simply allocate to avoid * endless recursion. * * Therefore let's grab new refcount blocks at the end of the image, which * will describe themselves and the new refcount table. This way we can * reference them only in the new table and do the switch to the new * refcount table at once without producing an inconsistent state in * between. */ BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW); /* Calculate the number of refcount blocks needed so far */ uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT); uint64_t blocks_used = (s->free_cluster_index + refcount_block_clusters - 1) / refcount_block_clusters; /* And now we need at least one block more for the new metadata */ uint64_t table_size = next_refcount_table_size(s, blocks_used + 1); uint64_t last_table_size; uint64_t blocks_clusters; do { uint64_t table_clusters = size_to_clusters(s, table_size); blocks_clusters = 1 + ((table_clusters + refcount_block_clusters - 1) / refcount_block_clusters); uint64_t meta_clusters = table_clusters + blocks_clusters; last_table_size = table_size; table_size = next_refcount_table_size(s, blocks_used + ((meta_clusters + refcount_block_clusters - 1) / refcount_block_clusters)); } while (last_table_size != table_size); #ifdef DEBUG_ALLOC2 fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n", s->refcount_table_size, table_size); #endif /* Create the new refcount table and blocks */ uint64_t meta_offset = (blocks_used * refcount_block_clusters) * s->cluster_size; uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size; uint16_t *new_blocks = qemu_mallocz(blocks_clusters * s->cluster_size); uint64_t *new_table = qemu_mallocz(table_size * sizeof(uint64_t)); assert(meta_offset >= (s->free_cluster_index * s->cluster_size)); /* Fill the new refcount table */ memcpy(new_table, s->refcount_table, s->refcount_table_size * sizeof(uint64_t)); new_table[refcount_table_index] = new_block; int i; for (i = 0; i < blocks_clusters; i++) { new_table[blocks_used + i] = meta_offset + (i * s->cluster_size); } /* Fill the refcount blocks */ uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t)); int block = 0; for (i = 0; i < table_clusters + blocks_clusters; i++) { new_blocks[block++] = cpu_to_be16(1); } /* Write refcount blocks to disk */ BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS); ret = bdrv_pwrite(bs->file, meta_offset, new_blocks, blocks_clusters * s->cluster_size); qemu_free(new_blocks); if (ret < 0) { goto fail_table; } /* Write refcount table to disk */ for(i = 0; i < table_size; i++) { cpu_to_be64s(&new_table[i]); } BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE); ret = bdrv_pwrite(bs->file, table_offset, new_table, table_size * sizeof(uint64_t)); if (ret < 0) { goto fail_table; } for(i = 0; i < table_size; i++) { cpu_to_be64s(&new_table[i]); } /* Hook up the new refcount table in the qcow2 header */ uint8_t data[12]; cpu_to_be64w((uint64_t*)data, table_offset); cpu_to_be32w((uint32_t*)(data + 8), table_clusters); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE); ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, refcount_table_offset), data, sizeof(data)); if (ret < 0) { goto fail_table; } /* And switch it in memory */ uint64_t old_table_offset = s->refcount_table_offset; uint64_t old_table_size = s->refcount_table_size; qemu_free(s->refcount_table); s->refcount_table = new_table; s->refcount_table_size = table_size; s->refcount_table_offset = table_offset; /* Free old table. Remember, we must not change free_cluster_index */ uint64_t old_free_cluster_index = s->free_cluster_index; qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t)); s->free_cluster_index = old_free_cluster_index; ret = load_refcount_block(bs, new_block); if (ret < 0) { goto fail_block; } return new_block; fail_table: qemu_free(new_table); fail_block: s->refcount_block_cache_offset = 0; return ret; } | 26,042 |
1 | static int parse_vtrk(AVFormatContext *s, FourxmDemuxContext *fourxm, uint8_t *buf, int size) { AVStream *st; /* check that there is enough data */ if (size != vtrk_SIZE) { return AVERROR_INVALIDDATA; } /* allocate a new AVStream */ st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 60, 1, fourxm->fps); fourxm->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_4XM; st->codec->extradata_size = 4; st->codec->extradata = av_malloc(4); AV_WL32(st->codec->extradata, AV_RL32(buf + 16)); st->codec->width = AV_RL32(buf + 36); st->codec->height = AV_RL32(buf + 40); return 0; } | 26,043 |
1 | void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) { if (bs->backing_hd) { assert(bs->backing_blocker); bdrv_op_unblock_all(bs->backing_hd, bs->backing_blocker); } else if (backing_hd) { error_setg(&bs->backing_blocker, "device is used as backing hd of '%s'", bdrv_get_device_name(bs)); } bs->backing_hd = backing_hd; if (!backing_hd) { error_free(bs->backing_blocker); bs->backing_blocker = NULL; goto out; } bs->open_flags &= ~BDRV_O_NO_BACKING; pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_hd->drv ? backing_hd->drv->format_name : ""); bdrv_op_block_all(bs->backing_hd, bs->backing_blocker); /* Otherwise we won't be able to commit due to check in bdrv_commit */ bdrv_op_unblock(bs->backing_hd, BLOCK_OP_TYPE_COMMIT, bs->backing_blocker); out: bdrv_refresh_limits(bs, NULL); } | 26,044 |
1 | static void scsi_command_complete(void *opaque, int ret) { SCSIGenericReq *r = (SCSIGenericReq *)opaque; SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, r->req.dev); r->req.aiocb = NULL; s->driver_status = r->io_header.driver_status; if (s->driver_status & SG_ERR_DRIVER_SENSE) s->senselen = r->io_header.sb_len_wr; if (ret != 0) r->req.status = BUSY; else { if (s->driver_status & SG_ERR_DRIVER_TIMEOUT) { r->req.status = BUSY; BADF("Driver Timeout\n"); } else if (r->io_header.status) r->req.status = r->io_header.status; else if (s->driver_status & SG_ERR_DRIVER_SENSE) r->req.status = CHECK_CONDITION; else r->req.status = GOOD; } DPRINTF("Command complete 0x%p tag=0x%x status=%d\n", r, r->req.tag, r->req.status); scsi_req_complete(&r->req); } | 26,045 |
1 | static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, int64_t offset, int64_t length, uint64_t addend, bool decrease, enum qcow2_discard_type type) { BDRVQcowState *s = bs->opaque; int64_t start, last, cluster_offset; uint16_t *refcount_block = NULL; int64_t old_table_index = -1; int ret; #ifdef DEBUG_ALLOC2 fprintf(stderr, "update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%s%" PRIu64 "\n", offset, length, decrease ? "-" : "", addend); #endif if (length < 0) { return -EINVAL; } else if (length == 0) { return 0; } if (decrease) { qcow2_cache_set_dependency(bs, s->refcount_block_cache, s->l2_table_cache); } start = start_of_cluster(s, offset); last = start_of_cluster(s, offset + length - 1); for(cluster_offset = start; cluster_offset <= last; cluster_offset += s->cluster_size) { int block_index; uint64_t refcount; int64_t cluster_index = cluster_offset >> s->cluster_bits; int64_t table_index = cluster_index >> s->refcount_block_bits; /* Load the refcount block and allocate it if needed */ if (table_index != old_table_index) { if (refcount_block) { ret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) &refcount_block); if (ret < 0) { goto fail; } } ret = alloc_refcount_block(bs, cluster_index, &refcount_block); if (ret < 0) { goto fail; } } old_table_index = table_index; qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refcount_block); /* we can update the count and save it */ block_index = cluster_index & (s->refcount_block_size - 1); refcount = be16_to_cpu(refcount_block[block_index]); if (decrease ? (refcount - addend > refcount) : (refcount + addend < refcount || refcount + addend > s->refcount_max)) { ret = -EINVAL; goto fail; } if (decrease) { refcount -= addend; } else { refcount += addend; } if (refcount == 0 && cluster_index < s->free_cluster_index) { s->free_cluster_index = cluster_index; } refcount_block[block_index] = cpu_to_be16(refcount); if (refcount == 0 && s->discard_passthrough[type]) { update_refcount_discard(bs, cluster_offset, s->cluster_size); } } ret = 0; fail: if (!s->cache_discards) { qcow2_process_discards(bs, ret); } /* Write last changed block to disk */ if (refcount_block) { int wret; wret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) &refcount_block); if (wret < 0) { return ret < 0 ? ret : wret; } } /* * Try do undo any updates if an error is returned (This may succeed in * some cases like ENOSPC for allocating a new refcount block) */ if (ret < 0) { int dummy; dummy = update_refcount(bs, offset, cluster_offset - offset, addend, !decrease, QCOW2_DISCARD_NEVER); (void)dummy; } return ret; } | 26,046 |
0 | int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size) { GetBitContext gb; int specific_config_bitindex; init_get_bits(&gb, buf, buf_size*8); c->object_type = get_object_type(&gb); c->sample_rate = get_sample_rate(&gb, &c->sampling_index); c->chan_config = get_bits(&gb, 4); if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) c->channels = ff_mpeg4audio_channels[c->chan_config]; c->sbr = -1; if (c->object_type == AOT_SBR || (c->object_type == AOT_PS && // check for W6132 Annex YYYY draft MP3onMP4 !(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) { c->ext_object_type = AOT_SBR; c->sbr = 1; c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index); c->object_type = get_object_type(&gb); if (c->object_type == AOT_ER_BSAC) c->ext_chan_config = get_bits(&gb, 4); } else { c->ext_object_type = AOT_NULL; c->ext_sample_rate = 0; } specific_config_bitindex = get_bits_count(&gb); if (c->object_type == AOT_ALS) { skip_bits(&gb, 5); if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S')) skip_bits_long(&gb, 24); specific_config_bitindex = get_bits_count(&gb); if (parse_config_ALS(&gb, c)) return -1; } if (c->ext_object_type != AOT_SBR) { int bits_left = buf_size*8 - get_bits_count(&gb); for (; bits_left > 15; bits_left--) { if (show_bits(&gb, 11) == 0x2b7) { // sync extension get_bits(&gb, 11); c->ext_object_type = get_object_type(&gb); if (c->ext_object_type == AOT_SBR && (c->sbr = get_bits1(&gb)) == 1) c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index); break; } else get_bits1(&gb); // skip 1 bit } } return specific_config_bitindex; } | 26,047 |
0 | void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv, int mvp_lx_flag, int LX) { HEVCLocalContext *lc = s->HEVClc; MvField *tab_mvf = s->ref->tab_mvf; int isScaledFlag_L0 = 0; int availableFlagLXA0 = 1; int availableFlagLXB0 = 1; int numMVPCandLX = 0; int min_pu_width = s->sps->min_pu_width; int xA0, yA0; int is_available_a0; int xA1, yA1; int is_available_a1; int xB0, yB0; int is_available_b0; int xB1, yB1; int is_available_b1; int xB2, yB2; int is_available_b2; Mv mvpcand_list[2] = { { 0 } }; Mv mxA; Mv mxB; int ref_idx_curr = 0; int ref_idx = 0; int pred_flag_index_l0; int pred_flag_index_l1; const int cand_bottom_left = lc->na.cand_bottom_left; const int cand_left = lc->na.cand_left; const int cand_up_left = lc->na.cand_up_left; const int cand_up = lc->na.cand_up; const int cand_up_right = lc->na.cand_up_right_sap; ref_idx_curr = LX; ref_idx = mv->ref_idx[LX]; pred_flag_index_l0 = LX; pred_flag_index_l1 = !LX; // left bottom spatial candidate xA0 = x0 - 1; yA0 = y0 + nPbH; is_available_a0 = AVAILABLE(cand_bottom_left, A0) && yA0 < s->sps->height && PRED_BLOCK_AVAILABLE(A0); //left spatial merge candidate xA1 = x0 - 1; yA1 = y0 + nPbH - 1; is_available_a1 = AVAILABLE(cand_left, A1); if (is_available_a0 || is_available_a1) isScaledFlag_L0 = 1; if (is_available_a0) { if (MP_MX(A0, pred_flag_index_l0, mxA)) { goto b_candidates; } if (MP_MX(A0, pred_flag_index_l1, mxA)) { goto b_candidates; } } if (is_available_a1) { if (MP_MX(A1, pred_flag_index_l0, mxA)) { goto b_candidates; } if (MP_MX(A1, pred_flag_index_l1, mxA)) { goto b_candidates; } } if (is_available_a0) { if (MP_MX_LT(A0, pred_flag_index_l0, mxA)) { goto b_candidates; } if (MP_MX_LT(A0, pred_flag_index_l1, mxA)) { goto b_candidates; } } if (is_available_a1) { if (MP_MX_LT(A1, pred_flag_index_l0, mxA)) { goto b_candidates; } if (MP_MX_LT(A1, pred_flag_index_l1, mxA)) { goto b_candidates; } } availableFlagLXA0 = 0; b_candidates: // B candidates // above right spatial merge candidate xB0 = x0 + nPbW; yB0 = y0 - 1; is_available_b0 = AVAILABLE(cand_up_right, B0) && xB0 < s->sps->width && PRED_BLOCK_AVAILABLE(B0); // above spatial merge candidate xB1 = x0 + nPbW - 1; yB1 = y0 - 1; is_available_b1 = AVAILABLE(cand_up, B1); // above left spatial merge candidate xB2 = x0 - 1; yB2 = y0 - 1; is_available_b2 = AVAILABLE(cand_up_left, B2); // above right spatial merge candidate if (is_available_b0) { if (MP_MX(B0, pred_flag_index_l0, mxB)) { goto scalef; } if (MP_MX(B0, pred_flag_index_l1, mxB)) { goto scalef; } } // above spatial merge candidate if (is_available_b1) { if (MP_MX(B1, pred_flag_index_l0, mxB)) { goto scalef; } if (MP_MX(B1, pred_flag_index_l1, mxB)) { goto scalef; } } // above left spatial merge candidate if (is_available_b2) { if (MP_MX(B2, pred_flag_index_l0, mxB)) { goto scalef; } if (MP_MX(B2, pred_flag_index_l1, mxB)) { goto scalef; } } availableFlagLXB0 = 0; scalef: if (!isScaledFlag_L0) { if (availableFlagLXB0) { availableFlagLXA0 = 1; mxA = mxB; } availableFlagLXB0 = 0; // XB0 and L1 if (is_available_b0) { availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l0, mxB); if (!availableFlagLXB0) availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l1, mxB); } if (is_available_b1 && !availableFlagLXB0) { availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l0, mxB); if (!availableFlagLXB0) availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l1, mxB); } if (is_available_b2 && !availableFlagLXB0) { availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l0, mxB); if (!availableFlagLXB0) availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l1, mxB); } } if (availableFlagLXA0) mvpcand_list[numMVPCandLX++] = mxA; if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y)) mvpcand_list[numMVPCandLX++] = mxB; //temporal motion vector prediction candidate if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag && mvp_lx_flag == numMVPCandLX) { Mv mv_col; int available_col = temporal_luma_motion_vector(s, x0, y0, nPbW, nPbH, ref_idx, &mv_col, LX); if (available_col) mvpcand_list[numMVPCandLX++] = mv_col; } mv->mv[LX] = mvpcand_list[mvp_lx_flag]; } | 26,048 |
1 | static void pc_compat_2_0(MachineState *machine) { smbios_legacy_mode = true; has_reserved_memory = false; } | 26,050 |
1 | static CharDriverState *qemu_chr_open_msmouse(const char *id, ChardevBackend *backend, ChardevReturn *ret, Error **errp) { ChardevCommon *common = backend->u.msmouse.data; MouseState *mouse; CharDriverState *chr; chr = qemu_chr_alloc(common, errp); chr->chr_write = msmouse_chr_write; chr->chr_close = msmouse_chr_close; chr->chr_accept_input = msmouse_chr_accept_input; chr->explicit_be_open = true; mouse = g_new0(MouseState, 1); mouse->hs = qemu_input_handler_register((DeviceState *)mouse, &msmouse_handler); mouse->chr = chr; chr->opaque = mouse; return chr; | 26,051 |
1 | int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr) { #ifdef KVM_CAP_MCE ram_addr_t ram_addr; target_phys_addr_t paddr; if ((env->mcg_cap & MCG_SER_P) && addr && (code == BUS_MCEERR_AR || code == BUS_MCEERR_AO)) { if (qemu_ram_addr_from_host(addr, &ram_addr) || !kvm_physical_memory_addr_from_ram(env->kvm_state, ram_addr, &paddr)) { fprintf(stderr, "Hardware memory error for memory used by " "QEMU itself instead of guest system!\n"); /* Hope we are lucky for AO MCE */ if (code == BUS_MCEERR_AO) { return 0; } else { hardware_memory_error(); } } kvm_mce_inject(env, paddr, code); } else #endif /* KVM_CAP_MCE */ { if (code == BUS_MCEERR_AO) { return 0; } else if (code == BUS_MCEERR_AR) { hardware_memory_error(); } else { return 1; } } return 0; } | 26,052 |
1 | static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int coded, int mquant, int codingset) { GetBitContext *gb = &v->s.gb; MpegEncContext *s = &v->s; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int run_diff, i; int16_t *dc_val; int16_t *ac_val, *ac_val2; int dcdiff; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int a_avail = v->a_avail, c_avail = v->c_avail; int use_pred = s->ac_pred; int scale; int q1, q2 = 0; /* XXX: Guard against dumb values of mquant */ mquant = (mquant < 1) ? 0 : ( (mquant>31) ? 31 : mquant ); /* Set DC scale - y and c use the same */ s->y_dc_scale = s->y_dc_scale_table[mquant]; s->c_dc_scale = s->c_dc_scale_table[mquant]; /* Get DC differential */ if (n < 4) { dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); } else { dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); } if (dcdiff < 0){ av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n"); return -1; } if (dcdiff) { if (dcdiff == 119 /* ESC index value */) { /* TODO: Optimize */ if (mquant == 1) dcdiff = get_bits(gb, 10); else if (mquant == 2) dcdiff = get_bits(gb, 9); else dcdiff = get_bits(gb, 8); } else { if (mquant == 1) dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; else if (mquant == 2) dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1; } if (get_bits(gb, 1)) dcdiff = -dcdiff; } /* Prediction */ dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir); *dc_val = dcdiff; /* Store the quantized DC coeff, used for prediction */ if (n < 4) { block[0] = dcdiff * s->y_dc_scale; } else { block[0] = dcdiff * s->c_dc_scale; } /* Skip ? */ run_diff = 0; i = 0; //AC Decoding i = 1; /* check if AC is needed at all and adjust direction if needed */ if(!a_avail) dc_pred_dir = 1; if(!c_avail) dc_pred_dir = 0; if(!a_avail && !c_avail) use_pred = 0; ac_val = s->ac_val[0][0] + s->block_index[n] * 16; ac_val2 = ac_val; scale = mquant * 2 + v->halfpq; if(dc_pred_dir) //left ac_val -= 16; else //top ac_val -= 16 * s->block_wrap[n]; q1 = s->current_picture.qscale_table[mb_pos]; if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1]; if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride]; if(n && n<4) q2 = q1; if(coded) { int last = 0, skip, value; const int8_t *zz_table; int k; zz_table = vc1_simple_progressive_8x8_zz; while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, codingset); i += skip; if(i > 63) break; block[zz_table[i++]] = value; } /* apply AC prediction if needed */ if(use_pred) { /* scale predictors if needed*/ if(q2 && q1!=q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; if(dc_pred_dir) { //left for(k = 1; k < 8; k++) block[k << 3] += (ac_val[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18; } else { //top for(k = 1; k < 8; k++) block[k] += (ac_val[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } else { if(dc_pred_dir) { //left for(k = 1; k < 8; k++) block[k << 3] += ac_val[k]; } else { //top for(k = 1; k < 8; k++) block[k] += ac_val[k + 8]; } } } /* save AC coeffs for further prediction */ for(k = 1; k < 8; k++) { ac_val2[k] = block[k << 3]; ac_val2[k + 8] = block[k]; } /* scale AC coeffs */ for(k = 1; k < 64; k++) if(block[k]) { block[k] *= scale; if(!v->pquantizer) block[k] += (block[k] < 0) ? -mquant : mquant; } if(use_pred) i = 63; } else { // no AC coeffs int k; memset(ac_val2, 0, 16 * 2); if(dc_pred_dir) {//left if(use_pred) { memcpy(ac_val2, ac_val, 8 * 2); if(q2 && q1!=q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; for(k = 1; k < 8; k++) ac_val2[k] = (ac_val2[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } } else {//top if(use_pred) { memcpy(ac_val2 + 8, ac_val + 8, 8 * 2); if(q2 && q1!=q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; for(k = 1; k < 8; k++) ac_val2[k + 8] = (ac_val2[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } } /* apply AC prediction if needed */ if(use_pred) { if(dc_pred_dir) { //left for(k = 1; k < 8; k++) { block[k << 3] = ac_val2[k] * scale; if(!v->pquantizer && block[k << 3]) block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant; } } else { //top for(k = 1; k < 8; k++) { block[k] = ac_val2[k + 8] * scale; if(!v->pquantizer && block[k]) block[k] += (block[k] < 0) ? -mquant : mquant; } } i = 63; } } s->block_last_index[n] = i; return 0; } | 26,053 |
0 | static int can_safely_read(GetBitContext* gb, uint64_t bits) { return get_bits_left(gb) >= bits; } | 26,054 |
0 | static int tta_probe(AVProbeData *p) { const uint8_t *d = p->buf; if (p->buf_size < 4) return 0; if (d[0] == 'T' && d[1] == 'T' && d[2] == 'A' && d[3] == '1') return 80; return 0; } | 26,055 |
0 | static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c, int i, int num_tables) { /* Using MADV_DONTNEED to discard memory is a Linux-specific feature */ #ifdef CONFIG_LINUX BDRVQcow2State *s = bs->opaque; void *t = qcow2_cache_get_table_addr(bs, c, i); int align = getpagesize(); size_t mem_size = (size_t) s->cluster_size * num_tables; size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t; size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align); if (length > 0) { madvise((uint8_t *) t + offset, length, MADV_DONTNEED); } #endif } | 26,056 |
0 | static void qpi_init(void) { kqemu_comm_base = 0xff000000 | 1; qpi_io_memory = cpu_register_io_memory( qpi_mem_read, qpi_mem_write, NULL); cpu_register_physical_memory(kqemu_comm_base & ~0xfff, 0x1000, qpi_io_memory); } | 26,057 |
0 | tight_detect_smooth_image(VncState *vs, int w, int h) { uint errors; int compression = vs->tight.compression; int quality = vs->tight.quality; if (!vs->vd->lossy) { return 0; } if (ds_get_bytes_per_pixel(vs->ds) == 1 || vs->clientds.pf.bytes_per_pixel == 1 || w < VNC_TIGHT_DETECT_MIN_WIDTH || h < VNC_TIGHT_DETECT_MIN_HEIGHT) { return 0; } if (vs->tight.quality != -1) { if (w * h < VNC_TIGHT_JPEG_MIN_RECT_SIZE) { return 0; } } else { if (w * h < tight_conf[compression].gradient_min_rect_size) { return 0; } } if (vs->clientds.pf.bytes_per_pixel == 4) { if (vs->tight.pixel24) { errors = tight_detect_smooth_image24(vs, w, h); if (vs->tight.quality != -1) { return (errors < tight_conf[quality].jpeg_threshold24); } return (errors < tight_conf[compression].gradient_threshold24); } else { errors = tight_detect_smooth_image32(vs, w, h); } } else { errors = tight_detect_smooth_image16(vs, w, h); } if (quality != -1) { return (errors < tight_conf[quality].jpeg_threshold); } return (errors < tight_conf[compression].gradient_threshold); } | 26,058 |
0 | static void list_formats(AVFormatContext *ctx, int type) { const struct video_data *s = ctx->priv_data; struct v4l2_fmtdesc vfd = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE }; while(!v4l2_ioctl(s->fd, VIDIOC_ENUM_FMT, &vfd)) { enum AVCodecID codec_id = avpriv_fmt_v4l2codec(vfd.pixelformat); enum AVPixelFormat pix_fmt = avpriv_fmt_v4l2ff(vfd.pixelformat, codec_id); vfd.index++; if (!(vfd.flags & V4L2_FMT_FLAG_COMPRESSED) && type & V4L_RAWFORMATS) { const char *fmt_name = av_get_pix_fmt_name(pix_fmt); av_log(ctx, AV_LOG_INFO, "Raw : %9s : %20s :", fmt_name ? fmt_name : "Unsupported", vfd.description); } else if (vfd.flags & V4L2_FMT_FLAG_COMPRESSED && type & V4L_COMPFORMATS) { AVCodec *codec = avcodec_find_decoder(codec_id); av_log(ctx, AV_LOG_INFO, "Compressed: %9s : %20s :", codec ? codec->name : "Unsupported", vfd.description); } else { continue; } #ifdef V4L2_FMT_FLAG_EMULATED if (vfd.flags & V4L2_FMT_FLAG_EMULATED) av_log(ctx, AV_LOG_INFO, " Emulated :"); #endif #if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE list_framesizes(ctx, vfd.pixelformat); #endif av_log(ctx, AV_LOG_INFO, "\n"); } } | 26,060 |
0 | static CharDriverState *qemu_chr_open_pp_fd(int fd, Error **errp) { CharDriverState *chr; ParallelCharDriver *drv; if (ioctl(fd, PPCLAIM) < 0) { error_setg_errno(errp, errno, "not a parallel port"); close(fd); return NULL; } drv = g_new0(ParallelCharDriver, 1); drv->fd = fd; drv->mode = IEEE1284_MODE_COMPAT; chr = qemu_chr_alloc(); chr->chr_write = null_chr_write; chr->chr_ioctl = pp_ioctl; chr->chr_close = pp_close; chr->opaque = drv; return chr; } | 26,062 |
0 | static QError *qerror_from_info(const char *fmt, va_list *va) { QError *qerr; qerr = qerror_new(); loc_save(&qerr->loc); qerr->error = error_obj_from_fmt_no_fail(fmt, va); qerr->err_msg = qerror_format(fmt, qerr->error); return qerr; } | 26,063 |
0 | static void unblock_io_signals(void) { sigset_t set; sigemptyset(&set); sigaddset(&set, SIGUSR2); sigaddset(&set, SIGIO); sigaddset(&set, SIGALRM); pthread_sigmask(SIG_UNBLOCK, &set, NULL); sigemptyset(&set); sigaddset(&set, SIGUSR1); pthread_sigmask(SIG_BLOCK, &set, NULL); } | 26,064 |
0 | float32 helper_fqtos(CPUSPARCState *env) { float32 ret; clear_float_exceptions(env); ret = float128_to_float32(QT1, &env->fp_status); check_ieee_exceptions(env); return ret; } | 26,065 |
0 | float32 float32_round_to_int( float32 a STATUS_PARAM) { flag aSign; int16 aExp; bits32 lastBitMask, roundBitsMask; int8 roundingMode; float32 z; aExp = extractFloat32Exp( a ); if ( 0x96 <= aExp ) { if ( ( aExp == 0xFF ) && extractFloat32Frac( a ) ) { return propagateFloat32NaN( a, a STATUS_VAR ); } return a; } if ( aExp <= 0x7E ) { if ( (bits32) ( a<<1 ) == 0 ) return a; STATUS(float_exception_flags) |= float_flag_inexact; aSign = extractFloat32Sign( a ); switch ( STATUS(float_rounding_mode) ) { case float_round_nearest_even: if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) { return packFloat32( aSign, 0x7F, 0 ); } break; case float_round_down: return aSign ? 0xBF800000 : 0; case float_round_up: return aSign ? 0x80000000 : 0x3F800000; } return packFloat32( aSign, 0, 0 ); } lastBitMask = 1; lastBitMask <<= 0x96 - aExp; roundBitsMask = lastBitMask - 1; z = a; roundingMode = STATUS(float_rounding_mode); if ( roundingMode == float_round_nearest_even ) { z += lastBitMask>>1; if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask; } else if ( roundingMode != float_round_to_zero ) { if ( extractFloat32Sign( z ) ^ ( roundingMode == float_round_up ) ) { z += roundBitsMask; } } z &= ~ roundBitsMask; if ( z != a ) STATUS(float_exception_flags) |= float_flag_inexact; return z; } | 26,066 |
0 | static void do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, Error **errp) { BlockDriverState *bs; BlockDriverState *target_bs; BlockDriverState *source = NULL; BdrvDirtyBitmap *bmap = NULL; AioContext *aio_context; QDict *options = NULL; Error *local_err = NULL; int flags; int64_t size; if (!backup->has_speed) { backup->speed = 0; } if (!backup->has_on_source_error) { backup->on_source_error = BLOCKDEV_ON_ERROR_REPORT; } if (!backup->has_on_target_error) { backup->on_target_error = BLOCKDEV_ON_ERROR_REPORT; } if (!backup->has_mode) { backup->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; } if (!backup->has_job_id) { backup->job_id = NULL; } bs = qmp_get_root_bs(backup->device, errp); if (!bs) { return; } aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); if (!backup->has_format) { backup->format = backup->mode == NEW_IMAGE_MODE_EXISTING ? NULL : (char*) bs->drv->format_name; } /* Early check to avoid creating target */ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) { goto out; } flags = bs->open_flags | BDRV_O_RDWR; /* See if we have a backing HD we can use to create our new image * on top of. */ if (backup->sync == MIRROR_SYNC_MODE_TOP) { source = backing_bs(bs); if (!source) { backup->sync = MIRROR_SYNC_MODE_FULL; } } if (backup->sync == MIRROR_SYNC_MODE_NONE) { source = bs; } size = bdrv_getlength(bs); if (size < 0) { error_setg_errno(errp, -size, "bdrv_getlength failed"); goto out; } if (backup->mode != NEW_IMAGE_MODE_EXISTING) { assert(backup->format); if (source) { bdrv_img_create(backup->target, backup->format, source->filename, source->drv->format_name, NULL, size, flags, &local_err, false); } else { bdrv_img_create(backup->target, backup->format, NULL, NULL, NULL, size, flags, &local_err, false); } } if (local_err) { error_propagate(errp, local_err); goto out; } if (backup->format) { options = qdict_new(); qdict_put(options, "driver", qstring_from_str(backup->format)); } target_bs = bdrv_open(backup->target, NULL, options, flags, errp); if (!target_bs) { goto out; } bdrv_set_aio_context(target_bs, aio_context); if (backup->has_bitmap) { bmap = bdrv_find_dirty_bitmap(bs, backup->bitmap); if (!bmap) { error_setg(errp, "Bitmap '%s' could not be found", backup->bitmap); bdrv_unref(target_bs); goto out; } } backup_start(backup->job_id, bs, target_bs, backup->speed, backup->sync, bmap, backup->on_source_error, backup->on_target_error, block_job_cb, bs, txn, &local_err); bdrv_unref(target_bs); if (local_err != NULL) { error_propagate(errp, local_err); goto out; } out: aio_context_release(aio_context); } | 26,067 |
0 | static int encrypt_sectors(BDRVQcowState *s, int64_t sector_num, uint8_t *buf, int nb_sectors, bool enc, Error **errp) { union { uint64_t ll[2]; uint8_t b[16]; } ivec; int i; int ret; for(i = 0; i < nb_sectors; i++) { ivec.ll[0] = cpu_to_le64(sector_num); ivec.ll[1] = 0; if (qcrypto_cipher_setiv(s->cipher, ivec.b, G_N_ELEMENTS(ivec.b), errp) < 0) { return -1; } if (enc) { ret = qcrypto_cipher_encrypt(s->cipher, buf, buf, 512, errp); } else { ret = qcrypto_cipher_decrypt(s->cipher, buf, buf, 512, errp); } if (ret < 0) { return -1; } sector_num++; buf += 512; } return 0; } | 26,068 |
0 | static void nbd_teardown_connection(BlockDriverState *bs) { NBDClientSession *client = nbd_get_client_session(bs); if (!client->ioc) { /* Already closed */ return; } /* finish any pending coroutines */ qio_channel_shutdown(client->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); nbd_recv_coroutines_enter_all(bs); nbd_client_detach_aio_context(bs); object_unref(OBJECT(client->sioc)); client->sioc = NULL; object_unref(OBJECT(client->ioc)); client->ioc = NULL; } | 26,070 |
0 | static int cinepak_decode_strip (CinepakContext *s, cvid_strip *strip, const uint8_t *data, int size) { const uint8_t *eod = (data + size); int chunk_id, chunk_size; /* coordinate sanity checks */ if (strip->x1 >= s->width || strip->x2 > s->width || strip->y1 >= s->height || strip->y2 > s->height || strip->x1 >= strip->x2 || strip->y1 >= strip->y2) return -1; while ((data + 4) <= eod) { chunk_id = data[0]; chunk_size = AV_RB24 (&data[1]) - 4; if(chunk_size < 0) return -1; data += 4; chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size; switch (chunk_id) { case 0x20: case 0x21: case 0x24: case 0x25: cinepak_decode_codebook (strip->v4_codebook, chunk_id, chunk_size, data); break; case 0x22: case 0x23: case 0x26: case 0x27: cinepak_decode_codebook (strip->v1_codebook, chunk_id, chunk_size, data); break; case 0x30: case 0x31: case 0x32: return cinepak_decode_vectors (s, strip, chunk_id, chunk_size, data); } data += chunk_size; } return -1; } | 26,071 |
0 | static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BlockDriver *drv = bs->drv; int64_t sector_num = offset >> BDRV_SECTOR_BITS; unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS; int ret; assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS); if (drv->bdrv_co_writev_flags) { ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov, flags); } else { assert(drv->supported_write_flags == 0); ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); } if (ret == 0 && (flags & BDRV_REQ_FUA) && !(drv->supported_write_flags & BDRV_REQ_FUA)) { ret = bdrv_co_flush(bs); } return ret; } | 26,072 |
0 | static void ss10_init(int ram_size, int vga_ram_size, int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { if (cpu_model == NULL) cpu_model = "TI SuperSparc II"; sun4m_common_init(ram_size, boot_device, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, 1, PROM_ADDR); // XXX prom overlap, actually first 4GB ok } | 26,073 |
0 | static uint64_t bonito_readl(void *opaque, target_phys_addr_t addr, unsigned size) { PCIBonitoState *s = opaque; uint32_t saddr; saddr = (addr - BONITO_REGBASE) >> 2; DPRINTF("bonito_readl "TARGET_FMT_plx"\n", addr); switch (saddr) { case BONITO_INTISR: return s->regs[saddr]; default: return s->regs[saddr]; } } | 26,074 |
0 | static int ast_write_header(AVFormatContext *s) { ASTMuxContext *ast = s->priv_data; AVIOContext *pb = s->pb; AVCodecContext *enc; unsigned int codec_tag; if (s->nb_streams == 1) { enc = s->streams[0]->codec; } else { av_log(s, AV_LOG_ERROR, "only one stream is supported\n"); return AVERROR(EINVAL); } if (enc->codec_id == AV_CODEC_ID_ADPCM_AFC) { av_log(s, AV_LOG_ERROR, "muxing ADPCM AFC is not implemented\n"); return AVERROR_PATCHWELCOME; } codec_tag = ff_codec_get_tag(ff_codec_ast_tags, enc->codec_id); if (!codec_tag) { av_log(s, AV_LOG_ERROR, "unsupported codec\n"); return AVERROR(EINVAL); } if (ast->loopstart && ast->loopend && ast->loopstart >= ast->loopend) { av_log(s, AV_LOG_ERROR, "loopend can't be less or equal to loopstart\n"); return AVERROR(EINVAL); } /* Convert milliseconds to samples */ CHECK_LOOP(start) CHECK_LOOP(end) ffio_wfourcc(pb, "STRM"); ast->size = avio_tell(pb); avio_wb32(pb, 0); /* File size minus header */ avio_wb16(pb, codec_tag); avio_wb16(pb, 16); /* Bit depth */ avio_wb16(pb, enc->channels); avio_wb16(pb, 0xFFFF); avio_wb32(pb, enc->sample_rate); ast->samples = avio_tell(pb); avio_wb32(pb, 0); /* Number of samples */ avio_wb32(pb, 0); /* Loopstart */ avio_wb32(pb, 0); /* Loopend */ avio_wb32(pb, 0); /* Size of first block */ /* Unknown */ avio_wb32(pb, 0); avio_wl32(pb, 0x7F); avio_wb64(pb, 0); avio_wb64(pb, 0); avio_wb32(pb, 0); avio_flush(pb); return 0; } | 26,076 |
0 | static int read_old_huffman_tables(HYuvContext *s) { GetBitContext gb; int i; init_get_bits(&gb, classic_shift_luma, classic_shift_luma_table_size * 8); if (read_len_table(s->len[0], &gb) < 0) return -1; init_get_bits(&gb, classic_shift_chroma, classic_shift_chroma_table_size * 8); if (read_len_table(s->len[1], &gb) < 0) return -1; for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i]; for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i]; if (s->bitstream_bpp >= 24) { memcpy(s->bits[1], s->bits[0], 256 * sizeof(uint32_t)); memcpy(s->len[1] , s->len [0], 256 * sizeof(uint8_t)); } memcpy(s->bits[2], s->bits[1], 256 * sizeof(uint32_t)); memcpy(s->len[2] , s->len [1], 256 * sizeof(uint8_t)); for (i = 0; i < 3; i++) { ff_free_vlc(&s->vlc[i]); init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0); } generate_joint_tables(s); return 0; } | 26,077 |
1 | static void pc_init_isa(MachineState *machine) { has_pci_info = false; has_acpi_build = false; smbios_defaults = false; if (!machine->cpu_model) { machine->cpu_model = "486"; } x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI); enable_compat_apic_id_mode(); pc_init1(machine, 0, 1); } | 26,078 |
1 | static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, GetBitContext *gb) { const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac; const int aot = m4ac->object_type; const int sampling_index = m4ac->sampling_index; if (aot != AOT_ER_AAC_ELD) { if (get_bits1(gb)) { av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n"); return AVERROR_INVALIDDATA; } ics->window_sequence[1] = ics->window_sequence[0]; ics->window_sequence[0] = get_bits(gb, 2); if (aot == AOT_ER_AAC_LD && ics->window_sequence[0] != ONLY_LONG_SEQUENCE) { av_log(ac->avctx, AV_LOG_ERROR, "AAC LD is only defined for ONLY_LONG_SEQUENCE but " "window sequence %d found.\n", ics->window_sequence[0]); ics->window_sequence[0] = ONLY_LONG_SEQUENCE; return AVERROR_INVALIDDATA; } ics->use_kb_window[1] = ics->use_kb_window[0]; ics->use_kb_window[0] = get_bits1(gb); } ics->num_window_groups = 1; ics->group_len[0] = 1; if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { int i; ics->max_sfb = get_bits(gb, 4); for (i = 0; i < 7; i++) { if (get_bits1(gb)) { ics->group_len[ics->num_window_groups - 1]++; } else { ics->num_window_groups++; ics->group_len[ics->num_window_groups - 1] = 1; } } ics->num_windows = 8; ics->swb_offset = ff_swb_offset_128[sampling_index]; ics->num_swb = ff_aac_num_swb_128[sampling_index]; ics->tns_max_bands = ff_tns_max_bands_128[sampling_index]; ics->predictor_present = 0; } else { ics->max_sfb = get_bits(gb, 6); ics->num_windows = 1; if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) { if (m4ac->frame_length_short) { ics->swb_offset = ff_swb_offset_480[sampling_index]; ics->num_swb = ff_aac_num_swb_480[sampling_index]; ics->tns_max_bands = ff_tns_max_bands_480[sampling_index]; } else { ics->swb_offset = ff_swb_offset_512[sampling_index]; ics->num_swb = ff_aac_num_swb_512[sampling_index]; ics->tns_max_bands = ff_tns_max_bands_512[sampling_index]; } if (!ics->num_swb || !ics->swb_offset) return AVERROR_BUG; } else { ics->swb_offset = ff_swb_offset_1024[sampling_index]; ics->num_swb = ff_aac_num_swb_1024[sampling_index]; ics->tns_max_bands = ff_tns_max_bands_1024[sampling_index]; } if (aot != AOT_ER_AAC_ELD) { ics->predictor_present = get_bits1(gb); ics->predictor_reset_group = 0; } if (ics->predictor_present) { if (aot == AOT_AAC_MAIN) { if (decode_prediction(ac, ics, gb)) { return AVERROR_INVALIDDATA; } } else if (aot == AOT_AAC_LC || aot == AOT_ER_AAC_LC) { av_log(ac->avctx, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n"); return AVERROR_INVALIDDATA; } else { if (aot == AOT_ER_AAC_LD) { av_log(ac->avctx, AV_LOG_ERROR, "LTP in ER AAC LD not yet implemented.\n"); return AVERROR_PATCHWELCOME; } if ((ics->ltp.present = get_bits(gb, 1))) decode_ltp(&ics->ltp, gb, ics->max_sfb); } } } if (ics->max_sfb > ics->num_swb) { av_log(ac->avctx, AV_LOG_ERROR, "Number of scalefactor bands in group (%d) " "exceeds limit (%d).\n", ics->max_sfb, ics->num_swb); return AVERROR_INVALIDDATA; } return 0; } | 26,079 |
1 | static void dvbsub_parse_region_segment(AVCodecContext *avctx, uint8_t *buf, int buf_size) { DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; uint8_t *buf_end = buf + buf_size; int region_id, object_id; DVBSubRegion *region; DVBSubObject *object; DVBSubObjectDisplay *display; int fill; if (buf_size < 10) return; region_id = *buf++; region = get_region(ctx, region_id); if (region == NULL) { region = av_mallocz(sizeof(DVBSubRegion)); region->id = region_id; region->next = ctx->region_list; ctx->region_list = region; fill = ((*buf++) >> 3) & 1; region->width = AV_RB16(buf); buf += 2; region->height = AV_RB16(buf); buf += 2; if (region->width * region->height != region->buf_size) { if (region->pbuf != 0) av_free(region->pbuf); region->buf_size = region->width * region->height; region->pbuf = av_malloc(region->buf_size); fill = 1; region->depth = 1 << (((*buf++) >> 2) & 7); region->clut = *buf++; if (region->depth == 8) region->bgcolour = *buf++; else { buf += 1; if (region->depth == 4) region->bgcolour = (((*buf++) >> 4) & 15); else region->bgcolour = (((*buf++) >> 2) & 3); #ifdef DEBUG av_log(avctx, AV_LOG_INFO, "Region %d, (%dx%d)\n", region_id, region->width, region->height); #endif if (fill) { memset(region->pbuf, region->bgcolour, region->buf_size); #ifdef DEBUG av_log(avctx, AV_LOG_INFO, "Fill region (%d)\n", region->bgcolour); #endif delete_region_display_list(ctx, region); while (buf + 5 < buf_end) { object_id = AV_RB16(buf); buf += 2; object = get_object(ctx, object_id); if (object == NULL) { object = av_mallocz(sizeof(DVBSubObject)); object->id = object_id; object->next = ctx->object_list; ctx->object_list = object; object->type = (*buf) >> 6; display = av_mallocz(sizeof(DVBSubObjectDisplay)); display->object_id = object_id; display->region_id = region_id; display->x_pos = AV_RB16(buf) & 0xfff; buf += 2; display->y_pos = AV_RB16(buf) & 0xfff; buf += 2; if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) { display->fgcolour = *buf++; display->bgcolour = *buf++; display->region_list_next = region->display_list; region->display_list = display; display->object_list_next = object->display_list; object->display_list = display; | 26,080 |
1 | int ff_unlock_avcodec(const AVCodec *codec) { if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init) return 0; av_assert0(ff_avcodec_locked); ff_avcodec_locked = 0; atomic_fetch_add(&entangled_thread_counter, -1); if (lockmgr_cb) { if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE)) return -1; } return 0; } | 26,081 |
1 | static inline void copy(LZOContext *c, int cnt) { register const uint8_t *src = c->in; register uint8_t *dst = c->out; if (cnt > c->in_end - src) { cnt = FFMAX(c->in_end - src, 0); c->error |= AV_LZO_INPUT_DEPLETED; } if (cnt > c->out_end - dst) { cnt = FFMAX(c->out_end - dst, 0); c->error |= AV_LZO_OUTPUT_FULL; } #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED) AV_COPY32U(dst, src); src += 4; dst += 4; cnt -= 4; if (cnt > 0) #endif memcpy(dst, src, cnt); c->in = src + cnt; c->out = dst + cnt; } | 26,082 |
1 | static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid) { MXFDescriptor *descriptor = arg; switch(tag) { case 0x3F01: descriptor->sub_descriptors_count = avio_rb32(pb); if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID)) return -1; descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID)); if (!descriptor->sub_descriptors_refs) return -1; avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */ avio_read(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID)); break; case 0x3004: avio_read(pb, descriptor->essence_container_ul, 16); break; case 0x3006: descriptor->linked_track_id = avio_rb32(pb); break; case 0x3201: /* PictureEssenceCoding */ avio_read(pb, descriptor->essence_codec_ul, 16); break; case 0x3203: descriptor->width = avio_rb32(pb); break; case 0x3202: descriptor->height = avio_rb32(pb); break; case 0x320E: descriptor->aspect_ratio.num = avio_rb32(pb); descriptor->aspect_ratio.den = avio_rb32(pb); break; case 0x3D03: descriptor->sample_rate.num = avio_rb32(pb); descriptor->sample_rate.den = avio_rb32(pb); break; case 0x3D06: /* SoundEssenceCompression */ avio_read(pb, descriptor->essence_codec_ul, 16); break; case 0x3D07: descriptor->channels = avio_rb32(pb); break; case 0x3D01: descriptor->bits_per_sample = avio_rb32(pb); break; case 0x3401: mxf_read_pixel_layout(pb, descriptor); break; default: /* Private uid used by SONY C0023S01.mxf */ if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) { descriptor->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); if (!descriptor->extradata) return -1; descriptor->extradata_size = size; avio_read(pb, descriptor->extradata, size); } break; } return 0; } | 26,083 |
0 | static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) { AudioFIRContext *s = ctx->priv; const float *src = (const float *)s->in[0]->extended_data[ch]; int index1 = (s->index + 1) % 3; int index2 = (s->index + 2) % 3; float *sum = s->sum[ch]; AVFrame *out = arg; float *block; float *dst; int n, i, j; memset(sum, 0, sizeof(*sum) * s->fft_length); block = s->block[ch] + s->part_index * s->block_size; memset(block, 0, sizeof(*block) * s->fft_length); s->fdsp->vector_fmul_scalar(block + s->part_size, src, s->dry_gain, s->nb_samples); emms_c(); av_rdft_calc(s->rdft[ch], block); block[2 * s->part_size] = block[1]; block[1] = 0; j = s->part_index; for (i = 0; i < s->nb_partitions; i++) { const int coffset = i * s->coeff_size; const FFTComplex *coeff = s->coeff[ch * !s->one2many] + coffset; block = s->block[ch] + j * s->block_size; s->fcmul_add(sum, block, (const float *)coeff, s->part_size); if (j == 0) j = s->nb_partitions; j--; } sum[1] = sum[2 * s->part_size]; av_rdft_calc(s->irdft[ch], sum); dst = (float *)s->buffer->extended_data[ch] + index1 * s->part_size; for (n = 0; n < s->part_size; n++) { dst[n] += sum[n]; } dst = (float *)s->buffer->extended_data[ch] + index2 * s->part_size; memcpy(dst, sum + s->part_size, s->part_size * sizeof(*dst)); dst = (float *)s->buffer->extended_data[ch] + s->index * s->part_size; if (out) { float *ptr = (float *)out->extended_data[ch]; s->fdsp->vector_fmul_scalar(ptr, dst, s->gain * s->wet_gain, out->nb_samples); emms_c(); } return 0; } | 26,084 |
0 | static int aiff_read_packet(AVFormatContext *s, AVPacket *pkt) { AVStream *st = s->streams[0]; AIFFInputContext *aiff = s->priv_data; int64_t max_size; int res, size; /* calculate size of remaining data */ max_size = aiff->data_end - avio_tell(s->pb); if (max_size <= 0) return AVERROR_EOF; /* Now for that packet */ if (st->codec->block_align >= 17) // GSM, QCLP, IMA4 size = st->codec->block_align; else size = (MAX_SIZE / st->codec->block_align) * st->codec->block_align; size = FFMIN(max_size, size); res = av_get_packet(s->pb, pkt, size); if (res < 0) return res; if (size >= st->codec->block_align) pkt->flags &= ~AV_PKT_FLAG_CORRUPT; /* Only one stream in an AIFF file */ pkt->stream_index = 0; pkt->duration = (res / st->codec->block_align) * aiff->block_duration; return 0; } | 26,085 |
1 | static int get_riff(AVFormatContext *s, AVIOContext *pb) { AVIContext *avi = s->priv_data; char header[8]; int i; /* check RIFF header */ avio_read(pb, header, 4); avi->riff_end = avio_rl32(pb); /* RIFF chunk size */ avi->riff_end += avio_tell(pb); /* RIFF chunk end */ avio_read(pb, header + 4, 4); for (i = 0; avi_headers[i][0]; i++) if (!memcmp(header, avi_headers[i], 8)) break; if (!avi_headers[i][0]) return AVERROR_INVALIDDATA; if (header[7] == 0x19) av_log(s, AV_LOG_INFO, "This file has been generated by a totally broken muxer.\n"); return 0; } | 26,086 |
1 | static int decode_segment(TAKDecContext *s, int8_t mode, int32_t *decoded, int len) { struct CParam code; GetBitContext *gb = &s->gb; int i; if (!mode) { memset(decoded, 0, len * sizeof(*decoded)); return 0; } if (mode > FF_ARRAY_ELEMS(xcodes)) return AVERROR_INVALIDDATA; code = xcodes[mode - 1]; for (i = 0; i < len; i++) { int x = get_bits_long(gb, code.init); if (x >= code.escape && get_bits1(gb)) { x |= 1 << code.init; if (x >= code.aescape) { int scale = get_unary(gb, 1, 9); if (scale == 9) { int scale_bits = get_bits(gb, 3); if (scale_bits > 0) { if (scale_bits == 7) { scale_bits += get_bits(gb, 5); if (scale_bits > 29) return AVERROR_INVALIDDATA; } scale = get_bits_long(gb, scale_bits) + 1; x += code.scale * scale; } x += code.bias; } else x += code.scale * scale - code.escape; } else x -= code.escape; } decoded[i] = (x >> 1) ^ -(x & 1); } return 0; } | 26,088 |
1 | static int paf_video_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt) { PAFVideoDecContext *c = avctx->priv_data; uint8_t code, *dst, *end; int i, frame, ret; if (pkt->size < 2) return AVERROR_INVALIDDATA; bytestream2_init(&c->gb, pkt->data, pkt->size); code = bytestream2_get_byte(&c->gb); if ((code & 0xF) > 4) { avpriv_request_sample(avctx, "unknown/invalid code"); return AVERROR_INVALIDDATA; } if ((ret = ff_reget_buffer(avctx, c->pic)) < 0) return ret; if (code & 0x20) { // frame is keyframe for (i = 0; i < 4; i++) memset(c->frame[i], 0, c->frame_size); memset(c->pic->data[1], 0, AVPALETTE_SIZE); c->current_frame = 0; c->pic->key_frame = 1; c->pic->pict_type = AV_PICTURE_TYPE_I; } else { c->pic->key_frame = 0; c->pic->pict_type = AV_PICTURE_TYPE_P; } if (code & 0x40) { // palette update uint32_t *out = (uint32_t *)c->pic->data[1]; int index, count; index = bytestream2_get_byte(&c->gb); count = bytestream2_get_byte(&c->gb) + 1; if (index + count > 256) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&c->gb) < 3 * count) return AVERROR_INVALIDDATA; out += index; for (i = 0; i < count; i++) { unsigned r, g, b; r = bytestream2_get_byteu(&c->gb); r = r << 2 | r >> 4; g = bytestream2_get_byteu(&c->gb); g = g << 2 | g >> 4; b = bytestream2_get_byteu(&c->gb); b = b << 2 | b >> 4; *out++ = (0xFFU << 24) | (r << 16) | (g << 8) | b; } c->pic->palette_has_changed = 1; } switch (code & 0x0F) { case 0: /* Block-based motion compensation using 4x4 blocks with either * horizontal or vertical vectors; might incorporate VQ as well. */ if ((ret = decode_0(c, pkt->data, code)) < 0) return ret; break; case 1: /* Uncompressed data. This mode specifies that (width * height) bytes * should be copied directly from the encoded buffer into the output. */ dst = c->frame[c->current_frame]; // possibly chunk length data bytestream2_skip(&c->gb, 2); if (bytestream2_get_bytes_left(&c->gb) < c->video_size) return AVERROR_INVALIDDATA; bytestream2_get_bufferu(&c->gb, dst, c->video_size); break; case 2: /* Copy reference frame: Consume the next byte in the stream as the * reference frame (which should be 0, 1, 2, or 3, and should not be * the same as the current frame number). */ frame = bytestream2_get_byte(&c->gb); if (frame > 3) return AVERROR_INVALIDDATA; if (frame != c->current_frame) memcpy(c->frame[c->current_frame], c->frame[frame], c->frame_size); break; case 4: /* Run length encoding.*/ dst = c->frame[c->current_frame]; end = dst + c->video_size; bytestream2_skip(&c->gb, 2); while (dst < end) { int8_t code; int count; if (bytestream2_get_bytes_left(&c->gb) < 2) return AVERROR_INVALIDDATA; code = bytestream2_get_byteu(&c->gb); count = FFABS(code) + 1; if (dst + count > end) return AVERROR_INVALIDDATA; if (code < 0) memset(dst, bytestream2_get_byteu(&c->gb), count); else bytestream2_get_buffer(&c->gb, dst, count); dst += count; } break; default: av_assert0(0); } av_image_copy_plane(c->pic->data[0], c->pic->linesize[0], c->frame[c->current_frame], c->width, c->width, c->height); c->current_frame = (c->current_frame + 1) & 3; if ((ret = av_frame_ref(data, c->pic)) < 0) return ret; *got_frame = 1; return pkt->size; } | 26,089 |
1 | int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix, int stride) { int in_channels, out_channels, i, o; in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout); out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout); if ( in_channels < 0 || in_channels > AVRESAMPLE_MAX_CHANNELS || out_channels < 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) { av_log(avr, AV_LOG_ERROR, "Invalid channel layouts\n"); return AVERROR(EINVAL); } switch (avr->mix_coeff_type) { case AV_MIX_COEFF_TYPE_Q8: if (!avr->am->matrix_q8[0]) { av_log(avr, AV_LOG_ERROR, "matrix is not set\n"); return AVERROR(EINVAL); } for (o = 0; o < out_channels; o++) for (i = 0; i < in_channels; i++) matrix[o * stride + i] = avr->am->matrix_q8[o][i] / 256.0; break; case AV_MIX_COEFF_TYPE_Q15: if (!avr->am->matrix_q15[0]) { av_log(avr, AV_LOG_ERROR, "matrix is not set\n"); return AVERROR(EINVAL); } for (o = 0; o < out_channels; o++) for (i = 0; i < in_channels; i++) matrix[o * stride + i] = avr->am->matrix_q15[o][i] / 32768.0; break; case AV_MIX_COEFF_TYPE_FLT: if (!avr->am->matrix_flt[0]) { av_log(avr, AV_LOG_ERROR, "matrix is not set\n"); return AVERROR(EINVAL); } for (o = 0; o < out_channels; o++) for (i = 0; i < in_channels; i++) matrix[o * stride + i] = avr->am->matrix_flt[o][i]; break; default: av_log(avr, AV_LOG_ERROR, "Invalid mix coeff type\n"); return AVERROR(EINVAL); } return 0; } | 26,091 |
0 | static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index) { AVPacket out_pkt = { 0 }, flush_pkt = { 0 }; AVStream *st = s->streams[stream_index]; uint8_t *data = pkt ? pkt->data : NULL; int size = pkt ? pkt->size : 0; int ret = 0, got_output = 0; if (!pkt) { av_init_packet(&flush_pkt); pkt = &flush_pkt; got_output = 1; } while (size > 0 || (pkt == &flush_pkt && got_output)) { int len; av_init_packet(&out_pkt); len = av_parser_parse2(st->parser, st->codec, &out_pkt.data, &out_pkt.size, data, size, pkt->pts, pkt->dts, pkt->pos); pkt->pts = pkt->dts = AV_NOPTS_VALUE; /* increment read pointer */ data += len; size -= len; got_output = !!out_pkt.size; if (!out_pkt.size) continue; if (pkt->side_data) { out_pkt.side_data = pkt->side_data; out_pkt.side_data_elems = pkt->side_data_elems; pkt->side_data = NULL; pkt->side_data_elems = 0; } /* set the duration */ out_pkt.duration = 0; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if (st->codec->sample_rate > 0) { out_pkt.duration = av_rescale_q_rnd(st->parser->duration, (AVRational) { 1, st->codec->sample_rate }, st->time_base, AV_ROUND_DOWN); } } out_pkt.stream_index = st->index; out_pkt.pts = st->parser->pts; out_pkt.dts = st->parser->dts; out_pkt.pos = st->parser->pos; if (st->parser->key_frame == 1 || (st->parser->key_frame == -1 && st->parser->pict_type == AV_PICTURE_TYPE_I)) out_pkt.flags |= AV_PKT_FLAG_KEY; compute_pkt_fields(s, st, st->parser, &out_pkt); if ((s->iformat->flags & AVFMT_GENERIC_INDEX) && out_pkt.flags & AV_PKT_FLAG_KEY) { ff_reduce_index(s, st->index); av_add_index_entry(st, st->parser->frame_offset, out_pkt.dts, 0, 0, AVINDEX_KEYFRAME); } if (out_pkt.data == pkt->data && out_pkt.size == pkt->size) { out_pkt.buf = pkt->buf; pkt->buf = NULL; } if ((ret = av_dup_packet(&out_pkt)) < 0) goto fail; if (!add_to_pktbuf(&s->internal->parse_queue, &out_pkt, &s->internal->parse_queue_end)) { av_packet_unref(&out_pkt); ret = AVERROR(ENOMEM); goto fail; } } /* end of the stream => close and free the parser */ if (pkt == &flush_pkt) { av_parser_close(st->parser); st->parser = NULL; } fail: av_packet_unref(pkt); return ret; } | 26,092 |
1 | int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, uint8_t* buf, int buf_size, int64_t pos) { int size, i; uint8_t *ppcm[4] = {0}; if (buf_size < DV_PROFILE_BYTES || !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) || buf_size < c->sys->frame_size) { return -1; /* Broken frame, or not enough data */ } /* Queueing audio packet */ /* FIXME: in case of no audio/bad audio we have to do something */ size = dv_extract_audio_info(c, buf); for (i = 0; i < c->ach; i++) { c->audio_pkt[i].pos = pos; c->audio_pkt[i].size = size; c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate; ppcm[i] = c->audio_buf[i]; } dv_extract_audio(buf, ppcm, c->sys); /* We work with 720p frames split in half, thus even frames have * channels 0,1 and odd 2,3. */ if (c->sys->height == 720) { if (buf[1] & 0x0C) { c->audio_pkt[2].size = c->audio_pkt[3].size = 0; } else { c->audio_pkt[0].size = c->audio_pkt[1].size = 0; c->abytes += size; } } else { c->abytes += size; } /* Now it's time to return video packet */ size = dv_extract_video_info(c, buf); av_init_packet(pkt); pkt->data = buf; pkt->pos = pos; pkt->size = size; pkt->flags |= AV_PKT_FLAG_KEY; pkt->stream_index = c->vst->id; pkt->pts = c->frames; c->frames++; return size; } | 26,093 |
1 | int mmu40x_get_physical_address (CPUState *env, mmu_ctx_t *ctx, target_ulong address, int rw, int access_type) { ppcemb_tlb_t *tlb; target_phys_addr_t raddr; int i, ret, zsel, zpr, pr; ret = -1; raddr = -1; pr = msr_pr; for (i = 0; i < env->nb_tlb; i++) { tlb = &env->tlb[i].tlbe; if (ppcemb_tlb_check(env, tlb, &raddr, address, env->spr[SPR_40x_PID], 0, i) < 0) continue; zsel = (tlb->attr >> 4) & 0xF; zpr = (env->spr[SPR_40x_ZPR] >> (28 - (2 * zsel))) & 0x3; #if defined (DEBUG_SOFTWARE_TLB) if (loglevel != 0) { fprintf(logfile, "%s: TLB %d zsel %d zpr %d rw %d attr %08x\n", __func__, i, zsel, zpr, rw, tlb->attr); } #endif /* Check execute enable bit */ switch (zpr) { case 0x2: if (pr != 0) goto check_perms; /* No break here */ case 0x3: /* All accesses granted */ ctx->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; ret = 0; break; case 0x0: if (pr != 0) { ctx->prot = 0; ret = -2; break; } /* No break here */ case 0x1: check_perms: /* Check from TLB entry */ /* XXX: there is a problem here or in the TLB fill code... */ ctx->prot = tlb->prot; ctx->prot |= PAGE_EXEC; ret = check_prot(ctx->prot, rw, access_type); break; } if (ret >= 0) { ctx->raddr = raddr; #if defined (DEBUG_SOFTWARE_TLB) if (loglevel != 0) { fprintf(logfile, "%s: access granted " ADDRX " => " REGX " %d %d\n", __func__, address, ctx->raddr, ctx->prot, ret); } #endif return 0; } } #if defined (DEBUG_SOFTWARE_TLB) if (loglevel != 0) { fprintf(logfile, "%s: access refused " ADDRX " => " REGX " %d %d\n", __func__, address, raddr, ctx->prot, ret); } #endif return ret; } | 26,094 |
1 | int bdrv_get_dirty(BlockDriverState *bs, int64_t sector) { int64_t chunk = sector / (int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK; if (bs->dirty_bitmap != NULL && (sector << BDRV_SECTOR_BITS) <= bdrv_getlength(bs)) { return bs->dirty_bitmap[chunk]; } else { return 0; } } | 26,095 |
1 | static int gdv_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { GDVContext *gdv = avctx->priv_data; GetByteContext *gb = &gdv->gb; PutByteContext *pb = &gdv->pb; AVFrame *frame = data; int ret, i, pal_size; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size); int compression; unsigned flags; uint8_t *dst; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; if (pal && pal_size == AVPALETTE_SIZE) memcpy(gdv->pal, pal, AVPALETTE_SIZE); bytestream2_init(gb, avpkt->data, avpkt->size); bytestream2_init_writer(pb, gdv->frame, gdv->frame_size); flags = bytestream2_get_le32(gb); compression = flags & 0xF; rescale(gdv, gdv->frame, avctx->width, avctx->height, !!(flags & 0x10), !!(flags & 0x20)); switch (compression) { case 1: memset(gdv->frame + PREAMBLE_SIZE, 0, gdv->frame_size - PREAMBLE_SIZE); case 0: if (bytestream2_get_bytes_left(gb) < 256*3) return AVERROR_INVALIDDATA; for (i = 0; i < 256; i++) { unsigned r = bytestream2_get_byte(gb); unsigned g = bytestream2_get_byte(gb); unsigned b = bytestream2_get_byte(gb); gdv->pal[i] = 0xFFU << 24 | r << 18 | g << 10 | b << 2; } break; case 2: ret = decompress_2(avctx); break; case 3: break; case 5: ret = decompress_5(avctx, flags >> 8); break; case 6: ret = decompress_68(avctx, flags >> 8, 0); break; case 8: ret = decompress_68(avctx, flags >> 8, 1); break; default: return AVERROR_INVALIDDATA; } memcpy(frame->data[1], gdv->pal, AVPALETTE_SIZE); dst = frame->data[0]; if (!gdv->scale_v && !gdv->scale_h) { int sidx = PREAMBLE_SIZE, didx = 0; int y, x; for (y = 0; y < avctx->height; y++) { for (x = 0; x < avctx->width; x++) { dst[x+didx] = gdv->frame[x+sidx]; } sidx += avctx->width; didx += frame->linesize[0]; } } else { int sidx = PREAMBLE_SIZE, didx = 0; int y, x; for (y = 0; y < avctx->height; y++) { if (!gdv->scale_v) { for (x = 0; x < avctx->width; x++) { dst[didx + x] = gdv->frame[sidx + x]; } } else { for (x = 0; x < avctx->width; x++) { dst[didx + x] = gdv->frame[sidx + x/2]; } } if (!gdv->scale_h || ((y & 1) == 1)) { sidx += !gdv->scale_v ? avctx->width : avctx->width/2; } didx += frame->linesize[0]; } } *got_frame = 1; return ret < 0 ? ret : avpkt->size; } | 26,096 |
0 | int ff_rle_encode(uint8_t *outbuf, int out_size, const uint8_t *ptr , int bpp, int w, int add_rep, int xor_rep, int add_raw, int xor_raw) { int count, x; uint8_t *out = outbuf; for(x = 0; x < w; x += count) { /* see if we can encode the next set of pixels with RLE */ if((count = count_pixels(ptr, w-x, bpp, 1)) > 1) { if(out + bpp + 1 > outbuf + out_size) return -1; *out++ = (count ^ xor_rep) + add_rep; memcpy(out, ptr, bpp); out += bpp; } else { /* fall back on uncompressed */ count = count_pixels(ptr, w-x, bpp, 0); *out++ = (count ^ xor_raw) + add_raw; if(out + bpp*count > outbuf + out_size) return -1; memcpy(out, ptr, bpp * count); out += bpp * count; } ptr += count * bpp; } return out - outbuf; } | 26,097 |
0 | static void stream_component_close(VideoState *is, int stream_index) { AVFormatContext *ic = is->ic; AVCodecContext *avctx; if (stream_index < 0 || stream_index >= ic->nb_streams) return; avctx = ic->streams[stream_index]->codec; switch (avctx->codec_type) { case AVMEDIA_TYPE_AUDIO: packet_queue_abort(&is->audioq); SDL_CloseAudio(); packet_queue_flush(&is->audioq); av_free_packet(&is->audio_pkt); if (is->swr_ctx) swr_free(&is->swr_ctx); av_freep(&is->audio_buf1); is->audio_buf = NULL; av_freep(&is->frame); if (is->rdft) { av_rdft_end(is->rdft); av_freep(&is->rdft_data); is->rdft = NULL; is->rdft_bits = 0; } break; case AVMEDIA_TYPE_VIDEO: packet_queue_abort(&is->videoq); /* note: we also signal this mutex to make sure we deblock the video thread in all cases */ SDL_LockMutex(is->pictq_mutex); SDL_CondSignal(is->pictq_cond); SDL_UnlockMutex(is->pictq_mutex); SDL_WaitThread(is->video_tid, NULL); packet_queue_flush(&is->videoq); break; case AVMEDIA_TYPE_SUBTITLE: packet_queue_abort(&is->subtitleq); /* note: we also signal this mutex to make sure we deblock the video thread in all cases */ SDL_LockMutex(is->subpq_mutex); is->subtitle_stream_changed = 1; SDL_CondSignal(is->subpq_cond); SDL_UnlockMutex(is->subpq_mutex); SDL_WaitThread(is->subtitle_tid, NULL); packet_queue_flush(&is->subtitleq); break; default: break; } ic->streams[stream_index]->discard = AVDISCARD_ALL; avcodec_close(avctx); #if CONFIG_AVFILTER free_buffer_pool(&is->buffer_pool); #endif switch (avctx->codec_type) { case AVMEDIA_TYPE_AUDIO: is->audio_st = NULL; is->audio_stream = -1; break; case AVMEDIA_TYPE_VIDEO: is->video_st = NULL; is->video_stream = -1; break; case AVMEDIA_TYPE_SUBTITLE: is->subtitle_st = NULL; is->subtitle_stream = -1; break; default: break; } } | 26,098 |
1 | static inline int mpeg1_decode_block_inter(MpegEncContext *s, int16_t *block, int n) { int level, i, j, run; RLTable *rl = &ff_rl_mpeg1; uint8_t * const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix = s->inter_matrix; const int qscale = s->qscale; { OPEN_READER(re, &s->gb); i = -1; // special case for first coefficient, no need to add second VLC table UPDATE_CACHE(re, &s->gb); if (((int32_t)GET_CACHE(re, &s->gb)) < 0) { level = (3 * qscale * quant_matrix[0]) >> 5; level = (level - 1) | 1; if (GET_CACHE(re, &s->gb) & 0x40000000) level = -level; block[0] = level; i++; SKIP_BITS(re, &s->gb, 2); if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF) goto end; } /* now quantify & encode AC coefficients */ for (;;) { GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); if (level != 0) { i += run; j = scantable[i]; level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5; level = (level - 1) | 1; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1); } else { /* escape */ run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6); UPDATE_CACHE(re, &s->gb); level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8); if (level == -128) { level = SHOW_UBITS(re, &s->gb, 8) - 256; SKIP_BITS(re, &s->gb, 8); } else if (level == 0) { level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8); } i += run; j = scantable[i]; if (level < 0) { level = -level; level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5; level = (level - 1) | 1; level = -level; } else { level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5; level = (level - 1) | 1; } } if (i > 63) { av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y); return -1; } block[j] = level; if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF) break; UPDATE_CACHE(re, &s->gb); } end: LAST_SKIP_BITS(re, &s->gb, 2); CLOSE_READER(re, &s->gb); } s->block_last_index[n] = i; return 0; } | 26,099 |
1 | static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe, VP8Frame *prev_frame) { VP8Context *s = avctx->priv_data; int mb_x, mb_y; 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++) { VP8Macroblock *mb = s->macroblocks_base + ((s->mb_width + 1) * (mb_y + 1) + 1); int mb_xy = mb_y * s->mb_width; AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101); s->mv_min.x = -MARGIN; s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN; for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) { if (mb_y == 0) AV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top, DC_PRED * 0x01010101); decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy, prev_frame && prev_frame->seg_map ? prev_frame->seg_map->data + mb_xy : NULL, 1); s->mv_min.x -= 64; s->mv_max.x -= 64; } s->mv_min.y -= 64; s->mv_max.y -= 64; } } | 26,101 |
1 | static struct omap_eac_s *omap_eac_init(struct omap_target_agent_s *ta, qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk) { struct omap_eac_s *s = (struct omap_eac_s *) g_malloc0(sizeof(struct omap_eac_s)); s->irq = irq; s->codec.rxdrq = *drq ++; s->codec.txdrq = *drq; omap_eac_reset(s); AUD_register_card("OMAP EAC", &s->codec.card); memory_region_init_io(&s->iomem, NULL, &omap_eac_ops, s, "omap.eac", omap_l4_region_size(ta, 0)); omap_l4_attach(ta, 0, &s->iomem); return s; } | 26,102 |
1 | bool runstate_needs_reset(void) { return runstate_check(RUN_STATE_INTERNAL_ERROR) || runstate_check(RUN_STATE_SHUTDOWN) || runstate_check(RUN_STATE_GUEST_PANICKED); } | 26,103 |
1 | int64_t bdrv_getlength(BlockDriverState *bs) { int64_t ret = bdrv_nb_sectors(bs); return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE; } | 26,104 |
1 | static av_always_inline void mc_luma_scaled(VP9Context *s, vp9_scaled_mc_func smc, vp9_mc_func (*mc)[2], uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, ThreadFrame *ref_frame, ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv, int px, int py, int pw, int ph, int bw, int bh, int w, int h, int bytesperpixel, const uint16_t *scale, const uint8_t *step) { if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width && s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) { mc_luma_unscaled(s, mc, dst, dst_stride, ref, ref_stride, ref_frame, y, x, in_mv, bw, bh, w, h, bytesperpixel); } else { #define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14) int mx, my; int refbw_m1, refbh_m1; int th; VP56mv mv; mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 8, (s->cols * 8 - x + px + 3) * 8); mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 8, (s->rows * 8 - y + py + 3) * 8); // BUG libvpx seems to scale the two components separately. This introduces // rounding errors but we have to reproduce them to be exactly compatible // with the output from libvpx... mx = scale_mv(mv.x * 2, 0) + scale_mv(x * 16, 0); my = scale_mv(mv.y * 2, 1) + scale_mv(y * 16, 1); y = my >> 4; x = mx >> 4; ref += y * ref_stride + x * bytesperpixel; mx &= 15; my &= 15; refbw_m1 = ((bw - 1) * step[0] + mx) >> 4; refbh_m1 = ((bh - 1) * step[1] + my) >> 4; // FIXME bilinear filter only needs 0/1 pixels, not 3/4 // we use +7 because the last 7 pixels of each sbrow can be changed in // the longest loopfilter of the next sbrow th = (y + refbh_m1 + 4 + 7) >> 6; ff_thread_await_progress(ref_frame, FFMAX(th, 0), 0); if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) { s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ref - 3 * ref_stride - 3 * bytesperpixel, 288, ref_stride, refbw_m1 + 8, refbh_m1 + 8, x - 3, y - 3, w, h); ref = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel; ref_stride = 288; } smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]); } } | 26,105 |
1 | static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block) { int i; register int t1,t2,t3,t4; DCTELEM *src, *dst; const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; src = block; dst = block; for(i = 0; i < 4; i++){ t1 = 17 * (src[0] + src[2]) + 4; t2 = 17 * (src[0] - src[2]) + 4; t3 = 22 * src[1] + 10 * src[3]; t4 = 22 * src[3] - 10 * src[1]; dst[0] = (t1 + t3) >> 3; dst[1] = (t2 - t4) >> 3; dst[2] = (t2 + t4) >> 3; dst[3] = (t1 - t3) >> 3; src += 8; dst += 8; } src = block; for(i = 0; i < 4; i++){ t1 = 17 * (src[ 0] + src[16]) + 64; t2 = 17 * (src[ 0] - src[16]) + 64; t3 = 22 * src[ 8] + 10 * src[24]; t4 = 22 * src[24] - 10 * src[ 8]; dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)]; dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)]; dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)]; dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)]; src ++; dest++; } } | 26,106 |
1 | long do_rt_sigreturn(CPUSH4State *regs) { struct target_rt_sigframe *frame; abi_ulong frame_addr; sigset_t blocked; target_ulong r0; #if defined(DEBUG_SIGNAL) fprintf(stderr, "do_rt_sigreturn\n"); #endif frame_addr = regs->gregs[15]; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; target_to_host_sigset(&blocked, &frame->uc.tuc_sigmask); do_sigprocmask(SIG_SETMASK, &blocked, NULL); if (restore_sigcontext(regs, &frame->uc.tuc_mcontext, &r0)) goto badframe; if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, uc.tuc_stack), 0, get_sp_from_cpustate(regs)) == -EFAULT) goto badframe; unlock_user_struct(frame, frame_addr, 0); return r0; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; } | 26,107 |
1 | int ff_draw_init(FFDrawContext *draw, enum PixelFormat format, unsigned flags) { const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[format]; const AVComponentDescriptor *c; unsigned i, nb_planes = 0; int pixelstep[MAX_PLANES] = { 0 }; if (!desc->name) return AVERROR(EINVAL); if (desc->flags & ~(PIX_FMT_PLANAR | PIX_FMT_RGB)) return AVERROR(ENOSYS); for (i = 0; i < desc->nb_components; i++) { c = &desc->comp[i]; /* for now, only 8-bits formats */ if (c->depth_minus1 != 8 - 1) return AVERROR(ENOSYS); if (c->plane >= MAX_PLANES) return AVERROR(ENOSYS); /* strange interleaving */ if (pixelstep[c->plane] != 0 && pixelstep[c->plane] != c->step_minus1 + 1) return AVERROR(ENOSYS); pixelstep[c->plane] = c->step_minus1 + 1; if (pixelstep[c->plane] >= 8) return AVERROR(ENOSYS); nb_planes = FFMAX(nb_planes, c->plane + 1); } if ((desc->log2_chroma_w || desc->log2_chroma_h) && nb_planes < 3) return AVERROR(ENOSYS); /* exclude NV12 and NV21 */ memset(draw, 0, sizeof(*draw)); draw->desc = desc; draw->format = format; draw->nb_planes = nb_planes; memcpy(draw->pixelstep, pixelstep, sizeof(draw->pixelstep)); if (nb_planes >= 3 && !(desc->flags & PIX_FMT_RGB)) { draw->hsub[1] = draw->hsub[2] = draw->hsub_max = desc->log2_chroma_w; draw->vsub[1] = draw->vsub[2] = draw->vsub_max = desc->log2_chroma_h; } for (i = 0; i < ((desc->nb_components - 1) | 1); i++) draw->comp_mask[desc->comp[i].plane] |= 1 << (desc->comp[i].offset_plus1 - 1); return 0; } | 26,108 |
1 | static void pty_chr_close(struct CharDriverState *chr) { PtyCharDriver *s = chr->opaque; int fd; remove_fd_in_watch(chr); fd = g_io_channel_unix_get_fd(s->fd); g_io_channel_unref(s->fd); close(fd); if (s->timer_tag) { g_source_remove(s->timer_tag); s->timer_tag = 0; } g_free(s); qemu_chr_be_event(chr, CHR_EVENT_CLOSED); } | 26,109 |
0 | av_cold void ff_dct_init_mmx(DCTContext *s) { #if HAVE_YASM int has_vectors = av_get_cpu_flags(); if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) s->dct32 = ff_dct32_float_sse; if (has_vectors & AV_CPU_FLAG_SSE2 && HAVE_SSE) s->dct32 = ff_dct32_float_sse2; if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX) s->dct32 = ff_dct32_float_avx; #endif } | 26,111 |
0 | int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame) { AVFrame *tmp; int ret; av_assert0(avctx->codec_type == AVMEDIA_TYPE_VIDEO); if (!frame->data[0]) return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF); if (av_frame_is_writable(frame)) { frame->pkt_pts = avctx->internal->pkt ? avctx->internal->pkt->pts : AV_NOPTS_VALUE; frame->reordered_opaque = avctx->reordered_opaque; return 0; } tmp = av_frame_alloc(); if (!tmp) return AVERROR(ENOMEM); av_frame_move_ref(tmp, frame); ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF); if (ret < 0) { av_frame_free(&tmp); return ret; } av_frame_copy(frame, tmp); av_frame_free(&tmp); return 0; } | 26,112 |
0 | static void block_dirty_bitmap_add_abort(BlkActionState *common) { BlockDirtyBitmapAdd *action; BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState, common, common); action = common->action->u.block_dirty_bitmap_add; /* Should not be able to fail: IF the bitmap was added via .prepare(), * then the node reference and bitmap name must have been valid. */ if (state->prepared) { qmp_block_dirty_bitmap_remove(action->node, action->name, &error_abort); } } | 26,115 |
0 | static int cirrus_bitblt_common_patterncopy(CirrusVGAState *s, bool videosrc) { uint32_t patternsize; uint8_t *dst; uint8_t *src; dst = s->vga.vram_ptr + s->cirrus_blt_dstaddr; if (videosrc) { switch (s->vga.get_bpp(&s->vga)) { case 8: patternsize = 64; break; case 15: case 16: patternsize = 128; break; case 24: case 32: default: patternsize = 256; break; } s->cirrus_blt_srcaddr &= ~(patternsize - 1); if (s->cirrus_blt_srcaddr + patternsize > s->vga.vram_size) { return 0; } src = s->vga.vram_ptr + s->cirrus_blt_srcaddr; } else { src = s->cirrus_bltbuf; } if (blit_is_unsafe(s, true)) { return 0; } (*s->cirrus_rop) (s, dst, src, s->cirrus_blt_dstpitch, 0, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); return 1; } | 26,116 |
0 | static int nbd_handle_export_name(NBDClient *client, uint32_t length) { int rc = -EINVAL, csock = client->sock; char name[256]; /* Client sends: [20 .. xx] export name (length bytes) */ TRACE("Checking length"); if (length > 255) { LOG("Bad length received"); goto fail; } if (read_sync(csock, name, length) != length) { LOG("read failed"); goto fail; } name[length] = '\0'; client->exp = nbd_export_find(name); if (!client->exp) { LOG("export not found"); goto fail; } QTAILQ_INSERT_TAIL(&client->exp->clients, client, next); nbd_export_get(client->exp); rc = 0; fail: return rc; } | 26,119 |
0 | static void tcg_out_insn_3401(TCGContext *s, AArch64Insn insn, TCGType ext, TCGReg rd, TCGReg rn, uint64_t aimm) { if (aimm > 0xfff) { assert((aimm & 0xfff) == 0); aimm >>= 12; assert(aimm <= 0xfff); aimm |= 1 << 12; /* apply LSL 12 */ } tcg_out32(s, insn | ext << 31 | aimm << 10 | rn << 5 | rd); } | 26,120 |
0 | static int proxy_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, FsCred *credp) { int retval; V9fsString fullname; v9fs_string_init(&fullname); v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); retval = v9fs_request(fs_ctx->private, T_MKDIR, NULL, "sddd", &fullname, credp->fc_mode, credp->fc_uid, credp->fc_gid); v9fs_string_free(&fullname); if (retval < 0) { errno = -retval; retval = -1; } v9fs_string_free(&fullname); return retval; } | 26,121 |
0 | static always_inline uint64_t float_zero_divide_excp (uint64_t arg1, uint64_t arg2) { env->fpscr |= 1 << FPSCR_ZX; env->fpscr &= ~((1 << FPSCR_FR) | (1 << FPSCR_FI)); /* Update the floating-point exception summary */ env->fpscr |= 1 << FPSCR_FX; if (fpscr_ze != 0) { /* Update the floating-point enabled exception summary */ env->fpscr |= 1 << FPSCR_FEX; if (msr_fe0 != 0 || msr_fe1 != 0) { helper_raise_exception_err(POWERPC_EXCP_PROGRAM, POWERPC_EXCP_FP | POWERPC_EXCP_FP_ZX); } } else { /* Set the result to infinity */ arg1 = ((arg1 ^ arg2) & 0x8000000000000000ULL); arg1 |= 0x7FFULL << 52; } return arg1; } | 26,123 |
0 | void *s1d13745_init(qemu_irq gpio_int) { BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s)); DisplaySurface *surface; s->fb = g_malloc(0x180000); s->con = graphic_console_init(blizzard_update_display, blizzard_invalidate_display, blizzard_screen_dump, NULL, s); surface = qemu_console_surface(s->con); switch (surface_bits_per_pixel(surface)) { case 0: s->line_fn_tab[0] = s->line_fn_tab[1] = g_malloc0(sizeof(blizzard_fn_t) * 0x10); break; case 8: s->line_fn_tab[0] = blizzard_draw_fn_8; s->line_fn_tab[1] = blizzard_draw_fn_r_8; break; case 15: s->line_fn_tab[0] = blizzard_draw_fn_15; s->line_fn_tab[1] = blizzard_draw_fn_r_15; break; case 16: s->line_fn_tab[0] = blizzard_draw_fn_16; s->line_fn_tab[1] = blizzard_draw_fn_r_16; break; case 24: s->line_fn_tab[0] = blizzard_draw_fn_24; s->line_fn_tab[1] = blizzard_draw_fn_r_24; break; case 32: s->line_fn_tab[0] = blizzard_draw_fn_32; s->line_fn_tab[1] = blizzard_draw_fn_r_32; break; default: fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__); exit(1); } blizzard_reset(s); return s; } | 26,124 |