void tlb_fill(target_ulong addr, int is_write, int mmu_idx, void *retaddr) { tlb_set_page(cpu_single_env, addr & ~(TARGET_PAGE_SIZE - 1), addr & ~(TARGET_PAGE_SIZE - 1), PAGE_READ | PAGE_WRITE | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE); }


pp_context_t *pp_get_context(int width, int height, int cpuCaps){ PPContext *c= memalign(32, sizeof(PPContext)); int i; int stride= (width+15)&(~15); //assumed / will realloc if needed memset(c, 0, sizeof(PPContext)); c->cpuCaps= cpuCaps; if(cpuCaps&PP_FORMAT){ c->hChromaSubSample= cpuCaps&0x3; c->vChromaSubSample= (cpuCaps>>4)&0x3; }else{ c->hChromaSubSample= 1; c->vChromaSubSample= 1; } reallocBuffers(c, width, height, stride); c->frameNum=-1; return c; }


static gboolean gd_leave_event(GtkWidget *widget, GdkEventCrossing *crossing, gpointer opaque) { VirtualConsole *vc = opaque; GtkDisplayState *s = vc->s; if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) { gd_ungrab_keyboard(s); } return TRUE; }


static void vty_receive(void *opaque, const uint8_t *buf, int size) { VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)opaque; int i; if ((dev->in == dev->out) && size) { /* toggle line to simulate edge interrupt */ qemu_irq_pulse(dev->sdev.qirq); } for (i = 0; i < size; i++) { assert((dev->in - dev->out) < VTERM_BUFSIZE); dev->buf[dev->in++ % VTERM_BUFSIZE] = buf[i]; } }


int kvm_arch_process_async_events(CPUState *env) { return 0; }


static void coroutine_fn stream_run(void *opaque) { StreamBlockJob *s = opaque; StreamCompleteData *data; BlockBackend *blk = s->common.blk; BlockDriverState *bs = blk_bs(blk); BlockDriverState *base = s->base; int64_t sector_num = 0; int64_t end = -1; uint64_t delay_ns = 0; int error = 0; int ret = 0; int n = 0; void *buf; if (!bs->backing) { goto out; } s->common.len = bdrv_getlength(bs); if (s->common.len < 0) { ret = s->common.len; goto out; } end = s->common.len >> BDRV_SECTOR_BITS; buf = qemu_blockalign(bs, STREAM_BUFFER_SIZE); /* Turn on copy-on-read for the whole block device so that guest read * requests help us make progress. Only do this when copying the entire * backing chain since the copy-on-read operation does not take base into * account. */ if (!base) { bdrv_enable_copy_on_read(bs); } for (sector_num = 0; sector_num < end; sector_num += n) { bool copy; /* Note that even when no rate limit is applied we need to yield * with no pending I/O here so that bdrv_drain_all() returns. */ block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); if (block_job_is_cancelled(&s->common)) { break; } copy = false; ret = bdrv_is_allocated(bs, sector_num, STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n); if (ret == 1) { /* Allocated in the top, no need to copy. */ } else if (ret >= 0) { /* Copy if allocated in the intermediate images. Limit to the * known-unallocated area [sector_num, sector_num+n). */ ret = bdrv_is_allocated_above(backing_bs(bs), base, sector_num, n, &n); /* Finish early if end of backing file has been reached */ if (ret == 0 && n == 0) { n = end - sector_num; } copy = (ret == 1); } trace_stream_one_iteration(s, sector_num * BDRV_SECTOR_SIZE, n * BDRV_SECTOR_SIZE, ret); if (copy) { ret = stream_populate(blk, sector_num * BDRV_SECTOR_SIZE, n * BDRV_SECTOR_SIZE, buf); } if (ret < 0) { BlockErrorAction action = block_job_error_action(&s->common, s->on_error, true, -ret); if (action == BLOCK_ERROR_ACTION_STOP) { n = 0; continue; } if (error == 0) { error = ret; } if (action == BLOCK_ERROR_ACTION_REPORT) { break; } } ret = 0; /* Publish progress */ s->common.offset += n * BDRV_SECTOR_SIZE; if (copy && s->common.speed) { delay_ns = ratelimit_calculate_delay(&s->limit, n * BDRV_SECTOR_SIZE); } } if (!base) { bdrv_disable_copy_on_read(bs); } /* Do not remove the backing file if an error was there but ignored. */ ret = error; qemu_vfree(buf); out: /* Modify backing chain and close BDSes in main loop */ data = g_malloc(sizeof(*data)); data->ret = ret; block_job_defer_to_main_loop(&s->common, stream_complete, data); }


static void palmte_onoff_gpios(void *opaque, int line, int level) { switch (line) { case 0: printf("%s: current to MMC/SD card %sabled.\n", __FUNCTION__, level ? "dis" : "en"); break; case 1: printf("%s: internal speaker amplifier %s.\n", __FUNCTION__, level ? "down" : "on"); break; /* These LCD & Audio output signals have not been identified yet. */ case 2: case 3: case 4: printf("%s: LCD GPIO%i %s.\n", __FUNCTION__, line - 1, level ? "high" : "low"); break; case 5: case 6: printf("%s: Audio GPIO%i %s.\n", __FUNCTION__, line - 4, level ? "high" : "low"); break; } }


static int ppc_hash64_check_prot(int prot, int rwx) { int ret; if (rwx == 2) { if (prot & PAGE_EXEC) { ret = 0; } else { ret = -2; } } else if (rwx == 1) { if (prot & PAGE_WRITE) { ret = 0; } else { ret = -2; } } else { if (prot & PAGE_READ) { ret = 0; } else { ret = -2; } } return ret; }


static void exynos4210_pwm_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { Exynos4210PWMState *s = (Exynos4210PWMState *)opaque; int index; uint32_t new_val; int i; switch (offset) { case TCFG0: case TCFG1: index = (offset - TCFG0) >> 2; s->reg_tcfg[index] = value; /* update timers frequencies */ for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) { exynos4210_pwm_update_freq(s, s->timer[i].id); } break; case TCON: for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) { if ((value & TCON_TIMER_MANUAL_UPD(i)) > (s->reg_tcon & TCON_TIMER_MANUAL_UPD(i))) { /* * TCNTB and TCMPB are loaded into TCNT and TCMP. * Update timers. */ /* this will start timer to run, this ok, because * during processing start bit timer will be stopped * if needed */ ptimer_set_count(s->timer[i].ptimer, s->timer[i].reg_tcntb); DPRINTF("set timer %d count to %x\n", i, s->timer[i].reg_tcntb); } if ((value & TCON_TIMER_START(i)) > (s->reg_tcon & TCON_TIMER_START(i))) { /* changed to start */ ptimer_run(s->timer[i].ptimer, 1); DPRINTF("run timer %d\n", i); } if ((value & TCON_TIMER_START(i)) < (s->reg_tcon & TCON_TIMER_START(i))) { /* changed to stop */ ptimer_stop(s->timer[i].ptimer); DPRINTF("stop timer %d\n", i); } } s->reg_tcon = value; break; case TCNTB0: case TCNTB1: case TCNTB2: case TCNTB3: case TCNTB4: index = (offset - TCNTB0) / 0xC; s->timer[index].reg_tcntb = value; break; case TCMPB0: case TCMPB1: case TCMPB2: case TCMPB3: index = (offset - TCMPB0) / 0xC; s->timer[index].reg_tcmpb = value; break; case TINT_CSTAT: new_val = (s->reg_tint_cstat & 0x3E0) + (0x1F & value); new_val &= ~(0x3E0 & value); for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) { if ((new_val & TINT_CSTAT_STATUS(i)) < (s->reg_tint_cstat & TINT_CSTAT_STATUS(i))) { qemu_irq_lower(s->timer[i].irq); } } s->reg_tint_cstat = new_val; break; default: fprintf(stderr, "[exynos4210.pwm: bad write offset " TARGET_FMT_plx "]\n", offset); break; } }


static void smbios_build_type_1_table(void) { SMBIOS_BUILD_TABLE_PRE(1, 0x100, true); /* required */ SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer); SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product); SMBIOS_TABLE_SET_STR(1, version_str, type1.version); SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial); if (qemu_uuid_set) { smbios_encode_uuid(&t->uuid, qemu_uuid); } else { memset(&t->uuid, 0, 16); } t->wake_up_type = 0x06; /* power switch */ SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku); SMBIOS_TABLE_SET_STR(1, family_str, type1.family); SMBIOS_BUILD_TABLE_POST; }


static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MpegEncContext *s = avctx->priv_data; int i; AVFrame *pict = data; int slice_count; const uint8_t *slices_hdr = NULL; av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size); /* no supplementary picture */ if (buf_size == 0) { return 0; } if(!avctx->slice_count){ slice_count = (*buf++) + 1; buf_size--; slices_hdr = buf + 4; buf += 8 * slice_count; buf_size -= 8 * slice_count; if (buf_size <= 0) return AVERROR_INVALIDDATA; }else slice_count = avctx->slice_count; for(i=0; i<slice_count; i++){ unsigned offset = get_slice_offset(avctx, slices_hdr, i); int size, size2; if (offset >= buf_size) return AVERROR_INVALIDDATA; if(i+1 == slice_count) size= buf_size - offset; else size= get_slice_offset(avctx, slices_hdr, i+1) - offset; if(i+2 >= slice_count) size2= buf_size - offset; else size2= get_slice_offset(avctx, slices_hdr, i+2) - offset; if (size <= 0 || size2 <= 0 || offset + FFMAX(size, size2) > buf_size) return AVERROR_INVALIDDATA; if(rv10_decode_packet(avctx, buf+offset, size, size2) > 8*size) i++; } if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){ ff_er_frame_end(s); ff_MPV_frame_end(s); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { *pict = s->current_picture_ptr->f; } else if (s->last_picture_ptr != NULL) { *pict = s->last_picture_ptr->f; } if(s->last_picture_ptr || s->low_delay){ *got_frame = 1; ff_print_debug_info(s, pict); } s->current_picture_ptr= NULL; // so we can detect if frame_end was not called (find some nicer solution...) } return avpkt->size; }


int css_do_rchp(uint8_t cssid, uint8_t chpid) { uint8_t real_cssid; if (cssid > channel_subsys.max_cssid) { return -EINVAL; } if (channel_subsys.max_cssid == 0) { real_cssid = channel_subsys.default_cssid; } else { real_cssid = cssid; } if (!channel_subsys.css[real_cssid]) { return -EINVAL; } if (!channel_subsys.css[real_cssid]->chpids[chpid].in_use) { return -ENODEV; } if (!channel_subsys.css[real_cssid]->chpids[chpid].is_virtual) { fprintf(stderr, "rchp unsupported for non-virtual chpid %x.%02x!\n", real_cssid, chpid); return -ENODEV; } /* We don't really use a channel path, so we're done here. */ css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT, channel_subsys.max_cssid > 0 ? 1 : 0, chpid); if (channel_subsys.max_cssid > 0) { css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT, 0, real_cssid << 8); } return 0; }


static void gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src, TCGv addr, int insn) { TCGv_i32 r_asi, r_size, r_sign; TCGv_i64 s64, t64 = tcg_temp_new_i64(); r_asi = gen_get_asi(dc, insn); r_size = tcg_const_i32(4); r_sign = tcg_const_i32(0); gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_size, r_sign); tcg_temp_free_i32(r_sign); s64 = tcg_temp_new_i64(); tcg_gen_extu_tl_i64(s64, src); gen_helper_st_asi(cpu_env, addr, s64, r_asi, r_size); tcg_temp_free_i64(s64); tcg_temp_free_i32(r_size); tcg_temp_free_i32(r_asi); tcg_gen_trunc_i64_tl(dst, t64); tcg_temp_free_i64(t64); }


static void borzoi_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) { spitz_common_init(ram_size, vga_ram_size, ds, kernel_filename, kernel_cmdline, initrd_filename, borzoi, 0x33f); }


static struct addrinfo *inet_parse_connect_opts(QemuOpts *opts, Error **errp) { struct addrinfo ai, *res; int rc; const char *addr; const char *port; memset(&ai, 0, sizeof(ai)); ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; ai.ai_family = PF_UNSPEC; ai.ai_socktype = SOCK_STREAM; addr = qemu_opt_get(opts, "host"); port = qemu_opt_get(opts, "port"); if (addr == NULL || port == NULL) { error_setg(errp, "host and/or port not specified"); return NULL; } if (qemu_opt_get_bool(opts, "ipv4", 0)) { ai.ai_family = PF_INET; } if (qemu_opt_get_bool(opts, "ipv6", 0)) { ai.ai_family = PF_INET6; } /* lookup */ rc = getaddrinfo(addr, port, &ai, &res); if (rc != 0) { error_setg(errp, "address resolution failed for %s:%s: %s", addr, port, gai_strerror(rc)); return NULL; } return res; }


static int arm_gic_init(SysBusDevice *dev) { /* Device instance init function for the GIC sysbus device */ int i; GICState *s = FROM_SYSBUS(GICState, dev); ARMGICClass *agc = ARM_GIC_GET_CLASS(s); agc->parent_init(dev); gic_init_irqs_and_distributor(s, s->num_irq); /* Memory regions for the CPU interfaces (NVIC doesn't have these): * a region for "CPU interface for this core", then a region for * "CPU interface for core 0", "for core 1", ... * NB that the memory region size of 0x100 applies for the 11MPCore * and also cores following the GIC v1 spec (ie A9). * GIC v2 defines a larger memory region (0x1000) so this will need * to be extended when we implement A15. */ memory_region_init_io(&s->cpuiomem[0], &gic_thiscpu_ops, s, "gic_cpu", 0x100); for (i = 0; i < NUM_CPU(s); i++) { s->backref[i] = s; memory_region_init_io(&s->cpuiomem[i+1], &gic_cpu_ops, &s->backref[i], "gic_cpu", 0x100); } /* Distributor */ sysbus_init_mmio(dev, &s->iomem); /* cpu interfaces (one for "current cpu" plus one per cpu) */ for (i = 0; i <= NUM_CPU(s); i++) { sysbus_init_mmio(dev, &s->cpuiomem[i]); } return 0; }


