project
stringclasses
2 values
commit_id
stringlengths
40
40
target
int64
0
1
func
stringlengths
26
142k
idx
int64
0
27.3k
qemu
e68c5958668596a5023e30ddf8368410878f7682
0
ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, Error **errp) { ChardevReturn *ret = g_new0(ChardevReturn, 1); CharDriverState *base, *chr = NULL; chr = qemu_chr_find(id); if (chr) { error_setg(errp, "Chardev '%s' already exists", id); g_free(ret); return NULL; } switch (backend->kind) { case CHARDEV_BACKEND_KIND_FILE: chr = qmp_chardev_open_file(backend->file, errp); break; case CHARDEV_BACKEND_KIND_SERIAL: chr = qmp_chardev_open_serial(backend->serial, errp); break; case CHARDEV_BACKEND_KIND_PARALLEL: chr = qmp_chardev_open_parallel(backend->parallel, errp); break; case CHARDEV_BACKEND_KIND_SOCKET: chr = qmp_chardev_open_socket(backend->socket, errp); break; #ifdef HAVE_CHARDEV_TTY case CHARDEV_BACKEND_KIND_PTY: { /* qemu_chr_open_pty sets "path" in opts */ QemuOpts *opts; opts = qemu_opts_create_nofail(qemu_find_opts("chardev")); chr = qemu_chr_open_pty(opts); ret->pty = g_strdup(qemu_opt_get(opts, "path")); ret->has_pty = true; qemu_opts_del(opts); break; } #endif case CHARDEV_BACKEND_KIND_NULL: chr = qemu_chr_open_null(); break; case CHARDEV_BACKEND_KIND_MUX: base = qemu_chr_find(backend->mux->chardev); if (base == NULL) { error_setg(errp, "mux: base chardev %s not found", backend->mux->chardev); break; } chr = qemu_chr_open_mux(base); break; case CHARDEV_BACKEND_KIND_MSMOUSE: chr = qemu_chr_open_msmouse(); break; #ifdef CONFIG_BRLAPI case CHARDEV_BACKEND_KIND_BRAILLE: chr = chr_baum_init(); break; #endif case CHARDEV_BACKEND_KIND_STDIO: chr = qemu_chr_open_stdio(backend->stdio); break; default: error_setg(errp, "unknown chardev backend (%d)", backend->kind); break; } if (chr == NULL && !error_is_set(errp)) { error_setg(errp, "Failed to create chardev"); } if (chr) { chr->label = g_strdup(id); chr->avail_connections = (backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1; QTAILQ_INSERT_TAIL(&chardevs, chr, next); return ret; } else { g_free(ret); return NULL; } }
18,995
qemu
92f9a4f13ea29de4644bd0b077643e1dff96ab29
0
static int pbm_pci_host_init(PCIDevice *d) { pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_SUN); pci_config_set_device_id(d->config, PCI_DEVICE_ID_SUN_SABRE); pci_set_word(d->config + PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); pci_set_word(d->config + PCI_STATUS, PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ | PCI_STATUS_DEVSEL_MEDIUM); pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); return 0; }
18,996
qemu
5fb6c7a8b26eab1a22207d24b4784bd2b39ab54b
0
static int32_t read_s32(uint8_t *data, size_t offset) { return (int32_t)((data[offset] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | data[offset + 3]); }
18,998
qemu
b769d8fef6c06ddb39ef0337882a4f8872b9c2bc
0
CPUSPARCState *cpu_sparc_init(void) { CPUSPARCState *env; cpu_exec_init(); if (!(env = malloc(sizeof(CPUSPARCState)))) return (NULL); memset(env, 0, sizeof(*env)); env->cwp = 0; env->wim = 1; env->regwptr = env->regbase + (env->cwp * 16); env->access_type = ACCESS_DATA; #if defined(CONFIG_USER_ONLY) env->user_mode_only = 1; #else /* Emulate Prom */ env->psrs = 1; env->pc = 0x4000; env->npc = env->pc + 4; env->mmuregs[0] = (0x10<<24) | MMU_E; /* Impl 1, ver 0, MMU Enabled */ env->mmuregs[1] = 0x3000 >> 4; /* MMU Context table */ #endif cpu_single_env = env; return (env); }
19,000
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
0
void timer_init_tl(QEMUTimer *ts, QEMUTimerList *timer_list, int scale, QEMUTimerCB *cb, void *opaque) { ts->timer_list = timer_list; ts->cb = cb; ts->opaque = opaque; ts->scale = scale; ts->expire_time = -1; }
19,001
qemu
0cd09c3a6cc2230ba38c462fc410b4acce59eb6f
0
static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features) { VirtIONet *n = VIRTIO_NET(vdev); NetClientState *nc = qemu_get_queue(n->nic); features |= (1 << VIRTIO_NET_F_MAC); if (!peer_has_vnet_hdr(n)) { features &= ~(0x1 << VIRTIO_NET_F_CSUM); features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO4); features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO6); features &= ~(0x1 << VIRTIO_NET_F_HOST_ECN); features &= ~(0x1 << VIRTIO_NET_F_GUEST_CSUM); features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO4); features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO6); features &= ~(0x1 << VIRTIO_NET_F_GUEST_ECN); } if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) { features &= ~(0x1 << VIRTIO_NET_F_GUEST_UFO); features &= ~(0x1 << VIRTIO_NET_F_HOST_UFO); } if (!get_vhost_net(nc->peer)) { return features; } return vhost_net_get_features(get_vhost_net(nc->peer), features); }
19,004
FFmpeg
eabbc64728c2fdb74f565aededec2ab023d20699
0
static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tracks, int num_tracks) { MatroskaMuxContext *mkv = s->priv_data; AVIOContext *dyn_cp, *pb = s->pb; ebml_master cues_element; int64_t currentpos; int i, j, ret; currentpos = avio_tell(pb); ret = start_ebml_master_crc32(pb, &dyn_cp, &cues_element, MATROSKA_ID_CUES, 0); if (ret < 0) return ret; for (i = 0; i < cues->num_entries; i++) { ebml_master cuepoint, track_positions; mkv_cuepoint *entry = &cues->entries[i]; uint64_t pts = entry->pts; int ctp_nb = 0; // Calculate the number of entries, so we know the element size for (j = 0; j < num_tracks; j++) tracks[j].has_cue = 0; for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) { int tracknum = entry[j].stream_idx; av_assert0(tracknum>=0 && tracknum<num_tracks); if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) continue; tracks[tracknum].has_cue = 1; ctp_nb ++; } cuepoint = start_ebml_master(dyn_cp, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(ctp_nb)); put_ebml_uint(dyn_cp, MATROSKA_ID_CUETIME, pts); // put all the entries from different tracks that have the exact same // timestamp into the same CuePoint for (j = 0; j < num_tracks; j++) tracks[j].has_cue = 0; for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) { int tracknum = entry[j].stream_idx; av_assert0(tracknum>=0 && tracknum<num_tracks); if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) continue; tracks[tracknum].has_cue = 1; track_positions = start_ebml_master(dyn_cp, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE); put_ebml_uint(dyn_cp, MATROSKA_ID_CUETRACK , entry[j].tracknum ); put_ebml_uint(dyn_cp, MATROSKA_ID_CUECLUSTERPOSITION , entry[j].cluster_pos); put_ebml_uint(dyn_cp, MATROSKA_ID_CUERELATIVEPOSITION, entry[j].relative_pos); if (entry[j].duration != -1) put_ebml_uint(dyn_cp, MATROSKA_ID_CUEDURATION , entry[j].duration); end_ebml_master(dyn_cp, track_positions); } i += j - 1; end_ebml_master(dyn_cp, cuepoint); } end_ebml_master_crc32(pb, &dyn_cp, mkv, cues_element); return currentpos; }
19,007
FFmpeg
c8241e730f116f1c9cfc0b34110aa7f052e05332
0
av_cold int ff_vaapi_encode_init(AVCodecContext *avctx, const VAAPIEncodeType *type) { VAAPIEncodeContext *ctx = avctx->priv_data; AVVAAPIFramesContext *recon_hwctx = NULL; AVVAAPIHWConfig *hwconfig = NULL; AVHWFramesConstraints *constraints = NULL; enum AVPixelFormat recon_format; VAStatus vas; int err, i; if (!avctx->hw_frames_ctx) { av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is " "required to associate the encoding device.\n"); return AVERROR(EINVAL); } ctx->codec = type; ctx->codec_options = ctx->codec_options_data; ctx->va_config = VA_INVALID_ID; ctx->va_context = VA_INVALID_ID; ctx->priv_data = av_mallocz(type->priv_data_size); if (!ctx->priv_data) { err = AVERROR(ENOMEM); goto fail; } ctx->input_frames_ref = av_buffer_ref(avctx->hw_frames_ctx); if (!ctx->input_frames_ref) { err = AVERROR(ENOMEM); goto fail; } ctx->input_frames = (AVHWFramesContext*)ctx->input_frames_ref->data; ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref); if (!ctx->device_ref) { err = AVERROR(ENOMEM); goto fail; } ctx->device = (AVHWDeviceContext*)ctx->device_ref->data; ctx->hwctx = ctx->device->hwctx; err = ctx->codec->init(avctx); if (err < 0) goto fail; err = vaapi_encode_check_config(avctx); if (err < 0) goto fail; vas = vaCreateConfig(ctx->hwctx->display, ctx->va_profile, ctx->va_entrypoint, ctx->config_attributes, ctx->nb_config_attributes, &ctx->va_config); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to create encode pipeline " "configuration: %d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); goto fail; } hwconfig = av_hwdevice_hwconfig_alloc(ctx->device_ref); if (!hwconfig) { err = AVERROR(ENOMEM); goto fail; } hwconfig->config_id = ctx->va_config; constraints = av_hwdevice_get_hwframe_constraints(ctx->device_ref, hwconfig); if (!constraints) { err = AVERROR(ENOMEM); goto fail; } // Probably we can use the input surface format as the surface format // of the reconstructed frames. If not, we just pick the first (only?) // format in the valid list and hope that it all works. recon_format = AV_PIX_FMT_NONE; if (constraints->valid_sw_formats) { for (i = 0; constraints->valid_sw_formats[i] != AV_PIX_FMT_NONE; i++) { if (ctx->input_frames->sw_format == constraints->valid_sw_formats[i]) { recon_format = ctx->input_frames->sw_format; break; } } if (recon_format == AV_PIX_FMT_NONE) { // No match. Just use the first in the supported list and // hope for the best. recon_format = constraints->valid_sw_formats[0]; } } else { // No idea what to use; copy input format. recon_format = ctx->input_frames->sw_format; } av_log(avctx, AV_LOG_DEBUG, "Using %s as format of " "reconstructed frames.\n", av_get_pix_fmt_name(recon_format)); if (ctx->aligned_width < constraints->min_width || ctx->aligned_height < constraints->min_height || ctx->aligned_width > constraints->max_width || ctx->aligned_height > constraints->max_height) { av_log(avctx, AV_LOG_ERROR, "Hardware does not support encoding at " "size %dx%d (constraints: width %d-%d height %d-%d).\n", ctx->aligned_width, ctx->aligned_height, constraints->min_width, constraints->max_width, constraints->min_height, constraints->max_height); err = AVERROR(EINVAL); goto fail; } av_freep(&hwconfig); av_hwframe_constraints_free(&constraints); ctx->recon_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref); if (!ctx->recon_frames_ref) { err = AVERROR(ENOMEM); goto fail; } ctx->recon_frames = (AVHWFramesContext*)ctx->recon_frames_ref->data; ctx->recon_frames->format = AV_PIX_FMT_VAAPI; ctx->recon_frames->sw_format = recon_format; ctx->recon_frames->width = ctx->aligned_width; ctx->recon_frames->height = ctx->aligned_height; ctx->recon_frames->initial_pool_size = ctx->nb_recon_frames; err = av_hwframe_ctx_init(ctx->recon_frames_ref); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to initialise reconstructed " "frame context: %d.\n", err); goto fail; } recon_hwctx = ctx->recon_frames->hwctx; vas = vaCreateContext(ctx->hwctx->display, ctx->va_config, ctx->aligned_width, ctx->aligned_height, VA_PROGRESSIVE, recon_hwctx->surface_ids, recon_hwctx->nb_surfaces, &ctx->va_context); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to create encode pipeline " "context: %d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(EIO); goto fail; } ctx->input_order = 0; ctx->output_delay = avctx->max_b_frames; ctx->decode_delay = 1; ctx->output_order = - ctx->output_delay - 1; if (ctx->codec->sequence_params_size > 0) { ctx->codec_sequence_params = av_mallocz(ctx->codec->sequence_params_size); if (!ctx->codec_sequence_params) { err = AVERROR(ENOMEM); goto fail; } } if (ctx->codec->picture_params_size > 0) { ctx->codec_picture_params = av_mallocz(ctx->codec->picture_params_size); if (!ctx->codec_picture_params) { err = AVERROR(ENOMEM); goto fail; } } if (ctx->codec->init_sequence_params) { err = ctx->codec->init_sequence_params(avctx); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Codec sequence initialisation " "failed: %d.\n", err); goto fail; } } ctx->output_buffer_pool = av_buffer_pool_init2(sizeof(VABufferID), avctx, &vaapi_encode_alloc_output_buffer, NULL); if (!ctx->output_buffer_pool) { err = AVERROR(ENOMEM); goto fail; } // All I are IDR for now. ctx->i_per_idr = 0; ctx->p_per_i = ((avctx->gop_size + avctx->max_b_frames) / (avctx->max_b_frames + 1)); ctx->b_per_p = avctx->max_b_frames; // This should be configurable somehow. (Needs testing on a machine // where it actually overlaps properly, though.) ctx->issue_mode = ISSUE_MODE_MAXIMISE_THROUGHPUT; return 0; fail: av_freep(&hwconfig); av_hwframe_constraints_free(&constraints); ff_vaapi_encode_close(avctx); return err; }
19,008
FFmpeg
20ec0d2a750a804f50c090cf6e6509db8ff9cadd
0
void ff_print_debug_info(MpegEncContext *s, AVFrame *pict) { if ( s->avctx->hwaccel || !pict || !pict->mb_type || (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)) return; if (s->avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) { int x,y; av_log(s->avctx, AV_LOG_DEBUG, "New frame, type: %c\n", av_get_picture_type_char(pict->pict_type)); for (y = 0; y < s->mb_height; y++) { for (x = 0; x < s->mb_width; x++) { if (s->avctx->debug & FF_DEBUG_SKIP) { int count = s->mbskip_table[x + y * s->mb_stride]; if (count > 9) count = 9; av_log(s->avctx, AV_LOG_DEBUG, "%1d", count); } if (s->avctx->debug & FF_DEBUG_QP) { av_log(s->avctx, AV_LOG_DEBUG, "%2d", pict->qscale_table[x + y * s->mb_stride]); } if (s->avctx->debug & FF_DEBUG_MB_TYPE) { int mb_type = pict->mb_type[x + y * s->mb_stride]; // Type & MV direction if (IS_PCM(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "P"); else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "A"); else if (IS_INTRA4x4(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "i"); else if (IS_INTRA16x16(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "I"); else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "d"); else if (IS_DIRECT(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "D"); else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "g"); else if (IS_GMC(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "G"); else if (IS_SKIP(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "S"); else if (!USES_LIST(mb_type, 1)) av_log(s->avctx, AV_LOG_DEBUG, ">"); else if (!USES_LIST(mb_type, 0)) av_log(s->avctx, AV_LOG_DEBUG, "<"); else { av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1)); av_log(s->avctx, AV_LOG_DEBUG, "X"); } // segmentation if (IS_8X8(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "+"); else if (IS_16X8(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "-"); else if (IS_8X16(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "|"); else if (IS_INTRA(mb_type) || IS_16X16(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, " "); else av_log(s->avctx, AV_LOG_DEBUG, "?"); if (IS_INTERLACED(mb_type)) av_log(s->avctx, AV_LOG_DEBUG, "="); else av_log(s->avctx, AV_LOG_DEBUG, " "); } } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } } if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)) { const int shift = 1 + s->quarter_sample; int mb_y; uint8_t *ptr; int i; int h_chroma_shift, v_chroma_shift, block_height; const int width = s->avctx->width; const int height = s->avctx->height; const int mv_sample_log2 = 4 - pict->motion_subsample_log2; const int mv_stride = (s->mb_width << mv_sample_log2) + (s->codec_id == AV_CODEC_ID_H264 ? 0 : 1); s->low_delay = 0; // needed to see the vectors without trashing the buffers avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift); for (i = 0; i < 3; i++) { size_t size= (i == 0) ? pict->linesize[i] * FFALIGN(height, 16): pict->linesize[i] * FFALIGN(height, 16) >> v_chroma_shift; s->visualization_buffer[i]= av_realloc(s->visualization_buffer[i], size); memcpy(s->visualization_buffer[i], pict->data[i], size); pict->data[i] = s->visualization_buffer[i]; } pict->type = FF_BUFFER_TYPE_COPY; pict->opaque= NULL; ptr = pict->data[0]; block_height = 16 >> v_chroma_shift; for (mb_y = 0; mb_y < s->mb_height; mb_y++) { int mb_x; for (mb_x = 0; mb_x < s->mb_width; mb_x++) { const int mb_index = mb_x + mb_y * s->mb_stride; if ((s->avctx->debug_mv) && pict->motion_val) { int type; for (type = 0; type < 3; type++) { int direction = 0; switch (type) { case 0: if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_P_FOR)) || (pict->pict_type!= AV_PICTURE_TYPE_P)) continue; direction = 0; break; case 1: if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_B_FOR)) || (pict->pict_type!= AV_PICTURE_TYPE_B)) continue; direction = 0; break; case 2: if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_B_BACK)) || (pict->pict_type!= AV_PICTURE_TYPE_B)) continue; direction = 1; break; } if (!USES_LIST(pict->mb_type[mb_index], direction)) continue; if (IS_8X8(pict->mb_type[mb_index])) { int i; for (i = 0; i < 4; i++) { int sx = mb_x * 16 + 4 + 8 * (i & 1); int sy = mb_y * 16 + 4 + 8 * (i >> 1); int xy = (mb_x * 2 + (i & 1) + (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1); int mx = (pict->motion_val[direction][xy][0] >> shift) + sx; int my = (pict->motion_val[direction][xy][1] >> shift) + sy; draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100); } } else if (IS_16X8(pict->mb_type[mb_index])) { int i; for (i = 0; i < 2; i++) { int sx = mb_x * 16 + 8; int sy = mb_y * 16 + 4 + 8 * i; int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1); int mx = (pict->motion_val[direction][xy][0] >> shift); int my = (pict->motion_val[direction][xy][1] >> shift); if (IS_INTERLACED(pict->mb_type[mb_index])) my *= 2; draw_arrow(ptr, sx, sy, mx + sx, my + sy, width, height, s->linesize, 100); } } else if (IS_8X16(pict->mb_type[mb_index])) { int i; for (i = 0; i < 2; i++) { int sx = mb_x * 16 + 4 + 8 * i; int sy = mb_y * 16 + 8; int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1); int mx = pict->motion_val[direction][xy][0] >> shift; int my = pict->motion_val[direction][xy][1] >> shift; if (IS_INTERLACED(pict->mb_type[mb_index])) my *= 2; draw_arrow(ptr, sx, sy, mx + sx, my + sy, width, height, s->linesize, 100); } } else { int sx= mb_x * 16 + 8; int sy= mb_y * 16 + 8; int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2; int mx= (pict->motion_val[direction][xy][0]>>shift) + sx; int my= (pict->motion_val[direction][xy][1]>>shift) + sy; draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100); } } } if ((s->avctx->debug & FF_DEBUG_VIS_QP) && pict->motion_val) { uint64_t c = (pict->qscale_table[mb_index] * 128 / 31) * 0x0101010101010101ULL; int y; for (y = 0; y < block_height; y++) { *(uint64_t *)(pict->data[1] + 8 * mb_x + (block_height * mb_y + y) * pict->linesize[1]) = c; *(uint64_t *)(pict->data[2] + 8 * mb_x + (block_height * mb_y + y) * pict->linesize[2]) = c; } } if ((s->avctx->debug & FF_DEBUG_VIS_MB_TYPE) && pict->motion_val) { int mb_type = pict->mb_type[mb_index]; uint64_t u,v; int y; #define COLOR(theta, r) \ u = (int)(128 + r * cos(theta * 3.141592 / 180)); \ v = (int)(128 + r * sin(theta * 3.141592 / 180)); u = v = 128; if (IS_PCM(mb_type)) { COLOR(120, 48) } else if ((IS_INTRA(mb_type) && IS_ACPRED(mb_type)) || IS_INTRA16x16(mb_type)) { COLOR(30, 48) } else if (IS_INTRA4x4(mb_type)) { COLOR(90, 48) } else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) { // COLOR(120, 48) } else if (IS_DIRECT(mb_type)) { COLOR(150, 48) } else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) { COLOR(170, 48) } else if (IS_GMC(mb_type)) { COLOR(190, 48) } else if (IS_SKIP(mb_type)) { // COLOR(180, 48) } else if (!USES_LIST(mb_type, 1)) { COLOR(240, 48) } else if (!USES_LIST(mb_type, 0)) { COLOR(0, 48) } else { av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1)); COLOR(300,48) } u *= 0x0101010101010101ULL; v *= 0x0101010101010101ULL; for (y = 0; y < block_height; y++) { *(uint64_t *)(pict->data[1] + 8 * mb_x + (block_height * mb_y + y) * pict->linesize[1]) = u; *(uint64_t *)(pict->data[2] + 8 * mb_x + (block_height * mb_y + y) * pict->linesize[2]) = v; } // segmentation if (IS_8X8(mb_type) || IS_16X8(mb_type)) { *(uint64_t *)(pict->data[0] + 16 * mb_x + 0 + (16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL; *(uint64_t *)(pict->data[0] + 16 * mb_x + 8 + (16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL; } if (IS_8X8(mb_type) || IS_8X16(mb_type)) { for (y = 0; y < 16; y++) pict->data[0][16 * mb_x + 8 + (16 * mb_y + y) * pict->linesize[0]] ^= 0x80; } if (IS_8X8(mb_type) && mv_sample_log2 >= 2) { int dm = 1 << (mv_sample_log2 - 2); for (i = 0; i < 4; i++) { int sx = mb_x * 16 + 8 * (i & 1); int sy = mb_y * 16 + 8 * (i >> 1); int xy = (mb_x * 2 + (i & 1) + (mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1); // FIXME bidir int32_t *mv = (int32_t *) &pict->motion_val[0][xy]; if (mv[0] != mv[dm] || mv[dm * mv_stride] != mv[dm * (mv_stride + 1)]) for (y = 0; y < 8; y++) pict->data[0][sx + 4 + (sy + y) * pict->linesize[0]] ^= 0x80; if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)]) *(uint64_t *)(pict->data[0] + sx + (sy + 4) * pict->linesize[0]) ^= 0x8080808080808080ULL; } } if (IS_INTERLACED(mb_type) && s->codec_id == AV_CODEC_ID_H264) { // hmm } } s->mbskip_table[mb_index] = 0; } } } }
19,010
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
1
static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d, uint64_t off) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; return qpci_io_readb(dev->pdev, CONFIG_BASE(dev) + off); }
19,013
qemu
4656e1f01289cc3aa20986deb6a407165826abe5
1
int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def) { env->msr_mask = def->msr_mask; env->mmu_model = def->mmu_model; env->excp_model = def->excp_model; env->bus_model = def->bus_model; env->insns_flags = def->insns_flags; env->insns_flags2 = def->insns_flags2; env->flags = def->flags; env->bfd_mach = def->bfd_mach; env->check_pow = def->check_pow; if (kvm_enabled()) { if (kvmppc_fixup_cpu(env) != 0) { fprintf(stderr, "Unable to virtualize selected CPU with KVM\n"); exit(1); } else { if (ppc_fixup_cpu(env) != 0) { fprintf(stderr, "Unable to emulate selected CPU with TCG\n"); exit(1); if (create_ppc_opcodes(env, def) < 0) return -1; init_ppc_proc(env, def); if (def->insns_flags & PPC_FLOAT) { gdb_register_coprocessor(env, gdb_get_float_reg, gdb_set_float_reg, 33, "power-fpu.xml", 0); if (def->insns_flags & PPC_ALTIVEC) { gdb_register_coprocessor(env, gdb_get_avr_reg, gdb_set_avr_reg, 34, "power-altivec.xml", 0); if (def->insns_flags & PPC_SPE) { gdb_register_coprocessor(env, gdb_get_spe_reg, gdb_set_spe_reg, 34, "power-spe.xml", 0); #if defined(PPC_DUMP_CPU) { const char *mmu_model, *excp_model, *bus_model; switch (env->mmu_model) { case POWERPC_MMU_32B: mmu_model = "PowerPC 32"; break; case POWERPC_MMU_SOFT_6xx: mmu_model = "PowerPC 6xx/7xx with software driven TLBs"; break; case POWERPC_MMU_SOFT_74xx: mmu_model = "PowerPC 74xx with software driven TLBs"; break; case POWERPC_MMU_SOFT_4xx: mmu_model = "PowerPC 4xx with software driven TLBs"; break; case POWERPC_MMU_SOFT_4xx_Z: mmu_model = "PowerPC 4xx with software driven TLBs " "and zones protections"; break; case POWERPC_MMU_REAL: mmu_model = "PowerPC real mode only"; break; case POWERPC_MMU_MPC8xx: mmu_model = "PowerPC MPC8xx"; break; case POWERPC_MMU_BOOKE: mmu_model = "PowerPC BookE"; break; case POWERPC_MMU_BOOKE206: mmu_model = "PowerPC BookE 2.06"; break; case POWERPC_MMU_601: mmu_model = "PowerPC 601"; break; #if defined (TARGET_PPC64) case POWERPC_MMU_64B: mmu_model = "PowerPC 64"; break; case POWERPC_MMU_620: mmu_model = "PowerPC 620"; break; #endif default: mmu_model = "Unknown or invalid"; break; switch (env->excp_model) { case POWERPC_EXCP_STD: excp_model = "PowerPC"; break; case POWERPC_EXCP_40x: excp_model = "PowerPC 40x"; break; case POWERPC_EXCP_601: excp_model = "PowerPC 601"; break; case POWERPC_EXCP_602: excp_model = "PowerPC 602"; break; case POWERPC_EXCP_603: excp_model = "PowerPC 603"; break; case POWERPC_EXCP_603E: excp_model = "PowerPC 603e"; break; case POWERPC_EXCP_604: excp_model = "PowerPC 604"; break; case POWERPC_EXCP_7x0: excp_model = "PowerPC 740/750"; break; case POWERPC_EXCP_7x5: excp_model = "PowerPC 745/755"; break; case POWERPC_EXCP_74xx: excp_model = "PowerPC 74xx"; break; case POWERPC_EXCP_BOOKE: excp_model = "PowerPC BookE"; break; #if defined (TARGET_PPC64) case POWERPC_EXCP_970: excp_model = "PowerPC 970"; break; #endif default: excp_model = "Unknown or invalid"; break; switch (env->bus_model) { case PPC_FLAGS_INPUT_6xx: bus_model = "PowerPC 6xx"; break; case PPC_FLAGS_INPUT_BookE: bus_model = "PowerPC BookE"; break; case PPC_FLAGS_INPUT_405: bus_model = "PowerPC 405"; break; case PPC_FLAGS_INPUT_401: bus_model = "PowerPC 401/403"; break; case PPC_FLAGS_INPUT_RCPU: bus_model = "RCPU / MPC8xx"; break; #if defined (TARGET_PPC64) case PPC_FLAGS_INPUT_970: bus_model = "PowerPC 970"; break; #endif default: bus_model = "Unknown or invalid"; break; printf("PowerPC %-12s : PVR %08x MSR %016" PRIx64 "\n" " MMU model : %s\n", def->name, def->pvr, def->msr_mask, mmu_model); #if !defined(CONFIG_USER_ONLY) if (env->tlb != NULL) { printf(" %d %s TLB in %d ways\n", env->nb_tlb, env->id_tlbs ? "splitted" : "merged", env->nb_ways); #endif printf(" Exceptions model : %s\n" " Bus model : %s\n", excp_model, bus_model); printf(" MSR features :\n"); if (env->flags & POWERPC_FLAG_SPE) printf(" signal processing engine enable" "\n"); else if (env->flags & POWERPC_FLAG_VRE) printf(" vector processor enable\n"); if (env->flags & POWERPC_FLAG_TGPR) printf(" temporary GPRs\n"); else if (env->flags & POWERPC_FLAG_CE) printf(" critical input enable\n"); if (env->flags & POWERPC_FLAG_SE) printf(" single-step trace mode\n"); else if (env->flags & POWERPC_FLAG_DWE) printf(" debug wait enable\n"); else if (env->flags & POWERPC_FLAG_UBLE) printf(" user BTB lock enable\n"); if (env->flags & POWERPC_FLAG_BE) printf(" branch-step trace mode\n"); else if (env->flags & POWERPC_FLAG_DE) printf(" debug interrupt enable\n"); if (env->flags & POWERPC_FLAG_PX) printf(" inclusive protection\n"); else if (env->flags & POWERPC_FLAG_PMM) printf(" performance monitor mark\n"); if (env->flags == POWERPC_FLAG_NONE) printf(" none\n"); printf(" Time-base/decrementer clock source: %s\n", env->flags & POWERPC_FLAG_RTC_CLK ? "RTC clock" : "bus clock"); dump_ppc_insns(env); dump_ppc_sprs(env); fflush(stdout); #endif return 0;
19,015
qemu
c6d2283068026035a6468aae9dcde953bd7521ac
1
static void set_dirty_bitmap(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int dirty) { int64_t start, end; start = sector_num / BDRV_SECTORS_PER_DIRTY_CHUNK; end = (sector_num + nb_sectors) / BDRV_SECTORS_PER_DIRTY_CHUNK; for (; start <= end; start++) { bs->dirty_bitmap[start] = dirty; } }
19,016
qemu
0479097859372a760843ad1b9c6ed3705c6423ca
1
static void pc_dimm_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCMachineState *pcms = PC_MACHINE(hotplug_dev); PCDIMMDevice *dimm = PC_DIMM(dev); PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); HotplugHandlerClass *hhc; Error *local_err = NULL; hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); if (local_err) { goto out; } pc_dimm_memory_unplug(dev, &pcms->hotplug_memory, mr); object_unparent(OBJECT(dev)); out: error_propagate(errp, local_err); }
19,017
qemu
bae416e5ba65701d3c5238164517158066d615e5
1
uint64_t ram_bytes_remaining(void) { return ram_state->migration_dirty_pages * TARGET_PAGE_SIZE; }
19,018
qemu
afeecec2e8e99ba184c487633d5d0dde68a002ac
1
QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX) /** * monitor_protocol_event(): Generate a Monitor event * * Event-specific data can be emitted through the (optional) 'data' parameter. */ void monitor_protocol_event(MonitorEvent event, QObject *data) { QDict *qmp; const char *event_name; Monitor *mon; assert(event < QEVENT_MAX); event_name = monitor_event_names[event]; assert(event_name != NULL); qmp = qdict_new(); timestamp_put(qmp); qdict_put(qmp, "event", qstring_from_str(event_name)); if (data) { qobject_incref(data); qdict_put_obj(qmp, "data", data); } QLIST_FOREACH(mon, &mon_list, entry) { if (monitor_ctrl_mode(mon) && qmp_cmd_mode(mon)) { monitor_json_emitter(mon, QOBJECT(qmp)); } } QDECREF(qmp); }
19,019
qemu
19dbcbf7cc1892f5130b4edd5a4bb4ca800ef7d8
1
static int preallocate(BlockDriverState *bs) { uint64_t nb_sectors; uint64_t offset; int num; int ret; QCowL2Meta meta; nb_sectors = bdrv_getlength(bs) >> 9; offset = 0; QLIST_INIT(&meta.dependent_requests); meta.cluster_offset = 0; while (nb_sectors) { num = MIN(nb_sectors, INT_MAX >> 9); ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, &meta); if (ret < 0) { return -1; } if (qcow2_alloc_cluster_link_l2(bs, &meta) < 0) { qcow2_free_any_clusters(bs, meta.cluster_offset, meta.nb_clusters); return -1; } /* There are no dependent requests, but we need to remove our request * from the list of in-flight requests */ run_dependent_requests(&meta); /* TODO Preallocate data if requested */ nb_sectors -= num; offset += num << 9; } /* * It is expected that the image file is large enough to actually contain * all of the allocated clusters (otherwise we get failing reads after * EOF). Extend the image to the last allocated sector. */ if (meta.cluster_offset != 0) { uint8_t buf[512]; memset(buf, 0, 512); bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf, 1); } return 0; }
19,020
qemu
ae392c416c69a020226c768d9c3af08b29dd6d96
1
static int msix_is_masked(PCIDevice *dev, int vector) { unsigned offset = vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL; return dev->msix_function_masked || dev->msix_table_page[offset] & PCI_MSIX_ENTRY_CTRL_MASKBIT; }
19,021
qemu
301c7d38a0c359b91526391d13617386f3d9bb29
1
static int vmdk_add_extent(BlockDriverState *bs, BlockDriverState *file, bool flat, int64_t sectors, int64_t l1_offset, int64_t l1_backup_offset, uint32_t l1_size, int l2_size, uint64_t cluster_sectors, VmdkExtent **new_extent) { VmdkExtent *extent; BDRVVmdkState *s = bs->opaque; if (cluster_sectors > 0x200000) { /* 0x200000 * 512Bytes = 1GB for one cluster is unrealistic */ error_report("invalid granularity, image may be corrupt"); return -EINVAL; } if (l1_size > 512 * 1024 * 1024) { /* Although with big capacity and small l1_entry_sectors, we can get a * big l1_size, we don't want unbounded value to allocate the table. * Limit it to 512M, which is 16PB for default cluster and L2 table * size */ error_report("L1 size too big"); return -EFBIG; } s->extents = g_realloc(s->extents, (s->num_extents + 1) * sizeof(VmdkExtent)); extent = &s->extents[s->num_extents]; s->num_extents++; memset(extent, 0, sizeof(VmdkExtent)); extent->file = file; extent->flat = flat; extent->sectors = sectors; extent->l1_table_offset = l1_offset; extent->l1_backup_table_offset = l1_backup_offset; extent->l1_size = l1_size; extent->l1_entry_sectors = l2_size * cluster_sectors; extent->l2_size = l2_size; extent->cluster_sectors = cluster_sectors; if (s->num_extents > 1) { extent->end_sector = (*(extent - 1)).end_sector + extent->sectors; } else { extent->end_sector = extent->sectors; } bs->total_sectors = extent->end_sector; if (new_extent) { *new_extent = extent; } return 0; }
19,022
FFmpeg
c7921a480467876ece06566e0efd8f6bce9d1903
1
static int get_stream_info(AVCodecContext *avctx) { FDKAACDecContext *s = avctx->priv_data; CStreamInfo *info = aacDecoder_GetStreamInfo(s->handle); int channel_counts[0x24] = { 0 }; int i, ch_error = 0; uint64_t ch_layout = 0; if (!info) { av_log(avctx, AV_LOG_ERROR, "Unable to get stream info\n"); return AVERROR_UNKNOWN; } if (info->sampleRate <= 0) { av_log(avctx, AV_LOG_ERROR, "Stream info not initialized\n"); return AVERROR_UNKNOWN; } avctx->sample_rate = info->sampleRate; avctx->frame_size = info->frameSize; for (i = 0; i < info->numChannels; i++) { AUDIO_CHANNEL_TYPE ctype = info->pChannelType[i]; if (ctype <= ACT_NONE || ctype > FF_ARRAY_ELEMS(channel_counts)) { av_log(avctx, AV_LOG_WARNING, "unknown channel type\n"); break; } channel_counts[ctype]++; } av_log(avctx, AV_LOG_DEBUG, "%d channels - front:%d side:%d back:%d lfe:%d top:%d\n", info->numChannels, channel_counts[ACT_FRONT], channel_counts[ACT_SIDE], channel_counts[ACT_BACK], channel_counts[ACT_LFE], channel_counts[ACT_FRONT_TOP] + channel_counts[ACT_SIDE_TOP] + channel_counts[ACT_BACK_TOP] + channel_counts[ACT_TOP]); switch (channel_counts[ACT_FRONT]) { case 4: ch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER; break; case 3: ch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER; break; case 2: ch_layout |= AV_CH_LAYOUT_STEREO; break; case 1: ch_layout |= AV_CH_FRONT_CENTER; break; default: av_log(avctx, AV_LOG_WARNING, "unsupported number of front channels: %d\n", channel_counts[ACT_FRONT]); ch_error = 1; break; } if (channel_counts[ACT_SIDE] > 0) { if (channel_counts[ACT_SIDE] == 2) { ch_layout |= AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT; } else { av_log(avctx, AV_LOG_WARNING, "unsupported number of side channels: %d\n", channel_counts[ACT_SIDE]); ch_error = 1; } } if (channel_counts[ACT_BACK] > 0) { switch (channel_counts[ACT_BACK]) { case 3: ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT | AV_CH_BACK_CENTER; break; case 2: ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT; break; case 1: ch_layout |= AV_CH_BACK_CENTER; break; default: av_log(avctx, AV_LOG_WARNING, "unsupported number of back channels: %d\n", channel_counts[ACT_BACK]); ch_error = 1; break; } } if (channel_counts[ACT_LFE] > 0) { if (channel_counts[ACT_LFE] == 1) { ch_layout |= AV_CH_LOW_FREQUENCY; } else { av_log(avctx, AV_LOG_WARNING, "unsupported number of LFE channels: %d\n", channel_counts[ACT_LFE]); ch_error = 1; } } if (!ch_error && av_get_channel_layout_nb_channels(ch_layout) != info->numChannels) { av_log(avctx, AV_LOG_WARNING, "unsupported channel configuration\n"); ch_error = 1; } if (ch_error) avctx->channel_layout = 0; else avctx->channel_layout = ch_layout; avctx->channels = info->numChannels; return 0; }
19,024
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
1
static void *qemu_rdma_data_init(const char *host_port, Error **errp) { RDMAContext *rdma = NULL; InetSocketAddress *addr; if (host_port) { rdma = g_malloc0(sizeof(RDMAContext)); memset(rdma, 0, sizeof(RDMAContext)); rdma->current_index = -1; rdma->current_chunk = -1; addr = inet_parse(host_port, NULL); if (addr != NULL) { rdma->port = atoi(addr->port); rdma->host = g_strdup(addr->host); } else { ERROR(errp, "bad RDMA migration address '%s'", host_port); g_free(rdma); rdma = NULL; } qapi_free_InetSocketAddress(addr); } return rdma; }
19,025
qemu
34779e8c3991f7fcd74b2045478abcef67dbeb15
1
static void test_tco_second_timeout_pause(void) { TestData td; const uint16_t ticks = TCO_SECS_TO_TICKS(32); QDict *ad; td.args = "-watchdog-action pause"; td.noreboot = false; test_init(&td); stop_tco(&td); clear_tco_status(&td); reset_on_second_timeout(true); set_tco_timeout(&td, TCO_SECS_TO_TICKS(16)); load_tco(&td); start_tco(&td); clock_step(ticks * TCO_TICK_NSEC * 2); ad = get_watchdog_action(); g_assert(!strcmp(qdict_get_str(ad, "action"), "pause")); QDECREF(ad); stop_tco(&td); qtest_end(); }
19,026
FFmpeg
a4f6be86d67ae30d494fbe8a470bc32b715d75a9
0
static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; int alpha = alpha_table[index_a]; int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0*bsi]]; tc[1] = tc0_table[index_a][bS[1*bsi]]; tc[2] = tc0_table[index_a][bS[2*bsi]]; tc[3] = tc0_table[index_a][bS[3*bsi]]; h->h264dsp.h264_h_loop_filter_luma_mbaff(pix, stride, alpha, beta, tc); } else { h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta); } }
19,028
FFmpeg
c89658008705d949c319df3fa6f400c481ad73e1
0
static int rtsp_read_packet(AVFormatContext *s, AVPacket *pkt) { RTSPState *rt = s->priv_data; int ret; RTSPMessageHeader reply1, *reply = &reply1; char cmd[1024]; if (rt->server_type == RTSP_SERVER_REAL) { int i; enum AVDiscard cache[MAX_STREAMS]; for (i = 0; i < s->nb_streams; i++) cache[i] = s->streams[i]->discard; if (!rt->need_subscription) { if (memcmp (cache, rt->real_setup_cache, sizeof(enum AVDiscard) * s->nb_streams)) { av_strlcatf(cmd, sizeof(cmd), "SET_PARAMETER %s RTSP/1.0\r\n" "Unsubscribe: %s\r\n", s->filename, rt->last_subscription); rtsp_send_cmd(s, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 1; } } if (rt->need_subscription) { int r, rule_nr, first = 1; memcpy(rt->real_setup_cache, cache, sizeof(enum AVDiscard) * s->nb_streams); rt->last_subscription[0] = 0; snprintf(cmd, sizeof(cmd), "SET_PARAMETER %s RTSP/1.0\r\n" "Subscribe: ", s->filename); for (i = 0; i < rt->nb_rtsp_streams; i++) { rule_nr = 0; for (r = 0; r < s->nb_streams; r++) { if (s->streams[r]->priv_data == rt->rtsp_streams[i]) { if (s->streams[r]->discard != AVDISCARD_ALL) { if (!first) av_strlcat(rt->last_subscription, ",", sizeof(rt->last_subscription)); ff_rdt_subscribe_rule( rt->last_subscription, sizeof(rt->last_subscription), i, rule_nr); first = 0; } rule_nr++; } } } av_strlcatf(cmd, sizeof(cmd), "%s\r\n", rt->last_subscription); rtsp_send_cmd(s, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 0; if (rt->state == RTSP_STATE_PLAYING) rtsp_read_play (s); } } ret = rtsp_fetch_packet(s, pkt); if (ret < 0) { return ret; } /* send dummy request to keep TCP connection alive */ if ((rt->server_type == RTSP_SERVER_WMS || rt->server_type == RTSP_SERVER_REAL) && (av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) { if (rt->server_type == RTSP_SERVER_WMS) { snprintf(cmd, sizeof(cmd) - 1, "GET_PARAMETER %s RTSP/1.0\r\n", s->filename); rtsp_send_cmd_async(s, cmd, reply, NULL); } else { rtsp_send_cmd_async(s, "OPTIONS * RTSP/1.0\r\n", reply, NULL); } } return 0; }
19,029
FFmpeg
0faf3c3a25ede9ecfdb1cf68a0f8aef23c25197a
0
static int cudaupload_query_formats(AVFilterContext *ctx) { static const enum AVPixelFormat input_pix_fmts[] = { AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE, }; static const enum AVPixelFormat output_pix_fmts[] = { AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE, }; AVFilterFormats *in_fmts = ff_make_format_list(input_pix_fmts); AVFilterFormats *out_fmts = ff_make_format_list(output_pix_fmts); ff_formats_ref(in_fmts, &ctx->inputs[0]->out_formats); ff_formats_ref(out_fmts, &ctx->outputs[0]->in_formats); return 0; }
19,030
FFmpeg
6c18f1cda2e2b2471ebf75d30d552cb0cb61b6ad
0
static void opt_audio_sample_fmt(const char *arg) { if (strcmp(arg, "list")) audio_sample_fmt = av_get_sample_fmt(arg); else { list_fmts(av_get_sample_fmt_string, AV_SAMPLE_FMT_NB); ffmpeg_exit(0); } }
19,032
FFmpeg
e1b0d3a389ff7050c66f43891539200eddf4af15
0
static int wsvqa_read_header(AVFormatContext *s) { WsVqaDemuxContext *wsvqa = s->priv_data; AVIOContext *pb = s->pb; AVStream *st; unsigned char *header; unsigned char scratch[VQA_PREAMBLE_SIZE]; unsigned int chunk_tag; unsigned int chunk_size; int fps; /* initialize the video decoder stream */ st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->start_time = 0; wsvqa->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_WS_VQA; st->codec->codec_tag = 0; /* no fourcc */ /* skip to the start of the VQA header */ avio_seek(pb, 20, SEEK_SET); /* the VQA header needs to go to the decoder */ st->codec->extradata_size = VQA_HEADER_SIZE; st->codec->extradata = av_mallocz(VQA_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); header = (unsigned char *)st->codec->extradata; if (avio_read(pb, st->codec->extradata, VQA_HEADER_SIZE) != VQA_HEADER_SIZE) { av_free(st->codec->extradata); return AVERROR(EIO); } st->codec->width = AV_RL16(&header[6]); st->codec->height = AV_RL16(&header[8]); fps = header[12]; st->nb_frames = st->duration = AV_RL16(&header[4]); if (fps < 1 || fps > 30) { av_log(s, AV_LOG_ERROR, "invalid fps: %d\n", fps); return AVERROR_INVALIDDATA; } avpriv_set_pts_info(st, 64, 1, fps); wsvqa->version = AV_RL16(&header[ 0]); wsvqa->sample_rate = AV_RL16(&header[24]); wsvqa->channels = header[26]; wsvqa->bps = header[27]; wsvqa->audio_stream_index = -1; s->ctx_flags |= AVFMTCTX_NOHEADER; /* there are 0 or more chunks before the FINF chunk; iterate until * FINF has been skipped and the file will be ready to be demuxed */ do { if (avio_read(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) return AVERROR(EIO); chunk_tag = AV_RB32(&scratch[0]); chunk_size = AV_RB32(&scratch[4]); /* catch any unknown header tags, for curiousity */ switch (chunk_tag) { case CINF_TAG: case CINH_TAG: case CIND_TAG: case PINF_TAG: case PINH_TAG: case PIND_TAG: case FINF_TAG: case CMDS_TAG: break; default: av_log (s, AV_LOG_ERROR, " note: unknown chunk seen (%c%c%c%c)\n", scratch[0], scratch[1], scratch[2], scratch[3]); break; } avio_skip(pb, chunk_size); } while (chunk_tag != FINF_TAG); return 0; }
19,033
FFmpeg
01e4537f66c6d054f8c7bdbdd5b3cfb4220d12fe
0
static void flat_print_str(WriterContext *wctx, const char *key, const char *value) { FlatContext *flat = wctx->priv; AVBPrint buf; flat_print_key_prefix(wctx); av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED); printf("%s=", flat_escape_key_str(&buf, key, flat->sep)); av_bprint_clear(&buf); printf("\"%s\"\n", flat_escape_value_str(&buf, value)); av_bprint_finalize(&buf, NULL); }
19,034
FFmpeg
b010d9b58651379883b42e58494aaefbab4df648
0
static int nut_write_packet(AVFormatContext *s, AVPacket *pkt){ NUTContext *nut = s->priv_data; StreamContext *nus= &nut->stream[pkt->stream_index]; AVIOContext *bc = s->pb, *dyn_bc; FrameCode *fc; int64_t coded_pts; int best_length, frame_code, flags, needed_flags, i, header_idx, best_header_idx; int key_frame = !!(pkt->flags & AV_PKT_FLAG_KEY); int store_sp=0; int ret; if(pkt->pts < 0) return -1; if(1LL<<(20+3*nut->header_count) <= avio_tell(bc)) write_headers(s, bc); if(key_frame && !(nus->last_flags & FLAG_KEY)) store_sp= 1; if(pkt->size + 30/*FIXME check*/ + avio_tell(bc) >= nut->last_syncpoint_pos + nut->max_distance) store_sp= 1; //FIXME: Ensure store_sp is 1 in the first place. if(store_sp){ Syncpoint *sp, dummy= {.pos= INT64_MAX}; ff_nut_reset_ts(nut, *nus->time_base, pkt->dts); for(i=0; i<s->nb_streams; i++){ AVStream *st= s->streams[i]; int64_t dts_tb = av_rescale_rnd(pkt->dts, nus->time_base->num * (int64_t)nut->stream[i].time_base->den, nus->time_base->den * (int64_t)nut->stream[i].time_base->num, AV_ROUND_DOWN); int index= av_index_search_timestamp(st, dts_tb, AVSEEK_FLAG_BACKWARD); if(index>=0) dummy.pos= FFMIN(dummy.pos, st->index_entries[index].pos); } if(dummy.pos == INT64_MAX) dummy.pos= 0; sp= av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp, NULL); nut->last_syncpoint_pos= avio_tell(bc); ret = avio_open_dyn_buf(&dyn_bc); if(ret < 0) return ret; put_tt(nut, nus->time_base, dyn_bc, pkt->dts); ff_put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0); put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE); ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0/*unused*/, pkt->dts); } av_assert0(nus->last_pts != AV_NOPTS_VALUE); coded_pts = pkt->pts & ((1<<nus->msb_pts_shift)-1); if(ff_lsb2full(nus, coded_pts) != pkt->pts) coded_pts= pkt->pts + (1<<nus->msb_pts_shift); best_header_idx= find_best_header_idx(nut, pkt); best_length=INT_MAX; frame_code= -1; for(i=0; i<256; i++){ int length= 0; FrameCode *fc= &nut->frame_code[i]; int flags= fc->flags; if(flags & FLAG_INVALID) continue; needed_flags= get_needed_flags(nut, nus, fc, pkt); if(flags & FLAG_CODED){ length++; flags = needed_flags; } if((flags & needed_flags) != needed_flags) continue; if((flags ^ needed_flags) & FLAG_KEY) continue; if(flags & FLAG_STREAM_ID) length+= ff_get_v_length(pkt->stream_index); if(pkt->size % fc->size_mul != fc->size_lsb) continue; if(flags & FLAG_SIZE_MSB) length += ff_get_v_length(pkt->size / fc->size_mul); if(flags & FLAG_CHECKSUM) length+=4; if(flags & FLAG_CODED_PTS) length += ff_get_v_length(coded_pts); if( (flags & FLAG_CODED) && nut->header_len[best_header_idx] > nut->header_len[fc->header_idx]+1){ flags |= FLAG_HEADER_IDX; } if(flags & FLAG_HEADER_IDX){ length += 1 - nut->header_len[best_header_idx]; }else{ length -= nut->header_len[fc->header_idx]; } length*=4; length+= !(flags & FLAG_CODED_PTS); length+= !(flags & FLAG_CHECKSUM); if(length < best_length){ best_length= length; frame_code=i; } } av_assert0(frame_code != -1); fc= &nut->frame_code[frame_code]; flags= fc->flags; needed_flags= get_needed_flags(nut, nus, fc, pkt); header_idx= fc->header_idx; ffio_init_checksum(bc, ff_crc04C11DB7_update, 0); avio_w8(bc, frame_code); if(flags & FLAG_CODED){ ff_put_v(bc, (flags^needed_flags) & ~(FLAG_CODED)); flags = needed_flags; } if(flags & FLAG_STREAM_ID) ff_put_v(bc, pkt->stream_index); if(flags & FLAG_CODED_PTS) ff_put_v(bc, coded_pts); if(flags & FLAG_SIZE_MSB) ff_put_v(bc, pkt->size / fc->size_mul); if(flags & FLAG_HEADER_IDX) ff_put_v(bc, header_idx= best_header_idx); if(flags & FLAG_CHECKSUM) avio_wl32(bc, ffio_get_checksum(bc)); else ffio_get_checksum(bc); avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]); nus->last_flags= flags; nus->last_pts= pkt->pts; //FIXME just store one per syncpoint if(flags & FLAG_KEY) av_add_index_entry( s->streams[pkt->stream_index], nut->last_syncpoint_pos, pkt->pts, 0, 0, AVINDEX_KEYFRAME); return 0; }
19,035
FFmpeg
dc3685e12999f106dd8e576e5b7d5543d4f70fa1
0
ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb, AVStream *st, RMStream *ast, int len, AVPacket *pkt, int *seq, int *flags, int64_t *timestamp) { RMDemuxContext *rm = s->priv_data; if (st->codec->codec_type == CODEC_TYPE_VIDEO) { rm->current_stream= st->id; if(rm_assemble_video_frame(s, pb, rm, ast, pkt, len)) return -1; //got partial frame } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) { if ((st->codec->codec_id == CODEC_ID_RA_288) || (st->codec->codec_id == CODEC_ID_COOK) || (st->codec->codec_id == CODEC_ID_ATRAC3) || (st->codec->codec_id == CODEC_ID_SIPR)) { int x; int sps = ast->sub_packet_size; int cfs = ast->coded_framesize; int h = ast->sub_packet_h; int y = ast->sub_packet_cnt; int w = ast->audio_framesize; if (*flags & 2) y = ast->sub_packet_cnt = 0; if (!y) ast->audiotimestamp = *timestamp; switch(st->codec->codec_id) { case CODEC_ID_RA_288: for (x = 0; x < h/2; x++) get_buffer(pb, ast->pkt.data+x*2*w+y*cfs, cfs); break; case CODEC_ID_ATRAC3: case CODEC_ID_COOK: for (x = 0; x < w/sps; x++) get_buffer(pb, ast->pkt.data+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps); break; } if (++(ast->sub_packet_cnt) < h) return -1; else { ast->sub_packet_cnt = 0; rm->audio_stream_num = st->index; rm->audio_pkt_cnt = h * w / st->codec->block_align - 1; // Release first audio packet av_new_packet(pkt, st->codec->block_align); memcpy(pkt->data, ast->pkt.data, st->codec->block_align); //FIXME avoid this *timestamp = ast->audiotimestamp; *flags = 2; // Mark first packet as keyframe } } else if (st->codec->codec_id == CODEC_ID_AAC) { int x; rm->audio_stream_num = st->index; ast->sub_packet_cnt = (get_be16(pb) & 0xf0) >> 4; if (ast->sub_packet_cnt) { for (x = 0; x < ast->sub_packet_cnt; x++) ast->sub_packet_lengths[x] = get_be16(pb); // Release first audio packet rm->audio_pkt_cnt = ast->sub_packet_cnt - 1; av_get_packet(pb, pkt, ast->sub_packet_lengths[0]); *flags = 2; // Mark first packet as keyframe } } else { av_get_packet(pb, pkt, len); rm_ac3_swap_bytes(st, pkt); } } else av_get_packet(pb, pkt, len); if( (st->discard >= AVDISCARD_NONKEY && !(*flags&2)) || st->discard >= AVDISCARD_ALL){ av_free_packet(pkt); return -1; } pkt->stream_index = st->index; #if 0 if (st->codec->codec_type == CODEC_TYPE_VIDEO) { if(st->codec->codec_id == CODEC_ID_RV20){ int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1); av_log(s, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq); seq |= (*timestamp&~0x3FFF); if(seq - *timestamp > 0x2000) seq -= 0x4000; if(seq - *timestamp < -0x2000) seq += 0x4000; } } #endif pkt->pts= *timestamp; if (*flags & 2) pkt->flags |= PKT_FLAG_KEY; return st->codec->codec_type == CODEC_TYPE_AUDIO ? rm->audio_pkt_cnt : 0; }
19,036
FFmpeg
90a43060077dbbca7ef161a584e95cbc7466264d
0
static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uint8_t *src, int size, int lines){ int c, line, pixels, code; const uint8_t *ssrc = src; int width = ((s->width * s->bpp) + 7) >> 3; #if CONFIG_ZLIB uint8_t *zbuf; unsigned long outlen; if(s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE){ int ret; outlen = width * lines; zbuf = av_malloc(outlen); ret = tiff_uncompress(zbuf, &outlen, src, size); if(ret != Z_OK){ av_log(s->avctx, AV_LOG_ERROR, "Uncompressing failed (%lu of %lu) with error %d\n", outlen, (unsigned long)width * lines, ret); av_free(zbuf); return -1; } src = zbuf; for(line = 0; line < lines; line++){ memcpy(dst, src, width); dst += stride; src += width; } av_free(zbuf); return 0; } #endif if(s->compr == TIFF_LZW){ if(ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF) < 0){ av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n"); return -1; } } if(s->compr == TIFF_CCITT_RLE || s->compr == TIFF_G3 || s->compr == TIFF_G4){ int i, ret = 0; uint8_t *src2 = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); if(!src2 || (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE < (unsigned)size){ av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); return -1; } if(s->fax_opts & 2){ av_log(s->avctx, AV_LOG_ERROR, "Uncompressed fax mode is not supported (yet)\n"); av_free(src2); return -1; } if(!s->fill_order){ memcpy(src2, src, size); }else{ for(i = 0; i < size; i++) src2[i] = av_reverse[src[i]]; } memset(src2+size, 0, FF_INPUT_BUFFER_PADDING_SIZE); switch(s->compr){ case TIFF_CCITT_RLE: case TIFF_G3: case TIFF_G4: ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride, s->compr, s->fax_opts); break; } av_free(src2); return ret; } for(line = 0; line < lines; line++){ if(src - ssrc > size){ av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n"); return -1; } switch(s->compr){ case TIFF_RAW: if (ssrc + size - src < width) return AVERROR_INVALIDDATA; if (!s->fill_order) { memcpy(dst, src, width); } else { int i; for (i = 0; i < width; i++) dst[i] = av_reverse[src[i]]; } src += width; break; case TIFF_PACKBITS: for(pixels = 0; pixels < width;){ code = (int8_t)*src++; if(code >= 0){ code++; if(pixels + code > width){ av_log(s->avctx, AV_LOG_ERROR, "Copy went out of bounds\n"); return -1; } memcpy(dst + pixels, src, code); src += code; pixels += code; }else if(code != -128){ // -127..-1 code = (-code) + 1; if(pixels + code > width){ av_log(s->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return -1; } c = *src++; memset(dst + pixels, c, code); pixels += code; } } break; case TIFF_LZW: pixels = ff_lzw_decode(s->lzw, dst, width); if(pixels < width){ av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n", pixels, width); return -1; } break; } dst += stride; } return 0; }
19,037
FFmpeg
e7a47515abbcf2c8a07c280ea3d04129fc3aaaf6
0
inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc, int flags, const int16_t *hChrFilter, const int16_t *hChrFilterPos, int hChrFilterSize, enum PixelFormat srcFormat, uint8_t *formatConvBuffer, uint32_t *pal) { int32_t av_unused *mmx2FilterPos = c->chrMmx2FilterPos; int16_t av_unused *mmx2Filter = c->chrMmx2Filter; int av_unused canMMX2BeUsed = c->canMMX2BeUsed; void av_unused *mmx2FilterCode= c->chrMmx2FilterCode; if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE) return; src1 += c->chrSrcOffset; src2 += c->chrSrcOffset; if (c->hcscale_internal) { c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } if (!c->hcscale_fast) { c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); } else { // fast bilinear upscale / crap downscale #if ARCH_X86 && CONFIG_GPL #if COMPILE_TEMPLATE_MMX2 int i; #if defined(PIC) DECLARE_ALIGNED(8, uint64_t, ebxsave); #endif if (canMMX2BeUsed) { __asm__ volatile( #if defined(PIC) "mov %%"REG_b", %6 \n\t" #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" // i PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE "xor %%"REG_a", %%"REG_a" \n\t" // i "mov %5, %%"REG_c" \n\t" // src "mov %1, %%"REG_D" \n\t" // buf1 "add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE #if defined(PIC) "mov %6, %%"REG_b" \n\t" #endif :: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), "m" (mmx2FilterCode), "m" (src2) #if defined(PIC) ,"m" (ebxsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) { //printf("%d %d %d\n", dstWidth, i, srcW); dst[i] = src1[srcW-1]*128; dst[i+VOFW] = src2[srcW-1]*128; } } else { #endif /* COMPILE_TEMPLATE_MMX2 */ x86_reg xInc_shr16 = (x86_reg) (xInc >> 16); uint16_t xInc_mask = xInc & 0xffff; __asm__ volatile( "xor %%"REG_a", %%"REG_a" \n\t" // i "xor %%"REG_d", %%"REG_d" \n\t" // xx "xorl %%ecx, %%ecx \n\t" // xalpha ASMALIGN(4) "1: \n\t" "mov %0, %%"REG_S" \n\t" "movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t" //src[xx] "movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t" //src[xx+1] FAST_BILINEAR_X86 "movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t" "movzbl (%5, %%"REG_d"), %%edi \n\t" //src[xx] "movzbl 1(%5, %%"REG_d"), %%esi \n\t" //src[xx+1] FAST_BILINEAR_X86 "movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t" "addw %4, %%cx \n\t" //xalpha += xInc&0xFFFF "adc %3, %%"REG_d" \n\t" //xx+= xInc>>16 + carry "add $1, %%"REG_a" \n\t" "cmp %2, %%"REG_a" \n\t" " jb 1b \n\t" /* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here, which is needed to support GCC 4.0. */ #if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4) :: "m" (src1), "m" (dst), "g" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #else :: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #endif "r" (src2) : "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi" ); #if COMPILE_TEMPLATE_MMX2 } //if MMX2 can't be used #endif #else c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc); #endif /* ARCH_X86 */ } if (c->chrConvertRange) c->chrConvertRange(dst, dstWidth); }
19,038
qemu
65207c59d99f2260c5f1d3b9c491146616a522aa
1
static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd, const QDict *params) { int ret; MonitorCompletionData *cb_data = g_malloc(sizeof(*cb_data)); cb_data->mon = mon; cb_data->user_print = cmd->user_print; monitor_suspend(mon); ret = cmd->mhandler.cmd_async(mon, params, user_monitor_complete, cb_data); if (ret < 0) { monitor_resume(mon); g_free(cb_data); } }
19,039
FFmpeg
56838103020385020469d1da076f0e4a6cbe15e5
1
static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int flags) { uint8_t *buf1; RMMuxContext *rm = s->priv_data; AVIOContext *pb = s->pb; StreamInfo *stream = rm->audio_stream; int i; /* XXX: suppress this malloc */ buf1 = av_malloc(size * sizeof(uint8_t)); write_packet_header(s, stream, size, !!(flags & AV_PKT_FLAG_KEY)); if (stream->enc->codec_id == AV_CODEC_ID_AC3) { /* for AC-3, the words seem to be reversed */ for(i=0;i<size;i+=2) { buf1[i] = buf[i+1]; buf1[i+1] = buf[i]; } avio_write(pb, buf1, size); } else { avio_write(pb, buf, size); } stream->nb_frames++; av_free(buf1); return 0; }
19,040
FFmpeg
4c3e1956ee35fdcc5ffdb28782050164b4623c0b
1
static int lag_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; LagarithContext *l = avctx->priv_data; ThreadFrame frame = { .f = data }; AVFrame *const p = data; uint8_t frametype = 0; uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9; uint32_t offs[4]; uint8_t *srcs[4], *dst; int i, j, planes = 3; p->key_frame = 1; frametype = buf[0]; offset_gu = AV_RL32(buf + 1); offset_bv = AV_RL32(buf + 5); switch (frametype) { case FRAME_SOLID_RGBA: avctx->pix_fmt = AV_PIX_FMT_RGB32; if (ff_thread_get_buffer(avctx, &frame, 0) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } dst = p->data[0]; for (j = 0; j < avctx->height; j++) { for (i = 0; i < avctx->width; i++) AV_WN32(dst + i * 4, offset_gu); dst += p->linesize[0]; } break; case FRAME_ARITH_RGBA: avctx->pix_fmt = AV_PIX_FMT_RGB32; planes = 4; offset_ry += 4; offs[3] = AV_RL32(buf + 9); case FRAME_ARITH_RGB24: case FRAME_U_RGB24: if (frametype == FRAME_ARITH_RGB24 || frametype == FRAME_U_RGB24) avctx->pix_fmt = AV_PIX_FMT_RGB24; if (ff_thread_get_buffer(avctx, &frame, 0) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } offs[0] = offset_bv; offs[1] = offset_gu; offs[2] = offset_ry; if (!l->rgb_planes) { l->rgb_stride = FFALIGN(avctx->width, 16); l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * planes + 1); if (!l->rgb_planes) { av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n"); return AVERROR(ENOMEM); } } for (i = 0; i < planes; i++) srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride; if (offset_ry >= buf_size || offset_gu >= buf_size || offset_bv >= buf_size || (planes == 4 && offs[3] >= buf_size)) { av_log(avctx, AV_LOG_ERROR, "Invalid frame offsets\n"); return AVERROR_INVALIDDATA; } for (i = 0; i < planes; i++) lag_decode_arith_plane(l, srcs[i], avctx->width, avctx->height, -l->rgb_stride, buf + offs[i], buf_size - offs[i]); dst = p->data[0]; for (i = 0; i < planes; i++) srcs[i] = l->rgb_planes + i * l->rgb_stride * avctx->height; for (j = 0; j < avctx->height; j++) { for (i = 0; i < avctx->width; i++) { uint8_t r, g, b, a; r = srcs[0][i]; g = srcs[1][i]; b = srcs[2][i]; r += g; b += g; if (frametype == FRAME_ARITH_RGBA) { a = srcs[3][i]; AV_WN32(dst + i * 4, MKBETAG(a, r, g, b)); } else { dst[i * 3 + 0] = r; dst[i * 3 + 1] = g; dst[i * 3 + 2] = b; } } dst += p->linesize[0]; for (i = 0; i < planes; i++) srcs[i] += l->rgb_stride; } break; case FRAME_ARITH_YUY2: avctx->pix_fmt = AV_PIX_FMT_YUV422P; if (ff_thread_get_buffer(avctx, &frame, 0) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } if (offset_ry >= buf_size || offset_gu >= buf_size || offset_bv >= buf_size) { av_log(avctx, AV_LOG_ERROR, "Invalid frame offsets\n"); return AVERROR_INVALIDDATA; } lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height, p->linesize[0], buf + offset_ry, buf_size - offset_ry); lag_decode_arith_plane(l, p->data[1], avctx->width / 2, avctx->height, p->linesize[1], buf + offset_gu, buf_size - offset_gu); lag_decode_arith_plane(l, p->data[2], avctx->width / 2, avctx->height, p->linesize[2], buf + offset_bv, buf_size - offset_bv); break; case FRAME_ARITH_YV12: avctx->pix_fmt = AV_PIX_FMT_YUV420P; if (ff_thread_get_buffer(avctx, &frame, 0) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } if (offset_ry >= buf_size || offset_gu >= buf_size || offset_bv >= buf_size) { av_log(avctx, AV_LOG_ERROR, "Invalid frame offsets\n"); return AVERROR_INVALIDDATA; } lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height, p->linesize[0], buf + offset_ry, buf_size - offset_ry); lag_decode_arith_plane(l, p->data[2], avctx->width / 2, avctx->height / 2, p->linesize[2], buf + offset_gu, buf_size - offset_gu); lag_decode_arith_plane(l, p->data[1], avctx->width / 2, avctx->height / 2, p->linesize[1], buf + offset_bv, buf_size - offset_bv); break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported Lagarith frame type: %#x\n", frametype); return -1; } *got_frame = 1; return buf_size; }
19,042
qemu
966439a67830239a6c520c5df6c55627b8153c8b
1
void do_divdo (void) { if (likely(!(((int64_t)T0 == INT64_MIN && (int64_t)T1 == -1ULL) || (int64_t)T1 == 0))) { xer_ov = 0; T0 = (int64_t)T0 / (int64_t)T1; } else { xer_so = 1; xer_ov = 1; T0 = (-1ULL) * ((uint64_t)T0 >> 63); } }
19,043
qemu
ba56e4cad41ea2b2fb68d18a632ebc7d4e4b1051
1
void framebuffer_update_display( DisplaySurface *ds, MemoryRegionSection *mem_section, int cols, /* Width in pixels. */ int rows, /* Height in pixels. */ int src_width, /* Length of source line, in bytes. */ int dest_row_pitch, /* Bytes between adjacent horizontal output pixels. */ int dest_col_pitch, /* Bytes between adjacent vertical output pixels. */ int invalidate, /* nonzero to redraw the whole image. */ drawfn fn, void *opaque, int *first_row, /* Input and output. */ int *last_row /* Output only */) { hwaddr src_len; uint8_t *dest; uint8_t *src; int first, last = 0; int dirty; int i; ram_addr_t addr; MemoryRegion *mem; i = *first_row; *first_row = -1; src_len = src_width * rows; mem = mem_section->mr; if (!mem) { return; } memory_region_sync_dirty_bitmap(mem); addr = mem_section->offset_within_region; src = memory_region_get_ram_ptr(mem) + addr; dest = surface_data(ds); if (dest_col_pitch < 0) { dest -= dest_col_pitch * (cols - 1); } if (dest_row_pitch < 0) { dest -= dest_row_pitch * (rows - 1); } first = -1; addr += i * src_width; src += i * src_width; dest += i * dest_row_pitch; for (; i < rows; i++) { dirty = memory_region_get_dirty(mem, addr, src_width, DIRTY_MEMORY_VGA); if (dirty || invalidate) { fn(opaque, dest, src, cols, dest_col_pitch); if (first == -1) first = i; last = i; } addr += src_width; src += src_width; dest += dest_row_pitch; } if (first < 0) { return; } memory_region_reset_dirty(mem, mem_section->offset_within_region, src_len, DIRTY_MEMORY_VGA); *first_row = first; *last_row = last; }
19,044
qemu
4482e05cbbb7e50e476f6a9500cf0b38913bd939
1
SPARCCPU *sparc64_cpu_devinit(const char *cpu_model, const char *default_cpu_model, uint64_t prom_addr) { SPARCCPU *cpu; CPUSPARCState *env; ResetData *reset_info; uint32_t tick_frequency = 100 * 1000000; uint32_t stick_frequency = 100 * 1000000; uint32_t hstick_frequency = 100 * 1000000; if (cpu_model == NULL) { cpu_model = default_cpu_model; } cpu = SPARC_CPU(cpu_generic_init(TYPE_SPARC_CPU, cpu_model)); if (cpu == NULL) { fprintf(stderr, "Unable to find Sparc CPU definition\n"); exit(1); } env = &cpu->env; env->tick = cpu_timer_create("tick", cpu, tick_irq, tick_frequency, TICK_INT_DIS, TICK_NPT_MASK); env->stick = cpu_timer_create("stick", cpu, stick_irq, stick_frequency, TICK_INT_DIS, TICK_NPT_MASK); env->hstick = cpu_timer_create("hstick", cpu, hstick_irq, hstick_frequency, TICK_INT_DIS, TICK_NPT_MASK); reset_info = g_malloc0(sizeof(ResetData)); reset_info->cpu = cpu; reset_info->prom_addr = prom_addr; qemu_register_reset(main_cpu_reset, reset_info); return cpu; }
19,045
FFmpeg
0cb7f8a26094c533b7dbe25897198953b6660f15
1
int ff_lzw_decode(LZWState *p, uint8_t *buf, int len){ int l, c, code, oc, fc; uint8_t *sp; struct LZWState *s = (struct LZWState *)p; if (s->end_code < 0) return 0; l = len; sp = s->sp; oc = s->oc; fc = s->fc; for (;;) { while (sp > s->stack) { *buf++ = *(--sp); if ((--l) == 0) goto the_end; } c = lzw_get_code(s); if (c == s->end_code) { s->end_code = -1; break; } else if (c == s->clear_code) { s->cursize = s->codesize + 1; s->curmask = mask[s->cursize]; s->slot = s->newcodes; s->top_slot = 1 << s->cursize; fc= oc= -1; } else { code = c; if (code >= s->slot) { *sp++ = fc; code = oc; } while (code >= s->newcodes) { *sp++ = s->suffix[code]; code = s->prefix[code]; } *sp++ = code; if (s->slot < s->top_slot && oc>=0) { s->suffix[s->slot] = code; s->prefix[s->slot++] = oc; } fc = code; oc = c; if (s->slot >= s->top_slot - s->extra_slot) { if (s->cursize < LZW_MAXBITS) { s->top_slot <<= 1; s->curmask = mask[++s->cursize]; } } } } the_end: s->sp = sp; s->oc = oc; s->fc = fc; return len - l; }
19,046
FFmpeg
319438e2f206036ee0cddf401dd50f3b2a3ae117
1
void ff_hyscale_fast_mmxext(SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc) { int32_t *filterPos = c->hLumFilterPos; int16_t *filter = c->hLumFilter; void *mmxextFilterCode = c->lumMmxextFilterCode; int i; #if ARCH_X86_64 uint64_t retsave; #else #if defined(PIC) uint64_t ebxsave; #endif #endif __asm__ volatile( #if ARCH_X86_64 "mov -8(%%rsp), %%"FF_REG_a" \n\t" "mov %%"FF_REG_a", %5 \n\t" // retsave #else #if defined(PIC) "mov %%"FF_REG_b", %5 \n\t" // ebxsave #endif #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"FF_REG_c" \n\t" "mov %1, %%"FF_REG_D" \n\t" "mov %2, %%"FF_REG_d" \n\t" "mov %3, %%"FF_REG_b" \n\t" "xor %%"FF_REG_a", %%"FF_REG_a" \n\t" // i PREFETCH" (%%"FF_REG_c") \n\t" PREFETCH" 32(%%"FF_REG_c") \n\t" PREFETCH" 64(%%"FF_REG_c") \n\t" #if ARCH_X86_64 #define CALL_MMXEXT_FILTER_CODE \ "movl (%%"FF_REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "movl (%%"FF_REG_b", %%"FF_REG_a"), %%esi \n\t"\ "add %%"FF_REG_S", %%"FF_REG_c" \n\t"\ "add %%"FF_REG_a", %%"FF_REG_D" \n\t"\ "xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\ #else #define CALL_MMXEXT_FILTER_CODE \ "movl (%%"FF_REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "addl (%%"FF_REG_b", %%"FF_REG_a"), %%"FF_REG_c" \n\t"\ "add %%"FF_REG_a", %%"FF_REG_D" \n\t"\ "xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\ #endif /* ARCH_X86_64 */ CALL_MMXEXT_FILTER_CODE CALL_MMXEXT_FILTER_CODE CALL_MMXEXT_FILTER_CODE CALL_MMXEXT_FILTER_CODE CALL_MMXEXT_FILTER_CODE CALL_MMXEXT_FILTER_CODE CALL_MMXEXT_FILTER_CODE CALL_MMXEXT_FILTER_CODE #if ARCH_X86_64 "mov %5, %%"FF_REG_a" \n\t" "mov %%"FF_REG_a", -8(%%rsp) \n\t" #else #if defined(PIC) "mov %5, %%"FF_REG_b" \n\t" #endif #endif :: "m" (src), "m" (dst), "m" (filter), "m" (filterPos), "m" (mmxextFilterCode) #if ARCH_X86_64 ,"m"(retsave) #else #if defined(PIC) ,"m" (ebxsave) #endif #endif : "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_D #if ARCH_X86_64 || !defined(PIC) ,"%"FF_REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128; }
19,047
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
1
static int get_int32_equal(QEMUFile *f, void *pv, size_t size) { int32_t *v = pv; int32_t v2; qemu_get_sbe32s(f, &v2); if (*v == v2) { return 0; } return -EINVAL; }
19,048
FFmpeg
2caf19e90f270abe1e80a3e85acaf0eb5c9d0aac
1
static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; int stride = _stride/sizeof(pixel); const pixel4 a= ((pixel4*)(src-stride))[0]; ((pixel4*)(src+0*stride))[0]= a; ((pixel4*)(src+1*stride))[0]= a; ((pixel4*)(src+2*stride))[0]= a; ((pixel4*)(src+3*stride))[0]= a; }
19,049
qemu
778358d0a8f74a76488daea3c1b6fb327d8135b4
1
static OfDpaGroup *of_dpa_group_alloc(uint32_t id) { OfDpaGroup *group = g_malloc0(sizeof(OfDpaGroup)); if (!group) { return NULL; } group->id = id; return group; }
19,050
FFmpeg
01ecb7172b684f1c4b3e748f95c5a9a494ca36ec
1
static float get_band_cost_UQUAD_mips(struct AACEncContext *s, PutBitContext *pb, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits) { const float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; int i; float cost = 0; int curbits = 0; int qc1, qc2, qc3, qc4; uint8_t *p_bits = (uint8_t*)ff_aac_spectral_bits[cb-1]; float *p_codes = (float *)ff_aac_codebook_vectors[cb-1]; for (i = 0; i < size; i += 4) { const float *vec; int curidx; float *in_pos = (float *)&in[i]; float di0, di1, di2, di3; int t0, t1, t2, t3, t4; qc1 = scaled[i ] * Q34 + ROUND_STANDARD; qc2 = scaled[i+1] * Q34 + ROUND_STANDARD; qc3 = scaled[i+2] * Q34 + ROUND_STANDARD; qc4 = scaled[i+3] * Q34 + ROUND_STANDARD; __asm__ volatile ( ".set push \n\t" ".set noreorder \n\t" "ori %[t4], $zero, 2 \n\t" "slt %[t0], %[t4], %[qc1] \n\t" "slt %[t1], %[t4], %[qc2] \n\t" "slt %[t2], %[t4], %[qc3] \n\t" "slt %[t3], %[t4], %[qc4] \n\t" "movn %[qc1], %[t4], %[t0] \n\t" "movn %[qc2], %[t4], %[t1] \n\t" "movn %[qc3], %[t4], %[t2] \n\t" "movn %[qc4], %[t4], %[t3] \n\t" ".set pop \n\t" : [qc1]"+r"(qc1), [qc2]"+r"(qc2), [qc3]"+r"(qc3), [qc4]"+r"(qc4), [t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3), [t4]"=&r"(t4) ); curidx = qc1; curidx *= 3; curidx += qc2; curidx *= 3; curidx += qc3; curidx *= 3; curidx += qc4; curbits += p_bits[curidx]; curbits += uquad_sign_bits[curidx]; vec = &p_codes[curidx*4]; __asm__ volatile ( ".set push \n\t" ".set noreorder \n\t" "lwc1 %[di0], 0(%[in_pos]) \n\t" "lwc1 %[di1], 4(%[in_pos]) \n\t" "lwc1 %[di2], 8(%[in_pos]) \n\t" "lwc1 %[di3], 12(%[in_pos]) \n\t" "abs.s %[di0], %[di0] \n\t" "abs.s %[di1], %[di1] \n\t" "abs.s %[di2], %[di2] \n\t" "abs.s %[di3], %[di3] \n\t" "lwc1 $f0, 0(%[vec]) \n\t" "lwc1 $f1, 4(%[vec]) \n\t" "lwc1 $f2, 8(%[vec]) \n\t" "lwc1 $f3, 12(%[vec]) \n\t" "nmsub.s %[di0], %[di0], $f0, %[IQ] \n\t" "nmsub.s %[di1], %[di1], $f1, %[IQ] \n\t" "nmsub.s %[di2], %[di2], $f2, %[IQ] \n\t" "nmsub.s %[di3], %[di3], $f3, %[IQ] \n\t" ".set pop \n\t" : [di0]"=&f"(di0), [di1]"=&f"(di1), [di2]"=&f"(di2), [di3]"=&f"(di3) : [in_pos]"r"(in_pos), [vec]"r"(vec), [IQ]"f"(IQ) : "$f0", "$f1", "$f2", "$f3", "memory" ); cost += di0 * di0 + di1 * di1 + di2 * di2 + di3 * di3; } if (bits) *bits = curbits; return cost * lambda + curbits; }
19,052
qemu
eaa2e027b73c9afca623d877c91150a94c83049d
1
static void sdl_grab_start(void) { /* * If the application is not active, do not try to enter grab state. This * prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the * application (SDL bug). */ if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) { return; } if (guest_cursor) { SDL_SetCursor(guest_sprite); if (!kbd_mouse_is_absolute() && !absolute_enabled) SDL_WarpMouse(guest_x, guest_y); } else sdl_hide_cursor(); if (SDL_WM_GrabInput(SDL_GRAB_ON) == SDL_GRAB_ON) { gui_grab = 1; sdl_update_caption(); } else sdl_show_cursor(); }
19,053
FFmpeg
220b24c7c97dc033ceab1510549f66d0e7b52ef1
1
static void libschroedinger_free_frame(void *data) { FFSchroEncodedFrame *enc_frame = data; av_freep(&enc_frame->p_encbuf); av_free(enc_frame); }
19,054
FFmpeg
01ecb7172b684f1c4b3e748f95c5a9a494ca36ec
1
static float quantize_band_cost(struct AACEncContext *s, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, int rtz) { return get_band_cost(s, NULL, in, scaled, size, scale_idx, cb, lambda, uplim, bits); }
19,055
qemu
898248a32915024a4f01ce4f0c3519509fb703cb
1
static void xhci_er_reset(XHCIState *xhci, int v) { XHCIInterrupter *intr = &xhci->intr[v]; XHCIEvRingSeg seg; if (intr->erstsz == 0) { /* disabled */ intr->er_start = 0; intr->er_size = 0; return; } /* cache the (sole) event ring segment location */ if (intr->erstsz != 1) { DPRINTF("xhci: invalid value for ERSTSZ: %d\n", intr->erstsz); xhci_die(xhci); return; } dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high); pci_dma_read(PCI_DEVICE(xhci), erstba, &seg, sizeof(seg)); le32_to_cpus(&seg.addr_low); le32_to_cpus(&seg.addr_high); le32_to_cpus(&seg.size); if (seg.size < 16 || seg.size > 4096) { DPRINTF("xhci: invalid value for segment size: %d\n", seg.size); xhci_die(xhci); return; } intr->er_start = xhci_addr64(seg.addr_low, seg.addr_high); intr->er_size = seg.size; intr->er_ep_idx = 0; intr->er_pcs = 1; intr->er_full = 0; DPRINTF("xhci: event ring[%d]:" DMA_ADDR_FMT " [%d]\n", v, intr->er_start, intr->er_size); }
19,056
qemu
7474f1be701f136b224af5e1abe55e97dc3f29a5
1
DeviceState *qdev_try_create(BusState *bus, const char *type) { DeviceState *dev; if (object_class_by_name(type) == NULL) { return NULL; } dev = DEVICE(object_new(type)); if (!dev) { return NULL; } if (!bus) { bus = sysbus_get_default(); } qdev_set_parent_bus(dev, bus); object_unref(OBJECT(dev)); return dev; }
19,057
qemu
debfb917a4f9c0784772c86f110f2bcd22e5a14f
1
static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = NULL; struct iscsi_url *iscsi_url = NULL; struct scsi_task *task = NULL; struct scsi_inquiry_standard *inq = NULL; struct scsi_inquiry_supported_pages *inq_vpd; char *initiator_name = NULL; QemuOpts *opts; Error *local_err = NULL; const char *filename; int i, ret; if ((BDRV_SECTOR_SIZE % 512) != 0) { error_setg(errp, "iSCSI: Invalid BDRV_SECTOR_SIZE. " "BDRV_SECTOR_SIZE(%lld) is not a multiple " "of 512", BDRV_SECTOR_SIZE); return -EINVAL; } opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto out; } filename = qemu_opt_get(opts, "filename"); iscsi_url = iscsi_parse_full_url(iscsi, filename); if (iscsi_url == NULL) { error_setg(errp, "Failed to parse URL : %s", filename); ret = -EINVAL; goto out; } memset(iscsilun, 0, sizeof(IscsiLun)); initiator_name = parse_initiator_name(iscsi_url->target); iscsi = iscsi_create_context(initiator_name); if (iscsi == NULL) { error_setg(errp, "iSCSI: Failed to create iSCSI context."); ret = -ENOMEM; goto out; } if (iscsi_set_targetname(iscsi, iscsi_url->target)) { error_setg(errp, "iSCSI: Failed to set target name."); ret = -EINVAL; goto out; } if (iscsi_url->user != NULL) { ret = iscsi_set_initiator_username_pwd(iscsi, iscsi_url->user, iscsi_url->passwd); if (ret != 0) { error_setg(errp, "Failed to set initiator username and password"); ret = -EINVAL; goto out; } } /* check if we got CHAP username/password via the options */ parse_chap(iscsi, iscsi_url->target, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); ret = -EINVAL; goto out; } if (iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL) != 0) { error_setg(errp, "iSCSI: Failed to set session type to normal."); ret = -EINVAL; goto out; } iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); /* check if we got HEADER_DIGEST via the options */ parse_header_digest(iscsi, iscsi_url->target, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); ret = -EINVAL; goto out; } if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, iscsi_url->lun) != 0) { error_setg(errp, "iSCSI: Failed to connect to LUN : %s", iscsi_get_error(iscsi)); ret = -EINVAL; goto out; } iscsilun->iscsi = iscsi; iscsilun->aio_context = bdrv_get_aio_context(bs); iscsilun->lun = iscsi_url->lun; iscsilun->has_write_same = true; task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 0, 0, (void **) &inq, errp); if (task == NULL) { ret = -EINVAL; goto out; } iscsilun->type = inq->periperal_device_type; scsi_free_scsi_task(task); task = NULL; /* Check the write protect flag of the LUN if we want to write */ if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) && iscsi_is_write_protected(iscsilun)) { error_setg(errp, "Cannot open a write protected LUN as read-write"); ret = -EACCES; goto out; } iscsi_readcapacity_sync(iscsilun, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); ret = -EINVAL; goto out; } bs->total_sectors = sector_lun2qemu(iscsilun->num_blocks, iscsilun); bs->request_alignment = iscsilun->block_size; /* We don't have any emulation for devices other than disks and CD-ROMs, so * this must be sg ioctl compatible. We force it to be sg, otherwise qemu * will try to read from the device to guess the image format. */ if (iscsilun->type != TYPE_DISK && iscsilun->type != TYPE_ROM) { bs->sg = 1; } task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, (void **) &inq_vpd, errp); if (task == NULL) { ret = -EINVAL; goto out; } for (i = 0; i < inq_vpd->num_pages; i++) { struct scsi_task *inq_task; struct scsi_inquiry_logical_block_provisioning *inq_lbp; struct scsi_inquiry_block_limits *inq_bl; switch (inq_vpd->pages[i]) { case SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING: inq_task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, (void **) &inq_lbp, errp); if (inq_task == NULL) { ret = -EINVAL; goto out; } memcpy(&iscsilun->lbp, inq_lbp, sizeof(struct scsi_inquiry_logical_block_provisioning)); scsi_free_scsi_task(inq_task); break; case SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS: inq_task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, (void **) &inq_bl, errp); if (inq_task == NULL) { ret = -EINVAL; goto out; } memcpy(&iscsilun->bl, inq_bl, sizeof(struct scsi_inquiry_block_limits)); scsi_free_scsi_task(inq_task); break; default: break; } } scsi_free_scsi_task(task); task = NULL; iscsi_attach_aio_context(bs, iscsilun->aio_context); /* Guess the internal cluster (page) size of the iscsi target by the means * of opt_unmap_gran. Transfer the unmap granularity only if it has a * reasonable size */ if (iscsilun->bl.opt_unmap_gran * iscsilun->block_size >= 4 * 1024 && iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) { iscsilun->cluster_sectors = (iscsilun->bl.opt_unmap_gran * iscsilun->block_size) >> BDRV_SECTOR_BITS; if (iscsilun->lbprz && !(bs->open_flags & BDRV_O_NOCACHE)) { iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun); if (iscsilun->allocationmap == NULL) { ret = -ENOMEM; } } } out: qemu_opts_del(opts); g_free(initiator_name); if (iscsi_url != NULL) { iscsi_destroy_url(iscsi_url); } if (task != NULL) { scsi_free_scsi_task(task); } if (ret) { if (iscsi != NULL) { iscsi_destroy_context(iscsi); } memset(iscsilun, 0, sizeof(IscsiLun)); } return ret; }
19,058
qemu
b981289c493c7ddabc1cdf7de99daa24642c7739
1
type_init(macio_register_types) void macio_init(PCIDevice *d, MemoryRegion *pic_mem, MemoryRegion *escc_mem) { MacIOState *macio_state = MACIO(d); macio_state->pic_mem = pic_mem; macio_state->escc_mem = escc_mem; /* Note: this code is strongly inspirated from the corresponding code in PearPC */ qdev_init_nofail(DEVICE(d)); }
19,059
qemu
6687b79d636cd60ed9adb1177d0d946b58fa7717
1
int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) { const char *name; const char *type; int i; type = qemu_opt_get(opts, "type"); if (!type) { error_set(errp, QERR_MISSING_PARAMETER, "type"); return -1; } if (is_netdev) { if (strcmp(type, "tap") != 0 && #ifdef CONFIG_NET_BRIDGE strcmp(type, "bridge") != 0 && #endif #ifdef CONFIG_SLIRP strcmp(type, "user") != 0 && #endif #ifdef CONFIG_VDE strcmp(type, "vde") != 0 && #endif strcmp(type, "socket") != 0) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a netdev backend type"); return -1; } if (qemu_opt_get(opts, "vlan")) { error_set(errp, QERR_INVALID_PARAMETER, "vlan"); return -1; } if (qemu_opt_get(opts, "name")) { error_set(errp, QERR_INVALID_PARAMETER, "name"); return -1; } if (!qemu_opts_id(opts)) { error_set(errp, QERR_MISSING_PARAMETER, "id"); return -1; } } name = qemu_opts_id(opts); if (!name) { name = qemu_opt_get(opts, "name"); } for (i = 0; i < NET_CLIENT_OPTIONS_KIND_MAX; i++) { if (net_client_types[i].type != NULL && !strcmp(net_client_types[i].type, type)) { Error *local_err = NULL; VLANState *vlan = NULL; int ret; qemu_opts_validate(opts, &net_client_types[i].desc[0], &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); return -1; } /* Do not add to a vlan if it's a -netdev or a nic with a * netdev= parameter. */ if (!(is_netdev || (strcmp(type, "nic") == 0 && qemu_opt_get(opts, "netdev")))) { vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1); } ret = 0; if (net_client_types[i].init) { ret = net_client_types[i].init(opts, name, vlan); if (ret < 0) { /* TODO push error reporting into init() methods */ error_set(errp, QERR_DEVICE_INIT_FAILED, type); return -1; } } return ret; } } error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a network client type"); return -1; }
19,060
qemu
723aedd53281cfa0997457cb156a59909a75f5a8
1
static void usbredir_handle_interrupt_out_data(USBRedirDevice *dev, USBPacket *p, uint8_t ep) { /* Output interrupt endpoint, normal async operation */ struct usb_redir_interrupt_packet_header interrupt_packet; uint8_t buf[p->iov.size]; DPRINTF("interrupt-out ep %02X len %zd id %"PRIu64"\n", ep, p->iov.size, p->id); if (usbredir_already_in_flight(dev, p->id)) { p->status = USB_RET_ASYNC; return; } interrupt_packet.endpoint = ep; interrupt_packet.length = p->iov.size; usb_packet_copy(p, buf, p->iov.size); usbredir_log_data(dev, "interrupt data out:", buf, p->iov.size); usbredirparser_send_interrupt_packet(dev->parser, p->id, &interrupt_packet, buf, p->iov.size); usbredirparser_do_write(dev->parser); p->status = USB_RET_ASYNC; }
19,061
FFmpeg
a5e0dbf530d447f36099aed575b34e9258c5d75a
1
static void push_output_configuration(AACContext *ac) { if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) { ac->oc[0] = ac->oc[1]; } ac->oc[1].status = OC_NONE; }
19,063
FFmpeg
215e197942e33d5c5749d786e938bf7abe856c1d
1
dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, enum dshowDeviceType devtype, IBaseFilter **pfilter) { struct dshow_ctx *ctx = avctx->priv_data; IBaseFilter *device_filter = NULL; IEnumMoniker *classenum = NULL; IMoniker *m = NULL; const char *device_name = ctx->device_name[devtype]; int r; const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory, &CLSID_AudioInputDeviceCategory }; const char *devtypename = (devtype == VideoDevice) ? "video" : "audio"; r = ICreateDevEnum_CreateClassEnumerator(devenum, device_guid[devtype], (IEnumMoniker **) &classenum, 0); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not enumerate %s devices.\n", devtypename); return AVERROR(EIO); } while (IEnumMoniker_Next(classenum, 1, &m, NULL) == S_OK && !device_filter) { IPropertyBag *bag = NULL; char *buf = NULL; VARIANT var; r = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (void *) &bag); if (r != S_OK) goto fail1; var.vt = VT_BSTR; r = IPropertyBag_Read(bag, L"FriendlyName", &var, NULL); if (r != S_OK) goto fail1; buf = dup_wchar_to_utf8(var.bstrVal); if (pfilter) { if (strcmp(device_name, buf)) goto fail1; IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter); } else { av_log(avctx, AV_LOG_INFO, " \"%s\"\n", buf); } fail1: if (buf) av_free(buf); if (bag) IPropertyBag_Release(bag); IMoniker_Release(m); } IEnumMoniker_Release(classenum); if (pfilter) { if (!device_filter) { av_log(avctx, AV_LOG_ERROR, "Could not find %s device.\n", devtypename); return AVERROR(EIO); } *pfilter = device_filter; } return 0; }
19,064
FFmpeg
ac424b23e404a53bb88e36496fac94d2ff9dd775
1
pp_context *pp_get_context(int width, int height, int cpuCaps){ PPContext *c= av_mallocz(sizeof(PPContext)); int stride= FFALIGN(width, 16); //assumed / will realloc if needed int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed c->av_class = &av_codec_context_class; if(cpuCaps&PP_FORMAT){ c->hChromaSubSample= cpuCaps&0x3; c->vChromaSubSample= (cpuCaps>>4)&0x3; }else{ c->hChromaSubSample= 1; c->vChromaSubSample= 1; } if (cpuCaps & PP_CPU_CAPS_AUTO) { c->cpuCaps = av_get_cpu_flags(); } else { c->cpuCaps = 0; if (cpuCaps & PP_CPU_CAPS_MMX) c->cpuCaps |= AV_CPU_FLAG_MMX; if (cpuCaps & PP_CPU_CAPS_MMX2) c->cpuCaps |= AV_CPU_FLAG_MMXEXT; if (cpuCaps & PP_CPU_CAPS_3DNOW) c->cpuCaps |= AV_CPU_FLAG_3DNOW; if (cpuCaps & PP_CPU_CAPS_ALTIVEC) c->cpuCaps |= AV_CPU_FLAG_ALTIVEC; } reallocBuffers(c, width, height, stride, qpStride); c->frameNum=-1; return c; }
19,066
FFmpeg
e07c82688e8187dbafac489b7c15427252974021
1
static void store_slice_c(uint8_t *dst, const int16_t *src, int dst_stride, int src_stride, int width, int height, int log2_scale) { int y, x; #define STORE(pos) do { \ temp = ((src[x + y * src_stride + pos] << log2_scale) + d[pos]) >> 8; \ if (temp & 0x100) temp = ~(temp >> 31); \ dst[x + y * dst_stride + pos] = temp; \ } while (0) for (y = 0; y < height; y++) { const uint8_t *d = dither[y&7]; for (x = 0; x < width; x += 8) { int temp; STORE(0); STORE(1); STORE(2); STORE(3); STORE(4); STORE(5); STORE(6); STORE(7); } } }
19,067
qemu
c9ad19c57b4e35dda507ec636443069048a4ad72
1
void helper_fxtract(void) { CPU86_LDoubleU temp; unsigned int expdif; temp.d = ST0; expdif = EXPD(temp) - EXPBIAS; /*DP exponent bias*/ ST0 = expdif; fpush(); BIASEXPONENT(temp); ST0 = temp.d; }
19,068
qemu
5c6c0e513600ba57c3e73b7151d3c0664438f7b5
1
static void usb_msd_cancel_io(USBPacket *p, void *opaque) { MSDState *s = opaque; s->scsi_dev->info->cancel_io(s->scsi_dev, s->tag); s->packet = NULL; s->scsi_len = 0; }
19,069
qemu
5f758366c0710d23e43f4d0f83816b98616a13d0
1
static CharDriverState *qmp_chardev_open_udp(ChardevUdp *udp, Error **errp) { int fd; fd = socket_dgram(udp->remote, udp->local, errp); if (error_is_set(errp)) { return NULL; } return qemu_chr_open_udp_fd(fd); }
19,070
FFmpeg
f6774f905fb3cfdc319523ac640be30b14c1bc55
1
static av_always_inline void MPV_motion_internal(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16], int is_mpeg12) { int i; int mb_y = s->mb_y; prefetch_motion(s, ref_picture, dir); if (!is_mpeg12 && s->obmc && s->pict_type != AV_PICTURE_TYPE_B) { apply_obmc(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op); return; } switch (s->mv_type) { case MV_TYPE_16X16: if (s->mcsel) { if (s->real_sprite_warping_points == 1) { gmc1_motion(s, dest_y, dest_cb, dest_cr, ref_picture); } else { gmc_motion(s, dest_y, dest_cb, dest_cr, ref_picture); } } else if (!is_mpeg12 && s->quarter_sample) { qpel_motion(s, dest_y, dest_cb, dest_cr, 0, 0, 0, ref_picture, pix_op, qpix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16); } else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) && s->mspel && s->codec_id == AV_CODEC_ID_WMV2) { ff_mspel_motion(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16); } else { mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y); } break; case MV_TYPE_8X8: if (!is_mpeg12) apply_8x8(s, dest_y, dest_cb, dest_cr, dir, ref_picture, qpix_op, pix_op); break; case MV_TYPE_FIELD: if (s->picture_structure == PICT_FRAME) { if (!is_mpeg12 && s->quarter_sample) { for (i = 0; i < 2; i++) qpel_motion(s, dest_y, dest_cb, dest_cr, 1, i, s->field_select[dir][i], ref_picture, pix_op, qpix_op, s->mv[dir][i][0], s->mv[dir][i][1], 8); } else { /* top field */ mpeg_motion_field(s, dest_y, dest_cb, dest_cr, 0, s->field_select[dir][0], ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y); /* bottom field */ mpeg_motion_field(s, dest_y, dest_cb, dest_cr, 1, s->field_select[dir][1], ref_picture, pix_op, s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y); } } else { if (s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) { ref_picture = s->current_picture_ptr->f.data; } mpeg_motion(s, dest_y, dest_cb, dest_cr, s->field_select[dir][0], ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y >> 1); } break; case MV_TYPE_16X8: for (i = 0; i < 2; i++) { uint8_t **ref2picture; if (s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == AV_PICTURE_TYPE_B || s->first_field) { ref2picture = ref_picture; } else { ref2picture = s->current_picture_ptr->f.data; } mpeg_motion(s, dest_y, dest_cb, dest_cr, s->field_select[dir][i], ref2picture, pix_op, s->mv[dir][i][0], s->mv[dir][i][1] + 16 * i, 8, mb_y >> 1); dest_y += 16 * s->linesize; dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize; dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize; } break; case MV_TYPE_DMV: if (s->picture_structure == PICT_FRAME) { for (i = 0; i < 2; i++) { int j; for (j = 0; j < 2; j++) mpeg_motion_field(s, dest_y, dest_cb, dest_cr, j, j ^ i, ref_picture, pix_op, s->mv[dir][2 * i + j][0], s->mv[dir][2 * i + j][1], 8, mb_y); pix_op = s->hdsp.avg_pixels_tab; } } else { for (i = 0; i < 2; i++) { mpeg_motion(s, dest_y, dest_cb, dest_cr, s->picture_structure != i + 1, ref_picture, pix_op, s->mv[dir][2 * i][0], s->mv[dir][2 * i][1], 16, mb_y >> 1); // after put we make avg of the same block pix_op = s->hdsp.avg_pixels_tab; /* opposite parity is always in the same frame if this is * second field */ if (!s->first_field) { ref_picture = s->current_picture_ptr->f.data; } } } break; default: assert(0); } }
19,071
FFmpeg
95fee70d6773fde1c34ff6422f48e5e66f37f263
1
static av_cold int imc_decode_init(AVCodecContext * avctx) { int i, j; IMCContext *q = avctx->priv_data; double r1, r2; q->decoder_reset = 1; for(i = 0; i < BANDS; i++) q->old_floor[i] = 1.0; /* Build mdct window, a simple sine window normalized with sqrt(2) */ ff_sine_window_init(q->mdct_sine_window, COEFFS); for(i = 0; i < COEFFS; i++) q->mdct_sine_window[i] *= sqrt(2.0); for(i = 0; i < COEFFS/2; i++){ q->post_cos[i] = (1.0f / 32768) * cos(i / 256.0 * M_PI); q->post_sin[i] = (1.0f / 32768) * sin(i / 256.0 * M_PI); r1 = sin((i * 4.0 + 1.0) / 1024.0 * M_PI); r2 = cos((i * 4.0 + 1.0) / 1024.0 * M_PI); if (i & 0x1) { q->pre_coef1[i] = (r1 + r2) * sqrt(2.0); q->pre_coef2[i] = -(r1 - r2) * sqrt(2.0); } else { q->pre_coef1[i] = -(r1 + r2) * sqrt(2.0); q->pre_coef2[i] = (r1 - r2) * sqrt(2.0); } q->last_fft_im[i] = 0; } /* Generate a square root table */ for(i = 0; i < 30; i++) { q->sqrt_tab[i] = sqrt(i); } /* initialize the VLC tables */ for(i = 0; i < 4 ; i++) { for(j = 0; j < 4; j++) { huffman_vlc[i][j].table = &vlc_tables[vlc_offsets[i * 4 + j]]; huffman_vlc[i][j].table_allocated = vlc_offsets[i * 4 + j + 1] - vlc_offsets[i * 4 + j]; init_vlc(&huffman_vlc[i][j], 9, imc_huffman_sizes[i], imc_huffman_lens[i][j], 1, 1, imc_huffman_bits[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC); } } q->one_div_log2 = 1/log(2); ff_fft_init(&q->fft, 7, 1); dsputil_init(&q->dsp, avctx); avctx->sample_fmt = AV_SAMPLE_FMT_FLT; avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; return 0; }
19,072
FFmpeg
aa3c77998404cc32233cb76e961ca27db8565459
1
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size) { int ret; int old_size; if (!pkt->size) return av_get_packet(s, pkt, size); old_size = pkt->size; ret = av_grow_packet(pkt, size); if (ret < 0) return ret; ret = avio_read(s, pkt->data + old_size, size); av_shrink_packet(pkt, old_size + FFMAX(ret, 0)); return ret; }
19,073
FFmpeg
8bedbb82cee4463a43e60eb22674c8bf927280ef
1
int ff_j2k_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy, AVCodecContext *avctx) { uint8_t log2_band_prec_width, log2_band_prec_height; int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1; if (ret=ff_jpeg2000_dwt_init(&comp->dwt, comp->coord, codsty->nreslevels2decode-1, codsty->transform)) return ret; for (i = 0; i < 2; i++) csize *= comp->coord[i][1] - comp->coord[i][0]; comp->data = av_malloc_array(csize, sizeof(*comp->data)); if (!comp->data) return AVERROR(ENOMEM); comp->reslevel = av_malloc_array(codsty->nreslevels, sizeof(*comp->reslevel)); if (!comp->reslevel) return AVERROR(ENOMEM); /* LOOP on resolution levels */ for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) { int declvl = codsty->nreslevels - reslevelno; // N_L -r see ISO/IEC 15444-1:2002 B.5 Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno; /* Compute borders for each resolution level. * Computation of trx_0, trx_1, try_0 and try_1. * see ISO/IEC 15444-1:2002 eq. B.5 and B-14 */ for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) reslevel->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1); // update precincts size: 2^n value reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno]; reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno]; /* Number of bands for each resolution level */ if (reslevelno == 0) reslevel->nbands = 1; else reslevel->nbands = 3; /* Number of precincts wich span the tile for resolution level reslevelno * see B.6 in ISO/IEC 15444-1:2002 eq. B-16 * num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -| - (trx_0 / 2 ^ log2_prec_width) * num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| - (try_0 / 2 ^ log2_prec_width) * for Dcinema profiles in JPEG 2000 * num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -| * num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| */ if (reslevel->coord[0][1] == reslevel->coord[0][0]) reslevel->num_precincts_x = 0; else reslevel->num_precincts_x = ff_jpeg2000_ceildivpow2(reslevel->coord[0][1], reslevel->log2_prec_width) - (reslevel->coord[0][0] >> reslevel->log2_prec_width); if (reslevel->coord[1][1] == reslevel->coord[1][0]) reslevel->num_precincts_y = 0; else reslevel->num_precincts_y = ff_jpeg2000_ceildivpow2(reslevel->coord[1][1], reslevel->log2_prec_height) - (reslevel->coord[1][0] >> reslevel->log2_prec_height); reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band)); if (!reslevel->band) return AVERROR(ENOMEM); for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) { Jpeg2000Band *band = reslevel->band + bandno; int cblkno, precno; int nb_precincts; /* TODO: Implementation of quantization step not finished, * see ISO/IEC 15444-1:2002 E.1 and A.6.4. */ switch (qntsty->quantsty) { uint8_t gain; int numbps; case JPEG2000_QSTY_NONE: /* TODO: to verify. No quantization in this case */ band->f_stepsize = 1; break; case JPEG2000_QSTY_SI: /*TODO: Compute formula to implement. */ numbps = cbps + lut_gain[codsty->transform == FF_DWT53][bandno + (reslevelno > 0)]; band->f_stepsize = SHL(2048 + qntsty->mant[gbandno], 2 + numbps - qntsty->expn[gbandno]); break; case JPEG2000_QSTY_SE: /* Exponent quantization step. * Formula: * delta_b = 2 ^ (R_b - expn_b) * (1 + (mant_b / 2 ^ 11)) * R_b = R_I + log2 (gain_b ) * see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */ /* TODO/WARN: value of log2 (gain_b ) not taken into account * but it works (compared to OpenJPEG). Why? * Further investigation needed. */ gain = cbps; band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]); band->f_stepsize *= (qntsty->mant[gbandno] / 2048.0 + 1.0); break; default: band->f_stepsize = 0; av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n"); break; } /* FIXME: In openjepg code stespize = stepsize * 0.5. Why? * If not set output of entropic decoder is not correct. */ if (!av_codec_is_encoder(avctx->codec)) band->f_stepsize *= 0.5; band->i_stepsize = band->f_stepsize * (1 << 16); /* computation of tbx_0, tbx_1, tby_0, tby_1 * see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1 * codeblock width and height is computed for * DCI JPEG 2000 codeblock_width = codeblock_width = 32 = 2 ^ 5 */ if (reslevelno == 0) { /* for reslevelno = 0, only one band, x0_b = y0_b = 0 */ for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0], declvl - 1); log2_band_prec_width = reslevel->log2_prec_width; log2_band_prec_height = reslevel->log2_prec_height; /* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */ band->log2_cblk_width = FFMIN(codsty->log2_cblk_width, reslevel->log2_prec_width); band->log2_cblk_height = FFMIN(codsty->log2_cblk_height, reslevel->log2_prec_height); } else { /* 3 bands x0_b = 1 y0_b = 0; x0_b = 0 y0_b = 1; x0_b = y0_b = 1 */ /* x0_b and y0_b are computed with ((bandno + 1 >> i) & 1) */ for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) /* Formula example for tbx_0 = ceildiv((tcx_0 - 2 ^ (declvl - 1) * x0_b) / declvl) */ band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0] - (((bandno + 1 >> i) & 1) << declvl - 1), declvl); /* TODO: Manage case of 3 band offsets here or * in coding/decoding function? */ /* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */ band->log2_cblk_width = FFMIN(codsty->log2_cblk_width, reslevel->log2_prec_width - 1); band->log2_cblk_height = FFMIN(codsty->log2_cblk_height, reslevel->log2_prec_height - 1); log2_band_prec_width = reslevel->log2_prec_width - 1; log2_band_prec_height = reslevel->log2_prec_height - 1; } for (j = 0; j < 2; j++) band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx); for (j = 0; j < 2; j++) band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy); band->prec = av_malloc_array(reslevel->num_precincts_x * reslevel->num_precincts_y, sizeof(*band->prec)); if (!band->prec) return AVERROR(ENOMEM); nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y; for (precno = 0; precno < nb_precincts; precno++) { Jpeg2000Prec *prec = band->prec + precno; /* TODO: Explain formula for JPEG200 DCINEMA. */ /* TODO: Verify with previous count of codeblocks per band */ /* Compute P_x0 */ prec->coord[0][0] = (precno % reslevel->num_precincts_x) * (1 << log2_band_prec_width); prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]); /* Compute P_y0 */ prec->coord[1][0] = (precno / reslevel->num_precincts_x) * (1 << log2_band_prec_height); prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]); /* Compute P_x1 */ prec->coord[0][1] = prec->coord[0][0] + (1 << log2_band_prec_width); prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]); /* Compute P_y1 */ prec->coord[1][1] = prec->coord[1][0] + (1 << log2_band_prec_height); prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]); prec->nb_codeblocks_width = ff_jpeg2000_ceildivpow2(prec->coord[0][1] - prec->coord[0][0], band->log2_cblk_width); prec->nb_codeblocks_height = ff_jpeg2000_ceildivpow2(prec->coord[1][1] - prec->coord[1][0], band->log2_cblk_height); /* Tag trees initialization */ prec->cblkincl = ff_j2k_tag_tree_init(prec->nb_codeblocks_width, prec->nb_codeblocks_height); if (!prec->cblkincl) return AVERROR(ENOMEM); prec->zerobits = ff_j2k_tag_tree_init(prec->nb_codeblocks_width, prec->nb_codeblocks_height); if (!prec->zerobits) return AVERROR(ENOMEM); prec->cblk = av_malloc_array(prec->nb_codeblocks_width * prec->nb_codeblocks_height, sizeof(*prec->cblk)); if (!prec->cblk) return AVERROR(ENOMEM); for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) { Jpeg2000Cblk *cblk = prec->cblk + cblkno; uint16_t Cx0, Cy0; /* Compute coordinates of codeblocks */ /* Compute Cx0*/ Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width; Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width); cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]); /* Compute Cy0*/ Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height; Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height); cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]); /* Compute Cx1 */ cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width), prec->coord[0][1]); /* Compute Cy1 */ cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height), prec->coord[1][1]); if((bandno + !!reslevelno) & 1) { cblk->coord[0][0] += comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0]; cblk->coord[0][1] += comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0]; } if((bandno + !!reslevelno) & 2) { cblk->coord[1][0] += comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0]; cblk->coord[1][1] += comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0]; } cblk->zero = 0; cblk->lblock = 3; cblk->length = 0; cblk->lengthinc = 0; cblk->npasses = 0; } } } } return 0; }
19,074
qemu
4ae4b609ee2d5bcc9df6c03c21dc1fed527aada1
1
static void gen_stx(DisasContext *dc, uint32_t code, uint32_t flags) { I_TYPE(instr, code); TCGv val = load_gpr(dc, instr.b); TCGv addr = tcg_temp_new(); tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s); tcg_gen_qemu_st_tl(val, addr, dc->mem_idx, flags); tcg_temp_free(addr); }
19,076
FFmpeg
f92f4935acd7d974adfd1deebdf1bb06cbe107ca
1
static void down_heap(uint32_t nr_heap, uint32_t *heap, uint32_t *weights) { uint32_t val = 1; uint32_t val2; uint32_t initial_val = heap[val]; while (1) { val2 = val << 1; if (val2 > nr_heap) break; if (val2 < nr_heap && weights[heap[val2 + 1]] < weights[heap[val2]]) val2++; if (weights[initial_val] < weights[heap[val2]]) break; heap[val] = heap[val2]; val = val2; } heap[val] = initial_val; }
19,077
FFmpeg
d7e9533aa06f4073a27812349b35ba5fede11ca1
1
static void dct_unquantize_mpeg1_mmx(MpegEncContext *s, DCTELEM *block, int n, int qscale) { int nCoeffs; const UINT16 *quant_matrix; if(s->alternate_scan) nCoeffs= 64; else nCoeffs= nCoeffs= zigzag_end[ s->block_last_index[n] ]; if (s->mb_intra) { int block0; if (n < 4) block0 = block[0] * s->y_dc_scale; else block0 = block[0] * s->c_dc_scale; /* XXX: only mpeg1 */ quant_matrix = s->intra_matrix; asm volatile( "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $15, %%mm7 \n\t" "movd %2, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "movl %3, %%eax \n\t" ".balign 16\n\t" "1: \n\t" "movq (%0, %%eax), %%mm0 \n\t" "movq 8(%0, %%eax), %%mm1 \n\t" "movq (%1, %%eax), %%mm4 \n\t" "movq 8(%1, %%eax), %%mm5 \n\t" "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] "pxor %%mm2, %%mm2 \n\t" "pxor %%mm3, %%mm3 \n\t" "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q "pxor %%mm4, %%mm4 \n\t" "pxor %%mm5, %%mm5 \n\t" // FIXME slow "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 "psraw $3, %%mm0 \n\t" "psraw $3, %%mm1 \n\t" "psubw %%mm7, %%mm0 \n\t" "psubw %%mm7, %%mm1 \n\t" "por %%mm7, %%mm0 \n\t" "por %%mm7, %%mm1 \n\t" "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm3, %%mm1 \n\t" "pandn %%mm0, %%mm4 \n\t" "pandn %%mm1, %%mm5 \n\t" "movq %%mm4, (%0, %%eax) \n\t" "movq %%mm5, 8(%0, %%eax) \n\t" "addl $16, %%eax \n\t" "js 1b \n\t" ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) : "%eax", "memory" ); block[0]= block0; } else { quant_matrix = s->non_intra_matrix; asm volatile( "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $15, %%mm7 \n\t" "movd %2, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "movl %3, %%eax \n\t" ".balign 16\n\t" "1: \n\t" "movq (%0, %%eax), %%mm0 \n\t" "movq 8(%0, %%eax), %%mm1 \n\t" "movq (%1, %%eax), %%mm4 \n\t" "movq 8(%1, %%eax), %%mm5 \n\t" "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] "pxor %%mm2, %%mm2 \n\t" "pxor %%mm3, %%mm3 \n\t" "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) "paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2 "paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2 "paddw %%mm7, %%mm0 \n\t" // abs(block[i])*2 + 1 "paddw %%mm7, %%mm1 \n\t" // abs(block[i])*2 + 1 "pmullw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q "pmullw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q "pxor %%mm4, %%mm4 \n\t" "pxor %%mm5, %%mm5 \n\t" // FIXME slow "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 "psraw $4, %%mm0 \n\t" "psraw $4, %%mm1 \n\t" "psubw %%mm7, %%mm0 \n\t" "psubw %%mm7, %%mm1 \n\t" "por %%mm7, %%mm0 \n\t" "por %%mm7, %%mm1 \n\t" "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm3, %%mm1 \n\t" "pandn %%mm0, %%mm4 \n\t" "pandn %%mm1, %%mm5 \n\t" "movq %%mm4, (%0, %%eax) \n\t" "movq %%mm5, 8(%0, %%eax) \n\t" "addl $16, %%eax \n\t" "js 1b \n\t" ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) : "%eax", "memory" ); } }
19,078
FFmpeg
571572fcddc16ebe3d60054ae5a2db05800c1d6d
1
void RENAME(ff_init_mpadsp_tabs)(void) { int i, j; /* compute mdct windows */ for (i = 0; i < 36; i++) { for (j = 0; j < 4; j++) { double d; if (j == 2 && i % 3 != 1) continue; d = sin(M_PI * (i + 0.5) / 36.0); if (j == 1) { if (i >= 30) d = 0; else if (i >= 24) d = sin(M_PI * (i - 18 + 0.5) / 12.0); else if (i >= 18) d = 1; } else if (j == 3) { if (i < 6) d = 0; else if (i < 12) d = sin(M_PI * (i - 6 + 0.5) / 12.0); else if (i < 18) d = 1; } //merge last stage of imdct into the window coefficients d *= 0.5 / cos(M_PI * (2 * i + 19) / 72); if (j == 2) RENAME(ff_mdct_win)[j][i/3] = FIXHR((d / (1<<5))); else { int idx = i < 18 ? i : i + (MDCT_BUF_SIZE/2 - 18); RENAME(ff_mdct_win)[j][idx] = FIXHR((d / (1<<5))); } } } /* NOTE: we do frequency inversion adter the MDCT by changing the sign of the right window coefs */ for (j = 0; j < 4; j++) { for (i = 0; i < MDCT_BUF_SIZE; i += 2) { RENAME(ff_mdct_win)[j + 4][i ] = RENAME(ff_mdct_win)[j][i ]; RENAME(ff_mdct_win)[j + 4][i + 1] = -RENAME(ff_mdct_win)[j][i + 1]; } } }
19,079
qemu
857d4f46c31d2f4d57d2f0fad9dfb584262bf9b9
1
static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { /* Perform I/O through a temporary buffer so that users who scribble over * their read buffer while the operation is in progress do not end up * modifying the image file. This is critical for zero-copy guest I/O * where anything might happen inside guest memory. */ void *bounce_buffer; BlockDriver *drv = bs->drv; struct iovec iov; QEMUIOVector bounce_qiov; int64_t cluster_sector_num; int cluster_nb_sectors; size_t skip_bytes; int ret; /* Cover entire cluster so no additional backing file I/O is required when * allocating cluster in the image file. */ bdrv_round_to_clusters(bs, sector_num, nb_sectors, &cluster_sector_num, &cluster_nb_sectors); trace_bdrv_co_do_copy_on_readv(bs, sector_num, nb_sectors, cluster_sector_num, cluster_nb_sectors); iov.iov_len = cluster_nb_sectors * BDRV_SECTOR_SIZE; iov.iov_base = bounce_buffer = qemu_blockalign(bs, iov.iov_len); qemu_iovec_init_external(&bounce_qiov, &iov, 1); ret = drv->bdrv_co_readv(bs, cluster_sector_num, cluster_nb_sectors, &bounce_qiov); if (ret < 0) { goto err; } if (drv->bdrv_co_write_zeroes && buffer_is_zero(bounce_buffer, iov.iov_len)) { ret = bdrv_co_do_write_zeroes(bs, cluster_sector_num, cluster_nb_sectors, 0); } else { /* This does not change the data on the disk, it is not necessary * to flush even in cache=writethrough mode. */ ret = drv->bdrv_co_writev(bs, cluster_sector_num, cluster_nb_sectors, &bounce_qiov); } if (ret < 0) { /* It might be okay to ignore write errors for guest requests. If this * is a deliberate copy-on-read then we don't want to ignore the error. * Simply report it in all cases. */ goto err; } skip_bytes = (sector_num - cluster_sector_num) * BDRV_SECTOR_SIZE; qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes, nb_sectors * BDRV_SECTOR_SIZE); err: qemu_vfree(bounce_buffer); return ret; }
19,080
qemu
d3f8e138c23ba082f87c96634d06b978473c1e9b
1
static int local_create_mapped_attr_dir(FsContext *ctx, const char *path) { int err; char attr_dir[PATH_MAX]; char *tmp_path = strdup(path); snprintf(attr_dir, PATH_MAX, "%s/%s/%s", ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR); err = mkdir(attr_dir, 0700); if (err < 0 && errno == EEXIST) { err = 0; } free(tmp_path); return err; }
19,081
qemu
af7e9e74c6a62a5bcd911726a9e88d28b61490e0
1
static int openpic_init(SysBusDevice *dev) { OpenPICState *opp = FROM_SYSBUS(typeof (*opp), dev); int i, j; struct memreg list_le[] = { {"glb", &openpic_glb_ops_le, true, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE}, {"tmr", &openpic_tmr_ops_le, true, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE}, {"msi", &openpic_msi_ops_le, true, OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE}, {"src", &openpic_src_ops_le, true, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE}, {"cpu", &openpic_cpu_ops_le, true, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE}, }; struct memreg list_be[] = { {"glb", &openpic_glb_ops_be, true, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE}, {"tmr", &openpic_tmr_ops_be, true, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE}, {"msi", &openpic_msi_ops_be, true, OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE}, {"src", &openpic_src_ops_be, true, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE}, {"cpu", &openpic_cpu_ops_be, true, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE}, }; struct memreg *list; switch (opp->model) { case OPENPIC_MODEL_FSL_MPIC_20: default: opp->flags |= OPENPIC_FLAG_IDE_CRIT; opp->nb_irqs = 80; opp->vid = VID_REVISION_1_2; opp->veni = VENI_GENERIC; opp->vector_mask = 0xFFFF; opp->tifr_reset = 0; opp->ipvp_reset = IPVP_MASK_MASK; opp->ide_reset = 1 << 0; opp->max_irq = FSL_MPIC_20_MAX_IRQ; opp->irq_ipi0 = FSL_MPIC_20_IPI_IRQ; opp->irq_tim0 = FSL_MPIC_20_TMR_IRQ; opp->irq_msi = FSL_MPIC_20_MSI_IRQ; opp->brr1 = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN; msi_supported = true; list = list_be; break; case OPENPIC_MODEL_RAVEN: opp->nb_irqs = RAVEN_MAX_EXT; opp->vid = VID_REVISION_1_3; opp->veni = VENI_GENERIC; opp->vector_mask = 0xFF; opp->tifr_reset = 4160000; opp->ipvp_reset = IPVP_MASK_MASK | IPVP_MODE_MASK; opp->ide_reset = 0; opp->max_irq = RAVEN_MAX_IRQ; opp->irq_ipi0 = RAVEN_IPI_IRQ; opp->irq_tim0 = RAVEN_TMR_IRQ; opp->brr1 = -1; list = list_le; /* Don't map MSI region */ list[2].map = false; /* Only UP supported today */ if (opp->nb_cpus != 1) { return -EINVAL; } break; } memory_region_init(&opp->mem, "openpic", 0x40000); for (i = 0; i < ARRAY_SIZE(list_le); i++) { if (!list[i].map) { continue; } memory_region_init_io(&opp->sub_io_mem[i], list[i].ops, opp, list[i].name, list[i].size); memory_region_add_subregion(&opp->mem, list[i].start_addr, &opp->sub_io_mem[i]); } for (i = 0; i < opp->nb_cpus; i++) { opp->dst[i].irqs = g_new(qemu_irq, OPENPIC_OUTPUT_NB); for (j = 0; j < OPENPIC_OUTPUT_NB; j++) { sysbus_init_irq(dev, &opp->dst[i].irqs[j]); } } register_savevm(&opp->busdev.qdev, "openpic", 0, 2, openpic_save, openpic_load, opp); sysbus_init_mmio(dev, &opp->mem); qdev_init_gpio_in(&dev->qdev, openpic_set_irq, opp->max_irq); return 0; }
19,083
FFmpeg
1255eed533b4069db7f205601953ca54c0dc42c9
1
static int tgq_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt){ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; const uint8_t *buf_start = buf; const uint8_t *buf_end = buf + buf_size; TgqContext *s = avctx->priv_data; int x,y; int big_endian = AV_RL32(&buf[4]) > 0x000FFFFF; buf += 8; if(8>buf_end-buf) { av_log(avctx, AV_LOG_WARNING, "truncated header\n"); return -1; } s->width = big_endian ? AV_RB16(&buf[0]) : AV_RL16(&buf[0]); s->height = big_endian ? AV_RB16(&buf[2]) : AV_RL16(&buf[2]); if (s->avctx->width!=s->width || s->avctx->height!=s->height) { avcodec_set_dimensions(s->avctx, s->width, s->height); if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); } tgq_calculate_qtable(s, buf[4]); buf += 8; if (!s->frame.data[0]) { s->frame.key_frame = 1; s->frame.pict_type = AV_PICTURE_TYPE_I; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; if (avctx->get_buffer(avctx, &s->frame)) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } } for (y=0; y<(avctx->height+15)/16; y++) for (x=0; x<(avctx->width+15)/16; x++) tgq_decode_mb(s, y, x, &buf, buf_end); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf-buf_start; }
19,084
FFmpeg
2e391a576c1fc2e8816990924c6e4c21ccf75a82
1
static int handle_packet(MpegTSContext *ts, const uint8_t *packet) { MpegTSFilter *tss; int len, pid, cc, expected_cc, cc_ok, afc, is_start, is_discontinuity, has_adaptation, has_payload; const uint8_t *p, *p_end; int64_t pos; pid = AV_RB16(packet + 1) & 0x1fff; if (pid && discard_pid(ts, pid)) return 0; is_start = packet[1] & 0x40; tss = ts->pids[pid]; if (ts->auto_guess && !tss && is_start) { add_pes_stream(ts, pid, -1); tss = ts->pids[pid]; if (!tss) return 0; ts->current_pid = pid; afc = (packet[3] >> 4) & 3; if (afc == 0) /* reserved value */ return 0; has_adaptation = afc & 2; has_payload = afc & 1; is_discontinuity = has_adaptation && packet[4] != 0 && /* with length > 0 */ (packet[5] & 0x80); /* and discontinuity indicated */ /* continuity check (currently not used) */ cc = (packet[3] & 0xf); expected_cc = has_payload ? (tss->last_cc + 1) & 0x0f : tss->last_cc; cc_ok = pid == 0x1FFF || // null packet PID is_discontinuity || tss->last_cc < 0 || expected_cc == cc; tss->last_cc = cc; if (!cc_ok) { av_log(ts->stream, AV_LOG_DEBUG, "Continuity check failed for pid %d expected %d got %d\n", pid, expected_cc, cc); p = packet + 4; if (has_adaptation) { int64_t pcr_h; int pcr_l; if (parse_pcr(&pcr_h, &pcr_l, packet) == 0) tss->last_pcr = pcr_h * 300 + pcr_l; /* skip adaptation field */ p += p[0] + 1; /* if past the end of packet, ignore */ p_end = packet + TS_PACKET_SIZE; if (p >= p_end || !has_payload) return 0; pos = avio_tell(ts->stream->pb); if (pos >= 0) { av_assert0(pos >= TS_PACKET_SIZE); ts->pos47_full = pos - TS_PACKET_SIZE; if (tss->type == MPEGTS_SECTION) { if (is_start) { /* pointer field present */ len = *p++; if (len > p_end - p) return 0; if (len && cc_ok) { /* write remaining section bytes */ write_section_data(ts, tss, p, len, 0); /* check whether filter has been closed */ if (!ts->pids[pid]) return 0; p += len; if (p < p_end) { write_section_data(ts, tss, p, p_end - p, 1); } else { if (cc_ok) { write_section_data(ts, tss, p, p_end - p, 0); // stop find_stream_info from waiting for more streams // when all programs have received a PMT if (ts->stream->ctx_flags & AVFMTCTX_NOHEADER && ts->scan_all_pmts <= 0) { int i; for (i = 0; i < ts->nb_prg; i++) { if (!ts->prg[i].pmt_found) break; if (i == ts->nb_prg && ts->nb_prg > 0) { int types = 0; for (i = 0; i < ts->stream->nb_streams; i++) { AVStream *st = ts->stream->streams[i]; if (st->codecpar->codec_type >= 0) types |= 1<<st->codecpar->codec_type; if ((types & (1<<AVMEDIA_TYPE_AUDIO) && types & (1<<AVMEDIA_TYPE_VIDEO)) || pos > 100000) { av_log(ts->stream, AV_LOG_DEBUG, "All programs have pmt, headers found\n"); ts->stream->ctx_flags &= ~AVFMTCTX_NOHEADER; } else { int ret; // Note: The position here points actually behind the current packet. if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start, pos - ts->raw_packet_size)) < 0) return ret; return 0;
19,085
qemu
f3a06403b82c7f036564e4caf18b52ce6885fcfb
1
void qmp_guest_suspend_disk(Error **errp) { Error *local_err = NULL; GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode)); *mode = GUEST_SUSPEND_MODE_DISK; check_suspend_mode(*mode, &local_err); acquire_privilege(SE_SHUTDOWN_NAME, &local_err); execute_async(do_suspend, mode, &local_err); if (local_err) { error_propagate(errp, local_err); g_free(mode); } }
19,086
qemu
b0a0551283076c6f3e57cf2bdd525334009b2677
0
static void kvm_pit_put(PITCommonState *pit) { KVMPITState *s = KVM_PIT(pit); struct kvm_pit_state2 kpit; struct kvm_pit_channel_state *kchan; struct PITChannelState *sc; int i, ret; /* The offset keeps changing as long as the VM is stopped. */ if (s->vm_stopped) { kvm_pit_update_clock_offset(s); } kpit.flags = pit->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0; for (i = 0; i < 3; i++) { kchan = &kpit.channels[i]; sc = &pit->channels[i]; kchan->count = sc->count; kchan->latched_count = sc->latched_count; kchan->count_latched = sc->count_latched; kchan->status_latched = sc->status_latched; kchan->status = sc->status; kchan->read_state = sc->read_state; kchan->write_state = sc->write_state; kchan->write_latch = sc->write_latch; kchan->rw_mode = sc->rw_mode; kchan->mode = sc->mode; kchan->bcd = sc->bcd; kchan->gate = sc->gate; kchan->count_load_time = sc->count_load_time - s->kernel_clock_offset; } ret = kvm_vm_ioctl(kvm_state, kvm_has_pit_state2() ? KVM_SET_PIT2 : KVM_SET_PIT, &kpit); if (ret < 0) { fprintf(stderr, "%s failed: %s\n", kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT", strerror(ret)); abort(); } }
19,088
qemu
69970fcef937bddd7f745efe39501c7716fdfe56
0
static void vfio_rtl8168_window_quirk_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { VFIOQuirk *quirk = opaque; VFIOPCIDevice *vdev = quirk->vdev; switch (addr) { case 4: /* address */ if ((data & 0x7fff0000) == 0x10000) { if (data & 0x10000000U && vdev->pdev.cap_present & QEMU_PCI_CAP_MSIX) { trace_vfio_rtl8168_window_quirk_write_table( memory_region_name(&quirk->mem), vdev->vbasedev.name); memory_region_dispatch_write(&vdev->pdev.msix_table_mmio, (hwaddr)(quirk->data.address_match & 0xfff), data, size, MEMTXATTRS_UNSPECIFIED); } quirk->data.flags = 1; quirk->data.address_match = data; return; } quirk->data.flags = 0; break; case 0: /* data */ quirk->data.address_mask = data; break; } trace_vfio_rtl8168_window_quirk_write_direct( memory_region_name(&quirk->mem), vdev->vbasedev.name); vfio_region_write(&vdev->bars[quirk->data.bar].region, addr + 0x70, data, size); }
19,089
qemu
6fc76aa9adc1c8896a97059f12a1e5e6c1820c64
0
static void hash32_bat_601_size(CPUPPCState *env, target_ulong *blp, int *validp, target_ulong batu, target_ulong batl) { target_ulong bl; int valid; bl = (batl & BATL32_601_BL) << 17; LOG_BATS("b %02x ==> bl " TARGET_FMT_lx " msk " TARGET_FMT_lx "\n", (uint8_t)(batl & BATL32_601_BL), bl, ~bl); valid = !!(batl & BATL32_601_V); *blp = bl; *validp = valid; }
19,091
qemu
9be385980d37e8f4fd33f605f5fb1c3d144170a8
0
static size_t cache_get_cache_pos(const PageCache *cache, uint64_t address) { size_t pos; g_assert(cache->max_num_items); pos = (address / cache->page_size) & (cache->max_num_items - 1); return pos; }
19,092
qemu
8bba5c81b1febeb20cdd60f1c18eb0e695cad6d6
0
void vnc_display_init(DisplayState *ds) { VncState *vs; vs = qemu_mallocz(sizeof(VncState)); if (!vs) exit(1); ds->opaque = vs; vnc_state = vs; vs->display = NULL; vs->password = NULL; vs->lsock = -1; vs->csock = -1; vs->depth = 4; vs->last_x = -1; vs->last_y = -1; vs->ds = ds; if (!keyboard_layout) keyboard_layout = "en-us"; vs->kbd_layout = init_keyboard_layout(keyboard_layout); if (!vs->kbd_layout) exit(1); vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs); vs->ds->data = NULL; vs->ds->dpy_update = vnc_dpy_update; vs->ds->dpy_resize = vnc_dpy_resize; vs->ds->dpy_refresh = NULL; memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row)); vnc_dpy_resize(vs->ds, 640, 400); }
19,093
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
0
QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id) { QemuOpts *opts; TAILQ_FOREACH(opts, &list->head, next) { if (!opts->id) { continue; } if (strcmp(opts->id, id) != 0) { continue; } return opts; } return NULL; }
19,094
qemu
cea5f9a28faa528b6b1b117c9ab2d8828f473fef
0
static inline TranslationBlock *tb_find_fast(void) { TranslationBlock *tb; target_ulong cs_base, pc; int flags; /* we record a subset of the CPU state. It will always be the same before a given translated block is executed. */ cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)]; if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base || tb->flags != flags)) { tb = tb_find_slow(pc, cs_base, flags); } return tb; }
19,095
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
0
static void aio_timerlist_notify(void *opaque) { aio_notify(opaque); }
19,096
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
0
void qdev_free(DeviceState *dev) { #if 0 /* FIXME: need sane vmstate_unregister function */ if (dev->info->vmsd) vmstate_unregister(dev->info->vmsd, dev); #endif if (dev->info->reset) qemu_unregister_reset(dev->info->reset, dev); LIST_REMOVE(dev, sibling); qemu_free(dev); }
19,097
FFmpeg
3425501d3b09650c6b295ba225e02e97c002372c
0
static inline void write_back_motion(H264Context *h, int mb_type){ MpegEncContext * const s = &h->s; const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride; const int b8_xy= 2*s->mb_x + 2*s->mb_y*h->b8_stride; int list; if(!USES_LIST(mb_type, 0)) fill_rectangle(&s->current_picture.ref_index[0][b8_xy], 2, 2, h->b8_stride, (uint8_t)LIST_NOT_USED, 1); for(list=0; list<2; list++){ int y; if(!USES_LIST(mb_type, list)) continue; for(y=0; y<4; y++){ *(uint64_t*)s->current_picture.motion_val[list][b_xy + 0 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+0 + 8*y]; *(uint64_t*)s->current_picture.motion_val[list][b_xy + 2 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+2 + 8*y]; } if( h->pps.cabac ) { if(IS_SKIP(mb_type)) fill_rectangle(h->mvd_table[list][b_xy], 4, 4, h->b_stride, 0, 4); else for(y=0; y<4; y++){ *(uint64_t*)h->mvd_table[list][b_xy + 0 + y*h->b_stride]= *(uint64_t*)h->mvd_cache[list][scan8[0]+0 + 8*y]; *(uint64_t*)h->mvd_table[list][b_xy + 2 + y*h->b_stride]= *(uint64_t*)h->mvd_cache[list][scan8[0]+2 + 8*y]; } } { int8_t *ref_index = &s->current_picture.ref_index[list][b8_xy]; ref_index[0+0*h->b8_stride]= h->ref_cache[list][scan8[0]]; ref_index[1+0*h->b8_stride]= h->ref_cache[list][scan8[4]]; ref_index[0+1*h->b8_stride]= h->ref_cache[list][scan8[8]]; ref_index[1+1*h->b8_stride]= h->ref_cache[list][scan8[12]]; } } if(h->slice_type == B_TYPE && h->pps.cabac){ if(IS_8X8(mb_type)){ uint8_t *direct_table = &h->direct_table[b8_xy]; direct_table[1+0*h->b8_stride] = IS_DIRECT(h->sub_mb_type[1]) ? 1 : 0; direct_table[0+1*h->b8_stride] = IS_DIRECT(h->sub_mb_type[2]) ? 1 : 0; direct_table[1+1*h->b8_stride] = IS_DIRECT(h->sub_mb_type[3]) ? 1 : 0; } } }
19,098
qemu
1687a089f103f9b7a1b4a1555068054cb46ee9e9
0
cac_new_pki_applet(int i, const unsigned char *cert, int cert_len, VCardKey *key) { VCardAppletPrivate *applet_private = NULL; VCardApplet *applet = NULL; unsigned char pki_aid[] = { 0xa0, 0x00, 0x00, 0x00, 0x79, 0x01, 0x00 }; int pki_aid_len = sizeof(pki_aid); pki_aid[pki_aid_len-1] = i; applet_private = cac_new_pki_applet_private(cert, cert_len, key); if (applet_private == NULL) { goto failure; } applet = vcard_new_applet(cac_applet_pki_process_apdu, cac_applet_pki_reset, pki_aid, pki_aid_len); if (applet == NULL) { goto failure; } vcard_set_applet_private(applet, applet_private, cac_delete_pki_applet_private); applet_private = NULL; return applet; failure: if (applet_private != NULL) { cac_delete_pki_applet_private(applet_private); } return NULL; }
19,100
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
0
static void omap_rtc_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_rtc_s *s = (struct omap_rtc_s *) opaque; int offset = addr & OMAP_MPUI_REG_MASK; struct tm new_tm; time_t ti[2]; if (size != 1) { return omap_badwidth_write8(opaque, addr, value); } switch (offset) { case 0x00: /* SECONDS_REG */ #ifdef ALMDEBUG printf("RTC SEC_REG <-- %02x\n", value); #endif s->ti -= s->current_tm.tm_sec; s->ti += from_bcd(value); return; case 0x04: /* MINUTES_REG */ #ifdef ALMDEBUG printf("RTC MIN_REG <-- %02x\n", value); #endif s->ti -= s->current_tm.tm_min * 60; s->ti += from_bcd(value) * 60; return; case 0x08: /* HOURS_REG */ #ifdef ALMDEBUG printf("RTC HRS_REG <-- %02x\n", value); #endif s->ti -= s->current_tm.tm_hour * 3600; if (s->pm_am) { s->ti += (from_bcd(value & 0x3f) & 12) * 3600; s->ti += ((value >> 7) & 1) * 43200; } else s->ti += from_bcd(value & 0x3f) * 3600; return; case 0x0c: /* DAYS_REG */ #ifdef ALMDEBUG printf("RTC DAY_REG <-- %02x\n", value); #endif s->ti -= s->current_tm.tm_mday * 86400; s->ti += from_bcd(value) * 86400; return; case 0x10: /* MONTHS_REG */ #ifdef ALMDEBUG printf("RTC MTH_REG <-- %02x\n", value); #endif memcpy(&new_tm, &s->current_tm, sizeof(new_tm)); new_tm.tm_mon = from_bcd(value); ti[0] = mktimegm(&s->current_tm); ti[1] = mktimegm(&new_tm); if (ti[0] != -1 && ti[1] != -1) { s->ti -= ti[0]; s->ti += ti[1]; } else { /* A less accurate version */ s->ti -= s->current_tm.tm_mon * 2592000; s->ti += from_bcd(value) * 2592000; } return; case 0x14: /* YEARS_REG */ #ifdef ALMDEBUG printf("RTC YRS_REG <-- %02x\n", value); #endif memcpy(&new_tm, &s->current_tm, sizeof(new_tm)); new_tm.tm_year += from_bcd(value) - (new_tm.tm_year % 100); ti[0] = mktimegm(&s->current_tm); ti[1] = mktimegm(&new_tm); if (ti[0] != -1 && ti[1] != -1) { s->ti -= ti[0]; s->ti += ti[1]; } else { /* A less accurate version */ s->ti -= (s->current_tm.tm_year % 100) * 31536000; s->ti += from_bcd(value) * 31536000; } return; case 0x18: /* WEEK_REG */ return; /* Ignored */ case 0x20: /* ALARM_SECONDS_REG */ #ifdef ALMDEBUG printf("ALM SEC_REG <-- %02x\n", value); #endif s->alarm_tm.tm_sec = from_bcd(value); omap_rtc_alarm_update(s); return; case 0x24: /* ALARM_MINUTES_REG */ #ifdef ALMDEBUG printf("ALM MIN_REG <-- %02x\n", value); #endif s->alarm_tm.tm_min = from_bcd(value); omap_rtc_alarm_update(s); return; case 0x28: /* ALARM_HOURS_REG */ #ifdef ALMDEBUG printf("ALM HRS_REG <-- %02x\n", value); #endif if (s->pm_am) s->alarm_tm.tm_hour = ((from_bcd(value & 0x3f)) % 12) + ((value >> 7) & 1) * 12; else s->alarm_tm.tm_hour = from_bcd(value); omap_rtc_alarm_update(s); return; case 0x2c: /* ALARM_DAYS_REG */ #ifdef ALMDEBUG printf("ALM DAY_REG <-- %02x\n", value); #endif s->alarm_tm.tm_mday = from_bcd(value); omap_rtc_alarm_update(s); return; case 0x30: /* ALARM_MONTHS_REG */ #ifdef ALMDEBUG printf("ALM MON_REG <-- %02x\n", value); #endif s->alarm_tm.tm_mon = from_bcd(value); omap_rtc_alarm_update(s); return; case 0x34: /* ALARM_YEARS_REG */ #ifdef ALMDEBUG printf("ALM YRS_REG <-- %02x\n", value); #endif s->alarm_tm.tm_year = from_bcd(value); omap_rtc_alarm_update(s); return; case 0x40: /* RTC_CTRL_REG */ #ifdef ALMDEBUG printf("RTC CONTROL <-- %02x\n", value); #endif s->pm_am = (value >> 3) & 1; s->auto_comp = (value >> 2) & 1; s->round = (value >> 1) & 1; s->running = value & 1; s->status &= 0xfd; s->status |= s->running << 1; return; case 0x44: /* RTC_STATUS_REG */ #ifdef ALMDEBUG printf("RTC STATUSL <-- %02x\n", value); #endif s->status &= ~((value & 0xc0) ^ 0x80); omap_rtc_interrupts_update(s); return; case 0x48: /* RTC_INTERRUPTS_REG */ #ifdef ALMDEBUG printf("RTC INTRS <-- %02x\n", value); #endif s->interrupts = value; return; case 0x4c: /* RTC_COMP_LSB_REG */ #ifdef ALMDEBUG printf("RTC COMPLSB <-- %02x\n", value); #endif s->comp_reg &= 0xff00; s->comp_reg |= 0x00ff & value; return; case 0x50: /* RTC_COMP_MSB_REG */ #ifdef ALMDEBUG printf("RTC COMPMSB <-- %02x\n", value); #endif s->comp_reg &= 0x00ff; s->comp_reg |= 0xff00 & (value << 8); return; default: OMAP_BAD_REG(addr); return; } }
19,101
qemu
a12a712a7dfbd2e2f4882ef2c90a9b2162166dd7
0
static void nbd_recv_coroutines_enter_all(BlockDriverState *bs) { NBDClientSession *s = nbd_get_client_session(bs); int i; for (i = 0; i < MAX_NBD_REQUESTS; i++) { if (s->recv_coroutine[i]) { qemu_coroutine_enter(s->recv_coroutine[i]); } } BDRV_POLL_WHILE(bs, s->read_reply_co); }
19,103
qemu
67c5322d7000fd105a926eec44bc1765b7d70bdd
0
static void serial_xmit(void *opaque) { SerialState *s = opaque; uint64_t new_xmit_ts = qemu_get_clock_ns(vm_clock); if (s->tsr_retry <= 0) { if (s->fcr & UART_FCR_FE) { s->tsr = fifo_get(s,XMIT_FIFO); if (!s->xmit_fifo.count) s->lsr |= UART_LSR_THRE; } else { s->tsr = s->thr; s->lsr |= UART_LSR_THRE; } } if (s->mcr & UART_MCR_LOOP) { /* in loopback mode, say that we just received a char */ serial_receive1(s, &s->tsr, 1); } else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) { if ((s->tsr_retry > 0) && (s->tsr_retry <= MAX_XMIT_RETRY)) { s->tsr_retry++; qemu_mod_timer(s->transmit_timer, new_xmit_ts + s->char_transmit_time); return; } else if (s->poll_msl < 0) { /* If we exceed MAX_XMIT_RETRY and the backend is not a real serial port, then drop any further failed writes instantly, until we get one that goes through. This is to prevent guests that log to unconnected pipes or pty's from stalling. */ s->tsr_retry = -1; } } else { s->tsr_retry = 0; } s->last_xmit_ts = qemu_get_clock_ns(vm_clock); if (!(s->lsr & UART_LSR_THRE)) qemu_mod_timer(s->transmit_timer, s->last_xmit_ts + s->char_transmit_time); if (s->lsr & UART_LSR_THRE) { s->lsr |= UART_LSR_TEMT; s->thr_ipending = 1; serial_update_irq(s); } }
19,104
qemu
2e8bc7874bb674b7d6837706b1249bf871941637
0
static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, BlockDriverState *base, bool want_zero, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { BlockDriverState *p; int64_t ret = 0; bool first = true; assert(bs != base); for (p = bs; p != base; p = backing_bs(p)) { ret = bdrv_co_get_block_status(p, want_zero, sector_num, nb_sectors, pnum, file); if (ret < 0) { break; } if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) { /* * Reading beyond the end of the file continues to read * zeroes, but we can only widen the result to the * unallocated length we learned from an earlier * iteration. */ *pnum = nb_sectors; } if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) { break; } /* [sector_num, pnum] unallocated on this layer, which could be only * the first part of [sector_num, nb_sectors]. */ nb_sectors = MIN(nb_sectors, *pnum); first = false; } return ret; }
19,105
qemu
bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884
0
static void socket_start_incoming_migration(SocketAddressLegacy *saddr, Error **errp) { QIOChannelSocket *listen_ioc = qio_channel_socket_new(); qio_channel_set_name(QIO_CHANNEL(listen_ioc), "migration-socket-listener"); if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) { object_unref(OBJECT(listen_ioc)); qapi_free_SocketAddressLegacy(saddr); return; } qio_channel_add_watch(QIO_CHANNEL(listen_ioc), G_IO_IN, socket_accept_incoming_migration, listen_ioc, (GDestroyNotify)object_unref); qapi_free_SocketAddressLegacy(saddr); }
19,106
qemu
81607cbfa433272d1f09bd0f0ae6c3b14f818972
0
QemuOpts *vnc_parse_func(const char *str) { QemuOptsList *olist = qemu_find_opts("vnc"); QemuOpts *opts = qemu_opts_parse(olist, str, 1); const char *id = qemu_opts_id(opts); if (!id) { /* auto-assign id if not present */ vnc_auto_assign_id(olist, opts); } return opts; }
19,107
FFmpeg
7a4f74eed51f914e9bbfebaffd4a92ac6791f819
0
static void flush_dpb(AVCodecContext *avctx) { H264Context *h = avctx->priv_data; int i; memset(h->delayed_pic, 0, sizeof(h->delayed_pic)); ff_h264_flush_change(h); if (h->DPB) for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) ff_h264_unref_picture(h, &h->DPB[i]); h->cur_pic_ptr = NULL; ff_h264_unref_picture(h, &h->cur_pic); h->mb_y = 0; ff_h264_free_tables(h); h->context_initialized = 0; }
19,109
qemu
67a0fd2a9bca204d2b39f910a97c7137636a0715
0
static int64_t coroutine_fn vdi_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { /* TODO: Check for too large sector_num (in bdrv_is_allocated or here). */ BDRVVdiState *s = (BDRVVdiState *)bs->opaque; size_t bmap_index = sector_num / s->block_sectors; size_t sector_in_block = sector_num % s->block_sectors; int n_sectors = s->block_sectors - sector_in_block; uint32_t bmap_entry = le32_to_cpu(s->bmap[bmap_index]); uint64_t offset; int result; logout("%p, %" PRId64 ", %d, %p\n", bs, sector_num, nb_sectors, pnum); if (n_sectors > nb_sectors) { n_sectors = nb_sectors; } *pnum = n_sectors; result = VDI_IS_ALLOCATED(bmap_entry); if (!result) { return 0; } offset = s->header.offset_data + (uint64_t)bmap_entry * s->block_size + sector_in_block * SECTOR_SIZE; return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset; }
19,110
qemu
0b5a24454fc551f0294fe93821e8c643214a55f5
0
static void coroutine_fn bdrv_aio_flush_co_entry(void *opaque) { BlockAIOCBCoroutine *acb = opaque; BlockDriverState *bs = acb->common.bs; acb->req.error = bdrv_co_flush(bs); acb->bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_co_em_bh, acb); qemu_bh_schedule(acb->bh); }
19,111
qemu
364031f17932814484657e5551ba12957d993d7e
0
int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode, const char *name, v9fs_synth_read read, v9fs_synth_write write, void *arg) { int ret; V9fsSynthNode *node, *tmp; if (!v9fs_synth_fs) { return EAGAIN; } if (!name || (strlen(name) >= NAME_MAX)) { return EINVAL; } if (!parent) { parent = &v9fs_synth_root; } qemu_mutex_lock(&v9fs_synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) { if (!strcmp(tmp->name, name)) { ret = EEXIST; goto err_out; } } /* Add file type and remove write bits */ mode = ((mode & 0777) | S_IFREG); node = g_malloc0(sizeof(V9fsSynthNode)); node->attr = &node->actual_attr; node->attr->inode = v9fs_synth_node_count++; node->attr->nlink = 1; node->attr->read = read; node->attr->write = write; node->attr->mode = mode; node->private = arg; pstrcpy(node->name, sizeof(node->name), name); QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling); ret = 0; err_out: qemu_mutex_unlock(&v9fs_synth_mutex); return ret; }
19,112
qemu
bb628e1af8b8b5ecf6420e50123cb696ee18b09f
0
static void usage(const char *name) { (printf) ( "Usage: %s [OPTIONS] FILE\n" "QEMU Disk Network Block Device Server\n" "\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n" "\n" "Connection properties:\n" " -p, --port=PORT port to listen on (default `%d')\n" " -b, --bind=IFACE interface to bind to (default `0.0.0.0')\n" " -k, --socket=PATH path to the unix socket\n" " (default '"SOCKET_PATH"')\n" " -e, --shared=NUM device can be shared by NUM clients (default '1')\n" " -t, --persistent don't exit on the last connection\n" " -v, --verbose display extra debugging information\n" "\n" "Exposing part of the image:\n" " -o, --offset=OFFSET offset into the image\n" " -P, --partition=NUM only expose partition NUM\n" "\n" #ifdef __linux__ "Kernel NBD client support:\n" " -c, --connect=DEV connect FILE to the local NBD device DEV\n" " -d, --disconnect disconnect the specified device\n" "\n" #endif "\n" "Block device options:\n" " -f, --format=FORMAT set image format (raw, qcow2, ...)\n" " -r, --read-only export read-only\n" " -s, --snapshot use FILE as an external snapshot, create a temporary\n" " file with backing_file=FILE, redirect the write to\n" " the temporary one\n" " -l, --load-snapshot=SNAPSHOT_PARAM\n" " load an internal snapshot inside FILE and export it\n" " as an read-only device, SNAPSHOT_PARAM format is\n" " 'snapshot.id=[ID],snapshot.name=[NAME]', or\n" " '[ID_OR_NAME]'\n" " -n, --nocache disable host cache\n" " --cache=MODE set cache mode (none, writeback, ...)\n" #ifdef CONFIG_LINUX_AIO " --aio=MODE set AIO mode (native or threads)\n" #endif " --discard=MODE set discard mode (ignore, unmap)\n" " --detect-zeroes=MODE set detect-zeroes mode (off, on, unmap)\n" "\n" "Report bugs to <[email protected]>\n" , name, NBD_DEFAULT_PORT, "DEVICE"); }
19,113
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
0
static void run_dependent_requests(QCowL2Meta *m) { QCowAIOCB *req; QCowAIOCB *next; /* Take the request off the list of running requests */ if (m->nb_clusters != 0) { LIST_REMOVE(m, next_in_flight); } /* * Restart all dependent requests. * Can't use LIST_FOREACH here - the next link might not be the same * any more after the callback (request could depend on a different * request now) */ for (req = m->dependent_requests.lh_first; req != NULL; req = next) { next = req->next_depend.le_next; qcow_aio_write_cb(req, 0); } /* Empty the list for the next part of the request */ LIST_INIT(&m->dependent_requests); }
19,114
qemu
9a10bbb4e83b184faef6fa744396a6775283c0aa
0
static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp) { VT686PMState *s = DO_UPCAST(VT686PMState, dev, dev); uint8_t *pci_conf; pci_conf = s->dev.config; pci_set_word(pci_conf + PCI_COMMAND, 0); pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM); /* 0x48-0x4B is Power Management I/O Base */ pci_set_long(pci_conf + 0x48, 0x00000001); /* SMB ports:0xeee0~0xeeef */ s->smb_io_base =((s->smb_io_base & 0xfff0) + 0x0); pci_conf[0x90] = s->smb_io_base | 1; pci_conf[0x91] = s->smb_io_base >> 8; pci_conf[0xd2] = 0x90; pm_smbus_init(&s->dev.qdev, &s->smb); memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io); apm_init(dev, &s->apm, NULL, s); memory_region_init(&s->io, OBJECT(dev), "vt82c686-pm", 64); memory_region_set_enabled(&s->io, false); memory_region_add_subregion(get_system_io(), 0, &s->io); acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io); acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io); acpi_pm1_cnt_init(&s->ar, &s->io, 2); }
19,117
qemu
9be385980d37e8f4fd33f605f5fb1c3d144170a8
0
static int load_refcount_block(BlockDriverState *bs, int64_t refcount_block_offset, void **refcount_block) { BDRVQcow2State *s = bs->opaque; int ret; BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD); ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset, refcount_block); return ret; }
19,118
qemu
42a268c241183877192c376d03bd9b6d527407c7
0
static inline void gen_branch_cond(DisasContext *ctx, TCGCond cond, TCGv r1, TCGv r2, int16_t address) { int jumpLabel; jumpLabel = gen_new_label(); tcg_gen_brcond_tl(cond, r1, r2, jumpLabel); gen_goto_tb(ctx, 1, ctx->next_pc); gen_set_label(jumpLabel); gen_goto_tb(ctx, 0, ctx->pc + address * 2); }
19,121
qemu
5a7e7a0bad17c96e03f55ed7019e2d7545e21a96
0
void qmp_drive_mirror(const char *device, const char *target, bool has_format, const char *format, bool has_node_name, const char *node_name, bool has_replaces, const char *replaces, enum MirrorSyncMode sync, bool has_mode, enum NewImageMode mode, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_target_error, BlockdevOnError on_target_error, Error **errp) { BlockDriverState *bs; BlockDriverState *source, *target_bs; BlockDriver *drv = NULL; Error *local_err = NULL; QDict *options = NULL; int flags; int64_t size; int ret; if (!has_speed) { speed = 0; } if (!has_on_source_error) { on_source_error = BLOCKDEV_ON_ERROR_REPORT; } if (!has_on_target_error) { on_target_error = BLOCKDEV_ON_ERROR_REPORT; } if (!has_mode) { mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; } if (!has_granularity) { granularity = 0; } if (!has_buf_size) { buf_size = DEFAULT_MIRROR_BUF_SIZE; } if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "a value in range [512B, 64MB]"); return; } if (granularity & (granularity - 1)) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2"); return; } bs = bdrv_find(device); if (!bs) { error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } if (!bdrv_is_inserted(bs)) { error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); return; } if (!has_format) { format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name; } if (format) { drv = bdrv_find_format(format); if (!drv) { error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); return; } } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR, errp)) { return; } flags = bs->open_flags | BDRV_O_RDWR; source = bs->backing_hd; if (!source && sync == MIRROR_SYNC_MODE_TOP) { sync = MIRROR_SYNC_MODE_FULL; } if (sync == MIRROR_SYNC_MODE_NONE) { source = bs; } size = bdrv_getlength(bs); if (size < 0) { error_setg_errno(errp, -size, "bdrv_getlength failed"); return; } if (has_replaces) { BlockDriverState *to_replace_bs; if (!has_node_name) { error_setg(errp, "a node-name must be provided when replacing a" " named node of the graph"); return; } to_replace_bs = check_to_replace_node(replaces, &local_err); if (!to_replace_bs) { error_propagate(errp, local_err); return; } if (size != bdrv_getlength(to_replace_bs)) { error_setg(errp, "cannot replace image with a mirror image of " "different size"); return; } } if ((sync == MIRROR_SYNC_MODE_FULL || !source) && mode != NEW_IMAGE_MODE_EXISTING) { /* create new image w/o backing file */ assert(format && drv); bdrv_img_create(target, format, NULL, NULL, NULL, size, flags, &local_err, false); } else { switch (mode) { case NEW_IMAGE_MODE_EXISTING: break; case NEW_IMAGE_MODE_ABSOLUTE_PATHS: /* create new image with backing file */ bdrv_img_create(target, format, source->filename, source->drv->format_name, NULL, size, flags, &local_err, false); break; default: abort(); } } if (local_err) { error_propagate(errp, local_err); return; } if (has_node_name) { options = qdict_new(); qdict_put(options, "node-name", qstring_from_str(node_name)); } /* Mirroring takes care of copy-on-write using the source's backing * file. */ target_bs = NULL; ret = bdrv_open(&target_bs, target, NULL, options, flags | BDRV_O_NO_BACKING, drv, &local_err); if (ret < 0) { error_propagate(errp, local_err); return; } /* pass the node name to replace to mirror start since it's loose coupling * and will allow to check whether the node still exist at mirror completion */ mirror_start(bs, target_bs, has_replaces ? replaces : NULL, speed, granularity, buf_size, sync, on_source_error, on_target_error, block_job_cb, bs, &local_err); if (local_err != NULL) { bdrv_unref(target_bs); error_propagate(errp, local_err); return; } }
19,123