id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
|
---|---|---|---|---|
6,714 | static int do_pcie_aer_inject_error(Monitor *mon,
const QDict *qdict, QObject **ret_data)
{
const char *id = qdict_get_str(qdict, "id");
const char *error_name;
uint32_t error_status;
bool correctable;
PCIDevice *dev;
PCIEAERErr err;
int ret;
ret = pci_qdev_find_device(id, &dev);
if (ret < 0) {
monitor_printf(mon,
"id or pci device path is invalid or device not "
"found. %s\n", id);
return ret;
}
if (!pci_is_express(dev)) {
monitor_printf(mon, "the device doesn't support pci express. %s\n",
id);
return -ENOSYS;
}
error_name = qdict_get_str(qdict, "error_status");
if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) {
char *e = NULL;
error_status = strtoul(error_name, &e, 0);
correctable = qdict_get_try_bool(qdict, "correctable", false);
if (!e || *e != '\0') {
monitor_printf(mon, "invalid error status value. \"%s\"",
error_name);
return -EINVAL;
}
}
err.status = error_status;
err.source_id = pci_requester_id(dev);
err.flags = 0;
if (correctable) {
err.flags |= PCIE_AER_ERR_IS_CORRECTABLE;
}
if (qdict_get_try_bool(qdict, "advisory_non_fatal", false)) {
err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY;
}
if (qdict_haskey(qdict, "header0")) {
err.flags |= PCIE_AER_ERR_HEADER_VALID;
}
if (qdict_haskey(qdict, "prefix0")) {
err.flags |= PCIE_AER_ERR_TLP_PREFIX_PRESENT;
}
err.header[0] = qdict_get_try_int(qdict, "header0", 0);
err.header[1] = qdict_get_try_int(qdict, "header1", 0);
err.header[2] = qdict_get_try_int(qdict, "header2", 0);
err.header[3] = qdict_get_try_int(qdict, "header3", 0);
err.prefix[0] = qdict_get_try_int(qdict, "prefix0", 0);
err.prefix[1] = qdict_get_try_int(qdict, "prefix1", 0);
err.prefix[2] = qdict_get_try_int(qdict, "prefix2", 0);
err.prefix[3] = qdict_get_try_int(qdict, "prefix3", 0);
ret = pcie_aer_inject_error(dev, &err);
*ret_data = qobject_from_jsonf("{'id': %s, "
"'root_bus': %s, 'bus': %d, 'devfn': %d, "
"'ret': %d}",
id, pci_root_bus_path(dev),
pci_bus_num(dev->bus), dev->devfn,
ret);
assert(*ret_data);
return 0;
}
| true | qemu | 9edd5338a2404909ac8d373964021e6dbb8f5815 |
6,715 | static int bmp_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVFrame *p = data;
unsigned int fsize, hsize;
int width, height;
unsigned int depth;
BiCompression comp;
unsigned int ihsize;
int i, j, n, linesize, ret;
uint32_t rgb[3] = {0};
uint32_t alpha = 0;
uint8_t *ptr;
int dsize;
const uint8_t *buf0 = buf;
GetByteContext gb;
if (buf_size < 14) {
av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size);
return AVERROR_INVALIDDATA;
}
if (bytestream_get_byte(&buf) != 'B' ||
bytestream_get_byte(&buf) != 'M') {
av_log(avctx, AV_LOG_ERROR, "bad magic number\n");
return AVERROR_INVALIDDATA;
}
fsize = bytestream_get_le32(&buf);
if (buf_size < fsize) {
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %u), trying to decode anyway\n",
buf_size, fsize);
fsize = buf_size;
}
buf += 2; /* reserved1 */
buf += 2; /* reserved2 */
hsize = bytestream_get_le32(&buf); /* header size */
ihsize = bytestream_get_le32(&buf); /* more header size */
if (ihsize + 14LL > hsize) {
av_log(avctx, AV_LOG_ERROR, "invalid header size %u\n", hsize);
return AVERROR_INVALIDDATA;
}
/* sometimes file size is set to some headers size, set a real size in that case */
if (fsize == 14 || fsize == ihsize + 14)
fsize = buf_size - 2;
if (fsize <= hsize) {
av_log(avctx, AV_LOG_ERROR,
"Declared file size is less than header size (%u < %u)\n",
fsize, hsize);
return AVERROR_INVALIDDATA;
}
switch (ihsize) {
case 40: // windib
case 56: // windib v3
case 64: // OS/2 v2
case 108: // windib v4
case 124: // windib v5
width = bytestream_get_le32(&buf);
height = bytestream_get_le32(&buf);
break;
case 12: // OS/2 v1
width = bytestream_get_le16(&buf);
height = bytestream_get_le16(&buf);
break;
default:
avpriv_report_missing_feature(avctx, "Information header size %u",
ihsize);
return AVERROR_PATCHWELCOME;
}
/* planes */
if (bytestream_get_le16(&buf) != 1) {
av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n");
return AVERROR_INVALIDDATA;
}
depth = bytestream_get_le16(&buf);
if (ihsize >= 40)
comp = bytestream_get_le32(&buf);
else
comp = BMP_RGB;
if (comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 &&
comp != BMP_RLE8) {
av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp);
return AVERROR_INVALIDDATA;
}
if (comp == BMP_BITFIELDS) {
buf += 20;
rgb[0] = bytestream_get_le32(&buf);
rgb[1] = bytestream_get_le32(&buf);
rgb[2] = bytestream_get_le32(&buf);
if (ihsize > 40)
alpha = bytestream_get_le32(&buf);
}
avctx->width = width;
avctx->height = height > 0 ? height : -(unsigned)height;
avctx->pix_fmt = AV_PIX_FMT_NONE;
switch (depth) {
case 32:
if (comp == BMP_BITFIELDS) {
if (rgb[0] == 0xFF000000 && rgb[1] == 0x00FF0000 && rgb[2] == 0x0000FF00)
avctx->pix_fmt = alpha ? AV_PIX_FMT_ABGR : AV_PIX_FMT_0BGR;
else if (rgb[0] == 0x00FF0000 && rgb[1] == 0x0000FF00 && rgb[2] == 0x000000FF)
avctx->pix_fmt = alpha ? AV_PIX_FMT_BGRA : AV_PIX_FMT_BGR0;
else if (rgb[0] == 0x0000FF00 && rgb[1] == 0x00FF0000 && rgb[2] == 0xFF000000)
avctx->pix_fmt = alpha ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB;
else if (rgb[0] == 0x000000FF && rgb[1] == 0x0000FF00 && rgb[2] == 0x00FF0000)
avctx->pix_fmt = alpha ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB0;
else {
av_log(avctx, AV_LOG_ERROR, "Unknown bitfields "
"%0"PRIX32" %0"PRIX32" %0"PRIX32"\n", rgb[0], rgb[1], rgb[2]);
return AVERROR(EINVAL);
}
} else {
avctx->pix_fmt = AV_PIX_FMT_BGRA;
}
break;
case 24:
avctx->pix_fmt = AV_PIX_FMT_BGR24;
break;
case 16:
if (comp == BMP_RGB)
avctx->pix_fmt = AV_PIX_FMT_RGB555;
else if (comp == BMP_BITFIELDS) {
if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F)
avctx->pix_fmt = AV_PIX_FMT_RGB565;
else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F)
avctx->pix_fmt = AV_PIX_FMT_RGB555;
else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F)
avctx->pix_fmt = AV_PIX_FMT_RGB444;
else {
av_log(avctx, AV_LOG_ERROR,
"Unknown bitfields %0"PRIX32" %0"PRIX32" %0"PRIX32"\n",
rgb[0], rgb[1], rgb[2]);
return AVERROR(EINVAL);
}
}
break;
case 8:
if (hsize - ihsize - 14 > 0)
avctx->pix_fmt = AV_PIX_FMT_PAL8;
else
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
break;
case 1:
case 4:
if (hsize - ihsize - 14 > 0) {
avctx->pix_fmt = AV_PIX_FMT_PAL8;
} else {
av_log(avctx, AV_LOG_ERROR, "Unknown palette for %u-colour BMP\n",
1 << depth);
return AVERROR_INVALIDDATA;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "depth %u not supported\n", depth);
return AVERROR_INVALIDDATA;
}
if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");
return AVERROR_INVALIDDATA;
}
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
return ret;
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
buf = buf0 + hsize;
dsize = buf_size - hsize;
/* Line size in file multiple of 4 */
n = ((avctx->width * depth + 31) / 8) & ~3;
if (n * avctx->height > dsize && comp != BMP_RLE4 && comp != BMP_RLE8) {
n = (avctx->width * depth + 7) / 8;
if (n * avctx->height > dsize) {
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
dsize, n * avctx->height);
return AVERROR_INVALIDDATA;
}
av_log(avctx, AV_LOG_ERROR, "data size too small, assuming missing line alignment\n");
}
// RLE may skip decoding some picture areas, so blank picture before decoding
if (comp == BMP_RLE4 || comp == BMP_RLE8)
memset(p->data[0], 0, avctx->height * p->linesize[0]);
if (height > 0) {
ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
linesize = -p->linesize[0];
} else {
ptr = p->data[0];
linesize = p->linesize[0];
}
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
int colors = 1 << depth;
memset(p->data[1], 0, 1024);
if (ihsize >= 36) {
int t;
buf = buf0 + 46;
t = bytestream_get_le32(&buf);
if (t < 0 || t > (1 << depth)) {
av_log(avctx, AV_LOG_ERROR,
"Incorrect number of colors - %X for bitdepth %u\n",
t, depth);
} else if (t) {
colors = t;
}
} else {
colors = FFMIN(256, (hsize-ihsize-14) / 3);
}
buf = buf0 + 14 + ihsize; //palette location
// OS/2 bitmap, 3 bytes per palette entry
if ((hsize-ihsize-14) < (colors << 2)) {
if ((hsize-ihsize-14) < colors * 3) {
av_log(avctx, AV_LOG_ERROR, "palette doesn't fit in packet\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < colors; i++)
((uint32_t*)p->data[1])[i] = (0xFFU<<24) | bytestream_get_le24(&buf);
} else {
for (i = 0; i < colors; i++)
((uint32_t*)p->data[1])[i] = 0xFFU << 24 | bytestream_get_le32(&buf);
}
buf = buf0 + hsize;
}
if (comp == BMP_RLE4 || comp == BMP_RLE8) {
if (comp == BMP_RLE8 && height < 0) {
p->data[0] += p->linesize[0] * (avctx->height - 1);
p->linesize[0] = -p->linesize[0];
}
bytestream2_init(&gb, buf, dsize);
ff_msrle_decode(avctx, p, depth, &gb);
if (height < 0) {
p->data[0] += p->linesize[0] * (avctx->height - 1);
p->linesize[0] = -p->linesize[0];
}
} else {
switch (depth) {
case 1:
for (i = 0; i < avctx->height; i++) {
int j;
for (j = 0; j < n; j++) {
ptr[j*8+0] = buf[j] >> 7;
ptr[j*8+1] = (buf[j] >> 6) & 1;
ptr[j*8+2] = (buf[j] >> 5) & 1;
ptr[j*8+3] = (buf[j] >> 4) & 1;
ptr[j*8+4] = (buf[j] >> 3) & 1;
ptr[j*8+5] = (buf[j] >> 2) & 1;
ptr[j*8+6] = (buf[j] >> 1) & 1;
ptr[j*8+7] = buf[j] & 1;
}
buf += n;
ptr += linesize;
}
break;
case 8:
case 24:
case 32:
for (i = 0; i < avctx->height; i++) {
memcpy(ptr, buf, n);
buf += n;
ptr += linesize;
}
break;
case 4:
for (i = 0; i < avctx->height; i++) {
int j;
for (j = 0; j < n; j++) {
ptr[j*2+0] = (buf[j] >> 4) & 0xF;
ptr[j*2+1] = buf[j] & 0xF;
}
buf += n;
ptr += linesize;
}
break;
case 16:
for (i = 0; i < avctx->height; i++) {
const uint16_t *src = (const uint16_t *) buf;
uint16_t *dst = (uint16_t *) ptr;
for (j = 0; j < avctx->width; j++)
*dst++ = av_le2ne16(*src++);
buf += n;
ptr += linesize;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n");
return AVERROR_INVALIDDATA;
}
}
if (avctx->pix_fmt == AV_PIX_FMT_BGRA) {
for (i = 0; i < avctx->height; i++) {
int j;
uint8_t *ptr = p->data[0] + p->linesize[0]*i + 3;
for (j = 0; j < avctx->width; j++) {
if (ptr[4*j])
break;
}
if (j < avctx->width)
break;
}
if (i == avctx->height)
avctx->pix_fmt = p->format = AV_PIX_FMT_BGR0;
}
*got_frame = 1;
return buf_size;
}
| true | FFmpeg | 63b8d4146d78595638417e431ea390aaf01f560f |
6,716 | static QIOChannel *nbd_negotiate_handle_starttls(NBDClient *client,
uint32_t length)
{
QIOChannel *ioc;
QIOChannelTLS *tioc;
struct NBDTLSHandshakeData data = { 0 };
TRACE("Setting up TLS");
ioc = client->ioc;
if (length) {
if (nbd_negotiate_drop_sync(ioc, length) != length) {
return NULL;
}
nbd_negotiate_send_rep(ioc, NBD_REP_ERR_INVALID, NBD_OPT_STARTTLS);
return NULL;
}
nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, NBD_OPT_STARTTLS);
tioc = qio_channel_tls_new_server(ioc,
client->tlscreds,
client->tlsaclname,
NULL);
if (!tioc) {
return NULL;
}
TRACE("Starting TLS handshake");
data.loop = g_main_loop_new(g_main_context_default(), FALSE);
qio_channel_tls_handshake(tioc,
nbd_tls_handshake,
&data,
NULL);
if (!data.complete) {
g_main_loop_run(data.loop);
}
g_main_loop_unref(data.loop);
if (data.error) {
object_unref(OBJECT(tioc));
error_free(data.error);
return NULL;
}
return QIO_CHANNEL(tioc);
}
| true | qemu | 63d5ef869e5e57de4875cd64b6f197cbb5763adf |
6,717 | static int shorten_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ShortenContext *s = avctx->priv_data;
int i, input_buf_size = 0;
int16_t *samples = data;
if(s->max_framesize == 0){
s->max_framesize= 1024; // should hopefully be enough for the first header
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
}
if(1 && s->max_framesize){//FIXME truncated
buf_size= FFMIN(buf_size, s->max_framesize - s->bitstream_size);
input_buf_size= buf_size;
if(s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size){
// printf("memmove\n");
memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
s->bitstream_index=0;
}
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size);
buf= &s->bitstream[s->bitstream_index];
buf_size += s->bitstream_size;
s->bitstream_size= buf_size;
if(buf_size < s->max_framesize){
*data_size = 0;
return input_buf_size;
}
}
init_get_bits(&s->gb, buf, buf_size*8);
skip_bits(&s->gb, s->bitindex);
if (!s->blocksize)
{
int ret;
if ((ret = read_header(s)) < 0)
return ret;
*data_size = 0;
}
else
{
int cmd;
int len;
cmd = get_ur_golomb_shorten(&s->gb, FNSIZE);
if (cmd > FN_VERBATIM) {
av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd);
if (s->bitstream_size > 0) {
s->bitstream_index++;
s->bitstream_size--;
}
return -1;
}
if (!is_audio_command[cmd]) {
/* process non-audio command */
switch (cmd) {
case FN_VERBATIM:
len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);
while (len--) {
get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);
}
break;
case FN_BITSHIFT:
s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
break;
case FN_BLOCKSIZE: {
int blocksize = get_uint(s, av_log2(s->blocksize));
if (blocksize > s->blocksize) {
av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n");
return AVERROR_PATCHWELCOME;
}
s->blocksize = blocksize;
break;
}
case FN_QUIT:
break;
}
*data_size = 0;
} else {
/* process audio command */
int ret;
int residual_size = 0;
int channel = s->cur_chan;
int32_t coffset;
if (cmd != FN_ZERO) {
residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE);
/* this is a hack as version 0 differed in defintion of get_sr_golomb_shorten */
if (s->version == 0)
residual_size--;
}
if (s->nmean == 0)
coffset = s->offset[channel][0];
else {
int32_t sum = (s->version < 2) ? 0 : s->nmean / 2;
for (i=0; i<s->nmean; i++)
sum += s->offset[channel][i];
coffset = sum / s->nmean;
if (s->version >= 2)
coffset >>= FFMIN(1, s->bitshift);
}
switch (cmd) {
case FN_ZERO:
for (i=0; i<s->blocksize; i++)
s->decoded[channel][i] = 0;
break;
case FN_DIFF0:
for (i=0; i<s->blocksize; i++)
s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + coffset;
break;
case FN_DIFF1:
for (i=0; i<s->blocksize; i++)
s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + s->decoded[channel][i - 1];
break;
case FN_DIFF2:
for (i=0; i<s->blocksize; i++)
s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + 2*s->decoded[channel][i-1]
- s->decoded[channel][i-2];
break;
case FN_DIFF3:
for (i=0; i<s->blocksize; i++)
s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + 3*s->decoded[channel][i-1]
- 3*s->decoded[channel][i-2]
+ s->decoded[channel][i-3];
break;
case FN_QLPC:
if ((ret = decode_subframe_lpc(s, channel, residual_size, coffset)) < 0)
return ret;
break;
}
if (s->nmean > 0) {
int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2;
for (i=0; i<s->blocksize; i++)
sum += s->decoded[channel][i];
for (i=1; i<s->nmean; i++)
s->offset[channel][i-1] = s->offset[channel][i];
if (s->version < 2)
s->offset[channel][s->nmean - 1] = sum / s->blocksize;
else
s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift;
}
for (i=-s->nwrap; i<0; i++)
s->decoded[channel][i] = s->decoded[channel][i + s->blocksize];
fix_bitshift(s, s->decoded[channel]);
s->cur_chan++;
if (s->cur_chan == s->channels) {
samples = interleave_buffer(samples, s->channels, s->blocksize, s->decoded);
s->cur_chan = 0;
*data_size = (int8_t *)samples - (int8_t *)data;
} else {
*data_size = 0;
}
}
}
// s->last_blocksize = s->blocksize;
s->bitindex = get_bits_count(&s->gb) - 8*((get_bits_count(&s->gb))/8);
i= (get_bits_count(&s->gb))/8;
if (i > buf_size) {
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
s->bitstream_size=0;
s->bitstream_index=0;
return -1;
}
if (s->bitstream_size) {
s->bitstream_index += i;
s->bitstream_size -= i;
return input_buf_size;
} else
return i;
}
| true | FFmpeg | 9e5e2c2d010c05c10337e9c1ec9d0d61495e0c9c |
6,718 | static int mm_decode_pal(MmContext *s)
{
int i;
bytestream2_skip(&s->gb, 4);
for (i = 0; i < 128; i++) {
s->palette[i] = 0xFF << 24 | bytestream2_get_be24(&s->gb);
s->palette[i+128] = s->palette[i]<<2;
}
return 0;
}
| true | FFmpeg | b12d92efd6c0d48665383a9baecc13e7ebbd8a22 |
6,719 | static int img_snapshot(int argc, char **argv)
{
BlockDriverState *bs;
QEMUSnapshotInfo sn;
char *filename, *snapshot_name = NULL;
int c, ret = 0, bdrv_oflags;
int action = 0;
qemu_timeval tv;
bool quiet = false;
bdrv_oflags = BDRV_O_FLAGS | BDRV_O_RDWR;
/* Parse commandline parameters */
for(;;) {
c = getopt(argc, argv, "la:c:d:hq");
if (c == -1) {
break;
}
switch(c) {
case '?':
case 'h':
help();
return 0;
case 'l':
if (action) {
help();
return 0;
}
action = SNAPSHOT_LIST;
bdrv_oflags &= ~BDRV_O_RDWR; /* no need for RW */
break;
case 'a':
if (action) {
help();
return 0;
}
action = SNAPSHOT_APPLY;
snapshot_name = optarg;
break;
case 'c':
if (action) {
help();
return 0;
}
action = SNAPSHOT_CREATE;
snapshot_name = optarg;
break;
case 'd':
if (action) {
help();
return 0;
}
action = SNAPSHOT_DELETE;
snapshot_name = optarg;
break;
case 'q':
quiet = true;
break;
}
}
if (optind != argc - 1) {
help();
}
filename = argv[optind++];
/* Open the image */
bs = bdrv_new_open(filename, NULL, bdrv_oflags, true, quiet);
if (!bs) {
return 1;
}
/* Perform the requested action */
switch(action) {
case SNAPSHOT_LIST:
dump_snapshots(bs);
break;
case SNAPSHOT_CREATE:
memset(&sn, 0, sizeof(sn));
pstrcpy(sn.name, sizeof(sn.name), snapshot_name);
qemu_gettimeofday(&tv);
sn.date_sec = tv.tv_sec;
sn.date_nsec = tv.tv_usec * 1000;
ret = bdrv_snapshot_create(bs, &sn);
if (ret) {
error_report("Could not create snapshot '%s': %d (%s)",
snapshot_name, ret, strerror(-ret));
}
break;
case SNAPSHOT_APPLY:
ret = bdrv_snapshot_goto(bs, snapshot_name);
if (ret) {
error_report("Could not apply snapshot '%s': %d (%s)",
snapshot_name, ret, strerror(-ret));
}
break;
case SNAPSHOT_DELETE:
ret = bdrv_snapshot_delete(bs, snapshot_name);
if (ret) {
error_report("Could not delete snapshot '%s': %d (%s)",
snapshot_name, ret, strerror(-ret));
}
break;
}
/* Cleanup */
bdrv_unref(bs);
if (ret) {
return 1;
}
return 0;
}
| true | qemu | a89d89d3e65800fa4a8e00de7af0ea8272bef779 |
6,720 | static void FUNCC(pred16x16_horizontal_add)(uint8_t *pix,
const int *block_offset,
const int16_t *block,
ptrdiff_t stride)
{
int i;
for(i=0; i<16; i++)
FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
}
| false | FFmpeg | 1acd7d594c15aa491729c837ad3519d3469e620a |
6,721 | static void release_unused_pictures(H264Context *h, int remove_current)
{
int i;
/* release non reference frames */
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (h->DPB[i].f.data[0] && !h->DPB[i].reference &&
(remove_current || &h->DPB[i] != h->cur_pic_ptr)) {
unref_picture(h, &h->DPB[i]);
}
}
}
| false | FFmpeg | a553c6a347d3d28d7ee44c3df3d5c4ee780dba23 |
6,722 | static av_noinline void emulated_edge_mc_sse(uint8_t * buf,const uint8_t *src,
ptrdiff_t buf_stride,
ptrdiff_t src_stride,
int block_w, int block_h,
int src_x, int src_y, int w, int h)
{
emulated_edge_mc(buf, src, buf_stride, src_stride, block_w, block_h,
src_x, src_y, w, h, vfixtbl_sse, &ff_emu_edge_vvar_sse,
hfixtbl_sse, &ff_emu_edge_hvar_sse);
}
| true | FFmpeg | 51daafb02eaf96e0743a37ce95a7f5d02c1fa3c2 |
6,723 | static inline int lock_hpte(void *hpte, target_ulong bits)
{
uint64_t pteh;
pteh = ldq_p(hpte);
/* We're protected by qemu's global lock here */
if (pteh & bits) {
return 0;
}
stq_p(hpte, pteh | HPTE_V_HVLOCK);
return 1;
}
| true | qemu | 35f9304d925a5423c51bd2c83a81fa3cc2b6e680 |
6,724 | static void iothread_set_poll_max_ns(Object *obj, Visitor *v,
const char *name, void *opaque, Error **errp)
{
IOThread *iothread = IOTHREAD(obj);
Error *local_err = NULL;
int64_t value;
visit_type_int64(v, name, &value, &local_err);
if (local_err) {
goto out;
}
if (value < 0) {
error_setg(&local_err, "poll_max_ns value must be in range "
"[0, %"PRId64"]", INT64_MAX);
goto out;
}
iothread->poll_max_ns = value;
if (iothread->ctx) {
aio_context_set_poll_params(iothread->ctx, value, &local_err);
}
out:
error_propagate(errp, local_err);
}
| true | qemu | 82a41186941c419afde977f477f19c545b40c1c5 |
6,725 | int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
{
CPUState *cpu = ENV_GET_CPU(env);
TaskState *ts = cpu->opaque;
struct emulated_sigtable *k;
struct sigqueue *q, **pq;
abi_ulong handler;
int queue;
trace_user_queue_signal(env, sig);
k = &ts->sigtab[sig - 1];
queue = gdb_queuesig ();
handler = sigact_table[sig - 1]._sa_handler;
if (ts->sigsegv_blocked && sig == TARGET_SIGSEGV) {
/* Guest has blocked SIGSEGV but we got one anyway. Assume this
* is a forced SIGSEGV (ie one the kernel handles via force_sig_info
* because it got a real MMU fault). A blocked SIGSEGV in that
* situation is treated as if using the default handler. This is
* not correct if some other process has randomly sent us a SIGSEGV
* via kill(), but that is not easy to distinguish at this point,
* so we assume it doesn't happen.
*/
handler = TARGET_SIG_DFL;
}
if (!queue && handler == TARGET_SIG_DFL) {
if (sig == TARGET_SIGTSTP || sig == TARGET_SIGTTIN || sig == TARGET_SIGTTOU) {
kill(getpid(),SIGSTOP);
return 0;
} else
/* default handler : ignore some signal. The other are fatal */
if (sig != TARGET_SIGCHLD &&
sig != TARGET_SIGURG &&
sig != TARGET_SIGWINCH &&
sig != TARGET_SIGCONT) {
force_sig(sig);
} else {
return 0; /* indicate ignored */
}
} else if (!queue && handler == TARGET_SIG_IGN) {
/* ignore signal */
return 0;
} else if (!queue && handler == TARGET_SIG_ERR) {
force_sig(sig);
} else {
pq = &k->first;
if (sig < TARGET_SIGRTMIN) {
/* if non real time signal, we queue exactly one signal */
if (!k->pending)
q = &k->info;
else
return 0;
} else {
if (!k->pending) {
/* first signal */
q = &k->info;
} else {
q = alloc_sigqueue(env);
if (!q)
return -EAGAIN;
while (*pq != NULL)
pq = &(*pq)->next;
}
}
*pq = q;
q->info = *info;
q->next = NULL;
k->pending = 1;
/* signal that a new signal is pending */
ts->signal_pending = 1;
return 1; /* indicates that the signal was queued */
}
}
| true | qemu | 3d3efba020da1de57a715e2087cf761ed0ad0904 |
6,726 | static void dss_sp_shift_sq_sub(const int32_t *filter_buf,
int32_t *error_buf, int32_t *dst)
{
int a;
for (a = 0; a < 72; a++) {
int i, tmp;
tmp = dst[a] * filter_buf[0];
for (i = 14; i > 0; i--)
tmp -= error_buf[i] * (unsigned)filter_buf[i];
for (i = 14; i > 0; i--)
error_buf[i] = error_buf[i - 1];
tmp = (tmp + 4096) >> 13;
error_buf[1] = tmp;
dst[a] = av_clip_int16(tmp);
}
}
| true | FFmpeg | 6ea428789371fa0601e9ebb5b7f2216d4e73e831 |
6,728 | static void gem_transmit(CadenceGEMState *s)
{
unsigned desc[2];
hwaddr packet_desc_addr;
uint8_t tx_packet[2048];
uint8_t *p;
unsigned total_bytes;
/* Do nothing if transmit is not enabled. */
if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) {
return;
DB_PRINT("\n");
/* The packet we will hand off to QEMU.
* Packets scattered across multiple descriptors are gathered to this
* one contiguous buffer first.
*/
p = tx_packet;
total_bytes = 0;
/* read current descriptor */
packet_desc_addr = s->tx_desc_addr;
DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr);
cpu_physical_memory_read(packet_desc_addr,
(uint8_t *)desc, sizeof(desc));
/* Handle all descriptors owned by hardware */
while (tx_desc_get_used(desc) == 0) {
/* Do nothing if transmit is not enabled. */
if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) {
return;
print_gem_tx_desc(desc);
/* The real hardware would eat this (and possibly crash).
* For QEMU let's lend a helping hand.
*/
if ((tx_desc_get_buffer(desc) == 0) ||
(tx_desc_get_length(desc) == 0)) {
DB_PRINT("Invalid TX descriptor @ 0x%x\n",
(unsigned)packet_desc_addr);
/* Gather this fragment of the packet from "dma memory" to our contig.
* buffer.
*/
cpu_physical_memory_read(tx_desc_get_buffer(desc), p,
tx_desc_get_length(desc));
p += tx_desc_get_length(desc);
total_bytes += tx_desc_get_length(desc);
/* Last descriptor for this packet; hand the whole thing off */
if (tx_desc_get_last(desc)) {
unsigned desc_first[2];
/* Modify the 1st descriptor of this packet to be owned by
* the processor.
*/
cpu_physical_memory_read(s->tx_desc_addr, (uint8_t *)desc_first,
sizeof(desc_first));
tx_desc_set_used(desc_first);
cpu_physical_memory_write(s->tx_desc_addr, (uint8_t *)desc_first,
sizeof(desc_first));
/* Advance the hardware current descriptor past this packet */
if (tx_desc_get_wrap(desc)) {
s->tx_desc_addr = s->regs[GEM_TXQBASE];
} else {
s->tx_desc_addr = packet_desc_addr + 8;
DB_PRINT("TX descriptor next: 0x%08x\n", s->tx_desc_addr);
s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_TXCMPL;
s->regs[GEM_ISR] |= GEM_INT_TXCMPL & ~(s->regs[GEM_IMR]);
/* Handle interrupt consequences */
gem_update_int_status(s);
/* Is checksum offload enabled? */
if (s->regs[GEM_DMACFG] & GEM_DMACFG_TXCSUM_OFFL) {
net_checksum_calculate(tx_packet, total_bytes);
/* Update MAC statistics */
gem_transmit_updatestats(s, tx_packet, total_bytes);
/* Send the packet somewhere */
if (s->phy_loop || (s->regs[GEM_NWCTRL] & GEM_NWCTRL_LOCALLOOP)) {
gem_receive(qemu_get_queue(s->nic), tx_packet, total_bytes);
} else {
qemu_send_packet(qemu_get_queue(s->nic), tx_packet,
total_bytes);
/* Prepare for next packet */
p = tx_packet;
total_bytes = 0;
/* read next descriptor */
if (tx_desc_get_wrap(desc)) {
packet_desc_addr = s->regs[GEM_TXQBASE];
} else {
packet_desc_addr += 8;
DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr);
cpu_physical_memory_read(packet_desc_addr,
(uint8_t *)desc, sizeof(desc));
if (tx_desc_get_used(desc)) {
s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_USED;
s->regs[GEM_ISR] |= GEM_INT_TXUSED & ~(s->regs[GEM_IMR]);
gem_update_int_status(s); | true | qemu | d7f053652fef48bee7c461c162c8d4d2c96ab157 |
6,729 | int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
{
AVPacketList **next_point, *this_pktl;
AVStream *st = s->streams[pkt->stream_index];
int chunked = s->max_chunk_size || s->max_chunk_duration;
this_pktl = av_mallocz(sizeof(AVPacketList));
if (!this_pktl)
return AVERROR(ENOMEM);
this_pktl->pkt = *pkt;
pkt->destruct = NULL; // do not free original but only the copy
av_dup_packet(&this_pktl->pkt); // duplicate the packet if it uses non-allocated memory
if (s->streams[pkt->stream_index]->last_in_packet_buffer) {
next_point = &(st->last_in_packet_buffer->next);
} else {
next_point = &s->packet_buffer;
}
if (chunked) {
uint64_t max= av_rescale_q_rnd(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base, AV_ROUND_UP);
st->interleaver_chunk_size += pkt->size;
st->interleaver_chunk_duration += pkt->duration;
if ( st->interleaver_chunk_size > s->max_chunk_size-1U
|| st->interleaver_chunk_duration > max-1U) {
st->interleaver_chunk_size =
st->interleaver_chunk_duration = 0;
this_pktl->pkt.flags |= CHUNK_START;
}
}
if (*next_point) {
if (chunked && !(this_pktl->pkt.flags & CHUNK_START))
goto next_non_null;
if (compare(s, &s->packet_buffer_end->pkt, pkt)) {
while ( *next_point
&& ((chunked && !((*next_point)->pkt.flags&CHUNK_START))
|| !compare(s, &(*next_point)->pkt, pkt)))
next_point = &(*next_point)->next;
if (*next_point)
goto next_non_null;
} else {
next_point = &(s->packet_buffer_end->next);
}
}
av_assert1(!*next_point);
s->packet_buffer_end = this_pktl;
next_non_null:
this_pktl->next = *next_point;
s->streams[pkt->stream_index]->last_in_packet_buffer =
*next_point = this_pktl;
return 0;
}
| false | FFmpeg | 69a96f9d4cf6d5a7f5b568c713b48d78452838fd |
6,730 | static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct,
float *out, float X[2][38][64],
float mdct_buf[2][64],
float *v0, int *v_off, const unsigned int div)
{
int i, n;
const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us;
const int step = 128 >> div;
float *v;
for (i = 0; i < 32; i++) {
if (*v_off < step) {
int saved_samples = (1280 - 128) >> div;
memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(float));
*v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - step;
} else {
*v_off -= step;
}
v = v0 + *v_off;
if (div) {
for (n = 0; n < 32; n++) {
X[0][i][ n] = -X[0][i][n];
X[0][i][32+n] = X[1][i][31-n];
}
mdct->imdct_half(mdct, mdct_buf[0], X[0][i]);
for (n = 0; n < 32; n++) {
v[ n] = mdct_buf[0][63 - 2*n];
v[63 - n] = -mdct_buf[0][62 - 2*n];
}
} else {
for (n = 1; n < 64; n+=2) {
X[1][i][n] = -X[1][i][n];
}
mdct->imdct_half(mdct, mdct_buf[0], X[0][i]);
mdct->imdct_half(mdct, mdct_buf[1], X[1][i]);
for (n = 0; n < 64; n++) {
v[ n] = -mdct_buf[0][63 - n] + mdct_buf[1][ n ];
v[127 - n] = mdct_buf[0][63 - n] + mdct_buf[1][ n ];
}
}
dsp->vector_fmul_add(out, v , sbr_qmf_window , zero64, 64 >> div);
dsp->vector_fmul_add(out, v + ( 192 >> div), sbr_qmf_window + ( 64 >> div), out , 64 >> div);
dsp->vector_fmul_add(out, v + ( 256 >> div), sbr_qmf_window + (128 >> div), out , 64 >> div);
dsp->vector_fmul_add(out, v + ( 448 >> div), sbr_qmf_window + (192 >> div), out , 64 >> div);
dsp->vector_fmul_add(out, v + ( 512 >> div), sbr_qmf_window + (256 >> div), out , 64 >> div);
dsp->vector_fmul_add(out, v + ( 704 >> div), sbr_qmf_window + (320 >> div), out , 64 >> div);
dsp->vector_fmul_add(out, v + ( 768 >> div), sbr_qmf_window + (384 >> div), out , 64 >> div);
dsp->vector_fmul_add(out, v + ( 960 >> div), sbr_qmf_window + (448 >> div), out , 64 >> div);
dsp->vector_fmul_add(out, v + (1024 >> div), sbr_qmf_window + (512 >> div), out , 64 >> div);
dsp->vector_fmul_add(out, v + (1216 >> div), sbr_qmf_window + (576 >> div), out , 64 >> div);
out += 64 >> div;
}
}
| false | FFmpeg | aac46e088d67a390489af686b846dea4987d8ffb |
6,731 | static int qdm2_decode(QDM2Context *q, const uint8_t *in, int16_t *out)
{
int ch, i;
const int frame_size = (q->frame_size * q->channels);
/* select input buffer */
q->compressed_data = in;
q->compressed_size = q->checksum_size;
/* copy old block, clear new block of output samples */
memmove(q->output_buffer, &q->output_buffer[frame_size], frame_size * sizeof(float));
memset(&q->output_buffer[frame_size], 0, frame_size * sizeof(float));
/* decode block of QDM2 compressed data */
if (q->sub_packet == 0) {
q->has_errors = 0; // zero it for a new super block
av_log(NULL,AV_LOG_DEBUG,"Superblock follows\n");
qdm2_decode_super_block(q);
}
/* parse subpackets */
if (!q->has_errors) {
if (q->sub_packet == 2)
qdm2_decode_fft_packets(q);
qdm2_fft_tone_synthesizer(q, q->sub_packet);
}
/* sound synthesis stage 1 (FFT) */
for (ch = 0; ch < q->channels; ch++) {
qdm2_calculate_fft(q, ch, q->sub_packet);
if (!q->has_errors && q->sub_packet_list_C[0].packet != NULL) {
SAMPLES_NEEDED_2("has errors, and C list is not empty")
return -1;
}
}
/* sound synthesis stage 2 (MPEG audio like synthesis filter) */
if (!q->has_errors && q->do_synth_filter)
qdm2_synthesis_filter(q, q->sub_packet);
q->sub_packet = (q->sub_packet + 1) % 16;
/* clip and convert output float[] to 16bit signed samples */
for (i = 0; i < frame_size; i++) {
int value = (int)q->output_buffer[i];
if (value > SOFTCLIP_THRESHOLD)
value = (value > HARDCLIP_THRESHOLD) ? 32767 : softclip_table[ value - SOFTCLIP_THRESHOLD];
else if (value < -SOFTCLIP_THRESHOLD)
value = (value < -HARDCLIP_THRESHOLD) ? -32767 : -softclip_table[-value - SOFTCLIP_THRESHOLD];
out[i] = value;
}
return 0;
}
| false | FFmpeg | 4b1f5e5090abed6c618c8ba380cd7d28d140f867 |
6,732 | int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
{
ByteIOContext pb;
uint8_t *buf;
int len;
int rtcp_bytes;
if (!s->rtp_ctx || (count < 1))
return -1;
/* XXX: mpeg pts hardcoded. RTCP send every 0.5 seconds */
s->octet_count += count;
rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
RTCP_TX_RATIO_DEN;
rtcp_bytes /= 50; // mmu_man: that's enough for me... VLC sends much less btw !?
if (rtcp_bytes < 28)
return -1;
s->last_octet_count = s->octet_count;
if (url_open_dyn_buf(&pb) < 0)
return -1;
// Receiver Report
put_byte(&pb, (RTP_VERSION << 6) + 1); /* 1 report block */
put_byte(&pb, 201);
put_be16(&pb, 7); /* length in words - 1 */
put_be32(&pb, s->ssrc); // our own SSRC
put_be32(&pb, s->ssrc); // XXX: should be the server's here!
// some placeholders we should really fill...
put_be32(&pb, ((0 << 24) | (0 & 0x0ffffff))); /* 0% lost, total 0 lost */
put_be32(&pb, (0 << 16) | s->seq);
put_be32(&pb, 0x68); /* jitter */
put_be32(&pb, -1); /* last SR timestamp */
put_be32(&pb, 1); /* delay since last SR */
// CNAME
put_byte(&pb, (RTP_VERSION << 6) + 1); /* 1 report block */
put_byte(&pb, 202);
len = strlen(s->hostname);
put_be16(&pb, (6 + len + 3) / 4); /* length in words - 1 */
put_be32(&pb, s->ssrc);
put_byte(&pb, 0x01);
put_byte(&pb, len);
put_buffer(&pb, s->hostname, len);
// padding
for (len = (6 + len) % 4; len % 4; len++) {
put_byte(&pb, 0);
}
put_flush_packet(&pb);
len = url_close_dyn_buf(&pb, &buf);
if ((len > 0) && buf) {
#if defined(DEBUG)
printf("sending %d bytes of RR\n", len);
#endif
url_write(s->rtp_ctx, buf, len);
av_free(buf);
}
return 0;
}
| false | FFmpeg | 4a6cc06123d969fe3214ff874bc87c1aec529143 |
6,733 | int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
int ret;
int slice_ret = 0;
AVFrame *pict = data;
s->flags = avctx->flags;
s->flags2 = avctx->flags2;
/* no supplementary picture */
if (buf_size == 0) {
/* special case for last picture */
if (s->low_delay == 0 && s->next_picture_ptr) {
if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
return ret;
s->next_picture_ptr = NULL;
*got_frame = 1;
}
return 0;
}
if (s->flags & CODEC_FLAG_TRUNCATED) {
int next;
if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4) {
next = ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size);
} else if (CONFIG_H263_DECODER && s->codec_id == AV_CODEC_ID_H263) {
next = ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
} else if (CONFIG_H263P_DECODER && s->codec_id == AV_CODEC_ID_H263P) {
next = ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
} else {
av_log(s->avctx, AV_LOG_ERROR,
"this codec does not support truncated bitstreams\n");
return AVERROR(ENOSYS);
}
if (ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf,
&buf_size) < 0)
return buf_size;
}
retry:
if (s->divx_packed && s->bitstream_buffer_size) {
int i;
for(i=0; i < buf_size-3; i++) {
if (buf[i]==0 && buf[i+1]==0 && buf[i+2]==1) {
if (buf[i+3]==0xB0) {
av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n");
s->bitstream_buffer_size = 0;
}
break;
}
}
}
if (s->bitstream_buffer_size && (s->divx_packed || buf_size < 20)) // divx 5.01+/xvid frame reorder
ret = init_get_bits8(&s->gb, s->bitstream_buffer,
s->bitstream_buffer_size);
else
ret = init_get_bits8(&s->gb, buf, buf_size);
s->bitstream_buffer_size = 0;
if (ret < 0)
return ret;
if (!s->context_initialized)
// we need the idct permutaton for reading a custom matrix
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
/* We need to set current_picture_ptr before reading the header,
* otherwise we cannot store anyting in there */
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
int i = ff_find_unused_picture(s, 0);
if (i < 0)
return i;
s->current_picture_ptr = &s->picture[i];
}
/* let's go :-) */
if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) {
ret = ff_wmv2_decode_picture_header(s);
} else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) {
ret = ff_msmpeg4_decode_picture_header(s);
} else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
if (s->avctx->extradata_size && s->picture_number == 0) {
GetBitContext gb;
if (init_get_bits8(&gb, s->avctx->extradata, s->avctx->extradata_size) >= 0 )
ff_mpeg4_decode_picture_header(avctx->priv_data, &gb);
}
ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb);
} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
ret = ff_intel_h263_decode_picture_header(s);
} else if (CONFIG_FLV_DECODER && s->h263_flv) {
ret = ff_flv_decode_picture_header(s);
} else {
ret = ff_h263_decode_picture_header(s);
}
if (ret < 0 || ret == FRAME_SKIPPED) {
if ( s->width != avctx->coded_width
|| s->height != avctx->coded_height) {
av_log(s->avctx, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n");
s->width = avctx->coded_width;
s->height= avctx->coded_height;
}
}
if (ret == FRAME_SKIPPED)
return get_consumed_bytes(s, buf_size);
/* skip if the header was thrashed */
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
return ret;
}
avctx->has_b_frames = !s->low_delay;
if (ff_mpeg4_workaround_bugs(avctx) == 1)
goto retry;
/* After H263 & mpeg4 header decode we have the height, width,
* and other parameters. So then we could init the picture.
* FIXME: By the way H263 decoder is evolving it should have
* an H263EncContext */
if (s->width != avctx->coded_width ||
s->height != avctx->coded_height ||
s->context_reinit) {
/* H.263 could change picture size any time */
s->context_reinit = 0;
ret = ff_set_dimensions(avctx, s->width, s->height);
if (ret < 0)
return ret;
if ((ret = ff_MPV_common_frame_size_change(s)))
return ret;
}
if (s->codec_id == AV_CODEC_ID_H263 ||
s->codec_id == AV_CODEC_ID_H263P ||
s->codec_id == AV_CODEC_ID_H263I)
s->gob_index = ff_h263_get_gob_height(s);
// for skipping the frame
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
/* skip B-frames if we don't have reference frames */
if (s->last_picture_ptr == NULL &&
(s->pict_type == AV_PICTURE_TYPE_B || s->droppable))
return get_consumed_bytes(s, buf_size);
if ((avctx->skip_frame >= AVDISCARD_NONREF &&
s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY &&
s->pict_type != AV_PICTURE_TYPE_I) ||
avctx->skip_frame >= AVDISCARD_ALL)
return get_consumed_bytes(s, buf_size);
if (s->next_p_frame_damaged) {
if (s->pict_type == AV_PICTURE_TYPE_B)
return get_consumed_bytes(s, buf_size);
else
s->next_p_frame_damaged = 0;
}
if ((!s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
} else {
s->me.qpel_put = s->dsp.put_no_rnd_qpel_pixels_tab;
s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
}
if ((ret = ff_MPV_frame_start(s, avctx)) < 0)
return ret;
if (!s->divx_packed && !avctx->hwaccel)
ff_thread_finish_setup(avctx);
if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
goto frame_end;
}
if (avctx->hwaccel) {
ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer,
s->gb.buffer_end - s->gb.buffer);
if (ret < 0 )
return ret;
}
ff_mpeg_er_frame_start(s);
/* the second part of the wmv2 header contains the MB skip bits which
* are stored in current_picture->mb_type which is not available before
* ff_MPV_frame_start() */
if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) {
ret = ff_wmv2_decode_secondary_picture_header(s);
if (ret < 0)
return ret;
if (ret == 1)
goto frame_end;
}
/* decode each macroblock */
s->mb_x = 0;
s->mb_y = 0;
slice_ret = decode_slice(s);
while (s->mb_y < s->mb_height) {
if (s->msmpeg4_version) {
if (s->slice_height == 0 || s->mb_x != 0 ||
(s->mb_y % s->slice_height) != 0 || get_bits_left(&s->gb) < 0)
break;
} else {
int prev_x = s->mb_x, prev_y = s->mb_y;
if (ff_h263_resync(s) < 0)
break;
if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x)
s->er.error_occurred = 1;
}
if (s->msmpeg4_version < 4 && s->h263_pred)
ff_mpeg4_clean_buffers(s);
if (decode_slice(s) < 0)
slice_ret = AVERROR_INVALIDDATA;
}
if (s->msmpeg4_version && s->msmpeg4_version < 4 &&
s->pict_type == AV_PICTURE_TYPE_I)
if (!CONFIG_MSMPEG4_DECODER ||
ff_msmpeg4_decode_ext_header(s, buf_size) < 0)
s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR;
av_assert1(s->bitstream_buffer_size == 0);
frame_end:
ff_er_frame_end(&s->er);
if (avctx->hwaccel) {
ret = avctx->hwaccel->end_frame(avctx);
if (ret < 0)
return ret;
}
ff_MPV_frame_end(s);
/* divx 5.01+ bitstream reorder stuff */
/* Since this clobbers the input buffer and hwaccel codecs still need the
* data during hwaccel->end_frame we should not do this any earlier */
if (s->codec_id == AV_CODEC_ID_MPEG4 && s->divx_packed) {
int current_pos = s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3);
int startcode_found = 0;
if (buf_size - current_pos > 7) {
int i;
for (i = current_pos; i < buf_size - 4; i++)
if (buf[i] == 0 &&
buf[i + 1] == 0 &&
buf[i + 2] == 1 &&
buf[i + 3] == 0xB6) {
startcode_found = !(buf[i + 4] & 0x40);
break;
}
}
if (startcode_found) {
av_fast_malloc(&s->bitstream_buffer,
&s->allocated_bitstream_buffer_size,
buf_size - current_pos +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->bitstream_buffer)
return AVERROR(ENOMEM);
memcpy(s->bitstream_buffer, buf + current_pos,
buf_size - current_pos);
s->bitstream_buffer_size = buf_size - current_pos;
}
}
if (!s->divx_packed && avctx->hwaccel)
ff_thread_finish_setup(avctx);
av_assert1(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
av_assert1(s->current_picture.f.pict_type == s->pict_type);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
} else if (s->last_picture_ptr != NULL) {
if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);
}
if (s->last_picture_ptr || s->low_delay) {
if ( pict->format == AV_PIX_FMT_YUV420P
&& (s->codec_tag == AV_RL32("GEOV") || s->codec_tag == AV_RL32("GEOX"))) {
int x, y, p;
av_frame_make_writable(pict);
for (p=0; p<3; p++) {
int w = FF_CEIL_RSHIFT(pict-> width, !!p);
int h = FF_CEIL_RSHIFT(pict->height, !!p);
int linesize = pict->linesize[p];
for (y=0; y<(h>>1); y++)
for (x=0; x<w; x++)
FFSWAP(int,
pict->data[p][x + y*linesize],
pict->data[p][x + (h-1-y)*linesize]);
}
}
*got_frame = 1;
}
if (slice_ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
else
return get_consumed_bytes(s, buf_size);
}
| false | FFmpeg | b239f3f69d1c10a7d12354a9038c5b109661324e |
6,734 | static void decorrelate_stereo_24(int32_t *buffer[MAX_CHANNELS],
int32_t *buffer_out,
int32_t *wasted_bits_buffer[MAX_CHANNELS],
int wasted_bits,
int numchannels, int numsamples,
uint8_t interlacing_shift,
uint8_t interlacing_leftweight)
{
int i;
if (numsamples <= 0)
return;
/* weighted interlacing */
if (interlacing_leftweight) {
for (i = 0; i < numsamples; i++) {
int32_t a, b;
a = buffer[0][i];
b = buffer[1][i];
a -= (b * interlacing_leftweight) >> interlacing_shift;
b += a;
if (wasted_bits) {
b = (b << wasted_bits) | wasted_bits_buffer[0][i];
a = (a << wasted_bits) | wasted_bits_buffer[1][i];
}
buffer_out[i * numchannels] = b << 8;
buffer_out[i * numchannels + 1] = a << 8;
}
} else {
for (i = 0; i < numsamples; i++) {
int32_t left, right;
left = buffer[0][i];
right = buffer[1][i];
if (wasted_bits) {
left = (left << wasted_bits) | wasted_bits_buffer[0][i];
right = (right << wasted_bits) | wasted_bits_buffer[1][i];
}
buffer_out[i * numchannels] = left << 8;
buffer_out[i * numchannels + 1] = right << 8;
}
}
}
| false | FFmpeg | dbbb9262ca0fd09f2582b11157a74c88ab7e1db5 |
6,735 | static int xwma_read_header(AVFormatContext *s)
{
int64_t size;
int ret = 0;
uint32_t dpds_table_size = 0;
uint32_t *dpds_table = NULL;
unsigned int tag;
AVIOContext *pb = s->pb;
AVStream *st;
XWMAContext *xwma = s->priv_data;
int i;
/* The following code is mostly copied from wav.c, with some
* minor alterations.
*/
/* check RIFF header */
tag = avio_rl32(pb);
if (tag != MKTAG('R', 'I', 'F', 'F'))
return -1;
avio_rl32(pb); /* file size */
tag = avio_rl32(pb);
if (tag != MKTAG('X', 'W', 'M', 'A'))
return -1;
/* parse fmt header */
tag = avio_rl32(pb);
if (tag != MKTAG('f', 'm', 't', ' '))
return -1;
size = avio_rl32(pb);
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
ret = ff_get_wav_header(pb, st->codec, size, 0);
if (ret < 0)
return ret;
st->need_parsing = AVSTREAM_PARSE_NONE;
/* All xWMA files I have seen contained WMAv2 data. If there are files
* using WMA Pro or some other codec, then we need to figure out the right
* extradata for that. Thus, ask the user for feedback, but try to go on
* anyway.
*/
if (st->codec->codec_id != AV_CODEC_ID_WMAV2) {
avpriv_request_sample(s, "Unexpected codec (tag 0x04%x; id %d)",
st->codec->codec_tag, st->codec->codec_id);
} else {
/* In all xWMA files I have seen, there is no extradata. But the WMA
* codecs require extradata, so we provide our own fake extradata.
*
* First, check that there really was no extradata in the header. If
* there was, then try to use it, after asking the user to provide a
* sample of this unusual file.
*/
if (st->codec->extradata_size != 0) {
/* Surprise, surprise: We *did* get some extradata. No idea
* if it will work, but just go on and try it, after asking
* the user for a sample.
*/
avpriv_request_sample(s, "Unexpected extradata (%d bytes)",
st->codec->extradata_size);
} else {
st->codec->extradata_size = 6;
st->codec->extradata = av_mallocz(6 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
/* setup extradata with our experimentally obtained value */
st->codec->extradata[4] = 31;
}
}
if (!st->codec->channels) {
av_log(s, AV_LOG_WARNING, "Invalid channel count: %d\n",
st->codec->channels);
return AVERROR_INVALIDDATA;
}
if (!st->codec->bits_per_coded_sample) {
av_log(s, AV_LOG_WARNING, "Invalid bits_per_coded_sample: %d\n",
st->codec->bits_per_coded_sample);
return AVERROR_INVALIDDATA;
}
/* set the sample rate */
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
/* parse the remaining RIFF chunks */
for (;;) {
if (pb->eof_reached) {
ret = AVERROR_EOF;
goto fail;
}
/* read next chunk tag */
tag = avio_rl32(pb);
size = avio_rl32(pb);
if (tag == MKTAG('d', 'a', 't', 'a')) {
/* We assume that the data chunk comes last. */
break;
} else if (tag == MKTAG('d','p','d','s')) {
/* Quoting the MSDN xWMA docs on the dpds chunk: "Contains the
* decoded packet cumulative data size array, each element is the
* number of bytes accumulated after the corresponding xWMA packet
* is decoded in order."
*
* Each packet has size equal to st->codec->block_align, which in
* all cases I saw so far was always 2230. Thus, we can use the
* dpds data to compute a seeking index.
*/
/* Error out if there is more than one dpds chunk. */
if (dpds_table) {
av_log(s, AV_LOG_ERROR, "two dpds chunks present\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
/* Compute the number of entries in the dpds chunk. */
if (size & 3) { /* Size should be divisible by four */
av_log(s, AV_LOG_WARNING,
"dpds chunk size %"PRId64" not divisible by 4\n", size);
}
dpds_table_size = size / 4;
if (dpds_table_size == 0 || dpds_table_size >= INT_MAX / 4) {
av_log(s, AV_LOG_ERROR,
"dpds chunk size %"PRId64" invalid\n", size);
return AVERROR_INVALIDDATA;
}
/* Allocate some temporary storage to keep the dpds data around.
* for processing later on.
*/
dpds_table = av_malloc(dpds_table_size * sizeof(uint32_t));
if (!dpds_table) {
return AVERROR(ENOMEM);
}
for (i = 0; i < dpds_table_size; ++i) {
dpds_table[i] = avio_rl32(pb);
size -= 4;
}
}
avio_skip(pb, size);
}
/* Determine overall data length */
if (size < 0) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (!size) {
xwma->data_end = INT64_MAX;
} else
xwma->data_end = avio_tell(pb) + size;
if (dpds_table && dpds_table_size) {
int64_t cur_pos;
const uint32_t bytes_per_sample
= (st->codec->channels * st->codec->bits_per_coded_sample) >> 3;
/* Estimate the duration from the total number of output bytes. */
const uint64_t total_decoded_bytes = dpds_table[dpds_table_size - 1];
if (!bytes_per_sample) {
av_log(s, AV_LOG_ERROR,
"Invalid bits_per_coded_sample %d for %d channels\n",
st->codec->bits_per_coded_sample, st->codec->channels);
ret = AVERROR_INVALIDDATA;
goto fail;
}
st->duration = total_decoded_bytes / bytes_per_sample;
/* Use the dpds data to build a seek table. We can only do this after
* we know the offset to the data chunk, as we need that to determine
* the actual offset to each input block.
* Note: If we allowed ourselves to assume that the data chunk always
* follows immediately after the dpds block, we could of course guess
* the data block's start offset already while reading the dpds chunk.
* I decided against that, just in case other chunks ever are
* discovered.
*/
cur_pos = avio_tell(pb);
for (i = 0; i < dpds_table_size; ++i) {
/* From the number of output bytes that would accumulate in the
* output buffer after decoding the first (i+1) packets, we compute
* an offset / timestamp pair.
*/
av_add_index_entry(st,
cur_pos + (i+1) * st->codec->block_align, /* pos */
dpds_table[i] / bytes_per_sample, /* timestamp */
st->codec->block_align, /* size */
0, /* duration */
AVINDEX_KEYFRAME);
}
} else if (st->codec->bit_rate) {
/* No dpds chunk was present (or only an empty one), so estimate
* the total duration using the average bits per sample and the
* total data length.
*/
st->duration = (size<<3) * st->codec->sample_rate / st->codec->bit_rate;
}
fail:
av_free(dpds_table);
return ret;
}
| false | FFmpeg | b9fbd034bfd4b323d57bc2ac888301c93fcfd4ca |
6,736 | static void test_acpi_asl(test_data *data)
{
int i;
AcpiSdtTable *sdt, *exp_sdt;
test_data exp_data;
memset(&exp_data, 0, sizeof(exp_data));
exp_data.ssdt_tables = load_expected_aml(data);
dump_aml_files(data);
for (i = 0; i < data->ssdt_tables->len; ++i) {
GString *asl, *exp_asl;
sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
exp_sdt = &g_array_index(exp_data.ssdt_tables, AcpiSdtTable, i);
load_asl(data->ssdt_tables, sdt);
asl = normalize_asl(sdt->asl);
load_asl(exp_data.ssdt_tables, exp_sdt);
exp_asl = normalize_asl(exp_sdt->asl);
g_assert(!g_strcmp0(asl->str, exp_asl->str));
g_string_free(asl, true);
g_string_free(exp_asl, true);
}
free_test_data(&exp_data);
}
| false | qemu | 4500bc98a6aab1734d865afaeade3509eb65b560 |
6,737 | static void iscsi_nop_timed_event(void *opaque)
{
IscsiLun *iscsilun = opaque;
aio_context_acquire(iscsilun->aio_context);
if (iscsi_get_nops_in_flight(iscsilun->iscsi) >= MAX_NOP_FAILURES) {
error_report("iSCSI: NOP timeout. Reconnecting...");
iscsilun->request_timed_out = true;
} else if (iscsi_nop_out_async(iscsilun->iscsi, NULL, NULL, 0, NULL) != 0) {
error_report("iSCSI: failed to sent NOP-Out. Disabling NOP messages.");
goto out;
}
timer_mod(iscsilun->nop_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + NOP_INTERVAL);
iscsi_set_events(iscsilun);
out:
aio_context_release(iscsilun->aio_context);
}
| false | qemu | d045c466d9e62b4321fadf586d024d54ddfd8bd4 |
6,738 | static bool sys_ops_accepts(void *opaque, target_phys_addr_t addr,
unsigned size, bool is_write)
{
return is_write && size == 4;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c |
6,739 | static target_ulong h_set_mode_resouce_addr_trans_mode(PowerPCCPU *cpu,
target_ulong mflags,
target_ulong value1,
target_ulong value2)
{
CPUState *cs;
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
target_ulong prefix;
if (!(pcc->insns_flags2 & PPC2_ISA207S)) {
return H_P2;
}
if (value1) {
return H_P3;
}
if (value2) {
return H_P4;
}
switch (mflags) {
case H_SET_MODE_ADDR_TRANS_NONE:
prefix = 0;
break;
case H_SET_MODE_ADDR_TRANS_0001_8000:
prefix = 0x18000;
break;
case H_SET_MODE_ADDR_TRANS_C000_0000_0000_4000:
prefix = 0xC000000000004000;
break;
default:
return H_UNSUPPORTED_FLAG;
}
CPU_FOREACH(cs) {
CPUPPCState *env = &POWERPC_CPU(cpu)->env;
set_spr(cs, SPR_LPCR, mflags << LPCR_AIL_SHIFT, LPCR_AIL);
env->excp_prefix = prefix;
}
return H_SUCCESS;
}
| false | qemu | b653282eccd2b43fd8068b9d6de40a3ff9e801ec |
6,741 | static int v210_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int packet_size, ret, width, height;
AVStream *st = s->streams[0];
width = st->codec->width;
height = st->codec->height;
packet_size = GET_PACKET_SIZE(width, height);
if (packet_size < 0)
return -1;
ret = av_get_packet(s->pb, pkt, packet_size);
pkt->pts = pkt->dts = pkt->pos / packet_size;
pkt->stream_index = 0;
if (ret < 0)
return ret;
return 0;
}
| false | FFmpeg | 12a419dacb479d663f04e316f9997568ef326965 |
6,742 | void op_dmtc0_ebase (void)
{
/* vectored interrupts not implemented */
/* Multi-CPU not implemented */
/* XXX: 64bit addressing broken */
env->CP0_EBase = (int32_t)0x80000000 | (T0 & 0x3FFFF000);
RETURN();
}
| false | qemu | b29a0341d7ed7e7df4bf77a41db8e614f1ddb645 |
6,743 | static int vmdk_add_extent(BlockDriverState *bs,
BlockDriverState *file, bool flat, int64_t sectors,
int64_t l1_offset, int64_t l1_backup_offset,
uint32_t l1_size,
int l2_size, uint64_t cluster_sectors,
VmdkExtent **new_extent,
Error **errp)
{
VmdkExtent *extent;
BDRVVmdkState *s = bs->opaque;
if (cluster_sectors > 0x200000) {
/* 0x200000 * 512Bytes = 1GB for one cluster is unrealistic */
error_setg(errp, "Invalid granularity, image may be corrupt");
return -EFBIG;
}
if (l1_size > 512 * 1024 * 1024) {
/* Although with big capacity and small l1_entry_sectors, we can get a
* big l1_size, we don't want unbounded value to allocate the table.
* Limit it to 512M, which is 16PB for default cluster and L2 table
* size */
error_setg(errp, "L1 size too big");
return -EFBIG;
}
s->extents = g_realloc(s->extents,
(s->num_extents + 1) * sizeof(VmdkExtent));
extent = &s->extents[s->num_extents];
s->num_extents++;
memset(extent, 0, sizeof(VmdkExtent));
extent->file = file;
extent->flat = flat;
extent->sectors = sectors;
extent->l1_table_offset = l1_offset;
extent->l1_backup_table_offset = l1_backup_offset;
extent->l1_size = l1_size;
extent->l1_entry_sectors = l2_size * cluster_sectors;
extent->l2_size = l2_size;
extent->cluster_sectors = flat ? sectors : cluster_sectors;
if (!flat) {
bs->bl.write_zeroes_alignment =
MAX(bs->bl.write_zeroes_alignment, cluster_sectors);
}
if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
} else {
extent->end_sector = extent->sectors;
}
bs->total_sectors = extent->end_sector;
if (new_extent) {
*new_extent = extent;
}
return 0;
}
| false | qemu | d34682cd4a06efe9ee3fc8cb7e8a0ea445299989 |
6,744 | static inline void tlb_protect_code1(CPUTLBEntry *tlb_entry, uint32_t addr)
{
if (addr == (tlb_entry->address &
(TARGET_PAGE_MASK | TLB_INVALID_MASK)) &&
(tlb_entry->address & ~TARGET_PAGE_MASK) != IO_MEM_CODE) {
tlb_entry->address |= IO_MEM_CODE;
tlb_entry->addend -= (unsigned long)phys_ram_base;
}
}
| false | qemu | 988578886e0b9af507a7ef111f549c5dd47d93f3 |
6,745 | static void disas_system(DisasContext *s, uint32_t insn)
{
unsigned int l, op0, op1, crn, crm, op2, rt;
l = extract32(insn, 21, 1);
op0 = extract32(insn, 19, 2);
op1 = extract32(insn, 16, 3);
crn = extract32(insn, 12, 4);
crm = extract32(insn, 8, 4);
op2 = extract32(insn, 5, 3);
rt = extract32(insn, 0, 5);
if (op0 == 0) {
if (l || rt != 31) {
unallocated_encoding(s);
return;
}
switch (crn) {
case 2: /* C5.6.68 HINT */
handle_hint(s, insn, op1, op2, crm);
break;
case 3: /* CLREX, DSB, DMB, ISB */
handle_sync(s, insn, op1, op2, crm);
break;
case 4: /* C5.6.130 MSR (immediate) */
handle_msr_i(s, insn, op1, op2, crm);
break;
default:
unallocated_encoding(s);
break;
}
return;
}
if (op0 == 1) {
/* C5.6.204 SYS */
handle_sys(s, insn, l, op1, op2, crn, crm, rt);
} else if (l) { /* op0 > 1 */
/* C5.6.129 MRS - move from system register */
handle_mrs(s, insn, op0, op1, op2, crn, crm, rt);
} else {
/* C5.6.131 MSR (register) - move to system register */
handle_msr(s, insn, op0, op1, op2, crn, crm, rt);
}
}
| false | qemu | fea505221eaf87889000378d4d33ad0dfd5f4d9d |
6,746 | POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->fw_name = "PowerPC,POWER7+";
dc->desc = "POWER7+";
dc->props = powerpc_servercpu_properties;
pcc->pvr_match = ppc_pvr_match_power7;
pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;
pcc->init_proc = init_proc_POWER7;
pcc->check_pow = check_pow_nocheck;
pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
PPC_FLOAT_FRSQRTES |
PPC_FLOAT_STFIWX |
PPC_FLOAT_EXT |
PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
PPC_MEM_SYNC | PPC_MEM_EIEIO |
PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
PPC_64B | PPC_ALTIVEC |
PPC_SEGMENT_64B | PPC_SLBI |
PPC_POPCNTB | PPC_POPCNTWD;
pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 |
PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
PPC2_FP_TST_ISA206;
pcc->msr_mask = (1ull << MSR_SF) |
(1ull << MSR_VR) |
(1ull << MSR_VSX) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_SE) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PMM) |
(1ull << MSR_RI) |
(1ull << MSR_LE);
pcc->mmu_model = POWERPC_MMU_2_06;
#if defined(CONFIG_SOFTMMU)
pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;
#endif
pcc->excp_model = POWERPC_EXCP_POWER7;
pcc->bus_model = PPC_FLAGS_INPUT_POWER7;
pcc->bfd_mach = bfd_mach_ppc64;
pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |
POWERPC_FLAG_BE | POWERPC_FLAG_PMM |
POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |
POWERPC_FLAG_VSX;
pcc->l1_dcache_size = 0x8000;
pcc->l1_icache_size = 0x8000;
pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;
}
| false | qemu | b60c60070c0df4ef01d5c727929fe0e93e6fdd09 |
6,747 | static ssize_t mp_dacl_getxattr(FsContext *ctx, const char *path,
const char *name, void *value, size_t size)
{
char buffer[PATH_MAX];
return lgetxattr(rpath(ctx, path, buffer), MAP_ACL_DEFAULT, value, size);
}
| false | qemu | 4fa4ce7107c6ec432f185307158c5df91ce54308 |
6,749 | static void fdt_add_timer_nodes(const VirtBoardInfo *vbi)
{
/* Note that on A15 h/w these interrupts are level-triggered,
* but for the GIC implementation provided by both QEMU and KVM
* they are edge-triggered.
*/
uint32_t irqflags = GIC_FDT_IRQ_FLAGS_EDGE_LO_HI;
irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
GIC_FDT_IRQ_PPI_CPU_WIDTH, (1 << vbi->smp_cpus) - 1);
qemu_fdt_add_subnode(vbi->fdt, "/timer");
qemu_fdt_setprop_string(vbi->fdt, "/timer",
"compatible", "arm,armv7-timer");
qemu_fdt_setprop_cells(vbi->fdt, "/timer", "interrupts",
GIC_FDT_IRQ_TYPE_PPI, 13, irqflags,
GIC_FDT_IRQ_TYPE_PPI, 14, irqflags,
GIC_FDT_IRQ_TYPE_PPI, 11, irqflags,
GIC_FDT_IRQ_TYPE_PPI, 10, irqflags);
}
| false | qemu | b32a950910bc03f2c012794b3215fc2de8f90de3 |
6,750 | static void eeprom24c0x_write(int scl, int sda)
{
if (eeprom.scl && scl && (eeprom.sda != sda)) {
logout("%u: scl = %u->%u, sda = %u->%u i2c %s\n",
eeprom.tick, eeprom.scl, scl, eeprom.sda, sda, sda ? "stop" : "start");
if (!sda) {
eeprom.tick = 1;
eeprom.command = 0;
}
} else if (eeprom.tick == 0 && !eeprom.ack) {
/* Waiting for start. */
logout("%u: scl = %u->%u, sda = %u->%u wait for i2c start\n",
eeprom.tick, eeprom.scl, scl, eeprom.sda, sda);
} else if (!eeprom.scl && scl) {
logout("%u: scl = %u->%u, sda = %u->%u trigger bit\n",
eeprom.tick, eeprom.scl, scl, eeprom.sda, sda);
if (eeprom.ack) {
logout("\ti2c ack bit = 0\n");
sda = 0;
eeprom.ack = 0;
} else if (eeprom.sda == sda) {
uint8_t bit = (sda != 0);
logout("\ti2c bit = %d\n", bit);
if (eeprom.tick < 9) {
eeprom.command <<= 1;
eeprom.command += bit;
eeprom.tick++;
if (eeprom.tick == 9) {
logout("\tcommand 0x%04x, %s\n", eeprom.command, bit ? "read" : "write");
eeprom.ack = 1;
}
} else if (eeprom.tick < 17) {
if (eeprom.command & 1) {
sda = ((eeprom.data & 0x80) != 0);
}
eeprom.address <<= 1;
eeprom.address += bit;
eeprom.tick++;
eeprom.data <<= 1;
if (eeprom.tick == 17) {
eeprom.data = eeprom.contents[eeprom.address];
logout("\taddress 0x%04x, data 0x%02x\n", eeprom.address, eeprom.data);
eeprom.ack = 1;
eeprom.tick = 0;
}
} else if (eeprom.tick >= 17) {
sda = 0;
}
} else {
logout("\tsda changed with raising scl\n");
}
} else {
logout("%u: scl = %u->%u, sda = %u->%u\n", eeprom.tick, eeprom.scl, scl, eeprom.sda, sda);
}
eeprom.scl = scl;
eeprom.sda = sda;
}
| false | qemu | 35c648078aa493c3b976840eb7cf2e53ab5b7a2d |
6,751 | static void cmd_mode_sense(IDEState *s, uint8_t *buf)
{
int action, code;
int max_len;
if (buf[0] == GPCMD_MODE_SENSE_10) {
max_len = ube16_to_cpu(buf + 7);
} else {
max_len = buf[4];
}
action = buf[2] >> 6;
code = buf[2] & 0x3f;
switch(action) {
case 0: /* current values */
switch(code) {
case MODE_PAGE_R_W_ERROR: /* error recovery */
cpu_to_ube16(&buf[0], 16 + 6);
buf[2] = 0x70;
buf[3] = 0;
buf[4] = 0;
buf[5] = 0;
buf[6] = 0;
buf[7] = 0;
buf[8] = MODE_PAGE_R_W_ERROR;
buf[9] = 16 - 10;
buf[10] = 0x00;
buf[11] = 0x05;
buf[12] = 0x00;
buf[13] = 0x00;
buf[14] = 0x00;
buf[15] = 0x00;
ide_atapi_cmd_reply(s, 16, max_len);
break;
case MODE_PAGE_AUDIO_CTL:
cpu_to_ube16(&buf[0], 24 + 6);
buf[2] = 0x70;
buf[3] = 0;
buf[4] = 0;
buf[5] = 0;
buf[6] = 0;
buf[7] = 0;
buf[8] = MODE_PAGE_AUDIO_CTL;
buf[9] = 24 - 10;
/* Fill with CDROM audio volume */
buf[17] = 0;
buf[19] = 0;
buf[21] = 0;
buf[23] = 0;
ide_atapi_cmd_reply(s, 24, max_len);
break;
case MODE_PAGE_CAPABILITIES:
cpu_to_ube16(&buf[0], 28 + 6);
buf[2] = 0x70;
buf[3] = 0;
buf[4] = 0;
buf[5] = 0;
buf[6] = 0;
buf[7] = 0;
buf[8] = MODE_PAGE_CAPABILITIES;
buf[9] = 28 - 10;
buf[10] = 0x00;
buf[11] = 0x00;
/* Claim PLAY_AUDIO capability (0x01) since some Linux
code checks for this to automount media. */
buf[12] = 0x71;
buf[13] = 3 << 5;
buf[14] = (1 << 0) | (1 << 3) | (1 << 5);
if (s->tray_locked) {
buf[6] |= 1 << 1;
}
buf[15] = 0x00;
cpu_to_ube16(&buf[16], 706);
buf[18] = 0;
buf[19] = 2;
cpu_to_ube16(&buf[20], 512);
cpu_to_ube16(&buf[22], 706);
buf[24] = 0;
buf[25] = 0;
buf[26] = 0;
buf[27] = 0;
ide_atapi_cmd_reply(s, 28, max_len);
break;
default:
goto error_cmd;
}
break;
case 1: /* changeable values */
goto error_cmd;
case 2: /* default values */
goto error_cmd;
default:
case 3: /* saved values */
ide_atapi_cmd_error(s, ILLEGAL_REQUEST,
ASC_SAVING_PARAMETERS_NOT_SUPPORTED);
break;
}
return;
error_cmd:
ide_atapi_cmd_error(s, ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET);
}
| false | qemu | a07c7dcd6f33b668747148ac28c0e147f958aa18 |
6,752 | static inline void RENAME(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#if COMPILE_TEMPLATE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm__ volatile(
"movq %0, %%mm7 \n\t"
"movq %1, %%mm6 \n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 11;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movd %1, %%mm0 \n\t"
"movd 3%1, %%mm3 \n\t"
"punpckldq 6%1, %%mm0 \n\t"
"punpckldq 9%1, %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm3, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"psrlq $3, %%mm0 \n\t"
"psrlq $3, %%mm3 \n\t"
"pand %2, %%mm0 \n\t"
"pand %2, %%mm3 \n\t"
"psrlq $5, %%mm1 \n\t"
"psrlq $5, %%mm4 \n\t"
"pand %%mm6, %%mm1 \n\t"
"pand %%mm6, %%mm4 \n\t"
"psrlq $8, %%mm2 \n\t"
"psrlq $8, %%mm5 \n\t"
"pand %%mm7, %%mm2 \n\t"
"pand %%mm7, %%mm5 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm2, %%mm0 \n\t"
"por %%mm5, %%mm3 \n\t"
"psllq $16, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 12;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
while (s < end) {
const int b = *s++;
const int g = *s++;
const int r = *s++;
*d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
}
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 |
6,754 | int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
{
/* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */
char *tmp_filename = g_malloc0(PATH_MAX + 1);
int64_t total_size;
QemuOpts *opts = NULL;
QDict *snapshot_options;
BlockDriverState *bs_snapshot;
Error *local_err;
int ret;
/* if snapshot, we create a temporary backing file and open it
instead of opening 'filename' directly */
/* Get the required size from the image */
total_size = bdrv_getlength(bs);
if (total_size < 0) {
ret = total_size;
error_setg_errno(errp, -total_size, "Could not get image size");
goto out;
}
/* Create the temporary image */
ret = get_tmp_filename(tmp_filename, PATH_MAX + 1);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not get temporary filename");
goto out;
}
opts = qemu_opts_create(bdrv_qcow2.create_opts, NULL, 0,
&error_abort);
qemu_opt_set_number(opts, BLOCK_OPT_SIZE, total_size, &error_abort);
ret = bdrv_create(&bdrv_qcow2, tmp_filename, opts, &local_err);
qemu_opts_del(opts);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not create temporary overlay "
"'%s': %s", tmp_filename,
error_get_pretty(local_err));
error_free(local_err);
goto out;
}
/* Prepare a new options QDict for the temporary file */
snapshot_options = qdict_new();
qdict_put(snapshot_options, "file.driver",
qstring_from_str("file"));
qdict_put(snapshot_options, "file.filename",
qstring_from_str(tmp_filename));
bs_snapshot = bdrv_new();
ret = bdrv_open(&bs_snapshot, NULL, NULL, snapshot_options,
flags, &bdrv_qcow2, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto out;
}
bdrv_append(bs_snapshot, bs);
out:
g_free(tmp_filename);
return ret;
}
| false | qemu | c2e0dbbfd7265eb9a7170ab195d8f9f8a1cbd1af |
6,755 | void address_space_read(AddressSpace *as, target_phys_addr_t addr, uint8_t *buf, int len)
{
address_space_rw(as, addr, buf, len, false);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c |
6,756 | static int ide_write_dma_cb(IDEState *s,
target_phys_addr_t phys_addr,
int transfer_size1)
{
int len, transfer_size, n;
int64_t sector_num;
transfer_size = transfer_size1;
for(;;) {
len = s->io_buffer_size - s->io_buffer_index;
if (len == 0) {
n = s->io_buffer_size >> 9;
sector_num = ide_get_sector(s);
bdrv_write(s->bs, sector_num, s->io_buffer,
s->io_buffer_size >> 9);
sector_num += n;
ide_set_sector(s, sector_num);
s->nsector -= n;
n = s->nsector;
if (n == 0) {
/* end of transfer */
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s);
return 0;
}
if (n > MAX_MULT_SECTORS)
n = MAX_MULT_SECTORS;
s->io_buffer_index = 0;
s->io_buffer_size = n * 512;
len = s->io_buffer_size;
}
if (transfer_size <= 0)
break;
if (len > transfer_size)
len = transfer_size;
cpu_physical_memory_read(phys_addr,
s->io_buffer + s->io_buffer_index, len);
s->io_buffer_index += len;
transfer_size -= len;
phys_addr += len;
}
return transfer_size1 - transfer_size;
}
| false | qemu | e774a278d82c9391c9fb6c9af42cd08bb9364b9f |
6,757 | static void pty_chr_update_read_handler_locked(CharDriverState *chr)
{
PtyCharDriver *s = chr->opaque;
GPollFD pfd;
pfd.fd = g_io_channel_unix_get_fd(s->fd);
pfd.events = G_IO_OUT;
pfd.revents = 0;
g_poll(&pfd, 1, 0);
if (pfd.revents & G_IO_HUP) {
pty_chr_state(chr, 0);
} else {
pty_chr_state(chr, 1);
}
}
| false | qemu | c1f2448998062f25df395cd239169400a4c41ed6 |
6,758 | QObject *json_parser_parse_err(QList *tokens, va_list *ap, Error **errp)
{
JSONParserContext ctxt = {};
QList *working;
QObject *result;
if (!tokens) {
return NULL;
}
working = qlist_copy(tokens);
result = parse_value(&ctxt, &working, ap);
QDECREF(working);
error_propagate(errp, ctxt.err);
return result;
}
| false | qemu | 65c0f1e9558c7c762cdb333406243fff1d687117 |
6,759 | int loader_exec(const char * filename, char ** argv, char ** envp,
struct target_pt_regs * regs, struct image_info *infop,
struct linux_binprm *bprm)
{
int retval;
int i;
bprm->p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int);
memset(bprm->page, 0, sizeof(bprm->page));
retval = open(filename, O_RDONLY);
if (retval < 0) {
return -errno;
}
bprm->fd = retval;
bprm->filename = (char *)filename;
bprm->argc = count(argv);
bprm->argv = argv;
bprm->envc = count(envp);
bprm->envp = envp;
retval = prepare_binprm(bprm);
if(retval>=0) {
if (bprm->buf[0] == 0x7f
&& bprm->buf[1] == 'E'
&& bprm->buf[2] == 'L'
&& bprm->buf[3] == 'F') {
retval = load_elf_binary(bprm, regs, infop);
#if defined(TARGET_HAS_BFLT)
} else if (bprm->buf[0] == 'b'
&& bprm->buf[1] == 'F'
&& bprm->buf[2] == 'L'
&& bprm->buf[3] == 'T') {
retval = load_flt_binary(bprm,regs,infop);
#endif
} else {
return -ENOEXEC;
}
}
if(retval>=0) {
/* success. Initialize important registers */
do_init_thread(regs, infop);
return retval;
}
/* Something went wrong, return the inode and free the argument pages*/
for (i=0 ; i<MAX_ARG_PAGES ; i++) {
g_free(bprm->page[i]);
}
return(retval);
}
| false | qemu | 03cfd8faa7ffb7201e2949b99c2f35b1fef7078b |
6,760 | int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive)
{
int ret;
struct flock fl = {
.l_whence = SEEK_SET,
.l_start = start,
.l_len = len,
.l_type = exclusive ? F_WRLCK : F_RDLCK,
};
ret = fcntl(fd, QEMU_GETLK, &fl);
if (ret == -1) {
return -errno;
} else {
return fl.l_type == F_UNLCK ? 0 : -EAGAIN;
}
}
| false | qemu | ca749954b09b89e22cd69c4949fb7e689b057963 |
6,761 | static int swri_resample(ResampleContext *c,
uint8_t *dst, const uint8_t *src, int *consumed,
int src_size, int dst_size, int update_ctx)
{
int fn_idx = c->format - AV_SAMPLE_FMT_S16P;
if (c->filter_length == 1 && c->phase_shift == 0) {
int index= c->index;
int frac= c->frac;
int64_t index2= (1LL<<32)*c->frac/c->src_incr + (1LL<<32)*index;
int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
int new_size = (src_size * (int64_t)c->src_incr - frac + c->dst_incr - 1) / c->dst_incr;
dst_size= FFMIN(dst_size, new_size);
c->dsp.resample_one[fn_idx](dst, src, dst_size, index2, incr);
index += dst_size * c->dst_incr_div;
index += (frac + dst_size * (int64_t)c->dst_incr_mod) / c->src_incr;
av_assert2(index >= 0);
*consumed= index;
if (update_ctx) {
c->frac = (frac + dst_size * (int64_t)c->dst_incr_mod) % c->src_incr;
c->index = 0;
}
} else {
int64_t end_index = (1LL + src_size - c->filter_length) << c->phase_shift;
int64_t delta_frac = (end_index - c->index) * c->src_incr - c->frac;
int delta_n = (delta_frac + c->dst_incr - 1) / c->dst_incr;
dst_size = FFMIN(dst_size, delta_n);
if (dst_size > 0) {
if (!c->linear) {
*consumed = c->dsp.resample_common[fn_idx](c, dst, src, dst_size, update_ctx);
} else {
*consumed = c->dsp.resample_linear[fn_idx](c, dst, src, dst_size, update_ctx);
}
} else {
*consumed = 0;
}
}
return dst_size;
}
| false | FFmpeg | 857cd1f33bcf86005529af2a77f861f884327be5 |
6,762 | static int dash_init(AVFormatContext *s)
{
DASHContext *c = s->priv_data;
int ret = 0, i;
char *ptr;
char basename[1024];
if (c->single_file_name)
c->single_file = 1;
if (c->single_file)
c->use_template = 0;
av_strlcpy(c->dirname, s->filename, sizeof(c->dirname));
ptr = strrchr(c->dirname, '/');
if (ptr) {
av_strlcpy(basename, &ptr[1], sizeof(basename));
ptr[1] = '\0';
} else {
c->dirname[0] = '\0';
av_strlcpy(basename, s->filename, sizeof(basename));
}
ptr = strrchr(basename, '.');
if (ptr)
*ptr = '\0';
c->streams = av_mallocz(sizeof(*c->streams) * s->nb_streams);
if (!c->streams)
return AVERROR(ENOMEM);
if ((ret = parse_adaptation_sets(s)) < 0)
return ret;
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
AdaptationSet *as = &c->as[os->as_idx - 1];
AVFormatContext *ctx;
AVStream *st;
AVDictionary *opts = NULL;
char filename[1024];
os->bit_rate = s->streams[i]->codecpar->bit_rate;
if (os->bit_rate) {
snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
" bandwidth=\"%d\"", os->bit_rate);
} else {
int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
AV_LOG_ERROR : AV_LOG_WARNING;
av_log(s, level, "No bit rate set for stream %d\n", i);
if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
return AVERROR(EINVAL);
}
// copy AdaptationSet language and role from stream metadata
dict_copy_entry(&as->metadata, s->streams[i]->metadata, "language");
dict_copy_entry(&as->metadata, s->streams[i]->metadata, "role");
ctx = avformat_alloc_context();
if (!ctx)
return AVERROR(ENOMEM);
// choose muxer based on codec: webm for VP8/9 and opus, mp4 otherwise
// note: os->format_name is also used as part of the mimetype of the
// representation, e.g. video/<format_name>
if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
s->streams[i]->codecpar->codec_id == AV_CODEC_ID_VP9 ||
s->streams[i]->codecpar->codec_id == AV_CODEC_ID_OPUS ||
s->streams[i]->codecpar->codec_id == AV_CODEC_ID_VORBIS) {
snprintf(os->format_name, sizeof(os->format_name), "webm");
} else {
snprintf(os->format_name, sizeof(os->format_name), "mp4");
}
ctx->oformat = av_guess_format(os->format_name, NULL, NULL);
if (!ctx->oformat)
return AVERROR_MUXER_NOT_FOUND;
os->ctx = ctx;
ctx->interrupt_callback = s->interrupt_callback;
ctx->opaque = s->opaque;
ctx->io_close = s->io_close;
ctx->io_open = s->io_open;
if (!(st = avformat_new_stream(ctx, NULL)))
return AVERROR(ENOMEM);
avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar);
st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
st->time_base = s->streams[i]->time_base;
st->avg_frame_rate = s->streams[i]->avg_frame_rate;
ctx->avoid_negative_ts = s->avoid_negative_ts;
ctx->flags = s->flags;
if ((ret = avio_open_dyn_buf(&ctx->pb)) < 0)
return ret;
if (c->single_file) {
if (c->single_file_name)
ff_dash_fill_tmpl_params(os->initfile, sizeof(os->initfile), c->single_file_name, i, 0, os->bit_rate, 0);
else
snprintf(os->initfile, sizeof(os->initfile), "%s-stream%d.m4s", basename, i);
} else {
ff_dash_fill_tmpl_params(os->initfile, sizeof(os->initfile), c->init_seg_name, i, 0, os->bit_rate, 0);
}
snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
ret = s->io_open(s, &os->out, filename, AVIO_FLAG_WRITE, NULL);
if (ret < 0)
return ret;
os->init_start_pos = 0;
if (!strcmp(os->format_name, "mp4")) {
av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
} else {
av_dict_set_int(&opts, "cluster_time_limit", c->min_seg_duration / 1000, 0);
av_dict_set_int(&opts, "cluster_size_limit", 5 * 1024 * 1024, 0); // set a large cluster size limit
av_dict_set_int(&opts, "dash", 1, 0);
av_dict_set_int(&opts, "dash_track_number", i + 1, 0);
av_dict_set_int(&opts, "live", 1, 0);
}
if ((ret = avformat_init_output(ctx, &opts)) < 0)
return ret;
os->ctx_inited = 1;
avio_flush(ctx->pb);
av_dict_free(&opts);
av_log(s, AV_LOG_VERBOSE, "Representation %d init segment will be written to: %s\n", i, filename);
// Flush init segment
// except for mp4, since delay_moov is set and the init segment
// is then flushed after the first packets
if (strcmp(os->format_name, "mp4")) {
flush_init_segment(s, os);
}
s->streams[i]->time_base = st->time_base;
// If the muxer wants to shift timestamps, request to have them shifted
// already before being handed to this muxer, so we don't have mismatches
// between the MPD and the actual segments.
s->avoid_negative_ts = ctx->avoid_negative_ts;
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
AVRational avg_frame_rate = s->streams[i]->avg_frame_rate;
if (avg_frame_rate.num > 0) {
if (av_cmp_q(avg_frame_rate, as->min_frame_rate) < 0)
as->min_frame_rate = avg_frame_rate;
if (av_cmp_q(as->max_frame_rate, avg_frame_rate) < 0)
as->max_frame_rate = avg_frame_rate;
} else {
as->ambiguous_frame_rate = 1;
}
c->has_video = 1;
}
set_codec_str(s, st->codecpar, os->codec_str, sizeof(os->codec_str));
os->first_pts = AV_NOPTS_VALUE;
os->max_pts = AV_NOPTS_VALUE;
os->last_dts = AV_NOPTS_VALUE;
os->segment_index = 1;
}
if (!c->has_video && c->min_seg_duration <= 0) {
av_log(s, AV_LOG_WARNING, "no video stream and no min seg duration set\n");
return AVERROR(EINVAL);
}
return 0;
}
| false | FFmpeg | d24e08e978792e09d212018677d1c0b8208ecef8 |
6,764 | static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst,
const uint8_t *src, int width,
int esc_count)
{
int i = 0;
int count;
uint8_t zero_run = 0;
const uint8_t *start = src;
uint8_t mask1 = -(esc_count < 2);
uint8_t mask2 = -(esc_count < 3);
uint8_t *end = dst + (width - 2);
output_zeros:
if (l->zeros_rem) {
count = FFMIN(l->zeros_rem, width - i);
memset(dst, 0, count);
l->zeros_rem -= count;
dst += count;
}
while (dst < end) {
i = 0;
while (!zero_run && dst + i < end) {
i++;
zero_run =
!(src[i] | (src[i + 1] & mask1) | (src[i + 2] & mask2));
}
if (zero_run) {
zero_run = 0;
i += esc_count;
memcpy(dst, src, i);
dst += i;
l->zeros_rem = lag_calc_zero_run(src[i]);
src += i + 1;
goto output_zeros;
} else {
memcpy(dst, src, i);
src += i;
}
}
return start - src;
}
| true | FFmpeg | 0a82f5275f719e6e369a807720a2c3603aa0ddd9 |
6,765 | void av_force_cpu_flags(int arg){
if ( (arg & ( AV_CPU_FLAG_3DNOW |
AV_CPU_FLAG_3DNOWEXT |
AV_CPU_FLAG_MMXEXT |
AV_CPU_FLAG_SSE |
AV_CPU_FLAG_SSE2 |
AV_CPU_FLAG_SSE2SLOW |
AV_CPU_FLAG_SSE3 |
AV_CPU_FLAG_SSE3SLOW |
AV_CPU_FLAG_SSSE3 |
AV_CPU_FLAG_SSE4 |
AV_CPU_FLAG_SSE42 |
AV_CPU_FLAG_AVX |
AV_CPU_FLAG_AVXSLOW |
AV_CPU_FLAG_XOP |
AV_CPU_FLAG_FMA3 |
AV_CPU_FLAG_FMA4 |
AV_CPU_FLAG_AVX2 ))
&& !(arg & AV_CPU_FLAG_MMX)) {
av_log(NULL, AV_LOG_WARNING, "MMX implied by specified flags\n");
arg |= AV_CPU_FLAG_MMX;
}
cpu_flags = arg;
}
| true | FFmpeg | fed50c4304eecb352e29ce789cdb96ea84d6162f |
6,766 | static void put_uint32(QEMUFile *f, void *pv, size_t size)
{
uint32_t *v = pv;
qemu_put_be32s(f, v);
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 |
6,767 | static int net_bridge_run_helper(const char *helper, const char *bridge)
{
sigset_t oldmask, mask;
int pid, status;
char *args[5];
char **parg;
int sv[2];
sigemptyset(&mask);
sigaddset(&mask, SIGCHLD);
sigprocmask(SIG_BLOCK, &mask, &oldmask);
if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
return -1;
}
/* try to launch bridge helper */
pid = fork();
if (pid == 0) {
int open_max = sysconf(_SC_OPEN_MAX), i;
char fd_buf[6+10];
char br_buf[6+IFNAMSIZ] = {0};
char helper_cmd[PATH_MAX + sizeof(fd_buf) + sizeof(br_buf) + 15];
for (i = 3; i < open_max; i++) {
if (i != sv[1]) {
close(i);
}
}
snprintf(fd_buf, sizeof(fd_buf), "%s%d", "--fd=", sv[1]);
if (strrchr(helper, ' ') || strrchr(helper, '\t')) {
/* assume helper is a command */
if (strstr(helper, "--br=") == NULL) {
snprintf(br_buf, sizeof(br_buf), "%s%s", "--br=", bridge);
}
snprintf(helper_cmd, sizeof(helper_cmd), "%s %s %s %s",
helper, "--use-vnet", fd_buf, br_buf);
parg = args;
*parg++ = (char *)"sh";
*parg++ = (char *)"-c";
*parg++ = helper_cmd;
*parg++ = NULL;
execv("/bin/sh", args);
} else {
/* assume helper is just the executable path name */
snprintf(br_buf, sizeof(br_buf), "%s%s", "--br=", bridge);
parg = args;
*parg++ = (char *)helper;
*parg++ = (char *)"--use-vnet";
*parg++ = fd_buf;
*parg++ = br_buf;
*parg++ = NULL;
execv(helper, args);
}
_exit(1);
} else if (pid > 0) {
int fd;
close(sv[1]);
do {
fd = recv_fd(sv[0]);
} while (fd == -1 && errno == EINTR);
close(sv[0]);
while (waitpid(pid, &status, 0) != pid) {
/* loop */
}
sigprocmask(SIG_SETMASK, &oldmask, NULL);
if (fd < 0) {
fprintf(stderr, "failed to recv file descriptor\n");
return -1;
}
if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
return fd;
}
}
fprintf(stderr, "failed to launch bridge helper\n");
return -1;
}
| true | qemu | a8a21be9855e0bb0947a7325d0d1741a8814f21e |
6,768 | static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
BDRVCURLState *s = bs->opaque;
CURLAIOCB *acb;
size_t start = sector_num * SECTOR_SIZE;
size_t end;
CURLState *state;
acb = qemu_aio_get(&curl_aio_pool, bs, cb, opaque);
if (!acb)
return NULL;
acb->qiov = qiov;
// In case we have the requested data already (e.g. read-ahead),
// we can just call the callback and be done.
switch (curl_find_buf(s, start, nb_sectors * SECTOR_SIZE, acb)) {
case FIND_RET_OK:
qemu_aio_release(acb);
// fall through
case FIND_RET_WAIT:
return &acb->common;
default:
break;
}
// No cache found, so let's start a new request
state = curl_init_state(s);
if (!state)
return NULL;
acb->start = 0;
acb->end = (nb_sectors * SECTOR_SIZE);
state->buf_off = 0;
if (state->orig_buf)
qemu_free(state->orig_buf);
state->buf_start = start;
state->buf_len = acb->end + READ_AHEAD_SIZE;
end = MIN(start + state->buf_len, s->len) - 1;
state->orig_buf = qemu_malloc(state->buf_len);
state->acb[0] = acb;
snprintf(state->range, 127, "%lld-%lld", (long long)start, (long long)end);
dprintf("CURL (AIO): Reading %d at %lld (%s)\n", (nb_sectors * SECTOR_SIZE), start, state->range);
curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range);
curl_multi_add_handle(s->multi, state->curl);
curl_multi_do(s);
return &acb->common;
}
| true | qemu | c76f4952bbf47116255bc00780ceae3bc8a657c0 |
6,769 | static int alloc_f(BlockDriverState *bs, int argc, char **argv)
{
int64_t offset, sector_num;
int nb_sectors, remaining;
char s1[64];
int num, sum_alloc;
int ret;
offset = cvtnum(argv[1]);
if (offset < 0) {
printf("non-numeric offset argument -- %s\n", argv[1]);
} else if (offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
offset);
if (argc == 3) {
nb_sectors = cvtnum(argv[2]);
if (nb_sectors < 0) {
printf("non-numeric length argument -- %s\n", argv[2]);
} else {
nb_sectors = 1;
remaining = nb_sectors;
sum_alloc = 0;
sector_num = offset >> 9;
while (remaining) {
ret = bdrv_is_allocated(bs, sector_num, remaining, &num);
sector_num += num;
remaining -= num;
if (ret) {
sum_alloc += num;
if (num == 0) {
nb_sectors -= remaining;
remaining = 0;
cvtstr(offset, s1, sizeof(s1));
printf("%d/%d sectors allocated at offset %s\n",
sum_alloc, nb_sectors, s1);
| true | qemu | d663640c04f2aab810915c556390211d75457704 |
6,770 | static void test_qga_fstrim(gconstpointer fix)
{
const TestFixture *fixture = fix;
QDict *ret;
QList *list;
const QListEntry *entry;
ret = qmp_fd(fixture->fd, "{'execute': 'guest-fstrim',"
" arguments: { minimum: 4194304 } }");
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
list = qdict_get_qlist(ret, "return");
entry = qlist_first(list);
g_assert(qdict_haskey(qobject_to_qdict(entry->value), "paths"));
QDECREF(ret);
}
| true | qemu | f94b3f64e6572c8cec73a538588f7cd754bcfa88 |
6,771 | static RemoveResult remove_hpte(CPUPPCState *env, target_ulong ptex,
target_ulong avpn,
target_ulong flags,
target_ulong *vp, target_ulong *rp)
{
hwaddr hpte;
target_ulong v, r, rb;
if ((ptex * HASH_PTE_SIZE_64) & ~env->htab_mask) {
return REMOVE_PARM;
}
hpte = ptex * HASH_PTE_SIZE_64;
v = ppc_hash64_load_hpte0(env, hpte);
r = ppc_hash64_load_hpte1(env, hpte);
if ((v & HPTE64_V_VALID) == 0 ||
((flags & H_AVPN) && (v & ~0x7fULL) != avpn) ||
((flags & H_ANDCOND) && (v & avpn) != 0)) {
return REMOVE_NOT_FOUND;
}
*vp = v;
*rp = r;
ppc_hash64_store_hpte0(env, hpte, HPTE64_V_HPTE_DIRTY);
rb = compute_tlbie_rb(v, r, ptex);
ppc_tlb_invalidate_one(env, rb);
return REMOVE_SUCCESS;
}
| true | qemu | f3c75d42adbba553eaf218a832d4fbea32c8f7b8 |
6,772 | static void pc_init1(MachineState *machine,
int pci_enabled,
int kvmclock_enabled)
{
PCMachineState *pc_machine = PC_MACHINE(machine);
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int i;
ram_addr_t below_4g_mem_size, above_4g_mem_size;
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
int piix3_devfn = -1;
qemu_irq *cpu_irq;
qemu_irq *gsi;
qemu_irq *i8259;
qemu_irq *smi_irq;
GSIState *gsi_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
ISADevice *floppy;
MemoryRegion *ram_memory;
MemoryRegion *pci_memory;
MemoryRegion *rom_memory;
DeviceState *icc_bridge;
FWCfgState *fw_cfg = NULL;
PcGuestInfo *guest_info;
ram_addr_t lowmem;
/* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory).
* If it doesn't, we need to split it in chunks below and above 4G.
* In any case, try to make sure that guest addresses aligned at
* 1G boundaries get mapped to host addresses aligned at 1G boundaries.
* For old machine types, use whatever split we used historically to avoid
* breaking migration.
*/
if (machine->ram_size >= 0xe0000000) {
lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
} else {
lowmem = 0xe0000000;
}
/* Handle the machine opt max-ram-below-4g. It is basically doing
* min(qemu limit, user limit).
*/
if (lowmem > pc_machine->max_ram_below_4g) {
lowmem = pc_machine->max_ram_below_4g;
if (machine->ram_size - lowmem > lowmem &&
lowmem & ((1ULL << 30) - 1)) {
error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
") not a multiple of 1G; possible bad performance.",
pc_machine->max_ram_below_4g);
}
}
if (machine->ram_size >= lowmem) {
above_4g_mem_size = machine->ram_size - lowmem;
below_4g_mem_size = lowmem;
} else {
above_4g_mem_size = 0;
below_4g_mem_size = machine->ram_size;
}
if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
&ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
}
icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
object_property_add_child(qdev_get_machine(), "icc-bridge",
OBJECT(icc_bridge), NULL);
pc_cpus_init(machine->cpu_model, icc_bridge);
if (kvm_enabled() && kvmclock_enabled) {
kvmclock_create();
}
if (pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
rom_memory = pci_memory;
} else {
pci_memory = NULL;
rom_memory = system_memory;
}
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
guest_info->has_acpi_build = has_acpi_build;
guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
guest_info->isapc_ram_fw = !pci_enabled;
guest_info->has_reserved_memory = has_reserved_memory;
if (smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
/* These values are guest ABI, do not change */
smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
mc->name, smbios_legacy_mode);
}
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
fw_cfg = pc_memory_init(machine, system_memory,
below_4g_mem_size, above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
} else if (machine->kernel_filename != NULL) {
/* For xen HVM direct kernel boot, load linux here */
fw_cfg = xen_load_linux(machine->kernel_filename,
machine->kernel_cmdline,
machine->initrd_filename,
below_4g_mem_size,
guest_info);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_irqchip_in_kernel()) {
kvm_pc_setup_irq_routing(pci_enabled);
gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
system_memory, system_io, machine->ram_size,
below_4g_mem_size,
above_4g_mem_size,
pci_memory, ram_memory);
} else {
pci_bus = NULL;
i440fx_state = NULL;
isa_bus = isa_bus_new(NULL, system_io);
no_hpet = 1;
}
isa_bus_irqs(isa_bus, gsi);
if (kvm_irqchip_in_kernel()) {
i8259 = kvm_i8259_init(isa_bus);
} else if (xen_enabled()) {
i8259 = xen_interrupt_controller_init();
} else {
cpu_irq = pc_allocate_cpu_irq();
i8259 = i8259_init(isa_bus, cpu_irq[0]);
}
for (i = 0; i < ISA_NUM_IRQS; i++) {
gsi_state->i8259_irq[i] = i8259[i];
}
if (pci_enabled) {
ioapic_init_gsi(gsi_state, "i440fx");
}
qdev_init_nofail(icc_bridge);
pc_register_ferr_irq(gsi[13]);
pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
/* init basic PC hardware */
pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled(),
0x4);
pc_nic_init(isa_bus, pci_bus);
ide_drive_get(hd, MAX_IDE_BUS);
if (pci_enabled) {
PCIDevice *dev;
if (xen_enabled()) {
dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
} else {
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
}
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
ISADevice *dev;
char busname[] = "ide.0";
dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
/*
* The ide bus name is ide.0 for the first bus and ide.1 for the
* second one.
*/
busname[4] = '0' + i;
idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
}
}
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
floppy, idebus[0], idebus[1], rtc_state);
if (pci_enabled && usb_enabled(false)) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
}
if (pci_enabled && acpi_enabled) {
DeviceState *piix4_pm;
I2CBus *smbus;
smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
/* TODO: Populate SPD eeprom data. */
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
gsi[9], *smi_irq,
kvm_enabled(), fw_cfg, &piix4_pm);
smbus_eeprom_init(smbus, 8, NULL, 0);
object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
TYPE_HOTPLUG_HANDLER,
(Object **)&pc_machine->acpi_dev,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
}
if (pci_enabled) {
pc_pci_device_init(pci_bus);
}
}
| true | qemu | d8f94e1bb275ab6a14a15220fd6afd0d04324aeb |
6,773 | int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size)
{
int64_t buffer_start;
int buffer_size;
int overlap, new_size, alloc_size;
if (s->write_flag)
return AVERROR(EINVAL);
buffer_size = s->buf_end - s->buffer;
/* the buffers must touch or overlap */
if ((buffer_start = s->pos - buffer_size) > buf_size)
return AVERROR(EINVAL);
overlap = buf_size - buffer_start;
new_size = buf_size + buffer_size - overlap;
alloc_size = FFMAX(s->buffer_size, new_size);
if (alloc_size > buf_size)
if (!(buf = av_realloc_f(buf, 1, alloc_size)))
return AVERROR(ENOMEM);
if (new_size > buf_size) {
memcpy(buf + buf_size, s->buffer + overlap, buffer_size - overlap);
buf_size = new_size;
}
av_free(s->buffer);
s->buf_ptr = s->buffer = buf;
s->buffer_size = alloc_size;
s->pos = buf_size;
s->buf_end = s->buf_ptr + buf_size;
s->eof_reached = 0;
s->must_flush = 0;
return 0;
}
| true | FFmpeg | 120b38b966b92a50dd36542190d35daba6730eb3 |
6,774 | static int url_connect(struct playlist *pls, AVDictionary *opts, AVDictionary *opts2)
{
AVDictionary *tmp = NULL;
int ret;
av_dict_copy(&tmp, opts, 0);
av_dict_copy(&tmp, opts2, 0);
av_opt_set_dict(pls->input, &tmp);
if ((ret = ffurl_connect(pls->input, NULL)) < 0) {
ffurl_close(pls->input);
pls->input = NULL;
}
av_dict_free(&tmp);
return ret;
}
| true | FFmpeg | 4eca1939ef0614d0959fffb93f93d44af6740e8c |
6,776 | void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
AVFilterPad **pads, AVFilterLink ***links,
AVFilterPad *newpad)
{
unsigned i;
idx = FFMIN(idx, *count);
*pads = av_realloc(*pads, sizeof(AVFilterPad) * (*count + 1));
*links = av_realloc(*links, sizeof(AVFilterLink*) * (*count + 1));
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))++;
}
| true | FFmpeg | 211a185cba78aa8410e85de91630aa3a8c083883 |
6,777 | static int spapr_cpu_core_realize_child(Object *child, void *opaque)
{
Error **errp = opaque, *local_err = NULL;
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
CPUState *cs = CPU(child);
PowerPCCPU *cpu = POWERPC_CPU(cs);
object_property_set_bool(child, true, "realized", &local_err);
if (local_err) {
error_propagate(errp, local_err);
return 1;
}
spapr_cpu_init(spapr, cpu, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return 1;
}
return 0;
}
| true | qemu | 7093645a843e5da1a750bc451dd8c9107d595c61 |
6,779 | static void blkverify_aio_cb(void *opaque, int ret)
{
BlkverifyAIOCB *acb = opaque;
switch (++acb->done) {
case 1:
acb->ret = ret;
break;
case 2:
if (acb->ret != ret) {
blkverify_err(acb, "return value mismatch %d != %d", acb->ret, ret);
}
if (acb->verify) {
acb->verify(acb);
}
aio_bh_schedule_oneshot(bdrv_get_aio_context(acb->common.bs),
blkverify_aio_bh, acb);
break;
}
}
| true | qemu | 44b6789299a8acca3f25331bc411055cafc7bb06 |
6,780 | static void do_video_out(AVFormatContext *s,
OutputStream *ost,
AVFrame *in_picture,
int *frame_size)
{
int ret, format_video_sync;
AVPacket pkt;
AVCodecContext *enc = ost->st->codec;
*frame_size = 0;
format_video_sync = video_sync_method;
if (format_video_sync == VSYNC_AUTO)
format_video_sync = (s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH :
(s->oformat->flags & AVFMT_VARIABLE_FPS) ? VSYNC_VFR : VSYNC_CFR;
if (format_video_sync != VSYNC_PASSTHROUGH &&
ost->frame_number &&
in_picture->pts != AV_NOPTS_VALUE &&
in_picture->pts < ost->sync_opts) {
nb_frames_drop++;
av_log(NULL, AV_LOG_VERBOSE, "*** drop!\n");
return;
}
if (in_picture->pts == AV_NOPTS_VALUE)
in_picture->pts = ost->sync_opts;
ost->sync_opts = in_picture->pts;
if (!ost->frame_number)
ost->first_pts = in_picture->pts;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
if (ost->frame_number >= ost->max_frames)
return;
if (s->oformat->flags & AVFMT_RAWPICTURE &&
enc->codec->id == AV_CODEC_ID_RAWVIDEO) {
/* raw pictures are written as AVPicture structure to
avoid any copies. We support temporarily the older
method. */
enc->coded_frame->interlaced_frame = in_picture->interlaced_frame;
enc->coded_frame->top_field_first = in_picture->top_field_first;
pkt.data = (uint8_t *)in_picture;
pkt.size = sizeof(AVPicture);
pkt.pts = av_rescale_q(in_picture->pts, enc->time_base, ost->st->time_base);
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(s, &pkt, ost);
} else {
int got_packet;
if (ost->st->codec->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) &&
ost->top_field_first >= 0)
in_picture->top_field_first = !!ost->top_field_first;
in_picture->quality = ost->st->codec->global_quality;
if (!enc->me_threshold)
in_picture->pict_type = 0;
if (ost->forced_kf_index < ost->forced_kf_count &&
in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
in_picture->pict_type = AV_PICTURE_TYPE_I;
ost->forced_kf_index++;
}
ret = avcodec_encode_video2(enc, &pkt, in_picture, &got_packet);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
exit(1);
}
if (got_packet) {
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
write_frame(s, &pkt, ost);
*frame_size = pkt.size;
video_size += pkt.size;
/* if two pass, output log */
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
/*
* For video, number of frames in == number of packets out.
* But there may be reordering, so we can't throw away frames on encoder
* flush, we need to limit them here, before they go into encoder.
*/
ost->frame_number++;
}
| true | FFmpeg | 636ced8e1dc8248a1353b416240b93d70ad03edb |
6,781 | static void pc_init_pci_1_4(QEMUMachineInitArgs *args)
{
pc_sysfw_flash_vs_rom_bug_compatible = true;
has_pvpanic = false;
x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
pc_init_pci(args);
}
| true | qemu | 9e1c2ec8fd8d9a9ee299ea86c5f6c986fe25e838 |
6,782 | void cpu_dump_state (CPUState *env, FILE *f, fprintf_function cpu_fprintf,
int flags)
{
#define RGPL 4
#define RFPL 4
int i;
cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
TARGET_FMT_lx " XER " TARGET_FMT_lx "\n",
env->nip, env->lr, env->ctr, env->xer);
cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
TARGET_FMT_lx " idx %d\n", env->msr, env->spr[SPR_HID0],
env->hflags, env->mmu_idx);
#if !defined(NO_TIMER_DUMP)
cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
" DECR %08" PRIu32
"\n",
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(env)
);
for (i = 0; i < 32; i++) {
if ((i & (RGPL - 1)) == 0)
cpu_fprintf(f, "GPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i));
if ((i & (RGPL - 1)) == (RGPL - 1))
cpu_fprintf(f, "\n");
cpu_fprintf(f, "CR ");
for (i = 0; i < 8; i++)
cpu_fprintf(f, "%01x", env->crf[i]);
cpu_fprintf(f, " [");
for (i = 0; i < 8; i++) {
char a = '-';
if (env->crf[i] & 0x08)
a = 'L';
else if (env->crf[i] & 0x04)
a = 'G';
else if (env->crf[i] & 0x02)
a = 'E';
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n",
env->reserve_addr);
for (i = 0; i < 32; i++) {
if ((i & (RFPL - 1)) == 0)
cpu_fprintf(f, "FPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
if ((i & (RFPL - 1)) == (RFPL - 1))
cpu_fprintf(f, "\n");
cpu_fprintf(f, "FPSCR %08x\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
env->spr[SPR_SRR0], env->spr[SPR_SRR1],
env->spr[SPR_PVR], env->spr[SPR_VRSAVE]);
cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
" SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG0], env->spr[SPR_SPRG1],
env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);
cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
" SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG4], env->spr[SPR_SPRG5],
env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);
if (env->excp_model == POWERPC_EXCP_BOOKE) {
cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
" MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);
cpu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx
" ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],
env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);
cpu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
" IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],
env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);
cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
" EPR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],
env->spr[SPR_BOOKE_EPR]);
/* FSL-specific */
cpu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx
" PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n",
env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],
env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);
/*
* IVORs are left out as they are large and do not change often --
* they can be read with "p $ivor0", "p $ivor1", etc.
*/
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
case POWERPC_MMU_620:
case POWERPC_MMU_64B:
cpu_fprintf(f, " SDR1 " TARGET_FMT_lx "\n", env->spr[SPR_SDR1]);
break;
case POWERPC_MMU_BOOKE206:
cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
" MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1],
env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]);
cpu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx
" MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6],
env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]);
cpu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx
" TLB1CFG " TARGET_FMT_lx "\n",
env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG],
env->spr[SPR_BOOKE_TLB1CFG]);
break;
default:
break;
#undef RGPL
#undef RFPL | true | qemu | 697ab892786d47008807a49f57b2fd86adfcd098 |
6,783 | static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret,
TCGReg c1, int32_t c2, int c2const)
{
/* For 32-bit comparisons, we can play games with ADDX/SUBX. */
switch (cond) {
case TCG_COND_LTU:
case TCG_COND_GEU:
/* The result of the comparison is in the carry bit. */
break;
case TCG_COND_EQ:
case TCG_COND_NE:
/* For equality, we can transform to inequality vs zero. */
if (c2 != 0) {
tcg_out_arithc(s, ret, c1, c2, c2const, ARITH_XOR);
}
c1 = TCG_REG_G0, c2 = ret, c2const = 0;
cond = (cond == TCG_COND_EQ ? TCG_COND_GEU : TCG_COND_LTU);
break;
case TCG_COND_GTU:
case TCG_COND_LEU:
/* If we don't need to load a constant into a register, we can
swap the operands on GTU/LEU. There's no benefit to loading
the constant into a temporary register. */
if (!c2const || c2 == 0) {
TCGReg t = c1;
c1 = c2;
c2 = t;
c2const = 0;
cond = tcg_swap_cond(cond);
break;
}
/* FALLTHRU */
default:
tcg_out_cmp(s, c1, c2, c2const);
tcg_out_movi_imm13(s, ret, 0);
tcg_out_movcc(s, cond, MOVCC_ICC, ret, 1, 1);
return;
}
tcg_out_cmp(s, c1, c2, c2const);
if (cond == TCG_COND_LTU) {
tcg_out_arithi(s, ret, TCG_REG_G0, 0, ARITH_ADDX);
} else {
tcg_out_arithi(s, ret, TCG_REG_G0, -1, ARITH_SUBX);
}
}
| true | qemu | 321b6c058544c136341bf9cc6055f127f307f03e |
6,784 | static inline void RENAME(yuv2rgb1)(uint16_t *buf0, uint16_t *uvbuf0, uint16_t *uvbuf1,
uint8_t *dest, int dstW, int uvalpha, int dstbpp)
{
int uvalpha1=uvalpha^4095;
const int yalpha1=0;
if(fullUVIpol || allwaysIpol)
{
RENAME(yuv2rgb2)(buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, dstbpp);
return;
}
#ifdef HAVE_MMX
if( uvalpha < 2048 ) // note this is not correct (shifts chrominance by 0.5 pixels) but its a bit faster
{
if(dstbpp == 32)
{
asm volatile(
YSCALEYUV2RGB1
WRITEBGR32
:: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%eax"
);
}
else if(dstbpp==24)
{
asm volatile(
"movl %4, %%ebx \n\t"
YSCALEYUV2RGB1
WRITEBGR24
:: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%eax", "%ebx"
);
}
else if(dstbpp==15)
{
asm volatile(
YSCALEYUV2RGB1
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15
:: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%eax"
);
}
else if(dstbpp==16)
{
asm volatile(
YSCALEYUV2RGB1
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16
:: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%eax"
);
}
}
else
{
if(dstbpp == 32)
{
asm volatile(
YSCALEYUV2RGB1b
WRITEBGR32
:: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%eax"
);
}
else if(dstbpp==24)
{
asm volatile(
"movl %4, %%ebx \n\t"
YSCALEYUV2RGB1b
WRITEBGR24
:: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%eax", "%ebx"
);
}
else if(dstbpp==15)
{
asm volatile(
YSCALEYUV2RGB1b
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g5Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR15
:: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%eax"
);
}
else if(dstbpp==16)
{
asm volatile(
YSCALEYUV2RGB1b
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm2\n\t"
"paddusb "MANGLE(g6Dither)", %%mm4\n\t"
"paddusb "MANGLE(r5Dither)", %%mm5\n\t"
#endif
WRITEBGR16
:: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW),
"m" (yalpha1), "m" (uvalpha1)
: "%eax"
);
}
}
#else
//FIXME write 2 versions (for even & odd lines)
if(dstbpp==32)
{
int i;
for(i=0; i<dstW-1; i+=2){
// vertical linear interpolation && yuv2rgb in a single step:
int Y1=yuvtab_2568[buf0[i]>>7];
int Y2=yuvtab_2568[buf0[i+1]>>7];
int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19);
int Cb= yuvtab_40cf[U];
int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
int Cr= yuvtab_3343[V];
dest[4*i+0]=clip_table[((Y1 + Cb) >>13)];
dest[4*i+1]=clip_table[((Y1 + Cg) >>13)];
dest[4*i+2]=clip_table[((Y1 + Cr) >>13)];
dest[4*i+4]=clip_table[((Y2 + Cb) >>13)];
dest[4*i+5]=clip_table[((Y2 + Cg) >>13)];
dest[4*i+6]=clip_table[((Y2 + Cr) >>13)];
}
}
else if(dstbpp==24)
{
int i;
for(i=0; i<dstW-1; i+=2){
// vertical linear interpolation && yuv2rgb in a single step:
int Y1=yuvtab_2568[buf0[i]>>7];
int Y2=yuvtab_2568[buf0[i+1]>>7];
int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19);
int Cb= yuvtab_40cf[U];
int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
int Cr= yuvtab_3343[V];
dest[0]=clip_table[((Y1 + Cb) >>13)];
dest[1]=clip_table[((Y1 + Cg) >>13)];
dest[2]=clip_table[((Y1 + Cr) >>13)];
dest[3]=clip_table[((Y2 + Cb) >>13)];
dest[4]=clip_table[((Y2 + Cg) >>13)];
dest[5]=clip_table[((Y2 + Cr) >>13)];
dest+=6;
}
}
else if(dstbpp==16)
{
int i;
for(i=0; i<dstW-1; i+=2){
// vertical linear interpolation && yuv2rgb in a single step:
int Y1=yuvtab_2568[buf0[i]>>7];
int Y2=yuvtab_2568[buf0[i+1]>>7];
int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19);
int Cb= yuvtab_40cf[U];
int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
int Cr= yuvtab_3343[V];
((uint16_t*)dest)[i] =
clip_table16b[(Y1 + Cb) >>13] |
clip_table16g[(Y1 + Cg) >>13] |
clip_table16r[(Y1 + Cr) >>13];
((uint16_t*)dest)[i+1] =
clip_table16b[(Y2 + Cb) >>13] |
clip_table16g[(Y2 + Cg) >>13] |
clip_table16r[(Y2 + Cr) >>13];
}
}
else if(dstbpp==15)
{
int i;
for(i=0; i<dstW-1; i+=2){
// vertical linear interpolation && yuv2rgb in a single step:
int Y1=yuvtab_2568[buf0[i]>>7];
int Y2=yuvtab_2568[buf0[i+1]>>7];
int U=((uvbuf0[i>>1]*uvalpha1+uvbuf1[i>>1]*uvalpha)>>19);
int V=((uvbuf0[(i>>1)+2048]*uvalpha1+uvbuf1[(i>>1)+2048]*uvalpha)>>19);
int Cb= yuvtab_40cf[U];
int Cg= yuvtab_1a1e[V] + yuvtab_0c92[U];
int Cr= yuvtab_3343[V];
((uint16_t*)dest)[i] =
clip_table15b[(Y1 + Cb) >>13] |
clip_table15g[(Y1 + Cg) >>13] |
clip_table15r[(Y1 + Cr) >>13];
((uint16_t*)dest)[i+1] =
clip_table15b[(Y2 + Cb) >>13] |
clip_table15g[(Y2 + Cg) >>13] |
clip_table15r[(Y2 + Cr) >>13];
}
}
#endif
}
| true | FFmpeg | 28bf81c90d36a55cf76e2be913c5215ebebf61f2 |
6,785 | static void receive_from_chr_layer(SCLPConsoleLM *scon, const uint8_t *buf,
int size)
{
assert(size == 1);
if (*buf == '\r' || *buf == '\n') {
scon->event.event_pending = true;
return;
}
scon->buf[scon->length] = *buf;
scon->length += 1;
if (scon->echo) {
qemu_chr_fe_write(scon->chr, buf, size);
}
}
| true | qemu | 4f3ed190a673c0020c3ccebb4882ae4675cb5f4d |
6,786 | static void write_strip_header(CinepakEncContext *s, int y, int h, int keyframe, unsigned char *buf, int strip_size)
{
buf[0] = keyframe ? 0x11: 0x10;
AV_WB24(&buf[1], strip_size + STRIP_HEADER_SIZE);
AV_WB16(&buf[4], y);
AV_WB16(&buf[6], 0);
AV_WB16(&buf[8], h);
AV_WB16(&buf[10], s->w);
}
| true | FFmpeg | 7da9f4523159670d577a2808d4481e64008a8894 |
6,787 | int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
{
int r;
unsigned irq;
/* PowerPC Qemu tracks the various core input pins (interrupt, critical
* interrupt, reset, etc) in PPC-specific env->irq_input_state. */
if (run->ready_for_interrupt_injection &&
(env->interrupt_request & CPU_INTERRUPT_HARD) &&
(env->irq_input_state & (1<<PPC_INPUT_INT)))
{
/* For now KVM disregards the 'irq' argument. However, in the
* future KVM could cache it in-kernel to avoid a heavyweight exit
* when reading the UIC.
*/
irq = -1U;
dprintf("injected interrupt %d\n", irq);
r = kvm_vcpu_ioctl(env, KVM_INTERRUPT, &irq);
if (r < 0)
printf("cpu %d fail inject %x\n", env->cpu_index, irq);
/* We don't know if there are more interrupts pending after this. However,
* the guest will return to userspace in the course of handling this one
* anyways, so we will get a chance to deliver the rest. */
return 0; | true | qemu | c6a94ba5f9b8240f90ac2bf5ae5249bf5590c438 |
6,788 | static void ppc_spapr_reset(void)
{
/* flush out the hash table */
memset(spapr->htab, 0, spapr->htab_size);
qemu_devices_reset();
/* Load the fdt */
spapr_finalize_fdt(spapr, spapr->fdt_addr, spapr->rtas_addr,
spapr->rtas_size);
/* Set up the entry state */
first_cpu->gpr[3] = spapr->fdt_addr;
first_cpu->gpr[5] = 0;
first_cpu->halted = 0;
first_cpu->nip = spapr->entry_point;
}
| true | qemu | 7f763a5d994bbddb50705d2e50decdf52937521f |
6,789 | static uint32_t calc_rice_params(RiceContext *rc, int pmin, int pmax,
int32_t *data, int n, int pred_order)
{
int i;
uint32_t bits[MAX_PARTITION_ORDER+1];
int opt_porder;
RiceContext tmp_rc;
uint32_t *udata;
uint32_t sums[MAX_PARTITION_ORDER+1][MAX_PARTITIONS];
assert(pmin >= 0 && pmin <= MAX_PARTITION_ORDER);
assert(pmax >= 0 && pmax <= MAX_PARTITION_ORDER);
assert(pmin <= pmax);
udata = av_malloc(n * sizeof(uint32_t));
for (i = 0; i < n; i++)
udata[i] = (2*data[i]) ^ (data[i]>>31);
calc_sums(pmin, pmax, udata, n, pred_order, sums);
opt_porder = pmin;
bits[pmin] = UINT32_MAX;
for (i = pmin; i <= pmax; i++) {
bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums[i], n, pred_order);
if (bits[i] <= bits[opt_porder]) {
opt_porder = i;
*rc = tmp_rc;
}
}
av_freep(&udata);
return bits[opt_porder];
}
| true | FFmpeg | 5ff998a233d759d0de83ea6f95c383d03d25d88e |
6,790 | static int decode_header(PSDContext * s)
{
int signature, version, color_mode, compression;
int64_t len_section;
int ret = 0;
if (bytestream2_get_bytes_left(&s->gb) < 30) {/* File header section + color map data section length */
av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
return AVERROR_INVALIDDATA;
}
signature = bytestream2_get_le32(&s->gb);
if (signature != MKTAG('8','B','P','S')) {
av_log(s->avctx, AV_LOG_ERROR, "Wrong signature %d.\n", signature);
return AVERROR_INVALIDDATA;
}
version = bytestream2_get_be16(&s->gb);
if (version != 1) {
av_log(s->avctx, AV_LOG_ERROR, "Wrong version %d.\n", version);
return AVERROR_INVALIDDATA;
}
bytestream2_skip(&s->gb, 6);/* reserved */
s->channel_count = bytestream2_get_be16(&s->gb);
if ((s->channel_count < 1) || (s->channel_count > 56)) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid channel count %d.\n", s->channel_count);
return AVERROR_INVALIDDATA;
}
s->height = bytestream2_get_be32(&s->gb);
if ((s->height > 30000) && (s->avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)) {
av_log(s->avctx, AV_LOG_ERROR,
"Height > 30000 is experimental, add "
"'-strict %d' if you want to try to decode the picture.\n",
FF_COMPLIANCE_EXPERIMENTAL);
return AVERROR_EXPERIMENTAL;
}
s->width = bytestream2_get_be32(&s->gb);
if ((s->width > 30000) && (s->avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)) {
av_log(s->avctx, AV_LOG_ERROR,
"Width > 30000 is experimental, add "
"'-strict %d' if you want to try to decode the picture.\n",
FF_COMPLIANCE_EXPERIMENTAL);
return AVERROR_EXPERIMENTAL;
}
if ((ret = ff_set_dimensions(s->avctx, s->width, s->height)) < 0)
return ret;
s->channel_depth = bytestream2_get_be16(&s->gb);
color_mode = bytestream2_get_be16(&s->gb);
switch (color_mode) {
case 0:
s->color_mode = PSD_BITMAP;
break;
case 1:
s->color_mode = PSD_GRAYSCALE;
break;
case 2:
s->color_mode = PSD_INDEXED;
break;
case 3:
s->color_mode = PSD_RGB;
break;
case 4:
s->color_mode = PSD_CMYK;
break;
case 7:
s->color_mode = PSD_MULTICHANNEL;
break;
case 8:
s->color_mode = PSD_DUOTONE;
break;
case 9:
s->color_mode = PSD_LAB;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown color mode %d.\n", color_mode);
return AVERROR_INVALIDDATA;
}
/* color map data */
len_section = bytestream2_get_be32(&s->gb);
if (len_section < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Negative size for color map data section.\n");
return AVERROR_INVALIDDATA;
}
if (bytestream2_get_bytes_left(&s->gb) < (len_section + 4)) { /* section and len next section */
av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
return AVERROR_INVALIDDATA;
}
bytestream2_skip(&s->gb, len_section);
/* image ressources */
len_section = bytestream2_get_be32(&s->gb);
if (len_section < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Negative size for image ressources section.\n");
return AVERROR_INVALIDDATA;
}
if (bytestream2_get_bytes_left(&s->gb) < (len_section + 4)) { /* section and len next section */
av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
return AVERROR_INVALIDDATA;
}
bytestream2_skip(&s->gb, len_section);
/* layers and masks */
len_section = bytestream2_get_be32(&s->gb);
if (len_section < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Negative size for layers and masks data section.\n");
return AVERROR_INVALIDDATA;
}
if (bytestream2_get_bytes_left(&s->gb) < len_section) {
av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
return AVERROR_INVALIDDATA;
}
bytestream2_skip(&s->gb, len_section);
/* image section */
if (bytestream2_get_bytes_left(&s->gb) < 2) {
av_log(s->avctx, AV_LOG_ERROR, "File without image data section.\n");
return AVERROR_INVALIDDATA;
}
s->compression = bytestream2_get_be16(&s->gb);
switch (s->compression) {
case 0:
case 1:
break;
case 2:
avpriv_request_sample(s->avctx, "ZIP without predictor compression");
return AVERROR_PATCHWELCOME;
break;
case 3:
avpriv_request_sample(s->avctx, "ZIP with predictor compression");
return AVERROR_PATCHWELCOME;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression %d.\n", compression);
return AVERROR_INVALIDDATA;
}
return ret;
}
| true | FFmpeg | ec2f3b1f57fd5fc01c8ddb0c927112a18bcd7cba |
6,791 | static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
{
int isv34, unsync;
unsigned tlen;
char tag[5];
int64_t next, end = avio_tell(s->pb) + len;
int taghdrlen;
const char *reason = NULL;
AVIOContext pb;
unsigned char *buffer = NULL;
int buffer_size = 0;
switch (version) {
case 2:
if (flags & 0x40) {
reason = "compression";
goto error;
}
isv34 = 0;
taghdrlen = 6;
case 3:
case 4:
isv34 = 1;
taghdrlen = 10;
default:
reason = "version";
goto error;
}
unsync = flags & 0x80;
if (isv34 && flags & 0x40) /* Extended header present, just skip over it */
avio_skip(s->pb, get_size(s->pb, 4));
while (len >= taghdrlen) {
unsigned int tflags;
int tunsync = 0;
if (isv34) {
avio_read(s->pb, tag, 4);
tag[4] = 0;
if(version==3){
tlen = avio_rb32(s->pb);
}else
tlen = get_size(s->pb, 4);
tflags = avio_rb16(s->pb);
tunsync = tflags & ID3v2_FLAG_UNSYNCH;
} else {
avio_read(s->pb, tag, 3);
tag[3] = 0;
tlen = avio_rb24(s->pb);
}
if (tlen > (1<<28))
len -= taghdrlen + tlen;
if (len < 0)
next = avio_tell(s->pb) + tlen;
if (tflags & ID3v2_FLAG_DATALEN) {
avio_rb32(s->pb);
tlen -= 4;
}
if (tflags & (ID3v2_FLAG_ENCRYPTION | ID3v2_FLAG_COMPRESSION)) {
av_log(s, AV_LOG_WARNING, "Skipping encrypted/compressed ID3v2 frame %s.\n", tag);
avio_skip(s->pb, tlen);
} else if (tag[0] == 'T') {
if (unsync || tunsync) {
int i, j;
av_fast_malloc(&buffer, &buffer_size, tlen);
for (i = 0, j = 0; i < tlen; i++, j++) {
buffer[j] = avio_r8(s->pb);
if (j > 0 && !buffer[j] && buffer[j - 1] == 0xff) {
/* Unsynchronised byte, skip it */
j--;
}
}
ffio_init_context(&pb, buffer, j, 0, NULL, NULL, NULL, NULL);
read_ttag(s, &pb, j, tag);
} else {
read_ttag(s, s->pb, tlen, tag);
}
}
else if (!tag[0]) {
if (tag[1])
av_log(s, AV_LOG_WARNING, "invalid frame id, assuming padding");
avio_skip(s->pb, tlen);
}
/* Skip to end of tag */
avio_seek(s->pb, next, SEEK_SET);
}
if (version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */
end += 10;
error:
if (reason)
av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n", version, reason);
avio_seek(s->pb, end, SEEK_SET);
av_free(buffer);
return;
} | true | FFmpeg | 64be0d1edad630f5bc0f287022f5880de07915b2 |
6,792 | static int mpeg_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
UINT8 *buf, int buf_size)
{
Mpeg1Context *s = avctx->priv_data;
UINT8 *buf_end, *buf_ptr, *buf_start;
int len, start_code_found, ret, code, start_code, input_size;
AVPicture *picture = data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
dprintf("fill_buffer\n");
*data_size = 0;
/* special case for last picture */
if (buf_size == 0) {
if (s2->picture_number > 0) {
picture->data[0] = s2->next_picture[0];
picture->data[1] = s2->next_picture[1];
picture->data[2] = s2->next_picture[2];
picture->linesize[0] = s2->linesize;
picture->linesize[1] = s2->linesize / 2;
picture->linesize[2] = s2->linesize / 2;
*data_size = sizeof(AVPicture);
}
return 0;
}
buf_ptr = buf;
buf_end = buf + buf_size;
if (s->repeat_field % 2 == 1) {
s->repeat_field++;
//fprintf(stderr,"\nRepeating last frame: %d -> %d! pict: %d %d", avctx->frame_number-1, avctx->frame_number,
// s2->picture_number, s->repeat_field);
*data_size = sizeof(AVPicture);
goto the_end;
}
while (buf_ptr < buf_end) {
buf_start = buf_ptr;
/* find start next code */
code = find_start_code(&buf_ptr, buf_end, &s->header_state);
if (code >= 0) {
start_code_found = 1;
} else {
start_code_found = 0;
}
/* copy to buffer */
len = buf_ptr - buf_start;
if (len + (s->buf_ptr - s->buffer) > s->buffer_size) {
/* data too big : flush */
s->buf_ptr = s->buffer;
if (start_code_found)
s->start_code = code;
} else {
memcpy(s->buf_ptr, buf_start, len);
s->buf_ptr += len;
if (start_code_found) {
/* prepare data for next start code */
input_size = s->buf_ptr - s->buffer;
start_code = s->start_code;
s->buf_ptr = s->buffer;
s->start_code = code;
switch(start_code) {
case SEQ_START_CODE:
mpeg1_decode_sequence(avctx, s->buffer,
input_size);
break;
case PICTURE_START_CODE:
/* we have a complete image : we try to decompress it */
mpeg1_decode_picture(avctx,
s->buffer, input_size);
break;
case EXT_START_CODE:
mpeg_decode_extension(avctx,
s->buffer, input_size);
break;
default:
if (start_code >= SLICE_MIN_START_CODE &&
start_code <= SLICE_MAX_START_CODE) {
ret = mpeg_decode_slice(avctx, picture,
start_code, s->buffer, input_size);
if (ret == 1) {
/* got a picture: exit */
/* first check if we must repeat the frame */
if (s2->progressive_frame && s2->repeat_first_field) {
//fprintf(stderr,"\nRepeat this frame: %d! pict: %d",avctx->frame_number,s2->picture_number);
s2->repeat_first_field = 0;
s2->progressive_frame = 0;
if (++s->repeat_field > 2)
s->repeat_field = 0;
}
*data_size = sizeof(AVPicture);
goto the_end;
}
}
break;
}
}
}
}
the_end:
return buf_ptr - buf;
}
| true | FFmpeg | d7e9533aa06f4073a27812349b35ba5fede11ca1 |
6,793 | static int mp_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MotionPixelsContext *mp = avctx->priv_data;
GetBitContext gb;
int i, count1, count2, sz;
mp->frame.reference = 1;
mp->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
if (avctx->reget_buffer(avctx, &mp->frame)) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
}
/* le32 bitstream msb first */
av_fast_malloc(&mp->bswapbuf, &mp->bswapbuf_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!mp->bswapbuf)
return AVERROR(ENOMEM);
mp->dsp.bswap_buf((uint32_t *)mp->bswapbuf, (const uint32_t *)buf, buf_size / 4);
if (buf_size & 3)
memcpy(mp->bswapbuf + (buf_size & ~3), buf + (buf_size & ~3), buf_size & 3);
init_get_bits(&gb, mp->bswapbuf, buf_size * 8);
memset(mp->changes_map, 0, avctx->width * avctx->height);
for (i = !(avctx->extradata[1] & 2); i < 2; ++i) {
count1 = get_bits(&gb, 12);
count2 = get_bits(&gb, 12);
mp_read_changes_map(mp, &gb, count1, 8, i);
mp_read_changes_map(mp, &gb, count2, 4, i);
}
mp->codes_count = get_bits(&gb, 4);
if (mp->codes_count == 0)
goto end;
if (mp->changes_map[0] == 0) {
*(uint16_t *)mp->frame.data[0] = get_bits(&gb, 15);
mp->changes_map[0] = 1;
}
mp_read_codes_table(mp, &gb);
sz = get_bits(&gb, 18);
if (avctx->extradata[0] != 5)
sz += get_bits(&gb, 18);
if (sz == 0)
goto end;
init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0);
mp_decode_frame_helper(mp, &gb);
free_vlc(&mp->vlc);
end:
*data_size = sizeof(AVFrame);
*(AVFrame *)data = mp->frame;
return buf_size;
}
| true | FFmpeg | 69a0bce753a5d5556d5bc0888afe390e22611dd8 |
6,794 | static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
int nb_sectors, bool is_write, BdrvRequestFlags flags)
{
QEMUIOVector qiov;
struct iovec iov = {
.iov_base = (void *)buf,
.iov_len = nb_sectors * BDRV_SECTOR_SIZE,
};
qemu_iovec_init_external(&qiov, &iov, 1);
return bdrv_prwv_co(bs, sector_num << BDRV_SECTOR_BITS,
&qiov, is_write, flags); | true | qemu | da15ee5134f715adb07e3688a1c6e8b42cb6ac94 |
6,795 | int qemu_set_fd_handler(int fd,
IOHandler *fd_read,
IOHandler *fd_write,
void *opaque)
{
static IOTrampoline fd_trampolines[FD_SETSIZE];
IOTrampoline *tramp = &fd_trampolines[fd];
if (tramp->tag != 0) {
g_io_channel_unref(tramp->chan);
g_source_remove(tramp->tag);
}
if (opaque) {
GIOCondition cond = 0;
tramp->fd_read = fd_read;
tramp->fd_write = fd_write;
tramp->opaque = opaque;
if (fd_read) {
cond |= G_IO_IN | G_IO_ERR;
}
if (fd_write) {
cond |= G_IO_OUT | G_IO_ERR;
}
tramp->chan = g_io_channel_unix_new(fd);
tramp->tag = g_io_add_watch(tramp->chan, cond, fd_trampoline, tramp);
}
return 0;
}
| true | qemu | c82dc29a9112f34e0a51cad9a412cf6d9d05dfb2 |
6,796 | static void adb_register_types(void)
{
type_register_static(&adb_bus_type_info);
type_register_static(&adb_device_type_info);
type_register_static(&adb_kbd_type_info);
type_register_static(&adb_mouse_type_info);
}
| true | qemu | 77cb0f5aafc8e6d0c6d3c339f381c9b7921648e0 |
6,797 | uint32_t nand_getio(DeviceState *dev)
{
int offset;
uint32_t x = 0;
NANDFlashState *s = (NANDFlashState *) dev;
/* Allow sequential reading */
if (!s->iolen && s->cmd == NAND_CMD_READ0) {
offset = (int) (s->addr & ((1 << s->addr_shift) - 1)) + s->offset;
s->offset = 0;
s->blk_load(s, s->addr, offset);
if (s->gnd)
s->iolen = (1 << s->page_shift) - offset;
else
s->iolen = (1 << s->page_shift) + (1 << s->oob_shift) - offset;
}
if (s->ce || s->iolen <= 0)
return 0;
for (offset = s->buswidth; offset--;) {
x |= s->ioaddr[offset] << (offset << 3);
}
/* after receiving READ STATUS command all subsequent reads will
* return the status register value until another command is issued
*/
if (s->cmd != NAND_CMD_READSTATUS) {
s->addr += s->buswidth;
s->ioaddr += s->buswidth;
s->iolen -= s->buswidth;
}
return x;
}
| true | qemu | 1984745ea8ad309a06690a83e91d031d21d709ff |
6,798 | char *vnc_display_local_addr(DisplayState *ds)
{
VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;
return vnc_socket_local_addr("%s:%s", vs->lsock);
}
| true | qemu | 21ef45d71221b4577330fe3aacfb06afad91ad46 |
6,799 | static void av_noinline filter_mb_edgech( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {
const unsigned int index_a = 52 + qp + h->slice_alpha_c0_offset;
const int alpha = alpha_table[index_a];
const int beta = (beta_table+52)[qp + h->slice_beta_offset];
if (alpha ==0 || beta == 0) return;
if( bS[0] < 4 ) {
int8_t tc[4];
tc[0] = tc0_table[index_a][bS[0]]+1;
tc[1] = tc0_table[index_a][bS[1]]+1;
tc[2] = tc0_table[index_a][bS[2]]+1;
tc[3] = tc0_table[index_a][bS[3]]+1;
h->s.dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc);
} else {
h->s.dsp.h264_v_loop_filter_chroma_intra(pix, stride, alpha, beta);
}
}
| false | FFmpeg | 0c32e19d584ba6ddbc27f0a796260404daaf4b6a |
6,800 | static inline void RENAME(dering)(uint8_t src[], int stride, PPContext *c)
{
#if HAVE_7REGS && (TEMPLATE_PP_MMXEXT || TEMPLATE_PP_3DNOW)
DECLARE_ALIGNED(8, uint64_t, tmp)[3];
__asm__ volatile(
"pxor %%mm6, %%mm6 \n\t"
"pcmpeqb %%mm7, %%mm7 \n\t"
"movq %2, %%mm0 \n\t"
"punpcklbw %%mm6, %%mm0 \n\t"
"psrlw $1, %%mm0 \n\t"
"psubw %%mm7, %%mm0 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"movq %%mm0, %3 \n\t"
"lea (%0, %1), %%"REG_a" \n\t"
"lea (%%"REG_a", %1, 4), %%"REG_d" \n\t"
// 0 1 2 3 4 5 6 7 8 9
// %0 eax eax+%1 eax+2%1 %0+4%1 edx edx+%1 edx+2%1 %0+8%1 edx+4%1
#undef REAL_FIND_MIN_MAX
#undef FIND_MIN_MAX
#if TEMPLATE_PP_MMXEXT
#define REAL_FIND_MIN_MAX(addr)\
"movq " #addr ", %%mm0 \n\t"\
"pminub %%mm0, %%mm7 \n\t"\
"pmaxub %%mm0, %%mm6 \n\t"
#else
#define REAL_FIND_MIN_MAX(addr)\
"movq " #addr ", %%mm0 \n\t"\
"movq %%mm7, %%mm1 \n\t"\
"psubusb %%mm0, %%mm6 \n\t"\
"paddb %%mm0, %%mm6 \n\t"\
"psubusb %%mm0, %%mm1 \n\t"\
"psubb %%mm1, %%mm7 \n\t"
#endif
#define FIND_MIN_MAX(addr) REAL_FIND_MIN_MAX(addr)
FIND_MIN_MAX((%%REGa))
FIND_MIN_MAX((%%REGa, %1))
FIND_MIN_MAX((%%REGa, %1, 2))
FIND_MIN_MAX((%0, %1, 4))
FIND_MIN_MAX((%%REGd))
FIND_MIN_MAX((%%REGd, %1))
FIND_MIN_MAX((%%REGd, %1, 2))
FIND_MIN_MAX((%0, %1, 8))
"movq %%mm7, %%mm4 \n\t"
"psrlq $8, %%mm7 \n\t"
#if TEMPLATE_PP_MMXEXT
"pminub %%mm4, %%mm7 \n\t" // min of pixels
"pshufw $0xF9, %%mm7, %%mm4 \n\t"
"pminub %%mm4, %%mm7 \n\t" // min of pixels
"pshufw $0xFE, %%mm7, %%mm4 \n\t"
"pminub %%mm4, %%mm7 \n\t"
#else
"movq %%mm7, %%mm1 \n\t"
"psubusb %%mm4, %%mm1 \n\t"
"psubb %%mm1, %%mm7 \n\t"
"movq %%mm7, %%mm4 \n\t"
"psrlq $16, %%mm7 \n\t"
"movq %%mm7, %%mm1 \n\t"
"psubusb %%mm4, %%mm1 \n\t"
"psubb %%mm1, %%mm7 \n\t"
"movq %%mm7, %%mm4 \n\t"
"psrlq $32, %%mm7 \n\t"
"movq %%mm7, %%mm1 \n\t"
"psubusb %%mm4, %%mm1 \n\t"
"psubb %%mm1, %%mm7 \n\t"
#endif
"movq %%mm6, %%mm4 \n\t"
"psrlq $8, %%mm6 \n\t"
#if TEMPLATE_PP_MMXEXT
"pmaxub %%mm4, %%mm6 \n\t" // max of pixels
"pshufw $0xF9, %%mm6, %%mm4 \n\t"
"pmaxub %%mm4, %%mm6 \n\t"
"pshufw $0xFE, %%mm6, %%mm4 \n\t"
"pmaxub %%mm4, %%mm6 \n\t"
#else
"psubusb %%mm4, %%mm6 \n\t"
"paddb %%mm4, %%mm6 \n\t"
"movq %%mm6, %%mm4 \n\t"
"psrlq $16, %%mm6 \n\t"
"psubusb %%mm4, %%mm6 \n\t"
"paddb %%mm4, %%mm6 \n\t"
"movq %%mm6, %%mm4 \n\t"
"psrlq $32, %%mm6 \n\t"
"psubusb %%mm4, %%mm6 \n\t"
"paddb %%mm4, %%mm6 \n\t"
#endif
"movq %%mm6, %%mm0 \n\t" // max
"psubb %%mm7, %%mm6 \n\t" // max - min
"push %4 \n\t"
"movd %%mm6, %k4 \n\t"
"cmpb "MANGLE(deringThreshold)", %b4 \n\t"
"pop %4 \n\t"
" jb 1f \n\t"
PAVGB(%%mm0, %%mm7) // a=(max + min)/2
"punpcklbw %%mm7, %%mm7 \n\t"
"punpcklbw %%mm7, %%mm7 \n\t"
"punpcklbw %%mm7, %%mm7 \n\t"
"movq %%mm7, (%4) \n\t"
"movq (%0), %%mm0 \n\t" // L10
"movq %%mm0, %%mm1 \n\t" // L10
"movq %%mm0, %%mm2 \n\t" // L10
"psllq $8, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movd -4(%0), %%mm3 \n\t"
"movd 8(%0), %%mm4 \n\t"
"psrlq $24, %%mm3 \n\t"
"psllq $56, %%mm4 \n\t"
"por %%mm3, %%mm1 \n\t" // L00
"por %%mm4, %%mm2 \n\t" // L20
"movq %%mm1, %%mm3 \n\t" // L00
PAVGB(%%mm2, %%mm1) // (L20 + L00)/2
PAVGB(%%mm0, %%mm1) // (L20 + L00 + 2L10)/4
"psubusb %%mm7, %%mm0 \n\t"
"psubusb %%mm7, %%mm2 \n\t"
"psubusb %%mm7, %%mm3 \n\t"
"pcmpeqb "MANGLE(b00)", %%mm0 \n\t" // L10 > a ? 0 : -1
"pcmpeqb "MANGLE(b00)", %%mm2 \n\t" // L20 > a ? 0 : -1
"pcmpeqb "MANGLE(b00)", %%mm3 \n\t" // L00 > a ? 0 : -1
"paddb %%mm2, %%mm0 \n\t"
"paddb %%mm3, %%mm0 \n\t"
"movq (%%"REG_a"), %%mm2 \n\t" // L11
"movq %%mm2, %%mm3 \n\t" // L11
"movq %%mm2, %%mm4 \n\t" // L11
"psllq $8, %%mm3 \n\t"
"psrlq $8, %%mm4 \n\t"
"movd -4(%%"REG_a"), %%mm5 \n\t"
"movd 8(%%"REG_a"), %%mm6 \n\t"
"psrlq $24, %%mm5 \n\t"
"psllq $56, %%mm6 \n\t"
"por %%mm5, %%mm3 \n\t" // L01
"por %%mm6, %%mm4 \n\t" // L21
"movq %%mm3, %%mm5 \n\t" // L01
PAVGB(%%mm4, %%mm3) // (L21 + L01)/2
PAVGB(%%mm2, %%mm3) // (L21 + L01 + 2L11)/4
"psubusb %%mm7, %%mm2 \n\t"
"psubusb %%mm7, %%mm4 \n\t"
"psubusb %%mm7, %%mm5 \n\t"
"pcmpeqb "MANGLE(b00)", %%mm2 \n\t" // L11 > a ? 0 : -1
"pcmpeqb "MANGLE(b00)", %%mm4 \n\t" // L21 > a ? 0 : -1
"pcmpeqb "MANGLE(b00)", %%mm5 \n\t" // L01 > a ? 0 : -1
"paddb %%mm4, %%mm2 \n\t"
"paddb %%mm5, %%mm2 \n\t"
// 0, 2, 3, 1
#define REAL_DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1) \
"movq " #src ", " #sx " \n\t" /* src[0] */\
"movq " #sx ", " #lx " \n\t" /* src[0] */\
"movq " #sx ", " #t0 " \n\t" /* src[0] */\
"psllq $8, " #lx " \n\t"\
"psrlq $8, " #t0 " \n\t"\
"movd -4" #src ", " #t1 " \n\t"\
"psrlq $24, " #t1 " \n\t"\
"por " #t1 ", " #lx " \n\t" /* src[-1] */\
"movd 8" #src ", " #t1 " \n\t"\
"psllq $56, " #t1 " \n\t"\
"por " #t1 ", " #t0 " \n\t" /* src[+1] */\
"movq " #lx ", " #t1 " \n\t" /* src[-1] */\
PAVGB(t0, lx) /* (src[-1] + src[+1])/2 */\
PAVGB(sx, lx) /* (src[-1] + 2src[0] + src[+1])/4 */\
PAVGB(lx, pplx) \
"movq " #lx ", 8(%4) \n\t"\
"movq (%4), " #lx " \n\t"\
"psubusb " #lx ", " #t1 " \n\t"\
"psubusb " #lx ", " #t0 " \n\t"\
"psubusb " #lx ", " #sx " \n\t"\
"movq "MANGLE(b00)", " #lx " \n\t"\
"pcmpeqb " #lx ", " #t1 " \n\t" /* src[-1] > a ? 0 : -1*/\
"pcmpeqb " #lx ", " #t0 " \n\t" /* src[+1] > a ? 0 : -1*/\
"pcmpeqb " #lx ", " #sx " \n\t" /* src[0] > a ? 0 : -1*/\
"paddb " #t1 ", " #t0 " \n\t"\
"paddb " #t0 ", " #sx " \n\t"\
\
PAVGB(plx, pplx) /* filtered */\
"movq " #dst ", " #t0 " \n\t" /* dst */\
"movq " #t0 ", " #t1 " \n\t" /* dst */\
"psubusb %3, " #t0 " \n\t"\
"paddusb %3, " #t1 " \n\t"\
PMAXUB(t0, pplx)\
PMINUB(t1, pplx, t0)\
"paddb " #sx ", " #ppsx " \n\t"\
"paddb " #psx ", " #ppsx " \n\t"\
"#paddb "MANGLE(b02)", " #ppsx " \n\t"\
"pand "MANGLE(b08)", " #ppsx " \n\t"\
"pcmpeqb " #lx ", " #ppsx " \n\t"\
"pand " #ppsx ", " #pplx " \n\t"\
"pandn " #dst ", " #ppsx " \n\t"\
"por " #pplx ", " #ppsx " \n\t"\
"movq " #ppsx ", " #dst " \n\t"\
"movq 8(%4), " #lx " \n\t"
#define DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1) \
REAL_DERING_CORE(dst,src,ppsx,psx,sx,pplx,plx,lx,t0,t1)
/*
0000000
1111111
1111110
1111101
1111100
1111011
1111010
1111001
1111000
1110111
*/
//DERING_CORE(dst ,src ,ppsx ,psx ,sx ,pplx ,plx ,lx ,t0 ,t1)
DERING_CORE((%%REGa) ,(%%REGa, %1) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7)
DERING_CORE((%%REGa, %1) ,(%%REGa, %1, 2),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7)
DERING_CORE((%%REGa, %1, 2),(%0, %1, 4) ,%%mm4,%%mm0,%%mm2,%%mm5,%%mm1,%%mm3,%%mm6,%%mm7)
DERING_CORE((%0, %1, 4) ,(%%REGd) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7)
DERING_CORE((%%REGd) ,(%%REGd, %1) ,%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7)
DERING_CORE((%%REGd, %1) ,(%%REGd, %1, 2),%%mm4,%%mm0,%%mm2,%%mm5,%%mm1,%%mm3,%%mm6,%%mm7)
DERING_CORE((%%REGd, %1, 2),(%0, %1, 8) ,%%mm0,%%mm2,%%mm4,%%mm1,%%mm3,%%mm5,%%mm6,%%mm7)
DERING_CORE((%0, %1, 8) ,(%%REGd, %1, 4),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,%%mm6,%%mm7)
"1: \n\t"
: : "r" (src), "r" ((x86_reg)stride), "m" (c->pQPb), "m"(c->pQPb2), "q"(tmp)
: "%"REG_a, "%"REG_d
);
#else // HAVE_7REGS && (TEMPLATE_PP_MMXEXT || TEMPLATE_PP_3DNOW)
int y;
int min=255;
int max=0;
int avg;
uint8_t *p;
int s[10];
const int QP2= c->QP/2 + 1;
src --;
for(y=1; y<9; y++){
int x;
p= src + stride*y;
for(x=1; x<9; x++){
p++;
if(*p > max) max= *p;
if(*p < min) min= *p;
}
}
avg= (min + max + 1)>>1;
if(max - min <deringThreshold) return;
for(y=0; y<10; y++){
int t = 0;
if(src[stride*y + 0] > avg) t+= 1;
if(src[stride*y + 1] > avg) t+= 2;
if(src[stride*y + 2] > avg) t+= 4;
if(src[stride*y + 3] > avg) t+= 8;
if(src[stride*y + 4] > avg) t+= 16;
if(src[stride*y + 5] > avg) t+= 32;
if(src[stride*y + 6] > avg) t+= 64;
if(src[stride*y + 7] > avg) t+= 128;
if(src[stride*y + 8] > avg) t+= 256;
if(src[stride*y + 9] > avg) t+= 512;
t |= (~t)<<16;
t &= (t<<1) & (t>>1);
s[y] = t;
}
for(y=1; y<9; y++){
int t = s[y-1] & s[y] & s[y+1];
t|= t>>16;
s[y-1]= t;
}
for(y=1; y<9; y++){
int x;
int t = s[y-1];
p= src + stride*y;
for(x=1; x<9; x++){
p++;
if(t & (1<<x)){
int f= (*(p-stride-1)) + 2*(*(p-stride)) + (*(p-stride+1))
+2*(*(p -1)) + 4*(*p ) + 2*(*(p +1))
+(*(p+stride-1)) + 2*(*(p+stride)) + (*(p+stride+1));
f= (f + 8)>>4;
#ifdef DEBUG_DERING_THRESHOLD
__asm__ volatile("emms\n\t":);
{
static long long numPixels=0;
if(x!=1 && x!=8 && y!=1 && y!=8) numPixels++;
// if((max-min)<20 || (max-min)*QP<200)
// if((max-min)*QP < 500)
// if(max-min<QP/2)
if(max-min < 20){
static int numSkipped=0;
static int errorSum=0;
static int worstQP=0;
static int worstRange=0;
static int worstDiff=0;
int diff= (f - *p);
int absDiff= FFABS(diff);
int error= diff*diff;
if(x==1 || x==8 || y==1 || y==8) continue;
numSkipped++;
if(absDiff > worstDiff){
worstDiff= absDiff;
worstQP= QP;
worstRange= max-min;
}
errorSum+= error;
if(1024LL*1024LL*1024LL % numSkipped == 0){
av_log(c, AV_LOG_INFO, "sum:%1.3f, skip:%d, wQP:%d, "
"wRange:%d, wDiff:%d, relSkip:%1.3f\n",
(float)errorSum/numSkipped, numSkipped, worstQP, worstRange,
worstDiff, (float)numSkipped/numPixels);
}
}
}
#endif
if (*p + QP2 < f) *p= *p + QP2;
else if(*p - QP2 > f) *p= *p - QP2;
else *p=f;
}
}
}
#ifdef DEBUG_DERING_THRESHOLD
if(max-min < 20){
for(y=1; y<9; y++){
int x;
int t = 0;
p= src + stride*y;
for(x=1; x<9; x++){
p++;
*p = FFMIN(*p + 20, 255);
}
}
// src[0] = src[7]=src[stride*7]=src[stride*7 + 7]=255;
}
#endif
#endif //TEMPLATE_PP_MMXEXT || TEMPLATE_PP_3DNOW
}
| false | FFmpeg | 78d2d1e0270cfbd38022f63f477381ed4294d22c |
6,803 | static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr,
SBRData *ch_data, const int e_a[2])
{
int e, k, m;
// max gain limits : -3dB, 0dB, 3dB, inf dB (limiter off)
static const SoftFloat limgain[4] = { { 760155524, 0 }, { 0x20000000, 1 },
{ 758351638, 1 }, { 625000000, 34 } };
for (e = 0; e < ch_data->bs_num_env; e++) {
int delta = !((e == e_a[1]) || (e == e_a[0]));
for (k = 0; k < sbr->n_lim; k++) {
SoftFloat gain_boost, gain_max;
SoftFloat sum[2] = { FLOAT_0, FLOAT_0 };
for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
const SoftFloat temp = av_div_sf(sbr->e_origmapped[e][m],
av_add_sf(FLOAT_1, sbr->q_mapped[e][m]));
sbr->q_m[e][m] = av_sqrt_sf(av_mul_sf(temp, sbr->q_mapped[e][m]));
sbr->s_m[e][m] = av_sqrt_sf(av_mul_sf(temp, av_int2sf(ch_data->s_indexmapped[e + 1][m], 0)));
if (!sbr->s_mapped[e][m]) {
if (delta) {
sbr->gain[e][m] = av_sqrt_sf(av_div_sf(sbr->e_origmapped[e][m],
av_mul_sf(av_add_sf(FLOAT_1, sbr->e_curr[e][m]),
av_add_sf(FLOAT_1, sbr->q_mapped[e][m]))));
} else {
sbr->gain[e][m] = av_sqrt_sf(av_div_sf(sbr->e_origmapped[e][m],
av_add_sf(FLOAT_1, sbr->e_curr[e][m])));
}
} else {
sbr->gain[e][m] = av_sqrt_sf(
av_div_sf(
av_mul_sf(sbr->e_origmapped[e][m], sbr->q_mapped[e][m]),
av_mul_sf(
av_add_sf(FLOAT_1, sbr->e_curr[e][m]),
av_add_sf(FLOAT_1, sbr->q_mapped[e][m]))));
}
}
for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
sum[0] = av_add_sf(sum[0], sbr->e_origmapped[e][m]);
sum[1] = av_add_sf(sum[1], sbr->e_curr[e][m]);
}
gain_max = av_mul_sf(limgain[sbr->bs_limiter_gains],
av_sqrt_sf(
av_div_sf(
av_add_sf(FLOAT_EPSILON, sum[0]),
av_add_sf(FLOAT_EPSILON, sum[1]))));
if (av_gt_sf(gain_max, FLOAT_100000))
gain_max = FLOAT_100000;
for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
SoftFloat q_m_max = av_div_sf(
av_mul_sf(sbr->q_m[e][m], gain_max),
sbr->gain[e][m]);
if (av_gt_sf(sbr->q_m[e][m], q_m_max))
sbr->q_m[e][m] = q_m_max;
if (av_gt_sf(sbr->gain[e][m], gain_max))
sbr->gain[e][m] = gain_max;
}
sum[0] = sum[1] = FLOAT_0;
for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
sum[0] = av_add_sf(sum[0], sbr->e_origmapped[e][m]);
sum[1] = av_add_sf(sum[1],
av_mul_sf(
av_mul_sf(sbr->e_curr[e][m],
sbr->gain[e][m]),
sbr->gain[e][m]));
sum[1] = av_add_sf(sum[1],
av_mul_sf(sbr->s_m[e][m], sbr->s_m[e][m]));
if (delta && !sbr->s_m[e][m].mant)
sum[1] = av_add_sf(sum[1],
av_mul_sf(sbr->q_m[e][m], sbr->q_m[e][m]));
}
gain_boost = av_sqrt_sf(
av_div_sf(
av_add_sf(FLOAT_EPSILON, sum[0]),
av_add_sf(FLOAT_EPSILON, sum[1])));
if (av_gt_sf(gain_boost, FLOAT_1584893192))
gain_boost = FLOAT_1584893192;
for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
sbr->gain[e][m] = av_mul_sf(sbr->gain[e][m], gain_boost);
sbr->q_m[e][m] = av_mul_sf(sbr->q_m[e][m], gain_boost);
sbr->s_m[e][m] = av_mul_sf(sbr->s_m[e][m], gain_boost);
}
}
}
}
| false | FFmpeg | 8a024f6a43444a73a3cd8d70abedde426b4e1986 |
6,804 | x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
{
struct x11_grab *s = s1->priv_data;
Display *dpy = s->dpy;
XImage *image = s->image;
int x_off = s->x_off;
int y_off = s->y_off;
int64_t curtime, delay;
struct timespec ts;
/* Calculate the time of the next frame */
s->time_frame += INT64_C(1000000);
/* wait based on the frame rate */
for(;;) {
curtime = av_gettime();
delay = s->time_frame * av_q2d(s->time_base) - curtime;
if (delay <= 0) {
if (delay < INT64_C(-1000000) * av_q2d(s->time_base)) {
s->time_frame += INT64_C(1000000);
}
break;
}
ts.tv_sec = delay / 1000000;
ts.tv_nsec = (delay % 1000000) * 1000;
nanosleep(&ts, NULL);
}
av_init_packet(pkt);
pkt->data = image->data;
pkt->size = s->frame_size;
pkt->pts = curtime;
if(s->use_shm) {
if (!XShmGetImage(dpy, RootWindow(dpy, DefaultScreen(dpy)), image, x_off, y_off, AllPlanes)) {
av_log (s1, AV_LOG_INFO, "XShmGetImage() failed\n");
}
} else {
if (!xget_zpixmap(dpy, RootWindow(dpy, DefaultScreen(dpy)), image, x_off, y_off)) {
av_log (s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
}
}
if(!s->nomouse){
paint_mouse_pointer(image, s);
}
return s->frame_size;
}
| false | FFmpeg | ce558c8f590610fc68596ef0b4ac2a9d299fbcb2 |
6,805 | static int svq3_decode_slice_header(H264Context *h)
{
MpegEncContext *const s = (MpegEncContext *) h;
const int mb_xy = h->mb_xy;
int i, header;
header = get_bits(&s->gb, 8);
if (((header & 0x9F) != 1 && (header & 0x9F) != 2) || (header & 0x60) == 0) {
/* TODO: what? */
av_log(h->s.avctx, AV_LOG_ERROR, "unsupported slice header (%02X)\n", header);
return -1;
} else {
int length = (header >> 5) & 3;
h->next_slice_index = get_bits_count(&s->gb) + 8*show_bits(&s->gb, 8*length) + 8*length;
if (h->next_slice_index > s->gb.size_in_bits) {
av_log(h->s.avctx, AV_LOG_ERROR, "slice after bitstream end\n");
return -1;
}
s->gb.size_in_bits = h->next_slice_index - 8*(length - 1);
skip_bits(&s->gb, 8);
if (h->svq3_watermark_key) {
uint32_t header = AV_RL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1]);
AV_WL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1], header ^ h->svq3_watermark_key);
}
if (length > 0) {
memcpy((uint8_t *) &s->gb.buffer[get_bits_count(&s->gb) >> 3],
&s->gb.buffer[s->gb.size_in_bits >> 3], (length - 1));
}
skip_bits_long(&s->gb, 0);
}
if ((i = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || i >= 3){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal slice type %d \n", i);
return -1;
}
h->slice_type = golomb_to_pict_type[i];
if ((header & 0x9F) == 2) {
i = (s->mb_num < 64) ? 6 : (1 + av_log2 (s->mb_num - 1));
s->mb_skip_run = get_bits(&s->gb, i) - (s->mb_x + (s->mb_y * s->mb_width));
} else {
skip_bits1(&s->gb);
s->mb_skip_run = 0;
}
h->slice_num = get_bits(&s->gb, 8);
s->qscale = get_bits(&s->gb, 5);
s->adaptive_quant = get_bits1(&s->gb);
/* unknown fields */
skip_bits1(&s->gb);
if (h->unknown_svq3_flag) {
skip_bits1(&s->gb);
}
skip_bits1(&s->gb);
skip_bits(&s->gb, 2);
while (get_bits1(&s->gb)) {
skip_bits(&s->gb, 8);
}
/* reset intra predictors and invalidate motion vector references */
if (s->mb_x > 0) {
memset(h->intra4x4_pred_mode+8*h->mb2br_xy[mb_xy - 1 ]+3, -1, 4*sizeof(int8_t));
memset(h->intra4x4_pred_mode+8*h->mb2br_xy[mb_xy - s->mb_x] , -1, 8*sizeof(int8_t)*s->mb_x);
}
if (s->mb_y > 0) {
memset(h->intra4x4_pred_mode+8*h->mb2br_xy[mb_xy - s->mb_stride], -1, 8*sizeof(int8_t)*(s->mb_width - s->mb_x));
if (s->mb_x > 0) {
h->intra4x4_pred_mode[8*h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] = -1;
}
}
return 0;
}
| false | FFmpeg | 3b606e71c475d07d45b5a8cb0825ce35c61e635d |
6,806 | POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->fw_name = "PowerPC,POWER7+";
dc->desc = "POWER7+";
pcc->pvr = CPU_POWERPC_POWER7P_BASE;
pcc->pvr_mask = CPU_POWERPC_POWER7P_MASK;
pcc->init_proc = init_proc_POWER7;
pcc->check_pow = check_pow_nocheck;
pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
PPC_FLOAT_FRSQRTES |
PPC_FLOAT_STFIWX |
PPC_FLOAT_EXT |
PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
PPC_MEM_SYNC | PPC_MEM_EIEIO |
PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
PPC_64B | PPC_ALTIVEC |
PPC_SEGMENT_64B | PPC_SLBI |
PPC_POPCNTB | PPC_POPCNTWD;
pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 |
PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
PPC2_FP_TST_ISA206;
pcc->msr_mask = (1ull << MSR_SF) |
(1ull << MSR_VR) |
(1ull << MSR_VSX) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_SE) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PMM) |
(1ull << MSR_RI) |
(1ull << MSR_LE);
pcc->mmu_model = POWERPC_MMU_2_06;
#if defined(CONFIG_SOFTMMU)
pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;
#endif
pcc->excp_model = POWERPC_EXCP_POWER7;
pcc->bus_model = PPC_FLAGS_INPUT_POWER7;
pcc->bfd_mach = bfd_mach_ppc64;
pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |
POWERPC_FLAG_BE | POWERPC_FLAG_PMM |
POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |
POWERPC_FLAG_VSX;
pcc->l1_dcache_size = 0x8000;
pcc->l1_icache_size = 0x8000;
pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;
} | true | qemu | 8dfa3a5e85eca94a93b1495136f49c5776fd5ada |
6,807 | static uint16_t phys_section_add(MemoryRegionSection *section)
{
if (phys_sections_nb == phys_sections_nb_alloc) {
phys_sections_nb_alloc = MAX(phys_sections_nb_alloc * 2, 16);
phys_sections = g_renew(MemoryRegionSection, phys_sections,
phys_sections_nb_alloc);
}
phys_sections[phys_sections_nb] = *section;
return phys_sections_nb++;
} | true | qemu | 68f3f65b09a1ce8c82fac17911ffc3bb6031ebe4 |
6,808 | static int tta_read_header(AVFormatContext *s)
{
TTAContext *c = s->priv_data;
AVStream *st;
int i, channels, bps, samplerate;
uint64_t framepos, start_offset;
uint32_t datalen;
if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
ff_id3v1_read(s);
start_offset = avio_tell(s->pb);
if (avio_rl32(s->pb) != AV_RL32("TTA1"))
return -1; // not tta file
avio_skip(s->pb, 2); // FIXME: flags
channels = avio_rl16(s->pb);
bps = avio_rl16(s->pb);
samplerate = avio_rl32(s->pb);
if(samplerate <= 0 || samplerate > 1000000){
av_log(s, AV_LOG_ERROR, "nonsense samplerate\n");
return -1;
}
datalen = avio_rl32(s->pb);
if (!datalen) {
av_log(s, AV_LOG_ERROR, "invalid datalen\n");
return AVERROR_INVALIDDATA;
}
avio_skip(s->pb, 4); // header crc
c->frame_size = samplerate * 256 / 245;
c->last_frame_size = datalen % c->frame_size;
if (!c->last_frame_size)
c->last_frame_size = c->frame_size;
c->totalframes = datalen / c->frame_size + (c->last_frame_size < c->frame_size);
c->currentframe = 0;
if(c->totalframes >= UINT_MAX/sizeof(uint32_t) || c->totalframes <= 0){
av_log(s, AV_LOG_ERROR, "totalframes %d invalid\n", c->totalframes);
return -1;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, samplerate);
st->start_time = 0;
st->duration = datalen;
framepos = avio_tell(s->pb) + 4*c->totalframes + 4;
for (i = 0; i < c->totalframes; i++) {
uint32_t size = avio_rl32(s->pb);
av_add_index_entry(st, framepos, i * c->frame_size, size, 0,
AVINDEX_KEYFRAME);
framepos += size;
}
avio_skip(s->pb, 4); // seektable crc
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_TTA;
st->codec->channels = channels;
st->codec->sample_rate = samplerate;
st->codec->bits_per_coded_sample = bps;
st->codec->extradata_size = avio_tell(s->pb) - start_offset;
if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){
//this check is redundant as avio_read should fail
av_log(s, AV_LOG_ERROR, "extradata_size too large\n");
return -1;
}
st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) {
st->codec->extradata_size = 0;
return AVERROR(ENOMEM);
}
avio_seek(s->pb, start_offset, SEEK_SET);
avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
return 0;
}
| false | FFmpeg | c4e0e314248865830ec073e5a3ef08e0a40aabf2 |
6,813 | static void sub2video_update(InputStream *ist, AVSubtitle *sub)
{
int w = ist->sub2video.w, h = ist->sub2video.h;
AVFrame *frame = ist->sub2video.frame;
int8_t *dst;
int dst_linesize;
int num_rects, i;
int64_t pts, end_pts;
if (!frame)
return;
if (sub) {
pts = av_rescale_q(sub->pts + sub->start_display_time * 1000,
AV_TIME_BASE_Q, ist->st->time_base);
end_pts = av_rescale_q(sub->pts + sub->end_display_time * 1000,
AV_TIME_BASE_Q, ist->st->time_base);
num_rects = sub->num_rects;
} else {
pts = ist->sub2video.end_pts;
end_pts = INT64_MAX;
num_rects = 0;
}
if (sub2video_get_blank_frame(ist) < 0) {
av_log(ist->dec_ctx, AV_LOG_ERROR,
"Impossible to get a blank canvas.\n");
return;
}
dst = frame->data [0];
dst_linesize = frame->linesize[0];
for (i = 0; i < num_rects; i++)
sub2video_copy_rect(dst, dst_linesize, w, h, sub->rects[i]);
sub2video_push_ref(ist, pts);
ist->sub2video.end_pts = end_pts;
}
| true | FFmpeg | 59975de77741766df4cc48c66bc151a6c31f9291 |
6,817 | void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value)
{
if (cpu_sh4_is_cached (env, address))
{
memory_content *r = malloc (sizeof(memory_content));
r->address = address;
r->value = value;
r->next = NULL;
*(env->movcal_backup_tail) = r;
env->movcal_backup_tail = &(r->next);
}
}
| true | qemu | 01a720125f5e2f0a23d2682b39dead2fcc820066 |
6,819 | static inline uint16_t mipsdsp_lshift16(uint16_t a, uint8_t s,
CPUMIPSState *env)
{
uint8_t sign;
uint16_t discard;
if (s == 0) {
return a;
} else {
sign = (a >> 15) & 0x01;
if (sign != 0) {
discard = (((0x01 << (16 - s)) - 1) << s) |
((a >> (14 - (s - 1))) & ((0x01 << s) - 1));
} else {
discard = a >> (14 - (s - 1));
}
if ((discard != 0x0000) && (discard != 0xFFFF)) {
set_DSPControl_overflow_flag(1, 22, env);
}
return a << s;
}
}
| true | qemu | 29851ee7c8bd3fb8542e21cd0270c73132590350 |
6,820 | static ssize_t dump_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
DumpState *s = vc->opaque;
struct pcap_sf_pkthdr hdr;
int64_t ts;
int caplen;
/* Early return in case of previous error. */
if (s->fd < 0) {
return size;
}
ts = muldiv64(qemu_get_clock(vm_clock), 1000000, get_ticks_per_sec());
caplen = size > s->pcap_caplen ? s->pcap_caplen : size;
hdr.ts.tv_sec = ts / 1000000;
hdr.ts.tv_usec = ts % 1000000;
hdr.caplen = caplen;
hdr.len = size;
if (write(s->fd, &hdr, sizeof(hdr)) != sizeof(hdr) ||
write(s->fd, buf, caplen) != caplen) {
qemu_log("-net dump write error - stop dump\n");
close(s->fd);
s->fd = -1;
}
return size;
}
| true | qemu | 731d5856cbb9c160fe02b90cd3cf354ea4f52f34 |
6,821 | static int openpic_load(QEMUFile* f, void *opaque, int version_id)
{
OpenPICState *opp = (OpenPICState *)opaque;
unsigned int i;
if (version_id != 1) {
return -EINVAL;
}
qemu_get_be32s(f, &opp->gcr);
qemu_get_be32s(f, &opp->vir);
qemu_get_be32s(f, &opp->pir);
qemu_get_be32s(f, &opp->spve);
qemu_get_be32s(f, &opp->tfrr);
qemu_get_be32s(f, &opp->nb_cpus);
for (i = 0; i < opp->nb_cpus; i++) {
qemu_get_sbe32s(f, &opp->dst[i].ctpr);
openpic_load_IRQ_queue(f, &opp->dst[i].raised);
openpic_load_IRQ_queue(f, &opp->dst[i].servicing);
qemu_get_buffer(f, (uint8_t *)&opp->dst[i].outputs_active,
sizeof(opp->dst[i].outputs_active));
}
for (i = 0; i < OPENPIC_MAX_TMR; i++) {
qemu_get_be32s(f, &opp->timers[i].tccr);
qemu_get_be32s(f, &opp->timers[i].tbcr);
}
for (i = 0; i < opp->max_irq; i++) {
uint32_t val;
val = qemu_get_be32(f);
write_IRQreg_idr(opp, i, val);
val = qemu_get_be32(f);
write_IRQreg_ivpr(opp, i, val);
qemu_get_be32s(f, &opp->src[i].ivpr);
qemu_get_be32s(f, &opp->src[i].idr);
qemu_get_be32s(f, &opp->src[i].destmask);
qemu_get_sbe32s(f, &opp->src[i].last_cpu);
qemu_get_sbe32s(f, &opp->src[i].pending);
}
return 0;
}
| true | qemu | 73d963c0a75cb99c6aaa3f6f25e427aa0b35a02e |
6,822 | int vnc_tight_send_framebuffer_update(VncState *vs, int x, int y,
int w, int h)
{
int max_rows;
if (vs->clientds.pf.bytes_per_pixel == 4 && vs->clientds.pf.rmax == 0xFF &&
vs->clientds.pf.bmax == 0xFF && vs->clientds.pf.gmax == 0xFF) {
vs->tight_pixel24 = true;
} else {
vs->tight_pixel24 = false;
}
if (w * h < VNC_TIGHT_MIN_SPLIT_RECT_SIZE)
return send_rect_simple(vs, x, y, w, h);
/* Calculate maximum number of rows in one non-solid rectangle. */
max_rows = tight_conf[vs->tight_compression].max_rect_size;
max_rows /= MIN(tight_conf[vs->tight_compression].max_rect_width, w);
return find_large_solid_color_rect(vs, x, y, w, h, max_rows);
}
| false | qemu | 245f7b51c0ea04fb2224b1127430a096c91aee70 |
6,823 | static uint64_t fw_cfg_data_mem_read(void *opaque, hwaddr addr,
unsigned size)
{
return fw_cfg_read(opaque);
}
| false | qemu | cfaadf0e89e7c2a47462d5f96390c9a9b4de037c |
6,824 | static IOMMUTLBEntry amdvi_translate(MemoryRegion *iommu, hwaddr addr,
bool is_write)
{
AMDVIAddressSpace *as = container_of(iommu, AMDVIAddressSpace, iommu);
AMDVIState *s = as->iommu_state;
IOMMUTLBEntry ret = {
.target_as = &address_space_memory,
.iova = addr,
.translated_addr = 0,
.addr_mask = ~(hwaddr)0,
.perm = IOMMU_NONE
};
if (!s->enabled) {
/* AMDVI disabled - corresponds to iommu=off not
* failure to provide any parameter
*/
ret.iova = addr & AMDVI_PAGE_MASK_4K;
ret.translated_addr = addr & AMDVI_PAGE_MASK_4K;
ret.addr_mask = ~AMDVI_PAGE_MASK_4K;
ret.perm = IOMMU_RW;
return ret;
} else if (amdvi_is_interrupt_addr(addr)) {
ret.iova = addr & AMDVI_PAGE_MASK_4K;
ret.translated_addr = addr & AMDVI_PAGE_MASK_4K;
ret.addr_mask = ~AMDVI_PAGE_MASK_4K;
ret.perm = IOMMU_WO;
return ret;
}
amdvi_do_translate(as, addr, is_write, &ret);
trace_amdvi_translation_result(as->bus_num, PCI_SLOT(as->devfn),
PCI_FUNC(as->devfn), addr, ret.translated_addr);
return ret;
}
| false | qemu | bf55b7afce53718ef96f4e6616da62c0ccac37dd |
6,825 | void ahci_command_wait(AHCIQState *ahci, AHCICommand *cmd)
{
/* We can't rely on STS_BSY until the command has started processing.
* Therefore, we also use the Command Issue bit as indication of
* a command in-flight. */
while (BITSET(ahci_px_rreg(ahci, cmd->port, AHCI_PX_TFD),
AHCI_PX_TFD_STS_BSY) ||
BITSET(ahci_px_rreg(ahci, cmd->port, AHCI_PX_CI), (1 << cmd->slot))) {
usleep(50);
}
}
| false | qemu | 4de484698bdda6c5e093dfbe4368cdb364fdf87f |
6,827 | static inline int gen_intermediate_code_internal(TranslationBlock * tb,
int spc, CPUSPARCState *env)
{
target_ulong pc_start, last_pc;
uint16_t *gen_opc_end;
DisasContext dc1, *dc = &dc1;
int j, lj = -1;
memset(dc, 0, sizeof(DisasContext));
dc->tb = tb;
pc_start = tb->pc;
dc->pc = pc_start;
dc->npc = (target_ulong) tb->cs_base;
#if defined(CONFIG_USER_ONLY)
dc->mem_idx = 0;
#else
dc->mem_idx = ((env->psrs) != 0);
#endif
gen_opc_ptr = gen_opc_buf;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
gen_opparam_ptr = gen_opparam_buf;
env->access_type = ACCESS_CODE;
do {
if (env->nb_breakpoints > 0) {
for(j = 0; j < env->nb_breakpoints; j++) {
if (env->breakpoints[j] == dc->pc) {
gen_debug(dc, dc->pc);
break;
}
}
}
if (spc) {
if (loglevel > 0)
fprintf(logfile, "Search PC...\n");
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
gen_opc_pc[lj] = dc->pc;
gen_opc_npc[lj] = dc->npc;
gen_opc_instr_start[lj] = 1;
}
}
last_pc = dc->pc;
disas_sparc_insn(dc);
if (dc->is_br)
break;
/* if the next PC is different, we abort now */
if (dc->pc != (last_pc + 4))
break;
} while ((gen_opc_ptr < gen_opc_end) &&
(dc->pc - pc_start) < (TARGET_PAGE_SIZE - 32));
if (!dc->is_br) {
if (dc->pc != DYNAMIC_PC &&
(dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) {
/* static PC and NPC: we can use direct chaining */
gen_op_branch((long)tb, dc->pc, dc->npc);
} else {
if (dc->pc != DYNAMIC_PC)
gen_op_jmp_im(dc->pc);
save_npc(dc);
gen_op_movl_T0_0();
gen_op_exit_tb();
}
}
*gen_opc_ptr = INDEX_op_end;
if (spc) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
tb->size = 0;
#if 0
if (loglevel > 0) {
page_dump(logfile);
}
#endif
} else {
tb->size = dc->npc - pc_start;
}
#ifdef DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "--------------\n");
fprintf(logfile, "IN: %s\n", lookup_symbol((uint8_t *)pc_start));
disas(logfile, (uint8_t *)pc_start, last_pc + 4 - pc_start, 0, 0);
fprintf(logfile, "\n");
if (loglevel & CPU_LOG_TB_OP) {
fprintf(logfile, "OP:\n");
dump_ops(gen_opc_buf, gen_opparam_buf);
fprintf(logfile, "\n");
}
}
#endif
env->access_type = ACCESS_DATA;
return 0;
}
| false | qemu | b769d8fef6c06ddb39ef0337882a4f8872b9c2bc |
6,828 | static void term_hist_add(const char *cmdline)
{
char *hist_entry, *new_entry;
int idx;
if (cmdline[0] == '\0')
return;
new_entry = NULL;
if (term_hist_entry != -1) {
/* We were editing an existing history entry: replace it */
hist_entry = term_history[term_hist_entry];
idx = term_hist_entry;
if (strcmp(hist_entry, cmdline) == 0) {
goto same_entry;
}
}
/* Search cmdline in history buffers */
for (idx = 0; idx < TERM_MAX_CMDS; idx++) {
hist_entry = term_history[idx];
if (hist_entry == NULL)
break;
if (strcmp(hist_entry, cmdline) == 0) {
same_entry:
new_entry = hist_entry;
/* Put this entry at the end of history */
memmove(&term_history[idx], &term_history[idx + 1],
&term_history[TERM_MAX_CMDS] - &term_history[idx + 1]);
term_history[TERM_MAX_CMDS - 1] = NULL;
for (; idx < TERM_MAX_CMDS; idx++) {
if (term_history[idx] == NULL)
break;
}
break;
}
}
if (idx == TERM_MAX_CMDS) {
/* Need to get one free slot */
free(term_history[0]);
memcpy(term_history, &term_history[1],
&term_history[TERM_MAX_CMDS] - &term_history[1]);
term_history[TERM_MAX_CMDS - 1] = NULL;
idx = TERM_MAX_CMDS - 1;
}
if (new_entry == NULL)
new_entry = strdup(cmdline);
term_history[idx] = new_entry;
term_hist_entry = -1;
}
| false | qemu | 7e2515e87c41e2e658aaed466e11cbdf1ea8bcb1 |
6,830 | static av_cold int flic_decode_init(AVCodecContext *avctx)
{
FlicDecodeContext *s = avctx->priv_data;
unsigned char *fli_header = (unsigned char *)avctx->extradata;
int depth;
if (avctx->extradata_size != 12 &&
avctx->extradata_size != 128) {
av_log(avctx, AV_LOG_ERROR, "Expected extradata of 12 or 128 bytes\n");
return AVERROR_INVALIDDATA;
}
s->avctx = avctx;
s->fli_type = AV_RL16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */
depth = 0;
if (s->avctx->extradata_size == 12) {
/* special case for magic carpet FLIs */
s->fli_type = FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE;
depth = 8;
} else {
depth = AV_RL16(&fli_header[12]);
}
if (depth == 0) {
depth = 8; /* Some FLC generators set depth to zero, when they mean 8Bpp. Fix up here */
}
if ((s->fli_type == FLC_FLX_TYPE_CODE) && (depth == 16)) {
depth = 15; /* Original Autodesk FLX's say the depth is 16Bpp when it is really 15Bpp */
}
switch (depth) {
case 8 : avctx->pix_fmt = AV_PIX_FMT_PAL8; break;
case 15 : avctx->pix_fmt = AV_PIX_FMT_RGB555; break;
case 16 : avctx->pix_fmt = AV_PIX_FMT_RGB565; break;
case 24 : avctx->pix_fmt = AV_PIX_FMT_BGR24; /* Supposedly BGR, but havent any files to test with */
av_log(avctx, AV_LOG_ERROR, "24Bpp FLC/FLX is unsupported due to no test files.\n");
return AVERROR_PATCHWELCOME;
default :
av_log(avctx, AV_LOG_ERROR, "Unknown FLC/FLX depth of %d Bpp is unsupported.\n",depth);
return AVERROR_INVALIDDATA;
}
s->frame.data[0] = NULL;
s->new_palette = 0;
return 0;
}
| false | FFmpeg | 3b199d29cd597a3518136d78860e172060b9e83d |
6,831 | static int mmu_translate_region(CPUS390XState *env, target_ulong vaddr,
uint64_t asc, uint64_t entry, int level,
target_ulong *raddr, int *flags, int rw,
bool exc)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
uint64_t origin, offs, new_entry;
const int pchks[4] = {
PGM_SEGMENT_TRANS, PGM_REG_THIRD_TRANS,
PGM_REG_SEC_TRANS, PGM_REG_FIRST_TRANS
};
PTE_DPRINTF("%s: 0x%" PRIx64 "\n", __func__, entry);
origin = entry & _REGION_ENTRY_ORIGIN;
offs = (vaddr >> (17 + 11 * level / 4)) & 0x3ff8;
new_entry = ldq_phys(cs->as, origin + offs);
PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n",
__func__, origin, offs, new_entry);
if ((new_entry & _REGION_ENTRY_INV) != 0) {
DPRINTF("%s: invalid region\n", __func__);
trigger_page_fault(env, vaddr, pchks[level / 4], asc, rw, exc);
return -1;
}
if ((new_entry & _REGION_ENTRY_TYPE_MASK) != level) {
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw, exc);
return -1;
}
/* XXX region protection flags */
/* *flags &= ~PAGE_WRITE */
if (level == _ASCE_TYPE_SEGMENT) {
return mmu_translate_segment(env, vaddr, asc, new_entry, raddr, flags,
rw, exc);
}
/* Check region table offset and length */
offs = (vaddr >> (28 + 11 * (level - 4) / 4)) & 3;
if (offs < ((new_entry & _REGION_ENTRY_TF) >> 6)
|| offs > (new_entry & _REGION_ENTRY_LENGTH)) {
DPRINTF("%s: invalid offset or len (%lx)\n", __func__, new_entry);
trigger_page_fault(env, vaddr, pchks[level / 4 - 1], asc, rw, exc);
return -1;
}
/* yet another region */
return mmu_translate_region(env, vaddr, asc, new_entry, level - 4,
raddr, flags, rw, exc);
}
| false | qemu | 43d49b0115aef2ead5125d4aa9719852d47ef6fc |
6,832 | static const char *rpath(FsContext *ctx, const char *path)
{
/* FIXME: so wrong... */
static char buffer[4096];
snprintf(buffer, sizeof(buffer), "%s/%s", ctx->fs_root, path);
return buffer;
}
| false | qemu | fc22118d9bb56ec71655b936a29513c140e6c289 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.