int bdrv_open(BlockDriverState *bs, const char *filename, int flags, BlockDriver *drv) { int ret; int probed = 0; if (flags & BDRV_O_SNAPSHOT) { BlockDriverState *bs1; int64_t total_size; int is_protocol = 0; BlockDriver *bdrv_qcow2; QEMUOptionParameter *options; char tmp_filename[PATH_MAX]; char backing_filename[PATH_MAX]; /* if snapshot, we create a temporary backing file and open it instead of opening 'filename' directly */ /* if there is a backing file, use it */ bs1 = bdrv_new(""); ret = bdrv_open(bs1, filename, 0, drv); if (ret < 0) { bdrv_delete(bs1); return ret; } total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK; if (bs1->drv && bs1->drv->protocol_name) is_protocol = 1; bdrv_delete(bs1); get_tmp_filename(tmp_filename, sizeof(tmp_filename)); /* Real path is meaningless for protocols */ if (is_protocol) snprintf(backing_filename, sizeof(backing_filename), "%s", filename); else if (!realpath(filename, backing_filename)) return -errno; bdrv_qcow2 = bdrv_find_format("qcow2"); options = parse_option_parameters("", bdrv_qcow2->create_options, NULL); set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size); set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename); if (drv) { set_option_parameter(options, BLOCK_OPT_BACKING_FMT, drv->format_name); } ret = bdrv_create(bdrv_qcow2, tmp_filename, options); free_option_parameters(options); if (ret < 0) { return ret; } filename = tmp_filename; drv = bdrv_qcow2; bs->is_temporary = 1; } /* Find the right image format driver */ if (!drv) { drv = find_image_format(filename); probed = 1; } if (!drv) { ret = -ENOENT; goto unlink_and_fail; } /* Open the image */ ret = bdrv_open_common(bs, filename, flags, drv); if (ret < 0) { goto unlink_and_fail; } /* If there is a backing file, use it */ if ((flags & BDRV_O_NO_BACKING) == 0 && bs->backing_file[0] != '\0') { char backing_filename[PATH_MAX]; int back_flags; BlockDriver *back_drv = NULL; bs->backing_hd = bdrv_new(""); path_combine(backing_filename, sizeof(backing_filename), filename, bs->backing_file); if (bs->backing_format[0] != '\0') back_drv = bdrv_find_format(bs->backing_format); /* backing files always opened read-only */ back_flags = flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); ret = bdrv_open(bs->backing_hd, backing_filename, back_flags, back_drv); if (ret < 0) { bdrv_close(bs); return ret; } if (bs->is_temporary) { bs->backing_hd->keep_read_only = !(flags & BDRV_O_RDWR); } else { /* base image inherits from "parent" */ bs->backing_hd->keep_read_only = bs->keep_read_only; } } if (!bdrv_key_required(bs)) { /* call the change callback */ bs->media_changed = 1; if (bs->change_cb) bs->change_cb(bs->change_opaque); } return 0; unlink_and_fail: if (bs->is_temporary) { unlink(filename); } return ret; }