static bool addrrange_intersects(AddrRange r1, AddrRange r2) { return (r1.start >= r2.start && r1.start < r2.start + r2.size) || (r2.start >= r1.start && r2.start < r1.start + r1.size); }


static void network_to_result(RDMARegisterResult *result) { result->rkey = ntohl(result->rkey); result->host_addr = ntohll(result->host_addr); };


static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, int width, enum PixelFormat srcFormat) { if(srcFormat == PIX_FMT_BGR24) { __asm__ volatile( "movq "MANGLE(ff_bgr24toY1Coeff)", %%mm5 \n\t" "movq "MANGLE(ff_bgr24toY2Coeff)", %%mm6 \n\t" : ); } else { __asm__ volatile( "movq "MANGLE(ff_rgb24toY1Coeff)", %%mm5 \n\t" "movq "MANGLE(ff_rgb24toY2Coeff)", %%mm6 \n\t" : ); } __asm__ volatile( "movq "MANGLE(ff_bgr24toYOffset)", %%mm4 \n\t" "mov %2, %%"REG_a" \n\t" "pxor %%mm7, %%mm7 \n\t" "1: \n\t" PREFETCH" 64(%0) \n\t" "movd (%0), %%mm0 \n\t" "movd 2(%0), %%mm1 \n\t" "movd 6(%0), %%mm2 \n\t" "movd 8(%0), %%mm3 \n\t" "add $12, %0 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" "paddd %%mm1, %%mm0 \n\t" "paddd %%mm3, %%mm2 \n\t" "paddd %%mm4, %%mm0 \n\t" "paddd %%mm4, %%mm2 \n\t" "psrad $15, %%mm0 \n\t" "psrad $15, %%mm2 \n\t" "packssdw %%mm2, %%mm0 \n\t" "packuswb %%mm0, %%mm0 \n\t" "movd %%mm0, (%1, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : "+r" (src) : "r" (dst+width), "g" ((x86_reg)-width) : "%"REG_a ); }


static int xvid_ff_2pass_after(struct xvid_context *ref, xvid_plg_data_t *param) { char *log = ref->twopassbuffer; const char *frame_types = " ipbs"; char frame_type; /* Quick bounds check */ if( log == NULL ) return XVID_ERR_FAIL; /* Convert the type given to us into a character */ if( param->type < 5 && param->type > 0 ) { frame_type = frame_types[param->type]; } else { return XVID_ERR_FAIL; } snprintf(BUFFER_CAT(log), BUFFER_REMAINING(log), "%c %d %d %d %d %d %d\n", frame_type, param->stats.quant, param->stats.kblks, param->stats.mblks, param->stats.ublks, param->stats.length, param->stats.hlength); return 0; }


int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame, struct vdpau_picture_context *pic_ctx) { VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data; AVVDPAUContext *hwctx = avctx->hwaccel_context; VdpVideoSurface surf = ff_vdpau_get_surface_id(frame); VdpStatus status; int val; val = ff_vdpau_common_reinit(avctx); if (val < 0) return val; #if FF_API_BUFS_VDPAU FF_DISABLE_DEPRECATION_WARNINGS hwctx->info = pic_ctx->info; hwctx->bitstream_buffers = pic_ctx->bitstream_buffers; hwctx->bitstream_buffers_used = pic_ctx->bitstream_buffers_used; hwctx->bitstream_buffers_allocated = pic_ctx->bitstream_buffers_allocated; FF_ENABLE_DEPRECATION_WARNINGS #endif if (!hwctx->render) { status = hwctx->render2(avctx, frame, (void *)&pic_ctx->info, pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers); } else status = vdctx->render(vdctx->decoder, surf, (void *)&pic_ctx->info, pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers); av_freep(&pic_ctx->bitstream_buffers); #if FF_API_BUFS_VDPAU FF_DISABLE_DEPRECATION_WARNINGS hwctx->bitstream_buffers = NULL; hwctx->bitstream_buffers_used = 0; hwctx->bitstream_buffers_allocated = 0; FF_ENABLE_DEPRECATION_WARNINGS #endif return vdpau_error(status); }


static CheckasmFunc *get_func(const char *name, int length) { CheckasmFunc *f, **f_ptr = &state.funcs; /* Search the tree for a matching node */ while ((f = *f_ptr)) { int cmp = cmp_func_names(name, f->name); if (!cmp) return f; f_ptr = &f->child[(cmp > 0)]; } /* Allocate and insert a new node into the tree */ f = *f_ptr = checkasm_malloc(sizeof(CheckasmFunc) + length); memcpy(f->name, name, length+1); return f; }


static void unref_picture(H264Context *h, Picture *pic) { int off = offsetof(Picture, tf) + sizeof(pic->tf); int i; if (!pic->f.data[0]) return; ff_thread_release_buffer(h->avctx, &pic->tf); av_buffer_unref(&pic->hwaccel_priv_buf); av_buffer_unref(&pic->qscale_table_buf); av_buffer_unref(&pic->mb_type_buf); for (i = 0; i < 2; i++) { av_buffer_unref(&pic->motion_val_buf[i]); av_buffer_unref(&pic->ref_index_buf[i]); } memset((uint8_t*)pic + off, 0, sizeof(*pic) - off); }


void ff_free_parser_state(AVFormatContext *s, AVParserState *state) { int i; AVParserStreamState *ss; if (!state) return; for (i = 0; i < state->nb_streams; i++) { ss = &state->stream_states[i]; if (ss->parser) av_parser_close(ss->parser); av_free_packet(&ss->cur_pkt); } free_packet_list(state->packet_buffer); free_packet_list(state->raw_packet_buffer); av_free(state->stream_states); av_free(state); }


static int mjpeg_decode_com(MJpegDecodeContext *s) { /* XXX: verify len field validity */ int len = get_bits(&s->gb, 16); if (len >= 2 && len < 32768) { /* XXX: any better upper bound */ uint8_t *cbuf = av_malloc(len - 1); if (cbuf) { int i; for (i = 0; i < len - 2; i++) cbuf[i] = get_bits(&s->gb, 8); if (i > 0 && cbuf[i-1] == '\n') cbuf[i-1] = 0; else cbuf[i] = 0; if(s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_INFO, "mjpeg comment: '%s'\n", cbuf); /* buggy avid, it puts EOI only at every 10th frame */ if (!strcmp(cbuf, "AVID")) { s->buggy_avid = 1; // if (s->first_picture) // printf("mjpeg: workarounding buggy AVID\n"); } else if(!strcmp(cbuf, "CS=ITU601")){ s->cs_itu601= 1; } av_free(cbuf); } } return 0; }


static void xhci_runtime_write(void *ptr, hwaddr reg, uint64_t val, unsigned size) { XHCIState *xhci = ptr; int v = (reg - 0x20) / 0x20; XHCIInterrupter *intr = &xhci->intr[v]; trace_usb_xhci_runtime_write(reg, val); if (reg < 0x20) { trace_usb_xhci_unimplemented("runtime write", reg); return; switch (reg & 0x1f) { case 0x00: /* IMAN */ if (val & IMAN_IP) { intr->iman &= ~IMAN_IP; intr->iman &= ~IMAN_IE; intr->iman |= val & IMAN_IE; if (v == 0) { xhci_intx_update(xhci); xhci_msix_update(xhci, v); break; case 0x04: /* IMOD */ intr->imod = val; break; case 0x08: /* ERSTSZ */ intr->erstsz = val & 0xffff; break; case 0x10: /* ERSTBA low */ /* XXX NEC driver bug: it doesn't align this to 64 bytes intr->erstba_low = val & 0xffffffc0; */ intr->erstba_low = val & 0xfffffff0; break; case 0x14: /* ERSTBA high */ intr->erstba_high = val; xhci_er_reset(xhci, v); break; case 0x18: /* ERDP low */ intr->erdp_low &= ~ERDP_EHB; intr->erdp_low = (val & ~ERDP_EHB) | (intr->erdp_low & ERDP_EHB); break; case 0x1c: /* ERDP high */ intr->erdp_high = val; xhci_events_update(xhci, v); break; default: trace_usb_xhci_unimplemented("oper write", reg);


static void test_ide_none(void) { char *argv[256]; setup_common(argv, ARRAY_SIZE(argv)); qtest_start(g_strjoinv(" ", argv)); test_cmos(); qtest_end(); }


int ff_dca_xll_decode_audio(DCAContext *s, AVFrame *frame) { /* FIXME: Decodes only the first frequency band. */ int seg, chset_i; /* Coding parameters for each channel set. */ struct coding_params { int seg_type; int rice_code_flag[16]; int pancAuxABIT[16]; int pancABIT0[16]; /* Not sure what this is */ int pancABIT[16]; /* Not sure what this is */ int nSamplPart0[16]; } param_state[16]; GetBitContext *gb = &s->xll_navi.gb; int *history; /* Layout: First the sample buffer for one segment per channel, * followed by history buffers of DCA_XLL_AORDER_MAX samples for * each channel. */ av_fast_malloc(&s->xll_sample_buf, &s->xll_sample_buf_size, (s->xll_smpl_in_seg + DCA_XLL_AORDER_MAX) * s->xll_channels * sizeof(*s->xll_sample_buf)); if (!s->xll_sample_buf) return AVERROR(ENOMEM); history = s->xll_sample_buf + s->xll_smpl_in_seg * s->xll_channels; for (seg = 0; seg < s->xll_segments; seg++) { unsigned in_channel; for (chset_i = in_channel = 0; chset_i < s->xll_nch_sets; chset_i++) { /* The spec isn't very explicit, but I think the NAVI sizes are in bytes. */ int end_pos = get_bits_count(gb) + 8 * s->xll_navi.chset_size[0][seg][chset_i]; int i, j; struct coding_params *params = &param_state[chset_i]; /* I think this flag means that we should keep seg_type and * other parameters from the previous segment. */ int use_seg_state_code_param; XllChSetSubHeader *chset = &s->xll_chsets[chset_i]; if (in_channel >= s->avctx->channels) /* FIXME: Could go directly to next segment */ goto next_chset; if (s->avctx->sample_rate != chset->sampling_frequency) { av_log(s->avctx, AV_LOG_WARNING, "XLL: unexpected chset sample rate %d, expected %d\n", chset->sampling_frequency, s->avctx->sample_rate); goto next_chset; } if (seg != 0) use_seg_state_code_param = get_bits(gb, 1); else use_seg_state_code_param = 0; if (!use_seg_state_code_param) { int num_param_sets, i; unsigned bits4ABIT; params->seg_type = get_bits(gb, 1); num_param_sets = params->seg_type ? 1 : chset->channels; if (chset->bit_width > 16) { bits4ABIT = 5; } else { if (chset->bit_width > 8) bits4ABIT = 4; else bits4ABIT = 3; if (s->xll_nch_sets > 1) bits4ABIT++; } for (i = 0; i < num_param_sets; i++) { params->rice_code_flag[i] = get_bits(gb, 1); if (!params->seg_type && params->rice_code_flag[i] && get_bits(gb, 1)) params->pancAuxABIT[i] = get_bits(gb, bits4ABIT) + 1; else params->pancAuxABIT[i] = 0; } for (i = 0; i < num_param_sets; i++) { if (!seg) { /* Parameters for part 1 */ params->pancABIT0[i] = get_bits(gb, bits4ABIT); if (params->rice_code_flag[i] == 0 && params->pancABIT0[i] > 0) /* For linear code */ params->pancABIT0[i]++; /* NOTE: In the spec, not indexed by band??? */ if (params->seg_type == 0) params->nSamplPart0[i] = chset->adapt_order[0][i]; else params->nSamplPart0[i] = chset->adapt_order_max[0]; } else params->nSamplPart0[i] = 0; /* Parameters for part 2 */ params->pancABIT[i] = get_bits(gb, bits4ABIT); if (params->rice_code_flag[i] == 0 && params->pancABIT[i] > 0) /* For linear code */ params->pancABIT[i]++; } } for (i = 0; i < chset->channels; i++) { int param_index = params->seg_type ? 0 : i; int bits = params->pancABIT0[param_index]; int part0 = params->nSamplPart0[param_index]; int *sample_buf = s->xll_sample_buf + (in_channel + i) * s->xll_smpl_in_seg; if (!params->rice_code_flag[param_index]) { /* Linear code */ if (bits) for (j = 0; j < part0; j++) sample_buf[j] = get_bits_sm(gb, bits); else memset(sample_buf, 0, part0 * sizeof(sample_buf[0])); /* Second part */ bits = params->pancABIT[param_index]; if (bits) for (j = part0; j < s->xll_smpl_in_seg; j++) sample_buf[j] = get_bits_sm(gb, bits); else memset(sample_buf + part0, 0, (s->xll_smpl_in_seg - part0) * sizeof(sample_buf[0])); } else { int aux_bits = params->pancAuxABIT[param_index]; for (j = 0; j < part0; j++) { /* FIXME: Is this identical to Golomb code? */ int t = get_unary(gb, 1, 33) << bits; /* FIXME: Could move this test outside of the loop, for efficiency. */ if (bits) t |= get_bits(gb, bits); sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1); } /* Second part */ bits = params->pancABIT[param_index]; /* Follow the spec's suggestion of using the * buffer also to store the hybrid-rice flags. */ memset(sample_buf + part0, 0, (s->xll_smpl_in_seg - part0) * sizeof(sample_buf[0])); if (aux_bits > 0) { /* For hybrid rice encoding, some samples are linearly * coded. According to the spec, "nBits4SamplLoci" bits * are used for each index, but this value is not * defined. I guess we should use log2(xll_smpl_in_seg) * bits. */ int count = get_bits(gb, s->xll_log_smpl_in_seg); av_log(s->avctx, AV_LOG_DEBUG, "aux count %d (bits %d)\n", count, s->xll_log_smpl_in_seg); for (j = 0; j < count; j++) sample_buf[get_bits(gb, s->xll_log_smpl_in_seg)] = 1; } for (j = part0; j < s->xll_smpl_in_seg; j++) { if (!sample_buf[j]) { int t = get_unary(gb, 1, 33); if (bits) t = (t << bits) | get_bits(gb, bits); sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1); } else sample_buf[j] = get_bits_sm(gb, aux_bits); } } } for (i = 0; i < chset->channels; i++) { unsigned adapt_order = chset->adapt_order[0][i]; int *sample_buf = s->xll_sample_buf + (in_channel + i) * s->xll_smpl_in_seg; int *prev = history + (in_channel + i) * DCA_XLL_AORDER_MAX; if (!adapt_order) { unsigned order; for (order = chset->fixed_order[0][i]; order > 0; order--) { unsigned j; for (j = 1; j < s->xll_smpl_in_seg; j++) sample_buf[j] += sample_buf[j - 1]; } } else /* Inverse adaptive prediction, in place. */ dca_xll_inv_adapt_pred(sample_buf, s->xll_smpl_in_seg, adapt_order, seg ? prev : NULL, chset->lpc_refl_coeffs_q_ind[0][i]); memcpy(prev, sample_buf + s->xll_smpl_in_seg - DCA_XLL_AORDER_MAX, DCA_XLL_AORDER_MAX * sizeof(*prev)); } for (i = 1; i < chset->channels; i += 2) { int coeff = chset->pw_ch_pairs_coeffs[0][i / 2]; if (coeff != 0) { int *sample_buf = s->xll_sample_buf + (in_channel + i) * s->xll_smpl_in_seg; int *prev = sample_buf - s->xll_smpl_in_seg; unsigned j; for (j = 0; j < s->xll_smpl_in_seg; j++) /* Shift is unspecified, but should apparently be 3. */ sample_buf[j] += ((int64_t) coeff * prev[j] + 4) >> 3; } } if (s->xll_scalable_lsb) { int lsb_start = end_pos - 8 * chset->lsb_fsize[0] - 8 * (s->xll_banddata_crc & 2); int done; i = get_bits_count(gb); if (i > lsb_start) { av_log(s->avctx, AV_LOG_ERROR, "chset data lsb exceeds NAVI size, end_pos %d, lsb_start %d, pos %d\n", end_pos, lsb_start, i); return AVERROR_INVALIDDATA; } if (i < lsb_start) skip_bits_long(gb, lsb_start - i); for (i = done = 0; i < chset->channels; i++) { int bits = chset->scalable_lsbs[0][i]; if (bits > 0) { /* The channel reordering is conceptually done * before adding the lsb:s, so we need to do * the inverse permutation here. */ unsigned pi = chset->orig_chan_order_inv[0][i]; int *sample_buf = s->xll_sample_buf + (in_channel + pi) * s->xll_smpl_in_seg; int adj = chset->bit_width_adj_per_ch[0][i]; int msb_shift = bits; unsigned j; if (adj > 0) msb_shift += adj - 1; for (j = 0; j < s->xll_smpl_in_seg; j++) sample_buf[j] = (sample_buf[j] << msb_shift) + (get_bits(gb, bits) << adj); done += bits * s->xll_smpl_in_seg; } } if (done > 8 * chset->lsb_fsize[0]) { av_log(s->avctx, AV_LOG_ERROR, "chset lsb exceeds lsb_size\n"); return AVERROR_INVALIDDATA; } } /* Store output. */ for (i = 0; i < chset->channels; i++) { int *sample_buf = s->xll_sample_buf + (in_channel + i) * s->xll_smpl_in_seg; int shift = 1 - chset->bit_resolution; int out_channel = chset->orig_chan_order[0][i]; float *out; /* XLL uses the channel order C, L, R, and we want L, * R, C. FIXME: Generalize. */ if (chset->ch_mask_enabled && (chset->ch_mask & 7) == 7 && out_channel < 3) out_channel = out_channel ? out_channel - 1 : 2; out_channel += in_channel; if (out_channel >= s->avctx->channels) continue; out = (float *) frame->extended_data[out_channel]; out += seg * s->xll_smpl_in_seg; /* NOTE: A one bit means residual encoding is *not* used. */ if ((chset->residual_encode >> i) & 1) { /* Replace channel samples. * FIXME: Most likely not the right thing to do. */ for (j = 0; j < s->xll_smpl_in_seg; j++) out[j] = ldexpf(sample_buf[j], shift); } else { /* Add residual signal to core channel */ for (j = 0; j < s->xll_smpl_in_seg; j++) out[j] += ldexpf(sample_buf[j], shift); } } if (chset->downmix_coeff_code_embedded && !chset->primary_ch_set && chset->hier_chset) { /* Undo hierarchical downmix of earlier channels. */ unsigned mix_channel; for (mix_channel = 0; mix_channel < in_channel; mix_channel++) { float *mix_buf; const int *col; float coeff; unsigned row; /* Similar channel reorder C, L, R vs L, R, C reorder. */ if (chset->ch_mask_enabled && (chset->ch_mask & 7) == 7 && mix_channel < 3) mix_buf = (float *) frame->extended_data[mix_channel ? mix_channel - 1 : 2]; else mix_buf = (float *) frame->extended_data[mix_channel]; mix_buf += seg * s->xll_smpl_in_seg; col = &chset->downmix_coeffs[mix_channel * (chset->channels + 1)]; /* Scale */ coeff = ldexpf(col[0], -16); for (j = 0; j < s->xll_smpl_in_seg; j++) mix_buf[j] *= coeff; for (row = 0; row < chset->channels && in_channel + row < s->avctx->channels; row++) if (col[row + 1]) { const float *new_channel = (const float *) frame->extended_data[in_channel + row]; new_channel += seg * s->xll_smpl_in_seg; coeff = ldexpf(col[row + 1], -15); for (j = 0; j < s->xll_smpl_in_seg; j++) mix_buf[j] -= coeff * new_channel[j]; } } } next_chset: in_channel += chset->channels; /* Skip to next channel set using the NAVI info. */ i = get_bits_count(gb); if (i > end_pos) { av_log(s->avctx, AV_LOG_ERROR, "chset data exceeds NAVI size\n"); return AVERROR_INVALIDDATA; } if (i < end_pos) skip_bits_long(gb, end_pos - i); } } return 0; }


static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, Jpeg2000Tile *tile, int width, int height, int bandpos, int lev) { int pass_t = 2, passno, x, y, max=0, nmsedec, bpno; int64_t wmsedec = 0; for (y = 0; y < height+2; y++) memset(t1->flags[y], 0, (width+2)*sizeof(int)); for (y = 0; y < height; y++){ for (x = 0; x < width; x++){ if (t1->data[y][x] < 0){ t1->flags[y+1][x+1] |= JPEG2000_T1_SGN; t1->data[y][x] = -t1->data[y][x]; } max = FFMAX(max, t1->data[y][x]); } } if (max == 0){ cblk->nonzerobits = 0; bpno = 0; } else{ cblk->nonzerobits = av_log2(max) + 1 - NMSEDEC_FRACBITS; bpno = cblk->nonzerobits - 1; } ff_mqc_initenc(&t1->mqc, cblk->data); for (passno = 0; bpno >= 0; passno++){ nmsedec=0; switch(pass_t){ case 0: encode_sigpass(t1, width, height, bandpos, &nmsedec, bpno); break; case 1: encode_refpass(t1, width, height, &nmsedec, bpno); break; case 2: encode_clnpass(t1, width, height, bandpos, &nmsedec, bpno); break; } cblk->passes[passno].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno].flushed, &cblk->passes[passno].flushed_len); wmsedec += (int64_t)nmsedec << (2*bpno); cblk->passes[passno].disto = wmsedec; if (++pass_t == 3){ pass_t = 0; bpno--; } } cblk->npasses = passno; cblk->ninclpasses = passno; cblk->passes[passno-1].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno-1].flushed, &cblk->passes[passno-1].flushed_len); }


void cpu_disable_ticks(void) { /* Here, the really thing protected by seqlock is cpu_clock_offset. */ seqlock_write_lock(&timers_state.vm_clock_seqlock); if (timers_state.cpu_ticks_enabled) { timers_state.cpu_ticks_offset = cpu_get_ticks(); timers_state.cpu_clock_offset = cpu_get_clock_locked(); timers_state.cpu_ticks_enabled = 0; } seqlock_write_unlock(&timers_state.vm_clock_seqlock); }


static inline void RENAME(yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, unsigned int width, unsigned int height, int lumStride, int chromStride, int dstStride) { //FIXME interpolate chroma RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2); }


static int decode_residuals(FLACContext *s, int channel, int pred_order) { int i, tmp, partition, method_type, rice_order; int sample = 0, samples; method_type = get_bits(&s->gb, 2); if (method_type > 1) { av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n", method_type); return -1; } rice_order = get_bits(&s->gb, 4); samples= s->blocksize >> rice_order; if (pred_order > samples) { av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n", pred_order, samples); return -1; } sample= i= pred_order; for (partition = 0; partition < (1 << rice_order); partition++) { tmp = get_bits(&s->gb, method_type == 0 ? 4 : 5); if (tmp == (method_type == 0 ? 15 : 31)) { tmp = get_bits(&s->gb, 5); for (; i < samples; i++, sample++) s->decoded[channel][sample] = get_sbits_long(&s->gb, tmp); } else { for (; i < samples; i++, sample++) { s->decoded[channel][sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0); } } i= 0; } return 0; }


static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts) { int ret, i; AVFormatContext *dev = NULL; AVDeviceInfoList *device_list = NULL; AVDictionary *tmp_opts = NULL; if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category)) return AVERROR(EINVAL); printf("Audo-detected sinks for %s:\n", fmt->name); if (!fmt->get_device_list) { ret = AVERROR(ENOSYS); printf("Cannot list sinks. Not implemented.\n"); goto fail; } if ((ret = avformat_alloc_output_context2(&dev, fmt, NULL, NULL)) < 0) { printf("Cannot open device: %s.\n", fmt->name); goto fail; } av_dict_copy(&tmp_opts, opts, 0); av_opt_set_dict2(dev, &tmp_opts, AV_OPT_SEARCH_CHILDREN); if ((ret = avdevice_list_devices(dev, &device_list)) < 0) { printf("Cannot list sinks.\n"); goto fail; } for (i = 0; i < device_list->nb_devices; i++) { printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ", device_list->devices[i]->device_name, device_list->devices[i]->device_description); } fail: av_dict_free(&tmp_opts); avdevice_free_list_devices(&device_list); avformat_free_context(dev); return ret; }


static int bmp_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { BMPContext *s = avctx->priv_data; AVFrame *picture = data; AVFrame *p = &s->picture; unsigned int fsize, hsize; int width, height; unsigned int depth; BiCompression comp; unsigned int ihsize; int i, j, n, linesize; uint32_t rgb[3]; uint8_t *ptr; int dsize; uint8_t *buf0 = buf; if(buf_size < 14){ av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size); return -1; } if(bytestream_get_byte(&buf) != 'B' || bytestream_get_byte(&buf) != 'M') { av_log(avctx, AV_LOG_ERROR, "bad magic number\n"); return -1; } fsize = bytestream_get_le32(&buf); if(buf_size < fsize){ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n", buf_size, fsize); return -1; } buf += 2; /* reserved1 */ buf += 2; /* reserved2 */ hsize = bytestream_get_le32(&buf); /* header size */ if(fsize <= hsize){ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n", fsize, hsize); return -1; } ihsize = bytestream_get_le32(&buf); /* more header size */ if(ihsize + 14 > hsize){ av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize); return -1; } width = bytestream_get_le32(&buf); height = bytestream_get_le32(&buf); if(bytestream_get_le16(&buf) != 1){ /* planes */ av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n"); return -1; } depth = bytestream_get_le16(&buf); if(ihsize > 16) comp = bytestream_get_le32(&buf); else comp = BMP_RGB; if(comp != BMP_RGB && comp != BMP_BITFIELDS){ av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp); return -1; } if(comp == BMP_BITFIELDS){ buf += 20; rgb[0] = bytestream_get_le32(&buf); rgb[1] = bytestream_get_le32(&buf); rgb[2] = bytestream_get_le32(&buf); } avctx->codec_id = CODEC_ID_BMP; avctx->width = width; avctx->height = height > 0? height: -height; avctx->pix_fmt = PIX_FMT_NONE; switch(depth){ case 32: if(comp == BMP_BITFIELDS){ rgb[0] = (rgb[0] >> 15) & 3; rgb[1] = (rgb[1] >> 15) & 3; rgb[2] = (rgb[2] >> 15) & 3; if(rgb[0] + rgb[1] + rgb[2] != 3 || rgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){ break; } } else { rgb[0] = 2; rgb[1] = 1; rgb[2] = 0; } avctx->pix_fmt = PIX_FMT_BGR24; break; case 24: avctx->pix_fmt = PIX_FMT_BGR24; break; case 16: if(comp == BMP_RGB) avctx->pix_fmt = PIX_FMT_RGB555; break; default: av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth); return -1; } if(avctx->pix_fmt == PIX_FMT_NONE){ av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n"); return -1; } if(p->data[0]) avctx->release_buffer(avctx, p); p->reference = 0; if(avctx->get_buffer(avctx, p) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } p->pict_type = FF_I_TYPE; p->key_frame = 1; buf = buf0 + hsize; dsize = buf_size - hsize; /* Line size in file multiple of 4 */ n = (avctx->width * (depth / 8) + 3) & ~3; if(n * avctx->height > dsize){ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n", dsize, n * avctx->height); return -1; } if(height > 0){ ptr = p->data[0] + (avctx->height - 1) * p->linesize[0]; linesize = -p->linesize[0]; } else { ptr = p->data[0]; linesize = p->linesize[0]; } switch(depth){ case 24: for(i = 0; i < avctx->height; i++){ memcpy(ptr, buf, n); buf += n; ptr += linesize; } break; case 16: for(i = 0; i < avctx->height; i++){ uint16_t *src = (uint16_t *) buf; uint16_t *dst = (uint16_t *) ptr; for(j = 0; j < avctx->width; j++) *dst++ = le2me_16(*src++); buf += n; ptr += linesize; } break; case 32: for(i = 0; i < avctx->height; i++){ uint8_t *src = buf; uint8_t *dst = ptr; for(j = 0; j < avctx->width; j++){ dst[0] = src[rgb[2]]; dst[1] = src[rgb[1]]; dst[2] = src[rgb[0]]; dst += 3; src += 4; } buf += n; ptr += linesize; } break; default: av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n"); return -1; } *picture = s->picture; *data_size = sizeof(AVPicture); return buf_size; }


