id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
7,708
static void decode_vui(HEVCContext *s, HEVCSPS *sps) { VUI *vui = &sps->vui; GetBitContext *gb = &s->HEVClc->gb; int sar_present; av_log(s->avctx, AV_LOG_DEBUG, "Decoding VUI\n"); sar_present = get_bits1(gb); if (sar_present) { uint8_t sar_idx = get_bits(gb, 8); if (sar_idx < FF_ARRAY_ELEMS(vui_sar)) vui->sar = vui_sar[sar_idx]; else if (sar_idx == 255) { vui->sar.num = get_bits(gb, 16); vui->sar.den = get_bits(gb, 16); } else av_log(s->avctx, AV_LOG_WARNING, "Unknown SAR index: %u.\n", sar_idx); } vui->overscan_info_present_flag = get_bits1(gb); if (vui->overscan_info_present_flag) vui->overscan_appropriate_flag = get_bits1(gb); vui->video_signal_type_present_flag = get_bits1(gb); if (vui->video_signal_type_present_flag) { vui->video_format = get_bits(gb, 3); vui->video_full_range_flag = get_bits1(gb); vui->colour_description_present_flag = get_bits1(gb); if (vui->video_full_range_flag && sps->pix_fmt == AV_PIX_FMT_YUV420P) sps->pix_fmt = AV_PIX_FMT_YUVJ420P; if (vui->colour_description_present_flag) { vui->colour_primaries = get_bits(gb, 8); vui->transfer_characteristic = get_bits(gb, 8); vui->matrix_coeffs = get_bits(gb, 8); // Set invalid values to "unspecified" if (vui->colour_primaries >= AVCOL_PRI_NB) vui->colour_primaries = AVCOL_PRI_UNSPECIFIED; if (vui->transfer_characteristic >= AVCOL_TRC_NB) vui->transfer_characteristic = AVCOL_TRC_UNSPECIFIED; if (vui->matrix_coeffs >= AVCOL_SPC_NB) vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED; } } vui->chroma_loc_info_present_flag = get_bits1(gb); if (vui->chroma_loc_info_present_flag) { vui->chroma_sample_loc_type_top_field = get_ue_golomb_long(gb); vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_long(gb); } vui->neutra_chroma_indication_flag = get_bits1(gb); vui->field_seq_flag = get_bits1(gb); vui->frame_field_info_present_flag = get_bits1(gb); vui->default_display_window_flag = get_bits1(gb); if (vui->default_display_window_flag) { //TODO: * 2 is only valid for 420 vui->def_disp_win.left_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.right_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.top_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.bottom_offset = get_ue_golomb_long(gb) * 2; if (s->apply_defdispwin && s->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) { av_log(s->avctx, AV_LOG_DEBUG, "discarding vui default display window, " "original values are l:%u r:%u t:%u b:%u\n", vui->def_disp_win.left_offset, vui->def_disp_win.right_offset, vui->def_disp_win.top_offset, vui->def_disp_win.bottom_offset); vui->def_disp_win.left_offset = vui->def_disp_win.right_offset = vui->def_disp_win.top_offset = vui->def_disp_win.bottom_offset = 0; } } vui->vui_timing_info_present_flag = get_bits1(gb); if (vui->vui_timing_info_present_flag) { vui->vui_num_units_in_tick = get_bits(gb, 32); vui->vui_time_scale = get_bits(gb, 32); vui->vui_poc_proportional_to_timing_flag = get_bits1(gb); if (vui->vui_poc_proportional_to_timing_flag) vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb); vui->vui_hrd_parameters_present_flag = get_bits1(gb); if (vui->vui_hrd_parameters_present_flag) decode_hrd(s, 1, sps->max_sub_layers); } vui->bitstream_restriction_flag = get_bits1(gb); if (vui->bitstream_restriction_flag) { vui->tiles_fixed_structure_flag = get_bits1(gb); vui->motion_vectors_over_pic_boundaries_flag = get_bits1(gb); vui->restricted_ref_pic_lists_flag = get_bits1(gb); vui->min_spatial_segmentation_idc = get_ue_golomb_long(gb); vui->max_bytes_per_pic_denom = get_ue_golomb_long(gb); vui->max_bits_per_min_cu_denom = get_ue_golomb_long(gb); vui->log2_max_mv_length_horizontal = get_ue_golomb_long(gb); vui->log2_max_mv_length_vertical = get_ue_golomb_long(gb); } }
true
FFmpeg
b818637b84948e917d11c987f2270cea5b3fcfea
7,710
static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async) { EHCIPacket *p; uint32_t entry, devaddr; EHCIQueue *q; entry = ehci_get_fetch_addr(ehci, async); q = ehci_find_queue_by_qh(ehci, entry, async); if (NULL == q) { q = ehci_alloc_queue(ehci, entry, async); } p = QTAILQ_FIRST(&q->packets); q->seen++; if (q->seen > 1) { /* we are going in circles -- stop processing */ ehci_set_state(ehci, async, EST_ACTIVE); q = NULL; goto out; } get_dwords(ehci, NLPTR_GET(q->qhaddr), (uint32_t *) &q->qh, sizeof(EHCIqh) >> 2); ehci_trace_qh(q, NLPTR_GET(q->qhaddr), &q->qh); devaddr = get_field(q->qh.epchar, QH_EPCHAR_DEVADDR); if (q->dev != NULL && q->dev->addr != devaddr) { if (!QTAILQ_EMPTY(&q->packets)) { /* should not happen (guest bug) */ ehci_cancel_queue(q); } q->dev = NULL; } if (q->dev == NULL) { q->dev = ehci_find_device(q->ehci, devaddr); } if (p && p->async == EHCI_ASYNC_FINISHED) { /* I/O finished -- continue processing queue */ trace_usb_ehci_packet_action(p->queue, p, "complete"); ehci_set_state(ehci, async, EST_EXECUTING); goto out; } if (async && (q->qh.epchar & QH_EPCHAR_H)) { /* EHCI spec version 1.0 Section 4.8.3 & 4.10.1 */ if (ehci->usbsts & USBSTS_REC) { ehci_clear_usbsts(ehci, USBSTS_REC); } else { DPRINTF("FETCHQH: QH 0x%08x. H-bit set, reclamation status reset" " - done processing\n", q->qhaddr); ehci_set_state(ehci, async, EST_ACTIVE); q = NULL; goto out; } } #if EHCI_DEBUG if (q->qhaddr != q->qh.next) { DPRINTF("FETCHQH: QH 0x%08x (h %x halt %x active %x) next 0x%08x\n", q->qhaddr, q->qh.epchar & QH_EPCHAR_H, q->qh.token & QTD_TOKEN_HALT, q->qh.token & QTD_TOKEN_ACTIVE, q->qh.next); } #endif if (q->qh.token & QTD_TOKEN_HALT) { ehci_set_state(ehci, async, EST_HORIZONTALQH); } else if ((q->qh.token & QTD_TOKEN_ACTIVE) && (NLPTR_TBIT(q->qh.current_qtd) == 0)) { q->qtdaddr = q->qh.current_qtd; ehci_set_state(ehci, async, EST_FETCHQTD); } else { /* EHCI spec version 1.0 Section 4.10.2 */ ehci_set_state(ehci, async, EST_ADVANCEQUEUE); } out: return q; }
true
qemu
dafe31fc2a8653b535d58f8c7b250c0827b14420
7,711
static av_cold int aacPlus_encode_init(AVCodecContext *avctx) { aacPlusAudioContext *s = avctx->priv_data; aacplusEncConfiguration *aacplus_cfg; /* number of channels */ if (avctx->channels < 1 || avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed\n", avctx->channels); return AVERROR(EINVAL); if (avctx->profile != FF_PROFILE_AAC_LOW && avctx->profile != FF_PROFILE_UNKNOWN) { av_log(avctx, AV_LOG_ERROR, "invalid AAC profile: %d, only LC supported\n", avctx->profile); return AVERROR(EINVAL); s->aacplus_handle = aacplusEncOpen(avctx->sample_rate, avctx->channels, &s->samples_input, &s->max_output_bytes); if (!s->aacplus_handle) { av_log(avctx, AV_LOG_ERROR, "can't open encoder\n"); return AVERROR(EINVAL); /* check aacplus version */ aacplus_cfg = aacplusEncGetCurrentConfiguration(s->aacplus_handle); aacplus_cfg->bitRate = avctx->bit_rate; aacplus_cfg->bandWidth = avctx->cutoff; aacplus_cfg->outputFormat = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER); aacplus_cfg->inputFormat = avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? AACPLUS_INPUT_FLOAT : AACPLUS_INPUT_16BIT; if (!aacplusEncSetConfiguration(s->aacplus_handle, aacplus_cfg)) { av_log(avctx, AV_LOG_ERROR, "libaacplus doesn't support this output format!\n"); return AVERROR(EINVAL); avctx->frame_size = s->samples_input / avctx->channels; /* Set decoder specific info */ avctx->extradata_size = 0; if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { unsigned char *buffer = NULL; unsigned long decoder_specific_info_size; if (aacplusEncGetDecoderSpecificInfo(s->aacplus_handle, &buffer, &decoder_specific_info_size) == 1) { avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE); avctx->extradata_size = decoder_specific_info_size; memcpy(avctx->extradata, buffer, avctx->extradata_size); return 0;
true
FFmpeg
642c49c983df2f56b656ce668f2a0257a1939578
7,713
static void s390_virtio_blk_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass); k->init = s390_virtio_blk_init; dc->props = s390_virtio_blk_properties; }
true
qemu
caffdac363801cd2cf2bf01ad013a8c1e1e43800
7,714
static int handle_connection(HTTPContext *c) { int len, ret; switch(c->state) { case HTTPSTATE_WAIT_REQUEST: case RTSPSTATE_WAIT_REQUEST: /* timeout ? */ if ((c->timeout - cur_time) < 0) return -1; if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; /* no need to read if no events */ if (!(c->poll_entry->revents & POLLIN)) return 0; /* read the data */ len = read(c->fd, c->buffer_ptr, 1); if (len < 0) { if (errno != EAGAIN && errno != EINTR) return -1; } else if (len == 0) { return -1; } else { /* search for end of request. */ uint8_t *ptr; c->buffer_ptr += len; ptr = c->buffer_ptr; if ((ptr >= c->buffer + 2 && !memcmp(ptr-2, "\n\n", 2)) || (ptr >= c->buffer + 4 && !memcmp(ptr-4, "\r\n\r\n", 4))) { /* request found : parse it and reply */ if (c->state == HTTPSTATE_WAIT_REQUEST) { ret = http_parse_request(c); } else { ret = rtsp_parse_request(c); } if (ret < 0) return -1; } else if (ptr >= c->buffer_end) { /* request too long: cannot do anything */ return -1; } } break; case HTTPSTATE_SEND_HEADER: if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; /* no need to write if no events */ if (!(c->poll_entry->revents & POLLOUT)) return 0; len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { /* error : close connection */ av_freep(&c->pb_buffer); return -1; } } else { c->buffer_ptr += len; if (c->stream) c->stream->bytes_served += len; c->data_count += len; if (c->buffer_ptr >= c->buffer_end) { av_freep(&c->pb_buffer); /* if error, exit */ if (c->http_error) { return -1; } /* all the buffer was sent : synchronize to the incoming stream */ c->state = HTTPSTATE_SEND_DATA_HEADER; c->buffer_ptr = c->buffer_end = c->buffer; } } break; case HTTPSTATE_SEND_DATA: case HTTPSTATE_SEND_DATA_HEADER: case HTTPSTATE_SEND_DATA_TRAILER: /* for packetized output, we consider we can always write (the input streams sets the speed). It may be better to verify that we do not rely too much on the kernel queues */ if (!c->is_packetized) { if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; /* no need to read if no events */ if (!(c->poll_entry->revents & POLLOUT)) return 0; } if (http_send_data(c) < 0) return -1; break; case HTTPSTATE_RECEIVE_DATA: /* no need to read if no events */ if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; if (!(c->poll_entry->revents & POLLIN)) return 0; if (http_receive_data(c) < 0) return -1; break; case HTTPSTATE_WAIT_FEED: /* no need to read if no events */ if (c->poll_entry->revents & (POLLIN | POLLERR | POLLHUP)) return -1; /* nothing to do, we'll be waken up by incoming feed packets */ break; case HTTPSTATE_WAIT: /* if the delay expired, we can send new packets */ if (compute_send_delay(c) <= 0) c->state = HTTPSTATE_SEND_DATA; break; case HTTPSTATE_WAIT_SHORT: /* just return back to send data */ c->state = HTTPSTATE_SEND_DATA; break; case RTSPSTATE_SEND_REPLY: if (c->poll_entry->revents & (POLLERR | POLLHUP)) { av_freep(&c->pb_buffer); return -1; } /* no need to write if no events */ if (!(c->poll_entry->revents & POLLOUT)) return 0; len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { /* error : close connection */ av_freep(&c->pb_buffer); return -1; } } else { c->buffer_ptr += len; c->data_count += len; if (c->buffer_ptr >= c->buffer_end) { /* all the buffer was sent : wait for a new request */ av_freep(&c->pb_buffer); start_wait_request(c, 1); } } break; case HTTPSTATE_READY: /* nothing to do */ break; default: return -1; } return 0; }
true
FFmpeg
1bc1cfdddf7ab8ef50d0fc888808d6b609eb5d8d
7,717
static int disas_coproc_insn(CPUARMState * env, DisasContext *s, uint32_t insn) { int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2; const ARMCPRegInfo *ri; cpnum = (insn >> 8) & 0xf; if (arm_feature(env, ARM_FEATURE_XSCALE) && ((env->cp15.c15_cpar ^ 0x3fff) & (1 << cpnum))) return 1; /* First check for coprocessor space used for actual instructions */ switch (cpnum) { case 0: case 1: if (arm_feature(env, ARM_FEATURE_IWMMXT)) { return disas_iwmmxt_insn(env, s, insn); } else if (arm_feature(env, ARM_FEATURE_XSCALE)) { return disas_dsp_insn(env, s, insn); return 1; default: break; /* Otherwise treat as a generic register access */ is64 = (insn & (1 << 25)) == 0; if (!is64 && ((insn & (1 << 4)) == 0)) { /* cdp */ return 1; crm = insn & 0xf; if (is64) { crn = 0; opc1 = (insn >> 4) & 0xf; opc2 = 0; rt2 = (insn >> 16) & 0xf; } else { crn = (insn >> 16) & 0xf; opc1 = (insn >> 21) & 7; opc2 = (insn >> 5) & 7; rt2 = 0; isread = (insn >> 20) & 1; rt = (insn >> 12) & 0xf; ri = get_arm_cp_reginfo(s->cp_regs, ENCODE_CP_REG(cpnum, is64, crn, crm, opc1, opc2)); if (ri) { /* Check access permissions */ if (!cp_access_ok(s->current_pl, ri, isread)) { return 1; /* Handle special cases first */ switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { case ARM_CP_NOP: return 0; case ARM_CP_WFI: if (isread) { return 1; s->is_jmp = DISAS_WFI; return 0; default: break; if (use_icount && (ri->type & ARM_CP_IO)) { gen_io_start(); if (isread) { /* Read */ if (is64) { TCGv_i64 tmp64; TCGv_i32 tmp; if (ri->type & ARM_CP_CONST) { tmp64 = tcg_const_i64(ri->resetvalue); } else if (ri->readfn) { tmp64 = tcg_temp_new_i64(); gen_helper_get_cp_reg64(tmp64, cpu_env, tmpptr); } else { tmp64 = tcg_temp_new_i64(); tcg_gen_ld_i64(tmp64, cpu_env, ri->fieldoffset); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); store_reg(s, rt, tmp); tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); store_reg(s, rt2, tmp); } else { TCGv_i32 tmp; if (ri->type & ARM_CP_CONST) { tmp = tcg_const_i32(ri->resetvalue); } else if (ri->readfn) { tmp = tcg_temp_new_i32(); gen_helper_get_cp_reg(tmp, cpu_env, tmpptr); } else { tmp = load_cpu_offset(ri->fieldoffset); if (rt == 15) { /* Destination register of r15 for 32 bit loads sets * the condition codes from the high 4 bits of the value gen_set_nzcv(tmp); tcg_temp_free_i32(tmp); } else { store_reg(s, rt, tmp); } else { /* Write */ if (ri->type & ARM_CP_CONST) { /* If not forbidden by access permissions, treat as WI */ return 0; if (is64) { TCGv_i32 tmplo, tmphi; TCGv_i64 tmp64 = tcg_temp_new_i64(); tmplo = load_reg(s, rt); tmphi = load_reg(s, rt2); tcg_gen_concat_i32_i64(tmp64, tmplo, tmphi); tcg_temp_free_i32(tmplo); tcg_temp_free_i32(tmphi); if (ri->writefn) { TCGv_ptr tmpptr = tcg_const_ptr(ri); gen_helper_set_cp_reg64(cpu_env, tmpptr, tmp64); } else { tcg_gen_st_i64(tmp64, cpu_env, ri->fieldoffset); tcg_temp_free_i64(tmp64); } else { if (ri->writefn) { TCGv_i32 tmp; tmp = load_reg(s, rt); gen_helper_set_cp_reg(cpu_env, tmpptr, tmp); tcg_temp_free_i32(tmp); } else { TCGv_i32 tmp = load_reg(s, rt); store_cpu_offset(tmp, ri->fieldoffset); if (use_icount && (ri->type & ARM_CP_IO)) { /* I/O operations must end the TB here (whether read or write) */ gen_io_end(); gen_lookup_tb(s); } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { /* We default to ending the TB on a coprocessor register write, * but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). gen_lookup_tb(s); return 0; /* Unknown register; this might be a guest error or a QEMU * unimplemented feature. if (is64) { qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " "64 bit system register cp:%d opc1: %d crm:%d\n", isread ? "read" : "write", cpnum, opc1, crm); } else { qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " "system register cp:%d opc1:%d crn:%d crm:%d opc2:%d\n", isread ? "read" : "write", cpnum, opc1, crn, crm, opc2); return 1;
true
qemu
f59df3f2354982ee0381b87d1ce561f1eb0ed505
7,718
static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc) { uint8_t codec_name[32]; int64_t stsd_start; unsigned int len; /* The first 16 bytes of the video sample description are already * read in ff_mov_read_stsd_entries() */ stsd_start = avio_tell(pb) - 16; avio_rb16(pb); /* version */ avio_rb16(pb); /* revision level */ avio_rb32(pb); /* vendor */ avio_rb32(pb); /* temporal quality */ avio_rb32(pb); /* spatial quality */ st->codecpar->width = avio_rb16(pb); /* width */ st->codecpar->height = avio_rb16(pb); /* height */ avio_rb32(pb); /* horiz resolution */ avio_rb32(pb); /* vert resolution */ avio_rb32(pb); /* data size, always 0 */ avio_rb16(pb); /* frames per samples */ len = avio_r8(pb); /* codec name, pascal string */ if (len > 31) len = 31; mov_read_mac_string(c, pb, len, codec_name, sizeof(codec_name)); if (len < 31) avio_skip(pb, 31 - len); if (codec_name[0]) av_dict_set(&st->metadata, "encoder", codec_name, 0); /* codec_tag YV12 triggers an UV swap in rawdec.c */ if (!memcmp(codec_name, "Planar Y'CbCr 8-bit 4:2:0", 25)) { st->codecpar->codec_tag = MKTAG('I', '4', '2', '0'); st->codecpar->width &= ~1; st->codecpar->height &= ~1; } /* Flash Media Server uses tag H.263 with Sorenson Spark */ if (st->codecpar->codec_tag == MKTAG('H','2','6','3') && !memcmp(codec_name, "Sorenson H263", 13)) st->codecpar->codec_id = AV_CODEC_ID_FLV1; st->codecpar->bits_per_coded_sample = avio_rb16(pb); /* depth */ avio_seek(pb, stsd_start, SEEK_SET); if (ff_get_qtpalette(st->codecpar->codec_id, pb, sc->palette)) { st->codecpar->bits_per_coded_sample &= 0x1F; sc->has_palette = 1; } }
true
FFmpeg
66453b1fba6c68f2f7f5117355d34b5f40910327
7,720
static inline void gen_check_tlb_flush(DisasContext *ctx) { }
true
qemu
e3cffe6fad29e07d401eabb913a6d88501d5c143
7,721
static int64_t coroutine_fn qcow_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { BDRVQcowState *s = bs->opaque; int index_in_cluster, n; uint64_t cluster_offset; qemu_co_mutex_lock(&s->lock); cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0); qemu_co_mutex_unlock(&s->lock); index_in_cluster = sector_num & (s->cluster_sectors - 1); n = s->cluster_sectors - index_in_cluster; if (n > nb_sectors) n = nb_sectors; *pnum = n; if (!cluster_offset) { return 0; } if ((cluster_offset & QCOW_OFLAG_COMPRESSED) || s->crypto) { return BDRV_BLOCK_DATA; } cluster_offset |= (index_in_cluster << BDRV_SECTOR_BITS); *file = bs->file->bs; return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | cluster_offset; }
true
qemu
56439e9d55626b65ecb887f1ac3714652555312e
7,722
static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y, int rnd) { if(y==0 && x==0) { /* no filter needed */ H264_CHROMA_MC8_MV0(dst, src, stride, h); return; } assert(x<8 && y<8 && x>=0 && y>=0); if(y==0 || x==0) { /* 1 dimensional filter only */ asm volatile( "movd %0, %%xmm7 \n\t" "movq %1, %%xmm6 \n\t" "pshuflw $0, %%xmm7, %%xmm7 \n\t" "movlhps %%xmm6, %%xmm6 \n\t" "movlhps %%xmm7, %%xmm7 \n\t" :: "r"(255*(x+y)+8), "m"(rnd?ff_pw_4:ff_pw_3)); if(x) { asm volatile( "1: \n\t" "movq (%1), %%xmm0 \n\t" "movq 1(%1), %%xmm1 \n\t" "movq (%1,%3), %%xmm2 \n\t" "movq 1(%1,%3), %%xmm3 \n\t" "punpcklbw %%xmm1, %%xmm0 \n\t" "punpcklbw %%xmm3, %%xmm2 \n\t" "pmaddubsw %%xmm7, %%xmm0 \n\t" "pmaddubsw %%xmm7, %%xmm2 \n\t" AVG_OP("movq (%0), %%xmm4 \n\t") AVG_OP("movhps (%0,%3), %%xmm4 \n\t") "paddw %%xmm6, %%xmm0 \n\t" "paddw %%xmm6, %%xmm2 \n\t" "psrlw $3, %%xmm0 \n\t" "psrlw $3, %%xmm2 \n\t" "packuswb %%xmm2, %%xmm0 \n\t" AVG_OP("pavgb %%xmm4, %%xmm0 \n\t") "movq %%xmm0, (%0) \n\t" "movhps %%xmm0, (%0,%3) \n\t" "sub $2, %2 \n\t" "lea (%1,%3,2), %1 \n\t" "lea (%0,%3,2), %0 \n\t" "jg 1b \n\t" :"+r"(dst), "+r"(src), "+r"(h) :"r"((long)stride) ); } else { asm volatile( "1: \n\t" "movq (%1), %%xmm0 \n\t" "movq (%1,%3), %%xmm1 \n\t" "movdqa %%xmm1, %%xmm2 \n\t" "movq (%1,%3,2), %%xmm3 \n\t" "punpcklbw %%xmm1, %%xmm0 \n\t" "punpcklbw %%xmm3, %%xmm2 \n\t" "pmaddubsw %%xmm7, %%xmm0 \n\t" "pmaddubsw %%xmm7, %%xmm2 \n\t" AVG_OP("movq (%0), %%xmm4 \n\t") AVG_OP("movhps (%0,%3), %%xmm4 \n\t") "paddw %%xmm6, %%xmm0 \n\t" "paddw %%xmm6, %%xmm2 \n\t" "psrlw $3, %%xmm0 \n\t" "psrlw $3, %%xmm2 \n\t" "packuswb %%xmm2, %%xmm0 \n\t" AVG_OP("pavgb %%xmm4, %%xmm0 \n\t") "movq %%xmm0, (%0) \n\t" "movhps %%xmm0, (%0,%3) \n\t" "sub $2, %2 \n\t" "lea (%1,%3,2), %1 \n\t" "lea (%0,%3,2), %0 \n\t" "jg 1b \n\t" :"+r"(dst), "+r"(src), "+r"(h) :"r"((long)stride) ); } return; } /* general case, bilinear */ asm volatile( "movd %0, %%xmm7 \n\t" "movd %1, %%xmm6 \n\t" "movdqa %2, %%xmm5 \n\t" "pshuflw $0, %%xmm7, %%xmm7 \n\t" "pshuflw $0, %%xmm6, %%xmm6 \n\t" "movlhps %%xmm7, %%xmm7 \n\t" "movlhps %%xmm6, %%xmm6 \n\t" :: "r"((x*255+8)*(8-y)), "r"((x*255+8)*y), "m"(rnd?ff_pw_32:ff_pw_28) ); asm volatile( "movq (%1), %%xmm0 \n\t" "movq 1(%1), %%xmm1 \n\t" "punpcklbw %%xmm1, %%xmm0 \n\t" "add %3, %1 \n\t" "1: \n\t" "movq (%1), %%xmm1 \n\t" "movq 1(%1), %%xmm2 \n\t" "movq (%1,%3), %%xmm3 \n\t" "movq 1(%1,%3), %%xmm4 \n\t" "lea (%1,%3,2), %1 \n\t" "punpcklbw %%xmm2, %%xmm1 \n\t" "punpcklbw %%xmm4, %%xmm3 \n\t" "movdqa %%xmm1, %%xmm2 \n\t" "movdqa %%xmm3, %%xmm4 \n\t" "pmaddubsw %%xmm7, %%xmm0 \n\t" "pmaddubsw %%xmm6, %%xmm1 \n\t" "pmaddubsw %%xmm7, %%xmm2 \n\t" "pmaddubsw %%xmm6, %%xmm3 \n\t" "paddw %%xmm5, %%xmm0 \n\t" "paddw %%xmm5, %%xmm2 \n\t" "paddw %%xmm0, %%xmm1 \n\t" "paddw %%xmm2, %%xmm3 \n\t" "movdqa %%xmm4, %%xmm0 \n\t" "psrlw $6, %%xmm1 \n\t" "psrlw $6, %%xmm3 \n\t" AVG_OP("movq (%0), %%xmm2 \n\t") AVG_OP("movhps (%0,%3), %%xmm2 \n\t") "packuswb %%xmm3, %%xmm1 \n\t" AVG_OP("pavgb %%xmm2, %%xmm1 \n\t") "movq %%xmm1, (%0)\n\t" "movhps %%xmm1, (%0,%3)\n\t" "sub $2, %2 \n\t" "lea (%0,%3,2), %0 \n\t" "jg 1b \n\t" :"+r"(dst), "+r"(src), "+r"(h) :"r"((long)stride) ); }
true
FFmpeg
96275520a383464ce9552ed727bd38dcb91d70fb
7,723
static void vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, unsigned idx) { int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_state state = { .index = vhost_vq_index, }; int r; r = dev->vhost_ops->vhost_get_vring_base(dev, &state); if (r < 0) { VHOST_OPS_DEBUG("vhost VQ %d ring restore failed: %d", idx, r); } else { virtio_queue_set_last_avail_idx(vdev, idx, state.num); } virtio_queue_invalidate_signalled_used(vdev, idx); virtio_queue_update_used_idx(vdev, idx); /* In the cross-endian case, we need to reset the vring endianness to * native as legacy devices expect so by default. if (vhost_needs_vring_endian(vdev)) { vhost_virtqueue_set_vring_endian_legacy(dev, !virtio_is_big_endian(vdev), vhost_vq_index); } vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx), 1, virtio_queue_get_used_size(vdev, idx)); vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, idx), 0, virtio_queue_get_avail_size(vdev, idx)); vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx), 0, virtio_queue_get_desc_size(vdev, idx)); }
true
qemu
2ae39a113af311cb56a0c35b7f212dafcef15303
7,724
BlockDeviceInfoList *bdrv_named_nodes_list(void) { BlockDeviceInfoList *list, *entry; BlockDriverState *bs; list = NULL; QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { entry = g_malloc0(sizeof(*entry)); entry->value = bdrv_block_device_info(bs); entry->next = list; list = entry; } return list; }
true
qemu
d5a8ee60a0fbc20a2c2d02f3bda1bb1bd365f1ee
7,725
void ff_put_h264_qpel16_mc01_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_qrt_16w_msa(src - (stride * 2), stride, dst, stride, 16, 0); }
false
FFmpeg
6796a1dd8c14843b77925cb83a3ef88706ae1dd0
7,726
int ff_thread_can_start_frame(AVCodecContext *avctx) { PerThreadContext *p = avctx->thread_opaque; if ((avctx->active_thread_type&FF_THREAD_FRAME) && p->state != STATE_SETTING_UP && (avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks && avctx->get_buffer != avcodec_default_get_buffer))) { return 0; } return 1; }
false
FFmpeg
97f8c6e14753b94c1f6a96fe354a125bbfdea2cb
7,727
static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, int width, int height, int bandpos) { int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y; int clnpass_cnt = 0; int bpass_csty_symbol = codsty->cblk_style & JPEG2000_CBLK_BYPASS; int vert_causal_ctx_csty_symbol = codsty->cblk_style & JPEG2000_CBLK_VSC; av_assert0(width <= JPEG2000_MAX_CBLKW); av_assert0(height <= JPEG2000_MAX_CBLKH); for (y = 0; y < height; y++) memset(t1->data[y], 0, width * sizeof(**t1->data)); /* If code-block contains no compressed data: nothing to do. */ if (!cblk->length) return 0; for (y = 0; y < height + 2; y++) memset(t1->flags[y], 0, (width + 2) * sizeof(**t1->flags)); cblk->data[cblk->length] = 0xff; cblk->data[cblk->length+1] = 0xff; ff_mqc_initdec(&t1->mqc, cblk->data); while (passno--) { switch(pass_t) { case 0: decode_sigpass(t1, width, height, bpno + 1, bandpos, bpass_csty_symbol && (clnpass_cnt >= 4), vert_causal_ctx_csty_symbol); break; case 1: decode_refpass(t1, width, height, bpno + 1); if (bpass_csty_symbol && clnpass_cnt >= 4) ff_mqc_initdec(&t1->mqc, cblk->data); break; case 2: decode_clnpass(s, t1, width, height, bpno + 1, bandpos, codsty->cblk_style & JPEG2000_CBLK_SEGSYM, vert_causal_ctx_csty_symbol); clnpass_cnt = clnpass_cnt + 1; if (bpass_csty_symbol && clnpass_cnt >= 4) ff_mqc_initdec(&t1->mqc, cblk->data); break; } pass_t++; if (pass_t == 3) { bpno--; pass_t = 0; } } return 0; }
false
FFmpeg
eea92133a16e7e0a837ad680afd4a05d08683a61
7,728
unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id) { int i; for(i=0; i<4 && tags[i]; i++){ int tag= codec_get_tag(tags[i], id); if(tag) return tag; } return 0; }
false
FFmpeg
6c77805fc84a63b74e5025b4d7eeea24c8138cf3
7,730
const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt) { if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB) return NULL; else return av_pix_fmt_descriptors[pix_fmt].name; }
false
FFmpeg
46db10ed0e04872eb9b003129f8395005c935ca4
7,731
static int decode_residual_block(AVSContext *h, GetBitContext *gb, const struct dec_2dvlc *r, int esc_golomb_order, int qp, uint8_t *dst, int stride) { int i, level_code, esc_code, level, run, mask; DCTELEM level_buf[65]; uint8_t run_buf[65]; DCTELEM *block = h->block; for(i=0;i<65;i++) { level_code = get_ue_code(gb,r->golomb_order); if(level_code >= ESCAPE_CODE) { run = ((level_code - ESCAPE_CODE) >> 1) + 1; esc_code = get_ue_code(gb,esc_golomb_order); level = esc_code + (run > r->max_run ? 1 : r->level_add[run]); while(level > r->inc_limit) r++; mask = -(level_code & 1); level = (level^mask) - mask; } else { level = r->rltab[level_code][0]; if(!level) //end of block signal break; run = r->rltab[level_code][1]; r += r->rltab[level_code][2]; } level_buf[i] = level; run_buf[i] = run; } if(dequant(h,level_buf, run_buf, block, ff_cavs_dequant_mul[qp], ff_cavs_dequant_shift[qp], i)) return -1; h->cdsp.cavs_idct8_add(dst,block,stride); h->s.dsp.clear_block(block); return 0; }
false
FFmpeg
6481a36010d8f7d834676f17ba555d0a3815c760
7,733
static void free_duplicate_context(MpegEncContext *s){ if(s==NULL) return; av_freep(&s->allocated_edge_emu_buffer); s->edge_emu_buffer= NULL; av_freep(&s->me.scratchpad); s->me.temp= s->rd_scratchpad= s->b_scratchpad= s->obmc_scratchpad= NULL; av_freep(&s->dct_error_sum); av_freep(&s->me.map); av_freep(&s->me.score_map); av_freep(&s->blocks); av_freep(&s->ac_val_base); s->block= NULL; }
true
FFmpeg
330deb75923675224fb9aed311d3d6ce3ec52420
7,734
int cpu_gen_code(CPUState *env, TranslationBlock *tb, int max_code_size, int *gen_code_size_ptr) { uint8_t *gen_code_buf; int gen_code_size; if (gen_intermediate_code(env, tb) < 0) return -1; /* generate machine code */ tb->tb_next_offset[0] = 0xffff; tb->tb_next_offset[1] = 0xffff; gen_code_buf = tb->tc_ptr; #ifdef USE_DIRECT_JUMP /* the following two entries are optional (only used for string ops) */ tb->tb_jmp_offset[2] = 0xffff; tb->tb_jmp_offset[3] = 0xffff; #endif dyngen_labels(gen_labels, nb_gen_labels, gen_code_buf, gen_opc_buf); gen_code_size = dyngen_code(gen_code_buf, tb->tb_next_offset, #ifdef USE_DIRECT_JUMP tb->tb_jmp_offset, #else NULL, #endif gen_opc_buf, gen_opparam_buf, gen_labels); *gen_code_size_ptr = gen_code_size; #ifdef DEBUG_DISAS if (loglevel & CPU_LOG_TB_OUT_ASM) { fprintf(logfile, "OUT: [size=%d]\n", *gen_code_size_ptr); disas(logfile, tb->tc_ptr, *gen_code_size_ptr); fprintf(logfile, "\n"); fflush(logfile); } #endif return 0; }
true
qemu
d07bde88a52bf293c3f8846cfd162e0a57e1557c
7,736
vnc_display_setup_auth(VncDisplay *vs, bool password, bool sasl, bool tls, bool x509, bool websocket) { /* * We have a choice of 3 authentication options * * 1. none * 2. vnc * 3. sasl * * The channel can be run in 2 modes * * 1. clear * 2. tls * * And TLS can use 2 types of credentials * * 1. anon * 2. x509 * * We thus have 9 possible logical combinations * * 1. clear + none * 2. clear + vnc * 3. clear + sasl * 4. tls + anon + none * 5. tls + anon + vnc * 6. tls + anon + sasl * 7. tls + x509 + none * 8. tls + x509 + vnc * 9. tls + x509 + sasl * * These need to be mapped into the VNC auth schemes * in an appropriate manner. In regular VNC, all the * TLS options get mapped into VNC_AUTH_VENCRYPT * sub-auth types. * * In websockets, the https:// protocol already provides * TLS support, so there is no need to make use of the * VeNCrypt extension. Furthermore, websockets browser * clients could not use VeNCrypt even if they wanted to, * as they cannot control when the TLS handshake takes * place. Thus there is no option but to rely on https://, * meaning combinations 4->6 and 7->9 will be mapped to * VNC auth schemes in the same way as combos 1->3. * * Regardless of fact that we have a different mapping to * VNC auth mechs for plain VNC vs websockets VNC, the end * result has the same security characteristics. */ if (password) { if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (websocket) { vs->ws_tls = true; } if (x509) { VNC_DEBUG("Initializing VNC server with x509 password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509VNC; } else { VNC_DEBUG("Initializing VNC server with TLS password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC; } } else { VNC_DEBUG("Initializing VNC server with password auth\n"); vs->auth = VNC_AUTH_VNC; vs->subauth = VNC_AUTH_INVALID; } if (websocket) { vs->ws_auth = VNC_AUTH_VNC; } else { vs->ws_auth = VNC_AUTH_INVALID; } } else if (sasl) { if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (websocket) { vs->ws_tls = true; } if (x509) { VNC_DEBUG("Initializing VNC server with x509 SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509SASL; } else { VNC_DEBUG("Initializing VNC server with TLS SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL; } } else { VNC_DEBUG("Initializing VNC server with SASL auth\n"); vs->auth = VNC_AUTH_SASL; vs->subauth = VNC_AUTH_INVALID; } if (websocket) { vs->ws_auth = VNC_AUTH_SASL; } else { vs->ws_auth = VNC_AUTH_INVALID; } } else { if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (websocket) { vs->ws_tls = true; } if (x509) { VNC_DEBUG("Initializing VNC server with x509 no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509NONE; } else { VNC_DEBUG("Initializing VNC server with TLS no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE; } } else { VNC_DEBUG("Initializing VNC server with no auth\n"); vs->auth = VNC_AUTH_NONE; vs->subauth = VNC_AUTH_INVALID; } if (websocket) { vs->ws_auth = VNC_AUTH_NONE; } else { vs->ws_auth = VNC_AUTH_INVALID; } } }
true
qemu
3e305e4a4752f70c0b5c3cf5b43ec957881714f7
7,737
static av_cold int peak_init_writer(AVFormatContext *s) { WAVMuxContext *wav = s->priv_data; AVCodecContext *enc = s->streams[0]->codec; if (enc->codec_id != AV_CODEC_ID_PCM_S8 && enc->codec_id != AV_CODEC_ID_PCM_S16LE && enc->codec_id != AV_CODEC_ID_PCM_U8 && enc->codec_id != AV_CODEC_ID_PCM_U16LE) { av_log(s, AV_LOG_ERROR, "%s codec not supported for Peak Chunk\n", s->streams[0]->codec->codec ? s->streams[0]->codec->codec->name : "NONE"); return -1; } wav->peak_bps = av_get_bits_per_sample(enc->codec_id) / 8; if (wav->peak_bps == 1 && wav->peak_format == PEAK_FORMAT_UINT16) { av_log(s, AV_LOG_ERROR, "Writing 16 bit peak for 8 bit audio does not make sense\n"); return AVERROR(EINVAL); } wav->peak_maxpos = av_mallocz(enc->channels * sizeof(*wav->peak_maxpos)); if (!wav->peak_maxpos) goto nomem; wav->peak_maxneg = av_mallocz(enc->channels * sizeof(*wav->peak_maxneg)); if (!wav->peak_maxneg) goto nomem; wav->peak_output = av_malloc(PEAK_BUFFER_SIZE); if (!wav->peak_output) goto nomem; wav->peak_outbuf_size = PEAK_BUFFER_SIZE; return 0; nomem: av_log(s, AV_LOG_ERROR, "Out of memory\n"); peak_free_buffers(s); return AVERROR(ENOMEM); }
true
FFmpeg
501158c682ceb7546d71209374dac406a7f43238
7,738
static int grow_refcount_table(BlockDriverState *bs, int min_size) { BDRVQcowState *s = bs->opaque; int new_table_size, new_table_size2, refcount_table_clusters, i, ret; uint64_t *new_table; int64_t table_offset; uint8_t data[12]; int old_table_size; int64_t old_table_offset; if (min_size <= s->refcount_table_size) return 0; /* compute new table size */ new_table_size = next_refcount_table_size(s, min_size); #ifdef DEBUG_ALLOC2 printf("grow_refcount_table from %d to %d\n", s->refcount_table_size, new_table_size); #endif new_table_size2 = new_table_size * sizeof(uint64_t); new_table = qemu_mallocz(new_table_size2); memcpy(new_table, s->refcount_table, s->refcount_table_size * sizeof(uint64_t)); for(i = 0; i < s->refcount_table_size; i++) cpu_to_be64s(&new_table[i]); /* Note: we cannot update the refcount now to avoid recursion */ table_offset = alloc_clusters_noref(bs, new_table_size2); ret = bdrv_pwrite(s->hd, table_offset, new_table, new_table_size2); if (ret != new_table_size2) goto fail; for(i = 0; i < s->refcount_table_size; i++) be64_to_cpus(&new_table[i]); cpu_to_be64w((uint64_t*)data, table_offset); cpu_to_be32w((uint32_t*)(data + 8), refcount_table_clusters); ret = bdrv_pwrite(s->hd, offsetof(QCowHeader, refcount_table_offset), data, sizeof(data)); if (ret != sizeof(data)) { goto fail; } qemu_free(s->refcount_table); old_table_offset = s->refcount_table_offset; old_table_size = s->refcount_table_size; s->refcount_table = new_table; s->refcount_table_size = new_table_size; s->refcount_table_offset = table_offset; update_refcount(bs, table_offset, new_table_size2, 1); qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t)); return 0; fail: qemu_free(new_table); return ret < 0 ? ret : -EIO; }
true
qemu
92dcb59fd4e1491afa0756ee9c2594869b487d23
7,739
static void vnc_dpy_switch(DisplayChangeListener *dcl, DisplaySurface *surface) { VncDisplay *vd = container_of(dcl, VncDisplay, dcl); VncState *vs; vnc_abort_display_jobs(vd); /* server surface */ qemu_pixman_image_unref(vd->server); vd->ds = surface; vd->server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT, surface_width(vd->ds), surface_height(vd->ds), NULL, 0); /* guest surface */ #if 0 /* FIXME */ if (ds_get_bytes_per_pixel(ds) != vd->guest.ds->pf.bytes_per_pixel) console_color_init(ds); #endif qemu_pixman_image_unref(vd->guest.fb); vd->guest.fb = pixman_image_ref(surface->image); vd->guest.format = surface->format; VNC_SET_VISIBLE_PIXELS_DIRTY(vd->guest.dirty, surface_width(vd->ds), surface_height(vd->ds)); QTAILQ_FOREACH(vs, &vd->clients, next) { vnc_colordepth(vs); vnc_desktop_resize(vs); if (vs->vd->cursor) { vnc_cursor_define(vs); } VNC_SET_VISIBLE_PIXELS_DIRTY(vs->dirty, surface_width(vd->ds), surface_height(vd->ds)); } }
true
qemu
bea60dd7679364493a0d7f5b54316c767cf894ef
7,740
static int parse_video_var(AVFormatContext *avctx, AVStream *st, const char *name, int size) { AVIOContext *pb = avctx->pb; if (!strcmp(name, "__DIR_COUNT")) { st->nb_frames = st->duration = var_read_int(pb, size); } else if (!strcmp(name, "COMPRESSION")) { char * str = var_read_string(pb, size); if (!strcmp(str, "1")) { st->codec->codec_id = AV_CODEC_ID_MVC1; } else if (!strcmp(str, "2")) { st->codec->pix_fmt = AV_PIX_FMT_ABGR; st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; } else if (!strcmp(str, "3")) { st->codec->codec_id = AV_CODEC_ID_SGIRLE; } else if (!strcmp(str, "10")) { st->codec->codec_id = AV_CODEC_ID_MJPEG; } else if (!strcmp(str, "MVC2")) { st->codec->codec_id = AV_CODEC_ID_MVC2; } else { av_log_ask_for_sample(avctx, "unknown video compression %s\n", str); } av_free(str); } else if (!strcmp(name, "FPS")) { st->time_base = av_inv_q(var_read_float(pb, size)); } else if (!strcmp(name, "HEIGHT")) { st->codec->height = var_read_int(pb, size); } else if (!strcmp(name, "PIXEL_ASPECT")) { st->sample_aspect_ratio = var_read_float(pb, size); av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, INT_MAX); } else if (!strcmp(name, "WIDTH")) { st->codec->width = var_read_int(pb, size); } else if (!strcmp(name, "ORIENTATION")) { if (var_read_int(pb, size) == 1101) { st->codec->extradata = av_strdup("BottomUp"); st->codec->extradata_size = 9; } } else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) { var_read_metadata(avctx, name, size); } else if (!strcmp(name, "INTERLACING") || !strcmp(name, "PACKING")) { avio_skip(pb, size); // ignore } else return -1; return 0; }
true
FFmpeg
4c9f35bb7c94d20455d3fca3a184b892f1a0aa4e
7,741
static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, UHCI_TD *td, uint32_t td_addr, uint32_t *int_mask) { int ret, max_len; bool spd; bool queuing = (q != NULL); uint8_t pid = td->token & 0xff; UHCIAsync *async; switch (pid) { case USB_TOKEN_OUT: case USB_TOKEN_SETUP: case USB_TOKEN_IN: break; default: /* invalid pid : frame interrupted */ s->status |= UHCI_STS_HCPERR; s->cmd &= ~UHCI_CMD_RS; uhci_update_irq(s); return TD_RESULT_STOP_FRAME; } async = uhci_async_find_td(s, td_addr); if (async) { if (uhci_queue_verify(async->queue, qh_addr, td, td_addr, queuing)) { assert(q == NULL || q == async->queue); q = async->queue; } else { uhci_queue_free(async->queue, "guest re-used pending td"); async = NULL; } } if (q == NULL) { q = uhci_queue_find(s, td); if (q && !uhci_queue_verify(q, qh_addr, td, td_addr, queuing)) { uhci_queue_free(q, "guest re-used qh"); q = NULL; } } if (q) { q->valid = QH_VALID; } /* Is active ? */ if (!(td->ctrl & TD_CTRL_ACTIVE)) { if (async) { /* Guest marked a pending td non-active, cancel the queue */ uhci_queue_free(async->queue, "pending td non-active"); } /* * ehci11d spec page 22: "Even if the Active bit in the TD is already * cleared when the TD is fetched ... an IOC interrupt is generated" */ if (td->ctrl & TD_CTRL_IOC) { *int_mask |= 0x01; } return TD_RESULT_NEXT_QH; } if (async) { if (queuing) { /* we are busy filling the queue, we are not prepared to consume completed packages then, just leave them in async state */ return TD_RESULT_ASYNC_CONT; } if (!async->done) { UHCI_TD last_td; UHCIAsync *last = QTAILQ_LAST(&async->queue->asyncs, asyncs_head); /* * While we are waiting for the current td to complete, the guest * may have added more tds to the queue. Note we re-read the td * rather then caching it, as we want to see guest made changes! */ uhci_read_td(s, &last_td, last->td_addr); uhci_queue_fill(async->queue, &last_td); return TD_RESULT_ASYNC_CONT; } uhci_async_unlink(async); goto done; } if (s->completions_only) { return TD_RESULT_ASYNC_CONT; } /* Allocate new packet */ if (q == NULL) { USBDevice *dev = uhci_find_device(s, (td->token >> 8) & 0x7f); USBEndpoint *ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf); if (ep == NULL) { return uhci_handle_td_error(s, td, td_addr, USB_RET_NODEV, int_mask); } q = uhci_queue_new(s, qh_addr, td, ep); } async = uhci_async_alloc(q, td_addr); max_len = ((td->token >> 21) + 1) & 0x7ff; spd = (pid == USB_TOKEN_IN && (td->ctrl & TD_CTRL_SPD) != 0); usb_packet_setup(&async->packet, pid, q->ep, 0, td_addr, spd, (td->ctrl & TD_CTRL_IOC) != 0); if (max_len <= sizeof(async->static_buf)) { async->buf = async->static_buf; } else { async->buf = g_malloc(max_len); } usb_packet_addbuf(&async->packet, async->buf, max_len); switch(pid) { case USB_TOKEN_OUT: case USB_TOKEN_SETUP: pci_dma_read(&s->dev, td->buffer, async->buf, max_len); usb_handle_packet(q->ep->dev, &async->packet); if (async->packet.status == USB_RET_SUCCESS) { async->packet.actual_length = max_len; } break; case USB_TOKEN_IN: usb_handle_packet(q->ep->dev, &async->packet); break; default: abort(); /* Never to execute */ } if (async->packet.status == USB_RET_ASYNC) { uhci_async_link(async); if (!queuing) { uhci_queue_fill(q, td); } return TD_RESULT_ASYNC_START; } done: ret = uhci_complete_td(s, td, async, int_mask); uhci_async_free(async); return ret; }
true
qemu
f419a626c76bcb26697883af702862e8623056f9
7,742
void do_405_check_ov (void) { if (likely(((T1 ^ T2) >> 31) || !((T0 ^ T2) >> 31))) { xer_ov = 0; } else { xer_ov = 1; xer_so = 1; } }
true
qemu
d9bce9d99f4656ae0b0127f7472db9067b8f84ab
7,743
static int milkymist_minimac2_init(SysBusDevice *sbd) { DeviceState *dev = DEVICE(sbd); MilkymistMinimac2State *s = MILKYMIST_MINIMAC2(dev); size_t buffers_size = TARGET_PAGE_ALIGN(3 * MINIMAC2_BUFFER_SIZE); sysbus_init_irq(sbd, &s->rx_irq); sysbus_init_irq(sbd, &s->tx_irq); memory_region_init_io(&s->regs_region, OBJECT(dev), &minimac2_ops, s, "milkymist-minimac2", R_MAX * 4); sysbus_init_mmio(sbd, &s->regs_region); /* register buffers memory */ memory_region_init_ram(&s->buffers, OBJECT(dev), "milkymist-minimac2.buffers", buffers_size, &error_abort); vmstate_register_ram_global(&s->buffers); s->rx0_buf = memory_region_get_ram_ptr(&s->buffers); s->rx1_buf = s->rx0_buf + MINIMAC2_BUFFER_SIZE; s->tx_buf = s->rx1_buf + MINIMAC2_BUFFER_SIZE; sysbus_init_mmio(sbd, &s->buffers); qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic = qemu_new_nic(&net_milkymist_minimac2_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); return 0; }
true
qemu
f8ed85ac992c48814d916d5df4d44f9a971c5de4
7,744
static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc) { int addr_reg, data_reg, data_reg2, r0, r1, rbase, bswap; #ifdef CONFIG_SOFTMMU int mem_index, s_bits, r2, addr_reg2; uint8_t *label_ptr; #endif data_reg = *args++; if (opc == 3) data_reg2 = *args++; else data_reg2 = 0; addr_reg = *args++; #ifdef CONFIG_SOFTMMU #if TARGET_LONG_BITS == 64 addr_reg2 = *args++; #else addr_reg2 = 0; #endif mem_index = *args; s_bits = opc & 3; r0 = 3; r1 = 4; r2 = 0; rbase = 0; tcg_out_tlb_check ( s, r0, r1, r2, addr_reg, addr_reg2, s_bits, offsetof (CPUArchState, tlb_table[mem_index][0].addr_read), offsetof (CPUTLBEntry, addend) - offsetof (CPUTLBEntry, addr_read), &label_ptr ); #else /* !CONFIG_SOFTMMU */ r0 = addr_reg; r1 = 3; rbase = GUEST_BASE ? TCG_GUEST_BASE_REG : 0; #endif #ifdef TARGET_WORDS_BIGENDIAN bswap = 0; #else bswap = 1; #endif switch (opc) { default: case 0: tcg_out32 (s, LBZX | TAB (data_reg, rbase, r0)); break; case 0|4: tcg_out32 (s, LBZX | TAB (data_reg, rbase, r0)); tcg_out32 (s, EXTSB | RA (data_reg) | RS (data_reg)); break; case 1: if (bswap) tcg_out32 (s, LHBRX | TAB (data_reg, rbase, r0)); else tcg_out32 (s, LHZX | TAB (data_reg, rbase, r0)); break; case 1|4: if (bswap) { tcg_out32 (s, LHBRX | TAB (data_reg, rbase, r0)); tcg_out32 (s, EXTSH | RA (data_reg) | RS (data_reg)); } else tcg_out32 (s, LHAX | TAB (data_reg, rbase, r0)); break; case 2: if (bswap) tcg_out32 (s, LWBRX | TAB (data_reg, rbase, r0)); else tcg_out32 (s, LWZX | TAB (data_reg, rbase, r0)); break; case 3: if (bswap) { tcg_out32 (s, ADDI | RT (r1) | RA (r0) | 4); tcg_out32 (s, LWBRX | TAB (data_reg, rbase, r0)); tcg_out32 (s, LWBRX | TAB (data_reg2, rbase, r1)); } else { #ifdef CONFIG_USE_GUEST_BASE tcg_out32 (s, ADDI | RT (r1) | RA (r0) | 4); tcg_out32 (s, LWZX | TAB (data_reg2, rbase, r0)); tcg_out32 (s, LWZX | TAB (data_reg, rbase, r1)); #else if (r0 == data_reg2) { tcg_out32 (s, LWZ | RT (0) | RA (r0)); tcg_out32 (s, LWZ | RT (data_reg) | RA (r0) | 4); tcg_out_mov (s, TCG_TYPE_I32, data_reg2, 0); } else { tcg_out32 (s, LWZ | RT (data_reg2) | RA (r0)); tcg_out32 (s, LWZ | RT (data_reg) | RA (r0) | 4); } #endif } break; } #ifdef CONFIG_SOFTMMU add_qemu_ldst_label (s, 1, opc, data_reg, data_reg2, addr_reg, addr_reg2, mem_index, s->code_ptr, label_ptr); #endif }
true
qemu
8f50c841b374dc90ea604888ca92c37f469c428a
7,746
static int url_connect(struct variant *var, AVDictionary *opts) { AVDictionary *tmp = NULL; int ret; av_dict_copy(&tmp, opts, 0); av_opt_set_dict(var->input, &tmp); if ((ret = ffurl_connect(var->input, NULL)) < 0) { ffurl_close(var->input); var->input = NULL; } av_dict_free(&tmp); return ret; }
false
FFmpeg
74942685cb457c01937686892878403a409baf27
7,747
void test_self_modifying_code(void) { int (*func)(void); func = (void *)code; printf("self modifying code:\n"); printf("func1 = 0x%x\n", func()); code[1] = 0x2; printf("func1 = 0x%x\n", func()); }
false
qemu
d1fe2b245910d42715e556458afe7d975d9417ef
7,748
static void fdt_add_psci_node(const VirtBoardInfo *vbi) { void *fdt = vbi->fdt; ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(0)); /* No PSCI for TCG yet */ if (kvm_enabled()) { qemu_fdt_add_subnode(fdt, "/psci"); if (armcpu->psci_version == 2) { const char comp[] = "arm,psci-0.2\0arm,psci"; qemu_fdt_setprop(fdt, "/psci", "compatible", comp, sizeof(comp)); } else { qemu_fdt_setprop_string(fdt, "/psci", "compatible", "arm,psci"); } qemu_fdt_setprop_string(fdt, "/psci", "method", "hvc"); qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend", QEMU_PSCI_0_1_FN_CPU_SUSPEND); qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off", QEMU_PSCI_0_1_FN_CPU_OFF); qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on", QEMU_PSCI_0_1_FN_CPU_ON); qemu_fdt_setprop_cell(fdt, "/psci", "migrate", QEMU_PSCI_0_1_FN_MIGRATE); } }
false
qemu
863714ba6cdc09d1a84069815dc67c8da66b0a29
7,750
static uint64_t ppc_radix64_walk_tree(PowerPCCPU *cpu, int rwx, vaddr eaddr, uint64_t base_addr, uint64_t nls, hwaddr *raddr, int *psize, int *fault_cause, int *prot, hwaddr *pte_addr) { CPUState *cs = CPU(cpu); uint64_t index, pde; if (nls < 5) { /* Directory maps less than 2**5 entries */ *fault_cause |= DSISR_R_BADCONFIG; return 0; } /* Read page <directory/table> entry from guest address space */ index = eaddr >> (*psize - nls); /* Shift */ index &= ((1UL << nls) - 1); /* Mask */ pde = ldq_phys(cs->as, base_addr + (index * sizeof(pde))); if (!(pde & R_PTE_VALID)) { /* Invalid Entry */ *fault_cause |= DSISR_NOPTE; return 0; } *psize -= nls; /* Check if Leaf Entry -> Page Table Entry -> Stop the Search */ if (pde & R_PTE_LEAF) { uint64_t rpn = pde & R_PTE_RPN; uint64_t mask = (1UL << *psize) - 1; if (ppc_radix64_check_prot(cpu, rwx, pde, fault_cause, prot)) { return 0; /* Protection Denied Access */ } /* Or high bits of rpn and low bits to ea to form whole real addr */ *raddr = (rpn & ~mask) | (eaddr & mask); *pte_addr = base_addr + (index * sizeof(pde)); return pde; } /* Next Level of Radix Tree */ return ppc_radix64_walk_tree(cpu, rwx, eaddr, pde & R_PDE_NLB, pde & R_PDE_NLS, raddr, psize, fault_cause, prot, pte_addr); }
false
qemu
6a042827b638dc73da6a72c72596f5be80bd4581
7,751
static int cpu_mips_register (CPUMIPSState *env, const mips_def_t *def) { env->CP0_PRid = def->CP0_PRid; env->CP0_Config0 = def->CP0_Config0; #ifdef TARGET_WORDS_BIGENDIAN env->CP0_Config0 |= (1 << CP0C0_BE); #endif env->CP0_Config1 = def->CP0_Config1; env->CP0_Config2 = def->CP0_Config2; env->CP0_Config3 = def->CP0_Config3; env->CP0_Config6 = def->CP0_Config6; env->CP0_Config7 = def->CP0_Config7; env->SYNCI_Step = def->SYNCI_Step; env->CCRes = def->CCRes; env->CP0_Status_rw_bitmask = def->CP0_Status_rw_bitmask; env->CP0_TCStatus_rw_bitmask = def->CP0_TCStatus_rw_bitmask; env->CP0_SRSCtl = def->CP0_SRSCtl; env->current_tc = 0; env->SEGBITS = def->SEGBITS; env->SEGMask = (target_ulong)((1ULL << def->SEGBITS) - 1); #if defined(TARGET_MIPS64) if (def->insn_flags & ISA_MIPS3) { env->hflags |= MIPS_HFLAG_64; env->SEGMask |= 3ULL << 62; } #endif env->PABITS = def->PABITS; env->PAMask = (target_ulong)((1ULL << def->PABITS) - 1); env->CP0_SRSConf0_rw_bitmask = def->CP0_SRSConf0_rw_bitmask; env->CP0_SRSConf0 = def->CP0_SRSConf0; env->CP0_SRSConf1_rw_bitmask = def->CP0_SRSConf1_rw_bitmask; env->CP0_SRSConf1 = def->CP0_SRSConf1; env->CP0_SRSConf2_rw_bitmask = def->CP0_SRSConf2_rw_bitmask; env->CP0_SRSConf2 = def->CP0_SRSConf2; env->CP0_SRSConf3_rw_bitmask = def->CP0_SRSConf3_rw_bitmask; env->CP0_SRSConf3 = def->CP0_SRSConf3; env->CP0_SRSConf4_rw_bitmask = def->CP0_SRSConf4_rw_bitmask; env->CP0_SRSConf4 = def->CP0_SRSConf4; env->insn_flags = def->insn_flags; #ifndef CONFIG_USER_ONLY if (!env->user_mode_only) mmu_init(env, def); #endif fpu_init(env, def); mvp_init(env, def); return 0; }
false
qemu
932e71cd57bab4e6206e1355c6425290721bbe34
7,752
static void scsi_write_do_fua(SCSIDiskReq *r) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); if (r->req.io_canceled) { scsi_req_cancel_complete(&r->req); goto done; } if (scsi_is_cmd_fua(&r->req.cmd)) { block_acct_start(bdrv_get_stats(s->qdev.conf.bs), &r->acct, 0, BLOCK_ACCT_FLUSH); r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r); return; } scsi_req_complete(&r->req, GOOD); done: scsi_req_unref(&r->req); }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
7,753
static uint32_t m5206_mbar_readb(void *opaque, target_phys_addr_t offset) { m5206_mbar_state *s = (m5206_mbar_state *)opaque; offset &= 0x3ff; if (offset >= 0x200) { hw_error("Bad MBAR read offset 0x%x", (int)offset); } if (m5206_mbar_width[offset >> 2] > 1) { uint16_t val; val = m5206_mbar_readw(opaque, offset & ~1); if ((offset & 1) == 0) { val >>= 8; } return val & 0xff; } return m5206_mbar_read(s, offset, 1); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
7,755
void HELPER(mvpg)(CPUS390XState *env, uint64_t r0, uint64_t r1, uint64_t r2) { /* XXX missing r0 handling */ env->cc_op = 0; #ifdef CONFIG_USER_ONLY memmove(g2h(r1), g2h(r2), TARGET_PAGE_SIZE); #else mvc_fast_memmove(env, TARGET_PAGE_SIZE, r1, r2); #endif }
false
qemu
6da528d14de29138ca5ac43d6d059889dd24f464
7,756
int64_t qmp_guest_fsfreeze_thaw(Error **err) { int ret; GuestFsfreezeMountList mounts; GuestFsfreezeMount *mount; int fd, i = 0, logged; QTAILQ_INIT(&mounts); ret = guest_fsfreeze_build_mount_list(&mounts); if (ret) { error_set(err, QERR_QGA_COMMAND_FAILED, "failed to enumerate filesystems"); return 0; } QTAILQ_FOREACH(mount, &mounts, next) { logged = false; fd = qemu_open(mount->dirname, O_RDONLY); if (fd == -1) { continue; } /* we have no way of knowing whether a filesystem was actually unfrozen * as a result of a successful call to FITHAW, only that if an error * was returned the filesystem was *not* unfrozen by that particular * call. * * since multiple preceeding FIFREEZEs require multiple calls to FITHAW * to unfreeze, continuing issuing FITHAW until an error is returned, * in which case either the filesystem is in an unfreezable state, or, * more likely, it was thawed previously (and remains so afterward). * * also, since the most recent successful call is the one that did * the actual unfreeze, we can use this to provide an accurate count * of the number of filesystems unfrozen by guest-fsfreeze-thaw, which * may * be useful for determining whether a filesystem was unfrozen * during the freeze/thaw phase by a process other than qemu-ga. */ do { ret = ioctl(fd, FITHAW); if (ret == 0 && !logged) { i++; logged = true; } } while (ret == 0); close(fd); } guest_fsfreeze_state.status = GUEST_FSFREEZE_STATUS_THAWED; enable_logging(); guest_fsfreeze_free_mount_list(&mounts); return i; }
false
qemu
f22d85e9e67262db34504f4079745f9843da6a92
7,757
static av_cold int xwd_encode_init(AVCodecContext *avctx) { avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); return 0; }
false
FFmpeg
d6604b29ef544793479d7fb4e05ef6622bb3e534
7,758
bool cpu_exec_all(void) { int ret = 0; if (next_cpu == NULL) next_cpu = first_cpu; for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) { CPUState *env = next_cpu; qemu_clock_enable(vm_clock, (env->singlestep_enabled & SSTEP_NOTIMER) == 0); if (qemu_alarm_pending()) break; if (cpu_can_run(env)) ret = qemu_cpu_exec(env); else if (env->stop) break; if (ret == EXCP_DEBUG) { gdb_set_stop_cpu(env); debug_requested = EXCP_DEBUG; break; } } exit_request = 0; return any_cpu_has_work(); }
false
qemu
3c638d0690a0b21c6acef7ce3132f821d8c1e25d
7,759
static inline void *alloc_code_gen_buffer(void) { int flags = MAP_PRIVATE | MAP_ANONYMOUS; uintptr_t start = 0; size_t size = tcg_ctx.code_gen_buffer_size; void *buf; /* Constrain the position of the buffer based on the host cpu. Note that these addresses are chosen in concert with the addresses assigned in the relevant linker script file. */ # if defined(__PIE__) || defined(__PIC__) /* Don't bother setting a preferred location if we're building a position-independent executable. We're more likely to get an address near the main executable if we let the kernel choose the address. */ # elif defined(__x86_64__) && defined(MAP_32BIT) /* Force the memory down into low memory with the executable. Leave the choice of exact location with the kernel. */ flags |= MAP_32BIT; /* Cannot expect to map more than 800MB in low memory. */ if (size > 800u * 1024 * 1024) { tcg_ctx.code_gen_buffer_size = size = 800u * 1024 * 1024; } # elif defined(__sparc__) start = 0x40000000ul; # elif defined(__s390x__) start = 0x90000000ul; # elif defined(__mips__) # if _MIPS_SIM == _ABI64 start = 0x128000000ul; # else start = 0x08000000ul; # endif # endif buf = mmap((void *)start, size + qemu_real_host_page_size, PROT_NONE, flags, -1, 0); if (buf == MAP_FAILED) { return NULL; } #ifdef __mips__ if (cross_256mb(buf, size)) { /* Try again, with the original still mapped, to avoid re-acquiring that 256mb crossing. This time don't specify an address. */ size_t size2; void *buf2 = mmap(NULL, size + qemu_real_host_page_size, PROT_NONE, flags, -1, 0); switch (buf2 != MAP_FAILED) { case 1: if (!cross_256mb(buf2, size)) { /* Success! Use the new buffer. */ munmap(buf, size); break; } /* Failure. Work with what we had. */ munmap(buf2, size); /* fallthru */ default: /* Split the original buffer. Free the smaller half. */ buf2 = split_cross_256mb(buf, size); size2 = tcg_ctx.code_gen_buffer_size; if (buf == buf2) { munmap(buf + size2 + qemu_real_host_page_size, size - size2); } else { munmap(buf, size - size2); } size = size2; break; } buf = buf2; } #endif /* Make the final buffer accessible. The guard page at the end will remain inaccessible with PROT_NONE. */ mprotect(buf, size, PROT_WRITE | PROT_READ | PROT_EXEC); /* Request large pages for the buffer. */ qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); return buf; }
false
qemu
8bdf4997823126a39bd4c99e4b2283b02cc7865f
7,760
size_t iov_from_buf(struct iovec *iov, unsigned int iov_cnt, size_t iov_off, const void *buf, size_t size) { size_t iovec_off, buf_off; unsigned int i; iovec_off = 0; buf_off = 0; for (i = 0; i < iov_cnt && size; i++) { if (iov_off < (iovec_off + iov[i].iov_len)) { size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off, size); memcpy(iov[i].iov_base + (iov_off - iovec_off), buf + buf_off, len); buf_off += len; iov_off += len; size -= len; } iovec_off += iov[i].iov_len; } return buf_off; }
false
qemu
2278a69e7020d86a8c73a28474e7709d3e7d5081
7,763
static int eth_can_rx(NetClientState *nc) { struct xlx_ethlite *s = DO_UPCAST(NICState, nc, nc)->opaque; int r; r = !(s->regs[R_RX_CTRL0] & CTRL_S); return r; }
false
qemu
808fb9f277abda16601e9db938d29aeaf2548585
7,764
static uint64_t exynos4210_pmu_read(void *opaque, target_phys_addr_t offset, unsigned size) { Exynos4210PmuState *s = (Exynos4210PmuState *)opaque; unsigned i; const Exynos4210PmuReg *reg_p = exynos4210_pmu_regs; for (i = 0; i < PMU_NUM_OF_REGISTERS; i++) { if (reg_p->offset == offset) { PRINT_DEBUG_EXTEND("%s [0x%04x] -> 0x%04x\n", reg_p->name, (uint32_t)offset, s->reg[i]); return s->reg[i]; } reg_p++; } PRINT_DEBUG("QEMU PMU ERROR: bad read offset 0x%04x\n", (uint32_t)offset); return 0; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
7,765
static void simple_number(void) { int i; struct { const char *encoded; int64_t decoded; int skip; } test_cases[] = { { "0", 0 }, { "1234", 1234 }, { "1", 1 }, { "-32", -32 }, { "-0", 0, .skip = 1 }, { }, }; for (i = 0; test_cases[i].encoded; i++) { QObject *obj; QInt *qint; obj = qobject_from_json(test_cases[i].encoded); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QINT); qint = qobject_to_qint(obj); g_assert(qint_get_int(qint) == test_cases[i].decoded); if (test_cases[i].skip == 0) { QString *str; str = qobject_to_json(obj); g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0); QDECREF(str); } QDECREF(qint); } }
false
qemu
0abfc4b885566eb41c3a4e1de5e2e105bdc062d9
7,767
static int check_exception(int intno, int *error_code) { int first_contributory = env->old_exception == 0 || (env->old_exception >= 10 && env->old_exception <= 13); int second_contributory = intno == 0 || (intno >= 10 && intno <= 13); qemu_log_mask(CPU_LOG_INT, "check_exception old: 0x%x new 0x%x\n", env->old_exception, intno); if (env->old_exception == EXCP08_DBLE) cpu_abort(env, "triple fault"); if ((first_contributory && second_contributory) || (env->old_exception == EXCP0E_PAGE && (second_contributory || (intno == EXCP0E_PAGE)))) { intno = EXCP08_DBLE; *error_code = 0; } if (second_contributory || (intno == EXCP0E_PAGE) || (intno == EXCP08_DBLE)) env->old_exception = intno; return intno; }
true
qemu
f55761a0c46583f4faf1d7595f4f41b35b15508b
7,768
yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0, const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf0, uint16_t *dest, int dstW, int uvalpha, int y, enum PixelFormat target) { const int32_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; int i; if (uvalpha < 2048) { for (i = 0; i < (dstW >> 1); i++) { int Y1 = (buf0[i * 2] ) >> 2; int Y2 = (buf0[i * 2 + 1]) >> 2; int U = (ubuf0[i] + (-128 << 11)) >> 2; int V = (vbuf0[i] + (-128 << 11)) >> 2; int R, G, B; Y1 -= c->yuv2rgb_y_offset; Y2 -= c->yuv2rgb_y_offset; Y1 *= c->yuv2rgb_y_coeff; Y2 *= c->yuv2rgb_y_coeff; Y1 += 1 << 13; Y2 += 1 << 13; R = V * c->yuv2rgb_v2r_coeff; G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; B = U * c->yuv2rgb_u2b_coeff; output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); dest += 6; } } else { for (i = 0; i < (dstW >> 1); i++) { int Y1 = (buf0[i * 2] ) >> 2; int Y2 = (buf0[i * 2 + 1]) >> 2; int U = (ubuf0[i] + ubuf1[i] + (-128 << 11)) >> 3; int V = (vbuf0[i] + vbuf1[i] + (-128 << 11)) >> 3; int R, G, B; Y1 -= c->yuv2rgb_y_offset; Y2 -= c->yuv2rgb_y_offset; Y1 *= c->yuv2rgb_y_coeff; Y2 *= c->yuv2rgb_y_coeff; Y1 += 1 << 13; Y2 += 1 << 13; R = V * c->yuv2rgb_v2r_coeff; G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; B = U * c->yuv2rgb_u2b_coeff; output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); dest += 6; } } }
true
FFmpeg
1ca7dc60d2f2cac8fce1bdb53d3d5bae195161b0
7,769
static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor) { int code, value, ofs = 0; char layout[16] = {0}; /* not for printing, may end up not terminated on purpose */ do { code = avio_r8(pb); value = avio_r8(pb); av_dlog(NULL, "pixel layout: code %#x\n", code); if (ofs <= 14) { layout[ofs++] = code; layout[ofs++] = value; } } while (code != 0); /* SMPTE 377M E.2.46 */ ff_mxf_decode_pixel_layout(layout, &descriptor->pix_fmt); }
true
FFmpeg
1d22d269f54cc7e44f778bb6ffee96a172eb07a1
7,771
static av_always_inline void rv40_weak_loop_filter(uint8_t *src, const int step, const ptrdiff_t stride, const int filter_p1, const int filter_q1, const int alpha, const int beta, const int lim_p0q0, const int lim_q1, const int lim_p1) { const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; int i, t, u, diff; for (i = 0; i < 4; i++, src += stride) { int diff_p1p0 = src[-2*step] - src[-1*step]; int diff_q1q0 = src[ 1*step] - src[ 0*step]; int diff_p1p2 = src[-2*step] - src[-3*step]; int diff_q1q2 = src[ 1*step] - src[ 2*step]; t = src[0*step] - src[-1*step]; if (!t) continue; u = (alpha * FFABS(t)) >> 7; if (u > 3 - (filter_p1 && filter_q1)) continue; t <<= 2; if (filter_p1 && filter_q1) t += src[-2*step] - src[1*step]; diff = CLIP_SYMM((t + 4) >> 3, lim_p0q0); src[-1*step] = cm[src[-1*step] + diff]; src[ 0*step] = cm[src[ 0*step] - diff]; if (filter_p1 && FFABS(diff_p1p2) <= beta) { t = (diff_p1p0 + diff_p1p2 - diff) >> 1; src[-2*step] = cm[src[-2*step] - CLIP_SYMM(t, lim_p1)]; } if (filter_q1 && FFABS(diff_q1q2) <= beta) { t = (diff_q1q0 + diff_q1q2 + diff) >> 1; src[ 1*step] = cm[src[ 1*step] - CLIP_SYMM(t, lim_q1)]; } } }
true
FFmpeg
956472a3236cc8eaeba5147c55b51bde6005c898
7,773
static int tak_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *pkt) { TAKDecContext *s = avctx->priv_data; AVFrame *frame = data; ThreadFrame tframe = { .f = data }; GetBitContext *gb = &s->gb; int chan, i, ret, hsize; if (pkt->size < TAK_MIN_FRAME_HEADER_BYTES) return AVERROR_INVALIDDATA; if ((ret = init_get_bits8(gb, pkt->data, pkt->size)) < 0) return ret; if ((ret = ff_tak_decode_frame_header(avctx, gb, &s->ti, 0)) < 0) return ret; hsize = get_bits_count(gb) / 8; if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_COMPLIANT)) { if (ff_tak_check_crc(pkt->data, hsize)) { av_log(avctx, AV_LOG_ERROR, "CRC error\n"); if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } } if (s->ti.codec != TAK_CODEC_MONO_STEREO && s->ti.codec != TAK_CODEC_MULTICHANNEL) { avpriv_report_missing_feature(avctx, "TAK codec type %d", s->ti.codec); return AVERROR_PATCHWELCOME; } if (s->ti.data_type) { av_log(avctx, AV_LOG_ERROR, "unsupported data type: %d\n", s->ti.data_type); return AVERROR_INVALIDDATA; } if (s->ti.codec == TAK_CODEC_MONO_STEREO && s->ti.channels > 2) { av_log(avctx, AV_LOG_ERROR, "invalid number of channels: %d\n", s->ti.channels); return AVERROR_INVALIDDATA; } if (s->ti.channels > 6) { av_log(avctx, AV_LOG_ERROR, "unsupported number of channels: %d\n", s->ti.channels); return AVERROR_INVALIDDATA; } if (s->ti.frame_samples <= 0) { av_log(avctx, AV_LOG_ERROR, "unsupported/invalid number of samples\n"); return AVERROR_INVALIDDATA; } avctx->bits_per_raw_sample = s->ti.bps; if ((ret = set_bps_params(avctx)) < 0) return ret; if (s->ti.sample_rate != avctx->sample_rate) { avctx->sample_rate = s->ti.sample_rate; set_sample_rate_params(avctx); } if (s->ti.ch_layout) avctx->channel_layout = s->ti.ch_layout; avctx->channels = s->ti.channels; s->nb_samples = s->ti.last_frame_samples ? s->ti.last_frame_samples : s->ti.frame_samples; frame->nb_samples = s->nb_samples; if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0) return ret; ff_thread_finish_setup(avctx); if (avctx->bits_per_raw_sample <= 16) { int buf_size = av_samples_get_buffer_size(NULL, avctx->channels, s->nb_samples, AV_SAMPLE_FMT_S32P, 0); if (buf_size < 0) return buf_size; av_fast_malloc(&s->decode_buffer, &s->decode_buffer_size, buf_size); if (!s->decode_buffer) return AVERROR(ENOMEM); ret = av_samples_fill_arrays((uint8_t **)s->decoded, NULL, s->decode_buffer, avctx->channels, s->nb_samples, AV_SAMPLE_FMT_S32P, 0); if (ret < 0) return ret; } else { for (chan = 0; chan < avctx->channels; chan++) s->decoded[chan] = (int32_t *)frame->extended_data[chan]; } if (s->nb_samples < 16) { for (chan = 0; chan < avctx->channels; chan++) { int32_t *decoded = s->decoded[chan]; for (i = 0; i < s->nb_samples; i++) decoded[i] = get_sbits(gb, avctx->bits_per_raw_sample); } } else { if (s->ti.codec == TAK_CODEC_MONO_STEREO) { for (chan = 0; chan < avctx->channels; chan++) if (ret = decode_channel(s, chan)) return ret; if (avctx->channels == 2) { s->nb_subframes = get_bits(gb, 1) + 1; if (s->nb_subframes > 1) { s->subframe_len[1] = get_bits(gb, 6); } s->dmode = get_bits(gb, 3); if (ret = decorrelate(s, 0, 1, s->nb_samples - 1)) return ret; } } else if (s->ti.codec == TAK_CODEC_MULTICHANNEL) { if (get_bits1(gb)) { int ch_mask = 0; chan = get_bits(gb, 4) + 1; if (chan > avctx->channels) return AVERROR_INVALIDDATA; for (i = 0; i < chan; i++) { int nbit = get_bits(gb, 4); if (nbit >= avctx->channels) return AVERROR_INVALIDDATA; if (ch_mask & 1 << nbit) return AVERROR_INVALIDDATA; s->mcdparams[i].present = get_bits1(gb); if (s->mcdparams[i].present) { s->mcdparams[i].index = get_bits(gb, 2); s->mcdparams[i].chan2 = get_bits(gb, 4); if (s->mcdparams[i].chan2 >= avctx->channels) { av_log(avctx, AV_LOG_ERROR, "invalid channel 2 (%d) for %d channel(s)\n", s->mcdparams[i].chan2, avctx->channels); return AVERROR_INVALIDDATA; } if (s->mcdparams[i].index == 1) { if ((nbit == s->mcdparams[i].chan2) || (ch_mask & 1 << s->mcdparams[i].chan2)) return AVERROR_INVALIDDATA; ch_mask |= 1 << s->mcdparams[i].chan2; } else if (!(ch_mask & 1 << s->mcdparams[i].chan2)) { return AVERROR_INVALIDDATA; } } s->mcdparams[i].chan1 = nbit; ch_mask |= 1 << nbit; } } else { chan = avctx->channels; for (i = 0; i < chan; i++) { s->mcdparams[i].present = 0; s->mcdparams[i].chan1 = i; } } for (i = 0; i < chan; i++) { if (s->mcdparams[i].present && s->mcdparams[i].index == 1) if (ret = decode_channel(s, s->mcdparams[i].chan2)) return ret; if (ret = decode_channel(s, s->mcdparams[i].chan1)) return ret; if (s->mcdparams[i].present) { s->dmode = mc_dmodes[s->mcdparams[i].index]; if (ret = decorrelate(s, s->mcdparams[i].chan2, s->mcdparams[i].chan1, s->nb_samples - 1)) return ret; } } } for (chan = 0; chan < avctx->channels; chan++) { int32_t *decoded = s->decoded[chan]; if (s->lpc_mode[chan]) decode_lpc(decoded, s->lpc_mode[chan], s->nb_samples); if (s->sample_shift[chan] > 0) for (i = 0; i < s->nb_samples; i++) decoded[i] *= 1 << s->sample_shift[chan]; } } align_get_bits(gb); skip_bits(gb, 24); if (get_bits_left(gb) < 0) av_log(avctx, AV_LOG_DEBUG, "overread\n"); else if (get_bits_left(gb) > 0) av_log(avctx, AV_LOG_DEBUG, "underread\n"); if (avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_COMPLIANT)) { if (ff_tak_check_crc(pkt->data + hsize, get_bits_count(gb) / 8 - hsize)) { av_log(avctx, AV_LOG_ERROR, "CRC error\n"); if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } } /* convert to output buffer */ switch (avctx->sample_fmt) { case AV_SAMPLE_FMT_U8P: for (chan = 0; chan < avctx->channels; chan++) { uint8_t *samples = (uint8_t *)frame->extended_data[chan]; int32_t *decoded = s->decoded[chan]; for (i = 0; i < s->nb_samples; i++) samples[i] = decoded[i] + 0x80; } break; case AV_SAMPLE_FMT_S16P: for (chan = 0; chan < avctx->channels; chan++) { int16_t *samples = (int16_t *)frame->extended_data[chan]; int32_t *decoded = s->decoded[chan]; for (i = 0; i < s->nb_samples; i++) samples[i] = decoded[i]; } break; case AV_SAMPLE_FMT_S32P: for (chan = 0; chan < avctx->channels; chan++) { int32_t *samples = (int32_t *)frame->extended_data[chan]; for (i = 0; i < s->nb_samples; i++) samples[i] *= 1 << 8; } break; } *got_frame_ptr = 1; return pkt->size; }
true
FFmpeg
e4efd41b83e78c7f2ee3e74bee90226110743a8e
7,774
static int msnwc_tcp_read_packet(AVFormatContext *ctx, AVPacket *pkt) { AVIOContext *pb = ctx->pb; uint16_t keyframe; uint32_t size, timestamp; avio_skip(pb, 1); /* one byte has been read ahead */ avio_skip(pb, 2); avio_skip(pb, 2); keyframe = avio_rl16(pb); size = avio_rl32(pb); avio_skip(pb, 4); avio_skip(pb, 4); timestamp = avio_rl32(pb); if(!size || av_get_packet(pb, pkt, size) != size) return -1; avio_skip(pb, 1); /* Read ahead one byte of struct size like read_header */ pkt->pts = timestamp; pkt->dts = timestamp; pkt->stream_index = 0; /* Some aMsn generated videos (or was it Mercury Messenger?) don't set * this bit and rely on the codec to get keyframe information */ if(keyframe&1) pkt->flags |= AV_PKT_FLAG_KEY; return HEADER_SIZE + size; }
true
FFmpeg
4dfbc7a7559ccab666a8fd39de4224eb4b02c768
7,775
static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { ZeroCodecContext *zc = avctx->priv_data; AVFrame *pic = avctx->coded_frame; AVFrame *prev_pic = &zc->previous_frame; z_stream *zstream = &zc->zstream; uint8_t *prev, *dst; int i, j, zret; pic->reference = 3; if (avctx->get_buffer(avctx, pic) < 0) { av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n"); return AVERROR(ENOMEM); zret = inflateReset(zstream); if (zret != Z_OK) { av_log(avctx, AV_LOG_ERROR, "Could not reset inflate: %d\n", zret); return AVERROR(EINVAL); zstream->next_in = avpkt->data; zstream->avail_in = avpkt->size; prev = prev_pic->data[0]; dst = pic->data[0]; /** * ZeroCodec has very simple interframe compression. If a value * is the same as the previous frame, set it to 0. */ if (avpkt->flags & AV_PKT_FLAG_KEY) { pic->key_frame = 1; pic->pict_type = AV_PICTURE_TYPE_I; } else { pic->key_frame = 0; pic->pict_type = AV_PICTURE_TYPE_P; for (i = 0; i < avctx->height; i++) { zstream->next_out = dst; zstream->avail_out = avctx->width << 1; zret = inflate(zstream, Z_SYNC_FLUSH); if (zret != Z_OK && zret != Z_STREAM_END) { av_log(avctx, AV_LOG_ERROR, "Inflate failed with return code: %d\n", zret); return AVERROR(EINVAL); if (!(avpkt->flags & AV_PKT_FLAG_KEY)) for (j = 0; j < avctx->width << 1; j++) dst[j] += prev[j] & -!dst[j]; prev += prev_pic->linesize[0]; dst += pic->linesize[0]; /* Release the previous buffer if need be */ if (prev_pic->data[0]) avctx->release_buffer(avctx, prev_pic); /* Store the previouse frame for use later */ *prev_pic = *pic; *data_size = sizeof(AVFrame); *(AVFrame *)data = *pic; return avpkt->size;
true
FFmpeg
4b70bba57ec9d61282e8b2b427d738dd44415652
7,776
bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq) { VirtIOSCSIReq *req, *next; int ret = 0; bool progress = false; QTAILQ_HEAD(, VirtIOSCSIReq) reqs = QTAILQ_HEAD_INITIALIZER(reqs); virtio_scsi_acquire(s); do { virtio_queue_set_notification(vq, 0); while ((req = virtio_scsi_pop_req(s, vq))) { progress = true; ret = virtio_scsi_handle_cmd_req_prepare(s, req); if (!ret) { QTAILQ_INSERT_TAIL(&reqs, req, next); } else if (ret == -EINVAL) { /* The device is broken and shouldn't process any request */ while (!QTAILQ_EMPTY(&reqs)) { req = QTAILQ_FIRST(&reqs); QTAILQ_REMOVE(&reqs, req, next); blk_io_unplug(req->sreq->dev->conf.blk); scsi_req_unref(req->sreq); virtqueue_detach_element(req->vq, &req->elem, 0); virtio_scsi_free_req(req); } } } virtio_queue_set_notification(vq, 1); } while (ret != -EINVAL && !virtio_queue_empty(vq)); QTAILQ_FOREACH_SAFE(req, &reqs, next, next) { virtio_scsi_handle_cmd_req_submit(s, req); } virtio_scsi_release(s); return progress; }
true
qemu
71407786054cad26de7ef66718b2a57a4bcb49b5
7,778
int ff_vda_create_decoder(struct vda_context *vda_ctx, uint8_t *extradata, int extradata_size) { OSStatus status = kVDADecoderNoErr; CFNumberRef height; CFNumberRef width; CFNumberRef format; CFDataRef avc_data; CFMutableDictionaryRef config_info; CFMutableDictionaryRef buffer_attributes; CFMutableDictionaryRef io_surface_properties; CFNumberRef cv_pix_fmt; /* Each VCL NAL in the bistream sent to the decoder * is preceded by a 4 bytes length header. * Change the avcC atom header if needed, to signal headers of 4 bytes. */ if (extradata_size >= 4 && (extradata[4] & 0x03) != 0x03) { uint8_t *rw_extradata; if (!(rw_extradata = av_malloc(extradata_size))) return AVERROR(ENOMEM); memcpy(rw_extradata, extradata, extradata_size); rw_extradata[4] |= 0x03; avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, extradata_size); av_freep(&rw_extradata); } else { avc_data = CFDataCreate(kCFAllocatorDefault, extradata, extradata_size); } config_info = CFDictionaryCreateMutable(kCFAllocatorDefault, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->height); width = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->width); format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->format); CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height); CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width); CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format); CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData, avc_data); buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); cv_pix_fmt = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->cv_pix_fmt_type); CFDictionarySetValue(buffer_attributes, kCVPixelBufferPixelFormatTypeKey, cv_pix_fmt); CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfacePropertiesKey, io_surface_properties); status = VDADecoderCreate(config_info, buffer_attributes, vda_decoder_callback, vda_ctx, &vda_ctx->decoder); CFRelease(height); CFRelease(width); CFRelease(format); CFRelease(avc_data); CFRelease(config_info); CFRelease(io_surface_properties); CFRelease(cv_pix_fmt); CFRelease(buffer_attributes); return status; }
false
FFmpeg
67afcefb35932b420998f6f3fda46c7c85848a3f
7,781
static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result, BdrvCheckMode fix) { return qcow2_check_refcounts(bs, result, fix); }
false
qemu
acbe59829e448aa63bdccc6ee484b7e1ac605e25
7,783
bool memory_region_present(MemoryRegion *parent, hwaddr addr) { MemoryRegion *mr = memory_region_find(parent, addr, 1).mr; if (!mr) { return false; } memory_region_unref(mr); return true; }
false
qemu
8e46bbf362458fc3e4638a53249248a1ee40b912
7,784
static int nut_probe(AVProbeData *p) { if (p->buf_size >= ID_LENGTH && !memcmp(p->buf, ID_STRING, ID_LENGTH)) return AVPROBE_SCORE_MAX; return 0; }
false
FFmpeg
87e8788680e16c51f6048af26f3f7830c35207a5
7,785
static void check_native_list(QObject *qobj, UserDefNativeListUnionKind kind) { QDict *qdict; QList *qlist; int i; g_assert(qobj); g_assert(qobject_type(qobj) == QTYPE_QDICT); qdict = qobject_to_qdict(qobj); g_assert(qdict); g_assert(qdict_haskey(qdict, "data")); qlist = qlist_copy(qobject_to_qlist(qdict_get(qdict, "data"))); switch (kind) { case USER_DEF_NATIVE_LIST_UNION_KIND_S8: case USER_DEF_NATIVE_LIST_UNION_KIND_S16: case USER_DEF_NATIVE_LIST_UNION_KIND_S32: case USER_DEF_NATIVE_LIST_UNION_KIND_S64: case USER_DEF_NATIVE_LIST_UNION_KIND_U8: case USER_DEF_NATIVE_LIST_UNION_KIND_U16: case USER_DEF_NATIVE_LIST_UNION_KIND_U32: case USER_DEF_NATIVE_LIST_UNION_KIND_U64: /* all integer elements in JSON arrays get stored into QInts when * we convert to QObjects, so we can check them all in the same * fashion, so simply fall through here */ case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: for (i = 0; i < 32; i++) { QObject *tmp; QInt *qvalue; tmp = qlist_peek(qlist); g_assert(tmp); qvalue = qobject_to_qint(tmp); g_assert_cmpint(qint_get_int(qvalue), ==, i); qobject_decref(qlist_pop(qlist)); } break; case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN: for (i = 0; i < 32; i++) { QObject *tmp; QBool *qvalue; tmp = qlist_peek(qlist); g_assert(tmp); qvalue = qobject_to_qbool(tmp); g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0); qobject_decref(qlist_pop(qlist)); } break; case USER_DEF_NATIVE_LIST_UNION_KIND_STRING: for (i = 0; i < 32; i++) { QObject *tmp; QString *qvalue; gchar str[8]; tmp = qlist_peek(qlist); g_assert(tmp); qvalue = qobject_to_qstring(tmp); sprintf(str, "%d", i); g_assert_cmpstr(qstring_get_str(qvalue), ==, str); qobject_decref(qlist_pop(qlist)); } break; case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER: for (i = 0; i < 32; i++) { QObject *tmp; QFloat *qvalue; GString *double_expected = g_string_new(""); GString *double_actual = g_string_new(""); tmp = qlist_peek(qlist); g_assert(tmp); qvalue = qobject_to_qfloat(tmp); g_string_printf(double_expected, "%.6f", (double)i / 3); g_string_printf(double_actual, "%.6f", qfloat_get_double(qvalue)); g_assert_cmpstr(double_actual->str, ==, double_expected->str); qobject_decref(qlist_pop(qlist)); g_string_free(double_expected, true); g_string_free(double_actual, true); } break; default: g_assert_not_reached(); } QDECREF(qlist); }
false
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
7,787
static void term_eol(void) { term_cmd_buf_index = term_cmd_buf_size; }
false
qemu
7e2515e87c41e2e658aaed466e11cbdf1ea8bcb1
7,788
static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun, void *hba_private) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d); SCSIRequest *req; SCSIDiskReq *r; req = scsi_req_alloc(&scsi_disk_reqops, &s->qdev, tag, lun, hba_private); r = DO_UPCAST(SCSIDiskReq, req, req); r->iov.iov_base = qemu_blockalign(s->bs, SCSI_DMA_BUF_SIZE); return req; }
false
qemu
7285477ab11831b1cf56e45878a89170dd06d9b9
7,789
int main_loop_wait(int nonblocking) { int ret; uint32_t timeout = UINT32_MAX; int64_t timeout_ns; if (nonblocking) { timeout = 0; } /* poll any events */ g_array_set_size(gpollfds, 0); /* reset for new iteration */ /* XXX: separate device handlers from system ones */ #ifdef CONFIG_SLIRP slirp_pollfds_fill(gpollfds, &timeout); #endif if (timeout == UINT32_MAX) { timeout_ns = -1; } else { timeout_ns = (uint64_t)timeout * (int64_t)(SCALE_MS); } timeout_ns = qemu_soonest_timeout(timeout_ns, timerlistgroup_deadline_ns( &main_loop_tlg)); ret = os_host_main_loop_wait(timeout_ns); #ifdef CONFIG_SLIRP slirp_pollfds_poll(gpollfds, (ret < 0)); #endif /* CPU thread can infinitely wait for event after missing the warp */ qemu_start_warp_timer(); qemu_clock_run_all_timers(); return ret; }
false
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
7,790
int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int mmu_idx, int is_softmmu) { #if !defined(CONFIG_USER_ONLY) target_phys_addr_t physical; int prot; #endif int access_type; int ret = 0; #if 0 log_cpu_state(env, 0); #endif qemu_log("%s pc " TARGET_FMT_lx " ad " TARGET_FMT_lx " rw %d mmu_idx %d smmu %d\n", __func__, env->active_tc.PC, address, rw, mmu_idx, is_softmmu); rw &= 1; /* data access */ /* XXX: put correct access by using cpu_restore_state() correctly */ access_type = ACCESS_INT; #if defined(CONFIG_USER_ONLY) ret = TLBRET_NOMATCH; #else ret = get_physical_address(env, &physical, &prot, address, rw, access_type); qemu_log("%s address=" TARGET_FMT_lx " ret %d physical " TARGET_FMT_plx " prot %d\n", __func__, address, ret, physical, prot); if (ret == TLBRET_MATCH) { ret = tlb_set_page(env, address & TARGET_PAGE_MASK, physical & TARGET_PAGE_MASK, prot, mmu_idx, is_softmmu); } else if (ret < 0) #endif { raise_mmu_exception(env, address, rw, ret); ret = 1; } return ret; }
false
qemu
d4c430a80f000d722bb70287af4d4c184a8d7006
7,793
static uint64_t vtd_context_cache_invalidate(IntelIOMMUState *s, uint64_t val) { uint64_t caig; uint64_t type = val & VTD_CCMD_CIRG_MASK; switch (type) { case VTD_CCMD_GLOBAL_INVL: VTD_DPRINTF(INV, "Global invalidation request"); caig = VTD_CCMD_GLOBAL_INVL_A; break; case VTD_CCMD_DOMAIN_INVL: VTD_DPRINTF(INV, "Domain-selective invalidation request"); caig = VTD_CCMD_DOMAIN_INVL_A; break; case VTD_CCMD_DEVICE_INVL: VTD_DPRINTF(INV, "Domain-selective invalidation request"); caig = VTD_CCMD_DEVICE_INVL_A; break; default: VTD_DPRINTF(GENERAL, "error: wrong context-cache invalidation granularity"); caig = 0; } return caig; }
false
qemu
d92fa2dc6e42e8bd8470e69d85141176f98feaea
7,794
uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, uint64_t new_lo, uint64_t new_hi) { uintptr_t ra = GETPC(); Int128 oldv, cmpv, newv; bool success; cmpv = int128_make128(env->exclusive_val, env->exclusive_high); newv = int128_make128(new_lo, new_hi); if (parallel_cpus) { #ifndef CONFIG_ATOMIC128 cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); #else int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); oldv = helper_atomic_cmpxchgo_le_mmu(env, addr, cmpv, newv, oi, ra); success = int128_eq(oldv, cmpv); #endif } else { uint64_t o0, o1; #ifdef CONFIG_USER_ONLY /* ??? Enforce alignment. */ uint64_t *haddr = g2h(addr); o0 = ldq_le_p(haddr + 0); o1 = ldq_le_p(haddr + 1); oldv = int128_make128(o0, o1); success = int128_eq(oldv, cmpv); if (success) { stq_le_p(haddr + 0, int128_getlo(newv)); stq_le_p(haddr + 1, int128_gethi(newv)); } #else int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi0 = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); TCGMemOpIdx oi1 = make_memop_idx(MO_LEQ, mem_idx); o0 = helper_le_ldq_mmu(env, addr + 0, oi0, ra); o1 = helper_le_ldq_mmu(env, addr + 8, oi1, ra); oldv = int128_make128(o0, o1); success = int128_eq(oldv, cmpv); if (success) { helper_le_stq_mmu(env, addr + 0, int128_getlo(newv), oi1, ra); helper_le_stq_mmu(env, addr + 8, int128_gethi(newv), oi1, ra); } #endif } return !success; }
false
qemu
2399d4e7cec22ecf1c51062d2ebfd45220dbaace
7,795
static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe) { H264BSFContext *ctx = bsfc->priv_data; int i; uint8_t unit_type; int32_t nal_size; uint32_t cumul_size = 0; const uint8_t *buf_end = buf + buf_size; int ret = 0; /* nothing to filter */ if (!avctx->extradata || avctx->extradata_size < 6) { *poutbuf = (uint8_t *)buf; *poutbuf_size = buf_size; return 0; } /* retrieve sps and pps NAL units from extradata */ if (!ctx->extradata_parsed) { if (args && strstr(args, "private_spspps_buf")) ctx->private_spspps = 1; ret = h264_extradata_to_annexb(ctx, avctx, AV_INPUT_BUFFER_PADDING_SIZE); if (ret < 0) return ret; ctx->length_size = ret; ctx->new_idr = 1; ctx->idr_sps_seen = 0; ctx->idr_pps_seen = 0; ctx->extradata_parsed = 1; } *poutbuf_size = 0; *poutbuf = NULL; do { ret= AVERROR(EINVAL); if (buf + ctx->length_size > buf_end) goto fail; for (nal_size = 0, i = 0; i<ctx->length_size; i++) nal_size = (nal_size << 8) | buf[i]; buf += ctx->length_size; unit_type = *buf & 0x1f; if (buf + nal_size > buf_end || nal_size < 0) goto fail; if (unit_type == 7) ctx->idr_sps_seen = ctx->new_idr = 1; else if (unit_type == 8) { ctx->idr_pps_seen = ctx->new_idr = 1; /* if SPS has not been seen yet, prepend the AVCC one to PPS */ if (!ctx->idr_sps_seen) { if (ctx->sps_offset == -1) av_log(avctx, AV_LOG_WARNING, "SPS not present in the stream, nor in AVCC, stream may be unreadable\n"); else { if ((ret = alloc_and_copy(poutbuf, poutbuf_size, ctx->spspps_buf + ctx->sps_offset, ctx->pps_offset != -1 ? ctx->pps_offset : ctx->spspps_size - ctx->sps_offset, buf, nal_size)) < 0) goto fail; ctx->idr_sps_seen = 1; goto next_nal; } } } /* if this is a new IDR picture following an IDR picture, reset the idr flag. * Just check first_mb_in_slice to be 0 as this is the simplest solution. * This could be checking idr_pic_id instead, but would complexify the parsing. */ if (!ctx->new_idr && unit_type == 5 && (buf[1] & 0x80)) ctx->new_idr = 1; /* prepend only to the first type 5 NAL unit of an IDR picture, if no sps/pps are already present */ if (ctx->new_idr && unit_type == 5 && !ctx->idr_sps_seen && !ctx->idr_pps_seen) { if ((ret=alloc_and_copy(poutbuf, poutbuf_size, ctx->spspps_buf, ctx->spspps_size, buf, nal_size)) < 0) goto fail; ctx->new_idr = 0; /* if only SPS has been seen, also insert PPS */ } else if (ctx->new_idr && unit_type == 5 && ctx->idr_sps_seen && !ctx->idr_pps_seen) { if (ctx->pps_offset == -1) { av_log(avctx, AV_LOG_WARNING, "PPS not present in the stream, nor in AVCC, stream may be unreadable\n"); if ((ret = alloc_and_copy(poutbuf, poutbuf_size, NULL, 0, buf, nal_size)) < 0) goto fail; } else if ((ret = alloc_and_copy(poutbuf, poutbuf_size, ctx->spspps_buf + ctx->pps_offset, ctx->spspps_size - ctx->pps_offset, buf, nal_size)) < 0) goto fail; } else { if ((ret=alloc_and_copy(poutbuf, poutbuf_size, NULL, 0, buf, nal_size)) < 0) goto fail; if (!ctx->new_idr && unit_type == 1) { ctx->new_idr = 1; ctx->idr_sps_seen = 0; ctx->idr_pps_seen = 0; } } next_nal: buf += nal_size; cumul_size += nal_size + ctx->length_size; } while (cumul_size < buf_size); return 1; fail: av_freep(poutbuf); *poutbuf_size = 0; return ret; }
false
FFmpeg
2bb54b82b5094fd906aa28c0443be08c95662a31
7,796
void qemu_notify_event(void) { /* Write 8 bytes to be compatible with eventfd. */ static const uint64_t val = 1; ssize_t ret; if (io_thread_fd == -1) { return; } do { ret = write(io_thread_fd, &val, sizeof(val)); } while (ret < 0 && errno == EINTR); /* EAGAIN is fine, a read must be pending. */ if (ret < 0 && errno != EAGAIN) { fprintf(stderr, "qemu_notify_event: write() failed: %s\n", strerror(errno)); exit(1); } }
false
qemu
4c8d0d27676778febad3802a95218d5ceaca171e
7,798
uint16_t virtio_get_cylinders(void) { return blk_cfg.geometry.cylinders; }
false
qemu
f04db28b86654d1c7ff805b40eff27bba6b0f686
7,799
static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf) { SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req); SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); int32_t len; uint8_t command; uint8_t *outbuf; int rc; command = buf[0]; outbuf = (uint8_t *)r->iov.iov_base; DPRINTF("Command: lun=%d tag=0x%x data=0x%02x", req->lun, req->tag, buf[0]); #ifdef DEBUG_SCSI { int i; for (i = 1; i < r->req.cmd.len; i++) { printf(" 0x%02x", buf[i]); } printf("\n"); } #endif if (req->lun) { /* Only LUN 0 supported. */ DPRINTF("Unimplemented LUN %d\n", req->lun); if (command != REQUEST_SENSE && command != INQUIRY) { scsi_check_condition(r, SENSE_CODE(LUN_NOT_SUPPORTED)); return 0; } } switch (command) { case TEST_UNIT_READY: case REQUEST_SENSE: case INQUIRY: case MODE_SENSE: case MODE_SENSE_10: case RESERVE: case RESERVE_10: case RELEASE: case RELEASE_10: case START_STOP: case ALLOW_MEDIUM_REMOVAL: case READ_CAPACITY_10: case SYNCHRONIZE_CACHE: case READ_TOC: case GET_CONFIGURATION: case SERVICE_ACTION_IN: case REPORT_LUNS: case VERIFY_10: rc = scsi_disk_emulate_command(r, outbuf); if (rc < 0) { return 0; } r->iov.iov_len = rc; break; case READ_6: case READ_10: case READ_12: case READ_16: len = r->req.cmd.xfer / s->qdev.blocksize; DPRINTF("Read (sector %" PRId64 ", count %d)\n", r->req.cmd.lba, len); if (r->req.cmd.lba > s->max_lba) goto illegal_lba; r->sector = r->req.cmd.lba * s->cluster_size; r->sector_count = len * s->cluster_size; break; case WRITE_6: case WRITE_10: case WRITE_12: case WRITE_16: case WRITE_VERIFY_10: case WRITE_VERIFY_12: case WRITE_VERIFY_16: len = r->req.cmd.xfer / s->qdev.blocksize; DPRINTF("Write %s(sector %" PRId64 ", count %d)\n", (command & 0xe) == 0xe ? "And Verify " : "", r->req.cmd.lba, len); if (r->req.cmd.lba > s->max_lba) goto illegal_lba; r->sector = r->req.cmd.lba * s->cluster_size; r->sector_count = len * s->cluster_size; break; case MODE_SELECT: DPRINTF("Mode Select(6) (len %lu)\n", (long)r->req.cmd.xfer); /* We don't support mode parameter changes. Allow the mode parameter header + block descriptors only. */ if (r->req.cmd.xfer > 12) { goto fail; } break; case MODE_SELECT_10: DPRINTF("Mode Select(10) (len %lu)\n", (long)r->req.cmd.xfer); /* We don't support mode parameter changes. Allow the mode parameter header + block descriptors only. */ if (r->req.cmd.xfer > 16) { goto fail; } break; case SEEK_6: case SEEK_10: DPRINTF("Seek(%d) (sector %" PRId64 ")\n", command == SEEK_6 ? 6 : 10, r->req.cmd.lba); if (r->req.cmd.lba > s->max_lba) { goto illegal_lba; } break; case WRITE_SAME_16: len = r->req.cmd.xfer / s->qdev.blocksize; DPRINTF("WRITE SAME(16) (sector %" PRId64 ", count %d)\n", r->req.cmd.lba, len); if (r->req.cmd.lba > s->max_lba) { goto illegal_lba; } /* * We only support WRITE SAME with the unmap bit set for now. */ if (!(buf[1] & 0x8)) { goto fail; } rc = bdrv_discard(s->bs, r->req.cmd.lba * s->cluster_size, len * s->cluster_size); if (rc < 0) { /* XXX: better error code ?*/ goto fail; } break; default: DPRINTF("Unknown SCSI command (%2.2x)\n", buf[0]); scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE)); return 0; fail: scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); return 0; illegal_lba: scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); return 0; } if (r->sector_count == 0 && r->iov.iov_len == 0) { scsi_req_complete(&r->req, GOOD); } len = r->sector_count * 512 + r->iov.iov_len; if (r->req.cmd.mode == SCSI_XFER_TO_DEV) { return -len; } else { if (!r->sector_count) r->sector_count = -1; return len; } }
false
qemu
fdaef06917100d97782df550c1807a1da054e27e
7,800
static void test_qemu_strtoul_octal(void) { const char *str = "0123"; char f = 'X'; const char *endptr = &f; unsigned long res = 999; int err; err = qemu_strtoul(str, &endptr, 8, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0123); g_assert(endptr == str + strlen(str)); res = 999; endptr = &f; err = qemu_strtoul(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0123); g_assert(endptr == str + strlen(str)); }
false
qemu
bc7c08a2c375acb7ae4d433054415588b176d34c
7,801
i2c_bus *i2c_init_bus(DeviceState *parent, const char *name) { i2c_bus *bus; bus = FROM_QBUS(i2c_bus, qbus_create(BUS_TYPE_I2C, sizeof(i2c_bus), parent, name)); register_savevm("i2c_bus", -1, 1, i2c_bus_save, i2c_bus_load, bus); return bus; }
false
qemu
10c4c98ab7dc18169b37b76f6ea5e60ebe65222b
7,802
int msix_uninit(PCIDevice *dev, MemoryRegion *bar) { if (!(dev->cap_present & QEMU_PCI_CAP_MSIX)) return 0; pci_del_capability(dev, PCI_CAP_ID_MSIX, MSIX_CAP_LENGTH); dev->msix_cap = 0; msix_free_irq_entries(dev); dev->msix_entries_nr = 0; memory_region_del_subregion(bar, &dev->msix_mmio); memory_region_destroy(&dev->msix_mmio); g_free(dev->msix_table_page); dev->msix_table_page = NULL; g_free(dev->msix_entry_used); dev->msix_entry_used = NULL; dev->cap_present &= ~QEMU_PCI_CAP_MSIX; return 0; }
false
qemu
44701ab71ad854e6be567a6294f4665f36651076
7,803
static int rtmp_open(URLContext *s, const char *uri, int flags) { RTMPContext *rt = s->priv_data; char proto[8], hostname[256], path[1024], auth[100], *fname; char *old_app; uint8_t buf[2048]; int port; AVDictionary *opts = NULL; int ret; if (rt->listen_timeout > 0) rt->listen = 1; rt->is_input = !(flags & AVIO_FLAG_WRITE); av_url_split(proto, sizeof(proto), auth, sizeof(auth), hostname, sizeof(hostname), &port, path, sizeof(path), s->filename); if (auth[0]) { char *ptr = strchr(auth, ':'); if (ptr) { *ptr = '\0'; av_strlcpy(rt->username, auth, sizeof(rt->username)); av_strlcpy(rt->password, ptr + 1, sizeof(rt->password)); } } if (rt->listen && strcmp(proto, "rtmp")) { av_log(s, AV_LOG_ERROR, "rtmp_listen not available for %s\n", proto); return AVERROR(EINVAL); } if (!strcmp(proto, "rtmpt") || !strcmp(proto, "rtmpts")) { if (!strcmp(proto, "rtmpts")) av_dict_set(&opts, "ffrtmphttp_tls", "1", 1); /* open the http tunneling connection */ ff_url_join(buf, sizeof(buf), "ffrtmphttp", NULL, hostname, port, NULL); } else if (!strcmp(proto, "rtmps")) { /* open the tls connection */ if (port < 0) port = RTMPS_DEFAULT_PORT; ff_url_join(buf, sizeof(buf), "tls", NULL, hostname, port, NULL); } else if (!strcmp(proto, "rtmpe") || (!strcmp(proto, "rtmpte"))) { if (!strcmp(proto, "rtmpte")) av_dict_set(&opts, "ffrtmpcrypt_tunneling", "1", 1); /* open the encrypted connection */ ff_url_join(buf, sizeof(buf), "ffrtmpcrypt", NULL, hostname, port, NULL); rt->encrypted = 1; } else { /* open the tcp connection */ if (port < 0) port = RTMP_DEFAULT_PORT; if (rt->listen) ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, "?listen&listen_timeout=%d", rt->listen_timeout * 1000); else ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); } reconnect: if ((ret = ffurl_open(&rt->stream, buf, AVIO_FLAG_READ_WRITE, &s->interrupt_callback, &opts)) < 0) { av_log(s , AV_LOG_ERROR, "Cannot open connection %s\n", buf); goto fail; } if (rt->swfverify) { if ((ret = rtmp_calc_swfhash(s)) < 0) goto fail; } rt->state = STATE_START; if (!rt->listen && (ret = rtmp_handshake(s, rt)) < 0) goto fail; if (rt->listen && (ret = rtmp_server_handshake(s, rt)) < 0) goto fail; rt->out_chunk_size = 128; rt->in_chunk_size = 128; // Probably overwritten later rt->state = STATE_HANDSHAKED; // Keep the application name when it has been defined by the user. old_app = rt->app; rt->app = av_malloc(APP_MAX_LENGTH); if (!rt->app) { ret = AVERROR(ENOMEM); goto fail; } //extract "app" part from path if (!strncmp(path, "/ondemand/", 10)) { fname = path + 10; memcpy(rt->app, "ondemand", 9); } else { char *next = *path ? path + 1 : path; char *p = strchr(next, '/'); if (!p) { fname = next; rt->app[0] = '\0'; } else { // make sure we do not mismatch a playpath for an application instance char *c = strchr(p + 1, ':'); fname = strchr(p + 1, '/'); if (!fname || (c && c < fname)) { fname = p + 1; av_strlcpy(rt->app, path + 1, p - path); } else { fname++; av_strlcpy(rt->app, path + 1, fname - path - 1); } } } if (old_app) { // The name of application has been defined by the user, override it. av_free(rt->app); rt->app = old_app; } if (!rt->playpath) { int len = strlen(fname); rt->playpath = av_malloc(PLAYPATH_MAX_LENGTH); if (!rt->playpath) { ret = AVERROR(ENOMEM); goto fail; } if (!strchr(fname, ':') && len >= 4 && (!strcmp(fname + len - 4, ".f4v") || !strcmp(fname + len - 4, ".mp4"))) { memcpy(rt->playpath, "mp4:", 5); } else if (len >= 4 && !strcmp(fname + len - 4, ".flv")) { fname[len - 4] = '\0'; } else { rt->playpath[0] = 0; } av_strlcat(rt->playpath, fname, PLAYPATH_MAX_LENGTH); } if (!rt->tcurl) { rt->tcurl = av_malloc(TCURL_MAX_LENGTH); if (!rt->tcurl) { ret = AVERROR(ENOMEM); goto fail; } ff_url_join(rt->tcurl, TCURL_MAX_LENGTH, proto, NULL, hostname, port, "/%s", rt->app); } if (!rt->flashver) { rt->flashver = av_malloc(FLASHVER_MAX_LENGTH); if (!rt->flashver) { ret = AVERROR(ENOMEM); goto fail; } if (rt->is_input) { snprintf(rt->flashver, FLASHVER_MAX_LENGTH, "%s %d,%d,%d,%d", RTMP_CLIENT_PLATFORM, RTMP_CLIENT_VER1, RTMP_CLIENT_VER2, RTMP_CLIENT_VER3, RTMP_CLIENT_VER4); } else { snprintf(rt->flashver, FLASHVER_MAX_LENGTH, "FMLE/3.0 (compatible; %s)", LIBAVFORMAT_IDENT); } } rt->client_report_size = 1048576; rt->bytes_read = 0; rt->last_bytes_read = 0; rt->server_bw = 2500000; av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n", proto, path, rt->app, rt->playpath); if (!rt->listen) { if ((ret = gen_connect(s, rt)) < 0) goto fail; } else { if (read_connect(s, s->priv_data) < 0) goto fail; rt->is_input = 1; } do { ret = get_packet(s, 1); } while (ret == EAGAIN); if (ret < 0) goto fail; if (rt->do_reconnect) { ffurl_close(rt->stream); rt->stream = NULL; rt->do_reconnect = 0; rt->nb_invokes = 0; memset(rt->prev_pkt, 0, sizeof(rt->prev_pkt)); free_tracked_methods(rt); goto reconnect; } if (rt->is_input) { // generate FLV header for demuxer rt->flv_size = 13; rt->flv_data = av_realloc(rt->flv_data, rt->flv_size); rt->flv_off = 0; memcpy(rt->flv_data, "FLV\1\5\0\0\0\011\0\0\0\0", rt->flv_size); } else { rt->flv_size = 0; rt->flv_data = NULL; rt->flv_off = 0; rt->skip_bytes = 13; } s->max_packet_size = rt->stream->max_packet_size; s->is_streamed = 1; return 0; fail: av_dict_free(&opts); rtmp_close(s); return ret; }
false
FFmpeg
02ac3398eb52679301028c2fd3ebad1b6261b4da
7,804
static always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type) { int16_t *ip = input; uint8_t *cm = cropTbl + MAX_NEG_CROP; int A_, B_, C_, D_, _Ad, _Bd, _Cd, _Dd, E_, F_, G_, H_; int _Ed, _Gd, _Add, _Bdd, _Fd, _Hd; int i; /* Inverse DCT on the rows now */ for (i = 0; i < 8; i++) { /* Check for non-zero values */ if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) { A_ = M(xC1S7, ip[1]) + M(xC7S1, ip[7]); B_ = M(xC7S1, ip[1]) - M(xC1S7, ip[7]); C_ = M(xC3S5, ip[3]) + M(xC5S3, ip[5]); D_ = M(xC3S5, ip[5]) - M(xC5S3, ip[3]); _Ad = M(xC4S4, (A_ - C_)); _Bd = M(xC4S4, (B_ - D_)); _Cd = A_ + C_; _Dd = B_ + D_; E_ = M(xC4S4, (ip[0] + ip[4])); F_ = M(xC4S4, (ip[0] - ip[4])); G_ = M(xC2S6, ip[2]) + M(xC6S2, ip[6]); H_ = M(xC6S2, ip[2]) - M(xC2S6, ip[6]); _Ed = E_ - G_; _Gd = E_ + G_; _Add = F_ + _Ad; _Bdd = _Bd - H_; _Fd = F_ - _Ad; _Hd = _Bd + H_; /* Final sequence of operations over-write original inputs. */ ip[0] = _Gd + _Cd ; ip[7] = _Gd - _Cd ; ip[1] = _Add + _Hd; ip[2] = _Add - _Hd; ip[3] = _Ed + _Dd ; ip[4] = _Ed - _Dd ; ip[5] = _Fd + _Bdd; ip[6] = _Fd - _Bdd; } ip += 8; /* next row */ } ip = input; for ( i = 0; i < 8; i++) { /* Check for non-zero values (bitwise or faster than ||) */ if ( ip[1 * 8] | ip[2 * 8] | ip[3 * 8] | ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) { A_ = M(xC1S7, ip[1*8]) + M(xC7S1, ip[7*8]); B_ = M(xC7S1, ip[1*8]) - M(xC1S7, ip[7*8]); C_ = M(xC3S5, ip[3*8]) + M(xC5S3, ip[5*8]); D_ = M(xC3S5, ip[5*8]) - M(xC5S3, ip[3*8]); _Ad = M(xC4S4, (A_ - C_)); _Bd = M(xC4S4, (B_ - D_)); _Cd = A_ + C_; _Dd = B_ + D_; E_ = M(xC4S4, (ip[0*8] + ip[4*8])); F_ = M(xC4S4, (ip[0*8] - ip[4*8])); G_ = M(xC2S6, ip[2*8]) + M(xC6S2, ip[6*8]); H_ = M(xC6S2, ip[2*8]) - M(xC2S6, ip[6*8]); _Ed = E_ - G_; _Gd = E_ + G_; _Add = F_ + _Ad; _Bdd = _Bd - H_; _Fd = F_ - _Ad; _Hd = _Bd + H_; if(type==1){ //HACK _Gd += 16*128; _Add+= 16*128; _Ed += 16*128; _Fd += 16*128; } _Gd += IdctAdjustBeforeShift; _Add += IdctAdjustBeforeShift; _Ed += IdctAdjustBeforeShift; _Fd += IdctAdjustBeforeShift; /* Final sequence of operations over-write original inputs. */ if(type==0){ ip[0*8] = (_Gd + _Cd ) >> 4; ip[7*8] = (_Gd - _Cd ) >> 4; ip[1*8] = (_Add + _Hd ) >> 4; ip[2*8] = (_Add - _Hd ) >> 4; ip[3*8] = (_Ed + _Dd ) >> 4; ip[4*8] = (_Ed - _Dd ) >> 4; ip[5*8] = (_Fd + _Bdd ) >> 4; ip[6*8] = (_Fd - _Bdd ) >> 4; }else if(type==1){ dst[0*stride] = cm[(_Gd + _Cd ) >> 4]; dst[7*stride] = cm[(_Gd - _Cd ) >> 4]; dst[1*stride] = cm[(_Add + _Hd ) >> 4]; dst[2*stride] = cm[(_Add - _Hd ) >> 4]; dst[3*stride] = cm[(_Ed + _Dd ) >> 4]; dst[4*stride] = cm[(_Ed - _Dd ) >> 4]; dst[5*stride] = cm[(_Fd + _Bdd ) >> 4]; dst[6*stride] = cm[(_Fd - _Bdd ) >> 4]; }else{ dst[0*stride] = cm[dst[0*stride] + ((_Gd + _Cd ) >> 4)]; dst[7*stride] = cm[dst[7*stride] + ((_Gd - _Cd ) >> 4)]; dst[1*stride] = cm[dst[1*stride] + ((_Add + _Hd ) >> 4)]; dst[2*stride] = cm[dst[2*stride] + ((_Add - _Hd ) >> 4)]; dst[3*stride] = cm[dst[3*stride] + ((_Ed + _Dd ) >> 4)]; dst[4*stride] = cm[dst[4*stride] + ((_Ed - _Dd ) >> 4)]; dst[5*stride] = cm[dst[5*stride] + ((_Fd + _Bdd ) >> 4)]; dst[6*stride] = cm[dst[6*stride] + ((_Fd - _Bdd ) >> 4)]; } } else { if(type==0){ ip[0*8] = ip[1*8] = ip[2*8] = ip[3*8] = ip[4*8] = ip[5*8] = ip[6*8] = ip[7*8] = ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20); }else if(type==1){ dst[0*stride]= dst[1*stride]= dst[2*stride]= dst[3*stride]= dst[4*stride]= dst[5*stride]= dst[6*stride]= dst[7*stride]= 128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20); }else{ if(ip[0*8]){ int v= ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20); dst[0*stride] = cm[dst[0*stride] + v]; dst[1*stride] = cm[dst[1*stride] + v]; dst[2*stride] = cm[dst[2*stride] + v]; dst[3*stride] = cm[dst[3*stride] + v]; dst[4*stride] = cm[dst[4*stride] + v]; dst[5*stride] = cm[dst[5*stride] + v]; dst[6*stride] = cm[dst[6*stride] + v]; dst[7*stride] = cm[dst[7*stride] + v]; } } } ip++; /* next column */ dst++; } }
false
FFmpeg
d26a9ea0df8c08faf1ed37041f4bc252db30f047
7,805
static int seek_test(const char *input_filename, const char *start, const char *end) { AVCodec *codec = NULL; AVCodecContext *ctx= NULL; AVCodecParameters *origin_par = NULL; AVFrame *fr = NULL; AVFormatContext *fmt_ctx = NULL; int video_stream; int result; int i, j; long int start_ts, end_ts; size_of_array = 0; number_of_elements = 0; crc_array = pts_array = NULL; result = avformat_open_input(&fmt_ctx, input_filename, NULL, NULL); if (result < 0) { av_log(NULL, AV_LOG_ERROR, "Can't open file\n"); return result; } result = avformat_find_stream_info(fmt_ctx, NULL); if (result < 0) { av_log(NULL, AV_LOG_ERROR, "Can't get stream info\n"); return result; } start_ts = read_seek_range(start); end_ts = read_seek_range(end); if ((start_ts < 0) || (end_ts < 0)) return -1; //TODO: add ability to work with audio format video_stream = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0); if (video_stream < 0) { av_log(NULL, AV_LOG_ERROR, "Can't find video stream in input file\n"); return -1; } origin_par = fmt_ctx->streams[video_stream]->codecpar; codec = avcodec_find_decoder(origin_par->codec_id); if (!codec) { av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n"); return -1; } ctx = avcodec_alloc_context3(codec); if (!ctx) { av_log(NULL, AV_LOG_ERROR, "Can't allocate decoder context\n"); return AVERROR(ENOMEM); } result = avcodec_parameters_to_context(ctx, origin_par); if (result) { av_log(NULL, AV_LOG_ERROR, "Can't copy decoder context\n"); return result; } result = avcodec_open2(ctx, codec, NULL); if (result < 0) { av_log(ctx, AV_LOG_ERROR, "Can't open decoder\n"); return result; } fr = av_frame_alloc(); if (!fr) { av_log(NULL, AV_LOG_ERROR, "Can't allocate frame\n"); return AVERROR(ENOMEM); } result = compute_crc_of_packets(fmt_ctx, video_stream, ctx, fr, 0, 0, 1); if (result != 0) return -1; for (i = start_ts; i < end_ts; i += 100) { for (j = i + 100; j < end_ts; j += 100) result = compute_crc_of_packets(fmt_ctx, video_stream, ctx, fr, i, j, 0); if (result != 0) return -1; } av_freep(&crc_array); av_freep(&pts_array); av_frame_free(&fr); avcodec_close(ctx); avformat_close_input(&fmt_ctx); avcodec_free_context(&ctx); return 0; }
false
FFmpeg
7679c38b3b57125007aa67b009665c8d3e8d6bcc
7,806
static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx) { int result, i, p, tile_size, pic_size_indx, mb_size, blk_size; int quant_mat, blk_size_changed = 0; IVIBandDesc *band, *band1, *band2; IVIPicConfig pic_conf; ctx->gop_flags = get_bits(&ctx->gb, 8); ctx->gop_hdr_size = (ctx->gop_flags & 1) ? get_bits(&ctx->gb, 16) : 0; if (ctx->gop_flags & IVI5_IS_PROTECTED) ctx->lock_word = get_bits_long(&ctx->gb, 32); tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0; if (tile_size > 256) { av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size); return -1; } /* decode number of wavelet bands */ /* num_levels * 3 + 1 */ pic_conf.luma_bands = get_bits(&ctx->gb, 2) * 3 + 1; pic_conf.chroma_bands = get_bits1(&ctx->gb) * 3 + 1; ctx->is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1; if (ctx->is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) { av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n", pic_conf.luma_bands, pic_conf.chroma_bands); return -1; } pic_size_indx = get_bits(&ctx->gb, 4); if (pic_size_indx == IVI5_PIC_SIZE_ESC) { pic_conf.pic_height = get_bits(&ctx->gb, 13); pic_conf.pic_width = get_bits(&ctx->gb, 13); } else { pic_conf.pic_height = ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2; pic_conf.pic_width = ivi5_common_pic_sizes[pic_size_indx * 2 ] << 2; } if (ctx->gop_flags & 2) { av_log(avctx, AV_LOG_ERROR, "YV12 picture format not supported!\n"); return -1; } pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2; pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2; if (!tile_size) { pic_conf.tile_height = pic_conf.pic_height; pic_conf.tile_width = pic_conf.pic_width; } else { pic_conf.tile_height = pic_conf.tile_width = tile_size; } /* check if picture layout was changed and reallocate buffers */ if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) { result = ff_ivi_init_planes(ctx->planes, &pic_conf); if (result) { av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n"); return -1; } ctx->pic_conf = pic_conf; blk_size_changed = 1; /* force reallocation of the internal structures */ } for (p = 0; p <= 1; p++) { for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) { band = &ctx->planes[p].bands[i]; band->is_halfpel = get_bits1(&ctx->gb); mb_size = get_bits1(&ctx->gb); blk_size = 8 >> get_bits1(&ctx->gb); mb_size = blk_size << !mb_size; blk_size_changed = mb_size != band->mb_size || blk_size != band->blk_size; if (blk_size_changed) { band->mb_size = mb_size; band->blk_size = blk_size; } if (get_bits1(&ctx->gb)) { av_log(avctx, AV_LOG_ERROR, "Extended transform info encountered!\n"); return -1; } /* select transform function and scan pattern according to plane and band number */ switch ((p << 2) + i) { case 0: band->inv_transform = ff_ivi_inverse_slant_8x8; band->dc_transform = ff_ivi_dc_slant_2d; band->scan = ff_zigzag_direct; break; case 1: band->inv_transform = ff_ivi_row_slant8; band->dc_transform = ff_ivi_dc_row_slant; band->scan = ff_ivi_vertical_scan_8x8; break; case 2: band->inv_transform = ff_ivi_col_slant8; band->dc_transform = ff_ivi_dc_col_slant; band->scan = ff_ivi_horizontal_scan_8x8; break; case 3: band->inv_transform = ff_ivi_put_pixels_8x8; band->dc_transform = ff_ivi_put_dc_pixel_8x8; band->scan = ff_ivi_horizontal_scan_8x8; break; case 4: band->inv_transform = ff_ivi_inverse_slant_4x4; band->dc_transform = ff_ivi_dc_slant_2d; band->scan = ff_ivi_direct_scan_4x4; break; } band->is_2d_trans = band->inv_transform == ff_ivi_inverse_slant_8x8 || band->inv_transform == ff_ivi_inverse_slant_4x4; /* select dequant matrix according to plane and band number */ if (!p) { quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0; } else { quant_mat = 5; } if (band->blk_size == 8) { band->intra_base = &ivi5_base_quant_8x8_intra[quant_mat][0]; band->inter_base = &ivi5_base_quant_8x8_inter[quant_mat][0]; band->intra_scale = &ivi5_scale_quant_8x8_intra[quant_mat][0]; band->inter_scale = &ivi5_scale_quant_8x8_inter[quant_mat][0]; } else { band->intra_base = ivi5_base_quant_4x4_intra; band->inter_base = ivi5_base_quant_4x4_inter; band->intra_scale = ivi5_scale_quant_4x4_intra; band->inter_scale = ivi5_scale_quant_4x4_inter; } if (get_bits(&ctx->gb, 2)) { av_log(avctx, AV_LOG_ERROR, "End marker missing!\n"); return -1; } } } /* copy chroma parameters into the 2nd chroma plane */ for (i = 0; i < pic_conf.chroma_bands; i++) { band1 = &ctx->planes[1].bands[i]; band2 = &ctx->planes[2].bands[i]; band2->width = band1->width; band2->height = band1->height; band2->mb_size = band1->mb_size; band2->blk_size = band1->blk_size; band2->is_halfpel = band1->is_halfpel; band2->intra_base = band1->intra_base; band2->inter_base = band1->inter_base; band2->intra_scale = band1->intra_scale; band2->inter_scale = band1->inter_scale; band2->scan = band1->scan; band2->inv_transform = band1->inv_transform; band2->dc_transform = band1->dc_transform; band2->is_2d_trans = band1->is_2d_trans; } /* reallocate internal structures if needed */ if (blk_size_changed) { result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width, pic_conf.tile_height); if (result) { av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate internal structures!\n"); return -1; } } if (ctx->gop_flags & 8) { if (get_bits(&ctx->gb, 3)) { av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n"); return -1; } if (get_bits1(&ctx->gb)) skip_bits_long(&ctx->gb, 24); /* skip transparency fill color */ } align_get_bits(&ctx->gb); skip_bits(&ctx->gb, 23); /* FIXME: unknown meaning */ /* skip GOP extension if any */ if (get_bits1(&ctx->gb)) { do { i = get_bits(&ctx->gb, 16); } while (i & 0x8000); } align_get_bits(&ctx->gb); return 0; }
false
FFmpeg
dc79685195a45c9b8b17d7b93d118e0aefa45462
7,807
static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ MpegEncContext * const s = &h->s; int i, j; int current_ref_assigned=0; Picture *pic; if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0) av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n"); for(i=0; i<mmco_count; i++){ int structure, frame_num, unref_pic; if(s->avctx->debug&FF_DEBUG_MMCO) av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg); switch(mmco[i].opcode){ case MMCO_SHORT2UNUSED: if(s->avctx->debug&FF_DEBUG_MMCO) av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count); frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure); pic = find_short(h, frame_num, &j); if (pic) { if (unreference_pic(h, pic, structure ^ PICT_FRAME)) remove_short_at_index(h, j); } else if(s->avctx->debug&FF_DEBUG_MMCO) av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short failure\n"); break; case MMCO_SHORT2LONG: if (FIELD_PICTURE && mmco[i].long_arg < h->long_ref_count && h->long_ref[mmco[i].long_arg]->frame_num == mmco[i].short_pic_num / 2) { /* do nothing, we've already moved this field pair. */ } else { int frame_num = mmco[i].short_pic_num >> FIELD_PICTURE; pic= remove_long(h, mmco[i].long_arg); if(pic) unreference_pic(h, pic, 0); h->long_ref[ mmco[i].long_arg ]= remove_short(h, frame_num); if (h->long_ref[ mmco[i].long_arg ]){ h->long_ref[ mmco[i].long_arg ]->long_ref=1; h->long_ref_count++; } } break; case MMCO_LONG2UNUSED: j = pic_num_extract(h, mmco[i].long_arg, &structure); pic = h->long_ref[j]; if (pic) { if (unreference_pic(h, pic, structure ^ PICT_FRAME)) remove_long_at_index(h, j); } else if(s->avctx->debug&FF_DEBUG_MMCO) av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n"); break; case MMCO_LONG: unref_pic = 1; if (FIELD_PICTURE && !s->first_field) { if (h->long_ref[mmco[i].long_arg] == s->current_picture_ptr) { /* Just mark second field as referenced */ unref_pic = 0; } else if (s->current_picture_ptr->reference) { /* First field in pair is in short term list or * at a different long term index. * This is not allowed; see 7.4.3, notes 2 and 3. * Report the problem and keep the pair where it is, * and mark this field valid. */ av_log(h->s.avctx, AV_LOG_ERROR, "illegal long term reference assignment for second " "field in complementary field pair (first field is " "short term or has non-matching long index)\n"); unref_pic = 0; } } if (unref_pic) { pic= remove_long(h, mmco[i].long_arg); if(pic) unreference_pic(h, pic, 0); h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr; h->long_ref[ mmco[i].long_arg ]->long_ref=1; h->long_ref_count++; } s->current_picture_ptr->reference |= s->picture_structure; current_ref_assigned=1; break; case MMCO_SET_MAX_LONG: assert(mmco[i].long_arg <= 16); // just remove the long term which index is greater than new max for(j = mmco[i].long_arg; j<16; j++){ pic = remove_long(h, j); if (pic) unreference_pic(h, pic, 0); } break; case MMCO_RESET: while(h->short_ref_count){ pic= remove_short(h, h->short_ref[0]->frame_num); if(pic) unreference_pic(h, pic, 0); } for(j = 0; j < 16; j++) { pic= remove_long(h, j); if(pic) unreference_pic(h, pic, 0); } s->current_picture_ptr->poc= s->current_picture_ptr->field_poc[0]= s->current_picture_ptr->field_poc[1]= h->poc_lsb= h->poc_msb= h->frame_num= s->current_picture_ptr->frame_num= 0; break; default: assert(0); } } if (!current_ref_assigned && FIELD_PICTURE && !s->first_field && s->current_picture_ptr->reference) { /* Second field of complementary field pair; the first field of * which is already referenced. If short referenced, it * should be first entry in short_ref. If not, it must exist * in long_ref; trying to put it on the short list here is an * error in the encoded bit stream (ref: 7.4.3, NOTE 2 and 3). */ if (h->short_ref_count && h->short_ref[0] == s->current_picture_ptr) { /* Just mark the second field valid */ s->current_picture_ptr->reference = PICT_FRAME; } else if (s->current_picture_ptr->long_ref) { av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term reference " "assignment for second field " "in complementary field pair " "(first field is long term)\n"); } else { /* * First field in reference, but not in any sensible place on our * reference lists. This shouldn't happen unless reference * handling somewhere else is wrong. */ assert(0); } current_ref_assigned = 1; } if(!current_ref_assigned){ pic= remove_short(h, s->current_picture_ptr->frame_num); if(pic){ unreference_pic(h, pic, 0); av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n"); } if(h->short_ref_count) memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*)); h->short_ref[0]= s->current_picture_ptr; h->short_ref[0]->long_ref=0; h->short_ref_count++; s->current_picture_ptr->reference |= s->picture_structure; } if (h->long_ref_count + h->short_ref_count > h->sps.ref_frame_count){ /* We have too many reference frames, probably due to corrupted * stream. Need to discard one frame. Prevents overrun of the * short_ref and long_ref buffers. */ av_log(h->s.avctx, AV_LOG_ERROR, "number of reference frames exceeds max (probably " "corrupt input), discarding one\n"); if (h->long_ref_count && !h->short_ref_count) { for (i = 0; i < 16; ++i) if (h->long_ref[i]) break; assert(i < 16); pic = h->long_ref[i]; remove_long_at_index(h, i); } else { pic = h->short_ref[h->short_ref_count - 1]; remove_short_at_index(h, h->short_ref_count - 1); } unreference_pic(h, pic, 0); } print_short_term(h); print_long_term(h); return 0; }
false
FFmpeg
9296f5d81acb9b3f8d8870a78ded6e284a1f4f58
7,809
void qmp_input_visitor_cleanup(QmpInputVisitor *v) { qobject_decref(v->stack[0].obj); g_free(v); }
false
qemu
ce140b176920b5b65184020735a3c65ed3e9aeda
7,810
static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status) { VirtIOBlock *s = VIRTIO_BLK(vdev); uint32_t features; if (s->dataplane && !(status & (VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK))) { virtio_blk_data_plane_stop(s->dataplane); } if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) { return; } features = vdev->guest_features; /* A guest that supports VIRTIO_BLK_F_CONFIG_WCE must be able to send * cache flushes. Thus, the "auto writethrough" behavior is never * necessary for guests that support the VIRTIO_BLK_F_CONFIG_WCE feature. * Leaving it enabled would break the following sequence: * * Guest started with "-drive cache=writethrough" * Guest sets status to 0 * Guest sets DRIVER bit in status field * Guest reads host features (WCE=0, CONFIG_WCE=1) * Guest writes guest features (WCE=0, CONFIG_WCE=1) * Guest writes 1 to the WCE configuration field (writeback mode) * Guest sets DRIVER_OK bit in status field * * s->bs would erroneously be placed in writethrough mode. */ if (!(features & (1 << VIRTIO_BLK_F_CONFIG_WCE))) { aio_context_acquire(bdrv_get_aio_context(s->bs)); bdrv_set_enable_write_cache(s->bs, !!(features & (1 << VIRTIO_BLK_F_WCE))); aio_context_release(bdrv_get_aio_context(s->bs)); } }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
7,811
static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, int i, AVIOContext *pb) { AVStream *st = s->streams[i]; AVCodecContext *codec = st->codec; ebml_master subinfo, track; int native_id = 0; int qt_id = 0; int bit_depth = av_get_bits_per_sample(codec->codec_id); int sample_rate = codec->sample_rate; int output_sample_rate = 0; int j, ret; AVDictionaryEntry *tag; // ms precision is the de-facto standard timescale for mkv files avpriv_set_pts_info(st, 64, 1, 1000); if (codec->codec_type == AVMEDIA_TYPE_ATTACHMENT) { mkv->have_attachments = 1; return 0; } if (!bit_depth) bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3; if (codec->codec_id == AV_CODEC_ID_AAC) get_aac_sample_rates(s, codec, &sample_rate, &output_sample_rate); track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0); put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER , i + 1); put_ebml_uint (pb, MATROSKA_ID_TRACKUID , i + 1); put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0); // no lacing (yet) if ((tag = av_dict_get(st->metadata, "title", NULL, 0))) put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value); tag = av_dict_get(st->metadata, "language", NULL, 0); put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag ? tag->value:"und"); // The default value for TRACKFLAGDEFAULT is 1, so add element // if we need to clear it. if (!(st->disposition & AV_DISPOSITION_DEFAULT)) put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT)); if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->initial_padding) { mkv->tracks[i].ts_offset = av_rescale_q(codec->initial_padding, (AVRational){ 1, codec->sample_rate }, st->time_base); put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, av_rescale_q(codec->initial_padding, (AVRational){ 1, codec->sample_rate }, (AVRational){ 1, 1000000000 })); } // look for a codec ID string specific to mkv to use, // if none are found, use AVI codes for (j = 0; ff_mkv_codec_tags[j].id != AV_CODEC_ID_NONE; j++) { if (ff_mkv_codec_tags[j].id == codec->codec_id) { put_ebml_string(pb, MATROSKA_ID_CODECID, ff_mkv_codec_tags[j].str); native_id = 1; break; } } if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 || codec->codec_id == AV_CODEC_ID_VP9 || codec->codec_id == AV_CODEC_ID_OPUS || codec->codec_id == AV_CODEC_ID_VORBIS)) { av_log(s, AV_LOG_ERROR, "Only VP8 or VP9 video and Vorbis or Opus audio are supported for WebM.\n"); return AVERROR(EINVAL); } switch (codec->codec_type) { case AVMEDIA_TYPE_VIDEO: put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO); if (st->avg_frame_rate.num > 0 && st->avg_frame_rate.den > 0) put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 1E9 / av_q2d(st->avg_frame_rate)); if (!native_id && ff_codec_get_tag(ff_codec_movvideo_tags, codec->codec_id) && (!ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id) || codec->codec_id == AV_CODEC_ID_SVQ1 || codec->codec_id == AV_CODEC_ID_SVQ3 || codec->codec_id == AV_CODEC_ID_CINEPAK)) qt_id = 1; if (qt_id) put_ebml_string(pb, MATROSKA_ID_CODECID, "V_QUICKTIME"); else if (!native_id) { // if there is no mkv-specific codec ID, use VFW mode put_ebml_string(pb, MATROSKA_ID_CODECID, "V_MS/VFW/FOURCC"); mkv->tracks[i].write_dts = 1; } subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKVIDEO, 0); // XXX: interlace flag? put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width); put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height); // check both side data and metadata for stereo information, // write the result to the bitstream if any is found ret = mkv_write_stereo_mode(s, pb, st, mkv->mode); if (ret < 0) return ret; end_ebml_master(pb, subinfo); break; case AVMEDIA_TYPE_AUDIO: put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_AUDIO); if (!native_id) // no mkv-specific ID, use ACM mode put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM"); subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0); put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS , codec->channels); put_ebml_float (pb, MATROSKA_ID_AUDIOSAMPLINGFREQ, sample_rate); if (output_sample_rate) put_ebml_float(pb, MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, output_sample_rate); if (bit_depth) put_ebml_uint(pb, MATROSKA_ID_AUDIOBITDEPTH, bit_depth); end_ebml_master(pb, subinfo); break; case AVMEDIA_TYPE_SUBTITLE: put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_SUBTITLE); if (!native_id) { av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not supported.\n", codec->codec_id); return AVERROR(ENOSYS); } break; default: av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are supported for Matroska.\n"); break; } ret = mkv_write_codecprivate(s, pb, codec, native_id, qt_id); if (ret < 0) return ret; end_ebml_master(pb, track); return 0; }
false
FFmpeg
51da7d02748cc54b7d009115e76efa940b99a8ef
7,812
static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) { ALSSpecificConfig *sconf = &ctx->sconf; AVCodecContext *avctx = ctx->avctx; GetBitContext *gb = &ctx->gb; unsigned int div_blocks[32]; ///< block sizes. unsigned int c; unsigned int js_blocks[2]; uint32_t bs_info = 0; // skip the size of the ra unit if present in the frame if (sconf->ra_flag == RA_FLAG_FRAMES && ra_frame) skip_bits_long(gb, 32); if (sconf->mc_coding && sconf->joint_stereo) { ctx->js_switch = get_bits1(gb); align_get_bits(gb); } if (!sconf->mc_coding || ctx->js_switch) { int independent_bs = !sconf->joint_stereo; for (c = 0; c < avctx->channels; c++) { js_blocks[0] = 0; js_blocks[1] = 0; get_block_sizes(ctx, div_blocks, &bs_info); // if joint_stereo and block_switching is set, independent decoding // is signaled via the first bit of bs_info if (sconf->joint_stereo && sconf->block_switching) if (bs_info >> 31) independent_bs = 2; // if this is the last channel, it has to be decoded independently if (c == avctx->channels - 1) independent_bs = 1; if (independent_bs) { if (decode_blocks_ind(ctx, ra_frame, c, div_blocks, js_blocks)) return -1; independent_bs--; } else { if (decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks)) return -1; c++; } // store carryover raw samples memmove(ctx->raw_samples[c] - sconf->max_order, ctx->raw_samples[c] - sconf->max_order + sconf->frame_length, sizeof(*ctx->raw_samples[c]) * sconf->max_order); } } else { // multi-channel coding ALSBlockData bd; int b; int *reverted_channels = ctx->reverted_channels; unsigned int offset = 0; for (c = 0; c < avctx->channels; c++) if (ctx->chan_data[c] < ctx->chan_data_buffer) { av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data!\n"); return -1; } memset(&bd, 0, sizeof(ALSBlockData)); memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels); bd.ra_block = ra_frame; bd.prev_raw_samples = ctx->prev_raw_samples; get_block_sizes(ctx, div_blocks, &bs_info); for (b = 0; b < ctx->num_blocks; b++) { bd.block_length = div_blocks[b]; for (c = 0; c < avctx->channels; c++) { bd.const_block = ctx->const_block + c; bd.shift_lsbs = ctx->shift_lsbs + c; bd.opt_order = ctx->opt_order + c; bd.store_prev_samples = ctx->store_prev_samples + c; bd.use_ltp = ctx->use_ltp + c; bd.ltp_lag = ctx->ltp_lag + c; bd.ltp_gain = ctx->ltp_gain[c]; bd.lpc_cof = ctx->lpc_cof[c]; bd.quant_cof = ctx->quant_cof[c]; bd.raw_samples = ctx->raw_samples[c] + offset; bd.raw_other = NULL; read_block(ctx, &bd); if (read_channel_data(ctx, ctx->chan_data[c], c)) return -1; } for (c = 0; c < avctx->channels; c++) if (revert_channel_correlation(ctx, &bd, ctx->chan_data, reverted_channels, offset, c)) return -1; for (c = 0; c < avctx->channels; c++) { bd.const_block = ctx->const_block + c; bd.shift_lsbs = ctx->shift_lsbs + c; bd.opt_order = ctx->opt_order + c; bd.store_prev_samples = ctx->store_prev_samples + c; bd.use_ltp = ctx->use_ltp + c; bd.ltp_lag = ctx->ltp_lag + c; bd.ltp_gain = ctx->ltp_gain[c]; bd.lpc_cof = ctx->lpc_cof[c]; bd.quant_cof = ctx->quant_cof[c]; bd.raw_samples = ctx->raw_samples[c] + offset; decode_block(ctx, &bd); } memset(reverted_channels, 0, avctx->channels * sizeof(*reverted_channels)); offset += div_blocks[b]; bd.ra_block = 0; } // store carryover raw samples for (c = 0; c < avctx->channels; c++) memmove(ctx->raw_samples[c] - sconf->max_order, ctx->raw_samples[c] - sconf->max_order + sconf->frame_length, sizeof(*ctx->raw_samples[c]) * sconf->max_order); } // TODO: read_diff_float_data return 0; }
false
FFmpeg
7ea948bac31d9d15627466a73a07e96eb6049939
7,813
static void fw_cfg_bootsplash(FWCfgState *s) { int boot_splash_time = -1; const char *boot_splash_filename = NULL; char *p; char *filename, *file_data; gsize file_size; int file_type; const char *temp; /* get user configuration */ QemuOptsList *plist = qemu_find_opts("boot-opts"); QemuOpts *opts = QTAILQ_FIRST(&plist->head); if (opts != NULL) { temp = qemu_opt_get(opts, "splash"); if (temp != NULL) { boot_splash_filename = temp; } temp = qemu_opt_get(opts, "splash-time"); if (temp != NULL) { p = (char *)temp; boot_splash_time = strtol(p, (char **)&p, 10); } } /* insert splash time if user configurated */ if (boot_splash_time >= 0) { /* validate the input */ if (boot_splash_time > 0xffff) { error_report("splash time is big than 65535, force it to 65535."); boot_splash_time = 0xffff; } /* use little endian format */ qemu_extra_params_fw[0] = (uint8_t)(boot_splash_time & 0xff); qemu_extra_params_fw[1] = (uint8_t)((boot_splash_time >> 8) & 0xff); fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2); } /* insert splash file if user configurated */ if (boot_splash_filename != NULL) { filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filename); if (filename == NULL) { error_report("failed to find file '%s'.", boot_splash_filename); return; } /* loading file data */ file_data = read_splashfile(filename, &file_size, &file_type); if (file_data == NULL) { g_free(filename); return; } if (boot_splash_filedata != NULL) { g_free(boot_splash_filedata); } boot_splash_filedata = (uint8_t *)file_data; boot_splash_filedata_size = file_size; /* insert data */ if (file_type == JPG_FILE) { fw_cfg_add_file(s, "bootsplash.jpg", boot_splash_filedata, boot_splash_filedata_size); } else { fw_cfg_add_file(s, "bootsplash.bmp", boot_splash_filedata, boot_splash_filedata_size); } g_free(filename); } }
false
qemu
ef1e1e0782e99c9dcf2b35e5310cdd8ca9211374
7,815
int omap_validate_tipb_mpui_addr(struct omap_mpu_state_s *s, target_phys_addr_t addr) { return addr >= 0xe1010000 && addr < 0xe1020004; }
false
qemu
b854bc196f5c4b4e3299c0b0ee63cf828ece9e77
7,816
int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required, int mq_required, Error **errp) { struct ifreq ifr; int fd, ret; int len = sizeof(struct virtio_net_hdr); unsigned int features; TFR(fd = open(PATH_NET_TUN, O_RDWR)); if (fd < 0) { error_setg_errno(errp, errno, "could not open %s", PATH_NET_TUN); return -1; } memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(fd, TUNGETFEATURES, &features) == -1) { error_report("warning: TUNGETFEATURES failed: %s", strerror(errno)); features = 0; } if (features & IFF_ONE_QUEUE) { ifr.ifr_flags |= IFF_ONE_QUEUE; } if (*vnet_hdr) { if (features & IFF_VNET_HDR) { *vnet_hdr = 1; ifr.ifr_flags |= IFF_VNET_HDR; } else { *vnet_hdr = 0; } if (vnet_hdr_required && !*vnet_hdr) { error_setg(errp, "vnet_hdr=1 requested, but no kernel " "support for IFF_VNET_HDR available"); close(fd); return -1; } /* * Make sure vnet header size has the default value: for a persistent * tap it might have been modified e.g. by another instance of qemu. * Ignore errors since old kernels do not support this ioctl: in this * case the header size implicitly has the correct value. */ ioctl(fd, TUNSETVNETHDRSZ, &len); } if (mq_required) { if (!(features & IFF_MULTI_QUEUE)) { error_setg(errp, "multiqueue required, but no kernel " "support for IFF_MULTI_QUEUE available"); close(fd); return -1; } else { ifr.ifr_flags |= IFF_MULTI_QUEUE; } } if (ifname[0] != '\0') pstrcpy(ifr.ifr_name, IFNAMSIZ, ifname); else pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d"); ret = ioctl(fd, TUNSETIFF, (void *) &ifr); if (ret != 0) { if (ifname[0] != '\0') { error_setg_errno(errp, errno, "could not configure %s (%s)", PATH_NET_TUN, ifr.ifr_name); } else { error_setg_errno(errp, errno, "could not configure %s", PATH_NET_TUN); } close(fd); return -1; } pstrcpy(ifname, ifname_size, ifr.ifr_name); fcntl(fd, F_SETFL, O_NONBLOCK); return fd; }
false
qemu
3dc6f8693694a649a9c83f1e2746565b47683923
7,818
static int vnc_refresh_server_surface(VncDisplay *vd) { int width = pixman_image_get_width(vd->guest.fb); int height = pixman_image_get_height(vd->guest.fb); int y; uint8_t *guest_row; uint8_t *server_row; int cmp_bytes; VncState *vs; int has_dirty = 0; pixman_image_t *tmpbuf = NULL; struct timeval tv = { 0, 0 }; if (!vd->non_adaptive) { gettimeofday(&tv, NULL); has_dirty = vnc_update_stats(vd, &tv); } /* * Walk through the guest dirty map. * Check and copy modified bits from guest to server surface. * Update server dirty map. */ cmp_bytes = 64; if (cmp_bytes > vnc_server_fb_stride(vd)) { cmp_bytes = vnc_server_fb_stride(vd); } if (vd->guest.format != VNC_SERVER_FB_FORMAT) { int width = pixman_image_get_width(vd->server); tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, width); } guest_row = (uint8_t *)pixman_image_get_data(vd->guest.fb); server_row = (uint8_t *)pixman_image_get_data(vd->server); for (y = 0; y < height; y++) { if (!bitmap_empty(vd->guest.dirty[y], VNC_DIRTY_BITS)) { int x; uint8_t *guest_ptr; uint8_t *server_ptr; if (vd->guest.format != VNC_SERVER_FB_FORMAT) { qemu_pixman_linebuf_fill(tmpbuf, vd->guest.fb, width, y); guest_ptr = (uint8_t *)pixman_image_get_data(tmpbuf); } else { guest_ptr = guest_row; } server_ptr = server_row; for (x = 0; x + 15 < width; x += 16, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) { if (!test_and_clear_bit((x / 16), vd->guest.dirty[y])) continue; if (memcmp(server_ptr, guest_ptr, cmp_bytes) == 0) continue; memcpy(server_ptr, guest_ptr, cmp_bytes); if (!vd->non_adaptive) vnc_rect_updated(vd, x, y, &tv); QTAILQ_FOREACH(vs, &vd->clients, next) { set_bit((x / 16), vs->dirty[y]); } has_dirty++; } } guest_row += pixman_image_get_stride(vd->guest.fb); server_row += pixman_image_get_stride(vd->server); } qemu_pixman_image_unref(tmpbuf); return has_dirty; }
false
qemu
bc210eb163b162ff2e94e5c8f4307715731257f8
7,820
QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque) { QEMUTimer *ts; ts = qemu_mallocz(sizeof(QEMUTimer)); ts->clock = clock; ts->cb = cb; ts->opaque = opaque; return ts; }
false
qemu
4a998740b22aa673ea475060c787da7c545588cf
7,821
static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size) { PCIDevice *s = container_of(pv, PCIDevice, config); uint32_t irq_state[PCI_NUM_PINS]; int i; for (i = 0; i < PCI_NUM_PINS; ++i) { irq_state[i] = qemu_get_be32(f); if (irq_state[i] != 0x1 && irq_state[i] != 0) { fprintf(stderr, "irq state %d: must be 0 or 1.\n", irq_state[i]); return -EINVAL; } } for (i = 0; i < PCI_NUM_PINS; ++i) { pci_set_irq_state(s, i, irq_state[i]); } return 0; }
false
qemu
c3f8f61157625d0bb5bfc135047573de48fdc675
7,822
static void test_visitor_in_native_list_uint32(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U32); }
false
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
7,823
av_cold void ff_vp8dsp_init_armv6(VP8DSPContext *dsp) { dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_armv6; dsp->vp8_luma_dc_wht_dc = ff_vp8_luma_dc_wht_dc_armv6; dsp->vp8_idct_add = ff_vp8_idct_add_armv6; dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_armv6; dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_armv6; dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_armv6; dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_armv6; dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_armv6; dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_armv6; dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_armv6; dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_armv6; dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_armv6; dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_armv6; dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_armv6; dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter16_simple_armv6; dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter16_simple_armv6; dsp->put_vp8_epel_pixels_tab[0][0][0] = ff_put_vp8_pixels16_armv6; dsp->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_armv6; dsp->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_armv6; dsp->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_armv6; dsp->put_vp8_epel_pixels_tab[1][0][0] = ff_put_vp8_pixels8_armv6; dsp->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_armv6; dsp->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_armv6; dsp->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_armv6; dsp->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_armv6; dsp->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_armv6; dsp->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_armv6; dsp->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_armv6; dsp->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_armv6; dsp->put_vp8_epel_pixels_tab[2][0][0] = ff_put_vp8_pixels4_armv6; dsp->put_vp8_epel_pixels_tab[2][0][1] = ff_put_vp8_epel4_h4_armv6; dsp->put_vp8_epel_pixels_tab[2][0][2] = ff_put_vp8_epel4_h6_armv6; dsp->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_armv6; dsp->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_armv6; dsp->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_armv6; dsp->put_vp8_epel_pixels_tab[2][2][0] = ff_put_vp8_epel4_v6_armv6; dsp->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_armv6; dsp->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_armv6; dsp->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_armv6; dsp->put_vp8_bilinear_pixels_tab[0][0][1] = ff_put_vp8_bilin16_h_armv6; dsp->put_vp8_bilinear_pixels_tab[0][0][2] = ff_put_vp8_bilin16_h_armv6; dsp->put_vp8_bilinear_pixels_tab[0][1][0] = ff_put_vp8_bilin16_v_armv6; dsp->put_vp8_bilinear_pixels_tab[0][1][1] = ff_put_vp8_bilin16_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[0][1][2] = ff_put_vp8_bilin16_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[0][2][0] = ff_put_vp8_bilin16_v_armv6; dsp->put_vp8_bilinear_pixels_tab[0][2][1] = ff_put_vp8_bilin16_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[0][2][2] = ff_put_vp8_bilin16_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_armv6; dsp->put_vp8_bilinear_pixels_tab[1][0][1] = ff_put_vp8_bilin8_h_armv6; dsp->put_vp8_bilinear_pixels_tab[1][0][2] = ff_put_vp8_bilin8_h_armv6; dsp->put_vp8_bilinear_pixels_tab[1][1][0] = ff_put_vp8_bilin8_v_armv6; dsp->put_vp8_bilinear_pixels_tab[1][1][1] = ff_put_vp8_bilin8_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[1][1][2] = ff_put_vp8_bilin8_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[1][2][0] = ff_put_vp8_bilin8_v_armv6; dsp->put_vp8_bilinear_pixels_tab[1][2][1] = ff_put_vp8_bilin8_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[1][2][2] = ff_put_vp8_bilin8_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[2][0][0] = ff_put_vp8_pixels4_armv6; dsp->put_vp8_bilinear_pixels_tab[2][0][1] = ff_put_vp8_bilin4_h_armv6; dsp->put_vp8_bilinear_pixels_tab[2][0][2] = ff_put_vp8_bilin4_h_armv6; dsp->put_vp8_bilinear_pixels_tab[2][1][0] = ff_put_vp8_bilin4_v_armv6; dsp->put_vp8_bilinear_pixels_tab[2][1][1] = ff_put_vp8_bilin4_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[2][1][2] = ff_put_vp8_bilin4_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[2][2][0] = ff_put_vp8_bilin4_v_armv6; dsp->put_vp8_bilinear_pixels_tab[2][2][1] = ff_put_vp8_bilin4_hv_armv6; dsp->put_vp8_bilinear_pixels_tab[2][2][2] = ff_put_vp8_bilin4_hv_armv6; }
false
FFmpeg
b8664c929437d6d079e16979c496a2db40cf2324
7,824
static int nbd_receive_list(QIOChannel *ioc, const char *want, bool *match, Error **errp) { nbd_opt_reply reply; uint32_t len; uint32_t namelen; char name[NBD_MAX_NAME_SIZE + 1]; int error; if (nbd_receive_option_reply(ioc, NBD_OPT_LIST, &reply, errp) < 0) { return -1; } error = nbd_handle_reply_err(ioc, &reply, errp); if (error <= 0) { /* The server did not support NBD_OPT_LIST, so set *match on * the assumption that any name will be accepted. */ *match = true; return error; } len = reply.length; if (reply.type == NBD_REP_ACK) { if (len != 0) { error_setg(errp, "length too long for option end"); nbd_send_opt_abort(ioc); return -1; } return 0; } else if (reply.type != NBD_REP_SERVER) { error_setg(errp, "Unexpected reply type %" PRIx32 " expected %x", reply.type, NBD_REP_SERVER); nbd_send_opt_abort(ioc); return -1; } if (len < sizeof(namelen) || len > NBD_MAX_BUFFER_SIZE) { error_setg(errp, "incorrect option length %" PRIu32, len); nbd_send_opt_abort(ioc); return -1; } if (read_sync(ioc, &namelen, sizeof(namelen), errp) < 0) { error_prepend(errp, "failed to read option name length"); nbd_send_opt_abort(ioc); return -1; } namelen = be32_to_cpu(namelen); len -= sizeof(namelen); if (len < namelen) { error_setg(errp, "incorrect option name length"); nbd_send_opt_abort(ioc); return -1; } if (namelen != strlen(want)) { if (drop_sync(ioc, len, errp) < 0) { error_prepend(errp, "failed to skip export name with wrong length"); nbd_send_opt_abort(ioc); return -1; } return 1; } assert(namelen < sizeof(name)); if (read_sync(ioc, name, namelen, errp) < 0) { error_prepend(errp, "failed to read export name"); nbd_send_opt_abort(ioc); return -1; } name[namelen] = '\0'; len -= namelen; if (drop_sync(ioc, len, errp) < 0) { error_prepend(errp, "failed to read export description"); nbd_send_opt_abort(ioc); return -1; } if (!strcmp(name, want)) { *match = true; } return 1; }
false
qemu
d1fdf257d52822695f5ace6c586e059aa17d4b79
7,825
static inline void cris_alu_alloc_temps(DisasContext *dc, int size, TCGv *t) { if (size == 4) { t[0] = cpu_R[dc->op2]; t[1] = cpu_R[dc->op1]; } else { t[0] = tcg_temp_new(TCG_TYPE_TL); t[1] = tcg_temp_new(TCG_TYPE_TL); } }
false
qemu
a7812ae412311d7d47f8aa85656faadac9d64b56
7,827
START_TEST(simple_varargs) { QObject *embedded_obj; QObject *obj; LiteralQObject decoded = QLIT_QLIST(((LiteralQObject[]){ QLIT_QINT(1), QLIT_QINT(2), QLIT_QLIST(((LiteralQObject[]){ QLIT_QINT(32), QLIT_QINT(42), {}})), {}})); embedded_obj = qobject_from_json("[32, 42]"); fail_unless(embedded_obj != NULL); obj = qobject_from_jsonf("[%d, 2, %p]", 1, embedded_obj); fail_unless(obj != NULL); fail_unless(compare_litqobj_to_qobj(&decoded, obj) == 1); qobject_decref(obj); }
false
qemu
ef76dc59fa5203d146a2acf85a0ad5a5971a4824
7,829
int pci_device_load(PCIDevice *s, QEMUFile *f) { uint8_t config[PCI_CONFIG_SPACE_SIZE]; uint32_t version_id; int i; version_id = qemu_get_be32(f); if (version_id > 2) return -EINVAL; qemu_get_buffer(f, config, sizeof config); for (i = 0; i < sizeof config; ++i) if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i]) return -EINVAL; memcpy(s->config, config, sizeof config); pci_update_mappings(s); if (version_id >= 2) for (i = 0; i < 4; i ++) s->irq_state[i] = qemu_get_be32(f); return 0; }
false
qemu
73534f2f682f2957fabb25e3890481098cc5dcee
7,830
static int usbredir_handle_interrupt_data(USBRedirDevice *dev, USBPacket *p, uint8_t ep) { if (ep & USB_DIR_IN) { /* Input interrupt endpoint, buffered packet input */ struct buf_packet *intp; int status, len; if (!dev->endpoint[EP2I(ep)].interrupt_started && !dev->endpoint[EP2I(ep)].interrupt_error) { struct usb_redir_start_interrupt_receiving_header start_int = { .endpoint = ep, }; /* No id, we look at the ep when receiving a status back */ usbredirparser_send_start_interrupt_receiving(dev->parser, 0, &start_int); usbredirparser_do_write(dev->parser); DPRINTF("interrupt recv started ep %02X\n", ep); dev->endpoint[EP2I(ep)].interrupt_started = 1; /* We don't really want to drop interrupt packets ever, but having some upper limit to how much we buffer is good. */ dev->endpoint[EP2I(ep)].bufpq_target_size = 1000; dev->endpoint[EP2I(ep)].bufpq_dropping_packets = 0; } intp = QTAILQ_FIRST(&dev->endpoint[EP2I(ep)].bufpq); if (intp == NULL) { DPRINTF2("interrupt-token-in ep %02X, no intp\n", ep); /* Check interrupt_error for stream errors */ status = dev->endpoint[EP2I(ep)].interrupt_error; dev->endpoint[EP2I(ep)].interrupt_error = 0; if (status) { return usbredir_handle_status(dev, status, 0); } return USB_RET_NAK; } DPRINTF("interrupt-token-in ep %02X status %d len %d\n", ep, intp->status, intp->len); status = intp->status; if (status != usb_redir_success) { bufp_free(dev, intp, ep); return usbredir_handle_status(dev, status, 0); } len = intp->len; if (len > p->iov.size) { ERROR("received int data is larger then packet ep %02X\n", ep); bufp_free(dev, intp, ep); return USB_RET_BABBLE; } usb_packet_copy(p, intp->data, len); bufp_free(dev, intp, ep); return len; } else { /* Output interrupt endpoint, normal async operation */ AsyncURB *aurb = async_alloc(dev, p); struct usb_redir_interrupt_packet_header interrupt_packet; uint8_t buf[p->iov.size]; DPRINTF("interrupt-out ep %02X len %zd id %u\n", ep, p->iov.size, aurb->packet_id); interrupt_packet.endpoint = ep; interrupt_packet.length = p->iov.size; aurb->interrupt_packet = interrupt_packet; usb_packet_copy(p, buf, p->iov.size); usbredir_log_data(dev, "interrupt data out:", buf, p->iov.size); usbredirparser_send_interrupt_packet(dev->parser, aurb->packet_id, &interrupt_packet, buf, p->iov.size); usbredirparser_do_write(dev->parser); return USB_RET_ASYNC; } }
false
qemu
104981d52b63dc3d68f39d4442881c667f44bbb9
7,831
void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) { unsigned int i; for (i = 0; i < ARRAY_SIZE(x86_defs); i++) (*cpu_fprintf)(f, "x86 %16s\n", x86_defs[i].name); }
false
qemu
b5ec5ce0e39d6e7ea707d5604a5f6d567dfd2f48
7,832
void qio_dns_resolver_lookup_result(QIODNSResolver *resolver, QIOTask *task, size_t *naddrs, SocketAddress ***addrs) { struct QIODNSResolverLookupData *data = qio_task_get_result_pointer(task); size_t i; *naddrs = 0; *addrs = NULL; if (!data) { return; } *naddrs = data->naddrs; *addrs = g_new0(SocketAddress *, data->naddrs); for (i = 0; i < data->naddrs; i++) { (*addrs)[i] = QAPI_CLONE(SocketAddress, data->addrs[i]); } }
false
qemu
dfd100f242370886bb6732f70f1f7cbd8eb9fedc
7,833
void virtio_init_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov, unsigned int *pniov, bool is_write) { V9fsState *s = pdu->s; V9fsVirtioState *v = container_of(s, V9fsVirtioState, state); VirtQueueElement *elem = &v->elems[pdu->idx]; if (is_write) { *piov = elem->out_sg; *pniov = elem->out_num; } else { *piov = elem->in_sg; *pniov = elem->in_num; } }
false
qemu
51b19ebe4320f3dcd93cea71235c1219318ddfd2
7,835
BlockDriverState *bdrv_next_node(BlockDriverState *bs) { if (!bs) { return QTAILQ_FIRST(&graph_bdrv_states); } return QTAILQ_NEXT(bs, node_list); }
false
qemu
61007b316cd71ee7333ff7a0a749a8949527575f
7,836
CPUState *ppc4xx_init (const char *cpu_model, clk_setup_t *cpu_clk, clk_setup_t *tb_clk, uint32_t sysclk) { CPUState *env; /* init CPUs */ env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find PowerPC %s CPU definition\n", cpu_model); exit(1); } cpu_clk->cb = NULL; /* We don't care about CPU clock frequency changes */ cpu_clk->opaque = env; /* Set time-base frequency to sysclk */ tb_clk->cb = ppc_emb_timers_init(env, sysclk); tb_clk->opaque = env; ppc_dcr_init(env, NULL, NULL); /* Register qemu callbacks */ qemu_register_reset((QEMUResetHandler*)&cpu_reset, env); return env; }
false
qemu
d63cb48db9016328a7a69f3a1c2938cd3dfc9d1a
7,838
void qemu_del_vm_change_state_handler(VMChangeStateEntry *e) { LIST_REMOVE (e, entries); qemu_free (e); }
false
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
7,839
static void ps2_mouse_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { static const int bmap[INPUT_BUTTON__MAX] = { [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON, }; PS2MouseState *s = (PS2MouseState *)dev; InputMoveEvent *move; InputBtnEvent *btn; /* check if deltas are recorded when disabled */ if (!(s->mouse_status & MOUSE_STATUS_ENABLED)) return; switch (evt->type) { case INPUT_EVENT_KIND_REL: move = evt->u.rel; if (move->axis == INPUT_AXIS_X) { s->mouse_dx += move->value; } else if (move->axis == INPUT_AXIS_Y) { s->mouse_dy -= move->value; } break; case INPUT_EVENT_KIND_BTN: btn = evt->u.btn; if (btn->down) { s->mouse_buttons |= bmap[btn->button]; if (btn->button == INPUT_BUTTON_WHEEL_UP) { s->mouse_dz--; } else if (btn->button == INPUT_BUTTON_WHEEL_DOWN) { s->mouse_dz++; } } else { s->mouse_buttons &= ~bmap[btn->button]; } break; default: /* keep gcc happy */ break; } }
false
qemu
32bafa8fdd098d52fbf1102d5a5e48d29398c0aa