static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, AVFilterInOut **open_inputs, AVFilterInOut **open_outputs, AVClass *log_ctx) { int ret, pad = 0; while (**buf == '[') { char *name = parse_link_name(buf, log_ctx); AVFilterInOut *match; AVFilterInOut *input = *curr_inputs; *curr_inputs = (*curr_inputs)->next; if (!name) /* First check if the label is not in the open_inputs list */ match = extract_inout(name, open_inputs); if (match) { if ((ret = link_filter(input->filter_ctx, input->pad_idx, match->filter_ctx, match->pad_idx, log_ctx)) < 0) return ret; av_free(match->name); av_free(name); av_free(match); av_free(input); } else { /* Not in the list, so add the first input as a open_output */ input->name = name; insert_inout(open_outputs, input); *buf += strspn(*buf, WHITESPACES); pad++; return pad;


static inline void rgb2rgb_init_c(void) { rgb15to16 = rgb15to16_c; rgb15tobgr24 = rgb15tobgr24_c; rgb15to32 = rgb15to32_c; rgb16tobgr24 = rgb16tobgr24_c; rgb16to32 = rgb16to32_c; rgb16to15 = rgb16to15_c; rgb24tobgr16 = rgb24tobgr16_c; rgb24tobgr15 = rgb24tobgr15_c; rgb24tobgr32 = rgb24tobgr32_c; rgb32to16 = rgb32to16_c; rgb32to15 = rgb32to15_c; rgb32tobgr24 = rgb32tobgr24_c; rgb24to15 = rgb24to15_c; rgb24to16 = rgb24to16_c; rgb24tobgr24 = rgb24tobgr24_c; shuffle_bytes_2103 = shuffle_bytes_2103_c; rgb32tobgr16 = rgb32tobgr16_c; rgb32tobgr15 = rgb32tobgr15_c; yv12toyuy2 = yv12toyuy2_c; yv12touyvy = yv12touyvy_c; yuv422ptoyuy2 = yuv422ptoyuy2_c; yuv422ptouyvy = yuv422ptouyvy_c; yuy2toyv12 = yuy2toyv12_c; planar2x = planar2x_c; rgb24toyv12 = rgb24toyv12_c; interleaveBytes = interleaveBytes_c; vu9_to_vu12 = vu9_to_vu12_c; yvu9_to_yuy2 = yvu9_to_yuy2_c; uyvytoyuv420 = uyvytoyuv420_c; uyvytoyuv422 = uyvytoyuv422_c; yuyvtoyuv420 = yuyvtoyuv420_c; yuyvtoyuv422 = yuyvtoyuv422_c; }


static Visitor *visitor_input_test_init_internal(TestInputVisitorData *data, const char *json_string, va_list *ap) { visitor_input_teardown(data, NULL); data->obj = qobject_from_jsonv(json_string, ap); g_assert(data->obj); data->qiv = qobject_input_visitor_new(data->obj); g_assert(data->qiv); return data->qiv; }


static int audio_decode_frame(VideoState *is) { int data_size, resampled_data_size; int64_t dec_channel_layout; int got_frame = 0; av_unused double audio_clock0; int wanted_nb_samples; AVRational tb; int ret; int reconfigure; if (!is->frame) if (!(is->frame = av_frame_alloc())) return AVERROR(ENOMEM); for (;;) { if (is->audioq.serial != is->auddec.pkt_serial) is->audio_buf_frames_pending = got_frame = 0; if (!got_frame) av_frame_unref(is->frame); if (is->paused) return -1; while (is->audio_buf_frames_pending || got_frame) { if (!is->audio_buf_frames_pending) { got_frame = 0; tb = (AVRational){1, is->frame->sample_rate}; #if CONFIG_AVFILTER dec_channel_layout = get_valid_channel_layout(is->frame->channel_layout, av_frame_get_channels(is->frame)); reconfigure = cmp_audio_fmts(is->audio_filter_src.fmt, is->audio_filter_src.channels, is->frame->format, av_frame_get_channels(is->frame)) || is->audio_filter_src.channel_layout != dec_channel_layout || is->audio_filter_src.freq != is->frame->sample_rate || is->auddec.pkt_serial != is->audio_last_serial; if (reconfigure) { char buf1[1024], buf2[1024]; av_get_channel_layout_string(buf1, sizeof(buf1), -1, is->audio_filter_src.channel_layout); av_get_channel_layout_string(buf2, sizeof(buf2), -1, dec_channel_layout); av_log(NULL, AV_LOG_DEBUG, "Audio frame changed from rate:%d ch:%d fmt:%s layout:%s serial:%d to rate:%d ch:%d fmt:%s layout:%s serial:%d\n", is->audio_filter_src.freq, is->audio_filter_src.channels, av_get_sample_fmt_name(is->audio_filter_src.fmt), buf1, is->audio_last_serial, is->frame->sample_rate, av_frame_get_channels(is->frame), av_get_sample_fmt_name(is->frame->format), buf2, is->auddec.pkt_serial); is->audio_filter_src.fmt = is->frame->format; is->audio_filter_src.channels = av_frame_get_channels(is->frame); is->audio_filter_src.channel_layout = dec_channel_layout; is->audio_filter_src.freq = is->frame->sample_rate; is->audio_last_serial = is->auddec.pkt_serial; if ((ret = configure_audio_filters(is, afilters, 1)) < 0) return ret; } if ((ret = av_buffersrc_add_frame(is->in_audio_filter, is->frame)) < 0) return ret; #endif } #if CONFIG_AVFILTER if ((ret = av_buffersink_get_frame_flags(is->out_audio_filter, is->frame, 0)) < 0) { if (ret == AVERROR(EAGAIN)) { is->audio_buf_frames_pending = 0; continue; } if (ret == AVERROR_EOF) is->auddec.finished = is->auddec.pkt_serial; return ret; } is->audio_buf_frames_pending = 1; tb = is->out_audio_filter->inputs[0]->time_base; #endif data_size = av_samples_get_buffer_size(NULL, av_frame_get_channels(is->frame), is->frame->nb_samples, is->frame->format, 1); dec_channel_layout = (is->frame->channel_layout && av_frame_get_channels(is->frame) == av_get_channel_layout_nb_channels(is->frame->channel_layout)) ? is->frame->channel_layout : av_get_default_channel_layout(av_frame_get_channels(is->frame)); wanted_nb_samples = synchronize_audio(is, is->frame->nb_samples); if (is->frame->format != is->audio_src.fmt || dec_channel_layout != is->audio_src.channel_layout || is->frame->sample_rate != is->audio_src.freq || (wanted_nb_samples != is->frame->nb_samples && !is->swr_ctx)) { swr_free(&is->swr_ctx); is->swr_ctx = swr_alloc_set_opts(NULL, is->audio_tgt.channel_layout, is->audio_tgt.fmt, is->audio_tgt.freq, dec_channel_layout, is->frame->format, is->frame->sample_rate, 0, NULL); if (!is->swr_ctx || swr_init(is->swr_ctx) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!\n", is->frame->sample_rate, av_get_sample_fmt_name(is->frame->format), av_frame_get_channels(is->frame), is->audio_tgt.freq, av_get_sample_fmt_name(is->audio_tgt.fmt), is->audio_tgt.channels); break; } is->audio_src.channel_layout = dec_channel_layout; is->audio_src.channels = av_frame_get_channels(is->frame); is->audio_src.freq = is->frame->sample_rate; is->audio_src.fmt = is->frame->format; } if (is->swr_ctx) { const uint8_t **in = (const uint8_t **)is->frame->extended_data; uint8_t **out = &is->audio_buf1; int out_count = (int64_t)wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate + 256; int out_size = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, out_count, is->audio_tgt.fmt, 0); int len2; if (out_size < 0) { av_log(NULL, AV_LOG_ERROR, "av_samples_get_buffer_size() failed\n"); break; } if (wanted_nb_samples != is->frame->nb_samples) { if (swr_set_compensation(is->swr_ctx, (wanted_nb_samples - is->frame->nb_samples) * is->audio_tgt.freq / is->frame->sample_rate, wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate) < 0) { av_log(NULL, AV_LOG_ERROR, "swr_set_compensation() failed\n"); break; } } av_fast_malloc(&is->audio_buf1, &is->audio_buf1_size, out_size); if (!is->audio_buf1) return AVERROR(ENOMEM); len2 = swr_convert(is->swr_ctx, out, out_count, in, is->frame->nb_samples); if (len2 < 0) { av_log(NULL, AV_LOG_ERROR, "swr_convert() failed\n"); break; } if (len2 == out_count) { av_log(NULL, AV_LOG_WARNING, "audio buffer is probably too small\n"); swr_init(is->swr_ctx); } is->audio_buf = is->audio_buf1; resampled_data_size = len2 * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt); } else { is->audio_buf = is->frame->data[0]; resampled_data_size = data_size; } audio_clock0 = is->audio_clock; /* update the audio clock with the pts */ if (is->frame->pts != AV_NOPTS_VALUE) is->audio_clock = is->frame->pts * av_q2d(tb) + (double) is->frame->nb_samples / is->frame->sample_rate; else is->audio_clock = NAN; is->audio_clock_serial = is->auddec.pkt_serial; #ifdef DEBUG { static double last_clock; printf("audio: delay=%0.3f clock=%0.3f clock0=%0.3f\n", is->audio_clock - last_clock, is->audio_clock, audio_clock0); last_clock = is->audio_clock; } #endif return resampled_data_size; } if ((got_frame = decoder_decode_frame(&is->auddec, is->frame, NULL)) < 0) return -1; if (is->auddec.flushed) is->audio_buf_frames_pending = 0; } }


static void scsi_do_read(void *opaque, int ret) { SCSIDiskReq *r = opaque; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint32_t n; if (r->req.aiocb != NULL) { r->req.aiocb = NULL; bdrv_acct_done(s->qdev.conf.bs, &r->acct); if (ret < 0) { if (scsi_handle_rw_error(r, -ret)) { goto done; if (r->req.sg) { dma_acct_start(s->qdev.conf.bs, &r->acct, r->req.sg, BDRV_ACCT_READ); r->req.resid -= r->req.sg->size; r->req.aiocb = dma_bdrv_read(s->qdev.conf.bs, r->req.sg, r->sector, scsi_dma_complete, r); } else { n = scsi_init_iovec(r, SCSI_DMA_BUF_SIZE); bdrv_acct_start(s->qdev.conf.bs, &r->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ); r->req.aiocb = bdrv_aio_readv(s->qdev.conf.bs, r->sector, &r->qiov, n, scsi_read_complete, r); done: if (!r->req.io_canceled) { scsi_req_unref(&r->req);


static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) { BDRVSheepdogState *s = acb->common.bs->opaque; struct iovec iov; AIOReq *aio_req; uint32_t offset, data_len, mn, mx; mn = s->min_dirty_data_idx; mx = s->max_dirty_data_idx; if (mn <= mx) { /* we need to update the vdi object. */ offset = sizeof(s->inode) - sizeof(s->inode.data_vdi_id) + mn * sizeof(s->inode.data_vdi_id[0]); data_len = (mx - mn + 1) * sizeof(s->inode.data_vdi_id[0]); s->min_dirty_data_idx = UINT32_MAX; s->max_dirty_data_idx = 0; iov.iov_base = &s->inode; iov.iov_len = sizeof(s->inode); aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id), data_len, offset, 0, false, 0, offset); QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); add_aio_request(s, aio_req, &iov, 1, AIOCB_WRITE_UDATA); acb->aio_done_func = sd_finish_aiocb; acb->aiocb_type = AIOCB_WRITE_UDATA; return; } sd_finish_aiocb(acb); }


static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs, BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, int64_t align, QEMUIOVector *qiov, int flags) { BlockDriver *drv = bs->drv; bool waited; int ret; int64_t start_sector = offset >> BDRV_SECTOR_BITS; int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE); uint64_t bytes_remaining = bytes; int max_transfer; assert(is_power_of_2(align)); assert((offset & (align - 1)) == 0); assert((bytes & (align - 1)) == 0); assert(!qiov || bytes == qiov->size); assert((bs->open_flags & BDRV_O_NO_IO) == 0); assert(!(flags & ~BDRV_REQ_MASK)); max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX), align); waited = wait_serialising_requests(req); assert(!waited || !req->serialising); assert(req->overlap_offset <= offset); assert(offset + bytes <= req->overlap_offset + req->overlap_bytes); ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req); if (!ret && bs->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF && !(flags & BDRV_REQ_ZERO_WRITE) && drv->bdrv_co_pwrite_zeroes && qemu_iovec_is_zero(qiov)) { flags |= BDRV_REQ_ZERO_WRITE; if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) { flags |= BDRV_REQ_MAY_UNMAP; } } if (ret < 0) { /* Do nothing, write notifier decided to fail this request */ } else if (flags & BDRV_REQ_ZERO_WRITE) { bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO); ret = bdrv_co_do_pwrite_zeroes(bs, offset, bytes, flags); } else if (flags & BDRV_REQ_WRITE_COMPRESSED) { ret = bdrv_driver_pwritev_compressed(bs, offset, bytes, qiov); } else if (bytes <= max_transfer) { bdrv_debug_event(bs, BLKDBG_PWRITEV); ret = bdrv_driver_pwritev(bs, offset, bytes, qiov, flags); } else { bdrv_debug_event(bs, BLKDBG_PWRITEV); while (bytes_remaining) { int num = MIN(bytes_remaining, max_transfer); QEMUIOVector local_qiov; int local_flags = flags; assert(num); if (num < bytes_remaining && (flags & BDRV_REQ_FUA) && !(bs->supported_write_flags & BDRV_REQ_FUA)) { /* If FUA is going to be emulated by flush, we only * need to flush on the last iteration */ local_flags &= ~BDRV_REQ_FUA; } qemu_iovec_init(&local_qiov, qiov->niov); qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, num); ret = bdrv_driver_pwritev(bs, offset + bytes - bytes_remaining, num, &local_qiov, local_flags); qemu_iovec_destroy(&local_qiov); if (ret < 0) { break; } bytes_remaining -= num; } } bdrv_debug_event(bs, BLKDBG_PWRITEV_DONE); ++bs->write_gen; bdrv_set_dirty(bs, start_sector, end_sector - start_sector); if (bs->wr_highest_offset < offset + bytes) { bs->wr_highest_offset = offset + bytes; } if (ret >= 0) { bs->total_sectors = MAX(bs->total_sectors, end_sector); ret = 0; } return ret; }


static target_ulong get_sigframe(struct target_sigaction *ka, CPUPPCState *env, int frame_size) { target_ulong oldsp, newsp; oldsp = env->gpr[1]; if ((ka->sa_flags & TARGET_SA_ONSTACK) && (sas_ss_flags(oldsp))) { oldsp = (target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size); } newsp = (oldsp - frame_size) & ~0xFUL; return newsp; }


vsprintf_len(string, format, args) char *string; const char *format; va_list args; { vsprintf(string, format, args); return strlen(string); }


void HELPER(idte)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint32_t m4) { CPUState *cs = CPU(s390_env_get_cpu(env)); const uintptr_t ra = GETPC(); uint64_t table, entry, raddr; uint16_t entries, i, index = 0; if (r2 & 0xff000) { cpu_restore_state(cs, ra); program_interrupt(env, PGM_SPECIFICATION, 4); } if (!(r2 & 0x800)) { /* invalidation-and-clearing operation */ table = r1 & _ASCE_ORIGIN; entries = (r2 & 0x7ff) + 1; switch (r1 & _ASCE_TYPE_MASK) { case _ASCE_TYPE_REGION1: index = (r2 >> 53) & 0x7ff; break; case _ASCE_TYPE_REGION2: index = (r2 >> 42) & 0x7ff; break; case _ASCE_TYPE_REGION3: index = (r2 >> 31) & 0x7ff; break; case _ASCE_TYPE_SEGMENT: index = (r2 >> 20) & 0x7ff; break; } for (i = 0; i < entries; i++) { /* addresses are not wrapped in 24/31bit mode but table index is */ raddr = table + ((index + i) & 0x7ff) * sizeof(entry); entry = cpu_ldq_real_ra(env, raddr, ra); if (!(entry & _REGION_ENTRY_INV)) { /* we are allowed to not store if already invalid */ entry |= _REGION_ENTRY_INV; cpu_stq_real_ra(env, raddr, entry, ra); } } } /* We simply flush the complete tlb, therefore we can ignore r3. */ if (m4 & 1) { tlb_flush(cs); } else { tlb_flush_all_cpus_synced(cs); } }


CharDriverState *qemu_chr_open_opts(QemuOpts *opts, void (*init)(struct CharDriverState *s)) { CharDriverState *chr; int i; if (qemu_opts_id(opts) == NULL) { fprintf(stderr, "chardev: no id specified\n"); return NULL; } for (i = 0; i < ARRAY_SIZE(backend_table); i++) { if (strcmp(backend_table[i].name, qemu_opt_get(opts, "backend")) == 0) break; } if (i == ARRAY_SIZE(backend_table)) { fprintf(stderr, "chardev: backend \"%s\" not found\n", qemu_opt_get(opts, "backend")); return NULL; } chr = backend_table[i].open(opts); if (!chr) { fprintf(stderr, "chardev: opening backend \"%s\" failed\n", qemu_opt_get(opts, "backend")); return NULL; } if (!chr->filename) chr->filename = qemu_strdup(qemu_opt_get(opts, "backend")); chr->init = init; TAILQ_INSERT_TAIL(&chardevs, chr, next); if (qemu_opt_get_bool(opts, "mux", 0)) { CharDriverState *base = chr; int len = strlen(qemu_opts_id(opts)) + 6; base->label = qemu_malloc(len); snprintf(base->label, len, "%s-base", qemu_opts_id(opts)); chr = qemu_chr_open_mux(base); chr->filename = base->filename; TAILQ_INSERT_TAIL(&chardevs, chr, next); } chr->label = qemu_strdup(qemu_opts_id(opts)); return chr; }