void HELPER(stfl)(CPUS390XState *env) { uint64_t words[MAX_STFL_WORDS]; do_stfle(env, words); cpu_stl_data(env, 200, words[0] >> 32); }


static QDict *qmp_check_input_obj(QObject *input_obj) { const QDictEntry *ent; int has_exec_key = 0; QDict *input_dict; if (qobject_type(input_obj) != QTYPE_QDICT) { qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "object"); return NULL; } input_dict = qobject_to_qdict(input_obj); for (ent = qdict_first(input_dict); ent; ent = qdict_next(input_dict, ent)){ const char *arg_name = qdict_entry_key(ent); const QObject *arg_obj = qdict_entry_value(ent); if (!strcmp(arg_name, "execute")) { if (qobject_type(arg_obj) != QTYPE_QSTRING) { qerror_report(QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute", "string"); return NULL; } has_exec_key = 1; } else if (!strcmp(arg_name, "arguments")) { if (qobject_type(arg_obj) != QTYPE_QDICT) { qerror_report(QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "arguments", "object"); return NULL; } } else if (!strcmp(arg_name, "id")) { /* FIXME: check duplicated IDs for async commands */ } else { qerror_report(QERR_QMP_EXTRA_MEMBER, arg_name); return NULL; } } if (!has_exec_key) { qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "execute"); return NULL; } return input_dict; }


static void add_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels, int line_size) { int i; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; /* read the pixels */ for(i=0;i<4;i++) { pixels[0] = cm[pixels[0] + block[0]]; pixels[1] = cm[pixels[1] + block[1]]; pixels[2] = cm[pixels[2] + block[2]]; pixels[3] = cm[pixels[3] + block[3]]; pixels += line_size; block += 8; } }


static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr) { int sign, code; int pred, extquant; int extrabits = 0; int16_t *dc_val; pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr); /* update predictor */ if (n < 4) { *dc_val = level * s->y_dc_scale; } else { *dc_val = level * s->c_dc_scale; } /* do the prediction */ level -= pred; if(s->msmpeg4_version<=2){ if (n < 4) { put_bits(&s->pb, ff_v2_dc_lum_table[level + 256][1], ff_v2_dc_lum_table[level + 256][0]); }else{ put_bits(&s->pb, ff_v2_dc_chroma_table[level + 256][1], ff_v2_dc_chroma_table[level + 256][0]); } }else{ sign = 0; if (level < 0) { level = -level; sign = 1; } code = level; if (code > DC_MAX) code = DC_MAX; else if( s->msmpeg4_version>=6 ) { if( s->qscale == 1 ) { extquant = (level + 3) & 0x3; code = ((level+3)>>2); } else if( s->qscale == 2 ) { extquant = (level + 1) & 0x1; code = ((level+1)>>1); } } if (s->dc_table_index == 0) { if (n < 4) { put_bits(&s->pb, ff_table0_dc_lum[code][1], ff_table0_dc_lum[code][0]); } else { put_bits(&s->pb, ff_table0_dc_chroma[code][1], ff_table0_dc_chroma[code][0]); } } else { if (n < 4) { put_bits(&s->pb, ff_table1_dc_lum[code][1], ff_table1_dc_lum[code][0]); } else { put_bits(&s->pb, ff_table1_dc_chroma[code][1], ff_table1_dc_chroma[code][0]); } } if(s->msmpeg4_version>=6 && s->qscale<=2) extrabits = 3 - s->qscale; if (code == DC_MAX) put_bits(&s->pb, 8 + extrabits, level); else if(extrabits > 0)//== VC1 && s->qscale<=2 put_bits(&s->pb, extrabits, extquant); if (level != 0) { put_bits(&s->pb, 1, sign); } } }


matroska_read_header (AVFormatContext *s, AVFormatParameters *ap) { MatroskaDemuxContext *matroska = s->priv_data; char *doctype; int version, last_level, res = 0; uint32_t id; matroska->ctx = s; /* First read the EBML header. */ doctype = NULL; if ((res = ebml_read_header(matroska, &doctype, &version)) < 0) return res; if ((doctype == NULL) || strcmp(doctype, "matroska")) { av_log(matroska->ctx, AV_LOG_ERROR, "Wrong EBML doctype ('%s' != 'matroska').\n", doctype ? doctype : "(none)"); if (doctype) av_free(doctype); return AVERROR_NOFMT; } av_free(doctype); if (version > 2) { av_log(matroska->ctx, AV_LOG_ERROR, "Matroska demuxer version 2 too old for file version %d\n", version); return AVERROR_NOFMT; } /* The next thing is a segment. */ while (1) { if (!(id = ebml_peek_id(matroska, &last_level))) return AVERROR(EIO); if (id == MATROSKA_ID_SEGMENT) break; /* oi! */ av_log(matroska->ctx, AV_LOG_INFO, "Expected a Segment ID (0x%x), but received 0x%x!\n", MATROSKA_ID_SEGMENT, id); if ((res = ebml_read_skip(matroska)) < 0) return res; } /* We now have a Matroska segment. * Seeks are from the beginning of the segment, * after the segment ID/length. */ if ((res = ebml_read_master(matroska, &id)) < 0) return res; matroska->segment_start = url_ftell(s->pb); matroska->time_scale = 1000000; /* we've found our segment, start reading the different contents in here */ while (res == 0) { if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { res = AVERROR(EIO); break; } else if (matroska->level_up) { matroska->level_up--; break; } switch (id) { /* stream info */ case MATROSKA_ID_INFO: { if ((res = ebml_read_master(matroska, &id)) < 0) break; res = matroska_parse_info(matroska); break; } /* track info headers */ case MATROSKA_ID_TRACKS: { if ((res = ebml_read_master(matroska, &id)) < 0) break; res = matroska_parse_tracks(matroska); break; } /* stream index */ case MATROSKA_ID_CUES: { if (!matroska->index_parsed) { if ((res = ebml_read_master(matroska, &id)) < 0) break; res = matroska_parse_index(matroska); } else res = ebml_read_skip(matroska); break; } /* metadata */ case MATROSKA_ID_TAGS: { if (!matroska->metadata_parsed) { if ((res = ebml_read_master(matroska, &id)) < 0) break; res = matroska_parse_metadata(matroska); } else res = ebml_read_skip(matroska); break; } /* file index (if seekable, seek to Cues/Tags to parse it) */ case MATROSKA_ID_SEEKHEAD: { if ((res = ebml_read_master(matroska, &id)) < 0) break; res = matroska_parse_seekhead(matroska); break; } case MATROSKA_ID_ATTACHMENTS: { if ((res = ebml_read_master(matroska, &id)) < 0) break; res = matroska_parse_attachments(s); break; } case MATROSKA_ID_CLUSTER: { /* Do not read the master - this will be done in the next * call to matroska_read_packet. */ res = 1; break; } default: av_log(matroska->ctx, AV_LOG_INFO, "Unknown matroska file header ID 0x%x\n", id); /* fall-through */ case EBML_ID_VOID: res = ebml_read_skip(matroska); break; } if (matroska->level_up) { matroska->level_up--; break; } } /* Have we found a cluster? */ if (ebml_peek_id(matroska, NULL) == MATROSKA_ID_CLUSTER) { int i, j; MatroskaTrack *track; AVStream *st; for (i = 0; i < matroska->num_tracks; i++) { enum CodecID codec_id = CODEC_ID_NONE; uint8_t *extradata = NULL; int extradata_size = 0; int extradata_offset = 0; track = matroska->tracks[i]; track->stream_index = -1; /* Apply some sanity checks. */ if (track->codec_id == NULL) continue; for(j=0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++){ if(!strncmp(ff_mkv_codec_tags[j].str, track->codec_id, strlen(ff_mkv_codec_tags[j].str))){ codec_id= ff_mkv_codec_tags[j].id; break; } } /* Set the FourCC from the CodecID. */ /* This is the MS compatibility mode which stores a * BITMAPINFOHEADER in the CodecPrivate. */ if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC) && (track->codec_priv_size >= 40) && (track->codec_priv != NULL)) { MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *) track; /* Offset of biCompression. Stored in LE. */ vtrack->fourcc = AV_RL32(track->codec_priv + 16); codec_id = codec_get_id(codec_bmp_tags, vtrack->fourcc); } /* This is the MS compatibility mode which stores a * WAVEFORMATEX in the CodecPrivate. */ else if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_AUDIO_ACM) && (track->codec_priv_size >= 18) && (track->codec_priv != NULL)) { uint16_t tag; /* Offset of wFormatTag. Stored in LE. */ tag = AV_RL16(track->codec_priv); codec_id = codec_get_id(codec_wav_tags, tag); } else if (codec_id == CODEC_ID_AAC && !track->codec_priv_size) { MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track; int profile = matroska_aac_profile(track->codec_id); int sri = matroska_aac_sri(audiotrack->internal_samplerate); extradata = av_malloc(5); if (extradata == NULL) return AVERROR(ENOMEM); extradata[0] = (profile << 3) | ((sri&0x0E) >> 1); extradata[1] = ((sri&0x01) << 7) | (audiotrack->channels<<3); if (strstr(track->codec_id, "SBR")) { sri = matroska_aac_sri(audiotrack->samplerate); extradata[2] = 0x56; extradata[3] = 0xE5; extradata[4] = 0x80 | (sri<<3); extradata_size = 5; } else { extradata_size = 2; } } else if (codec_id == CODEC_ID_TTA) { MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track; ByteIOContext b; extradata_size = 30; extradata = av_mallocz(extradata_size); if (extradata == NULL) return AVERROR(ENOMEM); init_put_byte(&b, extradata, extradata_size, 1, NULL, NULL, NULL, NULL); put_buffer(&b, "TTA1", 4); put_le16(&b, 1); put_le16(&b, audiotrack->channels); put_le16(&b, audiotrack->bitdepth); put_le32(&b, audiotrack->samplerate); put_le32(&b, matroska->ctx->duration * audiotrack->samplerate); } else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 || codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) { extradata_offset = 26; track->codec_priv_size -= extradata_offset; } else if (codec_id == CODEC_ID_RA_144) { MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track; audiotrack->samplerate = 8000; audiotrack->channels = 1; } else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK || codec_id == CODEC_ID_ATRAC3) { MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track; ByteIOContext b; init_put_byte(&b, track->codec_priv, track->codec_priv_size, 0, NULL, NULL, NULL, NULL); url_fskip(&b, 24); audiotrack->coded_framesize = get_be32(&b); url_fskip(&b, 12); audiotrack->sub_packet_h = get_be16(&b); audiotrack->frame_size = get_be16(&b); audiotrack->sub_packet_size = get_be16(&b); audiotrack->buf = av_malloc(audiotrack->frame_size * audiotrack->sub_packet_h); if (codec_id == CODEC_ID_RA_288) { audiotrack->block_align = audiotrack->coded_framesize; track->codec_priv_size = 0; } else { audiotrack->block_align = audiotrack->sub_packet_size; extradata_offset = 78; track->codec_priv_size -= extradata_offset; } } if (codec_id == CODEC_ID_NONE) { av_log(matroska->ctx, AV_LOG_INFO, "Unknown/unsupported CodecID %s.\n", track->codec_id); } track->stream_index = matroska->num_streams; matroska->num_streams++; st = av_new_stream(s, track->stream_index); if (st == NULL) return AVERROR(ENOMEM); av_set_pts_info(st, 64, matroska->time_scale, 1000*1000*1000); /* 64 bit pts in ns */ st->codec->codec_id = codec_id; st->start_time = 0; if (strcmp(track->language, "und")) strcpy(st->language, track->language); if (track->flags & MATROSKA_TRACK_DEFAULT) st->disposition |= AV_DISPOSITION_DEFAULT; if (track->default_duration) av_reduce(&st->codec->time_base.num, &st->codec->time_base.den, track->default_duration, 1000000000, 30000); if(extradata){ st->codec->extradata = extradata; st->codec->extradata_size = extradata_size; } else if(track->codec_priv && track->codec_priv_size > 0){ st->codec->extradata = av_malloc(track->codec_priv_size); if(st->codec->extradata == NULL) return AVERROR(ENOMEM); st->codec->extradata_size = track->codec_priv_size; memcpy(st->codec->extradata,track->codec_priv+extradata_offset, track->codec_priv_size); } if (track->type == MATROSKA_TRACK_TYPE_VIDEO) { MatroskaVideoTrack *videotrack = (MatroskaVideoTrack *)track; st->codec->codec_type = CODEC_TYPE_VIDEO; st->codec->codec_tag = videotrack->fourcc; st->codec->width = videotrack->pixel_width; st->codec->height = videotrack->pixel_height; if (videotrack->display_width == 0) videotrack->display_width= videotrack->pixel_width; if (videotrack->display_height == 0) videotrack->display_height= videotrack->pixel_height; av_reduce(&st->codec->sample_aspect_ratio.num, &st->codec->sample_aspect_ratio.den, st->codec->height * videotrack->display_width, st->codec-> width * videotrack->display_height, 255); st->need_parsing = AVSTREAM_PARSE_HEADERS; } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) { MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track; st->codec->codec_type = CODEC_TYPE_AUDIO; st->codec->sample_rate = audiotrack->samplerate; st->codec->channels = audiotrack->channels; st->codec->block_align = audiotrack->block_align; } else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) { st->codec->codec_type = CODEC_TYPE_SUBTITLE; } /* What do we do with private data? E.g. for Vorbis. */ } res = 0; } if (matroska->index_parsed) { int i, track, stream; for (i=0; i<matroska->num_indexes; i++) { MatroskaDemuxIndex *idx = &matroska->index[i]; track = matroska_find_track_by_num(matroska, idx->track); stream = matroska->tracks[track]->stream_index; if (stream >= 0) av_add_index_entry(matroska->ctx->streams[stream], idx->pos, idx->time/matroska->time_scale, 0, 0, AVINDEX_KEYFRAME); } } return res; }


