project
stringclasses 2
values | commit_id
stringlengths 40
40
| target
int64 0
1
| func
stringlengths 26
142k
| idx
int64 0
27.3k
|
---|---|---|---|---|
FFmpeg | 1d16a1cf99488f16492b1bb48e023f4da8377e07 | 0 | static void ff_h264_idct_add8_sse2(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
int i;
for(i=16; i<16+8; i+=2){
if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ])
ff_x264_add8x4_idct_sse2 (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
else if(block[i*16]|block[i*16+16])
ff_h264_idct_dc_add8_mmx2(dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
}
}
| 5,447 |
FFmpeg | 6a63ff19b6a7fe3bc32c7fb4a62fca8f65786432 | 0 | static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int entries, i, j;
get_be32(pb); // version + flags
entries = get_be32(pb);
if (entries >= UINT_MAX / sizeof(*sc->drefs))
return -1;
sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
if (!sc->drefs)
return AVERROR(ENOMEM);
sc->drefs_count = entries;
for (i = 0; i < sc->drefs_count; i++) {
MOVDref *dref = &sc->drefs[i];
uint32_t size = get_be32(pb);
int64_t next = url_ftell(pb) + size - 4;
dref->type = get_le32(pb);
get_be32(pb); // version + flags
dprintf(c->fc, "type %.4s size %d\n", (char*)&dref->type, size);
if (dref->type == MKTAG('a','l','i','s') && size > 150) {
/* macintosh alias record */
uint16_t volume_len, len;
char volume[28];
int16_t type;
url_fskip(pb, 10);
volume_len = get_byte(pb);
volume_len = FFMIN(volume_len, 27);
get_buffer(pb, volume, 27);
volume[volume_len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "volume %s, len %d\n", volume, volume_len);
url_fskip(pb, 112);
for (type = 0; type != -1 && url_ftell(pb) < next; ) {
type = get_be16(pb);
len = get_be16(pb);
av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);
if (len&1)
len += 1;
if (type == 2) { // absolute path
av_free(dref->path);
dref->path = av_mallocz(len+1);
if (!dref->path)
return AVERROR(ENOMEM);
get_buffer(pb, dref->path, len);
if (len > volume_len && !strncmp(dref->path, volume, volume_len)) {
len -= volume_len;
memmove(dref->path, dref->path+volume_len, len);
dref->path[len] = 0;
}
for (j = 0; j < len; j++)
if (dref->path[j] == ':')
dref->path[j] = '/';
av_log(c->fc, AV_LOG_DEBUG, "path %s\n", dref->path);
} else
url_fskip(pb, len);
}
}
url_fseek(pb, next, SEEK_SET);
}
return 0;
}
| 5,448 |
FFmpeg | 582552fb56ba6559cb1d094a7e7ae5dde3073c5c | 0 | void yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4])
{
vector signed short CY, CRV, CBU, CGU, CGV, OY, Y0;
int64_t crv __attribute__ ((aligned(16))) = inv_table[0];
int64_t cbu __attribute__ ((aligned(16))) = inv_table[1];
int64_t cgu __attribute__ ((aligned(16))) = inv_table[2];
int64_t cgv __attribute__ ((aligned(16))) = inv_table[3];
int64_t cy = (1<<16)-1;
int64_t oy = 0;
short tmp __attribute__ ((aligned(16)));
if ((c->flags & SWS_CPU_CAPS_ALTIVEC) == 0)
return;
cy = (cy *c->contrast )>>17;
crv= (crv*c->contrast * c->saturation)>>32;
cbu= (cbu*c->contrast * c->saturation)>>32;
cgu= (cgu*c->contrast * c->saturation)>>32;
cgv= (cgv*c->contrast * c->saturation)>>32;
oy -= 256*c->brightness;
tmp = cy;
CY = vec_lde (0, &tmp);
CY = vec_splat (CY, 0);
tmp = oy;
OY = vec_lde (0, &tmp);
OY = vec_splat (OY, 0);
tmp = crv>>3;
CRV = vec_lde (0, &tmp);
CRV = vec_splat (CRV, 0);
tmp = cbu>>3;
CBU = vec_lde (0, &tmp);
CBU = vec_splat (CBU, 0);
tmp = -(cgu>>1);
CGU = vec_lde (0, &tmp);
CGU = vec_splat (CGU, 0);
tmp = -(cgv>>1);
CGV = vec_lde (0, &tmp);
CGV = vec_splat (CGV, 0);
c->CSHIFT = (vector unsigned short)(2);
c->CY = CY;
c->OY = OY;
c->CRV = CRV;
c->CBU = CBU;
c->CGU = CGU;
c->CGV = CGV;
#if 0
printf ("cy: %hvx\n", CY);
printf ("oy: %hvx\n", OY);
printf ("crv: %hvx\n", CRV);
printf ("cbu: %hvx\n", CBU);
printf ("cgv: %hvx\n", CGV);
printf ("cgu: %hvx\n", CGU);
#endif
return;
}
| 5,449 |
qemu | ae50b2747f77944faa79eb914272b54eb30b63b3 | 1 | void mipsnet_init (int base, qemu_irq irq, NICInfo *nd)
{
MIPSnetState *s;
qemu_check_nic_model(nd, "mipsnet");
s = qemu_mallocz(sizeof(MIPSnetState));
register_ioport_write(base, 36, 1, mipsnet_ioport_write, s);
register_ioport_read(base, 36, 1, mipsnet_ioport_read, s);
register_ioport_write(base, 36, 2, mipsnet_ioport_write, s);
register_ioport_read(base, 36, 2, mipsnet_ioport_read, s);
register_ioport_write(base, 36, 4, mipsnet_ioport_write, s);
register_ioport_read(base, 36, 4, mipsnet_ioport_read, s);
s->io_base = base;
s->irq = irq;
if (nd && nd->vlan) {
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
mipsnet_can_receive, mipsnet_receive, NULL,
mipsnet_cleanup, s);
} else {
s->vc = NULL;
}
qemu_format_nic_info_str(s->vc, nd->macaddr);
mipsnet_reset(s);
register_savevm("mipsnet", 0, 0, mipsnet_save, mipsnet_load, s);
}
| 5,450 |
FFmpeg | 877f76ad33bb9b0b0d09565dd9ec1cf8e91096f1 | 1 | static inline void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst1[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst2[i]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
xpos+=xInc;
| 5,451 |
FFmpeg | 32be264cea542b4dc721b10092bf1dfe511a28ee | 1 | static void apply_window_and_mdct(AACEncContext *s, SingleChannelElement *sce,
float *audio)
{
int i;
float *output = sce->ret_buf;
apply_window[sce->ics.window_sequence[0]](s->fdsp, sce, audio);
if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE)
s->mdct1024.mdct_calc(&s->mdct1024, sce->coeffs, output);
else
for (i = 0; i < 1024; i += 128)
s->mdct128.mdct_calc(&s->mdct128, sce->coeffs + i, output + i*2);
memcpy(audio, audio + 1024, sizeof(audio[0]) * 1024);
memcpy(sce->pcoeffs, sce->coeffs, sizeof(sce->pcoeffs));
}
| 5,453 |
qemu | ad4aca69bbd40663ca93a3eb1d8042c023b9b407 | 1 | TPMVersion tpm_tis_get_tpm_version(Object *obj)
{
TPMState *s = TPM(obj);
return tpm_backend_get_tpm_version(s->be_driver); | 5,454 |
qemu | c707582b78d01d81fe4e470fd812334be145882d | 1 | vmxnet3_indicate_packet(VMXNET3State *s)
{
struct Vmxnet3_RxDesc rxd;
bool is_head = true;
uint32_t rxd_idx;
uint32_t rx_ridx;
struct Vmxnet3_RxCompDesc rxcd;
uint32_t new_rxcd_gen = VMXNET3_INIT_GEN;
hwaddr new_rxcd_pa = 0;
hwaddr ready_rxcd_pa = 0;
struct iovec *data = vmxnet_rx_pkt_get_iovec(s->rx_pkt);
size_t bytes_copied = 0;
size_t bytes_left = vmxnet_rx_pkt_get_total_len(s->rx_pkt);
uint16_t num_frags = 0;
size_t chunk_size;
vmxnet_rx_pkt_dump(s->rx_pkt);
while (bytes_left > 0) {
/* cannot add more frags to packet */
if (num_frags == s->max_rx_frags) {
break;
}
new_rxcd_pa = vmxnet3_pop_rxc_descr(s, RXQ_IDX, &new_rxcd_gen);
if (!new_rxcd_pa) {
break;
}
if (!vmxnet3_get_next_rx_descr(s, is_head, &rxd, &rxd_idx, &rx_ridx)) {
break;
}
chunk_size = MIN(bytes_left, rxd.len);
vmxnet3_physical_memory_writev(data, bytes_copied,
le64_to_cpu(rxd.addr), chunk_size);
bytes_copied += chunk_size;
bytes_left -= chunk_size;
vmxnet3_dump_rx_descr(&rxd);
if (0 != ready_rxcd_pa) {
cpu_physical_memory_write(ready_rxcd_pa, &rxcd, sizeof(rxcd));
}
memset(&rxcd, 0, sizeof(struct Vmxnet3_RxCompDesc));
rxcd.rxdIdx = rxd_idx;
rxcd.len = chunk_size;
rxcd.sop = is_head;
rxcd.gen = new_rxcd_gen;
rxcd.rqID = RXQ_IDX + rx_ridx * s->rxq_num;
if (0 == bytes_left) {
vmxnet3_rx_update_descr(s->rx_pkt, &rxcd);
}
VMW_RIPRN("RX Completion descriptor: rxRing: %lu rxIdx %lu len %lu "
"sop %d csum_correct %lu",
(unsigned long) rx_ridx,
(unsigned long) rxcd.rxdIdx,
(unsigned long) rxcd.len,
(int) rxcd.sop,
(unsigned long) rxcd.tuc);
is_head = false;
ready_rxcd_pa = new_rxcd_pa;
new_rxcd_pa = 0;
}
if (0 != ready_rxcd_pa) {
rxcd.eop = 1;
rxcd.err = (0 != bytes_left);
cpu_physical_memory_write(ready_rxcd_pa, &rxcd, sizeof(rxcd));
/* Flush RX descriptor changes */
smp_wmb();
}
if (0 != new_rxcd_pa) {
vmxnet3_revert_rxc_descr(s, RXQ_IDX);
}
vmxnet3_trigger_interrupt(s, s->rxq_descr[RXQ_IDX].intr_idx);
if (bytes_left == 0) {
vmxnet3_on_rx_done_update_stats(s, RXQ_IDX, VMXNET3_PKT_STATUS_OK);
return true;
} else if (num_frags == s->max_rx_frags) {
vmxnet3_on_rx_done_update_stats(s, RXQ_IDX, VMXNET3_PKT_STATUS_ERROR);
return false;
} else {
vmxnet3_on_rx_done_update_stats(s, RXQ_IDX,
VMXNET3_PKT_STATUS_OUT_OF_BUF);
return false;
}
}
| 5,455 |
qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | 0 | static void sp804_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
sp804_state *s = (sp804_state *)opaque;
if (offset < 0x20) {
arm_timer_write(s->timer[0], offset, value);
return;
}
if (offset < 0x40) {
arm_timer_write(s->timer[1], offset - 0x20, value);
return;
}
/* Technically we could be writing to the Test Registers, but not likely */
hw_error("%s: Bad offset %x\n", __func__, (int)offset);
}
| 5,456 |
qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | 0 | static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)
{
int sense;
bool start = buf[4] & 1;
bool loej = buf[4] & 2; /* load on start, eject on !start */
int pwrcnd = buf[4] & 0xf0;
if (pwrcnd) {
/* eject/load only happens for power condition == 0 */
return;
}
if (loej) {
if (!start && !s->tray_open && s->tray_locked) {
sense = bdrv_is_inserted(s->bs)
? NOT_READY : ILLEGAL_REQUEST;
ide_atapi_cmd_error(s, sense, ASC_MEDIA_REMOVAL_PREVENTED);
return;
}
if (s->tray_open != !start) {
bdrv_eject(s->bs, !start);
s->tray_open = !start;
}
}
ide_atapi_cmd_ok(s);
}
| 5,458 |
qemu | 4af245dc3e6e5c96405b3edb9d75657504256469 | 0 | void migration_tls_channel_connect(MigrationState *s,
QIOChannel *ioc,
const char *hostname,
Error **errp)
{
QCryptoTLSCreds *creds;
QIOChannelTLS *tioc;
creds = migration_tls_get_creds(
s, QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT, errp);
if (!creds) {
return;
}
if (s->parameters.tls_hostname) {
hostname = s->parameters.tls_hostname;
}
if (!hostname) {
error_setg(errp, "No hostname available for TLS");
return;
}
tioc = qio_channel_tls_new_client(
ioc, creds, hostname, errp);
if (!tioc) {
return;
}
trace_migration_tls_outgoing_handshake_start(hostname);
qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-outgoing");
qio_channel_tls_handshake(tioc,
migration_tls_outgoing_handshake,
s,
NULL);
}
| 5,461 |
qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | 0 | void bdrv_add_before_write_notifier(BlockDriverState *bs,
NotifierWithReturn *notifier)
{
notifier_with_return_list_add(&bs->before_write_notifiers, notifier);
}
| 5,462 |
qemu | e1c37d0e94048502f9874e6356ce7136d4b05bdb | 0 | static int qemu_savevm_state(Monitor *mon, QEMUFile *f)
{
int ret;
if (qemu_savevm_state_blocked(mon)) {
ret = -EINVAL;
goto out;
}
ret = qemu_savevm_state_begin(f, 0, 0);
if (ret < 0)
goto out;
do {
ret = qemu_savevm_state_iterate(f);
if (ret < 0)
goto out;
} while (ret == 0);
ret = qemu_savevm_state_complete(f);
out:
if (ret == 0) {
ret = qemu_file_get_error(f);
}
return ret;
}
| 5,463 |
qemu | da3e8a23492dbc13c4b70d90b6ae42970624e63a | 0 | static void s390_virtio_net_realize(VirtIOS390Device *s390_dev, Error **errp)
{
DeviceState *qdev = DEVICE(s390_dev);
VirtIONetS390 *dev = VIRTIO_NET_S390(s390_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
virtio_net_set_config_size(&dev->vdev, s390_dev->host_features);
virtio_net_set_netclient_name(&dev->vdev, qdev->id,
object_get_typename(OBJECT(qdev)));
qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
}
| 5,465 |
qemu | bdfd065b1f75cacca21af0b8d4811c64cc48d04c | 0 | static void nvdimm_build_ssdt(GSList *device_list, GArray *table_offsets,
GArray *table_data, BIOSLinker *linker,
GArray *dsm_dma_arrea)
{
Aml *ssdt, *sb_scope, *dev;
int mem_addr_offset, nvdimm_ssdt;
acpi_add_table(table_offsets, table_data);
ssdt = init_aml_allocator();
acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
sb_scope = aml_scope("\\_SB");
dev = aml_device("NVDR");
/*
* ACPI 6.0: 9.20 NVDIMM Devices:
*
* The ACPI Name Space device uses _HID of ACPI0012 to identify the root
* NVDIMM interface device. Platform firmware is required to contain one
* such device in _SB scope if NVDIMMs support is exposed by platform to
* OSPM.
* For each NVDIMM present or intended to be supported by platform,
* platform firmware also exposes an ACPI Namespace Device under the
* root device.
*/
aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0012")));
nvdimm_build_common_dsm(dev);
/* 0 is reserved for root device. */
nvdimm_build_device_dsm(dev, 0);
nvdimm_build_nvdimm_devices(device_list, dev);
aml_append(sb_scope, dev);
aml_append(ssdt, sb_scope);
nvdimm_ssdt = table_data->len;
/* copy AML table into ACPI tables blob and patch header there */
g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
mem_addr_offset = build_append_named_dword(table_data,
NVDIMM_ACPI_MEM_ADDR);
bios_linker_loader_alloc(linker,
NVDIMM_DSM_MEM_FILE, dsm_dma_arrea,
sizeof(NvdimmDsmIn), false /* high memory */);
bios_linker_loader_add_pointer(linker,
ACPI_BUILD_TABLE_FILE, mem_addr_offset, sizeof(uint32_t),
NVDIMM_DSM_MEM_FILE, 0);
build_header(linker, table_data,
(void *)(table_data->data + nvdimm_ssdt),
"SSDT", table_data->len - nvdimm_ssdt, 1, NULL, "NVDIMM");
free_aml_allocator();
}
| 5,466 |
FFmpeg | da8242e2d6f85d95239082efd0e5e2345e685a2c | 0 | static av_cold int eightsvx_decode_init(AVCodecContext *avctx)
{
EightSvxContext *esc = avctx->priv_data;
if (avctx->channels < 1 || avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "8SVX does not support more than 2 channels\n");
return AVERROR_INVALIDDATA;
}
switch (avctx->codec->id) {
case AV_CODEC_ID_8SVX_FIB: esc->table = fibonacci; break;
case AV_CODEC_ID_8SVX_EXP: esc->table = exponential; break;
case AV_CODEC_ID_PCM_S8_PLANAR:
case AV_CODEC_ID_8SVX_RAW: esc->table = NULL; break;
default:
av_log(avctx, AV_LOG_ERROR, "Invalid codec id %d.\n", avctx->codec->id);
return AVERROR_INVALIDDATA;
}
avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
avcodec_get_frame_defaults(&esc->frame);
avctx->coded_frame = &esc->frame;
return 0;
}
| 5,468 |
FFmpeg | e6ec482b429b241de0fb3088d87e28777d70ded5 | 0 | static av_cold int opus_encode_init(AVCodecContext *avctx)
{
int i, ch, ret;
OpusEncContext *s = avctx->priv_data;
s->avctx = avctx;
s->channels = avctx->channels;
/* Opus allows us to change the framesize on each packet (and each packet may
* have multiple frames in it) but we can't change the codec's frame size on
* runtime, so fix it to the lowest possible number of samples and use a queue
* to accumulate AVFrames until we have enough to encode whatever the encoder
* decides is the best */
avctx->frame_size = 120;
/* Initial padding will change if SILK is ever supported */
avctx->initial_padding = 120;
avctx->cutoff = !avctx->cutoff ? 20000 : avctx->cutoff;
if (!avctx->bit_rate) {
int coupled = ff_opus_default_coupled_streams[s->channels - 1];
avctx->bit_rate = coupled*(96000) + (s->channels - coupled*2)*(48000);
} else if (avctx->bit_rate < 6000 || avctx->bit_rate > 255000 * s->channels) {
int64_t clipped_rate = av_clip(avctx->bit_rate, 6000, 255000 * s->channels);
av_log(avctx, AV_LOG_ERROR, "Unsupported bitrate %"PRId64" kbps, clipping to %"PRId64" kbps\n",
avctx->bit_rate/1000, clipped_rate/1000);
avctx->bit_rate = clipped_rate;
}
/* Frame structs and range coder buffers */
s->frame = av_malloc(OPUS_MAX_FRAMES_PER_PACKET*sizeof(CeltFrame));
if (!s->frame)
return AVERROR(ENOMEM);
s->rc = av_malloc(OPUS_MAX_FRAMES_PER_PACKET*sizeof(OpusRangeCoder));
if (!s->rc)
return AVERROR(ENOMEM);
/* Extradata */
avctx->extradata_size = 19;
avctx->extradata = av_malloc(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
return AVERROR(ENOMEM);
opus_write_extradata(avctx);
ff_af_queue_init(avctx, &s->afq);
if (!(s->dsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT)))
return AVERROR(ENOMEM);
/* I have no idea why a base scaling factor of 68 works, could be the twiddles */
for (i = 0; i < CELT_BLOCK_NB; i++)
if ((ret = ff_mdct15_init(&s->mdct[i], 0, i + 3, 68 << (CELT_BLOCK_NB - 1 - i))))
return AVERROR(ENOMEM);
for (i = 0; i < OPUS_MAX_FRAMES_PER_PACKET; i++)
s->frame[i].block[0].emph_coeff = s->frame[i].block[1].emph_coeff = 0.0f;
/* Zero out previous energy (matters for inter first frame) */
for (ch = 0; ch < s->channels; ch++)
for (i = 0; i < CELT_MAX_BANDS; i++)
s->last_quantized_energy[ch][i] = 0.0f;
/* Allocate an empty frame to use as overlap for the first frame of audio */
ff_bufqueue_add(avctx, &s->bufqueue, spawn_empty_frame(s));
if (!ff_bufqueue_peek(&s->bufqueue, 0))
return AVERROR(ENOMEM);
return 0;
}
| 5,469 |
qemu | a818a4b69d47ca3826dee36878074395aeac2083 | 0 | static void scsi_destroy(SCSIDevice *s)
{
scsi_device_purge_requests(s, SENSE_CODE(NO_SENSE));
blockdev_mark_auto_del(s->conf.bs);
}
| 5,471 |
qemu | f6102c329c43d7d5e0bee1fc2fe4043e05f9810c | 0 | static void init_event_facility_class(ObjectClass *klass, void *data)
{
SysBusDeviceClass *sbdc = SYS_BUS_DEVICE_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(sbdc);
SCLPEventFacilityClass *k = EVENT_FACILITY_CLASS(dc);
dc->reset = reset_event_facility;
dc->vmsd = &vmstate_event_facility;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
k->init = init_event_facility;
k->command_handler = command_handler;
k->event_pending = event_pending;
}
| 5,472 |
qemu | 8bba5c81b1febeb20cdd60f1c18eb0e695cad6d6 | 0 | static void set_pixel_format(VncState *vs,
int bits_per_pixel, int depth,
int big_endian_flag, int true_color_flag,
int red_max, int green_max, int blue_max,
int red_shift, int green_shift, int blue_shift)
{
int host_big_endian_flag;
#ifdef WORDS_BIGENDIAN
host_big_endian_flag = 1;
#else
host_big_endian_flag = 0;
#endif
if (!true_color_flag) {
fail:
vnc_client_error(vs);
return;
}
if (bits_per_pixel == 32 &&
host_big_endian_flag == big_endian_flag &&
red_max == 0xff && green_max == 0xff && blue_max == 0xff &&
red_shift == 16 && green_shift == 8 && blue_shift == 0) {
vs->depth = 4;
vs->write_pixels = vnc_write_pixels_copy;
vs->send_hextile_tile = send_hextile_tile_32;
} else
if (bits_per_pixel == 16 &&
host_big_endian_flag == big_endian_flag &&
red_max == 31 && green_max == 63 && blue_max == 31 &&
red_shift == 11 && green_shift == 5 && blue_shift == 0) {
vs->depth = 2;
vs->write_pixels = vnc_write_pixels_copy;
vs->send_hextile_tile = send_hextile_tile_16;
} else
if (bits_per_pixel == 8 &&
red_max == 7 && green_max == 7 && blue_max == 3 &&
red_shift == 5 && green_shift == 2 && blue_shift == 0) {
vs->depth = 1;
vs->write_pixels = vnc_write_pixels_copy;
vs->send_hextile_tile = send_hextile_tile_8;
} else
{
/* generic and slower case */
if (bits_per_pixel != 8 &&
bits_per_pixel != 16 &&
bits_per_pixel != 32)
goto fail;
vs->depth = 4;
vs->red_shift = red_shift;
vs->red_max = red_max;
vs->red_shift1 = 24 - compute_nbits(red_max);
vs->green_shift = green_shift;
vs->green_max = green_max;
vs->green_shift1 = 16 - compute_nbits(green_max);
vs->blue_shift = blue_shift;
vs->blue_max = blue_max;
vs->blue_shift1 = 8 - compute_nbits(blue_max);
vs->pix_bpp = bits_per_pixel / 8;
vs->pix_big_endian = big_endian_flag;
vs->write_pixels = vnc_write_pixels_generic;
vs->send_hextile_tile = send_hextile_tile_generic;
}
vnc_dpy_resize(vs->ds, vs->ds->width, vs->ds->height);
memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));
memset(vs->old_data, 42, vs->ds->linesize * vs->ds->height);
vga_hw_invalidate();
vga_hw_update();
}
| 5,473 |
qemu | 1ff7df1a848044f58d0f3540f1447db4bb1d2d20 | 0 | void do_info_vnc(Monitor *mon)
{
if (vnc_display == NULL || vnc_display->display == NULL)
monitor_printf(mon, "VNC server disabled\n");
else {
monitor_printf(mon, "VNC server active on: ");
monitor_print_filename(mon, vnc_display->display);
monitor_printf(mon, "\n");
if (vnc_display->clients == NULL)
monitor_printf(mon, "No client connected\n");
else
monitor_printf(mon, "Client connected\n");
}
}
| 5,474 |
qemu | 9f939df955a4152aad69a19a77e0898631bb2c18 | 0 | void qemu_chr_generic_open(CharDriverState *s)
{
if (s->open_timer == NULL) {
s->open_timer = qemu_new_timer_ms(rt_clock,
qemu_chr_fire_open_event, s);
qemu_mod_timer(s->open_timer, qemu_get_clock_ms(rt_clock) - 1);
}
}
| 5,475 |
qemu | 25f8e2f512d87f0a77fc5c0b367dd200a7834d21 | 0 | static int pci_piix4_ide_initfn(PCIDevice *dev)
{
PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
pci_config_set_vendor_id(d->dev.config, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(d->dev.config, PCI_DEVICE_ID_INTEL_82371AB);
return pci_piix_ide_initfn(d);
}
| 5,476 |
qemu | eb05e011e248c6fb6baee295e14fd206e136028c | 0 | static void block_job_defer_to_main_loop_bh(void *opaque)
{
BlockJobDeferToMainLoopData *data = opaque;
AioContext *aio_context;
/* Prevent race with block_job_defer_to_main_loop() */
aio_context_acquire(data->aio_context);
/* Fetch BDS AioContext again, in case it has changed */
aio_context = blk_get_aio_context(data->job->blk);
if (aio_context != data->aio_context) {
aio_context_acquire(aio_context);
}
data->job->deferred_to_main_loop = false;
data->fn(data->job, data->opaque);
if (aio_context != data->aio_context) {
aio_context_release(aio_context);
}
aio_context_release(data->aio_context);
g_free(data);
}
| 5,477 |
qemu | d0e14376eefc40b07c8fb42c132c2202c66dcb0b | 0 | static void virtio_blk_handle_read(VirtIOBlockReq *req)
{
uint64_t sector;
sector = virtio_ldq_p(VIRTIO_DEVICE(req->dev), &req->out.sector);
bdrv_acct_start(req->dev->bs, &req->acct, req->qiov.size, BDRV_ACCT_READ);
trace_virtio_blk_handle_read(req, sector, req->qiov.size / 512);
if (sector & req->dev->sector_mask) {
virtio_blk_rw_complete(req, -EIO);
return;
}
if (req->qiov.size % req->dev->conf->logical_block_size) {
virtio_blk_rw_complete(req, -EIO);
return;
}
bdrv_aio_readv(req->dev->bs, sector, &req->qiov,
req->qiov.size / BDRV_SECTOR_SIZE,
virtio_blk_rw_complete, req);
}
| 5,478 |
qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | 0 | envlist_unsetenv(envlist_t *envlist, const char *env)
{
struct envlist_entry *entry;
size_t envname_len;
if ((envlist == NULL) || (env == NULL))
return (EINVAL);
/* env is not allowed to contain '=' */
if (strchr(env, '=') != NULL)
return (EINVAL);
/*
* Find out the requested entry and remove
* it from the list.
*/
envname_len = strlen(env);
for (entry = envlist->el_entries.lh_first; entry != NULL;
entry = entry->ev_link.le_next) {
if (strncmp(entry->ev_var, env, envname_len) == 0)
break;
}
if (entry != NULL) {
LIST_REMOVE(entry, ev_link);
free((char *)entry->ev_var);
free(entry);
envlist->el_count--;
}
return (0);
}
| 5,479 |
qemu | 68d553587c0aa271c3eb2902921b503740d775b6 | 0 | static int ehci_state_fetchitd(EHCIState *ehci, int async)
{
uint32_t entry;
EHCIitd itd;
assert(!async);
entry = ehci_get_fetch_addr(ehci, async);
get_dwords(NLPTR_GET(entry),(uint32_t *) &itd,
sizeof(EHCIitd) >> 2);
ehci_trace_itd(ehci, entry, &itd);
if (ehci_process_itd(ehci, &itd) != 0) {
return -1;
}
put_dwords(NLPTR_GET(entry), (uint32_t *) &itd,
sizeof(EHCIitd) >> 2);
ehci_set_fetch_addr(ehci, async, itd.next);
ehci_set_state(ehci, async, EST_FETCHENTRY);
return 1;
}
| 5,480 |
FFmpeg | e5540b3fd30367ce3cc33b2f34a04b660dbc4b38 | 0 | static int decode_b_mbs(VC9Context *v)
{
int x, y, current_mb = 0 , last_mb = v->height_mb*v->width_mb,
i /* MB / B postion information */;
int direct_b_bit = 0, skip_mb_bit = 0;
int ac_pred;
int b_mv1 = 0, b_mv2 = 0, b_mv_type = 0;
int mquant, mqdiff; /* MB quant stuff */
int tt_block; /* Block transform type */
for (y=0; y<v->height_mb; y++)
{
for (x=0; x<v->width_mb; x++)
{
if (v->direct_mb_plane[current_mb])
direct_b_bit = get_bits(&v->gb, 1);
if (1 /* Skip mode is raw */)
{
/* FIXME getting tired commenting */
#if 0
skip_mb_bit = get_bits(&v->gb, n); //vlc
#endif
}
if (!direct_b_bit)
{
if (skip_mb_bit)
{
/* FIXME getting tired commenting */
#if 0
b_mv_type = get_bits(&v->gb, n); //vlc
#endif
}
else
{
/* FIXME getting tired commenting */
#if 0
b_mv1 = get_bits(&v->gb, n); //VLC
#endif
if (1 /* b_mv1 isn't intra */)
{
/* FIXME: actually read it */
b_mv_type = 0; //vlc
}
}
}
if (!skip_mb_bit)
{
if (b_mv1 != last_mb)
{
GET_MQUANT();
if (1 /* intra mb */)
ac_pred = get_bits(&v->gb, 1);
}
else
{
if (1 /* forward_mb is interpolate */)
{
/* FIXME: actually read it */
b_mv2 = 0; //vlc
}
if (1 /* b_mv2 isn't the last */)
{
if (1 /* intra_mb */)
ac_pred = get_bits(&v->gb, 1);
GET_MQUANT();
}
}
}
//End1
/* FIXME getting tired, commenting */
#if 0
if (v->ttmbf)
v->ttmb = get_bits(&v->gb, n); //vlc
#endif
}
//End2
for (i=0; i<6; i++)
{
/* FIXME: process the block */
}
current_mb++;
}
return 0;
}
| 5,481 |
qemu | 6cd0beda2c3c21fd7575e944764f392be7ef50c1 | 0 | static int ram_save_iterate(QEMUFile *f, void *opaque)
{
int ret;
int i;
int64_t t0;
int total_sent = 0;
qemu_mutex_lock_ramlist();
if (ram_list.version != last_version) {
reset_ram_globals();
}
ram_control_before_iterate(f, RAM_CONTROL_ROUND);
t0 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
i = 0;
while ((ret = qemu_file_rate_limit(f)) == 0) {
int bytes_sent;
bytes_sent = ram_save_block(f, false);
/* no more blocks to sent */
if (bytes_sent == 0) {
break;
}
total_sent += bytes_sent;
acct_info.iterations++;
check_guest_throttling();
/* we want to check in the 1st loop, just in case it was the 1st time
and we had to sync the dirty bitmap.
qemu_get_clock_ns() is a bit expensive, so we only check each some
iterations
*/
if ((i & 63) == 0) {
uint64_t t1 = (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - t0) / 1000000;
if (t1 > MAX_WAIT) {
DPRINTF("big wait: %" PRIu64 " milliseconds, %d iterations\n",
t1, i);
break;
}
}
i++;
}
qemu_mutex_unlock_ramlist();
/*
* Must occur before EOS (or any QEMUFile operation)
* because of RDMA protocol.
*/
ram_control_after_iterate(f, RAM_CONTROL_ROUND);
if (ret < 0) {
bytes_transferred += total_sent;
return ret;
}
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
total_sent += 8;
bytes_transferred += total_sent;
return total_sent;
}
| 5,483 |
qemu | 8d31d6b65a7448582c7bd320fd1b8cfc6cca2720 | 0 | static void *file_ram_alloc(RAMBlock *block,
ram_addr_t memory,
const char *path,
Error **errp)
{
char *filename;
char *sanitized_name;
char *c;
void *area;
int fd;
uint64_t hpagesize;
Error *local_err = NULL;
hpagesize = gethugepagesize(path, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto error;
}
block->mr->align = hpagesize;
if (memory < hpagesize) {
error_setg(errp, "memory size 0x" RAM_ADDR_FMT " must be equal to "
"or larger than huge page size 0x%" PRIx64,
memory, hpagesize);
goto error;
}
if (kvm_enabled() && !kvm_has_sync_mmu()) {
error_setg(errp,
"host lacks kvm mmu notifiers, -mem-path unsupported");
goto error;
}
/* Make name safe to use with mkstemp by replacing '/' with '_'. */
sanitized_name = g_strdup(memory_region_name(block->mr));
for (c = sanitized_name; *c != '\0'; c++) {
if (*c == '/')
*c = '_';
}
filename = g_strdup_printf("%s/qemu_back_mem.%s.XXXXXX", path,
sanitized_name);
g_free(sanitized_name);
fd = mkstemp(filename);
if (fd < 0) {
error_setg_errno(errp, errno,
"unable to create backing store for hugepages");
g_free(filename);
goto error;
}
unlink(filename);
g_free(filename);
memory = ROUND_UP(memory, hpagesize);
/*
* ftruncate is not supported by hugetlbfs in older
* hosts, so don't bother bailing out on errors.
* If anything goes wrong with it under other filesystems,
* mmap will fail.
*/
if (ftruncate(fd, memory)) {
perror("ftruncate");
}
area = qemu_ram_mmap(fd, memory, hpagesize, block->flags & RAM_SHARED);
if (area == MAP_FAILED) {
error_setg_errno(errp, errno,
"unable to map backing store for hugepages");
close(fd);
goto error;
}
if (mem_prealloc) {
os_mem_prealloc(fd, area, memory);
}
block->fd = fd;
return area;
error:
return NULL;
}
| 5,485 |
qemu | 9ef91a677110ec200d7b2904fc4bcae5a77329ad | 0 | static BlockDriverAIOCB *raw_aio_readv(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
RawAIOCB *acb;
acb = raw_aio_setup(bs, sector_num, qiov, nb_sectors, cb, opaque);
if (!acb)
return NULL;
if (qemu_paio_read(&acb->aiocb) < 0) {
raw_aio_remove(acb);
return NULL;
}
return &acb->common;
}
| 5,486 |
FFmpeg | 9e88cc94e58e9e4d1293f9f56c973510e30495fd | 1 | void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
const uint8_t *flags)
{
int i, shift, sp1, sp2, sp3, sp4;
const int32_t *src;
int32_t *dst;
int tmp[64];
int t0, t1, t2, t3, t4, t5, t6, t7, t8;
/* apply the InvHaar8 to all columns */
#define COMPENSATE(x) (x)
src = in;
dst = tmp;
for (i = 0; i < 8; i++) {
if (flags[i]) {
/* pre-scaling */
shift = !(i & 4);
sp1 = src[ 0] << shift;
sp2 = src[ 8] << shift;
sp3 = src[16] << shift;
sp4 = src[24] << shift;
INV_HAAR8( sp1, sp2, sp3, sp4,
src[32], src[40], src[48], src[56],
dst[ 0], dst[ 8], dst[16], dst[24],
dst[32], dst[40], dst[48], dst[56],
t0, t1, t2, t3, t4, t5, t6, t7, t8);
} else
dst[ 0] = dst[ 8] = dst[16] = dst[24] =
dst[32] = dst[40] = dst[48] = dst[56] = 0;
src++;
dst++;
}
#undef COMPENSATE
/* apply the InvHaar8 to all rows */
#define COMPENSATE(x) (x)
src = tmp;
for (i = 0; i < 8; i++) {
if ( !src[0] && !src[1] && !src[2] && !src[3]
&& !src[4] && !src[5] && !src[6] && !src[7]) {
memset(out, 0, 8 * sizeof(out[0]));
} else {
INV_HAAR8(src[0], src[1], src[2], src[3],
src[4], src[5], src[6], src[7],
out[0], out[1], out[2], out[3],
out[4], out[5], out[6], out[7],
t0, t1, t2, t3, t4, t5, t6, t7, t8);
}
src += 8;
out += pitch;
}
#undef COMPENSATE
}
| 5,488 |
FFmpeg | ec482e738ddcb90b156cf306eb1911f7038efa19 | 0 | av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt,
int bps)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
if (EXTERNAL_SSE4(cpu_flags)) {
if (bps > 16 && CONFIG_FLAC_DECODER)
c->lpc = ff_flac_lpc_32_sse4;
}
if (EXTERNAL_XOP(cpu_flags)) {
if (bps > 16)
c->lpc = ff_flac_lpc_32_xop;
}
#endif
}
| 5,489 |
FFmpeg | f92f4935acd7d974adfd1deebdf1bb06cbe107ca | 1 | static void up_heap(uint32_t val, uint32_t *heap, uint32_t *weights)
{
uint32_t initial_val = heap[val];
while (weights[initial_val] < weights[heap[val >> 1]]) {
heap[val] = heap[val >> 1];
val >>= 1;
}
heap[val] = initial_val;
}
| 5,491 |
qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | 1 | static int vmstate_size(void *opaque, VMStateField *field)
{
int size = field->size;
if (field->flags & VMS_VBUFFER) {
size = *(int32_t *)(opaque+field->size_offset);
if (field->flags & VMS_MULTIPLY) {
size *= field->size;
}
}
return size;
}
| 5,492 |
FFmpeg | f78cd0c243b9149c7f604ecf1006d78e344aa6ca | 1 | void ff_simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
/* IDCT8 on each line */
for(i=0; i<4; i++) {
idctRowCondDC_8(block + i*8);
}
/* IDCT4 and store */
for(i=0;i<8;i++) {
idct4col_add(dest + i, line_size, block + i);
}
}
| 5,493 |
qemu | f7c31d6381f2cbac03e82fc23133f6863606edd8 | 1 | int net_handle_fd_param(Monitor *mon, const char *param)
{
if (!qemu_isdigit(param[0])) {
int fd;
fd = monitor_get_fd(mon, param);
if (fd == -1) {
error_report("No file descriptor named %s found", param);
return -1;
}
return fd;
} else {
return strtol(param, NULL, 0);
}
}
| 5,494 |
FFmpeg | f9d7e9feec2a0fd7f7930d01876a70a9b8a4a3b9 | 1 | static int tee_write_trailer(AVFormatContext *avf)
{
TeeContext *tee = avf->priv_data;
AVFormatContext *avf2;
int ret_all = 0, ret;
unsigned i;
for (i = 0; i < tee->nb_slaves; i++) {
avf2 = tee->slaves[i].avf;
if ((ret = av_write_trailer(avf2)) < 0)
if (!ret_all)
ret_all = ret;
if (!(avf2->oformat->flags & AVFMT_NOFILE))
ff_format_io_close(avf2, &avf2->pb);
}
close_slaves(avf);
return ret_all;
}
| 5,495 |
FFmpeg | 2cface71ca58b1ab811efae7d22f3264f362f672 | 1 | static int write_trailer(AVFormatContext *s){
NUTContext *nut= s->priv_data;
AVIOContext *bc= s->pb;
while(nut->header_count<3)
write_headers(s, bc);
avio_flush(bc);
ff_nut_free_sp(nut);
av_freep(&nut->stream);
av_freep(&nut->time_base);
return 0;
} | 5,496 |
qemu | 4871b51b9241b10f4fd8e04bbb21577886795e25 | 1 | static void vmgenid_set_guid_test(void)
{
QemuUUID expected, measured;
gchar *cmd;
g_assert(qemu_uuid_parse(VGID_GUID, &expected) == 0);
cmd = g_strdup_printf("-machine accel=tcg -device vmgenid,id=testvgid,"
"guid=%s", VGID_GUID);
qtest_start(cmd);
/* Read the GUID from accessing guest memory */
read_guid_from_memory(&measured);
g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) == 0);
qtest_quit(global_qtest);
g_free(cmd);
}
| 5,497 |
FFmpeg | 1851e1d05d06f6ef3436c667e4354da0f407b226 | 1 | static int rtp_write(URLContext *h, const uint8_t *buf, int size)
{
RTPContext *s = h->priv_data;
int ret;
URLContext *hd;
if (RTP_PT_IS_RTCP(buf[1])) {
/* RTCP payload type */
hd = s->rtcp_hd;
} else {
/* RTP payload type */
hd = s->rtp_hd;
}
ret = ffurl_write(hd, buf, size);
return ret;
} | 5,498 |
qemu | f4b147f6701f6f5127b70b82f41757a52dfa4aae | 1 | static unsigned int dec_addi_acr(DisasContext *dc)
{
TCGv t0;
DIS(fprintf (logfile, "addi.%c $r%u, $r%u, $acr\n",
memsize_char(memsize_zz(dc)), dc->op2, dc->op1));
cris_cc_mask(dc, 0);
t0 = tcg_temp_new(TCG_TYPE_TL);
tcg_gen_shl_tl(t0, cpu_R[dc->op2], tcg_const_tl(dc->zzsize));
tcg_gen_add_tl(cpu_R[R_ACR], cpu_R[dc->op1], t0);
return 2;
}
| 5,499 |
FFmpeg | ab2bfb85d49b2f8aa505816f93e75fd18ad0a361 | 1 | int ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
AVFilterPad **pads, AVFilterLink ***links,
AVFilterPad *newpad)
{
AVFilterLink **newlinks;
AVFilterPad *newpads;
unsigned i;
idx = FFMIN(idx, *count);
newpads = av_realloc_array(*pads, *count + 1, sizeof(AVFilterPad));
newlinks = av_realloc_array(*links, *count + 1, sizeof(AVFilterLink*));
if (newpads)
*pads = newpads;
if (newlinks)
*links = newlinks;
if (!newpads || !newlinks)
return AVERROR(ENOMEM);
memmove(*pads + idx + 1, *pads + idx, sizeof(AVFilterPad) * (*count - idx));
memmove(*links + idx + 1, *links + idx, sizeof(AVFilterLink*) * (*count - idx));
memcpy(*pads + idx, newpad, sizeof(AVFilterPad));
(*links)[idx] = NULL;
(*count)++;
for (i = idx + 1; i < *count; i++)
if (*links[i])
(*(unsigned *)((uint8_t *) *links[i] + padidx_off))++;
return 0;
}
| 5,501 |
qemu | 75cb298d905030fca897ea1d80e409c7f7e3e5ea | 1 | sbappend(struct socket *so, struct mbuf *m)
{
int ret = 0;
DEBUG_CALL("sbappend");
DEBUG_ARG("so = %p", so);
DEBUG_ARG("m = %p", m);
DEBUG_ARG("m->m_len = %d", m->m_len);
/* Shouldn't happen, but... e.g. foreign host closes connection */
if (m->m_len <= 0) {
m_free(m);
return;
}
/*
* If there is urgent data, call sosendoob
* if not all was sent, sowrite will take care of the rest
* (The rest of this function is just an optimisation)
*/
if (so->so_urgc) {
sbappendsb(&so->so_rcv, m);
m_free(m);
sosendoob(so);
return;
}
/*
* We only write if there's nothing in the buffer,
* ottherwise it'll arrive out of order, and hence corrupt
*/
if (!so->so_rcv.sb_cc)
ret = slirp_send(so, m->m_data, m->m_len, 0);
if (ret <= 0) {
/*
* Nothing was written
* It's possible that the socket has closed, but
* we don't need to check because if it has closed,
* it will be detected in the normal way by soread()
*/
sbappendsb(&so->so_rcv, m);
} else if (ret != m->m_len) {
/*
* Something was written, but not everything..
* sbappendsb the rest
*/
m->m_len -= ret;
m->m_data += ret;
sbappendsb(&so->so_rcv, m);
} /* else */
/* Whatever happened, we free the mbuf */
m_free(m);
}
| 5,502 |
FFmpeg | f77bfa837636a99a4034d31916a76f7d1688cf5a | 1 | static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)
{
XanContext *s = avctx->priv_data;
uint8_t *U, *V;
int val, uval, vval;
int i, j;
const uint8_t *src, *src_end;
const uint8_t *table;
int mode, offset, dec_size;
if (!chroma_off)
return 0;
if (chroma_off + 4 >= bytestream2_get_bytes_left(&s->gb)) {
av_log(avctx, AV_LOG_ERROR, "Invalid chroma block position\n");
return -1;
}
bytestream2_seek(&s->gb, chroma_off + 4, SEEK_SET);
mode = bytestream2_get_le16(&s->gb);
table = s->gb.buffer;
offset = bytestream2_get_le16(&s->gb) * 2;
if (offset >= bytestream2_get_bytes_left(&s->gb)) {
av_log(avctx, AV_LOG_ERROR, "Invalid chroma block offset\n");
return -1;
}
bytestream2_skip(&s->gb, offset);
memset(s->scratch_buffer, 0, s->buffer_size);
dec_size = xan_unpack(s, s->scratch_buffer, s->buffer_size);
if (dec_size < 0) {
av_log(avctx, AV_LOG_ERROR, "Chroma unpacking failed\n");
return -1;
}
U = s->pic.data[1];
V = s->pic.data[2];
src = s->scratch_buffer;
src_end = src + dec_size;
if (mode) {
for (j = 0; j < avctx->height >> 1; j++) {
for (i = 0; i < avctx->width >> 1; i++) {
val = *src++;
if (val) {
val = AV_RL16(table + (val << 1));
uval = (val >> 3) & 0xF8;
vval = (val >> 8) & 0xF8;
U[i] = uval | (uval >> 5);
V[i] = vval | (vval >> 5);
}
if (src == src_end)
return 0;
}
U += s->pic.linesize[1];
V += s->pic.linesize[2];
}
} else {
uint8_t *U2 = U + s->pic.linesize[1];
uint8_t *V2 = V + s->pic.linesize[2];
for (j = 0; j < avctx->height >> 2; j++) {
for (i = 0; i < avctx->width >> 1; i += 2) {
val = *src++;
if (val) {
val = AV_RL16(table + (val << 1));
uval = (val >> 3) & 0xF8;
vval = (val >> 8) & 0xF8;
U[i] = U[i+1] = U2[i] = U2[i+1] = uval | (uval >> 5);
V[i] = V[i+1] = V2[i] = V2[i+1] = vval | (vval >> 5);
}
}
U += s->pic.linesize[1] * 2;
V += s->pic.linesize[2] * 2;
U2 += s->pic.linesize[1] * 2;
V2 += s->pic.linesize[2] * 2;
}
}
return 0;
}
| 5,504 |
FFmpeg | ac4b32df71bd932838043a4838b86d11e169707f | 1 | void filter_mb(VP8Context *s, uint8_t *dst[3], VP8FilterStrength *f,
int mb_x, int mb_y)
{
int mbedge_lim, bedge_lim, hev_thresh;
int filter_level = f->filter_level;
int inner_limit = f->inner_limit;
int inner_filter = f->inner_filter;
int linesize = s->linesize;
int uvlinesize = s->uvlinesize;
static const uint8_t hev_thresh_lut[2][64] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2 }
};
if (!filter_level)
return;
bedge_lim = 2 * filter_level + inner_limit;
mbedge_lim = bedge_lim + 4;
hev_thresh = hev_thresh_lut[s->keyframe][filter_level];
if (mb_x) {
s->vp8dsp.vp8_h_loop_filter16y(dst[0], linesize,
mbedge_lim, inner_limit, hev_thresh);
s->vp8dsp.vp8_h_loop_filter8uv(dst[1], dst[2], uvlinesize,
mbedge_lim, inner_limit, hev_thresh);
}
if (inner_filter) {
s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 4, linesize, bedge_lim,
inner_limit, hev_thresh);
s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 8, linesize, bedge_lim,
inner_limit, hev_thresh);
s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 12, linesize, bedge_lim,
inner_limit, hev_thresh);
s->vp8dsp.vp8_h_loop_filter8uv_inner(dst[1] + 4, dst[2] + 4,
uvlinesize, bedge_lim,
inner_limit, hev_thresh);
}
if (mb_y) {
s->vp8dsp.vp8_v_loop_filter16y(dst[0], linesize,
mbedge_lim, inner_limit, hev_thresh);
s->vp8dsp.vp8_v_loop_filter8uv(dst[1], dst[2], uvlinesize,
mbedge_lim, inner_limit, hev_thresh);
}
if (inner_filter) {
s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0] + 4 * linesize,
linesize, bedge_lim,
inner_limit, hev_thresh);
s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0] + 8 * linesize,
linesize, bedge_lim,
inner_limit, hev_thresh);
s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0] + 12 * linesize,
linesize, bedge_lim,
inner_limit, hev_thresh);
s->vp8dsp.vp8_v_loop_filter8uv_inner(dst[1] + 4 * uvlinesize,
dst[2] + 4 * uvlinesize,
uvlinesize, bedge_lim,
inner_limit, hev_thresh);
}
}
| 5,505 |
qemu | 890241ab6942a0186eaf485dabf266a5a7aac428 | 1 | static void migrate_check_parameter(QTestState *who, const char *parameter,
const char *value)
{
QDict *rsp, *rsp_return;
const char *result;
rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }");
rsp_return = qdict_get_qdict(rsp, "return");
result = g_strdup_printf("%" PRId64,
qdict_get_try_int(rsp_return, parameter, -1));
g_assert_cmpstr(result, ==, value);
QDECREF(rsp);
}
| 5,506 |
FFmpeg | 4fecc3cf0998927456a9f8d8334587dd64154ec5 | 1 | int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size)
{
AVCodecContext *avctx = h->s.avctx;
if (!buf || size <= 0)
return -1;
if (buf[0] == 1) {
int i, cnt, nalsize;
const unsigned char *p = buf;
h->is_avc = 1;
if (size < 7) {
av_log(avctx, AV_LOG_ERROR, "avcC too short\n");
return -1;
}
/* sps and pps in the avcC always have length coded with 2 bytes,
* so put a fake nal_length_size = 2 while parsing them */
h->nal_length_size = 2;
// Decode sps from avcC
cnt = *(p + 5) & 0x1f; // Number of sps
p += 6;
for (i = 0; i < cnt; i++) {
nalsize = AV_RB16(p) + 2;
if(nalsize > size - (p-buf))
return -1;
if (decode_nal_units(h, p, nalsize) < 0) {
av_log(avctx, AV_LOG_ERROR,
"Decoding sps %d from avcC failed\n", i);
return -1;
}
p += nalsize;
}
// Decode pps from avcC
cnt = *(p++); // Number of pps
for (i = 0; i < cnt; i++) {
nalsize = AV_RB16(p) + 2;
if(nalsize > size - (p-buf))
return -1;
if (decode_nal_units(h, p, nalsize) < 0) {
av_log(avctx, AV_LOG_ERROR,
"Decoding pps %d from avcC failed\n", i);
return -1;
}
p += nalsize;
}
// Now store right nal length size, that will be used to parse all other nals
h->nal_length_size = (buf[4] & 0x03) + 1;
} else {
h->is_avc = 0;
if (decode_nal_units(h, buf, size) < 0)
return -1;
}
return size;
}
| 5,507 |
qemu | c5a49c63fa26e8825ad101dfe86339ae4c216539 | 1 | static void spr_write_hdecr(DisasContext *ctx, int sprn, int gprn)
{
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_store_hdecr(cpu_env, cpu_gpr[gprn]);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_stop_exception(ctx);
}
}
| 5,511 |
qemu | 908c7b9f788b6faed2fbfdf19920770614f8e853 | 1 | static int ioreq_parse(struct ioreq *ioreq)
{
struct XenBlkDev *blkdev = ioreq->blkdev;
uintptr_t mem;
size_t len;
int i;
xen_be_printf(&blkdev->xendev, 3,
"op %d, nr %d, handle %d, id %" PRId64 ", sector %" PRId64 "\n",
ioreq->req.operation, ioreq->req.nr_segments,
ioreq->req.handle, ioreq->req.id, ioreq->req.sector_number);
switch (ioreq->req.operation) {
case BLKIF_OP_READ:
ioreq->prot = PROT_WRITE; /* to memory */
if (ioreq->req.operation != BLKIF_OP_READ && blkdev->mode[0] != 'w') {
xen_be_printf(&blkdev->xendev, 0, "error: write req for ro device\n");
goto err;
}
break;
case BLKIF_OP_WRITE_BARRIER:
if (!syncwrite)
ioreq->presync = ioreq->postsync = 1;
/* fall through */
case BLKIF_OP_WRITE:
ioreq->prot = PROT_READ; /* from memory */
if (syncwrite)
ioreq->postsync = 1;
break;
default:
xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
ioreq->req.operation);
goto err;
};
ioreq->start = ioreq->req.sector_number * blkdev->file_blk;
for (i = 0; i < ioreq->req.nr_segments; i++) {
if (i == BLKIF_MAX_SEGMENTS_PER_REQUEST) {
xen_be_printf(&blkdev->xendev, 0, "error: nr_segments too big\n");
goto err;
}
if (ioreq->req.seg[i].first_sect > ioreq->req.seg[i].last_sect) {
xen_be_printf(&blkdev->xendev, 0, "error: first > last sector\n");
goto err;
}
if (ioreq->req.seg[i].last_sect * BLOCK_SIZE >= XC_PAGE_SIZE) {
xen_be_printf(&blkdev->xendev, 0, "error: page crossing\n");
goto err;
}
ioreq->domids[i] = blkdev->xendev.dom;
ioreq->refs[i] = ioreq->req.seg[i].gref;
mem = ioreq->req.seg[i].first_sect * blkdev->file_blk;
len = (ioreq->req.seg[i].last_sect - ioreq->req.seg[i].first_sect + 1) * blkdev->file_blk;
qemu_iovec_add(&ioreq->v, (void*)mem, len);
}
if (ioreq->start + ioreq->v.size > blkdev->file_size) {
xen_be_printf(&blkdev->xendev, 0, "error: access beyond end of file\n");
goto err;
}
return 0;
err:
ioreq->status = BLKIF_RSP_ERROR;
return -1;
}
| 5,512 |
qemu | 47d4be12c3997343e436c6cca89aefbbbeb70863 | 1 | static void test_qemu_strtoul_full_empty(void)
{
const char *str = "";
unsigned long res = 999;
int err;
err = qemu_strtoul(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
}
| 5,513 |
qemu | e4f4fb1eca795e36f363b4647724221e774523c1 | 1 | static void xen_sysdev_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
k->init = xen_sysdev_init;
dc->props = xen_sysdev_properties;
dc->bus_type = TYPE_XENSYSBUS;
} | 5,514 |
FFmpeg | e481ba2ed79421d82ed631d187c05c03260c6561 | 1 | static int vqf_read_header(AVFormatContext *s)
{
VqfContext *c = s->priv_data;
AVStream *st = avformat_new_stream(s, NULL);
int chunk_tag;
int rate_flag = -1;
int header_size;
int read_bitrate = 0;
int size;
uint8_t comm_chunk[12];
if (!st)
return AVERROR(ENOMEM);
avio_skip(s->pb, 12);
header_size = avio_rb32(s->pb);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_TWINVQ;
st->start_time = 0;
do {
int len;
chunk_tag = avio_rl32(s->pb);
if (chunk_tag == MKTAG('D','A','T','A'))
break;
len = avio_rb32(s->pb);
if ((unsigned) len > INT_MAX/2) {
av_log(s, AV_LOG_ERROR, "Malformed header\n");
header_size -= 8;
switch(chunk_tag){
case MKTAG('C','O','M','M'):
avio_read(s->pb, comm_chunk, 12);
st->codec->channels = AV_RB32(comm_chunk ) + 1;
read_bitrate = AV_RB32(comm_chunk + 4);
rate_flag = AV_RB32(comm_chunk + 8);
avio_skip(s->pb, len-12);
st->codec->bit_rate = read_bitrate*1000;
break;
case MKTAG('D','S','I','Z'): // size of compressed data
{
char buf[8] = {0};
int size = avio_rb32(s->pb);
snprintf(buf, sizeof(buf), "%d", size);
av_dict_set(&s->metadata, "size", buf, 0);
break;
case MKTAG('Y','E','A','R'): // recording date
case MKTAG('E','N','C','D'): // compression date
case MKTAG('E','X','T','R'): // reserved
case MKTAG('_','Y','M','H'): // reserved
case MKTAG('_','N','T','T'): // reserved
case MKTAG('_','I','D','3'): // reserved for ID3 tags
avio_skip(s->pb, FFMIN(len, header_size));
break;
default:
add_metadata(s, chunk_tag, len, header_size);
break;
header_size -= len;
} while (header_size >= 0);
switch (rate_flag) {
case -1:
av_log(s, AV_LOG_ERROR, "COMM tag not found!\n");
case 44:
st->codec->sample_rate = 44100;
break;
case 22:
st->codec->sample_rate = 22050;
break;
case 11:
st->codec->sample_rate = 11025;
break;
default:
st->codec->sample_rate = rate_flag*1000;
break;
switch (((st->codec->sample_rate/1000) << 8) +
read_bitrate/st->codec->channels) {
case (11<<8) + 8 :
case (8 <<8) + 8 :
case (11<<8) + 10:
case (22<<8) + 32:
size = 512;
break;
case (16<<8) + 16:
case (22<<8) + 20:
case (22<<8) + 24:
size = 1024;
break;
case (44<<8) + 40:
case (44<<8) + 48:
size = 2048;
break;
default:
av_log(s, AV_LOG_ERROR, "Mode not suported: %d Hz, %d kb/s.\n",
st->codec->sample_rate, st->codec->bit_rate);
c->frame_bit_len = st->codec->bit_rate*size/st->codec->sample_rate;
avpriv_set_pts_info(st, 64, size, st->codec->sample_rate);
/* put first 12 bytes of COMM chunk in extradata */
if (!(st->codec->extradata = av_malloc(12 + FF_INPUT_BUFFER_PADDING_SIZE)))
return AVERROR(ENOMEM);
st->codec->extradata_size = 12;
memcpy(st->codec->extradata, comm_chunk, 12);
ff_metadata_conv_ctx(s, NULL, vqf_metadata_conv);
return 0;
| 5,515 |
qemu | 3e80bf9351f8fec9085c46df6da075efd5e71003 | 1 | int qemu_sendv(int sockfd, struct iovec *iov, int len, int iov_offset)
{
return do_sendv_recvv(sockfd, iov, len, iov_offset, 1);
}
| 5,516 |
qemu | 95a5befc2f8b359e72926f89cd661d063c2cf06c | 1 | static int gdb_handle_vcont(GDBState *s, const char *p)
{
int res, idx, signal = 0;
char cur_action;
char *newstates;
unsigned long tmp;
CPUState *cpu;
#ifdef CONFIG_USER_ONLY
int max_cpus = 1; /* global variable max_cpus exists only in system mode */
CPU_FOREACH(cpu) {
max_cpus = max_cpus <= cpu->cpu_index ? cpu->cpu_index + 1 : max_cpus;
}
#endif
/* uninitialised CPUs stay 0 */
newstates = g_new0(char, max_cpus);
/* mark valid CPUs with 1 */
CPU_FOREACH(cpu) {
newstates[cpu->cpu_index] = 1;
}
/*
* res keeps track of what error we are returning, with -ENOTSUP meaning
* that the command is unknown or unsupported, thus returning an empty
* packet, while -EINVAL and -ERANGE cause an E22 packet, due to invalid,
* or incorrect parameters passed.
*/
res = 0;
while (*p) {
if (*p++ != ';') {
res = -ENOTSUP;
goto out;
}
cur_action = *p++;
if (cur_action == 'C' || cur_action == 'S') {
cur_action = tolower(cur_action);
res = qemu_strtoul(p + 1, &p, 16, &tmp);
if (res) {
goto out;
}
signal = gdb_signal_to_target(tmp);
} else if (cur_action != 'c' && cur_action != 's') {
/* unknown/invalid/unsupported command */
res = -ENOTSUP;
goto out;
}
/* thread specification. special values: (none), -1 = all; 0 = any */
if ((p[0] == ':' && p[1] == '-' && p[2] == '1') || (p[0] != ':')) {
if (*p == ':') {
p += 3;
}
for (idx = 0; idx < max_cpus; idx++) {
if (newstates[idx] == 1) {
newstates[idx] = cur_action;
}
}
} else if (*p == ':') {
p++;
res = qemu_strtoul(p, &p, 16, &tmp);
if (res) {
goto out;
}
/* 0 means any thread, so we pick the first valid CPU */
cpu = tmp ? find_cpu(tmp) : first_cpu;
/* invalid CPU/thread specified */
if (!cpu) {
res = -EINVAL;
goto out;
}
/* only use if no previous match occourred */
if (newstates[cpu->cpu_index] == 1) {
newstates[cpu->cpu_index] = cur_action;
}
}
}
s->signal = signal;
gdb_continue_partial(s, newstates);
out:
g_free(newstates);
return res;
}
| 5,518 |
FFmpeg | 33580a8625c77591919b6155a48da04dccc8d398 | 1 | static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
{
AVFormatContext *s = of->ctx;
AVStream *st = ost->st;
int ret;
if (!of->header_written) {
AVPacket tmp_pkt;
/* the muxer is not initialized yet, buffer the packet */
if (!av_fifo_space(ost->muxing_queue)) {
int new_size = FFMIN(2 * av_fifo_size(ost->muxing_queue),
ost->max_muxing_queue_size);
if (new_size <= av_fifo_size(ost->muxing_queue)) {
av_log(NULL, AV_LOG_ERROR,
"Too many packets buffered for output stream %d:%d.\n",
ost->file_index, ost->st->index);
exit_program(1);
}
ret = av_fifo_realloc2(ost->muxing_queue, new_size);
if (ret < 0)
exit_program(1);
}
av_packet_move_ref(&tmp_pkt, pkt);
av_fifo_generic_write(ost->muxing_queue, &tmp_pkt, sizeof(tmp_pkt), NULL);
return;
}
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method == VSYNC_DROP) ||
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
/*
* Audio encoders may split the packets -- #frames in != #packets out.
* But there is no reordering, so we can limit the number of output packets
* by simply dropping them here.
* Counting encoded video frames needs to be done separately because of
* reordering, see do_video_out()
*/
if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed)) {
if (ost->frame_number >= ost->max_frames) {
av_packet_unref(pkt);
return;
}
ost->frame_number++;
}
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
int i;
uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS,
NULL);
ost->quality = sd ? AV_RL32(sd) : -1;
ost->pict_type = sd ? sd[4] : AV_PICTURE_TYPE_NONE;
for (i = 0; i<FF_ARRAY_ELEMS(ost->error); i++) {
if (sd && i < sd[5])
ost->error[i] = AV_RL64(sd + 8 + 8*i);
else
ost->error[i] = -1;
}
if (ost->frame_rate.num && ost->is_cfr) {
if (pkt->duration > 0)
av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n");
pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate),
ost->st->time_base);
}
}
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
if (pkt->dts != AV_NOPTS_VALUE &&
pkt->pts != AV_NOPTS_VALUE &&
pkt->dts > pkt->pts) {
av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n",
pkt->dts, pkt->pts,
ost->file_index, ost->st->index);
pkt->pts =
pkt->dts = pkt->pts + pkt->dts + ost->last_mux_dts + 1
- FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1)
- FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1);
}
if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
pkt->dts != AV_NOPTS_VALUE &&
!(st->codecpar->codec_id == AV_CODEC_ID_VP9 && ost->stream_copy) &&
ost->last_mux_dts != AV_NOPTS_VALUE) {
int64_t max = ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT);
if (pkt->dts < max) {
int loglevel = max - pkt->dts > 2 || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG;
av_log(s, loglevel, "Non-monotonous DTS in output stream "
"%d:%d; previous: %"PRId64", current: %"PRId64"; ",
ost->file_index, ost->st->index, ost->last_mux_dts, pkt->dts);
if (exit_on_error) {
av_log(NULL, AV_LOG_FATAL, "aborting.\n");
exit_program(1);
}
av_log(s, loglevel, "changing to %"PRId64". This may result "
"in incorrect timestamps in the output file.\n",
max);
if (pkt->pts >= pkt->dts)
pkt->pts = FFMAX(pkt->pts, max);
pkt->dts = max;
}
}
}
ost->last_mux_dts = pkt->dts;
ost->data_size += pkt->size;
ost->packets_written++;
pkt->stream_index = ost->index;
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "muxer <- type:%s "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n",
av_get_media_type_string(ost->enc_ctx->codec_type),
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->st->time_base),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->st->time_base),
pkt->size
);
}
ret = av_interleaved_write_frame(s, pkt);
if (ret < 0) {
print_error("av_interleaved_write_frame()", ret);
main_return_code = 1;
close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED);
}
av_packet_unref(pkt);
}
| 5,519 |
qemu | e88774971c33671477c9eb4a4cf1e65a047c9838 | 1 | void bdrv_commit_all(void)
{
BlockDriverState *bs;
QTAILQ_FOREACH(bs, &bdrv_states, list) {
bdrv_commit(bs);
}
}
| 5,520 |
qemu | c804c2a71752dd1e150cde768d8c54b02fa8bad9 | 1 | static int event_qdev_exit(DeviceState *qdev)
{
SCLPEvent *event = DO_UPCAST(SCLPEvent, qdev, qdev);
SCLPEventClass *child = SCLP_EVENT_GET_CLASS(event);
if (child->exit) {
child->exit(event);
}
return 0;
}
| 5,522 |
FFmpeg | 2df0c32ea12ddfa72ba88309812bfb13b674130f | 0 | static av_cold int amr_wb_encode_init(AVCodecContext *avctx)
{
AMRWBContext *s = avctx->priv_data;
if (avctx->sample_rate != 16000) {
av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n");
return AVERROR(ENOSYS);
}
if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
return AVERROR(ENOSYS);
}
s->mode = get_wb_bitrate_mode(avctx->bit_rate, avctx);
s->last_bitrate = avctx->bit_rate;
avctx->frame_size = 320;
avctx->delay = 80;
s->state = E_IF_init();
return 0;
}
| 5,524 |
FFmpeg | 082cf97106e2e94a969877d4f8c05c1e526acf54 | 0 | static void filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
MpegEncContext * const s = &h->s;
int mb_y_firstrow = s->picture_structure == PICT_BOTTOM_FIELD;
int mb_xy, mb_type;
int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh;
mb_xy = h->mb_xy;
if(mb_x==0 || mb_y==mb_y_firstrow || !s->dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff ||
!(s->flags2 & CODEC_FLAG2_FAST) || //FIXME filter_mb_fast is broken, thus hasto be, but should not under CODEC_FLAG2_FAST
(h->deblocking_filter == 2 && (h->slice_table[mb_xy] != h->slice_table[h->top_mb_xy] ||
h->slice_table[mb_xy] != h->slice_table[mb_xy - 1]))) {
filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize);
return;
}
assert(!FRAME_MBAFF);
mb_type = s->current_picture.mb_type[mb_xy];
qp = s->current_picture.qscale_table[mb_xy];
qp0 = s->current_picture.qscale_table[mb_xy-1];
qp1 = s->current_picture.qscale_table[h->top_mb_xy];
qpc = get_chroma_qp( h, 0, qp );
qpc0 = get_chroma_qp( h, 0, qp0 );
qpc1 = get_chroma_qp( h, 0, qp1 );
qp0 = (qp + qp0 + 1) >> 1;
qp1 = (qp + qp1 + 1) >> 1;
qpc0 = (qpc + qpc0 + 1) >> 1;
qpc1 = (qpc + qpc1 + 1) >> 1;
qp_thresh = 15 - h->slice_alpha_c0_offset;
if(qp <= qp_thresh && qp0 <= qp_thresh && qp1 <= qp_thresh &&
qpc <= qp_thresh && qpc0 <= qp_thresh && qpc1 <= qp_thresh)
return;
if( IS_INTRA(mb_type) ) {
int16_t bS4[4] = {4,4,4,4};
int16_t bS3[4] = {3,3,3,3};
int16_t *bSH = FIELD_PICTURE ? bS3 : bS4;
if( IS_8x8DCT(mb_type) ) {
filter_mb_edgev( h, &img_y[4*0], linesize, bS4, qp0 );
filter_mb_edgev( h, &img_y[4*2], linesize, bS3, qp );
filter_mb_edgeh( h, &img_y[4*0*linesize], linesize, bSH, qp1 );
filter_mb_edgeh( h, &img_y[4*2*linesize], linesize, bS3, qp );
} else {
filter_mb_edgev( h, &img_y[4*0], linesize, bS4, qp0 );
filter_mb_edgev( h, &img_y[4*1], linesize, bS3, qp );
filter_mb_edgev( h, &img_y[4*2], linesize, bS3, qp );
filter_mb_edgev( h, &img_y[4*3], linesize, bS3, qp );
filter_mb_edgeh( h, &img_y[4*0*linesize], linesize, bSH, qp1 );
filter_mb_edgeh( h, &img_y[4*1*linesize], linesize, bS3, qp );
filter_mb_edgeh( h, &img_y[4*2*linesize], linesize, bS3, qp );
filter_mb_edgeh( h, &img_y[4*3*linesize], linesize, bS3, qp );
}
filter_mb_edgecv( h, &img_cb[2*0], uvlinesize, bS4, qpc0 );
filter_mb_edgecv( h, &img_cb[2*2], uvlinesize, bS3, qpc );
filter_mb_edgecv( h, &img_cr[2*0], uvlinesize, bS4, qpc0 );
filter_mb_edgecv( h, &img_cr[2*2], uvlinesize, bS3, qpc );
filter_mb_edgech( h, &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1 );
filter_mb_edgech( h, &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc );
filter_mb_edgech( h, &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1 );
filter_mb_edgech( h, &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc );
return;
} else {
DECLARE_ALIGNED_8(int16_t, bS[2][4][4]);
uint64_t (*bSv)[4] = (uint64_t(*)[4])bS;
int edges;
if( IS_8x8DCT(mb_type) && (h->cbp&7) == 7 ) {
edges = 4;
bSv[0][0] = bSv[0][2] = bSv[1][0] = bSv[1][2] = 0x0002000200020002ULL;
} else {
int mask_edge1 = (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) ? 3 :
(mb_type & MB_TYPE_16x8) ? 1 : 0;
int mask_edge0 = (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16))
&& (s->current_picture.mb_type[mb_xy-1] & (MB_TYPE_16x16 | MB_TYPE_8x16))
? 3 : 0;
int step = IS_8x8DCT(mb_type) ? 2 : 1;
edges = (mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4;
s->dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache,
(h->slice_type_nos == FF_B_TYPE), edges, step, mask_edge0, mask_edge1, FIELD_PICTURE);
}
if( IS_INTRA(s->current_picture.mb_type[mb_xy-1]) )
bSv[0][0] = 0x0004000400040004ULL;
if( IS_INTRA(s->current_picture.mb_type[h->top_mb_xy]) )
bSv[1][0] = FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL;
#define FILTER(hv,dir,edge)\
if(bSv[dir][edge]) {\
filter_mb_edge##hv( h, &img_y[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qp : qp##dir );\
if(!(edge&1)) {\
filter_mb_edgec##hv( h, &img_cb[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir );\
filter_mb_edgec##hv( h, &img_cr[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir );\
}\
}
if( edges == 1 ) {
FILTER(v,0,0);
FILTER(h,1,0);
} else if( IS_8x8DCT(mb_type) ) {
FILTER(v,0,0);
FILTER(v,0,2);
FILTER(h,1,0);
FILTER(h,1,2);
} else {
FILTER(v,0,0);
FILTER(v,0,1);
FILTER(v,0,2);
FILTER(v,0,3);
FILTER(h,1,0);
FILTER(h,1,1);
FILTER(h,1,2);
FILTER(h,1,3);
}
#undef FILTER
}
}
| 5,525 |
FFmpeg | 2ba6d7cb8278970bb9971448706c1e44ba043a81 | 1 | static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)
{
int i, err;
AVFormatContext *ic = avformat_alloc_context();
ic->interrupt_callback = int_cb;
err = avformat_open_input(&ic, filename, NULL, NULL);
if (err < 0)
return err;
/* copy stream format */
for(i=0;i<ic->nb_streams;i++) {
AVStream *st;
OutputStream *ost;
AVCodec *codec;
const char *enc_config;
codec = avcodec_find_encoder(ic->streams[i]->codecpar->codec_id);
if (!codec) {
av_log(s, AV_LOG_ERROR, "no encoder found for codec id %i\n", ic->streams[i]->codecpar->codec_id);
return AVERROR(EINVAL);
}
if (codec->type == AVMEDIA_TYPE_AUDIO)
opt_audio_codec(o, "c:a", codec->name);
else if (codec->type == AVMEDIA_TYPE_VIDEO)
opt_video_codec(o, "c:v", codec->name);
ost = new_output_stream(o, s, codec->type, -1);
st = ost->st;
avcodec_get_context_defaults3(st->codec, codec);
enc_config = av_stream_get_recommended_encoder_configuration(ic->streams[i]);
if (enc_config) {
AVDictionary *opts = NULL;
av_dict_parse_string(&opts, enc_config, "=", ",", 0);
av_opt_set_dict2(st->codec, &opts, AV_OPT_SEARCH_CHILDREN);
av_dict_free(&opts);
}
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)
choose_sample_fmt(st, codec);
else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy)
choose_pixel_fmt(st, st->codec, codec, st->codecpar->format);
avcodec_copy_context(ost->enc_ctx, st->codec);
if (enc_config)
av_dict_parse_string(&ost->encoder_opts, enc_config, "=", ",", 0);
}
avformat_close_input(&ic);
return err;
} | 5,527 |
qemu | 30fb2ca603e8b8d0f02630ef18bc0d0637a88ffa | 1 | VirtIODevice *virtio_balloon_init(DeviceState *dev)
{
VirtIOBalloon *s;
s = (VirtIOBalloon *)virtio_common_init("virtio-balloon",
VIRTIO_ID_BALLOON,
8, sizeof(VirtIOBalloon));
s->vdev.get_config = virtio_balloon_get_config;
s->vdev.set_config = virtio_balloon_set_config;
s->vdev.get_features = virtio_balloon_get_features;
s->ivq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
s->dvq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
s->svq = virtio_add_queue(&s->vdev, 128, virtio_balloon_receive_stats);
reset_stats(s);
qemu_add_balloon_handler(virtio_balloon_to_target, s);
register_savevm(dev, "virtio-balloon", -1, 1,
virtio_balloon_save, virtio_balloon_load, s);
return &s->vdev;
}
| 5,528 |
FFmpeg | 27085d1b47c3741cc0fac284c916127c4066d049 | 1 | static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
{
AVFrame *decoded_frame, *f;
AVCodecContext *avctx = ist->dec_ctx;
int i, ret, err = 0;
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
decoded_frame = ist->decoded_frame;
ret = decode(avctx, decoded_frame, got_output, pkt);
if (!*got_output || ret < 0)
return ret;
ist->samples_decoded += decoded_frame->nb_samples;
ist->frames_decoded++;
/* if the decoder provides a pts, use it instead of the last packet pts.
the decoder could be delaying output by a packet or more. */
if (decoded_frame->pts != AV_NOPTS_VALUE)
ist->next_dts = decoded_frame->pts;
else if (pkt && pkt->pts != AV_NOPTS_VALUE) {
decoded_frame->pts = pkt->pts;
}
if (decoded_frame->pts != AV_NOPTS_VALUE)
decoded_frame->pts = av_rescale_q(decoded_frame->pts,
ist->st->time_base,
(AVRational){1, avctx->sample_rate});
ist->nb_samples = decoded_frame->nb_samples;
for (i = 0; i < ist->nb_filters; i++) {
if (i < ist->nb_filters - 1) {
f = ist->filter_frame;
err = av_frame_ref(f, decoded_frame);
if (err < 0)
break;
} else
f = decoded_frame;
err = ifilter_send_frame(ist->filters[i], f);
if (err < 0)
break;
}
av_frame_unref(ist->filter_frame);
av_frame_unref(decoded_frame);
return err < 0 ? err : ret;
}
| 5,530 |
qemu | 62030ed135e4cfb960cb626510cbb3ea77bb9ef9 | 1 | static void test_port(int port)
{
struct qhc uhci;
g_assert(port > 0);
qusb_pci_init_one(qs->pcibus, &uhci, QPCI_DEVFN(0x1d, 0), 4);
uhci_port_test(&uhci, port - 1, UHCI_PORT_CCS);
} | 5,531 |
FFmpeg | 4391805916a1557278351f25428d0145b1073520 | 1 | rgb16_32ToUV_c_template(uint8_t *dstU, uint8_t *dstV,
const uint8_t *src, int width,
enum PixelFormat origin,
int shr, int shg, int shb, int shp,
int maskr, int maskg, int maskb,
int rsh, int gsh, int bsh, int S)
{
const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,
rnd = 257 << (S - 1);
int i;
for (i = 0; i < width; i++) {
int px = input_pixel(i) >> shp;
int b = (px & maskb) >> shb;
int g = (px & maskg) >> shg;
int r = (px & maskr) >> shr;
dstU[i] = (ru * r + gu * g + bu * b + rnd) >> S;
dstV[i] = (rv * r + gv * g + bv * b + rnd) >> S;
}
}
| 5,532 |
qemu | 3e9fab690d59ac15956c3733fe0794ce1ae4c4af | 1 | void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
qmp_block_set_io_throttle(qdict_get_str(qdict, "device"),
qdict_get_int(qdict, "bps"),
qdict_get_int(qdict, "bps_rd"),
qdict_get_int(qdict, "bps_wr"),
qdict_get_int(qdict, "iops"),
qdict_get_int(qdict, "iops_rd"),
qdict_get_int(qdict, "iops_wr"), &err);
hmp_handle_error(mon, &err);
}
| 5,533 |
qemu | aedbe19297907143f17b733a7ff0e0534377bed1 | 1 | void qemu_system_shutdown_request(void)
{
trace_qemu_system_shutdown_request();
replay_shutdown_request();
shutdown_requested = 1;
qemu_notify_event();
}
| 5,534 |
qemu | 65a8e1f6413a0f6f79894da710b5d6d43361d27d | 1 | size_t mptsas_config_ioc_0(MPTSASState *s, uint8_t **data, int address)
{
PCIDeviceClass *pcic = PCI_DEVICE_GET_CLASS(s);
return MPTSAS_CONFIG_PACK(0, MPI_CONFIG_PAGETYPE_IOC, 0x01,
"*l*lwwb*b*b*blww",
pcic->vendor_id, pcic->device_id, pcic->revision,
pcic->subsystem_vendor_id,
pcic->subsystem_id);
}
| 5,535 |
qemu | d1f193b0edb919ab109f88c53469ec9073f2e142 | 1 | static uint32_t sh_serial_ioport_read(void *opaque, uint32_t offs)
{
sh_serial_state *s = opaque;
uint32_t ret = ~0;
#if 0
switch(offs) {
case 0x00:
ret = s->smr;
break;
case 0x04:
ret = s->brr;
break;
case 0x08:
ret = s->scr;
break;
case 0x14:
ret = 0;
break;
}
#endif
if (s->feat & SH_SERIAL_FEAT_SCIF) {
switch(offs) {
case 0x00: /* SMR */
ret = s->smr;
break;
case 0x08: /* SCR */
ret = s->scr;
break;
case 0x10: /* FSR */
ret = 0;
if (s->flags & SH_SERIAL_FLAG_TEND)
ret |= (1 << 6);
if (s->flags & SH_SERIAL_FLAG_TDE)
ret |= (1 << 5);
if (s->flags & SH_SERIAL_FLAG_BRK)
ret |= (1 << 4);
if (s->flags & SH_SERIAL_FLAG_RDF)
ret |= (1 << 1);
if (s->flags & SH_SERIAL_FLAG_DR)
ret |= (1 << 0);
if (s->scr & (1 << 5))
s->flags |= SH_SERIAL_FLAG_TDE | SH_SERIAL_FLAG_TEND;
break;
case 0x14:
if (s->rx_cnt > 0) {
ret = s->rx_fifo[s->rx_tail++];
s->rx_cnt--;
if (s->rx_tail == SH_RX_FIFO_LENGTH)
s->rx_tail = 0;
if (s->rx_cnt < s->rtrg)
s->flags &= ~SH_SERIAL_FLAG_RDF;
}
break;
#if 0
case 0x18:
ret = s->fcr;
break;
#endif
case 0x1c:
ret = s->rx_cnt;
break;
case 0x20:
ret = s->sptr;
break;
case 0x24:
ret = 0;
break;
}
}
else {
#if 0
switch(offs) {
case 0x0c:
ret = s->dr;
break;
case 0x10:
ret = 0;
break;
case 0x14:
ret = s->rx_fifo[0];
break;
case 0x1c:
ret = s->sptr;
break;
}
#endif
}
#ifdef DEBUG_SERIAL
printf("sh_serial: read offs=0x%02x val=0x%x\n",
offs, ret);
#endif
if (ret & ~((1 << 16) - 1)) {
fprintf(stderr, "sh_serial: unsupported read from 0x%02x\n", offs);
assert(0);
}
return ret;
}
| 5,536 |
qemu | 038268e2e8087ee2fd8987a77ba580e15f14c147 | 1 | void ide_dma_cb(void *opaque, int ret)
{
IDEState *s = opaque;
int n;
int64_t sector_num;
bool stay_active = false;
if (ret < 0) {
int op = BM_STATUS_DMA_RETRY;
if (s->dma_cmd == IDE_DMA_READ)
op |= BM_STATUS_RETRY_READ;
else if (s->dma_cmd == IDE_DMA_TRIM)
op |= BM_STATUS_RETRY_TRIM;
if (ide_handle_rw_error(s, -ret, op)) {
return;
n = s->io_buffer_size >> 9;
if (n > s->nsector) {
/* The PRDs were longer than needed for this request. Shorten them so
* we don't get a negative remainder. The Active bit must remain set
* after the request completes. */
n = s->nsector;
stay_active = true;
sector_num = ide_get_sector(s);
if (n > 0) {
dma_buf_commit(s);
sector_num += n;
ide_set_sector(s, sector_num);
s->nsector -= n;
/* end of transfer ? */
if (s->nsector == 0) {
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
goto eot;
/* launch next transfer */
n = s->nsector;
s->io_buffer_index = 0;
s->io_buffer_size = n * 512;
if (s->bus->dma->ops->prepare_buf(s->bus->dma, ide_cmd_is_read(s)) == 0) {
/* The PRDs were too short. Reset the Active bit, but don't raise an
* interrupt. */
goto eot;
#ifdef DEBUG_AIO
printf("ide_dma_cb: sector_num=%" PRId64 " n=%d, cmd_cmd=%d\n",
sector_num, n, s->dma_cmd);
#endif
switch (s->dma_cmd) {
case IDE_DMA_READ:
s->bus->dma->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num,
ide_dma_cb, s);
break;
case IDE_DMA_WRITE:
s->bus->dma->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num,
ide_dma_cb, s);
break;
case IDE_DMA_TRIM:
s->bus->dma->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num,
ide_issue_trim, ide_dma_cb, s,
DMA_DIRECTION_TO_DEVICE);
break;
return;
eot:
if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) {
bdrv_acct_done(s->bs, &s->acct);
ide_set_inactive(s);
| 5,537 |
qemu | a1a6bbde4f6a29368f8f605cea2e73630ec1bc7c | 1 | static void icp_realize(DeviceState *dev, Error **errp)
{
ICPState *icp = ICP(dev);
ICPStateClass *icpc = ICP_GET_CLASS(dev);
PowerPCCPU *cpu;
CPUPPCState *env;
Object *obj;
Error *err = NULL;
obj = object_property_get_link(OBJECT(dev), ICP_PROP_XICS, &err);
if (!obj) {
error_setg(errp, "%s: required link '" ICP_PROP_XICS "' not found: %s",
__func__, error_get_pretty(err));
return;
}
icp->xics = XICS_FABRIC(obj);
obj = object_property_get_link(OBJECT(dev), ICP_PROP_CPU, &err);
if (!obj) {
error_setg(errp, "%s: required link '" ICP_PROP_CPU "' not found: %s",
__func__, error_get_pretty(err));
return;
}
cpu = POWERPC_CPU(obj);
cpu->intc = OBJECT(icp);
icp->cs = CPU(obj);
env = &cpu->env;
switch (PPC_INPUT(env)) {
case PPC_FLAGS_INPUT_POWER7:
icp->output = env->irq_inputs[POWER7_INPUT_INT];
break;
case PPC_FLAGS_INPUT_970:
icp->output = env->irq_inputs[PPC970_INPUT_INT];
break;
default:
error_setg(errp, "XICS interrupt controller does not support this CPU bus model");
return;
}
if (icpc->realize) {
icpc->realize(icp, errp);
}
qemu_register_reset(icp_reset, dev);
vmstate_register(NULL, icp->cs->cpu_index, &vmstate_icp_server, icp);
}
| 5,538 |
qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | 1 | static inline void gen_st8(TCGv val, TCGv addr, int index)
{
tcg_gen_qemu_st8(val, addr, index);
dead_tmp(val);
}
| 5,540 |
FFmpeg | 9cb1ed5735ec03f6331f9777e25aa2f736a9d60f | 0 | static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program)
{
AVStream *stream = ist->st;
AVCodecParameters *par;
AVCodecContext *dec_ctx;
char val_str[128];
const char *s;
AVRational sar, dar;
AVBPrint pbuf;
const AVCodecDescriptor *cd;
int ret = 0;
const char *profile = NULL;
av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
writer_print_section_header(w, in_program ? SECTION_ID_PROGRAM_STREAM : SECTION_ID_STREAM);
print_int("index", stream->index);
par = stream->codecpar;
dec_ctx = ist->dec_ctx;
if (cd = avcodec_descriptor_get(par->codec_id)) {
print_str("codec_name", cd->name);
if (!do_bitexact) {
print_str("codec_long_name",
cd->long_name ? cd->long_name : "unknown");
}
} else {
print_str_opt("codec_name", "unknown");
if (!do_bitexact) {
print_str_opt("codec_long_name", "unknown");
}
}
if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile)))
print_str("profile", profile);
else {
if (par->profile != FF_PROFILE_UNKNOWN) {
char profile_num[12];
snprintf(profile_num, sizeof(profile_num), "%d", par->profile);
print_str("profile", profile_num);
} else
print_str_opt("profile", "unknown");
}
s = av_get_media_type_string(par->codec_type);
if (s) print_str ("codec_type", s);
else print_str_opt("codec_type", "unknown");
#if FF_API_LAVF_AVCTX
print_q("codec_time_base", dec_ctx->time_base, '/');
#endif
/* print AVI/FourCC tag */
av_get_codec_tag_string(val_str, sizeof(val_str), par->codec_tag);
print_str("codec_tag_string", val_str);
print_fmt("codec_tag", "0x%04x", par->codec_tag);
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
print_int("width", par->width);
print_int("height", par->height);
if (dec_ctx) {
print_int("coded_width", dec_ctx->coded_width);
print_int("coded_height", dec_ctx->coded_height);
}
print_int("has_b_frames", par->video_delay);
sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
if (sar.den) {
print_q("sample_aspect_ratio", sar, ':');
av_reduce(&dar.num, &dar.den,
par->width * sar.num,
par->height * sar.den,
1024*1024);
print_q("display_aspect_ratio", dar, ':');
} else {
print_str_opt("sample_aspect_ratio", "N/A");
print_str_opt("display_aspect_ratio", "N/A");
}
s = av_get_pix_fmt_name(par->format);
if (s) print_str ("pix_fmt", s);
else print_str_opt("pix_fmt", "unknown");
print_int("level", par->level);
if (par->color_range != AVCOL_RANGE_UNSPECIFIED)
print_str ("color_range", av_color_range_name(par->color_range));
else
print_str_opt("color_range", "N/A");
s = av_get_colorspace_name(par->color_space);
if (s) print_str ("color_space", s);
else print_str_opt("color_space", "unknown");
if (par->color_trc != AVCOL_TRC_UNSPECIFIED)
print_str("color_transfer", av_color_transfer_name(par->color_trc));
else
print_str_opt("color_transfer", av_color_transfer_name(par->color_trc));
if (par->color_primaries != AVCOL_PRI_UNSPECIFIED)
print_str("color_primaries", av_color_primaries_name(par->color_primaries));
else
print_str_opt("color_primaries", av_color_primaries_name(par->color_primaries));
if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
print_str("chroma_location", av_chroma_location_name(par->chroma_location));
else
print_str_opt("chroma_location", av_chroma_location_name(par->chroma_location));
#if FF_API_PRIVATE_OPT
if (dec_ctx && dec_ctx->timecode_frame_start >= 0) {
char tcbuf[AV_TIMECODE_STR_SIZE];
av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start);
print_str("timecode", tcbuf);
} else {
print_str_opt("timecode", "N/A");
}
#endif
if (dec_ctx)
print_int("refs", dec_ctx->refs);
break;
case AVMEDIA_TYPE_AUDIO:
s = av_get_sample_fmt_name(par->format);
if (s) print_str ("sample_fmt", s);
else print_str_opt("sample_fmt", "unknown");
print_val("sample_rate", par->sample_rate, unit_hertz_str);
print_int("channels", par->channels);
if (par->channel_layout) {
av_bprint_clear(&pbuf);
av_bprint_channel_layout(&pbuf, par->channels, par->channel_layout);
print_str ("channel_layout", pbuf.str);
} else {
print_str_opt("channel_layout", "unknown");
}
print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id));
break;
case AVMEDIA_TYPE_SUBTITLE:
if (par->width)
print_int("width", par->width);
else
print_str_opt("width", "N/A");
if (par->height)
print_int("height", par->height);
else
print_str_opt("height", "N/A");
break;
}
if (dec_ctx && dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) {
const AVOption *opt = NULL;
while (opt = av_opt_next(dec_ctx->priv_data,opt)) {
uint8_t *str;
if (opt->flags) continue;
if (av_opt_get(dec_ctx->priv_data, opt->name, 0, &str) >= 0) {
print_str(opt->name, str);
av_free(str);
}
}
}
if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%x", stream->id);
else print_str_opt("id", "N/A");
print_q("r_frame_rate", stream->r_frame_rate, '/');
print_q("avg_frame_rate", stream->avg_frame_rate, '/');
print_q("time_base", stream->time_base, '/');
print_ts ("start_pts", stream->start_time);
print_time("start_time", stream->start_time, &stream->time_base);
print_ts ("duration_ts", stream->duration);
print_time("duration", stream->duration, &stream->time_base);
if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str);
else print_str_opt("bit_rate", "N/A");
#if FF_API_LAVF_AVCTX
if (stream->codec->rc_max_rate > 0) print_val ("max_bit_rate", stream->codec->rc_max_rate, unit_bit_per_second_str);
else print_str_opt("max_bit_rate", "N/A");
#endif
if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample);
else print_str_opt("bits_per_raw_sample", "N/A");
if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames);
else print_str_opt("nb_frames", "N/A");
if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]);
else print_str_opt("nb_read_frames", "N/A");
if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]);
else print_str_opt("nb_read_packets", "N/A");
if (do_show_data)
writer_print_data(w, "extradata", par->extradata,
par->extradata_size);
writer_print_data_hash(w, "extradata_hash", par->extradata,
par->extradata_size);
/* Print disposition information */
#define PRINT_DISPOSITION(flagname, name) do { \
print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \
} while (0)
if (do_show_stream_disposition) {
writer_print_section_header(w, in_program ? SECTION_ID_PROGRAM_STREAM_DISPOSITION : SECTION_ID_STREAM_DISPOSITION);
PRINT_DISPOSITION(DEFAULT, "default");
PRINT_DISPOSITION(DUB, "dub");
PRINT_DISPOSITION(ORIGINAL, "original");
PRINT_DISPOSITION(COMMENT, "comment");
PRINT_DISPOSITION(LYRICS, "lyrics");
PRINT_DISPOSITION(KARAOKE, "karaoke");
PRINT_DISPOSITION(FORCED, "forced");
PRINT_DISPOSITION(HEARING_IMPAIRED, "hearing_impaired");
PRINT_DISPOSITION(VISUAL_IMPAIRED, "visual_impaired");
PRINT_DISPOSITION(CLEAN_EFFECTS, "clean_effects");
PRINT_DISPOSITION(ATTACHED_PIC, "attached_pic");
writer_print_section_footer(w);
}
if (do_show_stream_tags)
ret = show_tags(w, stream->metadata, in_program ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS);
if (stream->nb_side_data) {
int i;
writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA_LIST);
for (i = 0; i < stream->nb_side_data; i++) {
AVPacketSideData *sd = &stream->side_data[i];
const char *name = av_packet_side_data_name(sd->type);
writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA);
print_str("side_data_type", name ? name : "unknown");
print_int("side_data_size", sd->size);
if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
}
writer_print_section_footer(w);
}
writer_print_section_footer(w);
}
writer_print_section_footer(w);
av_bprint_finalize(&pbuf, NULL);
fflush(stdout);
return ret;
}
| 5,541 |
FFmpeg | c8780822bacc38a8d84c882d564b07dd152366ed | 0 | static int build_filter(ResampleContext *c, void *filter, double factor, int tap_count, int alloc, int phase_count, int scale,
int filter_type, int kaiser_beta){
int ph, i;
double x, y, w;
double *tab = av_malloc_array(tap_count+1, sizeof(*tab));
const int center= (tap_count-1)/2;
if (!tab)
return AVERROR(ENOMEM);
/* if upsampling, only need to interpolate, no filter */
if (factor > 1.0)
factor = 1.0;
av_assert0(phase_count == 1 || phase_count % 2 == 0);
for(ph = 0; ph <= phase_count / 2; ph++) {
double norm = 0;
for(i=0;i<=tap_count;i++) {
x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
if (x == 0) y = 1.0;
else y = sin(x) / x;
switch(filter_type){
case SWR_FILTER_TYPE_CUBIC:{
const float d= -0.5; //first order derivative = -0.5
x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);
if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*( -x*x + x*x*x);
else y= d*(-4 + 8*x - 5*x*x + x*x*x);
break;}
case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:
w = 2.0*x / (factor*tap_count) + M_PI;
y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w);
break;
case SWR_FILTER_TYPE_KAISER:
w = 2.0*x / (factor*tap_count*M_PI);
y *= bessel(kaiser_beta*sqrt(FFMAX(1-w*w, 0)));
break;
default:
av_assert0(0);
}
tab[i] = y;
if (i < tap_count)
norm += y;
}
/* normalize so that an uniform color remains the same */
switch(c->format){
case AV_SAMPLE_FMT_S16P:
for(i=0;i<tap_count;i++)
((int16_t*)filter)[ph * alloc + i] = av_clip(lrintf(tab[i] * scale / norm), INT16_MIN, INT16_MAX);
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
av_clip(lrintf(tab[i] * scale / (norm - tab[0] + tab[tap_count])), INT16_MIN, INT16_MAX);
}
break;
case AV_SAMPLE_FMT_S32P:
for(i=0;i<tap_count;i++)
((int32_t*)filter)[ph * alloc + i] = av_clipl_int32(llrint(tab[i] * scale / norm));
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int32_t*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
av_clipl_int32(llrint(tab[i] * scale / (norm - tab[0] + tab[tap_count])));
}
break;
case AV_SAMPLE_FMT_FLTP:
for(i=0;i<tap_count;i++)
((float*)filter)[ph * alloc + i] = tab[i] * scale / norm;
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((float*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((float*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
}
break;
case AV_SAMPLE_FMT_DBLP:
for(i=0;i<tap_count;i++)
((double*)filter)[ph * alloc + i] = tab[i] * scale / norm;
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((double*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((double*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
}
break;
}
}
#if 0
{
#define LEN 1024
int j,k;
double sine[LEN + tap_count];
double filtered[LEN];
double maxff=-2, minff=2, maxsf=-2, minsf=2;
for(i=0; i<LEN; i++){
double ss=0, sf=0, ff=0;
for(j=0; j<LEN+tap_count; j++)
sine[j]= cos(i*j*M_PI/LEN);
for(j=0; j<LEN; j++){
double sum=0;
ph=0;
for(k=0; k<tap_count; k++)
sum += filter[ph * tap_count + k] * sine[k+j];
filtered[j]= sum / (1<<FILTER_SHIFT);
ss+= sine[j + center] * sine[j + center];
ff+= filtered[j] * filtered[j];
sf+= sine[j + center] * filtered[j];
}
ss= sqrt(2*ss/LEN);
ff= sqrt(2*ff/LEN);
sf= 2*sf/LEN;
maxff= FFMAX(maxff, ff);
minff= FFMIN(minff, ff);
maxsf= FFMAX(maxsf, sf);
minsf= FFMIN(minsf, sf);
if(i%11==0){
av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf);
minff=minsf= 2;
maxff=maxsf= -2;
}
}
}
#endif
av_free(tab);
return 0;
}
| 5,542 |
qemu | c89d416a2b0fb6a21224186b10af4c4a3feee31b | 1 | e1000e_write_ps_rx_descr(E1000ECore *core, uint8_t *desc,
struct NetRxPkt *pkt,
const E1000E_RSSInfo *rss_info,
size_t ps_hdr_len,
uint16_t(*written)[MAX_PS_BUFFERS])
{
int i;
union e1000_rx_desc_packet_split *d =
(union e1000_rx_desc_packet_split *) desc;
memset(d, 0, sizeof(*d));
d->wb.middle.length0 = cpu_to_le16((*written)[0]);
for (i = 0; i < PS_PAGE_BUFFERS; i++) {
d->wb.upper.length[i] = cpu_to_le16((*written)[i + 1]);
}
e1000e_build_rx_metadata(core, pkt, pkt != NULL,
rss_info,
&d->wb.lower.hi_dword.rss,
&d->wb.lower.mrq,
&d->wb.middle.status_error,
&d->wb.lower.hi_dword.csum_ip.ip_id,
&d->wb.middle.vlan);
d->wb.upper.header_status =
cpu_to_le16(ps_hdr_len | (ps_hdr_len ? E1000_RXDPS_HDRSTAT_HDRSP : 0));
trace_e1000e_rx_desc_ps_write((*written)[0], (*written)[1],
(*written)[2], (*written)[3]);
}
| 5,543 |
FFmpeg | a4435f9235eefac8a25f1cda471486e2c37b21b5 | 1 | static void print_track_chunks(FILE *out, struct Tracks *tracks, int main,
const char *type)
{
int i, j;
struct Track *track = tracks->tracks[main];
for (i = 0; i < track->chunks; i++) {
for (j = main + 1; j < tracks->nb_tracks; j++) {
if (tracks->tracks[j]->is_audio == track->is_audio &&
track->offsets[i].duration != tracks->tracks[j]->offsets[i].duration)
fprintf(stderr, "Mismatched duration of %s chunk %d in %s and %s\n",
type, i, track->name, tracks->tracks[j]->name);
}
fprintf(out, "\t\t<c n=\"%d\" d=\"%d\" />\n",
i, track->offsets[i].duration);
}
}
| 5,544 |
qemu | 2cdb5e142fb93e875fa53c52864ef5eb8d5d8b41 | 1 | void vncws_handshake_read(void *opaque)
{
VncState *vs = opaque;
uint8_t *handshake_end;
long ret;
buffer_reserve(&vs->ws_input, 4096);
ret = vnc_client_read_buf(vs, buffer_end(&vs->ws_input), 4096);
if (!ret) {
if (vs->csock == -1) {
vnc_disconnect_finish(vs);
}
return;
}
vs->ws_input.offset += ret;
handshake_end = (uint8_t *)g_strstr_len((char *)vs->ws_input.buffer,
vs->ws_input.offset, WS_HANDSHAKE_END);
if (handshake_end) {
qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs);
vncws_process_handshake(vs, vs->ws_input.buffer, vs->ws_input.offset);
buffer_advance(&vs->ws_input, handshake_end - vs->ws_input.buffer +
strlen(WS_HANDSHAKE_END));
}
}
| 5,545 |
qemu | a1bb73849fbd7d992b6ac2cf30c034244fb2299d | 1 | void helper_rfmci(CPUPPCState *env)
{
do_rfi(env, env->spr[SPR_BOOKE_MCSRR0], SPR_BOOKE_MCSRR1,
~((target_ulong)0x3FFF0000), 0);
}
| 5,546 |
qemu | d615efac7c4dc0984de31791c5c7d6b06408aadb | 1 | static int get_phys_addr_lpae(CPUARMState *env, target_ulong address,
int access_type, int is_user,
hwaddr *phys_ptr, int *prot,
target_ulong *page_size_ptr)
{
CPUState *cs = CPU(arm_env_get_cpu(env));
/* Read an LPAE long-descriptor translation table. */
MMUFaultType fault_type = translation_fault;
uint32_t level = 1;
uint32_t epd;
int32_t tsz;
uint32_t tg;
uint64_t ttbr;
int ttbr_select;
hwaddr descaddr, descmask;
uint32_t tableattrs;
target_ulong page_size;
uint32_t attrs;
int32_t granule_sz = 9;
int32_t va_size = 32;
int32_t tbi = 0;
if (arm_el_is_aa64(env, 1)) {
va_size = 64;
if (extract64(address, 55, 1))
tbi = extract64(env->cp15.c2_control, 38, 1);
else
tbi = extract64(env->cp15.c2_control, 37, 1);
tbi *= 8;
}
/* Determine whether this address is in the region controlled by
* TTBR0 or TTBR1 (or if it is in neither region and should fault).
* This is a Non-secure PL0/1 stage 1 translation, so controlled by
* TTBCR/TTBR0/TTBR1 in accordance with ARM ARM DDI0406C table B-32:
*/
uint32_t t0sz = extract32(env->cp15.c2_control, 0, 6);
if (arm_el_is_aa64(env, 1)) {
t0sz = MIN(t0sz, 39);
t0sz = MAX(t0sz, 16);
}
uint32_t t1sz = extract32(env->cp15.c2_control, 16, 6);
if (arm_el_is_aa64(env, 1)) {
t1sz = MIN(t1sz, 39);
t1sz = MAX(t1sz, 16);
}
if (t0sz && !extract64(address, va_size - t0sz, t0sz - tbi)) {
/* there is a ttbr0 region and we are in it (high bits all zero) */
ttbr_select = 0;
} else if (t1sz && !extract64(~address, va_size - t1sz, t1sz - tbi)) {
/* there is a ttbr1 region and we are in it (high bits all one) */
ttbr_select = 1;
} else if (!t0sz) {
/* ttbr0 region is "everything not in the ttbr1 region" */
ttbr_select = 0;
} else if (!t1sz) {
/* ttbr1 region is "everything not in the ttbr0 region" */
ttbr_select = 1;
} else {
/* in the gap between the two regions, this is a Translation fault */
fault_type = translation_fault;
goto do_fault;
}
/* Note that QEMU ignores shareability and cacheability attributes,
* so we don't need to do anything with the SH, ORGN, IRGN fields
* in the TTBCR. Similarly, TTBCR:A1 selects whether we get the
* ASID from TTBR0 or TTBR1, but QEMU's TLB doesn't currently
* implement any ASID-like capability so we can ignore it (instead
* we will always flush the TLB any time the ASID is changed).
*/
if (ttbr_select == 0) {
ttbr = env->cp15.ttbr0_el1;
epd = extract32(env->cp15.c2_control, 7, 1);
tsz = t0sz;
tg = extract32(env->cp15.c2_control, 14, 2);
if (tg == 1) { /* 64KB pages */
granule_sz = 13;
}
if (tg == 2) { /* 16KB pages */
granule_sz = 11;
}
} else {
ttbr = env->cp15.ttbr1_el1;
epd = extract32(env->cp15.c2_control, 23, 1);
tsz = t1sz;
tg = extract32(env->cp15.c2_control, 30, 2);
if (tg == 3) { /* 64KB pages */
granule_sz = 13;
}
if (tg == 1) { /* 16KB pages */
granule_sz = 11;
}
}
if (epd) {
/* Translation table walk disabled => Translation fault on TLB miss */
goto do_fault;
}
/* The starting level depends on the virtual address size which can be
* up to 48-bits and the translation granule size.
*/
if ((va_size - tsz) > (granule_sz * 4 + 3)) {
level = 0;
} else if ((va_size - tsz) > (granule_sz * 3 + 3)) {
level = 1;
} else {
level = 2;
}
/* Clear the vaddr bits which aren't part of the within-region address,
* so that we don't have to special case things when calculating the
* first descriptor address.
*/
if (tsz) {
address &= (1ULL << (va_size - tsz)) - 1;
}
descmask = (1ULL << (granule_sz + 3)) - 1;
/* Now we can extract the actual base address from the TTBR */
descaddr = extract64(ttbr, 0, 48);
descaddr &= ~((1ULL << (va_size - tsz - (granule_sz * (4 - level)))) - 1);
tableattrs = 0;
for (;;) {
uint64_t descriptor;
descaddr |= (address >> (granule_sz * (4 - level))) & descmask;
descaddr &= ~7ULL;
descriptor = ldq_phys(cs->as, descaddr);
if (!(descriptor & 1) ||
(!(descriptor & 2) && (level == 3))) {
/* Invalid, or the Reserved level 3 encoding */
goto do_fault;
}
descaddr = descriptor & 0xfffffff000ULL;
if ((descriptor & 2) && (level < 3)) {
/* Table entry. The top five bits are attributes which may
* propagate down through lower levels of the table (and
* which are all arranged so that 0 means "no effect", so
* we can gather them up by ORing in the bits at each level).
*/
tableattrs |= extract64(descriptor, 59, 5);
level++;
continue;
}
/* Block entry at level 1 or 2, or page entry at level 3.
* These are basically the same thing, although the number
* of bits we pull in from the vaddr varies.
*/
page_size = (1 << ((granule_sz * (4 - level)) + 3));
descaddr |= (address & (page_size - 1));
/* Extract attributes from the descriptor and merge with table attrs */
if (arm_feature(env, ARM_FEATURE_V8)) {
attrs = extract64(descriptor, 2, 10)
| (extract64(descriptor, 53, 11) << 10);
} else {
attrs = extract64(descriptor, 2, 10)
| (extract64(descriptor, 52, 12) << 10);
}
attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */
attrs |= extract32(tableattrs, 3, 1) << 5; /* APTable[1] => AP[2] */
/* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
* means "force PL1 access only", which means forcing AP[1] to 0.
*/
if (extract32(tableattrs, 2, 1)) {
attrs &= ~(1 << 4);
}
/* Since we're always in the Non-secure state, NSTable is ignored. */
break;
}
/* Here descaddr is the final physical address, and attributes
* are all in attrs.
*/
fault_type = access_fault;
if ((attrs & (1 << 8)) == 0) {
/* Access flag */
goto do_fault;
}
fault_type = permission_fault;
if (is_user && !(attrs & (1 << 4))) {
/* Unprivileged access not enabled */
goto do_fault;
}
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
if (attrs & (1 << 12) || (!is_user && (attrs & (1 << 11)))) {
/* XN or PXN */
if (access_type == 2) {
goto do_fault;
}
*prot &= ~PAGE_EXEC;
}
if (attrs & (1 << 5)) {
/* Write access forbidden */
if (access_type == 1) {
goto do_fault;
}
*prot &= ~PAGE_WRITE;
}
*phys_ptr = descaddr;
*page_size_ptr = page_size;
return 0;
do_fault:
/* Long-descriptor format IFSR/DFSR value */
return (1 << 9) | (fault_type << 2) | level;
}
| 5,547 |
FFmpeg | 8248b51e0b94f0151b6a2057ee639d6e0db29f5f | 1 | av_cold void ff_diracdsp_init(DiracDSPContext *c)
{
c->dirac_hpel_filter = dirac_hpel_filter;
c->add_rect_clamped = add_rect_clamped_c;
c->put_signed_rect_clamped[0] = put_signed_rect_clamped_8bit_c;
c->put_signed_rect_clamped[1] = put_signed_rect_clamped_10bit_c;
c->add_dirac_obmc[0] = add_obmc8_c;
c->add_dirac_obmc[1] = add_obmc16_c;
c->add_dirac_obmc[2] = add_obmc32_c;
c->weight_dirac_pixels_tab[0] = weight_dirac_pixels8_c;
c->weight_dirac_pixels_tab[1] = weight_dirac_pixels16_c;
c->weight_dirac_pixels_tab[2] = weight_dirac_pixels32_c;
c->biweight_dirac_pixels_tab[0] = biweight_dirac_pixels8_c;
c->biweight_dirac_pixels_tab[1] = biweight_dirac_pixels16_c;
c->biweight_dirac_pixels_tab[2] = biweight_dirac_pixels32_c;
PIXFUNC(put, 8);
PIXFUNC(put, 16);
PIXFUNC(put, 32);
PIXFUNC(avg, 8);
PIXFUNC(avg, 16);
PIXFUNC(avg, 32);
if (HAVE_MMX && HAVE_YASM) ff_diracdsp_init_mmx(c);
} | 5,548 |
FFmpeg | f7f892e4d5bded48b08e7b776a5fb7c350496f2b | 1 | static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref, uint8_t *decoded, int stride, int level, int threshold, int lambda, int intra){
int count, y, x, i, j, split, best_mean, best_score, best_count;
int best_vector[6];
int block_sum[7]= {0, 0, 0, 0, 0, 0};
int w= 2<<((level+2)>>1);
int h= 2<<((level+1)>>1);
int size=w*h;
int16_t block[7][256];
const int8_t *codebook_sum, *codebook;
const uint16_t (*mean_vlc)[2];
const uint8_t (*multistage_vlc)[2];
best_score=0;
//FIXME optimize, this doenst need to be done multiple times
if(intra){
codebook_sum= svq1_intra_codebook_sum[level];
codebook= ff_svq1_intra_codebooks[level];
mean_vlc= ff_svq1_intra_mean_vlc;
multistage_vlc= ff_svq1_intra_multistage_vlc[level];
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int v= src[x + y*stride];
block[0][x + w*y]= v;
best_score += v*v;
block_sum[0] += v;
}
}
}else{
codebook_sum= svq1_inter_codebook_sum[level];
codebook= ff_svq1_inter_codebooks[level];
mean_vlc= ff_svq1_inter_mean_vlc + 256;
multistage_vlc= ff_svq1_inter_multistage_vlc[level];
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int v= src[x + y*stride] - ref[x + y*stride];
block[0][x + w*y]= v;
best_score += v*v;
block_sum[0] += v;
}
}
}
best_count=0;
best_score -= ((block_sum[0]*block_sum[0])>>(level+3));
best_mean= (block_sum[0] + (size>>1)) >> (level+3);
if(level<4){
for(count=1; count<7; count++){
int best_vector_score= INT_MAX;
int best_vector_sum=-999, best_vector_mean=-999;
const int stage= count-1;
const int8_t *vector;
for(i=0; i<16; i++){
int sum= codebook_sum[stage*16 + i];
int sqr, diff, score;
vector = codebook + stage*size*16 + i*size;
sqr = s->dsp.ssd_int8_vs_int16(vector, block[stage], size);
diff= block_sum[stage] - sum;
score= sqr - ((diff*(int64_t)diff)>>(level+3)); //FIXME 64bit slooow
if(score < best_vector_score){
int mean= (diff + (size>>1)) >> (level+3);
assert(mean >-300 && mean<300);
mean= av_clip(mean, intra?0:-256, 255);
best_vector_score= score;
best_vector[stage]= i;
best_vector_sum= sum;
best_vector_mean= mean;
}
}
assert(best_vector_mean != -999);
vector= codebook + stage*size*16 + best_vector[stage]*size;
for(j=0; j<size; j++){
block[stage+1][j] = block[stage][j] - vector[j];
}
block_sum[stage+1]= block_sum[stage] - best_vector_sum;
best_vector_score +=
lambda*(+ 1 + 4*count
+ multistage_vlc[1+count][1]
+ mean_vlc[best_vector_mean][1]);
if(best_vector_score < best_score){
best_score= best_vector_score;
best_count= count;
best_mean= best_vector_mean;
}
}
}
split=0;
if(best_score > threshold && level){
int score=0;
int offset= (level&1) ? stride*h/2 : w/2;
PutBitContext backup[6];
for(i=level-1; i>=0; i--){
backup[i]= s->reorder_pb[i];
}
score += encode_block(s, src , ref , decoded , stride, level-1, threshold>>1, lambda, intra);
score += encode_block(s, src + offset, ref + offset, decoded + offset, stride, level-1, threshold>>1, lambda, intra);
score += lambda;
if(score < best_score){
best_score= score;
split=1;
}else{
for(i=level-1; i>=0; i--){
s->reorder_pb[i]= backup[i];
}
}
}
if (level > 0)
put_bits(&s->reorder_pb[level], 1, split);
if(!split){
assert((best_mean >= 0 && best_mean<256) || !intra);
assert(best_mean >= -256 && best_mean<256);
assert(best_count >=0 && best_count<7);
assert(level<4 || best_count==0);
/* output the encoding */
put_bits(&s->reorder_pb[level],
multistage_vlc[1 + best_count][1],
multistage_vlc[1 + best_count][0]);
put_bits(&s->reorder_pb[level], mean_vlc[best_mean][1],
mean_vlc[best_mean][0]);
for (i = 0; i < best_count; i++){
assert(best_vector[i]>=0 && best_vector[i]<16);
put_bits(&s->reorder_pb[level], 4, best_vector[i]);
}
for(y=0; y<h; y++){
for(x=0; x<w; x++){
decoded[x + y*stride]= src[x + y*stride] - block[best_count][x + w*y] + best_mean;
}
}
}
return best_score;
}
| 5,549 |
qemu | 2d3aa28cc2cf382aa04cd577e0be542175eea9bd | 1 | void object_property_set_link(Object *obj, Object *value,
const char *name, Error **errp)
{
object_property_set_str(obj, object_get_canonical_path(value),
name, errp);
}
| 5,550 |
qemu | 231bb267644ee3a9ebfd9c7f42d5d41610194b45 | 1 | static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i)
{
BDRVQcowState *s = bs->opaque;
int ret = 0;
if (!c->entries[i].dirty || !c->entries[i].offset) {
return 0;
}
trace_qcow2_cache_entry_flush(qemu_coroutine_self(),
c == s->l2_table_cache, i);
if (c->depends) {
ret = qcow2_cache_flush_dependency(bs, c);
} else if (c->depends_on_flush) {
ret = bdrv_flush(bs->file);
if (ret >= 0) {
c->depends_on_flush = false;
}
}
if (ret < 0) {
return ret;
}
if (c == s->refcount_block_cache) {
ret = qcow2_pre_write_overlap_check(bs,
QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_BLOCK,
c->entries[i].offset, s->cluster_size);
} else if (c == s->l2_table_cache) {
ret = qcow2_pre_write_overlap_check(bs,
QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L2,
c->entries[i].offset, s->cluster_size);
} else {
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT,
c->entries[i].offset, s->cluster_size);
}
if (ret < 0) {
return ret;
}
if (c == s->refcount_block_cache) {
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_UPDATE_PART);
} else if (c == s->l2_table_cache) {
BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE);
}
ret = bdrv_pwrite(bs->file, c->entries[i].offset, c->entries[i].table,
s->cluster_size);
if (ret < 0) {
return ret;
}
c->entries[i].dirty = false;
return 0;
}
| 5,551 |
qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | 0 | USBBus *usb_bus_new(DeviceState *host)
{
USBBus *bus;
bus = FROM_QBUS(USBBus, qbus_create(&usb_bus_info, host, NULL));
bus->busnr = next_usb_bus++;
TAILQ_INIT(&bus->free);
TAILQ_INIT(&bus->used);
TAILQ_INSERT_TAIL(&busses, bus, next);
return bus;
}
| 5,552 |
qemu | a205a053dcfd89c7ab57aef48d26cd9349388933 | 0 | sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn)
{
sPAPRTCETable *tcet;
char tmp[32];
if (spapr_tce_find_by_liobn(liobn)) {
error_report("Attempted to create TCE table with duplicate"
" LIOBN 0x%x", liobn);
return NULL;
}
tcet = SPAPR_TCE_TABLE(object_new(TYPE_SPAPR_TCE_TABLE));
tcet->liobn = liobn;
snprintf(tmp, sizeof(tmp), "tce-table-%x", liobn);
object_property_add_child(OBJECT(owner), tmp, OBJECT(tcet), NULL);
object_property_set_bool(OBJECT(tcet), true, "realized", NULL);
return tcet;
}
| 5,553 |
qemu | deb2db996cbb9470b39ae1e383791ef34c4eb3c2 | 0 | bool arm_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx)
{
return regime_using_lpae_format(env, mmu_idx);
}
| 5,554 |
qemu | a980a065fb5e86d6dec337e6cb6ff432f1a143c9 | 0 | static int usb_hub_initfn(USBDevice *dev)
{
USBHubState *s = DO_UPCAST(USBHubState, dev, dev);
USBHubPort *port;
int i;
s->dev.speed = USB_SPEED_FULL;
for (i = 0; i < NUM_PORTS; i++) {
port = &s->ports[i];
usb_register_port(usb_bus_from_device(dev),
&port->port, s, i, &s->dev, usb_hub_attach);
port->wPortStatus = PORT_STAT_POWER;
port->wPortChange = 0;
}
return 0;
}
| 5,555 |
FFmpeg | 1af5f60f6aafa5f2653e7ea7cd054b0a4f31c103 | 0 | static void horizontal_filter(unsigned char *first_pixel, int stride,
int *bounding_values)
{
unsigned char *end;
int filter_value;
for (end= first_pixel + 8*stride; first_pixel < end; first_pixel += stride) {
filter_value =
(first_pixel[-2] - first_pixel[ 1])
+3*(first_pixel[ 0] - first_pixel[-1]);
filter_value = bounding_values[(filter_value + 4) >> 3];
first_pixel[-1] = clip_uint8(first_pixel[-1] + filter_value);
first_pixel[ 0] = clip_uint8(first_pixel[ 0] - filter_value);
}
}
| 5,556 |
qemu | 37f51384ae05bd50f83308339dbffa3e78404874 | 0 | build_dmar_q35(GArray *table_data, BIOSLinker *linker)
{
int dmar_start = table_data->len;
AcpiTableDmar *dmar;
AcpiDmarHardwareUnit *drhd;
AcpiDmarRootPortATS *atsr;
uint8_t dmar_flags = 0;
X86IOMMUState *iommu = x86_iommu_get_default();
AcpiDmarDeviceScope *scope = NULL;
/* Root complex IOAPIC use one path[0] only */
size_t ioapic_scope_size = sizeof(*scope) + sizeof(scope->path[0]);
assert(iommu);
if (iommu->intr_supported) {
dmar_flags |= 0x1; /* Flags: 0x1: INT_REMAP */
}
dmar = acpi_data_push(table_data, sizeof(*dmar));
dmar->host_address_width = VTD_HOST_ADDRESS_WIDTH - 1;
dmar->flags = dmar_flags;
/* DMAR Remapping Hardware Unit Definition structure */
drhd = acpi_data_push(table_data, sizeof(*drhd) + ioapic_scope_size);
drhd->type = cpu_to_le16(ACPI_DMAR_TYPE_HARDWARE_UNIT);
drhd->length = cpu_to_le16(sizeof(*drhd) + ioapic_scope_size);
drhd->flags = ACPI_DMAR_INCLUDE_PCI_ALL;
drhd->pci_segment = cpu_to_le16(0);
drhd->address = cpu_to_le64(Q35_HOST_BRIDGE_IOMMU_ADDR);
/* Scope definition for the root-complex IOAPIC. See VT-d spec
* 8.3.1 (version Oct. 2014 or later). */
scope = &drhd->scope[0];
scope->entry_type = 0x03; /* Type: 0x03 for IOAPIC */
scope->length = ioapic_scope_size;
scope->enumeration_id = ACPI_BUILD_IOAPIC_ID;
scope->bus = Q35_PSEUDO_BUS_PLATFORM;
scope->path[0].device = PCI_SLOT(Q35_PSEUDO_DEVFN_IOAPIC);
scope->path[0].function = PCI_FUNC(Q35_PSEUDO_DEVFN_IOAPIC);
if (iommu->dt_supported) {
atsr = acpi_data_push(table_data, sizeof(*atsr));
atsr->type = cpu_to_le16(ACPI_DMAR_TYPE_ATSR);
atsr->length = cpu_to_le16(sizeof(*atsr));
atsr->flags = ACPI_DMAR_ATSR_ALL_PORTS;
atsr->pci_segment = cpu_to_le16(0);
}
build_header(linker, table_data, (void *)(table_data->data + dmar_start),
"DMAR", table_data->len - dmar_start, 1, NULL, NULL);
}
| 5,557 |
qemu | 307b7715d0256c95444cada36a02882e46bada2f | 0 | static void spapr_dr_connector_class_init(ObjectClass *k, void *data)
{
DeviceClass *dk = DEVICE_CLASS(k);
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
dk->reset = reset;
dk->realize = realize;
dk->unrealize = unrealize;
drck->set_isolation_state = set_isolation_state;
drck->set_allocation_state = set_allocation_state;
drck->release_pending = release_pending;
drck->set_signalled = set_signalled;
/*
* Reason: it crashes FIXME find and document the real reason
*/
dk->user_creatable = false;
}
| 5,558 |
qemu | 5bb95e41868b461f37159efb48908828ebd7ab36 | 0 | static void smbios_validate_table(void)
{
if (smbios_type4_count && smbios_type4_count != smp_cpus) {
fprintf(stderr,
"Number of SMBIOS Type 4 tables must match cpu count.\n");
exit(1);
}
}
| 5,559 |
qemu | e2779de053b64f023de382fd87b3596613d47d1e | 0 | static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
uint32_t *val, uint32_t dev_value,
uint32_t valid_mask)
{
XenPTRegInfo *reg = cfg_entry->reg;
XenPTRegion *base = NULL;
PCIDevice *d = &s->dev;
const PCIIORegion *r;
uint32_t writable_mask = 0;
uint32_t bar_emu_mask = 0;
uint32_t bar_ro_mask = 0;
uint32_t r_size = 0;
int index = 0;
index = xen_pt_bar_offset_to_index(reg->offset);
if (index < 0 || index >= PCI_NUM_REGIONS) {
XEN_PT_ERR(d, "Internal error: Invalid BAR index [%d].\n", index);
return -1;
}
r = &d->io_regions[index];
base = &s->bases[index];
r_size = xen_pt_get_emul_size(base->bar_flag, r->size);
/* set emulate mask and read-only mask values depend on the BAR flag */
switch (s->bases[index].bar_flag) {
case XEN_PT_BAR_FLAG_MEM:
bar_emu_mask = XEN_PT_BAR_MEM_EMU_MASK;
if (!r_size) {
/* low 32 bits mask for 64 bit bars */
bar_ro_mask = XEN_PT_BAR_ALLF;
} else {
bar_ro_mask = XEN_PT_BAR_MEM_RO_MASK | (r_size - 1);
}
break;
case XEN_PT_BAR_FLAG_IO:
bar_emu_mask = XEN_PT_BAR_IO_EMU_MASK;
bar_ro_mask = XEN_PT_BAR_IO_RO_MASK | (r_size - 1);
break;
case XEN_PT_BAR_FLAG_UPPER:
bar_emu_mask = XEN_PT_BAR_ALLF;
bar_ro_mask = r_size ? r_size - 1 : 0;
break;
default:
break;
}
/* modify emulate register */
writable_mask = bar_emu_mask & ~bar_ro_mask & valid_mask;
cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask);
/* check whether we need to update the virtual region address or not */
switch (s->bases[index].bar_flag) {
case XEN_PT_BAR_FLAG_UPPER:
case XEN_PT_BAR_FLAG_MEM:
/* nothing to do */
break;
case XEN_PT_BAR_FLAG_IO:
/* nothing to do */
break;
default:
break;
}
/* create value for writing to I/O device register */
*val = XEN_PT_MERGE_VALUE(*val, dev_value, 0);
return 0;
}
| 5,560 |
qemu | ddca7f86ac022289840e0200fd4050b2b58e9176 | 0 | static void v9fs_write(void *opaque)
{
ssize_t err;
int32_t fid;
uint64_t off;
uint32_t count;
int32_t len = 0;
int32_t total = 0;
size_t offset = 7;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
QEMUIOVector qiov_full;
QEMUIOVector qiov;
offset += pdu_unmarshal(pdu, offset, "dqd", &fid, &off, &count);
v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset, count, true);
trace_v9fs_write(pdu->tag, pdu->id, fid, off, count, qiov_full.niov);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (fidp->fid_type == P9_FID_FILE) {
if (fidp->fs.fd == -1) {
err = -EINVAL;
goto out;
}
} else if (fidp->fid_type == P9_FID_XATTR) {
/*
* setxattr operation
*/
err = v9fs_xattr_write(s, pdu, fidp, off, count,
qiov_full.iov, qiov_full.niov);
goto out;
} else {
err = -EINVAL;
goto out;
}
qemu_iovec_init(&qiov, qiov_full.niov);
do {
qemu_iovec_reset(&qiov);
qemu_iovec_copy(&qiov, &qiov_full, total, qiov_full.size - total);
if (0) {
print_sg(qiov.iov, qiov.niov);
}
/* Loop in case of EINTR */
do {
len = v9fs_co_pwritev(pdu, fidp, qiov.iov, qiov.niov, off);
if (len >= 0) {
off += len;
total += len;
}
} while (len == -EINTR && !pdu->cancelled);
if (len < 0) {
/* IO error return the error */
err = len;
goto out_qiov;
}
} while (total < count && len > 0);
offset = 7;
offset += pdu_marshal(pdu, offset, "d", total);
err = offset;
trace_v9fs_write_return(pdu->tag, pdu->id, total, err);
out_qiov:
qemu_iovec_destroy(&qiov);
out:
put_fid(pdu, fidp);
out_nofid:
qemu_iovec_destroy(&qiov_full);
complete_pdu(s, pdu, err);
}
| 5,561 |
qemu | 0bcba41fe379e4c6834adcf1456d9099db31a5b2 | 0 | void machine_register_compat_props(MachineState *machine)
{
MachineClass *mc = MACHINE_GET_CLASS(machine);
int i;
GlobalProperty *p;
if (!mc->compat_props) {
return;
}
for (i = 0; i < mc->compat_props->len; i++) {
p = g_array_index(mc->compat_props, GlobalProperty *, i);
/* Machine compat_props must never cause errors: */
p->errp = &error_abort;
qdev_prop_register_global(p);
}
}
| 5,562 |
qemu | 0ff0fad23d3693ecf7a0c462cdb48f0e60f93808 | 0 | static int win_chr_pipe_init(CharDriverState *chr, const char *filename,
Error **errp)
{
WinCharState *s = chr->opaque;
OVERLAPPED ov;
int ret;
DWORD size;
char openname[CHR_MAX_FILENAME_SIZE];
s->fpipe = TRUE;
s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!s->hsend) {
error_setg(errp, "Failed CreateEvent");
goto fail;
}
s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!s->hrecv) {
error_setg(errp, "Failed CreateEvent");
goto fail;
}
snprintf(openname, sizeof(openname), "\\\\.\\pipe\\%s", filename);
s->hcom = CreateNamedPipe(openname, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE |
PIPE_WAIT,
MAXCONNECT, NSENDBUF, NRECVBUF, NTIMEOUT, NULL);
if (s->hcom == INVALID_HANDLE_VALUE) {
error_setg(errp, "Failed CreateNamedPipe (%lu)", GetLastError());
s->hcom = NULL;
goto fail;
}
ZeroMemory(&ov, sizeof(ov));
ov.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
ret = ConnectNamedPipe(s->hcom, &ov);
if (ret) {
error_setg(errp, "Failed ConnectNamedPipe");
goto fail;
}
ret = GetOverlappedResult(s->hcom, &ov, &size, TRUE);
if (!ret) {
error_setg(errp, "Failed GetOverlappedResult");
if (ov.hEvent) {
CloseHandle(ov.hEvent);
ov.hEvent = NULL;
}
goto fail;
}
if (ov.hEvent) {
CloseHandle(ov.hEvent);
ov.hEvent = NULL;
}
qemu_add_polling_cb(win_chr_pipe_poll, chr);
return 0;
fail:
win_chr_close(chr);
return -1;
}
| 5,563 |
qemu | 9b717a3a1318455afce761301fec114982ccbf1f | 0 | static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
const char *name, int devfn,
Error **errp)
{
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
PCIConfigReadFunc *config_read = pc->config_read;
PCIConfigWriteFunc *config_write = pc->config_write;
Error *local_err = NULL;
DeviceState *dev = DEVICE(pci_dev);
pci_dev->bus = bus;
/* Only pci bridges can be attached to extra PCI root buses */
if (pci_bus_is_root(bus) && bus->parent_dev && !pc->is_bridge) {
error_setg(errp,
"PCI: Only PCI/PCIe bridges can be plugged into %s",
bus->parent_dev->name);
return NULL;
}
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
devfn += PCI_FUNC_MAX) {
if (!bus->devices[devfn])
goto found;
}
error_setg(errp, "PCI: no slot/function available for %s, all in use",
name);
return NULL;
found: ;
} else if (bus->devices[devfn]) {
error_setg(errp, "PCI: slot %d function %d not available for %s,"
" in use by %s",
PCI_SLOT(devfn), PCI_FUNC(devfn), name,
bus->devices[devfn]->name);
return NULL;
} else if (dev->hotplugged &&
pci_get_function_0(pci_dev)) {
error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s,"
" new func %s cannot be exposed to guest.",
PCI_SLOT(pci_get_function_0(pci_dev)->devfn),
pci_get_function_0(pci_dev)->name,
name);
return NULL;
}
pci_dev->devfn = devfn;
pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
memory_region_init(&pci_dev->bus_master_container_region, OBJECT(pci_dev),
"bus master container", UINT64_MAX);
address_space_init(&pci_dev->bus_master_as,
&pci_dev->bus_master_container_region, pci_dev->name);
if (qdev_hotplug) {
pci_init_bus_master(pci_dev);
}
pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
pci_dev->irq_state = 0;
pci_config_alloc(pci_dev);
pci_config_set_vendor_id(pci_dev->config, pc->vendor_id);
pci_config_set_device_id(pci_dev->config, pc->device_id);
pci_config_set_revision(pci_dev->config, pc->revision);
pci_config_set_class(pci_dev->config, pc->class_id);
if (!pc->is_bridge) {
if (pc->subsystem_vendor_id || pc->subsystem_id) {
pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,
pc->subsystem_vendor_id);
pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,
pc->subsystem_id);
} else {
pci_set_default_subsystem_id(pci_dev);
}
} else {
/* subsystem_vendor_id/subsystem_id are only for header type 0 */
assert(!pc->subsystem_vendor_id);
assert(!pc->subsystem_id);
}
pci_init_cmask(pci_dev);
pci_init_wmask(pci_dev);
pci_init_w1cmask(pci_dev);
if (pc->is_bridge) {
pci_init_mask_bridge(pci_dev);
}
pci_init_multifunction(bus, pci_dev, &local_err);
if (local_err) {
error_propagate(errp, local_err);
do_pci_unregister_device(pci_dev);
return NULL;
}
if (!config_read)
config_read = pci_default_read_config;
if (!config_write)
config_write = pci_default_write_config;
pci_dev->config_read = config_read;
pci_dev->config_write = config_write;
bus->devices[devfn] = pci_dev;
pci_dev->version_id = 2; /* Current pci device vmstate version */
return pci_dev;
}
| 5,564 |
qemu | d1eb8f2acba579830cf3798c3c15ce51be852c56 | 0 | int floatx80_lt(floatx80 a, floatx80 b, float_status *status)
{
flag aSign, bSign;
if ( ( ( extractFloatx80Exp( a ) == 0x7FFF )
&& (uint64_t) ( extractFloatx80Frac( a )<<1 ) )
|| ( ( extractFloatx80Exp( b ) == 0x7FFF )
&& (uint64_t) ( extractFloatx80Frac( b )<<1 ) )
) {
float_raise(float_flag_invalid, status);
return 0;
}
aSign = extractFloatx80Sign( a );
bSign = extractFloatx80Sign( b );
if ( aSign != bSign ) {
return
aSign
&& ( ( ( (uint16_t) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
!= 0 );
}
return
aSign ? lt128( b.high, b.low, a.high, a.low )
: lt128( a.high, a.low, b.high, b.low );
}
| 5,565 |
qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | 0 | int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event,
const char *tag)
{
while (bs && bs->drv && !bs->drv->bdrv_debug_breakpoint) {
bs = bs->file;
}
if (bs && bs->drv && bs->drv->bdrv_debug_breakpoint) {
return bs->drv->bdrv_debug_breakpoint(bs, event, tag);
}
return -ENOTSUP;
}
| 5,568 |
qemu | 831e8822530bb511a24329494f9121ad1f8b94ab | 0 | static target_ulong h_add_logical_lan_buffer(PowerPCCPU *cpu,
sPAPRMachineState *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong reg = args[0];
target_ulong buf = args[1];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
target_long ret;
DPRINTF("H_ADD_LOGICAL_LAN_BUFFER(0x" TARGET_FMT_lx
", 0x" TARGET_FMT_lx ")\n", reg, buf);
if (!sdev) {
hcall_dprintf("Bad device\n");
return H_PARAMETER;
}
if ((check_bd(dev, buf, 4) < 0)
|| (VLAN_BD_LEN(buf) < 16)) {
hcall_dprintf("Bad buffer enqueued\n");
return H_PARAMETER;
}
if (!dev->isopen) {
return H_RESOURCE;
}
ret = spapr_vlan_add_rxbuf_to_page(dev, buf);
if (ret) {
return ret;
}
dev->rx_bufs++;
qemu_flush_queued_packets(qemu_get_queue(dev->nic));
return H_SUCCESS;
}
| 5,569 |
qemu | ed396e2b2d256c1628de7c11841b509455a76c03 | 0 | static void openrisc_pic_cpu_handler(void *opaque, int irq, int level)
{
OpenRISCCPU *cpu = (OpenRISCCPU *)opaque;
CPUState *cs = CPU(cpu);
int i;
uint32_t irq_bit = 1 << irq;
if (irq > 31 || irq < 0) {
return;
}
if (level) {
cpu->env.picsr |= irq_bit;
} else {
cpu->env.picsr &= ~irq_bit;
}
for (i = 0; i < 32; i++) {
if ((cpu->env.picsr && (1 << i)) && (cpu->env.picmr && (1 << i))) {
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
} else {
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
cpu->env.picsr &= ~(1 << i);
}
}
}
| 5,571 |
Subsets and Splits