static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data; ac3_audio_block *ab = &ctx->audio_block; int frame_start; int i, j, k, l, value; float tmp_block_first_half[128], tmp_block_second_half[128]; int16_t *out_samples = (int16_t *)data; int nfchans; //Synchronize the frame. frame_start = ac3_synchronize(buf, buf_size); if (frame_start == -1) { av_log(avctx, AV_LOG_ERROR, "frame is not synchronized\n"); *data_size = 0; return buf_size; } //Initialize the GetBitContext with the start of valid AC3 Frame. init_get_bits(&(ctx->gb), buf + frame_start, (buf_size - frame_start) * 8); //Parse the syncinfo. //If 'fscod' or 'bsid' is not valid the decoder shall mute as per the standard. if (!ac3_parse_sync_info(ctx)) { av_log(avctx, AV_LOG_ERROR, "\n"); *data_size = 0; return -1; } //Check for the errors. /* if (ac3_error_check(ctx)) { *data_size = 0; return -1; } */ //Parse the BSI. //If 'bsid' is not valid decoder shall not decode the audio as per the standard. if (ac3_parse_bsi(ctx)) { av_log(avctx, AV_LOG_ERROR, "bsid is not valid\n"); *data_size = 0; return -1; } for (i = 0; i < MAX_BLOCKS; i++) memset(ctx->delay[i], 0, sizeof(ctx->delay[i])); avctx->sample_rate = ctx->sync_info.sampling_rate; avctx->bit_rate = ctx->sync_info.bit_rate; if (avctx->channels == 0) { //avctx->channels = ctx->bsi.nfchans + ((ctx->bsi.flags & AC3_BSI_LFEON) ? 1 : 0); ctx->output = AC3_OUTPUT_UNMODIFIED; } else if ((ctx->bsi.nfchans + ((ctx->bsi.flags & AC3_BSI_LFEON) ? 1 : 0)) < avctx->channels) { av_log(avctx, AV_LOG_INFO, "ac3_decoder: AC3 Source Channels Are Less Then Specified %d: Output to %d Channels\n", avctx->channels, (ctx->bsi.nfchans + ((ctx->bsi.flags & AC3_BSI_LFEON) ? 1 : 0))); //avctx->channels = ctx->bsi.nfchans + ((ctx->bsi.flags & AC3_BSI_LFEON) ? 1 : 0); ctx->output = AC3_OUTPUT_UNMODIFIED; } else if (avctx->channels == 1) { ctx->output = AC3_OUTPUT_MONO; } else if (avctx->channels == 2) { if (ctx->bsi.dsurmod == 0x02) ctx->output = AC3_OUTPUT_DOLBY; else ctx->output = AC3_OUTPUT_STEREO; } av_log(avctx, AV_LOG_INFO, "channels = %d \t bit rate = %d \t sampling rate = %d \n", avctx->channels, avctx->sample_rate, avctx->bit_rate); //Parse the Audio Blocks. *data_size = 0; for (i = 0; i < 6; i++) { if (ac3_parse_audio_block(ctx, i)) { av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n"); *data_size = 0; return -1; } av_log(NULL, AV_LOG_INFO, "doing imdct\n"); if (ctx->bsi.flags & AC3_BSI_LFEON) { ff_imdct_calc(&ctx->imdct_ctx_512, ctx->tmp_output, ab->transform_coeffs[0], ctx->tmp_imdct); for (l = 0; l < 256; l++) ab->block_output[0][l] = ctx->tmp_output[l] * window[l] + ctx->delay[0][l] * window[255 -l]; memcpy(ctx->delay[0], ctx->tmp_output + 256, sizeof(ctx->delay[0])); } for (j = 0; j < ctx->bsi.nfchans; j++) { if (ctx->audio_block.blksw & (1 << j)) { for (k = 0; k < 128; k++) { tmp_block_first_half[k] = ab->transform_coeffs[j + 1][2 * k]; tmp_block_second_half[k] = ab->transform_coeffs[j + 1][2 * k + 1]; } ff_imdct_calc(&ctx->imdct_ctx_256, ctx->tmp_output, tmp_block_first_half, ctx->tmp_imdct); for (l = 0; l < 256; l++) ab->block_output[j + 1][l] = ctx->tmp_output[l] * window[l] + ctx->delay[j + 1][l] * window[255 - l]; ff_imdct_calc(&ctx->imdct_ctx_256, ctx->delay[j + 1], tmp_block_second_half, ctx->tmp_imdct); } else { ff_imdct_calc(&ctx->imdct_ctx_512, ctx->tmp_output, ab->transform_coeffs[j + 1], ctx->tmp_imdct); for (l = 0; l < 256; l++) ab->block_output[j + 1][l] = ctx->tmp_output[l] * window[l] + ctx->delay[j + 1][l] * window[255 - l]; memcpy(ctx->delay[j + 1], ctx->tmp_output + 256, sizeof(ctx->delay[j + 1])); } } if (ctx->bsi.flags & AC3_BSI_LFEON) { for (l = 0; l < 256; l++) { value = lrint(ab->block_output[0][l]); if (value < -32768) value = -32768; else if (value > 32767) value = 32767; *(out_samples++) = value; } *data_size += 256 * sizeof(int16_t); } do_downmix(ctx); if (ctx->output == AC3_OUTPUT_UNMODIFIED) nfchans = ctx->bsi.nfchans; else nfchans = avctx->channels; for (k = 0; k < nfchans; k++) for (l = 0; l < 256; l++) { value = lrint(ab->block_output[k + 1][l]); if (value < -32768) value = -32768; else if (value > 32767) value = 32767; *(out_samples++) = value; } *data_size += nfchans * 256 * sizeof (int16_t); } return ctx->sync_info.framesize; }


static void ac97_save (QEMUFile *f, void *opaque) { size_t i; uint8_t active[LAST_INDEX]; AC97LinkState *s = opaque; pci_device_save (s->pci_dev, f); qemu_put_be32s (f, &s->glob_cnt); qemu_put_be32s (f, &s->glob_sta); qemu_put_be32s (f, &s->cas); for (i = 0; i < ARRAY_SIZE (s->bm_regs); ++i) { AC97BusMasterRegs *r = &s->bm_regs[i]; qemu_put_be32s (f, &r->bdbar); qemu_put_8s (f, &r->civ); qemu_put_8s (f, &r->lvi); qemu_put_be16s (f, &r->sr); qemu_put_be16s (f, &r->picb); qemu_put_8s (f, &r->piv); qemu_put_8s (f, &r->cr); qemu_put_be32s (f, &r->bd_valid); qemu_put_be32s (f, &r->bd.addr); qemu_put_be32s (f, &r->bd.ctl_len); } qemu_put_buffer (f, s->mixer_data, sizeof (s->mixer_data)); active[PI_INDEX] = AUD_is_active_in (s->voice_pi) ? 1 : 0; active[PO_INDEX] = AUD_is_active_out (s->voice_po) ? 1 : 0; active[MC_INDEX] = AUD_is_active_in (s->voice_mc) ? 1 : 0; qemu_put_buffer (f, active, sizeof (active)); }


static void timer_save(QEMUFile *f, void *opaque) { if (cpu_ticks_enabled) { hw_error("cannot save state if virtual timers are running"); } qemu_put_be64(f, cpu_ticks_offset); qemu_put_be64(f, ticks_per_sec); qemu_put_be64(f, cpu_clock_offset); }


void eth_get_protocols(const uint8_t *headers, uint32_t hdr_length, bool *isip4, bool *isip6, bool *isudp, bool *istcp) { int proto; size_t l2hdr_len = eth_get_l2_hdr_length(headers); assert(hdr_length >= eth_get_l2_hdr_length(headers)); *isip4 = *isip6 = *isudp = *istcp = false; proto = eth_get_l3_proto(headers, l2hdr_len); if (proto == ETH_P_IP) { *isip4 = true; struct ip_header *iphdr; assert(hdr_length >= eth_get_l2_hdr_length(headers) + sizeof(struct ip_header)); iphdr = PKT_GET_IP_HDR(headers); if (IP_HEADER_VERSION(iphdr) == IP_HEADER_VERSION_4) { if (iphdr->ip_p == IP_PROTO_TCP) { *istcp = true; } else if (iphdr->ip_p == IP_PROTO_UDP) { *isudp = true; } } } else if (proto == ETH_P_IPV6) { uint8_t l4proto; size_t full_ip6hdr_len; struct iovec hdr_vec; hdr_vec.iov_base = (void *) headers; hdr_vec.iov_len = hdr_length; *isip6 = true; if (eth_parse_ipv6_hdr(&hdr_vec, 1, l2hdr_len, &l4proto, &full_ip6hdr_len)) { if (l4proto == IP_PROTO_TCP) { *istcp = true; } else if (l4proto == IP_PROTO_UDP) { *isudp = true; } } } }


VncInfo *qmp_query_vnc(Error **errp) { VncInfo *info = g_malloc0(sizeof(*info)); VncDisplay *vd = vnc_display_find(NULL); SocketAddressLegacy *addr = NULL; if (vd == NULL || !vd->nlsock) { info->enabled = false; } else { info->enabled = true; /* for compatibility with the original command */ info->has_clients = true; info->clients = qmp_query_client_list(vd); if (vd->lsock == NULL) { return info; } addr = qio_channel_socket_get_local_address(vd->lsock[0], errp); if (!addr) { goto out_error; } switch (addr->type) { case SOCKET_ADDRESS_LEGACY_KIND_INET: info->host = g_strdup(addr->u.inet.data->host); info->service = g_strdup(addr->u.inet.data->port); if (addr->u.inet.data->ipv6) { info->family = NETWORK_ADDRESS_FAMILY_IPV6; } else { info->family = NETWORK_ADDRESS_FAMILY_IPV4; } break; case SOCKET_ADDRESS_LEGACY_KIND_UNIX: info->host = g_strdup(""); info->service = g_strdup(addr->u.q_unix.data->path); info->family = NETWORK_ADDRESS_FAMILY_UNIX; break; case SOCKET_ADDRESS_LEGACY_KIND_VSOCK: case SOCKET_ADDRESS_LEGACY_KIND_FD: error_setg(errp, "Unsupported socket address type %s", SocketAddressLegacyKind_lookup[addr->type]); goto out_error; default: abort(); } info->has_host = true; info->has_service = true; info->has_family = true; info->has_auth = true; info->auth = g_strdup(vnc_auth_name(vd)); } qapi_free_SocketAddressLegacy(addr); return info; out_error: qapi_free_SocketAddressLegacy(addr); qapi_free_VncInfo(info); return NULL; }