static void test_enabled(void) { int i; throttle_config_init(&cfg); g_assert(!throttle_enabled(&cfg)); for (i = 0; i < BUCKETS_COUNT; i++) { throttle_config_init(&cfg); set_cfg_value(false, i, 150); g_assert(throttle_enabled(&cfg)); } for (i = 0; i < BUCKETS_COUNT; i++) { throttle_config_init(&cfg); set_cfg_value(false, i, -150); g_assert(!throttle_enabled(&cfg)); } }


static inline void drawbox(AVFilterBufferRef *picref, unsigned int x, unsigned int y, unsigned int width, unsigned int height, uint8_t *line[4], int pixel_step[4], uint8_t color[4], int hsub, int vsub, int is_rgba_packed, uint8_t rgba_map[4]) { int i, j, alpha; if (color[3] != 0xFF) { if (is_rgba_packed) { uint8_t *p; for (j = 0; j < height; j++) for (i = 0; i < width; i++) SET_PIXEL_RGB(picref, color, 255, i+x, y+j, pixel_step[0], rgba_map[0], rgba_map[1], rgba_map[2], rgba_map[3]); } else { unsigned int luma_pos, chroma_pos1, chroma_pos2; for (j = 0; j < height; j++) for (i = 0; i < width; i++) SET_PIXEL_YUV(picref, color, 255, i+x, y+j, hsub, vsub); } } else { ff_draw_rectangle(picref->data, picref->linesize, line, pixel_step, hsub, vsub, x, y, width, height); } }


