id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
22,734 | e1000_can_receive(void *opaque)
{
E1000State *s = opaque;
return (s->mac_reg[RCTL] & E1000_RCTL_EN);
}
| false | qemu | e3f5ec2b5e92706e3b807059f79b1fb5d936e567 | e1000_can_receive(void *opaque)
{
E1000State *s = opaque;
return (s->mac_reg[RCTL] & E1000_RCTL_EN);
}
| {
"code": [],
"line_no": []
} | FUNC_0(void *VAR_0)
{
E1000State *s = VAR_0;
return (s->mac_reg[RCTL] & E1000_RCTL_EN);
}
| [
"FUNC_0(void *VAR_0)\n{",
"E1000State *s = VAR_0;",
"return (s->mac_reg[RCTL] & E1000_RCTL_EN);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
22,735 | static uint32_t intel_hda_mmio_readl(void *opaque, target_phys_addr_t addr)
{
IntelHDAState *d = opaque;
const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
return intel_hda_reg_read(d, reg, 0xffffffff);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t intel_hda_mmio_readl(void *opaque, target_phys_addr_t addr)
{
IntelHDAState *d = opaque;
const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
return intel_hda_reg_read(d, reg, 0xffffffff);
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
IntelHDAState *d = opaque;
const IntelHDAReg *VAR_0 = intel_hda_reg_find(d, addr);
return intel_hda_reg_read(d, VAR_0, 0xffffffff);
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"IntelHDAState *d = opaque;",
"const IntelHDAReg *VAR_0 = intel_hda_reg_find(d, addr);",
"return intel_hda_reg_read(d, VAR_0, 0xffffffff);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
]
] |
22,736 | void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
{
if (backing_hd) {
bdrv_ref(backing_hd);
}
if (bs->backing) {
assert(bs->backing_blocker);
bdrv_op_unblock_all(bs->backing->bs, bs->backing_blocker);
bdrv_unref_child(bs, bs->backing);
} else if (backing_hd) {
error_setg(&bs->backing_blocker,
"node is used as backing hd of '%s'",
bdrv_get_device_or_node_name(bs));
}
if (!backing_hd) {
error_free(bs->backing_blocker);
bs->backing_blocker = NULL;
bs->backing = NULL;
goto out;
}
bs->backing = bdrv_attach_child(bs, backing_hd, &child_backing);
bs->open_flags &= ~BDRV_O_NO_BACKING;
pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename);
pstrcpy(bs->backing_format, sizeof(bs->backing_format),
backing_hd->drv ? backing_hd->drv->format_name : "");
bdrv_op_block_all(backing_hd, bs->backing_blocker);
/* Otherwise we won't be able to commit due to check in bdrv_commit */
bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_COMMIT_TARGET,
bs->backing_blocker);
out:
bdrv_refresh_limits(bs, NULL);
}
| false | qemu | 260fecf13b0d30621dc88da03dc1b502b7358c6b | void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
{
if (backing_hd) {
bdrv_ref(backing_hd);
}
if (bs->backing) {
assert(bs->backing_blocker);
bdrv_op_unblock_all(bs->backing->bs, bs->backing_blocker);
bdrv_unref_child(bs, bs->backing);
} else if (backing_hd) {
error_setg(&bs->backing_blocker,
"node is used as backing hd of '%s'",
bdrv_get_device_or_node_name(bs));
}
if (!backing_hd) {
error_free(bs->backing_blocker);
bs->backing_blocker = NULL;
bs->backing = NULL;
goto out;
}
bs->backing = bdrv_attach_child(bs, backing_hd, &child_backing);
bs->open_flags &= ~BDRV_O_NO_BACKING;
pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename);
pstrcpy(bs->backing_format, sizeof(bs->backing_format),
backing_hd->drv ? backing_hd->drv->format_name : "");
bdrv_op_block_all(backing_hd, bs->backing_blocker);
bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_COMMIT_TARGET,
bs->backing_blocker);
out:
bdrv_refresh_limits(bs, NULL);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1)
{
if (VAR_1) {
bdrv_ref(VAR_1);
}
if (VAR_0->backing) {
assert(VAR_0->backing_blocker);
bdrv_op_unblock_all(VAR_0->backing->VAR_0, VAR_0->backing_blocker);
bdrv_unref_child(VAR_0, VAR_0->backing);
} else if (VAR_1) {
error_setg(&VAR_0->backing_blocker,
"node is used as backing hd of '%s'",
bdrv_get_device_or_node_name(VAR_0));
}
if (!VAR_1) {
error_free(VAR_0->backing_blocker);
VAR_0->backing_blocker = NULL;
VAR_0->backing = NULL;
goto out;
}
VAR_0->backing = bdrv_attach_child(VAR_0, VAR_1, &child_backing);
VAR_0->open_flags &= ~BDRV_O_NO_BACKING;
pstrcpy(VAR_0->backing_file, sizeof(VAR_0->backing_file), VAR_1->filename);
pstrcpy(VAR_0->backing_format, sizeof(VAR_0->backing_format),
VAR_1->drv ? VAR_1->drv->format_name : "");
bdrv_op_block_all(VAR_1, VAR_0->backing_blocker);
bdrv_op_unblock(VAR_1, BLOCK_OP_TYPE_COMMIT_TARGET,
VAR_0->backing_blocker);
out:
bdrv_refresh_limits(VAR_0, NULL);
}
| [
"void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1)\n{",
"if (VAR_1) {",
"bdrv_ref(VAR_1);",
"}",
"if (VAR_0->backing) {",
"assert(VAR_0->backing_blocker);",
"bdrv_op_unblock_all(VAR_0->backing->VAR_0, VAR_0->backing_blocker);",
"bdrv_unref_child(VAR_0, VAR_0->backing);",
"} else if (VAR_1) {",
"error_setg(&VAR_0->backing_blocker,\n\"node is used as backing hd of '%s'\",\nbdrv_get_device_or_node_name(VAR_0));",
"}",
"if (!VAR_1) {",
"error_free(VAR_0->backing_blocker);",
"VAR_0->backing_blocker = NULL;",
"VAR_0->backing = NULL;",
"goto out;",
"}",
"VAR_0->backing = bdrv_attach_child(VAR_0, VAR_1, &child_backing);",
"VAR_0->open_flags &= ~BDRV_O_NO_BACKING;",
"pstrcpy(VAR_0->backing_file, sizeof(VAR_0->backing_file), VAR_1->filename);",
"pstrcpy(VAR_0->backing_format, sizeof(VAR_0->backing_format),\nVAR_1->drv ? VAR_1->drv->format_name : \"\");",
"bdrv_op_block_all(VAR_1, VAR_0->backing_blocker);",
"bdrv_op_unblock(VAR_1, BLOCK_OP_TYPE_COMMIT_TARGET,\nVAR_0->backing_blocker);",
"out:\nbdrv_refresh_limits(VAR_0, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25,
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
57
],
[
61,
63
],
[
65,
67
],
[
69
]
] |
22,737 | void bdrv_parent_drained_end(BlockDriverState *bs)
{
BdrvChild *c;
QLIST_FOREACH(c, &bs->parents, next_parent) {
if (c->role->drained_end) {
c->role->drained_end(c);
}
}
}
| false | qemu | 02d213009d571bcd7171e3ff9234722a11d30d1b | void bdrv_parent_drained_end(BlockDriverState *bs)
{
BdrvChild *c;
QLIST_FOREACH(c, &bs->parents, next_parent) {
if (c->role->drained_end) {
c->role->drained_end(c);
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriverState *VAR_0)
{
BdrvChild *c;
QLIST_FOREACH(c, &VAR_0->parents, next_parent) {
if (c->role->drained_end) {
c->role->drained_end(c);
}
}
}
| [
"void FUNC_0(BlockDriverState *VAR_0)\n{",
"BdrvChild *c;",
"QLIST_FOREACH(c, &VAR_0->parents, next_parent) {",
"if (c->role->drained_end) {",
"c->role->drained_end(c);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
22,738 | static void virtio_ccw_crypto_instance_init(Object *obj)
{
VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(obj);
VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
ccw_dev->force_revision_1 = true;
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VIRTIO_CRYPTO);
object_property_add_alias(obj, "cryptodev", OBJECT(&dev->vdev),
"cryptodev", &error_abort);
}
| false | qemu | aa8f057e74ae08014736a690ff41f76c756f75f1 | static void virtio_ccw_crypto_instance_init(Object *obj)
{
VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(obj);
VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
ccw_dev->force_revision_1 = true;
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VIRTIO_CRYPTO);
object_property_add_alias(obj, "cryptodev", OBJECT(&dev->vdev),
"cryptodev", &error_abort);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0)
{
VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(VAR_0);
VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(VAR_0);
ccw_dev->force_revision_1 = true;
virtio_instance_init_common(VAR_0, &dev->vdev, sizeof(dev->vdev),
TYPE_VIRTIO_CRYPTO);
object_property_add_alias(VAR_0, "cryptodev", OBJECT(&dev->vdev),
"cryptodev", &error_abort);
}
| [
"static void FUNC_0(Object *VAR_0)\n{",
"VirtIOCryptoCcw *dev = VIRTIO_CRYPTO_CCW(VAR_0);",
"VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(VAR_0);",
"ccw_dev->force_revision_1 = true;",
"virtio_instance_init_common(VAR_0, &dev->vdev, sizeof(dev->vdev),\nTYPE_VIRTIO_CRYPTO);",
"object_property_add_alias(VAR_0, \"cryptodev\", OBJECT(&dev->vdev),\n\"cryptodev\", &error_abort);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
19,
21
],
[
23
]
] |
22,740 | static void gen_bxx(DisasContext *dc, uint32_t code, uint32_t flags)
{
I_TYPE(instr, code);
TCGLabel *l1 = gen_new_label();
tcg_gen_brcond_tl(flags, dc->cpu_R[instr.a], dc->cpu_R[instr.b], l1);
gen_goto_tb(dc, 0, dc->pc + 4);
gen_set_label(l1);
gen_goto_tb(dc, 1, dc->pc + 4 + (instr.imm16s & -4));
dc->is_jmp = DISAS_TB_JUMP;
}
| true | qemu | 4ae4b609ee2d5bcc9df6c03c21dc1fed527aada1 | static void gen_bxx(DisasContext *dc, uint32_t code, uint32_t flags)
{
I_TYPE(instr, code);
TCGLabel *l1 = gen_new_label();
tcg_gen_brcond_tl(flags, dc->cpu_R[instr.a], dc->cpu_R[instr.b], l1);
gen_goto_tb(dc, 0, dc->pc + 4);
gen_set_label(l1);
gen_goto_tb(dc, 1, dc->pc + 4 + (instr.imm16s & -4));
dc->is_jmp = DISAS_TB_JUMP;
}
| {
"code": [
" gen_goto_tb(dc, 1, dc->pc + 4 + (instr.imm16s & -4));"
],
"line_no": [
17
]
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, uint32_t VAR_2)
{
I_TYPE(instr, VAR_1);
TCGLabel *l1 = gen_new_label();
tcg_gen_brcond_tl(VAR_2, VAR_0->cpu_R[instr.a], VAR_0->cpu_R[instr.b], l1);
gen_goto_tb(VAR_0, 0, VAR_0->pc + 4);
gen_set_label(l1);
gen_goto_tb(VAR_0, 1, VAR_0->pc + 4 + (instr.imm16s & -4));
VAR_0->is_jmp = DISAS_TB_JUMP;
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{",
"I_TYPE(instr, VAR_1);",
"TCGLabel *l1 = gen_new_label();",
"tcg_gen_brcond_tl(VAR_2, VAR_0->cpu_R[instr.a], VAR_0->cpu_R[instr.b], l1);",
"gen_goto_tb(VAR_0, 0, VAR_0->pc + 4);",
"gen_set_label(l1);",
"gen_goto_tb(VAR_0, 1, VAR_0->pc + 4 + (instr.imm16s & -4));",
"VAR_0->is_jmp = DISAS_TB_JUMP;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
22,742 | static int flic_decode_frame_8BPP(AVCodecContext *avctx,
void *data, int *got_frame,
const uint8_t *buf, int buf_size)
{
FlicDecodeContext *s = avctx->priv_data;
GetByteContext g2;
int pixel_ptr;
int palette_ptr;
unsigned char palette_idx1;
unsigned char palette_idx2;
unsigned int frame_size;
int num_chunks;
unsigned int chunk_size;
int chunk_type;
int i, j, ret;
int color_packets;
int color_changes;
int color_shift;
unsigned char r, g, b;
int lines;
int compressed_lines;
int starting_line;
signed short line_packets;
int y_ptr;
int byte_run;
int pixel_skip;
int pixel_countdown;
unsigned char *pixels;
unsigned int pixel_limit;
bytestream2_init(&g2, buf, buf_size);
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
pixels = s->frame->data[0];
pixel_limit = s->avctx->height * s->frame->linesize[0];
if (buf_size < 16 || buf_size > INT_MAX - (3 * 256 + AV_INPUT_BUFFER_PADDING_SIZE))
frame_size = bytestream2_get_le32(&g2);
if (frame_size > buf_size)
frame_size = buf_size;
bytestream2_skip(&g2, 2); /* skip the magic number */
num_chunks = bytestream2_get_le16(&g2);
bytestream2_skip(&g2, 8); /* skip padding */
frame_size -= 16;
/* iterate through the chunks */
while ((frame_size >= 6) && (num_chunks > 0) &&
bytestream2_get_bytes_left(&g2) >= 4) {
int stream_ptr_after_chunk;
chunk_size = bytestream2_get_le32(&g2);
if (chunk_size > frame_size) {
av_log(avctx, AV_LOG_WARNING,
"Invalid chunk_size = %u > frame_size = %u\n", chunk_size, frame_size);
chunk_size = frame_size;
}
stream_ptr_after_chunk = bytestream2_tell(&g2) - 4 + chunk_size;
chunk_type = bytestream2_get_le16(&g2);
switch (chunk_type) {
case FLI_256_COLOR:
case FLI_COLOR:
/* check special case: If this file is from the Magic Carpet
* game and uses 6-bit colors even though it reports 256-color
* chunks in a 0xAF12-type file (fli_type is set to 0xAF13 during
* initialization) */
if ((chunk_type == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE))
color_shift = 0;
else
color_shift = 2;
/* set up the palette */
color_packets = bytestream2_get_le16(&g2);
palette_ptr = 0;
for (i = 0; i < color_packets; i++) {
/* first byte is how many colors to skip */
palette_ptr += bytestream2_get_byte(&g2);
/* next byte indicates how many entries to change */
color_changes = bytestream2_get_byte(&g2);
/* if there are 0 color changes, there are actually 256 */
if (color_changes == 0)
color_changes = 256;
if (bytestream2_tell(&g2) + color_changes * 3 > stream_ptr_after_chunk)
break;
for (j = 0; j < color_changes; j++) {
unsigned int entry;
/* wrap around, for good measure */
if ((unsigned)palette_ptr >= 256)
palette_ptr = 0;
r = bytestream2_get_byte(&g2) << color_shift;
g = bytestream2_get_byte(&g2) << color_shift;
b = bytestream2_get_byte(&g2) << color_shift;
entry = 0xFFU << 24 | r << 16 | g << 8 | b;
if (color_shift == 2)
entry |= entry >> 6 & 0x30303;
if (s->palette[palette_ptr] != entry)
s->new_palette = 1;
s->palette[palette_ptr++] = entry;
}
}
break;
case FLI_DELTA:
y_ptr = 0;
compressed_lines = bytestream2_get_le16(&g2);
while (compressed_lines > 0) {
if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk)
break;
line_packets = bytestream2_get_le16(&g2);
if ((line_packets & 0xC000) == 0xC000) {
// line skip opcode
line_packets = -line_packets;
y_ptr += line_packets * s->frame->linesize[0];
} else if ((line_packets & 0xC000) == 0x4000) {
av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets);
} else if ((line_packets & 0xC000) == 0x8000) {
// "last byte" opcode
pixel_ptr= y_ptr + s->frame->linesize[0] - 1;
CHECK_PIXEL_PTR(0);
pixels[pixel_ptr] = line_packets & 0xff;
} else {
compressed_lines--;
pixel_ptr = y_ptr;
CHECK_PIXEL_PTR(0);
pixel_countdown = s->avctx->width;
for (i = 0; i < line_packets; i++) {
if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk)
break;
/* account for the skip bytes */
pixel_skip = bytestream2_get_byte(&g2);
pixel_ptr += pixel_skip;
pixel_countdown -= pixel_skip;
byte_run = sign_extend(bytestream2_get_byte(&g2), 8);
if (byte_run < 0) {
byte_run = -byte_run;
palette_idx1 = bytestream2_get_byte(&g2);
palette_idx2 = bytestream2_get_byte(&g2);
CHECK_PIXEL_PTR(byte_run * 2);
for (j = 0; j < byte_run; j++, pixel_countdown -= 2) {
pixels[pixel_ptr++] = palette_idx1;
pixels[pixel_ptr++] = palette_idx2;
}
} else {
CHECK_PIXEL_PTR(byte_run * 2);
if (bytestream2_tell(&g2) + byte_run * 2 > stream_ptr_after_chunk)
break;
for (j = 0; j < byte_run * 2; j++, pixel_countdown--) {
pixels[pixel_ptr++] = bytestream2_get_byte(&g2);
}
}
}
y_ptr += s->frame->linesize[0];
}
}
break;
case FLI_LC:
/* line compressed */
starting_line = bytestream2_get_le16(&g2);
y_ptr = 0;
y_ptr += starting_line * s->frame->linesize[0];
compressed_lines = bytestream2_get_le16(&g2);
while (compressed_lines > 0) {
pixel_ptr = y_ptr;
CHECK_PIXEL_PTR(0);
pixel_countdown = s->avctx->width;
if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk)
break;
line_packets = bytestream2_get_byte(&g2);
if (line_packets > 0) {
for (i = 0; i < line_packets; i++) {
/* account for the skip bytes */
if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk)
break;
pixel_skip = bytestream2_get_byte(&g2);
pixel_ptr += pixel_skip;
pixel_countdown -= pixel_skip;
byte_run = sign_extend(bytestream2_get_byte(&g2),8);
if (byte_run > 0) {
CHECK_PIXEL_PTR(byte_run);
if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk)
break;
for (j = 0; j < byte_run; j++, pixel_countdown--) {
pixels[pixel_ptr++] = bytestream2_get_byte(&g2);
}
} else if (byte_run < 0) {
byte_run = -byte_run;
palette_idx1 = bytestream2_get_byte(&g2);
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++, pixel_countdown--) {
pixels[pixel_ptr++] = palette_idx1;
}
}
}
}
y_ptr += s->frame->linesize[0];
compressed_lines--;
}
break;
case FLI_BLACK:
/* set the whole frame to color 0 (which is usually black) */
memset(pixels, 0,
s->frame->linesize[0] * s->avctx->height);
break;
case FLI_BRUN:
/* Byte run compression: This chunk type only occurs in the first
* FLI frame and it will update the entire frame. */
y_ptr = 0;
for (lines = 0; lines < s->avctx->height; lines++) {
pixel_ptr = y_ptr;
/* disregard the line packets; instead, iterate through all
* pixels on a row */
bytestream2_skip(&g2, 1);
pixel_countdown = s->avctx->width;
while (pixel_countdown > 0) {
if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk)
break;
byte_run = sign_extend(bytestream2_get_byte(&g2), 8);
if (!byte_run) {
av_log(avctx, AV_LOG_ERROR, "Invalid byte run value.\n");
}
if (byte_run > 0) {
palette_idx1 = bytestream2_get_byte(&g2);
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++) {
pixels[pixel_ptr++] = palette_idx1;
pixel_countdown--;
if (pixel_countdown < 0)
av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
pixel_countdown, lines);
}
} else { /* copy bytes if byte_run < 0 */
byte_run = -byte_run;
CHECK_PIXEL_PTR(byte_run);
if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk)
break;
for (j = 0; j < byte_run; j++) {
pixels[pixel_ptr++] = bytestream2_get_byte(&g2);
pixel_countdown--;
if (pixel_countdown < 0)
av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
pixel_countdown, lines);
}
}
}
y_ptr += s->frame->linesize[0];
}
break;
case FLI_COPY:
/* copy the chunk (uncompressed frame) */
if (chunk_size - 6 != FFALIGN(s->avctx->width, 4) * s->avctx->height) {
av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \
"has incorrect size, skipping chunk\n", chunk_size - 6);
bytestream2_skip(&g2, chunk_size - 6);
} else {
for (y_ptr = 0; y_ptr < s->frame->linesize[0] * s->avctx->height;
y_ptr += s->frame->linesize[0]) {
bytestream2_get_buffer(&g2, &pixels[y_ptr],
s->avctx->width);
if (s->avctx->width & 3)
bytestream2_skip(&g2, 4 - (s->avctx->width & 3));
}
}
break;
case FLI_MINI:
/* some sort of a thumbnail? disregard this chunk... */
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", chunk_type);
break;
}
if (stream_ptr_after_chunk - bytestream2_tell(&g2) >= 0) {
bytestream2_skip(&g2, stream_ptr_after_chunk - bytestream2_tell(&g2));
} else {
av_log(avctx, AV_LOG_ERROR, "Chunk overread\n");
break;
}
frame_size -= chunk_size;
num_chunks--;
}
/* by the end of the chunk, the stream ptr should equal the frame
* size (minus 1 or 2, possibly); if it doesn't, issue a warning */
if (bytestream2_get_bytes_left(&g2) > 2)
av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \
"and final chunk ptr = %d\n", buf_size,
buf_size - bytestream2_get_bytes_left(&g2));
/* make the palette available on the way out */
memcpy(s->frame->data[1], s->palette, AVPALETTE_SIZE);
if (s->new_palette) {
s->frame->palette_has_changed = 1;
s->new_palette = 0;
}
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
return buf_size;
} | true | FFmpeg | 355e27e24dc88d6ba8f27501a34925d9d937a399 | static int flic_decode_frame_8BPP(AVCodecContext *avctx,
void *data, int *got_frame,
const uint8_t *buf, int buf_size)
{
FlicDecodeContext *s = avctx->priv_data;
GetByteContext g2;
int pixel_ptr;
int palette_ptr;
unsigned char palette_idx1;
unsigned char palette_idx2;
unsigned int frame_size;
int num_chunks;
unsigned int chunk_size;
int chunk_type;
int i, j, ret;
int color_packets;
int color_changes;
int color_shift;
unsigned char r, g, b;
int lines;
int compressed_lines;
int starting_line;
signed short line_packets;
int y_ptr;
int byte_run;
int pixel_skip;
int pixel_countdown;
unsigned char *pixels;
unsigned int pixel_limit;
bytestream2_init(&g2, buf, buf_size);
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
pixels = s->frame->data[0];
pixel_limit = s->avctx->height * s->frame->linesize[0];
if (buf_size < 16 || buf_size > INT_MAX - (3 * 256 + AV_INPUT_BUFFER_PADDING_SIZE))
frame_size = bytestream2_get_le32(&g2);
if (frame_size > buf_size)
frame_size = buf_size;
bytestream2_skip(&g2, 2);
num_chunks = bytestream2_get_le16(&g2);
bytestream2_skip(&g2, 8);
frame_size -= 16;
while ((frame_size >= 6) && (num_chunks > 0) &&
bytestream2_get_bytes_left(&g2) >= 4) {
int stream_ptr_after_chunk;
chunk_size = bytestream2_get_le32(&g2);
if (chunk_size > frame_size) {
av_log(avctx, AV_LOG_WARNING,
"Invalid chunk_size = %u > frame_size = %u\n", chunk_size, frame_size);
chunk_size = frame_size;
}
stream_ptr_after_chunk = bytestream2_tell(&g2) - 4 + chunk_size;
chunk_type = bytestream2_get_le16(&g2);
switch (chunk_type) {
case FLI_256_COLOR:
case FLI_COLOR:
if ((chunk_type == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE))
color_shift = 0;
else
color_shift = 2;
color_packets = bytestream2_get_le16(&g2);
palette_ptr = 0;
for (i = 0; i < color_packets; i++) {
palette_ptr += bytestream2_get_byte(&g2);
color_changes = bytestream2_get_byte(&g2);
if (color_changes == 0)
color_changes = 256;
if (bytestream2_tell(&g2) + color_changes * 3 > stream_ptr_after_chunk)
break;
for (j = 0; j < color_changes; j++) {
unsigned int entry;
if ((unsigned)palette_ptr >= 256)
palette_ptr = 0;
r = bytestream2_get_byte(&g2) << color_shift;
g = bytestream2_get_byte(&g2) << color_shift;
b = bytestream2_get_byte(&g2) << color_shift;
entry = 0xFFU << 24 | r << 16 | g << 8 | b;
if (color_shift == 2)
entry |= entry >> 6 & 0x30303;
if (s->palette[palette_ptr] != entry)
s->new_palette = 1;
s->palette[palette_ptr++] = entry;
}
}
break;
case FLI_DELTA:
y_ptr = 0;
compressed_lines = bytestream2_get_le16(&g2);
while (compressed_lines > 0) {
if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk)
break;
line_packets = bytestream2_get_le16(&g2);
if ((line_packets & 0xC000) == 0xC000) {
line_packets = -line_packets;
y_ptr += line_packets * s->frame->linesize[0];
} else if ((line_packets & 0xC000) == 0x4000) {
av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets);
} else if ((line_packets & 0xC000) == 0x8000) {
pixel_ptr= y_ptr + s->frame->linesize[0] - 1;
CHECK_PIXEL_PTR(0);
pixels[pixel_ptr] = line_packets & 0xff;
} else {
compressed_lines--;
pixel_ptr = y_ptr;
CHECK_PIXEL_PTR(0);
pixel_countdown = s->avctx->width;
for (i = 0; i < line_packets; i++) {
if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk)
break;
pixel_skip = bytestream2_get_byte(&g2);
pixel_ptr += pixel_skip;
pixel_countdown -= pixel_skip;
byte_run = sign_extend(bytestream2_get_byte(&g2), 8);
if (byte_run < 0) {
byte_run = -byte_run;
palette_idx1 = bytestream2_get_byte(&g2);
palette_idx2 = bytestream2_get_byte(&g2);
CHECK_PIXEL_PTR(byte_run * 2);
for (j = 0; j < byte_run; j++, pixel_countdown -= 2) {
pixels[pixel_ptr++] = palette_idx1;
pixels[pixel_ptr++] = palette_idx2;
}
} else {
CHECK_PIXEL_PTR(byte_run * 2);
if (bytestream2_tell(&g2) + byte_run * 2 > stream_ptr_after_chunk)
break;
for (j = 0; j < byte_run * 2; j++, pixel_countdown--) {
pixels[pixel_ptr++] = bytestream2_get_byte(&g2);
}
}
}
y_ptr += s->frame->linesize[0];
}
}
break;
case FLI_LC:
starting_line = bytestream2_get_le16(&g2);
y_ptr = 0;
y_ptr += starting_line * s->frame->linesize[0];
compressed_lines = bytestream2_get_le16(&g2);
while (compressed_lines > 0) {
pixel_ptr = y_ptr;
CHECK_PIXEL_PTR(0);
pixel_countdown = s->avctx->width;
if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk)
break;
line_packets = bytestream2_get_byte(&g2);
if (line_packets > 0) {
for (i = 0; i < line_packets; i++) {
if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk)
break;
pixel_skip = bytestream2_get_byte(&g2);
pixel_ptr += pixel_skip;
pixel_countdown -= pixel_skip;
byte_run = sign_extend(bytestream2_get_byte(&g2),8);
if (byte_run > 0) {
CHECK_PIXEL_PTR(byte_run);
if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk)
break;
for (j = 0; j < byte_run; j++, pixel_countdown--) {
pixels[pixel_ptr++] = bytestream2_get_byte(&g2);
}
} else if (byte_run < 0) {
byte_run = -byte_run;
palette_idx1 = bytestream2_get_byte(&g2);
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++, pixel_countdown--) {
pixels[pixel_ptr++] = palette_idx1;
}
}
}
}
y_ptr += s->frame->linesize[0];
compressed_lines--;
}
break;
case FLI_BLACK:
memset(pixels, 0,
s->frame->linesize[0] * s->avctx->height);
break;
case FLI_BRUN:
y_ptr = 0;
for (lines = 0; lines < s->avctx->height; lines++) {
pixel_ptr = y_ptr;
bytestream2_skip(&g2, 1);
pixel_countdown = s->avctx->width;
while (pixel_countdown > 0) {
if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk)
break;
byte_run = sign_extend(bytestream2_get_byte(&g2), 8);
if (!byte_run) {
av_log(avctx, AV_LOG_ERROR, "Invalid byte run value.\n");
}
if (byte_run > 0) {
palette_idx1 = bytestream2_get_byte(&g2);
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++) {
pixels[pixel_ptr++] = palette_idx1;
pixel_countdown--;
if (pixel_countdown < 0)
av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
pixel_countdown, lines);
}
} else {
byte_run = -byte_run;
CHECK_PIXEL_PTR(byte_run);
if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk)
break;
for (j = 0; j < byte_run; j++) {
pixels[pixel_ptr++] = bytestream2_get_byte(&g2);
pixel_countdown--;
if (pixel_countdown < 0)
av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
pixel_countdown, lines);
}
}
}
y_ptr += s->frame->linesize[0];
}
break;
case FLI_COPY:
if (chunk_size - 6 != FFALIGN(s->avctx->width, 4) * s->avctx->height) {
av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \
"has incorrect size, skipping chunk\n", chunk_size - 6);
bytestream2_skip(&g2, chunk_size - 6);
} else {
for (y_ptr = 0; y_ptr < s->frame->linesize[0] * s->avctx->height;
y_ptr += s->frame->linesize[0]) {
bytestream2_get_buffer(&g2, &pixels[y_ptr],
s->avctx->width);
if (s->avctx->width & 3)
bytestream2_skip(&g2, 4 - (s->avctx->width & 3));
}
}
break;
case FLI_MINI:
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", chunk_type);
break;
}
if (stream_ptr_after_chunk - bytestream2_tell(&g2) >= 0) {
bytestream2_skip(&g2, stream_ptr_after_chunk - bytestream2_tell(&g2));
} else {
av_log(avctx, AV_LOG_ERROR, "Chunk overread\n");
break;
}
frame_size -= chunk_size;
num_chunks--;
}
if (bytestream2_get_bytes_left(&g2) > 2)
av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \
"and final chunk ptr = %d\n", buf_size,
buf_size - bytestream2_get_bytes_left(&g2));
memcpy(s->frame->data[1], s->palette, AVPALETTE_SIZE);
if (s->new_palette) {
s->frame->palette_has_changed = 1;
s->new_palette = 0;
}
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
return buf_size;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
const uint8_t *VAR_3, int VAR_4)
{
FlicDecodeContext *s = VAR_0->priv_data;
GetByteContext g2;
int VAR_5;
int VAR_6;
unsigned char VAR_7;
unsigned char VAR_8;
unsigned int VAR_9;
int VAR_10;
unsigned int VAR_11;
int VAR_12;
int VAR_13, VAR_14, VAR_15;
int VAR_16;
int VAR_17;
int VAR_18;
unsigned char VAR_19, VAR_20, VAR_21;
int VAR_22;
int VAR_23;
int VAR_24;
signed short VAR_25;
int VAR_26;
int VAR_27;
int VAR_28;
int VAR_29;
unsigned char *VAR_30;
unsigned int VAR_31;
bytestream2_init(&g2, VAR_3, VAR_4);
if ((VAR_15 = ff_reget_buffer(VAR_0, s->frame)) < 0)
return VAR_15;
VAR_30 = s->frame->VAR_1[0];
VAR_31 = s->VAR_0->height * s->frame->linesize[0];
if (VAR_4 < 16 || VAR_4 > INT_MAX - (3 * 256 + AV_INPUT_BUFFER_PADDING_SIZE))
VAR_9 = bytestream2_get_le32(&g2);
if (VAR_9 > VAR_4)
VAR_9 = VAR_4;
bytestream2_skip(&g2, 2);
VAR_10 = bytestream2_get_le16(&g2);
bytestream2_skip(&g2, 8);
VAR_9 -= 16;
while ((VAR_9 >= 6) && (VAR_10 > 0) &&
bytestream2_get_bytes_left(&g2) >= 4) {
int VAR_32;
VAR_11 = bytestream2_get_le32(&g2);
if (VAR_11 > VAR_9) {
av_log(VAR_0, AV_LOG_WARNING,
"Invalid VAR_11 = %u > VAR_9 = %u\n", VAR_11, VAR_9);
VAR_11 = VAR_9;
}
VAR_32 = bytestream2_tell(&g2) - 4 + VAR_11;
VAR_12 = bytestream2_get_le16(&g2);
switch (VAR_12) {
case FLI_256_COLOR:
case FLI_COLOR:
if ((VAR_12 == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE))
VAR_18 = 0;
else
VAR_18 = 2;
VAR_16 = bytestream2_get_le16(&g2);
VAR_6 = 0;
for (VAR_13 = 0; VAR_13 < VAR_16; VAR_13++) {
VAR_6 += bytestream2_get_byte(&g2);
VAR_17 = bytestream2_get_byte(&g2);
if (VAR_17 == 0)
VAR_17 = 256;
if (bytestream2_tell(&g2) + VAR_17 * 3 > VAR_32)
break;
for (VAR_14 = 0; VAR_14 < VAR_17; VAR_14++) {
unsigned int VAR_33;
if ((unsigned)VAR_6 >= 256)
VAR_6 = 0;
VAR_19 = bytestream2_get_byte(&g2) << VAR_18;
VAR_20 = bytestream2_get_byte(&g2) << VAR_18;
VAR_21 = bytestream2_get_byte(&g2) << VAR_18;
VAR_33 = 0xFFU << 24 | VAR_19 << 16 | VAR_20 << 8 | VAR_21;
if (VAR_18 == 2)
VAR_33 |= VAR_33 >> 6 & 0x30303;
if (s->palette[VAR_6] != VAR_33)
s->new_palette = 1;
s->palette[VAR_6++] = VAR_33;
}
}
break;
case FLI_DELTA:
VAR_26 = 0;
VAR_23 = bytestream2_get_le16(&g2);
while (VAR_23 > 0) {
if (bytestream2_tell(&g2) + 2 > VAR_32)
break;
VAR_25 = bytestream2_get_le16(&g2);
if ((VAR_25 & 0xC000) == 0xC000) {
VAR_25 = -VAR_25;
VAR_26 += VAR_25 * s->frame->linesize[0];
} else if ((VAR_25 & 0xC000) == 0x4000) {
av_log(VAR_0, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", VAR_25);
} else if ((VAR_25 & 0xC000) == 0x8000) {
VAR_5= VAR_26 + s->frame->linesize[0] - 1;
CHECK_PIXEL_PTR(0);
VAR_30[VAR_5] = VAR_25 & 0xff;
} else {
VAR_23--;
VAR_5 = VAR_26;
CHECK_PIXEL_PTR(0);
VAR_29 = s->VAR_0->width;
for (VAR_13 = 0; VAR_13 < VAR_25; VAR_13++) {
if (bytestream2_tell(&g2) + 2 > VAR_32)
break;
VAR_28 = bytestream2_get_byte(&g2);
VAR_5 += VAR_28;
VAR_29 -= VAR_28;
VAR_27 = sign_extend(bytestream2_get_byte(&g2), 8);
if (VAR_27 < 0) {
VAR_27 = -VAR_27;
VAR_7 = bytestream2_get_byte(&g2);
VAR_8 = bytestream2_get_byte(&g2);
CHECK_PIXEL_PTR(VAR_27 * 2);
for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29 -= 2) {
VAR_30[VAR_5++] = VAR_7;
VAR_30[VAR_5++] = VAR_8;
}
} else {
CHECK_PIXEL_PTR(VAR_27 * 2);
if (bytestream2_tell(&g2) + VAR_27 * 2 > VAR_32)
break;
for (VAR_14 = 0; VAR_14 < VAR_27 * 2; VAR_14++, VAR_29--) {
VAR_30[VAR_5++] = bytestream2_get_byte(&g2);
}
}
}
VAR_26 += s->frame->linesize[0];
}
}
break;
case FLI_LC:
VAR_24 = bytestream2_get_le16(&g2);
VAR_26 = 0;
VAR_26 += VAR_24 * s->frame->linesize[0];
VAR_23 = bytestream2_get_le16(&g2);
while (VAR_23 > 0) {
VAR_5 = VAR_26;
CHECK_PIXEL_PTR(0);
VAR_29 = s->VAR_0->width;
if (bytestream2_tell(&g2) + 1 > VAR_32)
break;
VAR_25 = bytestream2_get_byte(&g2);
if (VAR_25 > 0) {
for (VAR_13 = 0; VAR_13 < VAR_25; VAR_13++) {
if (bytestream2_tell(&g2) + 1 > VAR_32)
break;
VAR_28 = bytestream2_get_byte(&g2);
VAR_5 += VAR_28;
VAR_29 -= VAR_28;
VAR_27 = sign_extend(bytestream2_get_byte(&g2),8);
if (VAR_27 > 0) {
CHECK_PIXEL_PTR(VAR_27);
if (bytestream2_tell(&g2) + VAR_27 > VAR_32)
break;
for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29--) {
VAR_30[VAR_5++] = bytestream2_get_byte(&g2);
}
} else if (VAR_27 < 0) {
VAR_27 = -VAR_27;
VAR_7 = bytestream2_get_byte(&g2);
CHECK_PIXEL_PTR(VAR_27);
for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29--) {
VAR_30[VAR_5++] = VAR_7;
}
}
}
}
VAR_26 += s->frame->linesize[0];
VAR_23--;
}
break;
case FLI_BLACK:
memset(VAR_30, 0,
s->frame->linesize[0] * s->VAR_0->height);
break;
case FLI_BRUN:
VAR_26 = 0;
for (VAR_22 = 0; VAR_22 < s->VAR_0->height; VAR_22++) {
VAR_5 = VAR_26;
bytestream2_skip(&g2, 1);
VAR_29 = s->VAR_0->width;
while (VAR_29 > 0) {
if (bytestream2_tell(&g2) + 1 > VAR_32)
break;
VAR_27 = sign_extend(bytestream2_get_byte(&g2), 8);
if (!VAR_27) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid byte run value.\n");
}
if (VAR_27 > 0) {
VAR_7 = bytestream2_get_byte(&g2);
CHECK_PIXEL_PTR(VAR_27);
for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++) {
VAR_30[VAR_5++] = VAR_7;
VAR_29--;
if (VAR_29 < 0)
av_log(VAR_0, AV_LOG_ERROR, "VAR_29 < 0 (%d) at line %d\n",
VAR_29, VAR_22);
}
} else {
VAR_27 = -VAR_27;
CHECK_PIXEL_PTR(VAR_27);
if (bytestream2_tell(&g2) + VAR_27 > VAR_32)
break;
for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++) {
VAR_30[VAR_5++] = bytestream2_get_byte(&g2);
VAR_29--;
if (VAR_29 < 0)
av_log(VAR_0, AV_LOG_ERROR, "VAR_29 < 0 (%d) at line %d\n",
VAR_29, VAR_22);
}
}
}
VAR_26 += s->frame->linesize[0];
}
break;
case FLI_COPY:
if (VAR_11 - 6 != FFALIGN(s->VAR_0->width, 4) * s->VAR_0->height) {
av_log(VAR_0, AV_LOG_ERROR, "In chunk FLI_COPY : source VAR_1 (%d bytes) " \
"has incorrect size, skipping chunk\n", VAR_11 - 6);
bytestream2_skip(&g2, VAR_11 - 6);
} else {
for (VAR_26 = 0; VAR_26 < s->frame->linesize[0] * s->VAR_0->height;
VAR_26 += s->frame->linesize[0]) {
bytestream2_get_buffer(&g2, &VAR_30[VAR_26],
s->VAR_0->width);
if (s->VAR_0->width & 3)
bytestream2_skip(&g2, 4 - (s->VAR_0->width & 3));
}
}
break;
case FLI_MINI:
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", VAR_12);
break;
}
if (VAR_32 - bytestream2_tell(&g2) >= 0) {
bytestream2_skip(&g2, VAR_32 - bytestream2_tell(&g2));
} else {
av_log(VAR_0, AV_LOG_ERROR, "Chunk overread\n");
break;
}
VAR_9 -= VAR_11;
VAR_10--;
}
if (bytestream2_get_bytes_left(&g2) > 2)
av_log(VAR_0, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \
"and final chunk ptr = %d\n", VAR_4,
VAR_4 - bytestream2_get_bytes_left(&g2));
memcpy(s->frame->VAR_1[1], s->palette, AVPALETTE_SIZE);
if (s->new_palette) {
s->frame->palette_has_changed = 1;
s->new_palette = 0;
}
if ((VAR_15 = av_frame_ref(VAR_1, s->frame)) < 0)
return VAR_15;
*VAR_2 = 1;
return VAR_4;
} | [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nconst uint8_t *VAR_3, int VAR_4)\n{",
"FlicDecodeContext *s = VAR_0->priv_data;",
"GetByteContext g2;",
"int VAR_5;",
"int VAR_6;",
"unsigned char VAR_7;",
"unsigned char VAR_8;",
"unsigned int VAR_9;",
"int VAR_10;",
"unsigned int VAR_11;",
"int VAR_12;",
"int VAR_13, VAR_14, VAR_15;",
"int VAR_16;",
"int VAR_17;",
"int VAR_18;",
"unsigned char VAR_19, VAR_20, VAR_21;",
"int VAR_22;",
"int VAR_23;",
"int VAR_24;",
"signed short VAR_25;",
"int VAR_26;",
"int VAR_27;",
"int VAR_28;",
"int VAR_29;",
"unsigned char *VAR_30;",
"unsigned int VAR_31;",
"bytestream2_init(&g2, VAR_3, VAR_4);",
"if ((VAR_15 = ff_reget_buffer(VAR_0, s->frame)) < 0)\nreturn VAR_15;",
"VAR_30 = s->frame->VAR_1[0];",
"VAR_31 = s->VAR_0->height * s->frame->linesize[0];",
"if (VAR_4 < 16 || VAR_4 > INT_MAX - (3 * 256 + AV_INPUT_BUFFER_PADDING_SIZE))\nVAR_9 = bytestream2_get_le32(&g2);",
"if (VAR_9 > VAR_4)\nVAR_9 = VAR_4;",
"bytestream2_skip(&g2, 2);",
"VAR_10 = bytestream2_get_le16(&g2);",
"bytestream2_skip(&g2, 8);",
"VAR_9 -= 16;",
"while ((VAR_9 >= 6) && (VAR_10 > 0) &&\nbytestream2_get_bytes_left(&g2) >= 4) {",
"int VAR_32;",
"VAR_11 = bytestream2_get_le32(&g2);",
"if (VAR_11 > VAR_9) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"Invalid VAR_11 = %u > VAR_9 = %u\\n\", VAR_11, VAR_9);",
"VAR_11 = VAR_9;",
"}",
"VAR_32 = bytestream2_tell(&g2) - 4 + VAR_11;",
"VAR_12 = bytestream2_get_le16(&g2);",
"switch (VAR_12) {",
"case FLI_256_COLOR:\ncase FLI_COLOR:\nif ((VAR_12 == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE))\nVAR_18 = 0;",
"else\nVAR_18 = 2;",
"VAR_16 = bytestream2_get_le16(&g2);",
"VAR_6 = 0;",
"for (VAR_13 = 0; VAR_13 < VAR_16; VAR_13++) {",
"VAR_6 += bytestream2_get_byte(&g2);",
"VAR_17 = bytestream2_get_byte(&g2);",
"if (VAR_17 == 0)\nVAR_17 = 256;",
"if (bytestream2_tell(&g2) + VAR_17 * 3 > VAR_32)\nbreak;",
"for (VAR_14 = 0; VAR_14 < VAR_17; VAR_14++) {",
"unsigned int VAR_33;",
"if ((unsigned)VAR_6 >= 256)\nVAR_6 = 0;",
"VAR_19 = bytestream2_get_byte(&g2) << VAR_18;",
"VAR_20 = bytestream2_get_byte(&g2) << VAR_18;",
"VAR_21 = bytestream2_get_byte(&g2) << VAR_18;",
"VAR_33 = 0xFFU << 24 | VAR_19 << 16 | VAR_20 << 8 | VAR_21;",
"if (VAR_18 == 2)\nVAR_33 |= VAR_33 >> 6 & 0x30303;",
"if (s->palette[VAR_6] != VAR_33)\ns->new_palette = 1;",
"s->palette[VAR_6++] = VAR_33;",
"}",
"}",
"break;",
"case FLI_DELTA:\nVAR_26 = 0;",
"VAR_23 = bytestream2_get_le16(&g2);",
"while (VAR_23 > 0) {",
"if (bytestream2_tell(&g2) + 2 > VAR_32)\nbreak;",
"VAR_25 = bytestream2_get_le16(&g2);",
"if ((VAR_25 & 0xC000) == 0xC000) {",
"VAR_25 = -VAR_25;",
"VAR_26 += VAR_25 * s->frame->linesize[0];",
"} else if ((VAR_25 & 0xC000) == 0x4000) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Undefined opcode (%x) in DELTA_FLI\\n\", VAR_25);",
"} else if ((VAR_25 & 0xC000) == 0x8000) {",
"VAR_5= VAR_26 + s->frame->linesize[0] - 1;",
"CHECK_PIXEL_PTR(0);",
"VAR_30[VAR_5] = VAR_25 & 0xff;",
"} else {",
"VAR_23--;",
"VAR_5 = VAR_26;",
"CHECK_PIXEL_PTR(0);",
"VAR_29 = s->VAR_0->width;",
"for (VAR_13 = 0; VAR_13 < VAR_25; VAR_13++) {",
"if (bytestream2_tell(&g2) + 2 > VAR_32)\nbreak;",
"VAR_28 = bytestream2_get_byte(&g2);",
"VAR_5 += VAR_28;",
"VAR_29 -= VAR_28;",
"VAR_27 = sign_extend(bytestream2_get_byte(&g2), 8);",
"if (VAR_27 < 0) {",
"VAR_27 = -VAR_27;",
"VAR_7 = bytestream2_get_byte(&g2);",
"VAR_8 = bytestream2_get_byte(&g2);",
"CHECK_PIXEL_PTR(VAR_27 * 2);",
"for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29 -= 2) {",
"VAR_30[VAR_5++] = VAR_7;",
"VAR_30[VAR_5++] = VAR_8;",
"}",
"} else {",
"CHECK_PIXEL_PTR(VAR_27 * 2);",
"if (bytestream2_tell(&g2) + VAR_27 * 2 > VAR_32)\nbreak;",
"for (VAR_14 = 0; VAR_14 < VAR_27 * 2; VAR_14++, VAR_29--) {",
"VAR_30[VAR_5++] = bytestream2_get_byte(&g2);",
"}",
"}",
"}",
"VAR_26 += s->frame->linesize[0];",
"}",
"}",
"break;",
"case FLI_LC:\nVAR_24 = bytestream2_get_le16(&g2);",
"VAR_26 = 0;",
"VAR_26 += VAR_24 * s->frame->linesize[0];",
"VAR_23 = bytestream2_get_le16(&g2);",
"while (VAR_23 > 0) {",
"VAR_5 = VAR_26;",
"CHECK_PIXEL_PTR(0);",
"VAR_29 = s->VAR_0->width;",
"if (bytestream2_tell(&g2) + 1 > VAR_32)\nbreak;",
"VAR_25 = bytestream2_get_byte(&g2);",
"if (VAR_25 > 0) {",
"for (VAR_13 = 0; VAR_13 < VAR_25; VAR_13++) {",
"if (bytestream2_tell(&g2) + 1 > VAR_32)\nbreak;",
"VAR_28 = bytestream2_get_byte(&g2);",
"VAR_5 += VAR_28;",
"VAR_29 -= VAR_28;",
"VAR_27 = sign_extend(bytestream2_get_byte(&g2),8);",
"if (VAR_27 > 0) {",
"CHECK_PIXEL_PTR(VAR_27);",
"if (bytestream2_tell(&g2) + VAR_27 > VAR_32)\nbreak;",
"for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29--) {",
"VAR_30[VAR_5++] = bytestream2_get_byte(&g2);",
"}",
"} else if (VAR_27 < 0) {",
"VAR_27 = -VAR_27;",
"VAR_7 = bytestream2_get_byte(&g2);",
"CHECK_PIXEL_PTR(VAR_27);",
"for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29--) {",
"VAR_30[VAR_5++] = VAR_7;",
"}",
"}",
"}",
"}",
"VAR_26 += s->frame->linesize[0];",
"VAR_23--;",
"}",
"break;",
"case FLI_BLACK:\nmemset(VAR_30, 0,\ns->frame->linesize[0] * s->VAR_0->height);",
"break;",
"case FLI_BRUN:\nVAR_26 = 0;",
"for (VAR_22 = 0; VAR_22 < s->VAR_0->height; VAR_22++) {",
"VAR_5 = VAR_26;",
"bytestream2_skip(&g2, 1);",
"VAR_29 = s->VAR_0->width;",
"while (VAR_29 > 0) {",
"if (bytestream2_tell(&g2) + 1 > VAR_32)\nbreak;",
"VAR_27 = sign_extend(bytestream2_get_byte(&g2), 8);",
"if (!VAR_27) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid byte run value.\\n\");",
"}",
"if (VAR_27 > 0) {",
"VAR_7 = bytestream2_get_byte(&g2);",
"CHECK_PIXEL_PTR(VAR_27);",
"for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++) {",
"VAR_30[VAR_5++] = VAR_7;",
"VAR_29--;",
"if (VAR_29 < 0)\nav_log(VAR_0, AV_LOG_ERROR, \"VAR_29 < 0 (%d) at line %d\\n\",\nVAR_29, VAR_22);",
"}",
"} else {",
"VAR_27 = -VAR_27;",
"CHECK_PIXEL_PTR(VAR_27);",
"if (bytestream2_tell(&g2) + VAR_27 > VAR_32)\nbreak;",
"for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++) {",
"VAR_30[VAR_5++] = bytestream2_get_byte(&g2);",
"VAR_29--;",
"if (VAR_29 < 0)\nav_log(VAR_0, AV_LOG_ERROR, \"VAR_29 < 0 (%d) at line %d\\n\",\nVAR_29, VAR_22);",
"}",
"}",
"}",
"VAR_26 += s->frame->linesize[0];",
"}",
"break;",
"case FLI_COPY:\nif (VAR_11 - 6 != FFALIGN(s->VAR_0->width, 4) * s->VAR_0->height) {",
"av_log(VAR_0, AV_LOG_ERROR, \"In chunk FLI_COPY : source VAR_1 (%d bytes) \" \\\n\"has incorrect size, skipping chunk\\n\", VAR_11 - 6);",
"bytestream2_skip(&g2, VAR_11 - 6);",
"} else {",
"for (VAR_26 = 0; VAR_26 < s->frame->linesize[0] * s->VAR_0->height;",
"VAR_26 += s->frame->linesize[0]) {",
"bytestream2_get_buffer(&g2, &VAR_30[VAR_26],\ns->VAR_0->width);",
"if (s->VAR_0->width & 3)\nbytestream2_skip(&g2, 4 - (s->VAR_0->width & 3));",
"}",
"}",
"break;",
"case FLI_MINI:\nbreak;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unrecognized chunk type: %d\\n\", VAR_12);",
"break;",
"}",
"if (VAR_32 - bytestream2_tell(&g2) >= 0) {",
"bytestream2_skip(&g2, VAR_32 - bytestream2_tell(&g2));",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Chunk overread\\n\");",
"break;",
"}",
"VAR_9 -= VAR_11;",
"VAR_10--;",
"}",
"if (bytestream2_get_bytes_left(&g2) > 2)\nav_log(VAR_0, AV_LOG_ERROR, \"Processed FLI chunk where chunk size = %d \" \\\n\"and final chunk ptr = %d\\n\", VAR_4,\nVAR_4 - bytestream2_get_bytes_left(&g2));",
"memcpy(s->frame->VAR_1[1], s->palette, AVPALETTE_SIZE);",
"if (s->new_palette) {",
"s->frame->palette_has_changed = 1;",
"s->new_palette = 0;",
"}",
"if ((VAR_15 = av_frame_ref(VAR_1, s->frame)) < 0)\nreturn VAR_15;",
"*VAR_2 = 1;",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3,
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31,
32
],
[
33
],
[
34
],
[
35,
36
],
[
37,
38
],
[
39
],
[
40
],
[
41
],
[
42
],
[
44,
45
],
[
46
],
[
47
],
[
48
],
[
49,
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
55
],
[
56,
57,
62,
63
],
[
64,
65
],
[
67
],
[
68
],
[
69
],
[
71
],
[
73
],
[
75,
76
],
[
77,
78
],
[
79
],
[
80
],
[
82,
83
],
[
84
],
[
85
],
[
86
],
[
87
],
[
88,
89
],
[
90,
91
],
[
92
],
[
93
],
[
94
],
[
95
],
[
96,
97
],
[
98
],
[
99
],
[
100,
101
],
[
102
],
[
103
],
[
105
],
[
106
],
[
107
],
[
108
],
[
109
],
[
111
],
[
112
],
[
113
],
[
114
],
[
115
],
[
116
],
[
117
],
[
118
],
[
119
],
[
120,
121
],
[
123
],
[
124
],
[
125
],
[
126
],
[
127
],
[
128
],
[
129
],
[
130
],
[
131
],
[
132
],
[
133
],
[
134
],
[
135
],
[
136
],
[
137
],
[
138,
139
],
[
140
],
[
141
],
[
142
],
[
143
],
[
144
],
[
145
],
[
146
],
[
147
],
[
148
],
[
149,
151
],
[
152
],
[
153
],
[
154
],
[
155
],
[
156
],
[
157
],
[
158
],
[
159,
160
],
[
161
],
[
162
],
[
163
],
[
165,
166
],
[
167
],
[
168
],
[
169
],
[
170
],
[
171
],
[
172
],
[
173,
174
],
[
175
],
[
176
],
[
177
],
[
178
],
[
179
],
[
180
],
[
181
],
[
182
],
[
183
],
[
184
],
[
185
],
[
186
],
[
187
],
[
188
],
[
189
],
[
190
],
[
191
],
[
192,
194,
195
],
[
196
],
[
197,
200
],
[
201
],
[
202
],
[
205
],
[
206
],
[
207
],
[
208,
209
],
[
210
],
[
211
],
[
212
],
[
213
],
[
214
],
[
215
],
[
216
],
[
217
],
[
218
],
[
219
],
[
220,
221,
222
],
[
223
],
[
224
],
[
225
],
[
226
],
[
227,
228
],
[
229
],
[
230
],
[
231
],
[
232,
233,
234
],
[
235
],
[
236
],
[
237
],
[
238
],
[
239
],
[
240
],
[
241,
243
],
[
244,
245
],
[
246
],
[
247
],
[
248
],
[
249
],
[
250,
251
],
[
252,
253
],
[
254
],
[
255
],
[
256
],
[
257,
259
],
[
260,
261
],
[
262
],
[
263
],
[
264
],
[
265
],
[
266
],
[
267
],
[
268
],
[
269
],
[
270
],
[
271
],
[
272
],
[
275,
276,
277,
278
],
[
280
],
[
281
],
[
282
],
[
283
],
[
284
],
[
285,
286
],
[
287
],
[
288
],
[
289
]
] |
22,743 | static void print_type_size(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
StringOutputVisitor *sov = to_sov(v);
static const char suffixes[] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E' };
uint64_t div, val;
char *out;
int i;
if (!sov->human) {
out = g_strdup_printf("%"PRIu64, *obj);
string_output_set(sov, out);
return;
}
val = *obj;
/* The exponent (returned in i) minus one gives us
* floor(log2(val * 1024 / 1000). The correction makes us
* switch to the higher power when the integer part is >= 1000.
*/
frexp(val / (1000.0 / 1024.0), &i);
i = (i - 1) / 10;
assert(i < ARRAY_SIZE(suffixes));
div = 1ULL << (i * 10);
out = g_strdup_printf("%"PRIu64" (%0.3g %c%s)", val,
(double)val/div, suffixes[i], i ? "iB" : "");
string_output_set(sov, out);
}
| true | qemu | 22951aaaebb6c4c314c58ad576960a9c57695bbc | static void print_type_size(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
StringOutputVisitor *sov = to_sov(v);
static const char suffixes[] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E' };
uint64_t div, val;
char *out;
int i;
if (!sov->human) {
out = g_strdup_printf("%"PRIu64, *obj);
string_output_set(sov, out);
return;
}
val = *obj;
frexp(val / (1000.0 / 1024.0), &i);
i = (i - 1) / 10;
assert(i < ARRAY_SIZE(suffixes));
div = 1ULL << (i * 10);
out = g_strdup_printf("%"PRIu64" (%0.3g %c%s)", val,
(double)val/div, suffixes[i], i ? "iB" : "");
string_output_set(sov, out);
}
| {
"code": [
" static const char suffixes[] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E' };",
" uint64_t div, val;",
" char *out;",
" int i;",
" frexp(val / (1000.0 / 1024.0), &i);",
" i = (i - 1) / 10;",
" assert(i < ARRAY_SIZE(suffixes));",
" div = 1ULL << (i * 10);",
" out = g_strdup_printf(\"%\"PRIu64\" (%0.3g %c%s)\", val,",
" (double)val/div, suffixes[i], i ? \"iB\" : \"\");"
],
"line_no": [
9,
11,
13,
15,
43,
45,
47,
49,
53,
55
]
} | static void FUNC_0(Visitor *VAR_0, const char *VAR_1, uint64_t *VAR_2,
Error **VAR_3)
{
StringOutputVisitor *sov = to_sov(VAR_0);
static const char VAR_4[] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E' };
uint64_t div, val;
char *VAR_5;
int VAR_6;
if (!sov->human) {
VAR_5 = g_strdup_printf("%"PRIu64, *VAR_2);
string_output_set(sov, VAR_5);
return;
}
val = *VAR_2;
frexp(val / (1000.0 / 1024.0), &VAR_6);
VAR_6 = (VAR_6 - 1) / 10;
assert(VAR_6 < ARRAY_SIZE(VAR_4));
div = 1ULL << (VAR_6 * 10);
VAR_5 = g_strdup_printf("%"PRIu64" (%0.3g %c%s)", val,
(double)val/div, VAR_4[VAR_6], VAR_6 ? "iB" : "");
string_output_set(sov, VAR_5);
}
| [
"static void FUNC_0(Visitor *VAR_0, const char *VAR_1, uint64_t *VAR_2,\nError **VAR_3)\n{",
"StringOutputVisitor *sov = to_sov(VAR_0);",
"static const char VAR_4[] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E' };",
"uint64_t div, val;",
"char *VAR_5;",
"int VAR_6;",
"if (!sov->human) {",
"VAR_5 = g_strdup_printf(\"%\"PRIu64, *VAR_2);",
"string_output_set(sov, VAR_5);",
"return;",
"}",
"val = *VAR_2;",
"frexp(val / (1000.0 / 1024.0), &VAR_6);",
"VAR_6 = (VAR_6 - 1) / 10;",
"assert(VAR_6 < ARRAY_SIZE(VAR_4));",
"div = 1ULL << (VAR_6 * 10);",
"VAR_5 = g_strdup_printf(\"%\"PRIu64\" (%0.3g %c%s)\", val,\n(double)val/div, VAR_4[VAR_6], VAR_6 ? \"iB\" : \"\");",
"string_output_set(sov, VAR_5);",
"}"
] | [
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55
],
[
57
],
[
59
]
] |
22,744 | static int cmp_color(const void *a, const void *b)
{
const struct range_box *box1 = a;
const struct range_box *box2 = b;
return box1->color - box2->color;
}
| true | FFmpeg | 92e483f8ed70d88d4f64337f65bae212502735d4 | static int cmp_color(const void *a, const void *b)
{
const struct range_box *box1 = a;
const struct range_box *box2 = b;
return box1->color - box2->color;
}
| {
"code": [
" return box1->color - box2->color;"
],
"line_no": [
9
]
} | static int FUNC_0(const void *VAR_0, const void *VAR_1)
{
const struct range_box *VAR_2 = VAR_0;
const struct range_box *VAR_3 = VAR_1;
return VAR_2->color - VAR_3->color;
}
| [
"static int FUNC_0(const void *VAR_0, const void *VAR_1)\n{",
"const struct range_box *VAR_2 = VAR_0;",
"const struct range_box *VAR_3 = VAR_1;",
"return VAR_2->color - VAR_3->color;",
"}"
] | [
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
22,745 | static void iommu_config_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
IOMMUState *is = opaque;
IOMMU_DPRINTF("IOMMU config write: 0x%" HWADDR_PRIx " val: %" PRIx64
" size: %d\n", addr, val, size);
switch (addr) {
case IOMMU_CTRL:
if (size == 4) {
is->regs[IOMMU_CTRL >> 3] &= 0xffffffffULL;
is->regs[IOMMU_CTRL >> 3] |= val << 32;
} else {
is->regs[IOMMU_CTRL] = val;
}
break;
case IOMMU_CTRL + 0x4:
is->regs[IOMMU_CTRL >> 3] &= 0xffffffff00000000ULL;
is->regs[IOMMU_CTRL >> 3] |= val & 0xffffffffULL;
break;
case IOMMU_BASE:
if (size == 4) {
is->regs[IOMMU_BASE >> 3] &= 0xffffffffULL;
is->regs[IOMMU_BASE >> 3] |= val << 32;
} else {
is->regs[IOMMU_BASE] = val;
}
break;
case IOMMU_BASE + 0x4:
is->regs[IOMMU_BASE >> 3] &= 0xffffffff00000000ULL;
is->regs[IOMMU_BASE >> 3] |= val & 0xffffffffULL;
break;
default:
qemu_log_mask(LOG_UNIMP,
"apb iommu: Unimplemented register write "
"reg 0x%" HWADDR_PRIx " size 0x%x value 0x%" PRIx64 "\n",
addr, size, val);
break;
}
}
| true | qemu | 68716da745858ca86ac587d14ac553051e5f04eb | static void iommu_config_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
IOMMUState *is = opaque;
IOMMU_DPRINTF("IOMMU config write: 0x%" HWADDR_PRIx " val: %" PRIx64
" size: %d\n", addr, val, size);
switch (addr) {
case IOMMU_CTRL:
if (size == 4) {
is->regs[IOMMU_CTRL >> 3] &= 0xffffffffULL;
is->regs[IOMMU_CTRL >> 3] |= val << 32;
} else {
is->regs[IOMMU_CTRL] = val;
}
break;
case IOMMU_CTRL + 0x4:
is->regs[IOMMU_CTRL >> 3] &= 0xffffffff00000000ULL;
is->regs[IOMMU_CTRL >> 3] |= val & 0xffffffffULL;
break;
case IOMMU_BASE:
if (size == 4) {
is->regs[IOMMU_BASE >> 3] &= 0xffffffffULL;
is->regs[IOMMU_BASE >> 3] |= val << 32;
} else {
is->regs[IOMMU_BASE] = val;
}
break;
case IOMMU_BASE + 0x4:
is->regs[IOMMU_BASE >> 3] &= 0xffffffff00000000ULL;
is->regs[IOMMU_BASE >> 3] |= val & 0xffffffffULL;
break;
default:
qemu_log_mask(LOG_UNIMP,
"apb iommu: Unimplemented register write "
"reg 0x%" HWADDR_PRIx " size 0x%x value 0x%" PRIx64 "\n",
addr, size, val);
break;
}
}
| {
"code": [
" is->regs[IOMMU_CTRL] = val;",
" is->regs[IOMMU_BASE] = val;"
],
"line_no": [
29,
53
]
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
IOMMUState *is = VAR_0;
IOMMU_DPRINTF("IOMMU config write: 0x%" HWADDR_PRIx " VAR_2: %" PRIx64
" VAR_3: %d\n", VAR_1, VAR_2, VAR_3);
switch (VAR_1) {
case IOMMU_CTRL:
if (VAR_3 == 4) {
is->regs[IOMMU_CTRL >> 3] &= 0xffffffffULL;
is->regs[IOMMU_CTRL >> 3] |= VAR_2 << 32;
} else {
is->regs[IOMMU_CTRL] = VAR_2;
}
break;
case IOMMU_CTRL + 0x4:
is->regs[IOMMU_CTRL >> 3] &= 0xffffffff00000000ULL;
is->regs[IOMMU_CTRL >> 3] |= VAR_2 & 0xffffffffULL;
break;
case IOMMU_BASE:
if (VAR_3 == 4) {
is->regs[IOMMU_BASE >> 3] &= 0xffffffffULL;
is->regs[IOMMU_BASE >> 3] |= VAR_2 << 32;
} else {
is->regs[IOMMU_BASE] = VAR_2;
}
break;
case IOMMU_BASE + 0x4:
is->regs[IOMMU_BASE >> 3] &= 0xffffffff00000000ULL;
is->regs[IOMMU_BASE >> 3] |= VAR_2 & 0xffffffffULL;
break;
default:
qemu_log_mask(LOG_UNIMP,
"apb iommu: Unimplemented register write "
"reg 0x%" HWADDR_PRIx " VAR_3 0x%x value 0x%" PRIx64 "\n",
VAR_1, VAR_3, VAR_2);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"IOMMUState *is = VAR_0;",
"IOMMU_DPRINTF(\"IOMMU config write: 0x%\" HWADDR_PRIx \" VAR_2: %\" PRIx64\n\" VAR_3: %d\\n\", VAR_1, VAR_2, VAR_3);",
"switch (VAR_1) {",
"case IOMMU_CTRL:\nif (VAR_3 == 4) {",
"is->regs[IOMMU_CTRL >> 3] &= 0xffffffffULL;",
"is->regs[IOMMU_CTRL >> 3] |= VAR_2 << 32;",
"} else {",
"is->regs[IOMMU_CTRL] = VAR_2;",
"}",
"break;",
"case IOMMU_CTRL + 0x4:\nis->regs[IOMMU_CTRL >> 3] &= 0xffffffff00000000ULL;",
"is->regs[IOMMU_CTRL >> 3] |= VAR_2 & 0xffffffffULL;",
"break;",
"case IOMMU_BASE:\nif (VAR_3 == 4) {",
"is->regs[IOMMU_BASE >> 3] &= 0xffffffffULL;",
"is->regs[IOMMU_BASE >> 3] |= VAR_2 << 32;",
"} else {",
"is->regs[IOMMU_BASE] = VAR_2;",
"}",
"break;",
"case IOMMU_BASE + 0x4:\nis->regs[IOMMU_BASE >> 3] &= 0xffffffff00000000ULL;",
"is->regs[IOMMU_BASE >> 3] |= VAR_2 & 0xffffffffULL;",
"break;",
"default:\nqemu_log_mask(LOG_UNIMP,\n\"apb iommu: Unimplemented register write \"\n\"reg 0x%\" HWADDR_PRIx \" VAR_3 0x%x value 0x%\" PRIx64 \"\\n\",\nVAR_1, VAR_3, VAR_2);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67,
69,
71,
73,
75
],
[
77
],
[
79
],
[
81
]
] |
22,746 | static void piix3_ide_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->no_hotplug = 1;
k->init = pci_piix_ide_initfn;
k->exit = pci_piix_ide_exitfn;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
k->class_id = PCI_CLASS_STORAGE_IDE;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
dc->no_user = 1;
}
| true | qemu | efec3dd631d94160288392721a5f9c39e50fb2bc | static void piix3_ide_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->no_hotplug = 1;
k->init = pci_piix_ide_initfn;
k->exit = pci_piix_ide_exitfn;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
k->class_id = PCI_CLASS_STORAGE_IDE;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
dc->no_user = 1;
}
| {
"code": [
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;"
],
"line_no": [
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
PCIDeviceClass *k = PCI_DEVICE_CLASS(VAR_0);
k->no_hotplug = 1;
k->init = pci_piix_ide_initfn;
k->exit = pci_piix_ide_exitfn;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
k->class_id = PCI_CLASS_STORAGE_IDE;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
dc->no_user = 1;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"PCIDeviceClass *k = PCI_DEVICE_CLASS(VAR_0);",
"k->no_hotplug = 1;",
"k->init = pci_piix_ide_initfn;",
"k->exit = pci_piix_ide_exitfn;",
"k->vendor_id = PCI_VENDOR_ID_INTEL;",
"k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;",
"k->class_id = PCI_CLASS_STORAGE_IDE;",
"set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);",
"dc->no_user = 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
22,747 | static void reconstruct_stereo_16(int32_t *buffer[MAX_CHANNELS],
int16_t *buffer_out,
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;
buffer_out[i*numchannels] = b;
buffer_out[i*numchannels + 1] = a;
}
return;
}
/* otherwise basic interlacing took place */
for (i = 0; i < numsamples; i++) {
int16_t left, right;
left = buffer[0][i];
right = buffer[1][i];
buffer_out[i*numchannels] = left;
buffer_out[i*numchannels + 1] = right;
}
}
| false | FFmpeg | dbbb9262ca0fd09f2582b11157a74c88ab7e1db5 | static void reconstruct_stereo_16(int32_t *buffer[MAX_CHANNELS],
int16_t *buffer_out,
int numchannels, int numsamples,
uint8_t interlacing_shift,
uint8_t interlacing_leftweight)
{
int i;
if (numsamples <= 0)
return;
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;
buffer_out[i*numchannels] = b;
buffer_out[i*numchannels + 1] = a;
}
return;
}
for (i = 0; i < numsamples; i++) {
int16_t left, right;
left = buffer[0][i];
right = buffer[1][i];
buffer_out[i*numchannels] = left;
buffer_out[i*numchannels + 1] = right;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int32_t *VAR_0[MAX_CHANNELS],
int16_t *VAR_1,
int VAR_2, int VAR_3,
uint8_t VAR_4,
uint8_t VAR_5)
{
int VAR_6;
if (VAR_3 <= 0)
return;
if (VAR_5) {
for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++) {
int32_t a, b;
a = VAR_0[0][VAR_6];
b = VAR_0[1][VAR_6];
a -= (b * VAR_5) >> VAR_4;
b += a;
VAR_1[VAR_6*VAR_2] = b;
VAR_1[VAR_6*VAR_2 + 1] = a;
}
return;
}
for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++) {
int16_t left, right;
left = VAR_0[0][VAR_6];
right = VAR_0[1][VAR_6];
VAR_1[VAR_6*VAR_2] = left;
VAR_1[VAR_6*VAR_2 + 1] = right;
}
}
| [
"static void FUNC_0(int32_t *VAR_0[MAX_CHANNELS],\nint16_t *VAR_1,\nint VAR_2, int VAR_3,\nuint8_t VAR_4,\nuint8_t VAR_5)\n{",
"int VAR_6;",
"if (VAR_3 <= 0)\nreturn;",
"if (VAR_5) {",
"for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++) {",
"int32_t a, b;",
"a = VAR_0[0][VAR_6];",
"b = VAR_0[1][VAR_6];",
"a -= (b * VAR_5) >> VAR_4;",
"b += a;",
"VAR_1[VAR_6*VAR_2] = b;",
"VAR_1[VAR_6*VAR_2 + 1] = a;",
"}",
"return;",
"}",
"for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++) {",
"int16_t left, right;",
"left = VAR_0[0][VAR_6];",
"right = VAR_0[1][VAR_6];",
"VAR_1[VAR_6*VAR_2] = left;",
"VAR_1[VAR_6*VAR_2 + 1] = right;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15,
17
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
22,748 | av_cold void ff_vp9_init_static(AVCodec *codec)
{
if ( vpx_codec_version_major() < 1
|| (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))
codec->capabilities |= AV_CODEC_CAP_EXPERIMENTAL;
codec->pix_fmts = vp9_pix_fmts_def;
#if CONFIG_LIBVPX_VP9_ENCODER
if ( vpx_codec_version_major() > 1
|| (vpx_codec_version_major() == 1 && vpx_codec_version_minor() >= 4)) {
#ifdef VPX_CODEC_CAP_HIGHBITDEPTH
vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx());
if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)
codec->pix_fmts = vp9_pix_fmts_highbd;
else
#endif
codec->pix_fmts = vp9_pix_fmts_highcol;
}
#endif
}
| false | FFmpeg | e54061ae6a5e22bad5c66ef4411acc8f778a9f90 | av_cold void ff_vp9_init_static(AVCodec *codec)
{
if ( vpx_codec_version_major() < 1
|| (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))
codec->capabilities |= AV_CODEC_CAP_EXPERIMENTAL;
codec->pix_fmts = vp9_pix_fmts_def;
#if CONFIG_LIBVPX_VP9_ENCODER
if ( vpx_codec_version_major() > 1
|| (vpx_codec_version_major() == 1 && vpx_codec_version_minor() >= 4)) {
#ifdef VPX_CODEC_CAP_HIGHBITDEPTH
vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx());
if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)
codec->pix_fmts = vp9_pix_fmts_highbd;
else
#endif
codec->pix_fmts = vp9_pix_fmts_highcol;
}
#endif
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(AVCodec *codec)
{
if ( vpx_codec_version_major() < 1
|| (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))
codec->capabilities |= AV_CODEC_CAP_EXPERIMENTAL;
codec->pix_fmts = vp9_pix_fmts_def;
#if CONFIG_LIBVPX_VP9_ENCODER
if ( vpx_codec_version_major() > 1
|| (vpx_codec_version_major() == 1 && vpx_codec_version_minor() >= 4)) {
#ifdef VPX_CODEC_CAP_HIGHBITDEPTH
vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx());
if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)
codec->pix_fmts = vp9_pix_fmts_highbd;
else
#endif
codec->pix_fmts = vp9_pix_fmts_highcol;
}
#endif
}
| [
"av_cold void FUNC_0(AVCodec *codec)\n{",
"if ( vpx_codec_version_major() < 1\n|| (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))\ncodec->capabilities |= AV_CODEC_CAP_EXPERIMENTAL;",
"codec->pix_fmts = vp9_pix_fmts_def;",
"#if CONFIG_LIBVPX_VP9_ENCODER\nif ( vpx_codec_version_major() > 1\n|| (vpx_codec_version_major() == 1 && vpx_codec_version_minor() >= 4)) {",
"#ifdef VPX_CODEC_CAP_HIGHBITDEPTH\nvpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx());",
"if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)\ncodec->pix_fmts = vp9_pix_fmts_highbd;",
"else\n#endif\ncodec->pix_fmts = vp9_pix_fmts_highcol;",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11
],
[
13,
15,
17
],
[
19,
21
],
[
23,
25
],
[
27,
29,
31
],
[
33
],
[
35,
37
]
] |
22,749 | void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1)
{
int cssid, ssid, schid, m;
SubchDev *sch;
int ret = -ENODEV;
int cc;
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
program_interrupt(&cpu->env, PGM_OPERAND, 2);
return;
}
trace_ioinst_sch_id("rsch", cssid, ssid, schid);
sch = css_find_subch(m, cssid, ssid, schid);
if (sch && css_subch_visible(sch)) {
ret = css_do_rsch(sch);
}
switch (ret) {
case -ENODEV:
cc = 3;
break;
case -EINVAL:
cc = 2;
break;
case 0:
cc = 0;
break;
default:
cc = 1;
break;
}
setcc(cpu, cc);
}
| false | qemu | 7e01376daea75e888c370aab521a7d4aeaf2ffd1 | void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1)
{
int cssid, ssid, schid, m;
SubchDev *sch;
int ret = -ENODEV;
int cc;
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
program_interrupt(&cpu->env, PGM_OPERAND, 2);
return;
}
trace_ioinst_sch_id("rsch", cssid, ssid, schid);
sch = css_find_subch(m, cssid, ssid, schid);
if (sch && css_subch_visible(sch)) {
ret = css_do_rsch(sch);
}
switch (ret) {
case -ENODEV:
cc = 3;
break;
case -EINVAL:
cc = 2;
break;
case 0:
cc = 0;
break;
default:
cc = 1;
break;
}
setcc(cpu, cc);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(S390CPU *VAR_0, uint64_t VAR_1)
{
int VAR_2, VAR_3, VAR_4, VAR_5;
SubchDev *sch;
int VAR_6 = -ENODEV;
int VAR_7;
if (ioinst_disassemble_sch_ident(VAR_1, &VAR_5, &VAR_2, &VAR_3, &VAR_4)) {
program_interrupt(&VAR_0->env, PGM_OPERAND, 2);
return;
}
trace_ioinst_sch_id("rsch", VAR_2, VAR_3, VAR_4);
sch = css_find_subch(VAR_5, VAR_2, VAR_3, VAR_4);
if (sch && css_subch_visible(sch)) {
VAR_6 = css_do_rsch(sch);
}
switch (VAR_6) {
case -ENODEV:
VAR_7 = 3;
break;
case -EINVAL:
VAR_7 = 2;
break;
case 0:
VAR_7 = 0;
break;
default:
VAR_7 = 1;
break;
}
setcc(VAR_0, VAR_7);
}
| [
"void FUNC_0(S390CPU *VAR_0, uint64_t VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"SubchDev *sch;",
"int VAR_6 = -ENODEV;",
"int VAR_7;",
"if (ioinst_disassemble_sch_ident(VAR_1, &VAR_5, &VAR_2, &VAR_3, &VAR_4)) {",
"program_interrupt(&VAR_0->env, PGM_OPERAND, 2);",
"return;",
"}",
"trace_ioinst_sch_id(\"rsch\", VAR_2, VAR_3, VAR_4);",
"sch = css_find_subch(VAR_5, VAR_2, VAR_3, VAR_4);",
"if (sch && css_subch_visible(sch)) {",
"VAR_6 = css_do_rsch(sch);",
"}",
"switch (VAR_6) {",
"case -ENODEV:\nVAR_7 = 3;",
"break;",
"case -EINVAL:\nVAR_7 = 2;",
"break;",
"case 0:\nVAR_7 = 0;",
"break;",
"default:\nVAR_7 = 1;",
"break;",
"}",
"setcc(VAR_0, VAR_7);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
22,750 | int kvm_arch_process_irqchip_events(CPUState *env)
{
return 0;
}
| false | qemu | 7a39fe588251ba042c91bf23d53b0ba820bf964c | int kvm_arch_process_irqchip_events(CPUState *env)
{
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(CPUState *VAR_0)
{
return 0;
}
| [
"int FUNC_0(CPUState *VAR_0)\n{",
"return 0;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,751 | static void decode_tones_amplitude(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
int ch_num, int band_has_tones[])
{
int mode, sb, j, i, diff, maxdiff, fi, delta, pred;
Atrac3pWaveParam *wsrc, *wref;
int refwaves[48];
Atrac3pWavesData *dst = ctx->channels[ch_num].tones_info;
Atrac3pWavesData *ref = ctx->channels[0].tones_info;
if (ch_num) {
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
if (!band_has_tones[sb] || !dst[sb].num_wavs)
continue;
wsrc = &ctx->waves_info->waves[dst[sb].start_index];
wref = &ctx->waves_info->waves[ref[sb].start_index];
for (j = 0; j < dst[sb].num_wavs; j++) {
for (i = 0, fi = 0, maxdiff = 1024; i < ref[sb].num_wavs; i++) {
diff = FFABS(wsrc[j].freq_index - wref[i].freq_index);
if (diff < maxdiff) {
maxdiff = diff;
fi = i;
}
}
if (maxdiff < 8)
refwaves[dst[sb].start_index + j] = fi + ref[sb].start_index;
else if (j < ref[sb].num_wavs)
refwaves[dst[sb].start_index + j] = j + ref[sb].start_index;
else
refwaves[dst[sb].start_index + j] = -1;
}
}
}
mode = get_bits(gb, ch_num + 1);
switch (mode) {
case 0: /** fixed-length coding */
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
if (!band_has_tones[sb] || !dst[sb].num_wavs)
continue;
if (ctx->waves_info->amplitude_mode)
for (i = 0; i < dst[sb].num_wavs; i++)
ctx->waves_info->waves[dst[sb].start_index + i].amp_sf = get_bits(gb, 6);
else
ctx->waves_info->waves[dst[sb].start_index].amp_sf = get_bits(gb, 6);
}
break;
case 1: /** min + VLC delta */
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
if (!band_has_tones[sb] || !dst[sb].num_wavs)
continue;
if (ctx->waves_info->amplitude_mode)
for (i = 0; i < dst[sb].num_wavs; i++)
ctx->waves_info->waves[dst[sb].start_index + i].amp_sf =
get_vlc2(gb, tone_vlc_tabs[3].table,
tone_vlc_tabs[3].bits, 1) + 20;
else
ctx->waves_info->waves[dst[sb].start_index].amp_sf =
get_vlc2(gb, tone_vlc_tabs[4].table,
tone_vlc_tabs[4].bits, 1) + 24;
}
break;
case 2: /** VLC modulo delta to master (slave only) */
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
if (!band_has_tones[sb] || !dst[sb].num_wavs)
continue;
for (i = 0; i < dst[sb].num_wavs; i++) {
delta = get_vlc2(gb, tone_vlc_tabs[5].table,
tone_vlc_tabs[5].bits, 1);
delta = sign_extend(delta, 5);
pred = refwaves[dst[sb].start_index + i] >= 0 ?
ctx->waves_info->waves[refwaves[dst[sb].start_index + i]].amp_sf : 34;
ctx->waves_info->waves[dst[sb].start_index + i].amp_sf = (pred + delta) & 0x3F;
}
}
break;
case 3: /** clone master (slave only) */
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
if (!band_has_tones[sb])
continue;
for (i = 0; i < dst[sb].num_wavs; i++)
ctx->waves_info->waves[dst[sb].start_index + i].amp_sf =
refwaves[dst[sb].start_index + i] >= 0
? ctx->waves_info->waves[refwaves[dst[sb].start_index + i]].amp_sf
: 32;
}
break;
}
}
| false | FFmpeg | d16ec1b6db25bc348b0d4800c9a0c9b7070e3710 | static void decode_tones_amplitude(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
int ch_num, int band_has_tones[])
{
int mode, sb, j, i, diff, maxdiff, fi, delta, pred;
Atrac3pWaveParam *wsrc, *wref;
int refwaves[48];
Atrac3pWavesData *dst = ctx->channels[ch_num].tones_info;
Atrac3pWavesData *ref = ctx->channels[0].tones_info;
if (ch_num) {
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
if (!band_has_tones[sb] || !dst[sb].num_wavs)
continue;
wsrc = &ctx->waves_info->waves[dst[sb].start_index];
wref = &ctx->waves_info->waves[ref[sb].start_index];
for (j = 0; j < dst[sb].num_wavs; j++) {
for (i = 0, fi = 0, maxdiff = 1024; i < ref[sb].num_wavs; i++) {
diff = FFABS(wsrc[j].freq_index - wref[i].freq_index);
if (diff < maxdiff) {
maxdiff = diff;
fi = i;
}
}
if (maxdiff < 8)
refwaves[dst[sb].start_index + j] = fi + ref[sb].start_index;
else if (j < ref[sb].num_wavs)
refwaves[dst[sb].start_index + j] = j + ref[sb].start_index;
else
refwaves[dst[sb].start_index + j] = -1;
}
}
}
mode = get_bits(gb, ch_num + 1);
switch (mode) {
case 0:
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
if (!band_has_tones[sb] || !dst[sb].num_wavs)
continue;
if (ctx->waves_info->amplitude_mode)
for (i = 0; i < dst[sb].num_wavs; i++)
ctx->waves_info->waves[dst[sb].start_index + i].amp_sf = get_bits(gb, 6);
else
ctx->waves_info->waves[dst[sb].start_index].amp_sf = get_bits(gb, 6);
}
break;
case 1:
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
if (!band_has_tones[sb] || !dst[sb].num_wavs)
continue;
if (ctx->waves_info->amplitude_mode)
for (i = 0; i < dst[sb].num_wavs; i++)
ctx->waves_info->waves[dst[sb].start_index + i].amp_sf =
get_vlc2(gb, tone_vlc_tabs[3].table,
tone_vlc_tabs[3].bits, 1) + 20;
else
ctx->waves_info->waves[dst[sb].start_index].amp_sf =
get_vlc2(gb, tone_vlc_tabs[4].table,
tone_vlc_tabs[4].bits, 1) + 24;
}
break;
case 2:
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
if (!band_has_tones[sb] || !dst[sb].num_wavs)
continue;
for (i = 0; i < dst[sb].num_wavs; i++) {
delta = get_vlc2(gb, tone_vlc_tabs[5].table,
tone_vlc_tabs[5].bits, 1);
delta = sign_extend(delta, 5);
pred = refwaves[dst[sb].start_index + i] >= 0 ?
ctx->waves_info->waves[refwaves[dst[sb].start_index + i]].amp_sf : 34;
ctx->waves_info->waves[dst[sb].start_index + i].amp_sf = (pred + delta) & 0x3F;
}
}
break;
case 3:
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++) {
if (!band_has_tones[sb])
continue;
for (i = 0; i < dst[sb].num_wavs; i++)
ctx->waves_info->waves[dst[sb].start_index + i].amp_sf =
refwaves[dst[sb].start_index + i] >= 0
? ctx->waves_info->waves[refwaves[dst[sb].start_index + i]].amp_sf
: 32;
}
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(GetBitContext *VAR_0, Atrac3pChanUnitCtx *VAR_1,
int VAR_2, int VAR_3[])
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
Atrac3pWaveParam *wsrc, *wref;
int VAR_13[48];
Atrac3pWavesData *dst = VAR_1->channels[VAR_2].tones_info;
Atrac3pWavesData *ref = VAR_1->channels[0].tones_info;
if (VAR_2) {
for (VAR_5 = 0; VAR_5 < VAR_1->waves_info->num_tone_bands; VAR_5++) {
if (!VAR_3[VAR_5] || !dst[VAR_5].num_wavs)
continue;
wsrc = &VAR_1->waves_info->waves[dst[VAR_5].start_index];
wref = &VAR_1->waves_info->waves[ref[VAR_5].start_index];
for (VAR_6 = 0; VAR_6 < dst[VAR_5].num_wavs; VAR_6++) {
for (VAR_7 = 0, VAR_10 = 0, VAR_9 = 1024; VAR_7 < ref[VAR_5].num_wavs; VAR_7++) {
VAR_8 = FFABS(wsrc[VAR_6].freq_index - wref[VAR_7].freq_index);
if (VAR_8 < VAR_9) {
VAR_9 = VAR_8;
VAR_10 = VAR_7;
}
}
if (VAR_9 < 8)
VAR_13[dst[VAR_5].start_index + VAR_6] = VAR_10 + ref[VAR_5].start_index;
else if (VAR_6 < ref[VAR_5].num_wavs)
VAR_13[dst[VAR_5].start_index + VAR_6] = VAR_6 + ref[VAR_5].start_index;
else
VAR_13[dst[VAR_5].start_index + VAR_6] = -1;
}
}
}
VAR_4 = get_bits(VAR_0, VAR_2 + 1);
switch (VAR_4) {
case 0:
for (VAR_5 = 0; VAR_5 < VAR_1->waves_info->num_tone_bands; VAR_5++) {
if (!VAR_3[VAR_5] || !dst[VAR_5].num_wavs)
continue;
if (VAR_1->waves_info->amplitude_mode)
for (VAR_7 = 0; VAR_7 < dst[VAR_5].num_wavs; VAR_7++)
VAR_1->waves_info->waves[dst[VAR_5].start_index + VAR_7].amp_sf = get_bits(VAR_0, 6);
else
VAR_1->waves_info->waves[dst[VAR_5].start_index].amp_sf = get_bits(VAR_0, 6);
}
break;
case 1:
for (VAR_5 = 0; VAR_5 < VAR_1->waves_info->num_tone_bands; VAR_5++) {
if (!VAR_3[VAR_5] || !dst[VAR_5].num_wavs)
continue;
if (VAR_1->waves_info->amplitude_mode)
for (VAR_7 = 0; VAR_7 < dst[VAR_5].num_wavs; VAR_7++)
VAR_1->waves_info->waves[dst[VAR_5].start_index + VAR_7].amp_sf =
get_vlc2(VAR_0, tone_vlc_tabs[3].table,
tone_vlc_tabs[3].bits, 1) + 20;
else
VAR_1->waves_info->waves[dst[VAR_5].start_index].amp_sf =
get_vlc2(VAR_0, tone_vlc_tabs[4].table,
tone_vlc_tabs[4].bits, 1) + 24;
}
break;
case 2:
for (VAR_5 = 0; VAR_5 < VAR_1->waves_info->num_tone_bands; VAR_5++) {
if (!VAR_3[VAR_5] || !dst[VAR_5].num_wavs)
continue;
for (VAR_7 = 0; VAR_7 < dst[VAR_5].num_wavs; VAR_7++) {
VAR_11 = get_vlc2(VAR_0, tone_vlc_tabs[5].table,
tone_vlc_tabs[5].bits, 1);
VAR_11 = sign_extend(VAR_11, 5);
VAR_12 = VAR_13[dst[VAR_5].start_index + VAR_7] >= 0 ?
VAR_1->waves_info->waves[VAR_13[dst[VAR_5].start_index + VAR_7]].amp_sf : 34;
VAR_1->waves_info->waves[dst[VAR_5].start_index + VAR_7].amp_sf = (VAR_12 + VAR_11) & 0x3F;
}
}
break;
case 3:
for (VAR_5 = 0; VAR_5 < VAR_1->waves_info->num_tone_bands; VAR_5++) {
if (!VAR_3[VAR_5])
continue;
for (VAR_7 = 0; VAR_7 < dst[VAR_5].num_wavs; VAR_7++)
VAR_1->waves_info->waves[dst[VAR_5].start_index + VAR_7].amp_sf =
VAR_13[dst[VAR_5].start_index + VAR_7] >= 0
? VAR_1->waves_info->waves[VAR_13[dst[VAR_5].start_index + VAR_7]].amp_sf
: 32;
}
break;
}
}
| [
"static void FUNC_0(GetBitContext *VAR_0, Atrac3pChanUnitCtx *VAR_1,\nint VAR_2, int VAR_3[])\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"Atrac3pWaveParam *wsrc, *wref;",
"int VAR_13[48];",
"Atrac3pWavesData *dst = VAR_1->channels[VAR_2].tones_info;",
"Atrac3pWavesData *ref = VAR_1->channels[0].tones_info;",
"if (VAR_2) {",
"for (VAR_5 = 0; VAR_5 < VAR_1->waves_info->num_tone_bands; VAR_5++) {",
"if (!VAR_3[VAR_5] || !dst[VAR_5].num_wavs)\ncontinue;",
"wsrc = &VAR_1->waves_info->waves[dst[VAR_5].start_index];",
"wref = &VAR_1->waves_info->waves[ref[VAR_5].start_index];",
"for (VAR_6 = 0; VAR_6 < dst[VAR_5].num_wavs; VAR_6++) {",
"for (VAR_7 = 0, VAR_10 = 0, VAR_9 = 1024; VAR_7 < ref[VAR_5].num_wavs; VAR_7++) {",
"VAR_8 = FFABS(wsrc[VAR_6].freq_index - wref[VAR_7].freq_index);",
"if (VAR_8 < VAR_9) {",
"VAR_9 = VAR_8;",
"VAR_10 = VAR_7;",
"}",
"}",
"if (VAR_9 < 8)\nVAR_13[dst[VAR_5].start_index + VAR_6] = VAR_10 + ref[VAR_5].start_index;",
"else if (VAR_6 < ref[VAR_5].num_wavs)\nVAR_13[dst[VAR_5].start_index + VAR_6] = VAR_6 + ref[VAR_5].start_index;",
"else\nVAR_13[dst[VAR_5].start_index + VAR_6] = -1;",
"}",
"}",
"}",
"VAR_4 = get_bits(VAR_0, VAR_2 + 1);",
"switch (VAR_4) {",
"case 0:\nfor (VAR_5 = 0; VAR_5 < VAR_1->waves_info->num_tone_bands; VAR_5++) {",
"if (!VAR_3[VAR_5] || !dst[VAR_5].num_wavs)\ncontinue;",
"if (VAR_1->waves_info->amplitude_mode)\nfor (VAR_7 = 0; VAR_7 < dst[VAR_5].num_wavs; VAR_7++)",
"VAR_1->waves_info->waves[dst[VAR_5].start_index + VAR_7].amp_sf = get_bits(VAR_0, 6);",
"else\nVAR_1->waves_info->waves[dst[VAR_5].start_index].amp_sf = get_bits(VAR_0, 6);",
"}",
"break;",
"case 1:\nfor (VAR_5 = 0; VAR_5 < VAR_1->waves_info->num_tone_bands; VAR_5++) {",
"if (!VAR_3[VAR_5] || !dst[VAR_5].num_wavs)\ncontinue;",
"if (VAR_1->waves_info->amplitude_mode)\nfor (VAR_7 = 0; VAR_7 < dst[VAR_5].num_wavs; VAR_7++)",
"VAR_1->waves_info->waves[dst[VAR_5].start_index + VAR_7].amp_sf =\nget_vlc2(VAR_0, tone_vlc_tabs[3].table,\ntone_vlc_tabs[3].bits, 1) + 20;",
"else\nVAR_1->waves_info->waves[dst[VAR_5].start_index].amp_sf =\nget_vlc2(VAR_0, tone_vlc_tabs[4].table,\ntone_vlc_tabs[4].bits, 1) + 24;",
"}",
"break;",
"case 2:\nfor (VAR_5 = 0; VAR_5 < VAR_1->waves_info->num_tone_bands; VAR_5++) {",
"if (!VAR_3[VAR_5] || !dst[VAR_5].num_wavs)\ncontinue;",
"for (VAR_7 = 0; VAR_7 < dst[VAR_5].num_wavs; VAR_7++) {",
"VAR_11 = get_vlc2(VAR_0, tone_vlc_tabs[5].table,\ntone_vlc_tabs[5].bits, 1);",
"VAR_11 = sign_extend(VAR_11, 5);",
"VAR_12 = VAR_13[dst[VAR_5].start_index + VAR_7] >= 0 ?\nVAR_1->waves_info->waves[VAR_13[dst[VAR_5].start_index + VAR_7]].amp_sf : 34;",
"VAR_1->waves_info->waves[dst[VAR_5].start_index + VAR_7].amp_sf = (VAR_12 + VAR_11) & 0x3F;",
"}",
"}",
"break;",
"case 3:\nfor (VAR_5 = 0; VAR_5 < VAR_1->waves_info->num_tone_bands; VAR_5++) {",
"if (!VAR_3[VAR_5])\ncontinue;",
"for (VAR_7 = 0; VAR_7 < dst[VAR_5].num_wavs; VAR_7++)",
"VAR_1->waves_info->waves[dst[VAR_5].start_index + VAR_7].amp_sf =\nVAR_13[dst[VAR_5].start_index + VAR_7] >= 0\n? VAR_1->waves_info->waves[VAR_13[dst[VAR_5].start_index + VAR_7]].amp_sf\n: 32;",
"}",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
53,
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
73
],
[
75,
77
],
[
79,
81
],
[
83,
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97,
99
],
[
101,
103
],
[
105,
107
],
[
109,
111,
113
],
[
115,
117,
119,
121
],
[
123
],
[
125
],
[
127,
129
],
[
131,
133
],
[
135
],
[
137,
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159,
161
],
[
163
],
[
165,
167,
169,
171
],
[
173
],
[
175
],
[
177
],
[
179
]
] |
22,754 | static int vhost_net_set_vnet_endian(VirtIODevice *dev, NetClientState *peer,
bool set)
{
int r = 0;
if (virtio_has_feature(dev, VIRTIO_F_VERSION_1) ||
(virtio_legacy_is_cross_endian(dev) && !virtio_is_big_endian(dev))) {
r = qemu_set_vnet_le(peer, set);
if (r) {
error_report("backend does not support LE vnet headers");
}
} else if (virtio_legacy_is_cross_endian(dev)) {
r = qemu_set_vnet_be(peer, set);
if (r) {
error_report("backend does not support BE vnet headers");
}
}
return r;
}
| false | qemu | 95129d6fc9ead97155627a4ca0cfd37282883658 | static int vhost_net_set_vnet_endian(VirtIODevice *dev, NetClientState *peer,
bool set)
{
int r = 0;
if (virtio_has_feature(dev, VIRTIO_F_VERSION_1) ||
(virtio_legacy_is_cross_endian(dev) && !virtio_is_big_endian(dev))) {
r = qemu_set_vnet_le(peer, set);
if (r) {
error_report("backend does not support LE vnet headers");
}
} else if (virtio_legacy_is_cross_endian(dev)) {
r = qemu_set_vnet_be(peer, set);
if (r) {
error_report("backend does not support BE vnet headers");
}
}
return r;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VirtIODevice *VAR_0, NetClientState *VAR_1,
bool VAR_2)
{
int VAR_3 = 0;
if (virtio_has_feature(VAR_0, VIRTIO_F_VERSION_1) ||
(virtio_legacy_is_cross_endian(VAR_0) && !virtio_is_big_endian(VAR_0))) {
VAR_3 = qemu_set_vnet_le(VAR_1, VAR_2);
if (VAR_3) {
error_report("backend does not support LE vnet headers");
}
} else if (virtio_legacy_is_cross_endian(VAR_0)) {
VAR_3 = qemu_set_vnet_be(VAR_1, VAR_2);
if (VAR_3) {
error_report("backend does not support BE vnet headers");
}
}
return VAR_3;
}
| [
"static int FUNC_0(VirtIODevice *VAR_0, NetClientState *VAR_1,\nbool VAR_2)\n{",
"int VAR_3 = 0;",
"if (virtio_has_feature(VAR_0, VIRTIO_F_VERSION_1) ||\n(virtio_legacy_is_cross_endian(VAR_0) && !virtio_is_big_endian(VAR_0))) {",
"VAR_3 = qemu_set_vnet_le(VAR_1, VAR_2);",
"if (VAR_3) {",
"error_report(\"backend does not support LE vnet headers\");",
"}",
"} else if (virtio_legacy_is_cross_endian(VAR_0)) {",
"VAR_3 = qemu_set_vnet_be(VAR_1, VAR_2);",
"if (VAR_3) {",
"error_report(\"backend does not support BE vnet headers\");",
"}",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
22,755 | static void virtio_net_add_queue(VirtIONet *n, int index)
{
VirtIODevice *vdev = VIRTIO_DEVICE(n);
n->vqs[index].rx_vq = virtio_add_queue(vdev, n->net_conf.rx_queue_size,
virtio_net_handle_rx);
if (n->net_conf.tx && !strcmp(n->net_conf.tx, "timer")) {
n->vqs[index].tx_vq =
virtio_add_queue(vdev, 256, virtio_net_handle_tx_timer);
n->vqs[index].tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
virtio_net_tx_timer,
&n->vqs[index]);
} else {
n->vqs[index].tx_vq =
virtio_add_queue(vdev, 256, virtio_net_handle_tx_bh);
n->vqs[index].tx_bh = qemu_bh_new(virtio_net_tx_bh, &n->vqs[index]);
}
n->vqs[index].tx_waiting = 0;
n->vqs[index].n = n;
}
| false | qemu | 9b02e1618cf26aa52cf786f215d757506dda14f8 | static void virtio_net_add_queue(VirtIONet *n, int index)
{
VirtIODevice *vdev = VIRTIO_DEVICE(n);
n->vqs[index].rx_vq = virtio_add_queue(vdev, n->net_conf.rx_queue_size,
virtio_net_handle_rx);
if (n->net_conf.tx && !strcmp(n->net_conf.tx, "timer")) {
n->vqs[index].tx_vq =
virtio_add_queue(vdev, 256, virtio_net_handle_tx_timer);
n->vqs[index].tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
virtio_net_tx_timer,
&n->vqs[index]);
} else {
n->vqs[index].tx_vq =
virtio_add_queue(vdev, 256, virtio_net_handle_tx_bh);
n->vqs[index].tx_bh = qemu_bh_new(virtio_net_tx_bh, &n->vqs[index]);
}
n->vqs[index].tx_waiting = 0;
n->vqs[index].n = n;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VirtIONet *VAR_0, int VAR_1)
{
VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);
VAR_0->vqs[VAR_1].rx_vq = virtio_add_queue(vdev, VAR_0->net_conf.rx_queue_size,
virtio_net_handle_rx);
if (VAR_0->net_conf.tx && !strcmp(VAR_0->net_conf.tx, "timer")) {
VAR_0->vqs[VAR_1].tx_vq =
virtio_add_queue(vdev, 256, virtio_net_handle_tx_timer);
VAR_0->vqs[VAR_1].tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
virtio_net_tx_timer,
&VAR_0->vqs[VAR_1]);
} else {
VAR_0->vqs[VAR_1].tx_vq =
virtio_add_queue(vdev, 256, virtio_net_handle_tx_bh);
VAR_0->vqs[VAR_1].tx_bh = qemu_bh_new(virtio_net_tx_bh, &VAR_0->vqs[VAR_1]);
}
VAR_0->vqs[VAR_1].tx_waiting = 0;
VAR_0->vqs[VAR_1].VAR_0 = VAR_0;
}
| [
"static void FUNC_0(VirtIONet *VAR_0, int VAR_1)\n{",
"VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);",
"VAR_0->vqs[VAR_1].rx_vq = virtio_add_queue(vdev, VAR_0->net_conf.rx_queue_size,\nvirtio_net_handle_rx);",
"if (VAR_0->net_conf.tx && !strcmp(VAR_0->net_conf.tx, \"timer\")) {",
"VAR_0->vqs[VAR_1].tx_vq =\nvirtio_add_queue(vdev, 256, virtio_net_handle_tx_timer);",
"VAR_0->vqs[VAR_1].tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,\nvirtio_net_tx_timer,\n&VAR_0->vqs[VAR_1]);",
"} else {",
"VAR_0->vqs[VAR_1].tx_vq =\nvirtio_add_queue(vdev, 256, virtio_net_handle_tx_bh);",
"VAR_0->vqs[VAR_1].tx_bh = qemu_bh_new(virtio_net_tx_bh, &VAR_0->vqs[VAR_1]);",
"}",
"VAR_0->vqs[VAR_1].tx_waiting = 0;",
"VAR_0->vqs[VAR_1].VAR_0 = VAR_0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15,
17
],
[
19,
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
]
] |
22,756 | int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,
unsigned int out_bytes)
{
unsigned int in_total, out_total;
virtqueue_get_avail_bytes(vq, &in_total, &out_total);
if ((in_bytes && in_bytes < in_total)
|| (out_bytes && out_bytes < out_total)) {
return 1;
}
return 0;
}
| false | qemu | e1f7b4812eab992de46c98b3726745afb042a7f0 | int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,
unsigned int out_bytes)
{
unsigned int in_total, out_total;
virtqueue_get_avail_bytes(vq, &in_total, &out_total);
if ((in_bytes && in_bytes < in_total)
|| (out_bytes && out_bytes < out_total)) {
return 1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(VirtQueue *VAR_0, unsigned int VAR_1,
unsigned int VAR_2)
{
unsigned int VAR_3, VAR_4;
virtqueue_get_avail_bytes(VAR_0, &VAR_3, &VAR_4);
if ((VAR_1 && VAR_1 < VAR_3)
|| (VAR_2 && VAR_2 < VAR_4)) {
return 1;
}
return 0;
}
| [
"int FUNC_0(VirtQueue *VAR_0, unsigned int VAR_1,\nunsigned int VAR_2)\n{",
"unsigned int VAR_3, VAR_4;",
"virtqueue_get_avail_bytes(VAR_0, &VAR_3, &VAR_4);",
"if ((VAR_1 && VAR_1 < VAR_3)\n|| (VAR_2 && VAR_2 < VAR_4)) {",
"return 1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
22,757 | static always_inline void gen_load_spr(TCGv t, int reg)
{
tcg_gen_ld_tl(t, cpu_env, offsetof(CPUState, spr[reg]));
}
| false | qemu | 5c55ff99fa88158871d5b9f619c485deae5f3d5b | static always_inline void gen_load_spr(TCGv t, int reg)
{
tcg_gen_ld_tl(t, cpu_env, offsetof(CPUState, spr[reg]));
}
| {
"code": [],
"line_no": []
} | static always_inline void FUNC_0(TCGv t, int reg)
{
tcg_gen_ld_tl(t, cpu_env, offsetof(CPUState, spr[reg]));
}
| [
"static always_inline void FUNC_0(TCGv t, int reg)\n{",
"tcg_gen_ld_tl(t, cpu_env, offsetof(CPUState, spr[reg]));",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,758 | void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
BlockCompletionFunc *cb, void *opaque)
{
BlockAIOCB *acb;
acb = g_slice_alloc(aiocb_info->aiocb_size);
acb->aiocb_info = aiocb_info;
acb->bs = bs;
acb->cb = cb;
acb->opaque = opaque;
acb->refcnt = 1;
return acb;
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
BlockCompletionFunc *cb, void *opaque)
{
BlockAIOCB *acb;
acb = g_slice_alloc(aiocb_info->aiocb_size);
acb->aiocb_info = aiocb_info;
acb->bs = bs;
acb->cb = cb;
acb->opaque = opaque;
acb->refcnt = 1;
return acb;
}
| {
"code": [],
"line_no": []
} | void *FUNC_0(const AIOCBInfo *VAR_0, BlockDriverState *VAR_1,
BlockCompletionFunc *VAR_2, void *VAR_3)
{
BlockAIOCB *acb;
acb = g_slice_alloc(VAR_0->aiocb_size);
acb->VAR_0 = VAR_0;
acb->VAR_1 = VAR_1;
acb->VAR_2 = VAR_2;
acb->VAR_3 = VAR_3;
acb->refcnt = 1;
return acb;
}
| [
"void *FUNC_0(const AIOCBInfo *VAR_0, BlockDriverState *VAR_1,\nBlockCompletionFunc *VAR_2, void *VAR_3)\n{",
"BlockAIOCB *acb;",
"acb = g_slice_alloc(VAR_0->aiocb_size);",
"acb->VAR_0 = VAR_0;",
"acb->VAR_1 = VAR_1;",
"acb->VAR_2 = VAR_2;",
"acb->VAR_3 = VAR_3;",
"acb->refcnt = 1;",
"return acb;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
22,760 | char *socket_address_to_string(struct SocketAddress *addr, Error **errp)
{
char *buf;
InetSocketAddress *inet;
switch (addr->type) {
case SOCKET_ADDRESS_KIND_INET:
inet = addr->u.inet.data;
if (strchr(inet->host, ':') == NULL) {
buf = g_strdup_printf("%s:%s", inet->host, inet->port);
} else {
buf = g_strdup_printf("[%s]:%s", inet->host, inet->port);
}
break;
case SOCKET_ADDRESS_KIND_UNIX:
buf = g_strdup(addr->u.q_unix.data->path);
break;
case SOCKET_ADDRESS_KIND_FD:
buf = g_strdup(addr->u.fd.data->str);
break;
case SOCKET_ADDRESS_KIND_VSOCK:
buf = g_strdup_printf("%s:%s",
addr->u.vsock.data->cid,
addr->u.vsock.data->port);
break;
default:
abort();
}
return buf;
}
| false | qemu | dfd100f242370886bb6732f70f1f7cbd8eb9fedc | char *socket_address_to_string(struct SocketAddress *addr, Error **errp)
{
char *buf;
InetSocketAddress *inet;
switch (addr->type) {
case SOCKET_ADDRESS_KIND_INET:
inet = addr->u.inet.data;
if (strchr(inet->host, ':') == NULL) {
buf = g_strdup_printf("%s:%s", inet->host, inet->port);
} else {
buf = g_strdup_printf("[%s]:%s", inet->host, inet->port);
}
break;
case SOCKET_ADDRESS_KIND_UNIX:
buf = g_strdup(addr->u.q_unix.data->path);
break;
case SOCKET_ADDRESS_KIND_FD:
buf = g_strdup(addr->u.fd.data->str);
break;
case SOCKET_ADDRESS_KIND_VSOCK:
buf = g_strdup_printf("%s:%s",
addr->u.vsock.data->cid,
addr->u.vsock.data->port);
break;
default:
abort();
}
return buf;
}
| {
"code": [],
"line_no": []
} | char *FUNC_0(struct SocketAddress *VAR_0, Error **VAR_1)
{
char *VAR_2;
InetSocketAddress *inet;
switch (VAR_0->type) {
case SOCKET_ADDRESS_KIND_INET:
inet = VAR_0->u.inet.data;
if (strchr(inet->host, ':') == NULL) {
VAR_2 = g_strdup_printf("%s:%s", inet->host, inet->port);
} else {
VAR_2 = g_strdup_printf("[%s]:%s", inet->host, inet->port);
}
break;
case SOCKET_ADDRESS_KIND_UNIX:
VAR_2 = g_strdup(VAR_0->u.q_unix.data->path);
break;
case SOCKET_ADDRESS_KIND_FD:
VAR_2 = g_strdup(VAR_0->u.fd.data->str);
break;
case SOCKET_ADDRESS_KIND_VSOCK:
VAR_2 = g_strdup_printf("%s:%s",
VAR_0->u.vsock.data->cid,
VAR_0->u.vsock.data->port);
break;
default:
abort();
}
return VAR_2;
}
| [
"char *FUNC_0(struct SocketAddress *VAR_0, Error **VAR_1)\n{",
"char *VAR_2;",
"InetSocketAddress *inet;",
"switch (VAR_0->type) {",
"case SOCKET_ADDRESS_KIND_INET:\ninet = VAR_0->u.inet.data;",
"if (strchr(inet->host, ':') == NULL) {",
"VAR_2 = g_strdup_printf(\"%s:%s\", inet->host, inet->port);",
"} else {",
"VAR_2 = g_strdup_printf(\"[%s]:%s\", inet->host, inet->port);",
"}",
"break;",
"case SOCKET_ADDRESS_KIND_UNIX:\nVAR_2 = g_strdup(VAR_0->u.q_unix.data->path);",
"break;",
"case SOCKET_ADDRESS_KIND_FD:\nVAR_2 = g_strdup(VAR_0->u.fd.data->str);",
"break;",
"case SOCKET_ADDRESS_KIND_VSOCK:\nVAR_2 = g_strdup_printf(\"%s:%s\",\nVAR_0->u.vsock.data->cid,\nVAR_0->u.vsock.data->port);",
"break;",
"default:\nabort();",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
35
],
[
39,
41
],
[
43
],
[
47,
49,
51,
53
],
[
55
],
[
59,
61
],
[
63
],
[
65
],
[
67
]
] |
22,761 | static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path,
const char *name, FsCred *credp)
{
char *path;
int err = -1;
int serrno = 0;
V9fsString fullname;
char buffer[PATH_MAX];
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
path = fullname.data;
/* Determine the security model */
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);
if (err == -1) {
goto out;
}
credp->fc_mode = credp->fc_mode|S_IFDIR;
err = local_set_xattr(rpath(fs_ctx, path, buffer), credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);
if (err == -1) {
goto out;
}
credp->fc_mode = credp->fc_mode|S_IFDIR;
err = local_set_mapped_file_attr(fs_ctx, path, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
(fs_ctx->export_flags & V9FS_SM_NONE)) {
err = mkdir(rpath(fs_ctx, path, buffer), credp->fc_mode);
if (err == -1) {
goto out;
}
err = local_post_create_passthrough(fs_ctx, path, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
}
goto out;
err_end:
remove(rpath(fs_ctx, path, buffer));
errno = serrno;
out:
v9fs_string_free(&fullname);
return err;
}
| false | qemu | 4fa4ce7107c6ec432f185307158c5df91ce54308 | static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path,
const char *name, FsCred *credp)
{
char *path;
int err = -1;
int serrno = 0;
V9fsString fullname;
char buffer[PATH_MAX];
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
path = fullname.data;
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);
if (err == -1) {
goto out;
}
credp->fc_mode = credp->fc_mode|S_IFDIR;
err = local_set_xattr(rpath(fs_ctx, path, buffer), credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);
if (err == -1) {
goto out;
}
credp->fc_mode = credp->fc_mode|S_IFDIR;
err = local_set_mapped_file_attr(fs_ctx, path, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
(fs_ctx->export_flags & V9FS_SM_NONE)) {
err = mkdir(rpath(fs_ctx, path, buffer), credp->fc_mode);
if (err == -1) {
goto out;
}
err = local_post_create_passthrough(fs_ctx, path, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
}
goto out;
err_end:
remove(rpath(fs_ctx, path, buffer));
errno = serrno;
out:
v9fs_string_free(&fullname);
return err;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
const char *VAR_2, FsCred *VAR_3)
{
char *VAR_4;
int VAR_5 = -1;
int VAR_6 = 0;
V9fsString fullname;
char VAR_7[PATH_MAX];
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", VAR_1->data, VAR_2);
VAR_4 = fullname.data;
if (VAR_0->export_flags & V9FS_SM_MAPPED) {
VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), SM_LOCAL_DIR_MODE_BITS);
if (VAR_5 == -1) {
goto out;
}
VAR_3->fc_mode = VAR_3->fc_mode|S_IFDIR;
VAR_5 = local_set_xattr(rpath(VAR_0, VAR_4, VAR_7), VAR_3);
if (VAR_5 == -1) {
VAR_6 = errno;
goto err_end;
}
} else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {
VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), SM_LOCAL_DIR_MODE_BITS);
if (VAR_5 == -1) {
goto out;
}
VAR_3->fc_mode = VAR_3->fc_mode|S_IFDIR;
VAR_5 = local_set_mapped_file_attr(VAR_0, VAR_4, VAR_3);
if (VAR_5 == -1) {
VAR_6 = errno;
goto err_end;
}
} else if ((VAR_0->export_flags & V9FS_SM_PASSTHROUGH) ||
(VAR_0->export_flags & V9FS_SM_NONE)) {
VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), VAR_3->fc_mode);
if (VAR_5 == -1) {
goto out;
}
VAR_5 = local_post_create_passthrough(VAR_0, VAR_4, VAR_3);
if (VAR_5 == -1) {
VAR_6 = errno;
goto err_end;
}
}
goto out;
err_end:
remove(rpath(VAR_0, VAR_4, VAR_7));
errno = VAR_6;
out:
v9fs_string_free(&fullname);
return VAR_5;
}
| [
"static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,\nconst char *VAR_2, FsCred *VAR_3)\n{",
"char *VAR_4;",
"int VAR_5 = -1;",
"int VAR_6 = 0;",
"V9fsString fullname;",
"char VAR_7[PATH_MAX];",
"v9fs_string_init(&fullname);",
"v9fs_string_sprintf(&fullname, \"%s/%s\", VAR_1->data, VAR_2);",
"VAR_4 = fullname.data;",
"if (VAR_0->export_flags & V9FS_SM_MAPPED) {",
"VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), SM_LOCAL_DIR_MODE_BITS);",
"if (VAR_5 == -1) {",
"goto out;",
"}",
"VAR_3->fc_mode = VAR_3->fc_mode|S_IFDIR;",
"VAR_5 = local_set_xattr(rpath(VAR_0, VAR_4, VAR_7), VAR_3);",
"if (VAR_5 == -1) {",
"VAR_6 = errno;",
"goto err_end;",
"}",
"} else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {",
"VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), SM_LOCAL_DIR_MODE_BITS);",
"if (VAR_5 == -1) {",
"goto out;",
"}",
"VAR_3->fc_mode = VAR_3->fc_mode|S_IFDIR;",
"VAR_5 = local_set_mapped_file_attr(VAR_0, VAR_4, VAR_3);",
"if (VAR_5 == -1) {",
"VAR_6 = errno;",
"goto err_end;",
"}",
"} else if ((VAR_0->export_flags & V9FS_SM_PASSTHROUGH) ||",
"(VAR_0->export_flags & V9FS_SM_NONE)) {",
"VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), VAR_3->fc_mode);",
"if (VAR_5 == -1) {",
"goto out;",
"}",
"VAR_5 = local_post_create_passthrough(VAR_0, VAR_4, VAR_3);",
"if (VAR_5 == -1) {",
"VAR_6 = errno;",
"goto err_end;",
"}",
"}",
"goto out;",
"err_end:\nremove(rpath(VAR_0, VAR_4, VAR_7));",
"errno = VAR_6;",
"out:\nv9fs_string_free(&fullname);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101,
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
]
] |
22,762 | int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
const AVPacket *avpkt)
{
AVCodecInternal *avci = avctx->internal;
int ret;
// copy to ensure we do not change avpkt
AVPacket tmp = *avpkt;
if (!avctx->codec)
return AVERROR(EINVAL);
if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for video\n");
return AVERROR(EINVAL);
}
*got_picture_ptr = 0;
if ((avctx->coded_width || avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
return AVERROR(EINVAL);
avcodec_get_frame_defaults(picture);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) {
int did_split = av_packet_split_side_data(&tmp);
ret = apply_param_change(avctx, &tmp);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error applying parameter changes.\n");
if (avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
}
avctx->internal->pkt = &tmp;
if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
&tmp);
else {
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
&tmp);
picture->pkt_dts = avpkt->dts;
if(!avctx->has_b_frames){
av_frame_set_pkt_pos(picture, avpkt->pos);
}
//FIXME these should be under if(!avctx->has_b_frames)
/* get_buffer is supposed to set frame parameters */
if (!(avctx->codec->capabilities & CODEC_CAP_DR1)) {
if (!picture->sample_aspect_ratio.num) picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (!picture->width) picture->width = avctx->width;
if (!picture->height) picture->height = avctx->height;
if (picture->format == AV_PIX_FMT_NONE) picture->format = avctx->pix_fmt;
}
}
add_metadata_from_side_data(avctx, picture);
fail:
emms_c(); //needed to avoid an emms_c() call before every return;
avctx->internal->pkt = NULL;
if (did_split) {
av_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_picture_ptr) {
if (!avctx->refcounted_frames) {
int err = unrefcount_frame(avci, picture);
if (err < 0)
return err;
}
avctx->frame_number++;
av_frame_set_best_effort_timestamp(picture,
guess_correct_pts(avctx,
picture->pkt_pts,
picture->pkt_dts));
} else
av_frame_unref(picture);
} else
ret = 0;
/* many decoders assign whole AVFrames, thus overwriting extended_data;
* make sure it's set correctly */
picture->extended_data = picture->data;
return ret;
}
| false | FFmpeg | 985c5f226af35fff00a86bc36cc8eaa8da3d23b0 | int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
const AVPacket *avpkt)
{
AVCodecInternal *avci = avctx->internal;
int ret;
AVPacket tmp = *avpkt;
if (!avctx->codec)
return AVERROR(EINVAL);
if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for video\n");
return AVERROR(EINVAL);
}
*got_picture_ptr = 0;
if ((avctx->coded_width || avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
return AVERROR(EINVAL);
avcodec_get_frame_defaults(picture);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) {
int did_split = av_packet_split_side_data(&tmp);
ret = apply_param_change(avctx, &tmp);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error applying parameter changes.\n");
if (avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
}
avctx->internal->pkt = &tmp;
if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
&tmp);
else {
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
&tmp);
picture->pkt_dts = avpkt->dts;
if(!avctx->has_b_frames){
av_frame_set_pkt_pos(picture, avpkt->pos);
}
if (!(avctx->codec->capabilities & CODEC_CAP_DR1)) {
if (!picture->sample_aspect_ratio.num) picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (!picture->width) picture->width = avctx->width;
if (!picture->height) picture->height = avctx->height;
if (picture->format == AV_PIX_FMT_NONE) picture->format = avctx->pix_fmt;
}
}
add_metadata_from_side_data(avctx, picture);
fail:
emms_c();
avctx->internal->pkt = NULL;
if (did_split) {
av_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_picture_ptr) {
if (!avctx->refcounted_frames) {
int err = unrefcount_frame(avci, picture);
if (err < 0)
return err;
}
avctx->frame_number++;
av_frame_set_best_effort_timestamp(picture,
guess_correct_pts(avctx,
picture->pkt_pts,
picture->pkt_dts));
} else
av_frame_unref(picture);
} else
ret = 0;
picture->extended_data = picture->data;
return ret;
}
| {
"code": [],
"line_no": []
} | int VAR_0 avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
const AVPacket *avpkt)
{
AVCodecInternal *avci = avctx->internal;
int ret;
AVPacket tmp = *avpkt;
if (!avctx->codec)
return AVERROR(EINVAL);
if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for video\n");
return AVERROR(EINVAL);
}
*got_picture_ptr = 0;
if ((avctx->coded_width || avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
return AVERROR(EINVAL);
avcodec_get_frame_defaults(picture);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) {
int did_split = av_packet_split_side_data(&tmp);
ret = apply_param_change(avctx, &tmp);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error applying parameter changes.\n");
if (avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
}
avctx->internal->pkt = &tmp;
if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
&tmp);
else {
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
&tmp);
picture->pkt_dts = avpkt->dts;
if(!avctx->has_b_frames){
av_frame_set_pkt_pos(picture, avpkt->pos);
}
if (!(avctx->codec->capabilities & CODEC_CAP_DR1)) {
if (!picture->sample_aspect_ratio.num) picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (!picture->width) picture->width = avctx->width;
if (!picture->height) picture->height = avctx->height;
if (picture->format == AV_PIX_FMT_NONE) picture->format = avctx->pix_fmt;
}
}
add_metadata_from_side_data(avctx, picture);
fail:
emms_c();
avctx->internal->pkt = NULL;
if (did_split) {
av_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_picture_ptr) {
if (!avctx->refcounted_frames) {
int err = unrefcount_frame(avci, picture);
if (err < 0)
return err;
}
avctx->frame_number++;
av_frame_set_best_effort_timestamp(picture,
guess_correct_pts(avctx,
picture->pkt_pts,
picture->pkt_dts));
} else
av_frame_unref(picture);
} else
ret = 0;
picture->extended_data = picture->data;
return ret;
}
| [
"int VAR_0 avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,\nint *got_picture_ptr,\nconst AVPacket *avpkt)\n{",
"AVCodecInternal *avci = avctx->internal;",
"int ret;",
"AVPacket tmp = *avpkt;",
"if (!avctx->codec)\nreturn AVERROR(EINVAL);",
"if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) {",
"av_log(avctx, AV_LOG_ERROR, \"Invalid media type for video\\n\");",
"return AVERROR(EINVAL);",
"}",
"*got_picture_ptr = 0;",
"if ((avctx->coded_width || avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))\nreturn AVERROR(EINVAL);",
"avcodec_get_frame_defaults(picture);",
"if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) {",
"int did_split = av_packet_split_side_data(&tmp);",
"ret = apply_param_change(avctx, &tmp);",
"if (ret < 0) {",
"av_log(avctx, AV_LOG_ERROR, \"Error applying parameter changes.\\n\");",
"if (avctx->err_recognition & AV_EF_EXPLODE)\ngoto fail;",
"}",
"avctx->internal->pkt = &tmp;",
"if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)\nret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,\n&tmp);",
"else {",
"ret = avctx->codec->decode(avctx, picture, got_picture_ptr,\n&tmp);",
"picture->pkt_dts = avpkt->dts;",
"if(!avctx->has_b_frames){",
"av_frame_set_pkt_pos(picture, avpkt->pos);",
"}",
"if (!(avctx->codec->capabilities & CODEC_CAP_DR1)) {",
"if (!picture->sample_aspect_ratio.num) picture->sample_aspect_ratio = avctx->sample_aspect_ratio;",
"if (!picture->width) picture->width = avctx->width;",
"if (!picture->height) picture->height = avctx->height;",
"if (picture->format == AV_PIX_FMT_NONE) picture->format = avctx->pix_fmt;",
"}",
"}",
"add_metadata_from_side_data(avctx, picture);",
"fail:\nemms_c();",
"avctx->internal->pkt = NULL;",
"if (did_split) {",
"av_packet_free_side_data(&tmp);",
"if(ret == tmp.size)\nret = avpkt->size;",
"}",
"if (*got_picture_ptr) {",
"if (!avctx->refcounted_frames) {",
"int err = unrefcount_frame(avci, picture);",
"if (err < 0)\nreturn err;",
"}",
"avctx->frame_number++;",
"av_frame_set_best_effort_timestamp(picture,\nguess_correct_pts(avctx,\npicture->pkt_pts,\npicture->pkt_dts));",
"} else",
"av_frame_unref(picture);",
"} else",
"ret = 0;",
"picture->extended_data = picture->data;",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
65,
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109,
111
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
143
],
[
145,
147,
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
167
],
[
171
],
[
173
]
] |
22,763 | static void blk_mig_cleanup(Monitor *mon)
{
BlkMigDevState *bmds;
BlkMigBlock *blk;
set_dirty_tracking(0);
while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
bdrv_set_in_use(bmds->bs, 0);
drive_put_ref(drive_get_by_blockdev(bmds->bs));
g_free(bmds->aio_bitmap);
g_free(bmds);
}
while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
g_free(blk->buf);
g_free(blk);
}
monitor_printf(mon, "\n");
}
| false | qemu | 539de1246d355d3b8aa33fb7cde732352d8827c7 | static void blk_mig_cleanup(Monitor *mon)
{
BlkMigDevState *bmds;
BlkMigBlock *blk;
set_dirty_tracking(0);
while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
bdrv_set_in_use(bmds->bs, 0);
drive_put_ref(drive_get_by_blockdev(bmds->bs));
g_free(bmds->aio_bitmap);
g_free(bmds);
}
while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
g_free(blk->buf);
g_free(blk);
}
monitor_printf(mon, "\n");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Monitor *VAR_0)
{
BlkMigDevState *bmds;
BlkMigBlock *blk;
set_dirty_tracking(0);
while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
bdrv_set_in_use(bmds->bs, 0);
drive_put_ref(drive_get_by_blockdev(bmds->bs));
g_free(bmds->aio_bitmap);
g_free(bmds);
}
while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
g_free(blk->buf);
g_free(blk);
}
monitor_printf(VAR_0, "\n");
}
| [
"static void FUNC_0(Monitor *VAR_0)\n{",
"BlkMigDevState *bmds;",
"BlkMigBlock *blk;",
"set_dirty_tracking(0);",
"while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {",
"QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);",
"bdrv_set_in_use(bmds->bs, 0);",
"drive_put_ref(drive_get_by_blockdev(bmds->bs));",
"g_free(bmds->aio_bitmap);",
"g_free(bmds);",
"}",
"while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {",
"QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);",
"g_free(blk->buf);",
"g_free(blk);",
"}",
"monitor_printf(VAR_0, \"\\n\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
]
] |
22,764 | void ram_control_load_hook(QEMUFile *f, uint64_t flags)
{
int ret = 0;
if (f->ops->hook_ram_load) {
ret = f->ops->hook_ram_load(f, f->opaque, flags);
if (ret < 0) {
qemu_file_set_error(f, ret);
}
} else {
qemu_file_set_error(f, ret);
}
}
| false | qemu | c77a5f2daa1ccbd825d59b95c70207c0a196bb94 | void ram_control_load_hook(QEMUFile *f, uint64_t flags)
{
int ret = 0;
if (f->ops->hook_ram_load) {
ret = f->ops->hook_ram_load(f, f->opaque, flags);
if (ret < 0) {
qemu_file_set_error(f, ret);
}
} else {
qemu_file_set_error(f, ret);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QEMUFile *VAR_0, uint64_t VAR_1)
{
int VAR_2 = 0;
if (VAR_0->ops->hook_ram_load) {
VAR_2 = VAR_0->ops->hook_ram_load(VAR_0, VAR_0->opaque, VAR_1);
if (VAR_2 < 0) {
qemu_file_set_error(VAR_0, VAR_2);
}
} else {
qemu_file_set_error(VAR_0, VAR_2);
}
}
| [
"void FUNC_0(QEMUFile *VAR_0, uint64_t VAR_1)\n{",
"int VAR_2 = 0;",
"if (VAR_0->ops->hook_ram_load) {",
"VAR_2 = VAR_0->ops->hook_ram_load(VAR_0, VAR_0->opaque, VAR_1);",
"if (VAR_2 < 0) {",
"qemu_file_set_error(VAR_0, VAR_2);",
"}",
"} else {",
"qemu_file_set_error(VAR_0, VAR_2);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
22,765 | static void usb_host_handle_destroy(USBDevice *udev)
{
USBHostDevice *s = USB_HOST_DEVICE(udev);
qemu_remove_exit_notifier(&s->exit);
QTAILQ_REMOVE(&hostdevs, s, next);
usb_host_close(s);
}
| false | qemu | e058fa2dd599ccc780d334558be9c1d155222b80 | static void usb_host_handle_destroy(USBDevice *udev)
{
USBHostDevice *s = USB_HOST_DEVICE(udev);
qemu_remove_exit_notifier(&s->exit);
QTAILQ_REMOVE(&hostdevs, s, next);
usb_host_close(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(USBDevice *VAR_0)
{
USBHostDevice *s = USB_HOST_DEVICE(VAR_0);
qemu_remove_exit_notifier(&s->exit);
QTAILQ_REMOVE(&hostdevs, s, next);
usb_host_close(s);
}
| [
"static void FUNC_0(USBDevice *VAR_0)\n{",
"USBHostDevice *s = USB_HOST_DEVICE(VAR_0);",
"qemu_remove_exit_notifier(&s->exit);",
"QTAILQ_REMOVE(&hostdevs, s, next);",
"usb_host_close(s);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
22,766 | static void *qpa_thread_out (void *arg)
{
PAVoiceOut *pa = arg;
HWVoiceOut *hw = &pa->hw;
int threshold;
threshold = conf.divisor ? hw->samples / conf.divisor : 0;
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
for (;;) {
int decr, to_mix, rpos;
for (;;) {
if (pa->done) {
goto exit;
}
if (pa->live > threshold) {
break;
}
if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {
goto exit;
}
}
decr = to_mix = pa->live;
rpos = hw->rpos;
if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
while (to_mix) {
int error;
int chunk = audio_MIN (to_mix, hw->samples - rpos);
struct st_sample *src = hw->mix_buf + rpos;
hw->clip (pa->pcm_buf, src, chunk);
if (pa_simple_write (pa->s, pa->pcm_buf,
chunk << hw->info.shift, &error) < 0) {
qpa_logerr (error, "pa_simple_write failed\n");
return NULL;
}
rpos = (rpos + chunk) % hw->samples;
to_mix -= chunk;
}
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
pa->live = 0;
pa->rpos = rpos;
pa->decr += decr;
}
exit:
audio_pt_unlock (&pa->pt, AUDIO_FUNC);
return NULL;
}
| false | qemu | 6315633b2535dc82dc1b3403f884b81e26b4c72c | static void *qpa_thread_out (void *arg)
{
PAVoiceOut *pa = arg;
HWVoiceOut *hw = &pa->hw;
int threshold;
threshold = conf.divisor ? hw->samples / conf.divisor : 0;
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
for (;;) {
int decr, to_mix, rpos;
for (;;) {
if (pa->done) {
goto exit;
}
if (pa->live > threshold) {
break;
}
if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {
goto exit;
}
}
decr = to_mix = pa->live;
rpos = hw->rpos;
if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
while (to_mix) {
int error;
int chunk = audio_MIN (to_mix, hw->samples - rpos);
struct st_sample *src = hw->mix_buf + rpos;
hw->clip (pa->pcm_buf, src, chunk);
if (pa_simple_write (pa->s, pa->pcm_buf,
chunk << hw->info.shift, &error) < 0) {
qpa_logerr (error, "pa_simple_write failed\n");
return NULL;
}
rpos = (rpos + chunk) % hw->samples;
to_mix -= chunk;
}
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
pa->live = 0;
pa->rpos = rpos;
pa->decr += decr;
}
exit:
audio_pt_unlock (&pa->pt, AUDIO_FUNC);
return NULL;
}
| {
"code": [],
"line_no": []
} | static void *FUNC_0 (void *VAR_0)
{
PAVoiceOut *pa = VAR_0;
HWVoiceOut *hw = &pa->hw;
int VAR_1;
VAR_1 = conf.divisor ? hw->samples / conf.divisor : 0;
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
for (;;) {
int VAR_2, VAR_3, VAR_4;
for (;;) {
if (pa->done) {
goto exit;
}
if (pa->live > VAR_1) {
break;
}
if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {
goto exit;
}
}
VAR_2 = VAR_3 = pa->live;
VAR_4 = hw->VAR_4;
if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
while (VAR_3) {
int VAR_5;
int VAR_6 = audio_MIN (VAR_3, hw->samples - VAR_4);
struct st_sample *VAR_7 = hw->mix_buf + VAR_4;
hw->clip (pa->pcm_buf, VAR_7, VAR_6);
if (pa_simple_write (pa->s, pa->pcm_buf,
VAR_6 << hw->info.shift, &VAR_5) < 0) {
qpa_logerr (VAR_5, "pa_simple_write failed\n");
return NULL;
}
VAR_4 = (VAR_4 + VAR_6) % hw->samples;
VAR_3 -= VAR_6;
}
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
pa->live = 0;
pa->VAR_4 = VAR_4;
pa->VAR_2 += VAR_2;
}
exit:
audio_pt_unlock (&pa->pt, AUDIO_FUNC);
return NULL;
}
| [
"static void *FUNC_0 (void *VAR_0)\n{",
"PAVoiceOut *pa = VAR_0;",
"HWVoiceOut *hw = &pa->hw;",
"int VAR_1;",
"VAR_1 = conf.divisor ? hw->samples / conf.divisor : 0;",
"if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {",
"return NULL;",
"}",
"for (;;) {",
"int VAR_2, VAR_3, VAR_4;",
"for (;;) {",
"if (pa->done) {",
"goto exit;",
"}",
"if (pa->live > VAR_1) {",
"break;",
"}",
"if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {",
"goto exit;",
"}",
"}",
"VAR_2 = VAR_3 = pa->live;",
"VAR_4 = hw->VAR_4;",
"if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {",
"return NULL;",
"}",
"while (VAR_3) {",
"int VAR_5;",
"int VAR_6 = audio_MIN (VAR_3, hw->samples - VAR_4);",
"struct st_sample *VAR_7 = hw->mix_buf + VAR_4;",
"hw->clip (pa->pcm_buf, VAR_7, VAR_6);",
"if (pa_simple_write (pa->s, pa->pcm_buf,\nVAR_6 << hw->info.shift, &VAR_5) < 0) {",
"qpa_logerr (VAR_5, \"pa_simple_write failed\\n\");",
"return NULL;",
"}",
"VAR_4 = (VAR_4 + VAR_6) % hw->samples;",
"VAR_3 -= VAR_6;",
"}",
"if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {",
"return NULL;",
"}",
"pa->live = 0;",
"pa->VAR_4 = VAR_4;",
"pa->VAR_2 += VAR_2;",
"}",
"exit:\naudio_pt_unlock (&pa->pt, AUDIO_FUNC);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125,
127
],
[
129
],
[
131
]
] |
22,767 | static void bench_undrained_flush_cb(void *opaque, int ret)
{
if (ret < 0) {
error_report("Failed flush request: %s\n", strerror(-ret));
exit(EXIT_FAILURE);
}
}
| false | qemu | df3c286c53ac51e7267f2761c7a0c62e11b6e815 | static void bench_undrained_flush_cb(void *opaque, int ret)
{
if (ret < 0) {
error_report("Failed flush request: %s\n", strerror(-ret));
exit(EXIT_FAILURE);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
if (VAR_1 < 0) {
error_report("Failed flush request: %s\n", strerror(-VAR_1));
exit(EXIT_FAILURE);
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"if (VAR_1 < 0) {",
"error_report(\"Failed flush request: %s\\n\", strerror(-VAR_1));",
"exit(EXIT_FAILURE);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
22,768 | static uint32_t nabm_readw (void *opaque, uint32_t addr)
{
PCIAC97LinkState *d = opaque;
AC97LinkState *s = &d->ac97;
AC97BusMasterRegs *r = NULL;
uint32_t index = addr - s->base[1];
uint32_t val = ~0U;
switch (index) {
case PI_SR:
case PO_SR:
case MC_SR:
r = &s->bm_regs[GET_BM (index)];
val = r->sr;
dolog ("SR[%d] -> %#x\n", GET_BM (index), val);
break;
case PI_PICB:
case PO_PICB:
case MC_PICB:
r = &s->bm_regs[GET_BM (index)];
val = r->picb;
dolog ("PICB[%d] -> %#x\n", GET_BM (index), val);
break;
default:
dolog ("U nabm readw %#x -> %#x\n", addr, val);
break;
}
return val;
}
| false | qemu | 10ee2aaa417d8d8978cdb2bbed55ebb152df5f6b | static uint32_t nabm_readw (void *opaque, uint32_t addr)
{
PCIAC97LinkState *d = opaque;
AC97LinkState *s = &d->ac97;
AC97BusMasterRegs *r = NULL;
uint32_t index = addr - s->base[1];
uint32_t val = ~0U;
switch (index) {
case PI_SR:
case PO_SR:
case MC_SR:
r = &s->bm_regs[GET_BM (index)];
val = r->sr;
dolog ("SR[%d] -> %#x\n", GET_BM (index), val);
break;
case PI_PICB:
case PO_PICB:
case MC_PICB:
r = &s->bm_regs[GET_BM (index)];
val = r->picb;
dolog ("PICB[%d] -> %#x\n", GET_BM (index), val);
break;
default:
dolog ("U nabm readw %#x -> %#x\n", addr, val);
break;
}
return val;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0 (void *opaque, uint32_t addr)
{
PCIAC97LinkState *d = opaque;
AC97LinkState *s = &d->ac97;
AC97BusMasterRegs *r = NULL;
uint32_t index = addr - s->base[1];
uint32_t val = ~0U;
switch (index) {
case PI_SR:
case PO_SR:
case MC_SR:
r = &s->bm_regs[GET_BM (index)];
val = r->sr;
dolog ("SR[%d] -> %#x\n", GET_BM (index), val);
break;
case PI_PICB:
case PO_PICB:
case MC_PICB:
r = &s->bm_regs[GET_BM (index)];
val = r->picb;
dolog ("PICB[%d] -> %#x\n", GET_BM (index), val);
break;
default:
dolog ("U nabm readw %#x -> %#x\n", addr, val);
break;
}
return val;
}
| [
"static uint32_t FUNC_0 (void *opaque, uint32_t addr)\n{",
"PCIAC97LinkState *d = opaque;",
"AC97LinkState *s = &d->ac97;",
"AC97BusMasterRegs *r = NULL;",
"uint32_t index = addr - s->base[1];",
"uint32_t val = ~0U;",
"switch (index) {",
"case PI_SR:\ncase PO_SR:\ncase MC_SR:\nr = &s->bm_regs[GET_BM (index)];",
"val = r->sr;",
"dolog (\"SR[%d] -> %#x\\n\", GET_BM (index), val);",
"break;",
"case PI_PICB:\ncase PO_PICB:\ncase MC_PICB:\nr = &s->bm_regs[GET_BM (index)];",
"val = r->picb;",
"dolog (\"PICB[%d] -> %#x\\n\", GET_BM (index), val);",
"break;",
"default:\ndolog (\"U nabm readw %#x -> %#x\\n\", addr, val);",
"break;",
"}",
"return val;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
33,
35,
37,
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
22,769 | static int ehci_state_executing(EHCIQueue *q, int async)
{
int again = 0;
int reload, nakcnt;
ehci_execute_complete(q);
if (q->usb_status == USB_RET_ASYNC) {
goto out;
}
if (q->usb_status == USB_RET_PROCERR) {
again = -1;
goto out;
}
// 4.10.3
if (!async) {
int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);
transactCtr--;
set_field(&q->qh.epcap, transactCtr, QH_EPCAP_MULT);
// 4.10.3, bottom of page 82, should exit this state when transaction
// counter decrements to 0
}
reload = get_field(q->qh.epchar, QH_EPCHAR_RL);
if (reload) {
nakcnt = get_field(q->qh.altnext_qtd, QH_ALTNEXT_NAKCNT);
if (q->usb_status == USB_RET_NAK) {
if (nakcnt) {
nakcnt--;
}
} else {
nakcnt = reload;
}
set_field(&q->qh.altnext_qtd, nakcnt, QH_ALTNEXT_NAKCNT);
}
/* 4.10.5 */
if ((q->usb_status == USB_RET_NAK) || (q->qh.token & QTD_TOKEN_ACTIVE)) {
ehci_set_state(q->ehci, async, EST_HORIZONTALQH);
} else {
ehci_set_state(q->ehci, async, EST_WRITEBACK);
}
again = 1;
out:
ehci_flush_qh(q);
return again;
}
| false | qemu | 553a6a59f6931bf3a034945e0c1585f4b05d6000 | static int ehci_state_executing(EHCIQueue *q, int async)
{
int again = 0;
int reload, nakcnt;
ehci_execute_complete(q);
if (q->usb_status == USB_RET_ASYNC) {
goto out;
}
if (q->usb_status == USB_RET_PROCERR) {
again = -1;
goto out;
}
if (!async) {
int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);
transactCtr--;
set_field(&q->qh.epcap, transactCtr, QH_EPCAP_MULT);
, bottom of page 82, should exit this state when transaction
}
reload = get_field(q->qh.epchar, QH_EPCHAR_RL);
if (reload) {
nakcnt = get_field(q->qh.altnext_qtd, QH_ALTNEXT_NAKCNT);
if (q->usb_status == USB_RET_NAK) {
if (nakcnt) {
nakcnt--;
}
} else {
nakcnt = reload;
}
set_field(&q->qh.altnext_qtd, nakcnt, QH_ALTNEXT_NAKCNT);
}
if ((q->usb_status == USB_RET_NAK) || (q->qh.token & QTD_TOKEN_ACTIVE)) {
ehci_set_state(q->ehci, async, EST_HORIZONTALQH);
} else {
ehci_set_state(q->ehci, async, EST_WRITEBACK);
}
again = 1;
out:
ehci_flush_qh(q);
return again;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(EHCIQueue *VAR_0, int VAR_1)
{
int VAR_2 = 0;
int VAR_3, VAR_4;
ehci_execute_complete(VAR_0);
if (VAR_0->usb_status == USB_RET_ASYNC) {
goto out;
}
if (VAR_0->usb_status == USB_RET_PROCERR) {
VAR_2 = -1;
goto out;
}
if (!VAR_1) {
int VAR_5 = get_field(VAR_0->qh.epcap, QH_EPCAP_MULT);
VAR_5--;
set_field(&VAR_0->qh.epcap, VAR_5, QH_EPCAP_MULT);
, bottom of page 82, should exit this state when transaction
}
VAR_3 = get_field(VAR_0->qh.epchar, QH_EPCHAR_RL);
if (VAR_3) {
VAR_4 = get_field(VAR_0->qh.altnext_qtd, QH_ALTNEXT_NAKCNT);
if (VAR_0->usb_status == USB_RET_NAK) {
if (VAR_4) {
VAR_4--;
}
} else {
VAR_4 = VAR_3;
}
set_field(&VAR_0->qh.altnext_qtd, VAR_4, QH_ALTNEXT_NAKCNT);
}
if ((VAR_0->usb_status == USB_RET_NAK) || (VAR_0->qh.token & QTD_TOKEN_ACTIVE)) {
ehci_set_state(VAR_0->ehci, VAR_1, EST_HORIZONTALQH);
} else {
ehci_set_state(VAR_0->ehci, VAR_1, EST_WRITEBACK);
}
VAR_2 = 1;
out:
ehci_flush_qh(VAR_0);
return VAR_2;
}
| [
"static int FUNC_0(EHCIQueue *VAR_0, int VAR_1)\n{",
"int VAR_2 = 0;",
"int VAR_3, VAR_4;",
"ehci_execute_complete(VAR_0);",
"if (VAR_0->usb_status == USB_RET_ASYNC) {",
"goto out;",
"}",
"if (VAR_0->usb_status == USB_RET_PROCERR) {",
"VAR_2 = -1;",
"goto out;",
"}",
"if (!VAR_1) {",
"int VAR_5 = get_field(VAR_0->qh.epcap, QH_EPCAP_MULT);",
"VAR_5--;",
"set_field(&VAR_0->qh.epcap, VAR_5, QH_EPCAP_MULT);",
", bottom of page 82, should exit this state when transaction\n}",
"VAR_3 = get_field(VAR_0->qh.epchar, QH_EPCHAR_RL);",
"if (VAR_3) {",
"VAR_4 = get_field(VAR_0->qh.altnext_qtd, QH_ALTNEXT_NAKCNT);",
"if (VAR_0->usb_status == USB_RET_NAK) {",
"if (VAR_4) {",
"VAR_4--;",
"}",
"} else {",
"VAR_4 = VAR_3;",
"}",
"set_field(&VAR_0->qh.altnext_qtd, VAR_4, QH_ALTNEXT_NAKCNT);",
"}",
"if ((VAR_0->usb_status == USB_RET_NAK) || (VAR_0->qh.token & QTD_TOKEN_ACTIVE)) {",
"ehci_set_state(VAR_0->ehci, VAR_1, EST_HORIZONTALQH);",
"} else {",
"ehci_set_state(VAR_0->ehci, VAR_1, EST_WRITEBACK);",
"}",
"VAR_2 = 1;",
"out:\nehci_flush_qh(VAR_0);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91,
93
],
[
95
],
[
97
]
] |
22,770 | static void gd_change_page(GtkNotebook *nb, gpointer arg1, guint arg2,
gpointer data)
{
GtkDisplayState *s = data;
VirtualConsole *vc;
gboolean on_vga;
if (!gtk_widget_get_realized(s->notebook)) {
return;
}
vc = gd_vc_find_by_page(s, arg2);
if (!vc) {
return;
}
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item),
TRUE);
on_vga = (vc->type == GD_VC_GFX);
if (!on_vga) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
FALSE);
} else if (s->full_screen) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
TRUE);
}
gtk_widget_set_sensitive(s->grab_item, on_vga);
gd_update_cursor(vc);
}
| false | qemu | 2884cf5b934808f547b5268a51be631805c25857 | static void gd_change_page(GtkNotebook *nb, gpointer arg1, guint arg2,
gpointer data)
{
GtkDisplayState *s = data;
VirtualConsole *vc;
gboolean on_vga;
if (!gtk_widget_get_realized(s->notebook)) {
return;
}
vc = gd_vc_find_by_page(s, arg2);
if (!vc) {
return;
}
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item),
TRUE);
on_vga = (vc->type == GD_VC_GFX);
if (!on_vga) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
FALSE);
} else if (s->full_screen) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
TRUE);
}
gtk_widget_set_sensitive(s->grab_item, on_vga);
gd_update_cursor(vc);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(GtkNotebook *VAR_0, gpointer VAR_1, guint VAR_2,
gpointer VAR_3)
{
GtkDisplayState *s = VAR_3;
VirtualConsole *vc;
gboolean on_vga;
if (!gtk_widget_get_realized(s->notebook)) {
return;
}
vc = gd_vc_find_by_page(s, VAR_2);
if (!vc) {
return;
}
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item),
TRUE);
on_vga = (vc->type == GD_VC_GFX);
if (!on_vga) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
FALSE);
} else if (s->full_screen) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
TRUE);
}
gtk_widget_set_sensitive(s->grab_item, on_vga);
gd_update_cursor(vc);
}
| [
"static void FUNC_0(GtkNotebook *VAR_0, gpointer VAR_1, guint VAR_2,\ngpointer VAR_3)\n{",
"GtkDisplayState *s = VAR_3;",
"VirtualConsole *vc;",
"gboolean on_vga;",
"if (!gtk_widget_get_realized(s->notebook)) {",
"return;",
"}",
"vc = gd_vc_find_by_page(s, VAR_2);",
"if (!vc) {",
"return;",
"}",
"gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item),\nTRUE);",
"on_vga = (vc->type == GD_VC_GFX);",
"if (!on_vga) {",
"gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),\nFALSE);",
"} else if (s->full_screen) {",
"gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),\nTRUE);",
"}",
"gtk_widget_set_sensitive(s->grab_item, on_vga);",
"gd_update_cursor(vc);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
]
] |
22,771 | static void address_space_update_topology(AddressSpace *as)
{
FlatView *old_view = as->current_map;
FlatView *new_view = generate_memory_topology(as->root);
address_space_update_topology_pass(as, old_view, new_view, false);
address_space_update_topology_pass(as, old_view, new_view, true);
as->current_map = new_view;
flatview_destroy(old_view);
address_space_update_ioeventfds(as);
}
| false | qemu | 856d72454f03aea26fd61c728762ef9cd1d71512 | static void address_space_update_topology(AddressSpace *as)
{
FlatView *old_view = as->current_map;
FlatView *new_view = generate_memory_topology(as->root);
address_space_update_topology_pass(as, old_view, new_view, false);
address_space_update_topology_pass(as, old_view, new_view, true);
as->current_map = new_view;
flatview_destroy(old_view);
address_space_update_ioeventfds(as);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AddressSpace *VAR_0)
{
FlatView *old_view = VAR_0->current_map;
FlatView *new_view = generate_memory_topology(VAR_0->root);
address_space_update_topology_pass(VAR_0, old_view, new_view, false);
address_space_update_topology_pass(VAR_0, old_view, new_view, true);
VAR_0->current_map = new_view;
flatview_destroy(old_view);
address_space_update_ioeventfds(VAR_0);
}
| [
"static void FUNC_0(AddressSpace *VAR_0)\n{",
"FlatView *old_view = VAR_0->current_map;",
"FlatView *new_view = generate_memory_topology(VAR_0->root);",
"address_space_update_topology_pass(VAR_0, old_view, new_view, false);",
"address_space_update_topology_pass(VAR_0, old_view, new_view, true);",
"VAR_0->current_map = new_view;",
"flatview_destroy(old_view);",
"address_space_update_ioeventfds(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
22,772 | static void ptimer_reload(ptimer_state *s)
{
if (s->delta == 0) {
ptimer_trigger(s);
s->delta = s->limit;
}
if (s->delta == 0 || s->period == 0) {
fprintf(stderr, "Timer with period zero, disabling\n");
s->enabled = 0;
return;
}
s->last_event = s->next_event;
s->next_event = s->last_event + s->delta * s->period;
if (s->period_frac) {
s->next_event += ((int64_t)s->period_frac * s->delta) >> 32;
}
timer_mod(s->timer, s->next_event);
}
| false | qemu | e91171e30235ae99ab8060988aa3c9536692bba8 | static void ptimer_reload(ptimer_state *s)
{
if (s->delta == 0) {
ptimer_trigger(s);
s->delta = s->limit;
}
if (s->delta == 0 || s->period == 0) {
fprintf(stderr, "Timer with period zero, disabling\n");
s->enabled = 0;
return;
}
s->last_event = s->next_event;
s->next_event = s->last_event + s->delta * s->period;
if (s->period_frac) {
s->next_event += ((int64_t)s->period_frac * s->delta) >> 32;
}
timer_mod(s->timer, s->next_event);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ptimer_state *VAR_0)
{
if (VAR_0->delta == 0) {
ptimer_trigger(VAR_0);
VAR_0->delta = VAR_0->limit;
}
if (VAR_0->delta == 0 || VAR_0->period == 0) {
fprintf(stderr, "Timer with period zero, disabling\n");
VAR_0->enabled = 0;
return;
}
VAR_0->last_event = VAR_0->next_event;
VAR_0->next_event = VAR_0->last_event + VAR_0->delta * VAR_0->period;
if (VAR_0->period_frac) {
VAR_0->next_event += ((int64_t)VAR_0->period_frac * VAR_0->delta) >> 32;
}
timer_mod(VAR_0->timer, VAR_0->next_event);
}
| [
"static void FUNC_0(ptimer_state *VAR_0)\n{",
"if (VAR_0->delta == 0) {",
"ptimer_trigger(VAR_0);",
"VAR_0->delta = VAR_0->limit;",
"}",
"if (VAR_0->delta == 0 || VAR_0->period == 0) {",
"fprintf(stderr, \"Timer with period zero, disabling\\n\");",
"VAR_0->enabled = 0;",
"return;",
"}",
"VAR_0->last_event = VAR_0->next_event;",
"VAR_0->next_event = VAR_0->last_event + VAR_0->delta * VAR_0->period;",
"if (VAR_0->period_frac) {",
"VAR_0->next_event += ((int64_t)VAR_0->period_frac * VAR_0->delta) >> 32;",
"}",
"timer_mod(VAR_0->timer, VAR_0->next_event);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
22,773 | static int init(AVFilterContext *ctx, const char *args, void *opaque)
{
GraphContext *gctx = ctx->priv;
if(!args)
return 0;
if(!(gctx->link_filter = avfilter_open(&vf_graph_dummy, NULL)))
return -1;
if(avfilter_init_filter(gctx->link_filter, NULL, ctx))
goto fail;
return graph_load_chain_from_string(ctx, args, NULL, NULL);
fail:
avfilter_destroy(gctx->link_filter);
return -1;
}
| false | FFmpeg | 54d7fcc1207ed37356f06e3a31a4e6bdaa096958 | static int init(AVFilterContext *ctx, const char *args, void *opaque)
{
GraphContext *gctx = ctx->priv;
if(!args)
return 0;
if(!(gctx->link_filter = avfilter_open(&vf_graph_dummy, NULL)))
return -1;
if(avfilter_init_filter(gctx->link_filter, NULL, ctx))
goto fail;
return graph_load_chain_from_string(ctx, args, NULL, NULL);
fail:
avfilter_destroy(gctx->link_filter);
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterContext *VAR_0, const char *VAR_1, void *VAR_2)
{
GraphContext *gctx = VAR_0->priv;
if(!VAR_1)
return 0;
if(!(gctx->link_filter = avfilter_open(&vf_graph_dummy, NULL)))
return -1;
if(avfilter_init_filter(gctx->link_filter, NULL, VAR_0))
goto fail;
return graph_load_chain_from_string(VAR_0, VAR_1, NULL, NULL);
fail:
avfilter_destroy(gctx->link_filter);
return -1;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0, const char *VAR_1, void *VAR_2)\n{",
"GraphContext *gctx = VAR_0->priv;",
"if(!VAR_1)\nreturn 0;",
"if(!(gctx->link_filter = avfilter_open(&vf_graph_dummy, NULL)))\nreturn -1;",
"if(avfilter_init_filter(gctx->link_filter, NULL, VAR_0))\ngoto fail;",
"return graph_load_chain_from_string(VAR_0, VAR_1, NULL, NULL);",
"fail:\navfilter_destroy(gctx->link_filter);",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15,
17
],
[
19,
21
],
[
25
],
[
29,
31
],
[
33
],
[
35
]
] |
22,776 | void kvm_arch_init_irq_routing(KVMState *s)
{
if (!kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) {
/* If kernel can't do irq routing, interrupt source
* override 0->2 cannot be set up as required by HPET.
* So we have to disable it.
*/
no_hpet = 1;
}
/* We know at this point that we're using the in-kernel
* irqchip, so we can use irqfds, and on x86 we know
* we can use msi via irqfd and GSI routing.
*/
kvm_irqfds_allowed = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_routing_allowed = true;
}
| false | qemu | f41389ae3c54bd5e2040e3f95a2872981c3ed965 | void kvm_arch_init_irq_routing(KVMState *s)
{
if (!kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) {
no_hpet = 1;
}
kvm_irqfds_allowed = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_routing_allowed = true;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(KVMState *VAR_0)
{
if (!kvm_check_extension(VAR_0, KVM_CAP_IRQ_ROUTING)) {
no_hpet = 1;
}
kvm_irqfds_allowed = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_routing_allowed = true;
}
| [
"void FUNC_0(KVMState *VAR_0)\n{",
"if (!kvm_check_extension(VAR_0, KVM_CAP_IRQ_ROUTING)) {",
"no_hpet = 1;",
"}",
"kvm_irqfds_allowed = true;",
"kvm_msi_via_irqfd_allowed = true;",
"kvm_gsi_routing_allowed = true;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
15
],
[
17
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
22,777 | static void output_visitor_test_add(const char *testpath,
TestOutputVisitorData *data,
void (*test_func)(TestOutputVisitorData *data, const void *user_data))
{
g_test_add(testpath, TestOutputVisitorData, data, visitor_output_setup,
test_func, visitor_output_teardown);
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void output_visitor_test_add(const char *testpath,
TestOutputVisitorData *data,
void (*test_func)(TestOutputVisitorData *data, const void *user_data))
{
g_test_add(testpath, TestOutputVisitorData, data, visitor_output_setup,
test_func, visitor_output_teardown);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0,
TestOutputVisitorData *VAR_3,
void (*VAR_2)(TestOutputVisitorData *VAR_3, const void *VAR_3))
{
g_test_add(VAR_0, TestOutputVisitorData, VAR_3, visitor_output_setup,
VAR_2, visitor_output_teardown);
}
| [
"static void FUNC_0(const char *VAR_0,\nTestOutputVisitorData *VAR_3,\nvoid (*VAR_2)(TestOutputVisitorData *VAR_3, const void *VAR_3))\n{",
"g_test_add(VAR_0, TestOutputVisitorData, VAR_3, visitor_output_setup,\nVAR_2, visitor_output_teardown);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9,
11
],
[
13
]
] |
22,778 | void cpu_loop (CPUState *env)
{
int trapnr;
target_siginfo_t info;
while (1) {
trapnr = cpu_alpha_exec (env);
switch (trapnr) {
case EXCP_RESET:
fprintf(stderr, "Reset requested. Exit\n");
exit(1);
break;
case EXCP_MCHK:
fprintf(stderr, "Machine check exception. Exit\n");
exit(1);
break;
case EXCP_ARITH:
fprintf(stderr, "Arithmetic trap.\n");
exit(1);
break;
case EXCP_HW_INTERRUPT:
fprintf(stderr, "External interrupt. Exit\n");
exit(1);
break;
case EXCP_DFAULT:
fprintf(stderr, "MMU data fault\n");
exit(1);
break;
case EXCP_DTB_MISS_PAL:
fprintf(stderr, "MMU data TLB miss in PALcode\n");
exit(1);
break;
case EXCP_ITB_MISS:
fprintf(stderr, "MMU instruction TLB miss\n");
exit(1);
break;
case EXCP_ITB_ACV:
fprintf(stderr, "MMU instruction access violation\n");
exit(1);
break;
case EXCP_DTB_MISS_NATIVE:
fprintf(stderr, "MMU data TLB miss\n");
exit(1);
break;
case EXCP_UNALIGN:
fprintf(stderr, "Unaligned access\n");
exit(1);
break;
case EXCP_OPCDEC:
fprintf(stderr, "Invalid instruction\n");
exit(1);
break;
case EXCP_FEN:
fprintf(stderr, "Floating-point not allowed\n");
exit(1);
break;
case EXCP_CALL_PAL ... (EXCP_CALL_PALP - 1):
call_pal(env, (trapnr >> 6) | 0x80);
break;
case EXCP_CALL_PALP ... (EXCP_CALL_PALE - 1):
fprintf(stderr, "Privileged call to PALcode\n");
exit(1);
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig (env, TARGET_SIGTRAP);
if (sig)
{
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
}
break;
default:
printf ("Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (env);
}
}
| false | qemu | 6049f4f831c6f409031dfa09282b38d0cbaecad8 | void cpu_loop (CPUState *env)
{
int trapnr;
target_siginfo_t info;
while (1) {
trapnr = cpu_alpha_exec (env);
switch (trapnr) {
case EXCP_RESET:
fprintf(stderr, "Reset requested. Exit\n");
exit(1);
break;
case EXCP_MCHK:
fprintf(stderr, "Machine check exception. Exit\n");
exit(1);
break;
case EXCP_ARITH:
fprintf(stderr, "Arithmetic trap.\n");
exit(1);
break;
case EXCP_HW_INTERRUPT:
fprintf(stderr, "External interrupt. Exit\n");
exit(1);
break;
case EXCP_DFAULT:
fprintf(stderr, "MMU data fault\n");
exit(1);
break;
case EXCP_DTB_MISS_PAL:
fprintf(stderr, "MMU data TLB miss in PALcode\n");
exit(1);
break;
case EXCP_ITB_MISS:
fprintf(stderr, "MMU instruction TLB miss\n");
exit(1);
break;
case EXCP_ITB_ACV:
fprintf(stderr, "MMU instruction access violation\n");
exit(1);
break;
case EXCP_DTB_MISS_NATIVE:
fprintf(stderr, "MMU data TLB miss\n");
exit(1);
break;
case EXCP_UNALIGN:
fprintf(stderr, "Unaligned access\n");
exit(1);
break;
case EXCP_OPCDEC:
fprintf(stderr, "Invalid instruction\n");
exit(1);
break;
case EXCP_FEN:
fprintf(stderr, "Floating-point not allowed\n");
exit(1);
break;
case EXCP_CALL_PAL ... (EXCP_CALL_PALP - 1):
call_pal(env, (trapnr >> 6) | 0x80);
break;
case EXCP_CALL_PALP ... (EXCP_CALL_PALE - 1):
fprintf(stderr, "Privileged call to PALcode\n");
exit(1);
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig (env, TARGET_SIGTRAP);
if (sig)
{
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
}
break;
default:
printf ("Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (env);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0 (CPUState *VAR_0)
{
int VAR_1;
target_siginfo_t info;
while (1) {
VAR_1 = cpu_alpha_exec (VAR_0);
switch (VAR_1) {
case EXCP_RESET:
fprintf(stderr, "Reset requested. Exit\n");
exit(1);
break;
case EXCP_MCHK:
fprintf(stderr, "Machine check exception. Exit\n");
exit(1);
break;
case EXCP_ARITH:
fprintf(stderr, "Arithmetic trap.\n");
exit(1);
break;
case EXCP_HW_INTERRUPT:
fprintf(stderr, "External interrupt. Exit\n");
exit(1);
break;
case EXCP_DFAULT:
fprintf(stderr, "MMU data fault\n");
exit(1);
break;
case EXCP_DTB_MISS_PAL:
fprintf(stderr, "MMU data TLB miss in PALcode\n");
exit(1);
break;
case EXCP_ITB_MISS:
fprintf(stderr, "MMU instruction TLB miss\n");
exit(1);
break;
case EXCP_ITB_ACV:
fprintf(stderr, "MMU instruction access violation\n");
exit(1);
break;
case EXCP_DTB_MISS_NATIVE:
fprintf(stderr, "MMU data TLB miss\n");
exit(1);
break;
case EXCP_UNALIGN:
fprintf(stderr, "Unaligned access\n");
exit(1);
break;
case EXCP_OPCDEC:
fprintf(stderr, "Invalid instruction\n");
exit(1);
break;
case EXCP_FEN:
fprintf(stderr, "Floating-point not allowed\n");
exit(1);
break;
case EXCP_CALL_PAL ... (EXCP_CALL_PALP - 1):
call_pal(VAR_0, (VAR_1 >> 6) | 0x80);
break;
case EXCP_CALL_PALP ... (EXCP_CALL_PALE - 1):
fprintf(stderr, "Privileged call to PALcode\n");
exit(1);
break;
case EXCP_DEBUG:
{
int VAR_2;
VAR_2 = gdb_handlesig (VAR_0, TARGET_SIGTRAP);
if (VAR_2)
{
info.si_signo = VAR_2;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(VAR_0, info.si_signo, &info);
}
}
break;
default:
printf ("Unhandled trap: 0x%x\n", VAR_1);
cpu_dump_state(VAR_0, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (VAR_0);
}
}
| [
"void FUNC_0 (CPUState *VAR_0)\n{",
"int VAR_1;",
"target_siginfo_t info;",
"while (1) {",
"VAR_1 = cpu_alpha_exec (VAR_0);",
"switch (VAR_1) {",
"case EXCP_RESET:\nfprintf(stderr, \"Reset requested. Exit\\n\");",
"exit(1);",
"break;",
"case EXCP_MCHK:\nfprintf(stderr, \"Machine check exception. Exit\\n\");",
"exit(1);",
"break;",
"case EXCP_ARITH:\nfprintf(stderr, \"Arithmetic trap.\\n\");",
"exit(1);",
"break;",
"case EXCP_HW_INTERRUPT:\nfprintf(stderr, \"External interrupt. Exit\\n\");",
"exit(1);",
"break;",
"case EXCP_DFAULT:\nfprintf(stderr, \"MMU data fault\\n\");",
"exit(1);",
"break;",
"case EXCP_DTB_MISS_PAL:\nfprintf(stderr, \"MMU data TLB miss in PALcode\\n\");",
"exit(1);",
"break;",
"case EXCP_ITB_MISS:\nfprintf(stderr, \"MMU instruction TLB miss\\n\");",
"exit(1);",
"break;",
"case EXCP_ITB_ACV:\nfprintf(stderr, \"MMU instruction access violation\\n\");",
"exit(1);",
"break;",
"case EXCP_DTB_MISS_NATIVE:\nfprintf(stderr, \"MMU data TLB miss\\n\");",
"exit(1);",
"break;",
"case EXCP_UNALIGN:\nfprintf(stderr, \"Unaligned access\\n\");",
"exit(1);",
"break;",
"case EXCP_OPCDEC:\nfprintf(stderr, \"Invalid instruction\\n\");",
"exit(1);",
"break;",
"case EXCP_FEN:\nfprintf(stderr, \"Floating-point not allowed\\n\");",
"exit(1);",
"break;",
"case EXCP_CALL_PAL ... (EXCP_CALL_PALP - 1):\ncall_pal(VAR_0, (VAR_1 >> 6) | 0x80);",
"break;",
"case EXCP_CALL_PALP ... (EXCP_CALL_PALE - 1):\nfprintf(stderr, \"Privileged call to PALcode\\n\");",
"exit(1);",
"break;",
"case EXCP_DEBUG:\n{",
"int VAR_2;",
"VAR_2 = gdb_handlesig (VAR_0, TARGET_SIGTRAP);",
"if (VAR_2)\n{",
"info.si_signo = VAR_2;",
"info.si_errno = 0;",
"info.si_code = TARGET_TRAP_BRKPT;",
"queue_signal(VAR_0, info.si_signo, &info);",
"}",
"}",
"break;",
"default:\nprintf (\"Unhandled trap: 0x%x\\n\", VAR_1);",
"cpu_dump_state(VAR_0, stderr, fprintf, 0);",
"exit (1);",
"}",
"process_pending_signals (VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
]
] |
22,779 | int rom_load_all(void)
{
target_phys_addr_t addr = 0;
MemoryRegionSection section;
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
continue;
}
if (addr > rom->addr) {
fprintf(stderr, "rom: requested regions overlap "
"(rom %s. free=0x" TARGET_FMT_plx
", addr=0x" TARGET_FMT_plx ")\n",
rom->name, addr, rom->addr);
return -1;
}
addr = rom->addr;
addr += rom->romsize;
section = memory_region_find(get_system_memory(), rom->addr, 1);
rom->isrom = section.size && memory_region_is_rom(section.mr);
}
qemu_register_reset(rom_reset, NULL);
roms_loaded = 1;
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | int rom_load_all(void)
{
target_phys_addr_t addr = 0;
MemoryRegionSection section;
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
continue;
}
if (addr > rom->addr) {
fprintf(stderr, "rom: requested regions overlap "
"(rom %s. free=0x" TARGET_FMT_plx
", addr=0x" TARGET_FMT_plx ")\n",
rom->name, addr, rom->addr);
return -1;
}
addr = rom->addr;
addr += rom->romsize;
section = memory_region_find(get_system_memory(), rom->addr, 1);
rom->isrom = section.size && memory_region_is_rom(section.mr);
}
qemu_register_reset(rom_reset, NULL);
roms_loaded = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void)
{
target_phys_addr_t addr = 0;
MemoryRegionSection section;
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
continue;
}
if (addr > rom->addr) {
fprintf(stderr, "rom: requested regions overlap "
"(rom %s. free=0x" TARGET_FMT_plx
", addr=0x" TARGET_FMT_plx ")\n",
rom->name, addr, rom->addr);
return -1;
}
addr = rom->addr;
addr += rom->romsize;
section = memory_region_find(get_system_memory(), rom->addr, 1);
rom->isrom = section.size && memory_region_is_rom(section.mr);
}
qemu_register_reset(rom_reset, NULL);
roms_loaded = 1;
return 0;
}
| [
"int FUNC_0(void)\n{",
"target_phys_addr_t addr = 0;",
"MemoryRegionSection section;",
"Rom *rom;",
"QTAILQ_FOREACH(rom, &roms, next) {",
"if (rom->fw_file) {",
"continue;",
"}",
"if (addr > rom->addr) {",
"fprintf(stderr, \"rom: requested regions overlap \"\n\"(rom %s. free=0x\" TARGET_FMT_plx\n\", addr=0x\" TARGET_FMT_plx \")\\n\",\nrom->name, addr, rom->addr);",
"return -1;",
"}",
"addr = rom->addr;",
"addr += rom->romsize;",
"section = memory_region_find(get_system_memory(), rom->addr, 1);",
"rom->isrom = section.size && memory_region_is_rom(section.mr);",
"}",
"qemu_register_reset(rom_reset, NULL);",
"roms_loaded = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25,
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
]
] |
22,780 | static int alsa_init_in (HWVoiceIn *hw, audsettings_t *as)
{
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
struct alsa_params_req req;
struct alsa_params_obt obt;
snd_pcm_t *handle;
audsettings_t obt_as;
req.fmt = aud_to_alsafmt (as->fmt);
req.freq = as->freq;
req.nchannels = as->nchannels;
req.period_size = conf.period_size_in;
req.buffer_size = conf.buffer_size_in;
req.size_in_usec = conf.size_in_usec_in;
req.override_mask = !!conf.period_size_in_overridden
| (!!conf.buffer_size_in_overridden << 1);
if (alsa_open (1, &req, &obt, &handle)) {
return -1;
}
obt_as.freq = obt.freq;
obt_as.nchannels = obt.nchannels;
obt_as.fmt = obt.fmt;
obt_as.endianness = obt.endianness;
audio_pcm_init_info (&hw->info, &obt_as);
hw->samples = obt.samples;
alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
if (!alsa->pcm_buf) {
dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
hw->samples, 1 << hw->info.shift);
alsa_anal_close (&handle);
return -1;
}
alsa->handle = handle;
return 0;
}
| false | qemu | 1ea879e5580f63414693655fcf0328559cdce138 | static int alsa_init_in (HWVoiceIn *hw, audsettings_t *as)
{
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
struct alsa_params_req req;
struct alsa_params_obt obt;
snd_pcm_t *handle;
audsettings_t obt_as;
req.fmt = aud_to_alsafmt (as->fmt);
req.freq = as->freq;
req.nchannels = as->nchannels;
req.period_size = conf.period_size_in;
req.buffer_size = conf.buffer_size_in;
req.size_in_usec = conf.size_in_usec_in;
req.override_mask = !!conf.period_size_in_overridden
| (!!conf.buffer_size_in_overridden << 1);
if (alsa_open (1, &req, &obt, &handle)) {
return -1;
}
obt_as.freq = obt.freq;
obt_as.nchannels = obt.nchannels;
obt_as.fmt = obt.fmt;
obt_as.endianness = obt.endianness;
audio_pcm_init_info (&hw->info, &obt_as);
hw->samples = obt.samples;
alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
if (!alsa->pcm_buf) {
dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
hw->samples, 1 << hw->info.shift);
alsa_anal_close (&handle);
return -1;
}
alsa->handle = handle;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (HWVoiceIn *VAR_0, audsettings_t *VAR_1)
{
ALSAVoiceIn *alsa = (ALSAVoiceIn *) VAR_0;
struct alsa_params_req VAR_2;
struct alsa_params_obt VAR_3;
snd_pcm_t *handle;
audsettings_t obt_as;
VAR_2.fmt = aud_to_alsafmt (VAR_1->fmt);
VAR_2.freq = VAR_1->freq;
VAR_2.nchannels = VAR_1->nchannels;
VAR_2.period_size = conf.period_size_in;
VAR_2.buffer_size = conf.buffer_size_in;
VAR_2.size_in_usec = conf.size_in_usec_in;
VAR_2.override_mask = !!conf.period_size_in_overridden
| (!!conf.buffer_size_in_overridden << 1);
if (alsa_open (1, &VAR_2, &VAR_3, &handle)) {
return -1;
}
obt_as.freq = VAR_3.freq;
obt_as.nchannels = VAR_3.nchannels;
obt_as.fmt = VAR_3.fmt;
obt_as.endianness = VAR_3.endianness;
audio_pcm_init_info (&VAR_0->info, &obt_as);
VAR_0->samples = VAR_3.samples;
alsa->pcm_buf = audio_calloc (AUDIO_FUNC, VAR_0->samples, 1 << VAR_0->info.shift);
if (!alsa->pcm_buf) {
dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
VAR_0->samples, 1 << VAR_0->info.shift);
alsa_anal_close (&handle);
return -1;
}
alsa->handle = handle;
return 0;
}
| [
"static int FUNC_0 (HWVoiceIn *VAR_0, audsettings_t *VAR_1)\n{",
"ALSAVoiceIn *alsa = (ALSAVoiceIn *) VAR_0;",
"struct alsa_params_req VAR_2;",
"struct alsa_params_obt VAR_3;",
"snd_pcm_t *handle;",
"audsettings_t obt_as;",
"VAR_2.fmt = aud_to_alsafmt (VAR_1->fmt);",
"VAR_2.freq = VAR_1->freq;",
"VAR_2.nchannels = VAR_1->nchannels;",
"VAR_2.period_size = conf.period_size_in;",
"VAR_2.buffer_size = conf.buffer_size_in;",
"VAR_2.size_in_usec = conf.size_in_usec_in;",
"VAR_2.override_mask = !!conf.period_size_in_overridden\n| (!!conf.buffer_size_in_overridden << 1);",
"if (alsa_open (1, &VAR_2, &VAR_3, &handle)) {",
"return -1;",
"}",
"obt_as.freq = VAR_3.freq;",
"obt_as.nchannels = VAR_3.nchannels;",
"obt_as.fmt = VAR_3.fmt;",
"obt_as.endianness = VAR_3.endianness;",
"audio_pcm_init_info (&VAR_0->info, &obt_as);",
"VAR_0->samples = VAR_3.samples;",
"alsa->pcm_buf = audio_calloc (AUDIO_FUNC, VAR_0->samples, 1 << VAR_0->info.shift);",
"if (!alsa->pcm_buf) {",
"dolog (\"Could not allocate ADC buffer (%d samples, each %d bytes)\\n\",\nVAR_0->samples, 1 << VAR_0->info.shift);",
"alsa_anal_close (&handle);",
"return -1;",
"}",
"alsa->handle = handle;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
]
] |
22,781 | static void rtas_power_off(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets)
{
if (nargs != 2 || nret != 1) {
rtas_st(rets, 0, -3);
return;
}
qemu_system_shutdown_request();
rtas_st(rets, 0, 0);
}
| false | qemu | 210b580b106fa798149e28aa13c66b325a43204e | static void rtas_power_off(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets)
{
if (nargs != 2 || nret != 1) {
rtas_st(rets, 0, -3);
return;
}
qemu_system_shutdown_request();
rtas_st(rets, 0, 0);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(sPAPREnvironment *VAR_0,
uint32_t VAR_1, uint32_t VAR_2, target_ulong VAR_3,
uint32_t VAR_4, target_ulong VAR_5)
{
if (VAR_2 != 2 || VAR_4 != 1) {
rtas_st(VAR_5, 0, -3);
return;
}
qemu_system_shutdown_request();
rtas_st(VAR_5, 0, 0);
}
| [
"static void FUNC_0(sPAPREnvironment *VAR_0,\nuint32_t VAR_1, uint32_t VAR_2, target_ulong VAR_3,\nuint32_t VAR_4, target_ulong VAR_5)\n{",
"if (VAR_2 != 2 || VAR_4 != 1) {",
"rtas_st(VAR_5, 0, -3);",
"return;",
"}",
"qemu_system_shutdown_request();",
"rtas_st(VAR_5, 0, 0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
22,782 | static uint64_t omap_id_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
if (size != 4) {
return omap_badwidth_read32(opaque, addr);
}
switch (addr) {
case 0xfffe1800: /* DIE_ID_LSB */
return 0xc9581f0e;
case 0xfffe1804: /* DIE_ID_MSB */
return 0xa8858bfa;
case 0xfffe2000: /* PRODUCT_ID_LSB */
return 0x00aaaafc;
case 0xfffe2004: /* PRODUCT_ID_MSB */
return 0xcafeb574;
case 0xfffed400: /* JTAG_ID_LSB */
switch (s->mpu_model) {
case omap310:
return 0x03310315;
case omap1510:
return 0x03310115;
default:
hw_error("%s: bad mpu model\n", __FUNCTION__);
}
break;
case 0xfffed404: /* JTAG_ID_MSB */
switch (s->mpu_model) {
case omap310:
return 0xfb57402f;
case omap1510:
return 0xfb47002f;
default:
hw_error("%s: bad mpu model\n", __FUNCTION__);
}
break;
}
OMAP_BAD_REG(addr);
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t omap_id_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
if (size != 4) {
return omap_badwidth_read32(opaque, addr);
}
switch (addr) {
case 0xfffe1800:
return 0xc9581f0e;
case 0xfffe1804:
return 0xa8858bfa;
case 0xfffe2000:
return 0x00aaaafc;
case 0xfffe2004:
return 0xcafeb574;
case 0xfffed400:
switch (s->mpu_model) {
case omap310:
return 0x03310315;
case omap1510:
return 0x03310115;
default:
hw_error("%s: bad mpu model\n", __FUNCTION__);
}
break;
case 0xfffed404:
switch (s->mpu_model) {
case omap310:
return 0xfb57402f;
case omap1510:
return 0xfb47002f;
default:
hw_error("%s: bad mpu model\n", __FUNCTION__);
}
break;
}
OMAP_BAD_REG(addr);
return 0;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
struct omap_mpu_state_s *VAR_0 = (struct omap_mpu_state_s *) opaque;
if (size != 4) {
return omap_badwidth_read32(opaque, addr);
}
switch (addr) {
case 0xfffe1800:
return 0xc9581f0e;
case 0xfffe1804:
return 0xa8858bfa;
case 0xfffe2000:
return 0x00aaaafc;
case 0xfffe2004:
return 0xcafeb574;
case 0xfffed400:
switch (VAR_0->mpu_model) {
case omap310:
return 0x03310315;
case omap1510:
return 0x03310115;
default:
hw_error("%VAR_0: bad mpu model\n", __FUNCTION__);
}
break;
case 0xfffed404:
switch (VAR_0->mpu_model) {
case omap310:
return 0xfb57402f;
case omap1510:
return 0xfb47002f;
default:
hw_error("%VAR_0: bad mpu model\n", __FUNCTION__);
}
break;
}
OMAP_BAD_REG(addr);
return 0;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"struct omap_mpu_state_s *VAR_0 = (struct omap_mpu_state_s *) opaque;",
"if (size != 4) {",
"return omap_badwidth_read32(opaque, addr);",
"}",
"switch (addr) {",
"case 0xfffe1800:\nreturn 0xc9581f0e;",
"case 0xfffe1804:\nreturn 0xa8858bfa;",
"case 0xfffe2000:\nreturn 0x00aaaafc;",
"case 0xfffe2004:\nreturn 0xcafeb574;",
"case 0xfffed400:\nswitch (VAR_0->mpu_model) {",
"case omap310:\nreturn 0x03310315;",
"case omap1510:\nreturn 0x03310115;",
"default:\nhw_error(\"%VAR_0: bad mpu model\\n\", __FUNCTION__);",
"}",
"break;",
"case 0xfffed404:\nswitch (VAR_0->mpu_model) {",
"case omap310:\nreturn 0xfb57402f;",
"case omap1510:\nreturn 0xfb47002f;",
"default:\nhw_error(\"%VAR_0: bad mpu model\\n\", __FUNCTION__);",
"}",
"break;",
"}",
"OMAP_BAD_REG(addr);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25,
27
],
[
31,
33
],
[
35,
37
],
[
41,
43
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
57
],
[
59
],
[
63,
65
],
[
67,
69
],
[
71,
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
]
] |
22,783 | ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
{
MapCacheEntry *entry = NULL;
MapCacheRev *reventry;
hwaddr paddr_index;
hwaddr size;
int found = 0;
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
if (reventry->vaddr_req == ptr) {
paddr_index = reventry->paddr_index;
size = reventry->size;
found = 1;
break;
}
}
if (!found) {
fprintf(stderr, "%s, could not find %p\n", __func__, ptr);
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
DPRINTF(" "TARGET_FMT_plx" -> %p is present\n", reventry->paddr_index,
reventry->vaddr_req);
}
abort();
return 0;
}
entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
while (entry && (entry->paddr_index != paddr_index || entry->size != size)) {
entry = entry->next;
}
if (!entry) {
DPRINTF("Trying to find address %p that is not in the mapcache!\n", ptr);
return 0;
}
return (reventry->paddr_index << MCACHE_BUCKET_SHIFT) +
((unsigned long) ptr - (unsigned long) entry->vaddr_base);
}
| false | qemu | 86a6a9bf551ffa183880480b37c5836d3916687a | ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
{
MapCacheEntry *entry = NULL;
MapCacheRev *reventry;
hwaddr paddr_index;
hwaddr size;
int found = 0;
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
if (reventry->vaddr_req == ptr) {
paddr_index = reventry->paddr_index;
size = reventry->size;
found = 1;
break;
}
}
if (!found) {
fprintf(stderr, "%s, could not find %p\n", __func__, ptr);
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
DPRINTF(" "TARGET_FMT_plx" -> %p is present\n", reventry->paddr_index,
reventry->vaddr_req);
}
abort();
return 0;
}
entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
while (entry && (entry->paddr_index != paddr_index || entry->size != size)) {
entry = entry->next;
}
if (!entry) {
DPRINTF("Trying to find address %p that is not in the mapcache!\n", ptr);
return 0;
}
return (reventry->paddr_index << MCACHE_BUCKET_SHIFT) +
((unsigned long) ptr - (unsigned long) entry->vaddr_base);
}
| {
"code": [],
"line_no": []
} | ram_addr_t FUNC_0(void *ptr)
{
MapCacheEntry *entry = NULL;
MapCacheRev *reventry;
hwaddr paddr_index;
hwaddr size;
int VAR_0 = 0;
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
if (reventry->vaddr_req == ptr) {
paddr_index = reventry->paddr_index;
size = reventry->size;
VAR_0 = 1;
break;
}
}
if (!VAR_0) {
fprintf(stderr, "%s, could not find %p\n", __func__, ptr);
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
DPRINTF(" "TARGET_FMT_plx" -> %p is present\n", reventry->paddr_index,
reventry->vaddr_req);
}
abort();
return 0;
}
entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
while (entry && (entry->paddr_index != paddr_index || entry->size != size)) {
entry = entry->next;
}
if (!entry) {
DPRINTF("Trying to find address %p that is not in the mapcache!\n", ptr);
return 0;
}
return (reventry->paddr_index << MCACHE_BUCKET_SHIFT) +
((unsigned long) ptr - (unsigned long) entry->vaddr_base);
}
| [
"ram_addr_t FUNC_0(void *ptr)\n{",
"MapCacheEntry *entry = NULL;",
"MapCacheRev *reventry;",
"hwaddr paddr_index;",
"hwaddr size;",
"int VAR_0 = 0;",
"QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {",
"if (reventry->vaddr_req == ptr) {",
"paddr_index = reventry->paddr_index;",
"size = reventry->size;",
"VAR_0 = 1;",
"break;",
"}",
"}",
"if (!VAR_0) {",
"fprintf(stderr, \"%s, could not find %p\\n\", __func__, ptr);",
"QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {",
"DPRINTF(\" \"TARGET_FMT_plx\" -> %p is present\\n\", reventry->paddr_index,\nreventry->vaddr_req);",
"}",
"abort();",
"return 0;",
"}",
"entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];",
"while (entry && (entry->paddr_index != paddr_index || entry->size != size)) {",
"entry = entry->next;",
"}",
"if (!entry) {",
"DPRINTF(\"Trying to find address %p that is not in the mapcache!\\n\", ptr);",
"return 0;",
"}",
"return (reventry->paddr_index << MCACHE_BUCKET_SHIFT) +\n((unsigned long) ptr - (unsigned long) entry->vaddr_base);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
]
] |
22,784 | static void hpdmc_write(void *opaque, target_phys_addr_t addr, uint64_t value,
unsigned size)
{
MilkymistHpdmcState *s = opaque;
trace_milkymist_hpdmc_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_SYSTEM:
case R_BYPASS:
case R_TIMING:
s->regs[addr] = value;
break;
case R_IODELAY:
/* ignore writes */
break;
default:
error_report("milkymist_hpdmc: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void hpdmc_write(void *opaque, target_phys_addr_t addr, uint64_t value,
unsigned size)
{
MilkymistHpdmcState *s = opaque;
trace_milkymist_hpdmc_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_SYSTEM:
case R_BYPASS:
case R_TIMING:
s->regs[addr] = value;
break;
case R_IODELAY:
break;
default:
error_report("milkymist_hpdmc: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2,
unsigned VAR_3)
{
MilkymistHpdmcState *s = VAR_0;
trace_milkymist_hpdmc_memory_write(VAR_1, VAR_2);
VAR_1 >>= 2;
switch (VAR_1) {
case R_SYSTEM:
case R_BYPASS:
case R_TIMING:
s->regs[VAR_1] = VAR_2;
break;
case R_IODELAY:
break;
default:
error_report("milkymist_hpdmc: write access to unknown register 0x"
TARGET_FMT_plx, VAR_1 << 2);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2,\nunsigned VAR_3)\n{",
"MilkymistHpdmcState *s = VAR_0;",
"trace_milkymist_hpdmc_memory_write(VAR_1, VAR_2);",
"VAR_1 >>= 2;",
"switch (VAR_1) {",
"case R_SYSTEM:\ncase R_BYPASS:\ncase R_TIMING:\ns->regs[VAR_1] = VAR_2;",
"break;",
"case R_IODELAY:\nbreak;",
"default:\nerror_report(\"milkymist_hpdmc: write access to unknown register 0x\"\nTARGET_FMT_plx, VAR_1 << 2);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19,
21,
23,
25
],
[
27
],
[
29,
33
],
[
37,
39,
41
],
[
43
],
[
45
],
[
47
]
] |
22,785 | static int write_elf32_note(DumpState *s)
{
target_phys_addr_t begin = s->memory_offset - s->note_size;
Elf32_Phdr phdr;
int endian = s->dump_info.d_endian;
int ret;
memset(&phdr, 0, sizeof(Elf32_Phdr));
phdr.p_type = cpu_convert_to_target32(PT_NOTE, endian);
phdr.p_offset = cpu_convert_to_target32(begin, endian);
phdr.p_paddr = 0;
phdr.p_filesz = cpu_convert_to_target32(s->note_size, endian);
phdr.p_memsz = cpu_convert_to_target32(s->note_size, endian);
phdr.p_vaddr = 0;
ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s);
if (ret < 0) {
dump_error(s, "dump: failed to write program header table.\n");
return -1;
}
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static int write_elf32_note(DumpState *s)
{
target_phys_addr_t begin = s->memory_offset - s->note_size;
Elf32_Phdr phdr;
int endian = s->dump_info.d_endian;
int ret;
memset(&phdr, 0, sizeof(Elf32_Phdr));
phdr.p_type = cpu_convert_to_target32(PT_NOTE, endian);
phdr.p_offset = cpu_convert_to_target32(begin, endian);
phdr.p_paddr = 0;
phdr.p_filesz = cpu_convert_to_target32(s->note_size, endian);
phdr.p_memsz = cpu_convert_to_target32(s->note_size, endian);
phdr.p_vaddr = 0;
ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s);
if (ret < 0) {
dump_error(s, "dump: failed to write program header table.\n");
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DumpState *VAR_0)
{
target_phys_addr_t begin = VAR_0->memory_offset - VAR_0->note_size;
Elf32_Phdr phdr;
int VAR_1 = VAR_0->dump_info.d_endian;
int VAR_2;
memset(&phdr, 0, sizeof(Elf32_Phdr));
phdr.p_type = cpu_convert_to_target32(PT_NOTE, VAR_1);
phdr.p_offset = cpu_convert_to_target32(begin, VAR_1);
phdr.p_paddr = 0;
phdr.p_filesz = cpu_convert_to_target32(VAR_0->note_size, VAR_1);
phdr.p_memsz = cpu_convert_to_target32(VAR_0->note_size, VAR_1);
phdr.p_vaddr = 0;
VAR_2 = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), VAR_0);
if (VAR_2 < 0) {
dump_error(VAR_0, "dump: failed to write program header table.\n");
return -1;
}
return 0;
}
| [
"static int FUNC_0(DumpState *VAR_0)\n{",
"target_phys_addr_t begin = VAR_0->memory_offset - VAR_0->note_size;",
"Elf32_Phdr phdr;",
"int VAR_1 = VAR_0->dump_info.d_endian;",
"int VAR_2;",
"memset(&phdr, 0, sizeof(Elf32_Phdr));",
"phdr.p_type = cpu_convert_to_target32(PT_NOTE, VAR_1);",
"phdr.p_offset = cpu_convert_to_target32(begin, VAR_1);",
"phdr.p_paddr = 0;",
"phdr.p_filesz = cpu_convert_to_target32(VAR_0->note_size, VAR_1);",
"phdr.p_memsz = cpu_convert_to_target32(VAR_0->note_size, VAR_1);",
"phdr.p_vaddr = 0;",
"VAR_2 = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), VAR_0);",
"if (VAR_2 < 0) {",
"dump_error(VAR_0, \"dump: failed to write program header table.\\n\");",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
]
] |
22,786 | int rom_add_vga(const char *file)
{
if (!rom_enable_driver_roms)
return 0;
return rom_add_file(file, "vgaroms", file, 0);
}
| false | qemu | bdb5ee3064d5ae786b0bcb6cf6ff4e3554a72990 | int rom_add_vga(const char *file)
{
if (!rom_enable_driver_roms)
return 0;
return rom_add_file(file, "vgaroms", file, 0);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const char *VAR_0)
{
if (!rom_enable_driver_roms)
return 0;
return rom_add_file(VAR_0, "vgaroms", VAR_0, 0);
}
| [
"int FUNC_0(const char *VAR_0)\n{",
"if (!rom_enable_driver_roms)\nreturn 0;",
"return rom_add_file(VAR_0, \"vgaroms\", VAR_0, 0);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
]
] |
22,788 | static void external_snapshot_prepare(BlkActionState *common,
Error **errp)
{
int flags = 0, ret;
QDict *options = NULL;
Error *local_err = NULL;
/* Device and node name of the image to generate the snapshot from */
const char *device;
const char *node_name;
/* Reference to the new image (for 'blockdev-snapshot') */
const char *snapshot_ref;
/* File name of the new image (for 'blockdev-snapshot-sync') */
const char *new_image_file;
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, common, common);
TransactionAction *action = common->action;
/* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar
* purpose but a different set of parameters */
switch (action->type) {
case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT:
{
BlockdevSnapshot *s = action->u.blockdev_snapshot;
device = s->node;
node_name = s->node;
new_image_file = NULL;
snapshot_ref = s->overlay;
}
break;
case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC:
{
BlockdevSnapshotSync *s = action->u.blockdev_snapshot_sync;
device = s->has_device ? s->device : NULL;
node_name = s->has_node_name ? s->node_name : NULL;
new_image_file = s->snapshot_file;
snapshot_ref = NULL;
}
break;
default:
g_assert_not_reached();
}
/* start processing */
if (action_check_completion_mode(common, errp) < 0) {
return;
}
state->old_bs = bdrv_lookup_bs(device, node_name, errp);
if (!state->old_bs) {
return;
}
/* Acquire AioContext now so any threads operating on old_bs stop */
state->aio_context = bdrv_get_aio_context(state->old_bs);
aio_context_acquire(state->aio_context);
bdrv_drained_begin(state->old_bs);
if (!bdrv_is_inserted(state->old_bs)) {
error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (bdrv_op_is_blocked(state->old_bs,
BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, errp)) {
return;
}
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
error_setg(errp, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
error_setg(errp, QERR_FEATURE_DISABLED, "snapshot");
return;
}
if (action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC) {
BlockdevSnapshotSync *s = action->u.blockdev_snapshot_sync;
const char *format = s->has_format ? s->format : "qcow2";
enum NewImageMode mode;
const char *snapshot_node_name =
s->has_snapshot_node_name ? s->snapshot_node_name : NULL;
if (node_name && !snapshot_node_name) {
error_setg(errp, "New snapshot node name missing");
return;
}
if (snapshot_node_name &&
bdrv_lookup_bs(snapshot_node_name, snapshot_node_name, NULL)) {
error_setg(errp, "New snapshot node name already in use");
return;
}
flags = state->old_bs->open_flags;
/* create new image w/backing file */
mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
if (mode != NEW_IMAGE_MODE_EXISTING) {
int64_t size = bdrv_getlength(state->old_bs);
if (size < 0) {
error_setg_errno(errp, -size, "bdrv_getlength failed");
return;
}
bdrv_img_create(new_image_file, format,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, size, flags, &local_err, false);
if (local_err) {
error_propagate(errp, local_err);
return;
}
}
options = qdict_new();
if (s->has_snapshot_node_name) {
qdict_put(options, "node-name",
qstring_from_str(snapshot_node_name));
}
qdict_put(options, "driver", qstring_from_str(format));
flags |= BDRV_O_NO_BACKING;
}
assert(state->new_bs == NULL);
ret = bdrv_open(&state->new_bs, new_image_file, snapshot_ref, options,
flags, errp);
/* We will manually add the backing_hd field to the bs later */
if (ret != 0) {
return;
}
if (state->new_bs->blk != NULL) {
error_setg(errp, "The snapshot is already in use by %s",
blk_name(state->new_bs->blk));
return;
}
if (bdrv_op_is_blocked(state->new_bs, BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT,
errp)) {
return;
}
if (state->new_bs->backing != NULL) {
error_setg(errp, "The snapshot already has a backing image");
return;
}
if (!state->new_bs->drv->supports_backing) {
error_setg(errp, "The snapshot does not support backing images");
}
}
| false | qemu | 32bafa8fdd098d52fbf1102d5a5e48d29398c0aa | static void external_snapshot_prepare(BlkActionState *common,
Error **errp)
{
int flags = 0, ret;
QDict *options = NULL;
Error *local_err = NULL;
const char *device;
const char *node_name;
const char *snapshot_ref;
const char *new_image_file;
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, common, common);
TransactionAction *action = common->action;
switch (action->type) {
case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT:
{
BlockdevSnapshot *s = action->u.blockdev_snapshot;
device = s->node;
node_name = s->node;
new_image_file = NULL;
snapshot_ref = s->overlay;
}
break;
case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC:
{
BlockdevSnapshotSync *s = action->u.blockdev_snapshot_sync;
device = s->has_device ? s->device : NULL;
node_name = s->has_node_name ? s->node_name : NULL;
new_image_file = s->snapshot_file;
snapshot_ref = NULL;
}
break;
default:
g_assert_not_reached();
}
if (action_check_completion_mode(common, errp) < 0) {
return;
}
state->old_bs = bdrv_lookup_bs(device, node_name, errp);
if (!state->old_bs) {
return;
}
state->aio_context = bdrv_get_aio_context(state->old_bs);
aio_context_acquire(state->aio_context);
bdrv_drained_begin(state->old_bs);
if (!bdrv_is_inserted(state->old_bs)) {
error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (bdrv_op_is_blocked(state->old_bs,
BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, errp)) {
return;
}
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
error_setg(errp, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
error_setg(errp, QERR_FEATURE_DISABLED, "snapshot");
return;
}
if (action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC) {
BlockdevSnapshotSync *s = action->u.blockdev_snapshot_sync;
const char *format = s->has_format ? s->format : "qcow2";
enum NewImageMode mode;
const char *snapshot_node_name =
s->has_snapshot_node_name ? s->snapshot_node_name : NULL;
if (node_name && !snapshot_node_name) {
error_setg(errp, "New snapshot node name missing");
return;
}
if (snapshot_node_name &&
bdrv_lookup_bs(snapshot_node_name, snapshot_node_name, NULL)) {
error_setg(errp, "New snapshot node name already in use");
return;
}
flags = state->old_bs->open_flags;
mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
if (mode != NEW_IMAGE_MODE_EXISTING) {
int64_t size = bdrv_getlength(state->old_bs);
if (size < 0) {
error_setg_errno(errp, -size, "bdrv_getlength failed");
return;
}
bdrv_img_create(new_image_file, format,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, size, flags, &local_err, false);
if (local_err) {
error_propagate(errp, local_err);
return;
}
}
options = qdict_new();
if (s->has_snapshot_node_name) {
qdict_put(options, "node-name",
qstring_from_str(snapshot_node_name));
}
qdict_put(options, "driver", qstring_from_str(format));
flags |= BDRV_O_NO_BACKING;
}
assert(state->new_bs == NULL);
ret = bdrv_open(&state->new_bs, new_image_file, snapshot_ref, options,
flags, errp);
if (ret != 0) {
return;
}
if (state->new_bs->blk != NULL) {
error_setg(errp, "The snapshot is already in use by %s",
blk_name(state->new_bs->blk));
return;
}
if (bdrv_op_is_blocked(state->new_bs, BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT,
errp)) {
return;
}
if (state->new_bs->backing != NULL) {
error_setg(errp, "The snapshot already has a backing image");
return;
}
if (!state->new_bs->drv->supports_backing) {
error_setg(errp, "The snapshot does not support backing images");
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlkActionState *VAR_0,
Error **VAR_1)
{
int VAR_2 = 0, VAR_3;
QDict *options = NULL;
Error *local_err = NULL;
const char *VAR_4;
const char *VAR_5;
const char *VAR_6;
const char *VAR_7;
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, VAR_0, VAR_0);
TransactionAction *action = VAR_0->action;
switch (action->type) {
case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT:
{
BlockdevSnapshot *s = action->u.blockdev_snapshot;
VAR_4 = s->node;
VAR_5 = s->node;
VAR_7 = NULL;
VAR_6 = s->overlay;
}
break;
case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC:
{
BlockdevSnapshotSync *s = action->u.blockdev_snapshot_sync;
VAR_4 = s->has_device ? s->VAR_4 : NULL;
VAR_5 = s->has_node_name ? s->VAR_5 : NULL;
VAR_7 = s->snapshot_file;
VAR_6 = NULL;
}
break;
default:
g_assert_not_reached();
}
if (action_check_completion_mode(VAR_0, VAR_1) < 0) {
return;
}
state->old_bs = bdrv_lookup_bs(VAR_4, VAR_5, VAR_1);
if (!state->old_bs) {
return;
}
state->aio_context = bdrv_get_aio_context(state->old_bs);
aio_context_acquire(state->aio_context);
bdrv_drained_begin(state->old_bs);
if (!bdrv_is_inserted(state->old_bs)) {
error_setg(VAR_1, QERR_DEVICE_HAS_NO_MEDIUM, VAR_4);
return;
}
if (bdrv_op_is_blocked(state->old_bs,
BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, VAR_1)) {
return;
}
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
error_setg(VAR_1, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
error_setg(VAR_1, QERR_FEATURE_DISABLED, "snapshot");
return;
}
if (action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC) {
BlockdevSnapshotSync *s = action->u.blockdev_snapshot_sync;
const char *VAR_8 = s->has_format ? s->VAR_8 : "qcow2";
enum NewImageMode VAR_9;
const char *VAR_10 =
s->has_snapshot_node_name ? s->VAR_10 : NULL;
if (VAR_5 && !VAR_10) {
error_setg(VAR_1, "New snapshot node name missing");
return;
}
if (VAR_10 &&
bdrv_lookup_bs(VAR_10, VAR_10, NULL)) {
error_setg(VAR_1, "New snapshot node name already in use");
return;
}
VAR_2 = state->old_bs->open_flags;
VAR_9 = s->has_mode ? s->VAR_9 : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
if (VAR_9 != NEW_IMAGE_MODE_EXISTING) {
int64_t size = bdrv_getlength(state->old_bs);
if (size < 0) {
error_setg_errno(VAR_1, -size, "bdrv_getlength failed");
return;
}
bdrv_img_create(VAR_7, VAR_8,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, size, VAR_2, &local_err, false);
if (local_err) {
error_propagate(VAR_1, local_err);
return;
}
}
options = qdict_new();
if (s->has_snapshot_node_name) {
qdict_put(options, "node-name",
qstring_from_str(VAR_10));
}
qdict_put(options, "driver", qstring_from_str(VAR_8));
VAR_2 |= BDRV_O_NO_BACKING;
}
assert(state->new_bs == NULL);
VAR_3 = bdrv_open(&state->new_bs, VAR_7, VAR_6, options,
VAR_2, VAR_1);
if (VAR_3 != 0) {
return;
}
if (state->new_bs->blk != NULL) {
error_setg(VAR_1, "The snapshot is already in use by %s",
blk_name(state->new_bs->blk));
return;
}
if (bdrv_op_is_blocked(state->new_bs, BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT,
VAR_1)) {
return;
}
if (state->new_bs->backing != NULL) {
error_setg(VAR_1, "The snapshot already has a backing image");
return;
}
if (!state->new_bs->drv->supports_backing) {
error_setg(VAR_1, "The snapshot does not support backing images");
}
}
| [
"static void FUNC_0(BlkActionState *VAR_0,\nError **VAR_1)\n{",
"int VAR_2 = 0, VAR_3;",
"QDict *options = NULL;",
"Error *local_err = NULL;",
"const char *VAR_4;",
"const char *VAR_5;",
"const char *VAR_6;",
"const char *VAR_7;",
"ExternalSnapshotState *state =\nDO_UPCAST(ExternalSnapshotState, VAR_0, VAR_0);",
"TransactionAction *action = VAR_0->action;",
"switch (action->type) {",
"case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT:\n{",
"BlockdevSnapshot *s = action->u.blockdev_snapshot;",
"VAR_4 = s->node;",
"VAR_5 = s->node;",
"VAR_7 = NULL;",
"VAR_6 = s->overlay;",
"}",
"break;",
"case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC:\n{",
"BlockdevSnapshotSync *s = action->u.blockdev_snapshot_sync;",
"VAR_4 = s->has_device ? s->VAR_4 : NULL;",
"VAR_5 = s->has_node_name ? s->VAR_5 : NULL;",
"VAR_7 = s->snapshot_file;",
"VAR_6 = NULL;",
"}",
"break;",
"default:\ng_assert_not_reached();",
"}",
"if (action_check_completion_mode(VAR_0, VAR_1) < 0) {",
"return;",
"}",
"state->old_bs = bdrv_lookup_bs(VAR_4, VAR_5, VAR_1);",
"if (!state->old_bs) {",
"return;",
"}",
"state->aio_context = bdrv_get_aio_context(state->old_bs);",
"aio_context_acquire(state->aio_context);",
"bdrv_drained_begin(state->old_bs);",
"if (!bdrv_is_inserted(state->old_bs)) {",
"error_setg(VAR_1, QERR_DEVICE_HAS_NO_MEDIUM, VAR_4);",
"return;",
"}",
"if (bdrv_op_is_blocked(state->old_bs,\nBLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, VAR_1)) {",
"return;",
"}",
"if (!bdrv_is_read_only(state->old_bs)) {",
"if (bdrv_flush(state->old_bs)) {",
"error_setg(VAR_1, QERR_IO_ERROR);",
"return;",
"}",
"}",
"if (!bdrv_is_first_non_filter(state->old_bs)) {",
"error_setg(VAR_1, QERR_FEATURE_DISABLED, \"snapshot\");",
"return;",
"}",
"if (action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC) {",
"BlockdevSnapshotSync *s = action->u.blockdev_snapshot_sync;",
"const char *VAR_8 = s->has_format ? s->VAR_8 : \"qcow2\";",
"enum NewImageMode VAR_9;",
"const char *VAR_10 =\ns->has_snapshot_node_name ? s->VAR_10 : NULL;",
"if (VAR_5 && !VAR_10) {",
"error_setg(VAR_1, \"New snapshot node name missing\");",
"return;",
"}",
"if (VAR_10 &&\nbdrv_lookup_bs(VAR_10, VAR_10, NULL)) {",
"error_setg(VAR_1, \"New snapshot node name already in use\");",
"return;",
"}",
"VAR_2 = state->old_bs->open_flags;",
"VAR_9 = s->has_mode ? s->VAR_9 : NEW_IMAGE_MODE_ABSOLUTE_PATHS;",
"if (VAR_9 != NEW_IMAGE_MODE_EXISTING) {",
"int64_t size = bdrv_getlength(state->old_bs);",
"if (size < 0) {",
"error_setg_errno(VAR_1, -size, \"bdrv_getlength failed\");",
"return;",
"}",
"bdrv_img_create(VAR_7, VAR_8,\nstate->old_bs->filename,\nstate->old_bs->drv->format_name,\nNULL, size, VAR_2, &local_err, false);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"}",
"options = qdict_new();",
"if (s->has_snapshot_node_name) {",
"qdict_put(options, \"node-name\",\nqstring_from_str(VAR_10));",
"}",
"qdict_put(options, \"driver\", qstring_from_str(VAR_8));",
"VAR_2 |= BDRV_O_NO_BACKING;",
"}",
"assert(state->new_bs == NULL);",
"VAR_3 = bdrv_open(&state->new_bs, VAR_7, VAR_6, options,\nVAR_2, VAR_1);",
"if (VAR_3 != 0) {",
"return;",
"}",
"if (state->new_bs->blk != NULL) {",
"error_setg(VAR_1, \"The snapshot is already in use by %s\",\nblk_name(state->new_bs->blk));",
"return;",
"}",
"if (bdrv_op_is_blocked(state->new_bs, BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT,\nVAR_1)) {",
"return;",
"}",
"if (state->new_bs->backing != NULL) {",
"error_setg(VAR_1, \"The snapshot already has a backing image\");",
"return;",
"}",
"if (!state->new_bs->drv->supports_backing) {",
"error_setg(VAR_1, \"The snapshot does not support backing images\");",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27,
29
],
[
31
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125,
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167,
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215,
217,
219,
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239,
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
255
],
[
257,
259
],
[
263
],
[
265
],
[
267
],
[
271
],
[
273,
275
],
[
277
],
[
279
],
[
283,
285
],
[
287
],
[
289
],
[
293
],
[
295
],
[
297
],
[
299
],
[
303
],
[
305
],
[
307
],
[
309
]
] |
22,789 | void helper_ldl_data(uint64_t t0, uint64_t t1)
{
ldl_data(t1, t0);
}
| false | qemu | 2374e73edafff0586cbfb67c333c5a7588f81fd5 | void helper_ldl_data(uint64_t t0, uint64_t t1)
{
ldl_data(t1, t0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint64_t VAR_0, uint64_t VAR_1)
{
ldl_data(VAR_1, VAR_0);
}
| [
"void FUNC_0(uint64_t VAR_0, uint64_t VAR_1)\n{",
"ldl_data(VAR_1, VAR_0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,790 | matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size,
int64_t pos, uint64_t cluster_time,
int is_keyframe, int *ptrack, AVPacket **ppkt)
{
int res = 0;
int track;
AVPacket *pkt;
uint8_t *origdata = data;
int16_t block_time;
uint32_t *lace_size = NULL;
int n, flags, laces = 0;
uint64_t num;
/* first byte(s): tracknum */
if ((n = matroska_ebmlnum_uint(data, size, &num)) < 0) {
av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n");
av_free(origdata);
return res;
}
data += n;
size -= n;
/* fetch track from num */
track = matroska_find_track_by_num(matroska, num);
if (ptrack) *ptrack = track;
if (size <= 3 || track < 0 || track >= matroska->num_tracks) {
av_log(matroska->ctx, AV_LOG_INFO,
"Invalid stream %d or size %u\n", track, size);
av_free(origdata);
return res;
}
if(matroska->ctx->streams[ matroska->tracks[track]->stream_index ]->discard >= AVDISCARD_ALL){
av_free(origdata);
return res;
}
/* block_time (relative to cluster time) */
block_time = (data[0] << 8) | data[1];
data += 2;
size -= 2;
flags = *data;
data += 1;
size -= 1;
if (is_keyframe == -1)
is_keyframe = flags & 1 ? PKT_FLAG_KEY : 0;
switch ((flags & 0x06) >> 1) {
case 0x0: /* no lacing */
laces = 1;
lace_size = av_mallocz(sizeof(int));
lace_size[0] = size;
break;
case 0x1: /* xiph lacing */
case 0x2: /* fixed-size lacing */
case 0x3: /* EBML lacing */
if (size == 0) {
res = -1;
break;
}
laces = (*data) + 1;
data += 1;
size -= 1;
lace_size = av_mallocz(laces * sizeof(int));
switch ((flags & 0x06) >> 1) {
case 0x1: /* xiph lacing */ {
uint8_t temp;
uint32_t total = 0;
for (n = 0; res == 0 && n < laces - 1; n++) {
while (1) {
if (size == 0) {
res = -1;
break;
}
temp = *data;
lace_size[n] += temp;
data += 1;
size -= 1;
if (temp != 0xff)
break;
}
total += lace_size[n];
}
lace_size[n] = size - total;
break;
}
case 0x2: /* fixed-size lacing */
for (n = 0; n < laces; n++)
lace_size[n] = size / laces;
break;
case 0x3: /* EBML lacing */ {
uint32_t total;
n = matroska_ebmlnum_uint(data, size, &num);
if (n < 0) {
av_log(matroska->ctx, AV_LOG_INFO,
"EBML block data error\n");
break;
}
data += n;
size -= n;
total = lace_size[0] = num;
for (n = 1; res == 0 && n < laces - 1; n++) {
int64_t snum;
int r;
r = matroska_ebmlnum_sint (data, size, &snum);
if (r < 0) {
av_log(matroska->ctx, AV_LOG_INFO,
"EBML block data error\n");
break;
}
data += r;
size -= r;
lace_size[n] = lace_size[n - 1] + snum;
total += lace_size[n];
}
lace_size[n] = size - total;
break;
}
}
break;
}
if (res == 0) {
int real_v = matroska->tracks[track]->flags & MATROSKA_TRACK_REAL_V;
for (n = 0; n < laces; n++) {
uint64_t timecode = AV_NOPTS_VALUE;
int slice, slices = 1;
if (real_v) {
slices = *data++ + 1;
lace_size[n]--;
}
if (cluster_time != (uint64_t)-1 && n == 0) {
if (cluster_time + block_time >= 0)
timecode = (cluster_time + block_time) * matroska->time_scale;
}
/* FIXME: duration */
for (slice=0; slice<slices; slice++) {
int slice_size, slice_offset = 0;
if (real_v)
slice_offset = rv_offset(data, slice, slices);
if (slice+1 == slices)
slice_size = lace_size[n] - slice_offset;
else
slice_size = rv_offset(data, slice+1, slices) - slice_offset;
pkt = av_mallocz(sizeof(AVPacket));
if (ppkt) *ppkt = pkt;
/* XXX: prevent data copy... */
if (av_new_packet(pkt, slice_size) < 0) {
res = AVERROR_NOMEM;
n = laces-1;
break;
}
memcpy (pkt->data, data+slice_offset, slice_size);
if (n == 0)
pkt->flags = is_keyframe;
pkt->stream_index = matroska->tracks[track]->stream_index;
pkt->pts = timecode;
pkt->pos = pos;
matroska_queue_packet(matroska, pkt);
}
data += lace_size[n];
}
}
av_free(lace_size);
av_free(origdata);
return res;
}
| false | FFmpeg | 6bed20f45a484f5709fec4c97a238240161b1797 | matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size,
int64_t pos, uint64_t cluster_time,
int is_keyframe, int *ptrack, AVPacket **ppkt)
{
int res = 0;
int track;
AVPacket *pkt;
uint8_t *origdata = data;
int16_t block_time;
uint32_t *lace_size = NULL;
int n, flags, laces = 0;
uint64_t num;
if ((n = matroska_ebmlnum_uint(data, size, &num)) < 0) {
av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n");
av_free(origdata);
return res;
}
data += n;
size -= n;
track = matroska_find_track_by_num(matroska, num);
if (ptrack) *ptrack = track;
if (size <= 3 || track < 0 || track >= matroska->num_tracks) {
av_log(matroska->ctx, AV_LOG_INFO,
"Invalid stream %d or size %u\n", track, size);
av_free(origdata);
return res;
}
if(matroska->ctx->streams[ matroska->tracks[track]->stream_index ]->discard >= AVDISCARD_ALL){
av_free(origdata);
return res;
}
block_time = (data[0] << 8) | data[1];
data += 2;
size -= 2;
flags = *data;
data += 1;
size -= 1;
if (is_keyframe == -1)
is_keyframe = flags & 1 ? PKT_FLAG_KEY : 0;
switch ((flags & 0x06) >> 1) {
case 0x0:
laces = 1;
lace_size = av_mallocz(sizeof(int));
lace_size[0] = size;
break;
case 0x1:
case 0x2:
case 0x3:
if (size == 0) {
res = -1;
break;
}
laces = (*data) + 1;
data += 1;
size -= 1;
lace_size = av_mallocz(laces * sizeof(int));
switch ((flags & 0x06) >> 1) {
case 0x1: {
uint8_t temp;
uint32_t total = 0;
for (n = 0; res == 0 && n < laces - 1; n++) {
while (1) {
if (size == 0) {
res = -1;
break;
}
temp = *data;
lace_size[n] += temp;
data += 1;
size -= 1;
if (temp != 0xff)
break;
}
total += lace_size[n];
}
lace_size[n] = size - total;
break;
}
case 0x2:
for (n = 0; n < laces; n++)
lace_size[n] = size / laces;
break;
case 0x3: {
uint32_t total;
n = matroska_ebmlnum_uint(data, size, &num);
if (n < 0) {
av_log(matroska->ctx, AV_LOG_INFO,
"EBML block data error\n");
break;
}
data += n;
size -= n;
total = lace_size[0] = num;
for (n = 1; res == 0 && n < laces - 1; n++) {
int64_t snum;
int r;
r = matroska_ebmlnum_sint (data, size, &snum);
if (r < 0) {
av_log(matroska->ctx, AV_LOG_INFO,
"EBML block data error\n");
break;
}
data += r;
size -= r;
lace_size[n] = lace_size[n - 1] + snum;
total += lace_size[n];
}
lace_size[n] = size - total;
break;
}
}
break;
}
if (res == 0) {
int real_v = matroska->tracks[track]->flags & MATROSKA_TRACK_REAL_V;
for (n = 0; n < laces; n++) {
uint64_t timecode = AV_NOPTS_VALUE;
int slice, slices = 1;
if (real_v) {
slices = *data++ + 1;
lace_size[n]--;
}
if (cluster_time != (uint64_t)-1 && n == 0) {
if (cluster_time + block_time >= 0)
timecode = (cluster_time + block_time) * matroska->time_scale;
}
for (slice=0; slice<slices; slice++) {
int slice_size, slice_offset = 0;
if (real_v)
slice_offset = rv_offset(data, slice, slices);
if (slice+1 == slices)
slice_size = lace_size[n] - slice_offset;
else
slice_size = rv_offset(data, slice+1, slices) - slice_offset;
pkt = av_mallocz(sizeof(AVPacket));
if (ppkt) *ppkt = pkt;
if (av_new_packet(pkt, slice_size) < 0) {
res = AVERROR_NOMEM;
n = laces-1;
break;
}
memcpy (pkt->data, data+slice_offset, slice_size);
if (n == 0)
pkt->flags = is_keyframe;
pkt->stream_index = matroska->tracks[track]->stream_index;
pkt->pts = timecode;
pkt->pos = pos;
matroska_queue_packet(matroska, pkt);
}
data += lace_size[n];
}
}
av_free(lace_size);
av_free(origdata);
return res;
}
| {
"code": [],
"line_no": []
} | FUNC_0(MatroskaDemuxContext *VAR_0, uint8_t *VAR_1, int VAR_2,
int64_t VAR_3, uint64_t VAR_4,
int VAR_5, int *VAR_6, AVPacket **VAR_7)
{
int VAR_8 = 0;
int VAR_9;
AVPacket *pkt;
uint8_t *origdata = VAR_1;
int16_t block_time;
uint32_t *lace_size = NULL;
int VAR_10, VAR_11, VAR_12 = 0;
uint64_t num;
if ((VAR_10 = matroska_ebmlnum_uint(VAR_1, VAR_2, &num)) < 0) {
av_log(VAR_0->ctx, AV_LOG_ERROR, "EBML block VAR_1 error\VAR_10");
av_free(origdata);
return VAR_8;
}
VAR_1 += VAR_10;
VAR_2 -= VAR_10;
VAR_9 = matroska_find_track_by_num(VAR_0, num);
if (VAR_6) *VAR_6 = VAR_9;
if (VAR_2 <= 3 || VAR_9 < 0 || VAR_9 >= VAR_0->num_tracks) {
av_log(VAR_0->ctx, AV_LOG_INFO,
"Invalid stream %d or VAR_2 %u\VAR_10", VAR_9, VAR_2);
av_free(origdata);
return VAR_8;
}
if(VAR_0->ctx->streams[ VAR_0->tracks[VAR_9]->stream_index ]->discard >= AVDISCARD_ALL){
av_free(origdata);
return VAR_8;
}
block_time = (VAR_1[0] << 8) | VAR_1[1];
VAR_1 += 2;
VAR_2 -= 2;
VAR_11 = *VAR_1;
VAR_1 += 1;
VAR_2 -= 1;
if (VAR_5 == -1)
VAR_5 = VAR_11 & 1 ? PKT_FLAG_KEY : 0;
switch ((VAR_11 & 0x06) >> 1) {
case 0x0:
VAR_12 = 1;
lace_size = av_mallocz(sizeof(int));
lace_size[0] = VAR_2;
break;
case 0x1:
case 0x2:
case 0x3:
if (VAR_2 == 0) {
VAR_8 = -1;
break;
}
VAR_12 = (*VAR_1) + 1;
VAR_1 += 1;
VAR_2 -= 1;
lace_size = av_mallocz(VAR_12 * sizeof(int));
switch ((VAR_11 & 0x06) >> 1) {
case 0x1: {
uint8_t temp;
uint32_t total = 0;
for (VAR_10 = 0; VAR_8 == 0 && VAR_10 < VAR_12 - 1; VAR_10++) {
while (1) {
if (VAR_2 == 0) {
VAR_8 = -1;
break;
}
temp = *VAR_1;
lace_size[VAR_10] += temp;
VAR_1 += 1;
VAR_2 -= 1;
if (temp != 0xff)
break;
}
total += lace_size[VAR_10];
}
lace_size[VAR_10] = VAR_2 - total;
break;
}
case 0x2:
for (VAR_10 = 0; VAR_10 < VAR_12; VAR_10++)
lace_size[VAR_10] = VAR_2 / VAR_12;
break;
case 0x3: {
uint32_t total;
VAR_10 = matroska_ebmlnum_uint(VAR_1, VAR_2, &num);
if (VAR_10 < 0) {
av_log(VAR_0->ctx, AV_LOG_INFO,
"EBML block VAR_1 error\VAR_10");
break;
}
VAR_1 += VAR_10;
VAR_2 -= VAR_10;
total = lace_size[0] = num;
for (VAR_10 = 1; VAR_8 == 0 && VAR_10 < VAR_12 - 1; VAR_10++) {
int64_t snum;
int VAR_13;
VAR_13 = matroska_ebmlnum_sint (VAR_1, VAR_2, &snum);
if (VAR_13 < 0) {
av_log(VAR_0->ctx, AV_LOG_INFO,
"EBML block VAR_1 error\VAR_10");
break;
}
VAR_1 += VAR_13;
VAR_2 -= VAR_13;
lace_size[VAR_10] = lace_size[VAR_10 - 1] + snum;
total += lace_size[VAR_10];
}
lace_size[VAR_10] = VAR_2 - total;
break;
}
}
break;
}
if (VAR_8 == 0) {
int VAR_14 = VAR_0->tracks[VAR_9]->VAR_11 & MATROSKA_TRACK_REAL_V;
for (VAR_10 = 0; VAR_10 < VAR_12; VAR_10++) {
uint64_t timecode = AV_NOPTS_VALUE;
int VAR_15, VAR_16 = 1;
if (VAR_14) {
VAR_16 = *VAR_1++ + 1;
lace_size[VAR_10]--;
}
if (VAR_4 != (uint64_t)-1 && VAR_10 == 0) {
if (VAR_4 + block_time >= 0)
timecode = (VAR_4 + block_time) * VAR_0->time_scale;
}
for (VAR_15=0; VAR_15<VAR_16; VAR_15++) {
int VAR_17, VAR_18 = 0;
if (VAR_14)
VAR_18 = rv_offset(VAR_1, VAR_15, VAR_16);
if (VAR_15+1 == VAR_16)
VAR_17 = lace_size[VAR_10] - VAR_18;
else
VAR_17 = rv_offset(VAR_1, VAR_15+1, VAR_16) - VAR_18;
pkt = av_mallocz(sizeof(AVPacket));
if (VAR_7) *VAR_7 = pkt;
if (av_new_packet(pkt, VAR_17) < 0) {
VAR_8 = AVERROR_NOMEM;
VAR_10 = VAR_12-1;
break;
}
memcpy (pkt->VAR_1, VAR_1+VAR_18, VAR_17);
if (VAR_10 == 0)
pkt->VAR_11 = VAR_5;
pkt->stream_index = VAR_0->tracks[VAR_9]->stream_index;
pkt->pts = timecode;
pkt->VAR_3 = VAR_3;
matroska_queue_packet(VAR_0, pkt);
}
VAR_1 += lace_size[VAR_10];
}
}
av_free(lace_size);
av_free(origdata);
return VAR_8;
}
| [
"FUNC_0(MatroskaDemuxContext *VAR_0, uint8_t *VAR_1, int VAR_2,\nint64_t VAR_3, uint64_t VAR_4,\nint VAR_5, int *VAR_6, AVPacket **VAR_7)\n{",
"int VAR_8 = 0;",
"int VAR_9;",
"AVPacket *pkt;",
"uint8_t *origdata = VAR_1;",
"int16_t block_time;",
"uint32_t *lace_size = NULL;",
"int VAR_10, VAR_11, VAR_12 = 0;",
"uint64_t num;",
"if ((VAR_10 = matroska_ebmlnum_uint(VAR_1, VAR_2, &num)) < 0) {",
"av_log(VAR_0->ctx, AV_LOG_ERROR, \"EBML block VAR_1 error\\VAR_10\");",
"av_free(origdata);",
"return VAR_8;",
"}",
"VAR_1 += VAR_10;",
"VAR_2 -= VAR_10;",
"VAR_9 = matroska_find_track_by_num(VAR_0, num);",
"if (VAR_6) *VAR_6 = VAR_9;",
"if (VAR_2 <= 3 || VAR_9 < 0 || VAR_9 >= VAR_0->num_tracks) {",
"av_log(VAR_0->ctx, AV_LOG_INFO,\n\"Invalid stream %d or VAR_2 %u\\VAR_10\", VAR_9, VAR_2);",
"av_free(origdata);",
"return VAR_8;",
"}",
"if(VAR_0->ctx->streams[ VAR_0->tracks[VAR_9]->stream_index ]->discard >= AVDISCARD_ALL){",
"av_free(origdata);",
"return VAR_8;",
"}",
"block_time = (VAR_1[0] << 8) | VAR_1[1];",
"VAR_1 += 2;",
"VAR_2 -= 2;",
"VAR_11 = *VAR_1;",
"VAR_1 += 1;",
"VAR_2 -= 1;",
"if (VAR_5 == -1)\nVAR_5 = VAR_11 & 1 ? PKT_FLAG_KEY : 0;",
"switch ((VAR_11 & 0x06) >> 1) {",
"case 0x0:\nVAR_12 = 1;",
"lace_size = av_mallocz(sizeof(int));",
"lace_size[0] = VAR_2;",
"break;",
"case 0x1:\ncase 0x2:\ncase 0x3:\nif (VAR_2 == 0) {",
"VAR_8 = -1;",
"break;",
"}",
"VAR_12 = (*VAR_1) + 1;",
"VAR_1 += 1;",
"VAR_2 -= 1;",
"lace_size = av_mallocz(VAR_12 * sizeof(int));",
"switch ((VAR_11 & 0x06) >> 1) {",
"case 0x1: {",
"uint8_t temp;",
"uint32_t total = 0;",
"for (VAR_10 = 0; VAR_8 == 0 && VAR_10 < VAR_12 - 1; VAR_10++) {",
"while (1) {",
"if (VAR_2 == 0) {",
"VAR_8 = -1;",
"break;",
"}",
"temp = *VAR_1;",
"lace_size[VAR_10] += temp;",
"VAR_1 += 1;",
"VAR_2 -= 1;",
"if (temp != 0xff)\nbreak;",
"}",
"total += lace_size[VAR_10];",
"}",
"lace_size[VAR_10] = VAR_2 - total;",
"break;",
"}",
"case 0x2:\nfor (VAR_10 = 0; VAR_10 < VAR_12; VAR_10++)",
"lace_size[VAR_10] = VAR_2 / VAR_12;",
"break;",
"case 0x3: {",
"uint32_t total;",
"VAR_10 = matroska_ebmlnum_uint(VAR_1, VAR_2, &num);",
"if (VAR_10 < 0) {",
"av_log(VAR_0->ctx, AV_LOG_INFO,\n\"EBML block VAR_1 error\\VAR_10\");",
"break;",
"}",
"VAR_1 += VAR_10;",
"VAR_2 -= VAR_10;",
"total = lace_size[0] = num;",
"for (VAR_10 = 1; VAR_8 == 0 && VAR_10 < VAR_12 - 1; VAR_10++) {",
"int64_t snum;",
"int VAR_13;",
"VAR_13 = matroska_ebmlnum_sint (VAR_1, VAR_2, &snum);",
"if (VAR_13 < 0) {",
"av_log(VAR_0->ctx, AV_LOG_INFO,\n\"EBML block VAR_1 error\\VAR_10\");",
"break;",
"}",
"VAR_1 += VAR_13;",
"VAR_2 -= VAR_13;",
"lace_size[VAR_10] = lace_size[VAR_10 - 1] + snum;",
"total += lace_size[VAR_10];",
"}",
"lace_size[VAR_10] = VAR_2 - total;",
"break;",
"}",
"}",
"break;",
"}",
"if (VAR_8 == 0) {",
"int VAR_14 = VAR_0->tracks[VAR_9]->VAR_11 & MATROSKA_TRACK_REAL_V;",
"for (VAR_10 = 0; VAR_10 < VAR_12; VAR_10++) {",
"uint64_t timecode = AV_NOPTS_VALUE;",
"int VAR_15, VAR_16 = 1;",
"if (VAR_14) {",
"VAR_16 = *VAR_1++ + 1;",
"lace_size[VAR_10]--;",
"}",
"if (VAR_4 != (uint64_t)-1 && VAR_10 == 0) {",
"if (VAR_4 + block_time >= 0)\ntimecode = (VAR_4 + block_time) * VAR_0->time_scale;",
"}",
"for (VAR_15=0; VAR_15<VAR_16; VAR_15++) {",
"int VAR_17, VAR_18 = 0;",
"if (VAR_14)\nVAR_18 = rv_offset(VAR_1, VAR_15, VAR_16);",
"if (VAR_15+1 == VAR_16)\nVAR_17 = lace_size[VAR_10] - VAR_18;",
"else\nVAR_17 = rv_offset(VAR_1, VAR_15+1, VAR_16) - VAR_18;",
"pkt = av_mallocz(sizeof(AVPacket));",
"if (VAR_7) *VAR_7 = pkt;",
"if (av_new_packet(pkt, VAR_17) < 0) {",
"VAR_8 = AVERROR_NOMEM;",
"VAR_10 = VAR_12-1;",
"break;",
"}",
"memcpy (pkt->VAR_1, VAR_1+VAR_18, VAR_17);",
"if (VAR_10 == 0)\npkt->VAR_11 = VAR_5;",
"pkt->stream_index = VAR_0->tracks[VAR_9]->stream_index;",
"pkt->pts = timecode;",
"pkt->VAR_3 = VAR_3;",
"matroska_queue_packet(VAR_0, pkt);",
"}",
"VAR_1 += lace_size[VAR_10];",
"}",
"}",
"av_free(lace_size);",
"av_free(origdata);",
"return VAR_8;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
105,
107,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175,
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271,
273
],
[
275
],
[
281
],
[
283
],
[
285,
287
],
[
289,
291
],
[
293,
295
],
[
297
],
[
299
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
317,
319
],
[
321
],
[
325
],
[
327
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
343
],
[
345
],
[
347
],
[
349
]
] |
22,791 | Visitor *qmp_input_visitor_new(QObject *obj, bool strict)
{
QmpInputVisitor *v;
assert(obj);
v = g_malloc0(sizeof(*v));
v->visitor.type = VISITOR_INPUT;
v->visitor.start_struct = qmp_input_start_struct;
v->visitor.check_struct = qmp_input_check_struct;
v->visitor.end_struct = qmp_input_pop;
v->visitor.start_list = qmp_input_start_list;
v->visitor.next_list = qmp_input_next_list;
v->visitor.end_list = qmp_input_pop;
v->visitor.start_alternate = qmp_input_start_alternate;
v->visitor.type_int64 = qmp_input_type_int64;
v->visitor.type_uint64 = qmp_input_type_uint64;
v->visitor.type_bool = qmp_input_type_bool;
v->visitor.type_str = qmp_input_type_str;
v->visitor.type_number = qmp_input_type_number;
v->visitor.type_any = qmp_input_type_any;
v->visitor.type_null = qmp_input_type_null;
v->visitor.optional = qmp_input_optional;
v->visitor.free = qmp_input_free;
v->strict = strict;
v->root = obj;
qobject_incref(obj);
return &v->visitor;
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | Visitor *qmp_input_visitor_new(QObject *obj, bool strict)
{
QmpInputVisitor *v;
assert(obj);
v = g_malloc0(sizeof(*v));
v->visitor.type = VISITOR_INPUT;
v->visitor.start_struct = qmp_input_start_struct;
v->visitor.check_struct = qmp_input_check_struct;
v->visitor.end_struct = qmp_input_pop;
v->visitor.start_list = qmp_input_start_list;
v->visitor.next_list = qmp_input_next_list;
v->visitor.end_list = qmp_input_pop;
v->visitor.start_alternate = qmp_input_start_alternate;
v->visitor.type_int64 = qmp_input_type_int64;
v->visitor.type_uint64 = qmp_input_type_uint64;
v->visitor.type_bool = qmp_input_type_bool;
v->visitor.type_str = qmp_input_type_str;
v->visitor.type_number = qmp_input_type_number;
v->visitor.type_any = qmp_input_type_any;
v->visitor.type_null = qmp_input_type_null;
v->visitor.optional = qmp_input_optional;
v->visitor.free = qmp_input_free;
v->strict = strict;
v->root = obj;
qobject_incref(obj);
return &v->visitor;
}
| {
"code": [],
"line_no": []
} | Visitor *FUNC_0(QObject *obj, bool strict)
{
QmpInputVisitor *v;
assert(obj);
v = g_malloc0(sizeof(*v));
v->visitor.type = VISITOR_INPUT;
v->visitor.start_struct = qmp_input_start_struct;
v->visitor.check_struct = qmp_input_check_struct;
v->visitor.end_struct = qmp_input_pop;
v->visitor.start_list = qmp_input_start_list;
v->visitor.next_list = qmp_input_next_list;
v->visitor.end_list = qmp_input_pop;
v->visitor.start_alternate = qmp_input_start_alternate;
v->visitor.type_int64 = qmp_input_type_int64;
v->visitor.type_uint64 = qmp_input_type_uint64;
v->visitor.type_bool = qmp_input_type_bool;
v->visitor.type_str = qmp_input_type_str;
v->visitor.type_number = qmp_input_type_number;
v->visitor.type_any = qmp_input_type_any;
v->visitor.type_null = qmp_input_type_null;
v->visitor.optional = qmp_input_optional;
v->visitor.free = qmp_input_free;
v->strict = strict;
v->root = obj;
qobject_incref(obj);
return &v->visitor;
}
| [
"Visitor *FUNC_0(QObject *obj, bool strict)\n{",
"QmpInputVisitor *v;",
"assert(obj);",
"v = g_malloc0(sizeof(*v));",
"v->visitor.type = VISITOR_INPUT;",
"v->visitor.start_struct = qmp_input_start_struct;",
"v->visitor.check_struct = qmp_input_check_struct;",
"v->visitor.end_struct = qmp_input_pop;",
"v->visitor.start_list = qmp_input_start_list;",
"v->visitor.next_list = qmp_input_next_list;",
"v->visitor.end_list = qmp_input_pop;",
"v->visitor.start_alternate = qmp_input_start_alternate;",
"v->visitor.type_int64 = qmp_input_type_int64;",
"v->visitor.type_uint64 = qmp_input_type_uint64;",
"v->visitor.type_bool = qmp_input_type_bool;",
"v->visitor.type_str = qmp_input_type_str;",
"v->visitor.type_number = qmp_input_type_number;",
"v->visitor.type_any = qmp_input_type_any;",
"v->visitor.type_null = qmp_input_type_null;",
"v->visitor.optional = qmp_input_optional;",
"v->visitor.free = qmp_input_free;",
"v->strict = strict;",
"v->root = obj;",
"qobject_incref(obj);",
"return &v->visitor;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61
]
] |
22,792 | static gboolean tcp_chr_accept(QIOChannel *channel,
GIOCondition cond,
void *opaque)
{
CharDriverState *chr = opaque;
TCPCharDriver *s = chr->opaque;
QIOChannelSocket *sioc;
sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(channel),
NULL);
if (!sioc) {
return TRUE;
}
if (s->do_telnetopt) {
tcp_chr_telnet_init(QIO_CHANNEL(sioc));
}
tcp_chr_new_client(chr, sioc);
object_unref(OBJECT(sioc));
return TRUE;
}
| false | qemu | f2001a7e0555b66d6db25a3ff1801540814045bb | static gboolean tcp_chr_accept(QIOChannel *channel,
GIOCondition cond,
void *opaque)
{
CharDriverState *chr = opaque;
TCPCharDriver *s = chr->opaque;
QIOChannelSocket *sioc;
sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(channel),
NULL);
if (!sioc) {
return TRUE;
}
if (s->do_telnetopt) {
tcp_chr_telnet_init(QIO_CHANNEL(sioc));
}
tcp_chr_new_client(chr, sioc);
object_unref(OBJECT(sioc));
return TRUE;
}
| {
"code": [],
"line_no": []
} | static gboolean FUNC_0(QIOChannel *channel,
GIOCondition cond,
void *opaque)
{
CharDriverState *chr = opaque;
TCPCharDriver *s = chr->opaque;
QIOChannelSocket *sioc;
sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(channel),
NULL);
if (!sioc) {
return TRUE;
}
if (s->do_telnetopt) {
tcp_chr_telnet_init(QIO_CHANNEL(sioc));
}
tcp_chr_new_client(chr, sioc);
object_unref(OBJECT(sioc));
return TRUE;
}
| [
"static gboolean FUNC_0(QIOChannel *channel,\nGIOCondition cond,\nvoid *opaque)\n{",
"CharDriverState *chr = opaque;",
"TCPCharDriver *s = chr->opaque;",
"QIOChannelSocket *sioc;",
"sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(channel),\nNULL);",
"if (!sioc) {",
"return TRUE;",
"}",
"if (s->do_telnetopt) {",
"tcp_chr_telnet_init(QIO_CHANNEL(sioc));",
"}",
"tcp_chr_new_client(chr, sioc);",
"object_unref(OBJECT(sioc));",
"return TRUE;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
45
],
[
47
]
] |
22,793 | void qemu_timer_notify_cb(void *opaque, QEMUClockType type)
{
qemu_notify_event();
}
| false | qemu | 6b8f0187a4d7c263e356302f8d308655372a4b5b | void qemu_timer_notify_cb(void *opaque, QEMUClockType type)
{
qemu_notify_event();
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void *VAR_0, QEMUClockType VAR_1)
{
qemu_notify_event();
}
| [
"void FUNC_0(void *VAR_0, QEMUClockType VAR_1)\n{",
"qemu_notify_event();",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,795 | static void return_frame(AVFilterContext *ctx, int is_second)
{
YADIFContext *yadif = ctx->priv;
AVFilterLink *link= ctx->outputs[0];
int tff;
if (yadif->parity == -1) {
tff = yadif->cur->video->interlaced ?
yadif->cur->video->top_field_first : 1;
} else {
tff = yadif->parity^1;
}
if (is_second) {
yadif->out = ff_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE, link->w, link->h);
avfilter_copy_buffer_ref_props(yadif->out, yadif->cur);
yadif->out->video->interlaced = 0;
}
if (!yadif->csp)
yadif->csp = &av_pix_fmt_descriptors[link->format];
if (yadif->csp->comp[0].depth_minus1 / 8 == 1)
yadif->filter_line = filter_line_c_16bit;
filter(ctx, yadif->out, tff ^ !is_second, tff);
if (is_second) {
int64_t cur_pts = yadif->cur->pts;
int64_t next_pts = yadif->next->pts;
if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
yadif->out->pts = cur_pts + next_pts;
} else {
yadif->out->pts = AV_NOPTS_VALUE;
}
ff_start_frame(ctx->outputs[0], yadif->out);
}
ff_draw_slice(ctx->outputs[0], 0, link->h, 1);
ff_end_frame(ctx->outputs[0]);
yadif->frame_pending = (yadif->mode&1) && !is_second;
}
| false | FFmpeg | 3825b5268844694ff50a0e0bfde64df43a862fae | static void return_frame(AVFilterContext *ctx, int is_second)
{
YADIFContext *yadif = ctx->priv;
AVFilterLink *link= ctx->outputs[0];
int tff;
if (yadif->parity == -1) {
tff = yadif->cur->video->interlaced ?
yadif->cur->video->top_field_first : 1;
} else {
tff = yadif->parity^1;
}
if (is_second) {
yadif->out = ff_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE, link->w, link->h);
avfilter_copy_buffer_ref_props(yadif->out, yadif->cur);
yadif->out->video->interlaced = 0;
}
if (!yadif->csp)
yadif->csp = &av_pix_fmt_descriptors[link->format];
if (yadif->csp->comp[0].depth_minus1 / 8 == 1)
yadif->filter_line = filter_line_c_16bit;
filter(ctx, yadif->out, tff ^ !is_second, tff);
if (is_second) {
int64_t cur_pts = yadif->cur->pts;
int64_t next_pts = yadif->next->pts;
if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
yadif->out->pts = cur_pts + next_pts;
} else {
yadif->out->pts = AV_NOPTS_VALUE;
}
ff_start_frame(ctx->outputs[0], yadif->out);
}
ff_draw_slice(ctx->outputs[0], 0, link->h, 1);
ff_end_frame(ctx->outputs[0]);
yadif->frame_pending = (yadif->mode&1) && !is_second;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFilterContext *VAR_0, int VAR_1)
{
YADIFContext *yadif = VAR_0->priv;
AVFilterLink *link= VAR_0->outputs[0];
int VAR_2;
if (yadif->parity == -1) {
VAR_2 = yadif->cur->video->interlaced ?
yadif->cur->video->top_field_first : 1;
} else {
VAR_2 = yadif->parity^1;
}
if (VAR_1) {
yadif->out = ff_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE, link->w, link->h);
avfilter_copy_buffer_ref_props(yadif->out, yadif->cur);
yadif->out->video->interlaced = 0;
}
if (!yadif->csp)
yadif->csp = &av_pix_fmt_descriptors[link->format];
if (yadif->csp->comp[0].depth_minus1 / 8 == 1)
yadif->filter_line = filter_line_c_16bit;
filter(VAR_0, yadif->out, VAR_2 ^ !VAR_1, VAR_2);
if (VAR_1) {
int64_t cur_pts = yadif->cur->pts;
int64_t next_pts = yadif->next->pts;
if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
yadif->out->pts = cur_pts + next_pts;
} else {
yadif->out->pts = AV_NOPTS_VALUE;
}
ff_start_frame(VAR_0->outputs[0], yadif->out);
}
ff_draw_slice(VAR_0->outputs[0], 0, link->h, 1);
ff_end_frame(VAR_0->outputs[0]);
yadif->frame_pending = (yadif->mode&1) && !VAR_1;
}
| [
"static void FUNC_0(AVFilterContext *VAR_0, int VAR_1)\n{",
"YADIFContext *yadif = VAR_0->priv;",
"AVFilterLink *link= VAR_0->outputs[0];",
"int VAR_2;",
"if (yadif->parity == -1) {",
"VAR_2 = yadif->cur->video->interlaced ?\nyadif->cur->video->top_field_first : 1;",
"} else {",
"VAR_2 = yadif->parity^1;",
"}",
"if (VAR_1) {",
"yadif->out = ff_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE |\nAV_PERM_REUSE, link->w, link->h);",
"avfilter_copy_buffer_ref_props(yadif->out, yadif->cur);",
"yadif->out->video->interlaced = 0;",
"}",
"if (!yadif->csp)\nyadif->csp = &av_pix_fmt_descriptors[link->format];",
"if (yadif->csp->comp[0].depth_minus1 / 8 == 1)\nyadif->filter_line = filter_line_c_16bit;",
"filter(VAR_0, yadif->out, VAR_2 ^ !VAR_1, VAR_2);",
"if (VAR_1) {",
"int64_t cur_pts = yadif->cur->pts;",
"int64_t next_pts = yadif->next->pts;",
"if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {",
"yadif->out->pts = cur_pts + next_pts;",
"} else {",
"yadif->out->pts = AV_NOPTS_VALUE;",
"}",
"ff_start_frame(VAR_0->outputs[0], yadif->out);",
"}",
"ff_draw_slice(VAR_0->outputs[0], 0, link->h, 1);",
"ff_end_frame(VAR_0->outputs[0]);",
"yadif->frame_pending = (yadif->mode&1) && !VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
45,
47
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
22,796 | static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb,
const float *in, int size, int scale_idx,
int cb, const float lambda)
{
const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
const float CLIPPED_ESCAPE = 165140.0f*IQ;
const int dim = (cb < FIRST_PAIR_BT) ? 4 : 2;
int i, j, k;
#ifndef USE_REALLY_FULL_SEARCH
const float Q34 = sqrtf(Q * sqrtf(Q));
const int range = aac_cb_range[cb];
const int maxval = aac_cb_maxval[cb];
int offs[4];
float *scaled = s->scoefs;
#endif /* USE_REALLY_FULL_SEARCH */
//START_TIMER
if (!cb)
return;
#ifndef USE_REALLY_FULL_SEARCH
offs[0] = 1;
for (i = 1; i < dim; i++)
offs[i] = offs[i-1]*range;
abs_pow34_v(scaled, in, size);
quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);
#endif /* USE_REALLY_FULL_SEARCH */
for (i = 0; i < size; i += dim) {
float mincost;
int minidx = 0;
int minbits = 0;
const float *vec;
#ifndef USE_REALLY_FULL_SEARCH
int (*quants)[2] = &s->qcoefs[i];
mincost = 0.0f;
for (j = 0; j < dim; j++)
mincost += in[i+j]*in[i+j]*lambda;
minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
minbits = ff_aac_spectral_bits[cb-1][minidx];
mincost += minbits;
for (j = 0; j < (1<<dim); j++) {
float rd = 0.0f;
int curbits;
int curidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
int same = 0;
for (k = 0; k < dim; k++) {
if ((j & (1 << k)) && quants[k][0] == quants[k][1]) {
same = 1;
break;
}
}
if (same)
continue;
for (k = 0; k < dim; k++)
curidx += quants[k][!!(j & (1 << k))] * offs[dim - 1 - k];
curbits = ff_aac_spectral_bits[cb-1][curidx];
vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
#else
vec = ff_aac_codebook_vectors[cb-1];
mincost = INFINITY;
for (j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim) {
float rd = 0.0f;
int curbits = ff_aac_spectral_bits[cb-1][j];
int curidx = j;
#endif /* USE_REALLY_FULL_SEARCH */
if (IS_CODEBOOK_UNSIGNED(cb)) {
for (k = 0; k < dim; k++) {
float t = fabsf(in[i+k]);
float di;
//do not code with escape sequence small values
if (vec[k] == 64.0f && t < 39.0f*IQ) {
rd = INFINITY;
break;
}
if (vec[k] == 64.0f) { //FIXME: slow
if (t >= CLIPPED_ESCAPE) {
di = t - CLIPPED_ESCAPE;
curbits += 21;
} else {
int c = av_clip(quant(t, Q), 0, 8191);
di = t - c*cbrt(c)*IQ;
curbits += av_log2(c)*2 - 4 + 1;
}
} else {
di = t - vec[k]*IQ;
}
if (vec[k] != 0.0f)
curbits++;
rd += di*di*lambda;
}
} else {
for (k = 0; k < dim; k++) {
float di = in[i+k] - vec[k]*IQ;
rd += di*di*lambda;
}
}
rd += curbits;
if (rd < mincost) {
mincost = rd;
minidx = curidx;
minbits = curbits;
}
}
put_bits(pb, ff_aac_spectral_bits[cb-1][minidx], ff_aac_spectral_codes[cb-1][minidx]);
if (IS_CODEBOOK_UNSIGNED(cb))
for (j = 0; j < dim; j++)
if (ff_aac_codebook_vectors[cb-1][minidx*dim+j] != 0.0f)
put_bits(pb, 1, in[i+j] < 0.0f);
if (cb == ESC_BT) {
for (j = 0; j < 2; j++) {
if (ff_aac_codebook_vectors[cb-1][minidx*2+j] == 64.0f) {
int coef = av_clip(quant(fabsf(in[i+j]), Q), 0, 8191);
int len = av_log2(coef);
put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2);
put_bits(pb, len, coef & ((1 << len) - 1));
}
}
}
}
//STOP_TIMER("quantize_and_encode")
}
| false | FFmpeg | a71e9b62546e4467751c0219869a7f6d004a5986 | static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb,
const float *in, int size, int scale_idx,
int cb, const float lambda)
{
const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
const float CLIPPED_ESCAPE = 165140.0f*IQ;
const int dim = (cb < FIRST_PAIR_BT) ? 4 : 2;
int i, j, k;
#ifndef USE_REALLY_FULL_SEARCH
const float Q34 = sqrtf(Q * sqrtf(Q));
const int range = aac_cb_range[cb];
const int maxval = aac_cb_maxval[cb];
int offs[4];
float *scaled = s->scoefs;
#endif
if (!cb)
return;
#ifndef USE_REALLY_FULL_SEARCH
offs[0] = 1;
for (i = 1; i < dim; i++)
offs[i] = offs[i-1]*range;
abs_pow34_v(scaled, in, size);
quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);
#endif
for (i = 0; i < size; i += dim) {
float mincost;
int minidx = 0;
int minbits = 0;
const float *vec;
#ifndef USE_REALLY_FULL_SEARCH
int (*quants)[2] = &s->qcoefs[i];
mincost = 0.0f;
for (j = 0; j < dim; j++)
mincost += in[i+j]*in[i+j]*lambda;
minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
minbits = ff_aac_spectral_bits[cb-1][minidx];
mincost += minbits;
for (j = 0; j < (1<<dim); j++) {
float rd = 0.0f;
int curbits;
int curidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
int same = 0;
for (k = 0; k < dim; k++) {
if ((j & (1 << k)) && quants[k][0] == quants[k][1]) {
same = 1;
break;
}
}
if (same)
continue;
for (k = 0; k < dim; k++)
curidx += quants[k][!!(j & (1 << k))] * offs[dim - 1 - k];
curbits = ff_aac_spectral_bits[cb-1][curidx];
vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
#else
vec = ff_aac_codebook_vectors[cb-1];
mincost = INFINITY;
for (j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim) {
float rd = 0.0f;
int curbits = ff_aac_spectral_bits[cb-1][j];
int curidx = j;
#endif
if (IS_CODEBOOK_UNSIGNED(cb)) {
for (k = 0; k < dim; k++) {
float t = fabsf(in[i+k]);
float di;
if (vec[k] == 64.0f && t < 39.0f*IQ) {
rd = INFINITY;
break;
}
if (vec[k] == 64.0f) {
if (t >= CLIPPED_ESCAPE) {
di = t - CLIPPED_ESCAPE;
curbits += 21;
} else {
int c = av_clip(quant(t, Q), 0, 8191);
di = t - c*cbrt(c)*IQ;
curbits += av_log2(c)*2 - 4 + 1;
}
} else {
di = t - vec[k]*IQ;
}
if (vec[k] != 0.0f)
curbits++;
rd += di*di*lambda;
}
} else {
for (k = 0; k < dim; k++) {
float di = in[i+k] - vec[k]*IQ;
rd += di*di*lambda;
}
}
rd += curbits;
if (rd < mincost) {
mincost = rd;
minidx = curidx;
minbits = curbits;
}
}
put_bits(pb, ff_aac_spectral_bits[cb-1][minidx], ff_aac_spectral_codes[cb-1][minidx]);
if (IS_CODEBOOK_UNSIGNED(cb))
for (j = 0; j < dim; j++)
if (ff_aac_codebook_vectors[cb-1][minidx*dim+j] != 0.0f)
put_bits(pb, 1, in[i+j] < 0.0f);
if (cb == ESC_BT) {
for (j = 0; j < 2; j++) {
if (ff_aac_codebook_vectors[cb-1][minidx*2+j] == 64.0f) {
int coef = av_clip(quant(fabsf(in[i+j]), Q), 0, 8191);
int len = av_log2(coef);
put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2);
put_bits(pb, len, coef & ((1 << len) - 1));
}
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct AACEncContext *VAR_0, PutBitContext *VAR_1,
const float *VAR_2, int VAR_3, int VAR_4,
int VAR_5, const float VAR_6)
{
const float VAR_7 = ff_aac_pow2sf_tab[200 + VAR_4 - SCALE_ONE_POS + SCALE_DIV_512];
const float VAR_8 = ff_aac_pow2sf_tab[200 - VAR_4 + SCALE_ONE_POS - SCALE_DIV_512];
const float VAR_9 = 165140.0f*VAR_7;
const int VAR_10 = (VAR_5 < FIRST_PAIR_BT) ? 4 : 2;
int VAR_11, VAR_12, VAR_13;
#ifndef USE_REALLY_FULL_SEARCH
const float VAR_14 = sqrtf(VAR_8 * sqrtf(VAR_8));
const int VAR_15 = aac_cb_range[VAR_5];
const int VAR_16 = aac_cb_maxval[VAR_5];
int VAR_17[4];
float *VAR_18 = VAR_0->scoefs;
#endif
if (!VAR_5)
return;
#ifndef USE_REALLY_FULL_SEARCH
VAR_17[0] = 1;
for (VAR_11 = 1; VAR_11 < VAR_10; VAR_11++)
VAR_17[VAR_11] = VAR_17[VAR_11-1]*VAR_15;
abs_pow34_v(VAR_18, VAR_2, VAR_3);
quantize_bands(VAR_0->qcoefs, VAR_2, VAR_18, VAR_3, VAR_14, !IS_CODEBOOK_UNSIGNED(VAR_5), VAR_16);
#endif
for (VAR_11 = 0; VAR_11 < VAR_3; VAR_11 += VAR_10) {
float VAR_19;
int VAR_20 = 0;
int VAR_21 = 0;
const float *VAR_22;
#ifndef USE_REALLY_FULL_SEARCH
int (*VAR_23)[2] = &VAR_0->qcoefs[VAR_11];
VAR_19 = 0.0f;
for (VAR_12 = 0; VAR_12 < VAR_10; VAR_12++)
VAR_19 += VAR_2[VAR_11+VAR_12]*VAR_2[VAR_11+VAR_12]*VAR_6;
VAR_20 = IS_CODEBOOK_UNSIGNED(VAR_5) ? 0 : 40;
VAR_21 = ff_aac_spectral_bits[VAR_5-1][VAR_20];
VAR_19 += VAR_21;
for (VAR_12 = 0; VAR_12 < (1<<VAR_10); VAR_12++) {
float VAR_24 = 0.0f;
int VAR_25;
int VAR_26 = IS_CODEBOOK_UNSIGNED(VAR_5) ? 0 : 40;
int VAR_27 = 0;
for (VAR_13 = 0; VAR_13 < VAR_10; VAR_13++) {
if ((VAR_12 & (1 << VAR_13)) && VAR_23[VAR_13][0] == VAR_23[VAR_13][1]) {
VAR_27 = 1;
break;
}
}
if (VAR_27)
continue;
for (VAR_13 = 0; VAR_13 < VAR_10; VAR_13++)
VAR_26 += VAR_23[VAR_13][!!(VAR_12 & (1 << VAR_13))] * VAR_17[VAR_10 - 1 - VAR_13];
VAR_25 = ff_aac_spectral_bits[VAR_5-1][VAR_26];
VAR_22 = &ff_aac_codebook_vectors[VAR_5-1][VAR_26*VAR_10];
#else
VAR_22 = ff_aac_codebook_vectors[VAR_5-1];
VAR_19 = INFINITY;
for (VAR_12 = 0; VAR_12 < ff_aac_spectral_sizes[VAR_5-1]; VAR_12++, VAR_22 += VAR_10) {
float VAR_24 = 0.0f;
int VAR_25 = ff_aac_spectral_bits[VAR_5-1][VAR_12];
int VAR_26 = VAR_12;
#endif
if (IS_CODEBOOK_UNSIGNED(VAR_5)) {
for (VAR_13 = 0; VAR_13 < VAR_10; VAR_13++) {
float VAR_28 = fabsf(VAR_2[VAR_11+VAR_13]);
float VAR_31;
if (VAR_22[VAR_13] == 64.0f && VAR_28 < 39.0f*VAR_7) {
VAR_24 = INFINITY;
break;
}
if (VAR_22[VAR_13] == 64.0f) {
if (VAR_28 >= VAR_9) {
VAR_31 = VAR_28 - VAR_9;
VAR_25 += 21;
} else {
int VAR_30 = av_clip(quant(VAR_28, VAR_8), 0, 8191);
VAR_31 = VAR_28 - VAR_30*cbrt(VAR_30)*VAR_7;
VAR_25 += av_log2(VAR_30)*2 - 4 + 1;
}
} else {
VAR_31 = VAR_28 - VAR_22[VAR_13]*VAR_7;
}
if (VAR_22[VAR_13] != 0.0f)
VAR_25++;
VAR_24 += VAR_31*VAR_31*VAR_6;
}
} else {
for (VAR_13 = 0; VAR_13 < VAR_10; VAR_13++) {
float VAR_31 = VAR_2[VAR_11+VAR_13] - VAR_22[VAR_13]*VAR_7;
VAR_24 += VAR_31*VAR_31*VAR_6;
}
}
VAR_24 += VAR_25;
if (VAR_24 < VAR_19) {
VAR_19 = VAR_24;
VAR_20 = VAR_26;
VAR_21 = VAR_25;
}
}
put_bits(VAR_1, ff_aac_spectral_bits[VAR_5-1][VAR_20], ff_aac_spectral_codes[VAR_5-1][VAR_20]);
if (IS_CODEBOOK_UNSIGNED(VAR_5))
for (VAR_12 = 0; VAR_12 < VAR_10; VAR_12++)
if (ff_aac_codebook_vectors[VAR_5-1][VAR_20*VAR_10+VAR_12] != 0.0f)
put_bits(VAR_1, 1, VAR_2[VAR_11+VAR_12] < 0.0f);
if (VAR_5 == ESC_BT) {
for (VAR_12 = 0; VAR_12 < 2; VAR_12++) {
if (ff_aac_codebook_vectors[VAR_5-1][VAR_20*2+VAR_12] == 64.0f) {
int VAR_31 = av_clip(quant(fabsf(VAR_2[VAR_11+VAR_12]), VAR_8), 0, 8191);
int VAR_32 = av_log2(VAR_31);
put_bits(VAR_1, VAR_32 - 4 + 1, (1 << (VAR_32 - 4 + 1)) - 2);
put_bits(VAR_1, VAR_32, VAR_31 & ((1 << VAR_32) - 1));
}
}
}
}
}
| [
"static void FUNC_0(struct AACEncContext *VAR_0, PutBitContext *VAR_1,\nconst float *VAR_2, int VAR_3, int VAR_4,\nint VAR_5, const float VAR_6)\n{",
"const float VAR_7 = ff_aac_pow2sf_tab[200 + VAR_4 - SCALE_ONE_POS + SCALE_DIV_512];",
"const float VAR_8 = ff_aac_pow2sf_tab[200 - VAR_4 + SCALE_ONE_POS - SCALE_DIV_512];",
"const float VAR_9 = 165140.0f*VAR_7;",
"const int VAR_10 = (VAR_5 < FIRST_PAIR_BT) ? 4 : 2;",
"int VAR_11, VAR_12, VAR_13;",
"#ifndef USE_REALLY_FULL_SEARCH\nconst float VAR_14 = sqrtf(VAR_8 * sqrtf(VAR_8));",
"const int VAR_15 = aac_cb_range[VAR_5];",
"const int VAR_16 = aac_cb_maxval[VAR_5];",
"int VAR_17[4];",
"float *VAR_18 = VAR_0->scoefs;",
"#endif\nif (!VAR_5)\nreturn;",
"#ifndef USE_REALLY_FULL_SEARCH\nVAR_17[0] = 1;",
"for (VAR_11 = 1; VAR_11 < VAR_10; VAR_11++)",
"VAR_17[VAR_11] = VAR_17[VAR_11-1]*VAR_15;",
"abs_pow34_v(VAR_18, VAR_2, VAR_3);",
"quantize_bands(VAR_0->qcoefs, VAR_2, VAR_18, VAR_3, VAR_14, !IS_CODEBOOK_UNSIGNED(VAR_5), VAR_16);",
"#endif\nfor (VAR_11 = 0; VAR_11 < VAR_3; VAR_11 += VAR_10) {",
"float VAR_19;",
"int VAR_20 = 0;",
"int VAR_21 = 0;",
"const float *VAR_22;",
"#ifndef USE_REALLY_FULL_SEARCH\nint (*VAR_23)[2] = &VAR_0->qcoefs[VAR_11];",
"VAR_19 = 0.0f;",
"for (VAR_12 = 0; VAR_12 < VAR_10; VAR_12++)",
"VAR_19 += VAR_2[VAR_11+VAR_12]*VAR_2[VAR_11+VAR_12]*VAR_6;",
"VAR_20 = IS_CODEBOOK_UNSIGNED(VAR_5) ? 0 : 40;",
"VAR_21 = ff_aac_spectral_bits[VAR_5-1][VAR_20];",
"VAR_19 += VAR_21;",
"for (VAR_12 = 0; VAR_12 < (1<<VAR_10); VAR_12++) {",
"float VAR_24 = 0.0f;",
"int VAR_25;",
"int VAR_26 = IS_CODEBOOK_UNSIGNED(VAR_5) ? 0 : 40;",
"int VAR_27 = 0;",
"for (VAR_13 = 0; VAR_13 < VAR_10; VAR_13++) {",
"if ((VAR_12 & (1 << VAR_13)) && VAR_23[VAR_13][0] == VAR_23[VAR_13][1]) {",
"VAR_27 = 1;",
"break;",
"}",
"}",
"if (VAR_27)\ncontinue;",
"for (VAR_13 = 0; VAR_13 < VAR_10; VAR_13++)",
"VAR_26 += VAR_23[VAR_13][!!(VAR_12 & (1 << VAR_13))] * VAR_17[VAR_10 - 1 - VAR_13];",
"VAR_25 = ff_aac_spectral_bits[VAR_5-1][VAR_26];",
"VAR_22 = &ff_aac_codebook_vectors[VAR_5-1][VAR_26*VAR_10];",
"#else\nVAR_22 = ff_aac_codebook_vectors[VAR_5-1];",
"VAR_19 = INFINITY;",
"for (VAR_12 = 0; VAR_12 < ff_aac_spectral_sizes[VAR_5-1]; VAR_12++, VAR_22 += VAR_10) {",
"float VAR_24 = 0.0f;",
"int VAR_25 = ff_aac_spectral_bits[VAR_5-1][VAR_12];",
"int VAR_26 = VAR_12;",
"#endif\nif (IS_CODEBOOK_UNSIGNED(VAR_5)) {",
"for (VAR_13 = 0; VAR_13 < VAR_10; VAR_13++) {",
"float VAR_28 = fabsf(VAR_2[VAR_11+VAR_13]);",
"float VAR_31;",
"if (VAR_22[VAR_13] == 64.0f && VAR_28 < 39.0f*VAR_7) {",
"VAR_24 = INFINITY;",
"break;",
"}",
"if (VAR_22[VAR_13] == 64.0f) {",
"if (VAR_28 >= VAR_9) {",
"VAR_31 = VAR_28 - VAR_9;",
"VAR_25 += 21;",
"} else {",
"int VAR_30 = av_clip(quant(VAR_28, VAR_8), 0, 8191);",
"VAR_31 = VAR_28 - VAR_30*cbrt(VAR_30)*VAR_7;",
"VAR_25 += av_log2(VAR_30)*2 - 4 + 1;",
"}",
"} else {",
"VAR_31 = VAR_28 - VAR_22[VAR_13]*VAR_7;",
"}",
"if (VAR_22[VAR_13] != 0.0f)\nVAR_25++;",
"VAR_24 += VAR_31*VAR_31*VAR_6;",
"}",
"} else {",
"for (VAR_13 = 0; VAR_13 < VAR_10; VAR_13++) {",
"float VAR_31 = VAR_2[VAR_11+VAR_13] - VAR_22[VAR_13]*VAR_7;",
"VAR_24 += VAR_31*VAR_31*VAR_6;",
"}",
"}",
"VAR_24 += VAR_25;",
"if (VAR_24 < VAR_19) {",
"VAR_19 = VAR_24;",
"VAR_20 = VAR_26;",
"VAR_21 = VAR_25;",
"}",
"}",
"put_bits(VAR_1, ff_aac_spectral_bits[VAR_5-1][VAR_20], ff_aac_spectral_codes[VAR_5-1][VAR_20]);",
"if (IS_CODEBOOK_UNSIGNED(VAR_5))\nfor (VAR_12 = 0; VAR_12 < VAR_10; VAR_12++)",
"if (ff_aac_codebook_vectors[VAR_5-1][VAR_20*VAR_10+VAR_12] != 0.0f)\nput_bits(VAR_1, 1, VAR_2[VAR_11+VAR_12] < 0.0f);",
"if (VAR_5 == ESC_BT) {",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++) {",
"if (ff_aac_codebook_vectors[VAR_5-1][VAR_20*2+VAR_12] == 64.0f) {",
"int VAR_31 = av_clip(quant(fabsf(VAR_2[VAR_11+VAR_12]), VAR_8), 0, 8191);",
"int VAR_32 = av_log2(VAR_31);",
"put_bits(VAR_1, VAR_32 - 4 + 1, (1 << (VAR_32 - 4 + 1)) - 2);",
"put_bits(VAR_1, VAR_32, VAR_31 & ((1 << VAR_32) - 1));",
"}",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
37,
39
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211,
213
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
]
] |
22,797 | static int seg_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
{
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
if (oc->oformat->check_bitstream) {
int ret = oc->oformat->check_bitstream(oc, pkt);
if (ret == 1) {
AVStream *st = s->streams[pkt->stream_index];
AVStream *ost = oc->streams[pkt->stream_index];
st->internal->bsfcs = ost->internal->bsfcs;
st->internal->nb_bsfcs = ost->internal->nb_bsfcs;
ost->internal->bsfcs = NULL;
ost->internal->nb_bsfcs = 0;
}
return ret;
}
return 1;
}
| false | FFmpeg | e29d2d9c92e19b0caf05a2064d132ccdecdfc3d5 | static int seg_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
{
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
if (oc->oformat->check_bitstream) {
int ret = oc->oformat->check_bitstream(oc, pkt);
if (ret == 1) {
AVStream *st = s->streams[pkt->stream_index];
AVStream *ost = oc->streams[pkt->stream_index];
st->internal->bsfcs = ost->internal->bsfcs;
st->internal->nb_bsfcs = ost->internal->nb_bsfcs;
ost->internal->bsfcs = NULL;
ost->internal->nb_bsfcs = 0;
}
return ret;
}
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct AVFormatContext *VAR_0, const AVPacket *VAR_1)
{
SegmentContext *seg = VAR_0->priv_data;
AVFormatContext *VAR_2 = seg->avf;
if (VAR_2->oformat->check_bitstream) {
int VAR_3 = VAR_2->oformat->check_bitstream(VAR_2, VAR_1);
if (VAR_3 == 1) {
AVStream *st = VAR_0->streams[VAR_1->stream_index];
AVStream *ost = VAR_2->streams[VAR_1->stream_index];
st->internal->bsfcs = ost->internal->bsfcs;
st->internal->nb_bsfcs = ost->internal->nb_bsfcs;
ost->internal->bsfcs = NULL;
ost->internal->nb_bsfcs = 0;
}
return VAR_3;
}
return 1;
}
| [
"static int FUNC_0(struct AVFormatContext *VAR_0, const AVPacket *VAR_1)\n{",
"SegmentContext *seg = VAR_0->priv_data;",
"AVFormatContext *VAR_2 = seg->avf;",
"if (VAR_2->oformat->check_bitstream) {",
"int VAR_3 = VAR_2->oformat->check_bitstream(VAR_2, VAR_1);",
"if (VAR_3 == 1) {",
"AVStream *st = VAR_0->streams[VAR_1->stream_index];",
"AVStream *ost = VAR_2->streams[VAR_1->stream_index];",
"st->internal->bsfcs = ost->internal->bsfcs;",
"st->internal->nb_bsfcs = ost->internal->nb_bsfcs;",
"ost->internal->bsfcs = NULL;",
"ost->internal->nb_bsfcs = 0;",
"}",
"return VAR_3;",
"}",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
22,798 | static int gen_check_bw(URLContext *s, RTMPContext *rt)
{
RTMPPacket pkt;
uint8_t *p;
int ret;
if ((ret = ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE,
0, 21)) < 0)
return ret;
p = pkt.data;
ff_amf_write_string(&p, "_checkbw");
ff_amf_write_number(&p, ++rt->nb_invokes);
ff_amf_write_null(&p);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return ret;
}
| false | FFmpeg | 82613564cfae459796642b22fc0163927d7f49e0 | static int gen_check_bw(URLContext *s, RTMPContext *rt)
{
RTMPPacket pkt;
uint8_t *p;
int ret;
if ((ret = ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE,
0, 21)) < 0)
return ret;
p = pkt.data;
ff_amf_write_string(&p, "_checkbw");
ff_amf_write_number(&p, ++rt->nb_invokes);
ff_amf_write_null(&p);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(URLContext *VAR_0, RTMPContext *VAR_1)
{
RTMPPacket pkt;
uint8_t *p;
int VAR_2;
if ((VAR_2 = ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE,
0, 21)) < 0)
return VAR_2;
p = pkt.data;
ff_amf_write_string(&p, "_checkbw");
ff_amf_write_number(&p, ++VAR_1->nb_invokes);
ff_amf_write_null(&p);
VAR_2 = ff_rtmp_packet_write(VAR_1->stream, &pkt, VAR_1->chunk_size,
VAR_1->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return VAR_2;
}
| [
"static int FUNC_0(URLContext *VAR_0, RTMPContext *VAR_1)\n{",
"RTMPPacket pkt;",
"uint8_t *p;",
"int VAR_2;",
"if ((VAR_2 = ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE,\n0, 21)) < 0)\nreturn VAR_2;",
"p = pkt.data;",
"ff_amf_write_string(&p, \"_checkbw\");",
"ff_amf_write_number(&p, ++VAR_1->nb_invokes);",
"ff_amf_write_null(&p);",
"VAR_2 = ff_rtmp_packet_write(VAR_1->stream, &pkt, VAR_1->chunk_size,\nVAR_1->prev_pkt[1]);",
"ff_rtmp_packet_destroy(&pkt);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
35
],
[
39
],
[
41
]
] |
22,799 | static void scsi_generic_purge_requests(SCSIGenericState *s)
{
SCSIGenericReq *r;
while (!QTAILQ_EMPTY(&s->qdev.requests)) {
r = DO_UPCAST(SCSIGenericReq, req, QTAILQ_FIRST(&s->qdev.requests));
if (r->req.aiocb) {
bdrv_aio_cancel(r->req.aiocb);
}
scsi_remove_request(r);
}
}
| true | qemu | ad2d30f79d3b0812f02c741be2189796b788d6d7 | static void scsi_generic_purge_requests(SCSIGenericState *s)
{
SCSIGenericReq *r;
while (!QTAILQ_EMPTY(&s->qdev.requests)) {
r = DO_UPCAST(SCSIGenericReq, req, QTAILQ_FIRST(&s->qdev.requests));
if (r->req.aiocb) {
bdrv_aio_cancel(r->req.aiocb);
}
scsi_remove_request(r);
}
}
| {
"code": [
" scsi_remove_request(r);",
" scsi_remove_request(r);",
" scsi_remove_request(r);",
" scsi_remove_request(r);",
" scsi_remove_request(r);"
],
"line_no": [
19,
19,
19,
19,
19
]
} | static void FUNC_0(SCSIGenericState *VAR_0)
{
SCSIGenericReq *r;
while (!QTAILQ_EMPTY(&VAR_0->qdev.requests)) {
r = DO_UPCAST(SCSIGenericReq, req, QTAILQ_FIRST(&VAR_0->qdev.requests));
if (r->req.aiocb) {
bdrv_aio_cancel(r->req.aiocb);
}
scsi_remove_request(r);
}
}
| [
"static void FUNC_0(SCSIGenericState *VAR_0)\n{",
"SCSIGenericReq *r;",
"while (!QTAILQ_EMPTY(&VAR_0->qdev.requests)) {",
"r = DO_UPCAST(SCSIGenericReq, req, QTAILQ_FIRST(&VAR_0->qdev.requests));",
"if (r->req.aiocb) {",
"bdrv_aio_cancel(r->req.aiocb);",
"}",
"scsi_remove_request(r);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
22,800 | static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
{
AVFrame *decoded_frame, *f;
int i, ret = 0, err = 0;
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
decoded_frame = ist->decoded_frame;
ret = decode(ist->dec_ctx, decoded_frame, got_output, pkt);
if (!*got_output || ret < 0)
return ret;
ist->frames_decoded++;
if (ist->hwaccel_retrieve_data && decoded_frame->format == ist->hwaccel_pix_fmt) {
err = ist->hwaccel_retrieve_data(ist->dec_ctx, decoded_frame);
if (err < 0)
goto fail;
}
ist->hwaccel_retrieved_pix_fmt = decoded_frame->format;
decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pts,
decoded_frame->pkt_dts);
if (ist->framerate.num)
decoded_frame->pts = ist->cfr_next_pts++;
if (ist->st->sample_aspect_ratio.num)
decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
for (i = 0; i < ist->nb_filters; i++) {
if (i < ist->nb_filters - 1) {
f = ist->filter_frame;
err = av_frame_ref(f, decoded_frame);
if (err < 0)
break;
} else
f = decoded_frame;
err = ifilter_send_frame(ist->filters[i], f);
if (err < 0)
break;
}
fail:
av_frame_unref(ist->filter_frame);
av_frame_unref(decoded_frame);
return err < 0 ? err : ret;
}
| true | FFmpeg | 27085d1b47c3741cc0fac284c916127c4066d049 | static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
{
AVFrame *decoded_frame, *f;
int i, ret = 0, err = 0;
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
decoded_frame = ist->decoded_frame;
ret = decode(ist->dec_ctx, decoded_frame, got_output, pkt);
if (!*got_output || ret < 0)
return ret;
ist->frames_decoded++;
if (ist->hwaccel_retrieve_data && decoded_frame->format == ist->hwaccel_pix_fmt) {
err = ist->hwaccel_retrieve_data(ist->dec_ctx, decoded_frame);
if (err < 0)
goto fail;
}
ist->hwaccel_retrieved_pix_fmt = decoded_frame->format;
decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pts,
decoded_frame->pkt_dts);
if (ist->framerate.num)
decoded_frame->pts = ist->cfr_next_pts++;
if (ist->st->sample_aspect_ratio.num)
decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
for (i = 0; i < ist->nb_filters; i++) {
if (i < ist->nb_filters - 1) {
f = ist->filter_frame;
err = av_frame_ref(f, decoded_frame);
if (err < 0)
break;
} else
f = decoded_frame;
err = ifilter_send_frame(ist->filters[i], f);
if (err < 0)
break;
}
fail:
av_frame_unref(ist->filter_frame);
av_frame_unref(decoded_frame);
return err < 0 ? err : ret;
}
| {
"code": [
"static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)"
],
"line_no": [
1
]
} | static int FUNC_0(InputStream *VAR_0, AVPacket *VAR_1, int *VAR_2)
{
AVFrame *decoded_frame, *f;
int VAR_3, VAR_4 = 0, VAR_5 = 0;
if (!VAR_0->decoded_frame && !(VAR_0->decoded_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
if (!VAR_0->filter_frame && !(VAR_0->filter_frame = av_frame_alloc()))
return AVERROR(ENOMEM);
decoded_frame = VAR_0->decoded_frame;
VAR_4 = decode(VAR_0->dec_ctx, decoded_frame, VAR_2, VAR_1);
if (!*VAR_2 || VAR_4 < 0)
return VAR_4;
VAR_0->frames_decoded++;
if (VAR_0->hwaccel_retrieve_data && decoded_frame->format == VAR_0->hwaccel_pix_fmt) {
VAR_5 = VAR_0->hwaccel_retrieve_data(VAR_0->dec_ctx, decoded_frame);
if (VAR_5 < 0)
goto fail;
}
VAR_0->hwaccel_retrieved_pix_fmt = decoded_frame->format;
decoded_frame->pts = guess_correct_pts(&VAR_0->pts_ctx, decoded_frame->pts,
decoded_frame->pkt_dts);
if (VAR_0->framerate.num)
decoded_frame->pts = VAR_0->cfr_next_pts++;
if (VAR_0->st->sample_aspect_ratio.num)
decoded_frame->sample_aspect_ratio = VAR_0->st->sample_aspect_ratio;
for (VAR_3 = 0; VAR_3 < VAR_0->nb_filters; VAR_3++) {
if (VAR_3 < VAR_0->nb_filters - 1) {
f = VAR_0->filter_frame;
VAR_5 = av_frame_ref(f, decoded_frame);
if (VAR_5 < 0)
break;
} else
f = decoded_frame;
VAR_5 = ifilter_send_frame(VAR_0->filters[VAR_3], f);
if (VAR_5 < 0)
break;
}
fail:
av_frame_unref(VAR_0->filter_frame);
av_frame_unref(decoded_frame);
return VAR_5 < 0 ? VAR_5 : VAR_4;
}
| [
"static int FUNC_0(InputStream *VAR_0, AVPacket *VAR_1, int *VAR_2)\n{",
"AVFrame *decoded_frame, *f;",
"int VAR_3, VAR_4 = 0, VAR_5 = 0;",
"if (!VAR_0->decoded_frame && !(VAR_0->decoded_frame = av_frame_alloc()))\nreturn AVERROR(ENOMEM);",
"if (!VAR_0->filter_frame && !(VAR_0->filter_frame = av_frame_alloc()))\nreturn AVERROR(ENOMEM);",
"decoded_frame = VAR_0->decoded_frame;",
"VAR_4 = decode(VAR_0->dec_ctx, decoded_frame, VAR_2, VAR_1);",
"if (!*VAR_2 || VAR_4 < 0)\nreturn VAR_4;",
"VAR_0->frames_decoded++;",
"if (VAR_0->hwaccel_retrieve_data && decoded_frame->format == VAR_0->hwaccel_pix_fmt) {",
"VAR_5 = VAR_0->hwaccel_retrieve_data(VAR_0->dec_ctx, decoded_frame);",
"if (VAR_5 < 0)\ngoto fail;",
"}",
"VAR_0->hwaccel_retrieved_pix_fmt = decoded_frame->format;",
"decoded_frame->pts = guess_correct_pts(&VAR_0->pts_ctx, decoded_frame->pts,\ndecoded_frame->pkt_dts);",
"if (VAR_0->framerate.num)\ndecoded_frame->pts = VAR_0->cfr_next_pts++;",
"if (VAR_0->st->sample_aspect_ratio.num)\ndecoded_frame->sample_aspect_ratio = VAR_0->st->sample_aspect_ratio;",
"for (VAR_3 = 0; VAR_3 < VAR_0->nb_filters; VAR_3++) {",
"if (VAR_3 < VAR_0->nb_filters - 1) {",
"f = VAR_0->filter_frame;",
"VAR_5 = av_frame_ref(f, decoded_frame);",
"if (VAR_5 < 0)\nbreak;",
"} else",
"f = decoded_frame;",
"VAR_5 = ifilter_send_frame(VAR_0->filters[VAR_3], f);",
"if (VAR_5 < 0)\nbreak;",
"}",
"fail:\nav_frame_unref(VAR_0->filter_frame);",
"av_frame_unref(decoded_frame);",
"return VAR_5 < 0 ? VAR_5 : VAR_4;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15,
17
],
[
19
],
[
23
],
[
25,
27
],
[
31
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
49,
51
],
[
53,
55
],
[
59,
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
83
],
[
85,
87
],
[
89
],
[
93,
95
],
[
97
],
[
99
],
[
101
]
] |
22,802 | int boot_sector_init(const char *fname)
{
FILE *f = fopen(fname, "w");
size_t len = sizeof boot_sector;
if (!f) {
fprintf(stderr, "Couldn't open \"%s\": %s", fname, strerror(errno));
return 1;
}
/* For Open Firmware based system, we can use a Forth script instead */
if (strcmp(qtest_get_arch(), "ppc64") == 0) {
len = sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x c!\n",
LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET,
HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
}
fwrite(boot_sector, 1, len, f);
fclose(f);
return 0;
}
| true | qemu | 3e353773721596971db2d0abc7015e7ea3d3af07 | int boot_sector_init(const char *fname)
{
FILE *f = fopen(fname, "w");
size_t len = sizeof boot_sector;
if (!f) {
fprintf(stderr, "Couldn't open \"%s\": %s", fname, strerror(errno));
return 1;
}
if (strcmp(qtest_get_arch(), "ppc64") == 0) {
len = sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x c!\n",
LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET,
HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
}
fwrite(boot_sector, 1, len, f);
fclose(f);
return 0;
}
| {
"code": [
"int boot_sector_init(const char *fname)",
" FILE *f = fopen(fname, \"w\");",
" if (!f) {",
" fwrite(boot_sector, 1, len, f);",
" fclose(f);"
],
"line_no": [
1,
5,
11,
35,
37
]
} | int FUNC_0(const char *VAR_0)
{
FILE *f = fopen(VAR_0, "w");
size_t len = sizeof boot_sector;
if (!f) {
fprintf(stderr, "Couldn't open \"%s\": %s", VAR_0, strerror(errno));
return 1;
}
if (strcmp(qtest_get_arch(), "ppc64") == 0) {
len = sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x c!\n",
LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET,
HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
}
fwrite(boot_sector, 1, len, f);
fclose(f);
return 0;
}
| [
"int FUNC_0(const char *VAR_0)\n{",
"FILE *f = fopen(VAR_0, \"w\");",
"size_t len = sizeof boot_sector;",
"if (!f) {",
"fprintf(stderr, \"Couldn't open \\\"%s\\\": %s\", VAR_0, strerror(errno));",
"return 1;",
"}",
"if (strcmp(qtest_get_arch(), \"ppc64\") == 0) {",
"len = sprintf((char *)boot_sector, \"\\\\ Bootscript\\n%x %x c! %x %x c!\\n\",\nLOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET,\nHIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);",
"}",
"fwrite(boot_sector, 1, len, f);",
"fclose(f);",
"return 0;",
"}"
] | [
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25,
27,
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
22,803 | static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
AVIContext *avi = s->priv_data;
AVStream *st;
int i, index;
int64_t pos, pos_min;
AVIStream *ast;
if (!avi->index_loaded) {
/* we only load the index on demand */
avi_load_index(s);
avi->index_loaded = 1;
}
assert(stream_index>= 0);
st = s->streams[stream_index];
ast= st->priv_data;
index= av_index_search_timestamp(st, timestamp * FFMAX(ast->sample_size, 1), flags);
if(index<0)
return -1;
/* find the position */
pos = st->index_entries[index].pos;
timestamp = st->index_entries[index].timestamp / FFMAX(ast->sample_size, 1);
// av_log(s, AV_LOG_DEBUG, "XX %"PRId64" %d %"PRId64"\n", timestamp, index, st->index_entries[index].timestamp);
if (CONFIG_DV_DEMUXER && avi->dv_demux) {
/* One and only one real stream for DV in AVI, and it has video */
/* offsets. Calling with other stream indexes should have failed */
/* the av_index_search_timestamp call above. */
assert(stream_index == 0);
/* Feed the DV video stream version of the timestamp to the */
/* DV demux so it can synthesize correct timestamps. */
dv_offset_reset(avi->dv_demux, timestamp);
avio_seek(s->pb, pos, SEEK_SET);
avi->stream_index= -1;
return 0;
}
pos_min= pos;
for(i = 0; i < s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
AVIStream *ast2 = st2->priv_data;
ast2->packet_size=
ast2->remaining= 0;
if (ast2->sub_ctx) {
seek_subtitle(st, st2, timestamp);
continue;
}
if (st2->nb_index_entries <= 0)
continue;
// assert(st2->codec->block_align);
assert((int64_t)st2->time_base.num*ast2->rate == (int64_t)st2->time_base.den*ast2->scale);
index = av_index_search_timestamp(
st2,
av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
flags | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if(index<0)
index=0;
ast2->seek_pos= st2->index_entries[index].pos;
pos_min= FFMIN(pos_min,ast2->seek_pos);
}
for(i = 0; i < s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
AVIStream *ast2 = st2->priv_data;
if (ast2->sub_ctx || st2->nb_index_entries <= 0)
continue;
index = av_index_search_timestamp(
st2,
av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
flags | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if(index<0)
index=0;
while(!avi->non_interleaved && index>0 && st2->index_entries[index-1].pos >= pos_min)
index--;
ast2->frame_offset = st2->index_entries[index].timestamp;
}
/* do the seek */
avio_seek(s->pb, pos_min, SEEK_SET);
avi->stream_index= -1;
avi->dts_max= INT_MIN;
return 0;
}
| true | FFmpeg | f9e083a156f19094cb6fcd134c1ca4ca899a1a6d | static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
AVIContext *avi = s->priv_data;
AVStream *st;
int i, index;
int64_t pos, pos_min;
AVIStream *ast;
if (!avi->index_loaded) {
avi_load_index(s);
avi->index_loaded = 1;
}
assert(stream_index>= 0);
st = s->streams[stream_index];
ast= st->priv_data;
index= av_index_search_timestamp(st, timestamp * FFMAX(ast->sample_size, 1), flags);
if(index<0)
return -1;
pos = st->index_entries[index].pos;
timestamp = st->index_entries[index].timestamp / FFMAX(ast->sample_size, 1);
if (CONFIG_DV_DEMUXER && avi->dv_demux) {
assert(stream_index == 0);
dv_offset_reset(avi->dv_demux, timestamp);
avio_seek(s->pb, pos, SEEK_SET);
avi->stream_index= -1;
return 0;
}
pos_min= pos;
for(i = 0; i < s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
AVIStream *ast2 = st2->priv_data;
ast2->packet_size=
ast2->remaining= 0;
if (ast2->sub_ctx) {
seek_subtitle(st, st2, timestamp);
continue;
}
if (st2->nb_index_entries <= 0)
continue;
assert((int64_t)st2->time_base.num*ast2->rate == (int64_t)st2->time_base.den*ast2->scale);
index = av_index_search_timestamp(
st2,
av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
flags | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if(index<0)
index=0;
ast2->seek_pos= st2->index_entries[index].pos;
pos_min= FFMIN(pos_min,ast2->seek_pos);
}
for(i = 0; i < s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
AVIStream *ast2 = st2->priv_data;
if (ast2->sub_ctx || st2->nb_index_entries <= 0)
continue;
index = av_index_search_timestamp(
st2,
av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
flags | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if(index<0)
index=0;
while(!avi->non_interleaved && index>0 && st2->index_entries[index-1].pos >= pos_min)
index--;
ast2->frame_offset = st2->index_entries[index].timestamp;
}
avio_seek(s->pb, pos_min, SEEK_SET);
avi->stream_index= -1;
avi->dts_max= INT_MIN;
return 0;
}
| {
"code": [
" avio_seek(s->pb, pos, SEEK_SET);",
" avio_seek(s->pb, pos_min, SEEK_SET);"
],
"line_no": [
75,
177
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)
{
AVIContext *avi = VAR_0->priv_data;
AVStream *st;
int VAR_4, VAR_5;
int64_t pos, pos_min;
AVIStream *ast;
if (!avi->index_loaded) {
avi_load_index(VAR_0);
avi->index_loaded = 1;
}
assert(VAR_1>= 0);
st = VAR_0->streams[VAR_1];
ast= st->priv_data;
VAR_5= av_index_search_timestamp(st, VAR_2 * FFMAX(ast->sample_size, 1), VAR_3);
if(VAR_5<0)
return -1;
pos = st->index_entries[VAR_5].pos;
VAR_2 = st->index_entries[VAR_5].VAR_2 / FFMAX(ast->sample_size, 1);
if (CONFIG_DV_DEMUXER && avi->dv_demux) {
assert(VAR_1 == 0);
dv_offset_reset(avi->dv_demux, VAR_2);
avio_seek(VAR_0->pb, pos, SEEK_SET);
avi->VAR_1= -1;
return 0;
}
pos_min= pos;
for(VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
AVStream *st2 = VAR_0->streams[VAR_4];
AVIStream *ast2 = st2->priv_data;
ast2->packet_size=
ast2->remaining= 0;
if (ast2->sub_ctx) {
seek_subtitle(st, st2, VAR_2);
continue;
}
if (st2->nb_index_entries <= 0)
continue;
assert((int64_t)st2->time_base.num*ast2->rate == (int64_t)st2->time_base.den*ast2->scale);
VAR_5 = av_index_search_timestamp(
st2,
av_rescale_q(VAR_2, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
VAR_3 | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if(VAR_5<0)
VAR_5=0;
ast2->seek_pos= st2->index_entries[VAR_5].pos;
pos_min= FFMIN(pos_min,ast2->seek_pos);
}
for(VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
AVStream *st2 = VAR_0->streams[VAR_4];
AVIStream *ast2 = st2->priv_data;
if (ast2->sub_ctx || st2->nb_index_entries <= 0)
continue;
VAR_5 = av_index_search_timestamp(
st2,
av_rescale_q(VAR_2, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
VAR_3 | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if(VAR_5<0)
VAR_5=0;
while(!avi->non_interleaved && VAR_5>0 && st2->index_entries[VAR_5-1].pos >= pos_min)
VAR_5--;
ast2->frame_offset = st2->index_entries[VAR_5].VAR_2;
}
avio_seek(VAR_0->pb, pos_min, SEEK_SET);
avi->VAR_1= -1;
avi->dts_max= INT_MIN;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)\n{",
"AVIContext *avi = VAR_0->priv_data;",
"AVStream *st;",
"int VAR_4, VAR_5;",
"int64_t pos, pos_min;",
"AVIStream *ast;",
"if (!avi->index_loaded) {",
"avi_load_index(VAR_0);",
"avi->index_loaded = 1;",
"}",
"assert(VAR_1>= 0);",
"st = VAR_0->streams[VAR_1];",
"ast= st->priv_data;",
"VAR_5= av_index_search_timestamp(st, VAR_2 * FFMAX(ast->sample_size, 1), VAR_3);",
"if(VAR_5<0)\nreturn -1;",
"pos = st->index_entries[VAR_5].pos;",
"VAR_2 = st->index_entries[VAR_5].VAR_2 / FFMAX(ast->sample_size, 1);",
"if (CONFIG_DV_DEMUXER && avi->dv_demux) {",
"assert(VAR_1 == 0);",
"dv_offset_reset(avi->dv_demux, VAR_2);",
"avio_seek(VAR_0->pb, pos, SEEK_SET);",
"avi->VAR_1= -1;",
"return 0;",
"}",
"pos_min= pos;",
"for(VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"AVStream *st2 = VAR_0->streams[VAR_4];",
"AVIStream *ast2 = st2->priv_data;",
"ast2->packet_size=\nast2->remaining= 0;",
"if (ast2->sub_ctx) {",
"seek_subtitle(st, st2, VAR_2);",
"continue;",
"}",
"if (st2->nb_index_entries <= 0)\ncontinue;",
"assert((int64_t)st2->time_base.num*ast2->rate == (int64_t)st2->time_base.den*ast2->scale);",
"VAR_5 = av_index_search_timestamp(\nst2,\nav_rescale_q(VAR_2, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),\nVAR_3 | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));",
"if(VAR_5<0)\nVAR_5=0;",
"ast2->seek_pos= st2->index_entries[VAR_5].pos;",
"pos_min= FFMIN(pos_min,ast2->seek_pos);",
"}",
"for(VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"AVStream *st2 = VAR_0->streams[VAR_4];",
"AVIStream *ast2 = st2->priv_data;",
"if (ast2->sub_ctx || st2->nb_index_entries <= 0)\ncontinue;",
"VAR_5 = av_index_search_timestamp(\nst2,\nav_rescale_q(VAR_2, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),\nVAR_3 | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));",
"if(VAR_5<0)\nVAR_5=0;",
"while(!avi->non_interleaved && VAR_5>0 && st2->index_entries[VAR_5-1].pos >= pos_min)\nVAR_5--;",
"ast2->frame_offset = st2->index_entries[VAR_5].VAR_2;",
"}",
"avio_seek(VAR_0->pb, pos_min, SEEK_SET);",
"avi->VAR_1= -1;",
"avi->dts_max= INT_MIN;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
45
],
[
47
],
[
55
],
[
63
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95,
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111,
113
],
[
119
],
[
121,
123,
125,
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147,
149
],
[
153,
155,
157,
159
],
[
161,
163
],
[
165,
167
],
[
169
],
[
171
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
]
] |
22,804 | static void timer_enable(struct xlx_timer *xt)
{
uint64_t count;
D(printf("%s timer=%d down=%d\n", __func__,
xt->nr, xt->regs[R_TCSR] & TCSR_UDT));
ptimer_stop(xt->ptimer);
if (xt->regs[R_TCSR] & TCSR_UDT)
count = xt->regs[R_TLR];
else
count = ~0 - xt->regs[R_TLR];
ptimer_set_count(xt->ptimer, count);
ptimer_run(xt->ptimer, 1);
}
| true | qemu | 7798a8828a654ce438584bdfccaa3e8a120cf998 | static void timer_enable(struct xlx_timer *xt)
{
uint64_t count;
D(printf("%s timer=%d down=%d\n", __func__,
xt->nr, xt->regs[R_TCSR] & TCSR_UDT));
ptimer_stop(xt->ptimer);
if (xt->regs[R_TCSR] & TCSR_UDT)
count = xt->regs[R_TLR];
else
count = ~0 - xt->regs[R_TLR];
ptimer_set_count(xt->ptimer, count);
ptimer_run(xt->ptimer, 1);
}
| {
"code": [
" ptimer_set_count(xt->ptimer, count);"
],
"line_no": [
27
]
} | static void FUNC_0(struct xlx_timer *VAR_0)
{
uint64_t count;
D(printf("%s timer=%d down=%d\n", __func__,
VAR_0->nr, VAR_0->regs[R_TCSR] & TCSR_UDT));
ptimer_stop(VAR_0->ptimer);
if (VAR_0->regs[R_TCSR] & TCSR_UDT)
count = VAR_0->regs[R_TLR];
else
count = ~0 - VAR_0->regs[R_TLR];
ptimer_set_count(VAR_0->ptimer, count);
ptimer_run(VAR_0->ptimer, 1);
}
| [
"static void FUNC_0(struct xlx_timer *VAR_0)\n{",
"uint64_t count;",
"D(printf(\"%s timer=%d down=%d\\n\", __func__,\nVAR_0->nr, VAR_0->regs[R_TCSR] & TCSR_UDT));",
"ptimer_stop(VAR_0->ptimer);",
"if (VAR_0->regs[R_TCSR] & TCSR_UDT)\ncount = VAR_0->regs[R_TLR];",
"else\ncount = ~0 - VAR_0->regs[R_TLR];",
"ptimer_set_count(VAR_0->ptimer, count);",
"ptimer_run(VAR_0->ptimer, 1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
19,
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
]
] |
22,805 | static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
{
struct tcphdr *ptcp, *stcp;
int res;
trace_colo_compare_main("compare tcp");
ptcp = (struct tcphdr *)ppkt->transport_header;
stcp = (struct tcphdr *)spkt->transport_header;
/*
* The 'identification' field in the IP header is *very* random
* it almost never matches. Fudge this by ignoring differences in
* unfragmented packets; they'll normally sort themselves out if different
* anyway, and it should recover at the TCP level.
* An alternative would be to get both the primary and secondary to rewrite
* somehow; but that would need some sync traffic to sync the state
*/
if (ntohs(ppkt->ip->ip_off) & IP_DF) {
spkt->ip->ip_id = ppkt->ip->ip_id;
/* and the sum will be different if the IDs were different */
spkt->ip->ip_sum = ppkt->ip->ip_sum;
}
/*
* Check tcp header length for tcp option field.
* th_off > 5 means this tcp packet have options field.
* The tcp options maybe always different.
* for example:
* From RFC 7323.
* TCP Timestamps option (TSopt):
* Kind: 8
*
* Length: 10 bytes
*
* +-------+-------+---------------------+---------------------+
* |Kind=8 | 10 | TS Value (TSval) |TS Echo Reply (TSecr)|
* +-------+-------+---------------------+---------------------+
* 1 1 4 4
*
* In this case the primary guest's timestamp always different with
* the secondary guest's timestamp. COLO just focus on payload,
* so we just need skip this field.
*/
if (ptcp->th_off > 5) {
ptrdiff_t tcp_offset;
tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data
+ (ptcp->th_off * 4) - ppkt->vnet_hdr_len;
res = colo_packet_compare_common(ppkt, spkt, tcp_offset);
} else if (ptcp->th_sum == stcp->th_sum) {
res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);
} else {
res = -1;
}
if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst));
strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src));
strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst));
trace_colo_compare_ip_info(ppkt->size, pri_ip_src,
pri_ip_dst, spkt->size,
sec_ip_src, sec_ip_dst);
trace_colo_compare_tcp_info("pri tcp packet",
ntohl(ptcp->th_seq),
ntohl(ptcp->th_ack),
res, ptcp->th_flags,
ppkt->size);
trace_colo_compare_tcp_info("sec tcp packet",
ntohl(stcp->th_seq),
ntohl(stcp->th_ack),
res, stcp->th_flags,
spkt->size);
qemu_hexdump((char *)ppkt->data, stderr,
"colo-compare ppkt", ppkt->size);
qemu_hexdump((char *)spkt->data, stderr,
"colo-compare spkt", spkt->size);
}
return res;
}
| true | qemu | d87aa138039a4be6d705793fd3e397c69c52405a | static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
{
struct tcphdr *ptcp, *stcp;
int res;
trace_colo_compare_main("compare tcp");
ptcp = (struct tcphdr *)ppkt->transport_header;
stcp = (struct tcphdr *)spkt->transport_header;
if (ntohs(ppkt->ip->ip_off) & IP_DF) {
spkt->ip->ip_id = ppkt->ip->ip_id;
spkt->ip->ip_sum = ppkt->ip->ip_sum;
}
if (ptcp->th_off > 5) {
ptrdiff_t tcp_offset;
tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data
+ (ptcp->th_off * 4) - ppkt->vnet_hdr_len;
res = colo_packet_compare_common(ppkt, spkt, tcp_offset);
} else if (ptcp->th_sum == stcp->th_sum) {
res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);
} else {
res = -1;
}
if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst));
strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src));
strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst));
trace_colo_compare_ip_info(ppkt->size, pri_ip_src,
pri_ip_dst, spkt->size,
sec_ip_src, sec_ip_dst);
trace_colo_compare_tcp_info("pri tcp packet",
ntohl(ptcp->th_seq),
ntohl(ptcp->th_ack),
res, ptcp->th_flags,
ppkt->size);
trace_colo_compare_tcp_info("sec tcp packet",
ntohl(stcp->th_seq),
ntohl(stcp->th_ack),
res, stcp->th_flags,
spkt->size);
qemu_hexdump((char *)ppkt->data, stderr,
"colo-compare ppkt", ppkt->size);
qemu_hexdump((char *)spkt->data, stderr,
"colo-compare spkt", spkt->size);
}
return res;
}
| {
"code": [
" if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {"
],
"line_no": [
113
]
} | static int FUNC_0(Packet *VAR_0, Packet *VAR_1)
{
struct tcphdr *VAR_2, *VAR_3;
int VAR_4;
trace_colo_compare_main("compare tcp");
VAR_2 = (struct tcphdr *)VAR_1->transport_header;
VAR_3 = (struct tcphdr *)VAR_0->transport_header;
if (ntohs(VAR_1->ip->ip_off) & IP_DF) {
VAR_0->ip->ip_id = VAR_1->ip->ip_id;
VAR_0->ip->ip_sum = VAR_1->ip->ip_sum;
}
if (VAR_2->th_off > 5) {
ptrdiff_t tcp_offset;
tcp_offset = VAR_1->transport_header - (uint8_t *)VAR_1->data
+ (VAR_2->th_off * 4) - VAR_1->vnet_hdr_len;
VAR_4 = colo_packet_compare_common(VAR_1, VAR_0, tcp_offset);
} else if (VAR_2->th_sum == VAR_3->th_sum) {
VAR_4 = colo_packet_compare_common(VAR_1, VAR_0, ETH_HLEN);
} else {
VAR_4 = -1;
}
if (VAR_4 != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
char VAR_5[20], VAR_6[20], VAR_7[20], VAR_8[20];
strcpy(VAR_5, inet_ntoa(VAR_1->ip->ip_src));
strcpy(VAR_6, inet_ntoa(VAR_1->ip->ip_dst));
strcpy(VAR_7, inet_ntoa(VAR_0->ip->ip_src));
strcpy(VAR_8, inet_ntoa(VAR_0->ip->ip_dst));
trace_colo_compare_ip_info(VAR_1->size, VAR_5,
VAR_6, VAR_0->size,
VAR_7, VAR_8);
trace_colo_compare_tcp_info("pri tcp packet",
ntohl(VAR_2->th_seq),
ntohl(VAR_2->th_ack),
VAR_4, VAR_2->th_flags,
VAR_1->size);
trace_colo_compare_tcp_info("sec tcp packet",
ntohl(VAR_3->th_seq),
ntohl(VAR_3->th_ack),
VAR_4, VAR_3->th_flags,
VAR_0->size);
qemu_hexdump((char *)VAR_1->data, stderr,
"colo-compare VAR_1", VAR_1->size);
qemu_hexdump((char *)VAR_0->data, stderr,
"colo-compare VAR_0", VAR_0->size);
}
return VAR_4;
}
| [
"static int FUNC_0(Packet *VAR_0, Packet *VAR_1)\n{",
"struct tcphdr *VAR_2, *VAR_3;",
"int VAR_4;",
"trace_colo_compare_main(\"compare tcp\");",
"VAR_2 = (struct tcphdr *)VAR_1->transport_header;",
"VAR_3 = (struct tcphdr *)VAR_0->transport_header;",
"if (ntohs(VAR_1->ip->ip_off) & IP_DF) {",
"VAR_0->ip->ip_id = VAR_1->ip->ip_id;",
"VAR_0->ip->ip_sum = VAR_1->ip->ip_sum;",
"}",
"if (VAR_2->th_off > 5) {",
"ptrdiff_t tcp_offset;",
"tcp_offset = VAR_1->transport_header - (uint8_t *)VAR_1->data\n+ (VAR_2->th_off * 4) - VAR_1->vnet_hdr_len;",
"VAR_4 = colo_packet_compare_common(VAR_1, VAR_0, tcp_offset);",
"} else if (VAR_2->th_sum == VAR_3->th_sum) {",
"VAR_4 = colo_packet_compare_common(VAR_1, VAR_0, ETH_HLEN);",
"} else {",
"VAR_4 = -1;",
"}",
"if (VAR_4 != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {",
"char VAR_5[20], VAR_6[20], VAR_7[20], VAR_8[20];",
"strcpy(VAR_5, inet_ntoa(VAR_1->ip->ip_src));",
"strcpy(VAR_6, inet_ntoa(VAR_1->ip->ip_dst));",
"strcpy(VAR_7, inet_ntoa(VAR_0->ip->ip_src));",
"strcpy(VAR_8, inet_ntoa(VAR_0->ip->ip_dst));",
"trace_colo_compare_ip_info(VAR_1->size, VAR_5,\nVAR_6, VAR_0->size,\nVAR_7, VAR_8);",
"trace_colo_compare_tcp_info(\"pri tcp packet\",\nntohl(VAR_2->th_seq),\nntohl(VAR_2->th_ack),\nVAR_4, VAR_2->th_flags,\nVAR_1->size);",
"trace_colo_compare_tcp_info(\"sec tcp packet\",\nntohl(VAR_3->th_seq),\nntohl(VAR_3->th_ack),\nVAR_4, VAR_3->th_flags,\nVAR_0->size);",
"qemu_hexdump((char *)VAR_1->data, stderr,\n\"colo-compare VAR_1\", VAR_1->size);",
"qemu_hexdump((char *)VAR_0->data, stderr,\n\"colo-compare VAR_0\", VAR_0->size);",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
37
],
[
39
],
[
43
],
[
45
],
[
89
],
[
91
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129,
131,
133
],
[
137,
139,
141,
143,
145
],
[
149,
151,
153,
155,
157
],
[
161,
163
],
[
165,
167
],
[
169
],
[
173
],
[
175
]
] |
22,806 | static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
uint32_t frame_size;
int ret, first = 1;
if (avio_feof(pb))
return AVERROR_EOF;
if (av_get_packet(pb, pkt, 12) != 12)
return AVERROR(EIO);
while (!avio_feof(pb)) {
if (!first) {
ret = av_append_packet(pb, pkt, 12);
if (ret < 0) {
return ret;
}
} else
first = 0;
frame_size = AV_RL32(pkt->data + pkt->size - 8);
if (frame_size > INT_MAX - 4) {
av_log(s, AV_LOG_ERROR, "Too large chunk size: %"PRIu32"\n", frame_size);
return AVERROR(EIO);
}
if (AV_RL32(pkt->data + pkt->size - 12) == MKTAG('E', 'O', 'F', 'R')) {
if (frame_size) {
av_log(s, AV_LOG_WARNING,
"skipping %"PRIu32" bytes of end-of-frame marker chunk\n",
frame_size);
avio_skip(pb, frame_size);
}
return 0;
}
ret = av_append_packet(pb, pkt, frame_size);
if (ret < 0) {
return ret;
}
}
return 0;
} | true | FFmpeg | c71999ef97b7cc8b1cb6eaf39e72e9ecbf825d9e | static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
uint32_t frame_size;
int ret, first = 1;
if (avio_feof(pb))
return AVERROR_EOF;
if (av_get_packet(pb, pkt, 12) != 12)
return AVERROR(EIO);
while (!avio_feof(pb)) {
if (!first) {
ret = av_append_packet(pb, pkt, 12);
if (ret < 0) {
return ret;
}
} else
first = 0;
frame_size = AV_RL32(pkt->data + pkt->size - 8);
if (frame_size > INT_MAX - 4) {
av_log(s, AV_LOG_ERROR, "Too large chunk size: %"PRIu32"\n", frame_size);
return AVERROR(EIO);
}
if (AV_RL32(pkt->data + pkt->size - 12) == MKTAG('E', 'O', 'F', 'R')) {
if (frame_size) {
av_log(s, AV_LOG_WARNING,
"skipping %"PRIu32" bytes of end-of-frame marker chunk\n",
frame_size);
avio_skip(pb, frame_size);
}
return 0;
}
ret = av_append_packet(pb, pkt, frame_size);
if (ret < 0) {
return ret;
}
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
AVIOContext *pb = VAR_0->pb;
uint32_t frame_size;
int VAR_2, VAR_3 = 1;
if (avio_feof(pb))
return AVERROR_EOF;
if (av_get_packet(pb, VAR_1, 12) != 12)
return AVERROR(EIO);
while (!avio_feof(pb)) {
if (!VAR_3) {
VAR_2 = av_append_packet(pb, VAR_1, 12);
if (VAR_2 < 0) {
return VAR_2;
}
} else
VAR_3 = 0;
frame_size = AV_RL32(VAR_1->data + VAR_1->size - 8);
if (frame_size > INT_MAX - 4) {
av_log(VAR_0, AV_LOG_ERROR, "Too large chunk size: %"PRIu32"\n", frame_size);
return AVERROR(EIO);
}
if (AV_RL32(VAR_1->data + VAR_1->size - 12) == MKTAG('E', 'O', 'F', 'R')) {
if (frame_size) {
av_log(VAR_0, AV_LOG_WARNING,
"skipping %"PRIu32" bytes of end-of-frame marker chunk\n",
frame_size);
avio_skip(pb, frame_size);
}
return 0;
}
VAR_2 = av_append_packet(pb, VAR_1, frame_size);
if (VAR_2 < 0) {
return VAR_2;
}
}
return 0;
} | [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"AVIOContext *pb = VAR_0->pb;",
"uint32_t frame_size;",
"int VAR_2, VAR_3 = 1;",
"if (avio_feof(pb))\nreturn AVERROR_EOF;",
"if (av_get_packet(pb, VAR_1, 12) != 12)\nreturn AVERROR(EIO);",
"while (!avio_feof(pb)) {",
"if (!VAR_3) {",
"VAR_2 = av_append_packet(pb, VAR_1, 12);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"} else",
"VAR_3 = 0;",
"frame_size = AV_RL32(VAR_1->data + VAR_1->size - 8);",
"if (frame_size > INT_MAX - 4) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Too large chunk size: %\"PRIu32\"\\n\", frame_size);",
"return AVERROR(EIO);",
"}",
"if (AV_RL32(VAR_1->data + VAR_1->size - 12) == MKTAG('E', 'O', 'F', 'R')) {",
"if (frame_size) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"skipping %\"PRIu32\" bytes of end-of-frame marker chunk\\n\",\nframe_size);",
"avio_skip(pb, frame_size);",
"}",
"return 0;",
"}",
"VAR_2 = av_append_packet(pb, VAR_1, frame_size);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
32
],
[
34
],
[
36
],
[
38
],
[
40
],
[
42
],
[
44
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
74
],
[
76
],
[
78
],
[
82
],
[
84
]
] |
22,807 | static int nut_read_close(AVFormatContext *s)
{
NUTContext *nut = s->priv_data;
av_freep(&nut->time_base);
av_freep(&nut->stream);
return 0;
} | true | FFmpeg | 27dbc47c05e07486feba1ab829db584da2159648 | static int nut_read_close(AVFormatContext *s)
{
NUTContext *nut = s->priv_data;
av_freep(&nut->time_base);
av_freep(&nut->stream);
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
NUTContext *nut = VAR_0->priv_data;
av_freep(&nut->time_base);
av_freep(&nut->stream);
return 0;
} | [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"NUTContext *nut = VAR_0->priv_data;",
"av_freep(&nut->time_base);",
"av_freep(&nut->stream);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
10
],
[
12
],
[
19
],
[
21
]
] |
22,808 | static int64_t pva_read_timestamp(struct AVFormatContext *s, int stream_index,
int64_t *pos, int64_t pos_limit) {
ByteIOContext *pb = s->pb;
PVAContext *pvactx = s->priv_data;
int length, streamid;
int64_t res;
pos_limit = FFMIN(*pos+PVA_MAX_PAYLOAD_LENGTH*8, (uint64_t)*pos+pos_limit);
while (*pos < pos_limit) {
res = AV_NOPTS_VALUE;
url_fseek(pb, *pos, SEEK_SET);
pvactx->continue_pes = 0;
if (read_part_of_packet(s, &res, &length, &streamid, 0)) {
(*pos)++;
continue;
}
if (streamid - 1 != stream_index || res == AV_NOPTS_VALUE) {
*pos = url_ftell(pb) + length;
continue;
}
break;
}
pvactx->continue_pes = 0;
return res;
}
| true | FFmpeg | 896873b5648c1c6d379c35832e99d966fa56f87f | static int64_t pva_read_timestamp(struct AVFormatContext *s, int stream_index,
int64_t *pos, int64_t pos_limit) {
ByteIOContext *pb = s->pb;
PVAContext *pvactx = s->priv_data;
int length, streamid;
int64_t res;
pos_limit = FFMIN(*pos+PVA_MAX_PAYLOAD_LENGTH*8, (uint64_t)*pos+pos_limit);
while (*pos < pos_limit) {
res = AV_NOPTS_VALUE;
url_fseek(pb, *pos, SEEK_SET);
pvactx->continue_pes = 0;
if (read_part_of_packet(s, &res, &length, &streamid, 0)) {
(*pos)++;
continue;
}
if (streamid - 1 != stream_index || res == AV_NOPTS_VALUE) {
*pos = url_ftell(pb) + length;
continue;
}
break;
}
pvactx->continue_pes = 0;
return res;
}
| {
"code": [
" int64_t res;"
],
"line_no": [
11
]
} | static int64_t FUNC_0(struct AVFormatContext *s, int stream_index,
int64_t *pos, int64_t pos_limit) {
ByteIOContext *pb = s->pb;
PVAContext *pvactx = s->priv_data;
int VAR_0, VAR_1;
int64_t res;
pos_limit = FFMIN(*pos+PVA_MAX_PAYLOAD_LENGTH*8, (uint64_t)*pos+pos_limit);
while (*pos < pos_limit) {
res = AV_NOPTS_VALUE;
url_fseek(pb, *pos, SEEK_SET);
pvactx->continue_pes = 0;
if (read_part_of_packet(s, &res, &VAR_0, &VAR_1, 0)) {
(*pos)++;
continue;
}
if (VAR_1 - 1 != stream_index || res == AV_NOPTS_VALUE) {
*pos = url_ftell(pb) + VAR_0;
continue;
}
break;
}
pvactx->continue_pes = 0;
return res;
}
| [
"static int64_t FUNC_0(struct AVFormatContext *s, int stream_index,\nint64_t *pos, int64_t pos_limit) {",
"ByteIOContext *pb = s->pb;",
"PVAContext *pvactx = s->priv_data;",
"int VAR_0, VAR_1;",
"int64_t res;",
"pos_limit = FFMIN(*pos+PVA_MAX_PAYLOAD_LENGTH*8, (uint64_t)*pos+pos_limit);",
"while (*pos < pos_limit) {",
"res = AV_NOPTS_VALUE;",
"url_fseek(pb, *pos, SEEK_SET);",
"pvactx->continue_pes = 0;",
"if (read_part_of_packet(s, &res, &VAR_0, &VAR_1, 0)) {",
"(*pos)++;",
"continue;",
"}",
"if (VAR_1 - 1 != stream_index || res == AV_NOPTS_VALUE) {",
"*pos = url_ftell(pb) + VAR_0;",
"continue;",
"}",
"break;",
"}",
"pvactx->continue_pes = 0;",
"return res;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
]
] |
22,809 | static ssize_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb)
{
int ret;
ret = ioctl(aiocb->aio_fildes, aiocb->aio_ioctl_cmd, aiocb->aio_ioctl_buf);
if (ret == -1)
return -errno;
/*
* This looks weird, but the aio code only consideres a request
* successful if it has written the number full number of bytes.
*
* Now we overload aio_nbytes as aio_ioctl_cmd for the ioctl command,
* so in fact we return the ioctl command here to make posix_aio_read()
* happy..
*/
return aiocb->aio_nbytes;
}
| true | qemu | e7d81004e486b0e80a674d164d8aec0e83fa812f | static ssize_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb)
{
int ret;
ret = ioctl(aiocb->aio_fildes, aiocb->aio_ioctl_cmd, aiocb->aio_ioctl_buf);
if (ret == -1)
return -errno;
return aiocb->aio_nbytes;
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(struct qemu_paiocb *aiocb)
{
int VAR_0;
VAR_0 = ioctl(aiocb->aio_fildes, aiocb->aio_ioctl_cmd, aiocb->aio_ioctl_buf);
if (VAR_0 == -1)
return -errno;
return aiocb->aio_nbytes;
}
| [
"static ssize_t FUNC_0(struct qemu_paiocb *aiocb)\n{",
"int VAR_0;",
"VAR_0 = ioctl(aiocb->aio_fildes, aiocb->aio_ioctl_cmd, aiocb->aio_ioctl_buf);",
"if (VAR_0 == -1)\nreturn -errno;",
"return aiocb->aio_nbytes;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
33
],
[
35
]
] |
22,810 | static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
{
FrameRateContext *s = ctx->priv;
ThreadData *td = arg;
uint16_t src1_factor = td->src1_factor;
uint16_t src2_factor = td->src2_factor;
int plane;
for (plane = 0; plane < 4 && td->copy_src1->data[plane] && td->copy_src2->data[plane]; plane++) {
int cpy_line_width = s->line_size[plane];
uint8_t *cpy_src1_data = td->copy_src1->data[plane];
int cpy_src1_line_size = td->copy_src1->linesize[plane];
uint8_t *cpy_src2_data = td->copy_src2->data[plane];
int cpy_src2_line_size = td->copy_src2->linesize[plane];
int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);
uint8_t *cpy_dst_data = s->work->data[plane];
int cpy_dst_line_size = s->work->linesize[plane];
const int start = (cpy_src_h * job ) / nb_jobs;
const int end = (cpy_src_h * (job+1)) / nb_jobs;
cpy_src1_data += start * cpy_src1_line_size;
cpy_src2_data += start * cpy_src2_line_size;
cpy_dst_data += start * cpy_dst_line_size;
s->blend(cpy_src1_data, cpy_src1_line_size,
cpy_src2_data, cpy_src2_line_size,
cpy_dst_data, cpy_dst_line_size,
cpy_line_width, end - start,
src1_factor, src2_factor, s->max / 2, s->bitdepth);
}
return 0;
}
| true | FFmpeg | 2cbe6bac0337939f023bd1c37a9c455e6d535f3a | static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
{
FrameRateContext *s = ctx->priv;
ThreadData *td = arg;
uint16_t src1_factor = td->src1_factor;
uint16_t src2_factor = td->src2_factor;
int plane;
for (plane = 0; plane < 4 && td->copy_src1->data[plane] && td->copy_src2->data[plane]; plane++) {
int cpy_line_width = s->line_size[plane];
uint8_t *cpy_src1_data = td->copy_src1->data[plane];
int cpy_src1_line_size = td->copy_src1->linesize[plane];
uint8_t *cpy_src2_data = td->copy_src2->data[plane];
int cpy_src2_line_size = td->copy_src2->linesize[plane];
int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);
uint8_t *cpy_dst_data = s->work->data[plane];
int cpy_dst_line_size = s->work->linesize[plane];
const int start = (cpy_src_h * job ) / nb_jobs;
const int end = (cpy_src_h * (job+1)) / nb_jobs;
cpy_src1_data += start * cpy_src1_line_size;
cpy_src2_data += start * cpy_src2_line_size;
cpy_dst_data += start * cpy_dst_line_size;
s->blend(cpy_src1_data, cpy_src1_line_size,
cpy_src2_data, cpy_src2_line_size,
cpy_dst_data, cpy_dst_line_size,
cpy_line_width, end - start,
src1_factor, src2_factor, s->max / 2, s->bitdepth);
}
return 0;
}
| {
"code": [
" src1_factor, src2_factor, s->max / 2, s->bitdepth);"
],
"line_no": [
55
]
} | static int FUNC_0(AVFilterContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)
{
FrameRateContext *s = VAR_0->priv;
ThreadData *td = VAR_1;
uint16_t src1_factor = td->src1_factor;
uint16_t src2_factor = td->src2_factor;
int VAR_4;
for (VAR_4 = 0; VAR_4 < 4 && td->copy_src1->data[VAR_4] && td->copy_src2->data[VAR_4]; VAR_4++) {
int cpy_line_width = s->line_size[VAR_4];
uint8_t *cpy_src1_data = td->copy_src1->data[VAR_4];
int cpy_src1_line_size = td->copy_src1->linesize[VAR_4];
uint8_t *cpy_src2_data = td->copy_src2->data[VAR_4];
int cpy_src2_line_size = td->copy_src2->linesize[VAR_4];
int cpy_src_h = (VAR_4 > 0 && VAR_4 < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);
uint8_t *cpy_dst_data = s->work->data[VAR_4];
int cpy_dst_line_size = s->work->linesize[VAR_4];
const int start = (cpy_src_h * VAR_2 ) / VAR_3;
const int end = (cpy_src_h * (VAR_2+1)) / VAR_3;
cpy_src1_data += start * cpy_src1_line_size;
cpy_src2_data += start * cpy_src2_line_size;
cpy_dst_data += start * cpy_dst_line_size;
s->blend(cpy_src1_data, cpy_src1_line_size,
cpy_src2_data, cpy_src2_line_size,
cpy_dst_data, cpy_dst_line_size,
cpy_line_width, end - start,
src1_factor, src2_factor, s->max / 2, s->bitdepth);
}
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)\n{",
"FrameRateContext *s = VAR_0->priv;",
"ThreadData *td = VAR_1;",
"uint16_t src1_factor = td->src1_factor;",
"uint16_t src2_factor = td->src2_factor;",
"int VAR_4;",
"for (VAR_4 = 0; VAR_4 < 4 && td->copy_src1->data[VAR_4] && td->copy_src2->data[VAR_4]; VAR_4++) {",
"int cpy_line_width = s->line_size[VAR_4];",
"uint8_t *cpy_src1_data = td->copy_src1->data[VAR_4];",
"int cpy_src1_line_size = td->copy_src1->linesize[VAR_4];",
"uint8_t *cpy_src2_data = td->copy_src2->data[VAR_4];",
"int cpy_src2_line_size = td->copy_src2->linesize[VAR_4];",
"int cpy_src_h = (VAR_4 > 0 && VAR_4 < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);",
"uint8_t *cpy_dst_data = s->work->data[VAR_4];",
"int cpy_dst_line_size = s->work->linesize[VAR_4];",
"const int start = (cpy_src_h * VAR_2 ) / VAR_3;",
"const int end = (cpy_src_h * (VAR_2+1)) / VAR_3;",
"cpy_src1_data += start * cpy_src1_line_size;",
"cpy_src2_data += start * cpy_src2_line_size;",
"cpy_dst_data += start * cpy_dst_line_size;",
"s->blend(cpy_src1_data, cpy_src1_line_size,\ncpy_src2_data, cpy_src2_line_size,\ncpy_dst_data, cpy_dst_line_size,\ncpy_line_width, end - start,\nsrc1_factor, src2_factor, s->max / 2, s->bitdepth);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49,
51,
53,
55
],
[
57
],
[
61
],
[
63
]
] |
22,812 | static void update_initial_timestamps(AVFormatContext *s, int stream_index,
int64_t dts, int64_t pts, AVPacket *pkt)
{
AVStream *st = s->streams[stream_index];
AVPacketList *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue;
int64_t pts_buffer[MAX_REORDER_DELAY+1];
int64_t shift;
int i, delay;
if (st->first_dts != AV_NOPTS_VALUE ||
dts == AV_NOPTS_VALUE ||
st->cur_dts == AV_NOPTS_VALUE ||
is_relative(dts))
return;
delay = st->codec->has_b_frames;
st->first_dts = dts - (st->cur_dts - RELATIVE_TS_BASE);
st->cur_dts = dts;
shift = st->first_dts - RELATIVE_TS_BASE;
for (i = 0; i<MAX_REORDER_DELAY+1; i++)
pts_buffer[i] = AV_NOPTS_VALUE;
if (is_relative(pts))
pts += shift;
for (; pktl; pktl = get_next_pkt(s, st, pktl)) {
if (pktl->pkt.stream_index != stream_index)
continue;
if (is_relative(pktl->pkt.pts))
pktl->pkt.pts += shift;
if (is_relative(pktl->pkt.dts))
pktl->pkt.dts += shift;
if (st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != AV_NOPTS_VALUE)
st->start_time = pktl->pkt.pts;
if (pktl->pkt.pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY && has_decode_delay_been_guessed(st)) {
pts_buffer[0] = pktl->pkt.pts;
for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
pktl->pkt.dts = select_from_pts_buffer(st, pts_buffer, pktl->pkt.dts);
}
}
if (st->start_time == AV_NOPTS_VALUE)
st->start_time = pts;
}
| true | FFmpeg | cafb19560401612a07760d230a50d9c1d0564daf | static void update_initial_timestamps(AVFormatContext *s, int stream_index,
int64_t dts, int64_t pts, AVPacket *pkt)
{
AVStream *st = s->streams[stream_index];
AVPacketList *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue;
int64_t pts_buffer[MAX_REORDER_DELAY+1];
int64_t shift;
int i, delay;
if (st->first_dts != AV_NOPTS_VALUE ||
dts == AV_NOPTS_VALUE ||
st->cur_dts == AV_NOPTS_VALUE ||
is_relative(dts))
return;
delay = st->codec->has_b_frames;
st->first_dts = dts - (st->cur_dts - RELATIVE_TS_BASE);
st->cur_dts = dts;
shift = st->first_dts - RELATIVE_TS_BASE;
for (i = 0; i<MAX_REORDER_DELAY+1; i++)
pts_buffer[i] = AV_NOPTS_VALUE;
if (is_relative(pts))
pts += shift;
for (; pktl; pktl = get_next_pkt(s, st, pktl)) {
if (pktl->pkt.stream_index != stream_index)
continue;
if (is_relative(pktl->pkt.pts))
pktl->pkt.pts += shift;
if (is_relative(pktl->pkt.dts))
pktl->pkt.dts += shift;
if (st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != AV_NOPTS_VALUE)
st->start_time = pktl->pkt.pts;
if (pktl->pkt.pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY && has_decode_delay_been_guessed(st)) {
pts_buffer[0] = pktl->pkt.pts;
for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
pktl->pkt.dts = select_from_pts_buffer(st, pts_buffer, pktl->pkt.dts);
}
}
if (st->start_time == AV_NOPTS_VALUE)
st->start_time = pts;
}
| {
"code": [
" int64_t shift;",
" shift = st->first_dts - RELATIVE_TS_BASE;"
],
"line_no": [
13,
37
]
} | static void FUNC_0(AVFormatContext *VAR_0, int VAR_1,
int64_t VAR_2, int64_t VAR_3, AVPacket *VAR_4)
{
AVStream *st = VAR_0->streams[VAR_1];
AVPacketList *pktl = VAR_0->internal->packet_buffer ? VAR_0->internal->packet_buffer : VAR_0->internal->parse_queue;
int64_t pts_buffer[MAX_REORDER_DELAY+1];
int64_t shift;
int VAR_5, VAR_6;
if (st->first_dts != AV_NOPTS_VALUE ||
VAR_2 == AV_NOPTS_VALUE ||
st->cur_dts == AV_NOPTS_VALUE ||
is_relative(VAR_2))
return;
VAR_6 = st->codec->has_b_frames;
st->first_dts = VAR_2 - (st->cur_dts - RELATIVE_TS_BASE);
st->cur_dts = VAR_2;
shift = st->first_dts - RELATIVE_TS_BASE;
for (VAR_5 = 0; VAR_5<MAX_REORDER_DELAY+1; VAR_5++)
pts_buffer[VAR_5] = AV_NOPTS_VALUE;
if (is_relative(VAR_3))
VAR_3 += shift;
for (; pktl; pktl = get_next_pkt(VAR_0, st, pktl)) {
if (pktl->VAR_4.VAR_1 != VAR_1)
continue;
if (is_relative(pktl->VAR_4.VAR_3))
pktl->VAR_4.VAR_3 += shift;
if (is_relative(pktl->VAR_4.VAR_2))
pktl->VAR_4.VAR_2 += shift;
if (st->start_time == AV_NOPTS_VALUE && pktl->VAR_4.VAR_3 != AV_NOPTS_VALUE)
st->start_time = pktl->VAR_4.VAR_3;
if (pktl->VAR_4.VAR_3 != AV_NOPTS_VALUE && VAR_6 <= MAX_REORDER_DELAY && has_decode_delay_been_guessed(st)) {
pts_buffer[0] = pktl->VAR_4.VAR_3;
for (VAR_5 = 0; VAR_5<VAR_6 && pts_buffer[VAR_5] > pts_buffer[VAR_5 + 1]; VAR_5++)
FFSWAP(int64_t, pts_buffer[VAR_5], pts_buffer[VAR_5 + 1]);
pktl->VAR_4.VAR_2 = select_from_pts_buffer(st, pts_buffer, pktl->VAR_4.VAR_2);
}
}
if (st->start_time == AV_NOPTS_VALUE)
st->start_time = VAR_3;
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nint64_t VAR_2, int64_t VAR_3, AVPacket *VAR_4)\n{",
"AVStream *st = VAR_0->streams[VAR_1];",
"AVPacketList *pktl = VAR_0->internal->packet_buffer ? VAR_0->internal->packet_buffer : VAR_0->internal->parse_queue;",
"int64_t pts_buffer[MAX_REORDER_DELAY+1];",
"int64_t shift;",
"int VAR_5, VAR_6;",
"if (st->first_dts != AV_NOPTS_VALUE ||\nVAR_2 == AV_NOPTS_VALUE ||\nst->cur_dts == AV_NOPTS_VALUE ||\nis_relative(VAR_2))\nreturn;",
"VAR_6 = st->codec->has_b_frames;",
"st->first_dts = VAR_2 - (st->cur_dts - RELATIVE_TS_BASE);",
"st->cur_dts = VAR_2;",
"shift = st->first_dts - RELATIVE_TS_BASE;",
"for (VAR_5 = 0; VAR_5<MAX_REORDER_DELAY+1; VAR_5++)",
"pts_buffer[VAR_5] = AV_NOPTS_VALUE;",
"if (is_relative(VAR_3))\nVAR_3 += shift;",
"for (; pktl; pktl = get_next_pkt(VAR_0, st, pktl)) {",
"if (pktl->VAR_4.VAR_1 != VAR_1)\ncontinue;",
"if (is_relative(pktl->VAR_4.VAR_3))\npktl->VAR_4.VAR_3 += shift;",
"if (is_relative(pktl->VAR_4.VAR_2))\npktl->VAR_4.VAR_2 += shift;",
"if (st->start_time == AV_NOPTS_VALUE && pktl->VAR_4.VAR_3 != AV_NOPTS_VALUE)\nst->start_time = pktl->VAR_4.VAR_3;",
"if (pktl->VAR_4.VAR_3 != AV_NOPTS_VALUE && VAR_6 <= MAX_REORDER_DELAY && has_decode_delay_been_guessed(st)) {",
"pts_buffer[0] = pktl->VAR_4.VAR_3;",
"for (VAR_5 = 0; VAR_5<VAR_6 && pts_buffer[VAR_5] > pts_buffer[VAR_5 + 1]; VAR_5++)",
"FFSWAP(int64_t, pts_buffer[VAR_5], pts_buffer[VAR_5 + 1]);",
"pktl->VAR_4.VAR_2 = select_from_pts_buffer(st, pts_buffer, pktl->VAR_4.VAR_2);",
"}",
"}",
"if (st->start_time == AV_NOPTS_VALUE)\nst->start_time = VAR_3;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21,
23,
25,
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47,
49
],
[
53
],
[
55,
57
],
[
59,
61
],
[
65,
67
],
[
71,
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
95,
97
],
[
99
]
] |
22,813 | static void ide_test_quit(void)
{
qtest_end();
} | true | qemu | 0142f88bff3dd5cb819c9900da1c1e0a4aae9c44 | static void ide_test_quit(void)
{
qtest_end();
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
qtest_end();
} | [
"static void FUNC_0(void)\n{",
"qtest_end();",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
]
] |
22,814 | static int update_prob(VP56RangeCoder *c, int p)
{
static const int inv_map_table[254] = {
7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176,
189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 113, 114, 115,
116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130,
131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145,
146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191,
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206,
207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221,
222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236,
237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
252, 253,
};
int d;
/* This code is trying to do a differential probability update. For a
* current probability A in the range [1, 255], the difference to a new
* probability of any value can be expressed differentially as 1-A,255-A
* where some part of this (absolute range) exists both in positive as
* well as the negative part, whereas another part only exists in one
* half. We're trying to code this shared part differentially, i.e.
* times two where the value of the lowest bit specifies the sign, and
* the single part is then coded on top of this. This absolute difference
* then again has a value of [0,254], but a bigger value in this range
* indicates that we're further away from the original value A, so we
* can code this as a VLC code, since higher values are increasingly
* unlikely. The first 20 values in inv_map_table[] allow 'cheap, rough'
* updates vs. the 'fine, exact' updates further down the range, which
* adds one extra dimension to this differential update model. */
if (!vp8_rac_get(c)) {
d = vp8_rac_get_uint(c, 4) + 0;
} else if (!vp8_rac_get(c)) {
d = vp8_rac_get_uint(c, 4) + 16;
} else if (!vp8_rac_get(c)) {
d = vp8_rac_get_uint(c, 5) + 32;
} else {
d = vp8_rac_get_uint(c, 7);
if (d >= 65)
d = (d << 1) - 65 + vp8_rac_get(c);
d += 64;
}
return p <= 128 ? 1 + inv_recenter_nonneg(inv_map_table[d], p - 1) :
255 - inv_recenter_nonneg(inv_map_table[d], 255 - p);
}
| true | FFmpeg | e91f860ea74e11e9178500fe8794c47f57dbf48c | static int update_prob(VP56RangeCoder *c, int p)
{
static const int inv_map_table[254] = {
7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176,
189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 113, 114, 115,
116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130,
131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145,
146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191,
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206,
207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221,
222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236,
237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
252, 253,
};
int d;
if (!vp8_rac_get(c)) {
d = vp8_rac_get_uint(c, 4) + 0;
} else if (!vp8_rac_get(c)) {
d = vp8_rac_get_uint(c, 4) + 16;
} else if (!vp8_rac_get(c)) {
d = vp8_rac_get_uint(c, 5) + 32;
} else {
d = vp8_rac_get_uint(c, 7);
if (d >= 65)
d = (d << 1) - 65 + vp8_rac_get(c);
d += 64;
}
return p <= 128 ? 1 + inv_recenter_nonneg(inv_map_table[d], p - 1) :
255 - inv_recenter_nonneg(inv_map_table[d], 255 - p);
}
| {
"code": [
" static const int inv_map_table[254] = {",
" 252, 253,"
],
"line_no": [
5,
43
]
} | static int FUNC_0(VP56RangeCoder *VAR_0, int VAR_1)
{
static const int VAR_2[254] = {
7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176,
189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 113, 114, 115,
116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130,
131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145,
146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191,
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206,
207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221,
222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236,
237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
252, 253,
};
int VAR_3;
if (!vp8_rac_get(VAR_0)) {
VAR_3 = vp8_rac_get_uint(VAR_0, 4) + 0;
} else if (!vp8_rac_get(VAR_0)) {
VAR_3 = vp8_rac_get_uint(VAR_0, 4) + 16;
} else if (!vp8_rac_get(VAR_0)) {
VAR_3 = vp8_rac_get_uint(VAR_0, 5) + 32;
} else {
VAR_3 = vp8_rac_get_uint(VAR_0, 7);
if (VAR_3 >= 65)
VAR_3 = (VAR_3 << 1) - 65 + vp8_rac_get(VAR_0);
VAR_3 += 64;
}
return VAR_1 <= 128 ? 1 + inv_recenter_nonneg(VAR_2[VAR_3], VAR_1 - 1) :
255 - inv_recenter_nonneg(VAR_2[VAR_3], 255 - VAR_1);
}
| [
"static int FUNC_0(VP56RangeCoder *VAR_0, int VAR_1)\n{",
"static const int VAR_2[254] = {",
"7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176,\n189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9,\n10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,\n25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39,\n40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54,\n55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,\n70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,\n86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100,\n101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 113, 114, 115,\n116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130,\n131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145,\n146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,\n161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,\n177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191,\n192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206,\n207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221,\n222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236,\n237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,\n252, 253,\n};",
"int VAR_3;",
"if (!vp8_rac_get(VAR_0)) {",
"VAR_3 = vp8_rac_get_uint(VAR_0, 4) + 0;",
"} else if (!vp8_rac_get(VAR_0)) {",
"VAR_3 = vp8_rac_get_uint(VAR_0, 4) + 16;",
"} else if (!vp8_rac_get(VAR_0)) {",
"VAR_3 = vp8_rac_get_uint(VAR_0, 5) + 32;",
"} else {",
"VAR_3 = vp8_rac_get_uint(VAR_0, 7);",
"if (VAR_3 >= 65)\nVAR_3 = (VAR_3 << 1) - 65 + vp8_rac_get(VAR_0);",
"VAR_3 += 64;",
"}",
"return VAR_1 <= 128 ? 1 + inv_recenter_nonneg(VAR_2[VAR_3], VAR_1 - 1) :\n255 - inv_recenter_nonneg(VAR_2[VAR_3], 255 - VAR_1);",
"}"
] | [
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45
],
[
47
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
107,
109
],
[
111
]
] |
22,816 | static void mcf5208evb_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
M68kCPU *cpu;
CPUM68KState *env;
int kernel_size;
uint64_t elf_entry;
hwaddr entry;
qemu_irq *pic;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
if (!cpu_model) {
cpu_model = "m5208";
}
cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model));
if (!cpu) {
fprintf(stderr, "Unable to find m68k CPU definition\n");
exit(1);
}
env = &cpu->env;
/* Initialize CPU registers. */
env->vbr = 0;
/* TODO: Configure BARs. */
/* DRAM at 0x40000000 */
memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_size);
memory_region_add_subregion(address_space_mem, 0x40000000, ram);
/* Internal SRAM. */
memory_region_init_ram(sram, NULL, "mcf5208.sram", 16384, &error_fatal);
memory_region_add_subregion(address_space_mem, 0x80000000, sram);
/* Internal peripherals. */
pic = mcf_intc_init(address_space_mem, 0xfc048000, cpu);
mcf_uart_mm_init(0xfc060000, pic[26], serial_hds[0]);
mcf_uart_mm_init(0xfc064000, pic[27], serial_hds[1]);
mcf_uart_mm_init(0xfc068000, pic[28], serial_hds[2]);
mcf5208_sys_init(address_space_mem, pic);
if (nb_nics > 1) {
fprintf(stderr, "Too many NICs\n");
exit(1);
}
if (nd_table[0].used) {
mcf_fec_init(address_space_mem, &nd_table[0],
0xfc030000, pic + 36);
}
/* 0xfc000000 SCM. */
/* 0xfc004000 XBS. */
/* 0xfc008000 FlexBus CS. */
/* 0xfc030000 FEC. */
/* 0xfc040000 SCM + Power management. */
/* 0xfc044000 eDMA. */
/* 0xfc048000 INTC. */
/* 0xfc058000 I2C. */
/* 0xfc05c000 QSPI. */
/* 0xfc060000 UART0. */
/* 0xfc064000 UART0. */
/* 0xfc068000 UART0. */
/* 0xfc070000 DMA timers. */
/* 0xfc080000 PIT0. */
/* 0xfc084000 PIT1. */
/* 0xfc088000 EPORT. */
/* 0xfc08c000 Watchdog. */
/* 0xfc090000 clock module. */
/* 0xfc0a0000 CCM + reset. */
/* 0xfc0a4000 GPIO. */
/* 0xfc0a8000 SDRAM controller. */
/* Load kernel. */
if (!kernel_filename) {
if (qtest_enabled()) {
return;
}
fprintf(stderr, "Kernel image must be specified\n");
exit(1);
}
kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
NULL, NULL, 1, EM_68K, 0, 0);
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, 0x40000000,
ram_size);
entry = 0x40000000;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
exit(1);
}
env->pc = entry;
}
| true | qemu | 4482e05cbbb7e50e476f6a9500cf0b38913bd939 | static void mcf5208evb_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
M68kCPU *cpu;
CPUM68KState *env;
int kernel_size;
uint64_t elf_entry;
hwaddr entry;
qemu_irq *pic;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
if (!cpu_model) {
cpu_model = "m5208";
}
cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model));
if (!cpu) {
fprintf(stderr, "Unable to find m68k CPU definition\n");
exit(1);
}
env = &cpu->env;
env->vbr = 0;
memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_size);
memory_region_add_subregion(address_space_mem, 0x40000000, ram);
memory_region_init_ram(sram, NULL, "mcf5208.sram", 16384, &error_fatal);
memory_region_add_subregion(address_space_mem, 0x80000000, sram);
pic = mcf_intc_init(address_space_mem, 0xfc048000, cpu);
mcf_uart_mm_init(0xfc060000, pic[26], serial_hds[0]);
mcf_uart_mm_init(0xfc064000, pic[27], serial_hds[1]);
mcf_uart_mm_init(0xfc068000, pic[28], serial_hds[2]);
mcf5208_sys_init(address_space_mem, pic);
if (nb_nics > 1) {
fprintf(stderr, "Too many NICs\n");
exit(1);
}
if (nd_table[0].used) {
mcf_fec_init(address_space_mem, &nd_table[0],
0xfc030000, pic + 36);
}
if (!kernel_filename) {
if (qtest_enabled()) {
return;
}
fprintf(stderr, "Kernel image must be specified\n");
exit(1);
}
kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
NULL, NULL, 1, EM_68K, 0, 0);
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, 0x40000000,
ram_size);
entry = 0x40000000;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
exit(1);
}
env->pc = entry;
}
| {
"code": [
" if (!cpu) {",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" if (!cpu) {",
" fprintf(stderr, \"Unable to find m68k CPU definition\\n\");",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" exit(1);",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" if (!cpu) {"
],
"line_no": [
39,
43,
39,
43,
43,
43,
43,
43,
43,
43,
43,
43,
39,
43,
39,
41,
43,
43,
43,
43,
43,
39,
43,
43,
43,
39,
43,
43,
43,
43,
43,
43,
43,
39,
43,
39,
43,
39
]
} | static void FUNC_0(MachineState *VAR_0)
{
ram_addr_t ram_size = VAR_0->ram_size;
const char *VAR_1 = VAR_0->VAR_1;
const char *VAR_2 = VAR_0->VAR_2;
M68kCPU *cpu;
CPUM68KState *env;
int VAR_3;
uint64_t elf_entry;
hwaddr entry;
qemu_irq *pic;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
if (!VAR_1) {
VAR_1 = "m5208";
}
cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, VAR_1));
if (!cpu) {
fprintf(stderr, "Unable to find m68k CPU definition\n");
exit(1);
}
env = &cpu->env;
env->vbr = 0;
memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_size);
memory_region_add_subregion(address_space_mem, 0x40000000, ram);
memory_region_init_ram(sram, NULL, "mcf5208.sram", 16384, &error_fatal);
memory_region_add_subregion(address_space_mem, 0x80000000, sram);
pic = mcf_intc_init(address_space_mem, 0xfc048000, cpu);
mcf_uart_mm_init(0xfc060000, pic[26], serial_hds[0]);
mcf_uart_mm_init(0xfc064000, pic[27], serial_hds[1]);
mcf_uart_mm_init(0xfc068000, pic[28], serial_hds[2]);
mcf5208_sys_init(address_space_mem, pic);
if (nb_nics > 1) {
fprintf(stderr, "Too many NICs\n");
exit(1);
}
if (nd_table[0].used) {
mcf_fec_init(address_space_mem, &nd_table[0],
0xfc030000, pic + 36);
}
if (!VAR_2) {
if (qtest_enabled()) {
return;
}
fprintf(stderr, "Kernel image must be specified\n");
exit(1);
}
VAR_3 = load_elf(VAR_2, NULL, NULL, &elf_entry,
NULL, NULL, 1, EM_68K, 0, 0);
entry = elf_entry;
if (VAR_3 < 0) {
VAR_3 = load_uimage(VAR_2, &entry, NULL, NULL,
NULL, NULL);
}
if (VAR_3 < 0) {
VAR_3 = load_image_targphys(VAR_2, 0x40000000,
ram_size);
entry = 0x40000000;
}
if (VAR_3 < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n", VAR_2);
exit(1);
}
env->pc = entry;
}
| [
"static void FUNC_0(MachineState *VAR_0)\n{",
"ram_addr_t ram_size = VAR_0->ram_size;",
"const char *VAR_1 = VAR_0->VAR_1;",
"const char *VAR_2 = VAR_0->VAR_2;",
"M68kCPU *cpu;",
"CPUM68KState *env;",
"int VAR_3;",
"uint64_t elf_entry;",
"hwaddr entry;",
"qemu_irq *pic;",
"MemoryRegion *address_space_mem = get_system_memory();",
"MemoryRegion *ram = g_new(MemoryRegion, 1);",
"MemoryRegion *sram = g_new(MemoryRegion, 1);",
"if (!VAR_1) {",
"VAR_1 = \"m5208\";",
"}",
"cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, VAR_1));",
"if (!cpu) {",
"fprintf(stderr, \"Unable to find m68k CPU definition\\n\");",
"exit(1);",
"}",
"env = &cpu->env;",
"env->vbr = 0;",
"memory_region_allocate_system_memory(ram, NULL, \"mcf5208.ram\", ram_size);",
"memory_region_add_subregion(address_space_mem, 0x40000000, ram);",
"memory_region_init_ram(sram, NULL, \"mcf5208.sram\", 16384, &error_fatal);",
"memory_region_add_subregion(address_space_mem, 0x80000000, sram);",
"pic = mcf_intc_init(address_space_mem, 0xfc048000, cpu);",
"mcf_uart_mm_init(0xfc060000, pic[26], serial_hds[0]);",
"mcf_uart_mm_init(0xfc064000, pic[27], serial_hds[1]);",
"mcf_uart_mm_init(0xfc068000, pic[28], serial_hds[2]);",
"mcf5208_sys_init(address_space_mem, pic);",
"if (nb_nics > 1) {",
"fprintf(stderr, \"Too many NICs\\n\");",
"exit(1);",
"}",
"if (nd_table[0].used) {",
"mcf_fec_init(address_space_mem, &nd_table[0],\n0xfc030000, pic + 36);",
"}",
"if (!VAR_2) {",
"if (qtest_enabled()) {",
"return;",
"}",
"fprintf(stderr, \"Kernel image must be specified\\n\");",
"exit(1);",
"}",
"VAR_3 = load_elf(VAR_2, NULL, NULL, &elf_entry,\nNULL, NULL, 1, EM_68K, 0, 0);",
"entry = elf_entry;",
"if (VAR_3 < 0) {",
"VAR_3 = load_uimage(VAR_2, &entry, NULL, NULL,\nNULL, NULL);",
"}",
"if (VAR_3 < 0) {",
"VAR_3 = load_image_targphys(VAR_2, 0x40000000,\nram_size);",
"entry = 0x40000000;",
"}",
"if (VAR_3 < 0) {",
"fprintf(stderr, \"qemu: could not load kernel '%s'\\n\", VAR_2);",
"exit(1);",
"}",
"env->pc = entry;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
53
],
[
61
],
[
63
],
[
69
],
[
71
],
[
77
],
[
81
],
[
83
],
[
85
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173,
175
],
[
177
],
[
179
],
[
181,
183
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
]
] |
22,817 | static void vga_get_text_resolution(VGACommonState *s, int *pwidth, int *pheight,
int *pcwidth, int *pcheight)
{
int width, cwidth, height, cheight;
/* total width & height */
cheight = (s->cr[VGA_CRTC_MAX_SCAN] & 0x1f) + 1;
cwidth = 8;
if (!(s->sr[VGA_SEQ_CLOCK_MODE] & VGA_SR01_CHAR_CLK_8DOTS)) {
cwidth = 9;
}
if (s->sr[VGA_SEQ_CLOCK_MODE] & 0x08) {
cwidth = 16; /* NOTE: no 18 pixel wide */
}
width = (s->cr[VGA_CRTC_H_DISP] + 1);
if (s->cr[VGA_CRTC_V_TOTAL] == 100) {
/* ugly hack for CGA 160x100x16 - explain me the logic */
height = 100;
} else {
height = s->cr[VGA_CRTC_V_DISP_END] |
((s->cr[VGA_CRTC_OVERFLOW] & 0x02) << 7) |
((s->cr[VGA_CRTC_OVERFLOW] & 0x40) << 3);
height = (height + 1) / cheight;
}
*pwidth = width;
*pheight = height;
*pcwidth = cwidth;
*pcheight = cheight;
}
| true | qemu | 94ef4f337fb614f18b765a8e0e878a4c23cdedcd | static void vga_get_text_resolution(VGACommonState *s, int *pwidth, int *pheight,
int *pcwidth, int *pcheight)
{
int width, cwidth, height, cheight;
cheight = (s->cr[VGA_CRTC_MAX_SCAN] & 0x1f) + 1;
cwidth = 8;
if (!(s->sr[VGA_SEQ_CLOCK_MODE] & VGA_SR01_CHAR_CLK_8DOTS)) {
cwidth = 9;
}
if (s->sr[VGA_SEQ_CLOCK_MODE] & 0x08) {
cwidth = 16;
}
width = (s->cr[VGA_CRTC_H_DISP] + 1);
if (s->cr[VGA_CRTC_V_TOTAL] == 100) {
height = 100;
} else {
height = s->cr[VGA_CRTC_V_DISP_END] |
((s->cr[VGA_CRTC_OVERFLOW] & 0x02) << 7) |
((s->cr[VGA_CRTC_OVERFLOW] & 0x40) << 3);
height = (height + 1) / cheight;
}
*pwidth = width;
*pheight = height;
*pcwidth = cwidth;
*pcheight = cheight;
}
| {
"code": [
" if (!(s->sr[VGA_SEQ_CLOCK_MODE] & VGA_SR01_CHAR_CLK_8DOTS)) {",
" if (s->sr[VGA_SEQ_CLOCK_MODE] & 0x08) {"
],
"line_no": [
17,
23
]
} | static void FUNC_0(VGACommonState *VAR_0, int *VAR_1, int *VAR_2,
int *VAR_3, int *VAR_4)
{
int VAR_5, VAR_6, VAR_7, VAR_8;
VAR_8 = (VAR_0->cr[VGA_CRTC_MAX_SCAN] & 0x1f) + 1;
VAR_6 = 8;
if (!(VAR_0->sr[VGA_SEQ_CLOCK_MODE] & VGA_SR01_CHAR_CLK_8DOTS)) {
VAR_6 = 9;
}
if (VAR_0->sr[VGA_SEQ_CLOCK_MODE] & 0x08) {
VAR_6 = 16;
}
VAR_5 = (VAR_0->cr[VGA_CRTC_H_DISP] + 1);
if (VAR_0->cr[VGA_CRTC_V_TOTAL] == 100) {
VAR_7 = 100;
} else {
VAR_7 = VAR_0->cr[VGA_CRTC_V_DISP_END] |
((VAR_0->cr[VGA_CRTC_OVERFLOW] & 0x02) << 7) |
((VAR_0->cr[VGA_CRTC_OVERFLOW] & 0x40) << 3);
VAR_7 = (VAR_7 + 1) / VAR_8;
}
*VAR_1 = VAR_5;
*VAR_2 = VAR_7;
*VAR_3 = VAR_6;
*VAR_4 = VAR_8;
}
| [
"static void FUNC_0(VGACommonState *VAR_0, int *VAR_1, int *VAR_2,\nint *VAR_3, int *VAR_4)\n{",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"VAR_8 = (VAR_0->cr[VGA_CRTC_MAX_SCAN] & 0x1f) + 1;",
"VAR_6 = 8;",
"if (!(VAR_0->sr[VGA_SEQ_CLOCK_MODE] & VGA_SR01_CHAR_CLK_8DOTS)) {",
"VAR_6 = 9;",
"}",
"if (VAR_0->sr[VGA_SEQ_CLOCK_MODE] & 0x08) {",
"VAR_6 = 16;",
"}",
"VAR_5 = (VAR_0->cr[VGA_CRTC_H_DISP] + 1);",
"if (VAR_0->cr[VGA_CRTC_V_TOTAL] == 100) {",
"VAR_7 = 100;",
"} else {",
"VAR_7 = VAR_0->cr[VGA_CRTC_V_DISP_END] |\n((VAR_0->cr[VGA_CRTC_OVERFLOW] & 0x02) << 7) |\n((VAR_0->cr[VGA_CRTC_OVERFLOW] & 0x40) << 3);",
"VAR_7 = (VAR_7 + 1) / VAR_8;",
"}",
"*VAR_1 = VAR_5;",
"*VAR_2 = VAR_7;",
"*VAR_3 = VAR_6;",
"*VAR_4 = VAR_8;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39,
41,
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
]
] |
22,819 | int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
AVFormatContext *src)
{
AVPacket local_pkt;
local_pkt = *pkt;
local_pkt.stream_index = dst_stream;
if (pkt->pts != AV_NOPTS_VALUE)
local_pkt.pts = av_rescale_q(pkt->pts,
src->streams[pkt->stream_index]->time_base,
dst->streams[dst_stream]->time_base);
if (pkt->dts != AV_NOPTS_VALUE)
local_pkt.dts = av_rescale_q(pkt->dts,
src->streams[pkt->stream_index]->time_base,
dst->streams[dst_stream]->time_base);
if (pkt->duration)
local_pkt.duration = av_rescale_q(pkt->duration,
src->streams[pkt->stream_index]->time_base,
dst->streams[dst_stream]->time_base);
return av_write_frame(dst, &local_pkt);
}
| true | FFmpeg | 383a04a127734d25c1ef7839c489bba297855801 | int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
AVFormatContext *src)
{
AVPacket local_pkt;
local_pkt = *pkt;
local_pkt.stream_index = dst_stream;
if (pkt->pts != AV_NOPTS_VALUE)
local_pkt.pts = av_rescale_q(pkt->pts,
src->streams[pkt->stream_index]->time_base,
dst->streams[dst_stream]->time_base);
if (pkt->dts != AV_NOPTS_VALUE)
local_pkt.dts = av_rescale_q(pkt->dts,
src->streams[pkt->stream_index]->time_base,
dst->streams[dst_stream]->time_base);
if (pkt->duration)
local_pkt.duration = av_rescale_q(pkt->duration,
src->streams[pkt->stream_index]->time_base,
dst->streams[dst_stream]->time_base);
return av_write_frame(dst, &local_pkt);
}
| {
"code": [
" return av_write_frame(dst, &local_pkt);"
],
"line_no": [
39
]
} | int FUNC_0(AVFormatContext *VAR_0, int VAR_1, AVPacket *VAR_2,
AVFormatContext *VAR_3)
{
AVPacket local_pkt;
local_pkt = *VAR_2;
local_pkt.stream_index = VAR_1;
if (VAR_2->pts != AV_NOPTS_VALUE)
local_pkt.pts = av_rescale_q(VAR_2->pts,
VAR_3->streams[VAR_2->stream_index]->time_base,
VAR_0->streams[VAR_1]->time_base);
if (VAR_2->dts != AV_NOPTS_VALUE)
local_pkt.dts = av_rescale_q(VAR_2->dts,
VAR_3->streams[VAR_2->stream_index]->time_base,
VAR_0->streams[VAR_1]->time_base);
if (VAR_2->duration)
local_pkt.duration = av_rescale_q(VAR_2->duration,
VAR_3->streams[VAR_2->stream_index]->time_base,
VAR_0->streams[VAR_1]->time_base);
return av_write_frame(VAR_0, &local_pkt);
}
| [
"int FUNC_0(AVFormatContext *VAR_0, int VAR_1, AVPacket *VAR_2,\nAVFormatContext *VAR_3)\n{",
"AVPacket local_pkt;",
"local_pkt = *VAR_2;",
"local_pkt.stream_index = VAR_1;",
"if (VAR_2->pts != AV_NOPTS_VALUE)\nlocal_pkt.pts = av_rescale_q(VAR_2->pts,\nVAR_3->streams[VAR_2->stream_index]->time_base,\nVAR_0->streams[VAR_1]->time_base);",
"if (VAR_2->dts != AV_NOPTS_VALUE)\nlocal_pkt.dts = av_rescale_q(VAR_2->dts,\nVAR_3->streams[VAR_2->stream_index]->time_base,\nVAR_0->streams[VAR_1]->time_base);",
"if (VAR_2->duration)\nlocal_pkt.duration = av_rescale_q(VAR_2->duration,\nVAR_3->streams[VAR_2->stream_index]->time_base,\nVAR_0->streams[VAR_1]->time_base);",
"return av_write_frame(VAR_0, &local_pkt);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15,
17,
19,
21
],
[
23,
25,
27,
29
],
[
31,
33,
35,
37
],
[
39
],
[
41
]
] |
22,820 | static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, int buf_size)
{
int i;
int skip = 0;
int len, toks, pos;
TM2Codes codes;
GetByteContext gb;
if (buf_size < 4) {
av_log(ctx->avctx, AV_LOG_ERROR, "not enough space for len left\n");
return AVERROR_INVALIDDATA;
}
/* get stream length in dwords */
bytestream2_init(&gb, buf, buf_size);
len = bytestream2_get_be32(&gb);
skip = len * 4 + 4;
if(len == 0)
return 4;
if (len >= INT_MAX/4-1 || len < 0 || skip > buf_size) {
av_log(ctx->avctx, AV_LOG_ERROR, "invalid stream size\n");
return AVERROR_INVALIDDATA;
}
toks = bytestream2_get_be32(&gb);
if(toks & 1) {
len = bytestream2_get_be32(&gb);
if(len == TM2_ESCAPE) {
len = bytestream2_get_be32(&gb);
}
if(len > 0) {
pos = bytestream2_tell(&gb);
if (skip <= pos)
return AVERROR_INVALIDDATA;
init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
if(tm2_read_deltas(ctx, stream_id) == -1)
return AVERROR_INVALIDDATA;
bytestream2_skip(&gb, ((get_bits_count(&ctx->gb) + 31) >> 5) << 2);
}
}
/* skip unused fields */
len = bytestream2_get_be32(&gb);
if(len == TM2_ESCAPE) { /* some unknown length - could be escaped too */
bytestream2_skip(&gb, 8); /* unused by decoder */
} else {
bytestream2_skip(&gb, 4); /* unused by decoder */
}
pos = bytestream2_tell(&gb);
if (skip <= pos)
return AVERROR_INVALIDDATA;
init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
if(tm2_build_huff_table(ctx, &codes) == -1)
return AVERROR_INVALIDDATA;
bytestream2_skip(&gb, ((get_bits_count(&ctx->gb) + 31) >> 5) << 2);
toks >>= 1;
/* check if we have sane number of tokens */
if((toks < 0) || (toks > 0xFFFFFF)){
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);
tm2_free_codes(&codes);
return AVERROR_INVALIDDATA;
}
ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int));
ctx->tok_lens[stream_id] = toks;
len = bytestream2_get_be32(&gb);
if(len > 0) {
pos = bytestream2_tell(&gb);
if (skip <= pos)
return AVERROR_INVALIDDATA;
init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
for(i = 0; i < toks; i++) {
if (get_bits_left(&ctx->gb) <= 0) {
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);
return AVERROR_INVALIDDATA;
}
ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes);
if (stream_id <= TM2_MOT && ctx->tokens[stream_id][i] >= TM2_DELTAS) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid delta token index %d for type %d, n=%d\n",
ctx->tokens[stream_id][i], stream_id, i);
return AVERROR_INVALIDDATA;
}
}
} else {
for(i = 0; i < toks; i++) {
ctx->tokens[stream_id][i] = codes.recode[0];
if (stream_id <= TM2_MOT && ctx->tokens[stream_id][i] >= TM2_DELTAS) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid delta token index %d for type %d, n=%d\n",
ctx->tokens[stream_id][i], stream_id, i);
return AVERROR_INVALIDDATA;
}
}
}
tm2_free_codes(&codes);
return skip;
}
| false | FFmpeg | 31fce399425b986557ab94a2dd8305b289710f0e | static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, int buf_size)
{
int i;
int skip = 0;
int len, toks, pos;
TM2Codes codes;
GetByteContext gb;
if (buf_size < 4) {
av_log(ctx->avctx, AV_LOG_ERROR, "not enough space for len left\n");
return AVERROR_INVALIDDATA;
}
bytestream2_init(&gb, buf, buf_size);
len = bytestream2_get_be32(&gb);
skip = len * 4 + 4;
if(len == 0)
return 4;
if (len >= INT_MAX/4-1 || len < 0 || skip > buf_size) {
av_log(ctx->avctx, AV_LOG_ERROR, "invalid stream size\n");
return AVERROR_INVALIDDATA;
}
toks = bytestream2_get_be32(&gb);
if(toks & 1) {
len = bytestream2_get_be32(&gb);
if(len == TM2_ESCAPE) {
len = bytestream2_get_be32(&gb);
}
if(len > 0) {
pos = bytestream2_tell(&gb);
if (skip <= pos)
return AVERROR_INVALIDDATA;
init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
if(tm2_read_deltas(ctx, stream_id) == -1)
return AVERROR_INVALIDDATA;
bytestream2_skip(&gb, ((get_bits_count(&ctx->gb) + 31) >> 5) << 2);
}
}
len = bytestream2_get_be32(&gb);
if(len == TM2_ESCAPE) {
bytestream2_skip(&gb, 8);
} else {
bytestream2_skip(&gb, 4);
}
pos = bytestream2_tell(&gb);
if (skip <= pos)
return AVERROR_INVALIDDATA;
init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
if(tm2_build_huff_table(ctx, &codes) == -1)
return AVERROR_INVALIDDATA;
bytestream2_skip(&gb, ((get_bits_count(&ctx->gb) + 31) >> 5) << 2);
toks >>= 1;
if((toks < 0) || (toks > 0xFFFFFF)){
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);
tm2_free_codes(&codes);
return AVERROR_INVALIDDATA;
}
ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int));
ctx->tok_lens[stream_id] = toks;
len = bytestream2_get_be32(&gb);
if(len > 0) {
pos = bytestream2_tell(&gb);
if (skip <= pos)
return AVERROR_INVALIDDATA;
init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8);
for(i = 0; i < toks; i++) {
if (get_bits_left(&ctx->gb) <= 0) {
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);
return AVERROR_INVALIDDATA;
}
ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes);
if (stream_id <= TM2_MOT && ctx->tokens[stream_id][i] >= TM2_DELTAS) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid delta token index %d for type %d, n=%d\n",
ctx->tokens[stream_id][i], stream_id, i);
return AVERROR_INVALIDDATA;
}
}
} else {
for(i = 0; i < toks; i++) {
ctx->tokens[stream_id][i] = codes.recode[0];
if (stream_id <= TM2_MOT && ctx->tokens[stream_id][i] >= TM2_DELTAS) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid delta token index %d for type %d, n=%d\n",
ctx->tokens[stream_id][i], stream_id, i);
return AVERROR_INVALIDDATA;
}
}
}
tm2_free_codes(&codes);
return skip;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(TM2Context *VAR_0, const uint8_t *VAR_1, int VAR_2, int VAR_3)
{
int VAR_4;
int VAR_5 = 0;
int VAR_6, VAR_7, VAR_8;
TM2Codes codes;
GetByteContext gb;
if (VAR_3 < 4) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "not enough space for VAR_6 left\n");
return AVERROR_INVALIDDATA;
}
bytestream2_init(&gb, VAR_1, VAR_3);
VAR_6 = bytestream2_get_be32(&gb);
VAR_5 = VAR_6 * 4 + 4;
if(VAR_6 == 0)
return 4;
if (VAR_6 >= INT_MAX/4-1 || VAR_6 < 0 || VAR_5 > VAR_3) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid stream size\n");
return AVERROR_INVALIDDATA;
}
VAR_7 = bytestream2_get_be32(&gb);
if(VAR_7 & 1) {
VAR_6 = bytestream2_get_be32(&gb);
if(VAR_6 == TM2_ESCAPE) {
VAR_6 = bytestream2_get_be32(&gb);
}
if(VAR_6 > 0) {
VAR_8 = bytestream2_tell(&gb);
if (VAR_5 <= VAR_8)
return AVERROR_INVALIDDATA;
init_get_bits(&VAR_0->gb, VAR_1 + VAR_8, (VAR_5 - VAR_8) * 8);
if(tm2_read_deltas(VAR_0, VAR_2) == -1)
return AVERROR_INVALIDDATA;
bytestream2_skip(&gb, ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2);
}
}
VAR_6 = bytestream2_get_be32(&gb);
if(VAR_6 == TM2_ESCAPE) {
bytestream2_skip(&gb, 8);
} else {
bytestream2_skip(&gb, 4);
}
VAR_8 = bytestream2_tell(&gb);
if (VAR_5 <= VAR_8)
return AVERROR_INVALIDDATA;
init_get_bits(&VAR_0->gb, VAR_1 + VAR_8, (VAR_5 - VAR_8) * 8);
if(tm2_build_huff_table(VAR_0, &codes) == -1)
return AVERROR_INVALIDDATA;
bytestream2_skip(&gb, ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2);
VAR_7 >>= 1;
if((VAR_7 < 0) || (VAR_7 > 0xFFFFFF)){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %VAR_4\n", VAR_7);
tm2_free_codes(&codes);
return AVERROR_INVALIDDATA;
}
VAR_0->tokens[VAR_2] = av_realloc(VAR_0->tokens[VAR_2], VAR_7 * sizeof(int));
VAR_0->tok_lens[VAR_2] = VAR_7;
VAR_6 = bytestream2_get_be32(&gb);
if(VAR_6 > 0) {
VAR_8 = bytestream2_tell(&gb);
if (VAR_5 <= VAR_8)
return AVERROR_INVALIDDATA;
init_get_bits(&VAR_0->gb, VAR_1 + VAR_8, (VAR_5 - VAR_8) * 8);
for(VAR_4 = 0; VAR_4 < VAR_7; VAR_4++) {
if (get_bits_left(&VAR_0->gb) <= 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %VAR_4\n", VAR_7);
return AVERROR_INVALIDDATA;
}
VAR_0->tokens[VAR_2][VAR_4] = tm2_get_token(&VAR_0->gb, &codes);
if (VAR_2 <= TM2_MOT && VAR_0->tokens[VAR_2][VAR_4] >= TM2_DELTAS) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid delta token index %d for type %d, n=%d\n",
VAR_0->tokens[VAR_2][VAR_4], VAR_2, VAR_4);
return AVERROR_INVALIDDATA;
}
}
} else {
for(VAR_4 = 0; VAR_4 < VAR_7; VAR_4++) {
VAR_0->tokens[VAR_2][VAR_4] = codes.recode[0];
if (VAR_2 <= TM2_MOT && VAR_0->tokens[VAR_2][VAR_4] >= TM2_DELTAS) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid delta token index %d for type %d, n=%d\n",
VAR_0->tokens[VAR_2][VAR_4], VAR_2, VAR_4);
return AVERROR_INVALIDDATA;
}
}
}
tm2_free_codes(&codes);
return VAR_5;
}
| [
"static int FUNC_0(TM2Context *VAR_0, const uint8_t *VAR_1, int VAR_2, int VAR_3)\n{",
"int VAR_4;",
"int VAR_5 = 0;",
"int VAR_6, VAR_7, VAR_8;",
"TM2Codes codes;",
"GetByteContext gb;",
"if (VAR_3 < 4) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"not enough space for VAR_6 left\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"bytestream2_init(&gb, VAR_1, VAR_3);",
"VAR_6 = bytestream2_get_be32(&gb);",
"VAR_5 = VAR_6 * 4 + 4;",
"if(VAR_6 == 0)\nreturn 4;",
"if (VAR_6 >= INT_MAX/4-1 || VAR_6 < 0 || VAR_5 > VAR_3) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid stream size\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_7 = bytestream2_get_be32(&gb);",
"if(VAR_7 & 1) {",
"VAR_6 = bytestream2_get_be32(&gb);",
"if(VAR_6 == TM2_ESCAPE) {",
"VAR_6 = bytestream2_get_be32(&gb);",
"}",
"if(VAR_6 > 0) {",
"VAR_8 = bytestream2_tell(&gb);",
"if (VAR_5 <= VAR_8)\nreturn AVERROR_INVALIDDATA;",
"init_get_bits(&VAR_0->gb, VAR_1 + VAR_8, (VAR_5 - VAR_8) * 8);",
"if(tm2_read_deltas(VAR_0, VAR_2) == -1)\nreturn AVERROR_INVALIDDATA;",
"bytestream2_skip(&gb, ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2);",
"}",
"}",
"VAR_6 = bytestream2_get_be32(&gb);",
"if(VAR_6 == TM2_ESCAPE) {",
"bytestream2_skip(&gb, 8);",
"} else {",
"bytestream2_skip(&gb, 4);",
"}",
"VAR_8 = bytestream2_tell(&gb);",
"if (VAR_5 <= VAR_8)\nreturn AVERROR_INVALIDDATA;",
"init_get_bits(&VAR_0->gb, VAR_1 + VAR_8, (VAR_5 - VAR_8) * 8);",
"if(tm2_build_huff_table(VAR_0, &codes) == -1)\nreturn AVERROR_INVALIDDATA;",
"bytestream2_skip(&gb, ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2);",
"VAR_7 >>= 1;",
"if((VAR_7 < 0) || (VAR_7 > 0xFFFFFF)){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Incorrect number of tokens: %VAR_4\\n\", VAR_7);",
"tm2_free_codes(&codes);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->tokens[VAR_2] = av_realloc(VAR_0->tokens[VAR_2], VAR_7 * sizeof(int));",
"VAR_0->tok_lens[VAR_2] = VAR_7;",
"VAR_6 = bytestream2_get_be32(&gb);",
"if(VAR_6 > 0) {",
"VAR_8 = bytestream2_tell(&gb);",
"if (VAR_5 <= VAR_8)\nreturn AVERROR_INVALIDDATA;",
"init_get_bits(&VAR_0->gb, VAR_1 + VAR_8, (VAR_5 - VAR_8) * 8);",
"for(VAR_4 = 0; VAR_4 < VAR_7; VAR_4++) {",
"if (get_bits_left(&VAR_0->gb) <= 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Incorrect number of tokens: %VAR_4\\n\", VAR_7);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->tokens[VAR_2][VAR_4] = tm2_get_token(&VAR_0->gb, &codes);",
"if (VAR_2 <= TM2_MOT && VAR_0->tokens[VAR_2][VAR_4] >= TM2_DELTAS) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid delta token index %d for type %d, n=%d\\n\",\nVAR_0->tokens[VAR_2][VAR_4], VAR_2, VAR_4);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"} else {",
"for(VAR_4 = 0; VAR_4 < VAR_7; VAR_4++) {",
"VAR_0->tokens[VAR_2][VAR_4] = codes.recode[0];",
"if (VAR_2 <= TM2_MOT && VAR_0->tokens[VAR_2][VAR_4] >= TM2_DELTAS) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid delta token index %d for type %d, n=%d\\n\",\nVAR_0->tokens[VAR_2][VAR_4], VAR_2, VAR_4);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"}",
"tm2_free_codes(&codes);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103,
105
],
[
107
],
[
109,
111
],
[
113
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
]
] |
22,821 | static int parse_section_header(GetByteContext *gbc, int *section_size,
enum HapSectionType *section_type)
{
if (bytestream2_get_bytes_left(gbc) < 4)
return AVERROR_INVALIDDATA;
*section_size = bytestream2_get_le24(gbc);
*section_type = bytestream2_get_byte(gbc);
if (*section_size == 0) {
if (bytestream2_get_bytes_left(gbc) < 4)
return AVERROR_INVALIDDATA;
*section_size = bytestream2_get_le32(gbc);
}
if (*section_size > bytestream2_get_bytes_left(gbc))
return AVERROR_INVALIDDATA;
else
return 0;
}
| false | FFmpeg | 205c31b301864e675d051b07b19b6c457cf2ab24 | static int parse_section_header(GetByteContext *gbc, int *section_size,
enum HapSectionType *section_type)
{
if (bytestream2_get_bytes_left(gbc) < 4)
return AVERROR_INVALIDDATA;
*section_size = bytestream2_get_le24(gbc);
*section_type = bytestream2_get_byte(gbc);
if (*section_size == 0) {
if (bytestream2_get_bytes_left(gbc) < 4)
return AVERROR_INVALIDDATA;
*section_size = bytestream2_get_le32(gbc);
}
if (*section_size > bytestream2_get_bytes_left(gbc))
return AVERROR_INVALIDDATA;
else
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(GetByteContext *VAR_0, int *VAR_1,
enum HapSectionType *VAR_2)
{
if (bytestream2_get_bytes_left(VAR_0) < 4)
return AVERROR_INVALIDDATA;
*VAR_1 = bytestream2_get_le24(VAR_0);
*VAR_2 = bytestream2_get_byte(VAR_0);
if (*VAR_1 == 0) {
if (bytestream2_get_bytes_left(VAR_0) < 4)
return AVERROR_INVALIDDATA;
*VAR_1 = bytestream2_get_le32(VAR_0);
}
if (*VAR_1 > bytestream2_get_bytes_left(VAR_0))
return AVERROR_INVALIDDATA;
else
return 0;
}
| [
"static int FUNC_0(GetByteContext *VAR_0, int *VAR_1,\nenum HapSectionType *VAR_2)\n{",
"if (bytestream2_get_bytes_left(VAR_0) < 4)\nreturn AVERROR_INVALIDDATA;",
"*VAR_1 = bytestream2_get_le24(VAR_0);",
"*VAR_2 = bytestream2_get_byte(VAR_0);",
"if (*VAR_1 == 0) {",
"if (bytestream2_get_bytes_left(VAR_0) < 4)\nreturn AVERROR_INVALIDDATA;",
"*VAR_1 = bytestream2_get_le32(VAR_0);",
"}",
"if (*VAR_1 > bytestream2_get_bytes_left(VAR_0))\nreturn AVERROR_INVALIDDATA;",
"else\nreturn 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
27
],
[
29
],
[
33,
35
],
[
37,
39
],
[
41
]
] |
22,823 | static int pps_range_extensions(GetBitContext *gb, AVCodecContext *avctx,
HEVCPPS *pps, HEVCSPS *sps) {
int i;
if (pps->transform_skip_enabled_flag) {
pps->log2_max_transform_skip_block_size = get_ue_golomb_long(gb) + 2;
}
pps->cross_component_prediction_enabled_flag = get_bits1(gb);
pps->chroma_qp_offset_list_enabled_flag = get_bits1(gb);
if (pps->chroma_qp_offset_list_enabled_flag) {
pps->diff_cu_chroma_qp_offset_depth = get_ue_golomb_long(gb);
pps->chroma_qp_offset_list_len_minus1 = get_ue_golomb_long(gb);
if (pps->chroma_qp_offset_list_len_minus1 && pps->chroma_qp_offset_list_len_minus1 >= 5) {
av_log(avctx, AV_LOG_ERROR,
"chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i <= pps->chroma_qp_offset_list_len_minus1; i++) {
pps->cb_qp_offset_list[i] = get_se_golomb_long(gb);
if (pps->cb_qp_offset_list[i]) {
av_log(avctx, AV_LOG_WARNING,
"cb_qp_offset_list not tested yet.\n");
}
pps->cr_qp_offset_list[i] = get_se_golomb_long(gb);
if (pps->cr_qp_offset_list[i]) {
av_log(avctx, AV_LOG_WARNING,
"cb_qp_offset_list not tested yet.\n");
}
}
}
pps->log2_sao_offset_scale_luma = get_ue_golomb_long(gb);
pps->log2_sao_offset_scale_chroma = get_ue_golomb_long(gb);
return(0);
}
| false | FFmpeg | e952d4b7ace607132130599905c75f25aaea9e56 | static int pps_range_extensions(GetBitContext *gb, AVCodecContext *avctx,
HEVCPPS *pps, HEVCSPS *sps) {
int i;
if (pps->transform_skip_enabled_flag) {
pps->log2_max_transform_skip_block_size = get_ue_golomb_long(gb) + 2;
}
pps->cross_component_prediction_enabled_flag = get_bits1(gb);
pps->chroma_qp_offset_list_enabled_flag = get_bits1(gb);
if (pps->chroma_qp_offset_list_enabled_flag) {
pps->diff_cu_chroma_qp_offset_depth = get_ue_golomb_long(gb);
pps->chroma_qp_offset_list_len_minus1 = get_ue_golomb_long(gb);
if (pps->chroma_qp_offset_list_len_minus1 && pps->chroma_qp_offset_list_len_minus1 >= 5) {
av_log(avctx, AV_LOG_ERROR,
"chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i <= pps->chroma_qp_offset_list_len_minus1; i++) {
pps->cb_qp_offset_list[i] = get_se_golomb_long(gb);
if (pps->cb_qp_offset_list[i]) {
av_log(avctx, AV_LOG_WARNING,
"cb_qp_offset_list not tested yet.\n");
}
pps->cr_qp_offset_list[i] = get_se_golomb_long(gb);
if (pps->cr_qp_offset_list[i]) {
av_log(avctx, AV_LOG_WARNING,
"cb_qp_offset_list not tested yet.\n");
}
}
}
pps->log2_sao_offset_scale_luma = get_ue_golomb_long(gb);
pps->log2_sao_offset_scale_chroma = get_ue_golomb_long(gb);
return(0);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(GetBitContext *VAR_0, AVCodecContext *VAR_1,
HEVCPPS *VAR_2, HEVCSPS *VAR_3) {
int VAR_4;
if (VAR_2->transform_skip_enabled_flag) {
VAR_2->log2_max_transform_skip_block_size = get_ue_golomb_long(VAR_0) + 2;
}
VAR_2->cross_component_prediction_enabled_flag = get_bits1(VAR_0);
VAR_2->chroma_qp_offset_list_enabled_flag = get_bits1(VAR_0);
if (VAR_2->chroma_qp_offset_list_enabled_flag) {
VAR_2->diff_cu_chroma_qp_offset_depth = get_ue_golomb_long(VAR_0);
VAR_2->chroma_qp_offset_list_len_minus1 = get_ue_golomb_long(VAR_0);
if (VAR_2->chroma_qp_offset_list_len_minus1 && VAR_2->chroma_qp_offset_list_len_minus1 >= 5) {
av_log(VAR_1, AV_LOG_ERROR,
"chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n");
return AVERROR_INVALIDDATA;
}
for (VAR_4 = 0; VAR_4 <= VAR_2->chroma_qp_offset_list_len_minus1; VAR_4++) {
VAR_2->cb_qp_offset_list[VAR_4] = get_se_golomb_long(VAR_0);
if (VAR_2->cb_qp_offset_list[VAR_4]) {
av_log(VAR_1, AV_LOG_WARNING,
"cb_qp_offset_list not tested yet.\n");
}
VAR_2->cr_qp_offset_list[VAR_4] = get_se_golomb_long(VAR_0);
if (VAR_2->cr_qp_offset_list[VAR_4]) {
av_log(VAR_1, AV_LOG_WARNING,
"cb_qp_offset_list not tested yet.\n");
}
}
}
VAR_2->log2_sao_offset_scale_luma = get_ue_golomb_long(VAR_0);
VAR_2->log2_sao_offset_scale_chroma = get_ue_golomb_long(VAR_0);
return(0);
}
| [
"static int FUNC_0(GetBitContext *VAR_0, AVCodecContext *VAR_1,\nHEVCPPS *VAR_2, HEVCSPS *VAR_3) {",
"int VAR_4;",
"if (VAR_2->transform_skip_enabled_flag) {",
"VAR_2->log2_max_transform_skip_block_size = get_ue_golomb_long(VAR_0) + 2;",
"}",
"VAR_2->cross_component_prediction_enabled_flag = get_bits1(VAR_0);",
"VAR_2->chroma_qp_offset_list_enabled_flag = get_bits1(VAR_0);",
"if (VAR_2->chroma_qp_offset_list_enabled_flag) {",
"VAR_2->diff_cu_chroma_qp_offset_depth = get_ue_golomb_long(VAR_0);",
"VAR_2->chroma_qp_offset_list_len_minus1 = get_ue_golomb_long(VAR_0);",
"if (VAR_2->chroma_qp_offset_list_len_minus1 && VAR_2->chroma_qp_offset_list_len_minus1 >= 5) {",
"av_log(VAR_1, AV_LOG_ERROR,\n\"chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"for (VAR_4 = 0; VAR_4 <= VAR_2->chroma_qp_offset_list_len_minus1; VAR_4++) {",
"VAR_2->cb_qp_offset_list[VAR_4] = get_se_golomb_long(VAR_0);",
"if (VAR_2->cb_qp_offset_list[VAR_4]) {",
"av_log(VAR_1, AV_LOG_WARNING,\n\"cb_qp_offset_list not tested yet.\\n\");",
"}",
"VAR_2->cr_qp_offset_list[VAR_4] = get_se_golomb_long(VAR_0);",
"if (VAR_2->cr_qp_offset_list[VAR_4]) {",
"av_log(VAR_1, AV_LOG_WARNING,\n\"cb_qp_offset_list not tested yet.\\n\");",
"}",
"}",
"}",
"VAR_2->log2_sao_offset_scale_luma = get_ue_golomb_long(VAR_0);",
"VAR_2->log2_sao_offset_scale_chroma = get_ue_golomb_long(VAR_0);",
"return(0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
]
] |
22,824 | av_cold int ff_wma_init(AVCodecContext *avctx, int flags2)
{
WMACodecContext *s = avctx->priv_data;
int i;
float bps1, high_freq;
volatile float bps;
int sample_rate1;
int coef_vlc_table;
if (avctx->sample_rate <= 0 || avctx->sample_rate > 50000 ||
avctx->channels <= 0 || avctx->channels > 2 ||
avctx->bit_rate <= 0)
return -1;
ff_fmt_convert_init(&s->fmt_conv, avctx);
avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
if (avctx->codec->id == AV_CODEC_ID_WMAV1)
s->version = 1;
else
s->version = 2;
/* compute MDCT block size */
s->frame_len_bits = ff_wma_get_frame_len_bits(avctx->sample_rate,
s->version, 0);
s->next_block_len_bits = s->frame_len_bits;
s->prev_block_len_bits = s->frame_len_bits;
s->block_len_bits = s->frame_len_bits;
s->frame_len = 1 << s->frame_len_bits;
if (s->use_variable_block_len) {
int nb_max, nb;
nb = ((flags2 >> 3) & 3) + 1;
if ((avctx->bit_rate / avctx->channels) >= 32000)
nb += 2;
nb_max = s->frame_len_bits - BLOCK_MIN_BITS;
if (nb > nb_max)
nb = nb_max;
s->nb_block_sizes = nb + 1;
} else
s->nb_block_sizes = 1;
/* init rate dependent parameters */
s->use_noise_coding = 1;
high_freq = avctx->sample_rate * 0.5;
/* if version 2, then the rates are normalized */
sample_rate1 = avctx->sample_rate;
if (s->version == 2) {
if (sample_rate1 >= 44100)
sample_rate1 = 44100;
else if (sample_rate1 >= 22050)
sample_rate1 = 22050;
else if (sample_rate1 >= 16000)
sample_rate1 = 16000;
else if (sample_rate1 >= 11025)
sample_rate1 = 11025;
else if (sample_rate1 >= 8000)
sample_rate1 = 8000;
}
bps = (float) avctx->bit_rate /
(float) (avctx->channels * avctx->sample_rate);
s->byte_offset_bits = av_log2((int) (bps * s->frame_len / 8.0 + 0.5)) + 2;
/* compute high frequency value and choose if noise coding should
* be activated */
bps1 = bps;
if (avctx->channels == 2)
bps1 = bps * 1.6;
if (sample_rate1 == 44100) {
if (bps1 >= 0.61)
s->use_noise_coding = 0;
else
high_freq = high_freq * 0.4;
} else if (sample_rate1 == 22050) {
if (bps1 >= 1.16)
s->use_noise_coding = 0;
else if (bps1 >= 0.72)
high_freq = high_freq * 0.7;
else
high_freq = high_freq * 0.6;
} else if (sample_rate1 == 16000) {
if (bps > 0.5)
high_freq = high_freq * 0.5;
else
high_freq = high_freq * 0.3;
} else if (sample_rate1 == 11025)
high_freq = high_freq * 0.7;
else if (sample_rate1 == 8000) {
if (bps <= 0.625)
high_freq = high_freq * 0.5;
else if (bps > 0.75)
s->use_noise_coding = 0;
else
high_freq = high_freq * 0.65;
} else {
if (bps >= 0.8)
high_freq = high_freq * 0.75;
else if (bps >= 0.6)
high_freq = high_freq * 0.6;
else
high_freq = high_freq * 0.5;
}
av_dlog(s->avctx, "flags2=0x%x\n", flags2);
av_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
s->version, avctx->channels, avctx->sample_rate, avctx->bit_rate,
avctx->block_align);
av_dlog(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
bps, bps1, high_freq, s->byte_offset_bits);
av_dlog(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
/* compute the scale factor band sizes for each MDCT block size */
{
int a, b, pos, lpos, k, block_len, i, j, n;
const uint8_t *table;
if (s->version == 1)
s->coefs_start = 3;
else
s->coefs_start = 0;
for (k = 0; k < s->nb_block_sizes; k++) {
block_len = s->frame_len >> k;
if (s->version == 1) {
lpos = 0;
for (i = 0; i < 25; i++) {
a = ff_wma_critical_freqs[i];
b = avctx->sample_rate;
pos = ((block_len * 2 * a) + (b >> 1)) / b;
if (pos > block_len)
pos = block_len;
s->exponent_bands[0][i] = pos - lpos;
if (pos >= block_len) {
i++;
break;
}
lpos = pos;
}
s->exponent_sizes[0] = i;
} else {
/* hardcoded tables */
table = NULL;
a = s->frame_len_bits - BLOCK_MIN_BITS - k;
if (a < 3) {
if (avctx->sample_rate >= 44100)
table = exponent_band_44100[a];
else if (avctx->sample_rate >= 32000)
table = exponent_band_32000[a];
else if (avctx->sample_rate >= 22050)
table = exponent_band_22050[a];
}
if (table) {
n = *table++;
for (i = 0; i < n; i++)
s->exponent_bands[k][i] = table[i];
s->exponent_sizes[k] = n;
} else {
j = 0;
lpos = 0;
for (i = 0; i < 25; i++) {
a = ff_wma_critical_freqs[i];
b = avctx->sample_rate;
pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
pos <<= 2;
if (pos > block_len)
pos = block_len;
if (pos > lpos)
s->exponent_bands[k][j++] = pos - lpos;
if (pos >= block_len)
break;
lpos = pos;
}
s->exponent_sizes[k] = j;
}
}
/* max number of coefs */
s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
/* high freq computation */
s->high_band_start[k] = (int) ((block_len * 2 * high_freq) /
avctx->sample_rate + 0.5);
n = s->exponent_sizes[k];
j = 0;
pos = 0;
for (i = 0; i < n; i++) {
int start, end;
start = pos;
pos += s->exponent_bands[k][i];
end = pos;
if (start < s->high_band_start[k])
start = s->high_band_start[k];
if (end > s->coefs_end[k])
end = s->coefs_end[k];
if (end > start)
s->exponent_high_bands[k][j++] = end - start;
}
s->exponent_high_sizes[k] = j;
#if 0
tprintf(s->avctx, "%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
s->frame_len >> k,
s->coefs_end[k],
s->high_band_start[k],
s->exponent_high_sizes[k]);
for (j = 0; j < s->exponent_high_sizes[k]; j++)
tprintf(s->avctx, " %d", s->exponent_high_bands[k][j]);
tprintf(s->avctx, "\n");
#endif /* 0 */
}
}
#ifdef TRACE
{
int i, j;
for (i = 0; i < s->nb_block_sizes; i++) {
tprintf(s->avctx, "%5d: n=%2d:",
s->frame_len >> i,
s->exponent_sizes[i]);
for (j = 0; j < s->exponent_sizes[i]; j++)
tprintf(s->avctx, " %d", s->exponent_bands[i][j]);
tprintf(s->avctx, "\n");
}
}
#endif /* TRACE */
/* init MDCT windows : simple sine window */
for (i = 0; i < s->nb_block_sizes; i++) {
ff_init_ff_sine_windows(s->frame_len_bits - i);
s->windows[i] = ff_sine_windows[s->frame_len_bits - i];
}
s->reset_block_lengths = 1;
if (s->use_noise_coding) {
/* init the noise generator */
if (s->use_exp_vlc)
s->noise_mult = 0.02;
else
s->noise_mult = 0.04;
#ifdef TRACE
for (i = 0; i < NOISE_TAB_SIZE; i++)
s->noise_table[i] = 1.0 * s->noise_mult;
#else
{
unsigned int seed;
float norm;
seed = 1;
norm = (1.0 / (float) (1LL << 31)) * sqrt(3) * s->noise_mult;
for (i = 0; i < NOISE_TAB_SIZE; i++) {
seed = seed * 314159 + 1;
s->noise_table[i] = (float) ((int) seed) * norm;
}
}
#endif /* TRACE */
}
/* choose the VLC tables for the coefficients */
coef_vlc_table = 2;
if (avctx->sample_rate >= 32000) {
if (bps1 < 0.72)
coef_vlc_table = 0;
else if (bps1 < 1.16)
coef_vlc_table = 1;
}
s->coef_vlcs[0] = &coef_vlcs[coef_vlc_table * 2];
s->coef_vlcs[1] = &coef_vlcs[coef_vlc_table * 2 + 1];
init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],
&s->int_table[0], s->coef_vlcs[0]);
init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
&s->int_table[1], s->coef_vlcs[1]);
return 0;
}
| false | FFmpeg | 596b5c488fa1d40f114a64d3b73e1863cab073fb | av_cold int ff_wma_init(AVCodecContext *avctx, int flags2)
{
WMACodecContext *s = avctx->priv_data;
int i;
float bps1, high_freq;
volatile float bps;
int sample_rate1;
int coef_vlc_table;
if (avctx->sample_rate <= 0 || avctx->sample_rate > 50000 ||
avctx->channels <= 0 || avctx->channels > 2 ||
avctx->bit_rate <= 0)
return -1;
ff_fmt_convert_init(&s->fmt_conv, avctx);
avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
if (avctx->codec->id == AV_CODEC_ID_WMAV1)
s->version = 1;
else
s->version = 2;
s->frame_len_bits = ff_wma_get_frame_len_bits(avctx->sample_rate,
s->version, 0);
s->next_block_len_bits = s->frame_len_bits;
s->prev_block_len_bits = s->frame_len_bits;
s->block_len_bits = s->frame_len_bits;
s->frame_len = 1 << s->frame_len_bits;
if (s->use_variable_block_len) {
int nb_max, nb;
nb = ((flags2 >> 3) & 3) + 1;
if ((avctx->bit_rate / avctx->channels) >= 32000)
nb += 2;
nb_max = s->frame_len_bits - BLOCK_MIN_BITS;
if (nb > nb_max)
nb = nb_max;
s->nb_block_sizes = nb + 1;
} else
s->nb_block_sizes = 1;
s->use_noise_coding = 1;
high_freq = avctx->sample_rate * 0.5;
sample_rate1 = avctx->sample_rate;
if (s->version == 2) {
if (sample_rate1 >= 44100)
sample_rate1 = 44100;
else if (sample_rate1 >= 22050)
sample_rate1 = 22050;
else if (sample_rate1 >= 16000)
sample_rate1 = 16000;
else if (sample_rate1 >= 11025)
sample_rate1 = 11025;
else if (sample_rate1 >= 8000)
sample_rate1 = 8000;
}
bps = (float) avctx->bit_rate /
(float) (avctx->channels * avctx->sample_rate);
s->byte_offset_bits = av_log2((int) (bps * s->frame_len / 8.0 + 0.5)) + 2;
bps1 = bps;
if (avctx->channels == 2)
bps1 = bps * 1.6;
if (sample_rate1 == 44100) {
if (bps1 >= 0.61)
s->use_noise_coding = 0;
else
high_freq = high_freq * 0.4;
} else if (sample_rate1 == 22050) {
if (bps1 >= 1.16)
s->use_noise_coding = 0;
else if (bps1 >= 0.72)
high_freq = high_freq * 0.7;
else
high_freq = high_freq * 0.6;
} else if (sample_rate1 == 16000) {
if (bps > 0.5)
high_freq = high_freq * 0.5;
else
high_freq = high_freq * 0.3;
} else if (sample_rate1 == 11025)
high_freq = high_freq * 0.7;
else if (sample_rate1 == 8000) {
if (bps <= 0.625)
high_freq = high_freq * 0.5;
else if (bps > 0.75)
s->use_noise_coding = 0;
else
high_freq = high_freq * 0.65;
} else {
if (bps >= 0.8)
high_freq = high_freq * 0.75;
else if (bps >= 0.6)
high_freq = high_freq * 0.6;
else
high_freq = high_freq * 0.5;
}
av_dlog(s->avctx, "flags2=0x%x\n", flags2);
av_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
s->version, avctx->channels, avctx->sample_rate, avctx->bit_rate,
avctx->block_align);
av_dlog(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
bps, bps1, high_freq, s->byte_offset_bits);
av_dlog(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
{
int a, b, pos, lpos, k, block_len, i, j, n;
const uint8_t *table;
if (s->version == 1)
s->coefs_start = 3;
else
s->coefs_start = 0;
for (k = 0; k < s->nb_block_sizes; k++) {
block_len = s->frame_len >> k;
if (s->version == 1) {
lpos = 0;
for (i = 0; i < 25; i++) {
a = ff_wma_critical_freqs[i];
b = avctx->sample_rate;
pos = ((block_len * 2 * a) + (b >> 1)) / b;
if (pos > block_len)
pos = block_len;
s->exponent_bands[0][i] = pos - lpos;
if (pos >= block_len) {
i++;
break;
}
lpos = pos;
}
s->exponent_sizes[0] = i;
} else {
table = NULL;
a = s->frame_len_bits - BLOCK_MIN_BITS - k;
if (a < 3) {
if (avctx->sample_rate >= 44100)
table = exponent_band_44100[a];
else if (avctx->sample_rate >= 32000)
table = exponent_band_32000[a];
else if (avctx->sample_rate >= 22050)
table = exponent_band_22050[a];
}
if (table) {
n = *table++;
for (i = 0; i < n; i++)
s->exponent_bands[k][i] = table[i];
s->exponent_sizes[k] = n;
} else {
j = 0;
lpos = 0;
for (i = 0; i < 25; i++) {
a = ff_wma_critical_freqs[i];
b = avctx->sample_rate;
pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
pos <<= 2;
if (pos > block_len)
pos = block_len;
if (pos > lpos)
s->exponent_bands[k][j++] = pos - lpos;
if (pos >= block_len)
break;
lpos = pos;
}
s->exponent_sizes[k] = j;
}
}
s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
s->high_band_start[k] = (int) ((block_len * 2 * high_freq) /
avctx->sample_rate + 0.5);
n = s->exponent_sizes[k];
j = 0;
pos = 0;
for (i = 0; i < n; i++) {
int start, end;
start = pos;
pos += s->exponent_bands[k][i];
end = pos;
if (start < s->high_band_start[k])
start = s->high_band_start[k];
if (end > s->coefs_end[k])
end = s->coefs_end[k];
if (end > start)
s->exponent_high_bands[k][j++] = end - start;
}
s->exponent_high_sizes[k] = j;
#if 0
tprintf(s->avctx, "%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
s->frame_len >> k,
s->coefs_end[k],
s->high_band_start[k],
s->exponent_high_sizes[k]);
for (j = 0; j < s->exponent_high_sizes[k]; j++)
tprintf(s->avctx, " %d", s->exponent_high_bands[k][j]);
tprintf(s->avctx, "\n");
#endif
}
}
#ifdef TRACE
{
int i, j;
for (i = 0; i < s->nb_block_sizes; i++) {
tprintf(s->avctx, "%5d: n=%2d:",
s->frame_len >> i,
s->exponent_sizes[i]);
for (j = 0; j < s->exponent_sizes[i]; j++)
tprintf(s->avctx, " %d", s->exponent_bands[i][j]);
tprintf(s->avctx, "\n");
}
}
#endif
for (i = 0; i < s->nb_block_sizes; i++) {
ff_init_ff_sine_windows(s->frame_len_bits - i);
s->windows[i] = ff_sine_windows[s->frame_len_bits - i];
}
s->reset_block_lengths = 1;
if (s->use_noise_coding) {
if (s->use_exp_vlc)
s->noise_mult = 0.02;
else
s->noise_mult = 0.04;
#ifdef TRACE
for (i = 0; i < NOISE_TAB_SIZE; i++)
s->noise_table[i] = 1.0 * s->noise_mult;
#else
{
unsigned int seed;
float norm;
seed = 1;
norm = (1.0 / (float) (1LL << 31)) * sqrt(3) * s->noise_mult;
for (i = 0; i < NOISE_TAB_SIZE; i++) {
seed = seed * 314159 + 1;
s->noise_table[i] = (float) ((int) seed) * norm;
}
}
#endif
}
coef_vlc_table = 2;
if (avctx->sample_rate >= 32000) {
if (bps1 < 0.72)
coef_vlc_table = 0;
else if (bps1 < 1.16)
coef_vlc_table = 1;
}
s->coef_vlcs[0] = &coef_vlcs[coef_vlc_table * 2];
s->coef_vlcs[1] = &coef_vlcs[coef_vlc_table * 2 + 1];
init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],
&s->int_table[0], s->coef_vlcs[0]);
init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
&s->int_table[1], s->coef_vlcs[1]);
return 0;
}
| {
"code": [],
"line_no": []
} | av_cold int FUNC_0(AVCodecContext *avctx, int flags2)
{
WMACodecContext *s = avctx->priv_data;
int VAR_14;
float VAR_1, VAR_2;
volatile float VAR_3;
int VAR_4;
int VAR_5;
if (avctx->sample_rate <= 0 || avctx->sample_rate > 50000 ||
avctx->channels <= 0 || avctx->channels > 2 ||
avctx->bit_rate <= 0)
return -1;
ff_fmt_convert_init(&s->fmt_conv, avctx);
avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
if (avctx->codec->id == AV_CODEC_ID_WMAV1)
s->version = 1;
else
s->version = 2;
s->frame_len_bits = ff_wma_get_frame_len_bits(avctx->sample_rate,
s->version, 0);
s->next_block_len_bits = s->frame_len_bits;
s->prev_block_len_bits = s->frame_len_bits;
s->block_len_bits = s->frame_len_bits;
s->frame_len = 1 << s->frame_len_bits;
if (s->use_variable_block_len) {
int VAR_6, VAR_7;
VAR_7 = ((flags2 >> 3) & 3) + 1;
if ((avctx->bit_rate / avctx->channels) >= 32000)
VAR_7 += 2;
VAR_6 = s->frame_len_bits - BLOCK_MIN_BITS;
if (VAR_7 > VAR_6)
VAR_7 = VAR_6;
s->nb_block_sizes = VAR_7 + 1;
} else
s->nb_block_sizes = 1;
s->use_noise_coding = 1;
VAR_2 = avctx->sample_rate * 0.5;
VAR_4 = avctx->sample_rate;
if (s->version == 2) {
if (VAR_4 >= 44100)
VAR_4 = 44100;
else if (VAR_4 >= 22050)
VAR_4 = 22050;
else if (VAR_4 >= 16000)
VAR_4 = 16000;
else if (VAR_4 >= 11025)
VAR_4 = 11025;
else if (VAR_4 >= 8000)
VAR_4 = 8000;
}
VAR_3 = (float) avctx->bit_rate /
(float) (avctx->channels * avctx->sample_rate);
s->byte_offset_bits = av_log2((int) (VAR_3 * s->frame_len / 8.0 + 0.5)) + 2;
VAR_1 = VAR_3;
if (avctx->channels == 2)
VAR_1 = VAR_3 * 1.6;
if (VAR_4 == 44100) {
if (VAR_1 >= 0.61)
s->use_noise_coding = 0;
else
VAR_2 = VAR_2 * 0.4;
} else if (VAR_4 == 22050) {
if (VAR_1 >= 1.16)
s->use_noise_coding = 0;
else if (VAR_1 >= 0.72)
VAR_2 = VAR_2 * 0.7;
else
VAR_2 = VAR_2 * 0.6;
} else if (VAR_4 == 16000) {
if (VAR_3 > 0.5)
VAR_2 = VAR_2 * 0.5;
else
VAR_2 = VAR_2 * 0.3;
} else if (VAR_4 == 11025)
VAR_2 = VAR_2 * 0.7;
else if (VAR_4 == 8000) {
if (VAR_3 <= 0.625)
VAR_2 = VAR_2 * 0.5;
else if (VAR_3 > 0.75)
s->use_noise_coding = 0;
else
VAR_2 = VAR_2 * 0.65;
} else {
if (VAR_3 >= 0.8)
VAR_2 = VAR_2 * 0.75;
else if (VAR_3 >= 0.6)
VAR_2 = VAR_2 * 0.6;
else
VAR_2 = VAR_2 * 0.5;
}
av_dlog(s->avctx, "flags2=0x%x\VAR_15", flags2);
av_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\VAR_15",
s->version, avctx->channels, avctx->sample_rate, avctx->bit_rate,
avctx->block_align);
av_dlog(s->avctx, "VAR_3=%f VAR_1=%f VAR_2=%f bitoffset=%d\VAR_15",
VAR_3, VAR_1, VAR_2, s->byte_offset_bits);
av_dlog(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\VAR_15",
s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
{
int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_14, VAR_15;
const uint8_t *VAR_16;
if (s->version == 1)
s->coefs_start = 3;
else
s->coefs_start = 0;
for (VAR_12 = 0; VAR_12 < s->nb_block_sizes; VAR_12++) {
VAR_13 = s->frame_len >> VAR_12;
if (s->version == 1) {
VAR_11 = 0;
for (VAR_14 = 0; VAR_14 < 25; VAR_14++) {
VAR_8 = ff_wma_critical_freqs[VAR_14];
VAR_9 = avctx->sample_rate;
VAR_10 = ((VAR_13 * 2 * VAR_8) + (VAR_9 >> 1)) / VAR_9;
if (VAR_10 > VAR_13)
VAR_10 = VAR_13;
s->exponent_bands[0][VAR_14] = VAR_10 - VAR_11;
if (VAR_10 >= VAR_13) {
VAR_14++;
break;
}
VAR_11 = VAR_10;
}
s->exponent_sizes[0] = VAR_14;
} else {
VAR_16 = NULL;
VAR_8 = s->frame_len_bits - BLOCK_MIN_BITS - VAR_12;
if (VAR_8 < 3) {
if (avctx->sample_rate >= 44100)
VAR_16 = exponent_band_44100[VAR_8];
else if (avctx->sample_rate >= 32000)
VAR_16 = exponent_band_32000[VAR_8];
else if (avctx->sample_rate >= 22050)
VAR_16 = exponent_band_22050[VAR_8];
}
if (VAR_16) {
VAR_15 = *VAR_16++;
for (VAR_14 = 0; VAR_14 < VAR_15; VAR_14++)
s->exponent_bands[VAR_12][VAR_14] = VAR_16[VAR_14];
s->exponent_sizes[VAR_12] = VAR_15;
} else {
VAR_14 = 0;
VAR_11 = 0;
for (VAR_14 = 0; VAR_14 < 25; VAR_14++) {
VAR_8 = ff_wma_critical_freqs[VAR_14];
VAR_9 = avctx->sample_rate;
VAR_10 = ((VAR_13 * 2 * VAR_8) + (VAR_9 << 1)) / (4 * VAR_9);
VAR_10 <<= 2;
if (VAR_10 > VAR_13)
VAR_10 = VAR_13;
if (VAR_10 > VAR_11)
s->exponent_bands[VAR_12][VAR_14++] = VAR_10 - VAR_11;
if (VAR_10 >= VAR_13)
break;
VAR_11 = VAR_10;
}
s->exponent_sizes[VAR_12] = VAR_14;
}
}
s->coefs_end[VAR_12] = (s->frame_len - ((s->frame_len * 9) / 100)) >> VAR_12;
s->high_band_start[VAR_12] = (int) ((VAR_13 * 2 * VAR_2) /
avctx->sample_rate + 0.5);
VAR_15 = s->exponent_sizes[VAR_12];
VAR_14 = 0;
VAR_10 = 0;
for (VAR_14 = 0; VAR_14 < VAR_15; VAR_14++) {
int start, end;
start = VAR_10;
VAR_10 += s->exponent_bands[VAR_12][VAR_14];
end = VAR_10;
if (start < s->high_band_start[VAR_12])
start = s->high_band_start[VAR_12];
if (end > s->coefs_end[VAR_12])
end = s->coefs_end[VAR_12];
if (end > start)
s->exponent_high_bands[VAR_12][VAR_14++] = end - start;
}
s->exponent_high_sizes[VAR_12] = VAR_14;
#if 0
tprintf(s->avctx, "%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
s->frame_len >> VAR_12,
s->coefs_end[VAR_12],
s->high_band_start[VAR_12],
s->exponent_high_sizes[VAR_12]);
for (VAR_14 = 0; VAR_14 < s->exponent_high_sizes[VAR_12]; VAR_14++)
tprintf(s->avctx, " %d", s->exponent_high_bands[VAR_12][VAR_14]);
tprintf(s->avctx, "\VAR_15");
#endif
}
}
#ifdef TRACE
{
int VAR_14, VAR_14;
for (VAR_14 = 0; VAR_14 < s->nb_block_sizes; VAR_14++) {
tprintf(s->avctx, "%5d: VAR_15=%2d:",
s->frame_len >> VAR_14,
s->exponent_sizes[VAR_14]);
for (VAR_14 = 0; VAR_14 < s->exponent_sizes[VAR_14]; VAR_14++)
tprintf(s->avctx, " %d", s->exponent_bands[VAR_14][VAR_14]);
tprintf(s->avctx, "\VAR_15");
}
}
#endif
for (VAR_14 = 0; VAR_14 < s->nb_block_sizes; VAR_14++) {
ff_init_ff_sine_windows(s->frame_len_bits - VAR_14);
s->windows[VAR_14] = ff_sine_windows[s->frame_len_bits - VAR_14];
}
s->reset_block_lengths = 1;
if (s->use_noise_coding) {
if (s->use_exp_vlc)
s->noise_mult = 0.02;
else
s->noise_mult = 0.04;
#ifdef TRACE
for (VAR_14 = 0; VAR_14 < NOISE_TAB_SIZE; VAR_14++)
s->noise_table[VAR_14] = 1.0 * s->noise_mult;
#else
{
unsigned int VAR_17;
float VAR_18;
VAR_17 = 1;
VAR_18 = (1.0 / (float) (1LL << 31)) * sqrt(3) * s->noise_mult;
for (VAR_14 = 0; VAR_14 < NOISE_TAB_SIZE; VAR_14++) {
VAR_17 = VAR_17 * 314159 + 1;
s->noise_table[VAR_14] = (float) ((int) VAR_17) * VAR_18;
}
}
#endif
}
VAR_5 = 2;
if (avctx->sample_rate >= 32000) {
if (VAR_1 < 0.72)
VAR_5 = 0;
else if (VAR_1 < 1.16)
VAR_5 = 1;
}
s->coef_vlcs[0] = &coef_vlcs[VAR_5 * 2];
s->coef_vlcs[1] = &coef_vlcs[VAR_5 * 2 + 1];
init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],
&s->int_table[0], s->coef_vlcs[0]);
init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
&s->int_table[1], s->coef_vlcs[1]);
return 0;
}
| [
"av_cold int FUNC_0(AVCodecContext *avctx, int flags2)\n{",
"WMACodecContext *s = avctx->priv_data;",
"int VAR_14;",
"float VAR_1, VAR_2;",
"volatile float VAR_3;",
"int VAR_4;",
"int VAR_5;",
"if (avctx->sample_rate <= 0 || avctx->sample_rate > 50000 ||\navctx->channels <= 0 || avctx->channels > 2 ||\navctx->bit_rate <= 0)\nreturn -1;",
"ff_fmt_convert_init(&s->fmt_conv, avctx);",
"avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);",
"if (avctx->codec->id == AV_CODEC_ID_WMAV1)\ns->version = 1;",
"else\ns->version = 2;",
"s->frame_len_bits = ff_wma_get_frame_len_bits(avctx->sample_rate,\ns->version, 0);",
"s->next_block_len_bits = s->frame_len_bits;",
"s->prev_block_len_bits = s->frame_len_bits;",
"s->block_len_bits = s->frame_len_bits;",
"s->frame_len = 1 << s->frame_len_bits;",
"if (s->use_variable_block_len) {",
"int VAR_6, VAR_7;",
"VAR_7 = ((flags2 >> 3) & 3) + 1;",
"if ((avctx->bit_rate / avctx->channels) >= 32000)\nVAR_7 += 2;",
"VAR_6 = s->frame_len_bits - BLOCK_MIN_BITS;",
"if (VAR_7 > VAR_6)\nVAR_7 = VAR_6;",
"s->nb_block_sizes = VAR_7 + 1;",
"} else",
"s->nb_block_sizes = 1;",
"s->use_noise_coding = 1;",
"VAR_2 = avctx->sample_rate * 0.5;",
"VAR_4 = avctx->sample_rate;",
"if (s->version == 2) {",
"if (VAR_4 >= 44100)\nVAR_4 = 44100;",
"else if (VAR_4 >= 22050)\nVAR_4 = 22050;",
"else if (VAR_4 >= 16000)\nVAR_4 = 16000;",
"else if (VAR_4 >= 11025)\nVAR_4 = 11025;",
"else if (VAR_4 >= 8000)\nVAR_4 = 8000;",
"}",
"VAR_3 = (float) avctx->bit_rate /\n(float) (avctx->channels * avctx->sample_rate);",
"s->byte_offset_bits = av_log2((int) (VAR_3 * s->frame_len / 8.0 + 0.5)) + 2;",
"VAR_1 = VAR_3;",
"if (avctx->channels == 2)\nVAR_1 = VAR_3 * 1.6;",
"if (VAR_4 == 44100) {",
"if (VAR_1 >= 0.61)\ns->use_noise_coding = 0;",
"else\nVAR_2 = VAR_2 * 0.4;",
"} else if (VAR_4 == 22050) {",
"if (VAR_1 >= 1.16)\ns->use_noise_coding = 0;",
"else if (VAR_1 >= 0.72)\nVAR_2 = VAR_2 * 0.7;",
"else\nVAR_2 = VAR_2 * 0.6;",
"} else if (VAR_4 == 16000) {",
"if (VAR_3 > 0.5)\nVAR_2 = VAR_2 * 0.5;",
"else\nVAR_2 = VAR_2 * 0.3;",
"} else if (VAR_4 == 11025)",
"VAR_2 = VAR_2 * 0.7;",
"else if (VAR_4 == 8000) {",
"if (VAR_3 <= 0.625)\nVAR_2 = VAR_2 * 0.5;",
"else if (VAR_3 > 0.75)\ns->use_noise_coding = 0;",
"else\nVAR_2 = VAR_2 * 0.65;",
"} else {",
"if (VAR_3 >= 0.8)\nVAR_2 = VAR_2 * 0.75;",
"else if (VAR_3 >= 0.6)\nVAR_2 = VAR_2 * 0.6;",
"else\nVAR_2 = VAR_2 * 0.5;",
"}",
"av_dlog(s->avctx, \"flags2=0x%x\\VAR_15\", flags2);",
"av_dlog(s->avctx, \"version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\\VAR_15\",\ns->version, avctx->channels, avctx->sample_rate, avctx->bit_rate,\navctx->block_align);",
"av_dlog(s->avctx, \"VAR_3=%f VAR_1=%f VAR_2=%f bitoffset=%d\\VAR_15\",\nVAR_3, VAR_1, VAR_2, s->byte_offset_bits);",
"av_dlog(s->avctx, \"use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\\VAR_15\",\ns->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);",
"{",
"int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_14, VAR_15;",
"const uint8_t *VAR_16;",
"if (s->version == 1)\ns->coefs_start = 3;",
"else\ns->coefs_start = 0;",
"for (VAR_12 = 0; VAR_12 < s->nb_block_sizes; VAR_12++) {",
"VAR_13 = s->frame_len >> VAR_12;",
"if (s->version == 1) {",
"VAR_11 = 0;",
"for (VAR_14 = 0; VAR_14 < 25; VAR_14++) {",
"VAR_8 = ff_wma_critical_freqs[VAR_14];",
"VAR_9 = avctx->sample_rate;",
"VAR_10 = ((VAR_13 * 2 * VAR_8) + (VAR_9 >> 1)) / VAR_9;",
"if (VAR_10 > VAR_13)\nVAR_10 = VAR_13;",
"s->exponent_bands[0][VAR_14] = VAR_10 - VAR_11;",
"if (VAR_10 >= VAR_13) {",
"VAR_14++;",
"break;",
"}",
"VAR_11 = VAR_10;",
"}",
"s->exponent_sizes[0] = VAR_14;",
"} else {",
"VAR_16 = NULL;",
"VAR_8 = s->frame_len_bits - BLOCK_MIN_BITS - VAR_12;",
"if (VAR_8 < 3) {",
"if (avctx->sample_rate >= 44100)\nVAR_16 = exponent_band_44100[VAR_8];",
"else if (avctx->sample_rate >= 32000)\nVAR_16 = exponent_band_32000[VAR_8];",
"else if (avctx->sample_rate >= 22050)\nVAR_16 = exponent_band_22050[VAR_8];",
"}",
"if (VAR_16) {",
"VAR_15 = *VAR_16++;",
"for (VAR_14 = 0; VAR_14 < VAR_15; VAR_14++)",
"s->exponent_bands[VAR_12][VAR_14] = VAR_16[VAR_14];",
"s->exponent_sizes[VAR_12] = VAR_15;",
"} else {",
"VAR_14 = 0;",
"VAR_11 = 0;",
"for (VAR_14 = 0; VAR_14 < 25; VAR_14++) {",
"VAR_8 = ff_wma_critical_freqs[VAR_14];",
"VAR_9 = avctx->sample_rate;",
"VAR_10 = ((VAR_13 * 2 * VAR_8) + (VAR_9 << 1)) / (4 * VAR_9);",
"VAR_10 <<= 2;",
"if (VAR_10 > VAR_13)\nVAR_10 = VAR_13;",
"if (VAR_10 > VAR_11)\ns->exponent_bands[VAR_12][VAR_14++] = VAR_10 - VAR_11;",
"if (VAR_10 >= VAR_13)\nbreak;",
"VAR_11 = VAR_10;",
"}",
"s->exponent_sizes[VAR_12] = VAR_14;",
"}",
"}",
"s->coefs_end[VAR_12] = (s->frame_len - ((s->frame_len * 9) / 100)) >> VAR_12;",
"s->high_band_start[VAR_12] = (int) ((VAR_13 * 2 * VAR_2) /\navctx->sample_rate + 0.5);",
"VAR_15 = s->exponent_sizes[VAR_12];",
"VAR_14 = 0;",
"VAR_10 = 0;",
"for (VAR_14 = 0; VAR_14 < VAR_15; VAR_14++) {",
"int start, end;",
"start = VAR_10;",
"VAR_10 += s->exponent_bands[VAR_12][VAR_14];",
"end = VAR_10;",
"if (start < s->high_band_start[VAR_12])\nstart = s->high_band_start[VAR_12];",
"if (end > s->coefs_end[VAR_12])\nend = s->coefs_end[VAR_12];",
"if (end > start)\ns->exponent_high_bands[VAR_12][VAR_14++] = end - start;",
"}",
"s->exponent_high_sizes[VAR_12] = VAR_14;",
"#if 0\ntprintf(s->avctx, \"%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: \",\ns->frame_len >> VAR_12,\ns->coefs_end[VAR_12],\ns->high_band_start[VAR_12],\ns->exponent_high_sizes[VAR_12]);",
"for (VAR_14 = 0; VAR_14 < s->exponent_high_sizes[VAR_12]; VAR_14++)",
"tprintf(s->avctx, \" %d\", s->exponent_high_bands[VAR_12][VAR_14]);",
"tprintf(s->avctx, \"\\VAR_15\");",
"#endif\n}",
"}",
"#ifdef TRACE\n{",
"int VAR_14, VAR_14;",
"for (VAR_14 = 0; VAR_14 < s->nb_block_sizes; VAR_14++) {",
"tprintf(s->avctx, \"%5d: VAR_15=%2d:\",\ns->frame_len >> VAR_14,\ns->exponent_sizes[VAR_14]);",
"for (VAR_14 = 0; VAR_14 < s->exponent_sizes[VAR_14]; VAR_14++)",
"tprintf(s->avctx, \" %d\", s->exponent_bands[VAR_14][VAR_14]);",
"tprintf(s->avctx, \"\\VAR_15\");",
"}",
"}",
"#endif\nfor (VAR_14 = 0; VAR_14 < s->nb_block_sizes; VAR_14++) {",
"ff_init_ff_sine_windows(s->frame_len_bits - VAR_14);",
"s->windows[VAR_14] = ff_sine_windows[s->frame_len_bits - VAR_14];",
"}",
"s->reset_block_lengths = 1;",
"if (s->use_noise_coding) {",
"if (s->use_exp_vlc)\ns->noise_mult = 0.02;",
"else\ns->noise_mult = 0.04;",
"#ifdef TRACE\nfor (VAR_14 = 0; VAR_14 < NOISE_TAB_SIZE; VAR_14++)",
"s->noise_table[VAR_14] = 1.0 * s->noise_mult;",
"#else\n{",
"unsigned int VAR_17;",
"float VAR_18;",
"VAR_17 = 1;",
"VAR_18 = (1.0 / (float) (1LL << 31)) * sqrt(3) * s->noise_mult;",
"for (VAR_14 = 0; VAR_14 < NOISE_TAB_SIZE; VAR_14++) {",
"VAR_17 = VAR_17 * 314159 + 1;",
"s->noise_table[VAR_14] = (float) ((int) VAR_17) * VAR_18;",
"}",
"}",
"#endif\n}",
"VAR_5 = 2;",
"if (avctx->sample_rate >= 32000) {",
"if (VAR_1 < 0.72)\nVAR_5 = 0;",
"else if (VAR_1 < 1.16)\nVAR_5 = 1;",
"}",
"s->coef_vlcs[0] = &coef_vlcs[VAR_5 * 2];",
"s->coef_vlcs[1] = &coef_vlcs[VAR_5 * 2 + 1];",
"init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],\n&s->int_table[0], s->coef_vlcs[0]);",
"init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],\n&s->int_table[1], s->coef_vlcs[1]);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21,
23,
25
],
[
29
],
[
31
],
[
35,
37
],
[
39,
41
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99,
101
],
[
103,
105
],
[
107,
109
],
[
111,
113
],
[
115,
117
],
[
119
],
[
123,
125
],
[
127
],
[
135
],
[
137,
139
],
[
141
],
[
143,
145
],
[
147,
149
],
[
151
],
[
153,
155
],
[
157,
159
],
[
161,
163
],
[
165
],
[
167,
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181,
183
],
[
185,
187
],
[
189,
191
],
[
193
],
[
195,
197
],
[
199,
201
],
[
203,
205
],
[
207
],
[
209
],
[
211,
213,
215
],
[
217,
219
],
[
221,
223
],
[
229
],
[
231
],
[
233
],
[
237,
239
],
[
241,
243
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
293,
295
],
[
297,
299
],
[
301,
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333,
335
],
[
337,
339
],
[
341,
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
359
],
[
363,
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383,
385
],
[
387,
389
],
[
391,
393
],
[
395
],
[
397
],
[
399,
401,
403,
405,
407,
409
],
[
411
],
[
413
],
[
415
],
[
417,
419
],
[
421
],
[
425,
427
],
[
429
],
[
431
],
[
433,
435,
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449,
455
],
[
457
],
[
459
],
[
461
],
[
465
],
[
469
],
[
473,
475
],
[
477,
479
],
[
483,
485
],
[
487
],
[
489,
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511,
513
],
[
519
],
[
521
],
[
523,
525
],
[
527,
529
],
[
531
],
[
533
],
[
535
],
[
537,
539
],
[
541,
543
],
[
547
],
[
549
]
] |
22,827 | void ff_put_h264_qpel4_mc13_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hv_qrt_4w_msa(src + stride - 2,
src - (stride * 2), stride, dst, stride, 4);
}
| false | FFmpeg | 2aab7c2dfaca4386c38e5d565cd2bf73096bcc86 | void ff_put_h264_qpel4_mc13_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hv_qrt_4w_msa(src + stride - 2,
src - (stride * 2), stride, dst, stride, 4);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avc_luma_hv_qrt_4w_msa(VAR_1 + VAR_2 - 2,
VAR_1 - (VAR_2 * 2), VAR_2, VAR_0, VAR_2, 4);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_hv_qrt_4w_msa(VAR_1 + VAR_2 - 2,\nVAR_1 - (VAR_2 * 2), VAR_2, VAR_0, VAR_2, 4);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11
]
] |
22,829 | static int flv_same_audio_codec(AVCodecContext *acodec, int flags)
{
int bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
int flv_codecid = flags & FLV_AUDIO_CODECID_MASK;
int codec_id;
if (!acodec->codec_id && !acodec->codec_tag)
return 1;
if (acodec->bits_per_coded_sample != bits_per_coded_sample)
return 0;
switch(flv_codecid) {
//no distinction between S16 and S8 PCM codec flags
case FLV_CODECID_PCM:
codec_id = bits_per_coded_sample == 8 ? AV_CODEC_ID_PCM_U8 :
#if HAVE_BIGENDIAN
AV_CODEC_ID_PCM_S16BE;
#else
AV_CODEC_ID_PCM_S16LE;
#endif
return codec_id == acodec->codec_id;
case FLV_CODECID_PCM_LE:
codec_id = bits_per_coded_sample == 8 ? AV_CODEC_ID_PCM_U8 : AV_CODEC_ID_PCM_S16LE;
return codec_id == acodec->codec_id;
case FLV_CODECID_AAC:
return acodec->codec_id == AV_CODEC_ID_AAC;
case FLV_CODECID_ADPCM:
return acodec->codec_id == AV_CODEC_ID_ADPCM_SWF;
case FLV_CODECID_SPEEX:
return acodec->codec_id == AV_CODEC_ID_SPEEX;
case FLV_CODECID_MP3:
return acodec->codec_id == AV_CODEC_ID_MP3;
case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
case FLV_CODECID_NELLYMOSER_16KHZ_MONO:
case FLV_CODECID_NELLYMOSER:
return acodec->codec_id == AV_CODEC_ID_NELLYMOSER;
case FLV_CODECID_PCM_MULAW:
return acodec->sample_rate == 8000 &&
acodec->codec_id == AV_CODEC_ID_PCM_MULAW;
case FLV_CODECID_PCM_ALAW:
return acodec->sample_rate = 8000 &&
acodec->codec_id == AV_CODEC_ID_PCM_ALAW;
default:
return acodec->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
}
}
| false | FFmpeg | 390b4d7088b5cecace245fee0c54a57e24dabdf4 | static int flv_same_audio_codec(AVCodecContext *acodec, int flags)
{
int bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
int flv_codecid = flags & FLV_AUDIO_CODECID_MASK;
int codec_id;
if (!acodec->codec_id && !acodec->codec_tag)
return 1;
if (acodec->bits_per_coded_sample != bits_per_coded_sample)
return 0;
switch(flv_codecid) {
case FLV_CODECID_PCM:
codec_id = bits_per_coded_sample == 8 ? AV_CODEC_ID_PCM_U8 :
#if HAVE_BIGENDIAN
AV_CODEC_ID_PCM_S16BE;
#else
AV_CODEC_ID_PCM_S16LE;
#endif
return codec_id == acodec->codec_id;
case FLV_CODECID_PCM_LE:
codec_id = bits_per_coded_sample == 8 ? AV_CODEC_ID_PCM_U8 : AV_CODEC_ID_PCM_S16LE;
return codec_id == acodec->codec_id;
case FLV_CODECID_AAC:
return acodec->codec_id == AV_CODEC_ID_AAC;
case FLV_CODECID_ADPCM:
return acodec->codec_id == AV_CODEC_ID_ADPCM_SWF;
case FLV_CODECID_SPEEX:
return acodec->codec_id == AV_CODEC_ID_SPEEX;
case FLV_CODECID_MP3:
return acodec->codec_id == AV_CODEC_ID_MP3;
case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
case FLV_CODECID_NELLYMOSER_16KHZ_MONO:
case FLV_CODECID_NELLYMOSER:
return acodec->codec_id == AV_CODEC_ID_NELLYMOSER;
case FLV_CODECID_PCM_MULAW:
return acodec->sample_rate == 8000 &&
acodec->codec_id == AV_CODEC_ID_PCM_MULAW;
case FLV_CODECID_PCM_ALAW:
return acodec->sample_rate = 8000 &&
acodec->codec_id == AV_CODEC_ID_PCM_ALAW;
default:
return acodec->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, int VAR_1)
{
int VAR_2 = (VAR_1 & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
int VAR_3 = VAR_1 & FLV_AUDIO_CODECID_MASK;
int VAR_4;
if (!VAR_0->VAR_4 && !VAR_0->codec_tag)
return 1;
if (VAR_0->VAR_2 != VAR_2)
return 0;
switch(VAR_3) {
case FLV_CODECID_PCM:
VAR_4 = VAR_2 == 8 ? AV_CODEC_ID_PCM_U8 :
#if HAVE_BIGENDIAN
AV_CODEC_ID_PCM_S16BE;
#else
AV_CODEC_ID_PCM_S16LE;
#endif
return VAR_4 == VAR_0->VAR_4;
case FLV_CODECID_PCM_LE:
VAR_4 = VAR_2 == 8 ? AV_CODEC_ID_PCM_U8 : AV_CODEC_ID_PCM_S16LE;
return VAR_4 == VAR_0->VAR_4;
case FLV_CODECID_AAC:
return VAR_0->VAR_4 == AV_CODEC_ID_AAC;
case FLV_CODECID_ADPCM:
return VAR_0->VAR_4 == AV_CODEC_ID_ADPCM_SWF;
case FLV_CODECID_SPEEX:
return VAR_0->VAR_4 == AV_CODEC_ID_SPEEX;
case FLV_CODECID_MP3:
return VAR_0->VAR_4 == AV_CODEC_ID_MP3;
case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
case FLV_CODECID_NELLYMOSER_16KHZ_MONO:
case FLV_CODECID_NELLYMOSER:
return VAR_0->VAR_4 == AV_CODEC_ID_NELLYMOSER;
case FLV_CODECID_PCM_MULAW:
return VAR_0->sample_rate == 8000 &&
VAR_0->VAR_4 == AV_CODEC_ID_PCM_MULAW;
case FLV_CODECID_PCM_ALAW:
return VAR_0->sample_rate = 8000 &&
VAR_0->VAR_4 == AV_CODEC_ID_PCM_ALAW;
default:
return VAR_0->codec_tag == (VAR_3 >> FLV_AUDIO_CODECID_OFFSET);
}
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, int VAR_1)\n{",
"int VAR_2 = (VAR_1 & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;",
"int VAR_3 = VAR_1 & FLV_AUDIO_CODECID_MASK;",
"int VAR_4;",
"if (!VAR_0->VAR_4 && !VAR_0->codec_tag)\nreturn 1;",
"if (VAR_0->VAR_2 != VAR_2)\nreturn 0;",
"switch(VAR_3) {",
"case FLV_CODECID_PCM:\nVAR_4 = VAR_2 == 8 ? AV_CODEC_ID_PCM_U8 :\n#if HAVE_BIGENDIAN\nAV_CODEC_ID_PCM_S16BE;",
"#else\nAV_CODEC_ID_PCM_S16LE;",
"#endif\nreturn VAR_4 == VAR_0->VAR_4;",
"case FLV_CODECID_PCM_LE:\nVAR_4 = VAR_2 == 8 ? AV_CODEC_ID_PCM_U8 : AV_CODEC_ID_PCM_S16LE;",
"return VAR_4 == VAR_0->VAR_4;",
"case FLV_CODECID_AAC:\nreturn VAR_0->VAR_4 == AV_CODEC_ID_AAC;",
"case FLV_CODECID_ADPCM:\nreturn VAR_0->VAR_4 == AV_CODEC_ID_ADPCM_SWF;",
"case FLV_CODECID_SPEEX:\nreturn VAR_0->VAR_4 == AV_CODEC_ID_SPEEX;",
"case FLV_CODECID_MP3:\nreturn VAR_0->VAR_4 == AV_CODEC_ID_MP3;",
"case FLV_CODECID_NELLYMOSER_8KHZ_MONO:\ncase FLV_CODECID_NELLYMOSER_16KHZ_MONO:\ncase FLV_CODECID_NELLYMOSER:\nreturn VAR_0->VAR_4 == AV_CODEC_ID_NELLYMOSER;",
"case FLV_CODECID_PCM_MULAW:\nreturn VAR_0->sample_rate == 8000 &&\nVAR_0->VAR_4 == AV_CODEC_ID_PCM_MULAW;",
"case FLV_CODECID_PCM_ALAW:\nreturn VAR_0->sample_rate = 8000 &&\nVAR_0->VAR_4 == AV_CODEC_ID_PCM_ALAW;",
"default:\nreturn VAR_0->codec_tag == (VAR_3 >> FLV_AUDIO_CODECID_OFFSET);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19,
21
],
[
25
],
[
29,
31,
33,
35
],
[
37,
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59,
61
],
[
63,
65
],
[
67,
69,
71,
73
],
[
75,
77,
79
],
[
81,
83,
85
],
[
87,
89
],
[
91
],
[
93
]
] |
22,830 | static inline void gen_op_clear_ieee_excp_and_FTT(void)
{
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~(FSR_FTT_MASK | FSR_CEXC_MASK));
}
| true | qemu | 47ad35f16ae4b6b93cbfa238d51d4edc7dea90b5 | static inline void gen_op_clear_ieee_excp_and_FTT(void)
{
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~(FSR_FTT_MASK | FSR_CEXC_MASK));
}
| {
"code": [
" tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~(FSR_FTT_MASK | FSR_CEXC_MASK));"
],
"line_no": [
5
]
} | static inline void FUNC_0(void)
{
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~(FSR_FTT_MASK | FSR_CEXC_MASK));
}
| [
"static inline void FUNC_0(void)\n{",
"tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~(FSR_FTT_MASK | FSR_CEXC_MASK));",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,831 | int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
int bit_size, int sync_extension)
{
GetBitContext gb;
int specific_config_bitindex;
if(bit_size<=0)
return AVERROR_INVALIDDATA;
init_get_bits(&gb, buf, bit_size);
c->object_type = get_object_type(&gb);
c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
c->chan_config = get_bits(&gb, 4);
if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
c->channels = ff_mpeg4audio_channels[c->chan_config];
c->sbr = -1;
c->ps = -1;
if (c->object_type == AOT_SBR || (c->object_type == AOT_PS &&
// check for W6132 Annex YYYY draft MP3onMP4
!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {
if (c->object_type == AOT_PS)
c->ps = 1;
c->ext_object_type = AOT_SBR;
c->sbr = 1;
c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
c->object_type = get_object_type(&gb);
if (c->object_type == AOT_ER_BSAC)
c->ext_chan_config = get_bits(&gb, 4);
} else {
c->ext_object_type = AOT_NULL;
c->ext_sample_rate = 0;
}
specific_config_bitindex = get_bits_count(&gb);
if (c->object_type == AOT_ALS) {
skip_bits(&gb, 5);
if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
skip_bits_long(&gb, 24);
specific_config_bitindex = get_bits_count(&gb);
if (parse_config_ALS(&gb, c))
return -1;
}
if (c->ext_object_type != AOT_SBR && sync_extension) {
while (get_bits_left(&gb) > 15) {
if (show_bits(&gb, 11) == 0x2b7) { // sync extension
get_bits(&gb, 11);
c->ext_object_type = get_object_type(&gb);
if (c->ext_object_type == AOT_SBR && (c->sbr = get_bits1(&gb)) == 1) {
c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
if (c->ext_sample_rate == c->sample_rate)
c->sbr = -1;
}
if (get_bits_left(&gb) > 11 && get_bits(&gb, 11) == 0x548)
c->ps = get_bits1(&gb);
break;
} else
get_bits1(&gb); // skip 1 bit
}
}
//PS requires SBR
if (!c->sbr)
c->ps = 0;
//Limit implicit PS to the HE-AACv2 Profile
if ((c->ps == -1 && c->object_type != AOT_AAC_LC) || c->channels & ~0x01)
c->ps = 0;
return specific_config_bitindex;
}
| true | FFmpeg | deefdf9788467edd262b9c29a4f6e33d2ae84b8c | int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
int bit_size, int sync_extension)
{
GetBitContext gb;
int specific_config_bitindex;
if(bit_size<=0)
return AVERROR_INVALIDDATA;
init_get_bits(&gb, buf, bit_size);
c->object_type = get_object_type(&gb);
c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
c->chan_config = get_bits(&gb, 4);
if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
c->channels = ff_mpeg4audio_channels[c->chan_config];
c->sbr = -1;
c->ps = -1;
if (c->object_type == AOT_SBR || (c->object_type == AOT_PS &&
!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {
if (c->object_type == AOT_PS)
c->ps = 1;
c->ext_object_type = AOT_SBR;
c->sbr = 1;
c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
c->object_type = get_object_type(&gb);
if (c->object_type == AOT_ER_BSAC)
c->ext_chan_config = get_bits(&gb, 4);
} else {
c->ext_object_type = AOT_NULL;
c->ext_sample_rate = 0;
}
specific_config_bitindex = get_bits_count(&gb);
if (c->object_type == AOT_ALS) {
skip_bits(&gb, 5);
if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
skip_bits_long(&gb, 24);
specific_config_bitindex = get_bits_count(&gb);
if (parse_config_ALS(&gb, c))
return -1;
}
if (c->ext_object_type != AOT_SBR && sync_extension) {
while (get_bits_left(&gb) > 15) {
if (show_bits(&gb, 11) == 0x2b7) {
get_bits(&gb, 11);
c->ext_object_type = get_object_type(&gb);
if (c->ext_object_type == AOT_SBR && (c->sbr = get_bits1(&gb)) == 1) {
c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
if (c->ext_sample_rate == c->sample_rate)
c->sbr = -1;
}
if (get_bits_left(&gb) > 11 && get_bits(&gb, 11) == 0x548)
c->ps = get_bits1(&gb);
break;
} else
get_bits1(&gb);
}
}
if (!c->sbr)
c->ps = 0;
if ((c->ps == -1 && c->object_type != AOT_AAC_LC) || c->channels & ~0x01)
c->ps = 0;
return specific_config_bitindex;
}
| {
"code": [
" if(bit_size<=0)",
" init_get_bits(&gb, buf, bit_size);"
],
"line_no": [
13,
19
]
} | int FUNC_0(MPEG4AudioConfig *VAR_0, const uint8_t *VAR_1,
int VAR_2, int VAR_3)
{
GetBitContext gb;
int VAR_4;
if(VAR_2<=0)
return AVERROR_INVALIDDATA;
init_get_bits(&gb, VAR_1, VAR_2);
VAR_0->object_type = get_object_type(&gb);
VAR_0->sample_rate = get_sample_rate(&gb, &VAR_0->sampling_index);
VAR_0->chan_config = get_bits(&gb, 4);
if (VAR_0->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
VAR_0->channels = ff_mpeg4audio_channels[VAR_0->chan_config];
VAR_0->sbr = -1;
VAR_0->ps = -1;
if (VAR_0->object_type == AOT_SBR || (VAR_0->object_type == AOT_PS &&
!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {
if (VAR_0->object_type == AOT_PS)
VAR_0->ps = 1;
VAR_0->ext_object_type = AOT_SBR;
VAR_0->sbr = 1;
VAR_0->ext_sample_rate = get_sample_rate(&gb, &VAR_0->ext_sampling_index);
VAR_0->object_type = get_object_type(&gb);
if (VAR_0->object_type == AOT_ER_BSAC)
VAR_0->ext_chan_config = get_bits(&gb, 4);
} else {
VAR_0->ext_object_type = AOT_NULL;
VAR_0->ext_sample_rate = 0;
}
VAR_4 = get_bits_count(&gb);
if (VAR_0->object_type == AOT_ALS) {
skip_bits(&gb, 5);
if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
skip_bits_long(&gb, 24);
VAR_4 = get_bits_count(&gb);
if (parse_config_ALS(&gb, VAR_0))
return -1;
}
if (VAR_0->ext_object_type != AOT_SBR && VAR_3) {
while (get_bits_left(&gb) > 15) {
if (show_bits(&gb, 11) == 0x2b7) {
get_bits(&gb, 11);
VAR_0->ext_object_type = get_object_type(&gb);
if (VAR_0->ext_object_type == AOT_SBR && (VAR_0->sbr = get_bits1(&gb)) == 1) {
VAR_0->ext_sample_rate = get_sample_rate(&gb, &VAR_0->ext_sampling_index);
if (VAR_0->ext_sample_rate == VAR_0->sample_rate)
VAR_0->sbr = -1;
}
if (get_bits_left(&gb) > 11 && get_bits(&gb, 11) == 0x548)
VAR_0->ps = get_bits1(&gb);
break;
} else
get_bits1(&gb);
}
}
if (!VAR_0->sbr)
VAR_0->ps = 0;
if ((VAR_0->ps == -1 && VAR_0->object_type != AOT_AAC_LC) || VAR_0->channels & ~0x01)
VAR_0->ps = 0;
return VAR_4;
}
| [
"int FUNC_0(MPEG4AudioConfig *VAR_0, const uint8_t *VAR_1,\nint VAR_2, int VAR_3)\n{",
"GetBitContext gb;",
"int VAR_4;",
"if(VAR_2<=0)\nreturn AVERROR_INVALIDDATA;",
"init_get_bits(&gb, VAR_1, VAR_2);",
"VAR_0->object_type = get_object_type(&gb);",
"VAR_0->sample_rate = get_sample_rate(&gb, &VAR_0->sampling_index);",
"VAR_0->chan_config = get_bits(&gb, 4);",
"if (VAR_0->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))\nVAR_0->channels = ff_mpeg4audio_channels[VAR_0->chan_config];",
"VAR_0->sbr = -1;",
"VAR_0->ps = -1;",
"if (VAR_0->object_type == AOT_SBR || (VAR_0->object_type == AOT_PS &&\n!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {",
"if (VAR_0->object_type == AOT_PS)\nVAR_0->ps = 1;",
"VAR_0->ext_object_type = AOT_SBR;",
"VAR_0->sbr = 1;",
"VAR_0->ext_sample_rate = get_sample_rate(&gb, &VAR_0->ext_sampling_index);",
"VAR_0->object_type = get_object_type(&gb);",
"if (VAR_0->object_type == AOT_ER_BSAC)\nVAR_0->ext_chan_config = get_bits(&gb, 4);",
"} else {",
"VAR_0->ext_object_type = AOT_NULL;",
"VAR_0->ext_sample_rate = 0;",
"}",
"VAR_4 = get_bits_count(&gb);",
"if (VAR_0->object_type == AOT_ALS) {",
"skip_bits(&gb, 5);",
"if (show_bits_long(&gb, 24) != MKBETAG('\\0','A','L','S'))\nskip_bits_long(&gb, 24);",
"VAR_4 = get_bits_count(&gb);",
"if (parse_config_ALS(&gb, VAR_0))\nreturn -1;",
"}",
"if (VAR_0->ext_object_type != AOT_SBR && VAR_3) {",
"while (get_bits_left(&gb) > 15) {",
"if (show_bits(&gb, 11) == 0x2b7) {",
"get_bits(&gb, 11);",
"VAR_0->ext_object_type = get_object_type(&gb);",
"if (VAR_0->ext_object_type == AOT_SBR && (VAR_0->sbr = get_bits1(&gb)) == 1) {",
"VAR_0->ext_sample_rate = get_sample_rate(&gb, &VAR_0->ext_sampling_index);",
"if (VAR_0->ext_sample_rate == VAR_0->sample_rate)\nVAR_0->sbr = -1;",
"}",
"if (get_bits_left(&gb) > 11 && get_bits(&gb, 11) == 0x548)\nVAR_0->ps = get_bits1(&gb);",
"break;",
"} else",
"get_bits1(&gb);",
"}",
"}",
"if (!VAR_0->sbr)\nVAR_0->ps = 0;",
"if ((VAR_0->ps == -1 && VAR_0->object_type != AOT_AAC_LC) || VAR_0->channels & ~0x01)\nVAR_0->ps = 0;",
"return VAR_4;",
"}"
] | [
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35,
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73,
75
],
[
79
],
[
83,
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
129,
131
],
[
135,
137
],
[
141
],
[
143
]
] |
22,832 | static void object_set_link_property(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
Object **child = opaque;
bool ambiguous = false;
const char *type;
char *path;
type = object_property_get_type(obj, name, NULL);
visit_type_str(v, &path, name, errp);
if (*child) {
object_unref(*child);
}
if (strcmp(path, "") != 0) {
Object *target;
target = object_resolve_path(path, &ambiguous);
if (target) {
gchar *target_type;
target_type = g_strdup(&type[5]);
target_type[strlen(target_type) - 2] = 0;
if (object_dynamic_cast(target, target_type)) {
object_ref(target);
*child = target;
} else {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, type);
}
g_free(target_type);
} else {
error_set(errp, QERR_DEVICE_NOT_FOUND, path);
}
} else {
*child = NULL;
}
g_free(path);
}
| true | qemu | 8f770d39056c797a0a3de7a9a1a00befddfb088a | static void object_set_link_property(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
Object **child = opaque;
bool ambiguous = false;
const char *type;
char *path;
type = object_property_get_type(obj, name, NULL);
visit_type_str(v, &path, name, errp);
if (*child) {
object_unref(*child);
}
if (strcmp(path, "") != 0) {
Object *target;
target = object_resolve_path(path, &ambiguous);
if (target) {
gchar *target_type;
target_type = g_strdup(&type[5]);
target_type[strlen(target_type) - 2] = 0;
if (object_dynamic_cast(target, target_type)) {
object_ref(target);
*child = target;
} else {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, type);
}
g_free(target_type);
} else {
error_set(errp, QERR_DEVICE_NOT_FOUND, path);
}
} else {
*child = NULL;
}
g_free(path);
}
| {
"code": [
" gchar *target_type;",
" target_type = g_strdup(&type[5]);",
" target_type[strlen(target_type) - 2] = 0;"
],
"line_no": [
43,
47,
49
]
} | static void FUNC_0(Object *VAR_0, Visitor *VAR_1, void *VAR_2,
const char *VAR_3, Error **VAR_4)
{
Object **child = VAR_2;
bool ambiguous = false;
const char *VAR_5;
char *VAR_6;
VAR_5 = object_property_get_type(VAR_0, VAR_3, NULL);
visit_type_str(VAR_1, &VAR_6, VAR_3, VAR_4);
if (*child) {
object_unref(*child);
}
if (strcmp(VAR_6, "") != 0) {
Object *target;
target = object_resolve_path(VAR_6, &ambiguous);
if (target) {
gchar *target_type;
target_type = g_strdup(&VAR_5[5]);
target_type[strlen(target_type) - 2] = 0;
if (object_dynamic_cast(target, target_type)) {
object_ref(target);
*child = target;
} else {
error_set(VAR_4, QERR_INVALID_PARAMETER_TYPE, VAR_3, VAR_5);
}
g_free(target_type);
} else {
error_set(VAR_4, QERR_DEVICE_NOT_FOUND, VAR_6);
}
} else {
*child = NULL;
}
g_free(VAR_6);
}
| [
"static void FUNC_0(Object *VAR_0, Visitor *VAR_1, void *VAR_2,\nconst char *VAR_3, Error **VAR_4)\n{",
"Object **child = VAR_2;",
"bool ambiguous = false;",
"const char *VAR_5;",
"char *VAR_6;",
"VAR_5 = object_property_get_type(VAR_0, VAR_3, NULL);",
"visit_type_str(VAR_1, &VAR_6, VAR_3, VAR_4);",
"if (*child) {",
"object_unref(*child);",
"}",
"if (strcmp(VAR_6, \"\") != 0) {",
"Object *target;",
"target = object_resolve_path(VAR_6, &ambiguous);",
"if (target) {",
"gchar *target_type;",
"target_type = g_strdup(&VAR_5[5]);",
"target_type[strlen(target_type) - 2] = 0;",
"if (object_dynamic_cast(target, target_type)) {",
"object_ref(target);",
"*child = target;",
"} else {",
"error_set(VAR_4, QERR_INVALID_PARAMETER_TYPE, VAR_3, VAR_5);",
"}",
"g_free(target_type);",
"} else {",
"error_set(VAR_4, QERR_DEVICE_NOT_FOUND, VAR_6);",
"}",
"} else {",
"*child = NULL;",
"}",
"g_free(VAR_6);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
22,835 | vorbis_header (AVFormatContext * s, int idx)
{
ogg_t *ogg = s->priv_data;
ogg_stream_t *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
oggvorbis_private_t *priv;
if (os->seq > 2)
return 0;
if (os->seq == 0) {
os->private = av_mallocz(sizeof(oggvorbis_private_t));
if (!os->private)
return 0;
}
priv = os->private;
priv->len[os->seq] = os->psize;
priv->packet[os->seq] = av_mallocz(os->psize);
memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize);
if (os->buf[os->pstart] == 1) {
uint8_t *p = os->buf + os->pstart + 11; //skip up to the audio channels
st->codec->channels = *p++;
st->codec->sample_rate = AV_RL32(p);
p += 8; //skip maximum and and nominal bitrate
st->codec->bit_rate = AV_RL32(p); //Minimum bitrate
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_VORBIS;
st->time_base.num = 1;
st->time_base.den = st->codec->sample_rate;
} else if (os->buf[os->pstart] == 3) {
vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8);
} else {
st->codec->extradata_size =
fixup_vorbis_headers(s, priv, &st->codec->extradata);
}
return os->seq < 3;
}
| true | FFmpeg | f5475e1b38a37c6da2e26097242cf82a2b1a9ee9 | vorbis_header (AVFormatContext * s, int idx)
{
ogg_t *ogg = s->priv_data;
ogg_stream_t *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
oggvorbis_private_t *priv;
if (os->seq > 2)
return 0;
if (os->seq == 0) {
os->private = av_mallocz(sizeof(oggvorbis_private_t));
if (!os->private)
return 0;
}
priv = os->private;
priv->len[os->seq] = os->psize;
priv->packet[os->seq] = av_mallocz(os->psize);
memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize);
if (os->buf[os->pstart] == 1) {
uint8_t *p = os->buf + os->pstart + 11;
st->codec->channels = *p++;
st->codec->sample_rate = AV_RL32(p);
p += 8;
st->codec->bit_rate = AV_RL32(p);
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_VORBIS;
st->time_base.num = 1;
st->time_base.den = st->codec->sample_rate;
} else if (os->buf[os->pstart] == 3) {
vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8);
} else {
st->codec->extradata_size =
fixup_vorbis_headers(s, priv, &st->codec->extradata);
}
return os->seq < 3;
}
| {
"code": [
" vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8);"
],
"line_no": [
67
]
} | FUNC_0 (AVFormatContext * VAR_0, int VAR_1)
{
ogg_t *ogg = VAR_0->priv_data;
ogg_stream_t *os = ogg->streams + VAR_1;
AVStream *st = VAR_0->streams[VAR_1];
oggvorbis_private_t *priv;
if (os->seq > 2)
return 0;
if (os->seq == 0) {
os->private = av_mallocz(sizeof(oggvorbis_private_t));
if (!os->private)
return 0;
}
priv = os->private;
priv->len[os->seq] = os->psize;
priv->packet[os->seq] = av_mallocz(os->psize);
memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize);
if (os->buf[os->pstart] == 1) {
uint8_t *p = os->buf + os->pstart + 11;
st->codec->channels = *p++;
st->codec->sample_rate = AV_RL32(p);
p += 8;
st->codec->bit_rate = AV_RL32(p);
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_VORBIS;
st->time_base.num = 1;
st->time_base.den = st->codec->sample_rate;
} else if (os->buf[os->pstart] == 3) {
vorbis_comment (VAR_0, os->buf + os->pstart + 7, os->psize - 8);
} else {
st->codec->extradata_size =
fixup_vorbis_headers(VAR_0, priv, &st->codec->extradata);
}
return os->seq < 3;
}
| [
"FUNC_0 (AVFormatContext * VAR_0, int VAR_1)\n{",
"ogg_t *ogg = VAR_0->priv_data;",
"ogg_stream_t *os = ogg->streams + VAR_1;",
"AVStream *st = VAR_0->streams[VAR_1];",
"oggvorbis_private_t *priv;",
"if (os->seq > 2)\nreturn 0;",
"if (os->seq == 0) {",
"os->private = av_mallocz(sizeof(oggvorbis_private_t));",
"if (!os->private)\nreturn 0;",
"}",
"priv = os->private;",
"priv->len[os->seq] = os->psize;",
"priv->packet[os->seq] = av_mallocz(os->psize);",
"memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize);",
"if (os->buf[os->pstart] == 1) {",
"uint8_t *p = os->buf + os->pstart + 11;",
"st->codec->channels = *p++;",
"st->codec->sample_rate = AV_RL32(p);",
"p += 8;",
"st->codec->bit_rate = AV_RL32(p);",
"st->codec->codec_type = CODEC_TYPE_AUDIO;",
"st->codec->codec_id = CODEC_ID_VORBIS;",
"st->time_base.num = 1;",
"st->time_base.den = st->codec->sample_rate;",
"} else if (os->buf[os->pstart] == 3) {",
"vorbis_comment (VAR_0, os->buf + os->pstart + 7, os->psize - 8);",
"} else {",
"st->codec->extradata_size =\nfixup_vorbis_headers(VAR_0, priv, &st->codec->extradata);",
"}",
"return os->seq < 3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
79
],
[
81
]
] |
22,836 | static void json_message_process_token(JSONLexer *lexer, GString *input,
JSONTokenType type, int x, int y)
{
JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer);
JSONToken *token;
switch (type) {
case JSON_LCURLY:
parser->brace_count++;
break;
case JSON_RCURLY:
parser->brace_count--;
break;
case JSON_LSQUARE:
parser->bracket_count++;
break;
case JSON_RSQUARE:
parser->bracket_count--;
break;
default:
break;
}
token = g_malloc(sizeof(JSONToken) + input->len + 1);
token->type = type;
memcpy(token->str, input->str, input->len);
token->str[input->len] = 0;
token->x = x;
token->y = y;
parser->token_size += input->len;
g_queue_push_tail(parser->tokens, token);
if (type == JSON_ERROR) {
goto out_emit_bad;
} else if (parser->brace_count < 0 ||
parser->bracket_count < 0 ||
(parser->brace_count == 0 &&
parser->bracket_count == 0)) {
goto out_emit;
} else if (parser->token_size > MAX_TOKEN_SIZE ||
g_queue_get_length(parser->tokens) > MAX_TOKEN_COUNT ||
parser->bracket_count + parser->brace_count > MAX_NESTING) {
/* Security consideration, we limit total memory allocated per object
* and the maximum recursion depth that a message can force.
*/
goto out_emit_bad;
}
return;
out_emit_bad:
/*
* Clear out token list and tell the parser to emit an error
* indication by passing it a NULL list
*/
json_message_free_tokens(parser);
out_emit:
/* send current list of tokens to parser and reset tokenizer */
parser->brace_count = 0;
parser->bracket_count = 0;
/* parser->emit takes ownership of parser->tokens. */
parser->emit(parser, parser->tokens);
parser->tokens = g_queue_new();
parser->token_size = 0;
}
| true | qemu | a942d8fa01f65279cdc135f4294db611bbc088ef | static void json_message_process_token(JSONLexer *lexer, GString *input,
JSONTokenType type, int x, int y)
{
JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer);
JSONToken *token;
switch (type) {
case JSON_LCURLY:
parser->brace_count++;
break;
case JSON_RCURLY:
parser->brace_count--;
break;
case JSON_LSQUARE:
parser->bracket_count++;
break;
case JSON_RSQUARE:
parser->bracket_count--;
break;
default:
break;
}
token = g_malloc(sizeof(JSONToken) + input->len + 1);
token->type = type;
memcpy(token->str, input->str, input->len);
token->str[input->len] = 0;
token->x = x;
token->y = y;
parser->token_size += input->len;
g_queue_push_tail(parser->tokens, token);
if (type == JSON_ERROR) {
goto out_emit_bad;
} else if (parser->brace_count < 0 ||
parser->bracket_count < 0 ||
(parser->brace_count == 0 &&
parser->bracket_count == 0)) {
goto out_emit;
} else if (parser->token_size > MAX_TOKEN_SIZE ||
g_queue_get_length(parser->tokens) > MAX_TOKEN_COUNT ||
parser->bracket_count + parser->brace_count > MAX_NESTING) {
goto out_emit_bad;
}
return;
out_emit_bad:
json_message_free_tokens(parser);
out_emit:
parser->brace_count = 0;
parser->bracket_count = 0;
parser->emit(parser, parser->tokens);
parser->tokens = g_queue_new();
parser->token_size = 0;
}
| {
"code": [
" parser->emit(parser, parser->tokens);"
],
"line_no": [
127
]
} | static void FUNC_0(JSONLexer *VAR_0, GString *VAR_1,
JSONTokenType VAR_2, int VAR_3, int VAR_4)
{
JSONMessageParser *parser = container_of(VAR_0, JSONMessageParser, VAR_0);
JSONToken *token;
switch (VAR_2) {
case JSON_LCURLY:
parser->brace_count++;
break;
case JSON_RCURLY:
parser->brace_count--;
break;
case JSON_LSQUARE:
parser->bracket_count++;
break;
case JSON_RSQUARE:
parser->bracket_count--;
break;
default:
break;
}
token = g_malloc(sizeof(JSONToken) + VAR_1->len + 1);
token->VAR_2 = VAR_2;
memcpy(token->str, VAR_1->str, VAR_1->len);
token->str[VAR_1->len] = 0;
token->VAR_3 = VAR_3;
token->VAR_4 = VAR_4;
parser->token_size += VAR_1->len;
g_queue_push_tail(parser->tokens, token);
if (VAR_2 == JSON_ERROR) {
goto out_emit_bad;
} else if (parser->brace_count < 0 ||
parser->bracket_count < 0 ||
(parser->brace_count == 0 &&
parser->bracket_count == 0)) {
goto out_emit;
} else if (parser->token_size > MAX_TOKEN_SIZE ||
g_queue_get_length(parser->tokens) > MAX_TOKEN_COUNT ||
parser->bracket_count + parser->brace_count > MAX_NESTING) {
goto out_emit_bad;
}
return;
out_emit_bad:
json_message_free_tokens(parser);
out_emit:
parser->brace_count = 0;
parser->bracket_count = 0;
parser->emit(parser, parser->tokens);
parser->tokens = g_queue_new();
parser->token_size = 0;
}
| [
"static void FUNC_0(JSONLexer *VAR_0, GString *VAR_1,\nJSONTokenType VAR_2, int VAR_3, int VAR_4)\n{",
"JSONMessageParser *parser = container_of(VAR_0, JSONMessageParser, VAR_0);",
"JSONToken *token;",
"switch (VAR_2) {",
"case JSON_LCURLY:\nparser->brace_count++;",
"break;",
"case JSON_RCURLY:\nparser->brace_count--;",
"break;",
"case JSON_LSQUARE:\nparser->bracket_count++;",
"break;",
"case JSON_RSQUARE:\nparser->bracket_count--;",
"break;",
"default:\nbreak;",
"}",
"token = g_malloc(sizeof(JSONToken) + VAR_1->len + 1);",
"token->VAR_2 = VAR_2;",
"memcpy(token->str, VAR_1->str, VAR_1->len);",
"token->str[VAR_1->len] = 0;",
"token->VAR_3 = VAR_3;",
"token->VAR_4 = VAR_4;",
"parser->token_size += VAR_1->len;",
"g_queue_push_tail(parser->tokens, token);",
"if (VAR_2 == JSON_ERROR) {",
"goto out_emit_bad;",
"} else if (parser->brace_count < 0 ||",
"parser->bracket_count < 0 ||\n(parser->brace_count == 0 &&\nparser->bracket_count == 0)) {",
"goto out_emit;",
"} else if (parser->token_size > MAX_TOKEN_SIZE ||",
"g_queue_get_length(parser->tokens) > MAX_TOKEN_COUNT ||\nparser->bracket_count + parser->brace_count > MAX_NESTING) {",
"goto out_emit_bad;",
"}",
"return;",
"out_emit_bad:\njson_message_free_tokens(parser);",
"out_emit:\nparser->brace_count = 0;",
"parser->bracket_count = 0;",
"parser->emit(parser, parser->tokens);",
"parser->tokens = g_queue_new();",
"parser->token_size = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75,
77,
79
],
[
81
],
[
83
],
[
85,
87
],
[
95
],
[
97
],
[
101
],
[
105,
115
],
[
117,
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
]
] |
22,838 | static void test_blk_write(BlockBackend *blk, long pattern, int64_t offset,
int64_t count, bool expect_failed)
{
void *pattern_buf = NULL;
QEMUIOVector qiov;
int async_ret = NOT_DONE;
pattern_buf = g_malloc(count);
if (pattern) {
memset(pattern_buf, pattern, count);
} else {
memset(pattern_buf, 0x00, count);
}
qemu_iovec_init(&qiov, 1);
qemu_iovec_add(&qiov, pattern_buf, count);
blk_aio_pwritev(blk, offset, &qiov, 0, blk_rw_done, &async_ret);
while (async_ret == NOT_DONE) {
main_loop_wait(false);
}
if (expect_failed) {
g_assert(async_ret != 0);
} else {
g_assert(async_ret == 0);
}
g_free(pattern_buf);
} | true | qemu | baf905e580ab9c8eaf228822c4a7b257493b4998 | static void test_blk_write(BlockBackend *blk, long pattern, int64_t offset,
int64_t count, bool expect_failed)
{
void *pattern_buf = NULL;
QEMUIOVector qiov;
int async_ret = NOT_DONE;
pattern_buf = g_malloc(count);
if (pattern) {
memset(pattern_buf, pattern, count);
} else {
memset(pattern_buf, 0x00, count);
}
qemu_iovec_init(&qiov, 1);
qemu_iovec_add(&qiov, pattern_buf, count);
blk_aio_pwritev(blk, offset, &qiov, 0, blk_rw_done, &async_ret);
while (async_ret == NOT_DONE) {
main_loop_wait(false);
}
if (expect_failed) {
g_assert(async_ret != 0);
} else {
g_assert(async_ret == 0);
}
g_free(pattern_buf);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(BlockBackend *VAR_0, long VAR_1, int64_t VAR_2,
int64_t VAR_3, bool VAR_4)
{
void *VAR_5 = NULL;
QEMUIOVector qiov;
int VAR_6 = NOT_DONE;
VAR_5 = g_malloc(VAR_3);
if (VAR_1) {
memset(VAR_5, VAR_1, VAR_3);
} else {
memset(VAR_5, 0x00, VAR_3);
}
qemu_iovec_init(&qiov, 1);
qemu_iovec_add(&qiov, VAR_5, VAR_3);
blk_aio_pwritev(VAR_0, VAR_2, &qiov, 0, blk_rw_done, &VAR_6);
while (VAR_6 == NOT_DONE) {
main_loop_wait(false);
}
if (VAR_4) {
g_assert(VAR_6 != 0);
} else {
g_assert(VAR_6 == 0);
}
g_free(VAR_5);
} | [
"static void FUNC_0(BlockBackend *VAR_0, long VAR_1, int64_t VAR_2,\nint64_t VAR_3, bool VAR_4)\n{",
"void *VAR_5 = NULL;",
"QEMUIOVector qiov;",
"int VAR_6 = NOT_DONE;",
"VAR_5 = g_malloc(VAR_3);",
"if (VAR_1) {",
"memset(VAR_5, VAR_1, VAR_3);",
"} else {",
"memset(VAR_5, 0x00, VAR_3);",
"}",
"qemu_iovec_init(&qiov, 1);",
"qemu_iovec_add(&qiov, VAR_5, VAR_3);",
"blk_aio_pwritev(VAR_0, VAR_2, &qiov, 0, blk_rw_done, &VAR_6);",
"while (VAR_6 == NOT_DONE) {",
"main_loop_wait(false);",
"}",
"if (VAR_4) {",
"g_assert(VAR_6 != 0);",
"} else {",
"g_assert(VAR_6 == 0);",
"}",
"g_free(VAR_5);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
60
]
] |
22,839 | void usb_packet_set_state(USBPacket *p, USBPacketState state)
{
static const char *name[] = {
[USB_PACKET_UNDEFINED] = "undef",
[USB_PACKET_SETUP] = "setup",
[USB_PACKET_QUEUED] = "queued",
[USB_PACKET_ASYNC] = "async",
[USB_PACKET_COMPLETE] = "complete",
[USB_PACKET_CANCELED] = "canceled",
};
USBDevice *dev = p->ep->dev;
USBBus *bus = usb_bus_from_device(dev);
trace_usb_packet_state_change(bus->busnr, dev->port->path, p->ep->nr,
p, name[p->state], name[state]);
p->state = state;
}
| true | qemu | 5ac2731cf821a7ecae90786d9052891afb09dfc2 | void usb_packet_set_state(USBPacket *p, USBPacketState state)
{
static const char *name[] = {
[USB_PACKET_UNDEFINED] = "undef",
[USB_PACKET_SETUP] = "setup",
[USB_PACKET_QUEUED] = "queued",
[USB_PACKET_ASYNC] = "async",
[USB_PACKET_COMPLETE] = "complete",
[USB_PACKET_CANCELED] = "canceled",
};
USBDevice *dev = p->ep->dev;
USBBus *bus = usb_bus_from_device(dev);
trace_usb_packet_state_change(bus->busnr, dev->port->path, p->ep->nr,
p, name[p->state], name[state]);
p->state = state;
}
| {
"code": [
"void usb_packet_set_state(USBPacket *p, USBPacketState state)",
" trace_usb_packet_state_change(bus->busnr, dev->port->path, p->ep->nr,",
" p, name[p->state], name[state]);"
],
"line_no": [
1,
27,
29
]
} | void FUNC_0(USBPacket *VAR_0, USBPacketState VAR_1)
{
static const char *VAR_2[] = {
[USB_PACKET_UNDEFINED] = "undef",
[USB_PACKET_SETUP] = "setup",
[USB_PACKET_QUEUED] = "queued",
[USB_PACKET_ASYNC] = "async",
[USB_PACKET_COMPLETE] = "complete",
[USB_PACKET_CANCELED] = "canceled",
};
USBDevice *dev = VAR_0->ep->dev;
USBBus *bus = usb_bus_from_device(dev);
trace_usb_packet_state_change(bus->busnr, dev->port->path, VAR_0->ep->nr,
VAR_0, VAR_2[VAR_0->VAR_1], VAR_2[VAR_1]);
VAR_0->VAR_1 = VAR_1;
}
| [
"void FUNC_0(USBPacket *VAR_0, USBPacketState VAR_1)\n{",
"static const char *VAR_2[] = {",
"[USB_PACKET_UNDEFINED] = \"undef\",\n[USB_PACKET_SETUP] = \"setup\",\n[USB_PACKET_QUEUED] = \"queued\",\n[USB_PACKET_ASYNC] = \"async\",\n[USB_PACKET_COMPLETE] = \"complete\",\n[USB_PACKET_CANCELED] = \"canceled\",\n};",
"USBDevice *dev = VAR_0->ep->dev;",
"USBBus *bus = usb_bus_from_device(dev);",
"trace_usb_packet_state_change(bus->busnr, dev->port->path, VAR_0->ep->nr,\nVAR_0, VAR_2[VAR_0->VAR_1], VAR_2[VAR_1]);",
"VAR_0->VAR_1 = VAR_1;",
"}"
] | [
1,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11,
13,
15,
17,
19
],
[
21
],
[
23
],
[
27,
29
],
[
31
],
[
33
]
] |
22,840 | static struct URLProtocol *url_find_protocol(const char *filename)
{
URLProtocol *up = NULL;
char proto_str[128], proto_nested[128], *ptr;
size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
if (filename[proto_len] != ':' &&
(filename[proto_len] != ',' || !strchr(filename + proto_len + 1, ':')) ||
is_dos_path(filename))
strcpy(proto_str, "file");
else
av_strlcpy(proto_str, filename,
FFMIN(proto_len + 1, sizeof(proto_str)));
if ((ptr = strchr(proto_str, ',')))
*ptr = '\0';
av_strlcpy(proto_nested, proto_str, sizeof(proto_nested));
if ((ptr = strchr(proto_nested, '+')))
*ptr = '\0';
while (up = ffurl_protocol_next(up)) {
if (!strcmp(proto_str, up->name))
break;
if (up->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&
!strcmp(proto_nested, up->name))
break;
}
return up;
}
| true | FFmpeg | 984d58a3440d513f66344b5332f6b589c0a6bbc6 | static struct URLProtocol *url_find_protocol(const char *filename)
{
URLProtocol *up = NULL;
char proto_str[128], proto_nested[128], *ptr;
size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
if (filename[proto_len] != ':' &&
(filename[proto_len] != ',' || !strchr(filename + proto_len + 1, ':')) ||
is_dos_path(filename))
strcpy(proto_str, "file");
else
av_strlcpy(proto_str, filename,
FFMIN(proto_len + 1, sizeof(proto_str)));
if ((ptr = strchr(proto_str, ',')))
*ptr = '\0';
av_strlcpy(proto_nested, proto_str, sizeof(proto_nested));
if ((ptr = strchr(proto_nested, '+')))
*ptr = '\0';
while (up = ffurl_protocol_next(up)) {
if (!strcmp(proto_str, up->name))
break;
if (up->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&
!strcmp(proto_nested, up->name))
break;
}
return up;
}
| {
"code": [
" (filename[proto_len] != ',' || !strchr(filename + proto_len + 1, ':')) ||"
],
"line_no": [
15
]
} | static struct URLProtocol *FUNC_0(const char *VAR_0)
{
URLProtocol *VAR_1 = NULL;
char VAR_2[128], VAR_3[128], *VAR_4;
size_t proto_len = strspn(VAR_0, URL_SCHEME_CHARS);
if (VAR_0[proto_len] != ':' &&
(VAR_0[proto_len] != ',' || !strchr(VAR_0 + proto_len + 1, ':')) ||
is_dos_path(VAR_0))
strcpy(VAR_2, "file");
else
av_strlcpy(VAR_2, VAR_0,
FFMIN(proto_len + 1, sizeof(VAR_2)));
if ((VAR_4 = strchr(VAR_2, ',')))
*VAR_4 = '\0';
av_strlcpy(VAR_3, VAR_2, sizeof(VAR_3));
if ((VAR_4 = strchr(VAR_3, '+')))
*VAR_4 = '\0';
while (VAR_1 = ffurl_protocol_next(VAR_1)) {
if (!strcmp(VAR_2, VAR_1->name))
break;
if (VAR_1->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&
!strcmp(VAR_3, VAR_1->name))
break;
}
return VAR_1;
}
| [
"static struct URLProtocol *FUNC_0(const char *VAR_0)\n{",
"URLProtocol *VAR_1 = NULL;",
"char VAR_2[128], VAR_3[128], *VAR_4;",
"size_t proto_len = strspn(VAR_0, URL_SCHEME_CHARS);",
"if (VAR_0[proto_len] != ':' &&\n(VAR_0[proto_len] != ',' || !strchr(VAR_0 + proto_len + 1, ':')) ||\nis_dos_path(VAR_0))\nstrcpy(VAR_2, \"file\");",
"else\nav_strlcpy(VAR_2, VAR_0,\nFFMIN(proto_len + 1, sizeof(VAR_2)));",
"if ((VAR_4 = strchr(VAR_2, ',')))\n*VAR_4 = '\\0';",
"av_strlcpy(VAR_3, VAR_2, sizeof(VAR_3));",
"if ((VAR_4 = strchr(VAR_3, '+')))\n*VAR_4 = '\\0';",
"while (VAR_1 = ffurl_protocol_next(VAR_1)) {",
"if (!strcmp(VAR_2, VAR_1->name))\nbreak;",
"if (VAR_1->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&\n!strcmp(VAR_3, VAR_1->name))\nbreak;",
"}",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15,
17,
19
],
[
21,
23,
25
],
[
29,
31
],
[
33
],
[
35,
37
],
[
41
],
[
43,
45
],
[
47,
49,
51
],
[
53
],
[
57
],
[
59
]
] |
22,841 | void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed, Error **errp)
{
BlockDriverInfo bdi;
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *proto_drv;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int flags;
uint64_t size;
int ret;
if (!has_speed) {
speed = 0;
}
if (!has_mode) {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_format) {
format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
if (bdrv_in_use(bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
flags = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && sync == MIRROR_SYNC_MODE_TOP) {
sync = MIRROR_SYNC_MODE_FULL;
}
proto_drv = bdrv_find_protocol(target);
if (!proto_drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
/* create new image w/o backing file */
assert(format && drv);
bdrv_get_geometry(bs, &size);
size *= 512;
ret = bdrv_img_create(target, format,
NULL, NULL, NULL, size, flags);
} else {
switch (mode) {
case NEW_IMAGE_MODE_EXISTING:
ret = 0;
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
/* create new image with backing file */
ret = bdrv_img_create(target, format,
source->filename,
source->drv->format_name,
NULL, -1, flags);
break;
default:
abort();
}
}
if (ret) {
error_set(errp, QERR_OPEN_FILE_FAILED, target);
return;
}
target_bs = bdrv_new("");
ret = bdrv_open(target_bs, target, flags | BDRV_O_NO_BACKING, drv);
if (ret < 0) {
bdrv_delete(target_bs);
error_set(errp, QERR_OPEN_FILE_FAILED, target);
return;
}
/* We need a backing file if we will copy parts of a cluster. */
if (bdrv_get_info(target_bs, &bdi) >= 0 && bdi.cluster_size != 0 &&
bdi.cluster_size >= BDRV_SECTORS_PER_DIRTY_CHUNK * 512) {
ret = bdrv_open_backing_file(target_bs);
if (ret < 0) {
bdrv_delete(target_bs);
error_set(errp, QERR_OPEN_FILE_FAILED, target);
return;
}
}
mirror_start(bs, target_bs, speed, sync, block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_delete(target_bs);
error_propagate(errp, local_err);
return;
}
/* Grab a reference so hotplug does not delete the BlockDriverState from
* underneath us.
*/
drive_get_ref(drive_get_by_blockdev(bs));
}
| true | qemu | b952b5589a36114e06201c0d2e82c293dbad2b1f | void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed, Error **errp)
{
BlockDriverInfo bdi;
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *proto_drv;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int flags;
uint64_t size;
int ret;
if (!has_speed) {
speed = 0;
}
if (!has_mode) {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_format) {
format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
if (bdrv_in_use(bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
flags = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && sync == MIRROR_SYNC_MODE_TOP) {
sync = MIRROR_SYNC_MODE_FULL;
}
proto_drv = bdrv_find_protocol(target);
if (!proto_drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
assert(format && drv);
bdrv_get_geometry(bs, &size);
size *= 512;
ret = bdrv_img_create(target, format,
NULL, NULL, NULL, size, flags);
} else {
switch (mode) {
case NEW_IMAGE_MODE_EXISTING:
ret = 0;
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
ret = bdrv_img_create(target, format,
source->filename,
source->drv->format_name,
NULL, -1, flags);
break;
default:
abort();
}
}
if (ret) {
error_set(errp, QERR_OPEN_FILE_FAILED, target);
return;
}
target_bs = bdrv_new("");
ret = bdrv_open(target_bs, target, flags | BDRV_O_NO_BACKING, drv);
if (ret < 0) {
bdrv_delete(target_bs);
error_set(errp, QERR_OPEN_FILE_FAILED, target);
return;
}
if (bdrv_get_info(target_bs, &bdi) >= 0 && bdi.cluster_size != 0 &&
bdi.cluster_size >= BDRV_SECTORS_PER_DIRTY_CHUNK * 512) {
ret = bdrv_open_backing_file(target_bs);
if (ret < 0) {
bdrv_delete(target_bs);
error_set(errp, QERR_OPEN_FILE_FAILED, target);
return;
}
}
mirror_start(bs, target_bs, speed, sync, block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_delete(target_bs);
error_propagate(errp, local_err);
return;
}
drive_get_ref(drive_get_by_blockdev(bs));
}
| {
"code": [
" bool has_speed, int64_t speed, Error **errp)",
" mirror_start(bs, target_bs, speed, sync, block_job_cb, bs, &local_err);"
],
"line_no": [
9,
223
]
} | void FUNC_0(const char *VAR_0, const char *VAR_1,
bool VAR_2, const char *VAR_3,
enum MirrorSyncMode VAR_4,
bool VAR_5, enum NewImageMode VAR_6,
bool VAR_7, int64_t VAR_8, Error **VAR_9)
{
BlockDriverInfo bdi;
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *proto_drv;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int VAR_10;
uint64_t size;
int VAR_11;
if (!VAR_7) {
VAR_8 = 0;
}
if (!VAR_5) {
VAR_6 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
bs = bdrv_find(VAR_0);
if (!bs) {
error_set(VAR_9, QERR_DEVICE_NOT_FOUND, VAR_0);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(VAR_9, QERR_DEVICE_HAS_NO_MEDIUM, VAR_0);
return;
}
if (!VAR_2) {
VAR_3 = VAR_6 == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (VAR_3) {
drv = bdrv_find_format(VAR_3);
if (!drv) {
error_set(VAR_9, QERR_INVALID_BLOCK_FORMAT, VAR_3);
return;
}
}
if (bdrv_in_use(bs)) {
error_set(VAR_9, QERR_DEVICE_IN_USE, VAR_0);
return;
}
VAR_10 = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && VAR_4 == MIRROR_SYNC_MODE_TOP) {
VAR_4 = MIRROR_SYNC_MODE_FULL;
}
proto_drv = bdrv_find_protocol(VAR_1);
if (!proto_drv) {
error_set(VAR_9, QERR_INVALID_BLOCK_FORMAT, VAR_3);
return;
}
if (VAR_4 == MIRROR_SYNC_MODE_FULL && VAR_6 != NEW_IMAGE_MODE_EXISTING) {
assert(VAR_3 && drv);
bdrv_get_geometry(bs, &size);
size *= 512;
VAR_11 = bdrv_img_create(VAR_1, VAR_3,
NULL, NULL, NULL, size, VAR_10);
} else {
switch (VAR_6) {
case NEW_IMAGE_MODE_EXISTING:
VAR_11 = 0;
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
VAR_11 = bdrv_img_create(VAR_1, VAR_3,
source->filename,
source->drv->format_name,
NULL, -1, VAR_10);
break;
default:
abort();
}
}
if (VAR_11) {
error_set(VAR_9, QERR_OPEN_FILE_FAILED, VAR_1);
return;
}
target_bs = bdrv_new("");
VAR_11 = bdrv_open(target_bs, VAR_1, VAR_10 | BDRV_O_NO_BACKING, drv);
if (VAR_11 < 0) {
bdrv_delete(target_bs);
error_set(VAR_9, QERR_OPEN_FILE_FAILED, VAR_1);
return;
}
if (bdrv_get_info(target_bs, &bdi) >= 0 && bdi.cluster_size != 0 &&
bdi.cluster_size >= BDRV_SECTORS_PER_DIRTY_CHUNK * 512) {
VAR_11 = bdrv_open_backing_file(target_bs);
if (VAR_11 < 0) {
bdrv_delete(target_bs);
error_set(VAR_9, QERR_OPEN_FILE_FAILED, VAR_1);
return;
}
}
mirror_start(bs, target_bs, VAR_8, VAR_4, block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_delete(target_bs);
error_propagate(VAR_9, local_err);
return;
}
drive_get_ref(drive_get_by_blockdev(bs));
}
| [
"void FUNC_0(const char *VAR_0, const char *VAR_1,\nbool VAR_2, const char *VAR_3,\nenum MirrorSyncMode VAR_4,\nbool VAR_5, enum NewImageMode VAR_6,\nbool VAR_7, int64_t VAR_8, Error **VAR_9)\n{",
"BlockDriverInfo bdi;",
"BlockDriverState *bs;",
"BlockDriverState *source, *target_bs;",
"BlockDriver *proto_drv;",
"BlockDriver *drv = NULL;",
"Error *local_err = NULL;",
"int VAR_10;",
"uint64_t size;",
"int VAR_11;",
"if (!VAR_7) {",
"VAR_8 = 0;",
"}",
"if (!VAR_5) {",
"VAR_6 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;",
"}",
"bs = bdrv_find(VAR_0);",
"if (!bs) {",
"error_set(VAR_9, QERR_DEVICE_NOT_FOUND, VAR_0);",
"return;",
"}",
"if (!bdrv_is_inserted(bs)) {",
"error_set(VAR_9, QERR_DEVICE_HAS_NO_MEDIUM, VAR_0);",
"return;",
"}",
"if (!VAR_2) {",
"VAR_3 = VAR_6 == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;",
"}",
"if (VAR_3) {",
"drv = bdrv_find_format(VAR_3);",
"if (!drv) {",
"error_set(VAR_9, QERR_INVALID_BLOCK_FORMAT, VAR_3);",
"return;",
"}",
"}",
"if (bdrv_in_use(bs)) {",
"error_set(VAR_9, QERR_DEVICE_IN_USE, VAR_0);",
"return;",
"}",
"VAR_10 = bs->open_flags | BDRV_O_RDWR;",
"source = bs->backing_hd;",
"if (!source && VAR_4 == MIRROR_SYNC_MODE_TOP) {",
"VAR_4 = MIRROR_SYNC_MODE_FULL;",
"}",
"proto_drv = bdrv_find_protocol(VAR_1);",
"if (!proto_drv) {",
"error_set(VAR_9, QERR_INVALID_BLOCK_FORMAT, VAR_3);",
"return;",
"}",
"if (VAR_4 == MIRROR_SYNC_MODE_FULL && VAR_6 != NEW_IMAGE_MODE_EXISTING) {",
"assert(VAR_3 && drv);",
"bdrv_get_geometry(bs, &size);",
"size *= 512;",
"VAR_11 = bdrv_img_create(VAR_1, VAR_3,\nNULL, NULL, NULL, size, VAR_10);",
"} else {",
"switch (VAR_6) {",
"case NEW_IMAGE_MODE_EXISTING:\nVAR_11 = 0;",
"break;",
"case NEW_IMAGE_MODE_ABSOLUTE_PATHS:\nVAR_11 = bdrv_img_create(VAR_1, VAR_3,\nsource->filename,\nsource->drv->format_name,\nNULL, -1, VAR_10);",
"break;",
"default:\nabort();",
"}",
"}",
"if (VAR_11) {",
"error_set(VAR_9, QERR_OPEN_FILE_FAILED, VAR_1);",
"return;",
"}",
"target_bs = bdrv_new(\"\");",
"VAR_11 = bdrv_open(target_bs, VAR_1, VAR_10 | BDRV_O_NO_BACKING, drv);",
"if (VAR_11 < 0) {",
"bdrv_delete(target_bs);",
"error_set(VAR_9, QERR_OPEN_FILE_FAILED, VAR_1);",
"return;",
"}",
"if (bdrv_get_info(target_bs, &bdi) >= 0 && bdi.cluster_size != 0 &&\nbdi.cluster_size >= BDRV_SECTORS_PER_DIRTY_CHUNK * 512) {",
"VAR_11 = bdrv_open_backing_file(target_bs);",
"if (VAR_11 < 0) {",
"bdrv_delete(target_bs);",
"error_set(VAR_9, QERR_OPEN_FILE_FAILED, VAR_1);",
"return;",
"}",
"}",
"mirror_start(bs, target_bs, VAR_8, VAR_4, block_job_cb, bs, &local_err);",
"if (local_err != NULL) {",
"bdrv_delete(target_bs);",
"error_propagate(VAR_9, local_err);",
"return;",
"}",
"drive_get_ref(drive_get_by_blockdev(bs));",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143,
145
],
[
147
],
[
149,
153,
155,
157,
159
],
[
161
],
[
163,
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
203,
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
243
],
[
245
]
] |
22,842 | static av_cold int sonic_decode_init(AVCodecContext *avctx)
{
SonicContext *s = avctx->priv_data;
GetBitContext gb;
int i;
s->channels = avctx->channels;
s->samplerate = avctx->sample_rate;
if (!avctx->extradata)
{
av_log(avctx, AV_LOG_ERROR, "No mandatory headers present\n");
return AVERROR_INVALIDDATA;
}
init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);
s->version = get_bits(&gb, 2);
if (s->version >= 2) {
s->version = get_bits(&gb, 8);
s->minor_version = get_bits(&gb, 8);
}
if (s->version != 2)
{
av_log(avctx, AV_LOG_ERROR, "Unsupported Sonic version, please report\n");
return AVERROR_INVALIDDATA;
}
if (s->version >= 1)
{
s->channels = get_bits(&gb, 2);
s->samplerate = samplerate_table[get_bits(&gb, 4)];
av_log(avctx, AV_LOG_INFO, "Sonicv2 chans: %d samprate: %d\n",
s->channels, s->samplerate);
}
if (s->channels > MAX_CHANNELS)
{
av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n");
return AVERROR_INVALIDDATA;
}
s->lossless = get_bits1(&gb);
if (!s->lossless)
skip_bits(&gb, 3); // XXX FIXME
s->decorrelation = get_bits(&gb, 2);
if (s->decorrelation != 3 && s->channels != 2) {
av_log(avctx, AV_LOG_ERROR, "invalid decorrelation %d\n", s->decorrelation);
return AVERROR_INVALIDDATA;
}
s->downsampling = get_bits(&gb, 2);
if (!s->downsampling) {
av_log(avctx, AV_LOG_ERROR, "invalid downsampling value\n");
return AVERROR_INVALIDDATA;
}
s->num_taps = (get_bits(&gb, 5)+1)<<5;
if (get_bits1(&gb)) // XXX FIXME
av_log(avctx, AV_LOG_INFO, "Custom quant table\n");
s->block_align = 2048LL*s->samplerate/(44100*s->downsampling);
s->frame_size = s->channels*s->block_align*s->downsampling;
// avctx->frame_size = s->block_align;
av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
s->version, s->minor_version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling);
// generate taps
s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant));
if (!s->tap_quant)
return AVERROR(ENOMEM);
for (i = 0; i < s->num_taps; i++)
s->tap_quant[i] = ff_sqrt(i+1);
s->predictor_k = av_calloc(s->num_taps, sizeof(*s->predictor_k));
for (i = 0; i < s->channels; i++)
{
s->predictor_state[i] = av_calloc(s->num_taps, sizeof(**s->predictor_state));
if (!s->predictor_state[i])
return AVERROR(ENOMEM);
}
for (i = 0; i < s->channels; i++)
{
s->coded_samples[i] = av_calloc(s->block_align, sizeof(**s->coded_samples));
if (!s->coded_samples[i])
return AVERROR(ENOMEM);
}
s->int_samples = av_calloc(s->frame_size, sizeof(*s->int_samples));
if (!s->int_samples)
return AVERROR(ENOMEM);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
| false | FFmpeg | ade8a46154cb45c88b1cb5c616eaa6320c941187 | static av_cold int sonic_decode_init(AVCodecContext *avctx)
{
SonicContext *s = avctx->priv_data;
GetBitContext gb;
int i;
s->channels = avctx->channels;
s->samplerate = avctx->sample_rate;
if (!avctx->extradata)
{
av_log(avctx, AV_LOG_ERROR, "No mandatory headers present\n");
return AVERROR_INVALIDDATA;
}
init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);
s->version = get_bits(&gb, 2);
if (s->version >= 2) {
s->version = get_bits(&gb, 8);
s->minor_version = get_bits(&gb, 8);
}
if (s->version != 2)
{
av_log(avctx, AV_LOG_ERROR, "Unsupported Sonic version, please report\n");
return AVERROR_INVALIDDATA;
}
if (s->version >= 1)
{
s->channels = get_bits(&gb, 2);
s->samplerate = samplerate_table[get_bits(&gb, 4)];
av_log(avctx, AV_LOG_INFO, "Sonicv2 chans: %d samprate: %d\n",
s->channels, s->samplerate);
}
if (s->channels > MAX_CHANNELS)
{
av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n");
return AVERROR_INVALIDDATA;
}
s->lossless = get_bits1(&gb);
if (!s->lossless)
skip_bits(&gb, 3);
s->decorrelation = get_bits(&gb, 2);
if (s->decorrelation != 3 && s->channels != 2) {
av_log(avctx, AV_LOG_ERROR, "invalid decorrelation %d\n", s->decorrelation);
return AVERROR_INVALIDDATA;
}
s->downsampling = get_bits(&gb, 2);
if (!s->downsampling) {
av_log(avctx, AV_LOG_ERROR, "invalid downsampling value\n");
return AVERROR_INVALIDDATA;
}
s->num_taps = (get_bits(&gb, 5)+1)<<5;
if (get_bits1(&gb))
av_log(avctx, AV_LOG_INFO, "Custom quant table\n");
s->block_align = 2048LL*s->samplerate/(44100*s->downsampling);
s->frame_size = s->channels*s->block_align*s->downsampling;
av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
s->version, s->minor_version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling);
s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant));
if (!s->tap_quant)
return AVERROR(ENOMEM);
for (i = 0; i < s->num_taps; i++)
s->tap_quant[i] = ff_sqrt(i+1);
s->predictor_k = av_calloc(s->num_taps, sizeof(*s->predictor_k));
for (i = 0; i < s->channels; i++)
{
s->predictor_state[i] = av_calloc(s->num_taps, sizeof(**s->predictor_state));
if (!s->predictor_state[i])
return AVERROR(ENOMEM);
}
for (i = 0; i < s->channels; i++)
{
s->coded_samples[i] = av_calloc(s->block_align, sizeof(**s->coded_samples));
if (!s->coded_samples[i])
return AVERROR(ENOMEM);
}
s->int_samples = av_calloc(s->frame_size, sizeof(*s->int_samples));
if (!s->int_samples)
return AVERROR(ENOMEM);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
SonicContext *s = avctx->priv_data;
GetBitContext gb;
int VAR_0;
s->channels = avctx->channels;
s->samplerate = avctx->sample_rate;
if (!avctx->extradata)
{
av_log(avctx, AV_LOG_ERROR, "No mandatory headers present\n");
return AVERROR_INVALIDDATA;
}
init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);
s->version = get_bits(&gb, 2);
if (s->version >= 2) {
s->version = get_bits(&gb, 8);
s->minor_version = get_bits(&gb, 8);
}
if (s->version != 2)
{
av_log(avctx, AV_LOG_ERROR, "Unsupported Sonic version, please report\n");
return AVERROR_INVALIDDATA;
}
if (s->version >= 1)
{
s->channels = get_bits(&gb, 2);
s->samplerate = samplerate_table[get_bits(&gb, 4)];
av_log(avctx, AV_LOG_INFO, "Sonicv2 chans: %d samprate: %d\n",
s->channels, s->samplerate);
}
if (s->channels > MAX_CHANNELS)
{
av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n");
return AVERROR_INVALIDDATA;
}
s->lossless = get_bits1(&gb);
if (!s->lossless)
skip_bits(&gb, 3);
s->decorrelation = get_bits(&gb, 2);
if (s->decorrelation != 3 && s->channels != 2) {
av_log(avctx, AV_LOG_ERROR, "invalid decorrelation %d\n", s->decorrelation);
return AVERROR_INVALIDDATA;
}
s->downsampling = get_bits(&gb, 2);
if (!s->downsampling) {
av_log(avctx, AV_LOG_ERROR, "invalid downsampling value\n");
return AVERROR_INVALIDDATA;
}
s->num_taps = (get_bits(&gb, 5)+1)<<5;
if (get_bits1(&gb))
av_log(avctx, AV_LOG_INFO, "Custom quant table\n");
s->block_align = 2048LL*s->samplerate/(44100*s->downsampling);
s->frame_size = s->channels*s->block_align*s->downsampling;
av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
s->version, s->minor_version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling);
s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant));
if (!s->tap_quant)
return AVERROR(ENOMEM);
for (VAR_0 = 0; VAR_0 < s->num_taps; VAR_0++)
s->tap_quant[VAR_0] = ff_sqrt(VAR_0+1);
s->predictor_k = av_calloc(s->num_taps, sizeof(*s->predictor_k));
for (VAR_0 = 0; VAR_0 < s->channels; VAR_0++)
{
s->predictor_state[VAR_0] = av_calloc(s->num_taps, sizeof(**s->predictor_state));
if (!s->predictor_state[VAR_0])
return AVERROR(ENOMEM);
}
for (VAR_0 = 0; VAR_0 < s->channels; VAR_0++)
{
s->coded_samples[VAR_0] = av_calloc(s->block_align, sizeof(**s->coded_samples));
if (!s->coded_samples[VAR_0])
return AVERROR(ENOMEM);
}
s->int_samples = av_calloc(s->frame_size, sizeof(*s->int_samples));
if (!s->int_samples)
return AVERROR(ENOMEM);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"SonicContext *s = avctx->priv_data;",
"GetBitContext gb;",
"int VAR_0;",
"s->channels = avctx->channels;",
"s->samplerate = avctx->sample_rate;",
"if (!avctx->extradata)\n{",
"av_log(avctx, AV_LOG_ERROR, \"No mandatory headers present\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);",
"s->version = get_bits(&gb, 2);",
"if (s->version >= 2) {",
"s->version = get_bits(&gb, 8);",
"s->minor_version = get_bits(&gb, 8);",
"}",
"if (s->version != 2)\n{",
"av_log(avctx, AV_LOG_ERROR, \"Unsupported Sonic version, please report\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (s->version >= 1)\n{",
"s->channels = get_bits(&gb, 2);",
"s->samplerate = samplerate_table[get_bits(&gb, 4)];",
"av_log(avctx, AV_LOG_INFO, \"Sonicv2 chans: %d samprate: %d\\n\",\ns->channels, s->samplerate);",
"}",
"if (s->channels > MAX_CHANNELS)\n{",
"av_log(avctx, AV_LOG_ERROR, \"Only mono and stereo streams are supported by now\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"s->lossless = get_bits1(&gb);",
"if (!s->lossless)\nskip_bits(&gb, 3);",
"s->decorrelation = get_bits(&gb, 2);",
"if (s->decorrelation != 3 && s->channels != 2) {",
"av_log(avctx, AV_LOG_ERROR, \"invalid decorrelation %d\\n\", s->decorrelation);",
"return AVERROR_INVALIDDATA;",
"}",
"s->downsampling = get_bits(&gb, 2);",
"if (!s->downsampling) {",
"av_log(avctx, AV_LOG_ERROR, \"invalid downsampling value\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"s->num_taps = (get_bits(&gb, 5)+1)<<5;",
"if (get_bits1(&gb))\nav_log(avctx, AV_LOG_INFO, \"Custom quant table\\n\");",
"s->block_align = 2048LL*s->samplerate/(44100*s->downsampling);",
"s->frame_size = s->channels*s->block_align*s->downsampling;",
"av_log(avctx, AV_LOG_INFO, \"Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\\n\",\ns->version, s->minor_version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling);",
"s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant));",
"if (!s->tap_quant)\nreturn AVERROR(ENOMEM);",
"for (VAR_0 = 0; VAR_0 < s->num_taps; VAR_0++)",
"s->tap_quant[VAR_0] = ff_sqrt(VAR_0+1);",
"s->predictor_k = av_calloc(s->num_taps, sizeof(*s->predictor_k));",
"for (VAR_0 = 0; VAR_0 < s->channels; VAR_0++)",
"{",
"s->predictor_state[VAR_0] = av_calloc(s->num_taps, sizeof(**s->predictor_state));",
"if (!s->predictor_state[VAR_0])\nreturn AVERROR(ENOMEM);",
"}",
"for (VAR_0 = 0; VAR_0 < s->channels; VAR_0++)",
"{",
"s->coded_samples[VAR_0] = av_calloc(s->block_align, sizeof(**s->coded_samples));",
"if (!s->coded_samples[VAR_0])\nreturn AVERROR(ENOMEM);",
"}",
"s->int_samples = av_calloc(s->frame_size, sizeof(*s->int_samples));",
"if (!s->int_samples)\nreturn AVERROR(ENOMEM);",
"avctx->sample_fmt = AV_SAMPLE_FMT_S16;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
57,
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117,
119
],
[
123
],
[
125
],
[
131,
133
],
[
139
],
[
141,
143
],
[
147
],
[
149
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
185,
187
],
[
191
],
[
193
],
[
195
]
] |
22,843 | static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu,
Error **errp)
{
CPUPPCState *env = &cpu->env;
CPUState *cs = CPU(cpu);
int i;
/* Set time-base frequency to 512 MHz */
cpu_ppc_tb_init(env, SPAPR_TIMEBASE_FREQ);
/* Enable PAPR mode in TCG or KVM */
cpu_ppc_set_papr(cpu);
if (cpu->max_compat) {
Error *local_err = NULL;
ppc_set_compat(cpu, cpu->max_compat, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
}
/* Set NUMA node for the added CPUs */
i = numa_get_node_for_cpu(cs->cpu_index);
if (i < nb_numa_nodes) {
cs->numa_node = i;
}
xics_cpu_setup(spapr->xics, cpu);
qemu_register_reset(spapr_cpu_reset, cpu);
spapr_cpu_reset(cpu);
} | true | qemu | 1d1be34d26b66069e20cbbcd798ea57763a0f152 | static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu,
Error **errp)
{
CPUPPCState *env = &cpu->env;
CPUState *cs = CPU(cpu);
int i;
cpu_ppc_tb_init(env, SPAPR_TIMEBASE_FREQ);
cpu_ppc_set_papr(cpu);
if (cpu->max_compat) {
Error *local_err = NULL;
ppc_set_compat(cpu, cpu->max_compat, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
}
i = numa_get_node_for_cpu(cs->cpu_index);
if (i < nb_numa_nodes) {
cs->numa_node = i;
}
xics_cpu_setup(spapr->xics, cpu);
qemu_register_reset(spapr_cpu_reset, cpu);
spapr_cpu_reset(cpu);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(sPAPRMachineState *VAR_0, PowerPCCPU *VAR_1,
Error **VAR_2)
{
CPUPPCState *env = &VAR_1->env;
CPUState *cs = CPU(VAR_1);
int VAR_3;
cpu_ppc_tb_init(env, SPAPR_TIMEBASE_FREQ);
cpu_ppc_set_papr(VAR_1);
if (VAR_1->max_compat) {
Error *local_err = NULL;
ppc_set_compat(VAR_1, VAR_1->max_compat, &local_err);
if (local_err) {
error_propagate(VAR_2, local_err);
return;
}
}
VAR_3 = numa_get_node_for_cpu(cs->cpu_index);
if (VAR_3 < nb_numa_nodes) {
cs->numa_node = VAR_3;
}
xics_cpu_setup(VAR_0->xics, VAR_1);
qemu_register_reset(spapr_cpu_reset, VAR_1);
spapr_cpu_reset(VAR_1);
} | [
"static void FUNC_0(sPAPRMachineState *VAR_0, PowerPCCPU *VAR_1,\nError **VAR_2)\n{",
"CPUPPCState *env = &VAR_1->env;",
"CPUState *cs = CPU(VAR_1);",
"int VAR_3;",
"cpu_ppc_tb_init(env, SPAPR_TIMEBASE_FREQ);",
"cpu_ppc_set_papr(VAR_1);",
"if (VAR_1->max_compat) {",
"Error *local_err = NULL;",
"ppc_set_compat(VAR_1, VAR_1->max_compat, &local_err);",
"if (local_err) {",
"error_propagate(VAR_2, local_err);",
"return;",
"}",
"}",
"VAR_3 = numa_get_node_for_cpu(cs->cpu_index);",
"if (VAR_3 < nb_numa_nodes) {",
"cs->numa_node = VAR_3;",
"}",
"xics_cpu_setup(VAR_0->xics, VAR_1);",
"qemu_register_reset(spapr_cpu_reset, VAR_1);",
"spapr_cpu_reset(VAR_1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
24
],
[
28
],
[
30
],
[
34
],
[
36
],
[
38
],
[
40
],
[
42
],
[
44
],
[
50
],
[
52
],
[
54
],
[
56
],
[
60
],
[
64
],
[
66
],
[
68
]
] |
22,845 | int ppc_find_by_name (const unsigned char *name, ppc_def_t **def)
{
int i, ret;
ret = -1;
*def = NULL;
for (i = 0; strcmp(ppc_defs[i].name, "default") != 0; i++) {
if (strcasecmp(name, ppc_defs[i].name) == 0) {
*def = &ppc_defs[i];
ret = 0;
break;
}
}
return ret;
}
| true | qemu | 068abdc8a57023eeafe1025b964a50f8a39929b4 | int ppc_find_by_name (const unsigned char *name, ppc_def_t **def)
{
int i, ret;
ret = -1;
*def = NULL;
for (i = 0; strcmp(ppc_defs[i].name, "default") != 0; i++) {
if (strcasecmp(name, ppc_defs[i].name) == 0) {
*def = &ppc_defs[i];
ret = 0;
break;
}
}
return ret;
}
| {
"code": [
" int i, ret;",
" for (i = 0; strcmp(ppc_defs[i].name, \"default\") != 0; i++) {",
" int i, ret;",
" break;"
],
"line_no": [
5,
13,
5,
21
]
} | int FUNC_0 (const unsigned char *VAR_0, ppc_def_t **VAR_1)
{
int VAR_2, VAR_3;
VAR_3 = -1;
*VAR_1 = NULL;
for (VAR_2 = 0; strcmp(ppc_defs[VAR_2].VAR_0, "default") != 0; VAR_2++) {
if (strcasecmp(VAR_0, ppc_defs[VAR_2].VAR_0) == 0) {
*VAR_1 = &ppc_defs[VAR_2];
VAR_3 = 0;
break;
}
}
return VAR_3;
}
| [
"int FUNC_0 (const unsigned char *VAR_0, ppc_def_t **VAR_1)\n{",
"int VAR_2, VAR_3;",
"VAR_3 = -1;",
"*VAR_1 = NULL;",
"for (VAR_2 = 0; strcmp(ppc_defs[VAR_2].VAR_0, \"default\") != 0; VAR_2++) {",
"if (strcasecmp(VAR_0, ppc_defs[VAR_2].VAR_0) == 0) {",
"*VAR_1 = &ppc_defs[VAR_2];",
"VAR_3 = 0;",
"break;",
"}",
"}",
"return VAR_3;",
"}"
] | [
0,
1,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
]
] |
22,846 | static void spitz_gpio_setup(PXA2xxState *cpu, int slots)
{
qemu_irq lcd_hsync;
/*
* Bad hack: We toggle the LCD hsync GPIO on every GPIO status
* read to satisfy broken guests that poll-wait for hsync.
* Simulating a real hsync event would be less practical and
* wouldn't guarantee that a guest ever exits the loop.
*/
spitz_hsync = 0;
lcd_hsync = qemu_allocate_irqs(spitz_lcd_hsync_handler, cpu, 1)[0];
pxa2xx_gpio_read_notifier(cpu->gpio, lcd_hsync);
pxa2xx_lcd_vsync_notifier(cpu->lcd, lcd_hsync);
/* MMC/SD host */
pxa2xx_mmci_handlers(cpu->mmc,
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_SD_WP),
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_SD_DETECT));
/* Battery lock always closed */
qemu_irq_raise(qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_BAT_COVER));
/* Handle reset */
qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_ON_RESET, cpu->reset);
/* PCMCIA signals: card's IRQ and Card-Detect */
if (slots >= 1)
pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_IRQ),
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_CD));
if (slots >= 2)
pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_IRQ),
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_CD));
}
| true | qemu | f3c7d0389fe8a2792fd4c1cf151b885de03c8f62 | static void spitz_gpio_setup(PXA2xxState *cpu, int slots)
{
qemu_irq lcd_hsync;
spitz_hsync = 0;
lcd_hsync = qemu_allocate_irqs(spitz_lcd_hsync_handler, cpu, 1)[0];
pxa2xx_gpio_read_notifier(cpu->gpio, lcd_hsync);
pxa2xx_lcd_vsync_notifier(cpu->lcd, lcd_hsync);
pxa2xx_mmci_handlers(cpu->mmc,
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_SD_WP),
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_SD_DETECT));
qemu_irq_raise(qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_BAT_COVER));
qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_ON_RESET, cpu->reset);
if (slots >= 1)
pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_IRQ),
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_CD));
if (slots >= 2)
pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_IRQ),
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_CD));
}
| {
"code": [
" lcd_hsync = qemu_allocate_irqs(spitz_lcd_hsync_handler, cpu, 1)[0];"
],
"line_no": [
21
]
} | static void FUNC_0(PXA2xxState *VAR_0, int VAR_1)
{
qemu_irq lcd_hsync;
spitz_hsync = 0;
lcd_hsync = qemu_allocate_irqs(spitz_lcd_hsync_handler, VAR_0, 1)[0];
pxa2xx_gpio_read_notifier(VAR_0->gpio, lcd_hsync);
pxa2xx_lcd_vsync_notifier(VAR_0->lcd, lcd_hsync);
pxa2xx_mmci_handlers(VAR_0->mmc,
qdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_SD_WP),
qdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_SD_DETECT));
qemu_irq_raise(qdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_BAT_COVER));
qdev_connect_gpio_out(VAR_0->gpio, SPITZ_GPIO_ON_RESET, VAR_0->reset);
if (VAR_1 >= 1)
pxa2xx_pcmcia_set_irq_cb(VAR_0->pcmcia[0],
qdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_CF1_IRQ),
qdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_CF1_CD));
if (VAR_1 >= 2)
pxa2xx_pcmcia_set_irq_cb(VAR_0->pcmcia[1],
qdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_CF2_IRQ),
qdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_CF2_CD));
}
| [
"static void FUNC_0(PXA2xxState *VAR_0, int VAR_1)\n{",
"qemu_irq lcd_hsync;",
"spitz_hsync = 0;",
"lcd_hsync = qemu_allocate_irqs(spitz_lcd_hsync_handler, VAR_0, 1)[0];",
"pxa2xx_gpio_read_notifier(VAR_0->gpio, lcd_hsync);",
"pxa2xx_lcd_vsync_notifier(VAR_0->lcd, lcd_hsync);",
"pxa2xx_mmci_handlers(VAR_0->mmc,\nqdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_SD_WP),\nqdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_SD_DETECT));",
"qemu_irq_raise(qdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_BAT_COVER));",
"qdev_connect_gpio_out(VAR_0->gpio, SPITZ_GPIO_ON_RESET, VAR_0->reset);",
"if (VAR_1 >= 1)\npxa2xx_pcmcia_set_irq_cb(VAR_0->pcmcia[0],\nqdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_CF1_IRQ),\nqdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_CF1_CD));",
"if (VAR_1 >= 2)\npxa2xx_pcmcia_set_irq_cb(VAR_0->pcmcia[1],\nqdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_CF2_IRQ),\nqdev_get_gpio_in(VAR_0->gpio, SPITZ_GPIO_CF2_CD));",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31,
33,
35
],
[
41
],
[
47
],
[
53,
55,
57,
59
],
[
61,
63,
65,
67
],
[
69
]
] |
22,847 | int vnc_display_pw_expire(DisplayState *ds, time_t expires)
{
VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;
vs->expires = expires;
return 0; | true | qemu | 1643f2b232628905e8f32965ff36a87bd53b93c5 | int vnc_display_pw_expire(DisplayState *ds, time_t expires)
{
VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;
vs->expires = expires;
return 0; | {
"code": [],
"line_no": []
} | int FUNC_0(DisplayState *VAR_0, time_t VAR_1)
{
VncDisplay *vs = VAR_0 ? (VncDisplay *)VAR_0->opaque : vnc_display;
vs->VAR_1 = VAR_1;
return 0; | [
"int FUNC_0(DisplayState *VAR_0, time_t VAR_1)\n{",
"VncDisplay *vs = VAR_0 ? (VncDisplay *)VAR_0->opaque : vnc_display;",
"vs->VAR_1 = VAR_1;",
"return 0;"
] | [
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
]
] |
22,848 | static int usb_hub_handle_data(USBDevice *dev, USBPacket *p)
{
USBHubState *s = (USBHubState *)dev;
int ret;
switch(p->pid) {
case USB_TOKEN_IN:
if (p->devep == 1) {
USBHubPort *port;
unsigned int status;
int i, n;
n = (NUM_PORTS + 1 + 7) / 8;
if (p->len == 1) { /* FreeBSD workaround */
n = 1;
} else if (n > p->len) {
return USB_RET_BABBLE;
}
status = 0;
for(i = 0; i < NUM_PORTS; i++) {
port = &s->ports[i];
if (port->wPortChange)
status |= (1 << (i + 1));
}
if (status != 0) {
for(i = 0; i < n; i++) {
p->data[i] = status >> (8 * i);
}
ret = n;
} else {
ret = USB_RET_NAK; /* usb11 11.13.1 */
}
} else {
goto fail;
}
break;
case USB_TOKEN_OUT:
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int usb_hub_handle_data(USBDevice *dev, USBPacket *p)
{
USBHubState *s = (USBHubState *)dev;
int ret;
switch(p->pid) {
case USB_TOKEN_IN:
if (p->devep == 1) {
USBHubPort *port;
unsigned int status;
int i, n;
n = (NUM_PORTS + 1 + 7) / 8;
if (p->len == 1) {
n = 1;
} else if (n > p->len) {
return USB_RET_BABBLE;
}
status = 0;
for(i = 0; i < NUM_PORTS; i++) {
port = &s->ports[i];
if (port->wPortChange)
status |= (1 << (i + 1));
}
if (status != 0) {
for(i = 0; i < n; i++) {
p->data[i] = status >> (8 * i);
}
ret = n;
} else {
ret = USB_RET_NAK;
}
} else {
goto fail;
}
break;
case USB_TOKEN_OUT:
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| {
"code": [
" } else if (n > p->len) {",
" p->data[i] = status >> (8 * i);"
],
"line_no": [
29,
51
]
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
USBHubState *s = (USBHubState *)VAR_0;
int VAR_2;
switch(VAR_1->pid) {
case USB_TOKEN_IN:
if (VAR_1->devep == 1) {
USBHubPort *port;
unsigned int VAR_3;
int VAR_4, VAR_5;
VAR_5 = (NUM_PORTS + 1 + 7) / 8;
if (VAR_1->len == 1) {
VAR_5 = 1;
} else if (VAR_5 > VAR_1->len) {
return USB_RET_BABBLE;
}
VAR_3 = 0;
for(VAR_4 = 0; VAR_4 < NUM_PORTS; VAR_4++) {
port = &s->ports[VAR_4];
if (port->wPortChange)
VAR_3 |= (1 << (VAR_4 + 1));
}
if (VAR_3 != 0) {
for(VAR_4 = 0; VAR_4 < VAR_5; VAR_4++) {
VAR_1->data[VAR_4] = VAR_3 >> (8 * VAR_4);
}
VAR_2 = VAR_5;
} else {
VAR_2 = USB_RET_NAK;
}
} else {
goto fail;
}
break;
case USB_TOKEN_OUT:
default:
fail:
VAR_2 = USB_RET_STALL;
break;
}
return VAR_2;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"USBHubState *s = (USBHubState *)VAR_0;",
"int VAR_2;",
"switch(VAR_1->pid) {",
"case USB_TOKEN_IN:\nif (VAR_1->devep == 1) {",
"USBHubPort *port;",
"unsigned int VAR_3;",
"int VAR_4, VAR_5;",
"VAR_5 = (NUM_PORTS + 1 + 7) / 8;",
"if (VAR_1->len == 1) {",
"VAR_5 = 1;",
"} else if (VAR_5 > VAR_1->len) {",
"return USB_RET_BABBLE;",
"}",
"VAR_3 = 0;",
"for(VAR_4 = 0; VAR_4 < NUM_PORTS; VAR_4++) {",
"port = &s->ports[VAR_4];",
"if (port->wPortChange)\nVAR_3 |= (1 << (VAR_4 + 1));",
"}",
"if (VAR_3 != 0) {",
"for(VAR_4 = 0; VAR_4 < VAR_5; VAR_4++) {",
"VAR_1->data[VAR_4] = VAR_3 >> (8 * VAR_4);",
"}",
"VAR_2 = VAR_5;",
"} else {",
"VAR_2 = USB_RET_NAK;",
"}",
"} else {",
"goto fail;",
"}",
"break;",
"case USB_TOKEN_OUT:\ndefault:\nfail:\nVAR_2 = USB_RET_STALL;",
"break;",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73,
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
22,849 | void bdrv_drain_all(void)
{
/* Always run first iteration so any pending completion BHs run */
bool busy = true;
BlockDriverState *bs;
while (busy) {
/* FIXME: We do not have timer support here, so this is effectively
* a busy wait.
*/
QTAILQ_FOREACH(bs, &bdrv_states, list) {
if (bdrv_start_throttled_reqs(bs)) {
busy = true;
}
}
busy = bdrv_requests_pending_all();
busy |= aio_poll(qemu_get_aio_context(), busy);
}
}
| true | qemu | 0b06ef3bdd17742ae50c0662d3fe8ed944648890 | void bdrv_drain_all(void)
{
bool busy = true;
BlockDriverState *bs;
while (busy) {
QTAILQ_FOREACH(bs, &bdrv_states, list) {
if (bdrv_start_throttled_reqs(bs)) {
busy = true;
}
}
busy = bdrv_requests_pending_all();
busy |= aio_poll(qemu_get_aio_context(), busy);
}
}
| {
"code": [
" if (bdrv_start_throttled_reqs(bs)) {",
" busy = true;"
],
"line_no": [
23,
25
]
} | void FUNC_0(void)
{
bool busy = true;
BlockDriverState *bs;
while (busy) {
QTAILQ_FOREACH(bs, &bdrv_states, list) {
if (bdrv_start_throttled_reqs(bs)) {
busy = true;
}
}
busy = bdrv_requests_pending_all();
busy |= aio_poll(qemu_get_aio_context(), busy);
}
}
| [
"void FUNC_0(void)\n{",
"bool busy = true;",
"BlockDriverState *bs;",
"while (busy) {",
"QTAILQ_FOREACH(bs, &bdrv_states, list) {",
"if (bdrv_start_throttled_reqs(bs)) {",
"busy = true;",
"}",
"}",
"busy = bdrv_requests_pending_all();",
"busy |= aio_poll(qemu_get_aio_context(), busy);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
13
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
22,851 | static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
TCGv r_cond)
{
unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
target_ulong target = dc->pc + offset;
if (cond == 0x0) {
/* unconditional not taken */
if (a) {
dc->pc = dc->npc + 4;
dc->npc = dc->pc + 4;
} else {
dc->pc = dc->npc;
dc->npc = dc->pc + 4;
}
} else if (cond == 0x8) {
/* unconditional taken */
if (a) {
dc->pc = target;
dc->npc = dc->pc + 4;
} else {
dc->pc = dc->npc;
dc->npc = target;
tcg_gen_mov_tl(cpu_pc, cpu_npc);
}
} else {
flush_cond(dc, r_cond);
gen_fcond(r_cond, cc, cond);
if (a) {
gen_branch_a(dc, target, dc->npc, r_cond);
dc->is_br = 1;
} else {
dc->pc = dc->npc;
dc->jump_pc[0] = target;
dc->jump_pc[1] = dc->npc + 4;
dc->npc = JUMP_PC;
}
}
}
| false | qemu | 548f66db33b91bf305c4e5228bb29585701ab58d | static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
TCGv r_cond)
{
unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
target_ulong target = dc->pc + offset;
if (cond == 0x0) {
if (a) {
dc->pc = dc->npc + 4;
dc->npc = dc->pc + 4;
} else {
dc->pc = dc->npc;
dc->npc = dc->pc + 4;
}
} else if (cond == 0x8) {
if (a) {
dc->pc = target;
dc->npc = dc->pc + 4;
} else {
dc->pc = dc->npc;
dc->npc = target;
tcg_gen_mov_tl(cpu_pc, cpu_npc);
}
} else {
flush_cond(dc, r_cond);
gen_fcond(r_cond, cc, cond);
if (a) {
gen_branch_a(dc, target, dc->npc, r_cond);
dc->is_br = 1;
} else {
dc->pc = dc->npc;
dc->jump_pc[0] = target;
dc->jump_pc[1] = dc->npc + 4;
dc->npc = JUMP_PC;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, int32_t VAR_1, uint32_t VAR_2, int VAR_3,
TCGv VAR_4)
{
unsigned int VAR_5 = GET_FIELD(VAR_2, 3, 6), VAR_6 = (VAR_2 & (1 << 29));
target_ulong target = VAR_0->pc + VAR_1;
if (VAR_5 == 0x0) {
if (VAR_6) {
VAR_0->pc = VAR_0->npc + 4;
VAR_0->npc = VAR_0->pc + 4;
} else {
VAR_0->pc = VAR_0->npc;
VAR_0->npc = VAR_0->pc + 4;
}
} else if (VAR_5 == 0x8) {
if (VAR_6) {
VAR_0->pc = target;
VAR_0->npc = VAR_0->pc + 4;
} else {
VAR_0->pc = VAR_0->npc;
VAR_0->npc = target;
tcg_gen_mov_tl(cpu_pc, cpu_npc);
}
} else {
flush_cond(VAR_0, VAR_4);
gen_fcond(VAR_4, VAR_3, VAR_5);
if (VAR_6) {
gen_branch_a(VAR_0, target, VAR_0->npc, VAR_4);
VAR_0->is_br = 1;
} else {
VAR_0->pc = VAR_0->npc;
VAR_0->jump_pc[0] = target;
VAR_0->jump_pc[1] = VAR_0->npc + 4;
VAR_0->npc = JUMP_PC;
}
}
}
| [
"static void FUNC_0(DisasContext *VAR_0, int32_t VAR_1, uint32_t VAR_2, int VAR_3,\nTCGv VAR_4)\n{",
"unsigned int VAR_5 = GET_FIELD(VAR_2, 3, 6), VAR_6 = (VAR_2 & (1 << 29));",
"target_ulong target = VAR_0->pc + VAR_1;",
"if (VAR_5 == 0x0) {",
"if (VAR_6) {",
"VAR_0->pc = VAR_0->npc + 4;",
"VAR_0->npc = VAR_0->pc + 4;",
"} else {",
"VAR_0->pc = VAR_0->npc;",
"VAR_0->npc = VAR_0->pc + 4;",
"}",
"} else if (VAR_5 == 0x8) {",
"if (VAR_6) {",
"VAR_0->pc = target;",
"VAR_0->npc = VAR_0->pc + 4;",
"} else {",
"VAR_0->pc = VAR_0->npc;",
"VAR_0->npc = target;",
"tcg_gen_mov_tl(cpu_pc, cpu_npc);",
"}",
"} else {",
"flush_cond(VAR_0, VAR_4);",
"gen_fcond(VAR_4, VAR_3, VAR_5);",
"if (VAR_6) {",
"gen_branch_a(VAR_0, target, VAR_0->npc, VAR_4);",
"VAR_0->is_br = 1;",
"} else {",
"VAR_0->pc = VAR_0->npc;",
"VAR_0->jump_pc[0] = target;",
"VAR_0->jump_pc[1] = VAR_0->npc + 4;",
"VAR_0->npc = JUMP_PC;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
22,852 | static inline uint32_t vtd_slpt_level_shift(uint32_t level)
{
return VTD_PAGE_SHIFT_4K + (level - 1) * VTD_SL_LEVEL_BITS;
}
| false | qemu | d66b969b0d9c8eefdcbff4b48535b0fe1501d139 | static inline uint32_t vtd_slpt_level_shift(uint32_t level)
{
return VTD_PAGE_SHIFT_4K + (level - 1) * VTD_SL_LEVEL_BITS;
}
| {
"code": [],
"line_no": []
} | static inline uint32_t FUNC_0(uint32_t level)
{
return VTD_PAGE_SHIFT_4K + (level - 1) * VTD_SL_LEVEL_BITS;
}
| [
"static inline uint32_t FUNC_0(uint32_t level)\n{",
"return VTD_PAGE_SHIFT_4K + (level - 1) * VTD_SL_LEVEL_BITS;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,853 | static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,
uint64_t *slptep, uint32_t *slpte_level,
bool *reads, bool *writes)
{
dma_addr_t addr = vtd_get_slpt_base_from_context(ce);
uint32_t level = vtd_get_level_from_context_entry(ce);
uint32_t offset;
uint64_t slpte;
uint32_t ce_agaw = vtd_get_agaw_from_context_entry(ce);
uint64_t access_right_check;
/* Check if @iova is above 2^X-1, where X is the minimum of MGAW
* in CAP_REG and AW in context-entry.
*/
if (iova & ~((1ULL << MIN(ce_agaw, VTD_MGAW)) - 1)) {
VTD_DPRINTF(GENERAL, "error: iova 0x%"PRIx64 " exceeds limits", iova);
return -VTD_FR_ADDR_BEYOND_MGAW;
}
/* FIXME: what is the Atomics request here? */
access_right_check = is_write ? VTD_SL_W : VTD_SL_R;
while (true) {
offset = vtd_iova_level_offset(iova, level);
slpte = vtd_get_slpte(addr, offset);
if (slpte == (uint64_t)-1) {
VTD_DPRINTF(GENERAL, "error: fail to access second-level paging "
"entry at level %"PRIu32 " for iova 0x%"PRIx64,
level, iova);
if (level == vtd_get_level_from_context_entry(ce)) {
/* Invalid programming of context-entry */
return -VTD_FR_CONTEXT_ENTRY_INV;
} else {
return -VTD_FR_PAGING_ENTRY_INV;
}
}
*reads = (*reads) && (slpte & VTD_SL_R);
*writes = (*writes) && (slpte & VTD_SL_W);
if (!(slpte & access_right_check)) {
VTD_DPRINTF(GENERAL, "error: lack of %s permission for "
"iova 0x%"PRIx64 " slpte 0x%"PRIx64,
(is_write ? "write" : "read"), iova, slpte);
return is_write ? -VTD_FR_WRITE : -VTD_FR_READ;
}
if (vtd_slpte_nonzero_rsvd(slpte, level)) {
VTD_DPRINTF(GENERAL, "error: non-zero reserved field in second "
"level paging entry level %"PRIu32 " slpte 0x%"PRIx64,
level, slpte);
return -VTD_FR_PAGING_ENTRY_RSVD;
}
if (vtd_is_last_slpte(slpte, level)) {
*slptep = slpte;
*slpte_level = level;
return 0;
}
addr = vtd_get_slpte_addr(slpte);
level--;
}
}
| false | qemu | f06a696dc958dd80f7eaf5be66fdefac77741ee0 | static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,
uint64_t *slptep, uint32_t *slpte_level,
bool *reads, bool *writes)
{
dma_addr_t addr = vtd_get_slpt_base_from_context(ce);
uint32_t level = vtd_get_level_from_context_entry(ce);
uint32_t offset;
uint64_t slpte;
uint32_t ce_agaw = vtd_get_agaw_from_context_entry(ce);
uint64_t access_right_check;
if (iova & ~((1ULL << MIN(ce_agaw, VTD_MGAW)) - 1)) {
VTD_DPRINTF(GENERAL, "error: iova 0x%"PRIx64 " exceeds limits", iova);
return -VTD_FR_ADDR_BEYOND_MGAW;
}
access_right_check = is_write ? VTD_SL_W : VTD_SL_R;
while (true) {
offset = vtd_iova_level_offset(iova, level);
slpte = vtd_get_slpte(addr, offset);
if (slpte == (uint64_t)-1) {
VTD_DPRINTF(GENERAL, "error: fail to access second-level paging "
"entry at level %"PRIu32 " for iova 0x%"PRIx64,
level, iova);
if (level == vtd_get_level_from_context_entry(ce)) {
return -VTD_FR_CONTEXT_ENTRY_INV;
} else {
return -VTD_FR_PAGING_ENTRY_INV;
}
}
*reads = (*reads) && (slpte & VTD_SL_R);
*writes = (*writes) && (slpte & VTD_SL_W);
if (!(slpte & access_right_check)) {
VTD_DPRINTF(GENERAL, "error: lack of %s permission for "
"iova 0x%"PRIx64 " slpte 0x%"PRIx64,
(is_write ? "write" : "read"), iova, slpte);
return is_write ? -VTD_FR_WRITE : -VTD_FR_READ;
}
if (vtd_slpte_nonzero_rsvd(slpte, level)) {
VTD_DPRINTF(GENERAL, "error: non-zero reserved field in second "
"level paging entry level %"PRIu32 " slpte 0x%"PRIx64,
level, slpte);
return -VTD_FR_PAGING_ENTRY_RSVD;
}
if (vtd_is_last_slpte(slpte, level)) {
*slptep = slpte;
*slpte_level = level;
return 0;
}
addr = vtd_get_slpte_addr(slpte);
level--;
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VTDContextEntry *VAR_0, uint64_t VAR_1, bool VAR_2,
uint64_t *VAR_3, uint32_t *VAR_4,
bool *VAR_5, bool *VAR_6)
{
dma_addr_t addr = vtd_get_slpt_base_from_context(VAR_0);
uint32_t level = vtd_get_level_from_context_entry(VAR_0);
uint32_t offset;
uint64_t slpte;
uint32_t ce_agaw = vtd_get_agaw_from_context_entry(VAR_0);
uint64_t access_right_check;
if (VAR_1 & ~((1ULL << MIN(ce_agaw, VTD_MGAW)) - 1)) {
VTD_DPRINTF(GENERAL, "error: VAR_1 0x%"PRIx64 " exceeds limits", VAR_1);
return -VTD_FR_ADDR_BEYOND_MGAW;
}
access_right_check = VAR_2 ? VTD_SL_W : VTD_SL_R;
while (true) {
offset = vtd_iova_level_offset(VAR_1, level);
slpte = vtd_get_slpte(addr, offset);
if (slpte == (uint64_t)-1) {
VTD_DPRINTF(GENERAL, "error: fail to access second-level paging "
"entry at level %"PRIu32 " for VAR_1 0x%"PRIx64,
level, VAR_1);
if (level == vtd_get_level_from_context_entry(VAR_0)) {
return -VTD_FR_CONTEXT_ENTRY_INV;
} else {
return -VTD_FR_PAGING_ENTRY_INV;
}
}
*VAR_5 = (*VAR_5) && (slpte & VTD_SL_R);
*VAR_6 = (*VAR_6) && (slpte & VTD_SL_W);
if (!(slpte & access_right_check)) {
VTD_DPRINTF(GENERAL, "error: lack of %s permission for "
"VAR_1 0x%"PRIx64 " slpte 0x%"PRIx64,
(VAR_2 ? "write" : "read"), VAR_1, slpte);
return VAR_2 ? -VTD_FR_WRITE : -VTD_FR_READ;
}
if (vtd_slpte_nonzero_rsvd(slpte, level)) {
VTD_DPRINTF(GENERAL, "error: non-zero reserved field in second "
"level paging entry level %"PRIu32 " slpte 0x%"PRIx64,
level, slpte);
return -VTD_FR_PAGING_ENTRY_RSVD;
}
if (vtd_is_last_slpte(slpte, level)) {
*VAR_3 = slpte;
*VAR_4 = level;
return 0;
}
addr = vtd_get_slpte_addr(slpte);
level--;
}
}
| [
"static int FUNC_0(VTDContextEntry *VAR_0, uint64_t VAR_1, bool VAR_2,\nuint64_t *VAR_3, uint32_t *VAR_4,\nbool *VAR_5, bool *VAR_6)\n{",
"dma_addr_t addr = vtd_get_slpt_base_from_context(VAR_0);",
"uint32_t level = vtd_get_level_from_context_entry(VAR_0);",
"uint32_t offset;",
"uint64_t slpte;",
"uint32_t ce_agaw = vtd_get_agaw_from_context_entry(VAR_0);",
"uint64_t access_right_check;",
"if (VAR_1 & ~((1ULL << MIN(ce_agaw, VTD_MGAW)) - 1)) {",
"VTD_DPRINTF(GENERAL, \"error: VAR_1 0x%\"PRIx64 \" exceeds limits\", VAR_1);",
"return -VTD_FR_ADDR_BEYOND_MGAW;",
"}",
"access_right_check = VAR_2 ? VTD_SL_W : VTD_SL_R;",
"while (true) {",
"offset = vtd_iova_level_offset(VAR_1, level);",
"slpte = vtd_get_slpte(addr, offset);",
"if (slpte == (uint64_t)-1) {",
"VTD_DPRINTF(GENERAL, \"error: fail to access second-level paging \"\n\"entry at level %\"PRIu32 \" for VAR_1 0x%\"PRIx64,\nlevel, VAR_1);",
"if (level == vtd_get_level_from_context_entry(VAR_0)) {",
"return -VTD_FR_CONTEXT_ENTRY_INV;",
"} else {",
"return -VTD_FR_PAGING_ENTRY_INV;",
"}",
"}",
"*VAR_5 = (*VAR_5) && (slpte & VTD_SL_R);",
"*VAR_6 = (*VAR_6) && (slpte & VTD_SL_W);",
"if (!(slpte & access_right_check)) {",
"VTD_DPRINTF(GENERAL, \"error: lack of %s permission for \"\n\"VAR_1 0x%\"PRIx64 \" slpte 0x%\"PRIx64,\n(VAR_2 ? \"write\" : \"read\"), VAR_1, slpte);",
"return VAR_2 ? -VTD_FR_WRITE : -VTD_FR_READ;",
"}",
"if (vtd_slpte_nonzero_rsvd(slpte, level)) {",
"VTD_DPRINTF(GENERAL, \"error: non-zero reserved field in second \"\n\"level paging entry level %\"PRIu32 \" slpte 0x%\"PRIx64,\nlevel, slpte);",
"return -VTD_FR_PAGING_ENTRY_RSVD;",
"}",
"if (vtd_is_last_slpte(slpte, level)) {",
"*VAR_3 = slpte;",
"*VAR_4 = level;",
"return 0;",
"}",
"addr = vtd_get_slpte_addr(slpte);",
"level--;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55,
57,
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83,
85
],
[
87
],
[
89
],
[
91
],
[
93,
95,
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
]
] |
22,854 | PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers)
{
PPCE500PCIState *controller;
PCIDevice *d;
int index;
static int ppce500_pci_id;
controller = qemu_mallocz(sizeof(PPCE500PCIState));
controller->pci_state.bus = pci_register_bus(NULL, "pci",
mpc85xx_pci_set_irq,
mpc85xx_pci_map_irq,
pci_irqs, 0x88, 4);
d = pci_register_device(controller->pci_state.bus,
"host bridge", sizeof(PCIDevice),
0, NULL, NULL);
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_FREESCALE);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_MPC8533E);
pci_config_set_class(d->config, PCI_CLASS_PROCESSOR_POWERPC);
controller->pci_dev = d;
/* CFGADDR */
index = cpu_register_io_memory(pcie500_cfgaddr_read,
pcie500_cfgaddr_write, controller);
if (index < 0)
goto free;
cpu_register_physical_memory(registers + PCIE500_CFGADDR, 4, index);
/* CFGDATA */
index = cpu_register_io_memory(pcie500_cfgdata_read,
pcie500_cfgdata_write,
&controller->pci_state);
if (index < 0)
goto free;
cpu_register_physical_memory(registers + PCIE500_CFGDATA, 4, index);
index = cpu_register_io_memory(e500_pci_reg_read,
e500_pci_reg_write, controller);
if (index < 0)
goto free;
cpu_register_physical_memory(registers + PCIE500_REG_BASE,
PCIE500_REG_SIZE, index);
/* XXX load/save code not tested. */
register_savevm("ppce500_pci", ppce500_pci_id++, 1,
ppce500_pci_save, ppce500_pci_load, controller);
return controller->pci_state.bus;
free:
printf("%s error\n", __func__);
qemu_free(controller);
return NULL;
}
| false | qemu | 4f5e19e6c570459cd524b29b24374f03860f5149 | PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers)
{
PPCE500PCIState *controller;
PCIDevice *d;
int index;
static int ppce500_pci_id;
controller = qemu_mallocz(sizeof(PPCE500PCIState));
controller->pci_state.bus = pci_register_bus(NULL, "pci",
mpc85xx_pci_set_irq,
mpc85xx_pci_map_irq,
pci_irqs, 0x88, 4);
d = pci_register_device(controller->pci_state.bus,
"host bridge", sizeof(PCIDevice),
0, NULL, NULL);
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_FREESCALE);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_MPC8533E);
pci_config_set_class(d->config, PCI_CLASS_PROCESSOR_POWERPC);
controller->pci_dev = d;
index = cpu_register_io_memory(pcie500_cfgaddr_read,
pcie500_cfgaddr_write, controller);
if (index < 0)
goto free;
cpu_register_physical_memory(registers + PCIE500_CFGADDR, 4, index);
index = cpu_register_io_memory(pcie500_cfgdata_read,
pcie500_cfgdata_write,
&controller->pci_state);
if (index < 0)
goto free;
cpu_register_physical_memory(registers + PCIE500_CFGDATA, 4, index);
index = cpu_register_io_memory(e500_pci_reg_read,
e500_pci_reg_write, controller);
if (index < 0)
goto free;
cpu_register_physical_memory(registers + PCIE500_REG_BASE,
PCIE500_REG_SIZE, index);
register_savevm("ppce500_pci", ppce500_pci_id++, 1,
ppce500_pci_save, ppce500_pci_load, controller);
return controller->pci_state.bus;
free:
printf("%s error\n", __func__);
qemu_free(controller);
return NULL;
}
| {
"code": [],
"line_no": []
} | PCIBus *FUNC_0(qemu_irq pci_irqs[4], target_phys_addr_t registers)
{
PPCE500PCIState *controller;
PCIDevice *d;
int VAR_0;
static int VAR_1;
controller = qemu_mallocz(sizeof(PPCE500PCIState));
controller->pci_state.bus = pci_register_bus(NULL, "pci",
mpc85xx_pci_set_irq,
mpc85xx_pci_map_irq,
pci_irqs, 0x88, 4);
d = pci_register_device(controller->pci_state.bus,
"host bridge", sizeof(PCIDevice),
0, NULL, NULL);
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_FREESCALE);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_MPC8533E);
pci_config_set_class(d->config, PCI_CLASS_PROCESSOR_POWERPC);
controller->pci_dev = d;
VAR_0 = cpu_register_io_memory(pcie500_cfgaddr_read,
pcie500_cfgaddr_write, controller);
if (VAR_0 < 0)
goto free;
cpu_register_physical_memory(registers + PCIE500_CFGADDR, 4, VAR_0);
VAR_0 = cpu_register_io_memory(pcie500_cfgdata_read,
pcie500_cfgdata_write,
&controller->pci_state);
if (VAR_0 < 0)
goto free;
cpu_register_physical_memory(registers + PCIE500_CFGDATA, 4, VAR_0);
VAR_0 = cpu_register_io_memory(e500_pci_reg_read,
e500_pci_reg_write, controller);
if (VAR_0 < 0)
goto free;
cpu_register_physical_memory(registers + PCIE500_REG_BASE,
PCIE500_REG_SIZE, VAR_0);
register_savevm("ppce500_pci", VAR_1++, 1,
ppce500_pci_save, ppce500_pci_load, controller);
return controller->pci_state.bus;
free:
printf("%s error\n", __func__);
qemu_free(controller);
return NULL;
}
| [
"PCIBus *FUNC_0(qemu_irq pci_irqs[4], target_phys_addr_t registers)\n{",
"PPCE500PCIState *controller;",
"PCIDevice *d;",
"int VAR_0;",
"static int VAR_1;",
"controller = qemu_mallocz(sizeof(PPCE500PCIState));",
"controller->pci_state.bus = pci_register_bus(NULL, \"pci\",\nmpc85xx_pci_set_irq,\nmpc85xx_pci_map_irq,\npci_irqs, 0x88, 4);",
"d = pci_register_device(controller->pci_state.bus,\n\"host bridge\", sizeof(PCIDevice),\n0, NULL, NULL);",
"pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_FREESCALE);",
"pci_config_set_device_id(d->config, PCI_DEVICE_ID_MPC8533E);",
"pci_config_set_class(d->config, PCI_CLASS_PROCESSOR_POWERPC);",
"controller->pci_dev = d;",
"VAR_0 = cpu_register_io_memory(pcie500_cfgaddr_read,\npcie500_cfgaddr_write, controller);",
"if (VAR_0 < 0)\ngoto free;",
"cpu_register_physical_memory(registers + PCIE500_CFGADDR, 4, VAR_0);",
"VAR_0 = cpu_register_io_memory(pcie500_cfgdata_read,\npcie500_cfgdata_write,\n&controller->pci_state);",
"if (VAR_0 < 0)\ngoto free;",
"cpu_register_physical_memory(registers + PCIE500_CFGDATA, 4, VAR_0);",
"VAR_0 = cpu_register_io_memory(e500_pci_reg_read,\ne500_pci_reg_write, controller);",
"if (VAR_0 < 0)\ngoto free;",
"cpu_register_physical_memory(registers + PCIE500_REG_BASE,\nPCIE500_REG_SIZE, VAR_0);",
"register_savevm(\"ppce500_pci\", VAR_1++, 1,\nppce500_pci_save, ppce500_pci_load, controller);",
"return controller->pci_state.bus;",
"free:\nprintf(\"%s error\\n\", __func__);",
"qemu_free(controller);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19,
21,
23,
25
],
[
27,
29,
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
49,
51
],
[
53,
55
],
[
57
],
[
63,
65,
67
],
[
69,
71
],
[
73
],
[
77,
79
],
[
81,
83
],
[
85,
87
],
[
93,
95
],
[
99
],
[
103,
105
],
[
107
],
[
109
],
[
111
]
] |
22,856 | int omap_validate_tipb_addr(struct omap_mpu_state_s *s,
target_phys_addr_t addr)
{
return addr >= 0xfffb0000 && addr < 0xffff0000;
}
| false | qemu | b854bc196f5c4b4e3299c0b0ee63cf828ece9e77 | int omap_validate_tipb_addr(struct omap_mpu_state_s *s,
target_phys_addr_t addr)
{
return addr >= 0xfffb0000 && addr < 0xffff0000;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(struct omap_mpu_state_s *VAR_0,
target_phys_addr_t VAR_1)
{
return VAR_1 >= 0xfffb0000 && VAR_1 < 0xffff0000;
}
| [
"int FUNC_0(struct omap_mpu_state_s *VAR_0,\ntarget_phys_addr_t VAR_1)\n{",
"return VAR_1 >= 0xfffb0000 && VAR_1 < 0xffff0000;",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.