static void unassigned_mem_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { #ifdef DEBUG_UNASSIGNED printf("Unassigned mem write " TARGET_FMT_plx " = 0x%"PRIx64"\n", addr, val); #endif #if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) cpu_unassigned_access(cpu_single_env, addr, 1, 0, 0, size); #endif }


static int milkymist_vgafb_init(SysBusDevice *dev) { MilkymistVgafbState *s = FROM_SYSBUS(typeof(*s), dev); memory_region_init_io(&s->regs_region, &vgafb_mmio_ops, s, "milkymist-vgafb", R_MAX * 4); sysbus_init_mmio(dev, &s->regs_region); s->con = graphic_console_init(vgafb_update_display, vgafb_invalidate_display, NULL, NULL, s); return 0; }


static void memory_init(void) { qemu_mutex_init(&flat_view_mutex); }


static void tcg_reg_alloc_bb_end(TCGContext *s, TCGRegSet allocated_regs) { int i; for (i = s->nb_globals; i < s->nb_temps; i++) { TCGTemp *ts = &s->temps[i]; if (ts->temp_local) { temp_save(s, ts, allocated_regs); } else { #ifdef USE_LIVENESS_ANALYSIS /* ??? Liveness does not yet incorporate indirect bases. */ if (!ts->indirect_base) { /* The liveness analysis already ensures that temps are dead. Keep an assert for safety. */ assert(ts->val_type == TEMP_VAL_DEAD); continue; } #endif temp_dead(s, ts); } } save_globals(s, allocated_regs); }


static int bitplane_decoding(uint8_t* plane, int width, int height, VC9Context *v) { int imode, x, y, i, code, use_vertical_tile, tile_w, tile_h; uint8_t invert, *planep = plane; int stride= width; invert = get_bits(&v->gb, 1); imode = get_vlc2(&v->gb, vc9_imode_vlc.table, VC9_IMODE_VLC_BITS, 2); av_log(v->avctx, AV_LOG_DEBUG, "Bitplane: imode=%i, invert=%i\n", imode, invert); switch (imode) { case IMODE_RAW: for (y=0; y<height; y++) { for (x=0; x<width; x++) planep[x] = (-get_bits(&v->gb, 1)); //-1=0xFF planep += stride; } invert=0; //spec says ignore invert if raw break; case IMODE_DIFF2: case IMODE_NORM2: if ((height*width) & 1) *(++planep) = get_bits(&v->gb, 1); for(i=0; i<(height*width)>>1; i++){ code = get_vlc2(&v->gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); *(++planep) = code&1; //lsb => left *(++planep) = code&2; //msb => right - this is a bitplane, so only !0 matters //FIXME width->stride } break; case IMODE_DIFF6: case IMODE_NORM6: use_vertical_tile= height%3==0 && width%3!=0; tile_w= use_vertical_tile ? 2 : 3; tile_h= use_vertical_tile ? 3 : 2; for(y= height%tile_h; y<height; y+=tile_h){ for(x= width%tile_w; x<width; x+=tile_w){ code = get_vlc2(&v->gb, vc9_norm6_vlc.table, VC9_NORM6_VLC_BITS, 2); //FIXME following is a pure guess and probably wrong planep[x + 0*stride]= (code>>0)&1; planep[x + 1 + 0*stride]= (code>>1)&1; if(use_vertical_tile){ planep[x + 0 + 1*stride]= (code>>2)&1; planep[x + 1 + 1*stride]= (code>>3)&1; planep[x + 0 + 2*stride]= (code>>4)&1; planep[x + 1 + 2*stride]= (code>>5)&1; }else{ planep[x + 2 + 0*stride]= (code>>2)&1; planep[x + 0 + 1*stride]= (code>>3)&1; planep[x + 1 + 1*stride]= (code>>4)&1; planep[x + 2 + 1*stride]= (code>>5)&1; } } } x= width % tile_w; decode_colskip(plane , x, height , stride, v); decode_rowskip(plane+x, width - x, height % tile_h, stride, v); break; case IMODE_ROWSKIP: decode_rowskip(plane, width, height, stride, v); break; case IMODE_COLSKIP: //Teh ugly decode_colskip(plane, width, height, stride, v); break; default: break; } /* Applying diff operator */ if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) { planep = plane; planep[0] ^= invert; for (x=1; x<width; x++) planep[x] ^= planep[x-1]; for (y=1; y<height; y++) { planep += stride; planep[0] ^= planep[-stride]; for (x=1; x<width; x++) { if (planep[x-1] != planep[x-stride]) planep[x] ^= invert; else planep[x] ^= planep[x-1]; } } } else if (invert) { planep = plane; for (x=0; x<width*height; x++) planep[x] = !planep[x]; //FIXME stride } return 0; }


static int qpa_init_out (HWVoiceOut *hw, audsettings_t *as) { int error; static pa_sample_spec ss; audsettings_t obt_as = *as; PAVoiceOut *pa = (PAVoiceOut *) hw; ss.format = audfmt_to_pa (as->fmt, as->endianness); ss.channels = as->nchannels; ss.rate = as->freq; obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness); pa->s = pa_simple_new ( conf.server, "qemu", PA_STREAM_PLAYBACK, conf.sink, "pcm.playback", &ss, NULL, /* channel map */ NULL, /* buffering attributes */ &error ); if (!pa->s) { qpa_logerr (error, "pa_simple_new for playback failed\n"); goto fail1; } audio_pcm_init_info (&hw->info, &obt_as); hw->samples = conf.samples; pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); if (!pa->pcm_buf) { dolog ("Could not allocate buffer (%d bytes)\n", hw->samples << hw->info.shift); goto fail2; } if (audio_pt_init (&pa->pt, qpa_thread_out, hw, AUDIO_CAP, AUDIO_FUNC)) { goto fail3; } return 0; fail3: free (pa->pcm_buf); pa->pcm_buf = NULL; fail2: pa_simple_free (pa->s); pa->s = NULL; fail1: return -1; }


static int proxy_name_to_path(FsContext *ctx, V9fsPath *dir_path, const char *name, V9fsPath *target) { if (dir_path) { v9fs_string_sprintf((V9fsString *)target, "%s/%s", dir_path->data, name); } else { v9fs_string_sprintf((V9fsString *)target, "%s", name); } /* Bump the size for including terminating NULL */ target->size++; return 0; }


static int v9fs_synth_mknod(FsContext *fs_ctx, V9fsPath *path, const char *buf, FsCred *credp) { errno = EPERM; return -1; }


static int roq_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { RoqContext *enc = avctx->priv_data; int size, ret; enc->avctx = avctx; enc->frame_to_enc = frame; if (frame->quality) enc->lambda = frame->quality - 1; else enc->lambda = 2*ROQ_LAMBDA_SCALE; /* 138 bits max per 8x8 block + * 256 codebooks*(6 bytes 2x2 + 4 bytes 4x4) + 8 bytes frame header */ size = ((enc->width * enc->height / 64) * 138 + 7) / 8 + 256 * (6 + 4) + 8; if ((ret = ff_alloc_packet(pkt, size)) < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet with size %d.\n", size); return ret; } enc->out_buf = pkt->data; /* Check for I frame */ if (enc->framesSinceKeyframe == avctx->gop_size) enc->framesSinceKeyframe = 0; if (enc->first_frame) { /* Alloc memory for the reconstruction data (we must know the stride for that) */ if (ff_get_buffer(avctx, enc->current_frame, 0) || ff_get_buffer(avctx, enc->last_frame, 0)) { av_log(avctx, AV_LOG_ERROR, " RoQ: get_buffer() failed\n"); return -1; } /* Before the first video frame, write a "video info" chunk */ roq_write_video_info_chunk(enc); enc->first_frame = 0; } /* Encode the actual frame */ roq_encode_video(enc); pkt->size = enc->out_buf - pkt->data; if (enc->framesSinceKeyframe == 1) pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; return 0; }


static int swf_write_video(AVFormatContext *s, AVCodecContext *enc, const uint8_t *buf, int size) { SWFContext *swf = s->priv_data; ByteIOContext *pb = &s->pb; int c = 0; int outSize = 0; int outSamples = 0; /* Flash Player limit */ if ( swf->swf_frame_number >= 16000 ) { return 0; } /* Store video data in queue */ if ( enc->codec_type == CODEC_TYPE_VIDEO ) { SWFFrame *new_frame = av_malloc(sizeof(SWFFrame)); new_frame->prev = 0; new_frame->next = swf->frame_head; new_frame->data = av_malloc(size); new_frame->size = size; memcpy(new_frame->data,buf,size); swf->frame_head = new_frame; if ( swf->frame_tail == 0 ) { swf->frame_tail = new_frame; } } if ( swf->audio_type ) { /* Prescan audio data for this swf frame */ retry_swf_audio_packet: if ( ( swf->audio_size-outSize ) >= 4 ) { int mp3FrameSize = 0; int mp3SampleRate = 0; int mp3IsMono = 0; int mp3SamplesPerFrame = 0; /* copy out mp3 header from ring buffer */ uint8_t header[4]; for (c=0; c<4; c++) { header[c] = swf->audio_fifo[(swf->audio_in_pos+outSize+c) % AUDIO_FIFO_SIZE]; } if ( swf_mp3_info(header,&mp3FrameSize,&mp3SamplesPerFrame,&mp3SampleRate,&mp3IsMono) ) { if ( ( swf->audio_size-outSize ) >= mp3FrameSize ) { outSize += mp3FrameSize; outSamples += mp3SamplesPerFrame; if ( ( swf->sound_samples + outSamples + swf->samples_per_frame ) < swf->video_samples ) { goto retry_swf_audio_packet; } } } else { /* invalid mp3 data, skip forward we need to do this since the Flash Player does not like custom headers */ swf->audio_in_pos ++; swf->audio_size --; swf->audio_in_pos %= AUDIO_FIFO_SIZE; goto retry_swf_audio_packet; } } /* audio stream is behind video stream, bail */ if ( ( swf->sound_samples + outSamples + swf->samples_per_frame ) < swf->video_samples ) { return 0; } /* compute audio/video drift */ if ( enc->codec_type == CODEC_TYPE_VIDEO ) { swf->skip_samples = (int)( ( (double)(swf->swf_frame_number) * (double)enc->frame_rate_base * 44100. ) / (double)(enc->frame_rate) ); swf->skip_samples -= swf->video_samples; } } /* check if we need to insert a padding frame */ if (swf->skip_samples <= ( swf->samples_per_frame / 2 ) ) { /* no, it is time for a real frame, check if one is available */ if ( swf->frame_tail ) { if ( swf->video_type == CODEC_ID_FLV1 ) { if ( swf->video_frame_number == 0 ) { /* create a new video object */ put_swf_tag(s, TAG_VIDEOSTREAM); put_le16(pb, VIDEO_ID); put_le16(pb, 15000 ); /* hard flash player limit */ put_le16(pb, enc->width); put_le16(pb, enc->height); put_byte(pb, 0); put_byte(pb, SWF_VIDEO_CODEC_FLV1); put_swf_end_tag(s); /* place the video object for the first time */ put_swf_tag(s, TAG_PLACEOBJECT2); put_byte(pb, 0x36); put_le16(pb, 1); put_le16(pb, VIDEO_ID); put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0); put_le16(pb, swf->video_frame_number ); put_byte(pb, 'v'); put_byte(pb, 'i'); put_byte(pb, 'd'); put_byte(pb, 'e'); put_byte(pb, 'o'); put_byte(pb, 0x00); put_swf_end_tag(s); } else { /* mark the character for update */ put_swf_tag(s, TAG_PLACEOBJECT2); put_byte(pb, 0x11); put_le16(pb, 1); put_le16(pb, swf->video_frame_number ); put_swf_end_tag(s); } // write out pending frames for (; ( enc->frame_number - swf->video_frame_number ) > 0;) { /* set video frame data */ put_swf_tag(s, TAG_VIDEOFRAME | TAG_LONG); put_le16(pb, VIDEO_ID); put_le16(pb, swf->video_frame_number++ ); put_buffer(pb, swf->frame_tail->data, swf->frame_tail->size); put_swf_end_tag(s); } } else if ( swf->video_type == CODEC_ID_MJPEG ) { if (swf->swf_frame_number > 0) { /* remove the shape */ put_swf_tag(s, TAG_REMOVEOBJECT); put_le16(pb, SHAPE_ID); /* shape ID */ put_le16(pb, 1); /* depth */ put_swf_end_tag(s); /* free the bitmap */ put_swf_tag(s, TAG_FREECHARACTER); put_le16(pb, BITMAP_ID); put_swf_end_tag(s); } put_swf_tag(s, TAG_JPEG2 | TAG_LONG); put_le16(pb, BITMAP_ID); /* ID of the image */ /* a dummy jpeg header seems to be required */ put_byte(pb, 0xff); put_byte(pb, 0xd8); put_byte(pb, 0xff); put_byte(pb, 0xd9); /* write the jpeg image */ put_buffer(pb, swf->frame_tail->data, swf->frame_tail->size); put_swf_end_tag(s); /* draw the shape */ put_swf_tag(s, TAG_PLACEOBJECT); put_le16(pb, SHAPE_ID); /* shape ID */ put_le16(pb, 1); /* depth */ put_swf_matrix(pb, 20 << FRAC_BITS, 0, 0, 20 << FRAC_BITS, 0, 0); put_swf_end_tag(s); } else { /* invalid codec */ } av_free(swf->frame_tail->data); swf->frame_tail = swf->frame_tail->prev; if ( swf->frame_tail ) { if ( swf->frame_tail->next ) { av_free(swf->frame_tail->next); } swf->frame_tail->next = 0; } else { swf->frame_head = 0; } swf->swf_frame_number ++; } } swf->video_samples += swf->samples_per_frame; /* streaming sound always should be placed just before showframe tags */ if ( outSize > 0 ) { put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG); put_le16(pb, outSamples); put_le16(pb, 0); for (c=0; c<outSize; c++) { put_byte(pb,swf->audio_fifo[(swf->audio_in_pos+c) % AUDIO_FIFO_SIZE]); } put_swf_end_tag(s); /* update FIFO */ swf->sound_samples += outSamples; swf->audio_in_pos += outSize; swf->audio_size -= outSize; swf->audio_in_pos %= AUDIO_FIFO_SIZE; } /* output the frame */ put_swf_tag(s, TAG_SHOWFRAME); put_swf_end_tag(s); put_flush_packet(&s->pb); return 0; }


static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, int buf_size, AVCodecContext *avctx) { HEVCParserContext *ctx = s->priv_data; int ret, i; ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0, AV_CODEC_ID_HEVC); if (ret < 0) return ret; for (i = 0; i < ctx->pkt.nb_nals; i++) { H2645NAL *nal = &ctx->pkt.nals[i]; /* ignore everything except parameter sets and VCL NALUs */ switch (nal->type) { case NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, avctx, &ctx->ps); break; case NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, avctx, &ctx->ps, 1); break; case NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, avctx, &ctx->ps); break; case NAL_TRAIL_R: case NAL_TRAIL_N: case NAL_TSA_N: case NAL_TSA_R: case NAL_STSA_N: case NAL_STSA_R: case NAL_BLA_W_LP: case NAL_BLA_W_RADL: case NAL_BLA_N_LP: case NAL_IDR_W_RADL: case NAL_IDR_N_LP: case NAL_CRA_NUT: case NAL_RADL_N: case NAL_RADL_R: case NAL_RASL_N: case NAL_RASL_R: if (buf == avctx->extradata) { av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type); return AVERROR_INVALIDDATA; } hevc_parse_slice_header(s, nal, avctx); break; } } return 0; }


static int get_channel_idx(char **map, int *ch, char delim, int max_ch) { char *next = split(*map, delim); int len; int n = 0; if (!next && delim == '-') return AVERROR(EINVAL); if (!*map) return AVERROR(EINVAL); len = strlen(*map); sscanf(*map, "%d%n", ch, &n); if (n != len) return AVERROR(EINVAL); if (*ch < 0 || *ch > max_ch) return AVERROR(EINVAL); *map = next; return 0; }


static int decode_residual_block(AVSContext *h, GetBitContext *gb, const struct dec_2dvlc *r, int esc_golomb_order, int qp, uint8_t *dst, int stride) { int i, level_code, esc_code, level, run, mask; DCTELEM level_buf[65]; uint8_t run_buf[65]; DCTELEM *block = h->block; for(i=0;i<65;i++) { level_code = get_ue_code(gb,r->golomb_order); if(level_code >= ESCAPE_CODE) { run = ((level_code - ESCAPE_CODE) >> 1) + 1; esc_code = get_ue_code(gb,esc_golomb_order); level = esc_code + (run > r->max_run ? 1 : r->level_add[run]); while(level > r->inc_limit) r++; mask = -(level_code & 1); level = (level^mask) - mask; } else { level = r->rltab[level_code][0]; if(!level) //end of block signal break; run = r->rltab[level_code][1]; r += r->rltab[level_code][2]; } level_buf[i] = level; run_buf[i] = run; } if(dequant(h,level_buf, run_buf, block, ff_cavs_dequant_mul[qp], ff_cavs_dequant_shift[qp], i)) return -1; h->cdsp.cavs_idct8_add(dst,block,stride); h->s.dsp.clear_block(block); return 0; }


static void device_set_hotplugged(Object *obj, bool value, Error **err) { DeviceState *dev = DEVICE(obj); dev->hotplugged = value; }


static void mips_fulong2e_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; char *filename; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios = g_new(MemoryRegion, 1); long bios_size; int64_t kernel_entry; qemu_irq *i8259; qemu_irq *cpu_exit_irq; PCIBus *pci_bus; ISABus *isa_bus; I2CBus *smbus; int i; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; MIPSCPU *cpu; CPUMIPSState *env; /* init CPUs */ if (cpu_model == NULL) { cpu_model = "Loongson-2E"; } cpu = cpu_mips_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } env = &cpu->env; qemu_register_reset(main_cpu_reset, cpu); /* fulong 2e has 256M ram. */ ram_size = 256 * 1024 * 1024; /* fulong 2e has a 1M flash.Winbond W39L040AP70Z */ bios_size = 1024 * 1024; /* allocate RAM */ memory_region_init_ram(ram, NULL, "fulong2e.ram", ram_size, &error_abort); vmstate_register_ram_global(ram); memory_region_init_ram(bios, NULL, "fulong2e.bios", bios_size, &error_abort); vmstate_register_ram_global(bios); memory_region_set_readonly(bios, true); memory_region_add_subregion(address_space_mem, 0, ram); memory_region_add_subregion(address_space_mem, 0x1fc00000LL, bios); /* We do not support flash operation, just loading pmon.bin as raw BIOS. * Please use -L to set the BIOS path and -bios to set bios name. */ if (kernel_filename) { loaderparams.ram_size = ram_size; loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; kernel_entry = load_kernel (env); write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry); } else { if (bios_name == NULL) { bios_name = FULONG_BIOSNAME; } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image_targphys(filename, 0x1fc00000LL, BIOS_SIZE); g_free(filename); } else { bios_size = -1; } if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename && !qtest_enabled()) { error_report("Could not load MIPS bios '%s'", bios_name); exit(1); } } /* Init internal devices */ cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); /* North bridge, Bonito --> IP2 */ pci_bus = bonito_init((qemu_irq *)&(env->irq[2])); /* South bridge */ ide_drive_get(hd, MAX_IDE_BUS); isa_bus = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0)); if (!isa_bus) { fprintf(stderr, "vt82c686b_init error\n"); exit(1); } /* Interrupt controller */ /* The 8259 -> IP5 */ i8259 = i8259_init(isa_bus, env->irq[5]); isa_bus_irqs(isa_bus, i8259); vt82c686b_ide_init(pci_bus, hd, PCI_DEVFN(FULONG2E_VIA_SLOT, 1)); pci_create_simple(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 2), "vt82c686b-usb-uhci"); pci_create_simple(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 3), "vt82c686b-usb-uhci"); smbus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 4), 0xeee1, NULL); /* TODO: Populate SPD eeprom data. */ smbus_eeprom_init(smbus, 1, eeprom_spd, sizeof(eeprom_spd)); /* init other devices */ pit = pit_init(isa_bus, 0x40, 0, NULL); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); /* Super I/O */ isa_create_simple(isa_bus, "i8042"); rtc_init(isa_bus, 2000, NULL); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_isa_init(isa_bus, i, serial_hds[i]); } } if (parallel_hds[0]) { parallel_init(isa_bus, 0, parallel_hds[0]); } /* Sound card */ audio_init(pci_bus); /* Network card */ network_init(pci_bus); }