static void create_vorbis_context(venc_context_t * venc, AVCodecContext * avccontext) { codebook_t * cb; floor_t * fc; residue_t * rc; mapping_t * mc; int i, book; venc->channels = avccontext->channels; venc->sample_rate = avccontext->sample_rate; venc->blocksize[0] = venc->blocksize[1] = 8; venc->ncodebooks = 10; venc->codebooks = av_malloc(sizeof(codebook_t) * venc->ncodebooks); // codebook 1 - floor1 book, values 0..255 cb = &venc->codebooks[0]; cb->nentries = 256; cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries); for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 8; cb->ndimentions = 0; cb->min = 0.; cb->delta = 0.; cb->seq_p = 0; cb->lookup = 0; cb->quantlist = NULL; ready_codebook(cb); // codebook 2 - residue classbook, values 0..1, dimentions 200 cb = &venc->codebooks[1]; cb->nentries = 2; cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries); for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 1; cb->ndimentions = 200; cb->min = 0.; cb->delta = 0.; cb->seq_p = 0; cb->lookup = 0; cb->quantlist = NULL; ready_codebook(cb); // codebook 3..10 - vector, for the residue, values -32767..32767, dimentions 1 for (book = 0; book < 8; book++) { cb = &venc->codebooks[2 + book]; cb->nentries = 5; cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries); for (i = 0; i < cb->nentries; i++) cb->entries[i].len = i == 2 ? 1 : 3; cb->ndimentions = 1; cb->delta = 1 << ((7 - book) * 2); cb->min = -cb->delta*2; cb->seq_p = 0; cb->lookup = 2; cb->quantlist = av_malloc(sizeof(int) * cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries)); for (i = 0; i < cb->nentries; i++) cb->quantlist[i] = i; ready_codebook(cb); } venc->nfloors = 1; venc->floors = av_malloc(sizeof(floor_t) * venc->nfloors); // just 1 floor fc = &venc->floors[0]; fc->partitions = 1; fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions); for (i = 0; i < fc->partitions; i++) fc->partition_to_class = 0; fc->nclasses = 1; fc->classes = av_malloc(sizeof(floor_class_t) * fc->nclasses); for (i = 0; i < fc->nclasses; i++) { floor_class_t * c = &fc->classes[i]; int j, books; c->dim = 1; c->subclass = 0; c->masterbook = 0; books = (1 << c->subclass); c->books = av_malloc(sizeof(int) * books); for (j = 0; j < books; j++) c->books[j] = 0; } fc->multiplier = 1; fc->rangebits = venc->blocksize[0]; fc->values = 2; for (i = 0; i < fc->partitions; i++) fc->values += fc->classes[fc->partition_to_class[i]].dim; fc->list = av_malloc(sizeof(*fc->list) * fc->values); fc->list[0].x = 0; fc->list[1].x = 1 << fc->rangebits; for (i = 2; i < fc->values; i++) fc->list[i].x = i * 5; venc->nresidues = 1; venc->residues = av_malloc(sizeof(residue_t) * venc->nresidues); // single residue rc = &venc->residues[0]; rc->type = 0; rc->begin = 0; rc->end = 1 << venc->blocksize[0]; rc->partition_size = 64; rc->classifications = 1; rc->classbook = 1; rc->books = av_malloc(sizeof(int[8]) * rc->classifications); for (i = 0; i < 8; i++) rc->books[0][i] = 2 + i; venc->nmappings = 1; venc->mappings = av_malloc(sizeof(mapping_t) * venc->nmappings); // single mapping mc = &venc->mappings[0]; mc->submaps = 1; mc->mux = av_malloc(sizeof(int) * venc->channels); for (i = 0; i < venc->channels; i++) mc->mux[i] = 0; mc->floor = av_malloc(sizeof(int) * mc->submaps); mc->residue = av_malloc(sizeof(int) * mc->submaps); for (i = 0; i < mc->submaps; i++) { mc->floor[i] = 0; mc->residue[i] = 0; } venc->nmodes = 1; venc->modes = av_malloc(sizeof(vorbis_mode_t) * venc->nmodes); // single mode venc->modes[0].blockflag = 0; venc->modes[0].mapping = 0; }


static int iscsi_readcapacity_sync(IscsiLun *iscsilun) { struct scsi_task *task = NULL; struct scsi_readcapacity10 *rc10 = NULL; struct scsi_readcapacity16 *rc16 = NULL; int ret = 0; int retries = ISCSI_CMD_RETRIES; do { if (task != NULL) { scsi_free_scsi_task(task); task = NULL; } switch (iscsilun->type) { case TYPE_DISK: task = iscsi_readcapacity16_sync(iscsilun->iscsi, iscsilun->lun); if (task != NULL && task->status == SCSI_STATUS_GOOD) { rc16 = scsi_datain_unmarshall(task); if (rc16 == NULL) { error_report("iSCSI: Failed to unmarshall readcapacity16 data."); ret = -EINVAL; } else { iscsilun->block_size = rc16->block_length; iscsilun->num_blocks = rc16->returned_lba + 1; iscsilun->lbpme = rc16->lbpme; iscsilun->lbprz = rc16->lbprz; } } break; case TYPE_ROM: task = iscsi_readcapacity10_sync(iscsilun->iscsi, iscsilun->lun, 0, 0); if (task != NULL && task->status == SCSI_STATUS_GOOD) { rc10 = scsi_datain_unmarshall(task); if (rc10 == NULL) { error_report("iSCSI: Failed to unmarshall readcapacity10 data."); ret = -EINVAL; } else { iscsilun->block_size = rc10->block_size; if (rc10->lba == 0) { /* blank disk loaded */ iscsilun->num_blocks = 0; } else { iscsilun->num_blocks = rc10->lba + 1; } } } break; default: return 0; } } while (task != NULL && task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_UNIT_ATTENTION && retries-- > 0); if (task == NULL || task->status != SCSI_STATUS_GOOD) { error_report("iSCSI: failed to send readcapacity10 command."); ret = -EINVAL; } if (task) { scsi_free_scsi_task(task); } return ret; }


int kvm_arch_process_async_events(CPUState *env) { if (kvm_irqchip_in_kernel()) { if (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)) { if (env->interrupt_request & CPU_INTERRUPT_INIT) { do_cpu_init(env); if (env->interrupt_request & CPU_INTERRUPT_SIPI) { do_cpu_sipi(env); return env->halted;


static void gen_slbmte(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); return; } gen_helper_store_slb(cpu_env, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); #endif }


static void shifter_out_im(TCGv var, int shift) { TCGv tmp = new_tmp(); if (shift == 0) { tcg_gen_andi_i32(tmp, var, 1); } else { tcg_gen_shri_i32(tmp, var, shift); if (shift != 31) tcg_gen_andi_i32(tmp, tmp, 1); } gen_set_CF(tmp); dead_tmp(tmp); }


static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table, const char *language, kbd_layout_t *k) { FILE *f; char * filename; char line[1024]; int len; filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language); f = filename ? fopen(filename, "r") : NULL; g_free(filename); if (!f) { fprintf(stderr, "Could not read keymap file: '%s'\n", language); return NULL; } if (!k) { k = g_malloc0(sizeof(kbd_layout_t)); } for(;;) { if (fgets(line, 1024, f) == NULL) { break; } len = strlen(line); if (len > 0 && line[len - 1] == '\n') { line[len - 1] = '\0'; } if (line[0] == '#') { continue; } if (!strncmp(line, "map ", 4)) { continue; } if (!strncmp(line, "include ", 8)) { parse_keyboard_layout(table, line + 8, k); } else { char *end_of_keysym = line; while (*end_of_keysym != 0 && *end_of_keysym != ' ') { end_of_keysym++; } if (*end_of_keysym) { int keysym; *end_of_keysym = 0; keysym = get_keysym(table, line); if (keysym == 0) { /* fprintf(stderr, "Warning: unknown keysym %s\n", line);*/ } else { const char *rest = end_of_keysym + 1; int keycode = strtol(rest, NULL, 0); if (strstr(rest, "numlock")) { add_to_key_range(&k->keypad_range, keycode); add_to_key_range(&k->numlock_range, keysym); /* fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode); */ } if (strstr(rest, "shift")) { keycode |= SCANCODE_SHIFT; } if (strstr(rest, "altgr")) { keycode |= SCANCODE_ALTGR; } if (strstr(rest, "ctrl")) { keycode |= SCANCODE_CTRL; } add_keysym(line, keysym, keycode, k); if (strstr(rest, "addupper")) { char *c; for (c = line; *c; c++) { *c = qemu_toupper(*c); } keysym = get_keysym(table, line); if (keysym) { add_keysym(line, keysym, keycode | SCANCODE_SHIFT, k); } } } } } } fclose(f); return k; }


static void ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ int i; for(i=16; i<16+8; i++){ if(nnzc[ scan8[i] ] || block[i*16]) ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride); } }


static void vmxnet3_deactivate_device(VMXNET3State *s) { VMW_CBPRN("Deactivating vmxnet3..."); s->device_active = false; }


e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val) { int i; core->mac[PBACLR] = val & E1000_PBACLR_VALID_MASK; if (msix_enabled(core->owner)) { return; } for (i = 0; i < E1000E_MSIX_VEC_NUM; i++) { if (core->mac[PBACLR] & BIT(i)) { msix_clr_pending(core->owner, i); } } }


void qemu_spice_vm_change_state_handler(void *opaque, int running, int reason) { SimpleSpiceDisplay *ssd = opaque; if (running) { ssd->worker->start(ssd->worker); } else { qemu_mutex_unlock_iothread(); ssd->worker->stop(ssd->worker); qemu_mutex_lock_iothread(); } ssd->running = running; }


