project
stringclasses 2
values | commit_id
stringlengths 40
40
| target
int64 0
1
| func
stringlengths 26
142k
| idx
int64 0
27.3k
|
---|---|---|---|---|
FFmpeg | 9f61abc8111c7c43f49ca012e957a108b9cc7610 | 0 | static int init_file(AVFormatContext *s, OutputStream *os, int64_t start_ts)
{
int ret, i;
ret = avio_open2(&os->out, os->temp_filename, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL);
if (ret < 0)
return ret;
avio_wb32(os->out, 0);
avio_wl32(os->out, MKTAG('m','d','a','t'));
for (i = 0; i < os->nb_extra_packets; i++) {
AV_WB24(os->extra_packets[i] + 4, start_ts);
os->extra_packets[i][7] = (start_ts >> 24) & 0x7f;
avio_write(os->out, os->extra_packets[i], os->extra_packet_sizes[i]);
}
return 0;
}
| 12,219 |
FFmpeg | 4381bddc9f93da34a44e683bdc4c05c6f061244e | 0 | static inline void log_input_change(void *ctx, AVFilterLink *link, AVFilterBufferRef *ref)
{
char old_layout_str[16], new_layout_str[16];
av_get_channel_layout_string(old_layout_str, sizeof(old_layout_str),
-1, link->channel_layout);
av_get_channel_layout_string(new_layout_str, sizeof(new_layout_str),
-1, ref->audio->channel_layout);
av_log(ctx, AV_LOG_INFO,
"Audio input format changed: "
"%s:%s:%"PRId64" -> %s:%s:%u, normalizing\n",
av_get_sample_fmt_name(link->format),
old_layout_str, link->sample_rate,
av_get_sample_fmt_name(ref->format),
new_layout_str, ref->audio->sample_rate);
}
| 12,220 |
FFmpeg | ca00a7e809a4b9c9fb146403d278964b88d16b85 | 1 | static int decode_mime_header(AMRWBContext *ctx, const uint8_t *buf)
{
/* Decode frame header (1st octet) */
ctx->fr_cur_mode = buf[0] >> 3 & 0x0F;
ctx->fr_quality = (buf[0] & 0x4) != 0x4;
return 1;
}
| 12,221 |
FFmpeg | a4c32c9a63142b602820800742f2d543b58cd278 | 1 | static void init_entropy_decoder(APEContext *ctx)
{
/* Read the CRC */
ctx->CRC = bytestream_get_be32(&ctx->ptr);
/* Read the frame flags if they exist */
ctx->frameflags = 0;
if ((ctx->fileversion > 3820) && (ctx->CRC & 0x80000000)) {
ctx->CRC &= ~0x80000000;
ctx->frameflags = bytestream_get_be32(&ctx->ptr);
}
/* Keep a count of the blocks decoded in this frame */
ctx->blocksdecoded = 0;
/* Initialize the rice structs */
ctx->riceX.k = 10;
ctx->riceX.ksum = (1 << ctx->riceX.k) * 16;
ctx->riceY.k = 10;
ctx->riceY.ksum = (1 << ctx->riceY.k) * 16;
/* The first 8 bits of input are ignored. */
ctx->ptr++;
range_start_decoding(ctx);
}
| 12,222 |
qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | 1 | static gboolean qio_channel_yield_enter(QIOChannel *ioc,
GIOCondition condition,
gpointer opaque)
{
QIOChannelYieldData *data = opaque;
qemu_coroutine_enter(data->co, NULL);
return FALSE;
}
| 12,223 |
qemu | 2a7f2630684ee556a394a354d64159a4470c0151 | 1 | void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)
{
int i;
if (s->portnr > NB_PORTS) {
error_setg(errp, "Too many ports! Max. port number is %d.",
NB_PORTS);
usb_bus_new(&s->bus, sizeof(s->bus), s->companion_enable ?
&ehci_bus_ops_companion : &ehci_bus_ops_standalone, dev);
for (i = 0; i < s->portnr; i++) {
usb_register_port(&s->bus, &s->ports[i], s, i, &ehci_port_ops,
USB_SPEED_MASK_HIGH);
s->ports[i].dev = 0;
s->frame_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ehci_work_timer, s);
s->async_bh = qemu_bh_new(ehci_work_bh, s);
s->device = dev;
s->vmstate = qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s);
| 12,224 |
qemu | bac05aa9a77af1ca7972c8dc07560f4daa7c2dfc | 1 | void qemu_system_guest_panicked(void)
{
qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort);
vm_stop(RUN_STATE_GUEST_PANICKED);
| 12,226 |
FFmpeg | 7da9f4523159670d577a2808d4481e64008a8894 | 1 | static void get_sub_picture(CinepakEncContext *s, int x, int y, AVPicture *in, AVPicture *out)
{
out->data[0] = in->data[0] + x + y * in->linesize[0];
out->linesize[0] = in->linesize[0];
if(s->pix_fmt == AV_PIX_FMT_YUV420P) {
out->data[1] = in->data[1] + (x >> 1) + (y >> 1) * in->linesize[1];
out->linesize[1] = in->linesize[1];
out->data[2] = in->data[2] + (x >> 1) + (y >> 1) * in->linesize[2];
out->linesize[2] = in->linesize[2];
}
}
| 12,227 |
FFmpeg | 8d95eb6702b46cd07385c5478b10924ea78e6f18 | 1 | int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
{
int ret = 0;
AVDictionary *tmp = NULL;
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
return AVERROR(EINVAL);
if (options)
av_dict_copy(&tmp, *options, 0);
/* If there is a user-supplied mutex locking routine, call it. */
if (ff_lockmgr_cb) {
if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
return -1;
entangled_thread_counter++;
if(entangled_thread_counter != 1){
av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
goto end;
if(avctx->codec || !codec) {
ret = AVERROR(EINVAL);
goto end;
avctx->internal = av_mallocz(sizeof(AVCodecInternal));
if (!avctx->internal) {
ret = AVERROR(ENOMEM);
goto end;
if (codec->priv_data_size > 0) {
if(!avctx->priv_data){
avctx->priv_data = av_mallocz(codec->priv_data_size);
if (!avctx->priv_data) {
ret = AVERROR(ENOMEM);
goto end;
if (codec->priv_class) {
*(AVClass**)avctx->priv_data= codec->priv_class;
av_opt_set_defaults(avctx->priv_data);
if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0)
} else {
avctx->priv_data = NULL;
if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
//We only call avcodec_set_dimensions() for non h264 codecs so as not to overwrite previously setup dimensions
if(!( avctx->coded_width && avctx->coded_height && avctx->width && avctx->height && avctx->codec_id == CODEC_ID_H264)){
if(avctx->coded_width && avctx->coded_height)
avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
else if(avctx->width && avctx->height)
avcodec_set_dimensions(avctx, avctx->width, avctx->height);
if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
&& ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0
|| av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) {
av_log(avctx, AV_LOG_WARNING, "ignoring invalid width/height values\n");
avcodec_set_dimensions(avctx, 0, 0);
/* if the decoder init function was already called previously,
free the already allocated subtitle_header before overwriting it */
if (codec->decode)
av_freep(&avctx->subtitle_header);
#define SANE_NB_CHANNELS 128U
if (avctx->channels > SANE_NB_CHANNELS) {
ret = AVERROR(EINVAL);
avctx->codec = codec;
if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
avctx->codec_id == CODEC_ID_NONE) {
avctx->codec_type = codec->type;
avctx->codec_id = codec->id;
if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
&& avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n");
ret = AVERROR(EINVAL);
avctx->frame_number = 0;
#if FF_API_ER
av_log(avctx, AV_LOG_DEBUG, "err{or,}_recognition separate: %d; %X\n",
avctx->error_recognition, avctx->err_recognition);
switch(avctx->error_recognition){
case FF_ER_EXPLODE : avctx->err_recognition |= AV_EF_EXPLODE | AV_EF_COMPLIANT | AV_EF_CAREFUL;
break;
case FF_ER_VERY_AGGRESSIVE:
case FF_ER_AGGRESSIVE : avctx->err_recognition |= AV_EF_AGGRESSIVE;
case FF_ER_COMPLIANT : avctx->err_recognition |= AV_EF_COMPLIANT;
case FF_ER_CAREFUL : avctx->err_recognition |= AV_EF_CAREFUL;
av_log(avctx, AV_LOG_DEBUG, "err{or,}_recognition combined: %d; %X\n",
avctx->error_recognition, avctx->err_recognition);
#endif
if (!HAVE_THREADS)
av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
if (HAVE_THREADS && !avctx->thread_opaque) {
ret = ff_thread_init(avctx);
if (ret < 0) {
if (!HAVE_THREADS && !(codec->capabilities & CODEC_CAP_AUTO_THREADS))
avctx->thread_count = 1;
if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) {
av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
avctx->codec->max_lowres);
ret = AVERROR(EINVAL);
if (avctx->codec->encode) {
int i;
if (avctx->codec->sample_fmts) {
for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
break;
if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
ret = AVERROR(EINVAL);
if (avctx->codec->supported_samplerates) {
for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++)
if (avctx->sample_rate == avctx->codec->supported_samplerates[i])
break;
if (avctx->codec->supported_samplerates[i] == 0) {
av_log(avctx, AV_LOG_ERROR, "Specified sample_rate is not supported\n");
ret = AVERROR(EINVAL);
if (avctx->codec->channel_layouts) {
if (!avctx->channel_layout) {
av_log(avctx, AV_LOG_WARNING, "channel_layout not specified\n");
} else {
for (i = 0; avctx->codec->channel_layouts[i] != 0; i++)
if (avctx->channel_layout == avctx->codec->channel_layouts[i])
break;
if (avctx->codec->channel_layouts[i] == 0) {
av_log(avctx, AV_LOG_ERROR, "Specified channel_layout is not supported\n");
ret = AVERROR(EINVAL);
if (avctx->channel_layout && avctx->channels) {
if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) {
av_log(avctx, AV_LOG_ERROR, "channel layout does not match number of channels\n");
ret = AVERROR(EINVAL);
} else if (avctx->channel_layout) {
avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
avctx->pts_correction_num_faulty_pts =
avctx->pts_correction_num_faulty_dts = 0;
avctx->pts_correction_last_pts =
avctx->pts_correction_last_dts = INT64_MIN;
if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){
ret = avctx->codec->init(avctx);
if (ret < 0) {
ret=0;
end:
entangled_thread_counter--;
/* Release any user-supplied mutex. */
if (ff_lockmgr_cb) {
(*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
if (options) {
av_dict_free(options);
*options = tmp;
return ret;
free_and_end:
av_dict_free(&tmp);
av_freep(&avctx->priv_data);
av_freep(&avctx->internal);
avctx->codec= NULL;
goto end; | 12,228 |
qemu | efec3dd631d94160288392721a5f9c39e50fb2bc | 1 | static void cpu_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
CPUClass *k = CPU_CLASS(klass);
k->class_by_name = cpu_common_class_by_name;
k->reset = cpu_common_reset;
k->get_arch_id = cpu_common_get_arch_id;
k->get_paging_enabled = cpu_common_get_paging_enabled;
k->get_memory_mapping = cpu_common_get_memory_mapping;
k->write_elf32_qemunote = cpu_common_write_elf32_qemunote;
k->write_elf32_note = cpu_common_write_elf32_note;
k->write_elf64_qemunote = cpu_common_write_elf64_qemunote;
k->write_elf64_note = cpu_common_write_elf64_note;
k->gdb_read_register = cpu_common_gdb_read_register;
k->gdb_write_register = cpu_common_gdb_write_register;
dc->realize = cpu_common_realizefn;
dc->no_user = 1;
}
| 12,229 |
qemu | c78d65e8a7d87badf46eda3a0b41330f5d239132 | 1 | static int fill_note_info(struct elf_note_info *info,
long signr, const CPUArchState *env)
{
#define NUMNOTES 3
CPUState *cpu = ENV_GET_CPU((CPUArchState *)env);
TaskState *ts = (TaskState *)cpu->opaque;
int i;
info->notes = g_malloc0(NUMNOTES * sizeof (struct memelfnote));
if (info->notes == NULL)
return (-ENOMEM);
info->prstatus = g_malloc0(sizeof (*info->prstatus));
if (info->prstatus == NULL)
return (-ENOMEM);
info->psinfo = g_malloc0(sizeof (*info->psinfo));
if (info->prstatus == NULL)
return (-ENOMEM);
/*
* First fill in status (and registers) of current thread
* including process info & aux vector.
*/
fill_prstatus(info->prstatus, ts, signr);
elf_core_copy_regs(&info->prstatus->pr_reg, env);
fill_note(&info->notes[0], "CORE", NT_PRSTATUS,
sizeof (*info->prstatus), info->prstatus);
fill_psinfo(info->psinfo, ts);
fill_note(&info->notes[1], "CORE", NT_PRPSINFO,
sizeof (*info->psinfo), info->psinfo);
fill_auxv_note(&info->notes[2], ts);
info->numnote = 3;
info->notes_size = 0;
for (i = 0; i < info->numnote; i++)
info->notes_size += note_size(&info->notes[i]);
/* read and fill status of all threads */
cpu_list_lock();
CPU_FOREACH(cpu) {
if (cpu == thread_cpu) {
continue;
}
fill_thread_info(info, (CPUArchState *)cpu->env_ptr);
}
cpu_list_unlock();
return (0);
}
| 12,230 |
qemu | 658ae5a7b90139a6a296cd4cd83643d843964796 | 1 | static uint16List **host_memory_append_node(uint16List **node,
unsigned long value)
{
*node = g_malloc0(sizeof(**node));
(*node)->value = value;
return &(*node)->next;
}
| 12,232 |
qemu | ddcb73b7782cb6104479503faea04cc224f982b5 | 1 | static int e1000_post_load(void *opaque, int version_id)
{
E1000State *s = opaque;
NetClientState *nc = qemu_get_queue(s->nic);
/* nc.link_down can't be migrated, so infer link_down according
* to link status bit in mac_reg[STATUS] */
nc->link_down = (s->mac_reg[STATUS] & E1000_STATUS_LU) == 0;
return 0;
}
| 12,233 |
qemu | 5e5a94b60518002e8ecc7afa78a9e7565b23e38f | 1 | bdrv_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, int64_t bytes,
enum BlockAcctType type)
{
assert(type < BDRV_MAX_IOTYPE);
cookie->bytes = bytes;
cookie->start_time_ns = get_clock();
cookie->type = type;
}
| 12,234 |
FFmpeg | f23a9759cee8442b02195a4539f65d041104c9cb | 1 | static int tcp_open(URLContext *h, const char *uri, int flags)
{
struct sockaddr_in dest_addr;
int port, fd = -1;
TCPContext *s = NULL;
fd_set wfds;
int fd_max, ret;
struct timeval tv;
socklen_t optlen;
char hostname[1024],proto[1024],path[1024],tmp[1024],*q;
if(!ff_network_init())
return AVERROR(EIO);
url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
&port, path, sizeof(path), uri);
if (strcmp(proto,"tcp") || port <= 0 || port >= 65536)
return AVERROR(EINVAL);
if ((q = strchr(hostname,'@'))) { strcpy(tmp,q+1); strcpy(hostname,tmp); }
dest_addr.sin_family = AF_INET;
dest_addr.sin_port = htons(port);
if (resolve_host(&dest_addr.sin_addr, hostname) < 0)
return AVERROR(EIO);
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
return AVERROR(EIO);
ff_socket_nonblock(fd, 1);
redo:
ret = connect(fd, (struct sockaddr *)&dest_addr,
sizeof(dest_addr));
if (ret < 0) {
if (ff_neterrno() == FF_NETERROR(EINTR))
goto redo;
if (ff_neterrno() != FF_NETERROR(EINPROGRESS) &&
ff_neterrno() != FF_NETERROR(EAGAIN))
goto fail;
/* wait until we are connected or until abort */
for(;;) {
if (url_interrupt_cb()) {
ret = AVERROR(EINTR);
goto fail1;
}
fd_max = fd;
FD_ZERO(&wfds);
FD_SET(fd, &wfds);
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);
if (ret > 0 && FD_ISSET(fd, &wfds))
break;
}
/* test error */
optlen = sizeof(ret);
getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
if (ret != 0)
goto fail;
}
s = av_malloc(sizeof(TCPContext));
if (!s)
return AVERROR(ENOMEM);
h->priv_data = s;
h->is_streamed = 1;
s->fd = fd;
return 0;
fail:
ret = AVERROR(EIO);
fail1:
if (fd >= 0)
closesocket(fd);
return ret;
}
| 12,235 |
FFmpeg | 963f76144897d3f7684d82ec21e51dd50ea1106e | 1 | static av_always_inline int even(uint64_t layout)
{
return (!layout || (layout & (layout - 1)));
}
| 12,236 |
qemu | 599d0c45615b7d099d256738a586d0f63bc707e6 | 1 | static int xen_host_pci_get_value(XenHostPCIDevice *d, const char *name,
unsigned int *pvalue, int base)
{
char path[PATH_MAX];
char buf[XEN_HOST_PCI_GET_VALUE_BUFFER_SIZE];
int fd, rc;
unsigned long value;
char *endptr;
rc = xen_host_pci_sysfs_path(d, name, path, sizeof (path));
if (rc) {
return rc;
}
fd = open(path, O_RDONLY);
if (fd == -1) {
XEN_HOST_PCI_LOG("Error: Can't open %s: %s\n", path, strerror(errno));
return -errno;
}
do {
rc = read(fd, &buf, sizeof (buf) - 1);
if (rc < 0 && errno != EINTR) {
rc = -errno;
goto out;
}
} while (rc < 0);
buf[rc] = 0;
value = strtol(buf, &endptr, base);
if (endptr == buf || *endptr != '\n') {
rc = -1;
} else if ((value == LONG_MIN || value == LONG_MAX) && errno == ERANGE) {
rc = -errno;
} else {
rc = 0;
*pvalue = value;
}
out:
close(fd);
return rc;
}
| 12,237 |
FFmpeg | 44729bc0204fd8bdc29c234fc663229e44420b09 | 1 | static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead)
{
ebml_master metaseek, seekentry;
int64_t currentpos;
int i;
currentpos = avio_tell(pb);
if (seekhead->reserved_size > 0)
if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0)
return -1;
metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size);
for (i = 0; i < seekhead->num_entries; i++) {
mkv_seekhead_entry *entry = &seekhead->entries[i];
seekentry = start_ebml_master(pb, MATROSKA_ID_SEEKENTRY, MAX_SEEKENTRY_SIZE);
put_ebml_id(pb, MATROSKA_ID_SEEKID);
put_ebml_num(pb, ebml_id_size(entry->elementid), 0);
put_ebml_id(pb, entry->elementid);
put_ebml_uint(pb, MATROSKA_ID_SEEKPOSITION, entry->segmentpos);
end_ebml_master(pb, seekentry);
}
end_ebml_master(pb, metaseek);
if (seekhead->reserved_size > 0) {
uint64_t remaining = seekhead->filepos + seekhead->reserved_size - avio_tell(pb);
put_ebml_void(pb, remaining);
avio_seek(pb, currentpos, SEEK_SET);
currentpos = seekhead->filepos;
}
av_free(seekhead->entries);
av_free(seekhead);
return currentpos;
}
| 12,238 |
FFmpeg | c2a016ad4d9c29285813ba5806189e63e063e0fb | 1 | static int wavpack_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
WavpackContext *s = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int frame_size;
int samplecount = 0;
s->block = 0;
s->samples_left = 0;
s->ch_offset = 0;
if(s->mkv_mode){
s->samples = AV_RL32(buf); buf += 4;
}
while(buf_size > 0){
if(!s->multichannel){
frame_size = buf_size;
}else{
if(!s->mkv_mode){
frame_size = AV_RL32(buf) - 12; buf += 4; buf_size -= 4;
}else{
if(buf_size < 12) //MKV files can have zero flags after last block
break;
frame_size = AV_RL32(buf + 8) + 12;
}
}
if(frame_size < 0 || frame_size > buf_size){
av_log(avctx, AV_LOG_ERROR, "Block %d has invalid size (size %d vs. %d bytes left)\n",
s->block, frame_size, buf_size);
return -1;
}
if((samplecount = wavpack_decode_block(avctx, s->block, data,
data_size, buf, frame_size)) < 0)
return -1;
s->block++;
buf += frame_size; buf_size -= frame_size;
}
*data_size = samplecount * avctx->channels;
return s->samples_left > 0 ? 0 : avpkt->size;
}
| 12,239 |
FFmpeg | ddfa3751c092feaf1e080f66587024689dfe603c | 1 | static int get_bits(J2kDecoderContext *s, int n)
{
int res = 0;
if (s->buf_end - s->buf < ((n - s->bit_index) >> 8))
return AVERROR(EINVAL);
while (--n >= 0){
res <<= 1;
if (s->bit_index == 0){
s->bit_index = 7 + (*s->buf != 0xff);
s->buf++;
}
s->bit_index--;
res |= (*s->buf >> s->bit_index) & 1;
}
return res;
}
| 12,240 |
qemu | 82a93a1d307064f35c363f79b04b0a0149ac53d9 | 1 | static uint32_t drc_set_usable(sPAPRDRConnector *drc)
{
/* if there's no resource/device associated with the DRC, there's
* no way for us to put it in an allocation state consistent with
* being 'USABLE'. PAPR 2.7, 13.5.3.4 documents that this should
* result in an RTAS return code of -3 / "no such indicator"
*/
if (!drc->dev) {
return RTAS_OUT_NO_SUCH_INDICATOR;
}
if (drc->awaiting_release && drc->awaiting_allocation) {
/* kernel is acknowledging a previous hotplug event
* while we are already removing it.
* it's safe to ignore awaiting_allocation here since we know the
* situation is predicated on the guest either already having done
* so (boot-time hotplug), or never being able to acquire in the
* first place (hotplug followed by immediate unplug).
*/
return RTAS_OUT_NO_SUCH_INDICATOR;
}
drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE;
drc->awaiting_allocation = false;
return RTAS_OUT_SUCCESS;
}
| 12,241 |
qemu | c9b83e9c23ecb094ddf987c7c37b8f454cb80615 | 1 | static ssize_t qcow2_crypto_hdr_init_func(QCryptoBlock *block, size_t headerlen,
void *opaque, Error **errp)
{
BlockDriverState *bs = opaque;
BDRVQcow2State *s = bs->opaque;
int64_t ret;
int64_t clusterlen;
ret = qcow2_alloc_clusters(bs, headerlen);
if (ret < 0) {
error_setg_errno(errp, -ret,
"Cannot allocate cluster for LUKS header size %zu",
headerlen);
return -1;
}
s->crypto_header.length = headerlen;
s->crypto_header.offset = ret;
/* Zero fill remaining space in cluster so it has predictable
* content in case of future spec changes */
clusterlen = size_to_clusters(s, headerlen) * s->cluster_size;
ret = bdrv_pwrite_zeroes(bs->file,
ret + headerlen,
clusterlen - headerlen, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not zero fill encryption header");
return -1;
}
return ret;
} | 12,242 |
FFmpeg | c8ea5ccd5db125e24d46c74339c64f9527d7a72e | 1 | static int get_cookies(HTTPContext *s, char **cookies, const char *path,
const char *domain)
{
// cookie strings will look like Set-Cookie header field values. Multiple
// Set-Cookie fields will result in multiple values delimited by a newline
int ret = 0;
char *next, *cookie, *set_cookies = av_strdup(s->cookies), *cset_cookies = set_cookies;
if (!set_cookies) return AVERROR(EINVAL);
*cookies = NULL;
while ((cookie = av_strtok(set_cookies, "\n", &next))) {
int domain_offset = 0;
char *param, *next_param, *cdomain = NULL, *cpath = NULL, *cvalue = NULL;
set_cookies = NULL;
while ((param = av_strtok(cookie, "; ", &next_param))) {
cookie = NULL;
if (!av_strncasecmp("path=", param, 5)) {
cpath = av_strdup(¶m[5]);
} else if (!av_strncasecmp("domain=", param, 7)) {
cdomain = av_strdup(¶m[7]);
} else if (!av_strncasecmp("secure", param, 6) ||
!av_strncasecmp("comment", param, 7) ||
!av_strncasecmp("max-age", param, 7) ||
!av_strncasecmp("version", param, 7)) {
// ignore Comment, Max-Age, Secure and Version
} else {
av_free(cvalue);
cvalue = av_strdup(param);
}
}
// ensure all of the necessary values are valid
if (!cdomain || !cpath || !cvalue) {
av_log(s, AV_LOG_WARNING,
"Invalid cookie found, no value, path or domain specified\n");
goto done_cookie;
}
// check if the request path matches the cookie path
if (av_strncasecmp(path, cpath, strlen(cpath)))
goto done_cookie;
// the domain should be at least the size of our cookie domain
domain_offset = strlen(domain) - strlen(cdomain);
if (domain_offset < 0)
goto done_cookie;
// match the cookie domain
if (av_strcasecmp(&domain[domain_offset], cdomain))
goto done_cookie;
// cookie parameters match, so copy the value
if (!*cookies) {
if (!(*cookies = av_strdup(cvalue))) {
ret = AVERROR(ENOMEM);
goto done_cookie;
}
} else {
char *tmp = *cookies;
size_t str_size = strlen(cvalue) + strlen(*cookies) + 3;
if (!(*cookies = av_malloc(str_size))) {
ret = AVERROR(ENOMEM);
goto done_cookie;
}
snprintf(*cookies, str_size, "%s; %s", tmp, cvalue);
av_free(tmp);
}
done_cookie:
av_free(cvalue);
if (ret < 0) {
if (*cookies) av_freep(cookies);
av_free(cset_cookies);
return ret;
}
}
av_free(cset_cookies);
return 0;
} | 12,244 |
FFmpeg | 19e95b88459e879d3e67a66350d937c32ed762ca | 1 | static inline void xan_wc3_copy_pixel_run(XanContext *s,
int x, int y, int pixel_count, int motion_x, int motion_y)
{
int stride;
int line_inc;
int curframe_index, prevframe_index;
int curframe_x, prevframe_x;
int width = s->avctx->width;
unsigned char *palette_plane, *prev_palette_plane;
palette_plane = s->current_frame.data[0];
prev_palette_plane = s->last_frame.data[0];
stride = s->current_frame.linesize[0];
line_inc = stride - width;
curframe_index = y * stride + x;
curframe_x = x;
prevframe_index = (y + motion_y) * stride + x + motion_x;
prevframe_x = x + motion_x;
while(pixel_count && (curframe_index < s->frame_size)) {
int count = FFMIN3(pixel_count, width - curframe_x, width - prevframe_x);
memcpy(palette_plane + curframe_index, prev_palette_plane + prevframe_index, count);
pixel_count -= count;
curframe_index += count;
prevframe_index += count;
curframe_x += count;
prevframe_x += count;
if (curframe_x >= width) {
curframe_index += line_inc;
curframe_x = 0;
}
if (prevframe_x >= width) {
prevframe_index += line_inc;
prevframe_x = 0;
}
}
} | 12,246 |
qemu | aca7aaf6287b6a9f688c1b115a76fdc056565a7e | 1 | pixman_format_code_t qemu_default_pixman_format(int bpp, bool native_endian)
{
if (native_endian) {
switch (bpp) {
case 15:
return PIXMAN_x1r5g5b5;
case 16:
return PIXMAN_r5g6b5;
case 24:
return PIXMAN_r8g8b8;
case 32:
return PIXMAN_x8r8g8b8;
}
} else {
switch (bpp) {
case 24:
return PIXMAN_b8g8r8;
case 32:
return PIXMAN_b8g8r8x8;
break;
}
}
g_assert_not_reached();
}
| 12,247 |
qemu | 61ed73cff427206b3a959b18a4877952f566279b | 1 | static ssize_t handle_aiocb_rw_linear(RawPosixAIOData *aiocb, char *buf)
{
ssize_t offset = 0;
ssize_t len;
while (offset < aiocb->aio_nbytes) {
if (aiocb->aio_type & QEMU_AIO_WRITE) {
len = pwrite(aiocb->aio_fildes,
(const char *)buf + offset,
aiocb->aio_nbytes - offset,
aiocb->aio_offset + offset);
} else {
len = pread(aiocb->aio_fildes,
buf + offset,
aiocb->aio_nbytes - offset,
aiocb->aio_offset + offset);
}
if (len == -1 && errno == EINTR) {
continue;
} else if (len == -1) {
offset = -errno;
} else if (len == 0) {
}
offset += len;
}
return offset;
} | 12,248 |
FFmpeg | 8d857c543402911f46ad38b093ab9aaf5b9a9a18 | 1 | static inline int get_block(GetBitContext *gb, DCTELEM *block, const uint8_t *scan,
const uint32_t *quant) {
int coeff, i, n;
int8_t ac;
uint8_t dc = get_bits(gb, 8);
// block not coded
if (dc == 255)
// number of non-zero coefficients
coeff = get_bits(gb, 6);
// normally we would only need to clear the (63 - coeff) last values,
// but since we do not know where they are we just clear the whole block
memset(block, 0, 64 * sizeof(DCTELEM));
// 2 bits per coefficient
while (coeff) {
ac = get_sbits(gb, 2);
if (ac == -2)
break; // continue with more bits
PUT_COEFF(ac);
}
// 4 bits per coefficient
ALIGN(4);
if (get_bits_count(gb) + (coeff << 2) >= gb->size_in_bits)
while (coeff) {
ac = get_sbits(gb, 4);
if (ac == -8)
break; // continue with more bits
PUT_COEFF(ac);
}
// 8 bits per coefficient
ALIGN(8);
if (get_bits_count(gb) + (coeff << 3) >= gb->size_in_bits)
while (coeff) {
ac = get_sbits(gb, 8);
PUT_COEFF(ac);
}
PUT_COEFF(dc);
return 1;
} | 12,249 |
qemu | 124fe7fb1b7a1db8cb2ebb9edae84716ffaf37ce | 1 | vcard_emul_find_vreader_from_slot(PK11SlotInfo *slot)
{
VReaderList *reader_list = vreader_get_reader_list();
VReaderListEntry *current_entry = NULL;
if (reader_list == NULL) {
return NULL;
}
for (current_entry = vreader_list_get_first(reader_list); current_entry;
current_entry = vreader_list_get_next(current_entry)) {
VReader *reader = vreader_list_get_reader(current_entry);
VReaderEmul *reader_emul = vreader_get_private(reader);
if (reader_emul->slot == slot) {
return reader;
}
vreader_free(reader);
}
return NULL;
} | 12,250 |
FFmpeg | 6bde1e9d14ff1e0ecff74b8ff59607f545c6f2ec | 0 | static int can_merge_formats(AVFilterFormats *a_arg,
AVFilterFormats *b_arg,
enum AVMediaType type,
int is_sample_rate)
{
AVFilterFormats *a, *b, *ret;
if (a == b)
return 1;
a = clone_filter_formats(a_arg);
b = clone_filter_formats(b_arg);
if (is_sample_rate) {
ret = ff_merge_samplerates(a, b);
} else {
ret = ff_merge_formats(a, b, type);
}
if (ret) {
av_freep(&ret->formats);
av_freep(&ret);
return 1;
} else {
av_freep(&a->formats);
av_freep(&b->formats);
av_freep(&a);
av_freep(&b);
return 0;
}
}
| 12,251 |
FFmpeg | 7df3b426bbfbd7efd9a0f56393e3cc78413b0869 | 1 | static int mxf_write_partition(AVFormatContext *s, int bodysid,
int indexsid,
const uint8_t *key, int write_metadata)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
int64_t header_byte_count_offset;
unsigned index_byte_count = 0;
uint64_t partition_offset = avio_tell(pb);
int err;
if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
12+mxf->edit_units_count*(11+mxf->slice_count*4);
else if (mxf->edit_unit_byte_count && indexsid)
index_byte_count = 80;
if (index_byte_count) {
// add encoded ber length
index_byte_count += 16 + klv_ber_length(index_byte_count);
index_byte_count += klv_fill_size(index_byte_count);
}
if (!memcmp(key, body_partition_key, 16)) {
if ((err = av_reallocp_array(&mxf->body_partition_offset, mxf->body_partitions_count + 1,
sizeof(*mxf->body_partition_offset))) < 0) {
mxf->body_partitions_count = 0;
return err;
}
mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset;
}
// write klv
avio_write(pb, key, 16);
klv_encode_ber_length(pb, 88 + 16 * mxf->essence_container_count);
// write partition value
avio_wb16(pb, 1); // majorVersion
avio_wb16(pb, 2); // minorVersion
avio_wb32(pb, KAG_SIZE); // KAGSize
avio_wb64(pb, partition_offset); // ThisPartition
if (!memcmp(key, body_partition_key, 16) && mxf->body_partitions_count > 1)
avio_wb64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]); // PreviousPartition
else if (!memcmp(key, footer_partition_key, 16) && mxf->body_partitions_count)
avio_wb64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]); // PreviousPartition
else
avio_wb64(pb, 0);
avio_wb64(pb, mxf->footer_partition_offset); // footerPartition
// set offset
header_byte_count_offset = avio_tell(pb);
avio_wb64(pb, 0); // headerByteCount, update later
// indexTable
avio_wb64(pb, index_byte_count); // indexByteCount
avio_wb32(pb, index_byte_count ? indexsid : 0); // indexSID
// BodyOffset
if (bodysid && mxf->edit_units_count && mxf->body_partitions_count) {
avio_wb64(pb, mxf->body_offset);
} else
avio_wb64(pb, 0);
avio_wb32(pb, bodysid); // bodySID
// operational pattern
avio_write(pb, op1a_ul, 16);
// essence container
mxf_write_essence_container_refs(s);
if (write_metadata) {
// mark the start of the headermetadata and calculate metadata size
int64_t pos, start;
unsigned header_byte_count;
mxf_write_klv_fill(s);
start = avio_tell(s->pb);
mxf_write_primer_pack(s);
mxf_write_header_metadata_sets(s);
pos = avio_tell(s->pb);
header_byte_count = pos - start + klv_fill_size(pos);
// update header_byte_count
avio_seek(pb, header_byte_count_offset, SEEK_SET);
avio_wb64(pb, header_byte_count);
avio_seek(pb, pos, SEEK_SET);
}
avio_flush(pb);
return 0;
}
| 12,252 |
qemu | 5f5a1318653c08e435cfa52f60b6a712815b659d | 1 | void virtio_config_writew(VirtIODevice *vdev, uint32_t addr, uint32_t data)
{
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint16_t val = data;
if (addr > (vdev->config_len - sizeof(val)))
return;
stw_p(vdev->config + addr, val);
if (k->set_config) {
k->set_config(vdev, vdev->config);
}
}
| 12,253 |
FFmpeg | ddfa3751c092feaf1e080f66587024689dfe603c | 1 | static uint8_t get_sot(J2kDecoderContext *s)
{
if (s->buf_end - s->buf < 4)
return AVERROR(EINVAL);
s->curtileno = bytestream_get_be16(&s->buf); ///< Isot
if((unsigned)s->curtileno >= s->numXtiles * s->numYtiles){
s->curtileno=0;
return AVERROR(EINVAL);
}
s->buf += 4; ///< Psot (ignored)
if (!bytestream_get_byte(&s->buf)){ ///< TPsot
J2kTile *tile = s->tile + s->curtileno;
/* copy defaults */
memcpy(tile->codsty, s->codsty, s->ncomponents * sizeof(J2kCodingStyle));
memcpy(tile->qntsty, s->qntsty, s->ncomponents * sizeof(J2kQuantStyle));
}
bytestream_get_byte(&s->buf); ///< TNsot
return 0;
}
| 12,254 |
qemu | 09aaa1602f9381c0e0fb539390b1793e51bdfc7b | 1 | static void i6300esb_pc_init(PCIBus *pci_bus)
{
I6300State *d;
uint8_t *pci_conf;
if (!pci_bus) {
fprintf(stderr, "wdt_i6300esb: no PCI bus in this machine\n");
return;
}
d = (I6300State *)
pci_register_device (pci_bus, "i6300esb_wdt", sizeof (I6300State),
-1,
i6300esb_config_read, i6300esb_config_write);
d->reboot_enabled = 1;
d->clock_scale = CLOCK_SCALE_1KHZ;
d->int_type = INT_TYPE_IRQ;
d->free_run = 0;
d->locked = 0;
d->enabled = 0;
d->timer = qemu_new_timer(vm_clock, i6300esb_timer_expired, d);
d->timer1_preload = 0xfffff;
d->timer2_preload = 0xfffff;
d->stage = 1;
d->unlock_state = 0;
d->previous_reboot_flag = 0;
pci_conf = d->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_ESB_9);
pci_config_set_class(pci_conf, PCI_CLASS_SYSTEM_OTHER);
pci_conf[0x0e] = 0x00;
pci_register_bar(&d->dev, 0, 0x10,
PCI_ADDRESS_SPACE_MEM, i6300esb_map);
register_savevm("i6300esb_wdt", -1, sizeof(I6300State),
i6300esb_save, i6300esb_load, d);
}
| 12,256 |
qemu | 43d70ddf9f96b3ad037abe4d5f9f2768196b8c92 | 1 | static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
TranslationBlock **last_tb, int *tb_exit,
SyncClocks *sc)
{
uintptr_t ret;
if (unlikely(atomic_read(&cpu->exit_request))) {
return;
}
trace_exec_tb(tb, tb->pc);
ret = cpu_tb_exec(cpu, tb);
*last_tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK);
*tb_exit = ret & TB_EXIT_MASK;
switch (*tb_exit) {
case TB_EXIT_REQUESTED:
/* Something asked us to stop executing
* chained TBs; just continue round the main
* loop. Whatever requested the exit will also
* have set something else (eg exit_request or
* interrupt_request) which we will handle
* next time around the loop. But we need to
* ensure the tcg_exit_req read in generated code
* comes before the next read of cpu->exit_request
* or cpu->interrupt_request.
*/
smp_rmb();
*last_tb = NULL;
break;
case TB_EXIT_ICOUNT_EXPIRED:
{
/* Instruction counter expired. */
#ifdef CONFIG_USER_ONLY
abort();
#else
int insns_left = cpu->icount_decr.u32;
if (cpu->icount_extra && insns_left >= 0) {
/* Refill decrementer and continue execution. */
cpu->icount_extra += insns_left;
insns_left = MIN(0xffff, cpu->icount_extra);
cpu->icount_extra -= insns_left;
cpu->icount_decr.u16.low = insns_left;
} else {
if (insns_left > 0) {
/* Execute remaining instructions. */
cpu_exec_nocache(cpu, insns_left, *last_tb, false);
align_clocks(sc, cpu);
}
cpu->exception_index = EXCP_INTERRUPT;
*last_tb = NULL;
cpu_loop_exit(cpu);
}
break;
#endif
}
default:
break;
}
}
| 12,258 |
qemu | 6cec5487990bf3f1f22b3fcb871978255e92ae0d | 1 | static void vnc_dpy_update(DisplayState *ds, int x, int y, int w, int h)
{
VncState *vs = ds->opaque;
int i;
h += y;
/* round x down to ensure the loop only spans one 16-pixel block per,
iteration. otherwise, if (x % 16) != 0, the last iteration may span
two 16-pixel blocks but we only mark the first as dirty
*/
w += (x % 16);
x -= (x % 16);
x = MIN(x, vs->width);
y = MIN(y, vs->height);
w = MIN(x + w, vs->width) - x;
h = MIN(h, vs->height);
for (; y < h; y++)
for (i = 0; i < w; i += 16)
vnc_set_bit(vs->dirty_row[y], (x + i) / 16);
}
| 12,260 |
qemu | f53c398aa603cea135ee58fd15249aeff7b9c7ea | 1 | static void musb_async_cancel_device(MUSBState *s, USBDevice *dev)
{
int ep, dir;
for (ep = 0; ep < 16; ep++) {
for (dir = 0; dir < 2; dir++) {
if (s->ep[ep].packey[dir].p.owner == NULL ||
s->ep[ep].packey[dir].p.owner->dev != dev) {
continue;
}
usb_cancel_packet(&s->ep[ep].packey[dir].p);
/* status updates needed here? */
}
}
}
| 12,261 |
qemu | aedbe19297907143f17b733a7ff0e0534377bed1 | 1 | int qemu_reset_requested_get(void)
{
return reset_requested;
}
| 12,262 |
FFmpeg | 075060023d978975ed5328e269d6e20163e669d2 | 1 | static void select_input_picture(MpegEncContext *s){
int i;
for(i=1; i<MAX_PICTURE_COUNT; i++)
s->reordered_input_picture[i-1]= s->reordered_input_picture[i];
s->reordered_input_picture[MAX_PICTURE_COUNT-1]= NULL;
/* set next picture type & ordering */
if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){
if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){
s->reordered_input_picture[0]= s->input_picture[0];
s->reordered_input_picture[0]->pict_type= I_TYPE;
s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
}else{
int b_frames;
if(s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor){
if(s->picture_in_gop_number < s->gop_size && skip_check(s, s->input_picture[0], s->next_picture_ptr)){
//FIXME check that te gop check above is +-1 correct
//av_log(NULL, AV_LOG_DEBUG, "skip %p %Ld\n", s->input_picture[0]->data[0], s->input_picture[0]->pts);
if(s->input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
for(i=0; i<4; i++)
s->input_picture[0]->data[i]= NULL;
s->input_picture[0]->type= 0;
}else{
assert( s->input_picture[0]->type==FF_BUFFER_TYPE_USER
|| s->input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL);
s->avctx->release_buffer(s->avctx, (AVFrame*)s->input_picture[0]);
}
emms_c();
ff_vbv_update(s, 0);
goto no_output_pic;
}
}
if(s->flags&CODEC_FLAG_PASS2){
for(i=0; i<s->max_b_frames+1; i++){
int pict_num= s->input_picture[0]->display_picture_number + i;
if(pict_num >= s->rc_context.num_entries)
break;
if(!s->input_picture[i]){
s->rc_context.entry[pict_num-1].new_pict_type = P_TYPE;
break;
}
s->input_picture[i]->pict_type=
s->rc_context.entry[pict_num].new_pict_type;
}
}
if(s->avctx->b_frame_strategy==0){
b_frames= s->max_b_frames;
while(b_frames && !s->input_picture[b_frames]) b_frames--;
}else if(s->avctx->b_frame_strategy==1){
for(i=1; i<s->max_b_frames+1; i++){
if(s->input_picture[i] && s->input_picture[i]->b_frame_score==0){
s->input_picture[i]->b_frame_score=
get_intra_count(s, s->input_picture[i ]->data[0],
s->input_picture[i-1]->data[0], s->linesize) + 1;
}
}
for(i=0; i<s->max_b_frames+1; i++){
if(s->input_picture[i]==NULL || s->input_picture[i]->b_frame_score - 1 > s->mb_num/s->avctx->b_sensitivity) break;
}
b_frames= FFMAX(0, i-1);
/* reset scores */
for(i=0; i<b_frames+1; i++){
s->input_picture[i]->b_frame_score=0;
}
}else if(s->avctx->b_frame_strategy==2){
b_frames= estimate_best_b_count(s);
}else{
av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
b_frames=0;
}
emms_c();
//static int b_count=0;
//b_count+= b_frames;
//av_log(s->avctx, AV_LOG_DEBUG, "b_frames: %d\n", b_count);
for(i= b_frames - 1; i>=0; i--){
int type= s->input_picture[i]->pict_type;
if(type && type != B_TYPE)
b_frames= i;
}
if(s->input_picture[b_frames]->pict_type == B_TYPE && b_frames == s->max_b_frames){
av_log(s->avctx, AV_LOG_ERROR, "warning, too many b frames in a row\n");
}
if(s->picture_in_gop_number + b_frames >= s->gop_size){
if((s->flags2 & CODEC_FLAG2_STRICT_GOP) && s->gop_size > s->picture_in_gop_number){
b_frames= s->gop_size - s->picture_in_gop_number - 1;
}else{
if(s->flags & CODEC_FLAG_CLOSED_GOP)
b_frames=0;
s->input_picture[b_frames]->pict_type= I_TYPE;
}
}
if( (s->flags & CODEC_FLAG_CLOSED_GOP)
&& b_frames
&& s->input_picture[b_frames]->pict_type== I_TYPE)
b_frames--;
s->reordered_input_picture[0]= s->input_picture[b_frames];
if(s->reordered_input_picture[0]->pict_type != I_TYPE)
s->reordered_input_picture[0]->pict_type= P_TYPE;
s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
for(i=0; i<b_frames; i++){
s->reordered_input_picture[i+1]= s->input_picture[i];
s->reordered_input_picture[i+1]->pict_type= B_TYPE;
s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++;
}
}
}
no_output_pic:
if(s->reordered_input_picture[0]){
s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE ? 3 : 0;
copy_picture(&s->new_picture, s->reordered_input_picture[0]);
if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
// input is a shared pix, so we can't modifiy it -> alloc a new one & ensure that the shared one is reuseable
int i= ff_find_unused_picture(s, 0);
Picture *pic= &s->picture[i];
/* mark us unused / free shared pic */
for(i=0; i<4; i++)
s->reordered_input_picture[0]->data[i]= NULL;
s->reordered_input_picture[0]->type= 0;
pic->reference = s->reordered_input_picture[0]->reference;
alloc_picture(s, pic, 0);
copy_picture_attributes(s, (AVFrame*)pic, (AVFrame*)s->reordered_input_picture[0]);
s->current_picture_ptr= pic;
}else{
// input is not a shared pix -> reuse buffer for current_pix
assert( s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_USER
|| s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL);
s->current_picture_ptr= s->reordered_input_picture[0];
for(i=0; i<4; i++){
s->new_picture.data[i]+= INPLACE_OFFSET;
}
}
copy_picture(&s->current_picture, s->current_picture_ptr);
s->picture_number= s->new_picture.display_picture_number;
//printf("dpn:%d\n", s->picture_number);
}else{
memset(&s->new_picture, 0, sizeof(Picture));
}
}
| 12,263 |
qemu | 12848bfc5d719bad536c5448205a3226be1fda47 | 1 | static int local_chown(FsContext *fs_ctx, const char *path, FsCred *credp)
{
if ((credp->fc_uid == -1 && credp->fc_gid == -1) ||
(fs_ctx->fs_sm == SM_PASSTHROUGH)) {
return lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid);
} else if (fs_ctx->fs_sm == SM_MAPPED) {
return local_set_xattr(rpath(fs_ctx, path), credp);
} else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
return lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid);
}
return -1;
}
| 12,264 |
FFmpeg | d7e9533aa06f4073a27812349b35ba5fede11ca1 | 1 | static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
{
const int mb_x= s->mb_x;
const int mb_y= s->mb_y;
int i;
#if 0
if (s->interlaced_dct) {
dct_linesize = s->linesize * 2;
dct_offset = s->linesize;
} else {
dct_linesize = s->linesize;
dct_offset = s->linesize * 8;
}
#endif
if (s->mb_intra) {
UINT8 *ptr;
int wrap;
wrap = s->linesize;
ptr = s->new_picture[0] + (mb_y * 16 * wrap) + mb_x * 16;
get_pixels(s->block[0], ptr , wrap);
get_pixels(s->block[1], ptr + 8, wrap);
get_pixels(s->block[2], ptr + 8 * wrap , wrap);
get_pixels(s->block[3], ptr + 8 * wrap + 8, wrap);
wrap >>=1;
ptr = s->new_picture[1] + (mb_y * 8 * wrap) + mb_x * 8;
get_pixels(s->block[4], ptr, wrap);
ptr = s->new_picture[2] + (mb_y * 8 * wrap) + mb_x * 8;
get_pixels(s->block[5], ptr, wrap);
}else{
op_pixels_func *op_pix;
qpel_mc_func *op_qpix;
UINT8 *dest_y, *dest_cb, *dest_cr;
UINT8 *ptr;
int wrap;
dest_y = s->current_picture[0] + (mb_y * 16 * s->linesize ) + mb_x * 16;
dest_cb = s->current_picture[1] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8;
dest_cr = s->current_picture[2] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8;
if ((!s->no_rounding) || s->pict_type==B_TYPE){
op_pix = put_pixels_tab;
op_qpix= qpel_mc_rnd_tab;
}else{
op_pix = put_no_rnd_pixels_tab;
op_qpix= qpel_mc_no_rnd_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture, op_pix, op_qpix);
if ((!s->no_rounding) || s->pict_type==B_TYPE)
op_pix = avg_pixels_tab;
else
op_pix = avg_no_rnd_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture, op_pix, op_qpix);
}
wrap = s->linesize;
ptr = s->new_picture[0] + (mb_y * 16 * wrap) + mb_x * 16;
diff_pixels(s->block[0], ptr , dest_y , wrap);
diff_pixels(s->block[1], ptr + 8, dest_y + 8, wrap);
diff_pixels(s->block[2], ptr + 8 * wrap , dest_y + 8 * wrap , wrap);
diff_pixels(s->block[3], ptr + 8 * wrap + 8, dest_y + 8 * wrap + 8, wrap);
wrap >>=1;
ptr = s->new_picture[1] + (mb_y * 8 * wrap) + mb_x * 8;
diff_pixels(s->block[4], ptr, dest_cb, wrap);
ptr = s->new_picture[2] + (mb_y * 8 * wrap) + mb_x * 8;
diff_pixels(s->block[5], ptr, dest_cr, wrap);
}
#if 0
{
float adap_parm;
adap_parm = ((s->avg_mb_var << 1) + s->mb_var[s->mb_width*mb_y+mb_x] + 1.0) /
((s->mb_var[s->mb_width*mb_y+mb_x] << 1) + s->avg_mb_var + 1.0);
printf("\ntype=%c qscale=%2d adap=%0.2f dquant=%4.2f var=%4d avgvar=%4d",
(s->mb_type[s->mb_width*mb_y+mb_x] > 0) ? 'I' : 'P',
s->qscale, adap_parm, s->qscale*adap_parm,
s->mb_var[s->mb_width*mb_y+mb_x], s->avg_mb_var);
}
#endif
/* DCT & quantize */
if (s->h263_msmpeg4) {
msmpeg4_dc_scale(s);
} else if (s->h263_pred) {
h263_dc_scale(s);
} else {
/* default quantization values */
s->y_dc_scale = 8;
s->c_dc_scale = 8;
}
for(i=0;i<6;i++) {
s->block_last_index[i] = dct_quantize(s, s->block[i], i, s->qscale);
}
/* huffman encode */
switch(s->out_format) {
case FMT_MPEG1:
mpeg1_encode_mb(s, s->block, motion_x, motion_y);
break;
case FMT_H263:
if (s->h263_msmpeg4)
msmpeg4_encode_mb(s, s->block, motion_x, motion_y);
else if(s->h263_pred)
mpeg4_encode_mb(s, s->block, motion_x, motion_y);
else
h263_encode_mb(s, s->block, motion_x, motion_y);
break;
case FMT_MJPEG:
mjpeg_encode_mb(s, s->block);
break;
}
}
| 12,265 |
qemu | ded67782e6d06069873adce7f9074d273ae75760 | 1 | static int acpi_load_old(QEMUFile *f, void *opaque, int version_id)
{
PIIX4PMState *s = opaque;
int ret, i;
uint16_t temp;
ret = pci_device_load(&s->dev, f);
if (ret < 0) {
return ret;
}
qemu_get_be16s(f, &s->ar.pm1.evt.sts);
qemu_get_be16s(f, &s->ar.pm1.evt.en);
qemu_get_be16s(f, &s->ar.pm1.cnt.cnt);
ret = vmstate_load_state(f, &vmstate_apm, opaque, 1);
if (ret) {
return ret;
}
qemu_get_timer(f, s->ar.tmr.timer);
qemu_get_sbe64s(f, &s->ar.tmr.overflow_time);
qemu_get_be16s(f, (uint16_t *)s->ar.gpe.sts);
for (i = 0; i < 3; i++) {
qemu_get_be16s(f, &temp);
}
qemu_get_be16s(f, (uint16_t *)s->ar.gpe.en);
for (i = 0; i < 3; i++) {
qemu_get_be16s(f, &temp);
}
ret = vmstate_load_state(f, &vmstate_pci_status, opaque, 1);
return ret;
}
| 12,266 |
qemu | 8be7e7e4c72c048b90e3482557954a24bba43ba7 | 1 | static int debugcon_parse(const char *devname)
{
QemuOpts *opts;
if (!qemu_chr_new("debugcon", devname, NULL)) {
exit(1);
}
opts = qemu_opts_create(qemu_find_opts("device"), "debugcon", 1);
if (!opts) {
fprintf(stderr, "qemu: already have a debugcon device\n");
exit(1);
}
qemu_opt_set(opts, "driver", "isa-debugcon");
qemu_opt_set(opts, "chardev", "debugcon");
return 0;
}
| 12,267 |
qemu | e13e973eedba0a52b4b8b079c4b85cdc68b7b4f0 | 1 | static CCIDBus *ccid_bus_new(DeviceState *dev)
{
CCIDBus *bus;
bus = FROM_QBUS(CCIDBus, qbus_create(&ccid_bus_info, dev, NULL));
bus->qbus.allow_hotplug = 1;
return bus;
}
| 12,268 |
qemu | e12ed72e5c00dd3375b8bd107200e4d7e950276a | 1 | bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr)
{
unsigned long *p = map + BIT_WORD(start);
const long size = start + nr;
int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
unsigned long dirty = 0;
unsigned long old_bits;
/* First word */
if (nr - bits_to_clear > 0) {
old_bits = atomic_fetch_and(p, ~mask_to_clear);
dirty |= old_bits & mask_to_clear;
nr -= bits_to_clear;
bits_to_clear = BITS_PER_LONG;
mask_to_clear = ~0UL;
p++;
}
/* Full words */
if (bits_to_clear == BITS_PER_LONG) {
while (nr >= BITS_PER_LONG) {
if (*p) {
old_bits = atomic_xchg(p, 0);
dirty |= old_bits;
}
nr -= BITS_PER_LONG;
p++;
}
}
/* Last word */
if (nr) {
mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
old_bits = atomic_fetch_and(p, ~mask_to_clear);
dirty |= old_bits & mask_to_clear;
} else {
if (!dirty) {
smp_mb();
}
}
return dirty != 0;
} | 12,269 |
FFmpeg | bf29794022db597f526a8575648244a7c6ee15ed | 1 | int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset)
{
struct {
LBRChunk lfe;
LBRChunk tonal;
LBRChunk tonal_grp[5];
LBRChunk grid1[DCA_LBR_CHANNELS / 2];
LBRChunk hr_grid[DCA_LBR_CHANNELS / 2];
LBRChunk ts1[DCA_LBR_CHANNELS / 2];
LBRChunk ts2[DCA_LBR_CHANNELS / 2];
} chunk = { 0 };
GetByteContext gb;
int i, ch, sb, sf, ret, group, chunk_id, chunk_len;
bytestream2_init(&gb, data + asset->lbr_offset, asset->lbr_size);
// LBR sync word
if (bytestream2_get_be32(&gb) != DCA_SYNCWORD_LBR) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sync word\n");
return AVERROR_INVALIDDATA;
}
// LBR header type
switch (bytestream2_get_byte(&gb)) {
case LBR_HEADER_SYNC_ONLY:
if (!s->sample_rate) {
av_log(s->avctx, AV_LOG_ERROR, "LBR decoder not initialized\n");
return AVERROR_INVALIDDATA;
}
break;
case LBR_HEADER_DECODER_INIT:
if ((ret = parse_decoder_init(s, &gb)) < 0) {
s->sample_rate = 0;
return ret;
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR header type\n");
return AVERROR_INVALIDDATA;
}
// LBR frame chunk header
chunk_id = bytestream2_get_byte(&gb);
chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
if (chunk_len > bytestream2_get_bytes_left(&gb)) {
chunk_len = bytestream2_get_bytes_left(&gb);
av_log(s->avctx, AV_LOG_WARNING, "LBR frame chunk was truncated\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
bytestream2_init(&gb, gb.buffer, chunk_len);
switch (chunk_id & 0x7f) {
case LBR_CHUNK_FRAME:
if (s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) {
int checksum = bytestream2_get_be16(&gb);
uint16_t res = chunk_id;
res += (chunk_len >> 8) & 0xff;
res += chunk_len & 0xff;
for (i = 0; i < chunk_len - 2; i++)
res += gb.buffer[i];
if (checksum != res) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid LBR checksum\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
} else {
bytestream2_skip(&gb, 2);
}
break;
case LBR_CHUNK_FRAME_NO_CSUM:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR frame chunk ID\n");
return AVERROR_INVALIDDATA;
}
// Clear current frame
memset(s->quant_levels, 0, sizeof(s->quant_levels));
memset(s->sb_indices, 0xff, sizeof(s->sb_indices));
memset(s->sec_ch_sbms, 0, sizeof(s->sec_ch_sbms));
memset(s->sec_ch_lrms, 0, sizeof(s->sec_ch_lrms));
memset(s->ch_pres, 0, sizeof(s->ch_pres));
memset(s->grid_1_scf, 0, sizeof(s->grid_1_scf));
memset(s->grid_2_scf, 0, sizeof(s->grid_2_scf));
memset(s->grid_3_avg, 0, sizeof(s->grid_3_avg));
memset(s->grid_3_scf, 0, sizeof(s->grid_3_scf));
memset(s->grid_3_pres, 0, sizeof(s->grid_3_pres));
memset(s->tonal_scf, 0, sizeof(s->tonal_scf));
memset(s->lfe_data, 0, sizeof(s->lfe_data));
s->part_stereo_pres = 0;
s->framenum = (s->framenum + 1) & 31;
for (ch = 0; ch < s->nchannels; ch++) {
for (sb = 0; sb < s->nsubbands / 4; sb++) {
s->part_stereo[ch][sb][0] = s->part_stereo[ch][sb][4];
s->part_stereo[ch][sb][4] = 16;
}
}
memset(s->lpc_coeff[s->framenum & 1], 0, sizeof(s->lpc_coeff[0]));
for (group = 0; group < 5; group++) {
for (sf = 0; sf < 1 << group; sf++) {
int sf_idx = ((s->framenum << group) + sf) & 31;
s->tonal_bounds[group][sf_idx][0] =
s->tonal_bounds[group][sf_idx][1] = s->ntones;
}
}
// Parse chunk headers
while (bytestream2_get_bytes_left(&gb) > 0) {
chunk_id = bytestream2_get_byte(&gb);
chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
chunk_id &= 0x7f;
if (chunk_len > bytestream2_get_bytes_left(&gb)) {
chunk_len = bytestream2_get_bytes_left(&gb);
av_log(s->avctx, AV_LOG_WARNING, "LBR chunk %#x was truncated\n", chunk_id);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
switch (chunk_id) {
case LBR_CHUNK_LFE:
chunk.lfe.len = chunk_len;
chunk.lfe.data = gb.buffer;
break;
case LBR_CHUNK_SCF:
case LBR_CHUNK_TONAL:
case LBR_CHUNK_TONAL_SCF:
chunk.tonal.id = chunk_id;
chunk.tonal.len = chunk_len;
chunk.tonal.data = gb.buffer;
break;
case LBR_CHUNK_TONAL_GRP_1:
case LBR_CHUNK_TONAL_GRP_2:
case LBR_CHUNK_TONAL_GRP_3:
case LBR_CHUNK_TONAL_GRP_4:
case LBR_CHUNK_TONAL_GRP_5:
i = LBR_CHUNK_TONAL_GRP_5 - chunk_id;
chunk.tonal_grp[i].id = i;
chunk.tonal_grp[i].len = chunk_len;
chunk.tonal_grp[i].data = gb.buffer;
break;
case LBR_CHUNK_TONAL_SCF_GRP_1:
case LBR_CHUNK_TONAL_SCF_GRP_2:
case LBR_CHUNK_TONAL_SCF_GRP_3:
case LBR_CHUNK_TONAL_SCF_GRP_4:
case LBR_CHUNK_TONAL_SCF_GRP_5:
i = LBR_CHUNK_TONAL_SCF_GRP_5 - chunk_id;
chunk.tonal_grp[i].id = i;
chunk.tonal_grp[i].len = chunk_len;
chunk.tonal_grp[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_GRID_LR:
case LBR_CHUNK_RES_GRID_LR + 1:
case LBR_CHUNK_RES_GRID_LR + 2:
i = chunk_id - LBR_CHUNK_RES_GRID_LR;
chunk.grid1[i].len = chunk_len;
chunk.grid1[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_GRID_HR:
case LBR_CHUNK_RES_GRID_HR + 1:
case LBR_CHUNK_RES_GRID_HR + 2:
i = chunk_id - LBR_CHUNK_RES_GRID_HR;
chunk.hr_grid[i].len = chunk_len;
chunk.hr_grid[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_TS_1:
case LBR_CHUNK_RES_TS_1 + 1:
case LBR_CHUNK_RES_TS_1 + 2:
i = chunk_id - LBR_CHUNK_RES_TS_1;
chunk.ts1[i].len = chunk_len;
chunk.ts1[i].data = gb.buffer;
break;
case LBR_CHUNK_RES_TS_2:
case LBR_CHUNK_RES_TS_2 + 1:
case LBR_CHUNK_RES_TS_2 + 2:
i = chunk_id - LBR_CHUNK_RES_TS_2;
chunk.ts2[i].len = chunk_len;
chunk.ts2[i].data = gb.buffer;
break;
}
bytestream2_skip(&gb, chunk_len);
}
// Parse the chunks
ret = parse_lfe_chunk(s, &chunk.lfe);
ret |= parse_tonal_chunk(s, &chunk.tonal);
for (i = 0; i < 5; i++)
ret |= parse_tonal_group(s, &chunk.tonal_grp[i]);
for (i = 0; i < (s->nchannels + 1) / 2; i++) {
int ch1 = i * 2;
int ch2 = FFMIN(ch1 + 1, s->nchannels - 1);
if (parse_grid_1_chunk (s, &chunk.grid1 [i], ch1, ch2) < 0 ||
parse_high_res_grid(s, &chunk.hr_grid[i], ch1, ch2) < 0) {
ret = -1;
continue;
}
// TS chunks depend on both grids. TS_2 depends on TS_1.
if (!chunk.grid1[i].len || !chunk.hr_grid[i].len || !chunk.ts1[i].len)
continue;
if (parse_ts1_chunk(s, &chunk.ts1[i], ch1, ch2) < 0 ||
parse_ts2_chunk(s, &chunk.ts2[i], ch1, ch2) < 0) {
ret = -1;
continue;
}
}
if (ret < 0 && (s->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
return 0;
}
| 12,270 |
qemu | 8b6b2afcf85dd5ff33075e93a2e30fbea34c5a55 | 1 | static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f)
{
int64_t completed_sector_sum = 0;
BlkMigDevState *bmds;
int progress;
int ret = 0;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (bmds->bulk_completed == 0) {
if (mig_save_device_bulk(mon, f, bmds) == 1) {
/* completed bulk section for this device */
bmds->bulk_completed = 1;
}
completed_sector_sum += bmds->completed_sectors;
ret = 1;
break;
} else {
completed_sector_sum += bmds->completed_sectors;
}
}
progress = completed_sector_sum * 100 / block_mig_state.total_sector_sum;
if (progress != block_mig_state.prev_progress) {
block_mig_state.prev_progress = progress;
qemu_put_be64(f, (progress << BDRV_SECTOR_BITS)
| BLK_MIG_FLAG_PROGRESS);
monitor_printf(mon, "Completed %d %%\r", progress);
monitor_flush(mon);
}
return ret;
}
| 12,271 |
qemu | ce675a7579fea498397c5d2da3c5367671e9f02a | 1 | int net_init_tap(const NetClientOptions *opts, const char *name,
NetClientState *peer)
{
const NetdevTapOptions *tap;
int fd, vnet_hdr = 0, i = 0, queues;
/* for the no-fd, no-helper case */
const char *script = NULL; /* suppress wrong "uninit'd use" gcc warning */
const char *downscript = NULL;
const char *vhostfdname;
char ifname[128];
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_TAP);
tap = opts->tap;
queues = tap->has_queues ? tap->queues : 1;
vhostfdname = tap->has_vhostfd ? tap->vhostfd : NULL;
if (tap->has_fd) {
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
tap->has_vnet_hdr || tap->has_helper || tap->has_queues ||
tap->has_fds) {
error_report("ifname=, script=, downscript=, vnet_hdr=, "
"helper=, queues=, and fds= are invalid with fd=");
fd = monitor_handle_fd_param(cur_mon, tap->fd);
if (fd == -1) {
fcntl(fd, F_SETFL, O_NONBLOCK);
vnet_hdr = tap_probe_vnet_hdr(fd);
if (net_init_tap_one(tap, peer, "tap", name, NULL,
script, downscript,
vhostfdname, vnet_hdr, fd)) {
} else if (tap->has_fds) {
char *fds[MAX_TAP_QUEUES];
char *vhost_fds[MAX_TAP_QUEUES];
int nfds, nvhosts;
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
tap->has_vnet_hdr || tap->has_helper || tap->has_queues ||
tap->has_fd) {
error_report("ifname=, script=, downscript=, vnet_hdr=, "
"helper=, queues=, and fd= are invalid with fds=");
nfds = get_fds(tap->fds, fds, MAX_TAP_QUEUES);
if (tap->has_vhostfds) {
nvhosts = get_fds(tap->vhostfds, vhost_fds, MAX_TAP_QUEUES);
if (nfds != nvhosts) {
error_report("The number of fds passed does not match the "
"number of vhostfds passed");
for (i = 0; i < nfds; i++) {
fd = monitor_handle_fd_param(cur_mon, fds[i]);
if (fd == -1) {
fcntl(fd, F_SETFL, O_NONBLOCK);
if (i == 0) {
vnet_hdr = tap_probe_vnet_hdr(fd);
} else if (vnet_hdr != tap_probe_vnet_hdr(fd)) {
error_report("vnet_hdr not consistent across given tap fds");
if (net_init_tap_one(tap, peer, "tap", name, ifname,
script, downscript,
tap->has_vhostfds ? vhost_fds[i] : NULL,
vnet_hdr, fd)) {
} else if (tap->has_helper) {
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
tap->has_vnet_hdr || tap->has_queues || tap->has_fds) {
error_report("ifname=, script=, downscript=, and vnet_hdr= "
"queues=, and fds= are invalid with helper=");
fd = net_bridge_run_helper(tap->helper, DEFAULT_BRIDGE_INTERFACE);
if (fd == -1) {
fcntl(fd, F_SETFL, O_NONBLOCK);
vnet_hdr = tap_probe_vnet_hdr(fd);
if (net_init_tap_one(tap, peer, "bridge", name, ifname,
script, downscript, vhostfdname,
vnet_hdr, fd)) {
} else {
script = tap->has_script ? tap->script : DEFAULT_NETWORK_SCRIPT;
downscript = tap->has_downscript ? tap->downscript :
DEFAULT_NETWORK_DOWN_SCRIPT;
if (tap->has_ifname) {
pstrcpy(ifname, sizeof ifname, tap->ifname);
} else {
ifname[0] = '\0';
for (i = 0; i < queues; i++) {
fd = net_tap_init(tap, &vnet_hdr, i >= 1 ? "no" : script,
ifname, sizeof ifname, queues > 1);
if (fd == -1) {
if (queues > 1 && i == 0 && !tap->has_ifname) {
if (tap_fd_get_ifname(fd, ifname)) {
error_report("Fail to get ifname");
if (net_init_tap_one(tap, peer, "tap", name, ifname,
i >= 1 ? "no" : script,
i >= 1 ? "no" : downscript,
vhostfdname, vnet_hdr, fd)) {
return 0; | 12,272 |
FFmpeg | eae63e3c156f784ee0612422f0c95131ea913c14 | 1 | static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q,
uint8_t *properties)
{
int compno;
if (bytestream2_get_bytes_left(&s->g) < 1)
return AVERROR_INVALIDDATA;
compno = bytestream2_get_byteu(&s->g);
properties[compno] |= HAD_QCC;
return get_qcx(s, n - 1, q + compno);
}
| 12,274 |
qemu | e638073c569e801ce9def2016a84f955cbbca779 | 1 | static void vfio_pci_load_rom(VFIODevice *vdev)
{
struct vfio_region_info reg_info = {
.argsz = sizeof(reg_info),
.index = VFIO_PCI_ROM_REGION_INDEX
};
uint64_t size;
off_t off = 0;
size_t bytes;
if (ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) {
error_report("vfio: Error getting ROM info: %m");
return;
}
DPRINTF("Device %04x:%02x:%02x.%x ROM:\n", vdev->host.domain,
vdev->host.bus, vdev->host.slot, vdev->host.function);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->rom_size = size = reg_info.size;
vdev->rom_offset = reg_info.offset;
if (!vdev->rom_size) {
error_report("vfio-pci: Cannot read device rom at "
"%04x:%02x:%02x.%x\n",
vdev->host.domain, vdev->host.bus, vdev->host.slot,
vdev->host.function);
error_printf("Device option ROM contents are probably invalid "
"(check dmesg).\nSkip option ROM probe with rombar=0, "
"or load from file with romfile=\n");
return;
}
vdev->rom = g_malloc(size);
memset(vdev->rom, 0xff, size);
while (size) {
bytes = pread(vdev->fd, vdev->rom + off, size, vdev->rom_offset + off);
if (bytes == 0) {
break;
} else if (bytes > 0) {
off += bytes;
size -= bytes;
} else {
if (errno == EINTR || errno == EAGAIN) {
continue;
}
error_report("vfio: Error reading device ROM: %m");
break;
}
}
} | 12,275 |
qemu | e89720b116131938fe3d4931302f69a28249c934 | 1 | static void tcg_out_op (TCGContext *s, TCGOpcode opc, const TCGArg *args,
const int *const_args)
{
int c;
switch (opc) {
case INDEX_op_exit_tb:
tcg_out_movi (s, TCG_TYPE_I64, TCG_REG_R3, args[0]);
tcg_out_b (s, 0, (tcg_target_long) tb_ret_addr);
break;
case INDEX_op_goto_tb:
if (s->tb_jmp_offset) {
/* direct jump method */
s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
s->code_ptr += 28;
}
else {
tcg_abort ();
}
s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf;
break;
case INDEX_op_br:
{
TCGLabel *l = &s->labels[args[0]];
if (l->has_value) {
tcg_out_b (s, 0, l->u.value);
}
else {
uint32_t val = *(uint32_t *) s->code_ptr;
/* Thanks to Andrzej Zaborowski */
tcg_out32 (s, B | (val & 0x3fffffc));
tcg_out_reloc (s, s->code_ptr - 4, R_PPC_REL24, args[0], 0);
}
}
break;
case INDEX_op_call:
tcg_out_call (s, args[0], const_args[0]);
break;
case INDEX_op_jmp:
if (const_args[0]) {
tcg_out_b (s, 0, args[0]);
}
else {
tcg_out32 (s, MTSPR | RS (args[0]) | CTR);
tcg_out32 (s, BCCTR | BO_ALWAYS);
}
break;
case INDEX_op_movi_i32:
tcg_out_movi (s, TCG_TYPE_I32, args[0], args[1]);
break;
case INDEX_op_movi_i64:
tcg_out_movi (s, TCG_TYPE_I64, args[0], args[1]);
break;
case INDEX_op_ld8u_i32:
case INDEX_op_ld8u_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LBZ, LBZX);
break;
case INDEX_op_ld8s_i32:
case INDEX_op_ld8s_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LBZ, LBZX);
tcg_out32 (s, EXTSB | RS (args[0]) | RA (args[0]));
break;
case INDEX_op_ld16u_i32:
case INDEX_op_ld16u_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LHZ, LHZX);
break;
case INDEX_op_ld16s_i32:
case INDEX_op_ld16s_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LHA, LHAX);
break;
case INDEX_op_ld_i32:
case INDEX_op_ld32u_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LWZ, LWZX);
break;
case INDEX_op_ld32s_i64:
tcg_out_ldsta (s, args[0], args[1], args[2], LWA, LWAX);
break;
case INDEX_op_ld_i64:
tcg_out_ldsta (s, args[0], args[1], args[2], LD, LDX);
break;
case INDEX_op_st8_i32:
case INDEX_op_st8_i64:
tcg_out_ldst (s, args[0], args[1], args[2], STB, STBX);
break;
case INDEX_op_st16_i32:
case INDEX_op_st16_i64:
tcg_out_ldst (s, args[0], args[1], args[2], STH, STHX);
break;
case INDEX_op_st_i32:
case INDEX_op_st32_i64:
tcg_out_ldst (s, args[0], args[1], args[2], STW, STWX);
break;
case INDEX_op_st_i64:
tcg_out_ldsta (s, args[0], args[1], args[2], STD, STDX);
break;
case INDEX_op_add_i32:
if (const_args[2])
ppc_addi32 (s, args[0], args[1], args[2]);
else
tcg_out32 (s, ADD | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_sub_i32:
if (const_args[2])
ppc_addi32 (s, args[0], args[1], -args[2]);
else
tcg_out32 (s, SUBF | TAB (args[0], args[2], args[1]));
break;
case INDEX_op_and_i64:
case INDEX_op_and_i32:
if (const_args[2]) {
if ((args[2] & 0xffff) == args[2])
tcg_out32 (s, ANDI | RS (args[1]) | RA (args[0]) | args[2]);
else if ((args[2] & 0xffff0000) == args[2])
tcg_out32 (s, ANDIS | RS (args[1]) | RA (args[0])
| ((args[2] >> 16) & 0xffff));
else {
tcg_out_movi (s, (opc == INDEX_op_and_i32
? TCG_TYPE_I32
: TCG_TYPE_I64),
0, args[2]);
tcg_out32 (s, AND | SAB (args[1], args[0], 0));
}
}
else
tcg_out32 (s, AND | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_or_i64:
case INDEX_op_or_i32:
if (const_args[2]) {
if (args[2] & 0xffff) {
tcg_out32 (s, ORI | RS (args[1]) | RA (args[0])
| (args[2] & 0xffff));
if (args[2] >> 16)
tcg_out32 (s, ORIS | RS (args[0]) | RA (args[0])
| ((args[2] >> 16) & 0xffff));
}
else {
tcg_out32 (s, ORIS | RS (args[1]) | RA (args[0])
| ((args[2] >> 16) & 0xffff));
}
}
else
tcg_out32 (s, OR | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_xor_i64:
case INDEX_op_xor_i32:
if (const_args[2]) {
if ((args[2] & 0xffff) == args[2])
tcg_out32 (s, XORI | RS (args[1]) | RA (args[0])
| (args[2] & 0xffff));
else if ((args[2] & 0xffff0000) == args[2])
tcg_out32 (s, XORIS | RS (args[1]) | RA (args[0])
| ((args[2] >> 16) & 0xffff));
else {
tcg_out_movi (s, (opc == INDEX_op_and_i32
? TCG_TYPE_I32
: TCG_TYPE_I64),
0, args[2]);
tcg_out32 (s, XOR | SAB (args[1], args[0], 0));
}
}
else
tcg_out32 (s, XOR | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_mul_i32:
if (const_args[2]) {
if (args[2] == (int16_t) args[2])
tcg_out32 (s, MULLI | RT (args[0]) | RA (args[1])
| (args[2] & 0xffff));
else {
tcg_out_movi (s, TCG_TYPE_I32, 0, args[2]);
tcg_out32 (s, MULLW | TAB (args[0], args[1], 0));
}
}
else
tcg_out32 (s, MULLW | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_div_i32:
tcg_out32 (s, DIVW | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_divu_i32:
tcg_out32 (s, DIVWU | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_rem_i32:
tcg_out32 (s, DIVW | TAB (0, args[1], args[2]));
tcg_out32 (s, MULLW | TAB (0, 0, args[2]));
tcg_out32 (s, SUBF | TAB (args[0], 0, args[1]));
break;
case INDEX_op_remu_i32:
tcg_out32 (s, DIVWU | TAB (0, args[1], args[2]));
tcg_out32 (s, MULLW | TAB (0, 0, args[2]));
tcg_out32 (s, SUBF | TAB (args[0], 0, args[1]));
break;
case INDEX_op_shl_i32:
if (const_args[2]) {
tcg_out32 (s, (RLWINM
| RA (args[0])
| RS (args[1])
| SH (args[2])
| MB (0)
| ME (31 - args[2])
)
);
}
else
tcg_out32 (s, SLW | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_shr_i32:
if (const_args[2]) {
tcg_out32 (s, (RLWINM
| RA (args[0])
| RS (args[1])
| SH (32 - args[2])
| MB (args[2])
| ME (31)
)
);
}
else
tcg_out32 (s, SRW | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_sar_i32:
if (const_args[2])
tcg_out32 (s, SRAWI | RS (args[1]) | RA (args[0]) | SH (args[2]));
else
tcg_out32 (s, SRAW | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_brcond_i32:
tcg_out_brcond (s, args[2], args[0], args[1], const_args[1], args[3], 0);
break;
case INDEX_op_brcond_i64:
tcg_out_brcond (s, args[2], args[0], args[1], const_args[1], args[3], 1);
break;
case INDEX_op_neg_i32:
case INDEX_op_neg_i64:
tcg_out32 (s, NEG | RT (args[0]) | RA (args[1]));
break;
case INDEX_op_not_i32:
case INDEX_op_not_i64:
tcg_out32 (s, NOR | SAB (args[1], args[0], args[1]));
break;
case INDEX_op_add_i64:
if (const_args[2])
ppc_addi64 (s, args[0], args[1], args[2]);
else
tcg_out32 (s, ADD | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_sub_i64:
if (const_args[2])
ppc_addi64 (s, args[0], args[1], -args[2]);
else
tcg_out32 (s, SUBF | TAB (args[0], args[2], args[1]));
break;
case INDEX_op_shl_i64:
if (const_args[2])
tcg_out_rld (s, RLDICR, args[0], args[1], args[2], 63 - args[2]);
else
tcg_out32 (s, SLD | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_shr_i64:
if (const_args[2])
tcg_out_rld (s, RLDICL, args[0], args[1], 64 - args[2], args[2]);
else
tcg_out32 (s, SRD | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_sar_i64:
if (const_args[2]) {
int sh = SH (args[2] & 0x1f) | (((args[2] >> 5) & 1) << 1);
tcg_out32 (s, SRADI | RA (args[0]) | RS (args[1]) | sh);
}
else
tcg_out32 (s, SRAD | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_mul_i64:
tcg_out32 (s, MULLD | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_div_i64:
tcg_out32 (s, DIVD | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_divu_i64:
tcg_out32 (s, DIVDU | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_rem_i64:
tcg_out32 (s, DIVD | TAB (0, args[1], args[2]));
tcg_out32 (s, MULLD | TAB (0, 0, args[2]));
tcg_out32 (s, SUBF | TAB (args[0], 0, args[1]));
break;
case INDEX_op_remu_i64:
tcg_out32 (s, DIVDU | TAB (0, args[1], args[2]));
tcg_out32 (s, MULLD | TAB (0, 0, args[2]));
tcg_out32 (s, SUBF | TAB (args[0], 0, args[1]));
break;
case INDEX_op_qemu_ld8u:
tcg_out_qemu_ld (s, args, 0);
break;
case INDEX_op_qemu_ld8s:
tcg_out_qemu_ld (s, args, 0 | 4);
break;
case INDEX_op_qemu_ld16u:
tcg_out_qemu_ld (s, args, 1);
break;
case INDEX_op_qemu_ld16s:
tcg_out_qemu_ld (s, args, 1 | 4);
break;
case INDEX_op_qemu_ld32:
case INDEX_op_qemu_ld32u:
tcg_out_qemu_ld (s, args, 2);
break;
case INDEX_op_qemu_ld32s:
tcg_out_qemu_ld (s, args, 2 | 4);
break;
case INDEX_op_qemu_ld64:
tcg_out_qemu_ld (s, args, 3);
break;
case INDEX_op_qemu_st8:
tcg_out_qemu_st (s, args, 0);
break;
case INDEX_op_qemu_st16:
tcg_out_qemu_st (s, args, 1);
break;
case INDEX_op_qemu_st32:
tcg_out_qemu_st (s, args, 2);
break;
case INDEX_op_qemu_st64:
tcg_out_qemu_st (s, args, 3);
break;
case INDEX_op_ext8s_i32:
case INDEX_op_ext8s_i64:
c = EXTSB;
goto gen_ext;
case INDEX_op_ext16s_i32:
case INDEX_op_ext16s_i64:
c = EXTSH;
goto gen_ext;
case INDEX_op_ext32s_i64:
c = EXTSW;
goto gen_ext;
gen_ext:
tcg_out32 (s, c | RS (args[1]) | RA (args[0]));
break;
case INDEX_op_ext32u_i64:
tcg_out_rld (s, RLDICR, args[0], args[1], 0, 32);
break;
case INDEX_op_setcond_i32:
tcg_out_setcond (s, TCG_TYPE_I32, args[3], args[0], args[1], args[2],
const_args[2]);
break;
case INDEX_op_setcond_i64:
tcg_out_setcond (s, TCG_TYPE_I64, args[3], args[0], args[1], args[2],
const_args[2]);
break;
default:
tcg_dump_ops (s, stderr);
tcg_abort ();
}
}
| 12,276 |
qemu | b47b35250fbfa062aedf6ab6e5faab84c4a76f4f | 1 | static int fdctrl_init_common(FDCtrl *fdctrl)
{
int i, j;
static int command_tables_inited = 0;
/* Fill 'command_to_handler' lookup table */
if (!command_tables_inited) {
command_tables_inited = 1;
for (i = ARRAY_SIZE(handlers) - 1; i >= 0; i--) {
for (j = 0; j < sizeof(command_to_handler); j++) {
if ((j & handlers[i].mask) == handlers[i].value) {
command_to_handler[j] = i;
}
}
}
}
FLOPPY_DPRINTF("init controller\n");
fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
fdctrl->fifo_size = 512;
fdctrl->result_timer = qemu_new_timer(vm_clock,
fdctrl_result_timer, fdctrl);
fdctrl->version = 0x90; /* Intel 82078 controller */
fdctrl->config = FD_CONFIG_EIS | FD_CONFIG_EFIFO; /* Implicit seek, polling & FIFO enabled */
fdctrl->num_floppies = MAX_FD;
if (fdctrl->dma_chann != -1)
DMA_register_channel(fdctrl->dma_chann, &fdctrl_transfer_handler, fdctrl);
fdctrl_connect_drives(fdctrl);
return 0;
}
| 12,277 |
qemu | a1f0cce2ac0243572ff72aa561da67fe3766a395 | 1 | static int32_t scsi_send_command(SCSIRequest *req, uint8_t *cmd)
{
SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, req->dev);
SCSIGenericReq *r = DO_UPCAST(SCSIGenericReq, req, req);
int ret;
scsi_req_enqueue(req);
if (cmd[0] != REQUEST_SENSE &&
(req->lun != s->lun || (cmd[1] >> 5) != s->lun)) {
DPRINTF("Unimplemented LUN %d\n", req->lun ? req->lun : cmd[1] >> 5);
s->sensebuf[0] = 0x70;
s->sensebuf[1] = 0x00;
s->sensebuf[2] = ILLEGAL_REQUEST;
s->sensebuf[3] = 0x00;
s->sensebuf[4] = 0x00;
s->sensebuf[5] = 0x00;
s->sensebuf[6] = 0x00;
s->senselen = 7;
s->driver_status = SG_ERR_DRIVER_SENSE;
r->req.status = CHECK_CONDITION;
scsi_req_complete(&r->req);
return 0;
}
if (-1 == scsi_req_parse(&r->req, cmd)) {
BADF("Unsupported command length, command %x\n", cmd[0]);
scsi_req_dequeue(&r->req);
scsi_req_unref(&r->req);
return 0;
}
scsi_req_fixup(&r->req);
DPRINTF("Command: lun=%d tag=0x%x len %zd data=0x%02x", lun, tag,
r->req.cmd.xfer, cmd[0]);
#ifdef DEBUG_SCSI
{
int i;
for (i = 1; i < r->req.cmd.len; i++) {
printf(" 0x%02x", cmd[i]);
}
printf("\n");
}
#endif
if (r->req.cmd.xfer == 0) {
if (r->buf != NULL)
qemu_free(r->buf);
r->buflen = 0;
r->buf = NULL;
ret = execute_command(s->bs, r, SG_DXFER_NONE, scsi_command_complete);
if (ret == -1) {
scsi_command_complete(r, -EINVAL);
}
return 0;
}
if (r->buflen != r->req.cmd.xfer) {
if (r->buf != NULL)
qemu_free(r->buf);
r->buf = qemu_malloc(r->req.cmd.xfer);
r->buflen = r->req.cmd.xfer;
}
memset(r->buf, 0, r->buflen);
r->len = r->req.cmd.xfer;
if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
r->len = 0;
return -r->req.cmd.xfer;
} else {
return r->req.cmd.xfer;
}
}
| 12,279 |
qemu | bdd81addf4033ce26e6cd180b060f63095f3ded9 | 1 | static void vfio_probe_ati_bar2_quirk(VFIOPCIDevice *vdev, int nr)
{
VFIOQuirk *quirk;
VFIOConfigMirrorQuirk *mirror;
/* Only enable on newer devices where BAR2 is 64bit */
if (!vfio_pci_is(vdev, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||
!vdev->has_vga || nr != 2 || !vdev->bars[2].mem64) {
return;
}
quirk = g_malloc0(sizeof(*quirk));
mirror = quirk->data = g_malloc0(sizeof(*mirror));
mirror->mem = quirk->mem = g_malloc0(sizeof(MemoryRegion));
quirk->nr_mem = 1;
mirror->vdev = vdev;
mirror->offset = 0x4000;
mirror->bar = nr;
memory_region_init_io(mirror->mem, OBJECT(vdev),
&vfio_generic_mirror_quirk, mirror,
"vfio-ati-bar2-4000-quirk", PCI_CONFIG_SPACE_SIZE);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
mirror->offset, mirror->mem, 1);
QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);
trace_vfio_quirk_ati_bar2_probe(vdev->vbasedev.name);
}
| 12,280 |
FFmpeg | 5e1bf9d8c0d2cdbbf17b06a5dfdf87a635b3203b | 1 | static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
{
pkt->data = NULL;
pkt->side_data = NULL;
if (pkt->buf) {
AVBufferRef *ref = av_buffer_ref(src->buf);
if (!ref)
return AVERROR(ENOMEM);
pkt->buf = ref;
pkt->data = ref->data;
} else {
DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
}
if (pkt->side_data_elems && dup)
pkt->side_data = src->side_data;
if (pkt->side_data_elems && !dup) {
return av_copy_packet_side_data(pkt, src);
}
return 0;
failed_alloc:
av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
| 12,282 |
FFmpeg | 928cfc7e4f42aa283bb1bd9a50f0b3caa5a0f7a5 | 1 | static void ffm_seek1(AVFormatContext *s, int64_t pos1)
{
FFMContext *ffm = s->priv_data;
AVIOContext *pb = s->pb;
int64_t pos;
pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE);
pos = FFMAX(pos, FFM_PACKET_SIZE);
av_dlog(s, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
avio_seek(pb, pos, SEEK_SET);
}
| 12,283 |
FFmpeg | b92b4775a0d07cacfdd2b4be6511f3cb362c977b | 1 | int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
{
int list, index, pic_structure;
print_short_term(h);
print_long_term(h);
h264_initialise_ref_list(h, sl);
for (list = 0; list < sl->list_count; list++) {
if (get_bits1(&sl->gb)) { // ref_pic_list_modification_flag_l[01]
int pred = h->curr_pic_num;
for (index = 0; ; index++) {
unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&sl->gb);
unsigned int pic_id;
int i;
H264Picture *ref = NULL;
if (modification_of_pic_nums_idc == 3)
break;
if (index >= sl->ref_count[list]) {
av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n");
return -1;
}
switch (modification_of_pic_nums_idc) {
case 0:
case 1: {
const unsigned int abs_diff_pic_num = get_ue_golomb(&sl->gb) + 1;
int frame_num;
if (abs_diff_pic_num > h->max_pic_num) {
av_log(h->avctx, AV_LOG_ERROR,
"abs_diff_pic_num overflow\n");
return AVERROR_INVALIDDATA;
}
if (modification_of_pic_nums_idc == 0)
pred -= abs_diff_pic_num;
else
pred += abs_diff_pic_num;
pred &= h->max_pic_num - 1;
frame_num = pic_num_extract(h, pred, &pic_structure);
for (i = h->short_ref_count - 1; i >= 0; i--) {
ref = h->short_ref[i];
assert(ref->reference);
assert(!ref->long_ref);
if (ref->frame_num == frame_num &&
(ref->reference & pic_structure))
break;
}
if (i >= 0)
ref->pic_id = pred;
break;
}
case 2: {
int long_idx;
pic_id = get_ue_golomb(&sl->gb); // long_term_pic_idx
long_idx = pic_num_extract(h, pic_id, &pic_structure);
if (long_idx > 31) {
av_log(h->avctx, AV_LOG_ERROR,
"long_term_pic_idx overflow\n");
return AVERROR_INVALIDDATA;
}
ref = h->long_ref[long_idx];
assert(!(ref && !ref->reference));
if (ref && (ref->reference & pic_structure) && !mismatches_ref(h, ref)) {
ref->pic_id = pic_id;
assert(ref->long_ref);
i = 0;
} else {
i = -1;
}
break;
}
default:
av_log(h->avctx, AV_LOG_ERROR,
"illegal modification_of_pic_nums_idc %u\n",
modification_of_pic_nums_idc);
return AVERROR_INVALIDDATA;
}
if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"reference picture missing during reorder\n");
memset(&sl->ref_list[list][index], 0, sizeof(sl->ref_list[0][0])); // FIXME
} else {
for (i = index; i + 1 < sl->ref_count[list]; i++) {
if (sl->ref_list[list][i].parent &&
ref->long_ref == sl->ref_list[list][i].parent->long_ref &&
ref->pic_id == sl->ref_list[list][i].pic_id)
break;
}
for (; i > index; i--) {
sl->ref_list[list][i] = sl->ref_list[list][i - 1];
}
ref_from_h264pic(&sl->ref_list[list][index], ref);
if (FIELD_PICTURE(h)) {
pic_as_field(&sl->ref_list[list][index], pic_structure);
}
}
}
}
}
for (list = 0; list < sl->list_count; list++) {
for (index = 0; index < sl->ref_count[list]; index++) {
if ( !sl->ref_list[list][index].parent
|| (!FIELD_PICTURE(h) && (sl->ref_list[list][index].reference&3) != 3)) {
int i;
av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture\n");
for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
return -1;
}
av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].parent->f->buf[0]) > 0);
}
}
return 0;
}
| 12,284 |
FFmpeg | 2bd8eb05d21b582d627a93852b59cb3cfc305dae | 1 | static inline void dxt5_block_internal(uint8_t *dst, ptrdiff_t stride,
const uint8_t *block)
{
int x, y;
uint32_t colors[4];
uint8_t alpha_indices[16];
uint16_t color0 = AV_RL16(block + 8);
uint16_t color1 = AV_RL16(block + 10);
uint32_t code = AV_RL32(block + 12);
uint8_t alpha0 = *(block);
uint8_t alpha1 = *(block + 1);
decompress_indices(alpha_indices, block + 2);
extract_color(colors, color0, color1, 1, 0);
for (y = 0; y < 4; y++) {
for (x = 0; x < 4; x++) {
int alpha_code = alpha_indices[x + y * 4];
uint32_t pixel;
uint8_t alpha;
if (alpha_code == 0) {
alpha = alpha0;
} else if (alpha_code == 1) {
alpha = alpha1;
} else {
if (alpha0 > alpha1) {
alpha = (uint8_t) (((8 - alpha_code) * alpha0 +
(alpha_code - 1) * alpha1) / 7);
} else {
if (alpha_code == 6) {
alpha = 0;
} else if (alpha_code == 7) {
alpha = 255;
} else {
alpha = (uint8_t) (((6 - alpha_code) * alpha0 +
(alpha_code - 1) * alpha1) / 5);
}
}
}
pixel = colors[code & 3] | (alpha << 24);
code >>= 2;
AV_WL32(dst + x * 4, pixel);
}
dst += stride;
}
}
| 12,285 |
qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | 1 | void OPPROTO op_POWER_sre (void)
{
T1 &= 0x1FUL;
env->spr[SPR_MQ] = rotl32(T0, 32 - T1);
T0 = Ts0 >> T1;
RETURN();
}
| 12,286 |
FFmpeg | 631f7484918a9e7260377c3cea878be708609e64 | 1 | static int h263_decode_block(MpegEncContext * s, int16_t * block,
int n, int coded)
{
int level, i, j, run;
RLTable *rl = &ff_h263_rl_inter;
const uint8_t *scan_table;
GetBitContext gb= s->gb;
scan_table = s->intra_scantable.permutated;
if (s->h263_aic && s->mb_intra) {
rl = &ff_rl_intra_aic;
i = 0;
if (s->ac_pred) {
if (s->h263_aic_dir)
scan_table = s->intra_v_scantable.permutated; /* left */
else
scan_table = s->intra_h_scantable.permutated; /* top */
}
} else if (s->mb_intra) {
/* DC coef */
if (CONFIG_RV10_DECODER && s->codec_id == AV_CODEC_ID_RV10) {
if (s->rv10_version == 3 && s->pict_type == AV_PICTURE_TYPE_I) {
int component, diff;
component = (n <= 3 ? 0 : n - 4 + 1);
level = s->last_dc[component];
if (s->rv10_first_dc_coded[component]) {
diff = ff_rv_decode_dc(s, n);
if (diff == 0xffff)
return -1;
level += diff;
level = level & 0xff; /* handle wrap round */
s->last_dc[component] = level;
} else {
s->rv10_first_dc_coded[component] = 1;
}
} else {
level = get_bits(&s->gb, 8);
if (level == 255)
level = 128;
}
}else{
level = get_bits(&s->gb, 8);
if((level&0x7F) == 0){
av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y);
if (s->avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT))
return -1;
}
if (level == 255)
level = 128;
}
block[0] = level;
i = 1;
} else {
i = 0;
}
if (!coded) {
if (s->mb_intra && s->h263_aic)
goto not_coded;
s->block_last_index[n] = i - 1;
return 0;
}
retry:
{
OPEN_READER(re, &s->gb);
i--; // offset by -1 to allow direct indexing of scan_table
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (run == 66) {
if (level){
CLOSE_READER(re, &s->gb);
av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y);
return -1;
}
/* escape */
if (CONFIG_FLV_DECODER && s->h263_flv > 1) {
int is11 = SHOW_UBITS(re, &s->gb, 1);
SKIP_CACHE(re, &s->gb, 1);
run = SHOW_UBITS(re, &s->gb, 7) + 1;
if (is11) {
SKIP_COUNTER(re, &s->gb, 1 + 7);
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 11);
SKIP_COUNTER(re, &s->gb, 11);
} else {
SKIP_CACHE(re, &s->gb, 7);
level = SHOW_SBITS(re, &s->gb, 7);
SKIP_COUNTER(re, &s->gb, 1 + 7 + 7);
}
} else {
run = SHOW_UBITS(re, &s->gb, 7) + 1;
SKIP_CACHE(re, &s->gb, 7);
level = (int8_t)SHOW_UBITS(re, &s->gb, 8);
SKIP_COUNTER(re, &s->gb, 7 + 8);
if(level == -128){
UPDATE_CACHE(re, &s->gb);
if (s->codec_id == AV_CODEC_ID_RV10) {
/* XXX: should patch encoder too */
level = SHOW_SBITS(re, &s->gb, 12);
SKIP_COUNTER(re, &s->gb, 12);
}else{
level = SHOW_UBITS(re, &s->gb, 5);
SKIP_CACHE(re, &s->gb, 5);
level |= SHOW_SBITS(re, &s->gb, 6)<<5;
SKIP_COUNTER(re, &s->gb, 5 + 6);
}
}
}
} else {
if (SHOW_UBITS(re, &s->gb, 1))
level = -level;
SKIP_COUNTER(re, &s->gb, 1);
}
i += run;
if (i >= 64){
CLOSE_READER(re, &s->gb);
// redo update without last flag, revert -1 offset
i = i - run + ((run-1)&63) + 1;
if (i < 64) {
// only last marker, no overrun
block[scan_table[i]] = level;
break;
}
if(s->alt_inter_vlc && rl == &ff_h263_rl_inter && !s->mb_intra){
//Looks like a hack but no, it's the way it is supposed to work ...
rl = &ff_rl_intra_aic;
i = 0;
s->gb= gb;
s->bdsp.clear_block(block);
goto retry;
}
av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d i:%d\n", s->mb_x, s->mb_y, s->mb_intra);
return -1;
}
j = scan_table[i];
block[j] = level;
}
}
not_coded:
if (s->mb_intra && s->h263_aic) {
ff_h263_pred_acdc(s, block, n);
i = 63;
}
s->block_last_index[n] = i;
return 0;
}
| 12,287 |
qemu | 5839e53bbc0fec56021d758aab7610df421ed8c8 | 1 | void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason)
{
BdrvOpBlocker *blocker;
assert((int) op >= 0 && op < BLOCK_OP_TYPE_MAX);
blocker = g_malloc0(sizeof(BdrvOpBlocker));
blocker->reason = reason;
QLIST_INSERT_HEAD(&bs->op_blockers[op], blocker, list);
}
| 12,288 |
qemu | 79218be42b835cbc7bd1b0fbd07d115add6e7605 | 1 | TraceEvent *trace_event_iter_next(TraceEventIter *iter)
{
while (iter->event < TRACE_EVENT_COUNT) {
TraceEvent *ev = &(trace_events[iter->event]);
iter->event++;
if (!iter->pattern ||
pattern_glob(iter->pattern,
trace_event_get_name(ev))) {
return ev;
}
}
return NULL;
}
| 12,289 |
FFmpeg | 8db2935db0caa8efbef009994920ef6a20289496 | 1 | static av_cold int ape_decode_init(AVCodecContext *avctx)
{
APEContext *s = avctx->priv_data;
int i;
if (avctx->extradata_size != 6) {
av_log(avctx, AV_LOG_ERROR, "Incorrect extradata\n");
return AVERROR(EINVAL);
}
if (avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "Only mono and stereo is supported\n");
return AVERROR(EINVAL);
}
s->bps = avctx->bits_per_coded_sample;
switch (s->bps) {
case 8:
avctx->sample_fmt = AV_SAMPLE_FMT_U8;
break;
case 16:
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
break;
case 24:
avctx->sample_fmt = AV_SAMPLE_FMT_S32;
break;
default:
av_log_ask_for_sample(avctx, "Unsupported bits per coded sample %d\n",
s->bps);
return AVERROR_PATCHWELCOME;
}
s->avctx = avctx;
s->channels = avctx->channels;
s->fileversion = AV_RL16(avctx->extradata);
s->compression_level = AV_RL16(avctx->extradata + 2);
s->flags = AV_RL16(avctx->extradata + 4);
av_log(avctx, AV_LOG_DEBUG, "Compression Level: %d - Flags: %d\n",
s->compression_level, s->flags);
if (s->compression_level % 1000 || s->compression_level > COMPRESSION_LEVEL_INSANE) {
av_log(avctx, AV_LOG_ERROR, "Incorrect compression level %d\n",
s->compression_level);
return AVERROR_INVALIDDATA;
}
s->fset = s->compression_level / 1000 - 1;
for (i = 0; i < APE_FILTER_LEVELS; i++) {
if (!ape_filter_orders[s->fset][i])
break;
FF_ALLOC_OR_GOTO(avctx, s->filterbuf[i],
(ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4,
filter_alloc_fail);
}
ff_dsputil_init(&s->dsp, avctx);
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
return 0;
filter_alloc_fail:
ape_decode_close(avctx);
return AVERROR(ENOMEM);
}
| 12,290 |
FFmpeg | 1693336aed3988e0c13ad1ff880257d80d6ae69d | 1 | static double lfo_get_value(SimpleLFO *lfo)
{
double phs = FFMIN(100, lfo->phase / FFMIN(1.99, FFMAX(0.01, lfo->pwidth)) + lfo->offset);
double val;
if (phs > 1)
phs = fmod(phs, 1.);
switch (lfo->mode) {
case SINE:
val = sin(phs * 2 * M_PI);
break;
case TRIANGLE:
if (phs > 0.75)
val = (phs - 0.75) * 4 - 1;
else if (phs > 0.25)
val = -4 * phs + 2;
else
val = phs * 4;
break;
case SQUARE:
val = phs < 0.5 ? -1 : +1;
break;
case SAWUP:
val = phs * 2 - 1;
break;
case SAWDOWN:
val = 1 - phs * 2;
break;
}
return val * lfo->amount;
} | 12,291 |
FFmpeg | 90fc00a623de44e137fe1601b91356e8cd8bdd54 | 1 | static int srt_get_duration(uint8_t **buf)
{
int i, duration = 0;
for (i=0; i<2 && !duration; i++) {
int s_hour, s_min, s_sec, s_hsec, e_hour, e_min, e_sec, e_hsec;
if (sscanf(*buf, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d",
&s_hour, &s_min, &s_sec, &s_hsec,
&e_hour, &e_min, &e_sec, &e_hsec) == 8) {
s_min += 60*s_hour; e_min += 60*e_hour;
s_sec += 60*s_min; e_sec += 60*e_min;
s_hsec += 1000*s_sec; e_hsec += 1000*e_sec;
duration = e_hsec - s_hsec;
}
*buf += strcspn(*buf, "\n") + 1;
}
return duration;
}
| 12,292 |
FFmpeg | c8241e730f116f1c9cfc0b34110aa7f052e05332 | 0 | static int vaapi_encode_mjpeg_init_picture_params(AVCodecContext *avctx,
VAAPIEncodePicture *pic)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAEncPictureParameterBufferJPEG *vpic = pic->codec_picture_params;
VAAPIEncodeMJPEGContext *priv = ctx->priv_data;
vpic->reconstructed_picture = pic->recon_surface;
vpic->coded_buf = pic->output_buffer;
vpic->picture_width = ctx->input_width;
vpic->picture_height = ctx->input_height;
vpic->pic_flags.bits.profile = 0;
vpic->pic_flags.bits.progressive = 0;
vpic->pic_flags.bits.huffman = 1;
vpic->pic_flags.bits.interleaved = 0;
vpic->pic_flags.bits.differential = 0;
vpic->sample_bit_depth = 8;
vpic->num_scan = 1;
vpic->num_components = 3;
vpic->component_id[0] = 1;
vpic->component_id[1] = 2;
vpic->component_id[2] = 3;
priv->component_subsample_h[0] = 2;
priv->component_subsample_v[0] = 2;
priv->component_subsample_h[1] = 1;
priv->component_subsample_v[1] = 1;
priv->component_subsample_h[2] = 1;
priv->component_subsample_v[2] = 1;
vpic->quantiser_table_selector[0] = 0;
vpic->quantiser_table_selector[1] = 1;
vpic->quantiser_table_selector[2] = 1;
vpic->quality = priv->quality;
pic->nb_slices = 1;
return 0;
}
| 12,293 |
FFmpeg | d574e22659bd51cdf16723a204fef65a9e783f1d | 0 | static int hdcd_scan(HDCDContext *ctx, hdcd_state_t *state, const int32_t *samples, int max, int stride)
{
int cdt_active = 0;
/* code detect timer */
int result;
if (state->sustain > 0) {
cdt_active = 1;
if (state->sustain <= max) {
state->control = 0;
max = state->sustain;
}
state->sustain -= max;
}
result = 0;
while (result < max) {
int flag;
int consumed = hdcd_integrate(ctx, state, &flag, samples, max - result, stride);
result += consumed;
if (flag > 0) {
/* reset timer if code detected in channel */
hdcd_sustain_reset(state);
break;
}
samples += consumed * stride;
}
/* code detect timer expired */
if (cdt_active && state->sustain == 0)
state->count_sustain_expired++;
return result;
}
| 12,294 |
FFmpeg | d3e18ad02795f9761b7e5a5c018dfef786046acf | 0 | static int swf_write_audio(AVFormatContext *s,
AVCodecContext *enc, const uint8_t *buf, int size)
{
SWFContext *swf = s->priv_data;
int c = 0;
/* Flash Player limit */
if ( swf->swf_frame_number >= 16000 ) {
return 0;
}
if (enc->codec_id == CODEC_ID_MP3 ) {
for (c=0; c<size; c++) {
swf->audio_fifo[(swf->audio_out_pos+c)%AUDIO_FIFO_SIZE] = buf[c];
}
swf->audio_size += size;
swf->audio_out_pos += size;
swf->audio_out_pos %= AUDIO_FIFO_SIZE;
}
/* if audio only stream make sure we add swf frames */
if ( swf->video_type == 0 ) {
swf_write_video(s, enc, 0, 0);
}
return 0;
}
| 12,295 |
FFmpeg | de1b1a7da9e6ddf42447271e519099a88b389e4a | 0 | static int64_t mp3_sync(AVFormatContext *s, int64_t target_pos, int flags)
{
int dir = (flags&AVSEEK_FLAG_BACKWARD) ? -1 : 1;
int64_t best_pos;
int best_score, i, j;
int64_t ret;
avio_seek(s->pb, FFMAX(target_pos - SEEK_WINDOW, 0), SEEK_SET);
ret = avio_seek(s->pb, target_pos, SEEK_SET);
if (ret < 0)
return ret;
#define MIN_VALID 3
best_pos = target_pos;
best_score = 999;
for(i=0; i<SEEK_WINDOW; i++) {
int64_t pos = target_pos + (dir > 0 ? i - SEEK_WINDOW/4 : -i);
int64_t candidate = -1;
int score = 999;
if (pos < 0)
continue;
for(j=0; j<MIN_VALID; j++) {
ret = check(s->pb, pos);
if(ret < 0)
break;
if ((target_pos - pos)*dir <= 0 && abs(MIN_VALID/2-j) < score) {
candidate = pos;
score = abs(MIN_VALID/2-j);
}
pos += ret;
}
if (best_score > score && j == MIN_VALID) {
best_pos = candidate;
best_score = score;
if(score == 0)
break;
}
}
return avio_seek(s->pb, best_pos, SEEK_SET);
}
| 12,296 |
qemu | 541dc0d47f10973c241e9955afc2aefc96adec51 | 0 | void test_segs(void)
{
struct modify_ldt_ldt_s ldt;
long long ldt_table[3];
int res, res2;
char tmp;
struct {
uint32_t offset;
uint16_t seg;
} __attribute__((packed)) segoff;
ldt.entry_number = 1;
ldt.base_addr = (unsigned long)&seg_data1;
ldt.limit = (sizeof(seg_data1) + 0xfff) >> 12;
ldt.seg_32bit = 1;
ldt.contents = MODIFY_LDT_CONTENTS_DATA;
ldt.read_exec_only = 0;
ldt.limit_in_pages = 1;
ldt.seg_not_present = 0;
ldt.useable = 1;
modify_ldt(1, &ldt, sizeof(ldt)); /* write ldt entry */
ldt.entry_number = 2;
ldt.base_addr = (unsigned long)&seg_data2;
ldt.limit = (sizeof(seg_data2) + 0xfff) >> 12;
ldt.seg_32bit = 1;
ldt.contents = MODIFY_LDT_CONTENTS_DATA;
ldt.read_exec_only = 0;
ldt.limit_in_pages = 1;
ldt.seg_not_present = 0;
ldt.useable = 1;
modify_ldt(1, &ldt, sizeof(ldt)); /* write ldt entry */
modify_ldt(0, &ldt_table, sizeof(ldt_table)); /* read ldt entries */
#if 0
{
int i;
for(i=0;i<3;i++)
printf("%d: %016Lx\n", i, ldt_table[i]);
}
#endif
/* do some tests with fs or gs */
asm volatile ("movl %0, %%fs" : : "r" (MK_SEL(1)));
seg_data1[1] = 0xaa;
seg_data2[1] = 0x55;
asm volatile ("fs movzbl 0x1, %0" : "=r" (res));
printf("FS[1] = %02x\n", res);
asm volatile ("pushl %%gs\n"
"movl %1, %%gs\n"
"gs movzbl 0x1, %0\n"
"popl %%gs\n"
: "=r" (res)
: "r" (MK_SEL(2)));
printf("GS[1] = %02x\n", res);
/* tests with ds/ss (implicit segment case) */
tmp = 0xa5;
asm volatile ("pushl %%ebp\n\t"
"pushl %%ds\n\t"
"movl %2, %%ds\n\t"
"movl %3, %%ebp\n\t"
"movzbl 0x1, %0\n\t"
"movzbl (%%ebp), %1\n\t"
"popl %%ds\n\t"
"popl %%ebp\n\t"
: "=r" (res), "=r" (res2)
: "r" (MK_SEL(1)), "r" (&tmp));
printf("DS[1] = %02x\n", res);
printf("SS[tmp] = %02x\n", res2);
segoff.seg = MK_SEL(2);
segoff.offset = 0xabcdef12;
asm volatile("lfs %2, %0\n\t"
"movl %%fs, %1\n\t"
: "=r" (res), "=g" (res2)
: "m" (segoff));
printf("FS:reg = %04x:%08x\n", res2, res);
TEST_LR("larw", "w", MK_SEL(2), 0x0100);
TEST_LR("larl", "", MK_SEL(2), 0x0100);
TEST_LR("lslw", "w", MK_SEL(2), 0);
TEST_LR("lsll", "", MK_SEL(2), 0);
TEST_LR("larw", "w", 0xfff8, 0);
TEST_LR("larl", "", 0xfff8, 0);
TEST_LR("lslw", "w", 0xfff8, 0);
TEST_LR("lsll", "", 0xfff8, 0);
TEST_ARPL("arpl", "w", 0x12345678 | 3, 0x762123c | 1);
TEST_ARPL("arpl", "w", 0x12345678 | 1, 0x762123c | 3);
TEST_ARPL("arpl", "w", 0x12345678 | 1, 0x762123c | 1);
}
| 12,297 |
qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | 0 | static void cpu_notify_map_clients(void)
{
MapClient *client;
while (!LIST_EMPTY(&map_client_list)) {
client = LIST_FIRST(&map_client_list);
client->callback(client->opaque);
cpu_unregister_map_client(client);
}
}
| 12,299 |
qemu | 1687a089f103f9b7a1b4a1555068054cb46ee9e9 | 0 | vcard_free(VCard *vcard)
{
VCardApplet *current_applet = NULL;
VCardApplet *next_applet = NULL;
if (vcard == NULL) {
return;
}
vcard->reference_count--;
if (vcard->reference_count != 0) {
return;
}
if (vcard->vcard_private_free) {
(*vcard->vcard_private_free)(vcard->vcard_private);
vcard->vcard_private_free = 0;
vcard->vcard_private = 0;
}
for (current_applet = vcard->applet_list; current_applet;
current_applet = next_applet) {
next_applet = current_applet->next;
vcard_delete_applet(current_applet);
}
vcard_buffer_response_delete(vcard->vcard_buffer_response);
g_free(vcard);
}
| 12,300 |
qemu | 36778660d7fd0748a6129916e47ecedd67bdb758 | 0 | static inline bool valid_ptex(PowerPCCPU *cpu, target_ulong ptex)
{
/*
* hash value/pteg group index is normalized by htab_mask
*/
if (((ptex & ~7ULL) / HPTES_PER_GROUP) & ~cpu->env.htab_mask) {
return false;
}
return true;
}
| 12,301 |
qemu | cd42d5b23691ad73edfd6dbcfc935a960a9c5a65 | 0 | gen_intermediate_code_internal(SuperHCPU *cpu, TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUSH4State *env = &cpu->env;
DisasContext ctx;
target_ulong pc_start;
static uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int i, ii;
int num_insns;
int max_insns;
pc_start = tb->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.pc = pc_start;
ctx.flags = (uint32_t)tb->flags;
ctx.bstate = BS_NONE;
ctx.memidx = (ctx.flags & SR_MD) == 0 ? 1 : 0;
/* We don't know if the delayed pc came from a dynamic or static branch,
so assume it is a dynamic branch. */
ctx.delayed_pc = -1; /* use delayed pc from env pointer */
ctx.tb = tb;
ctx.singlestep_enabled = cs->singlestep_enabled;
ctx.features = env->features;
ctx.has_movcal = (ctx.flags & TB_FLAG_PENDING_MOVCA);
ii = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_tb_start();
while (ctx.bstate == BS_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end) {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (ctx.pc == bp->pc) {
/* We have hit a breakpoint - make sure PC is up-to-date */
tcg_gen_movi_i32(cpu_pc, ctx.pc);
gen_helper_debug(cpu_env);
ctx.bstate = BS_BRANCH;
break;
}
}
}
if (search_pc) {
i = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (ii < i) {
ii++;
while (ii < i)
tcg_ctx.gen_opc_instr_start[ii++] = 0;
}
tcg_ctx.gen_opc_pc[ii] = ctx.pc;
gen_opc_hflags[ii] = ctx.flags;
tcg_ctx.gen_opc_instr_start[ii] = 1;
tcg_ctx.gen_opc_icount[ii] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
#if 0
fprintf(stderr, "Loading opcode at address 0x%08x\n", ctx.pc);
fflush(stderr);
#endif
ctx.opcode = cpu_lduw_code(env, ctx.pc);
decode_opc(&ctx);
num_insns++;
ctx.pc += 2;
if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)
break;
if (cs->singlestep_enabled) {
break;
}
if (num_insns >= max_insns)
break;
if (singlestep)
break;
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (cs->singlestep_enabled) {
tcg_gen_movi_i32(cpu_pc, ctx.pc);
gen_helper_debug(cpu_env);
} else {
switch (ctx.bstate) {
case BS_STOP:
/* gen_op_interrupt_restart(); */
/* fall through */
case BS_NONE:
if (ctx.flags) {
gen_store_flags(ctx.flags | DELAY_SLOT_CLEARME);
}
gen_goto_tb(&ctx, 0, ctx.pc);
break;
case BS_EXCP:
/* gen_op_interrupt_restart(); */
tcg_gen_exit_tb(0);
break;
case BS_BRANCH:
default:
break;
}
}
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
i = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
ii++;
while (ii <= i)
tcg_ctx.gen_opc_instr_start[ii++] = 0;
} else {
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
}
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("IN:\n"); /* , lookup_symbol(pc_start)); */
log_target_disas(env, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
}
#endif
}
| 12,302 |
qemu | e389be1673052b538534643165111725a79e5afd | 0 | static uint32_t get_level1_table_address(CPUARMState *env, uint32_t address)
{
uint32_t table;
if (address & env->cp15.c2_mask)
table = env->cp15.ttbr1_el1 & 0xffffc000;
else
table = env->cp15.ttbr0_el1 & env->cp15.c2_base_mask;
table |= (address >> 18) & 0x3ffc;
return table;
}
| 12,303 |
qemu | c650c008e326f3a1e84083bc269265456057a212 | 0 | static int do_setcontext(struct target_ucontext *ucp, CPUPPCState *env, int sig)
{
struct target_mcontext *mcp;
target_ulong mcp_addr;
sigset_t blocked;
target_sigset_t set;
if (copy_from_user(&set, h2g(ucp) + offsetof(struct target_ucontext, tuc_sigmask),
sizeof (set)))
return 1;
#if defined(TARGET_PPC64)
fprintf (stderr, "do_setcontext: not implemented\n");
return 0;
#else
if (__get_user(mcp_addr, &ucp->tuc_regs))
return 1;
if (!lock_user_struct(VERIFY_READ, mcp, mcp_addr, 1))
return 1;
target_to_host_sigset_internal(&blocked, &set);
do_sigprocmask(SIG_SETMASK, &blocked, NULL);
if (restore_user_regs(env, mcp, sig))
goto sigsegv;
unlock_user_struct(mcp, mcp_addr, 1);
return 0;
sigsegv:
unlock_user_struct(mcp, mcp_addr, 1);
return 1;
#endif
}
| 12,304 |
qemu | d42cf28837801cd1f835089fe9db2a42a1af55cd | 0 | static void bdrv_co_drain_bh_cb(void *opaque)
{
BdrvCoDrainData *data = opaque;
Coroutine *co = data->co;
BlockDriverState *bs = data->bs;
bdrv_dec_in_flight(bs);
bdrv_drain_poll(bs);
data->done = true;
qemu_coroutine_enter(co);
}
| 12,306 |
qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | 0 | QEMUTimerList *timerlist_new(QEMUClockType type,
QEMUTimerListNotifyCB *cb,
void *opaque)
{
QEMUTimerList *timer_list;
QEMUClock *clock = qemu_clock_ptr(type);
timer_list = g_malloc0(sizeof(QEMUTimerList));
qemu_event_init(&timer_list->timers_done_ev, true);
timer_list->clock = clock;
timer_list->notify_cb = cb;
timer_list->notify_opaque = opaque;
qemu_mutex_init(&timer_list->active_timers_lock);
QLIST_INSERT_HEAD(&clock->timerlists, timer_list, list);
return timer_list;
}
| 12,309 |
qemu | a7be9bad33d81d4bab2a51935b5443d258e7d082 | 0 | void cpu_check_irqs(CPUSPARCState *env)
{
uint32_t pil = env->pil_in |
(env->softint & ~(SOFTINT_TIMER | SOFTINT_STIMER));
/* check if TM or SM in SOFTINT are set
setting these also causes interrupt 14 */
if (env->softint & (SOFTINT_TIMER | SOFTINT_STIMER)) {
pil |= 1 << 14;
}
/* The bit corresponding to psrpil is (1<< psrpil), the next bit
is (2 << psrpil). */
if (pil < (2 << env->psrpil)){
if (env->interrupt_request & CPU_INTERRUPT_HARD) {
CPUIRQ_DPRINTF("Reset CPU IRQ (current interrupt %x)\n",
env->interrupt_index);
env->interrupt_index = 0;
cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
}
return;
}
if (cpu_interrupts_enabled(env)) {
unsigned int i;
for (i = 15; i > env->psrpil; i--) {
if (pil & (1 << i)) {
int old_interrupt = env->interrupt_index;
int new_interrupt = TT_EXTINT | i;
if (env->tl > 0 && cpu_tsptr(env)->tt > new_interrupt) {
CPUIRQ_DPRINTF("Not setting CPU IRQ: TL=%d "
"current %x >= pending %x\n",
env->tl, cpu_tsptr(env)->tt, new_interrupt);
} else if (old_interrupt != new_interrupt) {
env->interrupt_index = new_interrupt;
CPUIRQ_DPRINTF("Set CPU IRQ %d old=%x new=%x\n", i,
old_interrupt, new_interrupt);
cpu_interrupt(env, CPU_INTERRUPT_HARD);
}
break;
}
}
} else if (env->interrupt_request & CPU_INTERRUPT_HARD) {
CPUIRQ_DPRINTF("Interrupts disabled, pil=%08x pil_in=%08x softint=%08x "
"current interrupt %x\n",
pil, env->pil_in, env->softint, env->interrupt_index);
env->interrupt_index = 0;
cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
}
}
| 12,311 |
qemu | 0ab07c623c629acfbc792e5a174129c19faefbb7 | 0 | static void *qemu_kvm_cpu_thread_fn(void *arg)
{
CPUState *env = arg;
int r;
qemu_mutex_lock(&qemu_global_mutex);
qemu_thread_self(env->thread);
r = kvm_init_vcpu(env);
if (r < 0) {
fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r));
exit(1);
}
qemu_kvm_init_cpu_signals(env);
/* signal CPU creation */
env->created = 1;
qemu_cond_signal(&qemu_cpu_cond);
/* and wait for machine initialization */
while (!qemu_system_ready)
qemu_cond_timedwait(&qemu_system_cond, &qemu_global_mutex, 100);
while (1) {
if (cpu_can_run(env))
qemu_cpu_exec(env);
qemu_kvm_wait_io_event(env);
}
return NULL;
}
| 12,312 |
qemu | f0267ef7115656119bf00ed77857789adc036bda | 0 | static long do_sigreturn_v2(CPUARMState *env)
{
abi_ulong frame_addr;
struct sigframe_v2 *frame = NULL;
/*
* Since we stacked the signal on a 64-bit boundary,
* then 'sp' should be word aligned here. If it's
* not, then the user is trying to mess with us.
*/
frame_addr = env->regs[13];
trace_user_do_sigreturn(env, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return env->regs[0];
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV /* , current */);
return 0;
}
| 12,313 |
qemu | 364031f17932814484657e5551ba12957d993d7e | 0 | static int v9fs_synth_open(FsContext *ctx, V9fsPath *fs_path,
int flags, V9fsFidOpenState *fs)
{
V9fsSynthOpenState *synth_open;
V9fsSynthNode *node = *(V9fsSynthNode **)fs_path->data;
synth_open = g_malloc(sizeof(*synth_open));
synth_open->node = node;
node->open_count++;
fs->private = synth_open;
return 0;
}
| 12,315 |
FFmpeg | 3ebc7e04dea6072400d91c1c90eb3911754cee06 | 0 | static void filter_mb_edgecv( H264Context *h, uint8_t *pix, int stride, int bS[4], int qp ) {
int i, d;
const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 );
const int alpha = alpha_table[index_a];
const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )];
for( i = 0; i < 4; i++ ) {
if( bS[i] == 0 ) {
pix += 2 * stride;
continue;
}
/* 2px edge length (because we use same bS than the one for luma) */
for( d = 0; d < 2; d++ )
{
const uint8_t p0 = pix[-1];
const uint8_t p1 = pix[-2];
const uint8_t q0 = pix[0];
const uint8_t q1 = pix[1];
if( abs( p0 - q0 ) >= alpha ||
abs( p1 - p0 ) >= beta ||
abs( q1 - q0 ) >= beta ) {
pix += stride;
continue;
}
if( bS[i] < 4 ) {
const int tc = tc0_table[index_a][bS[i] - 1] + 1;
const int i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
pix[-1] = clip( p0 + i_delta, 0, 255 ); /* p0' */
pix[0] = clip( q0 - i_delta, 0, 255 ); /* q0' */
} else {
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */
pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */
}
pix += stride;
}
}
}
| 12,316 |
qemu | e3f5ec2b5e92706e3b807059f79b1fb5d936e567 | 0 | static void rtl8139_transfer_frame(RTL8139State *s, const uint8_t *buf, int size, int do_interrupt)
{
if (!size)
{
DEBUG_PRINT(("RTL8139: +++ empty ethernet frame\n"));
return;
}
if (TxLoopBack == (s->TxConfig & TxLoopBack))
{
DEBUG_PRINT(("RTL8139: +++ transmit loopback mode\n"));
rtl8139_do_receive(s, buf, size, do_interrupt);
}
else
{
qemu_send_packet(s->vc, buf, size);
}
}
| 12,318 |
qemu | a0fa2cb8ccf0b73cfd3ac01d557401a2303c0de4 | 0 | static void sclp_execute(SCCB *sccb, uint64_t code)
{
S390SCLPDevice *sdev = get_event_facility();
switch (code & SCLP_CMD_CODE_MASK) {
case SCLP_CMDW_READ_SCP_INFO:
case SCLP_CMDW_READ_SCP_INFO_FORCED:
read_SCP_info(sccb);
break;
case SCLP_CMDW_READ_CPU_INFO:
sclp_read_cpu_info(sccb);
break;
default:
sdev->sclp_command_handler(sdev->ef, sccb, code);
break;
}
}
| 12,319 |
qemu | 88b062c2036cfd05b5111147736a08ba05ea05a9 | 0 | static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf,
int64_t bytes, CoroutineEntry co_entry,
BdrvRequestFlags flags)
{
AioContext *aio_context;
QEMUIOVector qiov;
struct iovec iov;
Coroutine *co;
BlkRwCo rwco;
iov = (struct iovec) {
.iov_base = buf,
.iov_len = bytes,
};
qemu_iovec_init_external(&qiov, &iov, 1);
rwco = (BlkRwCo) {
.blk = blk,
.offset = offset,
.qiov = &qiov,
.flags = flags,
.ret = NOT_DONE,
};
co = qemu_coroutine_create(co_entry, &rwco);
qemu_coroutine_enter(co);
aio_context = blk_get_aio_context(blk);
while (rwco.ret == NOT_DONE) {
aio_poll(aio_context, true);
}
return rwco.ret;
}
| 12,321 |
qemu | ad9579aaa16d5b385922d49edac2c96c79bcfb62 | 0 | static int unix_listen_saddr(UnixSocketAddress *saddr,
bool update_addr,
Error **errp)
{
struct sockaddr_un un;
int sock, fd;
sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
error_setg_errno(errp, errno, "Failed to create Unix socket");
return -1;
}
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
if (saddr->path && strlen(saddr->path)) {
snprintf(un.sun_path, sizeof(un.sun_path), "%s", saddr->path);
} else {
const char *tmpdir = getenv("TMPDIR");
tmpdir = tmpdir ? tmpdir : "/tmp";
if (snprintf(un.sun_path, sizeof(un.sun_path), "%s/qemu-socket-XXXXXX",
tmpdir) >= sizeof(un.sun_path)) {
error_setg_errno(errp, errno,
"TMPDIR environment variable (%s) too large", tmpdir);
goto err;
}
/*
* This dummy fd usage silences the mktemp() unsecure warning.
* Using mkstemp() doesn't make things more secure here
* though. bind() complains about existing files, so we have
* to unlink first and thus re-open the race window. The
* worst case possible is bind() failing, i.e. a DoS attack.
*/
fd = mkstemp(un.sun_path);
if (fd < 0) {
error_setg_errno(errp, errno,
"Failed to make a temporary socket name in %s", tmpdir);
goto err;
}
close(fd);
if (update_addr) {
g_free(saddr->path);
saddr->path = g_strdup(un.sun_path);
}
}
if (unlink(un.sun_path) < 0 && errno != ENOENT) {
error_setg_errno(errp, errno,
"Failed to unlink socket %s", un.sun_path);
goto err;
}
if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
error_setg_errno(errp, errno, "Failed to bind socket to %s", un.sun_path);
goto err;
}
if (listen(sock, 1) < 0) {
error_setg_errno(errp, errno, "Failed to listen on socket");
goto err;
}
return sock;
err:
closesocket(sock);
return -1;
}
| 12,323 |
qemu | b49f7ead8d222bcb8df0388f3177002f3e33d046 | 0 | static void mirror_start_job(const char *job_id, BlockDriverState *bs,
BlockDriverState *target, const char *replaces,
int64_t speed, uint32_t granularity,
int64_t buf_size,
BlockMirrorBackingMode backing_mode,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
bool unmap,
BlockCompletionFunc *cb,
void *opaque, Error **errp,
const BlockJobDriver *driver,
bool is_none_mode, BlockDriverState *base)
{
MirrorBlockJob *s;
if (granularity == 0) {
granularity = bdrv_get_default_bitmap_granularity(target);
}
assert ((granularity & (granularity - 1)) == 0);
if (buf_size < 0) {
error_setg(errp, "Invalid parameter 'buf-size'");
return;
}
if (buf_size == 0) {
buf_size = DEFAULT_MIRROR_BUF_SIZE;
}
s = block_job_create(job_id, driver, bs, speed, cb, opaque, errp);
if (!s) {
return;
}
s->target = blk_new();
blk_insert_bs(s->target, target);
s->replaces = g_strdup(replaces);
s->on_source_error = on_source_error;
s->on_target_error = on_target_error;
s->is_none_mode = is_none_mode;
s->backing_mode = backing_mode;
s->base = base;
s->granularity = granularity;
s->buf_size = ROUND_UP(buf_size, granularity);
s->unmap = unmap;
s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);
if (!s->dirty_bitmap) {
g_free(s->replaces);
blk_unref(s->target);
block_job_unref(&s->common);
return;
}
bdrv_op_block_all(target, s->common.blocker);
s->common.co = qemu_coroutine_create(mirror_run, s);
trace_mirror_start(bs, s, s->common.co, opaque);
qemu_coroutine_enter(s->common.co);
}
| 12,324 |
FFmpeg | b785c62681a0a5a330b065e0754d27a313c44c8e | 0 | int RENAME(swri_resample)(ResampleContext *c, DELEM *dst, const DELEM *src, int *consumed, int src_size, int dst_size, int update_ctx){
int dst_index, i;
int index= c->index;
int frac= c->frac;
int dst_incr_frac= c->dst_incr % c->src_incr;
int dst_incr= c->dst_incr / c->src_incr;
av_assert1(c->filter_shift == FILTER_SHIFT);
av_assert1(c->felem_size == sizeof(FELEM));
if (c->filter_length == 1 && c->phase_shift == 0) {
int64_t index2= (1LL<<32)*c->frac/c->src_incr + (1LL<<32)*index;
int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
int new_size = (src_size * (int64_t)c->src_incr - frac + c->dst_incr - 1) / c->dst_incr;
dst_size= FFMIN(dst_size, new_size);
for(dst_index=0; dst_index < dst_size; dst_index++){
dst[dst_index] = src[index2>>32];
index2 += incr;
}
index += dst_index * dst_incr;
index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr;
frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr;
av_assert2(index >= 0);
*consumed= index;
index = 0;
} else if (index >= 0) {
int64_t end_index = (1LL + src_size - c->filter_length) << c->phase_shift;
int64_t delta_frac = (end_index - index) * c->src_incr - c->frac;
int delta_n = (delta_frac + c->dst_incr - 1) / c->dst_incr;
int n = FFMIN(dst_size, delta_n);
int sample_index;
if (!c->linear) {
sample_index = index >> c->phase_shift;
index &= c->phase_mask;
for (dst_index = 0; dst_index < n; dst_index++) {
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index;
#ifdef COMMON_CORE
COMMON_CORE
#else
FELEM2 val=0;
for (i = 0; i < c->filter_length; i++) {
val += src[sample_index + i] * (FELEM2)filter[i];
}
OUT(dst[dst_index], val);
#endif
frac += dst_incr_frac;
index += dst_incr;
if (frac >= c->src_incr) {
frac -= c->src_incr;
index++;
}
sample_index += index >> c->phase_shift;
index &= c->phase_mask;
}
} else {
sample_index = index >> c->phase_shift;
index &= c->phase_mask;
for (dst_index = 0; dst_index < n; dst_index++) {
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index;
FELEM2 val=0, v2 = 0;
#ifdef LINEAR_CORE
LINEAR_CORE
#else
for (i = 0; i < c->filter_length; i++) {
val += src[sample_index + i] * (FELEM2)filter[i];
v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_alloc];
}
#endif
val += (v2 - val) * (FELEML) frac / c->src_incr;
OUT(dst[dst_index], val);
frac += dst_incr_frac;
index += dst_incr;
if (frac >= c->src_incr) {
frac -= c->src_incr;
index++;
}
sample_index += index >> c->phase_shift;
index &= c->phase_mask;
}
}
*consumed = sample_index;
} else {
int sample_index = 0;
for(dst_index=0; dst_index < dst_size; dst_index++){
FELEM *filter;
FELEM2 val=0;
sample_index += index >> c->phase_shift;
index &= c->phase_mask;
filter = ((FELEM*)c->filter_bank) + c->filter_alloc*index;
if(sample_index + c->filter_length > src_size || -sample_index >= src_size){
break;
}else if(sample_index < 0){
for(i=0; i<c->filter_length; i++)
val += src[FFABS(sample_index + i)] * (FELEM2)filter[i];
OUT(dst[dst_index], val);
}else if(c->linear){
FELEM2 v2=0;
#ifdef LINEAR_CORE
LINEAR_CORE
#else
for(i=0; i<c->filter_length; i++){
val += src[sample_index + i] * (FELEM2)filter[i];
v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_alloc];
}
#endif
val+=(v2-val)*(FELEML)frac / c->src_incr;
OUT(dst[dst_index], val);
}else{
#ifdef COMMON_CORE
COMMON_CORE
#else
for(i=0; i<c->filter_length; i++){
val += src[sample_index + i] * (FELEM2)filter[i];
}
OUT(dst[dst_index], val);
#endif
}
frac += dst_incr_frac;
index += dst_incr;
if(frac >= c->src_incr){
frac -= c->src_incr;
index++;
}
}
*consumed= FFMAX(sample_index, 0);
index += FFMIN(sample_index, 0) << c->phase_shift;
}
if(update_ctx){
c->frac= frac;
c->index= index;
}
return dst_index;
}
| 12,327 |
qemu | 8d999995e45c1002aa11f269c98f2e93e6f8c42a | 0 | static uint32_t gic_dist_readb(void *opaque, hwaddr offset)
{
GICState *s = (GICState *)opaque;
uint32_t res;
int irq;
int i;
int cpu;
int cm;
int mask;
cpu = gic_get_current_cpu(s);
cm = 1 << cpu;
if (offset < 0x100) {
if (offset == 0)
return s->enabled;
if (offset == 4)
return ((s->num_irq / 32) - 1) | ((NUM_CPU(s) - 1) << 5);
if (offset < 0x08)
return 0;
if (offset >= 0x80) {
/* Interrupt Security , RAZ/WI */
return 0;
}
goto bad_reg;
} else if (offset < 0x200) {
/* Interrupt Set/Clear Enable. */
if (offset < 0x180)
irq = (offset - 0x100) * 8;
else
irq = (offset - 0x180) * 8;
irq += GIC_BASE_IRQ;
if (irq >= s->num_irq)
goto bad_reg;
res = 0;
for (i = 0; i < 8; i++) {
if (GIC_TEST_ENABLED(irq + i, cm)) {
res |= (1 << i);
}
}
} else if (offset < 0x300) {
/* Interrupt Set/Clear Pending. */
if (offset < 0x280)
irq = (offset - 0x200) * 8;
else
irq = (offset - 0x280) * 8;
irq += GIC_BASE_IRQ;
if (irq >= s->num_irq)
goto bad_reg;
res = 0;
mask = (irq < GIC_INTERNAL) ? cm : ALL_CPU_MASK;
for (i = 0; i < 8; i++) {
if (GIC_TEST_PENDING(irq + i, mask)) {
res |= (1 << i);
}
}
} else if (offset < 0x400) {
/* Interrupt Active. */
irq = (offset - 0x300) * 8 + GIC_BASE_IRQ;
if (irq >= s->num_irq)
goto bad_reg;
res = 0;
mask = (irq < GIC_INTERNAL) ? cm : ALL_CPU_MASK;
for (i = 0; i < 8; i++) {
if (GIC_TEST_ACTIVE(irq + i, mask)) {
res |= (1 << i);
}
}
} else if (offset < 0x800) {
/* Interrupt Priority. */
irq = (offset - 0x400) + GIC_BASE_IRQ;
if (irq >= s->num_irq)
goto bad_reg;
res = GIC_GET_PRIORITY(irq, cpu);
} else if (offset < 0xc00) {
/* Interrupt CPU Target. */
if (s->num_cpu == 1 && s->revision != REV_11MPCORE) {
/* For uniprocessor GICs these RAZ/WI */
res = 0;
} else {
irq = (offset - 0x800) + GIC_BASE_IRQ;
if (irq >= s->num_irq) {
goto bad_reg;
}
if (irq >= 29 && irq <= 31) {
res = cm;
} else {
res = GIC_TARGET(irq);
}
}
} else if (offset < 0xf00) {
/* Interrupt Configuration. */
irq = (offset - 0xc00) * 2 + GIC_BASE_IRQ;
if (irq >= s->num_irq)
goto bad_reg;
res = 0;
for (i = 0; i < 4; i++) {
if (GIC_TEST_MODEL(irq + i))
res |= (1 << (i * 2));
if (GIC_TEST_EDGE_TRIGGER(irq + i))
res |= (2 << (i * 2));
}
} else if (offset < 0xfe0) {
goto bad_reg;
} else /* offset >= 0xfe0 */ {
if (offset & 3) {
res = 0;
} else {
res = gic_id[(offset - 0xfe0) >> 2];
}
}
return res;
bad_reg:
qemu_log_mask(LOG_GUEST_ERROR,
"gic_dist_readb: Bad offset %x\n", (int)offset);
return 0;
}
| 12,328 |
qemu | 856d72454f03aea26fd61c728762ef9cd1d71512 | 0 | MemoryRegionSection memory_region_find(MemoryRegion *mr,
hwaddr addr, uint64_t size)
{
MemoryRegionSection ret = { .mr = NULL };
MemoryRegion *root;
AddressSpace *as;
AddrRange range;
FlatView *view;
FlatRange *fr;
addr += mr->addr;
for (root = mr; root->parent; ) {
root = root->parent;
addr += root->addr;
}
as = memory_region_to_address_space(root);
range = addrrange_make(int128_make64(addr), int128_make64(size));
view = as->current_map;
fr = flatview_lookup(view, range);
if (!fr) {
return ret;
}
while (fr > view->ranges && addrrange_intersects(fr[-1].addr, range)) {
--fr;
}
ret.mr = fr->mr;
ret.address_space = as;
range = addrrange_intersection(range, fr->addr);
ret.offset_within_region = fr->offset_in_region;
ret.offset_within_region += int128_get64(int128_sub(range.start,
fr->addr.start));
ret.size = range.size;
ret.offset_within_address_space = int128_get64(range.start);
ret.readonly = fr->readonly;
memory_region_ref(ret.mr);
return ret;
}
| 12,330 |
qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | 0 | static void omap_tcmi_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
if (size != 4) {
return omap_badwidth_write32(opaque, addr, value);
}
switch (addr) {
case 0x00: /* IMIF_PRIO */
case 0x04: /* EMIFS_PRIO */
case 0x08: /* EMIFF_PRIO */
case 0x10: /* EMIFS_CS0_CONFIG */
case 0x14: /* EMIFS_CS1_CONFIG */
case 0x18: /* EMIFS_CS2_CONFIG */
case 0x1c: /* EMIFS_CS3_CONFIG */
case 0x20: /* EMIFF_SDRAM_CONFIG */
case 0x24: /* EMIFF_MRS */
case 0x28: /* TIMEOUT1 */
case 0x2c: /* TIMEOUT2 */
case 0x30: /* TIMEOUT3 */
case 0x3c: /* EMIFF_SDRAM_CONFIG_2 */
case 0x40: /* EMIFS_CFG_DYN_WAIT */
s->tcmi_regs[addr >> 2] = value;
break;
case 0x0c: /* EMIFS_CONFIG */
s->tcmi_regs[addr >> 2] = (value & 0xf) | (1 << 4);
break;
default:
OMAP_BAD_REG(addr);
}
}
| 12,331 |
FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | 0 | static av_cold int xbm_encode_init(AVCodecContext *avctx)
{
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
return 0;
}
| 12,332 |
FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | 0 | static inline void RENAME(yuvPlanartoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
long width, long height,
long lumStride, long chromStride, long dstStride, long vertLumPerChroma)
{
long y;
const x86_reg chromWidth= width>>1;
for (y=0; y<height; y++) {
#if COMPILE_TEMPLATE_MMX
//FIXME handle 2 lines at once (fewer prefetches, reuse some chroma, but very likely memory-limited anyway)
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
".p2align 4 \n\t"
"1: \n\t"
PREFETCH" 32(%1, %%"REG_a", 2) \n\t"
PREFETCH" 32(%2, %%"REG_a") \n\t"
PREFETCH" 32(%3, %%"REG_a") \n\t"
"movq (%2, %%"REG_a"), %%mm0 \n\t" // U(0)
"movq %%mm0, %%mm2 \n\t" // U(0)
"movq (%3, %%"REG_a"), %%mm1 \n\t" // V(0)
"punpcklbw %%mm1, %%mm0 \n\t" // UVUV UVUV(0)
"punpckhbw %%mm1, %%mm2 \n\t" // UVUV UVUV(8)
"movq (%1, %%"REG_a",2), %%mm3 \n\t" // Y(0)
"movq 8(%1, %%"REG_a",2), %%mm5 \n\t" // Y(8)
"movq %%mm3, %%mm4 \n\t" // Y(0)
"movq %%mm5, %%mm6 \n\t" // Y(8)
"punpcklbw %%mm0, %%mm3 \n\t" // YUYV YUYV(0)
"punpckhbw %%mm0, %%mm4 \n\t" // YUYV YUYV(4)
"punpcklbw %%mm2, %%mm5 \n\t" // YUYV YUYV(8)
"punpckhbw %%mm2, %%mm6 \n\t" // YUYV YUYV(12)
MOVNTQ" %%mm3, (%0, %%"REG_a", 4) \n\t"
MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4) \n\t"
MOVNTQ" %%mm5, 16(%0, %%"REG_a", 4) \n\t"
MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4) \n\t"
"add $8, %%"REG_a" \n\t"
"cmp %4, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth)
: "%"REG_a
);
#else
#if ARCH_ALPHA && HAVE_MVI
#define pl2yuy2(n) \
y1 = yc[n]; \
y2 = yc2[n]; \
u = uc[n]; \
v = vc[n]; \
__asm__("unpkbw %1, %0" : "=r"(y1) : "r"(y1)); \
__asm__("unpkbw %1, %0" : "=r"(y2) : "r"(y2)); \
__asm__("unpkbl %1, %0" : "=r"(u) : "r"(u)); \
__asm__("unpkbl %1, %0" : "=r"(v) : "r"(v)); \
yuv1 = (u << 8) + (v << 24); \
yuv2 = yuv1 + y2; \
yuv1 += y1; \
qdst[n] = yuv1; \
qdst2[n] = yuv2;
int i;
uint64_t *qdst = (uint64_t *) dst;
uint64_t *qdst2 = (uint64_t *) (dst + dstStride);
const uint32_t *yc = (uint32_t *) ysrc;
const uint32_t *yc2 = (uint32_t *) (ysrc + lumStride);
const uint16_t *uc = (uint16_t*) usrc, *vc = (uint16_t*) vsrc;
for (i = 0; i < chromWidth; i += 8) {
uint64_t y1, y2, yuv1, yuv2;
uint64_t u, v;
/* Prefetch */
__asm__("ldq $31,64(%0)" :: "r"(yc));
__asm__("ldq $31,64(%0)" :: "r"(yc2));
__asm__("ldq $31,64(%0)" :: "r"(uc));
__asm__("ldq $31,64(%0)" :: "r"(vc));
pl2yuy2(0);
pl2yuy2(1);
pl2yuy2(2);
pl2yuy2(3);
yc += 4;
yc2 += 4;
uc += 4;
vc += 4;
qdst += 4;
qdst2 += 4;
}
y++;
ysrc += lumStride;
dst += dstStride;
#elif HAVE_FAST_64BIT
int i;
uint64_t *ldst = (uint64_t *) dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for (i = 0; i < chromWidth; i += 2) {
uint64_t k, l;
k = yc[0] + (uc[0] << 8) +
(yc[1] << 16) + (vc[0] << 24);
l = yc[2] + (uc[1] << 8) +
(yc[3] << 16) + (vc[1] << 24);
*ldst++ = k + (l << 32);
yc += 4;
uc += 2;
vc += 2;
}
#else
int i, *idst = (int32_t *) dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for (i = 0; i < chromWidth; i++) {
#if HAVE_BIGENDIAN
*idst++ = (yc[0] << 24)+ (uc[0] << 16) +
(yc[1] << 8) + (vc[0] << 0);
#else
*idst++ = yc[0] + (uc[0] << 8) +
(yc[1] << 16) + (vc[0] << 24);
#endif
yc += 2;
uc++;
vc++;
}
#endif
#endif
if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
usrc += chromStride;
vsrc += chromStride;
}
ysrc += lumStride;
dst += dstStride;
}
#if COMPILE_TEMPLATE_MMX
__asm__(EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif
}
| 12,333 |
FFmpeg | 0544c95fd6d0e3c1072554f9d13baf45af7fbf56 | 0 | DECL_IMDCT_BLOCKS(sse,sse)
#endif
DECL_IMDCT_BLOCKS(sse2,sse)
DECL_IMDCT_BLOCKS(sse3,sse)
DECL_IMDCT_BLOCKS(ssse3,sse)
#endif
#if HAVE_AVX_EXTERNAL
DECL_IMDCT_BLOCKS(avx,avx)
#endif
#endif /* HAVE_YASM */
av_cold void ff_mpadsp_init_x86(MPADSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
int i, j;
for (j = 0; j < 4; j++) {
for (i = 0; i < 40; i ++) {
mdct_win_sse[0][j][4*i ] = ff_mdct_win_float[j ][i];
mdct_win_sse[0][j][4*i + 1] = ff_mdct_win_float[j + 4][i];
mdct_win_sse[0][j][4*i + 2] = ff_mdct_win_float[j ][i];
mdct_win_sse[0][j][4*i + 3] = ff_mdct_win_float[j + 4][i];
mdct_win_sse[1][j][4*i ] = ff_mdct_win_float[0 ][i];
mdct_win_sse[1][j][4*i + 1] = ff_mdct_win_float[4 ][i];
mdct_win_sse[1][j][4*i + 2] = ff_mdct_win_float[j ][i];
mdct_win_sse[1][j][4*i + 3] = ff_mdct_win_float[j + 4][i];
}
}
#if HAVE_6REGS && HAVE_SSE_INLINE
if (INLINE_SSE(cpu_flags)) {
s->apply_window_float = apply_window_mp3;
}
#endif /* HAVE_SSE_INLINE */
#if HAVE_YASM
#if HAVE_SSE
#if ARCH_X86_32
if (EXTERNAL_SSE(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_sse;
}
#endif
if (EXTERNAL_SSE2(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_sse2;
}
if (EXTERNAL_SSE3(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_sse3;
}
if (EXTERNAL_SSSE3(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_ssse3;
}
#endif
#if HAVE_AVX_EXTERNAL
if (EXTERNAL_AVX(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_avx;
}
#endif
#endif /* HAVE_YASM */
}
| 12,334 |
FFmpeg | 9729f140ae073f1df2041b6c5fd2068592eb9c48 | 1 | static void dirac_unpack_block_motion_data(DiracContext *s)
{
GetBitContext *gb = &s->gb;
uint8_t *sbsplit = s->sbsplit;
int i, x, y, q, p;
DiracArith arith[8];
align_get_bits(gb);
/* [DIRAC_STD] 11.2.4 and 12.2.1 Number of blocks and superblocks */
s->sbwidth = DIVRNDUP(s->source.width, 4*s->plane[0].xbsep);
s->sbheight = DIVRNDUP(s->source.height, 4*s->plane[0].ybsep);
s->blwidth = 4 * s->sbwidth;
s->blheight = 4 * s->sbheight;
/* [DIRAC_STD] 12.3.1 Superblock splitting modes. superblock_split_modes()
decode superblock split modes */
ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb)); /* svq3_get_ue_golomb(gb) is the length */
for (y = 0; y < s->sbheight; y++) {
for (x = 0; x < s->sbwidth; x++) {
int split = dirac_get_arith_uint(arith, CTX_SB_F1, CTX_SB_DATA);
sbsplit[x] = (split + pred_sbsplit(sbsplit+x, s->sbwidth, x, y)) % 3;
}
sbsplit += s->sbwidth;
}
/* setup arith decoding */
ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb));
for (i = 0; i < s->num_refs; i++) {
ff_dirac_init_arith_decoder(arith + 4 + 2 * i, gb, svq3_get_ue_golomb(gb));
ff_dirac_init_arith_decoder(arith + 5 + 2 * i, gb, svq3_get_ue_golomb(gb));
}
for (i = 0; i < 3; i++)
ff_dirac_init_arith_decoder(arith+1+i, gb, svq3_get_ue_golomb(gb));
for (y = 0; y < s->sbheight; y++)
for (x = 0; x < s->sbwidth; x++) {
int blkcnt = 1 << s->sbsplit[y * s->sbwidth + x];
int step = 4 >> s->sbsplit[y * s->sbwidth + x];
for (q = 0; q < blkcnt; q++)
for (p = 0; p < blkcnt; p++) {
int bx = 4 * x + p*step;
int by = 4 * y + q*step;
DiracBlock *block = &s->blmotion[by*s->blwidth + bx];
decode_block_params(s, arith, block, s->blwidth, bx, by);
propagate_block_data(block, s->blwidth, step);
}
}
}
| 12,335 |
FFmpeg | d1916d13e28b87f4b1b214231149e12e1d536b4b | 1 | static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
long i;
for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
long a = *(long*)(src+i);
long b = *(long*)(dst+i);
*(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
}
for(; i<w; i++)
dst[i+0] += src[i+0];
}
| 12,336 |
qemu | 3026c4688ca80d9c5cc1606368c4a1009a6f507d | 1 | static int write_f(BlockBackend *blk, int argc, char **argv)
{
struct timeval t1, t2;
bool Cflag = false, qflag = false, bflag = false;
bool Pflag = false, zflag = false, cflag = false;
int flags = 0;
int c, cnt;
char *buf = NULL;
int64_t offset;
int64_t count;
/* Some compilers get confused and warn if this is not initialized. */
int64_t total = 0;
int pattern = 0xcd;
while ((c = getopt(argc, argv, "bcCfpP:quz")) != -1) {
switch (c) {
case 'b':
bflag = true;
break;
case 'c':
cflag = true;
break;
case 'C':
Cflag = true;
break;
case 'f':
flags |= BDRV_REQ_FUA;
break;
case 'p':
/* Ignored for backwards compatibility */
break;
case 'P':
Pflag = true;
pattern = parse_pattern(optarg);
if (pattern < 0) {
return 0;
}
break;
case 'q':
qflag = true;
break;
case 'u':
flags |= BDRV_REQ_MAY_UNMAP;
break;
case 'z':
zflag = true;
break;
default:
return qemuio_command_usage(&write_cmd);
}
}
if (optind != argc - 2) {
return qemuio_command_usage(&write_cmd);
}
if (bflag && zflag) {
printf("-b and -z cannot be specified at the same time\n");
return 0;
}
if ((flags & BDRV_REQ_FUA) && (bflag || cflag)) {
printf("-f and -b or -c cannot be specified at the same time\n");
return 0;
}
if ((flags & BDRV_REQ_MAY_UNMAP) && !zflag) {
printf("-u requires -z to be specified\n");
return 0;
}
if (zflag && Pflag) {
printf("-z and -P cannot be specified at the same time\n");
return 0;
}
offset = cvtnum(argv[optind]);
if (offset < 0) {
print_cvtnum_err(offset, argv[optind]);
return 0;
}
optind++;
count = cvtnum(argv[optind]);
if (count < 0) {
print_cvtnum_err(count, argv[optind]);
return 0;
} else if (count > SIZE_MAX) {
printf("length cannot exceed %" PRIu64 ", given %s\n",
(uint64_t) SIZE_MAX, argv[optind]);
return 0;
}
if (bflag || cflag) {
if (offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
offset);
return 0;
}
if (count & 0x1ff) {
printf("count %"PRId64" is not sector aligned\n",
count);
return 0;
}
}
if (!zflag) {
buf = qemu_io_alloc(blk, count, pattern);
}
gettimeofday(&t1, NULL);
if (bflag) {
cnt = do_save_vmstate(blk, buf, offset, count, &total);
} else if (zflag) {
cnt = do_co_pwrite_zeroes(blk, offset, count, flags, &total);
} else if (cflag) {
cnt = do_write_compressed(blk, buf, offset, count, &total);
} else {
cnt = do_pwrite(blk, buf, offset, count, flags, &total);
}
gettimeofday(&t2, NULL);
if (cnt < 0) {
printf("write failed: %s\n", strerror(-cnt));
goto out;
}
if (qflag) {
goto out;
}
/* Finally, report back -- -C gives a parsable format */
t2 = tsub(t2, t1);
print_report("wrote", &t2, offset, count, total, cnt, Cflag);
out:
if (!zflag) {
qemu_io_free(buf);
}
return 0;
}
| 12,337 |
FFmpeg | 5e715b583dab85735660b15a8d217a69164675fe | 1 | static int parse_audio(DBEContext *s, int start, int end, int seg_id)
{
int ch, ret, key = parse_key(s);
for (ch = start; ch < end; ch++) {
if (!s->ch_size[ch]) {
s->channels[seg_id][ch].nb_groups = 0;
continue;
}
if ((ret = convert_input(s, s->ch_size[ch], key)) < 0)
return ret;
if ((ret = parse_channel(s, ch, seg_id)) < 0) {
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return ret;
s->channels[seg_id][ch].nb_groups = 0;
}
skip_input(s, s->ch_size[ch]);
}
skip_input(s, 1);
return 0;
}
| 12,338 |
qemu | 77b0359bf414ad666d1714dc9888f1017c08e283 | 1 | static void qemu_input_queue_process(void *opaque)
{
struct QemuInputEventQueueHead *queue = opaque;
QemuInputEventQueue *item;
g_assert(!QTAILQ_EMPTY(queue));
item = QTAILQ_FIRST(queue);
g_assert(item->type == QEMU_INPUT_QUEUE_DELAY);
QTAILQ_REMOVE(queue, item, node);
g_free(item);
while (!QTAILQ_EMPTY(queue)) {
item = QTAILQ_FIRST(queue);
switch (item->type) {
case QEMU_INPUT_QUEUE_DELAY:
timer_mod(item->timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)
+ item->delay_ms);
return;
case QEMU_INPUT_QUEUE_EVENT:
qemu_input_event_send(item->src, item->evt);
qapi_free_InputEvent(item->evt);
break;
case QEMU_INPUT_QUEUE_SYNC:
qemu_input_event_sync();
break;
}
QTAILQ_REMOVE(queue, item, node);
g_free(item);
}
} | 12,339 |
qemu | af103c9310b7ab56a2552965d9d1274b0024f27b | 1 | static void vhost_scsi_unrealize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VHostSCSI *s = VHOST_SCSI(dev);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
/* This will stop vhost backend. */
vhost_scsi_set_status(vdev, 0);
g_free(s->dev.vqs);
virtio_scsi_common_unrealize(dev, errp);
} | 12,340 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.