id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
19,374 | bool aio_dispatch(AioContext *ctx)
{
bool progress;
progress = aio_bh_poll(ctx);
progress |= aio_dispatch_handlers(ctx, INVALID_HANDLE_VALUE);
progress |= timerlistgroup_run_timers(&ctx->tlg);
return progress;
}
| false | qemu | 721671ade77f4046b45893fbb7864ca84b9504cd | bool aio_dispatch(AioContext *ctx)
{
bool progress;
progress = aio_bh_poll(ctx);
progress |= aio_dispatch_handlers(ctx, INVALID_HANDLE_VALUE);
progress |= timerlistgroup_run_timers(&ctx->tlg);
return progress;
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(AioContext *ctx)
{
bool progress;
progress = aio_bh_poll(ctx);
progress |= aio_dispatch_handlers(ctx, INVALID_HANDLE_VALUE);
progress |= timerlistgroup_run_timers(&ctx->tlg);
return progress;
}
| [
"bool FUNC_0(AioContext *ctx)\n{",
"bool progress;",
"progress = aio_bh_poll(ctx);",
"progress |= aio_dispatch_handlers(ctx, INVALID_HANDLE_VALUE);",
"progress |= timerlistgroup_run_timers(&ctx->tlg);",
"return progress;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
19,375 | static void sm501_draw_crt(SM501State *s)
{
DisplaySurface *surface = qemu_console_surface(s->con);
int y, c_x = 0, c_y = 0;
uint8_t *hwc_src = NULL, *src = s->local_mem;
int width = get_width(s, 1);
int height = get_height(s, 1);
int src_bpp = get_bpp(s, 1);
int dst_bpp = surface_bytes_per_pixel(surface);
uint32_t *palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE -
SM501_DC_PANEL_PALETTE];
uint8_t hwc_palette[3 * 3];
int ds_depth_index = get_depth_index(surface);
draw_line_func *draw_line = NULL;
draw_hwc_line_func *draw_hwc_line = NULL;
int full_update = 0;
int y_start = -1;
ram_addr_t page_min = ~0l;
ram_addr_t page_max = 0l;
ram_addr_t offset = 0;
/* choose draw_line function */
switch (src_bpp) {
case 1:
draw_line = draw_line8_funcs[ds_depth_index];
break;
case 2:
draw_line = draw_line16_funcs[ds_depth_index];
break;
case 4:
draw_line = draw_line32_funcs[ds_depth_index];
break;
default:
printf("sm501 draw crt : invalid DC_CRT_CONTROL=%x.\n",
s->dc_crt_control);
abort();
break;
}
/* set up to draw hardware cursor */
if (is_hwc_enabled(s, 1)) {
/* choose cursor draw line function */
draw_hwc_line = draw_hwc_line_funcs[ds_depth_index];
hwc_src = get_hwc_address(s, 1);
c_x = get_hwc_x(s, 1);
c_y = get_hwc_y(s, 1);
get_hwc_palette(s, 1, hwc_palette);
}
/* adjust console size */
if (s->last_width != width || s->last_height != height) {
qemu_console_resize(s->con, width, height);
surface = qemu_console_surface(s->con);
s->last_width = width;
s->last_height = height;
full_update = 1;
}
/* draw each line according to conditions */
memory_region_sync_dirty_bitmap(&s->local_mem_region);
for (y = 0; y < height; y++) {
int update, update_hwc;
ram_addr_t page0 = offset;
ram_addr_t page1 = offset + width * src_bpp - 1;
/* check if hardware cursor is enabled and we're within its range */
update_hwc = draw_hwc_line && c_y <= y && y < c_y + SM501_HWC_HEIGHT;
update = full_update || update_hwc;
/* check dirty flags for each line */
update |= memory_region_get_dirty(&s->local_mem_region, page0,
page1 - page0, DIRTY_MEMORY_VGA);
/* draw line and change status */
if (update) {
uint8_t *d = surface_data(surface);
d += y * width * dst_bpp;
/* draw graphics layer */
draw_line(d, src, width, palette);
/* draw hardware cursor */
if (update_hwc) {
draw_hwc_line(d, hwc_src, width, hwc_palette, c_x, y - c_y);
}
if (y_start < 0) {
y_start = y;
}
if (page0 < page_min) {
page_min = page0;
}
if (page1 > page_max) {
page_max = page1;
}
} else {
if (y_start >= 0) {
/* flush to display */
dpy_gfx_update(s->con, 0, y_start, width, y - y_start);
y_start = -1;
}
}
src += width * src_bpp;
offset += width * src_bpp;
}
/* complete flush to display */
if (y_start >= 0) {
dpy_gfx_update(s->con, 0, y_start, width, y - y_start);
}
/* clear dirty flags */
if (page_min != ~0l) {
memory_region_reset_dirty(&s->local_mem_region,
page_min, page_max + TARGET_PAGE_SIZE,
DIRTY_MEMORY_VGA);
}
}
| false | qemu | 01d2d584c9e1d051892de115ab20787da62baf6a | static void sm501_draw_crt(SM501State *s)
{
DisplaySurface *surface = qemu_console_surface(s->con);
int y, c_x = 0, c_y = 0;
uint8_t *hwc_src = NULL, *src = s->local_mem;
int width = get_width(s, 1);
int height = get_height(s, 1);
int src_bpp = get_bpp(s, 1);
int dst_bpp = surface_bytes_per_pixel(surface);
uint32_t *palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE -
SM501_DC_PANEL_PALETTE];
uint8_t hwc_palette[3 * 3];
int ds_depth_index = get_depth_index(surface);
draw_line_func *draw_line = NULL;
draw_hwc_line_func *draw_hwc_line = NULL;
int full_update = 0;
int y_start = -1;
ram_addr_t page_min = ~0l;
ram_addr_t page_max = 0l;
ram_addr_t offset = 0;
switch (src_bpp) {
case 1:
draw_line = draw_line8_funcs[ds_depth_index];
break;
case 2:
draw_line = draw_line16_funcs[ds_depth_index];
break;
case 4:
draw_line = draw_line32_funcs[ds_depth_index];
break;
default:
printf("sm501 draw crt : invalid DC_CRT_CONTROL=%x.\n",
s->dc_crt_control);
abort();
break;
}
if (is_hwc_enabled(s, 1)) {
draw_hwc_line = draw_hwc_line_funcs[ds_depth_index];
hwc_src = get_hwc_address(s, 1);
c_x = get_hwc_x(s, 1);
c_y = get_hwc_y(s, 1);
get_hwc_palette(s, 1, hwc_palette);
}
if (s->last_width != width || s->last_height != height) {
qemu_console_resize(s->con, width, height);
surface = qemu_console_surface(s->con);
s->last_width = width;
s->last_height = height;
full_update = 1;
}
memory_region_sync_dirty_bitmap(&s->local_mem_region);
for (y = 0; y < height; y++) {
int update, update_hwc;
ram_addr_t page0 = offset;
ram_addr_t page1 = offset + width * src_bpp - 1;
update_hwc = draw_hwc_line && c_y <= y && y < c_y + SM501_HWC_HEIGHT;
update = full_update || update_hwc;
update |= memory_region_get_dirty(&s->local_mem_region, page0,
page1 - page0, DIRTY_MEMORY_VGA);
if (update) {
uint8_t *d = surface_data(surface);
d += y * width * dst_bpp;
draw_line(d, src, width, palette);
if (update_hwc) {
draw_hwc_line(d, hwc_src, width, hwc_palette, c_x, y - c_y);
}
if (y_start < 0) {
y_start = y;
}
if (page0 < page_min) {
page_min = page0;
}
if (page1 > page_max) {
page_max = page1;
}
} else {
if (y_start >= 0) {
dpy_gfx_update(s->con, 0, y_start, width, y - y_start);
y_start = -1;
}
}
src += width * src_bpp;
offset += width * src_bpp;
}
if (y_start >= 0) {
dpy_gfx_update(s->con, 0, y_start, width, y - y_start);
}
if (page_min != ~0l) {
memory_region_reset_dirty(&s->local_mem_region,
page_min, page_max + TARGET_PAGE_SIZE,
DIRTY_MEMORY_VGA);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SM501State *VAR_0)
{
DisplaySurface *surface = qemu_console_surface(VAR_0->con);
int VAR_1, VAR_2 = 0, VAR_3 = 0;
uint8_t *hwc_src = NULL, *src = VAR_0->local_mem;
int VAR_4 = get_width(VAR_0, 1);
int VAR_5 = get_height(VAR_0, 1);
int VAR_6 = get_bpp(VAR_0, 1);
int VAR_7 = surface_bytes_per_pixel(surface);
uint32_t *palette = (uint32_t *)&VAR_0->dc_palette[SM501_DC_CRT_PALETTE -
SM501_DC_PANEL_PALETTE];
uint8_t hwc_palette[3 * 3];
int VAR_8 = get_depth_index(surface);
draw_line_func *draw_line = NULL;
draw_hwc_line_func *draw_hwc_line = NULL;
int VAR_9 = 0;
int VAR_10 = -1;
ram_addr_t page_min = ~0l;
ram_addr_t page_max = 0l;
ram_addr_t offset = 0;
switch (VAR_6) {
case 1:
draw_line = draw_line8_funcs[VAR_8];
break;
case 2:
draw_line = draw_line16_funcs[VAR_8];
break;
case 4:
draw_line = draw_line32_funcs[VAR_8];
break;
default:
printf("sm501 draw crt : invalid DC_CRT_CONTROL=%x.\n",
VAR_0->dc_crt_control);
abort();
break;
}
if (is_hwc_enabled(VAR_0, 1)) {
draw_hwc_line = draw_hwc_line_funcs[VAR_8];
hwc_src = get_hwc_address(VAR_0, 1);
VAR_2 = get_hwc_x(VAR_0, 1);
VAR_3 = get_hwc_y(VAR_0, 1);
get_hwc_palette(VAR_0, 1, hwc_palette);
}
if (VAR_0->last_width != VAR_4 || VAR_0->last_height != VAR_5) {
qemu_console_resize(VAR_0->con, VAR_4, VAR_5);
surface = qemu_console_surface(VAR_0->con);
VAR_0->last_width = VAR_4;
VAR_0->last_height = VAR_5;
VAR_9 = 1;
}
memory_region_sync_dirty_bitmap(&VAR_0->local_mem_region);
for (VAR_1 = 0; VAR_1 < VAR_5; VAR_1++) {
int VAR_11, VAR_12;
ram_addr_t page0 = offset;
ram_addr_t page1 = offset + VAR_4 * VAR_6 - 1;
VAR_12 = draw_hwc_line && VAR_3 <= VAR_1 && VAR_1 < VAR_3 + SM501_HWC_HEIGHT;
VAR_11 = VAR_9 || VAR_12;
VAR_11 |= memory_region_get_dirty(&VAR_0->local_mem_region, page0,
page1 - page0, DIRTY_MEMORY_VGA);
if (VAR_11) {
uint8_t *d = surface_data(surface);
d += VAR_1 * VAR_4 * VAR_7;
draw_line(d, src, VAR_4, palette);
if (VAR_12) {
draw_hwc_line(d, hwc_src, VAR_4, hwc_palette, VAR_2, VAR_1 - VAR_3);
}
if (VAR_10 < 0) {
VAR_10 = VAR_1;
}
if (page0 < page_min) {
page_min = page0;
}
if (page1 > page_max) {
page_max = page1;
}
} else {
if (VAR_10 >= 0) {
dpy_gfx_update(VAR_0->con, 0, VAR_10, VAR_4, VAR_1 - VAR_10);
VAR_10 = -1;
}
}
src += VAR_4 * VAR_6;
offset += VAR_4 * VAR_6;
}
if (VAR_10 >= 0) {
dpy_gfx_update(VAR_0->con, 0, VAR_10, VAR_4, VAR_1 - VAR_10);
}
if (page_min != ~0l) {
memory_region_reset_dirty(&VAR_0->local_mem_region,
page_min, page_max + TARGET_PAGE_SIZE,
DIRTY_MEMORY_VGA);
}
}
| [
"static void FUNC_0(SM501State *VAR_0)\n{",
"DisplaySurface *surface = qemu_console_surface(VAR_0->con);",
"int VAR_1, VAR_2 = 0, VAR_3 = 0;",
"uint8_t *hwc_src = NULL, *src = VAR_0->local_mem;",
"int VAR_4 = get_width(VAR_0, 1);",
"int VAR_5 = get_height(VAR_0, 1);",
"int VAR_6 = get_bpp(VAR_0, 1);",
"int VAR_7 = surface_bytes_per_pixel(surface);",
"uint32_t *palette = (uint32_t *)&VAR_0->dc_palette[SM501_DC_CRT_PALETTE -\nSM501_DC_PANEL_PALETTE];",
"uint8_t hwc_palette[3 * 3];",
"int VAR_8 = get_depth_index(surface);",
"draw_line_func *draw_line = NULL;",
"draw_hwc_line_func *draw_hwc_line = NULL;",
"int VAR_9 = 0;",
"int VAR_10 = -1;",
"ram_addr_t page_min = ~0l;",
"ram_addr_t page_max = 0l;",
"ram_addr_t offset = 0;",
"switch (VAR_6) {",
"case 1:\ndraw_line = draw_line8_funcs[VAR_8];",
"break;",
"case 2:\ndraw_line = draw_line16_funcs[VAR_8];",
"break;",
"case 4:\ndraw_line = draw_line32_funcs[VAR_8];",
"break;",
"default:\nprintf(\"sm501 draw crt : invalid DC_CRT_CONTROL=%x.\\n\",\nVAR_0->dc_crt_control);",
"abort();",
"break;",
"}",
"if (is_hwc_enabled(VAR_0, 1)) {",
"draw_hwc_line = draw_hwc_line_funcs[VAR_8];",
"hwc_src = get_hwc_address(VAR_0, 1);",
"VAR_2 = get_hwc_x(VAR_0, 1);",
"VAR_3 = get_hwc_y(VAR_0, 1);",
"get_hwc_palette(VAR_0, 1, hwc_palette);",
"}",
"if (VAR_0->last_width != VAR_4 || VAR_0->last_height != VAR_5) {",
"qemu_console_resize(VAR_0->con, VAR_4, VAR_5);",
"surface = qemu_console_surface(VAR_0->con);",
"VAR_0->last_width = VAR_4;",
"VAR_0->last_height = VAR_5;",
"VAR_9 = 1;",
"}",
"memory_region_sync_dirty_bitmap(&VAR_0->local_mem_region);",
"for (VAR_1 = 0; VAR_1 < VAR_5; VAR_1++) {",
"int VAR_11, VAR_12;",
"ram_addr_t page0 = offset;",
"ram_addr_t page1 = offset + VAR_4 * VAR_6 - 1;",
"VAR_12 = draw_hwc_line && VAR_3 <= VAR_1 && VAR_1 < VAR_3 + SM501_HWC_HEIGHT;",
"VAR_11 = VAR_9 || VAR_12;",
"VAR_11 |= memory_region_get_dirty(&VAR_0->local_mem_region, page0,\npage1 - page0, DIRTY_MEMORY_VGA);",
"if (VAR_11) {",
"uint8_t *d = surface_data(surface);",
"d += VAR_1 * VAR_4 * VAR_7;",
"draw_line(d, src, VAR_4, palette);",
"if (VAR_12) {",
"draw_hwc_line(d, hwc_src, VAR_4, hwc_palette, VAR_2, VAR_1 - VAR_3);",
"}",
"if (VAR_10 < 0) {",
"VAR_10 = VAR_1;",
"}",
"if (page0 < page_min) {",
"page_min = page0;",
"}",
"if (page1 > page_max) {",
"page_max = page1;",
"}",
"} else {",
"if (VAR_10 >= 0) {",
"dpy_gfx_update(VAR_0->con, 0, VAR_10, VAR_4, VAR_1 - VAR_10);",
"VAR_10 = -1;",
"}",
"}",
"src += VAR_4 * VAR_6;",
"offset += VAR_4 * VAR_6;",
"}",
"if (VAR_10 >= 0) {",
"dpy_gfx_update(VAR_0->con, 0, VAR_10, VAR_4, VAR_1 - VAR_10);",
"}",
"if (page_min != ~0l) {",
"memory_region_reset_dirty(&VAR_0->local_mem_region,\npage_min, page_max + TARGET_PAGE_SIZE,\nDIRTY_MEMORY_VGA);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37
],
[
39
],
[
45
],
[
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65,
67,
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
133
],
[
135
],
[
139,
141
],
[
147
],
[
149
],
[
151
],
[
157
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
215
],
[
217
],
[
219
],
[
225
],
[
227,
229,
231
],
[
233
],
[
235
]
] |
19,376 | static void test_io(void)
{
#ifndef _WIN32
/* socketpair(PF_UNIX) which does not exist on windows */
int sv[2];
int r;
unsigned i, j, k, s, t;
fd_set fds;
unsigned niov;
struct iovec *iov, *siov;
unsigned char *buf;
size_t sz;
iov_random(&iov, &niov);
sz = iov_size(iov, niov);
buf = g_malloc(sz);
for (i = 0; i < sz; ++i) {
buf[i] = i & 255;
}
iov_from_buf(iov, niov, 0, buf, sz);
siov = g_memdup(iov, sizeof(*iov) * niov);
if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) < 0) {
perror("socketpair");
exit(1);
}
FD_ZERO(&fds);
t = 0;
if (fork() == 0) {
/* writer */
close(sv[0]);
FD_SET(sv[1], &fds);
fcntl(sv[1], F_SETFL, O_RDWR|O_NONBLOCK);
r = g_test_rand_int_range(sz / 2, sz);
setsockopt(sv[1], SOL_SOCKET, SO_SNDBUF, &r, sizeof(r));
for (i = 0; i <= sz; ++i) {
for (j = i; j <= sz; ++j) {
k = i;
do {
s = g_test_rand_int_range(0, j - k + 1);
r = iov_send(sv[1], iov, niov, k, s);
g_assert(memcmp(iov, siov, sizeof(*iov)*niov) == 0);
if (r >= 0) {
k += r;
t += r;
usleep(g_test_rand_int_range(0, 30));
} else if (errno == EAGAIN) {
select(sv[1]+1, NULL, &fds, NULL, NULL);
continue;
} else {
perror("send");
exit(1);
}
} while(k < j);
}
}
iov_free(iov, niov);
g_free(buf);
g_free(siov);
exit(0);
} else {
/* reader & verifier */
close(sv[1]);
FD_SET(sv[0], &fds);
fcntl(sv[0], F_SETFL, O_RDWR|O_NONBLOCK);
r = g_test_rand_int_range(sz / 2, sz);
setsockopt(sv[0], SOL_SOCKET, SO_RCVBUF, &r, sizeof(r));
usleep(500000);
for (i = 0; i <= sz; ++i) {
for (j = i; j <= sz; ++j) {
k = i;
iov_memset(iov, niov, 0, 0xff, -1);
do {
s = g_test_rand_int_range(0, j - k + 1);
r = iov_recv(sv[0], iov, niov, k, s);
g_assert(memcmp(iov, siov, sizeof(*iov)*niov) == 0);
if (r > 0) {
k += r;
t += r;
} else if (!r) {
if (s) {
break;
}
} else if (errno == EAGAIN) {
select(sv[0]+1, &fds, NULL, NULL, NULL);
continue;
} else {
perror("recv");
exit(1);
}
} while(k < j);
test_iov_bytes(iov, niov, i, j - i);
}
}
iov_free(iov, niov);
g_free(buf);
g_free(siov);
}
#endif
}
| false | qemu | e3ff9f0e57472e6411dc446b41789cbd9e2cf887 | static void test_io(void)
{
#ifndef _WIN32
int sv[2];
int r;
unsigned i, j, k, s, t;
fd_set fds;
unsigned niov;
struct iovec *iov, *siov;
unsigned char *buf;
size_t sz;
iov_random(&iov, &niov);
sz = iov_size(iov, niov);
buf = g_malloc(sz);
for (i = 0; i < sz; ++i) {
buf[i] = i & 255;
}
iov_from_buf(iov, niov, 0, buf, sz);
siov = g_memdup(iov, sizeof(*iov) * niov);
if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) < 0) {
perror("socketpair");
exit(1);
}
FD_ZERO(&fds);
t = 0;
if (fork() == 0) {
close(sv[0]);
FD_SET(sv[1], &fds);
fcntl(sv[1], F_SETFL, O_RDWR|O_NONBLOCK);
r = g_test_rand_int_range(sz / 2, sz);
setsockopt(sv[1], SOL_SOCKET, SO_SNDBUF, &r, sizeof(r));
for (i = 0; i <= sz; ++i) {
for (j = i; j <= sz; ++j) {
k = i;
do {
s = g_test_rand_int_range(0, j - k + 1);
r = iov_send(sv[1], iov, niov, k, s);
g_assert(memcmp(iov, siov, sizeof(*iov)*niov) == 0);
if (r >= 0) {
k += r;
t += r;
usleep(g_test_rand_int_range(0, 30));
} else if (errno == EAGAIN) {
select(sv[1]+1, NULL, &fds, NULL, NULL);
continue;
} else {
perror("send");
exit(1);
}
} while(k < j);
}
}
iov_free(iov, niov);
g_free(buf);
g_free(siov);
exit(0);
} else {
close(sv[1]);
FD_SET(sv[0], &fds);
fcntl(sv[0], F_SETFL, O_RDWR|O_NONBLOCK);
r = g_test_rand_int_range(sz / 2, sz);
setsockopt(sv[0], SOL_SOCKET, SO_RCVBUF, &r, sizeof(r));
usleep(500000);
for (i = 0; i <= sz; ++i) {
for (j = i; j <= sz; ++j) {
k = i;
iov_memset(iov, niov, 0, 0xff, -1);
do {
s = g_test_rand_int_range(0, j - k + 1);
r = iov_recv(sv[0], iov, niov, k, s);
g_assert(memcmp(iov, siov, sizeof(*iov)*niov) == 0);
if (r > 0) {
k += r;
t += r;
} else if (!r) {
if (s) {
break;
}
} else if (errno == EAGAIN) {
select(sv[0]+1, &fds, NULL, NULL, NULL);
continue;
} else {
perror("recv");
exit(1);
}
} while(k < j);
test_iov_bytes(iov, niov, i, j - i);
}
}
iov_free(iov, niov);
g_free(buf);
g_free(siov);
}
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
#ifndef _WIN32
int VAR_0[2];
int VAR_1;
unsigned VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;
fd_set fds;
unsigned VAR_7;
struct iovec *VAR_8, *VAR_9;
unsigned char *VAR_10;
size_t sz;
iov_random(&VAR_8, &VAR_7);
sz = iov_size(VAR_8, VAR_7);
VAR_10 = g_malloc(sz);
for (VAR_2 = 0; VAR_2 < sz; ++VAR_2) {
VAR_10[VAR_2] = VAR_2 & 255;
}
iov_from_buf(VAR_8, VAR_7, 0, VAR_10, sz);
VAR_9 = g_memdup(VAR_8, sizeof(*VAR_8) * VAR_7);
if (socketpair(PF_UNIX, SOCK_STREAM, 0, VAR_0) < 0) {
perror("socketpair");
exit(1);
}
FD_ZERO(&fds);
VAR_6 = 0;
if (fork() == 0) {
close(VAR_0[0]);
FD_SET(VAR_0[1], &fds);
fcntl(VAR_0[1], F_SETFL, O_RDWR|O_NONBLOCK);
VAR_1 = g_test_rand_int_range(sz / 2, sz);
setsockopt(VAR_0[1], SOL_SOCKET, SO_SNDBUF, &VAR_1, sizeof(VAR_1));
for (VAR_2 = 0; VAR_2 <= sz; ++VAR_2) {
for (VAR_3 = VAR_2; VAR_3 <= sz; ++VAR_3) {
VAR_4 = VAR_2;
do {
VAR_5 = g_test_rand_int_range(0, VAR_3 - VAR_4 + 1);
VAR_1 = iov_send(VAR_0[1], VAR_8, VAR_7, VAR_4, VAR_5);
g_assert(memcmp(VAR_8, VAR_9, sizeof(*VAR_8)*VAR_7) == 0);
if (VAR_1 >= 0) {
VAR_4 += VAR_1;
VAR_6 += VAR_1;
usleep(g_test_rand_int_range(0, 30));
} else if (errno == EAGAIN) {
select(VAR_0[1]+1, NULL, &fds, NULL, NULL);
continue;
} else {
perror("send");
exit(1);
}
} while(VAR_4 < VAR_3);
}
}
iov_free(VAR_8, VAR_7);
g_free(VAR_10);
g_free(VAR_9);
exit(0);
} else {
close(VAR_0[1]);
FD_SET(VAR_0[0], &fds);
fcntl(VAR_0[0], F_SETFL, O_RDWR|O_NONBLOCK);
VAR_1 = g_test_rand_int_range(sz / 2, sz);
setsockopt(VAR_0[0], SOL_SOCKET, SO_RCVBUF, &VAR_1, sizeof(VAR_1));
usleep(500000);
for (VAR_2 = 0; VAR_2 <= sz; ++VAR_2) {
for (VAR_3 = VAR_2; VAR_3 <= sz; ++VAR_3) {
VAR_4 = VAR_2;
iov_memset(VAR_8, VAR_7, 0, 0xff, -1);
do {
VAR_5 = g_test_rand_int_range(0, VAR_3 - VAR_4 + 1);
VAR_1 = iov_recv(VAR_0[0], VAR_8, VAR_7, VAR_4, VAR_5);
g_assert(memcmp(VAR_8, VAR_9, sizeof(*VAR_8)*VAR_7) == 0);
if (VAR_1 > 0) {
VAR_4 += VAR_1;
VAR_6 += VAR_1;
} else if (!VAR_1) {
if (VAR_5) {
break;
}
} else if (errno == EAGAIN) {
select(VAR_0[0]+1, &fds, NULL, NULL, NULL);
continue;
} else {
perror("recv");
exit(1);
}
} while(VAR_4 < VAR_3);
test_iov_bytes(VAR_8, VAR_7, VAR_2, VAR_3 - VAR_2);
}
}
iov_free(VAR_8, VAR_7);
g_free(VAR_10);
g_free(VAR_9);
}
#endif
}
| [
"static void FUNC_0(void)\n{",
"#ifndef _WIN32\nint VAR_0[2];",
"int VAR_1;",
"unsigned VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;",
"fd_set fds;",
"unsigned VAR_7;",
"struct iovec *VAR_8, *VAR_9;",
"unsigned char *VAR_10;",
"size_t sz;",
"iov_random(&VAR_8, &VAR_7);",
"sz = iov_size(VAR_8, VAR_7);",
"VAR_10 = g_malloc(sz);",
"for (VAR_2 = 0; VAR_2 < sz; ++VAR_2) {",
"VAR_10[VAR_2] = VAR_2 & 255;",
"}",
"iov_from_buf(VAR_8, VAR_7, 0, VAR_10, sz);",
"VAR_9 = g_memdup(VAR_8, sizeof(*VAR_8) * VAR_7);",
"if (socketpair(PF_UNIX, SOCK_STREAM, 0, VAR_0) < 0) {",
"perror(\"socketpair\");",
"exit(1);",
"}",
"FD_ZERO(&fds);",
"VAR_6 = 0;",
"if (fork() == 0) {",
"close(VAR_0[0]);",
"FD_SET(VAR_0[1], &fds);",
"fcntl(VAR_0[1], F_SETFL, O_RDWR|O_NONBLOCK);",
"VAR_1 = g_test_rand_int_range(sz / 2, sz);",
"setsockopt(VAR_0[1], SOL_SOCKET, SO_SNDBUF, &VAR_1, sizeof(VAR_1));",
"for (VAR_2 = 0; VAR_2 <= sz; ++VAR_2) {",
"for (VAR_3 = VAR_2; VAR_3 <= sz; ++VAR_3) {",
"VAR_4 = VAR_2;",
"do {",
"VAR_5 = g_test_rand_int_range(0, VAR_3 - VAR_4 + 1);",
"VAR_1 = iov_send(VAR_0[1], VAR_8, VAR_7, VAR_4, VAR_5);",
"g_assert(memcmp(VAR_8, VAR_9, sizeof(*VAR_8)*VAR_7) == 0);",
"if (VAR_1 >= 0) {",
"VAR_4 += VAR_1;",
"VAR_6 += VAR_1;",
"usleep(g_test_rand_int_range(0, 30));",
"} else if (errno == EAGAIN) {",
"select(VAR_0[1]+1, NULL, &fds, NULL, NULL);",
"continue;",
"} else {",
"perror(\"send\");",
"exit(1);",
"}",
"} while(VAR_4 < VAR_3);",
"}",
"}",
"iov_free(VAR_8, VAR_7);",
"g_free(VAR_10);",
"g_free(VAR_9);",
"exit(0);",
"} else {",
"close(VAR_0[1]);",
"FD_SET(VAR_0[0], &fds);",
"fcntl(VAR_0[0], F_SETFL, O_RDWR|O_NONBLOCK);",
"VAR_1 = g_test_rand_int_range(sz / 2, sz);",
"setsockopt(VAR_0[0], SOL_SOCKET, SO_RCVBUF, &VAR_1, sizeof(VAR_1));",
"usleep(500000);",
"for (VAR_2 = 0; VAR_2 <= sz; ++VAR_2) {",
"for (VAR_3 = VAR_2; VAR_3 <= sz; ++VAR_3) {",
"VAR_4 = VAR_2;",
"iov_memset(VAR_8, VAR_7, 0, 0xff, -1);",
"do {",
"VAR_5 = g_test_rand_int_range(0, VAR_3 - VAR_4 + 1);",
"VAR_1 = iov_recv(VAR_0[0], VAR_8, VAR_7, VAR_4, VAR_5);",
"g_assert(memcmp(VAR_8, VAR_9, sizeof(*VAR_8)*VAR_7) == 0);",
"if (VAR_1 > 0) {",
"VAR_4 += VAR_1;",
"VAR_6 += VAR_1;",
"} else if (!VAR_1) {",
"if (VAR_5) {",
"break;",
"}",
"} else if (errno == EAGAIN) {",
"select(VAR_0[0]+1, &fds, NULL, NULL, NULL);",
"continue;",
"} else {",
"perror(\"recv\");",
"exit(1);",
"}",
"} while(VAR_4 < VAR_3);",
"test_iov_bytes(VAR_8, VAR_7, VAR_2, VAR_3 - VAR_2);",
"}",
"}",
"iov_free(VAR_8, VAR_7);",
"g_free(VAR_10);",
"g_free(VAR_9);",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
]
] |
19,377 | static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
void *opaque)
{
GtkDisplayState *s = opaque;
int dx, dy;
int x, y;
x = motion->x / s->scale_x;
y = motion->y / s->scale_y;
if (kbd_mouse_is_absolute()) {
dx = x * 0x7FFF / (ds_get_width(s->ds) - 1);
dy = y * 0x7FFF / (ds_get_height(s->ds) - 1);
} else if (s->last_x == -1 || s->last_y == -1) {
dx = 0;
dy = 0;
} else {
dx = x - s->last_x;
dy = y - s->last_y;
}
s->last_x = x;
s->last_y = y;
if (kbd_mouse_is_absolute()) {
kbd_mouse_event(dx, dy, 0, s->button_mask);
}
return TRUE;
}
| false | qemu | 5104a1f65088285ddf870aa641b9061064e8757d | static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
void *opaque)
{
GtkDisplayState *s = opaque;
int dx, dy;
int x, y;
x = motion->x / s->scale_x;
y = motion->y / s->scale_y;
if (kbd_mouse_is_absolute()) {
dx = x * 0x7FFF / (ds_get_width(s->ds) - 1);
dy = y * 0x7FFF / (ds_get_height(s->ds) - 1);
} else if (s->last_x == -1 || s->last_y == -1) {
dx = 0;
dy = 0;
} else {
dx = x - s->last_x;
dy = y - s->last_y;
}
s->last_x = x;
s->last_y = y;
if (kbd_mouse_is_absolute()) {
kbd_mouse_event(dx, dy, 0, s->button_mask);
}
return TRUE;
}
| {
"code": [],
"line_no": []
} | static gboolean FUNC_0(GtkWidget *widget, GdkEventMotion *motion,
void *opaque)
{
GtkDisplayState *s = opaque;
int VAR_0, VAR_1;
int VAR_2, VAR_3;
VAR_2 = motion->VAR_2 / s->scale_x;
VAR_3 = motion->VAR_3 / s->scale_y;
if (kbd_mouse_is_absolute()) {
VAR_0 = VAR_2 * 0x7FFF / (ds_get_width(s->ds) - 1);
VAR_1 = VAR_3 * 0x7FFF / (ds_get_height(s->ds) - 1);
} else if (s->last_x == -1 || s->last_y == -1) {
VAR_0 = 0;
VAR_1 = 0;
} else {
VAR_0 = VAR_2 - s->last_x;
VAR_1 = VAR_3 - s->last_y;
}
s->last_x = VAR_2;
s->last_y = VAR_3;
if (kbd_mouse_is_absolute()) {
kbd_mouse_event(VAR_0, VAR_1, 0, s->button_mask);
}
return TRUE;
}
| [
"static gboolean FUNC_0(GtkWidget *widget, GdkEventMotion *motion,\nvoid *opaque)\n{",
"GtkDisplayState *s = opaque;",
"int VAR_0, VAR_1;",
"int VAR_2, VAR_3;",
"VAR_2 = motion->VAR_2 / s->scale_x;",
"VAR_3 = motion->VAR_3 / s->scale_y;",
"if (kbd_mouse_is_absolute()) {",
"VAR_0 = VAR_2 * 0x7FFF / (ds_get_width(s->ds) - 1);",
"VAR_1 = VAR_3 * 0x7FFF / (ds_get_height(s->ds) - 1);",
"} else if (s->last_x == -1 || s->last_y == -1) {",
"VAR_0 = 0;",
"VAR_1 = 0;",
"} else {",
"VAR_0 = VAR_2 - s->last_x;",
"VAR_1 = VAR_3 - s->last_y;",
"}",
"s->last_x = VAR_2;",
"s->last_y = VAR_3;",
"if (kbd_mouse_is_absolute()) {",
"kbd_mouse_event(VAR_0, VAR_1, 0, s->button_mask);",
"}",
"return TRUE;",
"}"
] | [
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
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
]
] |
19,378 | static int virtio_9p_init_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
VirtIODevice *vdev;
vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
vdev->nvectors = proxy->nvectors;
virtio_init_pci(proxy, vdev,
PCI_VENDOR_ID_REDHAT_QUMRANET,
0x1009,
0x2,
0x00);
/* make the actual value visible */
proxy->nvectors = vdev->nvectors;
return 0;
}
| false | qemu | e75ccf2c033fb0503d6cb7ddd0fd1dfa0aa4fc16 | static int virtio_9p_init_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
VirtIODevice *vdev;
vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
vdev->nvectors = proxy->nvectors;
virtio_init_pci(proxy, vdev,
PCI_VENDOR_ID_REDHAT_QUMRANET,
0x1009,
0x2,
0x00);
proxy->nvectors = vdev->nvectors;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, VAR_0, VAR_0);
VirtIODevice *vdev;
vdev = virtio_9p_init(&VAR_0->qdev, &proxy->fsconf);
vdev->nvectors = proxy->nvectors;
virtio_init_pci(proxy, vdev,
PCI_VENDOR_ID_REDHAT_QUMRANET,
0x1009,
0x2,
0x00);
proxy->nvectors = vdev->nvectors;
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, VAR_0, VAR_0);",
"VirtIODevice *vdev;",
"vdev = virtio_9p_init(&VAR_0->qdev, &proxy->fsconf);",
"vdev->nvectors = proxy->nvectors;",
"virtio_init_pci(proxy, vdev,\nPCI_VENDOR_ID_REDHAT_QUMRANET,\n0x1009,\n0x2,\n0x00);",
"proxy->nvectors = vdev->nvectors;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17,
19,
21,
23
],
[
27
],
[
29
],
[
31
]
] |
19,379 | void pc_guest_info_init(PCMachineState *pcms)
{
int i, j;
pcms->apic_xrupt_override = kvm_allows_irq0_override();
pcms->numa_nodes = nb_numa_nodes;
pcms->node_mem = g_malloc0(pcms->numa_nodes *
sizeof *pcms->node_mem);
for (i = 0; i < nb_numa_nodes; i++) {
pcms->node_mem[i] = numa_info[i].node_mem;
}
pcms->node_cpu = g_malloc0(pcms->apic_id_limit *
sizeof *pcms->node_cpu);
for (i = 0; i < max_cpus; i++) {
unsigned int apic_id = x86_cpu_apic_id_from_index(i);
assert(apic_id < pcms->apic_id_limit);
for (j = 0; j < nb_numa_nodes; j++) {
if (test_bit(i, numa_info[j].node_cpu)) {
pcms->node_cpu[apic_id] = j;
break;
}
}
}
pcms->machine_done.notify = pc_machine_done;
qemu_add_machine_init_done_notifier(&pcms->machine_done);
}
| false | qemu | 1f3aba377d2a531453f018c70de2580a142c74c9 | void pc_guest_info_init(PCMachineState *pcms)
{
int i, j;
pcms->apic_xrupt_override = kvm_allows_irq0_override();
pcms->numa_nodes = nb_numa_nodes;
pcms->node_mem = g_malloc0(pcms->numa_nodes *
sizeof *pcms->node_mem);
for (i = 0; i < nb_numa_nodes; i++) {
pcms->node_mem[i] = numa_info[i].node_mem;
}
pcms->node_cpu = g_malloc0(pcms->apic_id_limit *
sizeof *pcms->node_cpu);
for (i = 0; i < max_cpus; i++) {
unsigned int apic_id = x86_cpu_apic_id_from_index(i);
assert(apic_id < pcms->apic_id_limit);
for (j = 0; j < nb_numa_nodes; j++) {
if (test_bit(i, numa_info[j].node_cpu)) {
pcms->node_cpu[apic_id] = j;
break;
}
}
}
pcms->machine_done.notify = pc_machine_done;
qemu_add_machine_init_done_notifier(&pcms->machine_done);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PCMachineState *VAR_0)
{
int VAR_1, VAR_2;
VAR_0->apic_xrupt_override = kvm_allows_irq0_override();
VAR_0->numa_nodes = nb_numa_nodes;
VAR_0->node_mem = g_malloc0(VAR_0->numa_nodes *
sizeof *VAR_0->node_mem);
for (VAR_1 = 0; VAR_1 < nb_numa_nodes; VAR_1++) {
VAR_0->node_mem[VAR_1] = numa_info[VAR_1].node_mem;
}
VAR_0->node_cpu = g_malloc0(VAR_0->apic_id_limit *
sizeof *VAR_0->node_cpu);
for (VAR_1 = 0; VAR_1 < max_cpus; VAR_1++) {
unsigned int apic_id = x86_cpu_apic_id_from_index(VAR_1);
assert(apic_id < VAR_0->apic_id_limit);
for (VAR_2 = 0; VAR_2 < nb_numa_nodes; VAR_2++) {
if (test_bit(VAR_1, numa_info[VAR_2].node_cpu)) {
VAR_0->node_cpu[apic_id] = VAR_2;
break;
}
}
}
VAR_0->machine_done.notify = pc_machine_done;
qemu_add_machine_init_done_notifier(&VAR_0->machine_done);
}
| [
"void FUNC_0(PCMachineState *VAR_0)\n{",
"int VAR_1, VAR_2;",
"VAR_0->apic_xrupt_override = kvm_allows_irq0_override();",
"VAR_0->numa_nodes = nb_numa_nodes;",
"VAR_0->node_mem = g_malloc0(VAR_0->numa_nodes *\nsizeof *VAR_0->node_mem);",
"for (VAR_1 = 0; VAR_1 < nb_numa_nodes; VAR_1++) {",
"VAR_0->node_mem[VAR_1] = numa_info[VAR_1].node_mem;",
"}",
"VAR_0->node_cpu = g_malloc0(VAR_0->apic_id_limit *\nsizeof *VAR_0->node_cpu);",
"for (VAR_1 = 0; VAR_1 < max_cpus; VAR_1++) {",
"unsigned int apic_id = x86_cpu_apic_id_from_index(VAR_1);",
"assert(apic_id < VAR_0->apic_id_limit);",
"for (VAR_2 = 0; VAR_2 < nb_numa_nodes; VAR_2++) {",
"if (test_bit(VAR_1, numa_info[VAR_2].node_cpu)) {",
"VAR_0->node_cpu[apic_id] = VAR_2;",
"break;",
"}",
"}",
"}",
"VAR_0->machine_done.notify = pc_machine_done;",
"qemu_add_machine_init_done_notifier(&VAR_0->machine_done);",
"}"
] | [
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
],
[
25,
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
]
] |
19,381 | void DMA_schedule(int nchan) {}
| false | qemu | 19d2b5e6ff7202c2bf45c547efa85ae6c2d76bbd | void DMA_schedule(int nchan) {}
| {
"code": [],
"line_no": []
} | void FUNC_0(int VAR_0) {}
| [
"void FUNC_0(int VAR_0) {}"
] | [
0
] | [
[
1
]
] |
19,382 | static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
SgiContext *s = avctx->priv_data;
const AVFrame * const p = frame;
PutByteContext pbc;
uint8_t *in_buf, *encode_buf;
int x, y, z, length, tablesize, ret;
unsigned int width, height, depth, dimension;
unsigned int bytes_per_channel, pixmax, put_be;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
#if FF_API_CODER_TYPE
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->coder_type == FF_CODER_TYPE_RAW)
s->rle = 0;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
width = avctx->width;
height = avctx->height;
bytes_per_channel = 1;
pixmax = 0xFF;
put_be = HAVE_BIGENDIAN;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_GRAY8:
dimension = SGI_SINGLE_CHAN;
depth = SGI_GRAYSCALE;
break;
case AV_PIX_FMT_RGB24:
dimension = SGI_MULTI_CHAN;
depth = SGI_RGB;
break;
case AV_PIX_FMT_RGBA:
dimension = SGI_MULTI_CHAN;
depth = SGI_RGBA;
break;
case AV_PIX_FMT_GRAY16LE:
put_be = !HAVE_BIGENDIAN;
case AV_PIX_FMT_GRAY16BE:
bytes_per_channel = 2;
pixmax = 0xFFFF;
dimension = SGI_SINGLE_CHAN;
depth = SGI_GRAYSCALE;
break;
case AV_PIX_FMT_RGB48LE:
put_be = !HAVE_BIGENDIAN;
case AV_PIX_FMT_RGB48BE:
bytes_per_channel = 2;
pixmax = 0xFFFF;
dimension = SGI_MULTI_CHAN;
depth = SGI_RGB;
break;
case AV_PIX_FMT_RGBA64LE:
put_be = !HAVE_BIGENDIAN;
case AV_PIX_FMT_RGBA64BE:
bytes_per_channel = 2;
pixmax = 0xFFFF;
dimension = SGI_MULTI_CHAN;
depth = SGI_RGBA;
break;
default:
return AVERROR_INVALIDDATA;
}
tablesize = depth * height * 4;
length = SGI_HEADER_SIZE;
if (!s->rle)
length += depth * height * width;
else // assume sgi_rle_encode() produces at most 2x size of input
length += tablesize * 2 + depth * height * (2 * width + 1);
if ((ret = ff_alloc_packet(pkt, bytes_per_channel * length)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", length);
return ret;
}
bytestream2_init_writer(&pbc, pkt->data, pkt->size);
/* Encode header. */
bytestream2_put_be16(&pbc, SGI_MAGIC);
bytestream2_put_byte(&pbc, s->rle); /* RLE 1 - VERBATIM 0 */
bytestream2_put_byte(&pbc, bytes_per_channel);
bytestream2_put_be16(&pbc, dimension);
bytestream2_put_be16(&pbc, width);
bytestream2_put_be16(&pbc, height);
bytestream2_put_be16(&pbc, depth);
bytestream2_put_be32(&pbc, 0L); /* pixmin */
bytestream2_put_be32(&pbc, pixmax);
bytestream2_put_be32(&pbc, 0L); /* dummy */
/* name */
bytestream2_skip_p(&pbc, 80);
/* colormap */
bytestream2_put_be32(&pbc, 0L);
/* The rest of the 512 byte header is unused. */
bytestream2_skip_p(&pbc, 404);
if (s->rle) {
PutByteContext taboff_pcb, tablen_pcb;
/* Skip RLE offset table. */
bytestream2_init_writer(&taboff_pcb, pbc.buffer, tablesize);
bytestream2_skip_p(&pbc, tablesize);
/* Skip RLE length table. */
bytestream2_init_writer(&tablen_pcb, pbc.buffer, tablesize);
bytestream2_skip_p(&pbc, tablesize);
/* Make an intermediate consecutive buffer. */
if (!(encode_buf = av_malloc(width * bytes_per_channel)))
return AVERROR(ENOMEM);
for (z = 0; z < depth; z++) {
in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
for (y = 0; y < height; y++) {
bytestream2_put_be32(&taboff_pcb, bytestream2_tell_p(&pbc));
for (x = 0; x < width * bytes_per_channel; x += bytes_per_channel)
encode_buf[x] = in_buf[depth * x];
length = sgi_rle_encode(&pbc, encode_buf, width,
bytes_per_channel);
if (length < 1) {
av_free(encode_buf);
return AVERROR_INVALIDDATA;
}
bytestream2_put_be32(&tablen_pcb, length);
in_buf -= p->linesize[0];
}
}
av_free(encode_buf);
} else {
for (z = 0; z < depth; z++) {
in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
for (y = 0; y < height; y++) {
for (x = 0; x < width * depth; x += depth)
if (bytes_per_channel == 1)
bytestream2_put_byte(&pbc, in_buf[x]);
else
if (put_be)
bytestream2_put_be16(&pbc, ((uint16_t *)in_buf)[x]);
else
bytestream2_put_le16(&pbc, ((uint16_t *)in_buf)[x]);
in_buf -= p->linesize[0];
}
}
}
/* total length */
pkt->size = bytestream2_tell_p(&pbc);
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| false | FFmpeg | c34df422628e6b7b657faee241fe7bb2629e0f57 | static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
SgiContext *s = avctx->priv_data;
const AVFrame * const p = frame;
PutByteContext pbc;
uint8_t *in_buf, *encode_buf;
int x, y, z, length, tablesize, ret;
unsigned int width, height, depth, dimension;
unsigned int bytes_per_channel, pixmax, put_be;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
#if FF_API_CODER_TYPE
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->coder_type == FF_CODER_TYPE_RAW)
s->rle = 0;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
width = avctx->width;
height = avctx->height;
bytes_per_channel = 1;
pixmax = 0xFF;
put_be = HAVE_BIGENDIAN;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_GRAY8:
dimension = SGI_SINGLE_CHAN;
depth = SGI_GRAYSCALE;
break;
case AV_PIX_FMT_RGB24:
dimension = SGI_MULTI_CHAN;
depth = SGI_RGB;
break;
case AV_PIX_FMT_RGBA:
dimension = SGI_MULTI_CHAN;
depth = SGI_RGBA;
break;
case AV_PIX_FMT_GRAY16LE:
put_be = !HAVE_BIGENDIAN;
case AV_PIX_FMT_GRAY16BE:
bytes_per_channel = 2;
pixmax = 0xFFFF;
dimension = SGI_SINGLE_CHAN;
depth = SGI_GRAYSCALE;
break;
case AV_PIX_FMT_RGB48LE:
put_be = !HAVE_BIGENDIAN;
case AV_PIX_FMT_RGB48BE:
bytes_per_channel = 2;
pixmax = 0xFFFF;
dimension = SGI_MULTI_CHAN;
depth = SGI_RGB;
break;
case AV_PIX_FMT_RGBA64LE:
put_be = !HAVE_BIGENDIAN;
case AV_PIX_FMT_RGBA64BE:
bytes_per_channel = 2;
pixmax = 0xFFFF;
dimension = SGI_MULTI_CHAN;
depth = SGI_RGBA;
break;
default:
return AVERROR_INVALIDDATA;
}
tablesize = depth * height * 4;
length = SGI_HEADER_SIZE;
if (!s->rle)
length += depth * height * width;
else
length += tablesize * 2 + depth * height * (2 * width + 1);
if ((ret = ff_alloc_packet(pkt, bytes_per_channel * length)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", length);
return ret;
}
bytestream2_init_writer(&pbc, pkt->data, pkt->size);
bytestream2_put_be16(&pbc, SGI_MAGIC);
bytestream2_put_byte(&pbc, s->rle);
bytestream2_put_byte(&pbc, bytes_per_channel);
bytestream2_put_be16(&pbc, dimension);
bytestream2_put_be16(&pbc, width);
bytestream2_put_be16(&pbc, height);
bytestream2_put_be16(&pbc, depth);
bytestream2_put_be32(&pbc, 0L);
bytestream2_put_be32(&pbc, pixmax);
bytestream2_put_be32(&pbc, 0L);
bytestream2_skip_p(&pbc, 80);
bytestream2_put_be32(&pbc, 0L);
bytestream2_skip_p(&pbc, 404);
if (s->rle) {
PutByteContext taboff_pcb, tablen_pcb;
bytestream2_init_writer(&taboff_pcb, pbc.buffer, tablesize);
bytestream2_skip_p(&pbc, tablesize);
bytestream2_init_writer(&tablen_pcb, pbc.buffer, tablesize);
bytestream2_skip_p(&pbc, tablesize);
if (!(encode_buf = av_malloc(width * bytes_per_channel)))
return AVERROR(ENOMEM);
for (z = 0; z < depth; z++) {
in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
for (y = 0; y < height; y++) {
bytestream2_put_be32(&taboff_pcb, bytestream2_tell_p(&pbc));
for (x = 0; x < width * bytes_per_channel; x += bytes_per_channel)
encode_buf[x] = in_buf[depth * x];
length = sgi_rle_encode(&pbc, encode_buf, width,
bytes_per_channel);
if (length < 1) {
av_free(encode_buf);
return AVERROR_INVALIDDATA;
}
bytestream2_put_be32(&tablen_pcb, length);
in_buf -= p->linesize[0];
}
}
av_free(encode_buf);
} else {
for (z = 0; z < depth; z++) {
in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
for (y = 0; y < height; y++) {
for (x = 0; x < width * depth; x += depth)
if (bytes_per_channel == 1)
bytestream2_put_byte(&pbc, in_buf[x]);
else
if (put_be)
bytestream2_put_be16(&pbc, ((uint16_t *)in_buf)[x]);
else
bytestream2_put_le16(&pbc, ((uint16_t *)in_buf)[x]);
in_buf -= p->linesize[0];
}
}
}
pkt->size = bytestream2_tell_p(&pbc);
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
SgiContext *s = VAR_0->priv_data;
const AVFrame * const VAR_4 = VAR_2;
PutByteContext pbc;
uint8_t *in_buf, *encode_buf;
int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
unsigned int VAR_11, VAR_12, VAR_13, VAR_14;
unsigned int VAR_15, VAR_16, VAR_17;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
VAR_0->coded_frame->pict_type = AV_PICTURE_TYPE_I;
VAR_0->coded_frame->key_frame = 1;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
#if FF_API_CODER_TYPE
FF_DISABLE_DEPRECATION_WARNINGS
if (VAR_0->coder_type == FF_CODER_TYPE_RAW)
s->rle = 0;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
VAR_11 = VAR_0->VAR_11;
VAR_12 = VAR_0->VAR_12;
VAR_15 = 1;
VAR_16 = 0xFF;
VAR_17 = HAVE_BIGENDIAN;
switch (VAR_0->pix_fmt) {
case AV_PIX_FMT_GRAY8:
VAR_14 = SGI_SINGLE_CHAN;
VAR_13 = SGI_GRAYSCALE;
break;
case AV_PIX_FMT_RGB24:
VAR_14 = SGI_MULTI_CHAN;
VAR_13 = SGI_RGB;
break;
case AV_PIX_FMT_RGBA:
VAR_14 = SGI_MULTI_CHAN;
VAR_13 = SGI_RGBA;
break;
case AV_PIX_FMT_GRAY16LE:
VAR_17 = !HAVE_BIGENDIAN;
case AV_PIX_FMT_GRAY16BE:
VAR_15 = 2;
VAR_16 = 0xFFFF;
VAR_14 = SGI_SINGLE_CHAN;
VAR_13 = SGI_GRAYSCALE;
break;
case AV_PIX_FMT_RGB48LE:
VAR_17 = !HAVE_BIGENDIAN;
case AV_PIX_FMT_RGB48BE:
VAR_15 = 2;
VAR_16 = 0xFFFF;
VAR_14 = SGI_MULTI_CHAN;
VAR_13 = SGI_RGB;
break;
case AV_PIX_FMT_RGBA64LE:
VAR_17 = !HAVE_BIGENDIAN;
case AV_PIX_FMT_RGBA64BE:
VAR_15 = 2;
VAR_16 = 0xFFFF;
VAR_14 = SGI_MULTI_CHAN;
VAR_13 = SGI_RGBA;
break;
default:
return AVERROR_INVALIDDATA;
}
VAR_9 = VAR_13 * VAR_12 * 4;
VAR_8 = SGI_HEADER_SIZE;
if (!s->rle)
VAR_8 += VAR_13 * VAR_12 * VAR_11;
else
VAR_8 += VAR_9 * 2 + VAR_13 * VAR_12 * (2 * VAR_11 + 1);
if ((VAR_10 = ff_alloc_packet(VAR_1, VAR_15 * VAR_8)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet of size %d.\n", VAR_8);
return VAR_10;
}
bytestream2_init_writer(&pbc, VAR_1->data, VAR_1->size);
bytestream2_put_be16(&pbc, SGI_MAGIC);
bytestream2_put_byte(&pbc, s->rle);
bytestream2_put_byte(&pbc, VAR_15);
bytestream2_put_be16(&pbc, VAR_14);
bytestream2_put_be16(&pbc, VAR_11);
bytestream2_put_be16(&pbc, VAR_12);
bytestream2_put_be16(&pbc, VAR_13);
bytestream2_put_be32(&pbc, 0L);
bytestream2_put_be32(&pbc, VAR_16);
bytestream2_put_be32(&pbc, 0L);
bytestream2_skip_p(&pbc, 80);
bytestream2_put_be32(&pbc, 0L);
bytestream2_skip_p(&pbc, 404);
if (s->rle) {
PutByteContext taboff_pcb, tablen_pcb;
bytestream2_init_writer(&taboff_pcb, pbc.buffer, VAR_9);
bytestream2_skip_p(&pbc, VAR_9);
bytestream2_init_writer(&tablen_pcb, pbc.buffer, VAR_9);
bytestream2_skip_p(&pbc, VAR_9);
if (!(encode_buf = av_malloc(VAR_11 * VAR_15)))
return AVERROR(ENOMEM);
for (VAR_7 = 0; VAR_7 < VAR_13; VAR_7++) {
in_buf = VAR_4->data[0] + VAR_4->linesize[0] * (VAR_12 - 1) + VAR_7 * VAR_15;
for (VAR_6 = 0; VAR_6 < VAR_12; VAR_6++) {
bytestream2_put_be32(&taboff_pcb, bytestream2_tell_p(&pbc));
for (VAR_5 = 0; VAR_5 < VAR_11 * VAR_15; VAR_5 += VAR_15)
encode_buf[VAR_5] = in_buf[VAR_13 * VAR_5];
VAR_8 = sgi_rle_encode(&pbc, encode_buf, VAR_11,
VAR_15);
if (VAR_8 < 1) {
av_free(encode_buf);
return AVERROR_INVALIDDATA;
}
bytestream2_put_be32(&tablen_pcb, VAR_8);
in_buf -= VAR_4->linesize[0];
}
}
av_free(encode_buf);
} else {
for (VAR_7 = 0; VAR_7 < VAR_13; VAR_7++) {
in_buf = VAR_4->data[0] + VAR_4->linesize[0] * (VAR_12 - 1) + VAR_7 * VAR_15;
for (VAR_6 = 0; VAR_6 < VAR_12; VAR_6++) {
for (VAR_5 = 0; VAR_5 < VAR_11 * VAR_13; VAR_5 += VAR_13)
if (VAR_15 == 1)
bytestream2_put_byte(&pbc, in_buf[VAR_5]);
else
if (VAR_17)
bytestream2_put_be16(&pbc, ((uint16_t *)in_buf)[VAR_5]);
else
bytestream2_put_le16(&pbc, ((uint16_t *)in_buf)[VAR_5]);
in_buf -= VAR_4->linesize[0];
}
}
}
VAR_1->size = bytestream2_tell_p(&pbc);
VAR_1->flags |= AV_PKT_FLAG_KEY;
*VAR_3 = 1;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"SgiContext *s = VAR_0->priv_data;",
"const AVFrame * const VAR_4 = VAR_2;",
"PutByteContext pbc;",
"uint8_t *in_buf, *encode_buf;",
"int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"unsigned int VAR_11, VAR_12, VAR_13, VAR_14;",
"unsigned int VAR_15, VAR_16, VAR_17;",
"#if FF_API_CODED_FRAME\nFF_DISABLE_DEPRECATION_WARNINGS\nVAR_0->coded_frame->pict_type = AV_PICTURE_TYPE_I;",
"VAR_0->coded_frame->key_frame = 1;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\n#if FF_API_CODER_TYPE\nFF_DISABLE_DEPRECATION_WARNINGS\nif (VAR_0->coder_type == FF_CODER_TYPE_RAW)\ns->rle = 0;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nVAR_11 = VAR_0->VAR_11;",
"VAR_12 = VAR_0->VAR_12;",
"VAR_15 = 1;",
"VAR_16 = 0xFF;",
"VAR_17 = HAVE_BIGENDIAN;",
"switch (VAR_0->pix_fmt) {",
"case AV_PIX_FMT_GRAY8:\nVAR_14 = SGI_SINGLE_CHAN;",
"VAR_13 = SGI_GRAYSCALE;",
"break;",
"case AV_PIX_FMT_RGB24:\nVAR_14 = SGI_MULTI_CHAN;",
"VAR_13 = SGI_RGB;",
"break;",
"case AV_PIX_FMT_RGBA:\nVAR_14 = SGI_MULTI_CHAN;",
"VAR_13 = SGI_RGBA;",
"break;",
"case AV_PIX_FMT_GRAY16LE:\nVAR_17 = !HAVE_BIGENDIAN;",
"case AV_PIX_FMT_GRAY16BE:\nVAR_15 = 2;",
"VAR_16 = 0xFFFF;",
"VAR_14 = SGI_SINGLE_CHAN;",
"VAR_13 = SGI_GRAYSCALE;",
"break;",
"case AV_PIX_FMT_RGB48LE:\nVAR_17 = !HAVE_BIGENDIAN;",
"case AV_PIX_FMT_RGB48BE:\nVAR_15 = 2;",
"VAR_16 = 0xFFFF;",
"VAR_14 = SGI_MULTI_CHAN;",
"VAR_13 = SGI_RGB;",
"break;",
"case AV_PIX_FMT_RGBA64LE:\nVAR_17 = !HAVE_BIGENDIAN;",
"case AV_PIX_FMT_RGBA64BE:\nVAR_15 = 2;",
"VAR_16 = 0xFFFF;",
"VAR_14 = SGI_MULTI_CHAN;",
"VAR_13 = SGI_RGBA;",
"break;",
"default:\nreturn AVERROR_INVALIDDATA;",
"}",
"VAR_9 = VAR_13 * VAR_12 * 4;",
"VAR_8 = SGI_HEADER_SIZE;",
"if (!s->rle)\nVAR_8 += VAR_13 * VAR_12 * VAR_11;",
"else\nVAR_8 += VAR_9 * 2 + VAR_13 * VAR_12 * (2 * VAR_11 + 1);",
"if ((VAR_10 = ff_alloc_packet(VAR_1, VAR_15 * VAR_8)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error getting output packet of size %d.\\n\", VAR_8);",
"return VAR_10;",
"}",
"bytestream2_init_writer(&pbc, VAR_1->data, VAR_1->size);",
"bytestream2_put_be16(&pbc, SGI_MAGIC);",
"bytestream2_put_byte(&pbc, s->rle);",
"bytestream2_put_byte(&pbc, VAR_15);",
"bytestream2_put_be16(&pbc, VAR_14);",
"bytestream2_put_be16(&pbc, VAR_11);",
"bytestream2_put_be16(&pbc, VAR_12);",
"bytestream2_put_be16(&pbc, VAR_13);",
"bytestream2_put_be32(&pbc, 0L);",
"bytestream2_put_be32(&pbc, VAR_16);",
"bytestream2_put_be32(&pbc, 0L);",
"bytestream2_skip_p(&pbc, 80);",
"bytestream2_put_be32(&pbc, 0L);",
"bytestream2_skip_p(&pbc, 404);",
"if (s->rle) {",
"PutByteContext taboff_pcb, tablen_pcb;",
"bytestream2_init_writer(&taboff_pcb, pbc.buffer, VAR_9);",
"bytestream2_skip_p(&pbc, VAR_9);",
"bytestream2_init_writer(&tablen_pcb, pbc.buffer, VAR_9);",
"bytestream2_skip_p(&pbc, VAR_9);",
"if (!(encode_buf = av_malloc(VAR_11 * VAR_15)))\nreturn AVERROR(ENOMEM);",
"for (VAR_7 = 0; VAR_7 < VAR_13; VAR_7++) {",
"in_buf = VAR_4->data[0] + VAR_4->linesize[0] * (VAR_12 - 1) + VAR_7 * VAR_15;",
"for (VAR_6 = 0; VAR_6 < VAR_12; VAR_6++) {",
"bytestream2_put_be32(&taboff_pcb, bytestream2_tell_p(&pbc));",
"for (VAR_5 = 0; VAR_5 < VAR_11 * VAR_15; VAR_5 += VAR_15)",
"encode_buf[VAR_5] = in_buf[VAR_13 * VAR_5];",
"VAR_8 = sgi_rle_encode(&pbc, encode_buf, VAR_11,\nVAR_15);",
"if (VAR_8 < 1) {",
"av_free(encode_buf);",
"return AVERROR_INVALIDDATA;",
"}",
"bytestream2_put_be32(&tablen_pcb, VAR_8);",
"in_buf -= VAR_4->linesize[0];",
"}",
"}",
"av_free(encode_buf);",
"} else {",
"for (VAR_7 = 0; VAR_7 < VAR_13; VAR_7++) {",
"in_buf = VAR_4->data[0] + VAR_4->linesize[0] * (VAR_12 - 1) + VAR_7 * VAR_15;",
"for (VAR_6 = 0; VAR_6 < VAR_12; VAR_6++) {",
"for (VAR_5 = 0; VAR_5 < VAR_11 * VAR_13; VAR_5 += VAR_13)",
"if (VAR_15 == 1)\nbytestream2_put_byte(&pbc, in_buf[VAR_5]);",
"else\nif (VAR_17)\nbytestream2_put_be16(&pbc, ((uint16_t *)in_buf)[VAR_5]);",
"else\nbytestream2_put_le16(&pbc, ((uint16_t *)in_buf)[VAR_5]);",
"in_buf -= VAR_4->linesize[0];",
"}",
"}",
"}",
"VAR_1->size = bytestream2_tell_p(&pbc);",
"VAR_1->flags |= AV_PKT_FLAG_KEY;",
"*VAR_3 = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25,
27
],
[
29
],
[
31,
33,
37,
39,
41,
43
],
[
45,
47,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89,
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125,
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
145
],
[
147
],
[
149,
151
],
[
153,
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
201
],
[
207
],
[
213
],
[
217
],
[
219
],
[
225
],
[
227
],
[
233
],
[
235
],
[
241,
243
],
[
247
],
[
249
],
[
253
],
[
255
],
[
259
],
[
261
],
[
265,
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
295
],
[
299
],
[
301
],
[
303,
305
],
[
307,
309,
311
],
[
313,
315
],
[
319
],
[
321
],
[
323
],
[
325
],
[
331
],
[
333
],
[
335
],
[
339
],
[
341
]
] |
19,383 | static uint64_t sysbus_esp_mem_read(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
SysBusESPState *sysbus = opaque;
uint32_t saddr;
saddr = addr >> sysbus->it_shift;
return esp_reg_read(&sysbus->esp, saddr);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t sysbus_esp_mem_read(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
SysBusESPState *sysbus = opaque;
uint32_t saddr;
saddr = addr >> sysbus->it_shift;
return esp_reg_read(&sysbus->esp, saddr);
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
SysBusESPState *sysbus = opaque;
uint32_t saddr;
saddr = addr >> sysbus->it_shift;
return esp_reg_read(&sysbus->esp, saddr);
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned int size)\n{",
"SysBusESPState *sysbus = opaque;",
"uint32_t saddr;",
"saddr = addr >> sysbus->it_shift;",
"return esp_reg_read(&sysbus->esp, saddr);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
]
] |
19,384 | static int usb_bt_handle_data(USBDevice *dev, USBPacket *p)
{
struct USBBtState *s = (struct USBBtState *) dev->opaque;
int ret = 0;
if (!s->config)
goto fail;
switch (p->pid) {
case USB_TOKEN_IN:
switch (p->devep & 0xf) {
case USB_EVT_EP:
ret = usb_bt_fifo_dequeue(&s->evt, p);
break;
case USB_ACL_EP:
ret = usb_bt_fifo_dequeue(&s->acl, p);
break;
case USB_SCO_EP:
ret = usb_bt_fifo_dequeue(&s->sco, p);
break;
default:
goto fail;
}
break;
case USB_TOKEN_OUT:
switch (p->devep & 0xf) {
case USB_ACL_EP:
usb_bt_fifo_out_enqueue(s, &s->outacl, s->hci->acl_send,
usb_bt_hci_acl_complete, p);
break;
case USB_SCO_EP:
usb_bt_fifo_out_enqueue(s, &s->outsco, s->hci->sco_send,
usb_bt_hci_sco_complete, p);
break;
default:
goto fail;
}
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| false | qemu | 079d0b7f1eedcc634c371fe05b617fdc55c8b762 | static int usb_bt_handle_data(USBDevice *dev, USBPacket *p)
{
struct USBBtState *s = (struct USBBtState *) dev->opaque;
int ret = 0;
if (!s->config)
goto fail;
switch (p->pid) {
case USB_TOKEN_IN:
switch (p->devep & 0xf) {
case USB_EVT_EP:
ret = usb_bt_fifo_dequeue(&s->evt, p);
break;
case USB_ACL_EP:
ret = usb_bt_fifo_dequeue(&s->acl, p);
break;
case USB_SCO_EP:
ret = usb_bt_fifo_dequeue(&s->sco, p);
break;
default:
goto fail;
}
break;
case USB_TOKEN_OUT:
switch (p->devep & 0xf) {
case USB_ACL_EP:
usb_bt_fifo_out_enqueue(s, &s->outacl, s->hci->acl_send,
usb_bt_hci_acl_complete, p);
break;
case USB_SCO_EP:
usb_bt_fifo_out_enqueue(s, &s->outsco, s->hci->sco_send,
usb_bt_hci_sco_complete, p);
break;
default:
goto fail;
}
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
struct USBBtState *VAR_2 = (struct USBBtState *) VAR_0->opaque;
int VAR_3 = 0;
if (!VAR_2->config)
goto fail;
switch (VAR_1->pid) {
case USB_TOKEN_IN:
switch (VAR_1->devep & 0xf) {
case USB_EVT_EP:
VAR_3 = usb_bt_fifo_dequeue(&VAR_2->evt, VAR_1);
break;
case USB_ACL_EP:
VAR_3 = usb_bt_fifo_dequeue(&VAR_2->acl, VAR_1);
break;
case USB_SCO_EP:
VAR_3 = usb_bt_fifo_dequeue(&VAR_2->sco, VAR_1);
break;
default:
goto fail;
}
break;
case USB_TOKEN_OUT:
switch (VAR_1->devep & 0xf) {
case USB_ACL_EP:
usb_bt_fifo_out_enqueue(VAR_2, &VAR_2->outacl, VAR_2->hci->acl_send,
usb_bt_hci_acl_complete, VAR_1);
break;
case USB_SCO_EP:
usb_bt_fifo_out_enqueue(VAR_2, &VAR_2->outsco, VAR_2->hci->sco_send,
usb_bt_hci_sco_complete, VAR_1);
break;
default:
goto fail;
}
break;
default:
fail:
VAR_3 = USB_RET_STALL;
break;
}
return VAR_3;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"struct USBBtState *VAR_2 = (struct USBBtState *) VAR_0->opaque;",
"int VAR_3 = 0;",
"if (!VAR_2->config)\ngoto fail;",
"switch (VAR_1->pid) {",
"case USB_TOKEN_IN:\nswitch (VAR_1->devep & 0xf) {",
"case USB_EVT_EP:\nVAR_3 = usb_bt_fifo_dequeue(&VAR_2->evt, VAR_1);",
"break;",
"case USB_ACL_EP:\nVAR_3 = usb_bt_fifo_dequeue(&VAR_2->acl, VAR_1);",
"break;",
"case USB_SCO_EP:\nVAR_3 = usb_bt_fifo_dequeue(&VAR_2->sco, VAR_1);",
"break;",
"default:\ngoto fail;",
"}",
"break;",
"case USB_TOKEN_OUT:\nswitch (VAR_1->devep & 0xf) {",
"case USB_ACL_EP:\nusb_bt_fifo_out_enqueue(VAR_2, &VAR_2->outacl, VAR_2->hci->acl_send,\nusb_bt_hci_acl_complete, VAR_1);",
"break;",
"case USB_SCO_EP:\nusb_bt_fifo_out_enqueue(VAR_2, &VAR_2->outsco, VAR_2->hci->sco_send,\nusb_bt_hci_sco_complete, VAR_1);",
"break;",
"default:\ngoto fail;",
"}",
"break;",
"default:\nfail:\nVAR_3 = USB_RET_STALL;",
"break;",
"}",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27
],
[
31,
33
],
[
35
],
[
39,
41
],
[
43
],
[
47,
49
],
[
51
],
[
53
],
[
57,
59
],
[
61,
63,
65
],
[
67
],
[
71,
73,
75
],
[
77
],
[
81,
83
],
[
85
],
[
87
],
[
91,
93,
95
],
[
97
],
[
99
],
[
103
],
[
105
]
] |
19,385 | void bdrv_io_unplugged_begin(BlockDriverState *bs)
{
BdrvChild *child;
if (bs->io_plug_disabled++ == 0 && bs->io_plugged > 0) {
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_io_unplug) {
drv->bdrv_io_unplug(bs);
}
}
QLIST_FOREACH(child, &bs->children, next) {
bdrv_io_unplugged_begin(child->bs);
}
}
| false | qemu | 8f90b5e91df59fde0dfecc6738ff39f3edf14be5 | void bdrv_io_unplugged_begin(BlockDriverState *bs)
{
BdrvChild *child;
if (bs->io_plug_disabled++ == 0 && bs->io_plugged > 0) {
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_io_unplug) {
drv->bdrv_io_unplug(bs);
}
}
QLIST_FOREACH(child, &bs->children, next) {
bdrv_io_unplugged_begin(child->bs);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriverState *VAR_0)
{
BdrvChild *child;
if (VAR_0->io_plug_disabled++ == 0 && VAR_0->io_plugged > 0) {
BlockDriver *drv = VAR_0->drv;
if (drv && drv->bdrv_io_unplug) {
drv->bdrv_io_unplug(VAR_0);
}
}
QLIST_FOREACH(child, &VAR_0->children, next) {
FUNC_0(child->VAR_0);
}
}
| [
"void FUNC_0(BlockDriverState *VAR_0)\n{",
"BdrvChild *child;",
"if (VAR_0->io_plug_disabled++ == 0 && VAR_0->io_plugged > 0) {",
"BlockDriver *drv = VAR_0->drv;",
"if (drv && drv->bdrv_io_unplug) {",
"drv->bdrv_io_unplug(VAR_0);",
"}",
"}",
"QLIST_FOREACH(child, &VAR_0->children, next) {",
"FUNC_0(child->VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
19,386 | static void acpi_get_pm_info(AcpiPmInfo *pm)
{
Object *piix = piix4_pm_find();
Object *lpc = ich9_lpc_find();
Object *obj = NULL;
QObject *o;
pm->cpu_hp_io_base = 0;
pm->pcihp_io_base = 0;
pm->pcihp_io_len = 0;
if (piix) {
obj = piix;
pm->cpu_hp_io_base = PIIX4_CPU_HOTPLUG_IO_BASE;
pm->pcihp_io_base =
object_property_get_int(obj, ACPI_PCIHP_IO_BASE_PROP, NULL);
pm->pcihp_io_len =
object_property_get_int(obj, ACPI_PCIHP_IO_LEN_PROP, NULL);
}
if (lpc) {
obj = lpc;
pm->cpu_hp_io_base = ICH9_CPU_HOTPLUG_IO_BASE;
}
assert(obj);
pm->cpu_hp_io_len = ACPI_GPE_PROC_LEN;
pm->mem_hp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
pm->mem_hp_io_len = ACPI_MEMORY_HOTPLUG_IO_LEN;
/* Fill in optional s3/s4 related properties */
o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL);
if (o) {
pm->s3_disabled = qint_get_int(qobject_to_qint(o));
} else {
pm->s3_disabled = false;
}
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL);
if (o) {
pm->s4_disabled = qint_get_int(qobject_to_qint(o));
} else {
pm->s4_disabled = false;
}
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL);
if (o) {
pm->s4_val = qint_get_int(qobject_to_qint(o));
} else {
pm->s4_val = false;
}
qobject_decref(o);
/* Fill in mandatory properties */
pm->sci_int = object_property_get_int(obj, ACPI_PM_PROP_SCI_INT, NULL);
pm->acpi_enable_cmd = object_property_get_int(obj,
ACPI_PM_PROP_ACPI_ENABLE_CMD,
NULL);
pm->acpi_disable_cmd = object_property_get_int(obj,
ACPI_PM_PROP_ACPI_DISABLE_CMD,
NULL);
pm->io_base = object_property_get_int(obj, ACPI_PM_PROP_PM_IO_BASE,
NULL);
pm->gpe0_blk = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK,
NULL);
pm->gpe0_blk_len = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK_LEN,
NULL);
pm->pcihp_bridge_en =
object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
NULL);
}
| false | qemu | ebd8ea82441020f2781928b17f37ed9a0d2e4250 | static void acpi_get_pm_info(AcpiPmInfo *pm)
{
Object *piix = piix4_pm_find();
Object *lpc = ich9_lpc_find();
Object *obj = NULL;
QObject *o;
pm->cpu_hp_io_base = 0;
pm->pcihp_io_base = 0;
pm->pcihp_io_len = 0;
if (piix) {
obj = piix;
pm->cpu_hp_io_base = PIIX4_CPU_HOTPLUG_IO_BASE;
pm->pcihp_io_base =
object_property_get_int(obj, ACPI_PCIHP_IO_BASE_PROP, NULL);
pm->pcihp_io_len =
object_property_get_int(obj, ACPI_PCIHP_IO_LEN_PROP, NULL);
}
if (lpc) {
obj = lpc;
pm->cpu_hp_io_base = ICH9_CPU_HOTPLUG_IO_BASE;
}
assert(obj);
pm->cpu_hp_io_len = ACPI_GPE_PROC_LEN;
pm->mem_hp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
pm->mem_hp_io_len = ACPI_MEMORY_HOTPLUG_IO_LEN;
o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL);
if (o) {
pm->s3_disabled = qint_get_int(qobject_to_qint(o));
} else {
pm->s3_disabled = false;
}
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL);
if (o) {
pm->s4_disabled = qint_get_int(qobject_to_qint(o));
} else {
pm->s4_disabled = false;
}
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL);
if (o) {
pm->s4_val = qint_get_int(qobject_to_qint(o));
} else {
pm->s4_val = false;
}
qobject_decref(o);
pm->sci_int = object_property_get_int(obj, ACPI_PM_PROP_SCI_INT, NULL);
pm->acpi_enable_cmd = object_property_get_int(obj,
ACPI_PM_PROP_ACPI_ENABLE_CMD,
NULL);
pm->acpi_disable_cmd = object_property_get_int(obj,
ACPI_PM_PROP_ACPI_DISABLE_CMD,
NULL);
pm->io_base = object_property_get_int(obj, ACPI_PM_PROP_PM_IO_BASE,
NULL);
pm->gpe0_blk = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK,
NULL);
pm->gpe0_blk_len = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK_LEN,
NULL);
pm->pcihp_bridge_en =
object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
NULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AcpiPmInfo *VAR_0)
{
Object *piix = piix4_pm_find();
Object *lpc = ich9_lpc_find();
Object *obj = NULL;
QObject *o;
VAR_0->cpu_hp_io_base = 0;
VAR_0->pcihp_io_base = 0;
VAR_0->pcihp_io_len = 0;
if (piix) {
obj = piix;
VAR_0->cpu_hp_io_base = PIIX4_CPU_HOTPLUG_IO_BASE;
VAR_0->pcihp_io_base =
object_property_get_int(obj, ACPI_PCIHP_IO_BASE_PROP, NULL);
VAR_0->pcihp_io_len =
object_property_get_int(obj, ACPI_PCIHP_IO_LEN_PROP, NULL);
}
if (lpc) {
obj = lpc;
VAR_0->cpu_hp_io_base = ICH9_CPU_HOTPLUG_IO_BASE;
}
assert(obj);
VAR_0->cpu_hp_io_len = ACPI_GPE_PROC_LEN;
VAR_0->mem_hp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
VAR_0->mem_hp_io_len = ACPI_MEMORY_HOTPLUG_IO_LEN;
o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL);
if (o) {
VAR_0->s3_disabled = qint_get_int(qobject_to_qint(o));
} else {
VAR_0->s3_disabled = false;
}
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL);
if (o) {
VAR_0->s4_disabled = qint_get_int(qobject_to_qint(o));
} else {
VAR_0->s4_disabled = false;
}
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL);
if (o) {
VAR_0->s4_val = qint_get_int(qobject_to_qint(o));
} else {
VAR_0->s4_val = false;
}
qobject_decref(o);
VAR_0->sci_int = object_property_get_int(obj, ACPI_PM_PROP_SCI_INT, NULL);
VAR_0->acpi_enable_cmd = object_property_get_int(obj,
ACPI_PM_PROP_ACPI_ENABLE_CMD,
NULL);
VAR_0->acpi_disable_cmd = object_property_get_int(obj,
ACPI_PM_PROP_ACPI_DISABLE_CMD,
NULL);
VAR_0->io_base = object_property_get_int(obj, ACPI_PM_PROP_PM_IO_BASE,
NULL);
VAR_0->gpe0_blk = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK,
NULL);
VAR_0->gpe0_blk_len = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK_LEN,
NULL);
VAR_0->pcihp_bridge_en =
object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
NULL);
}
| [
"static void FUNC_0(AcpiPmInfo *VAR_0)\n{",
"Object *piix = piix4_pm_find();",
"Object *lpc = ich9_lpc_find();",
"Object *obj = NULL;",
"QObject *o;",
"VAR_0->cpu_hp_io_base = 0;",
"VAR_0->pcihp_io_base = 0;",
"VAR_0->pcihp_io_len = 0;",
"if (piix) {",
"obj = piix;",
"VAR_0->cpu_hp_io_base = PIIX4_CPU_HOTPLUG_IO_BASE;",
"VAR_0->pcihp_io_base =\nobject_property_get_int(obj, ACPI_PCIHP_IO_BASE_PROP, NULL);",
"VAR_0->pcihp_io_len =\nobject_property_get_int(obj, ACPI_PCIHP_IO_LEN_PROP, NULL);",
"}",
"if (lpc) {",
"obj = lpc;",
"VAR_0->cpu_hp_io_base = ICH9_CPU_HOTPLUG_IO_BASE;",
"}",
"assert(obj);",
"VAR_0->cpu_hp_io_len = ACPI_GPE_PROC_LEN;",
"VAR_0->mem_hp_io_base = ACPI_MEMORY_HOTPLUG_BASE;",
"VAR_0->mem_hp_io_len = ACPI_MEMORY_HOTPLUG_IO_LEN;",
"o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL);",
"if (o) {",
"VAR_0->s3_disabled = qint_get_int(qobject_to_qint(o));",
"} else {",
"VAR_0->s3_disabled = false;",
"}",
"qobject_decref(o);",
"o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL);",
"if (o) {",
"VAR_0->s4_disabled = qint_get_int(qobject_to_qint(o));",
"} else {",
"VAR_0->s4_disabled = false;",
"}",
"qobject_decref(o);",
"o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL);",
"if (o) {",
"VAR_0->s4_val = qint_get_int(qobject_to_qint(o));",
"} else {",
"VAR_0->s4_val = false;",
"}",
"qobject_decref(o);",
"VAR_0->sci_int = object_property_get_int(obj, ACPI_PM_PROP_SCI_INT, NULL);",
"VAR_0->acpi_enable_cmd = object_property_get_int(obj,\nACPI_PM_PROP_ACPI_ENABLE_CMD,\nNULL);",
"VAR_0->acpi_disable_cmd = object_property_get_int(obj,\nACPI_PM_PROP_ACPI_DISABLE_CMD,\nNULL);",
"VAR_0->io_base = object_property_get_int(obj, ACPI_PM_PROP_PM_IO_BASE,\nNULL);",
"VAR_0->gpe0_blk = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK,\nNULL);",
"VAR_0->gpe0_blk_len = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK_LEN,\nNULL);",
"VAR_0->pcihp_bridge_en =\nobject_property_get_bool(obj, \"acpi-pci-hotplug-with-bridge-support\",\nNULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
105
],
[
109,
111,
113
],
[
115,
117,
119
],
[
121,
123
],
[
125,
127
],
[
129,
131
],
[
133,
135,
137
],
[
139
]
] |
19,387 | static void icp_pit_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
icp_pit_state *s = (icp_pit_state *)opaque;
int n;
n = offset >> 8;
if (n > 2) {
hw_error("%s: Bad timer %d\n", __func__, n);
}
arm_timer_write(s->timer[n], offset & 0xff, value);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void icp_pit_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
icp_pit_state *s = (icp_pit_state *)opaque;
int n;
n = offset >> 8;
if (n > 2) {
hw_error("%s: Bad timer %d\n", __func__, n);
}
arm_timer_write(s->timer[n], offset & 0xff, value);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
icp_pit_state *s = (icp_pit_state *)VAR_0;
int VAR_4;
VAR_4 = VAR_1 >> 8;
if (VAR_4 > 2) {
hw_error("%s: Bad timer %d\VAR_4", __func__, VAR_4);
}
arm_timer_write(s->timer[VAR_4], VAR_1 & 0xff, VAR_2);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"icp_pit_state *s = (icp_pit_state *)VAR_0;",
"int VAR_4;",
"VAR_4 = VAR_1 >> 8;",
"if (VAR_4 > 2) {",
"hw_error(\"%s: Bad timer %d\\VAR_4\", __func__, VAR_4);",
"}",
"arm_timer_write(s->timer[VAR_4], VAR_1 & 0xff, VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
]
] |
19,388 | static ram_addr_t get_current_ram_size(void)
{
GSList *list = NULL, *item;
ram_addr_t size = ram_size;
pc_dimm_build_list(qdev_get_machine(), &list);
for (item = list; item; item = g_slist_next(item)) {
Object *obj = OBJECT(item->data);
size += object_property_get_int(obj, PC_DIMM_SIZE_PROP, &error_abort);
}
g_slist_free(list);
return size;
}
| false | qemu | 2b75f848238651ef1bb407f66fa38d68775782bf | static ram_addr_t get_current_ram_size(void)
{
GSList *list = NULL, *item;
ram_addr_t size = ram_size;
pc_dimm_build_list(qdev_get_machine(), &list);
for (item = list; item; item = g_slist_next(item)) {
Object *obj = OBJECT(item->data);
size += object_property_get_int(obj, PC_DIMM_SIZE_PROP, &error_abort);
}
g_slist_free(list);
return size;
}
| {
"code": [],
"line_no": []
} | static ram_addr_t FUNC_0(void)
{
GSList *list = NULL, *item;
ram_addr_t size = ram_size;
pc_dimm_build_list(qdev_get_machine(), &list);
for (item = list; item; item = g_slist_next(item)) {
Object *obj = OBJECT(item->data);
size += object_property_get_int(obj, PC_DIMM_SIZE_PROP, &error_abort);
}
g_slist_free(list);
return size;
}
| [
"static ram_addr_t FUNC_0(void)\n{",
"GSList *list = NULL, *item;",
"ram_addr_t size = ram_size;",
"pc_dimm_build_list(qdev_get_machine(), &list);",
"for (item = list; item; item = g_slist_next(item)) {",
"Object *obj = OBJECT(item->data);",
"size += object_property_get_int(obj, PC_DIMM_SIZE_PROP, &error_abort);",
"}",
"g_slist_free(list);",
"return size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
19,390 | void gen_intermediate_code_internal_a64(ARMCPU *cpu,
TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUARMState *env = &cpu->env;
DisasContext dc1, *dc = &dc1;
CPUBreakpoint *bp;
int j, lj;
target_ulong pc_start;
target_ulong next_page_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
dc->tb = tb;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->singlestep_enabled = cs->singlestep_enabled;
dc->condjmp = 0;
dc->aarch64 = 1;
dc->el3_is_aa64 = arm_el_is_aa64(env, 3);
dc->thumb = 0;
dc->bswap_code = 0;
dc->condexec_mask = 0;
dc->condexec_cond = 0;
dc->mmu_idx = ARM_TBFLAG_MMUIDX(tb->flags);
dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx);
#if !defined(CONFIG_USER_ONLY)
dc->user = (dc->current_el == 0);
#endif
dc->cpacr_fpen = ARM_TBFLAG_AA64_FPEN(tb->flags);
dc->vec_len = 0;
dc->vec_stride = 0;
dc->cp_regs = cpu->cp_regs;
dc->features = env->features;
/* Single step state. The code-generation logic here is:
* SS_ACTIVE == 0:
* generate code with no special handling for single-stepping (except
* that anything that can make us go to SS_ACTIVE == 1 must end the TB;
* this happens anyway because those changes are all system register or
* PSTATE writes).
* SS_ACTIVE == 1, PSTATE.SS == 1: (active-not-pending)
* emit code for one insn
* emit code to clear PSTATE.SS
* emit code to generate software step exception for completed step
* end TB (as usual for having generated an exception)
* SS_ACTIVE == 1, PSTATE.SS == 0: (active-pending)
* emit code to generate a software step exception
* end the TB
*/
dc->ss_active = ARM_TBFLAG_SS_ACTIVE(tb->flags);
dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(tb->flags);
dc->is_ldex = false;
dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el);
init_tmp_a64_array(dc);
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
lj = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
gen_tb_start(tb);
tcg_clear_temp_count();
do {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception_internal_insn(dc, 0, EXCP_DEBUG);
/* Advance PC so that clearing the breakpoint will
invalidate this TB. */
dc->pc += 2;
goto done_generating;
}
}
}
if (search_pc) {
j = tcg_op_buf_count();
if (lj < j) {
lj++;
while (lj < j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
}
tcg_ctx.gen_opc_pc[lj] = dc->pc;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(dc->pc);
}
if (dc->ss_active && !dc->pstate_ss) {
/* Singlestep state is Active-pending.
* If we're in this state at the start of a TB then either
* a) we just took an exception to an EL which is being debugged
* and this is the first insn in the exception handler
* b) debug exceptions were masked and we just unmasked them
* without changing EL (eg by clearing PSTATE.D)
* In either case we're going to take a swstep exception in the
* "did not step an insn" case, and so the syndrome ISV and EX
* bits should be zero.
*/
assert(num_insns == 0);
gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),
default_exception_el(dc));
dc->is_jmp = DISAS_EXC;
break;
}
disas_a64_insn(env, dc);
if (tcg_check_temp_count()) {
fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n",
dc->pc);
}
/* Translation stops when a conditional branch is encountered.
* Otherwise the subsequent code could get translated several times.
* Also stop translation when a page boundary is reached. This
* ensures prefetch aborts occur at the right place.
*/
num_insns++;
} while (!dc->is_jmp && !tcg_op_buf_full() &&
!cs->singlestep_enabled &&
!singlestep &&
!dc->ss_active &&
dc->pc < next_page_start &&
num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (unlikely(cs->singlestep_enabled || dc->ss_active)
&& dc->is_jmp != DISAS_EXC) {
/* Note that this means single stepping WFI doesn't halt the CPU.
* For conditional branch insns this is harmless unreachable code as
* gen_goto_tb() has already handled emitting the debug exception
* (and thus a tb-jump is not possible when singlestepping).
*/
assert(dc->is_jmp != DISAS_TB_JUMP);
if (dc->is_jmp != DISAS_JUMP) {
gen_a64_set_pc_im(dc->pc);
}
if (cs->singlestep_enabled) {
gen_exception_internal(EXCP_DEBUG);
} else {
gen_step_complete_exception(dc);
}
} else {
switch (dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, dc->pc);
break;
default:
case DISAS_UPDATE:
gen_a64_set_pc_im(dc->pc);
/* fall through */
case DISAS_JUMP:
/* indicate that the hash table must be used to find the next TB */
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
case DISAS_EXC:
case DISAS_SWI:
break;
case DISAS_WFE:
gen_a64_set_pc_im(dc->pc);
gen_helper_wfe(cpu_env);
break;
case DISAS_WFI:
/* This is a special case because we don't want to just halt the CPU
* if trying to debug across a WFI.
*/
gen_a64_set_pc_im(dc->pc);
gen_helper_wfi(cpu_env);
break;
}
}
done_generating:
gen_tb_end(tb, num_insns);
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, dc->pc - pc_start,
4 | (dc->bswap_code << 1));
qemu_log("\n");
}
#endif
if (search_pc) {
j = tcg_op_buf_count();
lj++;
while (lj <= j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
}
| false | qemu | 9dbbc748d671c70599101836cd1c2719d92f3017 | void gen_intermediate_code_internal_a64(ARMCPU *cpu,
TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUARMState *env = &cpu->env;
DisasContext dc1, *dc = &dc1;
CPUBreakpoint *bp;
int j, lj;
target_ulong pc_start;
target_ulong next_page_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
dc->tb = tb;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->singlestep_enabled = cs->singlestep_enabled;
dc->condjmp = 0;
dc->aarch64 = 1;
dc->el3_is_aa64 = arm_el_is_aa64(env, 3);
dc->thumb = 0;
dc->bswap_code = 0;
dc->condexec_mask = 0;
dc->condexec_cond = 0;
dc->mmu_idx = ARM_TBFLAG_MMUIDX(tb->flags);
dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx);
#if !defined(CONFIG_USER_ONLY)
dc->user = (dc->current_el == 0);
#endif
dc->cpacr_fpen = ARM_TBFLAG_AA64_FPEN(tb->flags);
dc->vec_len = 0;
dc->vec_stride = 0;
dc->cp_regs = cpu->cp_regs;
dc->features = env->features;
dc->ss_active = ARM_TBFLAG_SS_ACTIVE(tb->flags);
dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(tb->flags);
dc->is_ldex = false;
dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el);
init_tmp_a64_array(dc);
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
lj = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
gen_tb_start(tb);
tcg_clear_temp_count();
do {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception_internal_insn(dc, 0, EXCP_DEBUG);
dc->pc += 2;
goto done_generating;
}
}
}
if (search_pc) {
j = tcg_op_buf_count();
if (lj < j) {
lj++;
while (lj < j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
}
tcg_ctx.gen_opc_pc[lj] = dc->pc;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(dc->pc);
}
if (dc->ss_active && !dc->pstate_ss) {
assert(num_insns == 0);
gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),
default_exception_el(dc));
dc->is_jmp = DISAS_EXC;
break;
}
disas_a64_insn(env, dc);
if (tcg_check_temp_count()) {
fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n",
dc->pc);
}
num_insns++;
} while (!dc->is_jmp && !tcg_op_buf_full() &&
!cs->singlestep_enabled &&
!singlestep &&
!dc->ss_active &&
dc->pc < next_page_start &&
num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (unlikely(cs->singlestep_enabled || dc->ss_active)
&& dc->is_jmp != DISAS_EXC) {
assert(dc->is_jmp != DISAS_TB_JUMP);
if (dc->is_jmp != DISAS_JUMP) {
gen_a64_set_pc_im(dc->pc);
}
if (cs->singlestep_enabled) {
gen_exception_internal(EXCP_DEBUG);
} else {
gen_step_complete_exception(dc);
}
} else {
switch (dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, dc->pc);
break;
default:
case DISAS_UPDATE:
gen_a64_set_pc_im(dc->pc);
case DISAS_JUMP:
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
case DISAS_EXC:
case DISAS_SWI:
break;
case DISAS_WFE:
gen_a64_set_pc_im(dc->pc);
gen_helper_wfe(cpu_env);
break;
case DISAS_WFI:
gen_a64_set_pc_im(dc->pc);
gen_helper_wfi(cpu_env);
break;
}
}
done_generating:
gen_tb_end(tb, num_insns);
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, dc->pc - pc_start,
4 | (dc->bswap_code << 1));
qemu_log("\n");
}
#endif
if (search_pc) {
j = tcg_op_buf_count();
lj++;
while (lj <= j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ARMCPU *VAR_0,
TranslationBlock *VAR_1,
bool VAR_2)
{
CPUState *cs = CPU(VAR_0);
CPUARMState *env = &VAR_0->env;
DisasContext dc1, *dc = &dc1;
CPUBreakpoint *bp;
int VAR_3, VAR_4;
target_ulong pc_start;
target_ulong next_page_start;
int VAR_5;
int VAR_6;
pc_start = VAR_1->pc;
dc->VAR_1 = VAR_1;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->singlestep_enabled = cs->singlestep_enabled;
dc->condjmp = 0;
dc->aarch64 = 1;
dc->el3_is_aa64 = arm_el_is_aa64(env, 3);
dc->thumb = 0;
dc->bswap_code = 0;
dc->condexec_mask = 0;
dc->condexec_cond = 0;
dc->mmu_idx = ARM_TBFLAG_MMUIDX(VAR_1->flags);
dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx);
#if !defined(CONFIG_USER_ONLY)
dc->user = (dc->current_el == 0);
#endif
dc->cpacr_fpen = ARM_TBFLAG_AA64_FPEN(VAR_1->flags);
dc->vec_len = 0;
dc->vec_stride = 0;
dc->cp_regs = VAR_0->cp_regs;
dc->features = env->features;
dc->ss_active = ARM_TBFLAG_SS_ACTIVE(VAR_1->flags);
dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(VAR_1->flags);
dc->is_ldex = false;
dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el);
init_tmp_a64_array(dc);
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
VAR_4 = -1;
VAR_5 = 0;
VAR_6 = VAR_1->cflags & CF_COUNT_MASK;
if (VAR_6 == 0) {
VAR_6 = CF_COUNT_MASK;
}
gen_tb_start(VAR_1);
tcg_clear_temp_count();
do {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception_internal_insn(dc, 0, EXCP_DEBUG);
dc->pc += 2;
goto done_generating;
}
}
}
if (VAR_2) {
VAR_3 = tcg_op_buf_count();
if (VAR_4 < VAR_3) {
VAR_4++;
while (VAR_4 < VAR_3) {
tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;
}
}
tcg_ctx.gen_opc_pc[VAR_4] = dc->pc;
tcg_ctx.gen_opc_instr_start[VAR_4] = 1;
tcg_ctx.gen_opc_icount[VAR_4] = VAR_5;
}
if (VAR_5 + 1 == VAR_6 && (VAR_1->cflags & CF_LAST_IO)) {
gen_io_start();
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(dc->pc);
}
if (dc->ss_active && !dc->pstate_ss) {
assert(VAR_5 == 0);
gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),
default_exception_el(dc));
dc->is_jmp = DISAS_EXC;
break;
}
disas_a64_insn(env, dc);
if (tcg_check_temp_count()) {
fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n",
dc->pc);
}
VAR_5++;
} while (!dc->is_jmp && !tcg_op_buf_full() &&
!cs->singlestep_enabled &&
!singlestep &&
!dc->ss_active &&
dc->pc < next_page_start &&
VAR_5 < VAR_6);
if (VAR_1->cflags & CF_LAST_IO) {
gen_io_end();
}
if (unlikely(cs->singlestep_enabled || dc->ss_active)
&& dc->is_jmp != DISAS_EXC) {
assert(dc->is_jmp != DISAS_TB_JUMP);
if (dc->is_jmp != DISAS_JUMP) {
gen_a64_set_pc_im(dc->pc);
}
if (cs->singlestep_enabled) {
gen_exception_internal(EXCP_DEBUG);
} else {
gen_step_complete_exception(dc);
}
} else {
switch (dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, dc->pc);
break;
default:
case DISAS_UPDATE:
gen_a64_set_pc_im(dc->pc);
case DISAS_JUMP:
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
case DISAS_EXC:
case DISAS_SWI:
break;
case DISAS_WFE:
gen_a64_set_pc_im(dc->pc);
gen_helper_wfe(cpu_env);
break;
case DISAS_WFI:
gen_a64_set_pc_im(dc->pc);
gen_helper_wfi(cpu_env);
break;
}
}
done_generating:
gen_tb_end(VAR_1, VAR_5);
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, dc->pc - pc_start,
4 | (dc->bswap_code << 1));
qemu_log("\n");
}
#endif
if (VAR_2) {
VAR_3 = tcg_op_buf_count();
VAR_4++;
while (VAR_4 <= VAR_3) {
tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;
}
} else {
VAR_1->size = dc->pc - pc_start;
VAR_1->icount = VAR_5;
}
}
| [
"void FUNC_0(ARMCPU *VAR_0,\nTranslationBlock *VAR_1,\nbool VAR_2)\n{",
"CPUState *cs = CPU(VAR_0);",
"CPUARMState *env = &VAR_0->env;",
"DisasContext dc1, *dc = &dc1;",
"CPUBreakpoint *bp;",
"int VAR_3, VAR_4;",
"target_ulong pc_start;",
"target_ulong next_page_start;",
"int VAR_5;",
"int VAR_6;",
"pc_start = VAR_1->pc;",
"dc->VAR_1 = VAR_1;",
"dc->is_jmp = DISAS_NEXT;",
"dc->pc = pc_start;",
"dc->singlestep_enabled = cs->singlestep_enabled;",
"dc->condjmp = 0;",
"dc->aarch64 = 1;",
"dc->el3_is_aa64 = arm_el_is_aa64(env, 3);",
"dc->thumb = 0;",
"dc->bswap_code = 0;",
"dc->condexec_mask = 0;",
"dc->condexec_cond = 0;",
"dc->mmu_idx = ARM_TBFLAG_MMUIDX(VAR_1->flags);",
"dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx);",
"#if !defined(CONFIG_USER_ONLY)\ndc->user = (dc->current_el == 0);",
"#endif\ndc->cpacr_fpen = ARM_TBFLAG_AA64_FPEN(VAR_1->flags);",
"dc->vec_len = 0;",
"dc->vec_stride = 0;",
"dc->cp_regs = VAR_0->cp_regs;",
"dc->features = env->features;",
"dc->ss_active = ARM_TBFLAG_SS_ACTIVE(VAR_1->flags);",
"dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(VAR_1->flags);",
"dc->is_ldex = false;",
"dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el);",
"init_tmp_a64_array(dc);",
"next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;",
"VAR_4 = -1;",
"VAR_5 = 0;",
"VAR_6 = VAR_1->cflags & CF_COUNT_MASK;",
"if (VAR_6 == 0) {",
"VAR_6 = CF_COUNT_MASK;",
"}",
"gen_tb_start(VAR_1);",
"tcg_clear_temp_count();",
"do {",
"if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {",
"QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {",
"if (bp->pc == dc->pc) {",
"gen_exception_internal_insn(dc, 0, EXCP_DEBUG);",
"dc->pc += 2;",
"goto done_generating;",
"}",
"}",
"}",
"if (VAR_2) {",
"VAR_3 = tcg_op_buf_count();",
"if (VAR_4 < VAR_3) {",
"VAR_4++;",
"while (VAR_4 < VAR_3) {",
"tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;",
"}",
"}",
"tcg_ctx.gen_opc_pc[VAR_4] = dc->pc;",
"tcg_ctx.gen_opc_instr_start[VAR_4] = 1;",
"tcg_ctx.gen_opc_icount[VAR_4] = VAR_5;",
"}",
"if (VAR_5 + 1 == VAR_6 && (VAR_1->cflags & CF_LAST_IO)) {",
"gen_io_start();",
"}",
"if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {",
"tcg_gen_debug_insn_start(dc->pc);",
"}",
"if (dc->ss_active && !dc->pstate_ss) {",
"assert(VAR_5 == 0);",
"gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),\ndefault_exception_el(dc));",
"dc->is_jmp = DISAS_EXC;",
"break;",
"}",
"disas_a64_insn(env, dc);",
"if (tcg_check_temp_count()) {",
"fprintf(stderr, \"TCG temporary leak before \"TARGET_FMT_lx\"\\n\",\ndc->pc);",
"}",
"VAR_5++;",
"} while (!dc->is_jmp && !tcg_op_buf_full() &&",
"!cs->singlestep_enabled &&\n!singlestep &&\n!dc->ss_active &&\ndc->pc < next_page_start &&\nVAR_5 < VAR_6);",
"if (VAR_1->cflags & CF_LAST_IO) {",
"gen_io_end();",
"}",
"if (unlikely(cs->singlestep_enabled || dc->ss_active)\n&& dc->is_jmp != DISAS_EXC) {",
"assert(dc->is_jmp != DISAS_TB_JUMP);",
"if (dc->is_jmp != DISAS_JUMP) {",
"gen_a64_set_pc_im(dc->pc);",
"}",
"if (cs->singlestep_enabled) {",
"gen_exception_internal(EXCP_DEBUG);",
"} else {",
"gen_step_complete_exception(dc);",
"}",
"} else {",
"switch (dc->is_jmp) {",
"case DISAS_NEXT:\ngen_goto_tb(dc, 1, dc->pc);",
"break;",
"default:\ncase DISAS_UPDATE:\ngen_a64_set_pc_im(dc->pc);",
"case DISAS_JUMP:\ntcg_gen_exit_tb(0);",
"break;",
"case DISAS_TB_JUMP:\ncase DISAS_EXC:\ncase DISAS_SWI:\nbreak;",
"case DISAS_WFE:\ngen_a64_set_pc_im(dc->pc);",
"gen_helper_wfe(cpu_env);",
"break;",
"case DISAS_WFI:\ngen_a64_set_pc_im(dc->pc);",
"gen_helper_wfi(cpu_env);",
"break;",
"}",
"}",
"done_generating:\ngen_tb_end(VAR_1, VAR_5);",
"#ifdef DEBUG_DISAS\nif (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {",
"qemu_log(\"----------------\\n\");",
"qemu_log(\"IN: %s\\n\", lookup_symbol(pc_start));",
"log_target_disas(env, pc_start, dc->pc - pc_start,\n4 | (dc->bswap_code << 1));",
"qemu_log(\"\\n\");",
"}",
"#endif\nif (VAR_2) {",
"VAR_3 = tcg_op_buf_count();",
"VAR_4++;",
"while (VAR_4 <= VAR_3) {",
"tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;",
"}",
"} else {",
"VAR_1->size = dc->pc - pc_start;",
"VAR_1->icount = 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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
213
],
[
217
],
[
239
],
[
241,
243
],
[
245
],
[
247
],
[
249
],
[
253
],
[
257
],
[
259,
261
],
[
263
],
[
277
],
[
279
],
[
281,
283,
285,
287,
289
],
[
293
],
[
295
],
[
297
],
[
301,
303
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337,
339
],
[
341
],
[
343,
345,
347
],
[
351,
355
],
[
357
],
[
359,
361,
363,
365
],
[
367,
369
],
[
371
],
[
373
],
[
375,
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
395,
397
],
[
401,
403
],
[
405
],
[
407
],
[
409,
411
],
[
413
],
[
415
],
[
417,
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
]
] |
19,391 | static void gen_farith (DisasContext *ctx, uint32_t op1, int ft,
int fs, int fd, int cc)
{
const char *opn = "farith";
const char *condnames[] = {
"c.f",
"c.un",
"c.eq",
"c.ueq",
"c.olt",
"c.ult",
"c.ole",
"c.ule",
"c.sf",
"c.ngle",
"c.seq",
"c.ngl",
"c.lt",
"c.nge",
"c.le",
"c.ngt",
};
const char *condnames_abs[] = {
"cabs.f",
"cabs.un",
"cabs.eq",
"cabs.ueq",
"cabs.olt",
"cabs.ult",
"cabs.ole",
"cabs.ule",
"cabs.sf",
"cabs.ngle",
"cabs.seq",
"cabs.ngl",
"cabs.lt",
"cabs.nge",
"cabs.le",
"cabs.ngt",
};
enum { BINOP, CMPOP, OTHEROP } optype = OTHEROP;
uint32_t func = ctx->opcode & 0x3f;
switch (ctx->opcode & FOP(0x3f, 0x1f)) {
case FOP(0, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_add_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "add.s";
optype = BINOP;
break;
case FOP(1, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_sub_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "sub.s";
optype = BINOP;
break;
case FOP(2, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_mul_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "mul.s";
optype = BINOP;
break;
case FOP(3, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_div_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "div.s";
optype = BINOP;
break;
case FOP(4, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_sqrt_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "sqrt.s";
break;
case FOP(5, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_abs_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "abs.s";
break;
case FOP(6, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_mov_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "mov.s";
break;
case FOP(7, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_chs_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "neg.s";
break;
case FOP(8, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_roundl_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "round.l.s";
break;
case FOP(9, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_truncl_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "trunc.l.s";
break;
case FOP(10, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_ceill_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "ceil.l.s";
break;
case FOP(11, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_floorl_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "floor.l.s";
break;
case FOP(12, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_roundw_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "round.w.s";
break;
case FOP(13, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_truncw_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "trunc.w.s";
break;
case FOP(14, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_ceilw_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "ceil.w.s";
break;
case FOP(15, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_floorw_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "floor.w.s";
break;
case FOP(17, 16):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
gen_movcf_s(ctx, (ft >> 2) & 0x7, ft & 0x1);
GEN_STORE_FTN_FREG(fd, WT2);
opn = "movcf.s";
break;
case FOP(18, 16):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
gen_op_float_movz_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "movz.s";
break;
case FOP(19, 16):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
gen_op_float_movn_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "movn.s";
break;
case FOP(21, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_recip_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "recip.s";
break;
case FOP(22, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_rsqrt_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "rsqrt.s";
break;
case FOP(28, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
gen_op_float_recip2_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "recip2.s";
break;
case FOP(29, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_recip1_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "recip1.s";
break;
case FOP(30, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_rsqrt1_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "rsqrt1.s";
break;
case FOP(31, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
gen_op_float_rsqrt2_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "rsqrt2.s";
break;
case FOP(33, 16):
gen_op_cp1_registers(fd);
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvtd_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.d.s";
break;
case FOP(36, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvtw_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.w.s";
break;
case FOP(37, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvtl_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.l.s";
break;
case FOP(38, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT1, fs);
GEN_LOAD_FREG_FTN(WT0, ft);
gen_op_float_cvtps_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.ps.s";
break;
case FOP(48, 16):
case FOP(49, 16):
case FOP(50, 16):
case FOP(51, 16):
case FOP(52, 16):
case FOP(53, 16):
case FOP(54, 16):
case FOP(55, 16):
case FOP(56, 16):
case FOP(57, 16):
case FOP(58, 16):
case FOP(59, 16):
case FOP(60, 16):
case FOP(61, 16):
case FOP(62, 16):
case FOP(63, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
if (ctx->opcode & (1 << 6)) {
gen_op_cp1_64bitmode();
gen_cmpabs_s(func-48, cc);
opn = condnames_abs[func-48];
} else {
gen_cmp_s(func-48, cc);
opn = condnames[func-48];
}
break;
case FOP(0, 17):
gen_op_cp1_registers(fs | ft | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT1, ft);
gen_op_float_add_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "add.d";
optype = BINOP;
break;
case FOP(1, 17):
gen_op_cp1_registers(fs | ft | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT1, ft);
gen_op_float_sub_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "sub.d";
optype = BINOP;
break;
case FOP(2, 17):
gen_op_cp1_registers(fs | ft | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT1, ft);
gen_op_float_mul_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "mul.d";
optype = BINOP;
break;
case FOP(3, 17):
gen_op_cp1_registers(fs | ft | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT1, ft);
gen_op_float_div_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "div.d";
optype = BINOP;
break;
case FOP(4, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_sqrt_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "sqrt.d";
break;
case FOP(5, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_abs_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "abs.d";
break;
case FOP(6, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_mov_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "mov.d";
break;
case FOP(7, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_chs_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "neg.d";
break;
case FOP(8, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_roundl_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "round.l.d";
break;
case FOP(9, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_truncl_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "trunc.l.d";
break;
case FOP(10, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_ceill_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "ceil.l.d";
break;
case FOP(11, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_floorl_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "floor.l.d";
break;
case FOP(12, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_roundw_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "round.w.d";
break;
case FOP(13, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_truncw_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "trunc.w.d";
break;
case FOP(14, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_ceilw_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "ceil.w.d";
break;
case FOP(15, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_floorw_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "floor.w.d";
break;
case FOP(17, 17):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT2, fd);
gen_movcf_d(ctx, (ft >> 2) & 0x7, ft & 0x1);
GEN_STORE_FTN_FREG(fd, DT2);
opn = "movcf.d";
break;
case FOP(18, 17):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT2, fd);
gen_op_float_movz_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "movz.d";
break;
case FOP(19, 17):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT2, fd);
gen_op_float_movn_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "movn.d";
break;
case FOP(21, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_recip_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "recip.d";
break;
case FOP(22, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_rsqrt_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "rsqrt.d";
break;
case FOP(28, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT2, ft);
gen_op_float_recip2_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "recip2.d";
break;
case FOP(29, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_recip1_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "recip1.d";
break;
case FOP(30, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_rsqrt1_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "rsqrt1.d";
break;
case FOP(31, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT2, ft);
gen_op_float_rsqrt2_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "rsqrt2.d";
break;
case FOP(48, 17):
case FOP(49, 17):
case FOP(50, 17):
case FOP(51, 17):
case FOP(52, 17):
case FOP(53, 17):
case FOP(54, 17):
case FOP(55, 17):
case FOP(56, 17):
case FOP(57, 17):
case FOP(58, 17):
case FOP(59, 17):
case FOP(60, 17):
case FOP(61, 17):
case FOP(62, 17):
case FOP(63, 17):
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT1, ft);
if (ctx->opcode & (1 << 6)) {
gen_op_cp1_64bitmode();
gen_cmpabs_d(func-48, cc);
opn = condnames_abs[func-48];
} else {
gen_op_cp1_registers(fs | ft);
gen_cmp_d(func-48, cc);
opn = condnames[func-48];
}
break;
case FOP(32, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_cvts_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.s.d";
break;
case FOP(36, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_cvtw_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.w.d";
break;
case FOP(37, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_cvtl_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.l.d";
break;
case FOP(32, 20):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvts_w();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.s.w";
break;
case FOP(33, 20):
gen_op_cp1_registers(fd);
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvtd_w();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.d.w";
break;
case FOP(32, 21):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_cvts_l();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.s.l";
break;
case FOP(33, 21):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_cvtd_l();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.d.l";
break;
case FOP(38, 20):
case FOP(38, 21):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_cvtps_pw();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "cvt.ps.pw";
break;
case FOP(0, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
GEN_LOAD_FREG_FTN(WTH1, ft);
gen_op_float_add_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "add.ps";
break;
case FOP(1, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
GEN_LOAD_FREG_FTN(WTH1, ft);
gen_op_float_sub_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "sub.ps";
break;
case FOP(2, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
GEN_LOAD_FREG_FTN(WTH1, ft);
gen_op_float_mul_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "mul.ps";
break;
case FOP(5, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_abs_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "abs.ps";
break;
case FOP(6, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_mov_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "mov.ps";
break;
case FOP(7, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_chs_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "neg.ps";
break;
case FOP(17, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
GEN_LOAD_FREG_FTN(WTH2, fd);
gen_movcf_ps(ctx, (ft >> 2) & 0x7, ft & 0x1);
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "movcf.ps";
break;
case FOP(18, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
GEN_LOAD_FREG_FTN(WTH2, fd);
gen_op_float_movz_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "movz.ps";
break;
case FOP(19, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
GEN_LOAD_FREG_FTN(WTH2, fd);
gen_op_float_movn_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "movn.ps";
break;
case FOP(24, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, ft);
GEN_LOAD_FREG_FTN(WTH0, ft);
GEN_LOAD_FREG_FTN(WT1, fs);
GEN_LOAD_FREG_FTN(WTH1, fs);
gen_op_float_addr_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "addr.ps";
break;
case FOP(26, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, ft);
GEN_LOAD_FREG_FTN(WTH0, ft);
GEN_LOAD_FREG_FTN(WT1, fs);
GEN_LOAD_FREG_FTN(WTH1, fs);
gen_op_float_mulr_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "mulr.ps";
break;
case FOP(28, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
GEN_LOAD_FREG_FTN(WTH2, fd);
gen_op_float_recip2_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "recip2.ps";
break;
case FOP(29, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_recip1_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "recip1.ps";
break;
case FOP(30, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_rsqrt1_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "rsqrt1.ps";
break;
case FOP(31, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
GEN_LOAD_FREG_FTN(WTH2, fd);
gen_op_float_rsqrt2_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "rsqrt2.ps";
break;
case FOP(32, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_cvts_pu();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.s.pu";
break;
case FOP(36, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_cvtpw_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "cvt.pw.ps";
break;
case FOP(40, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvts_pl();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.s.pl";
break;
case FOP(44, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_pll_ps();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "pll.ps";
break;
case FOP(45, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH1, ft);
gen_op_float_plu_ps();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "plu.ps";
break;
case FOP(46, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_pul_ps();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "pul.ps";
break;
case FOP(47, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WTH1, ft);
gen_op_float_puu_ps();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "puu.ps";
break;
case FOP(48, 22):
case FOP(49, 22):
case FOP(50, 22):
case FOP(51, 22):
case FOP(52, 22):
case FOP(53, 22):
case FOP(54, 22):
case FOP(55, 22):
case FOP(56, 22):
case FOP(57, 22):
case FOP(58, 22):
case FOP(59, 22):
case FOP(60, 22):
case FOP(61, 22):
case FOP(62, 22):
case FOP(63, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
GEN_LOAD_FREG_FTN(WTH1, ft);
if (ctx->opcode & (1 << 6)) {
gen_cmpabs_ps(func-48, cc);
opn = condnames_abs[func-48];
} else {
gen_cmp_ps(func-48, cc);
opn = condnames[func-48];
}
break;
default:
MIPS_INVAL(opn);
generate_exception (ctx, EXCP_RI);
return;
}
switch (optype) {
case BINOP:
MIPS_DEBUG("%s %s, %s, %s", opn, fregnames[fd], fregnames[fs], fregnames[ft]);
break;
case CMPOP:
MIPS_DEBUG("%s %s,%s", opn, fregnames[fs], fregnames[ft]);
break;
default:
MIPS_DEBUG("%s %s,%s", opn, fregnames[fd], fregnames[fs]);
break;
}
}
| false | qemu | 5e755519ac9d867f7da13f58a9d0c262db82e14c | static void gen_farith (DisasContext *ctx, uint32_t op1, int ft,
int fs, int fd, int cc)
{
const char *opn = "farith";
const char *condnames[] = {
"c.f",
"c.un",
"c.eq",
"c.ueq",
"c.olt",
"c.ult",
"c.ole",
"c.ule",
"c.sf",
"c.ngle",
"c.seq",
"c.ngl",
"c.lt",
"c.nge",
"c.le",
"c.ngt",
};
const char *condnames_abs[] = {
"cabs.f",
"cabs.un",
"cabs.eq",
"cabs.ueq",
"cabs.olt",
"cabs.ult",
"cabs.ole",
"cabs.ule",
"cabs.sf",
"cabs.ngle",
"cabs.seq",
"cabs.ngl",
"cabs.lt",
"cabs.nge",
"cabs.le",
"cabs.ngt",
};
enum { BINOP, CMPOP, OTHEROP } optype = OTHEROP;
uint32_t func = ctx->opcode & 0x3f;
switch (ctx->opcode & FOP(0x3f, 0x1f)) {
case FOP(0, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_add_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "add.s";
optype = BINOP;
break;
case FOP(1, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_sub_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "sub.s";
optype = BINOP;
break;
case FOP(2, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_mul_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "mul.s";
optype = BINOP;
break;
case FOP(3, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_div_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "div.s";
optype = BINOP;
break;
case FOP(4, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_sqrt_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "sqrt.s";
break;
case FOP(5, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_abs_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "abs.s";
break;
case FOP(6, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_mov_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "mov.s";
break;
case FOP(7, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_chs_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "neg.s";
break;
case FOP(8, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_roundl_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "round.l.s";
break;
case FOP(9, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_truncl_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "trunc.l.s";
break;
case FOP(10, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_ceill_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "ceil.l.s";
break;
case FOP(11, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_floorl_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "floor.l.s";
break;
case FOP(12, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_roundw_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "round.w.s";
break;
case FOP(13, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_truncw_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "trunc.w.s";
break;
case FOP(14, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_ceilw_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "ceil.w.s";
break;
case FOP(15, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_floorw_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "floor.w.s";
break;
case FOP(17, 16):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
gen_movcf_s(ctx, (ft >> 2) & 0x7, ft & 0x1);
GEN_STORE_FTN_FREG(fd, WT2);
opn = "movcf.s";
break;
case FOP(18, 16):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
gen_op_float_movz_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "movz.s";
break;
case FOP(19, 16):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
gen_op_float_movn_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "movn.s";
break;
case FOP(21, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_recip_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "recip.s";
break;
case FOP(22, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_rsqrt_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "rsqrt.s";
break;
case FOP(28, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
gen_op_float_recip2_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "recip2.s";
break;
case FOP(29, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_recip1_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "recip1.s";
break;
case FOP(30, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_rsqrt1_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "rsqrt1.s";
break;
case FOP(31, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
gen_op_float_rsqrt2_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "rsqrt2.s";
break;
case FOP(33, 16):
gen_op_cp1_registers(fd);
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvtd_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.d.s";
break;
case FOP(36, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvtw_s();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.w.s";
break;
case FOP(37, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvtl_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.l.s";
break;
case FOP(38, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT1, fs);
GEN_LOAD_FREG_FTN(WT0, ft);
gen_op_float_cvtps_s();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.ps.s";
break;
case FOP(48, 16):
case FOP(49, 16):
case FOP(50, 16):
case FOP(51, 16):
case FOP(52, 16):
case FOP(53, 16):
case FOP(54, 16):
case FOP(55, 16):
case FOP(56, 16):
case FOP(57, 16):
case FOP(58, 16):
case FOP(59, 16):
case FOP(60, 16):
case FOP(61, 16):
case FOP(62, 16):
case FOP(63, 16):
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
if (ctx->opcode & (1 << 6)) {
gen_op_cp1_64bitmode();
gen_cmpabs_s(func-48, cc);
opn = condnames_abs[func-48];
} else {
gen_cmp_s(func-48, cc);
opn = condnames[func-48];
}
break;
case FOP(0, 17):
gen_op_cp1_registers(fs | ft | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT1, ft);
gen_op_float_add_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "add.d";
optype = BINOP;
break;
case FOP(1, 17):
gen_op_cp1_registers(fs | ft | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT1, ft);
gen_op_float_sub_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "sub.d";
optype = BINOP;
break;
case FOP(2, 17):
gen_op_cp1_registers(fs | ft | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT1, ft);
gen_op_float_mul_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "mul.d";
optype = BINOP;
break;
case FOP(3, 17):
gen_op_cp1_registers(fs | ft | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT1, ft);
gen_op_float_div_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "div.d";
optype = BINOP;
break;
case FOP(4, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_sqrt_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "sqrt.d";
break;
case FOP(5, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_abs_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "abs.d";
break;
case FOP(6, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_mov_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "mov.d";
break;
case FOP(7, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_chs_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "neg.d";
break;
case FOP(8, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_roundl_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "round.l.d";
break;
case FOP(9, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_truncl_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "trunc.l.d";
break;
case FOP(10, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_ceill_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "ceil.l.d";
break;
case FOP(11, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_floorl_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "floor.l.d";
break;
case FOP(12, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_roundw_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "round.w.d";
break;
case FOP(13, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_truncw_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "trunc.w.d";
break;
case FOP(14, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_ceilw_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "ceil.w.d";
break;
case FOP(15, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_floorw_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "floor.w.d";
break;
case FOP(17, 17):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT2, fd);
gen_movcf_d(ctx, (ft >> 2) & 0x7, ft & 0x1);
GEN_STORE_FTN_FREG(fd, DT2);
opn = "movcf.d";
break;
case FOP(18, 17):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT2, fd);
gen_op_float_movz_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "movz.d";
break;
case FOP(19, 17):
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT2, fd);
gen_op_float_movn_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "movn.d";
break;
case FOP(21, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_recip_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "recip.d";
break;
case FOP(22, 17):
gen_op_cp1_registers(fs | fd);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_rsqrt_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "rsqrt.d";
break;
case FOP(28, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT2, ft);
gen_op_float_recip2_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "recip2.d";
break;
case FOP(29, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_recip1_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "recip1.d";
break;
case FOP(30, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_rsqrt1_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "rsqrt1.d";
break;
case FOP(31, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT2, ft);
gen_op_float_rsqrt2_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "rsqrt2.d";
break;
case FOP(48, 17):
case FOP(49, 17):
case FOP(50, 17):
case FOP(51, 17):
case FOP(52, 17):
case FOP(53, 17):
case FOP(54, 17):
case FOP(55, 17):
case FOP(56, 17):
case FOP(57, 17):
case FOP(58, 17):
case FOP(59, 17):
case FOP(60, 17):
case FOP(61, 17):
case FOP(62, 17):
case FOP(63, 17):
GEN_LOAD_FREG_FTN(DT0, fs);
GEN_LOAD_FREG_FTN(DT1, ft);
if (ctx->opcode & (1 << 6)) {
gen_op_cp1_64bitmode();
gen_cmpabs_d(func-48, cc);
opn = condnames_abs[func-48];
} else {
gen_op_cp1_registers(fs | ft);
gen_cmp_d(func-48, cc);
opn = condnames[func-48];
}
break;
case FOP(32, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_cvts_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.s.d";
break;
case FOP(36, 17):
gen_op_cp1_registers(fs);
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_cvtw_d();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.w.d";
break;
case FOP(37, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_cvtl_d();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.l.d";
break;
case FOP(32, 20):
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvts_w();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.s.w";
break;
case FOP(33, 20):
gen_op_cp1_registers(fd);
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvtd_w();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.d.w";
break;
case FOP(32, 21):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_cvts_l();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.s.l";
break;
case FOP(33, 21):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, fs);
gen_op_float_cvtd_l();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "cvt.d.l";
break;
case FOP(38, 20):
case FOP(38, 21):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_cvtps_pw();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "cvt.ps.pw";
break;
case FOP(0, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
GEN_LOAD_FREG_FTN(WTH1, ft);
gen_op_float_add_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "add.ps";
break;
case FOP(1, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
GEN_LOAD_FREG_FTN(WTH1, ft);
gen_op_float_sub_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "sub.ps";
break;
case FOP(2, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
GEN_LOAD_FREG_FTN(WTH1, ft);
gen_op_float_mul_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "mul.ps";
break;
case FOP(5, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_abs_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "abs.ps";
break;
case FOP(6, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_mov_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "mov.ps";
break;
case FOP(7, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_chs_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "neg.ps";
break;
case FOP(17, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
GEN_LOAD_FREG_FTN(WTH2, fd);
gen_movcf_ps(ctx, (ft >> 2) & 0x7, ft & 0x1);
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "movcf.ps";
break;
case FOP(18, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
GEN_LOAD_FREG_FTN(WTH2, fd);
gen_op_float_movz_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "movz.ps";
break;
case FOP(19, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_REG_TN(T0, ft);
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
GEN_LOAD_FREG_FTN(WTH2, fd);
gen_op_float_movn_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "movn.ps";
break;
case FOP(24, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, ft);
GEN_LOAD_FREG_FTN(WTH0, ft);
GEN_LOAD_FREG_FTN(WT1, fs);
GEN_LOAD_FREG_FTN(WTH1, fs);
gen_op_float_addr_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "addr.ps";
break;
case FOP(26, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, ft);
GEN_LOAD_FREG_FTN(WTH0, ft);
GEN_LOAD_FREG_FTN(WT1, fs);
GEN_LOAD_FREG_FTN(WTH1, fs);
gen_op_float_mulr_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "mulr.ps";
break;
case FOP(28, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
GEN_LOAD_FREG_FTN(WTH2, fd);
gen_op_float_recip2_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "recip2.ps";
break;
case FOP(29, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_recip1_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "recip1.ps";
break;
case FOP(30, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_rsqrt1_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "rsqrt1.ps";
break;
case FOP(31, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT2, fd);
GEN_LOAD_FREG_FTN(WTH2, fd);
gen_op_float_rsqrt2_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "rsqrt2.ps";
break;
case FOP(32, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_cvts_pu();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.s.pu";
break;
case FOP(36, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
gen_op_float_cvtpw_ps();
GEN_STORE_FTN_FREG(fd, WT2);
GEN_STORE_FTN_FREG(fd, WTH2);
opn = "cvt.pw.ps";
break;
case FOP(40, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
gen_op_float_cvts_pl();
GEN_STORE_FTN_FREG(fd, WT2);
opn = "cvt.s.pl";
break;
case FOP(44, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_pll_ps();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "pll.ps";
break;
case FOP(45, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH1, ft);
gen_op_float_plu_ps();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "plu.ps";
break;
case FOP(46, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
gen_op_float_pul_ps();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "pul.ps";
break;
case FOP(47, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WTH1, ft);
gen_op_float_puu_ps();
GEN_STORE_FTN_FREG(fd, DT2);
opn = "puu.ps";
break;
case FOP(48, 22):
case FOP(49, 22):
case FOP(50, 22):
case FOP(51, 22):
case FOP(52, 22):
case FOP(53, 22):
case FOP(54, 22):
case FOP(55, 22):
case FOP(56, 22):
case FOP(57, 22):
case FOP(58, 22):
case FOP(59, 22):
case FOP(60, 22):
case FOP(61, 22):
case FOP(62, 22):
case FOP(63, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, fs);
GEN_LOAD_FREG_FTN(WTH0, fs);
GEN_LOAD_FREG_FTN(WT1, ft);
GEN_LOAD_FREG_FTN(WTH1, ft);
if (ctx->opcode & (1 << 6)) {
gen_cmpabs_ps(func-48, cc);
opn = condnames_abs[func-48];
} else {
gen_cmp_ps(func-48, cc);
opn = condnames[func-48];
}
break;
default:
MIPS_INVAL(opn);
generate_exception (ctx, EXCP_RI);
return;
}
switch (optype) {
case BINOP:
MIPS_DEBUG("%s %s, %s, %s", opn, fregnames[fd], fregnames[fs], fregnames[ft]);
break;
case CMPOP:
MIPS_DEBUG("%s %s,%s", opn, fregnames[fs], fregnames[ft]);
break;
default:
MIPS_DEBUG("%s %s,%s", opn, fregnames[fd], fregnames[fs]);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (DisasContext *VAR_0, uint32_t VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5)
{
const char *VAR_6 = "farith";
const char *VAR_7[] = {
"c.f",
"c.un",
"c.eq",
"c.ueq",
"c.olt",
"c.ult",
"c.ole",
"c.ule",
"c.sf",
"c.ngle",
"c.seq",
"c.ngl",
"c.lt",
"c.nge",
"c.le",
"c.ngt",
};
const char *VAR_8[] = {
"cabs.f",
"cabs.un",
"cabs.eq",
"cabs.ueq",
"cabs.olt",
"cabs.ult",
"cabs.ole",
"cabs.ule",
"cabs.sf",
"cabs.ngle",
"cabs.seq",
"cabs.ngl",
"cabs.lt",
"cabs.nge",
"cabs.le",
"cabs.ngt",
};
enum { BINOP, CMPOP, OTHEROP } VAR_9 = OTHEROP;
uint32_t func = VAR_0->opcode & 0x3f;
switch (VAR_0->opcode & FOP(0x3f, 0x1f)) {
case FOP(0, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
gen_op_float_add_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "add.s";
VAR_9 = BINOP;
break;
case FOP(1, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
gen_op_float_sub_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "sub.s";
VAR_9 = BINOP;
break;
case FOP(2, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
gen_op_float_mul_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "mul.s";
VAR_9 = BINOP;
break;
case FOP(3, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
gen_op_float_div_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "div.s";
VAR_9 = BINOP;
break;
case FOP(4, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_sqrt_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "sqrt.s";
break;
case FOP(5, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_abs_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "abs.s";
break;
case FOP(6, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_mov_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "mov.s";
break;
case FOP(7, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_chs_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "neg.s";
break;
case FOP(8, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_roundl_s();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "round.l.s";
break;
case FOP(9, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_truncl_s();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "trunc.l.s";
break;
case FOP(10, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_ceill_s();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "ceil.l.s";
break;
case FOP(11, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_floorl_s();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "floor.l.s";
break;
case FOP(12, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_roundw_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "round.w.s";
break;
case FOP(13, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_truncw_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "trunc.w.s";
break;
case FOP(14, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_ceilw_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "ceil.w.s";
break;
case FOP(15, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_floorw_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "floor.w.s";
break;
case FOP(17, 16):
GEN_LOAD_REG_TN(T0, VAR_2);
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT2, VAR_4);
gen_movcf_s(VAR_0, (VAR_2 >> 2) & 0x7, VAR_2 & 0x1);
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "movcf.s";
break;
case FOP(18, 16):
GEN_LOAD_REG_TN(T0, VAR_2);
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT2, VAR_4);
gen_op_float_movz_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "movz.s";
break;
case FOP(19, 16):
GEN_LOAD_REG_TN(T0, VAR_2);
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT2, VAR_4);
gen_op_float_movn_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "movn.s";
break;
case FOP(21, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_recip_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "recip.s";
break;
case FOP(22, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_rsqrt_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "rsqrt.s";
break;
case FOP(28, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT2, VAR_4);
gen_op_float_recip2_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "recip2.s";
break;
case FOP(29, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_recip1_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "recip1.s";
break;
case FOP(30, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_rsqrt1_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "rsqrt1.s";
break;
case FOP(31, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT2, VAR_4);
gen_op_float_rsqrt2_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "rsqrt2.s";
break;
case FOP(33, 16):
gen_op_cp1_registers(VAR_4);
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_cvtd_s();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "cvt.d.s";
break;
case FOP(36, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_cvtw_s();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "cvt.w.s";
break;
case FOP(37, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_cvtl_s();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "cvt.l.s";
break;
case FOP(38, 16):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT1, VAR_3);
GEN_LOAD_FREG_FTN(WT0, VAR_2);
gen_op_float_cvtps_s();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "cvt.ps.s";
break;
case FOP(48, 16):
case FOP(49, 16):
case FOP(50, 16):
case FOP(51, 16):
case FOP(52, 16):
case FOP(53, 16):
case FOP(54, 16):
case FOP(55, 16):
case FOP(56, 16):
case FOP(57, 16):
case FOP(58, 16):
case FOP(59, 16):
case FOP(60, 16):
case FOP(61, 16):
case FOP(62, 16):
case FOP(63, 16):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
if (VAR_0->opcode & (1 << 6)) {
gen_op_cp1_64bitmode();
gen_cmpabs_s(func-48, VAR_5);
VAR_6 = VAR_8[func-48];
} else {
gen_cmp_s(func-48, VAR_5);
VAR_6 = VAR_7[func-48];
}
break;
case FOP(0, 17):
gen_op_cp1_registers(VAR_3 | VAR_2 | VAR_4);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
GEN_LOAD_FREG_FTN(DT1, VAR_2);
gen_op_float_add_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "add.d";
VAR_9 = BINOP;
break;
case FOP(1, 17):
gen_op_cp1_registers(VAR_3 | VAR_2 | VAR_4);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
GEN_LOAD_FREG_FTN(DT1, VAR_2);
gen_op_float_sub_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "sub.d";
VAR_9 = BINOP;
break;
case FOP(2, 17):
gen_op_cp1_registers(VAR_3 | VAR_2 | VAR_4);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
GEN_LOAD_FREG_FTN(DT1, VAR_2);
gen_op_float_mul_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "mul.d";
VAR_9 = BINOP;
break;
case FOP(3, 17):
gen_op_cp1_registers(VAR_3 | VAR_2 | VAR_4);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
GEN_LOAD_FREG_FTN(DT1, VAR_2);
gen_op_float_div_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "div.d";
VAR_9 = BINOP;
break;
case FOP(4, 17):
gen_op_cp1_registers(VAR_3 | VAR_4);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_sqrt_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "sqrt.d";
break;
case FOP(5, 17):
gen_op_cp1_registers(VAR_3 | VAR_4);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_abs_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "abs.d";
break;
case FOP(6, 17):
gen_op_cp1_registers(VAR_3 | VAR_4);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_mov_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "mov.d";
break;
case FOP(7, 17):
gen_op_cp1_registers(VAR_3 | VAR_4);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_chs_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "neg.d";
break;
case FOP(8, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_roundl_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "round.l.d";
break;
case FOP(9, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_truncl_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "trunc.l.d";
break;
case FOP(10, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_ceill_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "ceil.l.d";
break;
case FOP(11, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_floorl_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "floor.l.d";
break;
case FOP(12, 17):
gen_op_cp1_registers(VAR_3);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_roundw_d();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "round.w.d";
break;
case FOP(13, 17):
gen_op_cp1_registers(VAR_3);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_truncw_d();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "trunc.w.d";
break;
case FOP(14, 17):
gen_op_cp1_registers(VAR_3);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_ceilw_d();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "ceil.w.d";
break;
case FOP(15, 17):
gen_op_cp1_registers(VAR_3);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_floorw_d();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "floor.w.d";
break;
case FOP(17, 17):
GEN_LOAD_REG_TN(T0, VAR_2);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
GEN_LOAD_FREG_FTN(DT2, VAR_4);
gen_movcf_d(VAR_0, (VAR_2 >> 2) & 0x7, VAR_2 & 0x1);
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "movcf.d";
break;
case FOP(18, 17):
GEN_LOAD_REG_TN(T0, VAR_2);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
GEN_LOAD_FREG_FTN(DT2, VAR_4);
gen_op_float_movz_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "movz.d";
break;
case FOP(19, 17):
GEN_LOAD_REG_TN(T0, VAR_2);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
GEN_LOAD_FREG_FTN(DT2, VAR_4);
gen_op_float_movn_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "movn.d";
break;
case FOP(21, 17):
gen_op_cp1_registers(VAR_3 | VAR_4);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_recip_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "recip.d";
break;
case FOP(22, 17):
gen_op_cp1_registers(VAR_3 | VAR_4);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_rsqrt_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "rsqrt.d";
break;
case FOP(28, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
GEN_LOAD_FREG_FTN(DT2, VAR_2);
gen_op_float_recip2_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "recip2.d";
break;
case FOP(29, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_recip1_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "recip1.d";
break;
case FOP(30, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_rsqrt1_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "rsqrt1.d";
break;
case FOP(31, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
GEN_LOAD_FREG_FTN(DT2, VAR_2);
gen_op_float_rsqrt2_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "rsqrt2.d";
break;
case FOP(48, 17):
case FOP(49, 17):
case FOP(50, 17):
case FOP(51, 17):
case FOP(52, 17):
case FOP(53, 17):
case FOP(54, 17):
case FOP(55, 17):
case FOP(56, 17):
case FOP(57, 17):
case FOP(58, 17):
case FOP(59, 17):
case FOP(60, 17):
case FOP(61, 17):
case FOP(62, 17):
case FOP(63, 17):
GEN_LOAD_FREG_FTN(DT0, VAR_3);
GEN_LOAD_FREG_FTN(DT1, VAR_2);
if (VAR_0->opcode & (1 << 6)) {
gen_op_cp1_64bitmode();
gen_cmpabs_d(func-48, VAR_5);
VAR_6 = VAR_8[func-48];
} else {
gen_op_cp1_registers(VAR_3 | VAR_2);
gen_cmp_d(func-48, VAR_5);
VAR_6 = VAR_7[func-48];
}
break;
case FOP(32, 17):
gen_op_cp1_registers(VAR_3);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_cvts_d();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "cvt.s.d";
break;
case FOP(36, 17):
gen_op_cp1_registers(VAR_3);
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_cvtw_d();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "cvt.w.d";
break;
case FOP(37, 17):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_cvtl_d();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "cvt.l.d";
break;
case FOP(32, 20):
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_cvts_w();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "cvt.s.w";
break;
case FOP(33, 20):
gen_op_cp1_registers(VAR_4);
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_cvtd_w();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "cvt.d.w";
break;
case FOP(32, 21):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_cvts_l();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "cvt.s.l";
break;
case FOP(33, 21):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(DT0, VAR_3);
gen_op_float_cvtd_l();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "cvt.d.l";
break;
case FOP(38, 20):
case FOP(38, 21):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
gen_op_float_cvtps_pw();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "cvt.ps.pw";
break;
case FOP(0, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
GEN_LOAD_FREG_FTN(WTH1, VAR_2);
gen_op_float_add_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "add.ps";
break;
case FOP(1, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
GEN_LOAD_FREG_FTN(WTH1, VAR_2);
gen_op_float_sub_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "sub.ps";
break;
case FOP(2, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
GEN_LOAD_FREG_FTN(WTH1, VAR_2);
gen_op_float_mul_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "mul.ps";
break;
case FOP(5, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
gen_op_float_abs_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "abs.ps";
break;
case FOP(6, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
gen_op_float_mov_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "mov.ps";
break;
case FOP(7, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
gen_op_float_chs_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "neg.ps";
break;
case FOP(17, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_REG_TN(T0, VAR_2);
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WT2, VAR_4);
GEN_LOAD_FREG_FTN(WTH2, VAR_4);
gen_movcf_ps(VAR_0, (VAR_2 >> 2) & 0x7, VAR_2 & 0x1);
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "movcf.ps";
break;
case FOP(18, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_REG_TN(T0, VAR_2);
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WT2, VAR_4);
GEN_LOAD_FREG_FTN(WTH2, VAR_4);
gen_op_float_movz_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "movz.ps";
break;
case FOP(19, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_REG_TN(T0, VAR_2);
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WT2, VAR_4);
GEN_LOAD_FREG_FTN(WTH2, VAR_4);
gen_op_float_movn_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "movn.ps";
break;
case FOP(24, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_2);
GEN_LOAD_FREG_FTN(WTH0, VAR_2);
GEN_LOAD_FREG_FTN(WT1, VAR_3);
GEN_LOAD_FREG_FTN(WTH1, VAR_3);
gen_op_float_addr_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "addr.ps";
break;
case FOP(26, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_2);
GEN_LOAD_FREG_FTN(WTH0, VAR_2);
GEN_LOAD_FREG_FTN(WT1, VAR_3);
GEN_LOAD_FREG_FTN(WTH1, VAR_3);
gen_op_float_mulr_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "mulr.ps";
break;
case FOP(28, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WT2, VAR_4);
GEN_LOAD_FREG_FTN(WTH2, VAR_4);
gen_op_float_recip2_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "recip2.ps";
break;
case FOP(29, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
gen_op_float_recip1_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "recip1.ps";
break;
case FOP(30, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
gen_op_float_rsqrt1_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "rsqrt1.ps";
break;
case FOP(31, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WT2, VAR_4);
GEN_LOAD_FREG_FTN(WTH2, VAR_4);
gen_op_float_rsqrt2_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "rsqrt2.ps";
break;
case FOP(32, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
gen_op_float_cvts_pu();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "cvt.s.pu";
break;
case FOP(36, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
gen_op_float_cvtpw_ps();
GEN_STORE_FTN_FREG(VAR_4, WT2);
GEN_STORE_FTN_FREG(VAR_4, WTH2);
VAR_6 = "cvt.pw.ps";
break;
case FOP(40, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
gen_op_float_cvts_pl();
GEN_STORE_FTN_FREG(VAR_4, WT2);
VAR_6 = "cvt.s.pl";
break;
case FOP(44, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
gen_op_float_pll_ps();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "pll.ps";
break;
case FOP(45, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH1, VAR_2);
gen_op_float_plu_ps();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "plu.ps";
break;
case FOP(46, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
gen_op_float_pul_ps();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "pul.ps";
break;
case FOP(47, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WTH1, VAR_2);
gen_op_float_puu_ps();
GEN_STORE_FTN_FREG(VAR_4, DT2);
VAR_6 = "puu.ps";
break;
case FOP(48, 22):
case FOP(49, 22):
case FOP(50, 22):
case FOP(51, 22):
case FOP(52, 22):
case FOP(53, 22):
case FOP(54, 22):
case FOP(55, 22):
case FOP(56, 22):
case FOP(57, 22):
case FOP(58, 22):
case FOP(59, 22):
case FOP(60, 22):
case FOP(61, 22):
case FOP(62, 22):
case FOP(63, 22):
gen_op_cp1_64bitmode();
GEN_LOAD_FREG_FTN(WT0, VAR_3);
GEN_LOAD_FREG_FTN(WTH0, VAR_3);
GEN_LOAD_FREG_FTN(WT1, VAR_2);
GEN_LOAD_FREG_FTN(WTH1, VAR_2);
if (VAR_0->opcode & (1 << 6)) {
gen_cmpabs_ps(func-48, VAR_5);
VAR_6 = VAR_8[func-48];
} else {
gen_cmp_ps(func-48, VAR_5);
VAR_6 = VAR_7[func-48];
}
break;
default:
MIPS_INVAL(VAR_6);
generate_exception (VAR_0, EXCP_RI);
return;
}
switch (VAR_9) {
case BINOP:
MIPS_DEBUG("%s %s, %s, %s", VAR_6, fregnames[VAR_4], fregnames[VAR_3], fregnames[VAR_2]);
break;
case CMPOP:
MIPS_DEBUG("%s %s,%s", VAR_6, fregnames[VAR_3], fregnames[VAR_2]);
break;
default:
MIPS_DEBUG("%s %s,%s", VAR_6, fregnames[VAR_4], fregnames[VAR_3]);
break;
}
}
| [
"static void FUNC_0 (DisasContext *VAR_0, uint32_t VAR_1, int VAR_2,\nint VAR_3, int VAR_4, int VAR_5)\n{",
"const char *VAR_6 = \"farith\";",
"const char *VAR_7[] = {",
"\"c.f\",\n\"c.un\",\n\"c.eq\",\n\"c.ueq\",\n\"c.olt\",\n\"c.ult\",\n\"c.ole\",\n\"c.ule\",\n\"c.sf\",\n\"c.ngle\",\n\"c.seq\",\n\"c.ngl\",\n\"c.lt\",\n\"c.nge\",\n\"c.le\",\n\"c.ngt\",\n};",
"const char *VAR_8[] = {",
"\"cabs.f\",\n\"cabs.un\",\n\"cabs.eq\",\n\"cabs.ueq\",\n\"cabs.olt\",\n\"cabs.ult\",\n\"cabs.ole\",\n\"cabs.ule\",\n\"cabs.sf\",\n\"cabs.ngle\",\n\"cabs.seq\",\n\"cabs.ngl\",\n\"cabs.lt\",\n\"cabs.nge\",\n\"cabs.le\",\n\"cabs.ngt\",\n};",
"enum { BINOP, CMPOP, OTHEROP } VAR_9 = OTHEROP;",
"uint32_t func = VAR_0->opcode & 0x3f;",
"switch (VAR_0->opcode & FOP(0x3f, 0x1f)) {",
"case FOP(0, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"gen_op_float_add_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"add.s\";",
"VAR_9 = BINOP;",
"break;",
"case FOP(1, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"gen_op_float_sub_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"sub.s\";",
"VAR_9 = BINOP;",
"break;",
"case FOP(2, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"gen_op_float_mul_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"mul.s\";",
"VAR_9 = BINOP;",
"break;",
"case FOP(3, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"gen_op_float_div_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"div.s\";",
"VAR_9 = BINOP;",
"break;",
"case FOP(4, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_sqrt_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"sqrt.s\";",
"break;",
"case FOP(5, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_abs_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"abs.s\";",
"break;",
"case FOP(6, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_mov_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"mov.s\";",
"break;",
"case FOP(7, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_chs_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"neg.s\";",
"break;",
"case FOP(8, 16):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_roundl_s();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"round.l.s\";",
"break;",
"case FOP(9, 16):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_truncl_s();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"trunc.l.s\";",
"break;",
"case FOP(10, 16):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_ceill_s();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"ceil.l.s\";",
"break;",
"case FOP(11, 16):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_floorl_s();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"floor.l.s\";",
"break;",
"case FOP(12, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_roundw_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"round.w.s\";",
"break;",
"case FOP(13, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_truncw_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"trunc.w.s\";",
"break;",
"case FOP(14, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_ceilw_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"ceil.w.s\";",
"break;",
"case FOP(15, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_floorw_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"floor.w.s\";",
"break;",
"case FOP(17, 16):\nGEN_LOAD_REG_TN(T0, VAR_2);",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT2, VAR_4);",
"gen_movcf_s(VAR_0, (VAR_2 >> 2) & 0x7, VAR_2 & 0x1);",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"movcf.s\";",
"break;",
"case FOP(18, 16):\nGEN_LOAD_REG_TN(T0, VAR_2);",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT2, VAR_4);",
"gen_op_float_movz_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"movz.s\";",
"break;",
"case FOP(19, 16):\nGEN_LOAD_REG_TN(T0, VAR_2);",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT2, VAR_4);",
"gen_op_float_movn_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"movn.s\";",
"break;",
"case FOP(21, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_recip_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"recip.s\";",
"break;",
"case FOP(22, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_rsqrt_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"rsqrt.s\";",
"break;",
"case FOP(28, 16):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT2, VAR_4);",
"gen_op_float_recip2_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"recip2.s\";",
"break;",
"case FOP(29, 16):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_recip1_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"recip1.s\";",
"break;",
"case FOP(30, 16):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_rsqrt1_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"rsqrt1.s\";",
"break;",
"case FOP(31, 16):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT2, VAR_4);",
"gen_op_float_rsqrt2_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"rsqrt2.s\";",
"break;",
"case FOP(33, 16):\ngen_op_cp1_registers(VAR_4);",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_cvtd_s();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"cvt.d.s\";",
"break;",
"case FOP(36, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_cvtw_s();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"cvt.w.s\";",
"break;",
"case FOP(37, 16):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_cvtl_s();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"cvt.l.s\";",
"break;",
"case FOP(38, 16):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT1, VAR_3);",
"GEN_LOAD_FREG_FTN(WT0, VAR_2);",
"gen_op_float_cvtps_s();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"cvt.ps.s\";",
"break;",
"case FOP(48, 16):\ncase FOP(49, 16):\ncase FOP(50, 16):\ncase FOP(51, 16):\ncase FOP(52, 16):\ncase FOP(53, 16):\ncase FOP(54, 16):\ncase FOP(55, 16):\ncase FOP(56, 16):\ncase FOP(57, 16):\ncase FOP(58, 16):\ncase FOP(59, 16):\ncase FOP(60, 16):\ncase FOP(61, 16):\ncase FOP(62, 16):\ncase FOP(63, 16):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"if (VAR_0->opcode & (1 << 6)) {",
"gen_op_cp1_64bitmode();",
"gen_cmpabs_s(func-48, VAR_5);",
"VAR_6 = VAR_8[func-48];",
"} else {",
"gen_cmp_s(func-48, VAR_5);",
"VAR_6 = VAR_7[func-48];",
"}",
"break;",
"case FOP(0, 17):\ngen_op_cp1_registers(VAR_3 | VAR_2 | VAR_4);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"GEN_LOAD_FREG_FTN(DT1, VAR_2);",
"gen_op_float_add_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"add.d\";",
"VAR_9 = BINOP;",
"break;",
"case FOP(1, 17):\ngen_op_cp1_registers(VAR_3 | VAR_2 | VAR_4);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"GEN_LOAD_FREG_FTN(DT1, VAR_2);",
"gen_op_float_sub_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"sub.d\";",
"VAR_9 = BINOP;",
"break;",
"case FOP(2, 17):\ngen_op_cp1_registers(VAR_3 | VAR_2 | VAR_4);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"GEN_LOAD_FREG_FTN(DT1, VAR_2);",
"gen_op_float_mul_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"mul.d\";",
"VAR_9 = BINOP;",
"break;",
"case FOP(3, 17):\ngen_op_cp1_registers(VAR_3 | VAR_2 | VAR_4);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"GEN_LOAD_FREG_FTN(DT1, VAR_2);",
"gen_op_float_div_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"div.d\";",
"VAR_9 = BINOP;",
"break;",
"case FOP(4, 17):\ngen_op_cp1_registers(VAR_3 | VAR_4);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_sqrt_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"sqrt.d\";",
"break;",
"case FOP(5, 17):\ngen_op_cp1_registers(VAR_3 | VAR_4);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_abs_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"abs.d\";",
"break;",
"case FOP(6, 17):\ngen_op_cp1_registers(VAR_3 | VAR_4);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_mov_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"mov.d\";",
"break;",
"case FOP(7, 17):\ngen_op_cp1_registers(VAR_3 | VAR_4);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_chs_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"neg.d\";",
"break;",
"case FOP(8, 17):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_roundl_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"round.l.d\";",
"break;",
"case FOP(9, 17):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_truncl_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"trunc.l.d\";",
"break;",
"case FOP(10, 17):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_ceill_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"ceil.l.d\";",
"break;",
"case FOP(11, 17):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_floorl_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"floor.l.d\";",
"break;",
"case FOP(12, 17):\ngen_op_cp1_registers(VAR_3);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_roundw_d();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"round.w.d\";",
"break;",
"case FOP(13, 17):\ngen_op_cp1_registers(VAR_3);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_truncw_d();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"trunc.w.d\";",
"break;",
"case FOP(14, 17):\ngen_op_cp1_registers(VAR_3);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_ceilw_d();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"ceil.w.d\";",
"break;",
"case FOP(15, 17):\ngen_op_cp1_registers(VAR_3);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_floorw_d();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"floor.w.d\";",
"break;",
"case FOP(17, 17):\nGEN_LOAD_REG_TN(T0, VAR_2);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"GEN_LOAD_FREG_FTN(DT2, VAR_4);",
"gen_movcf_d(VAR_0, (VAR_2 >> 2) & 0x7, VAR_2 & 0x1);",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"movcf.d\";",
"break;",
"case FOP(18, 17):\nGEN_LOAD_REG_TN(T0, VAR_2);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"GEN_LOAD_FREG_FTN(DT2, VAR_4);",
"gen_op_float_movz_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"movz.d\";",
"break;",
"case FOP(19, 17):\nGEN_LOAD_REG_TN(T0, VAR_2);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"GEN_LOAD_FREG_FTN(DT2, VAR_4);",
"gen_op_float_movn_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"movn.d\";",
"break;",
"case FOP(21, 17):\ngen_op_cp1_registers(VAR_3 | VAR_4);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_recip_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"recip.d\";",
"break;",
"case FOP(22, 17):\ngen_op_cp1_registers(VAR_3 | VAR_4);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_rsqrt_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"rsqrt.d\";",
"break;",
"case FOP(28, 17):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"GEN_LOAD_FREG_FTN(DT2, VAR_2);",
"gen_op_float_recip2_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"recip2.d\";",
"break;",
"case FOP(29, 17):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_recip1_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"recip1.d\";",
"break;",
"case FOP(30, 17):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_rsqrt1_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"rsqrt1.d\";",
"break;",
"case FOP(31, 17):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"GEN_LOAD_FREG_FTN(DT2, VAR_2);",
"gen_op_float_rsqrt2_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"rsqrt2.d\";",
"break;",
"case FOP(48, 17):\ncase FOP(49, 17):\ncase FOP(50, 17):\ncase FOP(51, 17):\ncase FOP(52, 17):\ncase FOP(53, 17):\ncase FOP(54, 17):\ncase FOP(55, 17):\ncase FOP(56, 17):\ncase FOP(57, 17):\ncase FOP(58, 17):\ncase FOP(59, 17):\ncase FOP(60, 17):\ncase FOP(61, 17):\ncase FOP(62, 17):\ncase FOP(63, 17):\nGEN_LOAD_FREG_FTN(DT0, VAR_3);",
"GEN_LOAD_FREG_FTN(DT1, VAR_2);",
"if (VAR_0->opcode & (1 << 6)) {",
"gen_op_cp1_64bitmode();",
"gen_cmpabs_d(func-48, VAR_5);",
"VAR_6 = VAR_8[func-48];",
"} else {",
"gen_op_cp1_registers(VAR_3 | VAR_2);",
"gen_cmp_d(func-48, VAR_5);",
"VAR_6 = VAR_7[func-48];",
"}",
"break;",
"case FOP(32, 17):\ngen_op_cp1_registers(VAR_3);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_cvts_d();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"cvt.s.d\";",
"break;",
"case FOP(36, 17):\ngen_op_cp1_registers(VAR_3);",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_cvtw_d();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"cvt.w.d\";",
"break;",
"case FOP(37, 17):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_cvtl_d();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"cvt.l.d\";",
"break;",
"case FOP(32, 20):\nGEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_cvts_w();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"cvt.s.w\";",
"break;",
"case FOP(33, 20):\ngen_op_cp1_registers(VAR_4);",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_cvtd_w();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"cvt.d.w\";",
"break;",
"case FOP(32, 21):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_cvts_l();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"cvt.s.l\";",
"break;",
"case FOP(33, 21):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(DT0, VAR_3);",
"gen_op_float_cvtd_l();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"cvt.d.l\";",
"break;",
"case FOP(38, 20):\ncase FOP(38, 21):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"gen_op_float_cvtps_pw();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"cvt.ps.pw\";",
"break;",
"case FOP(0, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"GEN_LOAD_FREG_FTN(WTH1, VAR_2);",
"gen_op_float_add_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"add.ps\";",
"break;",
"case FOP(1, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"GEN_LOAD_FREG_FTN(WTH1, VAR_2);",
"gen_op_float_sub_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"sub.ps\";",
"break;",
"case FOP(2, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"GEN_LOAD_FREG_FTN(WTH1, VAR_2);",
"gen_op_float_mul_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"mul.ps\";",
"break;",
"case FOP(5, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"gen_op_float_abs_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"abs.ps\";",
"break;",
"case FOP(6, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"gen_op_float_mov_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"mov.ps\";",
"break;",
"case FOP(7, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"gen_op_float_chs_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"neg.ps\";",
"break;",
"case FOP(17, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_REG_TN(T0, VAR_2);",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT2, VAR_4);",
"GEN_LOAD_FREG_FTN(WTH2, VAR_4);",
"gen_movcf_ps(VAR_0, (VAR_2 >> 2) & 0x7, VAR_2 & 0x1);",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"movcf.ps\";",
"break;",
"case FOP(18, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_REG_TN(T0, VAR_2);",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT2, VAR_4);",
"GEN_LOAD_FREG_FTN(WTH2, VAR_4);",
"gen_op_float_movz_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"movz.ps\";",
"break;",
"case FOP(19, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_REG_TN(T0, VAR_2);",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT2, VAR_4);",
"GEN_LOAD_FREG_FTN(WTH2, VAR_4);",
"gen_op_float_movn_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"movn.ps\";",
"break;",
"case FOP(24, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_2);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_2);",
"GEN_LOAD_FREG_FTN(WT1, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH1, VAR_3);",
"gen_op_float_addr_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"addr.ps\";",
"break;",
"case FOP(26, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_2);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_2);",
"GEN_LOAD_FREG_FTN(WT1, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH1, VAR_3);",
"gen_op_float_mulr_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"mulr.ps\";",
"break;",
"case FOP(28, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT2, VAR_4);",
"GEN_LOAD_FREG_FTN(WTH2, VAR_4);",
"gen_op_float_recip2_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"recip2.ps\";",
"break;",
"case FOP(29, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"gen_op_float_recip1_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"recip1.ps\";",
"break;",
"case FOP(30, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"gen_op_float_rsqrt1_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"rsqrt1.ps\";",
"break;",
"case FOP(31, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT2, VAR_4);",
"GEN_LOAD_FREG_FTN(WTH2, VAR_4);",
"gen_op_float_rsqrt2_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"rsqrt2.ps\";",
"break;",
"case FOP(32, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"gen_op_float_cvts_pu();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"cvt.s.pu\";",
"break;",
"case FOP(36, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"gen_op_float_cvtpw_ps();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"GEN_STORE_FTN_FREG(VAR_4, WTH2);",
"VAR_6 = \"cvt.pw.ps\";",
"break;",
"case FOP(40, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"gen_op_float_cvts_pl();",
"GEN_STORE_FTN_FREG(VAR_4, WT2);",
"VAR_6 = \"cvt.s.pl\";",
"break;",
"case FOP(44, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"gen_op_float_pll_ps();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"pll.ps\";",
"break;",
"case FOP(45, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH1, VAR_2);",
"gen_op_float_plu_ps();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"plu.ps\";",
"break;",
"case FOP(46, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"gen_op_float_pul_ps();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"pul.ps\";",
"break;",
"case FOP(47, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH1, VAR_2);",
"gen_op_float_puu_ps();",
"GEN_STORE_FTN_FREG(VAR_4, DT2);",
"VAR_6 = \"puu.ps\";",
"break;",
"case FOP(48, 22):\ncase FOP(49, 22):\ncase FOP(50, 22):\ncase FOP(51, 22):\ncase FOP(52, 22):\ncase FOP(53, 22):\ncase FOP(54, 22):\ncase FOP(55, 22):\ncase FOP(56, 22):\ncase FOP(57, 22):\ncase FOP(58, 22):\ncase FOP(59, 22):\ncase FOP(60, 22):\ncase FOP(61, 22):\ncase FOP(62, 22):\ncase FOP(63, 22):\ngen_op_cp1_64bitmode();",
"GEN_LOAD_FREG_FTN(WT0, VAR_3);",
"GEN_LOAD_FREG_FTN(WTH0, VAR_3);",
"GEN_LOAD_FREG_FTN(WT1, VAR_2);",
"GEN_LOAD_FREG_FTN(WTH1, VAR_2);",
"if (VAR_0->opcode & (1 << 6)) {",
"gen_cmpabs_ps(func-48, VAR_5);",
"VAR_6 = VAR_8[func-48];",
"} else {",
"gen_cmp_ps(func-48, VAR_5);",
"VAR_6 = VAR_7[func-48];",
"}",
"break;",
"default:\nMIPS_INVAL(VAR_6);",
"generate_exception (VAR_0, EXCP_RI);",
"return;",
"}",
"switch (VAR_9) {",
"case BINOP:\nMIPS_DEBUG(\"%s %s, %s, %s\", VAR_6, fregnames[VAR_4], fregnames[VAR_3], fregnames[VAR_2]);",
"break;",
"case CMPOP:\nMIPS_DEBUG(\"%s %s,%s\", VAR_6, fregnames[VAR_3], fregnames[VAR_2]);",
"break;",
"default:\nMIPS_DEBUG(\"%s %s,%s\", VAR_6, fregnames[VAR_4], fregnames[VAR_3]);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
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
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201,
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229,
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243,
245
],
[
247
],
[
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
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353,
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365,
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377,
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393,
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407,
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421,
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437,
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451,
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463,
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477,
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493,
495,
497,
499,
501,
503,
505,
507,
509,
511,
513,
515,
517,
519,
521,
523,
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545
],
[
547,
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565,
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583,
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601,
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617
],
[
619,
621
],
[
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633,
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
647,
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661,
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673
],
[
675,
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689,
691
],
[
693
],
[
695
],
[
697
],
[
699
],
[
701
],
[
703,
705
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717,
719
],
[
721
],
[
723
],
[
725
],
[
727
],
[
729
],
[
731,
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
745,
747
],
[
749
],
[
751
],
[
753
],
[
755
],
[
757
],
[
759,
761
],
[
763
],
[
765
],
[
767
],
[
769
],
[
771
],
[
773,
775
],
[
777
],
[
779
],
[
781
],
[
783
],
[
785
],
[
787,
789
],
[
791
],
[
793
],
[
795
],
[
797
],
[
799
],
[
801
],
[
803,
805
],
[
807
],
[
809
],
[
811
],
[
813
],
[
815
],
[
817
],
[
819,
821
],
[
823
],
[
825
],
[
827
],
[
829
],
[
831
],
[
833
],
[
835,
837
],
[
839
],
[
841
],
[
843
],
[
845
],
[
847
],
[
849,
851
],
[
853
],
[
855
],
[
857
],
[
859
],
[
861
],
[
863,
865
],
[
867
],
[
869
],
[
871
],
[
873
],
[
875
],
[
877
],
[
879,
881
],
[
883
],
[
885
],
[
887
],
[
889
],
[
891
],
[
893,
895
],
[
897
],
[
899
],
[
901
],
[
903
],
[
905
],
[
907,
909
],
[
911
],
[
913
],
[
915
],
[
917
],
[
919
],
[
921
],
[
923,
925,
927,
929,
931,
933,
935,
937,
939,
941,
943,
945,
947,
949,
951,
953,
955
],
[
957
],
[
959
],
[
961
],
[
963
],
[
965
],
[
967
],
[
969
],
[
971
],
[
973
],
[
975
],
[
977
],
[
979,
981
],
[
983
],
[
985
],
[
987
],
[
989
],
[
991
],
[
993,
995
],
[
997
],
[
999
],
[
1001
],
[
1003
],
[
1005
],
[
1007,
1009
],
[
1011
],
[
1013
],
[
1015
],
[
1017
],
[
1019
],
[
1021,
1023
],
[
1025
],
[
1027
],
[
1029
],
[
1031
],
[
1033,
1035
],
[
1037
],
[
1039
],
[
1041
],
[
1043
],
[
1045
],
[
1047,
1049
],
[
1051
],
[
1053
],
[
1055
],
[
1057
],
[
1059
],
[
1061,
1063
],
[
1065
],
[
1067
],
[
1069
],
[
1071
],
[
1073
],
[
1075,
1077,
1079
],
[
1081
],
[
1083
],
[
1085
],
[
1087
],
[
1089
],
[
1091
],
[
1093
],
[
1095,
1097
],
[
1099
],
[
1101
],
[
1103
],
[
1105
],
[
1107
],
[
1109
],
[
1111
],
[
1113
],
[
1115
],
[
1117,
1119
],
[
1121
],
[
1123
],
[
1125
],
[
1127
],
[
1129
],
[
1131
],
[
1133
],
[
1135
],
[
1137
],
[
1139,
1141
],
[
1143
],
[
1145
],
[
1147
],
[
1149
],
[
1151
],
[
1153
],
[
1155
],
[
1157
],
[
1159
],
[
1161,
1163
],
[
1165
],
[
1167
],
[
1169
],
[
1171
],
[
1173
],
[
1175
],
[
1177
],
[
1179,
1181
],
[
1183
],
[
1185
],
[
1187
],
[
1189
],
[
1191
],
[
1193
],
[
1195
],
[
1197,
1199
],
[
1201
],
[
1203
],
[
1205
],
[
1207
],
[
1209
],
[
1211
],
[
1213
],
[
1215,
1217
],
[
1219
],
[
1221
],
[
1223
],
[
1225
],
[
1227
],
[
1229
],
[
1231
],
[
1233
],
[
1235
],
[
1237
],
[
1239,
1241
],
[
1243
],
[
1245
],
[
1247
],
[
1249
],
[
1251
],
[
1253
],
[
1255
],
[
1257
],
[
1259
],
[
1261
],
[
1263,
1265
],
[
1267
],
[
1269
],
[
1271
],
[
1273
],
[
1275
],
[
1277
],
[
1279
],
[
1281
],
[
1283
],
[
1285
],
[
1287,
1289
],
[
1291
],
[
1293
],
[
1295
],
[
1297
],
[
1299
],
[
1301
],
[
1303
],
[
1305
],
[
1307
],
[
1309,
1311
],
[
1313
],
[
1315
],
[
1317
],
[
1319
],
[
1321
],
[
1323
],
[
1325
],
[
1327
],
[
1329
],
[
1331,
1333
],
[
1335
],
[
1337
],
[
1339
],
[
1341
],
[
1343
],
[
1345
],
[
1347
],
[
1349
],
[
1351
],
[
1353,
1355
],
[
1357
],
[
1359
],
[
1361
],
[
1363
],
[
1365
],
[
1367
],
[
1369
],
[
1371,
1373
],
[
1375
],
[
1377
],
[
1379
],
[
1381
],
[
1383
],
[
1385
],
[
1387
],
[
1389,
1391
],
[
1393
],
[
1395
],
[
1397
],
[
1399
],
[
1401
],
[
1403
],
[
1405
],
[
1407
],
[
1409
],
[
1411,
1413
],
[
1415
],
[
1417
],
[
1419
],
[
1421
],
[
1423
],
[
1425,
1427
],
[
1429
],
[
1431
],
[
1433
],
[
1435
],
[
1437
],
[
1439
],
[
1441
],
[
1443,
1445
],
[
1447
],
[
1449
],
[
1451
],
[
1453
],
[
1455
],
[
1457,
1459
],
[
1461
],
[
1463
],
[
1465
],
[
1467
],
[
1469
],
[
1471
],
[
1473,
1475
],
[
1477
],
[
1479
],
[
1481
],
[
1483
],
[
1485
],
[
1487
],
[
1489,
1491
],
[
1493
],
[
1495
],
[
1497
],
[
1499
],
[
1501
],
[
1503
],
[
1505,
1507
],
[
1509
],
[
1511
],
[
1513
],
[
1515
],
[
1517
],
[
1519
],
[
1521,
1523,
1525,
1527,
1529,
1531,
1533,
1535,
1537,
1539,
1541,
1543,
1545,
1547,
1549,
1551,
1553
],
[
1555
],
[
1557
],
[
1559
],
[
1561
],
[
1563
],
[
1565
],
[
1567
],
[
1569
],
[
1571
],
[
1573
],
[
1575
],
[
1577
],
[
1579,
1581
],
[
1583
],
[
1585
],
[
1587
],
[
1589
],
[
1591,
1593
],
[
1595
],
[
1597,
1599
],
[
1601
],
[
1603,
1605
],
[
1607
],
[
1609
],
[
1611
]
] |
19,392 | static int count_contiguous_clusters_unallocated(int nb_clusters,
uint64_t *l2_table,
QCow2ClusterType wanted_type)
{
int i;
assert(wanted_type == QCOW2_CLUSTER_ZERO ||
wanted_type == QCOW2_CLUSTER_UNALLOCATED);
for (i = 0; i < nb_clusters; i++) {
uint64_t entry = be64_to_cpu(l2_table[i]);
QCow2ClusterType type = qcow2_get_cluster_type(entry);
if (type != wanted_type || entry & L2E_OFFSET_MASK) {
break;
}
}
return i;
}
| false | qemu | fdfab37dfeffefbd4533b4158055c9b82d7c3e69 | static int count_contiguous_clusters_unallocated(int nb_clusters,
uint64_t *l2_table,
QCow2ClusterType wanted_type)
{
int i;
assert(wanted_type == QCOW2_CLUSTER_ZERO ||
wanted_type == QCOW2_CLUSTER_UNALLOCATED);
for (i = 0; i < nb_clusters; i++) {
uint64_t entry = be64_to_cpu(l2_table[i]);
QCow2ClusterType type = qcow2_get_cluster_type(entry);
if (type != wanted_type || entry & L2E_OFFSET_MASK) {
break;
}
}
return i;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0,
uint64_t *VAR_1,
QCow2ClusterType VAR_2)
{
int VAR_3;
assert(VAR_2 == QCOW2_CLUSTER_ZERO ||
VAR_2 == QCOW2_CLUSTER_UNALLOCATED);
for (VAR_3 = 0; VAR_3 < VAR_0; VAR_3++) {
uint64_t entry = be64_to_cpu(VAR_1[VAR_3]);
QCow2ClusterType type = qcow2_get_cluster_type(entry);
if (type != VAR_2 || entry & L2E_OFFSET_MASK) {
break;
}
}
return VAR_3;
}
| [
"static int FUNC_0(int VAR_0,\nuint64_t *VAR_1,\nQCow2ClusterType VAR_2)\n{",
"int VAR_3;",
"assert(VAR_2 == QCOW2_CLUSTER_ZERO ||\nVAR_2 == QCOW2_CLUSTER_UNALLOCATED);",
"for (VAR_3 = 0; VAR_3 < VAR_0; VAR_3++) {",
"uint64_t entry = be64_to_cpu(VAR_1[VAR_3]);",
"QCow2ClusterType type = qcow2_get_cluster_type(entry);",
"if (type != VAR_2 || entry & L2E_OFFSET_MASK) {",
"break;",
"}",
"}",
"return VAR_3;",
"}"
] | [
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
],
[
35
],
[
37
]
] |
19,393 | static void rv34_idct_dc_add_c(uint8_t *dst, ptrdiff_t stride, int dc)
{
const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i, j;
cm += (13*13*dc + 0x200) >> 10;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
dst[j] = cm[ dst[j] ];
dst += stride;
}
}
| true | FFmpeg | c23acbaed40101c677dfcfbbfe0d2c230a8e8f44 | static void rv34_idct_dc_add_c(uint8_t *dst, ptrdiff_t stride, int dc)
{
const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i, j;
cm += (13*13*dc + 0x200) >> 10;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
dst[j] = cm[ dst[j] ];
dst += stride;
}
}
| {
"code": [
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" cm += (13*13*dc + 0x200) >> 10;",
" dst[j] = cm[ dst[j] ];",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;"
],
"line_no": [
5,
11,
21,
5,
5,
5,
5,
5
]
} | static void FUNC_0(uint8_t *VAR_0, ptrdiff_t VAR_1, int VAR_2)
{
const uint8_t *VAR_3 = ff_cropTbl + MAX_NEG_CROP;
int VAR_4, VAR_5;
VAR_3 += (13*13*VAR_2 + 0x200) >> 10;
for (VAR_4 = 0; VAR_4 < 4; VAR_4++)
{
for (VAR_5 = 0; VAR_5 < 4; VAR_5++)
VAR_0[VAR_5] = VAR_3[ VAR_0[VAR_5] ];
VAR_0 += VAR_1;
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, ptrdiff_t VAR_1, int VAR_2)\n{",
"const uint8_t *VAR_3 = ff_cropTbl + MAX_NEG_CROP;",
"int VAR_4, VAR_5;",
"VAR_3 += (13*13*VAR_2 + 0x200) >> 10;",
"for (VAR_4 = 0; VAR_4 < 4; VAR_4++)",
"{",
"for (VAR_5 = 0; VAR_5 < 4; VAR_5++)",
"VAR_0[VAR_5] = VAR_3[ VAR_0[VAR_5] ];",
"VAR_0 += VAR_1;",
"}",
"}"
] | [
0,
1,
0,
1,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
]
] |
19,394 | qemu_irq *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
const char *kernel_filename, const char *cpu_model)
{
ARMCPU *cpu;
CPUARMState *env;
DeviceState *nvic;
qemu_irq *pic = g_new(qemu_irq, num_irq);
int image_size;
uint64_t entry;
uint64_t lowaddr;
int i;
int big_endian;
MemoryRegion *hack = g_new(MemoryRegion, 1);
if (cpu_model == NULL) {
cpu_model = "cortex-m3";
}
cpu = cpu_arm_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
armv7m_bitband_init();
nvic = qdev_create(NULL, "armv7m_nvic");
qdev_prop_set_uint32(nvic, "num-irq", num_irq);
env->nvic = nvic;
qdev_init_nofail(nvic);
sysbus_connect_irq(SYS_BUS_DEVICE(nvic), 0,
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
for (i = 0; i < num_irq; i++) {
pic[i] = qdev_get_gpio_in(nvic, i);
}
#ifdef TARGET_WORDS_BIGENDIAN
big_endian = 1;
#else
big_endian = 0;
#endif
if (!kernel_filename && !qtest_enabled()) {
fprintf(stderr, "Guest image must be specified (using -kernel)\n");
exit(1);
}
if (kernel_filename) {
image_size = load_elf(kernel_filename, NULL, NULL, &entry, &lowaddr,
NULL, big_endian, ELF_MACHINE, 1);
if (image_size < 0) {
image_size = load_image_targphys(kernel_filename, 0, mem_size);
lowaddr = 0;
}
if (image_size < 0) {
error_report("Could not load kernel '%s'", kernel_filename);
exit(1);
}
}
/* Hack to map an additional page of ram at the top of the address
space. This stops qemu complaining about executing code outside RAM
when returning from an exception. */
memory_region_init_ram(hack, NULL, "armv7m.hack", 0x1000, &error_abort);
vmstate_register_ram_global(hack);
memory_region_add_subregion(system_memory, 0xfffff000, hack);
qemu_register_reset(armv7m_reset, cpu);
return pic;
}
| true | qemu | f8ed85ac992c48814d916d5df4d44f9a971c5de4 | qemu_irq *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
const char *kernel_filename, const char *cpu_model)
{
ARMCPU *cpu;
CPUARMState *env;
DeviceState *nvic;
qemu_irq *pic = g_new(qemu_irq, num_irq);
int image_size;
uint64_t entry;
uint64_t lowaddr;
int i;
int big_endian;
MemoryRegion *hack = g_new(MemoryRegion, 1);
if (cpu_model == NULL) {
cpu_model = "cortex-m3";
}
cpu = cpu_arm_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
armv7m_bitband_init();
nvic = qdev_create(NULL, "armv7m_nvic");
qdev_prop_set_uint32(nvic, "num-irq", num_irq);
env->nvic = nvic;
qdev_init_nofail(nvic);
sysbus_connect_irq(SYS_BUS_DEVICE(nvic), 0,
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
for (i = 0; i < num_irq; i++) {
pic[i] = qdev_get_gpio_in(nvic, i);
}
#ifdef TARGET_WORDS_BIGENDIAN
big_endian = 1;
#else
big_endian = 0;
#endif
if (!kernel_filename && !qtest_enabled()) {
fprintf(stderr, "Guest image must be specified (using -kernel)\n");
exit(1);
}
if (kernel_filename) {
image_size = load_elf(kernel_filename, NULL, NULL, &entry, &lowaddr,
NULL, big_endian, ELF_MACHINE, 1);
if (image_size < 0) {
image_size = load_image_targphys(kernel_filename, 0, mem_size);
lowaddr = 0;
}
if (image_size < 0) {
error_report("Could not load kernel '%s'", kernel_filename);
exit(1);
}
}
memory_region_init_ram(hack, NULL, "armv7m.hack", 0x1000, &error_abort);
vmstate_register_ram_global(hack);
memory_region_add_subregion(system_memory, 0xfffff000, hack);
qemu_register_reset(armv7m_reset, cpu);
return pic;
}
| {
"code": [
" memory_region_init_ram(hack, NULL, \"armv7m.hack\", 0x1000, &error_abort);"
],
"line_no": [
127
]
} | qemu_irq *FUNC_0(MemoryRegion *system_memory, int mem_size, int num_irq,
const char *kernel_filename, const char *cpu_model)
{
ARMCPU *cpu;
CPUARMState *env;
DeviceState *nvic;
qemu_irq *pic = g_new(qemu_irq, num_irq);
int VAR_0;
uint64_t entry;
uint64_t lowaddr;
int VAR_1;
int VAR_2;
MemoryRegion *hack = g_new(MemoryRegion, 1);
if (cpu_model == NULL) {
cpu_model = "cortex-m3";
}
cpu = cpu_arm_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
armv7m_bitband_init();
nvic = qdev_create(NULL, "armv7m_nvic");
qdev_prop_set_uint32(nvic, "num-irq", num_irq);
env->nvic = nvic;
qdev_init_nofail(nvic);
sysbus_connect_irq(SYS_BUS_DEVICE(nvic), 0,
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
for (VAR_1 = 0; VAR_1 < num_irq; VAR_1++) {
pic[VAR_1] = qdev_get_gpio_in(nvic, VAR_1);
}
#ifdef TARGET_WORDS_BIGENDIAN
VAR_2 = 1;
#else
VAR_2 = 0;
#endif
if (!kernel_filename && !qtest_enabled()) {
fprintf(stderr, "Guest image must be specified (using -kernel)\n");
exit(1);
}
if (kernel_filename) {
VAR_0 = load_elf(kernel_filename, NULL, NULL, &entry, &lowaddr,
NULL, VAR_2, ELF_MACHINE, 1);
if (VAR_0 < 0) {
VAR_0 = load_image_targphys(kernel_filename, 0, mem_size);
lowaddr = 0;
}
if (VAR_0 < 0) {
error_report("Could not load kernel '%s'", kernel_filename);
exit(1);
}
}
memory_region_init_ram(hack, NULL, "armv7m.hack", 0x1000, &error_abort);
vmstate_register_ram_global(hack);
memory_region_add_subregion(system_memory, 0xfffff000, hack);
qemu_register_reset(armv7m_reset, cpu);
return pic;
}
| [
"qemu_irq *FUNC_0(MemoryRegion *system_memory, int mem_size, int num_irq,\nconst char *kernel_filename, const char *cpu_model)\n{",
"ARMCPU *cpu;",
"CPUARMState *env;",
"DeviceState *nvic;",
"qemu_irq *pic = g_new(qemu_irq, num_irq);",
"int VAR_0;",
"uint64_t entry;",
"uint64_t lowaddr;",
"int VAR_1;",
"int VAR_2;",
"MemoryRegion *hack = g_new(MemoryRegion, 1);",
"if (cpu_model == NULL) {",
"cpu_model = \"cortex-m3\";",
"}",
"cpu = cpu_arm_init(cpu_model);",
"if (cpu == NULL) {",
"fprintf(stderr, \"Unable to find CPU definition\\n\");",
"exit(1);",
"}",
"env = &cpu->env;",
"armv7m_bitband_init();",
"nvic = qdev_create(NULL, \"armv7m_nvic\");",
"qdev_prop_set_uint32(nvic, \"num-irq\", num_irq);",
"env->nvic = nvic;",
"qdev_init_nofail(nvic);",
"sysbus_connect_irq(SYS_BUS_DEVICE(nvic), 0,\nqdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));",
"for (VAR_1 = 0; VAR_1 < num_irq; VAR_1++) {",
"pic[VAR_1] = qdev_get_gpio_in(nvic, VAR_1);",
"}",
"#ifdef TARGET_WORDS_BIGENDIAN\nVAR_2 = 1;",
"#else\nVAR_2 = 0;",
"#endif\nif (!kernel_filename && !qtest_enabled()) {",
"fprintf(stderr, \"Guest image must be specified (using -kernel)\\n\");",
"exit(1);",
"}",
"if (kernel_filename) {",
"VAR_0 = load_elf(kernel_filename, NULL, NULL, &entry, &lowaddr,\nNULL, VAR_2, ELF_MACHINE, 1);",
"if (VAR_0 < 0) {",
"VAR_0 = load_image_targphys(kernel_filename, 0, mem_size);",
"lowaddr = 0;",
"}",
"if (VAR_0 < 0) {",
"error_report(\"Could not load kernel '%s'\", kernel_filename);",
"exit(1);",
"}",
"}",
"memory_region_init_ram(hack, NULL, \"armv7m.hack\", 0x1000, &error_abort);",
"vmstate_register_ram_global(hack);",
"memory_region_add_subregion(system_memory, 0xfffff000, hack);",
"qemu_register_reset(armv7m_reset, cpu);",
"return pic;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
73,
75
],
[
77,
79
],
[
81,
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
]
] |
19,395 | int qemu_show_nic_models(const char *arg, const char *const *models)
{
int i;
if (!arg || strcmp(arg, "?"))
return 0;
fprintf(stderr, "qemu: Supported NIC models: ");
for (i = 0 ; models[i]; i++)
fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
return 1;
}
| true | qemu | c8057f951d64de93bfd01569c0a725baa9f94372 | int qemu_show_nic_models(const char *arg, const char *const *models)
{
int i;
if (!arg || strcmp(arg, "?"))
return 0;
fprintf(stderr, "qemu: Supported NIC models: ");
for (i = 0 ; models[i]; i++)
fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
return 1;
}
| {
"code": [
" if (!arg || strcmp(arg, \"?\"))"
],
"line_no": [
9
]
} | int FUNC_0(const char *VAR_0, const char *const *VAR_1)
{
int VAR_2;
if (!VAR_0 || strcmp(VAR_0, "?"))
return 0;
fprintf(stderr, "qemu: Supported NIC VAR_1: ");
for (VAR_2 = 0 ; VAR_1[VAR_2]; VAR_2++)
fprintf(stderr, "%s%c", VAR_1[VAR_2], VAR_1[VAR_2+1] ? ',' : '\n');
return 1;
}
| [
"int FUNC_0(const char *VAR_0, const char *const *VAR_1)\n{",
"int VAR_2;",
"if (!VAR_0 || strcmp(VAR_0, \"?\"))\nreturn 0;",
"fprintf(stderr, \"qemu: Supported NIC VAR_1: \");",
"for (VAR_2 = 0 ; VAR_1[VAR_2]; VAR_2++)",
"fprintf(stderr, \"%s%c\", VAR_1[VAR_2], VAR_1[VAR_2+1] ? ',' : '\\n');",
"return 1;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
19,396 | void SwScale_Init(){
// generating tables:
int i;
for(i=0; i<768; i++){
int c= MIN(MAX(i-256, 0), 255);
clip_table[i]=c;
yuvtab_2568[c]= clip_yuvtab_2568[i]=(0x2568*(c-16))+(256<<13);
yuvtab_3343[c]= clip_yuvtab_3343[i]=0x3343*(c-128);
yuvtab_0c92[c]= clip_yuvtab_0c92[i]=-0x0c92*(c-128);
yuvtab_1a1e[c]= clip_yuvtab_1a1e[i]=-0x1a1e*(c-128);
yuvtab_40cf[c]= clip_yuvtab_40cf[i]=0x40cf*(c-128);
}
for(i=0; i<768; i++)
{
int v= clip_table[i];
clip_table16b[i]= v>>3;
clip_table16g[i]= (v<<3)&0x07E0;
clip_table16r[i]= (v<<8)&0xF800;
clip_table15b[i]= v>>3;
clip_table15g[i]= (v<<2)&0x03E0;
clip_table15r[i]= (v<<7)&0x7C00;
}
}
| true | FFmpeg | 28bf81c90d36a55cf76e2be913c5215ebebf61f2 | void SwScale_Init(){
int i;
for(i=0; i<768; i++){
int c= MIN(MAX(i-256, 0), 255);
clip_table[i]=c;
yuvtab_2568[c]= clip_yuvtab_2568[i]=(0x2568*(c-16))+(256<<13);
yuvtab_3343[c]= clip_yuvtab_3343[i]=0x3343*(c-128);
yuvtab_0c92[c]= clip_yuvtab_0c92[i]=-0x0c92*(c-128);
yuvtab_1a1e[c]= clip_yuvtab_1a1e[i]=-0x1a1e*(c-128);
yuvtab_40cf[c]= clip_yuvtab_40cf[i]=0x40cf*(c-128);
}
for(i=0; i<768; i++)
{
int v= clip_table[i];
clip_table16b[i]= v>>3;
clip_table16g[i]= (v<<3)&0x07E0;
clip_table16r[i]= (v<<8)&0xF800;
clip_table15b[i]= v>>3;
clip_table15g[i]= (v<<2)&0x03E0;
clip_table15r[i]= (v<<7)&0x7C00;
}
}
| {
"code": [
" \tint v= clip_table[i];"
],
"line_no": [
31
]
} | void FUNC_0(){
int VAR_0;
for(VAR_0=0; VAR_0<768; VAR_0++){
int VAR_1= MIN(MAX(VAR_0-256, 0), 255);
clip_table[VAR_0]=VAR_1;
yuvtab_2568[VAR_1]= clip_yuvtab_2568[VAR_0]=(0x2568*(VAR_1-16))+(256<<13);
yuvtab_3343[VAR_1]= clip_yuvtab_3343[VAR_0]=0x3343*(VAR_1-128);
yuvtab_0c92[VAR_1]= clip_yuvtab_0c92[VAR_0]=-0x0c92*(VAR_1-128);
yuvtab_1a1e[VAR_1]= clip_yuvtab_1a1e[VAR_0]=-0x1a1e*(VAR_1-128);
yuvtab_40cf[VAR_1]= clip_yuvtab_40cf[VAR_0]=0x40cf*(VAR_1-128);
}
for(VAR_0=0; VAR_0<768; VAR_0++)
{
int VAR_2= clip_table[VAR_0];
clip_table16b[VAR_0]= VAR_2>>3;
clip_table16g[VAR_0]= (VAR_2<<3)&0x07E0;
clip_table16r[VAR_0]= (VAR_2<<8)&0xF800;
clip_table15b[VAR_0]= VAR_2>>3;
clip_table15g[VAR_0]= (VAR_2<<2)&0x03E0;
clip_table15r[VAR_0]= (VAR_2<<7)&0x7C00;
}
}
| [
"void FUNC_0(){",
"int VAR_0;",
"for(VAR_0=0; VAR_0<768; VAR_0++){",
"int VAR_1= MIN(MAX(VAR_0-256, 0), 255);",
"clip_table[VAR_0]=VAR_1;",
"yuvtab_2568[VAR_1]= clip_yuvtab_2568[VAR_0]=(0x2568*(VAR_1-16))+(256<<13);",
"yuvtab_3343[VAR_1]= clip_yuvtab_3343[VAR_0]=0x3343*(VAR_1-128);",
"yuvtab_0c92[VAR_1]= clip_yuvtab_0c92[VAR_0]=-0x0c92*(VAR_1-128);",
"yuvtab_1a1e[VAR_1]= clip_yuvtab_1a1e[VAR_0]=-0x1a1e*(VAR_1-128);",
"yuvtab_40cf[VAR_1]= clip_yuvtab_40cf[VAR_0]=0x40cf*(VAR_1-128);",
"}",
"for(VAR_0=0; VAR_0<768; VAR_0++)",
"{",
"int VAR_2= clip_table[VAR_0];",
"clip_table16b[VAR_0]= VAR_2>>3;",
"clip_table16g[VAR_0]= (VAR_2<<3)&0x07E0;",
"clip_table16r[VAR_0]= (VAR_2<<8)&0xF800;",
"clip_table15b[VAR_0]= VAR_2>>3;",
"clip_table15g[VAR_0]= (VAR_2<<2)&0x03E0;",
"clip_table15r[VAR_0]= (VAR_2<<7)&0x7C00;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
]
] |
19,397 | void openrisc_cpu_do_interrupt(CPUState *cs)
{
#ifndef CONFIG_USER_ONLY
OpenRISCCPU *cpu = OPENRISC_CPU(cs);
CPUOpenRISCState *env = &cpu->env;
env->epcr = env->pc;
if (env->flags & D_FLAG) {
env->flags &= ~D_FLAG;
env->sr |= SR_DSX;
env->epcr -= 4;
if (cs->exception_index == EXCP_SYSCALL) {
env->epcr += 4;
/* For machine-state changed between user-mode and supervisor mode,
we need flush TLB when we enter&exit EXCP. */
tlb_flush(cs);
env->esr = env->sr;
env->sr &= ~SR_DME;
env->sr &= ~SR_IME;
env->sr |= SR_SM;
env->sr &= ~SR_IEE;
env->sr &= ~SR_TEE;
env->tlb->cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu;
env->tlb->cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu;
if (cs->exception_index > 0 && cs->exception_index < EXCP_NR) {
env->pc = (cs->exception_index << 8);
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
#endif
cs->exception_index = -1;
| true | qemu | c56e3b86701501364a4756201b6a9db9454463ab | void openrisc_cpu_do_interrupt(CPUState *cs)
{
#ifndef CONFIG_USER_ONLY
OpenRISCCPU *cpu = OPENRISC_CPU(cs);
CPUOpenRISCState *env = &cpu->env;
env->epcr = env->pc;
if (env->flags & D_FLAG) {
env->flags &= ~D_FLAG;
env->sr |= SR_DSX;
env->epcr -= 4;
if (cs->exception_index == EXCP_SYSCALL) {
env->epcr += 4;
tlb_flush(cs);
env->esr = env->sr;
env->sr &= ~SR_DME;
env->sr &= ~SR_IME;
env->sr |= SR_SM;
env->sr &= ~SR_IEE;
env->sr &= ~SR_TEE;
env->tlb->cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu;
env->tlb->cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu;
if (cs->exception_index > 0 && cs->exception_index < EXCP_NR) {
env->pc = (cs->exception_index << 8);
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
#endif
cs->exception_index = -1;
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUState *VAR_0)
{
#ifndef CONFIG_USER_ONLY
OpenRISCCPU *cpu = OPENRISC_CPU(VAR_0);
CPUOpenRISCState *env = &cpu->env;
env->epcr = env->pc;
if (env->flags & D_FLAG) {
env->flags &= ~D_FLAG;
env->sr |= SR_DSX;
env->epcr -= 4;
if (VAR_0->exception_index == EXCP_SYSCALL) {
env->epcr += 4;
tlb_flush(VAR_0);
env->esr = env->sr;
env->sr &= ~SR_DME;
env->sr &= ~SR_IME;
env->sr |= SR_SM;
env->sr &= ~SR_IEE;
env->sr &= ~SR_TEE;
env->tlb->cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu;
env->tlb->cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu;
if (VAR_0->exception_index > 0 && VAR_0->exception_index < EXCP_NR) {
env->pc = (VAR_0->exception_index << 8);
cpu_abort(VAR_0, "Unhandled exception 0x%x\n", VAR_0->exception_index);
#endif
VAR_0->exception_index = -1;
| [
"void FUNC_0(CPUState *VAR_0)\n{",
"#ifndef CONFIG_USER_ONLY\nOpenRISCCPU *cpu = OPENRISC_CPU(VAR_0);",
"CPUOpenRISCState *env = &cpu->env;",
"env->epcr = env->pc;",
"if (env->flags & D_FLAG) {",
"env->flags &= ~D_FLAG;",
"env->sr |= SR_DSX;",
"env->epcr -= 4;",
"if (VAR_0->exception_index == EXCP_SYSCALL) {",
"env->epcr += 4;",
"tlb_flush(VAR_0);",
"env->esr = env->sr;",
"env->sr &= ~SR_DME;",
"env->sr &= ~SR_IME;",
"env->sr |= SR_SM;",
"env->sr &= ~SR_IEE;",
"env->sr &= ~SR_TEE;",
"env->tlb->cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu;",
"env->tlb->cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu;",
"if (VAR_0->exception_index > 0 && VAR_0->exception_index < EXCP_NR) {",
"env->pc = (VAR_0->exception_index << 8);",
"cpu_abort(VAR_0, \"Unhandled exception 0x%x\\n\", VAR_0->exception_index);",
"#endif\nVAR_0->exception_index = -1;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
26
],
[
28
],
[
42
],
[
46
],
[
48
],
[
50
],
[
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
64
],
[
66
],
[
69
],
[
72,
76
]
] |
19,398 | static char *qemu_rbd_array_opts(QDict *options, const char *prefix, int type,
Error **errp)
{
int num_entries;
QemuOpts *opts = NULL;
QDict *sub_options;
const char *host;
const char *port;
char *str;
char *rados_str = NULL;
Error *local_err = NULL;
int i;
assert(type == RBD_MON_HOST);
num_entries = qdict_array_entries(options, prefix);
if (num_entries < 0) {
error_setg(errp, "Parse error on RBD QDict array");
return NULL;
}
for (i = 0; i < num_entries; i++) {
char *strbuf = NULL;
const char *value;
char *rados_str_tmp;
str = g_strdup_printf("%s%d.", prefix, i);
qdict_extract_subqdict(options, &sub_options, str);
g_free(str);
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, sub_options, &local_err);
QDECREF(sub_options);
if (local_err) {
error_propagate(errp, local_err);
g_free(rados_str);
rados_str = NULL;
goto exit;
}
if (type == RBD_MON_HOST) {
host = qemu_opt_get(opts, "host");
port = qemu_opt_get(opts, "port");
value = host;
if (port) {
/* check for ipv6 */
if (strchr(host, ':')) {
strbuf = g_strdup_printf("[%s]:%s", host, port);
} else {
strbuf = g_strdup_printf("%s:%s", host, port);
}
value = strbuf;
} else if (strchr(host, ':')) {
strbuf = g_strdup_printf("[%s]", host);
value = strbuf;
}
} else {
abort();
}
/* each iteration in the for loop will build upon the string, and if
* rados_str is NULL then it is our first pass */
if (rados_str) {
/* separate options with ';', as that is what rados_conf_set()
* requires */
rados_str_tmp = rados_str;
rados_str = g_strdup_printf("%s;%s", rados_str_tmp, value);
g_free(rados_str_tmp);
} else {
rados_str = g_strdup(value);
}
g_free(strbuf);
qemu_opts_del(opts);
opts = NULL;
}
exit:
qemu_opts_del(opts);
return rados_str;
}
| true | qemu | 2836284db603775af557e969d5a800efb0190324 | static char *qemu_rbd_array_opts(QDict *options, const char *prefix, int type,
Error **errp)
{
int num_entries;
QemuOpts *opts = NULL;
QDict *sub_options;
const char *host;
const char *port;
char *str;
char *rados_str = NULL;
Error *local_err = NULL;
int i;
assert(type == RBD_MON_HOST);
num_entries = qdict_array_entries(options, prefix);
if (num_entries < 0) {
error_setg(errp, "Parse error on RBD QDict array");
return NULL;
}
for (i = 0; i < num_entries; i++) {
char *strbuf = NULL;
const char *value;
char *rados_str_tmp;
str = g_strdup_printf("%s%d.", prefix, i);
qdict_extract_subqdict(options, &sub_options, str);
g_free(str);
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, sub_options, &local_err);
QDECREF(sub_options);
if (local_err) {
error_propagate(errp, local_err);
g_free(rados_str);
rados_str = NULL;
goto exit;
}
if (type == RBD_MON_HOST) {
host = qemu_opt_get(opts, "host");
port = qemu_opt_get(opts, "port");
value = host;
if (port) {
if (strchr(host, ':')) {
strbuf = g_strdup_printf("[%s]:%s", host, port);
} else {
strbuf = g_strdup_printf("%s:%s", host, port);
}
value = strbuf;
} else if (strchr(host, ':')) {
strbuf = g_strdup_printf("[%s]", host);
value = strbuf;
}
} else {
abort();
}
if (rados_str) {
rados_str_tmp = rados_str;
rados_str = g_strdup_printf("%s;%s", rados_str_tmp, value);
g_free(rados_str_tmp);
} else {
rados_str = g_strdup(value);
}
g_free(strbuf);
qemu_opts_del(opts);
opts = NULL;
}
exit:
qemu_opts_del(opts);
return rados_str;
}
| {
"code": [
"static char *qemu_rbd_array_opts(QDict *options, const char *prefix, int type,",
" Error **errp)",
" int num_entries;",
" QemuOpts *opts = NULL;",
" QDict *sub_options;",
" const char *host;",
" const char *port;",
" char *str;",
" char *rados_str = NULL;",
" Error *local_err = NULL;",
" assert(type == RBD_MON_HOST);",
" num_entries = qdict_array_entries(options, prefix);",
" if (num_entries < 0) {",
" error_setg(errp, \"Parse error on RBD QDict array\");",
" return NULL;",
" for (i = 0; i < num_entries; i++) {",
" char *strbuf = NULL;",
" const char *value;",
" char *rados_str_tmp;",
" str = g_strdup_printf(\"%s%d.\", prefix, i);",
" qdict_extract_subqdict(options, &sub_options, str);",
" g_free(str);",
" opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);",
" qemu_opts_absorb_qdict(opts, sub_options, &local_err);",
" QDECREF(sub_options);",
" if (local_err) {",
" error_propagate(errp, local_err);",
" g_free(rados_str);",
" rados_str = NULL;",
" goto exit;",
" if (type == RBD_MON_HOST) {",
" host = qemu_opt_get(opts, \"host\");",
" port = qemu_opt_get(opts, \"port\");",
" value = host;",
" if (port) {",
" if (strchr(host, ':')) {",
" strbuf = g_strdup_printf(\"[%s]:%s\", host, port);",
" } else {",
" strbuf = g_strdup_printf(\"%s:%s\", host, port);",
" value = strbuf;",
" } else if (strchr(host, ':')) {",
" strbuf = g_strdup_printf(\"[%s]\", host);",
" value = strbuf;",
" } else {",
" abort();",
" if (rados_str) {",
" rados_str_tmp = rados_str;",
" rados_str = g_strdup_printf(\"%s;%s\", rados_str_tmp, value);",
" g_free(rados_str_tmp);",
" rados_str = g_strdup(value);",
" g_free(strbuf);",
" qemu_opts_del(opts);",
" opts = NULL;",
"exit:",
" qemu_opts_del(opts);",
" qemu_opts_del(opts);"
],
"line_no": [
1,
3,
7,
9,
11,
13,
15,
17,
19,
21,
27,
31,
35,
37,
39,
45,
47,
49,
51,
55,
57,
59,
63,
65,
67,
69,
71,
73,
75,
77,
83,
85,
87,
91,
93,
97,
99,
101,
103,
107,
109,
111,
107,
117,
119,
129,
135,
137,
139,
143,
149,
151,
153,
159,
161,
151
]
} | static char *FUNC_0(QDict *VAR_0, const char *VAR_1, int VAR_2,
Error **VAR_3)
{
int VAR_4;
QemuOpts *opts = NULL;
QDict *sub_options;
const char *VAR_5;
const char *VAR_6;
char *VAR_7;
char *VAR_8 = NULL;
Error *local_err = NULL;
int VAR_9;
assert(VAR_2 == RBD_MON_HOST);
VAR_4 = qdict_array_entries(VAR_0, VAR_1);
if (VAR_4 < 0) {
error_setg(VAR_3, "Parse error on RBD QDict array");
return NULL;
}
for (VAR_9 = 0; VAR_9 < VAR_4; VAR_9++) {
char *VAR_10 = NULL;
const char *VAR_11;
char *VAR_12;
VAR_7 = g_strdup_printf("%s%d.", VAR_1, VAR_9);
qdict_extract_subqdict(VAR_0, &sub_options, VAR_7);
g_free(VAR_7);
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, sub_options, &local_err);
QDECREF(sub_options);
if (local_err) {
error_propagate(VAR_3, local_err);
g_free(VAR_8);
VAR_8 = NULL;
goto exit;
}
if (VAR_2 == RBD_MON_HOST) {
VAR_5 = qemu_opt_get(opts, "VAR_5");
VAR_6 = qemu_opt_get(opts, "VAR_6");
VAR_11 = VAR_5;
if (VAR_6) {
if (strchr(VAR_5, ':')) {
VAR_10 = g_strdup_printf("[%s]:%s", VAR_5, VAR_6);
} else {
VAR_10 = g_strdup_printf("%s:%s", VAR_5, VAR_6);
}
VAR_11 = VAR_10;
} else if (strchr(VAR_5, ':')) {
VAR_10 = g_strdup_printf("[%s]", VAR_5);
VAR_11 = VAR_10;
}
} else {
abort();
}
if (VAR_8) {
VAR_12 = VAR_8;
VAR_8 = g_strdup_printf("%s;%s", VAR_12, VAR_11);
g_free(VAR_12);
} else {
VAR_8 = g_strdup(VAR_11);
}
g_free(VAR_10);
qemu_opts_del(opts);
opts = NULL;
}
exit:
qemu_opts_del(opts);
return VAR_8;
}
| [
"static char *FUNC_0(QDict *VAR_0, const char *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"int VAR_4;",
"QemuOpts *opts = NULL;",
"QDict *sub_options;",
"const char *VAR_5;",
"const char *VAR_6;",
"char *VAR_7;",
"char *VAR_8 = NULL;",
"Error *local_err = NULL;",
"int VAR_9;",
"assert(VAR_2 == RBD_MON_HOST);",
"VAR_4 = qdict_array_entries(VAR_0, VAR_1);",
"if (VAR_4 < 0) {",
"error_setg(VAR_3, \"Parse error on RBD QDict array\");",
"return NULL;",
"}",
"for (VAR_9 = 0; VAR_9 < VAR_4; VAR_9++) {",
"char *VAR_10 = NULL;",
"const char *VAR_11;",
"char *VAR_12;",
"VAR_7 = g_strdup_printf(\"%s%d.\", VAR_1, VAR_9);",
"qdict_extract_subqdict(VAR_0, &sub_options, VAR_7);",
"g_free(VAR_7);",
"opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);",
"qemu_opts_absorb_qdict(opts, sub_options, &local_err);",
"QDECREF(sub_options);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"g_free(VAR_8);",
"VAR_8 = NULL;",
"goto exit;",
"}",
"if (VAR_2 == RBD_MON_HOST) {",
"VAR_5 = qemu_opt_get(opts, \"VAR_5\");",
"VAR_6 = qemu_opt_get(opts, \"VAR_6\");",
"VAR_11 = VAR_5;",
"if (VAR_6) {",
"if (strchr(VAR_5, ':')) {",
"VAR_10 = g_strdup_printf(\"[%s]:%s\", VAR_5, VAR_6);",
"} else {",
"VAR_10 = g_strdup_printf(\"%s:%s\", VAR_5, VAR_6);",
"}",
"VAR_11 = VAR_10;",
"} else if (strchr(VAR_5, ':')) {",
"VAR_10 = g_strdup_printf(\"[%s]\", VAR_5);",
"VAR_11 = VAR_10;",
"}",
"} else {",
"abort();",
"}",
"if (VAR_8) {",
"VAR_12 = VAR_8;",
"VAR_8 = g_strdup_printf(\"%s;%s\", VAR_12, VAR_11);",
"g_free(VAR_12);",
"} else {",
"VAR_8 = g_strdup(VAR_11);",
"}",
"g_free(VAR_10);",
"qemu_opts_del(opts);",
"opts = NULL;",
"}",
"exit:\nqemu_opts_del(opts);",
"return VAR_8;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
0,
0,
0,
1,
0,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
129
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159,
161
],
[
163
],
[
165
]
] |
19,399 | static float *put_vector(vorbis_enc_codebook *book, PutBitContext *pb,
float *num)
{
int i, entry = -1;
float distance = FLT_MAX;
assert(book->dimentions);
for (i = 0; i < book->nentries; i++) {
float * vec = book->dimentions + i * book->ndimentions, d = book->pow2[i];
int j;
if (!book->lens[i])
continue;
for (j = 0; j < book->ndimentions; j++)
d -= vec[j] * num[j];
if (distance > d) {
entry = i;
distance = d;
}
}
put_codeword(pb, book, entry);
return &book->dimentions[entry * book->ndimentions];
}
| true | FFmpeg | 1ba08c94f5bb4d1c3c2d3651b5e01edb4ce172e2 | static float *put_vector(vorbis_enc_codebook *book, PutBitContext *pb,
float *num)
{
int i, entry = -1;
float distance = FLT_MAX;
assert(book->dimentions);
for (i = 0; i < book->nentries; i++) {
float * vec = book->dimentions + i * book->ndimentions, d = book->pow2[i];
int j;
if (!book->lens[i])
continue;
for (j = 0; j < book->ndimentions; j++)
d -= vec[j] * num[j];
if (distance > d) {
entry = i;
distance = d;
}
}
put_codeword(pb, book, entry);
return &book->dimentions[entry * book->ndimentions];
}
| {
"code": [
" put_codeword(pb, book, entry);"
],
"line_no": [
37
]
} | static float *FUNC_0(vorbis_enc_codebook *VAR_0, PutBitContext *VAR_1,
float *VAR_2)
{
int VAR_3, VAR_4 = -1;
float VAR_5 = FLT_MAX;
assert(VAR_0->dimentions);
for (VAR_3 = 0; VAR_3 < VAR_0->nentries; VAR_3++) {
float * vec = VAR_0->dimentions + VAR_3 * VAR_0->ndimentions, d = VAR_0->pow2[VAR_3];
int j;
if (!VAR_0->lens[VAR_3])
continue;
for (j = 0; j < VAR_0->ndimentions; j++)
d -= vec[j] * VAR_2[j];
if (VAR_5 > d) {
VAR_4 = VAR_3;
VAR_5 = d;
}
}
put_codeword(VAR_1, VAR_0, VAR_4);
return &VAR_0->dimentions[VAR_4 * VAR_0->ndimentions];
}
| [
"static float *FUNC_0(vorbis_enc_codebook *VAR_0, PutBitContext *VAR_1,\nfloat *VAR_2)\n{",
"int VAR_3, VAR_4 = -1;",
"float VAR_5 = FLT_MAX;",
"assert(VAR_0->dimentions);",
"for (VAR_3 = 0; VAR_3 < VAR_0->nentries; VAR_3++) {",
"float * vec = VAR_0->dimentions + VAR_3 * VAR_0->ndimentions, d = VAR_0->pow2[VAR_3];",
"int j;",
"if (!VAR_0->lens[VAR_3])\ncontinue;",
"for (j = 0; j < VAR_0->ndimentions; j++)",
"d -= vec[j] * VAR_2[j];",
"if (VAR_5 > d) {",
"VAR_4 = VAR_3;",
"VAR_5 = d;",
"}",
"}",
"put_codeword(VAR_1, VAR_0, VAR_4);",
"return &VAR_0->dimentions[VAR_4 * VAR_0->ndimentions];",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
19,400 | static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
{
MOVMuxContext *mov = s->priv_data;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
AVCodecParameters *par = trk->par;
int64_t frag_duration = 0;
int size = pkt->size;
if (mov->flags & FF_MOV_FLAG_FRAG_DISCONT) {
int i;
for (i = 0; i < s->nb_streams; i++)
mov->tracks[i].frag_discont = 1;
mov->flags &= ~FF_MOV_FLAG_FRAG_DISCONT;
}
if (!pkt->size) {
if (trk->start_dts == AV_NOPTS_VALUE && trk->frag_discont) {
trk->start_dts = pkt->dts;
if (pkt->pts != AV_NOPTS_VALUE)
trk->start_cts = pkt->pts - pkt->dts;
else
trk->start_cts = 0;
}
if (trk->par->codec_id == AV_CODEC_ID_MP4ALS) {
int side_size = 0;
uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) {
void *newextra = av_mallocz(side_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!newextra)
return AVERROR(ENOMEM);
av_free(par->extradata);
par->extradata = newextra;
memcpy(par->extradata, side, side_size);
par->extradata_size = side_size;
mov->need_rewrite_extradata = 1;
}
}
return 0; /* Discard 0 sized packets */
}
if (trk->entry && pkt->stream_index < s->nb_streams)
frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts,
s->streams[pkt->stream_index]->time_base,
AV_TIME_BASE_Q);
if ((mov->max_fragment_duration &&
frag_duration >= mov->max_fragment_duration) ||
(mov->max_fragment_size && mov->mdat_size + size >= mov->max_fragment_size) ||
(mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME &&
par->codec_type == AVMEDIA_TYPE_VIDEO &&
trk->entry && pkt->flags & AV_PKT_FLAG_KEY)) {
if (frag_duration >= mov->min_fragment_duration) {
// Set the duration of this track to line up with the next
// sample in this track. This avoids relying on AVPacket
// duration, but only helps for this particular track, not
// for the other ones that are flushed at the same time.
trk->track_duration = pkt->dts - trk->start_dts;
if (pkt->pts != AV_NOPTS_VALUE)
trk->end_pts = pkt->pts;
else
trk->end_pts = pkt->dts;
trk->end_reliable = 1;
mov_auto_flush_fragment(s, 0);
}
}
return ff_mov_write_packet(s, pkt);
} | true | FFmpeg | 28343139330f557e00293933a4697c7d0fc19c56 | static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
{
MOVMuxContext *mov = s->priv_data;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
AVCodecParameters *par = trk->par;
int64_t frag_duration = 0;
int size = pkt->size;
if (mov->flags & FF_MOV_FLAG_FRAG_DISCONT) {
int i;
for (i = 0; i < s->nb_streams; i++)
mov->tracks[i].frag_discont = 1;
mov->flags &= ~FF_MOV_FLAG_FRAG_DISCONT;
}
if (!pkt->size) {
if (trk->start_dts == AV_NOPTS_VALUE && trk->frag_discont) {
trk->start_dts = pkt->dts;
if (pkt->pts != AV_NOPTS_VALUE)
trk->start_cts = pkt->pts - pkt->dts;
else
trk->start_cts = 0;
}
if (trk->par->codec_id == AV_CODEC_ID_MP4ALS) {
int side_size = 0;
uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) {
void *newextra = av_mallocz(side_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!newextra)
return AVERROR(ENOMEM);
av_free(par->extradata);
par->extradata = newextra;
memcpy(par->extradata, side, side_size);
par->extradata_size = side_size;
mov->need_rewrite_extradata = 1;
}
}
return 0;
}
if (trk->entry && pkt->stream_index < s->nb_streams)
frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts,
s->streams[pkt->stream_index]->time_base,
AV_TIME_BASE_Q);
if ((mov->max_fragment_duration &&
frag_duration >= mov->max_fragment_duration) ||
(mov->max_fragment_size && mov->mdat_size + size >= mov->max_fragment_size) ||
(mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME &&
par->codec_type == AVMEDIA_TYPE_VIDEO &&
trk->entry && pkt->flags & AV_PKT_FLAG_KEY)) {
if (frag_duration >= mov->min_fragment_duration) {
trk->track_duration = pkt->dts - trk->start_dts;
if (pkt->pts != AV_NOPTS_VALUE)
trk->end_pts = pkt->pts;
else
trk->end_pts = pkt->dts;
trk->end_reliable = 1;
mov_auto_flush_fragment(s, 0);
}
}
return ff_mov_write_packet(s, pkt);
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
MOVMuxContext *mov = VAR_0->priv_data;
MOVTrack *trk = &mov->tracks[VAR_1->stream_index];
AVCodecParameters *par = trk->par;
int64_t frag_duration = 0;
int VAR_2 = VAR_1->VAR_2;
if (mov->flags & FF_MOV_FLAG_FRAG_DISCONT) {
int VAR_3;
for (VAR_3 = 0; VAR_3 < VAR_0->nb_streams; VAR_3++)
mov->tracks[VAR_3].frag_discont = 1;
mov->flags &= ~FF_MOV_FLAG_FRAG_DISCONT;
}
if (!VAR_1->VAR_2) {
if (trk->start_dts == AV_NOPTS_VALUE && trk->frag_discont) {
trk->start_dts = VAR_1->dts;
if (VAR_1->pts != AV_NOPTS_VALUE)
trk->start_cts = VAR_1->pts - VAR_1->dts;
else
trk->start_cts = 0;
}
if (trk->par->codec_id == AV_CODEC_ID_MP4ALS) {
int VAR_4 = 0;
uint8_t *side = av_packet_get_side_data(VAR_1, AV_PKT_DATA_NEW_EXTRADATA, &VAR_4);
if (side && VAR_4 > 0 && (VAR_4 != par->extradata_size || memcmp(side, par->extradata, VAR_4))) {
void *VAR_5 = av_mallocz(VAR_4 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!VAR_5)
return AVERROR(ENOMEM);
av_free(par->extradata);
par->extradata = VAR_5;
memcpy(par->extradata, side, VAR_4);
par->extradata_size = VAR_4;
mov->need_rewrite_extradata = 1;
}
}
return 0;
}
if (trk->entry && VAR_1->stream_index < VAR_0->nb_streams)
frag_duration = av_rescale_q(VAR_1->dts - trk->cluster[0].dts,
VAR_0->streams[VAR_1->stream_index]->time_base,
AV_TIME_BASE_Q);
if ((mov->max_fragment_duration &&
frag_duration >= mov->max_fragment_duration) ||
(mov->max_fragment_size && mov->mdat_size + VAR_2 >= mov->max_fragment_size) ||
(mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME &&
par->codec_type == AVMEDIA_TYPE_VIDEO &&
trk->entry && VAR_1->flags & AV_PKT_FLAG_KEY)) {
if (frag_duration >= mov->min_fragment_duration) {
trk->track_duration = VAR_1->dts - trk->start_dts;
if (VAR_1->pts != AV_NOPTS_VALUE)
trk->end_pts = VAR_1->pts;
else
trk->end_pts = VAR_1->dts;
trk->end_reliable = 1;
mov_auto_flush_fragment(VAR_0, 0);
}
}
return ff_mov_write_packet(VAR_0, VAR_1);
} | [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"MOVMuxContext *mov = VAR_0->priv_data;",
"MOVTrack *trk = &mov->tracks[VAR_1->stream_index];",
"AVCodecParameters *par = trk->par;",
"int64_t frag_duration = 0;",
"int VAR_2 = VAR_1->VAR_2;",
"if (mov->flags & FF_MOV_FLAG_FRAG_DISCONT) {",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < VAR_0->nb_streams; VAR_3++)",
"mov->tracks[VAR_3].frag_discont = 1;",
"mov->flags &= ~FF_MOV_FLAG_FRAG_DISCONT;",
"}",
"if (!VAR_1->VAR_2) {",
"if (trk->start_dts == AV_NOPTS_VALUE && trk->frag_discont) {",
"trk->start_dts = VAR_1->dts;",
"if (VAR_1->pts != AV_NOPTS_VALUE)\ntrk->start_cts = VAR_1->pts - VAR_1->dts;",
"else\ntrk->start_cts = 0;",
"}",
"if (trk->par->codec_id == AV_CODEC_ID_MP4ALS) {",
"int VAR_4 = 0;",
"uint8_t *side = av_packet_get_side_data(VAR_1, AV_PKT_DATA_NEW_EXTRADATA, &VAR_4);",
"if (side && VAR_4 > 0 && (VAR_4 != par->extradata_size || memcmp(side, par->extradata, VAR_4))) {",
"void *VAR_5 = av_mallocz(VAR_4 + AV_INPUT_BUFFER_PADDING_SIZE);",
"if (!VAR_5)\nreturn AVERROR(ENOMEM);",
"av_free(par->extradata);",
"par->extradata = VAR_5;",
"memcpy(par->extradata, side, VAR_4);",
"par->extradata_size = VAR_4;",
"mov->need_rewrite_extradata = 1;",
"}",
"}",
"return 0;",
"}",
"if (trk->entry && VAR_1->stream_index < VAR_0->nb_streams)\nfrag_duration = av_rescale_q(VAR_1->dts - trk->cluster[0].dts,\nVAR_0->streams[VAR_1->stream_index]->time_base,\nAV_TIME_BASE_Q);",
"if ((mov->max_fragment_duration &&\nfrag_duration >= mov->max_fragment_duration) ||\n(mov->max_fragment_size && mov->mdat_size + VAR_2 >= mov->max_fragment_size) ||\n(mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME &&\npar->codec_type == AVMEDIA_TYPE_VIDEO &&\ntrk->entry && VAR_1->flags & AV_PKT_FLAG_KEY)) {",
"if (frag_duration >= mov->min_fragment_duration) {",
"trk->track_duration = VAR_1->dts - trk->start_dts;",
"if (VAR_1->pts != AV_NOPTS_VALUE)\ntrk->end_pts = VAR_1->pts;",
"else\ntrk->end_pts = VAR_1->dts;",
"trk->end_reliable = 1;",
"mov_auto_flush_fragment(VAR_0, 0);",
"}",
"}",
"return ff_mov_write_packet(VAR_0, 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17,
18
],
[
19,
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27,
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38,
39,
40,
41
],
[
42,
43,
44,
45,
46,
47
],
[
48
],
[
53
],
[
54,
55
],
[
56,
57
],
[
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63
]
] |
19,401 | int cpu_exec(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
#if !(defined(CONFIG_USER_ONLY) && \
(defined(TARGET_M68K) || defined(TARGET_PPC) || defined(TARGET_S390X)))
CPUClass *cc = CPU_GET_CLASS(cpu);
#endif
#ifdef TARGET_I386
X86CPU *x86_cpu = X86_CPU(cpu);
#endif
int ret, interrupt_request;
TranslationBlock *tb;
uint8_t *tc_ptr;
uintptr_t next_tb;
if (cpu->halted) {
if (!cpu_has_work(cpu)) {
return EXCP_HALTED;
}
cpu->halted = 0;
}
current_cpu = cpu;
/* As long as current_cpu is null, up to the assignment just above,
* requests by other threads to exit the execution loop are expected to
* be issued using the exit_request global. We must make sure that our
* evaluation of the global value is performed past the current_cpu
* value transition point, which requires a memory barrier as well as
* an instruction scheduling constraint on modern architectures. */
smp_mb();
if (unlikely(exit_request)) {
cpu->exit_request = 1;
}
#if defined(TARGET_I386)
/* put eflags in CPU temporary format */
CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
env->df = 1 - (2 * ((env->eflags >> 10) & 1));
CC_OP = CC_OP_EFLAGS;
env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
#elif defined(TARGET_SPARC)
#elif defined(TARGET_M68K)
env->cc_op = CC_OP_FLAGS;
env->cc_dest = env->sr & 0xf;
env->cc_x = (env->sr >> 4) & 1;
#elif defined(TARGET_ALPHA)
#elif defined(TARGET_ARM)
#elif defined(TARGET_UNICORE32)
#elif defined(TARGET_PPC)
env->reserve_addr = -1;
#elif defined(TARGET_LM32)
#elif defined(TARGET_MICROBLAZE)
#elif defined(TARGET_MIPS)
#elif defined(TARGET_MOXIE)
#elif defined(TARGET_OPENRISC)
#elif defined(TARGET_SH4)
#elif defined(TARGET_CRIS)
#elif defined(TARGET_S390X)
#elif defined(TARGET_XTENSA)
/* XXXXX */
#else
#error unsupported target CPU
#endif
cpu->exception_index = -1;
/* prepare setjmp context for exception handling */
for(;;) {
if (sigsetjmp(cpu->jmp_env, 0) == 0) {
/* if an exception is pending, we execute it here */
if (cpu->exception_index >= 0) {
if (cpu->exception_index >= EXCP_INTERRUPT) {
/* exit request from the cpu execution loop */
ret = cpu->exception_index;
if (ret == EXCP_DEBUG) {
cpu_handle_debug_exception(env);
}
break;
} else {
#if defined(CONFIG_USER_ONLY)
/* if user mode only, we simulate a fake exception
which will be handled outside the cpu execution
loop */
#if defined(TARGET_I386)
cc->do_interrupt(cpu);
#endif
ret = cpu->exception_index;
break;
#else
cc->do_interrupt(cpu);
cpu->exception_index = -1;
#endif
}
}
next_tb = 0; /* force lookup of first TB */
for(;;) {
interrupt_request = cpu->interrupt_request;
if (unlikely(interrupt_request)) {
if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) {
/* Mask out external interrupts for this step. */
interrupt_request &= ~CPU_INTERRUPT_SSTEP_MASK;
}
if (interrupt_request & CPU_INTERRUPT_DEBUG) {
cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG;
cpu->exception_index = EXCP_DEBUG;
cpu_loop_exit(cpu);
}
#if defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_MIPS) || \
defined(TARGET_PPC) || defined(TARGET_ALPHA) || defined(TARGET_CRIS) || \
defined(TARGET_MICROBLAZE) || defined(TARGET_LM32) || defined(TARGET_UNICORE32)
if (interrupt_request & CPU_INTERRUPT_HALT) {
cpu->interrupt_request &= ~CPU_INTERRUPT_HALT;
cpu->halted = 1;
cpu->exception_index = EXCP_HLT;
cpu_loop_exit(cpu);
}
#endif
#if defined(TARGET_I386)
#if !defined(CONFIG_USER_ONLY)
if (interrupt_request & CPU_INTERRUPT_POLL) {
cpu->interrupt_request &= ~CPU_INTERRUPT_POLL;
apic_poll_irq(x86_cpu->apic_state);
}
#endif
if (interrupt_request & CPU_INTERRUPT_INIT) {
cpu_svm_check_intercept_param(env, SVM_EXIT_INIT,
0);
do_cpu_init(x86_cpu);
cpu->exception_index = EXCP_HALTED;
cpu_loop_exit(cpu);
} else if (interrupt_request & CPU_INTERRUPT_SIPI) {
do_cpu_sipi(x86_cpu);
} else if (env->hflags2 & HF2_GIF_MASK) {
if ((interrupt_request & CPU_INTERRUPT_SMI) &&
!(env->hflags & HF_SMM_MASK)) {
cpu_svm_check_intercept_param(env, SVM_EXIT_SMI,
0);
cpu->interrupt_request &= ~CPU_INTERRUPT_SMI;
do_smm_enter(x86_cpu);
next_tb = 0;
} else if ((interrupt_request & CPU_INTERRUPT_NMI) &&
!(env->hflags2 & HF2_NMI_MASK)) {
cpu->interrupt_request &= ~CPU_INTERRUPT_NMI;
env->hflags2 |= HF2_NMI_MASK;
do_interrupt_x86_hardirq(env, EXCP02_NMI, 1);
next_tb = 0;
} else if (interrupt_request & CPU_INTERRUPT_MCE) {
cpu->interrupt_request &= ~CPU_INTERRUPT_MCE;
do_interrupt_x86_hardirq(env, EXCP12_MCHK, 0);
next_tb = 0;
} else if ((interrupt_request & CPU_INTERRUPT_HARD) &&
(((env->hflags2 & HF2_VINTR_MASK) &&
(env->hflags2 & HF2_HIF_MASK)) ||
(!(env->hflags2 & HF2_VINTR_MASK) &&
(env->eflags & IF_MASK &&
!(env->hflags & HF_INHIBIT_IRQ_MASK))))) {
int intno;
cpu_svm_check_intercept_param(env, SVM_EXIT_INTR,
0);
cpu->interrupt_request &= ~(CPU_INTERRUPT_HARD |
CPU_INTERRUPT_VIRQ);
intno = cpu_get_pic_interrupt(env);
qemu_log_mask(CPU_LOG_TB_IN_ASM, "Servicing hardware INT=0x%02x\n", intno);
do_interrupt_x86_hardirq(env, intno, 1);
/* ensure that no TB jump will be modified as
the program flow was changed */
next_tb = 0;
#if !defined(CONFIG_USER_ONLY)
} else if ((interrupt_request & CPU_INTERRUPT_VIRQ) &&
(env->eflags & IF_MASK) &&
!(env->hflags & HF_INHIBIT_IRQ_MASK)) {
int intno;
/* FIXME: this should respect TPR */
cpu_svm_check_intercept_param(env, SVM_EXIT_VINTR,
0);
intno = ldl_phys(cpu->as,
env->vm_vmcb
+ offsetof(struct vmcb,
control.int_vector));
qemu_log_mask(CPU_LOG_TB_IN_ASM, "Servicing virtual hardware INT=0x%02x\n", intno);
do_interrupt_x86_hardirq(env, intno, 1);
cpu->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
next_tb = 0;
#endif
}
}
#elif defined(TARGET_PPC)
if ((interrupt_request & CPU_INTERRUPT_RESET)) {
cpu_reset(cpu);
}
if (interrupt_request & CPU_INTERRUPT_HARD) {
ppc_hw_interrupt(env);
if (env->pending_interrupts == 0) {
cpu->interrupt_request &= ~CPU_INTERRUPT_HARD;
}
next_tb = 0;
}
#elif defined(TARGET_LM32)
if ((interrupt_request & CPU_INTERRUPT_HARD)
&& (env->ie & IE_IE)) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_MICROBLAZE)
if ((interrupt_request & CPU_INTERRUPT_HARD)
&& (env->sregs[SR_MSR] & MSR_IE)
&& !(env->sregs[SR_MSR] & (MSR_EIP | MSR_BIP))
&& !(env->iflags & (D_FLAG | IMM_FLAG))) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_MIPS)
if ((interrupt_request & CPU_INTERRUPT_HARD) &&
cpu_mips_hw_interrupts_pending(env)) {
/* Raise it */
cpu->exception_index = EXCP_EXT_INTERRUPT;
env->error_code = 0;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_OPENRISC)
{
int idx = -1;
if ((interrupt_request & CPU_INTERRUPT_HARD)
&& (env->sr & SR_IEE)) {
idx = EXCP_INT;
}
if ((interrupt_request & CPU_INTERRUPT_TIMER)
&& (env->sr & SR_TEE)) {
idx = EXCP_TICK;
}
if (idx >= 0) {
cpu->exception_index = idx;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
#elif defined(TARGET_SPARC)
if (interrupt_request & CPU_INTERRUPT_HARD) {
if (cpu_interrupts_enabled(env) &&
env->interrupt_index > 0) {
int pil = env->interrupt_index & 0xf;
int type = env->interrupt_index & 0xf0;
if (((type == TT_EXTINT) &&
cpu_pil_allowed(env, pil)) ||
type != TT_EXTINT) {
cpu->exception_index = env->interrupt_index;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
}
#elif defined(TARGET_ARM)
if (interrupt_request & CPU_INTERRUPT_FIQ
&& !(env->daif & PSTATE_F)) {
cpu->exception_index = EXCP_FIQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
/* ARMv7-M interrupt return works by loading a magic value
into the PC. On real hardware the load causes the
return to occur. The qemu implementation performs the
jump normally, then does the exception return when the
CPU tries to execute code at the magic address.
This will cause the magic PC value to be pushed to
the stack if an interrupt occurred at the wrong time.
We avoid this by disabling interrupts when
pc contains a magic address. */
if (interrupt_request & CPU_INTERRUPT_HARD
&& ((IS_M(env) && env->regs[15] < 0xfffffff0)
|| !(env->daif & PSTATE_I))) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_UNICORE32)
if (interrupt_request & CPU_INTERRUPT_HARD
&& !(env->uncached_asr & ASR_I)) {
cpu->exception_index = UC32_EXCP_INTR;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_SH4)
if (interrupt_request & CPU_INTERRUPT_HARD) {
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_ALPHA)
{
int idx = -1;
/* ??? This hard-codes the OSF/1 interrupt levels. */
switch (env->pal_mode ? 7 : env->ps & PS_INT_MASK) {
case 0 ... 3:
if (interrupt_request & CPU_INTERRUPT_HARD) {
idx = EXCP_DEV_INTERRUPT;
}
/* FALLTHRU */
case 4:
if (interrupt_request & CPU_INTERRUPT_TIMER) {
idx = EXCP_CLK_INTERRUPT;
}
/* FALLTHRU */
case 5:
if (interrupt_request & CPU_INTERRUPT_SMP) {
idx = EXCP_SMP_INTERRUPT;
}
/* FALLTHRU */
case 6:
if (interrupt_request & CPU_INTERRUPT_MCHK) {
idx = EXCP_MCHK;
}
}
if (idx >= 0) {
cpu->exception_index = idx;
env->error_code = 0;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
#elif defined(TARGET_CRIS)
if (interrupt_request & CPU_INTERRUPT_HARD
&& (env->pregs[PR_CCS] & I_FLAG)
&& !env->locked_irq) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
if (interrupt_request & CPU_INTERRUPT_NMI) {
unsigned int m_flag_archval;
if (env->pregs[PR_VR] < 32) {
m_flag_archval = M_FLAG_V10;
} else {
m_flag_archval = M_FLAG_V32;
}
if ((env->pregs[PR_CCS] & m_flag_archval)) {
cpu->exception_index = EXCP_NMI;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
#elif defined(TARGET_M68K)
if (interrupt_request & CPU_INTERRUPT_HARD
&& ((env->sr & SR_I) >> SR_I_SHIFT)
< env->pending_level) {
/* Real hardware gets the interrupt vector via an
IACK cycle at this point. Current emulated
hardware doesn't rely on this, so we
provide/save the vector when the interrupt is
first signalled. */
cpu->exception_index = env->pending_vector;
do_interrupt_m68k_hardirq(env);
next_tb = 0;
}
#elif defined(TARGET_S390X) && !defined(CONFIG_USER_ONLY)
if ((interrupt_request & CPU_INTERRUPT_HARD) &&
(env->psw.mask & PSW_MASK_EXT)) {
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_XTENSA)
if (interrupt_request & CPU_INTERRUPT_HARD) {
cpu->exception_index = EXC_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#endif
/* Don't use the cached interrupt_request value,
do_interrupt may have updated the EXITTB flag. */
if (cpu->interrupt_request & CPU_INTERRUPT_EXITTB) {
cpu->interrupt_request &= ~CPU_INTERRUPT_EXITTB;
/* ensure that no TB jump will be modified as
the program flow was changed */
next_tb = 0;
}
}
if (unlikely(cpu->exit_request)) {
cpu->exit_request = 0;
cpu->exception_index = EXCP_INTERRUPT;
cpu_loop_exit(cpu);
}
spin_lock(&tcg_ctx.tb_ctx.tb_lock);
have_tb_lock = true;
tb = tb_find_fast(env);
/* Note: we do it here to avoid a gcc bug on Mac OS X when
doing it in tb_find_slow */
if (tcg_ctx.tb_ctx.tb_invalidated_flag) {
/* as some TB could have been invalidated because
of memory exceptions while generating the code, we
must recompute the hash index here */
next_tb = 0;
tcg_ctx.tb_ctx.tb_invalidated_flag = 0;
}
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
qemu_log("Trace %p [" TARGET_FMT_lx "] %s\n",
tb->tc_ptr, tb->pc, lookup_symbol(tb->pc));
}
/* see if we can patch the calling TB. When the TB
spans two pages, we cannot safely do a direct
jump. */
if (next_tb != 0 && tb->page_addr[1] == -1) {
tb_add_jump((TranslationBlock *)(next_tb & ~TB_EXIT_MASK),
next_tb & TB_EXIT_MASK, tb);
}
have_tb_lock = false;
spin_unlock(&tcg_ctx.tb_ctx.tb_lock);
/* cpu_interrupt might be called while translating the
TB, but before it is linked into a potentially
infinite loop and becomes env->current_tb. Avoid
starting execution if there is a pending interrupt. */
cpu->current_tb = tb;
barrier();
if (likely(!cpu->exit_request)) {
tc_ptr = tb->tc_ptr;
/* execute the generated code */
next_tb = cpu_tb_exec(cpu, tc_ptr);
switch (next_tb & TB_EXIT_MASK) {
case TB_EXIT_REQUESTED:
/* Something asked us to stop executing
* chained TBs; just continue round the main
* loop. Whatever requested the exit will also
* have set something else (eg exit_request or
* interrupt_request) which we will handle
* next time around the loop.
*/
tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
next_tb = 0;
break;
case TB_EXIT_ICOUNT_EXPIRED:
{
/* Instruction counter expired. */
int insns_left;
tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
insns_left = cpu->icount_decr.u32;
if (cpu->icount_extra && insns_left >= 0) {
/* Refill decrementer and continue execution. */
cpu->icount_extra += insns_left;
if (cpu->icount_extra > 0xffff) {
insns_left = 0xffff;
} else {
insns_left = cpu->icount_extra;
}
cpu->icount_extra -= insns_left;
cpu->icount_decr.u16.low = insns_left;
} else {
if (insns_left > 0) {
/* Execute remaining instructions. */
cpu_exec_nocache(env, insns_left, tb);
}
cpu->exception_index = EXCP_INTERRUPT;
next_tb = 0;
cpu_loop_exit(cpu);
}
break;
}
default:
break;
}
}
cpu->current_tb = NULL;
/* reset soft MMU for next block (it can currently
only be set by a memory fault) */
} /* for(;;) */
} else {
/* Reload env after longjmp - the compiler may have smashed all
* local variables as longjmp is marked 'noreturn'. */
cpu = current_cpu;
env = cpu->env_ptr;
#if !(defined(CONFIG_USER_ONLY) && \
(defined(TARGET_M68K) || defined(TARGET_PPC) || defined(TARGET_S390X)))
cc = CPU_GET_CLASS(cpu);
#endif
#ifdef TARGET_I386
x86_cpu = X86_CPU(cpu);
#endif
if (have_tb_lock) {
spin_unlock(&tcg_ctx.tb_ctx.tb_lock);
have_tb_lock = false;
}
}
} /* for(;;) */
#if defined(TARGET_I386)
/* restore flags in standard format */
env->eflags = env->eflags | cpu_cc_compute_all(env, CC_OP)
| (env->df & DF_MASK);
#elif defined(TARGET_ARM)
/* XXX: Save/restore host fpu exception state?. */
#elif defined(TARGET_UNICORE32)
#elif defined(TARGET_SPARC)
#elif defined(TARGET_PPC)
#elif defined(TARGET_LM32)
#elif defined(TARGET_M68K)
cpu_m68k_flush_flags(env, env->cc_op);
env->cc_op = CC_OP_FLAGS;
env->sr = (env->sr & 0xffe0)
| env->cc_dest | (env->cc_x << 4);
#elif defined(TARGET_MICROBLAZE)
#elif defined(TARGET_MIPS)
#elif defined(TARGET_MOXIE)
#elif defined(TARGET_OPENRISC)
#elif defined(TARGET_SH4)
#elif defined(TARGET_ALPHA)
#elif defined(TARGET_CRIS)
#elif defined(TARGET_S390X)
#elif defined(TARGET_XTENSA)
/* XXXXX */
#else
#error unsupported target CPU
#endif
/* fail safe : never use current_cpu outside cpu_exec() */
current_cpu = NULL;
return ret;
} | true | qemu | bae2c270906475093e3d5f4c3103dbe67bf82009 | int cpu_exec(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
#if !(defined(CONFIG_USER_ONLY) && \
(defined(TARGET_M68K) || defined(TARGET_PPC) || defined(TARGET_S390X)))
CPUClass *cc = CPU_GET_CLASS(cpu);
#endif
#ifdef TARGET_I386
X86CPU *x86_cpu = X86_CPU(cpu);
#endif
int ret, interrupt_request;
TranslationBlock *tb;
uint8_t *tc_ptr;
uintptr_t next_tb;
if (cpu->halted) {
if (!cpu_has_work(cpu)) {
return EXCP_HALTED;
}
cpu->halted = 0;
}
current_cpu = cpu;
smp_mb();
if (unlikely(exit_request)) {
cpu->exit_request = 1;
}
#if defined(TARGET_I386)
CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
env->df = 1 - (2 * ((env->eflags >> 10) & 1));
CC_OP = CC_OP_EFLAGS;
env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
#elif defined(TARGET_SPARC)
#elif defined(TARGET_M68K)
env->cc_op = CC_OP_FLAGS;
env->cc_dest = env->sr & 0xf;
env->cc_x = (env->sr >> 4) & 1;
#elif defined(TARGET_ALPHA)
#elif defined(TARGET_ARM)
#elif defined(TARGET_UNICORE32)
#elif defined(TARGET_PPC)
env->reserve_addr = -1;
#elif defined(TARGET_LM32)
#elif defined(TARGET_MICROBLAZE)
#elif defined(TARGET_MIPS)
#elif defined(TARGET_MOXIE)
#elif defined(TARGET_OPENRISC)
#elif defined(TARGET_SH4)
#elif defined(TARGET_CRIS)
#elif defined(TARGET_S390X)
#elif defined(TARGET_XTENSA)
#else
#error unsupported target CPU
#endif
cpu->exception_index = -1;
for(;;) {
if (sigsetjmp(cpu->jmp_env, 0) == 0) {
if (cpu->exception_index >= 0) {
if (cpu->exception_index >= EXCP_INTERRUPT) {
ret = cpu->exception_index;
if (ret == EXCP_DEBUG) {
cpu_handle_debug_exception(env);
}
break;
} else {
#if defined(CONFIG_USER_ONLY)
#if defined(TARGET_I386)
cc->do_interrupt(cpu);
#endif
ret = cpu->exception_index;
break;
#else
cc->do_interrupt(cpu);
cpu->exception_index = -1;
#endif
}
}
next_tb = 0;
for(;;) {
interrupt_request = cpu->interrupt_request;
if (unlikely(interrupt_request)) {
if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) {
interrupt_request &= ~CPU_INTERRUPT_SSTEP_MASK;
}
if (interrupt_request & CPU_INTERRUPT_DEBUG) {
cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG;
cpu->exception_index = EXCP_DEBUG;
cpu_loop_exit(cpu);
}
#if defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_MIPS) || \
defined(TARGET_PPC) || defined(TARGET_ALPHA) || defined(TARGET_CRIS) || \
defined(TARGET_MICROBLAZE) || defined(TARGET_LM32) || defined(TARGET_UNICORE32)
if (interrupt_request & CPU_INTERRUPT_HALT) {
cpu->interrupt_request &= ~CPU_INTERRUPT_HALT;
cpu->halted = 1;
cpu->exception_index = EXCP_HLT;
cpu_loop_exit(cpu);
}
#endif
#if defined(TARGET_I386)
#if !defined(CONFIG_USER_ONLY)
if (interrupt_request & CPU_INTERRUPT_POLL) {
cpu->interrupt_request &= ~CPU_INTERRUPT_POLL;
apic_poll_irq(x86_cpu->apic_state);
}
#endif
if (interrupt_request & CPU_INTERRUPT_INIT) {
cpu_svm_check_intercept_param(env, SVM_EXIT_INIT,
0);
do_cpu_init(x86_cpu);
cpu->exception_index = EXCP_HALTED;
cpu_loop_exit(cpu);
} else if (interrupt_request & CPU_INTERRUPT_SIPI) {
do_cpu_sipi(x86_cpu);
} else if (env->hflags2 & HF2_GIF_MASK) {
if ((interrupt_request & CPU_INTERRUPT_SMI) &&
!(env->hflags & HF_SMM_MASK)) {
cpu_svm_check_intercept_param(env, SVM_EXIT_SMI,
0);
cpu->interrupt_request &= ~CPU_INTERRUPT_SMI;
do_smm_enter(x86_cpu);
next_tb = 0;
} else if ((interrupt_request & CPU_INTERRUPT_NMI) &&
!(env->hflags2 & HF2_NMI_MASK)) {
cpu->interrupt_request &= ~CPU_INTERRUPT_NMI;
env->hflags2 |= HF2_NMI_MASK;
do_interrupt_x86_hardirq(env, EXCP02_NMI, 1);
next_tb = 0;
} else if (interrupt_request & CPU_INTERRUPT_MCE) {
cpu->interrupt_request &= ~CPU_INTERRUPT_MCE;
do_interrupt_x86_hardirq(env, EXCP12_MCHK, 0);
next_tb = 0;
} else if ((interrupt_request & CPU_INTERRUPT_HARD) &&
(((env->hflags2 & HF2_VINTR_MASK) &&
(env->hflags2 & HF2_HIF_MASK)) ||
(!(env->hflags2 & HF2_VINTR_MASK) &&
(env->eflags & IF_MASK &&
!(env->hflags & HF_INHIBIT_IRQ_MASK))))) {
int intno;
cpu_svm_check_intercept_param(env, SVM_EXIT_INTR,
0);
cpu->interrupt_request &= ~(CPU_INTERRUPT_HARD |
CPU_INTERRUPT_VIRQ);
intno = cpu_get_pic_interrupt(env);
qemu_log_mask(CPU_LOG_TB_IN_ASM, "Servicing hardware INT=0x%02x\n", intno);
do_interrupt_x86_hardirq(env, intno, 1);
next_tb = 0;
#if !defined(CONFIG_USER_ONLY)
} else if ((interrupt_request & CPU_INTERRUPT_VIRQ) &&
(env->eflags & IF_MASK) &&
!(env->hflags & HF_INHIBIT_IRQ_MASK)) {
int intno;
cpu_svm_check_intercept_param(env, SVM_EXIT_VINTR,
0);
intno = ldl_phys(cpu->as,
env->vm_vmcb
+ offsetof(struct vmcb,
control.int_vector));
qemu_log_mask(CPU_LOG_TB_IN_ASM, "Servicing virtual hardware INT=0x%02x\n", intno);
do_interrupt_x86_hardirq(env, intno, 1);
cpu->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
next_tb = 0;
#endif
}
}
#elif defined(TARGET_PPC)
if ((interrupt_request & CPU_INTERRUPT_RESET)) {
cpu_reset(cpu);
}
if (interrupt_request & CPU_INTERRUPT_HARD) {
ppc_hw_interrupt(env);
if (env->pending_interrupts == 0) {
cpu->interrupt_request &= ~CPU_INTERRUPT_HARD;
}
next_tb = 0;
}
#elif defined(TARGET_LM32)
if ((interrupt_request & CPU_INTERRUPT_HARD)
&& (env->ie & IE_IE)) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_MICROBLAZE)
if ((interrupt_request & CPU_INTERRUPT_HARD)
&& (env->sregs[SR_MSR] & MSR_IE)
&& !(env->sregs[SR_MSR] & (MSR_EIP | MSR_BIP))
&& !(env->iflags & (D_FLAG | IMM_FLAG))) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_MIPS)
if ((interrupt_request & CPU_INTERRUPT_HARD) &&
cpu_mips_hw_interrupts_pending(env)) {
cpu->exception_index = EXCP_EXT_INTERRUPT;
env->error_code = 0;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_OPENRISC)
{
int idx = -1;
if ((interrupt_request & CPU_INTERRUPT_HARD)
&& (env->sr & SR_IEE)) {
idx = EXCP_INT;
}
if ((interrupt_request & CPU_INTERRUPT_TIMER)
&& (env->sr & SR_TEE)) {
idx = EXCP_TICK;
}
if (idx >= 0) {
cpu->exception_index = idx;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
#elif defined(TARGET_SPARC)
if (interrupt_request & CPU_INTERRUPT_HARD) {
if (cpu_interrupts_enabled(env) &&
env->interrupt_index > 0) {
int pil = env->interrupt_index & 0xf;
int type = env->interrupt_index & 0xf0;
if (((type == TT_EXTINT) &&
cpu_pil_allowed(env, pil)) ||
type != TT_EXTINT) {
cpu->exception_index = env->interrupt_index;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
}
#elif defined(TARGET_ARM)
if (interrupt_request & CPU_INTERRUPT_FIQ
&& !(env->daif & PSTATE_F)) {
cpu->exception_index = EXCP_FIQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
if (interrupt_request & CPU_INTERRUPT_HARD
&& ((IS_M(env) && env->regs[15] < 0xfffffff0)
|| !(env->daif & PSTATE_I))) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_UNICORE32)
if (interrupt_request & CPU_INTERRUPT_HARD
&& !(env->uncached_asr & ASR_I)) {
cpu->exception_index = UC32_EXCP_INTR;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_SH4)
if (interrupt_request & CPU_INTERRUPT_HARD) {
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_ALPHA)
{
int idx = -1;
switch (env->pal_mode ? 7 : env->ps & PS_INT_MASK) {
case 0 ... 3:
if (interrupt_request & CPU_INTERRUPT_HARD) {
idx = EXCP_DEV_INTERRUPT;
}
case 4:
if (interrupt_request & CPU_INTERRUPT_TIMER) {
idx = EXCP_CLK_INTERRUPT;
}
case 5:
if (interrupt_request & CPU_INTERRUPT_SMP) {
idx = EXCP_SMP_INTERRUPT;
}
case 6:
if (interrupt_request & CPU_INTERRUPT_MCHK) {
idx = EXCP_MCHK;
}
}
if (idx >= 0) {
cpu->exception_index = idx;
env->error_code = 0;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
#elif defined(TARGET_CRIS)
if (interrupt_request & CPU_INTERRUPT_HARD
&& (env->pregs[PR_CCS] & I_FLAG)
&& !env->locked_irq) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
if (interrupt_request & CPU_INTERRUPT_NMI) {
unsigned int m_flag_archval;
if (env->pregs[PR_VR] < 32) {
m_flag_archval = M_FLAG_V10;
} else {
m_flag_archval = M_FLAG_V32;
}
if ((env->pregs[PR_CCS] & m_flag_archval)) {
cpu->exception_index = EXCP_NMI;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
#elif defined(TARGET_M68K)
if (interrupt_request & CPU_INTERRUPT_HARD
&& ((env->sr & SR_I) >> SR_I_SHIFT)
< env->pending_level) {
cpu->exception_index = env->pending_vector;
do_interrupt_m68k_hardirq(env);
next_tb = 0;
}
#elif defined(TARGET_S390X) && !defined(CONFIG_USER_ONLY)
if ((interrupt_request & CPU_INTERRUPT_HARD) &&
(env->psw.mask & PSW_MASK_EXT)) {
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_XTENSA)
if (interrupt_request & CPU_INTERRUPT_HARD) {
cpu->exception_index = EXC_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#endif
if (cpu->interrupt_request & CPU_INTERRUPT_EXITTB) {
cpu->interrupt_request &= ~CPU_INTERRUPT_EXITTB;
next_tb = 0;
}
}
if (unlikely(cpu->exit_request)) {
cpu->exit_request = 0;
cpu->exception_index = EXCP_INTERRUPT;
cpu_loop_exit(cpu);
}
spin_lock(&tcg_ctx.tb_ctx.tb_lock);
have_tb_lock = true;
tb = tb_find_fast(env);
if (tcg_ctx.tb_ctx.tb_invalidated_flag) {
next_tb = 0;
tcg_ctx.tb_ctx.tb_invalidated_flag = 0;
}
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
qemu_log("Trace %p [" TARGET_FMT_lx "] %s\n",
tb->tc_ptr, tb->pc, lookup_symbol(tb->pc));
}
if (next_tb != 0 && tb->page_addr[1] == -1) {
tb_add_jump((TranslationBlock *)(next_tb & ~TB_EXIT_MASK),
next_tb & TB_EXIT_MASK, tb);
}
have_tb_lock = false;
spin_unlock(&tcg_ctx.tb_ctx.tb_lock);
cpu->current_tb = tb;
barrier();
if (likely(!cpu->exit_request)) {
tc_ptr = tb->tc_ptr;
next_tb = cpu_tb_exec(cpu, tc_ptr);
switch (next_tb & TB_EXIT_MASK) {
case TB_EXIT_REQUESTED:
tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
next_tb = 0;
break;
case TB_EXIT_ICOUNT_EXPIRED:
{
int insns_left;
tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
insns_left = cpu->icount_decr.u32;
if (cpu->icount_extra && insns_left >= 0) {
cpu->icount_extra += insns_left;
if (cpu->icount_extra > 0xffff) {
insns_left = 0xffff;
} else {
insns_left = cpu->icount_extra;
}
cpu->icount_extra -= insns_left;
cpu->icount_decr.u16.low = insns_left;
} else {
if (insns_left > 0) {
cpu_exec_nocache(env, insns_left, tb);
}
cpu->exception_index = EXCP_INTERRUPT;
next_tb = 0;
cpu_loop_exit(cpu);
}
break;
}
default:
break;
}
}
cpu->current_tb = NULL;
}
} else {
cpu = current_cpu;
env = cpu->env_ptr;
#if !(defined(CONFIG_USER_ONLY) && \
(defined(TARGET_M68K) || defined(TARGET_PPC) || defined(TARGET_S390X)))
cc = CPU_GET_CLASS(cpu);
#endif
#ifdef TARGET_I386
x86_cpu = X86_CPU(cpu);
#endif
if (have_tb_lock) {
spin_unlock(&tcg_ctx.tb_ctx.tb_lock);
have_tb_lock = false;
}
}
}
#if defined(TARGET_I386)
env->eflags = env->eflags | cpu_cc_compute_all(env, CC_OP)
| (env->df & DF_MASK);
#elif defined(TARGET_ARM)
#elif defined(TARGET_UNICORE32)
#elif defined(TARGET_SPARC)
#elif defined(TARGET_PPC)
#elif defined(TARGET_LM32)
#elif defined(TARGET_M68K)
cpu_m68k_flush_flags(env, env->cc_op);
env->cc_op = CC_OP_FLAGS;
env->sr = (env->sr & 0xffe0)
| env->cc_dest | (env->cc_x << 4);
#elif defined(TARGET_MICROBLAZE)
#elif defined(TARGET_MIPS)
#elif defined(TARGET_MOXIE)
#elif defined(TARGET_OPENRISC)
#elif defined(TARGET_SH4)
#elif defined(TARGET_ALPHA)
#elif defined(TARGET_CRIS)
#elif defined(TARGET_S390X)
#elif defined(TARGET_XTENSA)
#else
#error unsupported target CPU
#endif
current_cpu = NULL;
return ret;
} | {
"code": [],
"line_no": []
} | int FUNC_0(CPUArchState *VAR_0)
{
CPUState *cpu = ENV_GET_CPU(VAR_0);
#if !(defined(CONFIG_USER_ONLY) && \
(defined(TARGET_M68K) || defined(TARGET_PPC) || defined(TARGET_S390X)))
CPUClass *cc = CPU_GET_CLASS(cpu);
#endif
#ifdef TARGET_I386
X86CPU *x86_cpu = X86_CPU(cpu);
#endif
int VAR_1, VAR_2;
TranslationBlock *tb;
uint8_t *tc_ptr;
uintptr_t next_tb;
if (cpu->halted) {
if (!cpu_has_work(cpu)) {
return EXCP_HALTED;
}
cpu->halted = 0;
}
current_cpu = cpu;
smp_mb();
if (unlikely(exit_request)) {
cpu->exit_request = 1;
}
#if defined(TARGET_I386)
CC_SRC = VAR_0->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
VAR_0->df = 1 - (2 * ((VAR_0->eflags >> 10) & 1));
CC_OP = CC_OP_EFLAGS;
VAR_0->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
#elif defined(TARGET_SPARC)
#elif defined(TARGET_M68K)
VAR_0->cc_op = CC_OP_FLAGS;
VAR_0->cc_dest = VAR_0->sr & 0xf;
VAR_0->cc_x = (VAR_0->sr >> 4) & 1;
#elif defined(TARGET_ALPHA)
#elif defined(TARGET_ARM)
#elif defined(TARGET_UNICORE32)
#elif defined(TARGET_PPC)
VAR_0->reserve_addr = -1;
#elif defined(TARGET_LM32)
#elif defined(TARGET_MICROBLAZE)
#elif defined(TARGET_MIPS)
#elif defined(TARGET_MOXIE)
#elif defined(TARGET_OPENRISC)
#elif defined(TARGET_SH4)
#elif defined(TARGET_CRIS)
#elif defined(TARGET_S390X)
#elif defined(TARGET_XTENSA)
#else
#error unsupported target CPU
#endif
cpu->exception_index = -1;
for(;;) {
if (sigsetjmp(cpu->jmp_env, 0) == 0) {
if (cpu->exception_index >= 0) {
if (cpu->exception_index >= EXCP_INTERRUPT) {
VAR_1 = cpu->exception_index;
if (VAR_1 == EXCP_DEBUG) {
cpu_handle_debug_exception(VAR_0);
}
break;
} else {
#if defined(CONFIG_USER_ONLY)
#if defined(TARGET_I386)
cc->do_interrupt(cpu);
#endif
VAR_1 = cpu->exception_index;
break;
#else
cc->do_interrupt(cpu);
cpu->exception_index = -1;
#endif
}
}
next_tb = 0;
for(;;) {
VAR_2 = cpu->VAR_2;
if (unlikely(VAR_2)) {
if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) {
VAR_2 &= ~CPU_INTERRUPT_SSTEP_MASK;
}
if (VAR_2 & CPU_INTERRUPT_DEBUG) {
cpu->VAR_2 &= ~CPU_INTERRUPT_DEBUG;
cpu->exception_index = EXCP_DEBUG;
cpu_loop_exit(cpu);
}
#if defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_MIPS) || \
defined(TARGET_PPC) || defined(TARGET_ALPHA) || defined(TARGET_CRIS) || \
defined(TARGET_MICROBLAZE) || defined(TARGET_LM32) || defined(TARGET_UNICORE32)
if (VAR_2 & CPU_INTERRUPT_HALT) {
cpu->VAR_2 &= ~CPU_INTERRUPT_HALT;
cpu->halted = 1;
cpu->exception_index = EXCP_HLT;
cpu_loop_exit(cpu);
}
#endif
#if defined(TARGET_I386)
#if !defined(CONFIG_USER_ONLY)
if (VAR_2 & CPU_INTERRUPT_POLL) {
cpu->VAR_2 &= ~CPU_INTERRUPT_POLL;
apic_poll_irq(x86_cpu->apic_state);
}
#endif
if (VAR_2 & CPU_INTERRUPT_INIT) {
cpu_svm_check_intercept_param(VAR_0, SVM_EXIT_INIT,
0);
do_cpu_init(x86_cpu);
cpu->exception_index = EXCP_HALTED;
cpu_loop_exit(cpu);
} else if (VAR_2 & CPU_INTERRUPT_SIPI) {
do_cpu_sipi(x86_cpu);
} else if (VAR_0->hflags2 & HF2_GIF_MASK) {
if ((VAR_2 & CPU_INTERRUPT_SMI) &&
!(VAR_0->hflags & HF_SMM_MASK)) {
cpu_svm_check_intercept_param(VAR_0, SVM_EXIT_SMI,
0);
cpu->VAR_2 &= ~CPU_INTERRUPT_SMI;
do_smm_enter(x86_cpu);
next_tb = 0;
} else if ((VAR_2 & CPU_INTERRUPT_NMI) &&
!(VAR_0->hflags2 & HF2_NMI_MASK)) {
cpu->VAR_2 &= ~CPU_INTERRUPT_NMI;
VAR_0->hflags2 |= HF2_NMI_MASK;
do_interrupt_x86_hardirq(VAR_0, EXCP02_NMI, 1);
next_tb = 0;
} else if (VAR_2 & CPU_INTERRUPT_MCE) {
cpu->VAR_2 &= ~CPU_INTERRUPT_MCE;
do_interrupt_x86_hardirq(VAR_0, EXCP12_MCHK, 0);
next_tb = 0;
} else if ((VAR_2 & CPU_INTERRUPT_HARD) &&
(((VAR_0->hflags2 & HF2_VINTR_MASK) &&
(VAR_0->hflags2 & HF2_HIF_MASK)) ||
(!(VAR_0->hflags2 & HF2_VINTR_MASK) &&
(VAR_0->eflags & IF_MASK &&
!(VAR_0->hflags & HF_INHIBIT_IRQ_MASK))))) {
int intno;
cpu_svm_check_intercept_param(VAR_0, SVM_EXIT_INTR,
0);
cpu->VAR_2 &= ~(CPU_INTERRUPT_HARD |
CPU_INTERRUPT_VIRQ);
intno = cpu_get_pic_interrupt(VAR_0);
qemu_log_mask(CPU_LOG_TB_IN_ASM, "Servicing hardware INT=0x%02x\n", intno);
do_interrupt_x86_hardirq(VAR_0, intno, 1);
next_tb = 0;
#if !defined(CONFIG_USER_ONLY)
} else if ((VAR_2 & CPU_INTERRUPT_VIRQ) &&
(VAR_0->eflags & IF_MASK) &&
!(VAR_0->hflags & HF_INHIBIT_IRQ_MASK)) {
int intno;
cpu_svm_check_intercept_param(VAR_0, SVM_EXIT_VINTR,
0);
intno = ldl_phys(cpu->as,
VAR_0->vm_vmcb
+ offsetof(struct vmcb,
control.int_vector));
qemu_log_mask(CPU_LOG_TB_IN_ASM, "Servicing virtual hardware INT=0x%02x\n", intno);
do_interrupt_x86_hardirq(VAR_0, intno, 1);
cpu->VAR_2 &= ~CPU_INTERRUPT_VIRQ;
next_tb = 0;
#endif
}
}
#elif defined(TARGET_PPC)
if ((VAR_2 & CPU_INTERRUPT_RESET)) {
cpu_reset(cpu);
}
if (VAR_2 & CPU_INTERRUPT_HARD) {
ppc_hw_interrupt(VAR_0);
if (VAR_0->pending_interrupts == 0) {
cpu->VAR_2 &= ~CPU_INTERRUPT_HARD;
}
next_tb = 0;
}
#elif defined(TARGET_LM32)
if ((VAR_2 & CPU_INTERRUPT_HARD)
&& (VAR_0->ie & IE_IE)) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_MICROBLAZE)
if ((VAR_2 & CPU_INTERRUPT_HARD)
&& (VAR_0->sregs[SR_MSR] & MSR_IE)
&& !(VAR_0->sregs[SR_MSR] & (MSR_EIP | MSR_BIP))
&& !(VAR_0->iflags & (D_FLAG | IMM_FLAG))) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_MIPS)
if ((VAR_2 & CPU_INTERRUPT_HARD) &&
cpu_mips_hw_interrupts_pending(VAR_0)) {
cpu->exception_index = EXCP_EXT_INTERRUPT;
VAR_0->error_code = 0;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_OPENRISC)
{
int idx = -1;
if ((VAR_2 & CPU_INTERRUPT_HARD)
&& (VAR_0->sr & SR_IEE)) {
idx = EXCP_INT;
}
if ((VAR_2 & CPU_INTERRUPT_TIMER)
&& (VAR_0->sr & SR_TEE)) {
idx = EXCP_TICK;
}
if (idx >= 0) {
cpu->exception_index = idx;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
#elif defined(TARGET_SPARC)
if (VAR_2 & CPU_INTERRUPT_HARD) {
if (cpu_interrupts_enabled(VAR_0) &&
VAR_0->interrupt_index > 0) {
int pil = VAR_0->interrupt_index & 0xf;
int type = VAR_0->interrupt_index & 0xf0;
if (((type == TT_EXTINT) &&
cpu_pil_allowed(VAR_0, pil)) ||
type != TT_EXTINT) {
cpu->exception_index = VAR_0->interrupt_index;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
}
#elif defined(TARGET_ARM)
if (VAR_2 & CPU_INTERRUPT_FIQ
&& !(VAR_0->daif & PSTATE_F)) {
cpu->exception_index = EXCP_FIQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
if (VAR_2 & CPU_INTERRUPT_HARD
&& ((IS_M(VAR_0) && VAR_0->regs[15] < 0xfffffff0)
|| !(VAR_0->daif & PSTATE_I))) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_UNICORE32)
if (VAR_2 & CPU_INTERRUPT_HARD
&& !(VAR_0->uncached_asr & ASR_I)) {
cpu->exception_index = UC32_EXCP_INTR;
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_SH4)
if (VAR_2 & CPU_INTERRUPT_HARD) {
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_ALPHA)
{
int idx = -1;
switch (VAR_0->pal_mode ? 7 : VAR_0->ps & PS_INT_MASK) {
case 0 ... 3:
if (VAR_2 & CPU_INTERRUPT_HARD) {
idx = EXCP_DEV_INTERRUPT;
}
case 4:
if (VAR_2 & CPU_INTERRUPT_TIMER) {
idx = EXCP_CLK_INTERRUPT;
}
case 5:
if (VAR_2 & CPU_INTERRUPT_SMP) {
idx = EXCP_SMP_INTERRUPT;
}
case 6:
if (VAR_2 & CPU_INTERRUPT_MCHK) {
idx = EXCP_MCHK;
}
}
if (idx >= 0) {
cpu->exception_index = idx;
VAR_0->error_code = 0;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
#elif defined(TARGET_CRIS)
if (VAR_2 & CPU_INTERRUPT_HARD
&& (VAR_0->pregs[PR_CCS] & I_FLAG)
&& !VAR_0->locked_irq) {
cpu->exception_index = EXCP_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
if (VAR_2 & CPU_INTERRUPT_NMI) {
unsigned int m_flag_archval;
if (VAR_0->pregs[PR_VR] < 32) {
m_flag_archval = M_FLAG_V10;
} else {
m_flag_archval = M_FLAG_V32;
}
if ((VAR_0->pregs[PR_CCS] & m_flag_archval)) {
cpu->exception_index = EXCP_NMI;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
#elif defined(TARGET_M68K)
if (VAR_2 & CPU_INTERRUPT_HARD
&& ((VAR_0->sr & SR_I) >> SR_I_SHIFT)
< VAR_0->pending_level) {
cpu->exception_index = VAR_0->pending_vector;
do_interrupt_m68k_hardirq(VAR_0);
next_tb = 0;
}
#elif defined(TARGET_S390X) && !defined(CONFIG_USER_ONLY)
if ((VAR_2 & CPU_INTERRUPT_HARD) &&
(VAR_0->psw.mask & PSW_MASK_EXT)) {
cc->do_interrupt(cpu);
next_tb = 0;
}
#elif defined(TARGET_XTENSA)
if (VAR_2 & CPU_INTERRUPT_HARD) {
cpu->exception_index = EXC_IRQ;
cc->do_interrupt(cpu);
next_tb = 0;
}
#endif
if (cpu->VAR_2 & CPU_INTERRUPT_EXITTB) {
cpu->VAR_2 &= ~CPU_INTERRUPT_EXITTB;
next_tb = 0;
}
}
if (unlikely(cpu->exit_request)) {
cpu->exit_request = 0;
cpu->exception_index = EXCP_INTERRUPT;
cpu_loop_exit(cpu);
}
spin_lock(&tcg_ctx.tb_ctx.tb_lock);
have_tb_lock = true;
tb = tb_find_fast(VAR_0);
if (tcg_ctx.tb_ctx.tb_invalidated_flag) {
next_tb = 0;
tcg_ctx.tb_ctx.tb_invalidated_flag = 0;
}
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
qemu_log("Trace %p [" TARGET_FMT_lx "] %s\n",
tb->tc_ptr, tb->pc, lookup_symbol(tb->pc));
}
if (next_tb != 0 && tb->page_addr[1] == -1) {
tb_add_jump((TranslationBlock *)(next_tb & ~TB_EXIT_MASK),
next_tb & TB_EXIT_MASK, tb);
}
have_tb_lock = false;
spin_unlock(&tcg_ctx.tb_ctx.tb_lock);
cpu->current_tb = tb;
barrier();
if (likely(!cpu->exit_request)) {
tc_ptr = tb->tc_ptr;
next_tb = cpu_tb_exec(cpu, tc_ptr);
switch (next_tb & TB_EXIT_MASK) {
case TB_EXIT_REQUESTED:
tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
next_tb = 0;
break;
case TB_EXIT_ICOUNT_EXPIRED:
{
int VAR_3;
tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
VAR_3 = cpu->icount_decr.u32;
if (cpu->icount_extra && VAR_3 >= 0) {
cpu->icount_extra += VAR_3;
if (cpu->icount_extra > 0xffff) {
VAR_3 = 0xffff;
} else {
VAR_3 = cpu->icount_extra;
}
cpu->icount_extra -= VAR_3;
cpu->icount_decr.u16.low = VAR_3;
} else {
if (VAR_3 > 0) {
cpu_exec_nocache(VAR_0, VAR_3, tb);
}
cpu->exception_index = EXCP_INTERRUPT;
next_tb = 0;
cpu_loop_exit(cpu);
}
break;
}
default:
break;
}
}
cpu->current_tb = NULL;
}
} else {
cpu = current_cpu;
VAR_0 = cpu->env_ptr;
#if !(defined(CONFIG_USER_ONLY) && \
(defined(TARGET_M68K) || defined(TARGET_PPC) || defined(TARGET_S390X)))
cc = CPU_GET_CLASS(cpu);
#endif
#ifdef TARGET_I386
x86_cpu = X86_CPU(cpu);
#endif
if (have_tb_lock) {
spin_unlock(&tcg_ctx.tb_ctx.tb_lock);
have_tb_lock = false;
}
}
}
#if defined(TARGET_I386)
VAR_0->eflags = VAR_0->eflags | cpu_cc_compute_all(VAR_0, CC_OP)
| (VAR_0->df & DF_MASK);
#elif defined(TARGET_ARM)
#elif defined(TARGET_UNICORE32)
#elif defined(TARGET_SPARC)
#elif defined(TARGET_PPC)
#elif defined(TARGET_LM32)
#elif defined(TARGET_M68K)
cpu_m68k_flush_flags(VAR_0, VAR_0->cc_op);
VAR_0->cc_op = CC_OP_FLAGS;
VAR_0->sr = (VAR_0->sr & 0xffe0)
| VAR_0->cc_dest | (VAR_0->cc_x << 4);
#elif defined(TARGET_MICROBLAZE)
#elif defined(TARGET_MIPS)
#elif defined(TARGET_MOXIE)
#elif defined(TARGET_OPENRISC)
#elif defined(TARGET_SH4)
#elif defined(TARGET_ALPHA)
#elif defined(TARGET_CRIS)
#elif defined(TARGET_S390X)
#elif defined(TARGET_XTENSA)
#else
#error unsupported target CPU
#endif
current_cpu = NULL;
return VAR_1;
} | [
"int FUNC_0(CPUArchState *VAR_0)\n{",
"CPUState *cpu = ENV_GET_CPU(VAR_0);",
"#if !(defined(CONFIG_USER_ONLY) && \\\n(defined(TARGET_M68K) || defined(TARGET_PPC) || defined(TARGET_S390X)))\nCPUClass *cc = CPU_GET_CLASS(cpu);",
"#endif\n#ifdef TARGET_I386\nX86CPU *x86_cpu = X86_CPU(cpu);",
"#endif\nint VAR_1, VAR_2;",
"TranslationBlock *tb;",
"uint8_t *tc_ptr;",
"uintptr_t next_tb;",
"if (cpu->halted) {",
"if (!cpu_has_work(cpu)) {",
"return EXCP_HALTED;",
"}",
"cpu->halted = 0;",
"}",
"current_cpu = cpu;",
"smp_mb();",
"if (unlikely(exit_request)) {",
"cpu->exit_request = 1;",
"}",
"#if defined(TARGET_I386)\nCC_SRC = VAR_0->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);",
"VAR_0->df = 1 - (2 * ((VAR_0->eflags >> 10) & 1));",
"CC_OP = CC_OP_EFLAGS;",
"VAR_0->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);",
"#elif defined(TARGET_SPARC)\n#elif defined(TARGET_M68K)\nVAR_0->cc_op = CC_OP_FLAGS;",
"VAR_0->cc_dest = VAR_0->sr & 0xf;",
"VAR_0->cc_x = (VAR_0->sr >> 4) & 1;",
"#elif defined(TARGET_ALPHA)\n#elif defined(TARGET_ARM)\n#elif defined(TARGET_UNICORE32)\n#elif defined(TARGET_PPC)\nVAR_0->reserve_addr = -1;",
"#elif defined(TARGET_LM32)\n#elif defined(TARGET_MICROBLAZE)\n#elif defined(TARGET_MIPS)\n#elif defined(TARGET_MOXIE)\n#elif defined(TARGET_OPENRISC)\n#elif defined(TARGET_SH4)\n#elif defined(TARGET_CRIS)\n#elif defined(TARGET_S390X)\n#elif defined(TARGET_XTENSA)\n#else\n#error unsupported target CPU\n#endif\ncpu->exception_index = -1;",
"for(;;) {",
"if (sigsetjmp(cpu->jmp_env, 0) == 0) {",
"if (cpu->exception_index >= 0) {",
"if (cpu->exception_index >= EXCP_INTERRUPT) {",
"VAR_1 = cpu->exception_index;",
"if (VAR_1 == EXCP_DEBUG) {",
"cpu_handle_debug_exception(VAR_0);",
"}",
"break;",
"} else {",
"#if defined(CONFIG_USER_ONLY)\n#if defined(TARGET_I386)\ncc->do_interrupt(cpu);",
"#endif\nVAR_1 = cpu->exception_index;",
"break;",
"#else\ncc->do_interrupt(cpu);",
"cpu->exception_index = -1;",
"#endif\n}",
"}",
"next_tb = 0;",
"for(;;) {",
"VAR_2 = cpu->VAR_2;",
"if (unlikely(VAR_2)) {",
"if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) {",
"VAR_2 &= ~CPU_INTERRUPT_SSTEP_MASK;",
"}",
"if (VAR_2 & CPU_INTERRUPT_DEBUG) {",
"cpu->VAR_2 &= ~CPU_INTERRUPT_DEBUG;",
"cpu->exception_index = EXCP_DEBUG;",
"cpu_loop_exit(cpu);",
"}",
"#if defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_MIPS) || \\\ndefined(TARGET_PPC) || defined(TARGET_ALPHA) || defined(TARGET_CRIS) || \\\ndefined(TARGET_MICROBLAZE) || defined(TARGET_LM32) || defined(TARGET_UNICORE32)\nif (VAR_2 & CPU_INTERRUPT_HALT) {",
"cpu->VAR_2 &= ~CPU_INTERRUPT_HALT;",
"cpu->halted = 1;",
"cpu->exception_index = EXCP_HLT;",
"cpu_loop_exit(cpu);",
"}",
"#endif\n#if defined(TARGET_I386)\n#if !defined(CONFIG_USER_ONLY)\nif (VAR_2 & CPU_INTERRUPT_POLL) {",
"cpu->VAR_2 &= ~CPU_INTERRUPT_POLL;",
"apic_poll_irq(x86_cpu->apic_state);",
"}",
"#endif\nif (VAR_2 & CPU_INTERRUPT_INIT) {",
"cpu_svm_check_intercept_param(VAR_0, SVM_EXIT_INIT,\n0);",
"do_cpu_init(x86_cpu);",
"cpu->exception_index = EXCP_HALTED;",
"cpu_loop_exit(cpu);",
"} else if (VAR_2 & CPU_INTERRUPT_SIPI) {",
"do_cpu_sipi(x86_cpu);",
"} else if (VAR_0->hflags2 & HF2_GIF_MASK) {",
"if ((VAR_2 & CPU_INTERRUPT_SMI) &&\n!(VAR_0->hflags & HF_SMM_MASK)) {",
"cpu_svm_check_intercept_param(VAR_0, SVM_EXIT_SMI,\n0);",
"cpu->VAR_2 &= ~CPU_INTERRUPT_SMI;",
"do_smm_enter(x86_cpu);",
"next_tb = 0;",
"} else if ((VAR_2 & CPU_INTERRUPT_NMI) &&",
"!(VAR_0->hflags2 & HF2_NMI_MASK)) {",
"cpu->VAR_2 &= ~CPU_INTERRUPT_NMI;",
"VAR_0->hflags2 |= HF2_NMI_MASK;",
"do_interrupt_x86_hardirq(VAR_0, EXCP02_NMI, 1);",
"next_tb = 0;",
"} else if (VAR_2 & CPU_INTERRUPT_MCE) {",
"cpu->VAR_2 &= ~CPU_INTERRUPT_MCE;",
"do_interrupt_x86_hardirq(VAR_0, EXCP12_MCHK, 0);",
"next_tb = 0;",
"} else if ((VAR_2 & CPU_INTERRUPT_HARD) &&",
"(((VAR_0->hflags2 & HF2_VINTR_MASK) &&\n(VAR_0->hflags2 & HF2_HIF_MASK)) ||\n(!(VAR_0->hflags2 & HF2_VINTR_MASK) &&\n(VAR_0->eflags & IF_MASK &&\n!(VAR_0->hflags & HF_INHIBIT_IRQ_MASK))))) {",
"int intno;",
"cpu_svm_check_intercept_param(VAR_0, SVM_EXIT_INTR,\n0);",
"cpu->VAR_2 &= ~(CPU_INTERRUPT_HARD |\nCPU_INTERRUPT_VIRQ);",
"intno = cpu_get_pic_interrupt(VAR_0);",
"qemu_log_mask(CPU_LOG_TB_IN_ASM, \"Servicing hardware INT=0x%02x\\n\", intno);",
"do_interrupt_x86_hardirq(VAR_0, intno, 1);",
"next_tb = 0;",
"#if !defined(CONFIG_USER_ONLY)\n} else if ((VAR_2 & CPU_INTERRUPT_VIRQ) &&",
"(VAR_0->eflags & IF_MASK) &&\n!(VAR_0->hflags & HF_INHIBIT_IRQ_MASK)) {",
"int intno;",
"cpu_svm_check_intercept_param(VAR_0, SVM_EXIT_VINTR,\n0);",
"intno = ldl_phys(cpu->as,\nVAR_0->vm_vmcb\n+ offsetof(struct vmcb,\ncontrol.int_vector));",
"qemu_log_mask(CPU_LOG_TB_IN_ASM, \"Servicing virtual hardware INT=0x%02x\\n\", intno);",
"do_interrupt_x86_hardirq(VAR_0, intno, 1);",
"cpu->VAR_2 &= ~CPU_INTERRUPT_VIRQ;",
"next_tb = 0;",
"#endif\n}",
"}",
"#elif defined(TARGET_PPC)\nif ((VAR_2 & CPU_INTERRUPT_RESET)) {",
"cpu_reset(cpu);",
"}",
"if (VAR_2 & CPU_INTERRUPT_HARD) {",
"ppc_hw_interrupt(VAR_0);",
"if (VAR_0->pending_interrupts == 0) {",
"cpu->VAR_2 &= ~CPU_INTERRUPT_HARD;",
"}",
"next_tb = 0;",
"}",
"#elif defined(TARGET_LM32)\nif ((VAR_2 & CPU_INTERRUPT_HARD)\n&& (VAR_0->ie & IE_IE)) {",
"cpu->exception_index = EXCP_IRQ;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"#elif defined(TARGET_MICROBLAZE)\nif ((VAR_2 & CPU_INTERRUPT_HARD)\n&& (VAR_0->sregs[SR_MSR] & MSR_IE)\n&& !(VAR_0->sregs[SR_MSR] & (MSR_EIP | MSR_BIP))\n&& !(VAR_0->iflags & (D_FLAG | IMM_FLAG))) {",
"cpu->exception_index = EXCP_IRQ;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"#elif defined(TARGET_MIPS)\nif ((VAR_2 & CPU_INTERRUPT_HARD) &&\ncpu_mips_hw_interrupts_pending(VAR_0)) {",
"cpu->exception_index = EXCP_EXT_INTERRUPT;",
"VAR_0->error_code = 0;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"#elif defined(TARGET_OPENRISC)\n{",
"int idx = -1;",
"if ((VAR_2 & CPU_INTERRUPT_HARD)\n&& (VAR_0->sr & SR_IEE)) {",
"idx = EXCP_INT;",
"}",
"if ((VAR_2 & CPU_INTERRUPT_TIMER)\n&& (VAR_0->sr & SR_TEE)) {",
"idx = EXCP_TICK;",
"}",
"if (idx >= 0) {",
"cpu->exception_index = idx;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"}",
"#elif defined(TARGET_SPARC)\nif (VAR_2 & CPU_INTERRUPT_HARD) {",
"if (cpu_interrupts_enabled(VAR_0) &&\nVAR_0->interrupt_index > 0) {",
"int pil = VAR_0->interrupt_index & 0xf;",
"int type = VAR_0->interrupt_index & 0xf0;",
"if (((type == TT_EXTINT) &&\ncpu_pil_allowed(VAR_0, pil)) ||\ntype != TT_EXTINT) {",
"cpu->exception_index = VAR_0->interrupt_index;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"}",
"}",
"#elif defined(TARGET_ARM)\nif (VAR_2 & CPU_INTERRUPT_FIQ\n&& !(VAR_0->daif & PSTATE_F)) {",
"cpu->exception_index = EXCP_FIQ;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"if (VAR_2 & CPU_INTERRUPT_HARD\n&& ((IS_M(VAR_0) && VAR_0->regs[15] < 0xfffffff0)\n|| !(VAR_0->daif & PSTATE_I))) {",
"cpu->exception_index = EXCP_IRQ;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"#elif defined(TARGET_UNICORE32)\nif (VAR_2 & CPU_INTERRUPT_HARD\n&& !(VAR_0->uncached_asr & ASR_I)) {",
"cpu->exception_index = UC32_EXCP_INTR;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"#elif defined(TARGET_SH4)\nif (VAR_2 & CPU_INTERRUPT_HARD) {",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"#elif defined(TARGET_ALPHA)\n{",
"int idx = -1;",
"switch (VAR_0->pal_mode ? 7 : VAR_0->ps & PS_INT_MASK) {",
"case 0 ... 3:\nif (VAR_2 & CPU_INTERRUPT_HARD) {",
"idx = EXCP_DEV_INTERRUPT;",
"}",
"case 4:\nif (VAR_2 & CPU_INTERRUPT_TIMER) {",
"idx = EXCP_CLK_INTERRUPT;",
"}",
"case 5:\nif (VAR_2 & CPU_INTERRUPT_SMP) {",
"idx = EXCP_SMP_INTERRUPT;",
"}",
"case 6:\nif (VAR_2 & CPU_INTERRUPT_MCHK) {",
"idx = EXCP_MCHK;",
"}",
"}",
"if (idx >= 0) {",
"cpu->exception_index = idx;",
"VAR_0->error_code = 0;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"}",
"#elif defined(TARGET_CRIS)\nif (VAR_2 & CPU_INTERRUPT_HARD\n&& (VAR_0->pregs[PR_CCS] & I_FLAG)\n&& !VAR_0->locked_irq) {",
"cpu->exception_index = EXCP_IRQ;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"if (VAR_2 & CPU_INTERRUPT_NMI) {",
"unsigned int m_flag_archval;",
"if (VAR_0->pregs[PR_VR] < 32) {",
"m_flag_archval = M_FLAG_V10;",
"} else {",
"m_flag_archval = M_FLAG_V32;",
"}",
"if ((VAR_0->pregs[PR_CCS] & m_flag_archval)) {",
"cpu->exception_index = EXCP_NMI;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"}",
"#elif defined(TARGET_M68K)\nif (VAR_2 & CPU_INTERRUPT_HARD\n&& ((VAR_0->sr & SR_I) >> SR_I_SHIFT)\n< VAR_0->pending_level) {",
"cpu->exception_index = VAR_0->pending_vector;",
"do_interrupt_m68k_hardirq(VAR_0);",
"next_tb = 0;",
"}",
"#elif defined(TARGET_S390X) && !defined(CONFIG_USER_ONLY)\nif ((VAR_2 & CPU_INTERRUPT_HARD) &&\n(VAR_0->psw.mask & PSW_MASK_EXT)) {",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"#elif defined(TARGET_XTENSA)\nif (VAR_2 & CPU_INTERRUPT_HARD) {",
"cpu->exception_index = EXC_IRQ;",
"cc->do_interrupt(cpu);",
"next_tb = 0;",
"}",
"#endif\nif (cpu->VAR_2 & CPU_INTERRUPT_EXITTB) {",
"cpu->VAR_2 &= ~CPU_INTERRUPT_EXITTB;",
"next_tb = 0;",
"}",
"}",
"if (unlikely(cpu->exit_request)) {",
"cpu->exit_request = 0;",
"cpu->exception_index = EXCP_INTERRUPT;",
"cpu_loop_exit(cpu);",
"}",
"spin_lock(&tcg_ctx.tb_ctx.tb_lock);",
"have_tb_lock = true;",
"tb = tb_find_fast(VAR_0);",
"if (tcg_ctx.tb_ctx.tb_invalidated_flag) {",
"next_tb = 0;",
"tcg_ctx.tb_ctx.tb_invalidated_flag = 0;",
"}",
"if (qemu_loglevel_mask(CPU_LOG_EXEC)) {",
"qemu_log(\"Trace %p [\" TARGET_FMT_lx \"] %s\\n\",\ntb->tc_ptr, tb->pc, lookup_symbol(tb->pc));",
"}",
"if (next_tb != 0 && tb->page_addr[1] == -1) {",
"tb_add_jump((TranslationBlock *)(next_tb & ~TB_EXIT_MASK),\nnext_tb & TB_EXIT_MASK, tb);",
"}",
"have_tb_lock = false;",
"spin_unlock(&tcg_ctx.tb_ctx.tb_lock);",
"cpu->current_tb = tb;",
"barrier();",
"if (likely(!cpu->exit_request)) {",
"tc_ptr = tb->tc_ptr;",
"next_tb = cpu_tb_exec(cpu, tc_ptr);",
"switch (next_tb & TB_EXIT_MASK) {",
"case TB_EXIT_REQUESTED:\ntb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);",
"next_tb = 0;",
"break;",
"case TB_EXIT_ICOUNT_EXPIRED:\n{",
"int VAR_3;",
"tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);",
"VAR_3 = cpu->icount_decr.u32;",
"if (cpu->icount_extra && VAR_3 >= 0) {",
"cpu->icount_extra += VAR_3;",
"if (cpu->icount_extra > 0xffff) {",
"VAR_3 = 0xffff;",
"} else {",
"VAR_3 = cpu->icount_extra;",
"}",
"cpu->icount_extra -= VAR_3;",
"cpu->icount_decr.u16.low = VAR_3;",
"} else {",
"if (VAR_3 > 0) {",
"cpu_exec_nocache(VAR_0, VAR_3, tb);",
"}",
"cpu->exception_index = EXCP_INTERRUPT;",
"next_tb = 0;",
"cpu_loop_exit(cpu);",
"}",
"break;",
"}",
"default:\nbreak;",
"}",
"}",
"cpu->current_tb = NULL;",
"}",
"} else {",
"cpu = current_cpu;",
"VAR_0 = cpu->env_ptr;",
"#if !(defined(CONFIG_USER_ONLY) && \\\n(defined(TARGET_M68K) || defined(TARGET_PPC) || defined(TARGET_S390X)))\ncc = CPU_GET_CLASS(cpu);",
"#endif\n#ifdef TARGET_I386\nx86_cpu = X86_CPU(cpu);",
"#endif\nif (have_tb_lock) {",
"spin_unlock(&tcg_ctx.tb_ctx.tb_lock);",
"have_tb_lock = false;",
"}",
"}",
"}",
"#if defined(TARGET_I386)\nVAR_0->eflags = VAR_0->eflags | cpu_cc_compute_all(VAR_0, CC_OP)\n| (VAR_0->df & DF_MASK);",
"#elif defined(TARGET_ARM)\n#elif defined(TARGET_UNICORE32)\n#elif defined(TARGET_SPARC)\n#elif defined(TARGET_PPC)\n#elif defined(TARGET_LM32)\n#elif defined(TARGET_M68K)\ncpu_m68k_flush_flags(VAR_0, VAR_0->cc_op);",
"VAR_0->cc_op = CC_OP_FLAGS;",
"VAR_0->sr = (VAR_0->sr & 0xffe0)\n| VAR_0->cc_dest | (VAR_0->cc_x << 4);",
"#elif defined(TARGET_MICROBLAZE)\n#elif defined(TARGET_MIPS)\n#elif defined(TARGET_MOXIE)\n#elif defined(TARGET_OPENRISC)\n#elif defined(TARGET_SH4)\n#elif defined(TARGET_ALPHA)\n#elif defined(TARGET_CRIS)\n#elif defined(TARGET_S390X)\n#elif defined(TARGET_XTENSA)\n#else\n#error unsupported target CPU\n#endif\ncurrent_cpu = NULL;",
"return 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77,
81
],
[
83
],
[
85
],
[
87
],
[
89,
91,
93
],
[
95
],
[
97
],
[
99,
101,
103,
105,
107
],
[
109,
111,
113,
115,
117,
119,
121,
123,
125,
129,
131,
133,
135
],
[
141
],
[
143
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
173,
175
],
[
177,
179
],
[
181
],
[
183,
185
],
[
187
],
[
189,
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223,
225,
227,
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241,
243,
245,
247
],
[
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
],
[
341
],
[
343,
345
],
[
347,
349
],
[
351
],
[
355,
357
],
[
359,
361,
363,
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375,
377
],
[
379
],
[
381,
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403,
405,
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417,
419,
421,
423,
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435,
437,
439
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453,
455
],
[
457
],
[
459,
461
],
[
463
],
[
465
],
[
467,
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487,
489
],
[
491,
493
],
[
495
],
[
497
],
[
501,
503,
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519,
521,
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
551,
553,
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565,
567,
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579,
581
],
[
583
],
[
585
],
[
587
],
[
589,
591
],
[
593
],
[
597
],
[
599,
601
],
[
603
],
[
605
],
[
609,
611
],
[
613
],
[
615
],
[
619,
621
],
[
623
],
[
625
],
[
629,
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653,
655,
657,
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
693
],
[
695,
697,
699,
701
],
[
713
],
[
715
],
[
717
],
[
719
],
[
721,
723,
725
],
[
727
],
[
729
],
[
731
],
[
733,
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
745,
751
],
[
753
],
[
759
],
[
761
],
[
763
],
[
765
],
[
767
],
[
769
],
[
771
],
[
773
],
[
775
],
[
777
],
[
779
],
[
785
],
[
793
],
[
795
],
[
797
],
[
799
],
[
801,
803
],
[
805
],
[
813
],
[
815,
817
],
[
819
],
[
821
],
[
823
],
[
835
],
[
837
],
[
839
],
[
841
],
[
845
],
[
847
],
[
849,
865
],
[
867
],
[
869
],
[
871,
873
],
[
877
],
[
879
],
[
881
],
[
883
],
[
887
],
[
889
],
[
891
],
[
893
],
[
895
],
[
897
],
[
899
],
[
901
],
[
903
],
[
905
],
[
909
],
[
911
],
[
913
],
[
915
],
[
917
],
[
919
],
[
921
],
[
923
],
[
925,
927
],
[
929
],
[
931
],
[
933
],
[
939
],
[
941
],
[
947
],
[
949
],
[
951,
953,
955
],
[
957,
959,
961
],
[
963,
965
],
[
967
],
[
969
],
[
971
],
[
973
],
[
975
],
[
981,
985,
987
],
[
989,
993,
995,
997,
999,
1001,
1003
],
[
1005
],
[
1007,
1009
],
[
1011,
1013,
1015,
1017,
1019,
1021,
1023,
1025,
1027,
1031,
1033,
1035,
1041
],
[
1043
],
[
1045
]
] |
19,402 | static int bdrv_can_snapshot(BlockDriverState *bs)
{
return (bs &&
!bdrv_is_removable(bs) &&
!bdrv_is_read_only(bs));
}
| true | qemu | feeee5aca765606818e00f5a19d19f141f4ae365 | static int bdrv_can_snapshot(BlockDriverState *bs)
{
return (bs &&
!bdrv_is_removable(bs) &&
!bdrv_is_read_only(bs));
}
| {
"code": [
"static int bdrv_can_snapshot(BlockDriverState *bs)",
" return (bs &&",
" !bdrv_is_removable(bs) &&",
" !bdrv_is_read_only(bs));",
" return (bs &&",
" !bdrv_is_removable(bs) &&",
" !bdrv_is_read_only(bs));"
],
"line_no": [
1,
5,
7,
9,
5,
7,
9
]
} | static int FUNC_0(BlockDriverState *VAR_0)
{
return (VAR_0 &&
!bdrv_is_removable(VAR_0) &&
!bdrv_is_read_only(VAR_0));
}
| [
"static int FUNC_0(BlockDriverState *VAR_0)\n{",
"return (VAR_0 &&\n!bdrv_is_removable(VAR_0) &&\n!bdrv_is_read_only(VAR_0));",
"}"
] | [
1,
1,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11
]
] |
19,404 | int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
{
// "type=name:device,key=value,key2=value2"
// "type:device,key=value,key2=value2"
// -> av_hwdevice_ctx_create()
// "type=name@name"
// "type@name"
// -> av_hwdevice_ctx_create_derived()
AVDictionary *options = NULL;
char *type_name = NULL, *name = NULL, *device = NULL;
enum AVHWDeviceType type;
HWDevice *dev, *src;
AVBufferRef *device_ref = NULL;
int err;
const char *errmsg, *p, *q;
size_t k;
k = strcspn(arg, ":=@");
p = arg + k;
type_name = av_strndup(arg, k);
if (!type_name) {
err = AVERROR(ENOMEM);
goto fail;
}
type = av_hwdevice_find_type_by_name(type_name);
if (type == AV_HWDEVICE_TYPE_NONE) {
errmsg = "unknown device type";
goto invalid;
}
if (*p == '=') {
k = strcspn(p + 1, ":@");
name = av_strndup(p + 1, k);
if (!name) {
err = AVERROR(ENOMEM);
goto fail;
}
if (hw_device_get_by_name(name)) {
errmsg = "named device already exists";
goto invalid;
}
p += 1 + k;
} else {
// Give the device an automatic name of the form "type%d".
// We arbitrarily limit at 1000 anonymous devices of the same
// type - there is probably something else very wrong if you
// get to this limit.
size_t index_pos;
int index, index_limit = 1000;
index_pos = strlen(type_name);
name = av_malloc(index_pos + 4);
if (!name) {
err = AVERROR(ENOMEM);
goto fail;
}
for (index = 0; index < index_limit; index++) {
snprintf(name, index_pos + 4, "%s%d", type_name, index);
if (!hw_device_get_by_name(name))
break;
}
if (index >= index_limit) {
errmsg = "too many devices";
goto invalid;
}
}
if (!*p) {
// New device with no parameters.
err = av_hwdevice_ctx_create(&device_ref, type,
NULL, NULL, 0);
if (err < 0)
goto fail;
} else if (*p == ':') {
// New device with some parameters.
++p;
q = strchr(p, ',');
if (q) {
device = av_strndup(p, q - p);
if (!device) {
err = AVERROR(ENOMEM);
goto fail;
}
err = av_dict_parse_string(&options, q + 1, "=", ",", 0);
if (err < 0) {
errmsg = "failed to parse options";
goto invalid;
}
}
err = av_hwdevice_ctx_create(&device_ref, type,
device ? device : p, options, 0);
if (err < 0)
goto fail;
} else if (*p == '@') {
// Derive from existing device.
src = hw_device_get_by_name(p + 1);
if (!src) {
errmsg = "invalid source device name";
goto invalid;
}
err = av_hwdevice_ctx_create_derived(&device_ref, type,
src->device_ref, 0);
if (err < 0)
goto fail;
} else {
errmsg = "parse error";
goto invalid;
}
dev = hw_device_add();
if (!dev) {
err = AVERROR(ENOMEM);
goto fail;
}
dev->name = name;
dev->type = type;
dev->device_ref = device_ref;
if (dev_out)
*dev_out = dev;
name = NULL;
err = 0;
done:
av_freep(&type_name);
av_freep(&name);
av_freep(&device);
av_dict_free(&options);
return err;
invalid:
av_log(NULL, AV_LOG_ERROR,
"Invalid device specification \"%s\": %s\n", arg, errmsg);
err = AVERROR(EINVAL);
goto done;
fail:
av_log(NULL, AV_LOG_ERROR,
"Device creation failed: %d.\n", err);
av_buffer_unref(&device_ref);
goto done;
}
| false | FFmpeg | b0cd14fb1dab4b044f7fe6b53ac635409849de77 | int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
{
AVDictionary *options = NULL;
char *type_name = NULL, *name = NULL, *device = NULL;
enum AVHWDeviceType type;
HWDevice *dev, *src;
AVBufferRef *device_ref = NULL;
int err;
const char *errmsg, *p, *q;
size_t k;
k = strcspn(arg, ":=@");
p = arg + k;
type_name = av_strndup(arg, k);
if (!type_name) {
err = AVERROR(ENOMEM);
goto fail;
}
type = av_hwdevice_find_type_by_name(type_name);
if (type == AV_HWDEVICE_TYPE_NONE) {
errmsg = "unknown device type";
goto invalid;
}
if (*p == '=') {
k = strcspn(p + 1, ":@");
name = av_strndup(p + 1, k);
if (!name) {
err = AVERROR(ENOMEM);
goto fail;
}
if (hw_device_get_by_name(name)) {
errmsg = "named device already exists";
goto invalid;
}
p += 1 + k;
} else {
size_t index_pos;
int index, index_limit = 1000;
index_pos = strlen(type_name);
name = av_malloc(index_pos + 4);
if (!name) {
err = AVERROR(ENOMEM);
goto fail;
}
for (index = 0; index < index_limit; index++) {
snprintf(name, index_pos + 4, "%s%d", type_name, index);
if (!hw_device_get_by_name(name))
break;
}
if (index >= index_limit) {
errmsg = "too many devices";
goto invalid;
}
}
if (!*p) {
err = av_hwdevice_ctx_create(&device_ref, type,
NULL, NULL, 0);
if (err < 0)
goto fail;
} else if (*p == ':') {
++p;
q = strchr(p, ',');
if (q) {
device = av_strndup(p, q - p);
if (!device) {
err = AVERROR(ENOMEM);
goto fail;
}
err = av_dict_parse_string(&options, q + 1, "=", ",", 0);
if (err < 0) {
errmsg = "failed to parse options";
goto invalid;
}
}
err = av_hwdevice_ctx_create(&device_ref, type,
device ? device : p, options, 0);
if (err < 0)
goto fail;
} else if (*p == '@') {
src = hw_device_get_by_name(p + 1);
if (!src) {
errmsg = "invalid source device name";
goto invalid;
}
err = av_hwdevice_ctx_create_derived(&device_ref, type,
src->device_ref, 0);
if (err < 0)
goto fail;
} else {
errmsg = "parse error";
goto invalid;
}
dev = hw_device_add();
if (!dev) {
err = AVERROR(ENOMEM);
goto fail;
}
dev->name = name;
dev->type = type;
dev->device_ref = device_ref;
if (dev_out)
*dev_out = dev;
name = NULL;
err = 0;
done:
av_freep(&type_name);
av_freep(&name);
av_freep(&device);
av_dict_free(&options);
return err;
invalid:
av_log(NULL, AV_LOG_ERROR,
"Invalid device specification \"%s\": %s\n", arg, errmsg);
err = AVERROR(EINVAL);
goto done;
fail:
av_log(NULL, AV_LOG_ERROR,
"Device creation failed: %d.\n", err);
av_buffer_unref(&device_ref);
goto done;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const char *VAR_0, HWDevice **VAR_1)
{
AVDictionary *options = NULL;
char *VAR_2 = NULL, *VAR_3 = NULL, *VAR_4 = NULL;
enum AVHWDeviceType VAR_5;
HWDevice *dev, *src;
AVBufferRef *device_ref = NULL;
int VAR_6;
const char *VAR_7, *VAR_8, *VAR_9;
size_t k;
k = strcspn(VAR_0, ":=@");
VAR_8 = VAR_0 + k;
VAR_2 = av_strndup(VAR_0, k);
if (!VAR_2) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
VAR_5 = av_hwdevice_find_type_by_name(VAR_2);
if (VAR_5 == AV_HWDEVICE_TYPE_NONE) {
VAR_7 = "unknown VAR_4 VAR_5";
goto invalid;
}
if (*VAR_8 == '=') {
k = strcspn(VAR_8 + 1, ":@");
VAR_3 = av_strndup(VAR_8 + 1, k);
if (!VAR_3) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
if (hw_device_get_by_name(VAR_3)) {
VAR_7 = "named VAR_4 already exists";
goto invalid;
}
VAR_8 += 1 + k;
} else {
size_t index_pos;
int VAR_10, VAR_11 = 1000;
index_pos = strlen(VAR_2);
VAR_3 = av_malloc(index_pos + 4);
if (!VAR_3) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
for (VAR_10 = 0; VAR_10 < VAR_11; VAR_10++) {
snprintf(VAR_3, index_pos + 4, "%s%d", VAR_2, VAR_10);
if (!hw_device_get_by_name(VAR_3))
break;
}
if (VAR_10 >= VAR_11) {
VAR_7 = "too many devices";
goto invalid;
}
}
if (!*VAR_8) {
VAR_6 = av_hwdevice_ctx_create(&device_ref, VAR_5,
NULL, NULL, 0);
if (VAR_6 < 0)
goto fail;
} else if (*VAR_8 == ':') {
++VAR_8;
VAR_9 = strchr(VAR_8, ',');
if (VAR_9) {
VAR_4 = av_strndup(VAR_8, VAR_9 - VAR_8);
if (!VAR_4) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
VAR_6 = av_dict_parse_string(&options, VAR_9 + 1, "=", ",", 0);
if (VAR_6 < 0) {
VAR_7 = "failed to parse options";
goto invalid;
}
}
VAR_6 = av_hwdevice_ctx_create(&device_ref, VAR_5,
VAR_4 ? VAR_4 : VAR_8, options, 0);
if (VAR_6 < 0)
goto fail;
} else if (*VAR_8 == '@') {
src = hw_device_get_by_name(VAR_8 + 1);
if (!src) {
VAR_7 = "invalid source VAR_4 VAR_3";
goto invalid;
}
VAR_6 = av_hwdevice_ctx_create_derived(&device_ref, VAR_5,
src->device_ref, 0);
if (VAR_6 < 0)
goto fail;
} else {
VAR_7 = "parse error";
goto invalid;
}
dev = hw_device_add();
if (!dev) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
dev->VAR_3 = VAR_3;
dev->VAR_5 = VAR_5;
dev->device_ref = device_ref;
if (VAR_1)
*VAR_1 = dev;
VAR_3 = NULL;
VAR_6 = 0;
done:
av_freep(&VAR_2);
av_freep(&VAR_3);
av_freep(&VAR_4);
av_dict_free(&options);
return VAR_6;
invalid:
av_log(NULL, AV_LOG_ERROR,
"Invalid VAR_4 specification \"%s\": %s\n", VAR_0, VAR_7);
VAR_6 = AVERROR(EINVAL);
goto done;
fail:
av_log(NULL, AV_LOG_ERROR,
"Device creation failed: %d.\n", VAR_6);
av_buffer_unref(&device_ref);
goto done;
}
| [
"int FUNC_0(const char *VAR_0, HWDevice **VAR_1)\n{",
"AVDictionary *options = NULL;",
"char *VAR_2 = NULL, *VAR_3 = NULL, *VAR_4 = NULL;",
"enum AVHWDeviceType VAR_5;",
"HWDevice *dev, *src;",
"AVBufferRef *device_ref = NULL;",
"int VAR_6;",
"const char *VAR_7, *VAR_8, *VAR_9;",
"size_t k;",
"k = strcspn(VAR_0, \":=@\");",
"VAR_8 = VAR_0 + k;",
"VAR_2 = av_strndup(VAR_0, k);",
"if (!VAR_2) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_5 = av_hwdevice_find_type_by_name(VAR_2);",
"if (VAR_5 == AV_HWDEVICE_TYPE_NONE) {",
"VAR_7 = \"unknown VAR_4 VAR_5\";",
"goto invalid;",
"}",
"if (*VAR_8 == '=') {",
"k = strcspn(VAR_8 + 1, \":@\");",
"VAR_3 = av_strndup(VAR_8 + 1, k);",
"if (!VAR_3) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"if (hw_device_get_by_name(VAR_3)) {",
"VAR_7 = \"named VAR_4 already exists\";",
"goto invalid;",
"}",
"VAR_8 += 1 + k;",
"} else {",
"size_t index_pos;",
"int VAR_10, VAR_11 = 1000;",
"index_pos = strlen(VAR_2);",
"VAR_3 = av_malloc(index_pos + 4);",
"if (!VAR_3) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"for (VAR_10 = 0; VAR_10 < VAR_11; VAR_10++) {",
"snprintf(VAR_3, index_pos + 4, \"%s%d\", VAR_2, VAR_10);",
"if (!hw_device_get_by_name(VAR_3))\nbreak;",
"}",
"if (VAR_10 >= VAR_11) {",
"VAR_7 = \"too many devices\";",
"goto invalid;",
"}",
"}",
"if (!*VAR_8) {",
"VAR_6 = av_hwdevice_ctx_create(&device_ref, VAR_5,\nNULL, NULL, 0);",
"if (VAR_6 < 0)\ngoto fail;",
"} else if (*VAR_8 == ':') {",
"++VAR_8;",
"VAR_9 = strchr(VAR_8, ',');",
"if (VAR_9) {",
"VAR_4 = av_strndup(VAR_8, VAR_9 - VAR_8);",
"if (!VAR_4) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_6 = av_dict_parse_string(&options, VAR_9 + 1, \"=\", \",\", 0);",
"if (VAR_6 < 0) {",
"VAR_7 = \"failed to parse options\";",
"goto invalid;",
"}",
"}",
"VAR_6 = av_hwdevice_ctx_create(&device_ref, VAR_5,\nVAR_4 ? VAR_4 : VAR_8, options, 0);",
"if (VAR_6 < 0)\ngoto fail;",
"} else if (*VAR_8 == '@') {",
"src = hw_device_get_by_name(VAR_8 + 1);",
"if (!src) {",
"VAR_7 = \"invalid source VAR_4 VAR_3\";",
"goto invalid;",
"}",
"VAR_6 = av_hwdevice_ctx_create_derived(&device_ref, VAR_5,\nsrc->device_ref, 0);",
"if (VAR_6 < 0)\ngoto fail;",
"} else {",
"VAR_7 = \"parse error\";",
"goto invalid;",
"}",
"dev = hw_device_add();",
"if (!dev) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"dev->VAR_3 = VAR_3;",
"dev->VAR_5 = VAR_5;",
"dev->device_ref = device_ref;",
"if (VAR_1)\n*VAR_1 = dev;",
"VAR_3 = NULL;",
"VAR_6 = 0;",
"done:\nav_freep(&VAR_2);",
"av_freep(&VAR_3);",
"av_freep(&VAR_4);",
"av_dict_free(&options);",
"return VAR_6;",
"invalid:\nav_log(NULL, AV_LOG_ERROR,\n\"Invalid VAR_4 specification \\\"%s\\\": %s\\n\", VAR_0, VAR_7);",
"VAR_6 = AVERROR(EINVAL);",
"goto done;",
"fail:\nav_log(NULL, AV_LOG_ERROR,\n\"Device creation failed: %d.\\n\", VAR_6);",
"av_buffer_unref(&device_ref);",
"goto done;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
145,
147
],
[
149,
151
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189,
191
],
[
193,
195
],
[
199
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217,
219
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
255,
257
],
[
261
],
[
263
],
[
265,
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277,
279,
281
],
[
283
],
[
285
],
[
287,
289,
291
],
[
293
],
[
295
],
[
297
]
] |
19,405 | static void vaapi_encode_h264_write_pps(PutBitContext *pbc,
VAAPIEncodeContext *ctx)
{
VAEncPictureParameterBufferH264 *vpic = ctx->codec_picture_params;
VAAPIEncodeH264Context *priv = ctx->priv_data;
VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
vaapi_encode_h264_write_nal_header(pbc, NAL_PPS, 3);
ue(vpic_var(pic_parameter_set_id));
ue(vpic_var(seq_parameter_set_id));
u(1, vpic_field(entropy_coding_mode_flag));
u(1, mseq_var(bottom_field_pic_order_in_frame_present_flag));
ue(mseq_var(num_slice_groups_minus1));
if (mseq->num_slice_groups_minus1 > 0) {
ue(mseq_var(slice_group_map_type));
av_assert0(0 && "slice groups not supported");
}
ue(vpic_var(num_ref_idx_l0_active_minus1));
ue(vpic_var(num_ref_idx_l1_active_minus1));
u(1, vpic_field(weighted_pred_flag));
u(2, vpic_field(weighted_bipred_idc));
se(vpic->pic_init_qp - 26, pic_init_qp_minus26);
se(mseq_var(pic_init_qs_minus26));
se(vpic_var(chroma_qp_index_offset));
u(1, vpic_field(deblocking_filter_control_present_flag));
u(1, vpic_field(constrained_intra_pred_flag));
u(1, vpic_field(redundant_pic_cnt_present_flag));
u(1, vpic_field(transform_8x8_mode_flag));
u(1, vpic_field(pic_scaling_matrix_present_flag));
if (vpic->pic_fields.bits.pic_scaling_matrix_present_flag) {
av_assert0(0 && "scaling matrices not supported");
}
se(vpic_var(second_chroma_qp_index_offset));
vaapi_encode_h264_write_trailing_rbsp(pbc);
}
| false | FFmpeg | 5c2fb561d94fc51d76ab21d6f7cc5b6cc3aa599c | static void vaapi_encode_h264_write_pps(PutBitContext *pbc,
VAAPIEncodeContext *ctx)
{
VAEncPictureParameterBufferH264 *vpic = ctx->codec_picture_params;
VAAPIEncodeH264Context *priv = ctx->priv_data;
VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
vaapi_encode_h264_write_nal_header(pbc, NAL_PPS, 3);
ue(vpic_var(pic_parameter_set_id));
ue(vpic_var(seq_parameter_set_id));
u(1, vpic_field(entropy_coding_mode_flag));
u(1, mseq_var(bottom_field_pic_order_in_frame_present_flag));
ue(mseq_var(num_slice_groups_minus1));
if (mseq->num_slice_groups_minus1 > 0) {
ue(mseq_var(slice_group_map_type));
av_assert0(0 && "slice groups not supported");
}
ue(vpic_var(num_ref_idx_l0_active_minus1));
ue(vpic_var(num_ref_idx_l1_active_minus1));
u(1, vpic_field(weighted_pred_flag));
u(2, vpic_field(weighted_bipred_idc));
se(vpic->pic_init_qp - 26, pic_init_qp_minus26);
se(mseq_var(pic_init_qs_minus26));
se(vpic_var(chroma_qp_index_offset));
u(1, vpic_field(deblocking_filter_control_present_flag));
u(1, vpic_field(constrained_intra_pred_flag));
u(1, vpic_field(redundant_pic_cnt_present_flag));
u(1, vpic_field(transform_8x8_mode_flag));
u(1, vpic_field(pic_scaling_matrix_present_flag));
if (vpic->pic_fields.bits.pic_scaling_matrix_present_flag) {
av_assert0(0 && "scaling matrices not supported");
}
se(vpic_var(second_chroma_qp_index_offset));
vaapi_encode_h264_write_trailing_rbsp(pbc);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PutBitContext *VAR_0,
VAAPIEncodeContext *VAR_1)
{
VAEncPictureParameterBufferH264 *vpic = VAR_1->codec_picture_params;
VAAPIEncodeH264Context *priv = VAR_1->priv_data;
VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
vaapi_encode_h264_write_nal_header(VAR_0, NAL_PPS, 3);
ue(vpic_var(pic_parameter_set_id));
ue(vpic_var(seq_parameter_set_id));
u(1, vpic_field(entropy_coding_mode_flag));
u(1, mseq_var(bottom_field_pic_order_in_frame_present_flag));
ue(mseq_var(num_slice_groups_minus1));
if (mseq->num_slice_groups_minus1 > 0) {
ue(mseq_var(slice_group_map_type));
av_assert0(0 && "slice groups not supported");
}
ue(vpic_var(num_ref_idx_l0_active_minus1));
ue(vpic_var(num_ref_idx_l1_active_minus1));
u(1, vpic_field(weighted_pred_flag));
u(2, vpic_field(weighted_bipred_idc));
se(vpic->pic_init_qp - 26, pic_init_qp_minus26);
se(mseq_var(pic_init_qs_minus26));
se(vpic_var(chroma_qp_index_offset));
u(1, vpic_field(deblocking_filter_control_present_flag));
u(1, vpic_field(constrained_intra_pred_flag));
u(1, vpic_field(redundant_pic_cnt_present_flag));
u(1, vpic_field(transform_8x8_mode_flag));
u(1, vpic_field(pic_scaling_matrix_present_flag));
if (vpic->pic_fields.bits.pic_scaling_matrix_present_flag) {
av_assert0(0 && "scaling matrices not supported");
}
se(vpic_var(second_chroma_qp_index_offset));
vaapi_encode_h264_write_trailing_rbsp(VAR_0);
}
| [
"static void FUNC_0(PutBitContext *VAR_0,\nVAAPIEncodeContext *VAR_1)\n{",
"VAEncPictureParameterBufferH264 *vpic = VAR_1->codec_picture_params;",
"VAAPIEncodeH264Context *priv = VAR_1->priv_data;",
"VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;",
"vaapi_encode_h264_write_nal_header(VAR_0, NAL_PPS, 3);",
"ue(vpic_var(pic_parameter_set_id));",
"ue(vpic_var(seq_parameter_set_id));",
"u(1, vpic_field(entropy_coding_mode_flag));",
"u(1, mseq_var(bottom_field_pic_order_in_frame_present_flag));",
"ue(mseq_var(num_slice_groups_minus1));",
"if (mseq->num_slice_groups_minus1 > 0) {",
"ue(mseq_var(slice_group_map_type));",
"av_assert0(0 && \"slice groups not supported\");",
"}",
"ue(vpic_var(num_ref_idx_l0_active_minus1));",
"ue(vpic_var(num_ref_idx_l1_active_minus1));",
"u(1, vpic_field(weighted_pred_flag));",
"u(2, vpic_field(weighted_bipred_idc));",
"se(vpic->pic_init_qp - 26, pic_init_qp_minus26);",
"se(mseq_var(pic_init_qs_minus26));",
"se(vpic_var(chroma_qp_index_offset));",
"u(1, vpic_field(deblocking_filter_control_present_flag));",
"u(1, vpic_field(constrained_intra_pred_flag));",
"u(1, vpic_field(redundant_pic_cnt_present_flag));",
"u(1, vpic_field(transform_8x8_mode_flag));",
"u(1, vpic_field(pic_scaling_matrix_present_flag));",
"if (vpic->pic_fields.bits.pic_scaling_matrix_present_flag) {",
"av_assert0(0 && \"scaling matrices not supported\");",
"}",
"se(vpic_var(second_chroma_qp_index_offset));",
"vaapi_encode_h264_write_trailing_rbsp(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87
],
[
89
]
] |
19,407 | static av_always_inline int coeff_abs_level_remaining_decode(HEVCContext *s, int rc_rice_param)
{
int prefix = 0;
int suffix = 0;
int last_coeff_abs_level_remaining;
int i;
while (prefix < CABAC_MAX_BIN && get_cabac_bypass(&s->HEVClc->cc))
prefix++;
if (prefix == CABAC_MAX_BIN) {
av_log(s->avctx, AV_LOG_ERROR, "CABAC_MAX_BIN : %d\n", prefix);
return 0;
}
if (prefix < 3) {
for (i = 0; i < rc_rice_param; i++)
suffix = (suffix << 1) | get_cabac_bypass(&s->HEVClc->cc);
last_coeff_abs_level_remaining = (prefix << rc_rice_param) + suffix;
} else {
int prefix_minus3 = prefix - 3;
for (i = 0; i < prefix_minus3 + rc_rice_param; i++)
suffix = (suffix << 1) | get_cabac_bypass(&s->HEVClc->cc);
last_coeff_abs_level_remaining = (((1 << prefix_minus3) + 3 - 1)
<< rc_rice_param) + suffix;
}
return last_coeff_abs_level_remaining;
}
| false | FFmpeg | 94d4237a7a294ce80e1e577b38e9c93e8882aff9 | static av_always_inline int coeff_abs_level_remaining_decode(HEVCContext *s, int rc_rice_param)
{
int prefix = 0;
int suffix = 0;
int last_coeff_abs_level_remaining;
int i;
while (prefix < CABAC_MAX_BIN && get_cabac_bypass(&s->HEVClc->cc))
prefix++;
if (prefix == CABAC_MAX_BIN) {
av_log(s->avctx, AV_LOG_ERROR, "CABAC_MAX_BIN : %d\n", prefix);
return 0;
}
if (prefix < 3) {
for (i = 0; i < rc_rice_param; i++)
suffix = (suffix << 1) | get_cabac_bypass(&s->HEVClc->cc);
last_coeff_abs_level_remaining = (prefix << rc_rice_param) + suffix;
} else {
int prefix_minus3 = prefix - 3;
for (i = 0; i < prefix_minus3 + rc_rice_param; i++)
suffix = (suffix << 1) | get_cabac_bypass(&s->HEVClc->cc);
last_coeff_abs_level_remaining = (((1 << prefix_minus3) + 3 - 1)
<< rc_rice_param) + suffix;
}
return last_coeff_abs_level_remaining;
}
| {
"code": [],
"line_no": []
} | static av_always_inline int FUNC_0(HEVCContext *s, int rc_rice_param)
{
int VAR_0 = 0;
int VAR_1 = 0;
int VAR_2;
int VAR_3;
while (VAR_0 < CABAC_MAX_BIN && get_cabac_bypass(&s->HEVClc->cc))
VAR_0++;
if (VAR_0 == CABAC_MAX_BIN) {
av_log(s->avctx, AV_LOG_ERROR, "CABAC_MAX_BIN : %d\n", VAR_0);
return 0;
}
if (VAR_0 < 3) {
for (VAR_3 = 0; VAR_3 < rc_rice_param; VAR_3++)
VAR_1 = (VAR_1 << 1) | get_cabac_bypass(&s->HEVClc->cc);
VAR_2 = (VAR_0 << rc_rice_param) + VAR_1;
} else {
int VAR_4 = VAR_0 - 3;
for (VAR_3 = 0; VAR_3 < VAR_4 + rc_rice_param; VAR_3++)
VAR_1 = (VAR_1 << 1) | get_cabac_bypass(&s->HEVClc->cc);
VAR_2 = (((1 << VAR_4) + 3 - 1)
<< rc_rice_param) + VAR_1;
}
return VAR_2;
}
| [
"static av_always_inline int FUNC_0(HEVCContext *s, int rc_rice_param)\n{",
"int VAR_0 = 0;",
"int VAR_1 = 0;",
"int VAR_2;",
"int VAR_3;",
"while (VAR_0 < CABAC_MAX_BIN && get_cabac_bypass(&s->HEVClc->cc))\nVAR_0++;",
"if (VAR_0 == CABAC_MAX_BIN) {",
"av_log(s->avctx, AV_LOG_ERROR, \"CABAC_MAX_BIN : %d\\n\", VAR_0);",
"return 0;",
"}",
"if (VAR_0 < 3) {",
"for (VAR_3 = 0; VAR_3 < rc_rice_param; VAR_3++)",
"VAR_1 = (VAR_1 << 1) | get_cabac_bypass(&s->HEVClc->cc);",
"VAR_2 = (VAR_0 << rc_rice_param) + VAR_1;",
"} else {",
"int VAR_4 = VAR_0 - 3;",
"for (VAR_3 = 0; VAR_3 < VAR_4 + rc_rice_param; VAR_3++)",
"VAR_1 = (VAR_1 << 1) | get_cabac_bypass(&s->HEVClc->cc);",
"VAR_2 = (((1 << VAR_4) + 3 - 1)\n<< rc_rice_param) + VAR_1;",
"}",
"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
] | [
[
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
]
] |
19,409 | static void float_number(void)
{
int i;
struct {
const char *encoded;
double decoded;
int skip;
} test_cases[] = {
{ "32.43", 32.43 },
{ "0.222", 0.222 },
{ "-32.12313", -32.12313 },
{ "-32.20e-10", -32.20e-10, .skip = 1 },
{ },
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QFloat *qfloat;
obj = qobject_from_json(test_cases[i].encoded, NULL);
qfloat = qobject_to_qfloat(obj);
g_assert(qfloat);
g_assert(qfloat_get_double(qfloat) == test_cases[i].decoded);
if (test_cases[i].skip == 0) {
QString *str;
str = qobject_to_json(obj);
g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0);
QDECREF(str);
}
QDECREF(qfloat);
}
}
| true | qemu | aec4b054ea36c53c8b887da99f20010133b84378 | static void float_number(void)
{
int i;
struct {
const char *encoded;
double decoded;
int skip;
} test_cases[] = {
{ "32.43", 32.43 },
{ "0.222", 0.222 },
{ "-32.12313", -32.12313 },
{ "-32.20e-10", -32.20e-10, .skip = 1 },
{ },
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QFloat *qfloat;
obj = qobject_from_json(test_cases[i].encoded, NULL);
qfloat = qobject_to_qfloat(obj);
g_assert(qfloat);
g_assert(qfloat_get_double(qfloat) == test_cases[i].decoded);
if (test_cases[i].skip == 0) {
QString *str;
str = qobject_to_json(obj);
g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0);
QDECREF(str);
}
QDECREF(qfloat);
}
}
| {
"code": [
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);"
],
"line_no": [
39,
39,
39,
39,
39,
39,
39
]
} | static void FUNC_0(void)
{
int VAR_0;
struct {
const char *encoded;
double decoded;
int skip;
} VAR_1[] = {
{ "32.43", 32.43 },
{ "0.222", 0.222 },
{ "-32.12313", -32.12313 },
{ "-32.20e-10", -32.20e-10, .skip = 1 },
{ },
};
for (VAR_0 = 0; VAR_1[VAR_0].encoded; VAR_0++) {
QObject *obj;
QFloat *qfloat;
obj = qobject_from_json(VAR_1[VAR_0].encoded, NULL);
qfloat = qobject_to_qfloat(obj);
g_assert(qfloat);
g_assert(qfloat_get_double(qfloat) == VAR_1[VAR_0].decoded);
if (VAR_1[VAR_0].skip == 0) {
QString *str;
str = qobject_to_json(obj);
g_assert(strcmp(qstring_get_str(str), VAR_1[VAR_0].encoded) == 0);
QDECREF(str);
}
QDECREF(qfloat);
}
}
| [
"static void FUNC_0(void)\n{",
"int VAR_0;",
"struct {",
"const char *encoded;",
"double decoded;",
"int skip;",
"} VAR_1[] = {",
"{ \"32.43\", 32.43 },",
"{ \"0.222\", 0.222 },",
"{ \"-32.12313\", -32.12313 },",
"{ \"-32.20e-10\", -32.20e-10, .skip = 1 },",
"{ },",
"};",
"for (VAR_0 = 0; VAR_1[VAR_0].encoded; VAR_0++) {",
"QObject *obj;",
"QFloat *qfloat;",
"obj = qobject_from_json(VAR_1[VAR_0].encoded, NULL);",
"qfloat = qobject_to_qfloat(obj);",
"g_assert(qfloat);",
"g_assert(qfloat_get_double(qfloat) == VAR_1[VAR_0].decoded);",
"if (VAR_1[VAR_0].skip == 0) {",
"QString *str;",
"str = qobject_to_json(obj);",
"g_assert(strcmp(qstring_get_str(str), VAR_1[VAR_0].encoded) == 0);",
"QDECREF(str);",
"}",
"QDECREF(qfloat);",
"}",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
]
] |
19,410 | AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name)
{
int i;
if(!name)
return NULL;
for(i = 0; i < graph->filter_count; i ++)
if(graph->filters[i]->name && !strcmp(name, graph->filters[i]->name))
return graph->filters[i];
return NULL;
}
| false | FFmpeg | e1a43a414677258b1e01d3f9a8f40bfc74be4223 | AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name)
{
int i;
if(!name)
return NULL;
for(i = 0; i < graph->filter_count; i ++)
if(graph->filters[i]->name && !strcmp(name, graph->filters[i]->name))
return graph->filters[i];
return NULL;
}
| {
"code": [],
"line_no": []
} | AVFilterContext *FUNC_0(AVFilterGraph *graph, char *name)
{
int VAR_0;
if(!name)
return NULL;
for(VAR_0 = 0; VAR_0 < graph->filter_count; VAR_0 ++)
if(graph->filters[VAR_0]->name && !strcmp(name, graph->filters[VAR_0]->name))
return graph->filters[VAR_0];
return NULL;
}
| [
"AVFilterContext *FUNC_0(AVFilterGraph *graph, char *name)\n{",
"int VAR_0;",
"if(!name)\nreturn NULL;",
"for(VAR_0 = 0; VAR_0 < graph->filter_count; VAR_0 ++)",
"if(graph->filters[VAR_0]->name && !strcmp(name, graph->filters[VAR_0]->name))\nreturn graph->filters[VAR_0];",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
17,
19
],
[
23
],
[
25
]
] |
19,412 | static int mirror_do_read(MirrorBlockJob *s, int64_t sector_num,
int nb_sectors)
{
BlockBackend *source = s->common.blk;
int sectors_per_chunk, nb_chunks;
int ret = nb_sectors;
MirrorOp *op;
sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;
/* We can only handle as much as buf_size at a time. */
nb_sectors = MIN(s->buf_size >> BDRV_SECTOR_BITS, nb_sectors);
assert(nb_sectors);
if (s->cow_bitmap) {
ret += mirror_cow_align(s, §or_num, &nb_sectors);
}
assert(nb_sectors << BDRV_SECTOR_BITS <= s->buf_size);
/* The sector range must meet granularity because:
* 1) Caller passes in aligned values;
* 2) mirror_cow_align is used only when target cluster is larger. */
assert(!(sector_num % sectors_per_chunk));
nb_chunks = DIV_ROUND_UP(nb_sectors, sectors_per_chunk);
while (s->buf_free_count < nb_chunks) {
trace_mirror_yield_in_flight(s, sector_num, s->in_flight);
mirror_wait_for_io(s);
}
/* Allocate a MirrorOp that is used as an AIO callback. */
op = g_new(MirrorOp, 1);
op->s = s;
op->sector_num = sector_num;
op->nb_sectors = nb_sectors;
/* Now make a QEMUIOVector taking enough granularity-sized chunks
* from s->buf_free.
*/
qemu_iovec_init(&op->qiov, nb_chunks);
while (nb_chunks-- > 0) {
MirrorBuffer *buf = QSIMPLEQ_FIRST(&s->buf_free);
size_t remaining = nb_sectors * BDRV_SECTOR_SIZE - op->qiov.size;
QSIMPLEQ_REMOVE_HEAD(&s->buf_free, next);
s->buf_free_count--;
qemu_iovec_add(&op->qiov, buf, MIN(s->granularity, remaining));
}
/* Copy the dirty cluster. */
s->in_flight++;
s->sectors_in_flight += nb_sectors;
trace_mirror_one_iteration(s, sector_num, nb_sectors);
blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov,
nb_sectors * BDRV_SECTOR_SIZE,
mirror_read_complete, op);
return ret;
}
| true | qemu | 73698c30caaf16e990b8b2e6e7bc64928947e65e | static int mirror_do_read(MirrorBlockJob *s, int64_t sector_num,
int nb_sectors)
{
BlockBackend *source = s->common.blk;
int sectors_per_chunk, nb_chunks;
int ret = nb_sectors;
MirrorOp *op;
sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;
nb_sectors = MIN(s->buf_size >> BDRV_SECTOR_BITS, nb_sectors);
assert(nb_sectors);
if (s->cow_bitmap) {
ret += mirror_cow_align(s, §or_num, &nb_sectors);
}
assert(nb_sectors << BDRV_SECTOR_BITS <= s->buf_size);
assert(!(sector_num % sectors_per_chunk));
nb_chunks = DIV_ROUND_UP(nb_sectors, sectors_per_chunk);
while (s->buf_free_count < nb_chunks) {
trace_mirror_yield_in_flight(s, sector_num, s->in_flight);
mirror_wait_for_io(s);
}
op = g_new(MirrorOp, 1);
op->s = s;
op->sector_num = sector_num;
op->nb_sectors = nb_sectors;
qemu_iovec_init(&op->qiov, nb_chunks);
while (nb_chunks-- > 0) {
MirrorBuffer *buf = QSIMPLEQ_FIRST(&s->buf_free);
size_t remaining = nb_sectors * BDRV_SECTOR_SIZE - op->qiov.size;
QSIMPLEQ_REMOVE_HEAD(&s->buf_free, next);
s->buf_free_count--;
qemu_iovec_add(&op->qiov, buf, MIN(s->granularity, remaining));
}
s->in_flight++;
s->sectors_in_flight += nb_sectors;
trace_mirror_one_iteration(s, sector_num, nb_sectors);
blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov,
nb_sectors * BDRV_SECTOR_SIZE,
mirror_read_complete, op);
return ret;
}
| {
"code": [
" blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov,",
" nb_sectors * BDRV_SECTOR_SIZE,"
],
"line_no": [
107,
109
]
} | static int FUNC_0(MirrorBlockJob *VAR_0, int64_t VAR_1,
int VAR_2)
{
BlockBackend *source = VAR_0->common.blk;
int VAR_3, VAR_4;
int VAR_5 = VAR_2;
MirrorOp *op;
VAR_3 = VAR_0->granularity >> BDRV_SECTOR_BITS;
VAR_2 = MIN(VAR_0->buf_size >> BDRV_SECTOR_BITS, VAR_2);
assert(VAR_2);
if (VAR_0->cow_bitmap) {
VAR_5 += mirror_cow_align(VAR_0, &VAR_1, &VAR_2);
}
assert(VAR_2 << BDRV_SECTOR_BITS <= VAR_0->buf_size);
assert(!(VAR_1 % VAR_3));
VAR_4 = DIV_ROUND_UP(VAR_2, VAR_3);
while (VAR_0->buf_free_count < VAR_4) {
trace_mirror_yield_in_flight(VAR_0, VAR_1, VAR_0->in_flight);
mirror_wait_for_io(VAR_0);
}
op = g_new(MirrorOp, 1);
op->VAR_0 = VAR_0;
op->VAR_1 = VAR_1;
op->VAR_2 = VAR_2;
qemu_iovec_init(&op->qiov, VAR_4);
while (VAR_4-- > 0) {
MirrorBuffer *buf = QSIMPLEQ_FIRST(&VAR_0->buf_free);
size_t remaining = VAR_2 * BDRV_SECTOR_SIZE - op->qiov.size;
QSIMPLEQ_REMOVE_HEAD(&VAR_0->buf_free, next);
VAR_0->buf_free_count--;
qemu_iovec_add(&op->qiov, buf, MIN(VAR_0->granularity, remaining));
}
VAR_0->in_flight++;
VAR_0->sectors_in_flight += VAR_2;
trace_mirror_one_iteration(VAR_0, VAR_1, VAR_2);
blk_aio_preadv(source, VAR_1 * BDRV_SECTOR_SIZE, &op->qiov,
VAR_2 * BDRV_SECTOR_SIZE,
mirror_read_complete, op);
return VAR_5;
}
| [
"static int FUNC_0(MirrorBlockJob *VAR_0, int64_t VAR_1,\nint VAR_2)\n{",
"BlockBackend *source = VAR_0->common.blk;",
"int VAR_3, VAR_4;",
"int VAR_5 = VAR_2;",
"MirrorOp *op;",
"VAR_3 = VAR_0->granularity >> BDRV_SECTOR_BITS;",
"VAR_2 = MIN(VAR_0->buf_size >> BDRV_SECTOR_BITS, VAR_2);",
"assert(VAR_2);",
"if (VAR_0->cow_bitmap) {",
"VAR_5 += mirror_cow_align(VAR_0, &VAR_1, &VAR_2);",
"}",
"assert(VAR_2 << BDRV_SECTOR_BITS <= VAR_0->buf_size);",
"assert(!(VAR_1 % VAR_3));",
"VAR_4 = DIV_ROUND_UP(VAR_2, VAR_3);",
"while (VAR_0->buf_free_count < VAR_4) {",
"trace_mirror_yield_in_flight(VAR_0, VAR_1, VAR_0->in_flight);",
"mirror_wait_for_io(VAR_0);",
"}",
"op = g_new(MirrorOp, 1);",
"op->VAR_0 = VAR_0;",
"op->VAR_1 = VAR_1;",
"op->VAR_2 = VAR_2;",
"qemu_iovec_init(&op->qiov, VAR_4);",
"while (VAR_4-- > 0) {",
"MirrorBuffer *buf = QSIMPLEQ_FIRST(&VAR_0->buf_free);",
"size_t remaining = VAR_2 * BDRV_SECTOR_SIZE - op->qiov.size;",
"QSIMPLEQ_REMOVE_HEAD(&VAR_0->buf_free, next);",
"VAR_0->buf_free_count--;",
"qemu_iovec_add(&op->qiov, buf, MIN(VAR_0->granularity, remaining));",
"}",
"VAR_0->in_flight++;",
"VAR_0->sectors_in_flight += VAR_2;",
"trace_mirror_one_iteration(VAR_0, VAR_1, VAR_2);",
"blk_aio_preadv(source, VAR_1 * BDRV_SECTOR_SIZE, &op->qiov,\nVAR_2 * BDRV_SECTOR_SIZE,\nmirror_read_complete, op);",
"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,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
61
],
[
63
],
[
65
],
[
67
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
99
],
[
101
],
[
103
],
[
107,
109,
111
],
[
113
],
[
115
]
] |
19,413 | static void pred_temp_direct_motion(H264Context * const h, int *mb_type){
MpegEncContext * const s = &h->s;
int b8_stride = 2;
int b4_stride = h->b_stride;
int mb_xy = h->mb_xy, mb_y = s->mb_y;
int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1;
const int is_b8x8 = IS_8X8(*mb_type);
unsigned int sub_mb_type;
int i8, i4;
assert(h->ref_list[1][0].f.reference & 3);
await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type));
if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
mb_y = (s->mb_y&~1) + h->col_parity;
mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride;
b8_stride = 0;
}else{
mb_y += h->col_fieldoff;
mb_xy += s->mb_stride*h->col_fieldoff; // non zero for FL -> FL & differ parity
goto single_col;
}else{ // AFL/AFR/FR/FL -> AFR/FR
if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR
mb_y = s->mb_y&~1;
mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride;
mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy];
mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride];
b8_stride = 2+4*s->mb_stride;
b4_stride *= 6;
sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */
if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)
&& (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA)
&& !is_b8x8){
*mb_type |= MB_TYPE_16x8 |MB_TYPE_L0L1|MB_TYPE_DIRECT2; /* B_16x8 */
}else{
*mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1;
}else{ // AFR/FR -> AFR/FR
single_col:
mb_type_col[0] =
mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy];
sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */
if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){
*mb_type |= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_16x16 */
}else if(!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){
*mb_type |= MB_TYPE_L0L1|MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16));
}else{
if(!h->sps.direct_8x8_inference_flag){
/* FIXME save sub mb types from previous frames (or derive from MVs)
* so we know exactly what block size to use */
sub_mb_type = MB_TYPE_8x8|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_4x4 */
*mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1;
await_reference_mb_row(h, &h->ref_list[1][0], mb_y);
l1mv0 = &h->ref_list[1][0].f.motion_val[0][h->mb2b_xy [mb_xy]];
l1mv1 = &h->ref_list[1][0].f.motion_val[1][h->mb2b_xy [mb_xy]];
l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy];
l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy];
if(!b8_stride){
if(s->mb_y&1){
l1ref0 += 2;
l1ref1 += 2;
l1mv0 += 2*b4_stride;
l1mv1 += 2*b4_stride;
{
const int *map_col_to_list0[2] = {h->map_col_to_list0[0], h->map_col_to_list0[1]};
const int *dist_scale_factor = h->dist_scale_factor;
int ref_offset;
if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){
map_col_to_list0[0] = h->map_col_to_list0_field[s->mb_y&1][0];
map_col_to_list0[1] = h->map_col_to_list0_field[s->mb_y&1][1];
dist_scale_factor =h->dist_scale_factor_field[s->mb_y&1];
ref_offset = (h->ref_list[1][0].mbaff<<4) & (mb_type_col[0]>>3); //if(h->ref_list[1][0].mbaff && IS_INTERLACED(mb_type_col[0])) ref_offset=16 else 0
if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){
int y_shift = 2*!IS_INTERLACED(*mb_type);
assert(h->sps.direct_8x8_inference_flag);
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
const int y8 = i8>>1;
int ref0, scale;
const int16_t (*l1mv)[2]= l1mv0;
if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
continue;
h->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1);
if(IS_INTRA(mb_type_col[y8])){
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1);
fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
continue;
ref0 = l1ref0[x8 + y8*b8_stride];
if(ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else{
ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride] + ref_offset];
l1mv= l1mv1;
scale = dist_scale_factor[ref0];
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1);
{
const int16_t *mv_col = l1mv[x8*3 + y8*b4_stride];
int my_col = (mv_col[1]<<y_shift)/2;
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * my_col + 128) >> 8;
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4);
fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-my_col), 4);
return;
/* one-to-one mv scaling */
if(IS_16X16(*mb_type)){
int ref, mv0, mv1;
fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
if(IS_INTRA(mb_type_col[0])){
ref=mv0=mv1=0;
}else{
const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
: map_col_to_list0[1][l1ref1[0] + ref_offset];
const int scale = dist_scale_factor[ref0];
const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
int mv_l0[2];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
ref= ref0;
mv0= pack16to32(mv_l0[0],mv_l0[1]);
mv1= pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4);
}else{
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
const int y8 = i8>>1;
int ref0, scale;
const int16_t (*l1mv)[2]= l1mv0;
if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
continue;
h->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1);
if(IS_INTRA(mb_type_col[0])){
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1);
fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
continue;
assert(b8_stride == 2);
ref0 = l1ref0[i8];
if(ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else{
ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
l1mv= l1mv1;
scale = dist_scale_factor[ref0];
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1);
if(IS_SUB_8X8(sub_mb_type)){
const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride];
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * mv_col[1] + 128) >> 8;
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4);
fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-mv_col[1]), 4);
}else
for(i4=0; i4<4; i4++){
const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride];
int16_t *mv_l0 = h->mv_cache[0][scan8[i8*4+i4]];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
AV_WN32A(h->mv_cache[1][scan8[i8*4+i4]],
pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]));
| true | FFmpeg | 758ec111538ccd487686e8677aa754ee4d82beaa | static void pred_temp_direct_motion(H264Context * const h, int *mb_type){
MpegEncContext * const s = &h->s;
int b8_stride = 2;
int b4_stride = h->b_stride;
int mb_xy = h->mb_xy, mb_y = s->mb_y;
int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1;
const int is_b8x8 = IS_8X8(*mb_type);
unsigned int sub_mb_type;
int i8, i4;
assert(h->ref_list[1][0].f.reference & 3);
await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type));
if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) {
if (!IS_INTERLACED(*mb_type)) {
mb_y = (s->mb_y&~1) + h->col_parity;
mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride;
b8_stride = 0;
}else{
mb_y += h->col_fieldoff;
mb_xy += s->mb_stride*h->col_fieldoff;
goto single_col;
}else{
if(IS_INTERLACED(*mb_type)){
mb_y = s->mb_y&~1;
mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride;
mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy];
mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride];
b8_stride = 2+4*s->mb_stride;
b4_stride *= 6;
sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)
&& (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA)
&& !is_b8x8){
*mb_type |= MB_TYPE_16x8 |MB_TYPE_L0L1|MB_TYPE_DIRECT2;
}else{
*mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1;
}else{
single_col:
mb_type_col[0] =
mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy];
sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){
*mb_type |= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
}else if(!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){
*mb_type |= MB_TYPE_L0L1|MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16));
}else{
if(!h->sps.direct_8x8_inference_flag){
sub_mb_type = MB_TYPE_8x8|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
*mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1;
await_reference_mb_row(h, &h->ref_list[1][0], mb_y);
l1mv0 = &h->ref_list[1][0].f.motion_val[0][h->mb2b_xy [mb_xy]];
l1mv1 = &h->ref_list[1][0].f.motion_val[1][h->mb2b_xy [mb_xy]];
l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy];
l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy];
if(!b8_stride){
if(s->mb_y&1){
l1ref0 += 2;
l1ref1 += 2;
l1mv0 += 2*b4_stride;
l1mv1 += 2*b4_stride;
{
const int *map_col_to_list0[2] = {h->map_col_to_list0[0], h->map_col_to_list0[1]};
const int *dist_scale_factor = h->dist_scale_factor;
int ref_offset;
if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){
map_col_to_list0[0] = h->map_col_to_list0_field[s->mb_y&1][0];
map_col_to_list0[1] = h->map_col_to_list0_field[s->mb_y&1][1];
dist_scale_factor =h->dist_scale_factor_field[s->mb_y&1];
ref_offset = (h->ref_list[1][0].mbaff<<4) & (mb_type_col[0]>>3);
if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){
int y_shift = 2*!IS_INTERLACED(*mb_type);
assert(h->sps.direct_8x8_inference_flag);
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
const int y8 = i8>>1;
int ref0, scale;
const int16_t (*l1mv)[2]= l1mv0;
if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
continue;
h->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1);
if(IS_INTRA(mb_type_col[y8])){
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1);
fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
continue;
ref0 = l1ref0[x8 + y8*b8_stride];
if(ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else{
ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride] + ref_offset];
l1mv= l1mv1;
scale = dist_scale_factor[ref0];
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1);
{
const int16_t *mv_col = l1mv[x8*3 + y8*b4_stride];
int my_col = (mv_col[1]<<y_shift)/2;
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * my_col + 128) >> 8;
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4);
fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-my_col), 4);
return;
if(IS_16X16(*mb_type)){
int ref, mv0, mv1;
fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
if(IS_INTRA(mb_type_col[0])){
ref=mv0=mv1=0;
}else{
const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
: map_col_to_list0[1][l1ref1[0] + ref_offset];
const int scale = dist_scale_factor[ref0];
const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
int mv_l0[2];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
ref= ref0;
mv0= pack16to32(mv_l0[0],mv_l0[1]);
mv1= pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4);
}else{
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
const int y8 = i8>>1;
int ref0, scale;
const int16_t (*l1mv)[2]= l1mv0;
if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
continue;
h->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1);
if(IS_INTRA(mb_type_col[0])){
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1);
fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
continue;
assert(b8_stride == 2);
ref0 = l1ref0[i8];
if(ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else{
ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
l1mv= l1mv1;
scale = dist_scale_factor[ref0];
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1);
if(IS_SUB_8X8(sub_mb_type)){
const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride];
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * mv_col[1] + 128) >> 8;
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4);
fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-mv_col[1]), 4);
}else
for(i4=0; i4<4; i4++){
const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride];
int16_t *mv_l0 = h->mv_cache[0][scan8[i8*4+i4]];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
AV_WN32A(h->mv_cache[1][scan8[i8*4+i4]],
pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]));
| {
"code": [],
"line_no": []
} | static void FUNC_0(H264Context * const VAR_0, int *VAR_1){
MpegEncContext * const s = &VAR_0->s;
int VAR_2 = 2;
int VAR_3 = VAR_0->b_stride;
int VAR_4 = VAR_0->VAR_4, VAR_5 = s->VAR_5;
int VAR_6[2];
const FUNC_1 (*l1mv0)[2], (*l1mv1)[2];
const int8_t *VAR_7, *l1ref1;
const int VAR_8 = IS_8X8(*VAR_1);
unsigned int VAR_9;
int VAR_10, VAR_11;
assert(VAR_0->ref_list[1][0].f.reference & 3);
await_reference_mb_row(VAR_0, &VAR_0->ref_list[1][0], s->VAR_5 + !!IS_INTERLACED(*VAR_1));
if (IS_INTERLACED(VAR_0->ref_list[1][0].f.VAR_1[VAR_4])) {
if (!IS_INTERLACED(*VAR_1)) {
VAR_5 = (s->VAR_5&~1) + VAR_0->col_parity;
VAR_4= s->mb_x + ((s->VAR_5&~1) + VAR_0->col_parity)*s->mb_stride;
VAR_2 = 0;
}else{
VAR_5 += VAR_0->col_fieldoff;
VAR_4 += s->mb_stride*VAR_0->col_fieldoff;
goto single_col;
}else{
if(IS_INTERLACED(*VAR_1)){
VAR_5 = s->VAR_5&~1;
VAR_4= s->mb_x + (s->VAR_5&~1)*s->mb_stride;
VAR_6[0] = VAR_0->ref_list[1][0].f.VAR_1[VAR_4];
VAR_6[1] = VAR_0->ref_list[1][0].f.VAR_1[VAR_4 + s->mb_stride];
VAR_2 = 2+4*s->mb_stride;
VAR_3 *= 6;
VAR_9 = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
if( (VAR_6[0] & MB_TYPE_16x16_OR_INTRA)
&& (VAR_6[1] & MB_TYPE_16x16_OR_INTRA)
&& !VAR_8){
*VAR_1 |= MB_TYPE_16x8 |MB_TYPE_L0L1|MB_TYPE_DIRECT2;
}else{
*VAR_1 |= MB_TYPE_8x8|MB_TYPE_L0L1;
}else{
single_col:
VAR_6[0] =
VAR_6[1] = VAR_0->ref_list[1][0].f.VAR_1[VAR_4];
VAR_9 = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
if(!VAR_8 && (VAR_6[0] & MB_TYPE_16x16_OR_INTRA)){
*VAR_1 |= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
}else if(!VAR_8 && (VAR_6[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){
*VAR_1 |= MB_TYPE_L0L1|MB_TYPE_DIRECT2 | (VAR_6[0] & (MB_TYPE_16x8|MB_TYPE_8x16));
}else{
if(!VAR_0->sps.direct_8x8_inference_flag){
VAR_9 = MB_TYPE_8x8|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
*VAR_1 |= MB_TYPE_8x8|MB_TYPE_L0L1;
await_reference_mb_row(VAR_0, &VAR_0->ref_list[1][0], VAR_5);
l1mv0 = &VAR_0->ref_list[1][0].f.motion_val[0][VAR_0->mb2b_xy [VAR_4]];
l1mv1 = &VAR_0->ref_list[1][0].f.motion_val[1][VAR_0->mb2b_xy [VAR_4]];
VAR_7 = &VAR_0->ref_list[1][0].f.ref_index [0][4 * VAR_4];
l1ref1 = &VAR_0->ref_list[1][0].f.ref_index [1][4 * VAR_4];
if(!VAR_2){
if(s->VAR_5&1){
VAR_7 += 2;
l1ref1 += 2;
l1mv0 += 2*VAR_3;
l1mv1 += 2*VAR_3;
{
const int *map_col_to_list0[2] = {VAR_0->map_col_to_list0[0], VAR_0->map_col_to_list0[1]};
const int *dist_scale_factor = VAR_0->dist_scale_factor;
int ref_offset;
if(FRAME_MBAFF && IS_INTERLACED(*VAR_1)){
map_col_to_list0[0] = VAR_0->map_col_to_list0_field[s->VAR_5&1][0];
map_col_to_list0[1] = VAR_0->map_col_to_list0_field[s->VAR_5&1][1];
dist_scale_factor =VAR_0->dist_scale_factor_field[s->VAR_5&1];
ref_offset = (VAR_0->ref_list[1][0].mbaff<<4) & (VAR_6[0]>>3);
if(IS_INTERLACED(*VAR_1) != IS_INTERLACED(VAR_6[0])){
int y_shift = 2*!IS_INTERLACED(*VAR_1);
assert(VAR_0->sps.direct_8x8_inference_flag);
for(VAR_10=0; VAR_10<4; VAR_10++){
const int x8 = VAR_10&1;
const int y8 = VAR_10>>1;
int ref0, scale;
const FUNC_1 (*l1mv)[2]= l1mv0;
if(VAR_8 && !IS_DIRECT(VAR_0->VAR_9[VAR_10]))
continue;
VAR_0->VAR_9[VAR_10] = VAR_9;
fill_rectangle(&VAR_0->ref_cache[1][scan8[VAR_10*4]], 2, 2, 8, 0, 1);
if(IS_INTRA(VAR_6[y8])){
fill_rectangle(&VAR_0->ref_cache[0][scan8[VAR_10*4]], 2, 2, 8, 0, 1);
fill_rectangle(&VAR_0-> mv_cache[0][scan8[VAR_10*4]], 2, 2, 8, 0, 4);
fill_rectangle(&VAR_0-> mv_cache[1][scan8[VAR_10*4]], 2, 2, 8, 0, 4);
continue;
ref0 = VAR_7[x8 + y8*VAR_2];
if(ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else{
ref0 = map_col_to_list0[1][l1ref1[x8 + y8*VAR_2] + ref_offset];
l1mv= l1mv1;
scale = dist_scale_factor[ref0];
fill_rectangle(&VAR_0->ref_cache[0][scan8[VAR_10*4]], 2, 2, 8, ref0, 1);
{
const FUNC_1 *mv_col = l1mv[x8*3 + y8*VAR_3];
int my_col = (mv_col[1]<<y_shift)/2;
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * my_col + 128) >> 8;
fill_rectangle(&VAR_0->mv_cache[0][scan8[VAR_10*4]], 2, 2, 8, pack16to32(mx,my), 4);
fill_rectangle(&VAR_0->mv_cache[1][scan8[VAR_10*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-my_col), 4);
return;
if(IS_16X16(*VAR_1)){
int ref, mv0, mv1;
fill_rectangle(&VAR_0->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
if(IS_INTRA(VAR_6[0])){
ref=mv0=mv1=0;
}else{
const int ref0 = VAR_7[0] >= 0 ? map_col_to_list0[0][VAR_7[0] + ref_offset]
: map_col_to_list0[1][l1ref1[0] + ref_offset];
const int scale = dist_scale_factor[ref0];
const FUNC_1 *mv_col = VAR_7[0] >= 0 ? l1mv0[0] : l1mv1[0];
int mv_l0[2];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
ref= ref0;
mv0= pack16to32(mv_l0[0],mv_l0[1]);
mv1= pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);
fill_rectangle(&VAR_0->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
fill_rectangle(&VAR_0-> mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4);
fill_rectangle(&VAR_0-> mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4);
}else{
for(VAR_10=0; VAR_10<4; VAR_10++){
const int x8 = VAR_10&1;
const int y8 = VAR_10>>1;
int ref0, scale;
const FUNC_1 (*l1mv)[2]= l1mv0;
if(VAR_8 && !IS_DIRECT(VAR_0->VAR_9[VAR_10]))
continue;
VAR_0->VAR_9[VAR_10] = VAR_9;
fill_rectangle(&VAR_0->ref_cache[1][scan8[VAR_10*4]], 2, 2, 8, 0, 1);
if(IS_INTRA(VAR_6[0])){
fill_rectangle(&VAR_0->ref_cache[0][scan8[VAR_10*4]], 2, 2, 8, 0, 1);
fill_rectangle(&VAR_0-> mv_cache[0][scan8[VAR_10*4]], 2, 2, 8, 0, 4);
fill_rectangle(&VAR_0-> mv_cache[1][scan8[VAR_10*4]], 2, 2, 8, 0, 4);
continue;
assert(VAR_2 == 2);
ref0 = VAR_7[VAR_10];
if(ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else{
ref0 = map_col_to_list0[1][l1ref1[VAR_10] + ref_offset];
l1mv= l1mv1;
scale = dist_scale_factor[ref0];
fill_rectangle(&VAR_0->ref_cache[0][scan8[VAR_10*4]], 2, 2, 8, ref0, 1);
if(IS_SUB_8X8(VAR_9)){
const FUNC_1 *mv_col = l1mv[x8*3 + y8*3*VAR_3];
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * mv_col[1] + 128) >> 8;
fill_rectangle(&VAR_0->mv_cache[0][scan8[VAR_10*4]], 2, 2, 8, pack16to32(mx,my), 4);
fill_rectangle(&VAR_0->mv_cache[1][scan8[VAR_10*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-mv_col[1]), 4);
}else
for(VAR_11=0; VAR_11<4; VAR_11++){
const FUNC_1 *mv_col = l1mv[x8*2 + (VAR_11&1) + (y8*2 + (VAR_11>>1))*VAR_3];
FUNC_1 *mv_l0 = VAR_0->mv_cache[0][scan8[VAR_10*4+VAR_11]];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
AV_WN32A(VAR_0->mv_cache[1][scan8[VAR_10*4+VAR_11]],
pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]));
| [
"static void FUNC_0(H264Context * const VAR_0, int *VAR_1){",
"MpegEncContext * const s = &VAR_0->s;",
"int VAR_2 = 2;",
"int VAR_3 = VAR_0->b_stride;",
"int VAR_4 = VAR_0->VAR_4, VAR_5 = s->VAR_5;",
"int VAR_6[2];",
"const FUNC_1 (*l1mv0)[2], (*l1mv1)[2];",
"const int8_t *VAR_7, *l1ref1;",
"const int VAR_8 = IS_8X8(*VAR_1);",
"unsigned int VAR_9;",
"int VAR_10, VAR_11;",
"assert(VAR_0->ref_list[1][0].f.reference & 3);",
"await_reference_mb_row(VAR_0, &VAR_0->ref_list[1][0], s->VAR_5 + !!IS_INTERLACED(*VAR_1));",
"if (IS_INTERLACED(VAR_0->ref_list[1][0].f.VAR_1[VAR_4])) {",
"if (!IS_INTERLACED(*VAR_1)) {",
"VAR_5 = (s->VAR_5&~1) + VAR_0->col_parity;",
"VAR_4= s->mb_x + ((s->VAR_5&~1) + VAR_0->col_parity)*s->mb_stride;",
"VAR_2 = 0;",
"}else{",
"VAR_5 += VAR_0->col_fieldoff;",
"VAR_4 += s->mb_stride*VAR_0->col_fieldoff;",
"goto single_col;",
"}else{",
"if(IS_INTERLACED(*VAR_1)){",
"VAR_5 = s->VAR_5&~1;",
"VAR_4= s->mb_x + (s->VAR_5&~1)*s->mb_stride;",
"VAR_6[0] = VAR_0->ref_list[1][0].f.VAR_1[VAR_4];",
"VAR_6[1] = VAR_0->ref_list[1][0].f.VAR_1[VAR_4 + s->mb_stride];",
"VAR_2 = 2+4*s->mb_stride;",
"VAR_3 *= 6;",
"VAR_9 = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;",
"if( (VAR_6[0] & MB_TYPE_16x16_OR_INTRA)\n&& (VAR_6[1] & MB_TYPE_16x16_OR_INTRA)\n&& !VAR_8){",
"*VAR_1 |= MB_TYPE_16x8 |MB_TYPE_L0L1|MB_TYPE_DIRECT2;",
"}else{",
"*VAR_1 |= MB_TYPE_8x8|MB_TYPE_L0L1;",
"}else{",
"single_col:\nVAR_6[0] =\nVAR_6[1] = VAR_0->ref_list[1][0].f.VAR_1[VAR_4];",
"VAR_9 = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;",
"if(!VAR_8 && (VAR_6[0] & MB_TYPE_16x16_OR_INTRA)){",
"*VAR_1 |= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;",
"}else if(!VAR_8 && (VAR_6[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){",
"*VAR_1 |= MB_TYPE_L0L1|MB_TYPE_DIRECT2 | (VAR_6[0] & (MB_TYPE_16x8|MB_TYPE_8x16));",
"}else{",
"if(!VAR_0->sps.direct_8x8_inference_flag){",
"VAR_9 = MB_TYPE_8x8|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;",
"*VAR_1 |= MB_TYPE_8x8|MB_TYPE_L0L1;",
"await_reference_mb_row(VAR_0, &VAR_0->ref_list[1][0], VAR_5);",
"l1mv0 = &VAR_0->ref_list[1][0].f.motion_val[0][VAR_0->mb2b_xy [VAR_4]];",
"l1mv1 = &VAR_0->ref_list[1][0].f.motion_val[1][VAR_0->mb2b_xy [VAR_4]];",
"VAR_7 = &VAR_0->ref_list[1][0].f.ref_index [0][4 * VAR_4];",
"l1ref1 = &VAR_0->ref_list[1][0].f.ref_index [1][4 * VAR_4];",
"if(!VAR_2){",
"if(s->VAR_5&1){",
"VAR_7 += 2;",
"l1ref1 += 2;",
"l1mv0 += 2*VAR_3;",
"l1mv1 += 2*VAR_3;",
"{",
"const int *map_col_to_list0[2] = {VAR_0->map_col_to_list0[0], VAR_0->map_col_to_list0[1]};",
"const int *dist_scale_factor = VAR_0->dist_scale_factor;",
"int ref_offset;",
"if(FRAME_MBAFF && IS_INTERLACED(*VAR_1)){",
"map_col_to_list0[0] = VAR_0->map_col_to_list0_field[s->VAR_5&1][0];",
"map_col_to_list0[1] = VAR_0->map_col_to_list0_field[s->VAR_5&1][1];",
"dist_scale_factor =VAR_0->dist_scale_factor_field[s->VAR_5&1];",
"ref_offset = (VAR_0->ref_list[1][0].mbaff<<4) & (VAR_6[0]>>3);",
"if(IS_INTERLACED(*VAR_1) != IS_INTERLACED(VAR_6[0])){",
"int y_shift = 2*!IS_INTERLACED(*VAR_1);",
"assert(VAR_0->sps.direct_8x8_inference_flag);",
"for(VAR_10=0; VAR_10<4; VAR_10++){",
"const int x8 = VAR_10&1;",
"const int y8 = VAR_10>>1;",
"int ref0, scale;",
"const FUNC_1 (*l1mv)[2]= l1mv0;",
"if(VAR_8 && !IS_DIRECT(VAR_0->VAR_9[VAR_10]))\ncontinue;",
"VAR_0->VAR_9[VAR_10] = VAR_9;",
"fill_rectangle(&VAR_0->ref_cache[1][scan8[VAR_10*4]], 2, 2, 8, 0, 1);",
"if(IS_INTRA(VAR_6[y8])){",
"fill_rectangle(&VAR_0->ref_cache[0][scan8[VAR_10*4]], 2, 2, 8, 0, 1);",
"fill_rectangle(&VAR_0-> mv_cache[0][scan8[VAR_10*4]], 2, 2, 8, 0, 4);",
"fill_rectangle(&VAR_0-> mv_cache[1][scan8[VAR_10*4]], 2, 2, 8, 0, 4);",
"continue;",
"ref0 = VAR_7[x8 + y8*VAR_2];",
"if(ref0 >= 0)\nref0 = map_col_to_list0[0][ref0 + ref_offset];",
"else{",
"ref0 = map_col_to_list0[1][l1ref1[x8 + y8*VAR_2] + ref_offset];",
"l1mv= l1mv1;",
"scale = dist_scale_factor[ref0];",
"fill_rectangle(&VAR_0->ref_cache[0][scan8[VAR_10*4]], 2, 2, 8, ref0, 1);",
"{",
"const FUNC_1 *mv_col = l1mv[x8*3 + y8*VAR_3];",
"int my_col = (mv_col[1]<<y_shift)/2;",
"int mx = (scale * mv_col[0] + 128) >> 8;",
"int my = (scale * my_col + 128) >> 8;",
"fill_rectangle(&VAR_0->mv_cache[0][scan8[VAR_10*4]], 2, 2, 8, pack16to32(mx,my), 4);",
"fill_rectangle(&VAR_0->mv_cache[1][scan8[VAR_10*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-my_col), 4);",
"return;",
"if(IS_16X16(*VAR_1)){",
"int ref, mv0, mv1;",
"fill_rectangle(&VAR_0->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);",
"if(IS_INTRA(VAR_6[0])){",
"ref=mv0=mv1=0;",
"}else{",
"const int ref0 = VAR_7[0] >= 0 ? map_col_to_list0[0][VAR_7[0] + ref_offset]\n: map_col_to_list0[1][l1ref1[0] + ref_offset];",
"const int scale = dist_scale_factor[ref0];",
"const FUNC_1 *mv_col = VAR_7[0] >= 0 ? l1mv0[0] : l1mv1[0];",
"int mv_l0[2];",
"mv_l0[0] = (scale * mv_col[0] + 128) >> 8;",
"mv_l0[1] = (scale * mv_col[1] + 128) >> 8;",
"ref= ref0;",
"mv0= pack16to32(mv_l0[0],mv_l0[1]);",
"mv1= pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);",
"fill_rectangle(&VAR_0->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);",
"fill_rectangle(&VAR_0-> mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4);",
"fill_rectangle(&VAR_0-> mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4);",
"}else{",
"for(VAR_10=0; VAR_10<4; VAR_10++){",
"const int x8 = VAR_10&1;",
"const int y8 = VAR_10>>1;",
"int ref0, scale;",
"const FUNC_1 (*l1mv)[2]= l1mv0;",
"if(VAR_8 && !IS_DIRECT(VAR_0->VAR_9[VAR_10]))\ncontinue;",
"VAR_0->VAR_9[VAR_10] = VAR_9;",
"fill_rectangle(&VAR_0->ref_cache[1][scan8[VAR_10*4]], 2, 2, 8, 0, 1);",
"if(IS_INTRA(VAR_6[0])){",
"fill_rectangle(&VAR_0->ref_cache[0][scan8[VAR_10*4]], 2, 2, 8, 0, 1);",
"fill_rectangle(&VAR_0-> mv_cache[0][scan8[VAR_10*4]], 2, 2, 8, 0, 4);",
"fill_rectangle(&VAR_0-> mv_cache[1][scan8[VAR_10*4]], 2, 2, 8, 0, 4);",
"continue;",
"assert(VAR_2 == 2);",
"ref0 = VAR_7[VAR_10];",
"if(ref0 >= 0)\nref0 = map_col_to_list0[0][ref0 + ref_offset];",
"else{",
"ref0 = map_col_to_list0[1][l1ref1[VAR_10] + ref_offset];",
"l1mv= l1mv1;",
"scale = dist_scale_factor[ref0];",
"fill_rectangle(&VAR_0->ref_cache[0][scan8[VAR_10*4]], 2, 2, 8, ref0, 1);",
"if(IS_SUB_8X8(VAR_9)){",
"const FUNC_1 *mv_col = l1mv[x8*3 + y8*3*VAR_3];",
"int mx = (scale * mv_col[0] + 128) >> 8;",
"int my = (scale * mv_col[1] + 128) >> 8;",
"fill_rectangle(&VAR_0->mv_cache[0][scan8[VAR_10*4]], 2, 2, 8, pack16to32(mx,my), 4);",
"fill_rectangle(&VAR_0->mv_cache[1][scan8[VAR_10*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-mv_col[1]), 4);",
"}else",
"for(VAR_11=0; VAR_11<4; VAR_11++){",
"const FUNC_1 *mv_col = l1mv[x8*2 + (VAR_11&1) + (y8*2 + (VAR_11>>1))*VAR_3];",
"FUNC_1 *mv_l0 = VAR_0->mv_cache[0][scan8[VAR_10*4+VAR_11]];",
"mv_l0[0] = (scale * mv_col[0] + 128) >> 8;",
"mv_l0[1] = (scale * mv_col[1] + 128) >> 8;",
"AV_WN32A(VAR_0->mv_cache[1][scan8[VAR_10*4+VAR_11]],\npack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[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
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
50
],
[
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
62
],
[
64
],
[
66
],
[
74
],
[
78,
80,
82
],
[
84
],
[
86
],
[
88
],
[
91
],
[
93,
95,
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
119
],
[
122
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
176
],
[
180
],
[
182
],
[
184
],
[
188
],
[
190
],
[
192
],
[
194
],
[
196
],
[
200,
202
],
[
204
],
[
208
],
[
210
],
[
212
],
[
214
],
[
216
],
[
218
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
233
],
[
236
],
[
238
],
[
242
],
[
244
],
[
246
],
[
248
],
[
250
],
[
252
],
[
254
],
[
258
],
[
267
],
[
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281,
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
302
],
[
304
],
[
306
],
[
308
],
[
310
],
[
312
],
[
314
],
[
316
],
[
318
],
[
322,
324
],
[
326
],
[
328
],
[
330
],
[
332
],
[
334
],
[
336
],
[
338
],
[
343
],
[
345
],
[
347,
349
],
[
351
],
[
353
],
[
355
],
[
358
],
[
362
],
[
364
],
[
366
],
[
368
],
[
370
],
[
372
],
[
374
],
[
376
],
[
378
],
[
380
],
[
382
],
[
384
],
[
386
],
[
388,
390
]
] |
19,415 | static inline int cris_abs(int n)
{
int r;
asm ("abs\t%1, %0\n" : "=r" (r) : "r" (n));
return r;
}
| true | qemu | 21ce148c7ec71ee32834061355a5ecfd1a11f90f | static inline int cris_abs(int n)
{
int r;
asm ("abs\t%1, %0\n" : "=r" (r) : "r" (n));
return r;
}
| {
"code": [
"static inline int cris_abs(int n)"
],
"line_no": [
1
]
} | static inline int FUNC_0(int VAR_0)
{
int VAR_1;
asm ("abs\t%1, %0\VAR_0" : "=VAR_1" (VAR_1) : "VAR_1" (VAR_0));
return VAR_1;
}
| [
"static inline int FUNC_0(int VAR_0)\n{",
"int VAR_1;",
"asm (\"abs\\t%1, %0\\VAR_0\" : \"=VAR_1\" (VAR_1) : \"VAR_1\" (VAR_0));",
"return VAR_1;",
"}"
] | [
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
19,416 | static int bmdma_prepare_buf(IDEDMA *dma, int is_write)
{
BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
IDEState *s = bmdma_active_if(bm);
PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);
struct {
uint32_t addr;
uint32_t size;
} prd;
int l, len;
pci_dma_sglist_init(&s->sg, pci_dev,
s->nsector / (BMDMA_PAGE_SIZE / 512) + 1);
s->io_buffer_size = 0;
for(;;) {
if (bm->cur_prd_len == 0) {
/* end of table (with a fail safe of one page) */
if (bm->cur_prd_last ||
(bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE)
return s->io_buffer_size != 0;
pci_dma_read(pci_dev, bm->cur_addr, &prd, 8);
bm->cur_addr += 8;
prd.addr = le32_to_cpu(prd.addr);
prd.size = le32_to_cpu(prd.size);
len = prd.size & 0xfffe;
if (len == 0)
len = 0x10000;
bm->cur_prd_len = len;
bm->cur_prd_addr = prd.addr;
bm->cur_prd_last = (prd.size & 0x80000000);
}
l = bm->cur_prd_len;
if (l > 0) {
qemu_sglist_add(&s->sg, bm->cur_prd_addr, l);
bm->cur_prd_addr += l;
bm->cur_prd_len -= l;
s->io_buffer_size += l;
}
}
return 1;
}
| true | qemu | 3251bdcf1c67427d964517053c3d185b46e618e8 | static int bmdma_prepare_buf(IDEDMA *dma, int is_write)
{
BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
IDEState *s = bmdma_active_if(bm);
PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);
struct {
uint32_t addr;
uint32_t size;
} prd;
int l, len;
pci_dma_sglist_init(&s->sg, pci_dev,
s->nsector / (BMDMA_PAGE_SIZE / 512) + 1);
s->io_buffer_size = 0;
for(;;) {
if (bm->cur_prd_len == 0) {
if (bm->cur_prd_last ||
(bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE)
return s->io_buffer_size != 0;
pci_dma_read(pci_dev, bm->cur_addr, &prd, 8);
bm->cur_addr += 8;
prd.addr = le32_to_cpu(prd.addr);
prd.size = le32_to_cpu(prd.size);
len = prd.size & 0xfffe;
if (len == 0)
len = 0x10000;
bm->cur_prd_len = len;
bm->cur_prd_addr = prd.addr;
bm->cur_prd_last = (prd.size & 0x80000000);
}
l = bm->cur_prd_len;
if (l > 0) {
qemu_sglist_add(&s->sg, bm->cur_prd_addr, l);
bm->cur_prd_addr += l;
bm->cur_prd_len -= l;
s->io_buffer_size += l;
}
}
return 1;
}
| {
"code": [
"static int bmdma_prepare_buf(IDEDMA *dma, int is_write)",
" (bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE)",
" return s->io_buffer_size != 0;",
" return 1;"
],
"line_no": [
1,
37,
39,
79
]
} | static int FUNC_0(IDEDMA *VAR_0, int VAR_1)
{
BMDMAState *bm = DO_UPCAST(BMDMAState, VAR_0, VAR_0);
IDEState *s = bmdma_active_if(bm);
PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);
struct {
uint32_t addr;
uint32_t size;
} VAR_2;
int VAR_3, VAR_4;
pci_dma_sglist_init(&s->sg, pci_dev,
s->nsector / (BMDMA_PAGE_SIZE / 512) + 1);
s->io_buffer_size = 0;
for(;;) {
if (bm->cur_prd_len == 0) {
if (bm->cur_prd_last ||
(bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE)
return s->io_buffer_size != 0;
pci_dma_read(pci_dev, bm->cur_addr, &VAR_2, 8);
bm->cur_addr += 8;
VAR_2.addr = le32_to_cpu(VAR_2.addr);
VAR_2.size = le32_to_cpu(VAR_2.size);
VAR_4 = VAR_2.size & 0xfffe;
if (VAR_4 == 0)
VAR_4 = 0x10000;
bm->cur_prd_len = VAR_4;
bm->cur_prd_addr = VAR_2.addr;
bm->cur_prd_last = (VAR_2.size & 0x80000000);
}
VAR_3 = bm->cur_prd_len;
if (VAR_3 > 0) {
qemu_sglist_add(&s->sg, bm->cur_prd_addr, VAR_3);
bm->cur_prd_addr += VAR_3;
bm->cur_prd_len -= VAR_3;
s->io_buffer_size += VAR_3;
}
}
return 1;
}
| [
"static int FUNC_0(IDEDMA *VAR_0, int VAR_1)\n{",
"BMDMAState *bm = DO_UPCAST(BMDMAState, VAR_0, VAR_0);",
"IDEState *s = bmdma_active_if(bm);",
"PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);",
"struct {",
"uint32_t addr;",
"uint32_t size;",
"} VAR_2;",
"int VAR_3, VAR_4;",
"pci_dma_sglist_init(&s->sg, pci_dev,\ns->nsector / (BMDMA_PAGE_SIZE / 512) + 1);",
"s->io_buffer_size = 0;",
"for(;;) {",
"if (bm->cur_prd_len == 0) {",
"if (bm->cur_prd_last ||\n(bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE)\nreturn s->io_buffer_size != 0;",
"pci_dma_read(pci_dev, bm->cur_addr, &VAR_2, 8);",
"bm->cur_addr += 8;",
"VAR_2.addr = le32_to_cpu(VAR_2.addr);",
"VAR_2.size = le32_to_cpu(VAR_2.size);",
"VAR_4 = VAR_2.size & 0xfffe;",
"if (VAR_4 == 0)\nVAR_4 = 0x10000;",
"bm->cur_prd_len = VAR_4;",
"bm->cur_prd_addr = VAR_2.addr;",
"bm->cur_prd_last = (VAR_2.size & 0x80000000);",
"}",
"VAR_3 = bm->cur_prd_len;",
"if (VAR_3 > 0) {",
"qemu_sglist_add(&s->sg, bm->cur_prd_addr, VAR_3);",
"bm->cur_prd_addr += VAR_3;",
"bm->cur_prd_len -= VAR_3;",
"s->io_buffer_size += VAR_3;",
"}",
"}",
"return 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,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
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
]
] |
19,417 | av_cold int ff_mss12_decode_init(MSS12Context *c, int version,
SliceContext* sc1, SliceContext *sc2)
{
AVCodecContext *avctx = c->avctx;
int i;
if (avctx->extradata_size < 52 + 256 * 3) {
av_log(avctx, AV_LOG_ERROR, "Insufficient extradata size %d\n",
avctx->extradata_size);
if (AV_RB32(avctx->extradata) < avctx->extradata_size) {
av_log(avctx, AV_LOG_ERROR,
"Insufficient extradata size: expected %d got %d\n",
AV_RB32(avctx->extradata),
avctx->extradata_size);
avctx->coded_width = AV_RB32(avctx->extradata + 20);
avctx->coded_height = AV_RB32(avctx->extradata + 24);
if (avctx->coded_width > 4096 || avctx->coded_height > 4096) {
av_log(avctx, AV_LOG_ERROR, "Frame dimensions %dx%d too large",
av_log(avctx, AV_LOG_DEBUG, "Encoder version %d.%d\n",
AV_RB32(avctx->extradata + 4), AV_RB32(avctx->extradata + 8));
if (version != AV_RB32(avctx->extradata + 4) > 1) {
av_log(avctx, AV_LOG_ERROR,
"Header version doesn't match codec tag\n");
return -1;
c->free_colours = AV_RB32(avctx->extradata + 48);
if ((unsigned)c->free_colours > 256) {
av_log(avctx, AV_LOG_ERROR,
"Incorrect number of changeable palette entries: %d\n",
c->free_colours);
av_log(avctx, AV_LOG_DEBUG, "%d free colour(s)\n", c->free_colours);
av_log(avctx, AV_LOG_DEBUG, "Display dimensions %dx%d\n",
AV_RB32(avctx->extradata + 12), AV_RB32(avctx->extradata + 16));
av_log(avctx, AV_LOG_DEBUG, "Coded dimensions %dx%d\n",
av_log(avctx, AV_LOG_DEBUG, "%g frames per second\n",
av_int2float(AV_RB32(avctx->extradata + 28)));
av_log(avctx, AV_LOG_DEBUG, "Bitrate %d bps\n",
AV_RB32(avctx->extradata + 32));
av_log(avctx, AV_LOG_DEBUG, "Max. lead time %g ms\n",
av_int2float(AV_RB32(avctx->extradata + 36)));
av_log(avctx, AV_LOG_DEBUG, "Max. lag time %g ms\n",
av_int2float(AV_RB32(avctx->extradata + 40)));
av_log(avctx, AV_LOG_DEBUG, "Max. seek time %g ms\n",
av_int2float(AV_RB32(avctx->extradata + 44)));
if (version) {
if (avctx->extradata_size < 60 + 256 * 3) {
av_log(avctx, AV_LOG_ERROR,
"Insufficient extradata size %d for v2\n",
avctx->extradata_size);
c->slice_split = AV_RB32(avctx->extradata + 52);
av_log(avctx, AV_LOG_DEBUG, "Slice split %d\n", c->slice_split);
c->full_model_syms = AV_RB32(avctx->extradata + 56);
if (c->full_model_syms < 2 || c->full_model_syms > 256) {
av_log(avctx, AV_LOG_ERROR,
"Incorrect number of used colours %d\n",
c->full_model_syms);
av_log(avctx, AV_LOG_DEBUG, "Used colours %d\n",
c->full_model_syms);
} else {
c->slice_split = 0;
c->full_model_syms = 256;
for (i = 0; i < 256; i++)
c->pal[i] = 0xFFU << 24 | AV_RB24(avctx->extradata + 52 +
(version ? 8 : 0) + i * 3);
c->mask_stride = FFALIGN(avctx->width, 16);
c->mask = av_malloc(c->mask_stride * avctx->height);
if (!c->mask) {
av_log(avctx, AV_LOG_ERROR, "Cannot allocate mask plane\n");
return AVERROR(ENOMEM);
sc1->c = c;
slicecontext_init(sc1, version, c->full_model_syms);
if (c->slice_split) {
sc2->c = c;
slicecontext_init(sc2, version, c->full_model_syms);
c->corrupted = 1;
return 0;
| true | FFmpeg | ee9151b616fa7fa5e9b3258ecafd00c9f784baaa | av_cold int ff_mss12_decode_init(MSS12Context *c, int version,
SliceContext* sc1, SliceContext *sc2)
{
AVCodecContext *avctx = c->avctx;
int i;
if (avctx->extradata_size < 52 + 256 * 3) {
av_log(avctx, AV_LOG_ERROR, "Insufficient extradata size %d\n",
avctx->extradata_size);
if (AV_RB32(avctx->extradata) < avctx->extradata_size) {
av_log(avctx, AV_LOG_ERROR,
"Insufficient extradata size: expected %d got %d\n",
AV_RB32(avctx->extradata),
avctx->extradata_size);
avctx->coded_width = AV_RB32(avctx->extradata + 20);
avctx->coded_height = AV_RB32(avctx->extradata + 24);
if (avctx->coded_width > 4096 || avctx->coded_height > 4096) {
av_log(avctx, AV_LOG_ERROR, "Frame dimensions %dx%d too large",
av_log(avctx, AV_LOG_DEBUG, "Encoder version %d.%d\n",
AV_RB32(avctx->extradata + 4), AV_RB32(avctx->extradata + 8));
if (version != AV_RB32(avctx->extradata + 4) > 1) {
av_log(avctx, AV_LOG_ERROR,
"Header version doesn't match codec tag\n");
return -1;
c->free_colours = AV_RB32(avctx->extradata + 48);
if ((unsigned)c->free_colours > 256) {
av_log(avctx, AV_LOG_ERROR,
"Incorrect number of changeable palette entries: %d\n",
c->free_colours);
av_log(avctx, AV_LOG_DEBUG, "%d free colour(s)\n", c->free_colours);
av_log(avctx, AV_LOG_DEBUG, "Display dimensions %dx%d\n",
AV_RB32(avctx->extradata + 12), AV_RB32(avctx->extradata + 16));
av_log(avctx, AV_LOG_DEBUG, "Coded dimensions %dx%d\n",
av_log(avctx, AV_LOG_DEBUG, "%g frames per second\n",
av_int2float(AV_RB32(avctx->extradata + 28)));
av_log(avctx, AV_LOG_DEBUG, "Bitrate %d bps\n",
AV_RB32(avctx->extradata + 32));
av_log(avctx, AV_LOG_DEBUG, "Max. lead time %g ms\n",
av_int2float(AV_RB32(avctx->extradata + 36)));
av_log(avctx, AV_LOG_DEBUG, "Max. lag time %g ms\n",
av_int2float(AV_RB32(avctx->extradata + 40)));
av_log(avctx, AV_LOG_DEBUG, "Max. seek time %g ms\n",
av_int2float(AV_RB32(avctx->extradata + 44)));
if (version) {
if (avctx->extradata_size < 60 + 256 * 3) {
av_log(avctx, AV_LOG_ERROR,
"Insufficient extradata size %d for v2\n",
avctx->extradata_size);
c->slice_split = AV_RB32(avctx->extradata + 52);
av_log(avctx, AV_LOG_DEBUG, "Slice split %d\n", c->slice_split);
c->full_model_syms = AV_RB32(avctx->extradata + 56);
if (c->full_model_syms < 2 || c->full_model_syms > 256) {
av_log(avctx, AV_LOG_ERROR,
"Incorrect number of used colours %d\n",
c->full_model_syms);
av_log(avctx, AV_LOG_DEBUG, "Used colours %d\n",
c->full_model_syms);
} else {
c->slice_split = 0;
c->full_model_syms = 256;
for (i = 0; i < 256; i++)
c->pal[i] = 0xFFU << 24 | AV_RB24(avctx->extradata + 52 +
(version ? 8 : 0) + i * 3);
c->mask_stride = FFALIGN(avctx->width, 16);
c->mask = av_malloc(c->mask_stride * avctx->height);
if (!c->mask) {
av_log(avctx, AV_LOG_ERROR, "Cannot allocate mask plane\n");
return AVERROR(ENOMEM);
sc1->c = c;
slicecontext_init(sc1, version, c->full_model_syms);
if (c->slice_split) {
sc2->c = c;
slicecontext_init(sc2, version, c->full_model_syms);
c->corrupted = 1;
return 0;
| {
"code": [],
"line_no": []
} | av_cold int FUNC_0(MSS12Context *c, int version,
SliceContext* sc1, SliceContext *sc2)
{
AVCodecContext *avctx = c->avctx;
int VAR_0;
if (avctx->extradata_size < 52 + 256 * 3) {
av_log(avctx, AV_LOG_ERROR, "Insufficient extradata size %d\n",
avctx->extradata_size);
if (AV_RB32(avctx->extradata) < avctx->extradata_size) {
av_log(avctx, AV_LOG_ERROR,
"Insufficient extradata size: expected %d got %d\n",
AV_RB32(avctx->extradata),
avctx->extradata_size);
avctx->coded_width = AV_RB32(avctx->extradata + 20);
avctx->coded_height = AV_RB32(avctx->extradata + 24);
if (avctx->coded_width > 4096 || avctx->coded_height > 4096) {
av_log(avctx, AV_LOG_ERROR, "Frame dimensions %dx%d too large",
av_log(avctx, AV_LOG_DEBUG, "Encoder version %d.%d\n",
AV_RB32(avctx->extradata + 4), AV_RB32(avctx->extradata + 8));
if (version != AV_RB32(avctx->extradata + 4) > 1) {
av_log(avctx, AV_LOG_ERROR,
"Header version doesn't match codec tag\n");
return -1;
c->free_colours = AV_RB32(avctx->extradata + 48);
if ((unsigned)c->free_colours > 256) {
av_log(avctx, AV_LOG_ERROR,
"Incorrect number of changeable palette entries: %d\n",
c->free_colours);
av_log(avctx, AV_LOG_DEBUG, "%d free colour(s)\n", c->free_colours);
av_log(avctx, AV_LOG_DEBUG, "Display dimensions %dx%d\n",
AV_RB32(avctx->extradata + 12), AV_RB32(avctx->extradata + 16));
av_log(avctx, AV_LOG_DEBUG, "Coded dimensions %dx%d\n",
av_log(avctx, AV_LOG_DEBUG, "%g frames per second\n",
av_int2float(AV_RB32(avctx->extradata + 28)));
av_log(avctx, AV_LOG_DEBUG, "Bitrate %d bps\n",
AV_RB32(avctx->extradata + 32));
av_log(avctx, AV_LOG_DEBUG, "Max. lead time %g ms\n",
av_int2float(AV_RB32(avctx->extradata + 36)));
av_log(avctx, AV_LOG_DEBUG, "Max. lag time %g ms\n",
av_int2float(AV_RB32(avctx->extradata + 40)));
av_log(avctx, AV_LOG_DEBUG, "Max. seek time %g ms\n",
av_int2float(AV_RB32(avctx->extradata + 44)));
if (version) {
if (avctx->extradata_size < 60 + 256 * 3) {
av_log(avctx, AV_LOG_ERROR,
"Insufficient extradata size %d for v2\n",
avctx->extradata_size);
c->slice_split = AV_RB32(avctx->extradata + 52);
av_log(avctx, AV_LOG_DEBUG, "Slice split %d\n", c->slice_split);
c->full_model_syms = AV_RB32(avctx->extradata + 56);
if (c->full_model_syms < 2 || c->full_model_syms > 256) {
av_log(avctx, AV_LOG_ERROR,
"Incorrect number of used colours %d\n",
c->full_model_syms);
av_log(avctx, AV_LOG_DEBUG, "Used colours %d\n",
c->full_model_syms);
} else {
c->slice_split = 0;
c->full_model_syms = 256;
for (VAR_0 = 0; VAR_0 < 256; VAR_0++)
c->pal[VAR_0] = 0xFFU << 24 | AV_RB24(avctx->extradata + 52 +
(version ? 8 : 0) + VAR_0 * 3);
c->mask_stride = FFALIGN(avctx->width, 16);
c->mask = av_malloc(c->mask_stride * avctx->height);
if (!c->mask) {
av_log(avctx, AV_LOG_ERROR, "Cannot allocate mask plane\n");
return AVERROR(ENOMEM);
sc1->c = c;
slicecontext_init(sc1, version, c->full_model_syms);
if (c->slice_split) {
sc2->c = c;
slicecontext_init(sc2, version, c->full_model_syms);
c->corrupted = 1;
return 0;
| [
"av_cold int FUNC_0(MSS12Context *c, int version,\nSliceContext* sc1, SliceContext *sc2)\n{",
"AVCodecContext *avctx = c->avctx;",
"int VAR_0;",
"if (avctx->extradata_size < 52 + 256 * 3) {",
"av_log(avctx, AV_LOG_ERROR, \"Insufficient extradata size %d\\n\",\navctx->extradata_size);",
"if (AV_RB32(avctx->extradata) < avctx->extradata_size) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Insufficient extradata size: expected %d got %d\\n\",\nAV_RB32(avctx->extradata),\navctx->extradata_size);",
"avctx->coded_width = AV_RB32(avctx->extradata + 20);",
"avctx->coded_height = AV_RB32(avctx->extradata + 24);",
"if (avctx->coded_width > 4096 || avctx->coded_height > 4096) {",
"av_log(avctx, AV_LOG_ERROR, \"Frame dimensions %dx%d too large\",\nav_log(avctx, AV_LOG_DEBUG, \"Encoder version %d.%d\\n\",\nAV_RB32(avctx->extradata + 4), AV_RB32(avctx->extradata + 8));",
"if (version != AV_RB32(avctx->extradata + 4) > 1) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Header version doesn't match codec tag\\n\");",
"return -1;",
"c->free_colours = AV_RB32(avctx->extradata + 48);",
"if ((unsigned)c->free_colours > 256) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Incorrect number of changeable palette entries: %d\\n\",\nc->free_colours);",
"av_log(avctx, AV_LOG_DEBUG, \"%d free colour(s)\\n\", c->free_colours);",
"av_log(avctx, AV_LOG_DEBUG, \"Display dimensions %dx%d\\n\",\nAV_RB32(avctx->extradata + 12), AV_RB32(avctx->extradata + 16));",
"av_log(avctx, AV_LOG_DEBUG, \"Coded dimensions %dx%d\\n\",\nav_log(avctx, AV_LOG_DEBUG, \"%g frames per second\\n\",\nav_int2float(AV_RB32(avctx->extradata + 28)));",
"av_log(avctx, AV_LOG_DEBUG, \"Bitrate %d bps\\n\",\nAV_RB32(avctx->extradata + 32));",
"av_log(avctx, AV_LOG_DEBUG, \"Max. lead time %g ms\\n\",\nav_int2float(AV_RB32(avctx->extradata + 36)));",
"av_log(avctx, AV_LOG_DEBUG, \"Max. lag time %g ms\\n\",\nav_int2float(AV_RB32(avctx->extradata + 40)));",
"av_log(avctx, AV_LOG_DEBUG, \"Max. seek time %g ms\\n\",\nav_int2float(AV_RB32(avctx->extradata + 44)));",
"if (version) {",
"if (avctx->extradata_size < 60 + 256 * 3) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Insufficient extradata size %d for v2\\n\",\navctx->extradata_size);",
"c->slice_split = AV_RB32(avctx->extradata + 52);",
"av_log(avctx, AV_LOG_DEBUG, \"Slice split %d\\n\", c->slice_split);",
"c->full_model_syms = AV_RB32(avctx->extradata + 56);",
"if (c->full_model_syms < 2 || c->full_model_syms > 256) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Incorrect number of used colours %d\\n\",\nc->full_model_syms);",
"av_log(avctx, AV_LOG_DEBUG, \"Used colours %d\\n\",\nc->full_model_syms);",
"} else {",
"c->slice_split = 0;",
"c->full_model_syms = 256;",
"for (VAR_0 = 0; VAR_0 < 256; VAR_0++)",
"c->pal[VAR_0] = 0xFFU << 24 | AV_RB24(avctx->extradata + 52 +\n(version ? 8 : 0) + VAR_0 * 3);",
"c->mask_stride = FFALIGN(avctx->width, 16);",
"c->mask = av_malloc(c->mask_stride * avctx->height);",
"if (!c->mask) {",
"av_log(avctx, AV_LOG_ERROR, \"Cannot allocate mask plane\\n\");",
"return AVERROR(ENOMEM);",
"sc1->c = c;",
"slicecontext_init(sc1, version, c->full_model_syms);",
"if (c->slice_split) {",
"sc2->c = c;",
"slicecontext_init(sc2, version, c->full_model_syms);",
"c->corrupted = 1;",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
23
],
[
25,
27,
29,
31
],
[
37
],
[
39
],
[
41
],
[
43,
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
70
],
[
72
],
[
74,
76,
78
],
[
82
],
[
86,
88
],
[
90,
93,
95
],
[
97,
99
],
[
101,
103
],
[
105,
107
],
[
109,
111
],
[
115
],
[
117
],
[
119,
121,
123
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139,
141,
143
],
[
147,
149
],
[
151
],
[
153
],
[
155
],
[
160
],
[
162,
164
],
[
168
],
[
170
],
[
172
],
[
174
],
[
176
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
192
],
[
196
]
] |
19,418 | static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code)
{
AVFormatContext *s = nut->avf;
AVIOContext *bc = s->pb;
int size, stream_id, discard;
int64_t pts, last_IP_pts;
StreamContext *stc;
uint8_t header_idx;
size = decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);
if (size < 0)
return size;
stc = &nut->stream[stream_id];
if (stc->last_flags & FLAG_KEY)
stc->skip_until_key_frame = 0;
discard = s->streams[stream_id]->discard;
last_IP_pts = s->streams[stream_id]->last_IP_pts;
if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||
(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE &&
last_IP_pts > pts) ||
discard >= AVDISCARD_ALL ||
stc->skip_until_key_frame) {
avio_skip(bc, size);
return 1;
}
if (av_new_packet(pkt, size + nut->header_len[header_idx]) < 0)
return AVERROR(ENOMEM);
memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
pkt->pos = avio_tell(bc); // FIXME
if (stc->last_flags & FLAG_SM_DATA) {
int sm_size;
if (read_sm_data(s, bc, pkt, 0, pkt->pos + size) < 0)
return AVERROR_INVALIDDATA;
if (read_sm_data(s, bc, pkt, 1, pkt->pos + size) < 0)
return AVERROR_INVALIDDATA;
sm_size = avio_tell(bc) - pkt->pos;
size -= sm_size;
pkt->size -= sm_size;
}
avio_read(bc, pkt->data + nut->header_len[header_idx], size);
pkt->stream_index = stream_id;
if (stc->last_flags & FLAG_KEY)
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->pts = pts;
return 0;
}
| true | FFmpeg | 71fe97a60ad7dd6fe15238ca0eee1ed3121b5f80 | static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code)
{
AVFormatContext *s = nut->avf;
AVIOContext *bc = s->pb;
int size, stream_id, discard;
int64_t pts, last_IP_pts;
StreamContext *stc;
uint8_t header_idx;
size = decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);
if (size < 0)
return size;
stc = &nut->stream[stream_id];
if (stc->last_flags & FLAG_KEY)
stc->skip_until_key_frame = 0;
discard = s->streams[stream_id]->discard;
last_IP_pts = s->streams[stream_id]->last_IP_pts;
if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||
(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE &&
last_IP_pts > pts) ||
discard >= AVDISCARD_ALL ||
stc->skip_until_key_frame) {
avio_skip(bc, size);
return 1;
}
if (av_new_packet(pkt, size + nut->header_len[header_idx]) < 0)
return AVERROR(ENOMEM);
memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
pkt->pos = avio_tell(bc);
if (stc->last_flags & FLAG_SM_DATA) {
int sm_size;
if (read_sm_data(s, bc, pkt, 0, pkt->pos + size) < 0)
return AVERROR_INVALIDDATA;
if (read_sm_data(s, bc, pkt, 1, pkt->pos + size) < 0)
return AVERROR_INVALIDDATA;
sm_size = avio_tell(bc) - pkt->pos;
size -= sm_size;
pkt->size -= sm_size;
}
avio_read(bc, pkt->data + nut->header_len[header_idx], size);
pkt->stream_index = stream_id;
if (stc->last_flags & FLAG_KEY)
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->pts = pts;
return 0;
}
| {
"code": [
" avio_read(bc, pkt->data + nut->header_len[header_idx], size);"
],
"line_no": [
89
]
} | static int FUNC_0(NUTContext *VAR_0, AVPacket *VAR_1, int VAR_2)
{
AVFormatContext *s = VAR_0->avf;
AVIOContext *bc = s->pb;
int VAR_3, VAR_4, VAR_5;
int64_t pts, last_IP_pts;
StreamContext *stc;
uint8_t header_idx;
VAR_3 = decode_frame_header(VAR_0, &pts, &VAR_4, &header_idx, VAR_2);
if (VAR_3 < 0)
return VAR_3;
stc = &VAR_0->stream[VAR_4];
if (stc->last_flags & FLAG_KEY)
stc->skip_until_key_frame = 0;
VAR_5 = s->streams[VAR_4]->VAR_5;
last_IP_pts = s->streams[VAR_4]->last_IP_pts;
if ((VAR_5 >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||
(VAR_5 >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE &&
last_IP_pts > pts) ||
VAR_5 >= AVDISCARD_ALL ||
stc->skip_until_key_frame) {
avio_skip(bc, VAR_3);
return 1;
}
if (av_new_packet(VAR_1, VAR_3 + VAR_0->header_len[header_idx]) < 0)
return AVERROR(ENOMEM);
memcpy(VAR_1->data, VAR_0->header[header_idx], VAR_0->header_len[header_idx]);
VAR_1->pos = avio_tell(bc);
if (stc->last_flags & FLAG_SM_DATA) {
int VAR_6;
if (read_sm_data(s, bc, VAR_1, 0, VAR_1->pos + VAR_3) < 0)
return AVERROR_INVALIDDATA;
if (read_sm_data(s, bc, VAR_1, 1, VAR_1->pos + VAR_3) < 0)
return AVERROR_INVALIDDATA;
VAR_6 = avio_tell(bc) - VAR_1->pos;
VAR_3 -= VAR_6;
VAR_1->VAR_3 -= VAR_6;
}
avio_read(bc, VAR_1->data + VAR_0->header_len[header_idx], VAR_3);
VAR_1->stream_index = VAR_4;
if (stc->last_flags & FLAG_KEY)
VAR_1->flags |= AV_PKT_FLAG_KEY;
VAR_1->pts = pts;
return 0;
}
| [
"static int FUNC_0(NUTContext *VAR_0, AVPacket *VAR_1, int VAR_2)\n{",
"AVFormatContext *s = VAR_0->avf;",
"AVIOContext *bc = s->pb;",
"int VAR_3, VAR_4, VAR_5;",
"int64_t pts, last_IP_pts;",
"StreamContext *stc;",
"uint8_t header_idx;",
"VAR_3 = decode_frame_header(VAR_0, &pts, &VAR_4, &header_idx, VAR_2);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"stc = &VAR_0->stream[VAR_4];",
"if (stc->last_flags & FLAG_KEY)\nstc->skip_until_key_frame = 0;",
"VAR_5 = s->streams[VAR_4]->VAR_5;",
"last_IP_pts = s->streams[VAR_4]->last_IP_pts;",
"if ((VAR_5 >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||\n(VAR_5 >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE &&\nlast_IP_pts > pts) ||\nVAR_5 >= AVDISCARD_ALL ||\nstc->skip_until_key_frame) {",
"avio_skip(bc, VAR_3);",
"return 1;",
"}",
"if (av_new_packet(VAR_1, VAR_3 + VAR_0->header_len[header_idx]) < 0)\nreturn AVERROR(ENOMEM);",
"memcpy(VAR_1->data, VAR_0->header[header_idx], VAR_0->header_len[header_idx]);",
"VAR_1->pos = avio_tell(bc);",
"if (stc->last_flags & FLAG_SM_DATA) {",
"int VAR_6;",
"if (read_sm_data(s, bc, VAR_1, 0, VAR_1->pos + VAR_3) < 0)\nreturn AVERROR_INVALIDDATA;",
"if (read_sm_data(s, bc, VAR_1, 1, VAR_1->pos + VAR_3) < 0)\nreturn AVERROR_INVALIDDATA;",
"VAR_6 = avio_tell(bc) - VAR_1->pos;",
"VAR_3 -= VAR_6;",
"VAR_1->VAR_3 -= VAR_6;",
"}",
"avio_read(bc, VAR_1->data + VAR_0->header_len[header_idx], VAR_3);",
"VAR_1->stream_index = VAR_4;",
"if (stc->last_flags & FLAG_KEY)\nVAR_1->flags |= AV_PKT_FLAG_KEY;",
"VAR_1->pts = pts;",
"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,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
27
],
[
31,
33
],
[
37
],
[
39
],
[
41,
43,
45,
47,
49
],
[
51
],
[
53
],
[
55
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
93
],
[
95,
97
],
[
99
],
[
103
],
[
105
]
] |
19,419 | static int rm_assemble_video_frame(AVFormatContext *s, ByteIOContext *pb,
RMDemuxContext *rm, RMStream *vst,
AVPacket *pkt, int len, int *pseq)
{
int hdr, seq, pic_num, len2, pos;
int type;
hdr = get_byte(pb); len--;
type = hdr >> 6;
if(type != 3){ // not frame as a part of packet
seq = get_byte(pb); len--;
}
if(type != 1){ // not whole frame
len2 = get_num(pb, &len);
pos = get_num(pb, &len);
pic_num = get_byte(pb); len--;
}
if(len<0)
return -1;
rm->remaining_len = len;
if(type&1){ // frame, not slice
if(type == 3) // frame as a part of packet
len= len2;
if(rm->remaining_len < len)
return -1;
rm->remaining_len -= len;
if(av_new_packet(pkt, len + 9) < 0)
return AVERROR(EIO);
pkt->data[0] = 0;
AV_WL32(pkt->data + 1, 1);
AV_WL32(pkt->data + 5, 0);
get_buffer(pb, pkt->data + 9, len);
return 0;
}
//now we have to deal with single slice
*pseq = seq;
if((seq & 0x7F) == 1 || vst->curpic_num != pic_num){
vst->slices = ((hdr & 0x3F) << 1) + 1;
vst->videobufsize = len2 + 8*vst->slices + 1;
av_free_packet(&vst->pkt); //FIXME this should be output.
if(av_new_packet(&vst->pkt, vst->videobufsize) < 0)
return AVERROR(ENOMEM);
vst->videobufpos = 8*vst->slices + 1;
vst->cur_slice = 0;
vst->curpic_num = pic_num;
vst->pktpos = url_ftell(pb);
}
if(type == 2)
len = FFMIN(len, pos);
if(++vst->cur_slice > vst->slices)
return 1;
AV_WL32(vst->pkt.data - 7 + 8*vst->cur_slice, 1);
AV_WL32(vst->pkt.data - 3 + 8*vst->cur_slice, vst->videobufpos - 8*vst->slices - 1);
if(vst->videobufpos + len > vst->videobufsize)
return 1;
if (get_buffer(pb, vst->pkt.data + vst->videobufpos, len) != len)
return AVERROR(EIO);
vst->videobufpos += len;
rm->remaining_len-= len;
if(type == 2 || (vst->videobufpos) == vst->videobufsize){
vst->pkt.data[0] = vst->cur_slice-1;
*pkt= vst->pkt;
vst->pkt.data= NULL;
vst->pkt.size= 0;
if(vst->slices != vst->cur_slice) //FIXME find out how to set slices correct from the begin
memmove(pkt->data + 1 + 8*vst->cur_slice, pkt->data + 1 + 8*vst->slices,
vst->videobufpos - 1 - 8*vst->slices);
pkt->size = vst->videobufpos + 8*(vst->cur_slice - vst->slices);
pkt->pts = AV_NOPTS_VALUE;
pkt->pos = vst->pktpos;
return 0;
}
return 1;
} | true | FFmpeg | cbb5da57cdaf547e47253beef31ddf38d181252a | static int rm_assemble_video_frame(AVFormatContext *s, ByteIOContext *pb,
RMDemuxContext *rm, RMStream *vst,
AVPacket *pkt, int len, int *pseq)
{
int hdr, seq, pic_num, len2, pos;
int type;
hdr = get_byte(pb); len--;
type = hdr >> 6;
if(type != 3){
seq = get_byte(pb); len--;
}
if(type != 1){
len2 = get_num(pb, &len);
pos = get_num(pb, &len);
pic_num = get_byte(pb); len--;
}
if(len<0)
return -1;
rm->remaining_len = len;
if(type&1){
if(type == 3)
len= len2;
if(rm->remaining_len < len)
return -1;
rm->remaining_len -= len;
if(av_new_packet(pkt, len + 9) < 0)
return AVERROR(EIO);
pkt->data[0] = 0;
AV_WL32(pkt->data + 1, 1);
AV_WL32(pkt->data + 5, 0);
get_buffer(pb, pkt->data + 9, len);
return 0;
}
*pseq = seq;
if((seq & 0x7F) == 1 || vst->curpic_num != pic_num){
vst->slices = ((hdr & 0x3F) << 1) + 1;
vst->videobufsize = len2 + 8*vst->slices + 1;
av_free_packet(&vst->pkt);
if(av_new_packet(&vst->pkt, vst->videobufsize) < 0)
return AVERROR(ENOMEM);
vst->videobufpos = 8*vst->slices + 1;
vst->cur_slice = 0;
vst->curpic_num = pic_num;
vst->pktpos = url_ftell(pb);
}
if(type == 2)
len = FFMIN(len, pos);
if(++vst->cur_slice > vst->slices)
return 1;
AV_WL32(vst->pkt.data - 7 + 8*vst->cur_slice, 1);
AV_WL32(vst->pkt.data - 3 + 8*vst->cur_slice, vst->videobufpos - 8*vst->slices - 1);
if(vst->videobufpos + len > vst->videobufsize)
return 1;
if (get_buffer(pb, vst->pkt.data + vst->videobufpos, len) != len)
return AVERROR(EIO);
vst->videobufpos += len;
rm->remaining_len-= len;
if(type == 2 || (vst->videobufpos) == vst->videobufsize){
vst->pkt.data[0] = vst->cur_slice-1;
*pkt= vst->pkt;
vst->pkt.data= NULL;
vst->pkt.size= 0;
if(vst->slices != vst->cur_slice)
memmove(pkt->data + 1 + 8*vst->cur_slice, pkt->data + 1 + 8*vst->slices,
vst->videobufpos - 1 - 8*vst->slices);
pkt->size = vst->videobufpos + 8*(vst->cur_slice - vst->slices);
pkt->pts = AV_NOPTS_VALUE;
pkt->pos = vst->pktpos;
return 0;
}
return 1;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, ByteIOContext *VAR_1,
RMDemuxContext *VAR_2, RMStream *VAR_3,
AVPacket *VAR_4, int VAR_5, int *VAR_6)
{
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;
int VAR_12;
VAR_7 = get_byte(VAR_1); VAR_5--;
VAR_12 = VAR_7 >> 6;
if(VAR_12 != 3){
VAR_8 = get_byte(VAR_1); VAR_5--;
}
if(VAR_12 != 1){
VAR_10 = get_num(VAR_1, &VAR_5);
VAR_11 = get_num(VAR_1, &VAR_5);
VAR_9 = get_byte(VAR_1); VAR_5--;
}
if(VAR_5<0)
return -1;
VAR_2->remaining_len = VAR_5;
if(VAR_12&1){
if(VAR_12 == 3)
VAR_5= VAR_10;
if(VAR_2->remaining_len < VAR_5)
return -1;
VAR_2->remaining_len -= VAR_5;
if(av_new_packet(VAR_4, VAR_5 + 9) < 0)
return AVERROR(EIO);
VAR_4->data[0] = 0;
AV_WL32(VAR_4->data + 1, 1);
AV_WL32(VAR_4->data + 5, 0);
get_buffer(VAR_1, VAR_4->data + 9, VAR_5);
return 0;
}
*VAR_6 = VAR_8;
if((VAR_8 & 0x7F) == 1 || VAR_3->curpic_num != VAR_9){
VAR_3->slices = ((VAR_7 & 0x3F) << 1) + 1;
VAR_3->videobufsize = VAR_10 + 8*VAR_3->slices + 1;
av_free_packet(&VAR_3->VAR_4);
if(av_new_packet(&VAR_3->VAR_4, VAR_3->videobufsize) < 0)
return AVERROR(ENOMEM);
VAR_3->videobufpos = 8*VAR_3->slices + 1;
VAR_3->cur_slice = 0;
VAR_3->curpic_num = VAR_9;
VAR_3->pktpos = url_ftell(VAR_1);
}
if(VAR_12 == 2)
VAR_5 = FFMIN(VAR_5, VAR_11);
if(++VAR_3->cur_slice > VAR_3->slices)
return 1;
AV_WL32(VAR_3->VAR_4.data - 7 + 8*VAR_3->cur_slice, 1);
AV_WL32(VAR_3->VAR_4.data - 3 + 8*VAR_3->cur_slice, VAR_3->videobufpos - 8*VAR_3->slices - 1);
if(VAR_3->videobufpos + VAR_5 > VAR_3->videobufsize)
return 1;
if (get_buffer(VAR_1, VAR_3->VAR_4.data + VAR_3->videobufpos, VAR_5) != VAR_5)
return AVERROR(EIO);
VAR_3->videobufpos += VAR_5;
VAR_2->remaining_len-= VAR_5;
if(VAR_12 == 2 || (VAR_3->videobufpos) == VAR_3->videobufsize){
VAR_3->VAR_4.data[0] = VAR_3->cur_slice-1;
*VAR_4= VAR_3->VAR_4;
VAR_3->VAR_4.data= NULL;
VAR_3->VAR_4.size= 0;
if(VAR_3->slices != VAR_3->cur_slice)
memmove(VAR_4->data + 1 + 8*VAR_3->cur_slice, VAR_4->data + 1 + 8*VAR_3->slices,
VAR_3->videobufpos - 1 - 8*VAR_3->slices);
VAR_4->size = VAR_3->videobufpos + 8*(VAR_3->cur_slice - VAR_3->slices);
VAR_4->pts = AV_NOPTS_VALUE;
VAR_4->VAR_11 = VAR_3->pktpos;
return 0;
}
return 1;
} | [
"static int FUNC_0(AVFormatContext *VAR_0, ByteIOContext *VAR_1,\nRMDemuxContext *VAR_2, RMStream *VAR_3,\nAVPacket *VAR_4, int VAR_5, int *VAR_6)\n{",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;",
"int VAR_12;",
"VAR_7 = get_byte(VAR_1); VAR_5--;",
"VAR_12 = VAR_7 >> 6;",
"if(VAR_12 != 3){",
"VAR_8 = get_byte(VAR_1); VAR_5--;",
"}",
"if(VAR_12 != 1){",
"VAR_10 = get_num(VAR_1, &VAR_5);",
"VAR_11 = get_num(VAR_1, &VAR_5);",
"VAR_9 = get_byte(VAR_1); VAR_5--;",
"}",
"if(VAR_5<0)\nreturn -1;",
"VAR_2->remaining_len = VAR_5;",
"if(VAR_12&1){",
"if(VAR_12 == 3)\nVAR_5= VAR_10;",
"if(VAR_2->remaining_len < VAR_5)\nreturn -1;",
"VAR_2->remaining_len -= VAR_5;",
"if(av_new_packet(VAR_4, VAR_5 + 9) < 0)\nreturn AVERROR(EIO);",
"VAR_4->data[0] = 0;",
"AV_WL32(VAR_4->data + 1, 1);",
"AV_WL32(VAR_4->data + 5, 0);",
"get_buffer(VAR_1, VAR_4->data + 9, VAR_5);",
"return 0;",
"}",
"*VAR_6 = VAR_8;",
"if((VAR_8 & 0x7F) == 1 || VAR_3->curpic_num != VAR_9){",
"VAR_3->slices = ((VAR_7 & 0x3F) << 1) + 1;",
"VAR_3->videobufsize = VAR_10 + 8*VAR_3->slices + 1;",
"av_free_packet(&VAR_3->VAR_4);",
"if(av_new_packet(&VAR_3->VAR_4, VAR_3->videobufsize) < 0)\nreturn AVERROR(ENOMEM);",
"VAR_3->videobufpos = 8*VAR_3->slices + 1;",
"VAR_3->cur_slice = 0;",
"VAR_3->curpic_num = VAR_9;",
"VAR_3->pktpos = url_ftell(VAR_1);",
"}",
"if(VAR_12 == 2)\nVAR_5 = FFMIN(VAR_5, VAR_11);",
"if(++VAR_3->cur_slice > VAR_3->slices)\nreturn 1;",
"AV_WL32(VAR_3->VAR_4.data - 7 + 8*VAR_3->cur_slice, 1);",
"AV_WL32(VAR_3->VAR_4.data - 3 + 8*VAR_3->cur_slice, VAR_3->videobufpos - 8*VAR_3->slices - 1);",
"if(VAR_3->videobufpos + VAR_5 > VAR_3->videobufsize)\nreturn 1;",
"if (get_buffer(VAR_1, VAR_3->VAR_4.data + VAR_3->videobufpos, VAR_5) != VAR_5)\nreturn AVERROR(EIO);",
"VAR_3->videobufpos += VAR_5;",
"VAR_2->remaining_len-= VAR_5;",
"if(VAR_12 == 2 || (VAR_3->videobufpos) == VAR_3->videobufsize){",
"VAR_3->VAR_4.data[0] = VAR_3->cur_slice-1;",
"*VAR_4= VAR_3->VAR_4;",
"VAR_3->VAR_4.data= NULL;",
"VAR_3->VAR_4.size= 0;",
"if(VAR_3->slices != VAR_3->cur_slice)\nmemmove(VAR_4->data + 1 + 8*VAR_3->cur_slice, VAR_4->data + 1 + 8*VAR_3->slices,\nVAR_3->videobufpos - 1 - 8*VAR_3->slices);",
"VAR_4->size = VAR_3->videobufpos + 8*(VAR_3->cur_slice - VAR_3->slices);",
"VAR_4->pts = AV_NOPTS_VALUE;",
"VAR_4->VAR_11 = VAR_3->pktpos;",
"return 0;",
"}",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
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
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
105,
107
],
[
109
],
[
111
],
[
113,
115
],
[
117,
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139,
141
],
[
143
],
[
145
],
[
147
],
[
150
],
[
152
],
[
156
],
[
158
]
] |
19,420 | static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_t pos)
{
VideoPicture *vp;
double frame_delay, pts = pts1;
/* compute the exact PTS for the picture if it is omitted in the stream
* pts1 is the dts of the pkt / pts of the frame */
if (pts != 0) {
/* update video clock with pts, if present */
is->video_clock = pts;
} else {
pts = is->video_clock;
/* update video clock for next frame */
frame_delay = av_q2d(is->video_st->codec->time_base);
/* for MPEG2, the frame can be repeated, so we update the
clock accordingly */
frame_delay += src_frame->repeat_pict * (frame_delay * 0.5);
is->video_clock += frame_delay;
#if defined(DEBUG_SYNC) && 0
printf("frame_type=%c clock=%0.3f pts=%0.3f\n",
av_get_picture_type_char(src_frame->pict_type), pts, pts1);
#endif
/* wait until we have space to put a new picture */
SDL_LockMutex(is->pictq_mutex);
if(is->pictq_size>=VIDEO_PICTURE_QUEUE_SIZE && !is->refresh)
is->skip_frames= FFMAX(1.0 - FRAME_SKIP_FACTOR, is->skip_frames * (1.0-FRAME_SKIP_FACTOR));
while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&
!is->videoq.abort_request) {
SDL_UnlockMutex(is->pictq_mutex);
if (is->videoq.abort_request)
return -1;
vp = &is->pictq[is->pictq_windex];
vp->duration = frame_delay;
/* alloc or resize hardware picture buffer */
if (!vp->bmp ||
#if CONFIG_AVFILTER
vp->width != is->out_video_filter->inputs[0]->w ||
vp->height != is->out_video_filter->inputs[0]->h) {
#else
vp->width != is->video_st->codec->width ||
vp->height != is->video_st->codec->height) {
#endif
SDL_Event event;
vp->allocated = 0;
/* the allocation must be done in the main thread to avoid
locking problems */
event.type = FF_ALLOC_EVENT;
event.user.data1 = is;
SDL_PushEvent(&event);
/* wait until the picture is allocated */
SDL_LockMutex(is->pictq_mutex);
while (!vp->allocated && !is->videoq.abort_request) {
SDL_UnlockMutex(is->pictq_mutex);
if (is->videoq.abort_request)
return -1;
/* if the frame is not skipped, then display it */
if (vp->bmp) {
AVPicture pict;
#if CONFIG_AVFILTER
if(vp->picref)
avfilter_unref_buffer(vp->picref);
vp->picref = src_frame->opaque;
#endif
/* get a pointer on the bitmap */
SDL_LockYUVOverlay (vp->bmp);
memset(&pict,0,sizeof(AVPicture));
pict.data[0] = vp->bmp->pixels[0];
pict.data[1] = vp->bmp->pixels[2];
pict.data[2] = vp->bmp->pixels[1];
pict.linesize[0] = vp->bmp->pitches[0];
pict.linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1];
#if CONFIG_AVFILTER
//FIXME use direct rendering
av_picture_copy(&pict, (AVPicture *)src_frame,
vp->pix_fmt, vp->width, vp->height);
#else
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx,
vp->width, vp->height, vp->pix_fmt, vp->width, vp->height,
PIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL);
if (is->img_convert_ctx == NULL) {
fprintf(stderr, "Cannot initialize the conversion context\n");
exit(1);
sws_scale(is->img_convert_ctx, src_frame->data, src_frame->linesize,
0, vp->height, pict.data, pict.linesize);
#endif
/* update the bitmap content */
SDL_UnlockYUVOverlay(vp->bmp);
vp->pts = pts;
vp->pos = pos;
/* now we can update the picture count */
if (++is->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE)
is->pictq_windex = 0;
SDL_LockMutex(is->pictq_mutex);
vp->target_clock= compute_target_time(vp->pts, is);
is->pictq_size++;
SDL_UnlockMutex(is->pictq_mutex);
return 0;
| true | FFmpeg | 0a1cf6621067c4a85b519c8cad5c345c29017f89 | static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_t pos)
{
VideoPicture *vp;
double frame_delay, pts = pts1;
if (pts != 0) {
is->video_clock = pts;
} else {
pts = is->video_clock;
frame_delay = av_q2d(is->video_st->codec->time_base);
frame_delay += src_frame->repeat_pict * (frame_delay * 0.5);
is->video_clock += frame_delay;
#if defined(DEBUG_SYNC) && 0
printf("frame_type=%c clock=%0.3f pts=%0.3f\n",
av_get_picture_type_char(src_frame->pict_type), pts, pts1);
#endif
SDL_LockMutex(is->pictq_mutex);
if(is->pictq_size>=VIDEO_PICTURE_QUEUE_SIZE && !is->refresh)
is->skip_frames= FFMAX(1.0 - FRAME_SKIP_FACTOR, is->skip_frames * (1.0-FRAME_SKIP_FACTOR));
while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&
!is->videoq.abort_request) {
SDL_UnlockMutex(is->pictq_mutex);
if (is->videoq.abort_request)
return -1;
vp = &is->pictq[is->pictq_windex];
vp->duration = frame_delay;
if (!vp->bmp ||
#if CONFIG_AVFILTER
vp->width != is->out_video_filter->inputs[0]->w ||
vp->height != is->out_video_filter->inputs[0]->h) {
#else
vp->width != is->video_st->codec->width ||
vp->height != is->video_st->codec->height) {
#endif
SDL_Event event;
vp->allocated = 0;
event.type = FF_ALLOC_EVENT;
event.user.data1 = is;
SDL_PushEvent(&event);
SDL_LockMutex(is->pictq_mutex);
while (!vp->allocated && !is->videoq.abort_request) {
SDL_UnlockMutex(is->pictq_mutex);
if (is->videoq.abort_request)
return -1;
if (vp->bmp) {
AVPicture pict;
#if CONFIG_AVFILTER
if(vp->picref)
avfilter_unref_buffer(vp->picref);
vp->picref = src_frame->opaque;
#endif
SDL_LockYUVOverlay (vp->bmp);
memset(&pict,0,sizeof(AVPicture));
pict.data[0] = vp->bmp->pixels[0];
pict.data[1] = vp->bmp->pixels[2];
pict.data[2] = vp->bmp->pixels[1];
pict.linesize[0] = vp->bmp->pitches[0];
pict.linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1];
#if CONFIG_AVFILTER
av_picture_copy(&pict, (AVPicture *)src_frame,
vp->pix_fmt, vp->width, vp->height);
#else
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx,
vp->width, vp->height, vp->pix_fmt, vp->width, vp->height,
PIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL);
if (is->img_convert_ctx == NULL) {
fprintf(stderr, "Cannot initialize the conversion context\n");
exit(1);
sws_scale(is->img_convert_ctx, src_frame->data, src_frame->linesize,
0, vp->height, pict.data, pict.linesize);
#endif
SDL_UnlockYUVOverlay(vp->bmp);
vp->pts = pts;
vp->pos = pos;
if (++is->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE)
is->pictq_windex = 0;
SDL_LockMutex(is->pictq_mutex);
vp->target_clock= compute_target_time(vp->pts, is);
is->pictq_size++;
SDL_UnlockMutex(is->pictq_mutex);
return 0;
| {
"code": [],
"line_no": []
} | static int FUNC_0(VideoState *VAR_0, AVFrame *VAR_1, double VAR_2, int64_t VAR_3)
{
VideoPicture *vp;
double VAR_4, VAR_5 = VAR_2;
if (VAR_5 != 0) {
VAR_0->video_clock = VAR_5;
} else {
VAR_5 = VAR_0->video_clock;
VAR_4 = av_q2d(VAR_0->video_st->codec->time_base);
VAR_4 += VAR_1->repeat_pict * (VAR_4 * 0.5);
VAR_0->video_clock += VAR_4;
#if defined(DEBUG_SYNC) && 0
printf("frame_type=%c clock=%0.3f VAR_5=%0.3f\n",
av_get_picture_type_char(VAR_1->pict_type), VAR_5, VAR_2);
#endif
SDL_LockMutex(VAR_0->pictq_mutex);
if(VAR_0->pictq_size>=VIDEO_PICTURE_QUEUE_SIZE && !VAR_0->refresh)
VAR_0->skip_frames= FFMAX(1.0 - FRAME_SKIP_FACTOR, VAR_0->skip_frames * (1.0-FRAME_SKIP_FACTOR));
while (VAR_0->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&
!VAR_0->videoq.abort_request) {
SDL_UnlockMutex(VAR_0->pictq_mutex);
if (VAR_0->videoq.abort_request)
return -1;
vp = &VAR_0->pictq[VAR_0->pictq_windex];
vp->duration = VAR_4;
if (!vp->bmp ||
#if CONFIG_AVFILTER
vp->width != VAR_0->out_video_filter->inputs[0]->w ||
vp->height != VAR_0->out_video_filter->inputs[0]->h) {
#else
vp->width != VAR_0->video_st->codec->width ||
vp->height != VAR_0->video_st->codec->height) {
#endif
SDL_Event event;
vp->allocated = 0;
event.type = FF_ALLOC_EVENT;
event.user.data1 = VAR_0;
SDL_PushEvent(&event);
SDL_LockMutex(VAR_0->pictq_mutex);
while (!vp->allocated && !VAR_0->videoq.abort_request) {
SDL_UnlockMutex(VAR_0->pictq_mutex);
if (VAR_0->videoq.abort_request)
return -1;
if (vp->bmp) {
AVPicture pict;
#if CONFIG_AVFILTER
if(vp->picref)
avfilter_unref_buffer(vp->picref);
vp->picref = VAR_1->opaque;
#endif
SDL_LockYUVOverlay (vp->bmp);
memset(&pict,0,sizeof(AVPicture));
pict.data[0] = vp->bmp->pixels[0];
pict.data[1] = vp->bmp->pixels[2];
pict.data[2] = vp->bmp->pixels[1];
pict.linesize[0] = vp->bmp->pitches[0];
pict.linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1];
#if CONFIG_AVFILTER
av_picture_copy(&pict, (AVPicture *)VAR_1,
vp->pix_fmt, vp->width, vp->height);
#else
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
VAR_0->img_convert_ctx = sws_getCachedContext(VAR_0->img_convert_ctx,
vp->width, vp->height, vp->pix_fmt, vp->width, vp->height,
PIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL);
if (VAR_0->img_convert_ctx == NULL) {
fprintf(stderr, "Cannot initialize the conversion context\n");
exit(1);
sws_scale(VAR_0->img_convert_ctx, VAR_1->data, VAR_1->linesize,
0, vp->height, pict.data, pict.linesize);
#endif
SDL_UnlockYUVOverlay(vp->bmp);
vp->VAR_5 = VAR_5;
vp->VAR_3 = VAR_3;
if (++VAR_0->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE)
VAR_0->pictq_windex = 0;
SDL_LockMutex(VAR_0->pictq_mutex);
vp->target_clock= compute_target_time(vp->VAR_5, VAR_0);
VAR_0->pictq_size++;
SDL_UnlockMutex(VAR_0->pictq_mutex);
return 0;
| [
"static int FUNC_0(VideoState *VAR_0, AVFrame *VAR_1, double VAR_2, int64_t VAR_3)\n{",
"VideoPicture *vp;",
"double VAR_4, VAR_5 = VAR_2;",
"if (VAR_5 != 0) {",
"VAR_0->video_clock = VAR_5;",
"} else {",
"VAR_5 = VAR_0->video_clock;",
"VAR_4 = av_q2d(VAR_0->video_st->codec->time_base);",
"VAR_4 += VAR_1->repeat_pict * (VAR_4 * 0.5);",
"VAR_0->video_clock += VAR_4;",
"#if defined(DEBUG_SYNC) && 0\nprintf(\"frame_type=%c clock=%0.3f VAR_5=%0.3f\\n\",\nav_get_picture_type_char(VAR_1->pict_type), VAR_5, VAR_2);",
"#endif\nSDL_LockMutex(VAR_0->pictq_mutex);",
"if(VAR_0->pictq_size>=VIDEO_PICTURE_QUEUE_SIZE && !VAR_0->refresh)\nVAR_0->skip_frames= FFMAX(1.0 - FRAME_SKIP_FACTOR, VAR_0->skip_frames * (1.0-FRAME_SKIP_FACTOR));",
"while (VAR_0->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&\n!VAR_0->videoq.abort_request) {",
"SDL_UnlockMutex(VAR_0->pictq_mutex);",
"if (VAR_0->videoq.abort_request)\nreturn -1;",
"vp = &VAR_0->pictq[VAR_0->pictq_windex];",
"vp->duration = VAR_4;",
"if (!vp->bmp ||\n#if CONFIG_AVFILTER\nvp->width != VAR_0->out_video_filter->inputs[0]->w ||\nvp->height != VAR_0->out_video_filter->inputs[0]->h) {",
"#else\nvp->width != VAR_0->video_st->codec->width ||\nvp->height != VAR_0->video_st->codec->height) {",
"#endif\nSDL_Event event;",
"vp->allocated = 0;",
"event.type = FF_ALLOC_EVENT;",
"event.user.data1 = VAR_0;",
"SDL_PushEvent(&event);",
"SDL_LockMutex(VAR_0->pictq_mutex);",
"while (!vp->allocated && !VAR_0->videoq.abort_request) {",
"SDL_UnlockMutex(VAR_0->pictq_mutex);",
"if (VAR_0->videoq.abort_request)\nreturn -1;",
"if (vp->bmp) {",
"AVPicture pict;",
"#if CONFIG_AVFILTER\nif(vp->picref)\navfilter_unref_buffer(vp->picref);",
"vp->picref = VAR_1->opaque;",
"#endif\nSDL_LockYUVOverlay (vp->bmp);",
"memset(&pict,0,sizeof(AVPicture));",
"pict.data[0] = vp->bmp->pixels[0];",
"pict.data[1] = vp->bmp->pixels[2];",
"pict.data[2] = vp->bmp->pixels[1];",
"pict.linesize[0] = vp->bmp->pitches[0];",
"pict.linesize[1] = vp->bmp->pitches[2];",
"pict.linesize[2] = vp->bmp->pitches[1];",
"#if CONFIG_AVFILTER\nav_picture_copy(&pict, (AVPicture *)VAR_1,\nvp->pix_fmt, vp->width, vp->height);",
"#else\nsws_flags = av_get_int(sws_opts, \"sws_flags\", NULL);",
"VAR_0->img_convert_ctx = sws_getCachedContext(VAR_0->img_convert_ctx,\nvp->width, vp->height, vp->pix_fmt, vp->width, vp->height,\nPIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL);",
"if (VAR_0->img_convert_ctx == NULL) {",
"fprintf(stderr, \"Cannot initialize the conversion context\\n\");",
"exit(1);",
"sws_scale(VAR_0->img_convert_ctx, VAR_1->data, VAR_1->linesize,\n0, vp->height, pict.data, pict.linesize);",
"#endif\nSDL_UnlockYUVOverlay(vp->bmp);",
"vp->VAR_5 = VAR_5;",
"vp->VAR_3 = VAR_3;",
"if (++VAR_0->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE)\nVAR_0->pictq_windex = 0;",
"SDL_LockMutex(VAR_0->pictq_mutex);",
"vp->target_clock= compute_target_time(vp->VAR_5, VAR_0);",
"VAR_0->pictq_size++;",
"SDL_UnlockMutex(VAR_0->pictq_mutex);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
15
],
[
19
],
[
21
],
[
23
],
[
28
],
[
34
],
[
36
],
[
40,
42,
44
],
[
46,
52
],
[
56,
58
],
[
62,
64
],
[
68
],
[
72,
74
],
[
78
],
[
82
],
[
88,
90,
92,
94
],
[
96,
98,
100
],
[
102,
104
],
[
108
],
[
116
],
[
118
],
[
120
],
[
126
],
[
128
],
[
138
],
[
142,
144
],
[
151
],
[
153
],
[
155,
157,
159
],
[
161
],
[
163,
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
191,
195,
197
],
[
199,
201
],
[
203,
205,
207
],
[
209
],
[
211
],
[
213
],
[
216,
218
],
[
220,
224
],
[
228
],
[
230
],
[
236,
238
],
[
240
],
[
242
],
[
246
],
[
248
],
[
251
]
] |
19,421 | static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
{
AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
PCIRegion *pci_region = dev->real_device.regions;
int ret, pos;
/* Clear initial capabilities pointer and status copied from hw */
pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0);
pci_set_word(pci_dev->config + PCI_STATUS,
pci_get_word(pci_dev->config + PCI_STATUS) &
~PCI_STATUS_CAP_LIST);
/* Expose MSI capability
* MSI capability is the 1st capability in capability config */
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0);
if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {
if (!check_irqchip_in_kernel()) {
return -ENOTSUP;
}
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;
/* Only 32-bit/no-mask currently supported */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, 10);
if (ret < 0) {
return ret;
}
pci_dev->msi_cap = pos;
pci_set_word(pci_dev->config + pos + PCI_MSI_FLAGS,
pci_get_word(pci_dev->config + pos + PCI_MSI_FLAGS) &
PCI_MSI_FLAGS_QMASK);
pci_set_long(pci_dev->config + pos + PCI_MSI_ADDRESS_LO, 0);
pci_set_word(pci_dev->config + pos + PCI_MSI_DATA_32, 0);
/* Set writable fields */
pci_set_word(pci_dev->wmask + pos + PCI_MSI_FLAGS,
PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
pci_set_long(pci_dev->wmask + pos + PCI_MSI_ADDRESS_LO, 0xfffffffc);
pci_set_word(pci_dev->wmask + pos + PCI_MSI_DATA_32, 0xffff);
}
/* Expose MSI-X capability */
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0);
if (pos != 0 && kvm_device_msix_supported(kvm_state)) {
int bar_nr;
uint32_t msix_table_entry;
if (!check_irqchip_in_kernel()) {
return -ENOTSUP;
}
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX;
ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSIX, pos, 12);
if (ret < 0) {
return ret;
}
pci_dev->msix_cap = pos;
pci_set_word(pci_dev->config + pos + PCI_MSIX_FLAGS,
pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS) &
PCI_MSIX_FLAGS_QSIZE);
/* Only enable and function mask bits are writable */
pci_set_word(pci_dev->wmask + pos + PCI_MSIX_FLAGS,
PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);
msix_table_entry = pci_get_long(pci_dev->config + pos + PCI_MSIX_TABLE);
bar_nr = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK;
msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK;
dev->msix_table_addr = pci_region[bar_nr].base_addr + msix_table_entry;
dev->msix_max = pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS);
dev->msix_max &= PCI_MSIX_FLAGS_QSIZE;
dev->msix_max += 1;
}
/* Minimal PM support, nothing writable, device appears to NAK changes */
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PM, 0);
if (pos) {
uint16_t pmc;
ret = pci_add_capability(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF);
if (ret < 0) {
return ret;
}
assigned_dev_setup_cap_read(dev, pos, PCI_PM_SIZEOF);
pmc = pci_get_word(pci_dev->config + pos + PCI_CAP_FLAGS);
pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI);
pci_set_word(pci_dev->config + pos + PCI_CAP_FLAGS, pmc);
/* assign_device will bring the device up to D0, so we don't need
* to worry about doing that ourselves here. */
pci_set_word(pci_dev->config + pos + PCI_PM_CTRL,
PCI_PM_CTRL_NO_SOFT_RESET);
pci_set_byte(pci_dev->config + pos + PCI_PM_PPB_EXTENSIONS, 0);
pci_set_byte(pci_dev->config + pos + PCI_PM_DATA_REGISTER, 0);
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_EXP, 0);
if (pos) {
uint8_t version, size = 0;
uint16_t type, devctl, lnksta;
uint32_t devcap, lnkcap;
version = pci_get_byte(pci_dev->config + pos + PCI_EXP_FLAGS);
version &= PCI_EXP_FLAGS_VERS;
if (version == 1) {
size = 0x14;
} else if (version == 2) {
/*
* Check for non-std size, accept reduced size to 0x34,
* which is what bcm5761 implemented, violating the
* PCIe v3.0 spec that regs should exist and be read as 0,
* not optionally provided and shorten the struct size.
*/
size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - pos);
if (size < 0x34) {
error_report("%s: Invalid size PCIe cap-id 0x%x",
__func__, PCI_CAP_ID_EXP);
return -EINVAL;
} else if (size != 0x3c) {
error_report("WARNING, %s: PCIe cap-id 0x%x has "
"non-standard size 0x%x; std size should be 0x3c",
__func__, PCI_CAP_ID_EXP, size);
}
} else if (version == 0) {
uint16_t vid, did;
vid = pci_get_word(pci_dev->config + PCI_VENDOR_ID);
did = pci_get_word(pci_dev->config + PCI_DEVICE_ID);
if (vid == PCI_VENDOR_ID_INTEL && did == 0x10ed) {
/*
* quirk for Intel 82599 VF with invalid PCIe capability
* version, should really be version 2 (same as PF)
*/
size = 0x3c;
}
}
if (size == 0) {
error_report("%s: Unsupported PCI express capability version %d",
__func__, version);
return -EINVAL;
}
ret = pci_add_capability(pci_dev, PCI_CAP_ID_EXP, pos, size);
if (ret < 0) {
return ret;
}
assigned_dev_setup_cap_read(dev, pos, size);
type = pci_get_word(pci_dev->config + pos + PCI_EXP_FLAGS);
type = (type & PCI_EXP_FLAGS_TYPE) >> 4;
if (type != PCI_EXP_TYPE_ENDPOINT &&
type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) {
error_report("Device assignment only supports endpoint assignment,"
" device type %d", type);
return -EINVAL;
}
/* capabilities, pass existing read-only copy
* PCI_EXP_FLAGS_IRQ: updated by hardware, should be direct read */
/* device capabilities: hide FLR */
devcap = pci_get_long(pci_dev->config + pos + PCI_EXP_DEVCAP);
devcap &= ~PCI_EXP_DEVCAP_FLR;
pci_set_long(pci_dev->config + pos + PCI_EXP_DEVCAP, devcap);
/* device control: clear all error reporting enable bits, leaving
* only a few host values. Note, these are
* all writable, but not passed to hw.
*/
devctl = pci_get_word(pci_dev->config + pos + PCI_EXP_DEVCTL);
devctl = (devctl & (PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_PAYLOAD)) |
PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN;
pci_set_word(pci_dev->config + pos + PCI_EXP_DEVCTL, devctl);
devctl = PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_AUX_PME;
pci_set_word(pci_dev->wmask + pos + PCI_EXP_DEVCTL, ~devctl);
/* Clear device status */
pci_set_word(pci_dev->config + pos + PCI_EXP_DEVSTA, 0);
/* Link capabilities, expose links and latencues, clear reporting */
lnkcap = pci_get_long(pci_dev->config + pos + PCI_EXP_LNKCAP);
lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW |
PCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL |
PCI_EXP_LNKCAP_L1EL);
pci_set_long(pci_dev->config + pos + PCI_EXP_LNKCAP, lnkcap);
/* Link control, pass existing read-only copy. Should be writable? */
/* Link status, only expose current speed and width */
lnksta = pci_get_word(pci_dev->config + pos + PCI_EXP_LNKSTA);
lnksta &= (PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW);
pci_set_word(pci_dev->config + pos + PCI_EXP_LNKSTA, lnksta);
if (version >= 2) {
/* Slot capabilities, control, status - not needed for endpoints */
pci_set_long(pci_dev->config + pos + PCI_EXP_SLTCAP, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_SLTCTL, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_SLTSTA, 0);
/* Root control, capabilities, status - not needed for endpoints */
pci_set_word(pci_dev->config + pos + PCI_EXP_RTCTL, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_RTCAP, 0);
pci_set_long(pci_dev->config + pos + PCI_EXP_RTSTA, 0);
/* Device capabilities/control 2, pass existing read-only copy */
/* Link control 2, pass existing read-only copy */
}
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PCIX, 0);
if (pos) {
uint16_t cmd;
uint32_t status;
/* Only expose the minimum, 8 byte capability */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_PCIX, pos, 8);
if (ret < 0) {
return ret;
}
assigned_dev_setup_cap_read(dev, pos, 8);
/* Command register, clear upper bits, including extended modes */
cmd = pci_get_word(pci_dev->config + pos + PCI_X_CMD);
cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ |
PCI_X_CMD_MAX_SPLIT);
pci_set_word(pci_dev->config + pos + PCI_X_CMD, cmd);
/* Status register, update with emulated PCI bus location, clear
* error bits, leave the rest. */
status = pci_get_long(pci_dev->config + pos + PCI_X_STATUS);
status &= ~(PCI_X_STATUS_BUS | PCI_X_STATUS_DEVFN);
status |= (pci_bus_num(pci_dev->bus) << 8) | pci_dev->devfn;
status &= ~(PCI_X_STATUS_SPL_DISC | PCI_X_STATUS_UNX_SPL |
PCI_X_STATUS_SPL_ERR);
pci_set_long(pci_dev->config + pos + PCI_X_STATUS, status);
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VPD, 0);
if (pos) {
/* Direct R/W passthrough */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_VPD, pos, 8);
if (ret < 0) {
return ret;
}
assigned_dev_setup_cap_read(dev, pos, 8);
/* direct write for cap content */
assigned_dev_direct_config_write(dev, pos + 2, 6);
}
/* Devices can have multiple vendor capabilities, get them all */
for (pos = 0; (pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VNDR, pos));
pos += PCI_CAP_LIST_NEXT) {
uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS);
/* Direct R/W passthrough */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_VNDR, pos, len);
if (ret < 0) {
return ret;
}
assigned_dev_setup_cap_read(dev, pos, len);
/* direct write for cap content */
assigned_dev_direct_config_write(dev, pos + 2, len - 2);
}
/* If real and virtual capability list status bits differ, virtualize the
* access. */
if ((pci_get_word(pci_dev->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) !=
(assigned_dev_pci_read_byte(pci_dev, PCI_STATUS) &
PCI_STATUS_CAP_LIST)) {
dev->emulate_config_read[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
}
return 0;
}
| true | qemu | 665f119fbad97c05c2603673ac6b2dcbf0d0e9e1 | static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
{
AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
PCIRegion *pci_region = dev->real_device.regions;
int ret, pos;
pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0);
pci_set_word(pci_dev->config + PCI_STATUS,
pci_get_word(pci_dev->config + PCI_STATUS) &
~PCI_STATUS_CAP_LIST);
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0);
if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {
if (!check_irqchip_in_kernel()) {
return -ENOTSUP;
}
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;
ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, 10);
if (ret < 0) {
return ret;
}
pci_dev->msi_cap = pos;
pci_set_word(pci_dev->config + pos + PCI_MSI_FLAGS,
pci_get_word(pci_dev->config + pos + PCI_MSI_FLAGS) &
PCI_MSI_FLAGS_QMASK);
pci_set_long(pci_dev->config + pos + PCI_MSI_ADDRESS_LO, 0);
pci_set_word(pci_dev->config + pos + PCI_MSI_DATA_32, 0);
pci_set_word(pci_dev->wmask + pos + PCI_MSI_FLAGS,
PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
pci_set_long(pci_dev->wmask + pos + PCI_MSI_ADDRESS_LO, 0xfffffffc);
pci_set_word(pci_dev->wmask + pos + PCI_MSI_DATA_32, 0xffff);
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0);
if (pos != 0 && kvm_device_msix_supported(kvm_state)) {
int bar_nr;
uint32_t msix_table_entry;
if (!check_irqchip_in_kernel()) {
return -ENOTSUP;
}
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX;
ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSIX, pos, 12);
if (ret < 0) {
return ret;
}
pci_dev->msix_cap = pos;
pci_set_word(pci_dev->config + pos + PCI_MSIX_FLAGS,
pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS) &
PCI_MSIX_FLAGS_QSIZE);
pci_set_word(pci_dev->wmask + pos + PCI_MSIX_FLAGS,
PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);
msix_table_entry = pci_get_long(pci_dev->config + pos + PCI_MSIX_TABLE);
bar_nr = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK;
msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK;
dev->msix_table_addr = pci_region[bar_nr].base_addr + msix_table_entry;
dev->msix_max = pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS);
dev->msix_max &= PCI_MSIX_FLAGS_QSIZE;
dev->msix_max += 1;
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PM, 0);
if (pos) {
uint16_t pmc;
ret = pci_add_capability(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF);
if (ret < 0) {
return ret;
}
assigned_dev_setup_cap_read(dev, pos, PCI_PM_SIZEOF);
pmc = pci_get_word(pci_dev->config + pos + PCI_CAP_FLAGS);
pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI);
pci_set_word(pci_dev->config + pos + PCI_CAP_FLAGS, pmc);
pci_set_word(pci_dev->config + pos + PCI_PM_CTRL,
PCI_PM_CTRL_NO_SOFT_RESET);
pci_set_byte(pci_dev->config + pos + PCI_PM_PPB_EXTENSIONS, 0);
pci_set_byte(pci_dev->config + pos + PCI_PM_DATA_REGISTER, 0);
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_EXP, 0);
if (pos) {
uint8_t version, size = 0;
uint16_t type, devctl, lnksta;
uint32_t devcap, lnkcap;
version = pci_get_byte(pci_dev->config + pos + PCI_EXP_FLAGS);
version &= PCI_EXP_FLAGS_VERS;
if (version == 1) {
size = 0x14;
} else if (version == 2) {
size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - pos);
if (size < 0x34) {
error_report("%s: Invalid size PCIe cap-id 0x%x",
__func__, PCI_CAP_ID_EXP);
return -EINVAL;
} else if (size != 0x3c) {
error_report("WARNING, %s: PCIe cap-id 0x%x has "
"non-standard size 0x%x; std size should be 0x3c",
__func__, PCI_CAP_ID_EXP, size);
}
} else if (version == 0) {
uint16_t vid, did;
vid = pci_get_word(pci_dev->config + PCI_VENDOR_ID);
did = pci_get_word(pci_dev->config + PCI_DEVICE_ID);
if (vid == PCI_VENDOR_ID_INTEL && did == 0x10ed) {
size = 0x3c;
}
}
if (size == 0) {
error_report("%s: Unsupported PCI express capability version %d",
__func__, version);
return -EINVAL;
}
ret = pci_add_capability(pci_dev, PCI_CAP_ID_EXP, pos, size);
if (ret < 0) {
return ret;
}
assigned_dev_setup_cap_read(dev, pos, size);
type = pci_get_word(pci_dev->config + pos + PCI_EXP_FLAGS);
type = (type & PCI_EXP_FLAGS_TYPE) >> 4;
if (type != PCI_EXP_TYPE_ENDPOINT &&
type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) {
error_report("Device assignment only supports endpoint assignment,"
" device type %d", type);
return -EINVAL;
}
devcap = pci_get_long(pci_dev->config + pos + PCI_EXP_DEVCAP);
devcap &= ~PCI_EXP_DEVCAP_FLR;
pci_set_long(pci_dev->config + pos + PCI_EXP_DEVCAP, devcap);
devctl = pci_get_word(pci_dev->config + pos + PCI_EXP_DEVCTL);
devctl = (devctl & (PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_PAYLOAD)) |
PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN;
pci_set_word(pci_dev->config + pos + PCI_EXP_DEVCTL, devctl);
devctl = PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_AUX_PME;
pci_set_word(pci_dev->wmask + pos + PCI_EXP_DEVCTL, ~devctl);
pci_set_word(pci_dev->config + pos + PCI_EXP_DEVSTA, 0);
lnkcap = pci_get_long(pci_dev->config + pos + PCI_EXP_LNKCAP);
lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW |
PCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL |
PCI_EXP_LNKCAP_L1EL);
pci_set_long(pci_dev->config + pos + PCI_EXP_LNKCAP, lnkcap);
lnksta = pci_get_word(pci_dev->config + pos + PCI_EXP_LNKSTA);
lnksta &= (PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW);
pci_set_word(pci_dev->config + pos + PCI_EXP_LNKSTA, lnksta);
if (version >= 2) {
pci_set_long(pci_dev->config + pos + PCI_EXP_SLTCAP, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_SLTCTL, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_SLTSTA, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_RTCTL, 0);
pci_set_word(pci_dev->config + pos + PCI_EXP_RTCAP, 0);
pci_set_long(pci_dev->config + pos + PCI_EXP_RTSTA, 0);
}
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PCIX, 0);
if (pos) {
uint16_t cmd;
uint32_t status;
ret = pci_add_capability(pci_dev, PCI_CAP_ID_PCIX, pos, 8);
if (ret < 0) {
return ret;
}
assigned_dev_setup_cap_read(dev, pos, 8);
cmd = pci_get_word(pci_dev->config + pos + PCI_X_CMD);
cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ |
PCI_X_CMD_MAX_SPLIT);
pci_set_word(pci_dev->config + pos + PCI_X_CMD, cmd);
status = pci_get_long(pci_dev->config + pos + PCI_X_STATUS);
status &= ~(PCI_X_STATUS_BUS | PCI_X_STATUS_DEVFN);
status |= (pci_bus_num(pci_dev->bus) << 8) | pci_dev->devfn;
status &= ~(PCI_X_STATUS_SPL_DISC | PCI_X_STATUS_UNX_SPL |
PCI_X_STATUS_SPL_ERR);
pci_set_long(pci_dev->config + pos + PCI_X_STATUS, status);
}
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VPD, 0);
if (pos) {
ret = pci_add_capability(pci_dev, PCI_CAP_ID_VPD, pos, 8);
if (ret < 0) {
return ret;
}
assigned_dev_setup_cap_read(dev, pos, 8);
assigned_dev_direct_config_write(dev, pos + 2, 6);
}
for (pos = 0; (pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VNDR, pos));
pos += PCI_CAP_LIST_NEXT) {
uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS);
ret = pci_add_capability(pci_dev, PCI_CAP_ID_VNDR, pos, len);
if (ret < 0) {
return ret;
}
assigned_dev_setup_cap_read(dev, pos, len);
assigned_dev_direct_config_write(dev, pos + 2, len - 2);
}
if ((pci_get_word(pci_dev->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) !=
(assigned_dev_pci_read_byte(pci_dev, PCI_STATUS) &
PCI_STATUS_CAP_LIST)) {
dev->emulate_config_read[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
}
return 0;
}
| {
"code": [
" if (!check_irqchip_in_kernel()) {",
" if (!check_irqchip_in_kernel()) {"
],
"line_no": [
33,
33
]
} | static int FUNC_0(PCIDevice *VAR_0)
{
AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, VAR_0);
PCIRegion *pci_region = dev->real_device.regions;
int VAR_1, VAR_2;
pci_set_byte(VAR_0->config + PCI_CAPABILITY_LIST, 0);
pci_set_word(VAR_0->config + PCI_STATUS,
pci_get_word(VAR_0->config + PCI_STATUS) &
~PCI_STATUS_CAP_LIST);
VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_MSI, 0);
if (VAR_2 != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {
if (!check_irqchip_in_kernel()) {
return -ENOTSUP;
}
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;
VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_MSI, VAR_2, 10);
if (VAR_1 < 0) {
return VAR_1;
}
VAR_0->msi_cap = VAR_2;
pci_set_word(VAR_0->config + VAR_2 + PCI_MSI_FLAGS,
pci_get_word(VAR_0->config + VAR_2 + PCI_MSI_FLAGS) &
PCI_MSI_FLAGS_QMASK);
pci_set_long(VAR_0->config + VAR_2 + PCI_MSI_ADDRESS_LO, 0);
pci_set_word(VAR_0->config + VAR_2 + PCI_MSI_DATA_32, 0);
pci_set_word(VAR_0->wmask + VAR_2 + PCI_MSI_FLAGS,
PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
pci_set_long(VAR_0->wmask + VAR_2 + PCI_MSI_ADDRESS_LO, 0xfffffffc);
pci_set_word(VAR_0->wmask + VAR_2 + PCI_MSI_DATA_32, 0xffff);
}
VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_MSIX, 0);
if (VAR_2 != 0 && kvm_device_msix_supported(kvm_state)) {
int VAR_3;
uint32_t msix_table_entry;
if (!check_irqchip_in_kernel()) {
return -ENOTSUP;
}
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX;
VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_MSIX, VAR_2, 12);
if (VAR_1 < 0) {
return VAR_1;
}
VAR_0->msix_cap = VAR_2;
pci_set_word(VAR_0->config + VAR_2 + PCI_MSIX_FLAGS,
pci_get_word(VAR_0->config + VAR_2 + PCI_MSIX_FLAGS) &
PCI_MSIX_FLAGS_QSIZE);
pci_set_word(VAR_0->wmask + VAR_2 + PCI_MSIX_FLAGS,
PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);
msix_table_entry = pci_get_long(VAR_0->config + VAR_2 + PCI_MSIX_TABLE);
VAR_3 = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK;
msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK;
dev->msix_table_addr = pci_region[VAR_3].base_addr + msix_table_entry;
dev->msix_max = pci_get_word(VAR_0->config + VAR_2 + PCI_MSIX_FLAGS);
dev->msix_max &= PCI_MSIX_FLAGS_QSIZE;
dev->msix_max += 1;
}
VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_PM, 0);
if (VAR_2) {
uint16_t pmc;
VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_PM, VAR_2, PCI_PM_SIZEOF);
if (VAR_1 < 0) {
return VAR_1;
}
assigned_dev_setup_cap_read(dev, VAR_2, PCI_PM_SIZEOF);
pmc = pci_get_word(VAR_0->config + VAR_2 + PCI_CAP_FLAGS);
pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI);
pci_set_word(VAR_0->config + VAR_2 + PCI_CAP_FLAGS, pmc);
pci_set_word(VAR_0->config + VAR_2 + PCI_PM_CTRL,
PCI_PM_CTRL_NO_SOFT_RESET);
pci_set_byte(VAR_0->config + VAR_2 + PCI_PM_PPB_EXTENSIONS, 0);
pci_set_byte(VAR_0->config + VAR_2 + PCI_PM_DATA_REGISTER, 0);
}
VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_EXP, 0);
if (VAR_2) {
uint8_t version, size = 0;
uint16_t type, devctl, lnksta;
uint32_t devcap, lnkcap;
version = pci_get_byte(VAR_0->config + VAR_2 + PCI_EXP_FLAGS);
version &= PCI_EXP_FLAGS_VERS;
if (version == 1) {
size = 0x14;
} else if (version == 2) {
size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - VAR_2);
if (size < 0x34) {
error_report("%s: Invalid size PCIe cap-id 0x%x",
__func__, PCI_CAP_ID_EXP);
return -EINVAL;
} else if (size != 0x3c) {
error_report("WARNING, %s: PCIe cap-id 0x%x has "
"non-standard size 0x%x; std size should be 0x3c",
__func__, PCI_CAP_ID_EXP, size);
}
} else if (version == 0) {
uint16_t vid, did;
vid = pci_get_word(VAR_0->config + PCI_VENDOR_ID);
did = pci_get_word(VAR_0->config + PCI_DEVICE_ID);
if (vid == PCI_VENDOR_ID_INTEL && did == 0x10ed) {
size = 0x3c;
}
}
if (size == 0) {
error_report("%s: Unsupported PCI express capability version %d",
__func__, version);
return -EINVAL;
}
VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_EXP, VAR_2, size);
if (VAR_1 < 0) {
return VAR_1;
}
assigned_dev_setup_cap_read(dev, VAR_2, size);
type = pci_get_word(VAR_0->config + VAR_2 + PCI_EXP_FLAGS);
type = (type & PCI_EXP_FLAGS_TYPE) >> 4;
if (type != PCI_EXP_TYPE_ENDPOINT &&
type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) {
error_report("Device assignment only supports endpoint assignment,"
" device type %d", type);
return -EINVAL;
}
devcap = pci_get_long(VAR_0->config + VAR_2 + PCI_EXP_DEVCAP);
devcap &= ~PCI_EXP_DEVCAP_FLR;
pci_set_long(VAR_0->config + VAR_2 + PCI_EXP_DEVCAP, devcap);
devctl = pci_get_word(VAR_0->config + VAR_2 + PCI_EXP_DEVCTL);
devctl = (devctl & (PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_PAYLOAD)) |
PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN;
pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_DEVCTL, devctl);
devctl = PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_AUX_PME;
pci_set_word(VAR_0->wmask + VAR_2 + PCI_EXP_DEVCTL, ~devctl);
pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_DEVSTA, 0);
lnkcap = pci_get_long(VAR_0->config + VAR_2 + PCI_EXP_LNKCAP);
lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW |
PCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL |
PCI_EXP_LNKCAP_L1EL);
pci_set_long(VAR_0->config + VAR_2 + PCI_EXP_LNKCAP, lnkcap);
lnksta = pci_get_word(VAR_0->config + VAR_2 + PCI_EXP_LNKSTA);
lnksta &= (PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW);
pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_LNKSTA, lnksta);
if (version >= 2) {
pci_set_long(VAR_0->config + VAR_2 + PCI_EXP_SLTCAP, 0);
pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_SLTCTL, 0);
pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_SLTSTA, 0);
pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_RTCTL, 0);
pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_RTCAP, 0);
pci_set_long(VAR_0->config + VAR_2 + PCI_EXP_RTSTA, 0);
}
}
VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_PCIX, 0);
if (VAR_2) {
uint16_t cmd;
uint32_t status;
VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_PCIX, VAR_2, 8);
if (VAR_1 < 0) {
return VAR_1;
}
assigned_dev_setup_cap_read(dev, VAR_2, 8);
cmd = pci_get_word(VAR_0->config + VAR_2 + PCI_X_CMD);
cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ |
PCI_X_CMD_MAX_SPLIT);
pci_set_word(VAR_0->config + VAR_2 + PCI_X_CMD, cmd);
status = pci_get_long(VAR_0->config + VAR_2 + PCI_X_STATUS);
status &= ~(PCI_X_STATUS_BUS | PCI_X_STATUS_DEVFN);
status |= (pci_bus_num(VAR_0->bus) << 8) | VAR_0->devfn;
status &= ~(PCI_X_STATUS_SPL_DISC | PCI_X_STATUS_UNX_SPL |
PCI_X_STATUS_SPL_ERR);
pci_set_long(VAR_0->config + VAR_2 + PCI_X_STATUS, status);
}
VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_VPD, 0);
if (VAR_2) {
VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_VPD, VAR_2, 8);
if (VAR_1 < 0) {
return VAR_1;
}
assigned_dev_setup_cap_read(dev, VAR_2, 8);
assigned_dev_direct_config_write(dev, VAR_2 + 2, 6);
}
for (VAR_2 = 0; (VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_VNDR, VAR_2));
VAR_2 += PCI_CAP_LIST_NEXT) {
uint8_t len = pci_get_byte(VAR_0->config + VAR_2 + PCI_CAP_FLAGS);
VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_VNDR, VAR_2, len);
if (VAR_1 < 0) {
return VAR_1;
}
assigned_dev_setup_cap_read(dev, VAR_2, len);
assigned_dev_direct_config_write(dev, VAR_2 + 2, len - 2);
}
if ((pci_get_word(VAR_0->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) !=
(assigned_dev_pci_read_byte(VAR_0, PCI_STATUS) &
PCI_STATUS_CAP_LIST)) {
dev->emulate_config_read[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
}
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, VAR_0);",
"PCIRegion *pci_region = dev->real_device.regions;",
"int VAR_1, VAR_2;",
"pci_set_byte(VAR_0->config + PCI_CAPABILITY_LIST, 0);",
"pci_set_word(VAR_0->config + PCI_STATUS,\npci_get_word(VAR_0->config + PCI_STATUS) &\n~PCI_STATUS_CAP_LIST);",
"VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_MSI, 0);",
"if (VAR_2 != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {",
"if (!check_irqchip_in_kernel()) {",
"return -ENOTSUP;",
"}",
"dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;",
"VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_MSI, VAR_2, 10);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"VAR_0->msi_cap = VAR_2;",
"pci_set_word(VAR_0->config + VAR_2 + PCI_MSI_FLAGS,\npci_get_word(VAR_0->config + VAR_2 + PCI_MSI_FLAGS) &\nPCI_MSI_FLAGS_QMASK);",
"pci_set_long(VAR_0->config + VAR_2 + PCI_MSI_ADDRESS_LO, 0);",
"pci_set_word(VAR_0->config + VAR_2 + PCI_MSI_DATA_32, 0);",
"pci_set_word(VAR_0->wmask + VAR_2 + PCI_MSI_FLAGS,\nPCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);",
"pci_set_long(VAR_0->wmask + VAR_2 + PCI_MSI_ADDRESS_LO, 0xfffffffc);",
"pci_set_word(VAR_0->wmask + VAR_2 + PCI_MSI_DATA_32, 0xffff);",
"}",
"VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_MSIX, 0);",
"if (VAR_2 != 0 && kvm_device_msix_supported(kvm_state)) {",
"int VAR_3;",
"uint32_t msix_table_entry;",
"if (!check_irqchip_in_kernel()) {",
"return -ENOTSUP;",
"}",
"dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX;",
"VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_MSIX, VAR_2, 12);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"VAR_0->msix_cap = VAR_2;",
"pci_set_word(VAR_0->config + VAR_2 + PCI_MSIX_FLAGS,\npci_get_word(VAR_0->config + VAR_2 + PCI_MSIX_FLAGS) &\nPCI_MSIX_FLAGS_QSIZE);",
"pci_set_word(VAR_0->wmask + VAR_2 + PCI_MSIX_FLAGS,\nPCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);",
"msix_table_entry = pci_get_long(VAR_0->config + VAR_2 + PCI_MSIX_TABLE);",
"VAR_3 = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK;",
"msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK;",
"dev->msix_table_addr = pci_region[VAR_3].base_addr + msix_table_entry;",
"dev->msix_max = pci_get_word(VAR_0->config + VAR_2 + PCI_MSIX_FLAGS);",
"dev->msix_max &= PCI_MSIX_FLAGS_QSIZE;",
"dev->msix_max += 1;",
"}",
"VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_PM, 0);",
"if (VAR_2) {",
"uint16_t pmc;",
"VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_PM, VAR_2, PCI_PM_SIZEOF);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"assigned_dev_setup_cap_read(dev, VAR_2, PCI_PM_SIZEOF);",
"pmc = pci_get_word(VAR_0->config + VAR_2 + PCI_CAP_FLAGS);",
"pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI);",
"pci_set_word(VAR_0->config + VAR_2 + PCI_CAP_FLAGS, pmc);",
"pci_set_word(VAR_0->config + VAR_2 + PCI_PM_CTRL,\nPCI_PM_CTRL_NO_SOFT_RESET);",
"pci_set_byte(VAR_0->config + VAR_2 + PCI_PM_PPB_EXTENSIONS, 0);",
"pci_set_byte(VAR_0->config + VAR_2 + PCI_PM_DATA_REGISTER, 0);",
"}",
"VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_EXP, 0);",
"if (VAR_2) {",
"uint8_t version, size = 0;",
"uint16_t type, devctl, lnksta;",
"uint32_t devcap, lnkcap;",
"version = pci_get_byte(VAR_0->config + VAR_2 + PCI_EXP_FLAGS);",
"version &= PCI_EXP_FLAGS_VERS;",
"if (version == 1) {",
"size = 0x14;",
"} else if (version == 2) {",
"size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - VAR_2);",
"if (size < 0x34) {",
"error_report(\"%s: Invalid size PCIe cap-id 0x%x\",\n__func__, PCI_CAP_ID_EXP);",
"return -EINVAL;",
"} else if (size != 0x3c) {",
"error_report(\"WARNING, %s: PCIe cap-id 0x%x has \"\n\"non-standard size 0x%x; std size should be 0x3c\",",
"__func__, PCI_CAP_ID_EXP, size);",
"}",
"} else if (version == 0) {",
"uint16_t vid, did;",
"vid = pci_get_word(VAR_0->config + PCI_VENDOR_ID);",
"did = pci_get_word(VAR_0->config + PCI_DEVICE_ID);",
"if (vid == PCI_VENDOR_ID_INTEL && did == 0x10ed) {",
"size = 0x3c;",
"}",
"}",
"if (size == 0) {",
"error_report(\"%s: Unsupported PCI express capability version %d\",\n__func__, version);",
"return -EINVAL;",
"}",
"VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_EXP, VAR_2, size);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"assigned_dev_setup_cap_read(dev, VAR_2, size);",
"type = pci_get_word(VAR_0->config + VAR_2 + PCI_EXP_FLAGS);",
"type = (type & PCI_EXP_FLAGS_TYPE) >> 4;",
"if (type != PCI_EXP_TYPE_ENDPOINT &&\ntype != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) {",
"error_report(\"Device assignment only supports endpoint assignment,\"\n\" device type %d\", type);",
"return -EINVAL;",
"}",
"devcap = pci_get_long(VAR_0->config + VAR_2 + PCI_EXP_DEVCAP);",
"devcap &= ~PCI_EXP_DEVCAP_FLR;",
"pci_set_long(VAR_0->config + VAR_2 + PCI_EXP_DEVCAP, devcap);",
"devctl = pci_get_word(VAR_0->config + VAR_2 + PCI_EXP_DEVCTL);",
"devctl = (devctl & (PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_PAYLOAD)) |\nPCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN;",
"pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_DEVCTL, devctl);",
"devctl = PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_AUX_PME;",
"pci_set_word(VAR_0->wmask + VAR_2 + PCI_EXP_DEVCTL, ~devctl);",
"pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_DEVSTA, 0);",
"lnkcap = pci_get_long(VAR_0->config + VAR_2 + PCI_EXP_LNKCAP);",
"lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW |\nPCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL |\nPCI_EXP_LNKCAP_L1EL);",
"pci_set_long(VAR_0->config + VAR_2 + PCI_EXP_LNKCAP, lnkcap);",
"lnksta = pci_get_word(VAR_0->config + VAR_2 + PCI_EXP_LNKSTA);",
"lnksta &= (PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW);",
"pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_LNKSTA, lnksta);",
"if (version >= 2) {",
"pci_set_long(VAR_0->config + VAR_2 + PCI_EXP_SLTCAP, 0);",
"pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_SLTCTL, 0);",
"pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_SLTSTA, 0);",
"pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_RTCTL, 0);",
"pci_set_word(VAR_0->config + VAR_2 + PCI_EXP_RTCAP, 0);",
"pci_set_long(VAR_0->config + VAR_2 + PCI_EXP_RTSTA, 0);",
"}",
"}",
"VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_PCIX, 0);",
"if (VAR_2) {",
"uint16_t cmd;",
"uint32_t status;",
"VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_PCIX, VAR_2, 8);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"assigned_dev_setup_cap_read(dev, VAR_2, 8);",
"cmd = pci_get_word(VAR_0->config + VAR_2 + PCI_X_CMD);",
"cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ |\nPCI_X_CMD_MAX_SPLIT);",
"pci_set_word(VAR_0->config + VAR_2 + PCI_X_CMD, cmd);",
"status = pci_get_long(VAR_0->config + VAR_2 + PCI_X_STATUS);",
"status &= ~(PCI_X_STATUS_BUS | PCI_X_STATUS_DEVFN);",
"status |= (pci_bus_num(VAR_0->bus) << 8) | VAR_0->devfn;",
"status &= ~(PCI_X_STATUS_SPL_DISC | PCI_X_STATUS_UNX_SPL |\nPCI_X_STATUS_SPL_ERR);",
"pci_set_long(VAR_0->config + VAR_2 + PCI_X_STATUS, status);",
"}",
"VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_VPD, 0);",
"if (VAR_2) {",
"VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_VPD, VAR_2, 8);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"assigned_dev_setup_cap_read(dev, VAR_2, 8);",
"assigned_dev_direct_config_write(dev, VAR_2 + 2, 6);",
"}",
"for (VAR_2 = 0; (VAR_2 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_VNDR, VAR_2));",
"VAR_2 += PCI_CAP_LIST_NEXT) {",
"uint8_t len = pci_get_byte(VAR_0->config + VAR_2 + PCI_CAP_FLAGS);",
"VAR_1 = pci_add_capability(VAR_0, PCI_CAP_ID_VNDR, VAR_2, len);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"assigned_dev_setup_cap_read(dev, VAR_2, len);",
"assigned_dev_direct_config_write(dev, VAR_2 + 2, len - 2);",
"}",
"if ((pci_get_word(VAR_0->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) !=\n(assigned_dev_pci_read_byte(VAR_0, PCI_STATUS) &\nPCI_STATUS_CAP_LIST)) {",
"dev->emulate_config_read[PCI_STATUS] |= PCI_STATUS_CAP_LIST;",
"}",
"return 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17,
19,
21
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55,
57,
59
],
[
61
],
[
63
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111,
113,
115
],
[
121,
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
169
],
[
171
],
[
173
],
[
181,
183
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
241,
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
267
],
[
269
],
[
271
],
[
275
],
[
277,
279
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
293
],
[
297
],
[
301
],
[
303
],
[
305,
307
],
[
309,
311
],
[
313
],
[
315
],
[
327
],
[
329
],
[
331
],
[
343
],
[
345,
347
],
[
349
],
[
351
],
[
353
],
[
359
],
[
365
],
[
367,
369,
371
],
[
373
],
[
383
],
[
385
],
[
387
],
[
391
],
[
395
],
[
397
],
[
399
],
[
405
],
[
407
],
[
409
],
[
417
],
[
419
],
[
423
],
[
425
],
[
427
],
[
429
],
[
435
],
[
437
],
[
439
],
[
441
],
[
445
],
[
451
],
[
453,
455
],
[
457
],
[
465
],
[
467
],
[
469
],
[
471,
473
],
[
475
],
[
477
],
[
481
],
[
483
],
[
487
],
[
489
],
[
491
],
[
493
],
[
497
],
[
503
],
[
505
],
[
511
],
[
513
],
[
515
],
[
519
],
[
521
],
[
523
],
[
525
],
[
529
],
[
535
],
[
537
],
[
545,
547,
549
],
[
551
],
[
553
],
[
557
],
[
559
]
] |
19,422 | static void xscale_cpar_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
value &= 0x3fff;
if (env->cp15.c15_cpar != value) {
/* Changes cp0 to cp13 behavior, so needs a TB flush. */
tb_flush(env);
env->cp15.c15_cpar = value;
}
}
| true | qemu | c0f4af171999eda4e49de5169906ce98246457f0 | static void xscale_cpar_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
value &= 0x3fff;
if (env->cp15.c15_cpar != value) {
tb_flush(env);
env->cp15.c15_cpar = value;
}
}
| {
"code": [
" value &= 0x3fff;",
" if (env->cp15.c15_cpar != value) {",
" tb_flush(env);",
" env->cp15.c15_cpar = value;"
],
"line_no": [
7,
9,
13,
15
]
} | static void FUNC_0(CPUARMState *VAR_0, const ARMCPRegInfo *VAR_1,
uint64_t VAR_2)
{
VAR_2 &= 0x3fff;
if (VAR_0->cp15.c15_cpar != VAR_2) {
tb_flush(VAR_0);
VAR_0->cp15.c15_cpar = VAR_2;
}
}
| [
"static void FUNC_0(CPUARMState *VAR_0, const ARMCPRegInfo *VAR_1,\nuint64_t VAR_2)\n{",
"VAR_2 &= 0x3fff;",
"if (VAR_0->cp15.c15_cpar != VAR_2) {",
"tb_flush(VAR_0);",
"VAR_0->cp15.c15_cpar = VAR_2;",
"}",
"}"
] | [
0,
1,
1,
1,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
19,424 | static int compensate_volume(AVFilterContext *ctx)
{
struct SOFAlizerContext *s = ctx->priv;
float compensate;
float energy = 0;
float *ir;
int m;
if (s->sofa.ncid) {
/* find IR at front center position in the SOFA file (IR closest to 0°,0°,1m) */
struct NCSofa *sofa = &s->sofa;
m = find_m(s, 0, 0, 1);
/* get energy of that IR and compensate volume */
ir = sofa->data_ir + 2 * m * sofa->n_samples;
if (sofa->n_samples & 31) {
energy = avpriv_scalarproduct_float_c(ir, ir, sofa->n_samples);
} else {
energy = s->fdsp->scalarproduct_float(ir, ir, sofa->n_samples);
}
compensate = 256 / (sofa->n_samples * sqrt(energy));
av_log(ctx, AV_LOG_DEBUG, "Compensate-factor: %f\n", compensate);
ir = sofa->data_ir;
/* apply volume compensation to IRs */
s->fdsp->vector_fmul_scalar(ir, ir, compensate, sofa->n_samples * sofa->m_dim * 2);
emms_c();
}
return 0;
}
| true | FFmpeg | 79a54f30c8ba02cbf2b02c650120246b260977ec | static int compensate_volume(AVFilterContext *ctx)
{
struct SOFAlizerContext *s = ctx->priv;
float compensate;
float energy = 0;
float *ir;
int m;
if (s->sofa.ncid) {
struct NCSofa *sofa = &s->sofa;
m = find_m(s, 0, 0, 1);
ir = sofa->data_ir + 2 * m * sofa->n_samples;
if (sofa->n_samples & 31) {
energy = avpriv_scalarproduct_float_c(ir, ir, sofa->n_samples);
} else {
energy = s->fdsp->scalarproduct_float(ir, ir, sofa->n_samples);
}
compensate = 256 / (sofa->n_samples * sqrt(energy));
av_log(ctx, AV_LOG_DEBUG, "Compensate-factor: %f\n", compensate);
ir = sofa->data_ir;
s->fdsp->vector_fmul_scalar(ir, ir, compensate, sofa->n_samples * sofa->m_dim * 2);
emms_c();
}
return 0;
}
| {
"code": [
" s->fdsp->vector_fmul_scalar(ir, ir, compensate, sofa->n_samples * sofa->m_dim * 2);",
" emms_c();"
],
"line_no": [
47,
49
]
} | static int FUNC_0(AVFilterContext *VAR_0)
{
struct SOFAlizerContext *VAR_1 = VAR_0->priv;
float VAR_2;
float VAR_3 = 0;
float *VAR_4;
int VAR_5;
if (VAR_1->VAR_6.ncid) {
struct NCSofa *VAR_6 = &VAR_1->VAR_6;
VAR_5 = find_m(VAR_1, 0, 0, 1);
VAR_4 = VAR_6->data_ir + 2 * VAR_5 * VAR_6->n_samples;
if (VAR_6->n_samples & 31) {
VAR_3 = avpriv_scalarproduct_float_c(VAR_4, VAR_4, VAR_6->n_samples);
} else {
VAR_3 = VAR_1->fdsp->scalarproduct_float(VAR_4, VAR_4, VAR_6->n_samples);
}
VAR_2 = 256 / (VAR_6->n_samples * sqrt(VAR_3));
av_log(VAR_0, AV_LOG_DEBUG, "Compensate-factor: %f\n", VAR_2);
VAR_4 = VAR_6->data_ir;
VAR_1->fdsp->vector_fmul_scalar(VAR_4, VAR_4, VAR_2, VAR_6->n_samples * VAR_6->m_dim * 2);
emms_c();
}
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0)\n{",
"struct SOFAlizerContext *VAR_1 = VAR_0->priv;",
"float VAR_2;",
"float VAR_3 = 0;",
"float *VAR_4;",
"int VAR_5;",
"if (VAR_1->VAR_6.ncid) {",
"struct NCSofa *VAR_6 = &VAR_1->VAR_6;",
"VAR_5 = find_m(VAR_1, 0, 0, 1);",
"VAR_4 = VAR_6->data_ir + 2 * VAR_5 * VAR_6->n_samples;",
"if (VAR_6->n_samples & 31) {",
"VAR_3 = avpriv_scalarproduct_float_c(VAR_4, VAR_4, VAR_6->n_samples);",
"} else {",
"VAR_3 = VAR_1->fdsp->scalarproduct_float(VAR_4, VAR_4, VAR_6->n_samples);",
"}",
"VAR_2 = 256 / (VAR_6->n_samples * sqrt(VAR_3));",
"av_log(VAR_0, AV_LOG_DEBUG, \"Compensate-factor: %f\\n\", VAR_2);",
"VAR_4 = VAR_6->data_ir;",
"VAR_1->fdsp->vector_fmul_scalar(VAR_4, VAR_4, VAR_2, VAR_6->n_samples * VAR_6->m_dim * 2);",
"emms_c();",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
]
] |
19,425 | static char *qio_channel_websock_handshake_entry(const char *handshake,
size_t handshake_len,
const char *name)
{
char *begin, *end, *ret = NULL;
char *line = g_strdup_printf("%s%s: ",
QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM,
name);
begin = g_strstr_len(handshake, handshake_len, line);
if (begin != NULL) {
begin += strlen(line);
end = g_strstr_len(begin, handshake_len - (begin - handshake),
QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM);
if (end != NULL) {
ret = g_strndup(begin, end - begin);
}
}
g_free(line);
return ret;
}
| true | qemu | 07e95cd529af345fdeea230913f68eff5b925bb6 | static char *qio_channel_websock_handshake_entry(const char *handshake,
size_t handshake_len,
const char *name)
{
char *begin, *end, *ret = NULL;
char *line = g_strdup_printf("%s%s: ",
QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM,
name);
begin = g_strstr_len(handshake, handshake_len, line);
if (begin != NULL) {
begin += strlen(line);
end = g_strstr_len(begin, handshake_len - (begin - handshake),
QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM);
if (end != NULL) {
ret = g_strndup(begin, end - begin);
}
}
g_free(line);
return ret;
}
| {
"code": [
"static char *qio_channel_websock_handshake_entry(const char *handshake,",
" size_t handshake_len,",
" const char *name)",
" char *begin, *end, *ret = NULL;",
" char *line = g_strdup_printf(\"%s%s: \",",
" QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM,",
" name);",
" begin = g_strstr_len(handshake, handshake_len, line);",
" if (begin != NULL) {",
" begin += strlen(line);",
" end = g_strstr_len(begin, handshake_len - (begin - handshake),",
" QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM);",
" if (end != NULL) {",
" ret = g_strndup(begin, end - begin);",
" g_free(line);",
" return ret;",
" return ret;"
],
"line_no": [
1,
3,
5,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
35,
37,
37
]
} | static char *FUNC_0(const char *VAR_0,
size_t VAR_1,
const char *VAR_2)
{
char *VAR_3, *VAR_4, *VAR_5 = NULL;
char *VAR_6 = g_strdup_printf("%s%s: ",
QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM,
VAR_2);
VAR_3 = g_strstr_len(VAR_0, VAR_1, VAR_6);
if (VAR_3 != NULL) {
VAR_3 += strlen(VAR_6);
VAR_4 = g_strstr_len(VAR_3, VAR_1 - (VAR_3 - VAR_0),
QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM);
if (VAR_4 != NULL) {
VAR_5 = g_strndup(VAR_3, VAR_4 - VAR_3);
}
}
g_free(VAR_6);
return VAR_5;
}
| [
"static char *FUNC_0(const char *VAR_0,\nsize_t VAR_1,\nconst char *VAR_2)\n{",
"char *VAR_3, *VAR_4, *VAR_5 = NULL;",
"char *VAR_6 = g_strdup_printf(\"%s%s: \",\nQIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM,\nVAR_2);",
"VAR_3 = g_strstr_len(VAR_0, VAR_1, VAR_6);",
"if (VAR_3 != NULL) {",
"VAR_3 += strlen(VAR_6);",
"VAR_4 = g_strstr_len(VAR_3, VAR_1 - (VAR_3 - VAR_0),\nQIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM);",
"if (VAR_4 != NULL) {",
"VAR_5 = g_strndup(VAR_3, VAR_4 - VAR_3);",
"}",
"}",
"g_free(VAR_6);",
"return VAR_5;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
19,426 | static void machvirt_init(MachineState *machine)
{
VirtMachineState *vms = VIRT_MACHINE(machine);
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(machine);
qemu_irq pic[NUM_IRQS];
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *secure_sysmem = NULL;
int n, virt_max_cpus;
MemoryRegion *ram = g_new(MemoryRegion, 1);
const char *cpu_model = machine->cpu_model;
char **cpustr;
ObjectClass *oc;
const char *typename;
CPUClass *cc;
Error *err = NULL;
bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0);
uint8_t clustersz;
if (!cpu_model) {
cpu_model = "cortex-a15";
}
/* We can probe only here because during property set
* KVM is not available yet
*/
if (!vms->gic_version) {
if (!kvm_enabled()) {
error_report("gic-version=host requires KVM");
exit(1);
}
vms->gic_version = kvm_arm_vgic_probe();
if (!vms->gic_version) {
error_report("Unable to determine GIC version supported by host");
exit(1);
}
}
/* Separate the actual CPU model name from any appended features */
cpustr = g_strsplit(cpu_model, ",", 2);
if (!cpuname_valid(cpustr[0])) {
error_report("mach-virt: CPU %s not supported", cpustr[0]);
exit(1);
}
/* If we have an EL3 boot ROM then the assumption is that it will
* implement PSCI itself, so disable QEMU's internal implementation
* so it doesn't get in the way. Instead of starting secondary
* CPUs in PSCI powerdown state we will start them all running and
* let the boot ROM sort them out.
* The usual case is that we do use QEMU's PSCI implementation;
* if the guest has EL2 then we will use SMC as the conduit,
* and otherwise we will use HVC (for backwards compatibility and
* because if we're using KVM then we must use HVC).
*/
if (vms->secure && firmware_loaded) {
vms->psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;
} else if (vms->virt) {
vms->psci_conduit = QEMU_PSCI_CONDUIT_SMC;
} else {
vms->psci_conduit = QEMU_PSCI_CONDUIT_HVC;
}
/* The maximum number of CPUs depends on the GIC version, or on how
* many redistributors we can fit into the memory map.
*/
if (vms->gic_version == 3) {
virt_max_cpus = vms->memmap[VIRT_GIC_REDIST].size / 0x20000;
clustersz = GICV3_TARGETLIST_BITS;
} else {
virt_max_cpus = GIC_NCPU;
clustersz = GIC_TARGETLIST_BITS;
}
if (max_cpus > virt_max_cpus) {
error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
"supported by machine 'mach-virt' (%d)",
max_cpus, virt_max_cpus);
exit(1);
}
vms->smp_cpus = smp_cpus;
if (machine->ram_size > vms->memmap[VIRT_MEM].size) {
error_report("mach-virt: cannot model more than %dGB RAM", RAMLIMIT_GB);
exit(1);
}
if (vms->virt && kvm_enabled()) {
error_report("mach-virt: KVM does not support providing "
"Virtualization extensions to the guest CPU");
exit(1);
}
if (vms->secure) {
if (kvm_enabled()) {
error_report("mach-virt: KVM does not support Security extensions");
exit(1);
}
/* The Secure view of the world is the same as the NonSecure,
* but with a few extra devices. Create it as a container region
* containing the system memory at low priority; any secure-only
* devices go in at higher priority and take precedence.
*/
secure_sysmem = g_new(MemoryRegion, 1);
memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory",
UINT64_MAX);
memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1);
}
create_fdt(vms);
oc = cpu_class_by_name(TYPE_ARM_CPU, cpustr[0]);
if (!oc) {
error_report("Unable to find CPU definition");
exit(1);
}
typename = object_class_get_name(oc);
/* convert -smp CPU options specified by the user into global props */
cc = CPU_CLASS(oc);
cc->parse_features(typename, cpustr[1], &err);
g_strfreev(cpustr);
if (err) {
error_report_err(err);
exit(1);
}
for (n = 0; n < smp_cpus; n++) {
Object *cpuobj = object_new(typename);
if (!vmc->disallow_affinity_adjustment) {
/* Adjust MPIDR like 64-bit KVM hosts, which incorporate the
* GIC's target-list limitations. 32-bit KVM hosts currently
* always create clusters of 4 CPUs, but that is expected to
* change when they gain support for gicv3. When KVM is enabled
* it will override the changes we make here, therefore our
* purposes are to make TCG consistent (with 64-bit KVM hosts)
* and to improve SGI efficiency.
*/
uint8_t aff1 = n / clustersz;
uint8_t aff0 = n % clustersz;
object_property_set_int(cpuobj, (aff1 << ARM_AFF1_SHIFT) | aff0,
"mp-affinity", NULL);
}
if (!vms->secure) {
object_property_set_bool(cpuobj, false, "has_el3", NULL);
}
if (!vms->virt && object_property_find(cpuobj, "has_el2", NULL)) {
object_property_set_bool(cpuobj, false, "has_el2", NULL);
}
if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED) {
object_property_set_int(cpuobj, vms->psci_conduit,
"psci-conduit", NULL);
/* Secondary CPUs start in PSCI powered-down state */
if (n > 0) {
object_property_set_bool(cpuobj, true,
"start-powered-off", NULL);
}
}
if (vmc->no_pmu && object_property_find(cpuobj, "pmu", NULL)) {
object_property_set_bool(cpuobj, false, "pmu", NULL);
}
if (object_property_find(cpuobj, "reset-cbar", NULL)) {
object_property_set_int(cpuobj, vms->memmap[VIRT_CPUPERIPHS].base,
"reset-cbar", &error_abort);
}
object_property_set_link(cpuobj, OBJECT(sysmem), "memory",
&error_abort);
if (vms->secure) {
object_property_set_link(cpuobj, OBJECT(secure_sysmem),
"secure-memory", &error_abort);
}
object_property_set_bool(cpuobj, true, "realized", NULL);
}
fdt_add_timer_nodes(vms);
fdt_add_cpu_nodes(vms);
fdt_add_psci_node(vms);
memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram",
machine->ram_size);
memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram);
create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem);
create_gic(vms, pic);
fdt_add_pmu_nodes(vms);
create_uart(vms, pic, VIRT_UART, sysmem, serial_hds[0]);
if (vms->secure) {
create_secure_ram(vms, secure_sysmem);
create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem, serial_hds[1]);
}
create_rtc(vms, pic);
create_pcie(vms, pic);
create_gpio(vms, pic);
/* Create mmio transports, so the user can create virtio backends
* (which will be automatically plugged in to the transports). If
* no backend is created the transport will just sit harmlessly idle.
*/
create_virtio_devices(vms, pic);
vms->fw_cfg = create_fw_cfg(vms, &address_space_memory);
rom_set_fw(vms->fw_cfg);
vms->machine_done.notify = virt_machine_done;
qemu_add_machine_init_done_notifier(&vms->machine_done);
vms->bootinfo.ram_size = machine->ram_size;
vms->bootinfo.kernel_filename = machine->kernel_filename;
vms->bootinfo.kernel_cmdline = machine->kernel_cmdline;
vms->bootinfo.initrd_filename = machine->initrd_filename;
vms->bootinfo.nb_cpus = smp_cpus;
vms->bootinfo.board_id = -1;
vms->bootinfo.loader_start = vms->memmap[VIRT_MEM].base;
vms->bootinfo.get_dtb = machvirt_dtb;
vms->bootinfo.firmware_loaded = firmware_loaded;
arm_load_kernel(ARM_CPU(first_cpu), &vms->bootinfo);
/*
* arm_load_kernel machine init done notifier registration must
* happen before the platform_bus_create call. In this latter,
* another notifier is registered which adds platform bus nodes.
* Notifiers are executed in registration reverse order.
*/
create_platform_bus(vms, pic);
} | true | qemu | dbb74759fae6f521709e16e19cbb7d6fb2307700 | static void machvirt_init(MachineState *machine)
{
VirtMachineState *vms = VIRT_MACHINE(machine);
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(machine);
qemu_irq pic[NUM_IRQS];
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *secure_sysmem = NULL;
int n, virt_max_cpus;
MemoryRegion *ram = g_new(MemoryRegion, 1);
const char *cpu_model = machine->cpu_model;
char **cpustr;
ObjectClass *oc;
const char *typename;
CPUClass *cc;
Error *err = NULL;
bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0);
uint8_t clustersz;
if (!cpu_model) {
cpu_model = "cortex-a15";
}
if (!vms->gic_version) {
if (!kvm_enabled()) {
error_report("gic-version=host requires KVM");
exit(1);
}
vms->gic_version = kvm_arm_vgic_probe();
if (!vms->gic_version) {
error_report("Unable to determine GIC version supported by host");
exit(1);
}
}
cpustr = g_strsplit(cpu_model, ",", 2);
if (!cpuname_valid(cpustr[0])) {
error_report("mach-virt: CPU %s not supported", cpustr[0]);
exit(1);
}
if (vms->secure && firmware_loaded) {
vms->psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;
} else if (vms->virt) {
vms->psci_conduit = QEMU_PSCI_CONDUIT_SMC;
} else {
vms->psci_conduit = QEMU_PSCI_CONDUIT_HVC;
}
if (vms->gic_version == 3) {
virt_max_cpus = vms->memmap[VIRT_GIC_REDIST].size / 0x20000;
clustersz = GICV3_TARGETLIST_BITS;
} else {
virt_max_cpus = GIC_NCPU;
clustersz = GIC_TARGETLIST_BITS;
}
if (max_cpus > virt_max_cpus) {
error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
"supported by machine 'mach-virt' (%d)",
max_cpus, virt_max_cpus);
exit(1);
}
vms->smp_cpus = smp_cpus;
if (machine->ram_size > vms->memmap[VIRT_MEM].size) {
error_report("mach-virt: cannot model more than %dGB RAM", RAMLIMIT_GB);
exit(1);
}
if (vms->virt && kvm_enabled()) {
error_report("mach-virt: KVM does not support providing "
"Virtualization extensions to the guest CPU");
exit(1);
}
if (vms->secure) {
if (kvm_enabled()) {
error_report("mach-virt: KVM does not support Security extensions");
exit(1);
}
secure_sysmem = g_new(MemoryRegion, 1);
memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory",
UINT64_MAX);
memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1);
}
create_fdt(vms);
oc = cpu_class_by_name(TYPE_ARM_CPU, cpustr[0]);
if (!oc) {
error_report("Unable to find CPU definition");
exit(1);
}
typename = object_class_get_name(oc);
cc = CPU_CLASS(oc);
cc->parse_features(typename, cpustr[1], &err);
g_strfreev(cpustr);
if (err) {
error_report_err(err);
exit(1);
}
for (n = 0; n < smp_cpus; n++) {
Object *cpuobj = object_new(typename);
if (!vmc->disallow_affinity_adjustment) {
uint8_t aff1 = n / clustersz;
uint8_t aff0 = n % clustersz;
object_property_set_int(cpuobj, (aff1 << ARM_AFF1_SHIFT) | aff0,
"mp-affinity", NULL);
}
if (!vms->secure) {
object_property_set_bool(cpuobj, false, "has_el3", NULL);
}
if (!vms->virt && object_property_find(cpuobj, "has_el2", NULL)) {
object_property_set_bool(cpuobj, false, "has_el2", NULL);
}
if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED) {
object_property_set_int(cpuobj, vms->psci_conduit,
"psci-conduit", NULL);
if (n > 0) {
object_property_set_bool(cpuobj, true,
"start-powered-off", NULL);
}
}
if (vmc->no_pmu && object_property_find(cpuobj, "pmu", NULL)) {
object_property_set_bool(cpuobj, false, "pmu", NULL);
}
if (object_property_find(cpuobj, "reset-cbar", NULL)) {
object_property_set_int(cpuobj, vms->memmap[VIRT_CPUPERIPHS].base,
"reset-cbar", &error_abort);
}
object_property_set_link(cpuobj, OBJECT(sysmem), "memory",
&error_abort);
if (vms->secure) {
object_property_set_link(cpuobj, OBJECT(secure_sysmem),
"secure-memory", &error_abort);
}
object_property_set_bool(cpuobj, true, "realized", NULL);
}
fdt_add_timer_nodes(vms);
fdt_add_cpu_nodes(vms);
fdt_add_psci_node(vms);
memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram",
machine->ram_size);
memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram);
create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem);
create_gic(vms, pic);
fdt_add_pmu_nodes(vms);
create_uart(vms, pic, VIRT_UART, sysmem, serial_hds[0]);
if (vms->secure) {
create_secure_ram(vms, secure_sysmem);
create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem, serial_hds[1]);
}
create_rtc(vms, pic);
create_pcie(vms, pic);
create_gpio(vms, pic);
create_virtio_devices(vms, pic);
vms->fw_cfg = create_fw_cfg(vms, &address_space_memory);
rom_set_fw(vms->fw_cfg);
vms->machine_done.notify = virt_machine_done;
qemu_add_machine_init_done_notifier(&vms->machine_done);
vms->bootinfo.ram_size = machine->ram_size;
vms->bootinfo.kernel_filename = machine->kernel_filename;
vms->bootinfo.kernel_cmdline = machine->kernel_cmdline;
vms->bootinfo.initrd_filename = machine->initrd_filename;
vms->bootinfo.nb_cpus = smp_cpus;
vms->bootinfo.board_id = -1;
vms->bootinfo.loader_start = vms->memmap[VIRT_MEM].base;
vms->bootinfo.get_dtb = machvirt_dtb;
vms->bootinfo.firmware_loaded = firmware_loaded;
arm_load_kernel(ARM_CPU(first_cpu), &vms->bootinfo);
create_platform_bus(vms, pic);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(MachineState *VAR_0)
{
VirtMachineState *vms = VIRT_MACHINE(VAR_0);
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(VAR_0);
qemu_irq pic[NUM_IRQS];
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *secure_sysmem = NULL;
int VAR_1, VAR_2;
MemoryRegion *ram = g_new(MemoryRegion, 1);
const char *VAR_3 = VAR_0->VAR_3;
char **VAR_4;
ObjectClass *oc;
const char *VAR_5;
CPUClass *cc;
Error *err = NULL;
bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0);
uint8_t clustersz;
if (!VAR_3) {
VAR_3 = "cortex-a15";
}
if (!vms->gic_version) {
if (!kvm_enabled()) {
error_report("gic-version=host requires KVM");
exit(1);
}
vms->gic_version = kvm_arm_vgic_probe();
if (!vms->gic_version) {
error_report("Unable to determine GIC version supported by host");
exit(1);
}
}
VAR_4 = g_strsplit(VAR_3, ",", 2);
if (!cpuname_valid(VAR_4[0])) {
error_report("mach-virt: CPU %s not supported", VAR_4[0]);
exit(1);
}
if (vms->secure && firmware_loaded) {
vms->psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;
} else if (vms->virt) {
vms->psci_conduit = QEMU_PSCI_CONDUIT_SMC;
} else {
vms->psci_conduit = QEMU_PSCI_CONDUIT_HVC;
}
if (vms->gic_version == 3) {
VAR_2 = vms->memmap[VIRT_GIC_REDIST].size / 0x20000;
clustersz = GICV3_TARGETLIST_BITS;
} else {
VAR_2 = GIC_NCPU;
clustersz = GIC_TARGETLIST_BITS;
}
if (max_cpus > VAR_2) {
error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
"supported by VAR_0 'mach-virt' (%d)",
max_cpus, VAR_2);
exit(1);
}
vms->smp_cpus = smp_cpus;
if (VAR_0->ram_size > vms->memmap[VIRT_MEM].size) {
error_report("mach-virt: cannot model more than %dGB RAM", RAMLIMIT_GB);
exit(1);
}
if (vms->virt && kvm_enabled()) {
error_report("mach-virt: KVM does not support providing "
"Virtualization extensions to the guest CPU");
exit(1);
}
if (vms->secure) {
if (kvm_enabled()) {
error_report("mach-virt: KVM does not support Security extensions");
exit(1);
}
secure_sysmem = g_new(MemoryRegion, 1);
memory_region_init(secure_sysmem, OBJECT(VAR_0), "secure-memory",
UINT64_MAX);
memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1);
}
create_fdt(vms);
oc = cpu_class_by_name(TYPE_ARM_CPU, VAR_4[0]);
if (!oc) {
error_report("Unable to find CPU definition");
exit(1);
}
VAR_5 = object_class_get_name(oc);
cc = CPU_CLASS(oc);
cc->parse_features(VAR_5, VAR_4[1], &err);
g_strfreev(VAR_4);
if (err) {
error_report_err(err);
exit(1);
}
for (VAR_1 = 0; VAR_1 < smp_cpus; VAR_1++) {
Object *cpuobj = object_new(VAR_5);
if (!vmc->disallow_affinity_adjustment) {
uint8_t aff1 = VAR_1 / clustersz;
uint8_t aff0 = VAR_1 % clustersz;
object_property_set_int(cpuobj, (aff1 << ARM_AFF1_SHIFT) | aff0,
"mp-affinity", NULL);
}
if (!vms->secure) {
object_property_set_bool(cpuobj, false, "has_el3", NULL);
}
if (!vms->virt && object_property_find(cpuobj, "has_el2", NULL)) {
object_property_set_bool(cpuobj, false, "has_el2", NULL);
}
if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED) {
object_property_set_int(cpuobj, vms->psci_conduit,
"psci-conduit", NULL);
if (VAR_1 > 0) {
object_property_set_bool(cpuobj, true,
"start-powered-off", NULL);
}
}
if (vmc->no_pmu && object_property_find(cpuobj, "pmu", NULL)) {
object_property_set_bool(cpuobj, false, "pmu", NULL);
}
if (object_property_find(cpuobj, "reset-cbar", NULL)) {
object_property_set_int(cpuobj, vms->memmap[VIRT_CPUPERIPHS].base,
"reset-cbar", &error_abort);
}
object_property_set_link(cpuobj, OBJECT(sysmem), "memory",
&error_abort);
if (vms->secure) {
object_property_set_link(cpuobj, OBJECT(secure_sysmem),
"secure-memory", &error_abort);
}
object_property_set_bool(cpuobj, true, "realized", NULL);
}
fdt_add_timer_nodes(vms);
fdt_add_cpu_nodes(vms);
fdt_add_psci_node(vms);
memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram",
VAR_0->ram_size);
memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram);
create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem);
create_gic(vms, pic);
fdt_add_pmu_nodes(vms);
create_uart(vms, pic, VIRT_UART, sysmem, serial_hds[0]);
if (vms->secure) {
create_secure_ram(vms, secure_sysmem);
create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem, serial_hds[1]);
}
create_rtc(vms, pic);
create_pcie(vms, pic);
create_gpio(vms, pic);
create_virtio_devices(vms, pic);
vms->fw_cfg = create_fw_cfg(vms, &address_space_memory);
rom_set_fw(vms->fw_cfg);
vms->machine_done.notify = virt_machine_done;
qemu_add_machine_init_done_notifier(&vms->machine_done);
vms->bootinfo.ram_size = VAR_0->ram_size;
vms->bootinfo.kernel_filename = VAR_0->kernel_filename;
vms->bootinfo.kernel_cmdline = VAR_0->kernel_cmdline;
vms->bootinfo.initrd_filename = VAR_0->initrd_filename;
vms->bootinfo.nb_cpus = smp_cpus;
vms->bootinfo.board_id = -1;
vms->bootinfo.loader_start = vms->memmap[VIRT_MEM].base;
vms->bootinfo.get_dtb = machvirt_dtb;
vms->bootinfo.firmware_loaded = firmware_loaded;
arm_load_kernel(ARM_CPU(first_cpu), &vms->bootinfo);
create_platform_bus(vms, pic);
} | [
"static void FUNC_0(MachineState *VAR_0)\n{",
"VirtMachineState *vms = VIRT_MACHINE(VAR_0);",
"VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(VAR_0);",
"qemu_irq pic[NUM_IRQS];",
"MemoryRegion *sysmem = get_system_memory();",
"MemoryRegion *secure_sysmem = NULL;",
"int VAR_1, VAR_2;",
"MemoryRegion *ram = g_new(MemoryRegion, 1);",
"const char *VAR_3 = VAR_0->VAR_3;",
"char **VAR_4;",
"ObjectClass *oc;",
"const char *VAR_5;",
"CPUClass *cc;",
"Error *err = NULL;",
"bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0);",
"uint8_t clustersz;",
"if (!VAR_3) {",
"VAR_3 = \"cortex-a15\";",
"}",
"if (!vms->gic_version) {",
"if (!kvm_enabled()) {",
"error_report(\"gic-version=host requires KVM\");",
"exit(1);",
"}",
"vms->gic_version = kvm_arm_vgic_probe();",
"if (!vms->gic_version) {",
"error_report(\"Unable to determine GIC version supported by host\");",
"exit(1);",
"}",
"}",
"VAR_4 = g_strsplit(VAR_3, \",\", 2);",
"if (!cpuname_valid(VAR_4[0])) {",
"error_report(\"mach-virt: CPU %s not supported\", VAR_4[0]);",
"exit(1);",
"}",
"if (vms->secure && firmware_loaded) {",
"vms->psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;",
"} else if (vms->virt) {",
"vms->psci_conduit = QEMU_PSCI_CONDUIT_SMC;",
"} else {",
"vms->psci_conduit = QEMU_PSCI_CONDUIT_HVC;",
"}",
"if (vms->gic_version == 3) {",
"VAR_2 = vms->memmap[VIRT_GIC_REDIST].size / 0x20000;",
"clustersz = GICV3_TARGETLIST_BITS;",
"} else {",
"VAR_2 = GIC_NCPU;",
"clustersz = GIC_TARGETLIST_BITS;",
"}",
"if (max_cpus > VAR_2) {",
"error_report(\"Number of SMP CPUs requested (%d) exceeds max CPUs \"\n\"supported by VAR_0 'mach-virt' (%d)\",\nmax_cpus, VAR_2);",
"exit(1);",
"}",
"vms->smp_cpus = smp_cpus;",
"if (VAR_0->ram_size > vms->memmap[VIRT_MEM].size) {",
"error_report(\"mach-virt: cannot model more than %dGB RAM\", RAMLIMIT_GB);",
"exit(1);",
"}",
"if (vms->virt && kvm_enabled()) {",
"error_report(\"mach-virt: KVM does not support providing \"\n\"Virtualization extensions to the guest CPU\");",
"exit(1);",
"}",
"if (vms->secure) {",
"if (kvm_enabled()) {",
"error_report(\"mach-virt: KVM does not support Security extensions\");",
"exit(1);",
"}",
"secure_sysmem = g_new(MemoryRegion, 1);",
"memory_region_init(secure_sysmem, OBJECT(VAR_0), \"secure-memory\",\nUINT64_MAX);",
"memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1);",
"}",
"create_fdt(vms);",
"oc = cpu_class_by_name(TYPE_ARM_CPU, VAR_4[0]);",
"if (!oc) {",
"error_report(\"Unable to find CPU definition\");",
"exit(1);",
"}",
"VAR_5 = object_class_get_name(oc);",
"cc = CPU_CLASS(oc);",
"cc->parse_features(VAR_5, VAR_4[1], &err);",
"g_strfreev(VAR_4);",
"if (err) {",
"error_report_err(err);",
"exit(1);",
"}",
"for (VAR_1 = 0; VAR_1 < smp_cpus; VAR_1++) {",
"Object *cpuobj = object_new(VAR_5);",
"if (!vmc->disallow_affinity_adjustment) {",
"uint8_t aff1 = VAR_1 / clustersz;",
"uint8_t aff0 = VAR_1 % clustersz;",
"object_property_set_int(cpuobj, (aff1 << ARM_AFF1_SHIFT) | aff0,\n\"mp-affinity\", NULL);",
"}",
"if (!vms->secure) {",
"object_property_set_bool(cpuobj, false, \"has_el3\", NULL);",
"}",
"if (!vms->virt && object_property_find(cpuobj, \"has_el2\", NULL)) {",
"object_property_set_bool(cpuobj, false, \"has_el2\", NULL);",
"}",
"if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED) {",
"object_property_set_int(cpuobj, vms->psci_conduit,\n\"psci-conduit\", NULL);",
"if (VAR_1 > 0) {",
"object_property_set_bool(cpuobj, true,\n\"start-powered-off\", NULL);",
"}",
"}",
"if (vmc->no_pmu && object_property_find(cpuobj, \"pmu\", NULL)) {",
"object_property_set_bool(cpuobj, false, \"pmu\", NULL);",
"}",
"if (object_property_find(cpuobj, \"reset-cbar\", NULL)) {",
"object_property_set_int(cpuobj, vms->memmap[VIRT_CPUPERIPHS].base,\n\"reset-cbar\", &error_abort);",
"}",
"object_property_set_link(cpuobj, OBJECT(sysmem), \"memory\",\n&error_abort);",
"if (vms->secure) {",
"object_property_set_link(cpuobj, OBJECT(secure_sysmem),\n\"secure-memory\", &error_abort);",
"}",
"object_property_set_bool(cpuobj, true, \"realized\", NULL);",
"}",
"fdt_add_timer_nodes(vms);",
"fdt_add_cpu_nodes(vms);",
"fdt_add_psci_node(vms);",
"memory_region_allocate_system_memory(ram, NULL, \"mach-virt.ram\",\nVAR_0->ram_size);",
"memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram);",
"create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem);",
"create_gic(vms, pic);",
"fdt_add_pmu_nodes(vms);",
"create_uart(vms, pic, VIRT_UART, sysmem, serial_hds[0]);",
"if (vms->secure) {",
"create_secure_ram(vms, secure_sysmem);",
"create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem, serial_hds[1]);",
"}",
"create_rtc(vms, pic);",
"create_pcie(vms, pic);",
"create_gpio(vms, pic);",
"create_virtio_devices(vms, pic);",
"vms->fw_cfg = create_fw_cfg(vms, &address_space_memory);",
"rom_set_fw(vms->fw_cfg);",
"vms->machine_done.notify = virt_machine_done;",
"qemu_add_machine_init_done_notifier(&vms->machine_done);",
"vms->bootinfo.ram_size = VAR_0->ram_size;",
"vms->bootinfo.kernel_filename = VAR_0->kernel_filename;",
"vms->bootinfo.kernel_cmdline = VAR_0->kernel_cmdline;",
"vms->bootinfo.initrd_filename = VAR_0->initrd_filename;",
"vms->bootinfo.nb_cpus = smp_cpus;",
"vms->bootinfo.board_id = -1;",
"vms->bootinfo.loader_start = vms->memmap[VIRT_MEM].base;",
"vms->bootinfo.get_dtb = machvirt_dtb;",
"vms->bootinfo.firmware_loaded = firmware_loaded;",
"arm_load_kernel(ARM_CPU(first_cpu), &vms->bootinfo);",
"create_platform_bus(vms, pic);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153,
155,
157
],
[
159
],
[
161
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181,
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261
],
[
263
],
[
265
],
[
283
],
[
285
],
[
287,
289
],
[
291
],
[
295
],
[
297
],
[
299
],
[
303
],
[
305
],
[
307
],
[
311
],
[
313,
315
],
[
321
],
[
323,
325
],
[
327
],
[
329
],
[
333
],
[
335
],
[
337
],
[
341
],
[
343,
345
],
[
347
],
[
351,
353
],
[
355
],
[
357,
359
],
[
361
],
[
365
],
[
368
],
[
370
],
[
372
],
[
374
],
[
378,
380
],
[
382
],
[
386
],
[
390
],
[
394
],
[
398
],
[
402
],
[
404
],
[
406
],
[
408
],
[
412
],
[
416
],
[
420
],
[
432
],
[
436
],
[
438
],
[
442
],
[
444
],
[
448
],
[
450
],
[
452
],
[
454
],
[
456
],
[
458
],
[
460
],
[
462
],
[
464
],
[
466
],
[
482
],
[
484
]
] |
19,427 | static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
uint16_t *refcount_table, int64_t refcount_table_size, int64_t l2_offset,
int flags)
{
BDRVQcowState *s = bs->opaque;
uint64_t *l2_table, l2_entry;
uint64_t next_contiguous_offset = 0;
int i, l2_size, nb_csectors;
/* Read L2 table from disk */
l2_size = s->l2_size * sizeof(uint64_t);
l2_table = g_malloc(l2_size);
if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size)
goto fail;
/* Do the actual checks */
for(i = 0; i < s->l2_size; i++) {
l2_entry = be64_to_cpu(l2_table[i]);
switch (qcow2_get_cluster_type(l2_entry)) {
case QCOW2_CLUSTER_COMPRESSED:
/* Compressed clusters don't have QCOW_OFLAG_COPIED */
if (l2_entry & QCOW_OFLAG_COPIED) {
fprintf(stderr, "ERROR: cluster %" PRId64 ": "
"copied flag must never be set for compressed "
"clusters\n", l2_entry >> s->cluster_bits);
l2_entry &= ~QCOW_OFLAG_COPIED;
res->corruptions++;
}
/* Mark cluster as used */
nb_csectors = ((l2_entry >> s->csize_shift) &
s->csize_mask) + 1;
l2_entry &= s->cluster_offset_mask;
inc_refcounts(bs, res, refcount_table, refcount_table_size,
l2_entry & ~511, nb_csectors * 512);
if (flags & CHECK_FRAG_INFO) {
res->bfi.allocated_clusters++;
res->bfi.compressed_clusters++;
/* Compressed clusters are fragmented by nature. Since they
* take up sub-sector space but we only have sector granularity
* I/O we need to re-read the same sectors even for adjacent
* compressed clusters.
*/
res->bfi.fragmented_clusters++;
}
break;
case QCOW2_CLUSTER_ZERO:
if ((l2_entry & L2E_OFFSET_MASK) == 0) {
break;
}
/* fall through */
case QCOW2_CLUSTER_NORMAL:
{
uint64_t offset = l2_entry & L2E_OFFSET_MASK;
if (flags & CHECK_FRAG_INFO) {
res->bfi.allocated_clusters++;
if (next_contiguous_offset &&
offset != next_contiguous_offset) {
res->bfi.fragmented_clusters++;
}
next_contiguous_offset = offset + s->cluster_size;
}
/* Mark cluster as used */
inc_refcounts(bs, res, refcount_table,refcount_table_size,
offset, s->cluster_size);
/* Correct offsets are cluster aligned */
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not "
"properly aligned; L2 entry corrupted.\n", offset);
res->corruptions++;
}
break;
}
case QCOW2_CLUSTER_UNALLOCATED:
break;
default:
abort();
}
}
g_free(l2_table);
return 0;
fail:
fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n");
g_free(l2_table);
return -EIO;
}
| true | qemu | ad27390c85c50df402c7ec0d3864fc43e6559fb3 | static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
uint16_t *refcount_table, int64_t refcount_table_size, int64_t l2_offset,
int flags)
{
BDRVQcowState *s = bs->opaque;
uint64_t *l2_table, l2_entry;
uint64_t next_contiguous_offset = 0;
int i, l2_size, nb_csectors;
l2_size = s->l2_size * sizeof(uint64_t);
l2_table = g_malloc(l2_size);
if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size)
goto fail;
for(i = 0; i < s->l2_size; i++) {
l2_entry = be64_to_cpu(l2_table[i]);
switch (qcow2_get_cluster_type(l2_entry)) {
case QCOW2_CLUSTER_COMPRESSED:
if (l2_entry & QCOW_OFLAG_COPIED) {
fprintf(stderr, "ERROR: cluster %" PRId64 ": "
"copied flag must never be set for compressed "
"clusters\n", l2_entry >> s->cluster_bits);
l2_entry &= ~QCOW_OFLAG_COPIED;
res->corruptions++;
}
nb_csectors = ((l2_entry >> s->csize_shift) &
s->csize_mask) + 1;
l2_entry &= s->cluster_offset_mask;
inc_refcounts(bs, res, refcount_table, refcount_table_size,
l2_entry & ~511, nb_csectors * 512);
if (flags & CHECK_FRAG_INFO) {
res->bfi.allocated_clusters++;
res->bfi.compressed_clusters++;
res->bfi.fragmented_clusters++;
}
break;
case QCOW2_CLUSTER_ZERO:
if ((l2_entry & L2E_OFFSET_MASK) == 0) {
break;
}
case QCOW2_CLUSTER_NORMAL:
{
uint64_t offset = l2_entry & L2E_OFFSET_MASK;
if (flags & CHECK_FRAG_INFO) {
res->bfi.allocated_clusters++;
if (next_contiguous_offset &&
offset != next_contiguous_offset) {
res->bfi.fragmented_clusters++;
}
next_contiguous_offset = offset + s->cluster_size;
}
inc_refcounts(bs, res, refcount_table,refcount_table_size,
offset, s->cluster_size);
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not "
"properly aligned; L2 entry corrupted.\n", offset);
res->corruptions++;
}
break;
}
case QCOW2_CLUSTER_UNALLOCATED:
break;
default:
abort();
}
}
g_free(l2_table);
return 0;
fail:
fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n");
g_free(l2_table);
return -EIO;
}
| {
"code": [
" int i, l2_size, nb_csectors;",
" if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size)",
" fprintf(stderr, \"ERROR: I/O error in check_refcounts_l2\\n\");",
" return -EIO;",
" return -EIO;"
],
"line_no": [
15,
27,
191,
195,
195
]
} | static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,
uint16_t *VAR_2, int64_t VAR_3, int64_t VAR_4,
int VAR_5)
{
BDRVQcowState *s = VAR_0->opaque;
uint64_t *l2_table, l2_entry;
uint64_t next_contiguous_offset = 0;
int VAR_6, VAR_7, VAR_8;
VAR_7 = s->VAR_7 * sizeof(uint64_t);
l2_table = g_malloc(VAR_7);
if (bdrv_pread(VAR_0->file, VAR_4, l2_table, VAR_7) != VAR_7)
goto fail;
for(VAR_6 = 0; VAR_6 < s->VAR_7; VAR_6++) {
l2_entry = be64_to_cpu(l2_table[VAR_6]);
switch (qcow2_get_cluster_type(l2_entry)) {
case QCOW2_CLUSTER_COMPRESSED:
if (l2_entry & QCOW_OFLAG_COPIED) {
fprintf(stderr, "ERROR: cluster %" PRId64 ": "
"copied flag must never be set for compressed "
"clusters\n", l2_entry >> s->cluster_bits);
l2_entry &= ~QCOW_OFLAG_COPIED;
VAR_1->corruptions++;
}
VAR_8 = ((l2_entry >> s->csize_shift) &
s->csize_mask) + 1;
l2_entry &= s->cluster_offset_mask;
inc_refcounts(VAR_0, VAR_1, VAR_2, VAR_3,
l2_entry & ~511, VAR_8 * 512);
if (VAR_5 & CHECK_FRAG_INFO) {
VAR_1->bfi.allocated_clusters++;
VAR_1->bfi.compressed_clusters++;
VAR_1->bfi.fragmented_clusters++;
}
break;
case QCOW2_CLUSTER_ZERO:
if ((l2_entry & L2E_OFFSET_MASK) == 0) {
break;
}
case QCOW2_CLUSTER_NORMAL:
{
uint64_t offset = l2_entry & L2E_OFFSET_MASK;
if (VAR_5 & CHECK_FRAG_INFO) {
VAR_1->bfi.allocated_clusters++;
if (next_contiguous_offset &&
offset != next_contiguous_offset) {
VAR_1->bfi.fragmented_clusters++;
}
next_contiguous_offset = offset + s->cluster_size;
}
inc_refcounts(VAR_0, VAR_1, VAR_2,VAR_3,
offset, s->cluster_size);
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not "
"properly aligned; L2 entry corrupted.\n", offset);
VAR_1->corruptions++;
}
break;
}
case QCOW2_CLUSTER_UNALLOCATED:
break;
default:
abort();
}
}
g_free(l2_table);
return 0;
fail:
fprintf(stderr, "ERROR: I/O error in FUNC_0\n");
g_free(l2_table);
return -EIO;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,\nuint16_t *VAR_2, int64_t VAR_3, int64_t VAR_4,\nint VAR_5)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"uint64_t *l2_table, l2_entry;",
"uint64_t next_contiguous_offset = 0;",
"int VAR_6, VAR_7, VAR_8;",
"VAR_7 = s->VAR_7 * sizeof(uint64_t);",
"l2_table = g_malloc(VAR_7);",
"if (bdrv_pread(VAR_0->file, VAR_4, l2_table, VAR_7) != VAR_7)\ngoto fail;",
"for(VAR_6 = 0; VAR_6 < s->VAR_7; VAR_6++) {",
"l2_entry = be64_to_cpu(l2_table[VAR_6]);",
"switch (qcow2_get_cluster_type(l2_entry)) {",
"case QCOW2_CLUSTER_COMPRESSED:\nif (l2_entry & QCOW_OFLAG_COPIED) {",
"fprintf(stderr, \"ERROR: cluster %\" PRId64 \": \"\n\"copied flag must never be set for compressed \"\n\"clusters\\n\", l2_entry >> s->cluster_bits);",
"l2_entry &= ~QCOW_OFLAG_COPIED;",
"VAR_1->corruptions++;",
"}",
"VAR_8 = ((l2_entry >> s->csize_shift) &\ns->csize_mask) + 1;",
"l2_entry &= s->cluster_offset_mask;",
"inc_refcounts(VAR_0, VAR_1, VAR_2, VAR_3,\nl2_entry & ~511, VAR_8 * 512);",
"if (VAR_5 & CHECK_FRAG_INFO) {",
"VAR_1->bfi.allocated_clusters++;",
"VAR_1->bfi.compressed_clusters++;",
"VAR_1->bfi.fragmented_clusters++;",
"}",
"break;",
"case QCOW2_CLUSTER_ZERO:\nif ((l2_entry & L2E_OFFSET_MASK) == 0) {",
"break;",
"}",
"case QCOW2_CLUSTER_NORMAL:\n{",
"uint64_t offset = l2_entry & L2E_OFFSET_MASK;",
"if (VAR_5 & CHECK_FRAG_INFO) {",
"VAR_1->bfi.allocated_clusters++;",
"if (next_contiguous_offset &&\noffset != next_contiguous_offset) {",
"VAR_1->bfi.fragmented_clusters++;",
"}",
"next_contiguous_offset = offset + s->cluster_size;",
"}",
"inc_refcounts(VAR_0, VAR_1, VAR_2,VAR_3,\noffset, s->cluster_size);",
"if (offset_into_cluster(s, offset)) {",
"fprintf(stderr, \"ERROR offset=%\" PRIx64 \": Cluster is not \"\n\"properly aligned; L2 entry corrupted.\\n\", offset);",
"VAR_1->corruptions++;",
"}",
"break;",
"}",
"case QCOW2_CLUSTER_UNALLOCATED:\nbreak;",
"default:\nabort();",
"}",
"}",
"g_free(l2_table);",
"return 0;",
"fail:\nfprintf(stderr, \"ERROR: I/O error in FUNC_0\\n\");",
"g_free(l2_table);",
"return -EIO;",
"}"
] | [
0,
0,
0,
0,
1,
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,
1,
0,
1,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
27,
29
],
[
35
],
[
37
],
[
41
],
[
43,
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
59
],
[
65,
67
],
[
69
],
[
71,
73
],
[
77
],
[
79
],
[
81
],
[
95
],
[
97
],
[
99
],
[
103,
105
],
[
107
],
[
109
],
[
115,
117
],
[
119
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
143,
145
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167,
169
],
[
173,
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
189,
191
],
[
193
],
[
195
],
[
197
]
] |
19,428 | static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame)
{
DiracFrame *out = s->delay_frames[0];
int i, out_idx = 0;
int ret;
/* find frame with lowest picture number */
for (i = 1; s->delay_frames[i]; i++)
if (s->delay_frames[i]->avframe->display_picture_number < out->avframe->display_picture_number) {
out = s->delay_frames[i];
out_idx = i;
}
for (i = out_idx; s->delay_frames[i]; i++)
s->delay_frames[i] = s->delay_frames[i+1];
if (out) {
out->reference ^= DELAYED_PIC_REF;
*got_frame = 1;
if((ret = av_frame_ref(picture, out->avframe)) < 0)
return ret;
}
return 0;
}
| true | FFmpeg | 6899e6e56065d9365963e02690dc9e2ce7866050 | static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame)
{
DiracFrame *out = s->delay_frames[0];
int i, out_idx = 0;
int ret;
for (i = 1; s->delay_frames[i]; i++)
if (s->delay_frames[i]->avframe->display_picture_number < out->avframe->display_picture_number) {
out = s->delay_frames[i];
out_idx = i;
}
for (i = out_idx; s->delay_frames[i]; i++)
s->delay_frames[i] = s->delay_frames[i+1];
if (out) {
out->reference ^= DELAYED_PIC_REF;
*got_frame = 1;
if((ret = av_frame_ref(picture, out->avframe)) < 0)
return ret;
}
return 0;
}
| {
"code": [
" *got_frame = 1;"
],
"line_no": [
37
]
} | static int FUNC_0(DiracContext *VAR_0, AVFrame *VAR_1, int *VAR_2)
{
DiracFrame *out = VAR_0->delay_frames[0];
int VAR_3, VAR_4 = 0;
int VAR_5;
for (VAR_3 = 1; VAR_0->delay_frames[VAR_3]; VAR_3++)
if (VAR_0->delay_frames[VAR_3]->avframe->display_picture_number < out->avframe->display_picture_number) {
out = VAR_0->delay_frames[VAR_3];
VAR_4 = VAR_3;
}
for (VAR_3 = VAR_4; VAR_0->delay_frames[VAR_3]; VAR_3++)
VAR_0->delay_frames[VAR_3] = VAR_0->delay_frames[VAR_3+1];
if (out) {
out->reference ^= DELAYED_PIC_REF;
*VAR_2 = 1;
if((VAR_5 = av_frame_ref(VAR_1, out->avframe)) < 0)
return VAR_5;
}
return 0;
}
| [
"static int FUNC_0(DiracContext *VAR_0, AVFrame *VAR_1, int *VAR_2)\n{",
"DiracFrame *out = VAR_0->delay_frames[0];",
"int VAR_3, VAR_4 = 0;",
"int VAR_5;",
"for (VAR_3 = 1; VAR_0->delay_frames[VAR_3]; VAR_3++)",
"if (VAR_0->delay_frames[VAR_3]->avframe->display_picture_number < out->avframe->display_picture_number) {",
"out = VAR_0->delay_frames[VAR_3];",
"VAR_4 = VAR_3;",
"}",
"for (VAR_3 = VAR_4; VAR_0->delay_frames[VAR_3]; VAR_3++)",
"VAR_0->delay_frames[VAR_3] = VAR_0->delay_frames[VAR_3+1];",
"if (out) {",
"out->reference ^= DELAYED_PIC_REF;",
"*VAR_2 = 1;",
"if((VAR_5 = av_frame_ref(VAR_1, out->avframe)) < 0)\nreturn VAR_5;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
47
],
[
49
]
] |
19,429 | static void do_subtitle_out(AVFormatContext *s,
OutputStream *ost,
InputStream *ist,
AVSubtitle *sub)
{
int subtitle_out_max_size = 1024 * 1024;
int subtitle_out_size, nb, i;
AVCodecContext *enc;
AVPacket pkt;
int64_t pts;
if (sub->pts == AV_NOPTS_VALUE) {
av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
if (exit_on_error)
exit_program(1);
return;
}
enc = ost->enc_ctx;
if (!subtitle_out) {
subtitle_out = av_malloc(subtitle_out_max_size);
if (!subtitle_out) {
av_log(NULL, AV_LOG_FATAL, "Failed to allocate subtitle_out\n");
exit_program(1);
}
}
/* Note: DVB subtitle need one packet to draw them and one other
packet to clear them */
/* XXX: signal it in the codec context ? */
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
nb = 2;
else
nb = 1;
/* shift timestamp to honor -ss and make check_recording_time() work with -t */
pts = sub->pts;
if (output_files[ost->file_index]->start_time != AV_NOPTS_VALUE)
pts -= output_files[ost->file_index]->start_time;
for (i = 0; i < nb; i++) {
unsigned save_num_rects = sub->num_rects;
ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);
if (!check_recording_time(ost))
return;
sub->pts = pts;
// start_display_time is required to be 0
sub->pts += av_rescale_q(sub->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q);
sub->end_display_time -= sub->start_display_time;
sub->start_display_time = 0;
if (i == 1)
sub->num_rects = 0;
ost->frames_encoded++;
subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out,
subtitle_out_max_size, sub);
if (i == 1)
sub->num_rects = save_num_rects;
if (subtitle_out_size < 0) {
av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
exit_program(1);
}
av_init_packet(&pkt);
pkt.data = subtitle_out;
pkt.size = subtitle_out_size;
pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base);
pkt.duration = av_rescale_q(sub->end_display_time, (AVRational){ 1, 1000 }, ost->st->time_base);
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
/* XXX: the pts correction is handled here. Maybe handling
it in the codec would be better */
if (i == 0)
pkt.pts += 90 * sub->start_display_time;
else
pkt.pts += 90 * sub->end_display_time;
}
pkt.dts = pkt.pts;
write_frame(s, &pkt, ost);
}
}
| true | FFmpeg | 5ef19590802f000299e418143fc2301e3f43affe | static void do_subtitle_out(AVFormatContext *s,
OutputStream *ost,
InputStream *ist,
AVSubtitle *sub)
{
int subtitle_out_max_size = 1024 * 1024;
int subtitle_out_size, nb, i;
AVCodecContext *enc;
AVPacket pkt;
int64_t pts;
if (sub->pts == AV_NOPTS_VALUE) {
av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
if (exit_on_error)
exit_program(1);
return;
}
enc = ost->enc_ctx;
if (!subtitle_out) {
subtitle_out = av_malloc(subtitle_out_max_size);
if (!subtitle_out) {
av_log(NULL, AV_LOG_FATAL, "Failed to allocate subtitle_out\n");
exit_program(1);
}
}
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
nb = 2;
else
nb = 1;
pts = sub->pts;
if (output_files[ost->file_index]->start_time != AV_NOPTS_VALUE)
pts -= output_files[ost->file_index]->start_time;
for (i = 0; i < nb; i++) {
unsigned save_num_rects = sub->num_rects;
ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);
if (!check_recording_time(ost))
return;
sub->pts = pts;
sub->pts += av_rescale_q(sub->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q);
sub->end_display_time -= sub->start_display_time;
sub->start_display_time = 0;
if (i == 1)
sub->num_rects = 0;
ost->frames_encoded++;
subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out,
subtitle_out_max_size, sub);
if (i == 1)
sub->num_rects = save_num_rects;
if (subtitle_out_size < 0) {
av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
exit_program(1);
}
av_init_packet(&pkt);
pkt.data = subtitle_out;
pkt.size = subtitle_out_size;
pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base);
pkt.duration = av_rescale_q(sub->end_display_time, (AVRational){ 1, 1000 }, ost->st->time_base);
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
if (i == 0)
pkt.pts += 90 * sub->start_display_time;
else
pkt.pts += 90 * sub->end_display_time;
}
pkt.dts = pkt.pts;
write_frame(s, &pkt, ost);
}
}
| {
"code": [
" if (exit_on_error)",
" exit_program(1);",
" exit_program(1);",
" write_frame(s, &pkt, ost);",
" write_frame(s, &pkt, ost);",
" write_frame(s, &pkt, ost);"
],
"line_no": [
27,
29,
29,
161,
161,
161
]
} | static void FUNC_0(AVFormatContext *VAR_0,
OutputStream *VAR_1,
InputStream *VAR_2,
AVSubtitle *VAR_3)
{
int VAR_4 = 1024 * 1024;
int VAR_5, VAR_6, VAR_7;
AVCodecContext *enc;
AVPacket pkt;
int64_t pts;
if (VAR_3->pts == AV_NOPTS_VALUE) {
av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
if (exit_on_error)
exit_program(1);
return;
}
enc = VAR_1->enc_ctx;
if (!subtitle_out) {
subtitle_out = av_malloc(VAR_4);
if (!subtitle_out) {
av_log(NULL, AV_LOG_FATAL, "Failed to allocate subtitle_out\n");
exit_program(1);
}
}
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
VAR_6 = 2;
else
VAR_6 = 1;
pts = VAR_3->pts;
if (output_files[VAR_1->file_index]->start_time != AV_NOPTS_VALUE)
pts -= output_files[VAR_1->file_index]->start_time;
for (VAR_7 = 0; VAR_7 < VAR_6; VAR_7++) {
unsigned VAR_8 = VAR_3->num_rects;
VAR_1->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);
if (!check_recording_time(VAR_1))
return;
VAR_3->pts = pts;
VAR_3->pts += av_rescale_q(VAR_3->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q);
VAR_3->end_display_time -= VAR_3->start_display_time;
VAR_3->start_display_time = 0;
if (VAR_7 == 1)
VAR_3->num_rects = 0;
VAR_1->frames_encoded++;
VAR_5 = avcodec_encode_subtitle(enc, subtitle_out,
VAR_4, VAR_3);
if (VAR_7 == 1)
VAR_3->num_rects = VAR_8;
if (VAR_5 < 0) {
av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
exit_program(1);
}
av_init_packet(&pkt);
pkt.data = subtitle_out;
pkt.size = VAR_5;
pkt.pts = av_rescale_q(VAR_3->pts, AV_TIME_BASE_Q, VAR_1->st->time_base);
pkt.duration = av_rescale_q(VAR_3->end_display_time, (AVRational){ 1, 1000 }, VAR_1->st->time_base);
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
if (VAR_7 == 0)
pkt.pts += 90 * VAR_3->start_display_time;
else
pkt.pts += 90 * VAR_3->end_display_time;
}
pkt.dts = pkt.pts;
write_frame(VAR_0, &pkt, VAR_1);
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0,\nOutputStream *VAR_1,\nInputStream *VAR_2,\nAVSubtitle *VAR_3)\n{",
"int VAR_4 = 1024 * 1024;",
"int VAR_5, VAR_6, VAR_7;",
"AVCodecContext *enc;",
"AVPacket pkt;",
"int64_t pts;",
"if (VAR_3->pts == AV_NOPTS_VALUE) {",
"av_log(NULL, AV_LOG_ERROR, \"Subtitle packets must have a pts\\n\");",
"if (exit_on_error)\nexit_program(1);",
"return;",
"}",
"enc = VAR_1->enc_ctx;",
"if (!subtitle_out) {",
"subtitle_out = av_malloc(VAR_4);",
"if (!subtitle_out) {",
"av_log(NULL, AV_LOG_FATAL, \"Failed to allocate subtitle_out\\n\");",
"exit_program(1);",
"}",
"}",
"if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE)\nVAR_6 = 2;",
"else\nVAR_6 = 1;",
"pts = VAR_3->pts;",
"if (output_files[VAR_1->file_index]->start_time != AV_NOPTS_VALUE)\npts -= output_files[VAR_1->file_index]->start_time;",
"for (VAR_7 = 0; VAR_7 < VAR_6; VAR_7++) {",
"unsigned VAR_8 = VAR_3->num_rects;",
"VAR_1->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);",
"if (!check_recording_time(VAR_1))\nreturn;",
"VAR_3->pts = pts;",
"VAR_3->pts += av_rescale_q(VAR_3->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q);",
"VAR_3->end_display_time -= VAR_3->start_display_time;",
"VAR_3->start_display_time = 0;",
"if (VAR_7 == 1)\nVAR_3->num_rects = 0;",
"VAR_1->frames_encoded++;",
"VAR_5 = avcodec_encode_subtitle(enc, subtitle_out,\nVAR_4, VAR_3);",
"if (VAR_7 == 1)\nVAR_3->num_rects = VAR_8;",
"if (VAR_5 < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Subtitle encoding failed\\n\");",
"exit_program(1);",
"}",
"av_init_packet(&pkt);",
"pkt.data = subtitle_out;",
"pkt.size = VAR_5;",
"pkt.pts = av_rescale_q(VAR_3->pts, AV_TIME_BASE_Q, VAR_1->st->time_base);",
"pkt.duration = av_rescale_q(VAR_3->end_display_time, (AVRational){ 1, 1000 }, VAR_1->st->time_base);",
"if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {",
"if (VAR_7 == 0)\npkt.pts += 90 * VAR_3->start_display_time;",
"else\npkt.pts += 90 * VAR_3->end_display_time;",
"}",
"pkt.dts = pkt.pts;",
"write_frame(VAR_0, &pkt, VAR_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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
63,
65
],
[
67,
69
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
87
],
[
89,
91
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
111
],
[
115,
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
149,
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
]
] |
19,430 | static int bdrv_has_snapshot(BlockDriverState *bs)
{
return (bs &&
!bdrv_is_removable(bs) &&
!bdrv_is_read_only(bs));
}
| true | qemu | feeee5aca765606818e00f5a19d19f141f4ae365 | static int bdrv_has_snapshot(BlockDriverState *bs)
{
return (bs &&
!bdrv_is_removable(bs) &&
!bdrv_is_read_only(bs));
}
| {
"code": [
" return (bs &&",
" !bdrv_is_removable(bs) &&",
" !bdrv_is_read_only(bs));",
"static int bdrv_has_snapshot(BlockDriverState *bs)",
" return (bs &&",
" !bdrv_is_removable(bs) &&",
" !bdrv_is_read_only(bs));"
],
"line_no": [
5,
7,
9,
1,
5,
7,
9
]
} | static int FUNC_0(BlockDriverState *VAR_0)
{
return (VAR_0 &&
!bdrv_is_removable(VAR_0) &&
!bdrv_is_read_only(VAR_0));
}
| [
"static int FUNC_0(BlockDriverState *VAR_0)\n{",
"return (VAR_0 &&\n!bdrv_is_removable(VAR_0) &&\n!bdrv_is_read_only(VAR_0));",
"}"
] | [
1,
1,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11
]
] |
19,432 | static void dec_ill(DisasContext *dc)
{
cpu_abort(dc->env, "unknown opcode 0x%02x\n", dc->opcode);
}
| true | qemu | 3604a76fea6ff37738d4a8f596be38407be74a83 | static void dec_ill(DisasContext *dc)
{
cpu_abort(dc->env, "unknown opcode 0x%02x\n", dc->opcode);
}
| {
"code": [
" cpu_abort(dc->env, \"unknown opcode 0x%02x\\n\", dc->opcode);"
],
"line_no": [
5
]
} | static void FUNC_0(DisasContext *VAR_0)
{
cpu_abort(VAR_0->env, "unknown opcode 0x%02x\n", VAR_0->opcode);
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"cpu_abort(VAR_0->env, \"unknown opcode 0x%02x\\n\", VAR_0->opcode);",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
19,433 | static int vhdx_create_new_headers(BlockDriverState *bs, uint64_t image_size,
uint32_t log_size)
{
int ret = 0;
VHDXHeader *hdr = NULL;
hdr = g_malloc0(sizeof(VHDXHeader));
hdr->signature = VHDX_HEADER_SIGNATURE;
hdr->sequence_number = g_random_int();
hdr->log_version = 0;
hdr->version = 1;
hdr->log_length = log_size;
hdr->log_offset = VHDX_HEADER_SECTION_END;
vhdx_guid_generate(&hdr->file_write_guid);
vhdx_guid_generate(&hdr->data_write_guid);
ret = vhdx_write_header(bs, hdr, VHDX_HEADER1_OFFSET, false);
if (ret < 0) {
goto exit;
}
hdr->sequence_number++;
ret = vhdx_write_header(bs, hdr, VHDX_HEADER2_OFFSET, false);
if (ret < 0) {
goto exit;
}
exit:
g_free(hdr);
return ret;
}
| true | qemu | 5839e53bbc0fec56021d758aab7610df421ed8c8 | static int vhdx_create_new_headers(BlockDriverState *bs, uint64_t image_size,
uint32_t log_size)
{
int ret = 0;
VHDXHeader *hdr = NULL;
hdr = g_malloc0(sizeof(VHDXHeader));
hdr->signature = VHDX_HEADER_SIGNATURE;
hdr->sequence_number = g_random_int();
hdr->log_version = 0;
hdr->version = 1;
hdr->log_length = log_size;
hdr->log_offset = VHDX_HEADER_SECTION_END;
vhdx_guid_generate(&hdr->file_write_guid);
vhdx_guid_generate(&hdr->data_write_guid);
ret = vhdx_write_header(bs, hdr, VHDX_HEADER1_OFFSET, false);
if (ret < 0) {
goto exit;
}
hdr->sequence_number++;
ret = vhdx_write_header(bs, hdr, VHDX_HEADER2_OFFSET, false);
if (ret < 0) {
goto exit;
}
exit:
g_free(hdr);
return ret;
}
| {
"code": [
" hdr = g_malloc0(sizeof(VHDXHeader));"
],
"line_no": [
13
]
} | static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
uint32_t VAR_2)
{
int VAR_3 = 0;
VHDXHeader *hdr = NULL;
hdr = g_malloc0(sizeof(VHDXHeader));
hdr->signature = VHDX_HEADER_SIGNATURE;
hdr->sequence_number = g_random_int();
hdr->log_version = 0;
hdr->version = 1;
hdr->log_length = VAR_2;
hdr->log_offset = VHDX_HEADER_SECTION_END;
vhdx_guid_generate(&hdr->file_write_guid);
vhdx_guid_generate(&hdr->data_write_guid);
VAR_3 = vhdx_write_header(VAR_0, hdr, VHDX_HEADER1_OFFSET, false);
if (VAR_3 < 0) {
goto exit;
}
hdr->sequence_number++;
VAR_3 = vhdx_write_header(VAR_0, hdr, VHDX_HEADER2_OFFSET, false);
if (VAR_3 < 0) {
goto exit;
}
exit:
g_free(hdr);
return VAR_3;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nuint32_t VAR_2)\n{",
"int VAR_3 = 0;",
"VHDXHeader *hdr = NULL;",
"hdr = g_malloc0(sizeof(VHDXHeader));",
"hdr->signature = VHDX_HEADER_SIGNATURE;",
"hdr->sequence_number = g_random_int();",
"hdr->log_version = 0;",
"hdr->version = 1;",
"hdr->log_length = VAR_2;",
"hdr->log_offset = VHDX_HEADER_SECTION_END;",
"vhdx_guid_generate(&hdr->file_write_guid);",
"vhdx_guid_generate(&hdr->data_write_guid);",
"VAR_3 = vhdx_write_header(VAR_0, hdr, VHDX_HEADER1_OFFSET, false);",
"if (VAR_3 < 0) {",
"goto exit;",
"}",
"hdr->sequence_number++;",
"VAR_3 = vhdx_write_header(VAR_0, hdr, VHDX_HEADER2_OFFSET, false);",
"if (VAR_3 < 0) {",
"goto exit;",
"}",
"exit:\ng_free(hdr);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
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
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
]
] |
19,436 | void checkasm_check_h264qpel(void)
{
LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
H264QpelContext h;
int op, bit_depth, i, j;
for (op = 0; op < 2; op++) {
qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab;
const char *op_name = op ? "avg" : "put";
for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
ff_h264qpel_init(&h, bit_depth);
for (i = 0; i < (op ? 3 : 4); i++) {
int size = 16 >> i;
for (j = 0; j < 16; j++)
if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) {
randomize_buffers();
call_ref(dst0, src0, (ptrdiff_t)size * SIZEOF_PIXEL);
call_new(dst1, src1, (ptrdiff_t)size * SIZEOF_PIXEL);
if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))
fail();
bench_new(dst1, src1, (ptrdiff_t)size * SIZEOF_PIXEL);
}
}
}
report("%s", op_name);
}
}
| false | FFmpeg | 515b69f8f8e9a24cfaee95d8c1f63f265d8582fe | void checkasm_check_h264qpel(void)
{
LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
H264QpelContext h;
int op, bit_depth, i, j;
for (op = 0; op < 2; op++) {
qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab;
const char *op_name = op ? "avg" : "put";
for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
ff_h264qpel_init(&h, bit_depth);
for (i = 0; i < (op ? 3 : 4); i++) {
int size = 16 >> i;
for (j = 0; j < 16; j++)
if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) {
randomize_buffers();
call_ref(dst0, src0, (ptrdiff_t)size * SIZEOF_PIXEL);
call_new(dst1, src1, (ptrdiff_t)size * SIZEOF_PIXEL);
if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))
fail();
bench_new(dst1, src1, (ptrdiff_t)size * SIZEOF_PIXEL);
}
}
}
report("%s", op_name);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
H264QpelContext h;
int VAR_0, VAR_1, VAR_2, VAR_3;
for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {
qpel_mc_func (*tab)[16] = VAR_0 ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab;
const char *VAR_4 = VAR_0 ? "avg" : "put";
for (VAR_1 = 8; VAR_1 <= 10; VAR_1++) {
ff_h264qpel_init(&h, VAR_1);
for (VAR_2 = 0; VAR_2 < (VAR_0 ? 3 : 4); VAR_2++) {
int VAR_5 = 16 >> VAR_2;
for (VAR_3 = 0; VAR_3 < 16; VAR_3++)
if (check_func(tab[VAR_2][VAR_3], "%s_h264_qpel_%d_mc%d%d_%d", VAR_4, VAR_5, VAR_3 & 3, VAR_3 >> 2, VAR_1)) {
randomize_buffers();
call_ref(dst0, src0, (ptrdiff_t)VAR_5 * SIZEOF_PIXEL);
call_new(dst1, src1, (ptrdiff_t)VAR_5 * SIZEOF_PIXEL);
if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))
fail();
bench_new(dst1, src1, (ptrdiff_t)VAR_5 * SIZEOF_PIXEL);
}
}
}
report("%s", VAR_4);
}
}
| [
"void FUNC_0(void)\n{",
"LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);",
"LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);",
"LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);",
"LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);",
"H264QpelContext h;",
"int VAR_0, VAR_1, VAR_2, VAR_3;",
"for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {",
"qpel_mc_func (*tab)[16] = VAR_0 ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab;",
"const char *VAR_4 = VAR_0 ? \"avg\" : \"put\";",
"for (VAR_1 = 8; VAR_1 <= 10; VAR_1++) {",
"ff_h264qpel_init(&h, VAR_1);",
"for (VAR_2 = 0; VAR_2 < (VAR_0 ? 3 : 4); VAR_2++) {",
"int VAR_5 = 16 >> VAR_2;",
"for (VAR_3 = 0; VAR_3 < 16; VAR_3++)",
"if (check_func(tab[VAR_2][VAR_3], \"%s_h264_qpel_%d_mc%d%d_%d\", VAR_4, VAR_5, VAR_3 & 3, VAR_3 >> 2, VAR_1)) {",
"randomize_buffers();",
"call_ref(dst0, src0, (ptrdiff_t)VAR_5 * SIZEOF_PIXEL);",
"call_new(dst1, src1, (ptrdiff_t)VAR_5 * SIZEOF_PIXEL);",
"if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))\nfail();",
"bench_new(dst1, src1, (ptrdiff_t)VAR_5 * SIZEOF_PIXEL);",
"}",
"}",
"}",
"report(\"%s\", 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
19,437 | static int wma_decode_init(AVCodecContext * avctx)
{
WMADecodeContext *s = avctx->priv_data;
int i, flags1, flags2;
float *window;
uint8_t *extradata;
float bps1, high_freq, bps;
int sample_rate1;
int coef_vlc_table;
s->sample_rate = avctx->sample_rate;
s->nb_channels = avctx->channels;
s->bit_rate = avctx->bit_rate;
s->block_align = avctx->block_align;
if (avctx->codec_id == CODEC_ID_WMAV1) {
s->version = 1;
} else {
s->version = 2;
}
/* extract flag infos */
flags1 = 0;
flags2 = 0;
extradata = avctx->extradata;
if (s->version == 1 && avctx->extradata_size >= 4) {
flags1 = extradata[0] | (extradata[1] << 8);
flags2 = extradata[2] | (extradata[3] << 8);
} else if (s->version == 2 && avctx->extradata_size >= 6) {
flags1 = extradata[0] | (extradata[1] << 8) |
(extradata[2] << 16) | (extradata[3] << 24);
flags2 = extradata[4] | (extradata[5] << 8);
}
s->use_exp_vlc = flags2 & 0x0001;
s->use_bit_reservoir = flags2 & 0x0002;
s->use_variable_block_len = flags2 & 0x0004;
/* compute MDCT block size */
if (s->sample_rate <= 16000) {
s->frame_len_bits = 9;
} else if (s->sample_rate <= 22050 ||
(s->sample_rate <= 32000 && s->version == 1)) {
s->frame_len_bits = 10;
} else {
s->frame_len_bits = 11;
}
s->frame_len = 1 << s->frame_len_bits;
if (s->use_variable_block_len) {
s->nb_block_sizes = s->frame_len_bits - BLOCK_MIN_BITS + 1;
} else {
s->nb_block_sizes = 1;
}
/* init rate dependant parameters */
s->use_noise_coding = 1;
high_freq = s->sample_rate * 0.5;
/* if version 2, then the rates are normalized */
sample_rate1 = s->sample_rate;
if (s->version == 2) {
if (sample_rate1 >= 44100)
sample_rate1 = 44100;
else if (sample_rate1 >= 22050)
sample_rate1 = 22050;
else if (sample_rate1 >= 16000)
sample_rate1 = 16000;
else if (sample_rate1 >= 11025)
sample_rate1 = 11025;
else if (sample_rate1 >= 8000)
sample_rate1 = 8000;
}
bps = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);
s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0)) + 2;
/* compute high frequency value and choose if noise coding should
be activated */
bps1 = bps;
if (s->nb_channels == 2)
bps1 = bps * 1.6;
if (sample_rate1 == 44100) {
if (bps1 >= 0.61)
s->use_noise_coding = 0;
else
high_freq = high_freq * 0.4;
} else if (sample_rate1 == 22050) {
if (bps1 >= 1.16)
s->use_noise_coding = 0;
else if (bps1 >= 0.72)
high_freq = high_freq * 0.7;
else
high_freq = high_freq * 0.6;
} else if (sample_rate1 == 16000) {
if (bps > 0.5)
high_freq = high_freq * 0.5;
else
high_freq = high_freq * 0.3;
} else if (sample_rate1 == 11025) {
high_freq = high_freq * 0.7;
} else if (sample_rate1 == 8000) {
if (bps <= 0.625) {
high_freq = high_freq * 0.5;
} else if (bps > 0.75) {
s->use_noise_coding = 0;
} else {
high_freq = high_freq * 0.65;
}
} else {
if (bps >= 0.8) {
high_freq = high_freq * 0.75;
} else if (bps >= 0.6) {
high_freq = high_freq * 0.6;
} else {
high_freq = high_freq * 0.5;
}
}
#ifdef DEBUG_PARAMS
printf("flags1=0x%x flags2=0x%x\n", flags1, flags2);
printf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
s->version, s->nb_channels, s->sample_rate, s->bit_rate,
s->block_align);
printf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
bps, bps1, high_freq, s->byte_offset_bits);
printf("use_noise_coding=%d use_exp_vlc=%d\n",
s->use_noise_coding, s->use_exp_vlc);
#endif
/* compute the scale factor band sizes for each MDCT block size */
{
int a, b, pos, lpos, k, block_len, i, j, n;
const uint8_t *table;
if (s->version == 1) {
s->coefs_start = 3;
} else {
s->coefs_start = 0;
}
for(k = 0; k < s->nb_block_sizes; k++) {
block_len = s->frame_len >> k;
if (s->version == 1) {
lpos = 0;
for(i=0;i<25;i++) {
a = wma_critical_freqs[i];
b = s->sample_rate;
pos = ((block_len * 2 * a) + (b >> 1)) / b;
if (pos > block_len)
pos = block_len;
s->exponent_bands[0][i] = pos - lpos;
if (pos >= block_len) {
i++;
break;
}
lpos = pos;
}
s->exponent_sizes[0] = i;
} else {
/* hardcoded tables */
table = NULL;
a = s->frame_len_bits - BLOCK_MIN_BITS - k;
if (a < 3) {
if (s->sample_rate >= 44100)
table = exponent_band_44100[a];
else if (s->sample_rate >= 32000)
table = exponent_band_32000[a];
else if (s->sample_rate >= 22050)
table = exponent_band_22050[a];
}
if (table) {
n = *table++;
for(i=0;i<n;i++)
s->exponent_bands[k][i] = table[i];
s->exponent_sizes[k] = n;
} else {
j = 0;
lpos = 0;
for(i=0;i<25;i++) {
a = wma_critical_freqs[i];
b = s->sample_rate;
pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
pos <<= 2;
if (pos > block_len)
pos = block_len;
if (pos > lpos)
s->exponent_bands[k][j++] = pos - lpos;
if (pos >= block_len)
break;
lpos = pos;
}
s->exponent_sizes[k] = j;
}
}
/* max number of coefs */
s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
/* high freq computation */
s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
s->sample_rate + 0.5);
n = s->exponent_sizes[k];
j = 0;
pos = 0;
for(i=0;i<n;i++) {
int start, end;
start = pos;
pos += s->exponent_bands[k][i];
end = pos;
if (start < s->high_band_start[k])
start = s->high_band_start[k];
if (end > s->coefs_end[k])
end = s->coefs_end[k];
if (end > start)
s->exponent_high_bands[k][j++] = end - start;
}
s->exponent_high_sizes[k] = j;
#if 0
trace("%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
s->frame_len >> k,
s->coefs_end[k],
s->high_band_start[k],
s->exponent_high_sizes[k]);
for(j=0;j<s->exponent_high_sizes[k];j++)
trace(" %d", s->exponent_high_bands[k][j]);
trace("\n");
#endif
}
}
#ifdef DEBUG_TRACE
{
int i, j;
for(i = 0; i < s->nb_block_sizes; i++) {
trace("%5d: n=%2d:",
s->frame_len >> i,
s->exponent_sizes[i]);
for(j=0;j<s->exponent_sizes[i];j++)
trace(" %d", s->exponent_bands[i][j]);
trace("\n");
}
}
#endif
/* init MDCT */
for(i = 0; i < s->nb_block_sizes; i++)
ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1);
/* init MDCT windows : simple sinus window */
for(i = 0; i < s->nb_block_sizes; i++) {
int n, j;
float alpha;
n = 1 << (s->frame_len_bits - i);
window = av_malloc(sizeof(float) * n);
alpha = M_PI / (2.0 * n);
for(j=0;j<n;j++) {
window[n - j - 1] = sin((j + 0.5) * alpha);
}
s->windows[i] = window;
}
s->reset_block_lengths = 1;
if (s->use_noise_coding) {
/* init the noise generator */
if (s->use_exp_vlc)
s->noise_mult = 0.02;
else
s->noise_mult = 0.04;
#if defined(DEBUG_TRACE)
for(i=0;i<NOISE_TAB_SIZE;i++)
s->noise_table[i] = 1.0 * s->noise_mult;
#else
{
unsigned int seed;
float norm;
seed = 1;
norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;
for(i=0;i<NOISE_TAB_SIZE;i++) {
seed = seed * 314159 + 1;
s->noise_table[i] = (float)((int)seed) * norm;
}
}
#endif
init_vlc(&s->hgain_vlc, 9, sizeof(hgain_huffbits),
hgain_huffbits, 1, 1,
hgain_huffcodes, 2, 2);
}
if (s->use_exp_vlc) {
init_vlc(&s->exp_vlc, 9, sizeof(scale_huffbits),
scale_huffbits, 1, 1,
scale_huffcodes, 4, 4);
} else {
wma_lsp_to_curve_init(s, s->frame_len);
}
/* choose the VLC tables for the coefficients */
coef_vlc_table = 2;
if (s->sample_rate >= 32000) {
if (bps1 < 0.72)
coef_vlc_table = 0;
else if (bps1 < 1.16)
coef_vlc_table = 1;
}
init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],
&coef_vlcs[coef_vlc_table * 2]);
init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
&coef_vlcs[coef_vlc_table * 2 + 1]);
return 0;
}
| false | FFmpeg | 4707cb07e1ceb0d1a518eda08fbf0d4035ea7745 | static int wma_decode_init(AVCodecContext * avctx)
{
WMADecodeContext *s = avctx->priv_data;
int i, flags1, flags2;
float *window;
uint8_t *extradata;
float bps1, high_freq, bps;
int sample_rate1;
int coef_vlc_table;
s->sample_rate = avctx->sample_rate;
s->nb_channels = avctx->channels;
s->bit_rate = avctx->bit_rate;
s->block_align = avctx->block_align;
if (avctx->codec_id == CODEC_ID_WMAV1) {
s->version = 1;
} else {
s->version = 2;
}
flags1 = 0;
flags2 = 0;
extradata = avctx->extradata;
if (s->version == 1 && avctx->extradata_size >= 4) {
flags1 = extradata[0] | (extradata[1] << 8);
flags2 = extradata[2] | (extradata[3] << 8);
} else if (s->version == 2 && avctx->extradata_size >= 6) {
flags1 = extradata[0] | (extradata[1] << 8) |
(extradata[2] << 16) | (extradata[3] << 24);
flags2 = extradata[4] | (extradata[5] << 8);
}
s->use_exp_vlc = flags2 & 0x0001;
s->use_bit_reservoir = flags2 & 0x0002;
s->use_variable_block_len = flags2 & 0x0004;
if (s->sample_rate <= 16000) {
s->frame_len_bits = 9;
} else if (s->sample_rate <= 22050 ||
(s->sample_rate <= 32000 && s->version == 1)) {
s->frame_len_bits = 10;
} else {
s->frame_len_bits = 11;
}
s->frame_len = 1 << s->frame_len_bits;
if (s->use_variable_block_len) {
s->nb_block_sizes = s->frame_len_bits - BLOCK_MIN_BITS + 1;
} else {
s->nb_block_sizes = 1;
}
s->use_noise_coding = 1;
high_freq = s->sample_rate * 0.5;
sample_rate1 = s->sample_rate;
if (s->version == 2) {
if (sample_rate1 >= 44100)
sample_rate1 = 44100;
else if (sample_rate1 >= 22050)
sample_rate1 = 22050;
else if (sample_rate1 >= 16000)
sample_rate1 = 16000;
else if (sample_rate1 >= 11025)
sample_rate1 = 11025;
else if (sample_rate1 >= 8000)
sample_rate1 = 8000;
}
bps = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);
s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0)) + 2;
bps1 = bps;
if (s->nb_channels == 2)
bps1 = bps * 1.6;
if (sample_rate1 == 44100) {
if (bps1 >= 0.61)
s->use_noise_coding = 0;
else
high_freq = high_freq * 0.4;
} else if (sample_rate1 == 22050) {
if (bps1 >= 1.16)
s->use_noise_coding = 0;
else if (bps1 >= 0.72)
high_freq = high_freq * 0.7;
else
high_freq = high_freq * 0.6;
} else if (sample_rate1 == 16000) {
if (bps > 0.5)
high_freq = high_freq * 0.5;
else
high_freq = high_freq * 0.3;
} else if (sample_rate1 == 11025) {
high_freq = high_freq * 0.7;
} else if (sample_rate1 == 8000) {
if (bps <= 0.625) {
high_freq = high_freq * 0.5;
} else if (bps > 0.75) {
s->use_noise_coding = 0;
} else {
high_freq = high_freq * 0.65;
}
} else {
if (bps >= 0.8) {
high_freq = high_freq * 0.75;
} else if (bps >= 0.6) {
high_freq = high_freq * 0.6;
} else {
high_freq = high_freq * 0.5;
}
}
#ifdef DEBUG_PARAMS
printf("flags1=0x%x flags2=0x%x\n", flags1, flags2);
printf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
s->version, s->nb_channels, s->sample_rate, s->bit_rate,
s->block_align);
printf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
bps, bps1, high_freq, s->byte_offset_bits);
printf("use_noise_coding=%d use_exp_vlc=%d\n",
s->use_noise_coding, s->use_exp_vlc);
#endif
{
int a, b, pos, lpos, k, block_len, i, j, n;
const uint8_t *table;
if (s->version == 1) {
s->coefs_start = 3;
} else {
s->coefs_start = 0;
}
for(k = 0; k < s->nb_block_sizes; k++) {
block_len = s->frame_len >> k;
if (s->version == 1) {
lpos = 0;
for(i=0;i<25;i++) {
a = wma_critical_freqs[i];
b = s->sample_rate;
pos = ((block_len * 2 * a) + (b >> 1)) / b;
if (pos > block_len)
pos = block_len;
s->exponent_bands[0][i] = pos - lpos;
if (pos >= block_len) {
i++;
break;
}
lpos = pos;
}
s->exponent_sizes[0] = i;
} else {
table = NULL;
a = s->frame_len_bits - BLOCK_MIN_BITS - k;
if (a < 3) {
if (s->sample_rate >= 44100)
table = exponent_band_44100[a];
else if (s->sample_rate >= 32000)
table = exponent_band_32000[a];
else if (s->sample_rate >= 22050)
table = exponent_band_22050[a];
}
if (table) {
n = *table++;
for(i=0;i<n;i++)
s->exponent_bands[k][i] = table[i];
s->exponent_sizes[k] = n;
} else {
j = 0;
lpos = 0;
for(i=0;i<25;i++) {
a = wma_critical_freqs[i];
b = s->sample_rate;
pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
pos <<= 2;
if (pos > block_len)
pos = block_len;
if (pos > lpos)
s->exponent_bands[k][j++] = pos - lpos;
if (pos >= block_len)
break;
lpos = pos;
}
s->exponent_sizes[k] = j;
}
}
s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
s->sample_rate + 0.5);
n = s->exponent_sizes[k];
j = 0;
pos = 0;
for(i=0;i<n;i++) {
int start, end;
start = pos;
pos += s->exponent_bands[k][i];
end = pos;
if (start < s->high_band_start[k])
start = s->high_band_start[k];
if (end > s->coefs_end[k])
end = s->coefs_end[k];
if (end > start)
s->exponent_high_bands[k][j++] = end - start;
}
s->exponent_high_sizes[k] = j;
#if 0
trace("%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
s->frame_len >> k,
s->coefs_end[k],
s->high_band_start[k],
s->exponent_high_sizes[k]);
for(j=0;j<s->exponent_high_sizes[k];j++)
trace(" %d", s->exponent_high_bands[k][j]);
trace("\n");
#endif
}
}
#ifdef DEBUG_TRACE
{
int i, j;
for(i = 0; i < s->nb_block_sizes; i++) {
trace("%5d: n=%2d:",
s->frame_len >> i,
s->exponent_sizes[i]);
for(j=0;j<s->exponent_sizes[i];j++)
trace(" %d", s->exponent_bands[i][j]);
trace("\n");
}
}
#endif
for(i = 0; i < s->nb_block_sizes; i++)
ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1);
for(i = 0; i < s->nb_block_sizes; i++) {
int n, j;
float alpha;
n = 1 << (s->frame_len_bits - i);
window = av_malloc(sizeof(float) * n);
alpha = M_PI / (2.0 * n);
for(j=0;j<n;j++) {
window[n - j - 1] = sin((j + 0.5) * alpha);
}
s->windows[i] = window;
}
s->reset_block_lengths = 1;
if (s->use_noise_coding) {
if (s->use_exp_vlc)
s->noise_mult = 0.02;
else
s->noise_mult = 0.04;
#if defined(DEBUG_TRACE)
for(i=0;i<NOISE_TAB_SIZE;i++)
s->noise_table[i] = 1.0 * s->noise_mult;
#else
{
unsigned int seed;
float norm;
seed = 1;
norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;
for(i=0;i<NOISE_TAB_SIZE;i++) {
seed = seed * 314159 + 1;
s->noise_table[i] = (float)((int)seed) * norm;
}
}
#endif
init_vlc(&s->hgain_vlc, 9, sizeof(hgain_huffbits),
hgain_huffbits, 1, 1,
hgain_huffcodes, 2, 2);
}
if (s->use_exp_vlc) {
init_vlc(&s->exp_vlc, 9, sizeof(scale_huffbits),
scale_huffbits, 1, 1,
scale_huffcodes, 4, 4);
} else {
wma_lsp_to_curve_init(s, s->frame_len);
}
coef_vlc_table = 2;
if (s->sample_rate >= 32000) {
if (bps1 < 0.72)
coef_vlc_table = 0;
else if (bps1 < 1.16)
coef_vlc_table = 1;
}
init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],
&coef_vlcs[coef_vlc_table * 2]);
init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
&coef_vlcs[coef_vlc_table * 2 + 1]);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext * VAR_0)
{
WMADecodeContext *s = VAR_0->priv_data;
int VAR_16, VAR_2, VAR_3;
float *VAR_4;
uint8_t *extradata;
float VAR_5, VAR_6, VAR_7;
int VAR_8;
int VAR_9;
s->sample_rate = VAR_0->sample_rate;
s->nb_channels = VAR_0->channels;
s->bit_rate = VAR_0->bit_rate;
s->block_align = VAR_0->block_align;
if (VAR_0->codec_id == CODEC_ID_WMAV1) {
s->version = 1;
} else {
s->version = 2;
}
VAR_2 = 0;
VAR_3 = 0;
extradata = VAR_0->extradata;
if (s->version == 1 && VAR_0->extradata_size >= 4) {
VAR_2 = extradata[0] | (extradata[1] << 8);
VAR_3 = extradata[2] | (extradata[3] << 8);
} else if (s->version == 2 && VAR_0->extradata_size >= 6) {
VAR_2 = extradata[0] | (extradata[1] << 8) |
(extradata[2] << 16) | (extradata[3] << 24);
VAR_3 = extradata[4] | (extradata[5] << 8);
}
s->use_exp_vlc = VAR_3 & 0x0001;
s->use_bit_reservoir = VAR_3 & 0x0002;
s->use_variable_block_len = VAR_3 & 0x0004;
if (s->sample_rate <= 16000) {
s->frame_len_bits = 9;
} else if (s->sample_rate <= 22050 ||
(s->sample_rate <= 32000 && s->version == 1)) {
s->frame_len_bits = 10;
} else {
s->frame_len_bits = 11;
}
s->frame_len = 1 << s->frame_len_bits;
if (s->use_variable_block_len) {
s->nb_block_sizes = s->frame_len_bits - BLOCK_MIN_BITS + 1;
} else {
s->nb_block_sizes = 1;
}
s->use_noise_coding = 1;
VAR_6 = s->sample_rate * 0.5;
VAR_8 = s->sample_rate;
if (s->version == 2) {
if (VAR_8 >= 44100)
VAR_8 = 44100;
else if (VAR_8 >= 22050)
VAR_8 = 22050;
else if (VAR_8 >= 16000)
VAR_8 = 16000;
else if (VAR_8 >= 11025)
VAR_8 = 11025;
else if (VAR_8 >= 8000)
VAR_8 = 8000;
}
VAR_7 = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);
s->byte_offset_bits = av_log2((int)(VAR_7 * s->frame_len / 8.0)) + 2;
VAR_5 = VAR_7;
if (s->nb_channels == 2)
VAR_5 = VAR_7 * 1.6;
if (VAR_8 == 44100) {
if (VAR_5 >= 0.61)
s->use_noise_coding = 0;
else
VAR_6 = VAR_6 * 0.4;
} else if (VAR_8 == 22050) {
if (VAR_5 >= 1.16)
s->use_noise_coding = 0;
else if (VAR_5 >= 0.72)
VAR_6 = VAR_6 * 0.7;
else
VAR_6 = VAR_6 * 0.6;
} else if (VAR_8 == 16000) {
if (VAR_7 > 0.5)
VAR_6 = VAR_6 * 0.5;
else
VAR_6 = VAR_6 * 0.3;
} else if (VAR_8 == 11025) {
VAR_6 = VAR_6 * 0.7;
} else if (VAR_8 == 8000) {
if (VAR_7 <= 0.625) {
VAR_6 = VAR_6 * 0.5;
} else if (VAR_7 > 0.75) {
s->use_noise_coding = 0;
} else {
VAR_6 = VAR_6 * 0.65;
}
} else {
if (VAR_7 >= 0.8) {
VAR_6 = VAR_6 * 0.75;
} else if (VAR_7 >= 0.6) {
VAR_6 = VAR_6 * 0.6;
} else {
VAR_6 = VAR_6 * 0.5;
}
}
#ifdef DEBUG_PARAMS
printf("VAR_2=0x%x VAR_3=0x%x\VAR_17", VAR_2, VAR_3);
printf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\VAR_17",
s->version, s->nb_channels, s->sample_rate, s->bit_rate,
s->block_align);
printf("VAR_7=%f VAR_5=%f VAR_6=%f bitoffset=%d\VAR_17",
VAR_7, VAR_5, VAR_6, s->byte_offset_bits);
printf("use_noise_coding=%d use_exp_vlc=%d\VAR_17",
s->use_noise_coding, s->use_exp_vlc);
#endif
{
int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_16, VAR_17;
const uint8_t *VAR_18;
if (s->version == 1) {
s->coefs_start = 3;
} else {
s->coefs_start = 0;
}
for(VAR_14 = 0; VAR_14 < s->nb_block_sizes; VAR_14++) {
VAR_15 = s->frame_len >> VAR_14;
if (s->version == 1) {
VAR_13 = 0;
for(VAR_16=0;VAR_16<25;VAR_16++) {
VAR_10 = wma_critical_freqs[VAR_16];
VAR_11 = s->sample_rate;
VAR_12 = ((VAR_15 * 2 * VAR_10) + (VAR_11 >> 1)) / VAR_11;
if (VAR_12 > VAR_15)
VAR_12 = VAR_15;
s->exponent_bands[0][VAR_16] = VAR_12 - VAR_13;
if (VAR_12 >= VAR_15) {
VAR_16++;
break;
}
VAR_13 = VAR_12;
}
s->exponent_sizes[0] = VAR_16;
} else {
VAR_18 = NULL;
VAR_10 = s->frame_len_bits - BLOCK_MIN_BITS - VAR_14;
if (VAR_10 < 3) {
if (s->sample_rate >= 44100)
VAR_18 = exponent_band_44100[VAR_10];
else if (s->sample_rate >= 32000)
VAR_18 = exponent_band_32000[VAR_10];
else if (s->sample_rate >= 22050)
VAR_18 = exponent_band_22050[VAR_10];
}
if (VAR_18) {
VAR_17 = *VAR_18++;
for(VAR_16=0;VAR_16<VAR_17;VAR_16++)
s->exponent_bands[VAR_14][VAR_16] = VAR_18[VAR_16];
s->exponent_sizes[VAR_14] = VAR_17;
} else {
VAR_16 = 0;
VAR_13 = 0;
for(VAR_16=0;VAR_16<25;VAR_16++) {
VAR_10 = wma_critical_freqs[VAR_16];
VAR_11 = s->sample_rate;
VAR_12 = ((VAR_15 * 2 * VAR_10) + (VAR_11 << 1)) / (4 * VAR_11);
VAR_12 <<= 2;
if (VAR_12 > VAR_15)
VAR_12 = VAR_15;
if (VAR_12 > VAR_13)
s->exponent_bands[VAR_14][VAR_16++] = VAR_12 - VAR_13;
if (VAR_12 >= VAR_15)
break;
VAR_13 = VAR_12;
}
s->exponent_sizes[VAR_14] = VAR_16;
}
}
s->coefs_end[VAR_14] = (s->frame_len - ((s->frame_len * 9) / 100)) >> VAR_14;
s->high_band_start[VAR_14] = (int)((VAR_15 * 2 * VAR_6) /
s->sample_rate + 0.5);
VAR_17 = s->exponent_sizes[VAR_14];
VAR_16 = 0;
VAR_12 = 0;
for(VAR_16=0;VAR_16<VAR_17;VAR_16++) {
int start, end;
start = VAR_12;
VAR_12 += s->exponent_bands[VAR_14][VAR_16];
end = VAR_12;
if (start < s->high_band_start[VAR_14])
start = s->high_band_start[VAR_14];
if (end > s->coefs_end[VAR_14])
end = s->coefs_end[VAR_14];
if (end > start)
s->exponent_high_bands[VAR_14][VAR_16++] = end - start;
}
s->exponent_high_sizes[VAR_14] = VAR_16;
#if 0
trace("%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
s->frame_len >> VAR_14,
s->coefs_end[VAR_14],
s->high_band_start[VAR_14],
s->exponent_high_sizes[VAR_14]);
for(VAR_16=0;VAR_16<s->exponent_high_sizes[VAR_14];VAR_16++)
trace(" %d", s->exponent_high_bands[VAR_14][VAR_16]);
trace("\VAR_17");
#endif
}
}
#ifdef DEBUG_TRACE
{
int VAR_16, VAR_16;
for(VAR_16 = 0; VAR_16 < s->nb_block_sizes; VAR_16++) {
trace("%5d: VAR_17=%2d:",
s->frame_len >> VAR_16,
s->exponent_sizes[VAR_16]);
for(VAR_16=0;VAR_16<s->exponent_sizes[VAR_16];VAR_16++)
trace(" %d", s->exponent_bands[VAR_16][VAR_16]);
trace("\VAR_17");
}
}
#endif
for(VAR_16 = 0; VAR_16 < s->nb_block_sizes; VAR_16++)
ff_mdct_init(&s->mdct_ctx[VAR_16], s->frame_len_bits - VAR_16 + 1, 1);
for(VAR_16 = 0; VAR_16 < s->nb_block_sizes; VAR_16++) {
int VAR_17, VAR_16;
float alpha;
VAR_17 = 1 << (s->frame_len_bits - VAR_16);
VAR_4 = av_malloc(sizeof(float) * VAR_17);
alpha = M_PI / (2.0 * VAR_17);
for(VAR_16=0;VAR_16<VAR_17;VAR_16++) {
VAR_4[VAR_17 - VAR_16 - 1] = sin((VAR_16 + 0.5) * alpha);
}
s->windows[VAR_16] = VAR_4;
}
s->reset_block_lengths = 1;
if (s->use_noise_coding) {
if (s->use_exp_vlc)
s->noise_mult = 0.02;
else
s->noise_mult = 0.04;
#if defined(DEBUG_TRACE)
for(VAR_16=0;VAR_16<NOISE_TAB_SIZE;VAR_16++)
s->noise_table[VAR_16] = 1.0 * s->noise_mult;
#else
{
unsigned int VAR_19;
float VAR_20;
VAR_19 = 1;
VAR_20 = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;
for(VAR_16=0;VAR_16<NOISE_TAB_SIZE;VAR_16++) {
VAR_19 = VAR_19 * 314159 + 1;
s->noise_table[VAR_16] = (float)((int)VAR_19) * VAR_20;
}
}
#endif
init_vlc(&s->hgain_vlc, 9, sizeof(hgain_huffbits),
hgain_huffbits, 1, 1,
hgain_huffcodes, 2, 2);
}
if (s->use_exp_vlc) {
init_vlc(&s->exp_vlc, 9, sizeof(scale_huffbits),
scale_huffbits, 1, 1,
scale_huffcodes, 4, 4);
} else {
wma_lsp_to_curve_init(s, s->frame_len);
}
VAR_9 = 2;
if (s->sample_rate >= 32000) {
if (VAR_5 < 0.72)
VAR_9 = 0;
else if (VAR_5 < 1.16)
VAR_9 = 1;
}
init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],
&coef_vlcs[VAR_9 * 2]);
init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
&coef_vlcs[VAR_9 * 2 + 1]);
return 0;
}
| [
"static int FUNC_0(AVCodecContext * VAR_0)\n{",
"WMADecodeContext *s = VAR_0->priv_data;",
"int VAR_16, VAR_2, VAR_3;",
"float *VAR_4;",
"uint8_t *extradata;",
"float VAR_5, VAR_6, VAR_7;",
"int VAR_8;",
"int VAR_9;",
"s->sample_rate = VAR_0->sample_rate;",
"s->nb_channels = VAR_0->channels;",
"s->bit_rate = VAR_0->bit_rate;",
"s->block_align = VAR_0->block_align;",
"if (VAR_0->codec_id == CODEC_ID_WMAV1) {",
"s->version = 1;",
"} else {",
"s->version = 2;",
"}",
"VAR_2 = 0;",
"VAR_3 = 0;",
"extradata = VAR_0->extradata;",
"if (s->version == 1 && VAR_0->extradata_size >= 4) {",
"VAR_2 = extradata[0] | (extradata[1] << 8);",
"VAR_3 = extradata[2] | (extradata[3] << 8);",
"} else if (s->version == 2 && VAR_0->extradata_size >= 6) {",
"VAR_2 = extradata[0] | (extradata[1] << 8) |\n(extradata[2] << 16) | (extradata[3] << 24);",
"VAR_3 = extradata[4] | (extradata[5] << 8);",
"}",
"s->use_exp_vlc = VAR_3 & 0x0001;",
"s->use_bit_reservoir = VAR_3 & 0x0002;",
"s->use_variable_block_len = VAR_3 & 0x0004;",
"if (s->sample_rate <= 16000) {",
"s->frame_len_bits = 9;",
"} else if (s->sample_rate <= 22050 ||",
"(s->sample_rate <= 32000 && s->version == 1)) {",
"s->frame_len_bits = 10;",
"} else {",
"s->frame_len_bits = 11;",
"}",
"s->frame_len = 1 << s->frame_len_bits;",
"if (s->use_variable_block_len) {",
"s->nb_block_sizes = s->frame_len_bits - BLOCK_MIN_BITS + 1;",
"} else {",
"s->nb_block_sizes = 1;",
"}",
"s->use_noise_coding = 1;",
"VAR_6 = s->sample_rate * 0.5;",
"VAR_8 = s->sample_rate;",
"if (s->version == 2) {",
"if (VAR_8 >= 44100)\nVAR_8 = 44100;",
"else if (VAR_8 >= 22050)\nVAR_8 = 22050;",
"else if (VAR_8 >= 16000)\nVAR_8 = 16000;",
"else if (VAR_8 >= 11025)\nVAR_8 = 11025;",
"else if (VAR_8 >= 8000)\nVAR_8 = 8000;",
"}",
"VAR_7 = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);",
"s->byte_offset_bits = av_log2((int)(VAR_7 * s->frame_len / 8.0)) + 2;",
"VAR_5 = VAR_7;",
"if (s->nb_channels == 2)\nVAR_5 = VAR_7 * 1.6;",
"if (VAR_8 == 44100) {",
"if (VAR_5 >= 0.61)\ns->use_noise_coding = 0;",
"else\nVAR_6 = VAR_6 * 0.4;",
"} else if (VAR_8 == 22050) {",
"if (VAR_5 >= 1.16)\ns->use_noise_coding = 0;",
"else if (VAR_5 >= 0.72)\nVAR_6 = VAR_6 * 0.7;",
"else\nVAR_6 = VAR_6 * 0.6;",
"} else if (VAR_8 == 16000) {",
"if (VAR_7 > 0.5)\nVAR_6 = VAR_6 * 0.5;",
"else\nVAR_6 = VAR_6 * 0.3;",
"} else if (VAR_8 == 11025) {",
"VAR_6 = VAR_6 * 0.7;",
"} else if (VAR_8 == 8000) {",
"if (VAR_7 <= 0.625) {",
"VAR_6 = VAR_6 * 0.5;",
"} else if (VAR_7 > 0.75) {",
"s->use_noise_coding = 0;",
"} else {",
"VAR_6 = VAR_6 * 0.65;",
"}",
"} else {",
"if (VAR_7 >= 0.8) {",
"VAR_6 = VAR_6 * 0.75;",
"} else if (VAR_7 >= 0.6) {",
"VAR_6 = VAR_6 * 0.6;",
"} else {",
"VAR_6 = VAR_6 * 0.5;",
"}",
"}",
"#ifdef DEBUG_PARAMS\nprintf(\"VAR_2=0x%x VAR_3=0x%x\\VAR_17\", VAR_2, VAR_3);",
"printf(\"version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\\VAR_17\",\ns->version, s->nb_channels, s->sample_rate, s->bit_rate,\ns->block_align);",
"printf(\"VAR_7=%f VAR_5=%f VAR_6=%f bitoffset=%d\\VAR_17\",\nVAR_7, VAR_5, VAR_6, s->byte_offset_bits);",
"printf(\"use_noise_coding=%d use_exp_vlc=%d\\VAR_17\",\ns->use_noise_coding, s->use_exp_vlc);",
"#endif\n{",
"int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_16, VAR_17;",
"const uint8_t *VAR_18;",
"if (s->version == 1) {",
"s->coefs_start = 3;",
"} else {",
"s->coefs_start = 0;",
"}",
"for(VAR_14 = 0; VAR_14 < s->nb_block_sizes; VAR_14++) {",
"VAR_15 = s->frame_len >> VAR_14;",
"if (s->version == 1) {",
"VAR_13 = 0;",
"for(VAR_16=0;VAR_16<25;VAR_16++) {",
"VAR_10 = wma_critical_freqs[VAR_16];",
"VAR_11 = s->sample_rate;",
"VAR_12 = ((VAR_15 * 2 * VAR_10) + (VAR_11 >> 1)) / VAR_11;",
"if (VAR_12 > VAR_15)\nVAR_12 = VAR_15;",
"s->exponent_bands[0][VAR_16] = VAR_12 - VAR_13;",
"if (VAR_12 >= VAR_15) {",
"VAR_16++;",
"break;",
"}",
"VAR_13 = VAR_12;",
"}",
"s->exponent_sizes[0] = VAR_16;",
"} else {",
"VAR_18 = NULL;",
"VAR_10 = s->frame_len_bits - BLOCK_MIN_BITS - VAR_14;",
"if (VAR_10 < 3) {",
"if (s->sample_rate >= 44100)\nVAR_18 = exponent_band_44100[VAR_10];",
"else if (s->sample_rate >= 32000)\nVAR_18 = exponent_band_32000[VAR_10];",
"else if (s->sample_rate >= 22050)\nVAR_18 = exponent_band_22050[VAR_10];",
"}",
"if (VAR_18) {",
"VAR_17 = *VAR_18++;",
"for(VAR_16=0;VAR_16<VAR_17;VAR_16++)",
"s->exponent_bands[VAR_14][VAR_16] = VAR_18[VAR_16];",
"s->exponent_sizes[VAR_14] = VAR_17;",
"} else {",
"VAR_16 = 0;",
"VAR_13 = 0;",
"for(VAR_16=0;VAR_16<25;VAR_16++) {",
"VAR_10 = wma_critical_freqs[VAR_16];",
"VAR_11 = s->sample_rate;",
"VAR_12 = ((VAR_15 * 2 * VAR_10) + (VAR_11 << 1)) / (4 * VAR_11);",
"VAR_12 <<= 2;",
"if (VAR_12 > VAR_15)\nVAR_12 = VAR_15;",
"if (VAR_12 > VAR_13)\ns->exponent_bands[VAR_14][VAR_16++] = VAR_12 - VAR_13;",
"if (VAR_12 >= VAR_15)\nbreak;",
"VAR_13 = VAR_12;",
"}",
"s->exponent_sizes[VAR_14] = VAR_16;",
"}",
"}",
"s->coefs_end[VAR_14] = (s->frame_len - ((s->frame_len * 9) / 100)) >> VAR_14;",
"s->high_band_start[VAR_14] = (int)((VAR_15 * 2 * VAR_6) /\ns->sample_rate + 0.5);",
"VAR_17 = s->exponent_sizes[VAR_14];",
"VAR_16 = 0;",
"VAR_12 = 0;",
"for(VAR_16=0;VAR_16<VAR_17;VAR_16++) {",
"int start, end;",
"start = VAR_12;",
"VAR_12 += s->exponent_bands[VAR_14][VAR_16];",
"end = VAR_12;",
"if (start < s->high_band_start[VAR_14])\nstart = s->high_band_start[VAR_14];",
"if (end > s->coefs_end[VAR_14])\nend = s->coefs_end[VAR_14];",
"if (end > start)\ns->exponent_high_bands[VAR_14][VAR_16++] = end - start;",
"}",
"s->exponent_high_sizes[VAR_14] = VAR_16;",
"#if 0\ntrace(\"%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: \",\ns->frame_len >> VAR_14,\ns->coefs_end[VAR_14],\ns->high_band_start[VAR_14],\ns->exponent_high_sizes[VAR_14]);",
"for(VAR_16=0;VAR_16<s->exponent_high_sizes[VAR_14];VAR_16++)",
"trace(\" %d\", s->exponent_high_bands[VAR_14][VAR_16]);",
"trace(\"\\VAR_17\");",
"#endif\n}",
"}",
"#ifdef DEBUG_TRACE\n{",
"int VAR_16, VAR_16;",
"for(VAR_16 = 0; VAR_16 < s->nb_block_sizes; VAR_16++) {",
"trace(\"%5d: VAR_17=%2d:\",\ns->frame_len >> VAR_16,\ns->exponent_sizes[VAR_16]);",
"for(VAR_16=0;VAR_16<s->exponent_sizes[VAR_16];VAR_16++)",
"trace(\" %d\", s->exponent_bands[VAR_16][VAR_16]);",
"trace(\"\\VAR_17\");",
"}",
"}",
"#endif\nfor(VAR_16 = 0; VAR_16 < s->nb_block_sizes; VAR_16++)",
"ff_mdct_init(&s->mdct_ctx[VAR_16], s->frame_len_bits - VAR_16 + 1, 1);",
"for(VAR_16 = 0; VAR_16 < s->nb_block_sizes; VAR_16++) {",
"int VAR_17, VAR_16;",
"float alpha;",
"VAR_17 = 1 << (s->frame_len_bits - VAR_16);",
"VAR_4 = av_malloc(sizeof(float) * VAR_17);",
"alpha = M_PI / (2.0 * VAR_17);",
"for(VAR_16=0;VAR_16<VAR_17;VAR_16++) {",
"VAR_4[VAR_17 - VAR_16 - 1] = sin((VAR_16 + 0.5) * alpha);",
"}",
"s->windows[VAR_16] = VAR_4;",
"}",
"s->reset_block_lengths = 1;",
"if (s->use_noise_coding) {",
"if (s->use_exp_vlc)\ns->noise_mult = 0.02;",
"else\ns->noise_mult = 0.04;",
"#if defined(DEBUG_TRACE)\nfor(VAR_16=0;VAR_16<NOISE_TAB_SIZE;VAR_16++)",
"s->noise_table[VAR_16] = 1.0 * s->noise_mult;",
"#else\n{",
"unsigned int VAR_19;",
"float VAR_20;",
"VAR_19 = 1;",
"VAR_20 = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;",
"for(VAR_16=0;VAR_16<NOISE_TAB_SIZE;VAR_16++) {",
"VAR_19 = VAR_19 * 314159 + 1;",
"s->noise_table[VAR_16] = (float)((int)VAR_19) * VAR_20;",
"}",
"}",
"#endif\ninit_vlc(&s->hgain_vlc, 9, sizeof(hgain_huffbits),\nhgain_huffbits, 1, 1,\nhgain_huffcodes, 2, 2);",
"}",
"if (s->use_exp_vlc) {",
"init_vlc(&s->exp_vlc, 9, sizeof(scale_huffbits),\nscale_huffbits, 1, 1,\nscale_huffcodes, 4, 4);",
"} else {",
"wma_lsp_to_curve_init(s, s->frame_len);",
"}",
"VAR_9 = 2;",
"if (s->sample_rate >= 32000) {",
"if (VAR_5 < 0.72)\nVAR_9 = 0;",
"else if (VAR_5 < 1.16)\nVAR_9 = 1;",
"}",
"init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],\n&coef_vlcs[VAR_9 * 2]);",
"init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],\n&coef_vlcs[VAR_9 * 2 + 1]);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
109
],
[
111
],
[
117
],
[
119
],
[
121,
123
],
[
125,
127
],
[
129,
131
],
[
133,
135
],
[
137,
139
],
[
141
],
[
145
],
[
147
],
[
155
],
[
157,
159
],
[
161
],
[
163,
165
],
[
167,
169
],
[
171
],
[
173,
175
],
[
177,
179
],
[
181,
183
],
[
185
],
[
187,
189
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233,
235
],
[
237,
239,
241
],
[
243,
245
],
[
247,
249
],
[
251,
257
],
[
259
],
[
261
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293,
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
317
],
[
319
],
[
321
],
[
323,
325
],
[
327,
329
],
[
331,
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363,
365
],
[
367,
369
],
[
371,
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
389
],
[
393,
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413,
415
],
[
417,
419
],
[
421,
423
],
[
425
],
[
427
],
[
429,
431,
433,
435,
437,
439
],
[
441
],
[
443
],
[
445
],
[
447,
449
],
[
451
],
[
455,
457
],
[
459
],
[
461
],
[
463,
465,
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479,
485
],
[
487
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
517
],
[
521
],
[
527,
529
],
[
531,
533
],
[
537,
539
],
[
541
],
[
543,
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565,
567,
569,
571
],
[
573
],
[
577
],
[
579,
581,
583
],
[
585
],
[
587
],
[
589
],
[
595
],
[
597
],
[
599,
601
],
[
603,
605
],
[
607
],
[
611,
613
],
[
615,
617
],
[
619
],
[
621
]
] |
19,438 | const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len)
{
const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
void *dst;
uint8_t *bin;
int len, i;
if (!o || o->offset<=0)
return NULL;
if (o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len))
return NULL;
dst= ((uint8_t*)obj) + o->offset;
if (o_out) *o_out= o;
switch (o->type) {
case FF_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break;
case FF_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break;
case FF_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break;
case FF_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break;
case FF_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break;
case FF_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
case FF_OPT_TYPE_STRING: return *(void**)dst;
case FF_OPT_TYPE_BINARY:
len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
if (len >= (buf_len + 1)/2) return NULL;
bin = *(uint8_t**)dst;
for (i = 0; i < len; i++) snprintf(buf + i*2, 3, "%02X", bin[i]);
break;
default: return NULL;
}
return buf;
}
| false | FFmpeg | 4dbcdfa86d1405f7e5c0ec14a4be7d2fb5903d7b | const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len)
{
const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
void *dst;
uint8_t *bin;
int len, i;
if (!o || o->offset<=0)
return NULL;
if (o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len))
return NULL;
dst= ((uint8_t*)obj) + o->offset;
if (o_out) *o_out= o;
switch (o->type) {
case FF_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break;
case FF_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break;
case FF_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break;
case FF_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break;
case FF_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break;
case FF_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
case FF_OPT_TYPE_STRING: return *(void**)dst;
case FF_OPT_TYPE_BINARY:
len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
if (len >= (buf_len + 1)/2) return NULL;
bin = *(uint8_t**)dst;
for (i = 0; i < len; i++) snprintf(buf + i*2, 3, "%02X", bin[i]);
break;
default: return NULL;
}
return buf;
}
| {
"code": [],
"line_no": []
} | const char *FUNC_0(void *VAR_0, const char *VAR_1, const AVOption **VAR_2, char *VAR_3, int VAR_4)
{
const AVOption *VAR_5 = av_opt_find(VAR_0, VAR_1, NULL, 0, 0);
void *VAR_6;
uint8_t *bin;
int VAR_7, VAR_8;
if (!VAR_5 || VAR_5->offset<=0)
return NULL;
if (VAR_5->type != FF_OPT_TYPE_STRING && (!VAR_3 || !VAR_4))
return NULL;
VAR_6= ((uint8_t*)VAR_0) + VAR_5->offset;
if (VAR_2) *VAR_2= VAR_5;
switch (VAR_5->type) {
case FF_OPT_TYPE_FLAGS: snprintf(VAR_3, VAR_4, "0x%08X",*(int *)VAR_6);break;
case FF_OPT_TYPE_INT: snprintf(VAR_3, VAR_4, "%d" , *(int *)VAR_6);break;
case FF_OPT_TYPE_INT64: snprintf(VAR_3, VAR_4, "%"PRId64, *(int64_t*)VAR_6);break;
case FF_OPT_TYPE_FLOAT: snprintf(VAR_3, VAR_4, "%f" , *(float *)VAR_6);break;
case FF_OPT_TYPE_DOUBLE: snprintf(VAR_3, VAR_4, "%f" , *(double *)VAR_6);break;
case FF_OPT_TYPE_RATIONAL: snprintf(VAR_3, VAR_4, "%d/%d", ((AVRational*)VAR_6)->num, ((AVRational*)VAR_6)->den);break;
case FF_OPT_TYPE_STRING: return *(void**)VAR_6;
case FF_OPT_TYPE_BINARY:
VAR_7 = *(int*)(((uint8_t *)VAR_6) + sizeof(uint8_t *));
if (VAR_7 >= (VAR_4 + 1)/2) return NULL;
bin = *(uint8_t**)VAR_6;
for (VAR_8 = 0; VAR_8 < VAR_7; VAR_8++) snprintf(VAR_3 + VAR_8*2, 3, "%02X", bin[VAR_8]);
break;
default: return NULL;
}
return VAR_3;
}
| [
"const char *FUNC_0(void *VAR_0, const char *VAR_1, const AVOption **VAR_2, char *VAR_3, int VAR_4)\n{",
"const AVOption *VAR_5 = av_opt_find(VAR_0, VAR_1, NULL, 0, 0);",
"void *VAR_6;",
"uint8_t *bin;",
"int VAR_7, VAR_8;",
"if (!VAR_5 || VAR_5->offset<=0)\nreturn NULL;",
"if (VAR_5->type != FF_OPT_TYPE_STRING && (!VAR_3 || !VAR_4))\nreturn NULL;",
"VAR_6= ((uint8_t*)VAR_0) + VAR_5->offset;",
"if (VAR_2) *VAR_2= VAR_5;",
"switch (VAR_5->type) {",
"case FF_OPT_TYPE_FLAGS: snprintf(VAR_3, VAR_4, \"0x%08X\",*(int *)VAR_6);break;",
"case FF_OPT_TYPE_INT: snprintf(VAR_3, VAR_4, \"%d\" , *(int *)VAR_6);break;",
"case FF_OPT_TYPE_INT64: snprintf(VAR_3, VAR_4, \"%\"PRId64, *(int64_t*)VAR_6);break;",
"case FF_OPT_TYPE_FLOAT: snprintf(VAR_3, VAR_4, \"%f\" , *(float *)VAR_6);break;",
"case FF_OPT_TYPE_DOUBLE: snprintf(VAR_3, VAR_4, \"%f\" , *(double *)VAR_6);break;",
"case FF_OPT_TYPE_RATIONAL: snprintf(VAR_3, VAR_4, \"%d/%d\", ((AVRational*)VAR_6)->num, ((AVRational*)VAR_6)->den);break;",
"case FF_OPT_TYPE_STRING: return *(void**)VAR_6;",
"case FF_OPT_TYPE_BINARY:\nVAR_7 = *(int*)(((uint8_t *)VAR_6) + sizeof(uint8_t *));",
"if (VAR_7 >= (VAR_4 + 1)/2) return NULL;",
"bin = *(uint8_t**)VAR_6;",
"for (VAR_8 = 0; VAR_8 < VAR_7; VAR_8++) snprintf(VAR_3 + VAR_8*2, 3, \"%02X\", bin[VAR_8]);",
"break;",
"default: return NULL;",
"}",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17,
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
19,439 | static void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){
int i;
memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster then a loop?
/* mpeg1 */
d->mb_incr= s->mb_incr;
for(i=0; i<3; i++)
d->last_dc[i]= s->last_dc[i];
/* statistics */
d->mv_bits= s->mv_bits;
d->i_tex_bits= s->i_tex_bits;
d->p_tex_bits= s->p_tex_bits;
d->i_count= s->i_count;
d->p_count= s->p_count;
d->skip_count= s->skip_count;
d->misc_bits= s->misc_bits;
d->last_bits= 0;
d->mb_skiped= s->mb_skiped;
}
| false | FFmpeg | 7f2fe444a39bca733d390b6608801c5f002bfd31 | static void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){
int i;
memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int));
d->mb_incr= s->mb_incr;
for(i=0; i<3; i++)
d->last_dc[i]= s->last_dc[i];
d->mv_bits= s->mv_bits;
d->i_tex_bits= s->i_tex_bits;
d->p_tex_bits= s->p_tex_bits;
d->i_count= s->i_count;
d->p_count= s->p_count;
d->skip_count= s->skip_count;
d->misc_bits= s->misc_bits;
d->last_bits= 0;
d->mb_skiped= s->mb_skiped;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MpegEncContext *VAR_0, MpegEncContext *VAR_1, int VAR_2){
int VAR_3;
memcpy(VAR_0->last_mv, VAR_1->last_mv, 2*2*2*sizeof(int));
VAR_0->mb_incr= VAR_1->mb_incr;
for(VAR_3=0; VAR_3<3; VAR_3++)
VAR_0->last_dc[VAR_3]= VAR_1->last_dc[VAR_3];
VAR_0->mv_bits= VAR_1->mv_bits;
VAR_0->i_tex_bits= VAR_1->i_tex_bits;
VAR_0->p_tex_bits= VAR_1->p_tex_bits;
VAR_0->i_count= VAR_1->i_count;
VAR_0->p_count= VAR_1->p_count;
VAR_0->skip_count= VAR_1->skip_count;
VAR_0->misc_bits= VAR_1->misc_bits;
VAR_0->last_bits= 0;
VAR_0->mb_skiped= VAR_1->mb_skiped;
}
| [
"static void FUNC_0(MpegEncContext *VAR_0, MpegEncContext *VAR_1, int VAR_2){",
"int VAR_3;",
"memcpy(VAR_0->last_mv, VAR_1->last_mv, 2*2*2*sizeof(int));",
"VAR_0->mb_incr= VAR_1->mb_incr;",
"for(VAR_3=0; VAR_3<3; VAR_3++)",
"VAR_0->last_dc[VAR_3]= VAR_1->last_dc[VAR_3];",
"VAR_0->mv_bits= VAR_1->mv_bits;",
"VAR_0->i_tex_bits= VAR_1->i_tex_bits;",
"VAR_0->p_tex_bits= VAR_1->p_tex_bits;",
"VAR_0->i_count= VAR_1->i_count;",
"VAR_0->p_count= VAR_1->p_count;",
"VAR_0->skip_count= VAR_1->skip_count;",
"VAR_0->misc_bits= VAR_1->misc_bits;",
"VAR_0->last_bits= 0;",
"VAR_0->mb_skiped= VAR_1->mb_skiped;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
7
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
] |
19,440 | static int get_bits(Jpeg2000DecoderContext *s, int n)
{
int res = 0;
if (s->buf_end - s->buf < ((n - s->bit_index) >> 8))
return AVERROR(EINVAL);
while (--n >= 0) {
res <<= 1;
if (s->bit_index == 0) {
s->bit_index = 7 + (*s->buf != 0xff);
s->buf++;
}
s->bit_index--;
res |= (*s->buf >> s->bit_index) & 1;
}
return res;
}
| false | FFmpeg | 0b42631641d998e509cde6fa344edc6ab5cb4ac8 | static int get_bits(Jpeg2000DecoderContext *s, int n)
{
int res = 0;
if (s->buf_end - s->buf < ((n - s->bit_index) >> 8))
return AVERROR(EINVAL);
while (--n >= 0) {
res <<= 1;
if (s->bit_index == 0) {
s->bit_index = 7 + (*s->buf != 0xff);
s->buf++;
}
s->bit_index--;
res |= (*s->buf >> s->bit_index) & 1;
}
return res;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(Jpeg2000DecoderContext *VAR_0, int VAR_1)
{
int VAR_2 = 0;
if (VAR_0->buf_end - VAR_0->buf < ((VAR_1 - VAR_0->bit_index) >> 8))
return AVERROR(EINVAL);
while (--VAR_1 >= 0) {
VAR_2 <<= 1;
if (VAR_0->bit_index == 0) {
VAR_0->bit_index = 7 + (*VAR_0->buf != 0xff);
VAR_0->buf++;
}
VAR_0->bit_index--;
VAR_2 |= (*VAR_0->buf >> VAR_0->bit_index) & 1;
}
return VAR_2;
}
| [
"static int FUNC_0(Jpeg2000DecoderContext *VAR_0, int VAR_1)\n{",
"int VAR_2 = 0;",
"if (VAR_0->buf_end - VAR_0->buf < ((VAR_1 - VAR_0->bit_index) >> 8))\nreturn AVERROR(EINVAL);",
"while (--VAR_1 >= 0) {",
"VAR_2 <<= 1;",
"if (VAR_0->bit_index == 0) {",
"VAR_0->bit_index = 7 + (*VAR_0->buf != 0xff);",
"VAR_0->buf++;",
"}",
"VAR_0->bit_index--;",
"VAR_2 |= (*VAR_0->buf >> VAR_0->bit_index) & 1;",
"}",
"return VAR_2;",
"}"
] | [
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
]
] |
19,442 | static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
int srcSliceY, int srcSliceH, uint8_t *dst[],
int dstStride[])
{
const enum PixelFormat srcFormat = c->srcFormat;
const enum PixelFormat dstFormat = c->dstFormat;
const int srcBpp = (c->srcFormatBpp + 7) >> 3;
const int dstBpp = (c->dstFormatBpp + 7) >> 3;
const int srcId = c->srcFormatBpp;
const int dstId = c->dstFormatBpp;
void (*conv)(const uint8_t *src, uint8_t *dst, int src_size) = NULL;
#define CONV_IS(src, dst) (srcFormat == PIX_FMT_##src && dstFormat == PIX_FMT_##dst)
if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
if ( CONV_IS(ABGR, RGBA)
|| CONV_IS(ARGB, BGRA)
|| CONV_IS(BGRA, ARGB)
|| CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
else if (CONV_IS(ABGR, ARGB)
|| CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
else if (CONV_IS(ABGR, BGRA)
|| CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
else if (CONV_IS(BGRA, RGBA)
|| CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
else if (CONV_IS(BGRA, ABGR)
|| CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
} else
/* BGR -> BGR */
if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
(isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
switch (srcId | (dstId << 16)) {
case 0x000F0010: conv = rgb16to15; break;
case 0x000F0018: conv = rgb24to15; break;
case 0x000F0020: conv = rgb32to15; break;
case 0x0010000F: conv = rgb15to16; break;
case 0x00100018: conv = rgb24to16; break;
case 0x00100020: conv = rgb32to16; break;
case 0x0018000F: conv = rgb15to24; break;
case 0x00180010: conv = rgb16to24; break;
case 0x00180020: conv = rgb32to24; break;
case 0x0020000F: conv = rgb15to32; break;
case 0x00200010: conv = rgb16to32; break;
case 0x00200018: conv = rgb24to32; break;
}
} else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) ||
(isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
switch (srcId | (dstId << 16)) {
case 0x000C000C: conv = rgb12tobgr12; break;
case 0x000F000F: conv = rgb15tobgr15; break;
case 0x000F0010: conv = rgb16tobgr15; break;
case 0x000F0018: conv = rgb24tobgr15; break;
case 0x000F0020: conv = rgb32tobgr15; break;
case 0x0010000F: conv = rgb15tobgr16; break;
case 0x00100010: conv = rgb16tobgr16; break;
case 0x00100018: conv = rgb24tobgr16; break;
case 0x00100020: conv = rgb32tobgr16; break;
case 0x0018000F: conv = rgb15tobgr24; break;
case 0x00180010: conv = rgb16tobgr24; break;
case 0x00180018: conv = rgb24tobgr24; break;
case 0x00180020: conv = rgb32tobgr24; break;
case 0x0020000F: conv = rgb15tobgr32; break;
case 0x00200010: conv = rgb16tobgr32; break;
case 0x00200018: conv = rgb24tobgr32; break;
}
}
if (!conv) {
av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat));
} else {
const uint8_t *srcPtr = src[0];
uint8_t *dstPtr = dst[0];
if ((srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1) &&
!isRGBA32(dstFormat))
srcPtr += ALT32_CORR;
if ((dstFormat == PIX_FMT_RGB32_1 || dstFormat == PIX_FMT_BGR32_1) &&
!isRGBA32(srcFormat))
dstPtr += ALT32_CORR;
if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
!(srcStride[0] % srcBpp))
conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
srcSliceH * srcStride[0]);
else {
int i;
dstPtr += dstStride[0] * srcSliceY;
for (i = 0; i < srcSliceH; i++) {
conv(srcPtr, dstPtr, c->srcW * srcBpp);
srcPtr += srcStride[0];
dstPtr += dstStride[0];
}
}
}
return srcSliceH;
}
| true | FFmpeg | e7843db3df0224cafcc1af9da103a3a7286ae2ba | static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
int srcSliceY, int srcSliceH, uint8_t *dst[],
int dstStride[])
{
const enum PixelFormat srcFormat = c->srcFormat;
const enum PixelFormat dstFormat = c->dstFormat;
const int srcBpp = (c->srcFormatBpp + 7) >> 3;
const int dstBpp = (c->dstFormatBpp + 7) >> 3;
const int srcId = c->srcFormatBpp;
const int dstId = c->dstFormatBpp;
void (*conv)(const uint8_t *src, uint8_t *dst, int src_size) = NULL;
#define CONV_IS(src, dst) (srcFormat == PIX_FMT_##src && dstFormat == PIX_FMT_##dst)
if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
if ( CONV_IS(ABGR, RGBA)
|| CONV_IS(ARGB, BGRA)
|| CONV_IS(BGRA, ARGB)
|| CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
else if (CONV_IS(ABGR, ARGB)
|| CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
else if (CONV_IS(ABGR, BGRA)
|| CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
else if (CONV_IS(BGRA, RGBA)
|| CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
else if (CONV_IS(BGRA, ABGR)
|| CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
} else
if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
(isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
switch (srcId | (dstId << 16)) {
case 0x000F0010: conv = rgb16to15; break;
case 0x000F0018: conv = rgb24to15; break;
case 0x000F0020: conv = rgb32to15; break;
case 0x0010000F: conv = rgb15to16; break;
case 0x00100018: conv = rgb24to16; break;
case 0x00100020: conv = rgb32to16; break;
case 0x0018000F: conv = rgb15to24; break;
case 0x00180010: conv = rgb16to24; break;
case 0x00180020: conv = rgb32to24; break;
case 0x0020000F: conv = rgb15to32; break;
case 0x00200010: conv = rgb16to32; break;
case 0x00200018: conv = rgb24to32; break;
}
} else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) ||
(isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
switch (srcId | (dstId << 16)) {
case 0x000C000C: conv = rgb12tobgr12; break;
case 0x000F000F: conv = rgb15tobgr15; break;
case 0x000F0010: conv = rgb16tobgr15; break;
case 0x000F0018: conv = rgb24tobgr15; break;
case 0x000F0020: conv = rgb32tobgr15; break;
case 0x0010000F: conv = rgb15tobgr16; break;
case 0x00100010: conv = rgb16tobgr16; break;
case 0x00100018: conv = rgb24tobgr16; break;
case 0x00100020: conv = rgb32tobgr16; break;
case 0x0018000F: conv = rgb15tobgr24; break;
case 0x00180010: conv = rgb16tobgr24; break;
case 0x00180018: conv = rgb24tobgr24; break;
case 0x00180020: conv = rgb32tobgr24; break;
case 0x0020000F: conv = rgb15tobgr32; break;
case 0x00200010: conv = rgb16tobgr32; break;
case 0x00200018: conv = rgb24tobgr32; break;
}
}
if (!conv) {
av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat));
} else {
const uint8_t *srcPtr = src[0];
uint8_t *dstPtr = dst[0];
if ((srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1) &&
!isRGBA32(dstFormat))
srcPtr += ALT32_CORR;
if ((dstFormat == PIX_FMT_RGB32_1 || dstFormat == PIX_FMT_BGR32_1) &&
!isRGBA32(srcFormat))
dstPtr += ALT32_CORR;
if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
!(srcStride[0] % srcBpp))
conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
srcSliceH * srcStride[0]);
else {
int i;
dstPtr += dstStride[0] * srcSliceY;
for (i = 0; i < srcSliceH; i++) {
conv(srcPtr, dstPtr, c->srcW * srcBpp);
srcPtr += srcStride[0];
dstPtr += dstStride[0];
}
}
}
return srcSliceH;
}
| {
"code": [
"static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],",
" int srcSliceY, int srcSliceH, uint8_t *dst[],",
" int dstStride[])",
" const int srcBpp = (c->srcFormatBpp + 7) >> 3;",
" const int dstBpp = (c->dstFormatBpp + 7) >> 3;",
" void (*conv)(const uint8_t *src, uint8_t *dst, int src_size) = NULL;"
],
"line_no": [
1,
3,
5,
13,
15,
21
]
} | static int FUNC_0(SwsContext *VAR_0, const uint8_t *VAR_14[], int VAR_2[],
int VAR_3, int VAR_4, uint8_t *VAR_14[],
int VAR_6[])
{
const enum PixelFormat VAR_7 = VAR_0->VAR_7;
const enum PixelFormat VAR_8 = VAR_0->VAR_8;
const int VAR_9 = (VAR_0->srcFormatBpp + 7) >> 3;
const int VAR_10 = (VAR_0->dstFormatBpp + 7) >> 3;
const int VAR_11 = VAR_0->srcFormatBpp;
const int VAR_12 = VAR_0->dstFormatBpp;
void (*VAR_13)(const uint8_t *VAR_14, uint8_t *VAR_14, int VAR_14) = NULL;
#define CONV_IS(VAR_14, VAR_14) (VAR_7 == PIX_FMT_##VAR_14 && VAR_8 == PIX_FMT_##VAR_14)
if (isRGBA32(VAR_7) && isRGBA32(VAR_8)) {
if ( CONV_IS(ABGR, RGBA)
|| CONV_IS(ARGB, BGRA)
|| CONV_IS(BGRA, ARGB)
|| CONV_IS(RGBA, ABGR)) VAR_13 = shuffle_bytes_3210;
else if (CONV_IS(ABGR, ARGB)
|| CONV_IS(ARGB, ABGR)) VAR_13 = shuffle_bytes_0321;
else if (CONV_IS(ABGR, BGRA)
|| CONV_IS(ARGB, RGBA)) VAR_13 = shuffle_bytes_1230;
else if (CONV_IS(BGRA, RGBA)
|| CONV_IS(RGBA, BGRA)) VAR_13 = shuffle_bytes_2103;
else if (CONV_IS(BGRA, ABGR)
|| CONV_IS(RGBA, ARGB)) VAR_13 = shuffle_bytes_3012;
} else
if ((isBGRinInt(VAR_7) && isBGRinInt(VAR_8)) ||
(isRGBinInt(VAR_7) && isRGBinInt(VAR_8))) {
switch (VAR_11 | (VAR_12 << 16)) {
case 0x000F0010: VAR_13 = rgb16to15; break;
case 0x000F0018: VAR_13 = rgb24to15; break;
case 0x000F0020: VAR_13 = rgb32to15; break;
case 0x0010000F: VAR_13 = rgb15to16; break;
case 0x00100018: VAR_13 = rgb24to16; break;
case 0x00100020: VAR_13 = rgb32to16; break;
case 0x0018000F: VAR_13 = rgb15to24; break;
case 0x00180010: VAR_13 = rgb16to24; break;
case 0x00180020: VAR_13 = rgb32to24; break;
case 0x0020000F: VAR_13 = rgb15to32; break;
case 0x00200010: VAR_13 = rgb16to32; break;
case 0x00200018: VAR_13 = rgb24to32; break;
}
} else if ((isBGRinInt(VAR_7) && isRGBinInt(VAR_8)) ||
(isRGBinInt(VAR_7) && isBGRinInt(VAR_8))) {
switch (VAR_11 | (VAR_12 << 16)) {
case 0x000C000C: VAR_13 = rgb12tobgr12; break;
case 0x000F000F: VAR_13 = rgb15tobgr15; break;
case 0x000F0010: VAR_13 = rgb16tobgr15; break;
case 0x000F0018: VAR_13 = rgb24tobgr15; break;
case 0x000F0020: VAR_13 = rgb32tobgr15; break;
case 0x0010000F: VAR_13 = rgb15tobgr16; break;
case 0x00100010: VAR_13 = rgb16tobgr16; break;
case 0x00100018: VAR_13 = rgb24tobgr16; break;
case 0x00100020: VAR_13 = rgb32tobgr16; break;
case 0x0018000F: VAR_13 = rgb15tobgr24; break;
case 0x00180010: VAR_13 = rgb16tobgr24; break;
case 0x00180018: VAR_13 = rgb24tobgr24; break;
case 0x00180020: VAR_13 = rgb32tobgr24; break;
case 0x0020000F: VAR_13 = rgb15tobgr32; break;
case 0x00200010: VAR_13 = rgb16tobgr32; break;
case 0x00200018: VAR_13 = rgb24tobgr32; break;
}
}
if (!VAR_13) {
av_log(VAR_0, AV_LOG_ERROR, "internal error %s -> %s converter\n",
sws_format_name(VAR_7), sws_format_name(VAR_8));
} else {
const uint8_t *VAR_15 = VAR_14[0];
uint8_t *dstPtr = VAR_14[0];
if ((VAR_7 == PIX_FMT_RGB32_1 || VAR_7 == PIX_FMT_BGR32_1) &&
!isRGBA32(VAR_8))
VAR_15 += ALT32_CORR;
if ((VAR_8 == PIX_FMT_RGB32_1 || VAR_8 == PIX_FMT_BGR32_1) &&
!isRGBA32(VAR_7))
dstPtr += ALT32_CORR;
if (VAR_6[0] * VAR_9 == VAR_2[0] * VAR_10 && VAR_2[0] > 0 &&
!(VAR_2[0] % VAR_9))
VAR_13(VAR_15, dstPtr + VAR_6[0] * VAR_3,
VAR_4 * VAR_2[0]);
else {
int VAR_16;
dstPtr += VAR_6[0] * VAR_3;
for (VAR_16 = 0; VAR_16 < VAR_4; VAR_16++) {
VAR_13(VAR_15, dstPtr, VAR_0->srcW * VAR_9);
VAR_15 += VAR_2[0];
dstPtr += VAR_6[0];
}
}
}
return VAR_4;
}
| [
"static int FUNC_0(SwsContext *VAR_0, const uint8_t *VAR_14[], int VAR_2[],\nint VAR_3, int VAR_4, uint8_t *VAR_14[],\nint VAR_6[])\n{",
"const enum PixelFormat VAR_7 = VAR_0->VAR_7;",
"const enum PixelFormat VAR_8 = VAR_0->VAR_8;",
"const int VAR_9 = (VAR_0->srcFormatBpp + 7) >> 3;",
"const int VAR_10 = (VAR_0->dstFormatBpp + 7) >> 3;",
"const int VAR_11 = VAR_0->srcFormatBpp;",
"const int VAR_12 = VAR_0->dstFormatBpp;",
"void (*VAR_13)(const uint8_t *VAR_14, uint8_t *VAR_14, int VAR_14) = NULL;",
"#define CONV_IS(VAR_14, VAR_14) (VAR_7 == PIX_FMT_##VAR_14 && VAR_8 == PIX_FMT_##VAR_14)\nif (isRGBA32(VAR_7) && isRGBA32(VAR_8)) {",
"if ( CONV_IS(ABGR, RGBA)\n|| CONV_IS(ARGB, BGRA)\n|| CONV_IS(BGRA, ARGB)\n|| CONV_IS(RGBA, ABGR)) VAR_13 = shuffle_bytes_3210;",
"else if (CONV_IS(ABGR, ARGB)\n|| CONV_IS(ARGB, ABGR)) VAR_13 = shuffle_bytes_0321;",
"else if (CONV_IS(ABGR, BGRA)\n|| CONV_IS(ARGB, RGBA)) VAR_13 = shuffle_bytes_1230;",
"else if (CONV_IS(BGRA, RGBA)\n|| CONV_IS(RGBA, BGRA)) VAR_13 = shuffle_bytes_2103;",
"else if (CONV_IS(BGRA, ABGR)\n|| CONV_IS(RGBA, ARGB)) VAR_13 = shuffle_bytes_3012;",
"} else",
"if ((isBGRinInt(VAR_7) && isBGRinInt(VAR_8)) ||\n(isRGBinInt(VAR_7) && isRGBinInt(VAR_8))) {",
"switch (VAR_11 | (VAR_12 << 16)) {",
"case 0x000F0010: VAR_13 = rgb16to15; break;",
"case 0x000F0018: VAR_13 = rgb24to15; break;",
"case 0x000F0020: VAR_13 = rgb32to15; break;",
"case 0x0010000F: VAR_13 = rgb15to16; break;",
"case 0x00100018: VAR_13 = rgb24to16; break;",
"case 0x00100020: VAR_13 = rgb32to16; break;",
"case 0x0018000F: VAR_13 = rgb15to24; break;",
"case 0x00180010: VAR_13 = rgb16to24; break;",
"case 0x00180020: VAR_13 = rgb32to24; break;",
"case 0x0020000F: VAR_13 = rgb15to32; break;",
"case 0x00200010: VAR_13 = rgb16to32; break;",
"case 0x00200018: VAR_13 = rgb24to32; break;",
"}",
"} else if ((isBGRinInt(VAR_7) && isRGBinInt(VAR_8)) ||",
"(isRGBinInt(VAR_7) && isBGRinInt(VAR_8))) {",
"switch (VAR_11 | (VAR_12 << 16)) {",
"case 0x000C000C: VAR_13 = rgb12tobgr12; break;",
"case 0x000F000F: VAR_13 = rgb15tobgr15; break;",
"case 0x000F0010: VAR_13 = rgb16tobgr15; break;",
"case 0x000F0018: VAR_13 = rgb24tobgr15; break;",
"case 0x000F0020: VAR_13 = rgb32tobgr15; break;",
"case 0x0010000F: VAR_13 = rgb15tobgr16; break;",
"case 0x00100010: VAR_13 = rgb16tobgr16; break;",
"case 0x00100018: VAR_13 = rgb24tobgr16; break;",
"case 0x00100020: VAR_13 = rgb32tobgr16; break;",
"case 0x0018000F: VAR_13 = rgb15tobgr24; break;",
"case 0x00180010: VAR_13 = rgb16tobgr24; break;",
"case 0x00180018: VAR_13 = rgb24tobgr24; break;",
"case 0x00180020: VAR_13 = rgb32tobgr24; break;",
"case 0x0020000F: VAR_13 = rgb15tobgr32; break;",
"case 0x00200010: VAR_13 = rgb16tobgr32; break;",
"case 0x00200018: VAR_13 = rgb24tobgr32; break;",
"}",
"}",
"if (!VAR_13) {",
"av_log(VAR_0, AV_LOG_ERROR, \"internal error %s -> %s converter\\n\",\nsws_format_name(VAR_7), sws_format_name(VAR_8));",
"} else {",
"const uint8_t *VAR_15 = VAR_14[0];",
"uint8_t *dstPtr = VAR_14[0];",
"if ((VAR_7 == PIX_FMT_RGB32_1 || VAR_7 == PIX_FMT_BGR32_1) &&\n!isRGBA32(VAR_8))\nVAR_15 += ALT32_CORR;",
"if ((VAR_8 == PIX_FMT_RGB32_1 || VAR_8 == PIX_FMT_BGR32_1) &&\n!isRGBA32(VAR_7))\ndstPtr += ALT32_CORR;",
"if (VAR_6[0] * VAR_9 == VAR_2[0] * VAR_10 && VAR_2[0] > 0 &&\n!(VAR_2[0] % VAR_9))\nVAR_13(VAR_15, dstPtr + VAR_6[0] * VAR_3,\nVAR_4 * VAR_2[0]);",
"else {",
"int VAR_16;",
"dstPtr += VAR_6[0] * VAR_3;",
"for (VAR_16 = 0; VAR_16 < VAR_4; VAR_16++) {",
"VAR_13(VAR_15, dstPtr, VAR_0->srcW * VAR_9);",
"VAR_15 += VAR_2[0];",
"dstPtr += VAR_6[0];",
"}",
"}",
"}",
"return VAR_4;",
"}"
] | [
1,
0,
0,
1,
1,
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25,
29
],
[
31,
33,
35,
37
],
[
39,
41
],
[
43,
45
],
[
47,
49
],
[
51,
53
],
[
55
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
147,
149,
151
],
[
155,
157,
159
],
[
163,
165,
167,
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
]
] |
19,443 | static void gen_dmtc0(DisasContext *ctx, TCGv arg, int reg, int sel)
{
const char *rn = "invalid";
if (sel != 0)
check_insn(ctx, ISA_MIPS64);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
switch (reg) {
case 0:
switch (sel) {
case 0:
gen_helper_mtc0_index(cpu_env, arg);
rn = "Index";
case 1:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_mvpcontrol(cpu_env, arg);
rn = "MVPControl";
CP0_CHECK(ctx->insn_flags & ASE_MT);
/* ignored */
rn = "MVPConf0";
CP0_CHECK(ctx->insn_flags & ASE_MT);
/* ignored */
rn = "MVPConf1";
CP0_CHECK(ctx->vp);
/* ignored */
rn = "VPControl";
default:
goto cp0_unimplemented;
}
case 1:
switch (sel) {
case 0:
/* ignored */
rn = "Random";
case 1:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpecontrol(cpu_env, arg);
rn = "VPEControl";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpeconf0(cpu_env, arg);
rn = "VPEConf0";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpeconf1(cpu_env, arg);
rn = "VPEConf1";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_yqmask(cpu_env, arg);
rn = "YQMask";
case 5:
CP0_CHECK(ctx->insn_flags & ASE_MT);
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_VPESchedule));
rn = "VPESchedule";
case 6:
CP0_CHECK(ctx->insn_flags & ASE_MT);
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_VPEScheFBack));
rn = "VPEScheFBack";
case 7:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpeopt(cpu_env, arg);
rn = "VPEOpt";
default:
goto cp0_unimplemented;
}
switch (sel) {
case 0:
gen_helper_dmtc0_entrylo0(cpu_env, arg);
rn = "EntryLo0";
case 1:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcstatus(cpu_env, arg);
rn = "TCStatus";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcbind(cpu_env, arg);
rn = "TCBind";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcrestart(cpu_env, arg);
rn = "TCRestart";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tchalt(cpu_env, arg);
rn = "TCHalt";
case 5:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tccontext(cpu_env, arg);
rn = "TCContext";
case 6:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcschedule(cpu_env, arg);
rn = "TCSchedule";
case 7:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcschefback(cpu_env, arg);
rn = "TCScheFBack";
default:
goto cp0_unimplemented;
}
switch (sel) {
case 0:
gen_helper_dmtc0_entrylo1(cpu_env, arg);
rn = "EntryLo1";
case 1:
CP0_CHECK(ctx->vp);
/* ignored */
rn = "GlobalNumber";
default:
goto cp0_unimplemented;
}
switch (sel) {
case 0:
gen_helper_mtc0_context(cpu_env, arg);
rn = "Context";
case 1:
// gen_helper_mtc0_contextconfig(cpu_env, arg); /* SmartMIPS ASE */
rn = "ContextConfig";
goto cp0_unimplemented;
CP0_CHECK(ctx->ulri);
tcg_gen_st_tl(arg, cpu_env,
offsetof(CPUMIPSState, active_tc.CP0_UserLocal));
rn = "UserLocal";
default:
goto cp0_unimplemented;
}
case 5:
switch (sel) {
case 0:
gen_helper_mtc0_pagemask(cpu_env, arg);
rn = "PageMask";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_pagegrain(cpu_env, arg);
rn = "PageGrain";
default:
goto cp0_unimplemented;
}
case 6:
switch (sel) {
case 0:
gen_helper_mtc0_wired(cpu_env, arg);
rn = "Wired";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf0(cpu_env, arg);
rn = "SRSConf0";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf1(cpu_env, arg);
rn = "SRSConf1";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf2(cpu_env, arg);
rn = "SRSConf2";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf3(cpu_env, arg);
rn = "SRSConf3";
case 5:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf4(cpu_env, arg);
rn = "SRSConf4";
default:
goto cp0_unimplemented;
}
case 7:
switch (sel) {
case 0:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_hwrena(cpu_env, arg);
ctx->bstate = BS_STOP;
rn = "HWREna";
default:
goto cp0_unimplemented;
}
case 8:
switch (sel) {
case 0:
/* ignored */
rn = "BadVAddr";
case 1:
/* ignored */
rn = "BadInstr";
/* ignored */
rn = "BadInstrP";
default:
goto cp0_unimplemented;
}
case 9:
switch (sel) {
case 0:
gen_helper_mtc0_count(cpu_env, arg);
rn = "Count";
/* 6,7 are implementation dependent */
default:
goto cp0_unimplemented;
}
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
case 10:
switch (sel) {
case 0:
gen_helper_mtc0_entryhi(cpu_env, arg);
rn = "EntryHi";
default:
goto cp0_unimplemented;
}
case 11:
switch (sel) {
case 0:
gen_helper_mtc0_compare(cpu_env, arg);
rn = "Compare";
/* 6,7 are implementation dependent */
default:
goto cp0_unimplemented;
}
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
case 12:
switch (sel) {
case 0:
save_cpu_state(ctx, 1);
gen_helper_mtc0_status(cpu_env, arg);
/* BS_STOP isn't good enough here, hflags may have changed. */
gen_save_pc(ctx->pc + 4);
ctx->bstate = BS_EXCP;
rn = "Status";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_intctl(cpu_env, arg);
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "IntCtl";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsctl(cpu_env, arg);
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "SRSCtl";
check_insn(ctx, ISA_MIPS32R2);
gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_SRSMap));
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "SRSMap";
default:
goto cp0_unimplemented;
}
case 13:
switch (sel) {
case 0:
save_cpu_state(ctx, 1);
/* Mark as an IO operation because we may trigger a software
interrupt. */
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_mtc0_cause(cpu_env, arg);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
}
/* Stop translation as we may have triggered an intetrupt */
ctx->bstate = BS_STOP;
rn = "Cause";
default:
goto cp0_unimplemented;
}
case 14:
switch (sel) {
case 0:
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_EPC));
rn = "EPC";
default:
goto cp0_unimplemented;
}
case 15:
switch (sel) {
case 0:
/* ignored */
rn = "PRid";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_ebase(cpu_env, arg);
rn = "EBase";
default:
goto cp0_unimplemented;
}
case 16:
switch (sel) {
case 0:
gen_helper_mtc0_config0(cpu_env, arg);
rn = "Config";
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
case 1:
/* ignored, read only */
rn = "Config1";
gen_helper_mtc0_config2(cpu_env, arg);
rn = "Config2";
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
gen_helper_mtc0_config3(cpu_env, arg);
rn = "Config3";
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
/* currently ignored */
rn = "Config4";
case 5:
gen_helper_mtc0_config5(cpu_env, arg);
rn = "Config5";
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
/* 6,7 are implementation dependent */
default:
rn = "Invalid config selector";
goto cp0_unimplemented;
}
case 17:
switch (sel) {
case 0:
gen_helper_mtc0_lladdr(cpu_env, arg);
rn = "LLAddr";
case 1:
CP0_CHECK(ctx->mrp);
gen_helper_mtc0_maar(cpu_env, arg);
rn = "MAAR";
CP0_CHECK(ctx->mrp);
gen_helper_mtc0_maari(cpu_env, arg);
rn = "MAARI";
default:
goto cp0_unimplemented;
}
case 18:
switch (sel) {
case 0 ... 7:
gen_helper_0e1i(mtc0_watchlo, arg, sel);
rn = "WatchLo";
default:
goto cp0_unimplemented;
}
case 19:
switch (sel) {
case 0 ... 7:
gen_helper_0e1i(mtc0_watchhi, arg, sel);
rn = "WatchHi";
default:
goto cp0_unimplemented;
}
case 20:
switch (sel) {
case 0:
check_insn(ctx, ISA_MIPS3);
gen_helper_mtc0_xcontext(cpu_env, arg);
rn = "XContext";
default:
goto cp0_unimplemented;
}
case 21:
/* Officially reserved, but sel 0 is used for R1x000 framemask */
CP0_CHECK(!(ctx->insn_flags & ISA_MIPS32R6));
switch (sel) {
case 0:
gen_helper_mtc0_framemask(cpu_env, arg);
rn = "Framemask";
default:
goto cp0_unimplemented;
}
case 22:
/* ignored */
rn = "Diagnostic"; /* implementation dependent */
case 23:
switch (sel) {
case 0:
gen_helper_mtc0_debug(cpu_env, arg); /* EJTAG support */
/* BS_STOP isn't good enough here, hflags may have changed. */
gen_save_pc(ctx->pc + 4);
ctx->bstate = BS_EXCP;
rn = "Debug";
case 1:
// gen_helper_mtc0_tracecontrol(cpu_env, arg); /* PDtrace support */
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "TraceControl";
goto cp0_unimplemented;
// gen_helper_mtc0_tracecontrol2(cpu_env, arg); /* PDtrace support */
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "TraceControl2";
goto cp0_unimplemented;
// gen_helper_mtc0_usertracedata(cpu_env, arg); /* PDtrace support */
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "UserTraceData";
goto cp0_unimplemented;
// gen_helper_mtc0_tracebpc(cpu_env, arg); /* PDtrace support */
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
rn = "TraceBPC";
goto cp0_unimplemented;
default:
goto cp0_unimplemented;
}
case 24:
switch (sel) {
case 0:
/* EJTAG support */
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_DEPC));
rn = "DEPC";
default:
goto cp0_unimplemented;
}
case 25:
switch (sel) {
case 0:
gen_helper_mtc0_performance0(cpu_env, arg);
rn = "Performance0";
case 1:
// gen_helper_mtc0_performance1(cpu_env, arg);
rn = "Performance1";
goto cp0_unimplemented;
// gen_helper_mtc0_performance2(cpu_env, arg);
rn = "Performance2";
goto cp0_unimplemented;
// gen_helper_mtc0_performance3(cpu_env, arg);
rn = "Performance3";
goto cp0_unimplemented;
// gen_helper_mtc0_performance4(cpu_env, arg);
rn = "Performance4";
goto cp0_unimplemented;
case 5:
// gen_helper_mtc0_performance5(cpu_env, arg);
rn = "Performance5";
goto cp0_unimplemented;
case 6:
// gen_helper_mtc0_performance6(cpu_env, arg);
rn = "Performance6";
goto cp0_unimplemented;
case 7:
// gen_helper_mtc0_performance7(cpu_env, arg);
rn = "Performance7";
goto cp0_unimplemented;
default:
goto cp0_unimplemented;
}
case 26:
switch (sel) {
case 0:
gen_helper_mtc0_errctl(cpu_env, arg);
ctx->bstate = BS_STOP;
rn = "ErrCtl";
default:
goto cp0_unimplemented;
}
case 27:
switch (sel) {
case 0 ... 3:
/* ignored */
rn = "CacheErr";
default:
goto cp0_unimplemented;
}
case 28:
switch (sel) {
case 0:
case 6:
gen_helper_mtc0_taglo(cpu_env, arg);
rn = "TagLo";
case 1:
case 5:
case 7:
gen_helper_mtc0_datalo(cpu_env, arg);
rn = "DataLo";
default:
goto cp0_unimplemented;
}
case 29:
switch (sel) {
case 0:
case 6:
gen_helper_mtc0_taghi(cpu_env, arg);
rn = "TagHi";
case 1:
case 5:
case 7:
gen_helper_mtc0_datahi(cpu_env, arg);
rn = "DataHi";
default:
rn = "invalid sel";
goto cp0_unimplemented;
}
case 30:
switch (sel) {
case 0:
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_ErrorEPC));
rn = "ErrorEPC";
default:
goto cp0_unimplemented;
}
case 31:
switch (sel) {
case 0:
/* EJTAG support */
gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_DESAVE));
rn = "DESAVE";
case 2 ... 7:
CP0_CHECK(ctx->kscrexist & (1 << sel));
tcg_gen_st_tl(arg, cpu_env,
offsetof(CPUMIPSState, CP0_KScratch[sel-2]));
rn = "KScratch";
default:
goto cp0_unimplemented;
}
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
default:
goto cp0_unimplemented;
}
trace_mips_translate_c0("dmtc0", rn, reg, sel);
/* For simplicity assume that all writes can cause interrupts. */
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
ctx->bstate = BS_STOP;
}
return;
cp0_unimplemented:
qemu_log_mask(LOG_UNIMP, "dmtc0 %s (reg %d sel %d)\n", rn, reg, sel);
} | true | qemu | cec56a733dd2c3fa81dbedbecf03922258747f7d | static void gen_dmtc0(DisasContext *ctx, TCGv arg, int reg, int sel)
{
const char *rn = "invalid";
if (sel != 0)
check_insn(ctx, ISA_MIPS64);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
switch (reg) {
case 0:
switch (sel) {
case 0:
gen_helper_mtc0_index(cpu_env, arg);
rn = "Index";
case 1:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_mvpcontrol(cpu_env, arg);
rn = "MVPControl";
CP0_CHECK(ctx->insn_flags & ASE_MT);
rn = "MVPConf0";
CP0_CHECK(ctx->insn_flags & ASE_MT);
rn = "MVPConf1";
CP0_CHECK(ctx->vp);
rn = "VPControl";
default:
goto cp0_unimplemented;
}
case 1:
switch (sel) {
case 0:
rn = "Random";
case 1:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpecontrol(cpu_env, arg);
rn = "VPEControl";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpeconf0(cpu_env, arg);
rn = "VPEConf0";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpeconf1(cpu_env, arg);
rn = "VPEConf1";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_yqmask(cpu_env, arg);
rn = "YQMask";
case 5:
CP0_CHECK(ctx->insn_flags & ASE_MT);
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_VPESchedule));
rn = "VPESchedule";
case 6:
CP0_CHECK(ctx->insn_flags & ASE_MT);
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_VPEScheFBack));
rn = "VPEScheFBack";
case 7:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_vpeopt(cpu_env, arg);
rn = "VPEOpt";
default:
goto cp0_unimplemented;
}
switch (sel) {
case 0:
gen_helper_dmtc0_entrylo0(cpu_env, arg);
rn = "EntryLo0";
case 1:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcstatus(cpu_env, arg);
rn = "TCStatus";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcbind(cpu_env, arg);
rn = "TCBind";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcrestart(cpu_env, arg);
rn = "TCRestart";
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tchalt(cpu_env, arg);
rn = "TCHalt";
case 5:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tccontext(cpu_env, arg);
rn = "TCContext";
case 6:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcschedule(cpu_env, arg);
rn = "TCSchedule";
case 7:
CP0_CHECK(ctx->insn_flags & ASE_MT);
gen_helper_mtc0_tcschefback(cpu_env, arg);
rn = "TCScheFBack";
default:
goto cp0_unimplemented;
}
switch (sel) {
case 0:
gen_helper_dmtc0_entrylo1(cpu_env, arg);
rn = "EntryLo1";
case 1:
CP0_CHECK(ctx->vp);
rn = "GlobalNumber";
default:
goto cp0_unimplemented;
}
switch (sel) {
case 0:
gen_helper_mtc0_context(cpu_env, arg);
rn = "Context";
case 1:
rn = "ContextConfig";
goto cp0_unimplemented;
CP0_CHECK(ctx->ulri);
tcg_gen_st_tl(arg, cpu_env,
offsetof(CPUMIPSState, active_tc.CP0_UserLocal));
rn = "UserLocal";
default:
goto cp0_unimplemented;
}
case 5:
switch (sel) {
case 0:
gen_helper_mtc0_pagemask(cpu_env, arg);
rn = "PageMask";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_pagegrain(cpu_env, arg);
rn = "PageGrain";
default:
goto cp0_unimplemented;
}
case 6:
switch (sel) {
case 0:
gen_helper_mtc0_wired(cpu_env, arg);
rn = "Wired";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf0(cpu_env, arg);
rn = "SRSConf0";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf1(cpu_env, arg);
rn = "SRSConf1";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf2(cpu_env, arg);
rn = "SRSConf2";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf3(cpu_env, arg);
rn = "SRSConf3";
case 5:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsconf4(cpu_env, arg);
rn = "SRSConf4";
default:
goto cp0_unimplemented;
}
case 7:
switch (sel) {
case 0:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_hwrena(cpu_env, arg);
ctx->bstate = BS_STOP;
rn = "HWREna";
default:
goto cp0_unimplemented;
}
case 8:
switch (sel) {
case 0:
rn = "BadVAddr";
case 1:
rn = "BadInstr";
rn = "BadInstrP";
default:
goto cp0_unimplemented;
}
case 9:
switch (sel) {
case 0:
gen_helper_mtc0_count(cpu_env, arg);
rn = "Count";
default:
goto cp0_unimplemented;
}
ctx->bstate = BS_STOP;
case 10:
switch (sel) {
case 0:
gen_helper_mtc0_entryhi(cpu_env, arg);
rn = "EntryHi";
default:
goto cp0_unimplemented;
}
case 11:
switch (sel) {
case 0:
gen_helper_mtc0_compare(cpu_env, arg);
rn = "Compare";
default:
goto cp0_unimplemented;
}
ctx->bstate = BS_STOP;
case 12:
switch (sel) {
case 0:
save_cpu_state(ctx, 1);
gen_helper_mtc0_status(cpu_env, arg);
gen_save_pc(ctx->pc + 4);
ctx->bstate = BS_EXCP;
rn = "Status";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_intctl(cpu_env, arg);
ctx->bstate = BS_STOP;
rn = "IntCtl";
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_srsctl(cpu_env, arg);
ctx->bstate = BS_STOP;
rn = "SRSCtl";
check_insn(ctx, ISA_MIPS32R2);
gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_SRSMap));
ctx->bstate = BS_STOP;
rn = "SRSMap";
default:
goto cp0_unimplemented;
}
case 13:
switch (sel) {
case 0:
save_cpu_state(ctx, 1);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_mtc0_cause(cpu_env, arg);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
}
ctx->bstate = BS_STOP;
rn = "Cause";
default:
goto cp0_unimplemented;
}
case 14:
switch (sel) {
case 0:
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_EPC));
rn = "EPC";
default:
goto cp0_unimplemented;
}
case 15:
switch (sel) {
case 0:
rn = "PRid";
case 1:
check_insn(ctx, ISA_MIPS32R2);
gen_helper_mtc0_ebase(cpu_env, arg);
rn = "EBase";
default:
goto cp0_unimplemented;
}
case 16:
switch (sel) {
case 0:
gen_helper_mtc0_config0(cpu_env, arg);
rn = "Config";
ctx->bstate = BS_STOP;
case 1:
rn = "Config1";
gen_helper_mtc0_config2(cpu_env, arg);
rn = "Config2";
ctx->bstate = BS_STOP;
gen_helper_mtc0_config3(cpu_env, arg);
rn = "Config3";
ctx->bstate = BS_STOP;
rn = "Config4";
case 5:
gen_helper_mtc0_config5(cpu_env, arg);
rn = "Config5";
ctx->bstate = BS_STOP;
default:
rn = "Invalid config selector";
goto cp0_unimplemented;
}
case 17:
switch (sel) {
case 0:
gen_helper_mtc0_lladdr(cpu_env, arg);
rn = "LLAddr";
case 1:
CP0_CHECK(ctx->mrp);
gen_helper_mtc0_maar(cpu_env, arg);
rn = "MAAR";
CP0_CHECK(ctx->mrp);
gen_helper_mtc0_maari(cpu_env, arg);
rn = "MAARI";
default:
goto cp0_unimplemented;
}
case 18:
switch (sel) {
case 0 ... 7:
gen_helper_0e1i(mtc0_watchlo, arg, sel);
rn = "WatchLo";
default:
goto cp0_unimplemented;
}
case 19:
switch (sel) {
case 0 ... 7:
gen_helper_0e1i(mtc0_watchhi, arg, sel);
rn = "WatchHi";
default:
goto cp0_unimplemented;
}
case 20:
switch (sel) {
case 0:
check_insn(ctx, ISA_MIPS3);
gen_helper_mtc0_xcontext(cpu_env, arg);
rn = "XContext";
default:
goto cp0_unimplemented;
}
case 21:
CP0_CHECK(!(ctx->insn_flags & ISA_MIPS32R6));
switch (sel) {
case 0:
gen_helper_mtc0_framemask(cpu_env, arg);
rn = "Framemask";
default:
goto cp0_unimplemented;
}
case 22:
rn = "Diagnostic";
case 23:
switch (sel) {
case 0:
gen_helper_mtc0_debug(cpu_env, arg);
gen_save_pc(ctx->pc + 4);
ctx->bstate = BS_EXCP;
rn = "Debug";
case 1:
ctx->bstate = BS_STOP;
rn = "TraceControl";
goto cp0_unimplemented;
ctx->bstate = BS_STOP;
rn = "TraceControl2";
goto cp0_unimplemented;
ctx->bstate = BS_STOP;
rn = "UserTraceData";
goto cp0_unimplemented;
ctx->bstate = BS_STOP;
rn = "TraceBPC";
goto cp0_unimplemented;
default:
goto cp0_unimplemented;
}
case 24:
switch (sel) {
case 0:
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_DEPC));
rn = "DEPC";
default:
goto cp0_unimplemented;
}
case 25:
switch (sel) {
case 0:
gen_helper_mtc0_performance0(cpu_env, arg);
rn = "Performance0";
case 1:
rn = "Performance1";
goto cp0_unimplemented;
rn = "Performance2";
goto cp0_unimplemented;
rn = "Performance3";
goto cp0_unimplemented;
rn = "Performance4";
goto cp0_unimplemented;
case 5:
rn = "Performance5";
goto cp0_unimplemented;
case 6:
rn = "Performance6";
goto cp0_unimplemented;
case 7:
rn = "Performance7";
goto cp0_unimplemented;
default:
goto cp0_unimplemented;
}
case 26:
switch (sel) {
case 0:
gen_helper_mtc0_errctl(cpu_env, arg);
ctx->bstate = BS_STOP;
rn = "ErrCtl";
default:
goto cp0_unimplemented;
}
case 27:
switch (sel) {
case 0 ... 3:
rn = "CacheErr";
default:
goto cp0_unimplemented;
}
case 28:
switch (sel) {
case 0:
case 6:
gen_helper_mtc0_taglo(cpu_env, arg);
rn = "TagLo";
case 1:
case 5:
case 7:
gen_helper_mtc0_datalo(cpu_env, arg);
rn = "DataLo";
default:
goto cp0_unimplemented;
}
case 29:
switch (sel) {
case 0:
case 6:
gen_helper_mtc0_taghi(cpu_env, arg);
rn = "TagHi";
case 1:
case 5:
case 7:
gen_helper_mtc0_datahi(cpu_env, arg);
rn = "DataHi";
default:
rn = "invalid sel";
goto cp0_unimplemented;
}
case 30:
switch (sel) {
case 0:
tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_ErrorEPC));
rn = "ErrorEPC";
default:
goto cp0_unimplemented;
}
case 31:
switch (sel) {
case 0:
gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_DESAVE));
rn = "DESAVE";
case 2 ... 7:
CP0_CHECK(ctx->kscrexist & (1 << sel));
tcg_gen_st_tl(arg, cpu_env,
offsetof(CPUMIPSState, CP0_KScratch[sel-2]));
rn = "KScratch";
default:
goto cp0_unimplemented;
}
ctx->bstate = BS_STOP;
default:
goto cp0_unimplemented;
}
trace_mips_translate_c0("dmtc0", rn, reg, sel);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
ctx->bstate = BS_STOP;
}
return;
cp0_unimplemented:
qemu_log_mask(LOG_UNIMP, "dmtc0 %s (reg %d sel %d)\n", rn, reg, sel);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1, int VAR_2, int VAR_3)
{
const char *VAR_4 = "invalid";
if (VAR_3 != 0)
check_insn(VAR_0, ISA_MIPS64);
if (VAR_0->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
switch (VAR_2) {
case 0:
switch (VAR_3) {
case 0:
gen_helper_mtc0_index(cpu_env, VAR_1);
VAR_4 = "Index";
case 1:
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_mvpcontrol(cpu_env, VAR_1);
VAR_4 = "MVPControl";
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
VAR_4 = "MVPConf0";
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
VAR_4 = "MVPConf1";
CP0_CHECK(VAR_0->vp);
VAR_4 = "VPControl";
default:
goto cp0_unimplemented;
}
case 1:
switch (VAR_3) {
case 0:
VAR_4 = "Random";
case 1:
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_vpecontrol(cpu_env, VAR_1);
VAR_4 = "VPEControl";
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_vpeconf0(cpu_env, VAR_1);
VAR_4 = "VPEConf0";
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_vpeconf1(cpu_env, VAR_1);
VAR_4 = "VPEConf1";
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_yqmask(cpu_env, VAR_1);
VAR_4 = "YQMask";
case 5:
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
tcg_gen_st_tl(VAR_1, cpu_env, offsetof(CPUMIPSState, CP0_VPESchedule));
VAR_4 = "VPESchedule";
case 6:
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
tcg_gen_st_tl(VAR_1, cpu_env, offsetof(CPUMIPSState, CP0_VPEScheFBack));
VAR_4 = "VPEScheFBack";
case 7:
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_vpeopt(cpu_env, VAR_1);
VAR_4 = "VPEOpt";
default:
goto cp0_unimplemented;
}
switch (VAR_3) {
case 0:
gen_helper_dmtc0_entrylo0(cpu_env, VAR_1);
VAR_4 = "EntryLo0";
case 1:
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_tcstatus(cpu_env, VAR_1);
VAR_4 = "TCStatus";
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_tcbind(cpu_env, VAR_1);
VAR_4 = "TCBind";
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_tcrestart(cpu_env, VAR_1);
VAR_4 = "TCRestart";
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_tchalt(cpu_env, VAR_1);
VAR_4 = "TCHalt";
case 5:
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_tccontext(cpu_env, VAR_1);
VAR_4 = "TCContext";
case 6:
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_tcschedule(cpu_env, VAR_1);
VAR_4 = "TCSchedule";
case 7:
CP0_CHECK(VAR_0->insn_flags & ASE_MT);
gen_helper_mtc0_tcschefback(cpu_env, VAR_1);
VAR_4 = "TCScheFBack";
default:
goto cp0_unimplemented;
}
switch (VAR_3) {
case 0:
gen_helper_dmtc0_entrylo1(cpu_env, VAR_1);
VAR_4 = "EntryLo1";
case 1:
CP0_CHECK(VAR_0->vp);
VAR_4 = "GlobalNumber";
default:
goto cp0_unimplemented;
}
switch (VAR_3) {
case 0:
gen_helper_mtc0_context(cpu_env, VAR_1);
VAR_4 = "Context";
case 1:
VAR_4 = "ContextConfig";
goto cp0_unimplemented;
CP0_CHECK(VAR_0->ulri);
tcg_gen_st_tl(VAR_1, cpu_env,
offsetof(CPUMIPSState, active_tc.CP0_UserLocal));
VAR_4 = "UserLocal";
default:
goto cp0_unimplemented;
}
case 5:
switch (VAR_3) {
case 0:
gen_helper_mtc0_pagemask(cpu_env, VAR_1);
VAR_4 = "PageMask";
case 1:
check_insn(VAR_0, ISA_MIPS32R2);
gen_helper_mtc0_pagegrain(cpu_env, VAR_1);
VAR_4 = "PageGrain";
default:
goto cp0_unimplemented;
}
case 6:
switch (VAR_3) {
case 0:
gen_helper_mtc0_wired(cpu_env, VAR_1);
VAR_4 = "Wired";
case 1:
check_insn(VAR_0, ISA_MIPS32R2);
gen_helper_mtc0_srsconf0(cpu_env, VAR_1);
VAR_4 = "SRSConf0";
check_insn(VAR_0, ISA_MIPS32R2);
gen_helper_mtc0_srsconf1(cpu_env, VAR_1);
VAR_4 = "SRSConf1";
check_insn(VAR_0, ISA_MIPS32R2);
gen_helper_mtc0_srsconf2(cpu_env, VAR_1);
VAR_4 = "SRSConf2";
check_insn(VAR_0, ISA_MIPS32R2);
gen_helper_mtc0_srsconf3(cpu_env, VAR_1);
VAR_4 = "SRSConf3";
case 5:
check_insn(VAR_0, ISA_MIPS32R2);
gen_helper_mtc0_srsconf4(cpu_env, VAR_1);
VAR_4 = "SRSConf4";
default:
goto cp0_unimplemented;
}
case 7:
switch (VAR_3) {
case 0:
check_insn(VAR_0, ISA_MIPS32R2);
gen_helper_mtc0_hwrena(cpu_env, VAR_1);
VAR_0->bstate = BS_STOP;
VAR_4 = "HWREna";
default:
goto cp0_unimplemented;
}
case 8:
switch (VAR_3) {
case 0:
VAR_4 = "BadVAddr";
case 1:
VAR_4 = "BadInstr";
VAR_4 = "BadInstrP";
default:
goto cp0_unimplemented;
}
case 9:
switch (VAR_3) {
case 0:
gen_helper_mtc0_count(cpu_env, VAR_1);
VAR_4 = "Count";
default:
goto cp0_unimplemented;
}
VAR_0->bstate = BS_STOP;
case 10:
switch (VAR_3) {
case 0:
gen_helper_mtc0_entryhi(cpu_env, VAR_1);
VAR_4 = "EntryHi";
default:
goto cp0_unimplemented;
}
case 11:
switch (VAR_3) {
case 0:
gen_helper_mtc0_compare(cpu_env, VAR_1);
VAR_4 = "Compare";
default:
goto cp0_unimplemented;
}
VAR_0->bstate = BS_STOP;
case 12:
switch (VAR_3) {
case 0:
save_cpu_state(VAR_0, 1);
gen_helper_mtc0_status(cpu_env, VAR_1);
gen_save_pc(VAR_0->pc + 4);
VAR_0->bstate = BS_EXCP;
VAR_4 = "Status";
case 1:
check_insn(VAR_0, ISA_MIPS32R2);
gen_helper_mtc0_intctl(cpu_env, VAR_1);
VAR_0->bstate = BS_STOP;
VAR_4 = "IntCtl";
check_insn(VAR_0, ISA_MIPS32R2);
gen_helper_mtc0_srsctl(cpu_env, VAR_1);
VAR_0->bstate = BS_STOP;
VAR_4 = "SRSCtl";
check_insn(VAR_0, ISA_MIPS32R2);
gen_mtc0_store32(VAR_1, offsetof(CPUMIPSState, CP0_SRSMap));
VAR_0->bstate = BS_STOP;
VAR_4 = "SRSMap";
default:
goto cp0_unimplemented;
}
case 13:
switch (VAR_3) {
case 0:
save_cpu_state(VAR_0, 1);
if (VAR_0->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_mtc0_cause(cpu_env, VAR_1);
if (VAR_0->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
}
VAR_0->bstate = BS_STOP;
VAR_4 = "Cause";
default:
goto cp0_unimplemented;
}
case 14:
switch (VAR_3) {
case 0:
tcg_gen_st_tl(VAR_1, cpu_env, offsetof(CPUMIPSState, CP0_EPC));
VAR_4 = "EPC";
default:
goto cp0_unimplemented;
}
case 15:
switch (VAR_3) {
case 0:
VAR_4 = "PRid";
case 1:
check_insn(VAR_0, ISA_MIPS32R2);
gen_helper_mtc0_ebase(cpu_env, VAR_1);
VAR_4 = "EBase";
default:
goto cp0_unimplemented;
}
case 16:
switch (VAR_3) {
case 0:
gen_helper_mtc0_config0(cpu_env, VAR_1);
VAR_4 = "Config";
VAR_0->bstate = BS_STOP;
case 1:
VAR_4 = "Config1";
gen_helper_mtc0_config2(cpu_env, VAR_1);
VAR_4 = "Config2";
VAR_0->bstate = BS_STOP;
gen_helper_mtc0_config3(cpu_env, VAR_1);
VAR_4 = "Config3";
VAR_0->bstate = BS_STOP;
VAR_4 = "Config4";
case 5:
gen_helper_mtc0_config5(cpu_env, VAR_1);
VAR_4 = "Config5";
VAR_0->bstate = BS_STOP;
default:
VAR_4 = "Invalid config selector";
goto cp0_unimplemented;
}
case 17:
switch (VAR_3) {
case 0:
gen_helper_mtc0_lladdr(cpu_env, VAR_1);
VAR_4 = "LLAddr";
case 1:
CP0_CHECK(VAR_0->mrp);
gen_helper_mtc0_maar(cpu_env, VAR_1);
VAR_4 = "MAAR";
CP0_CHECK(VAR_0->mrp);
gen_helper_mtc0_maari(cpu_env, VAR_1);
VAR_4 = "MAARI";
default:
goto cp0_unimplemented;
}
case 18:
switch (VAR_3) {
case 0 ... 7:
gen_helper_0e1i(mtc0_watchlo, VAR_1, VAR_3);
VAR_4 = "WatchLo";
default:
goto cp0_unimplemented;
}
case 19:
switch (VAR_3) {
case 0 ... 7:
gen_helper_0e1i(mtc0_watchhi, VAR_1, VAR_3);
VAR_4 = "WatchHi";
default:
goto cp0_unimplemented;
}
case 20:
switch (VAR_3) {
case 0:
check_insn(VAR_0, ISA_MIPS3);
gen_helper_mtc0_xcontext(cpu_env, VAR_1);
VAR_4 = "XContext";
default:
goto cp0_unimplemented;
}
case 21:
CP0_CHECK(!(VAR_0->insn_flags & ISA_MIPS32R6));
switch (VAR_3) {
case 0:
gen_helper_mtc0_framemask(cpu_env, VAR_1);
VAR_4 = "Framemask";
default:
goto cp0_unimplemented;
}
case 22:
VAR_4 = "Diagnostic";
case 23:
switch (VAR_3) {
case 0:
gen_helper_mtc0_debug(cpu_env, VAR_1);
gen_save_pc(VAR_0->pc + 4);
VAR_0->bstate = BS_EXCP;
VAR_4 = "Debug";
case 1:
VAR_0->bstate = BS_STOP;
VAR_4 = "TraceControl";
goto cp0_unimplemented;
VAR_0->bstate = BS_STOP;
VAR_4 = "TraceControl2";
goto cp0_unimplemented;
VAR_0->bstate = BS_STOP;
VAR_4 = "UserTraceData";
goto cp0_unimplemented;
VAR_0->bstate = BS_STOP;
VAR_4 = "TraceBPC";
goto cp0_unimplemented;
default:
goto cp0_unimplemented;
}
case 24:
switch (VAR_3) {
case 0:
tcg_gen_st_tl(VAR_1, cpu_env, offsetof(CPUMIPSState, CP0_DEPC));
VAR_4 = "DEPC";
default:
goto cp0_unimplemented;
}
case 25:
switch (VAR_3) {
case 0:
gen_helper_mtc0_performance0(cpu_env, VAR_1);
VAR_4 = "Performance0";
case 1:
VAR_4 = "Performance1";
goto cp0_unimplemented;
VAR_4 = "Performance2";
goto cp0_unimplemented;
VAR_4 = "Performance3";
goto cp0_unimplemented;
VAR_4 = "Performance4";
goto cp0_unimplemented;
case 5:
VAR_4 = "Performance5";
goto cp0_unimplemented;
case 6:
VAR_4 = "Performance6";
goto cp0_unimplemented;
case 7:
VAR_4 = "Performance7";
goto cp0_unimplemented;
default:
goto cp0_unimplemented;
}
case 26:
switch (VAR_3) {
case 0:
gen_helper_mtc0_errctl(cpu_env, VAR_1);
VAR_0->bstate = BS_STOP;
VAR_4 = "ErrCtl";
default:
goto cp0_unimplemented;
}
case 27:
switch (VAR_3) {
case 0 ... 3:
VAR_4 = "CacheErr";
default:
goto cp0_unimplemented;
}
case 28:
switch (VAR_3) {
case 0:
case 6:
gen_helper_mtc0_taglo(cpu_env, VAR_1);
VAR_4 = "TagLo";
case 1:
case 5:
case 7:
gen_helper_mtc0_datalo(cpu_env, VAR_1);
VAR_4 = "DataLo";
default:
goto cp0_unimplemented;
}
case 29:
switch (VAR_3) {
case 0:
case 6:
gen_helper_mtc0_taghi(cpu_env, VAR_1);
VAR_4 = "TagHi";
case 1:
case 5:
case 7:
gen_helper_mtc0_datahi(cpu_env, VAR_1);
VAR_4 = "DataHi";
default:
VAR_4 = "invalid VAR_3";
goto cp0_unimplemented;
}
case 30:
switch (VAR_3) {
case 0:
tcg_gen_st_tl(VAR_1, cpu_env, offsetof(CPUMIPSState, CP0_ErrorEPC));
VAR_4 = "ErrorEPC";
default:
goto cp0_unimplemented;
}
case 31:
switch (VAR_3) {
case 0:
gen_mtc0_store32(VAR_1, offsetof(CPUMIPSState, CP0_DESAVE));
VAR_4 = "DESAVE";
case 2 ... 7:
CP0_CHECK(VAR_0->kscrexist & (1 << VAR_3));
tcg_gen_st_tl(VAR_1, cpu_env,
offsetof(CPUMIPSState, CP0_KScratch[VAR_3-2]));
VAR_4 = "KScratch";
default:
goto cp0_unimplemented;
}
VAR_0->bstate = BS_STOP;
default:
goto cp0_unimplemented;
}
trace_mips_translate_c0("dmtc0", VAR_4, VAR_2, VAR_3);
if (VAR_0->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
VAR_0->bstate = BS_STOP;
}
return;
cp0_unimplemented:
qemu_log_mask(LOG_UNIMP, "dmtc0 %s (VAR_2 %d VAR_3 %d)\n", VAR_4, VAR_2, VAR_3);
} | [
"static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1, int VAR_2, int VAR_3)\n{",
"const char *VAR_4 = \"invalid\";",
"if (VAR_3 != 0)\ncheck_insn(VAR_0, ISA_MIPS64);",
"if (VAR_0->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_start();",
"}",
"switch (VAR_2) {",
"case 0:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_index(cpu_env, VAR_1);",
"VAR_4 = \"Index\";",
"case 1:\nCP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_mvpcontrol(cpu_env, VAR_1);",
"VAR_4 = \"MVPControl\";",
"CP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"VAR_4 = \"MVPConf0\";",
"CP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"VAR_4 = \"MVPConf1\";",
"CP0_CHECK(VAR_0->vp);",
"VAR_4 = \"VPControl\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 1:\nswitch (VAR_3) {",
"case 0:\nVAR_4 = \"Random\";",
"case 1:\nCP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_vpecontrol(cpu_env, VAR_1);",
"VAR_4 = \"VPEControl\";",
"CP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_vpeconf0(cpu_env, VAR_1);",
"VAR_4 = \"VPEConf0\";",
"CP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_vpeconf1(cpu_env, VAR_1);",
"VAR_4 = \"VPEConf1\";",
"CP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_yqmask(cpu_env, VAR_1);",
"VAR_4 = \"YQMask\";",
"case 5:\nCP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"tcg_gen_st_tl(VAR_1, cpu_env, offsetof(CPUMIPSState, CP0_VPESchedule));",
"VAR_4 = \"VPESchedule\";",
"case 6:\nCP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"tcg_gen_st_tl(VAR_1, cpu_env, offsetof(CPUMIPSState, CP0_VPEScheFBack));",
"VAR_4 = \"VPEScheFBack\";",
"case 7:\nCP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_vpeopt(cpu_env, VAR_1);",
"VAR_4 = \"VPEOpt\";",
"default:\ngoto cp0_unimplemented;",
"}",
"switch (VAR_3) {",
"case 0:\ngen_helper_dmtc0_entrylo0(cpu_env, VAR_1);",
"VAR_4 = \"EntryLo0\";",
"case 1:\nCP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_tcstatus(cpu_env, VAR_1);",
"VAR_4 = \"TCStatus\";",
"CP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_tcbind(cpu_env, VAR_1);",
"VAR_4 = \"TCBind\";",
"CP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_tcrestart(cpu_env, VAR_1);",
"VAR_4 = \"TCRestart\";",
"CP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_tchalt(cpu_env, VAR_1);",
"VAR_4 = \"TCHalt\";",
"case 5:\nCP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_tccontext(cpu_env, VAR_1);",
"VAR_4 = \"TCContext\";",
"case 6:\nCP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_tcschedule(cpu_env, VAR_1);",
"VAR_4 = \"TCSchedule\";",
"case 7:\nCP0_CHECK(VAR_0->insn_flags & ASE_MT);",
"gen_helper_mtc0_tcschefback(cpu_env, VAR_1);",
"VAR_4 = \"TCScheFBack\";",
"default:\ngoto cp0_unimplemented;",
"}",
"switch (VAR_3) {",
"case 0:\ngen_helper_dmtc0_entrylo1(cpu_env, VAR_1);",
"VAR_4 = \"EntryLo1\";",
"case 1:\nCP0_CHECK(VAR_0->vp);",
"VAR_4 = \"GlobalNumber\";",
"default:\ngoto cp0_unimplemented;",
"}",
"switch (VAR_3) {",
"case 0:\ngen_helper_mtc0_context(cpu_env, VAR_1);",
"VAR_4 = \"Context\";",
"case 1:\nVAR_4 = \"ContextConfig\";",
"goto cp0_unimplemented;",
"CP0_CHECK(VAR_0->ulri);",
"tcg_gen_st_tl(VAR_1, cpu_env,\noffsetof(CPUMIPSState, active_tc.CP0_UserLocal));",
"VAR_4 = \"UserLocal\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 5:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_pagemask(cpu_env, VAR_1);",
"VAR_4 = \"PageMask\";",
"case 1:\ncheck_insn(VAR_0, ISA_MIPS32R2);",
"gen_helper_mtc0_pagegrain(cpu_env, VAR_1);",
"VAR_4 = \"PageGrain\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 6:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_wired(cpu_env, VAR_1);",
"VAR_4 = \"Wired\";",
"case 1:\ncheck_insn(VAR_0, ISA_MIPS32R2);",
"gen_helper_mtc0_srsconf0(cpu_env, VAR_1);",
"VAR_4 = \"SRSConf0\";",
"check_insn(VAR_0, ISA_MIPS32R2);",
"gen_helper_mtc0_srsconf1(cpu_env, VAR_1);",
"VAR_4 = \"SRSConf1\";",
"check_insn(VAR_0, ISA_MIPS32R2);",
"gen_helper_mtc0_srsconf2(cpu_env, VAR_1);",
"VAR_4 = \"SRSConf2\";",
"check_insn(VAR_0, ISA_MIPS32R2);",
"gen_helper_mtc0_srsconf3(cpu_env, VAR_1);",
"VAR_4 = \"SRSConf3\";",
"case 5:\ncheck_insn(VAR_0, ISA_MIPS32R2);",
"gen_helper_mtc0_srsconf4(cpu_env, VAR_1);",
"VAR_4 = \"SRSConf4\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 7:\nswitch (VAR_3) {",
"case 0:\ncheck_insn(VAR_0, ISA_MIPS32R2);",
"gen_helper_mtc0_hwrena(cpu_env, VAR_1);",
"VAR_0->bstate = BS_STOP;",
"VAR_4 = \"HWREna\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 8:\nswitch (VAR_3) {",
"case 0:\nVAR_4 = \"BadVAddr\";",
"case 1:\nVAR_4 = \"BadInstr\";",
"VAR_4 = \"BadInstrP\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 9:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_count(cpu_env, VAR_1);",
"VAR_4 = \"Count\";",
"default:\ngoto cp0_unimplemented;",
"}",
"VAR_0->bstate = BS_STOP;",
"case 10:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_entryhi(cpu_env, VAR_1);",
"VAR_4 = \"EntryHi\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 11:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_compare(cpu_env, VAR_1);",
"VAR_4 = \"Compare\";",
"default:\ngoto cp0_unimplemented;",
"}",
"VAR_0->bstate = BS_STOP;",
"case 12:\nswitch (VAR_3) {",
"case 0:\nsave_cpu_state(VAR_0, 1);",
"gen_helper_mtc0_status(cpu_env, VAR_1);",
"gen_save_pc(VAR_0->pc + 4);",
"VAR_0->bstate = BS_EXCP;",
"VAR_4 = \"Status\";",
"case 1:\ncheck_insn(VAR_0, ISA_MIPS32R2);",
"gen_helper_mtc0_intctl(cpu_env, VAR_1);",
"VAR_0->bstate = BS_STOP;",
"VAR_4 = \"IntCtl\";",
"check_insn(VAR_0, ISA_MIPS32R2);",
"gen_helper_mtc0_srsctl(cpu_env, VAR_1);",
"VAR_0->bstate = BS_STOP;",
"VAR_4 = \"SRSCtl\";",
"check_insn(VAR_0, ISA_MIPS32R2);",
"gen_mtc0_store32(VAR_1, offsetof(CPUMIPSState, CP0_SRSMap));",
"VAR_0->bstate = BS_STOP;",
"VAR_4 = \"SRSMap\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 13:\nswitch (VAR_3) {",
"case 0:\nsave_cpu_state(VAR_0, 1);",
"if (VAR_0->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_start();",
"}",
"gen_helper_mtc0_cause(cpu_env, VAR_1);",
"if (VAR_0->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_end();",
"}",
"VAR_0->bstate = BS_STOP;",
"VAR_4 = \"Cause\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 14:\nswitch (VAR_3) {",
"case 0:\ntcg_gen_st_tl(VAR_1, cpu_env, offsetof(CPUMIPSState, CP0_EPC));",
"VAR_4 = \"EPC\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 15:\nswitch (VAR_3) {",
"case 0:\nVAR_4 = \"PRid\";",
"case 1:\ncheck_insn(VAR_0, ISA_MIPS32R2);",
"gen_helper_mtc0_ebase(cpu_env, VAR_1);",
"VAR_4 = \"EBase\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 16:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_config0(cpu_env, VAR_1);",
"VAR_4 = \"Config\";",
"VAR_0->bstate = BS_STOP;",
"case 1:\nVAR_4 = \"Config1\";",
"gen_helper_mtc0_config2(cpu_env, VAR_1);",
"VAR_4 = \"Config2\";",
"VAR_0->bstate = BS_STOP;",
"gen_helper_mtc0_config3(cpu_env, VAR_1);",
"VAR_4 = \"Config3\";",
"VAR_0->bstate = BS_STOP;",
"VAR_4 = \"Config4\";",
"case 5:\ngen_helper_mtc0_config5(cpu_env, VAR_1);",
"VAR_4 = \"Config5\";",
"VAR_0->bstate = BS_STOP;",
"default:\nVAR_4 = \"Invalid config selector\";",
"goto cp0_unimplemented;",
"}",
"case 17:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_lladdr(cpu_env, VAR_1);",
"VAR_4 = \"LLAddr\";",
"case 1:\nCP0_CHECK(VAR_0->mrp);",
"gen_helper_mtc0_maar(cpu_env, VAR_1);",
"VAR_4 = \"MAAR\";",
"CP0_CHECK(VAR_0->mrp);",
"gen_helper_mtc0_maari(cpu_env, VAR_1);",
"VAR_4 = \"MAARI\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 18:\nswitch (VAR_3) {",
"case 0 ... 7:\ngen_helper_0e1i(mtc0_watchlo, VAR_1, VAR_3);",
"VAR_4 = \"WatchLo\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 19:\nswitch (VAR_3) {",
"case 0 ... 7:\ngen_helper_0e1i(mtc0_watchhi, VAR_1, VAR_3);",
"VAR_4 = \"WatchHi\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 20:\nswitch (VAR_3) {",
"case 0:\ncheck_insn(VAR_0, ISA_MIPS3);",
"gen_helper_mtc0_xcontext(cpu_env, VAR_1);",
"VAR_4 = \"XContext\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 21:\nCP0_CHECK(!(VAR_0->insn_flags & ISA_MIPS32R6));",
"switch (VAR_3) {",
"case 0:\ngen_helper_mtc0_framemask(cpu_env, VAR_1);",
"VAR_4 = \"Framemask\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 22:\nVAR_4 = \"Diagnostic\";",
"case 23:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_debug(cpu_env, VAR_1);",
"gen_save_pc(VAR_0->pc + 4);",
"VAR_0->bstate = BS_EXCP;",
"VAR_4 = \"Debug\";",
"case 1:\nVAR_0->bstate = BS_STOP;",
"VAR_4 = \"TraceControl\";",
"goto cp0_unimplemented;",
"VAR_0->bstate = BS_STOP;",
"VAR_4 = \"TraceControl2\";",
"goto cp0_unimplemented;",
"VAR_0->bstate = BS_STOP;",
"VAR_4 = \"UserTraceData\";",
"goto cp0_unimplemented;",
"VAR_0->bstate = BS_STOP;",
"VAR_4 = \"TraceBPC\";",
"goto cp0_unimplemented;",
"default:\ngoto cp0_unimplemented;",
"}",
"case 24:\nswitch (VAR_3) {",
"case 0:\ntcg_gen_st_tl(VAR_1, cpu_env, offsetof(CPUMIPSState, CP0_DEPC));",
"VAR_4 = \"DEPC\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 25:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_performance0(cpu_env, VAR_1);",
"VAR_4 = \"Performance0\";",
"case 1:\nVAR_4 = \"Performance1\";",
"goto cp0_unimplemented;",
"VAR_4 = \"Performance2\";",
"goto cp0_unimplemented;",
"VAR_4 = \"Performance3\";",
"goto cp0_unimplemented;",
"VAR_4 = \"Performance4\";",
"goto cp0_unimplemented;",
"case 5:\nVAR_4 = \"Performance5\";",
"goto cp0_unimplemented;",
"case 6:\nVAR_4 = \"Performance6\";",
"goto cp0_unimplemented;",
"case 7:\nVAR_4 = \"Performance7\";",
"goto cp0_unimplemented;",
"default:\ngoto cp0_unimplemented;",
"}",
"case 26:\nswitch (VAR_3) {",
"case 0:\ngen_helper_mtc0_errctl(cpu_env, VAR_1);",
"VAR_0->bstate = BS_STOP;",
"VAR_4 = \"ErrCtl\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 27:\nswitch (VAR_3) {",
"case 0 ... 3:\nVAR_4 = \"CacheErr\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 28:\nswitch (VAR_3) {",
"case 0:\ncase 6:\ngen_helper_mtc0_taglo(cpu_env, VAR_1);",
"VAR_4 = \"TagLo\";",
"case 1:\ncase 5:\ncase 7:\ngen_helper_mtc0_datalo(cpu_env, VAR_1);",
"VAR_4 = \"DataLo\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 29:\nswitch (VAR_3) {",
"case 0:\ncase 6:\ngen_helper_mtc0_taghi(cpu_env, VAR_1);",
"VAR_4 = \"TagHi\";",
"case 1:\ncase 5:\ncase 7:\ngen_helper_mtc0_datahi(cpu_env, VAR_1);",
"VAR_4 = \"DataHi\";",
"default:\nVAR_4 = \"invalid VAR_3\";",
"goto cp0_unimplemented;",
"}",
"case 30:\nswitch (VAR_3) {",
"case 0:\ntcg_gen_st_tl(VAR_1, cpu_env, offsetof(CPUMIPSState, CP0_ErrorEPC));",
"VAR_4 = \"ErrorEPC\";",
"default:\ngoto cp0_unimplemented;",
"}",
"case 31:\nswitch (VAR_3) {",
"case 0:\ngen_mtc0_store32(VAR_1, offsetof(CPUMIPSState, CP0_DESAVE));",
"VAR_4 = \"DESAVE\";",
"case 2 ... 7:\nCP0_CHECK(VAR_0->kscrexist & (1 << VAR_3));",
"tcg_gen_st_tl(VAR_1, cpu_env,\noffsetof(CPUMIPSState, CP0_KScratch[VAR_3-2]));",
"VAR_4 = \"KScratch\";",
"default:\ngoto cp0_unimplemented;",
"}",
"VAR_0->bstate = BS_STOP;",
"default:\ngoto cp0_unimplemented;",
"}",
"trace_mips_translate_c0(\"dmtc0\", VAR_4, VAR_2, VAR_3);",
"if (VAR_0->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_end();",
"VAR_0->bstate = BS_STOP;",
"}",
"return;",
"cp0_unimplemented:\nqemu_log_mask(LOG_UNIMP, \"dmtc0 %s (VAR_2 %d VAR_3 %d)\\n\", VAR_4, VAR_2, 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29,
31
],
[
33
],
[
36,
38
],
[
40
],
[
42
],
[
46
],
[
50
],
[
54
],
[
58
],
[
62
],
[
66
],
[
69,
71
],
[
73
],
[
76,
78
],
[
80,
84
],
[
87,
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
120,
122
],
[
124
],
[
126
],
[
129,
131
],
[
133
],
[
135
],
[
138,
140
],
[
142
],
[
144
],
[
147,
149
],
[
151
],
[
155
],
[
157,
159
],
[
161
],
[
164,
166
],
[
168
],
[
170
],
[
174
],
[
176
],
[
178
],
[
182
],
[
184
],
[
186
],
[
190
],
[
192
],
[
194
],
[
197,
199
],
[
201
],
[
203
],
[
206,
208
],
[
210
],
[
212
],
[
215,
217
],
[
219
],
[
221
],
[
224,
226
],
[
228
],
[
232
],
[
234,
236
],
[
238
],
[
241,
243
],
[
247
],
[
250,
252
],
[
254
],
[
258
],
[
260,
262
],
[
264
],
[
267,
271
],
[
273
],
[
276
],
[
278,
280
],
[
282
],
[
285,
287
],
[
289
],
[
292,
294
],
[
296,
298
],
[
300
],
[
303,
305
],
[
307
],
[
309
],
[
327,
329
],
[
331
],
[
334,
336
],
[
338,
340
],
[
342
],
[
345,
347
],
[
349
],
[
351
],
[
355
],
[
357
],
[
359
],
[
363
],
[
365
],
[
367
],
[
371
],
[
373
],
[
375
],
[
378,
380
],
[
382
],
[
384
],
[
387,
389
],
[
391
],
[
394,
396
],
[
398,
400
],
[
402
],
[
404
],
[
406
],
[
409,
411
],
[
413
],
[
416,
418
],
[
420,
424
],
[
427,
431
],
[
437
],
[
440,
442
],
[
444
],
[
447,
449
],
[
451,
453
],
[
455
],
[
460,
462
],
[
464
],
[
468
],
[
471,
473
],
[
475,
477
],
[
479
],
[
482,
484
],
[
486
],
[
489,
491
],
[
493,
495
],
[
497
],
[
502,
504
],
[
506
],
[
510
],
[
513,
515
],
[
517,
519
],
[
521
],
[
525
],
[
527
],
[
529
],
[
532,
534
],
[
536
],
[
540
],
[
542
],
[
546
],
[
548
],
[
552
],
[
554
],
[
558
],
[
560
],
[
564
],
[
566
],
[
569,
571
],
[
573
],
[
576,
578
],
[
580,
582
],
[
588
],
[
590
],
[
592
],
[
594
],
[
596
],
[
598
],
[
600
],
[
604
],
[
606
],
[
609,
611
],
[
613
],
[
616,
618
],
[
620,
622
],
[
624
],
[
627,
629
],
[
631
],
[
634,
636
],
[
638,
642
],
[
645,
647
],
[
649
],
[
651
],
[
654,
656
],
[
658
],
[
661,
663
],
[
665,
667
],
[
669
],
[
673
],
[
676,
680
],
[
684
],
[
686
],
[
690
],
[
694
],
[
696
],
[
700
],
[
706
],
[
709,
711
],
[
713
],
[
717
],
[
722,
724
],
[
726
],
[
728
],
[
731,
733
],
[
735,
737
],
[
739
],
[
742,
744
],
[
746
],
[
748
],
[
752
],
[
754
],
[
756
],
[
759,
761
],
[
763
],
[
766,
768
],
[
770,
772
],
[
774
],
[
777,
779
],
[
781
],
[
784,
786
],
[
788,
790
],
[
792
],
[
795,
797
],
[
799
],
[
802,
804
],
[
806,
808
],
[
810
],
[
812
],
[
815,
817
],
[
819
],
[
822,
826
],
[
828
],
[
830,
832
],
[
834
],
[
837,
839
],
[
841
],
[
844,
848
],
[
851,
853
],
[
855,
857
],
[
861
],
[
863
],
[
865
],
[
868,
874
],
[
876
],
[
878
],
[
885
],
[
887
],
[
889
],
[
896
],
[
898
],
[
900
],
[
907
],
[
909
],
[
911
],
[
913,
915
],
[
917
],
[
920,
922
],
[
924,
928
],
[
930
],
[
933,
935
],
[
937
],
[
940,
942
],
[
944,
946
],
[
948
],
[
951,
955
],
[
957
],
[
962
],
[
964
],
[
969
],
[
971
],
[
976
],
[
978
],
[
980,
984
],
[
986
],
[
988,
992
],
[
994
],
[
996,
1000
],
[
1002
],
[
1004,
1006
],
[
1008
],
[
1011,
1013
],
[
1015,
1017
],
[
1019
],
[
1021
],
[
1024,
1026
],
[
1028
],
[
1031,
1033
],
[
1035,
1039
],
[
1042,
1044
],
[
1046
],
[
1049,
1051
],
[
1053,
1057,
1059
],
[
1061
],
[
1064,
1067,
1069,
1071
],
[
1073
],
[
1076,
1078
],
[
1080
],
[
1083,
1085
],
[
1087,
1091,
1093
],
[
1095
],
[
1098,
1101,
1103,
1105
],
[
1107
],
[
1110,
1112
],
[
1114
],
[
1116
],
[
1119,
1121
],
[
1123,
1125
],
[
1127
],
[
1130,
1132
],
[
1134
],
[
1137,
1139
],
[
1141,
1145
],
[
1147
],
[
1150,
1152
],
[
1154,
1156
],
[
1158
],
[
1161,
1163
],
[
1165
],
[
1169
],
[
1172,
1174
],
[
1176
],
[
1178
],
[
1184
],
[
1186
],
[
1188
],
[
1190
],
[
1192
],
[
1196,
1198
],
[
1200
]
] |
19,444 | uint64_t HELPER(neon_sub_saturate_s64)(uint64_t src1, uint64_t src2)
{
uint64_t res;
res = src1 - src2;
if (((res ^ src1) & SIGNBIT64) && ((src1 ^ src2) & SIGNBIT64)) {
env->QF = 1;
res = ((int64_t)src1 >> 63) ^ ~SIGNBIT64;
}
return res;
}
| true | qemu | 72902672dc2ed6281cdb205259c1d52ecf01f6b2 | uint64_t HELPER(neon_sub_saturate_s64)(uint64_t src1, uint64_t src2)
{
uint64_t res;
res = src1 - src2;
if (((res ^ src1) & SIGNBIT64) && ((src1 ^ src2) & SIGNBIT64)) {
env->QF = 1;
res = ((int64_t)src1 >> 63) ^ ~SIGNBIT64;
}
return res;
}
| {
"code": [
" uint64_t res;",
" env->QF = 1;",
" res = ((int64_t)src1 >> 63) ^ ~SIGNBIT64;",
" return res;",
" uint64_t res;",
" env->QF = 1;",
" return res;",
"uint64_t HELPER(neon_sub_saturate_s64)(uint64_t src1, uint64_t src2)",
" uint64_t res;",
" res = src1 - src2;",
" if (((res ^ src1) & SIGNBIT64) && ((src1 ^ src2) & SIGNBIT64)) {",
" env->QF = 1;",
" res = ((int64_t)src1 >> 63) ^ ~SIGNBIT64;",
" return res;",
" uint64_t res;",
" env->QF = 1;",
" return res;"
],
"line_no": [
5,
13,
15,
19,
5,
13,
19,
1,
5,
9,
11,
13,
15,
19,
5,
13,
19
]
} | uint64_t FUNC_0(neon_sub_saturate_s64)(uint64_t src1, uint64_t src2)
{
uint64_t res;
res = src1 - src2;
if (((res ^ src1) & SIGNBIT64) && ((src1 ^ src2) & SIGNBIT64)) {
env->QF = 1;
res = ((int64_t)src1 >> 63) ^ ~SIGNBIT64;
}
return res;
}
| [
"uint64_t FUNC_0(neon_sub_saturate_s64)(uint64_t src1, uint64_t src2)\n{",
"uint64_t res;",
"res = src1 - src2;",
"if (((res ^ src1) & SIGNBIT64) && ((src1 ^ src2) & SIGNBIT64)) {",
"env->QF = 1;",
"res = ((int64_t)src1 >> 63) ^ ~SIGNBIT64;",
"}",
"return res;",
"}"
] | [
1,
1,
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
19,445 | static int coroutine_fn copy_sectors(BlockDriverState *bs,
uint64_t start_sect,
uint64_t cluster_offset,
int n_start, int n_end)
{
BDRVQcowState *s = bs->opaque;
QEMUIOVector qiov;
struct iovec iov;
int n, ret;
/*
* If this is the last cluster and it is only partially used, we must only
* copy until the end of the image, or bdrv_check_request will fail for the
* bdrv_read/write calls below.
*/
if (start_sect + n_end > bs->total_sectors) {
n_end = bs->total_sectors - start_sect;
n = n_end - n_start;
if (n <= 0) {
return 0;
iov.iov_len = n * BDRV_SECTOR_SIZE;
iov.iov_base = qemu_blockalign(bs, iov.iov_len);
qemu_iovec_init_external(&qiov, &iov, 1);
BLKDBG_EVENT(bs->file, BLKDBG_COW_READ);
/* Call .bdrv_co_readv() directly instead of using the public block-layer
* interface. This avoids double I/O throttling and request tracking,
* which can lead to deadlock when block layer copy-on-read is enabled.
*/
ret = bs->drv->bdrv_co_readv(bs, start_sect + n_start, n, &qiov);
if (ret < 0) {
goto out;
if (s->crypt_method) {
qcow2_encrypt_sectors(s, start_sect + n_start,
iov.iov_base, iov.iov_base, n, 1,
&s->aes_encrypt_key);
ret = qcow2_pre_write_overlap_check(bs, 0,
cluster_offset + n_start * BDRV_SECTOR_SIZE, n * BDRV_SECTOR_SIZE);
if (ret < 0) {
goto out;
BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE);
ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + n_start, n, &qiov);
if (ret < 0) {
goto out;
ret = 0;
out:
qemu_vfree(iov.iov_base);
return ret; | true | qemu | dba2855572c746836ad90ce9154403b5929d996b | static int coroutine_fn copy_sectors(BlockDriverState *bs,
uint64_t start_sect,
uint64_t cluster_offset,
int n_start, int n_end)
{
BDRVQcowState *s = bs->opaque;
QEMUIOVector qiov;
struct iovec iov;
int n, ret;
if (start_sect + n_end > bs->total_sectors) {
n_end = bs->total_sectors - start_sect;
n = n_end - n_start;
if (n <= 0) {
return 0;
iov.iov_len = n * BDRV_SECTOR_SIZE;
iov.iov_base = qemu_blockalign(bs, iov.iov_len);
qemu_iovec_init_external(&qiov, &iov, 1);
BLKDBG_EVENT(bs->file, BLKDBG_COW_READ);
ret = bs->drv->bdrv_co_readv(bs, start_sect + n_start, n, &qiov);
if (ret < 0) {
goto out;
if (s->crypt_method) {
qcow2_encrypt_sectors(s, start_sect + n_start,
iov.iov_base, iov.iov_base, n, 1,
&s->aes_encrypt_key);
ret = qcow2_pre_write_overlap_check(bs, 0,
cluster_offset + n_start * BDRV_SECTOR_SIZE, n * BDRV_SECTOR_SIZE);
if (ret < 0) {
goto out;
BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE);
ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + n_start, n, &qiov);
if (ret < 0) {
goto out;
ret = 0;
out:
qemu_vfree(iov.iov_base);
return ret; | {
"code": [],
"line_no": []
} | static int VAR_0 copy_sectors(BlockDriverState *bs,
uint64_t start_sect,
uint64_t cluster_offset,
int n_start, int n_end)
{
BDRVQcowState *s = bs->opaque;
QEMUIOVector qiov;
struct iovec iov;
int n, ret;
if (start_sect + n_end > bs->total_sectors) {
n_end = bs->total_sectors - start_sect;
n = n_end - n_start;
if (n <= 0) {
return 0;
iov.iov_len = n * BDRV_SECTOR_SIZE;
iov.iov_base = qemu_blockalign(bs, iov.iov_len);
qemu_iovec_init_external(&qiov, &iov, 1);
BLKDBG_EVENT(bs->file, BLKDBG_COW_READ);
ret = bs->drv->bdrv_co_readv(bs, start_sect + n_start, n, &qiov);
if (ret < 0) {
goto out;
if (s->crypt_method) {
qcow2_encrypt_sectors(s, start_sect + n_start,
iov.iov_base, iov.iov_base, n, 1,
&s->aes_encrypt_key);
ret = qcow2_pre_write_overlap_check(bs, 0,
cluster_offset + n_start * BDRV_SECTOR_SIZE, n * BDRV_SECTOR_SIZE);
if (ret < 0) {
goto out;
BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE);
ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + n_start, n, &qiov);
if (ret < 0) {
goto out;
ret = 0;
out:
qemu_vfree(iov.iov_base);
return ret; | [
"static int VAR_0 copy_sectors(BlockDriverState *bs,\nuint64_t start_sect,\nuint64_t cluster_offset,\nint n_start, int n_end)\n{",
"BDRVQcowState *s = bs->opaque;",
"QEMUIOVector qiov;",
"struct iovec iov;",
"int n, ret;",
"if (start_sect + n_end > bs->total_sectors) {",
"n_end = bs->total_sectors - start_sect;",
"n = n_end - n_start;",
"if (n <= 0) {",
"return 0;",
"iov.iov_len = n * BDRV_SECTOR_SIZE;",
"iov.iov_base = qemu_blockalign(bs, iov.iov_len);",
"qemu_iovec_init_external(&qiov, &iov, 1);",
"BLKDBG_EVENT(bs->file, BLKDBG_COW_READ);",
"ret = bs->drv->bdrv_co_readv(bs, start_sect + n_start, n, &qiov);",
"if (ret < 0) {",
"goto out;",
"if (s->crypt_method) {",
"qcow2_encrypt_sectors(s, start_sect + n_start,\niov.iov_base, iov.iov_base, n, 1,\n&s->aes_encrypt_key);",
"ret = qcow2_pre_write_overlap_check(bs, 0,\ncluster_offset + n_start * BDRV_SECTOR_SIZE, n * BDRV_SECTOR_SIZE);",
"if (ret < 0) {",
"goto out;",
"BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE);",
"ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + n_start, n, &qiov);",
"if (ret < 0) {",
"goto out;",
"ret = 0;",
"out:\nqemu_vfree(iov.iov_base);",
"return ret;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3,
4,
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32,
33,
34
],
[
35,
36
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41
],
[
42
],
[
43
],
[
44,
45
],
[
46
]
] |
19,446 | static void FUNCC(pred16x16_vertical_add)(uint8_t *pix, const int *block_offset,
const int16_t *block,
ptrdiff_t stride)
{
int i;
for(i=0; i<16; i++)
FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
}
| false | FFmpeg | 1acd7d594c15aa491729c837ad3519d3469e620a | static void FUNCC(pred16x16_vertical_add)(uint8_t *pix, const int *block_offset,
const int16_t *block,
ptrdiff_t stride)
{
int i;
for(i=0; i<16; i++)
FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(pred16x16_vertical_add)(uint8_t *pix, const int *block_offset,
const int16_t *block,
ptrdiff_t stride)
{
int VAR_0;
for(VAR_0=0; VAR_0<16; VAR_0++)
FUNC_0(pred4x4_vertical_add)(pix + block_offset[VAR_0], block + VAR_0*16*sizeof(pixel), stride);
}
| [
"static void FUNC_0(pred16x16_vertical_add)(uint8_t *pix, const int *block_offset,\nconst int16_t *block,\nptrdiff_t stride)\n{",
"int VAR_0;",
"for(VAR_0=0; VAR_0<16; VAR_0++)",
"FUNC_0(pred4x4_vertical_add)(pix + block_offset[VAR_0], block + VAR_0*16*sizeof(pixel), stride);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
19,447 | static int ac3_parse_audio_block(AC3DecodeContext * ctx, int index)
{
ac3_audio_block *ab = &ctx->audio_block;
int nfchans = ctx->bsi.nfchans;
int acmod = ctx->bsi.acmod;
int i, bnd, rbnd, grp, seg;
GetBitContext *gb = &ctx->gb;
uint32_t *flags = &ab->flags;
int bit_alloc_flags = 0;
float drange;
*flags = 0;
ab->blksw = 0;
for (i = 0; i < 5; i++)
ab->chcoeffs[i] = 1.0;
for (i = 0; i < nfchans; i++) /*block switch flag */
ab->blksw |= get_bits(gb, 1) << i;
ab->dithflag = 0;
for (i = 0; i < nfchans; i++) /* dithering flag */
ab->dithflag |= get_bits(gb, 1) << i;
if (get_bits(gb, 1)) { /* dynamic range */
*flags |= AC3_AB_DYNRNGE;
ab->dynrng = get_bits(gb, 8);
drange = ((((ab->dynrng & 0x1f) | 0x20) << 13) * scale_factors[3 - (ab->dynrng >> 5)]);
for (i = 0; i < nfchans; i++)
ab->chcoeffs[i] *= drange;
}
if (acmod == 0x00) { /* dynamic range 1+1 mode */
if (get_bits(gb, 1)) {
*flags |= AC3_AB_DYNRNG2E;
ab->dynrng2 = get_bits(gb, 8);
drange = ((((ab->dynrng2 & 0x1f) | 0x20) << 13) * scale_factors[3 - (ab->dynrng2 >> 5)]);
ab->chcoeffs[1] *= drange;
}
}
get_downmix_coeffs(ctx);
ab->chincpl = 0;
if (get_bits(gb, 1)) { /* coupling strategy */
*flags |= AC3_AB_CPLSTRE;
ab->cplbndstrc = 0;
if (get_bits(gb, 1)) { /* coupling in use */
*flags |= AC3_AB_CPLINU;
for (i = 0; i < nfchans; i++)
ab->chincpl |= get_bits(gb, 1) << i;
if (acmod == 0x02)
if (get_bits(gb, 1)) /* phase flag in use */
*flags |= AC3_AB_PHSFLGINU;
ab->cplbegf = get_bits(gb, 4);
ab->cplendf = get_bits(gb, 4);
assert((ab->ncplsubnd = 3 + ab->cplendf - ab->cplbegf) > 0);
ab->ncplbnd = ab->ncplsubnd;
for (i = 0; i < ab->ncplsubnd - 1; i++) /* coupling band structure */
if (get_bits(gb, 1)) {
ab->cplbndstrc |= 1 << i;
ab->ncplbnd--;
}
}
}
if (*flags & AC3_AB_CPLINU) {
ab->cplcoe = 0;
for (i = 0; i < nfchans; i++)
if (ab->chincpl & (1 << i))
if (get_bits(gb, 1)) { /* coupling co-ordinates */
ab->cplcoe |= 1 << i;
ab->mstrcplco[i] = get_bits(gb, 2);
for (bnd = 0; bnd < ab->ncplbnd; bnd++) {
ab->cplcoexp[i][bnd] = get_bits(gb, 4);
ab->cplcomant[i][bnd] = get_bits(gb, 4);
}
}
}
ab->phsflg = 0;
if ((acmod == 0x02) && (*flags & AC3_AB_PHSFLGINU) && (ab->cplcoe & 1 || ab->cplcoe & (1 << 1))) {
for (bnd = 0; bnd < ab->ncplbnd; bnd++)
if (get_bits(gb, 1))
ab->phsflg |= 1 << bnd;
}
generate_coupling_coordinates(ctx);
ab->rematflg = 0;
if (acmod == 0x02) /* rematrixing */
if (get_bits(gb, 1)) {
*flags |= AC3_AB_REMATSTR;
if (ab->cplbegf > 2 || !(*flags & AC3_AB_CPLINU))
for (rbnd = 0; rbnd < 4; rbnd++)
ab->rematflg |= get_bits(gb, 1) << bnd;
else if (ab->cplbegf > 0 && ab->cplbegf <= 2 && *flags & AC3_AB_CPLINU)
for (rbnd = 0; rbnd < 3; rbnd++)
ab->rematflg |= get_bits(gb, 1) << bnd;
else if (!(ab->cplbegf) && *flags & AC3_AB_CPLINU)
for (rbnd = 0; rbnd < 2; rbnd++)
ab->rematflg |= get_bits(gb, 1) << bnd;
}
if (*flags & AC3_AB_CPLINU) /* coupling exponent strategy */
ab->cplexpstr = get_bits(gb, 2);
for (i = 0; i < nfchans; i++) /* channel exponent strategy */
ab->chexpstr[i] = get_bits(gb, 2);
if (ctx->bsi.flags & AC3_BSI_LFEON) /* lfe exponent strategy */
ab->lfeexpstr = get_bits(gb, 1);
for (i = 0; i < nfchans; i++) /* channel bandwidth code */
if (ab->chexpstr[i] != AC3_EXPSTR_REUSE)
if (!(ab->chincpl & (1 << i))) {
ab->chbwcod[i] = get_bits(gb, 6);
assert (ab->chbwcod[i] <= 60);
}
if (*flags & AC3_AB_CPLINU)
if (ab->cplexpstr != AC3_EXPSTR_REUSE) {/* coupling exponents */
bit_alloc_flags |= 64;
ab->cplabsexp = get_bits(gb, 4) << 1;
ab->cplstrtmant = (ab->cplbegf * 12) + 37;
ab->cplendmant = ((ab->cplendmant + 3) * 12) + 37;
ab->ncplgrps = (ab->cplendmant - ab->cplstrtmant) / (3 << (ab->cplexpstr - 1));
for (grp = 0; grp < ab->ncplgrps; grp++)
ab->cplexps[grp] = get_bits(gb, 7);
}
for (i = 0; i < nfchans; i++) /* fbw channel exponents */
if (ab->chexpstr[i] != AC3_EXPSTR_REUSE) {
bit_alloc_flags |= 1 << i;
if (ab->chincpl & (1 << i))
ab->endmant[i] = (ab->cplbegf * 12) + 37;
else
ab->endmant[i] = ((ab->chbwcod[i] + 3) * 12) + 37;
ab->nchgrps[i] =
(ab->endmant[i] + (3 << (ab->chexpstr[i] - 1)) - 4) / (3 << (ab->chexpstr[i] - 1));
ab->exps[i][0] = ab->dexps[i][0] = get_bits(gb, 4);
for (grp = 1; grp <= ab->nchgrps[i]; grp++)
ab->exps[i][grp] = get_bits(gb, 7);
ab->gainrng[i] = get_bits(gb, 2);
}
if (ctx->bsi.flags & AC3_BSI_LFEON) /* lfe exponents */
if (ab->lfeexpstr != AC3_EXPSTR_REUSE) {
bit_alloc_flags |= 32;
ab->lfeexps[0] = ab->dlfeexps[0] = get_bits(gb, 4);
ab->lfeexps[1] = get_bits(gb, 7);
ab->lfeexps[2] = get_bits(gb, 7);
}
if (decode_exponents(ctx)) {/* decode the exponents for this block */
av_log(NULL, AV_LOG_ERROR, "Error parsing exponents\n");
return -1;
}
if (get_bits(gb, 1)) { /* bit allocation information */
*flags |= AC3_AB_BAIE;
bit_alloc_flags |= 127;
ab->sdcycod = get_bits(gb, 2);
ab->fdcycod = get_bits(gb, 2);
ab->sgaincod = get_bits(gb, 2);
ab->dbpbcod = get_bits(gb, 2);
ab->floorcod = get_bits(gb, 3);
}
if (get_bits(gb, 1)) { /* snroffset */
*flags |= AC3_AB_SNROFFSTE;
bit_alloc_flags |= 127;
ab->csnroffst = get_bits(gb, 6);
if (*flags & AC3_AB_CPLINU) { /* couling fine snr offset and fast gain code */
ab->cplfsnroffst = get_bits(gb, 4);
ab->cplfgaincod = get_bits(gb, 3);
}
for (i = 0; i < nfchans; i++) { /* channel fine snr offset and fast gain code */
ab->fsnroffst[i] = get_bits(gb, 4);
ab->fgaincod[i] = get_bits(gb, 3);
}
if (ctx->bsi.flags & AC3_BSI_LFEON) { /* lfe fine snr offset and fast gain code */
ab->lfefsnroffst = get_bits(gb, 4);
ab->lfefgaincod = get_bits(gb, 3);
}
}
if (*flags & AC3_AB_CPLINU)
if (get_bits(gb, 1)) { /* coupling leak information */
bit_alloc_flags |= 64;
*flags |= AC3_AB_CPLLEAKE;
ab->cplfleak = get_bits(gb, 3);
ab->cplsleak = get_bits(gb, 3);
}
if (get_bits(gb, 1)) { /* delta bit allocation information */
*flags |= AC3_AB_DELTBAIE;
bit_alloc_flags |= 127;
if (*flags & AC3_AB_CPLINU) {
ab->cpldeltbae = get_bits(gb, 2);
if (ab->cpldeltbae == AC3_DBASTR_RESERVED) {
av_log(NULL, AV_LOG_ERROR, "coupling delta bit allocation strategy reserved\n");
return -1;
}
}
for (i = 0; i < nfchans; i++) {
ab->deltbae[i] = get_bits(gb, 2);
if (ab->deltbae[i] == AC3_DBASTR_RESERVED) {
av_log(NULL, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
return -1;
}
}
if (*flags & AC3_AB_CPLINU)
if (ab->cpldeltbae == AC3_DBASTR_NEW) { /*coupling delta offset, len and bit allocation */
ab->cpldeltnseg = get_bits(gb, 3);
for (seg = 0; seg <= ab->cpldeltnseg; seg++) {
ab->cpldeltoffst[seg] = get_bits(gb, 5);
ab->cpldeltlen[seg] = get_bits(gb, 4);
ab->cpldeltba[seg] = get_bits(gb, 3);
}
}
for (i = 0; i < nfchans; i++)
if (ab->deltbae[i] == AC3_DBASTR_NEW) {/*channel delta offset, len and bit allocation */
ab->deltnseg[i] = get_bits(gb, 3);
for (seg = 0; seg <= ab->deltnseg[i]; seg++) {
ab->deltoffst[i][seg] = get_bits(gb, 5);
ab->deltlen[i][seg] = get_bits(gb, 4);
ab->deltba[i][seg] = get_bits(gb, 3);
}
}
}
if (do_bit_allocation (ctx, bit_alloc_flags)) /* perform the bit allocation */ {
av_log(NULL, AV_LOG_ERROR, "Error in bit allocation routine\n");
return -1;
}
if (get_bits(gb, 1)) { /* unused dummy data */
*flags |= AC3_AB_SKIPLE;
ab->skipl = get_bits(gb, 9);
while (ab->skipl) {
get_bits(gb, 8);
ab->skipl--;
}
}
/* unpack the transform coefficients
* * this also uncouples channels if coupling is in use.
*/
if (get_transform_coeffs(ctx)) {
av_log(NULL, AV_LOG_ERROR, "Error in routine get_transform_coeffs\n");
return -1;
}
/* recover coefficients if rematrixing is in use */
if (*flags & AC3_AB_REMATSTR)
do_rematrixing(ctx);
if (ctx->output != AC3_OUTPUT_UNMODIFIED)
do_downmix(ctx);
return 0;
}
| false | FFmpeg | 0058584580b87feb47898e60e4b80c7f425882ad | static int ac3_parse_audio_block(AC3DecodeContext * ctx, int index)
{
ac3_audio_block *ab = &ctx->audio_block;
int nfchans = ctx->bsi.nfchans;
int acmod = ctx->bsi.acmod;
int i, bnd, rbnd, grp, seg;
GetBitContext *gb = &ctx->gb;
uint32_t *flags = &ab->flags;
int bit_alloc_flags = 0;
float drange;
*flags = 0;
ab->blksw = 0;
for (i = 0; i < 5; i++)
ab->chcoeffs[i] = 1.0;
for (i = 0; i < nfchans; i++)
ab->blksw |= get_bits(gb, 1) << i;
ab->dithflag = 0;
for (i = 0; i < nfchans; i++)
ab->dithflag |= get_bits(gb, 1) << i;
if (get_bits(gb, 1)) {
*flags |= AC3_AB_DYNRNGE;
ab->dynrng = get_bits(gb, 8);
drange = ((((ab->dynrng & 0x1f) | 0x20) << 13) * scale_factors[3 - (ab->dynrng >> 5)]);
for (i = 0; i < nfchans; i++)
ab->chcoeffs[i] *= drange;
}
if (acmod == 0x00) {
if (get_bits(gb, 1)) {
*flags |= AC3_AB_DYNRNG2E;
ab->dynrng2 = get_bits(gb, 8);
drange = ((((ab->dynrng2 & 0x1f) | 0x20) << 13) * scale_factors[3 - (ab->dynrng2 >> 5)]);
ab->chcoeffs[1] *= drange;
}
}
get_downmix_coeffs(ctx);
ab->chincpl = 0;
if (get_bits(gb, 1)) {
*flags |= AC3_AB_CPLSTRE;
ab->cplbndstrc = 0;
if (get_bits(gb, 1)) {
*flags |= AC3_AB_CPLINU;
for (i = 0; i < nfchans; i++)
ab->chincpl |= get_bits(gb, 1) << i;
if (acmod == 0x02)
if (get_bits(gb, 1))
*flags |= AC3_AB_PHSFLGINU;
ab->cplbegf = get_bits(gb, 4);
ab->cplendf = get_bits(gb, 4);
assert((ab->ncplsubnd = 3 + ab->cplendf - ab->cplbegf) > 0);
ab->ncplbnd = ab->ncplsubnd;
for (i = 0; i < ab->ncplsubnd - 1; i++)
if (get_bits(gb, 1)) {
ab->cplbndstrc |= 1 << i;
ab->ncplbnd--;
}
}
}
if (*flags & AC3_AB_CPLINU) {
ab->cplcoe = 0;
for (i = 0; i < nfchans; i++)
if (ab->chincpl & (1 << i))
if (get_bits(gb, 1)) {
ab->cplcoe |= 1 << i;
ab->mstrcplco[i] = get_bits(gb, 2);
for (bnd = 0; bnd < ab->ncplbnd; bnd++) {
ab->cplcoexp[i][bnd] = get_bits(gb, 4);
ab->cplcomant[i][bnd] = get_bits(gb, 4);
}
}
}
ab->phsflg = 0;
if ((acmod == 0x02) && (*flags & AC3_AB_PHSFLGINU) && (ab->cplcoe & 1 || ab->cplcoe & (1 << 1))) {
for (bnd = 0; bnd < ab->ncplbnd; bnd++)
if (get_bits(gb, 1))
ab->phsflg |= 1 << bnd;
}
generate_coupling_coordinates(ctx);
ab->rematflg = 0;
if (acmod == 0x02)
if (get_bits(gb, 1)) {
*flags |= AC3_AB_REMATSTR;
if (ab->cplbegf > 2 || !(*flags & AC3_AB_CPLINU))
for (rbnd = 0; rbnd < 4; rbnd++)
ab->rematflg |= get_bits(gb, 1) << bnd;
else if (ab->cplbegf > 0 && ab->cplbegf <= 2 && *flags & AC3_AB_CPLINU)
for (rbnd = 0; rbnd < 3; rbnd++)
ab->rematflg |= get_bits(gb, 1) << bnd;
else if (!(ab->cplbegf) && *flags & AC3_AB_CPLINU)
for (rbnd = 0; rbnd < 2; rbnd++)
ab->rematflg |= get_bits(gb, 1) << bnd;
}
if (*flags & AC3_AB_CPLINU)
ab->cplexpstr = get_bits(gb, 2);
for (i = 0; i < nfchans; i++)
ab->chexpstr[i] = get_bits(gb, 2);
if (ctx->bsi.flags & AC3_BSI_LFEON)
ab->lfeexpstr = get_bits(gb, 1);
for (i = 0; i < nfchans; i++)
if (ab->chexpstr[i] != AC3_EXPSTR_REUSE)
if (!(ab->chincpl & (1 << i))) {
ab->chbwcod[i] = get_bits(gb, 6);
assert (ab->chbwcod[i] <= 60);
}
if (*flags & AC3_AB_CPLINU)
if (ab->cplexpstr != AC3_EXPSTR_REUSE) {
bit_alloc_flags |= 64;
ab->cplabsexp = get_bits(gb, 4) << 1;
ab->cplstrtmant = (ab->cplbegf * 12) + 37;
ab->cplendmant = ((ab->cplendmant + 3) * 12) + 37;
ab->ncplgrps = (ab->cplendmant - ab->cplstrtmant) / (3 << (ab->cplexpstr - 1));
for (grp = 0; grp < ab->ncplgrps; grp++)
ab->cplexps[grp] = get_bits(gb, 7);
}
for (i = 0; i < nfchans; i++)
if (ab->chexpstr[i] != AC3_EXPSTR_REUSE) {
bit_alloc_flags |= 1 << i;
if (ab->chincpl & (1 << i))
ab->endmant[i] = (ab->cplbegf * 12) + 37;
else
ab->endmant[i] = ((ab->chbwcod[i] + 3) * 12) + 37;
ab->nchgrps[i] =
(ab->endmant[i] + (3 << (ab->chexpstr[i] - 1)) - 4) / (3 << (ab->chexpstr[i] - 1));
ab->exps[i][0] = ab->dexps[i][0] = get_bits(gb, 4);
for (grp = 1; grp <= ab->nchgrps[i]; grp++)
ab->exps[i][grp] = get_bits(gb, 7);
ab->gainrng[i] = get_bits(gb, 2);
}
if (ctx->bsi.flags & AC3_BSI_LFEON)
if (ab->lfeexpstr != AC3_EXPSTR_REUSE) {
bit_alloc_flags |= 32;
ab->lfeexps[0] = ab->dlfeexps[0] = get_bits(gb, 4);
ab->lfeexps[1] = get_bits(gb, 7);
ab->lfeexps[2] = get_bits(gb, 7);
}
if (decode_exponents(ctx)) {
av_log(NULL, AV_LOG_ERROR, "Error parsing exponents\n");
return -1;
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_BAIE;
bit_alloc_flags |= 127;
ab->sdcycod = get_bits(gb, 2);
ab->fdcycod = get_bits(gb, 2);
ab->sgaincod = get_bits(gb, 2);
ab->dbpbcod = get_bits(gb, 2);
ab->floorcod = get_bits(gb, 3);
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_SNROFFSTE;
bit_alloc_flags |= 127;
ab->csnroffst = get_bits(gb, 6);
if (*flags & AC3_AB_CPLINU) {
ab->cplfsnroffst = get_bits(gb, 4);
ab->cplfgaincod = get_bits(gb, 3);
}
for (i = 0; i < nfchans; i++) {
ab->fsnroffst[i] = get_bits(gb, 4);
ab->fgaincod[i] = get_bits(gb, 3);
}
if (ctx->bsi.flags & AC3_BSI_LFEON) {
ab->lfefsnroffst = get_bits(gb, 4);
ab->lfefgaincod = get_bits(gb, 3);
}
}
if (*flags & AC3_AB_CPLINU)
if (get_bits(gb, 1)) {
bit_alloc_flags |= 64;
*flags |= AC3_AB_CPLLEAKE;
ab->cplfleak = get_bits(gb, 3);
ab->cplsleak = get_bits(gb, 3);
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_DELTBAIE;
bit_alloc_flags |= 127;
if (*flags & AC3_AB_CPLINU) {
ab->cpldeltbae = get_bits(gb, 2);
if (ab->cpldeltbae == AC3_DBASTR_RESERVED) {
av_log(NULL, AV_LOG_ERROR, "coupling delta bit allocation strategy reserved\n");
return -1;
}
}
for (i = 0; i < nfchans; i++) {
ab->deltbae[i] = get_bits(gb, 2);
if (ab->deltbae[i] == AC3_DBASTR_RESERVED) {
av_log(NULL, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
return -1;
}
}
if (*flags & AC3_AB_CPLINU)
if (ab->cpldeltbae == AC3_DBASTR_NEW) {
ab->cpldeltnseg = get_bits(gb, 3);
for (seg = 0; seg <= ab->cpldeltnseg; seg++) {
ab->cpldeltoffst[seg] = get_bits(gb, 5);
ab->cpldeltlen[seg] = get_bits(gb, 4);
ab->cpldeltba[seg] = get_bits(gb, 3);
}
}
for (i = 0; i < nfchans; i++)
if (ab->deltbae[i] == AC3_DBASTR_NEW) {
ab->deltnseg[i] = get_bits(gb, 3);
for (seg = 0; seg <= ab->deltnseg[i]; seg++) {
ab->deltoffst[i][seg] = get_bits(gb, 5);
ab->deltlen[i][seg] = get_bits(gb, 4);
ab->deltba[i][seg] = get_bits(gb, 3);
}
}
}
if (do_bit_allocation (ctx, bit_alloc_flags)) {
av_log(NULL, AV_LOG_ERROR, "Error in bit allocation routine\n");
return -1;
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_SKIPLE;
ab->skipl = get_bits(gb, 9);
while (ab->skipl) {
get_bits(gb, 8);
ab->skipl--;
}
}
if (get_transform_coeffs(ctx)) {
av_log(NULL, AV_LOG_ERROR, "Error in routine get_transform_coeffs\n");
return -1;
}
if (*flags & AC3_AB_REMATSTR)
do_rematrixing(ctx);
if (ctx->output != AC3_OUTPUT_UNMODIFIED)
do_downmix(ctx);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AC3DecodeContext * VAR_0, int VAR_1)
{
ac3_audio_block *ab = &VAR_0->audio_block;
int VAR_2 = VAR_0->bsi.VAR_2;
int VAR_3 = VAR_0->bsi.VAR_3;
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
GetBitContext *gb = &VAR_0->gb;
uint32_t *flags = &ab->flags;
int VAR_9 = 0;
float VAR_10;
*flags = 0;
ab->blksw = 0;
for (VAR_4 = 0; VAR_4 < 5; VAR_4++)
ab->chcoeffs[VAR_4] = 1.0;
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
ab->blksw |= get_bits(gb, 1) << VAR_4;
ab->dithflag = 0;
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
ab->dithflag |= get_bits(gb, 1) << VAR_4;
if (get_bits(gb, 1)) {
*flags |= AC3_AB_DYNRNGE;
ab->dynrng = get_bits(gb, 8);
VAR_10 = ((((ab->dynrng & 0x1f) | 0x20) << 13) * scale_factors[3 - (ab->dynrng >> 5)]);
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
ab->chcoeffs[VAR_4] *= VAR_10;
}
if (VAR_3 == 0x00) {
if (get_bits(gb, 1)) {
*flags |= AC3_AB_DYNRNG2E;
ab->dynrng2 = get_bits(gb, 8);
VAR_10 = ((((ab->dynrng2 & 0x1f) | 0x20) << 13) * scale_factors[3 - (ab->dynrng2 >> 5)]);
ab->chcoeffs[1] *= VAR_10;
}
}
get_downmix_coeffs(VAR_0);
ab->chincpl = 0;
if (get_bits(gb, 1)) {
*flags |= AC3_AB_CPLSTRE;
ab->cplbndstrc = 0;
if (get_bits(gb, 1)) {
*flags |= AC3_AB_CPLINU;
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
ab->chincpl |= get_bits(gb, 1) << VAR_4;
if (VAR_3 == 0x02)
if (get_bits(gb, 1))
*flags |= AC3_AB_PHSFLGINU;
ab->cplbegf = get_bits(gb, 4);
ab->cplendf = get_bits(gb, 4);
assert((ab->ncplsubnd = 3 + ab->cplendf - ab->cplbegf) > 0);
ab->ncplbnd = ab->ncplsubnd;
for (VAR_4 = 0; VAR_4 < ab->ncplsubnd - 1; VAR_4++)
if (get_bits(gb, 1)) {
ab->cplbndstrc |= 1 << VAR_4;
ab->ncplbnd--;
}
}
}
if (*flags & AC3_AB_CPLINU) {
ab->cplcoe = 0;
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
if (ab->chincpl & (1 << VAR_4))
if (get_bits(gb, 1)) {
ab->cplcoe |= 1 << VAR_4;
ab->mstrcplco[VAR_4] = get_bits(gb, 2);
for (VAR_5 = 0; VAR_5 < ab->ncplbnd; VAR_5++) {
ab->cplcoexp[VAR_4][VAR_5] = get_bits(gb, 4);
ab->cplcomant[VAR_4][VAR_5] = get_bits(gb, 4);
}
}
}
ab->phsflg = 0;
if ((VAR_3 == 0x02) && (*flags & AC3_AB_PHSFLGINU) && (ab->cplcoe & 1 || ab->cplcoe & (1 << 1))) {
for (VAR_5 = 0; VAR_5 < ab->ncplbnd; VAR_5++)
if (get_bits(gb, 1))
ab->phsflg |= 1 << VAR_5;
}
generate_coupling_coordinates(VAR_0);
ab->rematflg = 0;
if (VAR_3 == 0x02)
if (get_bits(gb, 1)) {
*flags |= AC3_AB_REMATSTR;
if (ab->cplbegf > 2 || !(*flags & AC3_AB_CPLINU))
for (VAR_6 = 0; VAR_6 < 4; VAR_6++)
ab->rematflg |= get_bits(gb, 1) << VAR_5;
else if (ab->cplbegf > 0 && ab->cplbegf <= 2 && *flags & AC3_AB_CPLINU)
for (VAR_6 = 0; VAR_6 < 3; VAR_6++)
ab->rematflg |= get_bits(gb, 1) << VAR_5;
else if (!(ab->cplbegf) && *flags & AC3_AB_CPLINU)
for (VAR_6 = 0; VAR_6 < 2; VAR_6++)
ab->rematflg |= get_bits(gb, 1) << VAR_5;
}
if (*flags & AC3_AB_CPLINU)
ab->cplexpstr = get_bits(gb, 2);
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
ab->chexpstr[VAR_4] = get_bits(gb, 2);
if (VAR_0->bsi.flags & AC3_BSI_LFEON)
ab->lfeexpstr = get_bits(gb, 1);
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
if (ab->chexpstr[VAR_4] != AC3_EXPSTR_REUSE)
if (!(ab->chincpl & (1 << VAR_4))) {
ab->chbwcod[VAR_4] = get_bits(gb, 6);
assert (ab->chbwcod[VAR_4] <= 60);
}
if (*flags & AC3_AB_CPLINU)
if (ab->cplexpstr != AC3_EXPSTR_REUSE) {
VAR_9 |= 64;
ab->cplabsexp = get_bits(gb, 4) << 1;
ab->cplstrtmant = (ab->cplbegf * 12) + 37;
ab->cplendmant = ((ab->cplendmant + 3) * 12) + 37;
ab->ncplgrps = (ab->cplendmant - ab->cplstrtmant) / (3 << (ab->cplexpstr - 1));
for (VAR_7 = 0; VAR_7 < ab->ncplgrps; VAR_7++)
ab->cplexps[VAR_7] = get_bits(gb, 7);
}
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
if (ab->chexpstr[VAR_4] != AC3_EXPSTR_REUSE) {
VAR_9 |= 1 << VAR_4;
if (ab->chincpl & (1 << VAR_4))
ab->endmant[VAR_4] = (ab->cplbegf * 12) + 37;
else
ab->endmant[VAR_4] = ((ab->chbwcod[VAR_4] + 3) * 12) + 37;
ab->nchgrps[VAR_4] =
(ab->endmant[VAR_4] + (3 << (ab->chexpstr[VAR_4] - 1)) - 4) / (3 << (ab->chexpstr[VAR_4] - 1));
ab->exps[VAR_4][0] = ab->dexps[VAR_4][0] = get_bits(gb, 4);
for (VAR_7 = 1; VAR_7 <= ab->nchgrps[VAR_4]; VAR_7++)
ab->exps[VAR_4][VAR_7] = get_bits(gb, 7);
ab->gainrng[VAR_4] = get_bits(gb, 2);
}
if (VAR_0->bsi.flags & AC3_BSI_LFEON)
if (ab->lfeexpstr != AC3_EXPSTR_REUSE) {
VAR_9 |= 32;
ab->lfeexps[0] = ab->dlfeexps[0] = get_bits(gb, 4);
ab->lfeexps[1] = get_bits(gb, 7);
ab->lfeexps[2] = get_bits(gb, 7);
}
if (decode_exponents(VAR_0)) {
av_log(NULL, AV_LOG_ERROR, "Error parsing exponents\n");
return -1;
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_BAIE;
VAR_9 |= 127;
ab->sdcycod = get_bits(gb, 2);
ab->fdcycod = get_bits(gb, 2);
ab->sgaincod = get_bits(gb, 2);
ab->dbpbcod = get_bits(gb, 2);
ab->floorcod = get_bits(gb, 3);
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_SNROFFSTE;
VAR_9 |= 127;
ab->csnroffst = get_bits(gb, 6);
if (*flags & AC3_AB_CPLINU) {
ab->cplfsnroffst = get_bits(gb, 4);
ab->cplfgaincod = get_bits(gb, 3);
}
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {
ab->fsnroffst[VAR_4] = get_bits(gb, 4);
ab->fgaincod[VAR_4] = get_bits(gb, 3);
}
if (VAR_0->bsi.flags & AC3_BSI_LFEON) {
ab->lfefsnroffst = get_bits(gb, 4);
ab->lfefgaincod = get_bits(gb, 3);
}
}
if (*flags & AC3_AB_CPLINU)
if (get_bits(gb, 1)) {
VAR_9 |= 64;
*flags |= AC3_AB_CPLLEAKE;
ab->cplfleak = get_bits(gb, 3);
ab->cplsleak = get_bits(gb, 3);
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_DELTBAIE;
VAR_9 |= 127;
if (*flags & AC3_AB_CPLINU) {
ab->cpldeltbae = get_bits(gb, 2);
if (ab->cpldeltbae == AC3_DBASTR_RESERVED) {
av_log(NULL, AV_LOG_ERROR, "coupling delta bit allocation strategy reserved\n");
return -1;
}
}
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {
ab->deltbae[VAR_4] = get_bits(gb, 2);
if (ab->deltbae[VAR_4] == AC3_DBASTR_RESERVED) {
av_log(NULL, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
return -1;
}
}
if (*flags & AC3_AB_CPLINU)
if (ab->cpldeltbae == AC3_DBASTR_NEW) {
ab->cpldeltnseg = get_bits(gb, 3);
for (VAR_8 = 0; VAR_8 <= ab->cpldeltnseg; VAR_8++) {
ab->cpldeltoffst[VAR_8] = get_bits(gb, 5);
ab->cpldeltlen[VAR_8] = get_bits(gb, 4);
ab->cpldeltba[VAR_8] = get_bits(gb, 3);
}
}
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
if (ab->deltbae[VAR_4] == AC3_DBASTR_NEW) {
ab->deltnseg[VAR_4] = get_bits(gb, 3);
for (VAR_8 = 0; VAR_8 <= ab->deltnseg[VAR_4]; VAR_8++) {
ab->deltoffst[VAR_4][VAR_8] = get_bits(gb, 5);
ab->deltlen[VAR_4][VAR_8] = get_bits(gb, 4);
ab->deltba[VAR_4][VAR_8] = get_bits(gb, 3);
}
}
}
if (do_bit_allocation (VAR_0, VAR_9)) {
av_log(NULL, AV_LOG_ERROR, "Error in bit allocation routine\n");
return -1;
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_SKIPLE;
ab->skipl = get_bits(gb, 9);
while (ab->skipl) {
get_bits(gb, 8);
ab->skipl--;
}
}
if (get_transform_coeffs(VAR_0)) {
av_log(NULL, AV_LOG_ERROR, "Error in routine get_transform_coeffs\n");
return -1;
}
if (*flags & AC3_AB_REMATSTR)
do_rematrixing(VAR_0);
if (VAR_0->output != AC3_OUTPUT_UNMODIFIED)
do_downmix(VAR_0);
return 0;
}
| [
"static int FUNC_0(AC3DecodeContext * VAR_0, int VAR_1)\n{",
"ac3_audio_block *ab = &VAR_0->audio_block;",
"int VAR_2 = VAR_0->bsi.VAR_2;",
"int VAR_3 = VAR_0->bsi.VAR_3;",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"GetBitContext *gb = &VAR_0->gb;",
"uint32_t *flags = &ab->flags;",
"int VAR_9 = 0;",
"float VAR_10;",
"*flags = 0;",
"ab->blksw = 0;",
"for (VAR_4 = 0; VAR_4 < 5; VAR_4++)",
"ab->chcoeffs[VAR_4] = 1.0;",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"ab->blksw |= get_bits(gb, 1) << VAR_4;",
"ab->dithflag = 0;",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"ab->dithflag |= get_bits(gb, 1) << VAR_4;",
"if (get_bits(gb, 1)) {",
"*flags |= AC3_AB_DYNRNGE;",
"ab->dynrng = get_bits(gb, 8);",
"VAR_10 = ((((ab->dynrng & 0x1f) | 0x20) << 13) * scale_factors[3 - (ab->dynrng >> 5)]);",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"ab->chcoeffs[VAR_4] *= VAR_10;",
"}",
"if (VAR_3 == 0x00) {",
"if (get_bits(gb, 1)) {",
"*flags |= AC3_AB_DYNRNG2E;",
"ab->dynrng2 = get_bits(gb, 8);",
"VAR_10 = ((((ab->dynrng2 & 0x1f) | 0x20) << 13) * scale_factors[3 - (ab->dynrng2 >> 5)]);",
"ab->chcoeffs[1] *= VAR_10;",
"}",
"}",
"get_downmix_coeffs(VAR_0);",
"ab->chincpl = 0;",
"if (get_bits(gb, 1)) {",
"*flags |= AC3_AB_CPLSTRE;",
"ab->cplbndstrc = 0;",
"if (get_bits(gb, 1)) {",
"*flags |= AC3_AB_CPLINU;",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"ab->chincpl |= get_bits(gb, 1) << VAR_4;",
"if (VAR_3 == 0x02)\nif (get_bits(gb, 1))\n*flags |= AC3_AB_PHSFLGINU;",
"ab->cplbegf = get_bits(gb, 4);",
"ab->cplendf = get_bits(gb, 4);",
"assert((ab->ncplsubnd = 3 + ab->cplendf - ab->cplbegf) > 0);",
"ab->ncplbnd = ab->ncplsubnd;",
"for (VAR_4 = 0; VAR_4 < ab->ncplsubnd - 1; VAR_4++)",
"if (get_bits(gb, 1)) {",
"ab->cplbndstrc |= 1 << VAR_4;",
"ab->ncplbnd--;",
"}",
"}",
"}",
"if (*flags & AC3_AB_CPLINU) {",
"ab->cplcoe = 0;",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"if (ab->chincpl & (1 << VAR_4))\nif (get_bits(gb, 1)) {",
"ab->cplcoe |= 1 << VAR_4;",
"ab->mstrcplco[VAR_4] = get_bits(gb, 2);",
"for (VAR_5 = 0; VAR_5 < ab->ncplbnd; VAR_5++) {",
"ab->cplcoexp[VAR_4][VAR_5] = get_bits(gb, 4);",
"ab->cplcomant[VAR_4][VAR_5] = get_bits(gb, 4);",
"}",
"}",
"}",
"ab->phsflg = 0;",
"if ((VAR_3 == 0x02) && (*flags & AC3_AB_PHSFLGINU) && (ab->cplcoe & 1 || ab->cplcoe & (1 << 1))) {",
"for (VAR_5 = 0; VAR_5 < ab->ncplbnd; VAR_5++)",
"if (get_bits(gb, 1))\nab->phsflg |= 1 << VAR_5;",
"}",
"generate_coupling_coordinates(VAR_0);",
"ab->rematflg = 0;",
"if (VAR_3 == 0x02)\nif (get_bits(gb, 1)) {",
"*flags |= AC3_AB_REMATSTR;",
"if (ab->cplbegf > 2 || !(*flags & AC3_AB_CPLINU))\nfor (VAR_6 = 0; VAR_6 < 4; VAR_6++)",
"ab->rematflg |= get_bits(gb, 1) << VAR_5;",
"else if (ab->cplbegf > 0 && ab->cplbegf <= 2 && *flags & AC3_AB_CPLINU)\nfor (VAR_6 = 0; VAR_6 < 3; VAR_6++)",
"ab->rematflg |= get_bits(gb, 1) << VAR_5;",
"else if (!(ab->cplbegf) && *flags & AC3_AB_CPLINU)\nfor (VAR_6 = 0; VAR_6 < 2; VAR_6++)",
"ab->rematflg |= get_bits(gb, 1) << VAR_5;",
"}",
"if (*flags & AC3_AB_CPLINU)\nab->cplexpstr = get_bits(gb, 2);",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"ab->chexpstr[VAR_4] = get_bits(gb, 2);",
"if (VAR_0->bsi.flags & AC3_BSI_LFEON)\nab->lfeexpstr = get_bits(gb, 1);",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"if (ab->chexpstr[VAR_4] != AC3_EXPSTR_REUSE)\nif (!(ab->chincpl & (1 << VAR_4))) {",
"ab->chbwcod[VAR_4] = get_bits(gb, 6);",
"assert (ab->chbwcod[VAR_4] <= 60);",
"}",
"if (*flags & AC3_AB_CPLINU)\nif (ab->cplexpstr != AC3_EXPSTR_REUSE) {",
"VAR_9 |= 64;",
"ab->cplabsexp = get_bits(gb, 4) << 1;",
"ab->cplstrtmant = (ab->cplbegf * 12) + 37;",
"ab->cplendmant = ((ab->cplendmant + 3) * 12) + 37;",
"ab->ncplgrps = (ab->cplendmant - ab->cplstrtmant) / (3 << (ab->cplexpstr - 1));",
"for (VAR_7 = 0; VAR_7 < ab->ncplgrps; VAR_7++)",
"ab->cplexps[VAR_7] = get_bits(gb, 7);",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"if (ab->chexpstr[VAR_4] != AC3_EXPSTR_REUSE) {",
"VAR_9 |= 1 << VAR_4;",
"if (ab->chincpl & (1 << VAR_4))\nab->endmant[VAR_4] = (ab->cplbegf * 12) + 37;",
"else\nab->endmant[VAR_4] = ((ab->chbwcod[VAR_4] + 3) * 12) + 37;",
"ab->nchgrps[VAR_4] =\n(ab->endmant[VAR_4] + (3 << (ab->chexpstr[VAR_4] - 1)) - 4) / (3 << (ab->chexpstr[VAR_4] - 1));",
"ab->exps[VAR_4][0] = ab->dexps[VAR_4][0] = get_bits(gb, 4);",
"for (VAR_7 = 1; VAR_7 <= ab->nchgrps[VAR_4]; VAR_7++)",
"ab->exps[VAR_4][VAR_7] = get_bits(gb, 7);",
"ab->gainrng[VAR_4] = get_bits(gb, 2);",
"}",
"if (VAR_0->bsi.flags & AC3_BSI_LFEON)\nif (ab->lfeexpstr != AC3_EXPSTR_REUSE) {",
"VAR_9 |= 32;",
"ab->lfeexps[0] = ab->dlfeexps[0] = get_bits(gb, 4);",
"ab->lfeexps[1] = get_bits(gb, 7);",
"ab->lfeexps[2] = get_bits(gb, 7);",
"}",
"if (decode_exponents(VAR_0)) {",
"av_log(NULL, AV_LOG_ERROR, \"Error parsing exponents\\n\");",
"return -1;",
"}",
"if (get_bits(gb, 1)) {",
"*flags |= AC3_AB_BAIE;",
"VAR_9 |= 127;",
"ab->sdcycod = get_bits(gb, 2);",
"ab->fdcycod = get_bits(gb, 2);",
"ab->sgaincod = get_bits(gb, 2);",
"ab->dbpbcod = get_bits(gb, 2);",
"ab->floorcod = get_bits(gb, 3);",
"}",
"if (get_bits(gb, 1)) {",
"*flags |= AC3_AB_SNROFFSTE;",
"VAR_9 |= 127;",
"ab->csnroffst = get_bits(gb, 6);",
"if (*flags & AC3_AB_CPLINU) {",
"ab->cplfsnroffst = get_bits(gb, 4);",
"ab->cplfgaincod = get_bits(gb, 3);",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {",
"ab->fsnroffst[VAR_4] = get_bits(gb, 4);",
"ab->fgaincod[VAR_4] = get_bits(gb, 3);",
"}",
"if (VAR_0->bsi.flags & AC3_BSI_LFEON) {",
"ab->lfefsnroffst = get_bits(gb, 4);",
"ab->lfefgaincod = get_bits(gb, 3);",
"}",
"}",
"if (*flags & AC3_AB_CPLINU)\nif (get_bits(gb, 1)) {",
"VAR_9 |= 64;",
"*flags |= AC3_AB_CPLLEAKE;",
"ab->cplfleak = get_bits(gb, 3);",
"ab->cplsleak = get_bits(gb, 3);",
"}",
"if (get_bits(gb, 1)) {",
"*flags |= AC3_AB_DELTBAIE;",
"VAR_9 |= 127;",
"if (*flags & AC3_AB_CPLINU) {",
"ab->cpldeltbae = get_bits(gb, 2);",
"if (ab->cpldeltbae == AC3_DBASTR_RESERVED) {",
"av_log(NULL, AV_LOG_ERROR, \"coupling delta bit allocation strategy reserved\\n\");",
"return -1;",
"}",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {",
"ab->deltbae[VAR_4] = get_bits(gb, 2);",
"if (ab->deltbae[VAR_4] == AC3_DBASTR_RESERVED) {",
"av_log(NULL, AV_LOG_ERROR, \"delta bit allocation strategy reserved\\n\");",
"return -1;",
"}",
"}",
"if (*flags & AC3_AB_CPLINU)\nif (ab->cpldeltbae == AC3_DBASTR_NEW) {",
"ab->cpldeltnseg = get_bits(gb, 3);",
"for (VAR_8 = 0; VAR_8 <= ab->cpldeltnseg; VAR_8++) {",
"ab->cpldeltoffst[VAR_8] = get_bits(gb, 5);",
"ab->cpldeltlen[VAR_8] = get_bits(gb, 4);",
"ab->cpldeltba[VAR_8] = get_bits(gb, 3);",
"}",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"if (ab->deltbae[VAR_4] == AC3_DBASTR_NEW) {",
"ab->deltnseg[VAR_4] = get_bits(gb, 3);",
"for (VAR_8 = 0; VAR_8 <= ab->deltnseg[VAR_4]; VAR_8++) {",
"ab->deltoffst[VAR_4][VAR_8] = get_bits(gb, 5);",
"ab->deltlen[VAR_4][VAR_8] = get_bits(gb, 4);",
"ab->deltba[VAR_4][VAR_8] = get_bits(gb, 3);",
"}",
"}",
"}",
"if (do_bit_allocation (VAR_0, VAR_9)) {",
"av_log(NULL, AV_LOG_ERROR, \"Error in bit allocation routine\\n\");",
"return -1;",
"}",
"if (get_bits(gb, 1)) {",
"*flags |= AC3_AB_SKIPLE;",
"ab->skipl = get_bits(gb, 9);",
"while (ab->skipl) {",
"get_bits(gb, 8);",
"ab->skipl--;",
"}",
"}",
"if (get_transform_coeffs(VAR_0)) {",
"av_log(NULL, AV_LOG_ERROR, \"Error in routine get_transform_coeffs\\n\");",
"return -1;",
"}",
"if (*flags & AC3_AB_REMATSTR)\ndo_rematrixing(VAR_0);",
"if (VAR_0->output != AC3_OUTPUT_UNMODIFIED)\ndo_downmix(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
123,
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159,
161
],
[
163
],
[
165,
167
],
[
169
],
[
171,
173
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199,
201
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239,
241
],
[
243,
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257,
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
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
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381,
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
449
],
[
451
],
[
453
],
[
455
],
[
459,
461
],
[
465,
467
],
[
471
],
[
473
]
] |
19,448 | static void h264_free_extradata(PayloadContext *data)
{
#ifdef DEBUG
int ii;
for (ii = 0; ii < 32; ii++) {
if (data->packet_types_received[ii])
av_log(NULL, AV_LOG_DEBUG, "Received %d packets of type %d\n",
data->packet_types_received[ii], ii);
}
#endif
assert(data);
assert(data->cookie == MAGIC_COOKIE);
// avoid stale pointers (assert)
data->cookie = DEAD_COOKIE;
// and clear out this...
av_free(data);
}
| false | FFmpeg | 202a6697ba54293235ce2d7bd5724f4f461e417f | static void h264_free_extradata(PayloadContext *data)
{
#ifdef DEBUG
int ii;
for (ii = 0; ii < 32; ii++) {
if (data->packet_types_received[ii])
av_log(NULL, AV_LOG_DEBUG, "Received %d packets of type %d\n",
data->packet_types_received[ii], ii);
}
#endif
assert(data);
assert(data->cookie == MAGIC_COOKIE);
data->cookie = DEAD_COOKIE;
av_free(data);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PayloadContext *VAR_0)
{
#ifdef DEBUG
int ii;
for (ii = 0; ii < 32; ii++) {
if (VAR_0->packet_types_received[ii])
av_log(NULL, AV_LOG_DEBUG, "Received %d packets of type %d\n",
VAR_0->packet_types_received[ii], ii);
}
#endif
assert(VAR_0);
assert(VAR_0->cookie == MAGIC_COOKIE);
VAR_0->cookie = DEAD_COOKIE;
av_free(VAR_0);
}
| [
"static void FUNC_0(PayloadContext *VAR_0)\n{",
"#ifdef DEBUG\nint ii;",
"for (ii = 0; ii < 32; ii++) {",
"if (VAR_0->packet_types_received[ii])\nav_log(NULL, AV_LOG_DEBUG, \"Received %d packets of type %d\\n\",\nVAR_0->packet_types_received[ii], ii);",
"}",
"#endif\nassert(VAR_0);",
"assert(VAR_0->cookie == MAGIC_COOKIE);",
"VAR_0->cookie = DEAD_COOKIE;",
"av_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11
],
[
13,
15,
17
],
[
19
],
[
21,
25
],
[
27
],
[
33
],
[
39
],
[
41
]
] |
19,449 | static int net_socket_connect_init(VLANState *vlan,
const char *model,
const char *name,
const char *host_str)
{
NetSocketState *s;
int fd, connected, ret, err;
struct sockaddr_in saddr;
if (parse_host_port(&saddr, host_str) < 0)
return -1;
fd = socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
return -1;
}
socket_set_nonblock(fd);
connected = 0;
for(;;) {
ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr));
if (ret < 0) {
err = socket_error();
if (err == EINTR || err == EWOULDBLOCK) {
} else if (err == EINPROGRESS) {
break;
#ifdef _WIN32
} else if (err == WSAEALREADY) {
break;
#endif
} else {
perror("connect");
closesocket(fd);
return -1;
}
} else {
connected = 1;
break;
}
}
s = net_socket_fd_init(vlan, model, name, fd, connected);
if (!s)
return -1;
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"socket: connect to %s:%d",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
return 0;
}
| true | qemu | 40ff6d7e8dceca227e7f8a3e8e0d58b2c66d19b4 | static int net_socket_connect_init(VLANState *vlan,
const char *model,
const char *name,
const char *host_str)
{
NetSocketState *s;
int fd, connected, ret, err;
struct sockaddr_in saddr;
if (parse_host_port(&saddr, host_str) < 0)
return -1;
fd = socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
return -1;
}
socket_set_nonblock(fd);
connected = 0;
for(;;) {
ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr));
if (ret < 0) {
err = socket_error();
if (err == EINTR || err == EWOULDBLOCK) {
} else if (err == EINPROGRESS) {
break;
#ifdef _WIN32
} else if (err == WSAEALREADY) {
break;
#endif
} else {
perror("connect");
closesocket(fd);
return -1;
}
} else {
connected = 1;
break;
}
}
s = net_socket_fd_init(vlan, model, name, fd, connected);
if (!s)
return -1;
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"socket: connect to %s:%d",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
return 0;
}
| {
"code": [
" fd = socket(PF_INET, SOCK_STREAM, 0);",
" fd = socket(PF_INET, SOCK_STREAM, 0);"
],
"line_no": [
25,
25
]
} | static int FUNC_0(VLANState *VAR_0,
const char *VAR_1,
const char *VAR_2,
const char *VAR_3)
{
NetSocketState *s;
int VAR_4, VAR_5, VAR_6, VAR_7;
struct sockaddr_in VAR_8;
if (parse_host_port(&VAR_8, VAR_3) < 0)
return -1;
VAR_4 = socket(PF_INET, SOCK_STREAM, 0);
if (VAR_4 < 0) {
perror("socket");
return -1;
}
socket_set_nonblock(VAR_4);
VAR_5 = 0;
for(;;) {
VAR_6 = connect(VAR_4, (struct sockaddr *)&VAR_8, sizeof(VAR_8));
if (VAR_6 < 0) {
VAR_7 = socket_error();
if (VAR_7 == EINTR || VAR_7 == EWOULDBLOCK) {
} else if (VAR_7 == EINPROGRESS) {
break;
#ifdef _WIN32
} else if (VAR_7 == WSAEALREADY) {
break;
#endif
} else {
perror("connect");
closesocket(VAR_4);
return -1;
}
} else {
VAR_5 = 1;
break;
}
}
s = net_socket_fd_init(VAR_0, VAR_1, VAR_2, VAR_4, VAR_5);
if (!s)
return -1;
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"socket: connect to %s:%d",
inet_ntoa(VAR_8.sin_addr), ntohs(VAR_8.sin_port));
return 0;
}
| [
"static int FUNC_0(VLANState *VAR_0,\nconst char *VAR_1,\nconst char *VAR_2,\nconst char *VAR_3)\n{",
"NetSocketState *s;",
"int VAR_4, VAR_5, VAR_6, VAR_7;",
"struct sockaddr_in VAR_8;",
"if (parse_host_port(&VAR_8, VAR_3) < 0)\nreturn -1;",
"VAR_4 = socket(PF_INET, SOCK_STREAM, 0);",
"if (VAR_4 < 0) {",
"perror(\"socket\");",
"return -1;",
"}",
"socket_set_nonblock(VAR_4);",
"VAR_5 = 0;",
"for(;;) {",
"VAR_6 = connect(VAR_4, (struct sockaddr *)&VAR_8, sizeof(VAR_8));",
"if (VAR_6 < 0) {",
"VAR_7 = socket_error();",
"if (VAR_7 == EINTR || VAR_7 == EWOULDBLOCK) {",
"} else if (VAR_7 == EINPROGRESS) {",
"break;",
"#ifdef _WIN32\n} else if (VAR_7 == WSAEALREADY) {",
"break;",
"#endif\n} else {",
"perror(\"connect\");",
"closesocket(VAR_4);",
"return -1;",
"}",
"} else {",
"VAR_5 = 1;",
"break;",
"}",
"}",
"s = net_socket_fd_init(VAR_0, VAR_1, VAR_2, VAR_4, VAR_5);",
"if (!s)\nreturn -1;",
"snprintf(s->nc.info_str, sizeof(s->nc.info_str),\n\"socket: connect to %s:%d\",\ninet_ntoa(VAR_8.sin_addr), ntohs(VAR_8.sin_port));",
"return 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
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
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
],
[
95
],
[
97
]
] |
19,450 | static int kvm_update_routing_entry(KVMState *s,
struct kvm_irq_routing_entry *new_entry)
{
struct kvm_irq_routing_entry *entry;
int n;
for (n = 0; n < s->irq_routes->nr; n++) {
entry = &s->irq_routes->entries[n];
if (entry->gsi != new_entry->gsi) {
continue;
}
entry->type = new_entry->type;
entry->flags = new_entry->flags;
entry->u = new_entry->u;
kvm_irqchip_commit_routes(s);
return 0;
}
return -ESRCH;
}
| true | qemu | 0fbc20740342713f282b118b4a446c4c43df3f4a | static int kvm_update_routing_entry(KVMState *s,
struct kvm_irq_routing_entry *new_entry)
{
struct kvm_irq_routing_entry *entry;
int n;
for (n = 0; n < s->irq_routes->nr; n++) {
entry = &s->irq_routes->entries[n];
if (entry->gsi != new_entry->gsi) {
continue;
}
entry->type = new_entry->type;
entry->flags = new_entry->flags;
entry->u = new_entry->u;
kvm_irqchip_commit_routes(s);
return 0;
}
return -ESRCH;
}
| {
"code": [
" entry->type = new_entry->type;",
" entry->flags = new_entry->flags;",
" entry->u = new_entry->u;"
],
"line_no": [
25,
27,
29
]
} | static int FUNC_0(KVMState *VAR_0,
struct kvm_irq_routing_entry *VAR_1)
{
struct kvm_irq_routing_entry *VAR_2;
int VAR_3;
for (VAR_3 = 0; VAR_3 < VAR_0->irq_routes->nr; VAR_3++) {
VAR_2 = &VAR_0->irq_routes->entries[VAR_3];
if (VAR_2->gsi != VAR_1->gsi) {
continue;
}
VAR_2->type = VAR_1->type;
VAR_2->flags = VAR_1->flags;
VAR_2->u = VAR_1->u;
kvm_irqchip_commit_routes(VAR_0);
return 0;
}
return -ESRCH;
}
| [
"static int FUNC_0(KVMState *VAR_0,\nstruct kvm_irq_routing_entry *VAR_1)\n{",
"struct kvm_irq_routing_entry *VAR_2;",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < VAR_0->irq_routes->nr; VAR_3++) {",
"VAR_2 = &VAR_0->irq_routes->entries[VAR_3];",
"if (VAR_2->gsi != VAR_1->gsi) {",
"continue;",
"}",
"VAR_2->type = VAR_1->type;",
"VAR_2->flags = VAR_1->flags;",
"VAR_2->u = VAR_1->u;",
"kvm_irqchip_commit_routes(VAR_0);",
"return 0;",
"}",
"return -ESRCH;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
]
] |
19,451 | int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num,
int nb_sectors)
{
struct nbd_request request;
struct nbd_reply reply;
ssize_t ret;
if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) {
return 0;
}
request.type = NBD_CMD_TRIM;
request.from = sector_num * 512;
request.len = nb_sectors * 512;
nbd_coroutine_start(client, &request);
ret = nbd_co_send_request(client, &request, NULL, 0);
if (ret < 0) {
reply.error = -ret;
} else {
nbd_co_receive_reply(client, &request, &reply, NULL, 0);
}
nbd_coroutine_end(client, &request);
return -reply.error;
}
| true | qemu | b1b27b64262fdace45e5ab134c4438338076cb98 | int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num,
int nb_sectors)
{
struct nbd_request request;
struct nbd_reply reply;
ssize_t ret;
if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) {
return 0;
}
request.type = NBD_CMD_TRIM;
request.from = sector_num * 512;
request.len = nb_sectors * 512;
nbd_coroutine_start(client, &request);
ret = nbd_co_send_request(client, &request, NULL, 0);
if (ret < 0) {
reply.error = -ret;
} else {
nbd_co_receive_reply(client, &request, &reply, NULL, 0);
}
nbd_coroutine_end(client, &request);
return -reply.error;
}
| {
"code": [
" struct nbd_request request;",
" struct nbd_request request;",
" struct nbd_request request;",
" struct nbd_request request;",
" request.type = NBD_CMD_TRIM;",
" struct nbd_request request;"
],
"line_no": [
7,
7,
7,
7,
21,
7
]
} | int FUNC_0(NbdClientSession *VAR_0, int64_t VAR_1,
int VAR_2)
{
struct nbd_request VAR_3;
struct nbd_reply VAR_4;
ssize_t ret;
if (!(VAR_0->nbdflags & NBD_FLAG_SEND_TRIM)) {
return 0;
}
VAR_3.type = NBD_CMD_TRIM;
VAR_3.from = VAR_1 * 512;
VAR_3.len = VAR_2 * 512;
nbd_coroutine_start(VAR_0, &VAR_3);
ret = nbd_co_send_request(VAR_0, &VAR_3, NULL, 0);
if (ret < 0) {
VAR_4.error = -ret;
} else {
nbd_co_receive_reply(VAR_0, &VAR_3, &VAR_4, NULL, 0);
}
nbd_coroutine_end(VAR_0, &VAR_3);
return -VAR_4.error;
}
| [
"int FUNC_0(NbdClientSession *VAR_0, int64_t VAR_1,\nint VAR_2)\n{",
"struct nbd_request VAR_3;",
"struct nbd_reply VAR_4;",
"ssize_t ret;",
"if (!(VAR_0->nbdflags & NBD_FLAG_SEND_TRIM)) {",
"return 0;",
"}",
"VAR_3.type = NBD_CMD_TRIM;",
"VAR_3.from = VAR_1 * 512;",
"VAR_3.len = VAR_2 * 512;",
"nbd_coroutine_start(VAR_0, &VAR_3);",
"ret = nbd_co_send_request(VAR_0, &VAR_3, NULL, 0);",
"if (ret < 0) {",
"VAR_4.error = -ret;",
"} else {",
"nbd_co_receive_reply(VAR_0, &VAR_3, &VAR_4, NULL, 0);",
"}",
"nbd_coroutine_end(VAR_0, &VAR_3);",
"return -VAR_4.error;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
]
] |
19,452 | ssize_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
{
if (ret <= 0) {
if (ret == 0) {
VNC_DEBUG("Closing down client sock: EOF\n");
} else if (ret != QIO_CHANNEL_ERR_BLOCK) {
VNC_DEBUG("Closing down client sock: ret %zd (%s)\n",
ret, errp ? error_get_pretty(*errp) : "Unknown");
}
vnc_disconnect_start(vs);
if (errp) {
error_free(*errp);
*errp = NULL;
}
return 0;
}
return ret;
}
| true | qemu | 537848ee62195fc06c328b1cd64f4218f404a7f1 | ssize_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
{
if (ret <= 0) {
if (ret == 0) {
VNC_DEBUG("Closing down client sock: EOF\n");
} else if (ret != QIO_CHANNEL_ERR_BLOCK) {
VNC_DEBUG("Closing down client sock: ret %zd (%s)\n",
ret, errp ? error_get_pretty(*errp) : "Unknown");
}
vnc_disconnect_start(vs);
if (errp) {
error_free(*errp);
*errp = NULL;
}
return 0;
}
return ret;
}
| {
"code": [
" vnc_disconnect_start(vs);"
],
"line_no": [
21
]
} | ssize_t FUNC_0(VncState *vs, ssize_t ret, Error **errp)
{
if (ret <= 0) {
if (ret == 0) {
VNC_DEBUG("Closing down client sock: EOF\n");
} else if (ret != QIO_CHANNEL_ERR_BLOCK) {
VNC_DEBUG("Closing down client sock: ret %zd (%s)\n",
ret, errp ? error_get_pretty(*errp) : "Unknown");
}
vnc_disconnect_start(vs);
if (errp) {
error_free(*errp);
*errp = NULL;
}
return 0;
}
return ret;
}
| [
"ssize_t FUNC_0(VncState *vs, ssize_t ret, Error **errp)\n{",
"if (ret <= 0) {",
"if (ret == 0) {",
"VNC_DEBUG(\"Closing down client sock: EOF\\n\");",
"} else if (ret != QIO_CHANNEL_ERR_BLOCK) {",
"VNC_DEBUG(\"Closing down client sock: ret %zd (%s)\\n\",\nret, errp ? error_get_pretty(*errp) : \"Unknown\");",
"}",
"vnc_disconnect_start(vs);",
"if (errp) {",
"error_free(*errp);",
"*errp = NULL;",
"}",
"return 0;",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
19,453 | static void pl031_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
k->init = pl031_init;
dc->no_user = 1;
dc->vmsd = &vmstate_pl031;
}
| true | qemu | efec3dd631d94160288392721a5f9c39e50fb2bc | static void pl031_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
k->init = pl031_init;
dc->no_user = 1;
dc->vmsd = &vmstate_pl031;
}
| {
"code": [
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;"
],
"line_no": [
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(VAR_0);
k->init = pl031_init;
dc->no_user = 1;
dc->vmsd = &vmstate_pl031;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(VAR_0);",
"k->init = pl031_init;",
"dc->no_user = 1;",
"dc->vmsd = &vmstate_pl031;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
19,454 | static inline void fimd_swap_data(unsigned int swap_ctl, uint64_t *data)
{
int i;
uint64_t res;
uint64_t x = *data;
if (swap_ctl & FIMD_WINCON_SWAP_BITS) {
res = 0;
for (i = 0; i < 64; i++) {
if (x & (1ULL << (64 - i))) {
res |= (1ULL << i);
}
}
x = res;
}
if (swap_ctl & FIMD_WINCON_SWAP_BYTE) {
x = bswap64(x);
}
if (swap_ctl & FIMD_WINCON_SWAP_HWORD) {
x = ((x & 0x000000000000FFFFULL) << 48) |
((x & 0x00000000FFFF0000ULL) << 16) |
((x & 0x0000FFFF00000000ULL) >> 16) |
((x & 0xFFFF000000000000ULL) >> 48);
}
if (swap_ctl & FIMD_WINCON_SWAP_WORD) {
x = ((x & 0x00000000FFFFFFFFULL) << 32) |
((x & 0xFFFFFFFF00000000ULL) >> 32);
}
*data = x;
}
| true | qemu | 644ead5be1a851abff16886240c5c6fc1c5137c0 | static inline void fimd_swap_data(unsigned int swap_ctl, uint64_t *data)
{
int i;
uint64_t res;
uint64_t x = *data;
if (swap_ctl & FIMD_WINCON_SWAP_BITS) {
res = 0;
for (i = 0; i < 64; i++) {
if (x & (1ULL << (64 - i))) {
res |= (1ULL << i);
}
}
x = res;
}
if (swap_ctl & FIMD_WINCON_SWAP_BYTE) {
x = bswap64(x);
}
if (swap_ctl & FIMD_WINCON_SWAP_HWORD) {
x = ((x & 0x000000000000FFFFULL) << 48) |
((x & 0x00000000FFFF0000ULL) << 16) |
((x & 0x0000FFFF00000000ULL) >> 16) |
((x & 0xFFFF000000000000ULL) >> 48);
}
if (swap_ctl & FIMD_WINCON_SWAP_WORD) {
x = ((x & 0x00000000FFFFFFFFULL) << 32) |
((x & 0xFFFFFFFF00000000ULL) >> 32);
}
*data = x;
}
| {
"code": [
" if (x & (1ULL << (64 - i))) {"
],
"line_no": [
19
]
} | static inline void FUNC_0(unsigned int VAR_0, uint64_t *VAR_1)
{
int VAR_2;
uint64_t res;
uint64_t x = *VAR_1;
if (VAR_0 & FIMD_WINCON_SWAP_BITS) {
res = 0;
for (VAR_2 = 0; VAR_2 < 64; VAR_2++) {
if (x & (1ULL << (64 - VAR_2))) {
res |= (1ULL << VAR_2);
}
}
x = res;
}
if (VAR_0 & FIMD_WINCON_SWAP_BYTE) {
x = bswap64(x);
}
if (VAR_0 & FIMD_WINCON_SWAP_HWORD) {
x = ((x & 0x000000000000FFFFULL) << 48) |
((x & 0x00000000FFFF0000ULL) << 16) |
((x & 0x0000FFFF00000000ULL) >> 16) |
((x & 0xFFFF000000000000ULL) >> 48);
}
if (VAR_0 & FIMD_WINCON_SWAP_WORD) {
x = ((x & 0x00000000FFFFFFFFULL) << 32) |
((x & 0xFFFFFFFF00000000ULL) >> 32);
}
*VAR_1 = x;
}
| [
"static inline void FUNC_0(unsigned int VAR_0, uint64_t *VAR_1)\n{",
"int VAR_2;",
"uint64_t res;",
"uint64_t x = *VAR_1;",
"if (VAR_0 & FIMD_WINCON_SWAP_BITS) {",
"res = 0;",
"for (VAR_2 = 0; VAR_2 < 64; VAR_2++) {",
"if (x & (1ULL << (64 - VAR_2))) {",
"res |= (1ULL << VAR_2);",
"}",
"}",
"x = res;",
"}",
"if (VAR_0 & FIMD_WINCON_SWAP_BYTE) {",
"x = bswap64(x);",
"}",
"if (VAR_0 & FIMD_WINCON_SWAP_HWORD) {",
"x = ((x & 0x000000000000FFFFULL) << 48) |\n((x & 0x00000000FFFF0000ULL) << 16) |\n((x & 0x0000FFFF00000000ULL) >> 16) |\n((x & 0xFFFF000000000000ULL) >> 48);",
"}",
"if (VAR_0 & FIMD_WINCON_SWAP_WORD) {",
"x = ((x & 0x00000000FFFFFFFFULL) << 32) |\n((x & 0xFFFFFFFF00000000ULL) >> 32);",
"}",
"*VAR_1 = x;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43,
45,
47,
49
],
[
51
],
[
55
],
[
57,
59
],
[
61
],
[
65
],
[
67
]
] |
19,455 | static int sdl_write_header(AVFormatContext *s)
{
SDLContext *sdl = s->priv_data;
AVStream *st = s->streams[0];
AVCodecContext *encctx = st->codec;
AVRational sar, dar; /* sample and display aspect ratios */
int i, ret;
int flags = SDL_SWSURFACE | sdl->window_fullscreen ? SDL_FULLSCREEN : 0;
if (!sdl->window_title)
sdl->window_title = av_strdup(s->filename);
if (!sdl->icon_title)
sdl->icon_title = av_strdup(sdl->window_title);
if (SDL_WasInit(SDL_INIT_VIDEO)) {
av_log(s, AV_LOG_ERROR,
"SDL video subsystem was already inited, aborting\n");
sdl->sdl_was_already_inited = 1;
ret = AVERROR(EINVAL);
goto fail;
}
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
av_log(s, AV_LOG_ERROR, "Unable to initialize SDL: %s\n", SDL_GetError());
ret = AVERROR(EINVAL);
goto fail;
}
if ( s->nb_streams > 1
|| encctx->codec_type != AVMEDIA_TYPE_VIDEO
|| encctx->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
ret = AVERROR(EINVAL);
goto fail;
}
for (i = 0; sdl_overlay_pix_fmt_map[i].pix_fmt != AV_PIX_FMT_NONE; i++) {
if (sdl_overlay_pix_fmt_map[i].pix_fmt == encctx->pix_fmt) {
sdl->overlay_fmt = sdl_overlay_pix_fmt_map[i].overlay_fmt;
break;
}
}
if (!sdl->overlay_fmt) {
av_log(s, AV_LOG_ERROR,
"Unsupported pixel format '%s', choose one of yuv420p, yuyv422, or uyvy422\n",
av_get_pix_fmt_name(encctx->pix_fmt));
ret = AVERROR(EINVAL);
goto fail;
}
/* compute overlay width and height from the codec context information */
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });
/* we suppose the screen has a 1/1 sample aspect ratio */
if (sdl->window_width && sdl->window_height) {
/* fit in the window */
if (av_cmp_q(dar, (AVRational){ sdl->window_width, sdl->window_height }) > 0) {
/* fit in width */
sdl->overlay_width = sdl->window_width;
sdl->overlay_height = av_rescale(sdl->overlay_width, dar.den, dar.num);
} else {
/* fit in height */
sdl->overlay_height = sdl->window_height;
sdl->overlay_width = av_rescale(sdl->overlay_height, dar.num, dar.den);
}
} else {
if (sar.num > sar.den) {
sdl->overlay_width = encctx->width;
sdl->overlay_height = av_rescale(sdl->overlay_width, dar.den, dar.num);
} else {
sdl->overlay_height = encctx->height;
sdl->overlay_width = av_rescale(sdl->overlay_height, dar.num, dar.den);
}
sdl->window_width = sdl->overlay_width;
sdl->window_height = sdl->overlay_height;
}
sdl->overlay_x = (sdl->window_width - sdl->overlay_width ) / 2;
sdl->overlay_y = (sdl->window_height - sdl->overlay_height) / 2;
SDL_WM_SetCaption(sdl->window_title, sdl->icon_title);
sdl->surface = SDL_SetVideoMode(sdl->window_width, sdl->window_height,
24, flags);
if (!sdl->surface) {
av_log(s, AV_LOG_ERROR, "Unable to set video mode: %s\n", SDL_GetError());
ret = AVERROR(EINVAL);
goto fail;
}
sdl->overlay = SDL_CreateYUVOverlay(encctx->width, encctx->height,
sdl->overlay_fmt, sdl->surface);
if (!sdl->overlay || sdl->overlay->pitches[0] < encctx->width) {
av_log(s, AV_LOG_ERROR,
"SDL does not support an overlay with size of %dx%d pixels\n",
encctx->width, encctx->height);
ret = AVERROR(EINVAL);
goto fail;
}
av_log(s, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d\n",
encctx->width, encctx->height, av_get_pix_fmt_name(encctx->pix_fmt), sar.num, sar.den,
sdl->overlay_width, sdl->overlay_height);
return 0;
fail:
sdl_write_trailer(s);
return ret;
}
| true | FFmpeg | 7de3b1394b71118279e8f997be490633bc3f5d46 | static int sdl_write_header(AVFormatContext *s)
{
SDLContext *sdl = s->priv_data;
AVStream *st = s->streams[0];
AVCodecContext *encctx = st->codec;
AVRational sar, dar;
int i, ret;
int flags = SDL_SWSURFACE | sdl->window_fullscreen ? SDL_FULLSCREEN : 0;
if (!sdl->window_title)
sdl->window_title = av_strdup(s->filename);
if (!sdl->icon_title)
sdl->icon_title = av_strdup(sdl->window_title);
if (SDL_WasInit(SDL_INIT_VIDEO)) {
av_log(s, AV_LOG_ERROR,
"SDL video subsystem was already inited, aborting\n");
sdl->sdl_was_already_inited = 1;
ret = AVERROR(EINVAL);
goto fail;
}
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
av_log(s, AV_LOG_ERROR, "Unable to initialize SDL: %s\n", SDL_GetError());
ret = AVERROR(EINVAL);
goto fail;
}
if ( s->nb_streams > 1
|| encctx->codec_type != AVMEDIA_TYPE_VIDEO
|| encctx->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
ret = AVERROR(EINVAL);
goto fail;
}
for (i = 0; sdl_overlay_pix_fmt_map[i].pix_fmt != AV_PIX_FMT_NONE; i++) {
if (sdl_overlay_pix_fmt_map[i].pix_fmt == encctx->pix_fmt) {
sdl->overlay_fmt = sdl_overlay_pix_fmt_map[i].overlay_fmt;
break;
}
}
if (!sdl->overlay_fmt) {
av_log(s, AV_LOG_ERROR,
"Unsupported pixel format '%s', choose one of yuv420p, yuyv422, or uyvy422\n",
av_get_pix_fmt_name(encctx->pix_fmt));
ret = AVERROR(EINVAL);
goto fail;
}
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });
if (sdl->window_width && sdl->window_height) {
if (av_cmp_q(dar, (AVRational){ sdl->window_width, sdl->window_height }) > 0) {
sdl->overlay_width = sdl->window_width;
sdl->overlay_height = av_rescale(sdl->overlay_width, dar.den, dar.num);
} else {
sdl->overlay_height = sdl->window_height;
sdl->overlay_width = av_rescale(sdl->overlay_height, dar.num, dar.den);
}
} else {
if (sar.num > sar.den) {
sdl->overlay_width = encctx->width;
sdl->overlay_height = av_rescale(sdl->overlay_width, dar.den, dar.num);
} else {
sdl->overlay_height = encctx->height;
sdl->overlay_width = av_rescale(sdl->overlay_height, dar.num, dar.den);
}
sdl->window_width = sdl->overlay_width;
sdl->window_height = sdl->overlay_height;
}
sdl->overlay_x = (sdl->window_width - sdl->overlay_width ) / 2;
sdl->overlay_y = (sdl->window_height - sdl->overlay_height) / 2;
SDL_WM_SetCaption(sdl->window_title, sdl->icon_title);
sdl->surface = SDL_SetVideoMode(sdl->window_width, sdl->window_height,
24, flags);
if (!sdl->surface) {
av_log(s, AV_LOG_ERROR, "Unable to set video mode: %s\n", SDL_GetError());
ret = AVERROR(EINVAL);
goto fail;
}
sdl->overlay = SDL_CreateYUVOverlay(encctx->width, encctx->height,
sdl->overlay_fmt, sdl->surface);
if (!sdl->overlay || sdl->overlay->pitches[0] < encctx->width) {
av_log(s, AV_LOG_ERROR,
"SDL does not support an overlay with size of %dx%d pixels\n",
encctx->width, encctx->height);
ret = AVERROR(EINVAL);
goto fail;
}
av_log(s, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d\n",
encctx->width, encctx->height, av_get_pix_fmt_name(encctx->pix_fmt), sar.num, sar.den,
sdl->overlay_width, sdl->overlay_height);
return 0;
fail:
sdl_write_trailer(s);
return ret;
}
| {
"code": [
" int flags = SDL_SWSURFACE | sdl->window_fullscreen ? SDL_FULLSCREEN : 0;",
" if (SDL_Init(SDL_INIT_VIDEO) != 0) {",
" av_log(s, AV_LOG_ERROR, \"Unable to initialize SDL: %s\\n\", SDL_GetError());",
" ret = AVERROR(EINVAL);",
" goto fail;",
" SDL_WM_SetCaption(sdl->window_title, sdl->icon_title);",
" sdl->surface = SDL_SetVideoMode(sdl->window_width, sdl->window_height,",
" 24, flags);",
" if (!sdl->surface) {",
" av_log(s, AV_LOG_ERROR, \"Unable to set video mode: %s\\n\", SDL_GetError());",
" ret = AVERROR(EINVAL);",
" sdl->overlay = SDL_CreateYUVOverlay(encctx->width, encctx->height,",
" sdl->overlay_fmt, sdl->surface);",
" if (!sdl->overlay || sdl->overlay->pitches[0] < encctx->width) {",
" av_log(s, AV_LOG_ERROR,",
" \"SDL does not support an overlay with size of %dx%d pixels\\n\",",
" encctx->width, encctx->height);",
" ret = AVERROR(EINVAL);",
" av_log(s, AV_LOG_VERBOSE, \"w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d\\n\",",
" encctx->width, encctx->height, av_get_pix_fmt_name(encctx->pix_fmt), sar.num, sar.den,",
" sdl->overlay_width, sdl->overlay_height);"
],
"line_no": [
15,
45,
47,
37,
39,
163,
165,
167,
169,
171,
37,
181,
183,
185,
31,
189,
191,
37,
201,
203,
205
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
SDLContext *sdl = VAR_0->priv_data;
AVStream *st = VAR_0->streams[0];
AVCodecContext *encctx = st->codec;
AVRational sar, dar;
int VAR_1, VAR_2;
int VAR_3 = SDL_SWSURFACE | sdl->window_fullscreen ? SDL_FULLSCREEN : 0;
if (!sdl->window_title)
sdl->window_title = av_strdup(VAR_0->filename);
if (!sdl->icon_title)
sdl->icon_title = av_strdup(sdl->window_title);
if (SDL_WasInit(SDL_INIT_VIDEO)) {
av_log(VAR_0, AV_LOG_ERROR,
"SDL video subsystem was already inited, aborting\n");
sdl->sdl_was_already_inited = 1;
VAR_2 = AVERROR(EINVAL);
goto fail;
}
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
av_log(VAR_0, AV_LOG_ERROR, "Unable to initialize SDL: %VAR_0\n", SDL_GetError());
VAR_2 = AVERROR(EINVAL);
goto fail;
}
if ( VAR_0->nb_streams > 1
|| encctx->codec_type != AVMEDIA_TYPE_VIDEO
|| encctx->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(VAR_0, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
VAR_2 = AVERROR(EINVAL);
goto fail;
}
for (VAR_1 = 0; sdl_overlay_pix_fmt_map[VAR_1].pix_fmt != AV_PIX_FMT_NONE; VAR_1++) {
if (sdl_overlay_pix_fmt_map[VAR_1].pix_fmt == encctx->pix_fmt) {
sdl->overlay_fmt = sdl_overlay_pix_fmt_map[VAR_1].overlay_fmt;
break;
}
}
if (!sdl->overlay_fmt) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported pixel format '%VAR_0', choose one of yuv420p, yuyv422, or uyvy422\n",
av_get_pix_fmt_name(encctx->pix_fmt));
VAR_2 = AVERROR(EINVAL);
goto fail;
}
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });
if (sdl->window_width && sdl->window_height) {
if (av_cmp_q(dar, (AVRational){ sdl->window_width, sdl->window_height }) > 0) {
sdl->overlay_width = sdl->window_width;
sdl->overlay_height = av_rescale(sdl->overlay_width, dar.den, dar.num);
} else {
sdl->overlay_height = sdl->window_height;
sdl->overlay_width = av_rescale(sdl->overlay_height, dar.num, dar.den);
}
} else {
if (sar.num > sar.den) {
sdl->overlay_width = encctx->width;
sdl->overlay_height = av_rescale(sdl->overlay_width, dar.den, dar.num);
} else {
sdl->overlay_height = encctx->height;
sdl->overlay_width = av_rescale(sdl->overlay_height, dar.num, dar.den);
}
sdl->window_width = sdl->overlay_width;
sdl->window_height = sdl->overlay_height;
}
sdl->overlay_x = (sdl->window_width - sdl->overlay_width ) / 2;
sdl->overlay_y = (sdl->window_height - sdl->overlay_height) / 2;
SDL_WM_SetCaption(sdl->window_title, sdl->icon_title);
sdl->surface = SDL_SetVideoMode(sdl->window_width, sdl->window_height,
24, VAR_3);
if (!sdl->surface) {
av_log(VAR_0, AV_LOG_ERROR, "Unable to set video mode: %VAR_0\n", SDL_GetError());
VAR_2 = AVERROR(EINVAL);
goto fail;
}
sdl->overlay = SDL_CreateYUVOverlay(encctx->width, encctx->height,
sdl->overlay_fmt, sdl->surface);
if (!sdl->overlay || sdl->overlay->pitches[0] < encctx->width) {
av_log(VAR_0, AV_LOG_ERROR,
"SDL does not support an overlay with size of %dx%d pixels\n",
encctx->width, encctx->height);
VAR_2 = AVERROR(EINVAL);
goto fail;
}
av_log(VAR_0, AV_LOG_VERBOSE, "w:%d h:%d fmt:%VAR_0 sar:%d/%d -> w:%d h:%d\n",
encctx->width, encctx->height, av_get_pix_fmt_name(encctx->pix_fmt), sar.num, sar.den,
sdl->overlay_width, sdl->overlay_height);
return 0;
fail:
sdl_write_trailer(VAR_0);
return VAR_2;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"SDLContext *sdl = VAR_0->priv_data;",
"AVStream *st = VAR_0->streams[0];",
"AVCodecContext *encctx = st->codec;",
"AVRational sar, dar;",
"int VAR_1, VAR_2;",
"int VAR_3 = SDL_SWSURFACE | sdl->window_fullscreen ? SDL_FULLSCREEN : 0;",
"if (!sdl->window_title)\nsdl->window_title = av_strdup(VAR_0->filename);",
"if (!sdl->icon_title)\nsdl->icon_title = av_strdup(sdl->window_title);",
"if (SDL_WasInit(SDL_INIT_VIDEO)) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"SDL video subsystem was already inited, aborting\\n\");",
"sdl->sdl_was_already_inited = 1;",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"if (SDL_Init(SDL_INIT_VIDEO) != 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unable to initialize SDL: %VAR_0\\n\", SDL_GetError());",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"if ( VAR_0->nb_streams > 1\n|| encctx->codec_type != AVMEDIA_TYPE_VIDEO\n|| encctx->codec_id != AV_CODEC_ID_RAWVIDEO) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Only supports one rawvideo stream\\n\");",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"for (VAR_1 = 0; sdl_overlay_pix_fmt_map[VAR_1].pix_fmt != AV_PIX_FMT_NONE; VAR_1++) {",
"if (sdl_overlay_pix_fmt_map[VAR_1].pix_fmt == encctx->pix_fmt) {",
"sdl->overlay_fmt = sdl_overlay_pix_fmt_map[VAR_1].overlay_fmt;",
"break;",
"}",
"}",
"if (!sdl->overlay_fmt) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported pixel format '%VAR_0', choose one of yuv420p, yuyv422, or uyvy422\\n\",\nav_get_pix_fmt_name(encctx->pix_fmt));",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };",
"dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });",
"if (sdl->window_width && sdl->window_height) {",
"if (av_cmp_q(dar, (AVRational){ sdl->window_width, sdl->window_height }) > 0) {",
"sdl->overlay_width = sdl->window_width;",
"sdl->overlay_height = av_rescale(sdl->overlay_width, dar.den, dar.num);",
"} else {",
"sdl->overlay_height = sdl->window_height;",
"sdl->overlay_width = av_rescale(sdl->overlay_height, dar.num, dar.den);",
"}",
"} else {",
"if (sar.num > sar.den) {",
"sdl->overlay_width = encctx->width;",
"sdl->overlay_height = av_rescale(sdl->overlay_width, dar.den, dar.num);",
"} else {",
"sdl->overlay_height = encctx->height;",
"sdl->overlay_width = av_rescale(sdl->overlay_height, dar.num, dar.den);",
"}",
"sdl->window_width = sdl->overlay_width;",
"sdl->window_height = sdl->overlay_height;",
"}",
"sdl->overlay_x = (sdl->window_width - sdl->overlay_width ) / 2;",
"sdl->overlay_y = (sdl->window_height - sdl->overlay_height) / 2;",
"SDL_WM_SetCaption(sdl->window_title, sdl->icon_title);",
"sdl->surface = SDL_SetVideoMode(sdl->window_width, sdl->window_height,\n24, VAR_3);",
"if (!sdl->surface) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unable to set video mode: %VAR_0\\n\", SDL_GetError());",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"sdl->overlay = SDL_CreateYUVOverlay(encctx->width, encctx->height,\nsdl->overlay_fmt, sdl->surface);",
"if (!sdl->overlay || sdl->overlay->pitches[0] < encctx->width) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"SDL does not support an overlay with size of %dx%d pixels\\n\",\nencctx->width, encctx->height);",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"av_log(VAR_0, AV_LOG_VERBOSE, \"w:%d h:%d fmt:%VAR_0 sar:%d/%d -> w:%d h:%d\\n\",\nencctx->width, encctx->height, av_get_pix_fmt_name(encctx->pix_fmt), sar.num, sar.den,\nsdl->overlay_width, sdl->overlay_height);",
"return 0;",
"fail:\nsdl_write_trailer(VAR_0);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
1,
1,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
1,
1,
1,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
23,
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89,
91,
93
],
[
95
],
[
97
],
[
99
],
[
105
],
[
107
],
[
113
],
[
117
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181,
183
],
[
185
],
[
187,
189,
191
],
[
193
],
[
195
],
[
197
],
[
201,
203,
205
],
[
207
],
[
211,
213
],
[
215
],
[
217
]
] |
19,456 | static void aux_bus_class_init(ObjectClass *klass, void *data)
{
BusClass *k = BUS_CLASS(klass);
/* AUXSlave has an MMIO so we need to change the way we print information
* in monitor.
*/
k->print_dev = aux_slave_dev_print;
}
| true | qemu | e0dadc1e9ef1f35208e5d2af9c7740c18a0b769f | static void aux_bus_class_init(ObjectClass *klass, void *data)
{
BusClass *k = BUS_CLASS(klass);
k->print_dev = aux_slave_dev_print;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
BusClass *k = BUS_CLASS(VAR_0);
k->print_dev = aux_slave_dev_print;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"BusClass *k = BUS_CLASS(VAR_0);",
"k->print_dev = aux_slave_dev_print;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
15
],
[
17
]
] |
19,457 | static int ape_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
APEContext *s = avctx->priv_data;
int16_t *samples = data;
int nblocks;
int i, n;
int blockstodecode;
int bytes_used;
if (buf_size == 0 && !s->samples) {
*data_size = 0;
return 0;
}
/* should not happen but who knows */
if (BLOCKS_PER_LOOP * 2 * avctx->channels > *data_size) {
av_log (avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc! (max is %d where you have %d)\n", *data_size, s->samples * 2 * avctx->channels);
return -1;
}
if(!s->samples){
s->data = av_realloc(s->data, (buf_size + 3) & ~3);
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
s->ptr = s->last_ptr = s->data;
s->data_end = s->data + buf_size;
nblocks = s->samples = bytestream_get_be32(&s->ptr);
n = bytestream_get_be32(&s->ptr);
if(n < 0 || n > 3){
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
s->data = NULL;
return -1;
}
s->ptr += n;
s->currentframeblocks = nblocks;
buf += 4;
if (s->samples <= 0) {
*data_size = 0;
return buf_size;
}
memset(s->decoded0, 0, sizeof(s->decoded0));
memset(s->decoded1, 0, sizeof(s->decoded1));
/* Initialize the frame decoder */
init_frame_decoder(s);
}
if (!s->data) {
*data_size = 0;
return buf_size;
}
nblocks = s->samples;
blockstodecode = FFMIN(BLOCKS_PER_LOOP, nblocks);
s->error=0;
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
ape_unpack_mono(s, blockstodecode);
else
ape_unpack_stereo(s, blockstodecode);
emms_c();
if(s->error || s->ptr > s->data_end){
s->samples=0;
av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
return -1;
}
for (i = 0; i < blockstodecode; i++) {
*samples++ = s->decoded0[i];
if(s->channels == 2)
*samples++ = s->decoded1[i];
}
s->samples -= blockstodecode;
*data_size = blockstodecode * 2 * s->channels;
bytes_used = s->samples ? s->ptr - s->last_ptr : buf_size;
s->last_ptr = s->ptr;
return bytes_used;
}
| false | FFmpeg | 3c25209bd9ee83eeb0373dcf790eb116e986f8e1 | static int ape_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
APEContext *s = avctx->priv_data;
int16_t *samples = data;
int nblocks;
int i, n;
int blockstodecode;
int bytes_used;
if (buf_size == 0 && !s->samples) {
*data_size = 0;
return 0;
}
if (BLOCKS_PER_LOOP * 2 * avctx->channels > *data_size) {
av_log (avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc! (max is %d where you have %d)\n", *data_size, s->samples * 2 * avctx->channels);
return -1;
}
if(!s->samples){
s->data = av_realloc(s->data, (buf_size + 3) & ~3);
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
s->ptr = s->last_ptr = s->data;
s->data_end = s->data + buf_size;
nblocks = s->samples = bytestream_get_be32(&s->ptr);
n = bytestream_get_be32(&s->ptr);
if(n < 0 || n > 3){
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
s->data = NULL;
return -1;
}
s->ptr += n;
s->currentframeblocks = nblocks;
buf += 4;
if (s->samples <= 0) {
*data_size = 0;
return buf_size;
}
memset(s->decoded0, 0, sizeof(s->decoded0));
memset(s->decoded1, 0, sizeof(s->decoded1));
init_frame_decoder(s);
}
if (!s->data) {
*data_size = 0;
return buf_size;
}
nblocks = s->samples;
blockstodecode = FFMIN(BLOCKS_PER_LOOP, nblocks);
s->error=0;
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
ape_unpack_mono(s, blockstodecode);
else
ape_unpack_stereo(s, blockstodecode);
emms_c();
if(s->error || s->ptr > s->data_end){
s->samples=0;
av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
return -1;
}
for (i = 0; i < blockstodecode; i++) {
*samples++ = s->decoded0[i];
if(s->channels == 2)
*samples++ = s->decoded1[i];
}
s->samples -= blockstodecode;
*data_size = blockstodecode * 2 * s->channels;
bytes_used = s->samples ? s->ptr - s->last_ptr : buf_size;
s->last_ptr = s->ptr;
return bytes_used;
}
| {
"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->size;
APEContext *s = VAR_0->priv_data;
int16_t *samples = VAR_1;
int VAR_6;
int VAR_7, VAR_8;
int VAR_9;
int VAR_10;
if (VAR_5 == 0 && !s->samples) {
*VAR_2 = 0;
return 0;
}
if (BLOCKS_PER_LOOP * 2 * VAR_0->channels > *VAR_2) {
av_log (VAR_0, AV_LOG_ERROR, "Packet size is too big to be handled in lavc! (max is %d where you have %d)\VAR_8", *VAR_2, s->samples * 2 * VAR_0->channels);
return -1;
}
if(!s->samples){
s->VAR_1 = av_realloc(s->VAR_1, (VAR_5 + 3) & ~3);
s->dsp.bswap_buf((uint32_t*)s->VAR_1, (const uint32_t*)VAR_4, VAR_5 >> 2);
s->ptr = s->last_ptr = s->VAR_1;
s->data_end = s->VAR_1 + VAR_5;
VAR_6 = s->samples = bytestream_get_be32(&s->ptr);
VAR_8 = bytestream_get_be32(&s->ptr);
if(VAR_8 < 0 || VAR_8 > 3){
av_log(VAR_0, AV_LOG_ERROR, "Incorrect offset passed\VAR_8");
s->VAR_1 = NULL;
return -1;
}
s->ptr += VAR_8;
s->currentframeblocks = VAR_6;
VAR_4 += 4;
if (s->samples <= 0) {
*VAR_2 = 0;
return VAR_5;
}
memset(s->decoded0, 0, sizeof(s->decoded0));
memset(s->decoded1, 0, sizeof(s->decoded1));
init_frame_decoder(s);
}
if (!s->VAR_1) {
*VAR_2 = 0;
return VAR_5;
}
VAR_6 = s->samples;
VAR_9 = FFMIN(BLOCKS_PER_LOOP, VAR_6);
s->error=0;
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
ape_unpack_mono(s, VAR_9);
else
ape_unpack_stereo(s, VAR_9);
emms_c();
if(s->error || s->ptr > s->data_end){
s->samples=0;
av_log(VAR_0, AV_LOG_ERROR, "Error decoding frame\VAR_8");
return -1;
}
for (VAR_7 = 0; VAR_7 < VAR_9; VAR_7++) {
*samples++ = s->decoded0[VAR_7];
if(s->channels == 2)
*samples++ = s->decoded1[VAR_7];
}
s->samples -= VAR_9;
*VAR_2 = VAR_9 * 2 * s->channels;
VAR_10 = s->samples ? s->ptr - s->last_ptr : VAR_5;
s->last_ptr = s->ptr;
return 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->size;",
"APEContext *s = VAR_0->priv_data;",
"int16_t *samples = VAR_1;",
"int VAR_6;",
"int VAR_7, VAR_8;",
"int VAR_9;",
"int VAR_10;",
"if (VAR_5 == 0 && !s->samples) {",
"*VAR_2 = 0;",
"return 0;",
"}",
"if (BLOCKS_PER_LOOP * 2 * VAR_0->channels > *VAR_2) {",
"av_log (VAR_0, AV_LOG_ERROR, \"Packet size is too big to be handled in lavc! (max is %d where you have %d)\\VAR_8\", *VAR_2, s->samples * 2 * VAR_0->channels);",
"return -1;",
"}",
"if(!s->samples){",
"s->VAR_1 = av_realloc(s->VAR_1, (VAR_5 + 3) & ~3);",
"s->dsp.bswap_buf((uint32_t*)s->VAR_1, (const uint32_t*)VAR_4, VAR_5 >> 2);",
"s->ptr = s->last_ptr = s->VAR_1;",
"s->data_end = s->VAR_1 + VAR_5;",
"VAR_6 = s->samples = bytestream_get_be32(&s->ptr);",
"VAR_8 = bytestream_get_be32(&s->ptr);",
"if(VAR_8 < 0 || VAR_8 > 3){",
"av_log(VAR_0, AV_LOG_ERROR, \"Incorrect offset passed\\VAR_8\");",
"s->VAR_1 = NULL;",
"return -1;",
"}",
"s->ptr += VAR_8;",
"s->currentframeblocks = VAR_6;",
"VAR_4 += 4;",
"if (s->samples <= 0) {",
"*VAR_2 = 0;",
"return VAR_5;",
"}",
"memset(s->decoded0, 0, sizeof(s->decoded0));",
"memset(s->decoded1, 0, sizeof(s->decoded1));",
"init_frame_decoder(s);",
"}",
"if (!s->VAR_1) {",
"*VAR_2 = 0;",
"return VAR_5;",
"}",
"VAR_6 = s->samples;",
"VAR_9 = FFMIN(BLOCKS_PER_LOOP, VAR_6);",
"s->error=0;",
"if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))\nape_unpack_mono(s, VAR_9);",
"else\nape_unpack_stereo(s, VAR_9);",
"emms_c();",
"if(s->error || s->ptr > s->data_end){",
"s->samples=0;",
"av_log(VAR_0, AV_LOG_ERROR, \"Error decoding frame\\VAR_8\");",
"return -1;",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_9; VAR_7++) {",
"*samples++ = s->decoded0[VAR_7];",
"if(s->channels == 2)\n*samples++ = s->decoded1[VAR_7];",
"}",
"s->samples -= VAR_9;",
"*VAR_2 = VAR_9 * 2 * s->channels;",
"VAR_10 = s->samples ? s->ptr - s->last_ptr : VAR_5;",
"s->last_ptr = s->ptr;",
"return 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,
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
],
[
27
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
123
],
[
127,
129
],
[
131,
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
]
] |
19,458 | static const UID *mxf_get_mpeg2_codec_ul(AVCodecContext *avctx)
{
int long_gop = avctx->gop_size > 1 || avctx->has_b_frames;
if (avctx->profile == 4) { // Main
if (avctx->level == 8) // Main
return &mxf_mpeg2_codec_uls[0+long_gop];
else if (avctx->level == 4) // High
return &mxf_mpeg2_codec_uls[4+long_gop];
else if (avctx->level == 6) // High 14
return &mxf_mpeg2_codec_uls[8+long_gop];
} else if (avctx->profile == 0) { // 422
if (avctx->level == 5) // Main
return &mxf_mpeg2_codec_uls[2+long_gop];
else if (avctx->level == 2) // High
return &mxf_mpeg2_codec_uls[6+long_gop];
}
return NULL;
}
| false | FFmpeg | b8b21dee0f0b4bcc1888067c497d6e838859d2cd | static const UID *mxf_get_mpeg2_codec_ul(AVCodecContext *avctx)
{
int long_gop = avctx->gop_size > 1 || avctx->has_b_frames;
if (avctx->profile == 4) {
if (avctx->level == 8)
return &mxf_mpeg2_codec_uls[0+long_gop];
else if (avctx->level == 4)
return &mxf_mpeg2_codec_uls[4+long_gop];
else if (avctx->level == 6) 14
return &mxf_mpeg2_codec_uls[8+long_gop];
} else if (avctx->profile == 0) {
if (avctx->level == 5)
return &mxf_mpeg2_codec_uls[2+long_gop];
else if (avctx->level == 2)
return &mxf_mpeg2_codec_uls[6+long_gop];
}
return NULL;
}
| {
"code": [],
"line_no": []
} | static const UID *FUNC_0(AVCodecContext *avctx)
{
int VAR_0 = avctx->gop_size > 1 || avctx->has_b_frames;
if (avctx->profile == 4) {
if (avctx->level == 8)
return &mxf_mpeg2_codec_uls[0+VAR_0];
else if (avctx->level == 4)
return &mxf_mpeg2_codec_uls[4+VAR_0];
else if (avctx->level == 6) 14
return &mxf_mpeg2_codec_uls[8+VAR_0];
} else if (avctx->profile == 0) {
if (avctx->level == 5)
return &mxf_mpeg2_codec_uls[2+VAR_0];
else if (avctx->level == 2)
return &mxf_mpeg2_codec_uls[6+VAR_0];
}
return NULL;
}
| [
"static const UID *FUNC_0(AVCodecContext *avctx)\n{",
"int VAR_0 = avctx->gop_size > 1 || avctx->has_b_frames;",
"if (avctx->profile == 4) {",
"if (avctx->level == 8)\nreturn &mxf_mpeg2_codec_uls[0+VAR_0];",
"else if (avctx->level == 4)\nreturn &mxf_mpeg2_codec_uls[4+VAR_0];",
"else if (avctx->level == 6) 14\nreturn &mxf_mpeg2_codec_uls[8+VAR_0];",
"} else if (avctx->profile == 0) {",
"if (avctx->level == 5)\nreturn &mxf_mpeg2_codec_uls[2+VAR_0];",
"else if (avctx->level == 2)\nreturn &mxf_mpeg2_codec_uls[6+VAR_0];",
"}",
"return NULL;",
"}"
] | [
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
]
] |
19,459 | static void free_packet_list(AVPacketList *pktl)
{
AVPacketList *cur;
while (pktl) {
cur = pktl;
pktl = cur->next;
av_free_packet(&cur->pkt);
av_free(cur);
}
}
| false | FFmpeg | 96dce6f7ceaa8d3c7eddd241213bec82e84e7f7a | static void free_packet_list(AVPacketList *pktl)
{
AVPacketList *cur;
while (pktl) {
cur = pktl;
pktl = cur->next;
av_free_packet(&cur->pkt);
av_free(cur);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVPacketList *VAR_0)
{
AVPacketList *cur;
while (VAR_0) {
cur = VAR_0;
VAR_0 = cur->next;
av_free_packet(&cur->pkt);
av_free(cur);
}
}
| [
"static void FUNC_0(AVPacketList *VAR_0)\n{",
"AVPacketList *cur;",
"while (VAR_0) {",
"cur = VAR_0;",
"VAR_0 = cur->next;",
"av_free_packet(&cur->pkt);",
"av_free(cur);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
19,460 | static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
int buf_size, void *data)
{
const AVFrame *pic = data;
int aligned_width = ((avctx->width + 47) / 48) * 48;
int stride = aligned_width * 8 / 3;
int h, w;
const uint16_t *y = (const uint16_t*)pic->data[0];
const uint16_t *u = (const uint16_t*)pic->data[1];
const uint16_t *v = (const uint16_t*)pic->data[2];
uint8_t *p = buf;
uint8_t *pdst = buf;
if (buf_size < aligned_width * avctx->height * 8 / 3) {
av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
return -1;
}
#define CLIP(v) av_clip(v, 4, 1019)
#define WRITE_PIXELS(a, b, c) \
do { \
val = CLIP(*a++); \
val |= (CLIP(*b++) << 10) | \
(CLIP(*c++) << 20); \
bytestream_put_le32(&p, val); \
} while (0)
for (h = 0; h < avctx->height; h++) {
uint32_t val;
for (w = 0; w < avctx->width - 5; w += 6) {
WRITE_PIXELS(u, y, v);
WRITE_PIXELS(y, u, y);
WRITE_PIXELS(v, y, u);
WRITE_PIXELS(y, v, y);
}
if (w < avctx->width - 1) {
WRITE_PIXELS(u, y, v);
val = CLIP(*y++);
if (w == avctx->width - 2)
bytestream_put_le32(&p, val);
}
if (w < avctx->width - 3) {
val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);
bytestream_put_le32(&p, val);
val = CLIP(*v++) | (CLIP(*y++) << 10);
bytestream_put_le32(&p, val);
}
pdst += stride;
memset(p, 0, pdst - p);
p = pdst;
y += pic->linesize[0] / 2 - avctx->width;
u += pic->linesize[1] / 2 - avctx->width / 2;
v += pic->linesize[2] / 2 - avctx->width / 2;
}
return p - buf;
}
| true | FFmpeg | c9dc66375b18590462f829a652d210c2e094693c | static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
int buf_size, void *data)
{
const AVFrame *pic = data;
int aligned_width = ((avctx->width + 47) / 48) * 48;
int stride = aligned_width * 8 / 3;
int h, w;
const uint16_t *y = (const uint16_t*)pic->data[0];
const uint16_t *u = (const uint16_t*)pic->data[1];
const uint16_t *v = (const uint16_t*)pic->data[2];
uint8_t *p = buf;
uint8_t *pdst = buf;
if (buf_size < aligned_width * avctx->height * 8 / 3) {
av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
return -1;
}
#define CLIP(v) av_clip(v, 4, 1019)
#define WRITE_PIXELS(a, b, c) \
do { \
val = CLIP(*a++); \
val |= (CLIP(*b++) << 10) | \
(CLIP(*c++) << 20); \
bytestream_put_le32(&p, val); \
} while (0)
for (h = 0; h < avctx->height; h++) {
uint32_t val;
for (w = 0; w < avctx->width - 5; w += 6) {
WRITE_PIXELS(u, y, v);
WRITE_PIXELS(y, u, y);
WRITE_PIXELS(v, y, u);
WRITE_PIXELS(y, v, y);
}
if (w < avctx->width - 1) {
WRITE_PIXELS(u, y, v);
val = CLIP(*y++);
if (w == avctx->width - 2)
bytestream_put_le32(&p, val);
}
if (w < avctx->width - 3) {
val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);
bytestream_put_le32(&p, val);
val = CLIP(*v++) | (CLIP(*y++) << 10);
bytestream_put_le32(&p, val);
}
pdst += stride;
memset(p, 0, pdst - p);
p = pdst;
y += pic->linesize[0] / 2 - avctx->width;
u += pic->linesize[1] / 2 - avctx->width / 2;
v += pic->linesize[2] / 2 - avctx->width / 2;
}
return p - buf;
}
| {
"code": [
" if (w < avctx->width - 3) {",
" val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);",
" bytestream_put_le32(&p, val);",
" val = CLIP(*v++) | (CLIP(*y++) << 10);",
" bytestream_put_le32(&p, val);"
],
"line_no": [
87,
89,
91,
95,
91
]
} | static int FUNC_0(AVCodecContext *VAR_0, unsigned char *VAR_1,
int VAR_2, void *VAR_3)
{
const AVFrame *VAR_4 = VAR_3;
int VAR_5 = ((VAR_0->width + 47) / 48) * 48;
int VAR_6 = VAR_5 * 8 / 3;
int VAR_7, VAR_8;
const uint16_t *VAR_9 = (const uint16_t*)VAR_4->VAR_3[0];
const uint16_t *VAR_10 = (const uint16_t*)VAR_4->VAR_3[1];
const uint16_t *VAR_11 = (const uint16_t*)VAR_4->VAR_3[2];
uint8_t *p = VAR_1;
uint8_t *pdst = VAR_1;
if (VAR_2 < VAR_5 * VAR_0->height * 8 / 3) {
av_log(VAR_0, AV_LOG_ERROR, "output buffer too small\n");
return -1;
}
#define CLIP(VAR_11) av_clip(VAR_11, 4, 1019)
#define WRITE_PIXELS(a, b, c) \
do { \
val = CLIP(*a++); \
val |= (CLIP(*b++) << 10) | \
(CLIP(*c++) << 20); \
bytestream_put_le32(&p, val); \
} while (0)
for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7++) {
uint32_t val;
for (VAR_8 = 0; VAR_8 < VAR_0->width - 5; VAR_8 += 6) {
WRITE_PIXELS(VAR_10, VAR_9, VAR_11);
WRITE_PIXELS(VAR_9, VAR_10, VAR_9);
WRITE_PIXELS(VAR_11, VAR_9, VAR_10);
WRITE_PIXELS(VAR_9, VAR_11, VAR_9);
}
if (VAR_8 < VAR_0->width - 1) {
WRITE_PIXELS(VAR_10, VAR_9, VAR_11);
val = CLIP(*VAR_9++);
if (VAR_8 == VAR_0->width - 2)
bytestream_put_le32(&p, val);
}
if (VAR_8 < VAR_0->width - 3) {
val |= (CLIP(*VAR_10++) << 10) | (CLIP(*VAR_9++) << 20);
bytestream_put_le32(&p, val);
val = CLIP(*VAR_11++) | (CLIP(*VAR_9++) << 10);
bytestream_put_le32(&p, val);
}
pdst += VAR_6;
memset(p, 0, pdst - p);
p = pdst;
VAR_9 += VAR_4->linesize[0] / 2 - VAR_0->width;
VAR_10 += VAR_4->linesize[1] / 2 - VAR_0->width / 2;
VAR_11 += VAR_4->linesize[2] / 2 - VAR_0->width / 2;
}
return p - VAR_1;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, unsigned char *VAR_1,\nint VAR_2, void *VAR_3)\n{",
"const AVFrame *VAR_4 = VAR_3;",
"int VAR_5 = ((VAR_0->width + 47) / 48) * 48;",
"int VAR_6 = VAR_5 * 8 / 3;",
"int VAR_7, VAR_8;",
"const uint16_t *VAR_9 = (const uint16_t*)VAR_4->VAR_3[0];",
"const uint16_t *VAR_10 = (const uint16_t*)VAR_4->VAR_3[1];",
"const uint16_t *VAR_11 = (const uint16_t*)VAR_4->VAR_3[2];",
"uint8_t *p = VAR_1;",
"uint8_t *pdst = VAR_1;",
"if (VAR_2 < VAR_5 * VAR_0->height * 8 / 3) {",
"av_log(VAR_0, AV_LOG_ERROR, \"output buffer too small\\n\");",
"return -1;",
"}",
"#define CLIP(VAR_11) av_clip(VAR_11, 4, 1019)\n#define WRITE_PIXELS(a, b, c) \\\ndo { \\",
"val = CLIP(*a++); \\",
"val |= (CLIP(*b++) << 10) | \\\n(CLIP(*c++) << 20); \\",
"bytestream_put_le32(&p, val); \\",
"} while (0)",
"for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7++) {",
"uint32_t val;",
"for (VAR_8 = 0; VAR_8 < VAR_0->width - 5; VAR_8 += 6) {",
"WRITE_PIXELS(VAR_10, VAR_9, VAR_11);",
"WRITE_PIXELS(VAR_9, VAR_10, VAR_9);",
"WRITE_PIXELS(VAR_11, VAR_9, VAR_10);",
"WRITE_PIXELS(VAR_9, VAR_11, VAR_9);",
"}",
"if (VAR_8 < VAR_0->width - 1) {",
"WRITE_PIXELS(VAR_10, VAR_9, VAR_11);",
"val = CLIP(*VAR_9++);",
"if (VAR_8 == VAR_0->width - 2)\nbytestream_put_le32(&p, val);",
"}",
"if (VAR_8 < VAR_0->width - 3) {",
"val |= (CLIP(*VAR_10++) << 10) | (CLIP(*VAR_9++) << 20);",
"bytestream_put_le32(&p, val);",
"val = CLIP(*VAR_11++) | (CLIP(*VAR_9++) << 10);",
"bytestream_put_le32(&p, val);",
"}",
"pdst += VAR_6;",
"memset(p, 0, pdst - p);",
"p = pdst;",
"VAR_9 += VAR_4->linesize[0] / 2 - VAR_0->width;",
"VAR_10 += VAR_4->linesize[1] / 2 - VAR_0->width / 2;",
"VAR_11 += VAR_4->linesize[2] / 2 - VAR_0->width / 2;",
"}",
"return p - 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,
1,
1,
1,
1,
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
],
[
31
],
[
33
],
[
37,
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
]
] |
19,461 | static void pc_init_pci_no_kvmclock(MachineState *machine)
{
has_pci_info = false;
has_acpi_build = false;
smbios_defaults = false;
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
enable_compat_apic_id_mode();
pc_init1(machine, 1, 0);
} | true | qemu | 5f8632d3c3d7bc5ef24166ba7cf90fcfb2adbf7d | static void pc_init_pci_no_kvmclock(MachineState *machine)
{
has_pci_info = false;
has_acpi_build = false;
smbios_defaults = false;
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
enable_compat_apic_id_mode();
pc_init1(machine, 1, 0);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(MachineState *VAR_0)
{
has_pci_info = false;
has_acpi_build = false;
smbios_defaults = false;
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
enable_compat_apic_id_mode();
pc_init1(VAR_0, 1, 0);
} | [
"static void FUNC_0(MachineState *VAR_0)\n{",
"has_pci_info = false;",
"has_acpi_build = false;",
"smbios_defaults = false;",
"x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);",
"enable_compat_apic_id_mode();",
"pc_init1(VAR_0, 1, 0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
16
],
[
18
],
[
20
],
[
22
]
] |
19,463 | static void ide_sector_read_cb(void *opaque, int ret)
{
IDEState *s = opaque;
int n;
s->pio_aiocb = NULL;
s->status &= ~BUSY_STAT;
if (ret == -ECANCELED) {
return;
}
block_acct_done(blk_get_stats(s->blk), &s->acct);
if (ret != 0) {
if (ide_handle_rw_error(s, -ret, IDE_RETRY_PIO |
IDE_RETRY_READ)) {
return;
}
}
n = s->nsector;
if (n > s->req_nb_sectors) {
n = s->req_nb_sectors;
}
ide_set_sector(s, ide_get_sector(s) + n);
s->nsector -= n;
/* Allow the guest to read the io_buffer */
ide_transfer_start(s, s->io_buffer, n * BDRV_SECTOR_SIZE, ide_sector_read);
ide_set_irq(s->bus);
}
| true | qemu | ecca3b397d06a957b18913ff9afc63860001cfdf | static void ide_sector_read_cb(void *opaque, int ret)
{
IDEState *s = opaque;
int n;
s->pio_aiocb = NULL;
s->status &= ~BUSY_STAT;
if (ret == -ECANCELED) {
return;
}
block_acct_done(blk_get_stats(s->blk), &s->acct);
if (ret != 0) {
if (ide_handle_rw_error(s, -ret, IDE_RETRY_PIO |
IDE_RETRY_READ)) {
return;
}
}
n = s->nsector;
if (n > s->req_nb_sectors) {
n = s->req_nb_sectors;
}
ide_set_sector(s, ide_get_sector(s) + n);
s->nsector -= n;
ide_transfer_start(s, s->io_buffer, n * BDRV_SECTOR_SIZE, ide_sector_read);
ide_set_irq(s->bus);
}
| {
"code": [
" block_acct_done(blk_get_stats(s->blk), &s->acct);",
" block_acct_done(blk_get_stats(s->blk), &s->acct);"
],
"line_no": [
23,
23
]
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
IDEState *s = VAR_0;
int VAR_2;
s->pio_aiocb = NULL;
s->status &= ~BUSY_STAT;
if (VAR_1 == -ECANCELED) {
return;
}
block_acct_done(blk_get_stats(s->blk), &s->acct);
if (VAR_1 != 0) {
if (ide_handle_rw_error(s, -VAR_1, IDE_RETRY_PIO |
IDE_RETRY_READ)) {
return;
}
}
VAR_2 = s->nsector;
if (VAR_2 > s->req_nb_sectors) {
VAR_2 = s->req_nb_sectors;
}
ide_set_sector(s, ide_get_sector(s) + VAR_2);
s->nsector -= VAR_2;
ide_transfer_start(s, s->io_buffer, VAR_2 * BDRV_SECTOR_SIZE, ide_sector_read);
ide_set_irq(s->bus);
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"IDEState *s = VAR_0;",
"int VAR_2;",
"s->pio_aiocb = NULL;",
"s->status &= ~BUSY_STAT;",
"if (VAR_1 == -ECANCELED) {",
"return;",
"}",
"block_acct_done(blk_get_stats(s->blk), &s->acct);",
"if (VAR_1 != 0) {",
"if (ide_handle_rw_error(s, -VAR_1, IDE_RETRY_PIO |\nIDE_RETRY_READ)) {",
"return;",
"}",
"}",
"VAR_2 = s->nsector;",
"if (VAR_2 > s->req_nb_sectors) {",
"VAR_2 = s->req_nb_sectors;",
"}",
"ide_set_sector(s, ide_get_sector(s) + VAR_2);",
"s->nsector -= VAR_2;",
"ide_transfer_start(s, s->io_buffer, VAR_2 * BDRV_SECTOR_SIZE, ide_sector_read);",
"ide_set_irq(s->bus);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
]
] |
19,464 | av_cold void INIT_FUNC(VP9DSPContext *dsp, int bitexact)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
#define init_lpf_8_func(idx1, idx2, dir, wd, bpp, opt) \
dsp->loop_filter_8[idx1][idx2] = ff_vp9_loop_filter_##dir##_##wd##_##bpp##_##opt
#define init_lpf_16_func(idx, dir, bpp, opt) \
dsp->loop_filter_16[idx] = loop_filter_##dir##_16_##bpp##_##opt
#define init_lpf_mix2_func(idx1, idx2, idx3, dir, wd1, wd2, bpp, opt) \
dsp->loop_filter_mix2[idx1][idx2][idx3] = loop_filter_##dir##_##wd1##wd2##_##bpp##_##opt
#define init_lpf_funcs(bpp, opt) \
init_lpf_8_func(0, 0, h, 4, bpp, opt); \
init_lpf_8_func(0, 1, v, 4, bpp, opt); \
init_lpf_8_func(1, 0, h, 8, bpp, opt); \
init_lpf_8_func(1, 1, v, 8, bpp, opt); \
init_lpf_8_func(2, 0, h, 16, bpp, opt); \
init_lpf_8_func(2, 1, v, 16, bpp, opt); \
init_lpf_16_func(0, h, bpp, opt); \
init_lpf_16_func(1, v, bpp, opt); \
init_lpf_mix2_func(0, 0, 0, h, 4, 4, bpp, opt); \
init_lpf_mix2_func(0, 1, 0, h, 4, 8, bpp, opt); \
init_lpf_mix2_func(1, 0, 0, h, 8, 4, bpp, opt); \
init_lpf_mix2_func(1, 1, 0, h, 8, 8, bpp, opt); \
init_lpf_mix2_func(0, 0, 1, v, 4, 4, bpp, opt); \
init_lpf_mix2_func(0, 1, 1, v, 4, 8, bpp, opt); \
init_lpf_mix2_func(1, 0, 1, v, 8, 4, bpp, opt); \
init_lpf_mix2_func(1, 1, 1, v, 8, 8, bpp, opt)
#define init_itx_func(idxa, idxb, typea, typeb, size, bpp, opt) \
dsp->itxfm_add[idxa][idxb] = \
ff_vp9_##typea##_##typeb##_##size##x##size##_add_##bpp##_##opt;
#define init_itx_func_one(idx, typea, typeb, size, bpp, opt) \
init_itx_func(idx, DCT_DCT, typea, typeb, size, bpp, opt); \
init_itx_func(idx, ADST_DCT, typea, typeb, size, bpp, opt); \
init_itx_func(idx, DCT_ADST, typea, typeb, size, bpp, opt); \
init_itx_func(idx, ADST_ADST, typea, typeb, size, bpp, opt)
#define init_itx_funcs(idx, size, bpp, opt) \
init_itx_func(idx, DCT_DCT, idct, idct, size, bpp, opt); \
init_itx_func(idx, ADST_DCT, idct, iadst, size, bpp, opt); \
init_itx_func(idx, DCT_ADST, iadst, idct, size, bpp, opt); \
init_itx_func(idx, ADST_ADST, iadst, iadst, size, bpp, opt); \
if (EXTERNAL_MMXEXT(cpu_flags)) {
init_ipred_func(tm, TM_VP8, 4, BPC, mmxext);
if (!bitexact) {
init_itx_func_one(4 /* lossless */, iwht, iwht, 4, BPC, mmxext);
#if BPC == 10
init_itx_func(TX_4X4, DCT_DCT, idct, idct, 4, 10, mmxext);
#endif
}
}
if (EXTERNAL_SSE2(cpu_flags)) {
init_subpel3(0, put, BPC, sse2);
init_subpel3(1, avg, BPC, sse2);
init_lpf_funcs(BPC, sse2);
init_8_16_32_ipred_funcs(tm, TM_VP8, BPC, sse2);
#if BPC == 10
if (!bitexact) {
init_itx_func(TX_4X4, ADST_DCT, idct, iadst, 4, 10, sse2);
init_itx_func(TX_4X4, DCT_ADST, iadst, idct, 4, 10, sse2);
init_itx_func(TX_4X4, ADST_ADST, iadst, iadst, 4, 10, sse2);
}
#endif
}
if (EXTERNAL_SSSE3(cpu_flags)) {
init_lpf_funcs(BPC, ssse3);
#if BPC == 10
if (!bitexact) {
init_itx_funcs(TX_4X4, 4, BPC, ssse3);
}
#endif
}
if (EXTERNAL_AVX(cpu_flags)) {
init_lpf_funcs(BPC, avx);
}
if (EXTERNAL_AVX2(cpu_flags)) {
#if HAVE_AVX2_EXTERNAL
init_subpel3_32_64(0, put, BPC, avx2);
init_subpel3_32_64(1, avg, BPC, avx2);
init_subpel2(2, 0, 16, put, BPC, avx2);
init_subpel2(2, 1, 16, avg, BPC, avx2);
#endif
}
#endif /* HAVE_YASM */
ff_vp9dsp_init_16bpp_x86(dsp);
} | true | FFmpeg | 235e76aeb877bd1b23c12e74588e86752e3dfbe7 | av_cold void INIT_FUNC(VP9DSPContext *dsp, int bitexact)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
#define init_lpf_8_func(idx1, idx2, dir, wd, bpp, opt) \
dsp->loop_filter_8[idx1][idx2] = ff_vp9_loop_filter_##dir##_##wd##_##bpp##_##opt
#define init_lpf_16_func(idx, dir, bpp, opt) \
dsp->loop_filter_16[idx] = loop_filter_##dir##_16_##bpp##_##opt
#define init_lpf_mix2_func(idx1, idx2, idx3, dir, wd1, wd2, bpp, opt) \
dsp->loop_filter_mix2[idx1][idx2][idx3] = loop_filter_##dir##_##wd1##wd2##_##bpp##_##opt
#define init_lpf_funcs(bpp, opt) \
init_lpf_8_func(0, 0, h, 4, bpp, opt); \
init_lpf_8_func(0, 1, v, 4, bpp, opt); \
init_lpf_8_func(1, 0, h, 8, bpp, opt); \
init_lpf_8_func(1, 1, v, 8, bpp, opt); \
init_lpf_8_func(2, 0, h, 16, bpp, opt); \
init_lpf_8_func(2, 1, v, 16, bpp, opt); \
init_lpf_16_func(0, h, bpp, opt); \
init_lpf_16_func(1, v, bpp, opt); \
init_lpf_mix2_func(0, 0, 0, h, 4, 4, bpp, opt); \
init_lpf_mix2_func(0, 1, 0, h, 4, 8, bpp, opt); \
init_lpf_mix2_func(1, 0, 0, h, 8, 4, bpp, opt); \
init_lpf_mix2_func(1, 1, 0, h, 8, 8, bpp, opt); \
init_lpf_mix2_func(0, 0, 1, v, 4, 4, bpp, opt); \
init_lpf_mix2_func(0, 1, 1, v, 4, 8, bpp, opt); \
init_lpf_mix2_func(1, 0, 1, v, 8, 4, bpp, opt); \
init_lpf_mix2_func(1, 1, 1, v, 8, 8, bpp, opt)
#define init_itx_func(idxa, idxb, typea, typeb, size, bpp, opt) \
dsp->itxfm_add[idxa][idxb] = \
ff_vp9_##typea##_##typeb##_##size##x##size##_add_##bpp##_##opt;
#define init_itx_func_one(idx, typea, typeb, size, bpp, opt) \
init_itx_func(idx, DCT_DCT, typea, typeb, size, bpp, opt); \
init_itx_func(idx, ADST_DCT, typea, typeb, size, bpp, opt); \
init_itx_func(idx, DCT_ADST, typea, typeb, size, bpp, opt); \
init_itx_func(idx, ADST_ADST, typea, typeb, size, bpp, opt)
#define init_itx_funcs(idx, size, bpp, opt) \
init_itx_func(idx, DCT_DCT, idct, idct, size, bpp, opt); \
init_itx_func(idx, ADST_DCT, idct, iadst, size, bpp, opt); \
init_itx_func(idx, DCT_ADST, iadst, idct, size, bpp, opt); \
init_itx_func(idx, ADST_ADST, iadst, iadst, size, bpp, opt); \
if (EXTERNAL_MMXEXT(cpu_flags)) {
init_ipred_func(tm, TM_VP8, 4, BPC, mmxext);
if (!bitexact) {
init_itx_func_one(4 , iwht, iwht, 4, BPC, mmxext);
#if BPC == 10
init_itx_func(TX_4X4, DCT_DCT, idct, idct, 4, 10, mmxext);
#endif
}
}
if (EXTERNAL_SSE2(cpu_flags)) {
init_subpel3(0, put, BPC, sse2);
init_subpel3(1, avg, BPC, sse2);
init_lpf_funcs(BPC, sse2);
init_8_16_32_ipred_funcs(tm, TM_VP8, BPC, sse2);
#if BPC == 10
if (!bitexact) {
init_itx_func(TX_4X4, ADST_DCT, idct, iadst, 4, 10, sse2);
init_itx_func(TX_4X4, DCT_ADST, iadst, idct, 4, 10, sse2);
init_itx_func(TX_4X4, ADST_ADST, iadst, iadst, 4, 10, sse2);
}
#endif
}
if (EXTERNAL_SSSE3(cpu_flags)) {
init_lpf_funcs(BPC, ssse3);
#if BPC == 10
if (!bitexact) {
init_itx_funcs(TX_4X4, 4, BPC, ssse3);
}
#endif
}
if (EXTERNAL_AVX(cpu_flags)) {
init_lpf_funcs(BPC, avx);
}
if (EXTERNAL_AVX2(cpu_flags)) {
#if HAVE_AVX2_EXTERNAL
init_subpel3_32_64(0, put, BPC, avx2);
init_subpel3_32_64(1, avg, BPC, avx2);
init_subpel2(2, 0, 16, put, BPC, avx2);
init_subpel2(2, 1, 16, avg, BPC, avx2);
#endif
}
#endif
ff_vp9dsp_init_16bpp_x86(dsp);
} | {
"code": [],
"line_no": []
} | av_cold void FUNC_0(VP9DSPContext *dsp, int bitexact)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
#define init_lpf_8_func(idx1, idx2, dir, wd, bpp, opt) \
dsp->loop_filter_8[idx1][idx2] = ff_vp9_loop_filter_##dir##_##wd##_##bpp##_##opt
#define init_lpf_16_func(idx, dir, bpp, opt) \
dsp->loop_filter_16[idx] = loop_filter_##dir##_16_##bpp##_##opt
#define init_lpf_mix2_func(idx1, idx2, idx3, dir, wd1, wd2, bpp, opt) \
dsp->loop_filter_mix2[idx1][idx2][idx3] = loop_filter_##dir##_##wd1##wd2##_##bpp##_##opt
#define init_lpf_funcs(bpp, opt) \
init_lpf_8_func(0, 0, h, 4, bpp, opt); \
init_lpf_8_func(0, 1, v, 4, bpp, opt); \
init_lpf_8_func(1, 0, h, 8, bpp, opt); \
init_lpf_8_func(1, 1, v, 8, bpp, opt); \
init_lpf_8_func(2, 0, h, 16, bpp, opt); \
init_lpf_8_func(2, 1, v, 16, bpp, opt); \
init_lpf_16_func(0, h, bpp, opt); \
init_lpf_16_func(1, v, bpp, opt); \
init_lpf_mix2_func(0, 0, 0, h, 4, 4, bpp, opt); \
init_lpf_mix2_func(0, 1, 0, h, 4, 8, bpp, opt); \
init_lpf_mix2_func(1, 0, 0, h, 8, 4, bpp, opt); \
init_lpf_mix2_func(1, 1, 0, h, 8, 8, bpp, opt); \
init_lpf_mix2_func(0, 0, 1, v, 4, 4, bpp, opt); \
init_lpf_mix2_func(0, 1, 1, v, 4, 8, bpp, opt); \
init_lpf_mix2_func(1, 0, 1, v, 8, 4, bpp, opt); \
init_lpf_mix2_func(1, 1, 1, v, 8, 8, bpp, opt)
#define init_itx_func(idxa, idxb, typea, typeb, size, bpp, opt) \
dsp->itxfm_add[idxa][idxb] = \
ff_vp9_##typea##_##typeb##_##size##x##size##_add_##bpp##_##opt;
#define init_itx_func_one(idx, typea, typeb, size, bpp, opt) \
init_itx_func(idx, DCT_DCT, typea, typeb, size, bpp, opt); \
init_itx_func(idx, ADST_DCT, typea, typeb, size, bpp, opt); \
init_itx_func(idx, DCT_ADST, typea, typeb, size, bpp, opt); \
init_itx_func(idx, ADST_ADST, typea, typeb, size, bpp, opt)
#define init_itx_funcs(idx, size, bpp, opt) \
init_itx_func(idx, DCT_DCT, idct, idct, size, bpp, opt); \
init_itx_func(idx, ADST_DCT, idct, iadst, size, bpp, opt); \
init_itx_func(idx, DCT_ADST, iadst, idct, size, bpp, opt); \
init_itx_func(idx, ADST_ADST, iadst, iadst, size, bpp, opt); \
if (EXTERNAL_MMXEXT(cpu_flags)) {
init_ipred_func(tm, TM_VP8, 4, BPC, mmxext);
if (!bitexact) {
init_itx_func_one(4 , iwht, iwht, 4, BPC, mmxext);
#if BPC == 10
init_itx_func(TX_4X4, DCT_DCT, idct, idct, 4, 10, mmxext);
#endif
}
}
if (EXTERNAL_SSE2(cpu_flags)) {
init_subpel3(0, put, BPC, sse2);
init_subpel3(1, avg, BPC, sse2);
init_lpf_funcs(BPC, sse2);
init_8_16_32_ipred_funcs(tm, TM_VP8, BPC, sse2);
#if BPC == 10
if (!bitexact) {
init_itx_func(TX_4X4, ADST_DCT, idct, iadst, 4, 10, sse2);
init_itx_func(TX_4X4, DCT_ADST, iadst, idct, 4, 10, sse2);
init_itx_func(TX_4X4, ADST_ADST, iadst, iadst, 4, 10, sse2);
}
#endif
}
if (EXTERNAL_SSSE3(cpu_flags)) {
init_lpf_funcs(BPC, ssse3);
#if BPC == 10
if (!bitexact) {
init_itx_funcs(TX_4X4, 4, BPC, ssse3);
}
#endif
}
if (EXTERNAL_AVX(cpu_flags)) {
init_lpf_funcs(BPC, avx);
}
if (EXTERNAL_AVX2(cpu_flags)) {
#if HAVE_AVX2_EXTERNAL
init_subpel3_32_64(0, put, BPC, avx2);
init_subpel3_32_64(1, avg, BPC, avx2);
init_subpel2(2, 0, 16, put, BPC, avx2);
init_subpel2(2, 1, 16, avg, BPC, avx2);
#endif
}
#endif
ff_vp9dsp_init_16bpp_x86(dsp);
} | [
"av_cold void FUNC_0(VP9DSPContext *dsp, int bitexact)\n{",
"#if HAVE_YASM\nint cpu_flags = av_get_cpu_flags();",
"#define init_lpf_8_func(idx1, idx2, dir, wd, bpp, opt) \\\ndsp->loop_filter_8[idx1][idx2] = ff_vp9_loop_filter_##dir##_##wd##_##bpp##_##opt\n#define init_lpf_16_func(idx, dir, bpp, opt) \\\ndsp->loop_filter_16[idx] = loop_filter_##dir##_16_##bpp##_##opt\n#define init_lpf_mix2_func(idx1, idx2, idx3, dir, wd1, wd2, bpp, opt) \\\ndsp->loop_filter_mix2[idx1][idx2][idx3] = loop_filter_##dir##_##wd1##wd2##_##bpp##_##opt\n#define init_lpf_funcs(bpp, opt) \\\ninit_lpf_8_func(0, 0, h, 4, bpp, opt); \\",
"init_lpf_8_func(0, 1, v, 4, bpp, opt); \\",
"init_lpf_8_func(1, 0, h, 8, bpp, opt); \\",
"init_lpf_8_func(1, 1, v, 8, bpp, opt); \\",
"init_lpf_8_func(2, 0, h, 16, bpp, opt); \\",
"init_lpf_8_func(2, 1, v, 16, bpp, opt); \\",
"init_lpf_16_func(0, h, bpp, opt); \\",
"init_lpf_16_func(1, v, bpp, opt); \\",
"init_lpf_mix2_func(0, 0, 0, h, 4, 4, bpp, opt); \\",
"init_lpf_mix2_func(0, 1, 0, h, 4, 8, bpp, opt); \\",
"init_lpf_mix2_func(1, 0, 0, h, 8, 4, bpp, opt); \\",
"init_lpf_mix2_func(1, 1, 0, h, 8, 8, bpp, opt); \\",
"init_lpf_mix2_func(0, 0, 1, v, 4, 4, bpp, opt); \\",
"init_lpf_mix2_func(0, 1, 1, v, 4, 8, bpp, opt); \\",
"init_lpf_mix2_func(1, 0, 1, v, 8, 4, bpp, opt); \\",
"init_lpf_mix2_func(1, 1, 1, v, 8, 8, bpp, opt)\n#define init_itx_func(idxa, idxb, typea, typeb, size, bpp, opt) \\\ndsp->itxfm_add[idxa][idxb] = \\\nff_vp9_##typea##_##typeb##_##size##x##size##_add_##bpp##_##opt;",
"#define init_itx_func_one(idx, typea, typeb, size, bpp, opt) \\\ninit_itx_func(idx, DCT_DCT, typea, typeb, size, bpp, opt); \\",
"init_itx_func(idx, ADST_DCT, typea, typeb, size, bpp, opt); \\",
"init_itx_func(idx, DCT_ADST, typea, typeb, size, bpp, opt); \\",
"init_itx_func(idx, ADST_ADST, typea, typeb, size, bpp, opt)\n#define init_itx_funcs(idx, size, bpp, opt) \\\ninit_itx_func(idx, DCT_DCT, idct, idct, size, bpp, opt); \\",
"init_itx_func(idx, ADST_DCT, idct, iadst, size, bpp, opt); \\",
"init_itx_func(idx, DCT_ADST, iadst, idct, size, bpp, opt); \\",
"init_itx_func(idx, ADST_ADST, iadst, iadst, size, bpp, opt); \\",
"if (EXTERNAL_MMXEXT(cpu_flags)) {",
"init_ipred_func(tm, TM_VP8, 4, BPC, mmxext);",
"if (!bitexact) {",
"init_itx_func_one(4 , iwht, iwht, 4, BPC, mmxext);",
"#if BPC == 10\ninit_itx_func(TX_4X4, DCT_DCT, idct, idct, 4, 10, mmxext);",
"#endif\n}",
"}",
"if (EXTERNAL_SSE2(cpu_flags)) {",
"init_subpel3(0, put, BPC, sse2);",
"init_subpel3(1, avg, BPC, sse2);",
"init_lpf_funcs(BPC, sse2);",
"init_8_16_32_ipred_funcs(tm, TM_VP8, BPC, sse2);",
"#if BPC == 10\nif (!bitexact) {",
"init_itx_func(TX_4X4, ADST_DCT, idct, iadst, 4, 10, sse2);",
"init_itx_func(TX_4X4, DCT_ADST, iadst, idct, 4, 10, sse2);",
"init_itx_func(TX_4X4, ADST_ADST, iadst, iadst, 4, 10, sse2);",
"}",
"#endif\n}",
"if (EXTERNAL_SSSE3(cpu_flags)) {",
"init_lpf_funcs(BPC, ssse3);",
"#if BPC == 10\nif (!bitexact) {",
"init_itx_funcs(TX_4X4, 4, BPC, ssse3);",
"}",
"#endif\n}",
"if (EXTERNAL_AVX(cpu_flags)) {",
"init_lpf_funcs(BPC, avx);",
"}",
"if (EXTERNAL_AVX2(cpu_flags)) {",
"#if HAVE_AVX2_EXTERNAL\ninit_subpel3_32_64(0, put, BPC, avx2);",
"init_subpel3_32_64(1, avg, BPC, avx2);",
"init_subpel2(2, 0, 16, put, BPC, avx2);",
"init_subpel2(2, 1, 16, avg, BPC, avx2);",
"#endif\n}",
"#endif\nff_vp9dsp_init_16bpp_x86(dsp);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
61,
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
75,
77,
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101,
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133,
135
],
[
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
151,
153
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177,
179
],
[
183,
187
],
[
189
]
] |
19,465 | static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int type, int length)
{
int buf_size = FFMAX(2*length, LEN_PRETTY_GUID) + 1;
char *buf = av_malloc(buf_size);
if (!buf)
return;
if (type == 0 && length == 4) {
snprintf(buf, buf_size, "%"PRIi32, avio_rl32(pb));
} else if (type == 1) {
avio_get_str16le(pb, length, buf, buf_size);
if (!strlen(buf)) {
av_free(buf);
return;
}
} else if (type == 3 && length == 4) {
strcpy(buf, avio_rl32(pb) ? "true" : "false");
} else if (type == 4 && length == 8) {
int64_t num = avio_rl64(pb);
if (!strcmp(key, "WM/EncodingTime") ||
!strcmp(key, "WM/MediaOriginalBroadcastDateTime"))
filetime_to_iso8601(buf, buf_size, num);
else if (!strcmp(key, "WM/WMRVEncodeTime") ||
!strcmp(key, "WM/WMRVEndTime"))
crazytime_to_iso8601(buf, buf_size, num);
else if (!strcmp(key, "WM/WMRVExpirationDate"))
oledate_to_iso8601(buf, buf_size, num);
else if (!strcmp(key, "WM/WMRVBitrate"))
snprintf(buf, buf_size, "%f", av_int2dbl(num));
else
snprintf(buf, buf_size, "%"PRIi64, num);
} else if (type == 5 && length == 2) {
snprintf(buf, buf_size, "%"PRIi16, avio_rl16(pb));
} else if (type == 6 && length == 16) {
ff_asf_guid guid;
avio_read(pb, guid, 16);
snprintf(buf, buf_size, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid));
} else if (type == 2 && !strcmp(key, "WM/Picture")) {
get_attachment(s, pb, length);
av_freep(&buf);
return;
} else {
av_freep(&buf);
av_log(s, AV_LOG_WARNING, "unsupported metadata entry; key:%s, type:%d, length:0x%x\n", key, type, length);
avio_skip(pb, length);
return;
}
av_metadata_set2(&s->metadata, key, buf, 0);
av_freep(&buf);
}
| true | FFmpeg | 8acab7ae5bbcb589c556425453ac3d851d35021f | static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int type, int length)
{
int buf_size = FFMAX(2*length, LEN_PRETTY_GUID) + 1;
char *buf = av_malloc(buf_size);
if (!buf)
return;
if (type == 0 && length == 4) {
snprintf(buf, buf_size, "%"PRIi32, avio_rl32(pb));
} else if (type == 1) {
avio_get_str16le(pb, length, buf, buf_size);
if (!strlen(buf)) {
av_free(buf);
return;
}
} else if (type == 3 && length == 4) {
strcpy(buf, avio_rl32(pb) ? "true" : "false");
} else if (type == 4 && length == 8) {
int64_t num = avio_rl64(pb);
if (!strcmp(key, "WM/EncodingTime") ||
!strcmp(key, "WM/MediaOriginalBroadcastDateTime"))
filetime_to_iso8601(buf, buf_size, num);
else if (!strcmp(key, "WM/WMRVEncodeTime") ||
!strcmp(key, "WM/WMRVEndTime"))
crazytime_to_iso8601(buf, buf_size, num);
else if (!strcmp(key, "WM/WMRVExpirationDate"))
oledate_to_iso8601(buf, buf_size, num);
else if (!strcmp(key, "WM/WMRVBitrate"))
snprintf(buf, buf_size, "%f", av_int2dbl(num));
else
snprintf(buf, buf_size, "%"PRIi64, num);
} else if (type == 5 && length == 2) {
snprintf(buf, buf_size, "%"PRIi16, avio_rl16(pb));
} else if (type == 6 && length == 16) {
ff_asf_guid guid;
avio_read(pb, guid, 16);
snprintf(buf, buf_size, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid));
} else if (type == 2 && !strcmp(key, "WM/Picture")) {
get_attachment(s, pb, length);
av_freep(&buf);
return;
} else {
av_freep(&buf);
av_log(s, AV_LOG_WARNING, "unsupported metadata entry; key:%s, type:%d, length:0x%x\n", key, type, length);
avio_skip(pb, length);
return;
}
av_metadata_set2(&s->metadata, key, buf, 0);
av_freep(&buf);
}
| {
"code": [
" else if (!strcmp(key, \"WM/WMRVExpirationDate\"))",
" oledate_to_iso8601(buf, buf_size, num);",
" else if (!strcmp(key, \"WM/WMRVBitrate\"))"
],
"line_no": [
51,
53,
55
]
} | static void FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, const char *VAR_2, int VAR_3, int VAR_4)
{
int VAR_5 = FFMAX(2*VAR_4, LEN_PRETTY_GUID) + 1;
char *VAR_6 = av_malloc(VAR_5);
if (!VAR_6)
return;
if (VAR_3 == 0 && VAR_4 == 4) {
snprintf(VAR_6, VAR_5, "%"PRIi32, avio_rl32(VAR_1));
} else if (VAR_3 == 1) {
avio_get_str16le(VAR_1, VAR_4, VAR_6, VAR_5);
if (!strlen(VAR_6)) {
av_free(VAR_6);
return;
}
} else if (VAR_3 == 3 && VAR_4 == 4) {
strcpy(VAR_6, avio_rl32(VAR_1) ? "true" : "false");
} else if (VAR_3 == 4 && VAR_4 == 8) {
int64_t num = avio_rl64(VAR_1);
if (!strcmp(VAR_2, "WM/EncodingTime") ||
!strcmp(VAR_2, "WM/MediaOriginalBroadcastDateTime"))
filetime_to_iso8601(VAR_6, VAR_5, num);
else if (!strcmp(VAR_2, "WM/WMRVEncodeTime") ||
!strcmp(VAR_2, "WM/WMRVEndTime"))
crazytime_to_iso8601(VAR_6, VAR_5, num);
else if (!strcmp(VAR_2, "WM/WMRVExpirationDate"))
oledate_to_iso8601(VAR_6, VAR_5, num);
else if (!strcmp(VAR_2, "WM/WMRVBitrate"))
snprintf(VAR_6, VAR_5, "%f", av_int2dbl(num));
else
snprintf(VAR_6, VAR_5, "%"PRIi64, num);
} else if (VAR_3 == 5 && VAR_4 == 2) {
snprintf(VAR_6, VAR_5, "%"PRIi16, avio_rl16(VAR_1));
} else if (VAR_3 == 6 && VAR_4 == 16) {
ff_asf_guid guid;
avio_read(VAR_1, guid, 16);
snprintf(VAR_6, VAR_5, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid));
} else if (VAR_3 == 2 && !strcmp(VAR_2, "WM/Picture")) {
get_attachment(VAR_0, VAR_1, VAR_4);
av_freep(&VAR_6);
return;
} else {
av_freep(&VAR_6);
av_log(VAR_0, AV_LOG_WARNING, "unsupported metadata entry; VAR_2:%VAR_0, VAR_3:%d, VAR_4:0x%x\n", VAR_2, VAR_3, VAR_4);
avio_skip(VAR_1, VAR_4);
return;
}
av_metadata_set2(&VAR_0->metadata, VAR_2, VAR_6, 0);
av_freep(&VAR_6);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, const char *VAR_2, int VAR_3, int VAR_4)\n{",
"int VAR_5 = FFMAX(2*VAR_4, LEN_PRETTY_GUID) + 1;",
"char *VAR_6 = av_malloc(VAR_5);",
"if (!VAR_6)\nreturn;",
"if (VAR_3 == 0 && VAR_4 == 4) {",
"snprintf(VAR_6, VAR_5, \"%\"PRIi32, avio_rl32(VAR_1));",
"} else if (VAR_3 == 1) {",
"avio_get_str16le(VAR_1, VAR_4, VAR_6, VAR_5);",
"if (!strlen(VAR_6)) {",
"av_free(VAR_6);",
"return;",
"}",
"} else if (VAR_3 == 3 && VAR_4 == 4) {",
"strcpy(VAR_6, avio_rl32(VAR_1) ? \"true\" : \"false\");",
"} else if (VAR_3 == 4 && VAR_4 == 8) {",
"int64_t num = avio_rl64(VAR_1);",
"if (!strcmp(VAR_2, \"WM/EncodingTime\") ||\n!strcmp(VAR_2, \"WM/MediaOriginalBroadcastDateTime\"))\nfiletime_to_iso8601(VAR_6, VAR_5, num);",
"else if (!strcmp(VAR_2, \"WM/WMRVEncodeTime\") ||\n!strcmp(VAR_2, \"WM/WMRVEndTime\"))\ncrazytime_to_iso8601(VAR_6, VAR_5, num);",
"else if (!strcmp(VAR_2, \"WM/WMRVExpirationDate\"))\noledate_to_iso8601(VAR_6, VAR_5, num);",
"else if (!strcmp(VAR_2, \"WM/WMRVBitrate\"))\nsnprintf(VAR_6, VAR_5, \"%f\", av_int2dbl(num));",
"else\nsnprintf(VAR_6, VAR_5, \"%\"PRIi64, num);",
"} else if (VAR_3 == 5 && VAR_4 == 2) {",
"snprintf(VAR_6, VAR_5, \"%\"PRIi16, avio_rl16(VAR_1));",
"} else if (VAR_3 == 6 && VAR_4 == 16) {",
"ff_asf_guid guid;",
"avio_read(VAR_1, guid, 16);",
"snprintf(VAR_6, VAR_5, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid));",
"} else if (VAR_3 == 2 && !strcmp(VAR_2, \"WM/Picture\")) {",
"get_attachment(VAR_0, VAR_1, VAR_4);",
"av_freep(&VAR_6);",
"return;",
"} else {",
"av_freep(&VAR_6);",
"av_log(VAR_0, AV_LOG_WARNING, \"unsupported metadata entry; VAR_2:%VAR_0, VAR_3:%d, VAR_4:0x%x\\n\", VAR_2, VAR_3, VAR_4);",
"avio_skip(VAR_1, VAR_4);",
"return;",
"}",
"av_metadata_set2(&VAR_0->metadata, VAR_2, VAR_6, 0);",
"av_freep(&VAR_6);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
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,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41,
43
],
[
45,
47,
49
],
[
51,
53
],
[
55,
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
]
] |
19,466 | void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
ISADevice **rtc_state,
bool create_fdctrl,
bool no_vmport,
uint32_t hpet_irqs)
{
int i;
DriveInfo *fd[MAX_FD];
DeviceState *hpet = NULL;
int pit_isa_irq = 0;
qemu_irq pit_alt_irq = NULL;
qemu_irq rtc_irq = NULL;
qemu_irq *a20_line;
ISADevice *i8042, *port92, *vmmouse, *pit = NULL;
MemoryRegion *ioport80_io = g_new(MemoryRegion, 1);
MemoryRegion *ioportF0_io = g_new(MemoryRegion, 1);
memory_region_init_io(ioport80_io, NULL, &ioport80_io_ops, NULL, "ioport80", 1);
memory_region_add_subregion(isa_bus->address_space_io, 0x80, ioport80_io);
memory_region_init_io(ioportF0_io, NULL, &ioportF0_io_ops, NULL, "ioportF0", 1);
memory_region_add_subregion(isa_bus->address_space_io, 0xf0, ioportF0_io);
/*
* Check if an HPET shall be created.
*
* Without KVM_CAP_PIT_STATE2, we cannot switch off the in-kernel PIT
* when the HPET wants to take over. Thus we have to disable the latter.
*/
if (!no_hpet && (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) {
/* In order to set property, here not using sysbus_try_create_simple */
hpet = qdev_try_create(NULL, TYPE_HPET);
if (hpet) {
/* For pc-piix-*, hpet's intcap is always IRQ2. For pc-q35-1.7
* and earlier, use IRQ2 for compat. Otherwise, use IRQ16~23,
* IRQ8 and IRQ2.
*/
uint8_t compat = object_property_get_int(OBJECT(hpet),
HPET_INTCAP, NULL);
if (!compat) {
qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
}
qdev_init_nofail(hpet);
sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE);
for (i = 0; i < GSI_NUM_PINS; i++) {
sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]);
}
pit_isa_irq = -1;
pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);
rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);
}
}
*rtc_state = rtc_init(isa_bus, 2000, rtc_irq);
qemu_register_boot_set(pc_boot_set, *rtc_state);
if (!xen_enabled()) {
if (kvm_pit_in_kernel()) {
pit = kvm_pit_init(isa_bus, 0x40);
} else {
pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
}
if (hpet) {
/* connect PIT to output control line of the HPET */
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
}
pcspk_init(isa_bus, pit);
}
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
i8042 = isa_create_simple(isa_bus, "i8042");
i8042_setup_a20_line(i8042, a20_line[0]);
if (!no_vmport) {
vmport_init(isa_bus);
vmmouse = isa_try_create(isa_bus, "vmmouse");
} else {
vmmouse = NULL;
}
if (vmmouse) {
DeviceState *dev = DEVICE(vmmouse);
qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
qdev_init_nofail(dev);
}
port92 = isa_create_simple(isa_bus, "port92");
port92_init(port92, a20_line[1]);
DMA_init(isa_bus, 0);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
create_fdctrl |= !!fd[i];
}
if (create_fdctrl) {
fdctrl_init_isa(isa_bus, fd);
}
} | true | qemu | ac64c5fdf8c1e470cfca94d7ad5686770e6e470a | void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
ISADevice **rtc_state,
bool create_fdctrl,
bool no_vmport,
uint32_t hpet_irqs)
{
int i;
DriveInfo *fd[MAX_FD];
DeviceState *hpet = NULL;
int pit_isa_irq = 0;
qemu_irq pit_alt_irq = NULL;
qemu_irq rtc_irq = NULL;
qemu_irq *a20_line;
ISADevice *i8042, *port92, *vmmouse, *pit = NULL;
MemoryRegion *ioport80_io = g_new(MemoryRegion, 1);
MemoryRegion *ioportF0_io = g_new(MemoryRegion, 1);
memory_region_init_io(ioport80_io, NULL, &ioport80_io_ops, NULL, "ioport80", 1);
memory_region_add_subregion(isa_bus->address_space_io, 0x80, ioport80_io);
memory_region_init_io(ioportF0_io, NULL, &ioportF0_io_ops, NULL, "ioportF0", 1);
memory_region_add_subregion(isa_bus->address_space_io, 0xf0, ioportF0_io);
if (!no_hpet && (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) {
hpet = qdev_try_create(NULL, TYPE_HPET);
if (hpet) {
uint8_t compat = object_property_get_int(OBJECT(hpet),
HPET_INTCAP, NULL);
if (!compat) {
qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
}
qdev_init_nofail(hpet);
sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE);
for (i = 0; i < GSI_NUM_PINS; i++) {
sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]);
}
pit_isa_irq = -1;
pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);
rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);
}
}
*rtc_state = rtc_init(isa_bus, 2000, rtc_irq);
qemu_register_boot_set(pc_boot_set, *rtc_state);
if (!xen_enabled()) {
if (kvm_pit_in_kernel()) {
pit = kvm_pit_init(isa_bus, 0x40);
} else {
pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
}
if (hpet) {
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
}
pcspk_init(isa_bus, pit);
}
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
i8042 = isa_create_simple(isa_bus, "i8042");
i8042_setup_a20_line(i8042, a20_line[0]);
if (!no_vmport) {
vmport_init(isa_bus);
vmmouse = isa_try_create(isa_bus, "vmmouse");
} else {
vmmouse = NULL;
}
if (vmmouse) {
DeviceState *dev = DEVICE(vmmouse);
qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
qdev_init_nofail(dev);
}
port92 = isa_create_simple(isa_bus, "port92");
port92_init(port92, a20_line[1]);
DMA_init(isa_bus, 0);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
create_fdctrl |= !!fd[i];
}
if (create_fdctrl) {
fdctrl_init_isa(isa_bus, fd);
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(ISABus *VAR_0, qemu_irq *VAR_1,
ISADevice **VAR_2,
bool VAR_3,
bool VAR_4,
uint32_t VAR_5)
{
int VAR_6;
DriveInfo *fd[MAX_FD];
DeviceState *hpet = NULL;
int VAR_7 = 0;
qemu_irq pit_alt_irq = NULL;
qemu_irq rtc_irq = NULL;
qemu_irq *a20_line;
ISADevice *i8042, *port92, *vmmouse, *pit = NULL;
MemoryRegion *ioport80_io = g_new(MemoryRegion, 1);
MemoryRegion *ioportF0_io = g_new(MemoryRegion, 1);
memory_region_init_io(ioport80_io, NULL, &ioport80_io_ops, NULL, "ioport80", 1);
memory_region_add_subregion(VAR_0->address_space_io, 0x80, ioport80_io);
memory_region_init_io(ioportF0_io, NULL, &ioportF0_io_ops, NULL, "ioportF0", 1);
memory_region_add_subregion(VAR_0->address_space_io, 0xf0, ioportF0_io);
if (!no_hpet && (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) {
hpet = qdev_try_create(NULL, TYPE_HPET);
if (hpet) {
uint8_t compat = object_property_get_int(OBJECT(hpet),
HPET_INTCAP, NULL);
if (!compat) {
qdev_prop_set_uint32(hpet, HPET_INTCAP, VAR_5);
}
qdev_init_nofail(hpet);
sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE);
for (VAR_6 = 0; VAR_6 < GSI_NUM_PINS; VAR_6++) {
sysbus_connect_irq(SYS_BUS_DEVICE(hpet), VAR_6, VAR_1[VAR_6]);
}
VAR_7 = -1;
pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);
rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);
}
}
*VAR_2 = rtc_init(VAR_0, 2000, rtc_irq);
qemu_register_boot_set(pc_boot_set, *VAR_2);
if (!xen_enabled()) {
if (kvm_pit_in_kernel()) {
pit = kvm_pit_init(VAR_0, 0x40);
} else {
pit = pit_init(VAR_0, 0x40, VAR_7, pit_alt_irq);
}
if (hpet) {
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
}
pcspk_init(VAR_0, pit);
}
serial_hds_isa_init(VAR_0, MAX_SERIAL_PORTS);
parallel_hds_isa_init(VAR_0, MAX_PARALLEL_PORTS);
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
i8042 = isa_create_simple(VAR_0, "i8042");
i8042_setup_a20_line(i8042, a20_line[0]);
if (!VAR_4) {
vmport_init(VAR_0);
vmmouse = isa_try_create(VAR_0, "vmmouse");
} else {
vmmouse = NULL;
}
if (vmmouse) {
DeviceState *dev = DEVICE(vmmouse);
qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
qdev_init_nofail(dev);
}
port92 = isa_create_simple(VAR_0, "port92");
port92_init(port92, a20_line[1]);
DMA_init(VAR_0, 0);
for(VAR_6 = 0; VAR_6 < MAX_FD; VAR_6++) {
fd[VAR_6] = drive_get(IF_FLOPPY, 0, VAR_6);
VAR_3 |= !!fd[VAR_6];
}
if (VAR_3) {
fdctrl_init_isa(VAR_0, fd);
}
} | [
"void FUNC_0(ISABus *VAR_0, qemu_irq *VAR_1,\nISADevice **VAR_2,\nbool VAR_3,\nbool VAR_4,\nuint32_t VAR_5)\n{",
"int VAR_6;",
"DriveInfo *fd[MAX_FD];",
"DeviceState *hpet = NULL;",
"int VAR_7 = 0;",
"qemu_irq pit_alt_irq = NULL;",
"qemu_irq rtc_irq = NULL;",
"qemu_irq *a20_line;",
"ISADevice *i8042, *port92, *vmmouse, *pit = NULL;",
"MemoryRegion *ioport80_io = g_new(MemoryRegion, 1);",
"MemoryRegion *ioportF0_io = g_new(MemoryRegion, 1);",
"memory_region_init_io(ioport80_io, NULL, &ioport80_io_ops, NULL, \"ioport80\", 1);",
"memory_region_add_subregion(VAR_0->address_space_io, 0x80, ioport80_io);",
"memory_region_init_io(ioportF0_io, NULL, &ioportF0_io_ops, NULL, \"ioportF0\", 1);",
"memory_region_add_subregion(VAR_0->address_space_io, 0xf0, ioportF0_io);",
"if (!no_hpet && (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) {",
"hpet = qdev_try_create(NULL, TYPE_HPET);",
"if (hpet) {",
"uint8_t compat = object_property_get_int(OBJECT(hpet),\nHPET_INTCAP, NULL);",
"if (!compat) {",
"qdev_prop_set_uint32(hpet, HPET_INTCAP, VAR_5);",
"}",
"qdev_init_nofail(hpet);",
"sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE);",
"for (VAR_6 = 0; VAR_6 < GSI_NUM_PINS; VAR_6++) {",
"sysbus_connect_irq(SYS_BUS_DEVICE(hpet), VAR_6, VAR_1[VAR_6]);",
"}",
"VAR_7 = -1;",
"pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);",
"rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);",
"}",
"}",
"*VAR_2 = rtc_init(VAR_0, 2000, rtc_irq);",
"qemu_register_boot_set(pc_boot_set, *VAR_2);",
"if (!xen_enabled()) {",
"if (kvm_pit_in_kernel()) {",
"pit = kvm_pit_init(VAR_0, 0x40);",
"} else {",
"pit = pit_init(VAR_0, 0x40, VAR_7, pit_alt_irq);",
"}",
"if (hpet) {",
"qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));",
"}",
"pcspk_init(VAR_0, pit);",
"}",
"serial_hds_isa_init(VAR_0, MAX_SERIAL_PORTS);",
"parallel_hds_isa_init(VAR_0, MAX_PARALLEL_PORTS);",
"a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);",
"i8042 = isa_create_simple(VAR_0, \"i8042\");",
"i8042_setup_a20_line(i8042, a20_line[0]);",
"if (!VAR_4) {",
"vmport_init(VAR_0);",
"vmmouse = isa_try_create(VAR_0, \"vmmouse\");",
"} else {",
"vmmouse = NULL;",
"}",
"if (vmmouse) {",
"DeviceState *dev = DEVICE(vmmouse);",
"qdev_prop_set_ptr(dev, \"ps2_mouse\", i8042);",
"qdev_init_nofail(dev);",
"}",
"port92 = isa_create_simple(VAR_0, \"port92\");",
"port92_init(port92, a20_line[1]);",
"DMA_init(VAR_0, 0);",
"for(VAR_6 = 0; VAR_6 < MAX_FD; VAR_6++) {",
"fd[VAR_6] = drive_get(IF_FLOPPY, 0, VAR_6);",
"VAR_3 |= !!fd[VAR_6];",
"}",
"if (VAR_3) {",
"fdctrl_init_isa(VAR_0, fd);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37
],
[
41
],
[
43
],
[
59
],
[
63
],
[
65
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
182
],
[
186
],
[
188
],
[
190
],
[
192
],
[
194
],
[
196
],
[
198
],
[
200
]
] |
19,467 | void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
uint16_t *y_list, int *flag,
int multiplier, float *out, int samples)
{
int lx, ly, i;
lx = 0;
ly = y_list[0] * multiplier;
for (i = 1; i < values; i++) {
int pos = list[i].sort;
if (flag[pos]) {
int x1 = list[pos].x;
int y1 = y_list[pos] * multiplier;
if (lx < samples)
render_line(lx, ly, FFMIN(x1,samples), y1, out);
lx = x1;
ly = y1;
}
if (lx >= samples)
break;
}
if (lx < samples)
render_line(lx, ly, samples, ly, out);
}
| true | FFmpeg | 57cd6d709565e84e84385f8f2a9641ca3fa718be | void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
uint16_t *y_list, int *flag,
int multiplier, float *out, int samples)
{
int lx, ly, i;
lx = 0;
ly = y_list[0] * multiplier;
for (i = 1; i < values; i++) {
int pos = list[i].sort;
if (flag[pos]) {
int x1 = list[pos].x;
int y1 = y_list[pos] * multiplier;
if (lx < samples)
render_line(lx, ly, FFMIN(x1,samples), y1, out);
lx = x1;
ly = y1;
}
if (lx >= samples)
break;
}
if (lx < samples)
render_line(lx, ly, samples, ly, out);
}
| {
"code": [
" int lx, ly, i;"
],
"line_no": [
9
]
} | void FUNC_0(vorbis_floor1_entry * VAR_0, int VAR_1,
uint16_t *VAR_2, int *VAR_3,
int VAR_4, float *VAR_5, int VAR_6)
{
int VAR_7, VAR_8, VAR_9;
VAR_7 = 0;
VAR_8 = VAR_2[0] * VAR_4;
for (VAR_9 = 1; VAR_9 < VAR_1; VAR_9++) {
int VAR_10 = VAR_0[VAR_9].sort;
if (VAR_3[VAR_10]) {
int VAR_11 = VAR_0[VAR_10].x;
int VAR_12 = VAR_2[VAR_10] * VAR_4;
if (VAR_7 < VAR_6)
render_line(VAR_7, VAR_8, FFMIN(VAR_11,VAR_6), VAR_12, VAR_5);
VAR_7 = VAR_11;
VAR_8 = VAR_12;
}
if (VAR_7 >= VAR_6)
break;
}
if (VAR_7 < VAR_6)
render_line(VAR_7, VAR_8, VAR_6, VAR_8, VAR_5);
}
| [
"void FUNC_0(vorbis_floor1_entry * VAR_0, int VAR_1,\nuint16_t *VAR_2, int *VAR_3,\nint VAR_4, float *VAR_5, int VAR_6)\n{",
"int VAR_7, VAR_8, VAR_9;",
"VAR_7 = 0;",
"VAR_8 = VAR_2[0] * VAR_4;",
"for (VAR_9 = 1; VAR_9 < VAR_1; VAR_9++) {",
"int VAR_10 = VAR_0[VAR_9].sort;",
"if (VAR_3[VAR_10]) {",
"int VAR_11 = VAR_0[VAR_10].x;",
"int VAR_12 = VAR_2[VAR_10] * VAR_4;",
"if (VAR_7 < VAR_6)\nrender_line(VAR_7, VAR_8, FFMIN(VAR_11,VAR_6), VAR_12, VAR_5);",
"VAR_7 = VAR_11;",
"VAR_8 = VAR_12;",
"}",
"if (VAR_7 >= VAR_6)\nbreak;",
"}",
"if (VAR_7 < VAR_6)\nrender_line(VAR_7, VAR_8, VAR_6, VAR_8, VAR_5);",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
]
] |
19,468 | static void channel_weighting(float *su1, float *su2, int *p3)
{
int band, nsample;
/* w[x][y] y=0 is left y=1 is right */
float w[2][2];
if (p3[1] != 7 || p3[3] != 7) {
get_channel_weights(p3[1], p3[0], w[0]);
get_channel_weights(p3[3], p3[2], w[1]);
for (band = 1; band < 4; band++) {
for (nsample = 0; nsample < 8; nsample++) {
su1[band * 256 + nsample] *= INTERPOLATE(w[0][0], w[0][1], nsample);
su2[band * 256 + nsample] *= INTERPOLATE(w[1][0], w[1][1], nsample);
}
for(; nsample < 256; nsample++) {
su1[band * 256 + nsample] *= w[1][0];
su2[band * 256 + nsample] *= w[1][1];
}
}
}
}
| false | FFmpeg | aefdb735c3df9480c1ca9bcf4a3835bd66271bd1 | static void channel_weighting(float *su1, float *su2, int *p3)
{
int band, nsample;
float w[2][2];
if (p3[1] != 7 || p3[3] != 7) {
get_channel_weights(p3[1], p3[0], w[0]);
get_channel_weights(p3[3], p3[2], w[1]);
for (band = 1; band < 4; band++) {
for (nsample = 0; nsample < 8; nsample++) {
su1[band * 256 + nsample] *= INTERPOLATE(w[0][0], w[0][1], nsample);
su2[band * 256 + nsample] *= INTERPOLATE(w[1][0], w[1][1], nsample);
}
for(; nsample < 256; nsample++) {
su1[band * 256 + nsample] *= w[1][0];
su2[band * 256 + nsample] *= w[1][1];
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(float *VAR_0, float *VAR_1, int *VAR_2)
{
int VAR_3, VAR_4;
float VAR_5[2][2];
if (VAR_2[1] != 7 || VAR_2[3] != 7) {
get_channel_weights(VAR_2[1], VAR_2[0], VAR_5[0]);
get_channel_weights(VAR_2[3], VAR_2[2], VAR_5[1]);
for (VAR_3 = 1; VAR_3 < 4; VAR_3++) {
for (VAR_4 = 0; VAR_4 < 8; VAR_4++) {
VAR_0[VAR_3 * 256 + VAR_4] *= INTERPOLATE(VAR_5[0][0], VAR_5[0][1], VAR_4);
VAR_1[VAR_3 * 256 + VAR_4] *= INTERPOLATE(VAR_5[1][0], VAR_5[1][1], VAR_4);
}
for(; VAR_4 < 256; VAR_4++) {
VAR_0[VAR_3 * 256 + VAR_4] *= VAR_5[1][0];
VAR_1[VAR_3 * 256 + VAR_4] *= VAR_5[1][1];
}
}
}
}
| [
"static void FUNC_0(float *VAR_0, float *VAR_1, int *VAR_2)\n{",
"int VAR_3, VAR_4;",
"float VAR_5[2][2];",
"if (VAR_2[1] != 7 || VAR_2[3] != 7) {",
"get_channel_weights(VAR_2[1], VAR_2[0], VAR_5[0]);",
"get_channel_weights(VAR_2[3], VAR_2[2], VAR_5[1]);",
"for (VAR_3 = 1; VAR_3 < 4; VAR_3++) {",
"for (VAR_4 = 0; VAR_4 < 8; VAR_4++) {",
"VAR_0[VAR_3 * 256 + VAR_4] *= INTERPOLATE(VAR_5[0][0], VAR_5[0][1], VAR_4);",
"VAR_1[VAR_3 * 256 + VAR_4] *= INTERPOLATE(VAR_5[1][0], VAR_5[1][1], VAR_4);",
"}",
"for(; VAR_4 < 256; VAR_4++) {",
"VAR_0[VAR_3 * 256 + VAR_4] *= VAR_5[1][0];",
"VAR_1[VAR_3 * 256 + VAR_4] *= VAR_5[1][1];",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
19,470 | bool bdrv_requests_pending(BlockDriverState *bs)
{
BdrvChild *child;
BlockBackendPublic *blkp = bs->blk ? blk_get_public(bs->blk) : NULL;
if (!QLIST_EMPTY(&bs->tracked_requests)) {
return true;
}
if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[0])) {
return true;
}
if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[1])) {
return true;
}
QLIST_FOREACH(child, &bs->children, next) {
if (bdrv_requests_pending(child->bs)) {
return true;
}
}
return false;
}
| false | qemu | cbe1beb7a1eaa34e0c24b4897395dac017e5d16f | bool bdrv_requests_pending(BlockDriverState *bs)
{
BdrvChild *child;
BlockBackendPublic *blkp = bs->blk ? blk_get_public(bs->blk) : NULL;
if (!QLIST_EMPTY(&bs->tracked_requests)) {
return true;
}
if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[0])) {
return true;
}
if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[1])) {
return true;
}
QLIST_FOREACH(child, &bs->children, next) {
if (bdrv_requests_pending(child->bs)) {
return true;
}
}
return false;
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(BlockDriverState *bs)
{
BdrvChild *child;
BlockBackendPublic *blkp = bs->blk ? blk_get_public(bs->blk) : NULL;
if (!QLIST_EMPTY(&bs->tracked_requests)) {
return true;
}
if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[0])) {
return true;
}
if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[1])) {
return true;
}
QLIST_FOREACH(child, &bs->children, next) {
if (FUNC_0(child->bs)) {
return true;
}
}
return false;
}
| [
"bool FUNC_0(BlockDriverState *bs)\n{",
"BdrvChild *child;",
"BlockBackendPublic *blkp = bs->blk ? blk_get_public(bs->blk) : NULL;",
"if (!QLIST_EMPTY(&bs->tracked_requests)) {",
"return true;",
"}",
"if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[0])) {",
"return true;",
"}",
"if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[1])) {",
"return true;",
"}",
"QLIST_FOREACH(child, &bs->children, next) {",
"if (FUNC_0(child->bs)) {",
"return true;",
"}",
"}",
"return false;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
]
] |
19,471 | static void qvirtio_9p_pci_free(QVirtIO9P *v9p)
{
qvirtqueue_cleanup(v9p->dev->bus, v9p->vq, v9p->alloc);
pc_alloc_uninit(v9p->alloc);
qvirtio_pci_device_disable(container_of(v9p->dev, QVirtioPCIDevice, vdev));
g_free(v9p->dev);
qpci_free_pc(v9p->bus);
g_free(v9p);
}
| false | qemu | a980f7f2c2f4d7e9a1eba4f804cd66dbd458b6d4 | static void qvirtio_9p_pci_free(QVirtIO9P *v9p)
{
qvirtqueue_cleanup(v9p->dev->bus, v9p->vq, v9p->alloc);
pc_alloc_uninit(v9p->alloc);
qvirtio_pci_device_disable(container_of(v9p->dev, QVirtioPCIDevice, vdev));
g_free(v9p->dev);
qpci_free_pc(v9p->bus);
g_free(v9p);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QVirtIO9P *VAR_0)
{
qvirtqueue_cleanup(VAR_0->dev->bus, VAR_0->vq, VAR_0->alloc);
pc_alloc_uninit(VAR_0->alloc);
qvirtio_pci_device_disable(container_of(VAR_0->dev, QVirtioPCIDevice, vdev));
g_free(VAR_0->dev);
qpci_free_pc(VAR_0->bus);
g_free(VAR_0);
}
| [
"static void FUNC_0(QVirtIO9P *VAR_0)\n{",
"qvirtqueue_cleanup(VAR_0->dev->bus, VAR_0->vq, VAR_0->alloc);",
"pc_alloc_uninit(VAR_0->alloc);",
"qvirtio_pci_device_disable(container_of(VAR_0->dev, QVirtioPCIDevice, vdev));",
"g_free(VAR_0->dev);",
"qpci_free_pc(VAR_0->bus);",
"g_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
19,474 | static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int count, BdrvRequestFlags flags)
{
BlockDriver *drv = bs->drv;
QEMUIOVector qiov;
struct iovec iov = {0};
int ret = 0;
bool need_flush = false;
int head = 0;
int tail = 0;
int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX);
int alignment = MAX(bs->bl.pwrite_zeroes_alignment ?: 1,
bs->request_alignment);
assert(is_power_of_2(alignment));
head = offset & (alignment - 1);
tail = (offset + count) & (alignment - 1);
max_write_zeroes &= ~(alignment - 1);
while (count > 0 && !ret) {
int num = count;
/* Align request. Block drivers can expect the "bulk" of the request
* to be aligned, and that unaligned requests do not cross cluster
* boundaries.
*/
if (head) {
/* Make a small request up to the first aligned sector. */
num = MIN(count, alignment - head);
head = 0;
} else if (tail && num > alignment) {
/* Shorten the request to the last aligned sector. */
num -= tail;
}
/* limit request size */
if (num > max_write_zeroes) {
num = max_write_zeroes;
}
ret = -ENOTSUP;
/* First try the efficient write zeroes operation */
if (drv->bdrv_co_pwrite_zeroes) {
ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,
flags & bs->supported_zero_flags);
if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&
!(bs->supported_zero_flags & BDRV_REQ_FUA)) {
need_flush = true;
}
} else {
assert(!bs->supported_zero_flags);
}
if (ret == -ENOTSUP) {
/* Fall back to bounce buffer if write zeroes is unsupported */
int max_xfer_len = MIN_NON_ZERO(bs->bl.max_transfer_length,
MAX_WRITE_ZEROES_BOUNCE_BUFFER);
BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
if ((flags & BDRV_REQ_FUA) &&
!(bs->supported_write_flags & BDRV_REQ_FUA)) {
/* No need for bdrv_driver_pwrite() to do a fallback
* flush on each chunk; use just one at the end */
write_flags &= ~BDRV_REQ_FUA;
need_flush = true;
}
num = MIN(num, max_xfer_len << BDRV_SECTOR_BITS);
iov.iov_len = num;
if (iov.iov_base == NULL) {
iov.iov_base = qemu_try_blockalign(bs, num);
if (iov.iov_base == NULL) {
ret = -ENOMEM;
goto fail;
}
memset(iov.iov_base, 0, num);
}
qemu_iovec_init_external(&qiov, &iov, 1);
ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags);
/* Keep bounce buffer around if it is big enough for all
* all future requests.
*/
if (num < max_xfer_len << BDRV_SECTOR_BITS) {
qemu_vfree(iov.iov_base);
iov.iov_base = NULL;
}
}
offset += num;
count -= num;
}
fail:
if (ret == 0 && need_flush) {
ret = bdrv_co_flush(bs);
}
qemu_vfree(iov.iov_base);
return ret;
}
| false | qemu | 5def6b80e1eca696c1fc6099e7f4d36729686402 | static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int count, BdrvRequestFlags flags)
{
BlockDriver *drv = bs->drv;
QEMUIOVector qiov;
struct iovec iov = {0};
int ret = 0;
bool need_flush = false;
int head = 0;
int tail = 0;
int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX);
int alignment = MAX(bs->bl.pwrite_zeroes_alignment ?: 1,
bs->request_alignment);
assert(is_power_of_2(alignment));
head = offset & (alignment - 1);
tail = (offset + count) & (alignment - 1);
max_write_zeroes &= ~(alignment - 1);
while (count > 0 && !ret) {
int num = count;
if (head) {
num = MIN(count, alignment - head);
head = 0;
} else if (tail && num > alignment) {
num -= tail;
}
if (num > max_write_zeroes) {
num = max_write_zeroes;
}
ret = -ENOTSUP;
if (drv->bdrv_co_pwrite_zeroes) {
ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,
flags & bs->supported_zero_flags);
if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&
!(bs->supported_zero_flags & BDRV_REQ_FUA)) {
need_flush = true;
}
} else {
assert(!bs->supported_zero_flags);
}
if (ret == -ENOTSUP) {
int max_xfer_len = MIN_NON_ZERO(bs->bl.max_transfer_length,
MAX_WRITE_ZEROES_BOUNCE_BUFFER);
BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
if ((flags & BDRV_REQ_FUA) &&
!(bs->supported_write_flags & BDRV_REQ_FUA)) {
write_flags &= ~BDRV_REQ_FUA;
need_flush = true;
}
num = MIN(num, max_xfer_len << BDRV_SECTOR_BITS);
iov.iov_len = num;
if (iov.iov_base == NULL) {
iov.iov_base = qemu_try_blockalign(bs, num);
if (iov.iov_base == NULL) {
ret = -ENOMEM;
goto fail;
}
memset(iov.iov_base, 0, num);
}
qemu_iovec_init_external(&qiov, &iov, 1);
ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags);
if (num < max_xfer_len << BDRV_SECTOR_BITS) {
qemu_vfree(iov.iov_base);
iov.iov_base = NULL;
}
}
offset += num;
count -= num;
}
fail:
if (ret == 0 && need_flush) {
ret = bdrv_co_flush(bs);
}
qemu_vfree(iov.iov_base);
return ret;
}
| {
"code": [],
"line_no": []
} | static int VAR_0 bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int count, BdrvRequestFlags flags)
{
BlockDriver *drv = bs->drv;
QEMUIOVector qiov;
struct iovec iov = {0};
int ret = 0;
bool need_flush = false;
int head = 0;
int tail = 0;
int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX);
int alignment = MAX(bs->bl.pwrite_zeroes_alignment ?: 1,
bs->request_alignment);
assert(is_power_of_2(alignment));
head = offset & (alignment - 1);
tail = (offset + count) & (alignment - 1);
max_write_zeroes &= ~(alignment - 1);
while (count > 0 && !ret) {
int num = count;
if (head) {
num = MIN(count, alignment - head);
head = 0;
} else if (tail && num > alignment) {
num -= tail;
}
if (num > max_write_zeroes) {
num = max_write_zeroes;
}
ret = -ENOTSUP;
if (drv->bdrv_co_pwrite_zeroes) {
ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,
flags & bs->supported_zero_flags);
if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&
!(bs->supported_zero_flags & BDRV_REQ_FUA)) {
need_flush = true;
}
} else {
assert(!bs->supported_zero_flags);
}
if (ret == -ENOTSUP) {
int max_xfer_len = MIN_NON_ZERO(bs->bl.max_transfer_length,
MAX_WRITE_ZEROES_BOUNCE_BUFFER);
BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
if ((flags & BDRV_REQ_FUA) &&
!(bs->supported_write_flags & BDRV_REQ_FUA)) {
write_flags &= ~BDRV_REQ_FUA;
need_flush = true;
}
num = MIN(num, max_xfer_len << BDRV_SECTOR_BITS);
iov.iov_len = num;
if (iov.iov_base == NULL) {
iov.iov_base = qemu_try_blockalign(bs, num);
if (iov.iov_base == NULL) {
ret = -ENOMEM;
goto fail;
}
memset(iov.iov_base, 0, num);
}
qemu_iovec_init_external(&qiov, &iov, 1);
ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags);
if (num < max_xfer_len << BDRV_SECTOR_BITS) {
qemu_vfree(iov.iov_base);
iov.iov_base = NULL;
}
}
offset += num;
count -= num;
}
fail:
if (ret == 0 && need_flush) {
ret = bdrv_co_flush(bs);
}
qemu_vfree(iov.iov_base);
return ret;
}
| [
"static int VAR_0 bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,\nint64_t offset, int count, BdrvRequestFlags flags)\n{",
"BlockDriver *drv = bs->drv;",
"QEMUIOVector qiov;",
"struct iovec iov = {0};",
"int ret = 0;",
"bool need_flush = false;",
"int head = 0;",
"int tail = 0;",
"int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX);",
"int alignment = MAX(bs->bl.pwrite_zeroes_alignment ?: 1,\nbs->request_alignment);",
"assert(is_power_of_2(alignment));",
"head = offset & (alignment - 1);",
"tail = (offset + count) & (alignment - 1);",
"max_write_zeroes &= ~(alignment - 1);",
"while (count > 0 && !ret) {",
"int num = count;",
"if (head) {",
"num = MIN(count, alignment - head);",
"head = 0;",
"} else if (tail && num > alignment) {",
"num -= tail;",
"}",
"if (num > max_write_zeroes) {",
"num = max_write_zeroes;",
"}",
"ret = -ENOTSUP;",
"if (drv->bdrv_co_pwrite_zeroes) {",
"ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,\nflags & bs->supported_zero_flags);",
"if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&\n!(bs->supported_zero_flags & BDRV_REQ_FUA)) {",
"need_flush = true;",
"}",
"} else {",
"assert(!bs->supported_zero_flags);",
"}",
"if (ret == -ENOTSUP) {",
"int max_xfer_len = MIN_NON_ZERO(bs->bl.max_transfer_length,\nMAX_WRITE_ZEROES_BOUNCE_BUFFER);",
"BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;",
"if ((flags & BDRV_REQ_FUA) &&\n!(bs->supported_write_flags & BDRV_REQ_FUA)) {",
"write_flags &= ~BDRV_REQ_FUA;",
"need_flush = true;",
"}",
"num = MIN(num, max_xfer_len << BDRV_SECTOR_BITS);",
"iov.iov_len = num;",
"if (iov.iov_base == NULL) {",
"iov.iov_base = qemu_try_blockalign(bs, num);",
"if (iov.iov_base == NULL) {",
"ret = -ENOMEM;",
"goto fail;",
"}",
"memset(iov.iov_base, 0, num);",
"}",
"qemu_iovec_init_external(&qiov, &iov, 1);",
"ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags);",
"if (num < max_xfer_len << BDRV_SECTOR_BITS) {",
"qemu_vfree(iov.iov_base);",
"iov.iov_base = NULL;",
"}",
"}",
"offset += num;",
"count -= num;",
"}",
"fail:\nif (ret == 0 && need_flush) {",
"ret = bdrv_co_flush(bs);",
"}",
"qemu_vfree(iov.iov_base);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87
],
[
89,
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
113,
115
],
[
117
],
[
121,
123
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
]
] |
19,475 | int load_vmstate(const char *name)
{
BlockDriverState *bs, *bs_vm_state;
QEMUSnapshotInfo sn;
QEMUFile *f;
int ret;
if (!bdrv_all_can_snapshot(&bs)) {
error_report("Device '%s' is writable but does not support snapshots.",
bdrv_get_device_name(bs));
return -ENOTSUP;
}
bs_vm_state = find_vmstate_bs();
if (!bs_vm_state) {
error_report("No block device supports snapshots");
return -ENOTSUP;
}
/* Don't even try to load empty VM states */
ret = bdrv_snapshot_find(bs_vm_state, &sn, name);
if (ret < 0) {
return ret;
} else if (sn.vm_state_size == 0) {
error_report("This is a disk-only snapshot. Revert to it offline "
"using qemu-img.");
return -EINVAL;
}
/* Verify if there is any device that doesn't support snapshots and is
writable and check if the requested snapshot is available too. */
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (!bdrv_can_snapshot(bs)) {
continue;
}
ret = bdrv_snapshot_find(bs, &sn, name);
if (ret < 0) {
error_report("Device '%s' does not have the requested snapshot '%s'",
bdrv_get_device_name(bs), name);
return ret;
}
}
/* Flush all IO requests so they don't interfere with the new state. */
bdrv_drain_all();
ret = bdrv_all_goto_snapshot(name, &bs);
if (ret < 0) {
error_report("Error %d while activating snapshot '%s' on '%s'",
ret, name, bdrv_get_device_name(bs));
return ret;
}
/* restore the VM state */
f = qemu_fopen_bdrv(bs_vm_state, 0);
if (!f) {
error_report("Could not open VM state file");
return -EINVAL;
}
qemu_system_reset(VMRESET_SILENT);
migration_incoming_state_new(f);
ret = qemu_loadvm_state(f);
qemu_fclose(f);
migration_incoming_state_destroy();
if (ret < 0) {
error_report("Error %d while loading VM state", ret);
return ret;
}
return 0;
}
| false | qemu | 723ccda1a0eecece8e70dbcdd35a603f6c41a475 | int load_vmstate(const char *name)
{
BlockDriverState *bs, *bs_vm_state;
QEMUSnapshotInfo sn;
QEMUFile *f;
int ret;
if (!bdrv_all_can_snapshot(&bs)) {
error_report("Device '%s' is writable but does not support snapshots.",
bdrv_get_device_name(bs));
return -ENOTSUP;
}
bs_vm_state = find_vmstate_bs();
if (!bs_vm_state) {
error_report("No block device supports snapshots");
return -ENOTSUP;
}
ret = bdrv_snapshot_find(bs_vm_state, &sn, name);
if (ret < 0) {
return ret;
} else if (sn.vm_state_size == 0) {
error_report("This is a disk-only snapshot. Revert to it offline "
"using qemu-img.");
return -EINVAL;
}
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (!bdrv_can_snapshot(bs)) {
continue;
}
ret = bdrv_snapshot_find(bs, &sn, name);
if (ret < 0) {
error_report("Device '%s' does not have the requested snapshot '%s'",
bdrv_get_device_name(bs), name);
return ret;
}
}
bdrv_drain_all();
ret = bdrv_all_goto_snapshot(name, &bs);
if (ret < 0) {
error_report("Error %d while activating snapshot '%s' on '%s'",
ret, name, bdrv_get_device_name(bs));
return ret;
}
f = qemu_fopen_bdrv(bs_vm_state, 0);
if (!f) {
error_report("Could not open VM state file");
return -EINVAL;
}
qemu_system_reset(VMRESET_SILENT);
migration_incoming_state_new(f);
ret = qemu_loadvm_state(f);
qemu_fclose(f);
migration_incoming_state_destroy();
if (ret < 0) {
error_report("Error %d while loading VM state", ret);
return ret;
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const char *VAR_0)
{
BlockDriverState *bs, *bs_vm_state;
QEMUSnapshotInfo sn;
QEMUFile *f;
int VAR_1;
if (!bdrv_all_can_snapshot(&bs)) {
error_report("Device '%s' is writable but does not support snapshots.",
bdrv_get_device_name(bs));
return -ENOTSUP;
}
bs_vm_state = find_vmstate_bs();
if (!bs_vm_state) {
error_report("No block device supports snapshots");
return -ENOTSUP;
}
VAR_1 = bdrv_snapshot_find(bs_vm_state, &sn, VAR_0);
if (VAR_1 < 0) {
return VAR_1;
} else if (sn.vm_state_size == 0) {
error_report("This is a disk-only snapshot. Revert to it offline "
"using qemu-img.");
return -EINVAL;
}
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (!bdrv_can_snapshot(bs)) {
continue;
}
VAR_1 = bdrv_snapshot_find(bs, &sn, VAR_0);
if (VAR_1 < 0) {
error_report("Device '%s' does not have the requested snapshot '%s'",
bdrv_get_device_name(bs), VAR_0);
return VAR_1;
}
}
bdrv_drain_all();
VAR_1 = bdrv_all_goto_snapshot(VAR_0, &bs);
if (VAR_1 < 0) {
error_report("Error %d while activating snapshot '%s' on '%s'",
VAR_1, VAR_0, bdrv_get_device_name(bs));
return VAR_1;
}
f = qemu_fopen_bdrv(bs_vm_state, 0);
if (!f) {
error_report("Could not open VM state file");
return -EINVAL;
}
qemu_system_reset(VMRESET_SILENT);
migration_incoming_state_new(f);
VAR_1 = qemu_loadvm_state(f);
qemu_fclose(f);
migration_incoming_state_destroy();
if (VAR_1 < 0) {
error_report("Error %d while loading VM state", VAR_1);
return VAR_1;
}
return 0;
}
| [
"int FUNC_0(const char *VAR_0)\n{",
"BlockDriverState *bs, *bs_vm_state;",
"QEMUSnapshotInfo sn;",
"QEMUFile *f;",
"int VAR_1;",
"if (!bdrv_all_can_snapshot(&bs)) {",
"error_report(\"Device '%s' is writable but does not support snapshots.\",\nbdrv_get_device_name(bs));",
"return -ENOTSUP;",
"}",
"bs_vm_state = find_vmstate_bs();",
"if (!bs_vm_state) {",
"error_report(\"No block device supports snapshots\");",
"return -ENOTSUP;",
"}",
"VAR_1 = bdrv_snapshot_find(bs_vm_state, &sn, VAR_0);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"} else if (sn.vm_state_size == 0) {",
"error_report(\"This is a disk-only snapshot. Revert to it offline \"\n\"using qemu-img.\");",
"return -EINVAL;",
"}",
"bs = NULL;",
"while ((bs = bdrv_next(bs))) {",
"if (!bdrv_can_snapshot(bs)) {",
"continue;",
"}",
"VAR_1 = bdrv_snapshot_find(bs, &sn, VAR_0);",
"if (VAR_1 < 0) {",
"error_report(\"Device '%s' does not have the requested snapshot '%s'\",\nbdrv_get_device_name(bs), VAR_0);",
"return VAR_1;",
"}",
"}",
"bdrv_drain_all();",
"VAR_1 = bdrv_all_goto_snapshot(VAR_0, &bs);",
"if (VAR_1 < 0) {",
"error_report(\"Error %d while activating snapshot '%s' on '%s'\",\nVAR_1, VAR_0, bdrv_get_device_name(bs));",
"return VAR_1;",
"}",
"f = qemu_fopen_bdrv(bs_vm_state, 0);",
"if (!f) {",
"error_report(\"Could not open VM state file\");",
"return -EINVAL;",
"}",
"qemu_system_reset(VMRESET_SILENT);",
"migration_incoming_state_new(f);",
"VAR_1 = qemu_loadvm_state(f);",
"qemu_fclose(f);",
"migration_incoming_state_destroy();",
"if (VAR_1 < 0) {",
"error_report(\"Error %d while loading VM state\", VAR_1);",
"return VAR_1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
93
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
]
] |
19,477 | build_fadt(GArray *table_data, GArray *linker, AcpiPmInfo *pm,
unsigned facs, unsigned dsdt,
const char *oem_id, const char *oem_table_id)
{
AcpiFadtDescriptorRev1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
fadt->firmware_ctrl = cpu_to_le32(facs);
/* FACS address to be filled by Guest linker */
bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
table_data, &fadt->firmware_ctrl,
sizeof fadt->firmware_ctrl);
fadt->dsdt = cpu_to_le32(dsdt);
/* DSDT address to be filled by Guest linker */
bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
table_data, &fadt->dsdt,
sizeof fadt->dsdt);
fadt_setup(fadt, pm);
build_header(linker, table_data,
(void *)fadt, "FACP", sizeof(*fadt), 1, oem_id, oem_table_id);
}
| false | qemu | 0e9b9edae7bebfd31fdbead4ccbbce03876a7edd | build_fadt(GArray *table_data, GArray *linker, AcpiPmInfo *pm,
unsigned facs, unsigned dsdt,
const char *oem_id, const char *oem_table_id)
{
AcpiFadtDescriptorRev1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
fadt->firmware_ctrl = cpu_to_le32(facs);
bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
table_data, &fadt->firmware_ctrl,
sizeof fadt->firmware_ctrl);
fadt->dsdt = cpu_to_le32(dsdt);
bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
table_data, &fadt->dsdt,
sizeof fadt->dsdt);
fadt_setup(fadt, pm);
build_header(linker, table_data,
(void *)fadt, "FACP", sizeof(*fadt), 1, oem_id, oem_table_id);
}
| {
"code": [],
"line_no": []
} | FUNC_0(GArray *VAR_0, GArray *VAR_1, AcpiPmInfo *VAR_2,
unsigned VAR_3, unsigned VAR_4,
const char *VAR_5, const char *VAR_6)
{
AcpiFadtDescriptorRev1 *fadt = acpi_data_push(VAR_0, sizeof(*fadt));
fadt->firmware_ctrl = cpu_to_le32(VAR_3);
bios_linker_loader_add_pointer(VAR_1, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
VAR_0, &fadt->firmware_ctrl,
sizeof fadt->firmware_ctrl);
fadt->VAR_4 = cpu_to_le32(VAR_4);
bios_linker_loader_add_pointer(VAR_1, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
VAR_0, &fadt->VAR_4,
sizeof fadt->VAR_4);
fadt_setup(fadt, VAR_2);
build_header(VAR_1, VAR_0,
(void *)fadt, "FACP", sizeof(*fadt), 1, VAR_5, VAR_6);
}
| [
"FUNC_0(GArray *VAR_0, GArray *VAR_1, AcpiPmInfo *VAR_2,\nunsigned VAR_3, unsigned VAR_4,\nconst char *VAR_5, const char *VAR_6)\n{",
"AcpiFadtDescriptorRev1 *fadt = acpi_data_push(VAR_0, sizeof(*fadt));",
"fadt->firmware_ctrl = cpu_to_le32(VAR_3);",
"bios_linker_loader_add_pointer(VAR_1, ACPI_BUILD_TABLE_FILE,\nACPI_BUILD_TABLE_FILE,\nVAR_0, &fadt->firmware_ctrl,\nsizeof fadt->firmware_ctrl);",
"fadt->VAR_4 = cpu_to_le32(VAR_4);",
"bios_linker_loader_add_pointer(VAR_1, ACPI_BUILD_TABLE_FILE,\nACPI_BUILD_TABLE_FILE,\nVAR_0, &fadt->VAR_4,\nsizeof fadt->VAR_4);",
"fadt_setup(fadt, VAR_2);",
"build_header(VAR_1, VAR_0,\n(void *)fadt, \"FACP\", sizeof(*fadt), 1, VAR_5, VAR_6);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
17,
19,
21,
23
],
[
27
],
[
31,
33,
35,
37
],
[
41
],
[
45,
47
],
[
49
]
] |
19,478 | static void test_visitor_in_bool(TestInputVisitorData *data,
const void *unused)
{
bool res = false;
Visitor *v;
v = visitor_input_test_init(data, "true");
visit_type_bool(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, true);
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void test_visitor_in_bool(TestInputVisitorData *data,
const void *unused)
{
bool res = false;
Visitor *v;
v = visitor_input_test_init(data, "true");
visit_type_bool(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, true);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
bool res = false;
Visitor *v;
v = visitor_input_test_init(VAR_0, "true");
visit_type_bool(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, true);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"bool res = false;",
"Visitor *v;",
"v = visitor_input_test_init(VAR_0, \"true\");",
"visit_type_bool(v, NULL, &res, &error_abort);",
"g_assert_cmpint(res, ==, true);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
]
] |
19,481 | static void e500plat_init(QEMUMachineInitArgs *args)
{
ram_addr_t ram_size = args->ram_size;
const char *boot_device = args->boot_device;
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
PPCE500Params params = {
.ram_size = ram_size,
.boot_device = boot_device,
.kernel_filename = kernel_filename,
.kernel_cmdline = kernel_cmdline,
.initrd_filename = initrd_filename,
.cpu_model = cpu_model,
.pci_first_slot = 0x11,
.pci_nr_slots = 2,
.fixup_devtree = e500plat_fixup_devtree,
};
ppce500_init(¶ms);
}
| false | qemu | 3bb7e02a9725a24e5bf915b35f914f82f5b07a1f | static void e500plat_init(QEMUMachineInitArgs *args)
{
ram_addr_t ram_size = args->ram_size;
const char *boot_device = args->boot_device;
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
PPCE500Params params = {
.ram_size = ram_size,
.boot_device = boot_device,
.kernel_filename = kernel_filename,
.kernel_cmdline = kernel_cmdline,
.initrd_filename = initrd_filename,
.cpu_model = cpu_model,
.pci_first_slot = 0x11,
.pci_nr_slots = 2,
.fixup_devtree = e500plat_fixup_devtree,
};
ppce500_init(¶ms);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QEMUMachineInitArgs *VAR_0)
{
ram_addr_t ram_size = VAR_0->ram_size;
const char *VAR_1 = VAR_0->VAR_1;
const char *VAR_2 = VAR_0->VAR_2;
const char *VAR_3 = VAR_0->VAR_3;
const char *VAR_4 = VAR_0->VAR_4;
const char *VAR_5 = VAR_0->VAR_5;
PPCE500Params params = {
.ram_size = ram_size,
.VAR_1 = VAR_1,
.VAR_3 = VAR_3,
.VAR_4 = VAR_4,
.VAR_5 = VAR_5,
.VAR_2 = VAR_2,
.pci_first_slot = 0x11,
.pci_nr_slots = 2,
.fixup_devtree = e500plat_fixup_devtree,
};
ppce500_init(¶ms);
}
| [
"static void FUNC_0(QEMUMachineInitArgs *VAR_0)\n{",
"ram_addr_t ram_size = VAR_0->ram_size;",
"const char *VAR_1 = VAR_0->VAR_1;",
"const char *VAR_2 = VAR_0->VAR_2;",
"const char *VAR_3 = VAR_0->VAR_3;",
"const char *VAR_4 = VAR_0->VAR_4;",
"const char *VAR_5 = VAR_0->VAR_5;",
"PPCE500Params params = {",
".ram_size = ram_size,\n.VAR_1 = VAR_1,\n.VAR_3 = VAR_3,\n.VAR_4 = VAR_4,\n.VAR_5 = VAR_5,\n.VAR_2 = VAR_2,\n.pci_first_slot = 0x11,\n.pci_nr_slots = 2,\n.fixup_devtree = e500plat_fixup_devtree,\n};",
"ppce500_init(¶ms);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21,
23,
25,
27,
29,
31,
33,
35,
37
],
[
41
],
[
43
]
] |
19,482 | static void gdb_read_byte(GDBState *s, int ch)
{
CPUState *env = s->env;
int i, csum;
uint8_t reply;
#ifndef CONFIG_USER_ONLY
if (s->last_packet_len) {
/* Waiting for a response to the last packet. If we see the start
of a new command then abandon the previous response. */
if (ch == '-') {
#ifdef DEBUG_GDB
printf("Got NACK, retransmitting\n");
#endif
put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len);
}
#ifdef DEBUG_GDB
else if (ch == '+')
printf("Got ACK\n");
else
printf("Got '%c' when expecting ACK/NACK\n", ch);
#endif
if (ch == '+' || ch == '$')
s->last_packet_len = 0;
if (ch != '$')
return;
}
if (vm_running) {
/* when the CPU is running, we cannot do anything except stop
it when receiving a char */
vm_stop(EXCP_INTERRUPT);
} else
#endif
{
switch(s->state) {
case RS_IDLE:
if (ch == '$') {
s->line_buf_index = 0;
s->state = RS_GETLINE;
}
break;
case RS_GETLINE:
if (ch == '#') {
s->state = RS_CHKSUM1;
} else if (s->line_buf_index >= sizeof(s->line_buf) - 1) {
s->state = RS_IDLE;
} else {
s->line_buf[s->line_buf_index++] = ch;
}
break;
case RS_CHKSUM1:
s->line_buf[s->line_buf_index] = '\0';
s->line_csum = fromhex(ch) << 4;
s->state = RS_CHKSUM2;
break;
case RS_CHKSUM2:
s->line_csum |= fromhex(ch);
csum = 0;
for(i = 0; i < s->line_buf_index; i++) {
csum += s->line_buf[i];
}
if (s->line_csum != (csum & 0xff)) {
reply = '-';
put_buffer(s, &reply, 1);
s->state = RS_IDLE;
} else {
reply = '+';
put_buffer(s, &reply, 1);
s->state = gdb_handle_packet(s, env, s->line_buf);
}
break;
default:
abort();
}
}
}
| false | qemu | 880a7578381d1c7ed4d41c7599ae3cc06567a824 | static void gdb_read_byte(GDBState *s, int ch)
{
CPUState *env = s->env;
int i, csum;
uint8_t reply;
#ifndef CONFIG_USER_ONLY
if (s->last_packet_len) {
if (ch == '-') {
#ifdef DEBUG_GDB
printf("Got NACK, retransmitting\n");
#endif
put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len);
}
#ifdef DEBUG_GDB
else if (ch == '+')
printf("Got ACK\n");
else
printf("Got '%c' when expecting ACK/NACK\n", ch);
#endif
if (ch == '+' || ch == '$')
s->last_packet_len = 0;
if (ch != '$')
return;
}
if (vm_running) {
vm_stop(EXCP_INTERRUPT);
} else
#endif
{
switch(s->state) {
case RS_IDLE:
if (ch == '$') {
s->line_buf_index = 0;
s->state = RS_GETLINE;
}
break;
case RS_GETLINE:
if (ch == '#') {
s->state = RS_CHKSUM1;
} else if (s->line_buf_index >= sizeof(s->line_buf) - 1) {
s->state = RS_IDLE;
} else {
s->line_buf[s->line_buf_index++] = ch;
}
break;
case RS_CHKSUM1:
s->line_buf[s->line_buf_index] = '\0';
s->line_csum = fromhex(ch) << 4;
s->state = RS_CHKSUM2;
break;
case RS_CHKSUM2:
s->line_csum |= fromhex(ch);
csum = 0;
for(i = 0; i < s->line_buf_index; i++) {
csum += s->line_buf[i];
}
if (s->line_csum != (csum & 0xff)) {
reply = '-';
put_buffer(s, &reply, 1);
s->state = RS_IDLE;
} else {
reply = '+';
put_buffer(s, &reply, 1);
s->state = gdb_handle_packet(s, env, s->line_buf);
}
break;
default:
abort();
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(GDBState *VAR_0, int VAR_1)
{
CPUState *env = VAR_0->env;
int VAR_2, VAR_3;
uint8_t reply;
#ifndef CONFIG_USER_ONLY
if (VAR_0->last_packet_len) {
if (VAR_1 == '-') {
#ifdef DEBUG_GDB
printf("Got NACK, retransmitting\n");
#endif
put_buffer(VAR_0, (uint8_t *)VAR_0->last_packet, VAR_0->last_packet_len);
}
#ifdef DEBUG_GDB
else if (VAR_1 == '+')
printf("Got ACK\n");
else
printf("Got '%c' when expecting ACK/NACK\n", VAR_1);
#endif
if (VAR_1 == '+' || VAR_1 == '$')
VAR_0->last_packet_len = 0;
if (VAR_1 != '$')
return;
}
if (vm_running) {
vm_stop(EXCP_INTERRUPT);
} else
#endif
{
switch(VAR_0->state) {
case RS_IDLE:
if (VAR_1 == '$') {
VAR_0->line_buf_index = 0;
VAR_0->state = RS_GETLINE;
}
break;
case RS_GETLINE:
if (VAR_1 == '#') {
VAR_0->state = RS_CHKSUM1;
} else if (VAR_0->line_buf_index >= sizeof(VAR_0->line_buf) - 1) {
VAR_0->state = RS_IDLE;
} else {
VAR_0->line_buf[VAR_0->line_buf_index++] = VAR_1;
}
break;
case RS_CHKSUM1:
VAR_0->line_buf[VAR_0->line_buf_index] = '\0';
VAR_0->line_csum = fromhex(VAR_1) << 4;
VAR_0->state = RS_CHKSUM2;
break;
case RS_CHKSUM2:
VAR_0->line_csum |= fromhex(VAR_1);
VAR_3 = 0;
for(VAR_2 = 0; VAR_2 < VAR_0->line_buf_index; VAR_2++) {
VAR_3 += VAR_0->line_buf[VAR_2];
}
if (VAR_0->line_csum != (VAR_3 & 0xff)) {
reply = '-';
put_buffer(VAR_0, &reply, 1);
VAR_0->state = RS_IDLE;
} else {
reply = '+';
put_buffer(VAR_0, &reply, 1);
VAR_0->state = gdb_handle_packet(VAR_0, env, VAR_0->line_buf);
}
break;
default:
abort();
}
}
}
| [
"static void FUNC_0(GDBState *VAR_0, int VAR_1)\n{",
"CPUState *env = VAR_0->env;",
"int VAR_2, VAR_3;",
"uint8_t reply;",
"#ifndef CONFIG_USER_ONLY\nif (VAR_0->last_packet_len) {",
"if (VAR_1 == '-') {",
"#ifdef DEBUG_GDB\nprintf(\"Got NACK, retransmitting\\n\");",
"#endif\nput_buffer(VAR_0, (uint8_t *)VAR_0->last_packet, VAR_0->last_packet_len);",
"}",
"#ifdef DEBUG_GDB\nelse if (VAR_1 == '+')\nprintf(\"Got ACK\\n\");",
"else\nprintf(\"Got '%c' when expecting ACK/NACK\\n\", VAR_1);",
"#endif\nif (VAR_1 == '+' || VAR_1 == '$')\nVAR_0->last_packet_len = 0;",
"if (VAR_1 != '$')\nreturn;",
"}",
"if (vm_running) {",
"vm_stop(EXCP_INTERRUPT);",
"} else",
"#endif\n{",
"switch(VAR_0->state) {",
"case RS_IDLE:\nif (VAR_1 == '$') {",
"VAR_0->line_buf_index = 0;",
"VAR_0->state = RS_GETLINE;",
"}",
"break;",
"case RS_GETLINE:\nif (VAR_1 == '#') {",
"VAR_0->state = RS_CHKSUM1;",
"} else if (VAR_0->line_buf_index >= sizeof(VAR_0->line_buf) - 1) {",
"VAR_0->state = RS_IDLE;",
"} else {",
"VAR_0->line_buf[VAR_0->line_buf_index++] = VAR_1;",
"}",
"break;",
"case RS_CHKSUM1:\nVAR_0->line_buf[VAR_0->line_buf_index] = '\\0';",
"VAR_0->line_csum = fromhex(VAR_1) << 4;",
"VAR_0->state = RS_CHKSUM2;",
"break;",
"case RS_CHKSUM2:\nVAR_0->line_csum |= fromhex(VAR_1);",
"VAR_3 = 0;",
"for(VAR_2 = 0; VAR_2 < VAR_0->line_buf_index; VAR_2++) {",
"VAR_3 += VAR_0->line_buf[VAR_2];",
"}",
"if (VAR_0->line_csum != (VAR_3 & 0xff)) {",
"reply = '-';",
"put_buffer(VAR_0, &reply, 1);",
"VAR_0->state = RS_IDLE;",
"} else {",
"reply = '+';",
"put_buffer(VAR_0, &reply, 1);",
"VAR_0->state = gdb_handle_packet(VAR_0, env, VAR_0->line_buf);",
"}",
"break;",
"default:\nabort();",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33,
35,
37
],
[
39,
41
],
[
43,
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
]
] |
19,483 | int ff_hevc_decode_nal_pps(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
HEVCSPS *sps = NULL;
int pic_area_in_ctbs;
int log2_diff_ctb_min_tb_size;
int i, j, x, y, ctb_addr_rs, tile_id;
int ret = 0;
unsigned int pps_id = 0;
AVBufferRef *pps_buf;
HEVCPPS *pps = av_mallocz(sizeof(*pps));
if (!pps)
return AVERROR(ENOMEM);
pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps),
hevc_pps_free, NULL, 0);
if (!pps_buf) {
av_freep(&pps);
return AVERROR(ENOMEM);
}
av_log(s->avctx, AV_LOG_DEBUG, "Decoding PPS\n");
// Default values
pps->loop_filter_across_tiles_enabled_flag = 1;
pps->num_tile_columns = 1;
pps->num_tile_rows = 1;
pps->uniform_spacing_flag = 1;
pps->disable_dbf = 0;
pps->beta_offset = 0;
pps->tc_offset = 0;
pps->log2_max_transform_skip_block_size = 2;
// Coded parameters
pps_id = get_ue_golomb_long(gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->sps_id = get_ue_golomb_long(gb);
if (pps->sps_id >= MAX_SPS_COUNT) {
av_log(s->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (!s->sps_list[pps->sps_id]) {
av_log(s->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
sps = (HEVCSPS *)s->sps_list[pps->sps_id]->data;
pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
pps->output_flag_present_flag = get_bits1(gb);
pps->num_extra_slice_header_bits = get_bits(gb, 3);
pps->sign_data_hiding_flag = get_bits1(gb);
pps->cabac_init_present_flag = get_bits1(gb);
pps->num_ref_idx_l0_default_active = get_ue_golomb_long(gb) + 1;
pps->num_ref_idx_l1_default_active = get_ue_golomb_long(gb) + 1;
pps->pic_init_qp_minus26 = get_se_golomb(gb);
pps->constrained_intra_pred_flag = get_bits1(gb);
pps->transform_skip_enabled_flag = get_bits1(gb);
pps->cu_qp_delta_enabled_flag = get_bits1(gb);
pps->diff_cu_qp_delta_depth = 0;
if (pps->cu_qp_delta_enabled_flag)
pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);
pps->cb_qp_offset = get_se_golomb(gb);
if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
av_log(s->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
pps->cb_qp_offset);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->cr_qp_offset = get_se_golomb(gb);
if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) {
av_log(s->avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n",
pps->cr_qp_offset);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->pic_slice_level_chroma_qp_offsets_present_flag = get_bits1(gb);
pps->weighted_pred_flag = get_bits1(gb);
pps->weighted_bipred_flag = get_bits1(gb);
pps->transquant_bypass_enable_flag = get_bits1(gb);
pps->tiles_enabled_flag = get_bits1(gb);
pps->entropy_coding_sync_enabled_flag = get_bits1(gb);
if (pps->tiles_enabled_flag) {
pps->num_tile_columns = get_ue_golomb_long(gb) + 1;
pps->num_tile_rows = get_ue_golomb_long(gb) + 1;
if (pps->num_tile_columns == 0 ||
pps->num_tile_columns >= sps->width) {
av_log(s->avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n",
pps->num_tile_columns - 1);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (pps->num_tile_rows == 0 ||
pps->num_tile_rows >= sps->height) {
av_log(s->avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n",
pps->num_tile_rows - 1);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
if (!pps->column_width || !pps->row_height) {
ret = AVERROR(ENOMEM);
goto err;
}
pps->uniform_spacing_flag = get_bits1(gb);
if (!pps->uniform_spacing_flag) {
uint64_t sum = 0;
for (i = 0; i < pps->num_tile_columns - 1; i++) {
pps->column_width[i] = get_ue_golomb_long(gb) + 1;
sum += pps->column_width[i];
}
if (sum >= sps->ctb_width) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid tile widths.\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width[pps->num_tile_columns - 1] = sps->ctb_width - sum;
sum = 0;
for (i = 0; i < pps->num_tile_rows - 1; i++) {
pps->row_height[i] = get_ue_golomb_long(gb) + 1;
sum += pps->row_height[i];
}
if (sum >= sps->ctb_height) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid tile heights.\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->row_height[pps->num_tile_rows - 1] = sps->ctb_height - sum;
}
pps->loop_filter_across_tiles_enabled_flag = get_bits1(gb);
}
pps->seq_loop_filter_across_slices_enabled_flag = get_bits1(gb);
pps->deblocking_filter_control_present_flag = get_bits1(gb);
if (pps->deblocking_filter_control_present_flag) {
pps->deblocking_filter_override_enabled_flag = get_bits1(gb);
pps->disable_dbf = get_bits1(gb);
if (!pps->disable_dbf) {
pps->beta_offset = get_se_golomb(gb) * 2;
pps->tc_offset = get_se_golomb(gb) * 2;
if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) {
av_log(s->avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n",
pps->beta_offset/2);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) {
av_log(s->avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n",
pps->tc_offset/2);
ret = AVERROR_INVALIDDATA;
goto err;
}
}
}
pps->scaling_list_data_present_flag = get_bits1(gb);
if (pps->scaling_list_data_present_flag) {
set_default_scaling_list_data(&pps->scaling_list);
ret = scaling_list_data(s, &pps->scaling_list, sps);
if (ret < 0)
goto err;
}
pps->lists_modification_present_flag = get_bits1(gb);
pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2;
if (pps->log2_parallel_merge_level > sps->log2_ctb_size) {
av_log(s->avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n",
pps->log2_parallel_merge_level - 2);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->slice_header_extension_present_flag = get_bits1(gb);
if (get_bits1(gb)) { // pps_extension_present_flag
int pps_range_extensions_flag = get_bits1(gb);
/* int pps_extension_7bits = */ get_bits(gb, 7);
if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && pps_range_extensions_flag) {
pps_range_extensions(s, pps, sps);
}
}
// Inferred parameters
pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));
pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd));
pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX));
if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) {
ret = AVERROR(ENOMEM);
goto err;
}
if (pps->uniform_spacing_flag) {
if (!pps->column_width) {
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
}
if (!pps->column_width || !pps->row_height) {
ret = AVERROR(ENOMEM);
goto err;
}
for (i = 0; i < pps->num_tile_columns; i++) {
pps->column_width[i] = ((i + 1) * sps->ctb_width) / pps->num_tile_columns -
(i * sps->ctb_width) / pps->num_tile_columns;
}
for (i = 0; i < pps->num_tile_rows; i++) {
pps->row_height[i] = ((i + 1) * sps->ctb_height) / pps->num_tile_rows -
(i * sps->ctb_height) / pps->num_tile_rows;
}
}
pps->col_bd[0] = 0;
for (i = 0; i < pps->num_tile_columns; i++)
pps->col_bd[i + 1] = pps->col_bd[i] + pps->column_width[i];
pps->row_bd[0] = 0;
for (i = 0; i < pps->num_tile_rows; i++)
pps->row_bd[i + 1] = pps->row_bd[i] + pps->row_height[i];
for (i = 0, j = 0; i < sps->ctb_width; i++) {
if (i > pps->col_bd[j])
j++;
pps->col_idxX[i] = j;
}
/**
* 6.5
*/
pic_area_in_ctbs = sps->ctb_width * sps->ctb_height;
pps->ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_rs_to_ts));
pps->ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_ts_to_rs));
pps->tile_id = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->tile_id));
pps->min_tb_addr_zs_tab = av_malloc_array((sps->tb_mask+2) * (sps->tb_mask+2), sizeof(*pps->min_tb_addr_zs_tab));
if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||
!pps->tile_id || !pps->min_tb_addr_zs_tab) {
ret = AVERROR(ENOMEM);
goto err;
}
for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
int tb_x = ctb_addr_rs % sps->ctb_width;
int tb_y = ctb_addr_rs / sps->ctb_width;
int tile_x = 0;
int tile_y = 0;
int val = 0;
for (i = 0; i < pps->num_tile_columns; i++) {
if (tb_x < pps->col_bd[i + 1]) {
tile_x = i;
break;
}
}
for (i = 0; i < pps->num_tile_rows; i++) {
if (tb_y < pps->row_bd[i + 1]) {
tile_y = i;
break;
}
}
for (i = 0; i < tile_x; i++)
val += pps->row_height[tile_y] * pps->column_width[i];
for (i = 0; i < tile_y; i++)
val += sps->ctb_width * pps->row_height[i];
val += (tb_y - pps->row_bd[tile_y]) * pps->column_width[tile_x] +
tb_x - pps->col_bd[tile_x];
pps->ctb_addr_rs_to_ts[ctb_addr_rs] = val;
pps->ctb_addr_ts_to_rs[val] = ctb_addr_rs;
}
for (j = 0, tile_id = 0; j < pps->num_tile_rows; j++)
for (i = 0; i < pps->num_tile_columns; i++, tile_id++)
for (y = pps->row_bd[j]; y < pps->row_bd[j + 1]; y++)
for (x = pps->col_bd[i]; x < pps->col_bd[i + 1]; x++)
pps->tile_id[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + x]] = tile_id;
pps->tile_pos_rs = av_malloc_array(tile_id, sizeof(*pps->tile_pos_rs));
if (!pps->tile_pos_rs) {
ret = AVERROR(ENOMEM);
goto err;
}
for (j = 0; j < pps->num_tile_rows; j++)
for (i = 0; i < pps->num_tile_columns; i++)
pps->tile_pos_rs[j * pps->num_tile_columns + i] = pps->row_bd[j] * sps->ctb_width + pps->col_bd[i];
log2_diff_ctb_min_tb_size = sps->log2_ctb_size - sps->log2_min_tb_size;
pps->min_tb_addr_zs = &pps->min_tb_addr_zs_tab[1*(sps->tb_mask+2)+1];
for (y = 0; y < sps->tb_mask+2; y++) {
pps->min_tb_addr_zs_tab[y*(sps->tb_mask+2)] = -1;
pps->min_tb_addr_zs_tab[y] = -1;
}
for (y = 0; y < sps->tb_mask+1; y++) {
for (x = 0; x < sps->tb_mask+1; x++) {
int tb_x = x >> log2_diff_ctb_min_tb_size;
int tb_y = y >> log2_diff_ctb_min_tb_size;
int ctb_addr_rs = sps->ctb_width * tb_y + tb_x;
int val = pps->ctb_addr_rs_to_ts[ctb_addr_rs] <<
(log2_diff_ctb_min_tb_size * 2);
for (i = 0; i < log2_diff_ctb_min_tb_size; i++) {
int m = 1 << i;
val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
}
pps->min_tb_addr_zs[y * (sps->tb_mask+2) + x] = val;
}
}
if (get_bits_left(gb) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Overread PPS by %d bits\n", -get_bits_left(gb));
goto err;
}
av_buffer_unref(&s->pps_list[pps_id]);
s->pps_list[pps_id] = pps_buf;
return 0;
err:
av_buffer_unref(&pps_buf);
return ret;
}
| false | FFmpeg | 9f9440bd8122cc8798139c9370db0873a24ae14b | int ff_hevc_decode_nal_pps(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
HEVCSPS *sps = NULL;
int pic_area_in_ctbs;
int log2_diff_ctb_min_tb_size;
int i, j, x, y, ctb_addr_rs, tile_id;
int ret = 0;
unsigned int pps_id = 0;
AVBufferRef *pps_buf;
HEVCPPS *pps = av_mallocz(sizeof(*pps));
if (!pps)
return AVERROR(ENOMEM);
pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps),
hevc_pps_free, NULL, 0);
if (!pps_buf) {
av_freep(&pps);
return AVERROR(ENOMEM);
}
av_log(s->avctx, AV_LOG_DEBUG, "Decoding PPS\n");
pps->loop_filter_across_tiles_enabled_flag = 1;
pps->num_tile_columns = 1;
pps->num_tile_rows = 1;
pps->uniform_spacing_flag = 1;
pps->disable_dbf = 0;
pps->beta_offset = 0;
pps->tc_offset = 0;
pps->log2_max_transform_skip_block_size = 2;
pps_id = get_ue_golomb_long(gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->sps_id = get_ue_golomb_long(gb);
if (pps->sps_id >= MAX_SPS_COUNT) {
av_log(s->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (!s->sps_list[pps->sps_id]) {
av_log(s->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
sps = (HEVCSPS *)s->sps_list[pps->sps_id]->data;
pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
pps->output_flag_present_flag = get_bits1(gb);
pps->num_extra_slice_header_bits = get_bits(gb, 3);
pps->sign_data_hiding_flag = get_bits1(gb);
pps->cabac_init_present_flag = get_bits1(gb);
pps->num_ref_idx_l0_default_active = get_ue_golomb_long(gb) + 1;
pps->num_ref_idx_l1_default_active = get_ue_golomb_long(gb) + 1;
pps->pic_init_qp_minus26 = get_se_golomb(gb);
pps->constrained_intra_pred_flag = get_bits1(gb);
pps->transform_skip_enabled_flag = get_bits1(gb);
pps->cu_qp_delta_enabled_flag = get_bits1(gb);
pps->diff_cu_qp_delta_depth = 0;
if (pps->cu_qp_delta_enabled_flag)
pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);
pps->cb_qp_offset = get_se_golomb(gb);
if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
av_log(s->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
pps->cb_qp_offset);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->cr_qp_offset = get_se_golomb(gb);
if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) {
av_log(s->avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n",
pps->cr_qp_offset);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->pic_slice_level_chroma_qp_offsets_present_flag = get_bits1(gb);
pps->weighted_pred_flag = get_bits1(gb);
pps->weighted_bipred_flag = get_bits1(gb);
pps->transquant_bypass_enable_flag = get_bits1(gb);
pps->tiles_enabled_flag = get_bits1(gb);
pps->entropy_coding_sync_enabled_flag = get_bits1(gb);
if (pps->tiles_enabled_flag) {
pps->num_tile_columns = get_ue_golomb_long(gb) + 1;
pps->num_tile_rows = get_ue_golomb_long(gb) + 1;
if (pps->num_tile_columns == 0 ||
pps->num_tile_columns >= sps->width) {
av_log(s->avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n",
pps->num_tile_columns - 1);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (pps->num_tile_rows == 0 ||
pps->num_tile_rows >= sps->height) {
av_log(s->avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n",
pps->num_tile_rows - 1);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
if (!pps->column_width || !pps->row_height) {
ret = AVERROR(ENOMEM);
goto err;
}
pps->uniform_spacing_flag = get_bits1(gb);
if (!pps->uniform_spacing_flag) {
uint64_t sum = 0;
for (i = 0; i < pps->num_tile_columns - 1; i++) {
pps->column_width[i] = get_ue_golomb_long(gb) + 1;
sum += pps->column_width[i];
}
if (sum >= sps->ctb_width) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid tile widths.\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width[pps->num_tile_columns - 1] = sps->ctb_width - sum;
sum = 0;
for (i = 0; i < pps->num_tile_rows - 1; i++) {
pps->row_height[i] = get_ue_golomb_long(gb) + 1;
sum += pps->row_height[i];
}
if (sum >= sps->ctb_height) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid tile heights.\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->row_height[pps->num_tile_rows - 1] = sps->ctb_height - sum;
}
pps->loop_filter_across_tiles_enabled_flag = get_bits1(gb);
}
pps->seq_loop_filter_across_slices_enabled_flag = get_bits1(gb);
pps->deblocking_filter_control_present_flag = get_bits1(gb);
if (pps->deblocking_filter_control_present_flag) {
pps->deblocking_filter_override_enabled_flag = get_bits1(gb);
pps->disable_dbf = get_bits1(gb);
if (!pps->disable_dbf) {
pps->beta_offset = get_se_golomb(gb) * 2;
pps->tc_offset = get_se_golomb(gb) * 2;
if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) {
av_log(s->avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n",
pps->beta_offset/2);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) {
av_log(s->avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n",
pps->tc_offset/2);
ret = AVERROR_INVALIDDATA;
goto err;
}
}
}
pps->scaling_list_data_present_flag = get_bits1(gb);
if (pps->scaling_list_data_present_flag) {
set_default_scaling_list_data(&pps->scaling_list);
ret = scaling_list_data(s, &pps->scaling_list, sps);
if (ret < 0)
goto err;
}
pps->lists_modification_present_flag = get_bits1(gb);
pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2;
if (pps->log2_parallel_merge_level > sps->log2_ctb_size) {
av_log(s->avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n",
pps->log2_parallel_merge_level - 2);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->slice_header_extension_present_flag = get_bits1(gb);
if (get_bits1(gb)) {
int pps_range_extensions_flag = get_bits1(gb);
get_bits(gb, 7);
if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && pps_range_extensions_flag) {
pps_range_extensions(s, pps, sps);
}
}
pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));
pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd));
pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX));
if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) {
ret = AVERROR(ENOMEM);
goto err;
}
if (pps->uniform_spacing_flag) {
if (!pps->column_width) {
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
}
if (!pps->column_width || !pps->row_height) {
ret = AVERROR(ENOMEM);
goto err;
}
for (i = 0; i < pps->num_tile_columns; i++) {
pps->column_width[i] = ((i + 1) * sps->ctb_width) / pps->num_tile_columns -
(i * sps->ctb_width) / pps->num_tile_columns;
}
for (i = 0; i < pps->num_tile_rows; i++) {
pps->row_height[i] = ((i + 1) * sps->ctb_height) / pps->num_tile_rows -
(i * sps->ctb_height) / pps->num_tile_rows;
}
}
pps->col_bd[0] = 0;
for (i = 0; i < pps->num_tile_columns; i++)
pps->col_bd[i + 1] = pps->col_bd[i] + pps->column_width[i];
pps->row_bd[0] = 0;
for (i = 0; i < pps->num_tile_rows; i++)
pps->row_bd[i + 1] = pps->row_bd[i] + pps->row_height[i];
for (i = 0, j = 0; i < sps->ctb_width; i++) {
if (i > pps->col_bd[j])
j++;
pps->col_idxX[i] = j;
}
pic_area_in_ctbs = sps->ctb_width * sps->ctb_height;
pps->ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_rs_to_ts));
pps->ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_ts_to_rs));
pps->tile_id = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->tile_id));
pps->min_tb_addr_zs_tab = av_malloc_array((sps->tb_mask+2) * (sps->tb_mask+2), sizeof(*pps->min_tb_addr_zs_tab));
if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||
!pps->tile_id || !pps->min_tb_addr_zs_tab) {
ret = AVERROR(ENOMEM);
goto err;
}
for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
int tb_x = ctb_addr_rs % sps->ctb_width;
int tb_y = ctb_addr_rs / sps->ctb_width;
int tile_x = 0;
int tile_y = 0;
int val = 0;
for (i = 0; i < pps->num_tile_columns; i++) {
if (tb_x < pps->col_bd[i + 1]) {
tile_x = i;
break;
}
}
for (i = 0; i < pps->num_tile_rows; i++) {
if (tb_y < pps->row_bd[i + 1]) {
tile_y = i;
break;
}
}
for (i = 0; i < tile_x; i++)
val += pps->row_height[tile_y] * pps->column_width[i];
for (i = 0; i < tile_y; i++)
val += sps->ctb_width * pps->row_height[i];
val += (tb_y - pps->row_bd[tile_y]) * pps->column_width[tile_x] +
tb_x - pps->col_bd[tile_x];
pps->ctb_addr_rs_to_ts[ctb_addr_rs] = val;
pps->ctb_addr_ts_to_rs[val] = ctb_addr_rs;
}
for (j = 0, tile_id = 0; j < pps->num_tile_rows; j++)
for (i = 0; i < pps->num_tile_columns; i++, tile_id++)
for (y = pps->row_bd[j]; y < pps->row_bd[j + 1]; y++)
for (x = pps->col_bd[i]; x < pps->col_bd[i + 1]; x++)
pps->tile_id[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + x]] = tile_id;
pps->tile_pos_rs = av_malloc_array(tile_id, sizeof(*pps->tile_pos_rs));
if (!pps->tile_pos_rs) {
ret = AVERROR(ENOMEM);
goto err;
}
for (j = 0; j < pps->num_tile_rows; j++)
for (i = 0; i < pps->num_tile_columns; i++)
pps->tile_pos_rs[j * pps->num_tile_columns + i] = pps->row_bd[j] * sps->ctb_width + pps->col_bd[i];
log2_diff_ctb_min_tb_size = sps->log2_ctb_size - sps->log2_min_tb_size;
pps->min_tb_addr_zs = &pps->min_tb_addr_zs_tab[1*(sps->tb_mask+2)+1];
for (y = 0; y < sps->tb_mask+2; y++) {
pps->min_tb_addr_zs_tab[y*(sps->tb_mask+2)] = -1;
pps->min_tb_addr_zs_tab[y] = -1;
}
for (y = 0; y < sps->tb_mask+1; y++) {
for (x = 0; x < sps->tb_mask+1; x++) {
int tb_x = x >> log2_diff_ctb_min_tb_size;
int tb_y = y >> log2_diff_ctb_min_tb_size;
int ctb_addr_rs = sps->ctb_width * tb_y + tb_x;
int val = pps->ctb_addr_rs_to_ts[ctb_addr_rs] <<
(log2_diff_ctb_min_tb_size * 2);
for (i = 0; i < log2_diff_ctb_min_tb_size; i++) {
int m = 1 << i;
val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
}
pps->min_tb_addr_zs[y * (sps->tb_mask+2) + x] = val;
}
}
if (get_bits_left(gb) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Overread PPS by %d bits\n", -get_bits_left(gb));
goto err;
}
av_buffer_unref(&s->pps_list[pps_id]);
s->pps_list[pps_id] = pps_buf;
return 0;
err:
av_buffer_unref(&pps_buf);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(HEVCContext *VAR_0)
{
GetBitContext *gb = &VAR_0->HEVClc->gb;
HEVCSPS *sps = NULL;
int VAR_1;
int VAR_2;
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9 = 0;
unsigned int VAR_10 = 0;
AVBufferRef *pps_buf;
HEVCPPS *pps = av_mallocz(sizeof(*pps));
if (!pps)
return AVERROR(ENOMEM);
pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps),
hevc_pps_free, NULL, 0);
if (!pps_buf) {
av_freep(&pps);
return AVERROR(ENOMEM);
}
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Decoding PPS\n");
pps->loop_filter_across_tiles_enabled_flag = 1;
pps->num_tile_columns = 1;
pps->num_tile_rows = 1;
pps->uniform_spacing_flag = 1;
pps->disable_dbf = 0;
pps->beta_offset = 0;
pps->tc_offset = 0;
pps->log2_max_transform_skip_block_size = 2;
VAR_10 = get_ue_golomb_long(gb);
if (VAR_10 >= MAX_PPS_COUNT) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", VAR_10);
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
pps->sps_id = get_ue_golomb_long(gb);
if (pps->sps_id >= MAX_SPS_COUNT) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id);
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
if (!VAR_0->sps_list[pps->sps_id]) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id);
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
sps = (HEVCSPS *)VAR_0->sps_list[pps->sps_id]->data;
pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
pps->output_flag_present_flag = get_bits1(gb);
pps->num_extra_slice_header_bits = get_bits(gb, 3);
pps->sign_data_hiding_flag = get_bits1(gb);
pps->cabac_init_present_flag = get_bits1(gb);
pps->num_ref_idx_l0_default_active = get_ue_golomb_long(gb) + 1;
pps->num_ref_idx_l1_default_active = get_ue_golomb_long(gb) + 1;
pps->pic_init_qp_minus26 = get_se_golomb(gb);
pps->constrained_intra_pred_flag = get_bits1(gb);
pps->transform_skip_enabled_flag = get_bits1(gb);
pps->cu_qp_delta_enabled_flag = get_bits1(gb);
pps->diff_cu_qp_delta_depth = 0;
if (pps->cu_qp_delta_enabled_flag)
pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);
pps->cb_qp_offset = get_se_golomb(gb);
if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
pps->cb_qp_offset);
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
pps->cr_qp_offset = get_se_golomb(gb);
if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n",
pps->cr_qp_offset);
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
pps->pic_slice_level_chroma_qp_offsets_present_flag = get_bits1(gb);
pps->weighted_pred_flag = get_bits1(gb);
pps->weighted_bipred_flag = get_bits1(gb);
pps->transquant_bypass_enable_flag = get_bits1(gb);
pps->tiles_enabled_flag = get_bits1(gb);
pps->entropy_coding_sync_enabled_flag = get_bits1(gb);
if (pps->tiles_enabled_flag) {
pps->num_tile_columns = get_ue_golomb_long(gb) + 1;
pps->num_tile_rows = get_ue_golomb_long(gb) + 1;
if (pps->num_tile_columns == 0 ||
pps->num_tile_columns >= sps->width) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n",
pps->num_tile_columns - 1);
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
if (pps->num_tile_rows == 0 ||
pps->num_tile_rows >= sps->height) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n",
pps->num_tile_rows - 1);
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
if (!pps->column_width || !pps->row_height) {
VAR_9 = AVERROR(ENOMEM);
goto err;
}
pps->uniform_spacing_flag = get_bits1(gb);
if (!pps->uniform_spacing_flag) {
uint64_t sum = 0;
for (VAR_3 = 0; VAR_3 < pps->num_tile_columns - 1; VAR_3++) {
pps->column_width[VAR_3] = get_ue_golomb_long(gb) + 1;
sum += pps->column_width[VAR_3];
}
if (sum >= sps->ctb_width) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid tile widths.\n");
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width[pps->num_tile_columns - 1] = sps->ctb_width - sum;
sum = 0;
for (VAR_3 = 0; VAR_3 < pps->num_tile_rows - 1; VAR_3++) {
pps->row_height[VAR_3] = get_ue_golomb_long(gb) + 1;
sum += pps->row_height[VAR_3];
}
if (sum >= sps->ctb_height) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid tile heights.\n");
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
pps->row_height[pps->num_tile_rows - 1] = sps->ctb_height - sum;
}
pps->loop_filter_across_tiles_enabled_flag = get_bits1(gb);
}
pps->seq_loop_filter_across_slices_enabled_flag = get_bits1(gb);
pps->deblocking_filter_control_present_flag = get_bits1(gb);
if (pps->deblocking_filter_control_present_flag) {
pps->deblocking_filter_override_enabled_flag = get_bits1(gb);
pps->disable_dbf = get_bits1(gb);
if (!pps->disable_dbf) {
pps->beta_offset = get_se_golomb(gb) * 2;
pps->tc_offset = get_se_golomb(gb) * 2;
if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n",
pps->beta_offset/2);
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n",
pps->tc_offset/2);
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
}
}
pps->scaling_list_data_present_flag = get_bits1(gb);
if (pps->scaling_list_data_present_flag) {
set_default_scaling_list_data(&pps->scaling_list);
VAR_9 = scaling_list_data(VAR_0, &pps->scaling_list, sps);
if (VAR_9 < 0)
goto err;
}
pps->lists_modification_present_flag = get_bits1(gb);
pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2;
if (pps->log2_parallel_merge_level > sps->log2_ctb_size) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n",
pps->log2_parallel_merge_level - 2);
VAR_9 = AVERROR_INVALIDDATA;
goto err;
}
pps->slice_header_extension_present_flag = get_bits1(gb);
if (get_bits1(gb)) {
int VAR_11 = get_bits1(gb);
get_bits(gb, 7);
if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && VAR_11) {
pps_range_extensions(VAR_0, pps, sps);
}
}
pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));
pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd));
pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX));
if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) {
VAR_9 = AVERROR(ENOMEM);
goto err;
}
if (pps->uniform_spacing_flag) {
if (!pps->column_width) {
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
}
if (!pps->column_width || !pps->row_height) {
VAR_9 = AVERROR(ENOMEM);
goto err;
}
for (VAR_3 = 0; VAR_3 < pps->num_tile_columns; VAR_3++) {
pps->column_width[VAR_3] = ((VAR_3 + 1) * sps->ctb_width) / pps->num_tile_columns -
(VAR_3 * sps->ctb_width) / pps->num_tile_columns;
}
for (VAR_3 = 0; VAR_3 < pps->num_tile_rows; VAR_3++) {
pps->row_height[VAR_3] = ((VAR_3 + 1) * sps->ctb_height) / pps->num_tile_rows -
(VAR_3 * sps->ctb_height) / pps->num_tile_rows;
}
}
pps->col_bd[0] = 0;
for (VAR_3 = 0; VAR_3 < pps->num_tile_columns; VAR_3++)
pps->col_bd[VAR_3 + 1] = pps->col_bd[VAR_3] + pps->column_width[VAR_3];
pps->row_bd[0] = 0;
for (VAR_3 = 0; VAR_3 < pps->num_tile_rows; VAR_3++)
pps->row_bd[VAR_3 + 1] = pps->row_bd[VAR_3] + pps->row_height[VAR_3];
for (VAR_3 = 0, VAR_4 = 0; VAR_3 < sps->ctb_width; VAR_3++) {
if (VAR_3 > pps->col_bd[VAR_4])
VAR_4++;
pps->col_idxX[VAR_3] = VAR_4;
}
VAR_1 = sps->ctb_width * sps->ctb_height;
pps->ctb_addr_rs_to_ts = av_malloc_array(VAR_1, sizeof(*pps->ctb_addr_rs_to_ts));
pps->ctb_addr_ts_to_rs = av_malloc_array(VAR_1, sizeof(*pps->ctb_addr_ts_to_rs));
pps->VAR_8 = av_malloc_array(VAR_1, sizeof(*pps->VAR_8));
pps->min_tb_addr_zs_tab = av_malloc_array((sps->tb_mask+2) * (sps->tb_mask+2), sizeof(*pps->min_tb_addr_zs_tab));
if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||
!pps->VAR_8 || !pps->min_tb_addr_zs_tab) {
VAR_9 = AVERROR(ENOMEM);
goto err;
}
for (VAR_7 = 0; VAR_7 < VAR_1; VAR_7++) {
int VAR_12 = VAR_7 % sps->ctb_width;
int VAR_13 = VAR_7 / sps->ctb_width;
int VAR_14 = 0;
int VAR_15 = 0;
int VAR_16 = 0;
for (VAR_3 = 0; VAR_3 < pps->num_tile_columns; VAR_3++) {
if (VAR_12 < pps->col_bd[VAR_3 + 1]) {
VAR_14 = VAR_3;
break;
}
}
for (VAR_3 = 0; VAR_3 < pps->num_tile_rows; VAR_3++) {
if (VAR_13 < pps->row_bd[VAR_3 + 1]) {
VAR_15 = VAR_3;
break;
}
}
for (VAR_3 = 0; VAR_3 < VAR_14; VAR_3++)
VAR_16 += pps->row_height[VAR_15] * pps->column_width[VAR_3];
for (VAR_3 = 0; VAR_3 < VAR_15; VAR_3++)
VAR_16 += sps->ctb_width * pps->row_height[VAR_3];
VAR_16 += (VAR_13 - pps->row_bd[VAR_15]) * pps->column_width[VAR_14] +
VAR_12 - pps->col_bd[VAR_14];
pps->ctb_addr_rs_to_ts[VAR_7] = VAR_16;
pps->ctb_addr_ts_to_rs[VAR_16] = VAR_7;
}
for (VAR_4 = 0, VAR_8 = 0; VAR_4 < pps->num_tile_rows; VAR_4++)
for (VAR_3 = 0; VAR_3 < pps->num_tile_columns; VAR_3++, VAR_8++)
for (VAR_6 = pps->row_bd[VAR_4]; VAR_6 < pps->row_bd[VAR_4 + 1]; VAR_6++)
for (VAR_5 = pps->col_bd[VAR_3]; VAR_5 < pps->col_bd[VAR_3 + 1]; VAR_5++)
pps->VAR_8[pps->ctb_addr_rs_to_ts[VAR_6 * sps->ctb_width + VAR_5]] = VAR_8;
pps->tile_pos_rs = av_malloc_array(VAR_8, sizeof(*pps->tile_pos_rs));
if (!pps->tile_pos_rs) {
VAR_9 = AVERROR(ENOMEM);
goto err;
}
for (VAR_4 = 0; VAR_4 < pps->num_tile_rows; VAR_4++)
for (VAR_3 = 0; VAR_3 < pps->num_tile_columns; VAR_3++)
pps->tile_pos_rs[VAR_4 * pps->num_tile_columns + VAR_3] = pps->row_bd[VAR_4] * sps->ctb_width + pps->col_bd[VAR_3];
VAR_2 = sps->log2_ctb_size - sps->log2_min_tb_size;
pps->min_tb_addr_zs = &pps->min_tb_addr_zs_tab[1*(sps->tb_mask+2)+1];
for (VAR_6 = 0; VAR_6 < sps->tb_mask+2; VAR_6++) {
pps->min_tb_addr_zs_tab[VAR_6*(sps->tb_mask+2)] = -1;
pps->min_tb_addr_zs_tab[VAR_6] = -1;
}
for (VAR_6 = 0; VAR_6 < sps->tb_mask+1; VAR_6++) {
for (VAR_5 = 0; VAR_5 < sps->tb_mask+1; VAR_5++) {
int VAR_12 = VAR_5 >> VAR_2;
int VAR_13 = VAR_6 >> VAR_2;
int VAR_7 = sps->ctb_width * VAR_13 + VAR_12;
int VAR_16 = pps->ctb_addr_rs_to_ts[VAR_7] <<
(VAR_2 * 2);
for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {
int m = 1 << VAR_3;
VAR_16 += (m & VAR_5 ? m * m : 0) + (m & VAR_6 ? 2 * m * m : 0);
}
pps->min_tb_addr_zs[VAR_6 * (sps->tb_mask+2) + VAR_5] = VAR_16;
}
}
if (get_bits_left(gb) < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Overread PPS by %d bits\n", -get_bits_left(gb));
goto err;
}
av_buffer_unref(&VAR_0->pps_list[VAR_10]);
VAR_0->pps_list[VAR_10] = pps_buf;
return 0;
err:
av_buffer_unref(&pps_buf);
return VAR_9;
}
| [
"int FUNC_0(HEVCContext *VAR_0)\n{",
"GetBitContext *gb = &VAR_0->HEVClc->gb;",
"HEVCSPS *sps = NULL;",
"int VAR_1;",
"int VAR_2;",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9 = 0;",
"unsigned int VAR_10 = 0;",
"AVBufferRef *pps_buf;",
"HEVCPPS *pps = av_mallocz(sizeof(*pps));",
"if (!pps)\nreturn AVERROR(ENOMEM);",
"pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps),\nhevc_pps_free, NULL, 0);",
"if (!pps_buf) {",
"av_freep(&pps);",
"return AVERROR(ENOMEM);",
"}",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Decoding PPS\\n\");",
"pps->loop_filter_across_tiles_enabled_flag = 1;",
"pps->num_tile_columns = 1;",
"pps->num_tile_rows = 1;",
"pps->uniform_spacing_flag = 1;",
"pps->disable_dbf = 0;",
"pps->beta_offset = 0;",
"pps->tc_offset = 0;",
"pps->log2_max_transform_skip_block_size = 2;",
"VAR_10 = get_ue_golomb_long(gb);",
"if (VAR_10 >= MAX_PPS_COUNT) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"PPS id out of range: %d\\n\", VAR_10);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->sps_id = get_ue_golomb_long(gb);",
"if (pps->sps_id >= MAX_SPS_COUNT) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"SPS id out of range: %d\\n\", pps->sps_id);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"if (!VAR_0->sps_list[pps->sps_id]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"SPS %u does not exist.\\n\", pps->sps_id);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"sps = (HEVCSPS *)VAR_0->sps_list[pps->sps_id]->data;",
"pps->dependent_slice_segments_enabled_flag = get_bits1(gb);",
"pps->output_flag_present_flag = get_bits1(gb);",
"pps->num_extra_slice_header_bits = get_bits(gb, 3);",
"pps->sign_data_hiding_flag = get_bits1(gb);",
"pps->cabac_init_present_flag = get_bits1(gb);",
"pps->num_ref_idx_l0_default_active = get_ue_golomb_long(gb) + 1;",
"pps->num_ref_idx_l1_default_active = get_ue_golomb_long(gb) + 1;",
"pps->pic_init_qp_minus26 = get_se_golomb(gb);",
"pps->constrained_intra_pred_flag = get_bits1(gb);",
"pps->transform_skip_enabled_flag = get_bits1(gb);",
"pps->cu_qp_delta_enabled_flag = get_bits1(gb);",
"pps->diff_cu_qp_delta_depth = 0;",
"if (pps->cu_qp_delta_enabled_flag)\npps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);",
"pps->cb_qp_offset = get_se_golomb(gb);",
"if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"pps_cb_qp_offset out of range: %d\\n\",\npps->cb_qp_offset);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->cr_qp_offset = get_se_golomb(gb);",
"if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"pps_cr_qp_offset out of range: %d\\n\",\npps->cr_qp_offset);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->pic_slice_level_chroma_qp_offsets_present_flag = get_bits1(gb);",
"pps->weighted_pred_flag = get_bits1(gb);",
"pps->weighted_bipred_flag = get_bits1(gb);",
"pps->transquant_bypass_enable_flag = get_bits1(gb);",
"pps->tiles_enabled_flag = get_bits1(gb);",
"pps->entropy_coding_sync_enabled_flag = get_bits1(gb);",
"if (pps->tiles_enabled_flag) {",
"pps->num_tile_columns = get_ue_golomb_long(gb) + 1;",
"pps->num_tile_rows = get_ue_golomb_long(gb) + 1;",
"if (pps->num_tile_columns == 0 ||\npps->num_tile_columns >= sps->width) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"num_tile_columns_minus1 out of range: %d\\n\",\npps->num_tile_columns - 1);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"if (pps->num_tile_rows == 0 ||\npps->num_tile_rows >= sps->height) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"num_tile_rows_minus1 out of range: %d\\n\",\npps->num_tile_rows - 1);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));",
"pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));",
"if (!pps->column_width || !pps->row_height) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto err;",
"}",
"pps->uniform_spacing_flag = get_bits1(gb);",
"if (!pps->uniform_spacing_flag) {",
"uint64_t sum = 0;",
"for (VAR_3 = 0; VAR_3 < pps->num_tile_columns - 1; VAR_3++) {",
"pps->column_width[VAR_3] = get_ue_golomb_long(gb) + 1;",
"sum += pps->column_width[VAR_3];",
"}",
"if (sum >= sps->ctb_width) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid tile widths.\\n\");",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->column_width[pps->num_tile_columns - 1] = sps->ctb_width - sum;",
"sum = 0;",
"for (VAR_3 = 0; VAR_3 < pps->num_tile_rows - 1; VAR_3++) {",
"pps->row_height[VAR_3] = get_ue_golomb_long(gb) + 1;",
"sum += pps->row_height[VAR_3];",
"}",
"if (sum >= sps->ctb_height) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid tile heights.\\n\");",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->row_height[pps->num_tile_rows - 1] = sps->ctb_height - sum;",
"}",
"pps->loop_filter_across_tiles_enabled_flag = get_bits1(gb);",
"}",
"pps->seq_loop_filter_across_slices_enabled_flag = get_bits1(gb);",
"pps->deblocking_filter_control_present_flag = get_bits1(gb);",
"if (pps->deblocking_filter_control_present_flag) {",
"pps->deblocking_filter_override_enabled_flag = get_bits1(gb);",
"pps->disable_dbf = get_bits1(gb);",
"if (!pps->disable_dbf) {",
"pps->beta_offset = get_se_golomb(gb) * 2;",
"pps->tc_offset = get_se_golomb(gb) * 2;",
"if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"pps_beta_offset_div2 out of range: %d\\n\",\npps->beta_offset/2);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"pps_tc_offset_div2 out of range: %d\\n\",\npps->tc_offset/2);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"}",
"}",
"pps->scaling_list_data_present_flag = get_bits1(gb);",
"if (pps->scaling_list_data_present_flag) {",
"set_default_scaling_list_data(&pps->scaling_list);",
"VAR_9 = scaling_list_data(VAR_0, &pps->scaling_list, sps);",
"if (VAR_9 < 0)\ngoto err;",
"}",
"pps->lists_modification_present_flag = get_bits1(gb);",
"pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2;",
"if (pps->log2_parallel_merge_level > sps->log2_ctb_size) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"log2_parallel_merge_level_minus2 out of range: %d\\n\",\npps->log2_parallel_merge_level - 2);",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->slice_header_extension_present_flag = get_bits1(gb);",
"if (get_bits1(gb)) {",
"int VAR_11 = get_bits1(gb);",
"get_bits(gb, 7);",
"if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && VAR_11) {",
"pps_range_extensions(VAR_0, pps, sps);",
"}",
"}",
"pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));",
"pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd));",
"pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX));",
"if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto err;",
"}",
"if (pps->uniform_spacing_flag) {",
"if (!pps->column_width) {",
"pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));",
"pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));",
"}",
"if (!pps->column_width || !pps->row_height) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto err;",
"}",
"for (VAR_3 = 0; VAR_3 < pps->num_tile_columns; VAR_3++) {",
"pps->column_width[VAR_3] = ((VAR_3 + 1) * sps->ctb_width) / pps->num_tile_columns -\n(VAR_3 * sps->ctb_width) / pps->num_tile_columns;",
"}",
"for (VAR_3 = 0; VAR_3 < pps->num_tile_rows; VAR_3++) {",
"pps->row_height[VAR_3] = ((VAR_3 + 1) * sps->ctb_height) / pps->num_tile_rows -\n(VAR_3 * sps->ctb_height) / pps->num_tile_rows;",
"}",
"}",
"pps->col_bd[0] = 0;",
"for (VAR_3 = 0; VAR_3 < pps->num_tile_columns; VAR_3++)",
"pps->col_bd[VAR_3 + 1] = pps->col_bd[VAR_3] + pps->column_width[VAR_3];",
"pps->row_bd[0] = 0;",
"for (VAR_3 = 0; VAR_3 < pps->num_tile_rows; VAR_3++)",
"pps->row_bd[VAR_3 + 1] = pps->row_bd[VAR_3] + pps->row_height[VAR_3];",
"for (VAR_3 = 0, VAR_4 = 0; VAR_3 < sps->ctb_width; VAR_3++) {",
"if (VAR_3 > pps->col_bd[VAR_4])\nVAR_4++;",
"pps->col_idxX[VAR_3] = VAR_4;",
"}",
"VAR_1 = sps->ctb_width * sps->ctb_height;",
"pps->ctb_addr_rs_to_ts = av_malloc_array(VAR_1, sizeof(*pps->ctb_addr_rs_to_ts));",
"pps->ctb_addr_ts_to_rs = av_malloc_array(VAR_1, sizeof(*pps->ctb_addr_ts_to_rs));",
"pps->VAR_8 = av_malloc_array(VAR_1, sizeof(*pps->VAR_8));",
"pps->min_tb_addr_zs_tab = av_malloc_array((sps->tb_mask+2) * (sps->tb_mask+2), sizeof(*pps->min_tb_addr_zs_tab));",
"if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||\n!pps->VAR_8 || !pps->min_tb_addr_zs_tab) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto err;",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_1; VAR_7++) {",
"int VAR_12 = VAR_7 % sps->ctb_width;",
"int VAR_13 = VAR_7 / sps->ctb_width;",
"int VAR_14 = 0;",
"int VAR_15 = 0;",
"int VAR_16 = 0;",
"for (VAR_3 = 0; VAR_3 < pps->num_tile_columns; VAR_3++) {",
"if (VAR_12 < pps->col_bd[VAR_3 + 1]) {",
"VAR_14 = VAR_3;",
"break;",
"}",
"}",
"for (VAR_3 = 0; VAR_3 < pps->num_tile_rows; VAR_3++) {",
"if (VAR_13 < pps->row_bd[VAR_3 + 1]) {",
"VAR_15 = VAR_3;",
"break;",
"}",
"}",
"for (VAR_3 = 0; VAR_3 < VAR_14; VAR_3++)",
"VAR_16 += pps->row_height[VAR_15] * pps->column_width[VAR_3];",
"for (VAR_3 = 0; VAR_3 < VAR_15; VAR_3++)",
"VAR_16 += sps->ctb_width * pps->row_height[VAR_3];",
"VAR_16 += (VAR_13 - pps->row_bd[VAR_15]) * pps->column_width[VAR_14] +\nVAR_12 - pps->col_bd[VAR_14];",
"pps->ctb_addr_rs_to_ts[VAR_7] = VAR_16;",
"pps->ctb_addr_ts_to_rs[VAR_16] = VAR_7;",
"}",
"for (VAR_4 = 0, VAR_8 = 0; VAR_4 < pps->num_tile_rows; VAR_4++)",
"for (VAR_3 = 0; VAR_3 < pps->num_tile_columns; VAR_3++, VAR_8++)",
"for (VAR_6 = pps->row_bd[VAR_4]; VAR_6 < pps->row_bd[VAR_4 + 1]; VAR_6++)",
"for (VAR_5 = pps->col_bd[VAR_3]; VAR_5 < pps->col_bd[VAR_3 + 1]; VAR_5++)",
"pps->VAR_8[pps->ctb_addr_rs_to_ts[VAR_6 * sps->ctb_width + VAR_5]] = VAR_8;",
"pps->tile_pos_rs = av_malloc_array(VAR_8, sizeof(*pps->tile_pos_rs));",
"if (!pps->tile_pos_rs) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto err;",
"}",
"for (VAR_4 = 0; VAR_4 < pps->num_tile_rows; VAR_4++)",
"for (VAR_3 = 0; VAR_3 < pps->num_tile_columns; VAR_3++)",
"pps->tile_pos_rs[VAR_4 * pps->num_tile_columns + VAR_3] = pps->row_bd[VAR_4] * sps->ctb_width + pps->col_bd[VAR_3];",
"VAR_2 = sps->log2_ctb_size - sps->log2_min_tb_size;",
"pps->min_tb_addr_zs = &pps->min_tb_addr_zs_tab[1*(sps->tb_mask+2)+1];",
"for (VAR_6 = 0; VAR_6 < sps->tb_mask+2; VAR_6++) {",
"pps->min_tb_addr_zs_tab[VAR_6*(sps->tb_mask+2)] = -1;",
"pps->min_tb_addr_zs_tab[VAR_6] = -1;",
"}",
"for (VAR_6 = 0; VAR_6 < sps->tb_mask+1; VAR_6++) {",
"for (VAR_5 = 0; VAR_5 < sps->tb_mask+1; VAR_5++) {",
"int VAR_12 = VAR_5 >> VAR_2;",
"int VAR_13 = VAR_6 >> VAR_2;",
"int VAR_7 = sps->ctb_width * VAR_13 + VAR_12;",
"int VAR_16 = pps->ctb_addr_rs_to_ts[VAR_7] <<\n(VAR_2 * 2);",
"for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {",
"int m = 1 << VAR_3;",
"VAR_16 += (m & VAR_5 ? m * m : 0) + (m & VAR_6 ? 2 * m * m : 0);",
"}",
"pps->min_tb_addr_zs[VAR_6 * (sps->tb_mask+2) + VAR_5] = VAR_16;",
"}",
"}",
"if (get_bits_left(gb) < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Overread PPS by %d bits\\n\", -get_bits_left(gb));",
"goto err;",
"}",
"av_buffer_unref(&VAR_0->pps_list[VAR_10]);",
"VAR_0->pps_list[VAR_10] = pps_buf;",
"return 0;",
"err:\nav_buffer_unref(&pps_buf);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
21
],
[
23
],
[
27,
29
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
119
],
[
123
],
[
127
],
[
129
],
[
133
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147,
149
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
203
],
[
205,
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219,
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
307
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327,
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339,
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363,
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375,
377
],
[
379
],
[
381
],
[
383
],
[
387
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
445
],
[
447,
449
],
[
451
],
[
455
],
[
457,
459
],
[
461
],
[
463
],
[
467
],
[
469
],
[
471
],
[
475
],
[
477
],
[
479
],
[
483
],
[
485,
487
],
[
489
],
[
491
],
[
501
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513,
515
],
[
517
],
[
519
],
[
521
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
539
],
[
541
],
[
543
],
[
545
],
[
547
],
[
549
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
567
],
[
569
],
[
571
],
[
573
],
[
577,
579
],
[
583
],
[
585
],
[
587
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
615
],
[
617
],
[
619
],
[
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645,
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
665
],
[
667,
669
],
[
671
],
[
673
],
[
677
],
[
679
],
[
683
],
[
687,
689
],
[
691
],
[
693
]
] |
19,484 | static void ide_drive_pre_save(void *opaque)
{
IDEState *s = opaque;
s->cur_io_buffer_len = 0;
if (!(s->status & DRQ_STAT))
return;
s->cur_io_buffer_offset = s->data_ptr - s->io_buffer;
s->cur_io_buffer_len = s->data_end - s->data_ptr;
s->end_transfer_fn_idx = transfer_end_table_idx(s->end_transfer_func);
if (s->end_transfer_fn_idx == -1) {
fprintf(stderr, "%s: invalid end_transfer_func for DRQ_STAT\n",
__func__);
s->end_transfer_fn_idx = 2;
}
}
| false | qemu | 4fc8d6711aff7a9c11e402c3d77b481609f9f486 | static void ide_drive_pre_save(void *opaque)
{
IDEState *s = opaque;
s->cur_io_buffer_len = 0;
if (!(s->status & DRQ_STAT))
return;
s->cur_io_buffer_offset = s->data_ptr - s->io_buffer;
s->cur_io_buffer_len = s->data_end - s->data_ptr;
s->end_transfer_fn_idx = transfer_end_table_idx(s->end_transfer_func);
if (s->end_transfer_fn_idx == -1) {
fprintf(stderr, "%s: invalid end_transfer_func for DRQ_STAT\n",
__func__);
s->end_transfer_fn_idx = 2;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
IDEState *s = VAR_0;
s->cur_io_buffer_len = 0;
if (!(s->status & DRQ_STAT))
return;
s->cur_io_buffer_offset = s->data_ptr - s->io_buffer;
s->cur_io_buffer_len = s->data_end - s->data_ptr;
s->end_transfer_fn_idx = transfer_end_table_idx(s->end_transfer_func);
if (s->end_transfer_fn_idx == -1) {
fprintf(stderr, "%s: invalid end_transfer_func for DRQ_STAT\n",
__func__);
s->end_transfer_fn_idx = 2;
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"IDEState *s = VAR_0;",
"s->cur_io_buffer_len = 0;",
"if (!(s->status & DRQ_STAT))\nreturn;",
"s->cur_io_buffer_offset = s->data_ptr - s->io_buffer;",
"s->cur_io_buffer_len = s->data_end - s->data_ptr;",
"s->end_transfer_fn_idx = transfer_end_table_idx(s->end_transfer_func);",
"if (s->end_transfer_fn_idx == -1) {",
"fprintf(stderr, \"%s: invalid end_transfer_func for DRQ_STAT\\n\",\n__func__);",
"s->end_transfer_fn_idx = 2;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
]
] |
19,485 | static int gdb_breakpoint_remove(CPUState *env, target_ulong addr,
target_ulong len, int type)
{
switch (type) {
case GDB_BREAKPOINT_SW:
case GDB_BREAKPOINT_HW:
return cpu_breakpoint_remove(env, addr, BP_GDB);
#ifndef CONFIG_USER_ONLY
case GDB_WATCHPOINT_WRITE:
case GDB_WATCHPOINT_READ:
case GDB_WATCHPOINT_ACCESS:
return cpu_watchpoint_remove(env, addr, len, xlat_gdb_type[type]);
#endif
default:
return -ENOSYS;
}
}
| false | qemu | 880a7578381d1c7ed4d41c7599ae3cc06567a824 | static int gdb_breakpoint_remove(CPUState *env, target_ulong addr,
target_ulong len, int type)
{
switch (type) {
case GDB_BREAKPOINT_SW:
case GDB_BREAKPOINT_HW:
return cpu_breakpoint_remove(env, addr, BP_GDB);
#ifndef CONFIG_USER_ONLY
case GDB_WATCHPOINT_WRITE:
case GDB_WATCHPOINT_READ:
case GDB_WATCHPOINT_ACCESS:
return cpu_watchpoint_remove(env, addr, len, xlat_gdb_type[type]);
#endif
default:
return -ENOSYS;
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CPUState *VAR_0, target_ulong VAR_1,
target_ulong VAR_2, int VAR_3)
{
switch (VAR_3) {
case GDB_BREAKPOINT_SW:
case GDB_BREAKPOINT_HW:
return cpu_breakpoint_remove(VAR_0, VAR_1, BP_GDB);
#ifndef CONFIG_USER_ONLY
case GDB_WATCHPOINT_WRITE:
case GDB_WATCHPOINT_READ:
case GDB_WATCHPOINT_ACCESS:
return cpu_watchpoint_remove(VAR_0, VAR_1, VAR_2, xlat_gdb_type[VAR_3]);
#endif
default:
return -ENOSYS;
}
}
| [
"static int FUNC_0(CPUState *VAR_0, target_ulong VAR_1,\ntarget_ulong VAR_2, int VAR_3)\n{",
"switch (VAR_3) {",
"case GDB_BREAKPOINT_SW:\ncase GDB_BREAKPOINT_HW:\nreturn cpu_breakpoint_remove(VAR_0, VAR_1, BP_GDB);",
"#ifndef CONFIG_USER_ONLY\ncase GDB_WATCHPOINT_WRITE:\ncase GDB_WATCHPOINT_READ:\ncase GDB_WATCHPOINT_ACCESS:\nreturn cpu_watchpoint_remove(VAR_0, VAR_1, VAR_2, xlat_gdb_type[VAR_3]);",
"#endif\ndefault:\nreturn -ENOSYS;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9,
11,
13
],
[
15,
17,
19,
21,
23
],
[
25,
27,
29
],
[
31
],
[
33
]
] |
19,486 | static int unin_main_pci_host_init(PCIDevice *d)
{
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_PCI);
d->config[0x08] = 0x00; // revision
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
d->config[0x0C] = 0x08; // cache_line_size
d->config[0x0D] = 0x10; // latency_timer
d->config[0x34] = 0x00; // capabilities_pointer
return 0;
}
| false | qemu | d7b61ecc61f84d23f98f1ee270fb48b41834ca00 | static int unin_main_pci_host_init(PCIDevice *d)
{
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_PCI);
d->config[0x08] = 0x00;
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
d->config[0x0C] = 0x08;
d->config[0x0D] = 0x10;
d->config[0x34] = 0x00;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0)
{
pci_config_set_vendor_id(VAR_0->config, PCI_VENDOR_ID_APPLE);
pci_config_set_device_id(VAR_0->config, PCI_DEVICE_ID_APPLE_UNI_N_PCI);
VAR_0->config[0x08] = 0x00;
pci_config_set_class(VAR_0->config, PCI_CLASS_BRIDGE_HOST);
VAR_0->config[0x0C] = 0x08;
VAR_0->config[0x0D] = 0x10;
VAR_0->config[0x34] = 0x00;
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"pci_config_set_vendor_id(VAR_0->config, PCI_VENDOR_ID_APPLE);",
"pci_config_set_device_id(VAR_0->config, PCI_DEVICE_ID_APPLE_UNI_N_PCI);",
"VAR_0->config[0x08] = 0x00;",
"pci_config_set_class(VAR_0->config, PCI_CLASS_BRIDGE_HOST);",
"VAR_0->config[0x0C] = 0x08;",
"VAR_0->config[0x0D] = 0x10;",
"VAR_0->config[0x34] = 0x00;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
19,487 | VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
{
VirtIOSerial *vser;
VirtIODevice *vdev;
uint32_t i;
if (!max_nr_ports)
return NULL;
vdev = virtio_common_init("virtio-serial", VIRTIO_ID_CONSOLE,
sizeof(struct virtio_console_config),
sizeof(VirtIOSerial));
vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
/* Spawn a new virtio-serial bus on which the ports will ride as devices */
vser->bus = virtser_bus_new(dev);
vser->bus->vser = vser;
QTAILQ_INIT(&vser->ports);
vser->bus->max_nr_ports = max_nr_ports;
vser->ivqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
vser->ovqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
/* Add a queue for host to guest transfers for port 0 (backward compat) */
vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
/* Add a queue for guest to host transfers for port 0 (backward compat) */
vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output);
/* control queue: host to guest */
vser->c_ivq = virtio_add_queue(vdev, 16, control_in);
/* control queue: guest to host */
vser->c_ovq = virtio_add_queue(vdev, 16, control_out);
for (i = 1; i < vser->bus->max_nr_ports; i++) {
/* Add a per-port queue for host to guest transfers */
vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input);
/* Add a per-per queue for guest to host transfers */
vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
}
vser->config.max_nr_ports = max_nr_ports;
vser->ports_map = qemu_mallocz(((max_nr_ports + 31) / 32)
* sizeof(vser->ports_map[0]));
/*
* Reserve location 0 for a console port for backward compat
* (old kernel, new qemu)
*/
mark_port_added(vser, 0);
vser->vdev.get_features = get_features;
vser->vdev.get_config = get_config;
vser->vdev.set_config = set_config;
/*
* Register for the savevm section with the virtio-console name
* to preserve backward compat
*/
register_savevm(dev, "virtio-console", -1, 2, virtio_serial_save,
virtio_serial_load, vser);
return vdev;
}
| false | qemu | 5ab4bb598d3f58542a06a6946f04b140be222892 | VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
{
VirtIOSerial *vser;
VirtIODevice *vdev;
uint32_t i;
if (!max_nr_ports)
return NULL;
vdev = virtio_common_init("virtio-serial", VIRTIO_ID_CONSOLE,
sizeof(struct virtio_console_config),
sizeof(VirtIOSerial));
vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
vser->bus = virtser_bus_new(dev);
vser->bus->vser = vser;
QTAILQ_INIT(&vser->ports);
vser->bus->max_nr_ports = max_nr_ports;
vser->ivqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
vser->ovqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output);
vser->c_ivq = virtio_add_queue(vdev, 16, control_in);
vser->c_ovq = virtio_add_queue(vdev, 16, control_out);
for (i = 1; i < vser->bus->max_nr_ports; i++) {
vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input);
vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
}
vser->config.max_nr_ports = max_nr_ports;
vser->ports_map = qemu_mallocz(((max_nr_ports + 31) / 32)
* sizeof(vser->ports_map[0]));
mark_port_added(vser, 0);
vser->vdev.get_features = get_features;
vser->vdev.get_config = get_config;
vser->vdev.set_config = set_config;
register_savevm(dev, "virtio-console", -1, 2, virtio_serial_save,
virtio_serial_load, vser);
return vdev;
}
| {
"code": [],
"line_no": []
} | VirtIODevice *FUNC_0(DeviceState *dev, uint32_t max_nr_ports)
{
VirtIOSerial *vser;
VirtIODevice *vdev;
uint32_t i;
if (!max_nr_ports)
return NULL;
vdev = virtio_common_init("virtio-serial", VIRTIO_ID_CONSOLE,
sizeof(struct virtio_console_config),
sizeof(VirtIOSerial));
vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
vser->bus = virtser_bus_new(dev);
vser->bus->vser = vser;
QTAILQ_INIT(&vser->ports);
vser->bus->max_nr_ports = max_nr_ports;
vser->ivqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
vser->ovqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output);
vser->c_ivq = virtio_add_queue(vdev, 16, control_in);
vser->c_ovq = virtio_add_queue(vdev, 16, control_out);
for (i = 1; i < vser->bus->max_nr_ports; i++) {
vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input);
vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
}
vser->config.max_nr_ports = max_nr_ports;
vser->ports_map = qemu_mallocz(((max_nr_ports + 31) / 32)
* sizeof(vser->ports_map[0]));
mark_port_added(vser, 0);
vser->vdev.get_features = get_features;
vser->vdev.get_config = get_config;
vser->vdev.set_config = set_config;
register_savevm(dev, "virtio-console", -1, 2, virtio_serial_save,
virtio_serial_load, vser);
return vdev;
}
| [
"VirtIODevice *FUNC_0(DeviceState *dev, uint32_t max_nr_ports)\n{",
"VirtIOSerial *vser;",
"VirtIODevice *vdev;",
"uint32_t i;",
"if (!max_nr_ports)\nreturn NULL;",
"vdev = virtio_common_init(\"virtio-serial\", VIRTIO_ID_CONSOLE,\nsizeof(struct virtio_console_config),\nsizeof(VirtIOSerial));",
"vser = DO_UPCAST(VirtIOSerial, vdev, vdev);",
"vser->bus = virtser_bus_new(dev);",
"vser->bus->vser = vser;",
"QTAILQ_INIT(&vser->ports);",
"vser->bus->max_nr_ports = max_nr_ports;",
"vser->ivqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));",
"vser->ovqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));",
"vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);",
"vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output);",
"vser->c_ivq = virtio_add_queue(vdev, 16, control_in);",
"vser->c_ovq = virtio_add_queue(vdev, 16, control_out);",
"for (i = 1; i < vser->bus->max_nr_ports; i++) {",
"vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input);",
"vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);",
"}",
"vser->config.max_nr_ports = max_nr_ports;",
"vser->ports_map = qemu_mallocz(((max_nr_ports + 31) / 32)\n* sizeof(vser->ports_map[0]));",
"mark_port_added(vser, 0);",
"vser->vdev.get_features = get_features;",
"vser->vdev.get_config = get_config;",
"vser->vdev.set_config = set_config;",
"register_savevm(dev, \"virtio-console\", -1, 2, virtio_serial_save,\nvirtio_serial_load, vser);",
"return vdev;",
"}"
] | [
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
51
],
[
55
],
[
61
],
[
65
],
[
69
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85,
87
],
[
97
],
[
101
],
[
103
],
[
105
],
[
117,
119
],
[
123
],
[
125
]
] |
19,488 | static void pci_vpb_map(SysBusDevice *dev, target_phys_addr_t base)
{
PCIVPBState *s = (PCIVPBState *)dev;
/* Selfconfig area. */
memory_region_add_subregion(get_system_memory(), base + 0x01000000,
&s->mem_config);
/* Normal config area. */
memory_region_add_subregion(get_system_memory(), base + 0x02000000,
&s->mem_config2);
if (s->realview) {
/* IO memory area. */
memory_region_add_subregion(get_system_memory(), base + 0x03000000,
&s->isa);
}
}
| false | qemu | 7d6e771f49c36f4388798ce25bde1dede40cda74 | static void pci_vpb_map(SysBusDevice *dev, target_phys_addr_t base)
{
PCIVPBState *s = (PCIVPBState *)dev;
memory_region_add_subregion(get_system_memory(), base + 0x01000000,
&s->mem_config);
memory_region_add_subregion(get_system_memory(), base + 0x02000000,
&s->mem_config2);
if (s->realview) {
memory_region_add_subregion(get_system_memory(), base + 0x03000000,
&s->isa);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SysBusDevice *VAR_0, target_phys_addr_t VAR_1)
{
PCIVPBState *s = (PCIVPBState *)VAR_0;
memory_region_add_subregion(get_system_memory(), VAR_1 + 0x01000000,
&s->mem_config);
memory_region_add_subregion(get_system_memory(), VAR_1 + 0x02000000,
&s->mem_config2);
if (s->realview) {
memory_region_add_subregion(get_system_memory(), VAR_1 + 0x03000000,
&s->isa);
}
}
| [
"static void FUNC_0(SysBusDevice *VAR_0, target_phys_addr_t VAR_1)\n{",
"PCIVPBState *s = (PCIVPBState *)VAR_0;",
"memory_region_add_subregion(get_system_memory(), VAR_1 + 0x01000000,\n&s->mem_config);",
"memory_region_add_subregion(get_system_memory(), VAR_1 + 0x02000000,\n&s->mem_config2);",
"if (s->realview) {",
"memory_region_add_subregion(get_system_memory(), VAR_1 + 0x03000000,\n&s->isa);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15,
17
],
[
21
],
[
25,
27
],
[
29
],
[
31
]
] |
19,491 | static void qmp_input_start_struct(Visitor *v, const char *name, void **obj,
size_t size, Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
Error *err = NULL;
if (obj) {
*obj = NULL;
}
if (!qobj) {
return;
}
if (qobject_type(qobj) != QTYPE_QDICT) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"QDict");
return;
}
qmp_input_push(qiv, qobj, obj, &err);
if (err) {
error_propagate(errp, err);
return;
}
if (obj) {
*obj = g_malloc0(size);
}
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void qmp_input_start_struct(Visitor *v, const char *name, void **obj,
size_t size, Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
Error *err = NULL;
if (obj) {
*obj = NULL;
}
if (!qobj) {
return;
}
if (qobject_type(qobj) != QTYPE_QDICT) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"QDict");
return;
}
qmp_input_push(qiv, qobj, obj, &err);
if (err) {
error_propagate(errp, err);
return;
}
if (obj) {
*obj = g_malloc0(size);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Visitor *VAR_0, const char *VAR_1, void **VAR_2,
size_t VAR_3, Error **VAR_4)
{
QmpInputVisitor *qiv = to_qiv(VAR_0);
QObject *qobj = qmp_input_get_object(qiv, VAR_1, true, VAR_4);
Error *err = NULL;
if (VAR_2) {
*VAR_2 = NULL;
}
if (!qobj) {
return;
}
if (qobject_type(qobj) != QTYPE_QDICT) {
error_setg(VAR_4, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : "null",
"QDict");
return;
}
qmp_input_push(qiv, qobj, VAR_2, &err);
if (err) {
error_propagate(VAR_4, err);
return;
}
if (VAR_2) {
*VAR_2 = g_malloc0(VAR_3);
}
}
| [
"static void FUNC_0(Visitor *VAR_0, const char *VAR_1, void **VAR_2,\nsize_t VAR_3, Error **VAR_4)\n{",
"QmpInputVisitor *qiv = to_qiv(VAR_0);",
"QObject *qobj = qmp_input_get_object(qiv, VAR_1, true, VAR_4);",
"Error *err = NULL;",
"if (VAR_2) {",
"*VAR_2 = NULL;",
"}",
"if (!qobj) {",
"return;",
"}",
"if (qobject_type(qobj) != QTYPE_QDICT) {",
"error_setg(VAR_4, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : \"null\",\n\"QDict\");",
"return;",
"}",
"qmp_input_push(qiv, qobj, VAR_2, &err);",
"if (err) {",
"error_propagate(VAR_4, err);",
"return;",
"}",
"if (VAR_2) {",
"*VAR_2 = g_malloc0(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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
19,493 | static int read_packet(ByteIOContext *pb, uint8_t *buf, int raw_packet_size)
{
int skip, len;
for(;;) {
len = get_buffer(pb, buf, TS_PACKET_SIZE);
if (len != TS_PACKET_SIZE)
return AVERROR(EIO);
/* check paquet sync byte */
if (buf[0] != 0x47) {
/* find a new packet start */
url_fseek(pb, -TS_PACKET_SIZE, SEEK_CUR);
if (mpegts_resync(pb) < 0)
return AVERROR_INVALIDDATA;
else
continue;
} else {
skip = raw_packet_size - TS_PACKET_SIZE;
if (skip > 0)
url_fskip(pb, skip);
break;
}
}
return 0;
}
| false | FFmpeg | 1303d62d8416fa315a0cc7bbbe35cfdab787ea92 | static int read_packet(ByteIOContext *pb, uint8_t *buf, int raw_packet_size)
{
int skip, len;
for(;;) {
len = get_buffer(pb, buf, TS_PACKET_SIZE);
if (len != TS_PACKET_SIZE)
return AVERROR(EIO);
if (buf[0] != 0x47) {
url_fseek(pb, -TS_PACKET_SIZE, SEEK_CUR);
if (mpegts_resync(pb) < 0)
return AVERROR_INVALIDDATA;
else
continue;
} else {
skip = raw_packet_size - TS_PACKET_SIZE;
if (skip > 0)
url_fskip(pb, skip);
break;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(ByteIOContext *VAR_0, uint8_t *VAR_1, int VAR_2)
{
int VAR_3, VAR_4;
for(;;) {
VAR_4 = get_buffer(VAR_0, VAR_1, TS_PACKET_SIZE);
if (VAR_4 != TS_PACKET_SIZE)
return AVERROR(EIO);
if (VAR_1[0] != 0x47) {
url_fseek(VAR_0, -TS_PACKET_SIZE, SEEK_CUR);
if (mpegts_resync(VAR_0) < 0)
return AVERROR_INVALIDDATA;
else
continue;
} else {
VAR_3 = VAR_2 - TS_PACKET_SIZE;
if (VAR_3 > 0)
url_fskip(VAR_0, VAR_3);
break;
}
}
return 0;
}
| [
"static int FUNC_0(ByteIOContext *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4;",
"for(;;) {",
"VAR_4 = get_buffer(VAR_0, VAR_1, TS_PACKET_SIZE);",
"if (VAR_4 != TS_PACKET_SIZE)\nreturn AVERROR(EIO);",
"if (VAR_1[0] != 0x47) {",
"url_fseek(VAR_0, -TS_PACKET_SIZE, SEEK_CUR);",
"if (mpegts_resync(VAR_0) < 0)\nreturn AVERROR_INVALIDDATA;",
"else\ncontinue;",
"} else {",
"VAR_3 = VAR_2 - TS_PACKET_SIZE;",
"if (VAR_3 > 0)\nurl_fskip(VAR_0, VAR_3);",
"break;",
"}",
"}",
"return 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
],
[
19
],
[
23
],
[
25,
27
],
[
29,
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
19,495 | av_cold void ff_fft_init_arm(FFTContext *s)
{
if (HAVE_NEON) {
s->fft_permute = ff_fft_permute_neon;
s->fft_calc = ff_fft_calc_neon;
s->imdct_calc = ff_imdct_calc_neon;
s->imdct_half = ff_imdct_half_neon;
s->mdct_calc = ff_mdct_calc_neon;
s->permutation = FF_MDCT_PERM_INTERLEAVE;
}
}
| false | FFmpeg | 11ab1e409ff272c8c0bce62f48a3767546547c6c | av_cold void ff_fft_init_arm(FFTContext *s)
{
if (HAVE_NEON) {
s->fft_permute = ff_fft_permute_neon;
s->fft_calc = ff_fft_calc_neon;
s->imdct_calc = ff_imdct_calc_neon;
s->imdct_half = ff_imdct_half_neon;
s->mdct_calc = ff_mdct_calc_neon;
s->permutation = FF_MDCT_PERM_INTERLEAVE;
}
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(FFTContext *s)
{
if (HAVE_NEON) {
s->fft_permute = ff_fft_permute_neon;
s->fft_calc = ff_fft_calc_neon;
s->imdct_calc = ff_imdct_calc_neon;
s->imdct_half = ff_imdct_half_neon;
s->mdct_calc = ff_mdct_calc_neon;
s->permutation = FF_MDCT_PERM_INTERLEAVE;
}
}
| [
"av_cold void FUNC_0(FFTContext *s)\n{",
"if (HAVE_NEON) {",
"s->fft_permute = ff_fft_permute_neon;",
"s->fft_calc = ff_fft_calc_neon;",
"s->imdct_calc = ff_imdct_calc_neon;",
"s->imdct_half = ff_imdct_half_neon;",
"s->mdct_calc = ff_mdct_calc_neon;",
"s->permutation = FF_MDCT_PERM_INTERLEAVE;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
19,496 | static int coroutine_fn bdrv_co_io_em(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *iov,
bool is_write)
{
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
BlockDriverAIOCB *acb;
if (is_write) {
acb = bdrv_aio_writev(bs, sector_num, iov, nb_sectors,
bdrv_co_io_em_complete, &co);
} else {
acb = bdrv_aio_readv(bs, sector_num, iov, nb_sectors,
bdrv_co_io_em_complete, &co);
}
trace_bdrv_co_io_em(bs, sector_num, nb_sectors, is_write, acb);
if (!acb) {
return -EIO;
}
qemu_coroutine_yield();
return co.ret;
}
| false | qemu | a652d16025030013116c4d63883b9e1ec08a4359 | static int coroutine_fn bdrv_co_io_em(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *iov,
bool is_write)
{
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
BlockDriverAIOCB *acb;
if (is_write) {
acb = bdrv_aio_writev(bs, sector_num, iov, nb_sectors,
bdrv_co_io_em_complete, &co);
} else {
acb = bdrv_aio_readv(bs, sector_num, iov, nb_sectors,
bdrv_co_io_em_complete, &co);
}
trace_bdrv_co_io_em(bs, sector_num, nb_sectors, is_write, acb);
if (!acb) {
return -EIO;
}
qemu_coroutine_yield();
return co.ret;
}
| {
"code": [],
"line_no": []
} | static int VAR_0 bdrv_co_io_em(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *iov,
bool is_write)
{
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
BlockDriverAIOCB *acb;
if (is_write) {
acb = bdrv_aio_writev(bs, sector_num, iov, nb_sectors,
bdrv_co_io_em_complete, &co);
} else {
acb = bdrv_aio_readv(bs, sector_num, iov, nb_sectors,
bdrv_co_io_em_complete, &co);
}
trace_bdrv_co_io_em(bs, sector_num, nb_sectors, is_write, acb);
if (!acb) {
return -EIO;
}
qemu_coroutine_yield();
return co.ret;
}
| [
"static int VAR_0 bdrv_co_io_em(BlockDriverState *bs, int64_t sector_num,\nint nb_sectors, QEMUIOVector *iov,\nbool is_write)\n{",
"CoroutineIOCompletion co = {",
".coroutine = qemu_coroutine_self(),\n};",
"BlockDriverAIOCB *acb;",
"if (is_write) {",
"acb = bdrv_aio_writev(bs, sector_num, iov, nb_sectors,\nbdrv_co_io_em_complete, &co);",
"} else {",
"acb = bdrv_aio_readv(bs, sector_num, iov, nb_sectors,\nbdrv_co_io_em_complete, &co);",
"}",
"trace_bdrv_co_io_em(bs, sector_num, nb_sectors, is_write, acb);",
"if (!acb) {",
"return -EIO;",
"}",
"qemu_coroutine_yield();",
"return co.ret;",
"}"
] | [
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
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.