static void do_audio_out(AVFormatContext *s, AVOutputStream *ost, AVInputStream *ist, unsigned char *buf, int size) { uint8_t *buftmp; uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE]; /* XXX: allocate it */ uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE]; /* XXX: allocate it - yep really WMA */ int size_out, frame_bytes, ret; AVCodecContext *enc; enc = &ost->st->codec; if (ost->audio_resample) { buftmp = audio_buf; size_out = audio_resample(ost->resample, (short *)buftmp, (short *)buf, size / (ist->st->codec.channels * 2)); size_out = size_out * enc->channels * 2; } else { buftmp = buf; size_out = size; } /* now encode as many frames as possible */ if (enc->frame_size > 1) { /* output resampled raw samples */ fifo_write(&ost->fifo, buftmp, size_out, &ost->fifo.wptr); frame_bytes = enc->frame_size * 2 * enc->channels; while (fifo_read(&ost->fifo, audio_buf, frame_bytes, &ost->fifo.rptr) == 0) { ret = avcodec_encode_audio(enc, audio_out, sizeof(audio_out), (short *)audio_buf); av_write_frame(s, ost->index, audio_out, ret); } } else { /* output a pcm frame */ /* XXX: change encoding codec API to avoid this ? */ switch(enc->codec->id) { case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: break; default: size_out = size_out >> 1; break; } ret = avcodec_encode_audio(enc, audio_out, size_out, (short *)buftmp); av_write_frame(s, ost->index, audio_out, ret); } }


static int ehci_state_waitlisthead(EHCIState *ehci, int async) { EHCIqh qh; int i = 0; int again = 0; uint32_t entry = ehci->asynclistaddr; /* set reclamation flag at start event (4.8.6) */ if (async) { ehci_set_usbsts(ehci, USBSTS_REC); } ehci_queues_rip_unused(ehci, async); /* Find the head of the list (4.9.1.1) */ for(i = 0; i < MAX_QH; i++) { get_dwords(ehci, NLPTR_GET(entry), (uint32_t *) &qh, sizeof(EHCIqh) >> 2); ehci_trace_qh(NULL, NLPTR_GET(entry), &qh); if (qh.epchar & QH_EPCHAR_H) { if (async) { entry |= (NLPTR_TYPE_QH << 1); } ehci_set_fetch_addr(ehci, async, entry); ehci_set_state(ehci, async, EST_FETCHENTRY); again = 1; goto out; } entry = qh.next; if (entry == ehci->asynclistaddr) { break; } } /* no head found for list. */ ehci_set_state(ehci, async, EST_ACTIVE); out: return again; }


static void aux_bus_map_device(AUXBus *bus, AUXSlave *dev, hwaddr addr) { memory_region_add_subregion(bus->aux_io, addr, dev->mmio); }


static int verify_md5(HEVCContext *s, AVFrame *frame) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); int pixel_shift = desc->comp[0].depth_minus1 > 7; int i, j; if (!desc) return AVERROR(EINVAL); av_log(s->avctx, AV_LOG_DEBUG, "Verifying checksum for frame with POC %d: ", s->poc); /* the checksums are LE, so we have to byteswap for >8bpp formats * on BE arches */ #if HAVE_BIGENDIAN if (pixel_shift && !s->checksum_buf) { av_fast_malloc(&s->checksum_buf, &s->checksum_buf_size, FFMAX3(frame->linesize[0], frame->linesize[1], frame->linesize[2])); if (!s->checksum_buf) return AVERROR(ENOMEM); } #endif for (i = 0; frame->data[i]; i++) { int width = s->avctx->coded_width; int height = s->avctx->coded_height; int w = (i == 1 || i == 2) ? (width >> desc->log2_chroma_w) : width; int h = (i == 1 || i == 2) ? (height >> desc->log2_chroma_h) : height; uint8_t md5[16]; av_md5_init(s->md5_ctx); for (j = 0; j < h; j++) { const uint8_t *src = frame->data[i] + j * frame->linesize[i]; #if HAVE_BIGENDIAN if (pixel_shift) { s->dsp.bswap16_buf((uint16_t*)s->checksum_buf, (const uint16_t*)src, w); src = s->checksum_buf; } #endif av_md5_update(s->md5_ctx, src, w << pixel_shift); } av_md5_final(s->md5_ctx, md5); if (!memcmp(md5, s->md5[i], 16)) { av_log (s->avctx, AV_LOG_DEBUG, "plane %d - correct ", i); print_md5(s->avctx, AV_LOG_DEBUG, md5); av_log (s->avctx, AV_LOG_DEBUG, "; "); } else { av_log (s->avctx, AV_LOG_ERROR, "mismatching checksum of plane %d - ", i); print_md5(s->avctx, AV_LOG_ERROR, md5); av_log (s->avctx, AV_LOG_ERROR, " != "); print_md5(s->avctx, AV_LOG_ERROR, s->md5[i]); av_log (s->avctx, AV_LOG_ERROR, "\n"); return AVERROR_INVALIDDATA; } } av_log(s->avctx, AV_LOG_DEBUG, "\n"); return 0; }


static int dxva2_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { const VC1Context *v = avctx->priv_data; AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; assert(ctx_pic); fill_picture_parameters(avctx, ctx, v, &ctx_pic->pp); ctx_pic->bitstream_size = 0; ctx_pic->bitstream = NULL; return 0; }


static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx, AVBitStreamFilterContext *bsfc){ while(bsfc){ AVPacket new_pkt= *pkt; int a= av_bitstream_filter_filter(bsfc, avctx, NULL, &new_pkt.data, &new_pkt.size, pkt->data, pkt->size, pkt->flags & PKT_FLAG_KEY); if(a){ av_free_packet(pkt); new_pkt.destruct= av_destruct_packet; } *pkt= new_pkt; bsfc= bsfc->next; } av_interleaved_write_frame(s, pkt); }


static inline void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int *tc0) { int i, d; for( i = 0; i < 4; i++ ) { if( tc0[i] < 0 ) { pix += 4*ystride; continue; } for( d = 0; d < 4; d++ ) { const int p0 = pix[-1*xstride]; const int p1 = pix[-2*xstride]; const int p2 = pix[-3*xstride]; const int q0 = pix[0]; const int q1 = pix[1*xstride]; const int q2 = pix[2*xstride]; if( ABS( p0 - q0 ) < alpha && ABS( p1 - p0 ) < beta && ABS( q1 - q0 ) < beta ) { int tc = tc0[i]; int i_delta; if( ABS( p2 - p0 ) < beta ) { pix[-2*xstride] = p1 + clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0[i], tc0[i] ); tc++; } if( ABS( q2 - q0 ) < beta ) { pix[xstride] = q1 + clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0[i], tc0[i] ); tc++; } i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); pix[-xstride] = clip_uint8( p0 + i_delta ); /* p0' */ pix[0] = clip_uint8( q0 - i_delta ); /* q0' */ } pix += ystride; } } }


int64_t av_gettime_relative(void) { #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000; #else return av_gettime() + 42 * 60 * 60 * INT64_C(1000000); #endif }


static void update_odml_entry(AVFormatContext *s, int stream_index, int64_t ix) { AVIOContext *pb = s->pb; AVIContext *avi = s->priv_data; AVIStream *avist = s->streams[stream_index]->priv_data; int64_t pos; int au_byterate, au_ssize, au_scale; avio_flush(pb); pos = avio_tell(pb); /* Updating one entry in the AVI OpenDML master index */ avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET); ffio_wfourcc(pb, "indx"); /* enabling this entry */ avio_skip(pb, 8); avio_wl32(pb, avi->riff_id); /* nEntriesInUse */ avio_skip(pb, 16 * avi->riff_id); avio_wl64(pb, ix); /* qwOffset */ avio_wl32(pb, pos - ix); /* dwSize */ ff_parse_specific_params(s->streams[stream_index], &au_byterate, &au_ssize, &au_scale); if (s->streams[stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) { uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset); if ((audio_segm_size % au_ssize > 0) && !avist->sample_requested) { avpriv_request_sample(s, "OpenDML index duration for audio packets with partial frames"); avist->sample_requested = 1; } avio_wl32(pb, audio_segm_size / au_ssize); /* dwDuration (sample count) */ } else avio_wl32(pb, avist->indexes.entry); /* dwDuration (packet count) */ avio_seek(pb, pos, SEEK_SET); }


av_cold void ff_msmpeg4_encode_init(MpegEncContext *s) { static int init_done=0; int i; ff_msmpeg4_common_init(s); if(s->msmpeg4_version>=4){ s->min_qcoeff= -255; s->max_qcoeff= 255; } if (!init_done) { /* init various encoding tables */ init_done = 1; init_mv_table(&ff_mv_tables[0]); init_mv_table(&ff_mv_tables[1]); for(i=0;i<NB_RL_TABLES;i++) ff_init_rl(&ff_rl_table[i], ff_static_rl_table_store[i]); for(i=0; i<NB_RL_TABLES; i++){ int level; for (level = 1; level <= MAX_LEVEL; level++) { int run; for(run=0; run<=MAX_RUN; run++){ int last; for(last=0; last<2; last++){ rl_length[i][level][run][last]= get_size_of_code(s, &ff_rl_table[ i], last, run, level, 0); } } } } } }


int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) { if (*spec <= '9' && *spec >= '0') /* opt:index */ return strtol(spec, NULL, 0) == st->index; else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' || *spec == 't') { /* opt:[vasdt] */ enum AVMediaType type; switch (*spec++) { case 'v': type = AVMEDIA_TYPE_VIDEO; break; case 'a': type = AVMEDIA_TYPE_AUDIO; break; case 's': type = AVMEDIA_TYPE_SUBTITLE; break; case 'd': type = AVMEDIA_TYPE_DATA; break; case 't': type = AVMEDIA_TYPE_ATTACHMENT; break; default: av_assert0(0); } if (type != st->codec->codec_type) return 0; if (*spec++ == ':') { /* possibly followed by :index */ int i, index = strtol(spec, NULL, 0); for (i = 0; i < s->nb_streams; i++) if (s->streams[i]->codec->codec_type == type && index-- == 0) return i == st->index; return 0; } return 1; } else if (*spec == 'p' && *(spec + 1) == ':') { int prog_id, i, j; char *endptr; spec += 2; prog_id = strtol(spec, &endptr, 0); for (i = 0; i < s->nb_programs; i++) { if (s->programs[i]->id != prog_id) continue; if (*endptr++ == ':') { int stream_idx = strtol(endptr, NULL, 0); return stream_idx >= 0 && stream_idx < s->programs[i]->nb_stream_indexes && st->index == s->programs[i]->stream_index[stream_idx]; } for (j = 0; j < s->programs[i]->nb_stream_indexes; j++) if (st->index == s->programs[i]->stream_index[j]) return 1; } return 0; } else if (*spec == '#') { int sid; char *endptr; sid = strtol(spec + 1, &endptr, 0); if (!*endptr) return st->id == sid; } else if (!*spec) /* empty specifier, matches everything */ return 1; av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec); return AVERROR(EINVAL); }


static void filter_mb_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) { const int index_a = qp + h->slice_alpha_c0_offset; const int alpha = (alpha_table+52)[index_a]; const int beta = (beta_table+52)[qp + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { int8_t tc[4]; tc[0] = (tc0_table+52)[index_a][bS[0]]+1; tc[1] = (tc0_table+52)[index_a][bS[1]]+1; tc[2] = (tc0_table+52)[index_a][bS[2]]+1; tc[3] = (tc0_table+52)[index_a][bS[3]]+1; h->s.dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc); } else { h->s.dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta); } }