static int pcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { PCMDecode *s = avctx->priv_data; int n; short *samples; uint8_t *src; samples = data; src = buf; switch(avctx->codec->id) { case CODEC_ID_PCM_S16LE: n = buf_size >> 1; for(;n>0;n--) { *samples++ = src[0] | (src[1] << 8); src += 2; } break; case CODEC_ID_PCM_S16BE: n = buf_size >> 1; for(;n>0;n--) { *samples++ = (src[0] << 8) | src[1]; src += 2; } break; case CODEC_ID_PCM_U16LE: n = buf_size >> 1; for(;n>0;n--) { *samples++ = (src[0] | (src[1] << 8)) - 0x8000; src += 2; } break; case CODEC_ID_PCM_U16BE: n = buf_size >> 1; for(;n>0;n--) { *samples++ = ((src[0] << 8) | src[1]) - 0x8000; src += 2; } break; case CODEC_ID_PCM_S8: n = buf_size; for(;n>0;n--) { *samples++ = src[0] << 8; src++; } break; case CODEC_ID_PCM_U8: n = buf_size; for(;n>0;n--) { *samples++ = ((int)src[0] - 128) << 8; src++; } break; case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: n = buf_size; for(;n>0;n--) { *samples++ = s->table[src[0]]; src++; } break; default: return -1; } *data_size = (uint8_t *)samples - (uint8_t *)data; return src - buf; }


void FUNCC(ff_h264_idct8_dc_add)(uint8_t *_dst, int16_t *block, int stride){ int i, j; int dc = (((dctcoef*)block)[0] + 32) >> 6; pixel *dst = (pixel*)_dst; stride >>= sizeof(pixel)-1; for( j = 0; j < 8; j++ ) { for( i = 0; i < 8; i++ ) dst[i] = av_clip_pixel( dst[i] + dc ); dst += stride; } }


static int colo_packet_compare_other(Packet *spkt, Packet *ppkt) { trace_colo_compare_main("compare other"); if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) { char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20]; strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src)); strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst)); strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src)); strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst)); trace_colo_compare_ip_info(ppkt->size, pri_ip_src, pri_ip_dst, spkt->size, sec_ip_src, sec_ip_dst); } return colo_packet_compare_common(ppkt, spkt, 0); }


