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
listlengths 1
2.8k
| label
listlengths 1
2.8k
| line_no
listlengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
10,331 | static void vmsvga_init(struct vmsvga_state_s *s,
MemoryRegion *address_space, MemoryRegion *io)
{
s->scratch_size = SVGA_SCRATCH_SIZE;
s->scratch = g_malloc(s->scratch_size * 4);
s->vga.con = graphic_console_init(vmsvga_update_display,
vmsvga_invalidate_display,
vmsvga_screen_dump,
vmsvga_text_update, s);
s->fifo_size = SVGA_FIFO_SIZE;
memory_region_init_ram(&s->fifo_ram, "vmsvga.fifo", s->fifo_size);
vmstate_register_ram_global(&s->fifo_ram);
s->fifo_ptr = memory_region_get_ram_ptr(&s->fifo_ram);
vga_common_init(&s->vga);
vga_init(&s->vga, address_space, io, true);
vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
s->new_depth = 32;
}
| false | qemu | 2c62f08ddbf3fa80dc7202eb9a2ea60ae44e2cc5 | static void vmsvga_init(struct vmsvga_state_s *s,
MemoryRegion *address_space, MemoryRegion *io)
{
s->scratch_size = SVGA_SCRATCH_SIZE;
s->scratch = g_malloc(s->scratch_size * 4);
s->vga.con = graphic_console_init(vmsvga_update_display,
vmsvga_invalidate_display,
vmsvga_screen_dump,
vmsvga_text_update, s);
s->fifo_size = SVGA_FIFO_SIZE;
memory_region_init_ram(&s->fifo_ram, "vmsvga.fifo", s->fifo_size);
vmstate_register_ram_global(&s->fifo_ram);
s->fifo_ptr = memory_region_get_ram_ptr(&s->fifo_ram);
vga_common_init(&s->vga);
vga_init(&s->vga, address_space, io, true);
vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
s->new_depth = 32;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct vmsvga_state_s *VAR_0,
MemoryRegion *VAR_1, MemoryRegion *VAR_2)
{
VAR_0->scratch_size = SVGA_SCRATCH_SIZE;
VAR_0->scratch = g_malloc(VAR_0->scratch_size * 4);
VAR_0->vga.con = graphic_console_init(vmsvga_update_display,
vmsvga_invalidate_display,
vmsvga_screen_dump,
vmsvga_text_update, VAR_0);
VAR_0->fifo_size = SVGA_FIFO_SIZE;
memory_region_init_ram(&VAR_0->fifo_ram, "vmsvga.fifo", VAR_0->fifo_size);
vmstate_register_ram_global(&VAR_0->fifo_ram);
VAR_0->fifo_ptr = memory_region_get_ram_ptr(&VAR_0->fifo_ram);
vga_common_init(&VAR_0->vga);
vga_init(&VAR_0->vga, VAR_1, VAR_2, true);
vmstate_register(NULL, 0, &vmstate_vga_common, &VAR_0->vga);
VAR_0->new_depth = 32;
}
| [
"static void FUNC_0(struct vmsvga_state_s *VAR_0,\nMemoryRegion *VAR_1, MemoryRegion *VAR_2)\n{",
"VAR_0->scratch_size = SVGA_SCRATCH_SIZE;",
"VAR_0->scratch = g_malloc(VAR_0->scratch_size * 4);",
"VAR_0->vga.con = graphic_console_init(vmsvga_update_display,\nvmsvga_invalidate_display,\nvmsvga_screen_dump,\nvmsvga_text_update, VAR_0);",
"VAR_0->fifo_size = SVGA_FIFO_SIZE;",
"memory_region_init_ram(&VAR_0->fifo_ram, \"vmsvga.fifo\", VAR_0->fifo_size);",
"vmstate_register_ram_global(&VAR_0->fifo_ram);",
"VAR_0->fifo_ptr = memory_region_get_ram_ptr(&VAR_0->fifo_ram);",
"vga_common_init(&VAR_0->vga);",
"vga_init(&VAR_0->vga, VAR_1, VAR_2, true);",
"vmstate_register(NULL, 0, &vmstate_vga_common, &VAR_0->vga);",
"VAR_0->new_depth = 32;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15,
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
]
|
10,332 | static int local_set_mapped_file_attr(FsContext *ctx,
const char *path, FsCred *credp)
{
FILE *fp;
int ret = 0;
char buf[ATTR_MAX];
char attr_path[PATH_MAX];
int uid = -1, gid = -1, mode = -1, rdev = -1;
fp = local_fopen(local_mapped_attr_path(ctx, path, attr_path), "r");
if (!fp) {
goto create_map_file;
}
memset(buf, 0, ATTR_MAX);
while (fgets(buf, ATTR_MAX, fp)) {
if (!strncmp(buf, "virtfs.uid", 10)) {
uid = atoi(buf+11);
} else if (!strncmp(buf, "virtfs.gid", 10)) {
gid = atoi(buf+11);
} else if (!strncmp(buf, "virtfs.mode", 11)) {
mode = atoi(buf+12);
} else if (!strncmp(buf, "virtfs.rdev", 11)) {
rdev = atoi(buf+12);
}
memset(buf, 0, ATTR_MAX);
}
fclose(fp);
goto update_map_file;
create_map_file:
ret = local_create_mapped_attr_dir(ctx, path);
if (ret < 0) {
goto err_out;
}
update_map_file:
fp = local_fopen(attr_path, "w");
if (!fp) {
ret = -1;
goto err_out;
}
if (credp->fc_uid != -1) {
uid = credp->fc_uid;
}
if (credp->fc_gid != -1) {
gid = credp->fc_gid;
}
if (credp->fc_mode != -1) {
mode = credp->fc_mode;
}
if (credp->fc_rdev != -1) {
rdev = credp->fc_rdev;
}
if (uid != -1) {
fprintf(fp, "virtfs.uid=%d\n", uid);
}
if (gid != -1) {
fprintf(fp, "virtfs.gid=%d\n", gid);
}
if (mode != -1) {
fprintf(fp, "virtfs.mode=%d\n", mode);
}
if (rdev != -1) {
fprintf(fp, "virtfs.rdev=%d\n", rdev);
}
fclose(fp);
err_out:
return ret;
}
| false | qemu | 4fa4ce7107c6ec432f185307158c5df91ce54308 | static int local_set_mapped_file_attr(FsContext *ctx,
const char *path, FsCred *credp)
{
FILE *fp;
int ret = 0;
char buf[ATTR_MAX];
char attr_path[PATH_MAX];
int uid = -1, gid = -1, mode = -1, rdev = -1;
fp = local_fopen(local_mapped_attr_path(ctx, path, attr_path), "r");
if (!fp) {
goto create_map_file;
}
memset(buf, 0, ATTR_MAX);
while (fgets(buf, ATTR_MAX, fp)) {
if (!strncmp(buf, "virtfs.uid", 10)) {
uid = atoi(buf+11);
} else if (!strncmp(buf, "virtfs.gid", 10)) {
gid = atoi(buf+11);
} else if (!strncmp(buf, "virtfs.mode", 11)) {
mode = atoi(buf+12);
} else if (!strncmp(buf, "virtfs.rdev", 11)) {
rdev = atoi(buf+12);
}
memset(buf, 0, ATTR_MAX);
}
fclose(fp);
goto update_map_file;
create_map_file:
ret = local_create_mapped_attr_dir(ctx, path);
if (ret < 0) {
goto err_out;
}
update_map_file:
fp = local_fopen(attr_path, "w");
if (!fp) {
ret = -1;
goto err_out;
}
if (credp->fc_uid != -1) {
uid = credp->fc_uid;
}
if (credp->fc_gid != -1) {
gid = credp->fc_gid;
}
if (credp->fc_mode != -1) {
mode = credp->fc_mode;
}
if (credp->fc_rdev != -1) {
rdev = credp->fc_rdev;
}
if (uid != -1) {
fprintf(fp, "virtfs.uid=%d\n", uid);
}
if (gid != -1) {
fprintf(fp, "virtfs.gid=%d\n", gid);
}
if (mode != -1) {
fprintf(fp, "virtfs.mode=%d\n", mode);
}
if (rdev != -1) {
fprintf(fp, "virtfs.rdev=%d\n", rdev);
}
fclose(fp);
err_out:
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0,
const char *VAR_1, FsCred *VAR_2)
{
FILE *fp;
int VAR_3 = 0;
char VAR_4[ATTR_MAX];
char VAR_5[PATH_MAX];
int VAR_6 = -1, VAR_7 = -1, VAR_8 = -1, VAR_9 = -1;
fp = local_fopen(local_mapped_attr_path(VAR_0, VAR_1, VAR_5), "r");
if (!fp) {
goto create_map_file;
}
memset(VAR_4, 0, ATTR_MAX);
while (fgets(VAR_4, ATTR_MAX, fp)) {
if (!strncmp(VAR_4, "virtfs.VAR_6", 10)) {
VAR_6 = atoi(VAR_4+11);
} else if (!strncmp(VAR_4, "virtfs.VAR_7", 10)) {
VAR_7 = atoi(VAR_4+11);
} else if (!strncmp(VAR_4, "virtfs.VAR_8", 11)) {
VAR_8 = atoi(VAR_4+12);
} else if (!strncmp(VAR_4, "virtfs.VAR_9", 11)) {
VAR_9 = atoi(VAR_4+12);
}
memset(VAR_4, 0, ATTR_MAX);
}
fclose(fp);
goto update_map_file;
create_map_file:
VAR_3 = local_create_mapped_attr_dir(VAR_0, VAR_1);
if (VAR_3 < 0) {
goto err_out;
}
update_map_file:
fp = local_fopen(VAR_5, "w");
if (!fp) {
VAR_3 = -1;
goto err_out;
}
if (VAR_2->fc_uid != -1) {
VAR_6 = VAR_2->fc_uid;
}
if (VAR_2->fc_gid != -1) {
VAR_7 = VAR_2->fc_gid;
}
if (VAR_2->fc_mode != -1) {
VAR_8 = VAR_2->fc_mode;
}
if (VAR_2->fc_rdev != -1) {
VAR_9 = VAR_2->fc_rdev;
}
if (VAR_6 != -1) {
fprintf(fp, "virtfs.VAR_6=%d\n", VAR_6);
}
if (VAR_7 != -1) {
fprintf(fp, "virtfs.VAR_7=%d\n", VAR_7);
}
if (VAR_8 != -1) {
fprintf(fp, "virtfs.VAR_8=%d\n", VAR_8);
}
if (VAR_9 != -1) {
fprintf(fp, "virtfs.VAR_9=%d\n", VAR_9);
}
fclose(fp);
err_out:
return VAR_3;
}
| [
"static int FUNC_0(FsContext *VAR_0,\nconst char *VAR_1, FsCred *VAR_2)\n{",
"FILE *fp;",
"int VAR_3 = 0;",
"char VAR_4[ATTR_MAX];",
"char VAR_5[PATH_MAX];",
"int VAR_6 = -1, VAR_7 = -1, VAR_8 = -1, VAR_9 = -1;",
"fp = local_fopen(local_mapped_attr_path(VAR_0, VAR_1, VAR_5), \"r\");",
"if (!fp) {",
"goto create_map_file;",
"}",
"memset(VAR_4, 0, ATTR_MAX);",
"while (fgets(VAR_4, ATTR_MAX, fp)) {",
"if (!strncmp(VAR_4, \"virtfs.VAR_6\", 10)) {",
"VAR_6 = atoi(VAR_4+11);",
"} else if (!strncmp(VAR_4, \"virtfs.VAR_7\", 10)) {",
"VAR_7 = atoi(VAR_4+11);",
"} else if (!strncmp(VAR_4, \"virtfs.VAR_8\", 11)) {",
"VAR_8 = atoi(VAR_4+12);",
"} else if (!strncmp(VAR_4, \"virtfs.VAR_9\", 11)) {",
"VAR_9 = atoi(VAR_4+12);",
"}",
"memset(VAR_4, 0, ATTR_MAX);",
"}",
"fclose(fp);",
"goto update_map_file;",
"create_map_file:\nVAR_3 = local_create_mapped_attr_dir(VAR_0, VAR_1);",
"if (VAR_3 < 0) {",
"goto err_out;",
"}",
"update_map_file:\nfp = local_fopen(VAR_5, \"w\");",
"if (!fp) {",
"VAR_3 = -1;",
"goto err_out;",
"}",
"if (VAR_2->fc_uid != -1) {",
"VAR_6 = VAR_2->fc_uid;",
"}",
"if (VAR_2->fc_gid != -1) {",
"VAR_7 = VAR_2->fc_gid;",
"}",
"if (VAR_2->fc_mode != -1) {",
"VAR_8 = VAR_2->fc_mode;",
"}",
"if (VAR_2->fc_rdev != -1) {",
"VAR_9 = VAR_2->fc_rdev;",
"}",
"if (VAR_6 != -1) {",
"fprintf(fp, \"virtfs.VAR_6=%d\\n\", VAR_6);",
"}",
"if (VAR_7 != -1) {",
"fprintf(fp, \"virtfs.VAR_7=%d\\n\", VAR_7);",
"}",
"if (VAR_8 != -1) {",
"fprintf(fp, \"virtfs.VAR_8=%d\\n\", VAR_8);",
"}",
"if (VAR_9 != -1) {",
"fprintf(fp, \"virtfs.VAR_9=%d\\n\", VAR_9);",
"}",
"fclose(fp);",
"err_out:\nreturn VAR_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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141,
143
],
[
145
]
]
|
10,334 | static int64_t qemu_next_alarm_deadline(void)
{
int64_t delta;
int64_t rtdelta;
if (!use_icount && vm_clock->active_timers) {
delta = vm_clock->active_timers->expire_time -
qemu_get_clock_ns(vm_clock);
} else {
delta = INT32_MAX;
}
if (host_clock->active_timers) {
int64_t hdelta = host_clock->active_timers->expire_time -
qemu_get_clock_ns(host_clock);
if (hdelta < delta) {
delta = hdelta;
}
}
if (rt_clock->active_timers) {
rtdelta = (rt_clock->active_timers->expire_time -
qemu_get_clock_ns(rt_clock));
if (rtdelta < delta) {
delta = rtdelta;
}
}
return delta;
}
| false | qemu | 4ffd16fc2900219c8ec8bb288b6fa3dfcae295a7 | static int64_t qemu_next_alarm_deadline(void)
{
int64_t delta;
int64_t rtdelta;
if (!use_icount && vm_clock->active_timers) {
delta = vm_clock->active_timers->expire_time -
qemu_get_clock_ns(vm_clock);
} else {
delta = INT32_MAX;
}
if (host_clock->active_timers) {
int64_t hdelta = host_clock->active_timers->expire_time -
qemu_get_clock_ns(host_clock);
if (hdelta < delta) {
delta = hdelta;
}
}
if (rt_clock->active_timers) {
rtdelta = (rt_clock->active_timers->expire_time -
qemu_get_clock_ns(rt_clock));
if (rtdelta < delta) {
delta = rtdelta;
}
}
return delta;
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(void)
{
int64_t delta;
int64_t rtdelta;
if (!use_icount && vm_clock->active_timers) {
delta = vm_clock->active_timers->expire_time -
qemu_get_clock_ns(vm_clock);
} else {
delta = INT32_MAX;
}
if (host_clock->active_timers) {
int64_t hdelta = host_clock->active_timers->expire_time -
qemu_get_clock_ns(host_clock);
if (hdelta < delta) {
delta = hdelta;
}
}
if (rt_clock->active_timers) {
rtdelta = (rt_clock->active_timers->expire_time -
qemu_get_clock_ns(rt_clock));
if (rtdelta < delta) {
delta = rtdelta;
}
}
return delta;
}
| [
"static int64_t FUNC_0(void)\n{",
"int64_t delta;",
"int64_t rtdelta;",
"if (!use_icount && vm_clock->active_timers) {",
"delta = vm_clock->active_timers->expire_time -\nqemu_get_clock_ns(vm_clock);",
"} else {",
"delta = INT32_MAX;",
"}",
"if (host_clock->active_timers) {",
"int64_t hdelta = host_clock->active_timers->expire_time -\nqemu_get_clock_ns(host_clock);",
"if (hdelta < delta) {",
"delta = hdelta;",
"}",
"}",
"if (rt_clock->active_timers) {",
"rtdelta = (rt_clock->active_timers->expire_time -\nqemu_get_clock_ns(rt_clock));",
"if (rtdelta < delta) {",
"delta = rtdelta;",
"}",
"}",
"return delta;",
"}"
]
| [
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,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
]
|
10,335 | static int decode_motion_vector (bit_buffer_t *bitbuf, svq1_pmv_t *mv, svq1_pmv_t **pmv) {
uint32_t bit_cache;
vlc_code_t *vlc;
int diff, sign;
int i;
for (i=0; i < 2; i++) {
/* get motion code */
bit_cache = get_bit_cache (bitbuf);
if (!(bit_cache & 0xFFE00000))
return -1; /* invalid vlc code */
if (bit_cache & 0x80000000) {
diff = 0;
/* flush bit */
skip_bits(bitbuf,1);
} else {
if (bit_cache >= 0x06000000) {
vlc = &motion_table_0[(bit_cache >> (32 - 7)) - 3];
} else {
vlc = &motion_table_1[(bit_cache >> (32 - 12)) - 2];
}
/* decode motion vector differential */
sign = (int) (bit_cache << (vlc->length - 1)) >> 31;
diff = (vlc->value ^ sign) - sign;
/* flush bits */
skip_bits(bitbuf,vlc->length);
}
/* add median of motion vector predictors and clip result */
if (i == 1)
mv->y = ((diff + MEDIAN(pmv[0]->y, pmv[1]->y, pmv[2]->y)) << 26) >> 26;
else
mv->x = ((diff + MEDIAN(pmv[0]->x, pmv[1]->x, pmv[2]->x)) << 26) >> 26;
}
return 0;
}
| false | FFmpeg | 82dd7d0dec29ee59af91ce18c29eb151b363ff37 | static int decode_motion_vector (bit_buffer_t *bitbuf, svq1_pmv_t *mv, svq1_pmv_t **pmv) {
uint32_t bit_cache;
vlc_code_t *vlc;
int diff, sign;
int i;
for (i=0; i < 2; i++) {
bit_cache = get_bit_cache (bitbuf);
if (!(bit_cache & 0xFFE00000))
return -1;
if (bit_cache & 0x80000000) {
diff = 0;
skip_bits(bitbuf,1);
} else {
if (bit_cache >= 0x06000000) {
vlc = &motion_table_0[(bit_cache >> (32 - 7)) - 3];
} else {
vlc = &motion_table_1[(bit_cache >> (32 - 12)) - 2];
}
sign = (int) (bit_cache << (vlc->length - 1)) >> 31;
diff = (vlc->value ^ sign) - sign;
skip_bits(bitbuf,vlc->length);
}
if (i == 1)
mv->y = ((diff + MEDIAN(pmv[0]->y, pmv[1]->y, pmv[2]->y)) << 26) >> 26;
else
mv->x = ((diff + MEDIAN(pmv[0]->x, pmv[1]->x, pmv[2]->x)) << 26) >> 26;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (bit_buffer_t *VAR_0, svq1_pmv_t *VAR_1, svq1_pmv_t **VAR_2) {
uint32_t bit_cache;
vlc_code_t *vlc;
int VAR_3, VAR_4;
int VAR_5;
for (VAR_5=0; VAR_5 < 2; VAR_5++) {
bit_cache = get_bit_cache (VAR_0);
if (!(bit_cache & 0xFFE00000))
return -1;
if (bit_cache & 0x80000000) {
VAR_3 = 0;
skip_bits(VAR_0,1);
} else {
if (bit_cache >= 0x06000000) {
vlc = &motion_table_0[(bit_cache >> (32 - 7)) - 3];
} else {
vlc = &motion_table_1[(bit_cache >> (32 - 12)) - 2];
}
VAR_4 = (int) (bit_cache << (vlc->length - 1)) >> 31;
VAR_3 = (vlc->value ^ VAR_4) - VAR_4;
skip_bits(VAR_0,vlc->length);
}
if (VAR_5 == 1)
VAR_1->y = ((VAR_3 + MEDIAN(VAR_2[0]->y, VAR_2[1]->y, VAR_2[2]->y)) << 26) >> 26;
else
VAR_1->x = ((VAR_3 + MEDIAN(VAR_2[0]->x, VAR_2[1]->x, VAR_2[2]->x)) << 26) >> 26;
}
return 0;
}
| [
"static int FUNC_0 (bit_buffer_t *VAR_0, svq1_pmv_t *VAR_1, svq1_pmv_t **VAR_2) {",
"uint32_t bit_cache;",
"vlc_code_t *vlc;",
"int\t VAR_3, VAR_4;",
"int\t VAR_5;",
"for (VAR_5=0; VAR_5 < 2; VAR_5++) {",
"bit_cache = get_bit_cache (VAR_0);",
"if (!(bit_cache & 0xFFE00000))\nreturn -1;",
"if (bit_cache & 0x80000000) {",
"VAR_3 = 0;",
"skip_bits(VAR_0,1);",
"} else {",
"if (bit_cache >= 0x06000000) {",
"vlc = &motion_table_0[(bit_cache >> (32 - 7)) - 3];",
"} else {",
"vlc = &motion_table_1[(bit_cache >> (32 - 12)) - 2];",
"}",
"VAR_4 = (int) (bit_cache << (vlc->length - 1)) >> 31;",
"VAR_3 = (vlc->value ^ VAR_4) - VAR_4;",
"skip_bits(VAR_0,vlc->length);",
"}",
"if (VAR_5 == 1)\nVAR_1->y = ((VAR_3 + MEDIAN(VAR_2[0]->y, VAR_2[1]->y, VAR_2[2]->y)) << 26) >> 26;",
"else\nVAR_1->x = ((VAR_3 + MEDIAN(VAR_2[0]->x, VAR_2[1]->x, VAR_2[2]->x)) << 26) >> 26;",
"}",
"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
],
[
9
],
[
13
],
[
19
],
[
23,
25
],
[
29
],
[
31
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
65
],
[
67
],
[
73,
75
],
[
77,
79
],
[
81
],
[
85
],
[
87
]
]
|
10,336 | static void drive_backup_prepare(BlkActionState *common, Error **errp)
{
DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
BlockBackend *blk;
DriveBackup *backup;
Error *local_err = NULL;
assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
backup = common->action->u.drive_backup.data;
blk = blk_by_name(backup->device);
if (!blk) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", backup->device);
return;
}
if (!blk_is_available(blk)) {
error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, backup->device);
return;
}
/* AioContext is released in .clean() */
state->aio_context = blk_get_aio_context(blk);
aio_context_acquire(state->aio_context);
bdrv_drained_begin(blk_bs(blk));
state->bs = blk_bs(blk);
do_drive_backup(backup->has_job_id ? backup->job_id : NULL,
backup->device, backup->target,
backup->has_format, backup->format,
backup->sync,
backup->has_mode, backup->mode,
backup->has_speed, backup->speed,
backup->has_bitmap, backup->bitmap,
backup->has_on_source_error, backup->on_source_error,
backup->has_on_target_error, backup->on_target_error,
common->block_job_txn, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
state->job = state->bs->job;
}
| false | qemu | b7e4fa224200ec87b9599a1d72b16ada35a3d113 | static void drive_backup_prepare(BlkActionState *common, Error **errp)
{
DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
BlockBackend *blk;
DriveBackup *backup;
Error *local_err = NULL;
assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
backup = common->action->u.drive_backup.data;
blk = blk_by_name(backup->device);
if (!blk) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", backup->device);
return;
}
if (!blk_is_available(blk)) {
error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, backup->device);
return;
}
state->aio_context = blk_get_aio_context(blk);
aio_context_acquire(state->aio_context);
bdrv_drained_begin(blk_bs(blk));
state->bs = blk_bs(blk);
do_drive_backup(backup->has_job_id ? backup->job_id : NULL,
backup->device, backup->target,
backup->has_format, backup->format,
backup->sync,
backup->has_mode, backup->mode,
backup->has_speed, backup->speed,
backup->has_bitmap, backup->bitmap,
backup->has_on_source_error, backup->on_source_error,
backup->has_on_target_error, backup->on_target_error,
common->block_job_txn, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
state->job = state->bs->job;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlkActionState *VAR_0, Error **VAR_1)
{
DriveBackupState *state = DO_UPCAST(DriveBackupState, VAR_0, VAR_0);
BlockBackend *blk;
DriveBackup *backup;
Error *local_err = NULL;
assert(VAR_0->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
backup = VAR_0->action->u.drive_backup.data;
blk = blk_by_name(backup->device);
if (!blk) {
error_set(VAR_1, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", backup->device);
return;
}
if (!blk_is_available(blk)) {
error_setg(VAR_1, QERR_DEVICE_HAS_NO_MEDIUM, backup->device);
return;
}
state->aio_context = blk_get_aio_context(blk);
aio_context_acquire(state->aio_context);
bdrv_drained_begin(blk_bs(blk));
state->bs = blk_bs(blk);
do_drive_backup(backup->has_job_id ? backup->job_id : NULL,
backup->device, backup->target,
backup->has_format, backup->format,
backup->sync,
backup->has_mode, backup->mode,
backup->has_speed, backup->speed,
backup->has_bitmap, backup->bitmap,
backup->has_on_source_error, backup->on_source_error,
backup->has_on_target_error, backup->on_target_error,
VAR_0->block_job_txn, &local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
return;
}
state->job = state->bs->job;
}
| [
"static void FUNC_0(BlkActionState *VAR_0, Error **VAR_1)\n{",
"DriveBackupState *state = DO_UPCAST(DriveBackupState, VAR_0, VAR_0);",
"BlockBackend *blk;",
"DriveBackup *backup;",
"Error *local_err = NULL;",
"assert(VAR_0->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);",
"backup = VAR_0->action->u.drive_backup.data;",
"blk = blk_by_name(backup->device);",
"if (!blk) {",
"error_set(VAR_1, ERROR_CLASS_DEVICE_NOT_FOUND,\n\"Device '%s' not found\", backup->device);",
"return;",
"}",
"if (!blk_is_available(blk)) {",
"error_setg(VAR_1, QERR_DEVICE_HAS_NO_MEDIUM, backup->device);",
"return;",
"}",
"state->aio_context = blk_get_aio_context(blk);",
"aio_context_acquire(state->aio_context);",
"bdrv_drained_begin(blk_bs(blk));",
"state->bs = blk_bs(blk);",
"do_drive_backup(backup->has_job_id ? backup->job_id : NULL,\nbackup->device, backup->target,\nbackup->has_format, backup->format,\nbackup->sync,\nbackup->has_mode, backup->mode,\nbackup->has_speed, backup->speed,\nbackup->has_bitmap, backup->bitmap,\nbackup->has_on_source_error, backup->on_source_error,\nbackup->has_on_target_error, backup->on_target_error,\nVAR_0->block_job_txn, &local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"state->job = state->bs->job;",
"}"
]
| [
0,
0,
0,
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
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59,
61,
63,
65,
67,
69,
71,
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
]
]
|
10,337 | void ssi_register_slave(SSISlaveInfo *info)
{
assert(info->qdev.size >= sizeof(SSISlave));
info->qdev.init = ssi_slave_init;
info->qdev.bus_type = BUS_TYPE_SSI;
qdev_register(&info->qdev);
}
| false | qemu | 10c4c98ab7dc18169b37b76f6ea5e60ebe65222b | void ssi_register_slave(SSISlaveInfo *info)
{
assert(info->qdev.size >= sizeof(SSISlave));
info->qdev.init = ssi_slave_init;
info->qdev.bus_type = BUS_TYPE_SSI;
qdev_register(&info->qdev);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(SSISlaveInfo *VAR_0)
{
assert(VAR_0->qdev.size >= sizeof(SSISlave));
VAR_0->qdev.init = ssi_slave_init;
VAR_0->qdev.bus_type = BUS_TYPE_SSI;
qdev_register(&VAR_0->qdev);
}
| [
"void FUNC_0(SSISlaveInfo *VAR_0)\n{",
"assert(VAR_0->qdev.size >= sizeof(SSISlave));",
"VAR_0->qdev.init = ssi_slave_init;",
"VAR_0->qdev.bus_type = BUS_TYPE_SSI;",
"qdev_register(&VAR_0->qdev);",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
]
|
10,339 | uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitmap)
{
return hbitmap_serialization_align(bitmap->bitmap);
}
| false | qemu | 86f6ae67e157362f3b141649874213ce01dcc622 | uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitmap)
{
return hbitmap_serialization_align(bitmap->bitmap);
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0(const BdrvDirtyBitmap *bitmap)
{
return hbitmap_serialization_align(bitmap->bitmap);
}
| [
"uint64_t FUNC_0(const BdrvDirtyBitmap *bitmap)\n{",
"return hbitmap_serialization_align(bitmap->bitmap);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
10,340 | static void parse_drive(DeviceState *dev, const char *str, void **ptr,
const char *propname, Error **errp)
{
BlockBackend *blk;
blk = blk_by_name(str);
if (!blk) {
error_setg(errp, "Property '%s.%s' can't find value '%s'",
object_get_typename(OBJECT(dev)), propname, str);
return;
}
if (blk_attach_dev(blk, dev) < 0) {
DriveInfo *dinfo = blk_legacy_dinfo(blk);
if (dinfo->type != IF_NONE) {
error_setg(errp, "Drive '%s' is already in use because "
"it has been automatically connected to another "
"device (did you need 'if=none' in the drive options?)",
str);
} else {
error_setg(errp, "Drive '%s' is already in use by another device",
str);
}
return;
}
*ptr = blk;
}
| false | qemu | a9d52a75634ac9aa7d101bf7f63e10bf6655a865 | static void parse_drive(DeviceState *dev, const char *str, void **ptr,
const char *propname, Error **errp)
{
BlockBackend *blk;
blk = blk_by_name(str);
if (!blk) {
error_setg(errp, "Property '%s.%s' can't find value '%s'",
object_get_typename(OBJECT(dev)), propname, str);
return;
}
if (blk_attach_dev(blk, dev) < 0) {
DriveInfo *dinfo = blk_legacy_dinfo(blk);
if (dinfo->type != IF_NONE) {
error_setg(errp, "Drive '%s' is already in use because "
"it has been automatically connected to another "
"device (did you need 'if=none' in the drive options?)",
str);
} else {
error_setg(errp, "Drive '%s' is already in use by another device",
str);
}
return;
}
*ptr = blk;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, const char *VAR_1, void **VAR_2,
const char *VAR_3, Error **VAR_4)
{
BlockBackend *blk;
blk = blk_by_name(VAR_1);
if (!blk) {
error_setg(VAR_4, "Property '%s.%s' can't find value '%s'",
object_get_typename(OBJECT(VAR_0)), VAR_3, VAR_1);
return;
}
if (blk_attach_dev(blk, VAR_0) < 0) {
DriveInfo *dinfo = blk_legacy_dinfo(blk);
if (dinfo->type != IF_NONE) {
error_setg(VAR_4, "Drive '%s' is already in use because "
"it has been automatically connected to another "
"device (did you need 'if=none' in the drive options?)",
VAR_1);
} else {
error_setg(VAR_4, "Drive '%s' is already in use by another device",
VAR_1);
}
return;
}
*VAR_2 = blk;
}
| [
"static void FUNC_0(DeviceState *VAR_0, const char *VAR_1, void **VAR_2,\nconst char *VAR_3, Error **VAR_4)\n{",
"BlockBackend *blk;",
"blk = blk_by_name(VAR_1);",
"if (!blk) {",
"error_setg(VAR_4, \"Property '%s.%s' can't find value '%s'\",\nobject_get_typename(OBJECT(VAR_0)), VAR_3, VAR_1);",
"return;",
"}",
"if (blk_attach_dev(blk, VAR_0) < 0) {",
"DriveInfo *dinfo = blk_legacy_dinfo(blk);",
"if (dinfo->type != IF_NONE) {",
"error_setg(VAR_4, \"Drive '%s' is already in use because \"\n\"it has been automatically connected to another \"\n\"device (did you need 'if=none' in the drive options?)\",\nVAR_1);",
"} else {",
"error_setg(VAR_4, \"Drive '%s' is already in use by another device\",\nVAR_1);",
"}",
"return;",
"}",
"*VAR_2 = blk;",
"}"
]
| [
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
],
[
29
],
[
31,
33,
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
]
|
10,341 | static int get_segment (CPUState *env, mmu_ctx_t *ctx,
target_ulong eaddr, int rw, int type)
{
target_phys_addr_t sdr, hash, mask, sdr_mask, htab_mask;
target_ulong sr, vsid, vsid_mask, pgidx, page_mask;
#if defined(TARGET_PPC64)
int attr;
#endif
int ds, nx, vsid_sh, sdr_sh;
int ret, ret2;
#if defined(TARGET_PPC64)
if (env->mmu_model == POWERPC_MMU_64B) {
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "Check SLBs\n");
}
#endif
ret = slb_lookup(env, eaddr, &vsid, &page_mask, &attr);
if (ret < 0)
return ret;
ctx->key = ((attr & 0x40) && msr_pr == 1) ||
((attr & 0x80) && msr_pr == 0) ? 1 : 0;
ds = 0;
nx = attr & 0x20 ? 1 : 0;
vsid_mask = 0x00003FFFFFFFFF80ULL;
vsid_sh = 7;
sdr_sh = 18;
sdr_mask = 0x3FF80;
} else
#endif /* defined(TARGET_PPC64) */
{
sr = env->sr[eaddr >> 28];
page_mask = 0x0FFFFFFF;
ctx->key = (((sr & 0x20000000) && msr_pr == 1) ||
((sr & 0x40000000) && msr_pr == 0)) ? 1 : 0;
ds = sr & 0x80000000 ? 1 : 0;
nx = sr & 0x10000000 ? 1 : 0;
vsid = sr & 0x00FFFFFF;
vsid_mask = 0x01FFFFC0;
vsid_sh = 6;
sdr_sh = 16;
sdr_mask = 0xFFC0;
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "Check segment v=0x" ADDRX " %d 0x" ADDRX
" nip=0x" ADDRX " lr=0x" ADDRX
" ir=%d dr=%d pr=%d %d t=%d\n",
eaddr, (int)(eaddr >> 28), sr, env->nip,
env->lr, msr_ir, msr_dr, msr_pr, rw, type);
}
#endif
}
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "pte segment: key=%d ds %d nx %d vsid " ADDRX "\n",
ctx->key, ds, nx, vsid);
}
#endif
ret = -1;
if (!ds) {
/* Check if instruction fetch is allowed, if needed */
if (type != ACCESS_CODE || nx == 0) {
/* Page address translation */
/* Primary table address */
sdr = env->sdr1;
pgidx = (eaddr & page_mask) >> TARGET_PAGE_BITS;
#if defined(TARGET_PPC64)
if (env->mmu_model == POWERPC_MMU_64B) {
htab_mask = 0x0FFFFFFF >> (28 - (sdr & 0x1F));
/* XXX: this is false for 1 TB segments */
hash = ((vsid ^ pgidx) << vsid_sh) & vsid_mask;
} else
#endif
{
htab_mask = sdr & 0x000001FF;
hash = ((vsid ^ pgidx) << vsid_sh) & vsid_mask;
}
mask = (htab_mask << sdr_sh) | sdr_mask;
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "sdr " PADDRX " sh %d hash " PADDRX " mask "
PADDRX " " ADDRX "\n", sdr, sdr_sh, hash, mask,
page_mask);
}
#endif
ctx->pg_addr[0] = get_pgaddr(sdr, sdr_sh, hash, mask);
/* Secondary table address */
hash = (~hash) & vsid_mask;
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "sdr " PADDRX " sh %d hash " PADDRX " mask "
PADDRX "\n", sdr, sdr_sh, hash, mask);
}
#endif
ctx->pg_addr[1] = get_pgaddr(sdr, sdr_sh, hash, mask);
#if defined(TARGET_PPC64)
if (env->mmu_model == POWERPC_MMU_64B) {
/* Only 5 bits of the page index are used in the AVPN */
ctx->ptem = (vsid << 12) | ((pgidx >> 4) & 0x0F80);
} else
#endif
{
ctx->ptem = (vsid << 7) | (pgidx >> 10);
}
/* Initialize real address with an invalid value */
ctx->raddr = (target_ulong)-1;
if (unlikely(env->mmu_model == POWERPC_MMU_SOFT_6xx ||
env->mmu_model == POWERPC_MMU_SOFT_74xx)) {
/* Software TLB search */
ret = ppc6xx_tlb_check(env, ctx, eaddr, rw, type);
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "0 sdr1=0x" PADDRX " vsid=0x%06x "
"api=0x%04x hash=0x%07x pg_addr=0x" PADDRX "\n",
sdr, (uint32_t)vsid, (uint32_t)pgidx,
(uint32_t)hash, ctx->pg_addr[0]);
}
#endif
/* Primary table lookup */
ret = find_pte(env, ctx, 0, rw);
if (ret < 0) {
/* Secondary table lookup */
#if defined (DEBUG_MMU)
if (eaddr != 0xEFFFFFFF && loglevel != 0) {
fprintf(logfile,
"1 sdr1=0x" PADDRX " vsid=0x%06x api=0x%04x "
"hash=0x%05x pg_addr=0x" PADDRX "\n",
sdr, (uint32_t)vsid, (uint32_t)pgidx,
(uint32_t)hash, ctx->pg_addr[1]);
}
#endif
ret2 = find_pte(env, ctx, 1, rw);
if (ret2 != -1)
ret = ret2;
}
}
#if defined (DEBUG_MMU)
if (loglevel != 0) {
target_phys_addr_t curaddr;
uint32_t a0, a1, a2, a3;
fprintf(logfile,
"Page table: " PADDRX " len " PADDRX "\n",
sdr, mask + 0x80);
for (curaddr = sdr; curaddr < (sdr + mask + 0x80);
curaddr += 16) {
a0 = ldl_phys(curaddr);
a1 = ldl_phys(curaddr + 4);
a2 = ldl_phys(curaddr + 8);
a3 = ldl_phys(curaddr + 12);
if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) {
fprintf(logfile,
PADDRX ": %08x %08x %08x %08x\n",
curaddr, a0, a1, a2, a3);
}
}
}
#endif
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "No access allowed\n");
#endif
ret = -3;
}
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "direct store...\n");
#endif
/* Direct-store segment : absolutely *BUGGY* for now */
switch (type) {
case ACCESS_INT:
/* Integer load/store : only access allowed */
break;
case ACCESS_CODE:
/* No code fetch is allowed in direct-store areas */
return -4;
case ACCESS_FLOAT:
/* Floating point load/store */
return -4;
case ACCESS_RES:
/* lwarx, ldarx or srwcx. */
return -4;
case ACCESS_CACHE:
/* dcba, dcbt, dcbtst, dcbf, dcbi, dcbst, dcbz, or icbi */
/* Should make the instruction do no-op.
* As it already do no-op, it's quite easy :-)
*/
ctx->raddr = eaddr;
return 0;
case ACCESS_EXT:
/* eciwx or ecowx */
return -4;
default:
if (logfile) {
fprintf(logfile, "ERROR: instruction should not need "
"address translation\n");
}
return -4;
}
if ((rw == 1 || ctx->key != 1) && (rw == 0 || ctx->key != 0)) {
ctx->raddr = eaddr;
ret = 2;
} else {
ret = -2;
}
}
return ret;
}
| false | qemu | b227a8e9aa5f27d29f77ba90d5eb9d0662a1175e | static int get_segment (CPUState *env, mmu_ctx_t *ctx,
target_ulong eaddr, int rw, int type)
{
target_phys_addr_t sdr, hash, mask, sdr_mask, htab_mask;
target_ulong sr, vsid, vsid_mask, pgidx, page_mask;
#if defined(TARGET_PPC64)
int attr;
#endif
int ds, nx, vsid_sh, sdr_sh;
int ret, ret2;
#if defined(TARGET_PPC64)
if (env->mmu_model == POWERPC_MMU_64B) {
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "Check SLBs\n");
}
#endif
ret = slb_lookup(env, eaddr, &vsid, &page_mask, &attr);
if (ret < 0)
return ret;
ctx->key = ((attr & 0x40) && msr_pr == 1) ||
((attr & 0x80) && msr_pr == 0) ? 1 : 0;
ds = 0;
nx = attr & 0x20 ? 1 : 0;
vsid_mask = 0x00003FFFFFFFFF80ULL;
vsid_sh = 7;
sdr_sh = 18;
sdr_mask = 0x3FF80;
} else
#endif
{
sr = env->sr[eaddr >> 28];
page_mask = 0x0FFFFFFF;
ctx->key = (((sr & 0x20000000) && msr_pr == 1) ||
((sr & 0x40000000) && msr_pr == 0)) ? 1 : 0;
ds = sr & 0x80000000 ? 1 : 0;
nx = sr & 0x10000000 ? 1 : 0;
vsid = sr & 0x00FFFFFF;
vsid_mask = 0x01FFFFC0;
vsid_sh = 6;
sdr_sh = 16;
sdr_mask = 0xFFC0;
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "Check segment v=0x" ADDRX " %d 0x" ADDRX
" nip=0x" ADDRX " lr=0x" ADDRX
" ir=%d dr=%d pr=%d %d t=%d\n",
eaddr, (int)(eaddr >> 28), sr, env->nip,
env->lr, msr_ir, msr_dr, msr_pr, rw, type);
}
#endif
}
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "pte segment: key=%d ds %d nx %d vsid " ADDRX "\n",
ctx->key, ds, nx, vsid);
}
#endif
ret = -1;
if (!ds) {
if (type != ACCESS_CODE || nx == 0) {
sdr = env->sdr1;
pgidx = (eaddr & page_mask) >> TARGET_PAGE_BITS;
#if defined(TARGET_PPC64)
if (env->mmu_model == POWERPC_MMU_64B) {
htab_mask = 0x0FFFFFFF >> (28 - (sdr & 0x1F));
hash = ((vsid ^ pgidx) << vsid_sh) & vsid_mask;
} else
#endif
{
htab_mask = sdr & 0x000001FF;
hash = ((vsid ^ pgidx) << vsid_sh) & vsid_mask;
}
mask = (htab_mask << sdr_sh) | sdr_mask;
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "sdr " PADDRX " sh %d hash " PADDRX " mask "
PADDRX " " ADDRX "\n", sdr, sdr_sh, hash, mask,
page_mask);
}
#endif
ctx->pg_addr[0] = get_pgaddr(sdr, sdr_sh, hash, mask);
hash = (~hash) & vsid_mask;
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "sdr " PADDRX " sh %d hash " PADDRX " mask "
PADDRX "\n", sdr, sdr_sh, hash, mask);
}
#endif
ctx->pg_addr[1] = get_pgaddr(sdr, sdr_sh, hash, mask);
#if defined(TARGET_PPC64)
if (env->mmu_model == POWERPC_MMU_64B) {
ctx->ptem = (vsid << 12) | ((pgidx >> 4) & 0x0F80);
} else
#endif
{
ctx->ptem = (vsid << 7) | (pgidx >> 10);
}
ctx->raddr = (target_ulong)-1;
if (unlikely(env->mmu_model == POWERPC_MMU_SOFT_6xx ||
env->mmu_model == POWERPC_MMU_SOFT_74xx)) {
ret = ppc6xx_tlb_check(env, ctx, eaddr, rw, type);
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "0 sdr1=0x" PADDRX " vsid=0x%06x "
"api=0x%04x hash=0x%07x pg_addr=0x" PADDRX "\n",
sdr, (uint32_t)vsid, (uint32_t)pgidx,
(uint32_t)hash, ctx->pg_addr[0]);
}
#endif
ret = find_pte(env, ctx, 0, rw);
if (ret < 0) {
#if defined (DEBUG_MMU)
if (eaddr != 0xEFFFFFFF && loglevel != 0) {
fprintf(logfile,
"1 sdr1=0x" PADDRX " vsid=0x%06x api=0x%04x "
"hash=0x%05x pg_addr=0x" PADDRX "\n",
sdr, (uint32_t)vsid, (uint32_t)pgidx,
(uint32_t)hash, ctx->pg_addr[1]);
}
#endif
ret2 = find_pte(env, ctx, 1, rw);
if (ret2 != -1)
ret = ret2;
}
}
#if defined (DEBUG_MMU)
if (loglevel != 0) {
target_phys_addr_t curaddr;
uint32_t a0, a1, a2, a3;
fprintf(logfile,
"Page table: " PADDRX " len " PADDRX "\n",
sdr, mask + 0x80);
for (curaddr = sdr; curaddr < (sdr + mask + 0x80);
curaddr += 16) {
a0 = ldl_phys(curaddr);
a1 = ldl_phys(curaddr + 4);
a2 = ldl_phys(curaddr + 8);
a3 = ldl_phys(curaddr + 12);
if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) {
fprintf(logfile,
PADDRX ": %08x %08x %08x %08x\n",
curaddr, a0, a1, a2, a3);
}
}
}
#endif
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "No access allowed\n");
#endif
ret = -3;
}
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "direct store...\n");
#endif
switch (type) {
case ACCESS_INT:
break;
case ACCESS_CODE:
return -4;
case ACCESS_FLOAT:
return -4;
case ACCESS_RES:
return -4;
case ACCESS_CACHE:
ctx->raddr = eaddr;
return 0;
case ACCESS_EXT:
return -4;
default:
if (logfile) {
fprintf(logfile, "ERROR: instruction should not need "
"address translation\n");
}
return -4;
}
if ((rw == 1 || ctx->key != 1) && (rw == 0 || ctx->key != 0)) {
ctx->raddr = eaddr;
ret = 2;
} else {
ret = -2;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (CPUState *VAR_0, mmu_ctx_t *VAR_1,
target_ulong VAR_2, int VAR_3, int VAR_4)
{
target_phys_addr_t sdr, hash, mask, sdr_mask, htab_mask;
target_ulong sr, vsid, vsid_mask, pgidx, page_mask;
#if defined(TARGET_PPC64)
int attr;
#endif
int VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9, VAR_10;
#if defined(TARGET_PPC64)
if (VAR_0->mmu_model == POWERPC_MMU_64B) {
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "Check SLBs\n");
}
#endif
VAR_9 = slb_lookup(VAR_0, VAR_2, &vsid, &page_mask, &attr);
if (VAR_9 < 0)
return VAR_9;
VAR_1->key = ((attr & 0x40) && msr_pr == 1) ||
((attr & 0x80) && msr_pr == 0) ? 1 : 0;
VAR_5 = 0;
VAR_6 = attr & 0x20 ? 1 : 0;
vsid_mask = 0x00003FFFFFFFFF80ULL;
VAR_7 = 7;
VAR_8 = 18;
sdr_mask = 0x3FF80;
} else
#endif
{
sr = VAR_0->sr[VAR_2 >> 28];
page_mask = 0x0FFFFFFF;
VAR_1->key = (((sr & 0x20000000) && msr_pr == 1) ||
((sr & 0x40000000) && msr_pr == 0)) ? 1 : 0;
VAR_5 = sr & 0x80000000 ? 1 : 0;
VAR_6 = sr & 0x10000000 ? 1 : 0;
vsid = sr & 0x00FFFFFF;
vsid_mask = 0x01FFFFC0;
VAR_7 = 6;
VAR_8 = 16;
sdr_mask = 0xFFC0;
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "Check segment v=0x" ADDRX " %d 0x" ADDRX
" nip=0x" ADDRX " lr=0x" ADDRX
" ir=%d dr=%d pr=%d %d t=%d\n",
VAR_2, (int)(VAR_2 >> 28), sr, VAR_0->nip,
VAR_0->lr, msr_ir, msr_dr, msr_pr, VAR_3, VAR_4);
}
#endif
}
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "pte segment: key=%d VAR_5 %d VAR_6 %d vsid " ADDRX "\n",
VAR_1->key, VAR_5, VAR_6, vsid);
}
#endif
VAR_9 = -1;
if (!VAR_5) {
if (VAR_4 != ACCESS_CODE || VAR_6 == 0) {
sdr = VAR_0->sdr1;
pgidx = (VAR_2 & page_mask) >> TARGET_PAGE_BITS;
#if defined(TARGET_PPC64)
if (VAR_0->mmu_model == POWERPC_MMU_64B) {
htab_mask = 0x0FFFFFFF >> (28 - (sdr & 0x1F));
hash = ((vsid ^ pgidx) << VAR_7) & vsid_mask;
} else
#endif
{
htab_mask = sdr & 0x000001FF;
hash = ((vsid ^ pgidx) << VAR_7) & vsid_mask;
}
mask = (htab_mask << VAR_8) | sdr_mask;
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "sdr " PADDRX " sh %d hash " PADDRX " mask "
PADDRX " " ADDRX "\n", sdr, VAR_8, hash, mask,
page_mask);
}
#endif
VAR_1->pg_addr[0] = get_pgaddr(sdr, VAR_8, hash, mask);
hash = (~hash) & vsid_mask;
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "sdr " PADDRX " sh %d hash " PADDRX " mask "
PADDRX "\n", sdr, VAR_8, hash, mask);
}
#endif
VAR_1->pg_addr[1] = get_pgaddr(sdr, VAR_8, hash, mask);
#if defined(TARGET_PPC64)
if (VAR_0->mmu_model == POWERPC_MMU_64B) {
VAR_1->ptem = (vsid << 12) | ((pgidx >> 4) & 0x0F80);
} else
#endif
{
VAR_1->ptem = (vsid << 7) | (pgidx >> 10);
}
VAR_1->raddr = (target_ulong)-1;
if (unlikely(VAR_0->mmu_model == POWERPC_MMU_SOFT_6xx ||
VAR_0->mmu_model == POWERPC_MMU_SOFT_74xx)) {
VAR_9 = ppc6xx_tlb_check(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0) {
fprintf(logfile, "0 sdr1=0x" PADDRX " vsid=0x%06x "
"api=0x%04x hash=0x%07x pg_addr=0x" PADDRX "\n",
sdr, (uint32_t)vsid, (uint32_t)pgidx,
(uint32_t)hash, VAR_1->pg_addr[0]);
}
#endif
VAR_9 = find_pte(VAR_0, VAR_1, 0, VAR_3);
if (VAR_9 < 0) {
#if defined (DEBUG_MMU)
if (VAR_2 != 0xEFFFFFFF && loglevel != 0) {
fprintf(logfile,
"1 sdr1=0x" PADDRX " vsid=0x%06x api=0x%04x "
"hash=0x%05x pg_addr=0x" PADDRX "\n",
sdr, (uint32_t)vsid, (uint32_t)pgidx,
(uint32_t)hash, VAR_1->pg_addr[1]);
}
#endif
VAR_10 = find_pte(VAR_0, VAR_1, 1, VAR_3);
if (VAR_10 != -1)
VAR_9 = VAR_10;
}
}
#if defined (DEBUG_MMU)
if (loglevel != 0) {
target_phys_addr_t curaddr;
uint32_t a0, a1, a2, a3;
fprintf(logfile,
"Page table: " PADDRX " len " PADDRX "\n",
sdr, mask + 0x80);
for (curaddr = sdr; curaddr < (sdr + mask + 0x80);
curaddr += 16) {
a0 = ldl_phys(curaddr);
a1 = ldl_phys(curaddr + 4);
a2 = ldl_phys(curaddr + 8);
a3 = ldl_phys(curaddr + 12);
if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) {
fprintf(logfile,
PADDRX ": %08x %08x %08x %08x\n",
curaddr, a0, a1, a2, a3);
}
}
}
#endif
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "No access allowed\n");
#endif
VAR_9 = -3;
}
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "direct store...\n");
#endif
switch (VAR_4) {
case ACCESS_INT:
break;
case ACCESS_CODE:
return -4;
case ACCESS_FLOAT:
return -4;
case ACCESS_RES:
return -4;
case ACCESS_CACHE:
VAR_1->raddr = VAR_2;
return 0;
case ACCESS_EXT:
return -4;
default:
if (logfile) {
fprintf(logfile, "ERROR: instruction should not need "
"address translation\n");
}
return -4;
}
if ((VAR_3 == 1 || VAR_1->key != 1) && (VAR_3 == 0 || VAR_1->key != 0)) {
VAR_1->raddr = VAR_2;
VAR_9 = 2;
} else {
VAR_9 = -2;
}
}
return VAR_9;
}
| [
"static int FUNC_0 (CPUState *VAR_0, mmu_ctx_t *VAR_1,\ntarget_ulong VAR_2, int VAR_3, int VAR_4)\n{",
"target_phys_addr_t sdr, hash, mask, sdr_mask, htab_mask;",
"target_ulong sr, vsid, vsid_mask, pgidx, page_mask;",
"#if defined(TARGET_PPC64)\nint attr;",
"#endif\nint VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9, VAR_10;",
"#if defined(TARGET_PPC64)\nif (VAR_0->mmu_model == POWERPC_MMU_64B) {",
"#if defined (DEBUG_MMU)\nif (loglevel != 0) {",
"fprintf(logfile, \"Check SLBs\\n\");",
"}",
"#endif\nVAR_9 = slb_lookup(VAR_0, VAR_2, &vsid, &page_mask, &attr);",
"if (VAR_9 < 0)\nreturn VAR_9;",
"VAR_1->key = ((attr & 0x40) && msr_pr == 1) ||\n((attr & 0x80) && msr_pr == 0) ? 1 : 0;",
"VAR_5 = 0;",
"VAR_6 = attr & 0x20 ? 1 : 0;",
"vsid_mask = 0x00003FFFFFFFFF80ULL;",
"VAR_7 = 7;",
"VAR_8 = 18;",
"sdr_mask = 0x3FF80;",
"} else",
"#endif\n{",
"sr = VAR_0->sr[VAR_2 >> 28];",
"page_mask = 0x0FFFFFFF;",
"VAR_1->key = (((sr & 0x20000000) && msr_pr == 1) ||\n((sr & 0x40000000) && msr_pr == 0)) ? 1 : 0;",
"VAR_5 = sr & 0x80000000 ? 1 : 0;",
"VAR_6 = sr & 0x10000000 ? 1 : 0;",
"vsid = sr & 0x00FFFFFF;",
"vsid_mask = 0x01FFFFC0;",
"VAR_7 = 6;",
"VAR_8 = 16;",
"sdr_mask = 0xFFC0;",
"#if defined (DEBUG_MMU)\nif (loglevel != 0) {",
"fprintf(logfile, \"Check segment v=0x\" ADDRX \" %d 0x\" ADDRX\n\" nip=0x\" ADDRX \" lr=0x\" ADDRX\n\" ir=%d dr=%d pr=%d %d t=%d\\n\",\nVAR_2, (int)(VAR_2 >> 28), sr, VAR_0->nip,\nVAR_0->lr, msr_ir, msr_dr, msr_pr, VAR_3, VAR_4);",
"}",
"#endif\n}",
"#if defined (DEBUG_MMU)\nif (loglevel != 0) {",
"fprintf(logfile, \"pte segment: key=%d VAR_5 %d VAR_6 %d vsid \" ADDRX \"\\n\",\nVAR_1->key, VAR_5, VAR_6, vsid);",
"}",
"#endif\nVAR_9 = -1;",
"if (!VAR_5) {",
"if (VAR_4 != ACCESS_CODE || VAR_6 == 0) {",
"sdr = VAR_0->sdr1;",
"pgidx = (VAR_2 & page_mask) >> TARGET_PAGE_BITS;",
"#if defined(TARGET_PPC64)\nif (VAR_0->mmu_model == POWERPC_MMU_64B) {",
"htab_mask = 0x0FFFFFFF >> (28 - (sdr & 0x1F));",
"hash = ((vsid ^ pgidx) << VAR_7) & vsid_mask;",
"} else",
"#endif\n{",
"htab_mask = sdr & 0x000001FF;",
"hash = ((vsid ^ pgidx) << VAR_7) & vsid_mask;",
"}",
"mask = (htab_mask << VAR_8) | sdr_mask;",
"#if defined (DEBUG_MMU)\nif (loglevel != 0) {",
"fprintf(logfile, \"sdr \" PADDRX \" sh %d hash \" PADDRX \" mask \"\nPADDRX \" \" ADDRX \"\\n\", sdr, VAR_8, hash, mask,\npage_mask);",
"}",
"#endif\nVAR_1->pg_addr[0] = get_pgaddr(sdr, VAR_8, hash, mask);",
"hash = (~hash) & vsid_mask;",
"#if defined (DEBUG_MMU)\nif (loglevel != 0) {",
"fprintf(logfile, \"sdr \" PADDRX \" sh %d hash \" PADDRX \" mask \"\nPADDRX \"\\n\", sdr, VAR_8, hash, mask);",
"}",
"#endif\nVAR_1->pg_addr[1] = get_pgaddr(sdr, VAR_8, hash, mask);",
"#if defined(TARGET_PPC64)\nif (VAR_0->mmu_model == POWERPC_MMU_64B) {",
"VAR_1->ptem = (vsid << 12) | ((pgidx >> 4) & 0x0F80);",
"} else",
"#endif\n{",
"VAR_1->ptem = (vsid << 7) | (pgidx >> 10);",
"}",
"VAR_1->raddr = (target_ulong)-1;",
"if (unlikely(VAR_0->mmu_model == POWERPC_MMU_SOFT_6xx ||\nVAR_0->mmu_model == POWERPC_MMU_SOFT_74xx)) {",
"VAR_9 = ppc6xx_tlb_check(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);",
"} else {",
"#if defined (DEBUG_MMU)\nif (loglevel != 0) {",
"fprintf(logfile, \"0 sdr1=0x\" PADDRX \" vsid=0x%06x \"\n\"api=0x%04x hash=0x%07x pg_addr=0x\" PADDRX \"\\n\",\nsdr, (uint32_t)vsid, (uint32_t)pgidx,\n(uint32_t)hash, VAR_1->pg_addr[0]);",
"}",
"#endif\nVAR_9 = find_pte(VAR_0, VAR_1, 0, VAR_3);",
"if (VAR_9 < 0) {",
"#if defined (DEBUG_MMU)\nif (VAR_2 != 0xEFFFFFFF && loglevel != 0) {",
"fprintf(logfile,\n\"1 sdr1=0x\" PADDRX \" vsid=0x%06x api=0x%04x \"\n\"hash=0x%05x pg_addr=0x\" PADDRX \"\\n\",\nsdr, (uint32_t)vsid, (uint32_t)pgidx,\n(uint32_t)hash, VAR_1->pg_addr[1]);",
"}",
"#endif\nVAR_10 = find_pte(VAR_0, VAR_1, 1, VAR_3);",
"if (VAR_10 != -1)\nVAR_9 = VAR_10;",
"}",
"}",
"#if defined (DEBUG_MMU)\nif (loglevel != 0) {",
"target_phys_addr_t curaddr;",
"uint32_t a0, a1, a2, a3;",
"fprintf(logfile,\n\"Page table: \" PADDRX \" len \" PADDRX \"\\n\",\nsdr, mask + 0x80);",
"for (curaddr = sdr; curaddr < (sdr + mask + 0x80);",
"curaddr += 16) {",
"a0 = ldl_phys(curaddr);",
"a1 = ldl_phys(curaddr + 4);",
"a2 = ldl_phys(curaddr + 8);",
"a3 = ldl_phys(curaddr + 12);",
"if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) {",
"fprintf(logfile,\nPADDRX \": %08x %08x %08x %08x\\n\",\ncuraddr, a0, a1, a2, a3);",
"}",
"}",
"}",
"#endif\n} else {",
"#if defined (DEBUG_MMU)\nif (loglevel != 0)\nfprintf(logfile, \"No access allowed\\n\");",
"#endif\nVAR_9 = -3;",
"}",
"} else {",
"#if defined (DEBUG_MMU)\nif (loglevel != 0)\nfprintf(logfile, \"direct store...\\n\");",
"#endif\nswitch (VAR_4) {",
"case ACCESS_INT:\nbreak;",
"case ACCESS_CODE:\nreturn -4;",
"case ACCESS_FLOAT:\nreturn -4;",
"case ACCESS_RES:\nreturn -4;",
"case ACCESS_CACHE:\nVAR_1->raddr = VAR_2;",
"return 0;",
"case ACCESS_EXT:\nreturn -4;",
"default:\nif (logfile) {",
"fprintf(logfile, \"ERROR: instruction should not need \"\n\"address translation\\n\");",
"}",
"return -4;",
"}",
"if ((VAR_3 == 1 || VAR_1->key != 1) && (VAR_3 == 0 || VAR_1->key != 0)) {",
"VAR_1->raddr = VAR_2;",
"VAR_9 = 2;",
"} else {",
"VAR_9 = -2;",
"}",
"}",
"return VAR_9;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
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
],
[
125
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
143
],
[
145
],
[
147,
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159,
161
],
[
163,
165,
167
],
[
169
],
[
171,
173
],
[
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189,
191
],
[
193,
195
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
213
],
[
215,
217
],
[
221
],
[
223
],
[
225,
227
],
[
229,
231,
233,
235
],
[
237
],
[
239,
243
],
[
245
],
[
249,
251
],
[
253,
255,
257,
259,
261
],
[
263
],
[
265,
267
],
[
269,
271
],
[
273
],
[
275
],
[
277,
279
],
[
281
],
[
283
],
[
285,
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,
345
],
[
347,
351
],
[
353,
357
],
[
359,
363
],
[
365,
369
],
[
371,
381
],
[
383
],
[
385,
389
],
[
391,
393
],
[
395,
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
421
],
[
423
]
]
|
10,342 | static void arm_gic_realize(DeviceState *dev, Error **errp)
{
/* Device instance realize function for the GIC sysbus device */
GICv3State *s = ARM_GICV3(dev);
ARMGICv3Class *agc = ARM_GICV3_GET_CLASS(s);
Error *local_err = NULL;
agc->parent_realize(dev, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
gicv3_init_irqs_and_mmio(s, gicv3_set_irq, NULL);
}
| false | qemu | 287c181ae4132d7cc75ea422051f2c90e90b6493 | static void arm_gic_realize(DeviceState *dev, Error **errp)
{
GICv3State *s = ARM_GICV3(dev);
ARMGICv3Class *agc = ARM_GICV3_GET_CLASS(s);
Error *local_err = NULL;
agc->parent_realize(dev, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
gicv3_init_irqs_and_mmio(s, gicv3_set_irq, NULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
GICv3State *s = ARM_GICV3(VAR_0);
ARMGICv3Class *agc = ARM_GICV3_GET_CLASS(s);
Error *local_err = NULL;
agc->parent_realize(VAR_0, &local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
return;
}
gicv3_init_irqs_and_mmio(s, gicv3_set_irq, NULL);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"GICv3State *s = ARM_GICV3(VAR_0);",
"ARMGICv3Class *agc = ARM_GICV3_GET_CLASS(s);",
"Error *local_err = NULL;",
"agc->parent_realize(VAR_0, &local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"gicv3_init_irqs_and_mmio(s, gicv3_set_irq, NULL);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
]
]
|
10,343 | static void build_append_notify_target(GArray *method, GArray *target_name,
uint32_t value, int size)
{
GArray *notify = build_alloc_array();
uint8_t op = 0xA0; /* IfOp */
build_append_byte(notify, 0x93); /* LEqualOp */
build_append_byte(notify, 0x68); /* Arg0Op */
build_append_value(notify, value, size);
build_append_byte(notify, 0x86); /* NotifyOp */
build_append_array(notify, target_name);
build_append_byte(notify, 0x69); /* Arg1Op */
/* Pack it up */
build_package(notify, op, 1);
build_append_array(method, notify);
build_free_array(notify);
}
| false | qemu | 99fd437dee468609de8218f0eb3b16621fb6a9c9 | static void build_append_notify_target(GArray *method, GArray *target_name,
uint32_t value, int size)
{
GArray *notify = build_alloc_array();
uint8_t op = 0xA0;
build_append_byte(notify, 0x93);
build_append_byte(notify, 0x68);
build_append_value(notify, value, size);
build_append_byte(notify, 0x86);
build_append_array(notify, target_name);
build_append_byte(notify, 0x69);
build_package(notify, op, 1);
build_append_array(method, notify);
build_free_array(notify);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(GArray *VAR_0, GArray *VAR_1,
uint32_t VAR_2, int VAR_3)
{
GArray *notify = build_alloc_array();
uint8_t op = 0xA0;
build_append_byte(notify, 0x93);
build_append_byte(notify, 0x68);
build_append_value(notify, VAR_2, VAR_3);
build_append_byte(notify, 0x86);
build_append_array(notify, VAR_1);
build_append_byte(notify, 0x69);
build_package(notify, op, 1);
build_append_array(VAR_0, notify);
build_free_array(notify);
}
| [
"static void FUNC_0(GArray *VAR_0, GArray *VAR_1,\nuint32_t VAR_2, int VAR_3)\n{",
"GArray *notify = build_alloc_array();",
"uint8_t op = 0xA0;",
"build_append_byte(notify, 0x93);",
"build_append_byte(notify, 0x68);",
"build_append_value(notify, VAR_2, VAR_3);",
"build_append_byte(notify, 0x86);",
"build_append_array(notify, VAR_1);",
"build_append_byte(notify, 0x69);",
"build_package(notify, op, 1);",
"build_append_array(VAR_0, notify);",
"build_free_array(notify);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
33
],
[
37
],
[
39
]
]
|
10,344 | static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
ARMCPU *cpu = arm_env_get_cpu(env);
if (env->cp15.contextidr_el1 != value && !arm_feature(env, ARM_FEATURE_MPU)
&& !extended_addresses_enabled(env)) {
/* For VMSA (when not using the LPAE long descriptor page table
* format) this register includes the ASID, so do a TLB flush.
* For PMSA it is purely a process ID and no action is needed.
*/
tlb_flush(CPU(cpu), 1);
}
env->cp15.contextidr_el1 = value;
}
| false | qemu | 8d5c773e323b22402abdd0beef4c7d2fc91dd0eb | static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
ARMCPU *cpu = arm_env_get_cpu(env);
if (env->cp15.contextidr_el1 != value && !arm_feature(env, ARM_FEATURE_MPU)
&& !extended_addresses_enabled(env)) {
tlb_flush(CPU(cpu), 1);
}
env->cp15.contextidr_el1 = value;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUARMState *VAR_0, const ARMCPRegInfo *VAR_1,
uint64_t VAR_2)
{
ARMCPU *cpu = arm_env_get_cpu(VAR_0);
if (VAR_0->cp15.contextidr_el1 != VAR_2 && !arm_feature(VAR_0, ARM_FEATURE_MPU)
&& !extended_addresses_enabled(VAR_0)) {
tlb_flush(CPU(cpu), 1);
}
VAR_0->cp15.contextidr_el1 = VAR_2;
}
| [
"static void FUNC_0(CPUARMState *VAR_0, const ARMCPRegInfo *VAR_1,\nuint64_t VAR_2)\n{",
"ARMCPU *cpu = arm_env_get_cpu(VAR_0);",
"if (VAR_0->cp15.contextidr_el1 != VAR_2 && !arm_feature(VAR_0, ARM_FEATURE_MPU)\n&& !extended_addresses_enabled(VAR_0)) {",
"tlb_flush(CPU(cpu), 1);",
"}",
"VAR_0->cp15.contextidr_el1 = VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
23
],
[
25
],
[
27
],
[
29
]
]
|
10,345 | static ram_addr_t qxl_rom_size(void)
{
uint32_t required_rom_size = sizeof(QXLRom) + sizeof(QXLModes) +
sizeof(qxl_modes);
uint32_t rom_size = 8192; /* two pages */
QEMU_BUILD_BUG_ON(required_rom_size > rom_size);
return rom_size;
}
| true | qemu | df45892c1290c6c853010b83e5afebe8740cb9fa | static ram_addr_t qxl_rom_size(void)
{
uint32_t required_rom_size = sizeof(QXLRom) + sizeof(QXLModes) +
sizeof(qxl_modes);
uint32_t rom_size = 8192;
QEMU_BUILD_BUG_ON(required_rom_size > rom_size);
return rom_size;
}
| {
"code": [
" uint32_t required_rom_size = sizeof(QXLRom) + sizeof(QXLModes) +",
" sizeof(qxl_modes);",
" QEMU_BUILD_BUG_ON(required_rom_size > rom_size);",
" return rom_size;"
],
"line_no": [
5,
7,
13,
15
]
} | static ram_addr_t FUNC_0(void)
{
uint32_t required_rom_size = sizeof(QXLRom) + sizeof(QXLModes) +
sizeof(qxl_modes);
uint32_t rom_size = 8192;
QEMU_BUILD_BUG_ON(required_rom_size > rom_size);
return rom_size;
}
| [
"static ram_addr_t FUNC_0(void)\n{",
"uint32_t required_rom_size = sizeof(QXLRom) + sizeof(QXLModes) +\nsizeof(qxl_modes);",
"uint32_t rom_size = 8192;",
"QEMU_BUILD_BUG_ON(required_rom_size > rom_size);",
"return rom_size;",
"}"
]
| [
0,
1,
0,
1,
1,
0
]
| [
[
1,
3
],
[
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
]
]
|
10,346 | static NetSocketState *net_socket_fd_init(NetClientState *peer,
const char *model, const char *name,
int fd, int is_connected)
{
int so_type = -1, optlen=sizeof(so_type);
if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type,
(socklen_t *)&optlen)< 0) {
fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n",
fd);
closesocket(fd);
return NULL;
}
switch(so_type) {
case SOCK_DGRAM:
return net_socket_fd_init_dgram(peer, model, name, fd, is_connected);
case SOCK_STREAM:
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
default:
/* who knows ... this could be a eg. a pty, do warn and continue as stream */
fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd);
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
}
return NULL;
}
| true | qemu | 0f8c289ad539feb5135c545bea947b310a893f4b | static NetSocketState *net_socket_fd_init(NetClientState *peer,
const char *model, const char *name,
int fd, int is_connected)
{
int so_type = -1, optlen=sizeof(so_type);
if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type,
(socklen_t *)&optlen)< 0) {
fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n",
fd);
closesocket(fd);
return NULL;
}
switch(so_type) {
case SOCK_DGRAM:
return net_socket_fd_init_dgram(peer, model, name, fd, is_connected);
case SOCK_STREAM:
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
default:
fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd);
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
}
return NULL;
}
| {
"code": [
" int fd, int is_connected)",
" return net_socket_fd_init_dgram(peer, model, name, fd, is_connected);"
],
"line_no": [
5,
31
]
} | static NetSocketState *FUNC_0(NetClientState *peer,
const char *model, const char *name,
int fd, int is_connected)
{
int VAR_0 = -1, VAR_1=sizeof(VAR_0);
if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&VAR_0,
(socklen_t *)&VAR_1)< 0) {
fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n",
fd);
closesocket(fd);
return NULL;
}
switch(VAR_0) {
case SOCK_DGRAM:
return net_socket_fd_init_dgram(peer, model, name, fd, is_connected);
case SOCK_STREAM:
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
default:
fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", VAR_0, fd);
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
}
return NULL;
}
| [
"static NetSocketState *FUNC_0(NetClientState *peer,\nconst char *model, const char *name,\nint fd, int is_connected)\n{",
"int VAR_0 = -1, VAR_1=sizeof(VAR_0);",
"if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&VAR_0,\n(socklen_t *)&VAR_1)< 0) {",
"fprintf(stderr, \"qemu: error: getsockopt(SO_TYPE) for fd=%d failed\\n\",\nfd);",
"closesocket(fd);",
"return NULL;",
"}",
"switch(VAR_0) {",
"case SOCK_DGRAM:\nreturn net_socket_fd_init_dgram(peer, model, name, fd, is_connected);",
"case SOCK_STREAM:\nreturn net_socket_fd_init_stream(peer, model, name, fd, is_connected);",
"default:\nfprintf(stderr, \"qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\\n\", VAR_0, fd);",
"return net_socket_fd_init_stream(peer, model, name, fd, is_connected);",
"}",
"return NULL;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
13,
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
37,
41
],
[
43
],
[
45
],
[
47
],
[
49
]
]
|
10,347 | static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
BdrvCheckMode fix, uint16_t **refcount_table,
int64_t *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int64_t i;
QCowSnapshot *sn;
int ret;
if (!*refcount_table) {
*refcount_table = g_try_new0(uint16_t, *nb_clusters);
if (*nb_clusters && *refcount_table == NULL) {
res->check_errors++;
return -ENOMEM;
}
}
/* header */
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
0, s->cluster_size);
if (ret < 0) {
return ret;
}
/* current L1 table */
ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters,
s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO);
if (ret < 0) {
return ret;
}
/* snapshots */
for (i = 0; i < s->nb_snapshots; i++) {
sn = s->snapshots + i;
ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters,
sn->l1_table_offset, sn->l1_size, 0);
if (ret < 0) {
return ret;
}
}
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
s->snapshots_offset, s->snapshots_size);
if (ret < 0) {
return ret;
}
/* refcount data */
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
s->refcount_table_offset,
s->refcount_table_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
return check_refblocks(bs, res, fix, refcount_table, nb_clusters);
}
| true | qemu | f307b2558f61e068ce514f2dde2cad74c62036d6 | static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
BdrvCheckMode fix, uint16_t **refcount_table,
int64_t *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int64_t i;
QCowSnapshot *sn;
int ret;
if (!*refcount_table) {
*refcount_table = g_try_new0(uint16_t, *nb_clusters);
if (*nb_clusters && *refcount_table == NULL) {
res->check_errors++;
return -ENOMEM;
}
}
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
0, s->cluster_size);
if (ret < 0) {
return ret;
}
ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters,
s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO);
if (ret < 0) {
return ret;
}
for (i = 0; i < s->nb_snapshots; i++) {
sn = s->snapshots + i;
ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters,
sn->l1_table_offset, sn->l1_size, 0);
if (ret < 0) {
return ret;
}
}
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
s->snapshots_offset, s->snapshots_size);
if (ret < 0) {
return ret;
}
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
s->refcount_table_offset,
s->refcount_table_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
return check_refblocks(bs, res, fix, refcount_table, nb_clusters);
}
| {
"code": [
" BDRVQcowState *s = bs->opaque;",
" if (ret < 0) {",
" return ret;",
" if (ret < 0) {",
" return ret;",
" BDRVQcowState *s = bs->opaque;",
" int ret;",
" if (ret < 0) {",
" if (ret < 0) {",
" if (ret < 0) {",
" if (ret < 0) {",
" if (ret < 0) {",
" return ret;",
" BdrvCheckMode fix, uint16_t **refcount_table,",
" int64_t *nb_clusters)",
" return check_refblocks(bs, res, fix, refcount_table, nb_clusters);"
],
"line_no": [
9,
41,
43,
41,
43,
9,
15,
41,
41,
41,
41,
41,
43,
3,
5,
109
]
} | static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,
BdrvCheckMode VAR_2, uint16_t **VAR_3,
int64_t *VAR_4)
{
BDRVQcowState *s = VAR_0->opaque;
int64_t i;
QCowSnapshot *sn;
int VAR_5;
if (!*VAR_3) {
*VAR_3 = g_try_new0(uint16_t, *VAR_4);
if (*VAR_4 && *VAR_3 == NULL) {
VAR_1->check_errors++;
return -ENOMEM;
}
}
VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4,
0, s->cluster_size);
if (VAR_5 < 0) {
return VAR_5;
}
VAR_5 = check_refcounts_l1(VAR_0, VAR_1, VAR_3, VAR_4,
s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO);
if (VAR_5 < 0) {
return VAR_5;
}
for (i = 0; i < s->nb_snapshots; i++) {
sn = s->snapshots + i;
VAR_5 = check_refcounts_l1(VAR_0, VAR_1, VAR_3, VAR_4,
sn->l1_table_offset, sn->l1_size, 0);
if (VAR_5 < 0) {
return VAR_5;
}
}
VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4,
s->snapshots_offset, s->snapshots_size);
if (VAR_5 < 0) {
return VAR_5;
}
VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4,
s->refcount_table_offset,
s->refcount_table_size * sizeof(uint64_t));
if (VAR_5 < 0) {
return VAR_5;
}
return check_refblocks(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,\nBdrvCheckMode VAR_2, uint16_t **VAR_3,\nint64_t *VAR_4)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int64_t i;",
"QCowSnapshot *sn;",
"int VAR_5;",
"if (!*VAR_3) {",
"*VAR_3 = g_try_new0(uint16_t, *VAR_4);",
"if (*VAR_4 && *VAR_3 == NULL) {",
"VAR_1->check_errors++;",
"return -ENOMEM;",
"}",
"}",
"VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4,\n0, s->cluster_size);",
"if (VAR_5 < 0) {",
"return VAR_5;",
"}",
"VAR_5 = check_refcounts_l1(VAR_0, VAR_1, VAR_3, VAR_4,\ns->l1_table_offset, s->l1_size, CHECK_FRAG_INFO);",
"if (VAR_5 < 0) {",
"return VAR_5;",
"}",
"for (i = 0; i < s->nb_snapshots; i++) {",
"sn = s->snapshots + i;",
"VAR_5 = check_refcounts_l1(VAR_0, VAR_1, VAR_3, VAR_4,\nsn->l1_table_offset, sn->l1_size, 0);",
"if (VAR_5 < 0) {",
"return VAR_5;",
"}",
"}",
"VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4,\ns->snapshots_offset, s->snapshots_size);",
"if (VAR_5 < 0) {",
"return VAR_5;",
"}",
"VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4,\ns->refcount_table_offset,\ns->refcount_table_size * sizeof(uint64_t));",
"if (VAR_5 < 0) {",
"return VAR_5;",
"}",
"return check_refblocks(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);",
"}"
]
| [
1,
1,
0,
0,
1,
0,
0,
0,
0,
0,
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,
1,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
95,
97,
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
]
]
|
10,348 | long check_dcbzl_effect(void)
{
register char *fakedata = (char*)av_malloc(1024);
register char *fakedata_middle;
register long zero = 0;
register long i = 0;
long count = 0;
if (!fakedata)
{
return 0L;
}
fakedata_middle = (fakedata + 512);
memset(fakedata, 0xFF, 1024);
/* below the constraint "b" seems to mean "Address base register"
in gcc-3.3 / RS/6000 speaks. seems to avoid using r0, so.... */
asm volatile("dcbzl %0, %1" : : "b" (fakedata_middle), "r" (zero));
for (i = 0; i < 1024 ; i ++)
{
if (fakedata[i] == (char)0)
count++;
}
av_free(fakedata);
return count;
}
| false | FFmpeg | 90901860c21468d6e9ae437c2bacb099c7bd3acf | long check_dcbzl_effect(void)
{
register char *fakedata = (char*)av_malloc(1024);
register char *fakedata_middle;
register long zero = 0;
register long i = 0;
long count = 0;
if (!fakedata)
{
return 0L;
}
fakedata_middle = (fakedata + 512);
memset(fakedata, 0xFF, 1024);
asm volatile("dcbzl %0, %1" : : "b" (fakedata_middle), "r" (zero));
for (i = 0; i < 1024 ; i ++)
{
if (fakedata[i] == (char)0)
count++;
}
av_free(fakedata);
return count;
}
| {
"code": [],
"line_no": []
} | long FUNC_0(void)
{
register char *VAR_0 = (char*)av_malloc(1024);
register char *VAR_1;
register long VAR_2 = 0;
register long VAR_3 = 0;
long VAR_4 = 0;
if (!VAR_0)
{
return 0L;
}
VAR_1 = (VAR_0 + 512);
memset(VAR_0, 0xFF, 1024);
asm volatile("dcbzl %0, %1" : : "b" (VAR_1), "r" (VAR_2));
for (VAR_3 = 0; VAR_3 < 1024 ; VAR_3 ++)
{
if (VAR_0[VAR_3] == (char)0)
VAR_4++;
}
av_free(VAR_0);
return VAR_4;
}
| [
"long FUNC_0(void)\n{",
"register char *VAR_0 = (char*)av_malloc(1024);",
"register char *VAR_1;",
"register long VAR_2 = 0;",
"register long VAR_3 = 0;",
"long VAR_4 = 0;",
"if (!VAR_0)\n{",
"return 0L;",
"}",
"VAR_1 = (VAR_0 + 512);",
"memset(VAR_0, 0xFF, 1024);",
"asm volatile(\"dcbzl %0, %1\" : : \"b\" (VAR_1), \"r\" (VAR_2));",
"for (VAR_3 = 0; VAR_3 < 1024 ; VAR_3 ++)",
"{",
"if (VAR_0[VAR_3] == (char)0)\nVAR_4++;",
"}",
"av_free(VAR_0);",
"return VAR_4;",
"}"
]
| [
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
],
[
27
],
[
31
],
[
39
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
55
],
[
59
],
[
61
]
]
|
10,350 | static void vga_update_display(void *opaque)
{
VGACommonState *s = opaque;
int full_update, graphic_mode;
qemu_flush_coalesced_mmio_buffer();
if (ds_get_bits_per_pixel(s->ds) == 0) {
/* nothing to do */
} else {
full_update = 0;
if (!(s->ar_index & 0x20)) {
graphic_mode = GMODE_BLANK;
} else {
graphic_mode = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE;
}
if (graphic_mode != s->graphic_mode) {
s->graphic_mode = graphic_mode;
s->cursor_blink_time = qemu_get_clock_ms(vm_clock);
full_update = 1;
}
switch(graphic_mode) {
case GMODE_TEXT:
vga_draw_text(s, full_update);
break;
case GMODE_GRAPH:
vga_draw_graphic(s, full_update);
break;
case GMODE_BLANK:
default:
vga_draw_blank(s, full_update);
break;
}
}
}
| true | qemu | 482f7bf86b43af9f6903c52726fedf82b28bf953 | static void vga_update_display(void *opaque)
{
VGACommonState *s = opaque;
int full_update, graphic_mode;
qemu_flush_coalesced_mmio_buffer();
if (ds_get_bits_per_pixel(s->ds) == 0) {
} else {
full_update = 0;
if (!(s->ar_index & 0x20)) {
graphic_mode = GMODE_BLANK;
} else {
graphic_mode = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE;
}
if (graphic_mode != s->graphic_mode) {
s->graphic_mode = graphic_mode;
s->cursor_blink_time = qemu_get_clock_ms(vm_clock);
full_update = 1;
}
switch(graphic_mode) {
case GMODE_TEXT:
vga_draw_text(s, full_update);
break;
case GMODE_GRAPH:
vga_draw_graphic(s, full_update);
break;
case GMODE_BLANK:
default:
vga_draw_blank(s, full_update);
break;
}
}
}
| {
"code": [
" if (!(s->ar_index & 0x20)) {"
],
"line_no": [
23
]
} | static void FUNC_0(void *VAR_0)
{
VGACommonState *s = VAR_0;
int VAR_1, VAR_2;
qemu_flush_coalesced_mmio_buffer();
if (ds_get_bits_per_pixel(s->ds) == 0) {
} else {
VAR_1 = 0;
if (!(s->ar_index & 0x20)) {
VAR_2 = GMODE_BLANK;
} else {
VAR_2 = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE;
}
if (VAR_2 != s->VAR_2) {
s->VAR_2 = VAR_2;
s->cursor_blink_time = qemu_get_clock_ms(vm_clock);
VAR_1 = 1;
}
switch(VAR_2) {
case GMODE_TEXT:
vga_draw_text(s, VAR_1);
break;
case GMODE_GRAPH:
vga_draw_graphic(s, VAR_1);
break;
case GMODE_BLANK:
default:
vga_draw_blank(s, VAR_1);
break;
}
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"VGACommonState *s = VAR_0;",
"int VAR_1, VAR_2;",
"qemu_flush_coalesced_mmio_buffer();",
"if (ds_get_bits_per_pixel(s->ds) == 0) {",
"} else {",
"VAR_1 = 0;",
"if (!(s->ar_index & 0x20)) {",
"VAR_2 = GMODE_BLANK;",
"} else {",
"VAR_2 = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE;",
"}",
"if (VAR_2 != s->VAR_2) {",
"s->VAR_2 = VAR_2;",
"s->cursor_blink_time = qemu_get_clock_ms(vm_clock);",
"VAR_1 = 1;",
"}",
"switch(VAR_2) {",
"case GMODE_TEXT:\nvga_draw_text(s, VAR_1);",
"break;",
"case GMODE_GRAPH:\nvga_draw_graphic(s, VAR_1);",
"break;",
"case GMODE_BLANK:\ndefault:\nvga_draw_blank(s, VAR_1);",
"break;",
"}",
"}",
"}"
]
| [
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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
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
]
]
|
10,352 | static inline void comp_block(MadContext *t, int mb_x, int mb_y,
int j, int mv_x, int mv_y, int add)
{
MpegEncContext *s = &t->s;
if (j < 4) {
comp(t->frame.data[0] + (mb_y*16 + ((j&2)<<2))*t->frame.linesize[0] + mb_x*16 + ((j&1)<<3),
t->frame.linesize[0],
t->last_frame.data[0] + (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x,
t->last_frame.linesize[0], add);
} else if (!(s->avctx->flags & CODEC_FLAG_GRAY)) {
int index = j - 3;
comp(t->frame.data[index] + (mb_y*8)*t->frame.linesize[index] + mb_x * 8,
t->frame.linesize[index],
t->last_frame.data[index] + (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2),
t->last_frame.linesize[index], add);
}
}
| true | FFmpeg | da35797359cec148f3fe59894c62727b0422d75a | static inline void comp_block(MadContext *t, int mb_x, int mb_y,
int j, int mv_x, int mv_y, int add)
{
MpegEncContext *s = &t->s;
if (j < 4) {
comp(t->frame.data[0] + (mb_y*16 + ((j&2)<<2))*t->frame.linesize[0] + mb_x*16 + ((j&1)<<3),
t->frame.linesize[0],
t->last_frame.data[0] + (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x,
t->last_frame.linesize[0], add);
} else if (!(s->avctx->flags & CODEC_FLAG_GRAY)) {
int index = j - 3;
comp(t->frame.data[index] + (mb_y*8)*t->frame.linesize[index] + mb_x * 8,
t->frame.linesize[index],
t->last_frame.data[index] + (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2),
t->last_frame.linesize[index], add);
}
}
| {
"code": [
" t->last_frame.data[0] + (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x,",
" t->last_frame.data[index] + (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2),"
],
"line_no": [
15,
27
]
} | static inline void FUNC_0(MadContext *VAR_0, int VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5, int VAR_6)
{
MpegEncContext *s = &VAR_0->s;
if (VAR_3 < 4) {
comp(VAR_0->frame.data[0] + (VAR_2*16 + ((VAR_3&2)<<2))*VAR_0->frame.linesize[0] + VAR_1*16 + ((VAR_3&1)<<3),
VAR_0->frame.linesize[0],
VAR_0->last_frame.data[0] + (VAR_2*16 + ((VAR_3&2)<<2) + VAR_5)*VAR_0->last_frame.linesize[0] + VAR_1*16 + ((VAR_3&1)<<3) + VAR_4,
VAR_0->last_frame.linesize[0], VAR_6);
} else if (!(s->avctx->flags & CODEC_FLAG_GRAY)) {
int VAR_7 = VAR_3 - 3;
comp(VAR_0->frame.data[VAR_7] + (VAR_2*8)*VAR_0->frame.linesize[VAR_7] + VAR_1 * 8,
VAR_0->frame.linesize[VAR_7],
VAR_0->last_frame.data[VAR_7] + (VAR_2 * 8 + (VAR_5/2))*VAR_0->last_frame.linesize[VAR_7] + VAR_1 * 8 + (VAR_4/2),
VAR_0->last_frame.linesize[VAR_7], VAR_6);
}
}
| [
"static inline void FUNC_0(MadContext *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4, int VAR_5, int VAR_6)\n{",
"MpegEncContext *s = &VAR_0->s;",
"if (VAR_3 < 4) {",
"comp(VAR_0->frame.data[0] + (VAR_2*16 + ((VAR_3&2)<<2))*VAR_0->frame.linesize[0] + VAR_1*16 + ((VAR_3&1)<<3),\nVAR_0->frame.linesize[0],\nVAR_0->last_frame.data[0] + (VAR_2*16 + ((VAR_3&2)<<2) + VAR_5)*VAR_0->last_frame.linesize[0] + VAR_1*16 + ((VAR_3&1)<<3) + VAR_4,\nVAR_0->last_frame.linesize[0], VAR_6);",
"} else if (!(s->avctx->flags & CODEC_FLAG_GRAY)) {",
"int VAR_7 = VAR_3 - 3;",
"comp(VAR_0->frame.data[VAR_7] + (VAR_2*8)*VAR_0->frame.linesize[VAR_7] + VAR_1 * 8,\nVAR_0->frame.linesize[VAR_7],\nVAR_0->last_frame.data[VAR_7] + (VAR_2 * 8 + (VAR_5/2))*VAR_0->last_frame.linesize[VAR_7] + VAR_1 * 8 + (VAR_4/2),\nVAR_0->last_frame.linesize[VAR_7], VAR_6);",
"}",
"}"
]
| [
0,
0,
0,
1,
0,
0,
1,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13,
15,
17
],
[
19
],
[
21
],
[
23,
25,
27,
29
],
[
31
],
[
33
]
]
|
10,353 | static inline int gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext dc1, *dc = &dc1;
uint16_t *gen_opc_end;
int j, lj;
target_ulong pc_start;
uint32_t next_page_start;
/* generate intermediate code */
pc_start = tb->pc;
dc->tb = tb;
gen_opc_ptr = gen_opc_buf;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
gen_opparam_ptr = gen_opparam_buf;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->singlestep_enabled = env->singlestep_enabled;
dc->condjmp = 0;
dc->thumb = env->thumb;
dc->is_mem = 0;
#if !defined(CONFIG_USER_ONLY)
dc->user = (env->uncached_cpsr & 0x1f) == ARM_CPU_MODE_USR;
#endif
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
nb_gen_labels = 0;
lj = -1;
do {
if (env->nb_breakpoints > 0) {
for(j = 0; j < env->nb_breakpoints; j++) {
if (env->breakpoints[j] == dc->pc) {
gen_op_movl_T0_im((long)dc->pc);
gen_op_movl_reg_TN[0][15]();
gen_op_debug();
dc->is_jmp = DISAS_JUMP;
}
}
}
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
}
gen_opc_pc[lj] = dc->pc;
gen_opc_instr_start[lj] = 1;
}
if (env->thumb)
disas_thumb_insn(dc);
else
disas_arm_insn(env, dc);
if (dc->condjmp && !dc->is_jmp) {
gen_set_label(dc->condlabel);
dc->condjmp = 0;
}
/* Translation stops when a conditional branch is enoutered.
* Otherwise the subsequent code could get translated several times.
* Also stop translation when a page boundary is reached. This
* ensures prefech aborts occur at the right place. */
} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
!env->singlestep_enabled &&
dc->pc < next_page_start);
/* At this stage dc->condjmp will only be set when the skipped
* instruction was a conditional branch, and the PC has already been
* written. */
if (__builtin_expect(env->singlestep_enabled, 0)) {
/* Make sure the pc is updated, and raise a debug exception. */
if (dc->condjmp) {
gen_op_debug();
gen_set_label(dc->condlabel);
}
if (dc->condjmp || !dc->is_jmp) {
gen_op_movl_T0_im((long)dc->pc);
gen_op_movl_reg_TN[0][15]();
dc->condjmp = 0;
}
gen_op_debug();
} else {
switch(dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, dc->pc);
default:
case DISAS_JUMP:
case DISAS_UPDATE:
/* indicate that the hash table must be used to find the next TB */
gen_op_movl_T0_0();
gen_op_exit_tb();
case DISAS_TB_JUMP:
/* nothing more to generate */
}
if (dc->condjmp) {
gen_set_label(dc->condlabel);
gen_goto_tb(dc, 1, dc->pc);
dc->condjmp = 0;
}
}
*gen_opc_ptr = INDEX_op_end;
#ifdef DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "----------------\n");
fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
target_disas(logfile, pc_start, dc->pc - pc_start, env->thumb);
fprintf(logfile, "\n");
if (loglevel & (CPU_LOG_TB_OP)) {
fprintf(logfile, "OP:\n");
dump_ops(gen_opc_buf, gen_opparam_buf);
fprintf(logfile, "\n");
}
}
#endif
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
tb->size = 0;
} else {
tb->size = dc->pc - pc_start;
}
return 0;
} | true | qemu | 6658ffb81ee56a510d7d77025872a508a9adce3a | static inline int gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext dc1, *dc = &dc1;
uint16_t *gen_opc_end;
int j, lj;
target_ulong pc_start;
uint32_t next_page_start;
pc_start = tb->pc;
dc->tb = tb;
gen_opc_ptr = gen_opc_buf;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
gen_opparam_ptr = gen_opparam_buf;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->singlestep_enabled = env->singlestep_enabled;
dc->condjmp = 0;
dc->thumb = env->thumb;
dc->is_mem = 0;
#if !defined(CONFIG_USER_ONLY)
dc->user = (env->uncached_cpsr & 0x1f) == ARM_CPU_MODE_USR;
#endif
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
nb_gen_labels = 0;
lj = -1;
do {
if (env->nb_breakpoints > 0) {
for(j = 0; j < env->nb_breakpoints; j++) {
if (env->breakpoints[j] == dc->pc) {
gen_op_movl_T0_im((long)dc->pc);
gen_op_movl_reg_TN[0][15]();
gen_op_debug();
dc->is_jmp = DISAS_JUMP;
}
}
}
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
}
gen_opc_pc[lj] = dc->pc;
gen_opc_instr_start[lj] = 1;
}
if (env->thumb)
disas_thumb_insn(dc);
else
disas_arm_insn(env, dc);
if (dc->condjmp && !dc->is_jmp) {
gen_set_label(dc->condlabel);
dc->condjmp = 0;
}
} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
!env->singlestep_enabled &&
dc->pc < next_page_start);
if (__builtin_expect(env->singlestep_enabled, 0)) {
if (dc->condjmp) {
gen_op_debug();
gen_set_label(dc->condlabel);
}
if (dc->condjmp || !dc->is_jmp) {
gen_op_movl_T0_im((long)dc->pc);
gen_op_movl_reg_TN[0][15]();
dc->condjmp = 0;
}
gen_op_debug();
} else {
switch(dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, dc->pc);
default:
case DISAS_JUMP:
case DISAS_UPDATE:
gen_op_movl_T0_0();
gen_op_exit_tb();
case DISAS_TB_JUMP:
}
if (dc->condjmp) {
gen_set_label(dc->condlabel);
gen_goto_tb(dc, 1, dc->pc);
dc->condjmp = 0;
}
}
*gen_opc_ptr = INDEX_op_end;
#ifdef DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "----------------\n");
fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
target_disas(logfile, pc_start, dc->pc - pc_start, env->thumb);
fprintf(logfile, "\n");
if (loglevel & (CPU_LOG_TB_OP)) {
fprintf(logfile, "OP:\n");
dump_ops(gen_opc_buf, gen_opparam_buf);
fprintf(logfile, "\n");
}
}
#endif
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
tb->size = 0;
} else {
tb->size = dc->pc - pc_start;
}
return 0;
} | {
"code": [],
"line_no": []
} | static inline int FUNC_0(CPUState *VAR_0,
TranslationBlock *VAR_1,
int VAR_2)
{
DisasContext dc1, *dc = &dc1;
uint16_t *gen_opc_end;
int VAR_3, VAR_4;
target_ulong pc_start;
uint32_t next_page_start;
pc_start = VAR_1->pc;
dc->VAR_1 = VAR_1;
gen_opc_ptr = gen_opc_buf;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
gen_opparam_ptr = gen_opparam_buf;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->singlestep_enabled = VAR_0->singlestep_enabled;
dc->condjmp = 0;
dc->thumb = VAR_0->thumb;
dc->is_mem = 0;
#if !defined(CONFIG_USER_ONLY)
dc->user = (VAR_0->uncached_cpsr & 0x1f) == ARM_CPU_MODE_USR;
#endif
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
nb_gen_labels = 0;
VAR_4 = -1;
do {
if (VAR_0->nb_breakpoints > 0) {
for(VAR_3 = 0; VAR_3 < VAR_0->nb_breakpoints; VAR_3++) {
if (VAR_0->breakpoints[VAR_3] == dc->pc) {
gen_op_movl_T0_im((long)dc->pc);
gen_op_movl_reg_TN[0][15]();
gen_op_debug();
dc->is_jmp = DISAS_JUMP;
}
}
}
if (VAR_2) {
VAR_3 = gen_opc_ptr - gen_opc_buf;
if (VAR_4 < VAR_3) {
VAR_4++;
while (VAR_4 < VAR_3)
gen_opc_instr_start[VAR_4++] = 0;
}
gen_opc_pc[VAR_4] = dc->pc;
gen_opc_instr_start[VAR_4] = 1;
}
if (VAR_0->thumb)
disas_thumb_insn(dc);
else
disas_arm_insn(VAR_0, dc);
if (dc->condjmp && !dc->is_jmp) {
gen_set_label(dc->condlabel);
dc->condjmp = 0;
}
} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
!VAR_0->singlestep_enabled &&
dc->pc < next_page_start);
if (__builtin_expect(VAR_0->singlestep_enabled, 0)) {
if (dc->condjmp) {
gen_op_debug();
gen_set_label(dc->condlabel);
}
if (dc->condjmp || !dc->is_jmp) {
gen_op_movl_T0_im((long)dc->pc);
gen_op_movl_reg_TN[0][15]();
dc->condjmp = 0;
}
gen_op_debug();
} else {
switch(dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, dc->pc);
default:
case DISAS_JUMP:
case DISAS_UPDATE:
gen_op_movl_T0_0();
gen_op_exit_tb();
case DISAS_TB_JUMP:
}
if (dc->condjmp) {
gen_set_label(dc->condlabel);
gen_goto_tb(dc, 1, dc->pc);
dc->condjmp = 0;
}
}
*gen_opc_ptr = INDEX_op_end;
#ifdef DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "----------------\n");
fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
target_disas(logfile, pc_start, dc->pc - pc_start, VAR_0->thumb);
fprintf(logfile, "\n");
if (loglevel & (CPU_LOG_TB_OP)) {
fprintf(logfile, "OP:\n");
dump_ops(gen_opc_buf, gen_opparam_buf);
fprintf(logfile, "\n");
}
}
#endif
if (VAR_2) {
VAR_3 = gen_opc_ptr - gen_opc_buf;
VAR_4++;
while (VAR_4 <= VAR_3)
gen_opc_instr_start[VAR_4++] = 0;
VAR_1->size = 0;
} else {
VAR_1->size = dc->pc - pc_start;
}
return 0;
} | [
"static inline int FUNC_0(CPUState *VAR_0,\nTranslationBlock *VAR_1,\nint VAR_2)\n{",
"DisasContext dc1, *dc = &dc1;",
"uint16_t *gen_opc_end;",
"int VAR_3, VAR_4;",
"target_ulong pc_start;",
"uint32_t next_page_start;",
"pc_start = VAR_1->pc;",
"dc->VAR_1 = VAR_1;",
"gen_opc_ptr = gen_opc_buf;",
"gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;",
"gen_opparam_ptr = gen_opparam_buf;",
"dc->is_jmp = DISAS_NEXT;",
"dc->pc = pc_start;",
"dc->singlestep_enabled = VAR_0->singlestep_enabled;",
"dc->condjmp = 0;",
"dc->thumb = VAR_0->thumb;",
"dc->is_mem = 0;",
"#if !defined(CONFIG_USER_ONLY)\ndc->user = (VAR_0->uncached_cpsr & 0x1f) == ARM_CPU_MODE_USR;",
"#endif\nnext_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;",
"nb_gen_labels = 0;",
"VAR_4 = -1;",
"do {",
"if (VAR_0->nb_breakpoints > 0) {",
"for(VAR_3 = 0; VAR_3 < VAR_0->nb_breakpoints; VAR_3++) {",
"if (VAR_0->breakpoints[VAR_3] == dc->pc) {",
"gen_op_movl_T0_im((long)dc->pc);",
"gen_op_movl_reg_TN[0][15]();",
"gen_op_debug();",
"dc->is_jmp = DISAS_JUMP;",
"}",
"}",
"}",
"if (VAR_2) {",
"VAR_3 = gen_opc_ptr - gen_opc_buf;",
"if (VAR_4 < VAR_3) {",
"VAR_4++;",
"while (VAR_4 < VAR_3)\ngen_opc_instr_start[VAR_4++] = 0;",
"}",
"gen_opc_pc[VAR_4] = dc->pc;",
"gen_opc_instr_start[VAR_4] = 1;",
"}",
"if (VAR_0->thumb)\ndisas_thumb_insn(dc);",
"else\ndisas_arm_insn(VAR_0, dc);",
"if (dc->condjmp && !dc->is_jmp) {",
"gen_set_label(dc->condlabel);",
"dc->condjmp = 0;",
"}",
"} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&",
"!VAR_0->singlestep_enabled &&\ndc->pc < next_page_start);",
"if (__builtin_expect(VAR_0->singlestep_enabled, 0)) {",
"if (dc->condjmp) {",
"gen_op_debug();",
"gen_set_label(dc->condlabel);",
"}",
"if (dc->condjmp || !dc->is_jmp) {",
"gen_op_movl_T0_im((long)dc->pc);",
"gen_op_movl_reg_TN[0][15]();",
"dc->condjmp = 0;",
"}",
"gen_op_debug();",
"} else {",
"switch(dc->is_jmp) {",
"case DISAS_NEXT:\ngen_goto_tb(dc, 1, dc->pc);",
"default:\ncase DISAS_JUMP:\ncase DISAS_UPDATE:\ngen_op_movl_T0_0();",
"gen_op_exit_tb();",
"case DISAS_TB_JUMP:\n}",
"if (dc->condjmp) {",
"gen_set_label(dc->condlabel);",
"gen_goto_tb(dc, 1, dc->pc);",
"dc->condjmp = 0;",
"}",
"}",
"*gen_opc_ptr = INDEX_op_end;",
"#ifdef DEBUG_DISAS\nif (loglevel & CPU_LOG_TB_IN_ASM) {",
"fprintf(logfile, \"----------------\\n\");",
"fprintf(logfile, \"IN: %s\\n\", lookup_symbol(pc_start));",
"target_disas(logfile, pc_start, dc->pc - pc_start, VAR_0->thumb);",
"fprintf(logfile, \"\\n\");",
"if (loglevel & (CPU_LOG_TB_OP)) {",
"fprintf(logfile, \"OP:\\n\");",
"dump_ops(gen_opc_buf, gen_opparam_buf);",
"fprintf(logfile, \"\\n\");",
"}",
"}",
"#endif\nif (VAR_2) {",
"VAR_3 = gen_opc_ptr - gen_opc_buf;",
"VAR_4++;",
"while (VAR_4 <= VAR_3)\ngen_opc_instr_start[VAR_4++] = 0;",
"VAR_1->size = 0;",
"} else {",
"VAR_1->size = dc->pc - pc_start;",
"}",
"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
]
| [
[
1,
2,
3,
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
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
],
[
43,
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49,
50
],
[
51,
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
61
],
[
62,
63
],
[
67
],
[
69
],
[
70
],
[
71
],
[
72
],
[
73
],
[
74
],
[
75
],
[
76
],
[
77
],
[
78
],
[
79
],
[
80
],
[
81,
82
],
[
83,
84,
85,
87
],
[
88
],
[
89,
91
],
[
92
],
[
93
],
[
94
],
[
95
],
[
96
],
[
97
],
[
98
],
[
99,
100
],
[
101
],
[
102
],
[
103
],
[
104
],
[
105
],
[
106
],
[
107
],
[
108
],
[
109
],
[
110
],
[
111,
112
],
[
113
],
[
114
],
[
115,
116
],
[
117
],
[
118
],
[
119
],
[
120
],
[
121
],
[
122
]
]
|
10,354 | static always_inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1, TCGv arg2,
int add_ca, int compute_ca, int compute_ov)
{
TCGv t0, t1;
if ((!compute_ca && !compute_ov) ||
(!TCGV_EQUAL(ret, arg1) && !TCGV_EQUAL(ret, arg2))) {
t0 = ret;
t0 = tcg_temp_local_new();
}
if (add_ca) {
t1 = tcg_temp_local_new();
tcg_gen_andi_tl(t1, cpu_xer, (1 << XER_CA));
tcg_gen_shri_tl(t1, t1, XER_CA);
}
if (compute_ca && compute_ov) {
/* Start with XER CA and OV disabled, the most likely case */
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~((1 << XER_CA) | (1 << XER_OV)));
} else if (compute_ca) {
/* Start with XER CA disabled, the most likely case */
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_CA));
} else if (compute_ov) {
/* Start with XER OV disabled, the most likely case */
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_OV));
}
if (add_ca) {
tcg_gen_not_tl(t0, arg1);
tcg_gen_add_tl(t0, t0, arg2);
gen_op_arith_compute_ca(ctx, t0, arg2, 0);
tcg_gen_add_tl(t0, t0, t1);
gen_op_arith_compute_ca(ctx, t0, t1, 0);
tcg_temp_free(t1);
tcg_gen_sub_tl(t0, arg2, arg1);
if (compute_ca) {
gen_op_arith_compute_ca(ctx, t0, arg2, 1);
}
}
if (compute_ov) {
gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 1);
}
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, t0);
if (!TCGV_EQUAL(t0, ret)) {
tcg_gen_mov_tl(ret, t0);
tcg_temp_free(t0);
}
} | true | qemu | d2e9fd8f703203c2eeeed120b1ef6c3a6574e0ab | static always_inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1, TCGv arg2,
int add_ca, int compute_ca, int compute_ov)
{
TCGv t0, t1;
if ((!compute_ca && !compute_ov) ||
(!TCGV_EQUAL(ret, arg1) && !TCGV_EQUAL(ret, arg2))) {
t0 = ret;
t0 = tcg_temp_local_new();
}
if (add_ca) {
t1 = tcg_temp_local_new();
tcg_gen_andi_tl(t1, cpu_xer, (1 << XER_CA));
tcg_gen_shri_tl(t1, t1, XER_CA);
}
if (compute_ca && compute_ov) {
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~((1 << XER_CA) | (1 << XER_OV)));
} else if (compute_ca) {
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_CA));
} else if (compute_ov) {
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_OV));
}
if (add_ca) {
tcg_gen_not_tl(t0, arg1);
tcg_gen_add_tl(t0, t0, arg2);
gen_op_arith_compute_ca(ctx, t0, arg2, 0);
tcg_gen_add_tl(t0, t0, t1);
gen_op_arith_compute_ca(ctx, t0, t1, 0);
tcg_temp_free(t1);
tcg_gen_sub_tl(t0, arg2, arg1);
if (compute_ca) {
gen_op_arith_compute_ca(ctx, t0, arg2, 1);
}
}
if (compute_ov) {
gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 1);
}
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, t0);
if (!TCGV_EQUAL(t0, ret)) {
tcg_gen_mov_tl(ret, t0);
tcg_temp_free(t0);
}
} | {
"code": [],
"line_no": []
} | static always_inline void FUNC_0(DisasContext *ctx, TCGv ret, TCGv arg1, TCGv arg2,
int add_ca, int compute_ca, int compute_ov)
{
TCGv t0, t1;
if ((!compute_ca && !compute_ov) ||
(!TCGV_EQUAL(ret, arg1) && !TCGV_EQUAL(ret, arg2))) {
t0 = ret;
t0 = tcg_temp_local_new();
}
if (add_ca) {
t1 = tcg_temp_local_new();
tcg_gen_andi_tl(t1, cpu_xer, (1 << XER_CA));
tcg_gen_shri_tl(t1, t1, XER_CA);
}
if (compute_ca && compute_ov) {
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~((1 << XER_CA) | (1 << XER_OV)));
} else if (compute_ca) {
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_CA));
} else if (compute_ov) {
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_OV));
}
if (add_ca) {
tcg_gen_not_tl(t0, arg1);
tcg_gen_add_tl(t0, t0, arg2);
gen_op_arith_compute_ca(ctx, t0, arg2, 0);
tcg_gen_add_tl(t0, t0, t1);
gen_op_arith_compute_ca(ctx, t0, t1, 0);
tcg_temp_free(t1);
tcg_gen_sub_tl(t0, arg2, arg1);
if (compute_ca) {
gen_op_arith_compute_ca(ctx, t0, arg2, 1);
}
}
if (compute_ov) {
gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 1);
}
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, t0);
if (!TCGV_EQUAL(t0, ret)) {
tcg_gen_mov_tl(ret, t0);
tcg_temp_free(t0);
}
} | [
"static always_inline void FUNC_0(DisasContext *ctx, TCGv ret, TCGv arg1, TCGv arg2,\nint add_ca, int compute_ca, int compute_ov)\n{",
"TCGv t0, t1;",
"if ((!compute_ca && !compute_ov) ||\n(!TCGV_EQUAL(ret, arg1) && !TCGV_EQUAL(ret, arg2))) {",
"t0 = ret;",
"t0 = tcg_temp_local_new();",
"}",
"if (add_ca) {",
"t1 = tcg_temp_local_new();",
"tcg_gen_andi_tl(t1, cpu_xer, (1 << XER_CA));",
"tcg_gen_shri_tl(t1, t1, XER_CA);",
"}",
"if (compute_ca && compute_ov) {",
"tcg_gen_andi_tl(cpu_xer, cpu_xer, ~((1 << XER_CA) | (1 << XER_OV)));",
"} else if (compute_ca) {",
"tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_CA));",
"} else if (compute_ov) {",
"tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_OV));",
"}",
"if (add_ca) {",
"tcg_gen_not_tl(t0, arg1);",
"tcg_gen_add_tl(t0, t0, arg2);",
"gen_op_arith_compute_ca(ctx, t0, arg2, 0);",
"tcg_gen_add_tl(t0, t0, t1);",
"gen_op_arith_compute_ca(ctx, t0, t1, 0);",
"tcg_temp_free(t1);",
"tcg_gen_sub_tl(t0, arg2, arg1);",
"if (compute_ca) {",
"gen_op_arith_compute_ca(ctx, t0, arg2, 1);",
"}",
"}",
"if (compute_ov) {",
"gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 1);",
"}",
"if (unlikely(Rc(ctx->opcode) != 0))\ngen_set_Rc0(ctx, t0);",
"if (!TCGV_EQUAL(t0, ret)) {",
"tcg_gen_mov_tl(ret, t0);",
"tcg_temp_free(t0);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
18
],
[
20
],
[
24
],
[
26
],
[
28
],
[
30
],
[
34
],
[
38
],
[
42
],
[
44
],
[
48
],
[
50
],
[
54
],
[
56
],
[
60
],
[
62
],
[
64
],
[
66
],
[
68
],
[
70
],
[
72
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93,
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
]
]
|
10,357 | static uint64_t imx_ccm_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
IMXCCMState *s = (IMXCCMState *)opaque;
DPRINTF("read(offset=%x)", offset >> 2);
switch (offset >> 2) {
case 0: /* CCMR */
DPRINTF(" ccmr = 0x%x\n", s->ccmr);
return s->ccmr;
case 1:
DPRINTF(" pdr0 = 0x%x\n", s->pdr0);
return s->pdr0;
case 2:
DPRINTF(" pdr1 = 0x%x\n", s->pdr1);
return s->pdr1;
case 4:
DPRINTF(" mpctl = 0x%x\n", s->mpctl);
return s->mpctl;
case 6:
DPRINTF(" spctl = 0x%x\n", s->spctl);
return s->spctl;
case 8:
DPRINTF(" cgr0 = 0x%x\n", s->cgr[0]);
return s->cgr[0];
case 9:
DPRINTF(" cgr1 = 0x%x\n", s->cgr[1]);
return s->cgr[1];
case 10:
DPRINTF(" cgr2 = 0x%x\n", s->cgr[2]);
return s->cgr[2];
case 18: /* LTR1 */
return 0x00004040;
case 23:
DPRINTF(" pcmr0 = 0x%x\n", s->pmcr0);
return s->pmcr0;
}
DPRINTF(" return 0\n");
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t imx_ccm_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
IMXCCMState *s = (IMXCCMState *)opaque;
DPRINTF("read(offset=%x)", offset >> 2);
switch (offset >> 2) {
case 0:
DPRINTF(" ccmr = 0x%x\n", s->ccmr);
return s->ccmr;
case 1:
DPRINTF(" pdr0 = 0x%x\n", s->pdr0);
return s->pdr0;
case 2:
DPRINTF(" pdr1 = 0x%x\n", s->pdr1);
return s->pdr1;
case 4:
DPRINTF(" mpctl = 0x%x\n", s->mpctl);
return s->mpctl;
case 6:
DPRINTF(" spctl = 0x%x\n", s->spctl);
return s->spctl;
case 8:
DPRINTF(" cgr0 = 0x%x\n", s->cgr[0]);
return s->cgr[0];
case 9:
DPRINTF(" cgr1 = 0x%x\n", s->cgr[1]);
return s->cgr[1];
case 10:
DPRINTF(" cgr2 = 0x%x\n", s->cgr[2]);
return s->cgr[2];
case 18:
return 0x00004040;
case 23:
DPRINTF(" pcmr0 = 0x%x\n", s->pmcr0);
return s->pmcr0;
}
DPRINTF(" return 0\n");
return 0;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,
unsigned size)
{
IMXCCMState *s = (IMXCCMState *)opaque;
DPRINTF("read(offset=%x)", offset >> 2);
switch (offset >> 2) {
case 0:
DPRINTF(" ccmr = 0x%x\n", s->ccmr);
return s->ccmr;
case 1:
DPRINTF(" pdr0 = 0x%x\n", s->pdr0);
return s->pdr0;
case 2:
DPRINTF(" pdr1 = 0x%x\n", s->pdr1);
return s->pdr1;
case 4:
DPRINTF(" mpctl = 0x%x\n", s->mpctl);
return s->mpctl;
case 6:
DPRINTF(" spctl = 0x%x\n", s->spctl);
return s->spctl;
case 8:
DPRINTF(" cgr0 = 0x%x\n", s->cgr[0]);
return s->cgr[0];
case 9:
DPRINTF(" cgr1 = 0x%x\n", s->cgr[1]);
return s->cgr[1];
case 10:
DPRINTF(" cgr2 = 0x%x\n", s->cgr[2]);
return s->cgr[2];
case 18:
return 0x00004040;
case 23:
DPRINTF(" pcmr0 = 0x%x\n", s->pmcr0);
return s->pmcr0;
}
DPRINTF(" return 0\n");
return 0;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,\nunsigned size)\n{",
"IMXCCMState *s = (IMXCCMState *)opaque;",
"DPRINTF(\"read(offset=%x)\", offset >> 2);",
"switch (offset >> 2) {",
"case 0:\nDPRINTF(\" ccmr = 0x%x\\n\", s->ccmr);",
"return s->ccmr;",
"case 1:\nDPRINTF(\" pdr0 = 0x%x\\n\", s->pdr0);",
"return s->pdr0;",
"case 2:\nDPRINTF(\" pdr1 = 0x%x\\n\", s->pdr1);",
"return s->pdr1;",
"case 4:\nDPRINTF(\" mpctl = 0x%x\\n\", s->mpctl);",
"return s->mpctl;",
"case 6:\nDPRINTF(\" spctl = 0x%x\\n\", s->spctl);",
"return s->spctl;",
"case 8:\nDPRINTF(\" cgr0 = 0x%x\\n\", s->cgr[0]);",
"return s->cgr[0];",
"case 9:\nDPRINTF(\" cgr1 = 0x%x\\n\", s->cgr[1]);",
"return s->cgr[1];",
"case 10:\nDPRINTF(\" cgr2 = 0x%x\\n\", s->cgr[2]);",
"return s->cgr[2];",
"case 18:\nreturn 0x00004040;",
"case 23:\nDPRINTF(\" pcmr0 = 0x%x\\n\", s->pmcr0);",
"return s->pmcr0;",
"}",
"DPRINTF(\" return 0\\n\");",
"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
]
| [
[
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
]
]
|
10,358 | static void ne2000_receive(void *opaque, const uint8_t *buf, size_t size)
{
NE2000State *s = opaque;
uint8_t *p;
unsigned int total_len, next, avail, len, index, mcast_idx;
uint8_t buf1[60];
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
#if defined(DEBUG_NE2000)
printf("NE2000: received len=%d\n", size);
#endif
if (s->cmd & E8390_STOP || ne2000_buffer_full(s))
return;
/* XXX: check this */
if (s->rxcr & 0x10) {
/* promiscuous: receive all */
} else {
if (!memcmp(buf, broadcast_macaddr, 6)) {
/* broadcast address */
if (!(s->rxcr & 0x04))
return;
} else if (buf[0] & 0x01) {
/* multicast */
if (!(s->rxcr & 0x08))
return;
mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))))
return;
} else if (s->mem[0] == buf[0] &&
s->mem[2] == buf[1] &&
s->mem[4] == buf[2] &&
s->mem[6] == buf[3] &&
s->mem[8] == buf[4] &&
s->mem[10] == buf[5]) {
/* match */
} else {
return;
}
}
/* if too small buffer, then expand it */
if (size < MIN_BUF_SIZE) {
memcpy(buf1, buf, size);
memset(buf1 + size, 0, MIN_BUF_SIZE - size);
buf = buf1;
size = MIN_BUF_SIZE;
}
index = s->curpag << 8;
/* 4 bytes for header */
total_len = size + 4;
/* address for next packet (4 bytes for CRC) */
next = index + ((total_len + 4 + 255) & ~0xff);
if (next >= s->stop)
next -= (s->stop - s->start);
/* prepare packet header */
p = s->mem + index;
s->rsr = ENRSR_RXOK; /* receive status */
/* XXX: check this */
if (buf[0] & 0x01)
s->rsr |= ENRSR_PHY;
p[0] = s->rsr;
p[1] = next >> 8;
p[2] = total_len;
p[3] = total_len >> 8;
index += 4;
/* write packet data */
while (size > 0) {
if (index <= s->stop)
avail = s->stop - index;
else
avail = 0;
len = size;
if (len > avail)
len = avail;
memcpy(s->mem + index, buf, len);
buf += len;
index += len;
if (index == s->stop)
index = s->start;
size -= len;
}
s->curpag = next >> 8;
/* now we can signal we have received something */
s->isr |= ENISR_RX;
ne2000_update_irq(s);
}
| false | qemu | e3f5ec2b5e92706e3b807059f79b1fb5d936e567 | static void ne2000_receive(void *opaque, const uint8_t *buf, size_t size)
{
NE2000State *s = opaque;
uint8_t *p;
unsigned int total_len, next, avail, len, index, mcast_idx;
uint8_t buf1[60];
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
#if defined(DEBUG_NE2000)
printf("NE2000: received len=%d\n", size);
#endif
if (s->cmd & E8390_STOP || ne2000_buffer_full(s))
return;
if (s->rxcr & 0x10) {
} else {
if (!memcmp(buf, broadcast_macaddr, 6)) {
if (!(s->rxcr & 0x04))
return;
} else if (buf[0] & 0x01) {
if (!(s->rxcr & 0x08))
return;
mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))))
return;
} else if (s->mem[0] == buf[0] &&
s->mem[2] == buf[1] &&
s->mem[4] == buf[2] &&
s->mem[6] == buf[3] &&
s->mem[8] == buf[4] &&
s->mem[10] == buf[5]) {
} else {
return;
}
}
if (size < MIN_BUF_SIZE) {
memcpy(buf1, buf, size);
memset(buf1 + size, 0, MIN_BUF_SIZE - size);
buf = buf1;
size = MIN_BUF_SIZE;
}
index = s->curpag << 8;
total_len = size + 4;
next = index + ((total_len + 4 + 255) & ~0xff);
if (next >= s->stop)
next -= (s->stop - s->start);
p = s->mem + index;
s->rsr = ENRSR_RXOK;
if (buf[0] & 0x01)
s->rsr |= ENRSR_PHY;
p[0] = s->rsr;
p[1] = next >> 8;
p[2] = total_len;
p[3] = total_len >> 8;
index += 4;
while (size > 0) {
if (index <= s->stop)
avail = s->stop - index;
else
avail = 0;
len = size;
if (len > avail)
len = avail;
memcpy(s->mem + index, buf, len);
buf += len;
index += len;
if (index == s->stop)
index = s->start;
size -= len;
}
s->curpag = next >> 8;
s->isr |= ENISR_RX;
ne2000_update_irq(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)
{
NE2000State *s = VAR_0;
uint8_t *p;
unsigned int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
uint8_t buf1[60];
static const uint8_t VAR_9[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
#if defined(DEBUG_NE2000)
printf("NE2000: received VAR_6=%d\n", VAR_2);
#endif
if (s->cmd & E8390_STOP || ne2000_buffer_full(s))
return;
if (s->rxcr & 0x10) {
} else {
if (!memcmp(VAR_1, VAR_9, 6)) {
if (!(s->rxcr & 0x04))
return;
} else if (VAR_1[0] & 0x01) {
if (!(s->rxcr & 0x08))
return;
VAR_8 = compute_mcast_idx(VAR_1);
if (!(s->mult[VAR_8 >> 3] & (1 << (VAR_8 & 7))))
return;
} else if (s->mem[0] == VAR_1[0] &&
s->mem[2] == VAR_1[1] &&
s->mem[4] == VAR_1[2] &&
s->mem[6] == VAR_1[3] &&
s->mem[8] == VAR_1[4] &&
s->mem[10] == VAR_1[5]) {
} else {
return;
}
}
if (VAR_2 < MIN_BUF_SIZE) {
memcpy(buf1, VAR_1, VAR_2);
memset(buf1 + VAR_2, 0, MIN_BUF_SIZE - VAR_2);
VAR_1 = buf1;
VAR_2 = MIN_BUF_SIZE;
}
VAR_7 = s->curpag << 8;
VAR_3 = VAR_2 + 4;
VAR_4 = VAR_7 + ((VAR_3 + 4 + 255) & ~0xff);
if (VAR_4 >= s->stop)
VAR_4 -= (s->stop - s->start);
p = s->mem + VAR_7;
s->rsr = ENRSR_RXOK;
if (VAR_1[0] & 0x01)
s->rsr |= ENRSR_PHY;
p[0] = s->rsr;
p[1] = VAR_4 >> 8;
p[2] = VAR_3;
p[3] = VAR_3 >> 8;
VAR_7 += 4;
while (VAR_2 > 0) {
if (VAR_7 <= s->stop)
VAR_5 = s->stop - VAR_7;
else
VAR_5 = 0;
VAR_6 = VAR_2;
if (VAR_6 > VAR_5)
VAR_6 = VAR_5;
memcpy(s->mem + VAR_7, VAR_1, VAR_6);
VAR_1 += VAR_6;
VAR_7 += VAR_6;
if (VAR_7 == s->stop)
VAR_7 = s->start;
VAR_2 -= VAR_6;
}
s->curpag = VAR_4 >> 8;
s->isr |= ENISR_RX;
ne2000_update_irq(s);
}
| [
"static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)\n{",
"NE2000State *s = VAR_0;",
"uint8_t *p;",
"unsigned int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"uint8_t buf1[60];",
"static const uint8_t VAR_9[6] =\n{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };",
"#if defined(DEBUG_NE2000)\nprintf(\"NE2000: received VAR_6=%d\\n\", VAR_2);",
"#endif\nif (s->cmd & E8390_STOP || ne2000_buffer_full(s))\nreturn;",
"if (s->rxcr & 0x10) {",
"} else {",
"if (!memcmp(VAR_1, VAR_9, 6)) {",
"if (!(s->rxcr & 0x04))\nreturn;",
"} else if (VAR_1[0] & 0x01) {",
"if (!(s->rxcr & 0x08))\nreturn;",
"VAR_8 = compute_mcast_idx(VAR_1);",
"if (!(s->mult[VAR_8 >> 3] & (1 << (VAR_8 & 7))))\nreturn;",
"} else if (s->mem[0] == VAR_1[0] &&",
"s->mem[2] == VAR_1[1] &&\ns->mem[4] == VAR_1[2] &&\ns->mem[6] == VAR_1[3] &&\ns->mem[8] == VAR_1[4] &&\ns->mem[10] == VAR_1[5]) {",
"} else {",
"return;",
"}",
"}",
"if (VAR_2 < MIN_BUF_SIZE) {",
"memcpy(buf1, VAR_1, VAR_2);",
"memset(buf1 + VAR_2, 0, MIN_BUF_SIZE - VAR_2);",
"VAR_1 = buf1;",
"VAR_2 = MIN_BUF_SIZE;",
"}",
"VAR_7 = s->curpag << 8;",
"VAR_3 = VAR_2 + 4;",
"VAR_4 = VAR_7 + ((VAR_3 + 4 + 255) & ~0xff);",
"if (VAR_4 >= s->stop)\nVAR_4 -= (s->stop - s->start);",
"p = s->mem + VAR_7;",
"s->rsr = ENRSR_RXOK;",
"if (VAR_1[0] & 0x01)\ns->rsr |= ENRSR_PHY;",
"p[0] = s->rsr;",
"p[1] = VAR_4 >> 8;",
"p[2] = VAR_3;",
"p[3] = VAR_3 >> 8;",
"VAR_7 += 4;",
"while (VAR_2 > 0) {",
"if (VAR_7 <= s->stop)\nVAR_5 = s->stop - VAR_7;",
"else\nVAR_5 = 0;",
"VAR_6 = VAR_2;",
"if (VAR_6 > VAR_5)\nVAR_6 = VAR_5;",
"memcpy(s->mem + VAR_7, VAR_1, VAR_6);",
"VAR_1 += VAR_6;",
"VAR_7 += VAR_6;",
"if (VAR_7 == s->stop)\nVAR_7 = s->start;",
"VAR_2 -= VAR_6;",
"}",
"s->curpag = VAR_4 >> 8;",
"s->isr |= ENISR_RX;",
"ne2000_update_irq(s);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
27,
29
],
[
35
],
[
39
],
[
41
],
[
45,
47
],
[
49
],
[
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65,
67,
69,
71,
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
109
],
[
113
],
[
115,
117
],
[
121
],
[
123
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
145
],
[
147,
149
],
[
151,
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
181
],
[
183
],
[
185
]
]
|
10,359 | int kvm_init(void)
{
static const char upgrade_note[] =
"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
"(see http://sourceforge.net/projects/kvm).\n";
KVMState *s;
const KVMCapabilityInfo *missing_cap;
int ret;
int i;
int max_vcpus;
s = g_malloc0(sizeof(KVMState));
/*
* On systems where the kernel can support different base page
* sizes, host page size may be different from TARGET_PAGE_SIZE,
* even with KVM. TARGET_PAGE_SIZE is assumed to be the minimum
* page size for the system though.
*/
assert(TARGET_PAGE_SIZE <= getpagesize());
#ifdef KVM_CAP_SET_GUEST_DEBUG
QTAILQ_INIT(&s->kvm_sw_breakpoints);
#endif
for (i = 0; i < ARRAY_SIZE(s->slots); i++) {
s->slots[i].slot = i;
}
s->vmfd = -1;
s->fd = qemu_open("/dev/kvm", O_RDWR);
if (s->fd == -1) {
fprintf(stderr, "Could not access KVM kernel module: %m\n");
ret = -errno;
goto err;
}
ret = kvm_ioctl(s, KVM_GET_API_VERSION, 0);
if (ret < KVM_API_VERSION) {
if (ret > 0) {
ret = -EINVAL;
}
fprintf(stderr, "kvm version too old\n");
goto err;
}
if (ret > KVM_API_VERSION) {
ret = -EINVAL;
fprintf(stderr, "kvm version not supported\n");
goto err;
}
max_vcpus = kvm_max_vcpus(s);
if (smp_cpus > max_vcpus) {
ret = -EINVAL;
fprintf(stderr, "Number of SMP cpus requested (%d) exceeds max cpus "
"supported by KVM (%d)\n", smp_cpus, max_vcpus);
goto err;
}
if (max_cpus > max_vcpus) {
ret = -EINVAL;
fprintf(stderr, "Number of hotpluggable cpus requested (%d) exceeds max cpus "
"supported by KVM (%d)\n", max_cpus, max_vcpus);
goto err;
}
s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);
if (s->vmfd < 0) {
#ifdef TARGET_S390X
fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
"your host kernel command line\n");
#endif
ret = s->vmfd;
goto err;
}
missing_cap = kvm_check_extension_list(s, kvm_required_capabilites);
if (!missing_cap) {
missing_cap =
kvm_check_extension_list(s, kvm_arch_required_capabilities);
}
if (missing_cap) {
ret = -EINVAL;
fprintf(stderr, "kvm does not support %s\n%s",
missing_cap->name, upgrade_note);
goto err;
}
s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
s->broken_set_mem_region = 1;
ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
if (ret > 0) {
s->broken_set_mem_region = 0;
}
#ifdef KVM_CAP_VCPU_EVENTS
s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
#endif
s->robust_singlestep =
kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);
#ifdef KVM_CAP_DEBUGREGS
s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);
#endif
#ifdef KVM_CAP_XSAVE
s->xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
#endif
#ifdef KVM_CAP_XCRS
s->xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
#endif
#ifdef KVM_CAP_PIT_STATE2
s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
#endif
#ifdef KVM_CAP_IRQ_ROUTING
s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
#endif
s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);
s->irq_set_ioctl = KVM_IRQ_LINE;
if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
s->irq_set_ioctl = KVM_IRQ_LINE_STATUS;
}
#ifdef KVM_CAP_READONLY_MEM
kvm_readonly_mem_allowed =
(kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
#endif
ret = kvm_arch_init(s);
if (ret < 0) {
goto err;
}
ret = kvm_irqchip_create(s);
if (ret < 0) {
goto err;
}
kvm_state = s;
memory_listener_register(&kvm_memory_listener, &address_space_memory);
memory_listener_register(&kvm_io_listener, &address_space_io);
s->many_ioeventfds = kvm_check_many_ioeventfds();
cpu_interrupt_handler = kvm_handle_interrupt;
return 0;
err:
if (s->vmfd >= 0) {
close(s->vmfd);
}
if (s->fd != -1) {
close(s->fd);
}
g_free(s);
return ret;
}
| false | qemu | 670436ced08738802e15764039d03ab0dbab2bf3 | int kvm_init(void)
{
static const char upgrade_note[] =
"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
"(see http:
KVMState *s;
const KVMCapabilityInfo *missing_cap;
int ret;
int i;
int max_vcpus;
s = g_malloc0(sizeof(KVMState));
assert(TARGET_PAGE_SIZE <= getpagesize());
#ifdef KVM_CAP_SET_GUEST_DEBUG
QTAILQ_INIT(&s->kvm_sw_breakpoints);
#endif
for (i = 0; i < ARRAY_SIZE(s->slots); i++) {
s->slots[i].slot = i;
}
s->vmfd = -1;
s->fd = qemu_open("/dev/kvm", O_RDWR);
if (s->fd == -1) {
fprintf(stderr, "Could not access KVM kernel module: %m\n");
ret = -errno;
goto err;
}
ret = kvm_ioctl(s, KVM_GET_API_VERSION, 0);
if (ret < KVM_API_VERSION) {
if (ret > 0) {
ret = -EINVAL;
}
fprintf(stderr, "kvm version too old\n");
goto err;
}
if (ret > KVM_API_VERSION) {
ret = -EINVAL;
fprintf(stderr, "kvm version not supported\n");
goto err;
}
max_vcpus = kvm_max_vcpus(s);
if (smp_cpus > max_vcpus) {
ret = -EINVAL;
fprintf(stderr, "Number of SMP cpus requested (%d) exceeds max cpus "
"supported by KVM (%d)\n", smp_cpus, max_vcpus);
goto err;
}
if (max_cpus > max_vcpus) {
ret = -EINVAL;
fprintf(stderr, "Number of hotpluggable cpus requested (%d) exceeds max cpus "
"supported by KVM (%d)\n", max_cpus, max_vcpus);
goto err;
}
s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);
if (s->vmfd < 0) {
#ifdef TARGET_S390X
fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
"your host kernel command line\n");
#endif
ret = s->vmfd;
goto err;
}
missing_cap = kvm_check_extension_list(s, kvm_required_capabilites);
if (!missing_cap) {
missing_cap =
kvm_check_extension_list(s, kvm_arch_required_capabilities);
}
if (missing_cap) {
ret = -EINVAL;
fprintf(stderr, "kvm does not support %s\n%s",
missing_cap->name, upgrade_note);
goto err;
}
s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
s->broken_set_mem_region = 1;
ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
if (ret > 0) {
s->broken_set_mem_region = 0;
}
#ifdef KVM_CAP_VCPU_EVENTS
s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
#endif
s->robust_singlestep =
kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);
#ifdef KVM_CAP_DEBUGREGS
s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);
#endif
#ifdef KVM_CAP_XSAVE
s->xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
#endif
#ifdef KVM_CAP_XCRS
s->xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
#endif
#ifdef KVM_CAP_PIT_STATE2
s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
#endif
#ifdef KVM_CAP_IRQ_ROUTING
s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
#endif
s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);
s->irq_set_ioctl = KVM_IRQ_LINE;
if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
s->irq_set_ioctl = KVM_IRQ_LINE_STATUS;
}
#ifdef KVM_CAP_READONLY_MEM
kvm_readonly_mem_allowed =
(kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
#endif
ret = kvm_arch_init(s);
if (ret < 0) {
goto err;
}
ret = kvm_irqchip_create(s);
if (ret < 0) {
goto err;
}
kvm_state = s;
memory_listener_register(&kvm_memory_listener, &address_space_memory);
memory_listener_register(&kvm_io_listener, &address_space_io);
s->many_ioeventfds = kvm_check_many_ioeventfds();
cpu_interrupt_handler = kvm_handle_interrupt;
return 0;
err:
if (s->vmfd >= 0) {
close(s->vmfd);
}
if (s->fd != -1) {
close(s->fd);
}
g_free(s);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void)
{
static const char VAR_0[] =
"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
"(see http:
KVMState *s;
const KVMCapabilityInfo *VAR_1;
int VAR_2;
int VAR_3;
int VAR_4;
s = g_malloc0(sizeof(KVMState));
assert(TARGET_PAGE_SIZE <= getpagesize());
#ifdef KVM_CAP_SET_GUEST_DEBUG
QTAILQ_INIT(&s->kvm_sw_breakpoints);
#endif
for (VAR_3 = 0; VAR_3 < ARRAY_SIZE(s->slots); VAR_3++) {
s->slots[VAR_3].slot = VAR_3;
}
s->vmfd = -1;
s->fd = qemu_open("/dev/kvm", O_RDWR);
if (s->fd == -1) {
fprintf(stderr, "Could not access KVM kernel module: %m\n");
VAR_2 = -errno;
goto err;
}
VAR_2 = kvm_ioctl(s, KVM_GET_API_VERSION, 0);
if (VAR_2 < KVM_API_VERSION) {
if (VAR_2 > 0) {
VAR_2 = -EINVAL;
}
fprintf(stderr, "kvm version too old\n");
goto err;
}
if (VAR_2 > KVM_API_VERSION) {
VAR_2 = -EINVAL;
fprintf(stderr, "kvm version not supported\n");
goto err;
}
VAR_4 = kvm_max_vcpus(s);
if (smp_cpus > VAR_4) {
VAR_2 = -EINVAL;
fprintf(stderr, "Number of SMP cpus requested (%d) exceeds max cpus "
"supported by KVM (%d)\n", smp_cpus, VAR_4);
goto err;
}
if (max_cpus > VAR_4) {
VAR_2 = -EINVAL;
fprintf(stderr, "Number of hotpluggable cpus requested (%d) exceeds max cpus "
"supported by KVM (%d)\n", max_cpus, VAR_4);
goto err;
}
s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);
if (s->vmfd < 0) {
#ifdef TARGET_S390X
fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
"your host kernel command line\n");
#endif
VAR_2 = s->vmfd;
goto err;
}
VAR_1 = kvm_check_extension_list(s, kvm_required_capabilites);
if (!VAR_1) {
VAR_1 =
kvm_check_extension_list(s, kvm_arch_required_capabilities);
}
if (VAR_1) {
VAR_2 = -EINVAL;
fprintf(stderr, "kvm does not support %s\n%s",
VAR_1->name, VAR_0);
goto err;
}
s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
s->broken_set_mem_region = 1;
VAR_2 = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
if (VAR_2 > 0) {
s->broken_set_mem_region = 0;
}
#ifdef KVM_CAP_VCPU_EVENTS
s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
#endif
s->robust_singlestep =
kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);
#ifdef KVM_CAP_DEBUGREGS
s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);
#endif
#ifdef KVM_CAP_XSAVE
s->xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
#endif
#ifdef KVM_CAP_XCRS
s->xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
#endif
#ifdef KVM_CAP_PIT_STATE2
s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
#endif
#ifdef KVM_CAP_IRQ_ROUTING
s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
#endif
s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);
s->irq_set_ioctl = KVM_IRQ_LINE;
if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
s->irq_set_ioctl = KVM_IRQ_LINE_STATUS;
}
#ifdef KVM_CAP_READONLY_MEM
kvm_readonly_mem_allowed =
(kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
#endif
VAR_2 = kvm_arch_init(s);
if (VAR_2 < 0) {
goto err;
}
VAR_2 = kvm_irqchip_create(s);
if (VAR_2 < 0) {
goto err;
}
kvm_state = s;
memory_listener_register(&kvm_memory_listener, &address_space_memory);
memory_listener_register(&kvm_io_listener, &address_space_io);
s->many_ioeventfds = kvm_check_many_ioeventfds();
cpu_interrupt_handler = kvm_handle_interrupt;
return 0;
err:
if (s->vmfd >= 0) {
close(s->vmfd);
}
if (s->fd != -1) {
close(s->fd);
}
g_free(s);
return VAR_2;
}
| [
"int FUNC_0(void)\n{",
"static const char VAR_0[] =\n\"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\\n\"\n\"(see http:\nKVMState *s;",
"const KVMCapabilityInfo *VAR_1;",
"int VAR_2;",
"int VAR_3;",
"int VAR_4;",
"s = g_malloc0(sizeof(KVMState));",
"assert(TARGET_PAGE_SIZE <= getpagesize());",
"#ifdef KVM_CAP_SET_GUEST_DEBUG\nQTAILQ_INIT(&s->kvm_sw_breakpoints);",
"#endif\nfor (VAR_3 = 0; VAR_3 < ARRAY_SIZE(s->slots); VAR_3++) {",
"s->slots[VAR_3].slot = VAR_3;",
"}",
"s->vmfd = -1;",
"s->fd = qemu_open(\"/dev/kvm\", O_RDWR);",
"if (s->fd == -1) {",
"fprintf(stderr, \"Could not access KVM kernel module: %m\\n\");",
"VAR_2 = -errno;",
"goto err;",
"}",
"VAR_2 = kvm_ioctl(s, KVM_GET_API_VERSION, 0);",
"if (VAR_2 < KVM_API_VERSION) {",
"if (VAR_2 > 0) {",
"VAR_2 = -EINVAL;",
"}",
"fprintf(stderr, \"kvm version too old\\n\");",
"goto err;",
"}",
"if (VAR_2 > KVM_API_VERSION) {",
"VAR_2 = -EINVAL;",
"fprintf(stderr, \"kvm version not supported\\n\");",
"goto err;",
"}",
"VAR_4 = kvm_max_vcpus(s);",
"if (smp_cpus > VAR_4) {",
"VAR_2 = -EINVAL;",
"fprintf(stderr, \"Number of SMP cpus requested (%d) exceeds max cpus \"\n\"supported by KVM (%d)\\n\", smp_cpus, VAR_4);",
"goto err;",
"}",
"if (max_cpus > VAR_4) {",
"VAR_2 = -EINVAL;",
"fprintf(stderr, \"Number of hotpluggable cpus requested (%d) exceeds max cpus \"\n\"supported by KVM (%d)\\n\", max_cpus, VAR_4);",
"goto err;",
"}",
"s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);",
"if (s->vmfd < 0) {",
"#ifdef TARGET_S390X\nfprintf(stderr, \"Please add the 'switch_amode' kernel parameter to \"\n\"your host kernel command line\\n\");",
"#endif\nVAR_2 = s->vmfd;",
"goto err;",
"}",
"VAR_1 = kvm_check_extension_list(s, kvm_required_capabilites);",
"if (!VAR_1) {",
"VAR_1 =\nkvm_check_extension_list(s, kvm_arch_required_capabilities);",
"}",
"if (VAR_1) {",
"VAR_2 = -EINVAL;",
"fprintf(stderr, \"kvm does not support %s\\n%s\",\nVAR_1->name, VAR_0);",
"goto err;",
"}",
"s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);",
"s->broken_set_mem_region = 1;",
"VAR_2 = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);",
"if (VAR_2 > 0) {",
"s->broken_set_mem_region = 0;",
"}",
"#ifdef KVM_CAP_VCPU_EVENTS\ns->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);",
"#endif\ns->robust_singlestep =\nkvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);",
"#ifdef KVM_CAP_DEBUGREGS\ns->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);",
"#endif\n#ifdef KVM_CAP_XSAVE\ns->xsave = kvm_check_extension(s, KVM_CAP_XSAVE);",
"#endif\n#ifdef KVM_CAP_XCRS\ns->xcrs = kvm_check_extension(s, KVM_CAP_XCRS);",
"#endif\n#ifdef KVM_CAP_PIT_STATE2\ns->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);",
"#endif\n#ifdef KVM_CAP_IRQ_ROUTING\ns->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);",
"#endif\ns->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);",
"s->irq_set_ioctl = KVM_IRQ_LINE;",
"if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {",
"s->irq_set_ioctl = KVM_IRQ_LINE_STATUS;",
"}",
"#ifdef KVM_CAP_READONLY_MEM\nkvm_readonly_mem_allowed =\n(kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);",
"#endif\nVAR_2 = kvm_arch_init(s);",
"if (VAR_2 < 0) {",
"goto err;",
"}",
"VAR_2 = kvm_irqchip_create(s);",
"if (VAR_2 < 0) {",
"goto err;",
"}",
"kvm_state = s;",
"memory_listener_register(&kvm_memory_listener, &address_space_memory);",
"memory_listener_register(&kvm_io_listener, &address_space_io);",
"s->many_ioeventfds = kvm_check_many_ioeventfds();",
"cpu_interrupt_handler = kvm_handle_interrupt;",
"return 0;",
"err:\nif (s->vmfd >= 0) {",
"close(s->vmfd);",
"}",
"if (s->fd != -1) {",
"close(s->fd);",
"}",
"g_free(s);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23
],
[
39
],
[
43,
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135,
137,
139
],
[
141,
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191,
193
],
[
195,
199,
201
],
[
205,
207
],
[
209,
213,
215
],
[
217,
221,
223
],
[
225,
229,
231
],
[
233,
237,
239
],
[
241,
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
259,
261,
263
],
[
265,
269
],
[
271
],
[
273
],
[
275
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
297
],
[
301
],
[
305
],
[
309,
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
327
],
[
329
]
]
|
10,360 | static int mov_open_dref(AVIOContext **pb, char *src, MOVDref *ref,
AVIOInterruptCB *int_cb)
{
/* try relative path, we do not try the absolute because it can leak information about our
system to an attacker */
if (ref->nlvl_to > 0 && ref->nlvl_from > 0) {
char filename[1024];
char *src_path;
int i, l;
/* find a source dir */
src_path = strrchr(src, '/');
if (src_path)
src_path++;
else
src_path = src;
/* find a next level down to target */
for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--)
if (ref->path[l] == '/') {
if (i == ref->nlvl_to - 1)
break;
else
i++;
}
/* compose filename if next level down to target was found */
if (i == ref->nlvl_to - 1 && src_path - src < sizeof(filename)) {
memcpy(filename, src, src_path - src);
filename[src_path - src] = 0;
for (i = 1; i < ref->nlvl_from; i++)
av_strlcat(filename, "../", 1024);
av_strlcat(filename, ref->path + l + 1, 1024);
if (!avio_open2(pb, filename, AVIO_FLAG_READ, int_cb, NULL))
return 0;
}
}
return AVERROR(ENOENT);
}
| false | FFmpeg | 9286de045968ad456d4e752651eec22de5e89060 | static int mov_open_dref(AVIOContext **pb, char *src, MOVDref *ref,
AVIOInterruptCB *int_cb)
{
if (ref->nlvl_to > 0 && ref->nlvl_from > 0) {
char filename[1024];
char *src_path;
int i, l;
src_path = strrchr(src, '/');
if (src_path)
src_path++;
else
src_path = src;
for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--)
if (ref->path[l] == '/') {
if (i == ref->nlvl_to - 1)
break;
else
i++;
}
if (i == ref->nlvl_to - 1 && src_path - src < sizeof(filename)) {
memcpy(filename, src, src_path - src);
filename[src_path - src] = 0;
for (i = 1; i < ref->nlvl_from; i++)
av_strlcat(filename, "../", 1024);
av_strlcat(filename, ref->path + l + 1, 1024);
if (!avio_open2(pb, filename, AVIO_FLAG_READ, int_cb, NULL))
return 0;
}
}
return AVERROR(ENOENT);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVIOContext **VAR_0, char *VAR_1, MOVDref *VAR_2,
AVIOInterruptCB *VAR_3)
{
if (VAR_2->nlvl_to > 0 && VAR_2->nlvl_from > 0) {
char VAR_4[1024];
char *VAR_5;
int VAR_6, VAR_7;
VAR_5 = strrchr(VAR_1, '/');
if (VAR_5)
VAR_5++;
else
VAR_5 = VAR_1;
for (VAR_6 = 0, VAR_7 = strlen(VAR_2->path) - 1; VAR_7 >= 0; VAR_7--)
if (VAR_2->path[VAR_7] == '/') {
if (VAR_6 == VAR_2->nlvl_to - 1)
break;
else
VAR_6++;
}
if (VAR_6 == VAR_2->nlvl_to - 1 && VAR_5 - VAR_1 < sizeof(VAR_4)) {
memcpy(VAR_4, VAR_1, VAR_5 - VAR_1);
VAR_4[VAR_5 - VAR_1] = 0;
for (VAR_6 = 1; VAR_6 < VAR_2->nlvl_from; VAR_6++)
av_strlcat(VAR_4, "../", 1024);
av_strlcat(VAR_4, VAR_2->path + VAR_7 + 1, 1024);
if (!avio_open2(VAR_0, VAR_4, AVIO_FLAG_READ, VAR_3, NULL))
return 0;
}
}
return AVERROR(ENOENT);
}
| [
"static int FUNC_0(AVIOContext **VAR_0, char *VAR_1, MOVDref *VAR_2,\nAVIOInterruptCB *VAR_3)\n{",
"if (VAR_2->nlvl_to > 0 && VAR_2->nlvl_from > 0) {",
"char VAR_4[1024];",
"char *VAR_5;",
"int VAR_6, VAR_7;",
"VAR_5 = strrchr(VAR_1, '/');",
"if (VAR_5)\nVAR_5++;",
"else\nVAR_5 = VAR_1;",
"for (VAR_6 = 0, VAR_7 = strlen(VAR_2->path) - 1; VAR_7 >= 0; VAR_7--)",
"if (VAR_2->path[VAR_7] == '/') {",
"if (VAR_6 == VAR_2->nlvl_to - 1)\nbreak;",
"else\nVAR_6++;",
"}",
"if (VAR_6 == VAR_2->nlvl_to - 1 && VAR_5 - VAR_1 < sizeof(VAR_4)) {",
"memcpy(VAR_4, VAR_1, VAR_5 - VAR_1);",
"VAR_4[VAR_5 - VAR_1] = 0;",
"for (VAR_6 = 1; VAR_6 < VAR_2->nlvl_from; VAR_6++)",
"av_strlcat(VAR_4, \"../\", 1024);",
"av_strlcat(VAR_4, VAR_2->path + VAR_7 + 1, 1024);",
"if (!avio_open2(VAR_0, VAR_4, AVIO_FLAG_READ, VAR_3, NULL))\nreturn 0;",
"}",
"}",
"return AVERROR(ENOENT);",
"}"
]
| [
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
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25,
27
],
[
29,
31
],
[
37
],
[
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
73,
75
],
[
77
],
[
79
],
[
83
],
[
85
]
]
|
10,361 | static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
uint64_t asc, uint64_t asce, int level,
target_ulong *raddr, int *flags, int rw)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
uint64_t offs = 0;
uint64_t origin;
uint64_t new_asce;
PTE_DPRINTF("%s: 0x%" PRIx64 "\n", __func__, asce);
if (((level != _ASCE_TYPE_SEGMENT) && (asce & _REGION_ENTRY_INV)) ||
((level == _ASCE_TYPE_SEGMENT) && (asce & _SEGMENT_ENTRY_INV))) {
/* XXX different regions have different faults */
DPRINTF("%s: invalid region\n", __func__);
trigger_page_fault(env, vaddr, PGM_SEGMENT_TRANS, asc, rw);
return -1;
}
if ((level <= _ASCE_TYPE_MASK) && ((asce & _ASCE_TYPE_MASK) != level)) {
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
if (asce & _ASCE_REAL_SPACE) {
/* direct mapping */
*raddr = vaddr;
return 0;
}
origin = asce & _ASCE_ORIGIN;
switch (level) {
case _ASCE_TYPE_REGION1 + 4:
offs = (vaddr >> 50) & 0x3ff8;
break;
case _ASCE_TYPE_REGION1:
offs = (vaddr >> 39) & 0x3ff8;
break;
case _ASCE_TYPE_REGION2:
offs = (vaddr >> 28) & 0x3ff8;
break;
case _ASCE_TYPE_REGION3:
offs = (vaddr >> 17) & 0x3ff8;
break;
case _ASCE_TYPE_SEGMENT:
offs = (vaddr >> 9) & 0x07f8;
origin = asce & _SEGMENT_ENTRY_ORIGIN;
break;
}
/* XXX region protection flags */
/* *flags &= ~PAGE_WRITE */
new_asce = ldq_phys(cs->as, origin + offs);
PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n",
__func__, origin, offs, new_asce);
if (level == _ASCE_TYPE_SEGMENT) {
/* 4KB page */
return mmu_translate_pte(env, vaddr, asc, new_asce, raddr, flags, rw);
} else if (level - 4 == _ASCE_TYPE_SEGMENT &&
(new_asce & _SEGMENT_ENTRY_FC) && (env->cregs[0] & CR0_EDAT)) {
/* 1MB page */
return mmu_translate_sfaa(env, vaddr, asc, new_asce, raddr, flags, rw);
} else {
/* yet another region */
return mmu_translate_asce(env, vaddr, asc, new_asce, level - 4, raddr,
flags, rw);
}
}
| false | qemu | 89a41e0a37f3c749f3038ac2544f74257bc7b94d | static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
uint64_t asc, uint64_t asce, int level,
target_ulong *raddr, int *flags, int rw)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
uint64_t offs = 0;
uint64_t origin;
uint64_t new_asce;
PTE_DPRINTF("%s: 0x%" PRIx64 "\n", __func__, asce);
if (((level != _ASCE_TYPE_SEGMENT) && (asce & _REGION_ENTRY_INV)) ||
((level == _ASCE_TYPE_SEGMENT) && (asce & _SEGMENT_ENTRY_INV))) {
DPRINTF("%s: invalid region\n", __func__);
trigger_page_fault(env, vaddr, PGM_SEGMENT_TRANS, asc, rw);
return -1;
}
if ((level <= _ASCE_TYPE_MASK) && ((asce & _ASCE_TYPE_MASK) != level)) {
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
if (asce & _ASCE_REAL_SPACE) {
*raddr = vaddr;
return 0;
}
origin = asce & _ASCE_ORIGIN;
switch (level) {
case _ASCE_TYPE_REGION1 + 4:
offs = (vaddr >> 50) & 0x3ff8;
break;
case _ASCE_TYPE_REGION1:
offs = (vaddr >> 39) & 0x3ff8;
break;
case _ASCE_TYPE_REGION2:
offs = (vaddr >> 28) & 0x3ff8;
break;
case _ASCE_TYPE_REGION3:
offs = (vaddr >> 17) & 0x3ff8;
break;
case _ASCE_TYPE_SEGMENT:
offs = (vaddr >> 9) & 0x07f8;
origin = asce & _SEGMENT_ENTRY_ORIGIN;
break;
}
new_asce = ldq_phys(cs->as, origin + offs);
PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n",
__func__, origin, offs, new_asce);
if (level == _ASCE_TYPE_SEGMENT) {
return mmu_translate_pte(env, vaddr, asc, new_asce, raddr, flags, rw);
} else if (level - 4 == _ASCE_TYPE_SEGMENT &&
(new_asce & _SEGMENT_ENTRY_FC) && (env->cregs[0] & CR0_EDAT)) {
return mmu_translate_sfaa(env, vaddr, asc, new_asce, raddr, flags, rw);
} else {
return mmu_translate_asce(env, vaddr, asc, new_asce, level - 4, raddr,
flags, rw);
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CPUS390XState *VAR_0, target_ulong VAR_1,
uint64_t VAR_2, uint64_t VAR_3, int VAR_4,
target_ulong *VAR_5, int *VAR_6, int VAR_7)
{
CPUState *cs = CPU(s390_env_get_cpu(VAR_0));
uint64_t offs = 0;
uint64_t origin;
uint64_t new_asce;
PTE_DPRINTF("%s: 0x%" PRIx64 "\n", __func__, VAR_3);
if (((VAR_4 != _ASCE_TYPE_SEGMENT) && (VAR_3 & _REGION_ENTRY_INV)) ||
((VAR_4 == _ASCE_TYPE_SEGMENT) && (VAR_3 & _SEGMENT_ENTRY_INV))) {
DPRINTF("%s: invalid region\n", __func__);
trigger_page_fault(VAR_0, VAR_1, PGM_SEGMENT_TRANS, VAR_2, VAR_7);
return -1;
}
if ((VAR_4 <= _ASCE_TYPE_MASK) && ((VAR_3 & _ASCE_TYPE_MASK) != VAR_4)) {
trigger_page_fault(VAR_0, VAR_1, PGM_TRANS_SPEC, VAR_2, VAR_7);
return -1;
}
if (VAR_3 & _ASCE_REAL_SPACE) {
*VAR_5 = VAR_1;
return 0;
}
origin = VAR_3 & _ASCE_ORIGIN;
switch (VAR_4) {
case _ASCE_TYPE_REGION1 + 4:
offs = (VAR_1 >> 50) & 0x3ff8;
break;
case _ASCE_TYPE_REGION1:
offs = (VAR_1 >> 39) & 0x3ff8;
break;
case _ASCE_TYPE_REGION2:
offs = (VAR_1 >> 28) & 0x3ff8;
break;
case _ASCE_TYPE_REGION3:
offs = (VAR_1 >> 17) & 0x3ff8;
break;
case _ASCE_TYPE_SEGMENT:
offs = (VAR_1 >> 9) & 0x07f8;
origin = VAR_3 & _SEGMENT_ENTRY_ORIGIN;
break;
}
new_asce = ldq_phys(cs->as, origin + offs);
PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n",
__func__, origin, offs, new_asce);
if (VAR_4 == _ASCE_TYPE_SEGMENT) {
return mmu_translate_pte(VAR_0, VAR_1, VAR_2, new_asce, VAR_5, VAR_6, VAR_7);
} else if (VAR_4 - 4 == _ASCE_TYPE_SEGMENT &&
(new_asce & _SEGMENT_ENTRY_FC) && (VAR_0->cregs[0] & CR0_EDAT)) {
return mmu_translate_sfaa(VAR_0, VAR_1, VAR_2, new_asce, VAR_5, VAR_6, VAR_7);
} else {
return FUNC_0(VAR_0, VAR_1, VAR_2, new_asce, VAR_4 - 4, VAR_5,
VAR_6, VAR_7);
}
}
| [
"static int FUNC_0(CPUS390XState *VAR_0, target_ulong VAR_1,\nuint64_t VAR_2, uint64_t VAR_3, int VAR_4,\ntarget_ulong *VAR_5, int *VAR_6, int VAR_7)\n{",
"CPUState *cs = CPU(s390_env_get_cpu(VAR_0));",
"uint64_t offs = 0;",
"uint64_t origin;",
"uint64_t new_asce;",
"PTE_DPRINTF(\"%s: 0x%\" PRIx64 \"\\n\", __func__, VAR_3);",
"if (((VAR_4 != _ASCE_TYPE_SEGMENT) && (VAR_3 & _REGION_ENTRY_INV)) ||\n((VAR_4 == _ASCE_TYPE_SEGMENT) && (VAR_3 & _SEGMENT_ENTRY_INV))) {",
"DPRINTF(\"%s: invalid region\\n\", __func__);",
"trigger_page_fault(VAR_0, VAR_1, PGM_SEGMENT_TRANS, VAR_2, VAR_7);",
"return -1;",
"}",
"if ((VAR_4 <= _ASCE_TYPE_MASK) && ((VAR_3 & _ASCE_TYPE_MASK) != VAR_4)) {",
"trigger_page_fault(VAR_0, VAR_1, PGM_TRANS_SPEC, VAR_2, VAR_7);",
"return -1;",
"}",
"if (VAR_3 & _ASCE_REAL_SPACE) {",
"*VAR_5 = VAR_1;",
"return 0;",
"}",
"origin = VAR_3 & _ASCE_ORIGIN;",
"switch (VAR_4) {",
"case _ASCE_TYPE_REGION1 + 4:\noffs = (VAR_1 >> 50) & 0x3ff8;",
"break;",
"case _ASCE_TYPE_REGION1:\noffs = (VAR_1 >> 39) & 0x3ff8;",
"break;",
"case _ASCE_TYPE_REGION2:\noffs = (VAR_1 >> 28) & 0x3ff8;",
"break;",
"case _ASCE_TYPE_REGION3:\noffs = (VAR_1 >> 17) & 0x3ff8;",
"break;",
"case _ASCE_TYPE_SEGMENT:\noffs = (VAR_1 >> 9) & 0x07f8;",
"origin = VAR_3 & _SEGMENT_ENTRY_ORIGIN;",
"break;",
"}",
"new_asce = ldq_phys(cs->as, origin + offs);",
"PTE_DPRINTF(\"%s: 0x%\" PRIx64 \" + 0x%\" PRIx64 \" => 0x%016\" PRIx64 \"\\n\",\n__func__, origin, offs, new_asce);",
"if (VAR_4 == _ASCE_TYPE_SEGMENT) {",
"return mmu_translate_pte(VAR_0, VAR_1, VAR_2, new_asce, VAR_5, VAR_6, VAR_7);",
"} else if (VAR_4 - 4 == _ASCE_TYPE_SEGMENT &&",
"(new_asce & _SEGMENT_ENTRY_FC) && (VAR_0->cregs[0] & CR0_EDAT)) {",
"return mmu_translate_sfaa(VAR_0, VAR_1, VAR_2, new_asce, VAR_5, VAR_6, VAR_7);",
"} else {",
"return FUNC_0(VAR_0, VAR_1, VAR_2, new_asce, VAR_4 - 4, VAR_5,\nVAR_6, 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,
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
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69,
71
],
[
73
],
[
75,
77
],
[
79
],
[
81,
83
],
[
85
],
[
87,
89
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
111
],
[
113,
115
],
[
119
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
137,
139
],
[
141
],
[
143
]
]
|
10,362 | bool iommu_dma_memory_valid(DMAContext *dma, dma_addr_t addr, dma_addr_t len,
DMADirection dir)
{
target_phys_addr_t paddr, plen;
#ifdef DEBUG_IOMMU
fprintf(stderr, "dma_memory_check context=%p addr=0x" DMA_ADDR_FMT
" len=0x" DMA_ADDR_FMT " dir=%d\n", dma, addr, len, dir);
#endif
while (len) {
if (dma->translate(dma, addr, &paddr, &plen, dir) != 0) {
return false;
}
/* The translation might be valid for larger regions. */
if (plen > len) {
plen = len;
}
len -= plen;
addr += plen;
}
return true;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | bool iommu_dma_memory_valid(DMAContext *dma, dma_addr_t addr, dma_addr_t len,
DMADirection dir)
{
target_phys_addr_t paddr, plen;
#ifdef DEBUG_IOMMU
fprintf(stderr, "dma_memory_check context=%p addr=0x" DMA_ADDR_FMT
" len=0x" DMA_ADDR_FMT " dir=%d\n", dma, addr, len, dir);
#endif
while (len) {
if (dma->translate(dma, addr, &paddr, &plen, dir) != 0) {
return false;
}
if (plen > len) {
plen = len;
}
len -= plen;
addr += plen;
}
return true;
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(DMAContext *dma, dma_addr_t addr, dma_addr_t len,
DMADirection dir)
{
target_phys_addr_t paddr, plen;
#ifdef DEBUG_IOMMU
fprintf(stderr, "dma_memory_check context=%p addr=0x" DMA_ADDR_FMT
" len=0x" DMA_ADDR_FMT " dir=%d\n", dma, addr, len, dir);
#endif
while (len) {
if (dma->translate(dma, addr, &paddr, &plen, dir) != 0) {
return false;
}
if (plen > len) {
plen = len;
}
len -= plen;
addr += plen;
}
return true;
}
| [
"bool FUNC_0(DMAContext *dma, dma_addr_t addr, dma_addr_t len,\nDMADirection dir)\n{",
"target_phys_addr_t paddr, plen;",
"#ifdef DEBUG_IOMMU\nfprintf(stderr, \"dma_memory_check context=%p addr=0x\" DMA_ADDR_FMT\n\" len=0x\" DMA_ADDR_FMT \" dir=%d\\n\", dma, addr, len, dir);",
"#endif\nwhile (len) {",
"if (dma->translate(dma, addr, &paddr, &plen, dir) != 0) {",
"return false;",
"}",
"if (plen > len) {",
"plen = len;",
"}",
"len -= plen;",
"addr += plen;",
"}",
"return true;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11,
13,
15
],
[
17,
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
]
]
|
10,363 | static void tm_put(QEMUFile *f, struct tm *tm) {
qemu_put_be16(f, tm->tm_sec);
qemu_put_be16(f, tm->tm_min);
qemu_put_be16(f, tm->tm_hour);
qemu_put_be16(f, tm->tm_mday);
qemu_put_be16(f, tm->tm_min);
qemu_put_be16(f, tm->tm_year);
}
| false | qemu | f0495f56c9f4574140c392bdbad42721ba692d19 | static void tm_put(QEMUFile *f, struct tm *tm) {
qemu_put_be16(f, tm->tm_sec);
qemu_put_be16(f, tm->tm_min);
qemu_put_be16(f, tm->tm_hour);
qemu_put_be16(f, tm->tm_mday);
qemu_put_be16(f, tm->tm_min);
qemu_put_be16(f, tm->tm_year);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QEMUFile *VAR_0, struct VAR_1 *VAR_1) {
qemu_put_be16(VAR_0, VAR_1->tm_sec);
qemu_put_be16(VAR_0, VAR_1->tm_min);
qemu_put_be16(VAR_0, VAR_1->tm_hour);
qemu_put_be16(VAR_0, VAR_1->tm_mday);
qemu_put_be16(VAR_0, VAR_1->tm_min);
qemu_put_be16(VAR_0, VAR_1->tm_year);
}
| [
"static void FUNC_0(QEMUFile *VAR_0, struct VAR_1 *VAR_1) {",
"qemu_put_be16(VAR_0, VAR_1->tm_sec);",
"qemu_put_be16(VAR_0, VAR_1->tm_min);",
"qemu_put_be16(VAR_0, VAR_1->tm_hour);",
"qemu_put_be16(VAR_0, VAR_1->tm_mday);",
"qemu_put_be16(VAR_0, VAR_1->tm_min);",
"qemu_put_be16(VAR_0, VAR_1->tm_year);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
]
|
10,365 | uint64_t helper_fsqrt(CPUPPCState *env, uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
/* Square root of a negative nonzero number */
farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT);
} else {
if (unlikely(float64_is_signaling_nan(farg.d))) {
/* sNaN square root */
fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN);
}
farg.d = float64_sqrt(farg.d, &env->fp_status);
}
return farg.ll;
}
| false | qemu | 59800ec8e52bcfa271fa61fb0aae19205ef1b7f1 | uint64_t helper_fsqrt(CPUPPCState *env, uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT);
} else {
if (unlikely(float64_is_signaling_nan(farg.d))) {
fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN);
}
farg.d = float64_sqrt(farg.d, &env->fp_status);
}
return farg.ll;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0(CPUPPCState *env, uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT);
} else {
if (unlikely(float64_is_signaling_nan(farg.d))) {
fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN);
}
farg.d = float64_sqrt(farg.d, &env->fp_status);
}
return farg.ll;
}
| [
"uint64_t FUNC_0(CPUPPCState *env, uint64_t arg)\n{",
"CPU_DoubleU farg;",
"farg.ll = arg;",
"if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {",
"farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT);",
"} else {",
"if (unlikely(float64_is_signaling_nan(farg.d))) {",
"fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN);",
"}",
"farg.d = float64_sqrt(farg.d, &env->fp_status);",
"}",
"return farg.ll;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
]
|
10,366 | static int kvm_handle_internal_error(CPUState *env, struct kvm_run *run)
{
fprintf(stderr, "KVM internal error.");
if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) {
int i;
fprintf(stderr, " Suberror: %d\n", run->internal.suberror);
for (i = 0; i < run->internal.ndata; ++i) {
fprintf(stderr, "extra data[%d]: %"PRIx64"\n",
i, (uint64_t)run->internal.data[i]);
}
} else {
fprintf(stderr, "\n");
}
if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) {
fprintf(stderr, "emulation failure\n");
if (!kvm_arch_stop_on_emulation_error(env)) {
cpu_dump_state(env, stderr, fprintf, CPU_DUMP_CODE);
return 0;
}
}
/* FIXME: Should trigger a qmp message to let management know
* something went wrong.
*/
return -1;
}
| false | qemu | d73cd8f4ea1c2944bd16f7a1c445eaa25c9e6e26 | static int kvm_handle_internal_error(CPUState *env, struct kvm_run *run)
{
fprintf(stderr, "KVM internal error.");
if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) {
int i;
fprintf(stderr, " Suberror: %d\n", run->internal.suberror);
for (i = 0; i < run->internal.ndata; ++i) {
fprintf(stderr, "extra data[%d]: %"PRIx64"\n",
i, (uint64_t)run->internal.data[i]);
}
} else {
fprintf(stderr, "\n");
}
if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) {
fprintf(stderr, "emulation failure\n");
if (!kvm_arch_stop_on_emulation_error(env)) {
cpu_dump_state(env, stderr, fprintf, CPU_DUMP_CODE);
return 0;
}
}
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CPUState *VAR_0, struct kvm_run *VAR_1)
{
fprintf(stderr, "KVM internal error.");
if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) {
int VAR_2;
fprintf(stderr, " Suberror: %d\n", VAR_1->internal.suberror);
for (VAR_2 = 0; VAR_2 < VAR_1->internal.ndata; ++VAR_2) {
fprintf(stderr, "extra data[%d]: %"PRIx64"\n",
VAR_2, (uint64_t)VAR_1->internal.data[VAR_2]);
}
} else {
fprintf(stderr, "\n");
}
if (VAR_1->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) {
fprintf(stderr, "emulation failure\n");
if (!kvm_arch_stop_on_emulation_error(VAR_0)) {
cpu_dump_state(VAR_0, stderr, fprintf, CPU_DUMP_CODE);
return 0;
}
}
return -1;
}
| [
"static int FUNC_0(CPUState *VAR_0, struct kvm_run *VAR_1)\n{",
"fprintf(stderr, \"KVM internal error.\");",
"if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) {",
"int VAR_2;",
"fprintf(stderr, \" Suberror: %d\\n\", VAR_1->internal.suberror);",
"for (VAR_2 = 0; VAR_2 < VAR_1->internal.ndata; ++VAR_2) {",
"fprintf(stderr, \"extra data[%d]: %\"PRIx64\"\\n\",\nVAR_2, (uint64_t)VAR_1->internal.data[VAR_2]);",
"}",
"} else {",
"fprintf(stderr, \"\\n\");",
"}",
"if (VAR_1->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) {",
"fprintf(stderr, \"emulation failure\\n\");",
"if (!kvm_arch_stop_on_emulation_error(VAR_0)) {",
"cpu_dump_state(VAR_0, stderr, fprintf, CPU_DUMP_CODE);",
"return 0;",
"}",
"}",
"return -1;",
"}"
]
| [
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
],
[
49
],
[
51
]
]
|
10,367 | int virtio_get_block_size(void)
{
return blk_cfg.blk_size;
}
| false | qemu | 92cb05574b7bd489be81f9c58497dc7dfe5d8859 | int virtio_get_block_size(void)
{
return blk_cfg.blk_size;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void)
{
return blk_cfg.blk_size;
}
| [
"int FUNC_0(void)\n{",
"return blk_cfg.blk_size;",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
10,368 | void tlb_fill(target_ulong addr, int is_write, int mmu_idx, void *retaddr)
{
tlb_set_page(cpu_single_env,
addr & ~(TARGET_PAGE_SIZE - 1),
addr & ~(TARGET_PAGE_SIZE - 1),
PAGE_READ | PAGE_WRITE | PAGE_EXEC,
mmu_idx, TARGET_PAGE_SIZE);
}
| false | qemu | b67ea0cd74417b42482499c29feb90914fbf8097 | void tlb_fill(target_ulong addr, int is_write, int mmu_idx, void *retaddr)
{
tlb_set_page(cpu_single_env,
addr & ~(TARGET_PAGE_SIZE - 1),
addr & ~(TARGET_PAGE_SIZE - 1),
PAGE_READ | PAGE_WRITE | PAGE_EXEC,
mmu_idx, TARGET_PAGE_SIZE);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(target_ulong VAR_0, int VAR_1, int VAR_2, void *VAR_3)
{
tlb_set_page(cpu_single_env,
VAR_0 & ~(TARGET_PAGE_SIZE - 1),
VAR_0 & ~(TARGET_PAGE_SIZE - 1),
PAGE_READ | PAGE_WRITE | PAGE_EXEC,
VAR_2, TARGET_PAGE_SIZE);
}
| [
"void FUNC_0(target_ulong VAR_0, int VAR_1, int VAR_2, void *VAR_3)\n{",
"tlb_set_page(cpu_single_env,\nVAR_0 & ~(TARGET_PAGE_SIZE - 1),\nVAR_0 & ~(TARGET_PAGE_SIZE - 1),\nPAGE_READ | PAGE_WRITE | PAGE_EXEC,\nVAR_2, TARGET_PAGE_SIZE);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5,
7,
9,
11,
13
],
[
15
]
]
|
10,371 | pp_context_t *pp_get_context(int width, int height, int cpuCaps){
PPContext *c= memalign(32, sizeof(PPContext));
int i;
int stride= (width+15)&(~15); //assumed / will realloc if needed
memset(c, 0, sizeof(PPContext));
c->cpuCaps= cpuCaps;
if(cpuCaps&PP_FORMAT){
c->hChromaSubSample= cpuCaps&0x3;
c->vChromaSubSample= (cpuCaps>>4)&0x3;
}else{
c->hChromaSubSample= 1;
c->vChromaSubSample= 1;
}
reallocBuffers(c, width, height, stride);
c->frameNum=-1;
return c;
}
| false | FFmpeg | ca390e727d165bf80445035c4b67a7239fdc87c0 | pp_context_t *pp_get_context(int width, int height, int cpuCaps){
PPContext *c= memalign(32, sizeof(PPContext));
int i;
int stride= (width+15)&(~15);
memset(c, 0, sizeof(PPContext));
c->cpuCaps= cpuCaps;
if(cpuCaps&PP_FORMAT){
c->hChromaSubSample= cpuCaps&0x3;
c->vChromaSubSample= (cpuCaps>>4)&0x3;
}else{
c->hChromaSubSample= 1;
c->vChromaSubSample= 1;
}
reallocBuffers(c, width, height, stride);
c->frameNum=-1;
return c;
}
| {
"code": [],
"line_no": []
} | pp_context_t *FUNC_0(int width, int height, int cpuCaps){
PPContext *c= memalign(32, sizeof(PPContext));
int VAR_0;
int VAR_1= (width+15)&(~15);
memset(c, 0, sizeof(PPContext));
c->cpuCaps= cpuCaps;
if(cpuCaps&PP_FORMAT){
c->hChromaSubSample= cpuCaps&0x3;
c->vChromaSubSample= (cpuCaps>>4)&0x3;
}else{
c->hChromaSubSample= 1;
c->vChromaSubSample= 1;
}
reallocBuffers(c, width, height, VAR_1);
c->frameNum=-1;
return c;
}
| [
"pp_context_t *FUNC_0(int width, int height, int cpuCaps){",
"PPContext *c= memalign(32, sizeof(PPContext));",
"int VAR_0;",
"int VAR_1= (width+15)&(~15);",
"memset(c, 0, sizeof(PPContext));",
"c->cpuCaps= cpuCaps;",
"if(cpuCaps&PP_FORMAT){",
"c->hChromaSubSample= cpuCaps&0x3;",
"c->vChromaSubSample= (cpuCaps>>4)&0x3;",
"}else{",
"c->hChromaSubSample= 1;",
"c->vChromaSubSample= 1;",
"}",
"reallocBuffers(c, width, height, VAR_1);",
"c->frameNum=-1;",
"return c;",
"}"
]
| [
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
],
[
35
],
[
39
],
[
41
]
]
|
10,372 | static gboolean gd_leave_event(GtkWidget *widget, GdkEventCrossing *crossing,
gpointer opaque)
{
VirtualConsole *vc = opaque;
GtkDisplayState *s = vc->s;
if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) {
gd_ungrab_keyboard(s);
}
return TRUE;
}
| false | qemu | 2884cf5b934808f547b5268a51be631805c25857 | static gboolean gd_leave_event(GtkWidget *widget, GdkEventCrossing *crossing,
gpointer opaque)
{
VirtualConsole *vc = opaque;
GtkDisplayState *s = vc->s;
if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) {
gd_ungrab_keyboard(s);
}
return TRUE;
}
| {
"code": [],
"line_no": []
} | static gboolean FUNC_0(GtkWidget *widget, GdkEventCrossing *crossing,
gpointer opaque)
{
VirtualConsole *vc = opaque;
GtkDisplayState *s = vc->s;
if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) {
gd_ungrab_keyboard(s);
}
return TRUE;
}
| [
"static gboolean FUNC_0(GtkWidget *widget, GdkEventCrossing *crossing,\ngpointer opaque)\n{",
"VirtualConsole *vc = opaque;",
"GtkDisplayState *s = vc->s;",
"if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) {",
"gd_ungrab_keyboard(s);",
"}",
"return TRUE;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
]
|
10,373 | static void vty_receive(void *opaque, const uint8_t *buf, int size)
{
VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)opaque;
int i;
if ((dev->in == dev->out) && size) {
/* toggle line to simulate edge interrupt */
qemu_irq_pulse(dev->sdev.qirq);
}
for (i = 0; i < size; i++) {
assert((dev->in - dev->out) < VTERM_BUFSIZE);
dev->buf[dev->in++ % VTERM_BUFSIZE] = buf[i];
}
}
| false | qemu | a307d59434ba78b97544b42b8cfd24a1b62e39a6 | static void vty_receive(void *opaque, const uint8_t *buf, int size)
{
VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)opaque;
int i;
if ((dev->in == dev->out) && size) {
qemu_irq_pulse(dev->sdev.qirq);
}
for (i = 0; i < size; i++) {
assert((dev->in - dev->out) < VTERM_BUFSIZE);
dev->buf[dev->in++ % VTERM_BUFSIZE] = buf[i];
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)VAR_0;
int VAR_3;
if ((dev->in == dev->out) && VAR_2) {
qemu_irq_pulse(dev->sdev.qirq);
}
for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {
assert((dev->in - dev->out) < VTERM_BUFSIZE);
dev->VAR_1[dev->in++ % VTERM_BUFSIZE] = VAR_1[VAR_3];
}
}
| [
"static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)VAR_0;",
"int VAR_3;",
"if ((dev->in == dev->out) && VAR_2) {",
"qemu_irq_pulse(dev->sdev.qirq);",
"}",
"for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {",
"assert((dev->in - dev->out) < VTERM_BUFSIZE);",
"dev->VAR_1[dev->in++ % VTERM_BUFSIZE] = VAR_1[VAR_3];",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
]
|
10,375 | int kvm_arch_process_async_events(CPUState *env)
{
return 0;
}
| false | qemu | 71b12d31971751f46c546d693c1e216f38ba2053 | int kvm_arch_process_async_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
]
]
|
10,377 | static void coroutine_fn stream_run(void *opaque)
{
StreamBlockJob *s = opaque;
StreamCompleteData *data;
BlockBackend *blk = s->common.blk;
BlockDriverState *bs = blk_bs(blk);
BlockDriverState *base = s->base;
int64_t sector_num = 0;
int64_t end = -1;
uint64_t delay_ns = 0;
int error = 0;
int ret = 0;
int n = 0;
void *buf;
if (!bs->backing) {
goto out;
}
s->common.len = bdrv_getlength(bs);
if (s->common.len < 0) {
ret = s->common.len;
goto out;
}
end = s->common.len >> BDRV_SECTOR_BITS;
buf = qemu_blockalign(bs, STREAM_BUFFER_SIZE);
/* Turn on copy-on-read for the whole block device so that guest read
* requests help us make progress. Only do this when copying the entire
* backing chain since the copy-on-read operation does not take base into
* account.
*/
if (!base) {
bdrv_enable_copy_on_read(bs);
}
for (sector_num = 0; sector_num < end; sector_num += n) {
bool copy;
/* Note that even when no rate limit is applied we need to yield
* with no pending I/O here so that bdrv_drain_all() returns.
*/
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
copy = false;
ret = bdrv_is_allocated(bs, sector_num,
STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n);
if (ret == 1) {
/* Allocated in the top, no need to copy. */
} else if (ret >= 0) {
/* Copy if allocated in the intermediate images. Limit to the
* known-unallocated area [sector_num, sector_num+n). */
ret = bdrv_is_allocated_above(backing_bs(bs), base,
sector_num, n, &n);
/* Finish early if end of backing file has been reached */
if (ret == 0 && n == 0) {
n = end - sector_num;
}
copy = (ret == 1);
}
trace_stream_one_iteration(s, sector_num * BDRV_SECTOR_SIZE,
n * BDRV_SECTOR_SIZE, ret);
if (copy) {
ret = stream_populate(blk, sector_num * BDRV_SECTOR_SIZE,
n * BDRV_SECTOR_SIZE, buf);
}
if (ret < 0) {
BlockErrorAction action =
block_job_error_action(&s->common, s->on_error, true, -ret);
if (action == BLOCK_ERROR_ACTION_STOP) {
n = 0;
continue;
}
if (error == 0) {
error = ret;
}
if (action == BLOCK_ERROR_ACTION_REPORT) {
break;
}
}
ret = 0;
/* Publish progress */
s->common.offset += n * BDRV_SECTOR_SIZE;
if (copy && s->common.speed) {
delay_ns = ratelimit_calculate_delay(&s->limit,
n * BDRV_SECTOR_SIZE);
}
}
if (!base) {
bdrv_disable_copy_on_read(bs);
}
/* Do not remove the backing file if an error was there but ignored. */
ret = error;
qemu_vfree(buf);
out:
/* Modify backing chain and close BDSes in main loop */
data = g_malloc(sizeof(*data));
data->ret = ret;
block_job_defer_to_main_loop(&s->common, stream_complete, data);
}
| false | qemu | d535435f4a3968a897803d38bf1642f3b644979a | static void coroutine_fn stream_run(void *opaque)
{
StreamBlockJob *s = opaque;
StreamCompleteData *data;
BlockBackend *blk = s->common.blk;
BlockDriverState *bs = blk_bs(blk);
BlockDriverState *base = s->base;
int64_t sector_num = 0;
int64_t end = -1;
uint64_t delay_ns = 0;
int error = 0;
int ret = 0;
int n = 0;
void *buf;
if (!bs->backing) {
goto out;
}
s->common.len = bdrv_getlength(bs);
if (s->common.len < 0) {
ret = s->common.len;
goto out;
}
end = s->common.len >> BDRV_SECTOR_BITS;
buf = qemu_blockalign(bs, STREAM_BUFFER_SIZE);
if (!base) {
bdrv_enable_copy_on_read(bs);
}
for (sector_num = 0; sector_num < end; sector_num += n) {
bool copy;
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
copy = false;
ret = bdrv_is_allocated(bs, sector_num,
STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n);
if (ret == 1) {
} else if (ret >= 0) {
ret = bdrv_is_allocated_above(backing_bs(bs), base,
sector_num, n, &n);
if (ret == 0 && n == 0) {
n = end - sector_num;
}
copy = (ret == 1);
}
trace_stream_one_iteration(s, sector_num * BDRV_SECTOR_SIZE,
n * BDRV_SECTOR_SIZE, ret);
if (copy) {
ret = stream_populate(blk, sector_num * BDRV_SECTOR_SIZE,
n * BDRV_SECTOR_SIZE, buf);
}
if (ret < 0) {
BlockErrorAction action =
block_job_error_action(&s->common, s->on_error, true, -ret);
if (action == BLOCK_ERROR_ACTION_STOP) {
n = 0;
continue;
}
if (error == 0) {
error = ret;
}
if (action == BLOCK_ERROR_ACTION_REPORT) {
break;
}
}
ret = 0;
s->common.offset += n * BDRV_SECTOR_SIZE;
if (copy && s->common.speed) {
delay_ns = ratelimit_calculate_delay(&s->limit,
n * BDRV_SECTOR_SIZE);
}
}
if (!base) {
bdrv_disable_copy_on_read(bs);
}
ret = error;
qemu_vfree(buf);
out:
data = g_malloc(sizeof(*data));
data->ret = ret;
block_job_defer_to_main_loop(&s->common, stream_complete, data);
}
| {
"code": [],
"line_no": []
} | static void VAR_0 stream_run(void *opaque)
{
StreamBlockJob *s = opaque;
StreamCompleteData *data;
BlockBackend *blk = s->common.blk;
BlockDriverState *bs = blk_bs(blk);
BlockDriverState *base = s->base;
int64_t sector_num = 0;
int64_t end = -1;
uint64_t delay_ns = 0;
int error = 0;
int ret = 0;
int n = 0;
void *buf;
if (!bs->backing) {
goto out;
}
s->common.len = bdrv_getlength(bs);
if (s->common.len < 0) {
ret = s->common.len;
goto out;
}
end = s->common.len >> BDRV_SECTOR_BITS;
buf = qemu_blockalign(bs, STREAM_BUFFER_SIZE);
if (!base) {
bdrv_enable_copy_on_read(bs);
}
for (sector_num = 0; sector_num < end; sector_num += n) {
bool copy;
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
copy = false;
ret = bdrv_is_allocated(bs, sector_num,
STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n);
if (ret == 1) {
} else if (ret >= 0) {
ret = bdrv_is_allocated_above(backing_bs(bs), base,
sector_num, n, &n);
if (ret == 0 && n == 0) {
n = end - sector_num;
}
copy = (ret == 1);
}
trace_stream_one_iteration(s, sector_num * BDRV_SECTOR_SIZE,
n * BDRV_SECTOR_SIZE, ret);
if (copy) {
ret = stream_populate(blk, sector_num * BDRV_SECTOR_SIZE,
n * BDRV_SECTOR_SIZE, buf);
}
if (ret < 0) {
BlockErrorAction action =
block_job_error_action(&s->common, s->on_error, true, -ret);
if (action == BLOCK_ERROR_ACTION_STOP) {
n = 0;
continue;
}
if (error == 0) {
error = ret;
}
if (action == BLOCK_ERROR_ACTION_REPORT) {
break;
}
}
ret = 0;
s->common.offset += n * BDRV_SECTOR_SIZE;
if (copy && s->common.speed) {
delay_ns = ratelimit_calculate_delay(&s->limit,
n * BDRV_SECTOR_SIZE);
}
}
if (!base) {
bdrv_disable_copy_on_read(bs);
}
ret = error;
qemu_vfree(buf);
out:
data = g_malloc(sizeof(*data));
data->ret = ret;
block_job_defer_to_main_loop(&s->common, stream_complete, data);
}
| [
"static void VAR_0 stream_run(void *opaque)\n{",
"StreamBlockJob *s = opaque;",
"StreamCompleteData *data;",
"BlockBackend *blk = s->common.blk;",
"BlockDriverState *bs = blk_bs(blk);",
"BlockDriverState *base = s->base;",
"int64_t sector_num = 0;",
"int64_t end = -1;",
"uint64_t delay_ns = 0;",
"int error = 0;",
"int ret = 0;",
"int n = 0;",
"void *buf;",
"if (!bs->backing) {",
"goto out;",
"}",
"s->common.len = bdrv_getlength(bs);",
"if (s->common.len < 0) {",
"ret = s->common.len;",
"goto out;",
"}",
"end = s->common.len >> BDRV_SECTOR_BITS;",
"buf = qemu_blockalign(bs, STREAM_BUFFER_SIZE);",
"if (!base) {",
"bdrv_enable_copy_on_read(bs);",
"}",
"for (sector_num = 0; sector_num < end; sector_num += n) {",
"bool copy;",
"block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);",
"if (block_job_is_cancelled(&s->common)) {",
"break;",
"}",
"copy = false;",
"ret = bdrv_is_allocated(bs, sector_num,\nSTREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n);",
"if (ret == 1) {",
"} else if (ret >= 0) {",
"ret = bdrv_is_allocated_above(backing_bs(bs), base,\nsector_num, n, &n);",
"if (ret == 0 && n == 0) {",
"n = end - sector_num;",
"}",
"copy = (ret == 1);",
"}",
"trace_stream_one_iteration(s, sector_num * BDRV_SECTOR_SIZE,\nn * BDRV_SECTOR_SIZE, ret);",
"if (copy) {",
"ret = stream_populate(blk, sector_num * BDRV_SECTOR_SIZE,\nn * BDRV_SECTOR_SIZE, buf);",
"}",
"if (ret < 0) {",
"BlockErrorAction action =\nblock_job_error_action(&s->common, s->on_error, true, -ret);",
"if (action == BLOCK_ERROR_ACTION_STOP) {",
"n = 0;",
"continue;",
"}",
"if (error == 0) {",
"error = ret;",
"}",
"if (action == BLOCK_ERROR_ACTION_REPORT) {",
"break;",
"}",
"}",
"ret = 0;",
"s->common.offset += n * BDRV_SECTOR_SIZE;",
"if (copy && s->common.speed) {",
"delay_ns = ratelimit_calculate_delay(&s->limit,\nn * BDRV_SECTOR_SIZE);",
"}",
"}",
"if (!base) {",
"bdrv_disable_copy_on_read(bs);",
"}",
"ret = error;",
"qemu_vfree(buf);",
"out:\ndata = g_malloc(sizeof(*data));",
"data->ret = ret;",
"block_job_defer_to_main_loop(&s->common, stream_complete, data);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
101,
103
],
[
105
],
[
109
],
[
115,
117
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
181
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
205
],
[
209
],
[
213,
217
],
[
219
],
[
221
],
[
223
]
]
|
10,378 | static void palmte_onoff_gpios(void *opaque, int line, int level)
{
switch (line) {
case 0:
printf("%s: current to MMC/SD card %sabled.\n",
__FUNCTION__, level ? "dis" : "en");
break;
case 1:
printf("%s: internal speaker amplifier %s.\n",
__FUNCTION__, level ? "down" : "on");
break;
/* These LCD & Audio output signals have not been identified yet. */
case 2:
case 3:
case 4:
printf("%s: LCD GPIO%i %s.\n",
__FUNCTION__, line - 1, level ? "high" : "low");
break;
case 5:
case 6:
printf("%s: Audio GPIO%i %s.\n",
__FUNCTION__, line - 4, level ? "high" : "low");
break;
}
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static void palmte_onoff_gpios(void *opaque, int line, int level)
{
switch (line) {
case 0:
printf("%s: current to MMC/SD card %sabled.\n",
__FUNCTION__, level ? "dis" : "en");
break;
case 1:
printf("%s: internal speaker amplifier %s.\n",
__FUNCTION__, level ? "down" : "on");
break;
case 2:
case 3:
case 4:
printf("%s: LCD GPIO%i %s.\n",
__FUNCTION__, line - 1, level ? "high" : "low");
break;
case 5:
case 6:
printf("%s: Audio GPIO%i %s.\n",
__FUNCTION__, line - 4, level ? "high" : "low");
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)
{
switch (VAR_1) {
case 0:
printf("%s: current to MMC/SD card %sabled.\n",
__FUNCTION__, VAR_2 ? "dis" : "en");
break;
case 1:
printf("%s: internal speaker amplifier %s.\n",
__FUNCTION__, VAR_2 ? "down" : "on");
break;
case 2:
case 3:
case 4:
printf("%s: LCD GPIO%i %s.\n",
__FUNCTION__, VAR_1 - 1, VAR_2 ? "high" : "low");
break;
case 5:
case 6:
printf("%s: Audio GPIO%i %s.\n",
__FUNCTION__, VAR_1 - 4, VAR_2 ? "high" : "low");
break;
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)\n{",
"switch (VAR_1) {",
"case 0:\nprintf(\"%s: current to MMC/SD card %sabled.\\n\",\n__FUNCTION__, VAR_2 ? \"dis\" : \"en\");",
"break;",
"case 1:\nprintf(\"%s: internal speaker amplifier %s.\\n\",\n__FUNCTION__, VAR_2 ? \"down\" : \"on\");",
"break;",
"case 2:\ncase 3:\ncase 4:\nprintf(\"%s: LCD GPIO%i %s.\\n\",\n__FUNCTION__, VAR_1 - 1, VAR_2 ? \"high\" : \"low\");",
"break;",
"case 5:\ncase 6:\nprintf(\"%s: Audio GPIO%i %s.\\n\",\n__FUNCTION__, VAR_1 - 4, VAR_2 ? \"high\" : \"low\");",
"break;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9,
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
27,
29,
31,
33,
35
],
[
37
],
[
39,
41,
43,
45
],
[
47
],
[
49
],
[
51
]
]
|
10,379 | static int ppc_hash64_check_prot(int prot, int rwx)
{
int ret;
if (rwx == 2) {
if (prot & PAGE_EXEC) {
ret = 0;
} else {
ret = -2;
}
} else if (rwx == 1) {
if (prot & PAGE_WRITE) {
ret = 0;
} else {
ret = -2;
}
} else {
if (prot & PAGE_READ) {
ret = 0;
} else {
ret = -2;
}
}
return ret;
}
| false | qemu | e01b444523e2b0c663b42b3e8f44ef48a6153051 | static int ppc_hash64_check_prot(int prot, int rwx)
{
int ret;
if (rwx == 2) {
if (prot & PAGE_EXEC) {
ret = 0;
} else {
ret = -2;
}
} else if (rwx == 1) {
if (prot & PAGE_WRITE) {
ret = 0;
} else {
ret = -2;
}
} else {
if (prot & PAGE_READ) {
ret = 0;
} else {
ret = -2;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, int VAR_1)
{
int VAR_2;
if (VAR_1 == 2) {
if (VAR_0 & PAGE_EXEC) {
VAR_2 = 0;
} else {
VAR_2 = -2;
}
} else if (VAR_1 == 1) {
if (VAR_0 & PAGE_WRITE) {
VAR_2 = 0;
} else {
VAR_2 = -2;
}
} else {
if (VAR_0 & PAGE_READ) {
VAR_2 = 0;
} else {
VAR_2 = -2;
}
}
return VAR_2;
}
| [
"static int FUNC_0(int VAR_0, int VAR_1)\n{",
"int VAR_2;",
"if (VAR_1 == 2) {",
"if (VAR_0 & PAGE_EXEC) {",
"VAR_2 = 0;",
"} else {",
"VAR_2 = -2;",
"}",
"} else if (VAR_1 == 1) {",
"if (VAR_0 & PAGE_WRITE) {",
"VAR_2 = 0;",
"} else {",
"VAR_2 = -2;",
"}",
"} else {",
"if (VAR_0 & PAGE_READ) {",
"VAR_2 = 0;",
"} else {",
"VAR_2 = -2;",
"}",
"}",
"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
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
]
]
|
10,380 | static void exynos4210_pwm_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
Exynos4210PWMState *s = (Exynos4210PWMState *)opaque;
int index;
uint32_t new_val;
int i;
switch (offset) {
case TCFG0: case TCFG1:
index = (offset - TCFG0) >> 2;
s->reg_tcfg[index] = value;
/* update timers frequencies */
for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) {
exynos4210_pwm_update_freq(s, s->timer[i].id);
}
break;
case TCON:
for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) {
if ((value & TCON_TIMER_MANUAL_UPD(i)) >
(s->reg_tcon & TCON_TIMER_MANUAL_UPD(i))) {
/*
* TCNTB and TCMPB are loaded into TCNT and TCMP.
* Update timers.
*/
/* this will start timer to run, this ok, because
* during processing start bit timer will be stopped
* if needed */
ptimer_set_count(s->timer[i].ptimer, s->timer[i].reg_tcntb);
DPRINTF("set timer %d count to %x\n", i,
s->timer[i].reg_tcntb);
}
if ((value & TCON_TIMER_START(i)) >
(s->reg_tcon & TCON_TIMER_START(i))) {
/* changed to start */
ptimer_run(s->timer[i].ptimer, 1);
DPRINTF("run timer %d\n", i);
}
if ((value & TCON_TIMER_START(i)) <
(s->reg_tcon & TCON_TIMER_START(i))) {
/* changed to stop */
ptimer_stop(s->timer[i].ptimer);
DPRINTF("stop timer %d\n", i);
}
}
s->reg_tcon = value;
break;
case TCNTB0: case TCNTB1:
case TCNTB2: case TCNTB3: case TCNTB4:
index = (offset - TCNTB0) / 0xC;
s->timer[index].reg_tcntb = value;
break;
case TCMPB0: case TCMPB1:
case TCMPB2: case TCMPB3:
index = (offset - TCMPB0) / 0xC;
s->timer[index].reg_tcmpb = value;
break;
case TINT_CSTAT:
new_val = (s->reg_tint_cstat & 0x3E0) + (0x1F & value);
new_val &= ~(0x3E0 & value);
for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) {
if ((new_val & TINT_CSTAT_STATUS(i)) <
(s->reg_tint_cstat & TINT_CSTAT_STATUS(i))) {
qemu_irq_lower(s->timer[i].irq);
}
}
s->reg_tint_cstat = new_val;
break;
default:
fprintf(stderr,
"[exynos4210.pwm: bad write offset " TARGET_FMT_plx "]\n",
offset);
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void exynos4210_pwm_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
Exynos4210PWMState *s = (Exynos4210PWMState *)opaque;
int index;
uint32_t new_val;
int i;
switch (offset) {
case TCFG0: case TCFG1:
index = (offset - TCFG0) >> 2;
s->reg_tcfg[index] = value;
for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) {
exynos4210_pwm_update_freq(s, s->timer[i].id);
}
break;
case TCON:
for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) {
if ((value & TCON_TIMER_MANUAL_UPD(i)) >
(s->reg_tcon & TCON_TIMER_MANUAL_UPD(i))) {
ptimer_set_count(s->timer[i].ptimer, s->timer[i].reg_tcntb);
DPRINTF("set timer %d count to %x\n", i,
s->timer[i].reg_tcntb);
}
if ((value & TCON_TIMER_START(i)) >
(s->reg_tcon & TCON_TIMER_START(i))) {
ptimer_run(s->timer[i].ptimer, 1);
DPRINTF("run timer %d\n", i);
}
if ((value & TCON_TIMER_START(i)) <
(s->reg_tcon & TCON_TIMER_START(i))) {
ptimer_stop(s->timer[i].ptimer);
DPRINTF("stop timer %d\n", i);
}
}
s->reg_tcon = value;
break;
case TCNTB0: case TCNTB1:
case TCNTB2: case TCNTB3: case TCNTB4:
index = (offset - TCNTB0) / 0xC;
s->timer[index].reg_tcntb = value;
break;
case TCMPB0: case TCMPB1:
case TCMPB2: case TCMPB3:
index = (offset - TCMPB0) / 0xC;
s->timer[index].reg_tcmpb = value;
break;
case TINT_CSTAT:
new_val = (s->reg_tint_cstat & 0x3E0) + (0x1F & value);
new_val &= ~(0x3E0 & value);
for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) {
if ((new_val & TINT_CSTAT_STATUS(i)) <
(s->reg_tint_cstat & TINT_CSTAT_STATUS(i))) {
qemu_irq_lower(s->timer[i].irq);
}
}
s->reg_tint_cstat = new_val;
break;
default:
fprintf(stderr,
"[exynos4210.pwm: bad write offset " TARGET_FMT_plx "]\n",
offset);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
Exynos4210PWMState *s = (Exynos4210PWMState *)VAR_0;
int VAR_4;
uint32_t new_val;
int VAR_5;
switch (VAR_1) {
case TCFG0: case TCFG1:
VAR_4 = (VAR_1 - TCFG0) >> 2;
s->reg_tcfg[VAR_4] = VAR_2;
for (VAR_5 = 0; VAR_5 < EXYNOS4210_PWM_TIMERS_NUM; VAR_5++) {
exynos4210_pwm_update_freq(s, s->timer[VAR_5].id);
}
break;
case TCON:
for (VAR_5 = 0; VAR_5 < EXYNOS4210_PWM_TIMERS_NUM; VAR_5++) {
if ((VAR_2 & TCON_TIMER_MANUAL_UPD(VAR_5)) >
(s->reg_tcon & TCON_TIMER_MANUAL_UPD(VAR_5))) {
ptimer_set_count(s->timer[VAR_5].ptimer, s->timer[VAR_5].reg_tcntb);
DPRINTF("set timer %d count to %x\n", VAR_5,
s->timer[VAR_5].reg_tcntb);
}
if ((VAR_2 & TCON_TIMER_START(VAR_5)) >
(s->reg_tcon & TCON_TIMER_START(VAR_5))) {
ptimer_run(s->timer[VAR_5].ptimer, 1);
DPRINTF("run timer %d\n", VAR_5);
}
if ((VAR_2 & TCON_TIMER_START(VAR_5)) <
(s->reg_tcon & TCON_TIMER_START(VAR_5))) {
ptimer_stop(s->timer[VAR_5].ptimer);
DPRINTF("stop timer %d\n", VAR_5);
}
}
s->reg_tcon = VAR_2;
break;
case TCNTB0: case TCNTB1:
case TCNTB2: case TCNTB3: case TCNTB4:
VAR_4 = (VAR_1 - TCNTB0) / 0xC;
s->timer[VAR_4].reg_tcntb = VAR_2;
break;
case TCMPB0: case TCMPB1:
case TCMPB2: case TCMPB3:
VAR_4 = (VAR_1 - TCMPB0) / 0xC;
s->timer[VAR_4].reg_tcmpb = VAR_2;
break;
case TINT_CSTAT:
new_val = (s->reg_tint_cstat & 0x3E0) + (0x1F & VAR_2);
new_val &= ~(0x3E0 & VAR_2);
for (VAR_5 = 0; VAR_5 < EXYNOS4210_PWM_TIMERS_NUM; VAR_5++) {
if ((new_val & TINT_CSTAT_STATUS(VAR_5)) <
(s->reg_tint_cstat & TINT_CSTAT_STATUS(VAR_5))) {
qemu_irq_lower(s->timer[VAR_5].irq);
}
}
s->reg_tint_cstat = new_val;
break;
default:
fprintf(stderr,
"[exynos4210.pwm: bad write VAR_1 " TARGET_FMT_plx "]\n",
VAR_1);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"Exynos4210PWMState *s = (Exynos4210PWMState *)VAR_0;",
"int VAR_4;",
"uint32_t new_val;",
"int VAR_5;",
"switch (VAR_1) {",
"case TCFG0: case TCFG1:\nVAR_4 = (VAR_1 - TCFG0) >> 2;",
"s->reg_tcfg[VAR_4] = VAR_2;",
"for (VAR_5 = 0; VAR_5 < EXYNOS4210_PWM_TIMERS_NUM; VAR_5++) {",
"exynos4210_pwm_update_freq(s, s->timer[VAR_5].id);",
"}",
"break;",
"case TCON:\nfor (VAR_5 = 0; VAR_5 < EXYNOS4210_PWM_TIMERS_NUM; VAR_5++) {",
"if ((VAR_2 & TCON_TIMER_MANUAL_UPD(VAR_5)) >\n(s->reg_tcon & TCON_TIMER_MANUAL_UPD(VAR_5))) {",
"ptimer_set_count(s->timer[VAR_5].ptimer, s->timer[VAR_5].reg_tcntb);",
"DPRINTF(\"set timer %d count to %x\\n\", VAR_5,\ns->timer[VAR_5].reg_tcntb);",
"}",
"if ((VAR_2 & TCON_TIMER_START(VAR_5)) >\n(s->reg_tcon & TCON_TIMER_START(VAR_5))) {",
"ptimer_run(s->timer[VAR_5].ptimer, 1);",
"DPRINTF(\"run timer %d\\n\", VAR_5);",
"}",
"if ((VAR_2 & TCON_TIMER_START(VAR_5)) <\n(s->reg_tcon & TCON_TIMER_START(VAR_5))) {",
"ptimer_stop(s->timer[VAR_5].ptimer);",
"DPRINTF(\"stop timer %d\\n\", VAR_5);",
"}",
"}",
"s->reg_tcon = VAR_2;",
"break;",
"case TCNTB0: case TCNTB1:\ncase TCNTB2: case TCNTB3: case TCNTB4:\nVAR_4 = (VAR_1 - TCNTB0) / 0xC;",
"s->timer[VAR_4].reg_tcntb = VAR_2;",
"break;",
"case TCMPB0: case TCMPB1:\ncase TCMPB2: case TCMPB3:\nVAR_4 = (VAR_1 - TCMPB0) / 0xC;",
"s->timer[VAR_4].reg_tcmpb = VAR_2;",
"break;",
"case TINT_CSTAT:\nnew_val = (s->reg_tint_cstat & 0x3E0) + (0x1F & VAR_2);",
"new_val &= ~(0x3E0 & VAR_2);",
"for (VAR_5 = 0; VAR_5 < EXYNOS4210_PWM_TIMERS_NUM; VAR_5++) {",
"if ((new_val & TINT_CSTAT_STATUS(VAR_5)) <\n(s->reg_tint_cstat & TINT_CSTAT_STATUS(VAR_5))) {",
"qemu_irq_lower(s->timer[VAR_5].irq);",
"}",
"}",
"s->reg_tint_cstat = new_val;",
"break;",
"default:\nfprintf(stderr,\n\"[exynos4210.pwm: bad write VAR_1 \" TARGET_FMT_plx \"]\\n\",\nVAR_1);",
"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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
43,
45
],
[
63
],
[
65,
67
],
[
69
],
[
73,
75
],
[
79
],
[
81
],
[
83
],
[
87,
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107,
109,
111
],
[
113
],
[
115
],
[
119,
121,
123
],
[
125
],
[
127
],
[
131,
133
],
[
135
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
159,
161,
163,
165
],
[
167
],
[
171
],
[
173
]
]
|
10,381 | static void smbios_build_type_1_table(void)
{
SMBIOS_BUILD_TABLE_PRE(1, 0x100, true); /* required */
SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer);
SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product);
SMBIOS_TABLE_SET_STR(1, version_str, type1.version);
SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial);
if (qemu_uuid_set) {
smbios_encode_uuid(&t->uuid, qemu_uuid);
} else {
memset(&t->uuid, 0, 16);
}
t->wake_up_type = 0x06; /* power switch */
SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku);
SMBIOS_TABLE_SET_STR(1, family_str, type1.family);
SMBIOS_BUILD_TABLE_POST;
}
| false | qemu | 9c5ce8db2e5c2769ed2fd3d91928dd1853b5ce7c | static void smbios_build_type_1_table(void)
{
SMBIOS_BUILD_TABLE_PRE(1, 0x100, true);
SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer);
SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product);
SMBIOS_TABLE_SET_STR(1, version_str, type1.version);
SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial);
if (qemu_uuid_set) {
smbios_encode_uuid(&t->uuid, qemu_uuid);
} else {
memset(&t->uuid, 0, 16);
}
t->wake_up_type = 0x06;
SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku);
SMBIOS_TABLE_SET_STR(1, family_str, type1.family);
SMBIOS_BUILD_TABLE_POST;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
SMBIOS_BUILD_TABLE_PRE(1, 0x100, true);
SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer);
SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product);
SMBIOS_TABLE_SET_STR(1, version_str, type1.version);
SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial);
if (qemu_uuid_set) {
smbios_encode_uuid(&t->uuid, qemu_uuid);
} else {
memset(&t->uuid, 0, 16);
}
t->wake_up_type = 0x06;
SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku);
SMBIOS_TABLE_SET_STR(1, family_str, type1.family);
SMBIOS_BUILD_TABLE_POST;
}
| [
"static void FUNC_0(void)\n{",
"SMBIOS_BUILD_TABLE_PRE(1, 0x100, true);",
"SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer);",
"SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product);",
"SMBIOS_TABLE_SET_STR(1, version_str, type1.version);",
"SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial);",
"if (qemu_uuid_set) {",
"smbios_encode_uuid(&t->uuid, qemu_uuid);",
"} else {",
"memset(&t->uuid, 0, 16);",
"}",
"t->wake_up_type = 0x06;",
"SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku);",
"SMBIOS_TABLE_SET_STR(1, family_str, type1.family);",
"SMBIOS_BUILD_TABLE_POST;",
"}"
]
| [
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
],
[
35
],
[
37
]
]
|
10,382 | static int rv10_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
int i;
AVFrame *pict = data;
int slice_count;
const uint8_t *slices_hdr = NULL;
av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
/* no supplementary picture */
if (buf_size == 0) {
return 0;
}
if(!avctx->slice_count){
slice_count = (*buf++) + 1;
buf_size--;
slices_hdr = buf + 4;
buf += 8 * slice_count;
buf_size -= 8 * slice_count;
if (buf_size <= 0)
return AVERROR_INVALIDDATA;
}else
slice_count = avctx->slice_count;
for(i=0; i<slice_count; i++){
unsigned offset = get_slice_offset(avctx, slices_hdr, i);
int size, size2;
if (offset >= buf_size)
return AVERROR_INVALIDDATA;
if(i+1 == slice_count)
size= buf_size - offset;
else
size= get_slice_offset(avctx, slices_hdr, i+1) - offset;
if(i+2 >= slice_count)
size2= buf_size - offset;
else
size2= get_slice_offset(avctx, slices_hdr, i+2) - offset;
if (size <= 0 || size2 <= 0 ||
offset + FFMAX(size, size2) > buf_size)
return AVERROR_INVALIDDATA;
if(rv10_decode_packet(avctx, buf+offset, size, size2) > 8*size)
i++;
}
if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){
ff_er_frame_end(s);
ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
}
if(s->last_picture_ptr || s->low_delay){
*got_frame = 1;
ff_print_debug_info(s, pict);
}
s->current_picture_ptr= NULL; // so we can detect if frame_end was not called (find some nicer solution...)
}
return avpkt->size;
}
| false | FFmpeg | 605b047bcc48482dc8a356f56629da259fbddbf1 | static int rv10_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
int i;
AVFrame *pict = data;
int slice_count;
const uint8_t *slices_hdr = NULL;
av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
if (buf_size == 0) {
return 0;
}
if(!avctx->slice_count){
slice_count = (*buf++) + 1;
buf_size--;
slices_hdr = buf + 4;
buf += 8 * slice_count;
buf_size -= 8 * slice_count;
if (buf_size <= 0)
return AVERROR_INVALIDDATA;
}else
slice_count = avctx->slice_count;
for(i=0; i<slice_count; i++){
unsigned offset = get_slice_offset(avctx, slices_hdr, i);
int size, size2;
if (offset >= buf_size)
return AVERROR_INVALIDDATA;
if(i+1 == slice_count)
size= buf_size - offset;
else
size= get_slice_offset(avctx, slices_hdr, i+1) - offset;
if(i+2 >= slice_count)
size2= buf_size - offset;
else
size2= get_slice_offset(avctx, slices_hdr, i+2) - offset;
if (size <= 0 || size2 <= 0 ||
offset + FFMAX(size, size2) > buf_size)
return AVERROR_INVALIDDATA;
if(rv10_decode_packet(avctx, buf+offset, size, size2) > 8*size)
i++;
}
if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){
ff_er_frame_end(s);
ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
}
if(s->last_picture_ptr || s->low_delay){
*got_frame = 1;
ff_print_debug_info(s, pict);
}
s->current_picture_ptr= NULL;
}
return avpkt->size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->VAR_10;
MpegEncContext *s = VAR_0->priv_data;
int VAR_6;
AVFrame *pict = VAR_1;
int VAR_7;
const uint8_t *VAR_8 = NULL;
av_dlog(VAR_0, "*****frame %d VAR_10=%d\n", VAR_0->frame_number, VAR_5);
if (VAR_5 == 0) {
return 0;
}
if(!VAR_0->VAR_7){
VAR_7 = (*VAR_4++) + 1;
VAR_5--;
VAR_8 = VAR_4 + 4;
VAR_4 += 8 * VAR_7;
VAR_5 -= 8 * VAR_7;
if (VAR_5 <= 0)
return AVERROR_INVALIDDATA;
}else
VAR_7 = VAR_0->VAR_7;
for(VAR_6=0; VAR_6<VAR_7; VAR_6++){
unsigned VAR_9 = get_slice_offset(VAR_0, VAR_8, VAR_6);
int VAR_10, VAR_11;
if (VAR_9 >= VAR_5)
return AVERROR_INVALIDDATA;
if(VAR_6+1 == VAR_7)
VAR_10= VAR_5 - VAR_9;
else
VAR_10= get_slice_offset(VAR_0, VAR_8, VAR_6+1) - VAR_9;
if(VAR_6+2 >= VAR_7)
VAR_11= VAR_5 - VAR_9;
else
VAR_11= get_slice_offset(VAR_0, VAR_8, VAR_6+2) - VAR_9;
if (VAR_10 <= 0 || VAR_11 <= 0 ||
VAR_9 + FFMAX(VAR_10, VAR_11) > VAR_5)
return AVERROR_INVALIDDATA;
if(rv10_decode_packet(VAR_0, VAR_4+VAR_9, VAR_10, VAR_11) > 8*VAR_10)
VAR_6++;
}
if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){
ff_er_frame_end(s);
ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
}
if(s->last_picture_ptr || s->low_delay){
*VAR_2 = 1;
ff_print_debug_info(s, pict);
}
s->current_picture_ptr= NULL;
}
return VAR_3->VAR_10;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->VAR_10;",
"MpegEncContext *s = VAR_0->priv_data;",
"int VAR_6;",
"AVFrame *pict = VAR_1;",
"int VAR_7;",
"const uint8_t *VAR_8 = NULL;",
"av_dlog(VAR_0, \"*****frame %d VAR_10=%d\\n\", VAR_0->frame_number, VAR_5);",
"if (VAR_5 == 0) {",
"return 0;",
"}",
"if(!VAR_0->VAR_7){",
"VAR_7 = (*VAR_4++) + 1;",
"VAR_5--;",
"VAR_8 = VAR_4 + 4;",
"VAR_4 += 8 * VAR_7;",
"VAR_5 -= 8 * VAR_7;",
"if (VAR_5 <= 0)\nreturn AVERROR_INVALIDDATA;",
"}else",
"VAR_7 = VAR_0->VAR_7;",
"for(VAR_6=0; VAR_6<VAR_7; VAR_6++){",
"unsigned VAR_9 = get_slice_offset(VAR_0, VAR_8, VAR_6);",
"int VAR_10, VAR_11;",
"if (VAR_9 >= VAR_5)\nreturn AVERROR_INVALIDDATA;",
"if(VAR_6+1 == VAR_7)\nVAR_10= VAR_5 - VAR_9;",
"else\nVAR_10= get_slice_offset(VAR_0, VAR_8, VAR_6+1) - VAR_9;",
"if(VAR_6+2 >= VAR_7)\nVAR_11= VAR_5 - VAR_9;",
"else\nVAR_11= get_slice_offset(VAR_0, VAR_8, VAR_6+2) - VAR_9;",
"if (VAR_10 <= 0 || VAR_11 <= 0 ||\nVAR_9 + FFMAX(VAR_10, VAR_11) > VAR_5)\nreturn AVERROR_INVALIDDATA;",
"if(rv10_decode_packet(VAR_0, VAR_4+VAR_9, VAR_10, VAR_11) > 8*VAR_10)\nVAR_6++;",
"}",
"if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){",
"ff_er_frame_end(s);",
"ff_MPV_frame_end(s);",
"if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {",
"*pict = s->current_picture_ptr->f;",
"} else if (s->last_picture_ptr != NULL) {",
"*pict = s->last_picture_ptr->f;",
"}",
"if(s->last_picture_ptr || s->low_delay){",
"*VAR_2 = 1;",
"ff_print_debug_info(s, pict);",
"}",
"s->current_picture_ptr= NULL;",
"}",
"return VAR_3->VAR_10;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
75,
77
],
[
79,
81
],
[
85,
87
],
[
89,
91
],
[
95,
97,
99
],
[
103,
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
]
]
|
10,384 | int css_do_rchp(uint8_t cssid, uint8_t chpid)
{
uint8_t real_cssid;
if (cssid > channel_subsys.max_cssid) {
return -EINVAL;
}
if (channel_subsys.max_cssid == 0) {
real_cssid = channel_subsys.default_cssid;
} else {
real_cssid = cssid;
}
if (!channel_subsys.css[real_cssid]) {
return -EINVAL;
}
if (!channel_subsys.css[real_cssid]->chpids[chpid].in_use) {
return -ENODEV;
}
if (!channel_subsys.css[real_cssid]->chpids[chpid].is_virtual) {
fprintf(stderr,
"rchp unsupported for non-virtual chpid %x.%02x!\n",
real_cssid, chpid);
return -ENODEV;
}
/* We don't really use a channel path, so we're done here. */
css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT,
channel_subsys.max_cssid > 0 ? 1 : 0, chpid);
if (channel_subsys.max_cssid > 0) {
css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT, 0, real_cssid << 8);
}
return 0;
}
| false | qemu | 5c8d6f008c0555b54cf10550fa86199a2cfabbca | int css_do_rchp(uint8_t cssid, uint8_t chpid)
{
uint8_t real_cssid;
if (cssid > channel_subsys.max_cssid) {
return -EINVAL;
}
if (channel_subsys.max_cssid == 0) {
real_cssid = channel_subsys.default_cssid;
} else {
real_cssid = cssid;
}
if (!channel_subsys.css[real_cssid]) {
return -EINVAL;
}
if (!channel_subsys.css[real_cssid]->chpids[chpid].in_use) {
return -ENODEV;
}
if (!channel_subsys.css[real_cssid]->chpids[chpid].is_virtual) {
fprintf(stderr,
"rchp unsupported for non-virtual chpid %x.%02x!\n",
real_cssid, chpid);
return -ENODEV;
}
css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT,
channel_subsys.max_cssid > 0 ? 1 : 0, chpid);
if (channel_subsys.max_cssid > 0) {
css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT, 0, real_cssid << 8);
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(uint8_t VAR_0, uint8_t VAR_1)
{
uint8_t real_cssid;
if (VAR_0 > channel_subsys.max_cssid) {
return -EINVAL;
}
if (channel_subsys.max_cssid == 0) {
real_cssid = channel_subsys.default_cssid;
} else {
real_cssid = VAR_0;
}
if (!channel_subsys.css[real_cssid]) {
return -EINVAL;
}
if (!channel_subsys.css[real_cssid]->chpids[VAR_1].in_use) {
return -ENODEV;
}
if (!channel_subsys.css[real_cssid]->chpids[VAR_1].is_virtual) {
fprintf(stderr,
"rchp unsupported for non-virtual VAR_1 %x.%02x!\n",
real_cssid, VAR_1);
return -ENODEV;
}
css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT,
channel_subsys.max_cssid > 0 ? 1 : 0, VAR_1);
if (channel_subsys.max_cssid > 0) {
css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT, 0, real_cssid << 8);
}
return 0;
}
| [
"int FUNC_0(uint8_t VAR_0, uint8_t VAR_1)\n{",
"uint8_t real_cssid;",
"if (VAR_0 > channel_subsys.max_cssid) {",
"return -EINVAL;",
"}",
"if (channel_subsys.max_cssid == 0) {",
"real_cssid = channel_subsys.default_cssid;",
"} else {",
"real_cssid = VAR_0;",
"}",
"if (!channel_subsys.css[real_cssid]) {",
"return -EINVAL;",
"}",
"if (!channel_subsys.css[real_cssid]->chpids[VAR_1].in_use) {",
"return -ENODEV;",
"}",
"if (!channel_subsys.css[real_cssid]->chpids[VAR_1].is_virtual) {",
"fprintf(stderr,\n\"rchp unsupported for non-virtual VAR_1 %x.%02x!\\n\",\nreal_cssid, VAR_1);",
"return -ENODEV;",
"}",
"css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT,\nchannel_subsys.max_cssid > 0 ? 1 : 0, VAR_1);",
"if (channel_subsys.max_cssid > 0) {",
"css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT, 0, real_cssid << 8);",
"}",
"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
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43,
45,
47
],
[
49
],
[
51
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
]
]
|
10,386 | static void gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src,
TCGv addr, int insn)
{
TCGv_i32 r_asi, r_size, r_sign;
TCGv_i64 s64, t64 = tcg_temp_new_i64();
r_asi = gen_get_asi(dc, insn);
r_size = tcg_const_i32(4);
r_sign = tcg_const_i32(0);
gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_size, r_sign);
tcg_temp_free_i32(r_sign);
s64 = tcg_temp_new_i64();
tcg_gen_extu_tl_i64(s64, src);
gen_helper_st_asi(cpu_env, addr, s64, r_asi, r_size);
tcg_temp_free_i64(s64);
tcg_temp_free_i32(r_size);
tcg_temp_free_i32(r_asi);
tcg_gen_trunc_i64_tl(dst, t64);
tcg_temp_free_i64(t64);
}
| false | qemu | 7ec1e5ea4bd0700fa48da86bffa2fcc6146c410a | static void gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src,
TCGv addr, int insn)
{
TCGv_i32 r_asi, r_size, r_sign;
TCGv_i64 s64, t64 = tcg_temp_new_i64();
r_asi = gen_get_asi(dc, insn);
r_size = tcg_const_i32(4);
r_sign = tcg_const_i32(0);
gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_size, r_sign);
tcg_temp_free_i32(r_sign);
s64 = tcg_temp_new_i64();
tcg_gen_extu_tl_i64(s64, src);
gen_helper_st_asi(cpu_env, addr, s64, r_asi, r_size);
tcg_temp_free_i64(s64);
tcg_temp_free_i32(r_size);
tcg_temp_free_i32(r_asi);
tcg_gen_trunc_i64_tl(dst, t64);
tcg_temp_free_i64(t64);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1, TCGv VAR_2,
TCGv VAR_3, int VAR_4)
{
TCGv_i32 r_asi, r_size, r_sign;
TCGv_i64 s64, t64 = tcg_temp_new_i64();
r_asi = gen_get_asi(VAR_0, VAR_4);
r_size = tcg_const_i32(4);
r_sign = tcg_const_i32(0);
gen_helper_ld_asi(t64, cpu_env, VAR_3, r_asi, r_size, r_sign);
tcg_temp_free_i32(r_sign);
s64 = tcg_temp_new_i64();
tcg_gen_extu_tl_i64(s64, VAR_2);
gen_helper_st_asi(cpu_env, VAR_3, s64, r_asi, r_size);
tcg_temp_free_i64(s64);
tcg_temp_free_i32(r_size);
tcg_temp_free_i32(r_asi);
tcg_gen_trunc_i64_tl(VAR_1, t64);
tcg_temp_free_i64(t64);
}
| [
"static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1, TCGv VAR_2,\nTCGv VAR_3, int VAR_4)\n{",
"TCGv_i32 r_asi, r_size, r_sign;",
"TCGv_i64 s64, t64 = tcg_temp_new_i64();",
"r_asi = gen_get_asi(VAR_0, VAR_4);",
"r_size = tcg_const_i32(4);",
"r_sign = tcg_const_i32(0);",
"gen_helper_ld_asi(t64, cpu_env, VAR_3, r_asi, r_size, r_sign);",
"tcg_temp_free_i32(r_sign);",
"s64 = tcg_temp_new_i64();",
"tcg_gen_extu_tl_i64(s64, VAR_2);",
"gen_helper_st_asi(cpu_env, VAR_3, s64, r_asi, r_size);",
"tcg_temp_free_i64(s64);",
"tcg_temp_free_i32(r_size);",
"tcg_temp_free_i32(r_asi);",
"tcg_gen_trunc_i64_tl(VAR_1, t64);",
"tcg_temp_free_i64(t64);",
"}"
]
| [
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
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
]
]
|
10,387 | static void borzoi_init(int ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
spitz_common_init(ram_size, vga_ram_size, ds, kernel_filename,
kernel_cmdline, initrd_filename, borzoi, 0x33f);
}
| false | qemu | 4207117c93357347500235952ce7891688089cb1 | static void borzoi_init(int ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
spitz_common_init(ram_size, vga_ram_size, ds, kernel_filename,
kernel_cmdline, initrd_filename, borzoi, 0x33f);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, int VAR_1, int VAR_2,
DisplayState *VAR_3, const char **VAR_4, int VAR_5,
const char *VAR_6, const char *VAR_7,
const char *VAR_8, const char *VAR_9)
{
spitz_common_init(VAR_0, VAR_1, VAR_3, VAR_6,
VAR_7, VAR_8, borzoi, 0x33f);
}
| [
"static void FUNC_0(int VAR_0, int VAR_1, int VAR_2,\nDisplayState *VAR_3, const char **VAR_4, int VAR_5,\nconst char *VAR_6, const char *VAR_7,\nconst char *VAR_8, const char *VAR_9)\n{",
"spitz_common_init(VAR_0, VAR_1, VAR_3, VAR_6,\nVAR_7, VAR_8, borzoi, 0x33f);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11,
13
],
[
15
]
]
|
10,388 | static struct addrinfo *inet_parse_connect_opts(QemuOpts *opts, Error **errp)
{
struct addrinfo ai, *res;
int rc;
const char *addr;
const char *port;
memset(&ai, 0, sizeof(ai));
ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
ai.ai_family = PF_UNSPEC;
ai.ai_socktype = SOCK_STREAM;
addr = qemu_opt_get(opts, "host");
port = qemu_opt_get(opts, "port");
if (addr == NULL || port == NULL) {
error_setg(errp, "host and/or port not specified");
return NULL;
}
if (qemu_opt_get_bool(opts, "ipv4", 0)) {
ai.ai_family = PF_INET;
}
if (qemu_opt_get_bool(opts, "ipv6", 0)) {
ai.ai_family = PF_INET6;
}
/* lookup */
rc = getaddrinfo(addr, port, &ai, &res);
if (rc != 0) {
error_setg(errp, "address resolution failed for %s:%s: %s", addr, port,
gai_strerror(rc));
return NULL;
}
return res;
}
| true | qemu | 3de3d698d942d1116152417f882c897b26b44e41 | static struct addrinfo *inet_parse_connect_opts(QemuOpts *opts, Error **errp)
{
struct addrinfo ai, *res;
int rc;
const char *addr;
const char *port;
memset(&ai, 0, sizeof(ai));
ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
ai.ai_family = PF_UNSPEC;
ai.ai_socktype = SOCK_STREAM;
addr = qemu_opt_get(opts, "host");
port = qemu_opt_get(opts, "port");
if (addr == NULL || port == NULL) {
error_setg(errp, "host and/or port not specified");
return NULL;
}
if (qemu_opt_get_bool(opts, "ipv4", 0)) {
ai.ai_family = PF_INET;
}
if (qemu_opt_get_bool(opts, "ipv6", 0)) {
ai.ai_family = PF_INET6;
}
rc = getaddrinfo(addr, port, &ai, &res);
if (rc != 0) {
error_setg(errp, "address resolution failed for %s:%s: %s", addr, port,
gai_strerror(rc));
return NULL;
}
return res;
}
| {
"code": [
" ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;",
" ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;"
],
"line_no": [
19,
19
]
} | static struct addrinfo *FUNC_0(QemuOpts *VAR_0, Error **VAR_1)
{
struct addrinfo VAR_2, *VAR_3;
int VAR_4;
const char *VAR_5;
const char *VAR_6;
memset(&VAR_2, 0, sizeof(VAR_2));
VAR_2.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
VAR_2.ai_family = PF_UNSPEC;
VAR_2.ai_socktype = SOCK_STREAM;
VAR_5 = qemu_opt_get(VAR_0, "host");
VAR_6 = qemu_opt_get(VAR_0, "VAR_6");
if (VAR_5 == NULL || VAR_6 == NULL) {
error_setg(VAR_1, "host and/or VAR_6 not specified");
return NULL;
}
if (qemu_opt_get_bool(VAR_0, "ipv4", 0)) {
VAR_2.ai_family = PF_INET;
}
if (qemu_opt_get_bool(VAR_0, "ipv6", 0)) {
VAR_2.ai_family = PF_INET6;
}
VAR_4 = getaddrinfo(VAR_5, VAR_6, &VAR_2, &VAR_3);
if (VAR_4 != 0) {
error_setg(VAR_1, "address resolution failed for %s:%s: %s", VAR_5, VAR_6,
gai_strerror(VAR_4));
return NULL;
}
return VAR_3;
}
| [
"static struct addrinfo *FUNC_0(QemuOpts *VAR_0, Error **VAR_1)\n{",
"struct addrinfo VAR_2, *VAR_3;",
"int VAR_4;",
"const char *VAR_5;",
"const char *VAR_6;",
"memset(&VAR_2, 0, sizeof(VAR_2));",
"VAR_2.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;",
"VAR_2.ai_family = PF_UNSPEC;",
"VAR_2.ai_socktype = SOCK_STREAM;",
"VAR_5 = qemu_opt_get(VAR_0, \"host\");",
"VAR_6 = qemu_opt_get(VAR_0, \"VAR_6\");",
"if (VAR_5 == NULL || VAR_6 == NULL) {",
"error_setg(VAR_1, \"host and/or VAR_6 not specified\");",
"return NULL;",
"}",
"if (qemu_opt_get_bool(VAR_0, \"ipv4\", 0)) {",
"VAR_2.ai_family = PF_INET;",
"}",
"if (qemu_opt_get_bool(VAR_0, \"ipv6\", 0)) {",
"VAR_2.ai_family = PF_INET6;",
"}",
"VAR_4 = getaddrinfo(VAR_5, VAR_6, &VAR_2, &VAR_3);",
"if (VAR_4 != 0) {",
"error_setg(VAR_1, \"address resolution failed for %s:%s: %s\", VAR_5, VAR_6,\ngai_strerror(VAR_4));",
"return NULL;",
"}",
"return VAR_3;",
"}"
]
| [
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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
]
]
|
10,390 | static int arm_gic_init(SysBusDevice *dev)
{
/* Device instance init function for the GIC sysbus device */
int i;
GICState *s = FROM_SYSBUS(GICState, dev);
ARMGICClass *agc = ARM_GIC_GET_CLASS(s);
agc->parent_init(dev);
gic_init_irqs_and_distributor(s, s->num_irq);
/* Memory regions for the CPU interfaces (NVIC doesn't have these):
* a region for "CPU interface for this core", then a region for
* "CPU interface for core 0", "for core 1", ...
* NB that the memory region size of 0x100 applies for the 11MPCore
* and also cores following the GIC v1 spec (ie A9).
* GIC v2 defines a larger memory region (0x1000) so this will need
* to be extended when we implement A15.
*/
memory_region_init_io(&s->cpuiomem[0], &gic_thiscpu_ops, s,
"gic_cpu", 0x100);
for (i = 0; i < NUM_CPU(s); i++) {
s->backref[i] = s;
memory_region_init_io(&s->cpuiomem[i+1], &gic_cpu_ops, &s->backref[i],
"gic_cpu", 0x100);
}
/* Distributor */
sysbus_init_mmio(dev, &s->iomem);
/* cpu interfaces (one for "current cpu" plus one per cpu) */
for (i = 0; i <= NUM_CPU(s); i++) {
sysbus_init_mmio(dev, &s->cpuiomem[i]);
}
return 0;
}
| true | qemu | 53111180946a56d314a9c1d07d09b9ef91e847b9 | static int arm_gic_init(SysBusDevice *dev)
{
int i;
GICState *s = FROM_SYSBUS(GICState, dev);
ARMGICClass *agc = ARM_GIC_GET_CLASS(s);
agc->parent_init(dev);
gic_init_irqs_and_distributor(s, s->num_irq);
memory_region_init_io(&s->cpuiomem[0], &gic_thiscpu_ops, s,
"gic_cpu", 0x100);
for (i = 0; i < NUM_CPU(s); i++) {
s->backref[i] = s;
memory_region_init_io(&s->cpuiomem[i+1], &gic_cpu_ops, &s->backref[i],
"gic_cpu", 0x100);
}
sysbus_init_mmio(dev, &s->iomem);
for (i = 0; i <= NUM_CPU(s); i++) {
sysbus_init_mmio(dev, &s->cpuiomem[i]);
}
return 0;
}
| {
"code": [
"static int arm_gic_init(SysBusDevice *dev)",
" GICState *s = FROM_SYSBUS(GICState, dev);",
" agc->parent_init(dev);",
" sysbus_init_mmio(dev, &s->iomem);",
" sysbus_init_mmio(dev, &s->cpuiomem[i]);",
" return 0;",
" GICState *s = FROM_SYSBUS(GICState, dev);",
" return 0;",
" return 0;"
],
"line_no": [
1,
9,
15,
55,
61,
65,
9,
65,
65
]
} | static int FUNC_0(SysBusDevice *VAR_0)
{
int VAR_1;
GICState *s = FROM_SYSBUS(GICState, VAR_0);
ARMGICClass *agc = ARM_GIC_GET_CLASS(s);
agc->parent_init(VAR_0);
gic_init_irqs_and_distributor(s, s->num_irq);
memory_region_init_io(&s->cpuiomem[0], &gic_thiscpu_ops, s,
"gic_cpu", 0x100);
for (VAR_1 = 0; VAR_1 < NUM_CPU(s); VAR_1++) {
s->backref[VAR_1] = s;
memory_region_init_io(&s->cpuiomem[VAR_1+1], &gic_cpu_ops, &s->backref[VAR_1],
"gic_cpu", 0x100);
}
sysbus_init_mmio(VAR_0, &s->iomem);
for (VAR_1 = 0; VAR_1 <= NUM_CPU(s); VAR_1++) {
sysbus_init_mmio(VAR_0, &s->cpuiomem[VAR_1]);
}
return 0;
}
| [
"static int FUNC_0(SysBusDevice *VAR_0)\n{",
"int VAR_1;",
"GICState *s = FROM_SYSBUS(GICState, VAR_0);",
"ARMGICClass *agc = ARM_GIC_GET_CLASS(s);",
"agc->parent_init(VAR_0);",
"gic_init_irqs_and_distributor(s, s->num_irq);",
"memory_region_init_io(&s->cpuiomem[0], &gic_thiscpu_ops, s,\n\"gic_cpu\", 0x100);",
"for (VAR_1 = 0; VAR_1 < NUM_CPU(s); VAR_1++) {",
"s->backref[VAR_1] = s;",
"memory_region_init_io(&s->cpuiomem[VAR_1+1], &gic_cpu_ops, &s->backref[VAR_1],\n\"gic_cpu\", 0x100);",
"}",
"sysbus_init_mmio(VAR_0, &s->iomem);",
"for (VAR_1 = 0; VAR_1 <= NUM_CPU(s); VAR_1++) {",
"sysbus_init_mmio(VAR_0, &s->cpuiomem[VAR_1]);",
"}",
"return 0;",
"}"
]
| [
1,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
0
]
| [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
39,
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
]
|
10,392 | static bool addrrange_intersects(AddrRange r1, AddrRange r2)
{
return (r1.start >= r2.start && r1.start < r2.start + r2.size)
|| (r2.start >= r1.start && r2.start < r1.start + r1.size);
}
| true | qemu | d2963631dd54ddf0f46c151b7e3013e39bb78d3b | static bool addrrange_intersects(AddrRange r1, AddrRange r2)
{
return (r1.start >= r2.start && r1.start < r2.start + r2.size)
|| (r2.start >= r1.start && r2.start < r1.start + r1.size);
}
| {
"code": [
" return (r1.start >= r2.start && r1.start < r2.start + r2.size)",
" || (r2.start >= r1.start && r2.start < r1.start + r1.size);"
],
"line_no": [
5,
7
]
} | static bool FUNC_0(AddrRange r1, AddrRange r2)
{
return (r1.start >= r2.start && r1.start < r2.start + r2.size)
|| (r2.start >= r1.start && r2.start < r1.start + r1.size);
}
| [
"static bool FUNC_0(AddrRange r1, AddrRange r2)\n{",
"return (r1.start >= r2.start && r1.start < r2.start + r2.size)\n|| (r2.start >= r1.start && r2.start < r1.start + r1.size);",
"}"
]
| [
0,
1,
0
]
| [
[
1,
3
],
[
5,
7
],
[
9
]
]
|
10,393 | static void network_to_result(RDMARegisterResult *result)
{
result->rkey = ntohl(result->rkey);
result->host_addr = ntohll(result->host_addr);
};
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static void network_to_result(RDMARegisterResult *result)
{
result->rkey = ntohl(result->rkey);
result->host_addr = ntohll(result->host_addr);
};
| {
"code": [],
"line_no": []
} | static void FUNC_0(RDMARegisterResult *VAR_0)
{
VAR_0->rkey = ntohl(VAR_0->rkey);
VAR_0->host_addr = ntohll(VAR_0->host_addr);
};
| [
"static void FUNC_0(RDMARegisterResult *VAR_0)\n{",
"VAR_0->rkey = ntohl(VAR_0->rkey);",
"VAR_0->host_addr = ntohll(VAR_0->host_addr);",
"};"
]
| [
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
10,394 | static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, int width, enum PixelFormat srcFormat)
{
if(srcFormat == PIX_FMT_BGR24) {
__asm__ volatile(
"movq "MANGLE(ff_bgr24toY1Coeff)", %%mm5 \n\t"
"movq "MANGLE(ff_bgr24toY2Coeff)", %%mm6 \n\t"
:
);
} else {
__asm__ volatile(
"movq "MANGLE(ff_rgb24toY1Coeff)", %%mm5 \n\t"
"movq "MANGLE(ff_rgb24toY2Coeff)", %%mm6 \n\t"
:
);
}
__asm__ volatile(
"movq "MANGLE(ff_bgr24toYOffset)", %%mm4 \n\t"
"mov %2, %%"REG_a" \n\t"
"pxor %%mm7, %%mm7 \n\t"
"1: \n\t"
PREFETCH" 64(%0) \n\t"
"movd (%0), %%mm0 \n\t"
"movd 2(%0), %%mm1 \n\t"
"movd 6(%0), %%mm2 \n\t"
"movd 8(%0), %%mm3 \n\t"
"add $12, %0 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
"paddd %%mm1, %%mm0 \n\t"
"paddd %%mm3, %%mm2 \n\t"
"paddd %%mm4, %%mm0 \n\t"
"paddd %%mm4, %%mm2 \n\t"
"psrad $15, %%mm0 \n\t"
"psrad $15, %%mm2 \n\t"
"packssdw %%mm2, %%mm0 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"movd %%mm0, (%1, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: "+r" (src)
: "r" (dst+width), "g" ((x86_reg)-width)
: "%"REG_a
);
}
| true | FFmpeg | c3ab0004ae4dffc32494ae84dd15cfaa909a7884 | static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, int width, enum PixelFormat srcFormat)
{
if(srcFormat == PIX_FMT_BGR24) {
__asm__ volatile(
"movq "MANGLE(ff_bgr24toY1Coeff)", %%mm5 \n\t"
"movq "MANGLE(ff_bgr24toY2Coeff)", %%mm6 \n\t"
:
);
} else {
__asm__ volatile(
"movq "MANGLE(ff_rgb24toY1Coeff)", %%mm5 \n\t"
"movq "MANGLE(ff_rgb24toY2Coeff)", %%mm6 \n\t"
:
);
}
__asm__ volatile(
"movq "MANGLE(ff_bgr24toYOffset)", %%mm4 \n\t"
"mov %2, %%"REG_a" \n\t"
"pxor %%mm7, %%mm7 \n\t"
"1: \n\t"
PREFETCH" 64(%0) \n\t"
"movd (%0), %%mm0 \n\t"
"movd 2(%0), %%mm1 \n\t"
"movd 6(%0), %%mm2 \n\t"
"movd 8(%0), %%mm3 \n\t"
"add $12, %0 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
"paddd %%mm1, %%mm0 \n\t"
"paddd %%mm3, %%mm2 \n\t"
"paddd %%mm4, %%mm0 \n\t"
"paddd %%mm4, %%mm2 \n\t"
"psrad $15, %%mm0 \n\t"
"psrad $15, %%mm2 \n\t"
"packssdw %%mm2, %%mm0 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"movd %%mm0, (%1, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: "+r" (src)
: "r" (dst+width), "g" ((x86_reg)-width)
: "%"REG_a
);
}
| {
"code": [
"static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, int width, enum PixelFormat srcFormat)"
],
"line_no": [
1
]
} | static inline void FUNC_0(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, int width, enum PixelFormat srcFormat)
{
if(srcFormat == PIX_FMT_BGR24) {
__asm__ volatile(
"movq "MANGLE(ff_bgr24toY1Coeff)", %%mm5 \n\t"
"movq "MANGLE(ff_bgr24toY2Coeff)", %%mm6 \n\t"
:
);
} else {
__asm__ volatile(
"movq "MANGLE(ff_rgb24toY1Coeff)", %%mm5 \n\t"
"movq "MANGLE(ff_rgb24toY2Coeff)", %%mm6 \n\t"
:
);
}
__asm__ volatile(
"movq "MANGLE(ff_bgr24toYOffset)", %%mm4 \n\t"
"mov %2, %%"REG_a" \n\t"
"pxor %%mm7, %%mm7 \n\t"
"1: \n\t"
PREFETCH" 64(%0) \n\t"
"movd (%0), %%mm0 \n\t"
"movd 2(%0), %%mm1 \n\t"
"movd 6(%0), %%mm2 \n\t"
"movd 8(%0), %%mm3 \n\t"
"add $12, %0 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
"paddd %%mm1, %%mm0 \n\t"
"paddd %%mm3, %%mm2 \n\t"
"paddd %%mm4, %%mm0 \n\t"
"paddd %%mm4, %%mm2 \n\t"
"psrad $15, %%mm0 \n\t"
"psrad $15, %%mm2 \n\t"
"packssdw %%mm2, %%mm0 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"movd %%mm0, (%1, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: "+r" (src)
: "r" (dst+width), "g" ((x86_reg)-width)
: "%"REG_a
);
}
| [
"static inline void FUNC_0(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, int width, enum PixelFormat srcFormat)\n{",
"if(srcFormat == PIX_FMT_BGR24) {",
"__asm__ volatile(\n\"movq \"MANGLE(ff_bgr24toY1Coeff)\", %%mm5 \\n\\t\"\n\"movq \"MANGLE(ff_bgr24toY2Coeff)\", %%mm6 \\n\\t\"\n:\n);",
"} else {",
"__asm__ volatile(\n\"movq \"MANGLE(ff_rgb24toY1Coeff)\", %%mm5 \\n\\t\"\n\"movq \"MANGLE(ff_rgb24toY2Coeff)\", %%mm6 \\n\\t\"\n:\n);",
"}",
"__asm__ volatile(\n\"movq \"MANGLE(ff_bgr24toYOffset)\", %%mm4 \\n\\t\"\n\"mov %2, %%\"REG_a\" \\n\\t\"\n\"pxor %%mm7, %%mm7 \\n\\t\"\n\"1: \\n\\t\"\nPREFETCH\" 64(%0) \\n\\t\"\n\"movd (%0), %%mm0 \\n\\t\"\n\"movd 2(%0), %%mm1 \\n\\t\"\n\"movd 6(%0), %%mm2 \\n\\t\"\n\"movd 8(%0), %%mm3 \\n\\t\"\n\"add $12, %0 \\n\\t\"\n\"punpcklbw %%mm7, %%mm0 \\n\\t\"\n\"punpcklbw %%mm7, %%mm1 \\n\\t\"\n\"punpcklbw %%mm7, %%mm2 \\n\\t\"\n\"punpcklbw %%mm7, %%mm3 \\n\\t\"\n\"pmaddwd %%mm5, %%mm0 \\n\\t\"\n\"pmaddwd %%mm6, %%mm1 \\n\\t\"\n\"pmaddwd %%mm5, %%mm2 \\n\\t\"\n\"pmaddwd %%mm6, %%mm3 \\n\\t\"\n\"paddd %%mm1, %%mm0 \\n\\t\"\n\"paddd %%mm3, %%mm2 \\n\\t\"\n\"paddd %%mm4, %%mm0 \\n\\t\"\n\"paddd %%mm4, %%mm2 \\n\\t\"\n\"psrad $15, %%mm0 \\n\\t\"\n\"psrad $15, %%mm2 \\n\\t\"\n\"packssdw %%mm2, %%mm0 \\n\\t\"\n\"packuswb %%mm0, %%mm0 \\n\\t\"\n\"movd %%mm0, (%1, %%\"REG_a\") \\n\\t\"\n\"add $4, %%\"REG_a\" \\n\\t\"\n\" js 1b \\n\\t\"\n: \"+r\" (src)\n: \"r\" (dst+width), \"g\" ((x86_reg)-width)\n: \"%\"REG_a\n);",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
7
],
[
9,
11,
13,
15,
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,
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
101
],
[
103
]
]
|
10,395 | static int xvid_ff_2pass_after(struct xvid_context *ref,
xvid_plg_data_t *param) {
char *log = ref->twopassbuffer;
const char *frame_types = " ipbs";
char frame_type;
/* Quick bounds check */
if( log == NULL )
return XVID_ERR_FAIL;
/* Convert the type given to us into a character */
if( param->type < 5 && param->type > 0 ) {
frame_type = frame_types[param->type];
} else {
return XVID_ERR_FAIL;
}
snprintf(BUFFER_CAT(log), BUFFER_REMAINING(log),
"%c %d %d %d %d %d %d\n",
frame_type, param->stats.quant, param->stats.kblks, param->stats.mblks,
param->stats.ublks, param->stats.length, param->stats.hlength);
return 0;
}
| false | FFmpeg | f929ab0569ff31ed5a59b0b0adb7ce09df3fca39 | static int xvid_ff_2pass_after(struct xvid_context *ref,
xvid_plg_data_t *param) {
char *log = ref->twopassbuffer;
const char *frame_types = " ipbs";
char frame_type;
if( log == NULL )
return XVID_ERR_FAIL;
if( param->type < 5 && param->type > 0 ) {
frame_type = frame_types[param->type];
} else {
return XVID_ERR_FAIL;
}
snprintf(BUFFER_CAT(log), BUFFER_REMAINING(log),
"%c %d %d %d %d %d %d\n",
frame_type, param->stats.quant, param->stats.kblks, param->stats.mblks,
param->stats.ublks, param->stats.length, param->stats.hlength);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct xvid_context *VAR_0,
xvid_plg_data_t *VAR_1) {
char *VAR_2 = VAR_0->twopassbuffer;
const char *VAR_3 = " ipbs";
char VAR_4;
if( VAR_2 == NULL )
return XVID_ERR_FAIL;
if( VAR_1->type < 5 && VAR_1->type > 0 ) {
VAR_4 = VAR_3[VAR_1->type];
} else {
return XVID_ERR_FAIL;
}
snprintf(BUFFER_CAT(VAR_2), BUFFER_REMAINING(VAR_2),
"%c %d %d %d %d %d %d\n",
VAR_4, VAR_1->stats.quant, VAR_1->stats.kblks, VAR_1->stats.mblks,
VAR_1->stats.ublks, VAR_1->stats.length, VAR_1->stats.hlength);
return 0;
}
| [
"static int FUNC_0(struct xvid_context *VAR_0,\nxvid_plg_data_t *VAR_1) {",
"char *VAR_2 = VAR_0->twopassbuffer;",
"const char *VAR_3 = \" ipbs\";",
"char VAR_4;",
"if( VAR_2 == NULL )\nreturn XVID_ERR_FAIL;",
"if( VAR_1->type < 5 && VAR_1->type > 0 ) {",
"VAR_4 = VAR_3[VAR_1->type];",
"} else {",
"return XVID_ERR_FAIL;",
"}",
"snprintf(BUFFER_CAT(VAR_2), BUFFER_REMAINING(VAR_2),\n\"%c %d %d %d %d %d %d\\n\",\nVAR_4, VAR_1->stats.quant, VAR_1->stats.kblks, VAR_1->stats.mblks,\nVAR_1->stats.ublks, VAR_1->stats.length, VAR_1->stats.hlength);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15,
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37,
39,
41
],
[
45
],
[
47
]
]
|
10,396 | int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
struct vdpau_picture_context *pic_ctx)
{
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
AVVDPAUContext *hwctx = avctx->hwaccel_context;
VdpVideoSurface surf = ff_vdpau_get_surface_id(frame);
VdpStatus status;
int val;
val = ff_vdpau_common_reinit(avctx);
if (val < 0)
return val;
#if FF_API_BUFS_VDPAU
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->info = pic_ctx->info;
hwctx->bitstream_buffers = pic_ctx->bitstream_buffers;
hwctx->bitstream_buffers_used = pic_ctx->bitstream_buffers_used;
hwctx->bitstream_buffers_allocated = pic_ctx->bitstream_buffers_allocated;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (!hwctx->render) {
status = hwctx->render2(avctx, frame, (void *)&pic_ctx->info,
pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
} else
status = vdctx->render(vdctx->decoder, surf, (void *)&pic_ctx->info,
pic_ctx->bitstream_buffers_used,
pic_ctx->bitstream_buffers);
av_freep(&pic_ctx->bitstream_buffers);
#if FF_API_BUFS_VDPAU
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->bitstream_buffers = NULL;
hwctx->bitstream_buffers_used = 0;
hwctx->bitstream_buffers_allocated = 0;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return vdpau_error(status);
}
| false | FFmpeg | 0e57c051181c06d9a3468d5e072ded827ed09a53 | int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
struct vdpau_picture_context *pic_ctx)
{
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
AVVDPAUContext *hwctx = avctx->hwaccel_context;
VdpVideoSurface surf = ff_vdpau_get_surface_id(frame);
VdpStatus status;
int val;
val = ff_vdpau_common_reinit(avctx);
if (val < 0)
return val;
#if FF_API_BUFS_VDPAU
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->info = pic_ctx->info;
hwctx->bitstream_buffers = pic_ctx->bitstream_buffers;
hwctx->bitstream_buffers_used = pic_ctx->bitstream_buffers_used;
hwctx->bitstream_buffers_allocated = pic_ctx->bitstream_buffers_allocated;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (!hwctx->render) {
status = hwctx->render2(avctx, frame, (void *)&pic_ctx->info,
pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
} else
status = vdctx->render(vdctx->decoder, surf, (void *)&pic_ctx->info,
pic_ctx->bitstream_buffers_used,
pic_ctx->bitstream_buffers);
av_freep(&pic_ctx->bitstream_buffers);
#if FF_API_BUFS_VDPAU
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->bitstream_buffers = NULL;
hwctx->bitstream_buffers_used = 0;
hwctx->bitstream_buffers_allocated = 0;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return vdpau_error(status);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1,
struct vdpau_picture_context *VAR_2)
{
VDPAUContext *vdctx = VAR_0->internal->hwaccel_priv_data;
AVVDPAUContext *hwctx = VAR_0->hwaccel_context;
VdpVideoSurface surf = ff_vdpau_get_surface_id(VAR_1);
VdpStatus status;
int VAR_3;
VAR_3 = ff_vdpau_common_reinit(VAR_0);
if (VAR_3 < 0)
return VAR_3;
#if FF_API_BUFS_VDPAU
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->info = VAR_2->info;
hwctx->bitstream_buffers = VAR_2->bitstream_buffers;
hwctx->bitstream_buffers_used = VAR_2->bitstream_buffers_used;
hwctx->bitstream_buffers_allocated = VAR_2->bitstream_buffers_allocated;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (!hwctx->render) {
status = hwctx->render2(VAR_0, VAR_1, (void *)&VAR_2->info,
VAR_2->bitstream_buffers_used, VAR_2->bitstream_buffers);
} else
status = vdctx->render(vdctx->decoder, surf, (void *)&VAR_2->info,
VAR_2->bitstream_buffers_used,
VAR_2->bitstream_buffers);
av_freep(&VAR_2->bitstream_buffers);
#if FF_API_BUFS_VDPAU
FF_DISABLE_DEPRECATION_WARNINGS
hwctx->bitstream_buffers = NULL;
hwctx->bitstream_buffers_used = 0;
hwctx->bitstream_buffers_allocated = 0;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return vdpau_error(status);
}
| [
"int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1,\nstruct vdpau_picture_context *VAR_2)\n{",
"VDPAUContext *vdctx = VAR_0->internal->hwaccel_priv_data;",
"AVVDPAUContext *hwctx = VAR_0->hwaccel_context;",
"VdpVideoSurface surf = ff_vdpau_get_surface_id(VAR_1);",
"VdpStatus status;",
"int VAR_3;",
"VAR_3 = ff_vdpau_common_reinit(VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"#if FF_API_BUFS_VDPAU\nFF_DISABLE_DEPRECATION_WARNINGS\nhwctx->info = VAR_2->info;",
"hwctx->bitstream_buffers = VAR_2->bitstream_buffers;",
"hwctx->bitstream_buffers_used = VAR_2->bitstream_buffers_used;",
"hwctx->bitstream_buffers_allocated = VAR_2->bitstream_buffers_allocated;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nif (!hwctx->render) {",
"status = hwctx->render2(VAR_0, VAR_1, (void *)&VAR_2->info,\nVAR_2->bitstream_buffers_used, VAR_2->bitstream_buffers);",
"} else",
"status = vdctx->render(vdctx->decoder, surf, (void *)&VAR_2->info,\nVAR_2->bitstream_buffers_used,\nVAR_2->bitstream_buffers);",
"av_freep(&VAR_2->bitstream_buffers);",
"#if FF_API_BUFS_VDPAU\nFF_DISABLE_DEPRECATION_WARNINGS\nhwctx->bitstream_buffers = NULL;",
"hwctx->bitstream_buffers_used = 0;",
"hwctx->bitstream_buffers_allocated = 0;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nreturn vdpau_error(status);",
"}"
]
| [
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
],
[
27,
29,
31
],
[
33
],
[
35
],
[
37
],
[
39,
41,
45
],
[
47,
49
],
[
51
],
[
53,
55,
57
],
[
61
],
[
65,
67,
69
],
[
71
],
[
73
],
[
75,
77,
81
],
[
83
]
]
|
10,397 | static CheckasmFunc *get_func(const char *name, int length)
{
CheckasmFunc *f, **f_ptr = &state.funcs;
/* Search the tree for a matching node */
while ((f = *f_ptr)) {
int cmp = cmp_func_names(name, f->name);
if (!cmp)
return f;
f_ptr = &f->child[(cmp > 0)];
}
/* Allocate and insert a new node into the tree */
f = *f_ptr = checkasm_malloc(sizeof(CheckasmFunc) + length);
memcpy(f->name, name, length+1);
return f;
}
| false | FFmpeg | 5405584b7b54ca889c341743de1d58792449830d | static CheckasmFunc *get_func(const char *name, int length)
{
CheckasmFunc *f, **f_ptr = &state.funcs;
while ((f = *f_ptr)) {
int cmp = cmp_func_names(name, f->name);
if (!cmp)
return f;
f_ptr = &f->child[(cmp > 0)];
}
f = *f_ptr = checkasm_malloc(sizeof(CheckasmFunc) + length);
memcpy(f->name, name, length+1);
return f;
}
| {
"code": [],
"line_no": []
} | static CheckasmFunc *FUNC_0(const char *name, int length)
{
CheckasmFunc *f, **f_ptr = &state.funcs;
while ((f = *f_ptr)) {
int VAR_0 = cmp_func_names(name, f->name);
if (!VAR_0)
return f;
f_ptr = &f->child[(VAR_0 > 0)];
}
f = *f_ptr = checkasm_malloc(sizeof(CheckasmFunc) + length);
memcpy(f->name, name, length+1);
return f;
}
| [
"static CheckasmFunc *FUNC_0(const char *name, int length)\n{",
"CheckasmFunc *f, **f_ptr = &state.funcs;",
"while ((f = *f_ptr)) {",
"int VAR_0 = cmp_func_names(name, f->name);",
"if (!VAR_0)\nreturn f;",
"f_ptr = &f->child[(VAR_0 > 0)];",
"}",
"f = *f_ptr = checkasm_malloc(sizeof(CheckasmFunc) + length);",
"memcpy(f->name, name, length+1);",
"return f;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
11
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
29
],
[
31
],
[
35
],
[
37
]
]
|
10,398 | static void unref_picture(H264Context *h, Picture *pic)
{
int off = offsetof(Picture, tf) + sizeof(pic->tf);
int i;
if (!pic->f.data[0])
return;
ff_thread_release_buffer(h->avctx, &pic->tf);
av_buffer_unref(&pic->hwaccel_priv_buf);
av_buffer_unref(&pic->qscale_table_buf);
av_buffer_unref(&pic->mb_type_buf);
for (i = 0; i < 2; i++) {
av_buffer_unref(&pic->motion_val_buf[i]);
av_buffer_unref(&pic->ref_index_buf[i]);
}
memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
}
| false | FFmpeg | a553c6a347d3d28d7ee44c3df3d5c4ee780dba23 | static void unref_picture(H264Context *h, Picture *pic)
{
int off = offsetof(Picture, tf) + sizeof(pic->tf);
int i;
if (!pic->f.data[0])
return;
ff_thread_release_buffer(h->avctx, &pic->tf);
av_buffer_unref(&pic->hwaccel_priv_buf);
av_buffer_unref(&pic->qscale_table_buf);
av_buffer_unref(&pic->mb_type_buf);
for (i = 0; i < 2; i++) {
av_buffer_unref(&pic->motion_val_buf[i]);
av_buffer_unref(&pic->ref_index_buf[i]);
}
memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(H264Context *VAR_0, Picture *VAR_1)
{
int VAR_2 = offsetof(Picture, tf) + sizeof(VAR_1->tf);
int VAR_3;
if (!VAR_1->f.data[0])
return;
ff_thread_release_buffer(VAR_0->avctx, &VAR_1->tf);
av_buffer_unref(&VAR_1->hwaccel_priv_buf);
av_buffer_unref(&VAR_1->qscale_table_buf);
av_buffer_unref(&VAR_1->mb_type_buf);
for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {
av_buffer_unref(&VAR_1->motion_val_buf[VAR_3]);
av_buffer_unref(&VAR_1->ref_index_buf[VAR_3]);
}
memset((uint8_t*)VAR_1 + VAR_2, 0, sizeof(*VAR_1) - VAR_2);
}
| [
"static void FUNC_0(H264Context *VAR_0, Picture *VAR_1)\n{",
"int VAR_2 = offsetof(Picture, tf) + sizeof(VAR_1->tf);",
"int VAR_3;",
"if (!VAR_1->f.data[0])\nreturn;",
"ff_thread_release_buffer(VAR_0->avctx, &VAR_1->tf);",
"av_buffer_unref(&VAR_1->hwaccel_priv_buf);",
"av_buffer_unref(&VAR_1->qscale_table_buf);",
"av_buffer_unref(&VAR_1->mb_type_buf);",
"for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {",
"av_buffer_unref(&VAR_1->motion_val_buf[VAR_3]);",
"av_buffer_unref(&VAR_1->ref_index_buf[VAR_3]);",
"}",
"memset((uint8_t*)VAR_1 + VAR_2, 0, sizeof(*VAR_1) - VAR_2);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
]
]
|
10,400 | void ff_free_parser_state(AVFormatContext *s, AVParserState *state)
{
int i;
AVParserStreamState *ss;
if (!state)
return;
for (i = 0; i < state->nb_streams; i++) {
ss = &state->stream_states[i];
if (ss->parser)
av_parser_close(ss->parser);
av_free_packet(&ss->cur_pkt);
}
free_packet_list(state->packet_buffer);
free_packet_list(state->raw_packet_buffer);
av_free(state->stream_states);
av_free(state);
}
| false | FFmpeg | 27c7ca9c12bb42d5c44d46f24cd970469d0ef55a | void ff_free_parser_state(AVFormatContext *s, AVParserState *state)
{
int i;
AVParserStreamState *ss;
if (!state)
return;
for (i = 0; i < state->nb_streams; i++) {
ss = &state->stream_states[i];
if (ss->parser)
av_parser_close(ss->parser);
av_free_packet(&ss->cur_pkt);
}
free_packet_list(state->packet_buffer);
free_packet_list(state->raw_packet_buffer);
av_free(state->stream_states);
av_free(state);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AVFormatContext *VAR_0, AVParserState *VAR_1)
{
int VAR_2;
AVParserStreamState *ss;
if (!VAR_1)
return;
for (VAR_2 = 0; VAR_2 < VAR_1->nb_streams; VAR_2++) {
ss = &VAR_1->stream_states[VAR_2];
if (ss->parser)
av_parser_close(ss->parser);
av_free_packet(&ss->cur_pkt);
}
free_packet_list(VAR_1->packet_buffer);
free_packet_list(VAR_1->raw_packet_buffer);
av_free(VAR_1->stream_states);
av_free(VAR_1);
}
| [
"void FUNC_0(AVFormatContext *VAR_0, AVParserState *VAR_1)\n{",
"int VAR_2;",
"AVParserStreamState *ss;",
"if (!VAR_1)\nreturn;",
"for (VAR_2 = 0; VAR_2 < VAR_1->nb_streams; VAR_2++) {",
"ss = &VAR_1->stream_states[VAR_2];",
"if (ss->parser)\nav_parser_close(ss->parser);",
"av_free_packet(&ss->cur_pkt);",
"}",
"free_packet_list(VAR_1->packet_buffer);",
"free_packet_list(VAR_1->raw_packet_buffer);",
"av_free(VAR_1->stream_states);",
"av_free(VAR_1);",
"}"
]
| [
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
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
]
]
|
10,401 | static int mjpeg_decode_com(MJpegDecodeContext *s)
{
/* XXX: verify len field validity */
int len = get_bits(&s->gb, 16);
if (len >= 2 && len < 32768) {
/* XXX: any better upper bound */
uint8_t *cbuf = av_malloc(len - 1);
if (cbuf) {
int i;
for (i = 0; i < len - 2; i++)
cbuf[i] = get_bits(&s->gb, 8);
if (i > 0 && cbuf[i-1] == '\n')
cbuf[i-1] = 0;
else
cbuf[i] = 0;
if(s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, "mjpeg comment: '%s'\n", cbuf);
/* buggy avid, it puts EOI only at every 10th frame */
if (!strcmp(cbuf, "AVID"))
{
s->buggy_avid = 1;
// if (s->first_picture)
// printf("mjpeg: workarounding buggy AVID\n");
}
else if(!strcmp(cbuf, "CS=ITU601")){
s->cs_itu601= 1;
}
av_free(cbuf);
}
}
return 0;
}
| true | FFmpeg | e33943728e775ef9f3239fe950f3be4fa405d1f2 | static int mjpeg_decode_com(MJpegDecodeContext *s)
{
int len = get_bits(&s->gb, 16);
if (len >= 2 && len < 32768) {
uint8_t *cbuf = av_malloc(len - 1);
if (cbuf) {
int i;
for (i = 0; i < len - 2; i++)
cbuf[i] = get_bits(&s->gb, 8);
if (i > 0 && cbuf[i-1] == '\n')
cbuf[i-1] = 0;
else
cbuf[i] = 0;
if(s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, "mjpeg comment: '%s'\n", cbuf);
if (!strcmp(cbuf, "AVID"))
{
s->buggy_avid = 1;
}
else if(!strcmp(cbuf, "CS=ITU601")){
s->cs_itu601= 1;
}
av_free(cbuf);
}
}
return 0;
}
| {
"code": [
" if (len >= 2 && len < 32768) {"
],
"line_no": [
9
]
} | static int FUNC_0(MJpegDecodeContext *VAR_0)
{
int VAR_1 = get_bits(&VAR_0->gb, 16);
if (VAR_1 >= 2 && VAR_1 < 32768) {
uint8_t *cbuf = av_malloc(VAR_1 - 1);
if (cbuf) {
int VAR_2;
for (VAR_2 = 0; VAR_2 < VAR_1 - 2; VAR_2++)
cbuf[VAR_2] = get_bits(&VAR_0->gb, 8);
if (VAR_2 > 0 && cbuf[VAR_2-1] == '\n')
cbuf[VAR_2-1] = 0;
else
cbuf[VAR_2] = 0;
if(VAR_0->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(VAR_0->avctx, AV_LOG_INFO, "mjpeg comment: '%VAR_0'\n", cbuf);
if (!strcmp(cbuf, "AVID"))
{
VAR_0->buggy_avid = 1;
}
else if(!strcmp(cbuf, "CS=ITU601")){
VAR_0->cs_itu601= 1;
}
av_free(cbuf);
}
}
return 0;
}
| [
"static int FUNC_0(MJpegDecodeContext *VAR_0)\n{",
"int VAR_1 = get_bits(&VAR_0->gb, 16);",
"if (VAR_1 >= 2 && VAR_1 < 32768) {",
"uint8_t *cbuf = av_malloc(VAR_1 - 1);",
"if (cbuf) {",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < VAR_1 - 2; VAR_2++)",
"cbuf[VAR_2] = get_bits(&VAR_0->gb, 8);",
"if (VAR_2 > 0 && cbuf[VAR_2-1] == '\\n')\ncbuf[VAR_2-1] = 0;",
"else\ncbuf[VAR_2] = 0;",
"if(VAR_0->avctx->debug & FF_DEBUG_PICT_INFO)\nav_log(VAR_0->avctx, AV_LOG_INFO, \"mjpeg comment: '%VAR_0'\\n\", cbuf);",
"if (!strcmp(cbuf, \"AVID\"))\n{",
"VAR_0->buggy_avid = 1;",
"}",
"else if(!strcmp(cbuf, \"CS=ITU601\")){",
"VAR_0->cs_itu601= 1;",
"}",
"av_free(cbuf);",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29
],
[
33,
35
],
[
41,
43
],
[
45
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
]
]
|
10,402 | static void xhci_runtime_write(void *ptr, hwaddr reg,
uint64_t val, unsigned size)
{
XHCIState *xhci = ptr;
int v = (reg - 0x20) / 0x20;
XHCIInterrupter *intr = &xhci->intr[v];
trace_usb_xhci_runtime_write(reg, val);
if (reg < 0x20) {
trace_usb_xhci_unimplemented("runtime write", reg);
return;
switch (reg & 0x1f) {
case 0x00: /* IMAN */
if (val & IMAN_IP) {
intr->iman &= ~IMAN_IP;
intr->iman &= ~IMAN_IE;
intr->iman |= val & IMAN_IE;
if (v == 0) {
xhci_intx_update(xhci);
xhci_msix_update(xhci, v);
break;
case 0x04: /* IMOD */
intr->imod = val;
break;
case 0x08: /* ERSTSZ */
intr->erstsz = val & 0xffff;
break;
case 0x10: /* ERSTBA low */
/* XXX NEC driver bug: it doesn't align this to 64 bytes
intr->erstba_low = val & 0xffffffc0; */
intr->erstba_low = val & 0xfffffff0;
break;
case 0x14: /* ERSTBA high */
intr->erstba_high = val;
xhci_er_reset(xhci, v);
break;
case 0x18: /* ERDP low */
intr->erdp_low &= ~ERDP_EHB;
intr->erdp_low = (val & ~ERDP_EHB) | (intr->erdp_low & ERDP_EHB);
break;
case 0x1c: /* ERDP high */
intr->erdp_high = val;
xhci_events_update(xhci, v);
break;
default:
trace_usb_xhci_unimplemented("oper write", reg);
| true | qemu | 7da76e12cc5cc902dda4c168d8d608fd4e61cbc5 | static void xhci_runtime_write(void *ptr, hwaddr reg,
uint64_t val, unsigned size)
{
XHCIState *xhci = ptr;
int v = (reg - 0x20) / 0x20;
XHCIInterrupter *intr = &xhci->intr[v];
trace_usb_xhci_runtime_write(reg, val);
if (reg < 0x20) {
trace_usb_xhci_unimplemented("runtime write", reg);
return;
switch (reg & 0x1f) {
case 0x00:
if (val & IMAN_IP) {
intr->iman &= ~IMAN_IP;
intr->iman &= ~IMAN_IE;
intr->iman |= val & IMAN_IE;
if (v == 0) {
xhci_intx_update(xhci);
xhci_msix_update(xhci, v);
break;
case 0x04:
intr->imod = val;
break;
case 0x08:
intr->erstsz = val & 0xffff;
break;
case 0x10:
intr->erstba_low = val & 0xfffffff0;
break;
case 0x14:
intr->erstba_high = val;
xhci_er_reset(xhci, v);
break;
case 0x18:
intr->erdp_low &= ~ERDP_EHB;
intr->erdp_low = (val & ~ERDP_EHB) | (intr->erdp_low & ERDP_EHB);
break;
case 0x1c:
intr->erdp_high = val;
xhci_events_update(xhci, v);
break;
default:
trace_usb_xhci_unimplemented("oper write", reg);
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
XHCIState *xhci = VAR_0;
int VAR_4 = (VAR_1 - 0x20) / 0x20;
XHCIInterrupter *intr = &xhci->intr[VAR_4];
trace_usb_xhci_runtime_write(VAR_1, VAR_2);
if (VAR_1 < 0x20) {
trace_usb_xhci_unimplemented("runtime write", VAR_1);
return;
switch (VAR_1 & 0x1f) {
case 0x00:
if (VAR_2 & IMAN_IP) {
intr->iman &= ~IMAN_IP;
intr->iman &= ~IMAN_IE;
intr->iman |= VAR_2 & IMAN_IE;
if (VAR_4 == 0) {
xhci_intx_update(xhci);
xhci_msix_update(xhci, VAR_4);
break;
case 0x04:
intr->imod = VAR_2;
break;
case 0x08:
intr->erstsz = VAR_2 & 0xffff;
break;
case 0x10:
intr->erstba_low = VAR_2 & 0xfffffff0;
break;
case 0x14:
intr->erstba_high = VAR_2;
xhci_er_reset(xhci, VAR_4);
break;
case 0x18:
intr->erdp_low &= ~ERDP_EHB;
intr->erdp_low = (VAR_2 & ~ERDP_EHB) | (intr->erdp_low & ERDP_EHB);
break;
case 0x1c:
intr->erdp_high = VAR_2;
xhci_events_update(xhci, VAR_4);
break;
default:
trace_usb_xhci_unimplemented("oper write", VAR_1);
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"XHCIState *xhci = VAR_0;",
"int VAR_4 = (VAR_1 - 0x20) / 0x20;",
"XHCIInterrupter *intr = &xhci->intr[VAR_4];",
"trace_usb_xhci_runtime_write(VAR_1, VAR_2);",
"if (VAR_1 < 0x20) {",
"trace_usb_xhci_unimplemented(\"runtime write\", VAR_1);",
"return;",
"switch (VAR_1 & 0x1f) {",
"case 0x00:\nif (VAR_2 & IMAN_IP) {",
"intr->iman &= ~IMAN_IP;",
"intr->iman &= ~IMAN_IE;",
"intr->iman |= VAR_2 & IMAN_IE;",
"if (VAR_4 == 0) {",
"xhci_intx_update(xhci);",
"xhci_msix_update(xhci, VAR_4);",
"break;",
"case 0x04:\nintr->imod = VAR_2;",
"break;",
"case 0x08:\nintr->erstsz = VAR_2 & 0xffff;",
"break;",
"case 0x10:\nintr->erstba_low = VAR_2 & 0xfffffff0;",
"break;",
"case 0x14:\nintr->erstba_high = VAR_2;",
"xhci_er_reset(xhci, VAR_4);",
"break;",
"case 0x18:\nintr->erdp_low &= ~ERDP_EHB;",
"intr->erdp_low = (VAR_2 & ~ERDP_EHB) | (intr->erdp_low & ERDP_EHB);",
"break;",
"case 0x1c:\nintr->erdp_high = VAR_2;",
"xhci_events_update(xhci, VAR_4);",
"break;",
"default:\ntrace_usb_xhci_unimplemented(\"oper write\", 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,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
26
],
[
28,
30
],
[
32
],
[
35
],
[
37
],
[
39
],
[
41
],
[
44
],
[
46
],
[
48,
50
],
[
52
],
[
54,
56
],
[
58
],
[
60,
66
],
[
68
],
[
70,
72
],
[
74
],
[
76
],
[
78,
81
],
[
84
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105,
107
]
]
|
10,403 | static void test_ide_none(void)
{
char *argv[256];
setup_common(argv, ARRAY_SIZE(argv));
qtest_start(g_strjoinv(" ", argv));
test_cmos();
qtest_end();
}
| true | qemu | 2c8f86961b6eaac705be21bc98299f5517eb0b6b | static void test_ide_none(void)
{
char *argv[256];
setup_common(argv, ARRAY_SIZE(argv));
qtest_start(g_strjoinv(" ", argv));
test_cmos();
qtest_end();
}
| {
"code": [
" char *argv[256];",
" setup_common(argv, ARRAY_SIZE(argv));",
" qtest_start(g_strjoinv(\" \", argv));",
" char *argv[256];",
" qtest_start(g_strjoinv(\" \", argv));",
" qtest_start(g_strjoinv(\" \", argv));",
" char *argv[256];",
" qtest_start(g_strjoinv(\" \", argv));"
],
"line_no": [
5,
9,
11,
5,
11,
11,
5,
11
]
} | static void FUNC_0(void)
{
char *VAR_0[256];
setup_common(VAR_0, ARRAY_SIZE(VAR_0));
qtest_start(g_strjoinv(" ", VAR_0));
test_cmos();
qtest_end();
}
| [
"static void FUNC_0(void)\n{",
"char *VAR_0[256];",
"setup_common(VAR_0, ARRAY_SIZE(VAR_0));",
"qtest_start(g_strjoinv(\" \", VAR_0));",
"test_cmos();",
"qtest_end();",
"}"
]
| [
0,
1,
1,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
]
|
10,404 | int ff_dca_xll_decode_audio(DCAContext *s, AVFrame *frame)
{
/* FIXME: Decodes only the first frequency band. */
int seg, chset_i;
/* Coding parameters for each channel set. */
struct coding_params {
int seg_type;
int rice_code_flag[16];
int pancAuxABIT[16];
int pancABIT0[16]; /* Not sure what this is */
int pancABIT[16]; /* Not sure what this is */
int nSamplPart0[16];
} param_state[16];
GetBitContext *gb = &s->xll_navi.gb;
int *history;
/* Layout: First the sample buffer for one segment per channel,
* followed by history buffers of DCA_XLL_AORDER_MAX samples for
* each channel. */
av_fast_malloc(&s->xll_sample_buf, &s->xll_sample_buf_size,
(s->xll_smpl_in_seg + DCA_XLL_AORDER_MAX) *
s->xll_channels * sizeof(*s->xll_sample_buf));
if (!s->xll_sample_buf)
return AVERROR(ENOMEM);
history = s->xll_sample_buf + s->xll_smpl_in_seg * s->xll_channels;
for (seg = 0; seg < s->xll_segments; seg++) {
unsigned in_channel;
for (chset_i = in_channel = 0; chset_i < s->xll_nch_sets; chset_i++) {
/* The spec isn't very explicit, but I think the NAVI sizes are in bytes. */
int end_pos = get_bits_count(gb) +
8 * s->xll_navi.chset_size[0][seg][chset_i];
int i, j;
struct coding_params *params = ¶m_state[chset_i];
/* I think this flag means that we should keep seg_type and
* other parameters from the previous segment. */
int use_seg_state_code_param;
XllChSetSubHeader *chset = &s->xll_chsets[chset_i];
if (in_channel >= s->avctx->channels)
/* FIXME: Could go directly to next segment */
goto next_chset;
if (s->avctx->sample_rate != chset->sampling_frequency) {
av_log(s->avctx, AV_LOG_WARNING,
"XLL: unexpected chset sample rate %d, expected %d\n",
chset->sampling_frequency, s->avctx->sample_rate);
goto next_chset;
}
if (seg != 0)
use_seg_state_code_param = get_bits(gb, 1);
else
use_seg_state_code_param = 0;
if (!use_seg_state_code_param) {
int num_param_sets, i;
unsigned bits4ABIT;
params->seg_type = get_bits(gb, 1);
num_param_sets = params->seg_type ? 1 : chset->channels;
if (chset->bit_width > 16) {
bits4ABIT = 5;
} else {
if (chset->bit_width > 8)
bits4ABIT = 4;
else
bits4ABIT = 3;
if (s->xll_nch_sets > 1)
bits4ABIT++;
}
for (i = 0; i < num_param_sets; i++) {
params->rice_code_flag[i] = get_bits(gb, 1);
if (!params->seg_type && params->rice_code_flag[i] && get_bits(gb, 1))
params->pancAuxABIT[i] = get_bits(gb, bits4ABIT) + 1;
else
params->pancAuxABIT[i] = 0;
}
for (i = 0; i < num_param_sets; i++) {
if (!seg) {
/* Parameters for part 1 */
params->pancABIT0[i] = get_bits(gb, bits4ABIT);
if (params->rice_code_flag[i] == 0 && params->pancABIT0[i] > 0)
/* For linear code */
params->pancABIT0[i]++;
/* NOTE: In the spec, not indexed by band??? */
if (params->seg_type == 0)
params->nSamplPart0[i] = chset->adapt_order[0][i];
else
params->nSamplPart0[i] = chset->adapt_order_max[0];
} else
params->nSamplPart0[i] = 0;
/* Parameters for part 2 */
params->pancABIT[i] = get_bits(gb, bits4ABIT);
if (params->rice_code_flag[i] == 0 && params->pancABIT[i] > 0)
/* For linear code */
params->pancABIT[i]++;
}
}
for (i = 0; i < chset->channels; i++) {
int param_index = params->seg_type ? 0 : i;
int bits = params->pancABIT0[param_index];
int part0 = params->nSamplPart0[param_index];
int *sample_buf = s->xll_sample_buf +
(in_channel + i) * s->xll_smpl_in_seg;
if (!params->rice_code_flag[param_index]) {
/* Linear code */
if (bits)
for (j = 0; j < part0; j++)
sample_buf[j] = get_bits_sm(gb, bits);
else
memset(sample_buf, 0, part0 * sizeof(sample_buf[0]));
/* Second part */
bits = params->pancABIT[param_index];
if (bits)
for (j = part0; j < s->xll_smpl_in_seg; j++)
sample_buf[j] = get_bits_sm(gb, bits);
else
memset(sample_buf + part0, 0,
(s->xll_smpl_in_seg - part0) * sizeof(sample_buf[0]));
} else {
int aux_bits = params->pancAuxABIT[param_index];
for (j = 0; j < part0; j++) {
/* FIXME: Is this identical to Golomb code? */
int t = get_unary(gb, 1, 33) << bits;
/* FIXME: Could move this test outside of the loop, for efficiency. */
if (bits)
t |= get_bits(gb, bits);
sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1);
}
/* Second part */
bits = params->pancABIT[param_index];
/* Follow the spec's suggestion of using the
* buffer also to store the hybrid-rice flags. */
memset(sample_buf + part0, 0,
(s->xll_smpl_in_seg - part0) * sizeof(sample_buf[0]));
if (aux_bits > 0) {
/* For hybrid rice encoding, some samples are linearly
* coded. According to the spec, "nBits4SamplLoci" bits
* are used for each index, but this value is not
* defined. I guess we should use log2(xll_smpl_in_seg)
* bits. */
int count = get_bits(gb, s->xll_log_smpl_in_seg);
av_log(s->avctx, AV_LOG_DEBUG, "aux count %d (bits %d)\n",
count, s->xll_log_smpl_in_seg);
for (j = 0; j < count; j++)
sample_buf[get_bits(gb, s->xll_log_smpl_in_seg)] = 1;
}
for (j = part0; j < s->xll_smpl_in_seg; j++) {
if (!sample_buf[j]) {
int t = get_unary(gb, 1, 33);
if (bits)
t = (t << bits) | get_bits(gb, bits);
sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1);
} else
sample_buf[j] = get_bits_sm(gb, aux_bits);
}
}
}
for (i = 0; i < chset->channels; i++) {
unsigned adapt_order = chset->adapt_order[0][i];
int *sample_buf = s->xll_sample_buf +
(in_channel + i) * s->xll_smpl_in_seg;
int *prev = history + (in_channel + i) * DCA_XLL_AORDER_MAX;
if (!adapt_order) {
unsigned order;
for (order = chset->fixed_order[0][i]; order > 0; order--) {
unsigned j;
for (j = 1; j < s->xll_smpl_in_seg; j++)
sample_buf[j] += sample_buf[j - 1];
}
} else
/* Inverse adaptive prediction, in place. */
dca_xll_inv_adapt_pred(sample_buf, s->xll_smpl_in_seg,
adapt_order, seg ? prev : NULL,
chset->lpc_refl_coeffs_q_ind[0][i]);
memcpy(prev, sample_buf + s->xll_smpl_in_seg - DCA_XLL_AORDER_MAX,
DCA_XLL_AORDER_MAX * sizeof(*prev));
}
for (i = 1; i < chset->channels; i += 2) {
int coeff = chset->pw_ch_pairs_coeffs[0][i / 2];
if (coeff != 0) {
int *sample_buf = s->xll_sample_buf +
(in_channel + i) * s->xll_smpl_in_seg;
int *prev = sample_buf - s->xll_smpl_in_seg;
unsigned j;
for (j = 0; j < s->xll_smpl_in_seg; j++)
/* Shift is unspecified, but should apparently be 3. */
sample_buf[j] += ((int64_t) coeff * prev[j] + 4) >> 3;
}
}
if (s->xll_scalable_lsb) {
int lsb_start = end_pos - 8 * chset->lsb_fsize[0] -
8 * (s->xll_banddata_crc & 2);
int done;
i = get_bits_count(gb);
if (i > lsb_start) {
av_log(s->avctx, AV_LOG_ERROR,
"chset data lsb exceeds NAVI size, end_pos %d, lsb_start %d, pos %d\n",
end_pos, lsb_start, i);
return AVERROR_INVALIDDATA;
}
if (i < lsb_start)
skip_bits_long(gb, lsb_start - i);
for (i = done = 0; i < chset->channels; i++) {
int bits = chset->scalable_lsbs[0][i];
if (bits > 0) {
/* The channel reordering is conceptually done
* before adding the lsb:s, so we need to do
* the inverse permutation here. */
unsigned pi = chset->orig_chan_order_inv[0][i];
int *sample_buf = s->xll_sample_buf +
(in_channel + pi) * s->xll_smpl_in_seg;
int adj = chset->bit_width_adj_per_ch[0][i];
int msb_shift = bits;
unsigned j;
if (adj > 0)
msb_shift += adj - 1;
for (j = 0; j < s->xll_smpl_in_seg; j++)
sample_buf[j] = (sample_buf[j] << msb_shift) +
(get_bits(gb, bits) << adj);
done += bits * s->xll_smpl_in_seg;
}
}
if (done > 8 * chset->lsb_fsize[0]) {
av_log(s->avctx, AV_LOG_ERROR,
"chset lsb exceeds lsb_size\n");
return AVERROR_INVALIDDATA;
}
}
/* Store output. */
for (i = 0; i < chset->channels; i++) {
int *sample_buf = s->xll_sample_buf +
(in_channel + i) * s->xll_smpl_in_seg;
int shift = 1 - chset->bit_resolution;
int out_channel = chset->orig_chan_order[0][i];
float *out;
/* XLL uses the channel order C, L, R, and we want L,
* R, C. FIXME: Generalize. */
if (chset->ch_mask_enabled &&
(chset->ch_mask & 7) == 7 && out_channel < 3)
out_channel = out_channel ? out_channel - 1 : 2;
out_channel += in_channel;
if (out_channel >= s->avctx->channels)
continue;
out = (float *) frame->extended_data[out_channel];
out += seg * s->xll_smpl_in_seg;
/* NOTE: A one bit means residual encoding is *not* used. */
if ((chset->residual_encode >> i) & 1) {
/* Replace channel samples.
* FIXME: Most likely not the right thing to do. */
for (j = 0; j < s->xll_smpl_in_seg; j++)
out[j] = ldexpf(sample_buf[j], shift);
} else {
/* Add residual signal to core channel */
for (j = 0; j < s->xll_smpl_in_seg; j++)
out[j] += ldexpf(sample_buf[j], shift);
}
}
if (chset->downmix_coeff_code_embedded &&
!chset->primary_ch_set && chset->hier_chset) {
/* Undo hierarchical downmix of earlier channels. */
unsigned mix_channel;
for (mix_channel = 0; mix_channel < in_channel; mix_channel++) {
float *mix_buf;
const int *col;
float coeff;
unsigned row;
/* Similar channel reorder C, L, R vs L, R, C reorder. */
if (chset->ch_mask_enabled &&
(chset->ch_mask & 7) == 7 && mix_channel < 3)
mix_buf = (float *) frame->extended_data[mix_channel ? mix_channel - 1 : 2];
else
mix_buf = (float *) frame->extended_data[mix_channel];
mix_buf += seg * s->xll_smpl_in_seg;
col = &chset->downmix_coeffs[mix_channel * (chset->channels + 1)];
/* Scale */
coeff = ldexpf(col[0], -16);
for (j = 0; j < s->xll_smpl_in_seg; j++)
mix_buf[j] *= coeff;
for (row = 0;
row < chset->channels && in_channel + row < s->avctx->channels;
row++)
if (col[row + 1]) {
const float *new_channel =
(const float *) frame->extended_data[in_channel + row];
new_channel += seg * s->xll_smpl_in_seg;
coeff = ldexpf(col[row + 1], -15);
for (j = 0; j < s->xll_smpl_in_seg; j++)
mix_buf[j] -= coeff * new_channel[j];
}
}
}
next_chset:
in_channel += chset->channels;
/* Skip to next channel set using the NAVI info. */
i = get_bits_count(gb);
if (i > end_pos) {
av_log(s->avctx, AV_LOG_ERROR,
"chset data exceeds NAVI size\n");
return AVERROR_INVALIDDATA;
}
if (i < end_pos)
skip_bits_long(gb, end_pos - i);
}
}
return 0;
}
| true | FFmpeg | c9ed48e80ef807ab0c1bb946ac8db5f34d83d9c9 | int ff_dca_xll_decode_audio(DCAContext *s, AVFrame *frame)
{
int seg, chset_i;
struct coding_params {
int seg_type;
int rice_code_flag[16];
int pancAuxABIT[16];
int pancABIT0[16];
int pancABIT[16];
int nSamplPart0[16];
} param_state[16];
GetBitContext *gb = &s->xll_navi.gb;
int *history;
av_fast_malloc(&s->xll_sample_buf, &s->xll_sample_buf_size,
(s->xll_smpl_in_seg + DCA_XLL_AORDER_MAX) *
s->xll_channels * sizeof(*s->xll_sample_buf));
if (!s->xll_sample_buf)
return AVERROR(ENOMEM);
history = s->xll_sample_buf + s->xll_smpl_in_seg * s->xll_channels;
for (seg = 0; seg < s->xll_segments; seg++) {
unsigned in_channel;
for (chset_i = in_channel = 0; chset_i < s->xll_nch_sets; chset_i++) {
int end_pos = get_bits_count(gb) +
8 * s->xll_navi.chset_size[0][seg][chset_i];
int i, j;
struct coding_params *params = ¶m_state[chset_i];
int use_seg_state_code_param;
XllChSetSubHeader *chset = &s->xll_chsets[chset_i];
if (in_channel >= s->avctx->channels)
goto next_chset;
if (s->avctx->sample_rate != chset->sampling_frequency) {
av_log(s->avctx, AV_LOG_WARNING,
"XLL: unexpected chset sample rate %d, expected %d\n",
chset->sampling_frequency, s->avctx->sample_rate);
goto next_chset;
}
if (seg != 0)
use_seg_state_code_param = get_bits(gb, 1);
else
use_seg_state_code_param = 0;
if (!use_seg_state_code_param) {
int num_param_sets, i;
unsigned bits4ABIT;
params->seg_type = get_bits(gb, 1);
num_param_sets = params->seg_type ? 1 : chset->channels;
if (chset->bit_width > 16) {
bits4ABIT = 5;
} else {
if (chset->bit_width > 8)
bits4ABIT = 4;
else
bits4ABIT = 3;
if (s->xll_nch_sets > 1)
bits4ABIT++;
}
for (i = 0; i < num_param_sets; i++) {
params->rice_code_flag[i] = get_bits(gb, 1);
if (!params->seg_type && params->rice_code_flag[i] && get_bits(gb, 1))
params->pancAuxABIT[i] = get_bits(gb, bits4ABIT) + 1;
else
params->pancAuxABIT[i] = 0;
}
for (i = 0; i < num_param_sets; i++) {
if (!seg) {
params->pancABIT0[i] = get_bits(gb, bits4ABIT);
if (params->rice_code_flag[i] == 0 && params->pancABIT0[i] > 0)
params->pancABIT0[i]++;
if (params->seg_type == 0)
params->nSamplPart0[i] = chset->adapt_order[0][i];
else
params->nSamplPart0[i] = chset->adapt_order_max[0];
} else
params->nSamplPart0[i] = 0;
params->pancABIT[i] = get_bits(gb, bits4ABIT);
if (params->rice_code_flag[i] == 0 && params->pancABIT[i] > 0)
params->pancABIT[i]++;
}
}
for (i = 0; i < chset->channels; i++) {
int param_index = params->seg_type ? 0 : i;
int bits = params->pancABIT0[param_index];
int part0 = params->nSamplPart0[param_index];
int *sample_buf = s->xll_sample_buf +
(in_channel + i) * s->xll_smpl_in_seg;
if (!params->rice_code_flag[param_index]) {
if (bits)
for (j = 0; j < part0; j++)
sample_buf[j] = get_bits_sm(gb, bits);
else
memset(sample_buf, 0, part0 * sizeof(sample_buf[0]));
bits = params->pancABIT[param_index];
if (bits)
for (j = part0; j < s->xll_smpl_in_seg; j++)
sample_buf[j] = get_bits_sm(gb, bits);
else
memset(sample_buf + part0, 0,
(s->xll_smpl_in_seg - part0) * sizeof(sample_buf[0]));
} else {
int aux_bits = params->pancAuxABIT[param_index];
for (j = 0; j < part0; j++) {
int t = get_unary(gb, 1, 33) << bits;
if (bits)
t |= get_bits(gb, bits);
sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1);
}
bits = params->pancABIT[param_index];
memset(sample_buf + part0, 0,
(s->xll_smpl_in_seg - part0) * sizeof(sample_buf[0]));
if (aux_bits > 0) {
int count = get_bits(gb, s->xll_log_smpl_in_seg);
av_log(s->avctx, AV_LOG_DEBUG, "aux count %d (bits %d)\n",
count, s->xll_log_smpl_in_seg);
for (j = 0; j < count; j++)
sample_buf[get_bits(gb, s->xll_log_smpl_in_seg)] = 1;
}
for (j = part0; j < s->xll_smpl_in_seg; j++) {
if (!sample_buf[j]) {
int t = get_unary(gb, 1, 33);
if (bits)
t = (t << bits) | get_bits(gb, bits);
sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1);
} else
sample_buf[j] = get_bits_sm(gb, aux_bits);
}
}
}
for (i = 0; i < chset->channels; i++) {
unsigned adapt_order = chset->adapt_order[0][i];
int *sample_buf = s->xll_sample_buf +
(in_channel + i) * s->xll_smpl_in_seg;
int *prev = history + (in_channel + i) * DCA_XLL_AORDER_MAX;
if (!adapt_order) {
unsigned order;
for (order = chset->fixed_order[0][i]; order > 0; order--) {
unsigned j;
for (j = 1; j < s->xll_smpl_in_seg; j++)
sample_buf[j] += sample_buf[j - 1];
}
} else
dca_xll_inv_adapt_pred(sample_buf, s->xll_smpl_in_seg,
adapt_order, seg ? prev : NULL,
chset->lpc_refl_coeffs_q_ind[0][i]);
memcpy(prev, sample_buf + s->xll_smpl_in_seg - DCA_XLL_AORDER_MAX,
DCA_XLL_AORDER_MAX * sizeof(*prev));
}
for (i = 1; i < chset->channels; i += 2) {
int coeff = chset->pw_ch_pairs_coeffs[0][i / 2];
if (coeff != 0) {
int *sample_buf = s->xll_sample_buf +
(in_channel + i) * s->xll_smpl_in_seg;
int *prev = sample_buf - s->xll_smpl_in_seg;
unsigned j;
for (j = 0; j < s->xll_smpl_in_seg; j++)
sample_buf[j] += ((int64_t) coeff * prev[j] + 4) >> 3;
}
}
if (s->xll_scalable_lsb) {
int lsb_start = end_pos - 8 * chset->lsb_fsize[0] -
8 * (s->xll_banddata_crc & 2);
int done;
i = get_bits_count(gb);
if (i > lsb_start) {
av_log(s->avctx, AV_LOG_ERROR,
"chset data lsb exceeds NAVI size, end_pos %d, lsb_start %d, pos %d\n",
end_pos, lsb_start, i);
return AVERROR_INVALIDDATA;
}
if (i < lsb_start)
skip_bits_long(gb, lsb_start - i);
for (i = done = 0; i < chset->channels; i++) {
int bits = chset->scalable_lsbs[0][i];
if (bits > 0) {
unsigned pi = chset->orig_chan_order_inv[0][i];
int *sample_buf = s->xll_sample_buf +
(in_channel + pi) * s->xll_smpl_in_seg;
int adj = chset->bit_width_adj_per_ch[0][i];
int msb_shift = bits;
unsigned j;
if (adj > 0)
msb_shift += adj - 1;
for (j = 0; j < s->xll_smpl_in_seg; j++)
sample_buf[j] = (sample_buf[j] << msb_shift) +
(get_bits(gb, bits) << adj);
done += bits * s->xll_smpl_in_seg;
}
}
if (done > 8 * chset->lsb_fsize[0]) {
av_log(s->avctx, AV_LOG_ERROR,
"chset lsb exceeds lsb_size\n");
return AVERROR_INVALIDDATA;
}
}
for (i = 0; i < chset->channels; i++) {
int *sample_buf = s->xll_sample_buf +
(in_channel + i) * s->xll_smpl_in_seg;
int shift = 1 - chset->bit_resolution;
int out_channel = chset->orig_chan_order[0][i];
float *out;
if (chset->ch_mask_enabled &&
(chset->ch_mask & 7) == 7 && out_channel < 3)
out_channel = out_channel ? out_channel - 1 : 2;
out_channel += in_channel;
if (out_channel >= s->avctx->channels)
continue;
out = (float *) frame->extended_data[out_channel];
out += seg * s->xll_smpl_in_seg;
if ((chset->residual_encode >> i) & 1) {
for (j = 0; j < s->xll_smpl_in_seg; j++)
out[j] = ldexpf(sample_buf[j], shift);
} else {
for (j = 0; j < s->xll_smpl_in_seg; j++)
out[j] += ldexpf(sample_buf[j], shift);
}
}
if (chset->downmix_coeff_code_embedded &&
!chset->primary_ch_set && chset->hier_chset) {
unsigned mix_channel;
for (mix_channel = 0; mix_channel < in_channel; mix_channel++) {
float *mix_buf;
const int *col;
float coeff;
unsigned row;
if (chset->ch_mask_enabled &&
(chset->ch_mask & 7) == 7 && mix_channel < 3)
mix_buf = (float *) frame->extended_data[mix_channel ? mix_channel - 1 : 2];
else
mix_buf = (float *) frame->extended_data[mix_channel];
mix_buf += seg * s->xll_smpl_in_seg;
col = &chset->downmix_coeffs[mix_channel * (chset->channels + 1)];
coeff = ldexpf(col[0], -16);
for (j = 0; j < s->xll_smpl_in_seg; j++)
mix_buf[j] *= coeff;
for (row = 0;
row < chset->channels && in_channel + row < s->avctx->channels;
row++)
if (col[row + 1]) {
const float *new_channel =
(const float *) frame->extended_data[in_channel + row];
new_channel += seg * s->xll_smpl_in_seg;
coeff = ldexpf(col[row + 1], -15);
for (j = 0; j < s->xll_smpl_in_seg; j++)
mix_buf[j] -= coeff * new_channel[j];
}
}
}
next_chset:
in_channel += chset->channels;
i = get_bits_count(gb);
if (i > end_pos) {
av_log(s->avctx, AV_LOG_ERROR,
"chset data exceeds NAVI size\n");
return AVERROR_INVALIDDATA;
}
if (i < end_pos)
skip_bits_long(gb, end_pos - i);
}
}
return 0;
}
| {
"code": [
" int bits = params->pancABIT0[param_index];"
],
"line_no": [
217
]
} | int FUNC_0(DCAContext *VAR_0, AVFrame *VAR_1)
{
int VAR_2, VAR_3;
struct coding_params {
int seg_type;
int rice_code_flag[16];
int pancAuxABIT[16];
int pancABIT0[16];
int pancABIT[16];
int nSamplPart0[16];
} VAR_4[16];
GetBitContext *gb = &VAR_0->xll_navi.gb;
int *VAR_5;
av_fast_malloc(&VAR_0->xll_sample_buf, &VAR_0->xll_sample_buf_size,
(VAR_0->xll_smpl_in_seg + DCA_XLL_AORDER_MAX) *
VAR_0->xll_channels * sizeof(*VAR_0->xll_sample_buf));
if (!VAR_0->xll_sample_buf)
return AVERROR(ENOMEM);
VAR_5 = VAR_0->xll_sample_buf + VAR_0->xll_smpl_in_seg * VAR_0->xll_channels;
for (VAR_2 = 0; VAR_2 < VAR_0->xll_segments; VAR_2++) {
unsigned in_channel;
for (VAR_3 = in_channel = 0; VAR_3 < VAR_0->xll_nch_sets; VAR_3++) {
int end_pos = get_bits_count(gb) +
8 * VAR_0->xll_navi.chset_size[0][VAR_2][VAR_3];
int i, j;
struct coding_params *params = &VAR_4[VAR_3];
int use_seg_state_code_param;
XllChSetSubHeader *chset = &VAR_0->xll_chsets[VAR_3];
if (in_channel >= VAR_0->avctx->channels)
goto next_chset;
if (VAR_0->avctx->sample_rate != chset->sampling_frequency) {
av_log(VAR_0->avctx, AV_LOG_WARNING,
"XLL: unexpected chset sample rate %d, expected %d\n",
chset->sampling_frequency, VAR_0->avctx->sample_rate);
goto next_chset;
}
if (VAR_2 != 0)
use_seg_state_code_param = get_bits(gb, 1);
else
use_seg_state_code_param = 0;
if (!use_seg_state_code_param) {
int num_param_sets, i;
unsigned bits4ABIT;
params->seg_type = get_bits(gb, 1);
num_param_sets = params->seg_type ? 1 : chset->channels;
if (chset->bit_width > 16) {
bits4ABIT = 5;
} else {
if (chset->bit_width > 8)
bits4ABIT = 4;
else
bits4ABIT = 3;
if (VAR_0->xll_nch_sets > 1)
bits4ABIT++;
}
for (i = 0; i < num_param_sets; i++) {
params->rice_code_flag[i] = get_bits(gb, 1);
if (!params->seg_type && params->rice_code_flag[i] && get_bits(gb, 1))
params->pancAuxABIT[i] = get_bits(gb, bits4ABIT) + 1;
else
params->pancAuxABIT[i] = 0;
}
for (i = 0; i < num_param_sets; i++) {
if (!VAR_2) {
params->pancABIT0[i] = get_bits(gb, bits4ABIT);
if (params->rice_code_flag[i] == 0 && params->pancABIT0[i] > 0)
params->pancABIT0[i]++;
if (params->seg_type == 0)
params->nSamplPart0[i] = chset->adapt_order[0][i];
else
params->nSamplPart0[i] = chset->adapt_order_max[0];
} else
params->nSamplPart0[i] = 0;
params->pancABIT[i] = get_bits(gb, bits4ABIT);
if (params->rice_code_flag[i] == 0 && params->pancABIT[i] > 0)
params->pancABIT[i]++;
}
}
for (i = 0; i < chset->channels; i++) {
int param_index = params->seg_type ? 0 : i;
int bits = params->pancABIT0[param_index];
int part0 = params->nSamplPart0[param_index];
int *sample_buf = VAR_0->xll_sample_buf +
(in_channel + i) * VAR_0->xll_smpl_in_seg;
if (!params->rice_code_flag[param_index]) {
if (bits)
for (j = 0; j < part0; j++)
sample_buf[j] = get_bits_sm(gb, bits);
else
memset(sample_buf, 0, part0 * sizeof(sample_buf[0]));
bits = params->pancABIT[param_index];
if (bits)
for (j = part0; j < VAR_0->xll_smpl_in_seg; j++)
sample_buf[j] = get_bits_sm(gb, bits);
else
memset(sample_buf + part0, 0,
(VAR_0->xll_smpl_in_seg - part0) * sizeof(sample_buf[0]));
} else {
int aux_bits = params->pancAuxABIT[param_index];
for (j = 0; j < part0; j++) {
int t = get_unary(gb, 1, 33) << bits;
if (bits)
t |= get_bits(gb, bits);
sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1);
}
bits = params->pancABIT[param_index];
memset(sample_buf + part0, 0,
(VAR_0->xll_smpl_in_seg - part0) * sizeof(sample_buf[0]));
if (aux_bits > 0) {
int count = get_bits(gb, VAR_0->xll_log_smpl_in_seg);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "aux count %d (bits %d)\n",
count, VAR_0->xll_log_smpl_in_seg);
for (j = 0; j < count; j++)
sample_buf[get_bits(gb, VAR_0->xll_log_smpl_in_seg)] = 1;
}
for (j = part0; j < VAR_0->xll_smpl_in_seg; j++) {
if (!sample_buf[j]) {
int t = get_unary(gb, 1, 33);
if (bits)
t = (t << bits) | get_bits(gb, bits);
sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1);
} else
sample_buf[j] = get_bits_sm(gb, aux_bits);
}
}
}
for (i = 0; i < chset->channels; i++) {
unsigned adapt_order = chset->adapt_order[0][i];
int *sample_buf = VAR_0->xll_sample_buf +
(in_channel + i) * VAR_0->xll_smpl_in_seg;
int *prev = VAR_5 + (in_channel + i) * DCA_XLL_AORDER_MAX;
if (!adapt_order) {
unsigned order;
for (order = chset->fixed_order[0][i]; order > 0; order--) {
unsigned j;
for (j = 1; j < VAR_0->xll_smpl_in_seg; j++)
sample_buf[j] += sample_buf[j - 1];
}
} else
dca_xll_inv_adapt_pred(sample_buf, VAR_0->xll_smpl_in_seg,
adapt_order, VAR_2 ? prev : NULL,
chset->lpc_refl_coeffs_q_ind[0][i]);
memcpy(prev, sample_buf + VAR_0->xll_smpl_in_seg - DCA_XLL_AORDER_MAX,
DCA_XLL_AORDER_MAX * sizeof(*prev));
}
for (i = 1; i < chset->channels; i += 2) {
int coeff = chset->pw_ch_pairs_coeffs[0][i / 2];
if (coeff != 0) {
int *sample_buf = VAR_0->xll_sample_buf +
(in_channel + i) * VAR_0->xll_smpl_in_seg;
int *prev = sample_buf - VAR_0->xll_smpl_in_seg;
unsigned j;
for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)
sample_buf[j] += ((int64_t) coeff * prev[j] + 4) >> 3;
}
}
if (VAR_0->xll_scalable_lsb) {
int lsb_start = end_pos - 8 * chset->lsb_fsize[0] -
8 * (VAR_0->xll_banddata_crc & 2);
int done;
i = get_bits_count(gb);
if (i > lsb_start) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"chset data lsb exceeds NAVI size, end_pos %d, lsb_start %d, pos %d\n",
end_pos, lsb_start, i);
return AVERROR_INVALIDDATA;
}
if (i < lsb_start)
skip_bits_long(gb, lsb_start - i);
for (i = done = 0; i < chset->channels; i++) {
int bits = chset->scalable_lsbs[0][i];
if (bits > 0) {
unsigned pi = chset->orig_chan_order_inv[0][i];
int *sample_buf = VAR_0->xll_sample_buf +
(in_channel + pi) * VAR_0->xll_smpl_in_seg;
int adj = chset->bit_width_adj_per_ch[0][i];
int msb_shift = bits;
unsigned j;
if (adj > 0)
msb_shift += adj - 1;
for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)
sample_buf[j] = (sample_buf[j] << msb_shift) +
(get_bits(gb, bits) << adj);
done += bits * VAR_0->xll_smpl_in_seg;
}
}
if (done > 8 * chset->lsb_fsize[0]) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"chset lsb exceeds lsb_size\n");
return AVERROR_INVALIDDATA;
}
}
for (i = 0; i < chset->channels; i++) {
int *sample_buf = VAR_0->xll_sample_buf +
(in_channel + i) * VAR_0->xll_smpl_in_seg;
int shift = 1 - chset->bit_resolution;
int out_channel = chset->orig_chan_order[0][i];
float *out;
if (chset->ch_mask_enabled &&
(chset->ch_mask & 7) == 7 && out_channel < 3)
out_channel = out_channel ? out_channel - 1 : 2;
out_channel += in_channel;
if (out_channel >= VAR_0->avctx->channels)
continue;
out = (float *) VAR_1->extended_data[out_channel];
out += VAR_2 * VAR_0->xll_smpl_in_seg;
if ((chset->residual_encode >> i) & 1) {
for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)
out[j] = ldexpf(sample_buf[j], shift);
} else {
for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)
out[j] += ldexpf(sample_buf[j], shift);
}
}
if (chset->downmix_coeff_code_embedded &&
!chset->primary_ch_set && chset->hier_chset) {
unsigned mix_channel;
for (mix_channel = 0; mix_channel < in_channel; mix_channel++) {
float *mix_buf;
const int *col;
float coeff;
unsigned row;
if (chset->ch_mask_enabled &&
(chset->ch_mask & 7) == 7 && mix_channel < 3)
mix_buf = (float *) VAR_1->extended_data[mix_channel ? mix_channel - 1 : 2];
else
mix_buf = (float *) VAR_1->extended_data[mix_channel];
mix_buf += VAR_2 * VAR_0->xll_smpl_in_seg;
col = &chset->downmix_coeffs[mix_channel * (chset->channels + 1)];
coeff = ldexpf(col[0], -16);
for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)
mix_buf[j] *= coeff;
for (row = 0;
row < chset->channels && in_channel + row < VAR_0->avctx->channels;
row++)
if (col[row + 1]) {
const float *new_channel =
(const float *) VAR_1->extended_data[in_channel + row];
new_channel += VAR_2 * VAR_0->xll_smpl_in_seg;
coeff = ldexpf(col[row + 1], -15);
for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)
mix_buf[j] -= coeff * new_channel[j];
}
}
}
next_chset:
in_channel += chset->channels;
i = get_bits_count(gb);
if (i > end_pos) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"chset data exceeds NAVI size\n");
return AVERROR_INVALIDDATA;
}
if (i < end_pos)
skip_bits_long(gb, end_pos - i);
}
}
return 0;
}
| [
"int FUNC_0(DCAContext *VAR_0, AVFrame *VAR_1)\n{",
"int VAR_2, VAR_3;",
"struct coding_params {",
"int seg_type;",
"int rice_code_flag[16];",
"int pancAuxABIT[16];",
"int pancABIT0[16];",
"int pancABIT[16];",
"int nSamplPart0[16];",
"} VAR_4[16];",
"GetBitContext *gb = &VAR_0->xll_navi.gb;",
"int *VAR_5;",
"av_fast_malloc(&VAR_0->xll_sample_buf, &VAR_0->xll_sample_buf_size,\n(VAR_0->xll_smpl_in_seg + DCA_XLL_AORDER_MAX) *\nVAR_0->xll_channels * sizeof(*VAR_0->xll_sample_buf));",
"if (!VAR_0->xll_sample_buf)\nreturn AVERROR(ENOMEM);",
"VAR_5 = VAR_0->xll_sample_buf + VAR_0->xll_smpl_in_seg * VAR_0->xll_channels;",
"for (VAR_2 = 0; VAR_2 < VAR_0->xll_segments; VAR_2++) {",
"unsigned in_channel;",
"for (VAR_3 = in_channel = 0; VAR_3 < VAR_0->xll_nch_sets; VAR_3++) {",
"int end_pos = get_bits_count(gb) +\n8 * VAR_0->xll_navi.chset_size[0][VAR_2][VAR_3];",
"int i, j;",
"struct coding_params *params = &VAR_4[VAR_3];",
"int use_seg_state_code_param;",
"XllChSetSubHeader *chset = &VAR_0->xll_chsets[VAR_3];",
"if (in_channel >= VAR_0->avctx->channels)\ngoto next_chset;",
"if (VAR_0->avctx->sample_rate != chset->sampling_frequency) {",
"av_log(VAR_0->avctx, AV_LOG_WARNING,\n\"XLL: unexpected chset sample rate %d, expected %d\\n\",\nchset->sampling_frequency, VAR_0->avctx->sample_rate);",
"goto next_chset;",
"}",
"if (VAR_2 != 0)\nuse_seg_state_code_param = get_bits(gb, 1);",
"else\nuse_seg_state_code_param = 0;",
"if (!use_seg_state_code_param) {",
"int num_param_sets, i;",
"unsigned bits4ABIT;",
"params->seg_type = get_bits(gb, 1);",
"num_param_sets = params->seg_type ? 1 : chset->channels;",
"if (chset->bit_width > 16) {",
"bits4ABIT = 5;",
"} else {",
"if (chset->bit_width > 8)\nbits4ABIT = 4;",
"else\nbits4ABIT = 3;",
"if (VAR_0->xll_nch_sets > 1)\nbits4ABIT++;",
"}",
"for (i = 0; i < num_param_sets; i++) {",
"params->rice_code_flag[i] = get_bits(gb, 1);",
"if (!params->seg_type && params->rice_code_flag[i] && get_bits(gb, 1))\nparams->pancAuxABIT[i] = get_bits(gb, bits4ABIT) + 1;",
"else\nparams->pancAuxABIT[i] = 0;",
"}",
"for (i = 0; i < num_param_sets; i++) {",
"if (!VAR_2) {",
"params->pancABIT0[i] = get_bits(gb, bits4ABIT);",
"if (params->rice_code_flag[i] == 0 && params->pancABIT0[i] > 0)\nparams->pancABIT0[i]++;",
"if (params->seg_type == 0)\nparams->nSamplPart0[i] = chset->adapt_order[0][i];",
"else\nparams->nSamplPart0[i] = chset->adapt_order_max[0];",
"} else",
"params->nSamplPart0[i] = 0;",
"params->pancABIT[i] = get_bits(gb, bits4ABIT);",
"if (params->rice_code_flag[i] == 0 && params->pancABIT[i] > 0)\nparams->pancABIT[i]++;",
"}",
"}",
"for (i = 0; i < chset->channels; i++) {",
"int param_index = params->seg_type ? 0 : i;",
"int bits = params->pancABIT0[param_index];",
"int part0 = params->nSamplPart0[param_index];",
"int *sample_buf = VAR_0->xll_sample_buf +\n(in_channel + i) * VAR_0->xll_smpl_in_seg;",
"if (!params->rice_code_flag[param_index]) {",
"if (bits)\nfor (j = 0; j < part0; j++)",
"sample_buf[j] = get_bits_sm(gb, bits);",
"else\nmemset(sample_buf, 0, part0 * sizeof(sample_buf[0]));",
"bits = params->pancABIT[param_index];",
"if (bits)\nfor (j = part0; j < VAR_0->xll_smpl_in_seg; j++)",
"sample_buf[j] = get_bits_sm(gb, bits);",
"else\nmemset(sample_buf + part0, 0,\n(VAR_0->xll_smpl_in_seg - part0) * sizeof(sample_buf[0]));",
"} else {",
"int aux_bits = params->pancAuxABIT[param_index];",
"for (j = 0; j < part0; j++) {",
"int t = get_unary(gb, 1, 33) << bits;",
"if (bits)\nt |= get_bits(gb, bits);",
"sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1);",
"}",
"bits = params->pancABIT[param_index];",
"memset(sample_buf + part0, 0,\n(VAR_0->xll_smpl_in_seg - part0) * sizeof(sample_buf[0]));",
"if (aux_bits > 0) {",
"int count = get_bits(gb, VAR_0->xll_log_smpl_in_seg);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"aux count %d (bits %d)\\n\",\ncount, VAR_0->xll_log_smpl_in_seg);",
"for (j = 0; j < count; j++)",
"sample_buf[get_bits(gb, VAR_0->xll_log_smpl_in_seg)] = 1;",
"}",
"for (j = part0; j < VAR_0->xll_smpl_in_seg; j++) {",
"if (!sample_buf[j]) {",
"int t = get_unary(gb, 1, 33);",
"if (bits)\nt = (t << bits) | get_bits(gb, bits);",
"sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1);",
"} else",
"sample_buf[j] = get_bits_sm(gb, aux_bits);",
"}",
"}",
"}",
"for (i = 0; i < chset->channels; i++) {",
"unsigned adapt_order = chset->adapt_order[0][i];",
"int *sample_buf = VAR_0->xll_sample_buf +\n(in_channel + i) * VAR_0->xll_smpl_in_seg;",
"int *prev = VAR_5 + (in_channel + i) * DCA_XLL_AORDER_MAX;",
"if (!adapt_order) {",
"unsigned order;",
"for (order = chset->fixed_order[0][i]; order > 0; order--) {",
"unsigned j;",
"for (j = 1; j < VAR_0->xll_smpl_in_seg; j++)",
"sample_buf[j] += sample_buf[j - 1];",
"}",
"} else",
"dca_xll_inv_adapt_pred(sample_buf, VAR_0->xll_smpl_in_seg,\nadapt_order, VAR_2 ? prev : NULL,\nchset->lpc_refl_coeffs_q_ind[0][i]);",
"memcpy(prev, sample_buf + VAR_0->xll_smpl_in_seg - DCA_XLL_AORDER_MAX,\nDCA_XLL_AORDER_MAX * sizeof(*prev));",
"}",
"for (i = 1; i < chset->channels; i += 2) {",
"int coeff = chset->pw_ch_pairs_coeffs[0][i / 2];",
"if (coeff != 0) {",
"int *sample_buf = VAR_0->xll_sample_buf +\n(in_channel + i) * VAR_0->xll_smpl_in_seg;",
"int *prev = sample_buf - VAR_0->xll_smpl_in_seg;",
"unsigned j;",
"for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)",
"sample_buf[j] += ((int64_t) coeff * prev[j] + 4) >> 3;",
"}",
"}",
"if (VAR_0->xll_scalable_lsb) {",
"int lsb_start = end_pos - 8 * chset->lsb_fsize[0] -\n8 * (VAR_0->xll_banddata_crc & 2);",
"int done;",
"i = get_bits_count(gb);",
"if (i > lsb_start) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"chset data lsb exceeds NAVI size, end_pos %d, lsb_start %d, pos %d\\n\",\nend_pos, lsb_start, i);",
"return AVERROR_INVALIDDATA;",
"}",
"if (i < lsb_start)\nskip_bits_long(gb, lsb_start - i);",
"for (i = done = 0; i < chset->channels; i++) {",
"int bits = chset->scalable_lsbs[0][i];",
"if (bits > 0) {",
"unsigned pi = chset->orig_chan_order_inv[0][i];",
"int *sample_buf = VAR_0->xll_sample_buf +\n(in_channel + pi) * VAR_0->xll_smpl_in_seg;",
"int adj = chset->bit_width_adj_per_ch[0][i];",
"int msb_shift = bits;",
"unsigned j;",
"if (adj > 0)\nmsb_shift += adj - 1;",
"for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)",
"sample_buf[j] = (sample_buf[j] << msb_shift) +\n(get_bits(gb, bits) << adj);",
"done += bits * VAR_0->xll_smpl_in_seg;",
"}",
"}",
"if (done > 8 * chset->lsb_fsize[0]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"chset lsb exceeds lsb_size\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"for (i = 0; i < chset->channels; i++) {",
"int *sample_buf = VAR_0->xll_sample_buf +\n(in_channel + i) * VAR_0->xll_smpl_in_seg;",
"int shift = 1 - chset->bit_resolution;",
"int out_channel = chset->orig_chan_order[0][i];",
"float *out;",
"if (chset->ch_mask_enabled &&\n(chset->ch_mask & 7) == 7 && out_channel < 3)\nout_channel = out_channel ? out_channel - 1 : 2;",
"out_channel += in_channel;",
"if (out_channel >= VAR_0->avctx->channels)\ncontinue;",
"out = (float *) VAR_1->extended_data[out_channel];",
"out += VAR_2 * VAR_0->xll_smpl_in_seg;",
"if ((chset->residual_encode >> i) & 1) {",
"for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)",
"out[j] = ldexpf(sample_buf[j], shift);",
"} else {",
"for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)",
"out[j] += ldexpf(sample_buf[j], shift);",
"}",
"}",
"if (chset->downmix_coeff_code_embedded &&\n!chset->primary_ch_set && chset->hier_chset) {",
"unsigned mix_channel;",
"for (mix_channel = 0; mix_channel < in_channel; mix_channel++) {",
"float *mix_buf;",
"const int *col;",
"float coeff;",
"unsigned row;",
"if (chset->ch_mask_enabled &&\n(chset->ch_mask & 7) == 7 && mix_channel < 3)\nmix_buf = (float *) VAR_1->extended_data[mix_channel ? mix_channel - 1 : 2];",
"else\nmix_buf = (float *) VAR_1->extended_data[mix_channel];",
"mix_buf += VAR_2 * VAR_0->xll_smpl_in_seg;",
"col = &chset->downmix_coeffs[mix_channel * (chset->channels + 1)];",
"coeff = ldexpf(col[0], -16);",
"for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)",
"mix_buf[j] *= coeff;",
"for (row = 0;",
"row < chset->channels && in_channel + row < VAR_0->avctx->channels;",
"row++)\nif (col[row + 1]) {",
"const float *new_channel =\n(const float *) VAR_1->extended_data[in_channel + row];",
"new_channel += VAR_2 * VAR_0->xll_smpl_in_seg;",
"coeff = ldexpf(col[row + 1], -15);",
"for (j = 0; j < VAR_0->xll_smpl_in_seg; j++)",
"mix_buf[j] -= coeff * new_channel[j];",
"}",
"}",
"}",
"next_chset:\nin_channel += chset->channels;",
"i = get_bits_count(gb);",
"if (i > end_pos) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"chset data exceeds NAVI size\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (i < end_pos)\nskip_bits_long(gb, end_pos - i);",
"}",
"}",
"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,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
7
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
43,
45,
47
],
[
49,
51
],
[
55
],
[
59
],
[
61
],
[
65
],
[
69,
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85,
89
],
[
93
],
[
95,
97,
99
],
[
101
],
[
103
],
[
105,
107
],
[
109,
111
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139,
141
],
[
143,
145
],
[
147
],
[
151
],
[
153
],
[
155,
157
],
[
159,
161
],
[
163
],
[
167
],
[
169
],
[
173
],
[
175,
179
],
[
185,
187
],
[
189,
191
],
[
193
],
[
195
],
[
201
],
[
203,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
227
],
[
231,
233
],
[
235
],
[
237,
239
],
[
245
],
[
247,
249
],
[
251
],
[
253,
255,
257
],
[
259
],
[
261
],
[
265
],
[
269
],
[
273,
275
],
[
277
],
[
279
],
[
285
],
[
293,
295
],
[
299
],
[
311
],
[
313,
315
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331,
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
349
],
[
351
],
[
353,
355
],
[
357
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
379,
381,
383
],
[
385,
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397,
399
],
[
401
],
[
403
],
[
405
],
[
409
],
[
411
],
[
413
],
[
417
],
[
419,
421
],
[
423
],
[
425
],
[
427
],
[
429,
431,
433
],
[
435
],
[
437
],
[
439,
441
],
[
445
],
[
447
],
[
449
],
[
457
],
[
459,
461
],
[
463
],
[
465
],
[
467
],
[
471,
473
],
[
477
],
[
479,
481
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493,
495
],
[
497
],
[
499
],
[
501
],
[
507
],
[
509,
511
],
[
513
],
[
515
],
[
517
],
[
525,
527,
529
],
[
533
],
[
535,
537
],
[
541
],
[
543
],
[
549
],
[
555
],
[
557
],
[
559
],
[
563
],
[
565
],
[
567
],
[
569
],
[
573,
575
],
[
579
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
593,
595,
597
],
[
599,
601
],
[
605
],
[
607
],
[
613
],
[
615
],
[
617
],
[
621
],
[
623
],
[
625,
627
],
[
629,
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
649,
651
],
[
655
],
[
657
],
[
659,
661
],
[
663
],
[
665
],
[
667,
669
],
[
671
],
[
673
],
[
675
],
[
677
]
]
|
10,405 | static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, Jpeg2000Tile *tile,
int width, int height, int bandpos, int lev)
{
int pass_t = 2, passno, x, y, max=0, nmsedec, bpno;
int64_t wmsedec = 0;
for (y = 0; y < height+2; y++)
memset(t1->flags[y], 0, (width+2)*sizeof(int));
for (y = 0; y < height; y++){
for (x = 0; x < width; x++){
if (t1->data[y][x] < 0){
t1->flags[y+1][x+1] |= JPEG2000_T1_SGN;
t1->data[y][x] = -t1->data[y][x];
}
max = FFMAX(max, t1->data[y][x]);
}
}
if (max == 0){
cblk->nonzerobits = 0;
bpno = 0;
} else{
cblk->nonzerobits = av_log2(max) + 1 - NMSEDEC_FRACBITS;
bpno = cblk->nonzerobits - 1;
}
ff_mqc_initenc(&t1->mqc, cblk->data);
for (passno = 0; bpno >= 0; passno++){
nmsedec=0;
switch(pass_t){
case 0: encode_sigpass(t1, width, height, bandpos, &nmsedec, bpno);
break;
case 1: encode_refpass(t1, width, height, &nmsedec, bpno);
break;
case 2: encode_clnpass(t1, width, height, bandpos, &nmsedec, bpno);
break;
}
cblk->passes[passno].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno].flushed, &cblk->passes[passno].flushed_len);
wmsedec += (int64_t)nmsedec << (2*bpno);
cblk->passes[passno].disto = wmsedec;
if (++pass_t == 3){
pass_t = 0;
bpno--;
}
}
cblk->npasses = passno;
cblk->ninclpasses = passno;
cblk->passes[passno-1].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno-1].flushed, &cblk->passes[passno-1].flushed_len);
}
| false | FFmpeg | f1e173049ecc9de03817385ba8962d14cba779db | static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, Jpeg2000Tile *tile,
int width, int height, int bandpos, int lev)
{
int pass_t = 2, passno, x, y, max=0, nmsedec, bpno;
int64_t wmsedec = 0;
for (y = 0; y < height+2; y++)
memset(t1->flags[y], 0, (width+2)*sizeof(int));
for (y = 0; y < height; y++){
for (x = 0; x < width; x++){
if (t1->data[y][x] < 0){
t1->flags[y+1][x+1] |= JPEG2000_T1_SGN;
t1->data[y][x] = -t1->data[y][x];
}
max = FFMAX(max, t1->data[y][x]);
}
}
if (max == 0){
cblk->nonzerobits = 0;
bpno = 0;
} else{
cblk->nonzerobits = av_log2(max) + 1 - NMSEDEC_FRACBITS;
bpno = cblk->nonzerobits - 1;
}
ff_mqc_initenc(&t1->mqc, cblk->data);
for (passno = 0; bpno >= 0; passno++){
nmsedec=0;
switch(pass_t){
case 0: encode_sigpass(t1, width, height, bandpos, &nmsedec, bpno);
break;
case 1: encode_refpass(t1, width, height, &nmsedec, bpno);
break;
case 2: encode_clnpass(t1, width, height, bandpos, &nmsedec, bpno);
break;
}
cblk->passes[passno].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno].flushed, &cblk->passes[passno].flushed_len);
wmsedec += (int64_t)nmsedec << (2*bpno);
cblk->passes[passno].disto = wmsedec;
if (++pass_t == 3){
pass_t = 0;
bpno--;
}
}
cblk->npasses = passno;
cblk->ninclpasses = passno;
cblk->passes[passno-1].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno-1].flushed, &cblk->passes[passno-1].flushed_len);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Jpeg2000EncoderContext *VAR_0, Jpeg2000T1Context *VAR_1, Jpeg2000Cblk *VAR_2, Jpeg2000Tile *VAR_3,
int VAR_4, int VAR_5, int VAR_6, int VAR_7)
{
int VAR_8 = 2, VAR_9, VAR_10, VAR_11, VAR_12=0, VAR_13, VAR_14;
int64_t wmsedec = 0;
for (VAR_11 = 0; VAR_11 < VAR_5+2; VAR_11++)
memset(VAR_1->flags[VAR_11], 0, (VAR_4+2)*sizeof(int));
for (VAR_11 = 0; VAR_11 < VAR_5; VAR_11++){
for (VAR_10 = 0; VAR_10 < VAR_4; VAR_10++){
if (VAR_1->data[VAR_11][VAR_10] < 0){
VAR_1->flags[VAR_11+1][VAR_10+1] |= JPEG2000_T1_SGN;
VAR_1->data[VAR_11][VAR_10] = -VAR_1->data[VAR_11][VAR_10];
}
VAR_12 = FFMAX(VAR_12, VAR_1->data[VAR_11][VAR_10]);
}
}
if (VAR_12 == 0){
VAR_2->nonzerobits = 0;
VAR_14 = 0;
} else{
VAR_2->nonzerobits = av_log2(VAR_12) + 1 - NMSEDEC_FRACBITS;
VAR_14 = VAR_2->nonzerobits - 1;
}
ff_mqc_initenc(&VAR_1->mqc, VAR_2->data);
for (VAR_9 = 0; VAR_14 >= 0; VAR_9++){
VAR_13=0;
switch(VAR_8){
case 0: encode_sigpass(VAR_1, VAR_4, VAR_5, VAR_6, &VAR_13, VAR_14);
break;
case 1: encode_refpass(VAR_1, VAR_4, VAR_5, &VAR_13, VAR_14);
break;
case 2: encode_clnpass(VAR_1, VAR_4, VAR_5, VAR_6, &VAR_13, VAR_14);
break;
}
VAR_2->passes[VAR_9].rate = ff_mqc_flush_to(&VAR_1->mqc, VAR_2->passes[VAR_9].flushed, &VAR_2->passes[VAR_9].flushed_len);
wmsedec += (int64_t)VAR_13 << (2*VAR_14);
VAR_2->passes[VAR_9].disto = wmsedec;
if (++VAR_8 == 3){
VAR_8 = 0;
VAR_14--;
}
}
VAR_2->npasses = VAR_9;
VAR_2->ninclpasses = VAR_9;
VAR_2->passes[VAR_9-1].rate = ff_mqc_flush_to(&VAR_1->mqc, VAR_2->passes[VAR_9-1].flushed, &VAR_2->passes[VAR_9-1].flushed_len);
}
| [
"static void FUNC_0(Jpeg2000EncoderContext *VAR_0, Jpeg2000T1Context *VAR_1, Jpeg2000Cblk *VAR_2, Jpeg2000Tile *VAR_3,\nint VAR_4, int VAR_5, int VAR_6, int VAR_7)\n{",
"int VAR_8 = 2, VAR_9, VAR_10, VAR_11, VAR_12=0, VAR_13, VAR_14;",
"int64_t wmsedec = 0;",
"for (VAR_11 = 0; VAR_11 < VAR_5+2; VAR_11++)",
"memset(VAR_1->flags[VAR_11], 0, (VAR_4+2)*sizeof(int));",
"for (VAR_11 = 0; VAR_11 < VAR_5; VAR_11++){",
"for (VAR_10 = 0; VAR_10 < VAR_4; VAR_10++){",
"if (VAR_1->data[VAR_11][VAR_10] < 0){",
"VAR_1->flags[VAR_11+1][VAR_10+1] |= JPEG2000_T1_SGN;",
"VAR_1->data[VAR_11][VAR_10] = -VAR_1->data[VAR_11][VAR_10];",
"}",
"VAR_12 = FFMAX(VAR_12, VAR_1->data[VAR_11][VAR_10]);",
"}",
"}",
"if (VAR_12 == 0){",
"VAR_2->nonzerobits = 0;",
"VAR_14 = 0;",
"} else{",
"VAR_2->nonzerobits = av_log2(VAR_12) + 1 - NMSEDEC_FRACBITS;",
"VAR_14 = VAR_2->nonzerobits - 1;",
"}",
"ff_mqc_initenc(&VAR_1->mqc, VAR_2->data);",
"for (VAR_9 = 0; VAR_14 >= 0; VAR_9++){",
"VAR_13=0;",
"switch(VAR_8){",
"case 0: encode_sigpass(VAR_1, VAR_4, VAR_5, VAR_6, &VAR_13, VAR_14);",
"break;",
"case 1: encode_refpass(VAR_1, VAR_4, VAR_5, &VAR_13, VAR_14);",
"break;",
"case 2: encode_clnpass(VAR_1, VAR_4, VAR_5, VAR_6, &VAR_13, VAR_14);",
"break;",
"}",
"VAR_2->passes[VAR_9].rate = ff_mqc_flush_to(&VAR_1->mqc, VAR_2->passes[VAR_9].flushed, &VAR_2->passes[VAR_9].flushed_len);",
"wmsedec += (int64_t)VAR_13 << (2*VAR_14);",
"VAR_2->passes[VAR_9].disto = wmsedec;",
"if (++VAR_8 == 3){",
"VAR_8 = 0;",
"VAR_14--;",
"}",
"}",
"VAR_2->npasses = VAR_9;",
"VAR_2->ninclpasses = VAR_9;",
"VAR_2->passes[VAR_9-1].rate = ff_mqc_flush_to(&VAR_1->mqc, VAR_2->passes[VAR_9-1].flushed, &VAR_2->passes[VAR_9-1].flushed_len);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
]
]
|
10,407 | void cpu_disable_ticks(void)
{
/* Here, the really thing protected by seqlock is cpu_clock_offset. */
seqlock_write_lock(&timers_state.vm_clock_seqlock);
if (timers_state.cpu_ticks_enabled) {
timers_state.cpu_ticks_offset = cpu_get_ticks();
timers_state.cpu_clock_offset = cpu_get_clock_locked();
timers_state.cpu_ticks_enabled = 0;
}
seqlock_write_unlock(&timers_state.vm_clock_seqlock);
}
| true | qemu | 5f3e31012e334f3410e04abae7f88565df17c91a | void cpu_disable_ticks(void)
{
seqlock_write_lock(&timers_state.vm_clock_seqlock);
if (timers_state.cpu_ticks_enabled) {
timers_state.cpu_ticks_offset = cpu_get_ticks();
timers_state.cpu_clock_offset = cpu_get_clock_locked();
timers_state.cpu_ticks_enabled = 0;
}
seqlock_write_unlock(&timers_state.vm_clock_seqlock);
}
| {
"code": [
" timers_state.cpu_ticks_offset = cpu_get_ticks();"
],
"line_no": [
11
]
} | void FUNC_0(void)
{
seqlock_write_lock(&timers_state.vm_clock_seqlock);
if (timers_state.cpu_ticks_enabled) {
timers_state.cpu_ticks_offset = cpu_get_ticks();
timers_state.cpu_clock_offset = cpu_get_clock_locked();
timers_state.cpu_ticks_enabled = 0;
}
seqlock_write_unlock(&timers_state.vm_clock_seqlock);
}
| [
"void FUNC_0(void)\n{",
"seqlock_write_lock(&timers_state.vm_clock_seqlock);",
"if (timers_state.cpu_ticks_enabled) {",
"timers_state.cpu_ticks_offset = cpu_get_ticks();",
"timers_state.cpu_clock_offset = cpu_get_clock_locked();",
"timers_state.cpu_ticks_enabled = 0;",
"}",
"seqlock_write_unlock(&timers_state.vm_clock_seqlock);",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
]
|
10,408 | static inline void RENAME(yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
unsigned int width, unsigned int height,
int lumStride, int chromStride, int dstStride)
{
//FIXME interpolate chroma
RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | static inline void RENAME(yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
unsigned int width, unsigned int height,
int lumStride, int chromStride, int dstStride)
{
RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);
}
| {
"code": [
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tint lumStride, int chromStride, int dstStride)",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tint lumStride, int chromStride, int dstStride)",
"\tunsigned int width, unsigned int height,",
"\tint lumStride, int chromStride, int dstStride)",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,",
"\tunsigned int width, unsigned int height,"
],
"line_no": [
3,
3,
3,
3,
3,
3,
3,
3,
3,
3,
3,
3,
5,
3,
3,
5,
3,
5,
3,
3,
3
]
} | static inline void FUNC_0(yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
unsigned int width, unsigned int height,
int lumStride, int chromStride, int dstStride)
{
FUNC_0(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);
}
| [
"static inline void FUNC_0(yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,\nunsigned int width, unsigned int height,\nint lumStride, int chromStride, int dstStride)\n{",
"FUNC_0(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);",
"}"
]
| [
1,
0,
0
]
| [
[
1,
3,
5,
7
],
[
11
],
[
13
]
]
|
10,411 | static int decode_residuals(FLACContext *s, int channel, int pred_order)
{
int i, tmp, partition, method_type, rice_order;
int sample = 0, samples;
method_type = get_bits(&s->gb, 2);
if (method_type > 1) {
av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
method_type);
return -1;
}
rice_order = get_bits(&s->gb, 4);
samples= s->blocksize >> rice_order;
if (pred_order > samples) {
av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n",
pred_order, samples);
return -1;
}
sample=
i= pred_order;
for (partition = 0; partition < (1 << rice_order); partition++) {
tmp = get_bits(&s->gb, method_type == 0 ? 4 : 5);
if (tmp == (method_type == 0 ? 15 : 31)) {
tmp = get_bits(&s->gb, 5);
for (; i < samples; i++, sample++)
s->decoded[channel][sample] = get_sbits_long(&s->gb, tmp);
} else {
for (; i < samples; i++, sample++) {
s->decoded[channel][sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
}
}
i= 0;
}
return 0;
}
| false | FFmpeg | ea98507db018c7b0ea7a167281a210ba1328dde7 | static int decode_residuals(FLACContext *s, int channel, int pred_order)
{
int i, tmp, partition, method_type, rice_order;
int sample = 0, samples;
method_type = get_bits(&s->gb, 2);
if (method_type > 1) {
av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
method_type);
return -1;
}
rice_order = get_bits(&s->gb, 4);
samples= s->blocksize >> rice_order;
if (pred_order > samples) {
av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n",
pred_order, samples);
return -1;
}
sample=
i= pred_order;
for (partition = 0; partition < (1 << rice_order); partition++) {
tmp = get_bits(&s->gb, method_type == 0 ? 4 : 5);
if (tmp == (method_type == 0 ? 15 : 31)) {
tmp = get_bits(&s->gb, 5);
for (; i < samples; i++, sample++)
s->decoded[channel][sample] = get_sbits_long(&s->gb, tmp);
} else {
for (; i < samples; i++, sample++) {
s->decoded[channel][sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
}
}
i= 0;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FLACContext *VAR_0, int VAR_1, int VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
int VAR_8 = 0, VAR_9;
VAR_6 = get_bits(&VAR_0->gb, 2);
if (VAR_6 > 1) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
VAR_6);
return -1;
}
VAR_7 = get_bits(&VAR_0->gb, 4);
VAR_9= VAR_0->blocksize >> VAR_7;
if (VAR_2 > VAR_9) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid predictor order: %VAR_3 > %VAR_3\n",
VAR_2, VAR_9);
return -1;
}
VAR_8=
VAR_3= VAR_2;
for (VAR_5 = 0; VAR_5 < (1 << VAR_7); VAR_5++) {
VAR_4 = get_bits(&VAR_0->gb, VAR_6 == 0 ? 4 : 5);
if (VAR_4 == (VAR_6 == 0 ? 15 : 31)) {
VAR_4 = get_bits(&VAR_0->gb, 5);
for (; VAR_3 < VAR_9; VAR_3++, VAR_8++)
VAR_0->decoded[VAR_1][VAR_8] = get_sbits_long(&VAR_0->gb, VAR_4);
} else {
for (; VAR_3 < VAR_9; VAR_3++, VAR_8++) {
VAR_0->decoded[VAR_1][VAR_8] = get_sr_golomb_flac(&VAR_0->gb, VAR_4, INT_MAX, 0);
}
}
VAR_3= 0;
}
return 0;
}
| [
"static int FUNC_0(FLACContext *VAR_0, int VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"int VAR_8 = 0, VAR_9;",
"VAR_6 = get_bits(&VAR_0->gb, 2);",
"if (VAR_6 > 1) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"illegal residual coding method %d\\n\",\nVAR_6);",
"return -1;",
"}",
"VAR_7 = get_bits(&VAR_0->gb, 4);",
"VAR_9= VAR_0->blocksize >> VAR_7;",
"if (VAR_2 > VAR_9) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid predictor order: %VAR_3 > %VAR_3\\n\",\nVAR_2, VAR_9);",
"return -1;",
"}",
"VAR_8=\nVAR_3= VAR_2;",
"for (VAR_5 = 0; VAR_5 < (1 << VAR_7); VAR_5++) {",
"VAR_4 = get_bits(&VAR_0->gb, VAR_6 == 0 ? 4 : 5);",
"if (VAR_4 == (VAR_6 == 0 ? 15 : 31)) {",
"VAR_4 = get_bits(&VAR_0->gb, 5);",
"for (; VAR_3 < VAR_9; VAR_3++, VAR_8++)",
"VAR_0->decoded[VAR_1][VAR_8] = get_sbits_long(&VAR_0->gb, VAR_4);",
"} else {",
"for (; VAR_3 < VAR_9; VAR_3++, VAR_8++) {",
"VAR_0->decoded[VAR_1][VAR_8] = get_sr_golomb_flac(&VAR_0->gb, VAR_4, INT_MAX, 0);",
"}",
"}",
"VAR_3= 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,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
]
]
|
10,413 | static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
{
int ret, i;
AVFormatContext *dev = NULL;
AVDeviceInfoList *device_list = NULL;
AVDictionary *tmp_opts = NULL;
if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category))
return AVERROR(EINVAL);
printf("Audo-detected sinks for %s:\n", fmt->name);
if (!fmt->get_device_list) {
ret = AVERROR(ENOSYS);
printf("Cannot list sinks. Not implemented.\n");
goto fail;
}
if ((ret = avformat_alloc_output_context2(&dev, fmt, NULL, NULL)) < 0) {
printf("Cannot open device: %s.\n", fmt->name);
goto fail;
}
av_dict_copy(&tmp_opts, opts, 0);
av_opt_set_dict2(dev, &tmp_opts, AV_OPT_SEARCH_CHILDREN);
if ((ret = avdevice_list_devices(dev, &device_list)) < 0) {
printf("Cannot list sinks.\n");
goto fail;
}
for (i = 0; i < device_list->nb_devices; i++) {
printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
device_list->devices[i]->device_name, device_list->devices[i]->device_description);
}
fail:
av_dict_free(&tmp_opts);
avdevice_free_list_devices(&device_list);
avformat_free_context(dev);
return ret;
}
| true | FFmpeg | 44e6eeb30de8e2d20db56284984da4615763525c | static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
{
int ret, i;
AVFormatContext *dev = NULL;
AVDeviceInfoList *device_list = NULL;
AVDictionary *tmp_opts = NULL;
if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category))
return AVERROR(EINVAL);
printf("Audo-detected sinks for %s:\n", fmt->name);
if (!fmt->get_device_list) {
ret = AVERROR(ENOSYS);
printf("Cannot list sinks. Not implemented.\n");
goto fail;
}
if ((ret = avformat_alloc_output_context2(&dev, fmt, NULL, NULL)) < 0) {
printf("Cannot open device: %s.\n", fmt->name);
goto fail;
}
av_dict_copy(&tmp_opts, opts, 0);
av_opt_set_dict2(dev, &tmp_opts, AV_OPT_SEARCH_CHILDREN);
if ((ret = avdevice_list_devices(dev, &device_list)) < 0) {
printf("Cannot list sinks.\n");
goto fail;
}
for (i = 0; i < device_list->nb_devices; i++) {
printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
device_list->devices[i]->device_name, device_list->devices[i]->device_description);
}
fail:
av_dict_free(&tmp_opts);
avdevice_free_list_devices(&device_list);
avformat_free_context(dev);
return ret;
}
| {
"code": [
" AVFormatContext *dev = NULL;",
" AVDictionary *tmp_opts = NULL;",
" av_dict_copy(&tmp_opts, opts, 0);",
" printf(\"Cannot open device: %s.\\n\", fmt->name);",
" goto fail;",
" if ((ret = avdevice_list_devices(dev, &device_list)) < 0) {",
" av_dict_free(&tmp_opts);",
" AVFormatContext *dev = NULL;",
" AVDictionary *tmp_opts = NULL;",
" if ((ret = avformat_alloc_output_context2(&dev, fmt, NULL, NULL)) < 0) {",
" printf(\"Cannot open device: %s.\\n\", fmt->name);",
" goto fail;",
" av_dict_copy(&tmp_opts, opts, 0);",
" av_opt_set_dict2(dev, &tmp_opts, AV_OPT_SEARCH_CHILDREN);",
" if ((ret = avdevice_list_devices(dev, &device_list)) < 0) {",
" av_dict_free(&tmp_opts);",
" avformat_free_context(dev);"
],
"line_no": [
7,
11,
43,
37,
29,
49,
71,
7,
11,
35,
37,
29,
43,
45,
49,
71,
75
]
} | static int FUNC_0(AVOutputFormat *VAR_0, AVDictionary *VAR_1)
{
int VAR_2, VAR_3;
AVFormatContext *dev = NULL;
AVDeviceInfoList *device_list = NULL;
AVDictionary *tmp_opts = NULL;
if (!VAR_0 || !VAR_0->priv_class || !AV_IS_OUTPUT_DEVICE(VAR_0->priv_class->category))
return AVERROR(EINVAL);
printf("Audo-detected sinks for %s:\n", VAR_0->name);
if (!VAR_0->get_device_list) {
VAR_2 = AVERROR(ENOSYS);
printf("Cannot list sinks. Not implemented.\n");
goto fail;
}
if ((VAR_2 = avformat_alloc_output_context2(&dev, VAR_0, NULL, NULL)) < 0) {
printf("Cannot open device: %s.\n", VAR_0->name);
goto fail;
}
av_dict_copy(&tmp_opts, VAR_1, 0);
av_opt_set_dict2(dev, &tmp_opts, AV_OPT_SEARCH_CHILDREN);
if ((VAR_2 = avdevice_list_devices(dev, &device_list)) < 0) {
printf("Cannot list sinks.\n");
goto fail;
}
for (VAR_3 = 0; VAR_3 < device_list->nb_devices; VAR_3++) {
printf("%s %s [%s]\n", device_list->default_device == VAR_3 ? "*" : " ",
device_list->devices[VAR_3]->device_name, device_list->devices[VAR_3]->device_description);
}
fail:
av_dict_free(&tmp_opts);
avdevice_free_list_devices(&device_list);
avformat_free_context(dev);
return VAR_2;
}
| [
"static int FUNC_0(AVOutputFormat *VAR_0, AVDictionary *VAR_1)\n{",
"int VAR_2, VAR_3;",
"AVFormatContext *dev = NULL;",
"AVDeviceInfoList *device_list = NULL;",
"AVDictionary *tmp_opts = NULL;",
"if (!VAR_0 || !VAR_0->priv_class || !AV_IS_OUTPUT_DEVICE(VAR_0->priv_class->category))\nreturn AVERROR(EINVAL);",
"printf(\"Audo-detected sinks for %s:\\n\", VAR_0->name);",
"if (!VAR_0->get_device_list) {",
"VAR_2 = AVERROR(ENOSYS);",
"printf(\"Cannot list sinks. Not implemented.\\n\");",
"goto fail;",
"}",
"if ((VAR_2 = avformat_alloc_output_context2(&dev, VAR_0, NULL, NULL)) < 0) {",
"printf(\"Cannot open device: %s.\\n\", VAR_0->name);",
"goto fail;",
"}",
"av_dict_copy(&tmp_opts, VAR_1, 0);",
"av_opt_set_dict2(dev, &tmp_opts, AV_OPT_SEARCH_CHILDREN);",
"if ((VAR_2 = avdevice_list_devices(dev, &device_list)) < 0) {",
"printf(\"Cannot list sinks.\\n\");",
"goto fail;",
"}",
"for (VAR_3 = 0; VAR_3 < device_list->nb_devices; VAR_3++) {",
"printf(\"%s %s [%s]\\n\", device_list->default_device == VAR_3 ? \"*\" : \" \",\ndevice_list->devices[VAR_3]->device_name, device_list->devices[VAR_3]->device_description);",
"}",
"fail:\nav_dict_free(&tmp_opts);",
"avdevice_free_list_devices(&device_list);",
"avformat_free_context(dev);",
"return VAR_2;",
"}"
]
| [
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61,
63
],
[
65
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
]
]
|
10,415 | static int bmp_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
BMPContext *s = avctx->priv_data;
AVFrame *picture = data;
AVFrame *p = &s->picture;
unsigned int fsize, hsize;
int width, height;
unsigned int depth;
BiCompression comp;
unsigned int ihsize;
int i, j, n, linesize;
uint32_t rgb[3];
uint8_t *ptr;
int dsize;
uint8_t *buf0 = buf;
if(buf_size < 14){
av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size);
return -1;
}
if(bytestream_get_byte(&buf) != 'B' ||
bytestream_get_byte(&buf) != 'M') {
av_log(avctx, AV_LOG_ERROR, "bad magic number\n");
return -1;
}
fsize = bytestream_get_le32(&buf);
if(buf_size < fsize){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
buf_size, fsize);
return -1;
}
buf += 2; /* reserved1 */
buf += 2; /* reserved2 */
hsize = bytestream_get_le32(&buf); /* header size */
if(fsize <= hsize){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
fsize, hsize);
return -1;
}
ihsize = bytestream_get_le32(&buf); /* more header size */
if(ihsize + 14 > hsize){
av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize);
return -1;
}
width = bytestream_get_le32(&buf);
height = bytestream_get_le32(&buf);
if(bytestream_get_le16(&buf) != 1){ /* planes */
av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n");
return -1;
}
depth = bytestream_get_le16(&buf);
if(ihsize > 16)
comp = bytestream_get_le32(&buf);
else
comp = BMP_RGB;
if(comp != BMP_RGB && comp != BMP_BITFIELDS){
av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp);
return -1;
}
if(comp == BMP_BITFIELDS){
buf += 20;
rgb[0] = bytestream_get_le32(&buf);
rgb[1] = bytestream_get_le32(&buf);
rgb[2] = bytestream_get_le32(&buf);
}
avctx->codec_id = CODEC_ID_BMP;
avctx->width = width;
avctx->height = height > 0? height: -height;
avctx->pix_fmt = PIX_FMT_NONE;
switch(depth){
case 32:
if(comp == BMP_BITFIELDS){
rgb[0] = (rgb[0] >> 15) & 3;
rgb[1] = (rgb[1] >> 15) & 3;
rgb[2] = (rgb[2] >> 15) & 3;
if(rgb[0] + rgb[1] + rgb[2] != 3 ||
rgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){
break;
}
} else {
rgb[0] = 2;
rgb[1] = 1;
rgb[2] = 0;
}
avctx->pix_fmt = PIX_FMT_BGR24;
break;
case 24:
avctx->pix_fmt = PIX_FMT_BGR24;
break;
case 16:
if(comp == BMP_RGB)
avctx->pix_fmt = PIX_FMT_RGB555;
break;
default:
av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth);
return -1;
}
if(avctx->pix_fmt == PIX_FMT_NONE){
av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");
return -1;
}
if(p->data[0])
avctx->release_buffer(avctx, p);
p->reference = 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type = FF_I_TYPE;
p->key_frame = 1;
buf = buf0 + hsize;
dsize = buf_size - hsize;
/* Line size in file multiple of 4 */
n = (avctx->width * (depth / 8) + 3) & ~3;
if(n * avctx->height > dsize){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
dsize, n * avctx->height);
return -1;
}
if(height > 0){
ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
linesize = -p->linesize[0];
} else {
ptr = p->data[0];
linesize = p->linesize[0];
}
switch(depth){
case 24:
for(i = 0; i < avctx->height; i++){
memcpy(ptr, buf, n);
buf += n;
ptr += linesize;
}
break;
case 16:
for(i = 0; i < avctx->height; i++){
uint16_t *src = (uint16_t *) buf;
uint16_t *dst = (uint16_t *) ptr;
for(j = 0; j < avctx->width; j++)
*dst++ = le2me_16(*src++);
buf += n;
ptr += linesize;
}
break;
case 32:
for(i = 0; i < avctx->height; i++){
uint8_t *src = buf;
uint8_t *dst = ptr;
for(j = 0; j < avctx->width; j++){
dst[0] = src[rgb[2]];
dst[1] = src[rgb[1]];
dst[2] = src[rgb[0]];
dst += 3;
src += 4;
}
buf += n;
ptr += linesize;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n");
return -1;
}
*picture = s->picture;
*data_size = sizeof(AVPicture);
return buf_size;
}
| true | FFmpeg | e8f917d6fd9f42fa4f36fd6dd8a21c1e31cd1c26 | static int bmp_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
BMPContext *s = avctx->priv_data;
AVFrame *picture = data;
AVFrame *p = &s->picture;
unsigned int fsize, hsize;
int width, height;
unsigned int depth;
BiCompression comp;
unsigned int ihsize;
int i, j, n, linesize;
uint32_t rgb[3];
uint8_t *ptr;
int dsize;
uint8_t *buf0 = buf;
if(buf_size < 14){
av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size);
return -1;
}
if(bytestream_get_byte(&buf) != 'B' ||
bytestream_get_byte(&buf) != 'M') {
av_log(avctx, AV_LOG_ERROR, "bad magic number\n");
return -1;
}
fsize = bytestream_get_le32(&buf);
if(buf_size < fsize){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
buf_size, fsize);
return -1;
}
buf += 2;
buf += 2;
hsize = bytestream_get_le32(&buf);
if(fsize <= hsize){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
fsize, hsize);
return -1;
}
ihsize = bytestream_get_le32(&buf);
if(ihsize + 14 > hsize){
av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize);
return -1;
}
width = bytestream_get_le32(&buf);
height = bytestream_get_le32(&buf);
if(bytestream_get_le16(&buf) != 1){
av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n");
return -1;
}
depth = bytestream_get_le16(&buf);
if(ihsize > 16)
comp = bytestream_get_le32(&buf);
else
comp = BMP_RGB;
if(comp != BMP_RGB && comp != BMP_BITFIELDS){
av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp);
return -1;
}
if(comp == BMP_BITFIELDS){
buf += 20;
rgb[0] = bytestream_get_le32(&buf);
rgb[1] = bytestream_get_le32(&buf);
rgb[2] = bytestream_get_le32(&buf);
}
avctx->codec_id = CODEC_ID_BMP;
avctx->width = width;
avctx->height = height > 0? height: -height;
avctx->pix_fmt = PIX_FMT_NONE;
switch(depth){
case 32:
if(comp == BMP_BITFIELDS){
rgb[0] = (rgb[0] >> 15) & 3;
rgb[1] = (rgb[1] >> 15) & 3;
rgb[2] = (rgb[2] >> 15) & 3;
if(rgb[0] + rgb[1] + rgb[2] != 3 ||
rgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){
break;
}
} else {
rgb[0] = 2;
rgb[1] = 1;
rgb[2] = 0;
}
avctx->pix_fmt = PIX_FMT_BGR24;
break;
case 24:
avctx->pix_fmt = PIX_FMT_BGR24;
break;
case 16:
if(comp == BMP_RGB)
avctx->pix_fmt = PIX_FMT_RGB555;
break;
default:
av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth);
return -1;
}
if(avctx->pix_fmt == PIX_FMT_NONE){
av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");
return -1;
}
if(p->data[0])
avctx->release_buffer(avctx, p);
p->reference = 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type = FF_I_TYPE;
p->key_frame = 1;
buf = buf0 + hsize;
dsize = buf_size - hsize;
n = (avctx->width * (depth / 8) + 3) & ~3;
if(n * avctx->height > dsize){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
dsize, n * avctx->height);
return -1;
}
if(height > 0){
ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
linesize = -p->linesize[0];
} else {
ptr = p->data[0];
linesize = p->linesize[0];
}
switch(depth){
case 24:
for(i = 0; i < avctx->height; i++){
memcpy(ptr, buf, n);
buf += n;
ptr += linesize;
}
break;
case 16:
for(i = 0; i < avctx->height; i++){
uint16_t *src = (uint16_t *) buf;
uint16_t *dst = (uint16_t *) ptr;
for(j = 0; j < avctx->width; j++)
*dst++ = le2me_16(*src++);
buf += n;
ptr += linesize;
}
break;
case 32:
for(i = 0; i < avctx->height; i++){
uint8_t *src = buf;
uint8_t *dst = ptr;
for(j = 0; j < avctx->width; j++){
dst[0] = src[rgb[2]];
dst[1] = src[rgb[1]];
dst[2] = src[rgb[0]];
dst += 3;
src += 4;
}
buf += n;
ptr += linesize;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n");
return -1;
}
*picture = s->picture;
*data_size = sizeof(AVPicture);
return buf_size;
}
| {
"code": [
" memcpy(ptr, buf, n);"
],
"line_no": [
311
]
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
BMPContext *s = VAR_0->priv_data;
AVFrame *picture = VAR_1;
AVFrame *p = &s->picture;
unsigned int VAR_5, VAR_6;
int VAR_7, VAR_8;
unsigned int VAR_9;
BiCompression comp;
unsigned int VAR_10;
int VAR_11, VAR_12, VAR_13, VAR_14;
uint32_t rgb[3];
uint8_t *ptr;
int VAR_15;
uint8_t *buf0 = VAR_3;
if(VAR_4 < 14){
av_log(VAR_0, AV_LOG_ERROR, "VAR_3 size too small (%d)\VAR_13", VAR_4);
return -1;
}
if(bytestream_get_byte(&VAR_3) != 'B' ||
bytestream_get_byte(&VAR_3) != 'M') {
av_log(VAR_0, AV_LOG_ERROR, "bad magic number\VAR_13");
return -1;
}
VAR_5 = bytestream_get_le32(&VAR_3);
if(VAR_4 < VAR_5){
av_log(VAR_0, AV_LOG_ERROR, "not enough VAR_1 (%d < %d)\VAR_13",
VAR_4, VAR_5);
return -1;
}
VAR_3 += 2;
VAR_3 += 2;
VAR_6 = bytestream_get_le32(&VAR_3);
if(VAR_5 <= VAR_6){
av_log(VAR_0, AV_LOG_ERROR, "not enough VAR_1 (%d < %d)\VAR_13",
VAR_5, VAR_6);
return -1;
}
VAR_10 = bytestream_get_le32(&VAR_3);
if(VAR_10 + 14 > VAR_6){
av_log(VAR_0, AV_LOG_ERROR, "invalid header size %d\VAR_13", VAR_6);
return -1;
}
VAR_7 = bytestream_get_le32(&VAR_3);
VAR_8 = bytestream_get_le32(&VAR_3);
if(bytestream_get_le16(&VAR_3) != 1){
av_log(VAR_0, AV_LOG_ERROR, "invalid BMP header\VAR_13");
return -1;
}
VAR_9 = bytestream_get_le16(&VAR_3);
if(VAR_10 > 16)
comp = bytestream_get_le32(&VAR_3);
else
comp = BMP_RGB;
if(comp != BMP_RGB && comp != BMP_BITFIELDS){
av_log(VAR_0, AV_LOG_ERROR, "BMP coding %d not supported\VAR_13", comp);
return -1;
}
if(comp == BMP_BITFIELDS){
VAR_3 += 20;
rgb[0] = bytestream_get_le32(&VAR_3);
rgb[1] = bytestream_get_le32(&VAR_3);
rgb[2] = bytestream_get_le32(&VAR_3);
}
VAR_0->codec_id = CODEC_ID_BMP;
VAR_0->VAR_7 = VAR_7;
VAR_0->VAR_8 = VAR_8 > 0? VAR_8: -VAR_8;
VAR_0->pix_fmt = PIX_FMT_NONE;
switch(VAR_9){
case 32:
if(comp == BMP_BITFIELDS){
rgb[0] = (rgb[0] >> 15) & 3;
rgb[1] = (rgb[1] >> 15) & 3;
rgb[2] = (rgb[2] >> 15) & 3;
if(rgb[0] + rgb[1] + rgb[2] != 3 ||
rgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){
break;
}
} else {
rgb[0] = 2;
rgb[1] = 1;
rgb[2] = 0;
}
VAR_0->pix_fmt = PIX_FMT_BGR24;
break;
case 24:
VAR_0->pix_fmt = PIX_FMT_BGR24;
break;
case 16:
if(comp == BMP_RGB)
VAR_0->pix_fmt = PIX_FMT_RGB555;
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "VAR_9 %d not supported\VAR_13", VAR_9);
return -1;
}
if(VAR_0->pix_fmt == PIX_FMT_NONE){
av_log(VAR_0, AV_LOG_ERROR, "unsupported pixel format\VAR_13");
return -1;
}
if(p->VAR_1[0])
VAR_0->release_buffer(VAR_0, p);
p->reference = 0;
if(VAR_0->get_buffer(VAR_0, p) < 0){
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\VAR_13");
return -1;
}
p->pict_type = FF_I_TYPE;
p->key_frame = 1;
VAR_3 = buf0 + VAR_6;
VAR_15 = VAR_4 - VAR_6;
VAR_13 = (VAR_0->VAR_7 * (VAR_9 / 8) + 3) & ~3;
if(VAR_13 * VAR_0->VAR_8 > VAR_15){
av_log(VAR_0, AV_LOG_ERROR, "not enough VAR_1 (%d < %d)\VAR_13",
VAR_15, VAR_13 * VAR_0->VAR_8);
return -1;
}
if(VAR_8 > 0){
ptr = p->VAR_1[0] + (VAR_0->VAR_8 - 1) * p->VAR_14[0];
VAR_14 = -p->VAR_14[0];
} else {
ptr = p->VAR_1[0];
VAR_14 = p->VAR_14[0];
}
switch(VAR_9){
case 24:
for(VAR_11 = 0; VAR_11 < VAR_0->VAR_8; VAR_11++){
memcpy(ptr, VAR_3, VAR_13);
VAR_3 += VAR_13;
ptr += VAR_14;
}
break;
case 16:
for(VAR_11 = 0; VAR_11 < VAR_0->VAR_8; VAR_11++){
uint16_t *src = (uint16_t *) VAR_3;
uint16_t *dst = (uint16_t *) ptr;
for(VAR_12 = 0; VAR_12 < VAR_0->VAR_7; VAR_12++)
*dst++ = le2me_16(*src++);
VAR_3 += VAR_13;
ptr += VAR_14;
}
break;
case 32:
for(VAR_11 = 0; VAR_11 < VAR_0->VAR_8; VAR_11++){
uint8_t *src = VAR_3;
uint8_t *dst = ptr;
for(VAR_12 = 0; VAR_12 < VAR_0->VAR_7; VAR_12++){
dst[0] = src[rgb[2]];
dst[1] = src[rgb[1]];
dst[2] = src[rgb[0]];
dst += 3;
src += 4;
}
VAR_3 += VAR_13;
ptr += VAR_14;
}
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "BMP decoder is broken\VAR_13");
return -1;
}
*picture = s->picture;
*VAR_2 = sizeof(AVPicture);
return VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"BMPContext *s = VAR_0->priv_data;",
"AVFrame *picture = VAR_1;",
"AVFrame *p = &s->picture;",
"unsigned int VAR_5, VAR_6;",
"int VAR_7, VAR_8;",
"unsigned int VAR_9;",
"BiCompression comp;",
"unsigned int VAR_10;",
"int VAR_11, VAR_12, VAR_13, VAR_14;",
"uint32_t rgb[3];",
"uint8_t *ptr;",
"int VAR_15;",
"uint8_t *buf0 = VAR_3;",
"if(VAR_4 < 14){",
"av_log(VAR_0, AV_LOG_ERROR, \"VAR_3 size too small (%d)\\VAR_13\", VAR_4);",
"return -1;",
"}",
"if(bytestream_get_byte(&VAR_3) != 'B' ||\nbytestream_get_byte(&VAR_3) != 'M') {",
"av_log(VAR_0, AV_LOG_ERROR, \"bad magic number\\VAR_13\");",
"return -1;",
"}",
"VAR_5 = bytestream_get_le32(&VAR_3);",
"if(VAR_4 < VAR_5){",
"av_log(VAR_0, AV_LOG_ERROR, \"not enough VAR_1 (%d < %d)\\VAR_13\",\nVAR_4, VAR_5);",
"return -1;",
"}",
"VAR_3 += 2;",
"VAR_3 += 2;",
"VAR_6 = bytestream_get_le32(&VAR_3);",
"if(VAR_5 <= VAR_6){",
"av_log(VAR_0, AV_LOG_ERROR, \"not enough VAR_1 (%d < %d)\\VAR_13\",\nVAR_5, VAR_6);",
"return -1;",
"}",
"VAR_10 = bytestream_get_le32(&VAR_3);",
"if(VAR_10 + 14 > VAR_6){",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid header size %d\\VAR_13\", VAR_6);",
"return -1;",
"}",
"VAR_7 = bytestream_get_le32(&VAR_3);",
"VAR_8 = bytestream_get_le32(&VAR_3);",
"if(bytestream_get_le16(&VAR_3) != 1){",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid BMP header\\VAR_13\");",
"return -1;",
"}",
"VAR_9 = bytestream_get_le16(&VAR_3);",
"if(VAR_10 > 16)\ncomp = bytestream_get_le32(&VAR_3);",
"else\ncomp = BMP_RGB;",
"if(comp != BMP_RGB && comp != BMP_BITFIELDS){",
"av_log(VAR_0, AV_LOG_ERROR, \"BMP coding %d not supported\\VAR_13\", comp);",
"return -1;",
"}",
"if(comp == BMP_BITFIELDS){",
"VAR_3 += 20;",
"rgb[0] = bytestream_get_le32(&VAR_3);",
"rgb[1] = bytestream_get_le32(&VAR_3);",
"rgb[2] = bytestream_get_le32(&VAR_3);",
"}",
"VAR_0->codec_id = CODEC_ID_BMP;",
"VAR_0->VAR_7 = VAR_7;",
"VAR_0->VAR_8 = VAR_8 > 0? VAR_8: -VAR_8;",
"VAR_0->pix_fmt = PIX_FMT_NONE;",
"switch(VAR_9){",
"case 32:\nif(comp == BMP_BITFIELDS){",
"rgb[0] = (rgb[0] >> 15) & 3;",
"rgb[1] = (rgb[1] >> 15) & 3;",
"rgb[2] = (rgb[2] >> 15) & 3;",
"if(rgb[0] + rgb[1] + rgb[2] != 3 ||\nrgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){",
"break;",
"}",
"} else {",
"rgb[0] = 2;",
"rgb[1] = 1;",
"rgb[2] = 0;",
"}",
"VAR_0->pix_fmt = PIX_FMT_BGR24;",
"break;",
"case 24:\nVAR_0->pix_fmt = PIX_FMT_BGR24;",
"break;",
"case 16:\nif(comp == BMP_RGB)\nVAR_0->pix_fmt = PIX_FMT_RGB555;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"VAR_9 %d not supported\\VAR_13\", VAR_9);",
"return -1;",
"}",
"if(VAR_0->pix_fmt == PIX_FMT_NONE){",
"av_log(VAR_0, AV_LOG_ERROR, \"unsupported pixel format\\VAR_13\");",
"return -1;",
"}",
"if(p->VAR_1[0])\nVAR_0->release_buffer(VAR_0, p);",
"p->reference = 0;",
"if(VAR_0->get_buffer(VAR_0, p) < 0){",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\VAR_13\");",
"return -1;",
"}",
"p->pict_type = FF_I_TYPE;",
"p->key_frame = 1;",
"VAR_3 = buf0 + VAR_6;",
"VAR_15 = VAR_4 - VAR_6;",
"VAR_13 = (VAR_0->VAR_7 * (VAR_9 / 8) + 3) & ~3;",
"if(VAR_13 * VAR_0->VAR_8 > VAR_15){",
"av_log(VAR_0, AV_LOG_ERROR, \"not enough VAR_1 (%d < %d)\\VAR_13\",\nVAR_15, VAR_13 * VAR_0->VAR_8);",
"return -1;",
"}",
"if(VAR_8 > 0){",
"ptr = p->VAR_1[0] + (VAR_0->VAR_8 - 1) * p->VAR_14[0];",
"VAR_14 = -p->VAR_14[0];",
"} else {",
"ptr = p->VAR_1[0];",
"VAR_14 = p->VAR_14[0];",
"}",
"switch(VAR_9){",
"case 24:\nfor(VAR_11 = 0; VAR_11 < VAR_0->VAR_8; VAR_11++){",
"memcpy(ptr, VAR_3, VAR_13);",
"VAR_3 += VAR_13;",
"ptr += VAR_14;",
"}",
"break;",
"case 16:\nfor(VAR_11 = 0; VAR_11 < VAR_0->VAR_8; VAR_11++){",
"uint16_t *src = (uint16_t *) VAR_3;",
"uint16_t *dst = (uint16_t *) ptr;",
"for(VAR_12 = 0; VAR_12 < VAR_0->VAR_7; VAR_12++)",
"*dst++ = le2me_16(*src++);",
"VAR_3 += VAR_13;",
"ptr += VAR_14;",
"}",
"break;",
"case 32:\nfor(VAR_11 = 0; VAR_11 < VAR_0->VAR_8; VAR_11++){",
"uint8_t *src = VAR_3;",
"uint8_t *dst = ptr;",
"for(VAR_12 = 0; VAR_12 < VAR_0->VAR_7; VAR_12++){",
"dst[0] = src[rgb[2]];",
"dst[1] = src[rgb[1]];",
"dst[2] = src[rgb[0]];",
"dst += 3;",
"src += 4;",
"}",
"VAR_3 += VAR_13;",
"ptr += VAR_14;",
"}",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"BMP decoder is broken\\VAR_13\");",
"return -1;",
"}",
"*picture = s->picture;",
"*VAR_2 = sizeof(AVPicture);",
"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,
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
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
125,
127
],
[
129,
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
167
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215,
217,
219
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239
],
[
243,
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
265
],
[
267
],
[
273
],
[
277
],
[
279,
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
305
],
[
307,
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321,
323
],
[
325
],
[
327
],
[
331
],
[
333
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345,
347
],
[
349
],
[
351
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379,
381
],
[
383
],
[
385
],
[
389
],
[
391
],
[
395
],
[
397
]
]
|
10,417 | void HELPER(stfl)(CPUS390XState *env)
{
uint64_t words[MAX_STFL_WORDS];
do_stfle(env, words);
cpu_stl_data(env, 200, words[0] >> 32);
}
| true | qemu | 86b5ab390992fd57f3a23764994a7e082bcc2fc4 | void HELPER(stfl)(CPUS390XState *env)
{
uint64_t words[MAX_STFL_WORDS];
do_stfle(env, words);
cpu_stl_data(env, 200, words[0] >> 32);
}
| {
"code": [
" cpu_stl_data(env, 200, words[0] >> 32);"
],
"line_no": [
11
]
} | void FUNC_0(stfl)(CPUS390XState *env)
{
uint64_t words[MAX_STFL_WORDS];
do_stfle(env, words);
cpu_stl_data(env, 200, words[0] >> 32);
}
| [
"void FUNC_0(stfl)(CPUS390XState *env)\n{",
"uint64_t words[MAX_STFL_WORDS];",
"do_stfle(env, words);",
"cpu_stl_data(env, 200, words[0] >> 32);",
"}"
]
| [
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
]
|
10,418 | static QDict *qmp_check_input_obj(QObject *input_obj)
{
const QDictEntry *ent;
int has_exec_key = 0;
QDict *input_dict;
if (qobject_type(input_obj) != QTYPE_QDICT) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "object");
return NULL;
}
input_dict = qobject_to_qdict(input_obj);
for (ent = qdict_first(input_dict); ent; ent = qdict_next(input_dict, ent)){
const char *arg_name = qdict_entry_key(ent);
const QObject *arg_obj = qdict_entry_value(ent);
if (!strcmp(arg_name, "execute")) {
if (qobject_type(arg_obj) != QTYPE_QSTRING) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute",
"string");
return NULL;
}
has_exec_key = 1;
} else if (!strcmp(arg_name, "arguments")) {
if (qobject_type(arg_obj) != QTYPE_QDICT) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "arguments",
"object");
return NULL;
}
} else if (!strcmp(arg_name, "id")) {
/* FIXME: check duplicated IDs for async commands */
} else {
qerror_report(QERR_QMP_EXTRA_MEMBER, arg_name);
return NULL;
}
}
if (!has_exec_key) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "execute");
return NULL;
}
return input_dict;
}
| true | qemu | 65207c59d99f2260c5f1d3b9c491146616a522aa | static QDict *qmp_check_input_obj(QObject *input_obj)
{
const QDictEntry *ent;
int has_exec_key = 0;
QDict *input_dict;
if (qobject_type(input_obj) != QTYPE_QDICT) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "object");
return NULL;
}
input_dict = qobject_to_qdict(input_obj);
for (ent = qdict_first(input_dict); ent; ent = qdict_next(input_dict, ent)){
const char *arg_name = qdict_entry_key(ent);
const QObject *arg_obj = qdict_entry_value(ent);
if (!strcmp(arg_name, "execute")) {
if (qobject_type(arg_obj) != QTYPE_QSTRING) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute",
"string");
return NULL;
}
has_exec_key = 1;
} else if (!strcmp(arg_name, "arguments")) {
if (qobject_type(arg_obj) != QTYPE_QDICT) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "arguments",
"object");
return NULL;
}
} else if (!strcmp(arg_name, "id")) {
} else {
qerror_report(QERR_QMP_EXTRA_MEMBER, arg_name);
return NULL;
}
}
if (!has_exec_key) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "execute");
return NULL;
}
return input_dict;
}
| {
"code": [
" } else if (!strcmp(arg_name, \"id\")) {"
],
"line_no": [
61
]
} | static QDict *FUNC_0(QObject *input_obj)
{
const QDictEntry *VAR_0;
int VAR_1 = 0;
QDict *input_dict;
if (qobject_type(input_obj) != QTYPE_QDICT) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "object");
return NULL;
}
input_dict = qobject_to_qdict(input_obj);
for (VAR_0 = qdict_first(input_dict); VAR_0; VAR_0 = qdict_next(input_dict, VAR_0)){
const char *arg_name = qdict_entry_key(VAR_0);
const QObject *arg_obj = qdict_entry_value(VAR_0);
if (!strcmp(arg_name, "execute")) {
if (qobject_type(arg_obj) != QTYPE_QSTRING) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute",
"string");
return NULL;
}
VAR_1 = 1;
} else if (!strcmp(arg_name, "arguments")) {
if (qobject_type(arg_obj) != QTYPE_QDICT) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "arguments",
"object");
return NULL;
}
} else if (!strcmp(arg_name, "id")) {
} else {
qerror_report(QERR_QMP_EXTRA_MEMBER, arg_name);
return NULL;
}
}
if (!VAR_1) {
qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "execute");
return NULL;
}
return input_dict;
}
| [
"static QDict *FUNC_0(QObject *input_obj)\n{",
"const QDictEntry *VAR_0;",
"int VAR_1 = 0;",
"QDict *input_dict;",
"if (qobject_type(input_obj) != QTYPE_QDICT) {",
"qerror_report(QERR_QMP_BAD_INPUT_OBJECT, \"object\");",
"return NULL;",
"}",
"input_dict = qobject_to_qdict(input_obj);",
"for (VAR_0 = qdict_first(input_dict); VAR_0; VAR_0 = qdict_next(input_dict, VAR_0)){",
"const char *arg_name = qdict_entry_key(VAR_0);",
"const QObject *arg_obj = qdict_entry_value(VAR_0);",
"if (!strcmp(arg_name, \"execute\")) {",
"if (qobject_type(arg_obj) != QTYPE_QSTRING) {",
"qerror_report(QERR_QMP_BAD_INPUT_OBJECT_MEMBER, \"execute\",\n\"string\");",
"return NULL;",
"}",
"VAR_1 = 1;",
"} else if (!strcmp(arg_name, \"arguments\")) {",
"if (qobject_type(arg_obj) != QTYPE_QDICT) {",
"qerror_report(QERR_QMP_BAD_INPUT_OBJECT_MEMBER, \"arguments\",\n\"object\");",
"return NULL;",
"}",
"} else if (!strcmp(arg_name, \"id\")) {",
"} else {",
"qerror_report(QERR_QMP_EXTRA_MEMBER, arg_name);",
"return NULL;",
"}",
"}",
"if (!VAR_1) {",
"qerror_report(QERR_QMP_BAD_INPUT_OBJECT, \"execute\");",
"return NULL;",
"}",
"return input_dict;",
"}"
]
| [
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,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
]
]
|
10,419 | static void add_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
/* read the pixels */
for(i=0;i<4;i++) {
pixels[0] = cm[pixels[0] + block[0]];
pixels[1] = cm[pixels[1] + block[1]];
pixels[2] = cm[pixels[2] + block[2]];
pixels[3] = cm[pixels[3] + block[3]];
pixels += line_size;
block += 8;
}
}
| true | FFmpeg | c23acbaed40101c677dfcfbbfe0d2c230a8e8f44 | static void add_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
for(i=0;i<4;i++) {
pixels[0] = cm[pixels[0] + block[0]];
pixels[1] = cm[pixels[1] + block[1]];
pixels[2] = cm[pixels[2] + block[2]];
pixels[3] = cm[pixels[3] + block[3]];
pixels += line_size;
block += 8;
}
}
| {
"code": [
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" pixels[0] = cm[pixels[0] + block[0]];",
" pixels[1] = cm[pixels[1] + block[1]];",
" pixels[2] = cm[pixels[2] + block[2]];",
" pixels[3] = cm[pixels[3] + block[3]];",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" pixels[0] = cm[pixels[0] + block[0]];",
" pixels[1] = cm[pixels[1] + block[1]];",
" pixels[2] = cm[pixels[2] + block[2]];",
" pixels[3] = cm[pixels[3] + block[3]];",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" pixels[0] = cm[pixels[0] + block[0]];",
" pixels[1] = cm[pixels[1] + block[1]];",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;"
],
"line_no": [
9,
9,
9,
9,
17,
19,
21,
23,
9,
17,
19,
21,
23,
9,
17,
19,
9,
9,
9,
9,
9,
9,
9
]
} | static void FUNC_0(const DCTELEM *VAR_0, uint8_t *restrict VAR_1,
int VAR_2)
{
int VAR_3;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
for(VAR_3=0;VAR_3<4;VAR_3++) {
VAR_1[0] = cm[VAR_1[0] + VAR_0[0]];
VAR_1[1] = cm[VAR_1[1] + VAR_0[1]];
VAR_1[2] = cm[VAR_1[2] + VAR_0[2]];
VAR_1[3] = cm[VAR_1[3] + VAR_0[3]];
VAR_1 += VAR_2;
VAR_0 += 8;
}
}
| [
"static void FUNC_0(const DCTELEM *VAR_0, uint8_t *restrict VAR_1,\nint VAR_2)\n{",
"int VAR_3;",
"uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
"for(VAR_3=0;VAR_3<4;VAR_3++) {",
"VAR_1[0] = cm[VAR_1[0] + VAR_0[0]];",
"VAR_1[1] = cm[VAR_1[1] + VAR_0[1]];",
"VAR_1[2] = cm[VAR_1[2] + VAR_0[2]];",
"VAR_1[3] = cm[VAR_1[3] + VAR_0[3]];",
"VAR_1 += VAR_2;",
"VAR_0 += 8;",
"}",
"}"
]
| [
0,
0,
1,
0,
1,
1,
1,
1,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
]
|
10,420 | static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
{
int sign, code;
int pred, extquant;
int extrabits = 0;
int16_t *dc_val;
pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
/* update predictor */
if (n < 4) {
*dc_val = level * s->y_dc_scale;
} else {
*dc_val = level * s->c_dc_scale;
}
/* do the prediction */
level -= pred;
if(s->msmpeg4_version<=2){
if (n < 4) {
put_bits(&s->pb,
ff_v2_dc_lum_table[level + 256][1],
ff_v2_dc_lum_table[level + 256][0]);
}else{
put_bits(&s->pb,
ff_v2_dc_chroma_table[level + 256][1],
ff_v2_dc_chroma_table[level + 256][0]);
}
}else{
sign = 0;
if (level < 0) {
level = -level;
sign = 1;
}
code = level;
if (code > DC_MAX)
code = DC_MAX;
else if( s->msmpeg4_version>=6 ) {
if( s->qscale == 1 ) {
extquant = (level + 3) & 0x3;
code = ((level+3)>>2);
} else if( s->qscale == 2 ) {
extquant = (level + 1) & 0x1;
code = ((level+1)>>1);
}
}
if (s->dc_table_index == 0) {
if (n < 4) {
put_bits(&s->pb, ff_table0_dc_lum[code][1], ff_table0_dc_lum[code][0]);
} else {
put_bits(&s->pb, ff_table0_dc_chroma[code][1], ff_table0_dc_chroma[code][0]);
}
} else {
if (n < 4) {
put_bits(&s->pb, ff_table1_dc_lum[code][1], ff_table1_dc_lum[code][0]);
} else {
put_bits(&s->pb, ff_table1_dc_chroma[code][1], ff_table1_dc_chroma[code][0]);
}
}
if(s->msmpeg4_version>=6 && s->qscale<=2)
extrabits = 3 - s->qscale;
if (code == DC_MAX)
put_bits(&s->pb, 8 + extrabits, level);
else if(extrabits > 0)//== VC1 && s->qscale<=2
put_bits(&s->pb, extrabits, extquant);
if (level != 0) {
put_bits(&s->pb, 1, sign);
}
}
}
| true | FFmpeg | e0a99d54111165eb83991945fed0568556cb0efe | static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
{
int sign, code;
int pred, extquant;
int extrabits = 0;
int16_t *dc_val;
pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
if (n < 4) {
*dc_val = level * s->y_dc_scale;
} else {
*dc_val = level * s->c_dc_scale;
}
level -= pred;
if(s->msmpeg4_version<=2){
if (n < 4) {
put_bits(&s->pb,
ff_v2_dc_lum_table[level + 256][1],
ff_v2_dc_lum_table[level + 256][0]);
}else{
put_bits(&s->pb,
ff_v2_dc_chroma_table[level + 256][1],
ff_v2_dc_chroma_table[level + 256][0]);
}
}else{
sign = 0;
if (level < 0) {
level = -level;
sign = 1;
}
code = level;
if (code > DC_MAX)
code = DC_MAX;
else if( s->msmpeg4_version>=6 ) {
if( s->qscale == 1 ) {
extquant = (level + 3) & 0x3;
code = ((level+3)>>2);
} else if( s->qscale == 2 ) {
extquant = (level + 1) & 0x1;
code = ((level+1)>>1);
}
}
if (s->dc_table_index == 0) {
if (n < 4) {
put_bits(&s->pb, ff_table0_dc_lum[code][1], ff_table0_dc_lum[code][0]);
} else {
put_bits(&s->pb, ff_table0_dc_chroma[code][1], ff_table0_dc_chroma[code][0]);
}
} else {
if (n < 4) {
put_bits(&s->pb, ff_table1_dc_lum[code][1], ff_table1_dc_lum[code][0]);
} else {
put_bits(&s->pb, ff_table1_dc_chroma[code][1], ff_table1_dc_chroma[code][0]);
}
}
if(s->msmpeg4_version>=6 && s->qscale<=2)
extrabits = 3 - s->qscale;
if (code == DC_MAX)
put_bits(&s->pb, 8 + extrabits, level);
else if(extrabits > 0)
put_bits(&s->pb, extrabits, extquant);
if (level != 0) {
put_bits(&s->pb, 1, sign);
}
}
}
| {
"code": [
" int pred, extquant;"
],
"line_no": [
7
]
} | static void FUNC_0(MpegEncContext * VAR_0, int VAR_1, int VAR_2, int *VAR_3)
{
int VAR_4, VAR_5;
int VAR_6, VAR_7;
int VAR_8 = 0;
int16_t *dc_val;
VAR_6 = ff_msmpeg4_pred_dc(VAR_0, VAR_2, &dc_val, VAR_3);
if (VAR_2 < 4) {
*dc_val = VAR_1 * VAR_0->y_dc_scale;
} else {
*dc_val = VAR_1 * VAR_0->c_dc_scale;
}
VAR_1 -= VAR_6;
if(VAR_0->msmpeg4_version<=2){
if (VAR_2 < 4) {
put_bits(&VAR_0->pb,
ff_v2_dc_lum_table[VAR_1 + 256][1],
ff_v2_dc_lum_table[VAR_1 + 256][0]);
}else{
put_bits(&VAR_0->pb,
ff_v2_dc_chroma_table[VAR_1 + 256][1],
ff_v2_dc_chroma_table[VAR_1 + 256][0]);
}
}else{
VAR_4 = 0;
if (VAR_1 < 0) {
VAR_1 = -VAR_1;
VAR_4 = 1;
}
VAR_5 = VAR_1;
if (VAR_5 > DC_MAX)
VAR_5 = DC_MAX;
else if( VAR_0->msmpeg4_version>=6 ) {
if( VAR_0->qscale == 1 ) {
VAR_7 = (VAR_1 + 3) & 0x3;
VAR_5 = ((VAR_1+3)>>2);
} else if( VAR_0->qscale == 2 ) {
VAR_7 = (VAR_1 + 1) & 0x1;
VAR_5 = ((VAR_1+1)>>1);
}
}
if (VAR_0->dc_table_index == 0) {
if (VAR_2 < 4) {
put_bits(&VAR_0->pb, ff_table0_dc_lum[VAR_5][1], ff_table0_dc_lum[VAR_5][0]);
} else {
put_bits(&VAR_0->pb, ff_table0_dc_chroma[VAR_5][1], ff_table0_dc_chroma[VAR_5][0]);
}
} else {
if (VAR_2 < 4) {
put_bits(&VAR_0->pb, ff_table1_dc_lum[VAR_5][1], ff_table1_dc_lum[VAR_5][0]);
} else {
put_bits(&VAR_0->pb, ff_table1_dc_chroma[VAR_5][1], ff_table1_dc_chroma[VAR_5][0]);
}
}
if(VAR_0->msmpeg4_version>=6 && VAR_0->qscale<=2)
VAR_8 = 3 - VAR_0->qscale;
if (VAR_5 == DC_MAX)
put_bits(&VAR_0->pb, 8 + VAR_8, VAR_1);
else if(VAR_8 > 0)
put_bits(&VAR_0->pb, VAR_8, VAR_7);
if (VAR_1 != 0) {
put_bits(&VAR_0->pb, 1, VAR_4);
}
}
}
| [
"static void FUNC_0(MpegEncContext * VAR_0, int VAR_1, int VAR_2, int *VAR_3)\n{",
"int VAR_4, VAR_5;",
"int VAR_6, VAR_7;",
"int VAR_8 = 0;",
"int16_t *dc_val;",
"VAR_6 = ff_msmpeg4_pred_dc(VAR_0, VAR_2, &dc_val, VAR_3);",
"if (VAR_2 < 4) {",
"*dc_val = VAR_1 * VAR_0->y_dc_scale;",
"} else {",
"*dc_val = VAR_1 * VAR_0->c_dc_scale;",
"}",
"VAR_1 -= VAR_6;",
"if(VAR_0->msmpeg4_version<=2){",
"if (VAR_2 < 4) {",
"put_bits(&VAR_0->pb,\nff_v2_dc_lum_table[VAR_1 + 256][1],\nff_v2_dc_lum_table[VAR_1 + 256][0]);",
"}else{",
"put_bits(&VAR_0->pb,\nff_v2_dc_chroma_table[VAR_1 + 256][1],\nff_v2_dc_chroma_table[VAR_1 + 256][0]);",
"}",
"}else{",
"VAR_4 = 0;",
"if (VAR_1 < 0) {",
"VAR_1 = -VAR_1;",
"VAR_4 = 1;",
"}",
"VAR_5 = VAR_1;",
"if (VAR_5 > DC_MAX)\nVAR_5 = DC_MAX;",
"else if( VAR_0->msmpeg4_version>=6 ) {",
"if( VAR_0->qscale == 1 ) {",
"VAR_7 = (VAR_1 + 3) & 0x3;",
"VAR_5 = ((VAR_1+3)>>2);",
"} else if( VAR_0->qscale == 2 ) {",
"VAR_7 = (VAR_1 + 1) & 0x1;",
"VAR_5 = ((VAR_1+1)>>1);",
"}",
"}",
"if (VAR_0->dc_table_index == 0) {",
"if (VAR_2 < 4) {",
"put_bits(&VAR_0->pb, ff_table0_dc_lum[VAR_5][1], ff_table0_dc_lum[VAR_5][0]);",
"} else {",
"put_bits(&VAR_0->pb, ff_table0_dc_chroma[VAR_5][1], ff_table0_dc_chroma[VAR_5][0]);",
"}",
"} else {",
"if (VAR_2 < 4) {",
"put_bits(&VAR_0->pb, ff_table1_dc_lum[VAR_5][1], ff_table1_dc_lum[VAR_5][0]);",
"} else {",
"put_bits(&VAR_0->pb, ff_table1_dc_chroma[VAR_5][1], ff_table1_dc_chroma[VAR_5][0]);",
"}",
"}",
"if(VAR_0->msmpeg4_version>=6 && VAR_0->qscale<=2)\nVAR_8 = 3 - VAR_0->qscale;",
"if (VAR_5 == DC_MAX)\nput_bits(&VAR_0->pb, 8 + VAR_8, VAR_1);",
"else if(VAR_8 > 0)\nput_bits(&VAR_0->pb, VAR_8, VAR_7);",
"if (VAR_1 != 0) {",
"put_bits(&VAR_0->pb, 1, VAR_4);",
"}",
"}",
"}"
]
| [
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,
0,
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
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
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
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125,
127
],
[
131,
133
],
[
135,
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
]
]
|
10,421 | matroska_read_header (AVFormatContext *s,
AVFormatParameters *ap)
{
MatroskaDemuxContext *matroska = s->priv_data;
char *doctype;
int version, last_level, res = 0;
uint32_t id;
matroska->ctx = s;
/* First read the EBML header. */
doctype = NULL;
if ((res = ebml_read_header(matroska, &doctype, &version)) < 0)
return res;
if ((doctype == NULL) || strcmp(doctype, "matroska")) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Wrong EBML doctype ('%s' != 'matroska').\n",
doctype ? doctype : "(none)");
if (doctype)
av_free(doctype);
return AVERROR_NOFMT;
}
av_free(doctype);
if (version > 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Matroska demuxer version 2 too old for file version %d\n",
version);
return AVERROR_NOFMT;
}
/* The next thing is a segment. */
while (1) {
if (!(id = ebml_peek_id(matroska, &last_level)))
return AVERROR(EIO);
if (id == MATROSKA_ID_SEGMENT)
break;
/* oi! */
av_log(matroska->ctx, AV_LOG_INFO,
"Expected a Segment ID (0x%x), but received 0x%x!\n",
MATROSKA_ID_SEGMENT, id);
if ((res = ebml_read_skip(matroska)) < 0)
return res;
}
/* We now have a Matroska segment.
* Seeks are from the beginning of the segment,
* after the segment ID/length. */
if ((res = ebml_read_master(matroska, &id)) < 0)
return res;
matroska->segment_start = url_ftell(s->pb);
matroska->time_scale = 1000000;
/* we've found our segment, start reading the different contents in here */
while (res == 0) {
if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {
res = AVERROR(EIO);
break;
} else if (matroska->level_up) {
matroska->level_up--;
break;
}
switch (id) {
/* stream info */
case MATROSKA_ID_INFO: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_info(matroska);
break;
}
/* track info headers */
case MATROSKA_ID_TRACKS: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_tracks(matroska);
break;
}
/* stream index */
case MATROSKA_ID_CUES: {
if (!matroska->index_parsed) {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_index(matroska);
} else
res = ebml_read_skip(matroska);
break;
}
/* metadata */
case MATROSKA_ID_TAGS: {
if (!matroska->metadata_parsed) {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_metadata(matroska);
} else
res = ebml_read_skip(matroska);
break;
}
/* file index (if seekable, seek to Cues/Tags to parse it) */
case MATROSKA_ID_SEEKHEAD: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_seekhead(matroska);
break;
}
case MATROSKA_ID_ATTACHMENTS: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_attachments(s);
break;
}
case MATROSKA_ID_CLUSTER: {
/* Do not read the master - this will be done in the next
* call to matroska_read_packet. */
res = 1;
break;
}
default:
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown matroska file header ID 0x%x\n", id);
/* fall-through */
case EBML_ID_VOID:
res = ebml_read_skip(matroska);
break;
}
if (matroska->level_up) {
matroska->level_up--;
break;
}
}
/* Have we found a cluster? */
if (ebml_peek_id(matroska, NULL) == MATROSKA_ID_CLUSTER) {
int i, j;
MatroskaTrack *track;
AVStream *st;
for (i = 0; i < matroska->num_tracks; i++) {
enum CodecID codec_id = CODEC_ID_NONE;
uint8_t *extradata = NULL;
int extradata_size = 0;
int extradata_offset = 0;
track = matroska->tracks[i];
track->stream_index = -1;
/* Apply some sanity checks. */
if (track->codec_id == NULL)
continue;
for(j=0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++){
if(!strncmp(ff_mkv_codec_tags[j].str, track->codec_id,
strlen(ff_mkv_codec_tags[j].str))){
codec_id= ff_mkv_codec_tags[j].id;
break;
}
}
/* Set the FourCC from the CodecID. */
/* This is the MS compatibility mode which stores a
* BITMAPINFOHEADER in the CodecPrivate. */
if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC) &&
(track->codec_priv_size >= 40) &&
(track->codec_priv != NULL)) {
MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *) track;
/* Offset of biCompression. Stored in LE. */
vtrack->fourcc = AV_RL32(track->codec_priv + 16);
codec_id = codec_get_id(codec_bmp_tags, vtrack->fourcc);
}
/* This is the MS compatibility mode which stores a
* WAVEFORMATEX in the CodecPrivate. */
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_ACM) &&
(track->codec_priv_size >= 18) &&
(track->codec_priv != NULL)) {
uint16_t tag;
/* Offset of wFormatTag. Stored in LE. */
tag = AV_RL16(track->codec_priv);
codec_id = codec_get_id(codec_wav_tags, tag);
}
else if (codec_id == CODEC_ID_AAC && !track->codec_priv_size) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track;
int profile = matroska_aac_profile(track->codec_id);
int sri = matroska_aac_sri(audiotrack->internal_samplerate);
extradata = av_malloc(5);
if (extradata == NULL)
return AVERROR(ENOMEM);
extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);
extradata[1] = ((sri&0x01) << 7) | (audiotrack->channels<<3);
if (strstr(track->codec_id, "SBR")) {
sri = matroska_aac_sri(audiotrack->samplerate);
extradata[2] = 0x56;
extradata[3] = 0xE5;
extradata[4] = 0x80 | (sri<<3);
extradata_size = 5;
} else {
extradata_size = 2;
}
}
else if (codec_id == CODEC_ID_TTA) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track;
ByteIOContext b;
extradata_size = 30;
extradata = av_mallocz(extradata_size);
if (extradata == NULL)
return AVERROR(ENOMEM);
init_put_byte(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
put_buffer(&b, "TTA1", 4);
put_le16(&b, 1);
put_le16(&b, audiotrack->channels);
put_le16(&b, audiotrack->bitdepth);
put_le32(&b, audiotrack->samplerate);
put_le32(&b, matroska->ctx->duration * audiotrack->samplerate);
}
else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
extradata_offset = 26;
track->codec_priv_size -= extradata_offset;
}
else if (codec_id == CODEC_ID_RA_144) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
audiotrack->samplerate = 8000;
audiotrack->channels = 1;
}
else if (codec_id == CODEC_ID_RA_288 ||
codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
ByteIOContext b;
init_put_byte(&b, track->codec_priv, track->codec_priv_size, 0,
NULL, NULL, NULL, NULL);
url_fskip(&b, 24);
audiotrack->coded_framesize = get_be32(&b);
url_fskip(&b, 12);
audiotrack->sub_packet_h = get_be16(&b);
audiotrack->frame_size = get_be16(&b);
audiotrack->sub_packet_size = get_be16(&b);
audiotrack->buf = av_malloc(audiotrack->frame_size * audiotrack->sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
audiotrack->block_align = audiotrack->coded_framesize;
track->codec_priv_size = 0;
} else {
audiotrack->block_align = audiotrack->sub_packet_size;
extradata_offset = 78;
track->codec_priv_size -= extradata_offset;
}
}
if (codec_id == CODEC_ID_NONE) {
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported CodecID %s.\n",
track->codec_id);
}
track->stream_index = matroska->num_streams;
matroska->num_streams++;
st = av_new_stream(s, track->stream_index);
if (st == NULL)
return AVERROR(ENOMEM);
av_set_pts_info(st, 64, matroska->time_scale, 1000*1000*1000); /* 64 bit pts in ns */
st->codec->codec_id = codec_id;
st->start_time = 0;
if (strcmp(track->language, "und"))
strcpy(st->language, track->language);
if (track->flags & MATROSKA_TRACK_DEFAULT)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (track->default_duration)
av_reduce(&st->codec->time_base.num, &st->codec->time_base.den,
track->default_duration, 1000000000, 30000);
if(extradata){
st->codec->extradata = extradata;
st->codec->extradata_size = extradata_size;
} else if(track->codec_priv && track->codec_priv_size > 0){
st->codec->extradata = av_malloc(track->codec_priv_size);
if(st->codec->extradata == NULL)
return AVERROR(ENOMEM);
st->codec->extradata_size = track->codec_priv_size;
memcpy(st->codec->extradata,track->codec_priv+extradata_offset,
track->codec_priv_size);
}
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
MatroskaVideoTrack *videotrack = (MatroskaVideoTrack *)track;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_tag = videotrack->fourcc;
st->codec->width = videotrack->pixel_width;
st->codec->height = videotrack->pixel_height;
if (videotrack->display_width == 0)
videotrack->display_width= videotrack->pixel_width;
if (videotrack->display_height == 0)
videotrack->display_height= videotrack->pixel_height;
av_reduce(&st->codec->sample_aspect_ratio.num,
&st->codec->sample_aspect_ratio.den,
st->codec->height * videotrack->display_width,
st->codec-> width * videotrack->display_height,
255);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->sample_rate = audiotrack->samplerate;
st->codec->channels = audiotrack->channels;
st->codec->block_align = audiotrack->block_align;
} else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
/* What do we do with private data? E.g. for Vorbis. */
}
res = 0;
}
if (matroska->index_parsed) {
int i, track, stream;
for (i=0; i<matroska->num_indexes; i++) {
MatroskaDemuxIndex *idx = &matroska->index[i];
track = matroska_find_track_by_num(matroska, idx->track);
stream = matroska->tracks[track]->stream_index;
if (stream >= 0)
av_add_index_entry(matroska->ctx->streams[stream],
idx->pos, idx->time/matroska->time_scale,
0, 0, AVINDEX_KEYFRAME);
}
}
return res;
}
| true | FFmpeg | 074ac3c2d04abaf6b8b1048ba55a1e4ade13042f | matroska_read_header (AVFormatContext *s,
AVFormatParameters *ap)
{
MatroskaDemuxContext *matroska = s->priv_data;
char *doctype;
int version, last_level, res = 0;
uint32_t id;
matroska->ctx = s;
doctype = NULL;
if ((res = ebml_read_header(matroska, &doctype, &version)) < 0)
return res;
if ((doctype == NULL) || strcmp(doctype, "matroska")) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Wrong EBML doctype ('%s' != 'matroska').\n",
doctype ? doctype : "(none)");
if (doctype)
av_free(doctype);
return AVERROR_NOFMT;
}
av_free(doctype);
if (version > 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Matroska demuxer version 2 too old for file version %d\n",
version);
return AVERROR_NOFMT;
}
while (1) {
if (!(id = ebml_peek_id(matroska, &last_level)))
return AVERROR(EIO);
if (id == MATROSKA_ID_SEGMENT)
break;
av_log(matroska->ctx, AV_LOG_INFO,
"Expected a Segment ID (0x%x), but received 0x%x!\n",
MATROSKA_ID_SEGMENT, id);
if ((res = ebml_read_skip(matroska)) < 0)
return res;
}
if ((res = ebml_read_master(matroska, &id)) < 0)
return res;
matroska->segment_start = url_ftell(s->pb);
matroska->time_scale = 1000000;
while (res == 0) {
if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {
res = AVERROR(EIO);
break;
} else if (matroska->level_up) {
matroska->level_up--;
break;
}
switch (id) {
case MATROSKA_ID_INFO: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_info(matroska);
break;
}
case MATROSKA_ID_TRACKS: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_tracks(matroska);
break;
}
case MATROSKA_ID_CUES: {
if (!matroska->index_parsed) {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_index(matroska);
} else
res = ebml_read_skip(matroska);
break;
}
case MATROSKA_ID_TAGS: {
if (!matroska->metadata_parsed) {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_metadata(matroska);
} else
res = ebml_read_skip(matroska);
break;
}
case MATROSKA_ID_SEEKHEAD: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_seekhead(matroska);
break;
}
case MATROSKA_ID_ATTACHMENTS: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_attachments(s);
break;
}
case MATROSKA_ID_CLUSTER: {
res = 1;
break;
}
default:
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown matroska file header ID 0x%x\n", id);
case EBML_ID_VOID:
res = ebml_read_skip(matroska);
break;
}
if (matroska->level_up) {
matroska->level_up--;
break;
}
}
if (ebml_peek_id(matroska, NULL) == MATROSKA_ID_CLUSTER) {
int i, j;
MatroskaTrack *track;
AVStream *st;
for (i = 0; i < matroska->num_tracks; i++) {
enum CodecID codec_id = CODEC_ID_NONE;
uint8_t *extradata = NULL;
int extradata_size = 0;
int extradata_offset = 0;
track = matroska->tracks[i];
track->stream_index = -1;
if (track->codec_id == NULL)
continue;
for(j=0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++){
if(!strncmp(ff_mkv_codec_tags[j].str, track->codec_id,
strlen(ff_mkv_codec_tags[j].str))){
codec_id= ff_mkv_codec_tags[j].id;
break;
}
}
if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC) &&
(track->codec_priv_size >= 40) &&
(track->codec_priv != NULL)) {
MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *) track;
vtrack->fourcc = AV_RL32(track->codec_priv + 16);
codec_id = codec_get_id(codec_bmp_tags, vtrack->fourcc);
}
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_ACM) &&
(track->codec_priv_size >= 18) &&
(track->codec_priv != NULL)) {
uint16_t tag;
tag = AV_RL16(track->codec_priv);
codec_id = codec_get_id(codec_wav_tags, tag);
}
else if (codec_id == CODEC_ID_AAC && !track->codec_priv_size) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track;
int profile = matroska_aac_profile(track->codec_id);
int sri = matroska_aac_sri(audiotrack->internal_samplerate);
extradata = av_malloc(5);
if (extradata == NULL)
return AVERROR(ENOMEM);
extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);
extradata[1] = ((sri&0x01) << 7) | (audiotrack->channels<<3);
if (strstr(track->codec_id, "SBR")) {
sri = matroska_aac_sri(audiotrack->samplerate);
extradata[2] = 0x56;
extradata[3] = 0xE5;
extradata[4] = 0x80 | (sri<<3);
extradata_size = 5;
} else {
extradata_size = 2;
}
}
else if (codec_id == CODEC_ID_TTA) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track;
ByteIOContext b;
extradata_size = 30;
extradata = av_mallocz(extradata_size);
if (extradata == NULL)
return AVERROR(ENOMEM);
init_put_byte(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
put_buffer(&b, "TTA1", 4);
put_le16(&b, 1);
put_le16(&b, audiotrack->channels);
put_le16(&b, audiotrack->bitdepth);
put_le32(&b, audiotrack->samplerate);
put_le32(&b, matroska->ctx->duration * audiotrack->samplerate);
}
else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
extradata_offset = 26;
track->codec_priv_size -= extradata_offset;
}
else if (codec_id == CODEC_ID_RA_144) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
audiotrack->samplerate = 8000;
audiotrack->channels = 1;
}
else if (codec_id == CODEC_ID_RA_288 ||
codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
ByteIOContext b;
init_put_byte(&b, track->codec_priv, track->codec_priv_size, 0,
NULL, NULL, NULL, NULL);
url_fskip(&b, 24);
audiotrack->coded_framesize = get_be32(&b);
url_fskip(&b, 12);
audiotrack->sub_packet_h = get_be16(&b);
audiotrack->frame_size = get_be16(&b);
audiotrack->sub_packet_size = get_be16(&b);
audiotrack->buf = av_malloc(audiotrack->frame_size * audiotrack->sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
audiotrack->block_align = audiotrack->coded_framesize;
track->codec_priv_size = 0;
} else {
audiotrack->block_align = audiotrack->sub_packet_size;
extradata_offset = 78;
track->codec_priv_size -= extradata_offset;
}
}
if (codec_id == CODEC_ID_NONE) {
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported CodecID %s.\n",
track->codec_id);
}
track->stream_index = matroska->num_streams;
matroska->num_streams++;
st = av_new_stream(s, track->stream_index);
if (st == NULL)
return AVERROR(ENOMEM);
av_set_pts_info(st, 64, matroska->time_scale, 1000*1000*1000);
st->codec->codec_id = codec_id;
st->start_time = 0;
if (strcmp(track->language, "und"))
strcpy(st->language, track->language);
if (track->flags & MATROSKA_TRACK_DEFAULT)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (track->default_duration)
av_reduce(&st->codec->time_base.num, &st->codec->time_base.den,
track->default_duration, 1000000000, 30000);
if(extradata){
st->codec->extradata = extradata;
st->codec->extradata_size = extradata_size;
} else if(track->codec_priv && track->codec_priv_size > 0){
st->codec->extradata = av_malloc(track->codec_priv_size);
if(st->codec->extradata == NULL)
return AVERROR(ENOMEM);
st->codec->extradata_size = track->codec_priv_size;
memcpy(st->codec->extradata,track->codec_priv+extradata_offset,
track->codec_priv_size);
}
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
MatroskaVideoTrack *videotrack = (MatroskaVideoTrack *)track;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_tag = videotrack->fourcc;
st->codec->width = videotrack->pixel_width;
st->codec->height = videotrack->pixel_height;
if (videotrack->display_width == 0)
videotrack->display_width= videotrack->pixel_width;
if (videotrack->display_height == 0)
videotrack->display_height= videotrack->pixel_height;
av_reduce(&st->codec->sample_aspect_ratio.num,
&st->codec->sample_aspect_ratio.den,
st->codec->height * videotrack->display_width,
st->codec-> width * videotrack->display_height,
255);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->sample_rate = audiotrack->samplerate;
st->codec->channels = audiotrack->channels;
st->codec->block_align = audiotrack->block_align;
} else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
}
res = 0;
}
if (matroska->index_parsed) {
int i, track, stream;
for (i=0; i<matroska->num_indexes; i++) {
MatroskaDemuxIndex *idx = &matroska->index[i];
track = matroska_find_track_by_num(matroska, idx->track);
stream = matroska->tracks[track]->stream_index;
if (stream >= 0)
av_add_index_entry(matroska->ctx->streams[stream],
idx->pos, idx->time/matroska->time_scale,
0, 0, AVINDEX_KEYFRAME);
}
}
return res;
}
| {
"code": [
" if (stream >= 0)"
],
"line_no": [
693
]
} | FUNC_0 (AVFormatContext *VAR_0,
AVFormatParameters *VAR_1)
{
MatroskaDemuxContext *matroska = VAR_0->priv_data;
char *VAR_2;
int VAR_3, VAR_4, VAR_5 = 0;
uint32_t id;
matroska->ctx = VAR_0;
VAR_2 = NULL;
if ((VAR_5 = ebml_read_header(matroska, &VAR_2, &VAR_3)) < 0)
return VAR_5;
if ((VAR_2 == NULL) || strcmp(VAR_2, "matroska")) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Wrong EBML VAR_2 ('%VAR_0' != 'matroska').\n",
VAR_2 ? VAR_2 : "(none)");
if (VAR_2)
av_free(VAR_2);
return AVERROR_NOFMT;
}
av_free(VAR_2);
if (VAR_3 > 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Matroska demuxer VAR_3 2 too old for file VAR_3 %d\n",
VAR_3);
return AVERROR_NOFMT;
}
while (1) {
if (!(id = ebml_peek_id(matroska, &VAR_4)))
return AVERROR(EIO);
if (id == MATROSKA_ID_SEGMENT)
break;
av_log(matroska->ctx, AV_LOG_INFO,
"Expected a Segment ID (0x%x), but received 0x%x!\n",
MATROSKA_ID_SEGMENT, id);
if ((VAR_5 = ebml_read_skip(matroska)) < 0)
return VAR_5;
}
if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)
return VAR_5;
matroska->segment_start = url_ftell(VAR_0->pb);
matroska->time_scale = 1000000;
while (VAR_5 == 0) {
if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {
VAR_5 = AVERROR(EIO);
break;
} else if (matroska->level_up) {
matroska->level_up--;
break;
}
switch (id) {
case MATROSKA_ID_INFO: {
if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)
break;
VAR_5 = matroska_parse_info(matroska);
break;
}
case MATROSKA_ID_TRACKS: {
if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)
break;
VAR_5 = matroska_parse_tracks(matroska);
break;
}
case MATROSKA_ID_CUES: {
if (!matroska->index_parsed) {
if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)
break;
VAR_5 = matroska_parse_index(matroska);
} else
VAR_5 = ebml_read_skip(matroska);
break;
}
case MATROSKA_ID_TAGS: {
if (!matroska->metadata_parsed) {
if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)
break;
VAR_5 = matroska_parse_metadata(matroska);
} else
VAR_5 = ebml_read_skip(matroska);
break;
}
case MATROSKA_ID_SEEKHEAD: {
if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)
break;
VAR_5 = matroska_parse_seekhead(matroska);
break;
}
case MATROSKA_ID_ATTACHMENTS: {
if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)
break;
VAR_5 = matroska_parse_attachments(VAR_0);
break;
}
case MATROSKA_ID_CLUSTER: {
VAR_5 = 1;
break;
}
default:
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown matroska file header ID 0x%x\n", id);
case EBML_ID_VOID:
VAR_5 = ebml_read_skip(matroska);
break;
}
if (matroska->level_up) {
matroska->level_up--;
break;
}
}
if (ebml_peek_id(matroska, NULL) == MATROSKA_ID_CLUSTER) {
int VAR_8, VAR_7;
MatroskaTrack *VAR_8;
AVStream *st;
for (VAR_8 = 0; VAR_8 < matroska->num_tracks; VAR_8++) {
enum CodecID codec_id = CODEC_ID_NONE;
uint8_t *extradata = NULL;
int extradata_size = 0;
int extradata_offset = 0;
VAR_8 = matroska->tracks[VAR_8];
VAR_8->stream_index = -1;
if (VAR_8->codec_id == NULL)
continue;
for(VAR_7=0; ff_mkv_codec_tags[VAR_7].id != CODEC_ID_NONE; VAR_7++){
if(!strncmp(ff_mkv_codec_tags[VAR_7].str, VAR_8->codec_id,
strlen(ff_mkv_codec_tags[VAR_7].str))){
codec_id= ff_mkv_codec_tags[VAR_7].id;
break;
}
}
if (!strcmp(VAR_8->codec_id,
MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC) &&
(VAR_8->codec_priv_size >= 40) &&
(VAR_8->codec_priv != NULL)) {
MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *) VAR_8;
vtrack->fourcc = AV_RL32(VAR_8->codec_priv + 16);
codec_id = codec_get_id(codec_bmp_tags, vtrack->fourcc);
}
else if (!strcmp(VAR_8->codec_id,
MATROSKA_CODEC_ID_AUDIO_ACM) &&
(VAR_8->codec_priv_size >= 18) &&
(VAR_8->codec_priv != NULL)) {
uint16_t tag;
tag = AV_RL16(VAR_8->codec_priv);
codec_id = codec_get_id(codec_wav_tags, tag);
}
else if (codec_id == CODEC_ID_AAC && !VAR_8->codec_priv_size) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) VAR_8;
int profile = matroska_aac_profile(VAR_8->codec_id);
int sri = matroska_aac_sri(audiotrack->internal_samplerate);
extradata = av_malloc(5);
if (extradata == NULL)
return AVERROR(ENOMEM);
extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);
extradata[1] = ((sri&0x01) << 7) | (audiotrack->channels<<3);
if (strstr(VAR_8->codec_id, "SBR")) {
sri = matroska_aac_sri(audiotrack->samplerate);
extradata[2] = 0x56;
extradata[3] = 0xE5;
extradata[4] = 0x80 | (sri<<3);
extradata_size = 5;
} else {
extradata_size = 2;
}
}
else if (codec_id == CODEC_ID_TTA) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) VAR_8;
ByteIOContext b;
extradata_size = 30;
extradata = av_mallocz(extradata_size);
if (extradata == NULL)
return AVERROR(ENOMEM);
init_put_byte(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
put_buffer(&b, "TTA1", 4);
put_le16(&b, 1);
put_le16(&b, audiotrack->channels);
put_le16(&b, audiotrack->bitdepth);
put_le32(&b, audiotrack->samplerate);
put_le32(&b, matroska->ctx->duration * audiotrack->samplerate);
}
else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
extradata_offset = 26;
VAR_8->codec_priv_size -= extradata_offset;
}
else if (codec_id == CODEC_ID_RA_144) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)VAR_8;
audiotrack->samplerate = 8000;
audiotrack->channels = 1;
}
else if (codec_id == CODEC_ID_RA_288 ||
codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)VAR_8;
ByteIOContext b;
init_put_byte(&b, VAR_8->codec_priv, VAR_8->codec_priv_size, 0,
NULL, NULL, NULL, NULL);
url_fskip(&b, 24);
audiotrack->coded_framesize = get_be32(&b);
url_fskip(&b, 12);
audiotrack->sub_packet_h = get_be16(&b);
audiotrack->frame_size = get_be16(&b);
audiotrack->sub_packet_size = get_be16(&b);
audiotrack->buf = av_malloc(audiotrack->frame_size * audiotrack->sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
audiotrack->block_align = audiotrack->coded_framesize;
VAR_8->codec_priv_size = 0;
} else {
audiotrack->block_align = audiotrack->sub_packet_size;
extradata_offset = 78;
VAR_8->codec_priv_size -= extradata_offset;
}
}
if (codec_id == CODEC_ID_NONE) {
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported CodecID %VAR_0.\n",
VAR_8->codec_id);
}
VAR_8->stream_index = matroska->num_streams;
matroska->num_streams++;
st = av_new_stream(VAR_0, VAR_8->stream_index);
if (st == NULL)
return AVERROR(ENOMEM);
av_set_pts_info(st, 64, matroska->time_scale, 1000*1000*1000);
st->codec->codec_id = codec_id;
st->start_time = 0;
if (strcmp(VAR_8->language, "und"))
strcpy(st->language, VAR_8->language);
if (VAR_8->flags & MATROSKA_TRACK_DEFAULT)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (VAR_8->default_duration)
av_reduce(&st->codec->time_base.num, &st->codec->time_base.den,
VAR_8->default_duration, 1000000000, 30000);
if(extradata){
st->codec->extradata = extradata;
st->codec->extradata_size = extradata_size;
} else if(VAR_8->codec_priv && VAR_8->codec_priv_size > 0){
st->codec->extradata = av_malloc(VAR_8->codec_priv_size);
if(st->codec->extradata == NULL)
return AVERROR(ENOMEM);
st->codec->extradata_size = VAR_8->codec_priv_size;
memcpy(st->codec->extradata,VAR_8->codec_priv+extradata_offset,
VAR_8->codec_priv_size);
}
if (VAR_8->type == MATROSKA_TRACK_TYPE_VIDEO) {
MatroskaVideoTrack *videotrack = (MatroskaVideoTrack *)VAR_8;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_tag = videotrack->fourcc;
st->codec->width = videotrack->pixel_width;
st->codec->height = videotrack->pixel_height;
if (videotrack->display_width == 0)
videotrack->display_width= videotrack->pixel_width;
if (videotrack->display_height == 0)
videotrack->display_height= videotrack->pixel_height;
av_reduce(&st->codec->sample_aspect_ratio.num,
&st->codec->sample_aspect_ratio.den,
st->codec->height * videotrack->display_width,
st->codec-> width * videotrack->display_height,
255);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
} else if (VAR_8->type == MATROSKA_TRACK_TYPE_AUDIO) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)VAR_8;
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->sample_rate = audiotrack->samplerate;
st->codec->channels = audiotrack->channels;
st->codec->block_align = audiotrack->block_align;
} else if (VAR_8->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
}
VAR_5 = 0;
}
if (matroska->index_parsed) {
int VAR_8, VAR_8, VAR_9;
for (VAR_8=0; VAR_8<matroska->num_indexes; VAR_8++) {
MatroskaDemuxIndex *idx = &matroska->index[VAR_8];
VAR_8 = matroska_find_track_by_num(matroska, idx->VAR_8);
VAR_9 = matroska->tracks[VAR_8]->stream_index;
if (VAR_9 >= 0)
av_add_index_entry(matroska->ctx->streams[VAR_9],
idx->pos, idx->time/matroska->time_scale,
0, 0, AVINDEX_KEYFRAME);
}
}
return VAR_5;
}
| [
"FUNC_0 (AVFormatContext *VAR_0,\nAVFormatParameters *VAR_1)\n{",
"MatroskaDemuxContext *matroska = VAR_0->priv_data;",
"char *VAR_2;",
"int VAR_3, VAR_4, VAR_5 = 0;",
"uint32_t id;",
"matroska->ctx = VAR_0;",
"VAR_2 = NULL;",
"if ((VAR_5 = ebml_read_header(matroska, &VAR_2, &VAR_3)) < 0)\nreturn VAR_5;",
"if ((VAR_2 == NULL) || strcmp(VAR_2, \"matroska\")) {",
"av_log(matroska->ctx, AV_LOG_ERROR,\n\"Wrong EBML VAR_2 ('%VAR_0' != 'matroska').\\n\",\nVAR_2 ? VAR_2 : \"(none)\");",
"if (VAR_2)\nav_free(VAR_2);",
"return AVERROR_NOFMT;",
"}",
"av_free(VAR_2);",
"if (VAR_3 > 2) {",
"av_log(matroska->ctx, AV_LOG_ERROR,\n\"Matroska demuxer VAR_3 2 too old for file VAR_3 %d\\n\",\nVAR_3);",
"return AVERROR_NOFMT;",
"}",
"while (1) {",
"if (!(id = ebml_peek_id(matroska, &VAR_4)))\nreturn AVERROR(EIO);",
"if (id == MATROSKA_ID_SEGMENT)\nbreak;",
"av_log(matroska->ctx, AV_LOG_INFO,\n\"Expected a Segment ID (0x%x), but received 0x%x!\\n\",\nMATROSKA_ID_SEGMENT, id);",
"if ((VAR_5 = ebml_read_skip(matroska)) < 0)\nreturn VAR_5;",
"}",
"if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)\nreturn VAR_5;",
"matroska->segment_start = url_ftell(VAR_0->pb);",
"matroska->time_scale = 1000000;",
"while (VAR_5 == 0) {",
"if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {",
"VAR_5 = AVERROR(EIO);",
"break;",
"} else if (matroska->level_up) {",
"matroska->level_up--;",
"break;",
"}",
"switch (id) {",
"case MATROSKA_ID_INFO: {",
"if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)\nbreak;",
"VAR_5 = matroska_parse_info(matroska);",
"break;",
"}",
"case MATROSKA_ID_TRACKS: {",
"if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)\nbreak;",
"VAR_5 = matroska_parse_tracks(matroska);",
"break;",
"}",
"case MATROSKA_ID_CUES: {",
"if (!matroska->index_parsed) {",
"if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)\nbreak;",
"VAR_5 = matroska_parse_index(matroska);",
"} else",
"VAR_5 = ebml_read_skip(matroska);",
"break;",
"}",
"case MATROSKA_ID_TAGS: {",
"if (!matroska->metadata_parsed) {",
"if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)\nbreak;",
"VAR_5 = matroska_parse_metadata(matroska);",
"} else",
"VAR_5 = ebml_read_skip(matroska);",
"break;",
"}",
"case MATROSKA_ID_SEEKHEAD: {",
"if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)\nbreak;",
"VAR_5 = matroska_parse_seekhead(matroska);",
"break;",
"}",
"case MATROSKA_ID_ATTACHMENTS: {",
"if ((VAR_5 = ebml_read_master(matroska, &id)) < 0)\nbreak;",
"VAR_5 = matroska_parse_attachments(VAR_0);",
"break;",
"}",
"case MATROSKA_ID_CLUSTER: {",
"VAR_5 = 1;",
"break;",
"}",
"default:\nav_log(matroska->ctx, AV_LOG_INFO,\n\"Unknown matroska file header ID 0x%x\\n\", id);",
"case EBML_ID_VOID:\nVAR_5 = ebml_read_skip(matroska);",
"break;",
"}",
"if (matroska->level_up) {",
"matroska->level_up--;",
"break;",
"}",
"}",
"if (ebml_peek_id(matroska, NULL) == MATROSKA_ID_CLUSTER) {",
"int VAR_8, VAR_7;",
"MatroskaTrack *VAR_8;",
"AVStream *st;",
"for (VAR_8 = 0; VAR_8 < matroska->num_tracks; VAR_8++) {",
"enum CodecID codec_id = CODEC_ID_NONE;",
"uint8_t *extradata = NULL;",
"int extradata_size = 0;",
"int extradata_offset = 0;",
"VAR_8 = matroska->tracks[VAR_8];",
"VAR_8->stream_index = -1;",
"if (VAR_8->codec_id == NULL)\ncontinue;",
"for(VAR_7=0; ff_mkv_codec_tags[VAR_7].id != CODEC_ID_NONE; VAR_7++){",
"if(!strncmp(ff_mkv_codec_tags[VAR_7].str, VAR_8->codec_id,\nstrlen(ff_mkv_codec_tags[VAR_7].str))){",
"codec_id= ff_mkv_codec_tags[VAR_7].id;",
"break;",
"}",
"}",
"if (!strcmp(VAR_8->codec_id,\nMATROSKA_CODEC_ID_VIDEO_VFW_FOURCC) &&\n(VAR_8->codec_priv_size >= 40) &&\n(VAR_8->codec_priv != NULL)) {",
"MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *) VAR_8;",
"vtrack->fourcc = AV_RL32(VAR_8->codec_priv + 16);",
"codec_id = codec_get_id(codec_bmp_tags, vtrack->fourcc);",
"}",
"else if (!strcmp(VAR_8->codec_id,\nMATROSKA_CODEC_ID_AUDIO_ACM) &&\n(VAR_8->codec_priv_size >= 18) &&\n(VAR_8->codec_priv != NULL)) {",
"uint16_t tag;",
"tag = AV_RL16(VAR_8->codec_priv);",
"codec_id = codec_get_id(codec_wav_tags, tag);",
"}",
"else if (codec_id == CODEC_ID_AAC && !VAR_8->codec_priv_size) {",
"MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) VAR_8;",
"int profile = matroska_aac_profile(VAR_8->codec_id);",
"int sri = matroska_aac_sri(audiotrack->internal_samplerate);",
"extradata = av_malloc(5);",
"if (extradata == NULL)\nreturn AVERROR(ENOMEM);",
"extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);",
"extradata[1] = ((sri&0x01) << 7) | (audiotrack->channels<<3);",
"if (strstr(VAR_8->codec_id, \"SBR\")) {",
"sri = matroska_aac_sri(audiotrack->samplerate);",
"extradata[2] = 0x56;",
"extradata[3] = 0xE5;",
"extradata[4] = 0x80 | (sri<<3);",
"extradata_size = 5;",
"} else {",
"extradata_size = 2;",
"}",
"}",
"else if (codec_id == CODEC_ID_TTA) {",
"MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) VAR_8;",
"ByteIOContext b;",
"extradata_size = 30;",
"extradata = av_mallocz(extradata_size);",
"if (extradata == NULL)\nreturn AVERROR(ENOMEM);",
"init_put_byte(&b, extradata, extradata_size, 1,\nNULL, NULL, NULL, NULL);",
"put_buffer(&b, \"TTA1\", 4);",
"put_le16(&b, 1);",
"put_le16(&b, audiotrack->channels);",
"put_le16(&b, audiotrack->bitdepth);",
"put_le32(&b, audiotrack->samplerate);",
"put_le32(&b, matroska->ctx->duration * audiotrack->samplerate);",
"}",
"else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||\ncodec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {",
"extradata_offset = 26;",
"VAR_8->codec_priv_size -= extradata_offset;",
"}",
"else if (codec_id == CODEC_ID_RA_144) {",
"MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)VAR_8;",
"audiotrack->samplerate = 8000;",
"audiotrack->channels = 1;",
"}",
"else if (codec_id == CODEC_ID_RA_288 ||\ncodec_id == CODEC_ID_COOK ||\ncodec_id == CODEC_ID_ATRAC3) {",
"MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)VAR_8;",
"ByteIOContext b;",
"init_put_byte(&b, VAR_8->codec_priv, VAR_8->codec_priv_size, 0,\nNULL, NULL, NULL, NULL);",
"url_fskip(&b, 24);",
"audiotrack->coded_framesize = get_be32(&b);",
"url_fskip(&b, 12);",
"audiotrack->sub_packet_h = get_be16(&b);",
"audiotrack->frame_size = get_be16(&b);",
"audiotrack->sub_packet_size = get_be16(&b);",
"audiotrack->buf = av_malloc(audiotrack->frame_size * audiotrack->sub_packet_h);",
"if (codec_id == CODEC_ID_RA_288) {",
"audiotrack->block_align = audiotrack->coded_framesize;",
"VAR_8->codec_priv_size = 0;",
"} else {",
"audiotrack->block_align = audiotrack->sub_packet_size;",
"extradata_offset = 78;",
"VAR_8->codec_priv_size -= extradata_offset;",
"}",
"}",
"if (codec_id == CODEC_ID_NONE) {",
"av_log(matroska->ctx, AV_LOG_INFO,\n\"Unknown/unsupported CodecID %VAR_0.\\n\",\nVAR_8->codec_id);",
"}",
"VAR_8->stream_index = matroska->num_streams;",
"matroska->num_streams++;",
"st = av_new_stream(VAR_0, VAR_8->stream_index);",
"if (st == NULL)\nreturn AVERROR(ENOMEM);",
"av_set_pts_info(st, 64, matroska->time_scale, 1000*1000*1000);",
"st->codec->codec_id = codec_id;",
"st->start_time = 0;",
"if (strcmp(VAR_8->language, \"und\"))\nstrcpy(st->language, VAR_8->language);",
"if (VAR_8->flags & MATROSKA_TRACK_DEFAULT)\nst->disposition |= AV_DISPOSITION_DEFAULT;",
"if (VAR_8->default_duration)\nav_reduce(&st->codec->time_base.num, &st->codec->time_base.den,\nVAR_8->default_duration, 1000000000, 30000);",
"if(extradata){",
"st->codec->extradata = extradata;",
"st->codec->extradata_size = extradata_size;",
"} else if(VAR_8->codec_priv && VAR_8->codec_priv_size > 0){",
"st->codec->extradata = av_malloc(VAR_8->codec_priv_size);",
"if(st->codec->extradata == NULL)\nreturn AVERROR(ENOMEM);",
"st->codec->extradata_size = VAR_8->codec_priv_size;",
"memcpy(st->codec->extradata,VAR_8->codec_priv+extradata_offset,\nVAR_8->codec_priv_size);",
"}",
"if (VAR_8->type == MATROSKA_TRACK_TYPE_VIDEO) {",
"MatroskaVideoTrack *videotrack = (MatroskaVideoTrack *)VAR_8;",
"st->codec->codec_type = CODEC_TYPE_VIDEO;",
"st->codec->codec_tag = videotrack->fourcc;",
"st->codec->width = videotrack->pixel_width;",
"st->codec->height = videotrack->pixel_height;",
"if (videotrack->display_width == 0)\nvideotrack->display_width= videotrack->pixel_width;",
"if (videotrack->display_height == 0)\nvideotrack->display_height= videotrack->pixel_height;",
"av_reduce(&st->codec->sample_aspect_ratio.num,\n&st->codec->sample_aspect_ratio.den,\nst->codec->height * videotrack->display_width,\nst->codec-> width * videotrack->display_height,\n255);",
"st->need_parsing = AVSTREAM_PARSE_HEADERS;",
"} else if (VAR_8->type == MATROSKA_TRACK_TYPE_AUDIO) {",
"MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)VAR_8;",
"st->codec->codec_type = CODEC_TYPE_AUDIO;",
"st->codec->sample_rate = audiotrack->samplerate;",
"st->codec->channels = audiotrack->channels;",
"st->codec->block_align = audiotrack->block_align;",
"} else if (VAR_8->type == MATROSKA_TRACK_TYPE_SUBTITLE) {",
"st->codec->codec_type = CODEC_TYPE_SUBTITLE;",
"}",
"}",
"VAR_5 = 0;",
"}",
"if (matroska->index_parsed) {",
"int VAR_8, VAR_8, VAR_9;",
"for (VAR_8=0; VAR_8<matroska->num_indexes; VAR_8++) {",
"MatroskaDemuxIndex *idx = &matroska->index[VAR_8];",
"VAR_8 = matroska_find_track_by_num(matroska, idx->VAR_8);",
"VAR_9 = matroska->tracks[VAR_8]->stream_index;",
"if (VAR_9 >= 0)\nav_add_index_entry(matroska->ctx->streams[VAR_9],\nidx->pos, idx->time/matroska->time_scale,\n0, 0, AVINDEX_KEYFRAME);",
"}",
"}",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23
],
[
25,
27
],
[
29
],
[
31,
33,
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
63
],
[
65,
67
],
[
69,
71
],
[
77,
79,
81
],
[
83,
85
],
[
87
],
[
97,
99
],
[
101
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
241
],
[
243
],
[
245
],
[
249,
251,
253
],
[
259,
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
311,
313
],
[
317
],
[
319,
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
339,
341,
343,
345
],
[
347
],
[
353
],
[
355
],
[
359
],
[
367,
369,
371,
373
],
[
375
],
[
381
],
[
383
],
[
387
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401,
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441,
443
],
[
445,
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
465,
467
],
[
469
],
[
471
],
[
473
],
[
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
489,
491,
493
],
[
495
],
[
497
],
[
501,
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
539
],
[
541,
543,
545
],
[
547
],
[
551
],
[
555
],
[
557
],
[
559,
561
],
[
563
],
[
567
],
[
569
],
[
571,
573
],
[
577,
579
],
[
583,
585,
587
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601,
603
],
[
605
],
[
607,
609
],
[
611
],
[
615
],
[
617
],
[
621
],
[
623
],
[
625
],
[
627
],
[
629,
631
],
[
633,
635
],
[
637,
639,
641,
643,
645
],
[
647
],
[
649
],
[
651
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
673
],
[
675
],
[
677
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
693,
695,
697,
699
],
[
701
],
[
703
],
[
707
],
[
709
]
]
|
10,423 | static void test_enabled(void)
{
int i;
throttle_config_init(&cfg);
g_assert(!throttle_enabled(&cfg));
for (i = 0; i < BUCKETS_COUNT; i++) {
throttle_config_init(&cfg);
set_cfg_value(false, i, 150);
g_assert(throttle_enabled(&cfg));
}
for (i = 0; i < BUCKETS_COUNT; i++) {
throttle_config_init(&cfg);
set_cfg_value(false, i, -150);
g_assert(!throttle_enabled(&cfg));
}
}
| true | qemu | d00e6923b1e2c1bec7840b0a0706764493648527 | static void test_enabled(void)
{
int i;
throttle_config_init(&cfg);
g_assert(!throttle_enabled(&cfg));
for (i = 0; i < BUCKETS_COUNT; i++) {
throttle_config_init(&cfg);
set_cfg_value(false, i, 150);
g_assert(throttle_enabled(&cfg));
}
for (i = 0; i < BUCKETS_COUNT; i++) {
throttle_config_init(&cfg);
set_cfg_value(false, i, -150);
g_assert(!throttle_enabled(&cfg));
}
}
| {
"code": [
" g_assert(!throttle_enabled(&cfg));"
],
"line_no": [
33
]
} | static void FUNC_0(void)
{
int VAR_0;
throttle_config_init(&cfg);
g_assert(!throttle_enabled(&cfg));
for (VAR_0 = 0; VAR_0 < BUCKETS_COUNT; VAR_0++) {
throttle_config_init(&cfg);
set_cfg_value(false, VAR_0, 150);
g_assert(throttle_enabled(&cfg));
}
for (VAR_0 = 0; VAR_0 < BUCKETS_COUNT; VAR_0++) {
throttle_config_init(&cfg);
set_cfg_value(false, VAR_0, -150);
g_assert(!throttle_enabled(&cfg));
}
}
| [
"static void FUNC_0(void)\n{",
"int VAR_0;",
"throttle_config_init(&cfg);",
"g_assert(!throttle_enabled(&cfg));",
"for (VAR_0 = 0; VAR_0 < BUCKETS_COUNT; VAR_0++) {",
"throttle_config_init(&cfg);",
"set_cfg_value(false, VAR_0, 150);",
"g_assert(throttle_enabled(&cfg));",
"}",
"for (VAR_0 = 0; VAR_0 < BUCKETS_COUNT; VAR_0++) {",
"throttle_config_init(&cfg);",
"set_cfg_value(false, VAR_0, -150);",
"g_assert(!throttle_enabled(&cfg));",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
]
|
10,424 | static inline void drawbox(AVFilterBufferRef *picref, unsigned int x, unsigned int y,
unsigned int width, unsigned int height,
uint8_t *line[4], int pixel_step[4], uint8_t color[4],
int hsub, int vsub, int is_rgba_packed, uint8_t rgba_map[4])
{
int i, j, alpha;
if (color[3] != 0xFF) {
if (is_rgba_packed) {
uint8_t *p;
for (j = 0; j < height; j++)
for (i = 0; i < width; i++)
SET_PIXEL_RGB(picref, color, 255, i+x, y+j, pixel_step[0],
rgba_map[0], rgba_map[1], rgba_map[2], rgba_map[3]);
} else {
unsigned int luma_pos, chroma_pos1, chroma_pos2;
for (j = 0; j < height; j++)
for (i = 0; i < width; i++)
SET_PIXEL_YUV(picref, color, 255, i+x, y+j, hsub, vsub);
}
} else {
ff_draw_rectangle(picref->data, picref->linesize,
line, pixel_step, hsub, vsub,
x, y, width, height);
}
}
| true | FFmpeg | db56a7507ee7c1e095d2eef451d5a487f614edff | static inline void drawbox(AVFilterBufferRef *picref, unsigned int x, unsigned int y,
unsigned int width, unsigned int height,
uint8_t *line[4], int pixel_step[4], uint8_t color[4],
int hsub, int vsub, int is_rgba_packed, uint8_t rgba_map[4])
{
int i, j, alpha;
if (color[3] != 0xFF) {
if (is_rgba_packed) {
uint8_t *p;
for (j = 0; j < height; j++)
for (i = 0; i < width; i++)
SET_PIXEL_RGB(picref, color, 255, i+x, y+j, pixel_step[0],
rgba_map[0], rgba_map[1], rgba_map[2], rgba_map[3]);
} else {
unsigned int luma_pos, chroma_pos1, chroma_pos2;
for (j = 0; j < height; j++)
for (i = 0; i < width; i++)
SET_PIXEL_YUV(picref, color, 255, i+x, y+j, hsub, vsub);
}
} else {
ff_draw_rectangle(picref->data, picref->linesize,
line, pixel_step, hsub, vsub,
x, y, width, height);
}
}
| {
"code": [
"static inline void drawbox(AVFilterBufferRef *picref, unsigned int x, unsigned int y,",
" unsigned int width, unsigned int height,"
],
"line_no": [
1,
3
]
} | static inline void FUNC_0(AVFilterBufferRef *VAR_0, unsigned int VAR_1, unsigned int VAR_2,
unsigned int VAR_3, unsigned int VAR_4,
uint8_t *VAR_5[4], int VAR_6[4], uint8_t VAR_7[4],
int VAR_8, int VAR_9, int VAR_10, uint8_t VAR_11[4])
{
int VAR_12, VAR_13, VAR_14;
if (VAR_7[3] != 0xFF) {
if (VAR_10) {
uint8_t *p;
for (VAR_13 = 0; VAR_13 < VAR_4; VAR_13++)
for (VAR_12 = 0; VAR_12 < VAR_3; VAR_12++)
SET_PIXEL_RGB(VAR_0, VAR_7, 255, VAR_12+VAR_1, VAR_2+VAR_13, VAR_6[0],
VAR_11[0], VAR_11[1], VAR_11[2], VAR_11[3]);
} else {
unsigned int VAR_15, VAR_16, VAR_17;
for (VAR_13 = 0; VAR_13 < VAR_4; VAR_13++)
for (VAR_12 = 0; VAR_12 < VAR_3; VAR_12++)
SET_PIXEL_YUV(VAR_0, VAR_7, 255, VAR_12+VAR_1, VAR_2+VAR_13, VAR_8, VAR_9);
}
} else {
ff_draw_rectangle(VAR_0->data, VAR_0->linesize,
VAR_5, VAR_6, VAR_8, VAR_9,
VAR_1, VAR_2, VAR_3, VAR_4);
}
}
| [
"static inline void FUNC_0(AVFilterBufferRef *VAR_0, unsigned int VAR_1, unsigned int VAR_2,\nunsigned int VAR_3, unsigned int VAR_4,\nuint8_t *VAR_5[4], int VAR_6[4], uint8_t VAR_7[4],\nint VAR_8, int VAR_9, int VAR_10, uint8_t VAR_11[4])\n{",
"int VAR_12, VAR_13, VAR_14;",
"if (VAR_7[3] != 0xFF) {",
"if (VAR_10) {",
"uint8_t *p;",
"for (VAR_13 = 0; VAR_13 < VAR_4; VAR_13++)",
"for (VAR_12 = 0; VAR_12 < VAR_3; VAR_12++)",
"SET_PIXEL_RGB(VAR_0, VAR_7, 255, VAR_12+VAR_1, VAR_2+VAR_13, VAR_6[0],\nVAR_11[0], VAR_11[1], VAR_11[2], VAR_11[3]);",
"} else {",
"unsigned int VAR_15, VAR_16, VAR_17;",
"for (VAR_13 = 0; VAR_13 < VAR_4; VAR_13++)",
"for (VAR_12 = 0; VAR_12 < VAR_3; VAR_12++)",
"SET_PIXEL_YUV(VAR_0, VAR_7, 255, VAR_12+VAR_1, VAR_2+VAR_13, VAR_8, VAR_9);",
"}",
"} else {",
"ff_draw_rectangle(VAR_0->data, VAR_0->linesize,\nVAR_5, VAR_6, VAR_8, VAR_9,\nVAR_1, VAR_2, VAR_3, VAR_4);",
"}",
"}"
]
| [
1,
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
]
]
|
10,425 | static void create_vorbis_context(venc_context_t * venc, AVCodecContext * avccontext) {
codebook_t * cb;
floor_t * fc;
residue_t * rc;
mapping_t * mc;
int i, book;
venc->channels = avccontext->channels;
venc->sample_rate = avccontext->sample_rate;
venc->blocksize[0] = venc->blocksize[1] = 8;
venc->ncodebooks = 10;
venc->codebooks = av_malloc(sizeof(codebook_t) * venc->ncodebooks);
// codebook 1 - floor1 book, values 0..255
cb = &venc->codebooks[0];
cb->nentries = 256;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 8;
cb->ndimentions = 0;
cb->min = 0.;
cb->delta = 0.;
cb->seq_p = 0;
cb->lookup = 0;
cb->quantlist = NULL;
ready_codebook(cb);
// codebook 2 - residue classbook, values 0..1, dimentions 200
cb = &venc->codebooks[1];
cb->nentries = 2;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 1;
cb->ndimentions = 200;
cb->min = 0.;
cb->delta = 0.;
cb->seq_p = 0;
cb->lookup = 0;
cb->quantlist = NULL;
ready_codebook(cb);
// codebook 3..10 - vector, for the residue, values -32767..32767, dimentions 1
for (book = 0; book < 8; book++) {
cb = &venc->codebooks[2 + book];
cb->nentries = 5;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (i = 0; i < cb->nentries; i++) cb->entries[i].len = i == 2 ? 1 : 3;
cb->ndimentions = 1;
cb->delta = 1 << ((7 - book) * 2);
cb->min = -cb->delta*2;
cb->seq_p = 0;
cb->lookup = 2;
cb->quantlist = av_malloc(sizeof(int) * cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries));
for (i = 0; i < cb->nentries; i++) cb->quantlist[i] = i;
ready_codebook(cb);
}
venc->nfloors = 1;
venc->floors = av_malloc(sizeof(floor_t) * venc->nfloors);
// just 1 floor
fc = &venc->floors[0];
fc->partitions = 1;
fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
for (i = 0; i < fc->partitions; i++) fc->partition_to_class = 0;
fc->nclasses = 1;
fc->classes = av_malloc(sizeof(floor_class_t) * fc->nclasses);
for (i = 0; i < fc->nclasses; i++) {
floor_class_t * c = &fc->classes[i];
int j, books;
c->dim = 1;
c->subclass = 0;
c->masterbook = 0;
books = (1 << c->subclass);
c->books = av_malloc(sizeof(int) * books);
for (j = 0; j < books; j++) c->books[j] = 0;
}
fc->multiplier = 1;
fc->rangebits = venc->blocksize[0];
fc->values = 2;
for (i = 0; i < fc->partitions; i++)
fc->values += fc->classes[fc->partition_to_class[i]].dim;
fc->list = av_malloc(sizeof(*fc->list) * fc->values);
fc->list[0].x = 0;
fc->list[1].x = 1 << fc->rangebits;
for (i = 2; i < fc->values; i++) fc->list[i].x = i * 5;
venc->nresidues = 1;
venc->residues = av_malloc(sizeof(residue_t) * venc->nresidues);
// single residue
rc = &venc->residues[0];
rc->type = 0;
rc->begin = 0;
rc->end = 1 << venc->blocksize[0];
rc->partition_size = 64;
rc->classifications = 1;
rc->classbook = 1;
rc->books = av_malloc(sizeof(int[8]) * rc->classifications);
for (i = 0; i < 8; i++) rc->books[0][i] = 2 + i;
venc->nmappings = 1;
venc->mappings = av_malloc(sizeof(mapping_t) * venc->nmappings);
// single mapping
mc = &venc->mappings[0];
mc->submaps = 1;
mc->mux = av_malloc(sizeof(int) * venc->channels);
for (i = 0; i < venc->channels; i++) mc->mux[i] = 0;
mc->floor = av_malloc(sizeof(int) * mc->submaps);
mc->residue = av_malloc(sizeof(int) * mc->submaps);
for (i = 0; i < mc->submaps; i++) {
mc->floor[i] = 0;
mc->residue[i] = 0;
}
venc->nmodes = 1;
venc->modes = av_malloc(sizeof(vorbis_mode_t) * venc->nmodes);
// single mode
venc->modes[0].blockflag = 0;
venc->modes[0].mapping = 0;
}
| true | FFmpeg | 2d06ce4c879549f13fc1c514cdb5680603f635d1 | static void create_vorbis_context(venc_context_t * venc, AVCodecContext * avccontext) {
codebook_t * cb;
floor_t * fc;
residue_t * rc;
mapping_t * mc;
int i, book;
venc->channels = avccontext->channels;
venc->sample_rate = avccontext->sample_rate;
venc->blocksize[0] = venc->blocksize[1] = 8;
venc->ncodebooks = 10;
venc->codebooks = av_malloc(sizeof(codebook_t) * venc->ncodebooks);
cb = &venc->codebooks[0];
cb->nentries = 256;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 8;
cb->ndimentions = 0;
cb->min = 0.;
cb->delta = 0.;
cb->seq_p = 0;
cb->lookup = 0;
cb->quantlist = NULL;
ready_codebook(cb);
cb = &venc->codebooks[1];
cb->nentries = 2;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 1;
cb->ndimentions = 200;
cb->min = 0.;
cb->delta = 0.;
cb->seq_p = 0;
cb->lookup = 0;
cb->quantlist = NULL;
ready_codebook(cb);
for (book = 0; book < 8; book++) {
cb = &venc->codebooks[2 + book];
cb->nentries = 5;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (i = 0; i < cb->nentries; i++) cb->entries[i].len = i == 2 ? 1 : 3;
cb->ndimentions = 1;
cb->delta = 1 << ((7 - book) * 2);
cb->min = -cb->delta*2;
cb->seq_p = 0;
cb->lookup = 2;
cb->quantlist = av_malloc(sizeof(int) * cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries));
for (i = 0; i < cb->nentries; i++) cb->quantlist[i] = i;
ready_codebook(cb);
}
venc->nfloors = 1;
venc->floors = av_malloc(sizeof(floor_t) * venc->nfloors);
fc = &venc->floors[0];
fc->partitions = 1;
fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
for (i = 0; i < fc->partitions; i++) fc->partition_to_class = 0;
fc->nclasses = 1;
fc->classes = av_malloc(sizeof(floor_class_t) * fc->nclasses);
for (i = 0; i < fc->nclasses; i++) {
floor_class_t * c = &fc->classes[i];
int j, books;
c->dim = 1;
c->subclass = 0;
c->masterbook = 0;
books = (1 << c->subclass);
c->books = av_malloc(sizeof(int) * books);
for (j = 0; j < books; j++) c->books[j] = 0;
}
fc->multiplier = 1;
fc->rangebits = venc->blocksize[0];
fc->values = 2;
for (i = 0; i < fc->partitions; i++)
fc->values += fc->classes[fc->partition_to_class[i]].dim;
fc->list = av_malloc(sizeof(*fc->list) * fc->values);
fc->list[0].x = 0;
fc->list[1].x = 1 << fc->rangebits;
for (i = 2; i < fc->values; i++) fc->list[i].x = i * 5;
venc->nresidues = 1;
venc->residues = av_malloc(sizeof(residue_t) * venc->nresidues);
rc = &venc->residues[0];
rc->type = 0;
rc->begin = 0;
rc->end = 1 << venc->blocksize[0];
rc->partition_size = 64;
rc->classifications = 1;
rc->classbook = 1;
rc->books = av_malloc(sizeof(int[8]) * rc->classifications);
for (i = 0; i < 8; i++) rc->books[0][i] = 2 + i;
venc->nmappings = 1;
venc->mappings = av_malloc(sizeof(mapping_t) * venc->nmappings);
mc = &venc->mappings[0];
mc->submaps = 1;
mc->mux = av_malloc(sizeof(int) * venc->channels);
for (i = 0; i < venc->channels; i++) mc->mux[i] = 0;
mc->floor = av_malloc(sizeof(int) * mc->submaps);
mc->residue = av_malloc(sizeof(int) * mc->submaps);
for (i = 0; i < mc->submaps; i++) {
mc->floor[i] = 0;
mc->residue[i] = 0;
}
venc->nmodes = 1;
venc->modes = av_malloc(sizeof(vorbis_mode_t) * venc->nmodes);
venc->modes[0].blockflag = 0;
venc->modes[0].mapping = 0;
}
| {
"code": [
" for (i = 0; i < fc->partitions; i++) fc->partition_to_class = 0;"
],
"line_no": [
127
]
} | static void FUNC_0(venc_context_t * VAR_0, AVCodecContext * VAR_1) {
codebook_t * cb;
floor_t * fc;
residue_t * rc;
mapping_t * mc;
int VAR_2, VAR_3;
VAR_0->channels = VAR_1->channels;
VAR_0->sample_rate = VAR_1->sample_rate;
VAR_0->blocksize[0] = VAR_0->blocksize[1] = 8;
VAR_0->ncodebooks = 10;
VAR_0->codebooks = av_malloc(sizeof(codebook_t) * VAR_0->ncodebooks);
cb = &VAR_0->codebooks[0];
cb->nentries = 256;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (VAR_2 = 0; VAR_2 < cb->nentries; VAR_2++) cb->entries[VAR_2].len = 8;
cb->ndimentions = 0;
cb->min = 0.;
cb->delta = 0.;
cb->seq_p = 0;
cb->lookup = 0;
cb->quantlist = NULL;
ready_codebook(cb);
cb = &VAR_0->codebooks[1];
cb->nentries = 2;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (VAR_2 = 0; VAR_2 < cb->nentries; VAR_2++) cb->entries[VAR_2].len = 1;
cb->ndimentions = 200;
cb->min = 0.;
cb->delta = 0.;
cb->seq_p = 0;
cb->lookup = 0;
cb->quantlist = NULL;
ready_codebook(cb);
for (VAR_3 = 0; VAR_3 < 8; VAR_3++) {
cb = &VAR_0->codebooks[2 + VAR_3];
cb->nentries = 5;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (VAR_2 = 0; VAR_2 < cb->nentries; VAR_2++) cb->entries[VAR_2].len = VAR_2 == 2 ? 1 : 3;
cb->ndimentions = 1;
cb->delta = 1 << ((7 - VAR_3) * 2);
cb->min = -cb->delta*2;
cb->seq_p = 0;
cb->lookup = 2;
cb->quantlist = av_malloc(sizeof(int) * cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries));
for (VAR_2 = 0; VAR_2 < cb->nentries; VAR_2++) cb->quantlist[VAR_2] = VAR_2;
ready_codebook(cb);
}
VAR_0->nfloors = 1;
VAR_0->floors = av_malloc(sizeof(floor_t) * VAR_0->nfloors);
fc = &VAR_0->floors[0];
fc->partitions = 1;
fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
for (VAR_2 = 0; VAR_2 < fc->partitions; VAR_2++) fc->partition_to_class = 0;
fc->nclasses = 1;
fc->classes = av_malloc(sizeof(floor_class_t) * fc->nclasses);
for (VAR_2 = 0; VAR_2 < fc->nclasses; VAR_2++) {
floor_class_t * c = &fc->classes[VAR_2];
int j, books;
c->dim = 1;
c->subclass = 0;
c->masterbook = 0;
books = (1 << c->subclass);
c->books = av_malloc(sizeof(int) * books);
for (j = 0; j < books; j++) c->books[j] = 0;
}
fc->multiplier = 1;
fc->rangebits = VAR_0->blocksize[0];
fc->values = 2;
for (VAR_2 = 0; VAR_2 < fc->partitions; VAR_2++)
fc->values += fc->classes[fc->partition_to_class[VAR_2]].dim;
fc->list = av_malloc(sizeof(*fc->list) * fc->values);
fc->list[0].x = 0;
fc->list[1].x = 1 << fc->rangebits;
for (VAR_2 = 2; VAR_2 < fc->values; VAR_2++) fc->list[VAR_2].x = VAR_2 * 5;
VAR_0->nresidues = 1;
VAR_0->residues = av_malloc(sizeof(residue_t) * VAR_0->nresidues);
rc = &VAR_0->residues[0];
rc->type = 0;
rc->begin = 0;
rc->end = 1 << VAR_0->blocksize[0];
rc->partition_size = 64;
rc->classifications = 1;
rc->classbook = 1;
rc->books = av_malloc(sizeof(int[8]) * rc->classifications);
for (VAR_2 = 0; VAR_2 < 8; VAR_2++) rc->books[0][VAR_2] = 2 + VAR_2;
VAR_0->nmappings = 1;
VAR_0->mappings = av_malloc(sizeof(mapping_t) * VAR_0->nmappings);
mc = &VAR_0->mappings[0];
mc->submaps = 1;
mc->mux = av_malloc(sizeof(int) * VAR_0->channels);
for (VAR_2 = 0; VAR_2 < VAR_0->channels; VAR_2++) mc->mux[VAR_2] = 0;
mc->floor = av_malloc(sizeof(int) * mc->submaps);
mc->residue = av_malloc(sizeof(int) * mc->submaps);
for (VAR_2 = 0; VAR_2 < mc->submaps; VAR_2++) {
mc->floor[VAR_2] = 0;
mc->residue[VAR_2] = 0;
}
VAR_0->nmodes = 1;
VAR_0->modes = av_malloc(sizeof(vorbis_mode_t) * VAR_0->nmodes);
VAR_0->modes[0].blockflag = 0;
VAR_0->modes[0].mapping = 0;
}
| [
"static void FUNC_0(venc_context_t * VAR_0, AVCodecContext * VAR_1) {",
"codebook_t * cb;",
"floor_t * fc;",
"residue_t * rc;",
"mapping_t * mc;",
"int VAR_2, VAR_3;",
"VAR_0->channels = VAR_1->channels;",
"VAR_0->sample_rate = VAR_1->sample_rate;",
"VAR_0->blocksize[0] = VAR_0->blocksize[1] = 8;",
"VAR_0->ncodebooks = 10;",
"VAR_0->codebooks = av_malloc(sizeof(codebook_t) * VAR_0->ncodebooks);",
"cb = &VAR_0->codebooks[0];",
"cb->nentries = 256;",
"cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);",
"for (VAR_2 = 0; VAR_2 < cb->nentries; VAR_2++) cb->entries[VAR_2].len = 8;",
"cb->ndimentions = 0;",
"cb->min = 0.;",
"cb->delta = 0.;",
"cb->seq_p = 0;",
"cb->lookup = 0;",
"cb->quantlist = NULL;",
"ready_codebook(cb);",
"cb = &VAR_0->codebooks[1];",
"cb->nentries = 2;",
"cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);",
"for (VAR_2 = 0; VAR_2 < cb->nentries; VAR_2++) cb->entries[VAR_2].len = 1;",
"cb->ndimentions = 200;",
"cb->min = 0.;",
"cb->delta = 0.;",
"cb->seq_p = 0;",
"cb->lookup = 0;",
"cb->quantlist = NULL;",
"ready_codebook(cb);",
"for (VAR_3 = 0; VAR_3 < 8; VAR_3++) {",
"cb = &VAR_0->codebooks[2 + VAR_3];",
"cb->nentries = 5;",
"cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);",
"for (VAR_2 = 0; VAR_2 < cb->nentries; VAR_2++) cb->entries[VAR_2].len = VAR_2 == 2 ? 1 : 3;",
"cb->ndimentions = 1;",
"cb->delta = 1 << ((7 - VAR_3) * 2);",
"cb->min = -cb->delta*2;",
"cb->seq_p = 0;",
"cb->lookup = 2;",
"cb->quantlist = av_malloc(sizeof(int) * cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries));",
"for (VAR_2 = 0; VAR_2 < cb->nentries; VAR_2++) cb->quantlist[VAR_2] = VAR_2;",
"ready_codebook(cb);",
"}",
"VAR_0->nfloors = 1;",
"VAR_0->floors = av_malloc(sizeof(floor_t) * VAR_0->nfloors);",
"fc = &VAR_0->floors[0];",
"fc->partitions = 1;",
"fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);",
"for (VAR_2 = 0; VAR_2 < fc->partitions; VAR_2++) fc->partition_to_class = 0;",
"fc->nclasses = 1;",
"fc->classes = av_malloc(sizeof(floor_class_t) * fc->nclasses);",
"for (VAR_2 = 0; VAR_2 < fc->nclasses; VAR_2++) {",
"floor_class_t * c = &fc->classes[VAR_2];",
"int j, books;",
"c->dim = 1;",
"c->subclass = 0;",
"c->masterbook = 0;",
"books = (1 << c->subclass);",
"c->books = av_malloc(sizeof(int) * books);",
"for (j = 0; j < books; j++) c->books[j] = 0;",
"}",
"fc->multiplier = 1;",
"fc->rangebits = VAR_0->blocksize[0];",
"fc->values = 2;",
"for (VAR_2 = 0; VAR_2 < fc->partitions; VAR_2++)",
"fc->values += fc->classes[fc->partition_to_class[VAR_2]].dim;",
"fc->list = av_malloc(sizeof(*fc->list) * fc->values);",
"fc->list[0].x = 0;",
"fc->list[1].x = 1 << fc->rangebits;",
"for (VAR_2 = 2; VAR_2 < fc->values; VAR_2++) fc->list[VAR_2].x = VAR_2 * 5;",
"VAR_0->nresidues = 1;",
"VAR_0->residues = av_malloc(sizeof(residue_t) * VAR_0->nresidues);",
"rc = &VAR_0->residues[0];",
"rc->type = 0;",
"rc->begin = 0;",
"rc->end = 1 << VAR_0->blocksize[0];",
"rc->partition_size = 64;",
"rc->classifications = 1;",
"rc->classbook = 1;",
"rc->books = av_malloc(sizeof(int[8]) * rc->classifications);",
"for (VAR_2 = 0; VAR_2 < 8; VAR_2++) rc->books[0][VAR_2] = 2 + VAR_2;",
"VAR_0->nmappings = 1;",
"VAR_0->mappings = av_malloc(sizeof(mapping_t) * VAR_0->nmappings);",
"mc = &VAR_0->mappings[0];",
"mc->submaps = 1;",
"mc->mux = av_malloc(sizeof(int) * VAR_0->channels);",
"for (VAR_2 = 0; VAR_2 < VAR_0->channels; VAR_2++) mc->mux[VAR_2] = 0;",
"mc->floor = av_malloc(sizeof(int) * mc->submaps);",
"mc->residue = av_malloc(sizeof(int) * mc->submaps);",
"for (VAR_2 = 0; VAR_2 < mc->submaps; VAR_2++) {",
"mc->floor[VAR_2] = 0;",
"mc->residue[VAR_2] = 0;",
"}",
"VAR_0->nmodes = 1;",
"VAR_0->modes = av_malloc(sizeof(vorbis_mode_t) * VAR_0->nmodes);",
"VAR_0->modes[0].blockflag = 0;",
"VAR_0->modes[0].mapping = 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
243
],
[
245
],
[
247
]
]
|
10,426 | static int iscsi_readcapacity_sync(IscsiLun *iscsilun)
{
struct scsi_task *task = NULL;
struct scsi_readcapacity10 *rc10 = NULL;
struct scsi_readcapacity16 *rc16 = NULL;
int ret = 0;
int retries = ISCSI_CMD_RETRIES;
do {
if (task != NULL) {
scsi_free_scsi_task(task);
task = NULL;
}
switch (iscsilun->type) {
case TYPE_DISK:
task = iscsi_readcapacity16_sync(iscsilun->iscsi, iscsilun->lun);
if (task != NULL && task->status == SCSI_STATUS_GOOD) {
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
error_report("iSCSI: Failed to unmarshall readcapacity16 data.");
ret = -EINVAL;
} else {
iscsilun->block_size = rc16->block_length;
iscsilun->num_blocks = rc16->returned_lba + 1;
iscsilun->lbpme = rc16->lbpme;
iscsilun->lbprz = rc16->lbprz;
}
}
break;
case TYPE_ROM:
task = iscsi_readcapacity10_sync(iscsilun->iscsi, iscsilun->lun, 0, 0);
if (task != NULL && task->status == SCSI_STATUS_GOOD) {
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
error_report("iSCSI: Failed to unmarshall readcapacity10 data.");
ret = -EINVAL;
} else {
iscsilun->block_size = rc10->block_size;
if (rc10->lba == 0) {
/* blank disk loaded */
iscsilun->num_blocks = 0;
} else {
iscsilun->num_blocks = rc10->lba + 1;
}
}
}
break;
default:
return 0;
}
} while (task != NULL && task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_UNIT_ATTENTION
&& retries-- > 0);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
error_report("iSCSI: failed to send readcapacity10 command.");
ret = -EINVAL;
}
if (task) {
scsi_free_scsi_task(task);
}
return ret;
}
| true | qemu | f2917853f715b0ef55df29eb2ffea29dc69ce814 | static int iscsi_readcapacity_sync(IscsiLun *iscsilun)
{
struct scsi_task *task = NULL;
struct scsi_readcapacity10 *rc10 = NULL;
struct scsi_readcapacity16 *rc16 = NULL;
int ret = 0;
int retries = ISCSI_CMD_RETRIES;
do {
if (task != NULL) {
scsi_free_scsi_task(task);
task = NULL;
}
switch (iscsilun->type) {
case TYPE_DISK:
task = iscsi_readcapacity16_sync(iscsilun->iscsi, iscsilun->lun);
if (task != NULL && task->status == SCSI_STATUS_GOOD) {
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
error_report("iSCSI: Failed to unmarshall readcapacity16 data.");
ret = -EINVAL;
} else {
iscsilun->block_size = rc16->block_length;
iscsilun->num_blocks = rc16->returned_lba + 1;
iscsilun->lbpme = rc16->lbpme;
iscsilun->lbprz = rc16->lbprz;
}
}
break;
case TYPE_ROM:
task = iscsi_readcapacity10_sync(iscsilun->iscsi, iscsilun->lun, 0, 0);
if (task != NULL && task->status == SCSI_STATUS_GOOD) {
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
error_report("iSCSI: Failed to unmarshall readcapacity10 data.");
ret = -EINVAL;
} else {
iscsilun->block_size = rc10->block_size;
if (rc10->lba == 0) {
iscsilun->num_blocks = 0;
} else {
iscsilun->num_blocks = rc10->lba + 1;
}
}
}
break;
default:
return 0;
}
} while (task != NULL && task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_UNIT_ATTENTION
&& retries-- > 0);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
error_report("iSCSI: failed to send readcapacity10 command.");
ret = -EINVAL;
}
if (task) {
scsi_free_scsi_task(task);
}
return ret;
}
| {
"code": [
" return 0;",
"static int iscsi_readcapacity_sync(IscsiLun *iscsilun)",
" int ret = 0;",
" error_report(\"iSCSI: Failed to unmarshall readcapacity16 data.\");",
" ret = -EINVAL;",
" error_report(\"iSCSI: Failed to unmarshall readcapacity10 data.\");",
" ret = -EINVAL;",
" return 0;",
" error_report(\"iSCSI: failed to send readcapacity10 command.\");",
" ret = -EINVAL;",
" return ret;",
" int ret = 0;"
],
"line_no": [
99,
1,
11,
41,
43,
71,
43,
99,
113,
115,
125,
11
]
} | static int FUNC_0(IscsiLun *VAR_0)
{
struct scsi_task *VAR_1 = NULL;
struct scsi_readcapacity10 *VAR_2 = NULL;
struct scsi_readcapacity16 *VAR_3 = NULL;
int VAR_4 = 0;
int VAR_5 = ISCSI_CMD_RETRIES;
do {
if (VAR_1 != NULL) {
scsi_free_scsi_task(VAR_1);
VAR_1 = NULL;
}
switch (VAR_0->type) {
case TYPE_DISK:
VAR_1 = iscsi_readcapacity16_sync(VAR_0->iscsi, VAR_0->lun);
if (VAR_1 != NULL && VAR_1->status == SCSI_STATUS_GOOD) {
VAR_3 = scsi_datain_unmarshall(VAR_1);
if (VAR_3 == NULL) {
error_report("iSCSI: Failed to unmarshall readcapacity16 data.");
VAR_4 = -EINVAL;
} else {
VAR_0->block_size = VAR_3->block_length;
VAR_0->num_blocks = VAR_3->returned_lba + 1;
VAR_0->lbpme = VAR_3->lbpme;
VAR_0->lbprz = VAR_3->lbprz;
}
}
break;
case TYPE_ROM:
VAR_1 = iscsi_readcapacity10_sync(VAR_0->iscsi, VAR_0->lun, 0, 0);
if (VAR_1 != NULL && VAR_1->status == SCSI_STATUS_GOOD) {
VAR_2 = scsi_datain_unmarshall(VAR_1);
if (VAR_2 == NULL) {
error_report("iSCSI: Failed to unmarshall readcapacity10 data.");
VAR_4 = -EINVAL;
} else {
VAR_0->block_size = VAR_2->block_size;
if (VAR_2->lba == 0) {
VAR_0->num_blocks = 0;
} else {
VAR_0->num_blocks = VAR_2->lba + 1;
}
}
}
break;
default:
return 0;
}
} while (VAR_1 != NULL && VAR_1->status == SCSI_STATUS_CHECK_CONDITION
&& VAR_1->sense.key == SCSI_SENSE_UNIT_ATTENTION
&& VAR_5-- > 0);
if (VAR_1 == NULL || VAR_1->status != SCSI_STATUS_GOOD) {
error_report("iSCSI: failed to send readcapacity10 command.");
VAR_4 = -EINVAL;
}
if (VAR_1) {
scsi_free_scsi_task(VAR_1);
}
return VAR_4;
}
| [
"static int FUNC_0(IscsiLun *VAR_0)\n{",
"struct scsi_task *VAR_1 = NULL;",
"struct scsi_readcapacity10 *VAR_2 = NULL;",
"struct scsi_readcapacity16 *VAR_3 = NULL;",
"int VAR_4 = 0;",
"int VAR_5 = ISCSI_CMD_RETRIES;",
"do {",
"if (VAR_1 != NULL) {",
"scsi_free_scsi_task(VAR_1);",
"VAR_1 = NULL;",
"}",
"switch (VAR_0->type) {",
"case TYPE_DISK:\nVAR_1 = iscsi_readcapacity16_sync(VAR_0->iscsi, VAR_0->lun);",
"if (VAR_1 != NULL && VAR_1->status == SCSI_STATUS_GOOD) {",
"VAR_3 = scsi_datain_unmarshall(VAR_1);",
"if (VAR_3 == NULL) {",
"error_report(\"iSCSI: Failed to unmarshall readcapacity16 data.\");",
"VAR_4 = -EINVAL;",
"} else {",
"VAR_0->block_size = VAR_3->block_length;",
"VAR_0->num_blocks = VAR_3->returned_lba + 1;",
"VAR_0->lbpme = VAR_3->lbpme;",
"VAR_0->lbprz = VAR_3->lbprz;",
"}",
"}",
"break;",
"case TYPE_ROM:\nVAR_1 = iscsi_readcapacity10_sync(VAR_0->iscsi, VAR_0->lun, 0, 0);",
"if (VAR_1 != NULL && VAR_1->status == SCSI_STATUS_GOOD) {",
"VAR_2 = scsi_datain_unmarshall(VAR_1);",
"if (VAR_2 == NULL) {",
"error_report(\"iSCSI: Failed to unmarshall readcapacity10 data.\");",
"VAR_4 = -EINVAL;",
"} else {",
"VAR_0->block_size = VAR_2->block_size;",
"if (VAR_2->lba == 0) {",
"VAR_0->num_blocks = 0;",
"} else {",
"VAR_0->num_blocks = VAR_2->lba + 1;",
"}",
"}",
"}",
"break;",
"default:\nreturn 0;",
"}",
"} while (VAR_1 != NULL && VAR_1->status == SCSI_STATUS_CHECK_CONDITION",
"&& VAR_1->sense.key == SCSI_SENSE_UNIT_ATTENTION\n&& VAR_5-- > 0);",
"if (VAR_1 == NULL || VAR_1->status != SCSI_STATUS_GOOD) {",
"error_report(\"iSCSI: failed to send readcapacity10 command.\");",
"VAR_4 = -EINVAL;",
"}",
"if (VAR_1) {",
"scsi_free_scsi_task(VAR_1);",
"}",
"return VAR_4;",
"}"
]
| [
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
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
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105,
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
]
]
|
10,427 | int kvm_arch_process_async_events(CPUState *env)
{
if (kvm_irqchip_in_kernel()) {
if (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)) {
if (env->interrupt_request & CPU_INTERRUPT_INIT) {
do_cpu_init(env);
if (env->interrupt_request & CPU_INTERRUPT_SIPI) {
do_cpu_sipi(env);
return env->halted; | true | qemu | ab443475c9235822e329e1bfde89be6c71e2c21e | int kvm_arch_process_async_events(CPUState *env)
{
if (kvm_irqchip_in_kernel()) {
if (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)) {
if (env->interrupt_request & CPU_INTERRUPT_INIT) {
do_cpu_init(env);
if (env->interrupt_request & CPU_INTERRUPT_SIPI) {
do_cpu_sipi(env);
return env->halted; | {
"code": [],
"line_no": []
} | int FUNC_0(CPUState *VAR_0)
{
if (kvm_irqchip_in_kernel()) {
if (VAR_0->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)) {
if (VAR_0->interrupt_request & CPU_INTERRUPT_INIT) {
do_cpu_init(VAR_0);
if (VAR_0->interrupt_request & CPU_INTERRUPT_SIPI) {
do_cpu_sipi(VAR_0);
return VAR_0->halted; | [
"int FUNC_0(CPUState *VAR_0)\n{",
"if (kvm_irqchip_in_kernel()) {",
"if (VAR_0->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)) {",
"if (VAR_0->interrupt_request & CPU_INTERRUPT_INIT) {",
"do_cpu_init(VAR_0);",
"if (VAR_0->interrupt_request & CPU_INTERRUPT_SIPI) {",
"do_cpu_sipi(VAR_0);",
"return VAR_0->halted;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
]
]
|
10,428 | static void gen_slbmte(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
return;
}
gen_helper_store_slb(cpu_env, cpu_gpr[rB(ctx->opcode)],
cpu_gpr[rS(ctx->opcode)]);
#endif
}
| true | qemu | 9b2fadda3e0196ffd485adde4fe9cdd6fae35300 | static void gen_slbmte(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
return;
}
gen_helper_store_slb(cpu_env, cpu_gpr[rB(ctx->opcode)],
cpu_gpr[rS(ctx->opcode)]);
#endif
}
| {
"code": [
" if (unlikely(ctx->pr)) {",
" if (unlikely(ctx->pr)) {",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif"
],
"line_no": [
11,
11,
5,
7,
9,
11,
13,
23,
5,
7,
9,
11,
13,
23,
23,
5,
7,
9,
11,
13,
11,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
23,
11,
23,
23,
23,
11,
23,
11,
23,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
7,
11,
13,
23,
5,
9,
11,
23,
11,
23,
5,
9,
11,
23,
5,
9,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
5,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23,
11,
23
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);
#else
if (unlikely(VAR_0->pr)) {
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);
return;
}
gen_helper_store_slb(cpu_env, cpu_gpr[rB(VAR_0->opcode)],
cpu_gpr[rS(VAR_0->opcode)]);
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);",
"#else\nif (unlikely(VAR_0->pr)) {",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);",
"return;",
"}",
"gen_helper_store_slb(cpu_env, cpu_gpr[rB(VAR_0->opcode)],\ncpu_gpr[rS(VAR_0->opcode)]);",
"#endif\n}"
]
| [
0,
1,
1,
1,
0,
0,
0,
1
]
| [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23,
25
]
]
|
10,430 | static void shifter_out_im(TCGv var, int shift)
{
TCGv tmp = new_tmp();
if (shift == 0) {
tcg_gen_andi_i32(tmp, var, 1);
} else {
tcg_gen_shri_i32(tmp, var, shift);
if (shift != 31)
tcg_gen_andi_i32(tmp, tmp, 1);
}
gen_set_CF(tmp);
dead_tmp(tmp);
}
| true | qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | static void shifter_out_im(TCGv var, int shift)
{
TCGv tmp = new_tmp();
if (shift == 0) {
tcg_gen_andi_i32(tmp, var, 1);
} else {
tcg_gen_shri_i32(tmp, var, shift);
if (shift != 31)
tcg_gen_andi_i32(tmp, tmp, 1);
}
gen_set_CF(tmp);
dead_tmp(tmp);
}
| {
"code": [
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" TCGv tmp = new_tmp();",
" dead_tmp(tmp);",
" dead_tmp(tmp);"
],
"line_no": [
5,
5,
5,
23,
5,
23,
5,
23,
5,
23,
5,
23,
23,
23,
23,
5,
23,
23,
5,
5,
5,
5,
5,
5,
5,
23,
5,
23,
5,
23,
5,
23,
5,
23,
23,
5,
23,
23,
5,
23,
23
]
} | static void FUNC_0(TCGv VAR_0, int VAR_1)
{
TCGv tmp = new_tmp();
if (VAR_1 == 0) {
tcg_gen_andi_i32(tmp, VAR_0, 1);
} else {
tcg_gen_shri_i32(tmp, VAR_0, VAR_1);
if (VAR_1 != 31)
tcg_gen_andi_i32(tmp, tmp, 1);
}
gen_set_CF(tmp);
dead_tmp(tmp);
}
| [
"static void FUNC_0(TCGv VAR_0, int VAR_1)\n{",
"TCGv tmp = new_tmp();",
"if (VAR_1 == 0) {",
"tcg_gen_andi_i32(tmp, VAR_0, 1);",
"} else {",
"tcg_gen_shri_i32(tmp, VAR_0, VAR_1);",
"if (VAR_1 != 31)\ntcg_gen_andi_i32(tmp, tmp, 1);",
"}",
"gen_set_CF(tmp);",
"dead_tmp(tmp);",
"}"
]
| [
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
10,431 | static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
const char *language,
kbd_layout_t *k)
{
FILE *f;
char * filename;
char line[1024];
int len;
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
f = filename ? fopen(filename, "r") : NULL;
g_free(filename);
if (!f) {
fprintf(stderr, "Could not read keymap file: '%s'\n", language);
return NULL;
}
if (!k) {
k = g_malloc0(sizeof(kbd_layout_t));
}
for(;;) {
if (fgets(line, 1024, f) == NULL) {
break;
}
len = strlen(line);
if (len > 0 && line[len - 1] == '\n') {
line[len - 1] = '\0';
}
if (line[0] == '#') {
continue;
}
if (!strncmp(line, "map ", 4)) {
continue;
}
if (!strncmp(line, "include ", 8)) {
parse_keyboard_layout(table, line + 8, k);
} else {
char *end_of_keysym = line;
while (*end_of_keysym != 0 && *end_of_keysym != ' ') {
end_of_keysym++;
}
if (*end_of_keysym) {
int keysym;
*end_of_keysym = 0;
keysym = get_keysym(table, line);
if (keysym == 0) {
/* fprintf(stderr, "Warning: unknown keysym %s\n", line);*/
} else {
const char *rest = end_of_keysym + 1;
int keycode = strtol(rest, NULL, 0);
if (strstr(rest, "numlock")) {
add_to_key_range(&k->keypad_range, keycode);
add_to_key_range(&k->numlock_range, keysym);
/* fprintf(stderr, "keypad keysym %04x keycode %d\n",
keysym, keycode); */
}
if (strstr(rest, "shift")) {
keycode |= SCANCODE_SHIFT;
}
if (strstr(rest, "altgr")) {
keycode |= SCANCODE_ALTGR;
}
if (strstr(rest, "ctrl")) {
keycode |= SCANCODE_CTRL;
}
add_keysym(line, keysym, keycode, k);
if (strstr(rest, "addupper")) {
char *c;
for (c = line; *c; c++) {
*c = qemu_toupper(*c);
}
keysym = get_keysym(table, line);
if (keysym) {
add_keysym(line, keysym,
keycode | SCANCODE_SHIFT, k);
}
}
}
}
}
}
fclose(f);
return k;
}
| true | qemu | fedf0d35aafc4f1f1e5f6dbc80cb23ae1ae49f0b | static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
const char *language,
kbd_layout_t *k)
{
FILE *f;
char * filename;
char line[1024];
int len;
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
f = filename ? fopen(filename, "r") : NULL;
g_free(filename);
if (!f) {
fprintf(stderr, "Could not read keymap file: '%s'\n", language);
return NULL;
}
if (!k) {
k = g_malloc0(sizeof(kbd_layout_t));
}
for(;;) {
if (fgets(line, 1024, f) == NULL) {
break;
}
len = strlen(line);
if (len > 0 && line[len - 1] == '\n') {
line[len - 1] = '\0';
}
if (line[0] == '#') {
continue;
}
if (!strncmp(line, "map ", 4)) {
continue;
}
if (!strncmp(line, "include ", 8)) {
parse_keyboard_layout(table, line + 8, k);
} else {
char *end_of_keysym = line;
while (*end_of_keysym != 0 && *end_of_keysym != ' ') {
end_of_keysym++;
}
if (*end_of_keysym) {
int keysym;
*end_of_keysym = 0;
keysym = get_keysym(table, line);
if (keysym == 0) {
} else {
const char *rest = end_of_keysym + 1;
int keycode = strtol(rest, NULL, 0);
if (strstr(rest, "numlock")) {
add_to_key_range(&k->keypad_range, keycode);
add_to_key_range(&k->numlock_range, keysym);
}
if (strstr(rest, "shift")) {
keycode |= SCANCODE_SHIFT;
}
if (strstr(rest, "altgr")) {
keycode |= SCANCODE_ALTGR;
}
if (strstr(rest, "ctrl")) {
keycode |= SCANCODE_CTRL;
}
add_keysym(line, keysym, keycode, k);
if (strstr(rest, "addupper")) {
char *c;
for (c = line; *c; c++) {
*c = qemu_toupper(*c);
}
keysym = get_keysym(table, line);
if (keysym) {
add_keysym(line, keysym,
keycode | SCANCODE_SHIFT, k);
}
}
}
}
}
}
fclose(f);
return k;
}
| {
"code": [
" k = g_malloc0(sizeof(kbd_layout_t));"
],
"line_no": [
37
]
} | static kbd_layout_t *FUNC_0(const name2keysym_t *table,
const char *language,
kbd_layout_t *k)
{
FILE *f;
char * VAR_0;
char VAR_1[1024];
int VAR_2;
VAR_0 = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
f = VAR_0 ? fopen(VAR_0, "r") : NULL;
g_free(VAR_0);
if (!f) {
fprintf(stderr, "Could not read keymap file: '%s'\n", language);
return NULL;
}
if (!k) {
k = g_malloc0(sizeof(kbd_layout_t));
}
for(;;) {
if (fgets(VAR_1, 1024, f) == NULL) {
break;
}
VAR_2 = strlen(VAR_1);
if (VAR_2 > 0 && VAR_1[VAR_2 - 1] == '\n') {
VAR_1[VAR_2 - 1] = '\0';
}
if (VAR_1[0] == '#') {
continue;
}
if (!strncmp(VAR_1, "map ", 4)) {
continue;
}
if (!strncmp(VAR_1, "include ", 8)) {
FUNC_0(table, VAR_1 + 8, k);
} else {
char *VAR_3 = VAR_1;
while (*VAR_3 != 0 && *VAR_3 != ' ') {
VAR_3++;
}
if (*VAR_3) {
int VAR_4;
*VAR_3 = 0;
VAR_4 = get_keysym(table, VAR_1);
if (VAR_4 == 0) {
} else {
const char *VAR_5 = VAR_3 + 1;
int VAR_6 = strtol(VAR_5, NULL, 0);
if (strstr(VAR_5, "numlock")) {
add_to_key_range(&k->keypad_range, VAR_6);
add_to_key_range(&k->numlock_range, VAR_4);
}
if (strstr(VAR_5, "shift")) {
VAR_6 |= SCANCODE_SHIFT;
}
if (strstr(VAR_5, "altgr")) {
VAR_6 |= SCANCODE_ALTGR;
}
if (strstr(VAR_5, "ctrl")) {
VAR_6 |= SCANCODE_CTRL;
}
add_keysym(VAR_1, VAR_4, VAR_6, k);
if (strstr(VAR_5, "addupper")) {
char *VAR_7;
for (VAR_7 = VAR_1; *VAR_7; VAR_7++) {
*VAR_7 = qemu_toupper(*VAR_7);
}
VAR_4 = get_keysym(table, VAR_1);
if (VAR_4) {
add_keysym(VAR_1, VAR_4,
VAR_6 | SCANCODE_SHIFT, k);
}
}
}
}
}
}
fclose(f);
return k;
}
| [
"static kbd_layout_t *FUNC_0(const name2keysym_t *table,\nconst char *language,\nkbd_layout_t *k)\n{",
"FILE *f;",
"char * VAR_0;",
"char VAR_1[1024];",
"int VAR_2;",
"VAR_0 = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);",
"f = VAR_0 ? fopen(VAR_0, \"r\") : NULL;",
"g_free(VAR_0);",
"if (!f) {",
"fprintf(stderr, \"Could not read keymap file: '%s'\\n\", language);",
"return NULL;",
"}",
"if (!k) {",
"k = g_malloc0(sizeof(kbd_layout_t));",
"}",
"for(;;) {",
"if (fgets(VAR_1, 1024, f) == NULL) {",
"break;",
"}",
"VAR_2 = strlen(VAR_1);",
"if (VAR_2 > 0 && VAR_1[VAR_2 - 1] == '\\n') {",
"VAR_1[VAR_2 - 1] = '\\0';",
"}",
"if (VAR_1[0] == '#') {",
"continue;",
"}",
"if (!strncmp(VAR_1, \"map \", 4)) {",
"continue;",
"}",
"if (!strncmp(VAR_1, \"include \", 8)) {",
"FUNC_0(table, VAR_1 + 8, k);",
"} else {",
"char *VAR_3 = VAR_1;",
"while (*VAR_3 != 0 && *VAR_3 != ' ') {",
"VAR_3++;",
"}",
"if (*VAR_3) {",
"int VAR_4;",
"*VAR_3 = 0;",
"VAR_4 = get_keysym(table, VAR_1);",
"if (VAR_4 == 0) {",
"} else {",
"const char *VAR_5 = VAR_3 + 1;",
"int VAR_6 = strtol(VAR_5, NULL, 0);",
"if (strstr(VAR_5, \"numlock\")) {",
"add_to_key_range(&k->keypad_range, VAR_6);",
"add_to_key_range(&k->numlock_range, VAR_4);",
"}",
"if (strstr(VAR_5, \"shift\")) {",
"VAR_6 |= SCANCODE_SHIFT;",
"}",
"if (strstr(VAR_5, \"altgr\")) {",
"VAR_6 |= SCANCODE_ALTGR;",
"}",
"if (strstr(VAR_5, \"ctrl\")) {",
"VAR_6 |= SCANCODE_CTRL;",
"}",
"add_keysym(VAR_1, VAR_4, VAR_6, k);",
"if (strstr(VAR_5, \"addupper\")) {",
"char *VAR_7;",
"for (VAR_7 = VAR_1; *VAR_7; VAR_7++) {",
"*VAR_7 = qemu_toupper(*VAR_7);",
"}",
"VAR_4 = get_keysym(table, VAR_1);",
"if (VAR_4) {",
"add_keysym(VAR_1, VAR_4,\nVAR_6 | SCANCODE_SHIFT, k);",
"}",
"}",
"}",
"}",
"}",
"}",
"fclose(f);",
"return k;",
"}"
]
| [
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
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
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
]
]
|
10,432 | static void ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
int i;
for(i=16; i<16+8; i++){
if(nnzc[ scan8[i] ] || block[i*16])
ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
}
}
| false | FFmpeg | 1d16a1cf99488f16492b1bb48e023f4da8377e07 | static void ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
int i;
for(i=16; i<16+8; i++){
if(nnzc[ scan8[i] ] || block[i*16])
ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t **VAR_0, const int *VAR_1, DCTELEM *VAR_2, int VAR_3, const uint8_t VAR_4[6*8]){
int VAR_5;
for(VAR_5=16; VAR_5<16+8; VAR_5++){
if(VAR_4[ scan8[VAR_5] ] || VAR_2[VAR_5*16])
ff_h264_idct_add_mmx (VAR_0[(VAR_5&4)>>2] + VAR_1[VAR_5], VAR_2 + VAR_5*16, VAR_3);
}
}
| [
"static void FUNC_0(uint8_t **VAR_0, const int *VAR_1, DCTELEM *VAR_2, int VAR_3, const uint8_t VAR_4[6*8]){",
"int VAR_5;",
"for(VAR_5=16; VAR_5<16+8; VAR_5++){",
"if(VAR_4[ scan8[VAR_5] ] || VAR_2[VAR_5*16])\nff_h264_idct_add_mmx (VAR_0[(VAR_5&4)>>2] + VAR_1[VAR_5], VAR_2 + VAR_5*16, VAR_3);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
]
]
|
10,433 | static void vmxnet3_deactivate_device(VMXNET3State *s)
{
VMW_CBPRN("Deactivating vmxnet3...");
s->device_active = false;
}
| true | qemu | aa4a3dce1c88ed51b616806b8214b7c8428b7470 | static void vmxnet3_deactivate_device(VMXNET3State *s)
{
VMW_CBPRN("Deactivating vmxnet3...");
s->device_active = false;
}
| {
"code": [
" VMW_CBPRN(\"Deactivating vmxnet3...\");",
" s->device_active = false;"
],
"line_no": [
5,
7
]
} | static void FUNC_0(VMXNET3State *VAR_0)
{
VMW_CBPRN("Deactivating vmxnet3...");
VAR_0->device_active = false;
}
| [
"static void FUNC_0(VMXNET3State *VAR_0)\n{",
"VMW_CBPRN(\"Deactivating vmxnet3...\");",
"VAR_0->device_active = false;",
"}"
]
| [
0,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
10,434 | e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val)
{
int i;
core->mac[PBACLR] = val & E1000_PBACLR_VALID_MASK;
if (msix_enabled(core->owner)) {
return;
}
for (i = 0; i < E1000E_MSIX_VEC_NUM; i++) {
if (core->mac[PBACLR] & BIT(i)) {
msix_clr_pending(core->owner, i);
}
}
}
| true | qemu | 680e60b6ba5a26332d684a60a6d9f39c0a999941 | e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val)
{
int i;
core->mac[PBACLR] = val & E1000_PBACLR_VALID_MASK;
if (msix_enabled(core->owner)) {
return;
}
for (i = 0; i < E1000E_MSIX_VEC_NUM; i++) {
if (core->mac[PBACLR] & BIT(i)) {
msix_clr_pending(core->owner, i);
}
}
}
| {
"code": [
" if (msix_enabled(core->owner)) {"
],
"line_no": [
13
]
} | FUNC_0(E1000ECore *VAR_0, int VAR_1, uint32_t VAR_2)
{
int VAR_3;
VAR_0->mac[PBACLR] = VAR_2 & E1000_PBACLR_VALID_MASK;
if (msix_enabled(VAR_0->owner)) {
return;
}
for (VAR_3 = 0; VAR_3 < E1000E_MSIX_VEC_NUM; VAR_3++) {
if (VAR_0->mac[PBACLR] & BIT(VAR_3)) {
msix_clr_pending(VAR_0->owner, VAR_3);
}
}
}
| [
"FUNC_0(E1000ECore *VAR_0, int VAR_1, uint32_t VAR_2)\n{",
"int VAR_3;",
"VAR_0->mac[PBACLR] = VAR_2 & E1000_PBACLR_VALID_MASK;",
"if (msix_enabled(VAR_0->owner)) {",
"return;",
"}",
"for (VAR_3 = 0; VAR_3 < E1000E_MSIX_VEC_NUM; VAR_3++) {",
"if (VAR_0->mac[PBACLR] & BIT(VAR_3)) {",
"msix_clr_pending(VAR_0->owner, VAR_3);",
"}",
"}",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
]
|
10,435 | void qemu_spice_vm_change_state_handler(void *opaque, int running, int reason)
{
SimpleSpiceDisplay *ssd = opaque;
if (running) {
ssd->worker->start(ssd->worker);
} else {
qemu_mutex_unlock_iothread();
ssd->worker->stop(ssd->worker);
qemu_mutex_lock_iothread();
}
ssd->running = running;
}
| true | qemu | 196a778428989217b82de042725dc8eb29c8f8d8 | void qemu_spice_vm_change_state_handler(void *opaque, int running, int reason)
{
SimpleSpiceDisplay *ssd = opaque;
if (running) {
ssd->worker->start(ssd->worker);
} else {
qemu_mutex_unlock_iothread();
ssd->worker->stop(ssd->worker);
qemu_mutex_lock_iothread();
}
ssd->running = running;
}
| {
"code": [
" qemu_mutex_unlock_iothread();",
" qemu_mutex_lock_iothread();",
" qemu_mutex_unlock_iothread();",
" qemu_mutex_lock_iothread();"
],
"line_no": [
15,
19,
15,
19
]
} | void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)
{
SimpleSpiceDisplay *ssd = VAR_0;
if (VAR_1) {
ssd->worker->start(ssd->worker);
} else {
qemu_mutex_unlock_iothread();
ssd->worker->stop(ssd->worker);
qemu_mutex_lock_iothread();
}
ssd->VAR_1 = VAR_1;
}
| [
"void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)\n{",
"SimpleSpiceDisplay *ssd = VAR_0;",
"if (VAR_1) {",
"ssd->worker->start(ssd->worker);",
"} else {",
"qemu_mutex_unlock_iothread();",
"ssd->worker->stop(ssd->worker);",
"qemu_mutex_lock_iothread();",
"}",
"ssd->VAR_1 = VAR_1;",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
10,436 | static void do_audio_out(AVFormatContext *s,
AVOutputStream *ost,
AVInputStream *ist,
unsigned char *buf, int size)
{
uint8_t *buftmp;
uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE]; /* XXX: allocate it */
uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE]; /* XXX: allocate it - yep really WMA */
int size_out, frame_bytes, ret;
AVCodecContext *enc;
enc = &ost->st->codec;
if (ost->audio_resample) {
buftmp = audio_buf;
size_out = audio_resample(ost->resample,
(short *)buftmp, (short *)buf,
size / (ist->st->codec.channels * 2));
size_out = size_out * enc->channels * 2;
} else {
buftmp = buf;
size_out = size;
}
/* now encode as many frames as possible */
if (enc->frame_size > 1) {
/* output resampled raw samples */
fifo_write(&ost->fifo, buftmp, size_out,
&ost->fifo.wptr);
frame_bytes = enc->frame_size * 2 * enc->channels;
while (fifo_read(&ost->fifo, audio_buf, frame_bytes,
&ost->fifo.rptr) == 0) {
ret = avcodec_encode_audio(enc, audio_out, sizeof(audio_out),
(short *)audio_buf);
av_write_frame(s, ost->index, audio_out, ret);
}
} else {
/* output a pcm frame */
/* XXX: change encoding codec API to avoid this ? */
switch(enc->codec->id) {
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_U16BE:
break;
default:
size_out = size_out >> 1;
break;
}
ret = avcodec_encode_audio(enc, audio_out, size_out,
(short *)buftmp);
av_write_frame(s, ost->index, audio_out, ret);
}
}
| true | FFmpeg | d66c7abc937069d57fb156bcecec16e406b88c7b | static void do_audio_out(AVFormatContext *s,
AVOutputStream *ost,
AVInputStream *ist,
unsigned char *buf, int size)
{
uint8_t *buftmp;
uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE];
uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE];
int size_out, frame_bytes, ret;
AVCodecContext *enc;
enc = &ost->st->codec;
if (ost->audio_resample) {
buftmp = audio_buf;
size_out = audio_resample(ost->resample,
(short *)buftmp, (short *)buf,
size / (ist->st->codec.channels * 2));
size_out = size_out * enc->channels * 2;
} else {
buftmp = buf;
size_out = size;
}
if (enc->frame_size > 1) {
fifo_write(&ost->fifo, buftmp, size_out,
&ost->fifo.wptr);
frame_bytes = enc->frame_size * 2 * enc->channels;
while (fifo_read(&ost->fifo, audio_buf, frame_bytes,
&ost->fifo.rptr) == 0) {
ret = avcodec_encode_audio(enc, audio_out, sizeof(audio_out),
(short *)audio_buf);
av_write_frame(s, ost->index, audio_out, ret);
}
} else {
switch(enc->codec->id) {
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_U16BE:
break;
default:
size_out = size_out >> 1;
break;
}
ret = avcodec_encode_audio(enc, audio_out, size_out,
(short *)buftmp);
av_write_frame(s, ost->index, audio_out, ret);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0,
AVOutputStream *VAR_1,
AVInputStream *VAR_2,
unsigned char *VAR_3, int VAR_4)
{
uint8_t *buftmp;
uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE];
uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE];
int VAR_5, VAR_6, VAR_7;
AVCodecContext *enc;
enc = &VAR_1->st->codec;
if (VAR_1->audio_resample) {
buftmp = audio_buf;
VAR_5 = audio_resample(VAR_1->resample,
(short *)buftmp, (short *)VAR_3,
VAR_4 / (VAR_2->st->codec.channels * 2));
VAR_5 = VAR_5 * enc->channels * 2;
} else {
buftmp = VAR_3;
VAR_5 = VAR_4;
}
if (enc->frame_size > 1) {
fifo_write(&VAR_1->fifo, buftmp, VAR_5,
&VAR_1->fifo.wptr);
VAR_6 = enc->frame_size * 2 * enc->channels;
while (fifo_read(&VAR_1->fifo, audio_buf, VAR_6,
&VAR_1->fifo.rptr) == 0) {
VAR_7 = avcodec_encode_audio(enc, audio_out, sizeof(audio_out),
(short *)audio_buf);
av_write_frame(VAR_0, VAR_1->index, audio_out, VAR_7);
}
} else {
switch(enc->codec->id) {
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_U16BE:
break;
default:
VAR_5 = VAR_5 >> 1;
break;
}
VAR_7 = avcodec_encode_audio(enc, audio_out, VAR_5,
(short *)buftmp);
av_write_frame(VAR_0, VAR_1->index, audio_out, VAR_7);
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0,\nAVOutputStream *VAR_1,\nAVInputStream *VAR_2,\nunsigned char *VAR_3, int VAR_4)\n{",
"uint8_t *buftmp;",
"uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE];",
"uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE];",
"int VAR_5, VAR_6, VAR_7;",
"AVCodecContext *enc;",
"enc = &VAR_1->st->codec;",
"if (VAR_1->audio_resample) {",
"buftmp = audio_buf;",
"VAR_5 = audio_resample(VAR_1->resample,\n(short *)buftmp, (short *)VAR_3,\nVAR_4 / (VAR_2->st->codec.channels * 2));",
"VAR_5 = VAR_5 * enc->channels * 2;",
"} else {",
"buftmp = VAR_3;",
"VAR_5 = VAR_4;",
"}",
"if (enc->frame_size > 1) {",
"fifo_write(&VAR_1->fifo, buftmp, VAR_5,\n&VAR_1->fifo.wptr);",
"VAR_6 = enc->frame_size * 2 * enc->channels;",
"while (fifo_read(&VAR_1->fifo, audio_buf, VAR_6,\n&VAR_1->fifo.rptr) == 0) {",
"VAR_7 = avcodec_encode_audio(enc, audio_out, sizeof(audio_out),\n(short *)audio_buf);",
"av_write_frame(VAR_0, VAR_1->index, audio_out, VAR_7);",
"}",
"} else {",
"switch(enc->codec->id) {",
"case CODEC_ID_PCM_S16LE:\ncase CODEC_ID_PCM_S16BE:\ncase CODEC_ID_PCM_U16LE:\ncase CODEC_ID_PCM_U16BE:\nbreak;",
"default:\nVAR_5 = VAR_5 >> 1;",
"break;",
"}",
"VAR_7 = avcodec_encode_audio(enc, audio_out, VAR_5,\n(short *)buftmp);",
"av_write_frame(VAR_0, VAR_1->index, audio_out, 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,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31,
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
51
],
[
55,
57
],
[
61
],
[
65,
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
83
],
[
85,
87,
89,
91,
93
],
[
95,
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
]
]
|
10,437 | static int ehci_state_waitlisthead(EHCIState *ehci, int async)
{
EHCIqh qh;
int i = 0;
int again = 0;
uint32_t entry = ehci->asynclistaddr;
/* set reclamation flag at start event (4.8.6) */
if (async) {
ehci_set_usbsts(ehci, USBSTS_REC);
}
ehci_queues_rip_unused(ehci, async);
/* Find the head of the list (4.9.1.1) */
for(i = 0; i < MAX_QH; i++) {
get_dwords(ehci, NLPTR_GET(entry), (uint32_t *) &qh,
sizeof(EHCIqh) >> 2);
ehci_trace_qh(NULL, NLPTR_GET(entry), &qh);
if (qh.epchar & QH_EPCHAR_H) {
if (async) {
entry |= (NLPTR_TYPE_QH << 1);
}
ehci_set_fetch_addr(ehci, async, entry);
ehci_set_state(ehci, async, EST_FETCHENTRY);
again = 1;
goto out;
}
entry = qh.next;
if (entry == ehci->asynclistaddr) {
break;
}
}
/* no head found for list. */
ehci_set_state(ehci, async, EST_ACTIVE);
out:
return again;
}
| true | qemu | 4be23939ab0d7019c7e59a37485b416fbbf0f073 | static int ehci_state_waitlisthead(EHCIState *ehci, int async)
{
EHCIqh qh;
int i = 0;
int again = 0;
uint32_t entry = ehci->asynclistaddr;
if (async) {
ehci_set_usbsts(ehci, USBSTS_REC);
}
ehci_queues_rip_unused(ehci, async);
for(i = 0; i < MAX_QH; i++) {
get_dwords(ehci, NLPTR_GET(entry), (uint32_t *) &qh,
sizeof(EHCIqh) >> 2);
ehci_trace_qh(NULL, NLPTR_GET(entry), &qh);
if (qh.epchar & QH_EPCHAR_H) {
if (async) {
entry |= (NLPTR_TYPE_QH << 1);
}
ehci_set_fetch_addr(ehci, async, entry);
ehci_set_state(ehci, async, EST_FETCHENTRY);
again = 1;
goto out;
}
entry = qh.next;
if (entry == ehci->asynclistaddr) {
break;
}
}
ehci_set_state(ehci, async, EST_ACTIVE);
out:
return again;
}
| {
"code": [
" ehci_queues_rip_unused(ehci, async);",
" break;"
],
"line_no": [
25,
67
]
} | static int FUNC_0(EHCIState *VAR_0, int VAR_1)
{
EHCIqh qh;
int VAR_2 = 0;
int VAR_3 = 0;
uint32_t entry = VAR_0->asynclistaddr;
if (VAR_1) {
ehci_set_usbsts(VAR_0, USBSTS_REC);
}
ehci_queues_rip_unused(VAR_0, VAR_1);
for(VAR_2 = 0; VAR_2 < MAX_QH; VAR_2++) {
get_dwords(VAR_0, NLPTR_GET(entry), (uint32_t *) &qh,
sizeof(EHCIqh) >> 2);
ehci_trace_qh(NULL, NLPTR_GET(entry), &qh);
if (qh.epchar & QH_EPCHAR_H) {
if (VAR_1) {
entry |= (NLPTR_TYPE_QH << 1);
}
ehci_set_fetch_addr(VAR_0, VAR_1, entry);
ehci_set_state(VAR_0, VAR_1, EST_FETCHENTRY);
VAR_3 = 1;
goto out;
}
entry = qh.next;
if (entry == VAR_0->asynclistaddr) {
break;
}
}
ehci_set_state(VAR_0, VAR_1, EST_ACTIVE);
out:
return VAR_3;
}
| [
"static int FUNC_0(EHCIState *VAR_0, int VAR_1)\n{",
"EHCIqh qh;",
"int VAR_2 = 0;",
"int VAR_3 = 0;",
"uint32_t entry = VAR_0->asynclistaddr;",
"if (VAR_1) {",
"ehci_set_usbsts(VAR_0, USBSTS_REC);",
"}",
"ehci_queues_rip_unused(VAR_0, VAR_1);",
"for(VAR_2 = 0; VAR_2 < MAX_QH; VAR_2++) {",
"get_dwords(VAR_0, NLPTR_GET(entry), (uint32_t *) &qh,\nsizeof(EHCIqh) >> 2);",
"ehci_trace_qh(NULL, NLPTR_GET(entry), &qh);",
"if (qh.epchar & QH_EPCHAR_H) {",
"if (VAR_1) {",
"entry |= (NLPTR_TYPE_QH << 1);",
"}",
"ehci_set_fetch_addr(VAR_0, VAR_1, entry);",
"ehci_set_state(VAR_0, VAR_1, EST_FETCHENTRY);",
"VAR_3 = 1;",
"goto out;",
"}",
"entry = qh.next;",
"if (entry == VAR_0->asynclistaddr) {",
"break;",
"}",
"}",
"ehci_set_state(VAR_0, VAR_1, EST_ACTIVE);",
"out:\nreturn VAR_3;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
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
],
[
17
],
[
19
],
[
21
],
[
25
],
[
31
],
[
33,
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
79
],
[
83,
85
],
[
87
]
]
|
10,438 | static void aux_bus_map_device(AUXBus *bus, AUXSlave *dev, hwaddr addr)
{
memory_region_add_subregion(bus->aux_io, addr, dev->mmio);
}
| true | qemu | e0dadc1e9ef1f35208e5d2af9c7740c18a0b769f | static void aux_bus_map_device(AUXBus *bus, AUXSlave *dev, hwaddr addr)
{
memory_region_add_subregion(bus->aux_io, addr, dev->mmio);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AUXBus *VAR_0, AUXSlave *VAR_1, hwaddr VAR_2)
{
memory_region_add_subregion(VAR_0->aux_io, VAR_2, VAR_1->mmio);
}
| [
"static void FUNC_0(AUXBus *VAR_0, AUXSlave *VAR_1, hwaddr VAR_2)\n{",
"memory_region_add_subregion(VAR_0->aux_io, VAR_2, VAR_1->mmio);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
10,440 | static int verify_md5(HEVCContext *s, AVFrame *frame)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
int pixel_shift = desc->comp[0].depth_minus1 > 7;
int i, j;
if (!desc)
return AVERROR(EINVAL);
av_log(s->avctx, AV_LOG_DEBUG, "Verifying checksum for frame with POC %d: ",
s->poc);
/* the checksums are LE, so we have to byteswap for >8bpp formats
* on BE arches */
#if HAVE_BIGENDIAN
if (pixel_shift && !s->checksum_buf) {
av_fast_malloc(&s->checksum_buf, &s->checksum_buf_size,
FFMAX3(frame->linesize[0], frame->linesize[1],
frame->linesize[2]));
if (!s->checksum_buf)
return AVERROR(ENOMEM);
}
#endif
for (i = 0; frame->data[i]; i++) {
int width = s->avctx->coded_width;
int height = s->avctx->coded_height;
int w = (i == 1 || i == 2) ? (width >> desc->log2_chroma_w) : width;
int h = (i == 1 || i == 2) ? (height >> desc->log2_chroma_h) : height;
uint8_t md5[16];
av_md5_init(s->md5_ctx);
for (j = 0; j < h; j++) {
const uint8_t *src = frame->data[i] + j * frame->linesize[i];
#if HAVE_BIGENDIAN
if (pixel_shift) {
s->dsp.bswap16_buf((uint16_t*)s->checksum_buf,
(const uint16_t*)src, w);
src = s->checksum_buf;
}
#endif
av_md5_update(s->md5_ctx, src, w << pixel_shift);
}
av_md5_final(s->md5_ctx, md5);
if (!memcmp(md5, s->md5[i], 16)) {
av_log (s->avctx, AV_LOG_DEBUG, "plane %d - correct ", i);
print_md5(s->avctx, AV_LOG_DEBUG, md5);
av_log (s->avctx, AV_LOG_DEBUG, "; ");
} else {
av_log (s->avctx, AV_LOG_ERROR, "mismatching checksum of plane %d - ", i);
print_md5(s->avctx, AV_LOG_ERROR, md5);
av_log (s->avctx, AV_LOG_ERROR, " != ");
print_md5(s->avctx, AV_LOG_ERROR, s->md5[i]);
av_log (s->avctx, AV_LOG_ERROR, "\n");
return AVERROR_INVALIDDATA;
}
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
return 0;
}
| true | FFmpeg | b769cf4b44c8112827c2fdfcab74bd95600fd6d3 | static int verify_md5(HEVCContext *s, AVFrame *frame)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
int pixel_shift = desc->comp[0].depth_minus1 > 7;
int i, j;
if (!desc)
return AVERROR(EINVAL);
av_log(s->avctx, AV_LOG_DEBUG, "Verifying checksum for frame with POC %d: ",
s->poc);
#if HAVE_BIGENDIAN
if (pixel_shift && !s->checksum_buf) {
av_fast_malloc(&s->checksum_buf, &s->checksum_buf_size,
FFMAX3(frame->linesize[0], frame->linesize[1],
frame->linesize[2]));
if (!s->checksum_buf)
return AVERROR(ENOMEM);
}
#endif
for (i = 0; frame->data[i]; i++) {
int width = s->avctx->coded_width;
int height = s->avctx->coded_height;
int w = (i == 1 || i == 2) ? (width >> desc->log2_chroma_w) : width;
int h = (i == 1 || i == 2) ? (height >> desc->log2_chroma_h) : height;
uint8_t md5[16];
av_md5_init(s->md5_ctx);
for (j = 0; j < h; j++) {
const uint8_t *src = frame->data[i] + j * frame->linesize[i];
#if HAVE_BIGENDIAN
if (pixel_shift) {
s->dsp.bswap16_buf((uint16_t*)s->checksum_buf,
(const uint16_t*)src, w);
src = s->checksum_buf;
}
#endif
av_md5_update(s->md5_ctx, src, w << pixel_shift);
}
av_md5_final(s->md5_ctx, md5);
if (!memcmp(md5, s->md5[i], 16)) {
av_log (s->avctx, AV_LOG_DEBUG, "plane %d - correct ", i);
print_md5(s->avctx, AV_LOG_DEBUG, md5);
av_log (s->avctx, AV_LOG_DEBUG, "; ");
} else {
av_log (s->avctx, AV_LOG_ERROR, "mismatching checksum of plane %d - ", i);
print_md5(s->avctx, AV_LOG_ERROR, md5);
av_log (s->avctx, AV_LOG_ERROR, " != ");
print_md5(s->avctx, AV_LOG_ERROR, s->md5[i]);
av_log (s->avctx, AV_LOG_ERROR, "\n");
return AVERROR_INVALIDDATA;
}
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
return 0;
}
| {
"code": [
" int pixel_shift = desc->comp[0].depth_minus1 > 7;"
],
"line_no": [
7
]
} | static int FUNC_0(HEVCContext *VAR_0, AVFrame *VAR_1)
{
const AVPixFmtDescriptor *VAR_2 = av_pix_fmt_desc_get(VAR_1->format);
int VAR_3 = VAR_2->comp[0].depth_minus1 > 7;
int VAR_4, VAR_5;
if (!VAR_2)
return AVERROR(EINVAL);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Verifying checksum for VAR_1 with POC %d: ",
VAR_0->poc);
#if HAVE_BIGENDIAN
if (VAR_3 && !VAR_0->checksum_buf) {
av_fast_malloc(&VAR_0->checksum_buf, &VAR_0->checksum_buf_size,
FFMAX3(VAR_1->linesize[0], VAR_1->linesize[1],
VAR_1->linesize[2]));
if (!VAR_0->checksum_buf)
return AVERROR(ENOMEM);
}
#endif
for (VAR_4 = 0; VAR_1->data[VAR_4]; VAR_4++) {
int width = VAR_0->avctx->coded_width;
int height = VAR_0->avctx->coded_height;
int w = (VAR_4 == 1 || VAR_4 == 2) ? (width >> VAR_2->log2_chroma_w) : width;
int h = (VAR_4 == 1 || VAR_4 == 2) ? (height >> VAR_2->log2_chroma_h) : height;
uint8_t md5[16];
av_md5_init(VAR_0->md5_ctx);
for (VAR_5 = 0; VAR_5 < h; VAR_5++) {
const uint8_t *src = VAR_1->data[VAR_4] + VAR_5 * VAR_1->linesize[VAR_4];
#if HAVE_BIGENDIAN
if (VAR_3) {
VAR_0->dsp.bswap16_buf((uint16_t*)VAR_0->checksum_buf,
(const uint16_t*)src, w);
src = VAR_0->checksum_buf;
}
#endif
av_md5_update(VAR_0->md5_ctx, src, w << VAR_3);
}
av_md5_final(VAR_0->md5_ctx, md5);
if (!memcmp(md5, VAR_0->md5[VAR_4], 16)) {
av_log (VAR_0->avctx, AV_LOG_DEBUG, "plane %d - correct ", VAR_4);
print_md5(VAR_0->avctx, AV_LOG_DEBUG, md5);
av_log (VAR_0->avctx, AV_LOG_DEBUG, "; ");
} else {
av_log (VAR_0->avctx, AV_LOG_ERROR, "mismatching checksum of plane %d - ", VAR_4);
print_md5(VAR_0->avctx, AV_LOG_ERROR, md5);
av_log (VAR_0->avctx, AV_LOG_ERROR, " != ");
print_md5(VAR_0->avctx, AV_LOG_ERROR, VAR_0->md5[VAR_4]);
av_log (VAR_0->avctx, AV_LOG_ERROR, "\n");
return AVERROR_INVALIDDATA;
}
}
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
return 0;
}
| [
"static int FUNC_0(HEVCContext *VAR_0, AVFrame *VAR_1)\n{",
"const AVPixFmtDescriptor *VAR_2 = av_pix_fmt_desc_get(VAR_1->format);",
"int VAR_3 = VAR_2->comp[0].depth_minus1 > 7;",
"int VAR_4, VAR_5;",
"if (!VAR_2)\nreturn AVERROR(EINVAL);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Verifying checksum for VAR_1 with POC %d: \",\nVAR_0->poc);",
"#if HAVE_BIGENDIAN\nif (VAR_3 && !VAR_0->checksum_buf) {",
"av_fast_malloc(&VAR_0->checksum_buf, &VAR_0->checksum_buf_size,\nFFMAX3(VAR_1->linesize[0], VAR_1->linesize[1],\nVAR_1->linesize[2]));",
"if (!VAR_0->checksum_buf)\nreturn AVERROR(ENOMEM);",
"}",
"#endif\nfor (VAR_4 = 0; VAR_1->data[VAR_4]; VAR_4++) {",
"int width = VAR_0->avctx->coded_width;",
"int height = VAR_0->avctx->coded_height;",
"int w = (VAR_4 == 1 || VAR_4 == 2) ? (width >> VAR_2->log2_chroma_w) : width;",
"int h = (VAR_4 == 1 || VAR_4 == 2) ? (height >> VAR_2->log2_chroma_h) : height;",
"uint8_t md5[16];",
"av_md5_init(VAR_0->md5_ctx);",
"for (VAR_5 = 0; VAR_5 < h; VAR_5++) {",
"const uint8_t *src = VAR_1->data[VAR_4] + VAR_5 * VAR_1->linesize[VAR_4];",
"#if HAVE_BIGENDIAN\nif (VAR_3) {",
"VAR_0->dsp.bswap16_buf((uint16_t*)VAR_0->checksum_buf,\n(const uint16_t*)src, w);",
"src = VAR_0->checksum_buf;",
"}",
"#endif\nav_md5_update(VAR_0->md5_ctx, src, w << VAR_3);",
"}",
"av_md5_final(VAR_0->md5_ctx, md5);",
"if (!memcmp(md5, VAR_0->md5[VAR_4], 16)) {",
"av_log (VAR_0->avctx, AV_LOG_DEBUG, \"plane %d - correct \", VAR_4);",
"print_md5(VAR_0->avctx, AV_LOG_DEBUG, md5);",
"av_log (VAR_0->avctx, AV_LOG_DEBUG, \"; \");",
"} else {",
"av_log (VAR_0->avctx, AV_LOG_ERROR, \"mismatching checksum of plane %d - \", VAR_4);",
"print_md5(VAR_0->avctx, AV_LOG_ERROR, md5);",
"av_log (VAR_0->avctx, AV_LOG_ERROR, \" != \");",
"print_md5(VAR_0->avctx, AV_LOG_ERROR, VAR_0->md5[VAR_4]);",
"av_log (VAR_0->avctx, AV_LOG_ERROR, \"\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"return 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19,
21
],
[
29,
31
],
[
33,
35,
37
],
[
39,
41
],
[
43
],
[
45,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
123
],
[
125
]
]
|
10,441 | static int dxva2_vc1_start_frame(AVCodecContext *avctx,
av_unused const uint8_t *buffer,
av_unused uint32_t size)
{
const VC1Context *v = avctx->priv_data;
AVDXVAContext *ctx = avctx->hwaccel_context;
struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;
if (!DXVA_CONTEXT_VALID(avctx, ctx))
return -1;
assert(ctx_pic);
fill_picture_parameters(avctx, ctx, v, &ctx_pic->pp);
ctx_pic->bitstream_size = 0;
ctx_pic->bitstream = NULL;
return 0;
}
| false | FFmpeg | 4dec101acc393fbfe9a8ce0237b9efbae3f20139 | static int dxva2_vc1_start_frame(AVCodecContext *avctx,
av_unused const uint8_t *buffer,
av_unused uint32_t size)
{
const VC1Context *v = avctx->priv_data;
AVDXVAContext *ctx = avctx->hwaccel_context;
struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;
if (!DXVA_CONTEXT_VALID(avctx, ctx))
return -1;
assert(ctx_pic);
fill_picture_parameters(avctx, ctx, v, &ctx_pic->pp);
ctx_pic->bitstream_size = 0;
ctx_pic->bitstream = NULL;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
av_unused const VAR_1 *buffer,
av_unused uint32_t size)
{
const VC1Context *VAR_2 = VAR_0->priv_data;
AVDXVAContext *ctx = VAR_0->hwaccel_context;
struct dxva2_picture_context *VAR_3 = VAR_2->s.current_picture_ptr->hwaccel_picture_private;
if (!DXVA_CONTEXT_VALID(VAR_0, ctx))
return -1;
assert(VAR_3);
fill_picture_parameters(VAR_0, ctx, VAR_2, &VAR_3->pp);
VAR_3->bitstream_size = 0;
VAR_3->bitstream = NULL;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nav_unused const VAR_1 *buffer,\nav_unused uint32_t size)\n{",
"const VC1Context *VAR_2 = VAR_0->priv_data;",
"AVDXVAContext *ctx = VAR_0->hwaccel_context;",
"struct dxva2_picture_context *VAR_3 = VAR_2->s.current_picture_ptr->hwaccel_picture_private;",
"if (!DXVA_CONTEXT_VALID(VAR_0, ctx))\nreturn -1;",
"assert(VAR_3);",
"fill_picture_parameters(VAR_0, ctx, VAR_2, &VAR_3->pp);",
"VAR_3->bitstream_size = 0;",
"VAR_3->bitstream = NULL;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
]
]
|
10,442 | static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx, AVBitStreamFilterContext *bsfc){
while(bsfc){
AVPacket new_pkt= *pkt;
int a= av_bitstream_filter_filter(bsfc, avctx, NULL,
&new_pkt.data, &new_pkt.size,
pkt->data, pkt->size,
pkt->flags & PKT_FLAG_KEY);
if(a){
av_free_packet(pkt);
new_pkt.destruct= av_destruct_packet;
}
*pkt= new_pkt;
bsfc= bsfc->next;
}
av_interleaved_write_frame(s, pkt);
}
| false | FFmpeg | 0ac0703107c12bc78ea2853877a38a2a7384789a | static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx, AVBitStreamFilterContext *bsfc){
while(bsfc){
AVPacket new_pkt= *pkt;
int a= av_bitstream_filter_filter(bsfc, avctx, NULL,
&new_pkt.data, &new_pkt.size,
pkt->data, pkt->size,
pkt->flags & PKT_FLAG_KEY);
if(a){
av_free_packet(pkt);
new_pkt.destruct= av_destruct_packet;
}
*pkt= new_pkt;
bsfc= bsfc->next;
}
av_interleaved_write_frame(s, pkt);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, AVCodecContext *VAR_2, AVBitStreamFilterContext *VAR_3){
while(VAR_3){
AVPacket new_pkt= *VAR_1;
int VAR_4= av_bitstream_filter_filter(VAR_3, VAR_2, NULL,
&new_pkt.data, &new_pkt.size,
VAR_1->data, VAR_1->size,
VAR_1->flags & PKT_FLAG_KEY);
if(VAR_4){
av_free_packet(VAR_1);
new_pkt.destruct= av_destruct_packet;
}
*VAR_1= new_pkt;
VAR_3= VAR_3->next;
}
av_interleaved_write_frame(VAR_0, VAR_1);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, AVCodecContext *VAR_2, AVBitStreamFilterContext *VAR_3){",
"while(VAR_3){",
"AVPacket new_pkt= *VAR_1;",
"int VAR_4= av_bitstream_filter_filter(VAR_3, VAR_2, NULL,\n&new_pkt.data, &new_pkt.size,\nVAR_1->data, VAR_1->size,\nVAR_1->flags & PKT_FLAG_KEY);",
"if(VAR_4){",
"av_free_packet(VAR_1);",
"new_pkt.destruct= av_destruct_packet;",
"}",
"*VAR_1= new_pkt;",
"VAR_3= VAR_3->next;",
"}",
"av_interleaved_write_frame(VAR_0, VAR_1);",
"}"
]
| [
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
],
[
27
],
[
29
],
[
33
],
[
35
]
]
|
10,443 | static inline void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int *tc0)
{
int i, d;
for( i = 0; i < 4; i++ ) {
if( tc0[i] < 0 ) {
pix += 4*ystride;
continue;
}
for( d = 0; d < 4; d++ ) {
const int p0 = pix[-1*xstride];
const int p1 = pix[-2*xstride];
const int p2 = pix[-3*xstride];
const int q0 = pix[0];
const int q1 = pix[1*xstride];
const int q2 = pix[2*xstride];
if( ABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) {
int tc = tc0[i];
int i_delta;
if( ABS( p2 - p0 ) < beta ) {
pix[-2*xstride] = p1 + clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0[i], tc0[i] );
tc++;
}
if( ABS( q2 - q0 ) < beta ) {
pix[xstride] = q1 + clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0[i], tc0[i] );
tc++;
}
i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
pix[-xstride] = clip_uint8( p0 + i_delta ); /* p0' */
pix[0] = clip_uint8( q0 - i_delta ); /* q0' */
}
pix += ystride;
}
}
}
| false | FFmpeg | bda1c56c474c137957c261dcf9df4fd3232a8b43 | static inline void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int *tc0)
{
int i, d;
for( i = 0; i < 4; i++ ) {
if( tc0[i] < 0 ) {
pix += 4*ystride;
continue;
}
for( d = 0; d < 4; d++ ) {
const int p0 = pix[-1*xstride];
const int p1 = pix[-2*xstride];
const int p2 = pix[-3*xstride];
const int q0 = pix[0];
const int q1 = pix[1*xstride];
const int q2 = pix[2*xstride];
if( ABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) {
int tc = tc0[i];
int i_delta;
if( ABS( p2 - p0 ) < beta ) {
pix[-2*xstride] = p1 + clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0[i], tc0[i] );
tc++;
}
if( ABS( q2 - q0 ) < beta ) {
pix[xstride] = q1 + clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0[i], tc0[i] );
tc++;
}
i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
pix[-xstride] = clip_uint8( p0 + i_delta );
pix[0] = clip_uint8( q0 - i_delta );
}
pix += ystride;
}
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4, int *VAR_5)
{
int VAR_6, VAR_7;
for( VAR_6 = 0; VAR_6 < 4; VAR_6++ ) {
if( VAR_5[VAR_6] < 0 ) {
VAR_0 += 4*VAR_2;
continue;
}
for( VAR_7 = 0; VAR_7 < 4; VAR_7++ ) {
const int VAR_8 = VAR_0[-1*VAR_1];
const int VAR_9 = VAR_0[-2*VAR_1];
const int VAR_10 = VAR_0[-3*VAR_1];
const int VAR_11 = VAR_0[0];
const int VAR_12 = VAR_0[1*VAR_1];
const int VAR_13 = VAR_0[2*VAR_1];
if( ABS( VAR_8 - VAR_11 ) < VAR_3 &&
ABS( VAR_9 - VAR_8 ) < VAR_4 &&
ABS( VAR_12 - VAR_11 ) < VAR_4 ) {
int VAR_14 = VAR_5[VAR_6];
int VAR_15;
if( ABS( VAR_10 - VAR_8 ) < VAR_4 ) {
VAR_0[-2*VAR_1] = VAR_9 + clip( ( VAR_10 + ( ( VAR_8 + VAR_11 + 1 ) >> 1 ) - ( VAR_9 << 1 ) ) >> 1, -VAR_5[VAR_6], VAR_5[VAR_6] );
VAR_14++;
}
if( ABS( VAR_13 - VAR_11 ) < VAR_4 ) {
VAR_0[VAR_1] = VAR_12 + clip( ( VAR_13 + ( ( VAR_8 + VAR_11 + 1 ) >> 1 ) - ( VAR_12 << 1 ) ) >> 1, -VAR_5[VAR_6], VAR_5[VAR_6] );
VAR_14++;
}
VAR_15 = clip( (((VAR_11 - VAR_8 ) << 2) + (VAR_9 - VAR_12) + 4) >> 3, -VAR_14, VAR_14 );
VAR_0[-VAR_1] = clip_uint8( VAR_8 + VAR_15 );
VAR_0[0] = clip_uint8( VAR_11 - VAR_15 );
}
VAR_0 += VAR_2;
}
}
}
| [
"static inline void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4, int *VAR_5)\n{",
"int VAR_6, VAR_7;",
"for( VAR_6 = 0; VAR_6 < 4; VAR_6++ ) {",
"if( VAR_5[VAR_6] < 0 ) {",
"VAR_0 += 4*VAR_2;",
"continue;",
"}",
"for( VAR_7 = 0; VAR_7 < 4; VAR_7++ ) {",
"const int VAR_8 = VAR_0[-1*VAR_1];",
"const int VAR_9 = VAR_0[-2*VAR_1];",
"const int VAR_10 = VAR_0[-3*VAR_1];",
"const int VAR_11 = VAR_0[0];",
"const int VAR_12 = VAR_0[1*VAR_1];",
"const int VAR_13 = VAR_0[2*VAR_1];",
"if( ABS( VAR_8 - VAR_11 ) < VAR_3 &&\nABS( VAR_9 - VAR_8 ) < VAR_4 &&\nABS( VAR_12 - VAR_11 ) < VAR_4 ) {",
"int VAR_14 = VAR_5[VAR_6];",
"int VAR_15;",
"if( ABS( VAR_10 - VAR_8 ) < VAR_4 ) {",
"VAR_0[-2*VAR_1] = VAR_9 + clip( ( VAR_10 + ( ( VAR_8 + VAR_11 + 1 ) >> 1 ) - ( VAR_9 << 1 ) ) >> 1, -VAR_5[VAR_6], VAR_5[VAR_6] );",
"VAR_14++;",
"}",
"if( ABS( VAR_13 - VAR_11 ) < VAR_4 ) {",
"VAR_0[VAR_1] = VAR_12 + clip( ( VAR_13 + ( ( VAR_8 + VAR_11 + 1 ) >> 1 ) - ( VAR_12 << 1 ) ) >> 1, -VAR_5[VAR_6], VAR_5[VAR_6] );",
"VAR_14++;",
"}",
"VAR_15 = clip( (((VAR_11 - VAR_8 ) << 2) + (VAR_9 - VAR_12) + 4) >> 3, -VAR_14, VAR_14 );",
"VAR_0[-VAR_1] = clip_uint8( VAR_8 + VAR_15 );",
"VAR_0[0] = clip_uint8( VAR_11 - VAR_15 );",
"}",
"VAR_0 += 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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35,
37
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
]
]
|
10,444 | int64_t av_gettime_relative(void)
{
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
#else
return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);
#endif
}
| false | FFmpeg | 0e8b68a2c4031e25082603ad88711be12210d41f | int64_t av_gettime_relative(void)
{
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
#else
return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);
#endif
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(void)
{
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
#else
return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);
#endif
}
| [
"int64_t FUNC_0(void)\n{",
"#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)\nstruct timespec ts;",
"clock_gettime(CLOCK_MONOTONIC, &ts);",
"return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;",
"#else\nreturn av_gettime() + 42 * 60 * 60 * INT64_C(1000000);",
"#endif\n}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
13,
15
],
[
17,
19
]
]
|
10,445 | static void update_odml_entry(AVFormatContext *s, int stream_index, int64_t ix)
{
AVIOContext *pb = s->pb;
AVIContext *avi = s->priv_data;
AVIStream *avist = s->streams[stream_index]->priv_data;
int64_t pos;
int au_byterate, au_ssize, au_scale;
avio_flush(pb);
pos = avio_tell(pb);
/* Updating one entry in the AVI OpenDML master index */
avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
ffio_wfourcc(pb, "indx"); /* enabling this entry */
avio_skip(pb, 8);
avio_wl32(pb, avi->riff_id); /* nEntriesInUse */
avio_skip(pb, 16 * avi->riff_id);
avio_wl64(pb, ix); /* qwOffset */
avio_wl32(pb, pos - ix); /* dwSize */
ff_parse_specific_params(s->streams[stream_index], &au_byterate, &au_ssize, &au_scale);
if (s->streams[stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {
uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);
if ((audio_segm_size % au_ssize > 0) && !avist->sample_requested) {
avpriv_request_sample(s, "OpenDML index duration for audio packets with partial frames");
avist->sample_requested = 1;
}
avio_wl32(pb, audio_segm_size / au_ssize); /* dwDuration (sample count) */
} else
avio_wl32(pb, avist->indexes.entry); /* dwDuration (packet count) */
avio_seek(pb, pos, SEEK_SET);
}
| false | FFmpeg | bbcc09518e0d1efc189a43ff0120c1a31f51c802 | static void update_odml_entry(AVFormatContext *s, int stream_index, int64_t ix)
{
AVIOContext *pb = s->pb;
AVIContext *avi = s->priv_data;
AVIStream *avist = s->streams[stream_index]->priv_data;
int64_t pos;
int au_byterate, au_ssize, au_scale;
avio_flush(pb);
pos = avio_tell(pb);
avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
ffio_wfourcc(pb, "indx");
avio_skip(pb, 8);
avio_wl32(pb, avi->riff_id);
avio_skip(pb, 16 * avi->riff_id);
avio_wl64(pb, ix);
avio_wl32(pb, pos - ix);
ff_parse_specific_params(s->streams[stream_index], &au_byterate, &au_ssize, &au_scale);
if (s->streams[stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {
uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);
if ((audio_segm_size % au_ssize > 0) && !avist->sample_requested) {
avpriv_request_sample(s, "OpenDML index duration for audio packets with partial frames");
avist->sample_requested = 1;
}
avio_wl32(pb, audio_segm_size / au_ssize);
} else
avio_wl32(pb, avist->indexes.entry);
avio_seek(pb, pos, SEEK_SET);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2)
{
AVIOContext *pb = VAR_0->pb;
AVIContext *avi = VAR_0->priv_data;
AVIStream *avist = VAR_0->streams[VAR_1]->priv_data;
int64_t pos;
int VAR_3, VAR_4, VAR_5;
avio_flush(pb);
pos = avio_tell(pb);
avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
ffio_wfourcc(pb, "indx");
avio_skip(pb, 8);
avio_wl32(pb, avi->riff_id);
avio_skip(pb, 16 * avi->riff_id);
avio_wl64(pb, VAR_2);
avio_wl32(pb, pos - VAR_2);
ff_parse_specific_params(VAR_0->streams[VAR_1], &VAR_3, &VAR_4, &VAR_5);
if (VAR_0->streams[VAR_1]->codec->codec_type == AVMEDIA_TYPE_AUDIO && VAR_4 > 0) {
uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);
if ((audio_segm_size % VAR_4 > 0) && !avist->sample_requested) {
avpriv_request_sample(VAR_0, "OpenDML index duration for audio packets with partial frames");
avist->sample_requested = 1;
}
avio_wl32(pb, audio_segm_size / VAR_4);
} else
avio_wl32(pb, avist->indexes.entry);
avio_seek(pb, pos, SEEK_SET);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2)\n{",
"AVIOContext *pb = VAR_0->pb;",
"AVIContext *avi = VAR_0->priv_data;",
"AVIStream *avist = VAR_0->streams[VAR_1]->priv_data;",
"int64_t pos;",
"int VAR_3, VAR_4, VAR_5;",
"avio_flush(pb);",
"pos = avio_tell(pb);",
"avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);",
"ffio_wfourcc(pb, \"indx\");",
"avio_skip(pb, 8);",
"avio_wl32(pb, avi->riff_id);",
"avio_skip(pb, 16 * avi->riff_id);",
"avio_wl64(pb, VAR_2);",
"avio_wl32(pb, pos - VAR_2);",
"ff_parse_specific_params(VAR_0->streams[VAR_1], &VAR_3, &VAR_4, &VAR_5);",
"if (VAR_0->streams[VAR_1]->codec->codec_type == AVMEDIA_TYPE_AUDIO && VAR_4 > 0) {",
"uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);",
"if ((audio_segm_size % VAR_4 > 0) && !avist->sample_requested) {",
"avpriv_request_sample(VAR_0, \"OpenDML index duration for audio packets with partial frames\");",
"avist->sample_requested = 1;",
"}",
"avio_wl32(pb, audio_segm_size / VAR_4);",
"} else",
"avio_wl32(pb, avist->indexes.entry);",
"avio_seek(pb, pos, SEEK_SET);",
"}"
]
| [
0,
0,
0,
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
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
]
]
|
10,446 | av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
{
static int init_done=0;
int i;
ff_msmpeg4_common_init(s);
if(s->msmpeg4_version>=4){
s->min_qcoeff= -255;
s->max_qcoeff= 255;
}
if (!init_done) {
/* init various encoding tables */
init_done = 1;
init_mv_table(&ff_mv_tables[0]);
init_mv_table(&ff_mv_tables[1]);
for(i=0;i<NB_RL_TABLES;i++)
ff_init_rl(&ff_rl_table[i], ff_static_rl_table_store[i]);
for(i=0; i<NB_RL_TABLES; i++){
int level;
for (level = 1; level <= MAX_LEVEL; level++) {
int run;
for(run=0; run<=MAX_RUN; run++){
int last;
for(last=0; last<2; last++){
rl_length[i][level][run][last]= get_size_of_code(s, &ff_rl_table[ i], last, run, level, 0);
}
}
}
}
}
}
| false | FFmpeg | 1c6183233d56fb27a4a154e7e64ecab98bd877f1 | av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
{
static int init_done=0;
int i;
ff_msmpeg4_common_init(s);
if(s->msmpeg4_version>=4){
s->min_qcoeff= -255;
s->max_qcoeff= 255;
}
if (!init_done) {
init_done = 1;
init_mv_table(&ff_mv_tables[0]);
init_mv_table(&ff_mv_tables[1]);
for(i=0;i<NB_RL_TABLES;i++)
ff_init_rl(&ff_rl_table[i], ff_static_rl_table_store[i]);
for(i=0; i<NB_RL_TABLES; i++){
int level;
for (level = 1; level <= MAX_LEVEL; level++) {
int run;
for(run=0; run<=MAX_RUN; run++){
int last;
for(last=0; last<2; last++){
rl_length[i][level][run][last]= get_size_of_code(s, &ff_rl_table[ i], last, run, level, 0);
}
}
}
}
}
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(MpegEncContext *s)
{
static int VAR_0=0;
int VAR_1;
ff_msmpeg4_common_init(s);
if(s->msmpeg4_version>=4){
s->min_qcoeff= -255;
s->max_qcoeff= 255;
}
if (!VAR_0) {
VAR_0 = 1;
init_mv_table(&ff_mv_tables[0]);
init_mv_table(&ff_mv_tables[1]);
for(VAR_1=0;VAR_1<NB_RL_TABLES;VAR_1++)
ff_init_rl(&ff_rl_table[VAR_1], ff_static_rl_table_store[VAR_1]);
for(VAR_1=0; VAR_1<NB_RL_TABLES; VAR_1++){
int level;
for (level = 1; level <= MAX_LEVEL; level++) {
int run;
for(run=0; run<=MAX_RUN; run++){
int last;
for(last=0; last<2; last++){
rl_length[VAR_1][level][run][last]= get_size_of_code(s, &ff_rl_table[ VAR_1], last, run, level, 0);
}
}
}
}
}
}
| [
"av_cold void FUNC_0(MpegEncContext *s)\n{",
"static int VAR_0=0;",
"int VAR_1;",
"ff_msmpeg4_common_init(s);",
"if(s->msmpeg4_version>=4){",
"s->min_qcoeff= -255;",
"s->max_qcoeff= 255;",
"}",
"if (!VAR_0) {",
"VAR_0 = 1;",
"init_mv_table(&ff_mv_tables[0]);",
"init_mv_table(&ff_mv_tables[1]);",
"for(VAR_1=0;VAR_1<NB_RL_TABLES;VAR_1++)",
"ff_init_rl(&ff_rl_table[VAR_1], ff_static_rl_table_store[VAR_1]);",
"for(VAR_1=0; VAR_1<NB_RL_TABLES; VAR_1++){",
"int level;",
"for (level = 1; level <= MAX_LEVEL; level++) {",
"int run;",
"for(run=0; run<=MAX_RUN; run++){",
"int last;",
"for(last=0; last<2; last++){",
"rl_length[VAR_1][level][run][last]= get_size_of_code(s, &ff_rl_table[ VAR_1], last, run, 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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
]
|
10,447 | int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
{
if (*spec <= '9' && *spec >= '0') /* opt:index */
return strtol(spec, NULL, 0) == st->index;
else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
*spec == 't') { /* opt:[vasdt] */
enum AVMediaType type;
switch (*spec++) {
case 'v': type = AVMEDIA_TYPE_VIDEO; break;
case 'a': type = AVMEDIA_TYPE_AUDIO; break;
case 's': type = AVMEDIA_TYPE_SUBTITLE; break;
case 'd': type = AVMEDIA_TYPE_DATA; break;
case 't': type = AVMEDIA_TYPE_ATTACHMENT; break;
default: av_assert0(0);
}
if (type != st->codec->codec_type)
return 0;
if (*spec++ == ':') { /* possibly followed by :index */
int i, index = strtol(spec, NULL, 0);
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->codec->codec_type == type && index-- == 0)
return i == st->index;
return 0;
}
return 1;
} else if (*spec == 'p' && *(spec + 1) == ':') {
int prog_id, i, j;
char *endptr;
spec += 2;
prog_id = strtol(spec, &endptr, 0);
for (i = 0; i < s->nb_programs; i++) {
if (s->programs[i]->id != prog_id)
continue;
if (*endptr++ == ':') {
int stream_idx = strtol(endptr, NULL, 0);
return stream_idx >= 0 &&
stream_idx < s->programs[i]->nb_stream_indexes &&
st->index == s->programs[i]->stream_index[stream_idx];
}
for (j = 0; j < s->programs[i]->nb_stream_indexes; j++)
if (st->index == s->programs[i]->stream_index[j])
return 1;
}
return 0;
} else if (*spec == '#') {
int sid;
char *endptr;
sid = strtol(spec + 1, &endptr, 0);
if (!*endptr)
return st->id == sid;
} else if (!*spec) /* empty specifier, matches everything */
return 1;
av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec);
return AVERROR(EINVAL);
}
| false | FFmpeg | b0629366a26628f19245ea2c06a6e366cb70f92f | int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
{
if (*spec <= '9' && *spec >= '0')
return strtol(spec, NULL, 0) == st->index;
else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
*spec == 't') {
enum AVMediaType type;
switch (*spec++) {
case 'v': type = AVMEDIA_TYPE_VIDEO; break;
case 'a': type = AVMEDIA_TYPE_AUDIO; break;
case 's': type = AVMEDIA_TYPE_SUBTITLE; break;
case 'd': type = AVMEDIA_TYPE_DATA; break;
case 't': type = AVMEDIA_TYPE_ATTACHMENT; break;
default: av_assert0(0);
}
if (type != st->codec->codec_type)
return 0;
if (*spec++ == ':') {
int i, index = strtol(spec, NULL, 0);
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->codec->codec_type == type && index-- == 0)
return i == st->index;
return 0;
}
return 1;
} else if (*spec == 'p' && *(spec + 1) == ':') {
int prog_id, i, j;
char *endptr;
spec += 2;
prog_id = strtol(spec, &endptr, 0);
for (i = 0; i < s->nb_programs; i++) {
if (s->programs[i]->id != prog_id)
continue;
if (*endptr++ == ':') {
int stream_idx = strtol(endptr, NULL, 0);
return stream_idx >= 0 &&
stream_idx < s->programs[i]->nb_stream_indexes &&
st->index == s->programs[i]->stream_index[stream_idx];
}
for (j = 0; j < s->programs[i]->nb_stream_indexes; j++)
if (st->index == s->programs[i]->stream_index[j])
return 1;
}
return 0;
} else if (*spec == '#') {
int sid;
char *endptr;
sid = strtol(spec + 1, &endptr, 0);
if (!*endptr)
return st->id == sid;
} else if (!*spec)
return 1;
av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec);
return AVERROR(EINVAL);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, const char *VAR_2)
{
if (*VAR_2 <= '9' && *VAR_2 >= '0')
return strtol(VAR_2, NULL, 0) == VAR_1->VAR_5;
else if (*VAR_2 == 'v' || *VAR_2 == 'a' || *VAR_2 == 'VAR_0' || *VAR_2 == 'd' ||
*VAR_2 == 't') {
enum AVMediaType VAR_3;
switch (*VAR_2++) {
case 'v': VAR_3 = AVMEDIA_TYPE_VIDEO; break;
case 'a': VAR_3 = AVMEDIA_TYPE_AUDIO; break;
case 'VAR_0': VAR_3 = AVMEDIA_TYPE_SUBTITLE; break;
case 'd': VAR_3 = AVMEDIA_TYPE_DATA; break;
case 't': VAR_3 = AVMEDIA_TYPE_ATTACHMENT; break;
default: av_assert0(0);
}
if (VAR_3 != VAR_1->codec->codec_type)
return 0;
if (*VAR_2++ == ':') {
int VAR_7, VAR_5 = strtol(VAR_2, NULL, 0);
for (VAR_7 = 0; VAR_7 < VAR_0->nb_streams; VAR_7++)
if (VAR_0->streams[VAR_7]->codec->codec_type == VAR_3 && VAR_5-- == 0)
return VAR_7 == VAR_1->VAR_5;
return 0;
}
return 1;
} else if (*VAR_2 == 'p' && *(VAR_2 + 1) == ':') {
int VAR_6, VAR_7, VAR_7;
char *VAR_10;
VAR_2 += 2;
VAR_6 = strtol(VAR_2, &VAR_10, 0);
for (VAR_7 = 0; VAR_7 < VAR_0->nb_programs; VAR_7++) {
if (VAR_0->programs[VAR_7]->id != VAR_6)
continue;
if (*VAR_10++ == ':') {
int stream_idx = strtol(VAR_10, NULL, 0);
return stream_idx >= 0 &&
stream_idx < VAR_0->programs[VAR_7]->nb_stream_indexes &&
VAR_1->VAR_5 == VAR_0->programs[VAR_7]->stream_index[stream_idx];
}
for (VAR_7 = 0; VAR_7 < VAR_0->programs[VAR_7]->nb_stream_indexes; VAR_7++)
if (VAR_1->VAR_5 == VAR_0->programs[VAR_7]->stream_index[VAR_7])
return 1;
}
return 0;
} else if (*VAR_2 == '#') {
int VAR_9;
char *VAR_10;
VAR_9 = strtol(VAR_2 + 1, &VAR_10, 0);
if (!*VAR_10)
return VAR_1->id == VAR_9;
} else if (!*VAR_2)
return 1;
av_log(VAR_0, AV_LOG_ERROR, "Invalid stream specifier: %VAR_0.\n", VAR_2);
return AVERROR(EINVAL);
}
| [
"int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, const char *VAR_2)\n{",
"if (*VAR_2 <= '9' && *VAR_2 >= '0')\nreturn strtol(VAR_2, NULL, 0) == VAR_1->VAR_5;",
"else if (*VAR_2 == 'v' || *VAR_2 == 'a' || *VAR_2 == 'VAR_0' || *VAR_2 == 'd' ||\n*VAR_2 == 't') {",
"enum AVMediaType VAR_3;",
"switch (*VAR_2++) {",
"case 'v': VAR_3 = AVMEDIA_TYPE_VIDEO; break;",
"case 'a': VAR_3 = AVMEDIA_TYPE_AUDIO; break;",
"case 'VAR_0': VAR_3 = AVMEDIA_TYPE_SUBTITLE; break;",
"case 'd': VAR_3 = AVMEDIA_TYPE_DATA; break;",
"case 't': VAR_3 = AVMEDIA_TYPE_ATTACHMENT; break;",
"default: av_assert0(0);",
"}",
"if (VAR_3 != VAR_1->codec->codec_type)\nreturn 0;",
"if (*VAR_2++ == ':') {",
"int VAR_7, VAR_5 = strtol(VAR_2, NULL, 0);",
"for (VAR_7 = 0; VAR_7 < VAR_0->nb_streams; VAR_7++)",
"if (VAR_0->streams[VAR_7]->codec->codec_type == VAR_3 && VAR_5-- == 0)\nreturn VAR_7 == VAR_1->VAR_5;",
"return 0;",
"}",
"return 1;",
"} else if (*VAR_2 == 'p' && *(VAR_2 + 1) == ':') {",
"int VAR_6, VAR_7, VAR_7;",
"char *VAR_10;",
"VAR_2 += 2;",
"VAR_6 = strtol(VAR_2, &VAR_10, 0);",
"for (VAR_7 = 0; VAR_7 < VAR_0->nb_programs; VAR_7++) {",
"if (VAR_0->programs[VAR_7]->id != VAR_6)\ncontinue;",
"if (*VAR_10++ == ':') {",
"int stream_idx = strtol(VAR_10, NULL, 0);",
"return stream_idx >= 0 &&\nstream_idx < VAR_0->programs[VAR_7]->nb_stream_indexes &&\nVAR_1->VAR_5 == VAR_0->programs[VAR_7]->stream_index[stream_idx];",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_0->programs[VAR_7]->nb_stream_indexes; VAR_7++)",
"if (VAR_1->VAR_5 == VAR_0->programs[VAR_7]->stream_index[VAR_7])\nreturn 1;",
"}",
"return 0;",
"} else if (*VAR_2 == '#') {",
"int VAR_9;",
"char *VAR_10;",
"VAR_9 = strtol(VAR_2 + 1, &VAR_10, 0);",
"if (!*VAR_10)\nreturn VAR_1->id == VAR_9;",
"} else if (!*VAR_2)",
"return 1;",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid stream specifier: %VAR_0.\\n\", VAR_2);",
"return AVERROR(EINVAL);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
71
],
[
73
],
[
75,
77,
79
],
[
81
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
]
]
|
10,448 | static void filter_mb_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) {
const int index_a = qp + h->slice_alpha_c0_offset;
const int alpha = (alpha_table+52)[index_a];
const int beta = (beta_table+52)[qp + h->slice_beta_offset];
if (alpha ==0 || beta == 0) return;
if( bS[0] < 4 ) {
int8_t tc[4];
tc[0] = (tc0_table+52)[index_a][bS[0]]+1;
tc[1] = (tc0_table+52)[index_a][bS[1]]+1;
tc[2] = (tc0_table+52)[index_a][bS[2]]+1;
tc[3] = (tc0_table+52)[index_a][bS[3]]+1;
h->s.dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
} else {
h->s.dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
}
}
| false | FFmpeg | 082cf97106e2e94a969877d4f8c05c1e526acf54 | static void filter_mb_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) {
const int index_a = qp + h->slice_alpha_c0_offset;
const int alpha = (alpha_table+52)[index_a];
const int beta = (beta_table+52)[qp + h->slice_beta_offset];
if (alpha ==0 || beta == 0) return;
if( bS[0] < 4 ) {
int8_t tc[4];
tc[0] = (tc0_table+52)[index_a][bS[0]]+1;
tc[1] = (tc0_table+52)[index_a][bS[1]]+1;
tc[2] = (tc0_table+52)[index_a][bS[2]]+1;
tc[3] = (tc0_table+52)[index_a][bS[3]]+1;
h->s.dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
} else {
h->s.dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, int16_t VAR_3[4], int VAR_4 ) {
const int VAR_5 = VAR_4 + VAR_0->slice_alpha_c0_offset;
const int VAR_6 = (alpha_table+52)[VAR_5];
const int VAR_7 = (beta_table+52)[VAR_4 + VAR_0->slice_beta_offset];
if (VAR_6 ==0 || VAR_7 == 0) return;
if( VAR_3[0] < 4 ) {
int8_t tc[4];
tc[0] = (tc0_table+52)[VAR_5][VAR_3[0]]+1;
tc[1] = (tc0_table+52)[VAR_5][VAR_3[1]]+1;
tc[2] = (tc0_table+52)[VAR_5][VAR_3[2]]+1;
tc[3] = (tc0_table+52)[VAR_5][VAR_3[3]]+1;
VAR_0->s.dsp.h264_h_loop_filter_chroma(VAR_1, VAR_2, VAR_6, VAR_7, tc);
} else {
VAR_0->s.dsp.h264_h_loop_filter_chroma_intra(VAR_1, VAR_2, VAR_6, VAR_7);
}
}
| [
"static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, int16_t VAR_3[4], int VAR_4 ) {",
"const int VAR_5 = VAR_4 + VAR_0->slice_alpha_c0_offset;",
"const int VAR_6 = (alpha_table+52)[VAR_5];",
"const int VAR_7 = (beta_table+52)[VAR_4 + VAR_0->slice_beta_offset];",
"if (VAR_6 ==0 || VAR_7 == 0) return;",
"if( VAR_3[0] < 4 ) {",
"int8_t tc[4];",
"tc[0] = (tc0_table+52)[VAR_5][VAR_3[0]]+1;",
"tc[1] = (tc0_table+52)[VAR_5][VAR_3[1]]+1;",
"tc[2] = (tc0_table+52)[VAR_5][VAR_3[2]]+1;",
"tc[3] = (tc0_table+52)[VAR_5][VAR_3[3]]+1;",
"VAR_0->s.dsp.h264_h_loop_filter_chroma(VAR_1, VAR_2, VAR_6, VAR_7, tc);",
"} else {",
"VAR_0->s.dsp.h264_h_loop_filter_chroma_intra(VAR_1, VAR_2, VAR_6, VAR_7);",
"}",
"}"
]
| [
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
]
]
|
10,450 | int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr,
int is_write1, int mmu_idx)
{
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
uint64_t ptep, pte;
target_ulong pde_addr, pte_addr;
int error_code = 0;
int is_dirty, prot, page_size, is_write, is_user;
hwaddr paddr;
uint64_t rsvd_mask = PG_HI_RSVD_MASK;
uint32_t page_offset;
target_ulong vaddr;
is_user = mmu_idx == MMU_USER_IDX;
#if defined(DEBUG_MMU)
printf("MMU fault: addr=%" VADDR_PRIx " w=%d u=%d eip=" TARGET_FMT_lx "\n",
addr, is_write1, is_user, env->eip);
#endif
is_write = is_write1 & 1;
if (!(env->cr[0] & CR0_PG_MASK)) {
pte = addr;
#ifdef TARGET_X86_64
if (!(env->hflags & HF_LMA_MASK)) {
/* Without long mode we can only address 32bits in real mode */
pte = (uint32_t)pte;
}
#endif
prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
page_size = 4096;
goto do_mapping;
}
if (!(env->efer & MSR_EFER_NXE)) {
rsvd_mask |= PG_NX_MASK;
}
if (env->cr[4] & CR4_PAE_MASK) {
uint64_t pde, pdpe;
target_ulong pdpe_addr;
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK) {
uint64_t pml4e_addr, pml4e;
int32_t sext;
/* test virtual address sign extension */
sext = (int64_t)addr >> 47;
if (sext != 0 && sext != -1) {
env->error_code = 0;
cs->exception_index = EXCP0D_GPF;
return 1;
}
pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) &
env->a20_mask;
pml4e = ldq_phys(cs->as, pml4e_addr);
if (!(pml4e & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pml4e & (rsvd_mask | PG_PSE_MASK)) {
goto do_fault_rsvd;
}
if (!(pml4e & PG_ACCESSED_MASK)) {
pml4e |= PG_ACCESSED_MASK;
stl_phys_notdirty(cs->as, pml4e_addr, pml4e);
}
ptep = pml4e ^ PG_NX_MASK;
pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((addr >> 30) & 0x1ff) << 3)) &
env->a20_mask;
pdpe = ldq_phys(cs->as, pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pdpe & rsvd_mask) {
goto do_fault_rsvd;
}
ptep &= pdpe ^ PG_NX_MASK;
if (!(pdpe & PG_ACCESSED_MASK)) {
pdpe |= PG_ACCESSED_MASK;
stl_phys_notdirty(cs->as, pdpe_addr, pdpe);
}
if (pdpe & PG_PSE_MASK) {
/* 1 GB page */
page_size = 1024 * 1024 * 1024;
pte_addr = pdpe_addr;
pte = pdpe;
goto do_check_protect;
}
} else
#endif
{
/* XXX: load them when cr3 is loaded ? */
pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) &
env->a20_mask;
pdpe = ldq_phys(cs->as, pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
goto do_fault;
}
rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK;
if (pdpe & rsvd_mask) {
goto do_fault_rsvd;
}
ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;
}
pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((addr >> 21) & 0x1ff) << 3)) &
env->a20_mask;
pde = ldq_phys(cs->as, pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pde & rsvd_mask) {
goto do_fault_rsvd;
}
ptep &= pde ^ PG_NX_MASK;
if (pde & PG_PSE_MASK) {
/* 2 MB page */
page_size = 2048 * 1024;
pte_addr = pde_addr;
pte = pde;
goto do_check_protect;
}
/* 4 KB page */
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(cs->as, pde_addr, pde);
}
pte_addr = ((pde & PG_ADDRESS_MASK) + (((addr >> 12) & 0x1ff) << 3)) &
env->a20_mask;
pte = ldq_phys(cs->as, pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pte & rsvd_mask) {
goto do_fault_rsvd;
}
/* combine pde and pte nx, user and rw protections */
ptep &= pte ^ PG_NX_MASK;
page_size = 4096;
} else {
uint32_t pde;
/* page directory entry */
pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) &
env->a20_mask;
pde = ldl_phys(cs->as, pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
goto do_fault;
}
ptep = pde | PG_NX_MASK;
/* if PSE bit is set, then we use a 4MB page */
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
page_size = 4096 * 1024;
pte_addr = pde_addr;
/* Bits 20-13 provide bits 39-32 of the address, bit 21 is reserved.
* Leave bits 20-13 in place for setting accessed/dirty bits below.
*/
pte = pde | ((pde & 0x1fe000) << (32 - 13));
rsvd_mask = 0x200000;
goto do_check_protect_pse36;
}
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(cs->as, pde_addr, pde);
}
/* page directory entry */
pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) &
env->a20_mask;
pte = ldl_phys(cs->as, pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
goto do_fault;
}
/* combine pde and pte user and rw protections */
ptep &= pte | PG_NX_MASK;
page_size = 4096;
rsvd_mask = 0;
}
do_check_protect:
rsvd_mask |= (page_size - 1) & PG_ADDRESS_MASK & ~PG_PSE_PAT_MASK;
do_check_protect_pse36:
if (pte & rsvd_mask) {
goto do_fault_rsvd;
}
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && is_write1 == 2) {
goto do_fault_protect;
}
switch (mmu_idx) {
case MMU_USER_IDX:
if (!(ptep & PG_USER_MASK)) {
goto do_fault_protect;
}
if (is_write && !(ptep & PG_RW_MASK)) {
goto do_fault_protect;
}
break;
case MMU_KSMAP_IDX:
if (is_write1 != 2 && (ptep & PG_USER_MASK)) {
goto do_fault_protect;
}
/* fall through */
case MMU_KNOSMAP_IDX:
if (is_write1 == 2 && (env->cr[4] & CR4_SMEP_MASK) &&
(ptep & PG_USER_MASK)) {
goto do_fault_protect;
}
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK)) {
goto do_fault_protect;
}
break;
default: /* cannot happen */
break;
}
is_dirty = is_write && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || is_dirty) {
pte |= PG_ACCESSED_MASK;
if (is_dirty) {
pte |= PG_DIRTY_MASK;
}
stl_phys_notdirty(cs->as, pte_addr, pte);
}
/* the page can be put in the TLB */
prot = PAGE_READ;
if (!(ptep & PG_NX_MASK))
prot |= PAGE_EXEC;
if (pte & PG_DIRTY_MASK) {
/* only set write access if already dirty... otherwise wait
for dirty access */
if (is_user) {
if (ptep & PG_RW_MASK)
prot |= PAGE_WRITE;
} else {
if (!(env->cr[0] & CR0_WP_MASK) ||
(ptep & PG_RW_MASK))
prot |= PAGE_WRITE;
}
}
do_mapping:
pte = pte & env->a20_mask;
/* align to page_size */
pte &= PG_ADDRESS_MASK & ~(page_size - 1);
/* Even if 4MB pages, we map only one 4KB page in the cache to
avoid filling it too fast */
vaddr = addr & TARGET_PAGE_MASK;
page_offset = vaddr & (page_size - 1);
paddr = pte + page_offset;
tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, page_size);
return 0;
do_fault_rsvd:
error_code |= PG_ERROR_RSVD_MASK;
do_fault_protect:
error_code |= PG_ERROR_P_MASK;
do_fault:
error_code |= (is_write << PG_ERROR_W_BIT);
if (is_user)
error_code |= PG_ERROR_U_MASK;
if (is_write1 == 2 &&
(((env->efer & MSR_EFER_NXE) &&
(env->cr[4] & CR4_PAE_MASK)) ||
(env->cr[4] & CR4_SMEP_MASK)))
error_code |= PG_ERROR_I_D_MASK;
if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) {
/* cr2 is not modified in case of exceptions */
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2),
addr);
} else {
env->cr[2] = addr;
}
env->error_code = error_code;
cs->exception_index = EXCP0E_PAGE;
return 1;
}
| true | qemu | b09481de91cce94342bac3327bb7633c39ff8bf6 | int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr,
int is_write1, int mmu_idx)
{
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
uint64_t ptep, pte;
target_ulong pde_addr, pte_addr;
int error_code = 0;
int is_dirty, prot, page_size, is_write, is_user;
hwaddr paddr;
uint64_t rsvd_mask = PG_HI_RSVD_MASK;
uint32_t page_offset;
target_ulong vaddr;
is_user = mmu_idx == MMU_USER_IDX;
#if defined(DEBUG_MMU)
printf("MMU fault: addr=%" VADDR_PRIx " w=%d u=%d eip=" TARGET_FMT_lx "\n",
addr, is_write1, is_user, env->eip);
#endif
is_write = is_write1 & 1;
if (!(env->cr[0] & CR0_PG_MASK)) {
pte = addr;
#ifdef TARGET_X86_64
if (!(env->hflags & HF_LMA_MASK)) {
pte = (uint32_t)pte;
}
#endif
prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
page_size = 4096;
goto do_mapping;
}
if (!(env->efer & MSR_EFER_NXE)) {
rsvd_mask |= PG_NX_MASK;
}
if (env->cr[4] & CR4_PAE_MASK) {
uint64_t pde, pdpe;
target_ulong pdpe_addr;
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK) {
uint64_t pml4e_addr, pml4e;
int32_t sext;
sext = (int64_t)addr >> 47;
if (sext != 0 && sext != -1) {
env->error_code = 0;
cs->exception_index = EXCP0D_GPF;
return 1;
}
pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) &
env->a20_mask;
pml4e = ldq_phys(cs->as, pml4e_addr);
if (!(pml4e & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pml4e & (rsvd_mask | PG_PSE_MASK)) {
goto do_fault_rsvd;
}
if (!(pml4e & PG_ACCESSED_MASK)) {
pml4e |= PG_ACCESSED_MASK;
stl_phys_notdirty(cs->as, pml4e_addr, pml4e);
}
ptep = pml4e ^ PG_NX_MASK;
pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((addr >> 30) & 0x1ff) << 3)) &
env->a20_mask;
pdpe = ldq_phys(cs->as, pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pdpe & rsvd_mask) {
goto do_fault_rsvd;
}
ptep &= pdpe ^ PG_NX_MASK;
if (!(pdpe & PG_ACCESSED_MASK)) {
pdpe |= PG_ACCESSED_MASK;
stl_phys_notdirty(cs->as, pdpe_addr, pdpe);
}
if (pdpe & PG_PSE_MASK) {
page_size = 1024 * 1024 * 1024;
pte_addr = pdpe_addr;
pte = pdpe;
goto do_check_protect;
}
} else
#endif
{
pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) &
env->a20_mask;
pdpe = ldq_phys(cs->as, pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
goto do_fault;
}
rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK;
if (pdpe & rsvd_mask) {
goto do_fault_rsvd;
}
ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;
}
pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((addr >> 21) & 0x1ff) << 3)) &
env->a20_mask;
pde = ldq_phys(cs->as, pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pde & rsvd_mask) {
goto do_fault_rsvd;
}
ptep &= pde ^ PG_NX_MASK;
if (pde & PG_PSE_MASK) {
page_size = 2048 * 1024;
pte_addr = pde_addr;
pte = pde;
goto do_check_protect;
}
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(cs->as, pde_addr, pde);
}
pte_addr = ((pde & PG_ADDRESS_MASK) + (((addr >> 12) & 0x1ff) << 3)) &
env->a20_mask;
pte = ldq_phys(cs->as, pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pte & rsvd_mask) {
goto do_fault_rsvd;
}
ptep &= pte ^ PG_NX_MASK;
page_size = 4096;
} else {
uint32_t pde;
pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) &
env->a20_mask;
pde = ldl_phys(cs->as, pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
goto do_fault;
}
ptep = pde | PG_NX_MASK;
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
page_size = 4096 * 1024;
pte_addr = pde_addr;
pte = pde | ((pde & 0x1fe000) << (32 - 13));
rsvd_mask = 0x200000;
goto do_check_protect_pse36;
}
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(cs->as, pde_addr, pde);
}
pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) &
env->a20_mask;
pte = ldl_phys(cs->as, pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
goto do_fault;
}
ptep &= pte | PG_NX_MASK;
page_size = 4096;
rsvd_mask = 0;
}
do_check_protect:
rsvd_mask |= (page_size - 1) & PG_ADDRESS_MASK & ~PG_PSE_PAT_MASK;
do_check_protect_pse36:
if (pte & rsvd_mask) {
goto do_fault_rsvd;
}
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && is_write1 == 2) {
goto do_fault_protect;
}
switch (mmu_idx) {
case MMU_USER_IDX:
if (!(ptep & PG_USER_MASK)) {
goto do_fault_protect;
}
if (is_write && !(ptep & PG_RW_MASK)) {
goto do_fault_protect;
}
break;
case MMU_KSMAP_IDX:
if (is_write1 != 2 && (ptep & PG_USER_MASK)) {
goto do_fault_protect;
}
case MMU_KNOSMAP_IDX:
if (is_write1 == 2 && (env->cr[4] & CR4_SMEP_MASK) &&
(ptep & PG_USER_MASK)) {
goto do_fault_protect;
}
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK)) {
goto do_fault_protect;
}
break;
default:
break;
}
is_dirty = is_write && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || is_dirty) {
pte |= PG_ACCESSED_MASK;
if (is_dirty) {
pte |= PG_DIRTY_MASK;
}
stl_phys_notdirty(cs->as, pte_addr, pte);
}
prot = PAGE_READ;
if (!(ptep & PG_NX_MASK))
prot |= PAGE_EXEC;
if (pte & PG_DIRTY_MASK) {
if (is_user) {
if (ptep & PG_RW_MASK)
prot |= PAGE_WRITE;
} else {
if (!(env->cr[0] & CR0_WP_MASK) ||
(ptep & PG_RW_MASK))
prot |= PAGE_WRITE;
}
}
do_mapping:
pte = pte & env->a20_mask;
pte &= PG_ADDRESS_MASK & ~(page_size - 1);
vaddr = addr & TARGET_PAGE_MASK;
page_offset = vaddr & (page_size - 1);
paddr = pte + page_offset;
tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, page_size);
return 0;
do_fault_rsvd:
error_code |= PG_ERROR_RSVD_MASK;
do_fault_protect:
error_code |= PG_ERROR_P_MASK;
do_fault:
error_code |= (is_write << PG_ERROR_W_BIT);
if (is_user)
error_code |= PG_ERROR_U_MASK;
if (is_write1 == 2 &&
(((env->efer & MSR_EFER_NXE) &&
(env->cr[4] & CR4_PAE_MASK)) ||
(env->cr[4] & CR4_SMEP_MASK)))
error_code |= PG_ERROR_I_D_MASK;
if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) {
stq_phys(cs->as,
env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2),
addr);
} else {
env->cr[2] = addr;
}
env->error_code = error_code;
cs->exception_index = EXCP0E_PAGE;
return 1;
}
| {
"code": [
" if (!(ptep & PG_NX_MASK))"
],
"line_no": [
469
]
} | int FUNC_0(CPUState *VAR_0, vaddr VAR_1,
int VAR_2, int VAR_3)
{
X86CPU *cpu = X86_CPU(VAR_0);
CPUX86State *env = &cpu->env;
uint64_t ptep, pte;
target_ulong pde_addr, pte_addr;
int VAR_4 = 0;
int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
hwaddr paddr;
uint64_t rsvd_mask = PG_HI_RSVD_MASK;
uint32_t page_offset;
target_ulong vaddr;
VAR_9 = VAR_3 == MMU_USER_IDX;
#if defined(DEBUG_MMU)
printf("MMU fault: VAR_1=%" VADDR_PRIx " w=%d u=%d eip=" TARGET_FMT_lx "\n",
VAR_1, VAR_2, VAR_9, env->eip);
#endif
VAR_8 = VAR_2 & 1;
if (!(env->cr[0] & CR0_PG_MASK)) {
pte = VAR_1;
#ifdef TARGET_X86_64
if (!(env->hflags & HF_LMA_MASK)) {
pte = (uint32_t)pte;
}
#endif
VAR_6 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
VAR_7 = 4096;
goto do_mapping;
}
if (!(env->efer & MSR_EFER_NXE)) {
rsvd_mask |= PG_NX_MASK;
}
if (env->cr[4] & CR4_PAE_MASK) {
uint64_t pde, pdpe;
target_ulong pdpe_addr;
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK) {
uint64_t pml4e_addr, pml4e;
int32_t sext;
sext = (int64_t)VAR_1 >> 47;
if (sext != 0 && sext != -1) {
env->VAR_4 = 0;
VAR_0->exception_index = EXCP0D_GPF;
return 1;
}
pml4e_addr = ((env->cr[3] & ~0xfff) + (((VAR_1 >> 39) & 0x1ff) << 3)) &
env->a20_mask;
pml4e = ldq_phys(VAR_0->as, pml4e_addr);
if (!(pml4e & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pml4e & (rsvd_mask | PG_PSE_MASK)) {
goto do_fault_rsvd;
}
if (!(pml4e & PG_ACCESSED_MASK)) {
pml4e |= PG_ACCESSED_MASK;
stl_phys_notdirty(VAR_0->as, pml4e_addr, pml4e);
}
ptep = pml4e ^ PG_NX_MASK;
pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((VAR_1 >> 30) & 0x1ff) << 3)) &
env->a20_mask;
pdpe = ldq_phys(VAR_0->as, pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pdpe & rsvd_mask) {
goto do_fault_rsvd;
}
ptep &= pdpe ^ PG_NX_MASK;
if (!(pdpe & PG_ACCESSED_MASK)) {
pdpe |= PG_ACCESSED_MASK;
stl_phys_notdirty(VAR_0->as, pdpe_addr, pdpe);
}
if (pdpe & PG_PSE_MASK) {
VAR_7 = 1024 * 1024 * 1024;
pte_addr = pdpe_addr;
pte = pdpe;
goto do_check_protect;
}
} else
#endif
{
pdpe_addr = ((env->cr[3] & ~0x1f) + ((VAR_1 >> 27) & 0x18)) &
env->a20_mask;
pdpe = ldq_phys(VAR_0->as, pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
goto do_fault;
}
rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK;
if (pdpe & rsvd_mask) {
goto do_fault_rsvd;
}
ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;
}
pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((VAR_1 >> 21) & 0x1ff) << 3)) &
env->a20_mask;
pde = ldq_phys(VAR_0->as, pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pde & rsvd_mask) {
goto do_fault_rsvd;
}
ptep &= pde ^ PG_NX_MASK;
if (pde & PG_PSE_MASK) {
VAR_7 = 2048 * 1024;
pte_addr = pde_addr;
pte = pde;
goto do_check_protect;
}
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(VAR_0->as, pde_addr, pde);
}
pte_addr = ((pde & PG_ADDRESS_MASK) + (((VAR_1 >> 12) & 0x1ff) << 3)) &
env->a20_mask;
pte = ldq_phys(VAR_0->as, pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
goto do_fault;
}
if (pte & rsvd_mask) {
goto do_fault_rsvd;
}
ptep &= pte ^ PG_NX_MASK;
VAR_7 = 4096;
} else {
uint32_t pde;
pde_addr = ((env->cr[3] & ~0xfff) + ((VAR_1 >> 20) & 0xffc)) &
env->a20_mask;
pde = ldl_phys(VAR_0->as, pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
goto do_fault;
}
ptep = pde | PG_NX_MASK;
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
VAR_7 = 4096 * 1024;
pte_addr = pde_addr;
pte = pde | ((pde & 0x1fe000) << (32 - 13));
rsvd_mask = 0x200000;
goto do_check_protect_pse36;
}
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(VAR_0->as, pde_addr, pde);
}
pte_addr = ((pde & ~0xfff) + ((VAR_1 >> 10) & 0xffc)) &
env->a20_mask;
pte = ldl_phys(VAR_0->as, pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
goto do_fault;
}
ptep &= pte | PG_NX_MASK;
VAR_7 = 4096;
rsvd_mask = 0;
}
do_check_protect:
rsvd_mask |= (VAR_7 - 1) & PG_ADDRESS_MASK & ~PG_PSE_PAT_MASK;
do_check_protect_pse36:
if (pte & rsvd_mask) {
goto do_fault_rsvd;
}
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && VAR_2 == 2) {
goto do_fault_protect;
}
switch (VAR_3) {
case MMU_USER_IDX:
if (!(ptep & PG_USER_MASK)) {
goto do_fault_protect;
}
if (VAR_8 && !(ptep & PG_RW_MASK)) {
goto do_fault_protect;
}
break;
case MMU_KSMAP_IDX:
if (VAR_2 != 2 && (ptep & PG_USER_MASK)) {
goto do_fault_protect;
}
case MMU_KNOSMAP_IDX:
if (VAR_2 == 2 && (env->cr[4] & CR4_SMEP_MASK) &&
(ptep & PG_USER_MASK)) {
goto do_fault_protect;
}
if ((env->cr[0] & CR0_WP_MASK) &&
VAR_8 && !(ptep & PG_RW_MASK)) {
goto do_fault_protect;
}
break;
default:
break;
}
VAR_5 = VAR_8 && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || VAR_5) {
pte |= PG_ACCESSED_MASK;
if (VAR_5) {
pte |= PG_DIRTY_MASK;
}
stl_phys_notdirty(VAR_0->as, pte_addr, pte);
}
VAR_6 = PAGE_READ;
if (!(ptep & PG_NX_MASK))
VAR_6 |= PAGE_EXEC;
if (pte & PG_DIRTY_MASK) {
if (VAR_9) {
if (ptep & PG_RW_MASK)
VAR_6 |= PAGE_WRITE;
} else {
if (!(env->cr[0] & CR0_WP_MASK) ||
(ptep & PG_RW_MASK))
VAR_6 |= PAGE_WRITE;
}
}
do_mapping:
pte = pte & env->a20_mask;
pte &= PG_ADDRESS_MASK & ~(VAR_7 - 1);
vaddr = VAR_1 & TARGET_PAGE_MASK;
page_offset = vaddr & (VAR_7 - 1);
paddr = pte + page_offset;
tlb_set_page(VAR_0, vaddr, paddr, VAR_6, VAR_3, VAR_7);
return 0;
do_fault_rsvd:
VAR_4 |= PG_ERROR_RSVD_MASK;
do_fault_protect:
VAR_4 |= PG_ERROR_P_MASK;
do_fault:
VAR_4 |= (VAR_8 << PG_ERROR_W_BIT);
if (VAR_9)
VAR_4 |= PG_ERROR_U_MASK;
if (VAR_2 == 2 &&
(((env->efer & MSR_EFER_NXE) &&
(env->cr[4] & CR4_PAE_MASK)) ||
(env->cr[4] & CR4_SMEP_MASK)))
VAR_4 |= PG_ERROR_I_D_MASK;
if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) {
stq_phys(VAR_0->as,
env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2),
VAR_1);
} else {
env->cr[2] = VAR_1;
}
env->VAR_4 = VAR_4;
VAR_0->exception_index = EXCP0E_PAGE;
return 1;
}
| [
"int FUNC_0(CPUState *VAR_0, vaddr VAR_1,\nint VAR_2, int VAR_3)\n{",
"X86CPU *cpu = X86_CPU(VAR_0);",
"CPUX86State *env = &cpu->env;",
"uint64_t ptep, pte;",
"target_ulong pde_addr, pte_addr;",
"int VAR_4 = 0;",
"int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"hwaddr paddr;",
"uint64_t rsvd_mask = PG_HI_RSVD_MASK;",
"uint32_t page_offset;",
"target_ulong vaddr;",
"VAR_9 = VAR_3 == MMU_USER_IDX;",
"#if defined(DEBUG_MMU)\nprintf(\"MMU fault: VAR_1=%\" VADDR_PRIx \" w=%d u=%d eip=\" TARGET_FMT_lx \"\\n\",\nVAR_1, VAR_2, VAR_9, env->eip);",
"#endif\nVAR_8 = VAR_2 & 1;",
"if (!(env->cr[0] & CR0_PG_MASK)) {",
"pte = VAR_1;",
"#ifdef TARGET_X86_64\nif (!(env->hflags & HF_LMA_MASK)) {",
"pte = (uint32_t)pte;",
"}",
"#endif\nVAR_6 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;",
"VAR_7 = 4096;",
"goto do_mapping;",
"}",
"if (!(env->efer & MSR_EFER_NXE)) {",
"rsvd_mask |= PG_NX_MASK;",
"}",
"if (env->cr[4] & CR4_PAE_MASK) {",
"uint64_t pde, pdpe;",
"target_ulong pdpe_addr;",
"#ifdef TARGET_X86_64\nif (env->hflags & HF_LMA_MASK) {",
"uint64_t pml4e_addr, pml4e;",
"int32_t sext;",
"sext = (int64_t)VAR_1 >> 47;",
"if (sext != 0 && sext != -1) {",
"env->VAR_4 = 0;",
"VAR_0->exception_index = EXCP0D_GPF;",
"return 1;",
"}",
"pml4e_addr = ((env->cr[3] & ~0xfff) + (((VAR_1 >> 39) & 0x1ff) << 3)) &\nenv->a20_mask;",
"pml4e = ldq_phys(VAR_0->as, pml4e_addr);",
"if (!(pml4e & PG_PRESENT_MASK)) {",
"goto do_fault;",
"}",
"if (pml4e & (rsvd_mask | PG_PSE_MASK)) {",
"goto do_fault_rsvd;",
"}",
"if (!(pml4e & PG_ACCESSED_MASK)) {",
"pml4e |= PG_ACCESSED_MASK;",
"stl_phys_notdirty(VAR_0->as, pml4e_addr, pml4e);",
"}",
"ptep = pml4e ^ PG_NX_MASK;",
"pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((VAR_1 >> 30) & 0x1ff) << 3)) &\nenv->a20_mask;",
"pdpe = ldq_phys(VAR_0->as, pdpe_addr);",
"if (!(pdpe & PG_PRESENT_MASK)) {",
"goto do_fault;",
"}",
"if (pdpe & rsvd_mask) {",
"goto do_fault_rsvd;",
"}",
"ptep &= pdpe ^ PG_NX_MASK;",
"if (!(pdpe & PG_ACCESSED_MASK)) {",
"pdpe |= PG_ACCESSED_MASK;",
"stl_phys_notdirty(VAR_0->as, pdpe_addr, pdpe);",
"}",
"if (pdpe & PG_PSE_MASK) {",
"VAR_7 = 1024 * 1024 * 1024;",
"pte_addr = pdpe_addr;",
"pte = pdpe;",
"goto do_check_protect;",
"}",
"} else",
"#endif\n{",
"pdpe_addr = ((env->cr[3] & ~0x1f) + ((VAR_1 >> 27) & 0x18)) &\nenv->a20_mask;",
"pdpe = ldq_phys(VAR_0->as, pdpe_addr);",
"if (!(pdpe & PG_PRESENT_MASK)) {",
"goto do_fault;",
"}",
"rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK;",
"if (pdpe & rsvd_mask) {",
"goto do_fault_rsvd;",
"}",
"ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;",
"}",
"pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((VAR_1 >> 21) & 0x1ff) << 3)) &\nenv->a20_mask;",
"pde = ldq_phys(VAR_0->as, pde_addr);",
"if (!(pde & PG_PRESENT_MASK)) {",
"goto do_fault;",
"}",
"if (pde & rsvd_mask) {",
"goto do_fault_rsvd;",
"}",
"ptep &= pde ^ PG_NX_MASK;",
"if (pde & PG_PSE_MASK) {",
"VAR_7 = 2048 * 1024;",
"pte_addr = pde_addr;",
"pte = pde;",
"goto do_check_protect;",
"}",
"if (!(pde & PG_ACCESSED_MASK)) {",
"pde |= PG_ACCESSED_MASK;",
"stl_phys_notdirty(VAR_0->as, pde_addr, pde);",
"}",
"pte_addr = ((pde & PG_ADDRESS_MASK) + (((VAR_1 >> 12) & 0x1ff) << 3)) &\nenv->a20_mask;",
"pte = ldq_phys(VAR_0->as, pte_addr);",
"if (!(pte & PG_PRESENT_MASK)) {",
"goto do_fault;",
"}",
"if (pte & rsvd_mask) {",
"goto do_fault_rsvd;",
"}",
"ptep &= pte ^ PG_NX_MASK;",
"VAR_7 = 4096;",
"} else {",
"uint32_t pde;",
"pde_addr = ((env->cr[3] & ~0xfff) + ((VAR_1 >> 20) & 0xffc)) &\nenv->a20_mask;",
"pde = ldl_phys(VAR_0->as, pde_addr);",
"if (!(pde & PG_PRESENT_MASK)) {",
"goto do_fault;",
"}",
"ptep = pde | PG_NX_MASK;",
"if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {",
"VAR_7 = 4096 * 1024;",
"pte_addr = pde_addr;",
"pte = pde | ((pde & 0x1fe000) << (32 - 13));",
"rsvd_mask = 0x200000;",
"goto do_check_protect_pse36;",
"}",
"if (!(pde & PG_ACCESSED_MASK)) {",
"pde |= PG_ACCESSED_MASK;",
"stl_phys_notdirty(VAR_0->as, pde_addr, pde);",
"}",
"pte_addr = ((pde & ~0xfff) + ((VAR_1 >> 10) & 0xffc)) &\nenv->a20_mask;",
"pte = ldl_phys(VAR_0->as, pte_addr);",
"if (!(pte & PG_PRESENT_MASK)) {",
"goto do_fault;",
"}",
"ptep &= pte | PG_NX_MASK;",
"VAR_7 = 4096;",
"rsvd_mask = 0;",
"}",
"do_check_protect:\nrsvd_mask |= (VAR_7 - 1) & PG_ADDRESS_MASK & ~PG_PSE_PAT_MASK;",
"do_check_protect_pse36:\nif (pte & rsvd_mask) {",
"goto do_fault_rsvd;",
"}",
"ptep ^= PG_NX_MASK;",
"if ((ptep & PG_NX_MASK) && VAR_2 == 2) {",
"goto do_fault_protect;",
"}",
"switch (VAR_3) {",
"case MMU_USER_IDX:\nif (!(ptep & PG_USER_MASK)) {",
"goto do_fault_protect;",
"}",
"if (VAR_8 && !(ptep & PG_RW_MASK)) {",
"goto do_fault_protect;",
"}",
"break;",
"case MMU_KSMAP_IDX:\nif (VAR_2 != 2 && (ptep & PG_USER_MASK)) {",
"goto do_fault_protect;",
"}",
"case MMU_KNOSMAP_IDX:\nif (VAR_2 == 2 && (env->cr[4] & CR4_SMEP_MASK) &&\n(ptep & PG_USER_MASK)) {",
"goto do_fault_protect;",
"}",
"if ((env->cr[0] & CR0_WP_MASK) &&\nVAR_8 && !(ptep & PG_RW_MASK)) {",
"goto do_fault_protect;",
"}",
"break;",
"default:\nbreak;",
"}",
"VAR_5 = VAR_8 && !(pte & PG_DIRTY_MASK);",
"if (!(pte & PG_ACCESSED_MASK) || VAR_5) {",
"pte |= PG_ACCESSED_MASK;",
"if (VAR_5) {",
"pte |= PG_DIRTY_MASK;",
"}",
"stl_phys_notdirty(VAR_0->as, pte_addr, pte);",
"}",
"VAR_6 = PAGE_READ;",
"if (!(ptep & PG_NX_MASK))\nVAR_6 |= PAGE_EXEC;",
"if (pte & PG_DIRTY_MASK) {",
"if (VAR_9) {",
"if (ptep & PG_RW_MASK)\nVAR_6 |= PAGE_WRITE;",
"} else {",
"if (!(env->cr[0] & CR0_WP_MASK) ||\n(ptep & PG_RW_MASK))\nVAR_6 |= PAGE_WRITE;",
"}",
"}",
"do_mapping:\npte = pte & env->a20_mask;",
"pte &= PG_ADDRESS_MASK & ~(VAR_7 - 1);",
"vaddr = VAR_1 & TARGET_PAGE_MASK;",
"page_offset = vaddr & (VAR_7 - 1);",
"paddr = pte + page_offset;",
"tlb_set_page(VAR_0, vaddr, paddr, VAR_6, VAR_3, VAR_7);",
"return 0;",
"do_fault_rsvd:\nVAR_4 |= PG_ERROR_RSVD_MASK;",
"do_fault_protect:\nVAR_4 |= PG_ERROR_P_MASK;",
"do_fault:\nVAR_4 |= (VAR_8 << PG_ERROR_W_BIT);",
"if (VAR_9)\nVAR_4 |= PG_ERROR_U_MASK;",
"if (VAR_2 == 2 &&\n(((env->efer & MSR_EFER_NXE) &&\n(env->cr[4] & CR4_PAE_MASK)) ||\n(env->cr[4] & CR4_SMEP_MASK)))\nVAR_4 |= PG_ERROR_I_D_MASK;",
"if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) {",
"stq_phys(VAR_0->as,\nenv->vm_vmcb + offsetof(struct vmcb, control.exit_info_2),\nVAR_1);",
"} else {",
"env->cr[2] = VAR_1;",
"}",
"env->VAR_4 = VAR_4;",
"VAR_0->exception_index = EXCP0E_PAGE;",
"return 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
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
],
[
29
],
[
31,
33,
35
],
[
37,
39
],
[
43
],
[
45
],
[
47,
49
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85,
87
],
[
89
],
[
91
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
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
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183,
185
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
279
],
[
281
],
[
283
],
[
285
],
[
291,
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
309
],
[
311
],
[
313
],
[
323
],
[
325
],
[
327
],
[
329
],
[
333
],
[
335
],
[
337
],
[
339
],
[
345,
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
359
],
[
361
],
[
363
],
[
365
],
[
369,
371
],
[
373,
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391,
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
409,
411
],
[
413
],
[
415
],
[
419,
421,
423
],
[
425
],
[
427
],
[
429,
431
],
[
433
],
[
435
],
[
437
],
[
441,
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
467
],
[
469,
471
],
[
473
],
[
479
],
[
481,
483
],
[
485
],
[
487,
489,
491
],
[
493
],
[
495
],
[
497,
499
],
[
505
],
[
513
],
[
515
],
[
517
],
[
521
],
[
523
],
[
525,
527
],
[
529,
531
],
[
533,
535
],
[
537,
539
],
[
541,
543,
545,
547,
549
],
[
551
],
[
555,
557,
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
]
]
|
10,451 | uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr)
{
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint8_t val;
k->get_config(vdev, vdev->config);
if (addr > (vdev->config_len - sizeof(val)))
return (uint32_t)-1;
val = ldub_p(vdev->config + addr);
return val;
}
| true | qemu | 5f5a1318653c08e435cfa52f60b6a712815b659d | uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr)
{
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint8_t val;
k->get_config(vdev, vdev->config);
if (addr > (vdev->config_len - sizeof(val)))
return (uint32_t)-1;
val = ldub_p(vdev->config + addr);
return val;
}
| {
"code": [
" k->get_config(vdev, vdev->config);",
" if (addr > (vdev->config_len - sizeof(val)))",
" k->get_config(vdev, vdev->config);",
" if (addr > (vdev->config_len - sizeof(val)))",
" k->get_config(vdev, vdev->config);",
" if (addr > (vdev->config_len - sizeof(val)))",
" if (addr > (vdev->config_len - sizeof(val)))",
" if (addr > (vdev->config_len - sizeof(val)))",
" if (addr > (vdev->config_len - sizeof(val)))"
],
"line_no": [
11,
15,
11,
15,
11,
15,
15,
15,
15
]
} | uint32_t FUNC_0(VirtIODevice *vdev, uint32_t addr)
{
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint8_t val;
k->get_config(vdev, vdev->config);
if (addr > (vdev->config_len - sizeof(val)))
return (uint32_t)-1;
val = ldub_p(vdev->config + addr);
return val;
}
| [
"uint32_t FUNC_0(VirtIODevice *vdev, uint32_t addr)\n{",
"VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);",
"uint8_t val;",
"k->get_config(vdev, vdev->config);",
"if (addr > (vdev->config_len - sizeof(val)))\nreturn (uint32_t)-1;",
"val = ldub_p(vdev->config + addr);",
"return val;",
"}"
]
| [
0,
0,
0,
1,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17
],
[
21
],
[
23
],
[
25
]
]
|
10,452 | av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
{
int n = 1 << nbits;
int ret;
s->nbits = nbits;
s->inverse = trans == IDFT_C2R || trans == DFT_C2R;
s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
if (nbits < 4 || nbits > 16)
return AVERROR(EINVAL);
if ((ret = ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C)) < 0)
return ret;
ff_init_ff_cos_tabs(nbits);
s->tcos = ff_cos_tabs[nbits];
s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2);
#if !CONFIG_HARDCODED_TABLES
{
int i;
const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1) * 2 * M_PI / n;
for (i = 0; i < (n >> 2); i++)
s->tsin[i] = sin(i * theta);
}
#endif
s->rdft_calc = rdft_calc_c;
if (ARCH_ARM) ff_rdft_init_arm(s);
return 0;
}
| false | FFmpeg | 0780ad9c688cc8272daa7780d3f112a9f55208ca | av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
{
int n = 1 << nbits;
int ret;
s->nbits = nbits;
s->inverse = trans == IDFT_C2R || trans == DFT_C2R;
s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
if (nbits < 4 || nbits > 16)
return AVERROR(EINVAL);
if ((ret = ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C)) < 0)
return ret;
ff_init_ff_cos_tabs(nbits);
s->tcos = ff_cos_tabs[nbits];
s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2);
#if !CONFIG_HARDCODED_TABLES
{
int i;
const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1) * 2 * M_PI / n;
for (i = 0; i < (n >> 2); i++)
s->tsin[i] = sin(i * theta);
}
#endif
s->rdft_calc = rdft_calc_c;
if (ARCH_ARM) ff_rdft_init_arm(s);
return 0;
}
| {
"code": [],
"line_no": []
} | av_cold int FUNC_0(RDFTContext *s, int nbits, enum RDFTransformType trans)
{
int VAR_0 = 1 << nbits;
int VAR_1;
s->nbits = nbits;
s->inverse = trans == IDFT_C2R || trans == DFT_C2R;
s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
if (nbits < 4 || nbits > 16)
return AVERROR(EINVAL);
if ((VAR_1 = ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C)) < 0)
return VAR_1;
ff_init_ff_cos_tabs(nbits);
s->tcos = ff_cos_tabs[nbits];
s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(VAR_0>>2);
#if !CONFIG_HARDCODED_TABLES
{
int VAR_2;
const double VAR_3 = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1) * 2 * M_PI / VAR_0;
for (VAR_2 = 0; VAR_2 < (VAR_0 >> 2); VAR_2++)
s->tsin[VAR_2] = sin(VAR_2 * VAR_3);
}
#endif
s->rdft_calc = rdft_calc_c;
if (ARCH_ARM) ff_rdft_init_arm(s);
return 0;
}
| [
"av_cold int FUNC_0(RDFTContext *s, int nbits, enum RDFTransformType trans)\n{",
"int VAR_0 = 1 << nbits;",
"int VAR_1;",
"s->nbits = nbits;",
"s->inverse = trans == IDFT_C2R || trans == DFT_C2R;",
"s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;",
"if (nbits < 4 || nbits > 16)\nreturn AVERROR(EINVAL);",
"if ((VAR_1 = ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C)) < 0)\nreturn VAR_1;",
"ff_init_ff_cos_tabs(nbits);",
"s->tcos = ff_cos_tabs[nbits];",
"s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(VAR_0>>2);",
"#if !CONFIG_HARDCODED_TABLES\n{",
"int VAR_2;",
"const double VAR_3 = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1) * 2 * M_PI / VAR_0;",
"for (VAR_2 = 0; VAR_2 < (VAR_0 >> 2); VAR_2++)",
"s->tsin[VAR_2] = sin(VAR_2 * VAR_3);",
"}",
"#endif\ns->rdft_calc = rdft_calc_c;",
"if (ARCH_ARM) ff_rdft_init_arm(s);",
"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
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25,
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
57
],
[
61
],
[
63
]
]
|
10,453 | static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *int_mask)
{
UHCIAsync *async;
int len = 0, max_len;
uint8_t pid;
USBDevice *dev;
USBEndpoint *ep;
/* Is active ? */
if (!(td->ctrl & TD_CTRL_ACTIVE))
return TD_RESULT_NEXT_QH;
async = uhci_async_find_td(s, addr, td);
if (async) {
/* Already submitted */
async->queue->valid = 32;
if (!async->done)
return TD_RESULT_ASYNC_CONT;
uhci_async_unlink(async);
goto done;
}
/* Allocate new packet */
async = uhci_async_alloc(uhci_queue_get(s, td), addr);
if (!async)
return TD_RESULT_NEXT_QH;
/* valid needs to be large enough to handle 10 frame delay
* for initial isochronous requests
*/
async->queue->valid = 32;
async->isoc = td->ctrl & TD_CTRL_IOS;
max_len = ((td->token >> 21) + 1) & 0x7ff;
pid = td->token & 0xff;
dev = uhci_find_device(s, (td->token >> 8) & 0x7f);
ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf);
usb_packet_setup(&async->packet, pid, ep);
qemu_sglist_add(&async->sgl, td->buffer, max_len);
usb_packet_map(&async->packet, &async->sgl);
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
len = usb_handle_packet(dev, &async->packet);
if (len >= 0)
len = max_len;
break;
case USB_TOKEN_IN:
len = usb_handle_packet(dev, &async->packet);
break;
default:
/* invalid pid : frame interrupted */
uhci_async_free(async);
s->status |= UHCI_STS_HCPERR;
uhci_update_irq(s);
return TD_RESULT_STOP_FRAME;
}
if (len == USB_RET_ASYNC) {
uhci_async_link(async);
return TD_RESULT_ASYNC_START;
}
async->packet.result = len;
done:
len = uhci_complete_td(s, td, async, int_mask);
usb_packet_unmap(&async->packet);
uhci_async_free(async);
return len;
}
| true | qemu | 6c60134091cb2754d810b012773754967d8bbf92 | static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *int_mask)
{
UHCIAsync *async;
int len = 0, max_len;
uint8_t pid;
USBDevice *dev;
USBEndpoint *ep;
if (!(td->ctrl & TD_CTRL_ACTIVE))
return TD_RESULT_NEXT_QH;
async = uhci_async_find_td(s, addr, td);
if (async) {
async->queue->valid = 32;
if (!async->done)
return TD_RESULT_ASYNC_CONT;
uhci_async_unlink(async);
goto done;
}
async = uhci_async_alloc(uhci_queue_get(s, td), addr);
if (!async)
return TD_RESULT_NEXT_QH;
async->queue->valid = 32;
async->isoc = td->ctrl & TD_CTRL_IOS;
max_len = ((td->token >> 21) + 1) & 0x7ff;
pid = td->token & 0xff;
dev = uhci_find_device(s, (td->token >> 8) & 0x7f);
ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf);
usb_packet_setup(&async->packet, pid, ep);
qemu_sglist_add(&async->sgl, td->buffer, max_len);
usb_packet_map(&async->packet, &async->sgl);
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
len = usb_handle_packet(dev, &async->packet);
if (len >= 0)
len = max_len;
break;
case USB_TOKEN_IN:
len = usb_handle_packet(dev, &async->packet);
break;
default:
uhci_async_free(async);
s->status |= UHCI_STS_HCPERR;
uhci_update_irq(s);
return TD_RESULT_STOP_FRAME;
}
if (len == USB_RET_ASYNC) {
uhci_async_link(async);
return TD_RESULT_ASYNC_START;
}
async->packet.result = len;
done:
len = uhci_complete_td(s, td, async, int_mask);
usb_packet_unmap(&async->packet);
uhci_async_free(async);
return len;
}
| {
"code": [
" if (!async)",
" return TD_RESULT_NEXT_QH;"
],
"line_no": [
53,
21
]
} | static int FUNC_0(UHCIState *VAR_0, uint32_t VAR_1, UHCI_TD *VAR_2, uint32_t *VAR_3)
{
UHCIAsync *async;
int VAR_4 = 0, VAR_5;
uint8_t pid;
USBDevice *dev;
USBEndpoint *ep;
if (!(VAR_2->ctrl & TD_CTRL_ACTIVE))
return TD_RESULT_NEXT_QH;
async = uhci_async_find_td(VAR_0, VAR_1, VAR_2);
if (async) {
async->queue->valid = 32;
if (!async->done)
return TD_RESULT_ASYNC_CONT;
uhci_async_unlink(async);
goto done;
}
async = uhci_async_alloc(uhci_queue_get(VAR_0, VAR_2), VAR_1);
if (!async)
return TD_RESULT_NEXT_QH;
async->queue->valid = 32;
async->isoc = VAR_2->ctrl & TD_CTRL_IOS;
VAR_5 = ((VAR_2->token >> 21) + 1) & 0x7ff;
pid = VAR_2->token & 0xff;
dev = uhci_find_device(VAR_0, (VAR_2->token >> 8) & 0x7f);
ep = usb_ep_get(dev, pid, (VAR_2->token >> 15) & 0xf);
usb_packet_setup(&async->packet, pid, ep);
qemu_sglist_add(&async->sgl, VAR_2->buffer, VAR_5);
usb_packet_map(&async->packet, &async->sgl);
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
VAR_4 = usb_handle_packet(dev, &async->packet);
if (VAR_4 >= 0)
VAR_4 = VAR_5;
break;
case USB_TOKEN_IN:
VAR_4 = usb_handle_packet(dev, &async->packet);
break;
default:
uhci_async_free(async);
VAR_0->status |= UHCI_STS_HCPERR;
uhci_update_irq(VAR_0);
return TD_RESULT_STOP_FRAME;
}
if (VAR_4 == USB_RET_ASYNC) {
uhci_async_link(async);
return TD_RESULT_ASYNC_START;
}
async->packet.result = VAR_4;
done:
VAR_4 = uhci_complete_td(VAR_0, VAR_2, async, VAR_3);
usb_packet_unmap(&async->packet);
uhci_async_free(async);
return VAR_4;
}
| [
"static int FUNC_0(UHCIState *VAR_0, uint32_t VAR_1, UHCI_TD *VAR_2, uint32_t *VAR_3)\n{",
"UHCIAsync *async;",
"int VAR_4 = 0, VAR_5;",
"uint8_t pid;",
"USBDevice *dev;",
"USBEndpoint *ep;",
"if (!(VAR_2->ctrl & TD_CTRL_ACTIVE))\nreturn TD_RESULT_NEXT_QH;",
"async = uhci_async_find_td(VAR_0, VAR_1, VAR_2);",
"if (async) {",
"async->queue->valid = 32;",
"if (!async->done)\nreturn TD_RESULT_ASYNC_CONT;",
"uhci_async_unlink(async);",
"goto done;",
"}",
"async = uhci_async_alloc(uhci_queue_get(VAR_0, VAR_2), VAR_1);",
"if (!async)\nreturn TD_RESULT_NEXT_QH;",
"async->queue->valid = 32;",
"async->isoc = VAR_2->ctrl & TD_CTRL_IOS;",
"VAR_5 = ((VAR_2->token >> 21) + 1) & 0x7ff;",
"pid = VAR_2->token & 0xff;",
"dev = uhci_find_device(VAR_0, (VAR_2->token >> 8) & 0x7f);",
"ep = usb_ep_get(dev, pid, (VAR_2->token >> 15) & 0xf);",
"usb_packet_setup(&async->packet, pid, ep);",
"qemu_sglist_add(&async->sgl, VAR_2->buffer, VAR_5);",
"usb_packet_map(&async->packet, &async->sgl);",
"switch(pid) {",
"case USB_TOKEN_OUT:\ncase USB_TOKEN_SETUP:\nVAR_4 = usb_handle_packet(dev, &async->packet);",
"if (VAR_4 >= 0)\nVAR_4 = VAR_5;",
"break;",
"case USB_TOKEN_IN:\nVAR_4 = usb_handle_packet(dev, &async->packet);",
"break;",
"default:\nuhci_async_free(async);",
"VAR_0->status |= UHCI_STS_HCPERR;",
"uhci_update_irq(VAR_0);",
"return TD_RESULT_STOP_FRAME;",
"}",
"if (VAR_4 == USB_RET_ASYNC) {",
"uhci_async_link(async);",
"return TD_RESULT_ASYNC_START;",
"}",
"async->packet.result = VAR_4;",
"done:\nVAR_4 = uhci_complete_td(VAR_0, VAR_2, async, VAR_3);",
"usb_packet_unmap(&async->packet);",
"uhci_async_free(async);",
"return VAR_4;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
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,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19,
21
],
[
25
],
[
27
],
[
31
],
[
35,
37
],
[
41
],
[
43
],
[
45
],
[
51
],
[
53,
55
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91,
93,
95
],
[
97,
99
],
[
101
],
[
105,
107
],
[
109
],
[
113,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
]
]
|
10,454 | static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_index)
{
if (s->correct_ts_overflow && st->pts_wrap_bits != 64 &&
st->pts_wrap_reference == AV_NOPTS_VALUE && st->first_dts != AV_NOPTS_VALUE) {
int i;
// reference time stamp should be 60 s before first time stamp
int64_t pts_wrap_reference = st->first_dts - av_rescale(60, st->time_base.den, st->time_base.num);
// if first time stamp is not more than 1/8 and 60s before the wrap point, subtract rather than add wrap offset
int pts_wrap_behavior = (st->first_dts < (1LL<<st->pts_wrap_bits) - (1LL<<st->pts_wrap_bits-3)) ||
(st->first_dts < (1LL<<st->pts_wrap_bits) - av_rescale(60, st->time_base.den, st->time_base.num)) ?
AV_PTS_WRAP_ADD_OFFSET : AV_PTS_WRAP_SUB_OFFSET;
AVProgram *first_program = av_find_program_from_stream(s, NULL, stream_index);
if (!first_program) {
int default_stream_index = av_find_default_stream_index(s);
if (s->streams[default_stream_index]->pts_wrap_reference == AV_NOPTS_VALUE) {
for (i=0; i<s->nb_streams; i++) {
s->streams[i]->pts_wrap_reference = pts_wrap_reference;
s->streams[i]->pts_wrap_behavior = pts_wrap_behavior;
}
}
else {
st->pts_wrap_reference = s->streams[default_stream_index]->pts_wrap_reference;
st->pts_wrap_behavior = s->streams[default_stream_index]->pts_wrap_behavior;
}
}
else {
AVProgram *program = first_program;
while (program) {
if (program->pts_wrap_reference != AV_NOPTS_VALUE) {
pts_wrap_reference = program->pts_wrap_reference;
pts_wrap_behavior = program->pts_wrap_behavior;
break;
}
program = av_find_program_from_stream(s, program, stream_index);
}
// update every program with differing pts_wrap_reference
program = first_program;
while(program) {
if (program->pts_wrap_reference != pts_wrap_reference) {
for (i=0; i<program->nb_stream_indexes; i++) {
s->streams[program->stream_index[i]]->pts_wrap_reference = pts_wrap_reference;
s->streams[program->stream_index[i]]->pts_wrap_behavior = pts_wrap_behavior;
}
program->pts_wrap_reference = pts_wrap_reference;
program->pts_wrap_behavior = pts_wrap_behavior;
}
program = av_find_program_from_stream(s, program, stream_index);
}
}
return 1;
}
return 0;
}
| true | FFmpeg | 1662bd350a470f1cbd5c2cc9a0e1bfaa8543033f | static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_index)
{
if (s->correct_ts_overflow && st->pts_wrap_bits != 64 &&
st->pts_wrap_reference == AV_NOPTS_VALUE && st->first_dts != AV_NOPTS_VALUE) {
int i;
int64_t pts_wrap_reference = st->first_dts - av_rescale(60, st->time_base.den, st->time_base.num);
int pts_wrap_behavior = (st->first_dts < (1LL<<st->pts_wrap_bits) - (1LL<<st->pts_wrap_bits-3)) ||
(st->first_dts < (1LL<<st->pts_wrap_bits) - av_rescale(60, st->time_base.den, st->time_base.num)) ?
AV_PTS_WRAP_ADD_OFFSET : AV_PTS_WRAP_SUB_OFFSET;
AVProgram *first_program = av_find_program_from_stream(s, NULL, stream_index);
if (!first_program) {
int default_stream_index = av_find_default_stream_index(s);
if (s->streams[default_stream_index]->pts_wrap_reference == AV_NOPTS_VALUE) {
for (i=0; i<s->nb_streams; i++) {
s->streams[i]->pts_wrap_reference = pts_wrap_reference;
s->streams[i]->pts_wrap_behavior = pts_wrap_behavior;
}
}
else {
st->pts_wrap_reference = s->streams[default_stream_index]->pts_wrap_reference;
st->pts_wrap_behavior = s->streams[default_stream_index]->pts_wrap_behavior;
}
}
else {
AVProgram *program = first_program;
while (program) {
if (program->pts_wrap_reference != AV_NOPTS_VALUE) {
pts_wrap_reference = program->pts_wrap_reference;
pts_wrap_behavior = program->pts_wrap_behavior;
break;
}
program = av_find_program_from_stream(s, program, stream_index);
}
program = first_program;
while(program) {
if (program->pts_wrap_reference != pts_wrap_reference) {
for (i=0; i<program->nb_stream_indexes; i++) {
s->streams[program->stream_index[i]]->pts_wrap_reference = pts_wrap_reference;
s->streams[program->stream_index[i]]->pts_wrap_behavior = pts_wrap_behavior;
}
program->pts_wrap_reference = pts_wrap_reference;
program->pts_wrap_behavior = pts_wrap_behavior;
}
program = av_find_program_from_stream(s, program, stream_index);
}
}
return 1;
}
return 0;
}
| {
"code": [
" if (s->correct_ts_overflow && st->pts_wrap_bits != 64 &&"
],
"line_no": [
5
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, int VAR_2)
{
if (VAR_0->correct_ts_overflow && VAR_1->pts_wrap_bits != 64 &&
VAR_1->pts_wrap_reference == AV_NOPTS_VALUE && VAR_1->first_dts != AV_NOPTS_VALUE) {
int VAR_3;
int64_t pts_wrap_reference = VAR_1->first_dts - av_rescale(60, VAR_1->time_base.den, VAR_1->time_base.num);
int VAR_4 = (VAR_1->first_dts < (1LL<<VAR_1->pts_wrap_bits) - (1LL<<VAR_1->pts_wrap_bits-3)) ||
(VAR_1->first_dts < (1LL<<VAR_1->pts_wrap_bits) - av_rescale(60, VAR_1->time_base.den, VAR_1->time_base.num)) ?
AV_PTS_WRAP_ADD_OFFSET : AV_PTS_WRAP_SUB_OFFSET;
AVProgram *first_program = av_find_program_from_stream(VAR_0, NULL, VAR_2);
if (!first_program) {
int VAR_5 = av_find_default_stream_index(VAR_0);
if (VAR_0->streams[VAR_5]->pts_wrap_reference == AV_NOPTS_VALUE) {
for (VAR_3=0; VAR_3<VAR_0->nb_streams; VAR_3++) {
VAR_0->streams[VAR_3]->pts_wrap_reference = pts_wrap_reference;
VAR_0->streams[VAR_3]->VAR_4 = VAR_4;
}
}
else {
VAR_1->pts_wrap_reference = VAR_0->streams[VAR_5]->pts_wrap_reference;
VAR_1->VAR_4 = VAR_0->streams[VAR_5]->VAR_4;
}
}
else {
AVProgram *program = first_program;
while (program) {
if (program->pts_wrap_reference != AV_NOPTS_VALUE) {
pts_wrap_reference = program->pts_wrap_reference;
VAR_4 = program->VAR_4;
break;
}
program = av_find_program_from_stream(VAR_0, program, VAR_2);
}
program = first_program;
while(program) {
if (program->pts_wrap_reference != pts_wrap_reference) {
for (VAR_3=0; VAR_3<program->nb_stream_indexes; VAR_3++) {
VAR_0->streams[program->VAR_2[VAR_3]]->pts_wrap_reference = pts_wrap_reference;
VAR_0->streams[program->VAR_2[VAR_3]]->VAR_4 = VAR_4;
}
program->pts_wrap_reference = pts_wrap_reference;
program->VAR_4 = VAR_4;
}
program = av_find_program_from_stream(VAR_0, program, VAR_2);
}
}
return 1;
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, int VAR_2)\n{",
"if (VAR_0->correct_ts_overflow && VAR_1->pts_wrap_bits != 64 &&\nVAR_1->pts_wrap_reference == AV_NOPTS_VALUE && VAR_1->first_dts != AV_NOPTS_VALUE) {",
"int VAR_3;",
"int64_t pts_wrap_reference = VAR_1->first_dts - av_rescale(60, VAR_1->time_base.den, VAR_1->time_base.num);",
"int VAR_4 = (VAR_1->first_dts < (1LL<<VAR_1->pts_wrap_bits) - (1LL<<VAR_1->pts_wrap_bits-3)) ||\n(VAR_1->first_dts < (1LL<<VAR_1->pts_wrap_bits) - av_rescale(60, VAR_1->time_base.den, VAR_1->time_base.num)) ?\nAV_PTS_WRAP_ADD_OFFSET : AV_PTS_WRAP_SUB_OFFSET;",
"AVProgram *first_program = av_find_program_from_stream(VAR_0, NULL, VAR_2);",
"if (!first_program) {",
"int VAR_5 = av_find_default_stream_index(VAR_0);",
"if (VAR_0->streams[VAR_5]->pts_wrap_reference == AV_NOPTS_VALUE) {",
"for (VAR_3=0; VAR_3<VAR_0->nb_streams; VAR_3++) {",
"VAR_0->streams[VAR_3]->pts_wrap_reference = pts_wrap_reference;",
"VAR_0->streams[VAR_3]->VAR_4 = VAR_4;",
"}",
"}",
"else {",
"VAR_1->pts_wrap_reference = VAR_0->streams[VAR_5]->pts_wrap_reference;",
"VAR_1->VAR_4 = VAR_0->streams[VAR_5]->VAR_4;",
"}",
"}",
"else {",
"AVProgram *program = first_program;",
"while (program) {",
"if (program->pts_wrap_reference != AV_NOPTS_VALUE) {",
"pts_wrap_reference = program->pts_wrap_reference;",
"VAR_4 = program->VAR_4;",
"break;",
"}",
"program = av_find_program_from_stream(VAR_0, program, VAR_2);",
"}",
"program = first_program;",
"while(program) {",
"if (program->pts_wrap_reference != pts_wrap_reference) {",
"for (VAR_3=0; VAR_3<program->nb_stream_indexes; VAR_3++) {",
"VAR_0->streams[program->VAR_2[VAR_3]]->pts_wrap_reference = pts_wrap_reference;",
"VAR_0->streams[program->VAR_2[VAR_3]]->VAR_4 = VAR_4;",
"}",
"program->pts_wrap_reference = pts_wrap_reference;",
"program->VAR_4 = VAR_4;",
"}",
"program = av_find_program_from_stream(VAR_0, program, VAR_2);",
"}",
"}",
"return 1;",
"}",
"return 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5,
7
],
[
9
],
[
15
],
[
19,
21,
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
]
]
|
10,455 | static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
{
PtyCharDriver *s = chr->opaque;
if (!s->connected) {
/* guest sends data, check for (re-)connect */
pty_chr_update_read_handler_locked(chr);
return 0;
}
return io_channel_send(s->fd, buf, len);
}
| true | qemu | cf7330c759345de2efe9c0df7921189ac5ff11d3 | static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
{
PtyCharDriver *s = chr->opaque;
if (!s->connected) {
pty_chr_update_read_handler_locked(chr);
return 0;
}
return io_channel_send(s->fd, buf, len);
}
| {
"code": [
" return 0;"
],
"line_no": [
15
]
} | static int FUNC_0(CharDriverState *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
PtyCharDriver *s = VAR_0->opaque;
if (!s->connected) {
pty_chr_update_read_handler_locked(VAR_0);
return 0;
}
return io_channel_send(s->fd, VAR_1, VAR_2);
}
| [
"static int FUNC_0(CharDriverState *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"PtyCharDriver *s = VAR_0->opaque;",
"if (!s->connected) {",
"pty_chr_update_read_handler_locked(VAR_0);",
"return 0;",
"}",
"return io_channel_send(s->fd, VAR_1, VAR_2);",
"}"
]
| [
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
]
|
10,456 | int vnc_client_io_error(VncState *vs, int ret, int last_errno)
{
if (ret == 0 || ret == -1) {
if (ret == -1) {
switch (last_errno) {
case EINTR:
case EAGAIN:
#ifdef _WIN32
case WSAEWOULDBLOCK:
#endif
return 0;
default:
break;
}
}
VNC_DEBUG("Closing down client sock %d %d\n", ret, ret < 0 ? last_errno : 0);
qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL);
closesocket(vs->csock);
qemu_del_timer(vs->timer);
qemu_free_timer(vs->timer);
if (vs->input.buffer) qemu_free(vs->input.buffer);
if (vs->output.buffer) qemu_free(vs->output.buffer);
#ifdef CONFIG_VNC_TLS
vnc_tls_client_cleanup(vs);
#endif /* CONFIG_VNC_TLS */
#ifdef CONFIG_VNC_SASL
vnc_sasl_client_cleanup(vs);
#endif /* CONFIG_VNC_SASL */
audio_del(vs);
VncState *p, *parent = NULL;
for (p = vs->vd->clients; p != NULL; p = p->next) {
if (p == vs) {
if (parent)
parent->next = p->next;
else
vs->vd->clients = p->next;
break;
}
parent = p;
}
if (!vs->vd->clients)
dcl->idle = 1;
qemu_free(vs->server.ds->data);
qemu_free(vs->server.ds);
qemu_free(vs->guest.ds);
qemu_free(vs);
return 0;
}
return ret;
}
| true | qemu | 198a0039c5fca224a77e9761e2350dd9cc102ad0 | int vnc_client_io_error(VncState *vs, int ret, int last_errno)
{
if (ret == 0 || ret == -1) {
if (ret == -1) {
switch (last_errno) {
case EINTR:
case EAGAIN:
#ifdef _WIN32
case WSAEWOULDBLOCK:
#endif
return 0;
default:
break;
}
}
VNC_DEBUG("Closing down client sock %d %d\n", ret, ret < 0 ? last_errno : 0);
qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL);
closesocket(vs->csock);
qemu_del_timer(vs->timer);
qemu_free_timer(vs->timer);
if (vs->input.buffer) qemu_free(vs->input.buffer);
if (vs->output.buffer) qemu_free(vs->output.buffer);
#ifdef CONFIG_VNC_TLS
vnc_tls_client_cleanup(vs);
#endif
#ifdef CONFIG_VNC_SASL
vnc_sasl_client_cleanup(vs);
#endif
audio_del(vs);
VncState *p, *parent = NULL;
for (p = vs->vd->clients; p != NULL; p = p->next) {
if (p == vs) {
if (parent)
parent->next = p->next;
else
vs->vd->clients = p->next;
break;
}
parent = p;
}
if (!vs->vd->clients)
dcl->idle = 1;
qemu_free(vs->server.ds->data);
qemu_free(vs->server.ds);
qemu_free(vs->guest.ds);
qemu_free(vs);
return 0;
}
return ret;
}
| {
"code": [
" VNC_DEBUG(\"Closing down client sock %d %d\\n\", ret, ret < 0 ? last_errno : 0);",
" qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL);",
" closesocket(vs->csock);",
" qemu_del_timer(vs->timer);",
" qemu_free_timer(vs->timer);",
" if (vs->input.buffer) qemu_free(vs->input.buffer);",
" if (vs->output.buffer) qemu_free(vs->output.buffer);",
"#ifdef CONFIG_VNC_TLS",
" vnc_tls_client_cleanup(vs);",
"#ifdef CONFIG_VNC_SASL",
" vnc_sasl_client_cleanup(vs);",
" audio_del(vs);",
" VncState *p, *parent = NULL;",
" for (p = vs->vd->clients; p != NULL; p = p->next) {",
" if (p == vs) {",
" if (parent)",
" parent->next = p->next;",
" vs->vd->clients = p->next;",
" break;",
" parent = p;",
" if (!vs->vd->clients)",
" dcl->idle = 1;",
" qemu_free(vs->server.ds->data);",
" qemu_free(vs->server.ds);",
" qemu_free(vs->guest.ds);",
" qemu_free(vs);"
],
"line_no": [
33,
35,
37,
39,
41,
43,
45,
47,
49,
53,
55,
59,
63,
65,
67,
69,
71,
75,
77,
81,
85,
87,
91,
93,
95,
97
]
} | int FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2)
{
if (VAR_1 == 0 || VAR_1 == -1) {
if (VAR_1 == -1) {
switch (VAR_2) {
case EINTR:
case EAGAIN:
#ifdef _WIN32
case WSAEWOULDBLOCK:
#endif
return 0;
default:
break;
}
}
VNC_DEBUG("Closing down client sock %d %d\n", VAR_1, VAR_1 < 0 ? VAR_2 : 0);
qemu_set_fd_handler2(VAR_0->csock, NULL, NULL, NULL, NULL);
closesocket(VAR_0->csock);
qemu_del_timer(VAR_0->timer);
qemu_free_timer(VAR_0->timer);
if (VAR_0->input.buffer) qemu_free(VAR_0->input.buffer);
if (VAR_0->output.buffer) qemu_free(VAR_0->output.buffer);
#ifdef CONFIG_VNC_TLS
vnc_tls_client_cleanup(VAR_0);
#endif
#ifdef CONFIG_VNC_SASL
vnc_sasl_client_cleanup(VAR_0);
#endif
audio_del(VAR_0);
VncState *p, *parent = NULL;
for (p = VAR_0->vd->clients; p != NULL; p = p->next) {
if (p == VAR_0) {
if (parent)
parent->next = p->next;
else
VAR_0->vd->clients = p->next;
break;
}
parent = p;
}
if (!VAR_0->vd->clients)
dcl->idle = 1;
qemu_free(VAR_0->server.ds->data);
qemu_free(VAR_0->server.ds);
qemu_free(VAR_0->guest.ds);
qemu_free(VAR_0);
return 0;
}
return VAR_1;
}
| [
"int FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2)\n{",
"if (VAR_1 == 0 || VAR_1 == -1) {",
"if (VAR_1 == -1) {",
"switch (VAR_2) {",
"case EINTR:\ncase EAGAIN:\n#ifdef _WIN32\ncase WSAEWOULDBLOCK:\n#endif\nreturn 0;",
"default:\nbreak;",
"}",
"}",
"VNC_DEBUG(\"Closing down client sock %d %d\\n\", VAR_1, VAR_1 < 0 ? VAR_2 : 0);",
"qemu_set_fd_handler2(VAR_0->csock, NULL, NULL, NULL, NULL);",
"closesocket(VAR_0->csock);",
"qemu_del_timer(VAR_0->timer);",
"qemu_free_timer(VAR_0->timer);",
"if (VAR_0->input.buffer) qemu_free(VAR_0->input.buffer);",
"if (VAR_0->output.buffer) qemu_free(VAR_0->output.buffer);",
"#ifdef CONFIG_VNC_TLS\nvnc_tls_client_cleanup(VAR_0);",
"#endif\n#ifdef CONFIG_VNC_SASL\nvnc_sasl_client_cleanup(VAR_0);",
"#endif\naudio_del(VAR_0);",
"VncState *p, *parent = NULL;",
"for (p = VAR_0->vd->clients; p != NULL; p = p->next) {",
"if (p == VAR_0) {",
"if (parent)\nparent->next = p->next;",
"else\nVAR_0->vd->clients = p->next;",
"break;",
"}",
"parent = p;",
"}",
"if (!VAR_0->vd->clients)\ndcl->idle = 1;",
"qemu_free(VAR_0->server.ds->data);",
"qemu_free(VAR_0->server.ds);",
"qemu_free(VAR_0->guest.ds);",
"qemu_free(VAR_0);",
"return 0;",
"}",
"return VAR_1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
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
],
[
45
],
[
47,
49
],
[
51,
53,
55
],
[
57,
59
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.