int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int is_write1, int mmu_idx) { X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; uint64_t ptep, pte; target_ulong pde_addr, pte_addr; int error_code = 0; int is_dirty, prot, page_size, is_write, is_user; hwaddr paddr; uint64_t rsvd_mask = PG_HI_RSVD_MASK; uint32_t page_offset; target_ulong vaddr; is_user = mmu_idx == MMU_USER_IDX; #if defined(DEBUG_MMU) printf("MMU fault: addr=%" VADDR_PRIx " w=%d u=%d eip=" TARGET_FMT_lx "\n", addr, is_write1, is_user, env->eip); #endif is_write = is_write1 & 1; if (!(env->cr[0] & CR0_PG_MASK)) { pte = addr; #ifdef TARGET_X86_64 if (!(env->hflags & HF_LMA_MASK)) { /* Without long mode we can only address 32bits in real mode */ pte = (uint32_t)pte; } #endif prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; page_size = 4096; goto do_mapping; } if (!(env->efer & MSR_EFER_NXE)) { rsvd_mask |= PG_NX_MASK; } if (env->cr[4] & CR4_PAE_MASK) { uint64_t pde, pdpe; target_ulong pdpe_addr; #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { uint64_t pml4e_addr, pml4e; int32_t sext; /* test virtual address sign extension */ sext = (int64_t)addr >> 47; if (sext != 0 && sext != -1) { env->error_code = 0; cs->exception_index = EXCP0D_GPF; return 1; } pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) & env->a20_mask; pml4e = ldq_phys(cs->as, pml4e_addr); if (!(pml4e & PG_PRESENT_MASK)) { goto do_fault; } if (pml4e & (rsvd_mask | PG_PSE_MASK)) { goto do_fault_rsvd; } if (!(pml4e & PG_ACCESSED_MASK)) { pml4e |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pml4e_addr, pml4e); } ptep = pml4e ^ PG_NX_MASK; pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((addr >> 30) & 0x1ff) << 3)) & env->a20_mask; pdpe = ldq_phys(cs->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } if (pdpe & rsvd_mask) { goto do_fault_rsvd; } ptep &= pdpe ^ PG_NX_MASK; if (!(pdpe & PG_ACCESSED_MASK)) { pdpe |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pdpe_addr, pdpe); } if (pdpe & PG_PSE_MASK) { /* 1 GB page */ page_size = 1024 * 1024 * 1024; pte_addr = pdpe_addr; pte = pdpe; goto do_check_protect; } } else #endif { /* XXX: load them when cr3 is loaded ? */ pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) & env->a20_mask; pdpe = ldq_phys(cs->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK; if (pdpe & rsvd_mask) { goto do_fault_rsvd; } ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK; } pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((addr >> 21) & 0x1ff) << 3)) & env->a20_mask; pde = ldq_phys(cs->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } if (pde & rsvd_mask) { goto do_fault_rsvd; } ptep &= pde ^ PG_NX_MASK; if (pde & PG_PSE_MASK) { /* 2 MB page */ page_size = 2048 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } /* 4 KB page */ if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pde_addr, pde); } pte_addr = ((pde & PG_ADDRESS_MASK) + (((addr >> 12) & 0x1ff) << 3)) & env->a20_mask; pte = ldq_phys(cs->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } if (pte & rsvd_mask) { goto do_fault_rsvd; } /* combine pde and pte nx, user and rw protections */ ptep &= pte ^ PG_NX_MASK; page_size = 4096; } else { uint32_t pde; /* page directory entry */ pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask; pde = ldl_phys(cs->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } ptep = pde | PG_NX_MASK; /* if PSE bit is set, then we use a 4MB page */ if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { page_size = 4096 * 1024; pte_addr = pde_addr; /* Bits 20-13 provide bits 39-32 of the address, bit 21 is reserved. * Leave bits 20-13 in place for setting accessed/dirty bits below. */ pte = pde | ((pde & 0x1fe000) << (32 - 13)); rsvd_mask = 0x200000; goto do_check_protect_pse36; } if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pde_addr, pde); } /* page directory entry */ pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask; pte = ldl_phys(cs->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } /* combine pde and pte user and rw protections */ ptep &= pte | PG_NX_MASK; page_size = 4096; rsvd_mask = 0; } do_check_protect: rsvd_mask |= (page_size - 1) & PG_ADDRESS_MASK & ~PG_PSE_PAT_MASK; do_check_protect_pse36: if (pte & rsvd_mask) { goto do_fault_rsvd; } ptep ^= PG_NX_MASK; if ((ptep & PG_NX_MASK) && is_write1 == 2) { goto do_fault_protect; } switch (mmu_idx) { case MMU_USER_IDX: if (!(ptep & PG_USER_MASK)) { goto do_fault_protect; } if (is_write && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; case MMU_KSMAP_IDX: if (is_write1 != 2 && (ptep & PG_USER_MASK)) { goto do_fault_protect; } /* fall through */ case MMU_KNOSMAP_IDX: if (is_write1 == 2 && (env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK)) { goto do_fault_protect; } if ((env->cr[0] & CR0_WP_MASK) && is_write && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; default: /* cannot happen */ break; } is_dirty = is_write && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || is_dirty) { pte |= PG_ACCESSED_MASK; if (is_dirty) { pte |= PG_DIRTY_MASK; } stl_phys_notdirty(cs->as, pte_addr, pte); } /* the page can be put in the TLB */ prot = PAGE_READ; if (!(ptep & PG_NX_MASK)) prot |= PAGE_EXEC; if (pte & PG_DIRTY_MASK) { /* only set write access if already dirty... otherwise wait for dirty access */ if (is_user) { if (ptep & PG_RW_MASK) prot |= PAGE_WRITE; } else { if (!(env->cr[0] & CR0_WP_MASK) || (ptep & PG_RW_MASK)) prot |= PAGE_WRITE; } } do_mapping: pte = pte & env->a20_mask; /* align to page_size */ pte &= PG_ADDRESS_MASK & ~(page_size - 1); /* Even if 4MB pages, we map only one 4KB page in the cache to avoid filling it too fast */ vaddr = addr & TARGET_PAGE_MASK; page_offset = vaddr & (page_size - 1); paddr = pte + page_offset; tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, page_size); return 0; do_fault_rsvd: error_code |= PG_ERROR_RSVD_MASK; do_fault_protect: error_code |= PG_ERROR_P_MASK; do_fault: error_code |= (is_write << PG_ERROR_W_BIT); if (is_user) error_code |= PG_ERROR_U_MASK; if (is_write1 == 2 && (((env->efer & MSR_EFER_NXE) && (env->cr[4] & CR4_PAE_MASK)) || (env->cr[4] & CR4_SMEP_MASK))) error_code |= PG_ERROR_I_D_MASK; if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) { /* cr2 is not modified in case of exceptions */ stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), addr); } else { env->cr[2] = addr; } env->error_code = error_code; cs->exception_index = EXCP0E_PAGE; return 1; }


uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr) { VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); uint8_t val; k->get_config(vdev, vdev->config); if (addr > (vdev->config_len - sizeof(val))) return (uint32_t)-1; val = ldub_p(vdev->config + addr); return val; }


av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans) { int n = 1 << nbits; int ret; s->nbits = nbits; s->inverse = trans == IDFT_C2R || trans == DFT_C2R; s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1; if (nbits < 4 || nbits > 16) return AVERROR(EINVAL); if ((ret = ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C)) < 0) return ret; ff_init_ff_cos_tabs(nbits); s->tcos = ff_cos_tabs[nbits]; s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2); #if !CONFIG_HARDCODED_TABLES { int i; const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1) * 2 * M_PI / n; for (i = 0; i < (n >> 2); i++) s->tsin[i] = sin(i * theta); } #endif s->rdft_calc = rdft_calc_c; if (ARCH_ARM) ff_rdft_init_arm(s); return 0; }


static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *int_mask) { UHCIAsync *async; int len = 0, max_len; uint8_t pid; USBDevice *dev; USBEndpoint *ep; /* Is active ? */ if (!(td->ctrl & TD_CTRL_ACTIVE)) return TD_RESULT_NEXT_QH; async = uhci_async_find_td(s, addr, td); if (async) { /* Already submitted */ async->queue->valid = 32; if (!async->done) return TD_RESULT_ASYNC_CONT; uhci_async_unlink(async); goto done; } /* Allocate new packet */ async = uhci_async_alloc(uhci_queue_get(s, td), addr); if (!async) return TD_RESULT_NEXT_QH; /* valid needs to be large enough to handle 10 frame delay * for initial isochronous requests */ async->queue->valid = 32; async->isoc = td->ctrl & TD_CTRL_IOS; max_len = ((td->token >> 21) + 1) & 0x7ff; pid = td->token & 0xff; dev = uhci_find_device(s, (td->token >> 8) & 0x7f); ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf); usb_packet_setup(&async->packet, pid, ep); qemu_sglist_add(&async->sgl, td->buffer, max_len); usb_packet_map(&async->packet, &async->sgl); switch(pid) { case USB_TOKEN_OUT: case USB_TOKEN_SETUP: len = usb_handle_packet(dev, &async->packet); if (len >= 0) len = max_len; break; case USB_TOKEN_IN: len = usb_handle_packet(dev, &async->packet); break; default: /* invalid pid : frame interrupted */ uhci_async_free(async); s->status |= UHCI_STS_HCPERR; uhci_update_irq(s); return TD_RESULT_STOP_FRAME; } if (len == USB_RET_ASYNC) { uhci_async_link(async); return TD_RESULT_ASYNC_START; } async->packet.result = len; done: len = uhci_complete_td(s, td, async, int_mask); usb_packet_unmap(&async->packet); uhci_async_free(async); return len; }