void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs, int64_t speed, BlockCompletionFunc *cb, void *opaque, Error **errp) { BlockBackend *blk; BlockJob *job; assert(cb); if (bs->job) { error_setg(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs)); return NULL; } blk = blk_new(); blk_insert_bs(blk, bs); job = g_malloc0(driver->instance_size); error_setg(&job->blocker, "block device is in use by block job: %s", BlockJobType_lookup[driver->job_type]); bdrv_op_block_all(bs, job->blocker); bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker); job->driver = driver; job->id = g_strdup(bdrv_get_device_name(bs)); job->blk = blk; job->cb = cb; job->opaque = opaque; job->busy = true; job->refcnt = 1; bs->job = job; QLIST_INSERT_HEAD(&block_jobs, job, job_list); blk_add_aio_context_notifier(blk, block_job_attached_aio_context, block_job_detach_aio_context, job); /* Only set speed when necessary to avoid NotSupported error */ if (speed != 0) { Error *local_err = NULL; block_job_set_speed(job, speed, &local_err); if (local_err) { block_job_unref(job); error_propagate(errp, local_err); return NULL; } } return job; }


static int pxa2xx_ssp_load(QEMUFile *f, void *opaque, int version_id) { PXA2xxSSPState *s = (PXA2xxSSPState *) opaque; int i; s->enable = qemu_get_be32(f); qemu_get_be32s(f, &s->sscr[0]); qemu_get_be32s(f, &s->sscr[1]); qemu_get_be32s(f, &s->sspsp); qemu_get_be32s(f, &s->ssto); qemu_get_be32s(f, &s->ssitr); qemu_get_be32s(f, &s->sssr); qemu_get_8s(f, &s->sstsa); qemu_get_8s(f, &s->ssrsa); qemu_get_8s(f, &s->ssacd); s->rx_level = qemu_get_byte(f); s->rx_start = 0; for (i = 0; i < s->rx_level; i ++) s->rx_fifo[i] = qemu_get_byte(f); return 0; }


static void truncpasses(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile) { int precno, compno, reslevelno, bandno, cblkno, lev; Jpeg2000CodingStyle *codsty = &s->codsty; for (compno = 0; compno < s->ncomponents; compno++){ Jpeg2000Component *comp = tile->comp + compno; for (reslevelno = 0, lev = codsty->nreslevels-1; reslevelno < codsty->nreslevels; reslevelno++, lev--){ Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno; for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){ for (bandno = 0; bandno < reslevel->nbands ; bandno++){ int bandpos = bandno + (reslevelno > 0); Jpeg2000Band *band = reslevel->band + bandno; Jpeg2000Prec *prec = band->prec + precno; for (cblkno = 0; cblkno < prec->nb_codeblocks_height * prec->nb_codeblocks_width; cblkno++){ Jpeg2000Cblk *cblk = prec->cblk + cblkno; cblk->ninclpasses = getcut(cblk, s->lambda, (int64_t)dwt_norms[codsty->transform == FF_DWT53][bandpos][lev] * (int64_t)band->i_stepsize >> 16); } } } } } }


static void gen_rfdi(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } /* Restore CPU state */ gen_helper_rfdi(cpu_env); gen_sync_exception(ctx); #endif }


