project
stringclasses
2 values
commit_id
stringlengths
40
40
target
int64
0
1
func
stringlengths
26
142k
idx
int64
0
27.3k
FFmpeg
d150a147dac67faeaf6b1f25a523ae330168ee1e
0
static void parse_presentation_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { PGSSubContext *ctx = avctx->priv_data; int x, y; int w = bytestream_get_be16(&buf); int h = bytestream_get_be16(&buf); av_dlog(avctx, "Video Dimensions %dx%d\n", w, h); if (av_image_check_size(w, h, 0, avctx) >= 0) avcodec_set_dimensions(avctx, w, h); /* Skip 1 bytes of unknown, frame rate? */ buf++; ctx->presentation.id_number = bytestream_get_be16(&buf); /* * Skip 3 bytes of unknown: * state * palette_update_flag (0x80), * palette_id_to_use, */ buf += 3; ctx->presentation.object_number = bytestream_get_byte(&buf); if (!ctx->presentation.object_number) return; /* * Skip 4 bytes of unknown: * object_id_ref (2 bytes), * window_id_ref, * composition_flag (0x80 - object cropped, 0x40 - object forced) */ buf += 4; x = bytestream_get_be16(&buf); y = bytestream_get_be16(&buf); /* TODO If cropping, cropping_x, cropping_y, cropping_width, cropping_height (all 2 bytes).*/ av_dlog(avctx, "Subtitle Placement x=%d, y=%d\n", x, y); if (x > avctx->width || y > avctx->height) { av_log(avctx, AV_LOG_ERROR, "Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n", x, y, avctx->width, avctx->height); x = 0; y = 0; } /* Fill in dimensions */ ctx->presentation.x = x; ctx->presentation.y = y; }
9,190
qemu
f5ed36635d8fa73feb66fe12b3b9c2ed90a1adbe
1
void virtio_init(VirtIODevice *vdev, const char *name, uint16_t device_id, size_t config_size) { BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); int i; int nvectors = k->query_nvectors ? k->query_nvectors(qbus->parent) : 0; if (nvectors) { vdev->vector_queues = g_malloc0(sizeof(*vdev->vector_queues) * nvectors); } vdev->device_id = device_id; vdev->status = 0; vdev->isr = 0; vdev->queue_sel = 0; vdev->config_vector = VIRTIO_NO_VECTOR; vdev->vq = g_malloc0(sizeof(VirtQueue) * VIRTIO_QUEUE_MAX); vdev->vm_running = runstate_is_running(); for (i = 0; i < VIRTIO_QUEUE_MAX; i++) { vdev->vq[i].vector = VIRTIO_NO_VECTOR; vdev->vq[i].vdev = vdev; vdev->vq[i].queue_index = i; } vdev->name = name; vdev->config_len = config_size; if (vdev->config_len) { vdev->config = g_malloc0(config_size); } else { vdev->config = NULL; } vdev->vmstate = qemu_add_vm_change_state_handler(virtio_vmstate_change, vdev); vdev->device_endian = virtio_default_endian(); vdev->use_guest_notifier_mask = true; }
9,191
qemu
456d60692310e7ac25cf822cc1e98192ad636ece
1
static int mon_init_func(QemuOpts *opts, void *opaque) { CharDriverState *chr; const char *chardev; const char *mode; int flags; mode = qemu_opt_get(opts, "mode"); if (mode == NULL) { mode = "readline"; } if (strcmp(mode, "readline") == 0) { flags = MONITOR_USE_READLINE; } else if (strcmp(mode, "control") == 0) { flags = MONITOR_USE_CONTROL; } else { fprintf(stderr, "unknown monitor mode \"%s\"\n", mode); exit(1); } if (qemu_opt_get_bool(opts, "pretty", 0)) flags |= MONITOR_USE_PRETTY; if (qemu_opt_get_bool(opts, "default", 0)) flags |= MONITOR_IS_DEFAULT; chardev = qemu_opt_get(opts, "chardev"); chr = qemu_chr_find(chardev); if (chr == NULL) { fprintf(stderr, "chardev \"%s\" not found\n", chardev); exit(1); } monitor_init(chr, flags); return 0; }
9,194
qemu
9e92f6d46233171898fc7d0487a04e5b78e44234
1
void ga_unset_frozen(GAState *s) { if (!ga_is_frozen(s)) { return; } /* if we delayed creation/opening of pid/log files due to being * in a frozen state at start up, do it now */ if (s->deferred_options.log_filepath) { s->log_file = fopen(s->deferred_options.log_filepath, "a"); if (!s->log_file) { s->log_file = stderr; } s->deferred_options.log_filepath = NULL; } ga_enable_logging(s); g_warning("logging re-enabled due to filesystem unfreeze"); if (s->deferred_options.pid_filepath) { if (!ga_open_pidfile(s->deferred_options.pid_filepath)) { g_warning("failed to create/open pid file"); } s->deferred_options.pid_filepath = NULL; } /* enable all disabled, non-blacklisted commands */ ga_enable_non_blacklisted(s->blacklist); s->frozen = false; if (!ga_delete_file(s->state_filepath_isfrozen)) { g_warning("unable to delete %s, fsfreeze may not function properly", s->state_filepath_isfrozen); } }
9,195
qemu
a0e640a87210b1e986bcd4e7f7de03beb3db0a4a
1
static int local_remove(FsContext *ctx, const char *path) { int err; struct stat stbuf; char *buffer; if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { buffer = rpath(ctx, path); err = lstat(buffer, &stbuf); g_free(buffer); if (err) { goto err_out; } /* * If directory remove .virtfs_metadata contained in the * directory */ if (S_ISDIR(stbuf.st_mode)) { buffer = g_strdup_printf("%s/%s/%s", ctx->fs_root, path, VIRTFS_META_DIR); err = remove(buffer); g_free(buffer); if (err < 0 && errno != ENOENT) { /* * We didn't had the .virtfs_metadata file. May be file created * in non-mapped mode ?. Ignore ENOENT. */ goto err_out; } } /* * Now remove the name from parent directory * .virtfs_metadata directory */ buffer = local_mapped_attr_path(ctx, path); err = remove(buffer); g_free(buffer); if (err < 0 && errno != ENOENT) { /* * We didn't had the .virtfs_metadata file. May be file created * in non-mapped mode ?. Ignore ENOENT. */ goto err_out; } } buffer = rpath(ctx, path); err = remove(buffer); g_free(buffer); err_out: return err; }
9,196
FFmpeg
14e4e26559697cfdea584767be4e68474a0a9c7f
1
static int t37(InterplayACMContext *s, unsigned ind, unsigned col) { GetBitContext *gb = &s->gb; unsigned i, b; int n1, n2; for (i = 0; i < s->rows; i++) { /* b = (x1) + (x2 * 11) */ b = get_bits(gb, 7); n1 = (mul_2x11[b] & 0x0F) - 5; n2 = ((mul_2x11[b] >> 4) & 0x0F) - 5; set_pos(s, i++, col, n1); if (i >= s->rows) break; set_pos(s, i, col, n2); return 0;
9,197
FFmpeg
6e42e6c4b410dbef8b593c2d796a5dad95f89ee4
1
static inline void RENAME(rgb24to32)(const uint8_t *src,uint8_t *dst,long src_size) { uint8_t *dest = dst; const uint8_t *s = src; const uint8_t *end; #ifdef HAVE_MMX const uint8_t *mm_end; #endif end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 23; __asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory"); while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movd %1, %%mm0\n\t" "punpckldq 3%1, %%mm0\n\t" "movd 6%1, %%mm1\n\t" "punpckldq 9%1, %%mm1\n\t" "movd 12%1, %%mm2\n\t" "punpckldq 15%1, %%mm2\n\t" "movd 18%1, %%mm3\n\t" "punpckldq 21%1, %%mm3\n\t" "pand %%mm7, %%mm0\n\t" "pand %%mm7, %%mm1\n\t" "pand %%mm7, %%mm2\n\t" "pand %%mm7, %%mm3\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm1, 8%0\n\t" MOVNTQ" %%mm2, 16%0\n\t" MOVNTQ" %%mm3, 24%0" :"=m"(*dest) :"m"(*s) :"memory"); dest += 32; s += 24; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { #ifdef WORDS_BIGENDIAN /* RGB24 (= R,G,B) -> RGB32 (= A,B,G,R) */ *dest++ = 0; *dest++ = s[2]; *dest++ = s[1]; *dest++ = s[0]; s+=3; #else *dest++ = *s++; *dest++ = *s++; *dest++ = *s++; *dest++ = 0; #endif } }
9,199
qemu
966439a67830239a6c520c5df6c55627b8153c8b
1
void do_subfmeo (void) { T1 = T0; T0 = ~T0 + xer_ca - 1; if (likely(!((uint32_t)~T1 & ((uint32_t)~T1 ^ (uint32_t)T0) & (1UL << 31)))) { xer_ov = 0; } else { xer_so = 1; xer_ov = 1; } if (likely((uint32_t)T1 != UINT32_MAX)) xer_ca = 1; }
9,200
qemu
8a9e0e7b890b2598da94646bf6a7272f3d3924de
1
static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCDIMMDevice *dimm = PC_DIMM(dev); PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); uint64_t size = memory_region_size(mr); char *mem_dev; if (size % SPAPR_MEMORY_BLOCK_SIZE) { error_setg(errp, "Hotplugged memory size must be a multiple of " "%lld MB", SPAPR_MEMORY_BLOCK_SIZE / M_BYTE); return; } mem_dev = object_property_get_str(OBJECT(dimm), PC_DIMM_MEMDEV_PROP, NULL); if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) { error_setg(errp, "Memory backend has bad page size. " "Use 'memory-backend-file' with correct mem-path."); return; } }
9,201
FFmpeg
d1adad3cca407f493c3637e20ecd4f7124e69212
0
static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, long width, long height, long lumStride, long chromStride, long srcStride) { long y; const x86_reg chromWidth= width>>1; #if COMPILE_TEMPLATE_MMX for (y=0; y<height-2; y+=2) { long i; for (i=0; i<2; i++) { __asm__ volatile( "mov %2, %%"REG_a" \n\t" "movq "MANGLE(ff_bgr2YCoeff)", %%mm6 \n\t" "movq "MANGLE(ff_w1111)", %%mm5 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t" ".p2align 4 \n\t" "1: \n\t" PREFETCH" 64(%0, %%"REG_d") \n\t" "movd (%0, %%"REG_d"), %%mm0 \n\t" "movd 3(%0, %%"REG_d"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 6(%0, %%"REG_d"), %%mm2 \n\t" "movd 9(%0, %%"REG_d"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "packssdw %%mm2, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" "movd 12(%0, %%"REG_d"), %%mm4 \n\t" "movd 15(%0, %%"REG_d"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 18(%0, %%"REG_d"), %%mm2 \n\t" "movd 21(%0, %%"REG_d"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm4 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "add $24, %%"REG_d" \n\t" "packssdw %%mm2, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "packuswb %%mm4, %%mm0 \n\t" "paddusb "MANGLE(ff_bgr2YOffset)", %%mm0 \n\t" MOVNTQ" %%mm0, (%1, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+width*3), "r" (ydst+width), "g" ((x86_reg)-width) : "%"REG_a, "%"REG_d ); ydst += lumStride; src += srcStride; } src -= srcStride*2; __asm__ volatile( "mov %4, %%"REG_a" \n\t" "movq "MANGLE(ff_w1111)", %%mm5 \n\t" "movq "MANGLE(ff_bgr2UCoeff)", %%mm6 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t" "add %%"REG_d", %%"REG_d" \n\t" ".p2align 4 \n\t" "1: \n\t" PREFETCH" 64(%0, %%"REG_d") \n\t" PREFETCH" 64(%1, %%"REG_d") \n\t" #if COMPILE_TEMPLATE_MMX2 || COMPILE_TEMPLATE_AMD3DNOW "movq (%0, %%"REG_d"), %%mm0 \n\t" "movq (%1, %%"REG_d"), %%mm1 \n\t" "movq 6(%0, %%"REG_d"), %%mm2 \n\t" "movq 6(%1, %%"REG_d"), %%mm3 \n\t" PAVGB" %%mm1, %%mm0 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $24, %%mm0 \n\t" "psrlq $24, %%mm2 \n\t" PAVGB" %%mm1, %%mm0 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" #else "movd (%0, %%"REG_d"), %%mm0 \n\t" "movd (%1, %%"REG_d"), %%mm1 \n\t" "movd 3(%0, %%"REG_d"), %%mm2 \n\t" "movd 3(%1, %%"REG_d"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm2, %%mm0 \n\t" "movd 6(%0, %%"REG_d"), %%mm4 \n\t" "movd 6(%1, %%"REG_d"), %%mm1 \n\t" "movd 9(%0, %%"REG_d"), %%mm2 \n\t" "movd 9(%1, %%"REG_d"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm4 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm4, %%mm2 \n\t" "psrlw $2, %%mm0 \n\t" "psrlw $2, %%mm2 \n\t" #endif "movq "MANGLE(ff_bgr2VCoeff)", %%mm1 \n\t" "movq "MANGLE(ff_bgr2VCoeff)", %%mm3 \n\t" "pmaddwd %%mm0, %%mm1 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm2, %%mm0 \n\t" "packssdw %%mm3, %%mm1 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm1 \n\t" "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0 "psraw $7, %%mm0 \n\t" #if COMPILE_TEMPLATE_MMX2 || COMPILE_TEMPLATE_AMD3DNOW "movq 12(%0, %%"REG_d"), %%mm4 \n\t" "movq 12(%1, %%"REG_d"), %%mm1 \n\t" "movq 18(%0, %%"REG_d"), %%mm2 \n\t" "movq 18(%1, %%"REG_d"), %%mm3 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "movq %%mm4, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $24, %%mm4 \n\t" "psrlq $24, %%mm2 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" #else "movd 12(%0, %%"REG_d"), %%mm4 \n\t" "movd 12(%1, %%"REG_d"), %%mm1 \n\t" "movd 15(%0, %%"REG_d"), %%mm2 \n\t" "movd 15(%1, %%"REG_d"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm4 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm2, %%mm4 \n\t" "movd 18(%0, %%"REG_d"), %%mm5 \n\t" "movd 18(%1, %%"REG_d"), %%mm1 \n\t" "movd 21(%0, %%"REG_d"), %%mm2 \n\t" "movd 21(%1, %%"REG_d"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm5 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm5 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm5, %%mm2 \n\t" "movq "MANGLE(ff_w1111)", %%mm5 \n\t" "psrlw $2, %%mm4 \n\t" "psrlw $2, %%mm2 \n\t" #endif "movq "MANGLE(ff_bgr2VCoeff)", %%mm1 \n\t" "movq "MANGLE(ff_bgr2VCoeff)", %%mm3 \n\t" "pmaddwd %%mm4, %%mm1 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm2, %%mm4 \n\t" "packssdw %%mm3, %%mm1 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm1 \n\t" "add $24, %%"REG_d" \n\t" "packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2 "psraw $7, %%mm4 \n\t" "movq %%mm0, %%mm1 \n\t" "punpckldq %%mm4, %%mm0 \n\t" "punpckhdq %%mm4, %%mm1 \n\t" "packsswb %%mm1, %%mm0 \n\t" "paddb "MANGLE(ff_bgr2UVOffset)", %%mm0 \n\t" "movd %%mm0, (%2, %%"REG_a") \n\t" "punpckhdq %%mm0, %%mm0 \n\t" "movd %%mm0, (%3, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+chromWidth*6), "r" (src+srcStride+chromWidth*6), "r" (udst+chromWidth), "r" (vdst+chromWidth), "g" (-chromWidth) : "%"REG_a, "%"REG_d ); udst += chromStride; vdst += chromStride; src += srcStride*2; } __asm__ volatile(EMMS" \n\t" SFENCE" \n\t" :::"memory"); #else y=0; #endif for (; y<height; y+=2) { long i; for (i=0; i<chromWidth; i++) { unsigned int b = src[6*i+0]; unsigned int g = src[6*i+1]; unsigned int r = src[6*i+2]; unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; unsigned int V = ((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128; unsigned int U = ((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128; udst[i] = U; vdst[i] = V; ydst[2*i] = Y; b = src[6*i+3]; g = src[6*i+4]; r = src[6*i+5]; Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i+1] = Y; } ydst += lumStride; src += srcStride; if(y+1 == height) break; for (i=0; i<chromWidth; i++) { unsigned int b = src[6*i+0]; unsigned int g = src[6*i+1]; unsigned int r = src[6*i+2]; unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i] = Y; b = src[6*i+3]; g = src[6*i+4]; r = src[6*i+5]; Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i+1] = Y; } udst += chromStride; vdst += chromStride; ydst += lumStride; src += srcStride; } }
9,202
qemu
dcc3a21209a8eeae0fe43966012f8e08d3566f98
0
static int aarch64_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu, int max_insns) { DisasContext *dc = container_of(dcbase, DisasContext, base); CPUARMState *env = cpu->env_ptr; ARMCPU *arm_cpu = arm_env_get_cpu(env); dc->pc = dc->base.pc_first; dc->condjmp = 0; dc->aarch64 = 1; /* If we are coming from secure EL0 in a system with a 32-bit EL3, then * there is no secure EL1, so we route exceptions to EL3. */ dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3); dc->thumb = 0; dc->sctlr_b = 0; dc->be_data = ARM_TBFLAG_BE_DATA(dc->base.tb->flags) ? MO_BE : MO_LE; dc->condexec_mask = 0; dc->condexec_cond = 0; dc->mmu_idx = core_to_arm_mmu_idx(env, ARM_TBFLAG_MMUIDX(dc->base.tb->flags)); dc->tbi0 = ARM_TBFLAG_TBI0(dc->base.tb->flags); dc->tbi1 = ARM_TBFLAG_TBI1(dc->base.tb->flags); dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx); #if !defined(CONFIG_USER_ONLY) dc->user = (dc->current_el == 0); #endif dc->fp_excp_el = ARM_TBFLAG_FPEXC_EL(dc->base.tb->flags); dc->vec_len = 0; dc->vec_stride = 0; dc->cp_regs = arm_cpu->cp_regs; dc->features = env->features; /* Single step state. The code-generation logic here is: * SS_ACTIVE == 0: * generate code with no special handling for single-stepping (except * that anything that can make us go to SS_ACTIVE == 1 must end the TB; * this happens anyway because those changes are all system register or * PSTATE writes). * SS_ACTIVE == 1, PSTATE.SS == 1: (active-not-pending) * emit code for one insn * emit code to clear PSTATE.SS * emit code to generate software step exception for completed step * end TB (as usual for having generated an exception) * SS_ACTIVE == 1, PSTATE.SS == 0: (active-pending) * emit code to generate a software step exception * end the TB */ dc->ss_active = ARM_TBFLAG_SS_ACTIVE(dc->base.tb->flags); dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(dc->base.tb->flags); dc->is_ldex = false; dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el); dc->next_page_start = (dc->base.pc_first & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; init_tmp_a64_array(dc); return max_insns; }
9,203
qemu
cde0fc7544ca590c83f349d4dcccf375d55d6042
0
static void monitor_print_error(Monitor *mon) { qerror_print(mon->error); QDECREF(mon->error); mon->error = NULL; }
9,204
qemu
0e9b9edae7bebfd31fdbead4ccbbce03876a7edd
0
void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, GArray *linker) { GSList *device_list; /* no NVDIMM device is plugged. */ device_list = nvdimm_get_plugged_device_list(); if (!device_list) { return; } nvdimm_build_nfit(device_list, table_offsets, table_data, linker); nvdimm_build_ssdt(device_list, table_offsets, table_data, linker); g_slist_free(device_list); }
9,205
qemu
33badfd1e3735b877e41939100511c65572be6b9
0
static void qio_channel_websock_handshake_process(QIOChannelWebsock *ioc, char *buffer, Error **errp) { QIOChannelWebsockHTTPHeader hdrs[32]; size_t nhdrs = G_N_ELEMENTS(hdrs); const char *protocols = NULL, *version = NULL, *key = NULL, *host = NULL, *connection = NULL, *upgrade = NULL; nhdrs = qio_channel_websock_extract_headers(ioc, buffer, hdrs, nhdrs, errp); if (!nhdrs) { return; } protocols = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL); if (!protocols) { error_setg(errp, "Missing websocket protocol header data"); goto bad_request; } version = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_VERSION); if (!version) { error_setg(errp, "Missing websocket version header data"); goto bad_request; } key = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_KEY); if (!key) { error_setg(errp, "Missing websocket key header data"); goto bad_request; } host = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_HOST); if (!host) { error_setg(errp, "Missing websocket host header data"); goto bad_request; } connection = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_CONNECTION); if (!connection) { error_setg(errp, "Missing websocket connection header data"); goto bad_request; } upgrade = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_UPGRADE); if (!upgrade) { error_setg(errp, "Missing websocket upgrade header data"); goto bad_request; } if (!g_strrstr(protocols, QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY)) { error_setg(errp, "No '%s' protocol is supported by client '%s'", QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY, protocols); goto bad_request; } if (!g_str_equal(version, QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION)) { error_setg(errp, "Version '%s' is not supported by client '%s'", QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION, version); goto bad_request; } if (strlen(key) != QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN) { error_setg(errp, "Key length '%zu' was not as expected '%d'", strlen(key), QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN); goto bad_request; } if (!g_strrstr(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE)) { error_setg(errp, "No connection upgrade requested '%s'", connection); goto bad_request; } if (!g_str_equal(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET)) { error_setg(errp, "Incorrect upgrade method '%s'", upgrade); goto bad_request; } qio_channel_websock_handshake_send_res_ok(ioc, key, errp); return; bad_request: qio_channel_websock_handshake_send_res_err( ioc, QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_BAD_REQUEST); }
9,206
qemu
c1755b14fade16f02d3e10a487a03741a2f317ce
0
uint16_t css_build_subchannel_id(SubchDev *sch) { if (channel_subsys.max_cssid > 0) { return (sch->cssid << 8) | (1 << 3) | (sch->ssid << 1) | 1; } return (sch->ssid << 1) | 1; }
9,208
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
0
void aio_bh_call(QEMUBH *bh) { bh->cb(bh->opaque); }
9,209
qemu
0d0e044dee0ed59628bb093a5be03528d6bde445
0
static void gd_connect_signals(GtkDisplayState *s) { g_signal_connect(s->show_tabs_item, "activate", G_CALLBACK(gd_menu_show_tabs), s); g_signal_connect(s->window, "key-press-event", G_CALLBACK(gd_window_key_event), s); g_signal_connect(s->window, "delete-event", G_CALLBACK(gd_window_close), s); #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect(s->drawing_area, "draw", G_CALLBACK(gd_draw_event), s); #else g_signal_connect(s->drawing_area, "expose-event", G_CALLBACK(gd_expose_event), s); #endif g_signal_connect(s->drawing_area, "motion-notify-event", G_CALLBACK(gd_motion_event), s); g_signal_connect(s->drawing_area, "button-press-event", G_CALLBACK(gd_button_event), s); g_signal_connect(s->drawing_area, "button-release-event", G_CALLBACK(gd_button_event), s); g_signal_connect(s->drawing_area, "scroll-event", G_CALLBACK(gd_scroll_event), s); g_signal_connect(s->drawing_area, "key-press-event", G_CALLBACK(gd_key_event), s); g_signal_connect(s->drawing_area, "key-release-event", G_CALLBACK(gd_key_event), s); g_signal_connect(s->pause_item, "activate", G_CALLBACK(gd_menu_pause), s); g_signal_connect(s->reset_item, "activate", G_CALLBACK(gd_menu_reset), s); g_signal_connect(s->powerdown_item, "activate", G_CALLBACK(gd_menu_powerdown), s); g_signal_connect(s->quit_item, "activate", G_CALLBACK(gd_menu_quit), s); g_signal_connect(s->full_screen_item, "activate", G_CALLBACK(gd_menu_full_screen), s); g_signal_connect(s->zoom_in_item, "activate", G_CALLBACK(gd_menu_zoom_in), s); g_signal_connect(s->zoom_out_item, "activate", G_CALLBACK(gd_menu_zoom_out), s); g_signal_connect(s->zoom_fixed_item, "activate", G_CALLBACK(gd_menu_zoom_fixed), s); g_signal_connect(s->zoom_fit_item, "activate", G_CALLBACK(gd_menu_zoom_fit), s); g_signal_connect(s->vga_item, "activate", G_CALLBACK(gd_menu_switch_vc), s); g_signal_connect(s->grab_item, "activate", G_CALLBACK(gd_menu_grab_input), s); g_signal_connect(s->notebook, "switch-page", G_CALLBACK(gd_change_page), s); g_signal_connect(s->drawing_area, "enter-notify-event", G_CALLBACK(gd_enter_event), s); g_signal_connect(s->drawing_area, "leave-notify-event", G_CALLBACK(gd_leave_event), s); g_signal_connect(s->drawing_area, "focus-out-event", G_CALLBACK(gd_focus_out_event), s); }
9,212
FFmpeg
2cc51d5025c976aa268a854df1eec86014512c8c
0
int ff_v4l2_context_set_status(V4L2Context* ctx, int cmd) { int type = ctx->type; int ret; ret = ioctl(ctx_to_m2mctx(ctx)->fd, cmd, &type); if (ret < 0) return AVERROR(errno); ctx->streamon = (cmd == VIDIOC_STREAMON); return 0; }
9,213
qemu
aa9438d9f8a19258514c5cc238d2494a2572ff58
0
static void scoop_writeb(void *opaque, target_phys_addr_t addr, uint32_t value) { ScoopInfo *s = (ScoopInfo *) opaque; value &= 0xffff; switch (addr) { case SCOOP_MCR: s->mcr = value; break; case SCOOP_CDR: s->cdr = value; break; case SCOOP_CPR: s->power = value; if (value & 0x80) s->power |= 0x8040; break; case SCOOP_CCR: s->ccr = value; break; case SCOOP_IRR_IRM: s->irr = value; break; case SCOOP_IMR: s->imr = value; break; case SCOOP_ISR: s->isr = value; break; case SCOOP_GPCR: s->gpio_dir = value; scoop_gpio_handler_update(s); break; case SCOOP_GPWR: case SCOOP_GPRR: /* GPRR is probably R/O in real HW */ s->gpio_level = value & s->gpio_dir; scoop_gpio_handler_update(s); break; default: zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr); } }
9,214
qemu
494a8ebe713055d3946183f4b395f85a18b43e9e
0
static int proxy_lsetxattr(FsContext *ctx, V9fsPath *fs_path, const char *name, void *value, size_t size, int flags) { int retval; V9fsString xname, xvalue; v9fs_string_init(&xname); v9fs_string_sprintf(&xname, "%s", name); v9fs_string_init(&xvalue); xvalue.size = size; xvalue.data = g_malloc(size); memcpy(xvalue.data, value, size); retval = v9fs_request(ctx->private, T_LSETXATTR, value, "sssdd", fs_path, &xname, &xvalue, size, flags); v9fs_string_free(&xname); v9fs_string_free(&xvalue); if (retval < 0) { errno = -retval; } return retval; }
9,216
qemu
41c01ee7157c04abea1b97ab409cd5065ecd30bd
0
static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration) { int dev_descr_len, config_descr_len; int interface, nb_interfaces; int ret, i; if (configuration == 0) /* address state - ignore */ return 1; DPRINTF("husb: claiming interfaces. config %d\n", configuration); i = 0; dev_descr_len = dev->descr[0]; if (dev_descr_len > dev->descr_len) { goto fail; } i += dev_descr_len; while (i < dev->descr_len) { DPRINTF("husb: i is %d, descr_len is %d, dl %d, dt %d\n", i, dev->descr_len, dev->descr[i], dev->descr[i+1]); if (dev->descr[i+1] != USB_DT_CONFIG) { i += dev->descr[i]; continue; } config_descr_len = dev->descr[i]; printf("husb: config #%d need %d\n", dev->descr[i + 5], configuration); if (configuration < 0 || configuration == dev->descr[i + 5]) { configuration = dev->descr[i + 5]; break; } i += config_descr_len; } if (i >= dev->descr_len) { fprintf(stderr, "husb: update iface failed. no matching configuration\n"); goto fail; } nb_interfaces = dev->descr[i + 4]; #ifdef USBDEVFS_DISCONNECT /* earlier Linux 2.4 do not support that */ { struct usbdevfs_ioctl ctrl; for (interface = 0; interface < nb_interfaces; interface++) { ctrl.ioctl_code = USBDEVFS_DISCONNECT; ctrl.ifno = interface; ctrl.data = 0; ret = ioctl(dev->fd, USBDEVFS_IOCTL, &ctrl); if (ret < 0 && errno != ENODATA) { perror("USBDEVFS_DISCONNECT"); goto fail; } } } #endif /* XXX: only grab if all interfaces are free */ for (interface = 0; interface < nb_interfaces; interface++) { ret = ioctl(dev->fd, USBDEVFS_CLAIMINTERFACE, &interface); if (ret < 0) { if (errno == EBUSY) { printf("husb: update iface. device already grabbed\n"); } else { perror("husb: failed to claim interface"); } fail: return 0; } } printf("husb: %d interfaces claimed for configuration %d\n", nb_interfaces, configuration); dev->ninterfaces = nb_interfaces; dev->configuration = configuration; return 1; }
9,217
qemu
210b580b106fa798149e28aa13c66b325a43204e
0
static void rtas_nvram_store(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { sPAPRNVRAM *nvram = spapr->nvram; hwaddr offset, buffer, len; int alen; void *membuf; if ((nargs != 3) || (nret != 2)) { rtas_st(rets, 0, -3); return; } if (!nvram) { rtas_st(rets, 0, -1); return; } offset = rtas_ld(args, 0); buffer = rtas_ld(args, 1); len = rtas_ld(args, 2); if (((offset + len) < offset) || ((offset + len) > nvram->size)) { rtas_st(rets, 0, -3); return; } membuf = cpu_physical_memory_map(buffer, &len, 0); if (nvram->drive) { alen = bdrv_pwrite(nvram->drive, offset, membuf, len); } else { assert(nvram->buf); memcpy(nvram->buf + offset, membuf, len); alen = len; } cpu_physical_memory_unmap(membuf, len, 0, len); rtas_st(rets, 0, (alen < len) ? -1 : 0); rtas_st(rets, 1, (alen < 0) ? 0 : alen); }
9,219
qemu
0719e71e5297f68b6b4500aa74e1b49d59806342
0
static bool sd_get_inserted(SDState *sd) { return blk_is_inserted(sd->blk); }
9,221
qemu
185698715dfb18c82ad2a5dbc169908602d43e81
0
uint32_t helper_efdctsi (uint64_t val) { CPU_DoubleU u; u.ll = val; /* NaN are not treated the same way IEEE 754 does */ if (unlikely(float64_is_nan(u.d))) return 0; return float64_to_int32(u.d, &env->vec_status); }
9,222
qemu
1c7242da851cc65a2cc93fbc6defa964084a2826
0
target_ulong helper_yield(target_ulong arg1) { if (arg1 < 0) { /* No scheduling policy implemented. */ if (arg1 != -2) { if (env->CP0_VPEControl & (1 << CP0VPECo_YSI) && env->active_tc.CP0_TCStatus & (1 << CP0TCSt_DT)) { env->CP0_VPEControl &= ~(0x7 << CP0VPECo_EXCPT); env->CP0_VPEControl |= 4 << CP0VPECo_EXCPT; helper_raise_exception(EXCP_THREAD); } } } else if (arg1 == 0) { if (0 /* TODO: TC underflow */) { env->CP0_VPEControl &= ~(0x7 << CP0VPECo_EXCPT); helper_raise_exception(EXCP_THREAD); } else { // TODO: Deallocate TC } } else if (arg1 > 0) { /* Yield qualifier inputs not implemented. */ env->CP0_VPEControl &= ~(0x7 << CP0VPECo_EXCPT); env->CP0_VPEControl |= 2 << CP0VPECo_EXCPT; helper_raise_exception(EXCP_THREAD); } return env->CP0_YQMask; }
9,223
FFmpeg
2d71f31df23910f18b17f17fa568b13fd5dcaf1a
0
static int lag_read_prob_header(lag_rac *rac, GetBitContext *gb) { int i, j, scale_factor; unsigned prob, cumulative_target; unsigned cumul_prob = 0; unsigned scaled_cumul_prob = 0; rac->prob[0] = 0; rac->prob[257] = UINT_MAX; /* Read probabilities from bitstream */ for (i = 1; i < 257; i++) { if (lag_decode_prob(gb, &rac->prob[i]) < 0) { av_log(rac->avctx, AV_LOG_ERROR, "Invalid probability encountered.\n"); return -1; } if ((uint64_t)cumul_prob + rac->prob[i] > UINT_MAX) { av_log(rac->avctx, AV_LOG_ERROR, "Integer overflow encountered in cumulative probability calculation.\n"); return -1; } cumul_prob += rac->prob[i]; if (!rac->prob[i]) { if (lag_decode_prob(gb, &prob)) { av_log(rac->avctx, AV_LOG_ERROR, "Invalid probability run encountered.\n"); return -1; } if (prob > 257 - i) prob = 257 - i; for (j = 0; j < prob; j++) rac->prob[++i] = 0; } } if (!cumul_prob) { av_log(rac->avctx, AV_LOG_ERROR, "All probabilities are 0!\n"); return -1; } /* Scale probabilities so cumulative probability is an even power of 2. */ scale_factor = av_log2(cumul_prob); if (cumul_prob & (cumul_prob - 1)) { uint64_t mul = softfloat_reciprocal(cumul_prob); for (i = 1; i < 257; i++) { rac->prob[i] = softfloat_mul(rac->prob[i], mul); scaled_cumul_prob += rac->prob[i]; } scale_factor++; cumulative_target = 1 << scale_factor; if (scaled_cumul_prob > cumulative_target) { av_log(rac->avctx, AV_LOG_ERROR, "Scaled probabilities are larger than target!\n"); return -1; } scaled_cumul_prob = cumulative_target - scaled_cumul_prob; for (i = 1; scaled_cumul_prob; i = (i & 0x7f) + 1) { if (rac->prob[i]) { rac->prob[i]++; scaled_cumul_prob--; } /* Comment from reference source: * if (b & 0x80 == 0) { // order of operations is 'wrong'; it has been left this way * // since the compression change is negligable and fixing it * // breaks backwards compatibility * b =- (signed int)b; * b &= 0xFF; * } else { * b++; * b &= 0x7f; * } */ } } rac->scale = scale_factor; /* Fill probability array with cumulative probability for each symbol. */ for (i = 1; i < 257; i++) rac->prob[i] += rac->prob[i - 1]; return 0; }
9,224
qemu
acd82796211041c5af43c8c523b85d250c2ccebe
1
MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data, unsigned size, MemTxAttrs attrs) { GICv3State *s = opaque; GICv3CPUState *cs; MemTxResult r; int cpuidx; /* This region covers all the redistributor pages; there are * (for GICv3) two 64K pages per CPU. At the moment they are * all contiguous (ie in this one region), though we might later * want to allow splitting of redistributor pages into several * blocks so we can support more CPUs. */ cpuidx = offset / 0x20000; offset %= 0x20000; assert(cpuidx < s->num_cpu); cs = &s->cpu[cpuidx]; switch (size) { case 1: r = gicr_readb(cs, offset, data, attrs); break; case 4: r = gicr_readl(cs, offset, data, attrs); break; case 8: r = gicr_readll(cs, offset, data, attrs); break; default: r = MEMTX_ERROR; break; } if (r == MEMTX_ERROR) { qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid guest read at offset " TARGET_FMT_plx "size %u\n", __func__, offset, size); trace_gicv3_redist_badread(gicv3_redist_affid(cs), offset, size, attrs.secure); } else { trace_gicv3_redist_read(gicv3_redist_affid(cs), offset, *data, size, attrs.secure); } return r; }
9,228
FFmpeg
d468ff0fdfdd3ff8f54adea3dd1ef4b94cb8538d
1
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length){ const uint8_t *end= buffer+length; #if !CONFIG_SMALL if(!ctx[256]) while(buffer<end-3){ crc ^= le2me_32(*(const uint32_t*)buffer); buffer+=4; crc = ctx[3*256 + ( crc &0xFF)] ^ctx[2*256 + ((crc>>8 )&0xFF)] ^ctx[1*256 + ((crc>>16)&0xFF)] ^ctx[0*256 + ((crc>>24) )]; } #endif while(buffer<end) crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8); return crc; }
9,230
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
1
void migrate_add_blocker(Error *reason) { migration_blockers = g_slist_prepend(migration_blockers, reason); }
9,232
FFmpeg
c99bd29462e1735ff85980e57ee57e55d1cc6745
1
static int encode_superframe(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ WMACodecContext *s = avctx->priv_data; const short *samples = data; int i, total_gain; s->block_len_bits= s->frame_len_bits; //required by non variable block len s->block_len = 1 << s->block_len_bits; apply_window_and_mdct(avctx, samples, avctx->frame_size); if (s->ms_stereo) { float a, b; int i; for(i = 0; i < s->block_len; i++) { a = s->coefs[0][i]*0.5; b = s->coefs[1][i]*0.5; s->coefs[0][i] = a + b; s->coefs[1][i] = a - b; } } if (buf_size < 2 * MAX_CODED_SUPERFRAME_SIZE) { av_log(avctx, AV_LOG_ERROR, "output buffer size is too small\n"); return AVERROR(EINVAL); } #if 1 total_gain= 128; for(i=64; i; i>>=1){ int error= encode_frame(s, s->coefs, buf, buf_size, total_gain-i); if(error<0) total_gain-= i; } #else total_gain= 90; best= encode_frame(s, s->coefs, buf, buf_size, total_gain); for(i=32; i; i>>=1){ int scoreL= encode_frame(s, s->coefs, buf, buf_size, total_gain-i); int scoreR= encode_frame(s, s->coefs, buf, buf_size, total_gain+i); av_log(NULL, AV_LOG_ERROR, "%d %d %d (%d)\n", scoreL, best, scoreR, total_gain); if(scoreL < FFMIN(best, scoreR)){ best = scoreL; total_gain -= i; }else if(scoreR < best){ best = scoreR; total_gain += i; } } #endif if ((i = encode_frame(s, s->coefs, buf, buf_size, total_gain)) >= 0) { av_log(avctx, AV_LOG_ERROR, "required frame size too large. please " "use a higher bit rate.\n"); return AVERROR(EINVAL); } assert((put_bits_count(&s->pb) & 7) == 0); while (i++) put_bits(&s->pb, 8, 'N'); flush_put_bits(&s->pb); return s->block_align; }
9,233
FFmpeg
5ff998a233d759d0de83ea6f95c383d03d25d88e
1
static int encode_residual_ch(FlacEncodeContext *s, int ch) { int i, n; int min_order, max_order, opt_order, omethod; FlacFrame *frame; FlacSubframe *sub; int32_t coefs[MAX_LPC_ORDER][MAX_LPC_ORDER]; int shift[MAX_LPC_ORDER]; int32_t *res, *smp; frame = &s->frame; sub = &frame->subframes[ch]; res = sub->residual; smp = sub->samples; n = frame->blocksize; /* CONSTANT */ for (i = 1; i < n; i++) if(smp[i] != smp[0]) break; if (i == n) { sub->type = sub->type_code = FLAC_SUBFRAME_CONSTANT; res[0] = smp[0]; return subframe_count_exact(s, sub, 0); } /* VERBATIM */ if (frame->verbatim_only || n < 5) { sub->type = sub->type_code = FLAC_SUBFRAME_VERBATIM; memcpy(res, smp, n * sizeof(int32_t)); return subframe_count_exact(s, sub, 0); } min_order = s->options.min_prediction_order; max_order = s->options.max_prediction_order; omethod = s->options.prediction_order_method; /* FIXED */ sub->type = FLAC_SUBFRAME_FIXED; if (s->options.lpc_type == FF_LPC_TYPE_NONE || s->options.lpc_type == FF_LPC_TYPE_FIXED || n <= max_order) { uint32_t bits[MAX_FIXED_ORDER+1]; if (max_order > MAX_FIXED_ORDER) max_order = MAX_FIXED_ORDER; opt_order = 0; bits[0] = UINT32_MAX; for (i = min_order; i <= max_order; i++) { encode_residual_fixed(res, smp, n, i); bits[i] = find_subframe_rice_params(s, sub, i); if (bits[i] < bits[opt_order]) opt_order = i; } sub->order = opt_order; sub->type_code = sub->type | sub->order; if (sub->order != max_order) { encode_residual_fixed(res, smp, n, sub->order); find_subframe_rice_params(s, sub, sub->order); } return subframe_count_exact(s, sub, sub->order); } /* LPC */ sub->type = FLAC_SUBFRAME_LPC; opt_order = ff_lpc_calc_coefs(&s->lpc_ctx, smp, n, min_order, max_order, s->options.lpc_coeff_precision, coefs, shift, s->options.lpc_type, s->options.lpc_passes, omethod, MAX_LPC_SHIFT, 0); if (omethod == ORDER_METHOD_2LEVEL || omethod == ORDER_METHOD_4LEVEL || omethod == ORDER_METHOD_8LEVEL) { int levels = 1 << omethod; uint32_t bits[1 << ORDER_METHOD_8LEVEL]; int order; int opt_index = levels-1; opt_order = max_order-1; bits[opt_index] = UINT32_MAX; for (i = levels-1; i >= 0; i--) { order = min_order + (((max_order-min_order+1) * (i+1)) / levels)-1; if (order < 0) order = 0; encode_residual_lpc(res, smp, n, order+1, coefs[order], shift[order]); bits[i] = find_subframe_rice_params(s, sub, order+1); if (bits[i] < bits[opt_index]) { opt_index = i; opt_order = order; } } opt_order++; } else if (omethod == ORDER_METHOD_SEARCH) { // brute-force optimal order search uint32_t bits[MAX_LPC_ORDER]; opt_order = 0; bits[0] = UINT32_MAX; for (i = min_order-1; i < max_order; i++) { encode_residual_lpc(res, smp, n, i+1, coefs[i], shift[i]); bits[i] = find_subframe_rice_params(s, sub, i+1); if (bits[i] < bits[opt_order]) opt_order = i; } opt_order++; } else if (omethod == ORDER_METHOD_LOG) { uint32_t bits[MAX_LPC_ORDER]; int step; opt_order = min_order - 1 + (max_order-min_order)/3; memset(bits, -1, sizeof(bits)); for (step = 16; step; step >>= 1) { int last = opt_order; for (i = last-step; i <= last+step; i += step) { if (i < min_order-1 || i >= max_order || bits[i] < UINT32_MAX) continue; encode_residual_lpc(res, smp, n, i+1, coefs[i], shift[i]); bits[i] = find_subframe_rice_params(s, sub, i+1); if (bits[i] < bits[opt_order]) opt_order = i; } } opt_order++; } sub->order = opt_order; sub->type_code = sub->type | (sub->order-1); sub->shift = shift[sub->order-1]; for (i = 0; i < sub->order; i++) sub->coefs[i] = coefs[sub->order-1][i]; encode_residual_lpc(res, smp, n, sub->order, sub->coefs, sub->shift); find_subframe_rice_params(s, sub, sub->order); return subframe_count_exact(s, sub, sub->order); }
9,234
FFmpeg
189ff4219644532bdfa7bab28dfedaee4d6d4021
1
static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, AVDictionary *opts, AVDictionary *opts2, int *is_http) { HLSContext *c = s->priv_data; AVDictionary *tmp = NULL; const char *proto_name = NULL; int ret; av_dict_copy(&tmp, opts, 0); av_dict_copy(&tmp, opts2, 0); if (av_strstart(url, "crypto", NULL)) { if (url[6] == '+' || url[6] == ':') proto_name = avio_find_protocol_name(url + 7); } if (!proto_name) proto_name = avio_find_protocol_name(url); if (!proto_name) return AVERROR_INVALIDDATA; // only http(s) & file are allowed if (!av_strstart(proto_name, "http", NULL) && !av_strstart(proto_name, "file", NULL)) return AVERROR_INVALIDDATA; if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] == ':') ; else if (av_strstart(url, "crypto", NULL) && !strncmp(proto_name, url + 7, strlen(proto_name)) && url[7 + strlen(proto_name)] == ':') ; else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5)) return AVERROR_INVALIDDATA; ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp); if (ret >= 0) { // update cookies on http response with setcookies. char *new_cookies = NULL; if (!(s->flags & AVFMT_FLAG_CUSTOM_IO)) av_opt_get(*pb, "cookies", AV_OPT_SEARCH_CHILDREN, (uint8_t**)&new_cookies); if (new_cookies) { av_free(c->cookies); c->cookies = new_cookies; } av_dict_set(&opts, "cookies", c->cookies, 0); } av_dict_free(&tmp); if (is_http) *is_http = av_strstart(proto_name, "http", NULL); return ret; }
9,235
qemu
5ea2fc84da1bffce749c9d0848f5336def2818bb
1
static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, abi_ulong parent_tidptr, target_ulong newtls, abi_ulong child_tidptr) { CPUState *cpu = ENV_GET_CPU(env); int ret; TaskState *ts; CPUState *new_cpu; CPUArchState *new_env; sigset_t sigmask; /* Emulate vfork() with fork() */ if (flags & CLONE_VFORK) flags &= ~(CLONE_VFORK | CLONE_VM); if (flags & CLONE_VM) { TaskState *parent_ts = (TaskState *)cpu->opaque; new_thread_info info; pthread_attr_t attr; ts = g_new0(TaskState, 1); init_task_state(ts); /* we create a new CPU instance. */ new_env = cpu_copy(env); /* Init regs that differ from the parent. */ cpu_clone_regs(new_env, newsp); new_cpu = ENV_GET_CPU(new_env); new_cpu->opaque = ts; ts->bprm = parent_ts->bprm; ts->info = parent_ts->info; ts->signal_mask = parent_ts->signal_mask; if (flags & CLONE_CHILD_CLEARTID) { ts->child_tidptr = child_tidptr; } if (flags & CLONE_SETTLS) { cpu_set_tls (new_env, newtls); } /* Grab a mutex so that thread setup appears atomic. */ pthread_mutex_lock(&clone_lock); memset(&info, 0, sizeof(info)); pthread_mutex_init(&info.mutex, NULL); pthread_mutex_lock(&info.mutex); pthread_cond_init(&info.cond, NULL); info.env = new_env; if (flags & CLONE_CHILD_SETTID) { info.child_tidptr = child_tidptr; } if (flags & CLONE_PARENT_SETTID) { info.parent_tidptr = parent_tidptr; } ret = pthread_attr_init(&attr); ret = pthread_attr_setstacksize(&attr, NEW_STACK_SIZE); ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); /* It is not safe to deliver signals until the child has finished initializing, so temporarily block all signals. */ sigfillset(&sigmask); sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask); ret = pthread_create(&info.thread, &attr, clone_func, &info); /* TODO: Free new CPU state if thread creation failed. */ sigprocmask(SIG_SETMASK, &info.sigmask, NULL); pthread_attr_destroy(&attr); if (ret == 0) { /* Wait for the child to initialize. */ pthread_cond_wait(&info.cond, &info.mutex); ret = info.tid; } else { ret = -1; } pthread_mutex_unlock(&info.mutex); pthread_cond_destroy(&info.cond); pthread_mutex_destroy(&info.mutex); pthread_mutex_unlock(&clone_lock); } else { /* if no CLONE_VM, we consider it is a fork */ if ((flags & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0) { return -TARGET_EINVAL; } if (block_signals()) { return -TARGET_ERESTARTSYS; } fork_start(); ret = fork(); if (ret == 0) { /* Child Process. */ rcu_after_fork(); cpu_clone_regs(env, newsp); fork_end(1); /* There is a race condition here. The parent process could theoretically read the TID in the child process before the child tid is set. This would require using either ptrace (not implemented) or having *_tidptr to point at a shared memory mapping. We can't repeat the spinlock hack used above because the child process gets its own copy of the lock. */ if (flags & CLONE_CHILD_SETTID) put_user_u32(gettid(), child_tidptr); if (flags & CLONE_PARENT_SETTID) put_user_u32(gettid(), parent_tidptr); ts = (TaskState *)cpu->opaque; if (flags & CLONE_SETTLS) cpu_set_tls (env, newtls); if (flags & CLONE_CHILD_CLEARTID) ts->child_tidptr = child_tidptr; } else { fork_end(0); } } return ret; }
9,236
FFmpeg
64b164f44abc232dbb125b36e2d00b54e1531ba7
1
static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, const char *name, const char *args, AVClass *log_ctx) { AVFilterContext *filt; AVFilter *filterdef; char inst_name[30]; snprintf(inst_name, sizeof(inst_name), "Parsed filter %d", index); filterdef = avfilter_get_by_name(name); if(!filterdef) { av_log(log_ctx, AV_LOG_ERROR, "no such filter: '%s'\n", name); return NULL; } filt = avfilter_open(filterdef, inst_name); if(!filt) { av_log(log_ctx, AV_LOG_ERROR, "error creating filter '%s'\n", name); return NULL; } if(avfilter_graph_add_filter(ctx, filt) < 0) return NULL; if(avfilter_init_filter(filt, args, NULL)) { av_log(log_ctx, AV_LOG_ERROR, "error initializing filter '%s' with args '%s'\n", name, args); return NULL; } return filt; }
9,237
FFmpeg
502d6c0a234b10f65acb0a203aedf14de70dc555
1
static int find_tag(ByteIOContext *pb, uint32_t tag1) { unsigned int tag; int size; for(;;) { if (url_feof(pb)) return -1; tag = get_le32(pb); size = get_le32(pb); if (tag == tag1) break; url_fseek(pb, size, SEEK_CUR); } if (size < 0) size = 0x7fffffff; return size; }
9,239
FFmpeg
6f1ccca4ae3b93b6a2a820a7a0e72081ab35767c
0
static av_always_inline int dnxhd_decode_dct_block(const DNXHDContext *ctx, RowContext *row, int n, int index_bits, int level_bias, int level_shift) { int i, j, index1, index2, len, flags; int level, component, sign; const int *scale; const uint8_t *weight_matrix; const uint8_t *ac_level = ctx->cid_table->ac_level; const uint8_t *ac_flags = ctx->cid_table->ac_flags; int16_t *block = row->blocks[n]; const int eob_index = ctx->cid_table->eob_index; int ret = 0; OPEN_READER(bs, &row->gb); ctx->bdsp.clear_block(block); if (!ctx->is_444) { if (n & 2) { component = 1 + (n & 1); scale = row->chroma_scale; weight_matrix = ctx->cid_table->chroma_weight; } else { component = 0; scale = row->luma_scale; weight_matrix = ctx->cid_table->luma_weight; } } else { component = (n >> 1) % 3; if (component) { scale = row->chroma_scale; weight_matrix = ctx->cid_table->chroma_weight; } else { scale = row->luma_scale; weight_matrix = ctx->cid_table->luma_weight; } } UPDATE_CACHE(bs, &row->gb); GET_VLC(len, bs, &row->gb, ctx->dc_vlc.table, DNXHD_DC_VLC_BITS, 1); if (len) { level = GET_CACHE(bs, &row->gb); LAST_SKIP_BITS(bs, &row->gb, len); sign = ~level >> 31; level = (NEG_USR32(sign ^ level, len) ^ sign) - sign; row->last_dc[component] += level; } block[0] = row->last_dc[component]; i = 0; UPDATE_CACHE(bs, &row->gb); GET_VLC(index1, bs, &row->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2); while (index1 != eob_index) { level = ac_level[index1]; flags = ac_flags[index1]; sign = SHOW_SBITS(bs, &row->gb, 1); SKIP_BITS(bs, &row->gb, 1); if (flags & 1) { level += SHOW_UBITS(bs, &row->gb, index_bits) << 7; SKIP_BITS(bs, &row->gb, index_bits); } if (flags & 2) { UPDATE_CACHE(bs, &row->gb); GET_VLC(index2, bs, &row->gb, ctx->run_vlc.table, DNXHD_VLC_BITS, 2); i += ctx->cid_table->run[index2]; } if (++i > 63) { av_log(ctx->avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", n, i); ret = -1; break; } j = ctx->scantable.permutated[i]; level *= scale[i]; level += scale[i] >> 1; if (level_bias < 32 || weight_matrix[i] != level_bias) level += level_bias; // 1<<(level_shift-1) level >>= level_shift; block[j] = (level ^ sign) - sign; UPDATE_CACHE(bs, &row->gb); GET_VLC(index1, bs, &row->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2); } CLOSE_READER(bs, &row->gb); return ret; }
9,240
FFmpeg
d549b0910c3471beb9ef268ce0d70d3ab9ed7bb3
0
static int read_data(void *opaque, uint8_t *buf, int buf_size) { struct playlist *v = opaque; HLSContext *c = v->parent->priv_data; int ret, i; int just_opened = 0; if (!v->needed) return AVERROR_EOF; restart: if (!v->input) { /* If this is a live stream and the reload interval has elapsed since * the last playlist reload, reload the playlists now. */ int64_t reload_interval = default_reload_interval(v); reload: if (!v->finished && av_gettime() - v->last_load_time >= reload_interval) { if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) { av_log(v->parent, AV_LOG_WARNING, "Failed to reload playlist %d\n", v->index); return ret; } /* If we need to reload the playlist again below (if * there's still no more segments), switch to a reload * interval of half the target duration. */ reload_interval = v->target_duration / 2; } if (v->cur_seq_no < v->start_seq_no) { av_log(NULL, AV_LOG_WARNING, "skipping %d segments ahead, expired from playlists\n", v->start_seq_no - v->cur_seq_no); v->cur_seq_no = v->start_seq_no; } if (v->cur_seq_no >= v->start_seq_no + v->n_segments) { if (v->finished) return AVERROR_EOF; while (av_gettime() - v->last_load_time < reload_interval) { if (ff_check_interrupt(c->interrupt_callback)) return AVERROR_EXIT; av_usleep(100*1000); } /* Enough time has elapsed since the last reload */ goto reload; } ret = open_input(c, v); if (ret < 0) { av_log(v->parent, AV_LOG_WARNING, "Failed to open segment of playlist %d\n", v->index); return ret; } just_opened = 1; } ret = read_from_url(v, buf, buf_size, READ_NORMAL); if (ret > 0) { if (just_opened && v->is_id3_timestamped != 0) { /* Intercept ID3 tags here, elementary audio streams are required * to convey timestamps using them in the beginning of each segment. */ intercept_id3(v, buf, buf_size, &ret); } return ret; } ffurl_close(v->input); v->input = NULL; v->cur_seq_no++; c->end_of_segment = 1; c->cur_seq_no = v->cur_seq_no; if (v->ctx && v->ctx->nb_streams && v->parent->nb_streams >= v->stream_offset + v->ctx->nb_streams) { v->needed = 0; for (i = v->stream_offset; i < v->stream_offset + v->ctx->nb_streams; i++) { if (v->parent->streams[i]->discard < AVDISCARD_ALL) v->needed = 1; } } if (!v->needed) { av_log(v->parent, AV_LOG_INFO, "No longer receiving playlist %d\n", v->index); return AVERROR_EOF; } goto restart; }
9,242
FFmpeg
a794356602af59029c765555361166128f74ae9e
0
static int decode_header(SnowContext *s){ int plane_index, tmp; uint8_t kstate[32]; memset(kstate, MID_STATE, sizeof(kstate)); s->keyframe= get_rac(&s->c, kstate); if(s->keyframe || s->always_reset){ reset_contexts(s); s->spatial_decomposition_type= s->qlog= s->qbias= s->mv_scale= s->block_max_depth= 0; } if(s->keyframe){ s->version= get_symbol(&s->c, s->header_state, 0); if(s->version>0){ av_log(s->avctx, AV_LOG_ERROR, "version %d not supported", s->version); return -1; } s->always_reset= get_rac(&s->c, s->header_state); s->temporal_decomposition_type= get_symbol(&s->c, s->header_state, 0); s->temporal_decomposition_count= get_symbol(&s->c, s->header_state, 0); s->spatial_decomposition_count= get_symbol(&s->c, s->header_state, 0); s->colorspace_type= get_symbol(&s->c, s->header_state, 0); s->chroma_h_shift= get_symbol(&s->c, s->header_state, 0); s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0); s->spatial_scalability= get_rac(&s->c, s->header_state); // s->rate_scalability= get_rac(&s->c, s->header_state); tmp= get_symbol(&s->c, s->header_state, 0)+1; if(tmp < 1 || tmp > MAX_REF_FRAMES){ av_log(s->avctx, AV_LOG_ERROR, "reference frame count is %d\n", tmp); return -1; } s->max_ref_frames= tmp; decode_qlogs(s); } if(!s->keyframe){ if(get_rac(&s->c, s->header_state)){ for(plane_index=0; plane_index<2; plane_index++){ int htaps, i, sum=0; Plane *p= &s->plane[plane_index]; p->diag_mc= get_rac(&s->c, s->header_state); htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2; if((unsigned)htaps > HTAPS_MAX || htaps==0) return -1; p->htaps= htaps; for(i= htaps/2; i; i--){ p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1)); sum += p->hcoeff[i]; } p->hcoeff[0]= 32-sum; } s->plane[2].diag_mc= s->plane[1].diag_mc; s->plane[2].htaps = s->plane[1].htaps; memcpy(s->plane[2].hcoeff, s->plane[1].hcoeff, sizeof(s->plane[1].hcoeff)); } if(get_rac(&s->c, s->header_state)){ s->spatial_decomposition_count= get_symbol(&s->c, s->header_state, 0); decode_qlogs(s); } } s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1); if(s->spatial_decomposition_type > 1){ av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported", s->spatial_decomposition_type); return -1; } s->qlog += get_symbol(&s->c, s->header_state, 1); s->mv_scale += get_symbol(&s->c, s->header_state, 1); s->qbias += get_symbol(&s->c, s->header_state, 1); s->block_max_depth+= get_symbol(&s->c, s->header_state, 1); if(s->block_max_depth > 1 || s->block_max_depth < 0){ av_log(s->avctx, AV_LOG_ERROR, "block_max_depth= %d is too large", s->block_max_depth); s->block_max_depth= 0; return -1; } return 0; }
9,243
FFmpeg
750562549ceef268b29b94f6a887d9cf331a8c78
0
static av_cold void x8_vlc_init(void){ int i; int offset = 0; int sizeidx = 0; static const uint16_t sizes[8*4 + 8*2 + 2 + 4] = { 576, 548, 582, 618, 546, 616, 560, 642, 584, 582, 704, 664, 512, 544, 656, 640, 512, 648, 582, 566, 532, 614, 596, 648, 586, 552, 584, 590, 544, 578, 584, 624, 528, 528, 526, 528, 536, 528, 526, 544, 544, 512, 512, 528, 528, 544, 512, 544, 128, 128, 128, 128, 128, 128}; static VLC_TYPE table[28150][2]; #define init_ac_vlc(dst,src) \ dst.table = &table[offset]; \ dst.table_allocated = sizes[sizeidx]; \ offset += sizes[sizeidx++]; \ init_vlc(&dst, \ AC_VLC_BITS,77, \ &src[1],4,2, \ &src[0],4,2, \ INIT_VLC_USE_NEW_STATIC) //set ac tables for(i=0;i<8;i++){ init_ac_vlc( j_ac_vlc[0][0][i], x8_ac0_highquant_table[i][0] ); init_ac_vlc( j_ac_vlc[0][1][i], x8_ac1_highquant_table[i][0] ); init_ac_vlc( j_ac_vlc[1][0][i], x8_ac0_lowquant_table [i][0] ); init_ac_vlc( j_ac_vlc[1][1][i], x8_ac1_lowquant_table [i][0] ); } #undef init_ac_vlc //set dc tables #define init_dc_vlc(dst,src) \ dst.table = &table[offset]; \ dst.table_allocated = sizes[sizeidx]; \ offset += sizes[sizeidx++]; \ init_vlc(&dst, \ DC_VLC_BITS,34, \ &src[1],4,2, \ &src[0],4,2, \ INIT_VLC_USE_NEW_STATIC); for(i=0;i<8;i++){ init_dc_vlc( j_dc_vlc[0][i], x8_dc_highquant_table[i][0]); init_dc_vlc( j_dc_vlc[1][i], x8_dc_lowquant_table [i][0]); } #undef init_dc_vlc //set orient tables #define init_or_vlc(dst,src) \ dst.table = &table[offset]; \ dst.table_allocated = sizes[sizeidx]; \ offset += sizes[sizeidx++]; \ init_vlc(&dst, \ OR_VLC_BITS,12, \ &src[1],4,2, \ &src[0],4,2, \ INIT_VLC_USE_NEW_STATIC); for(i=0;i<2;i++){ init_or_vlc( j_orient_vlc[0][i], x8_orient_highquant_table[i][0]); } for(i=0;i<4;i++){ init_or_vlc( j_orient_vlc[1][i], x8_orient_lowquant_table [i][0]) } if (offset != sizeof(table)/sizeof(VLC_TYPE)/2) av_log(NULL, AV_LOG_ERROR, "table size %i does not match needed %i\n", (int)(sizeof(table)/sizeof(VLC_TYPE)/2), offset); }
9,244
FFmpeg
8b47058c61af83c28231b860d46ee754ed7a9310
0
static int ass_split(ASSSplitContext *ctx, const char *buf) { char c, section[16]; int i; if (ctx->current_section >= 0) buf = ass_split_section(ctx, buf); while (buf && *buf) { if (sscanf(buf, "[%15[0-9A-Za-z+ ]]%c", section, &c) == 2) { buf += strcspn(buf, "\n") + 1; for (i=0; i<FF_ARRAY_ELEMS(ass_sections); i++) if (!strcmp(section, ass_sections[i].section)) { ctx->current_section = i; buf = ass_split_section(ctx, buf); } } else buf += strcspn(buf, "\n") + 1; } return buf ? 0 : AVERROR_INVALIDDATA; }
9,245
FFmpeg
71953ebcf94fe4ef316cdad1f276089205dd1d65
0
static int aac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AACContext *ac = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; GetBitContext gb; int buf_consumed; int buf_offset; int err; int new_extradata_size; const uint8_t *new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &new_extradata_size); if (new_extradata) { av_free(avctx->extradata); avctx->extradata = av_mallocz(new_extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); avctx->extradata_size = new_extradata_size; memcpy(avctx->extradata, new_extradata, new_extradata_size); push_output_configuration(ac); if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, avctx->extradata, avctx->extradata_size*8, 1) < 0) { pop_output_configuration(ac); return AVERROR_INVALIDDATA; } } init_get_bits(&gb, buf, buf_size * 8); if ((err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb)) < 0) return err; buf_consumed = (get_bits_count(&gb) + 7) >> 3; for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++) if (buf[buf_offset]) break; return buf_size > buf_offset ? buf_consumed : buf_size; }
9,247
qemu
a7812ae412311d7d47f8aa85656faadac9d64b56
0
static inline void t_gen_swapw(TCGv d, TCGv s) { TCGv t; /* d and s refer the same object. */ t = tcg_temp_new(TCG_TYPE_TL); tcg_gen_mov_tl(t, s); tcg_gen_shli_tl(d, t, 16); tcg_gen_shri_tl(t, t, 16); tcg_gen_or_tl(d, d, t); tcg_temp_free(t); }
9,251
qemu
67a0fd2a9bca204d2b39f910a97c7137636a0715
0
static int get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, MapEntry *e) { int64_t ret; int depth; /* As an optimization, we could cache the current range of unallocated * clusters in each file of the chain, and avoid querying the same * range repeatedly. */ depth = 0; for (;;) { ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &nb_sectors); if (ret < 0) { return ret; } assert(nb_sectors); if (ret & (BDRV_BLOCK_ZERO|BDRV_BLOCK_DATA)) { break; } bs = backing_bs(bs); if (bs == NULL) { ret = 0; break; } depth++; } e->start = sector_num * BDRV_SECTOR_SIZE; e->length = nb_sectors * BDRV_SECTOR_SIZE; e->flags = ret & ~BDRV_BLOCK_OFFSET_MASK; e->offset = ret & BDRV_BLOCK_OFFSET_MASK; e->depth = depth; e->bs = bs; return 0; }
9,252
qemu
f0ddf11b23260f0af84fb529486a8f9ba2d19401
0
void HELPER(cas2w)(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2) { uint32_t Dc1 = extract32(regs, 9, 3); uint32_t Dc2 = extract32(regs, 6, 3); uint32_t Du1 = extract32(regs, 3, 3); uint32_t Du2 = extract32(regs, 0, 3); int16_t c1 = env->dregs[Dc1]; int16_t c2 = env->dregs[Dc2]; int16_t u1 = env->dregs[Du1]; int16_t u2 = env->dregs[Du2]; int16_t l1, l2; uintptr_t ra = GETPC(); if (parallel_cpus) { /* Tell the main loop we need to serialize this insn. */ cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } else { /* We're executing in a serial context -- no need to be atomic. */ l1 = cpu_lduw_data_ra(env, a1, ra); l2 = cpu_lduw_data_ra(env, a2, ra); if (l1 == c1 && l2 == c2) { cpu_stw_data_ra(env, a1, u1, ra); cpu_stw_data_ra(env, a2, u2, ra); } } if (c1 != l1) { env->cc_n = l1; env->cc_v = c1; } else { env->cc_n = l2; env->cc_v = c2; } env->cc_op = CC_OP_CMPW; env->dregs[Dc1] = deposit32(env->dregs[Dc1], 0, 16, l1); env->dregs[Dc2] = deposit32(env->dregs[Dc2], 0, 16, l2); }
9,253
qemu
4dae83aeac63863af6b59f58552da68b35b1a40d
0
static void glib_select_fill(int *max_fd, fd_set *rfds, fd_set *wfds, fd_set *xfds, struct timeval *tv) { GMainContext *context = g_main_context_default(); int i; int timeout = 0, cur_timeout; g_main_context_prepare(context, &max_priority); n_poll_fds = g_main_context_query(context, max_priority, &timeout, poll_fds, ARRAY_SIZE(poll_fds)); g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds)); for (i = 0; i < n_poll_fds; i++) { GPollFD *p = &poll_fds[i]; if ((p->events & G_IO_IN)) { FD_SET(p->fd, rfds); *max_fd = MAX(*max_fd, p->fd); } if ((p->events & G_IO_OUT)) { FD_SET(p->fd, wfds); *max_fd = MAX(*max_fd, p->fd); } if ((p->events & G_IO_ERR)) { FD_SET(p->fd, xfds); *max_fd = MAX(*max_fd, p->fd); } } cur_timeout = (tv->tv_sec * 1000) + ((tv->tv_usec + 500) / 1000); if (timeout >= 0 && timeout < cur_timeout) { tv->tv_sec = timeout / 1000; tv->tv_usec = (timeout % 1000) * 1000; } }
9,254
qemu
2c6942fa7b332a95286071b92d233853e1000948
0
void bdrv_info(Monitor *mon, QObject **ret_data) { QList *bs_list; BlockDriverState *bs; bs_list = qlist_new(); QTAILQ_FOREACH(bs, &bdrv_states, list) { QObject *bs_obj; bs_obj = qobject_from_jsonf("{ 'device': %s, 'type': 'unknown', " "'removable': %i, 'locked': %i }", bs->device_name, bs->removable, bdrv_dev_is_medium_locked(bs)); if (bs->drv) { QObject *obj; QDict *bs_dict = qobject_to_qdict(bs_obj); obj = qobject_from_jsonf("{ 'file': %s, 'ro': %i, 'drv': %s, " "'encrypted': %i }", bs->filename, bs->read_only, bs->drv->format_name, bdrv_is_encrypted(bs)); if (bs->backing_file[0] != '\0') { QDict *qdict = qobject_to_qdict(obj); qdict_put(qdict, "backing_file", qstring_from_str(bs->backing_file)); } qdict_put_obj(bs_dict, "inserted", obj); } qlist_append_obj(bs_list, bs_obj); } *ret_data = QOBJECT(bs_list); }
9,256
qemu
be09ac4194bd0a61c0d9412c32431fbe2273cba1
0
static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags, abi_ulong target_addr, abi_ulong target_addrlen) { socklen_t addrlen; void *addr; void *host_msg; abi_long ret; host_msg = lock_user(VERIFY_WRITE, msg, len, 0); if (!host_msg) return -TARGET_EFAULT; if (target_addr) { if (get_user_u32(addrlen, target_addrlen)) { ret = -TARGET_EFAULT; goto fail; } if (addrlen < 0 || addrlen > MAX_SOCK_ADDR) { ret = -TARGET_EINVAL; goto fail; } addr = alloca(addrlen); ret = get_errno(recvfrom(fd, host_msg, len, flags, addr, &addrlen)); } else { addr = NULL; /* To keep compiler quiet. */ ret = get_errno(recv(fd, host_msg, len, flags)); } if (!is_error(ret)) { if (target_addr) { host_to_target_sockaddr(target_addr, addr, addrlen); if (put_user_u32(addrlen, target_addrlen)) { ret = -TARGET_EFAULT; goto fail; } } unlock_user(host_msg, msg, len); } else { fail: unlock_user(host_msg, msg, 0); } return ret; }
9,257
qemu
e3a0abfda71db1fa83be894dcff7c4871b36cc8d
0
static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc) { PageDesc *pd; void **lp; int i; #if defined(CONFIG_USER_ONLY) /* We can't use g_malloc because it may recurse into a locked mutex. */ # define ALLOC(P, SIZE) \ do { \ P = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, \ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \ } while (0) #else # define ALLOC(P, SIZE) \ do { P = g_malloc0(SIZE); } while (0) #endif /* Level 1. Always allocated. */ lp = l1_map + ((index >> V_L1_SHIFT) & (V_L1_SIZE - 1)); /* Level 2..N-1. */ for (i = V_L1_SHIFT / V_L2_BITS - 1; i > 0; i--) { void **p = *lp; if (p == NULL) { if (!alloc) { return NULL; } ALLOC(p, sizeof(void *) * V_L2_SIZE); *lp = p; } lp = p + ((index >> (i * V_L2_BITS)) & (V_L2_SIZE - 1)); } pd = *lp; if (pd == NULL) { if (!alloc) { return NULL; } ALLOC(pd, sizeof(PageDesc) * V_L2_SIZE); *lp = pd; } #undef ALLOC return pd + (index & (V_L2_SIZE - 1)); }
9,259
qemu
d20a580bc0eac9d489884f6d2ed28105880532b6
0
static void pointer_event(VncState *vs, int button_mask, int x, int y) { static uint32_t bmap[INPUT_BUTTON__MAX] = { [INPUT_BUTTON_LEFT] = 0x01, [INPUT_BUTTON_MIDDLE] = 0x02, [INPUT_BUTTON_RIGHT] = 0x04, [INPUT_BUTTON_WHEEL_UP] = 0x08, [INPUT_BUTTON_WHEEL_DOWN] = 0x10, }; QemuConsole *con = vs->vd->dcl.con; int width = pixman_image_get_width(vs->vd->server); int height = pixman_image_get_height(vs->vd->server); if (vs->last_bmask != button_mask) { qemu_input_update_buttons(con, bmap, vs->last_bmask, button_mask); vs->last_bmask = button_mask; } if (vs->absolute) { qemu_input_queue_abs(con, INPUT_AXIS_X, x, width); qemu_input_queue_abs(con, INPUT_AXIS_Y, y, height); } else if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE)) { qemu_input_queue_rel(con, INPUT_AXIS_X, x - 0x7FFF); qemu_input_queue_rel(con, INPUT_AXIS_Y, y - 0x7FFF); } else { if (vs->last_x != -1) { qemu_input_queue_rel(con, INPUT_AXIS_X, x - vs->last_x); qemu_input_queue_rel(con, INPUT_AXIS_Y, y - vs->last_y); } vs->last_x = x; vs->last_y = y; } qemu_input_event_sync(); }
9,261
qemu
5efdf53227809a0da436dd63d7ed19c99044ecbd
0
static bool is_zero_cluster(BlockDriverState *bs, int64_t start) { BDRVQcow2State *s = bs->opaque; int nr; BlockDriverState *file; int64_t res = bdrv_get_block_status_above(bs, NULL, start, s->cluster_sectors, &nr, &file); return res >= 0 && (res & BDRV_BLOCK_ZERO); }
9,262
qemu
75af1f34cd5b07c3c7fcf86dfc99a42de48a600d
0
static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, BdrvRequestFlags flags) { if (nb_sectors < 0 || nb_sectors > (UINT_MAX >> BDRV_SECTOR_BITS)) { return -EINVAL; } return bdrv_co_do_preadv(bs, sector_num << BDRV_SECTOR_BITS, nb_sectors << BDRV_SECTOR_BITS, qiov, flags); }
9,263
qemu
f17fd4fdf0df3d2f3444399d04c38d22b9a3e1b7
0
void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) { const char *param = qdict_get_str(qdict, "parameter"); const char *valuestr = qdict_get_str(qdict, "value"); int64_t valuebw = 0; long valueint = 0; Error *err = NULL; bool use_int_value = false; int i; for (i = 0; i < MIGRATION_PARAMETER__MAX; i++) { if (strcmp(param, MigrationParameter_lookup[i]) == 0) { MigrationParameters p = { 0 }; switch (i) { case MIGRATION_PARAMETER_COMPRESS_LEVEL: p.has_compress_level = true; use_int_value = true; break; case MIGRATION_PARAMETER_COMPRESS_THREADS: p.has_compress_threads = true; use_int_value = true; break; case MIGRATION_PARAMETER_DECOMPRESS_THREADS: p.has_decompress_threads = true; use_int_value = true; break; case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL: p.has_cpu_throttle_initial = true; use_int_value = true; break; case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT: p.has_cpu_throttle_increment = true; use_int_value = true; break; case MIGRATION_PARAMETER_TLS_CREDS: p.has_tls_creds = true; p.tls_creds = (char *) valuestr; break; case MIGRATION_PARAMETER_TLS_HOSTNAME: p.has_tls_hostname = true; p.tls_hostname = (char *) valuestr; break; case MIGRATION_PARAMETER_MAX_BANDWIDTH: p.has_max_bandwidth = true; valuebw = qemu_strtosz_MiB(valuestr, NULL); if (valuebw < 0 || (size_t)valuebw != valuebw) { error_setg(&err, "Invalid size %s", valuestr); goto cleanup; } p.max_bandwidth = valuebw; break; case MIGRATION_PARAMETER_DOWNTIME_LIMIT: p.has_downtime_limit = true; use_int_value = true; break; case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY: p.has_x_checkpoint_delay = true; use_int_value = true; break; } if (use_int_value) { if (qemu_strtol(valuestr, NULL, 10, &valueint) < 0) { error_setg(&err, "Unable to parse '%s' as an int", valuestr); goto cleanup; } /* Set all integers; only one has_FOO will be set, and * the code ignores the remaining values */ p.compress_level = valueint; p.compress_threads = valueint; p.decompress_threads = valueint; p.cpu_throttle_initial = valueint; p.cpu_throttle_increment = valueint; p.downtime_limit = valueint; p.x_checkpoint_delay = valueint; } qmp_migrate_set_parameters(&p, &err); break; } } if (i == MIGRATION_PARAMETER__MAX) { error_setg(&err, QERR_INVALID_PARAMETER, param); } cleanup: if (err) { error_report_err(err); } }
9,264
qemu
45876e913e169bf156a3fc36f21eb0adf6ec3671
0
static void mcf5208evb_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; M68kCPU *cpu; CPUM68KState *env; int kernel_size; uint64_t elf_entry; hwaddr entry; qemu_irq *pic; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *sram = g_new(MemoryRegion, 1); if (!cpu_model) { cpu_model = "m5208"; } cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model)); env = &cpu->env; /* Initialize CPU registers. */ env->vbr = 0; /* TODO: Configure BARs. */ /* DRAM at 0x40000000 */ memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_size); memory_region_add_subregion(address_space_mem, 0x40000000, ram); /* Internal SRAM. */ memory_region_init_ram(sram, NULL, "mcf5208.sram", 16384, &error_fatal); memory_region_add_subregion(address_space_mem, 0x80000000, sram); /* Internal peripherals. */ pic = mcf_intc_init(address_space_mem, 0xfc048000, cpu); mcf_uart_mm_init(0xfc060000, pic[26], serial_hds[0]); mcf_uart_mm_init(0xfc064000, pic[27], serial_hds[1]); mcf_uart_mm_init(0xfc068000, pic[28], serial_hds[2]); mcf5208_sys_init(address_space_mem, pic); if (nb_nics > 1) { fprintf(stderr, "Too many NICs\n"); exit(1); } if (nd_table[0].used) { mcf_fec_init(address_space_mem, &nd_table[0], 0xfc030000, pic + 36); } /* 0xfc000000 SCM. */ /* 0xfc004000 XBS. */ /* 0xfc008000 FlexBus CS. */ /* 0xfc030000 FEC. */ /* 0xfc040000 SCM + Power management. */ /* 0xfc044000 eDMA. */ /* 0xfc048000 INTC. */ /* 0xfc058000 I2C. */ /* 0xfc05c000 QSPI. */ /* 0xfc060000 UART0. */ /* 0xfc064000 UART0. */ /* 0xfc068000 UART0. */ /* 0xfc070000 DMA timers. */ /* 0xfc080000 PIT0. */ /* 0xfc084000 PIT1. */ /* 0xfc088000 EPORT. */ /* 0xfc08c000 Watchdog. */ /* 0xfc090000 clock module. */ /* 0xfc0a0000 CCM + reset. */ /* 0xfc0a4000 GPIO. */ /* 0xfc0a8000 SDRAM controller. */ /* Load kernel. */ if (!kernel_filename) { if (qtest_enabled()) { return; } fprintf(stderr, "Kernel image must be specified\n"); exit(1); } kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry, NULL, NULL, 1, EM_68K, 0, 0); entry = elf_entry; if (kernel_size < 0) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL, NULL, NULL); } if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, 0x40000000, ram_size); entry = 0x40000000; } if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } env->pc = entry; }
9,265
qemu
d0d7708ba29cbcc343364a46bff981e0ff88366f
0
static CharDriverState *qemu_chr_open_tty_fd(int fd) { CharDriverState *chr; tty_serial_init(fd, 115200, 'N', 8, 1); chr = qemu_chr_open_fd(fd, fd); chr->chr_ioctl = tty_serial_ioctl; chr->chr_close = qemu_chr_close_tty; return chr; }
9,266
qemu
faabdbb792889bf011a593578d1de51e14616bb7
0
void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp) { Error *local_err = NULL; Object *obj = OBJECT(dev); /* * TODO qdev_prop_ptr does not have getters or setters. It must * go now that it can be replaced with links. The test should be * removed along with it: all static properties are read/write. */ if (!prop->info->get && !prop->info->set) { return; } object_property_add(obj, prop->name, prop->info->name, prop->info->get, prop->info->set, prop->info->release, prop, &local_err); if (local_err) { error_propagate(errp, local_err); return; } object_property_set_description(obj, prop->name, prop->info->description, &error_abort); if (prop->info->set_default_value) { prop->info->set_default_value(obj, prop); } }
9,267
qemu
786a4ea82ec9c87e3a895cf41081029b285a5fe5
0
static uint16_t shpc_get_status(SHPCDevice *shpc, int slot, uint16_t msk) { uint8_t *status = shpc->config + SHPC_SLOT_STATUS(slot); return (pci_get_word(status) & msk) >> (ffs(msk) - 1); }
9,268
FFmpeg
dc5d1515681b57a257443ba72bb81fb3e6e6621b
0
static int hls_start(AVFormatContext *s, VariantStream *vs) { HLSContext *c = s->priv_data; AVFormatContext *oc = vs->avf; AVFormatContext *vtt_oc = vs->vtt_avf; AVDictionary *options = NULL; char *filename, iv_string[KEYSIZE*2 + 1]; int err = 0; if (c->flags & HLS_SINGLE_FILE) { av_strlcpy(oc->filename, vs->basename, sizeof(oc->filename)); if (vs->vtt_basename) av_strlcpy(vtt_oc->filename, vs->vtt_basename, sizeof(vtt_oc->filename)); } else if (c->max_seg_size > 0) { if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename), #if FF_API_HLS_WRAP vs->basename, 'd', c->wrap ? vs->sequence % c->wrap : vs->sequence) < 1) { #else vs->basename, 'd', vs->sequence) < 1) { #endif av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s', you can try to use -use_localtime 1 with it\n", vs->basename); return AVERROR(EINVAL); } } else { if (c->use_localtime) { time_t now0; struct tm *tm, tmpbuf; time(&now0); tm = localtime_r(&now0, &tmpbuf); if (!strftime(oc->filename, sizeof(oc->filename), vs->basename, tm)) { av_log(oc, AV_LOG_ERROR, "Could not get segment filename with use_localtime\n"); return AVERROR(EINVAL); } err = sls_flag_use_localtime_filename(oc, c, vs); if (err < 0) { return AVERROR(ENOMEM); } if (c->use_localtime_mkdir) { const char *dir; char *fn_copy = av_strdup(oc->filename); if (!fn_copy) { return AVERROR(ENOMEM); } dir = av_dirname(fn_copy); if (mkdir_p(dir) == -1 && errno != EEXIST) { av_log(oc, AV_LOG_ERROR, "Could not create directory %s with use_localtime_mkdir\n", dir); av_free(fn_copy); return AVERROR(errno); } av_free(fn_copy); } } else if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename), #if FF_API_HLS_WRAP vs->basename, 'd', c->wrap ? vs->sequence % c->wrap : vs->sequence) < 1) { #else vs->basename, 'd', vs->sequence) < 1) { #endif av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s' you can try to use -use_localtime 1 with it\n", vs->basename); return AVERROR(EINVAL); } if( vs->vtt_basename) { if (replace_int_data_in_filename(vtt_oc->filename, sizeof(vtt_oc->filename), #if FF_API_HLS_WRAP vs->vtt_basename, 'd', c->wrap ? vs->sequence % c->wrap : vs->sequence) < 1) { #else vs->vtt_basename, 'd', vs->sequence) < 1) { #endif av_log(vtt_oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", vs->vtt_basename); return AVERROR(EINVAL); } } } vs->number++; set_http_options(s, &options, c); if (c->flags & HLS_TEMP_FILE) { av_strlcat(oc->filename, ".tmp", sizeof(oc->filename)); } if (c->key_info_file || c->encrypt) { if (c->key_info_file && c->encrypt) { av_log(s, AV_LOG_WARNING, "Cannot use both -hls_key_info_file and -hls_enc," " will use -hls_key_info_file priority\n"); } if (!c->encrypt_started || (c->flags & HLS_PERIODIC_REKEY)) { if (c->key_info_file) { if ((err = hls_encryption_start(s)) < 0) goto fail; } else { if ((err = do_encrypt(s, vs)) < 0) goto fail; } c->encrypt_started = 1; } if ((err = av_dict_set(&options, "encryption_key", c->key_string, 0)) < 0) goto fail; err = av_strlcpy(iv_string, c->iv_string, sizeof(iv_string)); if (!err) snprintf(iv_string, sizeof(iv_string), "%032"PRIx64, vs->sequence); if ((err = av_dict_set(&options, "encryption_iv", iv_string, 0)) < 0) goto fail; filename = av_asprintf("crypto:%s", oc->filename); if (!filename) { err = AVERROR(ENOMEM); goto fail; } err = hlsenc_io_open(s, &oc->pb, filename, &options); av_free(filename); av_dict_free(&options); if (err < 0) return err; } else if (c->segment_type != SEGMENT_TYPE_FMP4) { if ((err = hlsenc_io_open(s, &oc->pb, oc->filename, &options)) < 0) goto fail; } if (vs->vtt_basename) { set_http_options(s, &options, c); if ((err = hlsenc_io_open(s, &vtt_oc->pb, vtt_oc->filename, &options)) < 0) goto fail; } av_dict_free(&options); if (c->segment_type != SEGMENT_TYPE_FMP4) { /* We only require one PAT/PMT per segment. */ if (oc->oformat->priv_class && oc->priv_data) { char period[21]; snprintf(period, sizeof(period), "%d", (INT_MAX / 2) - 1); av_opt_set(oc->priv_data, "mpegts_flags", "resend_headers", 0); av_opt_set(oc->priv_data, "sdt_period", period, 0); av_opt_set(oc->priv_data, "pat_period", period, 0); } } if (vs->vtt_basename) { err = avformat_write_header(vtt_oc,NULL); if (err < 0) return err; } return 0; fail: av_dict_free(&options); return err; }
9,269
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
0
void virtio_submit_multiwrite(BlockDriverState *bs, MultiReqBuffer *mrb) { int i, ret; if (!mrb->num_writes) { return; } ret = bdrv_aio_multiwrite(bs, mrb->blkreq, mrb->num_writes); if (ret != 0) { for (i = 0; i < mrb->num_writes; i++) { if (mrb->blkreq[i].error) { virtio_blk_rw_complete(mrb->blkreq[i].opaque, -EIO); } } } mrb->num_writes = 0; }
9,270
qemu
a369da5f31ddbdeb32a7f76622e480d3995fbb00
0
DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus) { DeviceState *dev = NULL; if (cirrus_vga_enabled) { if (pci_bus) { dev = pci_cirrus_vga_init(pci_bus); } else { dev = isa_cirrus_vga_init(get_system_memory()); } } else if (vmsvga_enabled) { if (pci_bus) { dev = pci_vmsvga_init(pci_bus); if (!dev) { fprintf(stderr, "Warning: vmware_vga not available," " using standard VGA instead\n"); dev = pci_vga_init(pci_bus); } } else { fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__); } #ifdef CONFIG_SPICE } else if (qxl_enabled) { if (pci_bus) { dev = &pci_create_simple(pci_bus, -1, "qxl-vga")->qdev; } else { fprintf(stderr, "%s: qxl: no PCI bus\n", __FUNCTION__); } #endif } else if (std_vga_enabled) { if (pci_bus) { dev = pci_vga_init(pci_bus); } else { dev = isa_vga_init(isa_bus); } } return dev; }
9,271
qemu
ddca7f86ac022289840e0200fd4050b2b58e9176
0
static void v9fs_version(void *opaque) { V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; V9fsString version; size_t offset = 7; pdu_unmarshal(pdu, offset, "ds", &s->msize, &version); trace_v9fs_version(pdu->tag, pdu->id, s->msize, version.data); virtfs_reset(pdu); if (!strcmp(version.data, "9P2000.u")) { s->proto_version = V9FS_PROTO_2000U; } else if (!strcmp(version.data, "9P2000.L")) { s->proto_version = V9FS_PROTO_2000L; } else { v9fs_string_sprintf(&version, "unknown"); } offset += pdu_marshal(pdu, offset, "ds", s->msize, &version); trace_v9fs_version_return(pdu->tag, pdu->id, s->msize, version.data); complete_pdu(s, pdu, offset); v9fs_string_free(&version); return; }
9,272
qemu
1945dbc15f0f1ffdc9a10526448e9eba7c599d98
0
static void openpic_irq_raise(openpic_t *opp, int n_CPU, IRQ_src_t *src) { int n_ci = IDR_CI0 - n_CPU; if ((opp->flags & OPENPIC_FLAG_IDE_CRIT) && test_bit(&src->ide, n_ci)) { qemu_irq_raise(opp->dst[n_CPU].irqs[OPENPIC_OUTPUT_CINT]); } else { qemu_irq_raise(opp->dst[n_CPU].irqs[OPENPIC_OUTPUT_INT]); } }
9,273
qemu
b7680cb6078bd7294a3dd86473d3f2fdee991dd0
0
void vm_stop(int reason) { QemuThread me; qemu_thread_self(&me); if (!qemu_thread_equal(&me, &io_thread)) { qemu_system_vmstop_request(reason); /* * FIXME: should not return to device code in case * vm_stop() has been requested. */ cpu_stop_current(); return; } do_vm_stop(reason); }
9,274
qemu
61007b316cd71ee7333ff7a0a749a8949527575f
0
int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset, const void *buf, int count) { int ret; ret = bdrv_pwrite(bs, offset, buf, count); if (ret < 0) { return ret; } /* No flush needed for cache modes that already do it */ if (bs->enable_write_cache) { bdrv_flush(bs); } return 0; }
9,275
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
0
static uint64_t mv88w8618_pit_read(void *opaque, target_phys_addr_t offset, unsigned size) { mv88w8618_pit_state *s = opaque; mv88w8618_timer_state *t; switch (offset) { case MP_PIT_TIMER1_VALUE ... MP_PIT_TIMER4_VALUE: t = &s->timer[(offset-MP_PIT_TIMER1_VALUE) >> 2]; return ptimer_get_count(t->ptimer); default: return 0; } }
9,276
FFmpeg
154b8bb80029e71d562e8936164266300dd35a0e
1
static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AMRWBContext *ctx = avctx->priv_data; AMRWBFrame *cf = &ctx->frame; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int expected_fr_size, header_size; float *buf_out; float spare_vector[AMRWB_SFR_SIZE]; // extra stack space to hold result from anti-sparseness processing float fixed_gain_factor; // fixed gain correction factor (gamma) float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use float synth_fixed_gain; // the fixed gain that synthesis should use float voice_fac, stab_fac; // parameters used for gain smoothing float synth_exc[AMRWB_SFR_SIZE]; // post-processed excitation for synthesis float hb_exc[AMRWB_SFR_SIZE_16k]; // excitation for the high frequency band float hb_samples[AMRWB_SFR_SIZE_16k]; // filtered high-band samples from synthesis float hb_gain; int sub, i, ret; /* get output buffer */ ctx->avframe.nb_samples = 4 * AMRWB_SFR_SIZE_16k; if ((ret = avctx->get_buffer(avctx, &ctx->avframe)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } buf_out = (float *)ctx->avframe.data[0]; header_size = decode_mime_header(ctx, buf); expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; if (buf_size < expected_fr_size) { av_log(avctx, AV_LOG_ERROR, "Frame too small (%d bytes). Truncated file?\n", buf_size); *got_frame_ptr = 0; return buf_size; } if (!ctx->fr_quality || ctx->fr_cur_mode > MODE_SID) av_log(avctx, AV_LOG_ERROR, "Encountered a bad or corrupted frame\n"); if (ctx->fr_cur_mode == MODE_SID) /* Comfort noise frame */ av_log_missing_feature(avctx, "SID mode", 1); if (ctx->fr_cur_mode >= MODE_SID) return -1; ff_amr_bit_reorder((uint16_t *) &ctx->frame, sizeof(AMRWBFrame), buf + header_size, amr_bit_orderings_by_mode[ctx->fr_cur_mode]); /* Decode the quantized ISF vector */ if (ctx->fr_cur_mode == MODE_6k60) { decode_isf_indices_36b(cf->isp_id, ctx->isf_cur); } else { decode_isf_indices_46b(cf->isp_id, ctx->isf_cur); } isf_add_mean_and_past(ctx->isf_cur, ctx->isf_q_past); ff_set_min_dist_lsf(ctx->isf_cur, MIN_ISF_SPACING, LP_ORDER - 1); stab_fac = stability_factor(ctx->isf_cur, ctx->isf_past_final); ctx->isf_cur[LP_ORDER - 1] *= 2.0; ff_acelp_lsf2lspd(ctx->isp[3], ctx->isf_cur, LP_ORDER); /* Generate a ISP vector for each subframe */ if (ctx->first_frame) { ctx->first_frame = 0; memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(double)); } interpolate_isp(ctx->isp, ctx->isp_sub4_past); for (sub = 0; sub < 4; sub++) ff_amrwb_lsp2lpc(ctx->isp[sub], ctx->lp_coef[sub], LP_ORDER); for (sub = 0; sub < 4; sub++) { const AMRWBSubFrame *cur_subframe = &cf->subframe[sub]; float *sub_buf = buf_out + sub * AMRWB_SFR_SIZE_16k; /* Decode adaptive codebook (pitch vector) */ decode_pitch_vector(ctx, cur_subframe, sub); /* Decode innovative codebook (fixed vector) */ decode_fixed_vector(ctx->fixed_vector, cur_subframe->pul_ih, cur_subframe->pul_il, ctx->fr_cur_mode); pitch_sharpening(ctx, ctx->fixed_vector); decode_gains(cur_subframe->vq_gain, ctx->fr_cur_mode, &fixed_gain_factor, &ctx->pitch_gain[0]); ctx->fixed_gain[0] = ff_amr_set_fixed_gain(fixed_gain_factor, ff_dot_productf(ctx->fixed_vector, ctx->fixed_vector, AMRWB_SFR_SIZE) / AMRWB_SFR_SIZE, ctx->prediction_error, ENERGY_MEAN, energy_pred_fac); /* Calculate voice factor and store tilt for next subframe */ voice_fac = voice_factor(ctx->pitch_vector, ctx->pitch_gain[0], ctx->fixed_vector, ctx->fixed_gain[0]); ctx->tilt_coef = voice_fac * 0.25 + 0.25; /* Construct current excitation */ for (i = 0; i < AMRWB_SFR_SIZE; i++) { ctx->excitation[i] *= ctx->pitch_gain[0]; ctx->excitation[i] += ctx->fixed_gain[0] * ctx->fixed_vector[i]; ctx->excitation[i] = truncf(ctx->excitation[i]); } /* Post-processing of excitation elements */ synth_fixed_gain = noise_enhancer(ctx->fixed_gain[0], &ctx->prev_tr_gain, voice_fac, stab_fac); synth_fixed_vector = anti_sparseness(ctx, ctx->fixed_vector, spare_vector); pitch_enhancer(synth_fixed_vector, voice_fac); synthesis(ctx, ctx->lp_coef[sub], synth_exc, synth_fixed_gain, synth_fixed_vector, &ctx->samples_az[LP_ORDER]); /* Synthesis speech post-processing */ de_emphasis(&ctx->samples_up[UPS_MEM_SIZE], &ctx->samples_az[LP_ORDER], PREEMPH_FAC, ctx->demph_mem); ff_acelp_apply_order_2_transfer_function(&ctx->samples_up[UPS_MEM_SIZE], &ctx->samples_up[UPS_MEM_SIZE], hpf_zeros, hpf_31_poles, hpf_31_gain, ctx->hpf_31_mem, AMRWB_SFR_SIZE); upsample_5_4(sub_buf, &ctx->samples_up[UPS_FIR_SIZE], AMRWB_SFR_SIZE_16k); /* High frequency band (6.4 - 7.0 kHz) generation part */ ff_acelp_apply_order_2_transfer_function(hb_samples, &ctx->samples_up[UPS_MEM_SIZE], hpf_zeros, hpf_400_poles, hpf_400_gain, ctx->hpf_400_mem, AMRWB_SFR_SIZE); hb_gain = find_hb_gain(ctx, hb_samples, cur_subframe->hb_gain, cf->vad); scaled_hb_excitation(ctx, hb_exc, synth_exc, hb_gain); hb_synthesis(ctx, sub, &ctx->samples_hb[LP_ORDER_16k], hb_exc, ctx->isf_cur, ctx->isf_past_final); /* High-band post-processing filters */ hb_fir_filter(hb_samples, bpf_6_7_coef, ctx->bpf_6_7_mem, &ctx->samples_hb[LP_ORDER_16k]); if (ctx->fr_cur_mode == MODE_23k85) hb_fir_filter(hb_samples, lpf_7_coef, ctx->lpf_7_mem, hb_samples); /* Add the low and high frequency bands */ for (i = 0; i < AMRWB_SFR_SIZE_16k; i++) sub_buf[i] = (sub_buf[i] + hb_samples[i]) * (1.0f / (1 << 15)); /* Update buffers and history */ update_sub_state(ctx); } /* update state for next frame */ memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0])); memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float)); *got_frame_ptr = 1; *(AVFrame *)data = ctx->avframe; return expected_fr_size; }
9,277
qemu
ff1d2ac949dc94d8a0e71fd46939fb69c2ef075b
1
static ssize_t mcf_fec_receive(NetClientState *nc, const uint8_t *buf, size_t size) { mcf_fec_state *s = qemu_get_nic_opaque(nc); mcf_fec_bd bd; uint32_t flags = 0; uint32_t addr; uint32_t crc; uint32_t buf_addr; uint8_t *crc_ptr; unsigned int buf_len; size_t retsize; DPRINTF("do_rx len %d\n", size); if (!s->rx_enabled) { return -1; } /* 4 bytes for the CRC. */ size += 4; crc = cpu_to_be32(crc32(~0, buf, size)); crc_ptr = (uint8_t *)&crc; /* Huge frames are truncted. */ if (size > FEC_MAX_FRAME_SIZE) { size = FEC_MAX_FRAME_SIZE; flags |= FEC_BD_TR | FEC_BD_LG; } /* Frames larger than the user limit just set error flags. */ if (size > (s->rcr >> 16)) { flags |= FEC_BD_LG; } addr = s->rx_descriptor; retsize = size; while (size > 0) { mcf_fec_read_bd(&bd, addr); if ((bd.flags & FEC_BD_E) == 0) { /* No descriptors available. Bail out. */ /* FIXME: This is wrong. We should probably either save the remainder for when more RX buffers are available, or flag an error. */ fprintf(stderr, "mcf_fec: Lost end of frame\n"); break; } buf_len = (size <= s->emrbr) ? size: s->emrbr; bd.length = buf_len; size -= buf_len; DPRINTF("rx_bd %x length %d\n", addr, bd.length); /* The last 4 bytes are the CRC. */ if (size < 4) buf_len += size - 4; buf_addr = bd.data; cpu_physical_memory_write(buf_addr, buf, buf_len); buf += buf_len; if (size < 4) { cpu_physical_memory_write(buf_addr + buf_len, crc_ptr, 4 - size); crc_ptr += 4 - size; } bd.flags &= ~FEC_BD_E; if (size == 0) { /* Last buffer in frame. */ bd.flags |= flags | FEC_BD_L; DPRINTF("rx frame flags %04x\n", bd.flags); s->eir |= FEC_INT_RXF; } else { s->eir |= FEC_INT_RXB; } mcf_fec_write_bd(&bd, addr); /* Advance to the next descriptor. */ if ((bd.flags & FEC_BD_W) != 0) { addr = s->erdsr; } else { addr += 8; } } s->rx_descriptor = addr; mcf_fec_enable_rx(s); mcf_fec_update(s); return retsize; }
9,278
qemu
1db6947dafa7f33a309130ccbf461748adac6da0
1
static int openfile(char *name, int flags, int growable) { if (bs) { fprintf(stderr, "file open already, try 'help close'\n"); return 1; } bs = bdrv_new("hda"); if (!bs) return 1; if (bdrv_open(bs, name, flags) == -1) { fprintf(stderr, "%s: can't open device %s\n", progname, name); bs = NULL; return 1; } if (growable) { if (!bs->drv || !bs->drv->protocol_name) { fprintf(stderr, "%s: only protocols can be opened growable\n", progname); return 1; } bs->growable = 1; } return 0; }
9,279
qemu
51a135287ae6be62d54d7ac2a99e647cbab1a828
1
static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, int write) { RBDAIOCB *acb; RADOSCB *rcb; rbd_completion_t c; int64_t off, size; char *buf; BDRVRBDState *s = bs->opaque; acb = qemu_aio_get(&rbd_aio_pool, bs, cb, opaque); acb->write = write; acb->qiov = qiov; acb->bounce = qemu_blockalign(bs, qiov->size); acb->ret = 0; acb->error = 0; acb->s = s; acb->cancelled = 0; acb->bh = NULL; if (write) { qemu_iovec_to_buffer(acb->qiov, acb->bounce); } buf = acb->bounce; off = sector_num * BDRV_SECTOR_SIZE; size = nb_sectors * BDRV_SECTOR_SIZE; s->qemu_aio_count++; /* All the RADOSCB */ rcb = qemu_malloc(sizeof(RADOSCB)); rcb->done = 0; rcb->acb = acb; rcb->buf = buf; rcb->s = acb->s; rcb->size = size; if (write) { rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c); rbd_aio_write(s->image, off, size, buf, c); } else { rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c); rbd_aio_read(s->image, off, size, buf, c); } return &acb->common; }
9,280
FFmpeg
1b539fbfe36c450a6f45706e740fd4e205b8be16
1
static int plot_cqt(AVFilterContext *ctx) { AVFilterLink *outlink = ctx->outputs[0]; ShowCQTContext *s = ctx->priv; int ret; memcpy(s->fft_result, s->fft_data, s->fft_len * sizeof(*s->fft_data)); av_fft_permute(s->fft_ctx, s->fft_result); av_fft_calc(s->fft_ctx, s->fft_result); s->fft_result[s->fft_len] = s->fft_result[0]; s->cqt_calc(s->cqt_result, s->fft_result, s->coeffs, s->cqt_len, s->fft_len); process_cqt(s); if (s->sono_h) s->update_sono(s->sono_frame, s->c_buf, s->sono_idx); if (!s->sono_count) { AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) return AVERROR(ENOMEM); if (s->bar_h) s->draw_bar(out, s->h_buf, s->rcp_h_buf, s->c_buf, s->bar_h); if (s->axis_h) s->draw_axis(out, s->axis_frame, s->c_buf, s->bar_h); if (s->sono_h) s->draw_sono(out, s->sono_frame, s->bar_h + s->axis_h, s->sono_idx); out->pts = s->frame_count; ret = ff_filter_frame(outlink, out); s->frame_count++; } s->sono_count = (s->sono_count + 1) % s->count; if (s->sono_h) s->sono_idx = (s->sono_idx + s->sono_h - 1) % s->sono_h; return ret; }
9,281
qemu
e0e2d644096c79a71099b176d08f465f6803a8b1
1
static inline void vring_used_idx_set(VirtQueue *vq, uint16_t val) { VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches); hwaddr pa = offsetof(VRingUsed, idx); virtio_stw_phys_cached(vq->vdev, &caches->used, pa, val); address_space_cache_invalidate(&caches->used, pa, sizeof(val)); vq->used_idx = val; }
9,284
qemu
723aedd53281cfa0997457cb156a59909a75f5a8
1
static void usbredir_interrupt_packet(void *priv, uint64_t id, struct usb_redir_interrupt_packet_header *interrupt_packet, uint8_t *data, int data_len) { USBRedirDevice *dev = priv; uint8_t ep = interrupt_packet->endpoint; DPRINTF("interrupt-in status %d ep %02X len %d id %"PRIu64"\n", interrupt_packet->status, ep, data_len, id); if (dev->endpoint[EP2I(ep)].type != USB_ENDPOINT_XFER_INT) { ERROR("received int packet for non interrupt endpoint %02X\n", ep); free(data); return; } if (ep & USB_DIR_IN) { if (dev->endpoint[EP2I(ep)].interrupt_started == 0) { DPRINTF("received int packet while not started ep %02X\n", ep); free(data); return; } /* bufp_alloc also adds the packet to the ep queue */ bufp_alloc(dev, data, data_len, interrupt_packet->status, ep); } else { USBPacket *p = usbredir_find_packet_by_id(dev, ep, id); if (p) { usbredir_handle_status(dev, p, interrupt_packet->status); p->actual_length = interrupt_packet->length; usb_packet_complete(&dev->dev, p); } } }
9,285
FFmpeg
7388c0c58601477db076e2e74e8b11f8a644384a
1
static int decode_band(IVI45DecContext *ctx, IVIBandDesc *band, AVCodecContext *avctx) { int result, i, t, idx1, idx2, pos; IVITile *tile; band->buf = band->bufs[ctx->dst_buf]; if (!band->buf) { av_log(avctx, AV_LOG_ERROR, "Band buffer points to no data!\n"); return AVERROR_INVALIDDATA; } band->ref_buf = band->bufs[ctx->ref_buf]; band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3); result = ctx->decode_band_hdr(ctx, band, avctx); if (result) { av_log(avctx, AV_LOG_ERROR, "Error while decoding band header: %d\n", result); return result; } if (band->is_empty) { av_log(avctx, AV_LOG_ERROR, "Empty band encountered!\n"); return AVERROR_INVALIDDATA; } band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel]; /* apply corrections to the selected rvmap table if present */ for (i = 0; i < band->num_corr; i++) { idx1 = band->corr[i * 2]; idx2 = band->corr[i * 2 + 1]; FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]); FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]); } pos = get_bits_count(&ctx->gb); for (t = 0; t < band->num_tiles; t++) { tile = &band->tiles[t]; if (tile->mb_size != band->mb_size) { av_log(avctx, AV_LOG_ERROR, "MB sizes mismatch: %d vs. %d\n", band->mb_size, tile->mb_size); return AVERROR_INVALIDDATA; } tile->is_empty = get_bits1(&ctx->gb); if (tile->is_empty) { result = ivi_process_empty_tile(avctx, band, tile, (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3)); if (result < 0) break; av_dlog(avctx, "Empty tile encountered!\n"); } else { tile->data_size = ivi_dec_tile_data_size(&ctx->gb); if (!tile->data_size) { av_log(avctx, AV_LOG_ERROR, "Tile data size is zero!\n"); return AVERROR_INVALIDDATA; } result = ctx->decode_mb_info(ctx, band, tile, avctx); if (result < 0) break; result = ivi_decode_blocks(&ctx->gb, band, tile, avctx); if (result < 0 || ((get_bits_count(&ctx->gb) - pos) >> 3) != tile->data_size) { av_log(avctx, AV_LOG_ERROR, "Corrupted tile data encountered!\n"); break; } pos += tile->data_size << 3; // skip to next tile } } /* restore the selected rvmap table by applying its corrections in reverse order */ for (i = band->num_corr-1; i >= 0; i--) { idx1 = band->corr[i*2]; idx2 = band->corr[i*2+1]; FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]); FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]); } #ifdef DEBUG if (band->checksum_present) { uint16_t chksum = ivi_calc_band_checksum(band); if (chksum != band->checksum) { av_log(avctx, AV_LOG_ERROR, "Band checksum mismatch! Plane %d, band %d, received: %x, calculated: %x\n", band->plane, band->band_num, band->checksum, chksum); } } #endif align_get_bits(&ctx->gb); return result; }
9,286
qemu
ab3ad07f89c7f9e03c17c98e1d1a02dbf61c605c
1
int e820_add_entry(uint64_t address, uint64_t length, uint32_t type) { int index = le32_to_cpu(e820_reserve.count); struct e820_entry *entry; if (type != E820_RAM) { /* old FW_CFG_E820_TABLE entry -- reservations only */ if (index >= E820_NR_ENTRIES) { return -EBUSY; } entry = &e820_reserve.entry[index++]; entry->address = cpu_to_le64(address); entry->length = cpu_to_le64(length); entry->type = cpu_to_le32(type); e820_reserve.count = cpu_to_le32(index); } /* new "etc/e820" file -- include ram too */ e820_table = g_realloc(e820_table, sizeof(struct e820_entry) * (e820_entries+1)); e820_table[e820_entries].address = cpu_to_le64(address); e820_table[e820_entries].length = cpu_to_le64(length); e820_table[e820_entries].type = cpu_to_le32(type); e820_entries++; return e820_entries; }
9,287
FFmpeg
347cb14b7cba7560e53f4434b419b9d8800253e7
1
static int mov_read_keys(MOVContext *c, AVIOContext *pb, MOVAtom atom) { uint32_t count; uint32_t i; if (atom.size < 8) return 0; avio_skip(pb, 4); count = avio_rb32(pb); if (count > UINT_MAX / sizeof(*c->meta_keys)) { av_log(c->fc, AV_LOG_ERROR, "The 'keys' atom with the invalid key count: %d\n", count); return AVERROR_INVALIDDATA; } c->meta_keys_count = count + 1; c->meta_keys = av_mallocz(c->meta_keys_count * sizeof(*c->meta_keys)); if (!c->meta_keys) return AVERROR(ENOMEM); for (i = 1; i <= count; ++i) { uint32_t key_size = avio_rb32(pb); uint32_t type = avio_rl32(pb); if (key_size < 8) { av_log(c->fc, AV_LOG_ERROR, "The key# %d in meta has invalid size: %d\n", i, key_size); return AVERROR_INVALIDDATA; } key_size -= 8; if (type != MKTAG('m','d','t','a')) { avio_skip(pb, key_size); } c->meta_keys[i] = av_mallocz(key_size + 1); if (!c->meta_keys[i]) return AVERROR(ENOMEM); avio_read(pb, c->meta_keys[i], key_size); } return 0; }
9,288
FFmpeg
5c720657c23afd798ae0db7c7362eb859a89ab3d
1
static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; uint32_t type; uint32_t av_unused ctype; int64_t title_size; char *title_str; if (c->fc->nb_streams < 1) // meta before first trak return 0; st = c->fc->streams[c->fc->nb_streams-1]; avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ /* component type */ ctype = avio_rl32(pb); type = avio_rl32(pb); /* component subtype */ av_log(c->fc, AV_LOG_TRACE, "ctype= %.4s (0x%08x)\n", (char*)&ctype, ctype); av_log(c->fc, AV_LOG_TRACE, "stype= %.4s\n", (char*)&type); if (type == MKTAG('v','i','d','e')) st->codec->codec_type = AVMEDIA_TYPE_VIDEO; else if (type == MKTAG('s','o','u','n')) st->codec->codec_type = AVMEDIA_TYPE_AUDIO; else if (type == MKTAG('m','1','a',' ')) st->codec->codec_id = AV_CODEC_ID_MP2; else if ((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p'))) st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; avio_rb32(pb); /* component manufacture */ avio_rb32(pb); /* component flags */ avio_rb32(pb); /* component flags mask */ title_size = atom.size - 24; if (title_size > 0) { title_str = av_malloc(title_size + 1); /* Add null terminator */ if (!title_str) return AVERROR(ENOMEM); avio_read(pb, title_str, title_size); title_str[title_size] = 0; if (title_str[0]) { int off = (!c->isom && title_str[0] == title_size - 1); av_dict_set(&st->metadata, "handler_name", title_str + off, 0); } av_freep(&title_str); } return 0; }
9,289
FFmpeg
f36aec3b5e18c4c167612d0051a6d5b6144b3552
1
static void chomp6(ChannelData *ctx, int16_t *output, uint8_t val, const uint16_t tab1[], const int16_t *tab2, int tab2_stride, uint32_t numChannels) { int16_t current; current = tab2[((ctx->index & 0x7f0) >> 4)*tab2_stride + val]; if ((ctx->previous ^ current) >= 0) { ctx->factor = FFMIN(ctx->factor + 506, 32767); } else { if (ctx->factor - 314 < -32768) ctx->factor = -32767; else ctx->factor -= 314; } current = mace_broken_clip_int16(current + ctx->level); ctx->level = ((current*ctx->factor) >> 15); current >>= 1; output[0] = QT_8S_2_16S(ctx->previous + ctx->prev2 - ((ctx->prev2-current) >> 2)); output[numChannels] = QT_8S_2_16S(ctx->previous + current + ((ctx->prev2-current) >> 2)); ctx->prev2 = ctx->previous; ctx->previous = current; if ((ctx->index += tab1[val] - (ctx->index >> 5)) < 0) ctx->index = 0; }
9,290
qemu
7d8abfcb50a33aed369bbd267852cf04009c49e9
1
aio_read_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; struct timeval t2; gettimeofday(&t2, NULL); if (ret < 0) { printf("readv failed: %s\n", strerror(-ret)); return; } if (ctx->Pflag) { void *cmp_buf = malloc(ctx->qiov.size); memset(cmp_buf, ctx->pattern, ctx->qiov.size); if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) { printf("Pattern verification failed at offset %lld, " "%zd bytes\n", (long long) ctx->offset, ctx->qiov.size); } free(cmp_buf); } if (ctx->qflag) { return; } if (ctx->vflag) { dump_buffer(ctx->buf, ctx->offset, ctx->qiov.size); } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, ctx->t1); print_report("read", &t2, ctx->offset, ctx->qiov.size, ctx->qiov.size, 1, ctx->Cflag); qemu_io_free(ctx->buf); free(ctx); }
9,291
qemu
8194f35a0c71a3bf169459bf715bea53b7bbc904
1
void helper_retry(void) { env->pc = env->tsptr->tpc; env->npc = env->tsptr->tnpc; PUT_CCR(env, env->tsptr->tstate >> 32); env->asi = (env->tsptr->tstate >> 24) & 0xff; change_pstate((env->tsptr->tstate >> 8) & 0xf3f); PUT_CWP64(env, env->tsptr->tstate & 0xff); env->tl--; env->tsptr = &env->ts[env->tl & MAXTL_MASK]; }
9,292
qemu
0752706de257b38763006ff5bb6b39a97e669ba2
1
static void slirp_hostfwd(SlirpState *s, Monitor *mon, const char *redir_str, int legacy_format) { struct in_addr host_addr = { .s_addr = INADDR_ANY }; struct in_addr guest_addr = { .s_addr = 0 }; int host_port, guest_port; const char *p; char buf[256]; int is_udp; char *end; p = redir_str; if (!p || get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (!strcmp(buf, "tcp") || buf[0] == '\0') { is_udp = 0; } else if (!strcmp(buf, "udp")) { is_udp = 1; } else { goto fail_syntax; } if (!legacy_format) { if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (buf[0] != '\0' && !inet_aton(buf, &host_addr)) { goto fail_syntax; } } if (get_str_sep(buf, sizeof(buf), &p, legacy_format ? ':' : '-') < 0) { goto fail_syntax; } host_port = strtol(buf, &end, 0); if (*end != '\0' || host_port < 1 || host_port > 65535) { goto fail_syntax; } if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (buf[0] != '\0' && !inet_aton(buf, &guest_addr)) { goto fail_syntax; } guest_port = strtol(p, &end, 0); if (*end != '\0' || guest_port < 1 || guest_port > 65535) { goto fail_syntax; } if (slirp_add_hostfwd(s->slirp, is_udp, host_addr, host_port, guest_addr, guest_port) < 0) { config_error(mon, "could not set up host forwarding rule '%s'\n", redir_str); } return; fail_syntax: config_error(mon, "invalid host forwarding rule '%s'\n", redir_str); }
9,293
FFmpeg
428098165de4c3edfe42c1b7f00627d287015863
1
static inline int RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int y, h_size; if(c->srcFormat == PIX_FMT_YUV422P){ srcStride[1] *= 2; srcStride[2] *= 2; } h_size= (c->dstW+7)&~7; if(h_size*3 > FFABS(dstStride[0])) h_size-=8; __asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ ); for (y= 0; y<srcSliceH; y++ ) { uint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0]; uint8_t *_py = src[0] + y*srcStride[0]; uint8_t *_pu = src[1] + (y>>1)*srcStride[1]; uint8_t *_pv = src[2] + (y>>1)*srcStride[2]; long index= -h_size/2; /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8 pixels in each iteration */ __asm__ __volatile__ ( /* load data for start of next scan line */ "movd (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */ "movd (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */ "movq (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */ // ".balign 16 \n\t" "1: \n\t" YUV2RGB /* mm0=B, %%mm2=G, %%mm1=R */ #ifdef HAVE_MMX2 "movq "MANGLE(M24A)", %%mm4 \n\t" "movq "MANGLE(M24C)", %%mm7 \n\t" "pshufw $0x50, %%mm0, %%mm5 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */ "pshufw $0x50, %%mm2, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */ "pshufw $0x00, %%mm1, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */ "pand %%mm4, %%mm5 \n\t" /* B2 B1 B0 */ "pand %%mm4, %%mm3 \n\t" /* G2 G1 G0 */ "pand %%mm7, %%mm6 \n\t" /* R1 R0 */ "psllq $8, %%mm3 \n\t" /* G2 G1 G0 */ "por %%mm5, %%mm6 \n\t" "por %%mm3, %%mm6 \n\t" MOVNTQ" %%mm6, (%1) \n\t" "psrlq $8, %%mm2 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */ "pshufw $0xA5, %%mm0, %%mm5 \n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */ "pshufw $0x55, %%mm2, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */ "pshufw $0xA5, %%mm1, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */ "pand "MANGLE(M24B)", %%mm5 \n\t" /* B5 B4 B3 */ "pand %%mm7, %%mm3 \n\t" /* G4 G3 */ "pand %%mm4, %%mm6 \n\t" /* R4 R3 R2 */ "por %%mm5, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */ "por %%mm3, %%mm6 \n\t" MOVNTQ" %%mm6, 8(%1) \n\t" "pshufw $0xFF, %%mm0, %%mm5 \n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */ "pshufw $0xFA, %%mm2, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */ "pshufw $0xFA, %%mm1, %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */ "movd 4 (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */ "pand %%mm7, %%mm5 \n\t" /* B7 B6 */ "pand %%mm4, %%mm3 \n\t" /* G7 G6 G5 */ "pand "MANGLE(M24B)", %%mm6 \n\t" /* R7 R6 R5 */ "movd 4 (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */ \ "por %%mm5, %%mm3 \n\t" "por %%mm3, %%mm6 \n\t" MOVNTQ" %%mm6, 16(%1) \n\t" "movq 8 (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */ "pxor %%mm4, %%mm4 \n\t" #else "pxor %%mm4, %%mm4 \n\t" "movq %%mm0, %%mm5 \n\t" /* B */ "movq %%mm1, %%mm6 \n\t" /* R */ "punpcklbw %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */ "punpcklbw %%mm4, %%mm1 \n\t" /* 0R0R0R0R 0 */ "punpckhbw %%mm2, %%mm5 \n\t" /* GBGBGBGB 2 */ "punpckhbw %%mm4, %%mm6 \n\t" /* 0R0R0R0R 2 */ "movq %%mm0, %%mm7 \n\t" /* GBGBGBGB 0 */ "movq %%mm5, %%mm3 \n\t" /* GBGBGBGB 2 */ "punpcklwd %%mm1, %%mm7 \n\t" /* 0RGB0RGB 0 */ "punpckhwd %%mm1, %%mm0 \n\t" /* 0RGB0RGB 1 */ "punpcklwd %%mm6, %%mm5 \n\t" /* 0RGB0RGB 2 */ "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */ "movq %%mm7, %%mm2 \n\t" /* 0RGB0RGB 0 */ "movq %%mm0, %%mm6 \n\t" /* 0RGB0RGB 1 */ "movq %%mm5, %%mm1 \n\t" /* 0RGB0RGB 2 */ "movq %%mm3, %%mm4 \n\t" /* 0RGB0RGB 3 */ "psllq $40, %%mm7 \n\t" /* RGB00000 0 */ "psllq $40, %%mm0 \n\t" /* RGB00000 1 */ "psllq $40, %%mm5 \n\t" /* RGB00000 2 */ "psllq $40, %%mm3 \n\t" /* RGB00000 3 */ "punpckhdq %%mm2, %%mm7 \n\t" /* 0RGBRGB0 0 */ "punpckhdq %%mm6, %%mm0 \n\t" /* 0RGBRGB0 1 */ "punpckhdq %%mm1, %%mm5 \n\t" /* 0RGBRGB0 2 */ "punpckhdq %%mm4, %%mm3 \n\t" /* 0RGBRGB0 3 */ "psrlq $8, %%mm7 \n\t" /* 00RGBRGB 0 */ "movq %%mm0, %%mm6 \n\t" /* 0RGBRGB0 1 */ "psllq $40, %%mm0 \n\t" /* GB000000 1 */ "por %%mm0, %%mm7 \n\t" /* GBRGBRGB 0 */ MOVNTQ" %%mm7, (%1) \n\t" "movd 4 (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */ "psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */ "movq %%mm5, %%mm1 \n\t" /* 0RGBRGB0 2 */ "psllq $24, %%mm5 \n\t" /* BRGB0000 2 */ "por %%mm5, %%mm6 \n\t" /* BRGBRGBR 1 */ MOVNTQ" %%mm6, 8(%1) \n\t" "movq 8 (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */ "psrlq $40, %%mm1 \n\t" /* 000000RG 2 */ "psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */ "por %%mm3, %%mm1 \n\t" /* RGBRGBRG 2 */ MOVNTQ" %%mm1, 16(%1) \n\t" "movd 4 (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */ "pxor %%mm4, %%mm4 \n\t" #endif "add $24, %1 \n\t" "add $4, %0 \n\t" " js 1b \n\t" : "+r" (index), "+r" (_image) : "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index) ); } __asm__ __volatile__ (EMMS); return srcSliceH; }
9,294
qemu
a80bf99fa3dd829ecea88b9bfb4f7cf146208f07
1
static void mux_chr_read(void *opaque, const uint8_t *buf, int size) { CharDriverState *chr = opaque; MuxDriver *d = chr->opaque; int m = chr->focus; int i; mux_chr_accept_input (opaque); for(i = 0; i < size; i++) if (mux_proc_byte(chr, d, buf[i])) { if (d->prod == d->cons && d->chr_can_read[m] && d->chr_can_read[m](d->ext_opaque[m])) d->chr_read[m](d->ext_opaque[m], &buf[i], 1); else d->buffer[d->prod++ & MUX_BUFFER_MASK] = buf[i]; } }
9,295
FFmpeg
7c1d608ece947c49b1ebbba415fada965cb8960f
1
static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) { VideoData *s = s1->priv_data; AVStream *st; int width, height; int video_fd, frame_size; int ret, frame_rate, frame_rate_base; int desired_palette, desired_depth; struct video_tuner tuner; struct video_audio audio; struct video_picture pict; int j; int vformat_num = sizeof(video_formats) / sizeof(video_formats[0]); if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) { av_log(s1, AV_LOG_ERROR, "Bad capture size (%dx%d) or wrong time base (%d)\n", ap->width, ap->height, ap->time_base.den); return -1; } width = ap->width; height = ap->height; frame_rate = ap->time_base.den; frame_rate_base = ap->time_base.num; if((unsigned)width > 32767 || (unsigned)height > 32767) { av_log(s1, AV_LOG_ERROR, "Capture size is out of range: %dx%d\n", width, height); return -1; } st = av_new_stream(s1, 0); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ s->width = width; s->height = height; s->frame_rate = frame_rate; s->frame_rate_base = frame_rate_base; video_fd = open(s1->filename, O_RDWR); if (video_fd < 0) { av_log(s1, AV_LOG_ERROR, "%s: %s\n", s1->filename, strerror(errno)); goto fail; } if (ioctl(video_fd,VIDIOCGCAP, &s->video_cap) < 0) { av_log(s1, AV_LOG_ERROR, "VIDIOCGCAP: %s\n", strerror(errno)); goto fail; } if (!(s->video_cap.type & VID_TYPE_CAPTURE)) { av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not handle capture\n"); goto fail; } desired_palette = -1; desired_depth = -1; for (j = 0; j < vformat_num; j++) { if (ap->pix_fmt == video_formats[j].pix_fmt) { desired_palette = video_formats[j].palette; desired_depth = video_formats[j].depth; break; } } /* set tv standard */ if (ap->standard && !ioctl(video_fd, VIDIOCGTUNER, &tuner)) { if (!strcasecmp(ap->standard, "pal")) tuner.mode = VIDEO_MODE_PAL; else if (!strcasecmp(ap->standard, "secam")) tuner.mode = VIDEO_MODE_SECAM; else tuner.mode = VIDEO_MODE_NTSC; ioctl(video_fd, VIDIOCSTUNER, &tuner); } /* unmute audio */ audio.audio = 0; ioctl(video_fd, VIDIOCGAUDIO, &audio); memcpy(&s->audio_saved, &audio, sizeof(audio)); audio.flags &= ~VIDEO_AUDIO_MUTE; ioctl(video_fd, VIDIOCSAUDIO, &audio); ioctl(video_fd, VIDIOCGPICT, &pict); #if 0 printf("v4l: colour=%d hue=%d brightness=%d constrast=%d whiteness=%d\n", pict.colour, pict.hue, pict.brightness, pict.contrast, pict.whiteness); #endif /* try to choose a suitable video format */ pict.palette = desired_palette; pict.depth= desired_depth; if (desired_palette == -1 || (ret = ioctl(video_fd, VIDIOCSPICT, &pict)) < 0) { for (j = 0; j < vformat_num; j++) { pict.palette = video_formats[j].palette; pict.depth = video_formats[j].depth; if (-1 != ioctl(video_fd, VIDIOCSPICT, &pict)) break; } if (j >= vformat_num) goto fail1; } ret = ioctl(video_fd,VIDIOCGMBUF,&s->gb_buffers); if (ret < 0) { /* try to use read based access */ struct video_window win; int val; win.x = 0; win.y = 0; win.width = width; win.height = height; win.chromakey = -1; win.flags = 0; ioctl(video_fd, VIDIOCSWIN, &win); s->frame_format = pict.palette; val = 1; ioctl(video_fd, VIDIOCCAPTURE, &val); s->time_frame = av_gettime() * s->frame_rate / s->frame_rate_base; s->use_mmap = 0; } else { s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_SHARED,video_fd,0); if ((unsigned char*)-1 == s->video_buf) { s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_PRIVATE,video_fd,0); if ((unsigned char*)-1 == s->video_buf) { av_log(s1, AV_LOG_ERROR, "mmap: %s\n", strerror(errno)); goto fail; } } s->gb_frame = 0; s->time_frame = av_gettime() * s->frame_rate / s->frame_rate_base; /* start to grab the first frame */ s->gb_buf.frame = s->gb_frame % s->gb_buffers.frames; s->gb_buf.height = height; s->gb_buf.width = width; s->gb_buf.format = pict.palette; ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf); if (ret < 0) { if (errno != EAGAIN) { fail1: av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not support suitable format\n"); } else { av_log(s1, AV_LOG_ERROR,"Fatal: grab device does not receive any video signal\n"); } goto fail; } for (j = 1; j < s->gb_buffers.frames; j++) { s->gb_buf.frame = j; ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf); } s->frame_format = s->gb_buf.format; s->use_mmap = 1; } for (j = 0; j < vformat_num; j++) { if (s->frame_format == video_formats[j].palette) { frame_size = width * height * video_formats[j].depth / 8; st->codec->pix_fmt = video_formats[j].pix_fmt; break; } } if (j >= vformat_num) goto fail; s->fd = video_fd; s->frame_size = frame_size; st->codec->codec_type = CODEC_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->width = width; st->codec->height = height; st->codec->time_base.den = frame_rate; st->codec->time_base.num = frame_rate_base; st->codec->bit_rate = frame_size * 1/av_q2d(st->codec->time_base) * 8; return 0; fail: if (video_fd >= 0) close(video_fd); av_free(st); return AVERROR(EIO); }
9,296
FFmpeg
6191198c216e0ca38d6e65270d2f1b054584a0a9
1
static void ipvideo_decode_opcodes(IpvideoContext *s, AVFrame *frame) { int x, y; unsigned char opcode; int ret; GetBitContext gb; bytestream2_skip(&s->stream_ptr, 14); /* data starts 14 bytes in */ if (!s->is_16bpp) { /* this is PAL8, so make the palette available */ memcpy(frame->data[1], s->pal, AVPALETTE_SIZE); s->stride = frame->linesize[0]; } else { s->stride = frame->linesize[0] >> 1; s->mv_ptr = s->stream_ptr; bytestream2_skip(&s->mv_ptr, bytestream2_get_le16(&s->stream_ptr)); } s->line_inc = s->stride - 8; s->upper_motion_limit_offset = (s->avctx->height - 8) * frame->linesize[0] + (s->avctx->width - 8) * (1 + s->is_16bpp); init_get_bits(&gb, s->decoding_map, s->decoding_map_size * 8); for (y = 0; y < s->avctx->height; y += 8) { for (x = 0; x < s->avctx->width; x += 8) { opcode = get_bits(&gb, 4); ff_tlog(s->avctx, " block @ (%3d, %3d): encoding 0x%X, data ptr offset %d\n", x, y, opcode, bytestream2_tell(&s->stream_ptr)); if (!s->is_16bpp) { s->pixel_ptr = frame->data[0] + x + y*frame->linesize[0]; ret = ipvideo_decode_block[opcode](s, frame); } else { s->pixel_ptr = frame->data[0] + x*2 + y*frame->linesize[0]; ret = ipvideo_decode_block16[opcode](s, frame); } if (ret != 0) { av_log(s->avctx, AV_LOG_ERROR, "decode problem on frame %d, @ block (%d, %d)\n", s->avctx->frame_number, x, y); } } } if (bytestream2_get_bytes_left(&s->stream_ptr) > 1) { av_log(s->avctx, AV_LOG_DEBUG, "decode finished with %d bytes left over\n", bytestream2_get_bytes_left(&s->stream_ptr)); } }
9,297
qemu
9faa574f7d07109e2256c0b4b63e8711d650f2d8
1
static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg) { GlusterAIOCB *acb = (GlusterAIOCB *)arg; BlockDriverState *bs = acb->common.bs; BDRVGlusterState *s = bs->opaque; int retval; acb->ret = ret; retval = qemu_write_full(s->fds[GLUSTER_FD_WRITE], &acb, sizeof(acb)); if (retval != sizeof(acb)) { /* * Gluster AIO callback thread failed to notify the waiting * QEMU thread about IO completion. * * Complete this IO request and make the disk inaccessible for * subsequent reads and writes. */ error_report("Gluster failed to notify QEMU about IO completion"); qemu_mutex_lock_iothread(); /* We are in gluster thread context */ acb->common.cb(acb->common.opaque, -EIO); qemu_aio_release(acb); close(s->fds[GLUSTER_FD_READ]); close(s->fds[GLUSTER_FD_WRITE]); qemu_aio_set_fd_handler(s->fds[GLUSTER_FD_READ], NULL, NULL, NULL); bs->drv = NULL; /* Make the disk inaccessible */ qemu_mutex_unlock_iothread(); } }
9,298
qemu
b4db54132ffeadafa9516cc553ba9548e42d42ad
1
static void close_htab_fd(sPAPRMachineState *spapr) { if (spapr->htab_fd >= 0) { close(spapr->htab_fd); } spapr->htab_fd = -1; }
9,299
qemu
b1fe60cd3525871a4c593ad8c2b39b89c19c00d0
1
static void intel_hda_update_irq(IntelHDAState *d) { int msi = d->msi && msi_enabled(&d->pci); int level; intel_hda_update_int_sts(d); if (d->int_sts & (1 << 31) && d->int_ctl & (1 << 31)) { level = 1; } else { level = 0; } dprint(d, 2, "%s: level %d [%s]\n", __FUNCTION__, level, msi ? "msi" : "intx"); if (msi) { if (level) { msi_notify(&d->pci, 0); } } else { pci_set_irq(&d->pci, level); } }
9,300
FFmpeg
12987f89007ee82b9d3a6090085dfaef8461ab8b
1
static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { int res = 0; uint64_t pos; uint64_t maxlen = 100 * 1024 * 1024; AVStream *st = s->streams[0]; int64_t start_time = s->streams[stream_index]->start_time; int64_t found; int idx; if (timestamp < start_time) timestamp = start_time; idx = av_index_search_timestamp(st, timestamp - start_time, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); if (idx < 0) return -1; pos = st->index_entries[idx].pos; if (idx < st->nb_index_entries - 2) maxlen = st->index_entries[idx + 2].pos - pos; maxlen = FFMAX(maxlen, 200 * 1024); res = avio_seek(s->pb, pos, SEEK_SET); if (res < 0) return res; found = gxf_resync_media(s, maxlen, -1, timestamp); if (FFABS(found - timestamp) > 4) return -1; return 0; }
9,302
qemu
65f3e33964bc4bb634d61463814a4ccca794e3c0
0
static int iscsi_aio_discard_acb(IscsiAIOCB *acb) { struct iscsi_context *iscsi = acb->iscsilun->iscsi; struct unmap_list list[1]; acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; list[0].lba = sector_qemu2lun(acb->sector_num, acb->iscsilun); list[0].num = acb->nb_sectors * BDRV_SECTOR_SIZE / acb->iscsilun->block_size; acb->task = iscsi_unmap_task(iscsi, acb->iscsilun->lun, 0, 0, &list[0], 1, iscsi_unmap_cb, acb); if (acb->task == NULL) { error_report("iSCSI: Failed to send unmap command. %s", iscsi_get_error(iscsi)); return -1; } return 0; }
9,303
qemu
8d5c773e323b22402abdd0beef4c7d2fc91dd0eb
0
static void vmsa_tcr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = arm_env_get_cpu(env); /* For AArch64 the A1 bit could result in a change of ASID, so TLB flush. */ tlb_flush(CPU(cpu), 1); env->cp15.c2_control = value; }
9,304
qemu
9a78eead0c74333a394c0f7bbfc4423ac746fcd5
0
cpu_mips_check_sign_extensions (CPUState *env, FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...), int flags) { int i; if (!SIGN_EXT_P(env->active_tc.PC)) cpu_fprintf(f, "BROKEN: pc=0x" TARGET_FMT_lx "\n", env->active_tc.PC); if (!SIGN_EXT_P(env->active_tc.HI[0])) cpu_fprintf(f, "BROKEN: HI=0x" TARGET_FMT_lx "\n", env->active_tc.HI[0]); if (!SIGN_EXT_P(env->active_tc.LO[0])) cpu_fprintf(f, "BROKEN: LO=0x" TARGET_FMT_lx "\n", env->active_tc.LO[0]); if (!SIGN_EXT_P(env->btarget)) cpu_fprintf(f, "BROKEN: btarget=0x" TARGET_FMT_lx "\n", env->btarget); for (i = 0; i < 32; i++) { if (!SIGN_EXT_P(env->active_tc.gpr[i])) cpu_fprintf(f, "BROKEN: %s=0x" TARGET_FMT_lx "\n", regnames[i], env->active_tc.gpr[i]); } if (!SIGN_EXT_P(env->CP0_EPC)) cpu_fprintf(f, "BROKEN: EPC=0x" TARGET_FMT_lx "\n", env->CP0_EPC); if (!SIGN_EXT_P(env->lladdr)) cpu_fprintf(f, "BROKEN: LLAddr=0x" TARGET_FMT_lx "\n", env->lladdr); }
9,305
qemu
b4049b74b97f30fe944c63b5f158ec9e87bd2593
0
void qemu_register_clock_reset_notifier(QEMUClock *clock, Notifier *notifier) { qemu_clock_register_reset_notifier(clock->type, notifier); }
9,306
FFmpeg
69e7336b8e16ee65226fc20381baf537f4b125e6
0
static int match_format(const char *name, const char *names) { const char *p; int len, namelen; if (!name || !names) return 0; namelen = strlen(name); while ((p = strchr(names, ','))) { len = FFMAX(p - names, namelen); if (!av_strncasecmp(name, names, len)) return 1; names = p + 1; } return !av_strcasecmp(name, names); }
9,308
qemu
8ddbc04f067e6f8c63f1e0f60a7d10bf9036fd9a
0
static int check_refcounts_l1(BlockDriverState *bs, uint16_t *refcount_table, int refcount_table_size, int64_t l1_table_offset, int l1_size, int check_copied) { BDRVQcowState *s = bs->opaque; uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2; int l2_size, i, j, nb_csectors, refcount; l2_table = NULL; l1_size2 = l1_size * sizeof(uint64_t); inc_refcounts(bs, refcount_table, refcount_table_size, l1_table_offset, l1_size2); l1_table = qemu_malloc(l1_size2); if (bdrv_pread(s->hd, l1_table_offset, l1_table, l1_size2) != l1_size2) goto fail; for(i = 0;i < l1_size; i++) be64_to_cpus(&l1_table[i]); l2_size = s->l2_size * sizeof(uint64_t); l2_table = qemu_malloc(l2_size); for(i = 0; i < l1_size; i++) { l2_offset = l1_table[i]; if (l2_offset) { if (check_copied) { refcount = get_refcount(bs, (l2_offset & ~QCOW_OFLAG_COPIED) >> s->cluster_bits); if ((refcount == 1) != ((l2_offset & QCOW_OFLAG_COPIED) != 0)) { printf("ERROR OFLAG_COPIED: l2_offset=%llx refcount=%d\n", l2_offset, refcount); } } l2_offset &= ~QCOW_OFLAG_COPIED; if (bdrv_pread(s->hd, l2_offset, l2_table, l2_size) != l2_size) goto fail; for(j = 0; j < s->l2_size; j++) { offset = be64_to_cpu(l2_table[j]); if (offset != 0) { if (offset & QCOW_OFLAG_COMPRESSED) { if (offset & QCOW_OFLAG_COPIED) { printf("ERROR: cluster %lld: copied flag must never be set for compressed clusters\n", offset >> s->cluster_bits); offset &= ~QCOW_OFLAG_COPIED; } nb_csectors = ((offset >> s->csize_shift) & s->csize_mask) + 1; offset &= s->cluster_offset_mask; inc_refcounts(bs, refcount_table, refcount_table_size, offset & ~511, nb_csectors * 512); } else { if (check_copied) { refcount = get_refcount(bs, (offset & ~QCOW_OFLAG_COPIED) >> s->cluster_bits); if ((refcount == 1) != ((offset & QCOW_OFLAG_COPIED) != 0)) { printf("ERROR OFLAG_COPIED: offset=%llx refcount=%d\n", offset, refcount); } } offset &= ~QCOW_OFLAG_COPIED; inc_refcounts(bs, refcount_table, refcount_table_size, offset, s->cluster_size); } } } inc_refcounts(bs, refcount_table, refcount_table_size, l2_offset, s->cluster_size); } } qemu_free(l1_table); qemu_free(l2_table); return 0; fail: printf("ERROR: I/O error in check_refcounts_l1\n"); qemu_free(l1_table); qemu_free(l2_table); return -EIO; }
9,309
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
0
static void ide_sector_read_cb(void *opaque, int ret) { IDEState *s = opaque; int n; s->pio_aiocb = NULL; s->status &= ~BUSY_STAT; if (ret == -ECANCELED) { return; } block_acct_done(bdrv_get_stats(s->bs), &s->acct); if (ret != 0) { if (ide_handle_rw_error(s, -ret, IDE_RETRY_PIO | IDE_RETRY_READ)) { return; } } n = s->nsector; if (n > s->req_nb_sectors) { n = s->req_nb_sectors; } /* Allow the guest to read the io_buffer */ ide_transfer_start(s, s->io_buffer, n * BDRV_SECTOR_SIZE, ide_sector_read); ide_set_irq(s->bus); ide_set_sector(s, ide_get_sector(s) + n); s->nsector -= n; }
9,310
qemu
ab9de3692e34dc874ce44c7905590ef98445ce33
0
static void logerr (struct audio_pt *pt, int err, const char *fmt, ...) { va_list ap; va_start (ap, fmt); AUD_vlog (pt->drv, fmt, ap); va_end (ap); AUD_log (NULL, "\n"); AUD_log (pt->drv, "Reason: %s\n", strerror (err)); }
9,311
qemu
5933e8a96ab9c59cb6b6c80c9db385364a68c959
0
static void slavio_timer_reset(DeviceState *d) { SLAVIO_TIMERState *s = container_of(d, SLAVIO_TIMERState, busdev.qdev); unsigned int i; CPUTimerState *curr_timer; for (i = 0; i <= MAX_CPUS; i++) { curr_timer = &s->cputimer[i]; curr_timer->limit = 0; curr_timer->count = 0; curr_timer->reached = 0; if (i < s->num_cpus) { ptimer_set_limit(curr_timer->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); ptimer_run(curr_timer->timer, 0); } curr_timer->running = 1; } s->cputimer_mode = 0; }
9,312
qemu
4d68e86bb10159099da0798f74e7512955f15eec
0
static void coroutine_delete(Coroutine *co) { if (CONFIG_COROUTINE_POOL) { qemu_mutex_lock(&pool_lock); if (pool_size < pool_max_size) { QSLIST_INSERT_HEAD(&pool, co, pool_next); co->caller = NULL; pool_size++; qemu_mutex_unlock(&pool_lock); return; } qemu_mutex_unlock(&pool_lock); } qemu_coroutine_delete(co); }
9,313
qemu
d0264d86b026e9d948de577b05ff86d708658576
0
static void arm_post_translate_insn(CPUARMState *env, DisasContext *dc) { if (dc->condjmp && !dc->base.is_jmp) { gen_set_label(dc->condlabel); dc->condjmp = 0; } /* Translation stops when a conditional branch is encountered. * Otherwise the subsequent code could get translated several times. * Also stop translation when a page boundary is reached. This * ensures prefetch aborts occur at the right place. * * We want to stop the TB if the next insn starts in a new page, * or if it spans between this page and the next. This means that * if we're looking at the last halfword in the page we need to * see if it's a 16-bit Thumb insn (which will fit in this TB) * or a 32-bit Thumb insn (which won't). * This is to avoid generating a silly TB with a single 16-bit insn * in it at the end of this page (which would execute correctly * but isn't very efficient). */ if (dc->base.is_jmp == DISAS_NEXT && (dc->pc >= dc->next_page_start || (dc->pc >= dc->next_page_start - 3 && insn_crosses_page(env, dc)))) { dc->base.is_jmp = DISAS_TOO_MANY; } dc->base.pc_next = dc->pc; translator_loop_temp_check(&dc->base); }
9,314
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
0
static void r2d_init(MachineState *machine) { const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; SuperHCPU *cpu; CPUSH4State *env; ResetData *reset_info; struct SH7750State *s; MemoryRegion *sdram = g_new(MemoryRegion, 1); qemu_irq *irq; DriveInfo *dinfo; int i; DeviceState *dev; SysBusDevice *busdev; MemoryRegion *address_space_mem = get_system_memory(); PCIBus *pci_bus; if (cpu_model == NULL) { cpu_model = "SH7751R"; } cpu = cpu_sh4_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } env = &cpu->env; reset_info = g_malloc0(sizeof(ResetData)); reset_info->cpu = cpu; reset_info->vector = env->pc; qemu_register_reset(main_cpu_reset, reset_info); /* Allocate memory space */ memory_region_init_ram(sdram, NULL, "r2d.sdram", SDRAM_SIZE, &error_abort); vmstate_register_ram_global(sdram); memory_region_add_subregion(address_space_mem, SDRAM_BASE, sdram); /* Register peripherals */ s = sh7750_init(cpu, address_space_mem); irq = r2d_fpga_init(address_space_mem, 0x04000000, sh7750_irl(s)); dev = qdev_create(NULL, "sh_pci"); busdev = SYS_BUS_DEVICE(dev); qdev_init_nofail(dev); pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci")); sysbus_mmio_map(busdev, 0, P4ADDR(0x1e200000)); sysbus_mmio_map(busdev, 1, A7ADDR(0x1e200000)); sysbus_connect_irq(busdev, 0, irq[PCI_INTA]); sysbus_connect_irq(busdev, 1, irq[PCI_INTB]); sysbus_connect_irq(busdev, 2, irq[PCI_INTC]); sysbus_connect_irq(busdev, 3, irq[PCI_INTD]); sm501_init(address_space_mem, 0x10000000, SM501_VRAM_SIZE, irq[SM501], serial_hds[2]); /* onboard CF (True IDE mode, Master only). */ dinfo = drive_get(IF_IDE, 0, 0); dev = qdev_create(NULL, "mmio-ide"); busdev = SYS_BUS_DEVICE(dev); sysbus_connect_irq(busdev, 0, irq[CF_IDE]); qdev_prop_set_uint32(dev, "shift", 1); qdev_init_nofail(dev); sysbus_mmio_map(busdev, 0, 0x14001000); sysbus_mmio_map(busdev, 1, 0x1400080c); mmio_ide_init_drives(dev, dinfo, NULL); /* onboard flash memory */ dinfo = drive_get(IF_PFLASH, 0, 0); pflash_cfi02_register(0x0, NULL, "r2d.flash", FLASH_SIZE, dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL, (16 * 1024), FLASH_SIZE >> 16, 1, 4, 0x0000, 0x0000, 0x0000, 0x0000, 0x555, 0x2aa, 0); /* NIC: rtl8139 on-board, and 2 slots. */ for (i = 0; i < nb_nics; i++) pci_nic_init_nofail(&nd_table[i], pci_bus, "rtl8139", i==0 ? "2" : NULL); /* USB keyboard */ usbdevice_create("keyboard"); /* Todo: register on board registers */ memset(&boot_params, 0, sizeof(boot_params)); if (kernel_filename) { int kernel_size; kernel_size = load_image_targphys(kernel_filename, SDRAM_BASE + LINUX_LOAD_OFFSET, INITRD_LOAD_OFFSET - LINUX_LOAD_OFFSET); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } /* initialization which should be done by firmware */ stl_phys(&address_space_memory, SH7750_BCR1, 1<<3); /* cs3 SDRAM */ stw_phys(&address_space_memory, SH7750_BCR2, 3<<(3*2)); /* cs3 32bit */ reset_info->vector = (SDRAM_BASE + LINUX_LOAD_OFFSET) | 0xa0000000; /* Start from P2 area */ } if (initrd_filename) { int initrd_size; initrd_size = load_image_targphys(initrd_filename, SDRAM_BASE + INITRD_LOAD_OFFSET, SDRAM_SIZE - INITRD_LOAD_OFFSET); if (initrd_size < 0) { fprintf(stderr, "qemu: could not load initrd '%s'\n", initrd_filename); exit(1); } /* initialization which should be done by firmware */ boot_params.loader_type = 1; boot_params.initrd_start = INITRD_LOAD_OFFSET; boot_params.initrd_size = initrd_size; } if (kernel_cmdline) { /* I see no evidence that this .kernel_cmdline buffer requires NUL-termination, so using strncpy should be ok. */ strncpy(boot_params.kernel_cmdline, kernel_cmdline, sizeof(boot_params.kernel_cmdline)); } rom_add_blob_fixed("boot_params", &boot_params, sizeof(boot_params), SDRAM_BASE + BOOT_PARAMS_OFFSET); }
9,315
qemu
bec93d7283b635aabaf0bbff67b6da7fc99e020a
0
static void gen_compute_eflags_s(DisasContext *s, TCGv reg, bool inv) { switch (s->cc_op) { case CC_OP_DYNAMIC: gen_compute_eflags(s); /* FALLTHRU */ case CC_OP_EFLAGS: tcg_gen_shri_tl(reg, cpu_cc_src, 7); tcg_gen_andi_tl(reg, reg, 1); if (inv) { tcg_gen_xori_tl(reg, reg, 1); } break; default: { int size = (s->cc_op - CC_OP_ADDB) & 3; TCGv t0 = gen_ext_tl(reg, cpu_cc_dst, size, true); tcg_gen_setcondi_tl(inv ? TCG_COND_GE : TCG_COND_LT, reg, t0, 0); } break; } }
9,316