static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_index) { if (s->correct_ts_overflow && st->pts_wrap_bits != 64 && st->pts_wrap_reference == AV_NOPTS_VALUE && st->first_dts != AV_NOPTS_VALUE) { int i; // reference time stamp should be 60 s before first time stamp int64_t pts_wrap_reference = st->first_dts - av_rescale(60, st->time_base.den, st->time_base.num); // if first time stamp is not more than 1/8 and 60s before the wrap point, subtract rather than add wrap offset int pts_wrap_behavior = (st->first_dts < (1LL<<st->pts_wrap_bits) - (1LL<<st->pts_wrap_bits-3)) || (st->first_dts < (1LL<<st->pts_wrap_bits) - av_rescale(60, st->time_base.den, st->time_base.num)) ? AV_PTS_WRAP_ADD_OFFSET : AV_PTS_WRAP_SUB_OFFSET; AVProgram *first_program = av_find_program_from_stream(s, NULL, stream_index); if (!first_program) { int default_stream_index = av_find_default_stream_index(s); if (s->streams[default_stream_index]->pts_wrap_reference == AV_NOPTS_VALUE) { for (i=0; i<s->nb_streams; i++) { s->streams[i]->pts_wrap_reference = pts_wrap_reference; s->streams[i]->pts_wrap_behavior = pts_wrap_behavior; } } else { st->pts_wrap_reference = s->streams[default_stream_index]->pts_wrap_reference; st->pts_wrap_behavior = s->streams[default_stream_index]->pts_wrap_behavior; } } else { AVProgram *program = first_program; while (program) { if (program->pts_wrap_reference != AV_NOPTS_VALUE) { pts_wrap_reference = program->pts_wrap_reference; pts_wrap_behavior = program->pts_wrap_behavior; break; } program = av_find_program_from_stream(s, program, stream_index); } // update every program with differing pts_wrap_reference program = first_program; while(program) { if (program->pts_wrap_reference != pts_wrap_reference) { for (i=0; i<program->nb_stream_indexes; i++) { s->streams[program->stream_index[i]]->pts_wrap_reference = pts_wrap_reference; s->streams[program->stream_index[i]]->pts_wrap_behavior = pts_wrap_behavior; } program->pts_wrap_reference = pts_wrap_reference; program->pts_wrap_behavior = pts_wrap_behavior; } program = av_find_program_from_stream(s, program, stream_index); } } return 1; } return 0; }


static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len) { PtyCharDriver *s = chr->opaque; if (!s->connected) { /* guest sends data, check for (re-)connect */ pty_chr_update_read_handler_locked(chr); return 0; } return io_channel_send(s->fd, buf, len); }


int vnc_client_io_error(VncState *vs, int ret, int last_errno) { if (ret == 0 || ret == -1) { if (ret == -1) { switch (last_errno) { case EINTR: case EAGAIN: #ifdef _WIN32 case WSAEWOULDBLOCK: #endif return 0; default: break; } } VNC_DEBUG("Closing down client sock %d %d\n", ret, ret < 0 ? last_errno : 0); qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL); closesocket(vs->csock); qemu_del_timer(vs->timer); qemu_free_timer(vs->timer); if (vs->input.buffer) qemu_free(vs->input.buffer); if (vs->output.buffer) qemu_free(vs->output.buffer); #ifdef CONFIG_VNC_TLS vnc_tls_client_cleanup(vs); #endif /* CONFIG_VNC_TLS */ #ifdef CONFIG_VNC_SASL vnc_sasl_client_cleanup(vs); #endif /* CONFIG_VNC_SASL */ audio_del(vs); VncState *p, *parent = NULL; for (p = vs->vd->clients; p != NULL; p = p->next) { if (p == vs) { if (parent) parent->next = p->next; else vs->vd->clients = p->next; break; } parent = p; } if (!vs->vd->clients) dcl->idle = 1; qemu_free(vs->server.ds->data); qemu_free(vs->server.ds); qemu_free(vs->guest.ds); qemu_free(vs); return 0; } return ret; }


static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int *coded_samples) { ADPCMDecodeContext *s = avctx->priv_data; int nb_samples = 0; int ch = avctx->channels; int has_coded_samples = 0; int header_size; *coded_samples = 0; switch (avctx->codec->id) { /* constant, only check buf_size */ case CODEC_ID_ADPCM_EA_XAS: if (buf_size < 76 * ch) nb_samples = 128; break; case CODEC_ID_ADPCM_IMA_QT: if (buf_size < 34 * ch) nb_samples = 64; break; /* simple 4-bit adpcm */ case CODEC_ID_ADPCM_CT: case CODEC_ID_ADPCM_IMA_EA_SEAD: case CODEC_ID_ADPCM_IMA_WS: case CODEC_ID_ADPCM_YAMAHA: nb_samples = buf_size * 2 / ch; break; } if (nb_samples) return nb_samples; /* simple 4-bit adpcm, with header */ header_size = 0; switch (avctx->codec->id) { case CODEC_ID_ADPCM_4XM: case CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break; case CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break; case CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4; break; } if (header_size > 0) return (buf_size - header_size) * 2 / ch; /* more complex formats */ switch (avctx->codec->id) { case CODEC_ID_ADPCM_EA: has_coded_samples = 1; if (buf_size < 4) *coded_samples = AV_RL32(buf); *coded_samples -= *coded_samples % 28; nb_samples = (buf_size - 12) / 30 * 28; break; case CODEC_ID_ADPCM_IMA_EA_EACS: has_coded_samples = 1; if (buf_size < 4) *coded_samples = AV_RL32(buf); nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch; break; case CODEC_ID_ADPCM_EA_MAXIS_XA: nb_samples = ((buf_size - ch) / (2 * ch)) * 2 * ch; break; case CODEC_ID_ADPCM_EA_R1: case CODEC_ID_ADPCM_EA_R2: case CODEC_ID_ADPCM_EA_R3: /* maximum number of samples */ /* has internal offsets and a per-frame switch to signal raw 16-bit */ has_coded_samples = 1; if (buf_size < 4) switch (avctx->codec->id) { case CODEC_ID_ADPCM_EA_R1: header_size = 4 + 9 * ch; *coded_samples = AV_RL32(buf); break; case CODEC_ID_ADPCM_EA_R2: header_size = 4 + 5 * ch; *coded_samples = AV_RL32(buf); break; case CODEC_ID_ADPCM_EA_R3: header_size = 4 + 5 * ch; *coded_samples = AV_RB32(buf); break; } *coded_samples -= *coded_samples % 28; nb_samples = (buf_size - header_size) * 2 / ch; nb_samples -= nb_samples % 28; break; case CODEC_ID_ADPCM_IMA_DK3: if (avctx->block_align > 0) buf_size = FFMIN(buf_size, avctx->block_align); nb_samples = ((buf_size - 16) * 8 / 3) / ch; break; case CODEC_ID_ADPCM_IMA_DK4: nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch; break; case CODEC_ID_ADPCM_IMA_WAV: if (avctx->block_align > 0) buf_size = FFMIN(buf_size, avctx->block_align); nb_samples = 1 + (buf_size - 4 * ch) / (4 * ch) * 8; break; case CODEC_ID_ADPCM_MS: if (avctx->block_align > 0) buf_size = FFMIN(buf_size, avctx->block_align); nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch; break; case CODEC_ID_ADPCM_SBPRO_2: case CODEC_ID_ADPCM_SBPRO_3: case CODEC_ID_ADPCM_SBPRO_4: { int samples_per_byte; switch (avctx->codec->id) { case CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break; case CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break; case CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break; } if (!s->status[0].step_index) { nb_samples++; buf_size -= ch; } nb_samples += buf_size * samples_per_byte / ch; break; } case CODEC_ID_ADPCM_SWF: { int buf_bits = buf_size * 8 - 2; int nbits = (buf[0] >> 6) + 2; int block_hdr_size = 22 * ch; int block_size = block_hdr_size + nbits * ch * 4095; int nblocks = buf_bits / block_size; int bits_left = buf_bits - nblocks * block_size; nb_samples = nblocks * 4096; if (bits_left >= block_hdr_size) nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch); break; } case CODEC_ID_ADPCM_THP: has_coded_samples = 1; if (buf_size < 8) *coded_samples = AV_RB32(&buf[4]); *coded_samples -= *coded_samples % 14; nb_samples = (buf_size - 80) / (8 * ch) * 14; break; case CODEC_ID_ADPCM_XA: nb_samples = (buf_size / 128) * 224 / ch; break; } /* validate coded sample count */ if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples)) return AVERROR_INVALIDDATA; return nb_samples; }


static int64_t calculate_mode_score(CinepakEncContext *s, CinepakMode mode, int h, int v1_size, int v4_size, int v4, strip_info *info) { //score = FF_LAMBDA_SCALE * error + lambda * bits int x; int entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4; int mb_count = s->w * h / MB_AREA; mb_info *mb; int64_t score1, score2, score3; int64_t ret = s->lambda * ((v1_size ? CHUNK_HEADER_SIZE + v1_size * entry_size : 0) + (v4_size ? CHUNK_HEADER_SIZE + v4_size * entry_size : 0) + CHUNK_HEADER_SIZE) << 3; //av_log(s->avctx, AV_LOG_INFO, "sizes %3i %3i -> %9li score mb_count %i", v1_size, v4_size, ret, mb_count); switch(mode) { case MODE_V1_ONLY: //one byte per MB ret += s->lambda * 8 * mb_count; for(x = 0; x < mb_count; x++) { mb = &s->mb[x]; ret += FF_LAMBDA_SCALE * mb->v1_error; mb->best_encoding = ENC_V1; } break; case MODE_V1_V4: //9 or 33 bits per MB for(x = 0; x < mb_count; x++) { mb = &s->mb[x]; score1 = s->lambda * 9 + FF_LAMBDA_SCALE * mb->v1_error; score2 = s->lambda * 33 + FF_LAMBDA_SCALE * mb->v4_error[v4]; if(score1 <= score2) { ret += score1; mb->best_encoding = ENC_V1; } else { ret += score2; mb->best_encoding = ENC_V4; } } break; case MODE_MC: //1, 10 or 34 bits per MB for(x = 0; x < mb_count; x++) { mb = &s->mb[x]; score1 = s->lambda * 1 + FF_LAMBDA_SCALE * mb->skip_error; score2 = s->lambda * 10 + FF_LAMBDA_SCALE * mb->v1_error; score3 = s->lambda * 34 + FF_LAMBDA_SCALE * mb->v4_error[v4]; if(score1 <= score2 && score1 <= score3) { ret += score1; mb->best_encoding = ENC_SKIP; } else if(score2 <= score1 && score2 <= score3) { ret += score2; mb->best_encoding = ENC_V1; } else { ret += score3; mb->best_encoding = ENC_V4; } } break; } return ret; }


static inline int GET_TOK(TM2Context *ctx,int type) { if(ctx->tok_ptrs[type] >= ctx->tok_lens[type]) { av_log(ctx->avctx, AV_LOG_ERROR, "Read token from stream %i out of bounds (%i>=%i)\n", type, ctx->tok_ptrs[type], ctx->tok_lens[type]); return 0; } if(type <= TM2_MOT) return ctx->deltas[type][ctx->tokens[type][ctx->tok_ptrs[type]++]]; return ctx->tokens[type][ctx->tok_ptrs[type]++]; }


int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) { RTSPState *rt = s->priv_data; AVStream *st = NULL; int reordering_queue_size = rt->reordering_queue_size; if (reordering_queue_size < 0) { if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP || !s->max_delay) reordering_queue_size = 0; else reordering_queue_size = RTP_REORDER_QUEUE_DEFAULT_SIZE; } /* open the RTP context */ if (rtsp_st->stream_index >= 0) st = s->streams[rtsp_st->stream_index]; if (!st) s->ctx_flags |= AVFMTCTX_NOHEADER; if (CONFIG_RTSP_MUXER && s->oformat) { int ret = ff_rtp_chain_mux_open((AVFormatContext **)&rtsp_st->transport_priv, s, st, rtsp_st->rtp_handle, RTSP_TCP_MAX_PACKET_SIZE, rtsp_st->stream_index); /* Ownership of rtp_handle is passed to the rtp mux context */ rtsp_st->rtp_handle = NULL; if (ret < 0) return ret; st->time_base = ((AVFormatContext*)rtsp_st->transport_priv)->streams[0]->time_base; } else if (rt->transport == RTSP_TRANSPORT_RAW) { return 0; // Don't need to open any parser here } else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT) rtsp_st->transport_priv = ff_rdt_parse_open(s, st->index, rtsp_st->dynamic_protocol_context, rtsp_st->dynamic_handler); else if (CONFIG_RTPDEC) rtsp_st->transport_priv = ff_rtp_parse_open(s, st, rtsp_st->sdp_payload_type, reordering_queue_size); if (!rtsp_st->transport_priv) { return AVERROR(ENOMEM); } else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RTP) { RTPDemuxContext *rtpctx = rtsp_st->transport_priv; rtpctx->ssrc = rtsp_st->ssrc; if (rtsp_st->dynamic_handler) { ff_rtp_parse_set_dynamic_protocol(rtsp_st->transport_priv, rtsp_st->dynamic_protocol_context, rtsp_st->dynamic_handler); } if (rtsp_st->crypto_suite[0]) ff_rtp_parse_set_crypto(rtsp_st->transport_priv, rtsp_st->crypto_suite, rtsp_st->crypto_params); } return 0; }


static void chassis_control(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, unsigned int max_rsp_len) { IPMIInterface *s = ibs->parent.intf; IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s); IPMI_CHECK_CMD_LEN(3); switch (cmd[2] & 0xf) { case 0: /* power down */ rsp[2] = k->do_hw_op(s, IPMI_POWEROFF_CHASSIS, 0); break; case 1: /* power up */ rsp[2] = k->do_hw_op(s, IPMI_POWERON_CHASSIS, 0); break; case 2: /* power cycle */ rsp[2] = k->do_hw_op(s, IPMI_POWERCYCLE_CHASSIS, 0); break; case 3: /* hard reset */ rsp[2] = k->do_hw_op(s, IPMI_RESET_CHASSIS, 0); break; case 4: /* pulse diagnostic interrupt */ rsp[2] = k->do_hw_op(s, IPMI_PULSE_DIAG_IRQ, 0); break; case 5: /* soft shutdown via ACPI by overtemp emulation */ rsp[2] = k->do_hw_op(s, IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP, 0); break; default: rsp[2] = IPMI_CC_INVALID_DATA_FIELD; return; } }


static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio, const float *la, int channel, int prev_type) { AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data; AacPsyChannel *pch = &pctx->ch[channel]; int grouping = 0; int uselongblock = 1; int attacks[AAC_NUM_BLOCKS_SHORT + 1] = { 0 }; float clippings[AAC_NUM_BLOCKS_SHORT]; int i; FFPsyWindowInfo wi = { { 0 } }; if (la) { float hpfsmpl[AAC_BLOCK_SIZE_LONG]; float const *pf = hpfsmpl; float attack_intensity[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS]; float energy_subshort[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS]; float energy_short[AAC_NUM_BLOCKS_SHORT + 1] = { 0 }; const float *firbuf = la + (AAC_BLOCK_SIZE_SHORT/4 - PSY_LAME_FIR_LEN); int att_sum = 0; /* LAME comment: apply high pass filter of fs/4 */ psy_hp_filter(firbuf, hpfsmpl, psy_fir_coeffs); /* Calculate the energies of each sub-shortblock */ for (i = 0; i < PSY_LAME_NUM_SUBBLOCKS; i++) { energy_subshort[i] = pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 1) * PSY_LAME_NUM_SUBBLOCKS)]; assert(pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)] > 0); attack_intensity[i] = energy_subshort[i] / pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)]; energy_short[0] += energy_subshort[i]; } for (i = 0; i < AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS; i++) { float const *const pfe = pf + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS); float p = 1.0f; for (; pf < pfe; pf++) p = FFMAX(p, fabsf(*pf)); pch->prev_energy_subshort[i] = energy_subshort[i + PSY_LAME_NUM_SUBBLOCKS] = p; energy_short[1 + i / PSY_LAME_NUM_SUBBLOCKS] += p; /* NOTE: The indexes below are [i + 3 - 2] in the LAME source. * Obviously the 3 and 2 have some significance, or this would be just [i + 1] * (which is what we use here). What the 3 stands for is ambiguous, as it is both * number of short blocks, and the number of sub-short blocks. * It seems that LAME is comparing each sub-block to sub-block + 1 in the * previous block. */ if (p > energy_subshort[i + 1]) p = p / energy_subshort[i + 1]; else if (energy_subshort[i + 1] > p * 10.0f) p = energy_subshort[i + 1] / (p * 10.0f); else p = 0.0; attack_intensity[i + PSY_LAME_NUM_SUBBLOCKS] = p; } /* compare energy between sub-short blocks */ for (i = 0; i < (AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS; i++) if (!attacks[i / PSY_LAME_NUM_SUBBLOCKS]) if (attack_intensity[i] > pch->attack_threshold) attacks[i / PSY_LAME_NUM_SUBBLOCKS] = (i % PSY_LAME_NUM_SUBBLOCKS) + 1; /* should have energy change between short blocks, in order to avoid periodic signals */ /* Good samples to show the effect are Trumpet test songs */ /* GB: tuned (1) to avoid too many short blocks for test sample TRUMPET */ /* RH: tuned (2) to let enough short blocks through for test sample FSOL and SNAPS */ for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++) { float const u = energy_short[i - 1]; float const v = energy_short[i]; float const m = FFMAX(u, v); if (m < 40000) { /* (2) */ if (u < 1.7f * v && v < 1.7f * u) { /* (1) */ if (i == 1 && attacks[0] < attacks[i]) attacks[0] = 0; attacks[i] = 0; } } att_sum += attacks[i]; } if (attacks[0] <= pch->prev_attack) attacks[0] = 0; att_sum += attacks[0]; /* 3 below indicates the previous attack happened in the last sub-block of the previous sequence */ if (pch->prev_attack == 3 || att_sum) { uselongblock = 0; for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++) if (attacks[i] && attacks[i-1]) attacks[i] = 0; } } else { /* We have no lookahead info, so just use same type as the previous sequence. */ uselongblock = !(prev_type == EIGHT_SHORT_SEQUENCE); } lame_apply_block_type(pch, &wi, uselongblock); /* Calculate input sample maximums and evaluate clipping risk */ if (audio) { for (i = 0; i < AAC_NUM_BLOCKS_SHORT; i++) { const float *wbuf = audio + i * AAC_BLOCK_SIZE_SHORT; float max = 0; int j; for (j = 0; j < AAC_BLOCK_SIZE_SHORT; j++) max = FFMAX(max, fabsf(wbuf[j])); clippings[i] = max; } } else { for (i = 0; i < 8; i++) clippings[i] = 0; } wi.window_type[1] = prev_type; if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) { float clipping = 0.0f; wi.num_windows = 1; wi.grouping[0] = 1; if (wi.window_type[0] == LONG_START_SEQUENCE) wi.window_shape = 0; else wi.window_shape = 1; for (i = 0; i < 8; i++) clipping = FFMAX(clipping, clippings[i]); wi.clipping[0] = clipping; } else { int lastgrp = 0; wi.num_windows = 8; wi.window_shape = 0; for (i = 0; i < 8; i++) { if (!((pch->next_grouping >> i) & 1)) lastgrp = i; wi.grouping[lastgrp]++; } for (i = 0; i < 8; i += wi.grouping[i]) { int w; float clipping = 0.0f; for (w = 0; w < wi.grouping[i] && !clipping; w++) clipping = FFMAX(clipping, clippings[i+w]); wi.clipping[i] = clipping; } } /* Determine grouping, based on the location of the first attack, and save for * the next frame. * FIXME: Move this to analysis. * TODO: Tune groupings depending on attack location * TODO: Handle more than one attack in a group */ for (i = 0; i < 9; i++) { if (attacks[i]) { grouping = i; break; } } pch->next_grouping = window_grouping[grouping]; pch->prev_attack = attacks[8]; return wi; }