void ide_data_writel(void *opaque, uint32_t addr, uint32_t val) { IDEBus *bus = opaque; IDEState *s = idebus_active_if(bus); uint8_t *p; /* PIO data access allowed only when DRQ bit is set. The result of a write * during PIO out is indeterminate, just ignore it. */ if (!(s->status & DRQ_STAT) || ide_is_pio_out(s)) { p = s->data_ptr; *(uint32_t *)p = le32_to_cpu(val); p += 4; s->data_ptr = p; if (p >= s->data_end) s->end_transfer_func(s);


void OPPROTO op_addo (void) { do_addo(); RETURN(); }


static bool run_poll_handlers_once(AioContext *ctx) { bool progress = false; AioHandler *node; QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) { if (!node->deleted && node->io_poll && node->io_poll(node->opaque)) { progress = true; } /* Caller handles freeing deleted nodes. Don't do it here. */ } return progress; }


static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { MpegEncContext * const s = &h->s; const int mb_xy= mb_x + mb_y*s->mb_stride; const int mb_type = s->current_picture.mb_type[mb_xy]; const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4; int first_vertical_edge_done = 0; int dir; /* FIXME: A given frame may occupy more than one position in * the reference list. So ref2frm should be populated with * frame numbers, not indices. */ static const int ref2frm[34] = {-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; //for sufficiently low qp, filtering wouldn't do anything //this is a conservative estimate: could also check beta_offset and more accurate chroma_qp if(!FRAME_MBAFF){ int qp_thresh = 15 - h->slice_alpha_c0_offset - FFMAX(0, h->pps.chroma_qp_index_offset); int qp = s->current_picture.qscale_table[mb_xy]; if(qp <= qp_thresh && (mb_x == 0 || ((qp + s->current_picture.qscale_table[mb_xy-1] + 1)>>1) <= qp_thresh) && (mb_y == 0 || ((qp + s->current_picture.qscale_table[h->top_mb_xy] + 1)>>1) <= qp_thresh)){ return; } } if (FRAME_MBAFF // left mb is in picture && h->slice_table[mb_xy-1] != 255 // and current and left pair do not have the same interlaced type && (IS_INTERLACED(mb_type) != IS_INTERLACED(s->current_picture.mb_type[mb_xy-1])) // and left mb is in the same slice if deblocking_filter == 2 && (h->deblocking_filter!=2 || h->slice_table[mb_xy-1] == h->slice_table[mb_xy])) { /* First vertical edge is different in MBAFF frames * There are 8 different bS to compute and 2 different Qp */ const int pair_xy = mb_x + (mb_y&~1)*s->mb_stride; const int left_mb_xy[2] = { pair_xy-1, pair_xy-1+s->mb_stride }; int16_t bS[8]; int qp[2]; int chroma_qp[2]; int mb_qp, mbn0_qp, mbn1_qp; int i; first_vertical_edge_done = 1; if( IS_INTRA(mb_type) ) bS[0] = bS[1] = bS[2] = bS[3] = bS[4] = bS[5] = bS[6] = bS[7] = 4; else { for( i = 0; i < 8; i++ ) { int mbn_xy = MB_FIELD ? left_mb_xy[i>>2] : left_mb_xy[i&1]; if( IS_INTRA( s->current_picture.mb_type[mbn_xy] ) ) bS[i] = 4; else if( h->non_zero_count_cache[12+8*(i>>1)] != 0 || /* FIXME: with 8x8dct + cavlc, should check cbp instead of nnz */ h->non_zero_count[mbn_xy][MB_FIELD ? i&3 : (i>>2)+(mb_y&1)*2] ) bS[i] = 2; else bS[i] = 1; } } mb_qp = s->current_picture.qscale_table[mb_xy]; mbn0_qp = s->current_picture.qscale_table[left_mb_xy[0]]; mbn1_qp = s->current_picture.qscale_table[left_mb_xy[1]]; qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1; chroma_qp[0] = ( get_chroma_qp( h, mb_qp ) + get_chroma_qp( h, mbn0_qp ) + 1 ) >> 1; qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1; chroma_qp[1] = ( get_chroma_qp( h, mb_qp ) + get_chroma_qp( h, mbn1_qp ) + 1 ) >> 1; /* Filter edge */ tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPc:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], chroma_qp[0], chroma_qp[1], linesize, uvlinesize); { int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } filter_mb_mbaff_edgev ( h, &img_y [0], linesize, bS, qp ); filter_mb_mbaff_edgecv( h, &img_cb[0], uvlinesize, bS, chroma_qp ); filter_mb_mbaff_edgecv( h, &img_cr[0], uvlinesize, bS, chroma_qp ); } /* dir : 0 -> vertical edge, 1 -> horizontal edge */ for( dir = 0; dir < 2; dir++ ) { int edge; const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; const int mbm_type = s->current_picture.mb_type[mbm_xy]; int start = h->slice_table[mbm_xy] == 255 ? 1 : 0; const int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP)) == (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4; // how often to recheck mv-based bS when iterating between edges const int mask_edge = (mb_type & (MB_TYPE_16x16 | (MB_TYPE_16x8 << dir))) ? 3 : (mb_type & (MB_TYPE_8x16 >> dir)) ? 1 : 0; // how often to recheck mv-based bS when iterating along each edge const int mask_par0 = mb_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)); if (first_vertical_edge_done) { start = 1; first_vertical_edge_done = 0; } if (h->deblocking_filter==2 && h->slice_table[mbm_xy] != h->slice_table[mb_xy]) start = 1; if (FRAME_MBAFF && (dir == 1) && ((mb_y&1) == 0) && start == 0 && !IS_INTERLACED(mb_type) && IS_INTERLACED(mbm_type) ) { // This is a special case in the norm where the filtering must // be done twice (one each of the field) even if we are in a // frame macroblock. // static const int nnz_idx[4] = {4,5,6,3}; unsigned int tmp_linesize = 2 * linesize; unsigned int tmp_uvlinesize = 2 * uvlinesize; int mbn_xy = mb_xy - 2 * s->mb_stride; int qp, chroma_qp; int i, j; int16_t bS[4]; for(j=0; j<2; j++, mbn_xy += s->mb_stride){ if( IS_INTRA(mb_type) || IS_INTRA(s->current_picture.mb_type[mbn_xy]) ) { bS[0] = bS[1] = bS[2] = bS[3] = 3; } else { const uint8_t *mbn_nnz = h->non_zero_count[mbn_xy]; for( i = 0; i < 4; i++ ) { if( h->non_zero_count_cache[scan8[0]+i] != 0 || mbn_nnz[nnz_idx[i]] != 0 ) bS[i] = 2; else bS[i] = 1; } } // Do not use s->qscale as luma quantizer because it has not the same // value in IPCM macroblocks. qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize); { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } filter_mb_edgeh( h, &img_y[j*linesize], tmp_linesize, bS, qp ); chroma_qp = ( h->chroma_qp + get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1; filter_mb_edgech( h, &img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp ); filter_mb_edgech( h, &img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp ); } start = 1; } /* Calculate bS */ for( edge = start; edge < edges; edge++ ) { /* mbn_xy: neighbor macroblock */ const int mbn_xy = edge > 0 ? mb_xy : mbm_xy; const int mbn_type = s->current_picture.mb_type[mbn_xy]; int16_t bS[4]; int qp; if( (edge&1) && IS_8x8DCT(mb_type) ) continue; if( IS_INTRA(mb_type) || IS_INTRA(mbn_type) ) { int value; if (edge == 0) { if ( (!IS_INTERLACED(mb_type) && !IS_INTERLACED(mbm_type)) || ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (dir == 0)) ) { value = 4; } else { value = 3; } } else { value = 3; } bS[0] = bS[1] = bS[2] = bS[3] = value; } else { int i, l; int mv_done; if( edge & mask_edge ) { bS[0] = bS[1] = bS[2] = bS[3] = 0; mv_done = 1; } else if( FRAME_MBAFF && IS_INTERLACED(mb_type ^ mbn_type)) { bS[0] = bS[1] = bS[2] = bS[3] = 1; mv_done = 1; } else if( mask_par0 && (edge || (mbn_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) { int b_idx= 8 + 4 + edge * (dir ? 8:1); int bn_idx= b_idx - (dir ? 8:1); int v = 0; for( l = 0; !v && l < 1 + (h->slice_type == B_TYPE); l++ ) { v |= ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] || FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit; } bS[0] = bS[1] = bS[2] = bS[3] = v; mv_done = 1; } else mv_done = 0; for( i = 0; i < 4; i++ ) { int x = dir == 0 ? edge : i; int y = dir == 0 ? i : edge; int b_idx= 8 + 4 + x + 8*y; int bn_idx= b_idx - (dir ? 8:1); if( h->non_zero_count_cache[b_idx] != 0 || h->non_zero_count_cache[bn_idx] != 0 ) { bS[i] = 2; } else if(!mv_done) { bS[i] = 0; for( l = 0; l < 1 + (h->slice_type == B_TYPE); l++ ) { if( ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] || FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit ) { bS[i] = 1; break; } } } } if(bS[0]+bS[1]+bS[2]+bS[3] == 0) continue; } /* Filter edge */ // Do not use s->qscale as luma quantizer because it has not the same // value in IPCM macroblocks. qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; //tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp, s->current_picture.qscale_table[mbn_xy]); tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize); { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } if( dir == 0 ) { filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp ); if( (edge&1) == 0 ) { int chroma_qp = ( h->chroma_qp + get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1; filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, chroma_qp ); filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, chroma_qp ); } } else { filter_mb_edgeh( h, &img_y[4*edge*linesize], linesize, bS, qp ); if( (edge&1) == 0 ) { int chroma_qp = ( h->chroma_qp + get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1; filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, chroma_qp ); filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, chroma_qp ); } } } } }


static void select_frame(AVFilterContext *ctx, AVFrame *frame) { SelectContext *select = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; double res; if (isnan(select->var_values[VAR_START_PTS])) select->var_values[VAR_START_PTS] = TS2D(frame->pts); if (isnan(select->var_values[VAR_START_T])) select->var_values[VAR_START_T] = TS2D(frame->pts) * av_q2d(inlink->time_base); select->var_values[VAR_N ] = inlink->frame_count; select->var_values[VAR_PTS] = TS2D(frame->pts); select->var_values[VAR_T ] = TS2D(frame->pts) * av_q2d(inlink->time_base); select->var_values[VAR_POS] = av_frame_get_pkt_pos(frame) == -1 ? NAN : av_frame_get_pkt_pos(frame); switch (inlink->type) { case AVMEDIA_TYPE_AUDIO: select->var_values[VAR_SAMPLES_N] = frame->nb_samples; break; case AVMEDIA_TYPE_VIDEO: select->var_values[VAR_INTERLACE_TYPE] = !frame->interlaced_frame ? INTERLACE_TYPE_P : frame->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B; select->var_values[VAR_PICT_TYPE] = frame->pict_type; #if CONFIG_AVCODEC if (select->do_scene_detect) { char buf[32]; select->var_values[VAR_SCENE] = get_scene_score(ctx, frame); // TODO: document metadata snprintf(buf, sizeof(buf), "%f", select->var_values[VAR_SCENE]); av_dict_set(avpriv_frame_get_metadatap(frame), "lavfi.scene_score", buf, 0); } #endif break; } select->select = res = av_expr_eval(select->expr, select->var_values, NULL); av_log(inlink->dst, AV_LOG_DEBUG, "n:%f pts:%f t:%f key:%d", select->var_values[VAR_N], select->var_values[VAR_PTS], select->var_values[VAR_T], (int)select->var_values[VAR_KEY]); switch (inlink->type) { case AVMEDIA_TYPE_VIDEO: av_log(inlink->dst, AV_LOG_DEBUG, " interlace_type:%c pict_type:%c scene:%f", select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_P ? 'P' : select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_T ? 'T' : select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_B ? 'B' : '?', av_get_picture_type_char(select->var_values[VAR_PICT_TYPE]), select->var_values[VAR_SCENE]); break; case AVMEDIA_TYPE_AUDIO: av_log(inlink->dst, AV_LOG_DEBUG, " samples_n:%d consumed_samples_n:%d", (int)select->var_values[VAR_SAMPLES_N], (int)select->var_values[VAR_CONSUMED_SAMPLES_N]); break; } if (res == 0) { select->select_out = -1; /* drop */ } else if (isnan(res) || res < 0) { select->select_out = 0; /* first output */ } else { select->select_out = FFMIN(ceilf(res)-1, select->nb_outputs-1); /* other outputs */ } av_log(inlink->dst, AV_LOG_DEBUG, " -> select:%f select_out:%d\n", res, select->select_out); if (res) { select->var_values[VAR_PREV_SELECTED_N] = select->var_values[VAR_N]; select->var_values[VAR_PREV_SELECTED_PTS] = select->var_values[VAR_PTS]; select->var_values[VAR_PREV_SELECTED_T] = select->var_values[VAR_T]; select->var_values[VAR_SELECTED_N] += 1.0; if (inlink->type == AVMEDIA_TYPE_AUDIO) select->var_values[VAR_CONSUMED_SAMPLES_N] += frame->nb_samples; } select->var_values[VAR_PREV_PTS] = select->var_values[VAR_PTS]; select->var_values[VAR_PREV_T] = select->var_values[VAR_T]; }


static int libkvazaar_encode(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { int retval = 0; kvz_picture *img_in = NULL; kvz_data_chunk *data_out = NULL; uint32_t len_out = 0; kvz_frame_info frame_info; LibkvazaarContext *ctx = avctx->priv_data; *got_packet_ptr = 0; if (frame) { int i = 0; av_assert0(frame->width == ctx->config->width); av_assert0(frame->height == ctx->config->height); av_assert0(frame->format == avctx->pix_fmt); // Allocate input picture for kvazaar. img_in = ctx->api->picture_alloc(frame->width, frame->height); if (!img_in) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate picture.\n"); retval = AVERROR(ENOMEM); goto done; } // Copy pixels from frame to img_in. for (i = 0; i < 3; ++i) { uint8_t *dst = img_in->data[i]; uint8_t *src = frame->data[i]; int width = (i == 0) ? frame->width : (frame->width / 2); int height = (i == 0) ? frame->height : (frame->height / 2); int y = 0; for (y = 0; y < height; ++y) { memcpy(dst, src, width); src += frame->linesize[i]; dst += width; } } } if (!ctx->api->encoder_encode(ctx->encoder, img_in, &data_out, &len_out, NULL, NULL, &frame_info)) { av_log(avctx, AV_LOG_ERROR, "Failed to encode frame.\n"); retval = AVERROR_EXTERNAL; goto done; } if (data_out) { kvz_data_chunk *chunk = NULL; uint64_t written = 0; retval = ff_alloc_packet(avpkt, len_out); if (retval < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n"); goto done; } for (chunk = data_out; chunk != NULL; chunk = chunk->next) { av_assert0(written + chunk->len <= len_out); memcpy(avpkt->data + written, chunk->data, chunk->len); written += chunk->len; } *got_packet_ptr = 1; ctx->api->chunk_free(data_out); data_out = NULL; avpkt->flags = 0; // IRAP VCL NAL unit types span the range // [BLA_W_LP (16), RSV_IRAP_VCL23 (23)]. if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP && frame_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) { avpkt->flags |= AV_PKT_FLAG_KEY; } } done: ctx->api->picture_free(img_in); ctx->api->chunk_free(data_out); return retval; }


static int send_extradata(APNGDemuxContext *ctx, AVPacket *pkt) { if (!ctx->extra_data_updated) { uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, ctx->extra_data_size); if (!side_data) return AVERROR(ENOMEM); memcpy(side_data, ctx->extra_data, ctx->extra_data_size); ctx->extra_data_updated = 1; } return 0; }


static void vga_mm_init(VGAState *s, target_phys_addr_t vram_base, target_phys_addr_t ctrl_base, int it_shift) { int s_ioport_ctrl, vga_io_memory; s->it_shift = it_shift; s_ioport_ctrl = cpu_register_io_memory(0, vga_mm_read_ctrl, vga_mm_write_ctrl, s); vga_io_memory = cpu_register_io_memory(0, vga_mem_read, vga_mem_write, s); register_savevm("vga", 0, 2, vga_save, vga_load, s); cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl); s->bank_offset = 0; cpu_register_physical_memory(vram_base + 0x000a0000, 0x20000, vga_io_memory); }


TranslationBlock *tb_gen_code(CPUState *cpu, target_ulong pc, target_ulong cs_base, uint32_t flags, int cflags) { CPUArchState *env = cpu->env_ptr; TranslationBlock *tb; tb_page_addr_t phys_pc, phys_page2; target_ulong virt_page2; tcg_insn_unit *gen_code_buf; int gen_code_size, search_size; #ifdef CONFIG_PROFILER int64_t ti; #endif assert_memory_lock(); phys_pc = get_page_addr_code(env, pc); if (use_icount && !(cflags & CF_IGNORE_ICOUNT)) { cflags |= CF_USE_ICOUNT; } tb = tb_alloc(pc); if (unlikely(!tb)) { buffer_overflow: /* flush must be done */ tb_flush(cpu); mmap_unlock(); /* Make the execution loop process the flush as soon as possible. */ cpu->exception_index = EXCP_INTERRUPT; cpu_loop_exit(cpu); } gen_code_buf = tcg_ctx.code_gen_ptr; tb->tc_ptr = gen_code_buf; tb->pc = pc; tb->cs_base = cs_base; tb->flags = flags; tb->cflags = cflags; tb->trace_vcpu_dstate = *cpu->trace_dstate; tb->invalid = false; #ifdef CONFIG_PROFILER tcg_ctx.tb_count1++; /* includes aborted translations because of exceptions */ ti = profile_getclock(); #endif tcg_func_start(&tcg_ctx); tcg_ctx.cpu = ENV_GET_CPU(env); gen_intermediate_code(cpu, tb); tcg_ctx.cpu = NULL; trace_translate_block(tb, tb->pc, tb->tc_ptr); /* generate machine code */ tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID; tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID; tcg_ctx.tb_jmp_reset_offset = tb->jmp_reset_offset; if (TCG_TARGET_HAS_direct_jump) { tcg_ctx.tb_jmp_insn_offset = tb->jmp_target_arg; tcg_ctx.tb_jmp_target_addr = NULL; } else { tcg_ctx.tb_jmp_insn_offset = NULL; tcg_ctx.tb_jmp_target_addr = tb->jmp_target_arg; } #ifdef CONFIG_PROFILER tcg_ctx.tb_count++; tcg_ctx.interm_time += profile_getclock() - ti; tcg_ctx.code_time -= profile_getclock(); #endif /* ??? Overflow could be handled better here. In particular, we don't need to re-do gen_intermediate_code, nor should we re-do the tcg optimization currently hidden inside tcg_gen_code. All that should be required is to flush the TBs, allocate a new TB, re-initialize it per above, and re-do the actual code generation. */ gen_code_size = tcg_gen_code(&tcg_ctx, tb); if (unlikely(gen_code_size < 0)) { goto buffer_overflow; } search_size = encode_search(tb, (void *)gen_code_buf + gen_code_size); if (unlikely(search_size < 0)) { goto buffer_overflow; } #ifdef CONFIG_PROFILER tcg_ctx.code_time += profile_getclock(); tcg_ctx.code_in_len += tb->size; tcg_ctx.code_out_len += gen_code_size; tcg_ctx.search_out_len += search_size; #endif #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) && qemu_log_in_addr_range(tb->pc)) { qemu_log_lock(); qemu_log("OUT: [size=%d]\n", gen_code_size); if (tcg_ctx.data_gen_ptr) { size_t code_size = tcg_ctx.data_gen_ptr - tb->tc_ptr; size_t data_size = gen_code_size - code_size; size_t i; log_disas(tb->tc_ptr, code_size); for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { if (sizeof(tcg_target_ulong) == 8) { qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n", (uintptr_t)tcg_ctx.data_gen_ptr + i, *(uint64_t *)(tcg_ctx.data_gen_ptr + i)); } else { qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n", (uintptr_t)tcg_ctx.data_gen_ptr + i, *(uint32_t *)(tcg_ctx.data_gen_ptr + i)); } } } else { log_disas(tb->tc_ptr, gen_code_size); } qemu_log("\n"); qemu_log_flush(); qemu_log_unlock(); } #endif tcg_ctx.code_gen_ptr = (void *) ROUND_UP((uintptr_t)gen_code_buf + gen_code_size + search_size, CODE_GEN_ALIGN); /* init jump list */ assert(((uintptr_t)tb & 3) == 0); tb->jmp_list_first = (uintptr_t)tb | 2; tb->jmp_list_next[0] = (uintptr_t)NULL; tb->jmp_list_next[1] = (uintptr_t)NULL; /* init original jump addresses wich has been set during tcg_gen_code() */ if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) { tb_reset_jump(tb, 0); } if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) { tb_reset_jump(tb, 1); } /* check next page if needed */ virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK; phys_page2 = -1; if ((pc & TARGET_PAGE_MASK) != virt_page2) { phys_page2 = get_page_addr_code(env, virt_page2); } /* As long as consistency of the TB stuff is provided by tb_lock in user * mode and is implicit in single-threaded softmmu emulation, no explicit * memory barrier is required before tb_link_page() makes the TB visible * through the physical hash table and physical page list. */ tb_link_page(tb, phys_pc, phys_page2); return tb; }


static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2, TCGv addr, int size) { TCGv tmp; int done_label; int fail_label; /* if (env->exclusive_addr == addr && env->exclusive_val == [addr]) { [addr] = {Rt}; {Rd} = 0; } else { {Rd} = 1; } */ fail_label = gen_new_label(); done_label = gen_new_label(); tcg_gen_brcond_i32(TCG_COND_NE, addr, cpu_exclusive_addr, fail_label); switch (size) { case 0: tmp = gen_ld8u(addr, IS_USER(s)); break; case 1: tmp = gen_ld16u(addr, IS_USER(s)); break; case 2: case 3: tmp = gen_ld32(addr, IS_USER(s)); break; default: abort(); } tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_val, fail_label); dead_tmp(tmp); if (size == 3) { TCGv tmp2 = new_tmp(); tcg_gen_addi_i32(tmp2, addr, 4); tmp = gen_ld32(tmp2, IS_USER(s)); dead_tmp(tmp2); tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_high, fail_label); dead_tmp(tmp); } tmp = load_reg(s, rt); switch (size) { case 0: gen_st8(tmp, addr, IS_USER(s)); break; case 1: gen_st16(tmp, addr, IS_USER(s)); break; case 2: case 3: gen_st32(tmp, addr, IS_USER(s)); break; default: abort(); } if (size == 3) { tcg_gen_addi_i32(addr, addr, 4); tmp = load_reg(s, rt2); gen_st32(tmp, addr, IS_USER(s)); } tcg_gen_movi_i32(cpu_R[rd], 0); tcg_gen_br(done_label); gen_set_label(fail_label); tcg_gen_movi_i32(cpu_R[rd], 1); gen_set_label(done_label); tcg_gen_movi_i32(cpu_exclusive_addr, -1); }


static void syborg_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env; qemu_irq *cpu_pic; qemu_irq pic[64]; ram_addr_t ram_addr; DeviceState *dev; int i; if (!cpu_model) cpu_model = "cortex-a8"; env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } /* RAM at address zero. */ ram_addr = qemu_ram_alloc(ram_size); cpu_register_physical_memory(0, ram_size, ram_addr | IO_MEM_RAM); cpu_pic = arm_pic_init_cpu(env); dev = sysbus_create_simple("syborg,interrupt", 0xC0000000, cpu_pic[ARM_PIC_CPU_IRQ]); for (i = 0; i < 64; i++) { pic[i] = qdev_get_gpio_in(dev, i); } sysbus_create_simple("syborg,rtc", 0xC0001000, NULL); dev = qdev_create(NULL, "syborg,timer"); qdev_prop_set_uint32(dev, "frequency", 1000000); qdev_init(dev); sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xC0002000); sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[1]); sysbus_create_simple("syborg,keyboard", 0xC0003000, pic[2]); sysbus_create_simple("syborg,pointer", 0xC0004000, pic[3]); sysbus_create_simple("syborg,framebuffer", 0xC0005000, pic[4]); sysbus_create_simple("syborg,serial", 0xC0006000, pic[5]); sysbus_create_simple("syborg,serial", 0xC0007000, pic[6]); sysbus_create_simple("syborg,serial", 0xC0008000, pic[7]); sysbus_create_simple("syborg,serial", 0xC0009000, pic[8]); if (nd_table[0].vlan) { DeviceState *dev; SysBusDevice *s; qemu_check_nic_model(&nd_table[0], "virtio"); dev = qdev_create(NULL, "syborg,virtio-net"); dev->nd = &nd_table[0]; qdev_init(dev); s = sysbus_from_qdev(dev); sysbus_mmio_map(s, 0, 0xc000c000); sysbus_connect_irq(s, 0, pic[9]); } syborg_binfo.ram_size = ram_size; syborg_binfo.kernel_filename = kernel_filename; syborg_binfo.kernel_cmdline = kernel_cmdline; syborg_binfo.initrd_filename = initrd_filename; syborg_binfo.board_id = 0; arm_load_kernel(env, &syborg_binfo); }


static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx, const uint8_t *buf, int buf_size) { const uint8_t *buf_ptr = buf, *bs_hdr; uint32_t frame_num, word2, check_sum, data_size; uint32_t y_offset, u_offset, v_offset, starts[3], ends[3]; uint16_t height, width; int i, j; /* parse and check the OS header */ frame_num = bytestream_get_le32(&buf_ptr); word2 = bytestream_get_le32(&buf_ptr); check_sum = bytestream_get_le32(&buf_ptr); data_size = bytestream_get_le32(&buf_ptr); if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) { av_log(avctx, AV_LOG_ERROR, "OS header checksum mismatch!\n"); return AVERROR_INVALIDDATA; } /* parse the bitstream header */ bs_hdr = buf_ptr; if (bytestream_get_le16(&buf_ptr) != 32) { av_log(avctx, AV_LOG_ERROR, "Unsupported codec version!\n"); return AVERROR_INVALIDDATA; } ctx->frame_num = frame_num; ctx->frame_flags = bytestream_get_le16(&buf_ptr); ctx->data_size = (bytestream_get_le32(&buf_ptr) + 7) >> 3; ctx->cb_offset = *buf_ptr++; if (ctx->data_size == 16) return 4; if (ctx->data_size > buf_size) ctx->data_size = buf_size; buf_ptr += 3; // skip reserved byte and checksum /* check frame dimensions */ height = bytestream_get_le16(&buf_ptr); width = bytestream_get_le16(&buf_ptr); if (av_image_check_size(width, height, 0, avctx)) return AVERROR_INVALIDDATA; if (width != ctx->width || height != ctx->height) { av_dlog(avctx, "Frame dimensions changed!\n"); ctx->width = width; ctx->height = height; free_frame_buffers(ctx); allocate_frame_buffers(ctx, avctx); avcodec_set_dimensions(avctx, width, height); } y_offset = bytestream_get_le32(&buf_ptr); v_offset = bytestream_get_le32(&buf_ptr); u_offset = bytestream_get_le32(&buf_ptr); /* unfortunately there is no common order of planes in the buffer */ /* so we use that sorting algo for determining planes data sizes */ starts[0] = y_offset; starts[1] = v_offset; starts[2] = u_offset; for (j = 0; j < 3; j++) { ends[j] = ctx->data_size; for (i = 2; i >= 0; i--) if (starts[i] < ends[j] && starts[i] > starts[j]) ends[j] = starts[i]; } ctx->y_data_size = ends[0] - starts[0]; ctx->v_data_size = ends[1] - starts[1]; ctx->u_data_size = ends[2] - starts[2]; if (FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 || FFMIN3(ctx->y_data_size, ctx->v_data_size, ctx->u_data_size) <= 0) { av_log(avctx, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n"); return AVERROR_INVALIDDATA; } ctx->y_data_ptr = bs_hdr + y_offset; ctx->v_data_ptr = bs_hdr + v_offset; ctx->u_data_ptr = bs_hdr + u_offset; ctx->alt_quant = buf_ptr + sizeof(uint32_t); if (ctx->data_size == 16) { av_log(avctx, AV_LOG_DEBUG, "Sync frame encountered!\n"); return 16; } if (ctx->frame_flags & BS_8BIT_PEL) { av_log_ask_for_sample(avctx, "8-bit pixel format\n"); return AVERROR_PATCHWELCOME; } if (ctx->frame_flags & BS_MV_X_HALF || ctx->frame_flags & BS_MV_Y_HALF) { av_log_ask_for_sample(avctx, "halfpel motion vectors\n"); return AVERROR_PATCHWELCOME; } return 0; }


static void cin_decode_rle(const unsigned char *src, int src_size, unsigned char *dst, int dst_size) { int len, code; unsigned char *dst_end = dst + dst_size; const unsigned char *src_end = src + src_size; while (src < src_end && dst < dst_end) { code = *src++; if (code & 0x80) { len = code - 0x7F; memset(dst, *src++, FFMIN(len, dst_end - dst)); } else { len = code + 1; memcpy(dst, src, FFMIN(len, dst_end - dst)); src += len; } dst += len; } }


BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque) { BlockDriver *drv = bs->drv; if (!drv) return NULL; return drv->bdrv_aio_flush(bs, cb, opaque);